teodor-new-chat-ui 4.1.11 → 4.1.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.umd.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(Ee,S){typeof exports=="object"&&typeof module<"u"?S(exports,require("react"),require("lucide-react"),require("@radix-ui/react-slot"),require("class-variance-authority"),require("clsx"),require("tailwind-merge"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","lucide-react","@radix-ui/react-slot","class-variance-authority","clsx","tailwind-merge","react-dom"],S):(Ee=typeof globalThis<"u"?globalThis:Ee||self,S(Ee.NewChatUI={},Ee.React,Ee.LucideReact,Ee.reactSlot,Ee.classVarianceAuthority,Ee.clsx,Ee.tailwindMerge,Ee.ReactDOM))})(this,function(Ee,S,ee,_n,Qr,wp,bp,_s){"use strict";var cC=Object.defineProperty;var uC=(Ee,S,ee)=>S in Ee?cC(Ee,S,{enumerable:!0,configurable:!0,writable:!0,value:ee}):Ee[S]=ee;var xp=(Ee,S,ee)=>uC(Ee,typeof S!="symbol"?S+"":S,ee);function Da(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const m=Da(S),eo=Da(_s);var Rs={exports:{}},wr={};/**
1
+ (function(ke,S){typeof exports=="object"&&typeof module<"u"?S(exports,require("react"),require("lucide-react"),require("@radix-ui/react-slot"),require("class-variance-authority"),require("clsx"),require("tailwind-merge"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","lucide-react","@radix-ui/react-slot","class-variance-authority","clsx","tailwind-merge","react-dom"],S):(ke=typeof globalThis<"u"?globalThis:ke||self,S(ke.NewChatUI={},ke.React,ke.LucideReact,ke.reactSlot,ke.classVarianceAuthority,ke.clsx,ke.tailwindMerge,ke.ReactDOM))})(this,function(ke,S,ee,_n,Qr,wp,bp,_s){"use strict";var cC=Object.defineProperty;var uC=(ke,S,ee)=>S in ke?cC(ke,S,{enumerable:!0,configurable:!0,writable:!0,value:ee}):ke[S]=ee;var xp=(ke,S,ee)=>uC(ke,typeof S!="symbol"?S+"":S,ee);function Da(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const m=Da(S),eo=Da(_s);var Rs={exports:{}},wr={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.min.js
4
4
  *
@@ -14,41 +14,41 @@
14
14
  *
15
15
  * This source code is licensed under the MIT license found in the
16
16
  * LICENSE file in the root directory of this source tree.
17
- */var Fa;function Sp(){return Fa||(Fa=1,process.env.NODE_ENV!=="production"&&function(){var e=S,t=Symbol.for("react.element"),n=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),a=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),f=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),p=Symbol.for("react.offscreen"),w=Symbol.iterator,v="@@iterator";function g(k){if(k===null||typeof k!="object")return null;var H=w&&k[w]||k[v];return typeof H=="function"?H:null}var x=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function b(k){{for(var H=arguments.length,te=new Array(H>1?H-1:0),ke=1;ke<H;ke++)te[ke-1]=arguments[ke];y("error",k,te)}}function y(k,H,te){{var ke=x.ReactDebugCurrentFrame,qe=ke.getStackAddendum();qe!==""&&(H+="%s",te=te.concat([qe]));var Ze=te.map(function(He){return String(He)});Ze.unshift("Warning: "+H),Function.prototype.apply.call(console[k],console,Ze)}}var E=!1,C=!1,T=!1,I=!1,A=!1,R;R=Symbol.for("react.module.reference");function j(k){return!!(typeof k=="string"||typeof k=="function"||k===r||k===s||A||k===o||k===u||k===d||I||k===p||E||C||T||typeof k=="object"&&k!==null&&(k.$$typeof===h||k.$$typeof===f||k.$$typeof===i||k.$$typeof===a||k.$$typeof===l||k.$$typeof===R||k.getModuleId!==void 0))}function M(k,H,te){var ke=k.displayName;if(ke)return ke;var qe=H.displayName||H.name||"";return qe!==""?te+"("+qe+")":te}function D(k){return k.displayName||"Context"}function L(k){if(k==null)return null;if(typeof k.tag=="number"&&b("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof k=="function")return k.displayName||k.name||null;if(typeof k=="string")return k;switch(k){case r:return"Fragment";case n:return"Portal";case s:return"Profiler";case o:return"StrictMode";case u:return"Suspense";case d:return"SuspenseList"}if(typeof k=="object")switch(k.$$typeof){case a:var H=k;return D(H)+".Consumer";case i:var te=k;return D(te._context)+".Provider";case l:return M(k,k.render,"ForwardRef");case f:var ke=k.displayName||null;return ke!==null?ke:L(k.type)||"Memo";case h:{var qe=k,Ze=qe._payload,He=qe._init;try{return L(He(Ze))}catch{return null}}}return null}var P=Object.assign,V=0,U,q,$,N,W,Y,de;function se(){}se.__reactDisabledLog=!0;function pe(){{if(V===0){U=console.log,q=console.info,$=console.warn,N=console.error,W=console.group,Y=console.groupCollapsed,de=console.groupEnd;var k={configurable:!0,enumerable:!0,value:se,writable:!0};Object.defineProperties(console,{info:k,log:k,warn:k,error:k,group:k,groupCollapsed:k,groupEnd:k})}V++}}function me(){{if(V--,V===0){var k={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:P({},k,{value:U}),info:P({},k,{value:q}),warn:P({},k,{value:$}),error:P({},k,{value:N}),group:P({},k,{value:W}),groupCollapsed:P({},k,{value:Y}),groupEnd:P({},k,{value:de})})}V<0&&b("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var Se=x.ReactCurrentDispatcher,B;function O(k,H,te){{if(B===void 0)try{throw Error()}catch(qe){var ke=qe.stack.trim().match(/\n( *(at )?)/);B=ke&&ke[1]||""}return`
18
- `+B+k}}var G=!1,Z;{var ce=typeof WeakMap=="function"?WeakMap:Map;Z=new ce}function ie(k,H){if(!k||G)return"";{var te=Z.get(k);if(te!==void 0)return te}var ke;G=!0;var qe=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var Ze;Ze=Se.current,Se.current=null,pe();try{if(H){var He=function(){throw Error()};if(Object.defineProperty(He.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(He,[])}catch(Et){ke=Et}Reflect.construct(k,[],He)}else{try{He.call()}catch(Et){ke=Et}k.call(He.prototype)}}else{try{throw Error()}catch(Et){ke=Et}k()}}catch(Et){if(Et&&ke&&typeof Et.stack=="string"){for(var $e=Et.stack.split(`
19
- `),St=ke.stack.split(`
17
+ */var Fa;function Sp(){return Fa||(Fa=1,process.env.NODE_ENV!=="production"&&function(){var e=S,t=Symbol.for("react.element"),n=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),a=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),f=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),p=Symbol.for("react.offscreen"),w=Symbol.iterator,v="@@iterator";function g(E){if(E===null||typeof E!="object")return null;var H=w&&E[w]||E[v];return typeof H=="function"?H:null}var x=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function b(E){{for(var H=arguments.length,te=new Array(H>1?H-1:0),Ee=1;Ee<H;Ee++)te[Ee-1]=arguments[Ee];y("error",E,te)}}function y(E,H,te){{var Ee=x.ReactDebugCurrentFrame,qe=Ee.getStackAddendum();qe!==""&&(H+="%s",te=te.concat([qe]));var Ze=te.map(function(He){return String(He)});Ze.unshift("Warning: "+H),Function.prototype.apply.call(console[E],console,Ze)}}var k=!1,C=!1,T=!1,I=!1,A=!1,R;R=Symbol.for("react.module.reference");function j(E){return!!(typeof E=="string"||typeof E=="function"||E===r||E===s||A||E===o||E===u||E===d||I||E===p||k||C||T||typeof E=="object"&&E!==null&&(E.$$typeof===h||E.$$typeof===f||E.$$typeof===i||E.$$typeof===a||E.$$typeof===l||E.$$typeof===R||E.getModuleId!==void 0))}function M(E,H,te){var Ee=E.displayName;if(Ee)return Ee;var qe=H.displayName||H.name||"";return qe!==""?te+"("+qe+")":te}function D(E){return E.displayName||"Context"}function L(E){if(E==null)return null;if(typeof E.tag=="number"&&b("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof E=="function")return E.displayName||E.name||null;if(typeof E=="string")return E;switch(E){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 E=="object")switch(E.$$typeof){case a:var H=E;return D(H)+".Consumer";case i:var te=E;return D(te._context)+".Provider";case l:return M(E,E.render,"ForwardRef");case f:var Ee=E.displayName||null;return Ee!==null?Ee:L(E.type)||"Memo";case h:{var qe=E,Ze=qe._payload,He=qe._init;try{return L(He(Ze))}catch{return null}}}return null}var P=Object.assign,V=0,U,q,F,N,W,Y,de;function se(){}se.__reactDisabledLog=!0;function pe(){{if(V===0){U=console.log,q=console.info,F=console.warn,N=console.error,W=console.group,Y=console.groupCollapsed,de=console.groupEnd;var E={configurable:!0,enumerable:!0,value:se,writable:!0};Object.defineProperties(console,{info:E,log:E,warn:E,error:E,group:E,groupCollapsed:E,groupEnd:E})}V++}}function ge(){{if(V--,V===0){var E={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:P({},E,{value:U}),info:P({},E,{value:q}),warn:P({},E,{value:F}),error:P({},E,{value:N}),group:P({},E,{value:W}),groupCollapsed:P({},E,{value:Y}),groupEnd:P({},E,{value:de})})}V<0&&b("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var Se=x.ReactCurrentDispatcher,B;function O(E,H,te){{if(B===void 0)try{throw Error()}catch(qe){var Ee=qe.stack.trim().match(/\n( *(at )?)/);B=Ee&&Ee[1]||""}return`
18
+ `+B+E}}var G=!1,Z;{var ce=typeof WeakMap=="function"?WeakMap:Map;Z=new ce}function ie(E,H){if(!E||G)return"";{var te=Z.get(E);if(te!==void 0)return te}var Ee;G=!0;var qe=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var Ze;Ze=Se.current,Se.current=null,pe();try{if(H){var He=function(){throw Error()};if(Object.defineProperty(He.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(He,[])}catch(kt){Ee=kt}Reflect.construct(E,[],He)}else{try{He.call()}catch(kt){Ee=kt}E.call(He.prototype)}}else{try{throw Error()}catch(kt){Ee=kt}E()}}catch(kt){if(kt&&Ee&&typeof kt.stack=="string"){for(var $e=kt.stack.split(`
19
+ `),St=Ee.stack.split(`
20
20
  `),ut=$e.length-1,ft=St.length-1;ut>=1&&ft>=0&&$e[ut]!==St[ft];)ft--;for(;ut>=1&&ft>=0;ut--,ft--)if($e[ut]!==St[ft]){if(ut!==1||ft!==1)do if(ut--,ft--,ft<0||$e[ut]!==St[ft]){var Ht=`
21
- `+$e[ut].replace(" at new "," at ");return k.displayName&&Ht.includes("<anonymous>")&&(Ht=Ht.replace("<anonymous>",k.displayName)),typeof k=="function"&&Z.set(k,Ht),Ht}while(ut>=1&&ft>=0);break}}}finally{G=!1,Se.current=Ze,me(),Error.prepareStackTrace=qe}var vr=k?k.displayName||k.name:"",Zn=vr?O(vr):"";return typeof k=="function"&&Z.set(k,Zn),Zn}function De(k,H,te){return ie(k,!1)}function Xe(k){var H=k.prototype;return!!(H&&H.isReactComponent)}function Je(k,H,te){if(k==null)return"";if(typeof k=="function")return ie(k,Xe(k));if(typeof k=="string")return O(k);switch(k){case u:return O("Suspense");case d:return O("SuspenseList")}if(typeof k=="object")switch(k.$$typeof){case l:return De(k.render);case f:return Je(k.type,H,te);case h:{var ke=k,qe=ke._payload,Ze=ke._init;try{return Je(Ze(qe),H,te)}catch{}}}return""}var Ne=Object.prototype.hasOwnProperty,Oe={},Qe=x.ReactDebugCurrentFrame;function Re(k){if(k){var H=k._owner,te=Je(k.type,k._source,H?H.type:null);Qe.setExtraStackFrame(te)}else Qe.setExtraStackFrame(null)}function st(k,H,te,ke,qe){{var Ze=Function.call.bind(Ne);for(var He in k)if(Ze(k,He)){var $e=void 0;try{if(typeof k[He]!="function"){var St=Error((ke||"React class")+": "+te+" type `"+He+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof k[He]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw St.name="Invariant Violation",St}$e=k[He](H,He,ke,te,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(ut){$e=ut}$e&&!($e instanceof Error)&&(Re(qe),b("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",ke||"React class",te,He,typeof $e),Re(null)),$e instanceof Error&&!($e.message in Oe)&&(Oe[$e.message]=!0,Re(qe),b("Failed %s type: %s",te,$e.message),Re(null))}}}var ct=Array.isArray;function Q(k){return ct(k)}function le(k){{var H=typeof Symbol=="function"&&Symbol.toStringTag,te=H&&k[Symbol.toStringTag]||k.constructor.name||"Object";return te}}function ge(k){try{return Ce(k),!1}catch{return!0}}function Ce(k){return""+k}function we(k){if(ge(k))return b("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",le(k)),Ce(k)}var _e=x.ReactCurrentOwner,et={key:!0,ref:!0,__self:!0,__source:!0},Ke,F;function J(k){if(Ne.call(k,"ref")){var H=Object.getOwnPropertyDescriptor(k,"ref").get;if(H&&H.isReactWarning)return!1}return k.ref!==void 0}function Te(k){if(Ne.call(k,"key")){var H=Object.getOwnPropertyDescriptor(k,"key").get;if(H&&H.isReactWarning)return!1}return k.key!==void 0}function Me(k,H){typeof k.ref=="string"&&_e.current}function Le(k,H){{var te=function(){Ke||(Ke=!0,b("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",H))};te.isReactWarning=!0,Object.defineProperty(k,"key",{get:te,configurable:!0})}}function it(k,H){{var te=function(){F||(F=!0,b("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",H))};te.isReactWarning=!0,Object.defineProperty(k,"ref",{get:te,configurable:!0})}}var Ot=function(k,H,te,ke,qe,Ze,He){var $e={$$typeof:t,type:k,key:H,ref:te,props:He,_owner:Ze};return $e._store={},Object.defineProperty($e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty($e,"_self",{configurable:!1,enumerable:!1,writable:!1,value:ke}),Object.defineProperty($e,"_source",{configurable:!1,enumerable:!1,writable:!1,value:qe}),Object.freeze&&(Object.freeze($e.props),Object.freeze($e)),$e};function gr(k,H,te,ke,qe){{var Ze,He={},$e=null,St=null;te!==void 0&&(we(te),$e=""+te),Te(H)&&(we(H.key),$e=""+H.key),J(H)&&(St=H.ref,Me(H,qe));for(Ze in H)Ne.call(H,Ze)&&!et.hasOwnProperty(Ze)&&(He[Ze]=H[Ze]);if(k&&k.defaultProps){var ut=k.defaultProps;for(Ze in ut)He[Ze]===void 0&&(He[Ze]=ut[Ze])}if($e||St){var ft=typeof k=="function"?k.displayName||k.name||"Unknown":k;$e&&Le(He,ft),St&&it(He,ft)}return Ot(k,$e,St,qe,ke,_e.current,He)}}var Xn=x.ReactCurrentOwner,xr=x.ReactDebugCurrentFrame;function cn(k){if(k){var H=k._owner,te=Je(k.type,k._source,H?H.type:null);xr.setExtraStackFrame(te)}else xr.setExtraStackFrame(null)}var Jn;Jn=!1;function jn(k){return typeof k=="object"&&k!==null&&k.$$typeof===t}function un(){{if(Xn.current){var k=L(Xn.current.type);if(k)return`
21
+ `+$e[ut].replace(" at new "," at ");return E.displayName&&Ht.includes("<anonymous>")&&(Ht=Ht.replace("<anonymous>",E.displayName)),typeof E=="function"&&Z.set(E,Ht),Ht}while(ut>=1&&ft>=0);break}}}finally{G=!1,Se.current=Ze,ge(),Error.prepareStackTrace=qe}var vr=E?E.displayName||E.name:"",Zn=vr?O(vr):"";return typeof E=="function"&&Z.set(E,Zn),Zn}function De(E,H,te){return ie(E,!1)}function Xe(E){var H=E.prototype;return!!(H&&H.isReactComponent)}function Je(E,H,te){if(E==null)return"";if(typeof E=="function")return ie(E,Xe(E));if(typeof E=="string")return O(E);switch(E){case u:return O("Suspense");case d:return O("SuspenseList")}if(typeof E=="object")switch(E.$$typeof){case l:return De(E.render);case f:return Je(E.type,H,te);case h:{var Ee=E,qe=Ee._payload,Ze=Ee._init;try{return Je(Ze(qe),H,te)}catch{}}}return""}var Ne=Object.prototype.hasOwnProperty,Oe={},Qe=x.ReactDebugCurrentFrame;function Re(E){if(E){var H=E._owner,te=Je(E.type,E._source,H?H.type:null);Qe.setExtraStackFrame(te)}else Qe.setExtraStackFrame(null)}function st(E,H,te,Ee,qe){{var Ze=Function.call.bind(Ne);for(var He in E)if(Ze(E,He)){var $e=void 0;try{if(typeof E[He]!="function"){var St=Error((Ee||"React class")+": "+te+" type `"+He+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof E[He]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw St.name="Invariant Violation",St}$e=E[He](H,He,Ee,te,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(ut){$e=ut}$e&&!($e instanceof Error)&&(Re(qe),b("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",Ee||"React class",te,He,typeof $e),Re(null)),$e instanceof Error&&!($e.message in Oe)&&(Oe[$e.message]=!0,Re(qe),b("Failed %s type: %s",te,$e.message),Re(null))}}}var ct=Array.isArray;function Q(E){return ct(E)}function le(E){{var H=typeof Symbol=="function"&&Symbol.toStringTag,te=H&&E[Symbol.toStringTag]||E.constructor.name||"Object";return te}}function me(E){try{return Ce(E),!1}catch{return!0}}function Ce(E){return""+E}function we(E){if(me(E))return b("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",le(E)),Ce(E)}var _e=x.ReactCurrentOwner,et={key:!0,ref:!0,__self:!0,__source:!0},Ke,$;function J(E){if(Ne.call(E,"ref")){var H=Object.getOwnPropertyDescriptor(E,"ref").get;if(H&&H.isReactWarning)return!1}return E.ref!==void 0}function Te(E){if(Ne.call(E,"key")){var H=Object.getOwnPropertyDescriptor(E,"key").get;if(H&&H.isReactWarning)return!1}return E.key!==void 0}function Me(E,H){typeof E.ref=="string"&&_e.current}function Le(E,H){{var te=function(){Ke||(Ke=!0,b("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",H))};te.isReactWarning=!0,Object.defineProperty(E,"key",{get:te,configurable:!0})}}function it(E,H){{var te=function(){$||($=!0,b("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",H))};te.isReactWarning=!0,Object.defineProperty(E,"ref",{get:te,configurable:!0})}}var Ot=function(E,H,te,Ee,qe,Ze,He){var $e={$$typeof:t,type:E,key:H,ref:te,props:He,_owner:Ze};return $e._store={},Object.defineProperty($e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty($e,"_self",{configurable:!1,enumerable:!1,writable:!1,value:Ee}),Object.defineProperty($e,"_source",{configurable:!1,enumerable:!1,writable:!1,value:qe}),Object.freeze&&(Object.freeze($e.props),Object.freeze($e)),$e};function gr(E,H,te,Ee,qe){{var Ze,He={},$e=null,St=null;te!==void 0&&(we(te),$e=""+te),Te(H)&&(we(H.key),$e=""+H.key),J(H)&&(St=H.ref,Me(H,qe));for(Ze in H)Ne.call(H,Ze)&&!et.hasOwnProperty(Ze)&&(He[Ze]=H[Ze]);if(E&&E.defaultProps){var ut=E.defaultProps;for(Ze in ut)He[Ze]===void 0&&(He[Ze]=ut[Ze])}if($e||St){var ft=typeof E=="function"?E.displayName||E.name||"Unknown":E;$e&&Le(He,ft),St&&it(He,ft)}return Ot(E,$e,St,qe,Ee,_e.current,He)}}var Xn=x.ReactCurrentOwner,xr=x.ReactDebugCurrentFrame;function cn(E){if(E){var H=E._owner,te=Je(E.type,E._source,H?H.type:null);xr.setExtraStackFrame(te)}else xr.setExtraStackFrame(null)}var Jn;Jn=!1;function jn(E){return typeof E=="object"&&E!==null&&E.$$typeof===t}function un(){{if(Xn.current){var E=L(Xn.current.type);if(E)return`
22
22
 
23
- Check the render method of \``+k+"`."}return""}}function Ns(k){return""}var Jr={};function Oa(k){{var H=un();if(!H){var te=typeof k=="string"?k:k.displayName||k.name;te&&(H=`
23
+ Check the render method of \``+E+"`."}return""}}function Ns(E){return""}var Jr={};function Oa(E){{var H=un();if(!H){var te=typeof E=="string"?E:E.displayName||E.name;te&&(H=`
24
24
 
25
- Check the top-level render call using <`+te+">.")}return H}}function ae(k,H){{if(!k._store||k._store.validated||k.key!=null)return;k._store.validated=!0;var te=Oa(H);if(Jr[te])return;Jr[te]=!0;var ke="";k&&k._owner&&k._owner!==Xn.current&&(ke=" It was passed a child from "+L(k._owner.type)+"."),cn(k),b('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',te,ke),cn(null)}}function xe(k,H){{if(typeof k!="object")return;if(Q(k))for(var te=0;te<k.length;te++){var ke=k[te];jn(ke)&&ae(ke,H)}else if(jn(k))k._store&&(k._store.validated=!0);else if(k){var qe=g(k);if(typeof qe=="function"&&qe!==k.entries)for(var Ze=qe.call(k),He;!(He=Ze.next()).done;)jn(He.value)&&ae(He.value,H)}}}function Be(k){{var H=k.type;if(H==null||typeof H=="string")return;var te;if(typeof H=="function")te=H.propTypes;else if(typeof H=="object"&&(H.$$typeof===l||H.$$typeof===f))te=H.propTypes;else return;if(te){var ke=L(H);st(te,k.props,"prop",ke,k)}else if(H.PropTypes!==void 0&&!Jn){Jn=!0;var qe=L(H);b("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",qe||"Unknown")}typeof H.getDefaultProps=="function"&&!H.getDefaultProps.isReactClassApproved&&b("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function ot(k){{for(var H=Object.keys(k.props),te=0;te<H.length;te++){var ke=H[te];if(ke!=="children"&&ke!=="key"){cn(k),b("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",ke),cn(null);break}}k.ref!==null&&(cn(k),b("Invalid attribute `ref` supplied to `React.Fragment`."),cn(null))}}var Mt={};function dn(k,H,te,ke,qe,Ze){{var He=j(k);if(!He){var $e="";(k===void 0||typeof k=="object"&&k!==null&&Object.keys(k).length===0)&&($e+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var St=Ns();St?$e+=St:$e+=un();var ut;k===null?ut="null":Q(k)?ut="array":k!==void 0&&k.$$typeof===t?(ut="<"+(L(k.type)||"Unknown")+" />",$e=" Did you accidentally export a JSX literal instead of a component?"):ut=typeof k,b("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",ut,$e)}var ft=gr(k,H,te,qe,Ze);if(ft==null)return ft;if(He){var Ht=H.children;if(Ht!==void 0)if(ke)if(Q(Ht)){for(var vr=0;vr<Ht.length;vr++)xe(Ht[vr],k);Object.freeze&&Object.freeze(Ht)}else b("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else xe(Ht,k)}if(Ne.call(H,"key")){var Zn=L(k),Et=Object.keys(H).filter(function(lC){return lC!=="key"}),Ma=Et.length>0?"{key: someKey, "+Et.join(": ..., ")+": ...}":"{key: someKey}";if(!Mt[Zn+Ma]){var aC=Et.length>0?"{"+Et.join(": ..., ")+": ...}":"{}";b(`A props object containing a "key" prop is being spread into JSX:
25
+ Check the top-level render call using <`+te+">.")}return H}}function ae(E,H){{if(!E._store||E._store.validated||E.key!=null)return;E._store.validated=!0;var te=Oa(H);if(Jr[te])return;Jr[te]=!0;var Ee="";E&&E._owner&&E._owner!==Xn.current&&(Ee=" It was passed a child from "+L(E._owner.type)+"."),cn(E),b('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',te,Ee),cn(null)}}function xe(E,H){{if(typeof E!="object")return;if(Q(E))for(var te=0;te<E.length;te++){var Ee=E[te];jn(Ee)&&ae(Ee,H)}else if(jn(E))E._store&&(E._store.validated=!0);else if(E){var qe=g(E);if(typeof qe=="function"&&qe!==E.entries)for(var Ze=qe.call(E),He;!(He=Ze.next()).done;)jn(He.value)&&ae(He.value,H)}}}function Be(E){{var H=E.type;if(H==null||typeof H=="string")return;var te;if(typeof H=="function")te=H.propTypes;else if(typeof H=="object"&&(H.$$typeof===l||H.$$typeof===f))te=H.propTypes;else return;if(te){var Ee=L(H);st(te,E.props,"prop",Ee,E)}else if(H.PropTypes!==void 0&&!Jn){Jn=!0;var qe=L(H);b("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",qe||"Unknown")}typeof H.getDefaultProps=="function"&&!H.getDefaultProps.isReactClassApproved&&b("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function ot(E){{for(var H=Object.keys(E.props),te=0;te<H.length;te++){var Ee=H[te];if(Ee!=="children"&&Ee!=="key"){cn(E),b("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",Ee),cn(null);break}}E.ref!==null&&(cn(E),b("Invalid attribute `ref` supplied to `React.Fragment`."),cn(null))}}var Mt={};function dn(E,H,te,Ee,qe,Ze){{var He=j(E);if(!He){var $e="";(E===void 0||typeof E=="object"&&E!==null&&Object.keys(E).length===0)&&($e+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var St=Ns();St?$e+=St:$e+=un();var ut;E===null?ut="null":Q(E)?ut="array":E!==void 0&&E.$$typeof===t?(ut="<"+(L(E.type)||"Unknown")+" />",$e=" Did you accidentally export a JSX literal instead of a component?"):ut=typeof E,b("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",ut,$e)}var ft=gr(E,H,te,qe,Ze);if(ft==null)return ft;if(He){var Ht=H.children;if(Ht!==void 0)if(Ee)if(Q(Ht)){for(var vr=0;vr<Ht.length;vr++)xe(Ht[vr],E);Object.freeze&&Object.freeze(Ht)}else b("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else xe(Ht,E)}if(Ne.call(H,"key")){var Zn=L(E),kt=Object.keys(H).filter(function(lC){return lC!=="key"}),Ma=kt.length>0?"{key: someKey, "+kt.join(": ..., ")+": ...}":"{key: someKey}";if(!Mt[Zn+Ma]){var aC=kt.length>0?"{"+kt.join(": ..., ")+": ...}":"{}";b(`A props object containing a "key" prop is being spread into JSX:
26
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} />`,Ma,Zn,aC,Zn),Mt[Zn+Ma]=!0}}return k===r?ot(ft):Be(ft),ft}}function Zr(k,H,te){return dn(k,H,te,!0)}function As(k,H,te){return dn(k,H,te,!1)}var js=As,gn=Zr;br.Fragment=r,br.jsx=js,br.jsxs=gn}()),br}process.env.NODE_ENV==="production"?Rs.exports=yp():Rs.exports=Sp();var c=Rs.exports;function $a(e,t){return function(){return e.apply(t,arguments)}}const{toString:Cp}=Object.prototype,{getPrototypeOf:Ps}=Object,{iterator:to,toStringTag:za}=Symbol,no=(e=>t=>{const n=Cp.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),Ut=e=>(e=e.toLowerCase(),t=>no(t)===e),ro=e=>t=>typeof t===e,{isArray:Qn}=Array,er=ro("undefined");function yr(e){return e!==null&&!er(e)&&e.constructor!==null&&!er(e.constructor)&&Ct(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Ba=Ut("ArrayBuffer");function Tp(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&Ba(e.buffer),t}const kp=ro("string"),Ct=ro("function"),Ha=ro("number"),Sr=e=>e!==null&&typeof e=="object",Ep=e=>e===!0||e===!1,oo=e=>{if(no(e)!=="object")return!1;const t=Ps(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(za in e)&&!(to in e)},Ip=e=>{if(!Sr(e)||yr(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},Np=Ut("Date"),Ap=Ut("File"),jp=Ut("Blob"),_p=Ut("FileList"),Rp=e=>Sr(e)&&Ct(e.pipe),Pp=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||Ct(e.append)&&((t=no(e))==="formdata"||t==="object"&&Ct(e.toString)&&e.toString()==="[object FormData]"))},Op=Ut("URLSearchParams"),[Mp,Dp,Lp,Fp]=["ReadableStream","Request","Response","Headers"].map(Ut),$p=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Cr(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,o;if(typeof e!="object"&&(e=[e]),Qn(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{if(yr(e))return;const s=n?Object.getOwnPropertyNames(e):Object.keys(e),i=s.length;let a;for(r=0;r<i;r++)a=s[r],t.call(null,e[a],a,e)}}function Ua(e,t){if(yr(e))return null;t=t.toLowerCase();const n=Object.keys(e);let r=n.length,o;for(;r-- >0;)if(o=n[r],t===o.toLowerCase())return o;return null}const Rn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Wa=e=>!er(e)&&e!==Rn;function Os(){const{caseless:e,skipUndefined:t}=Wa(this)&&this||{},n={},r=(o,s)=>{const i=e&&Ua(n,s)||s;oo(n[i])&&oo(o)?n[i]=Os(n[i],o):oo(o)?n[i]=Os({},o):Qn(o)?n[i]=o.slice():(!t||!er(o))&&(n[i]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&Cr(arguments[o],r);return n}const zp=(e,t,n,{allOwnKeys:r}={})=>(Cr(t,(o,s)=>{n&&Ct(o)?e[s]=$a(o,n):e[s]=o},{allOwnKeys:r}),e),Bp=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Hp=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},Up=(e,t,n,r)=>{let o,s,i;const a={};if(t=t||{},e==null)return t;do{for(o=Object.getOwnPropertyNames(e),s=o.length;s-- >0;)i=o[s],(!r||r(i,e,t))&&!a[i]&&(t[i]=e[i],a[i]=!0);e=n!==!1&&Ps(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},Wp=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return r!==-1&&r===n},Vp=e=>{if(!e)return null;if(Qn(e))return e;let t=e.length;if(!Ha(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Kp=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&Ps(Uint8Array)),qp=(e,t)=>{const r=(e&&e[to]).call(e);let o;for(;(o=r.next())&&!o.done;){const s=o.value;t.call(e,s[0],s[1])}},Gp=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},Yp=Ut("HTMLFormElement"),Xp=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),Va=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),Jp=Ut("RegExp"),Ka=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};Cr(n,(o,s)=>{let i;(i=t(o,s,e))!==!1&&(r[s]=i||o)}),Object.defineProperties(e,r)},Zp=e=>{Ka(e,(t,n)=>{if(Ct(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(Ct(r)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},Qp=(e,t)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return Qn(e)?r(e):r(String(e).split(t)),n},em=()=>{},tm=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function nm(e){return!!(e&&Ct(e.append)&&e[za]==="FormData"&&e[to])}const rm=e=>{const t=new Array(10),n=(r,o)=>{if(Sr(r)){if(t.indexOf(r)>=0)return;if(yr(r))return r;if(!("toJSON"in r)){t[o]=r;const s=Qn(r)?[]:{};return Cr(r,(i,a)=>{const l=n(i,o+1);!er(l)&&(s[a]=l)}),t[o]=void 0,s}}return r};return n(e,0)},om=Ut("AsyncFunction"),sm=e=>e&&(Sr(e)||Ct(e))&&Ct(e.then)&&Ct(e.catch),qa=((e,t)=>e?setImmediate:t?((n,r)=>(Rn.addEventListener("message",({source:o,data:s})=>{o===Rn&&s===n&&r.length&&r.shift()()},!1),o=>{r.push(o),Rn.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",Ct(Rn.postMessage)),im=typeof queueMicrotask<"u"?queueMicrotask.bind(Rn):typeof process<"u"&&process.nextTick||qa,_={isArray:Qn,isArrayBuffer:Ba,isBuffer:yr,isFormData:Pp,isArrayBufferView:Tp,isString:kp,isNumber:Ha,isBoolean:Ep,isObject:Sr,isPlainObject:oo,isEmptyObject:Ip,isReadableStream:Mp,isRequest:Dp,isResponse:Lp,isHeaders:Fp,isUndefined:er,isDate:Np,isFile:Ap,isBlob:jp,isRegExp:Jp,isFunction:Ct,isStream:Rp,isURLSearchParams:Op,isTypedArray:Kp,isFileList:_p,forEach:Cr,merge:Os,extend:zp,trim:$p,stripBOM:Bp,inherits:Hp,toFlatObject:Up,kindOf:no,kindOfTest:Ut,endsWith:Wp,toArray:Vp,forEachEntry:qp,matchAll:Gp,isHTMLForm:Yp,hasOwnProperty:Va,hasOwnProp:Va,reduceDescriptors:Ka,freezeMethods:Zp,toObjectSet:Qp,toCamelCase:Xp,noop:em,toFiniteNumber:tm,findKey:Ua,global:Rn,isContextDefined:Wa,isSpecCompliantForm:nm,toJSONObject:rm,isAsyncFn:om,isThenable:sm,setImmediate:qa,asap:im,isIterable:e=>e!=null&&Ct(e[to])};function Ae(e,t,n,r,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),o&&(this.response=o,this.status=o.status?o.status:null)}_.inherits(Ae,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:_.toJSONObject(this.config),code:this.code,status:this.status}}});const Ga=Ae.prototype,Ya={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{Ya[e]={value:e}}),Object.defineProperties(Ae,Ya),Object.defineProperty(Ga,"isAxiosError",{value:!0}),Ae.from=(e,t,n,r,o,s)=>{const i=Object.create(Ga);_.toFlatObject(e,i,function(d){return d!==Error.prototype},u=>u!=="isAxiosError");const a=e&&e.message?e.message:"Error",l=t==null&&e?e.code:t;return Ae.call(i,a,l,n,r,o),e&&i.cause==null&&Object.defineProperty(i,"cause",{value:e,configurable:!0}),i.name=e&&e.name||"Error",s&&Object.assign(i,s),i};const am=null;function Ms(e){return _.isPlainObject(e)||_.isArray(e)}function Xa(e){return _.endsWith(e,"[]")?e.slice(0,-2):e}function Ja(e,t,n){return e?e.concat(t).map(function(o,s){return o=Xa(o),!n&&s?"["+o+"]":o}).join(n?".":""):t}function lm(e){return _.isArray(e)&&!e.some(Ms)}const cm=_.toFlatObject(_,{},null,function(t){return/^is[A-Z]/.test(t)});function so(e,t,n){if(!_.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=_.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(v,g){return!_.isUndefined(g[v])});const r=n.metaTokens,o=n.visitor||d,s=n.dots,i=n.indexes,l=(n.Blob||typeof Blob<"u"&&Blob)&&_.isSpecCompliantForm(t);if(!_.isFunction(o))throw new TypeError("visitor must be a function");function u(w){if(w===null)return"";if(_.isDate(w))return w.toISOString();if(_.isBoolean(w))return w.toString();if(!l&&_.isBlob(w))throw new Ae("Blob is not supported. Use a Buffer instead.");return _.isArrayBuffer(w)||_.isTypedArray(w)?l&&typeof Blob=="function"?new Blob([w]):Buffer.from(w):w}function d(w,v,g){let x=w;if(w&&!g&&typeof w=="object"){if(_.endsWith(v,"{}"))v=r?v:v.slice(0,-2),w=JSON.stringify(w);else if(_.isArray(w)&&lm(w)||(_.isFileList(w)||_.endsWith(v,"[]"))&&(x=_.toArray(w)))return v=Xa(v),x.forEach(function(y,E){!(_.isUndefined(y)||y===null)&&t.append(i===!0?Ja([v],E,s):i===null?v:v+"[]",u(y))}),!1}return Ms(w)?!0:(t.append(Ja(g,v,s),u(w)),!1)}const f=[],h=Object.assign(cm,{defaultVisitor:d,convertValue:u,isVisitable:Ms});function p(w,v){if(!_.isUndefined(w)){if(f.indexOf(w)!==-1)throw Error("Circular reference detected in "+v.join("."));f.push(w),_.forEach(w,function(x,b){(!(_.isUndefined(x)||x===null)&&o.call(t,x,_.isString(b)?b.trim():b,v,h))===!0&&p(x,v?v.concat(b):[b])}),f.pop()}}if(!_.isObject(e))throw new TypeError("data must be an object");return p(e),t}function Za(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function Ds(e,t){this._pairs=[],e&&so(e,this,t)}const Qa=Ds.prototype;Qa.append=function(t,n){this._pairs.push([t,n])},Qa.toString=function(t){const n=t?function(r){return t.call(this,r,Za)}:Za;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function um(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function el(e,t,n){if(!t)return e;const r=n&&n.encode||um;_.isFunction(n)&&(n={serialize:n});const o=n&&n.serialize;let s;if(o?s=o(t,n):s=_.isURLSearchParams(t)?t.toString():new Ds(t,n).toString(r),s){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}class tl{constructor(){this.handlers=[]}use(t,n,r){return this.handlers.push({fulfilled:t,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){_.forEach(this.handlers,function(r){r!==null&&t(r)})}}const nl={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},dm={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:Ds,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},Ls=typeof window<"u"&&typeof document<"u",Fs=typeof navigator=="object"&&navigator||void 0,fm=Ls&&(!Fs||["ReactNative","NativeScript","NS"].indexOf(Fs.product)<0),hm=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",pm=Ls&&window.location.href||"http://localhost",gt={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Ls,hasStandardBrowserEnv:fm,hasStandardBrowserWebWorkerEnv:hm,navigator:Fs,origin:pm},Symbol.toStringTag,{value:"Module"})),...dm};function mm(e,t){return so(e,new gt.classes.URLSearchParams,{visitor:function(n,r,o,s){return gt.isNode&&_.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function gm(e){return _.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function xm(e){const t={},n=Object.keys(e);let r;const o=n.length;let s;for(r=0;r<o;r++)s=n[r],t[s]=e[s];return t}function rl(e){function t(n,r,o,s){let i=n[s++];if(i==="__proto__")return!0;const a=Number.isFinite(+i),l=s>=n.length;return i=!i&&_.isArray(o)?o.length:i,l?(_.hasOwnProp(o,i)?o[i]=[o[i],r]:o[i]=r,!a):((!o[i]||!_.isObject(o[i]))&&(o[i]=[]),t(n,r,o[i],s)&&_.isArray(o[i])&&(o[i]=xm(o[i])),!a)}if(_.isFormData(e)&&_.isFunction(e.entries)){const n={};return _.forEachEntry(e,(r,o)=>{t(gm(r),o,n,0)}),n}return null}function vm(e,t,n){if(_.isString(e))try{return(t||JSON.parse)(e),_.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const Tr={transitional:nl,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",o=r.indexOf("application/json")>-1,s=_.isObject(t);if(s&&_.isHTMLForm(t)&&(t=new FormData(t)),_.isFormData(t))return o?JSON.stringify(rl(t)):t;if(_.isArrayBuffer(t)||_.isBuffer(t)||_.isStream(t)||_.isFile(t)||_.isBlob(t)||_.isReadableStream(t))return t;if(_.isArrayBufferView(t))return t.buffer;if(_.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let a;if(s){if(r.indexOf("application/x-www-form-urlencoded")>-1)return mm(t,this.formSerializer).toString();if((a=_.isFileList(t))||r.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return so(a?{"files[]":t}:t,l&&new l,this.formSerializer)}}return s||o?(n.setContentType("application/json",!1),vm(t)):t}],transformResponse:[function(t){const n=this.transitional||Tr.transitional,r=n&&n.forcedJSONParsing,o=this.responseType==="json";if(_.isResponse(t)||_.isReadableStream(t))return t;if(t&&_.isString(t)&&(r&&!this.responseType||o)){const i=!(n&&n.silentJSONParsing)&&o;try{return JSON.parse(t,this.parseReviver)}catch(a){if(i)throw a.name==="SyntaxError"?Ae.from(a,Ae.ERR_BAD_RESPONSE,this,null,this.response):a}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:gt.classes.FormData,Blob:gt.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};_.forEach(["delete","get","head","post","put","patch"],e=>{Tr.headers[e]={}});const wm=_.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),bm=e=>{const t={};let n,r,o;return e&&e.split(`
31
- `).forEach(function(i){o=i.indexOf(":"),n=i.substring(0,o).trim().toLowerCase(),r=i.substring(o+1).trim(),!(!n||t[n]&&wm[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},ol=Symbol("internals");function kr(e){return e&&String(e).trim().toLowerCase()}function io(e){return e===!1||e==null?e:_.isArray(e)?e.map(io):String(e)}function ym(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}const Sm=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function $s(e,t,n,r,o){if(_.isFunction(r))return r.call(this,t,n);if(o&&(t=n),!!_.isString(t)){if(_.isString(r))return t.indexOf(r)!==-1;if(_.isRegExp(r))return r.test(t)}}function Cm(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function Tm(e,t){const n=_.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{value:function(o,s,i){return this[r].call(this,t,o,s,i)},configurable:!0})})}let Tt=class{constructor(t){t&&this.set(t)}set(t,n,r){const o=this;function s(a,l,u){const d=kr(l);if(!d)throw new Error("header name must be a non-empty string");const f=_.findKey(o,d);(!f||o[f]===void 0||u===!0||u===void 0&&o[f]!==!1)&&(o[f||l]=io(a))}const i=(a,l)=>_.forEach(a,(u,d)=>s(u,d,l));if(_.isPlainObject(t)||t instanceof this.constructor)i(t,n);else if(_.isString(t)&&(t=t.trim())&&!Sm(t))i(bm(t),n);else if(_.isObject(t)&&_.isIterable(t)){let a={},l,u;for(const d of t){if(!_.isArray(d))throw TypeError("Object iterator must return a key-value pair");a[u=d[0]]=(l=a[u])?_.isArray(l)?[...l,d[1]]:[l,d[1]]:d[1]}i(a,n)}else t!=null&&s(n,t,r);return this}get(t,n){if(t=kr(t),t){const r=_.findKey(this,t);if(r){const o=this[r];if(!n)return o;if(n===!0)return ym(o);if(_.isFunction(n))return n.call(this,o,r);if(_.isRegExp(n))return n.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=kr(t),t){const r=_.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||$s(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let o=!1;function s(i){if(i=kr(i),i){const a=_.findKey(r,i);a&&(!n||$s(r,r[a],a,n))&&(delete r[a],o=!0)}}return _.isArray(t)?t.forEach(s):s(t),o}clear(t){const n=Object.keys(this);let r=n.length,o=!1;for(;r--;){const s=n[r];(!t||$s(this,this[s],s,t,!0))&&(delete this[s],o=!0)}return o}normalize(t){const n=this,r={};return _.forEach(this,(o,s)=>{const i=_.findKey(r,s);if(i){n[i]=io(o),delete n[s];return}const a=t?Cm(s):String(s).trim();a!==s&&delete n[s],n[a]=io(o),r[a]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return _.forEach(this,(r,o)=>{r!=null&&r!==!1&&(n[o]=t&&_.isArray(r)?r.join(", "):r)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,n])=>t+": "+n).join(`
32
- `)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const r=new this(t);return n.forEach(o=>r.set(o)),r}static accessor(t){const r=(this[ol]=this[ol]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=kr(i);r[a]||(Tm(o,i),r[a]=!0)}return _.isArray(t)?t.forEach(s):s(t),this}};Tt.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),_.reduceDescriptors(Tt.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),_.freezeMethods(Tt);function zs(e,t){const n=this||Tr,r=t||n,o=Tt.from(r.headers);let s=r.data;return _.forEach(e,function(a){s=a.call(n,s,o.normalize(),t?t.status:void 0)}),o.normalize(),s}function sl(e){return!!(e&&e.__CANCEL__)}function tr(e,t,n){Ae.call(this,e??"canceled",Ae.ERR_CANCELED,t,n),this.name="CanceledError"}_.inherits(tr,Ae,{__CANCEL__:!0});function il(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new Ae("Request failed with status code "+n.status,[Ae.ERR_BAD_REQUEST,Ae.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function km(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Em(e,t){e=e||10;const n=new Array(e),r=new Array(e);let o=0,s=0,i;return t=t!==void 0?t:1e3,function(l){const u=Date.now(),d=r[s];i||(i=u),n[o]=l,r[o]=u;let f=s,h=0;for(;f!==o;)h+=n[f++],f=f%e;if(o=(o+1)%e,o===s&&(s=(s+1)%e),u-i<t)return;const p=d&&u-d;return p?Math.round(h*1e3/p):void 0}}function Im(e,t){let n=0,r=1e3/t,o,s;const i=(u,d=Date.now())=>{n=d,o=null,s&&(clearTimeout(s),s=null),e(...u)};return[(...u)=>{const d=Date.now(),f=d-n;f>=r?i(u,d):(o=u,s||(s=setTimeout(()=>{s=null,i(o)},r-f)))},()=>o&&i(o)]}const ao=(e,t,n=3)=>{let r=0;const o=Em(50,250);return Im(s=>{const i=s.loaded,a=s.lengthComputable?s.total:void 0,l=i-r,u=o(l),d=i<=a;r=i;const f={loaded:i,total:a,progress:a?i/a:void 0,bytes:l,rate:u||void 0,estimated:u&&a&&d?(a-i)/u:void 0,event:s,lengthComputable:a!=null,[t?"download":"upload"]:!0};e(f)},n)},al=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},ll=e=>(...t)=>_.asap(()=>e(...t)),Nm=gt.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,gt.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(gt.origin),gt.navigator&&/(msie|trident)/i.test(gt.navigator.userAgent)):()=>!0,Am=gt.hasStandardBrowserEnv?{write(e,t,n,r,o,s){const i=[e+"="+encodeURIComponent(t)];_.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),_.isString(r)&&i.push("path="+r),_.isString(o)&&i.push("domain="+o),s===!0&&i.push("secure"),document.cookie=i.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function jm(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function _m(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function cl(e,t,n){let r=!jm(t);return e&&(r||n==!1)?_m(e,t):t}const ul=e=>e instanceof Tt?{...e}:e;function Pn(e,t){t=t||{};const n={};function r(u,d,f,h){return _.isPlainObject(u)&&_.isPlainObject(d)?_.merge.call({caseless:h},u,d):_.isPlainObject(d)?_.merge({},d):_.isArray(d)?d.slice():d}function o(u,d,f,h){if(_.isUndefined(d)){if(!_.isUndefined(u))return r(void 0,u,f,h)}else return r(u,d,f,h)}function s(u,d){if(!_.isUndefined(d))return r(void 0,d)}function i(u,d){if(_.isUndefined(d)){if(!_.isUndefined(u))return r(void 0,u)}else return r(void 0,d)}function a(u,d,f){if(f in t)return r(u,d);if(f in e)return r(void 0,u)}const l={url:s,method:s,data:s,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:a,headers:(u,d,f)=>o(ul(u),ul(d),f,!0)};return _.forEach(Object.keys({...e,...t}),function(d){const f=l[d]||o,h=f(e[d],t[d],d);_.isUndefined(h)&&f!==a||(n[d]=h)}),n}const dl=e=>{const t=Pn({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=Tt.from(i),t.url=el(cl(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&i.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),_.isFormData(n)){if(gt.hasStandardBrowserEnv||gt.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(_.isFunction(n.getHeaders)){const l=n.getHeaders(),u=["content-type","content-length"];Object.entries(l).forEach(([d,f])=>{u.includes(d.toLowerCase())&&i.set(d,f)})}}if(gt.hasStandardBrowserEnv&&(r&&_.isFunction(r)&&(r=r(t)),r||r!==!1&&Nm(t.url))){const l=o&&s&&Am.read(s);l&&i.set(o,l)}return t},Rm=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=dl(e);let s=o.data;const i=Tt.from(o.headers).normalize();let{responseType:a,onUploadProgress:l,onDownloadProgress:u}=o,d,f,h,p,w;function v(){p&&p(),w&&w(),o.cancelToken&&o.cancelToken.unsubscribe(d),o.signal&&o.signal.removeEventListener("abort",d)}let g=new XMLHttpRequest;g.open(o.method.toUpperCase(),o.url,!0),g.timeout=o.timeout;function x(){if(!g)return;const y=Tt.from("getAllResponseHeaders"in g&&g.getAllResponseHeaders()),C={data:!a||a==="text"||a==="json"?g.responseText:g.response,status:g.status,statusText:g.statusText,headers:y,config:e,request:g};il(function(I){n(I),v()},function(I){r(I),v()},C),g=null}"onloadend"in g?g.onloadend=x:g.onreadystatechange=function(){!g||g.readyState!==4||g.status===0&&!(g.responseURL&&g.responseURL.indexOf("file:")===0)||setTimeout(x)},g.onabort=function(){g&&(r(new Ae("Request aborted",Ae.ECONNABORTED,e,g)),g=null)},g.onerror=function(E){const C=E&&E.message?E.message:"Network Error",T=new Ae(C,Ae.ERR_NETWORK,e,g);T.event=E||null,r(T),g=null},g.ontimeout=function(){let E=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const C=o.transitional||nl;o.timeoutErrorMessage&&(E=o.timeoutErrorMessage),r(new Ae(E,C.clarifyTimeoutError?Ae.ETIMEDOUT:Ae.ECONNABORTED,e,g)),g=null},s===void 0&&i.setContentType(null),"setRequestHeader"in g&&_.forEach(i.toJSON(),function(E,C){g.setRequestHeader(C,E)}),_.isUndefined(o.withCredentials)||(g.withCredentials=!!o.withCredentials),a&&a!=="json"&&(g.responseType=o.responseType),u&&([h,w]=ao(u,!0),g.addEventListener("progress",h)),l&&g.upload&&([f,p]=ao(l),g.upload.addEventListener("progress",f),g.upload.addEventListener("loadend",p)),(o.cancelToken||o.signal)&&(d=y=>{g&&(r(!y||y.type?new tr(null,e,g):y),g.abort(),g=null)},o.cancelToken&&o.cancelToken.subscribe(d),o.signal&&(o.signal.aborted?d():o.signal.addEventListener("abort",d)));const b=km(o.url);if(b&&gt.protocols.indexOf(b)===-1){r(new Ae("Unsupported protocol "+b+":",Ae.ERR_BAD_REQUEST,e));return}g.send(s||null)})},Pm=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let r=new AbortController,o;const s=function(u){if(!o){o=!0,a();const d=u instanceof Error?u:this.reason;r.abort(d instanceof Ae?d:new tr(d instanceof Error?d.message:d))}};let i=t&&setTimeout(()=>{i=null,s(new Ae(`timeout ${t} of ms exceeded`,Ae.ETIMEDOUT))},t);const a=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(u=>{u.unsubscribe?u.unsubscribe(s):u.removeEventListener("abort",s)}),e=null)};e.forEach(u=>u.addEventListener("abort",s));const{signal:l}=r;return l.unsubscribe=()=>_.asap(a),l}},Om=function*(e,t){let n=e.byteLength;if(n<t){yield e;return}let r=0,o;for(;r<n;)o=r+t,yield e.slice(r,o),r=o},Mm=async function*(e,t){for await(const n of Dm(e))yield*Om(n,t)},Dm=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:n,value:r}=await t.read();if(n)break;yield r}}finally{await t.cancel()}},fl=(e,t,n,r)=>{const o=Mm(e,t);let s=0,i,a=l=>{i||(i=!0,r&&r(l))};return new ReadableStream({async pull(l){try{const{done:u,value:d}=await o.next();if(u){a(),l.close();return}let f=d.byteLength;if(n){let h=s+=f;n(h)}l.enqueue(new Uint8Array(d))}catch(u){throw a(u),u}},cancel(l){return a(l),o.return()}},{highWaterMark:2})},hl=64*1024,{isFunction:lo}=_,Lm=(({Request:e,Response:t})=>({Request:e,Response:t}))(_.global),{ReadableStream:pl,TextEncoder:ml}=_.global,gl=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Fm=e=>{e=_.merge.call({skipUndefined:!0},Lm,e);const{fetch:t,Request:n,Response:r}=e,o=t?lo(t):typeof fetch=="function",s=lo(n),i=lo(r);if(!o)return!1;const a=o&&lo(pl),l=o&&(typeof ml=="function"?(w=>v=>w.encode(v))(new ml):async w=>new Uint8Array(await new n(w).arrayBuffer())),u=s&&a&&gl(()=>{let w=!1;const v=new n(gt.origin,{body:new pl,method:"POST",get duplex(){return w=!0,"half"}}).headers.has("Content-Type");return w&&!v}),d=i&&a&&gl(()=>_.isReadableStream(new r("").body)),f={stream:d&&(w=>w.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(w=>{!f[w]&&(f[w]=(v,g)=>{let x=v&&v[w];if(x)return x.call(v);throw new Ae(`Response type '${w}' is not supported`,Ae.ERR_NOT_SUPPORT,g)})});const h=async w=>{if(w==null)return 0;if(_.isBlob(w))return w.size;if(_.isSpecCompliantForm(w))return(await new n(gt.origin,{method:"POST",body:w}).arrayBuffer()).byteLength;if(_.isArrayBufferView(w)||_.isArrayBuffer(w))return w.byteLength;if(_.isURLSearchParams(w)&&(w=w+""),_.isString(w))return(await l(w)).byteLength},p=async(w,v)=>{const g=_.toFiniteNumber(w.getContentLength());return g??h(v)};return async w=>{let{url:v,method:g,data:x,signal:b,cancelToken:y,timeout:E,onDownloadProgress:C,onUploadProgress:T,responseType:I,headers:A,withCredentials:R="same-origin",fetchOptions:j}=dl(w),M=t||fetch;I=I?(I+"").toLowerCase():"text";let D=Pm([b,y&&y.toAbortSignal()],E),L=null;const P=D&&D.unsubscribe&&(()=>{D.unsubscribe()});let V;try{if(T&&u&&g!=="get"&&g!=="head"&&(V=await p(A,x))!==0){let Y=new n(v,{method:"POST",body:x,duplex:"half"}),de;if(_.isFormData(x)&&(de=Y.headers.get("content-type"))&&A.setContentType(de),Y.body){const[se,pe]=al(V,ao(ll(T)));x=fl(Y.body,hl,se,pe)}}_.isString(R)||(R=R?"include":"omit");const U=s&&"credentials"in n.prototype,q={...j,signal:D,method:g.toUpperCase(),headers:A.normalize().toJSON(),body:x,duplex:"half",credentials:U?R:void 0};L=s&&new n(v,q);let $=await(s?M(L,j):M(v,q));const N=d&&(I==="stream"||I==="response");if(d&&(C||N&&P)){const Y={};["status","statusText","headers"].forEach(me=>{Y[me]=$[me]});const de=_.toFiniteNumber($.headers.get("content-length")),[se,pe]=C&&al(de,ao(ll(C),!0))||[];$=new r(fl($.body,hl,se,()=>{pe&&pe(),P&&P()}),Y)}I=I||"text";let W=await f[_.findKey(f,I)||"text"]($,w);return!N&&P&&P(),await new Promise((Y,de)=>{il(Y,de,{data:W,headers:Tt.from($.headers),status:$.status,statusText:$.statusText,config:w,request:L})})}catch(U){throw P&&P(),U&&U.name==="TypeError"&&/Load failed|fetch/i.test(U.message)?Object.assign(new Ae("Network Error",Ae.ERR_NETWORK,w,L),{cause:U.cause||U}):Ae.from(U,U&&U.code,w,L)}}},$m=new Map,xl=e=>{let t=e?e.env:{};const{fetch:n,Request:r,Response:o}=t,s=[r,o,n];let i=s.length,a=i,l,u,d=$m;for(;a--;)l=s[a],u=d.get(l),u===void 0&&d.set(l,u=a?new Map:Fm(t)),d=u;return u};xl();const Bs={http:am,xhr:Rm,fetch:{get:xl}};_.forEach(Bs,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const vl=e=>`- ${e}`,zm=e=>_.isFunction(e)||e===null||e===!1,wl={getAdapter:(e,t)=>{e=_.isArray(e)?e:[e];const{length:n}=e;let r,o;const s={};for(let i=0;i<n;i++){r=e[i];let a;if(o=r,!zm(r)&&(o=Bs[(a=String(r)).toLowerCase()],o===void 0))throw new Ae(`Unknown adapter '${a}'`);if(o&&(_.isFunction(o)||(o=o.get(t))))break;s[a||"#"+i]=o}if(!o){const i=Object.entries(s).map(([l,u])=>`adapter ${l} `+(u===!1?"is not supported by the environment":"is not available in the build"));let a=n?i.length>1?`since :
30
+ <%s key={someKey} {...props} />`,Ma,Zn,aC,Zn),Mt[Zn+Ma]=!0}}return E===r?ot(ft):Be(ft),ft}}function Zr(E,H,te){return dn(E,H,te,!0)}function As(E,H,te){return dn(E,H,te,!1)}var js=As,gn=Zr;br.Fragment=r,br.jsx=js,br.jsxs=gn}()),br}process.env.NODE_ENV==="production"?Rs.exports=yp():Rs.exports=Sp();var c=Rs.exports;function $a(e,t){return function(){return e.apply(t,arguments)}}const{toString:Cp}=Object.prototype,{getPrototypeOf:Ps}=Object,{iterator:to,toStringTag:za}=Symbol,no=(e=>t=>{const n=Cp.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),Ut=e=>(e=e.toLowerCase(),t=>no(t)===e),ro=e=>t=>typeof t===e,{isArray:Qn}=Array,er=ro("undefined");function yr(e){return e!==null&&!er(e)&&e.constructor!==null&&!er(e.constructor)&&Ct(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Ba=Ut("ArrayBuffer");function Tp(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&Ba(e.buffer),t}const Ep=ro("string"),Ct=ro("function"),Ha=ro("number"),Sr=e=>e!==null&&typeof e=="object",kp=e=>e===!0||e===!1,oo=e=>{if(no(e)!=="object")return!1;const t=Ps(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(za in e)&&!(to in e)},Ip=e=>{if(!Sr(e)||yr(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},Np=Ut("Date"),Ap=Ut("File"),jp=Ut("Blob"),_p=Ut("FileList"),Rp=e=>Sr(e)&&Ct(e.pipe),Pp=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||Ct(e.append)&&((t=no(e))==="formdata"||t==="object"&&Ct(e.toString)&&e.toString()==="[object FormData]"))},Op=Ut("URLSearchParams"),[Mp,Dp,Lp,Fp]=["ReadableStream","Request","Response","Headers"].map(Ut),$p=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Cr(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,o;if(typeof e!="object"&&(e=[e]),Qn(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{if(yr(e))return;const s=n?Object.getOwnPropertyNames(e):Object.keys(e),i=s.length;let a;for(r=0;r<i;r++)a=s[r],t.call(null,e[a],a,e)}}function Ua(e,t){if(yr(e))return null;t=t.toLowerCase();const n=Object.keys(e);let r=n.length,o;for(;r-- >0;)if(o=n[r],t===o.toLowerCase())return o;return null}const Rn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Wa=e=>!er(e)&&e!==Rn;function Os(){const{caseless:e,skipUndefined:t}=Wa(this)&&this||{},n={},r=(o,s)=>{const i=e&&Ua(n,s)||s;oo(n[i])&&oo(o)?n[i]=Os(n[i],o):oo(o)?n[i]=Os({},o):Qn(o)?n[i]=o.slice():(!t||!er(o))&&(n[i]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&Cr(arguments[o],r);return n}const zp=(e,t,n,{allOwnKeys:r}={})=>(Cr(t,(o,s)=>{n&&Ct(o)?e[s]=$a(o,n):e[s]=o},{allOwnKeys:r}),e),Bp=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Hp=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},Up=(e,t,n,r)=>{let o,s,i;const a={};if(t=t||{},e==null)return t;do{for(o=Object.getOwnPropertyNames(e),s=o.length;s-- >0;)i=o[s],(!r||r(i,e,t))&&!a[i]&&(t[i]=e[i],a[i]=!0);e=n!==!1&&Ps(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},Wp=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return r!==-1&&r===n},Vp=e=>{if(!e)return null;if(Qn(e))return e;let t=e.length;if(!Ha(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Kp=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&Ps(Uint8Array)),qp=(e,t)=>{const r=(e&&e[to]).call(e);let o;for(;(o=r.next())&&!o.done;){const s=o.value;t.call(e,s[0],s[1])}},Gp=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},Yp=Ut("HTMLFormElement"),Xp=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),Va=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),Jp=Ut("RegExp"),Ka=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};Cr(n,(o,s)=>{let i;(i=t(o,s,e))!==!1&&(r[s]=i||o)}),Object.defineProperties(e,r)},Zp=e=>{Ka(e,(t,n)=>{if(Ct(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(Ct(r)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},Qp=(e,t)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return Qn(e)?r(e):r(String(e).split(t)),n},em=()=>{},tm=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function nm(e){return!!(e&&Ct(e.append)&&e[za]==="FormData"&&e[to])}const rm=e=>{const t=new Array(10),n=(r,o)=>{if(Sr(r)){if(t.indexOf(r)>=0)return;if(yr(r))return r;if(!("toJSON"in r)){t[o]=r;const s=Qn(r)?[]:{};return Cr(r,(i,a)=>{const l=n(i,o+1);!er(l)&&(s[a]=l)}),t[o]=void 0,s}}return r};return n(e,0)},om=Ut("AsyncFunction"),sm=e=>e&&(Sr(e)||Ct(e))&&Ct(e.then)&&Ct(e.catch),qa=((e,t)=>e?setImmediate:t?((n,r)=>(Rn.addEventListener("message",({source:o,data:s})=>{o===Rn&&s===n&&r.length&&r.shift()()},!1),o=>{r.push(o),Rn.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",Ct(Rn.postMessage)),im=typeof queueMicrotask<"u"?queueMicrotask.bind(Rn):typeof process<"u"&&process.nextTick||qa,_={isArray:Qn,isArrayBuffer:Ba,isBuffer:yr,isFormData:Pp,isArrayBufferView:Tp,isString:Ep,isNumber:Ha,isBoolean:kp,isObject:Sr,isPlainObject:oo,isEmptyObject:Ip,isReadableStream:Mp,isRequest:Dp,isResponse:Lp,isHeaders:Fp,isUndefined:er,isDate:Np,isFile:Ap,isBlob:jp,isRegExp:Jp,isFunction:Ct,isStream:Rp,isURLSearchParams:Op,isTypedArray:Kp,isFileList:_p,forEach:Cr,merge:Os,extend:zp,trim:$p,stripBOM:Bp,inherits:Hp,toFlatObject:Up,kindOf:no,kindOfTest:Ut,endsWith:Wp,toArray:Vp,forEachEntry:qp,matchAll:Gp,isHTMLForm:Yp,hasOwnProperty:Va,hasOwnProp:Va,reduceDescriptors:Ka,freezeMethods:Zp,toObjectSet:Qp,toCamelCase:Xp,noop:em,toFiniteNumber:tm,findKey:Ua,global:Rn,isContextDefined:Wa,isSpecCompliantForm:nm,toJSONObject:rm,isAsyncFn:om,isThenable:sm,setImmediate:qa,asap:im,isIterable:e=>e!=null&&Ct(e[to])};function Ae(e,t,n,r,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),o&&(this.response=o,this.status=o.status?o.status:null)}_.inherits(Ae,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:_.toJSONObject(this.config),code:this.code,status:this.status}}});const Ga=Ae.prototype,Ya={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{Ya[e]={value:e}}),Object.defineProperties(Ae,Ya),Object.defineProperty(Ga,"isAxiosError",{value:!0}),Ae.from=(e,t,n,r,o,s)=>{const i=Object.create(Ga);_.toFlatObject(e,i,function(d){return d!==Error.prototype},u=>u!=="isAxiosError");const a=e&&e.message?e.message:"Error",l=t==null&&e?e.code:t;return Ae.call(i,a,l,n,r,o),e&&i.cause==null&&Object.defineProperty(i,"cause",{value:e,configurable:!0}),i.name=e&&e.name||"Error",s&&Object.assign(i,s),i};const am=null;function Ms(e){return _.isPlainObject(e)||_.isArray(e)}function Xa(e){return _.endsWith(e,"[]")?e.slice(0,-2):e}function Ja(e,t,n){return e?e.concat(t).map(function(o,s){return o=Xa(o),!n&&s?"["+o+"]":o}).join(n?".":""):t}function lm(e){return _.isArray(e)&&!e.some(Ms)}const cm=_.toFlatObject(_,{},null,function(t){return/^is[A-Z]/.test(t)});function so(e,t,n){if(!_.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=_.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(v,g){return!_.isUndefined(g[v])});const r=n.metaTokens,o=n.visitor||d,s=n.dots,i=n.indexes,l=(n.Blob||typeof Blob<"u"&&Blob)&&_.isSpecCompliantForm(t);if(!_.isFunction(o))throw new TypeError("visitor must be a function");function u(w){if(w===null)return"";if(_.isDate(w))return w.toISOString();if(_.isBoolean(w))return w.toString();if(!l&&_.isBlob(w))throw new Ae("Blob is not supported. Use a Buffer instead.");return _.isArrayBuffer(w)||_.isTypedArray(w)?l&&typeof Blob=="function"?new Blob([w]):Buffer.from(w):w}function d(w,v,g){let x=w;if(w&&!g&&typeof w=="object"){if(_.endsWith(v,"{}"))v=r?v:v.slice(0,-2),w=JSON.stringify(w);else if(_.isArray(w)&&lm(w)||(_.isFileList(w)||_.endsWith(v,"[]"))&&(x=_.toArray(w)))return v=Xa(v),x.forEach(function(y,k){!(_.isUndefined(y)||y===null)&&t.append(i===!0?Ja([v],k,s):i===null?v:v+"[]",u(y))}),!1}return Ms(w)?!0:(t.append(Ja(g,v,s),u(w)),!1)}const f=[],h=Object.assign(cm,{defaultVisitor:d,convertValue:u,isVisitable:Ms});function p(w,v){if(!_.isUndefined(w)){if(f.indexOf(w)!==-1)throw Error("Circular reference detected in "+v.join("."));f.push(w),_.forEach(w,function(x,b){(!(_.isUndefined(x)||x===null)&&o.call(t,x,_.isString(b)?b.trim():b,v,h))===!0&&p(x,v?v.concat(b):[b])}),f.pop()}}if(!_.isObject(e))throw new TypeError("data must be an object");return p(e),t}function Za(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function Ds(e,t){this._pairs=[],e&&so(e,this,t)}const Qa=Ds.prototype;Qa.append=function(t,n){this._pairs.push([t,n])},Qa.toString=function(t){const n=t?function(r){return t.call(this,r,Za)}:Za;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function um(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function el(e,t,n){if(!t)return e;const r=n&&n.encode||um;_.isFunction(n)&&(n={serialize:n});const o=n&&n.serialize;let s;if(o?s=o(t,n):s=_.isURLSearchParams(t)?t.toString():new Ds(t,n).toString(r),s){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}class tl{constructor(){this.handlers=[]}use(t,n,r){return this.handlers.push({fulfilled:t,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){_.forEach(this.handlers,function(r){r!==null&&t(r)})}}const nl={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},dm={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:Ds,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},Ls=typeof window<"u"&&typeof document<"u",Fs=typeof navigator=="object"&&navigator||void 0,fm=Ls&&(!Fs||["ReactNative","NativeScript","NS"].indexOf(Fs.product)<0),hm=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",pm=Ls&&window.location.href||"http://localhost",gt={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Ls,hasStandardBrowserEnv:fm,hasStandardBrowserWebWorkerEnv:hm,navigator:Fs,origin:pm},Symbol.toStringTag,{value:"Module"})),...dm};function mm(e,t){return so(e,new gt.classes.URLSearchParams,{visitor:function(n,r,o,s){return gt.isNode&&_.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function gm(e){return _.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function xm(e){const t={},n=Object.keys(e);let r;const o=n.length;let s;for(r=0;r<o;r++)s=n[r],t[s]=e[s];return t}function rl(e){function t(n,r,o,s){let i=n[s++];if(i==="__proto__")return!0;const a=Number.isFinite(+i),l=s>=n.length;return i=!i&&_.isArray(o)?o.length:i,l?(_.hasOwnProp(o,i)?o[i]=[o[i],r]:o[i]=r,!a):((!o[i]||!_.isObject(o[i]))&&(o[i]=[]),t(n,r,o[i],s)&&_.isArray(o[i])&&(o[i]=xm(o[i])),!a)}if(_.isFormData(e)&&_.isFunction(e.entries)){const n={};return _.forEachEntry(e,(r,o)=>{t(gm(r),o,n,0)}),n}return null}function vm(e,t,n){if(_.isString(e))try{return(t||JSON.parse)(e),_.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const Tr={transitional:nl,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",o=r.indexOf("application/json")>-1,s=_.isObject(t);if(s&&_.isHTMLForm(t)&&(t=new FormData(t)),_.isFormData(t))return o?JSON.stringify(rl(t)):t;if(_.isArrayBuffer(t)||_.isBuffer(t)||_.isStream(t)||_.isFile(t)||_.isBlob(t)||_.isReadableStream(t))return t;if(_.isArrayBufferView(t))return t.buffer;if(_.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let a;if(s){if(r.indexOf("application/x-www-form-urlencoded")>-1)return mm(t,this.formSerializer).toString();if((a=_.isFileList(t))||r.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return so(a?{"files[]":t}:t,l&&new l,this.formSerializer)}}return s||o?(n.setContentType("application/json",!1),vm(t)):t}],transformResponse:[function(t){const n=this.transitional||Tr.transitional,r=n&&n.forcedJSONParsing,o=this.responseType==="json";if(_.isResponse(t)||_.isReadableStream(t))return t;if(t&&_.isString(t)&&(r&&!this.responseType||o)){const i=!(n&&n.silentJSONParsing)&&o;try{return JSON.parse(t,this.parseReviver)}catch(a){if(i)throw a.name==="SyntaxError"?Ae.from(a,Ae.ERR_BAD_RESPONSE,this,null,this.response):a}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:gt.classes.FormData,Blob:gt.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};_.forEach(["delete","get","head","post","put","patch"],e=>{Tr.headers[e]={}});const wm=_.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),bm=e=>{const t={};let n,r,o;return e&&e.split(`
31
+ `).forEach(function(i){o=i.indexOf(":"),n=i.substring(0,o).trim().toLowerCase(),r=i.substring(o+1).trim(),!(!n||t[n]&&wm[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},ol=Symbol("internals");function Er(e){return e&&String(e).trim().toLowerCase()}function io(e){return e===!1||e==null?e:_.isArray(e)?e.map(io):String(e)}function ym(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}const Sm=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function $s(e,t,n,r,o){if(_.isFunction(r))return r.call(this,t,n);if(o&&(t=n),!!_.isString(t)){if(_.isString(r))return t.indexOf(r)!==-1;if(_.isRegExp(r))return r.test(t)}}function Cm(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function Tm(e,t){const n=_.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{value:function(o,s,i){return this[r].call(this,t,o,s,i)},configurable:!0})})}let Tt=class{constructor(t){t&&this.set(t)}set(t,n,r){const o=this;function s(a,l,u){const d=Er(l);if(!d)throw new Error("header name must be a non-empty string");const f=_.findKey(o,d);(!f||o[f]===void 0||u===!0||u===void 0&&o[f]!==!1)&&(o[f||l]=io(a))}const i=(a,l)=>_.forEach(a,(u,d)=>s(u,d,l));if(_.isPlainObject(t)||t instanceof this.constructor)i(t,n);else if(_.isString(t)&&(t=t.trim())&&!Sm(t))i(bm(t),n);else if(_.isObject(t)&&_.isIterable(t)){let a={},l,u;for(const d of t){if(!_.isArray(d))throw TypeError("Object iterator must return a key-value pair");a[u=d[0]]=(l=a[u])?_.isArray(l)?[...l,d[1]]:[l,d[1]]:d[1]}i(a,n)}else t!=null&&s(n,t,r);return this}get(t,n){if(t=Er(t),t){const r=_.findKey(this,t);if(r){const o=this[r];if(!n)return o;if(n===!0)return ym(o);if(_.isFunction(n))return n.call(this,o,r);if(_.isRegExp(n))return n.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=Er(t),t){const r=_.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||$s(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let o=!1;function s(i){if(i=Er(i),i){const a=_.findKey(r,i);a&&(!n||$s(r,r[a],a,n))&&(delete r[a],o=!0)}}return _.isArray(t)?t.forEach(s):s(t),o}clear(t){const n=Object.keys(this);let r=n.length,o=!1;for(;r--;){const s=n[r];(!t||$s(this,this[s],s,t,!0))&&(delete this[s],o=!0)}return o}normalize(t){const n=this,r={};return _.forEach(this,(o,s)=>{const i=_.findKey(r,s);if(i){n[i]=io(o),delete n[s];return}const a=t?Cm(s):String(s).trim();a!==s&&delete n[s],n[a]=io(o),r[a]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return _.forEach(this,(r,o)=>{r!=null&&r!==!1&&(n[o]=t&&_.isArray(r)?r.join(", "):r)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,n])=>t+": "+n).join(`
32
+ `)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const r=new this(t);return n.forEach(o=>r.set(o)),r}static accessor(t){const r=(this[ol]=this[ol]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=Er(i);r[a]||(Tm(o,i),r[a]=!0)}return _.isArray(t)?t.forEach(s):s(t),this}};Tt.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),_.reduceDescriptors(Tt.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),_.freezeMethods(Tt);function zs(e,t){const n=this||Tr,r=t||n,o=Tt.from(r.headers);let s=r.data;return _.forEach(e,function(a){s=a.call(n,s,o.normalize(),t?t.status:void 0)}),o.normalize(),s}function sl(e){return!!(e&&e.__CANCEL__)}function tr(e,t,n){Ae.call(this,e??"canceled",Ae.ERR_CANCELED,t,n),this.name="CanceledError"}_.inherits(tr,Ae,{__CANCEL__:!0});function il(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new Ae("Request failed with status code "+n.status,[Ae.ERR_BAD_REQUEST,Ae.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function Em(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function km(e,t){e=e||10;const n=new Array(e),r=new Array(e);let o=0,s=0,i;return t=t!==void 0?t:1e3,function(l){const u=Date.now(),d=r[s];i||(i=u),n[o]=l,r[o]=u;let f=s,h=0;for(;f!==o;)h+=n[f++],f=f%e;if(o=(o+1)%e,o===s&&(s=(s+1)%e),u-i<t)return;const p=d&&u-d;return p?Math.round(h*1e3/p):void 0}}function Im(e,t){let n=0,r=1e3/t,o,s;const i=(u,d=Date.now())=>{n=d,o=null,s&&(clearTimeout(s),s=null),e(...u)};return[(...u)=>{const d=Date.now(),f=d-n;f>=r?i(u,d):(o=u,s||(s=setTimeout(()=>{s=null,i(o)},r-f)))},()=>o&&i(o)]}const ao=(e,t,n=3)=>{let r=0;const o=km(50,250);return Im(s=>{const i=s.loaded,a=s.lengthComputable?s.total:void 0,l=i-r,u=o(l),d=i<=a;r=i;const f={loaded:i,total:a,progress:a?i/a:void 0,bytes:l,rate:u||void 0,estimated:u&&a&&d?(a-i)/u:void 0,event:s,lengthComputable:a!=null,[t?"download":"upload"]:!0};e(f)},n)},al=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},ll=e=>(...t)=>_.asap(()=>e(...t)),Nm=gt.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,gt.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(gt.origin),gt.navigator&&/(msie|trident)/i.test(gt.navigator.userAgent)):()=>!0,Am=gt.hasStandardBrowserEnv?{write(e,t,n,r,o,s){const i=[e+"="+encodeURIComponent(t)];_.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),_.isString(r)&&i.push("path="+r),_.isString(o)&&i.push("domain="+o),s===!0&&i.push("secure"),document.cookie=i.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function jm(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function _m(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function cl(e,t,n){let r=!jm(t);return e&&(r||n==!1)?_m(e,t):t}const ul=e=>e instanceof Tt?{...e}:e;function Pn(e,t){t=t||{};const n={};function r(u,d,f,h){return _.isPlainObject(u)&&_.isPlainObject(d)?_.merge.call({caseless:h},u,d):_.isPlainObject(d)?_.merge({},d):_.isArray(d)?d.slice():d}function o(u,d,f,h){if(_.isUndefined(d)){if(!_.isUndefined(u))return r(void 0,u,f,h)}else return r(u,d,f,h)}function s(u,d){if(!_.isUndefined(d))return r(void 0,d)}function i(u,d){if(_.isUndefined(d)){if(!_.isUndefined(u))return r(void 0,u)}else return r(void 0,d)}function a(u,d,f){if(f in t)return r(u,d);if(f in e)return r(void 0,u)}const l={url:s,method:s,data:s,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:a,headers:(u,d,f)=>o(ul(u),ul(d),f,!0)};return _.forEach(Object.keys({...e,...t}),function(d){const f=l[d]||o,h=f(e[d],t[d],d);_.isUndefined(h)&&f!==a||(n[d]=h)}),n}const dl=e=>{const t=Pn({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=Tt.from(i),t.url=el(cl(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&i.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),_.isFormData(n)){if(gt.hasStandardBrowserEnv||gt.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(_.isFunction(n.getHeaders)){const l=n.getHeaders(),u=["content-type","content-length"];Object.entries(l).forEach(([d,f])=>{u.includes(d.toLowerCase())&&i.set(d,f)})}}if(gt.hasStandardBrowserEnv&&(r&&_.isFunction(r)&&(r=r(t)),r||r!==!1&&Nm(t.url))){const l=o&&s&&Am.read(s);l&&i.set(o,l)}return t},Rm=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=dl(e);let s=o.data;const i=Tt.from(o.headers).normalize();let{responseType:a,onUploadProgress:l,onDownloadProgress:u}=o,d,f,h,p,w;function v(){p&&p(),w&&w(),o.cancelToken&&o.cancelToken.unsubscribe(d),o.signal&&o.signal.removeEventListener("abort",d)}let g=new XMLHttpRequest;g.open(o.method.toUpperCase(),o.url,!0),g.timeout=o.timeout;function x(){if(!g)return;const y=Tt.from("getAllResponseHeaders"in g&&g.getAllResponseHeaders()),C={data:!a||a==="text"||a==="json"?g.responseText:g.response,status:g.status,statusText:g.statusText,headers:y,config:e,request:g};il(function(I){n(I),v()},function(I){r(I),v()},C),g=null}"onloadend"in g?g.onloadend=x:g.onreadystatechange=function(){!g||g.readyState!==4||g.status===0&&!(g.responseURL&&g.responseURL.indexOf("file:")===0)||setTimeout(x)},g.onabort=function(){g&&(r(new Ae("Request aborted",Ae.ECONNABORTED,e,g)),g=null)},g.onerror=function(k){const C=k&&k.message?k.message:"Network Error",T=new Ae(C,Ae.ERR_NETWORK,e,g);T.event=k||null,r(T),g=null},g.ontimeout=function(){let k=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const C=o.transitional||nl;o.timeoutErrorMessage&&(k=o.timeoutErrorMessage),r(new Ae(k,C.clarifyTimeoutError?Ae.ETIMEDOUT:Ae.ECONNABORTED,e,g)),g=null},s===void 0&&i.setContentType(null),"setRequestHeader"in g&&_.forEach(i.toJSON(),function(k,C){g.setRequestHeader(C,k)}),_.isUndefined(o.withCredentials)||(g.withCredentials=!!o.withCredentials),a&&a!=="json"&&(g.responseType=o.responseType),u&&([h,w]=ao(u,!0),g.addEventListener("progress",h)),l&&g.upload&&([f,p]=ao(l),g.upload.addEventListener("progress",f),g.upload.addEventListener("loadend",p)),(o.cancelToken||o.signal)&&(d=y=>{g&&(r(!y||y.type?new tr(null,e,g):y),g.abort(),g=null)},o.cancelToken&&o.cancelToken.subscribe(d),o.signal&&(o.signal.aborted?d():o.signal.addEventListener("abort",d)));const b=Em(o.url);if(b&&gt.protocols.indexOf(b)===-1){r(new Ae("Unsupported protocol "+b+":",Ae.ERR_BAD_REQUEST,e));return}g.send(s||null)})},Pm=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let r=new AbortController,o;const s=function(u){if(!o){o=!0,a();const d=u instanceof Error?u:this.reason;r.abort(d instanceof Ae?d:new tr(d instanceof Error?d.message:d))}};let i=t&&setTimeout(()=>{i=null,s(new Ae(`timeout ${t} of ms exceeded`,Ae.ETIMEDOUT))},t);const a=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(u=>{u.unsubscribe?u.unsubscribe(s):u.removeEventListener("abort",s)}),e=null)};e.forEach(u=>u.addEventListener("abort",s));const{signal:l}=r;return l.unsubscribe=()=>_.asap(a),l}},Om=function*(e,t){let n=e.byteLength;if(n<t){yield e;return}let r=0,o;for(;r<n;)o=r+t,yield e.slice(r,o),r=o},Mm=async function*(e,t){for await(const n of Dm(e))yield*Om(n,t)},Dm=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:n,value:r}=await t.read();if(n)break;yield r}}finally{await t.cancel()}},fl=(e,t,n,r)=>{const o=Mm(e,t);let s=0,i,a=l=>{i||(i=!0,r&&r(l))};return new ReadableStream({async pull(l){try{const{done:u,value:d}=await o.next();if(u){a(),l.close();return}let f=d.byteLength;if(n){let h=s+=f;n(h)}l.enqueue(new Uint8Array(d))}catch(u){throw a(u),u}},cancel(l){return a(l),o.return()}},{highWaterMark:2})},hl=64*1024,{isFunction:lo}=_,Lm=(({Request:e,Response:t})=>({Request:e,Response:t}))(_.global),{ReadableStream:pl,TextEncoder:ml}=_.global,gl=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Fm=e=>{e=_.merge.call({skipUndefined:!0},Lm,e);const{fetch:t,Request:n,Response:r}=e,o=t?lo(t):typeof fetch=="function",s=lo(n),i=lo(r);if(!o)return!1;const a=o&&lo(pl),l=o&&(typeof ml=="function"?(w=>v=>w.encode(v))(new ml):async w=>new Uint8Array(await new n(w).arrayBuffer())),u=s&&a&&gl(()=>{let w=!1;const v=new n(gt.origin,{body:new pl,method:"POST",get duplex(){return w=!0,"half"}}).headers.has("Content-Type");return w&&!v}),d=i&&a&&gl(()=>_.isReadableStream(new r("").body)),f={stream:d&&(w=>w.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(w=>{!f[w]&&(f[w]=(v,g)=>{let x=v&&v[w];if(x)return x.call(v);throw new Ae(`Response type '${w}' is not supported`,Ae.ERR_NOT_SUPPORT,g)})});const h=async w=>{if(w==null)return 0;if(_.isBlob(w))return w.size;if(_.isSpecCompliantForm(w))return(await new n(gt.origin,{method:"POST",body:w}).arrayBuffer()).byteLength;if(_.isArrayBufferView(w)||_.isArrayBuffer(w))return w.byteLength;if(_.isURLSearchParams(w)&&(w=w+""),_.isString(w))return(await l(w)).byteLength},p=async(w,v)=>{const g=_.toFiniteNumber(w.getContentLength());return g??h(v)};return async w=>{let{url:v,method:g,data:x,signal:b,cancelToken:y,timeout:k,onDownloadProgress:C,onUploadProgress:T,responseType:I,headers:A,withCredentials:R="same-origin",fetchOptions:j}=dl(w),M=t||fetch;I=I?(I+"").toLowerCase():"text";let D=Pm([b,y&&y.toAbortSignal()],k),L=null;const P=D&&D.unsubscribe&&(()=>{D.unsubscribe()});let V;try{if(T&&u&&g!=="get"&&g!=="head"&&(V=await p(A,x))!==0){let Y=new n(v,{method:"POST",body:x,duplex:"half"}),de;if(_.isFormData(x)&&(de=Y.headers.get("content-type"))&&A.setContentType(de),Y.body){const[se,pe]=al(V,ao(ll(T)));x=fl(Y.body,hl,se,pe)}}_.isString(R)||(R=R?"include":"omit");const U=s&&"credentials"in n.prototype,q={...j,signal:D,method:g.toUpperCase(),headers:A.normalize().toJSON(),body:x,duplex:"half",credentials:U?R:void 0};L=s&&new n(v,q);let F=await(s?M(L,j):M(v,q));const N=d&&(I==="stream"||I==="response");if(d&&(C||N&&P)){const Y={};["status","statusText","headers"].forEach(ge=>{Y[ge]=F[ge]});const de=_.toFiniteNumber(F.headers.get("content-length")),[se,pe]=C&&al(de,ao(ll(C),!0))||[];F=new r(fl(F.body,hl,se,()=>{pe&&pe(),P&&P()}),Y)}I=I||"text";let W=await f[_.findKey(f,I)||"text"](F,w);return!N&&P&&P(),await new Promise((Y,de)=>{il(Y,de,{data:W,headers:Tt.from(F.headers),status:F.status,statusText:F.statusText,config:w,request:L})})}catch(U){throw P&&P(),U&&U.name==="TypeError"&&/Load failed|fetch/i.test(U.message)?Object.assign(new Ae("Network Error",Ae.ERR_NETWORK,w,L),{cause:U.cause||U}):Ae.from(U,U&&U.code,w,L)}}},$m=new Map,xl=e=>{let t=e?e.env:{};const{fetch:n,Request:r,Response:o}=t,s=[r,o,n];let i=s.length,a=i,l,u,d=$m;for(;a--;)l=s[a],u=d.get(l),u===void 0&&d.set(l,u=a?new Map:Fm(t)),d=u;return u};xl();const Bs={http:am,xhr:Rm,fetch:{get:xl}};_.forEach(Bs,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const vl=e=>`- ${e}`,zm=e=>_.isFunction(e)||e===null||e===!1,wl={getAdapter:(e,t)=>{e=_.isArray(e)?e:[e];const{length:n}=e;let r,o;const s={};for(let i=0;i<n;i++){r=e[i];let a;if(o=r,!zm(r)&&(o=Bs[(a=String(r)).toLowerCase()],o===void 0))throw new Ae(`Unknown adapter '${a}'`);if(o&&(_.isFunction(o)||(o=o.get(t))))break;s[a||"#"+i]=o}if(!o){const i=Object.entries(s).map(([l,u])=>`adapter ${l} `+(u===!1?"is not supported by the environment":"is not available in the build"));let a=n?i.length>1?`since :
33
33
  `+i.map(vl).join(`
34
34
  `):" "+vl(i[0]):"as no adapter specified";throw new Ae("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return o},adapters:Bs};function Hs(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new tr(null,e)}function bl(e){return Hs(e),e.headers=Tt.from(e.headers),e.data=zs.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),wl.getAdapter(e.adapter||Tr.adapter,e)(e).then(function(r){return Hs(e),r.data=zs.call(e,e.transformResponse,r),r.headers=Tt.from(r.headers),r},function(r){return sl(r)||(Hs(e),r&&r.response&&(r.response.data=zs.call(e,e.transformResponse,r.response),r.response.headers=Tt.from(r.response.headers))),Promise.reject(r)})}const yl="1.12.2",co={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{co[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const Sl={};co.transitional=function(t,n,r){function o(s,i){return"[Axios v"+yl+"] Transitional option '"+s+"'"+i+(r?". "+r:"")}return(s,i,a)=>{if(t===!1)throw new Ae(o(i," has been removed"+(n?" in "+n:"")),Ae.ERR_DEPRECATED);return n&&!Sl[i]&&(Sl[i]=!0,console.warn(o(i," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(s,i,a):!0}},co.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function Bm(e,t,n){if(typeof e!="object")throw new Ae("options must be an object",Ae.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let o=r.length;for(;o-- >0;){const s=r[o],i=t[s];if(i){const a=e[s],l=a===void 0||i(a,s,e);if(l!==!0)throw new Ae("option "+s+" must be "+l,Ae.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new Ae("Unknown option "+s,Ae.ERR_BAD_OPTION)}}const uo={assertOptions:Bm,validators:co},Xt=uo.validators;let On=class{constructor(t){this.defaults=t||{},this.interceptors={request:new tl,response:new tl}}async request(t,n){try{return await this._request(t,n)}catch(r){if(r instanceof Error){let o={};Error.captureStackTrace?Error.captureStackTrace(o):o=new Error;const s=o.stack?o.stack.replace(/^.+\n/,""):"";try{r.stack?s&&!String(r.stack).endsWith(s.replace(/^.+\n.+\n/,""))&&(r.stack+=`
35
- `+s):r.stack=s}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=Pn(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:s}=n;r!==void 0&&uo.assertOptions(r,{silentJSONParsing:Xt.transitional(Xt.boolean),forcedJSONParsing:Xt.transitional(Xt.boolean),clarifyTimeoutError:Xt.transitional(Xt.boolean)},!1),o!=null&&(_.isFunction(o)?n.paramsSerializer={serialize:o}:uo.assertOptions(o,{encode:Xt.function,serialize:Xt.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),uo.assertOptions(n,{baseUrl:Xt.spelling("baseURL"),withXsrfToken:Xt.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=s&&_.merge(s.common,s[n.method]);s&&_.forEach(["delete","get","head","post","put","patch","common"],w=>{delete s[w]}),n.headers=Tt.concat(i,s);const a=[];let l=!0;this.interceptors.request.forEach(function(v){typeof v.runWhen=="function"&&v.runWhen(n)===!1||(l=l&&v.synchronous,a.unshift(v.fulfilled,v.rejected))});const u=[];this.interceptors.response.forEach(function(v){u.push(v.fulfilled,v.rejected)});let d,f=0,h;if(!l){const w=[bl.bind(this),void 0];for(w.unshift(...a),w.push(...u),h=w.length,d=Promise.resolve(n);f<h;)d=d.then(w[f++],w[f++]);return d}h=a.length;let p=n;for(;f<h;){const w=a[f++],v=a[f++];try{p=w(p)}catch(g){v.call(this,g);break}}try{d=bl.call(this,p)}catch(w){return Promise.reject(w)}for(f=0,h=u.length;f<h;)d=d.then(u[f++],u[f++]);return d}getUri(t){t=Pn(this.defaults,t);const n=cl(t.baseURL,t.url,t.allowAbsoluteUrls);return el(n,t.params,t.paramsSerializer)}};_.forEach(["delete","get","head","options"],function(t){On.prototype[t]=function(n,r){return this.request(Pn(r||{},{method:t,url:n,data:(r||{}).data}))}}),_.forEach(["post","put","patch"],function(t){function n(r){return function(s,i,a){return this.request(Pn(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}On.prototype[t]=n(),On.prototype[t+"Form"]=n(!0)});let Hm=class vp{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(s){n=s});const r=this;this.promise.then(o=>{if(!r._listeners)return;let s=r._listeners.length;for(;s-- >0;)r._listeners[s](o);r._listeners=null}),this.promise.then=o=>{let s;const i=new Promise(a=>{r.subscribe(a),s=a}).then(o);return i.cancel=function(){r.unsubscribe(s)},i},t(function(s,i,a){r.reason||(r.reason=new tr(s,i,a),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const t=new AbortController,n=r=>{t.abort(r)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new vp(function(o){t=o}),cancel:t}}};function Um(e){return function(n){return e.apply(null,n)}}function Wm(e){return _.isObject(e)&&e.isAxiosError===!0}const Us={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Us).forEach(([e,t])=>{Us[t]=e});function Cl(e){const t=new On(e),n=$a(On.prototype.request,t);return _.extend(n,On.prototype,t,{allOwnKeys:!0}),_.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return Cl(Pn(e,o))},n}const at=Cl(Tr);at.Axios=On,at.CanceledError=tr,at.CancelToken=Hm,at.isCancel=sl,at.VERSION=yl,at.toFormData=so,at.AxiosError=Ae,at.Cancel=at.CanceledError,at.all=function(t){return Promise.all(t)},at.spread=Um,at.isAxiosError=Wm,at.mergeConfig=Pn,at.AxiosHeaders=Tt,at.formToJSON=e=>rl(_.isHTMLForm(e)?new FormData(e):e),at.getAdapter=wl.getAdapter,at.HttpStatusCode=Us,at.default=at;const{Axios:xC,AxiosError:vC,CanceledError:wC,isCancel:bC,CancelToken:yC,VERSION:SC,all:CC,Cancel:TC,isAxiosError:kC,spread:EC,toFormData:IC,AxiosHeaders:NC,HttpStatusCode:AC,formToJSON:jC,getAdapter:_C,mergeConfig:RC}=at,Tl=typeof window<"u"?window.__API_BASE_URL__:void 0,kl=Tl?fn(Tl):void 0;function fn(e){const n=(e!=null&&e.trim()?e.trim():"/api/chat").replace(/\/+$/,"");return n?n.endsWith("/chat")?n:`${n}/chat`:"/api/chat"}let fo=null;const Ws=new Set;function El(){return fo}function Vs(e){fo=e,Ws.forEach(t=>t(e))}function Il(e){return Ws.add(e),()=>Ws.delete(e)}const Dt=at.create({...kl?{baseURL:kl}:{},timeout:3e4,withCredentials:!0});Dt.interceptors.request.use(e=>(fo&&(e.headers.Authorization=`Bearer ${fo}`),e)),Dt.interceptors.response.use(e=>e,e=>Promise.reject(e));async function It(e,t){return Dt.defaults.baseURL?(await Dt.get(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}async function Ks(e,t,n){return Dt.defaults.baseURL?(await Dt.post(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function Nl(e,t,n){return Dt.defaults.baseURL?(await Dt.put(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function Al(e,t){return Dt.defaults.baseURL?(await Dt.delete(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}function Nt(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class jl{get baseUrl(){const t=Dt.defaults.baseURL;return t?fn(String(t)):""}updateConfig(t){t.baseUrl&&(Dt.defaults.baseURL=fn(String(t.baseUrl))),t.authToken!==void 0&&Vs(t.authToken)}getAuthToken(){return El()}setAuthToken(t){Vs(t)}onTokenChange(t){return Il(t)}async listThreads(){const t=await It("/threads"),n=Nt(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async createThread(t){const r=await Ks("/threads",t?{title:t}:void 0);return Nt(r)}async updateThread(t,n){const r=await Nl(`/threads/${t}`,{title:n});return Nt(r)}async deleteThread(t){const n=await Al(`/threads/${t}`);return Nt(n)}async threadInfo(t){const n=await It(`/threads/${t}/info`);return Nt(n)}async listAgents(){const t=await It("/agents"),n=Nt(t);return(n==null?void 0:n.items)??[]}async getAgent(t){const n=await It(`/agents/${t}`);return Nt(n)}async getAgentSchema(t){const n=await It(`/agents/${t}/schema`);return Nt(n)}async getMessages(t){const n=await It(`/threads/${t.threadId}/messages`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs,limit:t.limit,before_id:t.beforeId??void 0}});return Nt(n)}async getState(t){const n=await It(`/threads/${t.threadId}/state`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return Nt(n)}async getStateHistory(t){const n=await It(`/threads/${t.threadId}/state/history`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return Nt(n)}async listCheckpoints(t){const n=await It(`/threads/${t}/checkpoints`,{params:{thread_id:t}});return Nt(n)}async resume(t){const n=await Ks("/runs/resume",{thread_id:t.threadId,value:t.value});return Nt(n)}}const xn=new jl,_l=S.createContext(null);function Vm({children:e,apiConfig:t}){const n=xn;if(t){const o=n.baseUrl,s=n.getAuthToken();t.baseUrl&&t.baseUrl!==o&&n.updateConfig({baseUrl:t.baseUrl}),t.apiKey!==void 0&&t.apiKey!==s&&n.updateConfig({authToken:t.apiKey})}const r={token:n.getAuthToken(),setToken:o=>n.setAuthToken(o),api:n,baseUrl:n.baseUrl};return c.jsx(_l.Provider,{value:r,children:e})}function qs(){const e=S.useContext(_l);if(!e)throw new Error("useApi must be used within ApiProvider");return e}function Km(e,t){const n=e==null?void 0:e.checkpoints,r=Array.isArray(n)?n.slice():n?Object.values(n):[],o=i=>i&&typeof i=="object"&&i!==null&&"checkpointId"in i&&"createdAt"in i&&typeof i.checkpointId=="string"&&typeof i.createdAt=="string",s=r.filter(o).map(i=>{const a=i;return{checkpointId:a.checkpointId,checkpointNs:a.checkpointNs??"",createdAt:a.createdAt,messagesLen:a.messagesLen??0,preview:a.preview??"",role:a.role??null,parentId:a.parentId??null,editedMessageId:a.editedMessageId??null,branchLabel:a.branchLabel??null,lastMessageId:a.lastMessageId??null,hasMessages:typeof a.hasMessages=="boolean"?a.hasMessages:void 0}});return{threadId:(e==null?void 0:e.threadId)??t??null,checkpoints:s}}async function qm(e){return await new Promise((t,n)=>{const r=new FileReader;r.onload=()=>{try{const o=r.result,s=new Uint8Array(o);let i="";const a=s.byteLength;for(let l=0;l<a;l++)i+=String.fromCharCode(s[l]);t(btoa(i))}catch(o){n(o)}},r.onerror=o=>n(o),r.readAsArrayBuffer(e)})}async function Gm(e,t=[],n,r,o,s){const i=[],a=[];for(const l of t)try{const u=await qm(l);a.push({filename:l.name,data:u,mime_type:l.type||"application/octet-stream"})}catch{}return{contentParts:i,filesInfo:a}}function Ym(e){return e.type!=="thread_info"&&e.type!=="token"}const Xm={messages:[],assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,toolIndex:{},lastBranch:null};function Jm(e,t){var n;switch(t.type){case"reset":{console.log("[MessageReducer] 🔄 RESET action received"),console.log("[MessageReducer] 📊 Before reset - messages count:",e.messages.length);const r={messages:Gs(((n=t.payload)==null?void 0:n.messages)??[]),assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,toolIndex:{},lastBranch:null};return console.log("[MessageReducer] 📊 After reset - messages count:",r.messages.length),r}case"seed":{const r=Gs(t.payload.messages),o={...e,messages:r,assemblingId:null};return Object.prototype.hasOwnProperty.call(t.payload,"checkpointId")&&(o.lastCheckpointId=t.payload.checkpointId??null),Object.prototype.hasOwnProperty.call(t.payload,"checkpointNs")&&(o.lastCheckpointNs=t.payload.checkpointNs??null),console.log("[MessageReducer] seed action (REPLACE mode):",{incomingCount:t.payload.messages.length,sanitizedCount:r.length,previousCount:e.messages.length,checkpointId:o.lastCheckpointId}),o}case"prepend":{const r=Gs(t.payload.messages);if(!r.length)return console.log("[MessageReducer] No incoming messages after sanitize - skipping"),e;const o=new Set(e.messages.map(i=>i.id)),s=r.filter(i=>!o.has(i.id));return console.log("[MessageReducer] After dedup:",{uniqueCount:s.length,duplicates:r.length-s.length,finalTotal:s.length+e.messages.length}),s.length?{...e,messages:[...s,...e.messages]}:(console.log("[MessageReducer] All messages were duplicates - skipping"),e)}case"user_message":{const r=t.payload.message;return e.messages.some(o=>o.id===r.id)?e:{...e,messages:[...e.messages,r]}}case"event":return Pl(e,t.payload.ev);case"batch":{const{events:r}=t.payload;return r.length?r.reduce((o,s)=>Pl(o,s),e):e}case"interrupt_response":{const{interruptId:r}=t.payload,o=e.messages.map(s=>({...s,content:s.content.filter(i=>i.type!=="interrupt")}));return{...e,messages:o,pendingInterrupt:null}}default:return e}}function Rl(e=[]){const[t,n]=S.useReducer(Jm,{...Xm,messages:e}),r=S.useRef([]),o=S.useRef(null),s=S.useRef(null),i=S.useCallback(()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),o.current=null,s.current=null;const d=r.current;d.length&&(r.current=[],n({type:"batch",payload:{events:d}}))},[]),a=S.useCallback(()=>{typeof window<"u"&&typeof window.requestAnimationFrame=="function"?o.current===null&&(o.current=window.requestAnimationFrame(()=>i())):s.current===null&&(s.current=setTimeout(i,8))},[i]),l=S.useCallback(d=>{r.current.push(d),a()},[a]);S.useEffect(()=>()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),r.current=[]},[]);const u=S.useMemo(()=>({reset:d=>n({type:"reset",payload:{messages:d}}),seed:(d,f)=>n({type:"seed",payload:{messages:d,...f??{}}}),prepend:d=>n({type:"prepend",payload:{messages:d}}),pushUser:d=>n({type:"user_message",payload:{message:d}}),onEvent:l}),[l]);return{state:t,dispatch:n,...u}}function Pl(e,t){var n,r;if(t.type==="message_start"&&t.role==="assistant"){const o=t.id,s=rg(t.model);if(e.messages.some(l=>l.id===o))return{...e,assemblingId:o};const a={id:o,role:"assistant",name:s||void 0,model:t.model,createdAt:new Date().toISOString(),content:[]};return{...e,assemblingId:o,messages:[...e.messages,a]}}if(t.type==="message_delta"){const o=e.assemblingId??Ys(e.messages);return o?{...e,messages:Xs(e.messages,o,t.delta)}:e}if(t.type==="message_end"){const o=e.assemblingId??Ys(e.messages);if(!o)return{...e,assemblingId:null};const s=e.messages,i=s.findIndex(a=>a.id===o&&a.role==="assistant");if(i>=0&&!((n=s[i].content)==null?void 0:n.some(u=>{var d;return(u==null?void 0:u.type)==="text"&&((d=u.text)==null?void 0:d.trim())}))){const u=[...s.slice(0,i),...s.slice(i+1)];return{...e,assemblingId:null,messages:u}}return e}if(t.type==="tool_start"){const o=t.id??t.call_id,s=t.name??t.tool??"tool";if(!o)return e;const i=`tool-${o}`,a={type:"tool_call",id:o,name:s,args:t.args};if(e.messages.find(d=>d.id===i))return{...e,toolIndex:{...e.toolIndex,[o]:i}};const u={id:i,role:"tool",name:s,createdAt:new Date().toISOString(),content:[a]};return{...e,messages:[...e.messages,u],toolIndex:{...e.toolIndex,[o]:i}}}if(t.type==="tool_end"){const o=t.id??t.call_id;if(!o)return e;const s=e.toolIndex[o]??`tool-${o}`,i={type:"tool_end",toolCallId:o,output:t.output,error:t.error},a=e.messages.find(d=>d.id===s),l={id:s,role:"tool",name:t.name??((r=e.messages.find(d=>d.id===s))==null?void 0:r.name),content:[i],createdAt:new Date().toISOString()},u=a?Xs(e.messages,s,[i]):[...e.messages,l];return{...e,messages:u,toolIndex:{...e.toolIndex,[o]:s}}}if(t.type==="checkpoint"){const o=t.checkpointNs??e.lastCheckpointNs??null,s=ng(e.messages,t.checkpointId,o);return{...e,lastCheckpointId:t.checkpointId,lastCheckpointNs:o,messages:s}}if(t.type==="branch"){const o=t.checkpointId??e.lastCheckpointId,s=t.checkpointNs??e.lastCheckpointNs;return{...e,lastBranch:t,lastCheckpointId:o??null,lastCheckpointNs:s??null}}if(t.type==="error"){const o={id:`err-${Date.now()}`,role:"system",content:[{type:"text",text:`Error: ${t.message}`}],createdAt:new Date().toISOString()};return{...e,messages:[...e.messages,o]}}if(t.type==="interrupt"){const o=e.assemblingId??Ys(e.messages),s={type:"interrupt",value:t.value};if(o)return{...e,assemblingId:null,messages:Xs(e.messages,o,[s]),pendingInterrupt:{id:t.id,value:t.value}};const i={id:`interrupt-${t.id}`,role:"system",createdAt:new Date().toISOString(),content:[s]};return{...e,messages:[...e.messages,i],pendingInterrupt:{id:t.id,value:t.value}}}return e}function Gs(e){return e.filter(t=>{if(t.role!=="assistant")return!0;const n=(t.content||[]).some(o=>{var s;return o&&o.type==="text"&&((s=o.text)==null?void 0:s.trim())}),r=(t.content||[]).some(o=>o&&o.type==="image_url");return!!(n||r)})}function Zm(e,t,n){return t<0||t>=e.length?e:[...e.slice(0,t),n,...e.slice(t+1)]}function Ys(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="assistant")return e[t].id;return null}function Qm(e,t,n){const r=e.findIndex(i=>i.id===t);if(r===-1)return e;const o=e[r],s=n(o);return s===o?e:[...e.slice(0,r),s,...e.slice(r+1)]}function Xs(e,t,n){return Qm(e,t,r=>({...r,content:eg(r.content,n)}))}function eg(e,t){const n=e.slice();for(const r of t)if(r.type==="text"){const o=n[n.length-1],s=r.text??"";if(!s)continue;if((o==null?void 0:o.type)==="text"){const i=o,a=i.text??"";if(!a){i.text=s;continue}if(s.startsWith(a)){i.text=s;continue}if(a.startsWith(s)){i.text=s;continue}const l=tg(a,s);l?i.text=a+l:s.length!==a.length&&(i.text=s)}else n.push({type:"text",text:s})}else n.push(r);return n}function tg(e,t){if(!t)return"";if(!e)return t;if(e===t)return"";const n=Math.min(e.length,t.length);for(let r=n;r>0;r--)if(e.slice(-r)===t.slice(0,r))return t.slice(r);return t}function ng(e,t,n){for(let r=e.length-1;r>=0;r--)if(e[r].role==="assistant"){const s={...e[r],checkpointId:t,checkpointNs:n??void 0};return Zm(e,r,s)}return e}function rg(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}function Ol(e={}){const t=S.useMemo(()=>fn(e.baseUrl),[e.baseUrl]),n=e.streamPath??"/runs/stream",[r,o]=S.useState(e.token??null),s=S.useRef(e.headers??{}),i=e.credentials??"include",[a,l]=S.useState(!1),[u,d]=S.useState(null),[f,h]=S.useState(""),[p,w]=S.useState(null),[v,g]=S.useState(0),[x,b]=S.useState(!1),y=S.useRef(null),E=S.useRef(!0),C=S.useRef(0),T=S.useCallback(j=>{o(j)},[]),I=S.useCallback(()=>{var j;(j=y.current)==null||j.abort(),y.current=null,l(!1),b(!1),C.current=0,g(0)},[]),A=S.useCallback(()=>{h(""),w(null),d(null)},[]),R=S.useCallback((j,M,D)=>{y.current&&(y.current.abort(),y.current=null),l(!0),d(null),e.autoAppendAssistant!==!1&&h("");const L=new AbortController;return y.current=L,(async()=>{var V,U,q,$,N,W,Y,de;const P=se=>{var pe;try{const me=JSON.parse(JSON.stringify(se));return(pe=me==null?void 0:me.payload)!=null&&pe.files_info&&Array.isArray(me.payload.files_info)&&(me.payload.files_info=me.payload.files_info.map(Se=>({...Se,data:Se!=null&&Se.data?`<base64 ${String(Se.data).length} chars>`:Se==null?void 0:Se.data}))),me}catch{return se}};try{let se={};try{if(r)se={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const Oe=window.__AUTH_TOKEN__,Qe=((V=window.localStorage)==null?void 0:V.getItem("authToken"))||null;let Re=null;try{const ct=(U=window.localStorage)==null?void 0:U.getItem("chat-settings");ct&&(Re=((q=JSON.parse(ct))==null?void 0:q.apiKey)||null)}catch{}const st=Oe||Qe||Re||null;st&&(se={Authorization:`Bearer ${st}`})}}catch{}console.debug("[use-chat] POST",t+n,P(j));const pe=await fetch(t+n,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream",...se,...s.current},body:JSON.stringify(j),signal:L.signal,credentials:i});if(!pe.ok||!pe.body){const Ne=await pe.text().catch(()=>"");throw console.debug("[use-chat] non-OK response",pe.status,Ne==null?void 0:Ne.slice(0,500)),new Error(`stream ${pe.status}${Ne?": "+Ne:""}`)}b(!0);const me=pe.body.getReader(),Se=new TextDecoder;let B="",O=[];C.current=0,g(0);let G=0,Z=null;const ce=()=>{if(O.length){const Ne=O.join("");O=[],E.current&&h(Oe=>Oe+Ne)}Z=null},ie=()=>{typeof window<"u"&&Z==null&&(Z=requestAnimationFrame(ce))};let De=Date.now();const Xe=setInterval(()=>{var Ne;if(Date.now()-De>6e4){const Oe="Stream idle timeout";d(Oe),L.abort(),(Ne=D==null?void 0:D.onError)==null||Ne.call(D,Oe)}},5e3),Je=1024*1024;try{const Ne=pe.headers.get("X-Thread-Id")||pe.headers.get("x-thread-id"),Oe=pe.headers.get("X-Thread-Created")||pe.headers.get("x-thread-created"),Qe=Ne??null,Re=String(Oe??"").toLowerCase()==="true";for(($=D==null?void 0:D.onOpen)==null||$.call(D,{threadId:Qe,created:Re});;){const{value:st,done:ct}=await me.read();if(ct)break;B+=Se.decode(st,{stream:!0}),B.length>Je&&(B="",console.warn("Stream buffer reset: exceeded 1MB"));let Q;for(;(Q=B.indexOf(`
35
+ `+s):r.stack=s}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=Pn(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:s}=n;r!==void 0&&uo.assertOptions(r,{silentJSONParsing:Xt.transitional(Xt.boolean),forcedJSONParsing:Xt.transitional(Xt.boolean),clarifyTimeoutError:Xt.transitional(Xt.boolean)},!1),o!=null&&(_.isFunction(o)?n.paramsSerializer={serialize:o}:uo.assertOptions(o,{encode:Xt.function,serialize:Xt.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),uo.assertOptions(n,{baseUrl:Xt.spelling("baseURL"),withXsrfToken:Xt.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=s&&_.merge(s.common,s[n.method]);s&&_.forEach(["delete","get","head","post","put","patch","common"],w=>{delete s[w]}),n.headers=Tt.concat(i,s);const a=[];let l=!0;this.interceptors.request.forEach(function(v){typeof v.runWhen=="function"&&v.runWhen(n)===!1||(l=l&&v.synchronous,a.unshift(v.fulfilled,v.rejected))});const u=[];this.interceptors.response.forEach(function(v){u.push(v.fulfilled,v.rejected)});let d,f=0,h;if(!l){const w=[bl.bind(this),void 0];for(w.unshift(...a),w.push(...u),h=w.length,d=Promise.resolve(n);f<h;)d=d.then(w[f++],w[f++]);return d}h=a.length;let p=n;for(;f<h;){const w=a[f++],v=a[f++];try{p=w(p)}catch(g){v.call(this,g);break}}try{d=bl.call(this,p)}catch(w){return Promise.reject(w)}for(f=0,h=u.length;f<h;)d=d.then(u[f++],u[f++]);return d}getUri(t){t=Pn(this.defaults,t);const n=cl(t.baseURL,t.url,t.allowAbsoluteUrls);return el(n,t.params,t.paramsSerializer)}};_.forEach(["delete","get","head","options"],function(t){On.prototype[t]=function(n,r){return this.request(Pn(r||{},{method:t,url:n,data:(r||{}).data}))}}),_.forEach(["post","put","patch"],function(t){function n(r){return function(s,i,a){return this.request(Pn(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}On.prototype[t]=n(),On.prototype[t+"Form"]=n(!0)});let Hm=class vp{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(s){n=s});const r=this;this.promise.then(o=>{if(!r._listeners)return;let s=r._listeners.length;for(;s-- >0;)r._listeners[s](o);r._listeners=null}),this.promise.then=o=>{let s;const i=new Promise(a=>{r.subscribe(a),s=a}).then(o);return i.cancel=function(){r.unsubscribe(s)},i},t(function(s,i,a){r.reason||(r.reason=new tr(s,i,a),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const t=new AbortController,n=r=>{t.abort(r)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new vp(function(o){t=o}),cancel:t}}};function Um(e){return function(n){return e.apply(null,n)}}function Wm(e){return _.isObject(e)&&e.isAxiosError===!0}const Us={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Us).forEach(([e,t])=>{Us[t]=e});function Cl(e){const t=new On(e),n=$a(On.prototype.request,t);return _.extend(n,On.prototype,t,{allOwnKeys:!0}),_.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return Cl(Pn(e,o))},n}const at=Cl(Tr);at.Axios=On,at.CanceledError=tr,at.CancelToken=Hm,at.isCancel=sl,at.VERSION=yl,at.toFormData=so,at.AxiosError=Ae,at.Cancel=at.CanceledError,at.all=function(t){return Promise.all(t)},at.spread=Um,at.isAxiosError=Wm,at.mergeConfig=Pn,at.AxiosHeaders=Tt,at.formToJSON=e=>rl(_.isHTMLForm(e)?new FormData(e):e),at.getAdapter=wl.getAdapter,at.HttpStatusCode=Us,at.default=at;const{Axios:xC,AxiosError:vC,CanceledError:wC,isCancel:bC,CancelToken:yC,VERSION:SC,all:CC,Cancel:TC,isAxiosError:EC,spread:kC,toFormData:IC,AxiosHeaders:NC,HttpStatusCode:AC,formToJSON:jC,getAdapter:_C,mergeConfig:RC}=at,Tl=typeof window<"u"?window.__API_BASE_URL__:void 0,El=Tl?fn(Tl):void 0;function fn(e){const n=(e!=null&&e.trim()?e.trim():"/api/chat").replace(/\/+$/,"");return n?n.endsWith("/chat")?n:`${n}/chat`:"/api/chat"}let fo=null;const Ws=new Set;function kl(){return fo}function Vs(e){fo=e,Ws.forEach(t=>t(e))}function Il(e){return Ws.add(e),()=>Ws.delete(e)}const Dt=at.create({...El?{baseURL:El}:{},timeout:3e4,withCredentials:!0});Dt.interceptors.request.use(e=>(fo&&(e.headers.Authorization=`Bearer ${fo}`),e)),Dt.interceptors.response.use(e=>e,e=>Promise.reject(e));async function It(e,t){return Dt.defaults.baseURL?(await Dt.get(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}async function Ks(e,t,n){return Dt.defaults.baseURL?(await Dt.post(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function Nl(e,t,n){return Dt.defaults.baseURL?(await Dt.put(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function Al(e,t){return Dt.defaults.baseURL?(await Dt.delete(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}function Nt(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class jl{get baseUrl(){const t=Dt.defaults.baseURL;return t?fn(String(t)):""}updateConfig(t){t.baseUrl&&(Dt.defaults.baseURL=fn(String(t.baseUrl))),t.authToken!==void 0&&Vs(t.authToken)}getAuthToken(){return kl()}setAuthToken(t){Vs(t)}onTokenChange(t){return Il(t)}async listThreads(){const t=await It("/threads"),n=Nt(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async createThread(t){const r=await Ks("/threads",t?{title:t}:void 0);return Nt(r)}async updateThread(t,n){const r=await Nl(`/threads/${t}`,{title:n});return Nt(r)}async deleteThread(t){const n=await Al(`/threads/${t}`);return Nt(n)}async threadInfo(t){const n=await It(`/threads/${t}/info`);return Nt(n)}async listAgents(){const t=await It("/agents"),n=Nt(t);return(n==null?void 0:n.items)??[]}async getAgent(t){const n=await It(`/agents/${t}`);return Nt(n)}async getAgentSchema(t){const n=await It(`/agents/${t}/schema`);return Nt(n)}async getMessages(t){const n=await It(`/threads/${t.threadId}/messages`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs,limit:t.limit,before_id:t.beforeId??void 0}});return Nt(n)}async getState(t){const n=await It(`/threads/${t.threadId}/state`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return Nt(n)}async getStateHistory(t){const n=await It(`/threads/${t.threadId}/state/history`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return Nt(n)}async listCheckpoints(t){const n=await It(`/threads/${t}/checkpoints`,{params:{thread_id:t}});return Nt(n)}async resume(t){const n=await Ks("/runs/resume",{thread_id:t.threadId,value:t.value});return Nt(n)}}const xn=new jl,_l=S.createContext(null);function Vm({children:e,apiConfig:t}){const n=xn;if(t){const o=n.baseUrl,s=n.getAuthToken();t.baseUrl&&t.baseUrl!==o&&n.updateConfig({baseUrl:t.baseUrl}),t.apiKey!==void 0&&t.apiKey!==s&&n.updateConfig({authToken:t.apiKey})}const r={token:n.getAuthToken(),setToken:o=>n.setAuthToken(o),api:n,baseUrl:n.baseUrl};return c.jsx(_l.Provider,{value:r,children:e})}function qs(){const e=S.useContext(_l);if(!e)throw new Error("useApi must be used within ApiProvider");return e}function Km(e,t){const n=e==null?void 0:e.checkpoints,r=Array.isArray(n)?n.slice():n?Object.values(n):[],o=i=>i&&typeof i=="object"&&i!==null&&"checkpointId"in i&&"createdAt"in i&&typeof i.checkpointId=="string"&&typeof i.createdAt=="string",s=r.filter(o).map(i=>{const a=i;return{checkpointId:a.checkpointId,checkpointNs:a.checkpointNs??"",createdAt:a.createdAt,messagesLen:a.messagesLen??0,preview:a.preview??"",role:a.role??null,parentId:a.parentId??null,editedMessageId:a.editedMessageId??null,branchLabel:a.branchLabel??null,lastMessageId:a.lastMessageId??null,hasMessages:typeof a.hasMessages=="boolean"?a.hasMessages:void 0}});return{threadId:(e==null?void 0:e.threadId)??t??null,checkpoints:s}}async function qm(e){return await new Promise((t,n)=>{const r=new FileReader;r.onload=()=>{try{const o=r.result,s=new Uint8Array(o);let i="";const a=s.byteLength;for(let l=0;l<a;l++)i+=String.fromCharCode(s[l]);t(btoa(i))}catch(o){n(o)}},r.onerror=o=>n(o),r.readAsArrayBuffer(e)})}async function Gm(e,t=[],n,r,o,s){const i=[],a=[];for(const l of t)try{const u=await qm(l);a.push({filename:l.name,data:u,mime_type:l.type||"application/octet-stream"})}catch{}return{contentParts:i,filesInfo:a}}function Ym(e){return e.type!=="thread_info"&&e.type!=="token"}const Xm={messages:[],assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,toolIndex:{},lastBranch:null};function Jm(e,t){var n;switch(t.type){case"reset":{console.log("[MessageReducer] 🔄 RESET action received"),console.log("[MessageReducer] 📊 Before reset - messages count:",e.messages.length);const r={messages:Gs(((n=t.payload)==null?void 0:n.messages)??[]),assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,toolIndex:{},lastBranch:null};return console.log("[MessageReducer] 📊 After reset - messages count:",r.messages.length),r}case"seed":{const r=Gs(t.payload.messages),o={...e,messages:r,assemblingId:null};return Object.prototype.hasOwnProperty.call(t.payload,"checkpointId")&&(o.lastCheckpointId=t.payload.checkpointId??null),Object.prototype.hasOwnProperty.call(t.payload,"checkpointNs")&&(o.lastCheckpointNs=t.payload.checkpointNs??null),console.log("[MessageReducer] seed action (REPLACE mode):",{incomingCount:t.payload.messages.length,sanitizedCount:r.length,previousCount:e.messages.length,checkpointId:o.lastCheckpointId}),o}case"prepend":{const r=Gs(t.payload.messages);if(!r.length)return console.log("[MessageReducer] No incoming messages after sanitize - skipping"),e;const o=new Set(e.messages.map(i=>i.id)),s=r.filter(i=>!o.has(i.id));return console.log("[MessageReducer] After dedup:",{uniqueCount:s.length,duplicates:r.length-s.length,finalTotal:s.length+e.messages.length}),s.length?{...e,messages:[...s,...e.messages]}:(console.log("[MessageReducer] All messages were duplicates - skipping"),e)}case"user_message":{const r=t.payload.message;return e.messages.some(o=>o.id===r.id)?e:{...e,messages:[...e.messages,r]}}case"event":return Pl(e,t.payload.ev);case"batch":{const{events:r}=t.payload;return r.length?r.reduce((o,s)=>Pl(o,s),e):e}case"interrupt_response":{const{interruptId:r}=t.payload,o=e.messages.map(s=>({...s,content:s.content.filter(i=>i.type!=="interrupt")}));return{...e,messages:o,pendingInterrupt:null}}default:return e}}function Rl(e=[]){const[t,n]=S.useReducer(Jm,{...Xm,messages:e}),r=S.useRef([]),o=S.useRef(null),s=S.useRef(null),i=S.useCallback(()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),o.current=null,s.current=null;const d=r.current;d.length&&(r.current=[],n({type:"batch",payload:{events:d}}))},[]),a=S.useCallback(()=>{typeof window<"u"&&typeof window.requestAnimationFrame=="function"?o.current===null&&(o.current=window.requestAnimationFrame(()=>i())):s.current===null&&(s.current=setTimeout(i,8))},[i]),l=S.useCallback(d=>{r.current.push(d),a()},[a]);S.useEffect(()=>()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),r.current=[]},[]);const u=S.useMemo(()=>({reset:d=>n({type:"reset",payload:{messages:d}}),seed:(d,f)=>n({type:"seed",payload:{messages:d,...f??{}}}),prepend:d=>n({type:"prepend",payload:{messages:d}}),pushUser:d=>n({type:"user_message",payload:{message:d}}),onEvent:l}),[l]);return{state:t,dispatch:n,...u}}function Pl(e,t){var n,r;if(t.type==="message_start"&&t.role==="assistant"){const o=t.id,s=rg(t.model);if(e.messages.some(l=>l.id===o))return{...e,assemblingId:o};const a={id:o,role:"assistant",name:s||void 0,model:t.model,createdAt:new Date().toISOString(),content:[]};return{...e,assemblingId:o,messages:[...e.messages,a]}}if(t.type==="message_delta"){const o=e.assemblingId??Ys(e.messages);return o?{...e,messages:Xs(e.messages,o,t.delta)}:e}if(t.type==="message_end"){const o=e.assemblingId??Ys(e.messages);if(!o)return{...e,assemblingId:null};const s=e.messages,i=s.findIndex(a=>a.id===o&&a.role==="assistant");if(i>=0&&!((n=s[i].content)==null?void 0:n.some(u=>{var d;return(u==null?void 0:u.type)==="text"&&((d=u.text)==null?void 0:d.trim())}))){const u=[...s.slice(0,i),...s.slice(i+1)];return{...e,assemblingId:null,messages:u}}return e}if(t.type==="tool_start"){const o=t.id??t.call_id,s=t.name??t.tool??"tool";if(!o)return e;const i=`tool-${o}`,a={type:"tool_call",id:o,name:s,args:t.args};if(e.messages.find(d=>d.id===i))return{...e,toolIndex:{...e.toolIndex,[o]:i}};const u={id:i,role:"tool",name:s,createdAt:new Date().toISOString(),content:[a]};return{...e,messages:[...e.messages,u],toolIndex:{...e.toolIndex,[o]:i}}}if(t.type==="tool_end"){const o=t.id??t.call_id;if(!o)return e;const s=e.toolIndex[o]??`tool-${o}`,i={type:"tool_end",toolCallId:o,output:t.output,error:t.error},a=e.messages.find(d=>d.id===s),l={id:s,role:"tool",name:t.name??((r=e.messages.find(d=>d.id===s))==null?void 0:r.name),content:[i],createdAt:new Date().toISOString()},u=a?Xs(e.messages,s,[i]):[...e.messages,l];return{...e,messages:u,toolIndex:{...e.toolIndex,[o]:s}}}if(t.type==="checkpoint"){const o=t.checkpointNs??e.lastCheckpointNs??null,s=ng(e.messages,t.checkpointId,o);return{...e,lastCheckpointId:t.checkpointId,lastCheckpointNs:o,messages:s}}if(t.type==="branch"){const o=t.checkpointId??e.lastCheckpointId,s=t.checkpointNs??e.lastCheckpointNs;return{...e,lastBranch:t,lastCheckpointId:o??null,lastCheckpointNs:s??null}}if(t.type==="error"){const o={id:`err-${Date.now()}`,role:"system",content:[{type:"text",text:`Error: ${t.message}`}],createdAt:new Date().toISOString()};return{...e,messages:[...e.messages,o]}}if(t.type==="interrupt"){const o=e.assemblingId??Ys(e.messages),s={type:"interrupt",value:t.value};if(o)return{...e,assemblingId:null,messages:Xs(e.messages,o,[s]),pendingInterrupt:{id:t.id,value:t.value}};const i={id:`interrupt-${t.id}`,role:"system",createdAt:new Date().toISOString(),content:[s]};return{...e,messages:[...e.messages,i],pendingInterrupt:{id:t.id,value:t.value}}}return e}function Gs(e){return e.filter(t=>{if(t.role!=="assistant")return!0;const n=(t.content||[]).some(o=>{var s;return o&&o.type==="text"&&((s=o.text)==null?void 0:s.trim())}),r=(t.content||[]).some(o=>o&&o.type==="image_url");return!!(n||r)})}function Zm(e,t,n){return t<0||t>=e.length?e:[...e.slice(0,t),n,...e.slice(t+1)]}function Ys(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="assistant")return e[t].id;return null}function Qm(e,t,n){const r=e.findIndex(i=>i.id===t);if(r===-1)return e;const o=e[r],s=n(o);return s===o?e:[...e.slice(0,r),s,...e.slice(r+1)]}function Xs(e,t,n){return Qm(e,t,r=>({...r,content:eg(r.content,n)}))}function eg(e,t){const n=e.slice();for(const r of t)if(r.type==="text"){const o=n[n.length-1],s=r.text??"";if(!s)continue;if((o==null?void 0:o.type)==="text"){const i=o,a=i.text??"";if(!a){i.text=s;continue}if(s.startsWith(a)){i.text=s;continue}if(a.startsWith(s)){i.text=s;continue}const l=tg(a,s);l?i.text=a+l:s.length!==a.length&&(i.text=s)}else n.push({type:"text",text:s})}else n.push(r);return n}function tg(e,t){if(!t)return"";if(!e)return t;if(e===t)return"";const n=Math.min(e.length,t.length);for(let r=n;r>0;r--)if(e.slice(-r)===t.slice(0,r))return t.slice(r);return t}function ng(e,t,n){for(let r=e.length-1;r>=0;r--)if(e[r].role==="assistant"){const s={...e[r],checkpointId:t,checkpointNs:n??void 0};return Zm(e,r,s)}return e}function rg(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}function Ol(e={}){const t=S.useMemo(()=>fn(e.baseUrl),[e.baseUrl]),n=e.streamPath??"/runs/stream",[r,o]=S.useState(e.token??null),s=S.useRef(e.headers??{}),i=e.credentials??"include",[a,l]=S.useState(!1),[u,d]=S.useState(null),[f,h]=S.useState(""),[p,w]=S.useState(null),[v,g]=S.useState(0),[x,b]=S.useState(!1),y=S.useRef(null),k=S.useRef(!0),C=S.useRef(0),T=S.useCallback(j=>{o(j)},[]),I=S.useCallback(()=>{var j;(j=y.current)==null||j.abort(),y.current=null,l(!1),b(!1),C.current=0,g(0)},[]),A=S.useCallback(()=>{h(""),w(null),d(null)},[]),R=S.useCallback((j,M,D)=>{y.current&&(y.current.abort(),y.current=null),l(!0),d(null),e.autoAppendAssistant!==!1&&h("");const L=new AbortController;return y.current=L,(async()=>{var V,U,q,F,N,W,Y,de;const P=se=>{var pe;try{const ge=JSON.parse(JSON.stringify(se));return(pe=ge==null?void 0:ge.payload)!=null&&pe.files_info&&Array.isArray(ge.payload.files_info)&&(ge.payload.files_info=ge.payload.files_info.map(Se=>({...Se,data:Se!=null&&Se.data?`<base64 ${String(Se.data).length} chars>`:Se==null?void 0:Se.data}))),ge}catch{return se}};try{let se={};try{if(r)se={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const Oe=window.__AUTH_TOKEN__,Qe=((V=window.localStorage)==null?void 0:V.getItem("authToken"))||null;let Re=null;try{const ct=(U=window.localStorage)==null?void 0:U.getItem("chat-settings");ct&&(Re=((q=JSON.parse(ct))==null?void 0:q.apiKey)||null)}catch{}const st=Oe||Qe||Re||null;st&&(se={Authorization:`Bearer ${st}`})}}catch{}console.debug("[use-chat] POST",t+n,P(j));const pe=await fetch(t+n,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream",...se,...s.current},body:JSON.stringify(j),signal:L.signal,credentials:i});if(!pe.ok||!pe.body){const Ne=await pe.text().catch(()=>"");throw console.debug("[use-chat] non-OK response",pe.status,Ne==null?void 0:Ne.slice(0,500)),new Error(`stream ${pe.status}${Ne?": "+Ne:""}`)}b(!0);const ge=pe.body.getReader(),Se=new TextDecoder;let B="",O=[];C.current=0,g(0);let G=0,Z=null;const ce=()=>{if(O.length){const Ne=O.join("");O=[],k.current&&h(Oe=>Oe+Ne)}Z=null},ie=()=>{typeof window<"u"&&Z==null&&(Z=requestAnimationFrame(ce))};let De=Date.now();const Xe=setInterval(()=>{var Ne;if(Date.now()-De>6e4){const Oe="Stream idle timeout";d(Oe),L.abort(),(Ne=D==null?void 0:D.onError)==null||Ne.call(D,Oe)}},5e3),Je=1024*1024;try{const Ne=pe.headers.get("X-Thread-Id")||pe.headers.get("x-thread-id"),Oe=pe.headers.get("X-Thread-Created")||pe.headers.get("x-thread-created"),Qe=Ne??null,Re=String(Oe??"").toLowerCase()==="true";for((F=D==null?void 0:D.onOpen)==null||F.call(D,{threadId:Qe,created:Re});;){const{value:st,done:ct}=await ge.read();if(ct)break;B+=Se.decode(st,{stream:!0}),B.length>Je&&(B="",console.warn("Stream buffer reset: exceeded 1MB"));let Q;for(;(Q=B.indexOf(`
36
36
 
37
- `))>=0;){const le=B.slice(0,Q);B=B.slice(Q+2);const ge=sg(le);if(!ge)continue;let Ce;try{Ce=JSON.parse(ge)}catch{console.debug("[use-chat] malformed SSE:",ge.slice(0,200));continue}const we=og(Ce)?Ce.data:Ce;De=Date.now();const _e=we.seq;if(_e!==void 0){if(_e<=G){console.debug("[use-chat] drop duplicate/out-of-order event",{seq:_e,lastProcessedSeq:G,type:we.type});continue}G>0&&_e>G+1&&((N=D==null?void 0:D.onGap)==null||N.call(D,{from:G,to:_e})),G=_e,C.current=_e,g(_e)}if(M==null||M(we),we.type==="token"&&e.autoAppendAssistant!==!1)O.push(we.content),ie();else if(we.type==="message_delta"){const et=we.delta.filter(Ke=>Ke.type==="text").map(Ke=>Ke.text).join("");et&&e.autoAppendAssistant!==!1&&(O.push(et),ie())}else we.type==="heartbeat"?console.debug("[use-chat] heartbeat received"):(Z!==null&&cancelAnimationFrame(Z),ce(),we.type==="checkpoint"?w(we.checkpointId):we.type==="error"&&d(we.message))}}ce()}catch(Ne){if(Ne.name!=="AbortError"){const Oe=Ne.message||String(Ne);d(Oe),(W=D==null?void 0:D.onError)==null||W.call(D,Oe)}}finally{try{await me.cancel()}catch{}finally{(Y=me.releaseLock)==null||Y.call(me)}Z!==null&&typeof window<"u"&&window.cancelAnimationFrame(Z),clearInterval(Xe),l(!1),b(!1),y.current=null,C.current=0,g(0)}}catch(se){if(se.name!=="AbortError"){const pe=se.message||String(se);d(pe),(de=D==null?void 0:D.onError)==null||de.call(D,pe)}}finally{l(!1),b(!1),y.current=null,C.current=0,g(0)}})(),{close:()=>L.abort()}},[t,n,r,e.autoAppendAssistant]);return S.useEffect(()=>()=>{var j;E.current=!1,(j=y.current)==null||j.abort()},[]),{isStreaming:a,error:u,assistantText:f,lastCheckpointId:p,lastSeq:v,connected:x,stream:R,stop:I,clear:A,setToken:T}}function og(e){return!!e&&typeof e=="object"&&e.protocolVersion==="v1"&&"data"in e}function sg(e){const t=e.split(/\r?\n/),n=[];for(const r of t)if(r&&!r.startsWith(":")&&r.startsWith("data:")){const o=r.slice(5);n.push(o.startsWith(" ")?o.slice(1):o)}return n.length===0?null:n.join(`
38
- `)}function ig({baseUrl:e,onThreadInfo:t,onMessageEvent:n,onUnhandledEvent:r,onSequenceGap:o}){const s=S.useRef(null),i=S.useCallback(p=>{const w=p.seq??null;if(w!==null){const v=s.current;if(v!==null){if(w<=v)return;w>v+1&&(o==null||o({from:v,to:w}))}s.current=w}if(p.type==="thread_info"){console.log("[useChatStreamingService] 🎯 Received thread_info event:",p),t(p);return}if(Ym(p)){n(p);return}r==null||r(p)},[n,o,t,r]),{stream:a,stop:l,isStreaming:u,error:d,setToken:f}=Ol({baseUrl:e,token:null}),h=S.useCallback((p,w)=>{s.current=null,a(p,i,{onOpen:w==null?void 0:w.onOpen,onError:v=>{var g;(g=w==null?void 0:w.onError)==null||g.call(w,v)},onGap:(w==null?void 0:w.onGap)??o})},[i,o,a]);return S.useMemo(()=>({startStream:h,stop:l,isStreaming:u,error:d,setAuthToken:f}),[h,l,u,d,f])}const Ml=S.createContext(null),Dl=S.createContext(null),Ll=S.createContext(null),ag=S.createContext(!1),lg=20;function cg({children:e,initialThreadId:t=null,autoLoadInitial:n=!0,disableAutoRestore:r=!1,enableFileAgentRouting:o=!1,fileAgentId:s="invoice_reader",onError:i,onThreadChange:a}){const{api:l,baseUrl:u}=qs(),d=S.useMemo(()=>fn(u),[u]),[f,h]=S.useState([]),[p,w]=S.useState(t),[v,g]=S.useState(!1),[x,b]=S.useState(!1),[y,E]=S.useState(!1),[C,T]=S.useState(!1),[I,A]=S.useState(null),[R,j]=S.useState(void 0),[M,D]=S.useState(void 0),{state:L,seed:P,prepend:V,pushUser:U,onEvent:q,reset:$}=Rl(),N=S.useRef(p);S.useEffect(()=>{N.current=p},[p]);const W=S.useRef(!1),Y=S.useRef([]),de=S.useRef(null),se=S.useRef(null),pe=S.useCallback((F,J)=>new Promise((Te,Me)=>{const Le=async()=>{W.current=!0;try{await F(),Te()}catch(it){Me(it)}finally{W.current=!1;const it=Y.current.shift();it&&it().catch(()=>{})}};W.current?Y.current.push(Le):Le().catch(it=>{Me(it)})}),[]),me=S.useCallback(async()=>{g(!0);try{const F=await l.listThreads();h(F)}catch(F){i==null||i(String(F)),console.error("[ChatSessionProvider] Failed to refresh threads:",F)}finally{g(!1)}},[l,i]);S.useCallback(async()=>{try{await me()}catch(F){console.error("[ChatSessionProvider] Failed to refresh threads after stream:",F)}},[me]);const Se=S.useRef(!1),B=S.useCallback((F,J)=>{const Te=Array.isArray(F==null?void 0:F.messages)?F.messages:[];J==="replace"?P(Te,{checkpointId:(F==null?void 0:F.checkpointId)??null,checkpointNs:(F==null?void 0:F.checkpointNs)??null}):J==="prepend"&&Te.length&&V(Te),A((F==null?void 0:F.nextCursor)??null),E(!!(F!=null&&F.hasMore)),j(Me=>(F==null?void 0:F.checkpointId)??Me??void 0),D(Me=>(F==null?void 0:F.checkpointNs)??Me??void 0)},[V,P]),O=S.useCallback(()=>{$([]),E(!1),T(!1),A(null),j(void 0),D(void 0)},[$]),G=S.useCallback(({from:F,to:J})=>{const Te=N.current;Te&&console.warn(`[ChatSessionProvider] Stream sequence gap detected (${F} -> ${J}) for thread ${Te}`)},[]),Z=S.useCallback(F=>{const J=F.threadId;console.log("[ChatSessionProvider] 📥 Handling thread_info event:",{threadId:J,title:F.title,created:F.created,currentThreads:f.length});const Te={threadId:J,title:F.title||`Thread ${J.slice(0,8)}`,createdAt:F.createdAt||new Date().toISOString(),updatedAt:F.updatedAt||new Date().toISOString(),messageCount:F.messageCount||0};N.current!==J&&(!N.current&&L.messages.length<=1&&(se.current=J),w(J)),h(Me=>{const Le=Me.findIndex(it=>it.threadId===J);if(Le>=0){const it=[...Me];return it[Le]=Te,console.log("[ChatSessionProvider] ✏️ Updated existing thread at index:",Le),it}else return console.log("[ChatSessionProvider] ➕ Added new thread to list"),[Te,...Me]})},[L.messages.length]),{startStream:ce,stop:ie,isStreaming:De,error:Xe,setAuthToken:Je}=ig({baseUrl:d,onThreadInfo:Z,onMessageEvent:q,onUnhandledEvent:F=>{console.warn(`[ChatSessionProvider] Unhandled stream event: ${F.type}`,F)},onSequenceGap:G});S.useEffect(()=>{Se.current=De},[De]),S.useEffect(()=>{var Te;const F=l.getAuthToken();Je(F);const J=(Te=l.onTokenChange)==null?void 0:Te.call(l,Me=>{Je(Me)});return()=>{J==null||J()}},[l,Je]);const Ne=S.useCallback(async F=>{const J=`temp-${Date.now()}`,Te={threadId:J,title:F||"New Chat",createdAt:new Date().toISOString(),updatedAt:new Date().toISOString(),messageCount:0};h(Me=>[Te,...Me]),w(J);try{const Me=await l.createThread(F),Le=typeof Me=="string"?Me:Me.threadId;return h(it=>it.map(Ot=>Ot.threadId===J?{...Ot,threadId:Le}:Ot)),w(Le),setTimeout(()=>me(),10),Le}catch(Me){throw h(Le=>Le.filter(it=>it.threadId!==J)),w(null),Me}},[l,me]),Oe=S.useCallback(async F=>{await l.deleteThread(F),N.current===F&&(se.current=F,w(null),O()),await me()},[l,O,me]),Qe=S.useCallback(async(F,J)=>{try{await l.updateThread(F,J),h(Te=>Te.map(Me=>Me.threadId===F?{...Me,title:J}:Me))}catch(Te){throw await me(),Te}},[l,me]),Re=S.useCallback(async(F,J,Te,Me=!1)=>{await pe(async()=>{if(se.current===F&&!Me){se.current=null;return}if(!(de.current===F&&!Me)){w(Le=>Le===F?Le:F),de.current=F,b(!0);try{const Le=await l.getMessages({threadId:F,checkpointId:J,checkpointNs:Te});B(Le,"replace"),j((Le==null?void 0:Le.checkpointId)??void 0),D((Le==null?void 0:Le.checkpointNs)??void 0)}catch(Le){throw i==null||i(String(Le)),Le}finally{de.current=null,b(!1)}}},`loadThread-${F}`)},[l,B,pe,i]),st=S.useCallback(async()=>{await pe(async()=>{N.current&&(se.current=N.current),w(null),O(),j(void 0),D(void 0);try{localStorage.removeItem("lastThreadId")}catch(F){console.warn("[ChatSessionProvider] Failed to clear lastThreadId:",F)}},"clearCurrentThread")},[O,pe]),ct=S.useCallback(async F=>{const J=await l.listCheckpoints(F);return Km(J,F)},[l]),Q=S.useCallback(async(F,J)=>{if(!N.current)throw new Error("No active thread");await Re(N.current,F,J??void 0,!0)},[Re]),le=S.useCallback(async()=>{if(!N.current)throw new Error("No active thread");await Re(N.current,void 0,void 0,!0)},[Re]),ge=S.useCallback(async F=>{if(!N.current)throw new Error("No active thread");if(C||!y)return;const J=I;if(J){T(!0);try{const Te=await l.getMessages({threadId:N.current,checkpointId:R,checkpointNs:M,limit:(F==null?void 0:F.limit)??lg,beforeId:J});B(Te,"prepend")}finally{T(!1)}}},[l,B,y,R,M,I,C]),Ce=S.useCallback(async(F,J)=>{var jn;const Te=N.current;!Te&&!(J!=null&&J.payloadExtras)&&console.warn("[ChatSessionProvider] No thread ID - message will create new thread");const Me=(J==null?void 0:J.attachments)||[],{contentParts:Le,filesInfo:it}=await Gm(l,Me),Ot=[...Le];F&&F.trim()&&Ot.push({type:"text",text:F.trim()});const gr={id:((jn=crypto.randomUUID)==null?void 0:jn.call(crypto))||`user-${Date.now()}`,role:"user",content:Ot,createdAt:new Date().toISOString(),checkpointId:(J==null?void 0:J.checkpointId)??L.lastCheckpointId??void 0,checkpointNs:(J==null?void 0:J.checkpointNs)??L.lastCheckpointNs??void 0};U(gr);const Xn={...gr,content:Ot},xr={...(J==null?void 0:J.payloadExtras)??{}},cn=Me.length>0,Jn={...Te?{threadId:Te}:{},payload:{messages:[Xn],files_info:it,...o&&cn&&s?{active_agent:s}:{},...xr},checkpointId:(J==null?void 0:J.checkpointId)??L.lastCheckpointId??void 0,checkpointNs:(J==null?void 0:J.checkpointNs)??L.lastCheckpointNs??void 0,nodeFilter:J==null?void 0:J.nodeFilter,config:J==null?void 0:J.config};ce(Jn,{onError:un=>{console.warn("[ChatSessionProvider] Stream error:",un)},onOpen:({threadId:un,created:Ns})=>{!N.current&&un&&(L.messages.length<=1&&(se.current=un),w(un))},onGap:G})},[l,o,s,G,L.lastCheckpointId,L.lastCheckpointNs,L.messages.length,U,ce]),we=S.useCallback(async(F,J,Te)=>{const Me=N.current;if(!Me)throw new Error("No active thread to handle interrupt");try{const Le=J?Te??!0:!1;await l.resume({threadId:Me,value:Le})}catch(Le){throw console.error(`[ChatSessionProvider] Failed to handle interrupt ${F}:`,Le),Le}},[l]);S.useEffect(()=>{if(a==null||a(p),p)try{localStorage.setItem("lastThreadId",p)}catch(F){console.warn("[ChatSessionProvider] Failed to persist lastThreadId:",F)}},[p,a]),S.useEffect(()=>{let F=!0;return(async()=>{try{if(await me(),!F)return;if(!r&&!t)try{const Te=localStorage.getItem("lastThreadId");Te&&(w(Te),n&&await Re(Te))}catch(Te){console.warn("[ChatSessionProvider] Failed to restore last thread:",Te)}else t&&n&&await Re(t)}catch(Te){console.error("[ChatSessionProvider] Initialization failed:",Te),i==null||i(String(Te))}})(),()=>{F=!1}},[]);const _e=S.useMemo(()=>({threads:f,currentThreadId:p,isLoadingThreads:v,isLoadingThread:x,setCurrentThreadId:w,createThread:Ne,deleteThread:Oe,renameThread:Qe,refreshThreads:me,loadThread:Re,clearCurrentThread:st,listCheckpoints:ct,navigateToCheckpoint:Q,returnToLatest:le}),[st,Ne,p,Oe,x,v,ct,Re,Q,me,Qe,le,f]),et=S.useMemo(()=>({messages:L.messages,assemblingId:L.assemblingId,lastUserMessage:null,hasMoreHistory:y,isLoadingHistory:C,send:Ce,stop:ie,loadOlderMessages:ge,clearMessages:O,handleInterrupt:we}),[O,we,y,C,ge,L.assemblingId,L.messages,Ce,ie]),Ke=S.useMemo(()=>({isStreaming:De,error:Xe,streamingAssistantId:L.assemblingId,lastCheckpointId:L.lastCheckpointId??null,lastCheckpointNs:L.lastCheckpointNs??null}),[De,L.assemblingId,L.lastCheckpointId,L.lastCheckpointNs,Xe]);return c.jsx(ag.Provider,{value:!0,children:c.jsx(Ll.Provider,{value:Ke,children:c.jsx(Ml.Provider,{value:_e,children:c.jsx(Dl.Provider,{value:et,children:e})})})})}function ho(){const e=S.useContext(Ml);if(!e)throw new Error("useThreads must be used within ChatSessionProvider");return e}function Js(){const e=S.useContext(Dl);if(!e)throw new Error("useMessages must be used within ChatSessionProvider");return e}function Fl(){const e=S.useContext(Ll);if(!e)throw new Error("useStream must be used within ChatSessionProvider");return e}function po({children:e,apiConfig:t,initialThreadId:n=null,autoLoadInitial:r=!0,disableAutoRestore:o=!1,enableFileAgentRouting:s=!1,fileAgentId:i="invoice_reader",onError:a,onThreadChange:l}){return c.jsx(Vm,{apiConfig:t,children:c.jsx(cg,{initialThreadId:n,autoLoadInitial:r,disableAutoRestore:o,enableFileAgentRouting:s,fileAgentId:i,onError:a,onThreadChange:l,children:e})})}function X(...e){return bp.twMerge(wp.clsx(e))}const ug=Qr.cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),Ue=m.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?_n.Slot:"button";return c.jsx(i,{className:X(ug({variant:t,size:n,className:e})),ref:s,...o})});Ue.displayName="Button";const $l=m.forwardRef(({className:e,...t},n)=>c.jsx("textarea",{className:X("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),ref:n,...t}));$l.displayName="Textarea";function dg({initialValue:e="",editingMessageId:t=null,placeholder:n="Type your message...",isStreaming:r=!1,disabled:o=!1,maxLength:s=2e4,onSend:i,onCancelEdit:a,onStop:l,className:u="",textareaClassName:d="",allowEmptySend:f=!1}){const[h,p]=S.useState(e),[w,v]=S.useTransition(),g=S.useRef(null);S.useEffect(()=>{p(e??""),g.current&&(g.current.style.height="auto",g.current.style.height=`${g.current.scrollHeight}px`)},[e,t]);const x=S.useCallback(()=>{const A=g.current;A&&(A.style.height="auto",A.style.height=`${A.scrollHeight}px`)},[]);S.useEffect(()=>{x()},[x]);const b=S.useCallback(async A=>{A&&A.preventDefault();const R=(h??"").trim();!R&&!f||v(()=>{try{const j=i(R);j&&typeof j.then=="function"?j.then(()=>{p(""),g.current&&(g.current.style.height="auto")}).catch(()=>{}):(p(""),g.current&&(g.current.style.height="auto"))}catch{}})},[h,i,f]),y=S.useCallback(A=>{p(A.target.value),g.current&&(g.current.style.height="auto",g.current.style.height=`${g.current.scrollHeight}px`)},[]),E=S.useCallback(A=>{A.key==="Enter"&&!A.shiftKey?(A.preventDefault(),b()):A.key==="Escape"&&t&&(A.preventDefault(),a==null||a())},[b,t,a]),I=`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${t?"border-[hsl(var(--ring))] bg-[hsl(var(--card))] text-[hsl(var(--card-foreground))] dark:bg-[hsl(var(--card))] dark:text-[hsl(var(--card-foreground))]":""} ${d}`;return c.jsx("form",{onSubmit:A=>void b(A),className:`w-full ${u}`,children:c.jsxs("div",{className:"flex items-end gap-2",children:[c.jsx("div",{className:"flex-1",children:c.jsx($l,{ref:g,value:h,onChange:y,onKeyDown:E,placeholder:t?"Edit your message...":n,className:I,disabled:o,maxLength:s,rows:1,spellCheck:!1,autoCorrect:"off"})}),c.jsx("div",{children:r?c.jsx(Ue,{type:"button",onClick:()=>{l==null||l()},size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",disabled:o||!l,children:c.jsx(ee.Square,{size:16})}):c.jsx(Ue,{type:"submit",size:"icon",className:"shrink-0",title:t?"Save changes":"Send message",disabled:o||!h.trim()&&!f||w,children:c.jsx(ee.Send,{size:16})})})]})})}const fg=S.memo(dg),mo=0,vn=1,nr=2,zl=4;function Bl(e){return()=>e}function hg(e){e()}function Hl(e,t){return n=>e(t(n))}function Ul(e,t){return()=>e(t)}function pg(e,t){return n=>e(t,n)}function Zs(e){return e!==void 0}function mg(...e){return()=>{e.map(hg)}}function rr(){}function go(e,t){return t(e),e}function gg(e,t){return t(e)}function tt(...e){return e}function Ve(e,t){return e(vn,t)}function je(e,t){e(mo,t)}function Qs(e){e(nr)}function lt(e){return e(zl)}function ue(e,t){return Ve(e,pg(t,mo))}function Wt(e,t){const n=e(vn,r=>{n(),t(r)});return n}function Wl(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function Vl(e,t){return e===t}function nt(e=Vl){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function be(e){return t=>n=>{e(n)&&t(n)}}function ne(e){return t=>Hl(t,e)}function Jt(e){return t=>()=>{t(e)}}function z(e,...t){const n=xg(...t);return(r,o)=>{switch(r){case nr:Qs(e);return;case vn:return Ve(e,n(o))}}}function Zt(e,t){return n=>r=>{n(t=e(t,r))}}function Mn(e){return t=>n=>{e>0?e--:t(n)}}function hn(e){let t=null,n;return r=>o=>{t=o,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function Pe(...e){const t=new Array(e.length);let n=0,r=null;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const a=Math.pow(2,i);Ve(s,l=>{const u=n;n=n|a,t[i]=l,u!==o&&n===o&&r&&(r(),r=null)})}),s=>i=>{const a=()=>{s([i].concat(t))};n===o?a():r=a}}function xg(...e){return t=>e.reduceRight(gg,t)}function vg(e){let t,n;const r=()=>t==null?void 0:t();return function(o,s){switch(o){case vn:return s?n===s?void 0:(r(),n=s,t=Ve(e,s),t):(r(),rr);case nr:r(),n=null;return}}}function K(e){let t=e;const n=ze();return(r,o)=>{switch(r){case mo:t=o;break;case vn:{o(t);break}case zl:return t}return n(r,o)}}function xt(e,t){return go(K(t),n=>ue(e,n))}function ze(){const e=[];return(t,n)=>{switch(t){case mo:e.slice().forEach(r=>{r(n)});return;case nr:e.splice(0,e.length);return;case vn:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}}}function At(e){return go(ze(),t=>ue(e,t))}function We(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:wg(),singleton:n}}const wg=()=>Symbol();function bg(e){const t=new Map,n=({constructor:r,dependencies:o,id:s,singleton:i})=>{if(i&&t.has(s))return t.get(s);const a=r(o.map(l=>n(l)));return i&&t.set(s,a),a};return n(e)}function dt(...e){const t=ze(),n=new Array(e.length);let r=0;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const a=Math.pow(2,i);Ve(s,l=>{n[i]=l,r=r|a,r===o&&je(t,n)})}),function(s,i){switch(s){case nr:{Qs(t);return}case vn:return r===o&&i(n),Ve(t,i)}}}function ve(e,t=Vl){return z(e,nt(t))}function ei(...e){return function(t,n){switch(t){case nr:return;case vn:return mg(...e.map(r=>Ve(r,n)))}}}var kt=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(kt||{});const yg={0:"debug",3:"error",1:"log",2:"warn"},Sg=()=>typeof globalThis>"u"?window:globalThis,wn=We(()=>{const e=K(3);return{log:K((t,n,r=1)=>{var o;const s=(o=Sg().VIRTUOSO_LOG_LEVEL)!=null?o:lt(e);r>=s&&console[yg[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0});function Dn(e,t,n){return ti(e,t,n).callbackRef}function ti(e,t,n){const r=S.useRef(null);let o=i=>{};const s=S.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(i=>{const a=()=>{const l=i[0].target;l.offsetParent!==null&&e(l)};n?a():requestAnimationFrame(a)}):null,[e,n]);return o=i=>{i&&t?(s==null||s.observe(i),r.current=i):(r.current&&(s==null||s.unobserve(r.current)),r.current=null)},{callbackRef:o,ref:r}}function Cg(e,t,n,r,o,s,i,a,l){const u=S.useCallback(d=>{const f=Tg(d.children,t,a?"offsetWidth":"offsetHeight",o);let h=d.parentElement;for(;!h.dataset.virtuosoScroller;)h=h.parentElement;const p=h.lastElementChild.dataset.viewportType==="window";let w;p&&(w=h.ownerDocument.defaultView);const v=i?a?i.scrollLeft:i.scrollTop:p?a?w.scrollX||w.document.documentElement.scrollLeft:w.scrollY||w.document.documentElement.scrollTop:a?h.scrollLeft:h.scrollTop,g=i?a?i.scrollWidth:i.scrollHeight:p?a?w.document.documentElement.scrollWidth:w.document.documentElement.scrollHeight:a?h.scrollWidth:h.scrollHeight,x=i?a?i.offsetWidth:i.offsetHeight:p?a?w.innerWidth:w.innerHeight:a?h.offsetWidth:h.offsetHeight;r({scrollHeight:g,scrollTop:Math.max(v,0),viewportHeight:x}),s==null||s(a?Kl("column-gap",getComputedStyle(d).columnGap,o):Kl("row-gap",getComputedStyle(d).rowGap,o)),f!==null&&e(f)},[e,t,o,s,i,r,a]);return ti(u,n,l)}function Tg(e,t,n,r){const o=e.length;if(o===0)return null;const s=[];for(let i=0;i<o;i++){const a=e.item(i);if(a.dataset.index===void 0)continue;const l=parseInt(a.dataset.index),u=parseFloat(a.dataset.knownSize),d=t(a,n);if(d===0&&r("Zero-sized element, this should not happen",{child:a},kt.ERROR),d===u)continue;const f=s[s.length-1];s.length===0||f.size!==d||f.endIndex!==l-1?s.push({endIndex:l,size:d,startIndex:l}):s[s.length-1].endIndex++}return s}function Kl(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,kt.WARN),t==="normal"?0:parseInt(t??"0",10)}function ql(e,t,n){const r=S.useRef(null),o=S.useCallback(l=>{if(!(l!=null&&l.offsetParent))return;const u=l.getBoundingClientRect(),d=u.width;let f,h;if(t){const p=t.getBoundingClientRect(),w=u.top-p.top;h=p.height-Math.max(0,w),f=w+t.scrollTop}else{const p=i.current.ownerDocument.defaultView;h=p.innerHeight-Math.max(0,u.top),f=u.top+p.scrollY}r.current={offsetTop:f,visibleHeight:h,visibleWidth:d},e(r.current)},[e,t]),{callbackRef:s,ref:i}=ti(o,!0,n),a=S.useCallback(()=>{o(i.current)},[o,i]);return S.useEffect(()=>{var l;if(t){t.addEventListener("scroll",a);const u=new ResizeObserver(()=>{requestAnimationFrame(a)});return u.observe(t),()=>{t.removeEventListener("scroll",a),u.unobserve(t)}}else{const u=(l=i.current)==null?void 0:l.ownerDocument.defaultView;return u==null||u.addEventListener("scroll",a),u==null||u.addEventListener("resize",a),()=>{u==null||u.removeEventListener("scroll",a),u==null||u.removeEventListener("resize",a)}}},[a,t,i]),s}const bt=We(()=>{const e=ze(),t=ze(),n=K(0),r=ze(),o=K(0),s=ze(),i=ze(),a=K(0),l=K(0),u=K(0),d=K(0),f=ze(),h=ze(),p=K(!1),w=K(!1),v=K(!1);return ue(z(e,ne(({scrollTop:g})=>g)),t),ue(z(e,ne(({scrollHeight:g})=>g)),i),ue(t,o),{deviation:n,fixedFooterHeight:u,fixedHeaderHeight:l,footerHeight:d,headerHeight:a,horizontalDirection:w,scrollBy:h,scrollContainerState:e,scrollHeight:i,scrollingInProgress:p,scrollTo:f,scrollTop:t,skipAnimationFrameInResizeObserver:v,smoothScrollTargetReached:r,statefulScrollTop:o,viewportHeight:s}},[],{singleton:!0}),Er={lvl:0};function Gl(e,t){const n=e.length;if(n===0)return[];let{index:r,value:o}=t(e[0]);const s=[];for(let i=1;i<n;i++){const{index:a,value:l}=t(e[i]);s.push({end:a-1,start:r,value:o}),r=a,o=l}return s.push({end:1/0,start:r,value:o}),s}function Ge(e){return e===Er}function Ir(e,t){if(!Ge(e))return t===e.k?e.v:t<e.k?Ir(e.l,t):Ir(e.r,t)}function Vt(e,t,n="k"){if(Ge(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){const r=Vt(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return Vt(e.l,t,n)}function jt(e,t,n){return Ge(e)?Jl(t,n,1):t===e.k?ht(e,{k:t,v:n}):t<e.k?Zl(ht(e,{l:jt(e.l,t,n)})):Zl(ht(e,{r:jt(e.r,t,n)}))}function or(){return Er}function xo(e,t,n){if(Ge(e))return[];const r=Vt(e,t)[0];return kg(ri(e,r,n))}function ni(e,t){if(Ge(e))return Er;const{k:n,l:r,r:o}=e;if(t===n){if(Ge(r))return o;if(Ge(o))return r;{const[s,i]=Xl(r);return vo(ht(e,{k:s,l:Yl(r),v:i}))}}else return t<n?vo(ht(e,{l:ni(r,t)})):vo(ht(e,{r:ni(o,t)}))}function Ln(e){return Ge(e)?[]:[...Ln(e.l),{k:e.k,v:e.v},...Ln(e.r)]}function ri(e,t,n){if(Ge(e))return[];const{k:r,l:o,r:s,v:i}=e;let a=[];return r>t&&(a=a.concat(ri(o,t,n))),r>=t&&r<=n&&a.push({k:r,v:i}),r<=n&&(a=a.concat(ri(s,t,n))),a}function vo(e){const{l:t,lvl:n,r}=e;if(r.lvl>=n-1&&t.lvl>=n-1)return e;if(n>r.lvl+1){if(oi(t))return Ql(ht(e,{lvl:n-1}));if(!Ge(t)&&!Ge(t.r))return ht(t.r,{l:ht(t,{r:t.r.l}),lvl:n,r:ht(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(oi(e))return si(ht(e,{lvl:n-1}));if(!Ge(r)&&!Ge(r.l)){const o=r.l,s=oi(o)?r.lvl-1:r.lvl;return ht(o,{l:ht(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:si(ht(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function ht(e,t){return Jl(t.k!==void 0?t.k:e.k,t.v!==void 0?t.v:e.v,t.lvl!==void 0?t.lvl:e.lvl,t.l!==void 0?t.l:e.l,t.r!==void 0?t.r:e.r)}function Yl(e){return Ge(e.r)?e.l:vo(ht(e,{r:Yl(e.r)}))}function oi(e){return Ge(e)||e.lvl>e.r.lvl}function Xl(e){return Ge(e.r)?[e.k,e.v]:Xl(e.r)}function Jl(e,t,n,r=Er,o=Er){return{k:e,l:r,lvl:n,r:o,v:t}}function Zl(e){return si(Ql(e))}function Ql(e){const{l:t}=e;return!Ge(t)&&t.lvl===e.lvl?ht(t,{r:ht(e,{l:t.r})}):e}function si(e){const{lvl:t,r:n}=e;return!Ge(n)&&!Ge(n.r)&&n.lvl===t&&n.r.lvl===t?ht(n,{l:ht(e,{r:n.l}),lvl:t+1}):e}function kg(e){return Gl(e,({k:t,v:n})=>({index:t,value:n}))}function ec(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function Nr(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const ii=We(()=>({recalcInProgress:K(!1)}),[],{singleton:!0});function tc(e,t,n){return e[wo(e,t,n)]}function wo(e,t,n,r=0){let o=e.length-1;for(;r<=o;){const s=Math.floor((r+o)/2),i=e[s],a=n(i,t);if(a===0)return s;if(a===-1){if(o-r<2)return s-1;o=s-1}else{if(o===r)return s;r=s+1}}throw new Error(`Failed binary finding record in array - ${e.join(",")}, searched for ${t}`)}function Eg(e,t,n,r){const o=wo(e,t,r),s=wo(e,n,r,o);return e.slice(o,s+1)}function bn(e,t){return Math.round(e.getBoundingClientRect()[t])}function bo(e){return!Ge(e.groupOffsetTree)}function ai({index:e},t){return t===e?0:t<e?-1:1}function Ig(){return{groupIndices:[],groupOffsetTree:or(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:or()}}function Ng(e,t){let n=Ge(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),Ge(e)){e=jt(e,0,s);continue}const a=xo(e,i-1,o+1);if(a.some(Mg(r)))continue;let l=!1,u=!1;for(const{end:d,start:f,value:h}of a)l?(o>=f||s===h)&&(e=ni(e,f)):(u=h!==s,l=!0),d>o&&o>=f&&h!==s&&(e=jt(e,o+1,h));u&&(e=jt(e,i,s))}return[e,n]}function Ag(e){return typeof e.groupIndex<"u"}function jg({offset:e},t){return t===e?0:t<e?-1:1}function Ar(e,t,n){if(t.length===0)return 0;const{index:r,offset:o,size:s}=tc(t,e,ai),i=e-r,a=s*i+(i-1)*n+o;return a>0?a+n:a}function nc(e,t){if(!bo(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function rc(e,t,n){if(Ag(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=nc(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function _g(e,t,n,r=0){return r>0&&(t=Math.max(t,tc(e,r,ai).offset)),Gl(Eg(e,t,n,jg),Og)}function Rg(e,[t,n,r,o]){t.length>0&&r("received item sizes",t,kt.DEBUG);const s=e.sizeTree;let i=s,a=0;if(n.length>0&&Ge(s)&&t.length===2){const h=t[0].size,p=t[1].size;i=n.reduce((w,v)=>jt(jt(w,v,h),v+1,p),i)}else[i,a]=Ng(i,t);if(i===s)return e;const{lastIndex:l,lastOffset:u,lastSize:d,offsetTree:f}=li(e.offsetTree,a,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((h,p)=>jt(h,p,Ar(p,f,o)),or()),lastIndex:l,lastOffset:u,lastSize:d,offsetTree:f,sizeTree:i}}function Pg(e){return Ln(e).map(({k:t,v:n},r,o)=>{const s=o[r+1];return{endIndex:s?s.k-1:1/0,size:n,startIndex:t}})}function oc(e,t){let n=0,r=0;for(;n<e;)n+=t[r+1]-t[r]-1,r++;return r-(n===e?0:1)}function li(e,t,n,r){let o=e,s=0,i=0,a=0,l=0;if(t!==0){l=wo(o,t-1,ai),a=o[l].offset;const u=Vt(n,t-1);s=u[0],i=u[1],o.length&&o[l].size===Vt(n,t)[1]&&(l-=1),o=o.slice(0,l+1)}else o=[];for(const{start:u,value:d}of xo(n,t,1/0)){const f=u-s,h=f*i+a+f*r;o.push({index:u,offset:h,size:d}),s=u,a=h,i=d}return{lastIndex:s,lastOffset:a,lastSize:i,offsetTree:o}}function Og(e){return{index:e.index,value:e}}function Mg(e){const{endIndex:t,size:n,startIndex:r}=e;return o=>o.start===r&&(o.end===t||o.end===1/0)&&o.value===n}const Dg={offsetHeight:"height",offsetWidth:"width"},Qt=We(([{log:e},{recalcInProgress:t}])=>{const n=ze(),r=ze(),o=xt(r,0),s=ze(),i=ze(),a=K(0),l=K([]),u=K(void 0),d=K(void 0),f=K((C,T)=>bn(C,Dg[T])),h=K(void 0),p=K(0),w=Ig(),v=xt(z(n,Pe(l,e,p),Zt(Rg,w),nt()),w),g=xt(z(l,nt(),Zt((C,T)=>({current:T,prev:C.current}),{current:[],prev:[]}),ne(({prev:C})=>C)),[]);ue(z(l,be(C=>C.length>0),Pe(v,p),ne(([C,T,I])=>{const A=C.reduce((R,j,M)=>jt(R,j,Ar(j,T.offsetTree,I)||M),or());return{...T,groupIndices:C,groupOffsetTree:A}})),v),ue(z(r,Pe(v),be(([C,{lastIndex:T}])=>C<T),ne(([C,{lastIndex:T,lastSize:I}])=>[{endIndex:T,size:I,startIndex:C}])),n),ue(u,d);const x=xt(z(u,ne(C=>C===void 0)),!0);ue(z(d,be(C=>C!==void 0&&Ge(lt(v).sizeTree)),ne(C=>[{endIndex:0,size:C,startIndex:0}])),n);const b=At(z(n,Pe(v),Zt(({sizes:C},[T,I])=>({changed:I!==C,sizes:I}),{changed:!1,sizes:w}),ne(C=>C.changed)));Ve(z(a,Zt((C,T)=>({diff:C.prev-T,prev:T}),{diff:0,prev:0}),ne(C=>C.diff)),C=>{const{groupIndices:T}=lt(v);if(C>0)je(t,!0),je(s,C+oc(C,T));else if(C<0){const I=lt(g);I.length>0&&(C-=oc(-C,I)),je(i,C)}}),Ve(z(a,Pe(e)),([C,T])=>{C<0&&T("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:a},kt.ERROR)});const y=At(s);ue(z(s,Pe(v),ne(([C,T])=>{const I=T.groupIndices.length>0,A=[],R=T.lastSize;if(I){const j=Ir(T.sizeTree,0);let M=0,D=0;for(;M<C;){const P=T.groupIndices[D],V=T.groupIndices.length===D+1?1/0:T.groupIndices[D+1]-P-1;A.push({endIndex:P,size:j,startIndex:P}),A.push({endIndex:P+1+V-1,size:R,startIndex:P+1}),D++,M+=V+1}const L=Ln(T.sizeTree);return M!==C&&L.shift(),L.reduce((P,{k:V,v:U})=>{let q=P.ranges;return P.prevSize!==0&&(q=[...P.ranges,{endIndex:V+C-1,size:P.prevSize,startIndex:P.prevIndex}]),{prevIndex:V+C,prevSize:U,ranges:q}},{prevIndex:C,prevSize:0,ranges:A}).ranges}return Ln(T.sizeTree).reduce((j,{k:M,v:D})=>({prevIndex:M+C,prevSize:D,ranges:[...j.ranges,{endIndex:M+C-1,size:j.prevSize,startIndex:j.prevIndex}]}),{prevIndex:0,prevSize:R,ranges:[]}).ranges})),n);const E=At(z(i,Pe(v,p),ne(([C,{offsetTree:T},I])=>{const A=-C;return Ar(A,T,I)})));return ue(z(i,Pe(v,p),ne(([C,T,I])=>{if(T.groupIndices.length>0){if(Ge(T.sizeTree))return T;let A=or();const R=lt(g);let j=0,M=0,D=0;for(;j<-C;){D=R[M];const L=R[M+1]-D-1;M++,j+=L+1}if(A=Ln(T.sizeTree).reduce((L,{k:P,v:V})=>jt(L,Math.max(0,P+C),V),A),j!==-C){const L=Ir(T.sizeTree,D);A=jt(A,0,L);const P=Vt(T.sizeTree,-C+1)[1];A=jt(A,1,P)}return{...T,sizeTree:A,...li(T.offsetTree,0,A,I)}}else{const A=Ln(T.sizeTree).reduce((R,{k:j,v:M})=>jt(R,Math.max(0,j+C),M),or());return{...T,sizeTree:A,...li(T.offsetTree,0,A,I)}}})),v),{beforeUnshiftWith:y,data:h,defaultItemSize:d,firstItemIndex:a,fixedItemSize:u,gap:p,groupIndices:l,itemSize:f,listRefresh:b,shiftWith:i,shiftWithOffset:E,sizeRanges:n,sizes:v,statefulTotalCount:o,totalCount:r,trackItemSizes:x,unshiftWith:s}},tt(wn,ii),{singleton:!0});function Lg(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const sc=We(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=ze(),i=ze(),a=At(z(s,ne(Lg)));return ue(z(a,ne(l=>l.totalCount)),n),ue(z(a,ne(l=>l.groupIndices)),e),ue(z(dt(o,t,r),be(([l,u])=>bo(u)),ne(([l,u,d])=>Vt(u.groupOffsetTree,Math.max(l-d,0),"v")[0]),nt(),ne(l=>[l])),i),{groupCounts:s,topItemsIndexes:i}},tt(Qt,bt)),yn=We(([{log:e}])=>{const t=K(!1),n=At(z(t,be(r=>r),nt()));return Ve(t,r=>{r&&lt(e)("props updated",{},kt.DEBUG)}),{didMount:n,propsReady:t}},tt(wn),{singleton:!0}),Fg=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function ic(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!Fg)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const jr=We(([{gap:e,listRefresh:t,sizes:n,totalCount:r},{fixedFooterHeight:o,fixedHeaderHeight:s,footerHeight:i,headerHeight:a,scrollingInProgress:l,scrollTo:u,smoothScrollTargetReached:d,viewportHeight:f},{log:h}])=>{const p=ze(),w=ze(),v=K(0);let g=null,x=null,b=null;function y(){g&&(g(),g=null),b&&(b(),b=null),x&&(clearTimeout(x),x=null),je(l,!1)}return ue(z(p,Pe(n,f,r,v,a,i,h),Pe(e,s,o),ne(([[E,C,T,I,A,R,j,M],D,L,P])=>{const V=ic(E),{align:U,behavior:q,offset:$}=V,N=I-1,W=rc(V,C,N);let Y=Ar(W,C.offsetTree,D)+R;U==="end"?(Y+=L+Vt(C.sizeTree,W)[1]-T+P,W===N&&(Y+=j)):U==="center"?Y+=(L+Vt(C.sizeTree,W)[1]-T+P)/2:Y-=A,$&&(Y+=$);const de=se=>{y(),se?(M("retrying to scroll to",{location:E},kt.DEBUG),je(p,E)):(je(w,!0),M("list did not change, scroll successful",{},kt.DEBUG))};if(y(),q==="smooth"){let se=!1;b=Ve(t,pe=>{se=se||pe}),g=Wt(d,()=>{de(se)})}else g=Wt(z(t,$g(150)),de);return x=setTimeout(()=>{y()},1200),je(l,!0),M("scrolling from index to",{behavior:q,index:W,top:Y},kt.DEBUG),{behavior:q,top:Y}})),u),{scrollTargetReached:w,scrollToIndex:p,topListHeight:v}},tt(Qt,bt,wn),{singleton:!0});function $g(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function ci(e,t){e==0?t():requestAnimationFrame(()=>{ci(e-1,t)})}function ui(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const _r=We(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:s},{didMount:i}])=>{const a=K(!0),l=K(0),u=K(!0);return ue(z(i,Pe(l),be(([d,f])=>!!f),Jt(!1)),a),ue(z(i,Pe(l),be(([d,f])=>!!f),Jt(!1)),u),Ve(z(dt(t,i),Pe(a,n,e,u),be(([[,d],f,{sizeTree:h},p,w])=>d&&(!Ge(h)||Zs(p))&&!f&&!w),Pe(l)),([,d])=>{Wt(o,()=>{je(u,!0)}),ci(4,()=>{Wt(r,()=>{je(a,!0)}),je(s,d)})}),{initialItemFinalLocationReached:u,initialTopMostItemIndex:l,scrolledToInitialItem:a}},tt(Qt,bt,jr,yn),{singleton:!0});function ac(e,t){return Math.abs(e-t)<1.01}const Rr="up",Pr="down",zg="none",Bg={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},Hg=0,Or=We(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=K(!1),a=K(!0),l=ze(),u=ze(),d=K(4),f=K(Hg),h=xt(z(ei(z(ve(o),Mn(1),Jt(!0)),z(ve(o),Mn(1),Jt(!1),Wl(100))),nt()),!1),p=xt(z(ei(z(n,Jt(!0)),z(n,Jt(!1),Wl(200))),nt()),!1);ue(z(dt(ve(o),ve(f)),ne(([b,y])=>b<=y),nt()),a),ue(z(a,hn(50)),u);const w=At(z(dt(r,ve(s),ve(t),ve(e),ve(d)),Zt((b,[{scrollHeight:y,scrollTop:E},C,T,I,A])=>{const R=E+C-y>-A,j={scrollHeight:y,scrollTop:E,viewportHeight:C};if(R){let D,L;return E>b.state.scrollTop?(D="SCROLLED_DOWN",L=b.state.scrollTop-E):(D="SIZE_DECREASED",L=b.state.scrollTop-E||b.scrollTopDelta),{atBottom:!0,atBottomBecause:D,scrollTopDelta:L,state:j}}let M;return j.scrollHeight>b.state.scrollHeight?M="SIZE_INCREASED":C<b.state.viewportHeight?M="VIEWPORT_HEIGHT_DECREASING":E<b.state.scrollTop?M="SCROLLING_UPWARDS":M="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:M,state:j}},Bg),nt((b,y)=>b&&b.atBottom===y.atBottom))),v=xt(z(r,Zt((b,{scrollHeight:y,scrollTop:E,viewportHeight:C})=>{if(ac(b.scrollHeight,y))return{changed:!1,jump:0,scrollHeight:y,scrollTop:E};{const T=y-(E+C)<1;return b.scrollTop!==E&&T?{changed:!0,jump:b.scrollTop-E,scrollHeight:y,scrollTop:E}:{changed:!0,jump:0,scrollHeight:y,scrollTop:E}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),be(b=>b.changed),ne(b=>b.jump)),0);ue(z(w,ne(b=>b.atBottom)),i),ue(z(i,hn(50)),l);const g=K(Pr);ue(z(r,ne(({scrollTop:b})=>b),nt(),Zt((b,y)=>lt(p)?{direction:b.direction,prevScrollTop:y}:{direction:y<b.prevScrollTop?Rr:Pr,prevScrollTop:y},{direction:Pr,prevScrollTop:0}),ne(b=>b.direction)),g),ue(z(r,hn(50),Jt(zg)),g);const x=K(0);return ue(z(h,be(b=>!b),Jt(0)),x),ue(z(o,hn(100),Pe(h),be(([b,y])=>!!y),Zt(([b,y],[E])=>[y,E],[0,0]),ne(([b,y])=>y-b)),x),{atBottomState:w,atBottomStateChange:l,atBottomThreshold:d,atTopStateChange:u,atTopThreshold:f,isAtBottom:i,isAtTop:a,isScrolling:h,lastJumpDueToItemResize:v,scrollDirection:g,scrollVelocity:x}},tt(bt)),yo="top",So="bottom",lc="none";function cc(e,t,n){return typeof e=="number"?n===Rr&&t===yo||n===Pr&&t===So?e:0:n===Rr?t===yo?e.main:e.reverse:t===So?e.main:e.reverse}function uc(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const di=We(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=ze(),i=K(0),a=K(0),l=K(0),u=xt(z(dt(ve(r),ve(o),ve(n),ve(s,Nr),ve(l),ve(i),ve(t),ve(e),ve(a)),ne(([d,f,h,[p,w],v,g,x,b,y])=>{const E=d-b,C=g+x,T=Math.max(h-E,0);let I=lc;const A=uc(y,yo),R=uc(y,So);return p-=b,p+=h+x,w+=h+x,w-=b,p>d+C-A&&(I=Rr),w<d-T+f+R&&(I=Pr),I!==lc?[Math.max(E-h-cc(v,yo,I)-A,0),E-T-x+f+cc(v,So,I)+R]:null}),be(d=>d!=null),nt(Nr)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:l,topListHeight:i,visibleRange:u}},tt(bt),{singleton:!0});function Ug(e,t,n){if(bo(t)){const r=nc(e,t);return[{index:Vt(t.groupOffsetTree,r)[0],offset:0,size:0},{data:n==null?void 0:n[0],index:r,offset:0,size:0}]}return[{data:n==null?void 0:n[0],index:e,offset:0,size:0}]}const fi={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Co(e,t,n,r,o,s){const{lastIndex:i,lastOffset:a,lastSize:l}=o;let u=0,d=0;if(e.length>0){u=e[0].offset;const v=e[e.length-1];d=v.offset+v.size}const f=n-i,h=a+f*l+(f-1)*r,p=u,w=h-d;return{bottom:d,firstItemIndex:s,items:fc(e,o,s),offsetBottom:w,offsetTop:u,top:p,topItems:fc(t,o,s),topListHeight:t.reduce((v,g)=>g.size+v,0),totalCount:n}}function dc(e,t,n,r,o,s){let i=0;if(n.groupIndices.length>0)for(const d of n.groupIndices){if(d-i>=e)break;i++}const a=e+i,l=ui(t,a),u=Array.from({length:a}).map((d,f)=>({data:s[f+l],index:f+l,offset:0,size:0}));return Co(u,[],a,o,n,r)}function fc(e,t,n){if(e.length===0)return[];if(!bo(t))return e.map(u=>({...u,index:u.index+n,originalIndex:u.index}));const r=e[0].index,o=e[e.length-1].index,s=[],i=xo(t.groupOffsetTree,r,o);let a,l=0;for(const u of e){(!a||a.end<u.index)&&(a=i.shift(),l=t.groupIndices.indexOf(a.start));let d;u.index===a.start?d={index:l,type:"group"}:d={groupIndex:l,index:u.index-(l+1)+n},s.push({...d,data:u.data,offset:u.offset,originalIndex:u.index,size:u.size})}return s}const Fn=We(([{data:e,firstItemIndex:t,gap:n,sizes:r,totalCount:o},s,{listBoundary:i,topListHeight:a,visibleRange:l},{initialTopMostItemIndex:u,scrolledToInitialItem:d},{topListHeight:f},h,{didMount:p},{recalcInProgress:w}])=>{const v=K([]),g=K(0),x=ze();ue(s.topItemsIndexes,v);const b=xt(z(dt(p,w,ve(l,Nr),ve(o),ve(r),ve(u),d,ve(v),ve(t),ve(n),e),be(([T,I,,A,,,,,,,R])=>{const j=R&&R.length!==A;return T&&!I&&!j}),ne(([,,[T,I],A,R,j,M,D,L,P,V])=>{const U=R,{offsetTree:q,sizeTree:$}=U,N=lt(g);if(A===0)return{...fi,totalCount:A};if(T===0&&I===0)return N===0?{...fi,totalCount:A}:dc(N,j,R,L,P,V||[]);if(Ge($))return N>0?null:Co(Ug(ui(j,A),U,V),[],A,P,U,L);const W=[];if(D.length>0){const me=D[0],Se=D[D.length-1];let B=0;for(const O of xo($,me,Se)){const G=O.value,Z=Math.max(O.start,me),ce=Math.min(O.end,Se);for(let ie=Z;ie<=ce;ie++)W.push({data:V==null?void 0:V[ie],index:ie,offset:B,size:G}),B+=G}}if(!M)return Co([],W,A,P,U,L);const Y=D.length>0?D[D.length-1]+1:0,de=_g(q,T,I,Y);if(de.length===0)return null;const se=A-1,pe=go([],me=>{for(const Se of de){const B=Se.value;let O=B.offset,G=Se.start;const Z=B.size;if(B.offset<T){G+=Math.floor((T-B.offset+P)/(Z+P));const ie=G-Se.start;O+=ie*Z+ie*P}G<Y&&(O+=(Y-G)*Z,G=Y);const ce=Math.min(Se.end,se);for(let ie=G;ie<=ce&&!(O>=I);ie++)me.push({data:V==null?void 0:V[ie],index:ie,offset:O,size:Z}),O+=Z+P}});return Co(pe,W,A,P,U,L)}),be(T=>T!==null),nt()),fi);ue(z(e,be(Zs),ne(T=>T==null?void 0:T.length)),o),ue(z(b,ne(T=>T.topListHeight)),f),ue(f,a),ue(z(b,ne(T=>[T.top,T.bottom])),i),ue(z(b,ne(T=>T.items)),x);const y=At(z(b,be(({items:T})=>T.length>0),Pe(o,e),be(([{items:T},I])=>T[T.length-1].originalIndex===I-1),ne(([,T,I])=>[T-1,I]),nt(Nr),ne(([T])=>T))),E=At(z(b,hn(200),be(({items:T,topItems:I})=>T.length>0&&T[0].originalIndex===I.length),ne(({items:T})=>T[0].index),nt())),C=At(z(b,be(({items:T})=>T.length>0),ne(({items:T})=>{let I=0,A=T.length-1;for(;T[I].type==="group"&&I<A;)I++;for(;T[A].type==="group"&&A>I;)A--;return{endIndex:T[A].index,startIndex:T[I].index}}),nt(ec)));return{endReached:y,initialItemCount:g,itemsRendered:x,listState:b,rangeChanged:C,startReached:E,topItemsIndexes:v,...h}},tt(Qt,sc,di,_r,jr,Or,yn,ii),{singleton:!0}),hc=We(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=ze(),i=xt(z(dt(n,e,r,t,o),ne(([a,l,u,d,f])=>a+l+u+d+f.offsetBottom+f.bottom)),0);return ue(ve(i),s),{totalListHeight:i,totalListHeightChanged:s}},tt(bt,Fn),{singleton:!0}),Wg=We(([{viewportHeight:e},{totalListHeight:t}])=>{const n=K(!1),r=xt(z(dt(n,e,t),be(([o])=>o),ne(([,o,s])=>Math.max(0,o-s)),hn(0),nt()),0);return{alignToBottom:n,paddingTopAddition:r}},tt(bt,hc),{singleton:!0}),pc=We(()=>({context:K(null)})),Vg=({itemBottom:e,itemTop:t,locationParams:{align:n,behavior:r,...o},viewportBottom:s,viewportTop:i})=>t<i?{...o,align:n??"start",behavior:r}:e>s?{...o,align:n??"end",behavior:r}:null,mc=We(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:s,scrollingInProgress:i,scrollTop:a,viewportHeight:l},{scrollToIndex:u}])=>{const d=ze();return ue(z(d,Pe(t,l,n,s,o,r,a),Pe(e),ne(([[f,h,p,w,v,g,x,b],y])=>{const{align:E,behavior:C,calculateViewLocation:T=Vg,done:I,...A}=f,R=rc(f,h,w-1),j=Ar(R,h.offsetTree,y)+v+g,M=j+Vt(h.sizeTree,R)[1],D=b+g,L=b+p-x,P=T({itemBottom:M,itemTop:j,locationParams:{align:E,behavior:C,...A},viewportBottom:L,viewportTop:D});return P?I&&Wt(z(i,be(V=>!V),Mn(lt(i)?1:2)),I):I&&I(),P}),be(f=>f!==null)),u),{scrollIntoView:d}},tt(Qt,bt,jr,Fn,wn),{singleton:!0});function gc(e){return e?e==="smooth"?"smooth":"auto":!1}const Kg=(e,t)=>typeof e=="function"?gc(e(t)):t&&gc(e),qg=We(([{listRefresh:e,totalCount:t,fixedItemSize:n,data:r},{atBottomState:o,isAtBottom:s},{scrollToIndex:i},{scrolledToInitialItem:a},{didMount:l,propsReady:u},{log:d},{scrollingInProgress:f},{context:h},{scrollIntoView:p}])=>{const w=K(!1),v=ze();let g=null;function x(C){je(i,{align:"end",behavior:C,index:"LAST"})}Ve(z(dt(z(ve(t),Mn(1)),l),Pe(ve(w),s,a,f),ne(([[C,T],I,A,R,j])=>{let M=T&&R,D="auto";return M&&(D=Kg(I,A||j),M=M&&!!D),{followOutputBehavior:D,shouldFollow:M,totalCount:C}}),be(({shouldFollow:C})=>C)),({followOutputBehavior:C,totalCount:T})=>{g&&(g(),g=null),lt(n)?requestAnimationFrame(()=>{lt(d)("following output to ",{totalCount:T},kt.DEBUG),x(C)}):g=Wt(e,()=>{lt(d)("following output to ",{totalCount:T},kt.DEBUG),x(C),g=null})});function b(C){const T=Wt(o,I=>{C&&!I.atBottom&&I.notAtBottomBecause==="SIZE_INCREASED"&&!g&&(lt(d)("scrolling to bottom due to increased size",{},kt.DEBUG),x("auto"))});setTimeout(T,100)}Ve(z(dt(ve(w),t,u),be(([C,,T])=>C&&T),Zt(({value:C},[,T])=>({refreshed:C===T,value:T}),{refreshed:!1,value:0}),be(({refreshed:C})=>C),Pe(w,t)),([,C])=>{lt(a)&&b(C!==!1)}),Ve(v,()=>{b(lt(w)!==!1)}),Ve(dt(ve(w),o),([C,T])=>{C&&!T.atBottom&&T.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&x("auto")});const y=K(null),E=ze();return ue(ei(z(ve(r),ne(C=>{var T;return(T=C==null?void 0:C.length)!=null?T:0})),z(ve(t))),E),Ve(z(dt(z(E,Mn(1)),l),Pe(ve(y),a,f,h),ne(([[C,T],I,A,R,j])=>T&&A&&(I==null?void 0:I({context:j,totalCount:C,scrollingInProgress:R}))),be(C=>!!C),hn(0)),C=>{g&&(g(),g=null),lt(n)?requestAnimationFrame(()=>{lt(d)("scrolling into view",{}),je(p,C)}):g=Wt(e,()=>{lt(d)("scrolling into view",{}),je(p,C),g=null})}),{autoscrollToBottom:v,followOutput:w,scrollIntoViewOnChange:y}},tt(Qt,Or,jr,_r,yn,wn,bt,pc,mc)),Gg=We(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(ue(z(a,Pe(s),be(([,l])=>l!==0),Pe(o,r,t,n,e),ne(([[,l],u,d,f,h,p=[]])=>dc(l,u,d,f,h,p))),i),{}),tt(Qt,_r,Fn,yn),{singleton:!0}),Yg=We(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=K(0);return Ve(z(e,Pe(r),be(([,o])=>o!==0),ne(([,o])=>({top:o}))),o=>{Wt(z(n,Mn(1),be(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{je(t,o)})})}),{initialScrollTop:r}},tt(yn,bt,Fn),{singleton:!0}),xc=We(([{scrollVelocity:e}])=>{const t=K(!1),n=ze(),r=K(!1);return ue(z(e,Pe(r,t,n),be(([o,s])=>!!s),ne(([o,s,i,a])=>{const{enter:l,exit:u}=s;if(i){if(u(o,a))return!1}else if(l(o,a))return!0;return i}),nt()),t),Ve(z(dt(t,e,n),Pe(r)),([[o,s,i],a])=>{o&&a&&a.change&&a.change(s,i)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},tt(Or),{singleton:!0}),hi=We(([{scrollContainerState:e,scrollTo:t}])=>{const n=ze(),r=ze(),o=ze(),s=K(!1),i=K(void 0);return ue(z(dt(n,r),ne(([{scrollHeight:a,scrollTop:l,viewportHeight:u},{offsetTop:d}])=>({scrollHeight:a,scrollTop:Math.max(0,l-d),viewportHeight:u}))),e),ue(z(t,Pe(r),ne(([a,{offsetTop:l}])=>({...a,top:a.top+l}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},tt(bt)),Xg=We(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:a,windowViewportRect:l}])=>{const u=ze(),d=K(void 0),f=K(null),h=K(null);return ue(a,f),ue(l,h),Ve(z(u,Pe(t,r,i,f,h,n)),([p,w,v,g,x,b,y])=>{const E=Pg(w.sizeTree);g&&x!==null&&b!==null&&(v=x.scrollTop-b.offsetTop),v-=y,p({ranges:E,scrollTop:v})}),ue(z(d,be(Zs),ne(Jg)),o),ue(z(s,Pe(d),be(([,p])=>p!==void 0),nt(),ne(([,p])=>p.ranges)),e),{getState:u,restoreStateFrom:d}},tt(Qt,bt,_r,yn,hi));function Jg(e){return{align:"start",index:0,offset:e.scrollTop}}const Zg=We(([{topItemsIndexes:e}])=>{const t=K(0);return ue(z(t,be(n=>n>=0),ne(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},tt(Fn));function vc(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const Qg=vc(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),ex=We(([{deviation:e,scrollBy:t,scrollingInProgress:n,scrollTop:r},{isAtBottom:o,isScrolling:s,lastJumpDueToItemResize:i,scrollDirection:a},{listState:l},{beforeUnshiftWith:u,gap:d,shiftWithOffset:f,sizes:h},{log:p},{recalcInProgress:w}])=>{const v=At(z(l,Pe(i),Zt(([,x,b,y],[{bottom:E,items:C,offsetBottom:T,totalCount:I},A])=>{const R=E+T;let j=0;return b===I&&x.length>0&&C.length>0&&(C[0].originalIndex===0&&x[0].originalIndex===0||(j=R-y,j!==0&&(j+=A))),[j,C,I,R]},[0,[],0,0]),be(([x])=>x!==0),Pe(r,a,n,o,p,w),be(([,x,b,y,,,E])=>!E&&!y&&x!==0&&b===Rr),ne(([[x],,,,,b])=>(b("Upward scrolling compensation",{amount:x},kt.DEBUG),x))));function g(x){x>0?(je(t,{behavior:"auto",top:-x}),je(e,0)):(je(e,0),je(t,{behavior:"auto",top:-x}))}return Ve(z(v,Pe(e,s)),([x,b,y])=>{y&&Qg()?je(e,b-x):g(-x)}),Ve(z(dt(xt(s,!1),e,w),be(([x,b,y])=>!x&&!y&&b!==0),ne(([x,b])=>b),hn(1)),g),ue(z(f,ne(x=>({top:-x}))),t),Ve(z(u,Pe(h,d),ne(([x,{groupIndices:b,lastSize:y,sizeTree:E},C])=>{function T(I){return I*(y+C)}if(b.length===0)return T(x);{let I=0;const A=Ir(E,0);let R=0,j=0;for(;R<x;){R++,I+=A;let M=b.length===j+1?1/0:b[j+1]-b[j]-1;R+M>x&&(I-=A,M=x-R+1),R+=M,I+=T(M),j++}return I}})),x=>{je(e,x),requestAnimationFrame(()=>{je(t,{top:x}),requestAnimationFrame(()=>{je(e,0),je(w,!1)})})}),{deviation:e}},tt(bt,Or,Fn,Qt,wn,ii)),tx=We(([e,t,n,r,o,s,i,a,l,u,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...l,...u,...d}),tt(di,Gg,yn,xc,hc,Yg,Wg,hi,mc,wn,pc)),wc=We(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:r,gap:o,groupIndices:s,itemSize:i,sizeRanges:a,sizes:l,statefulTotalCount:u,totalCount:d,trackItemSizes:f},{initialItemFinalLocationReached:h,initialTopMostItemIndex:p,scrolledToInitialItem:w},v,g,x,{listState:b,topItemsIndexes:y,...E},{scrollToIndex:C},T,{topItemCount:I},{groupCounts:A},R])=>(ue(E.rangeChanged,R.scrollSeekRangeChanged),ue(z(R.windowViewportRect,ne(j=>j.visibleHeight)),v.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,gap:o,groupCounts:A,initialItemFinalLocationReached:h,initialTopMostItemIndex:p,scrolledToInitialItem:w,sizeRanges:a,topItemCount:I,topItemsIndexes:y,totalCount:d,...x,groupIndices:s,itemSize:i,listState:b,scrollToIndex:C,statefulTotalCount:u,trackItemSizes:f,...E,...R,...v,sizes:l,...g}),tt(Qt,_r,bt,Xg,qg,Fn,jr,ex,Zg,sc,tx));function nx(e,t){const n={},r={};let o=0;const s=e.length;for(;o<s;)r[e[o]]=1,o+=1;for(const i in t)Object.hasOwn(r,i)||(n[i]=t[i]);return n}const To=typeof document<"u"?S.useLayoutEffect:S.useEffect;function bc(e,t,n){const r=Object.keys(t.required||{}),o=Object.keys(t.optional||{}),s=Object.keys(t.methods||{}),i=Object.keys(t.events||{}),a=S.createContext({});function l(g,x){g.propsReady&&je(g.propsReady,!1);for(const b of r){const y=g[t.required[b]];je(y,x[b])}for(const b of o)if(b in x){const y=g[t.optional[b]];je(y,x[b])}g.propsReady&&je(g.propsReady,!0)}function u(g){return s.reduce((x,b)=>(x[b]=y=>{const E=g[t.methods[b]];je(E,y)},x),{})}function d(g){return i.reduce((x,b)=>(x[b]=vg(g[t.events[b]]),x),{})}const f=S.forwardRef((g,x)=>{const{children:b,...y}=g,[E]=S.useState(()=>go(bg(e),I=>{l(I,y)})),[C]=S.useState(Ul(d,E));To(()=>{for(const I of i)I in y&&Ve(C[I],y[I]);return()=>{Object.values(C).map(Qs)}},[y,C,E]),To(()=>{l(E,y)}),S.useImperativeHandle(x,Bl(u(E)));const T=n;return c.jsx(a.Provider,{value:E,children:n?c.jsx(T,{...nx([...r,...o,...i],y),children:b}):b})}),h=g=>{const x=S.useContext(a);return S.useCallback(b=>{je(x[g],b)},[x,g])},p=g=>{const x=S.useContext(a)[g],b=S.useCallback(y=>Ve(x,y),[x]);return S.useSyncExternalStore(b,()=>lt(x),()=>lt(x))},w=g=>{const x=S.useContext(a)[g],[b,y]=S.useState(Ul(lt,x));return To(()=>Ve(x,E=>{E!==b&&y(Bl(E))}),[x,b]),b},v=S.version.startsWith("18")?p:w;return{Component:f,useEmitter:(g,x)=>{const b=S.useContext(a)[g];To(()=>Ve(b,x),[x,b])},useEmitterValue:v,usePublisher:h}}const yc=S.createContext(void 0),Sc=S.createContext(void 0),Cc=typeof document<"u"?S.useLayoutEffect:S.useEffect;function pi(e){return"self"in e}function rx(e){return"body"in e}function Tc(e,t,n,r=rr,o,s){const i=S.useRef(null),a=S.useRef(null),l=S.useRef(null),u=S.useCallback(h=>{let p,w,v;const g=h.target;if(rx(g)||pi(g)){const b=pi(g)?g:g.defaultView;v=s?b.scrollX:b.scrollY,p=s?b.document.documentElement.scrollWidth:b.document.documentElement.scrollHeight,w=s?b.innerWidth:b.innerHeight}else v=s?g.scrollLeft:g.scrollTop,p=s?g.scrollWidth:g.scrollHeight,w=s?g.offsetWidth:g.offsetHeight;const x=()=>{e({scrollHeight:p,scrollTop:Math.max(v,0),viewportHeight:w})};h.suppressFlushSync?x():_s.flushSync(x),a.current!==null&&(v===a.current||v<=0||v===p-w)&&(a.current=null,t(!0),l.current&&(clearTimeout(l.current),l.current=null))},[e,t,s]);S.useEffect(()=>{const h=o||i.current;return r(o||i.current),u({suppressFlushSync:!0,target:h}),h.addEventListener("scroll",u,{passive:!0}),()=>{r(null),h.removeEventListener("scroll",u)}},[i,u,n,r,o]);function d(h){const p=i.current;if(!p||(s?"offsetWidth"in p&&p.offsetWidth===0:"offsetHeight"in p&&p.offsetHeight===0))return;const w=h.behavior==="smooth";let v,g,x;pi(p)?(g=Math.max(bn(p.document.documentElement,s?"width":"height"),s?p.document.documentElement.scrollWidth:p.document.documentElement.scrollHeight),v=s?p.innerWidth:p.innerHeight,x=s?window.scrollX:window.scrollY):(g=p[s?"scrollWidth":"scrollHeight"],v=bn(p,s?"width":"height"),x=p[s?"scrollLeft":"scrollTop"]);const b=g-v;if(h.top=Math.ceil(Math.max(Math.min(b,h.top),0)),ac(v,g)||h.top===x){e({scrollHeight:g,scrollTop:x,viewportHeight:v}),w&&t(!0);return}w?(a.current=h.top,l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{l.current=null,a.current=null,t(!0)},1e3)):a.current=null,s&&(h={behavior:h.behavior,left:h.top}),p.scrollTo(h)}function f(h){s&&(h={behavior:h.behavior,left:h.top}),i.current.scrollBy(h)}return{scrollByCallback:f,scrollerRef:i,scrollToCallback:d}}const mi="-webkit-sticky",kc="sticky",gi=vc(()=>{if(typeof document>"u")return kc;const e=document.createElement("div");return e.style.position=mi,e.style.position===mi?mi:kc});function xi(e){return e}const ox=We(()=>{const e=K(a=>`Item ${a}`),t=K(a=>`Group ${a}`),n=K({}),r=K(xi),o=K("div"),s=K(rr),i=(a,l=null)=>xt(z(n,ne(u=>u[a]),nt()),l);return{components:n,computeItemKey:r,EmptyPlaceholder:i("EmptyPlaceholder"),FooterComponent:i("Footer"),GroupComponent:i("Group","div"),groupContent:t,HeaderComponent:i("Header"),HeaderFooterTag:o,ItemComponent:i("Item","div"),itemContent:e,ListComponent:i("List","div"),ScrollerComponent:i("Scroller","div"),scrollerRef:s,ScrollSeekPlaceholder:i("ScrollSeekPlaceholder"),TopItemListComponent:i("TopItemList")}}),sx=We(([e,t])=>({...e,...t}),tt(wc,ox)),ix=({height:e})=>c.jsx("div",{style:{height:e}}),ax={overflowAnchor:"none",position:gi(),zIndex:1},Ec={overflowAnchor:"none"},lx={...Ec,display:"inline-block",height:"100%"},Ic=S.memo(function({showTopList:e=!1}){const t=Ie("listState"),n=Lt("sizeRanges"),r=Ie("useWindowScroll"),o=Ie("customScrollParent"),s=Lt("windowScrollContainerState"),i=Lt("scrollContainerState"),a=o||r?s:i,l=Ie("itemContent"),u=Ie("context"),d=Ie("groupContent"),f=Ie("trackItemSizes"),h=Ie("itemSize"),p=Ie("log"),w=Lt("gap"),v=Ie("horizontalDirection"),{callbackRef:g}=Cg(n,h,f,e?rr:a,p,w,o,v,Ie("skipAnimationFrameInResizeObserver")),[x,b]=S.useState(0);vi("deviation",P=>{x!==P&&b(P)});const y=Ie("EmptyPlaceholder"),E=Ie("ScrollSeekPlaceholder")||ix,C=Ie("ListComponent"),T=Ie("ItemComponent"),I=Ie("GroupComponent"),A=Ie("computeItemKey"),R=Ie("isSeeking"),j=Ie("groupIndices").length>0,M=Ie("alignToBottom"),D=Ie("initialItemFinalLocationReached"),L=e?{}:{boxSizing:"border-box",...v?{display:"inline-block",height:"100%",marginLeft:x!==0?x:M?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:x!==0?x:M?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...D?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&y?c.jsx(y,{...vt(y,u)}):c.jsx(C,{...vt(C,u),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:g,style:L,children:(e?t.topItems:t.items).map(P=>{const V=P.originalIndex,U=A(V+t.firstItemIndex,P.data,u);return R?S.createElement(E,{...vt(E,u),height:P.size,index:P.index,key:U,type:P.type||"item",...P.type==="group"?{}:{groupIndex:P.groupIndex}}):P.type==="group"?S.createElement(I,{...vt(I,u),"data-index":V,"data-item-index":P.index,"data-known-size":P.size,key:U,style:ax},d(P.index,u)):S.createElement(T,{...vt(T,u),...fx(T,P.data),"data-index":V,"data-item-group-index":P.groupIndex,"data-item-index":P.index,"data-known-size":P.size,key:U,style:v?lx:Ec},j?l(P.index,P.groupIndex,P.data,u):l(P.index,P.data,u))})})}),cx={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},ux={outline:"none",overflowX:"auto",position:"relative"},ko=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),dx={position:gi(),top:0,width:"100%",zIndex:1};function vt(e,t){if(typeof e!="string")return{context:t}}function fx(e,t){return{item:typeof e=="string"?void 0:t}}const hx=S.memo(function(){const e=Ie("HeaderComponent"),t=Lt("headerHeight"),n=Ie("HeaderFooterTag"),r=Dn(S.useMemo(()=>s=>{t(bn(s,"height"))},[t]),!0,Ie("skipAnimationFrameInResizeObserver")),o=Ie("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...vt(e,o)})}):null}),px=S.memo(function(){const e=Ie("FooterComponent"),t=Lt("footerHeight"),n=Ie("HeaderFooterTag"),r=Dn(S.useMemo(()=>s=>{t(bn(s,"height"))},[t]),!0,Ie("skipAnimationFrameInResizeObserver")),o=Ie("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...vt(e,o)})}):null});function Nc({useEmitter:e,useEmitterValue:t,usePublisher:n}){return S.memo(function({children:r,style:o,context:s,...i}){const a=n("scrollContainerState"),l=t("ScrollerComponent"),u=n("smoothScrollTargetReached"),d=t("scrollerRef"),f=t("horizontalDirection")||!1,{scrollByCallback:h,scrollerRef:p,scrollToCallback:w}=Tc(a,u,l,d,void 0,f);return e("scrollTo",w),e("scrollBy",h),c.jsx(l,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:p,style:{...f?ux:cx,...o},tabIndex:0,...i,...vt(l,s),children:r})})}function Ac({useEmitter:e,useEmitterValue:t,usePublisher:n}){return S.memo(function({children:r,style:o,context:s,...i}){const a=n("windowScrollContainerState"),l=t("ScrollerComponent"),u=n("smoothScrollTargetReached"),d=t("totalListHeight"),f=t("deviation"),h=t("customScrollParent"),p=S.useRef(null),w=t("scrollerRef"),{scrollByCallback:v,scrollerRef:g,scrollToCallback:x}=Tc(a,u,l,w,h);return Cc(()=>{var b;return g.current=h||((b=p.current)==null?void 0:b.ownerDocument.defaultView),()=>{g.current=null}},[g,h]),e("windowScrollTo",x),e("scrollBy",v),c.jsx(l,{ref:p,"data-virtuoso-scroller":!0,style:{position:"relative",...o,...d!==0?{height:d+f}:{}},...i,...vt(l,s),children:r})})}const mx=({children:e})=>{const t=S.useContext(yc),n=Lt("viewportHeight"),r=Lt("fixedItemHeight"),o=Ie("alignToBottom"),s=Ie("horizontalDirection"),i=S.useMemo(()=>Hl(n,l=>bn(l,s?"width":"height")),[n,s]),a=Dn(i,!0,Ie("skipAnimationFrameInResizeObserver"));return S.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),c.jsx("div",{"data-viewport-type":"element",ref:a,style:ko(o),children:e})},gx=({children:e})=>{const t=S.useContext(yc),n=Lt("windowViewportRect"),r=Lt("fixedItemHeight"),o=Ie("customScrollParent"),s=ql(n,o,Ie("skipAnimationFrameInResizeObserver")),i=Ie("alignToBottom");return S.useEffect(()=>{t&&(r(t.itemHeight),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),c.jsx("div",{"data-viewport-type":"window",ref:s,style:ko(i),children:e})},xx=({children:e})=>{const t=Ie("TopItemListComponent")||"div",n=Ie("headerHeight"),r={...dx,marginTop:`${n}px`},o=Ie("context");return c.jsx(t,{style:r,...vt(t,o),children:e})},vx=S.memo(function(e){const t=Ie("useWindowScroll"),n=Ie("topItemsIndexes").length>0,r=Ie("customScrollParent"),o=Ie("context");return c.jsxs(r||t?yx:bx,{...e,context:o,children:[n&&c.jsx(xx,{children:c.jsx(Ic,{showTopList:!0})}),c.jsxs(r||t?gx:mx,{children:[c.jsx(hx,{}),c.jsx(Ic,{}),c.jsx(px,{})]})]})}),{Component:wx,useEmitter:vi,useEmitterValue:Ie,usePublisher:Lt}=bc(sx,{required:{},optional:{restoreStateFrom:"restoreStateFrom",context:"context",followOutput:"followOutput",scrollIntoViewOnChange:"scrollIntoViewOnChange",itemContent:"itemContent",groupContent:"groupContent",overscan:"overscan",increaseViewportBy:"increaseViewportBy",totalCount:"totalCount",groupCounts:"groupCounts",topItemCount:"topItemCount",firstItemIndex:"firstItemIndex",initialTopMostItemIndex:"initialTopMostItemIndex",components:"components",atBottomThreshold:"atBottomThreshold",atTopThreshold:"atTopThreshold",computeItemKey:"computeItemKey",defaultItemHeight:"defaultItemHeight",fixedItemHeight:"fixedItemHeight",itemSize:"itemSize",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"HeaderFooterTag",data:"data",initialItemCount:"initialItemCount",initialScrollTop:"initialScrollTop",alignToBottom:"alignToBottom",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",horizontalDirection:"horizontalDirection",skipAnimationFrameInResizeObserver:"skipAnimationFrameInResizeObserver"},methods:{scrollToIndex:"scrollToIndex",scrollIntoView:"scrollIntoView",scrollTo:"scrollTo",scrollBy:"scrollBy",autoscrollToBottom:"autoscrollToBottom",getState:"getState"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",totalListHeightChanged:"totalListHeightChanged",itemsRendered:"itemsRendered",groupIndices:"groupIndices"}},vx),bx=Nc({useEmitter:vi,useEmitterValue:Ie,usePublisher:Lt}),yx=Ac({useEmitter:vi,useEmitterValue:Ie,usePublisher:Lt}),Sx=wx;tt(wc,We(()=>{const e=K(u=>c.jsxs("td",{children:["Item $",u]})),t=K(null),n=K(u=>c.jsxs("td",{colSpan:1e3,children:["Group ",u]})),r=K(null),o=K(null),s=K({}),i=K(xi),a=K(rr),l=(u,d=null)=>xt(z(s,ne(f=>f[u]),nt()),d);return{components:s,computeItemKey:i,context:t,EmptyPlaceholder:l("EmptyPlaceholder"),FillerRow:l("FillerRow"),fixedFooterContent:o,fixedHeaderContent:r,itemContent:e,groupContent:n,ScrollerComponent:l("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder"),TableBodyComponent:l("TableBody","tbody"),TableComponent:l("Table","table"),TableFooterComponent:l("TableFoot","tfoot"),TableHeadComponent:l("TableHead","thead"),TableRowComponent:l("TableRow","tr"),GroupComponent:l("Group","tr")}})),gi();const jc={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},Cx={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:_c,floor:Eo,max:Mr,min:wi,round:Rc}=Math;function Pc(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function Tx(e){return{...Cx,items:e}}function Io(e,t){return e&&e.width===t.width&&e.height===t.height}function kx(e,t){return e&&e.column===t.column&&e.row===t.row}const Ex=We(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:r},{footerHeight:o,headerHeight:s,scrollBy:i,scrollContainerState:a,scrollTo:l,scrollTop:u,smoothScrollTargetReached:d,viewportHeight:f},h,p,{didMount:w,propsReady:v},{customScrollParent:g,useWindowScroll:x,windowScrollContainerState:b,windowScrollTo:y,windowViewportRect:E},C])=>{const T=K(0),I=K(0),A=K(jc),R=K({height:0,width:0}),j=K({height:0,width:0}),M=ze(),D=ze(),L=K(0),P=K(null),V=K({column:0,row:0}),U=ze(),q=ze(),$=K(!1),N=K(0),W=K(!0),Y=K(!1),de=K(!1);Ve(z(w,Pe(N),be(([O,G])=>!!G)),()=>{je(W,!1)}),Ve(z(dt(w,W,j,R,N,Y),be(([O,G,Z,ce,,ie])=>O&&!G&&Z.height!==0&&ce.height!==0&&!ie)),([,,,,O])=>{je(Y,!0),ci(1,()=>{je(M,O)}),Wt(z(u),()=>{je(t,[0,0]),je(W,!0)})}),ue(z(q,be(O=>O!=null&&O.scrollTop>0),Jt(0)),I),Ve(z(w,Pe(q),be(([,O])=>O!=null)),([,O])=>{O&&(je(R,O.viewport),je(j,O.item),je(V,O.gap),O.scrollTop>0&&(je($,!0),Wt(z(u,Mn(1)),G=>{je($,!1)}),je(l,{top:O.scrollTop})))}),ue(z(R,ne(({height:O})=>O)),f),ue(z(dt(ve(R,Io),ve(j,Io),ve(V,(O,G)=>O&&O.column===G.column&&O.row===G.row),ve(u)),ne(([O,G,Z,ce])=>({gap:Z,item:G,scrollTop:ce,viewport:O}))),U),ue(z(dt(ve(T),r,ve(V,kx),ve(j,Io),ve(R,Io),ve(P),ve(I),ve($),ve(W),ve(N)),be(([,,,,,,,O])=>!O),ne(([O,[G,Z],ce,ie,De,Xe,Je,,Ne,Oe])=>{const{column:Qe,row:Re}=ce,{height:st,width:ct}=ie,{width:Q}=De;if(Je===0&&(O===0||Q===0))return jc;if(ct===0){const J=ui(Oe,O),Te=J+Math.max(Je-1,0);return Tx(Pc(J,Te,Xe))}const le=Oc(Q,ct,Qe);let ge,Ce;Ne?G===0&&Z===0&&Je>0?(ge=0,Ce=Je-1):(ge=le*Eo((G+Re)/(st+Re)),Ce=le*_c((Z+Re)/(st+Re))-1,Ce=wi(O-1,Mr(Ce,le-1)),ge=wi(Ce,Mr(0,ge))):(ge=0,Ce=-1);const we=Pc(ge,Ce,Xe),{bottom:_e,top:et}=Mc(De,ce,ie,we),Ke=_c(O/le),F=Ke*st+(Ke-1)*Re-_e;return{bottom:_e,itemHeight:st,items:we,itemWidth:ct,offsetBottom:F,offsetTop:et,top:et}})),A),ue(z(P,be(O=>O!==null),ne(O=>O.length)),T),ue(z(dt(R,j,A,V),be(([O,G,{items:Z}])=>Z.length>0&&G.height!==0&&O.height!==0),ne(([O,G,{items:Z},ce])=>{const{bottom:ie,top:De}=Mc(O,ce,G,Z);return[De,ie]}),nt(Nr)),t);const se=K(!1);ue(z(u,Pe(se),ne(([O,G])=>G||O!==0)),se);const pe=At(z(dt(A,T),be(([{items:O}])=>O.length>0),Pe(se),be(([[O,G],Z])=>{const ce=O.items[O.items.length-1].index===G-1;return(Z||O.bottom>0&&O.itemHeight>0&&O.offsetBottom===0&&O.items.length===G)&&ce}),ne(([[,O]])=>O-1),nt())),me=At(z(ve(A),be(({items:O})=>O.length>0&&O[0].index===0),Jt(0),nt())),Se=At(z(ve(A),Pe($),be(([{items:O},G])=>O.length>0&&!G),ne(([{items:O}])=>({endIndex:O[O.length-1].index,startIndex:O[0].index})),nt(ec),hn(0)));ue(Se,p.scrollSeekRangeChanged),ue(z(M,Pe(R,j,T,V),ne(([O,G,Z,ce,ie])=>{const De=ic(O),{align:Xe,behavior:Je,offset:Ne}=De;let Oe=De.index;Oe==="LAST"&&(Oe=ce-1),Oe=Mr(0,Oe,wi(ce-1,Oe));let Qe=bi(G,ie,Z,Oe);return Xe==="end"?Qe=Rc(Qe-G.height+Z.height):Xe==="center"&&(Qe=Rc(Qe-G.height/2+Z.height/2)),Ne&&(Qe+=Ne),{behavior:Je,top:Qe}})),l);const B=xt(z(A,ne(O=>O.offsetBottom+O.bottom)),0);return ue(z(E,ne(O=>({height:O.visibleHeight,width:O.visibleWidth}))),R),{customScrollParent:g,data:P,deviation:L,footerHeight:o,gap:V,headerHeight:s,increaseViewportBy:e,initialItemCount:I,itemDimensions:j,overscan:n,restoreStateFrom:q,scrollBy:i,scrollContainerState:a,scrollHeight:D,scrollTo:l,scrollToIndex:M,scrollTop:u,smoothScrollTargetReached:d,totalCount:T,useWindowScroll:x,viewportDimensions:R,windowScrollContainerState:b,windowScrollTo:y,windowViewportRect:E,...p,gridState:A,horizontalDirection:de,initialTopMostItemIndex:N,totalListHeight:B,...h,endReached:pe,propsReady:v,rangeChanged:Se,startReached:me,stateChanged:U,stateRestoreInProgress:$,...C}},tt(di,bt,Or,xc,yn,hi,wn));function Oc(e,t,n){return Mr(1,Eo((e+n)/(Eo(t)+n)))}function Mc(e,t,n,r){const{height:o}=n;if(o===void 0||r.length===0)return{bottom:0,top:0};const s=bi(e,t,n,r[0].index);return{bottom:bi(e,t,n,r[r.length-1].index)+o,top:s}}function bi(e,t,n,r){const o=Oc(e.width,n.width,t.column),s=Eo(r/o),i=s*n.height+Mr(0,s-1)*t.row;return i>0?i+t.row:i}const Ix=We(()=>{const e=K(f=>`Item ${f}`),t=K({}),n=K(null),r=K("virtuoso-grid-item"),o=K("virtuoso-grid-list"),s=K(xi),i=K("div"),a=K(rr),l=(f,h=null)=>xt(z(t,ne(p=>p[f]),nt()),h),u=K(!1),d=K(!1);return ue(ve(d),u),{components:t,computeItemKey:s,context:n,FooterComponent:l("Footer"),HeaderComponent:l("Header"),headerFooterTag:i,itemClassName:r,ItemComponent:l("Item","div"),itemContent:e,listClassName:o,ListComponent:l("List","div"),readyStateChanged:u,reportReadyState:d,ScrollerComponent:l("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder","div")}}),Nx=We(([e,t])=>({...e,...t}),tt(Ex,Ix)),Ax=S.memo(function(){const e=rt("gridState"),t=rt("listClassName"),n=rt("itemClassName"),r=rt("itemContent"),o=rt("computeItemKey"),s=rt("isSeeking"),i=Ft("scrollHeight"),a=rt("ItemComponent"),l=rt("ListComponent"),u=rt("ScrollSeekPlaceholder"),d=rt("context"),f=Ft("itemDimensions"),h=Ft("gap"),p=rt("log"),w=rt("stateRestoreInProgress"),v=Ft("reportReadyState"),g=Dn(S.useMemo(()=>x=>{const b=x.parentElement.parentElement.scrollHeight;i(b);const y=x.firstChild;if(y){const{height:E,width:C}=y.getBoundingClientRect();f({height:E,width:C})}h({column:Lc("column-gap",getComputedStyle(x).columnGap,p),row:Lc("row-gap",getComputedStyle(x).rowGap,p)})},[i,f,h,p]),!0,!1);return Cc(()=>{e.itemHeight>0&&e.itemWidth>0&&v(!0)},[e]),w?null:c.jsx(l,{className:t,ref:g,...vt(l,d),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(x=>{const b=o(x.index,x.data,d);return s?c.jsx(u,{...vt(u,d),height:e.itemHeight,index:x.index,width:e.itemWidth},b):S.createElement(a,{...vt(a,d),className:n,"data-index":x.index,key:b},r(x.index,x.data,d))})})}),jx=S.memo(function(){const e=rt("HeaderComponent"),t=Ft("headerHeight"),n=rt("headerFooterTag"),r=Dn(S.useMemo(()=>s=>{t(bn(s,"height"))},[t]),!0,!1),o=rt("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...vt(e,o)})}):null}),_x=S.memo(function(){const e=rt("FooterComponent"),t=Ft("footerHeight"),n=rt("headerFooterTag"),r=Dn(S.useMemo(()=>s=>{t(bn(s,"height"))},[t]),!0,!1),o=rt("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...vt(e,o)})}):null}),Rx=({children:e})=>{const t=S.useContext(Sc),n=Ft("itemDimensions"),r=Ft("viewportDimensions"),o=Dn(S.useMemo(()=>s=>{r(s.getBoundingClientRect())},[r]),!0,!1);return S.useEffect(()=>{t&&(r({height:t.viewportHeight,width:t.viewportWidth}),n({height:t.itemHeight,width:t.itemWidth}))},[t,r,n]),c.jsx("div",{ref:o,style:ko(!1),children:e})},Px=({children:e})=>{const t=S.useContext(Sc),n=Ft("windowViewportRect"),r=Ft("itemDimensions"),o=rt("customScrollParent"),s=ql(n,o,!1);return S.useEffect(()=>{t&&(r({height:t.itemHeight,width:t.itemWidth}),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:t.viewportWidth}))},[t,n,r]),c.jsx("div",{ref:s,style:ko(!1),children:e})},Ox=S.memo(function({...e}){const t=rt("useWindowScroll"),n=rt("customScrollParent"),r=n||t?Dx:Mx,o=n||t?Px:Rx,s=rt("context");return c.jsx(r,{...e,...vt(r,s),children:c.jsxs(o,{children:[c.jsx(jx,{}),c.jsx(Ax,{}),c.jsx(_x,{})]})})}),{useEmitter:Dc,useEmitterValue:rt,usePublisher:Ft}=bc(Nx,{optional:{context:"context",totalCount:"totalCount",overscan:"overscan",itemContent:"itemContent",components:"components",computeItemKey:"computeItemKey",data:"data",initialItemCount:"initialItemCount",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"headerFooterTag",listClassName:"listClassName",itemClassName:"itemClassName",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",restoreStateFrom:"restoreStateFrom",initialTopMostItemIndex:"initialTopMostItemIndex",increaseViewportBy:"increaseViewportBy"},methods:{scrollTo:"scrollTo",scrollBy:"scrollBy",scrollToIndex:"scrollToIndex"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",stateChanged:"stateChanged",readyStateChanged:"readyStateChanged"}},Ox),Mx=Nc({useEmitter:Dc,useEmitterValue:rt,usePublisher:Ft}),Dx=Ac({useEmitter:Dc,useEmitterValue:rt,usePublisher:Ft});function Lc(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,kt.WARN),t==="normal"?0:parseInt(t??"0",10)}const Lx=Qr.cva("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function yi({className:e,variant:t,...n}){return c.jsx("div",{className:X(Lx({variant:t}),e),...n})}function oe(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}function Fx(e,t){const n=m.createContext(t),r=s=>{const{children:i,...a}=s,l=m.useMemo(()=>a,Object.values(a));return c.jsx(n.Provider,{value:l,children:i})};r.displayName=e+"Provider";function o(s){const i=m.useContext(n);if(i)return i;if(t!==void 0)return t;throw new Error(`\`${s}\` must be used within \`${e}\``)}return[r,o]}function en(e,t=[]){let n=[];function r(s,i){const a=m.createContext(i),l=n.length;n=[...n,i];const u=f=>{var x;const{scope:h,children:p,...w}=f,v=((x=h==null?void 0:h[e])==null?void 0:x[l])||a,g=m.useMemo(()=>w,Object.values(w));return c.jsx(v.Provider,{value:g,children:p})};u.displayName=s+"Provider";function d(f,h){var v;const p=((v=h==null?void 0:h[e])==null?void 0:v[l])||a,w=m.useContext(p);if(w)return w;if(i!==void 0)return i;throw new Error(`\`${f}\` must be used within \`${s}\``)}return[u,d]}const o=()=>{const s=n.map(i=>m.createContext(i));return function(a){const l=(a==null?void 0:a[e])||s;return m.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return o.scopeName=e,[r,$x(o,...t)]}function $x(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(s){const i=r.reduce((a,{useScope:l,scopeName:u})=>{const f=l(s)[`__scope${u}`];return{...a,...f}},{});return m.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var pt=globalThis!=null&&globalThis.document?m.useLayoutEffect:()=>{},zx=m[" useInsertionEffect ".trim().toString()]||pt;function $n({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=Bx({defaultProp:t,onChange:n}),a=e!==void 0,l=a?e:o;{const d=m.useRef(e!==void 0);m.useEffect(()=>{const f=d.current;f!==a&&console.warn(`${r} is changing from ${f?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),d.current=a},[a,r])}const u=m.useCallback(d=>{var f;if(a){const h=Hx(d)?d(e):d;h!==e&&((f=i.current)==null||f.call(i,h))}else s(d)},[a,e,s,i]);return[l,u]}function Bx({defaultProp:e,onChange:t}){const[n,r]=m.useState(e),o=m.useRef(n),s=m.useRef(t);return zx(()=>{s.current=t},[t]),m.useEffect(()=>{var i;o.current!==n&&((i=s.current)==null||i.call(s,n),o.current=n)},[n,o]),[n,r,s]}function Hx(e){return typeof e=="function"}function Fc(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Si(...e){return t=>{let n=!1;const r=e.map(o=>{const s=Fc(o,t);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let o=0;o<r.length;o++){const s=r[o];typeof s=="function"?s():Fc(e[o],null)}}}}function Fe(...e){return m.useCallback(Si(...e),e)}var Ux=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],ye=Ux.reduce((e,t)=>{const n=_n.createSlot(`Primitive.${t}`),r=m.forwardRef((o,s)=>{const{asChild:i,...a}=o,l=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),c.jsx(l,{...a,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function $c(e,t){e&&eo.flushSync(()=>e.dispatchEvent(t))}function Wx(e,t){return m.useReducer((n,r)=>t[n][r]??n,e)}var _t=e=>{const{present:t,children:n}=e,r=Vx(t),o=typeof n=="function"?n({present:r.isPresent}):m.Children.only(n),s=Fe(r.ref,Kx(o));return typeof n=="function"||r.isPresent?m.cloneElement(o,{ref:s}):null};_t.displayName="Presence";function Vx(e){const[t,n]=m.useState(),r=m.useRef(null),o=m.useRef(e),s=m.useRef("none"),i=e?"mounted":"unmounted",[a,l]=Wx(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return m.useEffect(()=>{const u=No(r.current);s.current=a==="mounted"?u:"none"},[a]),pt(()=>{const u=r.current,d=o.current;if(d!==e){const h=s.current,p=No(u);e?l("MOUNT"):p==="none"||(u==null?void 0:u.display)==="none"?l("UNMOUNT"):l(d&&h!==p?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,l]),pt(()=>{if(t){let u;const d=t.ownerDocument.defaultView??window,f=p=>{const v=No(r.current).includes(CSS.escape(p.animationName));if(p.target===t&&v&&(l("ANIMATION_END"),!o.current)){const g=t.style.animationFillMode;t.style.animationFillMode="forwards",u=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=g)})}},h=p=>{p.target===t&&(s.current=No(r.current))};return t.addEventListener("animationstart",h),t.addEventListener("animationcancel",f),t.addEventListener("animationend",f),()=>{d.clearTimeout(u),t.removeEventListener("animationstart",h),t.removeEventListener("animationcancel",f),t.removeEventListener("animationend",f)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:m.useCallback(u=>{r.current=u?getComputedStyle(u):null,n(u)},[])}}function No(e){return(e==null?void 0:e.animationName)||"none"}function Kx(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var qx=m[" useId ".trim().toString()]||(()=>{}),Gx=0;function tn(e){const[t,n]=m.useState(qx());return pt(()=>{n(r=>r??String(Gx++))},[e]),e||(t?`radix-${t}`:"")}var Ao="Collapsible",[Yx,OC]=en(Ao),[Xx,Ci]=Yx(Ao),zc=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:o,disabled:s,onOpenChange:i,...a}=e,[l,u]=$n({prop:r,defaultProp:o??!1,onChange:i,caller:Ao});return c.jsx(Xx,{scope:n,disabled:s,contentId:tn(),open:l,onOpenToggle:m.useCallback(()=>u(d=>!d),[u]),children:c.jsx(ye.div,{"data-state":ki(l),"data-disabled":s?"":void 0,...a,ref:t})})});zc.displayName=Ao;var Bc="CollapsibleTrigger",Hc=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,o=Ci(Bc,n);return c.jsx(ye.button,{type:"button","aria-controls":o.contentId,"aria-expanded":o.open||!1,"data-state":ki(o.open),"data-disabled":o.disabled?"":void 0,disabled:o.disabled,...r,ref:t,onClick:oe(e.onClick,o.onOpenToggle)})});Hc.displayName=Bc;var Ti="CollapsibleContent",Jx=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Ci(Ti,e.__scopeCollapsible);return c.jsx(_t,{present:n||o.open,children:({present:s})=>c.jsx(Zx,{...r,ref:t,present:s})})});Jx.displayName=Ti;var Zx=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:o,...s}=e,i=Ci(Ti,n),[a,l]=m.useState(r),u=m.useRef(null),d=Fe(t,u),f=m.useRef(0),h=f.current,p=m.useRef(0),w=p.current,v=i.open||a,g=m.useRef(v),x=m.useRef(void 0);return m.useEffect(()=>{const b=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(b)},[]),pt(()=>{const b=u.current;if(b){x.current=x.current||{transitionDuration:b.style.transitionDuration,animationName:b.style.animationName},b.style.transitionDuration="0s",b.style.animationName="none";const y=b.getBoundingClientRect();f.current=y.height,p.current=y.width,g.current||(b.style.transitionDuration=x.current.transitionDuration,b.style.animationName=x.current.animationName),l(r)}},[i.open,r]),c.jsx(ye.div,{"data-state":ki(i.open),"data-disabled":i.disabled?"":void 0,id:i.contentId,hidden:!v,...s,ref:d,style:{"--radix-collapsible-content-height":h?`${h}px`:void 0,"--radix-collapsible-content-width":w?`${w}px`:void 0,...e.style},children:v&&o})});function ki(e){return e?"open":"closed"}var Qx=zc;const Uc=Qx,Wc=Hc,Dr=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:X("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));Dr.displayName="Card";const Lr=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:X("flex flex-col space-y-1.5 p-6",e),...t}));Lr.displayName="CardHeader";const Fr=m.forwardRef(({className:e,...t},n)=>c.jsx("h3",{ref:n,className:X("text-2xl font-semibold leading-none tracking-tight",e),...t}));Fr.displayName="CardTitle";const Vc=m.forwardRef(({className:e,...t},n)=>c.jsx("p",{ref:n,className:X("text-sm text-muted-foreground",e),...t}));Vc.displayName="CardDescription";const jo=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:X("p-6 pt-0",e),...t}));jo.displayName="CardContent";const Kc=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:X("flex items-center p-6 pt-0",e),...t}));Kc.displayName="CardFooter";function qc(){return{async:!1,baseUrl:null,breaks:!1,extensions:null,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,hooks:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:null,sanitize:!1,sanitizer:null,silent:!1,smartypants:!1,tokenizer:null,walkTokens:null,xhtml:!1}}let zn=qc();function ev(e){zn=e}const Gc=/[&<>"']/,tv=new RegExp(Gc.source,"g"),Yc=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,nv=new RegExp(Yc.source,"g"),rv={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Xc=e=>rv[e];function wt(e,t){if(t){if(Gc.test(e))return e.replace(tv,Xc)}else if(Yc.test(e))return e.replace(nv,Xc);return e}const ov=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function Jc(e){return e.replace(ov,(t,n)=>(n=n.toLowerCase(),n==="colon"?":":n.charAt(0)==="#"?n.charAt(1)==="x"?String.fromCharCode(parseInt(n.substring(2),16)):String.fromCharCode(+n.substring(1)):""))}const sv=/(^|[^\[])\^/g;function Ye(e,t){e=typeof e=="string"?e:e.source,t=t||"";const n={replace:(r,o)=>(o=o.source||o,o=o.replace(sv,"$1"),e=e.replace(r,o),n),getRegex:()=>new RegExp(e,t)};return n}const iv=/[^\w:]/g,av=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function Zc(e,t,n){if(e){let r;try{r=decodeURIComponent(Jc(n)).replace(iv,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}t&&!av.test(n)&&(n=dv(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const _o={},lv=/^[^:]+:\/*[^/]*$/,cv=/^([^:]+:)[\s\S]*$/,uv=/^([^:]+:\/*[^/]*)[\s\S]*$/;function dv(e,t){_o[" "+e]||(lv.test(e)?_o[" "+e]=e+"/":_o[" "+e]=Po(e,"/",!0)),e=_o[" "+e];const n=e.indexOf(":")===-1;return t.substring(0,2)==="//"?n?t:e.replace(cv,"$1")+t:t.charAt(0)==="/"?n?t:e.replace(uv,"$1")+t:e+t}const Ro={exec:function(){}};function Qc(e,t){const n=e.replace(/\|/g,(s,i,a)=>{let l=!1,u=i;for(;--u>=0&&a[u]==="\\";)l=!l;return l?"|":" |"}),r=n.split(/ \|/);let o=0;if(r[0].trim()||r.shift(),r.length>0&&!r[r.length-1].trim()&&r.pop(),r.length>t)r.splice(t);else for(;r.length<t;)r.push("");for(;o<r.length;o++)r[o]=r[o].trim().replace(/\\\|/g,"|");return r}function Po(e,t,n){const r=e.length;if(r===0)return"";let o=0;for(;o<r;){const s=e.charAt(r-o-1);if(s===t&&!n)o++;else if(s!==t&&n)o++;else break}return e.slice(0,r-o)}function fv(e,t){if(e.indexOf(t[1])===-1)return-1;const n=e.length;let r=0,o=0;for(;o<n;o++)if(e[o]==="\\")o++;else if(e[o]===t[0])r++;else if(e[o]===t[1]&&(r--,r<0))return o;return-1}function hv(e){e&&e.sanitize&&!e.silent&&console.warn("marked(): sanitize and sanitizer parameters are deprecated since version 0.7.0, should not be used and will be removed in the future. Read more here: https://marked.js.org/#/USING_ADVANCED.md#options")}function eu(e,t){if(t<1)return"";let n="";for(;t>1;)t&1&&(n+=e),t>>=1,e+=e;return n+e}function tu(e,t,n,r){const o=t.href,s=t.title?wt(t.title):null,i=e[1].replace(/\\([\[\]])/g,"$1");if(e[0].charAt(0)!=="!"){r.state.inLink=!0;const a={type:"link",raw:n,href:o,title:s,text:i,tokens:r.inlineTokens(i)};return r.state.inLink=!1,a}return{type:"image",raw:n,href:o,title:s,text:wt(i)}}function pv(e,t){const n=e.match(/^(\s+)(?:```)/);if(n===null)return t;const r=n[1];return t.split(`
37
+ `))>=0;){const le=B.slice(0,Q);B=B.slice(Q+2);const me=sg(le);if(!me)continue;let Ce;try{Ce=JSON.parse(me)}catch{console.debug("[use-chat] malformed SSE:",me.slice(0,200));continue}const we=og(Ce)?Ce.data:Ce;De=Date.now();const _e=we.seq;if(_e!==void 0){if(_e<=G){console.debug("[use-chat] drop duplicate/out-of-order event",{seq:_e,lastProcessedSeq:G,type:we.type});continue}G>0&&_e>G+1&&((N=D==null?void 0:D.onGap)==null||N.call(D,{from:G,to:_e})),G=_e,C.current=_e,g(_e)}if(M==null||M(we),we.type==="token"&&e.autoAppendAssistant!==!1)O.push(we.content),ie();else if(we.type==="message_delta"){const et=we.delta.filter(Ke=>Ke.type==="text").map(Ke=>Ke.text).join("");et&&e.autoAppendAssistant!==!1&&(O.push(et),ie())}else we.type==="heartbeat"?console.debug("[use-chat] heartbeat received"):(Z!==null&&cancelAnimationFrame(Z),ce(),we.type==="checkpoint"?w(we.checkpointId):we.type==="error"&&d(we.message))}}ce()}catch(Ne){if(Ne.name!=="AbortError"){const Oe=Ne.message||String(Ne);d(Oe),(W=D==null?void 0:D.onError)==null||W.call(D,Oe)}}finally{try{await ge.cancel()}catch{}finally{(Y=ge.releaseLock)==null||Y.call(ge)}Z!==null&&typeof window<"u"&&window.cancelAnimationFrame(Z),clearInterval(Xe),l(!1),b(!1),y.current=null,C.current=0,g(0)}}catch(se){if(se.name!=="AbortError"){const pe=se.message||String(se);d(pe),(de=D==null?void 0:D.onError)==null||de.call(D,pe)}}finally{l(!1),b(!1),y.current=null,C.current=0,g(0)}})(),{close:()=>L.abort()}},[t,n,r,e.autoAppendAssistant]);return S.useEffect(()=>()=>{var j;k.current=!1,(j=y.current)==null||j.abort()},[]),{isStreaming:a,error:u,assistantText:f,lastCheckpointId:p,lastSeq:v,connected:x,stream:R,stop:I,clear:A,setToken:T}}function og(e){return!!e&&typeof e=="object"&&e.protocolVersion==="v1"&&"data"in e}function sg(e){const t=e.split(/\r?\n/),n=[];for(const r of t)if(r&&!r.startsWith(":")&&r.startsWith("data:")){const o=r.slice(5);n.push(o.startsWith(" ")?o.slice(1):o)}return n.length===0?null:n.join(`
38
+ `)}function ig({baseUrl:e,onThreadInfo:t,onMessageEvent:n,onUnhandledEvent:r,onSequenceGap:o}){const s=S.useRef(null),i=S.useCallback(p=>{const w=p.seq??null;if(w!==null){const v=s.current;if(v!==null){if(w<=v)return;w>v+1&&(o==null||o({from:v,to:w}))}s.current=w}if(p.type==="thread_info"){console.log("[useChatStreamingService] 🎯 Received thread_info event:",p),t(p);return}if(Ym(p)){n(p);return}r==null||r(p)},[n,o,t,r]),{stream:a,stop:l,isStreaming:u,error:d,setToken:f}=Ol({baseUrl:e,token:null}),h=S.useCallback((p,w)=>{s.current=null,a(p,i,{onOpen:w==null?void 0:w.onOpen,onError:v=>{var g;(g=w==null?void 0:w.onError)==null||g.call(w,v)},onGap:(w==null?void 0:w.onGap)??o})},[i,o,a]);return S.useMemo(()=>({startStream:h,stop:l,isStreaming:u,error:d,setAuthToken:f}),[h,l,u,d,f])}const Ml=S.createContext(null),Dl=S.createContext(null),Ll=S.createContext(null),ag=S.createContext(!1),lg=20;function cg({children:e,initialThreadId:t=null,autoLoadInitial:n=!0,disableAutoRestore:r=!1,enableFileAgentRouting:o=!1,fileAgentId:s="invoice_reader",onError:i,onThreadChange:a}){const{api:l,baseUrl:u}=qs(),d=S.useMemo(()=>fn(u),[u]),[f,h]=S.useState([]),[p,w]=S.useState(t),[v,g]=S.useState(!1),[x,b]=S.useState(!1),[y,k]=S.useState(!1),[C,T]=S.useState(!1),[I,A]=S.useState(null),[R,j]=S.useState(void 0),[M,D]=S.useState(void 0),{state:L,seed:P,prepend:V,pushUser:U,onEvent:q,reset:F}=Rl(),N=S.useRef(p);S.useEffect(()=>{N.current=p},[p]);const W=S.useRef(!1),Y=S.useRef([]),de=S.useRef(null),se=S.useRef(null),pe=S.useCallback(($,J)=>new Promise((Te,Me)=>{const Le=async()=>{W.current=!0;try{await $(),Te()}catch(it){Me(it)}finally{W.current=!1;const it=Y.current.shift();it&&it().catch(()=>{})}};W.current?Y.current.push(Le):Le().catch(it=>{Me(it)})}),[]),ge=S.useCallback(async()=>{g(!0);try{const $=await l.listThreads();h($)}catch($){i==null||i(String($)),console.error("[ChatSessionProvider] Failed to refresh threads:",$)}finally{g(!1)}},[l,i]),Se=S.useRef(!1),B=S.useCallback(($,J)=>{const Te=Array.isArray($==null?void 0:$.messages)?$.messages:[];J==="replace"?P(Te,{checkpointId:($==null?void 0:$.checkpointId)??null,checkpointNs:($==null?void 0:$.checkpointNs)??null}):J==="prepend"&&Te.length&&V(Te),A(($==null?void 0:$.nextCursor)??null),k(!!($!=null&&$.hasMore)),j(Me=>($==null?void 0:$.checkpointId)??Me??void 0),D(Me=>($==null?void 0:$.checkpointNs)??Me??void 0)},[V,P]),O=S.useCallback(()=>{F([]),k(!1),T(!1),A(null),j(void 0),D(void 0)},[F]),G=S.useCallback(({from:$,to:J})=>{const Te=N.current;Te&&console.warn(`[ChatSessionProvider] Stream sequence gap detected (${$} -> ${J}) for thread ${Te}`)},[]),Z=S.useCallback($=>{const J=$.threadId;console.log("[ChatSessionProvider] 📥 Handling thread_info event:",{threadId:J,title:$.title,created:$.created,currentThreads:f.length});const Te={threadId:J,title:$.title||`Thread ${J.slice(0,8)}`,createdAt:$.createdAt||new Date().toISOString(),updatedAt:$.updatedAt||new Date().toISOString(),messageCount:$.messageCount||0};N.current!==J&&(!N.current&&L.messages.length<=1&&(se.current=J),w(J)),h(Me=>{const Le=Me.findIndex(it=>it.threadId===J);if(Le>=0){const it=[...Me];return it[Le]=Te,console.log("[ChatSessionProvider] ✏️ Updated existing thread at index:",Le),it}else return console.log("[ChatSessionProvider] ➕ Added new thread to list"),[Te,...Me]})},[L.messages.length]),{startStream:ce,stop:ie,isStreaming:De,error:Xe,setAuthToken:Je}=ig({baseUrl:d,onThreadInfo:Z,onMessageEvent:q,onUnhandledEvent:$=>{console.warn(`[ChatSessionProvider] Unhandled stream event: ${$.type}`,$)},onSequenceGap:G});S.useEffect(()=>{Se.current=De},[De]),S.useEffect(()=>{var Te;const $=l.getAuthToken();Je($);const J=(Te=l.onTokenChange)==null?void 0:Te.call(l,Me=>{Je(Me)});return()=>{J==null||J()}},[l,Je]);const Ne=S.useCallback(async $=>{const J=`temp-${Date.now()}`,Te={threadId:J,title:$||"New Chat",createdAt:new Date().toISOString(),updatedAt:new Date().toISOString(),messageCount:0};h(Me=>[Te,...Me]),w(J);try{const Me=await l.createThread($),Le=typeof Me=="string"?Me:Me.threadId;return h(it=>it.map(Ot=>Ot.threadId===J?{...Ot,threadId:Le}:Ot)),w(Le),setTimeout(()=>ge(),10),Le}catch(Me){throw h(Le=>Le.filter(it=>it.threadId!==J)),w(null),Me}},[l,ge]),Oe=S.useCallback(async $=>{await l.deleteThread($),N.current===$&&(se.current=$,w(null),O()),await ge()},[l,O,ge]),Qe=S.useCallback(async($,J)=>{try{await l.updateThread($,J),h(Te=>Te.map(Me=>Me.threadId===$?{...Me,title:J}:Me))}catch(Te){throw await ge(),Te}},[l,ge]),Re=S.useCallback(async($,J,Te,Me=!1)=>{await pe(async()=>{if(se.current===$&&!Me){se.current=null;return}if(!(de.current===$&&!Me)){w(Le=>Le===$?Le:$),de.current=$,b(!0);try{const Le=await l.getMessages({threadId:$,checkpointId:J,checkpointNs:Te});B(Le,"replace"),j((Le==null?void 0:Le.checkpointId)??void 0),D((Le==null?void 0:Le.checkpointNs)??void 0)}catch(Le){throw i==null||i(String(Le)),Le}finally{de.current=null,b(!1)}}},`loadThread-${$}`)},[l,B,pe,i]),st=S.useCallback(async()=>{await pe(async()=>{N.current&&(se.current=N.current),w(null),O(),j(void 0),D(void 0);try{localStorage.removeItem("lastThreadId")}catch($){console.warn("[ChatSessionProvider] Failed to clear lastThreadId:",$)}},"clearCurrentThread")},[O,pe]),ct=S.useCallback(async $=>{const J=await l.listCheckpoints($);return Km(J,$)},[l]),Q=S.useCallback(async($,J)=>{if(!N.current)throw new Error("No active thread");await Re(N.current,$,J??void 0,!0)},[Re]),le=S.useCallback(async()=>{if(!N.current)throw new Error("No active thread");await Re(N.current,void 0,void 0,!0)},[Re]),me=S.useCallback(async $=>{if(!N.current)throw new Error("No active thread");if(C||!y)return;const J=I;if(J){T(!0);try{const Te=await l.getMessages({threadId:N.current,checkpointId:R,checkpointNs:M,limit:($==null?void 0:$.limit)??lg,beforeId:J});B(Te,"prepend")}finally{T(!1)}}},[l,B,y,R,M,I,C]),Ce=S.useCallback(async($,J)=>{var jn;const Te=N.current;!Te&&!(J!=null&&J.payloadExtras)&&console.warn("[ChatSessionProvider] No thread ID - message will create new thread");const Me=(J==null?void 0:J.attachments)||[],{contentParts:Le,filesInfo:it}=await Gm(l,Me),Ot=[...Le];$&&$.trim()&&Ot.push({type:"text",text:$.trim()});const gr={id:((jn=crypto.randomUUID)==null?void 0:jn.call(crypto))||`user-${Date.now()}`,role:"user",content:Ot,createdAt:new Date().toISOString(),checkpointId:(J==null?void 0:J.checkpointId)??L.lastCheckpointId??void 0,checkpointNs:(J==null?void 0:J.checkpointNs)??L.lastCheckpointNs??void 0};U(gr);const Xn={...gr,content:Ot},xr={...(J==null?void 0:J.payloadExtras)??{}},cn=Me.length>0,Jn={...Te?{threadId:Te}:{},payload:{messages:[Xn],files_info:it,...o&&cn&&s?{active_agent:s}:{},...xr},checkpointId:(J==null?void 0:J.checkpointId)??L.lastCheckpointId??void 0,checkpointNs:(J==null?void 0:J.checkpointNs)??L.lastCheckpointNs??void 0,nodeFilter:J==null?void 0:J.nodeFilter,config:J==null?void 0:J.config};ce(Jn,{onError:un=>{console.warn("[ChatSessionProvider] Stream error:",un)},onOpen:({threadId:un,created:Ns})=>{!N.current&&un&&(L.messages.length<=1&&(se.current=un),w(un))},onGap:G})},[l,o,s,G,L.lastCheckpointId,L.lastCheckpointNs,L.messages.length,U,ce]),we=S.useCallback(async($,J,Te)=>{const Me=N.current;if(!Me)throw new Error("No active thread to handle interrupt");try{const Le=J?Te??!0:!1;await l.resume({threadId:Me,value:Le})}catch(Le){throw console.error(`[ChatSessionProvider] Failed to handle interrupt ${$}:`,Le),Le}},[l]);S.useEffect(()=>{if(a==null||a(p),p)try{localStorage.setItem("lastThreadId",p)}catch($){console.warn("[ChatSessionProvider] Failed to persist lastThreadId:",$)}},[p,a]),S.useEffect(()=>{let $=!0;return(async()=>{try{if(await ge(),!$)return;if(!r&&!t)try{const Te=localStorage.getItem("lastThreadId");Te&&(w(Te),n&&await Re(Te))}catch(Te){console.warn("[ChatSessionProvider] Failed to restore last thread:",Te)}else t&&n&&await Re(t)}catch(Te){console.error("[ChatSessionProvider] Initialization failed:",Te),i==null||i(String(Te))}})(),()=>{$=!1}},[]);const _e=S.useMemo(()=>({threads:f,currentThreadId:p,isLoadingThreads:v,isLoadingThread:x,setCurrentThreadId:w,createThread:Ne,deleteThread:Oe,renameThread:Qe,refreshThreads:ge,loadThread:Re,clearCurrentThread:st,listCheckpoints:ct,navigateToCheckpoint:Q,returnToLatest:le}),[st,Ne,p,Oe,x,v,ct,Re,Q,ge,Qe,le,f]),et=S.useMemo(()=>({messages:L.messages,assemblingId:L.assemblingId,lastUserMessage:null,hasMoreHistory:y,isLoadingHistory:C,send:Ce,stop:ie,loadOlderMessages:me,clearMessages:O,handleInterrupt:we}),[O,we,y,C,me,L.assemblingId,L.messages,Ce,ie]),Ke=S.useMemo(()=>({isStreaming:De,error:Xe,streamingAssistantId:L.assemblingId,lastCheckpointId:L.lastCheckpointId??null,lastCheckpointNs:L.lastCheckpointNs??null}),[De,L.assemblingId,L.lastCheckpointId,L.lastCheckpointNs,Xe]);return c.jsx(ag.Provider,{value:!0,children:c.jsx(Ll.Provider,{value:Ke,children:c.jsx(Ml.Provider,{value:_e,children:c.jsx(Dl.Provider,{value:et,children:e})})})})}function ho(){const e=S.useContext(Ml);if(!e)throw new Error("useThreads must be used within ChatSessionProvider");return e}function Js(){const e=S.useContext(Dl);if(!e)throw new Error("useMessages must be used within ChatSessionProvider");return e}function Fl(){const e=S.useContext(Ll);if(!e)throw new Error("useStream must be used within ChatSessionProvider");return e}function po({children:e,apiConfig:t,initialThreadId:n=null,autoLoadInitial:r=!0,disableAutoRestore:o=!1,enableFileAgentRouting:s=!1,fileAgentId:i="invoice_reader",onError:a,onThreadChange:l}){return c.jsx(Vm,{apiConfig:t,children:c.jsx(cg,{initialThreadId:n,autoLoadInitial:r,disableAutoRestore:o,enableFileAgentRouting:s,fileAgentId:i,onError:a,onThreadChange:l,children:e})})}function X(...e){return bp.twMerge(wp.clsx(e))}const ug=Qr.cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),Ue=m.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?_n.Slot:"button";return c.jsx(i,{className:X(ug({variant:t,size:n,className:e})),ref:s,...o})});Ue.displayName="Button";const $l=m.forwardRef(({className:e,...t},n)=>c.jsx("textarea",{className:X("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),ref:n,...t}));$l.displayName="Textarea";function dg({initialValue:e="",editingMessageId:t=null,placeholder:n="Type your message...",isStreaming:r=!1,disabled:o=!1,maxLength:s=2e4,onSend:i,onCancelEdit:a,onStop:l,className:u="",textareaClassName:d="",allowEmptySend:f=!1}){const[h,p]=S.useState(e),[w,v]=S.useTransition(),g=S.useRef(null);S.useEffect(()=>{p(e??""),g.current&&(g.current.style.height="auto",g.current.style.height=`${g.current.scrollHeight}px`)},[e,t]);const x=S.useCallback(()=>{const A=g.current;A&&(A.style.height="auto",A.style.height=`${A.scrollHeight}px`)},[]);S.useEffect(()=>{x()},[x]);const b=S.useCallback(async A=>{A&&A.preventDefault();const R=(h??"").trim();!R&&!f||v(()=>{try{const j=i(R);j&&typeof j.then=="function"?j.then(()=>{p(""),g.current&&(g.current.style.height="auto")}).catch(()=>{}):(p(""),g.current&&(g.current.style.height="auto"))}catch{}})},[h,i,f]),y=S.useCallback(A=>{p(A.target.value),g.current&&(g.current.style.height="auto",g.current.style.height=`${g.current.scrollHeight}px`)},[]),k=S.useCallback(A=>{A.key==="Enter"&&!A.shiftKey?(A.preventDefault(),b()):A.key==="Escape"&&t&&(A.preventDefault(),a==null||a())},[b,t,a]),I=`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${t?"border-[hsl(var(--ring))] bg-[hsl(var(--card))] text-[hsl(var(--card-foreground))] dark:bg-[hsl(var(--card))] dark:text-[hsl(var(--card-foreground))]":""} ${d}`;return c.jsx("form",{onSubmit:A=>void b(A),className:`w-full ${u}`,children:c.jsxs("div",{className:"flex items-end gap-2",children:[c.jsx("div",{className:"flex-1",children:c.jsx($l,{ref:g,value:h,onChange:y,onKeyDown:k,placeholder:t?"Edit your message...":n,className:I,disabled:o,maxLength:s,rows:1,spellCheck:!1,autoCorrect:"off"})}),c.jsx("div",{children:r?c.jsx(Ue,{type:"button",onClick:()=>{l==null||l()},size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",disabled:o||!l,children:c.jsx(ee.Square,{size:16})}):c.jsx(Ue,{type:"submit",size:"icon",className:"shrink-0",title:t?"Save changes":"Send message",disabled:o||!h.trim()&&!f||w,children:c.jsx(ee.Send,{size:16})})})]})})}const fg=S.memo(dg),mo=0,vn=1,nr=2,zl=4;function Bl(e){return()=>e}function hg(e){e()}function Hl(e,t){return n=>e(t(n))}function Ul(e,t){return()=>e(t)}function pg(e,t){return n=>e(t,n)}function Zs(e){return e!==void 0}function mg(...e){return()=>{e.map(hg)}}function rr(){}function go(e,t){return t(e),e}function gg(e,t){return t(e)}function tt(...e){return e}function Ve(e,t){return e(vn,t)}function je(e,t){e(mo,t)}function Qs(e){e(nr)}function lt(e){return e(zl)}function ue(e,t){return Ve(e,pg(t,mo))}function Wt(e,t){const n=e(vn,r=>{n(),t(r)});return n}function Wl(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function Vl(e,t){return e===t}function nt(e=Vl){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function be(e){return t=>n=>{e(n)&&t(n)}}function ne(e){return t=>Hl(t,e)}function Jt(e){return t=>()=>{t(e)}}function z(e,...t){const n=xg(...t);return(r,o)=>{switch(r){case nr:Qs(e);return;case vn:return Ve(e,n(o))}}}function Zt(e,t){return n=>r=>{n(t=e(t,r))}}function Mn(e){return t=>n=>{e>0?e--:t(n)}}function hn(e){let t=null,n;return r=>o=>{t=o,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function Pe(...e){const t=new Array(e.length);let n=0,r=null;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const a=Math.pow(2,i);Ve(s,l=>{const u=n;n=n|a,t[i]=l,u!==o&&n===o&&r&&(r(),r=null)})}),s=>i=>{const a=()=>{s([i].concat(t))};n===o?a():r=a}}function xg(...e){return t=>e.reduceRight(gg,t)}function vg(e){let t,n;const r=()=>t==null?void 0:t();return function(o,s){switch(o){case vn:return s?n===s?void 0:(r(),n=s,t=Ve(e,s),t):(r(),rr);case nr:r(),n=null;return}}}function K(e){let t=e;const n=ze();return(r,o)=>{switch(r){case mo:t=o;break;case vn:{o(t);break}case zl:return t}return n(r,o)}}function xt(e,t){return go(K(t),n=>ue(e,n))}function ze(){const e=[];return(t,n)=>{switch(t){case mo:e.slice().forEach(r=>{r(n)});return;case nr:e.splice(0,e.length);return;case vn:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}}}function At(e){return go(ze(),t=>ue(e,t))}function We(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:wg(),singleton:n}}const wg=()=>Symbol();function bg(e){const t=new Map,n=({constructor:r,dependencies:o,id:s,singleton:i})=>{if(i&&t.has(s))return t.get(s);const a=r(o.map(l=>n(l)));return i&&t.set(s,a),a};return n(e)}function dt(...e){const t=ze(),n=new Array(e.length);let r=0;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const a=Math.pow(2,i);Ve(s,l=>{n[i]=l,r=r|a,r===o&&je(t,n)})}),function(s,i){switch(s){case nr:{Qs(t);return}case vn:return r===o&&i(n),Ve(t,i)}}}function ve(e,t=Vl){return z(e,nt(t))}function ei(...e){return function(t,n){switch(t){case nr:return;case vn:return mg(...e.map(r=>Ve(r,n)))}}}var Et=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(Et||{});const yg={0:"debug",3:"error",1:"log",2:"warn"},Sg=()=>typeof globalThis>"u"?window:globalThis,wn=We(()=>{const e=K(3);return{log:K((t,n,r=1)=>{var o;const s=(o=Sg().VIRTUOSO_LOG_LEVEL)!=null?o:lt(e);r>=s&&console[yg[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0});function Dn(e,t,n){return ti(e,t,n).callbackRef}function ti(e,t,n){const r=S.useRef(null);let o=i=>{};const s=S.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(i=>{const a=()=>{const l=i[0].target;l.offsetParent!==null&&e(l)};n?a():requestAnimationFrame(a)}):null,[e,n]);return o=i=>{i&&t?(s==null||s.observe(i),r.current=i):(r.current&&(s==null||s.unobserve(r.current)),r.current=null)},{callbackRef:o,ref:r}}function Cg(e,t,n,r,o,s,i,a,l){const u=S.useCallback(d=>{const f=Tg(d.children,t,a?"offsetWidth":"offsetHeight",o);let h=d.parentElement;for(;!h.dataset.virtuosoScroller;)h=h.parentElement;const p=h.lastElementChild.dataset.viewportType==="window";let w;p&&(w=h.ownerDocument.defaultView);const v=i?a?i.scrollLeft:i.scrollTop:p?a?w.scrollX||w.document.documentElement.scrollLeft:w.scrollY||w.document.documentElement.scrollTop:a?h.scrollLeft:h.scrollTop,g=i?a?i.scrollWidth:i.scrollHeight:p?a?w.document.documentElement.scrollWidth:w.document.documentElement.scrollHeight:a?h.scrollWidth:h.scrollHeight,x=i?a?i.offsetWidth:i.offsetHeight:p?a?w.innerWidth:w.innerHeight:a?h.offsetWidth:h.offsetHeight;r({scrollHeight:g,scrollTop:Math.max(v,0),viewportHeight:x}),s==null||s(a?Kl("column-gap",getComputedStyle(d).columnGap,o):Kl("row-gap",getComputedStyle(d).rowGap,o)),f!==null&&e(f)},[e,t,o,s,i,r,a]);return ti(u,n,l)}function Tg(e,t,n,r){const o=e.length;if(o===0)return null;const s=[];for(let i=0;i<o;i++){const a=e.item(i);if(a.dataset.index===void 0)continue;const l=parseInt(a.dataset.index),u=parseFloat(a.dataset.knownSize),d=t(a,n);if(d===0&&r("Zero-sized element, this should not happen",{child:a},Et.ERROR),d===u)continue;const f=s[s.length-1];s.length===0||f.size!==d||f.endIndex!==l-1?s.push({endIndex:l,size:d,startIndex:l}):s[s.length-1].endIndex++}return s}function Kl(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Et.WARN),t==="normal"?0:parseInt(t??"0",10)}function ql(e,t,n){const r=S.useRef(null),o=S.useCallback(l=>{if(!(l!=null&&l.offsetParent))return;const u=l.getBoundingClientRect(),d=u.width;let f,h;if(t){const p=t.getBoundingClientRect(),w=u.top-p.top;h=p.height-Math.max(0,w),f=w+t.scrollTop}else{const p=i.current.ownerDocument.defaultView;h=p.innerHeight-Math.max(0,u.top),f=u.top+p.scrollY}r.current={offsetTop:f,visibleHeight:h,visibleWidth:d},e(r.current)},[e,t]),{callbackRef:s,ref:i}=ti(o,!0,n),a=S.useCallback(()=>{o(i.current)},[o,i]);return S.useEffect(()=>{var l;if(t){t.addEventListener("scroll",a);const u=new ResizeObserver(()=>{requestAnimationFrame(a)});return u.observe(t),()=>{t.removeEventListener("scroll",a),u.unobserve(t)}}else{const u=(l=i.current)==null?void 0:l.ownerDocument.defaultView;return u==null||u.addEventListener("scroll",a),u==null||u.addEventListener("resize",a),()=>{u==null||u.removeEventListener("scroll",a),u==null||u.removeEventListener("resize",a)}}},[a,t,i]),s}const bt=We(()=>{const e=ze(),t=ze(),n=K(0),r=ze(),o=K(0),s=ze(),i=ze(),a=K(0),l=K(0),u=K(0),d=K(0),f=ze(),h=ze(),p=K(!1),w=K(!1),v=K(!1);return ue(z(e,ne(({scrollTop:g})=>g)),t),ue(z(e,ne(({scrollHeight:g})=>g)),i),ue(t,o),{deviation:n,fixedFooterHeight:u,fixedHeaderHeight:l,footerHeight:d,headerHeight:a,horizontalDirection:w,scrollBy:h,scrollContainerState:e,scrollHeight:i,scrollingInProgress:p,scrollTo:f,scrollTop:t,skipAnimationFrameInResizeObserver:v,smoothScrollTargetReached:r,statefulScrollTop:o,viewportHeight:s}},[],{singleton:!0}),kr={lvl:0};function Gl(e,t){const n=e.length;if(n===0)return[];let{index:r,value:o}=t(e[0]);const s=[];for(let i=1;i<n;i++){const{index:a,value:l}=t(e[i]);s.push({end:a-1,start:r,value:o}),r=a,o=l}return s.push({end:1/0,start:r,value:o}),s}function Ge(e){return e===kr}function Ir(e,t){if(!Ge(e))return t===e.k?e.v:t<e.k?Ir(e.l,t):Ir(e.r,t)}function Vt(e,t,n="k"){if(Ge(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){const r=Vt(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return Vt(e.l,t,n)}function jt(e,t,n){return Ge(e)?Jl(t,n,1):t===e.k?ht(e,{k:t,v:n}):t<e.k?Zl(ht(e,{l:jt(e.l,t,n)})):Zl(ht(e,{r:jt(e.r,t,n)}))}function or(){return kr}function xo(e,t,n){if(Ge(e))return[];const r=Vt(e,t)[0];return Eg(ri(e,r,n))}function ni(e,t){if(Ge(e))return kr;const{k:n,l:r,r:o}=e;if(t===n){if(Ge(r))return o;if(Ge(o))return r;{const[s,i]=Xl(r);return vo(ht(e,{k:s,l:Yl(r),v:i}))}}else return t<n?vo(ht(e,{l:ni(r,t)})):vo(ht(e,{r:ni(o,t)}))}function Ln(e){return Ge(e)?[]:[...Ln(e.l),{k:e.k,v:e.v},...Ln(e.r)]}function ri(e,t,n){if(Ge(e))return[];const{k:r,l:o,r:s,v:i}=e;let a=[];return r>t&&(a=a.concat(ri(o,t,n))),r>=t&&r<=n&&a.push({k:r,v:i}),r<=n&&(a=a.concat(ri(s,t,n))),a}function vo(e){const{l:t,lvl:n,r}=e;if(r.lvl>=n-1&&t.lvl>=n-1)return e;if(n>r.lvl+1){if(oi(t))return Ql(ht(e,{lvl:n-1}));if(!Ge(t)&&!Ge(t.r))return ht(t.r,{l:ht(t,{r:t.r.l}),lvl:n,r:ht(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(oi(e))return si(ht(e,{lvl:n-1}));if(!Ge(r)&&!Ge(r.l)){const o=r.l,s=oi(o)?r.lvl-1:r.lvl;return ht(o,{l:ht(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:si(ht(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function ht(e,t){return Jl(t.k!==void 0?t.k:e.k,t.v!==void 0?t.v:e.v,t.lvl!==void 0?t.lvl:e.lvl,t.l!==void 0?t.l:e.l,t.r!==void 0?t.r:e.r)}function Yl(e){return Ge(e.r)?e.l:vo(ht(e,{r:Yl(e.r)}))}function oi(e){return Ge(e)||e.lvl>e.r.lvl}function Xl(e){return Ge(e.r)?[e.k,e.v]:Xl(e.r)}function Jl(e,t,n,r=kr,o=kr){return{k:e,l:r,lvl:n,r:o,v:t}}function Zl(e){return si(Ql(e))}function Ql(e){const{l:t}=e;return!Ge(t)&&t.lvl===e.lvl?ht(t,{r:ht(e,{l:t.r})}):e}function si(e){const{lvl:t,r:n}=e;return!Ge(n)&&!Ge(n.r)&&n.lvl===t&&n.r.lvl===t?ht(n,{l:ht(e,{r:n.l}),lvl:t+1}):e}function Eg(e){return Gl(e,({k:t,v:n})=>({index:t,value:n}))}function ec(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function Nr(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const ii=We(()=>({recalcInProgress:K(!1)}),[],{singleton:!0});function tc(e,t,n){return e[wo(e,t,n)]}function wo(e,t,n,r=0){let o=e.length-1;for(;r<=o;){const s=Math.floor((r+o)/2),i=e[s],a=n(i,t);if(a===0)return s;if(a===-1){if(o-r<2)return s-1;o=s-1}else{if(o===r)return s;r=s+1}}throw new Error(`Failed binary finding record in array - ${e.join(",")}, searched for ${t}`)}function kg(e,t,n,r){const o=wo(e,t,r),s=wo(e,n,r,o);return e.slice(o,s+1)}function bn(e,t){return Math.round(e.getBoundingClientRect()[t])}function bo(e){return!Ge(e.groupOffsetTree)}function ai({index:e},t){return t===e?0:t<e?-1:1}function Ig(){return{groupIndices:[],groupOffsetTree:or(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:or()}}function Ng(e,t){let n=Ge(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),Ge(e)){e=jt(e,0,s);continue}const a=xo(e,i-1,o+1);if(a.some(Mg(r)))continue;let l=!1,u=!1;for(const{end:d,start:f,value:h}of a)l?(o>=f||s===h)&&(e=ni(e,f)):(u=h!==s,l=!0),d>o&&o>=f&&h!==s&&(e=jt(e,o+1,h));u&&(e=jt(e,i,s))}return[e,n]}function Ag(e){return typeof e.groupIndex<"u"}function jg({offset:e},t){return t===e?0:t<e?-1:1}function Ar(e,t,n){if(t.length===0)return 0;const{index:r,offset:o,size:s}=tc(t,e,ai),i=e-r,a=s*i+(i-1)*n+o;return a>0?a+n:a}function nc(e,t){if(!bo(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function rc(e,t,n){if(Ag(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=nc(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function _g(e,t,n,r=0){return r>0&&(t=Math.max(t,tc(e,r,ai).offset)),Gl(kg(e,t,n,jg),Og)}function Rg(e,[t,n,r,o]){t.length>0&&r("received item sizes",t,Et.DEBUG);const s=e.sizeTree;let i=s,a=0;if(n.length>0&&Ge(s)&&t.length===2){const h=t[0].size,p=t[1].size;i=n.reduce((w,v)=>jt(jt(w,v,h),v+1,p),i)}else[i,a]=Ng(i,t);if(i===s)return e;const{lastIndex:l,lastOffset:u,lastSize:d,offsetTree:f}=li(e.offsetTree,a,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((h,p)=>jt(h,p,Ar(p,f,o)),or()),lastIndex:l,lastOffset:u,lastSize:d,offsetTree:f,sizeTree:i}}function Pg(e){return Ln(e).map(({k:t,v:n},r,o)=>{const s=o[r+1];return{endIndex:s?s.k-1:1/0,size:n,startIndex:t}})}function oc(e,t){let n=0,r=0;for(;n<e;)n+=t[r+1]-t[r]-1,r++;return r-(n===e?0:1)}function li(e,t,n,r){let o=e,s=0,i=0,a=0,l=0;if(t!==0){l=wo(o,t-1,ai),a=o[l].offset;const u=Vt(n,t-1);s=u[0],i=u[1],o.length&&o[l].size===Vt(n,t)[1]&&(l-=1),o=o.slice(0,l+1)}else o=[];for(const{start:u,value:d}of xo(n,t,1/0)){const f=u-s,h=f*i+a+f*r;o.push({index:u,offset:h,size:d}),s=u,a=h,i=d}return{lastIndex:s,lastOffset:a,lastSize:i,offsetTree:o}}function Og(e){return{index:e.index,value:e}}function Mg(e){const{endIndex:t,size:n,startIndex:r}=e;return o=>o.start===r&&(o.end===t||o.end===1/0)&&o.value===n}const Dg={offsetHeight:"height",offsetWidth:"width"},Qt=We(([{log:e},{recalcInProgress:t}])=>{const n=ze(),r=ze(),o=xt(r,0),s=ze(),i=ze(),a=K(0),l=K([]),u=K(void 0),d=K(void 0),f=K((C,T)=>bn(C,Dg[T])),h=K(void 0),p=K(0),w=Ig(),v=xt(z(n,Pe(l,e,p),Zt(Rg,w),nt()),w),g=xt(z(l,nt(),Zt((C,T)=>({current:T,prev:C.current}),{current:[],prev:[]}),ne(({prev:C})=>C)),[]);ue(z(l,be(C=>C.length>0),Pe(v,p),ne(([C,T,I])=>{const A=C.reduce((R,j,M)=>jt(R,j,Ar(j,T.offsetTree,I)||M),or());return{...T,groupIndices:C,groupOffsetTree:A}})),v),ue(z(r,Pe(v),be(([C,{lastIndex:T}])=>C<T),ne(([C,{lastIndex:T,lastSize:I}])=>[{endIndex:T,size:I,startIndex:C}])),n),ue(u,d);const x=xt(z(u,ne(C=>C===void 0)),!0);ue(z(d,be(C=>C!==void 0&&Ge(lt(v).sizeTree)),ne(C=>[{endIndex:0,size:C,startIndex:0}])),n);const b=At(z(n,Pe(v),Zt(({sizes:C},[T,I])=>({changed:I!==C,sizes:I}),{changed:!1,sizes:w}),ne(C=>C.changed)));Ve(z(a,Zt((C,T)=>({diff:C.prev-T,prev:T}),{diff:0,prev:0}),ne(C=>C.diff)),C=>{const{groupIndices:T}=lt(v);if(C>0)je(t,!0),je(s,C+oc(C,T));else if(C<0){const I=lt(g);I.length>0&&(C-=oc(-C,I)),je(i,C)}}),Ve(z(a,Pe(e)),([C,T])=>{C<0&&T("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:a},Et.ERROR)});const y=At(s);ue(z(s,Pe(v),ne(([C,T])=>{const I=T.groupIndices.length>0,A=[],R=T.lastSize;if(I){const j=Ir(T.sizeTree,0);let M=0,D=0;for(;M<C;){const P=T.groupIndices[D],V=T.groupIndices.length===D+1?1/0:T.groupIndices[D+1]-P-1;A.push({endIndex:P,size:j,startIndex:P}),A.push({endIndex:P+1+V-1,size:R,startIndex:P+1}),D++,M+=V+1}const L=Ln(T.sizeTree);return M!==C&&L.shift(),L.reduce((P,{k:V,v:U})=>{let q=P.ranges;return P.prevSize!==0&&(q=[...P.ranges,{endIndex:V+C-1,size:P.prevSize,startIndex:P.prevIndex}]),{prevIndex:V+C,prevSize:U,ranges:q}},{prevIndex:C,prevSize:0,ranges:A}).ranges}return Ln(T.sizeTree).reduce((j,{k:M,v:D})=>({prevIndex:M+C,prevSize:D,ranges:[...j.ranges,{endIndex:M+C-1,size:j.prevSize,startIndex:j.prevIndex}]}),{prevIndex:0,prevSize:R,ranges:[]}).ranges})),n);const k=At(z(i,Pe(v,p),ne(([C,{offsetTree:T},I])=>{const A=-C;return Ar(A,T,I)})));return ue(z(i,Pe(v,p),ne(([C,T,I])=>{if(T.groupIndices.length>0){if(Ge(T.sizeTree))return T;let A=or();const R=lt(g);let j=0,M=0,D=0;for(;j<-C;){D=R[M];const L=R[M+1]-D-1;M++,j+=L+1}if(A=Ln(T.sizeTree).reduce((L,{k:P,v:V})=>jt(L,Math.max(0,P+C),V),A),j!==-C){const L=Ir(T.sizeTree,D);A=jt(A,0,L);const P=Vt(T.sizeTree,-C+1)[1];A=jt(A,1,P)}return{...T,sizeTree:A,...li(T.offsetTree,0,A,I)}}else{const A=Ln(T.sizeTree).reduce((R,{k:j,v:M})=>jt(R,Math.max(0,j+C),M),or());return{...T,sizeTree:A,...li(T.offsetTree,0,A,I)}}})),v),{beforeUnshiftWith:y,data:h,defaultItemSize:d,firstItemIndex:a,fixedItemSize:u,gap:p,groupIndices:l,itemSize:f,listRefresh:b,shiftWith:i,shiftWithOffset:k,sizeRanges:n,sizes:v,statefulTotalCount:o,totalCount:r,trackItemSizes:x,unshiftWith:s}},tt(wn,ii),{singleton:!0});function Lg(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const sc=We(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=ze(),i=ze(),a=At(z(s,ne(Lg)));return ue(z(a,ne(l=>l.totalCount)),n),ue(z(a,ne(l=>l.groupIndices)),e),ue(z(dt(o,t,r),be(([l,u])=>bo(u)),ne(([l,u,d])=>Vt(u.groupOffsetTree,Math.max(l-d,0),"v")[0]),nt(),ne(l=>[l])),i),{groupCounts:s,topItemsIndexes:i}},tt(Qt,bt)),yn=We(([{log:e}])=>{const t=K(!1),n=At(z(t,be(r=>r),nt()));return Ve(t,r=>{r&&lt(e)("props updated",{},Et.DEBUG)}),{didMount:n,propsReady:t}},tt(wn),{singleton:!0}),Fg=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function ic(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!Fg)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const jr=We(([{gap:e,listRefresh:t,sizes:n,totalCount:r},{fixedFooterHeight:o,fixedHeaderHeight:s,footerHeight:i,headerHeight:a,scrollingInProgress:l,scrollTo:u,smoothScrollTargetReached:d,viewportHeight:f},{log:h}])=>{const p=ze(),w=ze(),v=K(0);let g=null,x=null,b=null;function y(){g&&(g(),g=null),b&&(b(),b=null),x&&(clearTimeout(x),x=null),je(l,!1)}return ue(z(p,Pe(n,f,r,v,a,i,h),Pe(e,s,o),ne(([[k,C,T,I,A,R,j,M],D,L,P])=>{const V=ic(k),{align:U,behavior:q,offset:F}=V,N=I-1,W=rc(V,C,N);let Y=Ar(W,C.offsetTree,D)+R;U==="end"?(Y+=L+Vt(C.sizeTree,W)[1]-T+P,W===N&&(Y+=j)):U==="center"?Y+=(L+Vt(C.sizeTree,W)[1]-T+P)/2:Y-=A,F&&(Y+=F);const de=se=>{y(),se?(M("retrying to scroll to",{location:k},Et.DEBUG),je(p,k)):(je(w,!0),M("list did not change, scroll successful",{},Et.DEBUG))};if(y(),q==="smooth"){let se=!1;b=Ve(t,pe=>{se=se||pe}),g=Wt(d,()=>{de(se)})}else g=Wt(z(t,$g(150)),de);return x=setTimeout(()=>{y()},1200),je(l,!0),M("scrolling from index to",{behavior:q,index:W,top:Y},Et.DEBUG),{behavior:q,top:Y}})),u),{scrollTargetReached:w,scrollToIndex:p,topListHeight:v}},tt(Qt,bt,wn),{singleton:!0});function $g(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function ci(e,t){e==0?t():requestAnimationFrame(()=>{ci(e-1,t)})}function ui(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const _r=We(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:s},{didMount:i}])=>{const a=K(!0),l=K(0),u=K(!0);return ue(z(i,Pe(l),be(([d,f])=>!!f),Jt(!1)),a),ue(z(i,Pe(l),be(([d,f])=>!!f),Jt(!1)),u),Ve(z(dt(t,i),Pe(a,n,e,u),be(([[,d],f,{sizeTree:h},p,w])=>d&&(!Ge(h)||Zs(p))&&!f&&!w),Pe(l)),([,d])=>{Wt(o,()=>{je(u,!0)}),ci(4,()=>{Wt(r,()=>{je(a,!0)}),je(s,d)})}),{initialItemFinalLocationReached:u,initialTopMostItemIndex:l,scrolledToInitialItem:a}},tt(Qt,bt,jr,yn),{singleton:!0});function ac(e,t){return Math.abs(e-t)<1.01}const Rr="up",Pr="down",zg="none",Bg={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},Hg=0,Or=We(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=K(!1),a=K(!0),l=ze(),u=ze(),d=K(4),f=K(Hg),h=xt(z(ei(z(ve(o),Mn(1),Jt(!0)),z(ve(o),Mn(1),Jt(!1),Wl(100))),nt()),!1),p=xt(z(ei(z(n,Jt(!0)),z(n,Jt(!1),Wl(200))),nt()),!1);ue(z(dt(ve(o),ve(f)),ne(([b,y])=>b<=y),nt()),a),ue(z(a,hn(50)),u);const w=At(z(dt(r,ve(s),ve(t),ve(e),ve(d)),Zt((b,[{scrollHeight:y,scrollTop:k},C,T,I,A])=>{const R=k+C-y>-A,j={scrollHeight:y,scrollTop:k,viewportHeight:C};if(R){let D,L;return k>b.state.scrollTop?(D="SCROLLED_DOWN",L=b.state.scrollTop-k):(D="SIZE_DECREASED",L=b.state.scrollTop-k||b.scrollTopDelta),{atBottom:!0,atBottomBecause:D,scrollTopDelta:L,state:j}}let M;return j.scrollHeight>b.state.scrollHeight?M="SIZE_INCREASED":C<b.state.viewportHeight?M="VIEWPORT_HEIGHT_DECREASING":k<b.state.scrollTop?M="SCROLLING_UPWARDS":M="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:M,state:j}},Bg),nt((b,y)=>b&&b.atBottom===y.atBottom))),v=xt(z(r,Zt((b,{scrollHeight:y,scrollTop:k,viewportHeight:C})=>{if(ac(b.scrollHeight,y))return{changed:!1,jump:0,scrollHeight:y,scrollTop:k};{const T=y-(k+C)<1;return b.scrollTop!==k&&T?{changed:!0,jump:b.scrollTop-k,scrollHeight:y,scrollTop:k}:{changed:!0,jump:0,scrollHeight:y,scrollTop:k}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),be(b=>b.changed),ne(b=>b.jump)),0);ue(z(w,ne(b=>b.atBottom)),i),ue(z(i,hn(50)),l);const g=K(Pr);ue(z(r,ne(({scrollTop:b})=>b),nt(),Zt((b,y)=>lt(p)?{direction:b.direction,prevScrollTop:y}:{direction:y<b.prevScrollTop?Rr:Pr,prevScrollTop:y},{direction:Pr,prevScrollTop:0}),ne(b=>b.direction)),g),ue(z(r,hn(50),Jt(zg)),g);const x=K(0);return ue(z(h,be(b=>!b),Jt(0)),x),ue(z(o,hn(100),Pe(h),be(([b,y])=>!!y),Zt(([b,y],[k])=>[y,k],[0,0]),ne(([b,y])=>y-b)),x),{atBottomState:w,atBottomStateChange:l,atBottomThreshold:d,atTopStateChange:u,atTopThreshold:f,isAtBottom:i,isAtTop:a,isScrolling:h,lastJumpDueToItemResize:v,scrollDirection:g,scrollVelocity:x}},tt(bt)),yo="top",So="bottom",lc="none";function cc(e,t,n){return typeof e=="number"?n===Rr&&t===yo||n===Pr&&t===So?e:0:n===Rr?t===yo?e.main:e.reverse:t===So?e.main:e.reverse}function uc(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const di=We(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=ze(),i=K(0),a=K(0),l=K(0),u=xt(z(dt(ve(r),ve(o),ve(n),ve(s,Nr),ve(l),ve(i),ve(t),ve(e),ve(a)),ne(([d,f,h,[p,w],v,g,x,b,y])=>{const k=d-b,C=g+x,T=Math.max(h-k,0);let I=lc;const A=uc(y,yo),R=uc(y,So);return p-=b,p+=h+x,w+=h+x,w-=b,p>d+C-A&&(I=Rr),w<d-T+f+R&&(I=Pr),I!==lc?[Math.max(k-h-cc(v,yo,I)-A,0),k-T-x+f+cc(v,So,I)+R]:null}),be(d=>d!=null),nt(Nr)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:l,topListHeight:i,visibleRange:u}},tt(bt),{singleton:!0});function Ug(e,t,n){if(bo(t)){const r=nc(e,t);return[{index:Vt(t.groupOffsetTree,r)[0],offset:0,size:0},{data:n==null?void 0:n[0],index:r,offset:0,size:0}]}return[{data:n==null?void 0:n[0],index:e,offset:0,size:0}]}const fi={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Co(e,t,n,r,o,s){const{lastIndex:i,lastOffset:a,lastSize:l}=o;let u=0,d=0;if(e.length>0){u=e[0].offset;const v=e[e.length-1];d=v.offset+v.size}const f=n-i,h=a+f*l+(f-1)*r,p=u,w=h-d;return{bottom:d,firstItemIndex:s,items:fc(e,o,s),offsetBottom:w,offsetTop:u,top:p,topItems:fc(t,o,s),topListHeight:t.reduce((v,g)=>g.size+v,0),totalCount:n}}function dc(e,t,n,r,o,s){let i=0;if(n.groupIndices.length>0)for(const d of n.groupIndices){if(d-i>=e)break;i++}const a=e+i,l=ui(t,a),u=Array.from({length:a}).map((d,f)=>({data:s[f+l],index:f+l,offset:0,size:0}));return Co(u,[],a,o,n,r)}function fc(e,t,n){if(e.length===0)return[];if(!bo(t))return e.map(u=>({...u,index:u.index+n,originalIndex:u.index}));const r=e[0].index,o=e[e.length-1].index,s=[],i=xo(t.groupOffsetTree,r,o);let a,l=0;for(const u of e){(!a||a.end<u.index)&&(a=i.shift(),l=t.groupIndices.indexOf(a.start));let d;u.index===a.start?d={index:l,type:"group"}:d={groupIndex:l,index:u.index-(l+1)+n},s.push({...d,data:u.data,offset:u.offset,originalIndex:u.index,size:u.size})}return s}const Fn=We(([{data:e,firstItemIndex:t,gap:n,sizes:r,totalCount:o},s,{listBoundary:i,topListHeight:a,visibleRange:l},{initialTopMostItemIndex:u,scrolledToInitialItem:d},{topListHeight:f},h,{didMount:p},{recalcInProgress:w}])=>{const v=K([]),g=K(0),x=ze();ue(s.topItemsIndexes,v);const b=xt(z(dt(p,w,ve(l,Nr),ve(o),ve(r),ve(u),d,ve(v),ve(t),ve(n),e),be(([T,I,,A,,,,,,,R])=>{const j=R&&R.length!==A;return T&&!I&&!j}),ne(([,,[T,I],A,R,j,M,D,L,P,V])=>{const U=R,{offsetTree:q,sizeTree:F}=U,N=lt(g);if(A===0)return{...fi,totalCount:A};if(T===0&&I===0)return N===0?{...fi,totalCount:A}:dc(N,j,R,L,P,V||[]);if(Ge(F))return N>0?null:Co(Ug(ui(j,A),U,V),[],A,P,U,L);const W=[];if(D.length>0){const ge=D[0],Se=D[D.length-1];let B=0;for(const O of xo(F,ge,Se)){const G=O.value,Z=Math.max(O.start,ge),ce=Math.min(O.end,Se);for(let ie=Z;ie<=ce;ie++)W.push({data:V==null?void 0:V[ie],index:ie,offset:B,size:G}),B+=G}}if(!M)return Co([],W,A,P,U,L);const Y=D.length>0?D[D.length-1]+1:0,de=_g(q,T,I,Y);if(de.length===0)return null;const se=A-1,pe=go([],ge=>{for(const Se of de){const B=Se.value;let O=B.offset,G=Se.start;const Z=B.size;if(B.offset<T){G+=Math.floor((T-B.offset+P)/(Z+P));const ie=G-Se.start;O+=ie*Z+ie*P}G<Y&&(O+=(Y-G)*Z,G=Y);const ce=Math.min(Se.end,se);for(let ie=G;ie<=ce&&!(O>=I);ie++)ge.push({data:V==null?void 0:V[ie],index:ie,offset:O,size:Z}),O+=Z+P}});return Co(pe,W,A,P,U,L)}),be(T=>T!==null),nt()),fi);ue(z(e,be(Zs),ne(T=>T==null?void 0:T.length)),o),ue(z(b,ne(T=>T.topListHeight)),f),ue(f,a),ue(z(b,ne(T=>[T.top,T.bottom])),i),ue(z(b,ne(T=>T.items)),x);const y=At(z(b,be(({items:T})=>T.length>0),Pe(o,e),be(([{items:T},I])=>T[T.length-1].originalIndex===I-1),ne(([,T,I])=>[T-1,I]),nt(Nr),ne(([T])=>T))),k=At(z(b,hn(200),be(({items:T,topItems:I})=>T.length>0&&T[0].originalIndex===I.length),ne(({items:T})=>T[0].index),nt())),C=At(z(b,be(({items:T})=>T.length>0),ne(({items:T})=>{let I=0,A=T.length-1;for(;T[I].type==="group"&&I<A;)I++;for(;T[A].type==="group"&&A>I;)A--;return{endIndex:T[A].index,startIndex:T[I].index}}),nt(ec)));return{endReached:y,initialItemCount:g,itemsRendered:x,listState:b,rangeChanged:C,startReached:k,topItemsIndexes:v,...h}},tt(Qt,sc,di,_r,jr,Or,yn,ii),{singleton:!0}),hc=We(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=ze(),i=xt(z(dt(n,e,r,t,o),ne(([a,l,u,d,f])=>a+l+u+d+f.offsetBottom+f.bottom)),0);return ue(ve(i),s),{totalListHeight:i,totalListHeightChanged:s}},tt(bt,Fn),{singleton:!0}),Wg=We(([{viewportHeight:e},{totalListHeight:t}])=>{const n=K(!1),r=xt(z(dt(n,e,t),be(([o])=>o),ne(([,o,s])=>Math.max(0,o-s)),hn(0),nt()),0);return{alignToBottom:n,paddingTopAddition:r}},tt(bt,hc),{singleton:!0}),pc=We(()=>({context:K(null)})),Vg=({itemBottom:e,itemTop:t,locationParams:{align:n,behavior:r,...o},viewportBottom:s,viewportTop:i})=>t<i?{...o,align:n??"start",behavior:r}:e>s?{...o,align:n??"end",behavior:r}:null,mc=We(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:s,scrollingInProgress:i,scrollTop:a,viewportHeight:l},{scrollToIndex:u}])=>{const d=ze();return ue(z(d,Pe(t,l,n,s,o,r,a),Pe(e),ne(([[f,h,p,w,v,g,x,b],y])=>{const{align:k,behavior:C,calculateViewLocation:T=Vg,done:I,...A}=f,R=rc(f,h,w-1),j=Ar(R,h.offsetTree,y)+v+g,M=j+Vt(h.sizeTree,R)[1],D=b+g,L=b+p-x,P=T({itemBottom:M,itemTop:j,locationParams:{align:k,behavior:C,...A},viewportBottom:L,viewportTop:D});return P?I&&Wt(z(i,be(V=>!V),Mn(lt(i)?1:2)),I):I&&I(),P}),be(f=>f!==null)),u),{scrollIntoView:d}},tt(Qt,bt,jr,Fn,wn),{singleton:!0});function gc(e){return e?e==="smooth"?"smooth":"auto":!1}const Kg=(e,t)=>typeof e=="function"?gc(e(t)):t&&gc(e),qg=We(([{listRefresh:e,totalCount:t,fixedItemSize:n,data:r},{atBottomState:o,isAtBottom:s},{scrollToIndex:i},{scrolledToInitialItem:a},{didMount:l,propsReady:u},{log:d},{scrollingInProgress:f},{context:h},{scrollIntoView:p}])=>{const w=K(!1),v=ze();let g=null;function x(C){je(i,{align:"end",behavior:C,index:"LAST"})}Ve(z(dt(z(ve(t),Mn(1)),l),Pe(ve(w),s,a,f),ne(([[C,T],I,A,R,j])=>{let M=T&&R,D="auto";return M&&(D=Kg(I,A||j),M=M&&!!D),{followOutputBehavior:D,shouldFollow:M,totalCount:C}}),be(({shouldFollow:C})=>C)),({followOutputBehavior:C,totalCount:T})=>{g&&(g(),g=null),lt(n)?requestAnimationFrame(()=>{lt(d)("following output to ",{totalCount:T},Et.DEBUG),x(C)}):g=Wt(e,()=>{lt(d)("following output to ",{totalCount:T},Et.DEBUG),x(C),g=null})});function b(C){const T=Wt(o,I=>{C&&!I.atBottom&&I.notAtBottomBecause==="SIZE_INCREASED"&&!g&&(lt(d)("scrolling to bottom due to increased size",{},Et.DEBUG),x("auto"))});setTimeout(T,100)}Ve(z(dt(ve(w),t,u),be(([C,,T])=>C&&T),Zt(({value:C},[,T])=>({refreshed:C===T,value:T}),{refreshed:!1,value:0}),be(({refreshed:C})=>C),Pe(w,t)),([,C])=>{lt(a)&&b(C!==!1)}),Ve(v,()=>{b(lt(w)!==!1)}),Ve(dt(ve(w),o),([C,T])=>{C&&!T.atBottom&&T.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&x("auto")});const y=K(null),k=ze();return ue(ei(z(ve(r),ne(C=>{var T;return(T=C==null?void 0:C.length)!=null?T:0})),z(ve(t))),k),Ve(z(dt(z(k,Mn(1)),l),Pe(ve(y),a,f,h),ne(([[C,T],I,A,R,j])=>T&&A&&(I==null?void 0:I({context:j,totalCount:C,scrollingInProgress:R}))),be(C=>!!C),hn(0)),C=>{g&&(g(),g=null),lt(n)?requestAnimationFrame(()=>{lt(d)("scrolling into view",{}),je(p,C)}):g=Wt(e,()=>{lt(d)("scrolling into view",{}),je(p,C),g=null})}),{autoscrollToBottom:v,followOutput:w,scrollIntoViewOnChange:y}},tt(Qt,Or,jr,_r,yn,wn,bt,pc,mc)),Gg=We(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(ue(z(a,Pe(s),be(([,l])=>l!==0),Pe(o,r,t,n,e),ne(([[,l],u,d,f,h,p=[]])=>dc(l,u,d,f,h,p))),i),{}),tt(Qt,_r,Fn,yn),{singleton:!0}),Yg=We(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=K(0);return Ve(z(e,Pe(r),be(([,o])=>o!==0),ne(([,o])=>({top:o}))),o=>{Wt(z(n,Mn(1),be(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{je(t,o)})})}),{initialScrollTop:r}},tt(yn,bt,Fn),{singleton:!0}),xc=We(([{scrollVelocity:e}])=>{const t=K(!1),n=ze(),r=K(!1);return ue(z(e,Pe(r,t,n),be(([o,s])=>!!s),ne(([o,s,i,a])=>{const{enter:l,exit:u}=s;if(i){if(u(o,a))return!1}else if(l(o,a))return!0;return i}),nt()),t),Ve(z(dt(t,e,n),Pe(r)),([[o,s,i],a])=>{o&&a&&a.change&&a.change(s,i)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},tt(Or),{singleton:!0}),hi=We(([{scrollContainerState:e,scrollTo:t}])=>{const n=ze(),r=ze(),o=ze(),s=K(!1),i=K(void 0);return ue(z(dt(n,r),ne(([{scrollHeight:a,scrollTop:l,viewportHeight:u},{offsetTop:d}])=>({scrollHeight:a,scrollTop:Math.max(0,l-d),viewportHeight:u}))),e),ue(z(t,Pe(r),ne(([a,{offsetTop:l}])=>({...a,top:a.top+l}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},tt(bt)),Xg=We(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:a,windowViewportRect:l}])=>{const u=ze(),d=K(void 0),f=K(null),h=K(null);return ue(a,f),ue(l,h),Ve(z(u,Pe(t,r,i,f,h,n)),([p,w,v,g,x,b,y])=>{const k=Pg(w.sizeTree);g&&x!==null&&b!==null&&(v=x.scrollTop-b.offsetTop),v-=y,p({ranges:k,scrollTop:v})}),ue(z(d,be(Zs),ne(Jg)),o),ue(z(s,Pe(d),be(([,p])=>p!==void 0),nt(),ne(([,p])=>p.ranges)),e),{getState:u,restoreStateFrom:d}},tt(Qt,bt,_r,yn,hi));function Jg(e){return{align:"start",index:0,offset:e.scrollTop}}const Zg=We(([{topItemsIndexes:e}])=>{const t=K(0);return ue(z(t,be(n=>n>=0),ne(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},tt(Fn));function vc(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const Qg=vc(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),ex=We(([{deviation:e,scrollBy:t,scrollingInProgress:n,scrollTop:r},{isAtBottom:o,isScrolling:s,lastJumpDueToItemResize:i,scrollDirection:a},{listState:l},{beforeUnshiftWith:u,gap:d,shiftWithOffset:f,sizes:h},{log:p},{recalcInProgress:w}])=>{const v=At(z(l,Pe(i),Zt(([,x,b,y],[{bottom:k,items:C,offsetBottom:T,totalCount:I},A])=>{const R=k+T;let j=0;return b===I&&x.length>0&&C.length>0&&(C[0].originalIndex===0&&x[0].originalIndex===0||(j=R-y,j!==0&&(j+=A))),[j,C,I,R]},[0,[],0,0]),be(([x])=>x!==0),Pe(r,a,n,o,p,w),be(([,x,b,y,,,k])=>!k&&!y&&x!==0&&b===Rr),ne(([[x],,,,,b])=>(b("Upward scrolling compensation",{amount:x},Et.DEBUG),x))));function g(x){x>0?(je(t,{behavior:"auto",top:-x}),je(e,0)):(je(e,0),je(t,{behavior:"auto",top:-x}))}return Ve(z(v,Pe(e,s)),([x,b,y])=>{y&&Qg()?je(e,b-x):g(-x)}),Ve(z(dt(xt(s,!1),e,w),be(([x,b,y])=>!x&&!y&&b!==0),ne(([x,b])=>b),hn(1)),g),ue(z(f,ne(x=>({top:-x}))),t),Ve(z(u,Pe(h,d),ne(([x,{groupIndices:b,lastSize:y,sizeTree:k},C])=>{function T(I){return I*(y+C)}if(b.length===0)return T(x);{let I=0;const A=Ir(k,0);let R=0,j=0;for(;R<x;){R++,I+=A;let M=b.length===j+1?1/0:b[j+1]-b[j]-1;R+M>x&&(I-=A,M=x-R+1),R+=M,I+=T(M),j++}return I}})),x=>{je(e,x),requestAnimationFrame(()=>{je(t,{top:x}),requestAnimationFrame(()=>{je(e,0),je(w,!1)})})}),{deviation:e}},tt(bt,Or,Fn,Qt,wn,ii)),tx=We(([e,t,n,r,o,s,i,a,l,u,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...l,...u,...d}),tt(di,Gg,yn,xc,hc,Yg,Wg,hi,mc,wn,pc)),wc=We(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:r,gap:o,groupIndices:s,itemSize:i,sizeRanges:a,sizes:l,statefulTotalCount:u,totalCount:d,trackItemSizes:f},{initialItemFinalLocationReached:h,initialTopMostItemIndex:p,scrolledToInitialItem:w},v,g,x,{listState:b,topItemsIndexes:y,...k},{scrollToIndex:C},T,{topItemCount:I},{groupCounts:A},R])=>(ue(k.rangeChanged,R.scrollSeekRangeChanged),ue(z(R.windowViewportRect,ne(j=>j.visibleHeight)),v.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,gap:o,groupCounts:A,initialItemFinalLocationReached:h,initialTopMostItemIndex:p,scrolledToInitialItem:w,sizeRanges:a,topItemCount:I,topItemsIndexes:y,totalCount:d,...x,groupIndices:s,itemSize:i,listState:b,scrollToIndex:C,statefulTotalCount:u,trackItemSizes:f,...k,...R,...v,sizes:l,...g}),tt(Qt,_r,bt,Xg,qg,Fn,jr,ex,Zg,sc,tx));function nx(e,t){const n={},r={};let o=0;const s=e.length;for(;o<s;)r[e[o]]=1,o+=1;for(const i in t)Object.hasOwn(r,i)||(n[i]=t[i]);return n}const To=typeof document<"u"?S.useLayoutEffect:S.useEffect;function bc(e,t,n){const r=Object.keys(t.required||{}),o=Object.keys(t.optional||{}),s=Object.keys(t.methods||{}),i=Object.keys(t.events||{}),a=S.createContext({});function l(g,x){g.propsReady&&je(g.propsReady,!1);for(const b of r){const y=g[t.required[b]];je(y,x[b])}for(const b of o)if(b in x){const y=g[t.optional[b]];je(y,x[b])}g.propsReady&&je(g.propsReady,!0)}function u(g){return s.reduce((x,b)=>(x[b]=y=>{const k=g[t.methods[b]];je(k,y)},x),{})}function d(g){return i.reduce((x,b)=>(x[b]=vg(g[t.events[b]]),x),{})}const f=S.forwardRef((g,x)=>{const{children:b,...y}=g,[k]=S.useState(()=>go(bg(e),I=>{l(I,y)})),[C]=S.useState(Ul(d,k));To(()=>{for(const I of i)I in y&&Ve(C[I],y[I]);return()=>{Object.values(C).map(Qs)}},[y,C,k]),To(()=>{l(k,y)}),S.useImperativeHandle(x,Bl(u(k)));const T=n;return c.jsx(a.Provider,{value:k,children:n?c.jsx(T,{...nx([...r,...o,...i],y),children:b}):b})}),h=g=>{const x=S.useContext(a);return S.useCallback(b=>{je(x[g],b)},[x,g])},p=g=>{const x=S.useContext(a)[g],b=S.useCallback(y=>Ve(x,y),[x]);return S.useSyncExternalStore(b,()=>lt(x),()=>lt(x))},w=g=>{const x=S.useContext(a)[g],[b,y]=S.useState(Ul(lt,x));return To(()=>Ve(x,k=>{k!==b&&y(Bl(k))}),[x,b]),b},v=S.version.startsWith("18")?p:w;return{Component:f,useEmitter:(g,x)=>{const b=S.useContext(a)[g];To(()=>Ve(b,x),[x,b])},useEmitterValue:v,usePublisher:h}}const yc=S.createContext(void 0),Sc=S.createContext(void 0),Cc=typeof document<"u"?S.useLayoutEffect:S.useEffect;function pi(e){return"self"in e}function rx(e){return"body"in e}function Tc(e,t,n,r=rr,o,s){const i=S.useRef(null),a=S.useRef(null),l=S.useRef(null),u=S.useCallback(h=>{let p,w,v;const g=h.target;if(rx(g)||pi(g)){const b=pi(g)?g:g.defaultView;v=s?b.scrollX:b.scrollY,p=s?b.document.documentElement.scrollWidth:b.document.documentElement.scrollHeight,w=s?b.innerWidth:b.innerHeight}else v=s?g.scrollLeft:g.scrollTop,p=s?g.scrollWidth:g.scrollHeight,w=s?g.offsetWidth:g.offsetHeight;const x=()=>{e({scrollHeight:p,scrollTop:Math.max(v,0),viewportHeight:w})};h.suppressFlushSync?x():_s.flushSync(x),a.current!==null&&(v===a.current||v<=0||v===p-w)&&(a.current=null,t(!0),l.current&&(clearTimeout(l.current),l.current=null))},[e,t,s]);S.useEffect(()=>{const h=o||i.current;return r(o||i.current),u({suppressFlushSync:!0,target:h}),h.addEventListener("scroll",u,{passive:!0}),()=>{r(null),h.removeEventListener("scroll",u)}},[i,u,n,r,o]);function d(h){const p=i.current;if(!p||(s?"offsetWidth"in p&&p.offsetWidth===0:"offsetHeight"in p&&p.offsetHeight===0))return;const w=h.behavior==="smooth";let v,g,x;pi(p)?(g=Math.max(bn(p.document.documentElement,s?"width":"height"),s?p.document.documentElement.scrollWidth:p.document.documentElement.scrollHeight),v=s?p.innerWidth:p.innerHeight,x=s?window.scrollX:window.scrollY):(g=p[s?"scrollWidth":"scrollHeight"],v=bn(p,s?"width":"height"),x=p[s?"scrollLeft":"scrollTop"]);const b=g-v;if(h.top=Math.ceil(Math.max(Math.min(b,h.top),0)),ac(v,g)||h.top===x){e({scrollHeight:g,scrollTop:x,viewportHeight:v}),w&&t(!0);return}w?(a.current=h.top,l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{l.current=null,a.current=null,t(!0)},1e3)):a.current=null,s&&(h={behavior:h.behavior,left:h.top}),p.scrollTo(h)}function f(h){s&&(h={behavior:h.behavior,left:h.top}),i.current.scrollBy(h)}return{scrollByCallback:f,scrollerRef:i,scrollToCallback:d}}const mi="-webkit-sticky",Ec="sticky",gi=vc(()=>{if(typeof document>"u")return Ec;const e=document.createElement("div");return e.style.position=mi,e.style.position===mi?mi:Ec});function xi(e){return e}const ox=We(()=>{const e=K(a=>`Item ${a}`),t=K(a=>`Group ${a}`),n=K({}),r=K(xi),o=K("div"),s=K(rr),i=(a,l=null)=>xt(z(n,ne(u=>u[a]),nt()),l);return{components:n,computeItemKey:r,EmptyPlaceholder:i("EmptyPlaceholder"),FooterComponent:i("Footer"),GroupComponent:i("Group","div"),groupContent:t,HeaderComponent:i("Header"),HeaderFooterTag:o,ItemComponent:i("Item","div"),itemContent:e,ListComponent:i("List","div"),ScrollerComponent:i("Scroller","div"),scrollerRef:s,ScrollSeekPlaceholder:i("ScrollSeekPlaceholder"),TopItemListComponent:i("TopItemList")}}),sx=We(([e,t])=>({...e,...t}),tt(wc,ox)),ix=({height:e})=>c.jsx("div",{style:{height:e}}),ax={overflowAnchor:"none",position:gi(),zIndex:1},kc={overflowAnchor:"none"},lx={...kc,display:"inline-block",height:"100%"},Ic=S.memo(function({showTopList:e=!1}){const t=Ie("listState"),n=Lt("sizeRanges"),r=Ie("useWindowScroll"),o=Ie("customScrollParent"),s=Lt("windowScrollContainerState"),i=Lt("scrollContainerState"),a=o||r?s:i,l=Ie("itemContent"),u=Ie("context"),d=Ie("groupContent"),f=Ie("trackItemSizes"),h=Ie("itemSize"),p=Ie("log"),w=Lt("gap"),v=Ie("horizontalDirection"),{callbackRef:g}=Cg(n,h,f,e?rr:a,p,w,o,v,Ie("skipAnimationFrameInResizeObserver")),[x,b]=S.useState(0);vi("deviation",P=>{x!==P&&b(P)});const y=Ie("EmptyPlaceholder"),k=Ie("ScrollSeekPlaceholder")||ix,C=Ie("ListComponent"),T=Ie("ItemComponent"),I=Ie("GroupComponent"),A=Ie("computeItemKey"),R=Ie("isSeeking"),j=Ie("groupIndices").length>0,M=Ie("alignToBottom"),D=Ie("initialItemFinalLocationReached"),L=e?{}:{boxSizing:"border-box",...v?{display:"inline-block",height:"100%",marginLeft:x!==0?x:M?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:x!==0?x:M?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...D?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&y?c.jsx(y,{...vt(y,u)}):c.jsx(C,{...vt(C,u),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:g,style:L,children:(e?t.topItems:t.items).map(P=>{const V=P.originalIndex,U=A(V+t.firstItemIndex,P.data,u);return R?S.createElement(k,{...vt(k,u),height:P.size,index:P.index,key:U,type:P.type||"item",...P.type==="group"?{}:{groupIndex:P.groupIndex}}):P.type==="group"?S.createElement(I,{...vt(I,u),"data-index":V,"data-item-index":P.index,"data-known-size":P.size,key:U,style:ax},d(P.index,u)):S.createElement(T,{...vt(T,u),...fx(T,P.data),"data-index":V,"data-item-group-index":P.groupIndex,"data-item-index":P.index,"data-known-size":P.size,key:U,style:v?lx:kc},j?l(P.index,P.groupIndex,P.data,u):l(P.index,P.data,u))})})}),cx={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},ux={outline:"none",overflowX:"auto",position:"relative"},Eo=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),dx={position:gi(),top:0,width:"100%",zIndex:1};function vt(e,t){if(typeof e!="string")return{context:t}}function fx(e,t){return{item:typeof e=="string"?void 0:t}}const hx=S.memo(function(){const e=Ie("HeaderComponent"),t=Lt("headerHeight"),n=Ie("HeaderFooterTag"),r=Dn(S.useMemo(()=>s=>{t(bn(s,"height"))},[t]),!0,Ie("skipAnimationFrameInResizeObserver")),o=Ie("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...vt(e,o)})}):null}),px=S.memo(function(){const e=Ie("FooterComponent"),t=Lt("footerHeight"),n=Ie("HeaderFooterTag"),r=Dn(S.useMemo(()=>s=>{t(bn(s,"height"))},[t]),!0,Ie("skipAnimationFrameInResizeObserver")),o=Ie("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...vt(e,o)})}):null});function Nc({useEmitter:e,useEmitterValue:t,usePublisher:n}){return S.memo(function({children:r,style:o,context:s,...i}){const a=n("scrollContainerState"),l=t("ScrollerComponent"),u=n("smoothScrollTargetReached"),d=t("scrollerRef"),f=t("horizontalDirection")||!1,{scrollByCallback:h,scrollerRef:p,scrollToCallback:w}=Tc(a,u,l,d,void 0,f);return e("scrollTo",w),e("scrollBy",h),c.jsx(l,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:p,style:{...f?ux:cx,...o},tabIndex:0,...i,...vt(l,s),children:r})})}function Ac({useEmitter:e,useEmitterValue:t,usePublisher:n}){return S.memo(function({children:r,style:o,context:s,...i}){const a=n("windowScrollContainerState"),l=t("ScrollerComponent"),u=n("smoothScrollTargetReached"),d=t("totalListHeight"),f=t("deviation"),h=t("customScrollParent"),p=S.useRef(null),w=t("scrollerRef"),{scrollByCallback:v,scrollerRef:g,scrollToCallback:x}=Tc(a,u,l,w,h);return Cc(()=>{var b;return g.current=h||((b=p.current)==null?void 0:b.ownerDocument.defaultView),()=>{g.current=null}},[g,h]),e("windowScrollTo",x),e("scrollBy",v),c.jsx(l,{ref:p,"data-virtuoso-scroller":!0,style:{position:"relative",...o,...d!==0?{height:d+f}:{}},...i,...vt(l,s),children:r})})}const mx=({children:e})=>{const t=S.useContext(yc),n=Lt("viewportHeight"),r=Lt("fixedItemHeight"),o=Ie("alignToBottom"),s=Ie("horizontalDirection"),i=S.useMemo(()=>Hl(n,l=>bn(l,s?"width":"height")),[n,s]),a=Dn(i,!0,Ie("skipAnimationFrameInResizeObserver"));return S.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),c.jsx("div",{"data-viewport-type":"element",ref:a,style:Eo(o),children:e})},gx=({children:e})=>{const t=S.useContext(yc),n=Lt("windowViewportRect"),r=Lt("fixedItemHeight"),o=Ie("customScrollParent"),s=ql(n,o,Ie("skipAnimationFrameInResizeObserver")),i=Ie("alignToBottom");return S.useEffect(()=>{t&&(r(t.itemHeight),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),c.jsx("div",{"data-viewport-type":"window",ref:s,style:Eo(i),children:e})},xx=({children:e})=>{const t=Ie("TopItemListComponent")||"div",n=Ie("headerHeight"),r={...dx,marginTop:`${n}px`},o=Ie("context");return c.jsx(t,{style:r,...vt(t,o),children:e})},vx=S.memo(function(e){const t=Ie("useWindowScroll"),n=Ie("topItemsIndexes").length>0,r=Ie("customScrollParent"),o=Ie("context");return c.jsxs(r||t?yx:bx,{...e,context:o,children:[n&&c.jsx(xx,{children:c.jsx(Ic,{showTopList:!0})}),c.jsxs(r||t?gx:mx,{children:[c.jsx(hx,{}),c.jsx(Ic,{}),c.jsx(px,{})]})]})}),{Component:wx,useEmitter:vi,useEmitterValue:Ie,usePublisher:Lt}=bc(sx,{required:{},optional:{restoreStateFrom:"restoreStateFrom",context:"context",followOutput:"followOutput",scrollIntoViewOnChange:"scrollIntoViewOnChange",itemContent:"itemContent",groupContent:"groupContent",overscan:"overscan",increaseViewportBy:"increaseViewportBy",totalCount:"totalCount",groupCounts:"groupCounts",topItemCount:"topItemCount",firstItemIndex:"firstItemIndex",initialTopMostItemIndex:"initialTopMostItemIndex",components:"components",atBottomThreshold:"atBottomThreshold",atTopThreshold:"atTopThreshold",computeItemKey:"computeItemKey",defaultItemHeight:"defaultItemHeight",fixedItemHeight:"fixedItemHeight",itemSize:"itemSize",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"HeaderFooterTag",data:"data",initialItemCount:"initialItemCount",initialScrollTop:"initialScrollTop",alignToBottom:"alignToBottom",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",horizontalDirection:"horizontalDirection",skipAnimationFrameInResizeObserver:"skipAnimationFrameInResizeObserver"},methods:{scrollToIndex:"scrollToIndex",scrollIntoView:"scrollIntoView",scrollTo:"scrollTo",scrollBy:"scrollBy",autoscrollToBottom:"autoscrollToBottom",getState:"getState"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",totalListHeightChanged:"totalListHeightChanged",itemsRendered:"itemsRendered",groupIndices:"groupIndices"}},vx),bx=Nc({useEmitter:vi,useEmitterValue:Ie,usePublisher:Lt}),yx=Ac({useEmitter:vi,useEmitterValue:Ie,usePublisher:Lt}),Sx=wx;tt(wc,We(()=>{const e=K(u=>c.jsxs("td",{children:["Item $",u]})),t=K(null),n=K(u=>c.jsxs("td",{colSpan:1e3,children:["Group ",u]})),r=K(null),o=K(null),s=K({}),i=K(xi),a=K(rr),l=(u,d=null)=>xt(z(s,ne(f=>f[u]),nt()),d);return{components:s,computeItemKey:i,context:t,EmptyPlaceholder:l("EmptyPlaceholder"),FillerRow:l("FillerRow"),fixedFooterContent:o,fixedHeaderContent:r,itemContent:e,groupContent:n,ScrollerComponent:l("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder"),TableBodyComponent:l("TableBody","tbody"),TableComponent:l("Table","table"),TableFooterComponent:l("TableFoot","tfoot"),TableHeadComponent:l("TableHead","thead"),TableRowComponent:l("TableRow","tr"),GroupComponent:l("Group","tr")}})),gi();const jc={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},Cx={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:_c,floor:ko,max:Mr,min:wi,round:Rc}=Math;function Pc(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function Tx(e){return{...Cx,items:e}}function Io(e,t){return e&&e.width===t.width&&e.height===t.height}function Ex(e,t){return e&&e.column===t.column&&e.row===t.row}const kx=We(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:r},{footerHeight:o,headerHeight:s,scrollBy:i,scrollContainerState:a,scrollTo:l,scrollTop:u,smoothScrollTargetReached:d,viewportHeight:f},h,p,{didMount:w,propsReady:v},{customScrollParent:g,useWindowScroll:x,windowScrollContainerState:b,windowScrollTo:y,windowViewportRect:k},C])=>{const T=K(0),I=K(0),A=K(jc),R=K({height:0,width:0}),j=K({height:0,width:0}),M=ze(),D=ze(),L=K(0),P=K(null),V=K({column:0,row:0}),U=ze(),q=ze(),F=K(!1),N=K(0),W=K(!0),Y=K(!1),de=K(!1);Ve(z(w,Pe(N),be(([O,G])=>!!G)),()=>{je(W,!1)}),Ve(z(dt(w,W,j,R,N,Y),be(([O,G,Z,ce,,ie])=>O&&!G&&Z.height!==0&&ce.height!==0&&!ie)),([,,,,O])=>{je(Y,!0),ci(1,()=>{je(M,O)}),Wt(z(u),()=>{je(t,[0,0]),je(W,!0)})}),ue(z(q,be(O=>O!=null&&O.scrollTop>0),Jt(0)),I),Ve(z(w,Pe(q),be(([,O])=>O!=null)),([,O])=>{O&&(je(R,O.viewport),je(j,O.item),je(V,O.gap),O.scrollTop>0&&(je(F,!0),Wt(z(u,Mn(1)),G=>{je(F,!1)}),je(l,{top:O.scrollTop})))}),ue(z(R,ne(({height:O})=>O)),f),ue(z(dt(ve(R,Io),ve(j,Io),ve(V,(O,G)=>O&&O.column===G.column&&O.row===G.row),ve(u)),ne(([O,G,Z,ce])=>({gap:Z,item:G,scrollTop:ce,viewport:O}))),U),ue(z(dt(ve(T),r,ve(V,Ex),ve(j,Io),ve(R,Io),ve(P),ve(I),ve(F),ve(W),ve(N)),be(([,,,,,,,O])=>!O),ne(([O,[G,Z],ce,ie,De,Xe,Je,,Ne,Oe])=>{const{column:Qe,row:Re}=ce,{height:st,width:ct}=ie,{width:Q}=De;if(Je===0&&(O===0||Q===0))return jc;if(ct===0){const J=ui(Oe,O),Te=J+Math.max(Je-1,0);return Tx(Pc(J,Te,Xe))}const le=Oc(Q,ct,Qe);let me,Ce;Ne?G===0&&Z===0&&Je>0?(me=0,Ce=Je-1):(me=le*ko((G+Re)/(st+Re)),Ce=le*_c((Z+Re)/(st+Re))-1,Ce=wi(O-1,Mr(Ce,le-1)),me=wi(Ce,Mr(0,me))):(me=0,Ce=-1);const we=Pc(me,Ce,Xe),{bottom:_e,top:et}=Mc(De,ce,ie,we),Ke=_c(O/le),$=Ke*st+(Ke-1)*Re-_e;return{bottom:_e,itemHeight:st,items:we,itemWidth:ct,offsetBottom:$,offsetTop:et,top:et}})),A),ue(z(P,be(O=>O!==null),ne(O=>O.length)),T),ue(z(dt(R,j,A,V),be(([O,G,{items:Z}])=>Z.length>0&&G.height!==0&&O.height!==0),ne(([O,G,{items:Z},ce])=>{const{bottom:ie,top:De}=Mc(O,ce,G,Z);return[De,ie]}),nt(Nr)),t);const se=K(!1);ue(z(u,Pe(se),ne(([O,G])=>G||O!==0)),se);const pe=At(z(dt(A,T),be(([{items:O}])=>O.length>0),Pe(se),be(([[O,G],Z])=>{const ce=O.items[O.items.length-1].index===G-1;return(Z||O.bottom>0&&O.itemHeight>0&&O.offsetBottom===0&&O.items.length===G)&&ce}),ne(([[,O]])=>O-1),nt())),ge=At(z(ve(A),be(({items:O})=>O.length>0&&O[0].index===0),Jt(0),nt())),Se=At(z(ve(A),Pe(F),be(([{items:O},G])=>O.length>0&&!G),ne(([{items:O}])=>({endIndex:O[O.length-1].index,startIndex:O[0].index})),nt(ec),hn(0)));ue(Se,p.scrollSeekRangeChanged),ue(z(M,Pe(R,j,T,V),ne(([O,G,Z,ce,ie])=>{const De=ic(O),{align:Xe,behavior:Je,offset:Ne}=De;let Oe=De.index;Oe==="LAST"&&(Oe=ce-1),Oe=Mr(0,Oe,wi(ce-1,Oe));let Qe=bi(G,ie,Z,Oe);return Xe==="end"?Qe=Rc(Qe-G.height+Z.height):Xe==="center"&&(Qe=Rc(Qe-G.height/2+Z.height/2)),Ne&&(Qe+=Ne),{behavior:Je,top:Qe}})),l);const B=xt(z(A,ne(O=>O.offsetBottom+O.bottom)),0);return ue(z(k,ne(O=>({height:O.visibleHeight,width:O.visibleWidth}))),R),{customScrollParent:g,data:P,deviation:L,footerHeight:o,gap:V,headerHeight:s,increaseViewportBy:e,initialItemCount:I,itemDimensions:j,overscan:n,restoreStateFrom:q,scrollBy:i,scrollContainerState:a,scrollHeight:D,scrollTo:l,scrollToIndex:M,scrollTop:u,smoothScrollTargetReached:d,totalCount:T,useWindowScroll:x,viewportDimensions:R,windowScrollContainerState:b,windowScrollTo:y,windowViewportRect:k,...p,gridState:A,horizontalDirection:de,initialTopMostItemIndex:N,totalListHeight:B,...h,endReached:pe,propsReady:v,rangeChanged:Se,startReached:ge,stateChanged:U,stateRestoreInProgress:F,...C}},tt(di,bt,Or,xc,yn,hi,wn));function Oc(e,t,n){return Mr(1,ko((e+n)/(ko(t)+n)))}function Mc(e,t,n,r){const{height:o}=n;if(o===void 0||r.length===0)return{bottom:0,top:0};const s=bi(e,t,n,r[0].index);return{bottom:bi(e,t,n,r[r.length-1].index)+o,top:s}}function bi(e,t,n,r){const o=Oc(e.width,n.width,t.column),s=ko(r/o),i=s*n.height+Mr(0,s-1)*t.row;return i>0?i+t.row:i}const Ix=We(()=>{const e=K(f=>`Item ${f}`),t=K({}),n=K(null),r=K("virtuoso-grid-item"),o=K("virtuoso-grid-list"),s=K(xi),i=K("div"),a=K(rr),l=(f,h=null)=>xt(z(t,ne(p=>p[f]),nt()),h),u=K(!1),d=K(!1);return ue(ve(d),u),{components:t,computeItemKey:s,context:n,FooterComponent:l("Footer"),HeaderComponent:l("Header"),headerFooterTag:i,itemClassName:r,ItemComponent:l("Item","div"),itemContent:e,listClassName:o,ListComponent:l("List","div"),readyStateChanged:u,reportReadyState:d,ScrollerComponent:l("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder","div")}}),Nx=We(([e,t])=>({...e,...t}),tt(kx,Ix)),Ax=S.memo(function(){const e=rt("gridState"),t=rt("listClassName"),n=rt("itemClassName"),r=rt("itemContent"),o=rt("computeItemKey"),s=rt("isSeeking"),i=Ft("scrollHeight"),a=rt("ItemComponent"),l=rt("ListComponent"),u=rt("ScrollSeekPlaceholder"),d=rt("context"),f=Ft("itemDimensions"),h=Ft("gap"),p=rt("log"),w=rt("stateRestoreInProgress"),v=Ft("reportReadyState"),g=Dn(S.useMemo(()=>x=>{const b=x.parentElement.parentElement.scrollHeight;i(b);const y=x.firstChild;if(y){const{height:k,width:C}=y.getBoundingClientRect();f({height:k,width:C})}h({column:Lc("column-gap",getComputedStyle(x).columnGap,p),row:Lc("row-gap",getComputedStyle(x).rowGap,p)})},[i,f,h,p]),!0,!1);return Cc(()=>{e.itemHeight>0&&e.itemWidth>0&&v(!0)},[e]),w?null:c.jsx(l,{className:t,ref:g,...vt(l,d),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(x=>{const b=o(x.index,x.data,d);return s?c.jsx(u,{...vt(u,d),height:e.itemHeight,index:x.index,width:e.itemWidth},b):S.createElement(a,{...vt(a,d),className:n,"data-index":x.index,key:b},r(x.index,x.data,d))})})}),jx=S.memo(function(){const e=rt("HeaderComponent"),t=Ft("headerHeight"),n=rt("headerFooterTag"),r=Dn(S.useMemo(()=>s=>{t(bn(s,"height"))},[t]),!0,!1),o=rt("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...vt(e,o)})}):null}),_x=S.memo(function(){const e=rt("FooterComponent"),t=Ft("footerHeight"),n=rt("headerFooterTag"),r=Dn(S.useMemo(()=>s=>{t(bn(s,"height"))},[t]),!0,!1),o=rt("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...vt(e,o)})}):null}),Rx=({children:e})=>{const t=S.useContext(Sc),n=Ft("itemDimensions"),r=Ft("viewportDimensions"),o=Dn(S.useMemo(()=>s=>{r(s.getBoundingClientRect())},[r]),!0,!1);return S.useEffect(()=>{t&&(r({height:t.viewportHeight,width:t.viewportWidth}),n({height:t.itemHeight,width:t.itemWidth}))},[t,r,n]),c.jsx("div",{ref:o,style:Eo(!1),children:e})},Px=({children:e})=>{const t=S.useContext(Sc),n=Ft("windowViewportRect"),r=Ft("itemDimensions"),o=rt("customScrollParent"),s=ql(n,o,!1);return S.useEffect(()=>{t&&(r({height:t.itemHeight,width:t.itemWidth}),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:t.viewportWidth}))},[t,n,r]),c.jsx("div",{ref:s,style:Eo(!1),children:e})},Ox=S.memo(function({...e}){const t=rt("useWindowScroll"),n=rt("customScrollParent"),r=n||t?Dx:Mx,o=n||t?Px:Rx,s=rt("context");return c.jsx(r,{...e,...vt(r,s),children:c.jsxs(o,{children:[c.jsx(jx,{}),c.jsx(Ax,{}),c.jsx(_x,{})]})})}),{useEmitter:Dc,useEmitterValue:rt,usePublisher:Ft}=bc(Nx,{optional:{context:"context",totalCount:"totalCount",overscan:"overscan",itemContent:"itemContent",components:"components",computeItemKey:"computeItemKey",data:"data",initialItemCount:"initialItemCount",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"headerFooterTag",listClassName:"listClassName",itemClassName:"itemClassName",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",restoreStateFrom:"restoreStateFrom",initialTopMostItemIndex:"initialTopMostItemIndex",increaseViewportBy:"increaseViewportBy"},methods:{scrollTo:"scrollTo",scrollBy:"scrollBy",scrollToIndex:"scrollToIndex"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",stateChanged:"stateChanged",readyStateChanged:"readyStateChanged"}},Ox),Mx=Nc({useEmitter:Dc,useEmitterValue:rt,usePublisher:Ft}),Dx=Ac({useEmitter:Dc,useEmitterValue:rt,usePublisher:Ft});function Lc(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Et.WARN),t==="normal"?0:parseInt(t??"0",10)}const Lx=Qr.cva("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function yi({className:e,variant:t,...n}){return c.jsx("div",{className:X(Lx({variant:t}),e),...n})}function oe(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}function Fx(e,t){const n=m.createContext(t),r=s=>{const{children:i,...a}=s,l=m.useMemo(()=>a,Object.values(a));return c.jsx(n.Provider,{value:l,children:i})};r.displayName=e+"Provider";function o(s){const i=m.useContext(n);if(i)return i;if(t!==void 0)return t;throw new Error(`\`${s}\` must be used within \`${e}\``)}return[r,o]}function en(e,t=[]){let n=[];function r(s,i){const a=m.createContext(i),l=n.length;n=[...n,i];const u=f=>{var x;const{scope:h,children:p,...w}=f,v=((x=h==null?void 0:h[e])==null?void 0:x[l])||a,g=m.useMemo(()=>w,Object.values(w));return c.jsx(v.Provider,{value:g,children:p})};u.displayName=s+"Provider";function d(f,h){var v;const p=((v=h==null?void 0:h[e])==null?void 0:v[l])||a,w=m.useContext(p);if(w)return w;if(i!==void 0)return i;throw new Error(`\`${f}\` must be used within \`${s}\``)}return[u,d]}const o=()=>{const s=n.map(i=>m.createContext(i));return function(a){const l=(a==null?void 0:a[e])||s;return m.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return o.scopeName=e,[r,$x(o,...t)]}function $x(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(s){const i=r.reduce((a,{useScope:l,scopeName:u})=>{const f=l(s)[`__scope${u}`];return{...a,...f}},{});return m.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var pt=globalThis!=null&&globalThis.document?m.useLayoutEffect:()=>{},zx=m[" useInsertionEffect ".trim().toString()]||pt;function $n({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=Bx({defaultProp:t,onChange:n}),a=e!==void 0,l=a?e:o;{const d=m.useRef(e!==void 0);m.useEffect(()=>{const f=d.current;f!==a&&console.warn(`${r} is changing from ${f?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),d.current=a},[a,r])}const u=m.useCallback(d=>{var f;if(a){const h=Hx(d)?d(e):d;h!==e&&((f=i.current)==null||f.call(i,h))}else s(d)},[a,e,s,i]);return[l,u]}function Bx({defaultProp:e,onChange:t}){const[n,r]=m.useState(e),o=m.useRef(n),s=m.useRef(t);return zx(()=>{s.current=t},[t]),m.useEffect(()=>{var i;o.current!==n&&((i=s.current)==null||i.call(s,n),o.current=n)},[n,o]),[n,r,s]}function Hx(e){return typeof e=="function"}function Fc(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Si(...e){return t=>{let n=!1;const r=e.map(o=>{const s=Fc(o,t);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let o=0;o<r.length;o++){const s=r[o];typeof s=="function"?s():Fc(e[o],null)}}}}function Fe(...e){return m.useCallback(Si(...e),e)}var Ux=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],ye=Ux.reduce((e,t)=>{const n=_n.createSlot(`Primitive.${t}`),r=m.forwardRef((o,s)=>{const{asChild:i,...a}=o,l=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),c.jsx(l,{...a,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function $c(e,t){e&&eo.flushSync(()=>e.dispatchEvent(t))}function Wx(e,t){return m.useReducer((n,r)=>t[n][r]??n,e)}var _t=e=>{const{present:t,children:n}=e,r=Vx(t),o=typeof n=="function"?n({present:r.isPresent}):m.Children.only(n),s=Fe(r.ref,Kx(o));return typeof n=="function"||r.isPresent?m.cloneElement(o,{ref:s}):null};_t.displayName="Presence";function Vx(e){const[t,n]=m.useState(),r=m.useRef(null),o=m.useRef(e),s=m.useRef("none"),i=e?"mounted":"unmounted",[a,l]=Wx(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return m.useEffect(()=>{const u=No(r.current);s.current=a==="mounted"?u:"none"},[a]),pt(()=>{const u=r.current,d=o.current;if(d!==e){const h=s.current,p=No(u);e?l("MOUNT"):p==="none"||(u==null?void 0:u.display)==="none"?l("UNMOUNT"):l(d&&h!==p?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,l]),pt(()=>{if(t){let u;const d=t.ownerDocument.defaultView??window,f=p=>{const v=No(r.current).includes(CSS.escape(p.animationName));if(p.target===t&&v&&(l("ANIMATION_END"),!o.current)){const g=t.style.animationFillMode;t.style.animationFillMode="forwards",u=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=g)})}},h=p=>{p.target===t&&(s.current=No(r.current))};return t.addEventListener("animationstart",h),t.addEventListener("animationcancel",f),t.addEventListener("animationend",f),()=>{d.clearTimeout(u),t.removeEventListener("animationstart",h),t.removeEventListener("animationcancel",f),t.removeEventListener("animationend",f)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:m.useCallback(u=>{r.current=u?getComputedStyle(u):null,n(u)},[])}}function No(e){return(e==null?void 0:e.animationName)||"none"}function Kx(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var qx=m[" useId ".trim().toString()]||(()=>{}),Gx=0;function tn(e){const[t,n]=m.useState(qx());return pt(()=>{n(r=>r??String(Gx++))},[e]),e||(t?`radix-${t}`:"")}var Ao="Collapsible",[Yx,OC]=en(Ao),[Xx,Ci]=Yx(Ao),zc=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:o,disabled:s,onOpenChange:i,...a}=e,[l,u]=$n({prop:r,defaultProp:o??!1,onChange:i,caller:Ao});return c.jsx(Xx,{scope:n,disabled:s,contentId:tn(),open:l,onOpenToggle:m.useCallback(()=>u(d=>!d),[u]),children:c.jsx(ye.div,{"data-state":Ei(l),"data-disabled":s?"":void 0,...a,ref:t})})});zc.displayName=Ao;var Bc="CollapsibleTrigger",Hc=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,o=Ci(Bc,n);return c.jsx(ye.button,{type:"button","aria-controls":o.contentId,"aria-expanded":o.open||!1,"data-state":Ei(o.open),"data-disabled":o.disabled?"":void 0,disabled:o.disabled,...r,ref:t,onClick:oe(e.onClick,o.onOpenToggle)})});Hc.displayName=Bc;var Ti="CollapsibleContent",Jx=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Ci(Ti,e.__scopeCollapsible);return c.jsx(_t,{present:n||o.open,children:({present:s})=>c.jsx(Zx,{...r,ref:t,present:s})})});Jx.displayName=Ti;var Zx=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:o,...s}=e,i=Ci(Ti,n),[a,l]=m.useState(r),u=m.useRef(null),d=Fe(t,u),f=m.useRef(0),h=f.current,p=m.useRef(0),w=p.current,v=i.open||a,g=m.useRef(v),x=m.useRef(void 0);return m.useEffect(()=>{const b=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(b)},[]),pt(()=>{const b=u.current;if(b){x.current=x.current||{transitionDuration:b.style.transitionDuration,animationName:b.style.animationName},b.style.transitionDuration="0s",b.style.animationName="none";const y=b.getBoundingClientRect();f.current=y.height,p.current=y.width,g.current||(b.style.transitionDuration=x.current.transitionDuration,b.style.animationName=x.current.animationName),l(r)}},[i.open,r]),c.jsx(ye.div,{"data-state":Ei(i.open),"data-disabled":i.disabled?"":void 0,id:i.contentId,hidden:!v,...s,ref:d,style:{"--radix-collapsible-content-height":h?`${h}px`:void 0,"--radix-collapsible-content-width":w?`${w}px`:void 0,...e.style},children:v&&o})});function Ei(e){return e?"open":"closed"}var Qx=zc;const Uc=Qx,Wc=Hc,Dr=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:X("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));Dr.displayName="Card";const Lr=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:X("flex flex-col space-y-1.5 p-6",e),...t}));Lr.displayName="CardHeader";const Fr=m.forwardRef(({className:e,...t},n)=>c.jsx("h3",{ref:n,className:X("text-2xl font-semibold leading-none tracking-tight",e),...t}));Fr.displayName="CardTitle";const Vc=m.forwardRef(({className:e,...t},n)=>c.jsx("p",{ref:n,className:X("text-sm text-muted-foreground",e),...t}));Vc.displayName="CardDescription";const jo=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:X("p-6 pt-0",e),...t}));jo.displayName="CardContent";const Kc=m.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:X("flex items-center p-6 pt-0",e),...t}));Kc.displayName="CardFooter";function qc(){return{async:!1,baseUrl:null,breaks:!1,extensions:null,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,hooks:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:null,sanitize:!1,sanitizer:null,silent:!1,smartypants:!1,tokenizer:null,walkTokens:null,xhtml:!1}}let zn=qc();function ev(e){zn=e}const Gc=/[&<>"']/,tv=new RegExp(Gc.source,"g"),Yc=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,nv=new RegExp(Yc.source,"g"),rv={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Xc=e=>rv[e];function wt(e,t){if(t){if(Gc.test(e))return e.replace(tv,Xc)}else if(Yc.test(e))return e.replace(nv,Xc);return e}const ov=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function Jc(e){return e.replace(ov,(t,n)=>(n=n.toLowerCase(),n==="colon"?":":n.charAt(0)==="#"?n.charAt(1)==="x"?String.fromCharCode(parseInt(n.substring(2),16)):String.fromCharCode(+n.substring(1)):""))}const sv=/(^|[^\[])\^/g;function Ye(e,t){e=typeof e=="string"?e:e.source,t=t||"";const n={replace:(r,o)=>(o=o.source||o,o=o.replace(sv,"$1"),e=e.replace(r,o),n),getRegex:()=>new RegExp(e,t)};return n}const iv=/[^\w:]/g,av=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function Zc(e,t,n){if(e){let r;try{r=decodeURIComponent(Jc(n)).replace(iv,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}t&&!av.test(n)&&(n=dv(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const _o={},lv=/^[^:]+:\/*[^/]*$/,cv=/^([^:]+:)[\s\S]*$/,uv=/^([^:]+:\/*[^/]*)[\s\S]*$/;function dv(e,t){_o[" "+e]||(lv.test(e)?_o[" "+e]=e+"/":_o[" "+e]=Po(e,"/",!0)),e=_o[" "+e];const n=e.indexOf(":")===-1;return t.substring(0,2)==="//"?n?t:e.replace(cv,"$1")+t:t.charAt(0)==="/"?n?t:e.replace(uv,"$1")+t:e+t}const Ro={exec:function(){}};function Qc(e,t){const n=e.replace(/\|/g,(s,i,a)=>{let l=!1,u=i;for(;--u>=0&&a[u]==="\\";)l=!l;return l?"|":" |"}),r=n.split(/ \|/);let o=0;if(r[0].trim()||r.shift(),r.length>0&&!r[r.length-1].trim()&&r.pop(),r.length>t)r.splice(t);else for(;r.length<t;)r.push("");for(;o<r.length;o++)r[o]=r[o].trim().replace(/\\\|/g,"|");return r}function Po(e,t,n){const r=e.length;if(r===0)return"";let o=0;for(;o<r;){const s=e.charAt(r-o-1);if(s===t&&!n)o++;else if(s!==t&&n)o++;else break}return e.slice(0,r-o)}function fv(e,t){if(e.indexOf(t[1])===-1)return-1;const n=e.length;let r=0,o=0;for(;o<n;o++)if(e[o]==="\\")o++;else if(e[o]===t[0])r++;else if(e[o]===t[1]&&(r--,r<0))return o;return-1}function hv(e){e&&e.sanitize&&!e.silent&&console.warn("marked(): sanitize and sanitizer parameters are deprecated since version 0.7.0, should not be used and will be removed in the future. Read more here: https://marked.js.org/#/USING_ADVANCED.md#options")}function eu(e,t){if(t<1)return"";let n="";for(;t>1;)t&1&&(n+=e),t>>=1,e+=e;return n+e}function tu(e,t,n,r){const o=t.href,s=t.title?wt(t.title):null,i=e[1].replace(/\\([\[\]])/g,"$1");if(e[0].charAt(0)!=="!"){r.state.inLink=!0;const a={type:"link",raw:n,href:o,title:s,text:i,tokens:r.inlineTokens(i)};return r.state.inLink=!1,a}return{type:"image",raw:n,href:o,title:s,text:wt(i)}}function pv(e,t){const n=e.match(/^(\s+)(?:```)/);if(n===null)return t;const r=n[1];return t.split(`
39
39
  `).map(o=>{const s=o.match(/^\s+/);if(s===null)return o;const[i]=s;return i.length>=r.length?o.slice(r.length):o}).join(`
40
- `)}class Ei{constructor(t){this.options=t||zn}space(t){const n=this.rules.block.newline.exec(t);if(n&&n[0].length>0)return{type:"space",raw:n[0]}}code(t){const n=this.rules.block.code.exec(t);if(n){const r=n[0].replace(/^ {1,4}/gm,"");return{type:"code",raw:n[0],codeBlockStyle:"indented",text:this.options.pedantic?r:Po(r,`
40
+ `)}class ki{constructor(t){this.options=t||zn}space(t){const n=this.rules.block.newline.exec(t);if(n&&n[0].length>0)return{type:"space",raw:n[0]}}code(t){const n=this.rules.block.code.exec(t);if(n){const r=n[0].replace(/^ {1,4}/gm,"");return{type:"code",raw:n[0],codeBlockStyle:"indented",text:this.options.pedantic?r:Po(r,`
41
41
  `)}}}fences(t){const n=this.rules.block.fences.exec(t);if(n){const r=n[0],o=pv(r,n[3]||"");return{type:"code",raw:r,lang:n[2]?n[2].trim().replace(this.rules.inline._escapes,"$1"):n[2],text:o}}}heading(t){const n=this.rules.block.heading.exec(t);if(n){let r=n[2].trim();if(/#$/.test(r)){const o=Po(r,"#");(this.options.pedantic||!o||/ $/.test(o))&&(r=o.trim())}return{type:"heading",raw:n[0],depth:n[1].length,text:r,tokens:this.lexer.inline(r)}}}hr(t){const n=this.rules.block.hr.exec(t);if(n)return{type:"hr",raw:n[0]}}blockquote(t){const n=this.rules.block.blockquote.exec(t);if(n){const r=n[0].replace(/^ *>[ \t]?/gm,""),o=this.lexer.state.top;this.lexer.state.top=!0;const s=this.lexer.blockTokens(r);return this.lexer.state.top=o,{type:"blockquote",raw:n[0],tokens:s,text:r}}}list(t){let n=this.rules.block.list.exec(t);if(n){let r,o,s,i,a,l,u,d,f,h,p,w,v=n[1].trim();const g=v.length>1,x={type:"list",raw:"",ordered:g,start:g?+v.slice(0,-1):"",loose:!1,items:[]};v=g?`\\d{1,9}\\${v.slice(-1)}`:`\\${v}`,this.options.pedantic&&(v=g?v:"[*+-]");const b=new RegExp(`^( {0,3}${v})((?:[ ][^\\n]*)?(?:\\n|$))`);for(;t&&(w=!1,!(!(n=b.exec(t))||this.rules.block.hr.test(t)));){if(r=n[0],t=t.substring(r.length),d=n[2].split(`
42
- `,1)[0].replace(/^\t+/,E=>" ".repeat(3*E.length)),f=t.split(`
42
+ `,1)[0].replace(/^\t+/,k=>" ".repeat(3*k.length)),f=t.split(`
43
43
  `,1)[0],this.options.pedantic?(i=2,p=d.trimLeft()):(i=n[2].search(/[^ ]/),i=i>4?1:i,p=d.slice(i),i+=n[1].length),l=!1,!d&&/^ *$/.test(f)&&(r+=f+`
44
- `,t=t.substring(f.length+1),w=!0),!w){const E=new RegExp(`^ {0,${Math.min(3,i-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),C=new RegExp(`^ {0,${Math.min(3,i-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),T=new RegExp(`^ {0,${Math.min(3,i-1)}}(?:\`\`\`|~~~)`),I=new RegExp(`^ {0,${Math.min(3,i-1)}}#`);for(;t&&(h=t.split(`
45
- `,1)[0],f=h,this.options.pedantic&&(f=f.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),!(T.test(f)||I.test(f)||E.test(f)||C.test(t)));){if(f.search(/[^ ]/)>=i||!f.trim())p+=`
44
+ `,t=t.substring(f.length+1),w=!0),!w){const k=new RegExp(`^ {0,${Math.min(3,i-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),C=new RegExp(`^ {0,${Math.min(3,i-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),T=new RegExp(`^ {0,${Math.min(3,i-1)}}(?:\`\`\`|~~~)`),I=new RegExp(`^ {0,${Math.min(3,i-1)}}#`);for(;t&&(h=t.split(`
45
+ `,1)[0],f=h,this.options.pedantic&&(f=f.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),!(T.test(f)||I.test(f)||k.test(f)||C.test(t)));){if(f.search(/[^ ]/)>=i||!f.trim())p+=`
46
46
  `+f.slice(i);else{if(l||d.search(/[^ ]/)>=4||T.test(d)||I.test(d)||C.test(d))break;p+=`
47
47
  `+f}!l&&!f.trim()&&(l=!0),r+=h+`
48
- `,t=t.substring(h.length+1),d=f.slice(i)}}x.loose||(u?x.loose=!0:/\n *\n *$/.test(r)&&(u=!0)),this.options.gfm&&(o=/^\[[ xX]\] /.exec(p),o&&(s=o[0]!=="[ ] ",p=p.replace(/^\[[ xX]\] +/,""))),x.items.push({type:"list_item",raw:r,task:!!o,checked:s,loose:!1,text:p}),x.raw+=r}x.items[x.items.length-1].raw=r.trimRight(),x.items[x.items.length-1].text=p.trimRight(),x.raw=x.raw.trimRight();const y=x.items.length;for(a=0;a<y;a++)if(this.lexer.state.top=!1,x.items[a].tokens=this.lexer.blockTokens(x.items[a].text,[]),!x.loose){const E=x.items[a].tokens.filter(T=>T.type==="space"),C=E.length>0&&E.some(T=>/\n.*\n/.test(T.raw));x.loose=C}if(x.loose)for(a=0;a<y;a++)x.items[a].loose=!0;return x}}html(t){const n=this.rules.block.html.exec(t);if(n){const r={type:"html",raw:n[0],pre:!this.options.sanitizer&&(n[1]==="pre"||n[1]==="script"||n[1]==="style"),text:n[0]};if(this.options.sanitize){const o=this.options.sanitizer?this.options.sanitizer(n[0]):wt(n[0]);r.type="paragraph",r.text=o,r.tokens=this.lexer.inline(o)}return r}}def(t){const n=this.rules.block.def.exec(t);if(n){const r=n[1].toLowerCase().replace(/\s+/g," "),o=n[2]?n[2].replace(/^<(.*)>$/,"$1").replace(this.rules.inline._escapes,"$1"):"",s=n[3]?n[3].substring(1,n[3].length-1).replace(this.rules.inline._escapes,"$1"):n[3];return{type:"def",tag:r,raw:n[0],href:o,title:s}}}table(t){const n=this.rules.block.table.exec(t);if(n){const r={type:"table",header:Qc(n[1]).map(o=>({text:o})),align:n[2].replace(/^ *|\| *$/g,"").split(/ *\| */),rows:n[3]&&n[3].trim()?n[3].replace(/\n[ \t]*$/,"").split(`
48
+ `,t=t.substring(h.length+1),d=f.slice(i)}}x.loose||(u?x.loose=!0:/\n *\n *$/.test(r)&&(u=!0)),this.options.gfm&&(o=/^\[[ xX]\] /.exec(p),o&&(s=o[0]!=="[ ] ",p=p.replace(/^\[[ xX]\] +/,""))),x.items.push({type:"list_item",raw:r,task:!!o,checked:s,loose:!1,text:p}),x.raw+=r}x.items[x.items.length-1].raw=r.trimRight(),x.items[x.items.length-1].text=p.trimRight(),x.raw=x.raw.trimRight();const y=x.items.length;for(a=0;a<y;a++)if(this.lexer.state.top=!1,x.items[a].tokens=this.lexer.blockTokens(x.items[a].text,[]),!x.loose){const k=x.items[a].tokens.filter(T=>T.type==="space"),C=k.length>0&&k.some(T=>/\n.*\n/.test(T.raw));x.loose=C}if(x.loose)for(a=0;a<y;a++)x.items[a].loose=!0;return x}}html(t){const n=this.rules.block.html.exec(t);if(n){const r={type:"html",raw:n[0],pre:!this.options.sanitizer&&(n[1]==="pre"||n[1]==="script"||n[1]==="style"),text:n[0]};if(this.options.sanitize){const o=this.options.sanitizer?this.options.sanitizer(n[0]):wt(n[0]);r.type="paragraph",r.text=o,r.tokens=this.lexer.inline(o)}return r}}def(t){const n=this.rules.block.def.exec(t);if(n){const r=n[1].toLowerCase().replace(/\s+/g," "),o=n[2]?n[2].replace(/^<(.*)>$/,"$1").replace(this.rules.inline._escapes,"$1"):"",s=n[3]?n[3].substring(1,n[3].length-1).replace(this.rules.inline._escapes,"$1"):n[3];return{type:"def",tag:r,raw:n[0],href:o,title:s}}}table(t){const n=this.rules.block.table.exec(t);if(n){const r={type:"table",header:Qc(n[1]).map(o=>({text:o})),align:n[2].replace(/^ *|\| *$/g,"").split(/ *\| */),rows:n[3]&&n[3].trim()?n[3].replace(/\n[ \t]*$/,"").split(`
49
49
  `):[]};if(r.header.length===r.align.length){r.raw=n[0];let o=r.align.length,s,i,a,l;for(s=0;s<o;s++)/^ *-+: *$/.test(r.align[s])?r.align[s]="right":/^ *:-+: *$/.test(r.align[s])?r.align[s]="center":/^ *:-+ *$/.test(r.align[s])?r.align[s]="left":r.align[s]=null;for(o=r.rows.length,s=0;s<o;s++)r.rows[s]=Qc(r.rows[s],r.header.length).map(u=>({text:u}));for(o=r.header.length,i=0;i<o;i++)r.header[i].tokens=this.lexer.inline(r.header[i].text);for(o=r.rows.length,i=0;i<o;i++)for(l=r.rows[i],a=0;a<l.length;a++)l[a].tokens=this.lexer.inline(l[a].text);return r}}}lheading(t){const n=this.rules.block.lheading.exec(t);if(n)return{type:"heading",raw:n[0],depth:n[2].charAt(0)==="="?1:2,text:n[1],tokens:this.lexer.inline(n[1])}}paragraph(t){const n=this.rules.block.paragraph.exec(t);if(n){const r=n[1].charAt(n[1].length-1)===`
50
50
  `?n[1].slice(0,-1):n[1];return{type:"paragraph",raw:n[0],text:r,tokens:this.lexer.inline(r)}}}text(t){const n=this.rules.block.text.exec(t);if(n)return{type:"text",raw:n[0],text:n[0],tokens:this.lexer.inline(n[0])}}escape(t){const n=this.rules.inline.escape.exec(t);if(n)return{type:"escape",raw:n[0],text:wt(n[1])}}tag(t){const n=this.rules.inline.tag.exec(t);if(n)return!this.lexer.state.inLink&&/^<a /i.test(n[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&/^<\/a>/i.test(n[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(n[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(n[0])&&(this.lexer.state.inRawBlock=!1),{type:this.options.sanitize?"text":"html",raw:n[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(n[0]):wt(n[0]):n[0]}}link(t){const n=this.rules.inline.link.exec(t);if(n){const r=n[2].trim();if(!this.options.pedantic&&/^</.test(r)){if(!/>$/.test(r))return;const i=Po(r.slice(0,-1),"\\");if((r.length-i.length)%2===0)return}else{const i=fv(n[2],"()");if(i>-1){const l=(n[0].indexOf("!")===0?5:4)+n[1].length+i;n[2]=n[2].substring(0,i),n[0]=n[0].substring(0,l).trim(),n[3]=""}}let o=n[2],s="";if(this.options.pedantic){const i=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(o);i&&(o=i[1],s=i[3])}else s=n[3]?n[3].slice(1,-1):"";return o=o.trim(),/^</.test(o)&&(this.options.pedantic&&!/>$/.test(r)?o=o.slice(1):o=o.slice(1,-1)),tu(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 tu(r,o,r[0],this.lexer)}}emStrong(t,n,r=""){let o=this.rules.inline.emStrong.lDelim.exec(t);if(!o||o[3]&&r.match(/[\p{L}\p{N}]/u))return;const s=o[1]||o[2]||"";if(!s||s&&(r===""||this.rules.inline.punctuation.exec(r))){const i=o[0].length-1;let a,l,u=i,d=0;const f=o[0][0]==="*"?this.rules.inline.emStrong.rDelimAst:this.rules.inline.emStrong.rDelimUnd;for(f.lastIndex=0,n=n.slice(-1*t.length+i);(o=f.exec(n))!=null;){if(a=o[1]||o[2]||o[3]||o[4]||o[5]||o[6],!a)continue;if(l=a.length,o[3]||o[4]){u+=l;continue}else if((o[5]||o[6])&&i%3&&!((i+l)%3)){d+=l;continue}if(u-=l,u>0)continue;l=Math.min(l,l+u+d);const h=t.slice(0,i+o.index+(o[0].length-a.length)+l);if(Math.min(i,l)%2){const w=h.slice(1,-1);return{type:"em",raw:h,text:w,tokens:this.lexer.inlineTokens(w)}}const p=h.slice(2,-2);return{type:"strong",raw:h,text:p,tokens:this.lexer.inlineTokens(p)}}}}codespan(t){const n=this.rules.inline.code.exec(t);if(n){let r=n[2].replace(/\n/g," ");const o=/[^ ]/.test(r),s=/^ /.test(r)&&/ $/.test(r);return o&&s&&(r=r.substring(1,r.length-1)),r=wt(r,!0),{type:"codespan",raw:n[0],text:r}}}br(t){const n=this.rules.inline.br.exec(t);if(n)return{type:"br",raw:n[0]}}del(t){const n=this.rules.inline.del.exec(t);if(n)return{type:"del",raw:n[0],text:n[2],tokens:this.lexer.inlineTokens(n[2])}}autolink(t,n){const r=this.rules.inline.autolink.exec(t);if(r){let o,s;return r[2]==="@"?(o=wt(this.options.mangle?n(r[1]):r[1]),s="mailto:"+o):(o=wt(r[1]),s=o),{type:"link",raw:r[0],text:o,href:s,tokens:[{type:"text",raw:o,text:o}]}}}url(t,n){let r;if(r=this.rules.inline.url.exec(t)){let o,s;if(r[2]==="@")o=wt(this.options.mangle?n(r[0]):r[0]),s="mailto:"+o;else{let i;do i=r[0],r[0]=this.rules.inline._backpedal.exec(r[0])[0];while(i!==r[0]);o=wt(r[0]),r[1]==="www."?s="http://"+r[0]:s=r[0]}return{type:"link",raw:r[0],text:o,href:s,tokens:[{type:"text",raw:o,text:o}]}}}inlineText(t,n){const r=this.rules.inline.text.exec(t);if(r){let o;return this.lexer.state.inRawBlock?o=this.options.sanitize?this.options.sanitizer?this.options.sanitizer(r[0]):wt(r[0]):r[0]:o=wt(this.options.smartypants?n(r[0]):r[0]),{type:"text",raw:r[0],text:o}}}}const fe={newline:/^(?: *(?:\n|$))+/,code:/^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,fences:/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,hr:/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,blockquote:/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,list:/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/,html:"^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n *)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$))",def:/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/,table:Ro,lheading:/^((?:.|\n(?!\n))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,text:/^[^\n]+/};fe._label=/(?!\s*\])(?:\\.|[^\[\]\\])+/,fe._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,fe.def=Ye(fe.def).replace("label",fe._label).replace("title",fe._title).getRegex(),fe.bullet=/(?:[*+-]|\d{1,9}[.)])/,fe.listItemStart=Ye(/^( *)(bull) */).replace("bull",fe.bullet).getRegex(),fe.list=Ye(fe.list).replace(/bull/g,fe.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+fe.def.source+")").getRegex(),fe._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",fe._comment=/<!--(?!-?>)[\s\S]*?(?:-->|$)/,fe.html=Ye(fe.html,"i").replace("comment",fe._comment).replace("tag",fe._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),fe.paragraph=Ye(fe._paragraph).replace("hr",fe.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",fe._tag).getRegex(),fe.blockquote=Ye(fe.blockquote).replace("paragraph",fe.paragraph).getRegex(),fe.normal={...fe},fe.gfm={...fe.normal,table:"^ *([^\\n ].*\\|.*)\\n {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"},fe.gfm.table=Ye(fe.gfm.table).replace("hr",fe.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",fe._tag).getRegex(),fe.gfm.paragraph=Ye(fe._paragraph).replace("hr",fe.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("table",fe.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",fe._tag).getRegex(),fe.pedantic={...fe.normal,html:Ye(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",fe._comment).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Ro,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:Ye(fe.normal._paragraph).replace("hr",fe.hr).replace("heading",` *#{1,6} *[^
51
- ]`).replace("lheading",fe.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()};const re={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:Ro,tag:"^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>",link:/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/,reflink:/^!?\[(label)\]\[(ref)\]/,nolink:/^!?\[(ref)\](?:\[\])?/,reflinkSearch:"reflink|nolink(?!\\()",emStrong:{lDelim:/^(?:\*+(?:([punct_])|[^\s*]))|^_+(?:([punct*])|([^\s_]))/,rDelimAst:/^(?:[^_*\\]|\\.)*?\_\_(?:[^_*\\]|\\.)*?\*(?:[^_*\\]|\\.)*?(?=\_\_)|(?:[^*\\]|\\.)+(?=[^*])|[punct_](\*+)(?=[\s]|$)|(?:[^punct*_\s\\]|\\.)(\*+)(?=[punct_\s]|$)|[punct_\s](\*+)(?=[^punct*_\s])|[\s](\*+)(?=[punct_])|[punct_](\*+)(?=[punct_])|(?:[^punct*_\s\\]|\\.)(\*+)(?=[^punct*_\s])/,rDelimUnd:/^(?:[^_*\\]|\\.)*?\*\*(?:[^_*\\]|\\.)*?\_(?:[^_*\\]|\\.)*?(?=\*\*)|(?:[^_\\]|\\.)+(?=[^_])|[punct*](\_+)(?=[\s]|$)|(?:[^punct*_\s\\]|\\.)(\_+)(?=[punct*\s]|$)|[punct*\s](\_+)(?=[^punct*_\s])|[\s](\_+)(?=[punct*])|[punct*](\_+)(?=[punct*])/},code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,br:/^( {2,}|\\)\n(?!\s*$)/,del:Ro,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,punctuation:/^([\spunctuation])/};re._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",re.punctuation=Ye(re.punctuation).replace(/punctuation/g,re._punctuation).getRegex(),re.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g,re.escapedEmSt=/(?:^|[^\\])(?:\\\\)*\\[*_]/g,re._comment=Ye(fe._comment).replace("(?:-->|$)","-->").getRegex(),re.emStrong.lDelim=Ye(re.emStrong.lDelim).replace(/punct/g,re._punctuation).getRegex(),re.emStrong.rDelimAst=Ye(re.emStrong.rDelimAst,"g").replace(/punct/g,re._punctuation).getRegex(),re.emStrong.rDelimUnd=Ye(re.emStrong.rDelimUnd,"g").replace(/punct/g,re._punctuation).getRegex(),re._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,re._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,re._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])?)+(?![-_])/,re.autolink=Ye(re.autolink).replace("scheme",re._scheme).replace("email",re._email).getRegex(),re._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,re.tag=Ye(re.tag).replace("comment",re._comment).replace("attribute",re._attribute).getRegex(),re._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,re._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/,re._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,re.link=Ye(re.link).replace("label",re._label).replace("href",re._href).replace("title",re._title).getRegex(),re.reflink=Ye(re.reflink).replace("label",re._label).replace("ref",fe._label).getRegex(),re.nolink=Ye(re.nolink).replace("ref",fe._label).getRegex(),re.reflinkSearch=Ye(re.reflinkSearch,"g").replace("reflink",re.reflink).replace("nolink",re.nolink).getRegex(),re.normal={...re},re.pedantic={...re.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:Ye(/^!?\[(label)\]\((.*?)\)/).replace("label",re._label).getRegex(),reflink:Ye(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",re._label).getRegex()},re.gfm={...re.normal,escape:Ye(re.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.!#$%&'*+\/=?_`{\|}~-]+@)))/},re.gfm.url=Ye(re.gfm.url,"i").replace("email",re.gfm._extended_email).getRegex(),re.breaks={...re.gfm,br:Ye(re.br).replace("{2,}","*").getRegex(),text:Ye(re.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()};function mv(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 nu(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 Sn{constructor(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||zn,this.options.tokenizer=this.options.tokenizer||new Ei,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};const n={block:fe.normal,inline:re.normal};this.options.pedantic?(n.block=fe.pedantic,n.inline=re.pedantic):this.options.gfm&&(n.block=fe.gfm,this.options.breaks?n.inline=re.breaks:n.inline=re.gfm),this.tokenizer.rules=n}static get rules(){return{block:fe,inline:re}}static lex(t,n){return new Sn(n).lex(t)}static lexInline(t,n){return new Sn(n).inlineTokens(t)}lex(t){t=t.replace(/\r\n|\r/g,`
51
+ ]`).replace("lheading",fe.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()};const re={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:Ro,tag:"^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>",link:/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/,reflink:/^!?\[(label)\]\[(ref)\]/,nolink:/^!?\[(ref)\](?:\[\])?/,reflinkSearch:"reflink|nolink(?!\\()",emStrong:{lDelim:/^(?:\*+(?:([punct_])|[^\s*]))|^_+(?:([punct*])|([^\s_]))/,rDelimAst:/^(?:[^_*\\]|\\.)*?\_\_(?:[^_*\\]|\\.)*?\*(?:[^_*\\]|\\.)*?(?=\_\_)|(?:[^*\\]|\\.)+(?=[^*])|[punct_](\*+)(?=[\s]|$)|(?:[^punct*_\s\\]|\\.)(\*+)(?=[punct_\s]|$)|[punct_\s](\*+)(?=[^punct*_\s])|[\s](\*+)(?=[punct_])|[punct_](\*+)(?=[punct_])|(?:[^punct*_\s\\]|\\.)(\*+)(?=[^punct*_\s])/,rDelimUnd:/^(?:[^_*\\]|\\.)*?\*\*(?:[^_*\\]|\\.)*?\_(?:[^_*\\]|\\.)*?(?=\*\*)|(?:[^_\\]|\\.)+(?=[^_])|[punct*](\_+)(?=[\s]|$)|(?:[^punct*_\s\\]|\\.)(\_+)(?=[punct*\s]|$)|[punct*\s](\_+)(?=[^punct*_\s])|[\s](\_+)(?=[punct*])|[punct*](\_+)(?=[punct*])/},code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,br:/^( {2,}|\\)\n(?!\s*$)/,del:Ro,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,punctuation:/^([\spunctuation])/};re._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",re.punctuation=Ye(re.punctuation).replace(/punctuation/g,re._punctuation).getRegex(),re.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g,re.escapedEmSt=/(?:^|[^\\])(?:\\\\)*\\[*_]/g,re._comment=Ye(fe._comment).replace("(?:-->|$)","-->").getRegex(),re.emStrong.lDelim=Ye(re.emStrong.lDelim).replace(/punct/g,re._punctuation).getRegex(),re.emStrong.rDelimAst=Ye(re.emStrong.rDelimAst,"g").replace(/punct/g,re._punctuation).getRegex(),re.emStrong.rDelimUnd=Ye(re.emStrong.rDelimUnd,"g").replace(/punct/g,re._punctuation).getRegex(),re._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,re._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,re._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])?)+(?![-_])/,re.autolink=Ye(re.autolink).replace("scheme",re._scheme).replace("email",re._email).getRegex(),re._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,re.tag=Ye(re.tag).replace("comment",re._comment).replace("attribute",re._attribute).getRegex(),re._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,re._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/,re._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,re.link=Ye(re.link).replace("label",re._label).replace("href",re._href).replace("title",re._title).getRegex(),re.reflink=Ye(re.reflink).replace("label",re._label).replace("ref",fe._label).getRegex(),re.nolink=Ye(re.nolink).replace("ref",fe._label).getRegex(),re.reflinkSearch=Ye(re.reflinkSearch,"g").replace("reflink",re.reflink).replace("nolink",re.nolink).getRegex(),re.normal={...re},re.pedantic={...re.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:Ye(/^!?\[(label)\]\((.*?)\)/).replace("label",re._label).getRegex(),reflink:Ye(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",re._label).getRegex()},re.gfm={...re.normal,escape:Ye(re.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.!#$%&'*+\/=?_`{\|}~-]+@)))/},re.gfm.url=Ye(re.gfm.url,"i").replace("email",re.gfm._extended_email).getRegex(),re.breaks={...re.gfm,br:Ye(re.br).replace("{2,}","*").getRegex(),text:Ye(re.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()};function mv(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 nu(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 Sn{constructor(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||zn,this.options.tokenizer=this.options.tokenizer||new ki,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:fe.normal,inline:re.normal};this.options.pedantic?(n.block=fe.pedantic,n.inline=re.pedantic):this.options.gfm&&(n.block=fe.gfm,this.options.breaks?n.inline=re.breaks:n.inline=re.gfm),this.tokenizer.rules=n}static get rules(){return{block:fe,inline:re}}static lex(t,n){return new Sn(n).lex(t)}static lexInline(t,n){return new Sn(n).inlineTokens(t)}lex(t){t=t.replace(/\r\n|\r/g,`
52
52
  `),this.blockTokens(t,this.tokens);let n;for(;n=this.inlineQueue.shift();)this.inlineTokens(n.src,n.tokens);return this.tokens}blockTokens(t,n=[]){this.options.pedantic?t=t.replace(/\t/g," ").replace(/^ +$/gm,""):t=t.replace(/^( *)(\t+)/gm,(a,l,u)=>l+" ".repeat(u.length));let r,o,s,i;for(;t;)if(!(this.options.extensions&&this.options.extensions.block&&this.options.extensions.block.some(a=>(r=a.call({lexer:this},t,n))?(t=t.substring(r.raw.length),n.push(r),!0):!1))){if(r=this.tokenizer.space(t)){t=t.substring(r.raw.length),r.raw.length===1&&n.length>0?n[n.length-1].raw+=`
53
53
  `:n.push(r);continue}if(r=this.tokenizer.code(t)){t=t.substring(r.raw.length),o=n[n.length-1],o&&(o.type==="paragraph"||o.type==="text")?(o.raw+=`
54
54
  `+r.raw,o.text+=`
@@ -78,9 +78,9 @@ ${t}</blockquote>
78
78
  `}tablerow(t){return`<tr>
79
79
  ${t}</tr>
80
80
  `}tablecell(t,n){const r=n.header?"th":"td";return(n.align?`<${r} align="${n.align}">`:`<${r}>`)+t+`</${r}>
81
- `}strong(t){return`<strong>${t}</strong>`}em(t){return`<em>${t}</em>`}codespan(t){return`<code>${t}</code>`}br(){return this.options.xhtml?"<br/>":"<br>"}del(t){return`<del>${t}</del>`}link(t,n,r){if(t=Zc(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=Zc(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 ru{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 ou{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 Cn{constructor(t){this.options=t||zn,this.options.renderer=this.options.renderer||new Ii,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new ru,this.slugger=new ou}static parse(t,n){return new Cn(n).parse(t)}static parseInline(t,n){return new Cn(n).parseInline(t)}parse(t,n=!0){let r="",o,s,i,a,l,u,d,f,h,p,w,v,g,x,b,y,E,C,T;const I=t.length;for(o=0;o<I;o++){if(p=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[p.type]&&(T=this.options.extensions.renderers[p.type].call({parser:this},p),T!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(p.type))){r+=T||"";continue}switch(p.type){case"space":continue;case"hr":{r+=this.renderer.hr();continue}case"heading":{r+=this.renderer.heading(this.parseInline(p.tokens),p.depth,Jc(this.parseInline(p.tokens,this.textRenderer)),this.slugger);continue}case"code":{r+=this.renderer.code(p.text,p.lang,p.escaped);continue}case"table":{for(f="",d="",a=p.header.length,s=0;s<a;s++)d+=this.renderer.tablecell(this.parseInline(p.header[s].tokens),{header:!0,align:p.align[s]});for(f+=this.renderer.tablerow(d),h="",a=p.rows.length,s=0;s<a;s++){for(u=p.rows[s],d="",l=u.length,i=0;i<l;i++)d+=this.renderer.tablecell(this.parseInline(u[i].tokens),{header:!1,align:p.align[i]});h+=this.renderer.tablerow(d)}r+=this.renderer.table(f,h);continue}case"blockquote":{h=this.parse(p.tokens),r+=this.renderer.blockquote(h);continue}case"list":{for(w=p.ordered,v=p.start,g=p.loose,a=p.items.length,h="",s=0;s<a;s++)b=p.items[s],y=b.checked,E=b.task,x="",b.task&&(C=this.renderer.checkbox(y),g?b.tokens.length>0&&b.tokens[0].type==="paragraph"?(b.tokens[0].text=C+" "+b.tokens[0].text,b.tokens[0].tokens&&b.tokens[0].tokens.length>0&&b.tokens[0].tokens[0].type==="text"&&(b.tokens[0].tokens[0].text=C+" "+b.tokens[0].tokens[0].text)):b.tokens.unshift({type:"text",text:C}):x+=C),x+=this.parse(b.tokens,g),h+=this.renderer.listitem(x,E,y);r+=this.renderer.list(h,w,v);continue}case"html":{r+=this.renderer.html(p.text);continue}case"paragraph":{r+=this.renderer.paragraph(this.parseInline(p.tokens));continue}case"text":{for(h=p.tokens?this.parseInline(p.tokens):p.text;o+1<I&&t[o+1].type==="text";)p=t[++o],h+=`
81
+ `}strong(t){return`<strong>${t}</strong>`}em(t){return`<em>${t}</em>`}codespan(t){return`<code>${t}</code>`}br(){return this.options.xhtml?"<br/>":"<br>"}del(t){return`<del>${t}</del>`}link(t,n,r){if(t=Zc(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=Zc(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 ru{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 ou{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 Cn{constructor(t){this.options=t||zn,this.options.renderer=this.options.renderer||new Ii,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new ru,this.slugger=new ou}static parse(t,n){return new Cn(n).parse(t)}static parseInline(t,n){return new Cn(n).parseInline(t)}parse(t,n=!0){let r="",o,s,i,a,l,u,d,f,h,p,w,v,g,x,b,y,k,C,T;const I=t.length;for(o=0;o<I;o++){if(p=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[p.type]&&(T=this.options.extensions.renderers[p.type].call({parser:this},p),T!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(p.type))){r+=T||"";continue}switch(p.type){case"space":continue;case"hr":{r+=this.renderer.hr();continue}case"heading":{r+=this.renderer.heading(this.parseInline(p.tokens),p.depth,Jc(this.parseInline(p.tokens,this.textRenderer)),this.slugger);continue}case"code":{r+=this.renderer.code(p.text,p.lang,p.escaped);continue}case"table":{for(f="",d="",a=p.header.length,s=0;s<a;s++)d+=this.renderer.tablecell(this.parseInline(p.header[s].tokens),{header:!0,align:p.align[s]});for(f+=this.renderer.tablerow(d),h="",a=p.rows.length,s=0;s<a;s++){for(u=p.rows[s],d="",l=u.length,i=0;i<l;i++)d+=this.renderer.tablecell(this.parseInline(u[i].tokens),{header:!1,align:p.align[i]});h+=this.renderer.tablerow(d)}r+=this.renderer.table(f,h);continue}case"blockquote":{h=this.parse(p.tokens),r+=this.renderer.blockquote(h);continue}case"list":{for(w=p.ordered,v=p.start,g=p.loose,a=p.items.length,h="",s=0;s<a;s++)b=p.items[s],y=b.checked,k=b.task,x="",b.task&&(C=this.renderer.checkbox(y),g?b.tokens.length>0&&b.tokens[0].type==="paragraph"?(b.tokens[0].text=C+" "+b.tokens[0].text,b.tokens[0].tokens&&b.tokens[0].tokens.length>0&&b.tokens[0].tokens[0].type==="text"&&(b.tokens[0].tokens[0].text=C+" "+b.tokens[0].tokens[0].text)):b.tokens.unshift({type:"text",text:C}):x+=C),x+=this.parse(b.tokens,g),h+=this.renderer.listitem(x,k,y);r+=this.renderer.list(h,w,v);continue}case"html":{r+=this.renderer.html(p.text);continue}case"paragraph":{r+=this.renderer.paragraph(this.parseInline(p.tokens));continue}case"text":{for(h=p.tokens?this.parseInline(p.tokens):p.text;o+1<I&&t[o+1].type==="text";)p=t[++o],h+=`
82
82
  `+(p.tokens?this.parseInline(p.tokens):p.text);r+=n?this.renderer.paragraph(h):h;continue}default:{const A='Token with "'+p.type+'" type was not found.';if(this.options.silent){console.error(A);return}else throw new Error(A)}}}return r}parseInline(t,n){n=n||this.renderer;let r="",o,s,i;const a=t.length;for(o=0;o<a;o++){if(s=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[s.type]&&(i=this.options.extensions.renderers[s.type].call({parser:this},s),i!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type))){r+=i||"";continue}switch(s.type){case"escape":{r+=n.text(s.text);break}case"html":{r+=n.html(s.text);break}case"link":{r+=n.link(s.href,s.title,this.parseInline(s.tokens,n));break}case"image":{r+=n.image(s.href,s.title,s.text);break}case"strong":{r+=n.strong(this.parseInline(s.tokens,n));break}case"em":{r+=n.em(this.parseInline(s.tokens,n));break}case"codespan":{r+=n.codespan(s.text);break}case"br":{r+=n.br();break}case"del":{r+=n.del(this.parseInline(s.tokens,n));break}case"text":{r+=n.text(s.text);break}default:{const l='Token with "'+s.type+'" type was not found.';if(this.options.silent){console.error(l);return}else throw new Error(l)}}}return r}}class Oo{constructor(t){this.options=t||zn}preprocess(t){return t}postprocess(t){return t}}xp(Oo,"passThroughHooks",new Set(["preprocess","postprocess"]));function gv(e,t,n){return r=>{if(r.message+=`
83
- Please report this to https://github.com/markedjs/marked.`,e){const o="<p>An error occurred:</p><pre>"+wt(r.message+"",!0)+"</pre>";if(t)return Promise.resolve(o);if(n){n(null,o);return}return o}if(t)return Promise.reject(r);if(n){n(r);return}throw r}}function su(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...he.defaults,...s};const i=gv(r.silent,r.async,o);if(typeof n>"u"||n===null)return i(new Error("marked(): input parameter is undefined or null"));if(typeof n!="string")return i(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(n)+", string expected"));if(hv(r),r.hooks&&(r.hooks.options=r),o){const a=r.highlight;let l;try{r.hooks&&(n=r.hooks.preprocess(n)),l=e(n,r)}catch(f){return i(f)}const u=function(f){let h;if(!f)try{r.walkTokens&&he.walkTokens(l,r.walkTokens),h=t(l,r),r.hooks&&(h=r.hooks.postprocess(h))}catch(p){f=p}return r.highlight=a,f?i(f):o(null,h)};if(!a||a.length<3||(delete r.highlight,!l.length))return u();let d=0;he.walkTokens(l,function(f){f.type==="code"&&(d++,setTimeout(()=>{a(f.text,f.lang,function(h,p){if(h)return u(h);p!=null&&p!==f.text&&(f.text=p,f.escaped=!0),d--,d===0&&u()})},0))}),d===0&&u();return}if(r.async)return Promise.resolve(r.hooks?r.hooks.preprocess(n):n).then(a=>e(a,r)).then(a=>r.walkTokens?Promise.all(he.walkTokens(a,r.walkTokens)).then(()=>a):a).then(a=>t(a,r)).then(a=>r.hooks?r.hooks.postprocess(a):a).catch(i);try{r.hooks&&(n=r.hooks.preprocess(n));const a=e(n,r);r.walkTokens&&he.walkTokens(a,r.walkTokens);let l=t(a,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(a){return i(a)}}}function he(e,t,n){return su(Sn.lex,Cn.parse)(e,t,n)}he.options=he.setOptions=function(e){return he.defaults={...he.defaults,...e},ev(he.defaults),he},he.getDefaults=qc,he.defaults=zn,he.use=function(...e){const t=he.defaults.extensions||{renderers:{},childTokens:{}};e.forEach(n=>{const r={...n};if(r.async=he.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(o=>{if(!o.name)throw new Error("extension name required");if(o.renderer){const s=t.renderers[o.name];s?t.renderers[o.name]=function(...i){let a=o.renderer.apply(this,i);return a===!1&&(a=s.apply(this,i)),a}:t.renderers[o.name]=o.renderer}if(o.tokenizer){if(!o.level||o.level!=="block"&&o.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");t[o.level]?t[o.level].unshift(o.tokenizer):t[o.level]=[o.tokenizer],o.start&&(o.level==="block"?t.startBlock?t.startBlock.push(o.start):t.startBlock=[o.start]:o.level==="inline"&&(t.startInline?t.startInline.push(o.start):t.startInline=[o.start]))}o.childTokens&&(t.childTokens[o.name]=o.childTokens)}),r.extensions=t),n.renderer){const o=he.defaults.renderer||new Ii;for(const s in n.renderer){const i=o[s];o[s]=(...a)=>{let l=n.renderer[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.renderer=o}if(n.tokenizer){const o=he.defaults.tokenizer||new Ei;for(const s in n.tokenizer){const i=o[s];o[s]=(...a)=>{let l=n.tokenizer[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.tokenizer=o}if(n.hooks){const o=he.defaults.hooks||new Oo;for(const s in n.hooks){const i=o[s];Oo.passThroughHooks.has(s)?o[s]=a=>{if(he.defaults.async)return Promise.resolve(n.hooks[s].call(o,a)).then(u=>i.call(o,u));const l=n.hooks[s].call(o,a);return i.call(o,l)}:o[s]=(...a)=>{let l=n.hooks[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.hooks=o}if(n.walkTokens){const o=he.defaults.walkTokens;r.walkTokens=function(s){let i=[];return i.push(n.walkTokens.call(this,s)),o&&(i=i.concat(o.call(this,s))),i}}he.setOptions(r)})},he.walkTokens=function(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(he,r)),r.type){case"table":{for(const o of r.header)n=n.concat(he.walkTokens(o.tokens,t));for(const o of r.rows)for(const s of o)n=n.concat(he.walkTokens(s.tokens,t));break}case"list":{n=n.concat(he.walkTokens(r.items,t));break}default:he.defaults.extensions&&he.defaults.extensions.childTokens&&he.defaults.extensions.childTokens[r.type]?he.defaults.extensions.childTokens[r.type].forEach(function(o){n=n.concat(he.walkTokens(r[o],t))}):r.tokens&&(n=n.concat(he.walkTokens(r.tokens,t)))}return n},he.parseInline=su(Sn.lexInline,Cn.parseInline),he.Parser=Cn,he.parser=Cn.parse,he.Renderer=Ii,he.TextRenderer=ru,he.Lexer=Sn,he.lexer=Sn.lex,he.Tokenizer=Ei,he.Slugger=ou,he.Hooks=Oo,he.parse=he,he.options,he.setOptions,he.use,he.walkTokens,he.parseInline,Cn.parse,Sn.lex;function Ni({content:e,className:t="",allowHtml:n=!1}){const r=S.useMemo(()=>{try{if(!n){const o=e.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"").replace(/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi,"").replace(/javascript:/gi,"").replace(/on\w+\s*=/gi,"");return he.parse(o)}return he.parse(e)}catch(o){return console.error("[MarkdownContent] parse error",o),`<pre>Error rendering markdown: ${String(o)}</pre>`}},[e,n]);return c.jsx("div",{className:X("markdown prose max-w-none break-words dark:prose-invert",t),dangerouslySetInnerHTML:{__html:r}})}async function iu(e,t){return await It(e,{responseType:"blob",onDownloadProgress:r=>{try{t&&r.lengthComputable}catch{}},maxBodyLength:1/0})}async function au(e,t){return await(await iu(`/files/${e}/view`,t)).text()}async function xv(e,t){const n=await iu(`/files/${e}/download`,t),r=URL.createObjectURL(n);let o=`file_${e}`;try{const i=await It(`/files/${e}`);o=(i==null?void 0:i.filename)??o}catch{}const s=document.createElement("a");s.href=r,s.download=o,document.body.appendChild(s),s.click(),s.remove(),setTimeout(()=>URL.revokeObjectURL(r),6e4)}async function vv(e,t=50,n=0){const r={limit:t,offset:n};return e&&(r.thread_id=e),await It("/files",{params:r})}const wv=1,bv=1e6;let Ai=0;function yv(){return Ai=(Ai+1)%Number.MAX_SAFE_INTEGER,Ai.toString()}const ji=new Map,lu=e=>{if(ji.has(e))return;const t=setTimeout(()=>{ji.delete(e),$r({type:"REMOVE_TOAST",toastId:e})},bv);ji.set(e,t)},Sv=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,wv)};case"UPDATE_TOAST":return{...e,toasts:e.toasts.map(n=>n.id===t.toast.id?{...n,...t.toast}:n)};case"DISMISS_TOAST":{const{toastId:n}=t;return n?lu(n):e.toasts.forEach(r=>{lu(r.id)}),{...e,toasts:e.toasts.map(r=>r.id===n||n===void 0?{...r,open:!1}:r)}}case"REMOVE_TOAST":return t.toastId===void 0?{...e,toasts:[]}:{...e,toasts:e.toasts.filter(n=>n.id!==t.toastId)}}},Mo=[];let Do={toasts:[]};function $r(e){Do=Sv(Do,e),Mo.forEach(t=>{t(Do)})}function Cv({...e}){const t=yv(),n=o=>$r({type:"UPDATE_TOAST",toast:{...o,id:t}}),r=()=>$r({type:"DISMISS_TOAST",toastId:t});return $r({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:o=>{o||r()}}}),{id:t,dismiss:r,update:n}}function _i(){const[e,t]=m.useState(Do);return m.useEffect(()=>(Mo.push(t),()=>{const n=Mo.indexOf(t);n>-1&&Mo.splice(n,1)}),[e]),{...e,toast:Cv,dismiss:n=>$r({type:"DISMISS_TOAST",toastId:n})}}function mt(e){const t=m.useRef(e);return m.useEffect(()=>{t.current=e}),m.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function Tv(e,t=globalThis==null?void 0:globalThis.document){const n=mt(e);m.useEffect(()=>{const r=o=>{o.key==="Escape"&&n(o)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var kv="DismissableLayer",Ri="dismissableLayer.update",Ev="dismissableLayer.pointerDownOutside",Iv="dismissableLayer.focusOutside",cu,uu=m.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Lo=m.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...l}=e,u=m.useContext(uu),[d,f]=m.useState(null),h=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,p]=m.useState({}),w=Fe(t,I=>f(I)),v=Array.from(u.layers),[g]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),x=v.indexOf(g),b=d?v.indexOf(d):-1,y=u.layersWithOutsidePointerEventsDisabled.size>0,E=b>=x,C=jv(I=>{const A=I.target,R=[...u.branches].some(j=>j.contains(A));!E||R||(o==null||o(I),i==null||i(I),I.defaultPrevented||a==null||a())},h),T=_v(I=>{const A=I.target;[...u.branches].some(j=>j.contains(A))||(s==null||s(I),i==null||i(I),I.defaultPrevented||a==null||a())},h);return Tv(I=>{b===u.layers.size-1&&(r==null||r(I),!I.defaultPrevented&&a&&(I.preventDefault(),a()))},h),m.useEffect(()=>{if(d)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(cu=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),du(),()=>{n&&u.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=cu)}},[d,h,n,u]),m.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),du())},[d,u]),m.useEffect(()=>{const I=()=>p({});return document.addEventListener(Ri,I),()=>document.removeEventListener(Ri,I)},[]),c.jsx(ye.div,{...l,ref:w,style:{pointerEvents:y?E?"auto":"none":void 0,...e.style},onFocusCapture:oe(e.onFocusCapture,T.onFocusCapture),onBlurCapture:oe(e.onBlurCapture,T.onBlurCapture),onPointerDownCapture:oe(e.onPointerDownCapture,C.onPointerDownCapture)})});Lo.displayName=kv;var Nv="DismissableLayerBranch",Av=m.forwardRef((e,t)=>{const n=m.useContext(uu),r=m.useRef(null),o=Fe(t,r);return m.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),c.jsx(ye.div,{...e,ref:o})});Av.displayName=Nv;function jv(e,t=globalThis==null?void 0:globalThis.document){const n=mt(e),r=m.useRef(!1),o=m.useRef(()=>{});return m.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){fu(Ev,n,u,{discrete:!0})};const u={originalEvent:a};a.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=l,t.addEventListener("click",o.current,{once:!0})):l()}else t.removeEventListener("click",o.current);r.current=!1},i=window.setTimeout(()=>{t.addEventListener("pointerdown",s)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",s),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function _v(e,t=globalThis==null?void 0:globalThis.document){const n=mt(e),r=m.useRef(!1);return m.useEffect(()=>{const o=s=>{s.target&&!r.current&&fu(Iv,n,{originalEvent:s},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function du(){const e=new CustomEvent(Ri);document.dispatchEvent(e)}function fu(e,t,n,{discrete:r}){const o=n.originalEvent.target,s=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?$c(o,s):o.dispatchEvent(s)}var Pi="focusScope.autoFocusOnMount",Oi="focusScope.autoFocusOnUnmount",hu={bubbles:!1,cancelable:!0},Rv="FocusScope",Fo=m.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,l]=m.useState(null),u=mt(o),d=mt(s),f=m.useRef(null),h=Fe(t,v=>l(v)),p=m.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;m.useEffect(()=>{if(r){let v=function(y){if(p.paused||!a)return;const E=y.target;a.contains(E)?f.current=E:Tn(f.current,{select:!0})},g=function(y){if(p.paused||!a)return;const E=y.relatedTarget;E!==null&&(a.contains(E)||Tn(f.current,{select:!0}))},x=function(y){if(document.activeElement===document.body)for(const C of y)C.removedNodes.length>0&&Tn(a)};document.addEventListener("focusin",v),document.addEventListener("focusout",g);const b=new MutationObserver(x);return a&&b.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",v),document.removeEventListener("focusout",g),b.disconnect()}}},[r,a,p.paused]),m.useEffect(()=>{if(a){gu.add(p);const v=document.activeElement;if(!a.contains(v)){const x=new CustomEvent(Pi,hu);a.addEventListener(Pi,u),a.dispatchEvent(x),x.defaultPrevented||(Pv(Fv(pu(a)),{select:!0}),document.activeElement===v&&Tn(a))}return()=>{a.removeEventListener(Pi,u),setTimeout(()=>{const x=new CustomEvent(Oi,hu);a.addEventListener(Oi,d),a.dispatchEvent(x),x.defaultPrevented||Tn(v??document.body,{select:!0}),a.removeEventListener(Oi,d),gu.remove(p)},0)}}},[a,u,d,p]);const w=m.useCallback(v=>{if(!n&&!r||p.paused)return;const g=v.key==="Tab"&&!v.altKey&&!v.ctrlKey&&!v.metaKey,x=document.activeElement;if(g&&x){const b=v.currentTarget,[y,E]=Ov(b);y&&E?!v.shiftKey&&x===E?(v.preventDefault(),n&&Tn(y,{select:!0})):v.shiftKey&&x===y&&(v.preventDefault(),n&&Tn(E,{select:!0})):x===b&&v.preventDefault()}},[n,r,p.paused]);return c.jsx(ye.div,{tabIndex:-1,...i,ref:h,onKeyDown:w})});Fo.displayName=Rv;function Pv(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Tn(r,{select:t}),document.activeElement!==n)return}function Ov(e){const t=pu(e),n=mu(t,e),r=mu(t.reverse(),e);return[n,r]}function pu(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function mu(e,t){for(const n of e)if(!Mv(n,{upTo:t}))return n}function Mv(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function Dv(e){return e instanceof HTMLInputElement&&"select"in e}function Tn(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Dv(e)&&t&&e.select()}}var gu=Lv();function Lv(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=xu(e,t),e.unshift(t)},remove(t){var n;e=xu(e,t),(n=e[0])==null||n.resume()}}}function xu(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Fv(e){return e.filter(t=>t.tagName!=="A")}var $v="Portal",$o=m.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=m.useState(!1);pt(()=>s(!0),[]);const i=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?_s.createPortal(c.jsx(ye.div,{...r,ref:t}),i):null});$o.displayName=$v;var Mi=0;function Di(){m.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??vu()),document.body.insertAdjacentElement("beforeend",e[1]??vu()),Mi++,()=>{Mi===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Mi--}},[])}function vu(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var nn=function(){return nn=Object.assign||function(t){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])}return t},nn.apply(this,arguments)};function wu(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n}function zv(e,t,n){if(n||arguments.length===2)for(var r=0,o=t.length,s;r<o;r++)(s||!(r in t))&&(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return e.concat(s||Array.prototype.slice.call(t))}typeof SuppressedError=="function"&&SuppressedError;var zo="right-scroll-bar-position",Bo="width-before-scroll-bar",Bv="with-scroll-bars-hidden",Hv="--removed-body-scroll-bar-size";function Li(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function Uv(e,t){var n=S.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var o=n.value;o!==r&&(n.value=r,n.callback(r,o))}}}})[0];return n.callback=t,n.facade}var Wv=typeof window<"u"?m.useLayoutEffect:m.useEffect,bu=new WeakMap;function Vv(e,t){var n=Uv(null,function(r){return e.forEach(function(o){return Li(o,r)})});return Wv(function(){var r=bu.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||Li(a,null)}),s.forEach(function(a){o.has(a)||Li(a,i)})}bu.set(n,e)},[e]),n}function Kv(e){return e}function qv(e,t){t===void 0&&(t=Kv);var n=[],r=!1,o={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(s){var i=t(s,r);return n.push(i),function(){n=n.filter(function(a){return a!==i})}},assignSyncMedium:function(s){for(r=!0;n.length;){var i=n;n=[],i.forEach(s)}n={push:function(a){return s(a)},filter:function(){return n}}},assignMedium:function(s){r=!0;var i=[];if(n.length){var a=n;n=[],a.forEach(s),i=n}var l=function(){var d=i;i=[],d.forEach(s)},u=function(){return Promise.resolve().then(l)};u(),n={push:function(d){i.push(d),u()},filter:function(d){return i=i.filter(d),n}}}};return o}function Gv(e){e===void 0&&(e={});var t=qv(null);return t.options=nn({async:!0,ssr:!1},e),t}var yu=function(e){var t=e.sideCar,n=wu(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return m.createElement(r,nn({},n))};yu.isSideCarExport=!0;function Yv(e,t){return e.useMedium(t),yu}var Su=Gv(),Fi=function(){},Ho=m.forwardRef(function(e,t){var n=m.useRef(null),r=m.useState({onScrollCapture:Fi,onWheelCapture:Fi,onTouchMoveCapture:Fi}),o=r[0],s=r[1],i=e.forwardProps,a=e.children,l=e.className,u=e.removeScrollBar,d=e.enabled,f=e.shards,h=e.sideCar,p=e.noRelative,w=e.noIsolation,v=e.inert,g=e.allowPinchZoom,x=e.as,b=x===void 0?"div":x,y=e.gapMode,E=wu(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=h,T=Vv([n,t]),I=nn(nn({},E),o);return m.createElement(m.Fragment,null,d&&m.createElement(C,{sideCar:Su,removeScrollBar:u,shards:f,noRelative:p,noIsolation:w,inert:v,setCallbacks:s,allowPinchZoom:!!g,lockRef:n,gapMode:y}),i?m.cloneElement(m.Children.only(a),nn(nn({},I),{ref:T})):m.createElement(b,nn({},I,{className:l,ref:T}),a))});Ho.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},Ho.classNames={fullWidth:Bo,zeroRight:zo};var Xv=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Jv(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Xv();return t&&e.setAttribute("nonce",t),e}function Zv(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Qv(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var ew=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Jv())&&(Zv(t,n),Qv(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},tw=function(){var e=ew();return function(t,n){m.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Cu=function(){var e=tw(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},nw={left:0,top:0,right:0,gap:0},$i=function(e){return parseInt(e||"",10)||0},rw=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],o=t[e==="padding"?"paddingRight":"marginRight"];return[$i(n),$i(r),$i(o)]},ow=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return nw;var t=rw(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},sw=Cu(),sr="data-scroll-locked",iw=function(e,t,n,r){var o=e.left,s=e.top,i=e.right,a=e.gap;return n===void 0&&(n="margin"),`
83
+ Please report this to https://github.com/markedjs/marked.`,e){const o="<p>An error occurred:</p><pre>"+wt(r.message+"",!0)+"</pre>";if(t)return Promise.resolve(o);if(n){n(null,o);return}return o}if(t)return Promise.reject(r);if(n){n(r);return}throw r}}function su(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...he.defaults,...s};const i=gv(r.silent,r.async,o);if(typeof n>"u"||n===null)return i(new Error("marked(): input parameter is undefined or null"));if(typeof n!="string")return i(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(n)+", string expected"));if(hv(r),r.hooks&&(r.hooks.options=r),o){const a=r.highlight;let l;try{r.hooks&&(n=r.hooks.preprocess(n)),l=e(n,r)}catch(f){return i(f)}const u=function(f){let h;if(!f)try{r.walkTokens&&he.walkTokens(l,r.walkTokens),h=t(l,r),r.hooks&&(h=r.hooks.postprocess(h))}catch(p){f=p}return r.highlight=a,f?i(f):o(null,h)};if(!a||a.length<3||(delete r.highlight,!l.length))return u();let d=0;he.walkTokens(l,function(f){f.type==="code"&&(d++,setTimeout(()=>{a(f.text,f.lang,function(h,p){if(h)return u(h);p!=null&&p!==f.text&&(f.text=p,f.escaped=!0),d--,d===0&&u()})},0))}),d===0&&u();return}if(r.async)return Promise.resolve(r.hooks?r.hooks.preprocess(n):n).then(a=>e(a,r)).then(a=>r.walkTokens?Promise.all(he.walkTokens(a,r.walkTokens)).then(()=>a):a).then(a=>t(a,r)).then(a=>r.hooks?r.hooks.postprocess(a):a).catch(i);try{r.hooks&&(n=r.hooks.preprocess(n));const a=e(n,r);r.walkTokens&&he.walkTokens(a,r.walkTokens);let l=t(a,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(a){return i(a)}}}function he(e,t,n){return su(Sn.lex,Cn.parse)(e,t,n)}he.options=he.setOptions=function(e){return he.defaults={...he.defaults,...e},ev(he.defaults),he},he.getDefaults=qc,he.defaults=zn,he.use=function(...e){const t=he.defaults.extensions||{renderers:{},childTokens:{}};e.forEach(n=>{const r={...n};if(r.async=he.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(o=>{if(!o.name)throw new Error("extension name required");if(o.renderer){const s=t.renderers[o.name];s?t.renderers[o.name]=function(...i){let a=o.renderer.apply(this,i);return a===!1&&(a=s.apply(this,i)),a}:t.renderers[o.name]=o.renderer}if(o.tokenizer){if(!o.level||o.level!=="block"&&o.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");t[o.level]?t[o.level].unshift(o.tokenizer):t[o.level]=[o.tokenizer],o.start&&(o.level==="block"?t.startBlock?t.startBlock.push(o.start):t.startBlock=[o.start]:o.level==="inline"&&(t.startInline?t.startInline.push(o.start):t.startInline=[o.start]))}o.childTokens&&(t.childTokens[o.name]=o.childTokens)}),r.extensions=t),n.renderer){const o=he.defaults.renderer||new Ii;for(const s in n.renderer){const i=o[s];o[s]=(...a)=>{let l=n.renderer[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.renderer=o}if(n.tokenizer){const o=he.defaults.tokenizer||new ki;for(const s in n.tokenizer){const i=o[s];o[s]=(...a)=>{let l=n.tokenizer[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.tokenizer=o}if(n.hooks){const o=he.defaults.hooks||new Oo;for(const s in n.hooks){const i=o[s];Oo.passThroughHooks.has(s)?o[s]=a=>{if(he.defaults.async)return Promise.resolve(n.hooks[s].call(o,a)).then(u=>i.call(o,u));const l=n.hooks[s].call(o,a);return i.call(o,l)}:o[s]=(...a)=>{let l=n.hooks[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.hooks=o}if(n.walkTokens){const o=he.defaults.walkTokens;r.walkTokens=function(s){let i=[];return i.push(n.walkTokens.call(this,s)),o&&(i=i.concat(o.call(this,s))),i}}he.setOptions(r)})},he.walkTokens=function(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(he,r)),r.type){case"table":{for(const o of r.header)n=n.concat(he.walkTokens(o.tokens,t));for(const o of r.rows)for(const s of o)n=n.concat(he.walkTokens(s.tokens,t));break}case"list":{n=n.concat(he.walkTokens(r.items,t));break}default:he.defaults.extensions&&he.defaults.extensions.childTokens&&he.defaults.extensions.childTokens[r.type]?he.defaults.extensions.childTokens[r.type].forEach(function(o){n=n.concat(he.walkTokens(r[o],t))}):r.tokens&&(n=n.concat(he.walkTokens(r.tokens,t)))}return n},he.parseInline=su(Sn.lexInline,Cn.parseInline),he.Parser=Cn,he.parser=Cn.parse,he.Renderer=Ii,he.TextRenderer=ru,he.Lexer=Sn,he.lexer=Sn.lex,he.Tokenizer=ki,he.Slugger=ou,he.Hooks=Oo,he.parse=he,he.options,he.setOptions,he.use,he.walkTokens,he.parseInline,Cn.parse,Sn.lex;function Ni({content:e,className:t="",allowHtml:n=!1}){const r=S.useMemo(()=>{try{if(!n){const o=e.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"").replace(/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi,"").replace(/javascript:/gi,"").replace(/on\w+\s*=/gi,"");return he.parse(o)}return he.parse(e)}catch(o){return console.error("[MarkdownContent] parse error",o),`<pre>Error rendering markdown: ${String(o)}</pre>`}},[e,n]);return c.jsx("div",{className:X("markdown prose max-w-none break-words dark:prose-invert",t),dangerouslySetInnerHTML:{__html:r}})}async function iu(e,t){return await It(e,{responseType:"blob",onDownloadProgress:r=>{try{t&&r.lengthComputable}catch{}},maxBodyLength:1/0})}async function au(e,t){return await(await iu(`/files/${e}/view`,t)).text()}async function xv(e,t){const n=await iu(`/files/${e}/download`,t),r=URL.createObjectURL(n);let o=`file_${e}`;try{const i=await It(`/files/${e}`);o=(i==null?void 0:i.filename)??o}catch{}const s=document.createElement("a");s.href=r,s.download=o,document.body.appendChild(s),s.click(),s.remove(),setTimeout(()=>URL.revokeObjectURL(r),6e4)}async function vv(e,t=50,n=0){const r={limit:t,offset:n};return e&&(r.thread_id=e),await It("/files",{params:r})}const wv=1,bv=1e6;let Ai=0;function yv(){return Ai=(Ai+1)%Number.MAX_SAFE_INTEGER,Ai.toString()}const ji=new Map,lu=e=>{if(ji.has(e))return;const t=setTimeout(()=>{ji.delete(e),$r({type:"REMOVE_TOAST",toastId:e})},bv);ji.set(e,t)},Sv=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,wv)};case"UPDATE_TOAST":return{...e,toasts:e.toasts.map(n=>n.id===t.toast.id?{...n,...t.toast}:n)};case"DISMISS_TOAST":{const{toastId:n}=t;return n?lu(n):e.toasts.forEach(r=>{lu(r.id)}),{...e,toasts:e.toasts.map(r=>r.id===n||n===void 0?{...r,open:!1}:r)}}case"REMOVE_TOAST":return t.toastId===void 0?{...e,toasts:[]}:{...e,toasts:e.toasts.filter(n=>n.id!==t.toastId)}}},Mo=[];let Do={toasts:[]};function $r(e){Do=Sv(Do,e),Mo.forEach(t=>{t(Do)})}function Cv({...e}){const t=yv(),n=o=>$r({type:"UPDATE_TOAST",toast:{...o,id:t}}),r=()=>$r({type:"DISMISS_TOAST",toastId:t});return $r({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:o=>{o||r()}}}),{id:t,dismiss:r,update:n}}function _i(){const[e,t]=m.useState(Do);return m.useEffect(()=>(Mo.push(t),()=>{const n=Mo.indexOf(t);n>-1&&Mo.splice(n,1)}),[e]),{...e,toast:Cv,dismiss:n=>$r({type:"DISMISS_TOAST",toastId:n})}}function mt(e){const t=m.useRef(e);return m.useEffect(()=>{t.current=e}),m.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function Tv(e,t=globalThis==null?void 0:globalThis.document){const n=mt(e);m.useEffect(()=>{const r=o=>{o.key==="Escape"&&n(o)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var Ev="DismissableLayer",Ri="dismissableLayer.update",kv="dismissableLayer.pointerDownOutside",Iv="dismissableLayer.focusOutside",cu,uu=m.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Lo=m.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...l}=e,u=m.useContext(uu),[d,f]=m.useState(null),h=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,p]=m.useState({}),w=Fe(t,I=>f(I)),v=Array.from(u.layers),[g]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),x=v.indexOf(g),b=d?v.indexOf(d):-1,y=u.layersWithOutsidePointerEventsDisabled.size>0,k=b>=x,C=jv(I=>{const A=I.target,R=[...u.branches].some(j=>j.contains(A));!k||R||(o==null||o(I),i==null||i(I),I.defaultPrevented||a==null||a())},h),T=_v(I=>{const A=I.target;[...u.branches].some(j=>j.contains(A))||(s==null||s(I),i==null||i(I),I.defaultPrevented||a==null||a())},h);return Tv(I=>{b===u.layers.size-1&&(r==null||r(I),!I.defaultPrevented&&a&&(I.preventDefault(),a()))},h),m.useEffect(()=>{if(d)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(cu=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),du(),()=>{n&&u.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=cu)}},[d,h,n,u]),m.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),du())},[d,u]),m.useEffect(()=>{const I=()=>p({});return document.addEventListener(Ri,I),()=>document.removeEventListener(Ri,I)},[]),c.jsx(ye.div,{...l,ref:w,style:{pointerEvents:y?k?"auto":"none":void 0,...e.style},onFocusCapture:oe(e.onFocusCapture,T.onFocusCapture),onBlurCapture:oe(e.onBlurCapture,T.onBlurCapture),onPointerDownCapture:oe(e.onPointerDownCapture,C.onPointerDownCapture)})});Lo.displayName=Ev;var Nv="DismissableLayerBranch",Av=m.forwardRef((e,t)=>{const n=m.useContext(uu),r=m.useRef(null),o=Fe(t,r);return m.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),c.jsx(ye.div,{...e,ref:o})});Av.displayName=Nv;function jv(e,t=globalThis==null?void 0:globalThis.document){const n=mt(e),r=m.useRef(!1),o=m.useRef(()=>{});return m.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){fu(kv,n,u,{discrete:!0})};const u={originalEvent:a};a.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=l,t.addEventListener("click",o.current,{once:!0})):l()}else t.removeEventListener("click",o.current);r.current=!1},i=window.setTimeout(()=>{t.addEventListener("pointerdown",s)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",s),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function _v(e,t=globalThis==null?void 0:globalThis.document){const n=mt(e),r=m.useRef(!1);return m.useEffect(()=>{const o=s=>{s.target&&!r.current&&fu(Iv,n,{originalEvent:s},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function du(){const e=new CustomEvent(Ri);document.dispatchEvent(e)}function fu(e,t,n,{discrete:r}){const o=n.originalEvent.target,s=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?$c(o,s):o.dispatchEvent(s)}var Pi="focusScope.autoFocusOnMount",Oi="focusScope.autoFocusOnUnmount",hu={bubbles:!1,cancelable:!0},Rv="FocusScope",Fo=m.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,l]=m.useState(null),u=mt(o),d=mt(s),f=m.useRef(null),h=Fe(t,v=>l(v)),p=m.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;m.useEffect(()=>{if(r){let v=function(y){if(p.paused||!a)return;const k=y.target;a.contains(k)?f.current=k:Tn(f.current,{select:!0})},g=function(y){if(p.paused||!a)return;const k=y.relatedTarget;k!==null&&(a.contains(k)||Tn(f.current,{select:!0}))},x=function(y){if(document.activeElement===document.body)for(const C of y)C.removedNodes.length>0&&Tn(a)};document.addEventListener("focusin",v),document.addEventListener("focusout",g);const b=new MutationObserver(x);return a&&b.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",v),document.removeEventListener("focusout",g),b.disconnect()}}},[r,a,p.paused]),m.useEffect(()=>{if(a){gu.add(p);const v=document.activeElement;if(!a.contains(v)){const x=new CustomEvent(Pi,hu);a.addEventListener(Pi,u),a.dispatchEvent(x),x.defaultPrevented||(Pv(Fv(pu(a)),{select:!0}),document.activeElement===v&&Tn(a))}return()=>{a.removeEventListener(Pi,u),setTimeout(()=>{const x=new CustomEvent(Oi,hu);a.addEventListener(Oi,d),a.dispatchEvent(x),x.defaultPrevented||Tn(v??document.body,{select:!0}),a.removeEventListener(Oi,d),gu.remove(p)},0)}}},[a,u,d,p]);const w=m.useCallback(v=>{if(!n&&!r||p.paused)return;const g=v.key==="Tab"&&!v.altKey&&!v.ctrlKey&&!v.metaKey,x=document.activeElement;if(g&&x){const b=v.currentTarget,[y,k]=Ov(b);y&&k?!v.shiftKey&&x===k?(v.preventDefault(),n&&Tn(y,{select:!0})):v.shiftKey&&x===y&&(v.preventDefault(),n&&Tn(k,{select:!0})):x===b&&v.preventDefault()}},[n,r,p.paused]);return c.jsx(ye.div,{tabIndex:-1,...i,ref:h,onKeyDown:w})});Fo.displayName=Rv;function Pv(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Tn(r,{select:t}),document.activeElement!==n)return}function Ov(e){const t=pu(e),n=mu(t,e),r=mu(t.reverse(),e);return[n,r]}function pu(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function mu(e,t){for(const n of e)if(!Mv(n,{upTo:t}))return n}function Mv(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function Dv(e){return e instanceof HTMLInputElement&&"select"in e}function Tn(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Dv(e)&&t&&e.select()}}var gu=Lv();function Lv(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=xu(e,t),e.unshift(t)},remove(t){var n;e=xu(e,t),(n=e[0])==null||n.resume()}}}function xu(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Fv(e){return e.filter(t=>t.tagName!=="A")}var $v="Portal",$o=m.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=m.useState(!1);pt(()=>s(!0),[]);const i=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?_s.createPortal(c.jsx(ye.div,{...r,ref:t}),i):null});$o.displayName=$v;var Mi=0;function Di(){m.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??vu()),document.body.insertAdjacentElement("beforeend",e[1]??vu()),Mi++,()=>{Mi===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Mi--}},[])}function vu(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var nn=function(){return nn=Object.assign||function(t){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])}return t},nn.apply(this,arguments)};function wu(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n}function zv(e,t,n){if(n||arguments.length===2)for(var r=0,o=t.length,s;r<o;r++)(s||!(r in t))&&(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return e.concat(s||Array.prototype.slice.call(t))}typeof SuppressedError=="function"&&SuppressedError;var zo="right-scroll-bar-position",Bo="width-before-scroll-bar",Bv="with-scroll-bars-hidden",Hv="--removed-body-scroll-bar-size";function Li(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function Uv(e,t){var n=S.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var o=n.value;o!==r&&(n.value=r,n.callback(r,o))}}}})[0];return n.callback=t,n.facade}var Wv=typeof window<"u"?m.useLayoutEffect:m.useEffect,bu=new WeakMap;function Vv(e,t){var n=Uv(null,function(r){return e.forEach(function(o){return Li(o,r)})});return Wv(function(){var r=bu.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||Li(a,null)}),s.forEach(function(a){o.has(a)||Li(a,i)})}bu.set(n,e)},[e]),n}function Kv(e){return e}function qv(e,t){t===void 0&&(t=Kv);var n=[],r=!1,o={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(s){var i=t(s,r);return n.push(i),function(){n=n.filter(function(a){return a!==i})}},assignSyncMedium:function(s){for(r=!0;n.length;){var i=n;n=[],i.forEach(s)}n={push:function(a){return s(a)},filter:function(){return n}}},assignMedium:function(s){r=!0;var i=[];if(n.length){var a=n;n=[],a.forEach(s),i=n}var l=function(){var d=i;i=[],d.forEach(s)},u=function(){return Promise.resolve().then(l)};u(),n={push:function(d){i.push(d),u()},filter:function(d){return i=i.filter(d),n}}}};return o}function Gv(e){e===void 0&&(e={});var t=qv(null);return t.options=nn({async:!0,ssr:!1},e),t}var yu=function(e){var t=e.sideCar,n=wu(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return m.createElement(r,nn({},n))};yu.isSideCarExport=!0;function Yv(e,t){return e.useMedium(t),yu}var Su=Gv(),Fi=function(){},Ho=m.forwardRef(function(e,t){var n=m.useRef(null),r=m.useState({onScrollCapture:Fi,onWheelCapture:Fi,onTouchMoveCapture:Fi}),o=r[0],s=r[1],i=e.forwardProps,a=e.children,l=e.className,u=e.removeScrollBar,d=e.enabled,f=e.shards,h=e.sideCar,p=e.noRelative,w=e.noIsolation,v=e.inert,g=e.allowPinchZoom,x=e.as,b=x===void 0?"div":x,y=e.gapMode,k=wu(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=h,T=Vv([n,t]),I=nn(nn({},k),o);return m.createElement(m.Fragment,null,d&&m.createElement(C,{sideCar:Su,removeScrollBar:u,shards:f,noRelative:p,noIsolation:w,inert:v,setCallbacks:s,allowPinchZoom:!!g,lockRef:n,gapMode:y}),i?m.cloneElement(m.Children.only(a),nn(nn({},I),{ref:T})):m.createElement(b,nn({},I,{className:l,ref:T}),a))});Ho.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},Ho.classNames={fullWidth:Bo,zeroRight:zo};var Xv=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Jv(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Xv();return t&&e.setAttribute("nonce",t),e}function Zv(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Qv(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var ew=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Jv())&&(Zv(t,n),Qv(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},tw=function(){var e=ew();return function(t,n){m.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Cu=function(){var e=tw(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},nw={left:0,top:0,right:0,gap:0},$i=function(e){return parseInt(e||"",10)||0},rw=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],o=t[e==="padding"?"paddingRight":"marginRight"];return[$i(n),$i(r),$i(o)]},ow=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return nw;var t=rw(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},sw=Cu(),sr="data-scroll-locked",iw=function(e,t,n,r){var o=e.left,s=e.top,i=e.right,a=e.gap;return n===void 0&&(n="margin"),`
84
84
  .`.concat(Bv,` {
85
85
  overflow: hidden `).concat(r,`;
86
86
  padding-right: `).concat(a,"px ").concat(r,`;
@@ -117,18 +117,18 @@ Please report this to https://github.com/markedjs/marked.`,e){const o="<p>An err
117
117
  body[`).concat(sr,`] {
118
118
  `).concat(Hv,": ").concat(a,`px;
119
119
  }
120
- `)},Tu=function(){var e=parseInt(document.body.getAttribute(sr)||"0",10);return isFinite(e)?e:0},aw=function(){m.useEffect(function(){return document.body.setAttribute(sr,(Tu()+1).toString()),function(){var e=Tu()-1;e<=0?document.body.removeAttribute(sr):document.body.setAttribute(sr,e.toString())}},[])},lw=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;aw();var s=m.useMemo(function(){return ow(o)},[o]);return m.createElement(sw,{styles:iw(s,!t,o,n?"":"!important")})},zi=!1;if(typeof window<"u")try{var Uo=Object.defineProperty({},"passive",{get:function(){return zi=!0,!0}});window.addEventListener("test",Uo,Uo),window.removeEventListener("test",Uo,Uo)}catch{zi=!1}var ir=zi?{passive:!1}:!1,cw=function(e){return e.tagName==="TEXTAREA"},ku=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!cw(e)&&n[t]==="visible")},uw=function(e){return ku(e,"overflowY")},dw=function(e){return ku(e,"overflowX")},Eu=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=Iu(e,r);if(o){var s=Nu(e,r),i=s[1],a=s[2];if(i>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},fw=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},hw=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},Iu=function(e,t){return e==="v"?uw(t):dw(t)},Nu=function(e,t){return e==="v"?fw(t):hw(t)},pw=function(e,t){return e==="h"&&t==="rtl"?-1:1},mw=function(e,t,n,r,o){var s=pw(e,window.getComputedStyle(t).direction),i=s*r,a=n.target,l=t.contains(a),u=!1,d=i>0,f=0,h=0;do{if(!a)break;var p=Nu(e,a),w=p[0],v=p[1],g=p[2],x=v-g-s*w;(w||x)&&Iu(e,a)&&(f+=x,h+=w);var b=a.parentNode;a=b&&b.nodeType===Node.DOCUMENT_FRAGMENT_NODE?b.host:b}while(!l&&a!==document.body||l&&(t.contains(a)||t===a));return(d&&Math.abs(f)<1||!d&&Math.abs(h)<1)&&(u=!0),u},Wo=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Au=function(e){return[e.deltaX,e.deltaY]},ju=function(e){return e&&"current"in e?e.current:e},gw=function(e,t){return e[0]===t[0]&&e[1]===t[1]},xw=function(e){return`
120
+ `)},Tu=function(){var e=parseInt(document.body.getAttribute(sr)||"0",10);return isFinite(e)?e:0},aw=function(){m.useEffect(function(){return document.body.setAttribute(sr,(Tu()+1).toString()),function(){var e=Tu()-1;e<=0?document.body.removeAttribute(sr):document.body.setAttribute(sr,e.toString())}},[])},lw=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;aw();var s=m.useMemo(function(){return ow(o)},[o]);return m.createElement(sw,{styles:iw(s,!t,o,n?"":"!important")})},zi=!1;if(typeof window<"u")try{var Uo=Object.defineProperty({},"passive",{get:function(){return zi=!0,!0}});window.addEventListener("test",Uo,Uo),window.removeEventListener("test",Uo,Uo)}catch{zi=!1}var ir=zi?{passive:!1}:!1,cw=function(e){return e.tagName==="TEXTAREA"},Eu=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!cw(e)&&n[t]==="visible")},uw=function(e){return Eu(e,"overflowY")},dw=function(e){return Eu(e,"overflowX")},ku=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=Iu(e,r);if(o){var s=Nu(e,r),i=s[1],a=s[2];if(i>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},fw=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},hw=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},Iu=function(e,t){return e==="v"?uw(t):dw(t)},Nu=function(e,t){return e==="v"?fw(t):hw(t)},pw=function(e,t){return e==="h"&&t==="rtl"?-1:1},mw=function(e,t,n,r,o){var s=pw(e,window.getComputedStyle(t).direction),i=s*r,a=n.target,l=t.contains(a),u=!1,d=i>0,f=0,h=0;do{if(!a)break;var p=Nu(e,a),w=p[0],v=p[1],g=p[2],x=v-g-s*w;(w||x)&&Iu(e,a)&&(f+=x,h+=w);var b=a.parentNode;a=b&&b.nodeType===Node.DOCUMENT_FRAGMENT_NODE?b.host:b}while(!l&&a!==document.body||l&&(t.contains(a)||t===a));return(d&&Math.abs(f)<1||!d&&Math.abs(h)<1)&&(u=!0),u},Wo=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Au=function(e){return[e.deltaX,e.deltaY]},ju=function(e){return e&&"current"in e?e.current:e},gw=function(e,t){return e[0]===t[0]&&e[1]===t[1]},xw=function(e){return`
121
121
  .block-interactivity-`.concat(e,` {pointer-events: none;}
122
122
  .allow-interactivity-`).concat(e,` {pointer-events: all;}
123
- `)},vw=0,ar=[];function ww(e){var t=m.useRef([]),n=m.useRef([0,0]),r=m.useRef(),o=m.useState(vw++)[0],s=m.useState(Cu)[0],i=m.useRef(e);m.useEffect(function(){i.current=e},[e]),m.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var v=zv([e.lockRef.current],(e.shards||[]).map(ju),!0).filter(Boolean);return v.forEach(function(g){return g.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),v.forEach(function(g){return g.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var a=m.useCallback(function(v,g){if("touches"in v&&v.touches.length===2||v.type==="wheel"&&v.ctrlKey)return!i.current.allowPinchZoom;var x=Wo(v),b=n.current,y="deltaX"in v?v.deltaX:b[0]-x[0],E="deltaY"in v?v.deltaY:b[1]-x[1],C,T=v.target,I=Math.abs(y)>Math.abs(E)?"h":"v";if("touches"in v&&I==="h"&&T.type==="range")return!1;var A=Eu(I,T);if(!A)return!0;if(A?C=I:(C=I==="v"?"h":"v",A=Eu(I,T)),!A)return!1;if(!r.current&&"changedTouches"in v&&(y||E)&&(r.current=C),!C)return!0;var R=r.current||C;return mw(R,g,v,R==="h"?y:E)},[]),l=m.useCallback(function(v){var g=v;if(!(!ar.length||ar[ar.length-1]!==s)){var x="deltaY"in g?Au(g):Wo(g),b=t.current.filter(function(C){return C.name===g.type&&(C.target===g.target||g.target===C.shadowParent)&&gw(C.delta,x)})[0];if(b&&b.should){g.cancelable&&g.preventDefault();return}if(!b){var y=(i.current.shards||[]).map(ju).filter(Boolean).filter(function(C){return C.contains(g.target)}),E=y.length>0?a(g,y[0]):!i.current.noIsolation;E&&g.cancelable&&g.preventDefault()}}},[]),u=m.useCallback(function(v,g,x,b){var y={name:v,delta:g,target:x,should:b,shadowParent:bw(x)};t.current.push(y),setTimeout(function(){t.current=t.current.filter(function(E){return E!==y})},1)},[]),d=m.useCallback(function(v){n.current=Wo(v),r.current=void 0},[]),f=m.useCallback(function(v){u(v.type,Au(v),v.target,a(v,e.lockRef.current))},[]),h=m.useCallback(function(v){u(v.type,Wo(v),v.target,a(v,e.lockRef.current))},[]);m.useEffect(function(){return ar.push(s),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:h}),document.addEventListener("wheel",l,ir),document.addEventListener("touchmove",l,ir),document.addEventListener("touchstart",d,ir),function(){ar=ar.filter(function(v){return v!==s}),document.removeEventListener("wheel",l,ir),document.removeEventListener("touchmove",l,ir),document.removeEventListener("touchstart",d,ir)}},[]);var p=e.removeScrollBar,w=e.inert;return m.createElement(m.Fragment,null,w?m.createElement(s,{styles:xw(o)}):null,p?m.createElement(lw,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function bw(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const yw=Yv(Su,ww);var Vo=m.forwardRef(function(e,t){return m.createElement(Ho,nn({},e,{ref:t,sideCar:yw}))});Vo.classNames=Ho.classNames;var Sw=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},lr=new WeakMap,Ko=new WeakMap,qo={},Bi=0,_u=function(e){return e&&(e.host||_u(e.parentNode))},Cw=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=_u(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},Tw=function(e,t,n,r){var o=Cw(t,Array.isArray(e)?e:[e]);qo[n]||(qo[n]=new WeakMap);var s=qo[n],i=[],a=new Set,l=new Set(o),u=function(f){!f||a.has(f)||(a.add(f),u(f.parentNode))};o.forEach(u);var d=function(f){!f||l.has(f)||Array.prototype.forEach.call(f.children,function(h){if(a.has(h))d(h);else try{var p=h.getAttribute(r),w=p!==null&&p!=="false",v=(lr.get(h)||0)+1,g=(s.get(h)||0)+1;lr.set(h,v),s.set(h,g),i.push(h),v===1&&w&&Ko.set(h,!0),g===1&&h.setAttribute(n,"true"),w||h.setAttribute(r,"true")}catch(x){console.error("aria-hidden: cannot operate on ",h,x)}})};return d(t),a.clear(),Bi++,function(){i.forEach(function(f){var h=lr.get(f)-1,p=s.get(f)-1;lr.set(f,h),s.set(f,p),h||(Ko.has(f)||f.removeAttribute(r),Ko.delete(f)),p||f.removeAttribute(n)}),Bi--,Bi||(lr=new WeakMap,lr=new WeakMap,Ko=new WeakMap,qo={})}},Hi=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=Sw(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),Tw(r,o,n,"aria-hidden")):function(){return null}},Go="Dialog",[Ru,MC]=en(Go),[kw,Kt]=Ru(Go),Pu=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]=$n({prop:r,defaultProp:o??!1,onChange:s,caller:Go});return c.jsx(kw,{scope:t,triggerRef:a,contentRef:l,contentId:tn(),titleId:tn(),descriptionId:tn(),open:u,onOpenChange:d,onOpenToggle:m.useCallback(()=>d(f=>!f),[d]),modal:i,children:n})};Pu.displayName=Go;var Ou="DialogTrigger",Mu=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Kt(Ou,n),s=Fe(t,o.triggerRef);return c.jsx(ye.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Vi(o.open),...r,ref:s,onClick:oe(e.onClick,o.onOpenToggle)})});Mu.displayName=Ou;var Ui="DialogPortal",[Ew,Du]=Ru(Ui,{forceMount:void 0}),Lu=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=Kt(Ui,t);return c.jsx(Ew,{scope:t,forceMount:n,children:m.Children.map(r,i=>c.jsx(_t,{present:n||s.open,children:c.jsx($o,{asChild:!0,container:o,children:i})}))})};Lu.displayName=Ui;var Yo="DialogOverlay",Fu=m.forwardRef((e,t)=>{const n=Du(Yo,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=Kt(Yo,e.__scopeDialog);return s.modal?c.jsx(_t,{present:r||s.open,children:c.jsx(Nw,{...o,ref:t})}):null});Fu.displayName=Yo;var Iw=_n.createSlot("DialogOverlay.RemoveScroll"),Nw=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Kt(Yo,n);return c.jsx(Vo,{as:Iw,allowPinchZoom:!0,shards:[o.contentRef],children:c.jsx(ye.div,{"data-state":Vi(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),Bn="DialogContent",$u=m.forwardRef((e,t)=>{const n=Du(Bn,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=Kt(Bn,e.__scopeDialog);return c.jsx(_t,{present:r||s.open,children:s.modal?c.jsx(Aw,{...o,ref:t}):c.jsx(jw,{...o,ref:t})})});$u.displayName=Bn;var Aw=m.forwardRef((e,t)=>{const n=Kt(Bn,e.__scopeDialog),r=m.useRef(null),o=Fe(t,n.contentRef,r);return m.useEffect(()=>{const s=r.current;if(s)return Hi(s)},[]),c.jsx(zu,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:oe(e.onCloseAutoFocus,s=>{var i;s.preventDefault(),(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:oe(e.onPointerDownOutside,s=>{const i=s.detail.originalEvent,a=i.button===0&&i.ctrlKey===!0;(i.button===2||a)&&s.preventDefault()}),onFocusOutside:oe(e.onFocusOutside,s=>s.preventDefault())})}),jw=m.forwardRef((e,t)=>{const n=Kt(Bn,e.__scopeDialog),r=m.useRef(!1),o=m.useRef(!1);return c.jsx(zu,{...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()}})}),zu=m.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=Kt(Bn,n),l=m.useRef(null),u=Fe(t,l);return Di(),c.jsxs(c.Fragment,{children:[c.jsx(Fo,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:c.jsx(Lo,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":Vi(a.open),...i,ref:u,onDismiss:()=>a.onOpenChange(!1)})}),c.jsxs(c.Fragment,{children:[c.jsx(_w,{titleId:a.titleId}),c.jsx(Pw,{contentRef:l,descriptionId:a.descriptionId})]})]})}),Wi="DialogTitle",Bu=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Kt(Wi,n);return c.jsx(ye.h2,{id:o.titleId,...r,ref:t})});Bu.displayName=Wi;var Hu="DialogDescription",Uu=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Kt(Hu,n);return c.jsx(ye.p,{id:o.descriptionId,...r,ref:t})});Uu.displayName=Hu;var Wu="DialogClose",Vu=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Kt(Wu,n);return c.jsx(ye.button,{type:"button",...r,ref:t,onClick:oe(e.onClick,()=>o.onOpenChange(!1))})});Vu.displayName=Wu;function Vi(e){return e?"open":"closed"}var Ku="DialogTitleWarning",[DC,qu]=Fx(Ku,{contentName:Bn,titleName:Wi,docsSlug:"dialog"}),_w=({titleId:e})=>{const t=qu(Ku),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
123
+ `)},vw=0,ar=[];function ww(e){var t=m.useRef([]),n=m.useRef([0,0]),r=m.useRef(),o=m.useState(vw++)[0],s=m.useState(Cu)[0],i=m.useRef(e);m.useEffect(function(){i.current=e},[e]),m.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var v=zv([e.lockRef.current],(e.shards||[]).map(ju),!0).filter(Boolean);return v.forEach(function(g){return g.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),v.forEach(function(g){return g.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var a=m.useCallback(function(v,g){if("touches"in v&&v.touches.length===2||v.type==="wheel"&&v.ctrlKey)return!i.current.allowPinchZoom;var x=Wo(v),b=n.current,y="deltaX"in v?v.deltaX:b[0]-x[0],k="deltaY"in v?v.deltaY:b[1]-x[1],C,T=v.target,I=Math.abs(y)>Math.abs(k)?"h":"v";if("touches"in v&&I==="h"&&T.type==="range")return!1;var A=ku(I,T);if(!A)return!0;if(A?C=I:(C=I==="v"?"h":"v",A=ku(I,T)),!A)return!1;if(!r.current&&"changedTouches"in v&&(y||k)&&(r.current=C),!C)return!0;var R=r.current||C;return mw(R,g,v,R==="h"?y:k)},[]),l=m.useCallback(function(v){var g=v;if(!(!ar.length||ar[ar.length-1]!==s)){var x="deltaY"in g?Au(g):Wo(g),b=t.current.filter(function(C){return C.name===g.type&&(C.target===g.target||g.target===C.shadowParent)&&gw(C.delta,x)})[0];if(b&&b.should){g.cancelable&&g.preventDefault();return}if(!b){var y=(i.current.shards||[]).map(ju).filter(Boolean).filter(function(C){return C.contains(g.target)}),k=y.length>0?a(g,y[0]):!i.current.noIsolation;k&&g.cancelable&&g.preventDefault()}}},[]),u=m.useCallback(function(v,g,x,b){var y={name:v,delta:g,target:x,should:b,shadowParent:bw(x)};t.current.push(y),setTimeout(function(){t.current=t.current.filter(function(k){return k!==y})},1)},[]),d=m.useCallback(function(v){n.current=Wo(v),r.current=void 0},[]),f=m.useCallback(function(v){u(v.type,Au(v),v.target,a(v,e.lockRef.current))},[]),h=m.useCallback(function(v){u(v.type,Wo(v),v.target,a(v,e.lockRef.current))},[]);m.useEffect(function(){return ar.push(s),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:h}),document.addEventListener("wheel",l,ir),document.addEventListener("touchmove",l,ir),document.addEventListener("touchstart",d,ir),function(){ar=ar.filter(function(v){return v!==s}),document.removeEventListener("wheel",l,ir),document.removeEventListener("touchmove",l,ir),document.removeEventListener("touchstart",d,ir)}},[]);var p=e.removeScrollBar,w=e.inert;return m.createElement(m.Fragment,null,w?m.createElement(s,{styles:xw(o)}):null,p?m.createElement(lw,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function bw(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const yw=Yv(Su,ww);var Vo=m.forwardRef(function(e,t){return m.createElement(Ho,nn({},e,{ref:t,sideCar:yw}))});Vo.classNames=Ho.classNames;var Sw=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},lr=new WeakMap,Ko=new WeakMap,qo={},Bi=0,_u=function(e){return e&&(e.host||_u(e.parentNode))},Cw=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=_u(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},Tw=function(e,t,n,r){var o=Cw(t,Array.isArray(e)?e:[e]);qo[n]||(qo[n]=new WeakMap);var s=qo[n],i=[],a=new Set,l=new Set(o),u=function(f){!f||a.has(f)||(a.add(f),u(f.parentNode))};o.forEach(u);var d=function(f){!f||l.has(f)||Array.prototype.forEach.call(f.children,function(h){if(a.has(h))d(h);else try{var p=h.getAttribute(r),w=p!==null&&p!=="false",v=(lr.get(h)||0)+1,g=(s.get(h)||0)+1;lr.set(h,v),s.set(h,g),i.push(h),v===1&&w&&Ko.set(h,!0),g===1&&h.setAttribute(n,"true"),w||h.setAttribute(r,"true")}catch(x){console.error("aria-hidden: cannot operate on ",h,x)}})};return d(t),a.clear(),Bi++,function(){i.forEach(function(f){var h=lr.get(f)-1,p=s.get(f)-1;lr.set(f,h),s.set(f,p),h||(Ko.has(f)||f.removeAttribute(r),Ko.delete(f)),p||f.removeAttribute(n)}),Bi--,Bi||(lr=new WeakMap,lr=new WeakMap,Ko=new WeakMap,qo={})}},Hi=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=Sw(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),Tw(r,o,n,"aria-hidden")):function(){return null}},Go="Dialog",[Ru,MC]=en(Go),[Ew,Kt]=Ru(Go),Pu=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]=$n({prop:r,defaultProp:o??!1,onChange:s,caller:Go});return c.jsx(Ew,{scope:t,triggerRef:a,contentRef:l,contentId:tn(),titleId:tn(),descriptionId:tn(),open:u,onOpenChange:d,onOpenToggle:m.useCallback(()=>d(f=>!f),[d]),modal:i,children:n})};Pu.displayName=Go;var Ou="DialogTrigger",Mu=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Kt(Ou,n),s=Fe(t,o.triggerRef);return c.jsx(ye.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Vi(o.open),...r,ref:s,onClick:oe(e.onClick,o.onOpenToggle)})});Mu.displayName=Ou;var Ui="DialogPortal",[kw,Du]=Ru(Ui,{forceMount:void 0}),Lu=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=Kt(Ui,t);return c.jsx(kw,{scope:t,forceMount:n,children:m.Children.map(r,i=>c.jsx(_t,{present:n||s.open,children:c.jsx($o,{asChild:!0,container:o,children:i})}))})};Lu.displayName=Ui;var Yo="DialogOverlay",Fu=m.forwardRef((e,t)=>{const n=Du(Yo,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=Kt(Yo,e.__scopeDialog);return s.modal?c.jsx(_t,{present:r||s.open,children:c.jsx(Nw,{...o,ref:t})}):null});Fu.displayName=Yo;var Iw=_n.createSlot("DialogOverlay.RemoveScroll"),Nw=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Kt(Yo,n);return c.jsx(Vo,{as:Iw,allowPinchZoom:!0,shards:[o.contentRef],children:c.jsx(ye.div,{"data-state":Vi(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),Bn="DialogContent",$u=m.forwardRef((e,t)=>{const n=Du(Bn,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=Kt(Bn,e.__scopeDialog);return c.jsx(_t,{present:r||s.open,children:s.modal?c.jsx(Aw,{...o,ref:t}):c.jsx(jw,{...o,ref:t})})});$u.displayName=Bn;var Aw=m.forwardRef((e,t)=>{const n=Kt(Bn,e.__scopeDialog),r=m.useRef(null),o=Fe(t,n.contentRef,r);return m.useEffect(()=>{const s=r.current;if(s)return Hi(s)},[]),c.jsx(zu,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:oe(e.onCloseAutoFocus,s=>{var i;s.preventDefault(),(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:oe(e.onPointerDownOutside,s=>{const i=s.detail.originalEvent,a=i.button===0&&i.ctrlKey===!0;(i.button===2||a)&&s.preventDefault()}),onFocusOutside:oe(e.onFocusOutside,s=>s.preventDefault())})}),jw=m.forwardRef((e,t)=>{const n=Kt(Bn,e.__scopeDialog),r=m.useRef(!1),o=m.useRef(!1);return c.jsx(zu,{...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()}})}),zu=m.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=Kt(Bn,n),l=m.useRef(null),u=Fe(t,l);return Di(),c.jsxs(c.Fragment,{children:[c.jsx(Fo,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:c.jsx(Lo,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":Vi(a.open),...i,ref:u,onDismiss:()=>a.onOpenChange(!1)})}),c.jsxs(c.Fragment,{children:[c.jsx(_w,{titleId:a.titleId}),c.jsx(Pw,{contentRef:l,descriptionId:a.descriptionId})]})]})}),Wi="DialogTitle",Bu=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Kt(Wi,n);return c.jsx(ye.h2,{id:o.titleId,...r,ref:t})});Bu.displayName=Wi;var Hu="DialogDescription",Uu=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Kt(Hu,n);return c.jsx(ye.p,{id:o.descriptionId,...r,ref:t})});Uu.displayName=Hu;var Wu="DialogClose",Vu=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Kt(Wu,n);return c.jsx(ye.button,{type:"button",...r,ref:t,onClick:oe(e.onClick,()=>o.onOpenChange(!1))})});Vu.displayName=Wu;function Vi(e){return e?"open":"closed"}var Ku="DialogTitleWarning",[DC,qu]=Fx(Ku,{contentName:Bn,titleName:Wi,docsSlug:"dialog"}),_w=({titleId:e})=>{const t=qu(Ku),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
124
124
 
125
125
  If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
126
126
 
127
127
  For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return m.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},Rw="DialogDescriptionWarning",Pw=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${qu(Rw).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},Gu=Pu,Ow=Mu,Yu=Lu,Xo=Fu,Jo=$u,Hn=Bu,Zo=Uu,Xu=Vu;const Mw=Gu,Dw=Yu,Ju=m.forwardRef(({className:e,...t},n)=>c.jsx(Xo,{ref:n,className:X("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));Ju.displayName=Xo.displayName;const Zu=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===Hn||(u==null?void 0:u.displayName)===Hn.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(Dw,{children:[c.jsx(Ju,{}),c.jsxs(Jo,{ref:r,className:X("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...n,children:[!o&&c.jsx(Hn,{className:"sr-only",children:"Dialog"}),t,c.jsxs(Xu,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[c.jsx(ee.X,{className:"h-4 w-4"}),c.jsx("span",{className:"sr-only",children:"Close"})]})]})]})});Zu.displayName=Jo.displayName;const Qu=({className:e,...t})=>c.jsx("div",{className:X("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});Qu.displayName="DialogHeader";const ed=m.forwardRef(({className:e,...t},n)=>c.jsx(Hn,{ref:n,className:X("text-lg font-semibold leading-none tracking-tight",e),...t}));ed.displayName=Hn.displayName;const Lw=m.forwardRef(({className:e,...t},n)=>c.jsx(Zo,{ref:n,className:X("text-sm text-muted-foreground",e),...t}));Lw.displayName=Zo.displayName;function Fw({isOpen:e,onClose:t,fileId:n,fileName:r,mimeType:o}){const[s,i]=S.useState(!1),[a,l]=S.useState(null),[u,d]=S.useState(null),{toast:f}=_i(),h=S.useCallback(async()=>{if(n){i(!0),d(null),l(null);try{const x=await au(n);l(x)}catch(x){console.error("Failed to load file:",x),d(x instanceof Error?x.message:"Failed to load file")}finally{i(!1)}}},[n]);S.useEffect(()=>{e&&n&&h()},[e,n,h]);const p=async()=>{if(n)try{await xv(n),f({title:"Download started",description:`Downloading ${r}`})}catch(x){console.error("Failed to download file:",x),f({title:"Download failed",description:String(x),variant:"destructive"})}},w=async()=>{if(n)try{const x=await au(n),b=new Blob([x],{type:o}),y=URL.createObjectURL(b);window.open(y,"_blank"),URL.revokeObjectURL(y)}catch(x){console.error("Failed to open file externally:",x),f({title:"Failed to open file",description:String(x),variant:"destructive"})}},v=()=>s?c.jsxs("div",{className:"flex items-center justify-center py-12",children:[c.jsx(ee.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(Ue,{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(ee.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(ee.Image,{className:"h-5 w-5"}):c.jsx(ee.FileText,{className:"h-5 w-5"});return c.jsx(Mw,{open:e,onOpenChange:t,children:c.jsxs(Zu,{className:"max-w-4xl max-h-[90vh] overflow-hidden",children:[c.jsx(Qu,{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(ed,{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(Ue,{variant:"outline",size:"sm",onClick:w,className:"flex items-center gap-2",children:[c.jsx(ee.ExternalLink,{className:"h-4 w-4"}),"External"]}),c.jsxs(Ue,{variant:"outline",size:"sm",onClick:p,className:"flex items-center gap-2",children:[c.jsx(ee.Download,{className:"h-4 w-4"}),"Download"]})]})]})}),c.jsx("div",{className:"flex-1 overflow-hidden",children:v()})]})})}function td(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 nd(e){return!!(e&&typeof e=="object"&&(e.type==="file"||e.mimeType||e.filename||e.sourceType==="base64"))}function zr(e){if(typeof e=="string")return e.length>2e3?e.slice(0,2e3)+"... [truncated]":e;if(e&&typeof e=="object"){if(Array.isArray(e)){const n=e.map(zr).filter(r=>r!==void 0);return n.length?n:void 0}if(nd(e))return;const t={};for(const n of Object.keys(e)){const r=e[n];if(n==="data"&&typeof r=="string"&&r.length>100)t[n]=`[base64 ${r.length} chars omitted]`;else{const o=zr(r);o!==void 0&&(t[n]=o)}}return Object.keys(t).length?t:void 0}return e}function Ki(e){if(typeof e=="string")return e;if(nd(e))return"";try{const t=zr(e);return t===void 0?"":typeof t=="string"?t:JSON.stringify(t,null,2)}catch{return""}}function rd(e){if(!e)return null;if(typeof e=="object"&&!Array.isArray(e)){if(e.desirability||e.feasibility||e.viability||e.other)return{desirability:Array.isArray(e.desirability)?e.desirability:[],feasibility:Array.isArray(e.feasibility)?e.feasibility:[],viability:Array.isArray(e.viability)?e.viability:[],other:Array.isArray(e.other)?e.other:[]};if(e.output&&typeof e.output!="object")e=e.output;else if(e.output&&typeof e.output=="object")return rd(e.output)}const t=String(e),n={desirability:[],feasibility:[],viability:[],other:[]};let r=t;const o=Math.min(...["desirability=","feasibility=","viability=","other="].map(i=>{const a=r.toLowerCase().indexOf(i);return a===-1?Number.MAX_SAFE_INTEGER:a}));o!==Number.MAX_SAFE_INTEGER&&(r=r.slice(o));for(const i of Object.keys(n)){const l=new RegExp(i+"\\s*=\\s*\\[([\\s\\S]*?)\\]","i").exec(r);if(!l)continue;const u=l[1],d=/Issue\(([\s\S]*?)\)(?:,|$)/g;let f=null;for(;(f=d.exec(u))!==null;){const h=f[1],p=/title\s*=\s*(['"])([\s\S]*?)\1/.exec(h),w=/description\s*=\s*(['"])([\s\S]*?)\1/.exec(h),v=p?p[2].trim():"",g=w?w[2].trim():"";n[i].push({title:v,description:g})}}return Object.values(n).some(i=>i.length>0)?n:null}const Qo="prose prose-sm max-w-none break-words dark:prose-invert prose-headings:break-words prose-p:break-words prose-li:break-words prose-td:break-words prose-th:break-words prose-a:break-all prose-code:break-words prose-blockquote:break-words",Un=1e5;function $w(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function zw(e){const t=e.find(r=>r.type==="tool_call"),n=e.find(r=>r.type==="tool_end");return{name:t==null?void 0:t.name,toolCallId:(n==null?void 0:n.toolCallId)??(t==null?void 0:t.id)}}function Bw(e){const t=e.filter(r=>r.type==="tool_call");return e.filter(r=>r.type==="tool_end").map(r=>{var o;return{name:(o=t.find(s=>s.id===r.toolCallId))==null?void 0:o.name,toolCallId:r.toolCallId,output:r.output}})}function Hw(e){const t=(r,o=Un)=>{try{const s=zr(r),i=typeof s=="string"?s:JSON.stringify(s??"");return i.length<=o?i:i.slice(0,o)+`
128
- … [truncated ${i.length-o} chars]`}catch{return""}},n=e.filter(r=>r.type==="tool_end");if(n.length)try{return n.length===1?t(n[0].output):t(n.map(r=>({toolCallId:r.toolCallId,output:r.output})))}catch{}return t(e)}function Uw(e){const t=e.find(r=>r.type==="tool_end");if(!t)return null;const n=t.output;return typeof n=="string"?n:null}function Ww(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function od(e){const t=e.updatedAt??e.createdAt??"",n=Array.isArray(e.content)?e.content.map(r=>{switch(r.type){case"text":return`t:${r.text.length}`;case"image_url":return"img";case"file":return"file";case"tool_call":return"call";case"tool_end":return"end";default:return"unknown"}}).join("|"):"";return`${e.id}:${t}:${n}`}function Vw({className:e}){const[t,n]=S.useState(0);return S.useEffect(()=>{const r=setInterval(()=>n(o=>(o+1)%4),500);return()=>clearInterval(r)},[]),c.jsxs("span",{"aria-live":"polite",className:X("inline-block text-xs opacity-70 ml-1",e),children:["Is thinking",".".repeat(t)]})}const sd=S.memo(function({message:t,messageIndex:n,isStreamingMessage:r=!1,isEditing:o=!1,showActions:s=!0,showTimestamp:i=!0,showAgentName:a=!0,layoutSize:l="desktop",truncateToolMessages:u=!0,toolMessagePreviewLength:d=200,truncateUserMessages:f=!0,userMessagePreviewLength:h=200,customStyles:p={},onEdit:w,onRegenerate:v,onCancelEdit:g,onCopy:x}){const[b,y]=S.useState(!1),[E,C]=S.useState("collapsed"),[T,I]=S.useState(!1),{currentThreadId:A}=ho(),{handleInterrupt:R}=Js(),{toast:j}=_i(),[M,D]=S.useState({}),[L,P]=S.useState(!1),[V,U]=S.useState(null),q=l==="phone"||l==="half-screen",$=t.role,N=$==="tool",W=!(r&&$!=="user"),Y=S.useMemo(()=>{switch($){case"user":return"text-[hsl(var(--chat-bubble-user-text))]";case"assistant":return"text-[hsl(var(--chat-bubble-ai-text))]";case"tool":return"text-secondary-foreground";case"system":return"text-muted-foreground";default:return"text-[hsl(var(--chat-bubble-ai-text))]"}},[$]),de=S.useMemo(()=>$w(t.content),[t.content]),se=S.useMemo(()=>zw(t.content),[t.content]),pe=S.useMemo(()=>t.content.filter(Q=>Q.type==="image_url"),[t.content]),me=S.useMemo(()=>t.content.filter(Q=>Q.type==="file"),[t.content]),Se=S.useMemo(()=>t.content.filter(Q=>Q.type==="interrupt"),[t.content]),B=S.useMemo(()=>Hw(t.content),[t.content]);S.useMemo(()=>Uw(t.content),[t.content]);const O=S.useMemo(()=>B.length<=Un?B:`${B.slice(0,Un)}
129
- … [truncated ${B.length-Un} chars]`,[B]),G=S.useCallback(async(Q="all")=>{const ge=Q==="visible"&&N?O:N?B:de;async function Ce(we){try{await navigator.clipboard.writeText(we)}catch{try{const _e=document.createElement("textarea");_e.value=we,_e.setAttribute("readonly",""),_e.style.position="absolute",_e.style.left="-9999px",document.body.appendChild(_e),_e.select(),document.execCommand("copy"),document.body.removeChild(_e)}catch(_e){throw console.error("Failed to copy:",_e),_e}}}try{await Ce(ge),y(!0),setTimeout(()=>y(!1),2e3),x==null||x(ge)}catch(we){console.error("Failed to copy:",we)}},[N,B,de,O,x]),Z=S.useCallback(()=>{if(!w)return;const Q=N?B:de;w(t.id,Q)},[w,t.id,N,B,de]),ce=S.useCallback(()=>{v==null||v(n)},[v,n]),ie=S.useCallback(async(Q,le,ge)=>{if(!W){Q.preventDefault();return}if(M[ge]){Q.preventDefault();return}try{const Ce=String(le.url??""),we=Ce.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);if(we){Q.preventDefault();const _e=we[1],et=le.name||`file_${_e}`,Ke=le.mimeType||"application/octet-stream";U({id:_e,name:et,mimeType:Ke}),P(!0);return}if(Ce.startsWith("data:")){Q.preventDefault(),D(Ke=>({...Ke,[ge]:!0}));const _e=`${le.name}_${le.size}_${Date.now()}`,et=j({title:"Fetching file...",description:"",open:!0});try{const Ke=await vv(A??void 0);if(!Ke||!Array.isArray(Ke))throw new Error("Invalid file list response");const F=Ke.find(J=>!J||typeof J!="object"||!((J.filename??"")===(le.name??""))?!1:typeof le.size=="number"&&typeof J.size=="number"?J.size===le.size:!0);if(!(F!=null&&F.id))throw new Error(`File "${le.name}" is not yet available on the server`);if(!F.id||!F.filename)throw new Error("Invalid file data received from server");U({id:F.id,name:le.name||F.filename||`file_${F.id}`,mimeType:le.mimeType||F.mime_type||"application/octet-stream"}),P(!0),et.update({id:et.id,title:"Success",description:`Opened ${le.name}`,open:!0})}catch(Ke){console.error("Failed to fetch server file:",Ke);const F=Ke instanceof Error?Ke.message:"Unknown error occurred";et.update({id:et.id,title:"Failed",description:F}),j({title:"Failed to fetch file",description:F,open:!0})}finally{D(Ke=>({...Ke,[ge]:!1}))}}}catch(Ce){console.error("File click error:",Ce),D(we=>({...we,[ge]:!1}))}},[W,M,j,A]),De=S.useCallback(()=>{const le=X(q?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",Y);switch($){case"user":return c.jsx(ee.User,{className:le});case"assistant":return c.jsx(ee.Bot,{className:le});case"tool":return c.jsx(ee.Wrench,{className:le});default:return c.jsx(ee.Bot,{className:le})}},[q,Y,$]),Xe=S.useCallback(()=>{const Q="group relative mb-4 flex w-full";switch($){case"user":return X(Q,"justify-end");case"assistant":case"tool":case"system":return X(Q,"justify-start");default:return Q}},[$]),Je=S.useCallback(()=>{const Q=X("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",q&&"px-3 py-2 text-sm");switch($){case"user":return X(Q,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-user))] text-[hsl(var(--chat-bubble-user-text))]","border border-transparent");case"assistant":return X(Q,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40");case"tool":return X(Q,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return X(Q,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return X(Q,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40")}},[q,$]),Ne=S.useCallback(async Q=>{try{const le=Q.id||`interrupt-${Date.now()}`;await R(le,!0)}catch(le){console.error("Failed to approve interrupt:",le)}},[R]),Oe=S.useCallback(async Q=>{try{const le=Q.id||`interrupt-${Date.now()}`;await R(le,!1)}catch(le){console.error("Failed to reject interrupt:",le)}},[R]),Qe=S.useCallback(({part:Q,i:le})=>{if(Q.type==="text"){const ge=Q.text??"",Ce=ge.trim(),we=td(Ce);return we&&$!=="tool"?c.jsx(Kw,{data:we},le):$==="user"&&f&&Ce.length>h?c.jsxs(Uc,{open:T,onOpenChange:I,children:[c.jsx("div",{className:X("text-sm text-[hsl(var(--chat-bubble-user-text))]",q&&"text-xs"),children:T?c.jsx(Ni,{content:Ce,allowHtml:!1}):c.jsxs("pre",{className:X("font-sans whitespace-pre-wrap break-words bg-transparent p-0 m-0 text-[hsl(var(--chat-bubble-user-text))]",q&&"text-xs"),children:[Ce.substring(0,h),"..."]})}),c.jsx(Wc,{asChild:!0,children:c.jsx(Ue,{variant:"ghost",size:"sm",className:"h-6 text-xs !text-[hsl(var(--chat-bubble-user-text))]",children:T?c.jsxs(c.Fragment,{children:[c.jsx(ee.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):c.jsxs(c.Fragment,{children:[c.jsx(ee.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",Ce.length-h," chars)"]})})})]},le):c.jsx(Ni,{content:ge,allowHtml:!1},le)}if(Q.type==="image_url"){const ge=Q;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"})},le)}if(Q.type==="file"){const ge=Q,Ce=ge.name||"file";return c.jsxs("a",{href:ge.url,onClick:we=>ie(we,ge,le),className:`inline-flex items-center gap-2 rounded px-2 py-1 text-xs bg-gray-100 border hover:bg-gray-200
130
- dark:bg-background/10 dark:border-border/30 dark:hover:bg-background/20`,children:[M[le]?c.jsx(ee.Loader,{className:"h-4 w-4 animate-spin"}):null,c.jsxs("span",{className:"truncate max-w-[180px]",children:[Ce,M[le]?" (processing)":""]})]},le)}return Q.type==="interrupt"?c.jsx(Gw,{interruptPart:Q,onApprove:Ne,onReject:Oe},le):null},[ie,M,Ne,Oe,$,f,h,T,q]),Re=S.useCallback(()=>c.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/30 rounded",children:[c.jsx(ee.Paperclip,{className:"h-4 w-4 text-muted-foreground"}),c.jsx("span",{className:"text-sm text-muted-foreground",children:"File upload"})]}),[]),st=S.useCallback(()=>{const Q=de.trim().length>0||pe.length>0||me.length>0||Se.length>0;if(!N&&!Q&&!r)return Re();if(t.model==="reflection"){const le=de.trim(),ge=td(le);if(ge&&typeof ge=="object")return c.jsx(Yw,{data:ge})}if(N&&se.name==="get_issues"){const le=t.content.find(we=>we.type==="tool_end"),ge=(le==null?void 0:le.output)??B,Ce=rd(ge);if(Ce)return c.jsx(Xw,{issues:Ce})}if(N){const le=Bw(t.content);if(le.length>0)return c.jsx("div",{className:"space-y-2",children:le.map((ge,Ce)=>{const we=typeof ge.output=="string"?ge.output:Ki(ge.output),_e=we.length>Un?`${we.slice(0,Un)}
131
- … [truncated ${we.length-Un} chars]`:we,et=E==="expanded";return c.jsxs(Uc,{open:et,onOpenChange:Ke=>C(Ke?"expanded":"preview"),children:[c.jsx("div",{className:"flex items-center gap-2 text-xs",children:c.jsx(yi,{variant:"outline",children:(ge.name??"tool")+(ge.toolCallId?` • ${ge.toolCallId.slice(0,8)}`:"")})}),c.jsx("div",{className:"font-mono text-sm mt-1",children:c.jsx("pre",{className:"whitespace-pre-wrap break-words",children:et?_e:_e.slice(0,d)+(_e.length>d?"...":"")})}),c.jsx(Wc,{asChild:!0,children:c.jsx(Ue,{variant:"ghost",size:"sm",className:"h-6 text-xs",children:et?c.jsxs(c.Fragment,{children:[" ",c.jsx(ee.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):c.jsxs(c.Fragment,{children:[c.jsx(ee.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more"]})})})]},ge.toolCallId??Ce)})})}if(!N){const le=c.jsx("div",{className:"space-y-2",children:t.content.map((ge,Ce)=>c.jsx(Qe,{part:ge,i:Ce},Ce))});return r?c.jsxs("div",{"aria-busy":"true",role:"status",children:[le,c.jsx(Vw,{className:Y})]}):le}},[de,pe.length,me.length,Se.length,r,t.model,N,se.name,B,E,u,Re,Y]),ct=S.useMemo(()=>Ww(t),[t]);return c.jsxs(c.Fragment,{children:[c.jsx("div",{className:X(Xe(),p.container),children:c.jsxs("div",{className:X(Je(),p.content),children:[(i||a||N)&&c.jsxs("div",{className:X("flex items-center justify-between mb-2 pb-2 border-b border-current/10",q&&"mb-1 pb-1",Y,p.header),children:[c.jsxs("div",{className:"flex items-center gap-2",children:[De(),a&&ct&&c.jsx("span",{className:X("font-medium",q?"text-xs":"text-sm"),children:ct}),N&&se.name&&c.jsxs(yi,{variant:"outline",className:X("text-xs flex items-center gap-1 cursor-pointer",Y,"border border-current/40",q&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":E!=="collapsed",onKeyDown:Q=>{(Q.key==="Enter"||Q.key===" ")&&(Q.preventDefault(),C(le=>le==="collapsed"?"preview":"collapsed"))},onClick:()=>C(Q=>Q==="collapsed"?"preview":"collapsed"),children:[c.jsx("span",{children:se.name}),c.jsx("span",{className:"inline-flex items-center",children:E!=="collapsed"?c.jsx(ee.ChevronUp,{className:"h-3 w-3"}):c.jsx(ee.ChevronDown,{className:"h-3 w-3"})})]}),N&&!se.name&&c.jsx(Ue,{variant:"ghost",size:"sm",className:X("h-6 px-1",Y,"hover:bg-foreground/10"),onClick:()=>C(Q=>Q==="collapsed"?"preview":"collapsed"),children:c.jsxs("span",{className:"text-xs flex items-center gap-1",children:["Tool Output ",E!=="collapsed"?c.jsx(ee.ChevronUp,{className:"h-3 w-3"}):c.jsx(ee.ChevronDown,{className:"h-3 w-3"})]})})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[i&&t.createdAt&&c.jsx("time",{className:X("text-xs opacity-60",Y,q&&"text-xs"),dateTime:new Date(t.createdAt).toISOString(),title:new Date(t.createdAt).toLocaleString(),children:new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(new Date(t.createdAt))}),s&&!o&&c.jsxs("div",{className:X("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",p.actions),children:[c.jsxs("div",{className:"relative",children:[c.jsx(Ue,{variant:"ghost",size:"sm",onClick:()=>G(N?"visible":"all"),className:X("h-6 w-6 p-0 hover:bg-foreground/10",Y,q&&"h-5 w-5"),"aria-label":N?"Copy visible":"Copy message",title:N?"Copy visible portion":"Copy message",children:c.jsx(ee.Copy,{className:X(b?"text-success":Y,q?"h-3 w-3":"h-4 w-4")})}),N&&c.jsx(Ue,{variant:"ghost",size:"sm",onClick:()=>G("all"),className:X("h-6 px-1 text-xs hover:bg-foreground/10",Y),"aria-label":"Copy all (may be large)",title:"Copy all (may be large)",children:"all"})]}),$==="user"&&w&&c.jsx(Ue,{variant:"ghost",size:"sm",onClick:Z,className:X("h-6 w-6 p-0 hover:bg-foreground/10",Y,q&&"h-5 w-5"),"aria-label":"Edit message",children:c.jsx(ee.Edit,{className:X(Y,q?"h-3 w-3":"h-4 w-4")})}),$==="assistant"&&v&&c.jsx(Ue,{variant:"ghost",size:"sm",onClick:ce,className:X("h-6 w-6 p-0 hover:bg-foreground/10",Y,q&&"h-5 w-5"),"aria-label":"Regenerate response",children:c.jsx(ee.RotateCcw,{className:X(Y,q?"h-3 w-3":"h-4 w-4")})})]})]})]}),c.jsx("div",{className:"relative",children:st()}),N&&E==="expanded"&&(se.toolCallId||se.name)&&c.jsxs("div",{className:X("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",q&&"text-xs"),children:[se.name&&c.jsxs("div",{children:["Function: ",se.name]}),se.toolCallId&&c.jsxs("div",{children:["Call ID: ",se.toolCallId]})]}),!(i||a||N)&&s&&!o&&c.jsxs("div",{className:X("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",p.actions),children:[c.jsx(Ue,{variant:"ghost",size:"sm",onClick:()=>G(),className:X("h-6 w-6 p-0 hover:bg-background/50 text-current",q&&"h-5 w-5"),children:c.jsx(ee.Copy,{className:X(b?"text-success":"text-current",q?"h-3 w-3":"h-4 w-4")})}),$==="user"&&w&&c.jsx(Ue,{variant:"ghost",size:"sm",onClick:Z,className:X("h-6 w-6 p-0 hover:bg-background/50 text-current",q&&"h-5 w-5"),children:c.jsx(ee.Edit,{className:X("text-current",q?"h-3 w-3":"h-4 w-4")})}),$==="assistant"&&v&&c.jsx(Ue,{variant:"ghost",size:"sm",onClick:ce,className:X("h-6 w-6 p-0 hover:bg-background/50 text-current",q&&"h-5 w-5"),children:c.jsx(ee.RotateCcw,{className:X("text-current",q?"h-3 w-3":"h-4 w-4")})})]})]})}),V&&c.jsx(Fw,{isOpen:L,onClose:()=>{P(!1),U(null)},fileId:V.id,fileName:V.name,mimeType:V.mimeType})]})},(e,t)=>{var i,a,l,u,d,f,h,p;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&od(e.message)===od(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateToolMessages","toolMessagePreviewLength","truncateUserMessages","userMessagePreviewLength"].every(w=>e[w]===t[w]),s=((i=e.customStyles)==null?void 0:i.container)===((a=t.customStyles)==null?void 0:a.container)&&((l=e.customStyles)==null?void 0:l.content)===((u=t.customStyles)==null?void 0:u.content)&&((d=e.customStyles)==null?void 0:d.actions)===((f=t.customStyles)==null?void 0:f.actions)&&((h=e.customStyles)==null?void 0:h.header)===((p=t.customStyles)==null?void 0:p.header);return o&&s});function Kw({data:e}){if(Array.isArray(e))return e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?c.jsx("div",{className:Qo,children:c.jsx("ul",{className:"list-disc pl-5",children:e.map((n,r)=>c.jsx("li",{children:String(n)},r))})}):c.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:Ki(e)});if(e&&typeof e=="object"){const t=Array.isArray(e.distilled_facts)?e.distilled_facts:null,n=Array.isArray(e.follow_up_queries)?e.follow_up_queries:null,r=typeof e.is_sufficient=="boolean"?e.is_sufficient:void 0;if(t||n||typeof r=="boolean")return c.jsxs("div",{className:Qo,children:[typeof r=="boolean"&&c.jsxs("p",{children:[c.jsx("strong",{children:"Is sufficient:"})," ",r?"Yes":"No"]}),n&&n.length>0&&c.jsxs("div",{children:[c.jsx("p",{children:c.jsx("strong",{children:"Follow-up queries:"})}),c.jsx("ul",{className:"list-disc pl-5",children:n.map((s,i)=>c.jsx("li",{children:String(s)},i))})]}),t&&t.length>0&&c.jsxs("div",{children:[c.jsx("p",{children:c.jsx("strong",{children:"Facts:"})}),c.jsx("ul",{className:"list-disc pl-5",children:t.map((s,i)=>c.jsx("li",{children:String(s)},i))})]})]});const o=Object.entries(e);return c.jsx("div",{className:Qo,children:c.jsx("dl",{className:"mt-0",children:o.map(([s,i])=>c.jsxs("div",{className:"mb-1",children:[c.jsxs("dt",{className:"inline font-medium mr-1",children:[s,":"]}),c.jsx("dd",{className:"inline",children:qw(i)})]},s))})})}return c.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:Ki(e)})}function qw(e){if(e==null)return String(e);const t=typeof e;if(t==="string"||t==="number"||t==="boolean")return String(e);if(Array.isArray(e)&&e.every(r=>r===null||["string","number","boolean"].includes(typeof r)))return e.join(", ");try{return c.jsx("code",{className:"text-xs",children:JSON.stringify(zr(e))})}catch{return String(e)}}function Gw({interruptPart:e,onApprove:t,onReject:n}){const r=e.title??"Approve the result?";return c.jsxs(Dr,{className:"border-blue-200 dark:border-blue-800 bg-blue-50/50 dark:bg-blue-950/10",children:[c.jsxs(Lr,{className:"pb-3",children:[c.jsx(Fr,{className:"text-blue-900 dark:text-blue-100 text-base",children:r}),c.jsx(Vc,{className:"text-blue-700 dark:text-blue-300",children:"Please approve or reject this action to continue."})]}),c.jsx(Kc,{className:"pt-0",children:c.jsxs("div",{className:"flex gap-2 ml-auto",children:[c.jsx(Ue,{size:"sm",variant:"outline",onClick:()=>n(e),className:"border-red-300 text-red-700 hover:bg-red-50 dark:border-red-700 dark:text-red-300 dark:hover:bg-red-950/50",children:"Reject"}),c.jsx(Ue,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",children:"Approve"})]})})]})}function Yw({data:e}){return c.jsx("dl",{className:"grid grid-cols-1 gap-y-2",children:Object.entries(e).map(([t,n])=>c.jsxs("div",{className:"flex",children:[c.jsxs("dt",{className:"font-semibold mr-2",children:[t,":"]}),c.jsx("dd",{className:"flex-1 break-words",children:Array.isArray(n)?n.map((r,o)=>c.jsxs("div",{className:"ml-4 break-words",children:["- ",String(r)]},o)):String(n)})]},t))})}function Xw({issues:e}){const t=[{key:"desirability",title:"Desirability"},{key:"feasibility",title:"Feasibility"},{key:"viability",title:"Viability"},{key:"other",title:"Other"}];return c.jsx("div",{className:Qo,children:t.map(n=>{const r=e[n.key];return!r||!r.length?null:c.jsxs("div",{className:"mb-4",children:[c.jsxs("h4",{className:"font-semibold mb-2",children:[n.title," (",r.length,")"]}),c.jsx("ol",{className:"list-decimal pl-5 space-y-2",children:r.map((o,s)=>c.jsxs("li",{children:[c.jsx("div",{className:"font-medium",children:o.title}),c.jsx("div",{className:"text-sm text-muted-foreground",children:o.description})]},s))})]},n.key)})})}const id=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,qi=S.forwardRef(({messages:e,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onStartReached:a,onEdit:l,onRegenerate:u,onCancelEdit:d,className:f,style:h,emptyMessage:p,followNewMessages:w=!0,isNavigatingCheckpoint:v=!1,onScrollAway:g,onAtBottom:x},b)=>{const y=S.useRef(null),E=S.useRef(null),C=S.useRef(!1),[T,I]=S.useState(!0),A=S.useCallback(M=>{I(M),g&&g(!M),x&&x(M)},[g,x]),R=S.useMemo(()=>{if(a)return async()=>{if(!C.current){C.current=!0;try{await a()}finally{C.current=!1}}}},[a]),j=S.useMemo(()=>!w||v?!1:T?"auto":!1,[T,w,v]);return e.length===0?c.jsx("div",{className:f,style:h,children:c.jsx("div",{className:"flex items-center justify-center py-8 text-muted-foreground text-center max-w-md mx-auto",children:p||"No messages yet. Start a conversation!"})}):c.jsx("div",{className:f,style:h,children:c.jsx(Sx,{ref:M=>{y.current=M},scrollerRef:M=>{E.current=M instanceof HTMLDivElement?M:null},data:e,followOutput:j,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,alignToBottom:!1,startReached:()=>{R&&R()},atBottomStateChange:A,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(M,D)=>id(D,M),itemContent:(M,D)=>{const L=id(D,M);return c.jsx("div",{className:"mb-4 last:mb-0","data-message-id":L,style:{minHeight:"60px",containIntrinsicSize:"auto 120px"},children:c.jsx(sd,{message:D,messageIndex:M,isStreamingMessage:t&&n===D.id,streamingDebounceMs:r,isEditing:i===D.id,showActions:s,showTimestamp:!1,showAgentName:!0,layoutSize:o,truncateToolMessages:!1,toolMessagePreviewLength:200,onEdit:l,onRegenerate:()=>u(M),onCancelEdit:d})})}})})});qi.displayName="MessageList";const es=1e4;function Jw(e){if(typeof e!="string")return String(e);const t=[/<script[^>]*>.*?<\/script>/gi,/<iframe[^>]*>.*?<\/iframe>/gi,/javascript:/gi,/vbscript:/gi,/on\w+\s*=/gi,/<object[^>]*>.*?<\/object>/gi,/<embed[^>]*>.*?<\/embed>/gi,/<form[^>]*>.*?<\/form>/gi];let n=e;for(const o of t)n=n.replace(o,"");return/<[^>]+>/.test(n)&&!/<(?!\/?(?:code|strong|em|b|i|br|p|ul|ol|li|h[1-6])\b)[^>]+>/i.test(n)?n.replace(/<code>(.*?)<\/code>/gi,"`$1`").replace(/<strong>(.*?)<\/strong>/gi,"**$1**").replace(/<b>(.*?)<\/b>/gi,"**$1**").replace(/<em>(.*?)<\/em>/gi,"*$1*").replace(/<i>(.*?)<\/i>/gi,"*$1*").replace(/<br\s*\/?>/gi,`
128
+ … [truncated ${i.length-o} chars]`}catch{return""}},n=e.filter(r=>r.type==="tool_end");if(n.length)try{return n.length===1?t(n[0].output):t(n.map(r=>({toolCallId:r.toolCallId,output:r.output})))}catch{}return t(e)}function Uw(e){const t=e.find(r=>r.type==="tool_end");if(!t)return null;const n=t.output;return typeof n=="string"?n:null}function Ww(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function od(e){const t=e.updatedAt??e.createdAt??"",n=Array.isArray(e.content)?e.content.map(r=>{switch(r.type){case"text":return`t:${r.text.length}`;case"image_url":return"img";case"file":return"file";case"tool_call":return"call";case"tool_end":return"end";default:return"unknown"}}).join("|"):"";return`${e.id}:${t}:${n}`}function Vw({className:e}){const[t,n]=S.useState(0);return S.useEffect(()=>{const r=setInterval(()=>n(o=>(o+1)%4),500);return()=>clearInterval(r)},[]),c.jsxs("span",{"aria-live":"polite",className:X("inline-block text-xs opacity-70 ml-1",e),children:["Is thinking",".".repeat(t)]})}const sd=S.memo(function({message:t,messageIndex:n,isStreamingMessage:r=!1,isEditing:o=!1,showActions:s=!0,showTimestamp:i=!0,showAgentName:a=!0,layoutSize:l="desktop",truncateToolMessages:u=!0,toolMessagePreviewLength:d=200,truncateUserMessages:f=!0,userMessagePreviewLength:h=200,customStyles:p={},onEdit:w,onRegenerate:v,onCancelEdit:g,onCopy:x}){const[b,y]=S.useState(!1),[k,C]=S.useState("collapsed"),[T,I]=S.useState(!1),{currentThreadId:A}=ho(),{handleInterrupt:R}=Js(),{toast:j}=_i(),[M,D]=S.useState({}),[L,P]=S.useState(!1),[V,U]=S.useState(null),q=l==="phone"||l==="half-screen",F=t.role,N=F==="tool",W=!(r&&F!=="user"),Y=S.useMemo(()=>{switch(F){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))]"}},[F]),de=S.useMemo(()=>$w(t.content),[t.content]),se=S.useMemo(()=>zw(t.content),[t.content]),pe=S.useMemo(()=>t.content.filter(Q=>Q.type==="image_url"),[t.content]),ge=S.useMemo(()=>t.content.filter(Q=>Q.type==="file"),[t.content]),Se=S.useMemo(()=>t.content.filter(Q=>Q.type==="interrupt"),[t.content]),B=S.useMemo(()=>Hw(t.content),[t.content]);S.useMemo(()=>Uw(t.content),[t.content]);const O=S.useMemo(()=>B.length<=Un?B:`${B.slice(0,Un)}
129
+ … [truncated ${B.length-Un} chars]`,[B]),G=S.useCallback(async(Q="all")=>{const me=Q==="visible"&&N?O:N?B:de;async function Ce(we){try{await navigator.clipboard.writeText(we)}catch{try{const _e=document.createElement("textarea");_e.value=we,_e.setAttribute("readonly",""),_e.style.position="absolute",_e.style.left="-9999px",document.body.appendChild(_e),_e.select(),document.execCommand("copy"),document.body.removeChild(_e)}catch(_e){throw console.error("Failed to copy:",_e),_e}}}try{await Ce(me),y(!0),setTimeout(()=>y(!1),2e3),x==null||x(me)}catch(we){console.error("Failed to copy:",we)}},[N,B,de,O,x]),Z=S.useCallback(()=>{if(!w)return;const Q=N?B:de;w(t.id,Q)},[w,t.id,N,B,de]),ce=S.useCallback(()=>{v==null||v(n)},[v,n]),ie=S.useCallback(async(Q,le,me)=>{if(!W){Q.preventDefault();return}if(M[me]){Q.preventDefault();return}try{const Ce=String(le.url??""),we=Ce.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);if(we){Q.preventDefault();const _e=we[1],et=le.name||`file_${_e}`,Ke=le.mimeType||"application/octet-stream";U({id:_e,name:et,mimeType:Ke}),P(!0);return}if(Ce.startsWith("data:")){Q.preventDefault(),D(Ke=>({...Ke,[me]:!0}));const _e=`${le.name}_${le.size}_${Date.now()}`,et=j({title:"Fetching file...",description:"",open:!0});try{const Ke=await vv(A??void 0);if(!Ke||!Array.isArray(Ke))throw new Error("Invalid file list response");const $=Ke.find(J=>!J||typeof J!="object"||!((J.filename??"")===(le.name??""))?!1:typeof le.size=="number"&&typeof J.size=="number"?J.size===le.size:!0);if(!($!=null&&$.id))throw new Error(`File "${le.name}" is not yet available on the server`);if(!$.id||!$.filename)throw new Error("Invalid file data received from server");U({id:$.id,name:le.name||$.filename||`file_${$.id}`,mimeType:le.mimeType||$.mime_type||"application/octet-stream"}),P(!0),et.update({id:et.id,title:"Success",description:`Opened ${le.name}`,open:!0})}catch(Ke){console.error("Failed to fetch server file:",Ke);const $=Ke instanceof Error?Ke.message:"Unknown error occurred";et.update({id:et.id,title:"Failed",description:$}),j({title:"Failed to fetch file",description:$,open:!0})}finally{D(Ke=>({...Ke,[me]:!1}))}}}catch(Ce){console.error("File click error:",Ce),D(we=>({...we,[me]:!1}))}},[W,M,j,A]),De=S.useCallback(()=>{const le=X(q?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",Y);switch(F){case"user":return c.jsx(ee.User,{className:le});case"assistant":return c.jsx(ee.Bot,{className:le});case"tool":return c.jsx(ee.Wrench,{className:le});default:return c.jsx(ee.Bot,{className:le})}},[q,Y,F]),Xe=S.useCallback(()=>{const Q="group relative mb-4 flex w-full";switch(F){case"user":return X(Q,"justify-end");case"assistant":case"tool":case"system":return X(Q,"justify-start");default:return Q}},[F]),Je=S.useCallback(()=>{const Q=X("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",q&&"px-3 py-2 text-sm");switch(F){case"user":return X(Q,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-user))] text-[hsl(var(--chat-bubble-user-text))]","border border-transparent");case"assistant":return X(Q,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40");case"tool":return X(Q,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return X(Q,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return X(Q,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40")}},[q,F]),Ne=S.useCallback(async Q=>{try{const le=Q.id||`interrupt-${Date.now()}`;await R(le,!0)}catch(le){console.error("Failed to approve interrupt:",le)}},[R]),Oe=S.useCallback(async Q=>{try{const le=Q.id||`interrupt-${Date.now()}`;await R(le,!1)}catch(le){console.error("Failed to reject interrupt:",le)}},[R]),Qe=S.useCallback(({part:Q,i:le})=>{if(Q.type==="text"){const me=Q.text??"",Ce=me.trim(),we=td(Ce);return we&&F!=="tool"?c.jsx(Kw,{data:we},le):F==="user"&&f&&Ce.length>h?c.jsxs(Uc,{open:T,onOpenChange:I,children:[c.jsx("div",{className:X("text-sm text-[hsl(var(--chat-bubble-user-text))]",q&&"text-xs"),children:T?c.jsx(Ni,{content:Ce,allowHtml:!1}):c.jsxs("pre",{className:X("font-sans whitespace-pre-wrap break-words bg-transparent p-0 m-0 text-[hsl(var(--chat-bubble-user-text))]",q&&"text-xs"),children:[Ce.substring(0,h),"..."]})}),c.jsx(Wc,{asChild:!0,children:c.jsx(Ue,{variant:"ghost",size:"sm",className:"h-6 text-xs !text-[hsl(var(--chat-bubble-user-text))]",children:T?c.jsxs(c.Fragment,{children:[c.jsx(ee.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):c.jsxs(c.Fragment,{children:[c.jsx(ee.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",Ce.length-h," chars)"]})})})]},le):c.jsx(Ni,{content:me,allowHtml:!1},le)}if(Q.type==="image_url"){const me=Q;return c.jsx("div",{className:"my-2",children:c.jsx("img",{src:me.url,alt:me.alt??"",loading:"lazy",className:"border rounded max-h-[420px] w-auto object-contain"})},le)}if(Q.type==="file"){const me=Q,Ce=me.name||"file";return c.jsxs("a",{href:me.url,onClick:we=>ie(we,me,le),className:`inline-flex items-center gap-2 rounded px-2 py-1 text-xs bg-gray-100 border hover:bg-gray-200
130
+ dark:bg-background/10 dark:border-border/30 dark:hover:bg-background/20`,children:[M[le]?c.jsx(ee.Loader,{className:"h-4 w-4 animate-spin"}):null,c.jsxs("span",{className:"truncate max-w-[180px]",children:[Ce,M[le]?" (processing)":""]})]},le)}return Q.type==="interrupt"?c.jsx(Gw,{interruptPart:Q,onApprove:Ne,onReject:Oe},le):null},[ie,M,Ne,Oe,F,f,h,T,q]),Re=S.useCallback(()=>c.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/30 rounded",children:[c.jsx(ee.Paperclip,{className:"h-4 w-4 text-muted-foreground"}),c.jsx("span",{className:"text-sm text-muted-foreground",children:"File upload"})]}),[]),st=S.useCallback(()=>{const Q=de.trim().length>0||pe.length>0||ge.length>0||Se.length>0;if(!N&&!Q&&!r)return Re();if(t.model==="reflection"){const le=de.trim(),me=td(le);if(me&&typeof me=="object")return c.jsx(Yw,{data:me})}if(N&&se.name==="get_issues"){const le=t.content.find(we=>we.type==="tool_end"),me=(le==null?void 0:le.output)??B,Ce=rd(me);if(Ce)return c.jsx(Xw,{issues:Ce})}if(N){const le=Bw(t.content);if(le.length>0)return c.jsx("div",{className:"space-y-2",children:le.map((me,Ce)=>{const we=typeof me.output=="string"?me.output:Ki(me.output),_e=we.length>Un?`${we.slice(0,Un)}
131
+ … [truncated ${we.length-Un} chars]`:we,et=k==="expanded";return c.jsxs(Uc,{open:et,onOpenChange:Ke=>C(Ke?"expanded":"preview"),children:[c.jsx("div",{className:"flex items-center gap-2 text-xs",children:c.jsx(yi,{variant:"outline",children:(me.name??"tool")+(me.toolCallId?` • ${me.toolCallId.slice(0,8)}`:"")})}),c.jsx("div",{className:"font-mono text-sm mt-1",children:c.jsx("pre",{className:"whitespace-pre-wrap break-words",children:et?_e:_e.slice(0,d)+(_e.length>d?"...":"")})}),c.jsx(Wc,{asChild:!0,children:c.jsx(Ue,{variant:"ghost",size:"sm",className:"h-6 text-xs",children:et?c.jsxs(c.Fragment,{children:[" ",c.jsx(ee.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):c.jsxs(c.Fragment,{children:[c.jsx(ee.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more"]})})})]},me.toolCallId??Ce)})})}if(!N){const le=c.jsx("div",{className:"space-y-2",children:t.content.map((me,Ce)=>c.jsx(Qe,{part:me,i:Ce},Ce))});return r?c.jsxs("div",{"aria-busy":"true",role:"status",children:[le,c.jsx(Vw,{className:Y})]}):le}},[de,pe.length,ge.length,Se.length,r,t.model,N,se.name,B,k,u,Re,Y]),ct=S.useMemo(()=>Ww(t),[t]);return c.jsxs(c.Fragment,{children:[c.jsx("div",{className:X(Xe(),p.container),children:c.jsxs("div",{className:X(Je(),p.content),children:[(i||a||N)&&c.jsxs("div",{className:X("flex items-center justify-between mb-2 pb-2 border-b border-current/10",q&&"mb-1 pb-1",Y,p.header),children:[c.jsxs("div",{className:"flex items-center gap-2",children:[De(),a&&ct&&c.jsx("span",{className:X("font-medium",q?"text-xs":"text-sm"),children:ct}),N&&se.name&&c.jsxs(yi,{variant:"outline",className:X("text-xs flex items-center gap-1 cursor-pointer",Y,"border border-current/40",q&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":k!=="collapsed",onKeyDown:Q=>{(Q.key==="Enter"||Q.key===" ")&&(Q.preventDefault(),C(le=>le==="collapsed"?"preview":"collapsed"))},onClick:()=>C(Q=>Q==="collapsed"?"preview":"collapsed"),children:[c.jsx("span",{children:se.name}),c.jsx("span",{className:"inline-flex items-center",children:k!=="collapsed"?c.jsx(ee.ChevronUp,{className:"h-3 w-3"}):c.jsx(ee.ChevronDown,{className:"h-3 w-3"})})]}),N&&!se.name&&c.jsx(Ue,{variant:"ghost",size:"sm",className:X("h-6 px-1",Y,"hover:bg-foreground/10"),onClick:()=>C(Q=>Q==="collapsed"?"preview":"collapsed"),children:c.jsxs("span",{className:"text-xs flex items-center gap-1",children:["Tool Output ",k!=="collapsed"?c.jsx(ee.ChevronUp,{className:"h-3 w-3"}):c.jsx(ee.ChevronDown,{className:"h-3 w-3"})]})})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[i&&t.createdAt&&c.jsx("time",{className:X("text-xs opacity-60",Y,q&&"text-xs"),dateTime:new Date(t.createdAt).toISOString(),title:new Date(t.createdAt).toLocaleString(),children:new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(new Date(t.createdAt))}),s&&!o&&c.jsxs("div",{className:X("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",p.actions),children:[c.jsxs("div",{className:"relative",children:[c.jsx(Ue,{variant:"ghost",size:"sm",onClick:()=>G(N?"visible":"all"),className:X("h-6 w-6 p-0 hover:bg-foreground/10",Y,q&&"h-5 w-5"),"aria-label":N?"Copy visible":"Copy message",title:N?"Copy visible portion":"Copy message",children:c.jsx(ee.Copy,{className:X(b?"text-success":Y,q?"h-3 w-3":"h-4 w-4")})}),N&&c.jsx(Ue,{variant:"ghost",size:"sm",onClick:()=>G("all"),className:X("h-6 px-1 text-xs hover:bg-foreground/10",Y),"aria-label":"Copy all (may be large)",title:"Copy all (may be large)",children:"all"})]}),F==="user"&&w&&c.jsx(Ue,{variant:"ghost",size:"sm",onClick:Z,className:X("h-6 w-6 p-0 hover:bg-foreground/10",Y,q&&"h-5 w-5"),"aria-label":"Edit message",children:c.jsx(ee.Edit,{className:X(Y,q?"h-3 w-3":"h-4 w-4")})}),F==="assistant"&&v&&c.jsx(Ue,{variant:"ghost",size:"sm",onClick:ce,className:X("h-6 w-6 p-0 hover:bg-foreground/10",Y,q&&"h-5 w-5"),"aria-label":"Regenerate response",children:c.jsx(ee.RotateCcw,{className:X(Y,q?"h-3 w-3":"h-4 w-4")})})]})]})]}),c.jsx("div",{className:"relative",children:st()}),N&&k==="expanded"&&(se.toolCallId||se.name)&&c.jsxs("div",{className:X("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",q&&"text-xs"),children:[se.name&&c.jsxs("div",{children:["Function: ",se.name]}),se.toolCallId&&c.jsxs("div",{children:["Call ID: ",se.toolCallId]})]}),!(i||a||N)&&s&&!o&&c.jsxs("div",{className:X("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",p.actions),children:[c.jsx(Ue,{variant:"ghost",size:"sm",onClick:()=>G(),className:X("h-6 w-6 p-0 hover:bg-background/50 text-current",q&&"h-5 w-5"),children:c.jsx(ee.Copy,{className:X(b?"text-success":"text-current",q?"h-3 w-3":"h-4 w-4")})}),F==="user"&&w&&c.jsx(Ue,{variant:"ghost",size:"sm",onClick:Z,className:X("h-6 w-6 p-0 hover:bg-background/50 text-current",q&&"h-5 w-5"),children:c.jsx(ee.Edit,{className:X("text-current",q?"h-3 w-3":"h-4 w-4")})}),F==="assistant"&&v&&c.jsx(Ue,{variant:"ghost",size:"sm",onClick:ce,className:X("h-6 w-6 p-0 hover:bg-background/50 text-current",q&&"h-5 w-5"),children:c.jsx(ee.RotateCcw,{className:X("text-current",q?"h-3 w-3":"h-4 w-4")})})]})]})}),V&&c.jsx(Fw,{isOpen:L,onClose:()=>{P(!1),U(null)},fileId:V.id,fileName:V.name,mimeType:V.mimeType})]})},(e,t)=>{var i,a,l,u,d,f,h,p;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&od(e.message)===od(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateToolMessages","toolMessagePreviewLength","truncateUserMessages","userMessagePreviewLength"].every(w=>e[w]===t[w]),s=((i=e.customStyles)==null?void 0:i.container)===((a=t.customStyles)==null?void 0:a.container)&&((l=e.customStyles)==null?void 0:l.content)===((u=t.customStyles)==null?void 0:u.content)&&((d=e.customStyles)==null?void 0:d.actions)===((f=t.customStyles)==null?void 0:f.actions)&&((h=e.customStyles)==null?void 0:h.header)===((p=t.customStyles)==null?void 0:p.header);return o&&s});function Kw({data:e}){if(Array.isArray(e))return e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?c.jsx("div",{className:Qo,children:c.jsx("ul",{className:"list-disc pl-5",children:e.map((n,r)=>c.jsx("li",{children:String(n)},r))})}):c.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:Ki(e)});if(e&&typeof e=="object"){const t=Array.isArray(e.distilled_facts)?e.distilled_facts:null,n=Array.isArray(e.follow_up_queries)?e.follow_up_queries:null,r=typeof e.is_sufficient=="boolean"?e.is_sufficient:void 0;if(t||n||typeof r=="boolean")return c.jsxs("div",{className:Qo,children:[typeof r=="boolean"&&c.jsxs("p",{children:[c.jsx("strong",{children:"Is sufficient:"})," ",r?"Yes":"No"]}),n&&n.length>0&&c.jsxs("div",{children:[c.jsx("p",{children:c.jsx("strong",{children:"Follow-up queries:"})}),c.jsx("ul",{className:"list-disc pl-5",children:n.map((s,i)=>c.jsx("li",{children:String(s)},i))})]}),t&&t.length>0&&c.jsxs("div",{children:[c.jsx("p",{children:c.jsx("strong",{children:"Facts:"})}),c.jsx("ul",{className:"list-disc pl-5",children:t.map((s,i)=>c.jsx("li",{children:String(s)},i))})]})]});const o=Object.entries(e);return c.jsx("div",{className:Qo,children:c.jsx("dl",{className:"mt-0",children:o.map(([s,i])=>c.jsxs("div",{className:"mb-1",children:[c.jsxs("dt",{className:"inline font-medium mr-1",children:[s,":"]}),c.jsx("dd",{className:"inline",children:qw(i)})]},s))})})}return c.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:Ki(e)})}function qw(e){if(e==null)return String(e);const t=typeof e;if(t==="string"||t==="number"||t==="boolean")return String(e);if(Array.isArray(e)&&e.every(r=>r===null||["string","number","boolean"].includes(typeof r)))return e.join(", ");try{return c.jsx("code",{className:"text-xs",children:JSON.stringify(zr(e))})}catch{return String(e)}}function Gw({interruptPart:e,onApprove:t,onReject:n}){const r=e.title??"Approve the result?";return c.jsxs(Dr,{className:"border-blue-200 dark:border-blue-800 bg-blue-50/50 dark:bg-blue-950/10",children:[c.jsxs(Lr,{className:"pb-3",children:[c.jsx(Fr,{className:"text-blue-900 dark:text-blue-100 text-base",children:r}),c.jsx(Vc,{className:"text-blue-700 dark:text-blue-300",children:"Please approve or reject this action to continue."})]}),c.jsx(Kc,{className:"pt-0",children:c.jsxs("div",{className:"flex gap-2 ml-auto",children:[c.jsx(Ue,{size:"sm",variant:"outline",onClick:()=>n(e),className:"border-red-300 text-red-700 hover:bg-red-50 dark:border-red-700 dark:text-red-300 dark:hover:bg-red-950/50",children:"Reject"}),c.jsx(Ue,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",children:"Approve"})]})})]})}function Yw({data:e}){return c.jsx("dl",{className:"grid grid-cols-1 gap-y-2",children:Object.entries(e).map(([t,n])=>c.jsxs("div",{className:"flex",children:[c.jsxs("dt",{className:"font-semibold mr-2",children:[t,":"]}),c.jsx("dd",{className:"flex-1 break-words",children:Array.isArray(n)?n.map((r,o)=>c.jsxs("div",{className:"ml-4 break-words",children:["- ",String(r)]},o)):String(n)})]},t))})}function Xw({issues:e}){const t=[{key:"desirability",title:"Desirability"},{key:"feasibility",title:"Feasibility"},{key:"viability",title:"Viability"},{key:"other",title:"Other"}];return c.jsx("div",{className:Qo,children:t.map(n=>{const r=e[n.key];return!r||!r.length?null:c.jsxs("div",{className:"mb-4",children:[c.jsxs("h4",{className:"font-semibold mb-2",children:[n.title," (",r.length,")"]}),c.jsx("ol",{className:"list-decimal pl-5 space-y-2",children:r.map((o,s)=>c.jsxs("li",{children:[c.jsx("div",{className:"font-medium",children:o.title}),c.jsx("div",{className:"text-sm text-muted-foreground",children:o.description})]},s))})]},n.key)})})}const id=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,qi=S.forwardRef(({messages:e,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onStartReached:a,onEdit:l,onRegenerate:u,onCancelEdit:d,className:f,style:h,emptyMessage:p,followNewMessages:w=!0,isNavigatingCheckpoint:v=!1,onScrollAway:g,onAtBottom:x},b)=>{const y=S.useRef(null),k=S.useRef(null),C=S.useRef(!1),[T,I]=S.useState(!0),A=S.useCallback(M=>{I(M),g&&g(!M),x&&x(M)},[g,x]),R=S.useMemo(()=>{if(a)return async()=>{if(!C.current){C.current=!0;try{await a()}finally{C.current=!1}}}},[a]),j=S.useMemo(()=>!w||v?!1:T?"auto":!1,[T,w,v]);return e.length===0?c.jsx("div",{className:f,style:h,children:c.jsx("div",{className:"flex items-center justify-center py-8 text-muted-foreground text-center max-w-md mx-auto",children:p||"No messages yet. Start a conversation!"})}):c.jsx("div",{className:f,style:h,children:c.jsx(Sx,{ref:M=>{y.current=M},scrollerRef:M=>{k.current=M instanceof HTMLDivElement?M:null},data:e,followOutput:j,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,alignToBottom:!1,startReached:()=>{R&&R()},atBottomStateChange:A,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(M,D)=>id(D,M),itemContent:(M,D)=>{const L=id(D,M);return c.jsx("div",{className:"mb-4 last:mb-0","data-message-id":L,style:{minHeight:"60px",containIntrinsicSize:"auto 120px"},children:c.jsx(sd,{message:D,messageIndex:M,isStreamingMessage:t&&n===D.id,streamingDebounceMs:r,isEditing:i===D.id,showActions:s,showTimestamp:!1,showAgentName:!0,layoutSize:o,truncateToolMessages:!1,toolMessagePreviewLength:200,onEdit:l,onRegenerate:()=>u(M),onCancelEdit:d})})}})})});qi.displayName="MessageList";const es=1e4;function Jw(e){if(typeof e!="string")return String(e);const t=[/<script[^>]*>.*?<\/script>/gi,/<iframe[^>]*>.*?<\/iframe>/gi,/javascript:/gi,/vbscript:/gi,/on\w+\s*=/gi,/<object[^>]*>.*?<\/object>/gi,/<embed[^>]*>.*?<\/embed>/gi,/<form[^>]*>.*?<\/form>/gi];let n=e;for(const o of t)n=n.replace(o,"");return/<[^>]+>/.test(n)&&!/<(?!\/?(?:code|strong|em|b|i|br|p|ul|ol|li|h[1-6])\b)[^>]+>/i.test(n)?n.replace(/<code>(.*?)<\/code>/gi,"`$1`").replace(/<strong>(.*?)<\/strong>/gi,"**$1**").replace(/<b>(.*?)<\/b>/gi,"**$1**").replace(/<em>(.*?)<\/em>/gi,"*$1*").replace(/<i>(.*?)<\/i>/gi,"*$1*").replace(/<br\s*\/?>/gi,`
132
132
  `).replace(/<p>(.*?)<\/p>/gi,`$1
133
133
 
134
134
  `).replace(/<h([1-6])>(.*?)<\/h[1-6]>/gi,(o,s,i)=>`${"#".repeat(parseInt(s))} ${i}
@@ -136,4 +136,4 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
136
136
  `).replace(/<ul>/gi,"").replace(/<\/ul>/gi,`
137
137
  `).replace(/<ol>/gi,"").replace(/<\/ol>/gi,`
138
138
  `).replace(/<li>(.*?)<\/li>/gi,`- $1
139
- `).trim():n.replace(/</g,"&lt;").replace(/>/g,"&gt;").trim()}function Zw(e,t=es){if(!e||typeof e!="string")throw new Error("Invalid content: must be a non-empty string");if(e.length>t)throw new Error(`Message exceeds maximum length of ${t} characters`);return e}function Qw(e){let t;return typeof e=="string"?t=e:typeof e=="object"&&e!==null?t=JSON.stringify(e):t=String(e),Zw(t),Jw(t)}function Gi(e){const t=e+"CollectionProvider",[n,r]=en(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=v=>{const{scope:g,children:x}=v,b=S.useRef(null),y=S.useRef(new Map).current;return c.jsx(o,{scope:g,itemMap:y,collectionRef:b,children:x})};i.displayName=t;const a=e+"CollectionSlot",l=_n.createSlot(a),u=S.forwardRef((v,g)=>{const{scope:x,children:b}=v,y=s(a,x),E=Fe(g,y.collectionRef);return c.jsx(l,{ref:E,children:b})});u.displayName=a;const d=e+"CollectionItemSlot",f="data-radix-collection-item",h=_n.createSlot(d),p=S.forwardRef((v,g)=>{const{scope:x,children:b,...y}=v,E=S.useRef(null),C=Fe(g,E),T=s(d,x);return S.useEffect(()=>(T.itemMap.set(E,{ref:E,...y}),()=>void T.itemMap.delete(E))),c.jsx(h,{[f]:"",ref:C,children:b})});p.displayName=d;function w(v){const g=s(e+"CollectionConsumer",v);return S.useCallback(()=>{const b=g.collectionRef.current;if(!b)return[];const y=Array.from(b.querySelectorAll(`[${f}]`));return Array.from(g.itemMap.values()).sort((T,I)=>y.indexOf(T.ref.current)-y.indexOf(I.ref.current))},[g.collectionRef,g.itemMap])}return[{Provider:i,Slot:u,ItemSlot:p},w,r]}var eb=m.createContext(void 0);function ts(e){const t=m.useContext(eb);return e||t||"ltr"}const tb=["top","right","bottom","left"],kn=Math.min,Rt=Math.max,ns=Math.round,rs=Math.floor,rn=e=>({x:e,y:e}),nb={left:"right",right:"left",bottom:"top",top:"bottom"},rb={start:"end",end:"start"};function Yi(e,t,n){return Rt(e,kn(t,n))}function pn(e,t){return typeof e=="function"?e(t):e}function mn(e){return e.split("-")[0]}function cr(e){return e.split("-")[1]}function Xi(e){return e==="x"?"y":"x"}function Ji(e){return e==="y"?"height":"width"}const ob=new Set(["top","bottom"]);function on(e){return ob.has(mn(e))?"y":"x"}function Zi(e){return Xi(on(e))}function sb(e,t,n){n===void 0&&(n=!1);const r=cr(e),o=Zi(e),s=Ji(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=os(i)),[i,os(i)]}function ib(e){const t=os(e);return[Qi(e),t,Qi(t)]}function Qi(e){return e.replace(/start|end/g,t=>rb[t])}const ad=["left","right"],ld=["right","left"],ab=["top","bottom"],lb=["bottom","top"];function cb(e,t,n){switch(e){case"top":case"bottom":return n?t?ld:ad:t?ad:ld;case"left":case"right":return t?ab:lb;default:return[]}}function ub(e,t,n,r){const o=cr(e);let s=cb(mn(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(Qi)))),s}function os(e){return e.replace(/left|right|bottom|top/g,t=>nb[t])}function db(e){return{top:0,right:0,bottom:0,left:0,...e}}function cd(e){return typeof e!="number"?db(e):{top:e,right:e,bottom:e,left:e}}function ss(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}function ud(e,t,n){let{reference:r,floating:o}=e;const s=on(t),i=Zi(t),a=Ji(i),l=mn(t),u=s==="y",d=r.x+r.width/2-o.width/2,f=r.y+r.height/2-o.height/2,h=r[a]/2-o[a]/2;let p;switch(l){case"top":p={x:d,y:r.y-o.height};break;case"bottom":p={x:d,y:r.y+r.height};break;case"right":p={x:r.x+r.width,y:f};break;case"left":p={x:r.x-o.width,y:f};break;default:p={x:r.x,y:r.y}}switch(cr(t)){case"start":p[i]-=h*(n&&u?-1:1);break;case"end":p[i]+=h*(n&&u?-1:1);break}return p}const fb=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=n,a=s.filter(Boolean),l=await(i.isRTL==null?void 0:i.isRTL(t));let u=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:d,y:f}=ud(u,r,l),h=r,p={},w=0;for(let v=0;v<a.length;v++){const{name:g,fn:x}=a[v],{x:b,y,data:E,reset:C}=await x({x:d,y:f,initialPlacement:r,placement:h,strategy:o,middlewareData:p,rects:u,platform:i,elements:{reference:e,floating:t}});d=b??d,f=y??f,p={...p,[g]:{...p[g],...E}},C&&w<=50&&(w++,typeof C=="object"&&(C.placement&&(h=C.placement),C.rects&&(u=C.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):C.rects),{x:d,y:f}=ud(u,h,l)),v=-1)}return{x:d,y:f,placement:h,strategy:o,middlewareData:p}};async function Br(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:i,elements:a,strategy:l}=e,{boundary:u="clippingAncestors",rootBoundary:d="viewport",elementContext:f="floating",altBoundary:h=!1,padding:p=0}=pn(t,e),w=cd(p),g=a[h?f==="floating"?"reference":"floating":f],x=ss(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(g)))==null||n?g:g.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:u,rootBoundary:d,strategy:l})),b=f==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,y=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),E=await(s.isElement==null?void 0:s.isElement(y))?await(s.getScale==null?void 0:s.getScale(y))||{x:1,y:1}:{x:1,y:1},C=ss(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:b,offsetParent:y,strategy:l}):b);return{top:(x.top-C.top+w.top)/E.y,bottom:(C.bottom-x.bottom+w.bottom)/E.y,left:(x.left-C.left+w.left)/E.x,right:(C.right-x.right+w.right)/E.x}}const hb=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:s,platform:i,elements:a,middlewareData:l}=t,{element:u,padding:d=0}=pn(e,t)||{};if(u==null)return{};const f=cd(d),h={x:n,y:r},p=Zi(o),w=Ji(p),v=await i.getDimensions(u),g=p==="y",x=g?"top":"left",b=g?"bottom":"right",y=g?"clientHeight":"clientWidth",E=s.reference[w]+s.reference[p]-h[p]-s.floating[w],C=h[p]-s.reference[p],T=await(i.getOffsetParent==null?void 0:i.getOffsetParent(u));let I=T?T[y]:0;(!I||!await(i.isElement==null?void 0:i.isElement(T)))&&(I=a.floating[y]||s.floating[w]);const A=E/2-C/2,R=I/2-v[w]/2-1,j=kn(f[x],R),M=kn(f[b],R),D=j,L=I-v[w]-M,P=I/2-v[w]/2+A,V=Yi(D,P,L),U=!l.arrow&&cr(o)!=null&&P!==V&&s.reference[w]/2-(P<D?j:M)-v[w]/2<0,q=U?P<D?P-D:P-L:0;return{[p]:h[p]+q,data:{[p]:V,centerOffset:P-V-q,...U&&{alignmentOffset:q}},reset:U}}}),pb=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:s,rects:i,initialPlacement:a,platform:l,elements:u}=t,{mainAxis:d=!0,crossAxis:f=!0,fallbackPlacements:h,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:w="none",flipAlignment:v=!0,...g}=pn(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const x=mn(o),b=on(a),y=mn(a)===a,E=await(l.isRTL==null?void 0:l.isRTL(u.floating)),C=h||(y||!v?[os(a)]:ib(a)),T=w!=="none";!h&&T&&C.push(...ub(a,v,w,E));const I=[a,...C],A=await Br(t,g),R=[];let j=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&R.push(A[x]),f){const P=sb(o,i,E);R.push(A[P[0]],A[P[1]])}if(j=[...j,{placement:o,overflows:R}],!R.every(P=>P<=0)){var M,D;const P=(((M=s.flip)==null?void 0:M.index)||0)+1,V=I[P];if(V&&(!(f==="alignment"?b!==on(V):!1)||j.every($=>on($.placement)===b?$.overflows[0]>0:!0)))return{data:{index:P,overflows:j},reset:{placement:V}};let U=(D=j.filter(q=>q.overflows[0]<=0).sort((q,$)=>q.overflows[1]-$.overflows[1])[0])==null?void 0:D.placement;if(!U)switch(p){case"bestFit":{var L;const q=(L=j.filter($=>{if(T){const N=on($.placement);return N===b||N==="y"}return!0}).map($=>[$.placement,$.overflows.filter(N=>N>0).reduce((N,W)=>N+W,0)]).sort(($,N)=>$[1]-N[1])[0])==null?void 0:L[0];q&&(U=q);break}case"initialPlacement":U=a;break}if(o!==U)return{reset:{placement:U}}}return{}}}};function dd(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function fd(e){return tb.some(t=>e[t]>=0)}const mb=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=pn(e,t);switch(r){case"referenceHidden":{const s=await Br(t,{...o,elementContext:"reference"}),i=dd(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:fd(i)}}}case"escaped":{const s=await Br(t,{...o,altBoundary:!0}),i=dd(s,n.floating);return{data:{escapedOffsets:i,escaped:fd(i)}}}default:return{}}}}},hd=new Set(["left","top"]);async function gb(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=mn(n),a=cr(n),l=on(n)==="y",u=hd.has(i)?-1:1,d=s&&l?-1:1,f=pn(t,e);let{mainAxis:h,crossAxis:p,alignmentAxis:w}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof w=="number"&&(p=a==="end"?w*-1:w),l?{x:p*d,y:h*u}:{x:h*u,y:p*d}}const xb=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:s,placement:i,middlewareData:a}=t,l=await gb(t,e);return i===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:o+l.x,y:s+l.y,data:{...l,placement:i}}}}},vb=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o}=t,{mainAxis:s=!0,crossAxis:i=!1,limiter:a={fn:g=>{let{x,y:b}=g;return{x,y:b}}},...l}=pn(e,t),u={x:n,y:r},d=await Br(t,l),f=on(mn(o)),h=Xi(f);let p=u[h],w=u[f];if(s){const g=h==="y"?"top":"left",x=h==="y"?"bottom":"right",b=p+d[g],y=p-d[x];p=Yi(b,p,y)}if(i){const g=f==="y"?"top":"left",x=f==="y"?"bottom":"right",b=w+d[g],y=w-d[x];w=Yi(b,w,y)}const v=a.fn({...t,[h]:p,[f]:w});return{...v,data:{x:v.x-n,y:v.y-r,enabled:{[h]:s,[f]:i}}}}}},wb=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:s,middlewareData:i}=t,{offset:a=0,mainAxis:l=!0,crossAxis:u=!0}=pn(e,t),d={x:n,y:r},f=on(o),h=Xi(f);let p=d[h],w=d[f];const v=pn(a,t),g=typeof v=="number"?{mainAxis:v,crossAxis:0}:{mainAxis:0,crossAxis:0,...v};if(l){const y=h==="y"?"height":"width",E=s.reference[h]-s.floating[y]+g.mainAxis,C=s.reference[h]+s.reference[y]-g.mainAxis;p<E?p=E:p>C&&(p=C)}if(u){var x,b;const y=h==="y"?"width":"height",E=hd.has(mn(o)),C=s.reference[f]-s.floating[y]+(E&&((x=i.offset)==null?void 0:x[f])||0)+(E?0:g.crossAxis),T=s.reference[f]+s.reference[y]+(E?0:((b=i.offset)==null?void 0:b[f])||0)-(E?g.crossAxis:0);w<C?w=C:w>T&&(w=T)}return{[h]:p,[f]:w}}}},bb=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:s,platform:i,elements:a}=t,{apply:l=()=>{},...u}=pn(e,t),d=await Br(t,u),f=mn(o),h=cr(o),p=on(o)==="y",{width:w,height:v}=s.floating;let g,x;f==="top"||f==="bottom"?(g=f,x=h===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(x=f,g=h==="end"?"top":"bottom");const b=v-d.top-d.bottom,y=w-d.left-d.right,E=kn(v-d[g],b),C=kn(w-d[x],y),T=!t.middlewareData.shift;let I=E,A=C;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(A=y),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(I=b),T&&!h){const j=Rt(d.left,0),M=Rt(d.right,0),D=Rt(d.top,0),L=Rt(d.bottom,0);p?A=w-2*(j!==0||M!==0?j+M:Rt(d.left,d.right)):I=v-2*(D!==0||L!==0?D+L:Rt(d.top,d.bottom))}await l({...t,availableWidth:A,availableHeight:I});const R=await i.getDimensions(a.floating);return w!==R.width||v!==R.height?{reset:{rects:!0}}:{}}}};function is(){return typeof window<"u"}function ur(e){return pd(e)?(e.nodeName||"").toLowerCase():"#document"}function Pt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function sn(e){var t;return(t=(pd(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function pd(e){return is()?e instanceof Node||e instanceof Pt(e).Node:!1}function qt(e){return is()?e instanceof Element||e instanceof Pt(e).Element:!1}function an(e){return is()?e instanceof HTMLElement||e instanceof Pt(e).HTMLElement:!1}function md(e){return!is()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Pt(e).ShadowRoot}const yb=new Set(["inline","contents"]);function Hr(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=Gt(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!yb.has(o)}const Sb=new Set(["table","td","th"]);function Cb(e){return Sb.has(ur(e))}const Tb=[":popover-open",":modal"];function as(e){return Tb.some(t=>{try{return e.matches(t)}catch{return!1}})}const kb=["transform","translate","scale","rotate","perspective"],Eb=["transform","translate","scale","rotate","perspective","filter"],Ib=["paint","layout","strict","content"];function ea(e){const t=ta(),n=qt(e)?Gt(e):e;return kb.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)||Eb.some(r=>(n.willChange||"").includes(r))||Ib.some(r=>(n.contain||"").includes(r))}function Nb(e){let t=En(e);for(;an(t)&&!dr(t);){if(ea(t))return t;if(as(t))return null;t=En(t)}return null}function ta(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Ab=new Set(["html","body","#document"]);function dr(e){return Ab.has(ur(e))}function Gt(e){return Pt(e).getComputedStyle(e)}function ls(e){return qt(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function En(e){if(ur(e)==="html")return e;const t=e.assignedSlot||e.parentNode||md(e)&&e.host||sn(e);return md(t)?t.host:t}function gd(e){const t=En(e);return dr(t)?e.ownerDocument?e.ownerDocument.body:e.body:an(t)&&Hr(t)?t:gd(t)}function Ur(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=gd(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Pt(o);if(s){const a=na(i);return t.concat(i,i.visualViewport||[],Hr(o)?o:[],a&&n?Ur(a):[])}return t.concat(o,Ur(o,[],n))}function na(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function xd(e){const t=Gt(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=an(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=ns(n)!==s||ns(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function ra(e){return qt(e)?e:e.contextElement}function fr(e){const t=ra(e);if(!an(t))return rn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=xd(t);let i=(s?ns(n.width):n.width)/r,a=(s?ns(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const jb=rn(0);function vd(e){const t=Pt(e);return!ta()||!t.visualViewport?jb:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function _b(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Pt(e)?!1:t}function Wn(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=ra(e);let i=rn(1);t&&(r?qt(r)&&(i=fr(r)):i=fr(e));const a=_b(s,n,r)?vd(s):rn(0);let l=(o.left+a.x)/i.x,u=(o.top+a.y)/i.y,d=o.width/i.x,f=o.height/i.y;if(s){const h=Pt(s),p=r&&qt(r)?Pt(r):r;let w=h,v=na(w);for(;v&&r&&p!==w;){const g=fr(v),x=v.getBoundingClientRect(),b=Gt(v),y=x.left+(v.clientLeft+parseFloat(b.paddingLeft))*g.x,E=x.top+(v.clientTop+parseFloat(b.paddingTop))*g.y;l*=g.x,u*=g.y,d*=g.x,f*=g.y,l+=y,u+=E,w=Pt(v),v=na(w)}}return ss({width:d,height:f,x:l,y:u})}function oa(e,t){const n=ls(e).scrollLeft;return t?t.left+n:Wn(sn(e)).left+n}function wd(e,t,n){n===void 0&&(n=!1);const r=e.getBoundingClientRect(),o=r.left+t.scrollLeft-(n?0:oa(e,r)),s=r.top+t.scrollTop;return{x:o,y:s}}function Rb(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=sn(r),a=t?as(t.floating):!1;if(r===i||a&&s)return n;let l={scrollLeft:0,scrollTop:0},u=rn(1);const d=rn(0),f=an(r);if((f||!f&&!s)&&((ur(r)!=="body"||Hr(i))&&(l=ls(r)),an(r))){const p=Wn(r);u=fr(r),d.x=p.x+r.clientLeft,d.y=p.y+r.clientTop}const h=i&&!f&&!s?wd(i,l,!0):rn(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-l.scrollLeft*u.x+d.x+h.x,y:n.y*u.y-l.scrollTop*u.y+d.y+h.y}}function Pb(e){return Array.from(e.getClientRects())}function Ob(e){const t=sn(e),n=ls(e),r=e.ownerDocument.body,o=Rt(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Rt(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+oa(e);const a=-n.scrollTop;return Gt(r).direction==="rtl"&&(i+=Rt(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}function Mb(e,t){const n=Pt(e),r=sn(e),o=n.visualViewport;let s=r.clientWidth,i=r.clientHeight,a=0,l=0;if(o){s=o.width,i=o.height;const u=ta();(!u||u&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}return{width:s,height:i,x:a,y:l}}const Db=new Set(["absolute","fixed"]);function Lb(e,t){const n=Wn(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=an(e)?fr(e):rn(1),i=e.clientWidth*s.x,a=e.clientHeight*s.y,l=o*s.x,u=r*s.y;return{width:i,height:a,x:l,y:u}}function bd(e,t,n){let r;if(t==="viewport")r=Mb(e,n);else if(t==="document")r=Ob(sn(e));else if(qt(t))r=Lb(t,n);else{const o=vd(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return ss(r)}function yd(e,t){const n=En(e);return n===t||!qt(n)||dr(n)?!1:Gt(n).position==="fixed"||yd(n,t)}function Fb(e,t){const n=t.get(e);if(n)return n;let r=Ur(e,[],!1).filter(a=>qt(a)&&ur(a)!=="body"),o=null;const s=Gt(e).position==="fixed";let i=s?En(e):e;for(;qt(i)&&!dr(i);){const a=Gt(i),l=ea(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&Db.has(o.position)||Hr(i)&&!l&&yd(e,i))?r=r.filter(d=>d!==i):o=a,i=En(i)}return t.set(e,r),r}function $b(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?as(t)?[]:Fb(t,this._c):[].concat(n),r],a=i[0],l=i.reduce((u,d)=>{const f=bd(t,d,o);return u.top=Rt(f.top,u.top),u.right=kn(f.right,u.right),u.bottom=kn(f.bottom,u.bottom),u.left=Rt(f.left,u.left),u},bd(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function zb(e){const{width:t,height:n}=xd(e);return{width:t,height:n}}function Bb(e,t,n){const r=an(t),o=sn(t),s=n==="fixed",i=Wn(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=rn(0);function u(){l.x=oa(o)}if(r||!r&&!s)if((ur(t)!=="body"||Hr(o))&&(a=ls(t)),r){const p=Wn(t,!0,s,t);l.x=p.x+t.clientLeft,l.y=p.y+t.clientTop}else o&&u();s&&!r&&o&&u();const d=o&&!r&&!s?wd(o,a):rn(0),f=i.left+a.scrollLeft-l.x-d.x,h=i.top+a.scrollTop-l.y-d.y;return{x:f,y:h,width:i.width,height:i.height}}function sa(e){return Gt(e).position==="static"}function Sd(e,t){if(!an(e)||Gt(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return sn(e)===n&&(n=n.ownerDocument.body),n}function Cd(e,t){const n=Pt(e);if(as(e))return n;if(!an(e)){let o=En(e);for(;o&&!dr(o);){if(qt(o)&&!sa(o))return o;o=En(o)}return n}let r=Sd(e,t);for(;r&&Cb(r)&&sa(r);)r=Sd(r,t);return r&&dr(r)&&sa(r)&&!ea(r)?n:r||Nb(e)||n}const Hb=async function(e){const t=this.getOffsetParent||Cd,n=this.getDimensions,r=await n(e.floating);return{reference:Bb(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Ub(e){return Gt(e).direction==="rtl"}const Wb={convertOffsetParentRelativeRectToViewportRelativeRect:Rb,getDocumentElement:sn,getClippingRect:$b,getOffsetParent:Cd,getElementRects:Hb,getClientRects:Pb,getDimensions:zb,getScale:fr,isElement:qt,isRTL:Ub};function Td(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Vb(e,t){let n=null,r;const o=sn(e);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),s();const u=e.getBoundingClientRect(),{left:d,top:f,width:h,height:p}=u;if(a||t(),!h||!p)return;const w=rs(f),v=rs(o.clientWidth-(d+h)),g=rs(o.clientHeight-(f+p)),x=rs(d),y={rootMargin:-w+"px "+-v+"px "+-g+"px "+-x+"px",threshold:Rt(0,kn(1,l))||1};let E=!0;function C(T){const I=T[0].intersectionRatio;if(I!==l){if(!E)return i();I?i(!1,I):r=setTimeout(()=>{i(!1,1e-7)},1e3)}I===1&&!Td(u,e.getBoundingClientRect())&&i(),E=!1}try{n=new IntersectionObserver(C,{...y,root:o.ownerDocument})}catch{n=new IntersectionObserver(C,y)}n.observe(e)}return i(!0),s}function Kb(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,u=ra(e),d=o||s?[...u?Ur(u):[],...Ur(t)]:[];d.forEach(x=>{o&&x.addEventListener("scroll",n,{passive:!0}),s&&x.addEventListener("resize",n)});const f=u&&a?Vb(u,n):null;let h=-1,p=null;i&&(p=new ResizeObserver(x=>{let[b]=x;b&&b.target===u&&p&&(p.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var y;(y=p)==null||y.observe(t)})),n()}),u&&!l&&p.observe(u),p.observe(t));let w,v=l?Wn(e):null;l&&g();function g(){const x=Wn(e);v&&!Td(v,x)&&n(),v=x,w=requestAnimationFrame(g)}return n(),()=>{var x;d.forEach(b=>{o&&b.removeEventListener("scroll",n),s&&b.removeEventListener("resize",n)}),f==null||f(),(x=p)==null||x.disconnect(),p=null,l&&cancelAnimationFrame(w)}}const qb=xb,Gb=vb,Yb=pb,Xb=bb,Jb=mb,kd=hb,Zb=wb,Qb=(e,t,n)=>{const r=new Map,o={platform:Wb,...n},s={...o.platform,_c:r};return fb(e,t,{...o,platform:s})};var ey=typeof document<"u",ty=function(){},cs=ey?S.useLayoutEffect:ty;function us(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!us(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){const s=o[r];if(!(s==="_owner"&&e.$$typeof)&&!us(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function Ed(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Id(e,t){const n=Ed(e);return Math.round(t*n)/n}function ia(e){const t=m.useRef(e);return cs(()=>{t.current=e}),t}function ny(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:i}={},transform:a=!0,whileElementsMounted:l,open:u}=e,[d,f]=m.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[h,p]=m.useState(r);us(h,r)||p(r);const[w,v]=m.useState(null),[g,x]=m.useState(null),b=m.useCallback($=>{$!==T.current&&(T.current=$,v($))},[]),y=m.useCallback($=>{$!==I.current&&(I.current=$,x($))},[]),E=s||w,C=i||g,T=m.useRef(null),I=m.useRef(null),A=m.useRef(d),R=l!=null,j=ia(l),M=ia(o),D=ia(u),L=m.useCallback(()=>{if(!T.current||!I.current)return;const $={placement:t,strategy:n,middleware:h};M.current&&($.platform=M.current),Qb(T.current,I.current,$).then(N=>{const W={...N,isPositioned:D.current!==!1};P.current&&!us(A.current,W)&&(A.current=W,eo.flushSync(()=>{f(W)}))})},[h,t,n,M,D]);cs(()=>{u===!1&&A.current.isPositioned&&(A.current.isPositioned=!1,f($=>({...$,isPositioned:!1})))},[u]);const P=m.useRef(!1);cs(()=>(P.current=!0,()=>{P.current=!1}),[]),cs(()=>{if(E&&(T.current=E),C&&(I.current=C),E&&C){if(j.current)return j.current(E,C,L);L()}},[E,C,L,j,R]);const V=m.useMemo(()=>({reference:T,floating:I,setReference:b,setFloating:y}),[b,y]),U=m.useMemo(()=>({reference:E,floating:C}),[E,C]),q=m.useMemo(()=>{const $={position:n,left:0,top:0};if(!U.floating)return $;const N=Id(U.floating,d.x),W=Id(U.floating,d.y);return a?{...$,transform:"translate("+N+"px, "+W+"px)",...Ed(U.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:N,top:W}},[n,a,U.floating,d.x,d.y]);return m.useMemo(()=>({...d,update:L,refs:V,elements:U,floatingStyles:q}),[d,L,V,U,q])}const ry=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:o}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?kd({element:r.current,padding:o}).fn(n):{}:r?kd({element:r,padding:o}).fn(n):{}}}},oy=(e,t)=>({...qb(e),options:[e,t]}),sy=(e,t)=>({...Gb(e),options:[e,t]}),iy=(e,t)=>({...Zb(e),options:[e,t]}),ay=(e,t)=>({...Yb(e),options:[e,t]}),ly=(e,t)=>({...Xb(e),options:[e,t]}),cy=(e,t)=>({...Jb(e),options:[e,t]}),uy=(e,t)=>({...ry(e),options:[e,t]});var dy="Arrow",Nd=m.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return c.jsx(ye.svg,{...s,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:c.jsx("polygon",{points:"0,0 30,0 15,10"})})});Nd.displayName=dy;var fy=Nd;function Ad(e){const[t,n]=m.useState(void 0);return pt(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const s=o[0];let i,a;if("borderBoxSize"in s){const l=s.borderBoxSize,u=Array.isArray(l)?l[0]:l;i=u.inlineSize,a=u.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var aa="Popper",[jd,ds]=en(aa),[hy,_d]=jd(aa),Rd=e=>{const{__scopePopper:t,children:n}=e,[r,o]=m.useState(null);return c.jsx(hy,{scope:t,anchor:r,onAnchorChange:o,children:n})};Rd.displayName=aa;var Pd="PopperAnchor",Od=m.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=_d(Pd,n),i=m.useRef(null),a=Fe(t,i),l=m.useRef(null);return m.useEffect(()=>{const u=l.current;l.current=(r==null?void 0:r.current)||i.current,u!==l.current&&s.onAnchorChange(l.current)}),r?null:c.jsx(ye.div,{...o,ref:a})});Od.displayName=Pd;var la="PopperContent",[py,my]=jd(la),Md=m.forwardRef((e,t)=>{var B,O,G,Z,ce,ie;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:a=0,avoidCollisions:l=!0,collisionBoundary:u=[],collisionPadding:d=0,sticky:f="partial",hideWhenDetached:h=!1,updatePositionStrategy:p="optimized",onPlaced:w,...v}=e,g=_d(la,n),[x,b]=m.useState(null),y=Fe(t,De=>b(De)),[E,C]=m.useState(null),T=Ad(E),I=(T==null?void 0:T.width)??0,A=(T==null?void 0:T.height)??0,R=r+(s!=="center"?"-"+s:""),j=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},M=Array.isArray(u)?u:[u],D=M.length>0,L={padding:j,boundary:M.filter(xy),altBoundary:D},{refs:P,floatingStyles:V,placement:U,isPositioned:q,middlewareData:$}=ny({strategy:"fixed",placement:R,whileElementsMounted:(...De)=>Kb(...De,{animationFrame:p==="always"}),elements:{reference:g.anchor},middleware:[oy({mainAxis:o+A,alignmentAxis:i}),l&&sy({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?iy():void 0,...L}),l&&ay({...L}),ly({...L,apply:({elements:De,rects:Xe,availableWidth:Je,availableHeight:Ne})=>{const{width:Oe,height:Qe}=Xe.reference,Re=De.floating.style;Re.setProperty("--radix-popper-available-width",`${Je}px`),Re.setProperty("--radix-popper-available-height",`${Ne}px`),Re.setProperty("--radix-popper-anchor-width",`${Oe}px`),Re.setProperty("--radix-popper-anchor-height",`${Qe}px`)}}),E&&uy({element:E,padding:a}),vy({arrowWidth:I,arrowHeight:A}),h&&cy({strategy:"referenceHidden",...L})]}),[N,W]=Fd(U),Y=mt(w);pt(()=>{q&&(Y==null||Y())},[q,Y]);const de=(B=$.arrow)==null?void 0:B.x,se=(O=$.arrow)==null?void 0:O.y,pe=((G=$.arrow)==null?void 0:G.centerOffset)!==0,[me,Se]=m.useState();return pt(()=>{x&&Se(window.getComputedStyle(x).zIndex)},[x]),c.jsx("div",{ref:P.setFloating,"data-radix-popper-content-wrapper":"",style:{...V,transform:q?V.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:me,"--radix-popper-transform-origin":[(Z=$.transformOrigin)==null?void 0:Z.x,(ce=$.transformOrigin)==null?void 0:ce.y].join(" "),...((ie=$.hide)==null?void 0:ie.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:c.jsx(py,{scope:n,placedSide:N,onArrowChange:C,arrowX:de,arrowY:se,shouldHideArrow:pe,children:c.jsx(ye.div,{"data-side":N,"data-align":W,...v,ref:y,style:{...v.style,animation:q?void 0:"none"}})})})});Md.displayName=la;var Dd="PopperArrow",gy={top:"bottom",right:"left",bottom:"top",left:"right"},Ld=m.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=my(Dd,r),i=gy[s.placedSide];return c.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:c.jsx(fy,{...o,ref:n,style:{...o.style,display:"block"}})})});Ld.displayName=Dd;function xy(e){return e!==null}var vy=e=>({name:"transformOrigin",options:e,fn(t){var g,x,b;const{placement:n,rects:r,middlewareData:o}=t,i=((g=o.arrow)==null?void 0:g.centerOffset)!==0,a=i?0:e.arrowWidth,l=i?0:e.arrowHeight,[u,d]=Fd(n),f={start:"0%",center:"50%",end:"100%"}[d],h=(((x=o.arrow)==null?void 0:x.x)??0)+a/2,p=(((b=o.arrow)==null?void 0:b.y)??0)+l/2;let w="",v="";return u==="bottom"?(w=i?f:`${h}px`,v=`${-l}px`):u==="top"?(w=i?f:`${h}px`,v=`${r.floating.height+l}px`):u==="right"?(w=`${-l}px`,v=i?f:`${p}px`):u==="left"&&(w=`${r.floating.width+l}px`,v=i?f:`${p}px`),{data:{x:w,y:v}}}});function Fd(e){const[t,n="center"]=e.split("-");return[t,n]}var $d=Rd,zd=Od,Bd=Md,Hd=Ld,ca="rovingFocusGroup.onEntryFocus",wy={bubbles:!1,cancelable:!0},Wr="RovingFocusGroup",[ua,Ud,by]=Gi(Wr),[yy,Wd]=en(Wr,[by]),[Sy,Cy]=yy(Wr),Vd=m.forwardRef((e,t)=>c.jsx(ua.Provider,{scope:e.__scopeRovingFocusGroup,children:c.jsx(ua.Slot,{scope:e.__scopeRovingFocusGroup,children:c.jsx(Ty,{...e,ref:t})})}));Vd.displayName=Wr;var Ty=m.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:u,preventScrollOnEntryFocus:d=!1,...f}=e,h=m.useRef(null),p=Fe(t,h),w=ts(s),[v,g]=$n({prop:i,defaultProp:a??null,onChange:l,caller:Wr}),[x,b]=m.useState(!1),y=mt(u),E=Ud(n),C=m.useRef(!1),[T,I]=m.useState(0);return m.useEffect(()=>{const A=h.current;if(A)return A.addEventListener(ca,y),()=>A.removeEventListener(ca,y)},[y]),c.jsx(Sy,{scope:n,orientation:r,dir:w,loop:o,currentTabStopId:v,onItemFocus:m.useCallback(A=>g(A),[g]),onItemShiftTab:m.useCallback(()=>b(!0),[]),onFocusableItemAdd:m.useCallback(()=>I(A=>A+1),[]),onFocusableItemRemove:m.useCallback(()=>I(A=>A-1),[]),children:c.jsx(ye.div,{tabIndex:x||T===0?-1:0,"data-orientation":r,...f,ref:p,style:{outline:"none",...e.style},onMouseDown:oe(e.onMouseDown,()=>{C.current=!0}),onFocus:oe(e.onFocus,A=>{const R=!C.current;if(A.target===A.currentTarget&&R&&!x){const j=new CustomEvent(ca,wy);if(A.currentTarget.dispatchEvent(j),!j.defaultPrevented){const M=E().filter(U=>U.focusable),D=M.find(U=>U.active),L=M.find(U=>U.id===v),V=[D,L,...M].filter(Boolean).map(U=>U.ref.current);Gd(V,d)}}C.current=!1}),onBlur:oe(e.onBlur,()=>b(!1))})})}),Kd="RovingFocusGroupItem",qd=m.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,l=tn(),u=s||l,d=Cy(Kd,n),f=d.currentTabStopId===u,h=Ud(n),{onFocusableItemAdd:p,onFocusableItemRemove:w,currentTabStopId:v}=d;return m.useEffect(()=>{if(r)return p(),()=>w()},[r,p,w]),c.jsx(ua.ItemSlot,{scope:n,id:u,focusable:r,active:o,children:c.jsx(ye.span,{tabIndex:f?0:-1,"data-orientation":d.orientation,...a,ref:t,onMouseDown:oe(e.onMouseDown,g=>{r?d.onItemFocus(u):g.preventDefault()}),onFocus:oe(e.onFocus,()=>d.onItemFocus(u)),onKeyDown:oe(e.onKeyDown,g=>{if(g.key==="Tab"&&g.shiftKey){d.onItemShiftTab();return}if(g.target!==g.currentTarget)return;const x=Iy(g,d.orientation,d.dir);if(x!==void 0){if(g.metaKey||g.ctrlKey||g.altKey||g.shiftKey)return;g.preventDefault();let y=h().filter(E=>E.focusable).map(E=>E.ref.current);if(x==="last")y.reverse();else if(x==="prev"||x==="next"){x==="prev"&&y.reverse();const E=y.indexOf(g.currentTarget);y=d.loop?Ny(y,E+1):y.slice(E+1)}setTimeout(()=>Gd(y))}}),children:typeof i=="function"?i({isCurrentTabStop:f,hasTabStop:v!=null}):i})})});qd.displayName=Kd;var ky={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Ey(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Iy(e,t,n){const r=Ey(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return ky[r]}function Gd(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function Ny(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Ay=Vd,jy=qd,da=["Enter"," "],_y=["ArrowDown","PageUp","Home"],Yd=["ArrowUp","PageDown","End"],Ry=[..._y,...Yd],Py={ltr:[...da,"ArrowRight"],rtl:[...da,"ArrowLeft"]},Oy={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Vr="Menu",[Kr,My,Dy]=Gi(Vr),[Vn,Xd]=en(Vr,[Dy,ds,Wd]),fs=ds(),Jd=Wd(),[Ly,Kn]=Vn(Vr),[Fy,qr]=Vn(Vr),Zd=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=fs(t),[l,u]=m.useState(null),d=m.useRef(!1),f=mt(s),h=ts(o);return m.useEffect(()=>{const p=()=>{d.current=!0,document.addEventListener("pointerdown",w,{capture:!0,once:!0}),document.addEventListener("pointermove",w,{capture:!0,once:!0})},w=()=>d.current=!1;return document.addEventListener("keydown",p,{capture:!0}),()=>{document.removeEventListener("keydown",p,{capture:!0}),document.removeEventListener("pointerdown",w,{capture:!0}),document.removeEventListener("pointermove",w,{capture:!0})}},[]),c.jsx($d,{...a,children:c.jsx(Ly,{scope:t,open:n,onOpenChange:f,content:l,onContentChange:u,children:c.jsx(Fy,{scope:t,onClose:m.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:d,dir:h,modal:i,children:r})})})};Zd.displayName=Vr;var $y="MenuAnchor",fa=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=fs(n);return c.jsx(zd,{...o,...r,ref:t})});fa.displayName=$y;var ha="MenuPortal",[zy,Qd]=Vn(ha,{forceMount:void 0}),ef=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=Kn(ha,t);return c.jsx(zy,{scope:t,forceMount:n,children:c.jsx(_t,{present:n||s.open,children:c.jsx($o,{asChild:!0,container:o,children:r})})})};ef.displayName=ha;var $t="MenuContent",[By,pa]=Vn($t),tf=m.forwardRef((e,t)=>{const n=Qd($t,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=Kn($t,e.__scopeMenu),i=qr($t,e.__scopeMenu);return c.jsx(Kr.Provider,{scope:e.__scopeMenu,children:c.jsx(_t,{present:r||s.open,children:c.jsx(Kr.Slot,{scope:e.__scopeMenu,children:i.modal?c.jsx(Hy,{...o,ref:t}):c.jsx(Uy,{...o,ref:t})})})})}),Hy=m.forwardRef((e,t)=>{const n=Kn($t,e.__scopeMenu),r=m.useRef(null),o=Fe(t,r);return m.useEffect(()=>{const s=r.current;if(s)return Hi(s)},[]),c.jsx(ma,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:oe(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),Uy=m.forwardRef((e,t)=>{const n=Kn($t,e.__scopeMenu);return c.jsx(ma,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),Wy=_n.createSlot("MenuContent.ScrollLock"),ma=m.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:h,onDismiss:p,disableOutsideScroll:w,...v}=e,g=Kn($t,n),x=qr($t,n),b=fs(n),y=Jd(n),E=My(n),[C,T]=m.useState(null),I=m.useRef(null),A=Fe(t,I,g.onContentChange),R=m.useRef(0),j=m.useRef(""),M=m.useRef(0),D=m.useRef(null),L=m.useRef("right"),P=m.useRef(0),V=w?Vo:m.Fragment,U=w?{as:Wy,allowPinchZoom:!0}:void 0,q=N=>{var B,O;const W=j.current+N,Y=E().filter(G=>!G.disabled),de=document.activeElement,se=(B=Y.find(G=>G.ref.current===de))==null?void 0:B.textValue,pe=Y.map(G=>G.textValue),me=n0(pe,W,se),Se=(O=Y.find(G=>G.textValue===me))==null?void 0:O.ref.current;(function G(Z){j.current=Z,window.clearTimeout(R.current),Z!==""&&(R.current=window.setTimeout(()=>G(""),1e3))})(W),Se&&setTimeout(()=>Se.focus())};m.useEffect(()=>()=>window.clearTimeout(R.current),[]),Di();const $=m.useCallback(N=>{var Y,de;return L.current===((Y=D.current)==null?void 0:Y.side)&&o0(N,(de=D.current)==null?void 0:de.area)},[]);return c.jsx(By,{scope:n,searchRef:j,onItemEnter:m.useCallback(N=>{$(N)&&N.preventDefault()},[$]),onItemLeave:m.useCallback(N=>{var W;$(N)||((W=I.current)==null||W.focus(),T(null))},[$]),onTriggerLeave:m.useCallback(N=>{$(N)&&N.preventDefault()},[$]),pointerGraceTimerRef:M,onPointerGraceIntentChange:m.useCallback(N=>{D.current=N},[]),children:c.jsx(V,{...U,children:c.jsx(Fo,{asChild:!0,trapped:o,onMountAutoFocus:oe(s,N=>{var W;N.preventDefault(),(W=I.current)==null||W.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:c.jsx(Lo,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:h,onDismiss:p,children:c.jsx(Ay,{asChild:!0,...y,dir:x.dir,orientation:"vertical",loop:r,currentTabStopId:C,onCurrentTabStopIdChange:T,onEntryFocus:oe(l,N=>{x.isUsingKeyboardRef.current||N.preventDefault()}),preventScrollOnEntryFocus:!0,children:c.jsx(Bd,{role:"menu","aria-orientation":"vertical","data-state":wf(g.open),"data-radix-menu-content":"",dir:x.dir,...b,...v,ref:A,style:{outline:"none",...v.style},onKeyDown:oe(v.onKeyDown,N=>{const Y=N.target.closest("[data-radix-menu-content]")===N.currentTarget,de=N.ctrlKey||N.altKey||N.metaKey,se=N.key.length===1;Y&&(N.key==="Tab"&&N.preventDefault(),!de&&se&&q(N.key));const pe=I.current;if(N.target!==pe||!Ry.includes(N.key))return;N.preventDefault();const Se=E().filter(B=>!B.disabled).map(B=>B.ref.current);Yd.includes(N.key)&&Se.reverse(),e0(Se)}),onBlur:oe(e.onBlur,N=>{N.currentTarget.contains(N.target)||(window.clearTimeout(R.current),j.current="")}),onPointerMove:oe(e.onPointerMove,Yr(N=>{const W=N.target,Y=P.current!==N.clientX;if(N.currentTarget.contains(W)&&Y){const de=N.clientX>P.current?"right":"left";L.current=de,P.current=N.clientX}}))})})})})})})});tf.displayName=$t;var Vy="MenuGroup",ga=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(ye.div,{role:"group",...r,ref:t})});ga.displayName=Vy;var Ky="MenuLabel",nf=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(ye.div,{...r,ref:t})});nf.displayName=Ky;var hs="MenuItem",rf="menu.itemSelect",ps=m.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=m.useRef(null),i=qr(hs,e.__scopeMenu),a=pa(hs,e.__scopeMenu),l=Fe(t,s),u=m.useRef(!1),d=()=>{const f=s.current;if(!n&&f){const h=new CustomEvent(rf,{bubbles:!0,cancelable:!0});f.addEventListener(rf,p=>r==null?void 0:r(p),{once:!0}),$c(f,h),h.defaultPrevented?u.current=!1:i.onClose()}};return c.jsx(of,{...o,ref:l,disabled:n,onClick:oe(e.onClick,d),onPointerDown:f=>{var h;(h=e.onPointerDown)==null||h.call(e,f),u.current=!0},onPointerUp:oe(e.onPointerUp,f=>{var h;u.current||(h=f.currentTarget)==null||h.click()}),onKeyDown:oe(e.onKeyDown,f=>{const h=a.searchRef.current!=="";n||h&&f.key===" "||da.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});ps.displayName=hs;var of=m.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=pa(hs,n),a=Jd(n),l=m.useRef(null),u=Fe(t,l),[d,f]=m.useState(!1),[h,p]=m.useState("");return m.useEffect(()=>{const w=l.current;w&&p((w.textContent??"").trim())},[s.children]),c.jsx(Kr.ItemSlot,{scope:n,disabled:r,textValue:o??h,children:c.jsx(jy,{asChild:!0,...a,focusable:!r,children:c.jsx(ye.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:u,onPointerMove:oe(e.onPointerMove,Yr(w=>{r?i.onItemLeave(w):(i.onItemEnter(w),w.defaultPrevented||w.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:oe(e.onPointerLeave,Yr(w=>i.onItemLeave(w))),onFocus:oe(e.onFocus,()=>f(!0)),onBlur:oe(e.onBlur,()=>f(!1))})})})}),qy="MenuCheckboxItem",sf=m.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return c.jsx(df,{scope:e.__scopeMenu,checked:n,children:c.jsx(ps,{role:"menuitemcheckbox","aria-checked":ms(n)?"mixed":n,...o,ref:t,"data-state":va(n),onSelect:oe(o.onSelect,()=>r==null?void 0:r(ms(n)?!0:!n),{checkForDefaultPrevented:!1})})})});sf.displayName=qy;var af="MenuRadioGroup",[Gy,Yy]=Vn(af,{value:void 0,onValueChange:()=>{}}),lf=m.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=mt(r);return c.jsx(Gy,{scope:e.__scopeMenu,value:n,onValueChange:s,children:c.jsx(ga,{...o,ref:t})})});lf.displayName=af;var cf="MenuRadioItem",uf=m.forwardRef((e,t)=>{const{value:n,...r}=e,o=Yy(cf,e.__scopeMenu),s=n===o.value;return c.jsx(df,{scope:e.__scopeMenu,checked:s,children:c.jsx(ps,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":va(s),onSelect:oe(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});uf.displayName=cf;var xa="MenuItemIndicator",[df,Xy]=Vn(xa,{checked:!1}),ff=m.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=Xy(xa,n);return c.jsx(_t,{present:r||ms(s.checked)||s.checked===!0,children:c.jsx(ye.span,{...o,ref:t,"data-state":va(s.checked)})})});ff.displayName=xa;var Jy="MenuSeparator",hf=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(ye.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});hf.displayName=Jy;var Zy="MenuArrow",pf=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=fs(n);return c.jsx(Hd,{...o,...r,ref:t})});pf.displayName=Zy;var Qy="MenuSub",[LC,mf]=Vn(Qy),Gr="MenuSubTrigger",gf=m.forwardRef((e,t)=>{const n=Kn(Gr,e.__scopeMenu),r=qr(Gr,e.__scopeMenu),o=mf(Gr,e.__scopeMenu),s=pa(Gr,e.__scopeMenu),i=m.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,u={__scopeMenu:e.__scopeMenu},d=m.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return m.useEffect(()=>d,[d]),m.useEffect(()=>{const f=a.current;return()=>{window.clearTimeout(f),l(null)}},[a,l]),c.jsx(fa,{asChild:!0,...u,children:c.jsx(of,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":wf(n.open),...e,ref:Si(t,o.onTriggerChange),onClick:f=>{var h;(h=e.onClick)==null||h.call(e,f),!(e.disabled||f.defaultPrevented)&&(f.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:oe(e.onPointerMove,Yr(f=>{s.onItemEnter(f),!f.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(s.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),d()},100))})),onPointerLeave:oe(e.onPointerLeave,Yr(f=>{var p,w;d();const h=(p=n.content)==null?void 0:p.getBoundingClientRect();if(h){const v=(w=n.content)==null?void 0:w.dataset.side,g=v==="right",x=g?-5:5,b=h[g?"left":"right"],y=h[g?"right":"left"];s.onPointerGraceIntentChange({area:[{x:f.clientX+x,y:f.clientY},{x:b,y:h.top},{x:y,y:h.top},{x:y,y:h.bottom},{x:b,y:h.bottom}],side:v}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(f),f.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:oe(e.onKeyDown,f=>{var p;const h=s.searchRef.current!=="";e.disabled||h&&f.key===" "||Py[r.dir].includes(f.key)&&(n.onOpenChange(!0),(p=n.content)==null||p.focus(),f.preventDefault())})})})});gf.displayName=Gr;var xf="MenuSubContent",vf=m.forwardRef((e,t)=>{const n=Qd($t,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=Kn($t,e.__scopeMenu),i=qr($t,e.__scopeMenu),a=mf(xf,e.__scopeMenu),l=m.useRef(null),u=Fe(t,l);return c.jsx(Kr.Provider,{scope:e.__scopeMenu,children:c.jsx(_t,{present:r||s.open,children:c.jsx(Kr.Slot,{scope:e.__scopeMenu,children:c.jsx(ma,{id:a.contentId,"aria-labelledby":a.triggerId,...o,ref:u,align:"start",side:i.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:d=>{var f;i.isUsingKeyboardRef.current&&((f=l.current)==null||f.focus()),d.preventDefault()},onCloseAutoFocus:d=>d.preventDefault(),onFocusOutside:oe(e.onFocusOutside,d=>{d.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:oe(e.onEscapeKeyDown,d=>{i.onClose(),d.preventDefault()}),onKeyDown:oe(e.onKeyDown,d=>{var p;const f=d.currentTarget.contains(d.target),h=Oy[i.dir].includes(d.key);f&&h&&(s.onOpenChange(!1),(p=a.trigger)==null||p.focus(),d.preventDefault())})})})})})});vf.displayName=xf;function wf(e){return e?"open":"closed"}function ms(e){return e==="indeterminate"}function va(e){return ms(e)?"indeterminate":e?"checked":"unchecked"}function e0(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function t0(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function n0(e,t,n){const o=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=t0(e,Math.max(s,0));o.length===1&&(i=i.filter(u=>u!==n));const l=i.find(u=>u.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function r0(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const a=t[s],l=t[i],u=a.x,d=a.y,f=l.x,h=l.y;d>r!=h>r&&n<(f-u)*(r-d)/(h-d)+u&&(o=!o)}return o}function o0(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return r0(n,t)}function Yr(e){return t=>t.pointerType==="mouse"?e(t):void 0}var s0=Zd,i0=fa,a0=ef,l0=tf,c0=ga,u0=nf,d0=ps,f0=sf,h0=lf,p0=uf,m0=ff,g0=hf,x0=pf,v0=gf,w0=vf,gs="DropdownMenu",[b0,FC]=en(gs,[Xd]),yt=Xd(),[y0,bf]=b0(gs),yf=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,l=yt(t),u=m.useRef(null),[d,f]=$n({prop:o,defaultProp:s??!1,onChange:i,caller:gs});return c.jsx(y0,{scope:t,triggerId:tn(),triggerRef:u,contentId:tn(),open:d,onOpenChange:f,onOpenToggle:m.useCallback(()=>f(h=>!h),[f]),modal:a,children:c.jsx(s0,{...l,open:d,onOpenChange:f,dir:r,modal:a,children:n})})};yf.displayName=gs;var Sf="DropdownMenuTrigger",Cf=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=bf(Sf,n),i=yt(n);return c.jsx(i0,{asChild:!0,...i,children:c.jsx(ye.button,{type:"button",id:s.triggerId,"aria-haspopup":"menu","aria-expanded":s.open,"aria-controls":s.open?s.contentId:void 0,"data-state":s.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...o,ref:Si(t,s.triggerRef),onPointerDown:oe(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:oe(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});Cf.displayName=Sf;var S0="DropdownMenuPortal",Tf=e=>{const{__scopeDropdownMenu:t,...n}=e,r=yt(t);return c.jsx(a0,{...r,...n})};Tf.displayName=S0;var kf="DropdownMenuContent",Ef=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=bf(kf,n),s=yt(n),i=m.useRef(!1);return c.jsx(l0,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:oe(e.onCloseAutoFocus,a=>{var l;i.current||(l=o.triggerRef.current)==null||l.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:oe(e.onInteractOutside,a=>{const l=a.detail.originalEvent,u=l.button===0&&l.ctrlKey===!0,d=l.button===2||u;(!o.modal||d)&&(i.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Ef.displayName=kf;var C0="DropdownMenuGroup",T0=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=yt(n);return c.jsx(c0,{...o,...r,ref:t})});T0.displayName=C0;var k0="DropdownMenuLabel",If=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=yt(n);return c.jsx(u0,{...o,...r,ref:t})});If.displayName=k0;var E0="DropdownMenuItem",Nf=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=yt(n);return c.jsx(d0,{...o,...r,ref:t})});Nf.displayName=E0;var I0="DropdownMenuCheckboxItem",Af=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=yt(n);return c.jsx(f0,{...o,...r,ref:t})});Af.displayName=I0;var N0="DropdownMenuRadioGroup",A0=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=yt(n);return c.jsx(h0,{...o,...r,ref:t})});A0.displayName=N0;var j0="DropdownMenuRadioItem",jf=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=yt(n);return c.jsx(p0,{...o,...r,ref:t})});jf.displayName=j0;var _0="DropdownMenuItemIndicator",_f=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=yt(n);return c.jsx(m0,{...o,...r,ref:t})});_f.displayName=_0;var R0="DropdownMenuSeparator",Rf=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=yt(n);return c.jsx(g0,{...o,...r,ref:t})});Rf.displayName=R0;var P0="DropdownMenuArrow",O0=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=yt(n);return c.jsx(x0,{...o,...r,ref:t})});O0.displayName=P0;var M0="DropdownMenuSubTrigger",Pf=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=yt(n);return c.jsx(v0,{...o,...r,ref:t})});Pf.displayName=M0;var D0="DropdownMenuSubContent",Of=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=yt(n);return c.jsx(w0,{...o,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Of.displayName=D0;var L0=yf,F0=Cf,$0=Tf,Mf=Ef,Df=If,Lf=Nf,Ff=Af,$f=jf,zf=_f,Bf=Rf,Hf=Pf,Uf=Of;const z0=L0,B0=F0,H0=m.forwardRef(({className:e,inset:t,children:n,...r},o)=>c.jsxs(Hf,{ref:o,className:X("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",t&&"pl-8",e),...r,children:[n,c.jsx(ee.ChevronRight,{className:"ml-auto h-4 w-4"})]}));H0.displayName=Hf.displayName;const U0=m.forwardRef(({className:e,...t},n)=>c.jsx(Uf,{ref:n,className:X("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...t}));U0.displayName=Uf.displayName;const Wf=m.forwardRef(({className:e,sideOffset:t=4,...n},r)=>c.jsx($0,{children:c.jsx(Mf,{ref:r,sideOffset:t,className:X("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n})}));Wf.displayName=Mf.displayName;const wa=m.forwardRef(({className:e,inset:t,...n},r)=>c.jsx(Lf,{ref:r,className:X("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...n}));wa.displayName=Lf.displayName;const W0=m.forwardRef(({className:e,children:t,checked:n,...r},o)=>c.jsxs(Ff,{ref:o,className:X("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:n,...r,children:[c.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:c.jsx(zf,{children:c.jsx(ee.Check,{className:"h-4 w-4"})})}),t]}));W0.displayName=Ff.displayName;const V0=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs($f,{ref:r,className:X("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[c.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:c.jsx(zf,{children:c.jsx(ee.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));V0.displayName=$f.displayName;const K0=m.forwardRef(({className:e,inset:t,...n},r)=>c.jsx(Df,{ref:r,className:X("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));K0.displayName=Df.displayName;const q0=m.forwardRef(({className:e,...t},n)=>c.jsx(Bf,{ref:n,className:X("-mx-1 my-1 h-px bg-muted",e),...t}));q0.displayName=Bf.displayName;function xs({className:e="",placeholder:t="Type your message...",autoFocus:n=!0,maxHeight:r=void 0,streamingDebounceMs:o=500,streamingThrottleMs:s,followNewMessages:i=!0,enableFileUpload:a=!0,enableExcelUpload:l=!1,enableMessageEditing:u=!0,customStyles:d={},onMessageSent:f,onExcelUploadSuccess:h,onError:p}){const{api:w}=qs(),{currentThreadId:v,isLoadingThread:g,listCheckpoints:x,navigateToCheckpoint:b,returnToLatest:y}=ho(),{messages:E,hasMoreHistory:C,isLoadingHistory:T,send:I,stop:A,loadOlderMessages:R}=Js(),{isStreaming:j,error:M,streamingAssistantId:D,lastCheckpointId:L,lastCheckpointNs:P}=Fl(),[V,U]=S.useState(null),[q,$]=S.useState(""),[N,W]=S.useState(null),[Y,de]=S.useState([]),[se,pe]=S.useState(0),[me,Se]=S.useState(0),[B,O]=S.useState(!1),[G,Z]=S.useState(null),[ce,ie]=S.useState(null),[De,Xe]=S.useState(!1),[Je,Ne]=S.useState(null),[Oe,Qe]=S.useState([]),[Re,st]=S.useState(null),[ct,Q]=S.useState(null),[le,ge]=S.useState(!1),Ce=S.useRef(null),we=S.useRef(null),_e=S.useRef(null),et=S.useCallback(()=>{Ce.current&&(Ce.current.value=""),we.current&&(we.current.value=""),pe(ae=>ae+1),Se(ae=>ae+1)},[]),Ke=S.useRef(!1);S.useEffect(()=>{Ke.current&&!j&&(de([]),et()),Ke.current=j},[j,et]);const[F,J]=S.useState("desktop");S.useEffect(()=>{const ae=()=>{const xe=window.innerWidth;J(xe<640?"phone":xe<1024?"tablet":"desktop")};return ae(),window.addEventListener("resize",ae),()=>window.removeEventListener("resize",ae)},[]),S.useEffect(()=>{let ae=!1;if(!v){Qe([]),st(null),Q(null),_e.current=null;return}const xe={threadId:v,checkpointId:L??null,checkpointNs:P??null},Be=_e.current;if(!(Be&&Be.threadId===xe.threadId&&Be.checkpointId===xe.checkpointId&&Be.checkpointNs===xe.checkpointNs))return x(v).then(ot=>{var js;if(ae)return;const Mt=((ot==null?void 0:ot.checkpoints)??[]).slice().sort((gn,k)=>new Date(k.createdAt).getTime()-new Date(gn.createdAt).getTime());Qe(Mt);const dn=Re,Zr=dn&&Mt.some(gn=>gn.checkpointId===dn)?dn:((js=Mt[0])==null?void 0:js.checkpointId)??null;let As=null;if(Zr){const gn=Mt.find(k=>k.checkpointId===Zr);As=(gn==null?void 0:gn.checkpointNs)??null}st(Zr),Q(As),_e.current=xe}).catch(ot=>{console.error("ChatInterface - listCheckpoints error:",ot),ae||(Qe([]),_e.current=null)}),()=>{ae=!0}},[v,L,P,Re,x]),S.useEffect(()=>{L&&(st(L),Q(P??null))},[L,P]);const Te=S.useCallback(async()=>{if(!(!C||T))try{await R()}catch(ae){console.warn("loadOlderMessages failed",ae)}},[C,T,R]);S.useEffect(()=>{(async()=>{if(!w.baseUrl){Ne(null);return}try{const xe=await w.getAgent("default");Ne(xe.uiDefaultMessage||null)}catch(xe){console.warn("Failed to fetch default message:",xe),Ne(null)}})()},[w]),S.useEffect(()=>{M&&!De&&(p==null||p(M))},[M,De,p]);const Me=ae=>{if(ae.length>es)return`Message too long (${ae.length}/${es} characters)`;try{return Qw(ae),null}catch(xe){return(xe==null?void 0:xe.message)||"Invalid message"}},Le=async ae=>{const xe=ae.trim();if(!(!xe&&Y.length===0)){if(xe){const Be=Me(xe);if(Be){W(Be);return}}try{await I(xe||"",{checkpointId:Re??L??void 0,checkpointNs:ct??P??void 0,payloadExtras:V?{edit:!0,originalMessageId:V}:void 0,attachments:Y}),f==null||f(xe),W(null),de([]),et(),U(null),$("")}catch(Be){const ot=(Be==null?void 0:Be.message)||"Failed to send message";W(ot),p==null||p(ot)}}},it=S.useCallback((ae,xe)=>{u&&(U(ae),$(xe),W(null))},[u]),Ot=S.useCallback(()=>{U(null),$(""),W(null)},[]),gr=S.useCallback((ae,xe)=>{it(ae,xe)},[it]),Xn=S.useCallback(ae=>{const xe=Be=>{const ot=Be.content||[],Mt=ot.filter(dn=>dn.type==="text").map(dn=>dn.text).join("");if(Mt)return Mt;try{return JSON.stringify(ot,null,2)}catch{return String(ot)}};for(let Be=ae-1;Be>=0;Be--)if(E[Be].role==="user"){const ot=xe(E[Be]);ot&&I(ot,{checkpointId:Re??L??void 0,checkpointNs:ct??P??void 0});break}},[E,I,Re,ct,L,P]),xr=ae=>{const xe=Array.from(ae.target.files||[]);de(Be=>[...Be,...xe]),ae.target.value=""},cn=ae=>{de(xe=>{const Be=xe.filter((ot,Mt)=>ae!==Mt);return Be.length===0&&et(),Be})},Jn=async ae=>{const xe=(ae.target.files||[])[0];if(xe){Z(null),ie(null),O(!0);try{await I("",{checkpointId:Re??L??void 0,checkpointNs:ct??P??void 0,attachments:[xe]});const Be=`Uploaded ${xe.name} - processing through chat stream`;ie(Be)}catch(Be){const ot=Be instanceof Error?Be.message:"Failed to upload Excel file";console.error("Excel upload failed",Be),Z(ot),p==null||p(ot)}finally{O(!1),ae.target.value="",et()}}},jn=ae=>{if(!ae)return"Unknown";const xe=Date.parse(ae);return Number.isNaN(xe)?ae:new Date(xe).toLocaleString()},un=async ae=>{if(v){ge(!0);try{if(!ae){await y(),st(null),Q(null);return}const xe=Oe.find(ot=>ot.checkpointId===ae),Be=(xe==null?void 0:xe.checkpointNs)??null;await b(ae,Be),st(ae),Q(Be)}finally{ge(!1)}}},Ns=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${d.container||""}`,Jr=`flex-1 min-h-0 min-w-0 max-h-full w-full overflow-hidden overscroll-contain break-words break-anywhere p-4 bg-transparent ${d.messagesArea||""}`,Oa=`flex-shrink-0 w-full border-t p-4 bg-transparent ${d.inputArea||""}`;return c.jsxs("div",{className:Ns,children:[!!M&&!De&&c.jsxs("div",{className:"flex-shrink-0 bg-red-50 border border-red-200 text-red-800 px-4 py-2 text-sm flex items-center justify-between",children:[c.jsx("span",{children:M}),c.jsx(Ue,{variant:"ghost",size:"sm",onClick:()=>Xe(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:c.jsx(ee.X,{size:16})})]}),v&&Oe.length>0&&c.jsxs("div",{className:"flex-shrink-0 flex items-center gap-2 px-4 py-2 border-b border-border bg-muted/60 text-xs dark:bg-muted/50",children:[c.jsx("span",{className:"opacity-70",children:"Checkpoint:"}),c.jsxs("select",{className:"border border-border rounded px-2 py-1 text-xs bg-card text-foreground focus:outline-none focus:ring-1 focus:ring-ring dark:bg-secondary",value:Re??"",onChange:ae=>{const xe=ae.target.value||null;un(xe)},children:[c.jsx("option",{value:"",children:"Latest"}),Oe.map(ae=>c.jsxs("option",{value:ae.checkpointId,children:[jn(ae.createdAt),ae.preview?` — ${ae.preview.slice(0,40)}`:""]},ae.checkpointId))]})]}),c.jsxs("div",{className:`relative ${Jr}`,style:r?{maxHeight:r}:void 0,children:[c.jsx(qi,{className:"h-full",style:{height:"100%"},messages:E,isStreaming:j,streamingAssistantId:D,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:F,enableMessageEditing:u,editingMessageId:V,onStartReached:()=>{Te()},onEdit:gr,onRegenerate:Xn,onCancelEdit:Ot,emptyMessage:Je??void 0,isNavigatingCheckpoint:le}),g&&c.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 bg-background/80 backdrop-blur-sm text-muted-foreground",children:[c.jsx(ee.Loader2,{className:"h-6 w-6 animate-spin"}),c.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading messages…"})]})]}),c.jsxs("div",{className:Oa,children:[V&&c.jsx("div",{className:"mb-3 p-3 bg-blue-50 border border-blue-200 rounded-lg",children:c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(ee.Edit3,{size:16,className:"text-blue-600"}),c.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),c.jsx(Ue,{variant:"ghost",size:"sm",onClick:Ot,className:"text-blue-600 hover:bg-blue-100",children:c.jsx(ee.X,{size:16})})]})}),(a||l)&&c.jsxs("div",{className:"mb-3 space-y-3",children:[a&&c.jsxs(c.Fragment,{children:[c.jsx("input",{ref:Ce,type:"file",multiple:!0,onChange:ae=>xr(ae),className:"hidden"},se),Y.length>0&&c.jsx("div",{className:"flex flex-wrap gap-2",children:Y.map((ae,xe)=>c.jsxs("div",{className:"flex items-center gap-2 bg-gray-100 dark:bg-gray-800 rounded-lg px-3 py-2 text-sm text-gray-900 dark:text-gray-100",children:[c.jsx(ee.Paperclip,{size:14}),c.jsx("span",{className:"truncate max-w-[150px]",children:ae.name}),c.jsx(Ue,{variant:"ghost",size:"sm",onClick:()=>cn(xe),className:"h-4 w-4 p-0 text-gray-500 dark:text-gray-400 hover:text-red-500 dark:hover:text-red-400","aria-label":`Remove ${ae.name}`,children:c.jsx(ee.X,{size:12})})]},xe))})]}),l&&c.jsxs(c.Fragment,{children:[c.jsx("input",{ref:we,type:"file",accept:".xls,.xlsx,.xlsm",onChange:Jn,className:"hidden"},me),B&&c.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[c.jsx(ee.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),ce&&!B&&c.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:ce}),G&&!B&&c.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:G})]})]}),N&&c.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:N}),c.jsxs("div",{className:"flex items-end gap-2",children:[(a||l)&&c.jsxs(z0,{children:[c.jsx(B0,{asChild:!0,children:c.jsx(Ue,{type:"button",size:"icon",variant:"outline",disabled:j,title:"More input actions",className:d.moreButton||"",children:c.jsx(ee.Plus,{size:16})})}),c.jsxs(Wf,{align:"start",sideOffset:6,className:"w-52",children:[a&&c.jsxs(wa,{onClick:()=>{var ae;return(ae=Ce.current)==null?void 0:ae.click()},className:"cursor-pointer",children:[c.jsx(ee.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),l&&c.jsxs(wa,{onClick:()=>{var ae;B||(ae=we.current)==null||ae.click()},className:`cursor-pointer ${B?"opacity-60 pointer-events-none":""}`,children:[c.jsx(ee.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),c.jsx("div",{className:"flex-1",children:c.jsx(fg,{initialValue:q,editingMessageId:V,placeholder:V?"Edit your message...":t,isStreaming:j,disabled:!1,maxLength:es,onSend:Le,onCancelEdit:Ot,onStop:A,allowEmptySend:Y.length>0,textareaClassName:`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${V?"border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50":""} ${N?"border-red-400":""} ${d.textarea||""}`})})]})]})]})}const vs=m.forwardRef(({className:e,type:t,...n},r)=>c.jsx("input",{type:t,className:X("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:r,...n}));vs.displayName="Input";function ba(e,[t,n]){return Math.min(n,Math.max(t,e))}function G0(e,t){return m.useReducer((n,r)=>t[n][r]??n,e)}var ya="ScrollArea",[Vf,$C]=en(ya),[Y0,zt]=Vf(ya),Kf=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,l]=m.useState(null),[u,d]=m.useState(null),[f,h]=m.useState(null),[p,w]=m.useState(null),[v,g]=m.useState(null),[x,b]=m.useState(0),[y,E]=m.useState(0),[C,T]=m.useState(!1),[I,A]=m.useState(!1),R=Fe(t,M=>l(M)),j=ts(o);return c.jsx(Y0,{scope:n,type:r,dir:j,scrollHideDelay:s,scrollArea:a,viewport:u,onViewportChange:d,content:f,onContentChange:h,scrollbarX:p,onScrollbarXChange:w,scrollbarXEnabled:C,onScrollbarXEnabledChange:T,scrollbarY:v,onScrollbarYChange:g,scrollbarYEnabled:I,onScrollbarYEnabledChange:A,onCornerWidthChange:b,onCornerHeightChange:E,children:c.jsx(ye.div,{dir:j,...i,ref:R,style:{position:"relative","--radix-scroll-area-corner-width":x+"px","--radix-scroll-area-corner-height":y+"px",...e.style}})})});Kf.displayName=ya;var qf="ScrollAreaViewport",Gf=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=zt(qf,n),a=m.useRef(null),l=Fe(t,a,i.onViewportChange);return c.jsxs(c.Fragment,{children:[c.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:o}),c.jsx(ye.div,{"data-radix-scroll-area-viewport":"",...s,ref:l,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:c.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});Gf.displayName=qf;var ln="ScrollAreaScrollbar",Sa=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=zt(ln,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:i}=o,a=e.orientation==="horizontal";return m.useEffect(()=>(a?s(!0):i(!0),()=>{a?s(!1):i(!1)}),[a,s,i]),o.type==="hover"?c.jsx(X0,{...r,ref:t,forceMount:n}):o.type==="scroll"?c.jsx(J0,{...r,ref:t,forceMount:n}):o.type==="auto"?c.jsx(Yf,{...r,ref:t,forceMount:n}):o.type==="always"?c.jsx(Ca,{...r,ref:t}):null});Sa.displayName=ln;var X0=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=zt(ln,e.__scopeScrollArea),[s,i]=m.useState(!1);return m.useEffect(()=>{const a=o.scrollArea;let l=0;if(a){const u=()=>{window.clearTimeout(l),i(!0)},d=()=>{l=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",u),a.addEventListener("pointerleave",d),()=>{window.clearTimeout(l),a.removeEventListener("pointerenter",u),a.removeEventListener("pointerleave",d)}}},[o.scrollArea,o.scrollHideDelay]),c.jsx(_t,{present:n||s,children:c.jsx(Yf,{"data-state":s?"visible":"hidden",...r,ref:t})})}),J0=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=zt(ln,e.__scopeScrollArea),s=e.orientation==="horizontal",i=Ss(()=>l("SCROLL_END"),100),[a,l]=G0("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return m.useEffect(()=>{if(a==="idle"){const u=window.setTimeout(()=>l("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(u)}},[a,o.scrollHideDelay,l]),m.useEffect(()=>{const u=o.viewport,d=s?"scrollLeft":"scrollTop";if(u){let f=u[d];const h=()=>{const p=u[d];f!==p&&(l("SCROLL"),i()),f=p};return u.addEventListener("scroll",h),()=>u.removeEventListener("scroll",h)}},[o.viewport,s,l,i]),c.jsx(_t,{present:n||a!=="hidden",children:c.jsx(Ca,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:oe(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:oe(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),Yf=m.forwardRef((e,t)=>{const n=zt(ln,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=m.useState(!1),a=e.orientation==="horizontal",l=Ss(()=>{if(n.viewport){const u=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?u:d)}},10);return hr(n.viewport,l),hr(n.content,l),c.jsx(_t,{present:r||s,children:c.jsx(Ca,{"data-state":s?"visible":"hidden",...o,ref:t})})}),Ca=m.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=zt(ln,e.__scopeScrollArea),s=m.useRef(null),i=m.useRef(0),[a,l]=m.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=eh(a.viewport,a.content),d={...r,sizes:a,onSizesChange:l,hasThumb:u>0&&u<1,onThumbChange:h=>s.current=h,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:h=>i.current=h};function f(h,p){return rS(h,i.current,a,p)}return n==="horizontal"?c.jsx(Z0,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollLeft,p=th(h,a,o.dir);s.current.style.transform=`translate3d(${p}px, 0, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollLeft=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollLeft=f(h,o.dir))}}):n==="vertical"?c.jsx(Q0,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollTop,p=th(h,a);s.current.style.transform=`translate3d(0, ${p}px, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollTop=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollTop=f(h))}}):null}),Z0=m.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=zt(ln,e.__scopeScrollArea),[i,a]=m.useState(),l=m.useRef(null),u=Fe(t,l,s.onScrollbarXChange);return m.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),c.jsx(Jf,{"data-orientation":"horizontal",...o,ref:u,sizes:n,style:{bottom:0,left:s.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:s.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":ys(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.x),onDragScroll:d=>e.onDragScroll(d.x),onWheelScroll:(d,f)=>{if(s.viewport){const h=s.viewport.scrollLeft+d.deltaX;e.onWheelScroll(h),rh(h,f)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:l.current.clientWidth,paddingStart:bs(i.paddingLeft),paddingEnd:bs(i.paddingRight)}})}})}),Q0=m.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=zt(ln,e.__scopeScrollArea),[i,a]=m.useState(),l=m.useRef(null),u=Fe(t,l,s.onScrollbarYChange);return m.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),c.jsx(Jf,{"data-orientation":"vertical",...o,ref:u,sizes:n,style:{top:0,right:s.dir==="ltr"?0:void 0,left:s.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":ys(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.y),onDragScroll:d=>e.onDragScroll(d.y),onWheelScroll:(d,f)=>{if(s.viewport){const h=s.viewport.scrollTop+d.deltaY;e.onWheelScroll(h),rh(h,f)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:l.current.clientHeight,paddingStart:bs(i.paddingTop),paddingEnd:bs(i.paddingBottom)}})}})}),[eS,Xf]=Vf(ln),Jf=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:l,onDragScroll:u,onWheelScroll:d,onResize:f,...h}=e,p=zt(ln,n),[w,v]=m.useState(null),g=Fe(t,R=>v(R)),x=m.useRef(null),b=m.useRef(""),y=p.viewport,E=r.content-r.viewport,C=mt(d),T=mt(l),I=Ss(f,10);function A(R){if(x.current){const j=R.clientX-x.current.left,M=R.clientY-x.current.top;u({x:j,y:M})}}return m.useEffect(()=>{const R=j=>{const M=j.target;(w==null?void 0:w.contains(M))&&C(j,E)};return document.addEventListener("wheel",R,{passive:!1}),()=>document.removeEventListener("wheel",R,{passive:!1})},[y,w,E,C]),m.useEffect(T,[r,T]),hr(w,I),hr(p.content,I),c.jsx(eS,{scope:n,scrollbar:w,hasThumb:o,onThumbChange:mt(s),onThumbPointerUp:mt(i),onThumbPositionChange:T,onThumbPointerDown:mt(a),children:c.jsx(ye.div,{...h,ref:g,style:{position:"absolute",...h.style},onPointerDown:oe(e.onPointerDown,R=>{R.button===0&&(R.target.setPointerCapture(R.pointerId),x.current=w.getBoundingClientRect(),b.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",p.viewport&&(p.viewport.style.scrollBehavior="auto"),A(R))}),onPointerMove:oe(e.onPointerMove,A),onPointerUp:oe(e.onPointerUp,R=>{const j=R.target;j.hasPointerCapture(R.pointerId)&&j.releasePointerCapture(R.pointerId),document.body.style.webkitUserSelect=b.current,p.viewport&&(p.viewport.style.scrollBehavior=""),x.current=null})})})}),ws="ScrollAreaThumb",Zf=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Xf(ws,e.__scopeScrollArea);return c.jsx(_t,{present:n||o.hasThumb,children:c.jsx(tS,{ref:t,...r})})}),tS=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=zt(ws,n),i=Xf(ws,n),{onThumbPositionChange:a}=i,l=Fe(t,f=>i.onThumbChange(f)),u=m.useRef(void 0),d=Ss(()=>{u.current&&(u.current(),u.current=void 0)},100);return m.useEffect(()=>{const f=s.viewport;if(f){const h=()=>{if(d(),!u.current){const p=oS(f,a);u.current=p,a()}};return a(),f.addEventListener("scroll",h),()=>f.removeEventListener("scroll",h)}},[s.viewport,d,a]),c.jsx(ye.div,{"data-state":i.hasThumb?"visible":"hidden",...o,ref:l,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:oe(e.onPointerDownCapture,f=>{const p=f.target.getBoundingClientRect(),w=f.clientX-p.left,v=f.clientY-p.top;i.onThumbPointerDown({x:w,y:v})}),onPointerUp:oe(e.onPointerUp,i.onThumbPointerUp)})});Zf.displayName=ws;var Ta="ScrollAreaCorner",Qf=m.forwardRef((e,t)=>{const n=zt(Ta,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?c.jsx(nS,{...e,ref:t}):null});Qf.displayName=Ta;var nS=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=zt(Ta,n),[s,i]=m.useState(0),[a,l]=m.useState(0),u=!!(s&&a);return hr(o.scrollbarX,()=>{var f;const d=((f=o.scrollbarX)==null?void 0:f.offsetHeight)||0;o.onCornerHeightChange(d),l(d)}),hr(o.scrollbarY,()=>{var f;const d=((f=o.scrollbarY)==null?void 0:f.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),u?c.jsx(ye.div,{...r,ref:t,style:{width:s,height:a,position:"absolute",right:o.dir==="ltr"?0:void 0,left:o.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function bs(e){return e?parseInt(e,10):0}function eh(e,t){const n=e/t;return isNaN(n)?0:n}function ys(e){const t=eh(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function rS(e,t,n,r="ltr"){const o=ys(n),s=o/2,i=t||s,a=o-i,l=n.scrollbar.paddingStart+i,u=n.scrollbar.size-n.scrollbar.paddingEnd-a,d=n.content-n.viewport,f=r==="ltr"?[0,d]:[d*-1,0];return nh([l,u],f)(e)}function th(e,t,n="ltr"){const r=ys(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,s=t.scrollbar.size-o,i=t.content-t.viewport,a=s-r,l=n==="ltr"?[0,i]:[i*-1,0],u=ba(e,l);return nh([0,i],[0,a])(u)}function nh(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function rh(e,t){return e>0&&e<t}var oS=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return function o(){const s={left:e.scrollLeft,top:e.scrollTop},i=n.left!==s.left,a=n.top!==s.top;(i||a)&&t(),n=s,r=window.requestAnimationFrame(o)}(),()=>window.cancelAnimationFrame(r)};function Ss(e,t){const n=mt(e),r=m.useRef(0);return m.useEffect(()=>()=>window.clearTimeout(r.current),[]),m.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function hr(e,t){const n=mt(t);pt(()=>{let r=0;if(e){const o=new ResizeObserver(()=>{cancelAnimationFrame(r),r=window.requestAnimationFrame(n)});return o.observe(e),()=>{window.cancelAnimationFrame(r),o.unobserve(e)}}},[e,n])}var oh=Kf,sS=Gf,iS=Qf;const sh=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(oh,{ref:r,className:X("relative overflow-hidden",e),...n,children:[c.jsx(sS,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),c.jsx(ih,{}),c.jsx(iS,{})]}));sh.displayName=oh.displayName;const ih=m.forwardRef(({className:e,orientation:t="vertical",...n},r)=>c.jsx(Sa,{ref:r,orientation:t,className:X("flex touch-none select-none transition-colors",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...n,children:c.jsx(Zf,{className:"relative flex-1 rounded-full bg-border"})}));ih.displayName=Sa.displayName;function ka({className:e="",showCreateButton:t=!0,showDeleteButton:n=!0,showEditTitle:r=!0,maxHeight:o="400px",customStyles:s={},currentThreadId:i=null,navigateToThread:a,onThreadSelect:l,onThreadCreate:u,onThreadDelete:d}){const{loadThread:f,threads:h,currentThreadId:p,createThread:w,deleteThread:v,renameThread:g,isLoadingThreads:x}=ho(),[b,y]=S.useState(h??[]),[E,C]=S.useState(null),[T,I]=S.useState(""),[A,R]=S.useState(!1);S.useEffect(()=>{y(h??[])},[h]);const j=async N=>{try{await f(N),a==null||a(N),l==null||l(N)}catch(W){console.error("Failed to select thread:",W)}},M=async()=>{try{R(!0);const N=await w();u==null||u(N),a==null||a(N)}catch(N){console.error("Failed to create thread:",N)}finally{R(!1)}},D=async(N,W)=>{if(W.stopPropagation(),!!confirm("Delete this thread?"))try{await v(N),d==null||d(N)}catch(Y){console.error("Failed to delete thread:",Y)}},L=(N,W)=>{W.stopPropagation(),C(N.threadId),I(N.title||`Thread ${N.threadId.slice(0,8)}`)},P=async N=>{if(T.trim())try{await g(N,T.trim()),C(null),I("")}catch(W){console.error("Failed to update title:",W)}},V=()=>{C(null),I("")},U=(N,W)=>{N.key==="Enter"?P(W):N.key==="Escape"&&V()},q=N=>{if(!N)return"";try{const W=new Date(N),de=new Date().getTime()-W.getTime(),se=Math.floor(de/(1e3*60*60*24));return se===0?W.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):se===1?"Yesterday":se<7?`${se} days ago`:W.toLocaleDateString()}catch{return""}},$=N=>N.title||`Thread ${N.threadId.slice(0,8)}`;return c.jsxs("div",{className:`flex flex-col h-full ${e} ${s.container||""}`,children:[t&&c.jsx("div",{className:s.header||"flex-shrink-0 p-2 border-b bg-slate-800 border-slate-700 text-slate-100 flex justify-end",children:c.jsx(Ue,{onClick:M,disabled:A||x,className:s.createButton||"p-2",size:"sm",variant:"ghost",title:A?"Creating...":"New Chat",children:c.jsx(ee.MessageSquarePlus,{size:20})})}),c.jsx(sh,{className:`flex-1 min-h-0 ${s.threadList||""}`,style:o?{maxHeight:o}:void 0,children:c.jsx("div",{className:"p-2 space-y-1 pb-4",children:x?c.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-8 text-slate-400",children:[c.jsx(ee.Loader2,{className:"h-5 w-5 animate-spin"}),c.jsx("span",{className:"text-sm",children:"Loading threads…"})]}):b.length===0?c.jsxs("div",{className:"text-center py-8 text-slate-400",children:[c.jsx(ee.MessageSquare,{className:"w-8 h-8 mx-auto mb-2 opacity-40 text-slate-500"}),c.jsx("p",{className:"text-sm text-slate-500",children:"No conversations yet"})]}):b.slice().sort((N,W)=>new Date(W.updatedAt||W.createdAt||"").getTime()-new Date(N.updatedAt||N.createdAt||"").getTime()).map(N=>c.jsxs("div",{onClick:()=>j(N.threadId),className:`group relative p-3 rounded-lg cursor-pointer transition-colors border ${(i??p)===N.threadId?`${s.activeThread||"bg-slate-600 border-slate-500"} `:`${s.threadItem||"bg-slate-700 border-slate-600 hover:bg-slate-600 text-gray-900 dark:text-slate-100"}`} ${s.threadItem||""} text-gray-900 dark:text-slate-100`,children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("div",{className:"flex-1 min-w-0",children:E===N.threadId?c.jsxs("div",{className:"flex items-center gap-2",onClick:W=>W.stopPropagation(),children:[c.jsx(vs,{value:T,onChange:W=>I(W.target.value),onKeyDown:W=>U(W,N.threadId),className:"h-6 text-sm",autoFocus:!0}),c.jsx(Ue,{variant:"ghost",size:"sm",onClick:()=>P(N.threadId),className:"h-6 w-6 p-0",children:c.jsx(ee.Check,{size:12})}),c.jsx(Ue,{variant:"ghost",size:"sm",onClick:V,className:"h-6 w-6 p-0",children:c.jsx(ee.X,{size:12})})]}):c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"font-medium text-sm truncate text-gray-900 dark:text-slate-100",children:$(N)}),c.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-slate-400 mt-1",children:[c.jsx(ee.Calendar,{size:10}),c.jsx("span",{children:q(N.updatedAt||N.createdAt)})]})]})}),c.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2",children:[r&&E!==N.threadId&&c.jsx(Ue,{variant:"ghost",size:"sm",onClick:W=>L(N,W),className:"h-6 w-6 p-0",title:"Edit title",children:c.jsx(ee.Edit3,{size:12})}),n&&c.jsx(Ue,{variant:"ghost",size:"sm",onClick:W=>D(N.threadId,W),className:"h-6 w-6 p-0 text-red-400 hover:text-red-300 hover:bg-red-900/20",title:"Delete thread",children:c.jsx(ee.Trash2,{size:12})})]})]}),i===N.threadId&&c.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-1 h-8 bg-blue-400 rounded-r"})]},N.threadId))})})]})}function pr(e){if(!(typeof globalThis>"u"))return globalThis[e]}function aS(e){if(typeof e!="string")return;const t=e.trim();if(t)return fn(t)}function ah(){const e=[pr("__API_BASE_URL__"),pr("__CHAT_API_BASE_URL__"),pr("__CHAT_API_URL__")];for(const t of e){const n=aS(t);if(n)return n}}function lh(){const e=[pr("__API_AUTH_TOKEN__"),pr("__CHAT_API_KEY__"),pr("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function ch(...e){for(const t of e)if(typeof t=="string"&&t.trim())return fn(t);return fn()}function uh(){const e={},t=ah(),n=lh();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function dh(){const e=uh(),t=xn.getAuthToken(),n=ah();return{apiBaseUrl:ch(e.baseUrl,xn.baseUrl,n),apiKey:t||e.apiKey||lh()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,truncateToolMessages:!0,toolMessagePreviewLength:200,darkMode:!1,enableSound:!1,messageHistory:100}}const fh="chat-settings";function lS(){try{const e=localStorage.getItem(fh);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function cS(e){try{const t={...e,apiBaseUrl:fn(e.apiBaseUrl)};localStorage.setItem(fh,JSON.stringify(t)),t.apiKey&&xn.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function uS(){const e=dh(),t=lS(),n=xn.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:ch(xn.baseUrl,r,e.apiBaseUrl)}}function dS(e){xn.updateConfig({baseUrl:e.apiBaseUrl,authToken:e.apiKey??void 0}),cS(e)}var fS="Label",hh=m.forwardRef((e,t)=>c.jsx(ye.label,{...e,ref:t,onMouseDown:n=>{var o;n.target.closest("button, input, select, textarea")||((o=e.onMouseDown)==null||o.call(e,n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));hh.displayName=fS;var ph=hh;const hS=Qr.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Bt=m.forwardRef(({className:e,...t},n)=>c.jsx(ph,{ref:n,className:X(hS(),e),...t}));Bt.displayName=ph.displayName;function mh(e){const t=m.useRef({value:e,previous:e});return m.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var Cs="Switch",[pS,zC]=en(Cs),[mS,gS]=pS(Cs),gh=m.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:s,required:i,disabled:a,value:l="on",onCheckedChange:u,form:d,...f}=e,[h,p]=m.useState(null),w=Fe(t,y=>p(y)),v=m.useRef(!1),g=h?d||!!h.closest("form"):!0,[x,b]=$n({prop:o,defaultProp:s??!1,onChange:u,caller:Cs});return c.jsxs(mS,{scope:n,checked:x,disabled:a,children:[c.jsx(ye.button,{type:"button",role:"switch","aria-checked":x,"aria-required":i,"data-state":bh(x),"data-disabled":a?"":void 0,disabled:a,value:l,...f,ref:w,onClick:oe(e.onClick,y=>{b(E=>!E),g&&(v.current=y.isPropagationStopped(),v.current||y.stopPropagation())})}),g&&c.jsx(wh,{control:h,bubbles:!v.current,name:r,value:l,checked:x,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});gh.displayName=Cs;var xh="SwitchThumb",vh=m.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=gS(xh,n);return c.jsx(ye.span,{"data-state":bh(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});vh.displayName=xh;var xS="SwitchBubbleInput",wh=m.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=m.useRef(null),a=Fe(i,s),l=mh(n),u=Ad(t);return m.useEffect(()=>{const d=i.current;if(!d)return;const f=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(f,"checked").set;if(l!==n&&p){const w=new Event("click",{bubbles:r});p.call(d,n),d.dispatchEvent(w)}},[l,n,r]),c.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:a,style:{...o.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});wh.displayName=xS;function bh(e){return e?"checked":"unchecked"}var yh=gh,vS=vh;const In=m.forwardRef(({className:e,...t},n)=>c.jsx(yh,{className:X("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...t,ref:n,children:c.jsx(vS,{className:X("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));In.displayName=yh.displayName;var Sh=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),wS="VisuallyHidden",bS=m.forwardRef((e,t)=>c.jsx(ye.span,{...e,ref:t,style:{...Sh,...e.style}}));bS.displayName=wS;var yS=[" ","Enter","ArrowUp","ArrowDown"],SS=[" ","Enter"],qn="Select",[Ts,ks,CS]=Gi(qn),[mr,BC]=en(qn,[CS,ds]),Es=ds(),[TS,Nn]=mr(qn),[kS,ES]=mr(qn),Ch=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:l,dir:u,name:d,autoComplete:f,disabled:h,required:p,form:w}=e,v=Es(t),[g,x]=m.useState(null),[b,y]=m.useState(null),[E,C]=m.useState(!1),T=ts(u),[I,A]=$n({prop:r,defaultProp:o??!1,onChange:s,caller:qn}),[R,j]=$n({prop:i,defaultProp:a,onChange:l,caller:qn}),M=m.useRef(null),D=g?w||!!g.closest("form"):!0,[L,P]=m.useState(new Set),V=Array.from(L).map(U=>U.props.value).join(";");return c.jsx($d,{...v,children:c.jsxs(TS,{required:p,scope:t,trigger:g,onTriggerChange:x,valueNode:b,onValueNodeChange:y,valueNodeHasChildren:E,onValueNodeHasChildrenChange:C,contentId:tn(),value:R,onValueChange:j,open:I,onOpenChange:A,dir:T,triggerPointerDownPosRef:M,disabled:h,children:[c.jsx(Ts.Provider,{scope:t,children:c.jsx(kS,{scope:e.__scopeSelect,onNativeOptionAdd:m.useCallback(U=>{P(q=>new Set(q).add(U))},[]),onNativeOptionRemove:m.useCallback(U=>{P(q=>{const $=new Set(q);return $.delete(U),$})},[]),children:n})}),D?c.jsxs(qh,{"aria-hidden":!0,required:p,tabIndex:-1,name:d,autoComplete:f,value:R,onChange:U=>j(U.target.value),disabled:h,form:w,children:[R===void 0?c.jsx("option",{value:""}):null,Array.from(L)]},V):null]})})};Ch.displayName=qn;var Th="SelectTrigger",kh=m.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=Es(n),i=Nn(Th,n),a=i.disabled||r,l=Fe(t,i.onTriggerChange),u=ks(n),d=m.useRef("touch"),[f,h,p]=Yh(v=>{const g=u().filter(y=>!y.disabled),x=g.find(y=>y.value===i.value),b=Xh(g,v,x);b!==void 0&&i.onValueChange(b.value)}),w=v=>{a||(i.onOpenChange(!0),p()),v&&(i.triggerPointerDownPosRef.current={x:Math.round(v.pageX),y:Math.round(v.pageY)})};return c.jsx(zd,{asChild:!0,...s,children:c.jsx(ye.button,{type:"button",role:"combobox","aria-controls":i.contentId,"aria-expanded":i.open,"aria-required":i.required,"aria-autocomplete":"none",dir:i.dir,"data-state":i.open?"open":"closed",disabled:a,"data-disabled":a?"":void 0,"data-placeholder":Gh(i.value)?"":void 0,...o,ref:l,onClick:oe(o.onClick,v=>{v.currentTarget.focus(),d.current!=="mouse"&&w(v)}),onPointerDown:oe(o.onPointerDown,v=>{d.current=v.pointerType;const g=v.target;g.hasPointerCapture(v.pointerId)&&g.releasePointerCapture(v.pointerId),v.button===0&&v.ctrlKey===!1&&v.pointerType==="mouse"&&(w(v),v.preventDefault())}),onKeyDown:oe(o.onKeyDown,v=>{const g=f.current!=="";!(v.ctrlKey||v.altKey||v.metaKey)&&v.key.length===1&&h(v.key),!(g&&v.key===" ")&&yS.includes(v.key)&&(w(),v.preventDefault())})})})});kh.displayName=Th;var Eh="SelectValue",Ih=m.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=Nn(Eh,n),{onValueNodeHasChildrenChange:u}=l,d=s!==void 0,f=Fe(t,l.onValueNodeChange);return pt(()=>{u(d)},[u,d]),c.jsx(ye.span,{...a,ref:f,style:{pointerEvents:"none"},children:Gh(l.value)?c.jsx(c.Fragment,{children:i}):s})});Ih.displayName=Eh;var IS="SelectIcon",Nh=m.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return c.jsx(ye.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});Nh.displayName=IS;var NS="SelectPortal",Ah=e=>c.jsx($o,{asChild:!0,...e});Ah.displayName=NS;var Gn="SelectContent",jh=m.forwardRef((e,t)=>{const n=Nn(Gn,e.__scopeSelect),[r,o]=m.useState();if(pt(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?eo.createPortal(c.jsx(_h,{scope:e.__scopeSelect,children:c.jsx(Ts.Slot,{scope:e.__scopeSelect,children:c.jsx("div",{children:e.children})})}),s):null}return c.jsx(Rh,{...e,ref:t})});jh.displayName=Gn;var Yt=10,[_h,An]=mr(Gn),AS="SelectContentImpl",jS=_n.createSlot("SelectContent.RemoveScroll"),Rh=m.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:a,sideOffset:l,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:h,collisionPadding:p,sticky:w,hideWhenDetached:v,avoidCollisions:g,...x}=e,b=Nn(Gn,n),[y,E]=m.useState(null),[C,T]=m.useState(null),I=Fe(t,B=>E(B)),[A,R]=m.useState(null),[j,M]=m.useState(null),D=ks(n),[L,P]=m.useState(!1),V=m.useRef(!1);m.useEffect(()=>{if(y)return Hi(y)},[y]),Di();const U=m.useCallback(B=>{const[O,...G]=D().map(ie=>ie.ref.current),[Z]=G.slice(-1),ce=document.activeElement;for(const ie of B)if(ie===ce||(ie==null||ie.scrollIntoView({block:"nearest"}),ie===O&&C&&(C.scrollTop=0),ie===Z&&C&&(C.scrollTop=C.scrollHeight),ie==null||ie.focus(),document.activeElement!==ce))return},[D,C]),q=m.useCallback(()=>U([A,y]),[U,A,y]);m.useEffect(()=>{L&&q()},[L,q]);const{onOpenChange:$,triggerPointerDownPosRef:N}=b;m.useEffect(()=>{if(y){let B={x:0,y:0};const O=Z=>{var ce,ie;B={x:Math.abs(Math.round(Z.pageX)-(((ce=N.current)==null?void 0:ce.x)??0)),y:Math.abs(Math.round(Z.pageY)-(((ie=N.current)==null?void 0:ie.y)??0))}},G=Z=>{B.x<=10&&B.y<=10?Z.preventDefault():y.contains(Z.target)||$(!1),document.removeEventListener("pointermove",O),N.current=null};return N.current!==null&&(document.addEventListener("pointermove",O),document.addEventListener("pointerup",G,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",O),document.removeEventListener("pointerup",G,{capture:!0})}}},[y,$,N]),m.useEffect(()=>{const B=()=>$(!1);return window.addEventListener("blur",B),window.addEventListener("resize",B),()=>{window.removeEventListener("blur",B),window.removeEventListener("resize",B)}},[$]);const[W,Y]=Yh(B=>{const O=D().filter(ce=>!ce.disabled),G=O.find(ce=>ce.ref.current===document.activeElement),Z=Xh(O,B,G);Z&&setTimeout(()=>Z.ref.current.focus())}),de=m.useCallback((B,O,G)=>{const Z=!V.current&&!G;(b.value!==void 0&&b.value===O||Z)&&(R(B),Z&&(V.current=!0))},[b.value]),se=m.useCallback(()=>y==null?void 0:y.focus(),[y]),pe=m.useCallback((B,O,G)=>{const Z=!V.current&&!G;(b.value!==void 0&&b.value===O||Z)&&M(B)},[b.value]),me=r==="popper"?Ea:Ph,Se=me===Ea?{side:a,sideOffset:l,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:h,collisionPadding:p,sticky:w,hideWhenDetached:v,avoidCollisions:g}:{};return c.jsx(_h,{scope:n,content:y,viewport:C,onViewportChange:T,itemRefCallback:de,selectedItem:A,onItemLeave:se,itemTextRefCallback:pe,focusSelectedItem:q,selectedItemText:j,position:r,isPositioned:L,searchRef:W,children:c.jsx(Vo,{as:jS,allowPinchZoom:!0,children:c.jsx(Fo,{asChild:!0,trapped:b.open,onMountAutoFocus:B=>{B.preventDefault()},onUnmountAutoFocus:oe(o,B=>{var O;(O=b.trigger)==null||O.focus({preventScroll:!0}),B.preventDefault()}),children:c.jsx(Lo,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:B=>B.preventDefault(),onDismiss:()=>b.onOpenChange(!1),children:c.jsx(me,{role:"listbox",id:b.contentId,"data-state":b.open?"open":"closed",dir:b.dir,onContextMenu:B=>B.preventDefault(),...x,...Se,onPlaced:()=>P(!0),ref:I,style:{display:"flex",flexDirection:"column",outline:"none",...x.style},onKeyDown:oe(x.onKeyDown,B=>{const O=B.ctrlKey||B.altKey||B.metaKey;if(B.key==="Tab"&&B.preventDefault(),!O&&B.key.length===1&&Y(B.key),["ArrowUp","ArrowDown","Home","End"].includes(B.key)){let Z=D().filter(ce=>!ce.disabled).map(ce=>ce.ref.current);if(["ArrowUp","End"].includes(B.key)&&(Z=Z.slice().reverse()),["ArrowUp","ArrowDown"].includes(B.key)){const ce=B.target,ie=Z.indexOf(ce);Z=Z.slice(ie+1)}setTimeout(()=>U(Z)),B.preventDefault()}})})})})})})});Rh.displayName=AS;var _S="SelectItemAlignedPosition",Ph=m.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=Nn(Gn,n),i=An(Gn,n),[a,l]=m.useState(null),[u,d]=m.useState(null),f=Fe(t,I=>d(I)),h=ks(n),p=m.useRef(!1),w=m.useRef(!0),{viewport:v,selectedItem:g,selectedItemText:x,focusSelectedItem:b}=i,y=m.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&u&&v&&g&&x){const I=s.trigger.getBoundingClientRect(),A=u.getBoundingClientRect(),R=s.valueNode.getBoundingClientRect(),j=x.getBoundingClientRect();if(s.dir!=="rtl"){const ce=j.left-A.left,ie=R.left-ce,De=I.left-ie,Xe=I.width+De,Je=Math.max(Xe,A.width),Ne=window.innerWidth-Yt,Oe=ba(ie,[Yt,Math.max(Yt,Ne-Je)]);a.style.minWidth=Xe+"px",a.style.left=Oe+"px"}else{const ce=A.right-j.right,ie=window.innerWidth-R.right-ce,De=window.innerWidth-I.right-ie,Xe=I.width+De,Je=Math.max(Xe,A.width),Ne=window.innerWidth-Yt,Oe=ba(ie,[Yt,Math.max(Yt,Ne-Je)]);a.style.minWidth=Xe+"px",a.style.right=Oe+"px"}const M=h(),D=window.innerHeight-Yt*2,L=v.scrollHeight,P=window.getComputedStyle(u),V=parseInt(P.borderTopWidth,10),U=parseInt(P.paddingTop,10),q=parseInt(P.borderBottomWidth,10),$=parseInt(P.paddingBottom,10),N=V+U+L+$+q,W=Math.min(g.offsetHeight*5,N),Y=window.getComputedStyle(v),de=parseInt(Y.paddingTop,10),se=parseInt(Y.paddingBottom,10),pe=I.top+I.height/2-Yt,me=D-pe,Se=g.offsetHeight/2,B=g.offsetTop+Se,O=V+U+B,G=N-O;if(O<=pe){const ce=M.length>0&&g===M[M.length-1].ref.current;a.style.bottom="0px";const ie=u.clientHeight-v.offsetTop-v.offsetHeight,De=Math.max(me,Se+(ce?se:0)+ie+q),Xe=O+De;a.style.height=Xe+"px"}else{const ce=M.length>0&&g===M[0].ref.current;a.style.top="0px";const De=Math.max(pe,V+v.offsetTop+(ce?de:0)+Se)+G;a.style.height=De+"px",v.scrollTop=O-pe+v.offsetTop}a.style.margin=`${Yt}px 0`,a.style.minHeight=W+"px",a.style.maxHeight=D+"px",r==null||r(),requestAnimationFrame(()=>p.current=!0)}},[h,s.trigger,s.valueNode,a,u,v,g,x,s.dir,r]);pt(()=>y(),[y]);const[E,C]=m.useState();pt(()=>{u&&C(window.getComputedStyle(u).zIndex)},[u]);const T=m.useCallback(I=>{I&&w.current===!0&&(y(),b==null||b(),w.current=!1)},[y,b]);return c.jsx(PS,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:p,onScrollButtonChange:T,children:c.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:E},children:c.jsx(ye.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Ph.displayName=_S;var RS="SelectPopperPosition",Ea=m.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=Yt,...s}=e,i=Es(n);return c.jsx(Bd,{...i,...s,ref:t,align:r,collisionPadding:o,style:{boxSizing:"border-box",...s.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});Ea.displayName=RS;var[PS,Ia]=mr(Gn,{}),Na="SelectViewport",Oh=m.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=An(Na,n),i=Ia(Na,n),a=Fe(t,s.onViewportChange),l=m.useRef(0);return c.jsxs(c.Fragment,{children:[c.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),c.jsx(Ts.Slot,{scope:n,children:c.jsx(ye.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:oe(o.onScroll,u=>{const d=u.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:h}=i;if(h!=null&&h.current&&f){const p=Math.abs(l.current-d.scrollTop);if(p>0){const w=window.innerHeight-Yt*2,v=parseFloat(f.style.minHeight),g=parseFloat(f.style.height),x=Math.max(v,g);if(x<w){const b=x+p,y=Math.min(w,b),E=b-y;f.style.height=y+"px",f.style.bottom==="0px"&&(d.scrollTop=E>0?E:0,f.style.justifyContent="flex-end")}}}l.current=d.scrollTop})})})]})});Oh.displayName=Na;var Mh="SelectGroup",[OS,MS]=mr(Mh),DS=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=tn();return c.jsx(OS,{scope:n,id:o,children:c.jsx(ye.div,{role:"group","aria-labelledby":o,...r,ref:t})})});DS.displayName=Mh;var Dh="SelectLabel",Lh=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=MS(Dh,n);return c.jsx(ye.div,{id:o.id,...r,ref:t})});Lh.displayName=Dh;var Is="SelectItem",[LS,Fh]=mr(Is),$h=m.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=Nn(Is,n),l=An(Is,n),u=a.value===r,[d,f]=m.useState(s??""),[h,p]=m.useState(!1),w=Fe(t,b=>{var y;return(y=l.itemRefCallback)==null?void 0:y.call(l,b,r,o)}),v=tn(),g=m.useRef("touch"),x=()=>{o||(a.onValueChange(r),a.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return c.jsx(LS,{scope:n,value:r,disabled:o,textId:v,isSelected:u,onItemTextChange:m.useCallback(b=>{f(y=>y||((b==null?void 0:b.textContent)??"").trim())},[]),children:c.jsx(Ts.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:c.jsx(ye.div,{role:"option","aria-labelledby":v,"data-highlighted":h?"":void 0,"aria-selected":u&&h,"data-state":u?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:w,onFocus:oe(i.onFocus,()=>p(!0)),onBlur:oe(i.onBlur,()=>p(!1)),onClick:oe(i.onClick,()=>{g.current!=="mouse"&&x()}),onPointerUp:oe(i.onPointerUp,()=>{g.current==="mouse"&&x()}),onPointerDown:oe(i.onPointerDown,b=>{g.current=b.pointerType}),onPointerMove:oe(i.onPointerMove,b=>{var y;g.current=b.pointerType,o?(y=l.onItemLeave)==null||y.call(l):g.current==="mouse"&&b.currentTarget.focus({preventScroll:!0})}),onPointerLeave:oe(i.onPointerLeave,b=>{var y;b.currentTarget===document.activeElement&&((y=l.onItemLeave)==null||y.call(l))}),onKeyDown:oe(i.onKeyDown,b=>{var E;((E=l.searchRef)==null?void 0:E.current)!==""&&b.key===" "||(SS.includes(b.key)&&x(),b.key===" "&&b.preventDefault())})})})})});$h.displayName=Is;var Xr="SelectItemText",zh=m.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=Nn(Xr,n),a=An(Xr,n),l=Fh(Xr,n),u=ES(Xr,n),[d,f]=m.useState(null),h=Fe(t,x=>f(x),l.onItemTextChange,x=>{var b;return(b=a.itemTextRefCallback)==null?void 0:b.call(a,x,l.value,l.disabled)}),p=d==null?void 0:d.textContent,w=m.useMemo(()=>c.jsx("option",{value:l.value,disabled:l.disabled,children:p},l.value),[l.disabled,l.value,p]),{onNativeOptionAdd:v,onNativeOptionRemove:g}=u;return pt(()=>(v(w),()=>g(w)),[v,g,w]),c.jsxs(c.Fragment,{children:[c.jsx(ye.span,{id:l.textId,...s,ref:h}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?eo.createPortal(s.children,i.valueNode):null]})});zh.displayName=Xr;var Bh="SelectItemIndicator",Hh=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return Fh(Bh,n).isSelected?c.jsx(ye.span,{"aria-hidden":!0,...r,ref:t}):null});Hh.displayName=Bh;var Aa="SelectScrollUpButton",Uh=m.forwardRef((e,t)=>{const n=An(Aa,e.__scopeSelect),r=Ia(Aa,e.__scopeSelect),[o,s]=m.useState(!1),i=Fe(t,r.onScrollButtonChange);return pt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const u=l.scrollTop>0;s(u)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?c.jsx(Vh,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});Uh.displayName=Aa;var ja="SelectScrollDownButton",Wh=m.forwardRef((e,t)=>{const n=An(ja,e.__scopeSelect),r=Ia(ja,e.__scopeSelect),[o,s]=m.useState(!1),i=Fe(t,r.onScrollButtonChange);return pt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const u=l.scrollHeight-l.clientHeight,d=Math.ceil(l.scrollTop)<u;s(d)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?c.jsx(Vh,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});Wh.displayName=ja;var Vh=m.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=An("SelectScrollButton",n),i=m.useRef(null),a=ks(n),l=m.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return m.useEffect(()=>()=>l(),[l]),pt(()=>{var d;const u=a().find(f=>f.ref.current===document.activeElement);(d=u==null?void 0:u.ref.current)==null||d.scrollIntoView({block:"nearest"})},[a]),c.jsx(ye.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:oe(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:oe(o.onPointerMove,()=>{var u;(u=s.onItemLeave)==null||u.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:oe(o.onPointerLeave,()=>{l()})})}),FS="SelectSeparator",Kh=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return c.jsx(ye.div,{"aria-hidden":!0,...r,ref:t})});Kh.displayName=FS;var _a="SelectArrow",$S=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Es(n),s=Nn(_a,n),i=An(_a,n);return s.open&&i.position==="popper"?c.jsx(Hd,{...o,...r,ref:t}):null});$S.displayName=_a;var zS="SelectBubbleInput",qh=m.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=m.useRef(null),s=Fe(r,o),i=mh(t);return m.useEffect(()=>{const a=o.current;if(!a)return;const l=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(l,"value").set;if(i!==t&&d){const f=new Event("change",{bubbles:!0});d.call(a,t),a.dispatchEvent(f)}},[i,t]),c.jsx(ye.select,{...n,style:{...Sh,...n.style},ref:s,defaultValue:t})});qh.displayName=zS;function Gh(e){return e===""||e===void 0}function Yh(e){const t=mt(e),n=m.useRef(""),r=m.useRef(0),o=m.useCallback(i=>{const a=n.current+i;t(a),function l(u){n.current=u,window.clearTimeout(r.current),u!==""&&(r.current=window.setTimeout(()=>l(""),1e3))}(a)},[t]),s=m.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return m.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function Xh(e,t,n){const o=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=BS(e,Math.max(s,0));o.length===1&&(i=i.filter(u=>u!==n));const l=i.find(u=>u.textValue.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function BS(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var HS=Ch,Jh=kh,US=Ih,WS=Nh,VS=Ah,Zh=jh,KS=Oh,Qh=Lh,ep=$h,qS=zh,GS=Hh,tp=Uh,np=Wh,rp=Kh;const op=HS,sp=US,Ra=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(Jh,{ref:r,className:X("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[t,c.jsx(WS,{asChild:!0,children:c.jsx(ee.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));Ra.displayName=Jh.displayName;const ip=m.forwardRef(({className:e,...t},n)=>c.jsx(tp,{ref:n,className:X("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(ee.ChevronUp,{className:"h-4 w-4"})}));ip.displayName=tp.displayName;const ap=m.forwardRef(({className:e,...t},n)=>c.jsx(np,{ref:n,className:X("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(ee.ChevronDown,{className:"h-4 w-4"})}));ap.displayName=np.displayName;const Pa=m.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>c.jsx(VS,{children:c.jsxs(Zh,{ref:o,className:X("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...r,children:[c.jsx(ip,{}),c.jsx(KS,{className:X("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),c.jsx(ap,{})]})}));Pa.displayName=Zh.displayName;const YS=m.forwardRef(({className:e,...t},n)=>c.jsx(Qh,{ref:n,className:X("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));YS.displayName=Qh.displayName;const Yn=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(ep,{ref:r,className:X("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[c.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:c.jsx(GS,{children:c.jsx(ee.Check,{className:"h-4 w-4"})})}),c.jsx(qS,{children:t})]}));Yn.displayName=ep.displayName;const XS=m.forwardRef(({className:e,...t},n)=>c.jsx(rp,{ref:n,className:X("-mx-1 my-1 h-px bg-muted",e),...t}));XS.displayName=rp.displayName;var JS="Separator",lp="horizontal",ZS=["horizontal","vertical"],cp=m.forwardRef((e,t)=>{const{decorative:n,orientation:r=lp,...o}=e,s=QS(r)?r:lp,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return c.jsx(ye.div,{"data-orientation":s,...a,...o,ref:t})});cp.displayName=JS;function QS(e){return ZS.includes(e)}var up=cp;const dp=m.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>c.jsx(up,{ref:o,decorative:n,orientation:t,className:X("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));dp.displayName=up.displayName;const eC=Gu,tC=Ow,nC=Yu,fp=m.forwardRef(({className:e,...t},n)=>c.jsx(Xo,{className:X("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t,ref:n}));fp.displayName=Xo.displayName;const rC=Qr.cva("fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),hp=m.forwardRef(({side:e="right",className:t,children:n,...r},o)=>c.jsxs(nC,{children:[c.jsx(fp,{}),c.jsxs(Jo,{ref:o,className:X(rC({side:e}),t),...r,children:[n,c.jsxs(Xu,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary",children:[c.jsx(ee.X,{className:"h-4 w-4"}),c.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));hp.displayName=Jo.displayName;const pp=({className:e,...t})=>c.jsx("div",{className:X("flex flex-col space-y-2 text-center sm:text-left",e),...t});pp.displayName="SheetHeader";const mp=m.forwardRef(({className:e,...t},n)=>c.jsx(Hn,{ref:n,className:X("text-lg font-semibold text-foreground",e),...t}));mp.displayName=Hn.displayName;const gp=m.forwardRef(({className:e,...t},n)=>c.jsx(Zo,{ref:n,className:X("text-sm text-muted-foreground",e),...t}));gp.displayName=Zo.displayName;const oC={api:{baseUrl:"http://localhost:8000/api",authToken:"",enableAuth:!1},ui:{layout:"sidebar",theme:"light",showTimestamps:!0,showAgentNames:!0,compactMessages:!1},behavior:{autoSave:!0,enableStreaming:!0,showTypingIndicator:!0}};function sC({settings:e,onSettingsChange:t,className:n=""}){const[r,o]=S.useState(!1),[s,i]=S.useState(!1),[a,l]=S.useState(e),[u,d]=S.useState(!1),{toast:f}=_i();S.useEffect(()=>{const g=JSON.stringify(a)!==JSON.stringify(e);d(g)},[a,e]),S.useEffect(()=>{l(e)},[e]);const h=()=>{t(a),d(!1),f({title:"Settings saved",description:"Your chat configuration has been updated successfully."})},p=()=>{l(oC),d(!0),f({title:"Settings reset",description:"Configuration has been reset to defaults."})},w=()=>{l(e),d(!1),o(!1)},v=async()=>{try{const x=await(await fetch(`${a.api.baseUrl}/health`)).json();f({title:"Connection successful",description:`API is ${x.status||"healthy"}`})}catch{f({title:"Connection failed",description:"Unable to connect to the API endpoint.",variant:"destructive"})}};return c.jsxs(eC,{open:r,onOpenChange:o,children:[c.jsx(tC,{asChild:!0,children:c.jsxs(Ue,{variant:"outline",size:"sm",className:n,children:[c.jsx(ee.Settings,{className:"h-4 w-4 mr-2"}),"Settings",u&&c.jsx(yi,{variant:"destructive",className:"ml-2 h-4 w-4 p-0"})]})}),c.jsxs(hp,{className:"w-[500px] sm:w-[600px] overflow-y-auto",children:[c.jsxs(pp,{children:[c.jsx(mp,{children:"Chat Settings"}),c.jsx(gp,{children:"Configure your chat interface, API connection, and behavior preferences."})]}),c.jsxs("div",{className:"space-y-6 py-6",children:[c.jsxs(Dr,{children:[c.jsx(Lr,{className:"pb-3",children:c.jsxs(Fr,{className:"text-lg flex items-center gap-2",children:[c.jsx(ee.Server,{className:"h-5 w-5"}),"API Configuration"]})}),c.jsxs(jo,{className:"space-y-4",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx(Bt,{htmlFor:"api-url",children:"API Base URL"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(vs,{id:"api-url",value:a.api.baseUrl,onChange:g=>l(x=>({...x,api:{...x.api,baseUrl:g.target.value}})),placeholder:"http://localhost:8000/api"}),c.jsx(Ue,{variant:"outline",onClick:v,children:"Test"})]})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(Bt,{htmlFor:"enable-auth",children:"Enable Authentication"}),c.jsx(In,{id:"enable-auth",checked:a.api.enableAuth,onCheckedChange:g=>l(x=>({...x,api:{...x.api,enableAuth:g}}))})]}),a.api.enableAuth&&c.jsxs("div",{className:"space-y-2",children:[c.jsx(Bt,{htmlFor:"auth-token",children:"Authentication Token"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(vs,{id:"auth-token",type:s?"text":"password",value:a.api.authToken,onChange:g=>l(x=>({...x,api:{...x.api,authToken:g.target.value}})),placeholder:"Enter your Bearer token"}),c.jsx(Ue,{variant:"outline",size:"icon",onClick:()=>i(!s),children:s?c.jsx(ee.EyeOff,{className:"h-4 w-4"}):c.jsx(ee.Eye,{className:"h-4 w-4"})})]})]})]})]}),c.jsxs(Dr,{children:[c.jsx(Lr,{className:"pb-3",children:c.jsxs(Fr,{className:"text-lg flex items-center gap-2",children:[c.jsx(ee.Layout,{className:"h-5 w-5"}),"Interface Settings"]})}),c.jsxs(jo,{className:"space-y-4",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx(Bt,{htmlFor:"layout",children:"Layout Style"}),c.jsxs(op,{value:a.ui.layout,onValueChange:g=>l(x=>({...x,ui:{...x.ui,layout:g}})),children:[c.jsx(Ra,{children:c.jsx(sp,{})}),c.jsxs(Pa,{children:[c.jsx(Yn,{value:"sidebar",children:"Sidebar Layout"}),c.jsx(Yn,{value:"fullscreen",children:"Fullscreen"}),c.jsx(Yn,{value:"tabs",children:"Tabbed Interface"})]})]})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(Bt,{htmlFor:"theme",children:"Theme"}),c.jsxs(op,{value:a.ui.theme,onValueChange:g=>l(x=>({...x,ui:{...x.ui,theme:g}})),children:[c.jsx(Ra,{children:c.jsx(sp,{})}),c.jsxs(Pa,{children:[c.jsx(Yn,{value:"light",children:"Light"}),c.jsx(Yn,{value:"dark",children:"Dark"}),c.jsx(Yn,{value:"system",children:"System"})]})]})]}),c.jsx(dp,{}),c.jsxs("div",{className:"space-y-3",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(Bt,{htmlFor:"show-timestamps",children:"Show Timestamps"}),c.jsx(In,{id:"show-timestamps",checked:a.ui.showTimestamps,onCheckedChange:g=>l(x=>({...x,ui:{...x.ui,showTimestamps:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(Bt,{htmlFor:"show-agent-names",children:"Show Agent Names"}),c.jsx(In,{id:"show-agent-names",checked:a.ui.showAgentNames,onCheckedChange:g=>l(x=>({...x,ui:{...x.ui,showAgentNames:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(Bt,{htmlFor:"compact-messages",children:"Compact Messages"}),c.jsx(In,{id:"compact-messages",checked:a.ui.compactMessages,onCheckedChange:g=>l(x=>({...x,ui:{...x.ui,compactMessages:g}}))})]})]})]})]}),c.jsxs(Dr,{children:[c.jsx(Lr,{className:"pb-3",children:c.jsxs(Fr,{className:"text-lg flex items-center gap-2",children:[c.jsx(ee.MessageCircle,{className:"h-5 w-5"}),"Behavior Settings"]})}),c.jsxs(jo,{className:"space-y-4",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx(Bt,{htmlFor:"auto-save",children:"Auto-save Conversations"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Automatically save messages to threads"})]}),c.jsx(In,{id:"auto-save",checked:a.behavior.autoSave,onCheckedChange:g=>l(x=>({...x,behavior:{...x.behavior,autoSave:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx(Bt,{htmlFor:"enable-streaming",children:"Enable Streaming"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Stream responses in real-time"})]}),c.jsx(In,{id:"enable-streaming",checked:a.behavior.enableStreaming,onCheckedChange:g=>l(x=>({...x,behavior:{...x.behavior,enableStreaming:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx(Bt,{htmlFor:"typing-indicator",children:"Typing Indicator"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Show typing indicator during responses"})]}),c.jsx(In,{id:"typing-indicator",checked:a.behavior.showTypingIndicator,onCheckedChange:g=>l(x=>({...x,behavior:{...x.behavior,showTypingIndicator:g}}))})]})]})]})]}),c.jsxs("div",{className:"flex items-center justify-between pt-6 border-t",children:[c.jsxs(Ue,{variant:"outline",onClick:p,children:[c.jsx(ee.RotateCcw,{className:"h-4 w-4 mr-2"}),"Reset"]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(Ue,{variant:"outline",onClick:w,children:"Cancel"}),c.jsxs(Ue,{onClick:h,disabled:!u,children:[c.jsx(ee.Save,{className:"h-4 w-4 mr-2"}),"Save Changes"]})]})]})]})]})}function iC({layout:e="sidebar",layoutSize:t="desktop",showThreads:n=!0,className:r="",customStyles:o={},...s}){const i=u=>{const d="h-full";switch(u){case"phone":return`${d} max-w-none`;case"tablet":return`${d} max-w-4xl mx-auto`;case"half-screen":return`${d} max-w-2xl`;case"desktop":default:return`${d} max-w-7xl mx-auto`}},a=u=>({"--chat-sidebar-width":u==="phone"?"100%":u==="tablet"?"280px":u==="half-screen"?"240px":"320px","--chat-message-max-width":u==="phone"?"95%":u==="tablet"?"90%":u==="half-screen"?"85%":"80%","--chat-input-height":u==="phone"?"120px":"100px"}),l=S.useCallback(u=>{var d;(d=s.onThreadChange)==null||d.call(s,u)},[s]);return e==="fullscreen"?c.jsx(po,{...s,onThreadChange:l,children:c.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:c.jsx(xs,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?c.jsx(po,{...s,onThreadChange:l,children:c.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:c.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[n&&c.jsx("div",{className:`w-80 border-r flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:c.jsx(ka,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),c.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:c.jsx(xs,{onError:s.onError,enableFileUpload:!0})})]})})}):c.jsx(po,{...s,onThreadChange:l,children:c.jsxs("div",{className:`${i(t)} flex overflow-hidden ${r} ${o.container||""}`,style:a(t),children:[n&&c.jsx("div",{className:`w-80 border-r bg-gray-50 flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:c.jsx(ka,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),c.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:c.jsx(xs,{onError:s.onError,enableFileUpload:!0})})]})})}Ee.ChatApi=jl,Ee.ChatInterface=xs,Ee.ChatProviders=po,Ee.ChatSettings=sC,Ee.MarkdownContent=Ni,Ee.MessageComponent=sd,Ee.MessageList=qi,Ee.ThreadManager=ka,Ee.applySettings=dS,Ee.chatApiClient=xn,Ee.default=iC,Ee.del=Al,Ee.get=It,Ee.getChatToken=El,Ee.getCurrentSettings=uS,Ee.getDefaultApiConfig=uh,Ee.getDefaultChatSettings=dh,Ee.onChatTokenChanged=Il,Ee.post=Ks,Ee.put=Nl,Ee.setChatToken=Vs,Ee.useApi=qs,Ee.useChatStream=Ol,Ee.useMessages=Js,Ee.useMessagesReducer=Rl,Ee.useStream=Fl,Ee.useThreads=ho,Object.defineProperties(Ee,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
139
+ `).trim():n.replace(/</g,"&lt;").replace(/>/g,"&gt;").trim()}function Zw(e,t=es){if(!e||typeof e!="string")throw new Error("Invalid content: must be a non-empty string");if(e.length>t)throw new Error(`Message exceeds maximum length of ${t} characters`);return e}function Qw(e){let t;return typeof e=="string"?t=e:typeof e=="object"&&e!==null?t=JSON.stringify(e):t=String(e),Zw(t),Jw(t)}function Gi(e){const t=e+"CollectionProvider",[n,r]=en(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=v=>{const{scope:g,children:x}=v,b=S.useRef(null),y=S.useRef(new Map).current;return c.jsx(o,{scope:g,itemMap:y,collectionRef:b,children:x})};i.displayName=t;const a=e+"CollectionSlot",l=_n.createSlot(a),u=S.forwardRef((v,g)=>{const{scope:x,children:b}=v,y=s(a,x),k=Fe(g,y.collectionRef);return c.jsx(l,{ref:k,children:b})});u.displayName=a;const d=e+"CollectionItemSlot",f="data-radix-collection-item",h=_n.createSlot(d),p=S.forwardRef((v,g)=>{const{scope:x,children:b,...y}=v,k=S.useRef(null),C=Fe(g,k),T=s(d,x);return S.useEffect(()=>(T.itemMap.set(k,{ref:k,...y}),()=>void T.itemMap.delete(k))),c.jsx(h,{[f]:"",ref:C,children:b})});p.displayName=d;function w(v){const g=s(e+"CollectionConsumer",v);return S.useCallback(()=>{const b=g.collectionRef.current;if(!b)return[];const y=Array.from(b.querySelectorAll(`[${f}]`));return Array.from(g.itemMap.values()).sort((T,I)=>y.indexOf(T.ref.current)-y.indexOf(I.ref.current))},[g.collectionRef,g.itemMap])}return[{Provider:i,Slot:u,ItemSlot:p},w,r]}var eb=m.createContext(void 0);function ts(e){const t=m.useContext(eb);return e||t||"ltr"}const tb=["top","right","bottom","left"],En=Math.min,Rt=Math.max,ns=Math.round,rs=Math.floor,rn=e=>({x:e,y:e}),nb={left:"right",right:"left",bottom:"top",top:"bottom"},rb={start:"end",end:"start"};function Yi(e,t,n){return Rt(e,En(t,n))}function pn(e,t){return typeof e=="function"?e(t):e}function mn(e){return e.split("-")[0]}function cr(e){return e.split("-")[1]}function Xi(e){return e==="x"?"y":"x"}function Ji(e){return e==="y"?"height":"width"}const ob=new Set(["top","bottom"]);function on(e){return ob.has(mn(e))?"y":"x"}function Zi(e){return Xi(on(e))}function sb(e,t,n){n===void 0&&(n=!1);const r=cr(e),o=Zi(e),s=Ji(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=os(i)),[i,os(i)]}function ib(e){const t=os(e);return[Qi(e),t,Qi(t)]}function Qi(e){return e.replace(/start|end/g,t=>rb[t])}const ad=["left","right"],ld=["right","left"],ab=["top","bottom"],lb=["bottom","top"];function cb(e,t,n){switch(e){case"top":case"bottom":return n?t?ld:ad:t?ad:ld;case"left":case"right":return t?ab:lb;default:return[]}}function ub(e,t,n,r){const o=cr(e);let s=cb(mn(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(Qi)))),s}function os(e){return e.replace(/left|right|bottom|top/g,t=>nb[t])}function db(e){return{top:0,right:0,bottom:0,left:0,...e}}function cd(e){return typeof e!="number"?db(e):{top:e,right:e,bottom:e,left:e}}function ss(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}function ud(e,t,n){let{reference:r,floating:o}=e;const s=on(t),i=Zi(t),a=Ji(i),l=mn(t),u=s==="y",d=r.x+r.width/2-o.width/2,f=r.y+r.height/2-o.height/2,h=r[a]/2-o[a]/2;let p;switch(l){case"top":p={x:d,y:r.y-o.height};break;case"bottom":p={x:d,y:r.y+r.height};break;case"right":p={x:r.x+r.width,y:f};break;case"left":p={x:r.x-o.width,y:f};break;default:p={x:r.x,y:r.y}}switch(cr(t)){case"start":p[i]-=h*(n&&u?-1:1);break;case"end":p[i]+=h*(n&&u?-1:1);break}return p}const fb=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=n,a=s.filter(Boolean),l=await(i.isRTL==null?void 0:i.isRTL(t));let u=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:d,y:f}=ud(u,r,l),h=r,p={},w=0;for(let v=0;v<a.length;v++){const{name:g,fn:x}=a[v],{x:b,y,data:k,reset:C}=await x({x:d,y:f,initialPlacement:r,placement:h,strategy:o,middlewareData:p,rects:u,platform:i,elements:{reference:e,floating:t}});d=b??d,f=y??f,p={...p,[g]:{...p[g],...k}},C&&w<=50&&(w++,typeof C=="object"&&(C.placement&&(h=C.placement),C.rects&&(u=C.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):C.rects),{x:d,y:f}=ud(u,h,l)),v=-1)}return{x:d,y:f,placement:h,strategy:o,middlewareData:p}};async function Br(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:i,elements:a,strategy:l}=e,{boundary:u="clippingAncestors",rootBoundary:d="viewport",elementContext:f="floating",altBoundary:h=!1,padding:p=0}=pn(t,e),w=cd(p),g=a[h?f==="floating"?"reference":"floating":f],x=ss(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(g)))==null||n?g:g.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:u,rootBoundary:d,strategy:l})),b=f==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,y=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),k=await(s.isElement==null?void 0:s.isElement(y))?await(s.getScale==null?void 0:s.getScale(y))||{x:1,y:1}:{x:1,y:1},C=ss(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:b,offsetParent:y,strategy:l}):b);return{top:(x.top-C.top+w.top)/k.y,bottom:(C.bottom-x.bottom+w.bottom)/k.y,left:(x.left-C.left+w.left)/k.x,right:(C.right-x.right+w.right)/k.x}}const hb=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:s,platform:i,elements:a,middlewareData:l}=t,{element:u,padding:d=0}=pn(e,t)||{};if(u==null)return{};const f=cd(d),h={x:n,y:r},p=Zi(o),w=Ji(p),v=await i.getDimensions(u),g=p==="y",x=g?"top":"left",b=g?"bottom":"right",y=g?"clientHeight":"clientWidth",k=s.reference[w]+s.reference[p]-h[p]-s.floating[w],C=h[p]-s.reference[p],T=await(i.getOffsetParent==null?void 0:i.getOffsetParent(u));let I=T?T[y]:0;(!I||!await(i.isElement==null?void 0:i.isElement(T)))&&(I=a.floating[y]||s.floating[w]);const A=k/2-C/2,R=I/2-v[w]/2-1,j=En(f[x],R),M=En(f[b],R),D=j,L=I-v[w]-M,P=I/2-v[w]/2+A,V=Yi(D,P,L),U=!l.arrow&&cr(o)!=null&&P!==V&&s.reference[w]/2-(P<D?j:M)-v[w]/2<0,q=U?P<D?P-D:P-L:0;return{[p]:h[p]+q,data:{[p]:V,centerOffset:P-V-q,...U&&{alignmentOffset:q}},reset:U}}}),pb=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:s,rects:i,initialPlacement:a,platform:l,elements:u}=t,{mainAxis:d=!0,crossAxis:f=!0,fallbackPlacements:h,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:w="none",flipAlignment:v=!0,...g}=pn(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const x=mn(o),b=on(a),y=mn(a)===a,k=await(l.isRTL==null?void 0:l.isRTL(u.floating)),C=h||(y||!v?[os(a)]:ib(a)),T=w!=="none";!h&&T&&C.push(...ub(a,v,w,k));const I=[a,...C],A=await Br(t,g),R=[];let j=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&R.push(A[x]),f){const P=sb(o,i,k);R.push(A[P[0]],A[P[1]])}if(j=[...j,{placement:o,overflows:R}],!R.every(P=>P<=0)){var M,D;const P=(((M=s.flip)==null?void 0:M.index)||0)+1,V=I[P];if(V&&(!(f==="alignment"?b!==on(V):!1)||j.every(F=>on(F.placement)===b?F.overflows[0]>0:!0)))return{data:{index:P,overflows:j},reset:{placement:V}};let U=(D=j.filter(q=>q.overflows[0]<=0).sort((q,F)=>q.overflows[1]-F.overflows[1])[0])==null?void 0:D.placement;if(!U)switch(p){case"bestFit":{var L;const q=(L=j.filter(F=>{if(T){const N=on(F.placement);return N===b||N==="y"}return!0}).map(F=>[F.placement,F.overflows.filter(N=>N>0).reduce((N,W)=>N+W,0)]).sort((F,N)=>F[1]-N[1])[0])==null?void 0:L[0];q&&(U=q);break}case"initialPlacement":U=a;break}if(o!==U)return{reset:{placement:U}}}return{}}}};function dd(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function fd(e){return tb.some(t=>e[t]>=0)}const mb=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=pn(e,t);switch(r){case"referenceHidden":{const s=await Br(t,{...o,elementContext:"reference"}),i=dd(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:fd(i)}}}case"escaped":{const s=await Br(t,{...o,altBoundary:!0}),i=dd(s,n.floating);return{data:{escapedOffsets:i,escaped:fd(i)}}}default:return{}}}}},hd=new Set(["left","top"]);async function gb(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=mn(n),a=cr(n),l=on(n)==="y",u=hd.has(i)?-1:1,d=s&&l?-1:1,f=pn(t,e);let{mainAxis:h,crossAxis:p,alignmentAxis:w}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof w=="number"&&(p=a==="end"?w*-1:w),l?{x:p*d,y:h*u}:{x:h*u,y:p*d}}const xb=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:s,placement:i,middlewareData:a}=t,l=await gb(t,e);return i===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:o+l.x,y:s+l.y,data:{...l,placement:i}}}}},vb=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o}=t,{mainAxis:s=!0,crossAxis:i=!1,limiter:a={fn:g=>{let{x,y:b}=g;return{x,y:b}}},...l}=pn(e,t),u={x:n,y:r},d=await Br(t,l),f=on(mn(o)),h=Xi(f);let p=u[h],w=u[f];if(s){const g=h==="y"?"top":"left",x=h==="y"?"bottom":"right",b=p+d[g],y=p-d[x];p=Yi(b,p,y)}if(i){const g=f==="y"?"top":"left",x=f==="y"?"bottom":"right",b=w+d[g],y=w-d[x];w=Yi(b,w,y)}const v=a.fn({...t,[h]:p,[f]:w});return{...v,data:{x:v.x-n,y:v.y-r,enabled:{[h]:s,[f]:i}}}}}},wb=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:s,middlewareData:i}=t,{offset:a=0,mainAxis:l=!0,crossAxis:u=!0}=pn(e,t),d={x:n,y:r},f=on(o),h=Xi(f);let p=d[h],w=d[f];const v=pn(a,t),g=typeof v=="number"?{mainAxis:v,crossAxis:0}:{mainAxis:0,crossAxis:0,...v};if(l){const y=h==="y"?"height":"width",k=s.reference[h]-s.floating[y]+g.mainAxis,C=s.reference[h]+s.reference[y]-g.mainAxis;p<k?p=k:p>C&&(p=C)}if(u){var x,b;const y=h==="y"?"width":"height",k=hd.has(mn(o)),C=s.reference[f]-s.floating[y]+(k&&((x=i.offset)==null?void 0:x[f])||0)+(k?0:g.crossAxis),T=s.reference[f]+s.reference[y]+(k?0:((b=i.offset)==null?void 0:b[f])||0)-(k?g.crossAxis:0);w<C?w=C:w>T&&(w=T)}return{[h]:p,[f]:w}}}},bb=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:s,platform:i,elements:a}=t,{apply:l=()=>{},...u}=pn(e,t),d=await Br(t,u),f=mn(o),h=cr(o),p=on(o)==="y",{width:w,height:v}=s.floating;let g,x;f==="top"||f==="bottom"?(g=f,x=h===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(x=f,g=h==="end"?"top":"bottom");const b=v-d.top-d.bottom,y=w-d.left-d.right,k=En(v-d[g],b),C=En(w-d[x],y),T=!t.middlewareData.shift;let I=k,A=C;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(A=y),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(I=b),T&&!h){const j=Rt(d.left,0),M=Rt(d.right,0),D=Rt(d.top,0),L=Rt(d.bottom,0);p?A=w-2*(j!==0||M!==0?j+M:Rt(d.left,d.right)):I=v-2*(D!==0||L!==0?D+L:Rt(d.top,d.bottom))}await l({...t,availableWidth:A,availableHeight:I});const R=await i.getDimensions(a.floating);return w!==R.width||v!==R.height?{reset:{rects:!0}}:{}}}};function is(){return typeof window<"u"}function ur(e){return pd(e)?(e.nodeName||"").toLowerCase():"#document"}function Pt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function sn(e){var t;return(t=(pd(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function pd(e){return is()?e instanceof Node||e instanceof Pt(e).Node:!1}function qt(e){return is()?e instanceof Element||e instanceof Pt(e).Element:!1}function an(e){return is()?e instanceof HTMLElement||e instanceof Pt(e).HTMLElement:!1}function md(e){return!is()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Pt(e).ShadowRoot}const yb=new Set(["inline","contents"]);function Hr(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=Gt(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!yb.has(o)}const Sb=new Set(["table","td","th"]);function Cb(e){return Sb.has(ur(e))}const Tb=[":popover-open",":modal"];function as(e){return Tb.some(t=>{try{return e.matches(t)}catch{return!1}})}const Eb=["transform","translate","scale","rotate","perspective"],kb=["transform","translate","scale","rotate","perspective","filter"],Ib=["paint","layout","strict","content"];function ea(e){const t=ta(),n=qt(e)?Gt(e):e;return Eb.some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||kb.some(r=>(n.willChange||"").includes(r))||Ib.some(r=>(n.contain||"").includes(r))}function Nb(e){let t=kn(e);for(;an(t)&&!dr(t);){if(ea(t))return t;if(as(t))return null;t=kn(t)}return null}function ta(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Ab=new Set(["html","body","#document"]);function dr(e){return Ab.has(ur(e))}function Gt(e){return Pt(e).getComputedStyle(e)}function ls(e){return qt(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function kn(e){if(ur(e)==="html")return e;const t=e.assignedSlot||e.parentNode||md(e)&&e.host||sn(e);return md(t)?t.host:t}function gd(e){const t=kn(e);return dr(t)?e.ownerDocument?e.ownerDocument.body:e.body:an(t)&&Hr(t)?t:gd(t)}function Ur(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=gd(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Pt(o);if(s){const a=na(i);return t.concat(i,i.visualViewport||[],Hr(o)?o:[],a&&n?Ur(a):[])}return t.concat(o,Ur(o,[],n))}function na(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function xd(e){const t=Gt(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=an(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=ns(n)!==s||ns(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function ra(e){return qt(e)?e:e.contextElement}function fr(e){const t=ra(e);if(!an(t))return rn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=xd(t);let i=(s?ns(n.width):n.width)/r,a=(s?ns(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const jb=rn(0);function vd(e){const t=Pt(e);return!ta()||!t.visualViewport?jb:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function _b(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Pt(e)?!1:t}function Wn(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=ra(e);let i=rn(1);t&&(r?qt(r)&&(i=fr(r)):i=fr(e));const a=_b(s,n,r)?vd(s):rn(0);let l=(o.left+a.x)/i.x,u=(o.top+a.y)/i.y,d=o.width/i.x,f=o.height/i.y;if(s){const h=Pt(s),p=r&&qt(r)?Pt(r):r;let w=h,v=na(w);for(;v&&r&&p!==w;){const g=fr(v),x=v.getBoundingClientRect(),b=Gt(v),y=x.left+(v.clientLeft+parseFloat(b.paddingLeft))*g.x,k=x.top+(v.clientTop+parseFloat(b.paddingTop))*g.y;l*=g.x,u*=g.y,d*=g.x,f*=g.y,l+=y,u+=k,w=Pt(v),v=na(w)}}return ss({width:d,height:f,x:l,y:u})}function oa(e,t){const n=ls(e).scrollLeft;return t?t.left+n:Wn(sn(e)).left+n}function wd(e,t,n){n===void 0&&(n=!1);const r=e.getBoundingClientRect(),o=r.left+t.scrollLeft-(n?0:oa(e,r)),s=r.top+t.scrollTop;return{x:o,y:s}}function Rb(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=sn(r),a=t?as(t.floating):!1;if(r===i||a&&s)return n;let l={scrollLeft:0,scrollTop:0},u=rn(1);const d=rn(0),f=an(r);if((f||!f&&!s)&&((ur(r)!=="body"||Hr(i))&&(l=ls(r)),an(r))){const p=Wn(r);u=fr(r),d.x=p.x+r.clientLeft,d.y=p.y+r.clientTop}const h=i&&!f&&!s?wd(i,l,!0):rn(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-l.scrollLeft*u.x+d.x+h.x,y:n.y*u.y-l.scrollTop*u.y+d.y+h.y}}function Pb(e){return Array.from(e.getClientRects())}function Ob(e){const t=sn(e),n=ls(e),r=e.ownerDocument.body,o=Rt(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Rt(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+oa(e);const a=-n.scrollTop;return Gt(r).direction==="rtl"&&(i+=Rt(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}function Mb(e,t){const n=Pt(e),r=sn(e),o=n.visualViewport;let s=r.clientWidth,i=r.clientHeight,a=0,l=0;if(o){s=o.width,i=o.height;const u=ta();(!u||u&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}return{width:s,height:i,x:a,y:l}}const Db=new Set(["absolute","fixed"]);function Lb(e,t){const n=Wn(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=an(e)?fr(e):rn(1),i=e.clientWidth*s.x,a=e.clientHeight*s.y,l=o*s.x,u=r*s.y;return{width:i,height:a,x:l,y:u}}function bd(e,t,n){let r;if(t==="viewport")r=Mb(e,n);else if(t==="document")r=Ob(sn(e));else if(qt(t))r=Lb(t,n);else{const o=vd(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return ss(r)}function yd(e,t){const n=kn(e);return n===t||!qt(n)||dr(n)?!1:Gt(n).position==="fixed"||yd(n,t)}function Fb(e,t){const n=t.get(e);if(n)return n;let r=Ur(e,[],!1).filter(a=>qt(a)&&ur(a)!=="body"),o=null;const s=Gt(e).position==="fixed";let i=s?kn(e):e;for(;qt(i)&&!dr(i);){const a=Gt(i),l=ea(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&Db.has(o.position)||Hr(i)&&!l&&yd(e,i))?r=r.filter(d=>d!==i):o=a,i=kn(i)}return t.set(e,r),r}function $b(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?as(t)?[]:Fb(t,this._c):[].concat(n),r],a=i[0],l=i.reduce((u,d)=>{const f=bd(t,d,o);return u.top=Rt(f.top,u.top),u.right=En(f.right,u.right),u.bottom=En(f.bottom,u.bottom),u.left=Rt(f.left,u.left),u},bd(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function zb(e){const{width:t,height:n}=xd(e);return{width:t,height:n}}function Bb(e,t,n){const r=an(t),o=sn(t),s=n==="fixed",i=Wn(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=rn(0);function u(){l.x=oa(o)}if(r||!r&&!s)if((ur(t)!=="body"||Hr(o))&&(a=ls(t)),r){const p=Wn(t,!0,s,t);l.x=p.x+t.clientLeft,l.y=p.y+t.clientTop}else o&&u();s&&!r&&o&&u();const d=o&&!r&&!s?wd(o,a):rn(0),f=i.left+a.scrollLeft-l.x-d.x,h=i.top+a.scrollTop-l.y-d.y;return{x:f,y:h,width:i.width,height:i.height}}function sa(e){return Gt(e).position==="static"}function Sd(e,t){if(!an(e)||Gt(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return sn(e)===n&&(n=n.ownerDocument.body),n}function Cd(e,t){const n=Pt(e);if(as(e))return n;if(!an(e)){let o=kn(e);for(;o&&!dr(o);){if(qt(o)&&!sa(o))return o;o=kn(o)}return n}let r=Sd(e,t);for(;r&&Cb(r)&&sa(r);)r=Sd(r,t);return r&&dr(r)&&sa(r)&&!ea(r)?n:r||Nb(e)||n}const Hb=async function(e){const t=this.getOffsetParent||Cd,n=this.getDimensions,r=await n(e.floating);return{reference:Bb(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Ub(e){return Gt(e).direction==="rtl"}const Wb={convertOffsetParentRelativeRectToViewportRelativeRect:Rb,getDocumentElement:sn,getClippingRect:$b,getOffsetParent:Cd,getElementRects:Hb,getClientRects:Pb,getDimensions:zb,getScale:fr,isElement:qt,isRTL:Ub};function Td(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Vb(e,t){let n=null,r;const o=sn(e);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),s();const u=e.getBoundingClientRect(),{left:d,top:f,width:h,height:p}=u;if(a||t(),!h||!p)return;const w=rs(f),v=rs(o.clientWidth-(d+h)),g=rs(o.clientHeight-(f+p)),x=rs(d),y={rootMargin:-w+"px "+-v+"px "+-g+"px "+-x+"px",threshold:Rt(0,En(1,l))||1};let k=!0;function C(T){const I=T[0].intersectionRatio;if(I!==l){if(!k)return i();I?i(!1,I):r=setTimeout(()=>{i(!1,1e-7)},1e3)}I===1&&!Td(u,e.getBoundingClientRect())&&i(),k=!1}try{n=new IntersectionObserver(C,{...y,root:o.ownerDocument})}catch{n=new IntersectionObserver(C,y)}n.observe(e)}return i(!0),s}function Kb(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,u=ra(e),d=o||s?[...u?Ur(u):[],...Ur(t)]:[];d.forEach(x=>{o&&x.addEventListener("scroll",n,{passive:!0}),s&&x.addEventListener("resize",n)});const f=u&&a?Vb(u,n):null;let h=-1,p=null;i&&(p=new ResizeObserver(x=>{let[b]=x;b&&b.target===u&&p&&(p.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var y;(y=p)==null||y.observe(t)})),n()}),u&&!l&&p.observe(u),p.observe(t));let w,v=l?Wn(e):null;l&&g();function g(){const x=Wn(e);v&&!Td(v,x)&&n(),v=x,w=requestAnimationFrame(g)}return n(),()=>{var x;d.forEach(b=>{o&&b.removeEventListener("scroll",n),s&&b.removeEventListener("resize",n)}),f==null||f(),(x=p)==null||x.disconnect(),p=null,l&&cancelAnimationFrame(w)}}const qb=xb,Gb=vb,Yb=pb,Xb=bb,Jb=mb,Ed=hb,Zb=wb,Qb=(e,t,n)=>{const r=new Map,o={platform:Wb,...n},s={...o.platform,_c:r};return fb(e,t,{...o,platform:s})};var ey=typeof document<"u",ty=function(){},cs=ey?S.useLayoutEffect:ty;function us(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!us(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){const s=o[r];if(!(s==="_owner"&&e.$$typeof)&&!us(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function kd(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Id(e,t){const n=kd(e);return Math.round(t*n)/n}function ia(e){const t=m.useRef(e);return cs(()=>{t.current=e}),t}function ny(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:i}={},transform:a=!0,whileElementsMounted:l,open:u}=e,[d,f]=m.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[h,p]=m.useState(r);us(h,r)||p(r);const[w,v]=m.useState(null),[g,x]=m.useState(null),b=m.useCallback(F=>{F!==T.current&&(T.current=F,v(F))},[]),y=m.useCallback(F=>{F!==I.current&&(I.current=F,x(F))},[]),k=s||w,C=i||g,T=m.useRef(null),I=m.useRef(null),A=m.useRef(d),R=l!=null,j=ia(l),M=ia(o),D=ia(u),L=m.useCallback(()=>{if(!T.current||!I.current)return;const F={placement:t,strategy:n,middleware:h};M.current&&(F.platform=M.current),Qb(T.current,I.current,F).then(N=>{const W={...N,isPositioned:D.current!==!1};P.current&&!us(A.current,W)&&(A.current=W,eo.flushSync(()=>{f(W)}))})},[h,t,n,M,D]);cs(()=>{u===!1&&A.current.isPositioned&&(A.current.isPositioned=!1,f(F=>({...F,isPositioned:!1})))},[u]);const P=m.useRef(!1);cs(()=>(P.current=!0,()=>{P.current=!1}),[]),cs(()=>{if(k&&(T.current=k),C&&(I.current=C),k&&C){if(j.current)return j.current(k,C,L);L()}},[k,C,L,j,R]);const V=m.useMemo(()=>({reference:T,floating:I,setReference:b,setFloating:y}),[b,y]),U=m.useMemo(()=>({reference:k,floating:C}),[k,C]),q=m.useMemo(()=>{const F={position:n,left:0,top:0};if(!U.floating)return F;const N=Id(U.floating,d.x),W=Id(U.floating,d.y);return a?{...F,transform:"translate("+N+"px, "+W+"px)",...kd(U.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:N,top:W}},[n,a,U.floating,d.x,d.y]);return m.useMemo(()=>({...d,update:L,refs:V,elements:U,floatingStyles:q}),[d,L,V,U,q])}const ry=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:o}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?Ed({element:r.current,padding:o}).fn(n):{}:r?Ed({element:r,padding:o}).fn(n):{}}}},oy=(e,t)=>({...qb(e),options:[e,t]}),sy=(e,t)=>({...Gb(e),options:[e,t]}),iy=(e,t)=>({...Zb(e),options:[e,t]}),ay=(e,t)=>({...Yb(e),options:[e,t]}),ly=(e,t)=>({...Xb(e),options:[e,t]}),cy=(e,t)=>({...Jb(e),options:[e,t]}),uy=(e,t)=>({...ry(e),options:[e,t]});var dy="Arrow",Nd=m.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return c.jsx(ye.svg,{...s,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:c.jsx("polygon",{points:"0,0 30,0 15,10"})})});Nd.displayName=dy;var fy=Nd;function Ad(e){const[t,n]=m.useState(void 0);return pt(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const s=o[0];let i,a;if("borderBoxSize"in s){const l=s.borderBoxSize,u=Array.isArray(l)?l[0]:l;i=u.inlineSize,a=u.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var aa="Popper",[jd,ds]=en(aa),[hy,_d]=jd(aa),Rd=e=>{const{__scopePopper:t,children:n}=e,[r,o]=m.useState(null);return c.jsx(hy,{scope:t,anchor:r,onAnchorChange:o,children:n})};Rd.displayName=aa;var Pd="PopperAnchor",Od=m.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=_d(Pd,n),i=m.useRef(null),a=Fe(t,i),l=m.useRef(null);return m.useEffect(()=>{const u=l.current;l.current=(r==null?void 0:r.current)||i.current,u!==l.current&&s.onAnchorChange(l.current)}),r?null:c.jsx(ye.div,{...o,ref:a})});Od.displayName=Pd;var la="PopperContent",[py,my]=jd(la),Md=m.forwardRef((e,t)=>{var B,O,G,Z,ce,ie;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:a=0,avoidCollisions:l=!0,collisionBoundary:u=[],collisionPadding:d=0,sticky:f="partial",hideWhenDetached:h=!1,updatePositionStrategy:p="optimized",onPlaced:w,...v}=e,g=_d(la,n),[x,b]=m.useState(null),y=Fe(t,De=>b(De)),[k,C]=m.useState(null),T=Ad(k),I=(T==null?void 0:T.width)??0,A=(T==null?void 0:T.height)??0,R=r+(s!=="center"?"-"+s:""),j=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},M=Array.isArray(u)?u:[u],D=M.length>0,L={padding:j,boundary:M.filter(xy),altBoundary:D},{refs:P,floatingStyles:V,placement:U,isPositioned:q,middlewareData:F}=ny({strategy:"fixed",placement:R,whileElementsMounted:(...De)=>Kb(...De,{animationFrame:p==="always"}),elements:{reference:g.anchor},middleware:[oy({mainAxis:o+A,alignmentAxis:i}),l&&sy({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?iy():void 0,...L}),l&&ay({...L}),ly({...L,apply:({elements:De,rects:Xe,availableWidth:Je,availableHeight:Ne})=>{const{width:Oe,height:Qe}=Xe.reference,Re=De.floating.style;Re.setProperty("--radix-popper-available-width",`${Je}px`),Re.setProperty("--radix-popper-available-height",`${Ne}px`),Re.setProperty("--radix-popper-anchor-width",`${Oe}px`),Re.setProperty("--radix-popper-anchor-height",`${Qe}px`)}}),k&&uy({element:k,padding:a}),vy({arrowWidth:I,arrowHeight:A}),h&&cy({strategy:"referenceHidden",...L})]}),[N,W]=Fd(U),Y=mt(w);pt(()=>{q&&(Y==null||Y())},[q,Y]);const de=(B=F.arrow)==null?void 0:B.x,se=(O=F.arrow)==null?void 0:O.y,pe=((G=F.arrow)==null?void 0:G.centerOffset)!==0,[ge,Se]=m.useState();return pt(()=>{x&&Se(window.getComputedStyle(x).zIndex)},[x]),c.jsx("div",{ref:P.setFloating,"data-radix-popper-content-wrapper":"",style:{...V,transform:q?V.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ge,"--radix-popper-transform-origin":[(Z=F.transformOrigin)==null?void 0:Z.x,(ce=F.transformOrigin)==null?void 0:ce.y].join(" "),...((ie=F.hide)==null?void 0:ie.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:c.jsx(py,{scope:n,placedSide:N,onArrowChange:C,arrowX:de,arrowY:se,shouldHideArrow:pe,children:c.jsx(ye.div,{"data-side":N,"data-align":W,...v,ref:y,style:{...v.style,animation:q?void 0:"none"}})})})});Md.displayName=la;var Dd="PopperArrow",gy={top:"bottom",right:"left",bottom:"top",left:"right"},Ld=m.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=my(Dd,r),i=gy[s.placedSide];return c.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:c.jsx(fy,{...o,ref:n,style:{...o.style,display:"block"}})})});Ld.displayName=Dd;function xy(e){return e!==null}var vy=e=>({name:"transformOrigin",options:e,fn(t){var g,x,b;const{placement:n,rects:r,middlewareData:o}=t,i=((g=o.arrow)==null?void 0:g.centerOffset)!==0,a=i?0:e.arrowWidth,l=i?0:e.arrowHeight,[u,d]=Fd(n),f={start:"0%",center:"50%",end:"100%"}[d],h=(((x=o.arrow)==null?void 0:x.x)??0)+a/2,p=(((b=o.arrow)==null?void 0:b.y)??0)+l/2;let w="",v="";return u==="bottom"?(w=i?f:`${h}px`,v=`${-l}px`):u==="top"?(w=i?f:`${h}px`,v=`${r.floating.height+l}px`):u==="right"?(w=`${-l}px`,v=i?f:`${p}px`):u==="left"&&(w=`${r.floating.width+l}px`,v=i?f:`${p}px`),{data:{x:w,y:v}}}});function Fd(e){const[t,n="center"]=e.split("-");return[t,n]}var $d=Rd,zd=Od,Bd=Md,Hd=Ld,ca="rovingFocusGroup.onEntryFocus",wy={bubbles:!1,cancelable:!0},Wr="RovingFocusGroup",[ua,Ud,by]=Gi(Wr),[yy,Wd]=en(Wr,[by]),[Sy,Cy]=yy(Wr),Vd=m.forwardRef((e,t)=>c.jsx(ua.Provider,{scope:e.__scopeRovingFocusGroup,children:c.jsx(ua.Slot,{scope:e.__scopeRovingFocusGroup,children:c.jsx(Ty,{...e,ref:t})})}));Vd.displayName=Wr;var Ty=m.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:u,preventScrollOnEntryFocus:d=!1,...f}=e,h=m.useRef(null),p=Fe(t,h),w=ts(s),[v,g]=$n({prop:i,defaultProp:a??null,onChange:l,caller:Wr}),[x,b]=m.useState(!1),y=mt(u),k=Ud(n),C=m.useRef(!1),[T,I]=m.useState(0);return m.useEffect(()=>{const A=h.current;if(A)return A.addEventListener(ca,y),()=>A.removeEventListener(ca,y)},[y]),c.jsx(Sy,{scope:n,orientation:r,dir:w,loop:o,currentTabStopId:v,onItemFocus:m.useCallback(A=>g(A),[g]),onItemShiftTab:m.useCallback(()=>b(!0),[]),onFocusableItemAdd:m.useCallback(()=>I(A=>A+1),[]),onFocusableItemRemove:m.useCallback(()=>I(A=>A-1),[]),children:c.jsx(ye.div,{tabIndex:x||T===0?-1:0,"data-orientation":r,...f,ref:p,style:{outline:"none",...e.style},onMouseDown:oe(e.onMouseDown,()=>{C.current=!0}),onFocus:oe(e.onFocus,A=>{const R=!C.current;if(A.target===A.currentTarget&&R&&!x){const j=new CustomEvent(ca,wy);if(A.currentTarget.dispatchEvent(j),!j.defaultPrevented){const M=k().filter(U=>U.focusable),D=M.find(U=>U.active),L=M.find(U=>U.id===v),V=[D,L,...M].filter(Boolean).map(U=>U.ref.current);Gd(V,d)}}C.current=!1}),onBlur:oe(e.onBlur,()=>b(!1))})})}),Kd="RovingFocusGroupItem",qd=m.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,l=tn(),u=s||l,d=Cy(Kd,n),f=d.currentTabStopId===u,h=Ud(n),{onFocusableItemAdd:p,onFocusableItemRemove:w,currentTabStopId:v}=d;return m.useEffect(()=>{if(r)return p(),()=>w()},[r,p,w]),c.jsx(ua.ItemSlot,{scope:n,id:u,focusable:r,active:o,children:c.jsx(ye.span,{tabIndex:f?0:-1,"data-orientation":d.orientation,...a,ref:t,onMouseDown:oe(e.onMouseDown,g=>{r?d.onItemFocus(u):g.preventDefault()}),onFocus:oe(e.onFocus,()=>d.onItemFocus(u)),onKeyDown:oe(e.onKeyDown,g=>{if(g.key==="Tab"&&g.shiftKey){d.onItemShiftTab();return}if(g.target!==g.currentTarget)return;const x=Iy(g,d.orientation,d.dir);if(x!==void 0){if(g.metaKey||g.ctrlKey||g.altKey||g.shiftKey)return;g.preventDefault();let y=h().filter(k=>k.focusable).map(k=>k.ref.current);if(x==="last")y.reverse();else if(x==="prev"||x==="next"){x==="prev"&&y.reverse();const k=y.indexOf(g.currentTarget);y=d.loop?Ny(y,k+1):y.slice(k+1)}setTimeout(()=>Gd(y))}}),children:typeof i=="function"?i({isCurrentTabStop:f,hasTabStop:v!=null}):i})})});qd.displayName=Kd;var Ey={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function ky(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Iy(e,t,n){const r=ky(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return Ey[r]}function Gd(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function Ny(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Ay=Vd,jy=qd,da=["Enter"," "],_y=["ArrowDown","PageUp","Home"],Yd=["ArrowUp","PageDown","End"],Ry=[..._y,...Yd],Py={ltr:[...da,"ArrowRight"],rtl:[...da,"ArrowLeft"]},Oy={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Vr="Menu",[Kr,My,Dy]=Gi(Vr),[Vn,Xd]=en(Vr,[Dy,ds,Wd]),fs=ds(),Jd=Wd(),[Ly,Kn]=Vn(Vr),[Fy,qr]=Vn(Vr),Zd=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=fs(t),[l,u]=m.useState(null),d=m.useRef(!1),f=mt(s),h=ts(o);return m.useEffect(()=>{const p=()=>{d.current=!0,document.addEventListener("pointerdown",w,{capture:!0,once:!0}),document.addEventListener("pointermove",w,{capture:!0,once:!0})},w=()=>d.current=!1;return document.addEventListener("keydown",p,{capture:!0}),()=>{document.removeEventListener("keydown",p,{capture:!0}),document.removeEventListener("pointerdown",w,{capture:!0}),document.removeEventListener("pointermove",w,{capture:!0})}},[]),c.jsx($d,{...a,children:c.jsx(Ly,{scope:t,open:n,onOpenChange:f,content:l,onContentChange:u,children:c.jsx(Fy,{scope:t,onClose:m.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:d,dir:h,modal:i,children:r})})})};Zd.displayName=Vr;var $y="MenuAnchor",fa=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=fs(n);return c.jsx(zd,{...o,...r,ref:t})});fa.displayName=$y;var ha="MenuPortal",[zy,Qd]=Vn(ha,{forceMount:void 0}),ef=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=Kn(ha,t);return c.jsx(zy,{scope:t,forceMount:n,children:c.jsx(_t,{present:n||s.open,children:c.jsx($o,{asChild:!0,container:o,children:r})})})};ef.displayName=ha;var $t="MenuContent",[By,pa]=Vn($t),tf=m.forwardRef((e,t)=>{const n=Qd($t,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=Kn($t,e.__scopeMenu),i=qr($t,e.__scopeMenu);return c.jsx(Kr.Provider,{scope:e.__scopeMenu,children:c.jsx(_t,{present:r||s.open,children:c.jsx(Kr.Slot,{scope:e.__scopeMenu,children:i.modal?c.jsx(Hy,{...o,ref:t}):c.jsx(Uy,{...o,ref:t})})})})}),Hy=m.forwardRef((e,t)=>{const n=Kn($t,e.__scopeMenu),r=m.useRef(null),o=Fe(t,r);return m.useEffect(()=>{const s=r.current;if(s)return Hi(s)},[]),c.jsx(ma,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:oe(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),Uy=m.forwardRef((e,t)=>{const n=Kn($t,e.__scopeMenu);return c.jsx(ma,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),Wy=_n.createSlot("MenuContent.ScrollLock"),ma=m.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:h,onDismiss:p,disableOutsideScroll:w,...v}=e,g=Kn($t,n),x=qr($t,n),b=fs(n),y=Jd(n),k=My(n),[C,T]=m.useState(null),I=m.useRef(null),A=Fe(t,I,g.onContentChange),R=m.useRef(0),j=m.useRef(""),M=m.useRef(0),D=m.useRef(null),L=m.useRef("right"),P=m.useRef(0),V=w?Vo:m.Fragment,U=w?{as:Wy,allowPinchZoom:!0}:void 0,q=N=>{var B,O;const W=j.current+N,Y=k().filter(G=>!G.disabled),de=document.activeElement,se=(B=Y.find(G=>G.ref.current===de))==null?void 0:B.textValue,pe=Y.map(G=>G.textValue),ge=n0(pe,W,se),Se=(O=Y.find(G=>G.textValue===ge))==null?void 0:O.ref.current;(function G(Z){j.current=Z,window.clearTimeout(R.current),Z!==""&&(R.current=window.setTimeout(()=>G(""),1e3))})(W),Se&&setTimeout(()=>Se.focus())};m.useEffect(()=>()=>window.clearTimeout(R.current),[]),Di();const F=m.useCallback(N=>{var Y,de;return L.current===((Y=D.current)==null?void 0:Y.side)&&o0(N,(de=D.current)==null?void 0:de.area)},[]);return c.jsx(By,{scope:n,searchRef:j,onItemEnter:m.useCallback(N=>{F(N)&&N.preventDefault()},[F]),onItemLeave:m.useCallback(N=>{var W;F(N)||((W=I.current)==null||W.focus(),T(null))},[F]),onTriggerLeave:m.useCallback(N=>{F(N)&&N.preventDefault()},[F]),pointerGraceTimerRef:M,onPointerGraceIntentChange:m.useCallback(N=>{D.current=N},[]),children:c.jsx(V,{...U,children:c.jsx(Fo,{asChild:!0,trapped:o,onMountAutoFocus:oe(s,N=>{var W;N.preventDefault(),(W=I.current)==null||W.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:c.jsx(Lo,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:h,onDismiss:p,children:c.jsx(Ay,{asChild:!0,...y,dir:x.dir,orientation:"vertical",loop:r,currentTabStopId:C,onCurrentTabStopIdChange:T,onEntryFocus:oe(l,N=>{x.isUsingKeyboardRef.current||N.preventDefault()}),preventScrollOnEntryFocus:!0,children:c.jsx(Bd,{role:"menu","aria-orientation":"vertical","data-state":wf(g.open),"data-radix-menu-content":"",dir:x.dir,...b,...v,ref:A,style:{outline:"none",...v.style},onKeyDown:oe(v.onKeyDown,N=>{const Y=N.target.closest("[data-radix-menu-content]")===N.currentTarget,de=N.ctrlKey||N.altKey||N.metaKey,se=N.key.length===1;Y&&(N.key==="Tab"&&N.preventDefault(),!de&&se&&q(N.key));const pe=I.current;if(N.target!==pe||!Ry.includes(N.key))return;N.preventDefault();const Se=k().filter(B=>!B.disabled).map(B=>B.ref.current);Yd.includes(N.key)&&Se.reverse(),e0(Se)}),onBlur:oe(e.onBlur,N=>{N.currentTarget.contains(N.target)||(window.clearTimeout(R.current),j.current="")}),onPointerMove:oe(e.onPointerMove,Yr(N=>{const W=N.target,Y=P.current!==N.clientX;if(N.currentTarget.contains(W)&&Y){const de=N.clientX>P.current?"right":"left";L.current=de,P.current=N.clientX}}))})})})})})})});tf.displayName=$t;var Vy="MenuGroup",ga=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(ye.div,{role:"group",...r,ref:t})});ga.displayName=Vy;var Ky="MenuLabel",nf=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(ye.div,{...r,ref:t})});nf.displayName=Ky;var hs="MenuItem",rf="menu.itemSelect",ps=m.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=m.useRef(null),i=qr(hs,e.__scopeMenu),a=pa(hs,e.__scopeMenu),l=Fe(t,s),u=m.useRef(!1),d=()=>{const f=s.current;if(!n&&f){const h=new CustomEvent(rf,{bubbles:!0,cancelable:!0});f.addEventListener(rf,p=>r==null?void 0:r(p),{once:!0}),$c(f,h),h.defaultPrevented?u.current=!1:i.onClose()}};return c.jsx(of,{...o,ref:l,disabled:n,onClick:oe(e.onClick,d),onPointerDown:f=>{var h;(h=e.onPointerDown)==null||h.call(e,f),u.current=!0},onPointerUp:oe(e.onPointerUp,f=>{var h;u.current||(h=f.currentTarget)==null||h.click()}),onKeyDown:oe(e.onKeyDown,f=>{const h=a.searchRef.current!=="";n||h&&f.key===" "||da.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});ps.displayName=hs;var of=m.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=pa(hs,n),a=Jd(n),l=m.useRef(null),u=Fe(t,l),[d,f]=m.useState(!1),[h,p]=m.useState("");return m.useEffect(()=>{const w=l.current;w&&p((w.textContent??"").trim())},[s.children]),c.jsx(Kr.ItemSlot,{scope:n,disabled:r,textValue:o??h,children:c.jsx(jy,{asChild:!0,...a,focusable:!r,children:c.jsx(ye.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:u,onPointerMove:oe(e.onPointerMove,Yr(w=>{r?i.onItemLeave(w):(i.onItemEnter(w),w.defaultPrevented||w.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:oe(e.onPointerLeave,Yr(w=>i.onItemLeave(w))),onFocus:oe(e.onFocus,()=>f(!0)),onBlur:oe(e.onBlur,()=>f(!1))})})})}),qy="MenuCheckboxItem",sf=m.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return c.jsx(df,{scope:e.__scopeMenu,checked:n,children:c.jsx(ps,{role:"menuitemcheckbox","aria-checked":ms(n)?"mixed":n,...o,ref:t,"data-state":va(n),onSelect:oe(o.onSelect,()=>r==null?void 0:r(ms(n)?!0:!n),{checkForDefaultPrevented:!1})})})});sf.displayName=qy;var af="MenuRadioGroup",[Gy,Yy]=Vn(af,{value:void 0,onValueChange:()=>{}}),lf=m.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=mt(r);return c.jsx(Gy,{scope:e.__scopeMenu,value:n,onValueChange:s,children:c.jsx(ga,{...o,ref:t})})});lf.displayName=af;var cf="MenuRadioItem",uf=m.forwardRef((e,t)=>{const{value:n,...r}=e,o=Yy(cf,e.__scopeMenu),s=n===o.value;return c.jsx(df,{scope:e.__scopeMenu,checked:s,children:c.jsx(ps,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":va(s),onSelect:oe(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});uf.displayName=cf;var xa="MenuItemIndicator",[df,Xy]=Vn(xa,{checked:!1}),ff=m.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=Xy(xa,n);return c.jsx(_t,{present:r||ms(s.checked)||s.checked===!0,children:c.jsx(ye.span,{...o,ref:t,"data-state":va(s.checked)})})});ff.displayName=xa;var Jy="MenuSeparator",hf=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(ye.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});hf.displayName=Jy;var Zy="MenuArrow",pf=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=fs(n);return c.jsx(Hd,{...o,...r,ref:t})});pf.displayName=Zy;var Qy="MenuSub",[LC,mf]=Vn(Qy),Gr="MenuSubTrigger",gf=m.forwardRef((e,t)=>{const n=Kn(Gr,e.__scopeMenu),r=qr(Gr,e.__scopeMenu),o=mf(Gr,e.__scopeMenu),s=pa(Gr,e.__scopeMenu),i=m.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,u={__scopeMenu:e.__scopeMenu},d=m.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return m.useEffect(()=>d,[d]),m.useEffect(()=>{const f=a.current;return()=>{window.clearTimeout(f),l(null)}},[a,l]),c.jsx(fa,{asChild:!0,...u,children:c.jsx(of,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":wf(n.open),...e,ref:Si(t,o.onTriggerChange),onClick:f=>{var h;(h=e.onClick)==null||h.call(e,f),!(e.disabled||f.defaultPrevented)&&(f.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:oe(e.onPointerMove,Yr(f=>{s.onItemEnter(f),!f.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(s.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),d()},100))})),onPointerLeave:oe(e.onPointerLeave,Yr(f=>{var p,w;d();const h=(p=n.content)==null?void 0:p.getBoundingClientRect();if(h){const v=(w=n.content)==null?void 0:w.dataset.side,g=v==="right",x=g?-5:5,b=h[g?"left":"right"],y=h[g?"right":"left"];s.onPointerGraceIntentChange({area:[{x:f.clientX+x,y:f.clientY},{x:b,y:h.top},{x:y,y:h.top},{x:y,y:h.bottom},{x:b,y:h.bottom}],side:v}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(f),f.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:oe(e.onKeyDown,f=>{var p;const h=s.searchRef.current!=="";e.disabled||h&&f.key===" "||Py[r.dir].includes(f.key)&&(n.onOpenChange(!0),(p=n.content)==null||p.focus(),f.preventDefault())})})})});gf.displayName=Gr;var xf="MenuSubContent",vf=m.forwardRef((e,t)=>{const n=Qd($t,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=Kn($t,e.__scopeMenu),i=qr($t,e.__scopeMenu),a=mf(xf,e.__scopeMenu),l=m.useRef(null),u=Fe(t,l);return c.jsx(Kr.Provider,{scope:e.__scopeMenu,children:c.jsx(_t,{present:r||s.open,children:c.jsx(Kr.Slot,{scope:e.__scopeMenu,children:c.jsx(ma,{id:a.contentId,"aria-labelledby":a.triggerId,...o,ref:u,align:"start",side:i.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:d=>{var f;i.isUsingKeyboardRef.current&&((f=l.current)==null||f.focus()),d.preventDefault()},onCloseAutoFocus:d=>d.preventDefault(),onFocusOutside:oe(e.onFocusOutside,d=>{d.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:oe(e.onEscapeKeyDown,d=>{i.onClose(),d.preventDefault()}),onKeyDown:oe(e.onKeyDown,d=>{var p;const f=d.currentTarget.contains(d.target),h=Oy[i.dir].includes(d.key);f&&h&&(s.onOpenChange(!1),(p=a.trigger)==null||p.focus(),d.preventDefault())})})})})})});vf.displayName=xf;function wf(e){return e?"open":"closed"}function ms(e){return e==="indeterminate"}function va(e){return ms(e)?"indeterminate":e?"checked":"unchecked"}function e0(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function t0(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function n0(e,t,n){const o=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=t0(e,Math.max(s,0));o.length===1&&(i=i.filter(u=>u!==n));const l=i.find(u=>u.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function r0(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const a=t[s],l=t[i],u=a.x,d=a.y,f=l.x,h=l.y;d>r!=h>r&&n<(f-u)*(r-d)/(h-d)+u&&(o=!o)}return o}function o0(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return r0(n,t)}function Yr(e){return t=>t.pointerType==="mouse"?e(t):void 0}var s0=Zd,i0=fa,a0=ef,l0=tf,c0=ga,u0=nf,d0=ps,f0=sf,h0=lf,p0=uf,m0=ff,g0=hf,x0=pf,v0=gf,w0=vf,gs="DropdownMenu",[b0,FC]=en(gs,[Xd]),yt=Xd(),[y0,bf]=b0(gs),yf=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,l=yt(t),u=m.useRef(null),[d,f]=$n({prop:o,defaultProp:s??!1,onChange:i,caller:gs});return c.jsx(y0,{scope:t,triggerId:tn(),triggerRef:u,contentId:tn(),open:d,onOpenChange:f,onOpenToggle:m.useCallback(()=>f(h=>!h),[f]),modal:a,children:c.jsx(s0,{...l,open:d,onOpenChange:f,dir:r,modal:a,children:n})})};yf.displayName=gs;var Sf="DropdownMenuTrigger",Cf=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=bf(Sf,n),i=yt(n);return c.jsx(i0,{asChild:!0,...i,children:c.jsx(ye.button,{type:"button",id:s.triggerId,"aria-haspopup":"menu","aria-expanded":s.open,"aria-controls":s.open?s.contentId:void 0,"data-state":s.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...o,ref:Si(t,s.triggerRef),onPointerDown:oe(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:oe(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});Cf.displayName=Sf;var S0="DropdownMenuPortal",Tf=e=>{const{__scopeDropdownMenu:t,...n}=e,r=yt(t);return c.jsx(a0,{...r,...n})};Tf.displayName=S0;var Ef="DropdownMenuContent",kf=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=bf(Ef,n),s=yt(n),i=m.useRef(!1);return c.jsx(l0,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:oe(e.onCloseAutoFocus,a=>{var l;i.current||(l=o.triggerRef.current)==null||l.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:oe(e.onInteractOutside,a=>{const l=a.detail.originalEvent,u=l.button===0&&l.ctrlKey===!0,d=l.button===2||u;(!o.modal||d)&&(i.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});kf.displayName=Ef;var C0="DropdownMenuGroup",T0=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=yt(n);return c.jsx(c0,{...o,...r,ref:t})});T0.displayName=C0;var E0="DropdownMenuLabel",If=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=yt(n);return c.jsx(u0,{...o,...r,ref:t})});If.displayName=E0;var k0="DropdownMenuItem",Nf=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=yt(n);return c.jsx(d0,{...o,...r,ref:t})});Nf.displayName=k0;var I0="DropdownMenuCheckboxItem",Af=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=yt(n);return c.jsx(f0,{...o,...r,ref:t})});Af.displayName=I0;var N0="DropdownMenuRadioGroup",A0=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=yt(n);return c.jsx(h0,{...o,...r,ref:t})});A0.displayName=N0;var j0="DropdownMenuRadioItem",jf=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=yt(n);return c.jsx(p0,{...o,...r,ref:t})});jf.displayName=j0;var _0="DropdownMenuItemIndicator",_f=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=yt(n);return c.jsx(m0,{...o,...r,ref:t})});_f.displayName=_0;var R0="DropdownMenuSeparator",Rf=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=yt(n);return c.jsx(g0,{...o,...r,ref:t})});Rf.displayName=R0;var P0="DropdownMenuArrow",O0=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=yt(n);return c.jsx(x0,{...o,...r,ref:t})});O0.displayName=P0;var M0="DropdownMenuSubTrigger",Pf=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=yt(n);return c.jsx(v0,{...o,...r,ref:t})});Pf.displayName=M0;var D0="DropdownMenuSubContent",Of=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=yt(n);return c.jsx(w0,{...o,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Of.displayName=D0;var L0=yf,F0=Cf,$0=Tf,Mf=kf,Df=If,Lf=Nf,Ff=Af,$f=jf,zf=_f,Bf=Rf,Hf=Pf,Uf=Of;const z0=L0,B0=F0,H0=m.forwardRef(({className:e,inset:t,children:n,...r},o)=>c.jsxs(Hf,{ref:o,className:X("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",t&&"pl-8",e),...r,children:[n,c.jsx(ee.ChevronRight,{className:"ml-auto h-4 w-4"})]}));H0.displayName=Hf.displayName;const U0=m.forwardRef(({className:e,...t},n)=>c.jsx(Uf,{ref:n,className:X("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...t}));U0.displayName=Uf.displayName;const Wf=m.forwardRef(({className:e,sideOffset:t=4,...n},r)=>c.jsx($0,{children:c.jsx(Mf,{ref:r,sideOffset:t,className:X("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n})}));Wf.displayName=Mf.displayName;const wa=m.forwardRef(({className:e,inset:t,...n},r)=>c.jsx(Lf,{ref:r,className:X("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...n}));wa.displayName=Lf.displayName;const W0=m.forwardRef(({className:e,children:t,checked:n,...r},o)=>c.jsxs(Ff,{ref:o,className:X("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:n,...r,children:[c.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:c.jsx(zf,{children:c.jsx(ee.Check,{className:"h-4 w-4"})})}),t]}));W0.displayName=Ff.displayName;const V0=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs($f,{ref:r,className:X("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[c.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:c.jsx(zf,{children:c.jsx(ee.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));V0.displayName=$f.displayName;const K0=m.forwardRef(({className:e,inset:t,...n},r)=>c.jsx(Df,{ref:r,className:X("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));K0.displayName=Df.displayName;const q0=m.forwardRef(({className:e,...t},n)=>c.jsx(Bf,{ref:n,className:X("-mx-1 my-1 h-px bg-muted",e),...t}));q0.displayName=Bf.displayName;function xs({className:e="",placeholder:t="Type your message...",autoFocus:n=!0,maxHeight:r=void 0,streamingDebounceMs:o=500,streamingThrottleMs:s,followNewMessages:i=!0,enableFileUpload:a=!0,enableExcelUpload:l=!1,enableMessageEditing:u=!0,customStyles:d={},onMessageSent:f,onExcelUploadSuccess:h,onError:p}){const{api:w}=qs(),{currentThreadId:v,isLoadingThread:g,listCheckpoints:x,navigateToCheckpoint:b,returnToLatest:y}=ho(),{messages:k,hasMoreHistory:C,isLoadingHistory:T,send:I,stop:A,loadOlderMessages:R}=Js(),{isStreaming:j,error:M,streamingAssistantId:D,lastCheckpointId:L,lastCheckpointNs:P}=Fl(),[V,U]=S.useState(null),[q,F]=S.useState(""),[N,W]=S.useState(null),[Y,de]=S.useState([]),[se,pe]=S.useState(0),[ge,Se]=S.useState(0),[B,O]=S.useState(!1),[G,Z]=S.useState(null),[ce,ie]=S.useState(null),[De,Xe]=S.useState(!1),[Je,Ne]=S.useState(null),[Oe,Qe]=S.useState([]),[Re,st]=S.useState(null),[ct,Q]=S.useState(null),[le,me]=S.useState(!1),Ce=S.useRef(null),we=S.useRef(null),_e=S.useRef(null),et=S.useCallback(()=>{Ce.current&&(Ce.current.value=""),we.current&&(we.current.value=""),pe(ae=>ae+1),Se(ae=>ae+1)},[]),Ke=S.useRef(!1);S.useEffect(()=>{Ke.current&&!j&&(de([]),et()),Ke.current=j},[j,et]);const[$,J]=S.useState("desktop");S.useEffect(()=>{const ae=()=>{const xe=window.innerWidth;J(xe<640?"phone":xe<1024?"tablet":"desktop")};return ae(),window.addEventListener("resize",ae),()=>window.removeEventListener("resize",ae)},[]),S.useEffect(()=>{let ae=!1;if(!v){Qe([]),st(null),Q(null),_e.current=null;return}const xe={threadId:v,checkpointId:L??null,checkpointNs:P??null},Be=_e.current;if(!(Be&&Be.threadId===xe.threadId&&Be.checkpointId===xe.checkpointId&&Be.checkpointNs===xe.checkpointNs))return x(v).then(ot=>{var js;if(ae)return;const Mt=((ot==null?void 0:ot.checkpoints)??[]).slice().sort((gn,E)=>new Date(E.createdAt).getTime()-new Date(gn.createdAt).getTime());Qe(Mt);const dn=Re,Zr=dn&&Mt.some(gn=>gn.checkpointId===dn)?dn:((js=Mt[0])==null?void 0:js.checkpointId)??null;let As=null;if(Zr){const gn=Mt.find(E=>E.checkpointId===Zr);As=(gn==null?void 0:gn.checkpointNs)??null}st(Zr),Q(As),_e.current=xe}).catch(ot=>{console.error("ChatInterface - listCheckpoints error:",ot),ae||(Qe([]),_e.current=null)}),()=>{ae=!0}},[v,L,P,Re,x]),S.useEffect(()=>{L&&(st(L),Q(P??null))},[L,P]);const Te=S.useCallback(async()=>{if(!(!C||T))try{await R()}catch(ae){console.warn("loadOlderMessages failed",ae)}},[C,T,R]);S.useEffect(()=>{(async()=>{if(!w.baseUrl){Ne(null);return}try{const xe=await w.getAgent("default");Ne(xe.uiDefaultMessage||null)}catch(xe){console.warn("Failed to fetch default message:",xe),Ne(null)}})()},[w]),S.useEffect(()=>{M&&!De&&(p==null||p(M))},[M,De,p]);const Me=ae=>{if(ae.length>es)return`Message too long (${ae.length}/${es} characters)`;try{return Qw(ae),null}catch(xe){return(xe==null?void 0:xe.message)||"Invalid message"}},Le=async ae=>{const xe=ae.trim();if(!(!xe&&Y.length===0)){if(xe){const Be=Me(xe);if(Be){W(Be);return}}try{await I(xe||"",{checkpointId:Re??L??void 0,checkpointNs:ct??P??void 0,payloadExtras:V?{edit:!0,originalMessageId:V}:void 0,attachments:Y}),f==null||f(xe),W(null),de([]),et(),U(null),F("")}catch(Be){const ot=(Be==null?void 0:Be.message)||"Failed to send message";W(ot),p==null||p(ot)}}},it=S.useCallback((ae,xe)=>{u&&(U(ae),F(xe),W(null))},[u]),Ot=S.useCallback(()=>{U(null),F(""),W(null)},[]),gr=S.useCallback((ae,xe)=>{it(ae,xe)},[it]),Xn=S.useCallback(ae=>{const xe=Be=>{const ot=Be.content||[],Mt=ot.filter(dn=>dn.type==="text").map(dn=>dn.text).join("");if(Mt)return Mt;try{return JSON.stringify(ot,null,2)}catch{return String(ot)}};for(let Be=ae-1;Be>=0;Be--)if(k[Be].role==="user"){const ot=xe(k[Be]);ot&&I(ot,{checkpointId:Re??L??void 0,checkpointNs:ct??P??void 0});break}},[k,I,Re,ct,L,P]),xr=ae=>{const xe=Array.from(ae.target.files||[]);de(Be=>[...Be,...xe]),ae.target.value=""},cn=ae=>{de(xe=>{const Be=xe.filter((ot,Mt)=>ae!==Mt);return Be.length===0&&et(),Be})},Jn=async ae=>{const xe=(ae.target.files||[])[0];if(xe){Z(null),ie(null),O(!0);try{await I("",{checkpointId:Re??L??void 0,checkpointNs:ct??P??void 0,attachments:[xe]});const Be=`Uploaded ${xe.name} - processing through chat stream`;ie(Be)}catch(Be){const ot=Be instanceof Error?Be.message:"Failed to upload Excel file";console.error("Excel upload failed",Be),Z(ot),p==null||p(ot)}finally{O(!1),ae.target.value="",et()}}},jn=ae=>{if(!ae)return"Unknown";const xe=Date.parse(ae);return Number.isNaN(xe)?ae:new Date(xe).toLocaleString()},un=async ae=>{if(v){me(!0);try{if(!ae){await y(),st(null),Q(null);return}const xe=Oe.find(ot=>ot.checkpointId===ae),Be=(xe==null?void 0:xe.checkpointNs)??null;await b(ae,Be),st(ae),Q(Be)}finally{me(!1)}}},Ns=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${d.container||""}`,Jr=`flex-1 min-h-0 min-w-0 max-h-full w-full overflow-hidden overscroll-contain break-words break-anywhere p-4 bg-transparent ${d.messagesArea||""}`,Oa=`flex-shrink-0 w-full border-t p-4 bg-transparent ${d.inputArea||""}`;return c.jsxs("div",{className:Ns,children:[!!M&&!De&&c.jsxs("div",{className:"flex-shrink-0 bg-red-50 border border-red-200 text-red-800 px-4 py-2 text-sm flex items-center justify-between",children:[c.jsx("span",{children:M}),c.jsx(Ue,{variant:"ghost",size:"sm",onClick:()=>Xe(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:c.jsx(ee.X,{size:16})})]}),v&&Oe.length>0&&c.jsxs("div",{className:"flex-shrink-0 flex items-center gap-2 px-4 py-2 border-b border-border bg-muted/60 text-xs dark:bg-muted/50",children:[c.jsx("span",{className:"opacity-70",children:"Checkpoint:"}),c.jsxs("select",{className:"border border-border rounded px-2 py-1 text-xs bg-card text-foreground focus:outline-none focus:ring-1 focus:ring-ring dark:bg-secondary",value:Re??"",onChange:ae=>{const xe=ae.target.value||null;un(xe)},children:[c.jsx("option",{value:"",children:"Latest"}),Oe.map(ae=>c.jsxs("option",{value:ae.checkpointId,children:[jn(ae.createdAt),ae.preview?` — ${ae.preview.slice(0,40)}`:""]},ae.checkpointId))]})]}),c.jsxs("div",{className:`relative ${Jr}`,style:r?{maxHeight:r}:void 0,children:[c.jsx(qi,{className:"h-full",style:{height:"100%"},messages:k,isStreaming:j,streamingAssistantId:D,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:$,enableMessageEditing:u,editingMessageId:V,onStartReached:()=>{Te()},onEdit:gr,onRegenerate:Xn,onCancelEdit:Ot,emptyMessage:Je??void 0,isNavigatingCheckpoint:le}),g&&c.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 bg-background/80 backdrop-blur-sm text-muted-foreground",children:[c.jsx(ee.Loader2,{className:"h-6 w-6 animate-spin"}),c.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading messages…"})]})]}),c.jsxs("div",{className:Oa,children:[V&&c.jsx("div",{className:"mb-3 p-3 bg-blue-50 border border-blue-200 rounded-lg",children:c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(ee.Edit3,{size:16,className:"text-blue-600"}),c.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),c.jsx(Ue,{variant:"ghost",size:"sm",onClick:Ot,className:"text-blue-600 hover:bg-blue-100",children:c.jsx(ee.X,{size:16})})]})}),(a||l)&&c.jsxs("div",{className:"mb-3 space-y-3",children:[a&&c.jsxs(c.Fragment,{children:[c.jsx("input",{ref:Ce,type:"file",multiple:!0,onChange:ae=>xr(ae),className:"hidden"},se),Y.length>0&&c.jsx("div",{className:"flex flex-wrap gap-2",children:Y.map((ae,xe)=>c.jsxs("div",{className:"flex items-center gap-2 bg-gray-100 dark:bg-gray-800 rounded-lg px-3 py-2 text-sm text-gray-900 dark:text-gray-100",children:[c.jsx(ee.Paperclip,{size:14}),c.jsx("span",{className:"truncate max-w-[150px]",children:ae.name}),c.jsx(Ue,{variant:"ghost",size:"sm",onClick:()=>cn(xe),className:"h-4 w-4 p-0 text-gray-500 dark:text-gray-400 hover:text-red-500 dark:hover:text-red-400","aria-label":`Remove ${ae.name}`,children:c.jsx(ee.X,{size:12})})]},xe))})]}),l&&c.jsxs(c.Fragment,{children:[c.jsx("input",{ref:we,type:"file",accept:".xls,.xlsx,.xlsm",onChange:Jn,className:"hidden"},ge),B&&c.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[c.jsx(ee.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),ce&&!B&&c.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:ce}),G&&!B&&c.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:G})]})]}),N&&c.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:N}),c.jsxs("div",{className:"flex items-end gap-2",children:[(a||l)&&c.jsxs(z0,{children:[c.jsx(B0,{asChild:!0,children:c.jsx(Ue,{type:"button",size:"icon",variant:"outline",disabled:j,title:"More input actions",className:d.moreButton||"",children:c.jsx(ee.Plus,{size:16})})}),c.jsxs(Wf,{align:"start",sideOffset:6,className:"w-52",children:[a&&c.jsxs(wa,{onClick:()=>{var ae;return(ae=Ce.current)==null?void 0:ae.click()},className:"cursor-pointer",children:[c.jsx(ee.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),l&&c.jsxs(wa,{onClick:()=>{var ae;B||(ae=we.current)==null||ae.click()},className:`cursor-pointer ${B?"opacity-60 pointer-events-none":""}`,children:[c.jsx(ee.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),c.jsx("div",{className:"flex-1",children:c.jsx(fg,{initialValue:q,editingMessageId:V,placeholder:V?"Edit your message...":t,isStreaming:j,disabled:!1,maxLength:es,onSend:Le,onCancelEdit:Ot,onStop:A,allowEmptySend:Y.length>0,textareaClassName:`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${V?"border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50":""} ${N?"border-red-400":""} ${d.textarea||""}`})})]})]})]})}const vs=m.forwardRef(({className:e,type:t,...n},r)=>c.jsx("input",{type:t,className:X("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:r,...n}));vs.displayName="Input";function ba(e,[t,n]){return Math.min(n,Math.max(t,e))}function G0(e,t){return m.useReducer((n,r)=>t[n][r]??n,e)}var ya="ScrollArea",[Vf,$C]=en(ya),[Y0,zt]=Vf(ya),Kf=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,l]=m.useState(null),[u,d]=m.useState(null),[f,h]=m.useState(null),[p,w]=m.useState(null),[v,g]=m.useState(null),[x,b]=m.useState(0),[y,k]=m.useState(0),[C,T]=m.useState(!1),[I,A]=m.useState(!1),R=Fe(t,M=>l(M)),j=ts(o);return c.jsx(Y0,{scope:n,type:r,dir:j,scrollHideDelay:s,scrollArea:a,viewport:u,onViewportChange:d,content:f,onContentChange:h,scrollbarX:p,onScrollbarXChange:w,scrollbarXEnabled:C,onScrollbarXEnabledChange:T,scrollbarY:v,onScrollbarYChange:g,scrollbarYEnabled:I,onScrollbarYEnabledChange:A,onCornerWidthChange:b,onCornerHeightChange:k,children:c.jsx(ye.div,{dir:j,...i,ref:R,style:{position:"relative","--radix-scroll-area-corner-width":x+"px","--radix-scroll-area-corner-height":y+"px",...e.style}})})});Kf.displayName=ya;var qf="ScrollAreaViewport",Gf=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=zt(qf,n),a=m.useRef(null),l=Fe(t,a,i.onViewportChange);return c.jsxs(c.Fragment,{children:[c.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:o}),c.jsx(ye.div,{"data-radix-scroll-area-viewport":"",...s,ref:l,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:c.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});Gf.displayName=qf;var ln="ScrollAreaScrollbar",Sa=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=zt(ln,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:i}=o,a=e.orientation==="horizontal";return m.useEffect(()=>(a?s(!0):i(!0),()=>{a?s(!1):i(!1)}),[a,s,i]),o.type==="hover"?c.jsx(X0,{...r,ref:t,forceMount:n}):o.type==="scroll"?c.jsx(J0,{...r,ref:t,forceMount:n}):o.type==="auto"?c.jsx(Yf,{...r,ref:t,forceMount:n}):o.type==="always"?c.jsx(Ca,{...r,ref:t}):null});Sa.displayName=ln;var X0=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=zt(ln,e.__scopeScrollArea),[s,i]=m.useState(!1);return m.useEffect(()=>{const a=o.scrollArea;let l=0;if(a){const u=()=>{window.clearTimeout(l),i(!0)},d=()=>{l=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",u),a.addEventListener("pointerleave",d),()=>{window.clearTimeout(l),a.removeEventListener("pointerenter",u),a.removeEventListener("pointerleave",d)}}},[o.scrollArea,o.scrollHideDelay]),c.jsx(_t,{present:n||s,children:c.jsx(Yf,{"data-state":s?"visible":"hidden",...r,ref:t})})}),J0=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=zt(ln,e.__scopeScrollArea),s=e.orientation==="horizontal",i=Ss(()=>l("SCROLL_END"),100),[a,l]=G0("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return m.useEffect(()=>{if(a==="idle"){const u=window.setTimeout(()=>l("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(u)}},[a,o.scrollHideDelay,l]),m.useEffect(()=>{const u=o.viewport,d=s?"scrollLeft":"scrollTop";if(u){let f=u[d];const h=()=>{const p=u[d];f!==p&&(l("SCROLL"),i()),f=p};return u.addEventListener("scroll",h),()=>u.removeEventListener("scroll",h)}},[o.viewport,s,l,i]),c.jsx(_t,{present:n||a!=="hidden",children:c.jsx(Ca,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:oe(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:oe(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),Yf=m.forwardRef((e,t)=>{const n=zt(ln,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=m.useState(!1),a=e.orientation==="horizontal",l=Ss(()=>{if(n.viewport){const u=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?u:d)}},10);return hr(n.viewport,l),hr(n.content,l),c.jsx(_t,{present:r||s,children:c.jsx(Ca,{"data-state":s?"visible":"hidden",...o,ref:t})})}),Ca=m.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=zt(ln,e.__scopeScrollArea),s=m.useRef(null),i=m.useRef(0),[a,l]=m.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=eh(a.viewport,a.content),d={...r,sizes:a,onSizesChange:l,hasThumb:u>0&&u<1,onThumbChange:h=>s.current=h,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:h=>i.current=h};function f(h,p){return rS(h,i.current,a,p)}return n==="horizontal"?c.jsx(Z0,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollLeft,p=th(h,a,o.dir);s.current.style.transform=`translate3d(${p}px, 0, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollLeft=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollLeft=f(h,o.dir))}}):n==="vertical"?c.jsx(Q0,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollTop,p=th(h,a);s.current.style.transform=`translate3d(0, ${p}px, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollTop=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollTop=f(h))}}):null}),Z0=m.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=zt(ln,e.__scopeScrollArea),[i,a]=m.useState(),l=m.useRef(null),u=Fe(t,l,s.onScrollbarXChange);return m.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),c.jsx(Jf,{"data-orientation":"horizontal",...o,ref:u,sizes:n,style:{bottom:0,left:s.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:s.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":ys(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.x),onDragScroll:d=>e.onDragScroll(d.x),onWheelScroll:(d,f)=>{if(s.viewport){const h=s.viewport.scrollLeft+d.deltaX;e.onWheelScroll(h),rh(h,f)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:l.current.clientWidth,paddingStart:bs(i.paddingLeft),paddingEnd:bs(i.paddingRight)}})}})}),Q0=m.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=zt(ln,e.__scopeScrollArea),[i,a]=m.useState(),l=m.useRef(null),u=Fe(t,l,s.onScrollbarYChange);return m.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),c.jsx(Jf,{"data-orientation":"vertical",...o,ref:u,sizes:n,style:{top:0,right:s.dir==="ltr"?0:void 0,left:s.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":ys(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.y),onDragScroll:d=>e.onDragScroll(d.y),onWheelScroll:(d,f)=>{if(s.viewport){const h=s.viewport.scrollTop+d.deltaY;e.onWheelScroll(h),rh(h,f)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:l.current.clientHeight,paddingStart:bs(i.paddingTop),paddingEnd:bs(i.paddingBottom)}})}})}),[eS,Xf]=Vf(ln),Jf=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:l,onDragScroll:u,onWheelScroll:d,onResize:f,...h}=e,p=zt(ln,n),[w,v]=m.useState(null),g=Fe(t,R=>v(R)),x=m.useRef(null),b=m.useRef(""),y=p.viewport,k=r.content-r.viewport,C=mt(d),T=mt(l),I=Ss(f,10);function A(R){if(x.current){const j=R.clientX-x.current.left,M=R.clientY-x.current.top;u({x:j,y:M})}}return m.useEffect(()=>{const R=j=>{const M=j.target;(w==null?void 0:w.contains(M))&&C(j,k)};return document.addEventListener("wheel",R,{passive:!1}),()=>document.removeEventListener("wheel",R,{passive:!1})},[y,w,k,C]),m.useEffect(T,[r,T]),hr(w,I),hr(p.content,I),c.jsx(eS,{scope:n,scrollbar:w,hasThumb:o,onThumbChange:mt(s),onThumbPointerUp:mt(i),onThumbPositionChange:T,onThumbPointerDown:mt(a),children:c.jsx(ye.div,{...h,ref:g,style:{position:"absolute",...h.style},onPointerDown:oe(e.onPointerDown,R=>{R.button===0&&(R.target.setPointerCapture(R.pointerId),x.current=w.getBoundingClientRect(),b.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",p.viewport&&(p.viewport.style.scrollBehavior="auto"),A(R))}),onPointerMove:oe(e.onPointerMove,A),onPointerUp:oe(e.onPointerUp,R=>{const j=R.target;j.hasPointerCapture(R.pointerId)&&j.releasePointerCapture(R.pointerId),document.body.style.webkitUserSelect=b.current,p.viewport&&(p.viewport.style.scrollBehavior=""),x.current=null})})})}),ws="ScrollAreaThumb",Zf=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Xf(ws,e.__scopeScrollArea);return c.jsx(_t,{present:n||o.hasThumb,children:c.jsx(tS,{ref:t,...r})})}),tS=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=zt(ws,n),i=Xf(ws,n),{onThumbPositionChange:a}=i,l=Fe(t,f=>i.onThumbChange(f)),u=m.useRef(void 0),d=Ss(()=>{u.current&&(u.current(),u.current=void 0)},100);return m.useEffect(()=>{const f=s.viewport;if(f){const h=()=>{if(d(),!u.current){const p=oS(f,a);u.current=p,a()}};return a(),f.addEventListener("scroll",h),()=>f.removeEventListener("scroll",h)}},[s.viewport,d,a]),c.jsx(ye.div,{"data-state":i.hasThumb?"visible":"hidden",...o,ref:l,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:oe(e.onPointerDownCapture,f=>{const p=f.target.getBoundingClientRect(),w=f.clientX-p.left,v=f.clientY-p.top;i.onThumbPointerDown({x:w,y:v})}),onPointerUp:oe(e.onPointerUp,i.onThumbPointerUp)})});Zf.displayName=ws;var Ta="ScrollAreaCorner",Qf=m.forwardRef((e,t)=>{const n=zt(Ta,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?c.jsx(nS,{...e,ref:t}):null});Qf.displayName=Ta;var nS=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=zt(Ta,n),[s,i]=m.useState(0),[a,l]=m.useState(0),u=!!(s&&a);return hr(o.scrollbarX,()=>{var f;const d=((f=o.scrollbarX)==null?void 0:f.offsetHeight)||0;o.onCornerHeightChange(d),l(d)}),hr(o.scrollbarY,()=>{var f;const d=((f=o.scrollbarY)==null?void 0:f.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),u?c.jsx(ye.div,{...r,ref:t,style:{width:s,height:a,position:"absolute",right:o.dir==="ltr"?0:void 0,left:o.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function bs(e){return e?parseInt(e,10):0}function eh(e,t){const n=e/t;return isNaN(n)?0:n}function ys(e){const t=eh(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function rS(e,t,n,r="ltr"){const o=ys(n),s=o/2,i=t||s,a=o-i,l=n.scrollbar.paddingStart+i,u=n.scrollbar.size-n.scrollbar.paddingEnd-a,d=n.content-n.viewport,f=r==="ltr"?[0,d]:[d*-1,0];return nh([l,u],f)(e)}function th(e,t,n="ltr"){const r=ys(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,s=t.scrollbar.size-o,i=t.content-t.viewport,a=s-r,l=n==="ltr"?[0,i]:[i*-1,0],u=ba(e,l);return nh([0,i],[0,a])(u)}function nh(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function rh(e,t){return e>0&&e<t}var oS=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return function o(){const s={left:e.scrollLeft,top:e.scrollTop},i=n.left!==s.left,a=n.top!==s.top;(i||a)&&t(),n=s,r=window.requestAnimationFrame(o)}(),()=>window.cancelAnimationFrame(r)};function Ss(e,t){const n=mt(e),r=m.useRef(0);return m.useEffect(()=>()=>window.clearTimeout(r.current),[]),m.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function hr(e,t){const n=mt(t);pt(()=>{let r=0;if(e){const o=new ResizeObserver(()=>{cancelAnimationFrame(r),r=window.requestAnimationFrame(n)});return o.observe(e),()=>{window.cancelAnimationFrame(r),o.unobserve(e)}}},[e,n])}var oh=Kf,sS=Gf,iS=Qf;const sh=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(oh,{ref:r,className:X("relative overflow-hidden",e),...n,children:[c.jsx(sS,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),c.jsx(ih,{}),c.jsx(iS,{})]}));sh.displayName=oh.displayName;const ih=m.forwardRef(({className:e,orientation:t="vertical",...n},r)=>c.jsx(Sa,{ref:r,orientation:t,className:X("flex touch-none select-none transition-colors",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...n,children:c.jsx(Zf,{className:"relative flex-1 rounded-full bg-border"})}));ih.displayName=Sa.displayName;function Ea({className:e="",showCreateButton:t=!0,showDeleteButton:n=!0,showEditTitle:r=!0,maxHeight:o="400px",customStyles:s={},currentThreadId:i=null,navigateToThread:a,onThreadSelect:l,onThreadCreate:u,onThreadDelete:d}){const{loadThread:f,threads:h,currentThreadId:p,createThread:w,deleteThread:v,renameThread:g,isLoadingThreads:x}=ho(),[b,y]=S.useState(h??[]),[k,C]=S.useState(null),[T,I]=S.useState(""),[A,R]=S.useState(!1);S.useEffect(()=>{y(h??[])},[h]);const j=async N=>{try{await f(N),a==null||a(N),l==null||l(N)}catch(W){console.error("Failed to select thread:",W)}},M=async()=>{try{R(!0);const N=await w();u==null||u(N),a==null||a(N)}catch(N){console.error("Failed to create thread:",N)}finally{R(!1)}},D=async(N,W)=>{if(W.stopPropagation(),!!confirm("Delete this thread?"))try{await v(N),d==null||d(N)}catch(Y){console.error("Failed to delete thread:",Y)}},L=(N,W)=>{W.stopPropagation(),C(N.threadId),I(N.title||`Thread ${N.threadId.slice(0,8)}`)},P=async N=>{if(T.trim())try{await g(N,T.trim()),C(null),I("")}catch(W){console.error("Failed to update title:",W)}},V=()=>{C(null),I("")},U=(N,W)=>{N.key==="Enter"?P(W):N.key==="Escape"&&V()},q=N=>{if(!N)return"";try{const W=new Date(N),de=new Date().getTime()-W.getTime(),se=Math.floor(de/(1e3*60*60*24));return se===0?W.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):se===1?"Yesterday":se<7?`${se} days ago`:W.toLocaleDateString()}catch{return""}},F=N=>N.title||`Thread ${N.threadId.slice(0,8)}`;return c.jsxs("div",{className:`flex flex-col h-full ${e} ${s.container||""}`,children:[t&&c.jsx("div",{className:s.header||"flex-shrink-0 p-2 border-b bg-slate-800 border-slate-700 text-slate-100 flex justify-end",children:c.jsx(Ue,{onClick:M,disabled:A||x,className:s.createButton||"p-2",size:"sm",variant:"ghost",title:A?"Creating...":"New Chat",children:c.jsx(ee.MessageSquarePlus,{size:20})})}),c.jsx(sh,{className:`flex-1 min-h-0 ${s.threadList||""}`,style:o?{maxHeight:o}:void 0,children:c.jsx("div",{className:"p-2 space-y-1 pb-4",children:x?c.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-8 text-slate-400",children:[c.jsx(ee.Loader2,{className:"h-5 w-5 animate-spin"}),c.jsx("span",{className:"text-sm",children:"Loading threads…"})]}):b.length===0?c.jsxs("div",{className:"text-center py-8 text-slate-400",children:[c.jsx(ee.MessageSquare,{className:"w-8 h-8 mx-auto mb-2 opacity-40 text-slate-500"}),c.jsx("p",{className:"text-sm text-slate-500",children:"No conversations yet"})]}):b.slice().sort((N,W)=>new Date(W.updatedAt||W.createdAt||"").getTime()-new Date(N.updatedAt||N.createdAt||"").getTime()).map(N=>c.jsxs("div",{onClick:()=>j(N.threadId),className:`group relative p-3 rounded-lg cursor-pointer transition-colors border ${(i??p)===N.threadId?`${s.activeThread||"bg-slate-600 border-slate-500"} `:`${s.threadItem||"bg-slate-700 border-slate-600 hover:bg-slate-600 text-gray-900 dark:text-slate-100"}`} ${s.threadItem||""} text-gray-900 dark:text-slate-100`,children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("div",{className:"flex-1 min-w-0",children:k===N.threadId?c.jsxs("div",{className:"flex items-center gap-2",onClick:W=>W.stopPropagation(),children:[c.jsx(vs,{value:T,onChange:W=>I(W.target.value),onKeyDown:W=>U(W,N.threadId),className:"h-6 text-sm",autoFocus:!0}),c.jsx(Ue,{variant:"ghost",size:"sm",onClick:()=>P(N.threadId),className:"h-6 w-6 p-0",children:c.jsx(ee.Check,{size:12})}),c.jsx(Ue,{variant:"ghost",size:"sm",onClick:V,className:"h-6 w-6 p-0",children:c.jsx(ee.X,{size:12})})]}):c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"font-medium text-sm truncate text-gray-900 dark:text-slate-100",children:F(N)}),c.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-slate-400 mt-1",children:[c.jsx(ee.Calendar,{size:10}),c.jsx("span",{children:q(N.updatedAt||N.createdAt)})]})]})}),c.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2",children:[r&&k!==N.threadId&&c.jsx(Ue,{variant:"ghost",size:"sm",onClick:W=>L(N,W),className:"h-6 w-6 p-0",title:"Edit title",children:c.jsx(ee.Edit3,{size:12})}),n&&c.jsx(Ue,{variant:"ghost",size:"sm",onClick:W=>D(N.threadId,W),className:"h-6 w-6 p-0 text-red-400 hover:text-red-300 hover:bg-red-900/20",title:"Delete thread",children:c.jsx(ee.Trash2,{size:12})})]})]}),i===N.threadId&&c.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-1 h-8 bg-blue-400 rounded-r"})]},N.threadId))})})]})}function pr(e){if(!(typeof globalThis>"u"))return globalThis[e]}function aS(e){if(typeof e!="string")return;const t=e.trim();if(t)return fn(t)}function ah(){const e=[pr("__API_BASE_URL__"),pr("__CHAT_API_BASE_URL__"),pr("__CHAT_API_URL__")];for(const t of e){const n=aS(t);if(n)return n}}function lh(){const e=[pr("__API_AUTH_TOKEN__"),pr("__CHAT_API_KEY__"),pr("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function ch(...e){for(const t of e)if(typeof t=="string"&&t.trim())return fn(t);return fn()}function uh(){const e={},t=ah(),n=lh();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function dh(){const e=uh(),t=xn.getAuthToken(),n=ah();return{apiBaseUrl:ch(e.baseUrl,xn.baseUrl,n),apiKey:t||e.apiKey||lh()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,truncateToolMessages:!0,toolMessagePreviewLength:200,darkMode:!1,enableSound:!1,messageHistory:100}}const fh="chat-settings";function lS(){try{const e=localStorage.getItem(fh);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function cS(e){try{const t={...e,apiBaseUrl:fn(e.apiBaseUrl)};localStorage.setItem(fh,JSON.stringify(t)),t.apiKey&&xn.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function uS(){const e=dh(),t=lS(),n=xn.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:ch(xn.baseUrl,r,e.apiBaseUrl)}}function dS(e){xn.updateConfig({baseUrl:e.apiBaseUrl,authToken:e.apiKey??void 0}),cS(e)}var fS="Label",hh=m.forwardRef((e,t)=>c.jsx(ye.label,{...e,ref:t,onMouseDown:n=>{var o;n.target.closest("button, input, select, textarea")||((o=e.onMouseDown)==null||o.call(e,n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));hh.displayName=fS;var ph=hh;const hS=Qr.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Bt=m.forwardRef(({className:e,...t},n)=>c.jsx(ph,{ref:n,className:X(hS(),e),...t}));Bt.displayName=ph.displayName;function mh(e){const t=m.useRef({value:e,previous:e});return m.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var Cs="Switch",[pS,zC]=en(Cs),[mS,gS]=pS(Cs),gh=m.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:s,required:i,disabled:a,value:l="on",onCheckedChange:u,form:d,...f}=e,[h,p]=m.useState(null),w=Fe(t,y=>p(y)),v=m.useRef(!1),g=h?d||!!h.closest("form"):!0,[x,b]=$n({prop:o,defaultProp:s??!1,onChange:u,caller:Cs});return c.jsxs(mS,{scope:n,checked:x,disabled:a,children:[c.jsx(ye.button,{type:"button",role:"switch","aria-checked":x,"aria-required":i,"data-state":bh(x),"data-disabled":a?"":void 0,disabled:a,value:l,...f,ref:w,onClick:oe(e.onClick,y=>{b(k=>!k),g&&(v.current=y.isPropagationStopped(),v.current||y.stopPropagation())})}),g&&c.jsx(wh,{control:h,bubbles:!v.current,name:r,value:l,checked:x,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});gh.displayName=Cs;var xh="SwitchThumb",vh=m.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=gS(xh,n);return c.jsx(ye.span,{"data-state":bh(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});vh.displayName=xh;var xS="SwitchBubbleInput",wh=m.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=m.useRef(null),a=Fe(i,s),l=mh(n),u=Ad(t);return m.useEffect(()=>{const d=i.current;if(!d)return;const f=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(f,"checked").set;if(l!==n&&p){const w=new Event("click",{bubbles:r});p.call(d,n),d.dispatchEvent(w)}},[l,n,r]),c.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:a,style:{...o.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});wh.displayName=xS;function bh(e){return e?"checked":"unchecked"}var yh=gh,vS=vh;const In=m.forwardRef(({className:e,...t},n)=>c.jsx(yh,{className:X("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...t,ref:n,children:c.jsx(vS,{className:X("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));In.displayName=yh.displayName;var Sh=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),wS="VisuallyHidden",bS=m.forwardRef((e,t)=>c.jsx(ye.span,{...e,ref:t,style:{...Sh,...e.style}}));bS.displayName=wS;var yS=[" ","Enter","ArrowUp","ArrowDown"],SS=[" ","Enter"],qn="Select",[Ts,Es,CS]=Gi(qn),[mr,BC]=en(qn,[CS,ds]),ks=ds(),[TS,Nn]=mr(qn),[ES,kS]=mr(qn),Ch=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:l,dir:u,name:d,autoComplete:f,disabled:h,required:p,form:w}=e,v=ks(t),[g,x]=m.useState(null),[b,y]=m.useState(null),[k,C]=m.useState(!1),T=ts(u),[I,A]=$n({prop:r,defaultProp:o??!1,onChange:s,caller:qn}),[R,j]=$n({prop:i,defaultProp:a,onChange:l,caller:qn}),M=m.useRef(null),D=g?w||!!g.closest("form"):!0,[L,P]=m.useState(new Set),V=Array.from(L).map(U=>U.props.value).join(";");return c.jsx($d,{...v,children:c.jsxs(TS,{required:p,scope:t,trigger:g,onTriggerChange:x,valueNode:b,onValueNodeChange:y,valueNodeHasChildren:k,onValueNodeHasChildrenChange:C,contentId:tn(),value:R,onValueChange:j,open:I,onOpenChange:A,dir:T,triggerPointerDownPosRef:M,disabled:h,children:[c.jsx(Ts.Provider,{scope:t,children:c.jsx(ES,{scope:e.__scopeSelect,onNativeOptionAdd:m.useCallback(U=>{P(q=>new Set(q).add(U))},[]),onNativeOptionRemove:m.useCallback(U=>{P(q=>{const F=new Set(q);return F.delete(U),F})},[]),children:n})}),D?c.jsxs(qh,{"aria-hidden":!0,required:p,tabIndex:-1,name:d,autoComplete:f,value:R,onChange:U=>j(U.target.value),disabled:h,form:w,children:[R===void 0?c.jsx("option",{value:""}):null,Array.from(L)]},V):null]})})};Ch.displayName=qn;var Th="SelectTrigger",Eh=m.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=ks(n),i=Nn(Th,n),a=i.disabled||r,l=Fe(t,i.onTriggerChange),u=Es(n),d=m.useRef("touch"),[f,h,p]=Yh(v=>{const g=u().filter(y=>!y.disabled),x=g.find(y=>y.value===i.value),b=Xh(g,v,x);b!==void 0&&i.onValueChange(b.value)}),w=v=>{a||(i.onOpenChange(!0),p()),v&&(i.triggerPointerDownPosRef.current={x:Math.round(v.pageX),y:Math.round(v.pageY)})};return c.jsx(zd,{asChild:!0,...s,children:c.jsx(ye.button,{type:"button",role:"combobox","aria-controls":i.contentId,"aria-expanded":i.open,"aria-required":i.required,"aria-autocomplete":"none",dir:i.dir,"data-state":i.open?"open":"closed",disabled:a,"data-disabled":a?"":void 0,"data-placeholder":Gh(i.value)?"":void 0,...o,ref:l,onClick:oe(o.onClick,v=>{v.currentTarget.focus(),d.current!=="mouse"&&w(v)}),onPointerDown:oe(o.onPointerDown,v=>{d.current=v.pointerType;const g=v.target;g.hasPointerCapture(v.pointerId)&&g.releasePointerCapture(v.pointerId),v.button===0&&v.ctrlKey===!1&&v.pointerType==="mouse"&&(w(v),v.preventDefault())}),onKeyDown:oe(o.onKeyDown,v=>{const g=f.current!=="";!(v.ctrlKey||v.altKey||v.metaKey)&&v.key.length===1&&h(v.key),!(g&&v.key===" ")&&yS.includes(v.key)&&(w(),v.preventDefault())})})})});Eh.displayName=Th;var kh="SelectValue",Ih=m.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=Nn(kh,n),{onValueNodeHasChildrenChange:u}=l,d=s!==void 0,f=Fe(t,l.onValueNodeChange);return pt(()=>{u(d)},[u,d]),c.jsx(ye.span,{...a,ref:f,style:{pointerEvents:"none"},children:Gh(l.value)?c.jsx(c.Fragment,{children:i}):s})});Ih.displayName=kh;var IS="SelectIcon",Nh=m.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return c.jsx(ye.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});Nh.displayName=IS;var NS="SelectPortal",Ah=e=>c.jsx($o,{asChild:!0,...e});Ah.displayName=NS;var Gn="SelectContent",jh=m.forwardRef((e,t)=>{const n=Nn(Gn,e.__scopeSelect),[r,o]=m.useState();if(pt(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?eo.createPortal(c.jsx(_h,{scope:e.__scopeSelect,children:c.jsx(Ts.Slot,{scope:e.__scopeSelect,children:c.jsx("div",{children:e.children})})}),s):null}return c.jsx(Rh,{...e,ref:t})});jh.displayName=Gn;var Yt=10,[_h,An]=mr(Gn),AS="SelectContentImpl",jS=_n.createSlot("SelectContent.RemoveScroll"),Rh=m.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:a,sideOffset:l,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:h,collisionPadding:p,sticky:w,hideWhenDetached:v,avoidCollisions:g,...x}=e,b=Nn(Gn,n),[y,k]=m.useState(null),[C,T]=m.useState(null),I=Fe(t,B=>k(B)),[A,R]=m.useState(null),[j,M]=m.useState(null),D=Es(n),[L,P]=m.useState(!1),V=m.useRef(!1);m.useEffect(()=>{if(y)return Hi(y)},[y]),Di();const U=m.useCallback(B=>{const[O,...G]=D().map(ie=>ie.ref.current),[Z]=G.slice(-1),ce=document.activeElement;for(const ie of B)if(ie===ce||(ie==null||ie.scrollIntoView({block:"nearest"}),ie===O&&C&&(C.scrollTop=0),ie===Z&&C&&(C.scrollTop=C.scrollHeight),ie==null||ie.focus(),document.activeElement!==ce))return},[D,C]),q=m.useCallback(()=>U([A,y]),[U,A,y]);m.useEffect(()=>{L&&q()},[L,q]);const{onOpenChange:F,triggerPointerDownPosRef:N}=b;m.useEffect(()=>{if(y){let B={x:0,y:0};const O=Z=>{var ce,ie;B={x:Math.abs(Math.round(Z.pageX)-(((ce=N.current)==null?void 0:ce.x)??0)),y:Math.abs(Math.round(Z.pageY)-(((ie=N.current)==null?void 0:ie.y)??0))}},G=Z=>{B.x<=10&&B.y<=10?Z.preventDefault():y.contains(Z.target)||F(!1),document.removeEventListener("pointermove",O),N.current=null};return N.current!==null&&(document.addEventListener("pointermove",O),document.addEventListener("pointerup",G,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",O),document.removeEventListener("pointerup",G,{capture:!0})}}},[y,F,N]),m.useEffect(()=>{const B=()=>F(!1);return window.addEventListener("blur",B),window.addEventListener("resize",B),()=>{window.removeEventListener("blur",B),window.removeEventListener("resize",B)}},[F]);const[W,Y]=Yh(B=>{const O=D().filter(ce=>!ce.disabled),G=O.find(ce=>ce.ref.current===document.activeElement),Z=Xh(O,B,G);Z&&setTimeout(()=>Z.ref.current.focus())}),de=m.useCallback((B,O,G)=>{const Z=!V.current&&!G;(b.value!==void 0&&b.value===O||Z)&&(R(B),Z&&(V.current=!0))},[b.value]),se=m.useCallback(()=>y==null?void 0:y.focus(),[y]),pe=m.useCallback((B,O,G)=>{const Z=!V.current&&!G;(b.value!==void 0&&b.value===O||Z)&&M(B)},[b.value]),ge=r==="popper"?ka:Ph,Se=ge===ka?{side:a,sideOffset:l,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:h,collisionPadding:p,sticky:w,hideWhenDetached:v,avoidCollisions:g}:{};return c.jsx(_h,{scope:n,content:y,viewport:C,onViewportChange:T,itemRefCallback:de,selectedItem:A,onItemLeave:se,itemTextRefCallback:pe,focusSelectedItem:q,selectedItemText:j,position:r,isPositioned:L,searchRef:W,children:c.jsx(Vo,{as:jS,allowPinchZoom:!0,children:c.jsx(Fo,{asChild:!0,trapped:b.open,onMountAutoFocus:B=>{B.preventDefault()},onUnmountAutoFocus:oe(o,B=>{var O;(O=b.trigger)==null||O.focus({preventScroll:!0}),B.preventDefault()}),children:c.jsx(Lo,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:B=>B.preventDefault(),onDismiss:()=>b.onOpenChange(!1),children:c.jsx(ge,{role:"listbox",id:b.contentId,"data-state":b.open?"open":"closed",dir:b.dir,onContextMenu:B=>B.preventDefault(),...x,...Se,onPlaced:()=>P(!0),ref:I,style:{display:"flex",flexDirection:"column",outline:"none",...x.style},onKeyDown:oe(x.onKeyDown,B=>{const O=B.ctrlKey||B.altKey||B.metaKey;if(B.key==="Tab"&&B.preventDefault(),!O&&B.key.length===1&&Y(B.key),["ArrowUp","ArrowDown","Home","End"].includes(B.key)){let Z=D().filter(ce=>!ce.disabled).map(ce=>ce.ref.current);if(["ArrowUp","End"].includes(B.key)&&(Z=Z.slice().reverse()),["ArrowUp","ArrowDown"].includes(B.key)){const ce=B.target,ie=Z.indexOf(ce);Z=Z.slice(ie+1)}setTimeout(()=>U(Z)),B.preventDefault()}})})})})})})});Rh.displayName=AS;var _S="SelectItemAlignedPosition",Ph=m.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=Nn(Gn,n),i=An(Gn,n),[a,l]=m.useState(null),[u,d]=m.useState(null),f=Fe(t,I=>d(I)),h=Es(n),p=m.useRef(!1),w=m.useRef(!0),{viewport:v,selectedItem:g,selectedItemText:x,focusSelectedItem:b}=i,y=m.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&u&&v&&g&&x){const I=s.trigger.getBoundingClientRect(),A=u.getBoundingClientRect(),R=s.valueNode.getBoundingClientRect(),j=x.getBoundingClientRect();if(s.dir!=="rtl"){const ce=j.left-A.left,ie=R.left-ce,De=I.left-ie,Xe=I.width+De,Je=Math.max(Xe,A.width),Ne=window.innerWidth-Yt,Oe=ba(ie,[Yt,Math.max(Yt,Ne-Je)]);a.style.minWidth=Xe+"px",a.style.left=Oe+"px"}else{const ce=A.right-j.right,ie=window.innerWidth-R.right-ce,De=window.innerWidth-I.right-ie,Xe=I.width+De,Je=Math.max(Xe,A.width),Ne=window.innerWidth-Yt,Oe=ba(ie,[Yt,Math.max(Yt,Ne-Je)]);a.style.minWidth=Xe+"px",a.style.right=Oe+"px"}const M=h(),D=window.innerHeight-Yt*2,L=v.scrollHeight,P=window.getComputedStyle(u),V=parseInt(P.borderTopWidth,10),U=parseInt(P.paddingTop,10),q=parseInt(P.borderBottomWidth,10),F=parseInt(P.paddingBottom,10),N=V+U+L+F+q,W=Math.min(g.offsetHeight*5,N),Y=window.getComputedStyle(v),de=parseInt(Y.paddingTop,10),se=parseInt(Y.paddingBottom,10),pe=I.top+I.height/2-Yt,ge=D-pe,Se=g.offsetHeight/2,B=g.offsetTop+Se,O=V+U+B,G=N-O;if(O<=pe){const ce=M.length>0&&g===M[M.length-1].ref.current;a.style.bottom="0px";const ie=u.clientHeight-v.offsetTop-v.offsetHeight,De=Math.max(ge,Se+(ce?se:0)+ie+q),Xe=O+De;a.style.height=Xe+"px"}else{const ce=M.length>0&&g===M[0].ref.current;a.style.top="0px";const De=Math.max(pe,V+v.offsetTop+(ce?de:0)+Se)+G;a.style.height=De+"px",v.scrollTop=O-pe+v.offsetTop}a.style.margin=`${Yt}px 0`,a.style.minHeight=W+"px",a.style.maxHeight=D+"px",r==null||r(),requestAnimationFrame(()=>p.current=!0)}},[h,s.trigger,s.valueNode,a,u,v,g,x,s.dir,r]);pt(()=>y(),[y]);const[k,C]=m.useState();pt(()=>{u&&C(window.getComputedStyle(u).zIndex)},[u]);const T=m.useCallback(I=>{I&&w.current===!0&&(y(),b==null||b(),w.current=!1)},[y,b]);return c.jsx(PS,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:p,onScrollButtonChange:T,children:c.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:k},children:c.jsx(ye.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Ph.displayName=_S;var RS="SelectPopperPosition",ka=m.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=Yt,...s}=e,i=ks(n);return c.jsx(Bd,{...i,...s,ref:t,align:r,collisionPadding:o,style:{boxSizing:"border-box",...s.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});ka.displayName=RS;var[PS,Ia]=mr(Gn,{}),Na="SelectViewport",Oh=m.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=An(Na,n),i=Ia(Na,n),a=Fe(t,s.onViewportChange),l=m.useRef(0);return c.jsxs(c.Fragment,{children:[c.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),c.jsx(Ts.Slot,{scope:n,children:c.jsx(ye.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:oe(o.onScroll,u=>{const d=u.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:h}=i;if(h!=null&&h.current&&f){const p=Math.abs(l.current-d.scrollTop);if(p>0){const w=window.innerHeight-Yt*2,v=parseFloat(f.style.minHeight),g=parseFloat(f.style.height),x=Math.max(v,g);if(x<w){const b=x+p,y=Math.min(w,b),k=b-y;f.style.height=y+"px",f.style.bottom==="0px"&&(d.scrollTop=k>0?k:0,f.style.justifyContent="flex-end")}}}l.current=d.scrollTop})})})]})});Oh.displayName=Na;var Mh="SelectGroup",[OS,MS]=mr(Mh),DS=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=tn();return c.jsx(OS,{scope:n,id:o,children:c.jsx(ye.div,{role:"group","aria-labelledby":o,...r,ref:t})})});DS.displayName=Mh;var Dh="SelectLabel",Lh=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=MS(Dh,n);return c.jsx(ye.div,{id:o.id,...r,ref:t})});Lh.displayName=Dh;var Is="SelectItem",[LS,Fh]=mr(Is),$h=m.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=Nn(Is,n),l=An(Is,n),u=a.value===r,[d,f]=m.useState(s??""),[h,p]=m.useState(!1),w=Fe(t,b=>{var y;return(y=l.itemRefCallback)==null?void 0:y.call(l,b,r,o)}),v=tn(),g=m.useRef("touch"),x=()=>{o||(a.onValueChange(r),a.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return c.jsx(LS,{scope:n,value:r,disabled:o,textId:v,isSelected:u,onItemTextChange:m.useCallback(b=>{f(y=>y||((b==null?void 0:b.textContent)??"").trim())},[]),children:c.jsx(Ts.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:c.jsx(ye.div,{role:"option","aria-labelledby":v,"data-highlighted":h?"":void 0,"aria-selected":u&&h,"data-state":u?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:w,onFocus:oe(i.onFocus,()=>p(!0)),onBlur:oe(i.onBlur,()=>p(!1)),onClick:oe(i.onClick,()=>{g.current!=="mouse"&&x()}),onPointerUp:oe(i.onPointerUp,()=>{g.current==="mouse"&&x()}),onPointerDown:oe(i.onPointerDown,b=>{g.current=b.pointerType}),onPointerMove:oe(i.onPointerMove,b=>{var y;g.current=b.pointerType,o?(y=l.onItemLeave)==null||y.call(l):g.current==="mouse"&&b.currentTarget.focus({preventScroll:!0})}),onPointerLeave:oe(i.onPointerLeave,b=>{var y;b.currentTarget===document.activeElement&&((y=l.onItemLeave)==null||y.call(l))}),onKeyDown:oe(i.onKeyDown,b=>{var k;((k=l.searchRef)==null?void 0:k.current)!==""&&b.key===" "||(SS.includes(b.key)&&x(),b.key===" "&&b.preventDefault())})})})})});$h.displayName=Is;var Xr="SelectItemText",zh=m.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=Nn(Xr,n),a=An(Xr,n),l=Fh(Xr,n),u=kS(Xr,n),[d,f]=m.useState(null),h=Fe(t,x=>f(x),l.onItemTextChange,x=>{var b;return(b=a.itemTextRefCallback)==null?void 0:b.call(a,x,l.value,l.disabled)}),p=d==null?void 0:d.textContent,w=m.useMemo(()=>c.jsx("option",{value:l.value,disabled:l.disabled,children:p},l.value),[l.disabled,l.value,p]),{onNativeOptionAdd:v,onNativeOptionRemove:g}=u;return pt(()=>(v(w),()=>g(w)),[v,g,w]),c.jsxs(c.Fragment,{children:[c.jsx(ye.span,{id:l.textId,...s,ref:h}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?eo.createPortal(s.children,i.valueNode):null]})});zh.displayName=Xr;var Bh="SelectItemIndicator",Hh=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return Fh(Bh,n).isSelected?c.jsx(ye.span,{"aria-hidden":!0,...r,ref:t}):null});Hh.displayName=Bh;var Aa="SelectScrollUpButton",Uh=m.forwardRef((e,t)=>{const n=An(Aa,e.__scopeSelect),r=Ia(Aa,e.__scopeSelect),[o,s]=m.useState(!1),i=Fe(t,r.onScrollButtonChange);return pt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const u=l.scrollTop>0;s(u)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?c.jsx(Vh,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});Uh.displayName=Aa;var ja="SelectScrollDownButton",Wh=m.forwardRef((e,t)=>{const n=An(ja,e.__scopeSelect),r=Ia(ja,e.__scopeSelect),[o,s]=m.useState(!1),i=Fe(t,r.onScrollButtonChange);return pt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const u=l.scrollHeight-l.clientHeight,d=Math.ceil(l.scrollTop)<u;s(d)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?c.jsx(Vh,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});Wh.displayName=ja;var Vh=m.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=An("SelectScrollButton",n),i=m.useRef(null),a=Es(n),l=m.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return m.useEffect(()=>()=>l(),[l]),pt(()=>{var d;const u=a().find(f=>f.ref.current===document.activeElement);(d=u==null?void 0:u.ref.current)==null||d.scrollIntoView({block:"nearest"})},[a]),c.jsx(ye.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:oe(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:oe(o.onPointerMove,()=>{var u;(u=s.onItemLeave)==null||u.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:oe(o.onPointerLeave,()=>{l()})})}),FS="SelectSeparator",Kh=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return c.jsx(ye.div,{"aria-hidden":!0,...r,ref:t})});Kh.displayName=FS;var _a="SelectArrow",$S=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=ks(n),s=Nn(_a,n),i=An(_a,n);return s.open&&i.position==="popper"?c.jsx(Hd,{...o,...r,ref:t}):null});$S.displayName=_a;var zS="SelectBubbleInput",qh=m.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=m.useRef(null),s=Fe(r,o),i=mh(t);return m.useEffect(()=>{const a=o.current;if(!a)return;const l=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(l,"value").set;if(i!==t&&d){const f=new Event("change",{bubbles:!0});d.call(a,t),a.dispatchEvent(f)}},[i,t]),c.jsx(ye.select,{...n,style:{...Sh,...n.style},ref:s,defaultValue:t})});qh.displayName=zS;function Gh(e){return e===""||e===void 0}function Yh(e){const t=mt(e),n=m.useRef(""),r=m.useRef(0),o=m.useCallback(i=>{const a=n.current+i;t(a),function l(u){n.current=u,window.clearTimeout(r.current),u!==""&&(r.current=window.setTimeout(()=>l(""),1e3))}(a)},[t]),s=m.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return m.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function Xh(e,t,n){const o=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=BS(e,Math.max(s,0));o.length===1&&(i=i.filter(u=>u!==n));const l=i.find(u=>u.textValue.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function BS(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var HS=Ch,Jh=Eh,US=Ih,WS=Nh,VS=Ah,Zh=jh,KS=Oh,Qh=Lh,ep=$h,qS=zh,GS=Hh,tp=Uh,np=Wh,rp=Kh;const op=HS,sp=US,Ra=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(Jh,{ref:r,className:X("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[t,c.jsx(WS,{asChild:!0,children:c.jsx(ee.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));Ra.displayName=Jh.displayName;const ip=m.forwardRef(({className:e,...t},n)=>c.jsx(tp,{ref:n,className:X("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(ee.ChevronUp,{className:"h-4 w-4"})}));ip.displayName=tp.displayName;const ap=m.forwardRef(({className:e,...t},n)=>c.jsx(np,{ref:n,className:X("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(ee.ChevronDown,{className:"h-4 w-4"})}));ap.displayName=np.displayName;const Pa=m.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>c.jsx(VS,{children:c.jsxs(Zh,{ref:o,className:X("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...r,children:[c.jsx(ip,{}),c.jsx(KS,{className:X("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),c.jsx(ap,{})]})}));Pa.displayName=Zh.displayName;const YS=m.forwardRef(({className:e,...t},n)=>c.jsx(Qh,{ref:n,className:X("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));YS.displayName=Qh.displayName;const Yn=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(ep,{ref:r,className:X("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[c.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:c.jsx(GS,{children:c.jsx(ee.Check,{className:"h-4 w-4"})})}),c.jsx(qS,{children:t})]}));Yn.displayName=ep.displayName;const XS=m.forwardRef(({className:e,...t},n)=>c.jsx(rp,{ref:n,className:X("-mx-1 my-1 h-px bg-muted",e),...t}));XS.displayName=rp.displayName;var JS="Separator",lp="horizontal",ZS=["horizontal","vertical"],cp=m.forwardRef((e,t)=>{const{decorative:n,orientation:r=lp,...o}=e,s=QS(r)?r:lp,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return c.jsx(ye.div,{"data-orientation":s,...a,...o,ref:t})});cp.displayName=JS;function QS(e){return ZS.includes(e)}var up=cp;const dp=m.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>c.jsx(up,{ref:o,decorative:n,orientation:t,className:X("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));dp.displayName=up.displayName;const eC=Gu,tC=Ow,nC=Yu,fp=m.forwardRef(({className:e,...t},n)=>c.jsx(Xo,{className:X("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t,ref:n}));fp.displayName=Xo.displayName;const rC=Qr.cva("fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),hp=m.forwardRef(({side:e="right",className:t,children:n,...r},o)=>c.jsxs(nC,{children:[c.jsx(fp,{}),c.jsxs(Jo,{ref:o,className:X(rC({side:e}),t),...r,children:[n,c.jsxs(Xu,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary",children:[c.jsx(ee.X,{className:"h-4 w-4"}),c.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));hp.displayName=Jo.displayName;const pp=({className:e,...t})=>c.jsx("div",{className:X("flex flex-col space-y-2 text-center sm:text-left",e),...t});pp.displayName="SheetHeader";const mp=m.forwardRef(({className:e,...t},n)=>c.jsx(Hn,{ref:n,className:X("text-lg font-semibold text-foreground",e),...t}));mp.displayName=Hn.displayName;const gp=m.forwardRef(({className:e,...t},n)=>c.jsx(Zo,{ref:n,className:X("text-sm text-muted-foreground",e),...t}));gp.displayName=Zo.displayName;const oC={api:{baseUrl:"http://localhost:8000/api",authToken:"",enableAuth:!1},ui:{layout:"sidebar",theme:"light",showTimestamps:!0,showAgentNames:!0,compactMessages:!1},behavior:{autoSave:!0,enableStreaming:!0,showTypingIndicator:!0}};function sC({settings:e,onSettingsChange:t,className:n=""}){const[r,o]=S.useState(!1),[s,i]=S.useState(!1),[a,l]=S.useState(e),[u,d]=S.useState(!1),{toast:f}=_i();S.useEffect(()=>{const g=JSON.stringify(a)!==JSON.stringify(e);d(g)},[a,e]),S.useEffect(()=>{l(e)},[e]);const h=()=>{t(a),d(!1),f({title:"Settings saved",description:"Your chat configuration has been updated successfully."})},p=()=>{l(oC),d(!0),f({title:"Settings reset",description:"Configuration has been reset to defaults."})},w=()=>{l(e),d(!1),o(!1)},v=async()=>{try{const x=await(await fetch(`${a.api.baseUrl}/health`)).json();f({title:"Connection successful",description:`API is ${x.status||"healthy"}`})}catch{f({title:"Connection failed",description:"Unable to connect to the API endpoint.",variant:"destructive"})}};return c.jsxs(eC,{open:r,onOpenChange:o,children:[c.jsx(tC,{asChild:!0,children:c.jsxs(Ue,{variant:"outline",size:"sm",className:n,children:[c.jsx(ee.Settings,{className:"h-4 w-4 mr-2"}),"Settings",u&&c.jsx(yi,{variant:"destructive",className:"ml-2 h-4 w-4 p-0"})]})}),c.jsxs(hp,{className:"w-[500px] sm:w-[600px] overflow-y-auto",children:[c.jsxs(pp,{children:[c.jsx(mp,{children:"Chat Settings"}),c.jsx(gp,{children:"Configure your chat interface, API connection, and behavior preferences."})]}),c.jsxs("div",{className:"space-y-6 py-6",children:[c.jsxs(Dr,{children:[c.jsx(Lr,{className:"pb-3",children:c.jsxs(Fr,{className:"text-lg flex items-center gap-2",children:[c.jsx(ee.Server,{className:"h-5 w-5"}),"API Configuration"]})}),c.jsxs(jo,{className:"space-y-4",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx(Bt,{htmlFor:"api-url",children:"API Base URL"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(vs,{id:"api-url",value:a.api.baseUrl,onChange:g=>l(x=>({...x,api:{...x.api,baseUrl:g.target.value}})),placeholder:"http://localhost:8000/api"}),c.jsx(Ue,{variant:"outline",onClick:v,children:"Test"})]})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(Bt,{htmlFor:"enable-auth",children:"Enable Authentication"}),c.jsx(In,{id:"enable-auth",checked:a.api.enableAuth,onCheckedChange:g=>l(x=>({...x,api:{...x.api,enableAuth:g}}))})]}),a.api.enableAuth&&c.jsxs("div",{className:"space-y-2",children:[c.jsx(Bt,{htmlFor:"auth-token",children:"Authentication Token"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(vs,{id:"auth-token",type:s?"text":"password",value:a.api.authToken,onChange:g=>l(x=>({...x,api:{...x.api,authToken:g.target.value}})),placeholder:"Enter your Bearer token"}),c.jsx(Ue,{variant:"outline",size:"icon",onClick:()=>i(!s),children:s?c.jsx(ee.EyeOff,{className:"h-4 w-4"}):c.jsx(ee.Eye,{className:"h-4 w-4"})})]})]})]})]}),c.jsxs(Dr,{children:[c.jsx(Lr,{className:"pb-3",children:c.jsxs(Fr,{className:"text-lg flex items-center gap-2",children:[c.jsx(ee.Layout,{className:"h-5 w-5"}),"Interface Settings"]})}),c.jsxs(jo,{className:"space-y-4",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx(Bt,{htmlFor:"layout",children:"Layout Style"}),c.jsxs(op,{value:a.ui.layout,onValueChange:g=>l(x=>({...x,ui:{...x.ui,layout:g}})),children:[c.jsx(Ra,{children:c.jsx(sp,{})}),c.jsxs(Pa,{children:[c.jsx(Yn,{value:"sidebar",children:"Sidebar Layout"}),c.jsx(Yn,{value:"fullscreen",children:"Fullscreen"}),c.jsx(Yn,{value:"tabs",children:"Tabbed Interface"})]})]})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(Bt,{htmlFor:"theme",children:"Theme"}),c.jsxs(op,{value:a.ui.theme,onValueChange:g=>l(x=>({...x,ui:{...x.ui,theme:g}})),children:[c.jsx(Ra,{children:c.jsx(sp,{})}),c.jsxs(Pa,{children:[c.jsx(Yn,{value:"light",children:"Light"}),c.jsx(Yn,{value:"dark",children:"Dark"}),c.jsx(Yn,{value:"system",children:"System"})]})]})]}),c.jsx(dp,{}),c.jsxs("div",{className:"space-y-3",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(Bt,{htmlFor:"show-timestamps",children:"Show Timestamps"}),c.jsx(In,{id:"show-timestamps",checked:a.ui.showTimestamps,onCheckedChange:g=>l(x=>({...x,ui:{...x.ui,showTimestamps:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(Bt,{htmlFor:"show-agent-names",children:"Show Agent Names"}),c.jsx(In,{id:"show-agent-names",checked:a.ui.showAgentNames,onCheckedChange:g=>l(x=>({...x,ui:{...x.ui,showAgentNames:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(Bt,{htmlFor:"compact-messages",children:"Compact Messages"}),c.jsx(In,{id:"compact-messages",checked:a.ui.compactMessages,onCheckedChange:g=>l(x=>({...x,ui:{...x.ui,compactMessages:g}}))})]})]})]})]}),c.jsxs(Dr,{children:[c.jsx(Lr,{className:"pb-3",children:c.jsxs(Fr,{className:"text-lg flex items-center gap-2",children:[c.jsx(ee.MessageCircle,{className:"h-5 w-5"}),"Behavior Settings"]})}),c.jsxs(jo,{className:"space-y-4",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx(Bt,{htmlFor:"auto-save",children:"Auto-save Conversations"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Automatically save messages to threads"})]}),c.jsx(In,{id:"auto-save",checked:a.behavior.autoSave,onCheckedChange:g=>l(x=>({...x,behavior:{...x.behavior,autoSave:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx(Bt,{htmlFor:"enable-streaming",children:"Enable Streaming"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Stream responses in real-time"})]}),c.jsx(In,{id:"enable-streaming",checked:a.behavior.enableStreaming,onCheckedChange:g=>l(x=>({...x,behavior:{...x.behavior,enableStreaming:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx(Bt,{htmlFor:"typing-indicator",children:"Typing Indicator"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Show typing indicator during responses"})]}),c.jsx(In,{id:"typing-indicator",checked:a.behavior.showTypingIndicator,onCheckedChange:g=>l(x=>({...x,behavior:{...x.behavior,showTypingIndicator:g}}))})]})]})]})]}),c.jsxs("div",{className:"flex items-center justify-between pt-6 border-t",children:[c.jsxs(Ue,{variant:"outline",onClick:p,children:[c.jsx(ee.RotateCcw,{className:"h-4 w-4 mr-2"}),"Reset"]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(Ue,{variant:"outline",onClick:w,children:"Cancel"}),c.jsxs(Ue,{onClick:h,disabled:!u,children:[c.jsx(ee.Save,{className:"h-4 w-4 mr-2"}),"Save Changes"]})]})]})]})]})}function iC({layout:e="sidebar",layoutSize:t="desktop",showThreads:n=!0,className:r="",customStyles:o={},...s}){const i=u=>{const d="h-full";switch(u){case"phone":return`${d} max-w-none`;case"tablet":return`${d} max-w-4xl mx-auto`;case"half-screen":return`${d} max-w-2xl`;case"desktop":default:return`${d} max-w-7xl mx-auto`}},a=u=>({"--chat-sidebar-width":u==="phone"?"100%":u==="tablet"?"280px":u==="half-screen"?"240px":"320px","--chat-message-max-width":u==="phone"?"95%":u==="tablet"?"90%":u==="half-screen"?"85%":"80%","--chat-input-height":u==="phone"?"120px":"100px"}),l=S.useCallback(u=>{var d;(d=s.onThreadChange)==null||d.call(s,u)},[s]);return e==="fullscreen"?c.jsx(po,{...s,onThreadChange:l,children:c.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:c.jsx(xs,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?c.jsx(po,{...s,onThreadChange:l,children:c.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:c.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[n&&c.jsx("div",{className:`w-80 border-r flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:c.jsx(Ea,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),c.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:c.jsx(xs,{onError:s.onError,enableFileUpload:!0})})]})})}):c.jsx(po,{...s,onThreadChange:l,children:c.jsxs("div",{className:`${i(t)} flex overflow-hidden ${r} ${o.container||""}`,style:a(t),children:[n&&c.jsx("div",{className:`w-80 border-r bg-gray-50 flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:c.jsx(Ea,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),c.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:c.jsx(xs,{onError:s.onError,enableFileUpload:!0})})]})})}ke.ChatApi=jl,ke.ChatInterface=xs,ke.ChatProviders=po,ke.ChatSettings=sC,ke.MarkdownContent=Ni,ke.MessageComponent=sd,ke.MessageList=qi,ke.ThreadManager=Ea,ke.applySettings=dS,ke.chatApiClient=xn,ke.default=iC,ke.del=Al,ke.get=It,ke.getChatToken=kl,ke.getCurrentSettings=uS,ke.getDefaultApiConfig=uh,ke.getDefaultChatSettings=dh,ke.onChatTokenChanged=Il,ke.post=Ks,ke.put=Nl,ke.setChatToken=Vs,ke.useApi=qs,ke.useChatStream=Ol,ke.useMessages=Js,ke.useMessagesReducer=Rl,ke.useStream=Fl,ke.useThreads=ho,Object.defineProperties(ke,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});