teodor-new-chat-ui 4.3.465 → 4.3.466
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
|
@@ -14,29 +14,29 @@
|
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the MIT license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var ic;function xx(){return ic||(ic=1,process.env.NODE_ENV!=="production"&&function(){var e=b,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"),c=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),h=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),f=Symbol.for("react.offscreen"),v=Symbol.iterator,g="@@iterator";function x(
|
|
18
|
-
`+H+
|
|
17
|
+
*/var ic;function xx(){return ic||(ic=1,process.env.NODE_ENV!=="production"&&function(){var e=b,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"),c=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),h=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),f=Symbol.for("react.offscreen"),v=Symbol.iterator,g="@@iterator";function x(N){if(N===null||typeof N!="object")return null;var re=v&&N[v]||N[g];return typeof re=="function"?re:null}var y=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function w(N){{for(var re=arguments.length,de=new Array(re>1?re-1:0),Ie=1;Ie<re;Ie++)de[Ie-1]=arguments[Ie];S("error",N,de)}}function S(N,re,de){{var Ie=y.ReactDebugCurrentFrame,Ye=Ie.getStackAddendum();Ye!==""&&(re+="%s",de=de.concat([Ye]));var tt=de.map(function(Ue){return String(Ue)});tt.unshift("Warning: "+re),Function.prototype.apply.call(console[N],console,tt)}}var k=!1,C=!1,T=!1,E=!1,j=!1,_;_=Symbol.for("react.module.reference");function D(N){return!!(typeof N=="string"||typeof N=="function"||N===r||N===s||j||N===o||N===c||N===d||E||N===f||k||C||T||typeof N=="object"&&N!==null&&(N.$$typeof===m||N.$$typeof===h||N.$$typeof===i||N.$$typeof===a||N.$$typeof===l||N.$$typeof===_||N.getModuleId!==void 0))}function F(N,re,de){var Ie=N.displayName;if(Ie)return Ie;var Ye=re.displayName||re.name||"";return Ye!==""?de+"("+Ye+")":de}function G(N){return N.displayName||"Context"}function K(N){if(N==null)return null;if(typeof N.tag=="number"&&w("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof N=="function")return N.displayName||N.name||null;if(typeof N=="string")return N;switch(N){case r:return"Fragment";case n:return"Portal";case s:return"Profiler";case o:return"StrictMode";case c:return"Suspense";case d:return"SuspenseList"}if(typeof N=="object")switch(N.$$typeof){case a:var re=N;return G(re)+".Consumer";case i:var de=N;return G(de._context)+".Provider";case l:return F(N,N.render,"ForwardRef");case h:var Ie=N.displayName||null;return Ie!==null?Ie:K(N.type)||"Memo";case m:{var Ye=N,tt=Ye._payload,Ue=Ye._init;try{return K(Ue(tt))}catch{return null}}}return null}var A=Object.assign,Y=0,q,W,R,I,z,J,P;function O(){}O.__reactDisabledLog=!0;function M(){{if(Y===0){q=console.log,W=console.info,R=console.warn,I=console.error,z=console.group,J=console.groupCollapsed,P=console.groupEnd;var N={configurable:!0,enumerable:!0,value:O,writable:!0};Object.defineProperties(console,{info:N,log:N,warn:N,error:N,group:N,groupCollapsed:N,groupEnd:N})}Y++}}function L(){{if(Y--,Y===0){var N={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:A({},N,{value:q}),info:A({},N,{value:W}),warn:A({},N,{value:R}),error:A({},N,{value:I}),group:A({},N,{value:z}),groupCollapsed:A({},N,{value:J}),groupEnd:A({},N,{value:P})})}Y<0&&w("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var ee=y.ReactCurrentDispatcher,H;function $(N,re,de){{if(H===void 0)try{throw Error()}catch(Ye){var Ie=Ye.stack.trim().match(/\n( *(at )?)/);H=Ie&&Ie[1]||""}return`
|
|
18
|
+
`+H+N}}var Z=!1,te;{var Q=typeof WeakMap=="function"?WeakMap:Map;te=new Q}function U(N,re){if(!N||Z)return"";{var de=te.get(N);if(de!==void 0)return de}var Ie;Z=!0;var Ye=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var tt;tt=ee.current,ee.current=null,M();try{if(re){var Ue=function(){throw Error()};if(Object.defineProperty(Ue.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Ue,[])}catch(Vt){Ie=Vt}Reflect.construct(N,[],Ue)}else{try{Ue.call()}catch(Vt){Ie=Vt}N.call(Ue.prototype)}}else{try{throw Error()}catch(Vt){Ie=Vt}N()}}catch(Vt){if(Vt&&Ie&&typeof Vt.stack=="string"){for(var Fe=Vt.stack.split(`
|
|
19
19
|
`),$t=Ie.stack.split(`
|
|
20
20
|
`),mt=Fe.length-1,xt=$t.length-1;mt>=1&&xt>=0&&Fe[mt]!==$t[xt];)xt--;for(;mt>=1&&xt>=0;mt--,xt--)if(Fe[mt]!==$t[xt]){if(mt!==1||xt!==1)do if(mt--,xt--,xt<0||Fe[mt]!==$t[xt]){var sn=`
|
|
21
|
-
`+Fe[mt].replace(" at new "," at ");return
|
|
21
|
+
`+Fe[mt].replace(" at new "," at ");return N.displayName&&sn.includes("<anonymous>")&&(sn=sn.replace("<anonymous>",N.displayName)),typeof N=="function"&&te.set(N,sn),sn}while(mt>=1&&xt>=0);break}}}finally{Z=!1,ee.current=tt,L(),Error.prepareStackTrace=Ye}var Br=N?N.displayName||N.name:"",hr=Br?$(Br):"";return typeof N=="function"&&te.set(N,hr),hr}function le(N,re,de){return U(N,!1)}function ie(N){var re=N.prototype;return!!(re&&re.isReactComponent)}function ge(N,re,de){if(N==null)return"";if(typeof N=="function")return U(N,ie(N));if(typeof N=="string")return $(N);switch(N){case c:return $("Suspense");case d:return $("SuspenseList")}if(typeof N=="object")switch(N.$$typeof){case l:return le(N.render);case h:return ge(N.type,re,de);case m:{var Ie=N,Ye=Ie._payload,tt=Ie._init;try{return ge(tt(Ye),re,de)}catch{}}}return""}var we=Object.prototype.hasOwnProperty,Ce={},Ae=y.ReactDebugCurrentFrame;function Ee(N){if(N){var re=N._owner,de=ge(N.type,N._source,re?re.type:null);Ae.setExtraStackFrame(de)}else Ae.setExtraStackFrame(null)}function st(N,re,de,Ie,Ye){{var tt=Function.call.bind(we);for(var Ue in N)if(tt(N,Ue)){var Fe=void 0;try{if(typeof N[Ue]!="function"){var $t=Error((Ie||"React class")+": "+de+" type `"+Ue+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof N[Ue]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw $t.name="Invariant Violation",$t}Fe=N[Ue](re,Ue,Ie,de,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(mt){Fe=mt}Fe&&!(Fe instanceof Error)&&(Ee(Ye),w("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",Ie||"React class",de,Ue,typeof Fe),Ee(null)),Fe instanceof Error&&!(Fe.message in Ce)&&(Ce[Fe.message]=!0,Ee(Ye),w("Failed %s type: %s",de,Fe.message),Ee(null))}}}var lt=Array.isArray;function St(N){return lt(N)}function Oe(N){{var re=typeof Symbol=="function"&&Symbol.toStringTag,de=re&&N[Symbol.toStringTag]||N.constructor.name||"Object";return de}}function qe(N){try{return We(N),!1}catch{return!0}}function We(N){return""+N}function je(N){if(qe(N))return w("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Oe(N)),We(N)}var _e=y.ReactCurrentOwner,ct={key:!0,ref:!0,__self:!0,__source:!0},kt,nt;function Et(N){if(we.call(N,"ref")){var re=Object.getOwnPropertyDescriptor(N,"ref").get;if(re&&re.isReactWarning)return!1}return N.ref!==void 0}function bt(N){if(we.call(N,"key")){var re=Object.getOwnPropertyDescriptor(N,"key").get;if(re&&re.isReactWarning)return!1}return N.key!==void 0}function wt(N,re){typeof N.ref=="string"&&_e.current}function Ct(N,re){{var de=function(){kt||(kt=!0,w("%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)",re))};de.isReactWarning=!0,Object.defineProperty(N,"key",{get:de,configurable:!0})}}function on(N,re){{var de=function(){nt||(nt=!0,w("%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)",re))};de.isReactWarning=!0,Object.defineProperty(N,"ref",{get:de,configurable:!0})}}var Tt=function(N,re,de,Ie,Ye,tt,Ue){var Fe={$$typeof:t,type:N,key:re,ref:de,props:Ue,_owner:tt};return Fe._store={},Object.defineProperty(Fe._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(Fe,"_self",{configurable:!1,enumerable:!1,writable:!1,value:Ie}),Object.defineProperty(Fe,"_source",{configurable:!1,enumerable:!1,writable:!1,value:Ye}),Object.freeze&&(Object.freeze(Fe.props),Object.freeze(Fe)),Fe};function Lt(N,re,de,Ie,Ye){{var tt,Ue={},Fe=null,$t=null;de!==void 0&&(je(de),Fe=""+de),bt(re)&&(je(re.key),Fe=""+re.key),Et(re)&&($t=re.ref,wt(re,Ye));for(tt in re)we.call(re,tt)&&!ct.hasOwnProperty(tt)&&(Ue[tt]=re[tt]);if(N&&N.defaultProps){var mt=N.defaultProps;for(tt in mt)Ue[tt]===void 0&&(Ue[tt]=mt[tt])}if(Fe||$t){var xt=typeof N=="function"?N.displayName||N.name||"Unknown":N;Fe&&Ct(Ue,xt),$t&&on(Ue,xt)}return Tt(N,Fe,$t,Ye,Ie,_e.current,Ue)}}var _t=y.ReactCurrentOwner,$e=y.ReactDebugCurrentFrame;function ze(N){if(N){var re=N._owner,de=ge(N.type,N._source,re?re.type:null);$e.setExtraStackFrame(de)}else $e.setExtraStackFrame(null)}var Mt;Mt=!1;function X(N){return typeof N=="object"&&N!==null&&N.$$typeof===t}function fe(){{if(_t.current){var N=K(_t.current.type);if(N)return`
|
|
22
22
|
|
|
23
|
-
Check the render method of \``+
|
|
23
|
+
Check the render method of \``+N+"`."}return""}}function He(N){return""}var ae={};function me(N){{var re=fe();if(!re){var de=typeof N=="string"?N:N.displayName||N.name;de&&(re=`
|
|
24
24
|
|
|
25
|
-
Check the top-level render call using <`+de+">.")}return re}}function Se(
|
|
25
|
+
Check the top-level render call using <`+de+">.")}return re}}function Se(N,re){{if(!N._store||N._store.validated||N.key!=null)return;N._store.validated=!0;var de=me(re);if(ae[de])return;ae[de]=!0;var Ie="";N&&N._owner&&N._owner!==_t.current&&(Ie=" It was passed a child from "+K(N._owner.type)+"."),ze(N),w('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',de,Ie),ze(null)}}function Ve(N,re){{if(typeof N!="object")return;if(St(N))for(var de=0;de<N.length;de++){var Ie=N[de];X(Ie)&&Se(Ie,re)}else if(X(N))N._store&&(N._store.validated=!0);else if(N){var Ye=x(N);if(typeof Ye=="function"&&Ye!==N.entries)for(var tt=Ye.call(N),Ue;!(Ue=tt.next()).done;)X(Ue.value)&&Se(Ue.value,re)}}}function it(N){{var re=N.type;if(re==null||typeof re=="string")return;var de;if(typeof re=="function")de=re.propTypes;else if(typeof re=="object"&&(re.$$typeof===l||re.$$typeof===h))de=re.propTypes;else return;if(de){var Ie=K(re);st(de,N.props,"prop",Ie,N)}else if(re.PropTypes!==void 0&&!Mt){Mt=!0;var Ye=K(re);w("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",Ye||"Unknown")}typeof re.getDefaultProps=="function"&&!re.getDefaultProps.isReactClassApproved&&w("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function et(N){{for(var re=Object.keys(N.props),de=0;de<re.length;de++){var Ie=re[de];if(Ie!=="children"&&Ie!=="key"){ze(N),w("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",Ie),ze(null);break}}N.ref!==null&&(ze(N),w("Invalid attribute `ref` supplied to `React.Fragment`."),ze(null))}}var Qt={};function Re(N,re,de,Ie,Ye,tt){{var Ue=D(N);if(!Ue){var Fe="";(N===void 0||typeof N=="object"&&N!==null&&Object.keys(N).length===0)&&(Fe+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var $t=He();$t?Fe+=$t:Fe+=fe();var mt;N===null?mt="null":St(N)?mt="array":N!==void 0&&N.$$typeof===t?(mt="<"+(K(N.type)||"Unknown")+" />",Fe=" Did you accidentally export a JSX literal instead of a component?"):mt=typeof N,w("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",mt,Fe)}var xt=Lt(N,re,de,Ye,tt);if(xt==null)return xt;if(Ue){var sn=re.children;if(sn!==void 0)if(Ie)if(St(sn)){for(var Br=0;Br<sn.length;Br++)Ve(sn[Br],N);Object.freeze&&Object.freeze(sn)}else w("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Ve(sn,N)}if(we.call(re,"key")){var hr=K(N),Vt=Object.keys(re).filter(function(oN){return oN!=="key"}),Jl=Vt.length>0?"{key: someKey, "+Vt.join(": ..., ")+": ...}":"{key: someKey}";if(!Qt[hr+Jl]){var rN=Vt.length>0?"{"+Vt.join(": ..., ")+": ...}":"{}";w(`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} />`,Jl,hr,rN,hr),Qt[hr+Jl]=!0}}return A===r?et(xt):it(xt),xt}}function pt(A,re,de){return Re(A,re,de,!0)}function Je(A,re,de){return Re(A,re,de,!1)}var ut=Je,In=pt;Wr.Fragment=r,Wr.jsx=ut,Wr.jsxs=In}()),Wr}process.env.NODE_ENV==="production"?xi.exports=gx():xi.exports=xx();var u=xi.exports;const vx=({timelineEntries:e,activeCheckpointId:t,onSelectCheckpoint:n,messagePreviews:r,className:o,onHoverStart:s,onHoverEnd:i})=>{const a=e??[],l=a.length>0,c=b.useMemo(()=>l?[...a].reverse():[],[a,l]),d=t??(a.length?a[a.length-1].id:null);if(!l)return null;const m=["w-32 flex-shrink-0 flex-col border-r border-border/40 pr-2 flex bg-white text-gray-900 dark:bg-slate-900 dark:text-slate-100",o].filter(Boolean).join(" ");return u.jsxs("div",{className:m,onMouseEnter:s,onMouseLeave:i,children:[u.jsxs("div",{className:"relative flex-1 overflow-y-auto pt-4 pb-2 pr-1",children:[u.jsx("div",{className:"absolute left-0 right-0 top-1 px-2 pb-3 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:u.jsx("span",{children:"Timeline"})}),u.jsx("div",{className:"pointer-events-none absolute left-3 top-0 bottom-0 w-px bg-border/40"}),u.jsx("div",{className:"flex flex-col gap-3 pt-6 pr-2",children:c.map(f=>{const v=d===f.id,g=(r==null?void 0:r.get(f.id))??null;return u.jsxs("button",{type:"button",disabled:!n,onClick:()=>n==null?void 0:n(f.id),className:`relative flex items-start gap-2 text-left text-[11px] transition ${v?"text-primary":"text-muted-foreground"} ${n?"hover:text-foreground":"cursor-default opacity-70"}`,children:[u.jsx("span",{className:`mt-1 inline-flex h-3 w-3 items-center justify-center rounded-full border ${v?"border-primary bg-primary/10 text-primary":"border-border bg-background"}`,children:u.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${v?"bg-primary":"bg-border"}`})}),u.jsxs("span",{className:"flex-1",children:[u.jsx("span",{className:"block font-medium leading-tight",children:f.label||"User input"}),u.jsxs("span",{className:"text-[9px] uppercase tracking-wide text-muted-foreground/70",children:[f.step!==null?`STEP ${f.step}`:"STEP —",f.next?` - ${f.next}`:""]}),g&&u.jsx("p",{className:"text-[10px] text-muted-foreground/80 mt-1 line-clamp-2",title:g,children:g})]})]},f.id)})})]}),n&&u.jsx("button",{type:"button",onClick:()=>n==null?void 0:n(null),className:"mt-auto mb-3 rounded-md border border-border/70 px-2 py-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground transition hover:border-foreground/60 hover:text-foreground",children:"Latest"})]})};function ac(e,t){return function(){return e.apply(t,arguments)}}const{toString:bx}=Object.prototype,{getPrototypeOf:vi}=Object,{iterator:Ro,toStringTag:lc}=Symbol,Oo=(e=>t=>{const n=bx.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),an=e=>(e=e.toLowerCase(),t=>Oo(t)===e),Do=e=>t=>typeof t===e,{isArray:pr}=Array,mr=Do("undefined");function Vr(e){return e!==null&&!mr(e)&&e.constructor!==null&&!mr(e.constructor)&&Ft(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const cc=an("ArrayBuffer");function wx(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&cc(e.buffer),t}const yx=Do("string"),Ft=Do("function"),uc=Do("number"),Kr=e=>e!==null&&typeof e=="object",Sx=e=>e===!0||e===!1,Lo=e=>{if(Oo(e)!=="object")return!1;const t=vi(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(lc in e)&&!(Ro in e)},Cx=e=>{if(!Kr(e)||Vr(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},Tx=an("Date"),kx=an("File"),Ex=an("Blob"),Ix=an("FileList"),Nx=e=>Kr(e)&&Ft(e.pipe),Ax=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||Ft(e.append)&&((t=Oo(e))==="formdata"||t==="object"&&Ft(e.toString)&&e.toString()==="[object FormData]"))},jx=an("URLSearchParams"),[Px,_x,Mx,Rx]=["ReadableStream","Request","Response","Headers"].map(an),Ox=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function qr(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,o;if(typeof e!="object"&&(e=[e]),pr(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{if(Vr(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 dc(e,t){if(Vr(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 Jn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,fc=e=>!mr(e)&&e!==Jn;function bi(){const{caseless:e,skipUndefined:t}=fc(this)&&this||{},n={},r=(o,s)=>{const i=e&&dc(n,s)||s;Lo(n[i])&&Lo(o)?n[i]=bi(n[i],o):Lo(o)?n[i]=bi({},o):pr(o)?n[i]=o.slice():(!t||!mr(o))&&(n[i]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&qr(arguments[o],r);return n}const Dx=(e,t,n,{allOwnKeys:r}={})=>(qr(t,(o,s)=>{n&&Ft(o)?e[s]=ac(o,n):e[s]=o},{allOwnKeys:r}),e),Lx=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),$x=(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)},Fx=(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&&vi(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},Bx=(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},zx=e=>{if(!e)return null;if(pr(e))return e;let t=e.length;if(!uc(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Hx=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&vi(Uint8Array)),Ux=(e,t)=>{const r=(e&&e[Ro]).call(e);let o;for(;(o=r.next())&&!o.done;){const s=o.value;t.call(e,s[0],s[1])}},Wx=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},Vx=an("HTMLFormElement"),Kx=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),hc=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),qx=an("RegExp"),pc=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};qr(n,(o,s)=>{let i;(i=t(o,s,e))!==!1&&(r[s]=i||o)}),Object.defineProperties(e,r)},Gx=e=>{pc(e,(t,n)=>{if(Ft(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(Ft(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+"'")})}})},Yx=(e,t)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return pr(e)?r(e):r(String(e).split(t)),n},Xx=()=>{},Jx=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function Zx(e){return!!(e&&Ft(e.append)&&e[lc]==="FormData"&&e[Ro])}const Qx=e=>{const t=new Array(10),n=(r,o)=>{if(Kr(r)){if(t.indexOf(r)>=0)return;if(Vr(r))return r;if(!("toJSON"in r)){t[o]=r;const s=pr(r)?[]:{};return qr(r,(i,a)=>{const l=n(i,o+1);!mr(l)&&(s[a]=l)}),t[o]=void 0,s}}return r};return n(e,0)},ev=an("AsyncFunction"),tv=e=>e&&(Kr(e)||Ft(e))&&Ft(e.then)&&Ft(e.catch),mc=((e,t)=>e?setImmediate:t?((n,r)=>(Jn.addEventListener("message",({source:o,data:s})=>{o===Jn&&s===n&&r.length&&r.shift()()},!1),o=>{r.push(o),Jn.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",Ft(Jn.postMessage)),nv=typeof queueMicrotask<"u"?queueMicrotask.bind(Jn):typeof process<"u"&&process.nextTick||mc,V={isArray:pr,isArrayBuffer:cc,isBuffer:Vr,isFormData:Ax,isArrayBufferView:wx,isString:yx,isNumber:uc,isBoolean:Sx,isObject:Kr,isPlainObject:Lo,isEmptyObject:Cx,isReadableStream:Px,isRequest:_x,isResponse:Mx,isHeaders:Rx,isUndefined:mr,isDate:Tx,isFile:kx,isBlob:Ex,isRegExp:qx,isFunction:Ft,isStream:Nx,isURLSearchParams:jx,isTypedArray:Hx,isFileList:Ix,forEach:qr,merge:bi,extend:Dx,trim:Ox,stripBOM:Lx,inherits:$x,toFlatObject:Fx,kindOf:Oo,kindOfTest:an,endsWith:Bx,toArray:zx,forEachEntry:Ux,matchAll:Wx,isHTMLForm:Vx,hasOwnProperty:hc,hasOwnProp:hc,reduceDescriptors:pc,freezeMethods:Gx,toObjectSet:Yx,toCamelCase:Kx,noop:Xx,toFiniteNumber:Jx,findKey:dc,global:Jn,isContextDefined:fc,isSpecCompliantForm:Zx,toJSONObject:Qx,isAsyncFn:ev,isThenable:tv,setImmediate:mc,asap:nv,isIterable:e=>e!=null&&Ft(e[Ro])};function Pe(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)}V.inherits(Pe,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:V.toJSONObject(this.config),code:this.code,status:this.status}}});const gc=Pe.prototype,xc={};["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=>{xc[e]={value:e}}),Object.defineProperties(Pe,xc),Object.defineProperty(gc,"isAxiosError",{value:!0}),Pe.from=(e,t,n,r,o,s)=>{const i=Object.create(gc);V.toFlatObject(e,i,function(d){return d!==Error.prototype},c=>c!=="isAxiosError");const a=e&&e.message?e.message:"Error",l=t==null&&e?e.code:t;return Pe.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 rv=null;function wi(e){return V.isPlainObject(e)||V.isArray(e)}function vc(e){return V.endsWith(e,"[]")?e.slice(0,-2):e}function bc(e,t,n){return e?e.concat(t).map(function(o,s){return o=vc(o),!n&&s?"["+o+"]":o}).join(n?".":""):t}function ov(e){return V.isArray(e)&&!e.some(wi)}const sv=V.toFlatObject(V,{},null,function(t){return/^is[A-Z]/.test(t)});function $o(e,t,n){if(!V.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=V.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(g,x){return!V.isUndefined(x[g])});const r=n.metaTokens,o=n.visitor||d,s=n.dots,i=n.indexes,l=(n.Blob||typeof Blob<"u"&&Blob)&&V.isSpecCompliantForm(t);if(!V.isFunction(o))throw new TypeError("visitor must be a function");function c(v){if(v===null)return"";if(V.isDate(v))return v.toISOString();if(V.isBoolean(v))return v.toString();if(!l&&V.isBlob(v))throw new Pe("Blob is not supported. Use a Buffer instead.");return V.isArrayBuffer(v)||V.isTypedArray(v)?l&&typeof Blob=="function"?new Blob([v]):Buffer.from(v):v}function d(v,g,x){let y=v;if(v&&!x&&typeof v=="object"){if(V.endsWith(g,"{}"))g=r?g:g.slice(0,-2),v=JSON.stringify(v);else if(V.isArray(v)&&ov(v)||(V.isFileList(v)||V.endsWith(g,"[]"))&&(y=V.toArray(v)))return g=vc(g),y.forEach(function(S,k){!(V.isUndefined(S)||S===null)&&t.append(i===!0?bc([g],k,s):i===null?g:g+"[]",c(S))}),!1}return wi(v)?!0:(t.append(bc(x,g,s),c(v)),!1)}const h=[],m=Object.assign(sv,{defaultVisitor:d,convertValue:c,isVisitable:wi});function f(v,g){if(!V.isUndefined(v)){if(h.indexOf(v)!==-1)throw Error("Circular reference detected in "+g.join("."));h.push(v),V.forEach(v,function(y,w){(!(V.isUndefined(y)||y===null)&&o.call(t,y,V.isString(w)?w.trim():w,g,m))===!0&&f(y,g?g.concat(w):[w])}),h.pop()}}if(!V.isObject(e))throw new TypeError("data must be an object");return f(e),t}function wc(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function yi(e,t){this._pairs=[],e&&$o(e,this,t)}const yc=yi.prototype;yc.append=function(t,n){this._pairs.push([t,n])},yc.toString=function(t){const n=t?function(r){return t.call(this,r,wc)}:wc;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function iv(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Sc(e,t,n){if(!t)return e;const r=n&&n.encode||iv;V.isFunction(n)&&(n={serialize:n});const o=n&&n.serialize;let s;if(o?s=o(t,n):s=V.isURLSearchParams(t)?t.toString():new yi(t,n).toString(r),s){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}class Cc{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){V.forEach(this.handlers,function(r){r!==null&&t(r)})}}const Tc={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},av={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:yi,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},Si=typeof window<"u"&&typeof document<"u",Ci=typeof navigator=="object"&&navigator||void 0,lv=Si&&(!Ci||["ReactNative","NativeScript","NS"].indexOf(Ci.product)<0),cv=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",uv=Si&&window.location.href||"http://localhost",It={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Si,hasStandardBrowserEnv:lv,hasStandardBrowserWebWorkerEnv:cv,navigator:Ci,origin:uv},Symbol.toStringTag,{value:"Module"})),...av};function dv(e,t){return $o(e,new It.classes.URLSearchParams,{visitor:function(n,r,o,s){return It.isNode&&V.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function fv(e){return V.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function hv(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 kc(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&&V.isArray(o)?o.length:i,l?(V.hasOwnProp(o,i)?o[i]=[o[i],r]:o[i]=r,!a):((!o[i]||!V.isObject(o[i]))&&(o[i]=[]),t(n,r,o[i],s)&&V.isArray(o[i])&&(o[i]=hv(o[i])),!a)}if(V.isFormData(e)&&V.isFunction(e.entries)){const n={};return V.forEachEntry(e,(r,o)=>{t(fv(r),o,n,0)}),n}return null}function pv(e,t,n){if(V.isString(e))try{return(t||JSON.parse)(e),V.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const Gr={transitional:Tc,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",o=r.indexOf("application/json")>-1,s=V.isObject(t);if(s&&V.isHTMLForm(t)&&(t=new FormData(t)),V.isFormData(t))return o?JSON.stringify(kc(t)):t;if(V.isArrayBuffer(t)||V.isBuffer(t)||V.isStream(t)||V.isFile(t)||V.isBlob(t)||V.isReadableStream(t))return t;if(V.isArrayBufferView(t))return t.buffer;if(V.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 dv(t,this.formSerializer).toString();if((a=V.isFileList(t))||r.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return $o(a?{"files[]":t}:t,l&&new l,this.formSerializer)}}return s||o?(n.setContentType("application/json",!1),pv(t)):t}],transformResponse:[function(t){const n=this.transitional||Gr.transitional,r=n&&n.forcedJSONParsing,o=this.responseType==="json";if(V.isResponse(t)||V.isReadableStream(t))return t;if(t&&V.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"?Pe.from(a,Pe.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:It.classes.FormData,Blob:It.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};V.forEach(["delete","get","head","post","put","patch"],e=>{Gr.headers[e]={}});const mv=V.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"]),gv=e=>{const t={};let n,r,o;return e&&e.split(`
|
|
30
|
+
<%s key={someKey} {...props} />`,Jl,hr,rN,hr),Qt[hr+Jl]=!0}}return N===r?et(xt):it(xt),xt}}function pt(N,re,de){return Re(N,re,de,!0)}function Je(N,re,de){return Re(N,re,de,!1)}var ut=Je,In=pt;Wr.Fragment=r,Wr.jsx=ut,Wr.jsxs=In}()),Wr}process.env.NODE_ENV==="production"?xi.exports=gx():xi.exports=xx();var u=xi.exports;const vx=({timelineEntries:e,activeCheckpointId:t,onSelectCheckpoint:n,messagePreviews:r,className:o,onHoverStart:s,onHoverEnd:i})=>{const a=e??[],l=a.length>0,c=b.useMemo(()=>l?[...a].reverse():[],[a,l]),d=t??(a.length?a[a.length-1].id:null);if(!l)return null;const m=["w-32 flex-shrink-0 flex-col border-r border-border/40 pr-2 flex bg-white text-gray-900 dark:bg-slate-900 dark:text-slate-100",o].filter(Boolean).join(" ");return u.jsxs("div",{className:m,onMouseEnter:s,onMouseLeave:i,children:[u.jsxs("div",{className:"relative flex-1 overflow-y-auto pt-4 pb-2 pr-1",children:[u.jsx("div",{className:"absolute left-0 right-0 top-1 px-2 pb-3 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:u.jsx("span",{children:"Timeline"})}),u.jsx("div",{className:"pointer-events-none absolute left-3 top-0 bottom-0 w-px bg-border/40"}),u.jsx("div",{className:"flex flex-col gap-3 pt-6 pr-2",children:c.map(f=>{const v=d===f.id,g=(r==null?void 0:r.get(f.id))??null;return u.jsxs("button",{type:"button",disabled:!n,onClick:()=>n==null?void 0:n(f.id),className:`relative flex items-start gap-2 text-left text-[11px] transition ${v?"text-primary":"text-muted-foreground"} ${n?"hover:text-foreground":"cursor-default opacity-70"}`,children:[u.jsx("span",{className:`mt-1 inline-flex h-3 w-3 items-center justify-center rounded-full border ${v?"border-primary bg-primary/10 text-primary":"border-border bg-background"}`,children:u.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${v?"bg-primary":"bg-border"}`})}),u.jsxs("span",{className:"flex-1",children:[u.jsx("span",{className:"block font-medium leading-tight",children:f.label||"User input"}),u.jsxs("span",{className:"text-[9px] uppercase tracking-wide text-muted-foreground/70",children:[f.step!==null?`STEP ${f.step}`:"STEP —",f.next?` - ${f.next}`:""]}),g&&u.jsx("p",{className:"text-[10px] text-muted-foreground/80 mt-1 line-clamp-2",title:g,children:g})]})]},f.id)})})]}),n&&u.jsx("button",{type:"button",onClick:()=>n==null?void 0:n(null),className:"mt-auto mb-3 rounded-md border border-border/70 px-2 py-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground transition hover:border-foreground/60 hover:text-foreground",children:"Latest"})]})};function ac(e,t){return function(){return e.apply(t,arguments)}}const{toString:bx}=Object.prototype,{getPrototypeOf:vi}=Object,{iterator:Ro,toStringTag:lc}=Symbol,Oo=(e=>t=>{const n=bx.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),an=e=>(e=e.toLowerCase(),t=>Oo(t)===e),Do=e=>t=>typeof t===e,{isArray:pr}=Array,mr=Do("undefined");function Vr(e){return e!==null&&!mr(e)&&e.constructor!==null&&!mr(e.constructor)&&Ft(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const cc=an("ArrayBuffer");function wx(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&cc(e.buffer),t}const yx=Do("string"),Ft=Do("function"),uc=Do("number"),Kr=e=>e!==null&&typeof e=="object",Sx=e=>e===!0||e===!1,Lo=e=>{if(Oo(e)!=="object")return!1;const t=vi(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(lc in e)&&!(Ro in e)},Cx=e=>{if(!Kr(e)||Vr(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},Tx=an("Date"),kx=an("File"),Ex=an("Blob"),Ix=an("FileList"),Nx=e=>Kr(e)&&Ft(e.pipe),Ax=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||Ft(e.append)&&((t=Oo(e))==="formdata"||t==="object"&&Ft(e.toString)&&e.toString()==="[object FormData]"))},jx=an("URLSearchParams"),[Px,_x,Mx,Rx]=["ReadableStream","Request","Response","Headers"].map(an),Ox=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function qr(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,o;if(typeof e!="object"&&(e=[e]),pr(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{if(Vr(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 dc(e,t){if(Vr(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 Jn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,fc=e=>!mr(e)&&e!==Jn;function bi(){const{caseless:e,skipUndefined:t}=fc(this)&&this||{},n={},r=(o,s)=>{const i=e&&dc(n,s)||s;Lo(n[i])&&Lo(o)?n[i]=bi(n[i],o):Lo(o)?n[i]=bi({},o):pr(o)?n[i]=o.slice():(!t||!mr(o))&&(n[i]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&qr(arguments[o],r);return n}const Dx=(e,t,n,{allOwnKeys:r}={})=>(qr(t,(o,s)=>{n&&Ft(o)?e[s]=ac(o,n):e[s]=o},{allOwnKeys:r}),e),Lx=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),$x=(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)},Fx=(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&&vi(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},Bx=(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},zx=e=>{if(!e)return null;if(pr(e))return e;let t=e.length;if(!uc(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Hx=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&vi(Uint8Array)),Ux=(e,t)=>{const r=(e&&e[Ro]).call(e);let o;for(;(o=r.next())&&!o.done;){const s=o.value;t.call(e,s[0],s[1])}},Wx=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},Vx=an("HTMLFormElement"),Kx=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),hc=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),qx=an("RegExp"),pc=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};qr(n,(o,s)=>{let i;(i=t(o,s,e))!==!1&&(r[s]=i||o)}),Object.defineProperties(e,r)},Gx=e=>{pc(e,(t,n)=>{if(Ft(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(Ft(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+"'")})}})},Yx=(e,t)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return pr(e)?r(e):r(String(e).split(t)),n},Xx=()=>{},Jx=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function Zx(e){return!!(e&&Ft(e.append)&&e[lc]==="FormData"&&e[Ro])}const Qx=e=>{const t=new Array(10),n=(r,o)=>{if(Kr(r)){if(t.indexOf(r)>=0)return;if(Vr(r))return r;if(!("toJSON"in r)){t[o]=r;const s=pr(r)?[]:{};return qr(r,(i,a)=>{const l=n(i,o+1);!mr(l)&&(s[a]=l)}),t[o]=void 0,s}}return r};return n(e,0)},ev=an("AsyncFunction"),tv=e=>e&&(Kr(e)||Ft(e))&&Ft(e.then)&&Ft(e.catch),mc=((e,t)=>e?setImmediate:t?((n,r)=>(Jn.addEventListener("message",({source:o,data:s})=>{o===Jn&&s===n&&r.length&&r.shift()()},!1),o=>{r.push(o),Jn.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",Ft(Jn.postMessage)),nv=typeof queueMicrotask<"u"?queueMicrotask.bind(Jn):typeof process<"u"&&process.nextTick||mc,V={isArray:pr,isArrayBuffer:cc,isBuffer:Vr,isFormData:Ax,isArrayBufferView:wx,isString:yx,isNumber:uc,isBoolean:Sx,isObject:Kr,isPlainObject:Lo,isEmptyObject:Cx,isReadableStream:Px,isRequest:_x,isResponse:Mx,isHeaders:Rx,isUndefined:mr,isDate:Tx,isFile:kx,isBlob:Ex,isRegExp:qx,isFunction:Ft,isStream:Nx,isURLSearchParams:jx,isTypedArray:Hx,isFileList:Ix,forEach:qr,merge:bi,extend:Dx,trim:Ox,stripBOM:Lx,inherits:$x,toFlatObject:Fx,kindOf:Oo,kindOfTest:an,endsWith:Bx,toArray:zx,forEachEntry:Ux,matchAll:Wx,isHTMLForm:Vx,hasOwnProperty:hc,hasOwnProp:hc,reduceDescriptors:pc,freezeMethods:Gx,toObjectSet:Yx,toCamelCase:Kx,noop:Xx,toFiniteNumber:Jx,findKey:dc,global:Jn,isContextDefined:fc,isSpecCompliantForm:Zx,toJSONObject:Qx,isAsyncFn:ev,isThenable:tv,setImmediate:mc,asap:nv,isIterable:e=>e!=null&&Ft(e[Ro])};function Pe(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)}V.inherits(Pe,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:V.toJSONObject(this.config),code:this.code,status:this.status}}});const gc=Pe.prototype,xc={};["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=>{xc[e]={value:e}}),Object.defineProperties(Pe,xc),Object.defineProperty(gc,"isAxiosError",{value:!0}),Pe.from=(e,t,n,r,o,s)=>{const i=Object.create(gc);V.toFlatObject(e,i,function(d){return d!==Error.prototype},c=>c!=="isAxiosError");const a=e&&e.message?e.message:"Error",l=t==null&&e?e.code:t;return Pe.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 rv=null;function wi(e){return V.isPlainObject(e)||V.isArray(e)}function vc(e){return V.endsWith(e,"[]")?e.slice(0,-2):e}function bc(e,t,n){return e?e.concat(t).map(function(o,s){return o=vc(o),!n&&s?"["+o+"]":o}).join(n?".":""):t}function ov(e){return V.isArray(e)&&!e.some(wi)}const sv=V.toFlatObject(V,{},null,function(t){return/^is[A-Z]/.test(t)});function $o(e,t,n){if(!V.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=V.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(g,x){return!V.isUndefined(x[g])});const r=n.metaTokens,o=n.visitor||d,s=n.dots,i=n.indexes,l=(n.Blob||typeof Blob<"u"&&Blob)&&V.isSpecCompliantForm(t);if(!V.isFunction(o))throw new TypeError("visitor must be a function");function c(v){if(v===null)return"";if(V.isDate(v))return v.toISOString();if(V.isBoolean(v))return v.toString();if(!l&&V.isBlob(v))throw new Pe("Blob is not supported. Use a Buffer instead.");return V.isArrayBuffer(v)||V.isTypedArray(v)?l&&typeof Blob=="function"?new Blob([v]):Buffer.from(v):v}function d(v,g,x){let y=v;if(v&&!x&&typeof v=="object"){if(V.endsWith(g,"{}"))g=r?g:g.slice(0,-2),v=JSON.stringify(v);else if(V.isArray(v)&&ov(v)||(V.isFileList(v)||V.endsWith(g,"[]"))&&(y=V.toArray(v)))return g=vc(g),y.forEach(function(S,k){!(V.isUndefined(S)||S===null)&&t.append(i===!0?bc([g],k,s):i===null?g:g+"[]",c(S))}),!1}return wi(v)?!0:(t.append(bc(x,g,s),c(v)),!1)}const h=[],m=Object.assign(sv,{defaultVisitor:d,convertValue:c,isVisitable:wi});function f(v,g){if(!V.isUndefined(v)){if(h.indexOf(v)!==-1)throw Error("Circular reference detected in "+g.join("."));h.push(v),V.forEach(v,function(y,w){(!(V.isUndefined(y)||y===null)&&o.call(t,y,V.isString(w)?w.trim():w,g,m))===!0&&f(y,g?g.concat(w):[w])}),h.pop()}}if(!V.isObject(e))throw new TypeError("data must be an object");return f(e),t}function wc(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function yi(e,t){this._pairs=[],e&&$o(e,this,t)}const yc=yi.prototype;yc.append=function(t,n){this._pairs.push([t,n])},yc.toString=function(t){const n=t?function(r){return t.call(this,r,wc)}:wc;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function iv(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Sc(e,t,n){if(!t)return e;const r=n&&n.encode||iv;V.isFunction(n)&&(n={serialize:n});const o=n&&n.serialize;let s;if(o?s=o(t,n):s=V.isURLSearchParams(t)?t.toString():new yi(t,n).toString(r),s){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}class Cc{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){V.forEach(this.handlers,function(r){r!==null&&t(r)})}}const Tc={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},av={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:yi,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},Si=typeof window<"u"&&typeof document<"u",Ci=typeof navigator=="object"&&navigator||void 0,lv=Si&&(!Ci||["ReactNative","NativeScript","NS"].indexOf(Ci.product)<0),cv=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",uv=Si&&window.location.href||"http://localhost",It={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Si,hasStandardBrowserEnv:lv,hasStandardBrowserWebWorkerEnv:cv,navigator:Ci,origin:uv},Symbol.toStringTag,{value:"Module"})),...av};function dv(e,t){return $o(e,new It.classes.URLSearchParams,{visitor:function(n,r,o,s){return It.isNode&&V.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function fv(e){return V.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function hv(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 kc(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&&V.isArray(o)?o.length:i,l?(V.hasOwnProp(o,i)?o[i]=[o[i],r]:o[i]=r,!a):((!o[i]||!V.isObject(o[i]))&&(o[i]=[]),t(n,r,o[i],s)&&V.isArray(o[i])&&(o[i]=hv(o[i])),!a)}if(V.isFormData(e)&&V.isFunction(e.entries)){const n={};return V.forEachEntry(e,(r,o)=>{t(fv(r),o,n,0)}),n}return null}function pv(e,t,n){if(V.isString(e))try{return(t||JSON.parse)(e),V.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const Gr={transitional:Tc,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",o=r.indexOf("application/json")>-1,s=V.isObject(t);if(s&&V.isHTMLForm(t)&&(t=new FormData(t)),V.isFormData(t))return o?JSON.stringify(kc(t)):t;if(V.isArrayBuffer(t)||V.isBuffer(t)||V.isStream(t)||V.isFile(t)||V.isBlob(t)||V.isReadableStream(t))return t;if(V.isArrayBufferView(t))return t.buffer;if(V.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 dv(t,this.formSerializer).toString();if((a=V.isFileList(t))||r.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return $o(a?{"files[]":t}:t,l&&new l,this.formSerializer)}}return s||o?(n.setContentType("application/json",!1),pv(t)):t}],transformResponse:[function(t){const n=this.transitional||Gr.transitional,r=n&&n.forcedJSONParsing,o=this.responseType==="json";if(V.isResponse(t)||V.isReadableStream(t))return t;if(t&&V.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"?Pe.from(a,Pe.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:It.classes.FormData,Blob:It.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};V.forEach(["delete","get","head","post","put","patch"],e=>{Gr.headers[e]={}});const mv=V.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"]),gv=e=>{const t={};let n,r,o;return e&&e.split(`
|
|
31
31
|
`).forEach(function(i){o=i.indexOf(":"),n=i.substring(0,o).trim().toLowerCase(),r=i.substring(o+1).trim(),!(!n||t[n]&&mv[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},Ec=Symbol("internals");function Yr(e){return e&&String(e).trim().toLowerCase()}function Fo(e){return e===!1||e==null?e:V.isArray(e)?e.map(Fo):String(e)}function xv(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 vv=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function Ti(e,t,n,r,o){if(V.isFunction(r))return r.call(this,t,n);if(o&&(t=n),!!V.isString(t)){if(V.isString(r))return t.indexOf(r)!==-1;if(V.isRegExp(r))return r.test(t)}}function bv(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function wv(e,t){const n=V.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 Bt=class{constructor(t){t&&this.set(t)}set(t,n,r){const o=this;function s(a,l,c){const d=Yr(l);if(!d)throw new Error("header name must be a non-empty string");const h=V.findKey(o,d);(!h||o[h]===void 0||c===!0||c===void 0&&o[h]!==!1)&&(o[h||l]=Fo(a))}const i=(a,l)=>V.forEach(a,(c,d)=>s(c,d,l));if(V.isPlainObject(t)||t instanceof this.constructor)i(t,n);else if(V.isString(t)&&(t=t.trim())&&!vv(t))i(gv(t),n);else if(V.isObject(t)&&V.isIterable(t)){let a={},l,c;for(const d of t){if(!V.isArray(d))throw TypeError("Object iterator must return a key-value pair");a[c=d[0]]=(l=a[c])?V.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=Yr(t),t){const r=V.findKey(this,t);if(r){const o=this[r];if(!n)return o;if(n===!0)return xv(o);if(V.isFunction(n))return n.call(this,o,r);if(V.isRegExp(n))return n.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=Yr(t),t){const r=V.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||Ti(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let o=!1;function s(i){if(i=Yr(i),i){const a=V.findKey(r,i);a&&(!n||Ti(r,r[a],a,n))&&(delete r[a],o=!0)}}return V.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||Ti(this,this[s],s,t,!0))&&(delete this[s],o=!0)}return o}normalize(t){const n=this,r={};return V.forEach(this,(o,s)=>{const i=V.findKey(r,s);if(i){n[i]=Fo(o),delete n[s];return}const a=t?bv(s):String(s).trim();a!==s&&delete n[s],n[a]=Fo(o),r[a]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return V.forEach(this,(r,o)=>{r!=null&&r!==!1&&(n[o]=t&&V.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[Ec]=this[Ec]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=Yr(i);r[a]||(wv(o,i),r[a]=!0)}return V.isArray(t)?t.forEach(s):s(t),this}};Bt.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),V.reduceDescriptors(Bt.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),V.freezeMethods(Bt);function ki(e,t){const n=this||Gr,r=t||n,o=Bt.from(r.headers);let s=r.data;return V.forEach(e,function(a){s=a.call(n,s,o.normalize(),t?t.status:void 0)}),o.normalize(),s}function Ic(e){return!!(e&&e.__CANCEL__)}function gr(e,t,n){Pe.call(this,e??"canceled",Pe.ERR_CANCELED,t,n),this.name="CanceledError"}V.inherits(gr,Pe,{__CANCEL__:!0});function Nc(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new Pe("Request failed with status code "+n.status,[Pe.ERR_BAD_REQUEST,Pe.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function yv(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Sv(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 c=Date.now(),d=r[s];i||(i=c),n[o]=l,r[o]=c;let h=s,m=0;for(;h!==o;)m+=n[h++],h=h%e;if(o=(o+1)%e,o===s&&(s=(s+1)%e),c-i<t)return;const f=d&&c-d;return f?Math.round(m*1e3/f):void 0}}function Cv(e,t){let n=0,r=1e3/t,o,s;const i=(c,d=Date.now())=>{n=d,o=null,s&&(clearTimeout(s),s=null),e(...c)};return[(...c)=>{const d=Date.now(),h=d-n;h>=r?i(c,d):(o=c,s||(s=setTimeout(()=>{s=null,i(o)},r-h)))},()=>o&&i(o)]}const Bo=(e,t,n=3)=>{let r=0;const o=Sv(50,250);return Cv(s=>{const i=s.loaded,a=s.lengthComputable?s.total:void 0,l=i-r,c=o(l),d=i<=a;r=i;const h={loaded:i,total:a,progress:a?i/a:void 0,bytes:l,rate:c||void 0,estimated:c&&a&&d?(a-i)/c:void 0,event:s,lengthComputable:a!=null,[t?"download":"upload"]:!0};e(h)},n)},Ac=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},jc=e=>(...t)=>V.asap(()=>e(...t)),Tv=It.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,It.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(It.origin),It.navigator&&/(msie|trident)/i.test(It.navigator.userAgent)):()=>!0,kv=It.hasStandardBrowserEnv?{write(e,t,n,r,o,s){const i=[e+"="+encodeURIComponent(t)];V.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),V.isString(r)&&i.push("path="+r),V.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 Ev(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Iv(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function Pc(e,t,n){let r=!Ev(t);return e&&(r||n==!1)?Iv(e,t):t}const _c=e=>e instanceof Bt?{...e}:e;function Zn(e,t){t=t||{};const n={};function r(c,d,h,m){return V.isPlainObject(c)&&V.isPlainObject(d)?V.merge.call({caseless:m},c,d):V.isPlainObject(d)?V.merge({},d):V.isArray(d)?d.slice():d}function o(c,d,h,m){if(V.isUndefined(d)){if(!V.isUndefined(c))return r(void 0,c,h,m)}else return r(c,d,h,m)}function s(c,d){if(!V.isUndefined(d))return r(void 0,d)}function i(c,d){if(V.isUndefined(d)){if(!V.isUndefined(c))return r(void 0,c)}else return r(void 0,d)}function a(c,d,h){if(h in t)return r(c,d);if(h in e)return r(void 0,c)}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:(c,d,h)=>o(_c(c),_c(d),h,!0)};return V.forEach(Object.keys({...e,...t}),function(d){const h=l[d]||o,m=h(e[d],t[d],d);V.isUndefined(m)&&h!==a||(n[d]=m)}),n}const Mc=e=>{const t=Zn({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=Bt.from(i),t.url=Sc(Pc(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&i.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),V.isFormData(n)){if(It.hasStandardBrowserEnv||It.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(V.isFunction(n.getHeaders)){const l=n.getHeaders(),c=["content-type","content-length"];Object.entries(l).forEach(([d,h])=>{c.includes(d.toLowerCase())&&i.set(d,h)})}}if(It.hasStandardBrowserEnv&&(r&&V.isFunction(r)&&(r=r(t)),r||r!==!1&&Tv(t.url))){const l=o&&s&&kv.read(s);l&&i.set(o,l)}return t},Nv=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=Mc(e);let s=o.data;const i=Bt.from(o.headers).normalize();let{responseType:a,onUploadProgress:l,onDownloadProgress:c}=o,d,h,m,f,v;function g(){f&&f(),v&&v(),o.cancelToken&&o.cancelToken.unsubscribe(d),o.signal&&o.signal.removeEventListener("abort",d)}let x=new XMLHttpRequest;x.open(o.method.toUpperCase(),o.url,!0),x.timeout=o.timeout;function y(){if(!x)return;const S=Bt.from("getAllResponseHeaders"in x&&x.getAllResponseHeaders()),C={data:!a||a==="text"||a==="json"?x.responseText:x.response,status:x.status,statusText:x.statusText,headers:S,config:e,request:x};Nc(function(E){n(E),g()},function(E){r(E),g()},C),x=null}"onloadend"in x?x.onloadend=y:x.onreadystatechange=function(){!x||x.readyState!==4||x.status===0&&!(x.responseURL&&x.responseURL.indexOf("file:")===0)||setTimeout(y)},x.onabort=function(){x&&(r(new Pe("Request aborted",Pe.ECONNABORTED,e,x)),x=null)},x.onerror=function(k){const C=k&&k.message?k.message:"Network Error",T=new Pe(C,Pe.ERR_NETWORK,e,x);T.event=k||null,r(T),x=null},x.ontimeout=function(){let k=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const C=o.transitional||Tc;o.timeoutErrorMessage&&(k=o.timeoutErrorMessage),r(new Pe(k,C.clarifyTimeoutError?Pe.ETIMEDOUT:Pe.ECONNABORTED,e,x)),x=null},s===void 0&&i.setContentType(null),"setRequestHeader"in x&&V.forEach(i.toJSON(),function(k,C){x.setRequestHeader(C,k)}),V.isUndefined(o.withCredentials)||(x.withCredentials=!!o.withCredentials),a&&a!=="json"&&(x.responseType=o.responseType),c&&([m,v]=Bo(c,!0),x.addEventListener("progress",m)),l&&x.upload&&([h,f]=Bo(l),x.upload.addEventListener("progress",h),x.upload.addEventListener("loadend",f)),(o.cancelToken||o.signal)&&(d=S=>{x&&(r(!S||S.type?new gr(null,e,x):S),x.abort(),x=null)},o.cancelToken&&o.cancelToken.subscribe(d),o.signal&&(o.signal.aborted?d():o.signal.addEventListener("abort",d)));const w=yv(o.url);if(w&&It.protocols.indexOf(w)===-1){r(new Pe("Unsupported protocol "+w+":",Pe.ERR_BAD_REQUEST,e));return}x.send(s||null)})},Av=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let r=new AbortController,o;const s=function(c){if(!o){o=!0,a();const d=c instanceof Error?c:this.reason;r.abort(d instanceof Pe?d:new gr(d instanceof Error?d.message:d))}};let i=t&&setTimeout(()=>{i=null,s(new Pe(`timeout ${t} of ms exceeded`,Pe.ETIMEDOUT))},t);const a=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(c=>{c.unsubscribe?c.unsubscribe(s):c.removeEventListener("abort",s)}),e=null)};e.forEach(c=>c.addEventListener("abort",s));const{signal:l}=r;return l.unsubscribe=()=>V.asap(a),l}},jv=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},Pv=async function*(e,t){for await(const n of _v(e))yield*jv(n,t)},_v=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()}},Rc=(e,t,n,r)=>{const o=Pv(e,t);let s=0,i,a=l=>{i||(i=!0,r&&r(l))};return new ReadableStream({async pull(l){try{const{done:c,value:d}=await o.next();if(c){a(),l.close();return}let h=d.byteLength;if(n){let m=s+=h;n(m)}l.enqueue(new Uint8Array(d))}catch(c){throw a(c),c}},cancel(l){return a(l),o.return()}},{highWaterMark:2})},Oc=64*1024,{isFunction:zo}=V,Mv=(({Request:e,Response:t})=>({Request:e,Response:t}))(V.global),{ReadableStream:Dc,TextEncoder:Lc}=V.global,$c=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Rv=e=>{e=V.merge.call({skipUndefined:!0},Mv,e);const{fetch:t,Request:n,Response:r}=e,o=t?zo(t):typeof fetch=="function",s=zo(n),i=zo(r);if(!o)return!1;const a=o&&zo(Dc),l=o&&(typeof Lc=="function"?(v=>g=>v.encode(g))(new Lc):async v=>new Uint8Array(await new n(v).arrayBuffer())),c=s&&a&&$c(()=>{let v=!1;const g=new n(It.origin,{body:new Dc,method:"POST",get duplex(){return v=!0,"half"}}).headers.has("Content-Type");return v&&!g}),d=i&&a&&$c(()=>V.isReadableStream(new r("").body)),h={stream:d&&(v=>v.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(v=>{!h[v]&&(h[v]=(g,x)=>{let y=g&&g[v];if(y)return y.call(g);throw new Pe(`Response type '${v}' is not supported`,Pe.ERR_NOT_SUPPORT,x)})});const m=async v=>{if(v==null)return 0;if(V.isBlob(v))return v.size;if(V.isSpecCompliantForm(v))return(await new n(It.origin,{method:"POST",body:v}).arrayBuffer()).byteLength;if(V.isArrayBufferView(v)||V.isArrayBuffer(v))return v.byteLength;if(V.isURLSearchParams(v)&&(v=v+""),V.isString(v))return(await l(v)).byteLength},f=async(v,g)=>{const x=V.toFiniteNumber(v.getContentLength());return x??m(g)};return async v=>{let{url:g,method:x,data:y,signal:w,cancelToken:S,timeout:k,onDownloadProgress:C,onUploadProgress:T,responseType:E,headers:N,withCredentials:M="same-origin",fetchOptions:O}=Mc(v),F=t||fetch;E=E?(E+"").toLowerCase():"text";let G=Av([w,S&&S.toAbortSignal()],k),K=null;const j=G&&G.unsubscribe&&(()=>{G.unsubscribe()});let Y;try{if(T&&c&&x!=="get"&&x!=="head"&&(Y=await f(N,y))!==0){let J=new n(g,{method:"POST",body:y,duplex:"half"}),_;if(V.isFormData(y)&&(_=J.headers.get("content-type"))&&N.setContentType(_),J.body){const[P,D]=Ac(Y,Bo(jc(T)));y=Rc(J.body,Oc,P,D)}}V.isString(M)||(M=M?"include":"omit");const q=s&&"credentials"in n.prototype,z={...O,signal:G,method:x.toUpperCase(),headers:N.normalize().toJSON(),body:y,duplex:"half",credentials:q?M:void 0};K=s&&new n(g,z);let R=await(s?F(K,O):F(g,z));const I=d&&(E==="stream"||E==="response");if(d&&(C||I&&j)){const J={};["status","statusText","headers"].forEach($=>{J[$]=R[$]});const _=V.toFiniteNumber(R.headers.get("content-length")),[P,D]=C&&Ac(_,Bo(jc(C),!0))||[];R=new r(Rc(R.body,Oc,P,()=>{D&&D(),j&&j()}),J)}E=E||"text";let U=await h[V.findKey(h,E)||"text"](R,v);return!I&&j&&j(),await new Promise((J,_)=>{Nc(J,_,{data:U,headers:Bt.from(R.headers),status:R.status,statusText:R.statusText,config:v,request:K})})}catch(q){throw j&&j(),q&&q.name==="TypeError"&&/Load failed|fetch/i.test(q.message)?Object.assign(new Pe("Network Error",Pe.ERR_NETWORK,v,K),{cause:q.cause||q}):Pe.from(q,q&&q.code,v,K)}}},Ov=new Map,Fc=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,c,d=Ov;for(;a--;)l=s[a],c=d.get(l),c===void 0&&d.set(l,c=a?new Map:Rv(t)),d=c;return c};Fc();const Ei={http:rv,xhr:Nv,fetch:{get:Fc}};V.forEach(Ei,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Bc=e=>`- ${e}`,Dv=e=>V.isFunction(e)||e===null||e===!1,zc={getAdapter:(e,t)=>{e=V.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,!Dv(r)&&(o=Ei[(a=String(r)).toLowerCase()],o===void 0))throw new Pe(`Unknown adapter '${a}'`);if(o&&(V.isFunction(o)||(o=o.get(t))))break;s[a||"#"+i]=o}if(!o){const i=Object.entries(s).map(([l,c])=>`adapter ${l} `+(c===!1?"is not supported by the environment":"is not available in the build"));let a=n?i.length>1?`since :
|
|
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[Ec]=this[Ec]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=Yr(i);r[a]||(wv(o,i),r[a]=!0)}return V.isArray(t)?t.forEach(s):s(t),this}};Bt.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),V.reduceDescriptors(Bt.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),V.freezeMethods(Bt);function ki(e,t){const n=this||Gr,r=t||n,o=Bt.from(r.headers);let s=r.data;return V.forEach(e,function(a){s=a.call(n,s,o.normalize(),t?t.status:void 0)}),o.normalize(),s}function Ic(e){return!!(e&&e.__CANCEL__)}function gr(e,t,n){Pe.call(this,e??"canceled",Pe.ERR_CANCELED,t,n),this.name="CanceledError"}V.inherits(gr,Pe,{__CANCEL__:!0});function Nc(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new Pe("Request failed with status code "+n.status,[Pe.ERR_BAD_REQUEST,Pe.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function yv(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Sv(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 c=Date.now(),d=r[s];i||(i=c),n[o]=l,r[o]=c;let h=s,m=0;for(;h!==o;)m+=n[h++],h=h%e;if(o=(o+1)%e,o===s&&(s=(s+1)%e),c-i<t)return;const f=d&&c-d;return f?Math.round(m*1e3/f):void 0}}function Cv(e,t){let n=0,r=1e3/t,o,s;const i=(c,d=Date.now())=>{n=d,o=null,s&&(clearTimeout(s),s=null),e(...c)};return[(...c)=>{const d=Date.now(),h=d-n;h>=r?i(c,d):(o=c,s||(s=setTimeout(()=>{s=null,i(o)},r-h)))},()=>o&&i(o)]}const Bo=(e,t,n=3)=>{let r=0;const o=Sv(50,250);return Cv(s=>{const i=s.loaded,a=s.lengthComputable?s.total:void 0,l=i-r,c=o(l),d=i<=a;r=i;const h={loaded:i,total:a,progress:a?i/a:void 0,bytes:l,rate:c||void 0,estimated:c&&a&&d?(a-i)/c:void 0,event:s,lengthComputable:a!=null,[t?"download":"upload"]:!0};e(h)},n)},Ac=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},jc=e=>(...t)=>V.asap(()=>e(...t)),Tv=It.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,It.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(It.origin),It.navigator&&/(msie|trident)/i.test(It.navigator.userAgent)):()=>!0,kv=It.hasStandardBrowserEnv?{write(e,t,n,r,o,s){const i=[e+"="+encodeURIComponent(t)];V.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),V.isString(r)&&i.push("path="+r),V.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 Ev(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Iv(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function Pc(e,t,n){let r=!Ev(t);return e&&(r||n==!1)?Iv(e,t):t}const _c=e=>e instanceof Bt?{...e}:e;function Zn(e,t){t=t||{};const n={};function r(c,d,h,m){return V.isPlainObject(c)&&V.isPlainObject(d)?V.merge.call({caseless:m},c,d):V.isPlainObject(d)?V.merge({},d):V.isArray(d)?d.slice():d}function o(c,d,h,m){if(V.isUndefined(d)){if(!V.isUndefined(c))return r(void 0,c,h,m)}else return r(c,d,h,m)}function s(c,d){if(!V.isUndefined(d))return r(void 0,d)}function i(c,d){if(V.isUndefined(d)){if(!V.isUndefined(c))return r(void 0,c)}else return r(void 0,d)}function a(c,d,h){if(h in t)return r(c,d);if(h in e)return r(void 0,c)}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:(c,d,h)=>o(_c(c),_c(d),h,!0)};return V.forEach(Object.keys({...e,...t}),function(d){const h=l[d]||o,m=h(e[d],t[d],d);V.isUndefined(m)&&h!==a||(n[d]=m)}),n}const Mc=e=>{const t=Zn({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=Bt.from(i),t.url=Sc(Pc(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&i.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),V.isFormData(n)){if(It.hasStandardBrowserEnv||It.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(V.isFunction(n.getHeaders)){const l=n.getHeaders(),c=["content-type","content-length"];Object.entries(l).forEach(([d,h])=>{c.includes(d.toLowerCase())&&i.set(d,h)})}}if(It.hasStandardBrowserEnv&&(r&&V.isFunction(r)&&(r=r(t)),r||r!==!1&&Tv(t.url))){const l=o&&s&&kv.read(s);l&&i.set(o,l)}return t},Nv=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=Mc(e);let s=o.data;const i=Bt.from(o.headers).normalize();let{responseType:a,onUploadProgress:l,onDownloadProgress:c}=o,d,h,m,f,v;function g(){f&&f(),v&&v(),o.cancelToken&&o.cancelToken.unsubscribe(d),o.signal&&o.signal.removeEventListener("abort",d)}let x=new XMLHttpRequest;x.open(o.method.toUpperCase(),o.url,!0),x.timeout=o.timeout;function y(){if(!x)return;const S=Bt.from("getAllResponseHeaders"in x&&x.getAllResponseHeaders()),C={data:!a||a==="text"||a==="json"?x.responseText:x.response,status:x.status,statusText:x.statusText,headers:S,config:e,request:x};Nc(function(E){n(E),g()},function(E){r(E),g()},C),x=null}"onloadend"in x?x.onloadend=y:x.onreadystatechange=function(){!x||x.readyState!==4||x.status===0&&!(x.responseURL&&x.responseURL.indexOf("file:")===0)||setTimeout(y)},x.onabort=function(){x&&(r(new Pe("Request aborted",Pe.ECONNABORTED,e,x)),x=null)},x.onerror=function(k){const C=k&&k.message?k.message:"Network Error",T=new Pe(C,Pe.ERR_NETWORK,e,x);T.event=k||null,r(T),x=null},x.ontimeout=function(){let k=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const C=o.transitional||Tc;o.timeoutErrorMessage&&(k=o.timeoutErrorMessage),r(new Pe(k,C.clarifyTimeoutError?Pe.ETIMEDOUT:Pe.ECONNABORTED,e,x)),x=null},s===void 0&&i.setContentType(null),"setRequestHeader"in x&&V.forEach(i.toJSON(),function(k,C){x.setRequestHeader(C,k)}),V.isUndefined(o.withCredentials)||(x.withCredentials=!!o.withCredentials),a&&a!=="json"&&(x.responseType=o.responseType),c&&([m,v]=Bo(c,!0),x.addEventListener("progress",m)),l&&x.upload&&([h,f]=Bo(l),x.upload.addEventListener("progress",h),x.upload.addEventListener("loadend",f)),(o.cancelToken||o.signal)&&(d=S=>{x&&(r(!S||S.type?new gr(null,e,x):S),x.abort(),x=null)},o.cancelToken&&o.cancelToken.subscribe(d),o.signal&&(o.signal.aborted?d():o.signal.addEventListener("abort",d)));const w=yv(o.url);if(w&&It.protocols.indexOf(w)===-1){r(new Pe("Unsupported protocol "+w+":",Pe.ERR_BAD_REQUEST,e));return}x.send(s||null)})},Av=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let r=new AbortController,o;const s=function(c){if(!o){o=!0,a();const d=c instanceof Error?c:this.reason;r.abort(d instanceof Pe?d:new gr(d instanceof Error?d.message:d))}};let i=t&&setTimeout(()=>{i=null,s(new Pe(`timeout ${t} of ms exceeded`,Pe.ETIMEDOUT))},t);const a=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(c=>{c.unsubscribe?c.unsubscribe(s):c.removeEventListener("abort",s)}),e=null)};e.forEach(c=>c.addEventListener("abort",s));const{signal:l}=r;return l.unsubscribe=()=>V.asap(a),l}},jv=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},Pv=async function*(e,t){for await(const n of _v(e))yield*jv(n,t)},_v=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()}},Rc=(e,t,n,r)=>{const o=Pv(e,t);let s=0,i,a=l=>{i||(i=!0,r&&r(l))};return new ReadableStream({async pull(l){try{const{done:c,value:d}=await o.next();if(c){a(),l.close();return}let h=d.byteLength;if(n){let m=s+=h;n(m)}l.enqueue(new Uint8Array(d))}catch(c){throw a(c),c}},cancel(l){return a(l),o.return()}},{highWaterMark:2})},Oc=64*1024,{isFunction:zo}=V,Mv=(({Request:e,Response:t})=>({Request:e,Response:t}))(V.global),{ReadableStream:Dc,TextEncoder:Lc}=V.global,$c=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Rv=e=>{e=V.merge.call({skipUndefined:!0},Mv,e);const{fetch:t,Request:n,Response:r}=e,o=t?zo(t):typeof fetch=="function",s=zo(n),i=zo(r);if(!o)return!1;const a=o&&zo(Dc),l=o&&(typeof Lc=="function"?(v=>g=>v.encode(g))(new Lc):async v=>new Uint8Array(await new n(v).arrayBuffer())),c=s&&a&&$c(()=>{let v=!1;const g=new n(It.origin,{body:new Dc,method:"POST",get duplex(){return v=!0,"half"}}).headers.has("Content-Type");return v&&!g}),d=i&&a&&$c(()=>V.isReadableStream(new r("").body)),h={stream:d&&(v=>v.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(v=>{!h[v]&&(h[v]=(g,x)=>{let y=g&&g[v];if(y)return y.call(g);throw new Pe(`Response type '${v}' is not supported`,Pe.ERR_NOT_SUPPORT,x)})});const m=async v=>{if(v==null)return 0;if(V.isBlob(v))return v.size;if(V.isSpecCompliantForm(v))return(await new n(It.origin,{method:"POST",body:v}).arrayBuffer()).byteLength;if(V.isArrayBufferView(v)||V.isArrayBuffer(v))return v.byteLength;if(V.isURLSearchParams(v)&&(v=v+""),V.isString(v))return(await l(v)).byteLength},f=async(v,g)=>{const x=V.toFiniteNumber(v.getContentLength());return x??m(g)};return async v=>{let{url:g,method:x,data:y,signal:w,cancelToken:S,timeout:k,onDownloadProgress:C,onUploadProgress:T,responseType:E,headers:j,withCredentials:_="same-origin",fetchOptions:D}=Mc(v),F=t||fetch;E=E?(E+"").toLowerCase():"text";let G=Av([w,S&&S.toAbortSignal()],k),K=null;const A=G&&G.unsubscribe&&(()=>{G.unsubscribe()});let Y;try{if(T&&c&&x!=="get"&&x!=="head"&&(Y=await f(j,y))!==0){let J=new n(g,{method:"POST",body:y,duplex:"half"}),P;if(V.isFormData(y)&&(P=J.headers.get("content-type"))&&j.setContentType(P),J.body){const[O,M]=Ac(Y,Bo(jc(T)));y=Rc(J.body,Oc,O,M)}}V.isString(_)||(_=_?"include":"omit");const q=s&&"credentials"in n.prototype,W={...D,signal:G,method:x.toUpperCase(),headers:j.normalize().toJSON(),body:y,duplex:"half",credentials:q?_:void 0};K=s&&new n(g,W);let R=await(s?F(K,D):F(g,W));const I=d&&(E==="stream"||E==="response");if(d&&(C||I&&A)){const J={};["status","statusText","headers"].forEach(L=>{J[L]=R[L]});const P=V.toFiniteNumber(R.headers.get("content-length")),[O,M]=C&&Ac(P,Bo(jc(C),!0))||[];R=new r(Rc(R.body,Oc,O,()=>{M&&M(),A&&A()}),J)}E=E||"text";let z=await h[V.findKey(h,E)||"text"](R,v);return!I&&A&&A(),await new Promise((J,P)=>{Nc(J,P,{data:z,headers:Bt.from(R.headers),status:R.status,statusText:R.statusText,config:v,request:K})})}catch(q){throw A&&A(),q&&q.name==="TypeError"&&/Load failed|fetch/i.test(q.message)?Object.assign(new Pe("Network Error",Pe.ERR_NETWORK,v,K),{cause:q.cause||q}):Pe.from(q,q&&q.code,v,K)}}},Ov=new Map,Fc=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,c,d=Ov;for(;a--;)l=s[a],c=d.get(l),c===void 0&&d.set(l,c=a?new Map:Rv(t)),d=c;return c};Fc();const Ei={http:rv,xhr:Nv,fetch:{get:Fc}};V.forEach(Ei,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Bc=e=>`- ${e}`,Dv=e=>V.isFunction(e)||e===null||e===!1,zc={getAdapter:(e,t)=>{e=V.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,!Dv(r)&&(o=Ei[(a=String(r)).toLowerCase()],o===void 0))throw new Pe(`Unknown adapter '${a}'`);if(o&&(V.isFunction(o)||(o=o.get(t))))break;s[a||"#"+i]=o}if(!o){const i=Object.entries(s).map(([l,c])=>`adapter ${l} `+(c===!1?"is not supported by the environment":"is not available in the build"));let a=n?i.length>1?`since :
|
|
33
33
|
`+i.map(Bc).join(`
|
|
34
34
|
`):" "+Bc(i[0]):"as no adapter specified";throw new Pe("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return o},adapters:Ei};function Ii(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new gr(null,e)}function Hc(e){return Ii(e),e.headers=Bt.from(e.headers),e.data=ki.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),zc.getAdapter(e.adapter||Gr.adapter,e)(e).then(function(r){return Ii(e),r.data=ki.call(e,e.transformResponse,r),r.headers=Bt.from(r.headers),r},function(r){return Ic(r)||(Ii(e),r&&r.response&&(r.response.data=ki.call(e,e.transformResponse,r.response),r.response.headers=Bt.from(r.response.headers))),Promise.reject(r)})}const Uc="1.12.2",Ho={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Ho[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const Wc={};Ho.transitional=function(t,n,r){function o(s,i){return"[Axios v"+Uc+"] Transitional option '"+s+"'"+i+(r?". "+r:"")}return(s,i,a)=>{if(t===!1)throw new Pe(o(i," has been removed"+(n?" in "+n:"")),Pe.ERR_DEPRECATED);return n&&!Wc[i]&&(Wc[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}},Ho.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function Lv(e,t,n){if(typeof e!="object")throw new Pe("options must be an object",Pe.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 Pe("option "+s+" must be "+l,Pe.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new Pe("Unknown option "+s,Pe.ERR_BAD_OPTION)}}const Uo={assertOptions:Lv,validators:Ho},gn=Uo.validators;let Qn=class{constructor(t){this.defaults=t||{},this.interceptors={request:new Cc,response:new Cc}}async request(t,n){try{return await this._request(t,n)}catch(r){if(r instanceof Error){let o={};Error.captureStackTrace?Error.captureStackTrace(o):o=new Error;const s=o.stack?o.stack.replace(/^.+\n/,""):"";try{r.stack?s&&!String(r.stack).endsWith(s.replace(/^.+\n.+\n/,""))&&(r.stack+=`
|
|
35
|
-
`+s):r.stack=s}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=Zn(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:s}=n;r!==void 0&&Uo.assertOptions(r,{silentJSONParsing:gn.transitional(gn.boolean),forcedJSONParsing:gn.transitional(gn.boolean),clarifyTimeoutError:gn.transitional(gn.boolean)},!1),o!=null&&(V.isFunction(o)?n.paramsSerializer={serialize:o}:Uo.assertOptions(o,{encode:gn.function,serialize:gn.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Uo.assertOptions(n,{baseUrl:gn.spelling("baseURL"),withXsrfToken:gn.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=s&&V.merge(s.common,s[n.method]);s&&V.forEach(["delete","get","head","post","put","patch","common"],v=>{delete s[v]}),n.headers=Bt.concat(i,s);const a=[];let l=!0;this.interceptors.request.forEach(function(g){typeof g.runWhen=="function"&&g.runWhen(n)===!1||(l=l&&g.synchronous,a.unshift(g.fulfilled,g.rejected))});const c=[];this.interceptors.response.forEach(function(g){c.push(g.fulfilled,g.rejected)});let d,h=0,m;if(!l){const v=[Hc.bind(this),void 0];for(v.unshift(...a),v.push(...c),m=v.length,d=Promise.resolve(n);h<m;)d=d.then(v[h++],v[h++]);return d}m=a.length;let f=n;for(;h<m;){const v=a[h++],g=a[h++];try{f=v(f)}catch(x){g.call(this,x);break}}try{d=Hc.call(this,f)}catch(v){return Promise.reject(v)}for(h=0,m=c.length;h<m;)d=d.then(c[h++],c[h++]);return d}getUri(t){t=Zn(this.defaults,t);const n=Pc(t.baseURL,t.url,t.allowAbsoluteUrls);return Sc(n,t.params,t.paramsSerializer)}};V.forEach(["delete","get","head","options"],function(t){Qn.prototype[t]=function(n,r){return this.request(Zn(r||{},{method:t,url:n,data:(r||{}).data}))}}),V.forEach(["post","put","patch"],function(t){function n(r){return function(s,i,a){return this.request(Zn(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}Qn.prototype[t]=n(),Qn.prototype[t+"Form"]=n(!0)});let $v=class rx{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 gr(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 rx(function(o){t=o}),cancel:t}}};function Fv(e){return function(n){return e.apply(null,n)}}function Bv(e){return V.isObject(e)&&e.isAxiosError===!0}const Ni={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(Ni).forEach(([e,t])=>{Ni[t]=e});function Vc(e){const t=new Qn(e),n=ac(Qn.prototype.request,t);return V.extend(n,Qn.prototype,t,{allOwnKeys:!0}),V.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return Vc(Zn(e,o))},n}const dt=Vc(Gr);dt.Axios=Qn,dt.CanceledError=gr,dt.CancelToken=$v,dt.isCancel=Ic,dt.VERSION=Uc,dt.toFormData=$o,dt.AxiosError=Pe,dt.Cancel=dt.CanceledError,dt.all=function(t){return Promise.all(t)},dt.spread=Fv,dt.isAxiosError=Bv,dt.mergeConfig=Zn,dt.AxiosHeaders=Bt,dt.formToJSON=e=>kc(V.isHTMLForm(e)?new FormData(e):e),dt.getAdapter=zc.getAdapter,dt.HttpStatusCode=Ni,dt.default=dt;const{Axios:hN,AxiosError:pN,CanceledError:mN,isCancel:gN,CancelToken:xN,VERSION:vN,all:bN,Cancel:wN,isAxiosError:yN,spread:SN,toFormData:CN,AxiosHeaders:TN,HttpStatusCode:kN,formToJSON:EN,getAdapter:IN,mergeConfig:NN}=dt,Kc=typeof window<"u"?window.__API_BASE_URL__:void 0,qc=Kc?xn(Kc):void 0;function xn(e){const n=(e!=null&&e.trim()?e.trim():"/api/chat").replace(/\/+$/,"");return n?n.endsWith("/chat")?n:`${n}/chat`:"/api/chat"}let Wo=null;const Ai=new Set;function Gc(){return Wo}function Vo(e){Wo=e,Ai.forEach(t=>t(e))}function Yc(e){return Ai.add(e),()=>Ai.delete(e)}const Xc=3e4,Jc=9e4,qt=dt.create({...qc?{baseURL:qc}:{},timeout:Xc,withCredentials:!0});qt.interceptors.request.use(e=>(Wo&&(e.headers.Authorization=`Bearer ${Wo}`),e)),qt.interceptors.response.use(e=>{if(typeof window<"u"&&(e!=null&&e.data))try{const t=e.data,n=t.data||{},r=typeof t.token=="string"&&t.token||typeof n.token=="string"&&n.token||null,o=typeof t.expires_at=="number"&&t.expires_at||typeof n.expires_at=="number"&&n.expires_at||typeof t.expiresAt=="number"&&t.expiresAt||typeof n.expiresAt=="number"&&n.expiresAt||null;r&&(localStorage.setItem("authToken",r),Vo(r)),o&&localStorage.setItem("authTokenExpiresAt",o.toString()),(r||o)&&window.dispatchEvent(new CustomEvent("smartorg:chat-token-updated",{detail:{token:r,expiresAt:o}}))}catch(t){console.warn("[chat-api] Error storing token:",t)}return e},e=>Promise.reject(e));async function Gt(e,t){return qt.defaults.baseURL?(await qt.get(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}async function Ko(e,t,n){return qt.defaults.baseURL?(await qt.post(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function Zc(e,t,n){return qt.defaults.baseURL?(await qt.put(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function ji(e,t){return qt.defaults.baseURL?(await qt.delete(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}function Rt(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class qo{get baseUrl(){const t=qt.defaults.baseURL;return t?xn(String(t)):""}updateConfig(t){t.baseUrl&&(qt.defaults.baseURL=xn(String(t.baseUrl))),t.authToken!==void 0&&Vo(t.authToken)}getAuthToken(){return Gc()}setAuthToken(t){Vo(t)}onTokenChange(t){return Yc(t)}async listThreads(){const t=await Gt("/threads"),n=Rt(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async listSharedThreads(){const t=await Gt("/threads/shared"),n=Rt(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async createThread(t){const r=await Ko("/threads",t?{title:t}:void 0);return Rt(r)}async updateThread(t,n){const r=await Zc(`/threads/${t}`,{title:n});return Rt(r)}async deleteThread(t){const n=await ji(`/threads/${t}`);return Rt(n)}async shareThread(t,n){const r=await Ko(`/threads/${t}/share`,{shared_with_user_id:n});return Rt(r)}async threadInfo(t){const n=await Gt(`/threads/${t}/info`);return Rt(n)}async listAgents(){const t=await Gt("/agents"),n=Rt(t);return(n==null?void 0:n.items)??[]}async getAgent(t){const n=await Gt(`/agents/${t}`);return Rt(n)}async getAgentSchema(t){const n=await Gt(`/agents/${t}/schema`);return Rt(n)}async getState(t){const n=await Gt(`/threads/${t.threadId}/state`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return Rt(n)}async getStateHistory(t){const n=await Gt(`/threads/${t.threadId}/state/history`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs},timeout:Jc});return Rt(n)}async cancelRun(t){const n=await Ko("/runs/cancel",{threadId:t});return Rt(n)}async unshareThread(t,n){const r=await ji(`/threads/${t}/share/${n}`);return Rt(r)}}const Nn=new qo,zv=qo,Hv=qo;async function Pi(e,t){return await Gt(e,{responseType:"blob",onDownloadProgress:r=>{try{if(t&&r.lengthComputable){const o=r.loaded/r.total;t(o)}}catch{}},maxBodyLength:1/0})}async function Uv(e,t){const n=await Pi(`/files/${e}/view`,t),r=URL.createObjectURL(n);window.open(r,"_blank"),setTimeout(()=>URL.revokeObjectURL(r),6e4)}async function _i(e,t){return await(await Pi(`/files/${e}/view`,t)).text()}async function Qc(e,t){const n=await Pi(`/files/${e}/download`,t),r=URL.createObjectURL(n);let o=`file_${e}`;try{const i=await Gt(`/files/${e}`);o=(i==null?void 0:i.filename)??o}catch{}const s=document.createElement("a");s.href=r,s.download=o,document.body.appendChild(s),s.click(),s.remove(),setTimeout(()=>URL.revokeObjectURL(r),6e4)}async function Wv(e){return await Gt(`/files/${e}`)}async function eu(e,t=50,n=0){const r={limit:t,offset:n};return e&&(r.thread_id=e),await Gt("/files",{params:r})}const tu=b.createContext(null);function nu({children:e,apiConfig:t}){const n=Nn;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 u.jsx(tu.Provider,{value:r,children:e})}async function ru(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 ou(e=[]){const t=[],n=[];for(const r of e)try{const o=await ru(r);n.push({filename:r.name,data:o,mime_type:r.type||"application/octet-stream"})}catch{}return{contentParts:t,filesInfo:n}}function Xr(){const e=b.useContext(tu);if(!e)throw new Error("useApi must be used within ApiProvider");return e}function su(e){return!!e&&typeof e=="object"&&"data"in e}function Mi(e){return e.filter(t=>{var i;if(t.role!=="assistant")return!0;const n=(t.content??[]).some(a=>{var l;return a&&a.type==="text"&&((l=a.text)==null?void 0:l.trim())}),r=(t.content??[]).some(a=>a&&a.type==="image_url"),o=(i=t.artifact)==null?void 0:i.plots,s=Array.isArray(o)&&o.length>0;return!!(n||r||s)})}function Jr(e,t,n){return t<0||t>=e.length?e:[...e.slice(0,t),n,...e.slice(t+1)]}function Vv(e){let t=!1;const n=e.map(r=>{const o=(r.content??[]).filter(s=>s.type!=="interrupt");return o.length!==r.content.length?(t=!0,{...r,content:o}):r});return t?n:e}function iu(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="assistant")return e[t].id;return null}function au(e){return!e||!e.length?"":e.filter(t=>t.type==="text").map(t=>t.text??"").join("")}function lu(e,t,n,r){const o={...n};if(r!==null&&typeof r=="number"){if(typeof o.lastSeq=="number"&&r<=o.lastSeq)return{newParts:e,newMeta:o,changed:!1};o.lastSeq=r}const s=t.filter(h=>h.type==="text").map(h=>h.text??"").join(""),i=t.filter(h=>h.type!=="text"),a=o.lastText??au(e);let l="",c=e.slice();if(s){const h=Kv(a,s);if(h===""?l="":h===s?l=s:l=h,l){const m=c[c.length-1];if((m==null?void 0:m.type)==="text"){const f=m.text??"",v={...m,text:f+l};c=[...c.slice(0,c.length-1),v]}else c=[...c,{type:"text",text:l}];o.lastText=a+l}else o.lastText=a}i.length&&(c=[...c,...i]);const d=!!(l||i.length);return{newParts:c,newMeta:o,changed:d}}function cu(e){return e.replace(/\s+/g," ").trim()}function Kv(e,t){if(!t)return"";if(!e)return t;if(e===t)return"";const n=Math.min(e.length,t.length);for(let i=n;i>0;i--)if(e.slice(-i)===t.slice(0,i))return t.slice(i);const r=cu(e),o=cu(t);if(r===o)return"";const s=Math.min(r.length,o.length);for(let i=s;i>0;i--)if(r.slice(-i)===o.slice(0,i))return t;return t}function qv(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 Jr(e,r,s)}return e}function uu(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}function Gv(e={}){const t=b.useMemo(()=>xn(e.baseUrl),[e.baseUrl]),n=e.streamPath??"/runs/stream",[r,o]=b.useState(e.token??null),s=b.useRef(e.headers??{}),i=e.credentials??"include",[a,l]=b.useState(!1),[c,d]=b.useState(null),[h,m]=b.useState(""),[f,v]=b.useState(null),[g,x]=b.useState(0),[y,w]=b.useState(!1),[S,k]=b.useState(null),C=b.useRef(null),T=b.useRef(!0),E=b.useRef(0),N=b.useRef(null),M=b.useRef(null),O=b.useRef(null),F=b.useRef(null),G=b.useRef({messageId:null,lastSeq:null,lastText:""}),K=b.useCallback(z=>{o(z)},[]),j=b.useCallback(()=>{m(""),v(null),d(null),M.current=null,O.current=null,F.current=null,k(null),G.current={messageId:null,lastSeq:null,lastText:""}},[]),Y=b.useCallback(()=>{var U;console.debug("[use-chat] stop() invoked - aborting stream");const z=(U=N.current)==null?void 0:U.threadId,R=()=>{var J;(J=C.current)==null||J.abort(),C.current=null,N.current=null,l(!1),w(!1),E.current=0,x(0)};(z?Nn.cancelRun(z).catch(J=>{console.warn("[use-chat] cancel run failed:",J)}):Promise.resolve()).finally(R)},[]),q=b.useCallback((z,R,I)=>{C.current&&(C.current.abort(),C.current=null),l(!0),d(null),e.autoAppendAssistant!==!1&&m(""),v(null),M.current=null,O.current=null,F.current=null,k(null),G.current={messageId:null,lastSeq:null,lastText:""};const U=new AbortController;C.current=U;let J=null,_=null,P=!1;return N.current={threadId:z.threadId??null,headers:{}},(async()=>{var $,ee,H,L,Z,te,Q,W,le,ie,ge,we,Ce,Ae,Ee,st,lt,St;const D=Oe=>{var qe;try{const We=JSON.parse(JSON.stringify(Oe));return(qe=We==null?void 0:We.payload)!=null&&qe.files_info&&Array.isArray(We.payload.files_info)&&(We.payload.files_info=We.payload.files_info.map(je=>({...je,data:je!=null&&je.data?`<base64 ${String(je.data).length} chars>`:je==null?void 0:je.data}))),We}catch{return Oe}};try{let Oe={};try{if(r)Oe={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const ze=window.__AUTH_TOKEN__,Mt=(($=window.localStorage)==null?void 0:$.getItem("authToken"))||null;let X=null;try{const He=(ee=window.localStorage)==null?void 0:ee.getItem("chat-settings");He&&(X=((H=JSON.parse(He))==null?void 0:H.apiKey)||null)}catch{}const fe=ze||Mt||X||null;fe&&(Oe={Authorization:`Bearer ${fe}`})}}catch{}console.debug("[use-chat] POST",t+n,D(z));let qe={};if(typeof window<"u")try{const $e=(L=window.localStorage)==null?void 0:L.getItem("authSessionId");$e&&(qe={"X-Session-Id":$e})}catch{}const We={...Oe,...qe,...s.current},je={"Content-Type":"application/json",Accept:"text/event-stream",...We},_e=await fetch(t+n,{method:"POST",headers:je,body:JSON.stringify(z),signal:U.signal,credentials:i});if(N.current&&(N.current.headers=We),!_e.ok||!_e.body){const $e=await _e.text().catch(()=>"");console.debug("[use-chat] non-OK response",_e.status,$e==null?void 0:$e.slice(0,500));const ze=`stream ${_e.status}${$e?": "+$e:""}`;throw(Z=I==null?void 0:I.onConnectionError)==null||Z.call(I,ze),P=!0,J="error",_=ze,new Error(ze)}w(!0);const ct=_e.body.getReader(),kt=new TextDecoder;let nt="",Et=[];E.current=0,x(0);let bt=0,wt=null;const Ct=()=>{if(Et.length){const $e=Et.join("");Et=[],T.current&&m(ze=>ze+$e)}wt=null},on=()=>{typeof window<"u"&&wt==null&&(wt=requestAnimationFrame(Ct))};let Tt=Date.now();const Lt=setInterval(()=>{var $e;if(Date.now()-Tt>18e5){const ze="Stream idle timeout";d(ze),J="error",_=ze,U.abort(),($e=I==null?void 0:I.onError)==null||$e.call(I,ze)}},5e3),_t=1024*1024;try{const $e=_e.headers.get("X-Thread-Id")||_e.headers.get("x-thread-id"),ze=_e.headers.get("X-Thread-Created")||_e.headers.get("x-thread-created"),Mt=$e??null,X=String(ze??"").toLowerCase()==="true";for(N.current&&!N.current.threadId&&(N.current={...N.current,threadId:Mt}),(te=I==null?void 0:I.onOpen)==null||te.call(I,{threadId:Mt,created:X});;){const{value:fe,done:He}=await ct.read();if(He)break;nt+=kt.decode(fe,{stream:!0}),nt.length>_t&&(nt="",console.warn("Stream buffer reset: exceeded 1MB"));let ae;for(;(ae=nt.indexOf(`
|
|
35
|
+
`+s):r.stack=s}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=Zn(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:s}=n;r!==void 0&&Uo.assertOptions(r,{silentJSONParsing:gn.transitional(gn.boolean),forcedJSONParsing:gn.transitional(gn.boolean),clarifyTimeoutError:gn.transitional(gn.boolean)},!1),o!=null&&(V.isFunction(o)?n.paramsSerializer={serialize:o}:Uo.assertOptions(o,{encode:gn.function,serialize:gn.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Uo.assertOptions(n,{baseUrl:gn.spelling("baseURL"),withXsrfToken:gn.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=s&&V.merge(s.common,s[n.method]);s&&V.forEach(["delete","get","head","post","put","patch","common"],v=>{delete s[v]}),n.headers=Bt.concat(i,s);const a=[];let l=!0;this.interceptors.request.forEach(function(g){typeof g.runWhen=="function"&&g.runWhen(n)===!1||(l=l&&g.synchronous,a.unshift(g.fulfilled,g.rejected))});const c=[];this.interceptors.response.forEach(function(g){c.push(g.fulfilled,g.rejected)});let d,h=0,m;if(!l){const v=[Hc.bind(this),void 0];for(v.unshift(...a),v.push(...c),m=v.length,d=Promise.resolve(n);h<m;)d=d.then(v[h++],v[h++]);return d}m=a.length;let f=n;for(;h<m;){const v=a[h++],g=a[h++];try{f=v(f)}catch(x){g.call(this,x);break}}try{d=Hc.call(this,f)}catch(v){return Promise.reject(v)}for(h=0,m=c.length;h<m;)d=d.then(c[h++],c[h++]);return d}getUri(t){t=Zn(this.defaults,t);const n=Pc(t.baseURL,t.url,t.allowAbsoluteUrls);return Sc(n,t.params,t.paramsSerializer)}};V.forEach(["delete","get","head","options"],function(t){Qn.prototype[t]=function(n,r){return this.request(Zn(r||{},{method:t,url:n,data:(r||{}).data}))}}),V.forEach(["post","put","patch"],function(t){function n(r){return function(s,i,a){return this.request(Zn(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}Qn.prototype[t]=n(),Qn.prototype[t+"Form"]=n(!0)});let $v=class rx{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 gr(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 rx(function(o){t=o}),cancel:t}}};function Fv(e){return function(n){return e.apply(null,n)}}function Bv(e){return V.isObject(e)&&e.isAxiosError===!0}const Ni={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(Ni).forEach(([e,t])=>{Ni[t]=e});function Vc(e){const t=new Qn(e),n=ac(Qn.prototype.request,t);return V.extend(n,Qn.prototype,t,{allOwnKeys:!0}),V.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return Vc(Zn(e,o))},n}const dt=Vc(Gr);dt.Axios=Qn,dt.CanceledError=gr,dt.CancelToken=$v,dt.isCancel=Ic,dt.VERSION=Uc,dt.toFormData=$o,dt.AxiosError=Pe,dt.Cancel=dt.CanceledError,dt.all=function(t){return Promise.all(t)},dt.spread=Fv,dt.isAxiosError=Bv,dt.mergeConfig=Zn,dt.AxiosHeaders=Bt,dt.formToJSON=e=>kc(V.isHTMLForm(e)?new FormData(e):e),dt.getAdapter=zc.getAdapter,dt.HttpStatusCode=Ni,dt.default=dt;const{Axios:hN,AxiosError:pN,CanceledError:mN,isCancel:gN,CancelToken:xN,VERSION:vN,all:bN,Cancel:wN,isAxiosError:yN,spread:SN,toFormData:CN,AxiosHeaders:TN,HttpStatusCode:kN,formToJSON:EN,getAdapter:IN,mergeConfig:NN}=dt,Kc=typeof window<"u"?window.__API_BASE_URL__:void 0,qc=Kc?xn(Kc):void 0;function xn(e){const n=(e!=null&&e.trim()?e.trim():"/api/chat").replace(/\/+$/,"");return n?n.endsWith("/chat")?n:`${n}/chat`:"/api/chat"}let Wo=null;const Ai=new Set;function Gc(){return Wo}function Vo(e){Wo=e,Ai.forEach(t=>t(e))}function Yc(e){return Ai.add(e),()=>Ai.delete(e)}const Xc=3e4,Jc=9e4,qt=dt.create({...qc?{baseURL:qc}:{},timeout:Xc,withCredentials:!0});qt.interceptors.request.use(e=>(Wo&&(e.headers.Authorization=`Bearer ${Wo}`),e)),qt.interceptors.response.use(e=>{if(typeof window<"u"&&(e!=null&&e.data))try{const t=e.data,n=t.data||{},r=typeof t.token=="string"&&t.token||typeof n.token=="string"&&n.token||null,o=typeof t.expires_at=="number"&&t.expires_at||typeof n.expires_at=="number"&&n.expires_at||typeof t.expiresAt=="number"&&t.expiresAt||typeof n.expiresAt=="number"&&n.expiresAt||null;r&&(localStorage.setItem("authToken",r),Vo(r)),o&&localStorage.setItem("authTokenExpiresAt",o.toString()),(r||o)&&window.dispatchEvent(new CustomEvent("smartorg:chat-token-updated",{detail:{token:r,expiresAt:o}}))}catch(t){console.warn("[chat-api] Error storing token:",t)}return e},e=>Promise.reject(e));async function Gt(e,t){return qt.defaults.baseURL?(await qt.get(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}async function Ko(e,t,n){return qt.defaults.baseURL?(await qt.post(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function Zc(e,t,n){return qt.defaults.baseURL?(await qt.put(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function ji(e,t){return qt.defaults.baseURL?(await qt.delete(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}function Rt(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class qo{get baseUrl(){const t=qt.defaults.baseURL;return t?xn(String(t)):""}updateConfig(t){t.baseUrl&&(qt.defaults.baseURL=xn(String(t.baseUrl))),t.authToken!==void 0&&Vo(t.authToken)}getAuthToken(){return Gc()}setAuthToken(t){Vo(t)}onTokenChange(t){return Yc(t)}async listThreads(){const t=await Gt("/threads"),n=Rt(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async listSharedThreads(){const t=await Gt("/threads/shared"),n=Rt(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async createThread(t){const r=await Ko("/threads",t?{title:t}:void 0);return Rt(r)}async updateThread(t,n){const r=await Zc(`/threads/${t}`,{title:n});return Rt(r)}async deleteThread(t){const n=await ji(`/threads/${t}`);return Rt(n)}async shareThread(t,n){const r=await Ko(`/threads/${t}/share`,{shared_with_user_id:n});return Rt(r)}async threadInfo(t){const n=await Gt(`/threads/${t}/info`);return Rt(n)}async listAgents(){const t=await Gt("/agents"),n=Rt(t);return(n==null?void 0:n.items)??[]}async getAgent(t){const n=await Gt(`/agents/${t}`);return Rt(n)}async getAgentSchema(t){const n=await Gt(`/agents/${t}/schema`);return Rt(n)}async getState(t){const n=await Gt(`/threads/${t.threadId}/state`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return Rt(n)}async getStateHistory(t){const n=await Gt(`/threads/${t.threadId}/state/history`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs},timeout:Jc});return Rt(n)}async cancelRun(t){const n=await Ko("/runs/cancel",{threadId:t});return Rt(n)}async unshareThread(t,n){const r=await ji(`/threads/${t}/share/${n}`);return Rt(r)}}const Nn=new qo,zv=qo,Hv=qo;async function Pi(e,t){return await Gt(e,{responseType:"blob",onDownloadProgress:r=>{try{if(t&&r.lengthComputable){const o=r.loaded/r.total;t(o)}}catch{}},maxBodyLength:1/0})}async function Uv(e,t){const n=await Pi(`/files/${e}/view`,t),r=URL.createObjectURL(n);window.open(r,"_blank"),setTimeout(()=>URL.revokeObjectURL(r),6e4)}async function _i(e,t){return await(await Pi(`/files/${e}/view`,t)).text()}async function Qc(e,t){const n=await Pi(`/files/${e}/download`,t),r=URL.createObjectURL(n);let o=`file_${e}`;try{const i=await Gt(`/files/${e}`);o=(i==null?void 0:i.filename)??o}catch{}const s=document.createElement("a");s.href=r,s.download=o,document.body.appendChild(s),s.click(),s.remove(),setTimeout(()=>URL.revokeObjectURL(r),6e4)}async function Wv(e){return await Gt(`/files/${e}`)}async function eu(e,t=50,n=0){const r={limit:t,offset:n};return e&&(r.thread_id=e),await Gt("/files",{params:r})}const tu=b.createContext(null);function nu({children:e,apiConfig:t}){const n=Nn;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 u.jsx(tu.Provider,{value:r,children:e})}async function ru(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 ou(e=[]){const t=[],n=[];for(const r of e)try{const o=await ru(r);n.push({filename:r.name,data:o,mime_type:r.type||"application/octet-stream"})}catch{}return{contentParts:t,filesInfo:n}}function Xr(){const e=b.useContext(tu);if(!e)throw new Error("useApi must be used within ApiProvider");return e}function su(e){return!!e&&typeof e=="object"&&"data"in e}function Mi(e){return e.filter(t=>{var i;if(t.role!=="assistant")return!0;const n=(t.content??[]).some(a=>{var l;return a&&a.type==="text"&&((l=a.text)==null?void 0:l.trim())}),r=(t.content??[]).some(a=>a&&a.type==="image_url"),o=(i=t.artifact)==null?void 0:i.plots,s=Array.isArray(o)&&o.length>0;return!!(n||r||s)})}function Jr(e,t,n){return t<0||t>=e.length?e:[...e.slice(0,t),n,...e.slice(t+1)]}function Vv(e){let t=!1;const n=e.map(r=>{const o=(r.content??[]).filter(s=>s.type!=="interrupt");return o.length!==r.content.length?(t=!0,{...r,content:o}):r});return t?n:e}function iu(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="assistant")return e[t].id;return null}function au(e){return!e||!e.length?"":e.filter(t=>t.type==="text").map(t=>t.text??"").join("")}function lu(e,t,n,r){const o={...n};if(r!==null&&typeof r=="number"){if(typeof o.lastSeq=="number"&&r<=o.lastSeq)return{newParts:e,newMeta:o,changed:!1};o.lastSeq=r}const s=t.filter(h=>h.type==="text").map(h=>h.text??"").join(""),i=t.filter(h=>h.type!=="text"),a=o.lastText??au(e);let l="",c=e.slice();if(s){const h=Kv(a,s);if(h===""?l="":h===s?l=s:l=h,l){const m=c[c.length-1];if((m==null?void 0:m.type)==="text"){const f=m.text??"",v={...m,text:f+l};c=[...c.slice(0,c.length-1),v]}else c=[...c,{type:"text",text:l}];o.lastText=a+l}else o.lastText=a}i.length&&(c=[...c,...i]);const d=!!(l||i.length);return{newParts:c,newMeta:o,changed:d}}function cu(e){return e.replace(/\s+/g," ").trim()}function Kv(e,t){if(!t)return"";if(!e)return t;if(e===t)return"";const n=Math.min(e.length,t.length);for(let i=n;i>0;i--)if(e.slice(-i)===t.slice(0,i))return t.slice(i);const r=cu(e),o=cu(t);if(r===o)return"";const s=Math.min(r.length,o.length);for(let i=s;i>0;i--)if(r.slice(-i)===o.slice(0,i))return t;return t}function qv(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 Jr(e,r,s)}return e}function uu(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}function Gv(e={}){const t=b.useMemo(()=>xn(e.baseUrl),[e.baseUrl]),n=e.streamPath??"/runs/stream",[r,o]=b.useState(e.token??null),s=b.useRef(e.headers??{}),i=e.credentials??"include",[a,l]=b.useState(!1),[c,d]=b.useState(null),[h,m]=b.useState(""),[f,v]=b.useState(null),[g,x]=b.useState(0),[y,w]=b.useState(!1),[S,k]=b.useState(null),C=b.useRef(null),T=b.useRef(!0),E=b.useRef(0),j=b.useRef(null),_=b.useRef(null),D=b.useRef(null),F=b.useRef(null),G=b.useRef({messageId:null,lastSeq:null,lastText:""}),K=b.useCallback(W=>{o(W)},[]),A=b.useCallback(()=>{m(""),v(null),d(null),_.current=null,D.current=null,F.current=null,k(null),G.current={messageId:null,lastSeq:null,lastText:""}},[]),Y=b.useCallback(()=>{var z;console.debug("[use-chat] stop() invoked - aborting stream");const W=(z=j.current)==null?void 0:z.threadId,R=()=>{var J;(J=C.current)==null||J.abort(),C.current=null,j.current=null,l(!1),w(!1),E.current=0,x(0)};(W?Nn.cancelRun(W).catch(J=>{console.warn("[use-chat] cancel run failed:",J)}):Promise.resolve()).finally(R)},[]),q=b.useCallback((W,R,I)=>{C.current&&(C.current.abort(),C.current=null),l(!0),d(null),e.autoAppendAssistant!==!1&&m(""),v(null),_.current=null,D.current=null,F.current=null,k(null),G.current={messageId:null,lastSeq:null,lastText:""};const z=new AbortController;C.current=z;let J=null,P=null,O=!1;return j.current={threadId:W.threadId??null,headers:{}},(async()=>{var L,ee,H,$,Z,te,Q,U,le,ie,ge,we,Ce,Ae,Ee,st,lt,St;const M=Oe=>{var qe;try{const We=JSON.parse(JSON.stringify(Oe));return(qe=We==null?void 0:We.payload)!=null&&qe.files_info&&Array.isArray(We.payload.files_info)&&(We.payload.files_info=We.payload.files_info.map(je=>({...je,data:je!=null&&je.data?`<base64 ${String(je.data).length} chars>`:je==null?void 0:je.data}))),We}catch{return Oe}};try{let Oe={};try{if(r)Oe={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const ze=window.__AUTH_TOKEN__,Mt=((L=window.localStorage)==null?void 0:L.getItem("authToken"))||null;let X=null;try{const He=(ee=window.localStorage)==null?void 0:ee.getItem("chat-settings");He&&(X=((H=JSON.parse(He))==null?void 0:H.apiKey)||null)}catch{}const fe=ze||Mt||X||null;fe&&(Oe={Authorization:`Bearer ${fe}`})}}catch{}console.debug("[use-chat] POST",t+n,M(W));let qe={};if(typeof window<"u")try{const $e=($=window.localStorage)==null?void 0:$.getItem("authSessionId");$e&&(qe={"X-Session-Id":$e})}catch{}const We={...Oe,...qe,...s.current},je={"Content-Type":"application/json",Accept:"text/event-stream",...We},_e=await fetch(t+n,{method:"POST",headers:je,body:JSON.stringify(W),signal:z.signal,credentials:i});if(j.current&&(j.current.headers=We),!_e.ok||!_e.body){const $e=await _e.text().catch(()=>"");console.debug("[use-chat] non-OK response",_e.status,$e==null?void 0:$e.slice(0,500));const ze=`stream ${_e.status}${$e?": "+$e:""}`;throw(Z=I==null?void 0:I.onConnectionError)==null||Z.call(I,ze),O=!0,J="error",P=ze,new Error(ze)}w(!0);const ct=_e.body.getReader(),kt=new TextDecoder;let nt="",Et=[];E.current=0,x(0);let bt=0,wt=null;const Ct=()=>{if(Et.length){const $e=Et.join("");Et=[],T.current&&m(ze=>ze+$e)}wt=null},on=()=>{typeof window<"u"&&wt==null&&(wt=requestAnimationFrame(Ct))};let Tt=Date.now();const Lt=setInterval(()=>{var $e;if(Date.now()-Tt>18e5){const ze="Stream idle timeout";d(ze),J="error",P=ze,z.abort(),($e=I==null?void 0:I.onError)==null||$e.call(I,ze)}},5e3),_t=1024*1024;try{const $e=_e.headers.get("X-Thread-Id")||_e.headers.get("x-thread-id"),ze=_e.headers.get("X-Thread-Created")||_e.headers.get("x-thread-created"),Mt=$e??null,X=String(ze??"").toLowerCase()==="true";for(j.current&&!j.current.threadId&&(j.current={...j.current,threadId:Mt}),(te=I==null?void 0:I.onOpen)==null||te.call(I,{threadId:Mt,created:X});;){const{value:fe,done:He}=await ct.read();if(He)break;nt+=kt.decode(fe,{stream:!0}),nt.length>_t&&(nt="",console.warn("Stream buffer reset: exceeded 1MB"));let ae;for(;(ae=nt.indexOf(`
|
|
36
36
|
|
|
37
37
|
`))>=0;){const me=nt.slice(0,ae);nt=nt.slice(ae+2);const Se=me.split(/\r?\n/),Ve=[];for(const Je of Se)if(!(!Je||Je.startsWith(":"))&&Je.startsWith("data:")){const ut=Je.slice(5);Ve.push(ut.startsWith(" ")?ut.slice(1):ut)}const it=Ve.join(`
|
|
38
|
-
`);if(!it)continue;let et;try{et=JSON.parse(it)}catch{console.debug("[use-chat] malformed SSE:",it.slice(0,200));continue}const Qt=su(et)?et.data:et;if(!Qt){console.warn("[use-chat] dropped envelope event without payload",et);continue}const Re=Qt;Tt=Date.now();const pt=Re.seq;if(pt!==void 0){if(pt<=bt){console.debug("[use-chat] drop duplicate/out-of-order event",{seq:pt,lastProcessedSeq:bt,type:Re.type});continue}bt>0&&pt>bt+1&&((Q=I==null?void 0:I.onGap)==null||Q.call(I,{from:bt,to:pt})),bt=pt,E.current=pt,x(pt)}if(Re.type==="message.start"&&Re.role==="assistant"){const Je=uu(Re.model);G.current={messageId:Re.id,lastSeq:pt??null,lastText:""},k({id:Re.id,role:"assistant",name:Je??void 0,model:Re.model,createdAt:new Date().toISOString(),content:[]})}if(Re.type==="checkpoint")M.current=Re.checkpointId??null,O.current=Re.checkpointNs??null,v(Re.checkpointId??null);else if(Re.type==="state_history"){F.current=Re;try{const ut=Rn(Re).latest;ut&&(M.current=ut.checkpointId??null,O.current=ut.checkpointNs??null,v(ut.checkpointId??null))}catch(Je){console.warn("[use-chat] Failed to hydrate state_history payload",Je)}}try{R==null||R(Re)}catch(Je){console.error("[use-chat] Error in onEvent callback:",Je,"for event:",Re.type)}if(Re.type==="message.delta"){k(ut=>{const In=G.current;if(!ut||In.messageId!==ut.id)return ut;const{newParts:A,newMeta:re,changed:de}=lu(ut.content??[],Re.delta,{lastSeq:In.lastSeq,lastText:In.lastText},pt??null);return de?(G.current={...In,lastSeq:re.lastSeq??In.lastSeq,lastText:re.lastText??In.lastText},{...ut,content:A}):ut});const Je=Re.delta.filter(ut=>ut.type==="text").map(ut=>ut.text).join("");Je&&e.autoAppendAssistant!==!1&&(Et.push(Je),on())}else if(Re.type==="heartbeat"){console.debug("[use-chat] heartbeat received");try{(W=I==null?void 0:I.onHeartbeat)==null||W.call(I,Re)}catch(Je){console.warn("[use-chat] heartbeat callback failed",Je)}}else if(wt!==null&&cancelAnimationFrame(wt),Ct(),Re.type==="checkpoint")v(Re.checkpointId);else if(Re.type==="error"){const Je=Re;if(d(Je.message),J="error",_=Je.message,Je.error_type==="auth_error"||Je.code==="TOKEN_EXPIRED"||((le=Je.message)==null?void 0:le.includes("token"))||((ie=Je.message)==null?void 0:ie.includes("401"))||((ge=Je.message)==null?void 0:ge.includes("unauthorized"))||((we=Je.message)==null?void 0:we.includes("Unauthorized"))){console.error("[use-chat] Auth error detected:",Je.message);try{(Ce=I==null?void 0:I.onAuthError)==null||Ce.call(I,Je.message)}catch(In){console.warn("[use-chat] onAuthError handler failed",In)}U.abort()}}}}Ct(),J===null&&!U.signal.aborted&&(J="complete")}catch($e){if($e.name==="AbortError")J=J??"aborted";else{const ze=$e.message||String($e);J="error",_=ze,d(ze),(Ae=I==null?void 0:I.onError)==null||Ae.call(I,ze)}}finally{try{await ct.cancel()}catch{}finally{(Ee=ct.releaseLock)==null||Ee.call(ct)}wt!==null&&typeof window<"u"&&window.cancelAnimationFrame(wt),clearInterval(Lt)}}catch(Oe){if(Oe.name==="AbortError")J=J??"aborted";else{const qe=Oe.message||String(Oe);J="error",_=qe,d(qe),(st=I==null?void 0:I.onError)==null||st.call(I,qe),P||((lt=I==null?void 0:I.onConnectionError)==null||lt.call(I,qe),P=!0)}}finally{const Oe=E.current,qe=M.current,We=O.current,je=F.current,_e=J??(U.signal.aborted?"aborted":_?"error":"complete");try{(St=I==null?void 0:I.onClosed)==null||St.call(I,{reason:_e,lastSeq:Oe,lastCheckpointId:qe,lastCheckpointNs:We,lastStateHistory:je,error:_})}catch(ct){console.warn("[use-chat] onClosed callback failed",ct)}l(!1),w(!1),C.current=null,E.current=0,x(0),N.current=null}})(),{close:()=>U.abort()}},[t,n,r,e.autoAppendAssistant]);return b.useEffect(()=>()=>{var z;T.current=!1,(z=C.current)==null||z.abort()},[]),{isStreaming:a,error:c,assistantText:h,assistantMessage:S,lastCheckpointId:f,lastSeq:g,connected:y,stream:q,stop:Y,clear:j,setToken:K}}const Yv=["detail","message","error","description","title"];function Go(e){if(!e)return null;if(typeof e=="string"){const t=e.trim();return t.length?t:null}if(Array.isArray(e)){for(const t of e){const n=Go(t);if(n)return n}return null}if(typeof e=="object"){const t=e;for(const n of Yv){const r=Go(t[n]);if(r)return r}if("errors"in t){const n=Go(t.errors);if(n)return n}}return null}function Xv(e){if(!e)return"Request failed";const t=e.response,n=Go(t==null?void 0:t.data);if(n)return n;if(t!=null&&t.statusText)return t.statusText;if(e instanceof Error&&e.message)return e.message;if(typeof e=="string"){const r=e.trim();if(r.length)return r}return t!=null&&t.status?`Request failed with status code ${t.status}`:"Request failed"}function du({api:e,initialThreadId:t=null,onError:n,onThreadChange:r,onCurrentThreadDeleted:o}){const[s,i]=b.useState([]),[a,l]=b.useState(t),[c,d]=b.useState(!1),[h,m]=b.useState(null),[f,v]=b.useState([]),[g,x]=b.useState(!1),[,y]=b.useState(null),[w,S]=b.useState(null),[k,C]=b.useState(!1),T=b.useRef(a),E=b.useRef(new Map);b.useEffect(()=>{T.current=a},[a]);const N=b.useCallback(async()=>{d(!0),m(null);try{const R=await e.listThreads();i(R??[])}catch(R){const I=String(R);m(I),n==null||n(I)}finally{d(!1)}},[e,n]),M=b.useCallback(async()=>{x(!0),y(null);try{const R=await e.listSharedThreads();v(R??[])}catch(R){const I=String(R);y(I),n==null||n(I)}finally{x(!1)}},[e,n]);b.useEffect(()=>{N()},[N]),b.useEffect(()=>{M()},[M]),b.useEffect(()=>{r==null||r(a)},[a,r]);const O=b.useCallback(async R=>{try{const I=await e.createThread(R);return l(I.threadId),await N(),I.threadId}catch(I){const U=String(I);return n==null||n(U),null}},[e,n,N]),F=b.useCallback(async R=>{const I=s;i(J=>J.filter(_=>_.threadId!==R));const U=new AbortController;E.current.set(R,U);try{await e.deleteThread(R),T.current===R&&(l(null),o==null||o())}catch(J){i(I);const _=String(J);n==null||n(_)}finally{E.current.delete(R)}},[e,o,n,s]),G=b.useCallback(async(R,I)=>{try{await e.updateThread(R,I),await N()}catch(U){n==null||n(String(U))}},[e,n,N]),K=b.useCallback(async(R,I)=>{C(!0),S("Sharing thread…");try{await e.shareThread(R,I),await M(),S("Shared successfully")}catch(U){const J=Xv(U);throw n==null||n(J),S(`Failed to share: ${J}`),new Error(J)}finally{C(!1)}},[e,n,M]),j=b.useCallback(async(R,I)=>{try{await e.unshareThread(R,I),await M()}catch(U){const J=String(U);throw n==null||n(J),U}},[e,n,M]),Y=b.useMemo(()=>({createThread:O,deleteThread:F,renameThread:G,refreshThreads:N,refreshSharedThreads:M,shareThread:K,unshareThread:j}),[O,F,G,N,M,K,j]),q=b.useCallback(R=>{if(!(R!=null&&R.threadId))return;const I={threadId:R.threadId,title:R.title||`Thread ${R.threadId.slice(0,8)}`,createdAt:R.createdAt||new Date().toISOString(),updatedAt:R.updatedAt||new Date().toISOString(),messageCount:R.messageCount??1};i(U=>{let J=!1;const _=U.map(P=>P.threadId===I.threadId?(J=!0,console.debug("[useThreadsState] thread_info: updating existing thread",I.threadId),{...P,title:I.title??P.title,updatedAt:I.updatedAt??P.updatedAt,messageCount:I.messageCount??P.messageCount}):P);return J?_:(console.debug("[useThreadsState] thread_info: adding thread to list",I.threadId),[I,...U])})},[]),z=b.useCallback(()=>S(null),[]);return{threads:s,currentThreadId:a,currentThreadIdRef:T,setCurrentThreadId:l,isLoadingThreads:c,threadsError:h,sharedThreads:f,isLoadingSharedThreads:g,actions:Y,addThreadFromEvent:q,shareInFlight:k,shareStatus:w,clearShareStatus:z}}const fu=b.createContext(null);function hu({children:e,initialThreadId:t=null,onError:n,onThreadChange:r}){const{api:o}=Xr(),{threads:s,currentThreadId:i,setCurrentThreadId:a,currentThreadIdRef:l,isLoadingThreads:c,threadsError:d,sharedThreads:h,isLoadingSharedThreads:m,actions:f,addThreadFromEvent:v,shareInFlight:g,shareStatus:x,clearShareStatus:y}=du({api:o,initialThreadId:t,onError:n,onThreadChange:r}),w=b.useMemo(()=>({threads:s,currentThreadId:i,setCurrentThreadId:a,currentThreadIdRef:l,isLoading:c,error:d,sharedThreads:h,isLoadingSharedThreads:m,actions:f,shareInFlight:g,shareStatus:x,clearShareStatus:y,addThreadFromEvent:v}),[s,i,a,l,c,d,h,m,f,g,x,y,v]);return u.jsx(fu.Provider,{value:w,children:e})}function xr(){const e=b.useContext(fu);if(!e)throw new Error("useThreads must be used within a ThreadsProvider");return e}function Ri(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 pu(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;if(e&&typeof e=="object"){if(Array.isArray(e)){const n=e.map(Zr).filter(r=>r!==void 0);if(!n.length){console.debug("[message-utils] sanitizeForDisplay - array emptied -> returning undefined",{originalLength:e.length});return}return n}if(pu(e)){try{console.debug("[message-utils] sanitizeForDisplay - dropping file-like object",{sampleFilename:e&&(e.filename||e.name)?e.filename||e.name:void 0,keys:Object.keys(e||{})})}catch(n){console.debug("[message-utils] sanitizeForDisplay - dropped file-like (unable to inspect)",{err:String(n)})}return}const t={};for(const n of Object.keys(e)){const r=e[n];if(n==="data"&&typeof r=="string"&&r.length>100)t[n]=`[base64 ${r.length} chars omitted]`;else{const o=Zr(r);o!==void 0&&(t[n]=o)}}if(Object.keys(t).length)return t;try{console.debug("[message-utils] sanitizeForDisplay - object emptied -> returning undefined",{originalKeys:Object.keys(e||{})})}catch(n){console.debug("[message-utils] sanitizeForDisplay - object emptied -> returning undefined (inspect failed)",{err:String(n)})}return}return e}function vr(e){if(typeof e=="string")return e;if(pu(e))return"";try{const t=Zr(e);return t===void 0?"":typeof t=="string"?t:JSON.stringify(t,null,2)}catch{return""}}function Jv(e){return typeof e!="string"?!1:/^[\s\n]*[-*]\s|^[\s\n]*#+\s|```|^\s*\[.*\]\(|^>\s/.test(e)}function Zv(e){const t=vr(e);return typeof e=="string"&&Jv(e)?{content:e,isMarkdown:!0}:{content:t,isMarkdown:!1}}function Qr(e){if(e==null)return e;if(typeof e=="string"){const t=e.trim();if(t.startsWith("{")||t.startsWith("[")){const n=Ri(t);if(n!==null)return Qr(n)}return e}return typeof e=="object"&&!Array.isArray(e)&&e.content!==void 0?Qr(e.content):e}function Qv(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function Oi(e){const t=e.content.find(s=>s.type==="tool_call"),n=e.additionalKwargs??{},r=typeof(t==null?void 0:t.id)=="string"&&t.id||typeof n.toolCallId=="string"&&n.toolCallId||(e.id.startsWith("tool-")?e.id.slice(5):void 0);return{name:(typeof(t==null?void 0:t.name)=="string"&&t.name||typeof n.toolName=="string"&&n.toolName||e.name&&String(e.name))??void 0,toolCallId:r??void 0}}function Yo(e){if(e==null)return null;const t=String(e).trim();return t.length>0?t:null}function eb(e){const t=r=>{try{const o=Zr(r);return typeof o=="string"?o:JSON.stringify(o??"")}catch{return""}},n=e.filter(r=>r.type==="text");return n.length?t(n.map(r=>r.text).join(`
|
|
39
|
-
`)):t(e)}function tb(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function mu(e){if(e.role==="default_message")return`default:${e.content.length}`;const t=e.updatedAt??e.createdAt??"",n=Array.isArray(e.content)?e.content.map(i=>{switch(i.type){case"text":return`t:${i.text.length}`;case"image_url":return"img";case"file":return"file";case"tool_call":return"call";case"interrupt":return"interrupt";default:return"unknown"}}).join("|"):"",r="checkpointId"in e&&e.checkpointId?`cp:${e.checkpointId}`:"",o="checkpointNs"in e&&e.checkpointNs?`ns:${e.checkpointNs}`:"",s=[r,o].filter(Boolean).join("|");return`${e.id}:${t}:${n}${s?`:${s}`:""}`}function nb(e){if(!e)return"image/png";const t=e.trim();return t?t.includes("/")?t:`image/${t}`:"image/png"}function rb(e){const t=[],n=r=>{r&&r.trim()&&t.push(r.trim())};return e&&(n(e.plotId),n(e.artifactId)),t}function ob({base64:e,url:t,formatHint:n,extras:r}){const o=typeof e=="string"&&e.length>0,s=nb(n),i=o?`data:${s};base64,${e}`:t,a=rb(r),l=a.length?a.join(" / "):void 0,c=l?`${l} artifact`:"artifact image";return{src:i,alt:c,label:l}}function sb(e){var o,s;const t=((o=e.content_base64)==null?void 0:o.trim())||void 0,n=((s=e.url)==null?void 0:s.trim())||void 0,r=e.format||e.mimeType||e.mime_type;return ob({base64:t,url:n,formatHint:r,extras:{plotId:e.plotId,artifactId:e.artifactId}})}function gu(e){var n;const t=(n=e.additionalKwargs)==null?void 0:n.toolProgress;return Array.isArray(t)?t:[]}const ib={messages:[],assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,messagesStreamMeta:{},pendingInterrupt:null};function ab(e,t){var n;switch(t.type){case"reset":return{messages:Mi(((n=t.payload)==null?void 0:n.messages)??[]),assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,pendingInterrupt:null,messagesStreamMeta:{}};case"user_message":{const{message:r,editingMessageId:o}=t.payload;if(o){const s=e.messages.findIndex(i=>i.id===o);if(s>=0){const i=e.messages.slice(0,s);return{...e,messages:[...i,r]}}}return{...e,messages:[...e.messages,r]}}case"seed":{const r=Mi(t.payload.messages),o={...e,messages:r,assemblingId:null,pendingInterrupt:t.payload.pendingInterrupt??null};return Object.prototype.hasOwnProperty.call(t.payload,"checkpointId")&&(o.lastCheckpointId=t.payload.checkpointId??null),Object.prototype.hasOwnProperty.call(t.payload,"checkpointNs")&&(o.lastCheckpointNs=t.payload.checkpointNs??null),o}case"prepend":{const r=Mi(t.payload.messages);if(!r.length)return e;const o=new Set(e.messages.map(a=>a.id)),s=r.filter(a=>!o.has(a.id));if(!s.length)return e;const i=[...s,...e.messages];return{...e,messages:i}}case"event":return xu(e,t.payload.ev);case"batch":{const{events:r}=t.payload;return r.length?r.reduce((o,s)=>xu(o,s),e):e}default:return e}}function lb(e=[]){const[t,n]=b.useReducer(ab,{...ib,messages:e}),r=b.useRef([]),o=b.useRef(null),s=b.useRef(null),i=b.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=b.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=b.useCallback(d=>{r.current.push(d),a()},[a]);b.useEffect(()=>()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),r.current=[]},[]);const c=b.useMemo(()=>({reset:d=>n({type:"reset",payload:{messages:d}}),seed:(d,h)=>n({type:"seed",payload:{messages:d,...h??{}}}),prepend:d=>n({type:"prepend",payload:{messages:d}}),pushUser:(d,h)=>n({type:"user_message",payload:{message:d,editingMessageId:h}}),onEvent:l}),[l]);return{state:t,dispatch:n,...c}}function xu(e,t){var n,r,o;if(t.type==="message.start"&&t.role==="assistant"){const s=t.id,i=uu(t.model);if(e.messages.some(c=>c.id===s)){const c=e.messagesStreamMeta??{},d={...c,[s]:c[s]??{lastSeq:t.seq??null,lastText:""}};return{...e,assemblingId:s,messagesStreamMeta:d}}const l={id:s,role:"assistant",name:i||void 0,model:t.model,createdAt:new Date().toISOString(),content:[]};return{...e,assemblingId:s,messages:[...e.messages,l]}}if(t.type==="tool.start")return ub(e,t);if(t.type==="tool.progress")return db(e,t);if(t.type==="tool.end")return fb(e,t);if(t.type==="message.delta"){const s=e.assemblingId??iu(e.messages);if(!s)return e;const i=e.messages,a=i.findIndex(C=>C.id===s&&C.role==="assistant");if(a===-1)return e;const l=i[a],c=e.messagesStreamMeta,d=c??{},h=d[s],m=h??{lastSeq:null,lastText:au(l.content)},f=t.seq??null;if(f!==null&&typeof f=="number"&&typeof m.lastSeq=="number"&&f<=m.lastSeq)return console.debug("[MessageReducer] skipping delta - seq <= lastSeq",{seq:f,lastSeq:m.lastSeq}),e;const{newParts:v,newMeta:g,changed:x}=lu(l.content,t.delta,m,f);if(!x)return e;const y={...l,content:v},w=Jr(i,a,y),S=!h||h.lastSeq!==g.lastSeq||h.lastText!==g.lastText,k=S?{...d,[s]:g}:c;return S?{...e,messages:w,messagesStreamMeta:k}:{...e,messages:w}}if(t.type==="message.end"){const s=e.assemblingId??iu(e.messages);if(!s)return{...e,assemblingId:null};const i=e.messages,a=i.findIndex(l=>l.id===s&&l.role==="assistant");if(a>=0){const l=i[a];if(!((n=l.content)==null?void 0:n.some(d=>{var h;return(d==null?void 0:d.type)==="text"&&((h=d.text)==null?void 0:h.trim())}))){console.debug("[MessageReducer] pruning assistant message with no visible text",{id:l.id,contentTypes:(r=l.content)==null?void 0:r.map(h=>h==null?void 0:h.type),contentPreview:(o=l.content)==null?void 0:o.map(h=>(h==null?void 0:h.type)==="text"?String(h.text).slice(0,100):h==null?void 0:h.type)});const d=[...i.slice(0,a),...i.slice(a+1)];return{...e,assemblingId:null,messages:d}}}return e}if(t.type==="checkpoint"){const s=t.checkpointNs??e.lastCheckpointNs??null,i=qv(e.messages,t.checkpointId,s);return{...e,lastCheckpointId:t.checkpointId,lastCheckpointNs:s,messages:i}}if(t.type==="error"){const s={id:`err-${Date.now()}`,role:"system",content:[{type:"text",text:`Error: ${t.message}`}],createdAt:new Date().toISOString()};return{...e,messages:[...e.messages,s]}}if(t.type==="state_history"){const s=Rn(t),i=s.interrupt,a=s.latest,l=i===null?Vv(e.messages):e.messages;return{...e,messages:l,pendingInterrupt:i,lastCheckpointId:(a==null?void 0:a.checkpointId)??e.lastCheckpointId,lastCheckpointNs:(a==null?void 0:a.checkpointNs)??e.lastCheckpointNs}}return t.type==="thread_info",e}function Di(e){return e.call_id??e.id??null}function vu(e){return e.id??e.call_id??`tool-${Date.now()}-${Math.random().toString(16).slice(2)}`}function bu(e,t,n,r){const o=t??`call-${Date.now()}-${Math.random().toString(16).slice(2)}`;return{id:e,role:"tool",name:n??void 0,content:[{type:"tool_call",id:o,name:n??"tool",args:r??{}}],createdAt:new Date().toISOString(),additionalKwargs:{toolCallId:o,toolName:n??void 0,toolStreaming:!0,toolProgress:[]}}}function Li(e,t){if(!t)return-1;for(let n=0;n<e.length;n+=1){const r=e[n];if(r.role!=="tool")continue;const o=r.additionalKwargs??{};if(typeof o.toolCallId=="string"&&o.toolCallId===t||Oi(r).toolCallId===t)return n}return-1}function cb(e){if(e==null)return[];const t=Qr(e);if(typeof t=="string"&&t.trim())return[{type:"text",text:t}];const n=vr(t??e);return n?[{type:"text",text:n}]:[]}function wu(e,t){const n=e.additionalKwargs??{},r=Array.isArray(n.toolProgress)?[...n.toolProgress]:[],o={...n,toolProgress:[...r,t]};return{...e,additionalKwargs:o}}function ub(e,t){const n=Di(t),r=Li(e.messages,n),o=t.name??t.tool??void 0,s=vu(t);if(r>=0){const a=e.messages[r],c={...a.additionalKwargs??{},toolStreaming:!0,toolProgress:[]},d={...a,name:o??a.name,additionalKwargs:c};return{...e,messages:Jr(e.messages,r,d)}}const i=bu(s,n,o,t.args);return{...e,messages:[...e.messages,i]}}function db(e,t){const n=Di(t);if(!n)return e;const r=Li(e.messages,n);if(r===-1)return e;const o={type:t.type,content:typeof t.content=="string"?t.content:void 0,seq:t.seq??null,timestamp:new Date().toISOString()},s=t.metadata;s&&(o.metadata=s);const i=t.idx;typeof i=="number"&&(o.idx=i);const a=wu(e.messages[r],o);return{...e,messages:Jr(e.messages,r,a)}}function fb(e,t){const n=Di(t),r=vu(t);let o=e.messages,s=Li(o,n);if(s===-1){const v=t.name??t.tool??void 0;o=[...o,bu(r,n,v,{})],s=o.length-1}const i=o[s],a=t.output??t.error??null,l=cb(a),c=[...i.content,...l],d={type:t.type,content:typeof t.output=="string"?t.output:void 0,seq:t.seq??null,timestamp:new Date().toISOString()};t.artifact&&(d.artifact=t.artifact);const h=wu(i,d),m=t.artifact??i.artifact,f={...h,name:t.name??t.tool??i.name,content:c,artifact:m,additionalKwargs:{...h.additionalKwargs??{},toolStreaming:!1}};return{...e,messages:Jr(o,s,f)}}function yu({api:e,seed:t,prepend:n,onError:r,currentThreadId:o,initialThreadId:s=null,initialCheckpointId:i=null,initialCheckpointNs:a=null,autoLoadInitial:l=!0,isStreaming:c,getMessages:d}){const[h,m]=b.useState(null),v=b.useMemo(()=>Rn(h),[h]).checkpoints,g=nc(v),x=g.timeline,[y,w]=b.useState(!1),[S,k]=b.useState(null),[C,T]=b.useState(!1),[E,N]=b.useState(!1),[M,O]=b.useState(!1),[F,G]=b.useState(null),K=b.useRef(o),j=b.useRef(null),Y=b.useRef(null),q=b.useRef(null),z=b.useRef(null),R=b.useRef(null),I=b.useRef(new Map);b.useEffect(()=>{K.current=o},[o]);const U=b.useCallback(async Q=>{var le,ie;if(!Q.threadId)return;const W=Q.threadId;(le=Q.onStart)==null||le.call(Q),Q.setLoading(!0);try{await Q.action(W)}catch(ge){if(K.current===W){const we=String(ge);(ie=Q.handleError)==null||ie.call(Q,we),r==null||r(we)}throw ge}finally{Q.setLoading(!1)}},[r]),J=b.useCallback(async(Q,W)=>{if(!Q)return;const le=`${Q}:${W??"latest"}`,ie=I.current.get(le);if(ie)return ie;const ge=U({threadId:Q,setLoading:T,onStart:()=>G(null),handleError:we=>G(we),action:async we=>{const Ce=await e.getStateHistory({threadId:we,checkpointId:W??void 0});if(K.current!==we){console.log(`[useThreadHistoryState] Thread changed during load (was ${we}, now ${K.current}), discarding stale data`);return}const{checkpoints:Ae}=Rn(Ce),Ee=Ae.find(st=>st.messages&&st.messages.length>0)??(W?Ae.find(st=>st.checkpointId===W):null)??Ae[0];t((Ee==null?void 0:Ee.messages)??[],{checkpointId:(Ee==null?void 0:Ee.checkpointId)??null,checkpointNs:(Ee==null?void 0:Ee.checkpointNs)??null}),m(Ce),w(!!(Ee!=null&&Ee.nextCursor)),k((Ee==null?void 0:Ee.nextCursor)??null)}});I.current.set(le,ge);try{await ge}finally{I.current.delete(le)}return K.current===Q&&(R.current=le),ge},[e,t,U]),_=b.useCallback(async(Q,W)=>{z.current=Q;try{await J(Q,W)}finally{z.current===Q&&(z.current=null)}},[J]),P=b.useCallback(Q=>{Y.current=Q},[]),D=b.useCallback(Q=>{q.current=Q},[]),$=b.useCallback(Q=>{const W=Q.threadId??K.current;if(!W||K.current&&K.current!==W)return;const{checkpoints:le}=Rn(Q);if(!le.length)return;const ie=le.find(we=>we.messages&&we.messages.length>0)??le.find(we=>!!we.checkpointId)??le[0],ge=q.current===W;!c&&!ge&&t((ie==null?void 0:ie.messages)??[],{checkpointId:(ie==null?void 0:ie.checkpointId)??null,checkpointNs:(ie==null?void 0:ie.checkpointNs)??null}),m(Q),w(!!(ie!=null&&ie.nextCursor)),k((ie==null?void 0:ie.nextCursor)??null),R.current=`${W}:latest`,Y.current=null,q.current===W&&(q.current=null)},[t,c]),ee=b.useCallback(async(Q,W)=>{const le=K.current;await U({threadId:le,setLoading:O,action:async ie=>{const ge=await e.getStateHistory({threadId:ie,checkpointId:Q,checkpointNs:W??void 0});if(K.current!==ie){console.log(`[useThreadHistoryState] Thread changed during checkpoint navigation (was ${ie}, now ${K.current}), discarding stale data`);return}const{checkpoints:we}=Rn(ge),Ce=we.find(Ae=>Ae.checkpointId===Q&&(W?Ae.checkpointNs===W:!0));if(!Ce){console.warn("[useThreadHistoryState] Requested checkpoint not found:",{checkpointId:Q,checkpointNs:W});return}m(ge),t(Ce.messages??[],{checkpointId:Ce.checkpointId??null,checkpointNs:Ce.checkpointNs??null})}}).catch(()=>{})},[e,t,U]),H=b.useCallback((Q,W)=>{t(d(),{checkpointId:Q??null,checkpointNs:W??null})},[d,t]),L=b.useCallback(async()=>{K.current&&await _(K.current)},[_]),Z=b.useCallback(async()=>{const Q=K.current;!Q||!S||await U({threadId:Q,setLoading:N,action:async W=>{const le=await e.getStateHistory({threadId:W,checkpointId:S});if(K.current!==W)return;const{checkpoints:ie}=Rn(le);if(ie.length>0){const ge=ie[ie.length-1];n((ge==null?void 0:ge.messages)??[]),w(!!(ge!=null&&ge.nextCursor)),k((ge==null?void 0:ge.nextCursor)??null)}}}).catch(()=>{})},[e,S,r,n,U]);b.useEffect(()=>{if(!l||!o||C||c)return;if(Y.current===o){Y.current=null,j.current=o;return}if(q.current===o){j.current=o;return}if(z.current===o){z.current=null,j.current=o;return}if(j.current===o)return;j.current=o;let Q;console.log("[useThreadHistoryState] Loading thread with latest checkpoint");const W=`${o}:latest`;R.current!==W&&_(o,Q)},[l,o,i,a,s,C,c,_]);const te=b.useCallback(()=>{m(null),w(!1),k(null),T(!1),N(!1),O(!1),G(null),Y.current=null,q.current=null,j.current=null,R.current=null,z.current=null},[]);return{threadCheckpoints:v,threadTimeline:x,checkpointIndex:g,isLoadingThread:C,isHistoryLoading:E,isLoadingCheckpoint:M,threadStateError:F,hasMoreHistory:y,loadThread:_,navigateToCheckpoint:ee,loadOlderMessages:Z,setCurrentCheckpointId:H,returnToLatest:L,handleStateHistoryEvent:$,markSkipNextLoad:P,markStreamPendingThread:D,resetHistoryState:te}}const Su=b.createContext(null),Cu=b.createContext(null);function eo(){const e=b.useContext(Su);if(!e)throw new Error("useThreadState must be used within a ThreadStateProvider");return e}function Tu(){const e=b.useContext(Cu);if(!e)throw new Error("useThreadStateUpdater must be used within a ThreadStateProvider");return e}function ku({children:e,initialThreadId:t=null,initialCheckpointId:n=null,initialCheckpointNs:r=null,autoLoadInitial:o=!0,isStreaming:s,onError:i}){const{api:a}=Xr(),{currentThreadId:l}=xr(),{state:c,seed:d,prepend:h,pushUser:m,onEvent:f}=lb(),{threadCheckpoints:v,threadTimeline:g,checkpointIndex:x,isLoadingThread:y,isHistoryLoading:w,isLoadingCheckpoint:S,threadStateError:k,hasMoreHistory:C,loadThread:T,navigateToCheckpoint:E,loadOlderMessages:N,setCurrentCheckpointId:M,returnToLatest:O,handleStateHistoryEvent:F,markSkipNextLoad:G,markStreamPendingThread:K,resetHistoryState:j}=yu({api:a,seed:d,prepend:h,onError:i,currentThreadId:l,initialThreadId:t,initialCheckpointId:n,initialCheckpointNs:r,autoLoadInitial:o,isStreaming:s,getMessages:b.useCallback(()=>c.messages,[c.messages])}),[Y,q]=b.useState(()=>async()=>{throw new Error("clearThread is not ready")}),[z,R]=b.useState(()=>async()=>{throw new Error("respondToInterrupt is not ready")});b.useEffect(()=>{l||(d([],{}),j())},[l,d,j]);const I=b.useCallback(D=>q(()=>D),[]),U=b.useCallback(D=>R(()=>D),[]),J=b.useMemo(()=>({assemblingMessageId:c.assemblingId??null}),[c.assemblingId]),_=b.useMemo(()=>({threadId:l,messages:c.messages,interrupt:c.pendingInterrupt,checkpoint:{id:c.lastCheckpointId??null,namespace:c.lastCheckpointNs??null},checkpoints:v,checkpointIndex:x,timelineCheckpoints:g,metadata:J,isLoading:y,isHistoryLoading:w,isLoadingCheckpoint:S,error:k,hasMore:C,loadOlder:N,clearState:Y,navigateToCheckpoint:E,setCurrentCheckpointId:M,returnToLatest:O,loadThread:T,clearThread:Y,respondToInterrupt:z,messagePreviews:x.messagePreviews,handleStateHistoryEvent:F,markSkipNextLoad:G,markStreamPendingThread:K,resetHistoryState:j,pushUser:m,onEvent:f}),[l,c,v,g,x,J,y,w,S,k,C,N,Y,E,M,O,T,z,x.messagePreviews,F,G,K,j,m,f]),P=b.useMemo(()=>({registerClearThread:I,registerRespondToInterrupt:U}),[I,U]);return u.jsx(Cu.Provider,{value:P,children:u.jsx(Su.Provider,{value:_,children:e})})}function Eu(e,t){if(!e)return null;const n=_n(e);if(!n)return null;const r=_n(n.configurable)??n;return Mn(r,t)??null}function hb(e){const t=Eu(e,["checkpoint_id","checkpointId"]);if(!t)return null;const n=Eu(e,["checkpoint_ns","checkpointNs"]);return{checkpointId:t,checkpointNs:n}}function pb(e,t){const n=typeof e.step=="number"?e.step:Number.POSITIVE_INFINITY,r=typeof t.step=="number"?t.step:Number.POSITIVE_INFINITY;if(n!==r)return n-r;const o=e.createdAt?Date.parse(e.createdAt):0,s=t.createdAt?Date.parse(t.createdAt):0;return o-s}function mb(e,t){const n=[...e].sort(pb);for(const r of n){if(r.messageId!==t)continue;const o=hb(r.parentConfig);if(!o)throw new Error(`Parent checkpoint info missing for message ${t}`);return o}throw new Error(`Message ${t} not found in timeline`)}const Iu=b.createContext(null),Nu=b.createContext(!1);function gb({children:e,initialThreadId:t=null,initialCheckpointId:n=null,initialCheckpointNs:r=null,autoLoadInitial:o=!0,onError:s,onAuthError:i,onThreadChange:a,onConnectionError:l,onToolEnd:c}){const{api:d,baseUrl:h}=Xr(),m=b.useMemo(()=>xn(h),[h]),{stream:f,stop:v,isStreaming:g,error:x,setToken:y}=Gv({baseUrl:m}),[w,S]=b.useState(!1);return b.useEffect(()=>{S(g)},[g]),u.jsx(hu,{initialThreadId:t,onError:s,onThreadChange:a,children:u.jsx(ku,{initialThreadId:t,initialCheckpointId:n,initialCheckpointNs:r,autoLoadInitial:o,onError:s,isStreaming:w,children:u.jsx(Nu.Provider,{value:!0,children:u.jsx(xb,{api:d,streamApi:{stream:f,stop:v,isStreaming:g,error:x,setToken:y},onError:s,onAuthError:i,onConnectionError:l,onToolEnd:c,children:e})})})})}function xb({children:e,api:t,streamApi:n,onError:r,onAuthError:o,onConnectionError:s,onToolEnd:i}){const{stream:a,stop:l,isStreaming:c,error:d,setToken:h}=n,{setCurrentThreadId:m,currentThreadIdRef:f,addThreadFromEvent:v}=xr(),{checkpoint:g,timelineCheckpoints:x,handleStateHistoryEvent:y,markSkipNextLoad:w,markStreamPendingThread:S,resetHistoryState:k,pushUser:C,onEvent:T}=eo(),{registerClearThread:E,registerRespondToInterrupt:N}=Tu(),M=b.useCallback(z=>{v(z),f.current!==z.threadId&&((z.created??!f.current)&&w(z.threadId),S(z.threadId),m(z.threadId))},[v,w,S,m,f]),O=b.useCallback(z=>{z.type==="thread_info"?M(z):z.type==="state_history"?y(z):z.type==="tool.end"?i==null||i(z):T(z)},[M,y,T,i]),F=b.useCallback(z=>{a(z,O,{onError:R=>{console.error("[StreamingProvider] Stream error:",R),r==null||r(R)},onAuthError:R=>{console.error("[StreamingProvider] Auth error:",R),o==null||o(R)},onConnectionError:R=>{console.error("[StreamingProvider] Connection error:",R),s==null||s(R)}})},[a,O,r,o,s]),G=b.useRef(g);b.useEffect(()=>{G.current=g},[g]);const K=b.useCallback(async(z,R,I)=>{const U=f.current;if(!U)throw new Error("No active thread to handle interrupt");const J=R?I??!0:!1,_=G.current,P={threadId:U,checkpointId:_.id??void 0,checkpointNs:_.namespace??void 0,command:{kind:"resume",value:J}};F(P)},[f,F]);b.useEffect(()=>{N(K)},[K,N]);const j=b.useCallback(async()=>{l(),k(),m(null);try{await t.getAgent("default")}catch(z){console.warn("[StreamingProvider] Failed to refetch agent after clearing thread:",z)}},[t,k,m,l]);b.useEffect(()=>{E(j)},[j,E]);const Y=b.useCallback(async(z,R)=>{let I=f.current;const U=(z==null?void 0:z.text)??"",J=(z==null?void 0:z.attachments)??[],_=(U==null?void 0:U.trim())??"",P={...(z==null?void 0:z.payload)??{}},D=Array.isArray(P.messages)?P.messages:void 0;D&&delete P.messages;const $=!!(D&&D.length);if(!I&&!_&&J.length===0&&!$)return;if(!I){const Ae=Math.floor(Date.now()/1e3).toString(16).padStart(8,"0"),Ee=Array.from({length:4},()=>Math.floor(Math.random()*4294967295).toString(16).padStart(8,"0")).join("").slice(0,16);I=`${Ae}${Ee}`,w(I),m(I)}const{contentParts:ee,filesInfo:H}=await ou(J),L=[...ee];_&&L.push({type:"text",text:U});const Z=R==null?void 0:R.originalMessageId,te=!!(R!=null&&R.edit&&Z),Q=!$&&L.length>0;let W=null;Q&&(W={id:te?Z:`msg-${Date.now()}`,role:"user",content:L,createdAt:new Date().toISOString()},te?C(W,Z):C(W));const le=$?D:W?[W]:[],ie={...P,...H.length?{files_info:H}:{}};le.length?ie.messages=le:"messages"in ie||(ie.messages=[]);let ge=(R==null?void 0:R.checkpointId)??g.id??void 0,we=(R==null?void 0:R.checkpointNs)??g.namespace??void 0;if(te&&Z){const Ae=mb(x,Z);ge=Ae.checkpointId,we=Ae.checkpointNs??void 0}const Ce={threadId:I,payload:ie,checkpointId:ge,checkpointNs:we,edit:!!(R!=null&&R.edit)};F(Ce)},[g,f,w,C,F,x]),q=b.useMemo(()=>({isStreaming:c,error:d,connectionState:c?"connected":"idle",submit:Y,send:Y,stop:l,setAuthToken:h}),[c,d,Y,l,h]);return u.jsx(Iu.Provider,{value:q,children:e})}function $i(){const e=b.useContext(Iu);if(!e)throw new Error("useStream must be used within StreamingProvider");return e}function vb(){return b.useContext(Nu)}function Au(e){return typeof e=="object"&&e!==null}function bb(e,t){if(Object.is(e,t))return!0;if(!Au(e)||!Au(t))return!1;const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const o of n)if(!Object.prototype.hasOwnProperty.call(t,o)||!Object.is(e[o],t[o]))return!1;return!0}function ju(e){const t=b.useRef(e),n=b.useRef(e);return bb(t.current,e)||(t.current=e,n.current=e),n.current}function br({children:e,apiConfig:t,initialThreadId:n=null,initialCheckpointId:r=null,initialCheckpointNs:o=null,autoLoadInitial:s=!0,onConnectionError:i,onError:a,onAuthError:l,onThreadChange:c,onToolEnd:d}){const h=ju(t),m=to(a),f=to(l),v=to(i),g=to(c),x=to(d),y=b.useMemo(()=>({initialThreadId:n,initialCheckpointId:r,initialCheckpointNs:o,autoLoadInitial:s,onError:m,onAuthError:f,onConnectionError:v,onThreadChange:g,onToolEnd:x}),[n,r,o,s,m,f,v,g,x]);return u.jsx(nu,{apiConfig:h,children:u.jsx(gb,{...y,children:e})})}function to(e){const t=b.useRef(e);return b.useEffect(()=>{t.current=e},[e]),b.useCallback((...n)=>{const r=t.current;if(r)return r(...n)},[])}function wr(e){if(!(typeof globalThis>"u"))return globalThis[e]}function wb(e){if(typeof e!="string")return;const t=e.trim();if(t)return xn(t)}function Pu(){const e=[wr("__API_BASE_URL__"),wr("__CHAT_API_BASE_URL__"),wr("__CHAT_API_URL__")];for(const t of e){const n=wb(t);if(n)return n}}function _u(){const e=[wr("__API_AUTH_TOKEN__"),wr("__CHAT_API_KEY__"),wr("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function Mu(...e){for(const t of e)if(typeof t=="string"&&t.trim())return xn(t);return xn()}function Ru(){const e={},t=Pu(),n=_u();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function Ou(){const e=Ru(),t=Nn.getAuthToken(),n=Pu();return{apiBaseUrl:Mu(e.baseUrl,Nn.baseUrl,n),apiKey:t||e.apiKey||_u()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,darkMode:!1,enableSound:!1,messageHistory:100}}const Fi="chat-settings";function Du(){try{const e=localStorage.getItem(Fi);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function Lu(e){try{const t={...e,apiBaseUrl:xn(e.apiBaseUrl)};localStorage.setItem(Fi,JSON.stringify(t)),t.apiKey&&Nn.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function yb(){const e=Ou(),t=Du(),n=Nn.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:Mu(Nn.baseUrl,r,e.apiBaseUrl)}}function Sb(e){Nn.updateConfig({baseUrl:e.apiBaseUrl,authToken:e.apiKey??void 0}),Lu(e)}function oe(...e){return sx.twMerge(ox.clsx(e))}const Cb=zr.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"}}),Xe=p.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?Kt.Slot:"button";return u.jsx(i,{className:oe(Cb({variant:t,size:n,className:e})),ref:s,...o})});Xe.displayName="Button";function ce(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 $u(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function On(...e){return t=>{let n=!1;const r=e.map(o=>{const s=$u(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():$u(e[o],null)}}}}function De(...e){return p.useCallback(On(...e),e)}function Tb(e,t){const n=p.createContext(t),r=s=>{const{children:i,...a}=s,l=p.useMemo(()=>a,Object.values(a));return u.jsx(n.Provider,{value:l,children:i})};r.displayName=e+"Provider";function o(s){const i=p.useContext(n);if(i)return i;if(t!==void 0)return t;throw new Error(`\`${s}\` must be used within \`${e}\``)}return[r,o]}function ln(e,t=[]){let n=[];function r(s,i){const a=p.createContext(i),l=n.length;n=[...n,i];const c=h=>{var y;const{scope:m,children:f,...v}=h,g=((y=m==null?void 0:m[e])==null?void 0:y[l])||a,x=p.useMemo(()=>v,Object.values(v));return u.jsx(g.Provider,{value:x,children:f})};c.displayName=s+"Provider";function d(h,m){var g;const f=((g=m==null?void 0:m[e])==null?void 0:g[l])||a,v=p.useContext(f);if(v)return v;if(i!==void 0)return i;throw new Error(`\`${h}\` must be used within \`${s}\``)}return[c,d]}const o=()=>{const s=n.map(i=>p.createContext(i));return function(a){const l=(a==null?void 0:a[e])||s;return p.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return o.scopeName=e,[r,kb(o,...t)]}function kb(...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:c})=>{const h=l(s)[`__scope${c}`];return{...a,...h}},{});return p.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var yt=globalThis!=null&&globalThis.document?p.useLayoutEffect:()=>{},Eb=p[" useInsertionEffect ".trim().toString()]||yt;function Dn({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=Ib({defaultProp:t,onChange:n}),a=e!==void 0,l=a?e:o;{const d=p.useRef(e!==void 0);p.useEffect(()=>{const h=d.current;h!==a&&console.warn(`${r} is changing from ${h?"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 c=p.useCallback(d=>{var h;if(a){const m=Nb(d)?d(e):d;m!==e&&((h=i.current)==null||h.call(i,m))}else s(d)},[a,e,s,i]);return[l,c]}function Ib({defaultProp:e,onChange:t}){const[n,r]=p.useState(e),o=p.useRef(n),s=p.useRef(t);return Eb(()=>{s.current=t},[t]),p.useEffect(()=>{var i;o.current!==n&&((i=s.current)==null||i.call(s,n),o.current=n)},[n,o]),[n,r,s]}function Nb(e){return typeof e=="function"}var Ab=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],xe=Ab.reduce((e,t)=>{const n=Kt.createSlot(`Primitive.${t}`),r=p.forwardRef((o,s)=>{const{asChild:i,...a}=o,l=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),u.jsx(l,{...a,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Bi(e,t){e&&Hr.flushSync(()=>e.dispatchEvent(t))}function Xo(e){const t=e+"CollectionProvider",[n,r]=ln(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=g=>{const{scope:x,children:y}=g,w=b.useRef(null),S=b.useRef(new Map).current;return u.jsx(o,{scope:x,itemMap:S,collectionRef:w,children:y})};i.displayName=t;const a=e+"CollectionSlot",l=Kt.createSlot(a),c=b.forwardRef((g,x)=>{const{scope:y,children:w}=g,S=s(a,y),k=De(x,S.collectionRef);return u.jsx(l,{ref:k,children:w})});c.displayName=a;const d=e+"CollectionItemSlot",h="data-radix-collection-item",m=Kt.createSlot(d),f=b.forwardRef((g,x)=>{const{scope:y,children:w,...S}=g,k=b.useRef(null),C=De(x,k),T=s(d,y);return b.useEffect(()=>(T.itemMap.set(k,{ref:k,...S}),()=>void T.itemMap.delete(k))),u.jsx(m,{[h]:"",ref:C,children:w})});f.displayName=d;function v(g){const x=s(e+"CollectionConsumer",g);return b.useCallback(()=>{const w=x.collectionRef.current;if(!w)return[];const S=Array.from(w.querySelectorAll(`[${h}]`));return Array.from(x.itemMap.values()).sort((T,E)=>S.indexOf(T.ref.current)-S.indexOf(E.ref.current))},[x.collectionRef,x.itemMap])}return[{Provider:i,Slot:c,ItemSlot:f},v,r]}var jb=p.createContext(void 0);function Jo(e){const t=p.useContext(jb);return e||t||"ltr"}function ft(e){const t=p.useRef(e);return p.useEffect(()=>{t.current=e}),p.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function Pb(e,t=globalThis==null?void 0:globalThis.document){const n=ft(e);p.useEffect(()=>{const r=o=>{o.key==="Escape"&&n(o)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var _b="DismissableLayer",zi="dismissableLayer.update",Mb="dismissableLayer.pointerDownOutside",Rb="dismissableLayer.focusOutside",Fu,Bu=p.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),yr=p.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...l}=e,c=p.useContext(Bu),[d,h]=p.useState(null),m=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,f]=p.useState({}),v=De(t,E=>h(E)),g=Array.from(c.layers),[x]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),y=g.indexOf(x),w=d?g.indexOf(d):-1,S=c.layersWithOutsidePointerEventsDisabled.size>0,k=w>=y,C=Db(E=>{const N=E.target,M=[...c.branches].some(O=>O.contains(N));!k||M||(o==null||o(E),i==null||i(E),E.defaultPrevented||a==null||a())},m),T=Lb(E=>{const N=E.target;[...c.branches].some(O=>O.contains(N))||(s==null||s(E),i==null||i(E),E.defaultPrevented||a==null||a())},m);return Pb(E=>{w===c.layers.size-1&&(r==null||r(E),!E.defaultPrevented&&a&&(E.preventDefault(),a()))},m),p.useEffect(()=>{if(d)return n&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(Fu=m.body.style.pointerEvents,m.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(d)),c.layers.add(d),Hu(),()=>{n&&c.layersWithOutsidePointerEventsDisabled.size===1&&(m.body.style.pointerEvents=Fu)}},[d,m,n,c]),p.useEffect(()=>()=>{d&&(c.layers.delete(d),c.layersWithOutsidePointerEventsDisabled.delete(d),Hu())},[d,c]),p.useEffect(()=>{const E=()=>f({});return document.addEventListener(zi,E),()=>document.removeEventListener(zi,E)},[]),u.jsx(xe.div,{...l,ref:v,style:{pointerEvents:S?k?"auto":"none":void 0,...e.style},onFocusCapture:ce(e.onFocusCapture,T.onFocusCapture),onBlurCapture:ce(e.onBlurCapture,T.onBlurCapture),onPointerDownCapture:ce(e.onPointerDownCapture,C.onPointerDownCapture)})});yr.displayName=_b;var Ob="DismissableLayerBranch",zu=p.forwardRef((e,t)=>{const n=p.useContext(Bu),r=p.useRef(null),o=De(t,r);return p.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),u.jsx(xe.div,{...e,ref:o})});zu.displayName=Ob;function Db(e,t=globalThis==null?void 0:globalThis.document){const n=ft(e),r=p.useRef(!1),o=p.useRef(()=>{});return p.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){Uu(Mb,n,c,{discrete:!0})};const c={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 Lb(e,t=globalThis==null?void 0:globalThis.document){const n=ft(e),r=p.useRef(!1);return p.useEffect(()=>{const o=s=>{s.target&&!r.current&&Uu(Rb,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 Hu(){const e=new CustomEvent(zi);document.dispatchEvent(e)}function Uu(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?Bi(o,s):o.dispatchEvent(s)}var $b=yr,Fb=zu,Hi=0;function Ui(){p.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Wu()),document.body.insertAdjacentElement("beforeend",e[1]??Wu()),Hi++,()=>{Hi===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Hi--}},[])}function Wu(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var Wi="focusScope.autoFocusOnMount",Vi="focusScope.autoFocusOnUnmount",Vu={bubbles:!1,cancelable:!0},Bb="FocusScope",Zo=p.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,l]=p.useState(null),c=ft(o),d=ft(s),h=p.useRef(null),m=De(t,g=>l(g)),f=p.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;p.useEffect(()=>{if(r){let g=function(S){if(f.paused||!a)return;const k=S.target;a.contains(k)?h.current=k:Ln(h.current,{select:!0})},x=function(S){if(f.paused||!a)return;const k=S.relatedTarget;k!==null&&(a.contains(k)||Ln(h.current,{select:!0}))},y=function(S){if(document.activeElement===document.body)for(const C of S)C.removedNodes.length>0&&Ln(a)};document.addEventListener("focusin",g),document.addEventListener("focusout",x);const w=new MutationObserver(y);return a&&w.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",g),document.removeEventListener("focusout",x),w.disconnect()}}},[r,a,f.paused]),p.useEffect(()=>{if(a){Gu.add(f);const g=document.activeElement;if(!a.contains(g)){const y=new CustomEvent(Wi,Vu);a.addEventListener(Wi,c),a.dispatchEvent(y),y.defaultPrevented||(zb(Kb(Ku(a)),{select:!0}),document.activeElement===g&&Ln(a))}return()=>{a.removeEventListener(Wi,c),setTimeout(()=>{const y=new CustomEvent(Vi,Vu);a.addEventListener(Vi,d),a.dispatchEvent(y),y.defaultPrevented||Ln(g??document.body,{select:!0}),a.removeEventListener(Vi,d),Gu.remove(f)},0)}}},[a,c,d,f]);const v=p.useCallback(g=>{if(!n&&!r||f.paused)return;const x=g.key==="Tab"&&!g.altKey&&!g.ctrlKey&&!g.metaKey,y=document.activeElement;if(x&&y){const w=g.currentTarget,[S,k]=Hb(w);S&&k?!g.shiftKey&&y===k?(g.preventDefault(),n&&Ln(S,{select:!0})):g.shiftKey&&y===S&&(g.preventDefault(),n&&Ln(k,{select:!0})):y===w&&g.preventDefault()}},[n,r,f.paused]);return u.jsx(xe.div,{tabIndex:-1,...i,ref:m,onKeyDown:v})});Zo.displayName=Bb;function zb(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Ln(r,{select:t}),document.activeElement!==n)return}function Hb(e){const t=Ku(e),n=qu(t,e),r=qu(t.reverse(),e);return[n,r]}function Ku(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 qu(e,t){for(const n of e)if(!Ub(n,{upTo:t}))return n}function Ub(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 Wb(e){return e instanceof HTMLInputElement&&"select"in e}function Ln(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Wb(e)&&t&&e.select()}}var Gu=Vb();function Vb(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=Yu(e,t),e.unshift(t)},remove(t){var n;e=Yu(e,t),(n=e[0])==null||n.resume()}}}function Yu(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Kb(e){return e.filter(t=>t.tagName!=="A")}var qb=p[" useId ".trim().toString()]||(()=>{}),Gb=0;function Nt(e){const[t,n]=p.useState(qb());return yt(()=>{n(r=>r??String(Gb++))},[e]),t?`radix-${t}`:""}const Yb=["top","right","bottom","left"],$n=Math.min,Yt=Math.max,Qo=Math.round,es=Math.floor,vn=e=>({x:e,y:e}),Xb={left:"right",right:"left",bottom:"top",top:"bottom"},Jb={start:"end",end:"start"};function Ki(e,t,n){return Yt(e,$n(t,n))}function An(e,t){return typeof e=="function"?e(t):e}function jn(e){return e.split("-")[0]}function Sr(e){return e.split("-")[1]}function qi(e){return e==="x"?"y":"x"}function Gi(e){return e==="y"?"height":"width"}const Zb=new Set(["top","bottom"]);function bn(e){return Zb.has(jn(e))?"y":"x"}function Yi(e){return qi(bn(e))}function Qb(e,t,n){n===void 0&&(n=!1);const r=Sr(e),o=Yi(e),s=Gi(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=ts(i)),[i,ts(i)]}function ew(e){const t=ts(e);return[Xi(e),t,Xi(t)]}function Xi(e){return e.replace(/start|end/g,t=>Jb[t])}const Xu=["left","right"],Ju=["right","left"],tw=["top","bottom"],nw=["bottom","top"];function rw(e,t,n){switch(e){case"top":case"bottom":return n?t?Ju:Xu:t?Xu:Ju;case"left":case"right":return t?tw:nw;default:return[]}}function ow(e,t,n,r){const o=Sr(e);let s=rw(jn(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(Xi)))),s}function ts(e){return e.replace(/left|right|bottom|top/g,t=>Xb[t])}function sw(e){return{top:0,right:0,bottom:0,left:0,...e}}function Zu(e){return typeof e!="number"?sw(e):{top:e,right:e,bottom:e,left:e}}function ns(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 Qu(e,t,n){let{reference:r,floating:o}=e;const s=bn(t),i=Yi(t),a=Gi(i),l=jn(t),c=s==="y",d=r.x+r.width/2-o.width/2,h=r.y+r.height/2-o.height/2,m=r[a]/2-o[a]/2;let f;switch(l){case"top":f={x:d,y:r.y-o.height};break;case"bottom":f={x:d,y:r.y+r.height};break;case"right":f={x:r.x+r.width,y:h};break;case"left":f={x:r.x-o.width,y:h};break;default:f={x:r.x,y:r.y}}switch(Sr(t)){case"start":f[i]-=m*(n&&c?-1:1);break;case"end":f[i]+=m*(n&&c?-1:1);break}return f}const iw=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 c=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:d,y:h}=Qu(c,r,l),m=r,f={},v=0;for(let g=0;g<a.length;g++){const{name:x,fn:y}=a[g],{x:w,y:S,data:k,reset:C}=await y({x:d,y:h,initialPlacement:r,placement:m,strategy:o,middlewareData:f,rects:c,platform:i,elements:{reference:e,floating:t}});d=w??d,h=S??h,f={...f,[x]:{...f[x],...k}},C&&v<=50&&(v++,typeof C=="object"&&(C.placement&&(m=C.placement),C.rects&&(c=C.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):C.rects),{x:d,y:h}=Qu(c,m,l)),g=-1)}return{x:d,y:h,placement:m,strategy:o,middlewareData:f}};async function no(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:i,elements:a,strategy:l}=e,{boundary:c="clippingAncestors",rootBoundary:d="viewport",elementContext:h="floating",altBoundary:m=!1,padding:f=0}=An(t,e),v=Zu(f),x=a[m?h==="floating"?"reference":"floating":h],y=ns(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(x)))==null||n?x:x.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:c,rootBoundary:d,strategy:l})),w=h==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,S=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),k=await(s.isElement==null?void 0:s.isElement(S))?await(s.getScale==null?void 0:s.getScale(S))||{x:1,y:1}:{x:1,y:1},C=ns(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:w,offsetParent:S,strategy:l}):w);return{top:(y.top-C.top+v.top)/k.y,bottom:(C.bottom-y.bottom+v.bottom)/k.y,left:(y.left-C.left+v.left)/k.x,right:(C.right-y.right+v.right)/k.x}}const aw=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:c,padding:d=0}=An(e,t)||{};if(c==null)return{};const h=Zu(d),m={x:n,y:r},f=Yi(o),v=Gi(f),g=await i.getDimensions(c),x=f==="y",y=x?"top":"left",w=x?"bottom":"right",S=x?"clientHeight":"clientWidth",k=s.reference[v]+s.reference[f]-m[f]-s.floating[v],C=m[f]-s.reference[f],T=await(i.getOffsetParent==null?void 0:i.getOffsetParent(c));let E=T?T[S]:0;(!E||!await(i.isElement==null?void 0:i.isElement(T)))&&(E=a.floating[S]||s.floating[v]);const N=k/2-C/2,M=E/2-g[v]/2-1,O=$n(h[y],M),F=$n(h[w],M),G=O,K=E-g[v]-F,j=E/2-g[v]/2+N,Y=Ki(G,j,K),q=!l.arrow&&Sr(o)!=null&&j!==Y&&s.reference[v]/2-(j<G?O:F)-g[v]/2<0,z=q?j<G?j-G:j-K:0;return{[f]:m[f]+z,data:{[f]:Y,centerOffset:j-Y-z,...q&&{alignmentOffset:z}},reset:q}}}),lw=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:c}=t,{mainAxis:d=!0,crossAxis:h=!0,fallbackPlacements:m,fallbackStrategy:f="bestFit",fallbackAxisSideDirection:v="none",flipAlignment:g=!0,...x}=An(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const y=jn(o),w=bn(a),S=jn(a)===a,k=await(l.isRTL==null?void 0:l.isRTL(c.floating)),C=m||(S||!g?[ts(a)]:ew(a)),T=v!=="none";!m&&T&&C.push(...ow(a,g,v,k));const E=[a,...C],N=await no(t,x),M=[];let O=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&M.push(N[y]),h){const j=Qb(o,i,k);M.push(N[j[0]],N[j[1]])}if(O=[...O,{placement:o,overflows:M}],!M.every(j=>j<=0)){var F,G;const j=(((F=s.flip)==null?void 0:F.index)||0)+1,Y=E[j];if(Y&&(!(h==="alignment"?w!==bn(Y):!1)||O.every(R=>bn(R.placement)===w?R.overflows[0]>0:!0)))return{data:{index:j,overflows:O},reset:{placement:Y}};let q=(G=O.filter(z=>z.overflows[0]<=0).sort((z,R)=>z.overflows[1]-R.overflows[1])[0])==null?void 0:G.placement;if(!q)switch(f){case"bestFit":{var K;const z=(K=O.filter(R=>{if(T){const I=bn(R.placement);return I===w||I==="y"}return!0}).map(R=>[R.placement,R.overflows.filter(I=>I>0).reduce((I,U)=>I+U,0)]).sort((R,I)=>R[1]-I[1])[0])==null?void 0:K[0];z&&(q=z);break}case"initialPlacement":q=a;break}if(o!==q)return{reset:{placement:q}}}return{}}}};function ed(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function td(e){return Yb.some(t=>e[t]>=0)}const cw=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=An(e,t);switch(r){case"referenceHidden":{const s=await no(t,{...o,elementContext:"reference"}),i=ed(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:td(i)}}}case"escaped":{const s=await no(t,{...o,altBoundary:!0}),i=ed(s,n.floating);return{data:{escapedOffsets:i,escaped:td(i)}}}default:return{}}}}},nd=new Set(["left","top"]);async function uw(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=jn(n),a=Sr(n),l=bn(n)==="y",c=nd.has(i)?-1:1,d=s&&l?-1:1,h=An(t,e);let{mainAxis:m,crossAxis:f,alignmentAxis:v}=typeof h=="number"?{mainAxis:h,crossAxis:0,alignmentAxis:null}:{mainAxis:h.mainAxis||0,crossAxis:h.crossAxis||0,alignmentAxis:h.alignmentAxis};return a&&typeof v=="number"&&(f=a==="end"?v*-1:v),l?{x:f*d,y:m*c}:{x:m*c,y:f*d}}const dw=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 uw(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}}}}},fw=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:x=>{let{x:y,y:w}=x;return{x:y,y:w}}},...l}=An(e,t),c={x:n,y:r},d=await no(t,l),h=bn(jn(o)),m=qi(h);let f=c[m],v=c[h];if(s){const x=m==="y"?"top":"left",y=m==="y"?"bottom":"right",w=f+d[x],S=f-d[y];f=Ki(w,f,S)}if(i){const x=h==="y"?"top":"left",y=h==="y"?"bottom":"right",w=v+d[x],S=v-d[y];v=Ki(w,v,S)}const g=a.fn({...t,[m]:f,[h]:v});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[m]:s,[h]:i}}}}}},hw=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:c=!0}=An(e,t),d={x:n,y:r},h=bn(o),m=qi(h);let f=d[m],v=d[h];const g=An(a,t),x=typeof g=="number"?{mainAxis:g,crossAxis:0}:{mainAxis:0,crossAxis:0,...g};if(l){const S=m==="y"?"height":"width",k=s.reference[m]-s.floating[S]+x.mainAxis,C=s.reference[m]+s.reference[S]-x.mainAxis;f<k?f=k:f>C&&(f=C)}if(c){var y,w;const S=m==="y"?"width":"height",k=nd.has(jn(o)),C=s.reference[h]-s.floating[S]+(k&&((y=i.offset)==null?void 0:y[h])||0)+(k?0:x.crossAxis),T=s.reference[h]+s.reference[S]+(k?0:((w=i.offset)==null?void 0:w[h])||0)-(k?x.crossAxis:0);v<C?v=C:v>T&&(v=T)}return{[m]:f,[h]:v}}}},pw=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=()=>{},...c}=An(e,t),d=await no(t,c),h=jn(o),m=Sr(o),f=bn(o)==="y",{width:v,height:g}=s.floating;let x,y;h==="top"||h==="bottom"?(x=h,y=m===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(y=h,x=m==="end"?"top":"bottom");const w=g-d.top-d.bottom,S=v-d.left-d.right,k=$n(g-d[x],w),C=$n(v-d[y],S),T=!t.middlewareData.shift;let E=k,N=C;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(N=S),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(E=w),T&&!m){const O=Yt(d.left,0),F=Yt(d.right,0),G=Yt(d.top,0),K=Yt(d.bottom,0);f?N=v-2*(O!==0||F!==0?O+F:Yt(d.left,d.right)):E=g-2*(G!==0||K!==0?G+K:Yt(d.top,d.bottom))}await l({...t,availableWidth:N,availableHeight:E});const M=await i.getDimensions(a.floating);return v!==M.width||g!==M.height?{reset:{rects:!0}}:{}}}};function rs(){return typeof window<"u"}function Cr(e){return rd(e)?(e.nodeName||"").toLowerCase():"#document"}function Xt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function wn(e){var t;return(t=(rd(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function rd(e){return rs()?e instanceof Node||e instanceof Xt(e).Node:!1}function cn(e){return rs()?e instanceof Element||e instanceof Xt(e).Element:!1}function yn(e){return rs()?e instanceof HTMLElement||e instanceof Xt(e).HTMLElement:!1}function od(e){return!rs()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Xt(e).ShadowRoot}const mw=new Set(["inline","contents"]);function ro(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=un(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!mw.has(o)}const gw=new Set(["table","td","th"]);function xw(e){return gw.has(Cr(e))}const vw=[":popover-open",":modal"];function os(e){return vw.some(t=>{try{return e.matches(t)}catch{return!1}})}const bw=["transform","translate","scale","rotate","perspective"],ww=["transform","translate","scale","rotate","perspective","filter"],yw=["paint","layout","strict","content"];function Ji(e){const t=Zi(),n=cn(e)?un(e):e;return bw.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)||ww.some(r=>(n.willChange||"").includes(r))||yw.some(r=>(n.contain||"").includes(r))}function Sw(e){let t=Fn(e);for(;yn(t)&&!Tr(t);){if(Ji(t))return t;if(os(t))return null;t=Fn(t)}return null}function Zi(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Cw=new Set(["html","body","#document"]);function Tr(e){return Cw.has(Cr(e))}function un(e){return Xt(e).getComputedStyle(e)}function ss(e){return cn(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Fn(e){if(Cr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||od(e)&&e.host||wn(e);return od(t)?t.host:t}function sd(e){const t=Fn(e);return Tr(t)?e.ownerDocument?e.ownerDocument.body:e.body:yn(t)&&ro(t)?t:sd(t)}function oo(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=sd(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Xt(o);if(s){const a=Qi(i);return t.concat(i,i.visualViewport||[],ro(o)?o:[],a&&n?oo(a):[])}return t.concat(o,oo(o,[],n))}function Qi(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function id(e){const t=un(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=yn(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=Qo(n)!==s||Qo(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function ea(e){return cn(e)?e:e.contextElement}function kr(e){const t=ea(e);if(!yn(t))return vn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=id(t);let i=(s?Qo(n.width):n.width)/r,a=(s?Qo(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const Tw=vn(0);function ad(e){const t=Xt(e);return!Zi()||!t.visualViewport?Tw:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function kw(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Xt(e)?!1:t}function er(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=ea(e);let i=vn(1);t&&(r?cn(r)&&(i=kr(r)):i=kr(e));const a=kw(s,n,r)?ad(s):vn(0);let l=(o.left+a.x)/i.x,c=(o.top+a.y)/i.y,d=o.width/i.x,h=o.height/i.y;if(s){const m=Xt(s),f=r&&cn(r)?Xt(r):r;let v=m,g=Qi(v);for(;g&&r&&f!==v;){const x=kr(g),y=g.getBoundingClientRect(),w=un(g),S=y.left+(g.clientLeft+parseFloat(w.paddingLeft))*x.x,k=y.top+(g.clientTop+parseFloat(w.paddingTop))*x.y;l*=x.x,c*=x.y,d*=x.x,h*=x.y,l+=S,c+=k,v=Xt(g),g=Qi(v)}}return ns({width:d,height:h,x:l,y:c})}function is(e,t){const n=ss(e).scrollLeft;return t?t.left+n:er(wn(e)).left+n}function ld(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-is(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function Ew(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=wn(r),a=t?os(t.floating):!1;if(r===i||a&&s)return n;let l={scrollLeft:0,scrollTop:0},c=vn(1);const d=vn(0),h=yn(r);if((h||!h&&!s)&&((Cr(r)!=="body"||ro(i))&&(l=ss(r)),yn(r))){const f=er(r);c=kr(r),d.x=f.x+r.clientLeft,d.y=f.y+r.clientTop}const m=i&&!h&&!s?ld(i,l):vn(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+d.x+m.x,y:n.y*c.y-l.scrollTop*c.y+d.y+m.y}}function Iw(e){return Array.from(e.getClientRects())}function Nw(e){const t=wn(e),n=ss(e),r=e.ownerDocument.body,o=Yt(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Yt(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+is(e);const a=-n.scrollTop;return un(r).direction==="rtl"&&(i+=Yt(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const cd=25;function Aw(e,t){const n=Xt(e),r=wn(e),o=n.visualViewport;let s=r.clientWidth,i=r.clientHeight,a=0,l=0;if(o){s=o.width,i=o.height;const d=Zi();(!d||d&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}const c=is(r);if(c<=0){const d=r.ownerDocument,h=d.body,m=getComputedStyle(h),f=d.compatMode==="CSS1Compat"&&parseFloat(m.marginLeft)+parseFloat(m.marginRight)||0,v=Math.abs(r.clientWidth-h.clientWidth-f);v<=cd&&(s-=v)}else c<=cd&&(s+=c);return{width:s,height:i,x:a,y:l}}const jw=new Set(["absolute","fixed"]);function Pw(e,t){const n=er(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=yn(e)?kr(e):vn(1),i=e.clientWidth*s.x,a=e.clientHeight*s.y,l=o*s.x,c=r*s.y;return{width:i,height:a,x:l,y:c}}function ud(e,t,n){let r;if(t==="viewport")r=Aw(e,n);else if(t==="document")r=Nw(wn(e));else if(cn(t))r=Pw(t,n);else{const o=ad(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return ns(r)}function dd(e,t){const n=Fn(e);return n===t||!cn(n)||Tr(n)?!1:un(n).position==="fixed"||dd(n,t)}function _w(e,t){const n=t.get(e);if(n)return n;let r=oo(e,[],!1).filter(a=>cn(a)&&Cr(a)!=="body"),o=null;const s=un(e).position==="fixed";let i=s?Fn(e):e;for(;cn(i)&&!Tr(i);){const a=un(i),l=Ji(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&jw.has(o.position)||ro(i)&&!l&&dd(e,i))?r=r.filter(d=>d!==i):o=a,i=Fn(i)}return t.set(e,r),r}function Mw(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?os(t)?[]:_w(t,this._c):[].concat(n),r],a=i[0],l=i.reduce((c,d)=>{const h=ud(t,d,o);return c.top=Yt(h.top,c.top),c.right=$n(h.right,c.right),c.bottom=$n(h.bottom,c.bottom),c.left=Yt(h.left,c.left),c},ud(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function Rw(e){const{width:t,height:n}=id(e);return{width:t,height:n}}function Ow(e,t,n){const r=yn(t),o=wn(t),s=n==="fixed",i=er(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=vn(0);function c(){l.x=is(o)}if(r||!r&&!s)if((Cr(t)!=="body"||ro(o))&&(a=ss(t)),r){const f=er(t,!0,s,t);l.x=f.x+t.clientLeft,l.y=f.y+t.clientTop}else o&&c();s&&!r&&o&&c();const d=o&&!r&&!s?ld(o,a):vn(0),h=i.left+a.scrollLeft-l.x-d.x,m=i.top+a.scrollTop-l.y-d.y;return{x:h,y:m,width:i.width,height:i.height}}function ta(e){return un(e).position==="static"}function fd(e,t){if(!yn(e)||un(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return wn(e)===n&&(n=n.ownerDocument.body),n}function hd(e,t){const n=Xt(e);if(os(e))return n;if(!yn(e)){let o=Fn(e);for(;o&&!Tr(o);){if(cn(o)&&!ta(o))return o;o=Fn(o)}return n}let r=fd(e,t);for(;r&&xw(r)&&ta(r);)r=fd(r,t);return r&&Tr(r)&&ta(r)&&!Ji(r)?n:r||Sw(e)||n}const Dw=async function(e){const t=this.getOffsetParent||hd,n=this.getDimensions,r=await n(e.floating);return{reference:Ow(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Lw(e){return un(e).direction==="rtl"}const $w={convertOffsetParentRelativeRectToViewportRelativeRect:Ew,getDocumentElement:wn,getClippingRect:Mw,getOffsetParent:hd,getElementRects:Dw,getClientRects:Iw,getDimensions:Rw,getScale:kr,isElement:cn,isRTL:Lw};function pd(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Fw(e,t){let n=null,r;const o=wn(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 c=e.getBoundingClientRect(),{left:d,top:h,width:m,height:f}=c;if(a||t(),!m||!f)return;const v=es(h),g=es(o.clientWidth-(d+m)),x=es(o.clientHeight-(h+f)),y=es(d),S={rootMargin:-v+"px "+-g+"px "+-x+"px "+-y+"px",threshold:Yt(0,$n(1,l))||1};let k=!0;function C(T){const E=T[0].intersectionRatio;if(E!==l){if(!k)return i();E?i(!1,E):r=setTimeout(()=>{i(!1,1e-7)},1e3)}E===1&&!pd(c,e.getBoundingClientRect())&&i(),k=!1}try{n=new IntersectionObserver(C,{...S,root:o.ownerDocument})}catch{n=new IntersectionObserver(C,S)}n.observe(e)}return i(!0),s}function Bw(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,c=ea(e),d=o||s?[...c?oo(c):[],...oo(t)]:[];d.forEach(y=>{o&&y.addEventListener("scroll",n,{passive:!0}),s&&y.addEventListener("resize",n)});const h=c&&a?Fw(c,n):null;let m=-1,f=null;i&&(f=new ResizeObserver(y=>{let[w]=y;w&&w.target===c&&f&&(f.unobserve(t),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var S;(S=f)==null||S.observe(t)})),n()}),c&&!l&&f.observe(c),f.observe(t));let v,g=l?er(e):null;l&&x();function x(){const y=er(e);g&&!pd(g,y)&&n(),g=y,v=requestAnimationFrame(x)}return n(),()=>{var y;d.forEach(w=>{o&&w.removeEventListener("scroll",n),s&&w.removeEventListener("resize",n)}),h==null||h(),(y=f)==null||y.disconnect(),f=null,l&&cancelAnimationFrame(v)}}const zw=dw,Hw=fw,Uw=lw,Ww=pw,Vw=cw,md=aw,Kw=hw,qw=(e,t,n)=>{const r=new Map,o={platform:$w,...n},s={...o.platform,_c:r};return iw(e,t,{...o,platform:s})};var Gw=typeof document<"u",Yw=function(){},as=Gw?b.useLayoutEffect:Yw;function ls(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(!ls(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)&&!ls(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function gd(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function xd(e,t){const n=gd(e);return Math.round(t*n)/n}function na(e){const t=p.useRef(e);return as(()=>{t.current=e}),t}function Xw(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:c}=e,[d,h]=p.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[m,f]=p.useState(r);ls(m,r)||f(r);const[v,g]=p.useState(null),[x,y]=p.useState(null),w=p.useCallback(R=>{R!==T.current&&(T.current=R,g(R))},[]),S=p.useCallback(R=>{R!==E.current&&(E.current=R,y(R))},[]),k=s||v,C=i||x,T=p.useRef(null),E=p.useRef(null),N=p.useRef(d),M=l!=null,O=na(l),F=na(o),G=na(c),K=p.useCallback(()=>{if(!T.current||!E.current)return;const R={placement:t,strategy:n,middleware:m};F.current&&(R.platform=F.current),qw(T.current,E.current,R).then(I=>{const U={...I,isPositioned:G.current!==!1};j.current&&!ls(N.current,U)&&(N.current=U,Hr.flushSync(()=>{h(U)}))})},[m,t,n,F,G]);as(()=>{c===!1&&N.current.isPositioned&&(N.current.isPositioned=!1,h(R=>({...R,isPositioned:!1})))},[c]);const j=p.useRef(!1);as(()=>(j.current=!0,()=>{j.current=!1}),[]),as(()=>{if(k&&(T.current=k),C&&(E.current=C),k&&C){if(O.current)return O.current(k,C,K);K()}},[k,C,K,O,M]);const Y=p.useMemo(()=>({reference:T,floating:E,setReference:w,setFloating:S}),[w,S]),q=p.useMemo(()=>({reference:k,floating:C}),[k,C]),z=p.useMemo(()=>{const R={position:n,left:0,top:0};if(!q.floating)return R;const I=xd(q.floating,d.x),U=xd(q.floating,d.y);return a?{...R,transform:"translate("+I+"px, "+U+"px)",...gd(q.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:I,top:U}},[n,a,q.floating,d.x,d.y]);return p.useMemo(()=>({...d,update:K,refs:Y,elements:q,floatingStyles:z}),[d,K,Y,q,z])}const Jw=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?md({element:r.current,padding:o}).fn(n):{}:r?md({element:r,padding:o}).fn(n):{}}}},Zw=(e,t)=>({...zw(e),options:[e,t]}),Qw=(e,t)=>({...Hw(e),options:[e,t]}),ey=(e,t)=>({...Kw(e),options:[e,t]}),ty=(e,t)=>({...Uw(e),options:[e,t]}),ny=(e,t)=>({...Ww(e),options:[e,t]}),ry=(e,t)=>({...Vw(e),options:[e,t]}),oy=(e,t)=>({...Jw(e),options:[e,t]});var sy="Arrow",vd=p.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return u.jsx(xe.svg,{...s,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:u.jsx("polygon",{points:"0,0 30,0 15,10"})})});vd.displayName=sy;var iy=vd;function bd(e){const[t,n]=p.useState(void 0);return yt(()=>{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,c=Array.isArray(l)?l[0]:l;i=c.inlineSize,a=c.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 ra="Popper",[wd,Er]=ln(ra),[ay,yd]=wd(ra),Sd=e=>{const{__scopePopper:t,children:n}=e,[r,o]=p.useState(null);return u.jsx(ay,{scope:t,anchor:r,onAnchorChange:o,children:n})};Sd.displayName=ra;var Cd="PopperAnchor",Td=p.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=yd(Cd,n),i=p.useRef(null),a=De(t,i),l=p.useRef(null);return p.useEffect(()=>{const c=l.current;l.current=(r==null?void 0:r.current)||i.current,c!==l.current&&s.onAnchorChange(l.current)}),r?null:u.jsx(xe.div,{...o,ref:a})});Td.displayName=Cd;var oa="PopperContent",[ly,cy]=wd(oa),kd=p.forwardRef((e,t)=>{var H,L,Z,te,Q,W;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:a=0,avoidCollisions:l=!0,collisionBoundary:c=[],collisionPadding:d=0,sticky:h="partial",hideWhenDetached:m=!1,updatePositionStrategy:f="optimized",onPlaced:v,...g}=e,x=yd(oa,n),[y,w]=p.useState(null),S=De(t,le=>w(le)),[k,C]=p.useState(null),T=bd(k),E=(T==null?void 0:T.width)??0,N=(T==null?void 0:T.height)??0,M=r+(s!=="center"?"-"+s:""),O=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},F=Array.isArray(c)?c:[c],G=F.length>0,K={padding:O,boundary:F.filter(dy),altBoundary:G},{refs:j,floatingStyles:Y,placement:q,isPositioned:z,middlewareData:R}=Xw({strategy:"fixed",placement:M,whileElementsMounted:(...le)=>Bw(...le,{animationFrame:f==="always"}),elements:{reference:x.anchor},middleware:[Zw({mainAxis:o+N,alignmentAxis:i}),l&&Qw({mainAxis:!0,crossAxis:!1,limiter:h==="partial"?ey():void 0,...K}),l&&ty({...K}),ny({...K,apply:({elements:le,rects:ie,availableWidth:ge,availableHeight:we})=>{const{width:Ce,height:Ae}=ie.reference,Ee=le.floating.style;Ee.setProperty("--radix-popper-available-width",`${ge}px`),Ee.setProperty("--radix-popper-available-height",`${we}px`),Ee.setProperty("--radix-popper-anchor-width",`${Ce}px`),Ee.setProperty("--radix-popper-anchor-height",`${Ae}px`)}}),k&&oy({element:k,padding:a}),fy({arrowWidth:E,arrowHeight:N}),m&&ry({strategy:"referenceHidden",...K})]}),[I,U]=Nd(q),J=ft(v);yt(()=>{z&&(J==null||J())},[z,J]);const _=(H=R.arrow)==null?void 0:H.x,P=(L=R.arrow)==null?void 0:L.y,D=((Z=R.arrow)==null?void 0:Z.centerOffset)!==0,[$,ee]=p.useState();return yt(()=>{y&&ee(window.getComputedStyle(y).zIndex)},[y]),u.jsx("div",{ref:j.setFloating,"data-radix-popper-content-wrapper":"",style:{...Y,transform:z?Y.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:$,"--radix-popper-transform-origin":[(te=R.transformOrigin)==null?void 0:te.x,(Q=R.transformOrigin)==null?void 0:Q.y].join(" "),...((W=R.hide)==null?void 0:W.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:u.jsx(ly,{scope:n,placedSide:I,onArrowChange:C,arrowX:_,arrowY:P,shouldHideArrow:D,children:u.jsx(xe.div,{"data-side":I,"data-align":U,...g,ref:S,style:{...g.style,animation:z?void 0:"none"}})})})});kd.displayName=oa;var Ed="PopperArrow",uy={top:"bottom",right:"left",bottom:"top",left:"right"},Id=p.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=cy(Ed,r),i=uy[s.placedSide];return u.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:u.jsx(iy,{...o,ref:n,style:{...o.style,display:"block"}})})});Id.displayName=Ed;function dy(e){return e!==null}var fy=e=>({name:"transformOrigin",options:e,fn(t){var x,y,w;const{placement:n,rects:r,middlewareData:o}=t,i=((x=o.arrow)==null?void 0:x.centerOffset)!==0,a=i?0:e.arrowWidth,l=i?0:e.arrowHeight,[c,d]=Nd(n),h={start:"0%",center:"50%",end:"100%"}[d],m=(((y=o.arrow)==null?void 0:y.x)??0)+a/2,f=(((w=o.arrow)==null?void 0:w.y)??0)+l/2;let v="",g="";return c==="bottom"?(v=i?h:`${m}px`,g=`${-l}px`):c==="top"?(v=i?h:`${m}px`,g=`${r.floating.height+l}px`):c==="right"?(v=`${-l}px`,g=i?h:`${f}px`):c==="left"&&(v=`${r.floating.width+l}px`,g=i?h:`${f}px`),{data:{x:v,y:g}}}});function Nd(e){const[t,n="center"]=e.split("-");return[t,n]}var sa=Sd,ia=Td,aa=kd,la=Id,hy="Portal",so=p.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=p.useState(!1);yt(()=>s(!0),[]);const i=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?Mo.createPortal(u.jsx(xe.div,{...r,ref:t}),i):null});so.displayName=hy;function py(e,t){return p.useReducer((n,r)=>t[n][r]??n,e)}var zt=e=>{const{present:t,children:n}=e,r=my(t),o=typeof n=="function"?n({present:r.isPresent}):p.Children.only(n),s=De(r.ref,gy(o));return typeof n=="function"||r.isPresent?p.cloneElement(o,{ref:s}):null};zt.displayName="Presence";function my(e){const[t,n]=p.useState(),r=p.useRef(null),o=p.useRef(e),s=p.useRef("none"),i=e?"mounted":"unmounted",[a,l]=py(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return p.useEffect(()=>{const c=cs(r.current);s.current=a==="mounted"?c:"none"},[a]),yt(()=>{const c=r.current,d=o.current;if(d!==e){const m=s.current,f=cs(c);e?l("MOUNT"):f==="none"||(c==null?void 0:c.display)==="none"?l("UNMOUNT"):l(d&&m!==f?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,l]),yt(()=>{if(t){let c;const d=t.ownerDocument.defaultView??window,h=f=>{const g=cs(r.current).includes(CSS.escape(f.animationName));if(f.target===t&&g&&(l("ANIMATION_END"),!o.current)){const x=t.style.animationFillMode;t.style.animationFillMode="forwards",c=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=x)})}},m=f=>{f.target===t&&(s.current=cs(r.current))};return t.addEventListener("animationstart",m),t.addEventListener("animationcancel",h),t.addEventListener("animationend",h),()=>{d.clearTimeout(c),t.removeEventListener("animationstart",m),t.removeEventListener("animationcancel",h),t.removeEventListener("animationend",h)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:p.useCallback(c=>{r.current=c?getComputedStyle(c):null,n(c)},[])}}function cs(e){return(e==null?void 0:e.animationName)||"none"}function gy(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 ca="rovingFocusGroup.onEntryFocus",xy={bubbles:!1,cancelable:!0},io="RovingFocusGroup",[ua,Ad,vy]=Xo(io),[by,jd]=ln(io,[vy]),[wy,yy]=by(io),Pd=p.forwardRef((e,t)=>u.jsx(ua.Provider,{scope:e.__scopeRovingFocusGroup,children:u.jsx(ua.Slot,{scope:e.__scopeRovingFocusGroup,children:u.jsx(Sy,{...e,ref:t})})}));Pd.displayName=io;var Sy=p.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:c,preventScrollOnEntryFocus:d=!1,...h}=e,m=p.useRef(null),f=De(t,m),v=Jo(s),[g,x]=Dn({prop:i,defaultProp:a??null,onChange:l,caller:io}),[y,w]=p.useState(!1),S=ft(c),k=Ad(n),C=p.useRef(!1),[T,E]=p.useState(0);return p.useEffect(()=>{const N=m.current;if(N)return N.addEventListener(ca,S),()=>N.removeEventListener(ca,S)},[S]),u.jsx(wy,{scope:n,orientation:r,dir:v,loop:o,currentTabStopId:g,onItemFocus:p.useCallback(N=>x(N),[x]),onItemShiftTab:p.useCallback(()=>w(!0),[]),onFocusableItemAdd:p.useCallback(()=>E(N=>N+1),[]),onFocusableItemRemove:p.useCallback(()=>E(N=>N-1),[]),children:u.jsx(xe.div,{tabIndex:y||T===0?-1:0,"data-orientation":r,...h,ref:f,style:{outline:"none",...e.style},onMouseDown:ce(e.onMouseDown,()=>{C.current=!0}),onFocus:ce(e.onFocus,N=>{const M=!C.current;if(N.target===N.currentTarget&&M&&!y){const O=new CustomEvent(ca,xy);if(N.currentTarget.dispatchEvent(O),!O.defaultPrevented){const F=k().filter(q=>q.focusable),G=F.find(q=>q.active),K=F.find(q=>q.id===g),Y=[G,K,...F].filter(Boolean).map(q=>q.ref.current);Rd(Y,d)}}C.current=!1}),onBlur:ce(e.onBlur,()=>w(!1))})})}),_d="RovingFocusGroupItem",Md=p.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,l=Nt(),c=s||l,d=yy(_d,n),h=d.currentTabStopId===c,m=Ad(n),{onFocusableItemAdd:f,onFocusableItemRemove:v,currentTabStopId:g}=d;return p.useEffect(()=>{if(r)return f(),()=>v()},[r,f,v]),u.jsx(ua.ItemSlot,{scope:n,id:c,focusable:r,active:o,children:u.jsx(xe.span,{tabIndex:h?0:-1,"data-orientation":d.orientation,...a,ref:t,onMouseDown:ce(e.onMouseDown,x=>{r?d.onItemFocus(c):x.preventDefault()}),onFocus:ce(e.onFocus,()=>d.onItemFocus(c)),onKeyDown:ce(e.onKeyDown,x=>{if(x.key==="Tab"&&x.shiftKey){d.onItemShiftTab();return}if(x.target!==x.currentTarget)return;const y=ky(x,d.orientation,d.dir);if(y!==void 0){if(x.metaKey||x.ctrlKey||x.altKey||x.shiftKey)return;x.preventDefault();let S=m().filter(k=>k.focusable).map(k=>k.ref.current);if(y==="last")S.reverse();else if(y==="prev"||y==="next"){y==="prev"&&S.reverse();const k=S.indexOf(x.currentTarget);S=d.loop?Ey(S,k+1):S.slice(k+1)}setTimeout(()=>Rd(S))}}),children:typeof i=="function"?i({isCurrentTabStop:h,hasTabStop:g!=null}):i})})});Md.displayName=_d;var Cy={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Ty(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function ky(e,t,n){const r=Ty(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return Cy[r]}function Rd(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function Ey(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Iy=Pd,Ny=Md,Ay=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Ir=new WeakMap,us=new WeakMap,ds={},da=0,Od=function(e){return e&&(e.host||Od(e.parentNode))},jy=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=Od(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})},Py=function(e,t,n,r){var o=jy(t,Array.isArray(e)?e:[e]);ds[n]||(ds[n]=new WeakMap);var s=ds[n],i=[],a=new Set,l=new Set(o),c=function(h){!h||a.has(h)||(a.add(h),c(h.parentNode))};o.forEach(c);var d=function(h){!h||l.has(h)||Array.prototype.forEach.call(h.children,function(m){if(a.has(m))d(m);else try{var f=m.getAttribute(r),v=f!==null&&f!=="false",g=(Ir.get(m)||0)+1,x=(s.get(m)||0)+1;Ir.set(m,g),s.set(m,x),i.push(m),g===1&&v&&us.set(m,!0),x===1&&m.setAttribute(n,"true"),v||m.setAttribute(r,"true")}catch(y){console.error("aria-hidden: cannot operate on ",m,y)}})};return d(t),a.clear(),da++,function(){i.forEach(function(h){var m=Ir.get(h)-1,f=s.get(h)-1;Ir.set(h,m),s.set(h,f),m||(us.has(h)||h.removeAttribute(r),us.delete(h)),f||h.removeAttribute(n)}),da--,da||(Ir=new WeakMap,Ir=new WeakMap,us=new WeakMap,ds={})}},fa=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=Ay(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),Py(r,o,n,"aria-hidden")):function(){return null}},Sn=function(){return Sn=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},Sn.apply(this,arguments)};function Dd(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 _y(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 fs="right-scroll-bar-position",hs="width-before-scroll-bar",My="with-scroll-bars-hidden",Ry="--removed-body-scroll-bar-size";function ha(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function Oy(e,t){var n=b.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 Dy=typeof window<"u"?p.useLayoutEffect:p.useEffect,Ld=new WeakMap;function Ly(e,t){var n=Oy(null,function(r){return e.forEach(function(o){return ha(o,r)})});return Dy(function(){var r=Ld.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||ha(a,null)}),s.forEach(function(a){o.has(a)||ha(a,i)})}Ld.set(n,e)},[e]),n}function $y(e){return e}function Fy(e,t){t===void 0&&(t=$y);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)},c=function(){return Promise.resolve().then(l)};c(),n={push:function(d){i.push(d),c()},filter:function(d){return i=i.filter(d),n}}}};return o}function By(e){e===void 0&&(e={});var t=Fy(null);return t.options=Sn({async:!0,ssr:!1},e),t}var $d=function(e){var t=e.sideCar,n=Dd(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return p.createElement(r,Sn({},n))};$d.isSideCarExport=!0;function zy(e,t){return e.useMedium(t),$d}var Fd=By(),pa=function(){},ps=p.forwardRef(function(e,t){var n=p.useRef(null),r=p.useState({onScrollCapture:pa,onWheelCapture:pa,onTouchMoveCapture:pa}),o=r[0],s=r[1],i=e.forwardProps,a=e.children,l=e.className,c=e.removeScrollBar,d=e.enabled,h=e.shards,m=e.sideCar,f=e.noRelative,v=e.noIsolation,g=e.inert,x=e.allowPinchZoom,y=e.as,w=y===void 0?"div":y,S=e.gapMode,k=Dd(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=m,T=Ly([n,t]),E=Sn(Sn({},k),o);return p.createElement(p.Fragment,null,d&&p.createElement(C,{sideCar:Fd,removeScrollBar:c,shards:h,noRelative:f,noIsolation:v,inert:g,setCallbacks:s,allowPinchZoom:!!x,lockRef:n,gapMode:S}),i?p.cloneElement(p.Children.only(a),Sn(Sn({},E),{ref:T})):p.createElement(w,Sn({},E,{className:l,ref:T}),a))});ps.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},ps.classNames={fullWidth:hs,zeroRight:fs};var Hy=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Uy(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Hy();return t&&e.setAttribute("nonce",t),e}function Wy(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Vy(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var Ky=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Uy())&&(Wy(t,n),Vy(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},qy=function(){var e=Ky();return function(t,n){p.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Bd=function(){var e=qy(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},Gy={left:0,top:0,right:0,gap:0},ma=function(e){return parseInt(e||"",10)||0},Yy=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[ma(n),ma(r),ma(o)]},Xy=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Gy;var t=Yy(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])}},Jy=Bd(),Nr="data-scroll-locked",Zy=function(e,t,n,r){var o=e.left,s=e.top,i=e.right,a=e.gap;return n===void 0&&(n="margin"),`
|
|
38
|
+
`);if(!it)continue;let et;try{et=JSON.parse(it)}catch{console.debug("[use-chat] malformed SSE:",it.slice(0,200));continue}const Qt=su(et)?et.data:et;if(!Qt){console.warn("[use-chat] dropped envelope event without payload",et);continue}const Re=Qt;Tt=Date.now();const pt=Re.seq;if(pt!==void 0){if(pt<=bt){console.debug("[use-chat] drop duplicate/out-of-order event",{seq:pt,lastProcessedSeq:bt,type:Re.type});continue}bt>0&&pt>bt+1&&((Q=I==null?void 0:I.onGap)==null||Q.call(I,{from:bt,to:pt})),bt=pt,E.current=pt,x(pt)}if(Re.type==="message.start"&&Re.role==="assistant"){const Je=uu(Re.model);G.current={messageId:Re.id,lastSeq:pt??null,lastText:""},k({id:Re.id,role:"assistant",name:Je??void 0,model:Re.model,createdAt:new Date().toISOString(),content:[]})}if(Re.type==="checkpoint")_.current=Re.checkpointId??null,D.current=Re.checkpointNs??null,v(Re.checkpointId??null);else if(Re.type==="state_history"){F.current=Re;try{const ut=Rn(Re).latest;ut&&(_.current=ut.checkpointId??null,D.current=ut.checkpointNs??null,v(ut.checkpointId??null))}catch(Je){console.warn("[use-chat] Failed to hydrate state_history payload",Je)}}try{R==null||R(Re)}catch(Je){console.error("[use-chat] Error in onEvent callback:",Je,"for event:",Re.type)}if(Re.type==="message.delta"){k(ut=>{const In=G.current;if(!ut||In.messageId!==ut.id)return ut;const{newParts:N,newMeta:re,changed:de}=lu(ut.content??[],Re.delta,{lastSeq:In.lastSeq,lastText:In.lastText},pt??null);return de?(G.current={...In,lastSeq:re.lastSeq??In.lastSeq,lastText:re.lastText??In.lastText},{...ut,content:N}):ut});const Je=Re.delta.filter(ut=>ut.type==="text").map(ut=>ut.text).join("");Je&&e.autoAppendAssistant!==!1&&(Et.push(Je),on())}else if(Re.type==="heartbeat"){console.debug("[use-chat] heartbeat received");try{(U=I==null?void 0:I.onHeartbeat)==null||U.call(I,Re)}catch(Je){console.warn("[use-chat] heartbeat callback failed",Je)}}else if(wt!==null&&cancelAnimationFrame(wt),Ct(),Re.type==="checkpoint")v(Re.checkpointId);else if(Re.type==="error"){const Je=Re;if(d(Je.message),J="error",P=Je.message,Je.error_type==="auth_error"||Je.code==="TOKEN_EXPIRED"||((le=Je.message)==null?void 0:le.includes("token"))||((ie=Je.message)==null?void 0:ie.includes("401"))||((ge=Je.message)==null?void 0:ge.includes("unauthorized"))||((we=Je.message)==null?void 0:we.includes("Unauthorized"))){console.error("[use-chat] Auth error detected:",Je.message);try{(Ce=I==null?void 0:I.onAuthError)==null||Ce.call(I,Je.message)}catch(In){console.warn("[use-chat] onAuthError handler failed",In)}z.abort()}}}}Ct(),J===null&&!z.signal.aborted&&(J="complete")}catch($e){if($e.name==="AbortError")J=J??"aborted";else{const ze=$e.message||String($e);J="error",P=ze,d(ze),(Ae=I==null?void 0:I.onError)==null||Ae.call(I,ze)}}finally{try{await ct.cancel()}catch{}finally{(Ee=ct.releaseLock)==null||Ee.call(ct)}wt!==null&&typeof window<"u"&&window.cancelAnimationFrame(wt),clearInterval(Lt)}}catch(Oe){if(Oe.name==="AbortError")J=J??"aborted";else{const qe=Oe.message||String(Oe);J="error",P=qe,d(qe),(st=I==null?void 0:I.onError)==null||st.call(I,qe),O||((lt=I==null?void 0:I.onConnectionError)==null||lt.call(I,qe),O=!0)}}finally{const Oe=E.current,qe=_.current,We=D.current,je=F.current,_e=J??(z.signal.aborted?"aborted":P?"error":"complete");try{(St=I==null?void 0:I.onClosed)==null||St.call(I,{reason:_e,lastSeq:Oe,lastCheckpointId:qe,lastCheckpointNs:We,lastStateHistory:je,error:P})}catch(ct){console.warn("[use-chat] onClosed callback failed",ct)}l(!1),w(!1),C.current=null,E.current=0,x(0),j.current=null}})(),{close:()=>z.abort()}},[t,n,r,e.autoAppendAssistant]);return b.useEffect(()=>()=>{var W;T.current=!1,(W=C.current)==null||W.abort()},[]),{isStreaming:a,error:c,assistantText:h,assistantMessage:S,lastCheckpointId:f,lastSeq:g,connected:y,stream:q,stop:Y,clear:A,setToken:K}}const Yv=["detail","message","error","description","title"];function Go(e){if(!e)return null;if(typeof e=="string"){const t=e.trim();return t.length?t:null}if(Array.isArray(e)){for(const t of e){const n=Go(t);if(n)return n}return null}if(typeof e=="object"){const t=e;for(const n of Yv){const r=Go(t[n]);if(r)return r}if("errors"in t){const n=Go(t.errors);if(n)return n}}return null}function Xv(e){if(!e)return"Request failed";const t=e.response,n=Go(t==null?void 0:t.data);if(n)return n;if(t!=null&&t.statusText)return t.statusText;if(e instanceof Error&&e.message)return e.message;if(typeof e=="string"){const r=e.trim();if(r.length)return r}return t!=null&&t.status?`Request failed with status code ${t.status}`:"Request failed"}function du({api:e,initialThreadId:t=null,onError:n,onThreadChange:r,onCurrentThreadDeleted:o}){const[s,i]=b.useState([]),[a,l]=b.useState(t),[c,d]=b.useState(!1),[h,m]=b.useState(null),[f,v]=b.useState([]),[g,x]=b.useState(!1),[,y]=b.useState(null),[w,S]=b.useState(null),[k,C]=b.useState(!1),T=b.useRef(a),E=b.useRef(new Map);b.useEffect(()=>{T.current=a},[a]);const j=b.useCallback(async()=>{d(!0),m(null);try{const R=await e.listThreads();i(R??[])}catch(R){const I=String(R);m(I),n==null||n(I)}finally{d(!1)}},[e,n]),_=b.useCallback(async()=>{x(!0),y(null);try{const R=await e.listSharedThreads();v(R??[])}catch(R){const I=String(R);y(I),n==null||n(I)}finally{x(!1)}},[e,n]);b.useEffect(()=>{j()},[j]),b.useEffect(()=>{_()},[_]),b.useEffect(()=>{r==null||r(a)},[a,r]);const D=b.useCallback(async R=>{try{const I=await e.createThread(R);return l(I.threadId),await j(),I.threadId}catch(I){const z=String(I);return n==null||n(z),null}},[e,n,j]),F=b.useCallback(async R=>{const I=s;i(J=>J.filter(P=>P.threadId!==R));const z=new AbortController;E.current.set(R,z);try{await e.deleteThread(R),T.current===R&&(l(null),o==null||o())}catch(J){i(I);const P=String(J);n==null||n(P)}finally{E.current.delete(R)}},[e,o,n,s]),G=b.useCallback(async(R,I)=>{try{await e.updateThread(R,I),await j()}catch(z){n==null||n(String(z))}},[e,n,j]),K=b.useCallback(async(R,I)=>{C(!0),S("Sharing thread…");try{await e.shareThread(R,I),await _(),S("Shared successfully")}catch(z){const J=Xv(z);throw n==null||n(J),S(`Failed to share: ${J}`),new Error(J)}finally{C(!1)}},[e,n,_]),A=b.useCallback(async(R,I)=>{try{await e.unshareThread(R,I),await _()}catch(z){const J=String(z);throw n==null||n(J),z}},[e,n,_]),Y=b.useMemo(()=>({createThread:D,deleteThread:F,renameThread:G,refreshThreads:j,refreshSharedThreads:_,shareThread:K,unshareThread:A}),[D,F,G,j,_,K,A]),q=b.useCallback(R=>{if(!(R!=null&&R.threadId))return;const I={threadId:R.threadId,title:R.title||`Thread ${R.threadId.slice(0,8)}`,createdAt:R.createdAt||new Date().toISOString(),updatedAt:R.updatedAt||new Date().toISOString(),messageCount:R.messageCount??1};i(z=>{let J=!1;const P=z.map(O=>O.threadId===I.threadId?(J=!0,console.debug("[useThreadsState] thread_info: updating existing thread",I.threadId),{...O,title:I.title??O.title,updatedAt:I.updatedAt??O.updatedAt,messageCount:I.messageCount??O.messageCount}):O);return J?P:(console.debug("[useThreadsState] thread_info: adding thread to list",I.threadId),[I,...z])})},[]),W=b.useCallback(()=>S(null),[]);return{threads:s,currentThreadId:a,currentThreadIdRef:T,setCurrentThreadId:l,isLoadingThreads:c,threadsError:h,sharedThreads:f,isLoadingSharedThreads:g,actions:Y,addThreadFromEvent:q,shareInFlight:k,shareStatus:w,clearShareStatus:W}}const fu=b.createContext(null);function hu({children:e,initialThreadId:t=null,onError:n,onThreadChange:r}){const{api:o}=Xr(),{threads:s,currentThreadId:i,setCurrentThreadId:a,currentThreadIdRef:l,isLoadingThreads:c,threadsError:d,sharedThreads:h,isLoadingSharedThreads:m,actions:f,addThreadFromEvent:v,shareInFlight:g,shareStatus:x,clearShareStatus:y}=du({api:o,initialThreadId:t,onError:n,onThreadChange:r}),w=b.useMemo(()=>({threads:s,currentThreadId:i,setCurrentThreadId:a,currentThreadIdRef:l,isLoading:c,error:d,sharedThreads:h,isLoadingSharedThreads:m,actions:f,shareInFlight:g,shareStatus:x,clearShareStatus:y,addThreadFromEvent:v}),[s,i,a,l,c,d,h,m,f,g,x,y,v]);return u.jsx(fu.Provider,{value:w,children:e})}function xr(){const e=b.useContext(fu);if(!e)throw new Error("useThreads must be used within a ThreadsProvider");return e}function Ri(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 pu(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;if(e&&typeof e=="object"){if(Array.isArray(e)){const n=e.map(Zr).filter(r=>r!==void 0);if(!n.length){console.debug("[message-utils] sanitizeForDisplay - array emptied -> returning undefined",{originalLength:e.length});return}return n}if(pu(e)){try{console.debug("[message-utils] sanitizeForDisplay - dropping file-like object",{sampleFilename:e&&(e.filename||e.name)?e.filename||e.name:void 0,keys:Object.keys(e||{})})}catch(n){console.debug("[message-utils] sanitizeForDisplay - dropped file-like (unable to inspect)",{err:String(n)})}return}const t={};for(const n of Object.keys(e)){const r=e[n];if(n==="data"&&typeof r=="string"&&r.length>100)t[n]=`[base64 ${r.length} chars omitted]`;else{const o=Zr(r);o!==void 0&&(t[n]=o)}}if(Object.keys(t).length)return t;try{console.debug("[message-utils] sanitizeForDisplay - object emptied -> returning undefined",{originalKeys:Object.keys(e||{})})}catch(n){console.debug("[message-utils] sanitizeForDisplay - object emptied -> returning undefined (inspect failed)",{err:String(n)})}return}return e}function vr(e){if(typeof e=="string")return e;if(pu(e))return"";try{const t=Zr(e);return t===void 0?"":typeof t=="string"?t:JSON.stringify(t,null,2)}catch{return""}}function Jv(e){return typeof e!="string"?!1:/^[\s\n]*[-*]\s|^[\s\n]*#+\s|```|^\s*\[.*\]\(|^>\s/.test(e)}function Zv(e){const t=vr(e);return typeof e=="string"&&Jv(e)?{content:e,isMarkdown:!0}:{content:t,isMarkdown:!1}}function Qr(e){if(e==null)return e;if(typeof e=="string"){const t=e.trim();if(t.startsWith("{")||t.startsWith("[")){const n=Ri(t);if(n!==null)return Qr(n)}return e}return typeof e=="object"&&!Array.isArray(e)&&e.content!==void 0?Qr(e.content):e}function Qv(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function Oi(e){const t=e.content.find(s=>s.type==="tool_call"),n=e.additionalKwargs??{},r=typeof(t==null?void 0:t.id)=="string"&&t.id||typeof n.toolCallId=="string"&&n.toolCallId||(e.id.startsWith("tool-")?e.id.slice(5):void 0);return{name:(typeof(t==null?void 0:t.name)=="string"&&t.name||typeof n.toolName=="string"&&n.toolName||e.name&&String(e.name))??void 0,toolCallId:r??void 0}}function Yo(e){if(e==null)return null;const t=String(e).trim();return t.length>0?t:null}function eb(e){const t=r=>{try{const o=Zr(r);return typeof o=="string"?o:JSON.stringify(o??"")}catch{return""}},n=e.filter(r=>r.type==="text");return n.length?t(n.map(r=>r.text).join(`
|
|
39
|
+
`)):t(e)}function tb(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function mu(e){if(e.role==="default_message")return`default:${e.content.length}`;const t=e.updatedAt??e.createdAt??"",n=Array.isArray(e.content)?e.content.map(i=>{switch(i.type){case"text":return`t:${i.text.length}`;case"image_url":return"img";case"file":return"file";case"tool_call":return"call";case"interrupt":return"interrupt";default:return"unknown"}}).join("|"):"",r="checkpointId"in e&&e.checkpointId?`cp:${e.checkpointId}`:"",o="checkpointNs"in e&&e.checkpointNs?`ns:${e.checkpointNs}`:"",s=[r,o].filter(Boolean).join("|");return`${e.id}:${t}:${n}${s?`:${s}`:""}`}function nb(e){if(!e)return"image/png";const t=e.trim();return t?t.includes("/")?t:`image/${t}`:"image/png"}function rb(e){const t=[],n=r=>{r&&r.trim()&&t.push(r.trim())};return e&&(n(e.plotId),n(e.artifactId)),t}function ob({base64:e,url:t,formatHint:n,extras:r}){const o=typeof e=="string"&&e.length>0,s=nb(n),i=o?`data:${s};base64,${e}`:t,a=rb(r),l=a.length?a.join(" / "):void 0,c=l?`${l} artifact`:"artifact image";return{src:i,alt:c,label:l}}function sb(e){var o,s;const t=((o=e.content_base64)==null?void 0:o.trim())||void 0,n=((s=e.url)==null?void 0:s.trim())||void 0,r=e.format||e.mimeType||e.mime_type;return ob({base64:t,url:n,formatHint:r,extras:{plotId:e.plotId,artifactId:e.artifactId}})}function gu(e){var n;const t=(n=e.additionalKwargs)==null?void 0:n.toolProgress;return Array.isArray(t)?t:[]}const ib={messages:[],assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,messagesStreamMeta:{},pendingInterrupt:null};function ab(e,t){var n;switch(t.type){case"reset":return{messages:Mi(((n=t.payload)==null?void 0:n.messages)??[]),assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,pendingInterrupt:null,messagesStreamMeta:{}};case"user_message":{const{message:r,editingMessageId:o}=t.payload;if(o){const s=e.messages.findIndex(i=>i.id===o);if(s>=0){const i=e.messages.slice(0,s);return{...e,messages:[...i,r]}}}return{...e,messages:[...e.messages,r]}}case"seed":{const r=Mi(t.payload.messages),o={...e,messages:r,assemblingId:null,pendingInterrupt:t.payload.pendingInterrupt??null};return Object.prototype.hasOwnProperty.call(t.payload,"checkpointId")&&(o.lastCheckpointId=t.payload.checkpointId??null),Object.prototype.hasOwnProperty.call(t.payload,"checkpointNs")&&(o.lastCheckpointNs=t.payload.checkpointNs??null),o}case"prepend":{const r=Mi(t.payload.messages);if(!r.length)return e;const o=new Set(e.messages.map(a=>a.id)),s=r.filter(a=>!o.has(a.id));if(!s.length)return e;const i=[...s,...e.messages];return{...e,messages:i}}case"event":return xu(e,t.payload.ev);case"batch":{const{events:r}=t.payload;return r.length?r.reduce((o,s)=>xu(o,s),e):e}default:return e}}function lb(e=[]){const[t,n]=b.useReducer(ab,{...ib,messages:e}),r=b.useRef([]),o=b.useRef(null),s=b.useRef(null),i=b.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=b.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=b.useCallback(d=>{r.current.push(d),a()},[a]);b.useEffect(()=>()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),r.current=[]},[]);const c=b.useMemo(()=>({reset:d=>n({type:"reset",payload:{messages:d}}),seed:(d,h)=>n({type:"seed",payload:{messages:d,...h??{}}}),prepend:d=>n({type:"prepend",payload:{messages:d}}),pushUser:(d,h)=>n({type:"user_message",payload:{message:d,editingMessageId:h}}),onEvent:l}),[l]);return{state:t,dispatch:n,...c}}function xu(e,t){var n,r,o;if(t.type==="message.start"&&t.role==="assistant"){const s=t.id,i=uu(t.model);if(e.messages.some(c=>c.id===s)){const c=e.messagesStreamMeta??{},d={...c,[s]:c[s]??{lastSeq:t.seq??null,lastText:""}};return{...e,assemblingId:s,messagesStreamMeta:d}}const l={id:s,role:"assistant",name:i||void 0,model:t.model,createdAt:new Date().toISOString(),content:[]};return{...e,assemblingId:s,messages:[...e.messages,l]}}if(t.type==="tool.start")return ub(e,t);if(t.type==="tool.progress")return db(e,t);if(t.type==="tool.end")return fb(e,t);if(t.type==="message.delta"){const s=e.assemblingId??iu(e.messages);if(!s)return e;const i=e.messages,a=i.findIndex(C=>C.id===s&&C.role==="assistant");if(a===-1)return e;const l=i[a],c=e.messagesStreamMeta,d=c??{},h=d[s],m=h??{lastSeq:null,lastText:au(l.content)},f=t.seq??null;if(f!==null&&typeof f=="number"&&typeof m.lastSeq=="number"&&f<=m.lastSeq)return console.debug("[MessageReducer] skipping delta - seq <= lastSeq",{seq:f,lastSeq:m.lastSeq}),e;const{newParts:v,newMeta:g,changed:x}=lu(l.content,t.delta,m,f);if(!x)return e;const y={...l,content:v},w=Jr(i,a,y),S=!h||h.lastSeq!==g.lastSeq||h.lastText!==g.lastText,k=S?{...d,[s]:g}:c;return S?{...e,messages:w,messagesStreamMeta:k}:{...e,messages:w}}if(t.type==="message.end"){const s=e.assemblingId??iu(e.messages);if(!s)return{...e,assemblingId:null};const i=e.messages,a=i.findIndex(l=>l.id===s&&l.role==="assistant");if(a>=0){const l=i[a];if(!((n=l.content)==null?void 0:n.some(d=>{var h;return(d==null?void 0:d.type)==="text"&&((h=d.text)==null?void 0:h.trim())}))){console.debug("[MessageReducer] pruning assistant message with no visible text",{id:l.id,contentTypes:(r=l.content)==null?void 0:r.map(h=>h==null?void 0:h.type),contentPreview:(o=l.content)==null?void 0:o.map(h=>(h==null?void 0:h.type)==="text"?String(h.text).slice(0,100):h==null?void 0:h.type)});const d=[...i.slice(0,a),...i.slice(a+1)];return{...e,assemblingId:null,messages:d}}}return e}if(t.type==="checkpoint"){const s=t.checkpointNs??e.lastCheckpointNs??null,i=qv(e.messages,t.checkpointId,s);return{...e,lastCheckpointId:t.checkpointId,lastCheckpointNs:s,messages:i}}if(t.type==="error"){const s={id:`err-${Date.now()}`,role:"system",content:[{type:"text",text:`Error: ${t.message}`}],createdAt:new Date().toISOString()};return{...e,messages:[...e.messages,s]}}if(t.type==="state_history"){const s=Rn(t),i=s.interrupt,a=s.latest,l=i===null?Vv(e.messages):e.messages;return{...e,messages:l,pendingInterrupt:i,lastCheckpointId:(a==null?void 0:a.checkpointId)??e.lastCheckpointId,lastCheckpointNs:(a==null?void 0:a.checkpointNs)??e.lastCheckpointNs}}return t.type==="thread_info",e}function Di(e){return e.call_id??e.id??null}function vu(e){return e.id??e.call_id??`tool-${Date.now()}-${Math.random().toString(16).slice(2)}`}function bu(e,t,n,r){const o=t??`call-${Date.now()}-${Math.random().toString(16).slice(2)}`;return{id:e,role:"tool",name:n??void 0,content:[{type:"tool_call",id:o,name:n??"tool",args:r??{}}],createdAt:new Date().toISOString(),additionalKwargs:{toolCallId:o,toolName:n??void 0,toolStreaming:!0,toolProgress:[]}}}function Li(e,t){if(!t)return-1;for(let n=0;n<e.length;n+=1){const r=e[n];if(r.role!=="tool")continue;const o=r.additionalKwargs??{};if(typeof o.toolCallId=="string"&&o.toolCallId===t||Oi(r).toolCallId===t)return n}return-1}function cb(e){if(e==null)return[];const t=Qr(e);if(typeof t=="string"&&t.trim())return[{type:"text",text:t}];const n=vr(t??e);return n?[{type:"text",text:n}]:[]}function wu(e,t){const n=e.additionalKwargs??{},r=Array.isArray(n.toolProgress)?[...n.toolProgress]:[],o={...n,toolProgress:[...r,t]};return{...e,additionalKwargs:o}}function ub(e,t){const n=Di(t),r=Li(e.messages,n),o=t.name??t.tool??void 0,s=vu(t);if(r>=0){const a=e.messages[r],c={...a.additionalKwargs??{},toolStreaming:!0,toolProgress:[]},d={...a,name:o??a.name,additionalKwargs:c};return{...e,messages:Jr(e.messages,r,d)}}const i=bu(s,n,o,t.args);return{...e,messages:[...e.messages,i]}}function db(e,t){const n=Di(t);if(!n)return e;const r=Li(e.messages,n);if(r===-1)return e;const o={type:t.type,content:typeof t.content=="string"?t.content:void 0,seq:t.seq??null,timestamp:new Date().toISOString()},s=t.metadata;s&&(o.metadata=s);const i=t.idx;typeof i=="number"&&(o.idx=i);const a=wu(e.messages[r],o);return{...e,messages:Jr(e.messages,r,a)}}function fb(e,t){const n=Di(t),r=vu(t);let o=e.messages,s=Li(o,n);if(s===-1){const v=t.name??t.tool??void 0;o=[...o,bu(r,n,v,{})],s=o.length-1}const i=o[s],a=t.output??t.error??null,l=cb(a),c=[...i.content,...l],d={type:t.type,content:typeof t.output=="string"?t.output:void 0,seq:t.seq??null,timestamp:new Date().toISOString()};t.artifact&&(d.artifact=t.artifact);const h=wu(i,d),m=t.artifact??i.artifact,f={...h,name:t.name??t.tool??i.name,content:c,artifact:m,additionalKwargs:{...h.additionalKwargs??{},toolStreaming:!1}};return{...e,messages:Jr(o,s,f)}}function yu({api:e,seed:t,prepend:n,onError:r,currentThreadId:o,initialThreadId:s=null,initialCheckpointId:i=null,initialCheckpointNs:a=null,autoLoadInitial:l=!0,isStreaming:c,getMessages:d}){const[h,m]=b.useState(null),v=b.useMemo(()=>Rn(h),[h]).checkpoints,g=nc(v),x=g.timeline,[y,w]=b.useState(!1),[S,k]=b.useState(null),[C,T]=b.useState(!1),[E,j]=b.useState(!1),[_,D]=b.useState(!1),[F,G]=b.useState(null),K=b.useRef(o),A=b.useRef(null),Y=b.useRef(null),q=b.useRef(null),W=b.useRef(null),R=b.useRef(null),I=b.useRef(new Map);b.useEffect(()=>{K.current=o},[o]);const z=b.useCallback(async Q=>{var le,ie;if(!Q.threadId)return;const U=Q.threadId;(le=Q.onStart)==null||le.call(Q),Q.setLoading(!0);try{await Q.action(U)}catch(ge){if(K.current===U){const we=String(ge);(ie=Q.handleError)==null||ie.call(Q,we),r==null||r(we)}throw ge}finally{Q.setLoading(!1)}},[r]),J=b.useCallback(async(Q,U)=>{if(!Q)return;const le=`${Q}:${U??"latest"}`,ie=I.current.get(le);if(ie)return ie;const ge=z({threadId:Q,setLoading:T,onStart:()=>G(null),handleError:we=>G(we),action:async we=>{const Ce=await e.getStateHistory({threadId:we,checkpointId:U??void 0});if(K.current!==we){console.log(`[useThreadHistoryState] Thread changed during load (was ${we}, now ${K.current}), discarding stale data`);return}const{checkpoints:Ae}=Rn(Ce),Ee=Ae.find(st=>st.messages&&st.messages.length>0)??(U?Ae.find(st=>st.checkpointId===U):null)??Ae[0];t((Ee==null?void 0:Ee.messages)??[],{checkpointId:(Ee==null?void 0:Ee.checkpointId)??null,checkpointNs:(Ee==null?void 0:Ee.checkpointNs)??null}),m(Ce),w(!!(Ee!=null&&Ee.nextCursor)),k((Ee==null?void 0:Ee.nextCursor)??null)}});I.current.set(le,ge);try{await ge}finally{I.current.delete(le)}return K.current===Q&&(R.current=le),ge},[e,t,z]),P=b.useCallback(async(Q,U)=>{W.current=Q;try{await J(Q,U)}finally{W.current===Q&&(W.current=null)}},[J]),O=b.useCallback(Q=>{Y.current=Q},[]),M=b.useCallback(Q=>{q.current=Q},[]),L=b.useCallback(Q=>{const U=Q.threadId??K.current;if(!U||K.current&&K.current!==U)return;const{checkpoints:le}=Rn(Q);if(!le.length)return;const ie=le.find(we=>we.messages&&we.messages.length>0)??le.find(we=>!!we.checkpointId)??le[0],ge=q.current===U;!c&&!ge&&t((ie==null?void 0:ie.messages)??[],{checkpointId:(ie==null?void 0:ie.checkpointId)??null,checkpointNs:(ie==null?void 0:ie.checkpointNs)??null}),m(Q),w(!!(ie!=null&&ie.nextCursor)),k((ie==null?void 0:ie.nextCursor)??null),R.current=`${U}:latest`,Y.current=null,q.current===U&&(q.current=null)},[t,c]),ee=b.useCallback(async(Q,U)=>{const le=K.current;await z({threadId:le,setLoading:D,action:async ie=>{const ge=await e.getStateHistory({threadId:ie,checkpointId:Q,checkpointNs:U??void 0});if(K.current!==ie){console.log(`[useThreadHistoryState] Thread changed during checkpoint navigation (was ${ie}, now ${K.current}), discarding stale data`);return}const{checkpoints:we}=Rn(ge),Ce=we.find(Ae=>Ae.checkpointId===Q&&(U?Ae.checkpointNs===U:!0));if(!Ce){console.warn("[useThreadHistoryState] Requested checkpoint not found:",{checkpointId:Q,checkpointNs:U});return}m(ge),t(Ce.messages??[],{checkpointId:Ce.checkpointId??null,checkpointNs:Ce.checkpointNs??null})}}).catch(()=>{})},[e,t,z]),H=b.useCallback((Q,U)=>{t(d(),{checkpointId:Q??null,checkpointNs:U??null})},[d,t]),$=b.useCallback(async()=>{K.current&&await P(K.current)},[P]),Z=b.useCallback(async()=>{const Q=K.current;!Q||!S||await z({threadId:Q,setLoading:j,action:async U=>{const le=await e.getStateHistory({threadId:U,checkpointId:S});if(K.current!==U)return;const{checkpoints:ie}=Rn(le);if(ie.length>0){const ge=ie[ie.length-1];n((ge==null?void 0:ge.messages)??[]),w(!!(ge!=null&&ge.nextCursor)),k((ge==null?void 0:ge.nextCursor)??null)}}}).catch(()=>{})},[e,S,r,n,z]);b.useEffect(()=>{if(!l||!o||C||c)return;if(Y.current===o){Y.current=null,A.current=o;return}if(q.current===o){A.current=o;return}if(W.current===o){W.current=null,A.current=o;return}if(A.current===o)return;A.current=o;let Q;console.log("[useThreadHistoryState] Loading thread with latest checkpoint");const U=`${o}:latest`;R.current!==U&&P(o,Q)},[l,o,i,a,s,C,c,P]);const te=b.useCallback(()=>{m(null),w(!1),k(null),T(!1),j(!1),D(!1),G(null),Y.current=null,q.current=null,A.current=null,R.current=null,W.current=null},[]);return{threadCheckpoints:v,threadTimeline:x,checkpointIndex:g,isLoadingThread:C,isHistoryLoading:E,isLoadingCheckpoint:_,threadStateError:F,hasMoreHistory:y,loadThread:P,navigateToCheckpoint:ee,loadOlderMessages:Z,setCurrentCheckpointId:H,returnToLatest:$,handleStateHistoryEvent:L,markSkipNextLoad:O,markStreamPendingThread:M,resetHistoryState:te}}const Su=b.createContext(null),Cu=b.createContext(null);function eo(){const e=b.useContext(Su);if(!e)throw new Error("useThreadState must be used within a ThreadStateProvider");return e}function Tu(){const e=b.useContext(Cu);if(!e)throw new Error("useThreadStateUpdater must be used within a ThreadStateProvider");return e}function ku({children:e,initialThreadId:t=null,initialCheckpointId:n=null,initialCheckpointNs:r=null,autoLoadInitial:o=!0,isStreaming:s,onError:i}){const{api:a}=Xr(),{currentThreadId:l}=xr(),{state:c,seed:d,prepend:h,pushUser:m,onEvent:f}=lb(),{threadCheckpoints:v,threadTimeline:g,checkpointIndex:x,isLoadingThread:y,isHistoryLoading:w,isLoadingCheckpoint:S,threadStateError:k,hasMoreHistory:C,loadThread:T,navigateToCheckpoint:E,loadOlderMessages:j,setCurrentCheckpointId:_,returnToLatest:D,handleStateHistoryEvent:F,markSkipNextLoad:G,markStreamPendingThread:K,resetHistoryState:A}=yu({api:a,seed:d,prepend:h,onError:i,currentThreadId:l,initialThreadId:t,initialCheckpointId:n,initialCheckpointNs:r,autoLoadInitial:o,isStreaming:s,getMessages:b.useCallback(()=>c.messages,[c.messages])}),[Y,q]=b.useState(()=>async()=>{throw new Error("clearThread is not ready")}),[W,R]=b.useState(()=>async()=>{throw new Error("respondToInterrupt is not ready")});b.useEffect(()=>{l||(d([],{}),A())},[l,d,A]);const I=b.useCallback(M=>q(()=>M),[]),z=b.useCallback(M=>R(()=>M),[]),J=b.useMemo(()=>({assemblingMessageId:c.assemblingId??null}),[c.assemblingId]),P=b.useMemo(()=>({threadId:l,messages:c.messages,interrupt:c.pendingInterrupt,checkpoint:{id:c.lastCheckpointId??null,namespace:c.lastCheckpointNs??null},checkpoints:v,checkpointIndex:x,timelineCheckpoints:g,metadata:J,isLoading:y,isHistoryLoading:w,isLoadingCheckpoint:S,error:k,hasMore:C,loadOlder:j,clearState:Y,navigateToCheckpoint:E,setCurrentCheckpointId:_,returnToLatest:D,loadThread:T,clearThread:Y,respondToInterrupt:W,messagePreviews:x.messagePreviews,handleStateHistoryEvent:F,markSkipNextLoad:G,markStreamPendingThread:K,resetHistoryState:A,pushUser:m,onEvent:f}),[l,c,v,g,x,J,y,w,S,k,C,j,Y,E,_,D,T,W,x.messagePreviews,F,G,K,A,m,f]),O=b.useMemo(()=>({registerClearThread:I,registerRespondToInterrupt:z}),[I,z]);return u.jsx(Cu.Provider,{value:O,children:u.jsx(Su.Provider,{value:P,children:e})})}function Eu(e,t){if(!e)return null;const n=_n(e);if(!n)return null;const r=_n(n.configurable)??n;return Mn(r,t)??null}function hb(e){const t=Eu(e,["checkpoint_id","checkpointId"]);if(!t)return null;const n=Eu(e,["checkpoint_ns","checkpointNs"]);return{checkpointId:t,checkpointNs:n}}function pb(e,t){const n=typeof e.step=="number"?e.step:Number.POSITIVE_INFINITY,r=typeof t.step=="number"?t.step:Number.POSITIVE_INFINITY;if(n!==r)return n-r;const o=e.createdAt?Date.parse(e.createdAt):0,s=t.createdAt?Date.parse(t.createdAt):0;return o-s}function mb(e,t){const n=[...e].sort(pb);for(const r of n){if(r.messageId!==t)continue;const o=hb(r.parentConfig);if(!o)throw new Error(`Parent checkpoint info missing for message ${t}`);return o}throw new Error(`Message ${t} not found in timeline`)}const Iu=b.createContext(null),Nu=b.createContext(!1);function gb({children:e,initialThreadId:t=null,initialCheckpointId:n=null,initialCheckpointNs:r=null,autoLoadInitial:o=!0,onError:s,onAuthError:i,onThreadChange:a,onConnectionError:l,onToolEnd:c}){const{api:d,baseUrl:h}=Xr(),m=b.useMemo(()=>xn(h),[h]),{stream:f,stop:v,isStreaming:g,error:x,setToken:y}=Gv({baseUrl:m}),[w,S]=b.useState(!1);return b.useEffect(()=>{S(g)},[g]),u.jsx(hu,{initialThreadId:t,onError:s,onThreadChange:a,children:u.jsx(ku,{initialThreadId:t,initialCheckpointId:n,initialCheckpointNs:r,autoLoadInitial:o,onError:s,isStreaming:w,children:u.jsx(Nu.Provider,{value:!0,children:u.jsx(xb,{api:d,streamApi:{stream:f,stop:v,isStreaming:g,error:x,setToken:y},onError:s,onAuthError:i,onConnectionError:l,onToolEnd:c,children:e})})})})}function xb({children:e,api:t,streamApi:n,onError:r,onAuthError:o,onConnectionError:s,onToolEnd:i}){const{stream:a,stop:l,isStreaming:c,error:d,setToken:h}=n,{setCurrentThreadId:m,currentThreadIdRef:f,addThreadFromEvent:v}=xr(),{checkpoint:g,timelineCheckpoints:x,handleStateHistoryEvent:y,markSkipNextLoad:w,markStreamPendingThread:S,resetHistoryState:k,pushUser:C,onEvent:T}=eo(),{registerClearThread:E,registerRespondToInterrupt:j}=Tu(),_=b.useCallback(W=>{v(W),f.current!==W.threadId&&((W.created??!f.current)&&w(W.threadId),S(W.threadId),m(W.threadId))},[v,w,S,m,f]),D=b.useCallback(W=>{W.type==="thread_info"?_(W):W.type==="state_history"?y(W):W.type==="tool.end"?i==null||i(W):T(W)},[_,y,T,i]),F=b.useCallback(W=>{a(W,D,{onError:R=>{console.error("[StreamingProvider] Stream error:",R),r==null||r(R)},onAuthError:R=>{console.error("[StreamingProvider] Auth error:",R),o==null||o(R)},onConnectionError:R=>{console.error("[StreamingProvider] Connection error:",R),s==null||s(R)}})},[a,D,r,o,s]),G=b.useRef(g);b.useEffect(()=>{G.current=g},[g]);const K=b.useCallback(async(W,R,I)=>{const z=f.current;if(!z)throw new Error("No active thread to handle interrupt");const J=R?I??!0:!1,P=G.current,O={threadId:z,checkpointId:P.id??void 0,checkpointNs:P.namespace??void 0,command:{kind:"resume",value:J}};F(O)},[f,F]);b.useEffect(()=>{j(K)},[K,j]);const A=b.useCallback(async()=>{l(),k(),m(null);try{await t.getAgent("default")}catch(W){console.warn("[StreamingProvider] Failed to refetch agent after clearing thread:",W)}},[t,k,m,l]);b.useEffect(()=>{E(A)},[A,E]);const Y=b.useCallback(async(W,R)=>{let I=f.current;const z=(W==null?void 0:W.text)??"",J=(W==null?void 0:W.attachments)??[],P=(z==null?void 0:z.trim())??"",O={...(W==null?void 0:W.payload)??{}},M=Array.isArray(O.messages)?O.messages:void 0;M&&delete O.messages;const L=!!(M&&M.length);if(!I&&!P&&J.length===0&&!L)return;if(!I){const Ae=Math.floor(Date.now()/1e3).toString(16).padStart(8,"0"),Ee=Array.from({length:4},()=>Math.floor(Math.random()*4294967295).toString(16).padStart(8,"0")).join("").slice(0,16);I=`${Ae}${Ee}`,w(I),m(I)}const{contentParts:ee,filesInfo:H}=await ou(J),$=[...ee];P&&$.push({type:"text",text:z});const Z=R==null?void 0:R.originalMessageId,te=!!(R!=null&&R.edit&&Z),Q=!L&&$.length>0;let U=null;Q&&(U={id:te?Z:`msg-${Date.now()}`,role:"user",content:$,createdAt:new Date().toISOString()},te?C(U,Z):C(U));const le=L?M:U?[U]:[],ie={...O,...H.length?{files_info:H}:{}};le.length?ie.messages=le:"messages"in ie||(ie.messages=[]);let ge=(R==null?void 0:R.checkpointId)??g.id??void 0,we=(R==null?void 0:R.checkpointNs)??g.namespace??void 0;if(te&&Z){const Ae=mb(x,Z);ge=Ae.checkpointId,we=Ae.checkpointNs??void 0}const Ce={threadId:I,payload:ie,checkpointId:ge,checkpointNs:we,edit:!!(R!=null&&R.edit)};F(Ce)},[g,f,w,C,F,x]),q=b.useMemo(()=>({isStreaming:c,error:d,connectionState:c?"connected":"idle",submit:Y,send:Y,stop:l,setAuthToken:h}),[c,d,Y,l,h]);return u.jsx(Iu.Provider,{value:q,children:e})}function $i(){const e=b.useContext(Iu);if(!e)throw new Error("useStream must be used within StreamingProvider");return e}function vb(){return b.useContext(Nu)}function Au(e){return typeof e=="object"&&e!==null}function bb(e,t){if(Object.is(e,t))return!0;if(!Au(e)||!Au(t))return!1;const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const o of n)if(!Object.prototype.hasOwnProperty.call(t,o)||!Object.is(e[o],t[o]))return!1;return!0}function ju(e){const t=b.useRef(e),n=b.useRef(e);return bb(t.current,e)||(t.current=e,n.current=e),n.current}function br({children:e,apiConfig:t,initialThreadId:n=null,initialCheckpointId:r=null,initialCheckpointNs:o=null,autoLoadInitial:s=!0,onConnectionError:i,onError:a,onAuthError:l,onThreadChange:c,onToolEnd:d}){const h=ju(t),m=to(a),f=to(l),v=to(i),g=to(c),x=to(d),y=b.useMemo(()=>({initialThreadId:n,initialCheckpointId:r,initialCheckpointNs:o,autoLoadInitial:s,onError:m,onAuthError:f,onConnectionError:v,onThreadChange:g,onToolEnd:x}),[n,r,o,s,m,f,v,g,x]);return u.jsx(nu,{apiConfig:h,children:u.jsx(gb,{...y,children:e})})}function to(e){const t=b.useRef(e);return b.useEffect(()=>{t.current=e},[e]),b.useCallback((...n)=>{const r=t.current;if(r)return r(...n)},[])}function wr(e){if(!(typeof globalThis>"u"))return globalThis[e]}function wb(e){if(typeof e!="string")return;const t=e.trim();if(t)return xn(t)}function Pu(){const e=[wr("__API_BASE_URL__"),wr("__CHAT_API_BASE_URL__"),wr("__CHAT_API_URL__")];for(const t of e){const n=wb(t);if(n)return n}}function _u(){const e=[wr("__API_AUTH_TOKEN__"),wr("__CHAT_API_KEY__"),wr("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function Mu(...e){for(const t of e)if(typeof t=="string"&&t.trim())return xn(t);return xn()}function Ru(){const e={},t=Pu(),n=_u();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function Ou(){const e=Ru(),t=Nn.getAuthToken(),n=Pu();return{apiBaseUrl:Mu(e.baseUrl,Nn.baseUrl,n),apiKey:t||e.apiKey||_u()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,darkMode:!1,enableSound:!1,messageHistory:100}}const Fi="chat-settings";function Du(){try{const e=localStorage.getItem(Fi);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function Lu(e){try{const t={...e,apiBaseUrl:xn(e.apiBaseUrl)};localStorage.setItem(Fi,JSON.stringify(t)),t.apiKey&&Nn.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function yb(){const e=Ou(),t=Du(),n=Nn.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:Mu(Nn.baseUrl,r,e.apiBaseUrl)}}function Sb(e){Nn.updateConfig({baseUrl:e.apiBaseUrl,authToken:e.apiKey??void 0}),Lu(e)}function oe(...e){return sx.twMerge(ox.clsx(e))}const Cb=zr.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"}}),Xe=p.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?Kt.Slot:"button";return u.jsx(i,{className:oe(Cb({variant:t,size:n,className:e})),ref:s,...o})});Xe.displayName="Button";function ce(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 $u(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function On(...e){return t=>{let n=!1;const r=e.map(o=>{const s=$u(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():$u(e[o],null)}}}}function De(...e){return p.useCallback(On(...e),e)}function Tb(e,t){const n=p.createContext(t),r=s=>{const{children:i,...a}=s,l=p.useMemo(()=>a,Object.values(a));return u.jsx(n.Provider,{value:l,children:i})};r.displayName=e+"Provider";function o(s){const i=p.useContext(n);if(i)return i;if(t!==void 0)return t;throw new Error(`\`${s}\` must be used within \`${e}\``)}return[r,o]}function ln(e,t=[]){let n=[];function r(s,i){const a=p.createContext(i),l=n.length;n=[...n,i];const c=h=>{var y;const{scope:m,children:f,...v}=h,g=((y=m==null?void 0:m[e])==null?void 0:y[l])||a,x=p.useMemo(()=>v,Object.values(v));return u.jsx(g.Provider,{value:x,children:f})};c.displayName=s+"Provider";function d(h,m){var g;const f=((g=m==null?void 0:m[e])==null?void 0:g[l])||a,v=p.useContext(f);if(v)return v;if(i!==void 0)return i;throw new Error(`\`${h}\` must be used within \`${s}\``)}return[c,d]}const o=()=>{const s=n.map(i=>p.createContext(i));return function(a){const l=(a==null?void 0:a[e])||s;return p.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return o.scopeName=e,[r,kb(o,...t)]}function kb(...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:c})=>{const h=l(s)[`__scope${c}`];return{...a,...h}},{});return p.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var yt=globalThis!=null&&globalThis.document?p.useLayoutEffect:()=>{},Eb=p[" useInsertionEffect ".trim().toString()]||yt;function Dn({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=Ib({defaultProp:t,onChange:n}),a=e!==void 0,l=a?e:o;{const d=p.useRef(e!==void 0);p.useEffect(()=>{const h=d.current;h!==a&&console.warn(`${r} is changing from ${h?"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 c=p.useCallback(d=>{var h;if(a){const m=Nb(d)?d(e):d;m!==e&&((h=i.current)==null||h.call(i,m))}else s(d)},[a,e,s,i]);return[l,c]}function Ib({defaultProp:e,onChange:t}){const[n,r]=p.useState(e),o=p.useRef(n),s=p.useRef(t);return Eb(()=>{s.current=t},[t]),p.useEffect(()=>{var i;o.current!==n&&((i=s.current)==null||i.call(s,n),o.current=n)},[n,o]),[n,r,s]}function Nb(e){return typeof e=="function"}var Ab=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],xe=Ab.reduce((e,t)=>{const n=Kt.createSlot(`Primitive.${t}`),r=p.forwardRef((o,s)=>{const{asChild:i,...a}=o,l=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),u.jsx(l,{...a,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Bi(e,t){e&&Hr.flushSync(()=>e.dispatchEvent(t))}function Xo(e){const t=e+"CollectionProvider",[n,r]=ln(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=g=>{const{scope:x,children:y}=g,w=b.useRef(null),S=b.useRef(new Map).current;return u.jsx(o,{scope:x,itemMap:S,collectionRef:w,children:y})};i.displayName=t;const a=e+"CollectionSlot",l=Kt.createSlot(a),c=b.forwardRef((g,x)=>{const{scope:y,children:w}=g,S=s(a,y),k=De(x,S.collectionRef);return u.jsx(l,{ref:k,children:w})});c.displayName=a;const d=e+"CollectionItemSlot",h="data-radix-collection-item",m=Kt.createSlot(d),f=b.forwardRef((g,x)=>{const{scope:y,children:w,...S}=g,k=b.useRef(null),C=De(x,k),T=s(d,y);return b.useEffect(()=>(T.itemMap.set(k,{ref:k,...S}),()=>void T.itemMap.delete(k))),u.jsx(m,{[h]:"",ref:C,children:w})});f.displayName=d;function v(g){const x=s(e+"CollectionConsumer",g);return b.useCallback(()=>{const w=x.collectionRef.current;if(!w)return[];const S=Array.from(w.querySelectorAll(`[${h}]`));return Array.from(x.itemMap.values()).sort((T,E)=>S.indexOf(T.ref.current)-S.indexOf(E.ref.current))},[x.collectionRef,x.itemMap])}return[{Provider:i,Slot:c,ItemSlot:f},v,r]}var jb=p.createContext(void 0);function Jo(e){const t=p.useContext(jb);return e||t||"ltr"}function ft(e){const t=p.useRef(e);return p.useEffect(()=>{t.current=e}),p.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function Pb(e,t=globalThis==null?void 0:globalThis.document){const n=ft(e);p.useEffect(()=>{const r=o=>{o.key==="Escape"&&n(o)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var _b="DismissableLayer",zi="dismissableLayer.update",Mb="dismissableLayer.pointerDownOutside",Rb="dismissableLayer.focusOutside",Fu,Bu=p.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),yr=p.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...l}=e,c=p.useContext(Bu),[d,h]=p.useState(null),m=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,f]=p.useState({}),v=De(t,E=>h(E)),g=Array.from(c.layers),[x]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),y=g.indexOf(x),w=d?g.indexOf(d):-1,S=c.layersWithOutsidePointerEventsDisabled.size>0,k=w>=y,C=Db(E=>{const j=E.target,_=[...c.branches].some(D=>D.contains(j));!k||_||(o==null||o(E),i==null||i(E),E.defaultPrevented||a==null||a())},m),T=Lb(E=>{const j=E.target;[...c.branches].some(D=>D.contains(j))||(s==null||s(E),i==null||i(E),E.defaultPrevented||a==null||a())},m);return Pb(E=>{w===c.layers.size-1&&(r==null||r(E),!E.defaultPrevented&&a&&(E.preventDefault(),a()))},m),p.useEffect(()=>{if(d)return n&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(Fu=m.body.style.pointerEvents,m.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(d)),c.layers.add(d),Hu(),()=>{n&&c.layersWithOutsidePointerEventsDisabled.size===1&&(m.body.style.pointerEvents=Fu)}},[d,m,n,c]),p.useEffect(()=>()=>{d&&(c.layers.delete(d),c.layersWithOutsidePointerEventsDisabled.delete(d),Hu())},[d,c]),p.useEffect(()=>{const E=()=>f({});return document.addEventListener(zi,E),()=>document.removeEventListener(zi,E)},[]),u.jsx(xe.div,{...l,ref:v,style:{pointerEvents:S?k?"auto":"none":void 0,...e.style},onFocusCapture:ce(e.onFocusCapture,T.onFocusCapture),onBlurCapture:ce(e.onBlurCapture,T.onBlurCapture),onPointerDownCapture:ce(e.onPointerDownCapture,C.onPointerDownCapture)})});yr.displayName=_b;var Ob="DismissableLayerBranch",zu=p.forwardRef((e,t)=>{const n=p.useContext(Bu),r=p.useRef(null),o=De(t,r);return p.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),u.jsx(xe.div,{...e,ref:o})});zu.displayName=Ob;function Db(e,t=globalThis==null?void 0:globalThis.document){const n=ft(e),r=p.useRef(!1),o=p.useRef(()=>{});return p.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){Uu(Mb,n,c,{discrete:!0})};const c={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 Lb(e,t=globalThis==null?void 0:globalThis.document){const n=ft(e),r=p.useRef(!1);return p.useEffect(()=>{const o=s=>{s.target&&!r.current&&Uu(Rb,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 Hu(){const e=new CustomEvent(zi);document.dispatchEvent(e)}function Uu(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?Bi(o,s):o.dispatchEvent(s)}var $b=yr,Fb=zu,Hi=0;function Ui(){p.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Wu()),document.body.insertAdjacentElement("beforeend",e[1]??Wu()),Hi++,()=>{Hi===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Hi--}},[])}function Wu(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var Wi="focusScope.autoFocusOnMount",Vi="focusScope.autoFocusOnUnmount",Vu={bubbles:!1,cancelable:!0},Bb="FocusScope",Zo=p.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,l]=p.useState(null),c=ft(o),d=ft(s),h=p.useRef(null),m=De(t,g=>l(g)),f=p.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;p.useEffect(()=>{if(r){let g=function(S){if(f.paused||!a)return;const k=S.target;a.contains(k)?h.current=k:Ln(h.current,{select:!0})},x=function(S){if(f.paused||!a)return;const k=S.relatedTarget;k!==null&&(a.contains(k)||Ln(h.current,{select:!0}))},y=function(S){if(document.activeElement===document.body)for(const C of S)C.removedNodes.length>0&&Ln(a)};document.addEventListener("focusin",g),document.addEventListener("focusout",x);const w=new MutationObserver(y);return a&&w.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",g),document.removeEventListener("focusout",x),w.disconnect()}}},[r,a,f.paused]),p.useEffect(()=>{if(a){Gu.add(f);const g=document.activeElement;if(!a.contains(g)){const y=new CustomEvent(Wi,Vu);a.addEventListener(Wi,c),a.dispatchEvent(y),y.defaultPrevented||(zb(Kb(Ku(a)),{select:!0}),document.activeElement===g&&Ln(a))}return()=>{a.removeEventListener(Wi,c),setTimeout(()=>{const y=new CustomEvent(Vi,Vu);a.addEventListener(Vi,d),a.dispatchEvent(y),y.defaultPrevented||Ln(g??document.body,{select:!0}),a.removeEventListener(Vi,d),Gu.remove(f)},0)}}},[a,c,d,f]);const v=p.useCallback(g=>{if(!n&&!r||f.paused)return;const x=g.key==="Tab"&&!g.altKey&&!g.ctrlKey&&!g.metaKey,y=document.activeElement;if(x&&y){const w=g.currentTarget,[S,k]=Hb(w);S&&k?!g.shiftKey&&y===k?(g.preventDefault(),n&&Ln(S,{select:!0})):g.shiftKey&&y===S&&(g.preventDefault(),n&&Ln(k,{select:!0})):y===w&&g.preventDefault()}},[n,r,f.paused]);return u.jsx(xe.div,{tabIndex:-1,...i,ref:m,onKeyDown:v})});Zo.displayName=Bb;function zb(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Ln(r,{select:t}),document.activeElement!==n)return}function Hb(e){const t=Ku(e),n=qu(t,e),r=qu(t.reverse(),e);return[n,r]}function Ku(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 qu(e,t){for(const n of e)if(!Ub(n,{upTo:t}))return n}function Ub(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 Wb(e){return e instanceof HTMLInputElement&&"select"in e}function Ln(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Wb(e)&&t&&e.select()}}var Gu=Vb();function Vb(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=Yu(e,t),e.unshift(t)},remove(t){var n;e=Yu(e,t),(n=e[0])==null||n.resume()}}}function Yu(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Kb(e){return e.filter(t=>t.tagName!=="A")}var qb=p[" useId ".trim().toString()]||(()=>{}),Gb=0;function Nt(e){const[t,n]=p.useState(qb());return yt(()=>{n(r=>r??String(Gb++))},[e]),t?`radix-${t}`:""}const Yb=["top","right","bottom","left"],$n=Math.min,Yt=Math.max,Qo=Math.round,es=Math.floor,vn=e=>({x:e,y:e}),Xb={left:"right",right:"left",bottom:"top",top:"bottom"},Jb={start:"end",end:"start"};function Ki(e,t,n){return Yt(e,$n(t,n))}function An(e,t){return typeof e=="function"?e(t):e}function jn(e){return e.split("-")[0]}function Sr(e){return e.split("-")[1]}function qi(e){return e==="x"?"y":"x"}function Gi(e){return e==="y"?"height":"width"}const Zb=new Set(["top","bottom"]);function bn(e){return Zb.has(jn(e))?"y":"x"}function Yi(e){return qi(bn(e))}function Qb(e,t,n){n===void 0&&(n=!1);const r=Sr(e),o=Yi(e),s=Gi(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=ts(i)),[i,ts(i)]}function ew(e){const t=ts(e);return[Xi(e),t,Xi(t)]}function Xi(e){return e.replace(/start|end/g,t=>Jb[t])}const Xu=["left","right"],Ju=["right","left"],tw=["top","bottom"],nw=["bottom","top"];function rw(e,t,n){switch(e){case"top":case"bottom":return n?t?Ju:Xu:t?Xu:Ju;case"left":case"right":return t?tw:nw;default:return[]}}function ow(e,t,n,r){const o=Sr(e);let s=rw(jn(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(Xi)))),s}function ts(e){return e.replace(/left|right|bottom|top/g,t=>Xb[t])}function sw(e){return{top:0,right:0,bottom:0,left:0,...e}}function Zu(e){return typeof e!="number"?sw(e):{top:e,right:e,bottom:e,left:e}}function ns(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 Qu(e,t,n){let{reference:r,floating:o}=e;const s=bn(t),i=Yi(t),a=Gi(i),l=jn(t),c=s==="y",d=r.x+r.width/2-o.width/2,h=r.y+r.height/2-o.height/2,m=r[a]/2-o[a]/2;let f;switch(l){case"top":f={x:d,y:r.y-o.height};break;case"bottom":f={x:d,y:r.y+r.height};break;case"right":f={x:r.x+r.width,y:h};break;case"left":f={x:r.x-o.width,y:h};break;default:f={x:r.x,y:r.y}}switch(Sr(t)){case"start":f[i]-=m*(n&&c?-1:1);break;case"end":f[i]+=m*(n&&c?-1:1);break}return f}const iw=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 c=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:d,y:h}=Qu(c,r,l),m=r,f={},v=0;for(let g=0;g<a.length;g++){const{name:x,fn:y}=a[g],{x:w,y:S,data:k,reset:C}=await y({x:d,y:h,initialPlacement:r,placement:m,strategy:o,middlewareData:f,rects:c,platform:i,elements:{reference:e,floating:t}});d=w??d,h=S??h,f={...f,[x]:{...f[x],...k}},C&&v<=50&&(v++,typeof C=="object"&&(C.placement&&(m=C.placement),C.rects&&(c=C.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):C.rects),{x:d,y:h}=Qu(c,m,l)),g=-1)}return{x:d,y:h,placement:m,strategy:o,middlewareData:f}};async function no(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:i,elements:a,strategy:l}=e,{boundary:c="clippingAncestors",rootBoundary:d="viewport",elementContext:h="floating",altBoundary:m=!1,padding:f=0}=An(t,e),v=Zu(f),x=a[m?h==="floating"?"reference":"floating":h],y=ns(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(x)))==null||n?x:x.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:c,rootBoundary:d,strategy:l})),w=h==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,S=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),k=await(s.isElement==null?void 0:s.isElement(S))?await(s.getScale==null?void 0:s.getScale(S))||{x:1,y:1}:{x:1,y:1},C=ns(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:w,offsetParent:S,strategy:l}):w);return{top:(y.top-C.top+v.top)/k.y,bottom:(C.bottom-y.bottom+v.bottom)/k.y,left:(y.left-C.left+v.left)/k.x,right:(C.right-y.right+v.right)/k.x}}const aw=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:c,padding:d=0}=An(e,t)||{};if(c==null)return{};const h=Zu(d),m={x:n,y:r},f=Yi(o),v=Gi(f),g=await i.getDimensions(c),x=f==="y",y=x?"top":"left",w=x?"bottom":"right",S=x?"clientHeight":"clientWidth",k=s.reference[v]+s.reference[f]-m[f]-s.floating[v],C=m[f]-s.reference[f],T=await(i.getOffsetParent==null?void 0:i.getOffsetParent(c));let E=T?T[S]:0;(!E||!await(i.isElement==null?void 0:i.isElement(T)))&&(E=a.floating[S]||s.floating[v]);const j=k/2-C/2,_=E/2-g[v]/2-1,D=$n(h[y],_),F=$n(h[w],_),G=D,K=E-g[v]-F,A=E/2-g[v]/2+j,Y=Ki(G,A,K),q=!l.arrow&&Sr(o)!=null&&A!==Y&&s.reference[v]/2-(A<G?D:F)-g[v]/2<0,W=q?A<G?A-G:A-K:0;return{[f]:m[f]+W,data:{[f]:Y,centerOffset:A-Y-W,...q&&{alignmentOffset:W}},reset:q}}}),lw=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:c}=t,{mainAxis:d=!0,crossAxis:h=!0,fallbackPlacements:m,fallbackStrategy:f="bestFit",fallbackAxisSideDirection:v="none",flipAlignment:g=!0,...x}=An(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const y=jn(o),w=bn(a),S=jn(a)===a,k=await(l.isRTL==null?void 0:l.isRTL(c.floating)),C=m||(S||!g?[ts(a)]:ew(a)),T=v!=="none";!m&&T&&C.push(...ow(a,g,v,k));const E=[a,...C],j=await no(t,x),_=[];let D=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&_.push(j[y]),h){const A=Qb(o,i,k);_.push(j[A[0]],j[A[1]])}if(D=[...D,{placement:o,overflows:_}],!_.every(A=>A<=0)){var F,G;const A=(((F=s.flip)==null?void 0:F.index)||0)+1,Y=E[A];if(Y&&(!(h==="alignment"?w!==bn(Y):!1)||D.every(R=>bn(R.placement)===w?R.overflows[0]>0:!0)))return{data:{index:A,overflows:D},reset:{placement:Y}};let q=(G=D.filter(W=>W.overflows[0]<=0).sort((W,R)=>W.overflows[1]-R.overflows[1])[0])==null?void 0:G.placement;if(!q)switch(f){case"bestFit":{var K;const W=(K=D.filter(R=>{if(T){const I=bn(R.placement);return I===w||I==="y"}return!0}).map(R=>[R.placement,R.overflows.filter(I=>I>0).reduce((I,z)=>I+z,0)]).sort((R,I)=>R[1]-I[1])[0])==null?void 0:K[0];W&&(q=W);break}case"initialPlacement":q=a;break}if(o!==q)return{reset:{placement:q}}}return{}}}};function ed(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function td(e){return Yb.some(t=>e[t]>=0)}const cw=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=An(e,t);switch(r){case"referenceHidden":{const s=await no(t,{...o,elementContext:"reference"}),i=ed(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:td(i)}}}case"escaped":{const s=await no(t,{...o,altBoundary:!0}),i=ed(s,n.floating);return{data:{escapedOffsets:i,escaped:td(i)}}}default:return{}}}}},nd=new Set(["left","top"]);async function uw(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=jn(n),a=Sr(n),l=bn(n)==="y",c=nd.has(i)?-1:1,d=s&&l?-1:1,h=An(t,e);let{mainAxis:m,crossAxis:f,alignmentAxis:v}=typeof h=="number"?{mainAxis:h,crossAxis:0,alignmentAxis:null}:{mainAxis:h.mainAxis||0,crossAxis:h.crossAxis||0,alignmentAxis:h.alignmentAxis};return a&&typeof v=="number"&&(f=a==="end"?v*-1:v),l?{x:f*d,y:m*c}:{x:m*c,y:f*d}}const dw=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 uw(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}}}}},fw=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:x=>{let{x:y,y:w}=x;return{x:y,y:w}}},...l}=An(e,t),c={x:n,y:r},d=await no(t,l),h=bn(jn(o)),m=qi(h);let f=c[m],v=c[h];if(s){const x=m==="y"?"top":"left",y=m==="y"?"bottom":"right",w=f+d[x],S=f-d[y];f=Ki(w,f,S)}if(i){const x=h==="y"?"top":"left",y=h==="y"?"bottom":"right",w=v+d[x],S=v-d[y];v=Ki(w,v,S)}const g=a.fn({...t,[m]:f,[h]:v});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[m]:s,[h]:i}}}}}},hw=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:c=!0}=An(e,t),d={x:n,y:r},h=bn(o),m=qi(h);let f=d[m],v=d[h];const g=An(a,t),x=typeof g=="number"?{mainAxis:g,crossAxis:0}:{mainAxis:0,crossAxis:0,...g};if(l){const S=m==="y"?"height":"width",k=s.reference[m]-s.floating[S]+x.mainAxis,C=s.reference[m]+s.reference[S]-x.mainAxis;f<k?f=k:f>C&&(f=C)}if(c){var y,w;const S=m==="y"?"width":"height",k=nd.has(jn(o)),C=s.reference[h]-s.floating[S]+(k&&((y=i.offset)==null?void 0:y[h])||0)+(k?0:x.crossAxis),T=s.reference[h]+s.reference[S]+(k?0:((w=i.offset)==null?void 0:w[h])||0)-(k?x.crossAxis:0);v<C?v=C:v>T&&(v=T)}return{[m]:f,[h]:v}}}},pw=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=()=>{},...c}=An(e,t),d=await no(t,c),h=jn(o),m=Sr(o),f=bn(o)==="y",{width:v,height:g}=s.floating;let x,y;h==="top"||h==="bottom"?(x=h,y=m===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(y=h,x=m==="end"?"top":"bottom");const w=g-d.top-d.bottom,S=v-d.left-d.right,k=$n(g-d[x],w),C=$n(v-d[y],S),T=!t.middlewareData.shift;let E=k,j=C;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(j=S),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(E=w),T&&!m){const D=Yt(d.left,0),F=Yt(d.right,0),G=Yt(d.top,0),K=Yt(d.bottom,0);f?j=v-2*(D!==0||F!==0?D+F:Yt(d.left,d.right)):E=g-2*(G!==0||K!==0?G+K:Yt(d.top,d.bottom))}await l({...t,availableWidth:j,availableHeight:E});const _=await i.getDimensions(a.floating);return v!==_.width||g!==_.height?{reset:{rects:!0}}:{}}}};function rs(){return typeof window<"u"}function Cr(e){return rd(e)?(e.nodeName||"").toLowerCase():"#document"}function Xt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function wn(e){var t;return(t=(rd(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function rd(e){return rs()?e instanceof Node||e instanceof Xt(e).Node:!1}function cn(e){return rs()?e instanceof Element||e instanceof Xt(e).Element:!1}function yn(e){return rs()?e instanceof HTMLElement||e instanceof Xt(e).HTMLElement:!1}function od(e){return!rs()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Xt(e).ShadowRoot}const mw=new Set(["inline","contents"]);function ro(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=un(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!mw.has(o)}const gw=new Set(["table","td","th"]);function xw(e){return gw.has(Cr(e))}const vw=[":popover-open",":modal"];function os(e){return vw.some(t=>{try{return e.matches(t)}catch{return!1}})}const bw=["transform","translate","scale","rotate","perspective"],ww=["transform","translate","scale","rotate","perspective","filter"],yw=["paint","layout","strict","content"];function Ji(e){const t=Zi(),n=cn(e)?un(e):e;return bw.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)||ww.some(r=>(n.willChange||"").includes(r))||yw.some(r=>(n.contain||"").includes(r))}function Sw(e){let t=Fn(e);for(;yn(t)&&!Tr(t);){if(Ji(t))return t;if(os(t))return null;t=Fn(t)}return null}function Zi(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Cw=new Set(["html","body","#document"]);function Tr(e){return Cw.has(Cr(e))}function un(e){return Xt(e).getComputedStyle(e)}function ss(e){return cn(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Fn(e){if(Cr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||od(e)&&e.host||wn(e);return od(t)?t.host:t}function sd(e){const t=Fn(e);return Tr(t)?e.ownerDocument?e.ownerDocument.body:e.body:yn(t)&&ro(t)?t:sd(t)}function oo(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=sd(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Xt(o);if(s){const a=Qi(i);return t.concat(i,i.visualViewport||[],ro(o)?o:[],a&&n?oo(a):[])}return t.concat(o,oo(o,[],n))}function Qi(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function id(e){const t=un(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=yn(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=Qo(n)!==s||Qo(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function ea(e){return cn(e)?e:e.contextElement}function kr(e){const t=ea(e);if(!yn(t))return vn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=id(t);let i=(s?Qo(n.width):n.width)/r,a=(s?Qo(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const Tw=vn(0);function ad(e){const t=Xt(e);return!Zi()||!t.visualViewport?Tw:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function kw(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Xt(e)?!1:t}function er(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=ea(e);let i=vn(1);t&&(r?cn(r)&&(i=kr(r)):i=kr(e));const a=kw(s,n,r)?ad(s):vn(0);let l=(o.left+a.x)/i.x,c=(o.top+a.y)/i.y,d=o.width/i.x,h=o.height/i.y;if(s){const m=Xt(s),f=r&&cn(r)?Xt(r):r;let v=m,g=Qi(v);for(;g&&r&&f!==v;){const x=kr(g),y=g.getBoundingClientRect(),w=un(g),S=y.left+(g.clientLeft+parseFloat(w.paddingLeft))*x.x,k=y.top+(g.clientTop+parseFloat(w.paddingTop))*x.y;l*=x.x,c*=x.y,d*=x.x,h*=x.y,l+=S,c+=k,v=Xt(g),g=Qi(v)}}return ns({width:d,height:h,x:l,y:c})}function is(e,t){const n=ss(e).scrollLeft;return t?t.left+n:er(wn(e)).left+n}function ld(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-is(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function Ew(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=wn(r),a=t?os(t.floating):!1;if(r===i||a&&s)return n;let l={scrollLeft:0,scrollTop:0},c=vn(1);const d=vn(0),h=yn(r);if((h||!h&&!s)&&((Cr(r)!=="body"||ro(i))&&(l=ss(r)),yn(r))){const f=er(r);c=kr(r),d.x=f.x+r.clientLeft,d.y=f.y+r.clientTop}const m=i&&!h&&!s?ld(i,l):vn(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+d.x+m.x,y:n.y*c.y-l.scrollTop*c.y+d.y+m.y}}function Iw(e){return Array.from(e.getClientRects())}function Nw(e){const t=wn(e),n=ss(e),r=e.ownerDocument.body,o=Yt(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Yt(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+is(e);const a=-n.scrollTop;return un(r).direction==="rtl"&&(i+=Yt(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const cd=25;function Aw(e,t){const n=Xt(e),r=wn(e),o=n.visualViewport;let s=r.clientWidth,i=r.clientHeight,a=0,l=0;if(o){s=o.width,i=o.height;const d=Zi();(!d||d&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}const c=is(r);if(c<=0){const d=r.ownerDocument,h=d.body,m=getComputedStyle(h),f=d.compatMode==="CSS1Compat"&&parseFloat(m.marginLeft)+parseFloat(m.marginRight)||0,v=Math.abs(r.clientWidth-h.clientWidth-f);v<=cd&&(s-=v)}else c<=cd&&(s+=c);return{width:s,height:i,x:a,y:l}}const jw=new Set(["absolute","fixed"]);function Pw(e,t){const n=er(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=yn(e)?kr(e):vn(1),i=e.clientWidth*s.x,a=e.clientHeight*s.y,l=o*s.x,c=r*s.y;return{width:i,height:a,x:l,y:c}}function ud(e,t,n){let r;if(t==="viewport")r=Aw(e,n);else if(t==="document")r=Nw(wn(e));else if(cn(t))r=Pw(t,n);else{const o=ad(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return ns(r)}function dd(e,t){const n=Fn(e);return n===t||!cn(n)||Tr(n)?!1:un(n).position==="fixed"||dd(n,t)}function _w(e,t){const n=t.get(e);if(n)return n;let r=oo(e,[],!1).filter(a=>cn(a)&&Cr(a)!=="body"),o=null;const s=un(e).position==="fixed";let i=s?Fn(e):e;for(;cn(i)&&!Tr(i);){const a=un(i),l=Ji(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&jw.has(o.position)||ro(i)&&!l&&dd(e,i))?r=r.filter(d=>d!==i):o=a,i=Fn(i)}return t.set(e,r),r}function Mw(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?os(t)?[]:_w(t,this._c):[].concat(n),r],a=i[0],l=i.reduce((c,d)=>{const h=ud(t,d,o);return c.top=Yt(h.top,c.top),c.right=$n(h.right,c.right),c.bottom=$n(h.bottom,c.bottom),c.left=Yt(h.left,c.left),c},ud(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function Rw(e){const{width:t,height:n}=id(e);return{width:t,height:n}}function Ow(e,t,n){const r=yn(t),o=wn(t),s=n==="fixed",i=er(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=vn(0);function c(){l.x=is(o)}if(r||!r&&!s)if((Cr(t)!=="body"||ro(o))&&(a=ss(t)),r){const f=er(t,!0,s,t);l.x=f.x+t.clientLeft,l.y=f.y+t.clientTop}else o&&c();s&&!r&&o&&c();const d=o&&!r&&!s?ld(o,a):vn(0),h=i.left+a.scrollLeft-l.x-d.x,m=i.top+a.scrollTop-l.y-d.y;return{x:h,y:m,width:i.width,height:i.height}}function ta(e){return un(e).position==="static"}function fd(e,t){if(!yn(e)||un(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return wn(e)===n&&(n=n.ownerDocument.body),n}function hd(e,t){const n=Xt(e);if(os(e))return n;if(!yn(e)){let o=Fn(e);for(;o&&!Tr(o);){if(cn(o)&&!ta(o))return o;o=Fn(o)}return n}let r=fd(e,t);for(;r&&xw(r)&&ta(r);)r=fd(r,t);return r&&Tr(r)&&ta(r)&&!Ji(r)?n:r||Sw(e)||n}const Dw=async function(e){const t=this.getOffsetParent||hd,n=this.getDimensions,r=await n(e.floating);return{reference:Ow(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Lw(e){return un(e).direction==="rtl"}const $w={convertOffsetParentRelativeRectToViewportRelativeRect:Ew,getDocumentElement:wn,getClippingRect:Mw,getOffsetParent:hd,getElementRects:Dw,getClientRects:Iw,getDimensions:Rw,getScale:kr,isElement:cn,isRTL:Lw};function pd(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Fw(e,t){let n=null,r;const o=wn(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 c=e.getBoundingClientRect(),{left:d,top:h,width:m,height:f}=c;if(a||t(),!m||!f)return;const v=es(h),g=es(o.clientWidth-(d+m)),x=es(o.clientHeight-(h+f)),y=es(d),S={rootMargin:-v+"px "+-g+"px "+-x+"px "+-y+"px",threshold:Yt(0,$n(1,l))||1};let k=!0;function C(T){const E=T[0].intersectionRatio;if(E!==l){if(!k)return i();E?i(!1,E):r=setTimeout(()=>{i(!1,1e-7)},1e3)}E===1&&!pd(c,e.getBoundingClientRect())&&i(),k=!1}try{n=new IntersectionObserver(C,{...S,root:o.ownerDocument})}catch{n=new IntersectionObserver(C,S)}n.observe(e)}return i(!0),s}function Bw(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,c=ea(e),d=o||s?[...c?oo(c):[],...oo(t)]:[];d.forEach(y=>{o&&y.addEventListener("scroll",n,{passive:!0}),s&&y.addEventListener("resize",n)});const h=c&&a?Fw(c,n):null;let m=-1,f=null;i&&(f=new ResizeObserver(y=>{let[w]=y;w&&w.target===c&&f&&(f.unobserve(t),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var S;(S=f)==null||S.observe(t)})),n()}),c&&!l&&f.observe(c),f.observe(t));let v,g=l?er(e):null;l&&x();function x(){const y=er(e);g&&!pd(g,y)&&n(),g=y,v=requestAnimationFrame(x)}return n(),()=>{var y;d.forEach(w=>{o&&w.removeEventListener("scroll",n),s&&w.removeEventListener("resize",n)}),h==null||h(),(y=f)==null||y.disconnect(),f=null,l&&cancelAnimationFrame(v)}}const zw=dw,Hw=fw,Uw=lw,Ww=pw,Vw=cw,md=aw,Kw=hw,qw=(e,t,n)=>{const r=new Map,o={platform:$w,...n},s={...o.platform,_c:r};return iw(e,t,{...o,platform:s})};var Gw=typeof document<"u",Yw=function(){},as=Gw?b.useLayoutEffect:Yw;function ls(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(!ls(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)&&!ls(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function gd(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function xd(e,t){const n=gd(e);return Math.round(t*n)/n}function na(e){const t=p.useRef(e);return as(()=>{t.current=e}),t}function Xw(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:c}=e,[d,h]=p.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[m,f]=p.useState(r);ls(m,r)||f(r);const[v,g]=p.useState(null),[x,y]=p.useState(null),w=p.useCallback(R=>{R!==T.current&&(T.current=R,g(R))},[]),S=p.useCallback(R=>{R!==E.current&&(E.current=R,y(R))},[]),k=s||v,C=i||x,T=p.useRef(null),E=p.useRef(null),j=p.useRef(d),_=l!=null,D=na(l),F=na(o),G=na(c),K=p.useCallback(()=>{if(!T.current||!E.current)return;const R={placement:t,strategy:n,middleware:m};F.current&&(R.platform=F.current),qw(T.current,E.current,R).then(I=>{const z={...I,isPositioned:G.current!==!1};A.current&&!ls(j.current,z)&&(j.current=z,Hr.flushSync(()=>{h(z)}))})},[m,t,n,F,G]);as(()=>{c===!1&&j.current.isPositioned&&(j.current.isPositioned=!1,h(R=>({...R,isPositioned:!1})))},[c]);const A=p.useRef(!1);as(()=>(A.current=!0,()=>{A.current=!1}),[]),as(()=>{if(k&&(T.current=k),C&&(E.current=C),k&&C){if(D.current)return D.current(k,C,K);K()}},[k,C,K,D,_]);const Y=p.useMemo(()=>({reference:T,floating:E,setReference:w,setFloating:S}),[w,S]),q=p.useMemo(()=>({reference:k,floating:C}),[k,C]),W=p.useMemo(()=>{const R={position:n,left:0,top:0};if(!q.floating)return R;const I=xd(q.floating,d.x),z=xd(q.floating,d.y);return a?{...R,transform:"translate("+I+"px, "+z+"px)",...gd(q.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:I,top:z}},[n,a,q.floating,d.x,d.y]);return p.useMemo(()=>({...d,update:K,refs:Y,elements:q,floatingStyles:W}),[d,K,Y,q,W])}const Jw=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?md({element:r.current,padding:o}).fn(n):{}:r?md({element:r,padding:o}).fn(n):{}}}},Zw=(e,t)=>({...zw(e),options:[e,t]}),Qw=(e,t)=>({...Hw(e),options:[e,t]}),ey=(e,t)=>({...Kw(e),options:[e,t]}),ty=(e,t)=>({...Uw(e),options:[e,t]}),ny=(e,t)=>({...Ww(e),options:[e,t]}),ry=(e,t)=>({...Vw(e),options:[e,t]}),oy=(e,t)=>({...Jw(e),options:[e,t]});var sy="Arrow",vd=p.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return u.jsx(xe.svg,{...s,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:u.jsx("polygon",{points:"0,0 30,0 15,10"})})});vd.displayName=sy;var iy=vd;function bd(e){const[t,n]=p.useState(void 0);return yt(()=>{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,c=Array.isArray(l)?l[0]:l;i=c.inlineSize,a=c.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 ra="Popper",[wd,Er]=ln(ra),[ay,yd]=wd(ra),Sd=e=>{const{__scopePopper:t,children:n}=e,[r,o]=p.useState(null);return u.jsx(ay,{scope:t,anchor:r,onAnchorChange:o,children:n})};Sd.displayName=ra;var Cd="PopperAnchor",Td=p.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=yd(Cd,n),i=p.useRef(null),a=De(t,i),l=p.useRef(null);return p.useEffect(()=>{const c=l.current;l.current=(r==null?void 0:r.current)||i.current,c!==l.current&&s.onAnchorChange(l.current)}),r?null:u.jsx(xe.div,{...o,ref:a})});Td.displayName=Cd;var oa="PopperContent",[ly,cy]=wd(oa),kd=p.forwardRef((e,t)=>{var H,$,Z,te,Q,U;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:a=0,avoidCollisions:l=!0,collisionBoundary:c=[],collisionPadding:d=0,sticky:h="partial",hideWhenDetached:m=!1,updatePositionStrategy:f="optimized",onPlaced:v,...g}=e,x=yd(oa,n),[y,w]=p.useState(null),S=De(t,le=>w(le)),[k,C]=p.useState(null),T=bd(k),E=(T==null?void 0:T.width)??0,j=(T==null?void 0:T.height)??0,_=r+(s!=="center"?"-"+s:""),D=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},F=Array.isArray(c)?c:[c],G=F.length>0,K={padding:D,boundary:F.filter(dy),altBoundary:G},{refs:A,floatingStyles:Y,placement:q,isPositioned:W,middlewareData:R}=Xw({strategy:"fixed",placement:_,whileElementsMounted:(...le)=>Bw(...le,{animationFrame:f==="always"}),elements:{reference:x.anchor},middleware:[Zw({mainAxis:o+j,alignmentAxis:i}),l&&Qw({mainAxis:!0,crossAxis:!1,limiter:h==="partial"?ey():void 0,...K}),l&&ty({...K}),ny({...K,apply:({elements:le,rects:ie,availableWidth:ge,availableHeight:we})=>{const{width:Ce,height:Ae}=ie.reference,Ee=le.floating.style;Ee.setProperty("--radix-popper-available-width",`${ge}px`),Ee.setProperty("--radix-popper-available-height",`${we}px`),Ee.setProperty("--radix-popper-anchor-width",`${Ce}px`),Ee.setProperty("--radix-popper-anchor-height",`${Ae}px`)}}),k&&oy({element:k,padding:a}),fy({arrowWidth:E,arrowHeight:j}),m&&ry({strategy:"referenceHidden",...K})]}),[I,z]=Nd(q),J=ft(v);yt(()=>{W&&(J==null||J())},[W,J]);const P=(H=R.arrow)==null?void 0:H.x,O=($=R.arrow)==null?void 0:$.y,M=((Z=R.arrow)==null?void 0:Z.centerOffset)!==0,[L,ee]=p.useState();return yt(()=>{y&&ee(window.getComputedStyle(y).zIndex)},[y]),u.jsx("div",{ref:A.setFloating,"data-radix-popper-content-wrapper":"",style:{...Y,transform:W?Y.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:L,"--radix-popper-transform-origin":[(te=R.transformOrigin)==null?void 0:te.x,(Q=R.transformOrigin)==null?void 0:Q.y].join(" "),...((U=R.hide)==null?void 0:U.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:u.jsx(ly,{scope:n,placedSide:I,onArrowChange:C,arrowX:P,arrowY:O,shouldHideArrow:M,children:u.jsx(xe.div,{"data-side":I,"data-align":z,...g,ref:S,style:{...g.style,animation:W?void 0:"none"}})})})});kd.displayName=oa;var Ed="PopperArrow",uy={top:"bottom",right:"left",bottom:"top",left:"right"},Id=p.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=cy(Ed,r),i=uy[s.placedSide];return u.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:u.jsx(iy,{...o,ref:n,style:{...o.style,display:"block"}})})});Id.displayName=Ed;function dy(e){return e!==null}var fy=e=>({name:"transformOrigin",options:e,fn(t){var x,y,w;const{placement:n,rects:r,middlewareData:o}=t,i=((x=o.arrow)==null?void 0:x.centerOffset)!==0,a=i?0:e.arrowWidth,l=i?0:e.arrowHeight,[c,d]=Nd(n),h={start:"0%",center:"50%",end:"100%"}[d],m=(((y=o.arrow)==null?void 0:y.x)??0)+a/2,f=(((w=o.arrow)==null?void 0:w.y)??0)+l/2;let v="",g="";return c==="bottom"?(v=i?h:`${m}px`,g=`${-l}px`):c==="top"?(v=i?h:`${m}px`,g=`${r.floating.height+l}px`):c==="right"?(v=`${-l}px`,g=i?h:`${f}px`):c==="left"&&(v=`${r.floating.width+l}px`,g=i?h:`${f}px`),{data:{x:v,y:g}}}});function Nd(e){const[t,n="center"]=e.split("-");return[t,n]}var sa=Sd,ia=Td,aa=kd,la=Id,hy="Portal",so=p.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=p.useState(!1);yt(()=>s(!0),[]);const i=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?Mo.createPortal(u.jsx(xe.div,{...r,ref:t}),i):null});so.displayName=hy;function py(e,t){return p.useReducer((n,r)=>t[n][r]??n,e)}var zt=e=>{const{present:t,children:n}=e,r=my(t),o=typeof n=="function"?n({present:r.isPresent}):p.Children.only(n),s=De(r.ref,gy(o));return typeof n=="function"||r.isPresent?p.cloneElement(o,{ref:s}):null};zt.displayName="Presence";function my(e){const[t,n]=p.useState(),r=p.useRef(null),o=p.useRef(e),s=p.useRef("none"),i=e?"mounted":"unmounted",[a,l]=py(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return p.useEffect(()=>{const c=cs(r.current);s.current=a==="mounted"?c:"none"},[a]),yt(()=>{const c=r.current,d=o.current;if(d!==e){const m=s.current,f=cs(c);e?l("MOUNT"):f==="none"||(c==null?void 0:c.display)==="none"?l("UNMOUNT"):l(d&&m!==f?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,l]),yt(()=>{if(t){let c;const d=t.ownerDocument.defaultView??window,h=f=>{const g=cs(r.current).includes(CSS.escape(f.animationName));if(f.target===t&&g&&(l("ANIMATION_END"),!o.current)){const x=t.style.animationFillMode;t.style.animationFillMode="forwards",c=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=x)})}},m=f=>{f.target===t&&(s.current=cs(r.current))};return t.addEventListener("animationstart",m),t.addEventListener("animationcancel",h),t.addEventListener("animationend",h),()=>{d.clearTimeout(c),t.removeEventListener("animationstart",m),t.removeEventListener("animationcancel",h),t.removeEventListener("animationend",h)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:p.useCallback(c=>{r.current=c?getComputedStyle(c):null,n(c)},[])}}function cs(e){return(e==null?void 0:e.animationName)||"none"}function gy(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 ca="rovingFocusGroup.onEntryFocus",xy={bubbles:!1,cancelable:!0},io="RovingFocusGroup",[ua,Ad,vy]=Xo(io),[by,jd]=ln(io,[vy]),[wy,yy]=by(io),Pd=p.forwardRef((e,t)=>u.jsx(ua.Provider,{scope:e.__scopeRovingFocusGroup,children:u.jsx(ua.Slot,{scope:e.__scopeRovingFocusGroup,children:u.jsx(Sy,{...e,ref:t})})}));Pd.displayName=io;var Sy=p.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:c,preventScrollOnEntryFocus:d=!1,...h}=e,m=p.useRef(null),f=De(t,m),v=Jo(s),[g,x]=Dn({prop:i,defaultProp:a??null,onChange:l,caller:io}),[y,w]=p.useState(!1),S=ft(c),k=Ad(n),C=p.useRef(!1),[T,E]=p.useState(0);return p.useEffect(()=>{const j=m.current;if(j)return j.addEventListener(ca,S),()=>j.removeEventListener(ca,S)},[S]),u.jsx(wy,{scope:n,orientation:r,dir:v,loop:o,currentTabStopId:g,onItemFocus:p.useCallback(j=>x(j),[x]),onItemShiftTab:p.useCallback(()=>w(!0),[]),onFocusableItemAdd:p.useCallback(()=>E(j=>j+1),[]),onFocusableItemRemove:p.useCallback(()=>E(j=>j-1),[]),children:u.jsx(xe.div,{tabIndex:y||T===0?-1:0,"data-orientation":r,...h,ref:f,style:{outline:"none",...e.style},onMouseDown:ce(e.onMouseDown,()=>{C.current=!0}),onFocus:ce(e.onFocus,j=>{const _=!C.current;if(j.target===j.currentTarget&&_&&!y){const D=new CustomEvent(ca,xy);if(j.currentTarget.dispatchEvent(D),!D.defaultPrevented){const F=k().filter(q=>q.focusable),G=F.find(q=>q.active),K=F.find(q=>q.id===g),Y=[G,K,...F].filter(Boolean).map(q=>q.ref.current);Rd(Y,d)}}C.current=!1}),onBlur:ce(e.onBlur,()=>w(!1))})})}),_d="RovingFocusGroupItem",Md=p.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,l=Nt(),c=s||l,d=yy(_d,n),h=d.currentTabStopId===c,m=Ad(n),{onFocusableItemAdd:f,onFocusableItemRemove:v,currentTabStopId:g}=d;return p.useEffect(()=>{if(r)return f(),()=>v()},[r,f,v]),u.jsx(ua.ItemSlot,{scope:n,id:c,focusable:r,active:o,children:u.jsx(xe.span,{tabIndex:h?0:-1,"data-orientation":d.orientation,...a,ref:t,onMouseDown:ce(e.onMouseDown,x=>{r?d.onItemFocus(c):x.preventDefault()}),onFocus:ce(e.onFocus,()=>d.onItemFocus(c)),onKeyDown:ce(e.onKeyDown,x=>{if(x.key==="Tab"&&x.shiftKey){d.onItemShiftTab();return}if(x.target!==x.currentTarget)return;const y=ky(x,d.orientation,d.dir);if(y!==void 0){if(x.metaKey||x.ctrlKey||x.altKey||x.shiftKey)return;x.preventDefault();let S=m().filter(k=>k.focusable).map(k=>k.ref.current);if(y==="last")S.reverse();else if(y==="prev"||y==="next"){y==="prev"&&S.reverse();const k=S.indexOf(x.currentTarget);S=d.loop?Ey(S,k+1):S.slice(k+1)}setTimeout(()=>Rd(S))}}),children:typeof i=="function"?i({isCurrentTabStop:h,hasTabStop:g!=null}):i})})});Md.displayName=_d;var Cy={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Ty(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function ky(e,t,n){const r=Ty(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return Cy[r]}function Rd(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function Ey(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Iy=Pd,Ny=Md,Ay=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Ir=new WeakMap,us=new WeakMap,ds={},da=0,Od=function(e){return e&&(e.host||Od(e.parentNode))},jy=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=Od(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})},Py=function(e,t,n,r){var o=jy(t,Array.isArray(e)?e:[e]);ds[n]||(ds[n]=new WeakMap);var s=ds[n],i=[],a=new Set,l=new Set(o),c=function(h){!h||a.has(h)||(a.add(h),c(h.parentNode))};o.forEach(c);var d=function(h){!h||l.has(h)||Array.prototype.forEach.call(h.children,function(m){if(a.has(m))d(m);else try{var f=m.getAttribute(r),v=f!==null&&f!=="false",g=(Ir.get(m)||0)+1,x=(s.get(m)||0)+1;Ir.set(m,g),s.set(m,x),i.push(m),g===1&&v&&us.set(m,!0),x===1&&m.setAttribute(n,"true"),v||m.setAttribute(r,"true")}catch(y){console.error("aria-hidden: cannot operate on ",m,y)}})};return d(t),a.clear(),da++,function(){i.forEach(function(h){var m=Ir.get(h)-1,f=s.get(h)-1;Ir.set(h,m),s.set(h,f),m||(us.has(h)||h.removeAttribute(r),us.delete(h)),f||h.removeAttribute(n)}),da--,da||(Ir=new WeakMap,Ir=new WeakMap,us=new WeakMap,ds={})}},fa=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=Ay(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),Py(r,o,n,"aria-hidden")):function(){return null}},Sn=function(){return Sn=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},Sn.apply(this,arguments)};function Dd(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 _y(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 fs="right-scroll-bar-position",hs="width-before-scroll-bar",My="with-scroll-bars-hidden",Ry="--removed-body-scroll-bar-size";function ha(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function Oy(e,t){var n=b.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 Dy=typeof window<"u"?p.useLayoutEffect:p.useEffect,Ld=new WeakMap;function Ly(e,t){var n=Oy(null,function(r){return e.forEach(function(o){return ha(o,r)})});return Dy(function(){var r=Ld.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||ha(a,null)}),s.forEach(function(a){o.has(a)||ha(a,i)})}Ld.set(n,e)},[e]),n}function $y(e){return e}function Fy(e,t){t===void 0&&(t=$y);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)},c=function(){return Promise.resolve().then(l)};c(),n={push:function(d){i.push(d),c()},filter:function(d){return i=i.filter(d),n}}}};return o}function By(e){e===void 0&&(e={});var t=Fy(null);return t.options=Sn({async:!0,ssr:!1},e),t}var $d=function(e){var t=e.sideCar,n=Dd(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return p.createElement(r,Sn({},n))};$d.isSideCarExport=!0;function zy(e,t){return e.useMedium(t),$d}var Fd=By(),pa=function(){},ps=p.forwardRef(function(e,t){var n=p.useRef(null),r=p.useState({onScrollCapture:pa,onWheelCapture:pa,onTouchMoveCapture:pa}),o=r[0],s=r[1],i=e.forwardProps,a=e.children,l=e.className,c=e.removeScrollBar,d=e.enabled,h=e.shards,m=e.sideCar,f=e.noRelative,v=e.noIsolation,g=e.inert,x=e.allowPinchZoom,y=e.as,w=y===void 0?"div":y,S=e.gapMode,k=Dd(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=m,T=Ly([n,t]),E=Sn(Sn({},k),o);return p.createElement(p.Fragment,null,d&&p.createElement(C,{sideCar:Fd,removeScrollBar:c,shards:h,noRelative:f,noIsolation:v,inert:g,setCallbacks:s,allowPinchZoom:!!x,lockRef:n,gapMode:S}),i?p.cloneElement(p.Children.only(a),Sn(Sn({},E),{ref:T})):p.createElement(w,Sn({},E,{className:l,ref:T}),a))});ps.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},ps.classNames={fullWidth:hs,zeroRight:fs};var Hy=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Uy(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Hy();return t&&e.setAttribute("nonce",t),e}function Wy(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Vy(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var Ky=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Uy())&&(Wy(t,n),Vy(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},qy=function(){var e=Ky();return function(t,n){p.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Bd=function(){var e=qy(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},Gy={left:0,top:0,right:0,gap:0},ma=function(e){return parseInt(e||"",10)||0},Yy=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[ma(n),ma(r),ma(o)]},Xy=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Gy;var t=Yy(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])}},Jy=Bd(),Nr="data-scroll-locked",Zy=function(e,t,n,r){var o=e.left,s=e.top,i=e.right,a=e.gap;return n===void 0&&(n="margin"),`
|
|
40
40
|
.`.concat(My,` {
|
|
41
41
|
overflow: hidden `).concat(r,`;
|
|
42
42
|
padding-right: `).concat(a,"px ").concat(r,`;
|
|
@@ -76,7 +76,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
76
76
|
`)},zd=function(){var e=parseInt(document.body.getAttribute(Nr)||"0",10);return isFinite(e)?e:0},Qy=function(){p.useEffect(function(){return document.body.setAttribute(Nr,(zd()+1).toString()),function(){var e=zd()-1;e<=0?document.body.removeAttribute(Nr):document.body.setAttribute(Nr,e.toString())}},[])},e0=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;Qy();var s=p.useMemo(function(){return Xy(o)},[o]);return p.createElement(Jy,{styles:Zy(s,!t,o,n?"":"!important")})},ga=!1;if(typeof window<"u")try{var ms=Object.defineProperty({},"passive",{get:function(){return ga=!0,!0}});window.addEventListener("test",ms,ms),window.removeEventListener("test",ms,ms)}catch{ga=!1}var Ar=ga?{passive:!1}:!1,t0=function(e){return e.tagName==="TEXTAREA"},Hd=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!t0(e)&&n[t]==="visible")},n0=function(e){return Hd(e,"overflowY")},r0=function(e){return Hd(e,"overflowX")},Ud=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=Wd(e,r);if(o){var s=Vd(e,r),i=s[1],a=s[2];if(i>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},o0=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},s0=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},Wd=function(e,t){return e==="v"?n0(t):r0(t)},Vd=function(e,t){return e==="v"?o0(t):s0(t)},i0=function(e,t){return e==="h"&&t==="rtl"?-1:1},a0=function(e,t,n,r,o){var s=i0(e,window.getComputedStyle(t).direction),i=s*r,a=n.target,l=t.contains(a),c=!1,d=i>0,h=0,m=0;do{if(!a)break;var f=Vd(e,a),v=f[0],g=f[1],x=f[2],y=g-x-s*v;(v||y)&&Wd(e,a)&&(h+=y,m+=v);var w=a.parentNode;a=w&&w.nodeType===Node.DOCUMENT_FRAGMENT_NODE?w.host:w}while(!l&&a!==document.body||l&&(t.contains(a)||t===a));return(d&&Math.abs(h)<1||!d&&Math.abs(m)<1)&&(c=!0),c},gs=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Kd=function(e){return[e.deltaX,e.deltaY]},qd=function(e){return e&&"current"in e?e.current:e},l0=function(e,t){return e[0]===t[0]&&e[1]===t[1]},c0=function(e){return`
|
|
77
77
|
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
78
78
|
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
79
|
-
`)},u0=0,jr=[];function d0(e){var t=p.useRef([]),n=p.useRef([0,0]),r=p.useRef(),o=p.useState(u0++)[0],s=p.useState(Bd)[0],i=p.useRef(e);p.useEffect(function(){i.current=e},[e]),p.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var g=_y([e.lockRef.current],(e.shards||[]).map(qd),!0).filter(Boolean);return g.forEach(function(x){return x.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),g.forEach(function(x){return x.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var a=p.useCallback(function(g,x){if("touches"in g&&g.touches.length===2||g.type==="wheel"&&g.ctrlKey)return!i.current.allowPinchZoom;var y=gs(g),w=n.current,S="deltaX"in g?g.deltaX:w[0]-y[0],k="deltaY"in g?g.deltaY:w[1]-y[1],C,T=g.target,E=Math.abs(S)>Math.abs(k)?"h":"v";if("touches"in g&&E==="h"&&T.type==="range")return!1;var N=Ud(E,T);if(!N)return!0;if(N?C=E:(C=E==="v"?"h":"v",N=Ud(E,T)),!N)return!1;if(!r.current&&"changedTouches"in g&&(S||k)&&(r.current=C),!C)return!0;var M=r.current||C;return a0(M,x,g,M==="h"?S:k)},[]),l=p.useCallback(function(g){var x=g;if(!(!jr.length||jr[jr.length-1]!==s)){var y="deltaY"in x?Kd(x):gs(x),w=t.current.filter(function(C){return C.name===x.type&&(C.target===x.target||x.target===C.shadowParent)&&l0(C.delta,y)})[0];if(w&&w.should){x.cancelable&&x.preventDefault();return}if(!w){var S=(i.current.shards||[]).map(qd).filter(Boolean).filter(function(C){return C.contains(x.target)}),k=S.length>0?a(x,S[0]):!i.current.noIsolation;k&&x.cancelable&&x.preventDefault()}}},[]),c=p.useCallback(function(g,x,y,w){var S={name:g,delta:x,target:y,should:w,shadowParent:f0(y)};t.current.push(S),setTimeout(function(){t.current=t.current.filter(function(k){return k!==S})},1)},[]),d=p.useCallback(function(g){n.current=gs(g),r.current=void 0},[]),h=p.useCallback(function(g){c(g.type,Kd(g),g.target,a(g,e.lockRef.current))},[]),m=p.useCallback(function(g){c(g.type,gs(g),g.target,a(g,e.lockRef.current))},[]);p.useEffect(function(){return jr.push(s),e.setCallbacks({onScrollCapture:h,onWheelCapture:h,onTouchMoveCapture:m}),document.addEventListener("wheel",l,Ar),document.addEventListener("touchmove",l,Ar),document.addEventListener("touchstart",d,Ar),function(){jr=jr.filter(function(g){return g!==s}),document.removeEventListener("wheel",l,Ar),document.removeEventListener("touchmove",l,Ar),document.removeEventListener("touchstart",d,Ar)}},[]);var f=e.removeScrollBar,v=e.inert;return p.createElement(p.Fragment,null,v?p.createElement(s,{styles:c0(o)}):null,f?p.createElement(e0,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function f0(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const h0=zy(Fd,d0);var xs=p.forwardRef(function(e,t){return p.createElement(ps,Sn({},e,{ref:t,sideCar:h0}))});xs.classNames=ps.classNames;var xa=["Enter"," "],p0=["ArrowDown","PageUp","Home"],Gd=["ArrowUp","PageDown","End"],m0=[...p0,...Gd],g0={ltr:[...xa,"ArrowRight"],rtl:[...xa,"ArrowLeft"]},x0={ltr:["ArrowLeft"],rtl:["ArrowRight"]},ao="Menu",[lo,v0,b0]=Xo(ao),[tr,Yd]=ln(ao,[b0,Er,jd]),vs=Er(),Xd=jd(),[w0,nr]=tr(ao),[y0,co]=tr(ao),Jd=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=vs(t),[l,c]=p.useState(null),d=p.useRef(!1),h=ft(s),m=Jo(o);return p.useEffect(()=>{const f=()=>{d.current=!0,document.addEventListener("pointerdown",v,{capture:!0,once:!0}),document.addEventListener("pointermove",v,{capture:!0,once:!0})},v=()=>d.current=!1;return document.addEventListener("keydown",f,{capture:!0}),()=>{document.removeEventListener("keydown",f,{capture:!0}),document.removeEventListener("pointerdown",v,{capture:!0}),document.removeEventListener("pointermove",v,{capture:!0})}},[]),u.jsx(sa,{...a,children:u.jsx(w0,{scope:t,open:n,onOpenChange:h,content:l,onContentChange:c,children:u.jsx(y0,{scope:t,onClose:p.useCallback(()=>h(!1),[h]),isUsingKeyboardRef:d,dir:m,modal:i,children:r})})})};Jd.displayName=ao;var S0="MenuAnchor",va=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=vs(n);return u.jsx(ia,{...o,...r,ref:t})});va.displayName=S0;var ba="MenuPortal",[C0,Zd]=tr(ba,{forceMount:void 0}),Qd=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=nr(ba,t);return u.jsx(C0,{scope:t,forceMount:n,children:u.jsx(zt,{present:n||s.open,children:u.jsx(so,{asChild:!0,container:o,children:r})})})};Qd.displayName=ba;var en="MenuContent",[T0,wa]=tr(en),ef=p.forwardRef((e,t)=>{const n=Zd(en,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=nr(en,e.__scopeMenu),i=co(en,e.__scopeMenu);return u.jsx(lo.Provider,{scope:e.__scopeMenu,children:u.jsx(zt,{present:r||s.open,children:u.jsx(lo.Slot,{scope:e.__scopeMenu,children:i.modal?u.jsx(k0,{...o,ref:t}):u.jsx(E0,{...o,ref:t})})})})}),k0=p.forwardRef((e,t)=>{const n=nr(en,e.__scopeMenu),r=p.useRef(null),o=De(t,r);return p.useEffect(()=>{const s=r.current;if(s)return fa(s)},[]),u.jsx(ya,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:ce(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),E0=p.forwardRef((e,t)=>{const n=nr(en,e.__scopeMenu);return u.jsx(ya,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),I0=Kt.createSlot("MenuContent.ScrollLock"),ya=p.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:h,onInteractOutside:m,onDismiss:f,disableOutsideScroll:v,...g}=e,x=nr(en,n),y=co(en,n),w=vs(n),S=Xd(n),k=v0(n),[C,T]=p.useState(null),E=p.useRef(null),N=De(t,E,x.onContentChange),M=p.useRef(0),O=p.useRef(""),F=p.useRef(0),G=p.useRef(null),K=p.useRef("right"),j=p.useRef(0),Y=v?xs:p.Fragment,q=v?{as:I0,allowPinchZoom:!0}:void 0,z=I=>{var H,L;const U=O.current+I,J=k().filter(Z=>!Z.disabled),_=document.activeElement,P=(H=J.find(Z=>Z.ref.current===_))==null?void 0:H.textValue,D=J.map(Z=>Z.textValue),$=F0(D,U,P),ee=(L=J.find(Z=>Z.textValue===$))==null?void 0:L.ref.current;(function Z(te){O.current=te,window.clearTimeout(M.current),te!==""&&(M.current=window.setTimeout(()=>Z(""),1e3))})(U),ee&&setTimeout(()=>ee.focus())};p.useEffect(()=>()=>window.clearTimeout(M.current),[]),Ui();const R=p.useCallback(I=>{var J,_;return K.current===((J=G.current)==null?void 0:J.side)&&z0(I,(_=G.current)==null?void 0:_.area)},[]);return u.jsx(T0,{scope:n,searchRef:O,onItemEnter:p.useCallback(I=>{R(I)&&I.preventDefault()},[R]),onItemLeave:p.useCallback(I=>{var U;R(I)||((U=E.current)==null||U.focus(),T(null))},[R]),onTriggerLeave:p.useCallback(I=>{R(I)&&I.preventDefault()},[R]),pointerGraceTimerRef:F,onPointerGraceIntentChange:p.useCallback(I=>{G.current=I},[]),children:u.jsx(Y,{...q,children:u.jsx(Zo,{asChild:!0,trapped:o,onMountAutoFocus:ce(s,I=>{var U;I.preventDefault(),(U=E.current)==null||U.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:u.jsx(yr,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:h,onInteractOutside:m,onDismiss:f,children:u.jsx(Iy,{asChild:!0,...S,dir:y.dir,orientation:"vertical",loop:r,currentTabStopId:C,onCurrentTabStopIdChange:T,onEntryFocus:ce(l,I=>{y.isUsingKeyboardRef.current||I.preventDefault()}),preventScrollOnEntryFocus:!0,children:u.jsx(aa,{role:"menu","aria-orientation":"vertical","data-state":vf(x.open),"data-radix-menu-content":"",dir:y.dir,...w,...g,ref:N,style:{outline:"none",...g.style},onKeyDown:ce(g.onKeyDown,I=>{const J=I.target.closest("[data-radix-menu-content]")===I.currentTarget,_=I.ctrlKey||I.altKey||I.metaKey,P=I.key.length===1;J&&(I.key==="Tab"&&I.preventDefault(),!_&&P&&z(I.key));const D=E.current;if(I.target!==D||!m0.includes(I.key))return;I.preventDefault();const ee=k().filter(H=>!H.disabled).map(H=>H.ref.current);Gd.includes(I.key)&&ee.reverse(),L0(ee)}),onBlur:ce(e.onBlur,I=>{I.currentTarget.contains(I.target)||(window.clearTimeout(M.current),O.current="")}),onPointerMove:ce(e.onPointerMove,fo(I=>{const U=I.target,J=j.current!==I.clientX;if(I.currentTarget.contains(U)&&J){const _=I.clientX>j.current?"right":"left";K.current=_,j.current=I.clientX}}))})})})})})})});ef.displayName=en;var N0="MenuGroup",Sa=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(xe.div,{role:"group",...r,ref:t})});Sa.displayName=N0;var A0="MenuLabel",tf=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(xe.div,{...r,ref:t})});tf.displayName=A0;var bs="MenuItem",nf="menu.itemSelect",ws=p.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=p.useRef(null),i=co(bs,e.__scopeMenu),a=wa(bs,e.__scopeMenu),l=De(t,s),c=p.useRef(!1),d=()=>{const h=s.current;if(!n&&h){const m=new CustomEvent(nf,{bubbles:!0,cancelable:!0});h.addEventListener(nf,f=>r==null?void 0:r(f),{once:!0}),Bi(h,m),m.defaultPrevented?c.current=!1:i.onClose()}};return u.jsx(rf,{...o,ref:l,disabled:n,onClick:ce(e.onClick,d),onPointerDown:h=>{var m;(m=e.onPointerDown)==null||m.call(e,h),c.current=!0},onPointerUp:ce(e.onPointerUp,h=>{var m;c.current||(m=h.currentTarget)==null||m.click()}),onKeyDown:ce(e.onKeyDown,h=>{const m=a.searchRef.current!=="";n||m&&h.key===" "||xa.includes(h.key)&&(h.currentTarget.click(),h.preventDefault())})})});ws.displayName=bs;var rf=p.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=wa(bs,n),a=Xd(n),l=p.useRef(null),c=De(t,l),[d,h]=p.useState(!1),[m,f]=p.useState("");return p.useEffect(()=>{const v=l.current;v&&f((v.textContent??"").trim())},[s.children]),u.jsx(lo.ItemSlot,{scope:n,disabled:r,textValue:o??m,children:u.jsx(Ny,{asChild:!0,...a,focusable:!r,children:u.jsx(xe.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:c,onPointerMove:ce(e.onPointerMove,fo(v=>{r?i.onItemLeave(v):(i.onItemEnter(v),v.defaultPrevented||v.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:ce(e.onPointerLeave,fo(v=>i.onItemLeave(v))),onFocus:ce(e.onFocus,()=>h(!0)),onBlur:ce(e.onBlur,()=>h(!1))})})})}),j0="MenuCheckboxItem",of=p.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return u.jsx(uf,{scope:e.__scopeMenu,checked:n,children:u.jsx(ws,{role:"menuitemcheckbox","aria-checked":ys(n)?"mixed":n,...o,ref:t,"data-state":Ta(n),onSelect:ce(o.onSelect,()=>r==null?void 0:r(ys(n)?!0:!n),{checkForDefaultPrevented:!1})})})});of.displayName=j0;var sf="MenuRadioGroup",[P0,_0]=tr(sf,{value:void 0,onValueChange:()=>{}}),af=p.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=ft(r);return u.jsx(P0,{scope:e.__scopeMenu,value:n,onValueChange:s,children:u.jsx(Sa,{...o,ref:t})})});af.displayName=sf;var lf="MenuRadioItem",cf=p.forwardRef((e,t)=>{const{value:n,...r}=e,o=_0(lf,e.__scopeMenu),s=n===o.value;return u.jsx(uf,{scope:e.__scopeMenu,checked:s,children:u.jsx(ws,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":Ta(s),onSelect:ce(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});cf.displayName=lf;var Ca="MenuItemIndicator",[uf,M0]=tr(Ca,{checked:!1}),df=p.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=M0(Ca,n);return u.jsx(zt,{present:r||ys(s.checked)||s.checked===!0,children:u.jsx(xe.span,{...o,ref:t,"data-state":Ta(s.checked)})})});df.displayName=Ca;var R0="MenuSeparator",ff=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(xe.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});ff.displayName=R0;var O0="MenuArrow",hf=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=vs(n);return u.jsx(la,{...o,...r,ref:t})});hf.displayName=O0;var D0="MenuSub",[AN,pf]=tr(D0),uo="MenuSubTrigger",mf=p.forwardRef((e,t)=>{const n=nr(uo,e.__scopeMenu),r=co(uo,e.__scopeMenu),o=pf(uo,e.__scopeMenu),s=wa(uo,e.__scopeMenu),i=p.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,c={__scopeMenu:e.__scopeMenu},d=p.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return p.useEffect(()=>d,[d]),p.useEffect(()=>{const h=a.current;return()=>{window.clearTimeout(h),l(null)}},[a,l]),u.jsx(va,{asChild:!0,...c,children:u.jsx(rf,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":vf(n.open),...e,ref:On(t,o.onTriggerChange),onClick:h=>{var m;(m=e.onClick)==null||m.call(e,h),!(e.disabled||h.defaultPrevented)&&(h.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:ce(e.onPointerMove,fo(h=>{s.onItemEnter(h),!h.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(s.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),d()},100))})),onPointerLeave:ce(e.onPointerLeave,fo(h=>{var f,v;d();const m=(f=n.content)==null?void 0:f.getBoundingClientRect();if(m){const g=(v=n.content)==null?void 0:v.dataset.side,x=g==="right",y=x?-5:5,w=m[x?"left":"right"],S=m[x?"right":"left"];s.onPointerGraceIntentChange({area:[{x:h.clientX+y,y:h.clientY},{x:w,y:m.top},{x:S,y:m.top},{x:S,y:m.bottom},{x:w,y:m.bottom}],side:g}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(h),h.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:ce(e.onKeyDown,h=>{var f;const m=s.searchRef.current!=="";e.disabled||m&&h.key===" "||g0[r.dir].includes(h.key)&&(n.onOpenChange(!0),(f=n.content)==null||f.focus(),h.preventDefault())})})})});mf.displayName=uo;var gf="MenuSubContent",xf=p.forwardRef((e,t)=>{const n=Zd(en,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=nr(en,e.__scopeMenu),i=co(en,e.__scopeMenu),a=pf(gf,e.__scopeMenu),l=p.useRef(null),c=De(t,l);return u.jsx(lo.Provider,{scope:e.__scopeMenu,children:u.jsx(zt,{present:r||s.open,children:u.jsx(lo.Slot,{scope:e.__scopeMenu,children:u.jsx(ya,{id:a.contentId,"aria-labelledby":a.triggerId,...o,ref:c,align:"start",side:i.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:d=>{var h;i.isUsingKeyboardRef.current&&((h=l.current)==null||h.focus()),d.preventDefault()},onCloseAutoFocus:d=>d.preventDefault(),onFocusOutside:ce(e.onFocusOutside,d=>{d.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:ce(e.onEscapeKeyDown,d=>{i.onClose(),d.preventDefault()}),onKeyDown:ce(e.onKeyDown,d=>{var f;const h=d.currentTarget.contains(d.target),m=x0[i.dir].includes(d.key);h&&m&&(s.onOpenChange(!1),(f=a.trigger)==null||f.focus(),d.preventDefault())})})})})})});xf.displayName=gf;function vf(e){return e?"open":"closed"}function ys(e){return e==="indeterminate"}function Ta(e){return ys(e)?"indeterminate":e?"checked":"unchecked"}function L0(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function $0(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function F0(e,t,n){const o=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=$0(e,Math.max(s,0));o.length===1&&(i=i.filter(c=>c!==n));const l=i.find(c=>c.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function B0(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],c=a.x,d=a.y,h=l.x,m=l.y;d>r!=m>r&&n<(h-c)*(r-d)/(m-d)+c&&(o=!o)}return o}function z0(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return B0(n,t)}function fo(e){return t=>t.pointerType==="mouse"?e(t):void 0}var H0=Jd,U0=va,W0=Qd,V0=ef,K0=Sa,q0=tf,G0=ws,Y0=of,X0=af,J0=cf,Z0=df,Q0=ff,eS=hf,tS=mf,nS=xf,Ss="DropdownMenu",[rS,jN]=ln(Ss,[Yd]),Ot=Yd(),[oS,bf]=rS(Ss),wf=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,l=Ot(t),c=p.useRef(null),[d,h]=Dn({prop:o,defaultProp:s??!1,onChange:i,caller:Ss});return u.jsx(oS,{scope:t,triggerId:Nt(),triggerRef:c,contentId:Nt(),open:d,onOpenChange:h,onOpenToggle:p.useCallback(()=>h(m=>!m),[h]),modal:a,children:u.jsx(H0,{...l,open:d,onOpenChange:h,dir:r,modal:a,children:n})})};wf.displayName=Ss;var yf="DropdownMenuTrigger",Sf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=bf(yf,n),i=Ot(n);return u.jsx(U0,{asChild:!0,...i,children:u.jsx(xe.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:On(t,s.triggerRef),onPointerDown:ce(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:ce(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});Sf.displayName=yf;var sS="DropdownMenuPortal",Cf=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Ot(t);return u.jsx(W0,{...r,...n})};Cf.displayName=sS;var Tf="DropdownMenuContent",kf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=bf(Tf,n),s=Ot(n),i=p.useRef(!1);return u.jsx(V0,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:ce(e.onCloseAutoFocus,a=>{var l;i.current||(l=o.triggerRef.current)==null||l.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:ce(e.onInteractOutside,a=>{const l=a.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0,d=l.button===2||c;(!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=Tf;var iS="DropdownMenuGroup",aS=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(K0,{...o,...r,ref:t})});aS.displayName=iS;var lS="DropdownMenuLabel",Ef=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(q0,{...o,...r,ref:t})});Ef.displayName=lS;var cS="DropdownMenuItem",If=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(G0,{...o,...r,ref:t})});If.displayName=cS;var uS="DropdownMenuCheckboxItem",Nf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(Y0,{...o,...r,ref:t})});Nf.displayName=uS;var dS="DropdownMenuRadioGroup",fS=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(X0,{...o,...r,ref:t})});fS.displayName=dS;var hS="DropdownMenuRadioItem",Af=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(J0,{...o,...r,ref:t})});Af.displayName=hS;var pS="DropdownMenuItemIndicator",jf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(Z0,{...o,...r,ref:t})});jf.displayName=pS;var mS="DropdownMenuSeparator",Pf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(Q0,{...o,...r,ref:t})});Pf.displayName=mS;var gS="DropdownMenuArrow",xS=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(eS,{...o,...r,ref:t})});xS.displayName=gS;var vS="DropdownMenuSubTrigger",_f=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(tS,{...o,...r,ref:t})});_f.displayName=vS;var bS="DropdownMenuSubContent",Mf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(nS,{...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)"}})});Mf.displayName=bS;var wS=wf,yS=Sf,SS=Cf,Rf=kf,Of=Ef,Df=If,Lf=Nf,$f=Af,Ff=jf,Bf=Pf,zf=_f,Hf=Mf;const Cs=wS,Ts=yS,CS=p.forwardRef(({className:e,inset:t,children:n,...r},o)=>u.jsxs(zf,{ref:o,className:oe("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",t&&"pl-8",e),...r,children:[n,u.jsx(ue.ChevronRight,{className:"ml-auto h-4 w-4"})]}));CS.displayName=zf.displayName;const TS=p.forwardRef(({className:e,...t},n)=>u.jsx(Hf,{ref:n,className:oe("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...t}));TS.displayName=Hf.displayName;const ho=p.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(SS,{children:u.jsx(Rf,{ref:r,sideOffset:t,className:oe("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n})}));ho.displayName=Rf.displayName;const Bn=p.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(Df,{ref:r,className:oe("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...n}));Bn.displayName=Df.displayName;const kS=p.forwardRef(({className:e,children:t,checked:n,...r},o)=>u.jsxs(Lf,{ref:o,className:oe("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:n,...r,children:[u.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx(Ff,{children:u.jsx(ue.Check,{className:"h-4 w-4"})})}),t]}));kS.displayName=Lf.displayName;const ES=p.forwardRef(({className:e,children:t,...n},r)=>u.jsxs($f,{ref:r,className:oe("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[u.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx(Ff,{children:u.jsx(ue.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));ES.displayName=$f.displayName;const IS=p.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(Of,{ref:r,className:oe("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));IS.displayName=Of.displayName;const NS=p.forwardRef(({className:e,...t},n)=>u.jsx(Bf,{ref:n,className:oe("-mx-1 my-1 h-px bg-muted",e),...t}));NS.displayName=Bf.displayName;const ka=p.forwardRef(({className:e,...t},n)=>u.jsx("textarea",{className:oe("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),ref:n,...t}));ka.displayName="Textarea";const AS=1e4;function Uf({initialValue:e="",editingMessageId:t=null,placeholder:n="Type your message...",isStreaming:r=!1,disabled:o=!1,maxLength:s=AS,value:i,onValueChange:a,onSend:l,onCancelEdit:c,onStop:d,className:h="",textareaClassName:m="",allowEmptySend:f=!1,validate:v,onValidationError:g}){const x=i!==void 0,[y,w]=b.useState(e),S=(x?i:y)??"",[k,C]=b.useTransition(),T=b.useRef(null),E=b.useRef(0),N=b.useRef(null),M=b.useRef("");b.useEffect(()=>{x||(w(e??""),N.current=null,T.current&&(T.current.style.height="auto",T.current.style.height=`${T.current.scrollHeight}px`))},[e,t,x]);const[O,F]=b.useState(null),G=b.useCallback(P=>P.length>s?`Message too long (${P.length}/${s} characters)`:null,[s]),K=b.useMemo(()=>v??G,[v,G]),j=b.useCallback(P=>{const D=K(P);return F(D),g==null||g(D),M.current=P,D},[K,g]),Y=b.useCallback(()=>{const P=T.current;P&&(P.style.height="auto",P.style.height=`${P.scrollHeight}px`)},[]);b.useEffect(()=>{Y()},[Y,S]),b.useEffect(()=>{if(!O)return;const P=(S??"").trim();M.current!==P&&j(P)},[S,O,j]);const q=b.useCallback((P,{fromUser:D})=>{x||w(P),D&&(a==null||a(P))},[x,a]),z=b.useCallback(async P=>{P&&P.preventDefault();const D=(S??"").trim();if(!D&&!f||j(D))return;const $=++E.current;N.current={id:$,shouldClear:!0},C(()=>{var ee,H,L;try{const Z=l(D);Z&&typeof Z.then=="function"?Z.then(()=>{var te,Q;((te=N.current)==null?void 0:te.id)===$&&N.current.shouldClear&&(x||(w(""),T.current&&(T.current.style.height="auto"),a==null||a(""))),((Q=N.current)==null?void 0:Q.id)===$&&(N.current=null)}).catch(()=>{var te;((te=N.current)==null?void 0:te.id)===$&&(N.current=null)}):(((ee=N.current)==null?void 0:ee.id)===$&&N.current.shouldClear&&(x||(w(""),T.current&&(T.current.style.height="auto"),a==null||a(""))),((H=N.current)==null?void 0:H.id)===$&&(N.current=null))}catch{((L=N.current)==null?void 0:L.id)===$&&(N.current=null)}})},[S,l,f,x,a,j]),R=b.useCallback(P=>{const D=P.target.value;q(D,{fromUser:!0}),N.current&&(N.current.shouldClear=!1),T.current&&(T.current.style.height="auto",T.current.style.height=`${T.current.scrollHeight}px`),O&&j(D.trim())},[q,j,O]),I=b.useCallback(P=>{P.key==="Enter"&&!P.shiftKey?(P.preventDefault(),z()):P.key==="Escape"&&t&&(P.preventDefault(),c==null||c())},[z,t,c]),_=`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))]":""} ${m}`;return u.jsx("form",{onSubmit:P=>void z(P),className:`w-full ${h}`,children:u.jsxs("div",{className:"flex items-end gap-2",children:[u.jsxs("div",{className:"flex-1",children:[u.jsx(ka,{ref:T,value:S,onChange:R,onKeyDown:I,placeholder:t?"Edit your message...":n,className:_,disabled:o,maxLength:s,rows:1,spellCheck:!1,autoCorrect:"off"}),O&&u.jsx("p",{className:"mt-1 text-xs text-destructive font-medium",children:O})]}),u.jsx("div",{children:r?u.jsx(Xe,{type:"button",onClick:()=>{d==null||d()},size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",disabled:o||!d,children:u.jsx(ue.Square,{size:16})}):u.jsx(Xe,{type:"submit",size:"icon",className:"shrink-0",title:t?"Save changes":"Send message",disabled:o||!S.trim()&&!f||k,children:u.jsx(ue.Send,{size:16})})})]})})}const jS=b.memo(Uf);function Wf({composerValue:e,onComposerChange:t,onSend:n,onCancelEdit:r,onStop:o,editingMessageId:s=null,editingInitialValue:i="",placeholder:a="Type your message...",isStreaming:l=!1,disabled:c=!1,textareaClassName:d="",customStyles:h={},enableFileUpload:m=!1,enableExcelUpload:f=!1,onExcelUpload:v,onError:g,allowEmptySend:x=!1,inputError:y=null}){const[w,S]=b.useState([]),k=b.useRef(null),C=b.useRef(null),[T,E]=b.useState(0),[N,M]=b.useState(0),[O,F]=b.useState(!1),[G,K]=b.useState(null),[j,Y]=b.useState(null),q=b.useCallback(()=>{k.current&&(k.current.value=""),C.current&&(C.current.value=""),E(D=>D+1),M(D=>D+1)},[]),z=b.useCallback(D=>{S($=>[...$,...D])},[]),R=b.useCallback(D=>{const $=Array.from(D.target.files||[]);z($),D.target.value=""},[z]),I=b.useCallback(D=>{S($=>{const ee=$.filter((H,L)=>L!==D);return ee.length===0&&q(),ee})},[q]),U=b.useCallback(async D=>{const $=(D.target.files||[])[0];if($&&(K(null),Y(null),!!v)){F(!0);try{await v($),K(`Uploaded ${$.name} - processing through chat stream`)}catch(ee){const H=ee instanceof Error?ee.message:"Failed to upload Excel file";Y(H),g==null||g(H)}finally{F(!1),D.target.value="",q()}}},[v,g,q]),J=b.useMemo(()=>x||w.length>0,[x,w]),_=b.useCallback(async D=>{const $=n(D,w);try{const ee=await $;return w.length>0&&(S([]),q()),ee}catch(ee){throw ee}},[n,q,w]),P=`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${s?"border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50":""} ${y?"border-red-400":""} ${h.textarea||""} ${d}`;return u.jsxs(u.Fragment,{children:[(m||f)&&u.jsxs("div",{className:"mb-3 space-y-3",children:[m&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:k,type:"file",multiple:!0,onChange:R,className:"hidden"},T),w.length>0&&u.jsx("div",{className:"flex flex-wrap gap-2",children:w.map((D,$)=>u.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:[u.jsx(ue.Paperclip,{size:14}),u.jsx("span",{className:"truncate max-w-[150px]",children:D.name}),u.jsx(Xe,{variant:"ghost",size:"sm",onClick:()=>I($),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 ${D.name}`,children:u.jsx(ue.X,{size:12})})]},$))})]}),f&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:C,type:"file",accept:".xls,.xlsx,.xlsm",onChange:U,className:"hidden"},N),O&&u.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(ue.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),G&&!O&&u.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:G}),j&&!O&&u.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:j})]})]}),u.jsxs("div",{className:"flex items-end gap-2",children:[(m||f)&&u.jsxs(Cs,{children:[u.jsx(Ts,{asChild:!0,children:u.jsx(Xe,{type:"button",size:"icon",variant:"outline",disabled:l||c,title:"More input actions",className:h.moreButton||"",children:u.jsx(ue.Plus,{size:16})})}),u.jsxs(ho,{align:"start",sideOffset:6,className:"w-52",children:[m&&u.jsxs(Bn,{onClick:()=>{var D;return(D=k.current)==null?void 0:D.click()},className:"cursor-pointer",children:[u.jsx(ue.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),f&&u.jsxs(Bn,{onClick:()=>{var D;O||(D=C.current)==null||D.click()},className:`cursor-pointer ${O?"opacity-60 pointer-events-none":""}`,children:[u.jsx(ue.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),u.jsx("div",{className:"flex-1",children:u.jsx(jS,{initialValue:i,editingMessageId:s,value:e,onValueChange:t,placeholder:s?"Edit your message...":a,isStreaming:l,disabled:c,onSend:_,onCancelEdit:r,onStop:o,allowEmptySend:J,textareaClassName:P})})]})]})}const PS=b.memo(Wf),ks=0,zn=1,Pr=2,Vf=4;function Kf(e){return()=>e}function _S(e){e()}function qf(e,t){return n=>e(t(n))}function Gf(e,t){return()=>e(t)}function MS(e,t){return n=>e(t,n)}function Ea(e){return e!==void 0}function RS(...e){return()=>{e.map(_S)}}function _r(){}function Es(e,t){return t(e),e}function OS(e,t){return t(e)}function rt(...e){return e}function Ge(e,t){return e(zn,t)}function Me(e,t){e(ks,t)}function Ia(e){e(Pr)}function ht(e){return e(Vf)}function ve(e,t){return Ge(e,MS(t,ks))}function dn(e,t){const n=e(zn,r=>{n(),t(r)});return n}function Yf(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function Xf(e,t){return e===t}function ot(e=Xf){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function ke(e){return t=>n=>{e(n)&&t(n)}}function he(e){return t=>qf(t,e)}function Cn(e){return t=>()=>{t(e)}}function ne(e,...t){const n=DS(...t);return(r,o)=>{switch(r){case Pr:Ia(e);return;case zn:return Ge(e,n(o))}}}function Tn(e,t){return n=>r=>{n(t=e(t,r))}}function rr(e){return t=>n=>{e>0?e--:t(n)}}function Pn(e){let t=null,n;return r=>o=>{t=o,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function Le(...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);Ge(s,l=>{const c=n;n=n|a,t[i]=l,c!==o&&n===o&&r&&(r(),r=null)})}),s=>i=>{const a=()=>{s([i].concat(t))};n===o?a():r=a}}function DS(...e){return t=>e.reduceRight(OS,t)}function LS(e){let t,n;const r=()=>t==null?void 0:t();return function(o,s){switch(o){case zn:return s?n===s?void 0:(r(),n=s,t=Ge(e,s),t):(r(),_r);case Pr:r(),n=null;return}}}function se(e){let t=e;const n=Be();return(r,o)=>{switch(r){case ks:t=o;break;case zn:{o(t);break}case Vf:return t}return n(r,o)}}function At(e,t){return Es(se(t),n=>ve(e,n))}function Be(){const e=[];return(t,n)=>{switch(t){case ks:e.slice().forEach(r=>{r(n)});return;case Pr:e.splice(0,e.length);return;case zn:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}}}function Jt(e){return Es(Be(),t=>ve(e,t))}function Ke(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:$S(),singleton:n}}const $S=()=>Symbol();function FS(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 gt(...e){const t=Be(),n=new Array(e.length);let r=0;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const a=Math.pow(2,i);Ge(s,l=>{n[i]=l,r=r|a,r===o&&Me(t,n)})}),function(s,i){switch(s){case Pr:{Ia(t);return}case zn:return r===o&&i(n),Ge(t,i)}}}function Te(e,t=Xf){return ne(e,ot(t))}function Na(...e){return function(t,n){switch(t){case Pr:return;case zn:return RS(...e.map(r=>Ge(r,n)))}}}var Ht=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(Ht||{});const BS={0:"debug",3:"error",1:"log",2:"warn"},zS=()=>typeof globalThis>"u"?window:globalThis,Hn=Ke(()=>{const e=se(3);return{log:se((t,n,r=1)=>{var o;const s=(o=zS().VIRTUOSO_LOG_LEVEL)!=null?o:ht(e);r>=s&&console[BS[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0});function or(e,t,n){return Aa(e,t,n).callbackRef}function Aa(e,t,n){const r=b.useRef(null);let o=i=>{};const s=b.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 HS(e,t,n,r,o,s,i,a,l){const c=b.useCallback(d=>{const h=US(d.children,t,a?"offsetWidth":"offsetHeight",o);let m=d.parentElement;for(;!m.dataset.virtuosoScroller;)m=m.parentElement;const f=m.lastElementChild.dataset.viewportType==="window";let v;f&&(v=m.ownerDocument.defaultView);const g=i?a?i.scrollLeft:i.scrollTop:f?a?v.scrollX||v.document.documentElement.scrollLeft:v.scrollY||v.document.documentElement.scrollTop:a?m.scrollLeft:m.scrollTop,x=i?a?i.scrollWidth:i.scrollHeight:f?a?v.document.documentElement.scrollWidth:v.document.documentElement.scrollHeight:a?m.scrollWidth:m.scrollHeight,y=i?a?i.offsetWidth:i.offsetHeight:f?a?v.innerWidth:v.innerHeight:a?m.offsetWidth:m.offsetHeight;r({scrollHeight:x,scrollTop:Math.max(g,0),viewportHeight:y}),s==null||s(a?Jf("column-gap",getComputedStyle(d).columnGap,o):Jf("row-gap",getComputedStyle(d).rowGap,o)),h!==null&&e(h)},[e,t,o,s,i,r,a]);return Aa(c,n,l)}function US(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),c=parseFloat(a.dataset.knownSize),d=t(a,n);if(d===0&&r("Zero-sized element, this should not happen",{child:a},Ht.ERROR),d===c)continue;const h=s[s.length-1];s.length===0||h.size!==d||h.endIndex!==l-1?s.push({endIndex:l,size:d,startIndex:l}):s[s.length-1].endIndex++}return s}function Jf(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Ht.WARN),t==="normal"?0:parseInt(t??"0",10)}function Zf(e,t,n){const r=b.useRef(null),o=b.useCallback(l=>{if(!(l!=null&&l.offsetParent))return;const c=l.getBoundingClientRect(),d=c.width;let h,m;if(t){const f=t.getBoundingClientRect(),v=c.top-f.top;m=f.height-Math.max(0,v),h=v+t.scrollTop}else{const f=i.current.ownerDocument.defaultView;m=f.innerHeight-Math.max(0,c.top),h=c.top+f.scrollY}r.current={offsetTop:h,visibleHeight:m,visibleWidth:d},e(r.current)},[e,t]),{callbackRef:s,ref:i}=Aa(o,!0,n),a=b.useCallback(()=>{o(i.current)},[o,i]);return b.useEffect(()=>{var l;if(t){t.addEventListener("scroll",a);const c=new ResizeObserver(()=>{requestAnimationFrame(a)});return c.observe(t),()=>{t.removeEventListener("scroll",a),c.unobserve(t)}}else{const c=(l=i.current)==null?void 0:l.ownerDocument.defaultView;return c==null||c.addEventListener("scroll",a),c==null||c.addEventListener("resize",a),()=>{c==null||c.removeEventListener("scroll",a),c==null||c.removeEventListener("resize",a)}}},[a,t,i]),s}const Dt=Ke(()=>{const e=Be(),t=Be(),n=se(0),r=Be(),o=se(0),s=Be(),i=Be(),a=se(0),l=se(0),c=se(0),d=se(0),h=Be(),m=Be(),f=se(!1),v=se(!1),g=se(!1);return ve(ne(e,he(({scrollTop:x})=>x)),t),ve(ne(e,he(({scrollHeight:x})=>x)),i),ve(t,o),{deviation:n,fixedFooterHeight:c,fixedHeaderHeight:l,footerHeight:d,headerHeight:a,horizontalDirection:v,scrollBy:m,scrollContainerState:e,scrollHeight:i,scrollingInProgress:f,scrollTo:h,scrollTop:t,skipAnimationFrameInResizeObserver:g,smoothScrollTargetReached:r,statefulScrollTop:o,viewportHeight:s}},[],{singleton:!0}),po={lvl:0};function Qf(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 Ze(e){return e===po}function mo(e,t){if(!Ze(e))return t===e.k?e.v:t<e.k?mo(e.l,t):mo(e.r,t)}function fn(e,t,n="k"){if(Ze(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){const r=fn(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return fn(e.l,t,n)}function Zt(e,t,n){return Ze(e)?nh(t,n,1):t===e.k?vt(e,{k:t,v:n}):t<e.k?rh(vt(e,{l:Zt(e.l,t,n)})):rh(vt(e,{r:Zt(e.r,t,n)}))}function Mr(){return po}function Is(e,t,n){if(Ze(e))return[];const r=fn(e,t)[0];return WS(Pa(e,r,n))}function ja(e,t){if(Ze(e))return po;const{k:n,l:r,r:o}=e;if(t===n){if(Ze(r))return o;if(Ze(o))return r;{const[s,i]=th(r);return Ns(vt(e,{k:s,l:eh(r),v:i}))}}else return t<n?Ns(vt(e,{l:ja(r,t)})):Ns(vt(e,{r:ja(o,t)}))}function sr(e){return Ze(e)?[]:[...sr(e.l),{k:e.k,v:e.v},...sr(e.r)]}function Pa(e,t,n){if(Ze(e))return[];const{k:r,l:o,r:s,v:i}=e;let a=[];return r>t&&(a=a.concat(Pa(o,t,n))),r>=t&&r<=n&&a.push({k:r,v:i}),r<=n&&(a=a.concat(Pa(s,t,n))),a}function Ns(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(_a(t))return oh(vt(e,{lvl:n-1}));if(!Ze(t)&&!Ze(t.r))return vt(t.r,{l:vt(t,{r:t.r.l}),lvl:n,r:vt(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(_a(e))return Ma(vt(e,{lvl:n-1}));if(!Ze(r)&&!Ze(r.l)){const o=r.l,s=_a(o)?r.lvl-1:r.lvl;return vt(o,{l:vt(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:Ma(vt(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function vt(e,t){return nh(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 eh(e){return Ze(e.r)?e.l:Ns(vt(e,{r:eh(e.r)}))}function _a(e){return Ze(e)||e.lvl>e.r.lvl}function th(e){return Ze(e.r)?[e.k,e.v]:th(e.r)}function nh(e,t,n,r=po,o=po){return{k:e,l:r,lvl:n,r:o,v:t}}function rh(e){return Ma(oh(e))}function oh(e){const{l:t}=e;return!Ze(t)&&t.lvl===e.lvl?vt(t,{r:vt(e,{l:t.r})}):e}function Ma(e){const{lvl:t,r:n}=e;return!Ze(n)&&!Ze(n.r)&&n.lvl===t&&n.r.lvl===t?vt(n,{l:vt(e,{r:n.l}),lvl:t+1}):e}function WS(e){return Qf(e,({k:t,v:n})=>({index:t,value:n}))}function sh(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function go(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const Ra=Ke(()=>({recalcInProgress:se(!1)}),[],{singleton:!0});function ih(e,t,n){return e[As(e,t,n)]}function As(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 VS(e,t,n,r){const o=As(e,t,r),s=As(e,n,r,o);return e.slice(o,s+1)}function Un(e,t){return Math.round(e.getBoundingClientRect()[t])}function js(e){return!Ze(e.groupOffsetTree)}function Oa({index:e},t){return t===e?0:t<e?-1:1}function KS(){return{groupIndices:[],groupOffsetTree:Mr(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Mr()}}function qS(e,t){let n=Ze(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),Ze(e)){e=Zt(e,0,s);continue}const a=Is(e,i-1,o+1);if(a.some(eC(r)))continue;let l=!1,c=!1;for(const{end:d,start:h,value:m}of a)l?(o>=h||s===m)&&(e=ja(e,h)):(c=m!==s,l=!0),d>o&&o>=h&&m!==s&&(e=Zt(e,o+1,m));c&&(e=Zt(e,i,s))}return[e,n]}function GS(e){return typeof e.groupIndex<"u"}function YS({offset:e},t){return t===e?0:t<e?-1:1}function xo(e,t,n){if(t.length===0)return 0;const{index:r,offset:o,size:s}=ih(t,e,Oa),i=e-r,a=s*i+(i-1)*n+o;return a>0?a+n:a}function ah(e,t){if(!js(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function lh(e,t,n){if(GS(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=ah(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function XS(e,t,n,r=0){return r>0&&(t=Math.max(t,ih(e,r,Oa).offset)),Qf(VS(e,t,n,YS),QS)}function JS(e,[t,n,r,o]){t.length>0&&r("received item sizes",t,Ht.DEBUG);const s=e.sizeTree;let i=s,a=0;if(n.length>0&&Ze(s)&&t.length===2){const m=t[0].size,f=t[1].size;i=n.reduce((v,g)=>Zt(Zt(v,g,m),g+1,f),i)}else[i,a]=qS(i,t);if(i===s)return e;const{lastIndex:l,lastOffset:c,lastSize:d,offsetTree:h}=Da(e.offsetTree,a,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((m,f)=>Zt(m,f,xo(f,h,o)),Mr()),lastIndex:l,lastOffset:c,lastSize:d,offsetTree:h,sizeTree:i}}function ZS(e){return sr(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 ch(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 Da(e,t,n,r){let o=e,s=0,i=0,a=0,l=0;if(t!==0){l=As(o,t-1,Oa),a=o[l].offset;const c=fn(n,t-1);s=c[0],i=c[1],o.length&&o[l].size===fn(n,t)[1]&&(l-=1),o=o.slice(0,l+1)}else o=[];for(const{start:c,value:d}of Is(n,t,1/0)){const h=c-s,m=h*i+a+h*r;o.push({index:c,offset:m,size:d}),s=c,a=m,i=d}return{lastIndex:s,lastOffset:a,lastSize:i,offsetTree:o}}function QS(e){return{index:e.index,value:e}}function eC(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 tC={offsetHeight:"height",offsetWidth:"width"},kn=Ke(([{log:e},{recalcInProgress:t}])=>{const n=Be(),r=Be(),o=At(r,0),s=Be(),i=Be(),a=se(0),l=se([]),c=se(void 0),d=se(void 0),h=se((C,T)=>Un(C,tC[T])),m=se(void 0),f=se(0),v=KS(),g=At(ne(n,Le(l,e,f),Tn(JS,v),ot()),v),x=At(ne(l,ot(),Tn((C,T)=>({current:T,prev:C.current}),{current:[],prev:[]}),he(({prev:C})=>C)),[]);ve(ne(l,ke(C=>C.length>0),Le(g,f),he(([C,T,E])=>{const N=C.reduce((M,O,F)=>Zt(M,O,xo(O,T.offsetTree,E)||F),Mr());return{...T,groupIndices:C,groupOffsetTree:N}})),g),ve(ne(r,Le(g),ke(([C,{lastIndex:T}])=>C<T),he(([C,{lastIndex:T,lastSize:E}])=>[{endIndex:T,size:E,startIndex:C}])),n),ve(c,d);const y=At(ne(c,he(C=>C===void 0)),!0);ve(ne(d,ke(C=>C!==void 0&&Ze(ht(g).sizeTree)),he(C=>[{endIndex:0,size:C,startIndex:0}])),n);const w=Jt(ne(n,Le(g),Tn(({sizes:C},[T,E])=>({changed:E!==C,sizes:E}),{changed:!1,sizes:v}),he(C=>C.changed)));Ge(ne(a,Tn((C,T)=>({diff:C.prev-T,prev:T}),{diff:0,prev:0}),he(C=>C.diff)),C=>{const{groupIndices:T}=ht(g);if(C>0)Me(t,!0),Me(s,C+ch(C,T));else if(C<0){const E=ht(x);E.length>0&&(C-=ch(-C,E)),Me(i,C)}}),Ge(ne(a,Le(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},Ht.ERROR)});const S=Jt(s);ve(ne(s,Le(g),he(([C,T])=>{const E=T.groupIndices.length>0,N=[],M=T.lastSize;if(E){const O=mo(T.sizeTree,0);let F=0,G=0;for(;F<C;){const j=T.groupIndices[G],Y=T.groupIndices.length===G+1?1/0:T.groupIndices[G+1]-j-1;N.push({endIndex:j,size:O,startIndex:j}),N.push({endIndex:j+1+Y-1,size:M,startIndex:j+1}),G++,F+=Y+1}const K=sr(T.sizeTree);return F!==C&&K.shift(),K.reduce((j,{k:Y,v:q})=>{let z=j.ranges;return j.prevSize!==0&&(z=[...j.ranges,{endIndex:Y+C-1,size:j.prevSize,startIndex:j.prevIndex}]),{prevIndex:Y+C,prevSize:q,ranges:z}},{prevIndex:C,prevSize:0,ranges:N}).ranges}return sr(T.sizeTree).reduce((O,{k:F,v:G})=>({prevIndex:F+C,prevSize:G,ranges:[...O.ranges,{endIndex:F+C-1,size:O.prevSize,startIndex:O.prevIndex}]}),{prevIndex:0,prevSize:M,ranges:[]}).ranges})),n);const k=Jt(ne(i,Le(g,f),he(([C,{offsetTree:T},E])=>{const N=-C;return xo(N,T,E)})));return ve(ne(i,Le(g,f),he(([C,T,E])=>{if(T.groupIndices.length>0){if(Ze(T.sizeTree))return T;let N=Mr();const M=ht(x);let O=0,F=0,G=0;for(;O<-C;){G=M[F];const K=M[F+1]-G-1;F++,O+=K+1}if(N=sr(T.sizeTree).reduce((K,{k:j,v:Y})=>Zt(K,Math.max(0,j+C),Y),N),O!==-C){const K=mo(T.sizeTree,G);N=Zt(N,0,K);const j=fn(T.sizeTree,-C+1)[1];N=Zt(N,1,j)}return{...T,sizeTree:N,...Da(T.offsetTree,0,N,E)}}else{const N=sr(T.sizeTree).reduce((M,{k:O,v:F})=>Zt(M,Math.max(0,O+C),F),Mr());return{...T,sizeTree:N,...Da(T.offsetTree,0,N,E)}}})),g),{beforeUnshiftWith:S,data:m,defaultItemSize:d,firstItemIndex:a,fixedItemSize:c,gap:f,groupIndices:l,itemSize:h,listRefresh:w,shiftWith:i,shiftWithOffset:k,sizeRanges:n,sizes:g,statefulTotalCount:o,totalCount:r,trackItemSizes:y,unshiftWith:s}},rt(Hn,Ra),{singleton:!0});function nC(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const uh=Ke(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=Be(),i=Be(),a=Jt(ne(s,he(nC)));return ve(ne(a,he(l=>l.totalCount)),n),ve(ne(a,he(l=>l.groupIndices)),e),ve(ne(gt(o,t,r),ke(([l,c])=>js(c)),he(([l,c,d])=>fn(c.groupOffsetTree,Math.max(l-d,0),"v")[0]),ot(),he(l=>[l])),i),{groupCounts:s,topItemsIndexes:i}},rt(kn,Dt)),Wn=Ke(([{log:e}])=>{const t=se(!1),n=Jt(ne(t,ke(r=>r),ot()));return Ge(t,r=>{r&&ht(e)("props updated",{},Ht.DEBUG)}),{didMount:n,propsReady:t}},rt(Hn),{singleton:!0}),rC=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function dh(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!rC)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const vo=Ke(([{gap:e,listRefresh:t,sizes:n,totalCount:r},{fixedFooterHeight:o,fixedHeaderHeight:s,footerHeight:i,headerHeight:a,scrollingInProgress:l,scrollTo:c,smoothScrollTargetReached:d,viewportHeight:h},{log:m}])=>{const f=Be(),v=Be(),g=se(0);let x=null,y=null,w=null;function S(){x&&(x(),x=null),w&&(w(),w=null),y&&(clearTimeout(y),y=null),Me(l,!1)}return ve(ne(f,Le(n,h,r,g,a,i,m),Le(e,s,o),he(([[k,C,T,E,N,M,O,F],G,K,j])=>{const Y=dh(k),{align:q,behavior:z,offset:R}=Y,I=E-1,U=lh(Y,C,I);let J=xo(U,C.offsetTree,G)+M;q==="end"?(J+=K+fn(C.sizeTree,U)[1]-T+j,U===I&&(J+=O)):q==="center"?J+=(K+fn(C.sizeTree,U)[1]-T+j)/2:J-=N,R&&(J+=R);const _=P=>{S(),P?(F("retrying to scroll to",{location:k},Ht.DEBUG),Me(f,k)):(Me(v,!0),F("list did not change, scroll successful",{},Ht.DEBUG))};if(S(),z==="smooth"){let P=!1;w=Ge(t,D=>{P=P||D}),x=dn(d,()=>{_(P)})}else x=dn(ne(t,oC(150)),_);return y=setTimeout(()=>{S()},1200),Me(l,!0),F("scrolling from index to",{behavior:z,index:U,top:J},Ht.DEBUG),{behavior:z,top:J}})),c),{scrollTargetReached:v,scrollToIndex:f,topListHeight:g}},rt(kn,Dt,Hn),{singleton:!0});function oC(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function La(e,t){e==0?t():requestAnimationFrame(()=>{La(e-1,t)})}function $a(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const bo=Ke(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:s},{didMount:i}])=>{const a=se(!0),l=se(0),c=se(!0);return ve(ne(i,Le(l),ke(([d,h])=>!!h),Cn(!1)),a),ve(ne(i,Le(l),ke(([d,h])=>!!h),Cn(!1)),c),Ge(ne(gt(t,i),Le(a,n,e,c),ke(([[,d],h,{sizeTree:m},f,v])=>d&&(!Ze(m)||Ea(f))&&!h&&!v),Le(l)),([,d])=>{dn(o,()=>{Me(c,!0)}),La(4,()=>{dn(r,()=>{Me(a,!0)}),Me(s,d)})}),{initialItemFinalLocationReached:c,initialTopMostItemIndex:l,scrolledToInitialItem:a}},rt(kn,Dt,vo,Wn),{singleton:!0});function fh(e,t){return Math.abs(e-t)<1.01}const wo="up",yo="down",sC="none",iC={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},aC=0,So=Ke(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=se(!1),a=se(!0),l=Be(),c=Be(),d=se(4),h=se(aC),m=At(ne(Na(ne(Te(o),rr(1),Cn(!0)),ne(Te(o),rr(1),Cn(!1),Yf(100))),ot()),!1),f=At(ne(Na(ne(n,Cn(!0)),ne(n,Cn(!1),Yf(200))),ot()),!1);ve(ne(gt(Te(o),Te(h)),he(([w,S])=>w<=S),ot()),a),ve(ne(a,Pn(50)),c);const v=Jt(ne(gt(r,Te(s),Te(t),Te(e),Te(d)),Tn((w,[{scrollHeight:S,scrollTop:k},C,T,E,N])=>{const M=k+C-S>-N,O={scrollHeight:S,scrollTop:k,viewportHeight:C};if(M){let G,K;return k>w.state.scrollTop?(G="SCROLLED_DOWN",K=w.state.scrollTop-k):(G="SIZE_DECREASED",K=w.state.scrollTop-k||w.scrollTopDelta),{atBottom:!0,atBottomBecause:G,scrollTopDelta:K,state:O}}let F;return O.scrollHeight>w.state.scrollHeight?F="SIZE_INCREASED":C<w.state.viewportHeight?F="VIEWPORT_HEIGHT_DECREASING":k<w.state.scrollTop?F="SCROLLING_UPWARDS":F="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:F,state:O}},iC),ot((w,S)=>w&&w.atBottom===S.atBottom))),g=At(ne(r,Tn((w,{scrollHeight:S,scrollTop:k,viewportHeight:C})=>{if(fh(w.scrollHeight,S))return{changed:!1,jump:0,scrollHeight:S,scrollTop:k};{const T=S-(k+C)<1;return w.scrollTop!==k&&T?{changed:!0,jump:w.scrollTop-k,scrollHeight:S,scrollTop:k}:{changed:!0,jump:0,scrollHeight:S,scrollTop:k}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),ke(w=>w.changed),he(w=>w.jump)),0);ve(ne(v,he(w=>w.atBottom)),i),ve(ne(i,Pn(50)),l);const x=se(yo);ve(ne(r,he(({scrollTop:w})=>w),ot(),Tn((w,S)=>ht(f)?{direction:w.direction,prevScrollTop:S}:{direction:S<w.prevScrollTop?wo:yo,prevScrollTop:S},{direction:yo,prevScrollTop:0}),he(w=>w.direction)),x),ve(ne(r,Pn(50),Cn(sC)),x);const y=se(0);return ve(ne(m,ke(w=>!w),Cn(0)),y),ve(ne(o,Pn(100),Le(m),ke(([w,S])=>!!S),Tn(([w,S],[k])=>[S,k],[0,0]),he(([w,S])=>S-w)),y),{atBottomState:v,atBottomStateChange:l,atBottomThreshold:d,atTopStateChange:c,atTopThreshold:h,isAtBottom:i,isAtTop:a,isScrolling:m,lastJumpDueToItemResize:g,scrollDirection:x,scrollVelocity:y}},rt(Dt)),Ps="top",_s="bottom",hh="none";function ph(e,t,n){return typeof e=="number"?n===wo&&t===Ps||n===yo&&t===_s?e:0:n===wo?t===Ps?e.main:e.reverse:t===_s?e.main:e.reverse}function mh(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const Fa=Ke(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=Be(),i=se(0),a=se(0),l=se(0),c=At(ne(gt(Te(r),Te(o),Te(n),Te(s,go),Te(l),Te(i),Te(t),Te(e),Te(a)),he(([d,h,m,[f,v],g,x,y,w,S])=>{const k=d-w,C=x+y,T=Math.max(m-k,0);let E=hh;const N=mh(S,Ps),M=mh(S,_s);return f-=w,f+=m+y,v+=m+y,v-=w,f>d+C-N&&(E=wo),v<d-T+h+M&&(E=yo),E!==hh?[Math.max(k-m-ph(g,Ps,E)-N,0),k-T-y+h+ph(g,_s,E)+M]:null}),ke(d=>d!=null),ot(go)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:l,topListHeight:i,visibleRange:c}},rt(Dt),{singleton:!0});function lC(e,t,n){if(js(t)){const r=ah(e,t);return[{index:fn(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 Ba={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Ms(e,t,n,r,o,s){const{lastIndex:i,lastOffset:a,lastSize:l}=o;let c=0,d=0;if(e.length>0){c=e[0].offset;const g=e[e.length-1];d=g.offset+g.size}const h=n-i,m=a+h*l+(h-1)*r,f=c,v=m-d;return{bottom:d,firstItemIndex:s,items:xh(e,o,s),offsetBottom:v,offsetTop:c,top:f,topItems:xh(t,o,s),topListHeight:t.reduce((g,x)=>x.size+g,0),totalCount:n}}function gh(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=$a(t,a),c=Array.from({length:a}).map((d,h)=>({data:s[h+l],index:h+l,offset:0,size:0}));return Ms(c,[],a,o,n,r)}function xh(e,t,n){if(e.length===0)return[];if(!js(t))return e.map(c=>({...c,index:c.index+n,originalIndex:c.index}));const r=e[0].index,o=e[e.length-1].index,s=[],i=Is(t.groupOffsetTree,r,o);let a,l=0;for(const c of e){(!a||a.end<c.index)&&(a=i.shift(),l=t.groupIndices.indexOf(a.start));let d;c.index===a.start?d={index:l,type:"group"}:d={groupIndex:l,index:c.index-(l+1)+n},s.push({...d,data:c.data,offset:c.offset,originalIndex:c.index,size:c.size})}return s}const ir=Ke(([{data:e,firstItemIndex:t,gap:n,sizes:r,totalCount:o},s,{listBoundary:i,topListHeight:a,visibleRange:l},{initialTopMostItemIndex:c,scrolledToInitialItem:d},{topListHeight:h},m,{didMount:f},{recalcInProgress:v}])=>{const g=se([]),x=se(0),y=Be();ve(s.topItemsIndexes,g);const w=At(ne(gt(f,v,Te(l,go),Te(o),Te(r),Te(c),d,Te(g),Te(t),Te(n),e),ke(([T,E,,N,,,,,,,M])=>{const O=M&&M.length!==N;return T&&!E&&!O}),he(([,,[T,E],N,M,O,F,G,K,j,Y])=>{const q=M,{offsetTree:z,sizeTree:R}=q,I=ht(x);if(N===0)return{...Ba,totalCount:N};if(T===0&&E===0)return I===0?{...Ba,totalCount:N}:gh(I,O,M,K,j,Y||[]);if(Ze(R))return I>0?null:Ms(lC($a(O,N),q,Y),[],N,j,q,K);const U=[];if(G.length>0){const $=G[0],ee=G[G.length-1];let H=0;for(const L of Is(R,$,ee)){const Z=L.value,te=Math.max(L.start,$),Q=Math.min(L.end,ee);for(let W=te;W<=Q;W++)U.push({data:Y==null?void 0:Y[W],index:W,offset:H,size:Z}),H+=Z}}if(!F)return Ms([],U,N,j,q,K);const J=G.length>0?G[G.length-1]+1:0,_=XS(z,T,E,J);if(_.length===0)return null;const P=N-1,D=Es([],$=>{for(const ee of _){const H=ee.value;let L=H.offset,Z=ee.start;const te=H.size;if(H.offset<T){Z+=Math.floor((T-H.offset+j)/(te+j));const W=Z-ee.start;L+=W*te+W*j}Z<J&&(L+=(J-Z)*te,Z=J);const Q=Math.min(ee.end,P);for(let W=Z;W<=Q&&!(L>=E);W++)$.push({data:Y==null?void 0:Y[W],index:W,offset:L,size:te}),L+=te+j}});return Ms(D,U,N,j,q,K)}),ke(T=>T!==null),ot()),Ba);ve(ne(e,ke(Ea),he(T=>T==null?void 0:T.length)),o),ve(ne(w,he(T=>T.topListHeight)),h),ve(h,a),ve(ne(w,he(T=>[T.top,T.bottom])),i),ve(ne(w,he(T=>T.items)),y);const S=Jt(ne(w,ke(({items:T})=>T.length>0),Le(o,e),ke(([{items:T},E])=>T[T.length-1].originalIndex===E-1),he(([,T,E])=>[T-1,E]),ot(go),he(([T])=>T))),k=Jt(ne(w,Pn(200),ke(({items:T,topItems:E})=>T.length>0&&T[0].originalIndex===E.length),he(({items:T})=>T[0].index),ot())),C=Jt(ne(w,ke(({items:T})=>T.length>0),he(({items:T})=>{let E=0,N=T.length-1;for(;T[E].type==="group"&&E<N;)E++;for(;T[N].type==="group"&&N>E;)N--;return{endIndex:T[N].index,startIndex:T[E].index}}),ot(sh)));return{endReached:S,initialItemCount:x,itemsRendered:y,listState:w,rangeChanged:C,startReached:k,topItemsIndexes:g,...m}},rt(kn,uh,Fa,bo,vo,So,Wn,Ra),{singleton:!0}),vh=Ke(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=Be(),i=At(ne(gt(n,e,r,t,o),he(([a,l,c,d,h])=>a+l+c+d+h.offsetBottom+h.bottom)),0);return ve(Te(i),s),{totalListHeight:i,totalListHeightChanged:s}},rt(Dt,ir),{singleton:!0}),cC=Ke(([{viewportHeight:e},{totalListHeight:t}])=>{const n=se(!1),r=At(ne(gt(n,e,t),ke(([o])=>o),he(([,o,s])=>Math.max(0,o-s)),Pn(0),ot()),0);return{alignToBottom:n,paddingTopAddition:r}},rt(Dt,vh),{singleton:!0}),bh=Ke(()=>({context:se(null)})),uC=({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,wh=Ke(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:s,scrollingInProgress:i,scrollTop:a,viewportHeight:l},{scrollToIndex:c}])=>{const d=Be();return ve(ne(d,Le(t,l,n,s,o,r,a),Le(e),he(([[h,m,f,v,g,x,y,w],S])=>{const{align:k,behavior:C,calculateViewLocation:T=uC,done:E,...N}=h,M=lh(h,m,v-1),O=xo(M,m.offsetTree,S)+g+x,F=O+fn(m.sizeTree,M)[1],G=w+x,K=w+f-y,j=T({itemBottom:F,itemTop:O,locationParams:{align:k,behavior:C,...N},viewportBottom:K,viewportTop:G});return j?E&&dn(ne(i,ke(Y=>!Y),rr(ht(i)?1:2)),E):E&&E(),j}),ke(h=>h!==null)),c),{scrollIntoView:d}},rt(kn,Dt,vo,ir,Hn),{singleton:!0});function yh(e){return e?e==="smooth"?"smooth":"auto":!1}const dC=(e,t)=>typeof e=="function"?yh(e(t)):t&&yh(e),fC=Ke(([{listRefresh:e,totalCount:t,fixedItemSize:n,data:r},{atBottomState:o,isAtBottom:s},{scrollToIndex:i},{scrolledToInitialItem:a},{didMount:l,propsReady:c},{log:d},{scrollingInProgress:h},{context:m},{scrollIntoView:f}])=>{const v=se(!1),g=Be();let x=null;function y(C){Me(i,{align:"end",behavior:C,index:"LAST"})}Ge(ne(gt(ne(Te(t),rr(1)),l),Le(Te(v),s,a,h),he(([[C,T],E,N,M,O])=>{let F=T&&M,G="auto";return F&&(G=dC(E,N||O),F=F&&!!G),{followOutputBehavior:G,shouldFollow:F,totalCount:C}}),ke(({shouldFollow:C})=>C)),({followOutputBehavior:C,totalCount:T})=>{x&&(x(),x=null),ht(n)?requestAnimationFrame(()=>{ht(d)("following output to ",{totalCount:T},Ht.DEBUG),y(C)}):x=dn(e,()=>{ht(d)("following output to ",{totalCount:T},Ht.DEBUG),y(C),x=null})});function w(C){const T=dn(o,E=>{C&&!E.atBottom&&E.notAtBottomBecause==="SIZE_INCREASED"&&!x&&(ht(d)("scrolling to bottom due to increased size",{},Ht.DEBUG),y("auto"))});setTimeout(T,100)}Ge(ne(gt(Te(v),t,c),ke(([C,,T])=>C&&T),Tn(({value:C},[,T])=>({refreshed:C===T,value:T}),{refreshed:!1,value:0}),ke(({refreshed:C})=>C),Le(v,t)),([,C])=>{ht(a)&&w(C!==!1)}),Ge(g,()=>{w(ht(v)!==!1)}),Ge(gt(Te(v),o),([C,T])=>{C&&!T.atBottom&&T.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&y("auto")});const S=se(null),k=Be();return ve(Na(ne(Te(r),he(C=>{var T;return(T=C==null?void 0:C.length)!=null?T:0})),ne(Te(t))),k),Ge(ne(gt(ne(k,rr(1)),l),Le(Te(S),a,h,m),he(([[C,T],E,N,M,O])=>T&&N&&(E==null?void 0:E({context:O,totalCount:C,scrollingInProgress:M}))),ke(C=>!!C),Pn(0)),C=>{x&&(x(),x=null),ht(n)?requestAnimationFrame(()=>{ht(d)("scrolling into view",{}),Me(f,C)}):x=dn(e,()=>{ht(d)("scrolling into view",{}),Me(f,C),x=null})}),{autoscrollToBottom:g,followOutput:v,scrollIntoViewOnChange:S}},rt(kn,So,vo,bo,Wn,Hn,Dt,bh,wh)),hC=Ke(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(ve(ne(a,Le(s),ke(([,l])=>l!==0),Le(o,r,t,n,e),he(([[,l],c,d,h,m,f=[]])=>gh(l,c,d,h,m,f))),i),{}),rt(kn,bo,ir,Wn),{singleton:!0}),pC=Ke(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=se(0);return Ge(ne(e,Le(r),ke(([,o])=>o!==0),he(([,o])=>({top:o}))),o=>{dn(ne(n,rr(1),ke(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{Me(t,o)})})}),{initialScrollTop:r}},rt(Wn,Dt,ir),{singleton:!0}),Sh=Ke(([{scrollVelocity:e}])=>{const t=se(!1),n=Be(),r=se(!1);return ve(ne(e,Le(r,t,n),ke(([o,s])=>!!s),he(([o,s,i,a])=>{const{enter:l,exit:c}=s;if(i){if(c(o,a))return!1}else if(l(o,a))return!0;return i}),ot()),t),Ge(ne(gt(t,e,n),Le(r)),([[o,s,i],a])=>{o&&a&&a.change&&a.change(s,i)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},rt(So),{singleton:!0}),za=Ke(([{scrollContainerState:e,scrollTo:t}])=>{const n=Be(),r=Be(),o=Be(),s=se(!1),i=se(void 0);return ve(ne(gt(n,r),he(([{scrollHeight:a,scrollTop:l,viewportHeight:c},{offsetTop:d}])=>({scrollHeight:a,scrollTop:Math.max(0,l-d),viewportHeight:c}))),e),ve(ne(t,Le(r),he(([a,{offsetTop:l}])=>({...a,top:a.top+l}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},rt(Dt)),mC=Ke(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:a,windowViewportRect:l}])=>{const c=Be(),d=se(void 0),h=se(null),m=se(null);return ve(a,h),ve(l,m),Ge(ne(c,Le(t,r,i,h,m,n)),([f,v,g,x,y,w,S])=>{const k=ZS(v.sizeTree);x&&y!==null&&w!==null&&(g=y.scrollTop-w.offsetTop),g-=S,f({ranges:k,scrollTop:g})}),ve(ne(d,ke(Ea),he(gC)),o),ve(ne(s,Le(d),ke(([,f])=>f!==void 0),ot(),he(([,f])=>f.ranges)),e),{getState:c,restoreStateFrom:d}},rt(kn,Dt,bo,Wn,za));function gC(e){return{align:"start",index:0,offset:e.scrollTop}}const xC=Ke(([{topItemsIndexes:e}])=>{const t=se(0);return ve(ne(t,ke(n=>n>=0),he(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},rt(ir));function Ch(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const vC=Ch(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),bC=Ke(([{deviation:e,scrollBy:t,scrollingInProgress:n,scrollTop:r},{isAtBottom:o,isScrolling:s,lastJumpDueToItemResize:i,scrollDirection:a},{listState:l},{beforeUnshiftWith:c,gap:d,shiftWithOffset:h,sizes:m},{log:f},{recalcInProgress:v}])=>{const g=Jt(ne(l,Le(i),Tn(([,y,w,S],[{bottom:k,items:C,offsetBottom:T,totalCount:E},N])=>{const M=k+T;let O=0;return w===E&&y.length>0&&C.length>0&&(C[0].originalIndex===0&&y[0].originalIndex===0||(O=M-S,O!==0&&(O+=N))),[O,C,E,M]},[0,[],0,0]),ke(([y])=>y!==0),Le(r,a,n,o,f,v),ke(([,y,w,S,,,k])=>!k&&!S&&y!==0&&w===wo),he(([[y],,,,,w])=>(w("Upward scrolling compensation",{amount:y},Ht.DEBUG),y))));function x(y){y>0?(Me(t,{behavior:"auto",top:-y}),Me(e,0)):(Me(e,0),Me(t,{behavior:"auto",top:-y}))}return Ge(ne(g,Le(e,s)),([y,w,S])=>{S&&vC()?Me(e,w-y):x(-y)}),Ge(ne(gt(At(s,!1),e,v),ke(([y,w,S])=>!y&&!S&&w!==0),he(([y,w])=>w),Pn(1)),x),ve(ne(h,he(y=>({top:-y}))),t),Ge(ne(c,Le(m,d),he(([y,{groupIndices:w,lastSize:S,sizeTree:k},C])=>{function T(E){return E*(S+C)}if(w.length===0)return T(y);{let E=0;const N=mo(k,0);let M=0,O=0;for(;M<y;){M++,E+=N;let F=w.length===O+1?1/0:w[O+1]-w[O]-1;M+F>y&&(E-=N,F=y-M+1),M+=F,E+=T(F),O++}return E}})),y=>{Me(e,y),requestAnimationFrame(()=>{Me(t,{top:y}),requestAnimationFrame(()=>{Me(e,0),Me(v,!1)})})}),{deviation:e}},rt(Dt,So,ir,kn,Hn,Ra)),wC=Ke(([e,t,n,r,o,s,i,a,l,c,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...l,...c,...d}),rt(Fa,hC,Wn,Sh,vh,pC,cC,za,wh,Hn,bh)),Th=Ke(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:r,gap:o,groupIndices:s,itemSize:i,sizeRanges:a,sizes:l,statefulTotalCount:c,totalCount:d,trackItemSizes:h},{initialItemFinalLocationReached:m,initialTopMostItemIndex:f,scrolledToInitialItem:v},g,x,y,{listState:w,topItemsIndexes:S,...k},{scrollToIndex:C},T,{topItemCount:E},{groupCounts:N},M])=>(ve(k.rangeChanged,M.scrollSeekRangeChanged),ve(ne(M.windowViewportRect,he(O=>O.visibleHeight)),g.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,gap:o,groupCounts:N,initialItemFinalLocationReached:m,initialTopMostItemIndex:f,scrolledToInitialItem:v,sizeRanges:a,topItemCount:E,topItemsIndexes:S,totalCount:d,...y,groupIndices:s,itemSize:i,listState:w,scrollToIndex:C,statefulTotalCount:c,trackItemSizes:h,...k,...M,...g,sizes:l,...x}),rt(kn,bo,Dt,mC,fC,ir,vo,bC,xC,uh,wC));function yC(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 Rs=typeof document<"u"?b.useLayoutEffect:b.useEffect;function kh(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=b.createContext({});function l(x,y){x.propsReady&&Me(x.propsReady,!1);for(const w of r){const S=x[t.required[w]];Me(S,y[w])}for(const w of o)if(w in y){const S=x[t.optional[w]];Me(S,y[w])}x.propsReady&&Me(x.propsReady,!0)}function c(x){return s.reduce((y,w)=>(y[w]=S=>{const k=x[t.methods[w]];Me(k,S)},y),{})}function d(x){return i.reduce((y,w)=>(y[w]=LS(x[t.events[w]]),y),{})}const h=b.forwardRef((x,y)=>{const{children:w,...S}=x,[k]=b.useState(()=>Es(FS(e),E=>{l(E,S)})),[C]=b.useState(Gf(d,k));Rs(()=>{for(const E of i)E in S&&Ge(C[E],S[E]);return()=>{Object.values(C).map(Ia)}},[S,C,k]),Rs(()=>{l(k,S)}),b.useImperativeHandle(y,Kf(c(k)));const T=n;return u.jsx(a.Provider,{value:k,children:n?u.jsx(T,{...yC([...r,...o,...i],S),children:w}):w})}),m=x=>{const y=b.useContext(a);return b.useCallback(w=>{Me(y[x],w)},[y,x])},f=x=>{const y=b.useContext(a)[x],w=b.useCallback(S=>Ge(y,S),[y]);return b.useSyncExternalStore(w,()=>ht(y),()=>ht(y))},v=x=>{const y=b.useContext(a)[x],[w,S]=b.useState(Gf(ht,y));return Rs(()=>Ge(y,k=>{k!==w&&S(Kf(k))}),[y,w]),w},g=b.version.startsWith("18")?f:v;return{Component:h,useEmitter:(x,y)=>{const w=b.useContext(a)[x];Rs(()=>Ge(w,y),[y,w])},useEmitterValue:g,usePublisher:m}}const Eh=b.createContext(void 0),Ih=b.createContext(void 0),Nh=typeof document<"u"?b.useLayoutEffect:b.useEffect;function Ha(e){return"self"in e}function SC(e){return"body"in e}function Ah(e,t,n,r=_r,o,s){const i=b.useRef(null),a=b.useRef(null),l=b.useRef(null),c=b.useCallback(m=>{let f,v,g;const x=m.target;if(SC(x)||Ha(x)){const w=Ha(x)?x:x.defaultView;g=s?w.scrollX:w.scrollY,f=s?w.document.documentElement.scrollWidth:w.document.documentElement.scrollHeight,v=s?w.innerWidth:w.innerHeight}else g=s?x.scrollLeft:x.scrollTop,f=s?x.scrollWidth:x.scrollHeight,v=s?x.offsetWidth:x.offsetHeight;const y=()=>{e({scrollHeight:f,scrollTop:Math.max(g,0),viewportHeight:v})};m.suppressFlushSync?y():Mo.flushSync(y),a.current!==null&&(g===a.current||g<=0||g===f-v)&&(a.current=null,t(!0),l.current&&(clearTimeout(l.current),l.current=null))},[e,t,s]);b.useEffect(()=>{const m=o||i.current;return r(o||i.current),c({suppressFlushSync:!0,target:m}),m.addEventListener("scroll",c,{passive:!0}),()=>{r(null),m.removeEventListener("scroll",c)}},[i,c,n,r,o]);function d(m){const f=i.current;if(!f||(s?"offsetWidth"in f&&f.offsetWidth===0:"offsetHeight"in f&&f.offsetHeight===0))return;const v=m.behavior==="smooth";let g,x,y;Ha(f)?(x=Math.max(Un(f.document.documentElement,s?"width":"height"),s?f.document.documentElement.scrollWidth:f.document.documentElement.scrollHeight),g=s?f.innerWidth:f.innerHeight,y=s?window.scrollX:window.scrollY):(x=f[s?"scrollWidth":"scrollHeight"],g=Un(f,s?"width":"height"),y=f[s?"scrollLeft":"scrollTop"]);const w=x-g;if(m.top=Math.ceil(Math.max(Math.min(w,m.top),0)),fh(g,x)||m.top===y){e({scrollHeight:x,scrollTop:y,viewportHeight:g}),v&&t(!0);return}v?(a.current=m.top,l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{l.current=null,a.current=null,t(!0)},1e3)):a.current=null,s&&(m={behavior:m.behavior,left:m.top}),f.scrollTo(m)}function h(m){s&&(m={behavior:m.behavior,left:m.top}),i.current.scrollBy(m)}return{scrollByCallback:h,scrollerRef:i,scrollToCallback:d}}const Ua="-webkit-sticky",jh="sticky",Wa=Ch(()=>{if(typeof document>"u")return jh;const e=document.createElement("div");return e.style.position=Ua,e.style.position===Ua?Ua:jh});function Va(e){return e}const CC=Ke(()=>{const e=se(a=>`Item ${a}`),t=se(a=>`Group ${a}`),n=se({}),r=se(Va),o=se("div"),s=se(_r),i=(a,l=null)=>At(ne(n,he(c=>c[a]),ot()),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")}}),TC=Ke(([e,t])=>({...e,...t}),rt(Th,CC)),kC=({height:e})=>u.jsx("div",{style:{height:e}}),EC={overflowAnchor:"none",position:Wa(),zIndex:1},Ph={overflowAnchor:"none"},IC={...Ph,display:"inline-block",height:"100%"},_h=b.memo(function({showTopList:e=!1}){const t=Ne("listState"),n=tn("sizeRanges"),r=Ne("useWindowScroll"),o=Ne("customScrollParent"),s=tn("windowScrollContainerState"),i=tn("scrollContainerState"),a=o||r?s:i,l=Ne("itemContent"),c=Ne("context"),d=Ne("groupContent"),h=Ne("trackItemSizes"),m=Ne("itemSize"),f=Ne("log"),v=tn("gap"),g=Ne("horizontalDirection"),{callbackRef:x}=HS(n,m,h,e?_r:a,f,v,o,g,Ne("skipAnimationFrameInResizeObserver")),[y,w]=b.useState(0);Ka("deviation",j=>{y!==j&&w(j)});const S=Ne("EmptyPlaceholder"),k=Ne("ScrollSeekPlaceholder")||kC,C=Ne("ListComponent"),T=Ne("ItemComponent"),E=Ne("GroupComponent"),N=Ne("computeItemKey"),M=Ne("isSeeking"),O=Ne("groupIndices").length>0,F=Ne("alignToBottom"),G=Ne("initialItemFinalLocationReached"),K=e?{}:{boxSizing:"border-box",...g?{display:"inline-block",height:"100%",marginLeft:y!==0?y:F?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:y!==0?y:F?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...G?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&S?u.jsx(S,{...jt(S,c)}):u.jsx(C,{...jt(C,c),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:x,style:K,children:(e?t.topItems:t.items).map(j=>{const Y=j.originalIndex,q=N(Y+t.firstItemIndex,j.data,c);return M?b.createElement(k,{...jt(k,c),height:j.size,index:j.index,key:q,type:j.type||"item",...j.type==="group"?{}:{groupIndex:j.groupIndex}}):j.type==="group"?b.createElement(E,{...jt(E,c),"data-index":Y,"data-item-index":j.index,"data-known-size":j.size,key:q,style:EC},d(j.index,c)):b.createElement(T,{...jt(T,c),...PC(T,j.data),"data-index":Y,"data-item-group-index":j.groupIndex,"data-item-index":j.index,"data-known-size":j.size,key:q,style:g?IC:Ph},O?l(j.index,j.groupIndex,j.data,c):l(j.index,j.data,c))})})}),NC={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},AC={outline:"none",overflowX:"auto",position:"relative"},Os=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),jC={position:Wa(),top:0,width:"100%",zIndex:1};function jt(e,t){if(typeof e!="string")return{context:t}}function PC(e,t){return{item:typeof e=="string"?void 0:t}}const _C=b.memo(function(){const e=Ne("HeaderComponent"),t=tn("headerHeight"),n=Ne("HeaderFooterTag"),r=or(b.useMemo(()=>s=>{t(Un(s,"height"))},[t]),!0,Ne("skipAnimationFrameInResizeObserver")),o=Ne("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...jt(e,o)})}):null}),MC=b.memo(function(){const e=Ne("FooterComponent"),t=tn("footerHeight"),n=Ne("HeaderFooterTag"),r=or(b.useMemo(()=>s=>{t(Un(s,"height"))},[t]),!0,Ne("skipAnimationFrameInResizeObserver")),o=Ne("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...jt(e,o)})}):null});function Mh({useEmitter:e,useEmitterValue:t,usePublisher:n}){return b.memo(function({children:r,style:o,context:s,...i}){const a=n("scrollContainerState"),l=t("ScrollerComponent"),c=n("smoothScrollTargetReached"),d=t("scrollerRef"),h=t("horizontalDirection")||!1,{scrollByCallback:m,scrollerRef:f,scrollToCallback:v}=Ah(a,c,l,d,void 0,h);return e("scrollTo",v),e("scrollBy",m),u.jsx(l,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:f,style:{...h?AC:NC,...o},tabIndex:0,...i,...jt(l,s),children:r})})}function Rh({useEmitter:e,useEmitterValue:t,usePublisher:n}){return b.memo(function({children:r,style:o,context:s,...i}){const a=n("windowScrollContainerState"),l=t("ScrollerComponent"),c=n("smoothScrollTargetReached"),d=t("totalListHeight"),h=t("deviation"),m=t("customScrollParent"),f=b.useRef(null),v=t("scrollerRef"),{scrollByCallback:g,scrollerRef:x,scrollToCallback:y}=Ah(a,c,l,v,m);return Nh(()=>{var w;return x.current=m||((w=f.current)==null?void 0:w.ownerDocument.defaultView),()=>{x.current=null}},[x,m]),e("windowScrollTo",y),e("scrollBy",g),u.jsx(l,{ref:f,"data-virtuoso-scroller":!0,style:{position:"relative",...o,...d!==0?{height:d+h}:{}},...i,...jt(l,s),children:r})})}const RC=({children:e})=>{const t=b.useContext(Eh),n=tn("viewportHeight"),r=tn("fixedItemHeight"),o=Ne("alignToBottom"),s=Ne("horizontalDirection"),i=b.useMemo(()=>qf(n,l=>Un(l,s?"width":"height")),[n,s]),a=or(i,!0,Ne("skipAnimationFrameInResizeObserver"));return b.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),u.jsx("div",{"data-viewport-type":"element",ref:a,style:Os(o),children:e})},OC=({children:e})=>{const t=b.useContext(Eh),n=tn("windowViewportRect"),r=tn("fixedItemHeight"),o=Ne("customScrollParent"),s=Zf(n,o,Ne("skipAnimationFrameInResizeObserver")),i=Ne("alignToBottom");return b.useEffect(()=>{t&&(r(t.itemHeight),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),u.jsx("div",{"data-viewport-type":"window",ref:s,style:Os(i),children:e})},DC=({children:e})=>{const t=Ne("TopItemListComponent")||"div",n=Ne("headerHeight"),r={...jC,marginTop:`${n}px`},o=Ne("context");return u.jsx(t,{style:r,...jt(t,o),children:e})},LC=b.memo(function(e){const t=Ne("useWindowScroll"),n=Ne("topItemsIndexes").length>0,r=Ne("customScrollParent"),o=Ne("context");return u.jsxs(r||t?BC:FC,{...e,context:o,children:[n&&u.jsx(DC,{children:u.jsx(_h,{showTopList:!0})}),u.jsxs(r||t?OC:RC,{children:[u.jsx(_C,{}),u.jsx(_h,{}),u.jsx(MC,{})]})]})}),{Component:$C,useEmitter:Ka,useEmitterValue:Ne,usePublisher:tn}=kh(TC,{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"}},LC),FC=Mh({useEmitter:Ka,useEmitterValue:Ne,usePublisher:tn}),BC=Rh({useEmitter:Ka,useEmitterValue:Ne,usePublisher:tn}),zC=$C;rt(Th,Ke(()=>{const e=se(c=>u.jsxs("td",{children:["Item $",c]})),t=se(null),n=se(c=>u.jsxs("td",{colSpan:1e3,children:["Group ",c]})),r=se(null),o=se(null),s=se({}),i=se(Va),a=se(_r),l=(c,d=null)=>At(ne(s,he(h=>h[c]),ot()),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")}})),Wa();const Oh={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},HC={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:Dh,floor:Ds,max:Co,min:qa,round:Lh}=Math;function $h(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function UC(e){return{...HC,items:e}}function Ls(e,t){return e&&e.width===t.width&&e.height===t.height}function WC(e,t){return e&&e.column===t.column&&e.row===t.row}const VC=Ke(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:r},{footerHeight:o,headerHeight:s,scrollBy:i,scrollContainerState:a,scrollTo:l,scrollTop:c,smoothScrollTargetReached:d,viewportHeight:h},m,f,{didMount:v,propsReady:g},{customScrollParent:x,useWindowScroll:y,windowScrollContainerState:w,windowScrollTo:S,windowViewportRect:k},C])=>{const T=se(0),E=se(0),N=se(Oh),M=se({height:0,width:0}),O=se({height:0,width:0}),F=Be(),G=Be(),K=se(0),j=se(null),Y=se({column:0,row:0}),q=Be(),z=Be(),R=se(!1),I=se(0),U=se(!0),J=se(!1),_=se(!1);Ge(ne(v,Le(I),ke(([L,Z])=>!!Z)),()=>{Me(U,!1)}),Ge(ne(gt(v,U,O,M,I,J),ke(([L,Z,te,Q,,W])=>L&&!Z&&te.height!==0&&Q.height!==0&&!W)),([,,,,L])=>{Me(J,!0),La(1,()=>{Me(F,L)}),dn(ne(c),()=>{Me(t,[0,0]),Me(U,!0)})}),ve(ne(z,ke(L=>L!=null&&L.scrollTop>0),Cn(0)),E),Ge(ne(v,Le(z),ke(([,L])=>L!=null)),([,L])=>{L&&(Me(M,L.viewport),Me(O,L.item),Me(Y,L.gap),L.scrollTop>0&&(Me(R,!0),dn(ne(c,rr(1)),Z=>{Me(R,!1)}),Me(l,{top:L.scrollTop})))}),ve(ne(M,he(({height:L})=>L)),h),ve(ne(gt(Te(M,Ls),Te(O,Ls),Te(Y,(L,Z)=>L&&L.column===Z.column&&L.row===Z.row),Te(c)),he(([L,Z,te,Q])=>({gap:te,item:Z,scrollTop:Q,viewport:L}))),q),ve(ne(gt(Te(T),r,Te(Y,WC),Te(O,Ls),Te(M,Ls),Te(j),Te(E),Te(R),Te(U),Te(I)),ke(([,,,,,,,L])=>!L),he(([L,[Z,te],Q,W,le,ie,ge,,we,Ce])=>{const{column:Ae,row:Ee}=Q,{height:st,width:lt}=W,{width:St}=le;if(ge===0&&(L===0||St===0))return Oh;if(lt===0){const Et=$a(Ce,L),bt=Et+Math.max(ge-1,0);return UC($h(Et,bt,ie))}const Oe=Fh(St,lt,Ae);let qe,We;we?Z===0&&te===0&&ge>0?(qe=0,We=ge-1):(qe=Oe*Ds((Z+Ee)/(st+Ee)),We=Oe*Dh((te+Ee)/(st+Ee))-1,We=qa(L-1,Co(We,Oe-1)),qe=qa(We,Co(0,qe))):(qe=0,We=-1);const je=$h(qe,We,ie),{bottom:_e,top:ct}=Bh(le,Q,W,je),kt=Dh(L/Oe),nt=kt*st+(kt-1)*Ee-_e;return{bottom:_e,itemHeight:st,items:je,itemWidth:lt,offsetBottom:nt,offsetTop:ct,top:ct}})),N),ve(ne(j,ke(L=>L!==null),he(L=>L.length)),T),ve(ne(gt(M,O,N,Y),ke(([L,Z,{items:te}])=>te.length>0&&Z.height!==0&&L.height!==0),he(([L,Z,{items:te},Q])=>{const{bottom:W,top:le}=Bh(L,Q,Z,te);return[le,W]}),ot(go)),t);const P=se(!1);ve(ne(c,Le(P),he(([L,Z])=>Z||L!==0)),P);const D=Jt(ne(gt(N,T),ke(([{items:L}])=>L.length>0),Le(P),ke(([[L,Z],te])=>{const Q=L.items[L.items.length-1].index===Z-1;return(te||L.bottom>0&&L.itemHeight>0&&L.offsetBottom===0&&L.items.length===Z)&&Q}),he(([[,L]])=>L-1),ot())),$=Jt(ne(Te(N),ke(({items:L})=>L.length>0&&L[0].index===0),Cn(0),ot())),ee=Jt(ne(Te(N),Le(R),ke(([{items:L},Z])=>L.length>0&&!Z),he(([{items:L}])=>({endIndex:L[L.length-1].index,startIndex:L[0].index})),ot(sh),Pn(0)));ve(ee,f.scrollSeekRangeChanged),ve(ne(F,Le(M,O,T,Y),he(([L,Z,te,Q,W])=>{const le=dh(L),{align:ie,behavior:ge,offset:we}=le;let Ce=le.index;Ce==="LAST"&&(Ce=Q-1),Ce=Co(0,Ce,qa(Q-1,Ce));let Ae=Ga(Z,W,te,Ce);return ie==="end"?Ae=Lh(Ae-Z.height+te.height):ie==="center"&&(Ae=Lh(Ae-Z.height/2+te.height/2)),we&&(Ae+=we),{behavior:ge,top:Ae}})),l);const H=At(ne(N,he(L=>L.offsetBottom+L.bottom)),0);return ve(ne(k,he(L=>({height:L.visibleHeight,width:L.visibleWidth}))),M),{customScrollParent:x,data:j,deviation:K,footerHeight:o,gap:Y,headerHeight:s,increaseViewportBy:e,initialItemCount:E,itemDimensions:O,overscan:n,restoreStateFrom:z,scrollBy:i,scrollContainerState:a,scrollHeight:G,scrollTo:l,scrollToIndex:F,scrollTop:c,smoothScrollTargetReached:d,totalCount:T,useWindowScroll:y,viewportDimensions:M,windowScrollContainerState:w,windowScrollTo:S,windowViewportRect:k,...f,gridState:N,horizontalDirection:_,initialTopMostItemIndex:I,totalListHeight:H,...m,endReached:D,propsReady:g,rangeChanged:ee,startReached:$,stateChanged:q,stateRestoreInProgress:R,...C}},rt(Fa,Dt,So,Sh,Wn,za,Hn));function Fh(e,t,n){return Co(1,Ds((e+n)/(Ds(t)+n)))}function Bh(e,t,n,r){const{height:o}=n;if(o===void 0||r.length===0)return{bottom:0,top:0};const s=Ga(e,t,n,r[0].index);return{bottom:Ga(e,t,n,r[r.length-1].index)+o,top:s}}function Ga(e,t,n,r){const o=Fh(e.width,n.width,t.column),s=Ds(r/o),i=s*n.height+Co(0,s-1)*t.row;return i>0?i+t.row:i}const KC=Ke(()=>{const e=se(h=>`Item ${h}`),t=se({}),n=se(null),r=se("virtuoso-grid-item"),o=se("virtuoso-grid-list"),s=se(Va),i=se("div"),a=se(_r),l=(h,m=null)=>At(ne(t,he(f=>f[h]),ot()),m),c=se(!1),d=se(!1);return ve(Te(d),c),{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:c,reportReadyState:d,ScrollerComponent:l("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder","div")}}),qC=Ke(([e,t])=>({...e,...t}),rt(VC,KC)),GC=b.memo(function(){const e=at("gridState"),t=at("listClassName"),n=at("itemClassName"),r=at("itemContent"),o=at("computeItemKey"),s=at("isSeeking"),i=nn("scrollHeight"),a=at("ItemComponent"),l=at("ListComponent"),c=at("ScrollSeekPlaceholder"),d=at("context"),h=nn("itemDimensions"),m=nn("gap"),f=at("log"),v=at("stateRestoreInProgress"),g=nn("reportReadyState"),x=or(b.useMemo(()=>y=>{const w=y.parentElement.parentElement.scrollHeight;i(w);const S=y.firstChild;if(S){const{height:k,width:C}=S.getBoundingClientRect();h({height:k,width:C})}m({column:Hh("column-gap",getComputedStyle(y).columnGap,f),row:Hh("row-gap",getComputedStyle(y).rowGap,f)})},[i,h,m,f]),!0,!1);return Nh(()=>{e.itemHeight>0&&e.itemWidth>0&&g(!0)},[e]),v?null:u.jsx(l,{className:t,ref:x,...jt(l,d),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(y=>{const w=o(y.index,y.data,d);return s?u.jsx(c,{...jt(c,d),height:e.itemHeight,index:y.index,width:e.itemWidth},w):b.createElement(a,{...jt(a,d),className:n,"data-index":y.index,key:w},r(y.index,y.data,d))})})}),YC=b.memo(function(){const e=at("HeaderComponent"),t=nn("headerHeight"),n=at("headerFooterTag"),r=or(b.useMemo(()=>s=>{t(Un(s,"height"))},[t]),!0,!1),o=at("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...jt(e,o)})}):null}),XC=b.memo(function(){const e=at("FooterComponent"),t=nn("footerHeight"),n=at("headerFooterTag"),r=or(b.useMemo(()=>s=>{t(Un(s,"height"))},[t]),!0,!1),o=at("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...jt(e,o)})}):null}),JC=({children:e})=>{const t=b.useContext(Ih),n=nn("itemDimensions"),r=nn("viewportDimensions"),o=or(b.useMemo(()=>s=>{r(s.getBoundingClientRect())},[r]),!0,!1);return b.useEffect(()=>{t&&(r({height:t.viewportHeight,width:t.viewportWidth}),n({height:t.itemHeight,width:t.itemWidth}))},[t,r,n]),u.jsx("div",{ref:o,style:Os(!1),children:e})},ZC=({children:e})=>{const t=b.useContext(Ih),n=nn("windowViewportRect"),r=nn("itemDimensions"),o=at("customScrollParent"),s=Zf(n,o,!1);return b.useEffect(()=>{t&&(r({height:t.itemHeight,width:t.itemWidth}),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:t.viewportWidth}))},[t,n,r]),u.jsx("div",{ref:s,style:Os(!1),children:e})},QC=b.memo(function({...e}){const t=at("useWindowScroll"),n=at("customScrollParent"),r=n||t?tT:eT,o=n||t?ZC:JC,s=at("context");return u.jsx(r,{...e,...jt(r,s),children:u.jsxs(o,{children:[u.jsx(YC,{}),u.jsx(GC,{}),u.jsx(XC,{})]})})}),{useEmitter:zh,useEmitterValue:at,usePublisher:nn}=kh(qC,{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"}},QC),eT=Mh({useEmitter:zh,useEmitterValue:at,usePublisher:nn}),tT=Rh({useEmitter:zh,useEmitterValue:at,usePublisher:nn});function Hh(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Ht.WARN),t==="normal"?0:parseInt(t??"0",10)}var $s="Dialog",[Uh,_N]=ln($s),[nT,hn]=Uh($s),Wh=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:i=!0}=e,a=p.useRef(null),l=p.useRef(null),[c,d]=Dn({prop:r,defaultProp:o??!1,onChange:s,caller:$s});return u.jsx(nT,{scope:t,triggerRef:a,contentRef:l,contentId:Nt(),titleId:Nt(),descriptionId:Nt(),open:c,onOpenChange:d,onOpenToggle:p.useCallback(()=>d(h=>!h),[d]),modal:i,children:n})};Wh.displayName=$s;var Vh="DialogTrigger",Kh=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=hn(Vh,n),s=De(t,o.triggerRef);return u.jsx(xe.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Ja(o.open),...r,ref:s,onClick:ce(e.onClick,o.onOpenToggle)})});Kh.displayName=Vh;var Ya="DialogPortal",[rT,qh]=Uh(Ya,{forceMount:void 0}),Gh=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=hn(Ya,t);return u.jsx(rT,{scope:t,forceMount:n,children:p.Children.map(r,i=>u.jsx(zt,{present:n||s.open,children:u.jsx(so,{asChild:!0,container:o,children:i})}))})};Gh.displayName=Ya;var Fs="DialogOverlay",Yh=p.forwardRef((e,t)=>{const n=qh(Fs,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=hn(Fs,e.__scopeDialog);return s.modal?u.jsx(zt,{present:r||s.open,children:u.jsx(sT,{...o,ref:t})}):null});Yh.displayName=Fs;var oT=Kt.createSlot("DialogOverlay.RemoveScroll"),sT=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=hn(Fs,n);return u.jsx(xs,{as:oT,allowPinchZoom:!0,shards:[o.contentRef],children:u.jsx(xe.div,{"data-state":Ja(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),ar="DialogContent",Xh=p.forwardRef((e,t)=>{const n=qh(ar,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=hn(ar,e.__scopeDialog);return u.jsx(zt,{present:r||s.open,children:s.modal?u.jsx(iT,{...o,ref:t}):u.jsx(aT,{...o,ref:t})})});Xh.displayName=ar;var iT=p.forwardRef((e,t)=>{const n=hn(ar,e.__scopeDialog),r=p.useRef(null),o=De(t,n.contentRef,r);return p.useEffect(()=>{const s=r.current;if(s)return fa(s)},[]),u.jsx(Jh,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ce(e.onCloseAutoFocus,s=>{var i;s.preventDefault(),(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:ce(e.onPointerDownOutside,s=>{const i=s.detail.originalEvent,a=i.button===0&&i.ctrlKey===!0;(i.button===2||a)&&s.preventDefault()}),onFocusOutside:ce(e.onFocusOutside,s=>s.preventDefault())})}),aT=p.forwardRef((e,t)=>{const n=hn(ar,e.__scopeDialog),r=p.useRef(!1),o=p.useRef(!1);return u.jsx(Jh,{...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,c;(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;((c=n.triggerRef.current)==null?void 0:c.contains(i))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&o.current&&s.preventDefault()}})}),Jh=p.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=hn(ar,n),l=p.useRef(null),c=De(t,l);return Ui(),u.jsxs(u.Fragment,{children:[u.jsx(Zo,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:u.jsx(yr,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":Ja(a.open),...i,ref:c,onDismiss:()=>a.onOpenChange(!1)})}),u.jsxs(u.Fragment,{children:[u.jsx(lT,{titleId:a.titleId}),u.jsx(uT,{contentRef:l,descriptionId:a.descriptionId})]})]})}),Xa="DialogTitle",Zh=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=hn(Xa,n);return u.jsx(xe.h2,{id:o.titleId,...r,ref:t})});Zh.displayName=Xa;var Qh="DialogDescription",ep=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=hn(Qh,n);return u.jsx(xe.p,{id:o.descriptionId,...r,ref:t})});ep.displayName=Qh;var tp="DialogClose",np=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=hn(tp,n);return u.jsx(xe.button,{type:"button",...r,ref:t,onClick:ce(e.onClick,()=>o.onOpenChange(!1))})});np.displayName=tp;function Ja(e){return e?"open":"closed"}var rp="DialogTitleWarning",[MN,op]=Tb(rp,{contentName:ar,titleName:Xa,docsSlug:"dialog"}),lT=({titleId:e})=>{const t=op(rp),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
79
|
+
`)},u0=0,jr=[];function d0(e){var t=p.useRef([]),n=p.useRef([0,0]),r=p.useRef(),o=p.useState(u0++)[0],s=p.useState(Bd)[0],i=p.useRef(e);p.useEffect(function(){i.current=e},[e]),p.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var g=_y([e.lockRef.current],(e.shards||[]).map(qd),!0).filter(Boolean);return g.forEach(function(x){return x.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),g.forEach(function(x){return x.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var a=p.useCallback(function(g,x){if("touches"in g&&g.touches.length===2||g.type==="wheel"&&g.ctrlKey)return!i.current.allowPinchZoom;var y=gs(g),w=n.current,S="deltaX"in g?g.deltaX:w[0]-y[0],k="deltaY"in g?g.deltaY:w[1]-y[1],C,T=g.target,E=Math.abs(S)>Math.abs(k)?"h":"v";if("touches"in g&&E==="h"&&T.type==="range")return!1;var j=Ud(E,T);if(!j)return!0;if(j?C=E:(C=E==="v"?"h":"v",j=Ud(E,T)),!j)return!1;if(!r.current&&"changedTouches"in g&&(S||k)&&(r.current=C),!C)return!0;var _=r.current||C;return a0(_,x,g,_==="h"?S:k)},[]),l=p.useCallback(function(g){var x=g;if(!(!jr.length||jr[jr.length-1]!==s)){var y="deltaY"in x?Kd(x):gs(x),w=t.current.filter(function(C){return C.name===x.type&&(C.target===x.target||x.target===C.shadowParent)&&l0(C.delta,y)})[0];if(w&&w.should){x.cancelable&&x.preventDefault();return}if(!w){var S=(i.current.shards||[]).map(qd).filter(Boolean).filter(function(C){return C.contains(x.target)}),k=S.length>0?a(x,S[0]):!i.current.noIsolation;k&&x.cancelable&&x.preventDefault()}}},[]),c=p.useCallback(function(g,x,y,w){var S={name:g,delta:x,target:y,should:w,shadowParent:f0(y)};t.current.push(S),setTimeout(function(){t.current=t.current.filter(function(k){return k!==S})},1)},[]),d=p.useCallback(function(g){n.current=gs(g),r.current=void 0},[]),h=p.useCallback(function(g){c(g.type,Kd(g),g.target,a(g,e.lockRef.current))},[]),m=p.useCallback(function(g){c(g.type,gs(g),g.target,a(g,e.lockRef.current))},[]);p.useEffect(function(){return jr.push(s),e.setCallbacks({onScrollCapture:h,onWheelCapture:h,onTouchMoveCapture:m}),document.addEventListener("wheel",l,Ar),document.addEventListener("touchmove",l,Ar),document.addEventListener("touchstart",d,Ar),function(){jr=jr.filter(function(g){return g!==s}),document.removeEventListener("wheel",l,Ar),document.removeEventListener("touchmove",l,Ar),document.removeEventListener("touchstart",d,Ar)}},[]);var f=e.removeScrollBar,v=e.inert;return p.createElement(p.Fragment,null,v?p.createElement(s,{styles:c0(o)}):null,f?p.createElement(e0,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function f0(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const h0=zy(Fd,d0);var xs=p.forwardRef(function(e,t){return p.createElement(ps,Sn({},e,{ref:t,sideCar:h0}))});xs.classNames=ps.classNames;var xa=["Enter"," "],p0=["ArrowDown","PageUp","Home"],Gd=["ArrowUp","PageDown","End"],m0=[...p0,...Gd],g0={ltr:[...xa,"ArrowRight"],rtl:[...xa,"ArrowLeft"]},x0={ltr:["ArrowLeft"],rtl:["ArrowRight"]},ao="Menu",[lo,v0,b0]=Xo(ao),[tr,Yd]=ln(ao,[b0,Er,jd]),vs=Er(),Xd=jd(),[w0,nr]=tr(ao),[y0,co]=tr(ao),Jd=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=vs(t),[l,c]=p.useState(null),d=p.useRef(!1),h=ft(s),m=Jo(o);return p.useEffect(()=>{const f=()=>{d.current=!0,document.addEventListener("pointerdown",v,{capture:!0,once:!0}),document.addEventListener("pointermove",v,{capture:!0,once:!0})},v=()=>d.current=!1;return document.addEventListener("keydown",f,{capture:!0}),()=>{document.removeEventListener("keydown",f,{capture:!0}),document.removeEventListener("pointerdown",v,{capture:!0}),document.removeEventListener("pointermove",v,{capture:!0})}},[]),u.jsx(sa,{...a,children:u.jsx(w0,{scope:t,open:n,onOpenChange:h,content:l,onContentChange:c,children:u.jsx(y0,{scope:t,onClose:p.useCallback(()=>h(!1),[h]),isUsingKeyboardRef:d,dir:m,modal:i,children:r})})})};Jd.displayName=ao;var S0="MenuAnchor",va=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=vs(n);return u.jsx(ia,{...o,...r,ref:t})});va.displayName=S0;var ba="MenuPortal",[C0,Zd]=tr(ba,{forceMount:void 0}),Qd=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=nr(ba,t);return u.jsx(C0,{scope:t,forceMount:n,children:u.jsx(zt,{present:n||s.open,children:u.jsx(so,{asChild:!0,container:o,children:r})})})};Qd.displayName=ba;var en="MenuContent",[T0,wa]=tr(en),ef=p.forwardRef((e,t)=>{const n=Zd(en,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=nr(en,e.__scopeMenu),i=co(en,e.__scopeMenu);return u.jsx(lo.Provider,{scope:e.__scopeMenu,children:u.jsx(zt,{present:r||s.open,children:u.jsx(lo.Slot,{scope:e.__scopeMenu,children:i.modal?u.jsx(k0,{...o,ref:t}):u.jsx(E0,{...o,ref:t})})})})}),k0=p.forwardRef((e,t)=>{const n=nr(en,e.__scopeMenu),r=p.useRef(null),o=De(t,r);return p.useEffect(()=>{const s=r.current;if(s)return fa(s)},[]),u.jsx(ya,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:ce(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),E0=p.forwardRef((e,t)=>{const n=nr(en,e.__scopeMenu);return u.jsx(ya,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),I0=Kt.createSlot("MenuContent.ScrollLock"),ya=p.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:h,onInteractOutside:m,onDismiss:f,disableOutsideScroll:v,...g}=e,x=nr(en,n),y=co(en,n),w=vs(n),S=Xd(n),k=v0(n),[C,T]=p.useState(null),E=p.useRef(null),j=De(t,E,x.onContentChange),_=p.useRef(0),D=p.useRef(""),F=p.useRef(0),G=p.useRef(null),K=p.useRef("right"),A=p.useRef(0),Y=v?xs:p.Fragment,q=v?{as:I0,allowPinchZoom:!0}:void 0,W=I=>{var H,$;const z=D.current+I,J=k().filter(Z=>!Z.disabled),P=document.activeElement,O=(H=J.find(Z=>Z.ref.current===P))==null?void 0:H.textValue,M=J.map(Z=>Z.textValue),L=F0(M,z,O),ee=($=J.find(Z=>Z.textValue===L))==null?void 0:$.ref.current;(function Z(te){D.current=te,window.clearTimeout(_.current),te!==""&&(_.current=window.setTimeout(()=>Z(""),1e3))})(z),ee&&setTimeout(()=>ee.focus())};p.useEffect(()=>()=>window.clearTimeout(_.current),[]),Ui();const R=p.useCallback(I=>{var J,P;return K.current===((J=G.current)==null?void 0:J.side)&&z0(I,(P=G.current)==null?void 0:P.area)},[]);return u.jsx(T0,{scope:n,searchRef:D,onItemEnter:p.useCallback(I=>{R(I)&&I.preventDefault()},[R]),onItemLeave:p.useCallback(I=>{var z;R(I)||((z=E.current)==null||z.focus(),T(null))},[R]),onTriggerLeave:p.useCallback(I=>{R(I)&&I.preventDefault()},[R]),pointerGraceTimerRef:F,onPointerGraceIntentChange:p.useCallback(I=>{G.current=I},[]),children:u.jsx(Y,{...q,children:u.jsx(Zo,{asChild:!0,trapped:o,onMountAutoFocus:ce(s,I=>{var z;I.preventDefault(),(z=E.current)==null||z.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:u.jsx(yr,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:h,onInteractOutside:m,onDismiss:f,children:u.jsx(Iy,{asChild:!0,...S,dir:y.dir,orientation:"vertical",loop:r,currentTabStopId:C,onCurrentTabStopIdChange:T,onEntryFocus:ce(l,I=>{y.isUsingKeyboardRef.current||I.preventDefault()}),preventScrollOnEntryFocus:!0,children:u.jsx(aa,{role:"menu","aria-orientation":"vertical","data-state":vf(x.open),"data-radix-menu-content":"",dir:y.dir,...w,...g,ref:j,style:{outline:"none",...g.style},onKeyDown:ce(g.onKeyDown,I=>{const J=I.target.closest("[data-radix-menu-content]")===I.currentTarget,P=I.ctrlKey||I.altKey||I.metaKey,O=I.key.length===1;J&&(I.key==="Tab"&&I.preventDefault(),!P&&O&&W(I.key));const M=E.current;if(I.target!==M||!m0.includes(I.key))return;I.preventDefault();const ee=k().filter(H=>!H.disabled).map(H=>H.ref.current);Gd.includes(I.key)&&ee.reverse(),L0(ee)}),onBlur:ce(e.onBlur,I=>{I.currentTarget.contains(I.target)||(window.clearTimeout(_.current),D.current="")}),onPointerMove:ce(e.onPointerMove,fo(I=>{const z=I.target,J=A.current!==I.clientX;if(I.currentTarget.contains(z)&&J){const P=I.clientX>A.current?"right":"left";K.current=P,A.current=I.clientX}}))})})})})})})});ef.displayName=en;var N0="MenuGroup",Sa=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(xe.div,{role:"group",...r,ref:t})});Sa.displayName=N0;var A0="MenuLabel",tf=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(xe.div,{...r,ref:t})});tf.displayName=A0;var bs="MenuItem",nf="menu.itemSelect",ws=p.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=p.useRef(null),i=co(bs,e.__scopeMenu),a=wa(bs,e.__scopeMenu),l=De(t,s),c=p.useRef(!1),d=()=>{const h=s.current;if(!n&&h){const m=new CustomEvent(nf,{bubbles:!0,cancelable:!0});h.addEventListener(nf,f=>r==null?void 0:r(f),{once:!0}),Bi(h,m),m.defaultPrevented?c.current=!1:i.onClose()}};return u.jsx(rf,{...o,ref:l,disabled:n,onClick:ce(e.onClick,d),onPointerDown:h=>{var m;(m=e.onPointerDown)==null||m.call(e,h),c.current=!0},onPointerUp:ce(e.onPointerUp,h=>{var m;c.current||(m=h.currentTarget)==null||m.click()}),onKeyDown:ce(e.onKeyDown,h=>{const m=a.searchRef.current!=="";n||m&&h.key===" "||xa.includes(h.key)&&(h.currentTarget.click(),h.preventDefault())})})});ws.displayName=bs;var rf=p.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=wa(bs,n),a=Xd(n),l=p.useRef(null),c=De(t,l),[d,h]=p.useState(!1),[m,f]=p.useState("");return p.useEffect(()=>{const v=l.current;v&&f((v.textContent??"").trim())},[s.children]),u.jsx(lo.ItemSlot,{scope:n,disabled:r,textValue:o??m,children:u.jsx(Ny,{asChild:!0,...a,focusable:!r,children:u.jsx(xe.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:c,onPointerMove:ce(e.onPointerMove,fo(v=>{r?i.onItemLeave(v):(i.onItemEnter(v),v.defaultPrevented||v.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:ce(e.onPointerLeave,fo(v=>i.onItemLeave(v))),onFocus:ce(e.onFocus,()=>h(!0)),onBlur:ce(e.onBlur,()=>h(!1))})})})}),j0="MenuCheckboxItem",of=p.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return u.jsx(uf,{scope:e.__scopeMenu,checked:n,children:u.jsx(ws,{role:"menuitemcheckbox","aria-checked":ys(n)?"mixed":n,...o,ref:t,"data-state":Ta(n),onSelect:ce(o.onSelect,()=>r==null?void 0:r(ys(n)?!0:!n),{checkForDefaultPrevented:!1})})})});of.displayName=j0;var sf="MenuRadioGroup",[P0,_0]=tr(sf,{value:void 0,onValueChange:()=>{}}),af=p.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=ft(r);return u.jsx(P0,{scope:e.__scopeMenu,value:n,onValueChange:s,children:u.jsx(Sa,{...o,ref:t})})});af.displayName=sf;var lf="MenuRadioItem",cf=p.forwardRef((e,t)=>{const{value:n,...r}=e,o=_0(lf,e.__scopeMenu),s=n===o.value;return u.jsx(uf,{scope:e.__scopeMenu,checked:s,children:u.jsx(ws,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":Ta(s),onSelect:ce(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});cf.displayName=lf;var Ca="MenuItemIndicator",[uf,M0]=tr(Ca,{checked:!1}),df=p.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=M0(Ca,n);return u.jsx(zt,{present:r||ys(s.checked)||s.checked===!0,children:u.jsx(xe.span,{...o,ref:t,"data-state":Ta(s.checked)})})});df.displayName=Ca;var R0="MenuSeparator",ff=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(xe.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});ff.displayName=R0;var O0="MenuArrow",hf=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=vs(n);return u.jsx(la,{...o,...r,ref:t})});hf.displayName=O0;var D0="MenuSub",[AN,pf]=tr(D0),uo="MenuSubTrigger",mf=p.forwardRef((e,t)=>{const n=nr(uo,e.__scopeMenu),r=co(uo,e.__scopeMenu),o=pf(uo,e.__scopeMenu),s=wa(uo,e.__scopeMenu),i=p.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,c={__scopeMenu:e.__scopeMenu},d=p.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return p.useEffect(()=>d,[d]),p.useEffect(()=>{const h=a.current;return()=>{window.clearTimeout(h),l(null)}},[a,l]),u.jsx(va,{asChild:!0,...c,children:u.jsx(rf,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":vf(n.open),...e,ref:On(t,o.onTriggerChange),onClick:h=>{var m;(m=e.onClick)==null||m.call(e,h),!(e.disabled||h.defaultPrevented)&&(h.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:ce(e.onPointerMove,fo(h=>{s.onItemEnter(h),!h.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(s.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),d()},100))})),onPointerLeave:ce(e.onPointerLeave,fo(h=>{var f,v;d();const m=(f=n.content)==null?void 0:f.getBoundingClientRect();if(m){const g=(v=n.content)==null?void 0:v.dataset.side,x=g==="right",y=x?-5:5,w=m[x?"left":"right"],S=m[x?"right":"left"];s.onPointerGraceIntentChange({area:[{x:h.clientX+y,y:h.clientY},{x:w,y:m.top},{x:S,y:m.top},{x:S,y:m.bottom},{x:w,y:m.bottom}],side:g}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(h),h.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:ce(e.onKeyDown,h=>{var f;const m=s.searchRef.current!=="";e.disabled||m&&h.key===" "||g0[r.dir].includes(h.key)&&(n.onOpenChange(!0),(f=n.content)==null||f.focus(),h.preventDefault())})})})});mf.displayName=uo;var gf="MenuSubContent",xf=p.forwardRef((e,t)=>{const n=Zd(en,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=nr(en,e.__scopeMenu),i=co(en,e.__scopeMenu),a=pf(gf,e.__scopeMenu),l=p.useRef(null),c=De(t,l);return u.jsx(lo.Provider,{scope:e.__scopeMenu,children:u.jsx(zt,{present:r||s.open,children:u.jsx(lo.Slot,{scope:e.__scopeMenu,children:u.jsx(ya,{id:a.contentId,"aria-labelledby":a.triggerId,...o,ref:c,align:"start",side:i.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:d=>{var h;i.isUsingKeyboardRef.current&&((h=l.current)==null||h.focus()),d.preventDefault()},onCloseAutoFocus:d=>d.preventDefault(),onFocusOutside:ce(e.onFocusOutside,d=>{d.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:ce(e.onEscapeKeyDown,d=>{i.onClose(),d.preventDefault()}),onKeyDown:ce(e.onKeyDown,d=>{var f;const h=d.currentTarget.contains(d.target),m=x0[i.dir].includes(d.key);h&&m&&(s.onOpenChange(!1),(f=a.trigger)==null||f.focus(),d.preventDefault())})})})})})});xf.displayName=gf;function vf(e){return e?"open":"closed"}function ys(e){return e==="indeterminate"}function Ta(e){return ys(e)?"indeterminate":e?"checked":"unchecked"}function L0(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function $0(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function F0(e,t,n){const o=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=$0(e,Math.max(s,0));o.length===1&&(i=i.filter(c=>c!==n));const l=i.find(c=>c.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function B0(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],c=a.x,d=a.y,h=l.x,m=l.y;d>r!=m>r&&n<(h-c)*(r-d)/(m-d)+c&&(o=!o)}return o}function z0(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return B0(n,t)}function fo(e){return t=>t.pointerType==="mouse"?e(t):void 0}var H0=Jd,U0=va,W0=Qd,V0=ef,K0=Sa,q0=tf,G0=ws,Y0=of,X0=af,J0=cf,Z0=df,Q0=ff,eS=hf,tS=mf,nS=xf,Ss="DropdownMenu",[rS,jN]=ln(Ss,[Yd]),Ot=Yd(),[oS,bf]=rS(Ss),wf=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,l=Ot(t),c=p.useRef(null),[d,h]=Dn({prop:o,defaultProp:s??!1,onChange:i,caller:Ss});return u.jsx(oS,{scope:t,triggerId:Nt(),triggerRef:c,contentId:Nt(),open:d,onOpenChange:h,onOpenToggle:p.useCallback(()=>h(m=>!m),[h]),modal:a,children:u.jsx(H0,{...l,open:d,onOpenChange:h,dir:r,modal:a,children:n})})};wf.displayName=Ss;var yf="DropdownMenuTrigger",Sf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=bf(yf,n),i=Ot(n);return u.jsx(U0,{asChild:!0,...i,children:u.jsx(xe.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:On(t,s.triggerRef),onPointerDown:ce(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:ce(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});Sf.displayName=yf;var sS="DropdownMenuPortal",Cf=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Ot(t);return u.jsx(W0,{...r,...n})};Cf.displayName=sS;var Tf="DropdownMenuContent",kf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=bf(Tf,n),s=Ot(n),i=p.useRef(!1);return u.jsx(V0,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:ce(e.onCloseAutoFocus,a=>{var l;i.current||(l=o.triggerRef.current)==null||l.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:ce(e.onInteractOutside,a=>{const l=a.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0,d=l.button===2||c;(!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=Tf;var iS="DropdownMenuGroup",aS=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(K0,{...o,...r,ref:t})});aS.displayName=iS;var lS="DropdownMenuLabel",Ef=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(q0,{...o,...r,ref:t})});Ef.displayName=lS;var cS="DropdownMenuItem",If=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(G0,{...o,...r,ref:t})});If.displayName=cS;var uS="DropdownMenuCheckboxItem",Nf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(Y0,{...o,...r,ref:t})});Nf.displayName=uS;var dS="DropdownMenuRadioGroup",fS=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(X0,{...o,...r,ref:t})});fS.displayName=dS;var hS="DropdownMenuRadioItem",Af=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(J0,{...o,...r,ref:t})});Af.displayName=hS;var pS="DropdownMenuItemIndicator",jf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(Z0,{...o,...r,ref:t})});jf.displayName=pS;var mS="DropdownMenuSeparator",Pf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(Q0,{...o,...r,ref:t})});Pf.displayName=mS;var gS="DropdownMenuArrow",xS=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(eS,{...o,...r,ref:t})});xS.displayName=gS;var vS="DropdownMenuSubTrigger",_f=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(tS,{...o,...r,ref:t})});_f.displayName=vS;var bS="DropdownMenuSubContent",Mf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(nS,{...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)"}})});Mf.displayName=bS;var wS=wf,yS=Sf,SS=Cf,Rf=kf,Of=Ef,Df=If,Lf=Nf,$f=Af,Ff=jf,Bf=Pf,zf=_f,Hf=Mf;const Cs=wS,Ts=yS,CS=p.forwardRef(({className:e,inset:t,children:n,...r},o)=>u.jsxs(zf,{ref:o,className:oe("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",t&&"pl-8",e),...r,children:[n,u.jsx(ue.ChevronRight,{className:"ml-auto h-4 w-4"})]}));CS.displayName=zf.displayName;const TS=p.forwardRef(({className:e,...t},n)=>u.jsx(Hf,{ref:n,className:oe("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...t}));TS.displayName=Hf.displayName;const ho=p.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(SS,{children:u.jsx(Rf,{ref:r,sideOffset:t,className:oe("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n})}));ho.displayName=Rf.displayName;const Bn=p.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(Df,{ref:r,className:oe("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...n}));Bn.displayName=Df.displayName;const kS=p.forwardRef(({className:e,children:t,checked:n,...r},o)=>u.jsxs(Lf,{ref:o,className:oe("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:n,...r,children:[u.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx(Ff,{children:u.jsx(ue.Check,{className:"h-4 w-4"})})}),t]}));kS.displayName=Lf.displayName;const ES=p.forwardRef(({className:e,children:t,...n},r)=>u.jsxs($f,{ref:r,className:oe("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[u.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx(Ff,{children:u.jsx(ue.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));ES.displayName=$f.displayName;const IS=p.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(Of,{ref:r,className:oe("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));IS.displayName=Of.displayName;const NS=p.forwardRef(({className:e,...t},n)=>u.jsx(Bf,{ref:n,className:oe("-mx-1 my-1 h-px bg-muted",e),...t}));NS.displayName=Bf.displayName;const ka=p.forwardRef(({className:e,...t},n)=>u.jsx("textarea",{className:oe("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),ref:n,...t}));ka.displayName="Textarea";const AS=1e4;function Uf({initialValue:e="",editingMessageId:t=null,placeholder:n="Type your message...",isStreaming:r=!1,disabled:o=!1,maxLength:s=AS,value:i,onValueChange:a,onSend:l,onCancelEdit:c,onStop:d,className:h="",textareaClassName:m="",allowEmptySend:f=!1,sendButtonClassName:v,validate:g,onValidationError:x}){const y=i!==void 0,[w,S]=b.useState(e),k=(y?i:w)??"",[C,T]=b.useTransition(),E=b.useRef(null),j=b.useRef(0),_=b.useRef(null),D=b.useRef("");b.useEffect(()=>{y||(S(e??""),_.current=null,E.current&&(E.current.style.height="auto",E.current.style.height=`${E.current.scrollHeight}px`))},[e,t,y]);const[F,G]=b.useState(null),K=b.useCallback(M=>M.length>s?`Message too long (${M.length}/${s} characters)`:null,[s]),A=b.useMemo(()=>g??K,[g,K]),Y=b.useCallback(M=>{const L=A(M);return G(L),x==null||x(L),D.current=M,L},[A,x]),q=b.useCallback(()=>{const M=E.current;M&&(M.style.height="auto",M.style.height=`${M.scrollHeight}px`)},[]);b.useEffect(()=>{q()},[q,k]),b.useEffect(()=>{if(!F)return;const M=(k??"").trim();D.current!==M&&Y(M)},[k,F,Y]);const W=b.useCallback((M,{fromUser:L})=>{y||S(M),L&&(a==null||a(M))},[y,a]),R=b.useCallback(async M=>{M&&M.preventDefault();const L=(k??"").trim();if(!L&&!f||Y(L))return;const ee=++j.current;_.current={id:ee,shouldClear:!0},T(()=>{var H,$,Z;try{const te=l(L);te&&typeof te.then=="function"?te.then(()=>{var Q,U;((Q=_.current)==null?void 0:Q.id)===ee&&_.current.shouldClear&&(y||(S(""),E.current&&(E.current.style.height="auto"),a==null||a(""))),((U=_.current)==null?void 0:U.id)===ee&&(_.current=null)}).catch(()=>{var Q;((Q=_.current)==null?void 0:Q.id)===ee&&(_.current=null)}):(((H=_.current)==null?void 0:H.id)===ee&&_.current.shouldClear&&(y||(S(""),E.current&&(E.current.style.height="auto"),a==null||a(""))),(($=_.current)==null?void 0:$.id)===ee&&(_.current=null))}catch{((Z=_.current)==null?void 0:Z.id)===ee&&(_.current=null)}})},[k,l,f,y,a,Y]),I=b.useCallback(M=>{const L=M.target.value;W(L,{fromUser:!0}),_.current&&(_.current.shouldClear=!1),E.current&&(E.current.style.height="auto",E.current.style.height=`${E.current.scrollHeight}px`),F&&Y(L.trim())},[W,Y,F]),z=b.useCallback(M=>{M.key==="Enter"&&!M.shiftKey?(M.preventDefault(),R()):M.key==="Escape"&&t&&(M.preventDefault(),c==null||c())},[R,t,c]),O=`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))]":""} ${m}`;return u.jsx("form",{onSubmit:M=>void R(M),className:`w-full ${h}`,children:u.jsxs("div",{className:"flex items-end gap-2",children:[u.jsxs("div",{className:"flex-1",children:[u.jsx(ka,{ref:E,value:k,onChange:I,onKeyDown:z,placeholder:t?"Edit your message...":n,className:O,disabled:o,maxLength:s,rows:1,spellCheck:!1,autoCorrect:"off"}),F&&u.jsx("p",{className:"mt-1 text-xs text-destructive font-medium",children:F})]}),u.jsx("div",{children:r?u.jsx(Xe,{type:"button",onClick:()=>{d==null||d()},size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",disabled:o||!d,children:u.jsx(ue.Square,{size:16})}):u.jsx(Xe,{type:"submit",size:"icon",className:`shrink-0 ${v??""}`,title:t?"Save changes":"Send message",disabled:o||!k.trim()&&!f||C,children:u.jsx(ue.Send,{size:16})})})]})})}const jS=b.memo(Uf);function Wf({composerValue:e,onComposerChange:t,onSend:n,onCancelEdit:r,onStop:o,editingMessageId:s=null,editingInitialValue:i="",placeholder:a="Type your message...",isStreaming:l=!1,disabled:c=!1,textareaClassName:d="",customStyles:h={},enableFileUpload:m=!1,enableExcelUpload:f=!1,onExcelUpload:v,onError:g,allowEmptySend:x=!1,inputError:y=null}){const[w,S]=b.useState([]),k=b.useRef(null),C=b.useRef(null),[T,E]=b.useState(0),[j,_]=b.useState(0),[D,F]=b.useState(!1),[G,K]=b.useState(null),[A,Y]=b.useState(null),q=b.useCallback(()=>{k.current&&(k.current.value=""),C.current&&(C.current.value=""),E(M=>M+1),_(M=>M+1)},[]),W=b.useCallback(M=>{S(L=>[...L,...M])},[]),R=b.useCallback(M=>{const L=Array.from(M.target.files||[]);W(L),M.target.value=""},[W]),I=b.useCallback(M=>{S(L=>{const ee=L.filter((H,$)=>$!==M);return ee.length===0&&q(),ee})},[q]),z=b.useCallback(async M=>{const L=(M.target.files||[])[0];if(L&&(K(null),Y(null),!!v)){F(!0);try{await v(L),K(`Uploaded ${L.name} - processing through chat stream`)}catch(ee){const H=ee instanceof Error?ee.message:"Failed to upload Excel file";Y(H),g==null||g(H)}finally{F(!1),M.target.value="",q()}}},[v,g,q]),J=b.useMemo(()=>x||w.length>0,[x,w]),P=b.useCallback(async M=>{const L=n(M,w);try{const ee=await L;return w.length>0&&(S([]),q()),ee}catch(ee){throw ee}},[n,q,w]),O=`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${s?"border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50":""} ${y?"border-red-400":""} ${h.textarea||""} ${d}`;return u.jsxs(u.Fragment,{children:[(m||f)&&u.jsxs("div",{className:"mb-3 space-y-3",children:[m&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:k,type:"file",multiple:!0,onChange:R,className:"hidden"},T),w.length>0&&u.jsx("div",{className:"flex flex-wrap gap-2",children:w.map((M,L)=>u.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:[u.jsx(ue.Paperclip,{size:14}),u.jsx("span",{className:"truncate max-w-[150px]",children:M.name}),u.jsx(Xe,{variant:"ghost",size:"sm",onClick:()=>I(L),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 ${M.name}`,children:u.jsx(ue.X,{size:12})})]},L))})]}),f&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:C,type:"file",accept:".xls,.xlsx,.xlsm",onChange:z,className:"hidden"},j),D&&u.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(ue.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),G&&!D&&u.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:G}),A&&!D&&u.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:A})]})]}),u.jsxs("div",{className:"flex items-end gap-2",children:[(m||f)&&u.jsxs(Cs,{children:[u.jsx(Ts,{asChild:!0,children:u.jsx(Xe,{type:"button",size:"icon",variant:"outline",disabled:l||c,title:"More input actions",className:h.moreButton||"",children:u.jsx(ue.Plus,{size:16})})}),u.jsxs(ho,{align:"start",sideOffset:6,className:"w-52",children:[m&&u.jsxs(Bn,{onClick:()=>{var M;return(M=k.current)==null?void 0:M.click()},className:"cursor-pointer",children:[u.jsx(ue.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),f&&u.jsxs(Bn,{onClick:()=>{var M;D||(M=C.current)==null||M.click()},className:`cursor-pointer ${D?"opacity-60 pointer-events-none":""}`,children:[u.jsx(ue.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),u.jsx("div",{className:"flex-1",children:u.jsx(jS,{initialValue:i,editingMessageId:s,value:e,onValueChange:t,placeholder:s?"Edit your message...":a,isStreaming:l,disabled:c,onSend:P,onCancelEdit:r,onStop:o,allowEmptySend:J,textareaClassName:O,sendButtonClassName:h.sendButton})})]})]})}const PS=b.memo(Wf),ks=0,zn=1,Pr=2,Vf=4;function Kf(e){return()=>e}function _S(e){e()}function qf(e,t){return n=>e(t(n))}function Gf(e,t){return()=>e(t)}function MS(e,t){return n=>e(t,n)}function Ea(e){return e!==void 0}function RS(...e){return()=>{e.map(_S)}}function _r(){}function Es(e,t){return t(e),e}function OS(e,t){return t(e)}function rt(...e){return e}function Ge(e,t){return e(zn,t)}function Me(e,t){e(ks,t)}function Ia(e){e(Pr)}function ht(e){return e(Vf)}function ve(e,t){return Ge(e,MS(t,ks))}function dn(e,t){const n=e(zn,r=>{n(),t(r)});return n}function Yf(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function Xf(e,t){return e===t}function ot(e=Xf){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function ke(e){return t=>n=>{e(n)&&t(n)}}function he(e){return t=>qf(t,e)}function Cn(e){return t=>()=>{t(e)}}function ne(e,...t){const n=DS(...t);return(r,o)=>{switch(r){case Pr:Ia(e);return;case zn:return Ge(e,n(o))}}}function Tn(e,t){return n=>r=>{n(t=e(t,r))}}function rr(e){return t=>n=>{e>0?e--:t(n)}}function Pn(e){let t=null,n;return r=>o=>{t=o,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function Le(...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);Ge(s,l=>{const c=n;n=n|a,t[i]=l,c!==o&&n===o&&r&&(r(),r=null)})}),s=>i=>{const a=()=>{s([i].concat(t))};n===o?a():r=a}}function DS(...e){return t=>e.reduceRight(OS,t)}function LS(e){let t,n;const r=()=>t==null?void 0:t();return function(o,s){switch(o){case zn:return s?n===s?void 0:(r(),n=s,t=Ge(e,s),t):(r(),_r);case Pr:r(),n=null;return}}}function se(e){let t=e;const n=Be();return(r,o)=>{switch(r){case ks:t=o;break;case zn:{o(t);break}case Vf:return t}return n(r,o)}}function At(e,t){return Es(se(t),n=>ve(e,n))}function Be(){const e=[];return(t,n)=>{switch(t){case ks:e.slice().forEach(r=>{r(n)});return;case Pr:e.splice(0,e.length);return;case zn:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}}}function Jt(e){return Es(Be(),t=>ve(e,t))}function Ke(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:$S(),singleton:n}}const $S=()=>Symbol();function FS(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 gt(...e){const t=Be(),n=new Array(e.length);let r=0;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const a=Math.pow(2,i);Ge(s,l=>{n[i]=l,r=r|a,r===o&&Me(t,n)})}),function(s,i){switch(s){case Pr:{Ia(t);return}case zn:return r===o&&i(n),Ge(t,i)}}}function Te(e,t=Xf){return ne(e,ot(t))}function Na(...e){return function(t,n){switch(t){case Pr:return;case zn:return RS(...e.map(r=>Ge(r,n)))}}}var Ht=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(Ht||{});const BS={0:"debug",3:"error",1:"log",2:"warn"},zS=()=>typeof globalThis>"u"?window:globalThis,Hn=Ke(()=>{const e=se(3);return{log:se((t,n,r=1)=>{var o;const s=(o=zS().VIRTUOSO_LOG_LEVEL)!=null?o:ht(e);r>=s&&console[BS[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0});function or(e,t,n){return Aa(e,t,n).callbackRef}function Aa(e,t,n){const r=b.useRef(null);let o=i=>{};const s=b.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 HS(e,t,n,r,o,s,i,a,l){const c=b.useCallback(d=>{const h=US(d.children,t,a?"offsetWidth":"offsetHeight",o);let m=d.parentElement;for(;!m.dataset.virtuosoScroller;)m=m.parentElement;const f=m.lastElementChild.dataset.viewportType==="window";let v;f&&(v=m.ownerDocument.defaultView);const g=i?a?i.scrollLeft:i.scrollTop:f?a?v.scrollX||v.document.documentElement.scrollLeft:v.scrollY||v.document.documentElement.scrollTop:a?m.scrollLeft:m.scrollTop,x=i?a?i.scrollWidth:i.scrollHeight:f?a?v.document.documentElement.scrollWidth:v.document.documentElement.scrollHeight:a?m.scrollWidth:m.scrollHeight,y=i?a?i.offsetWidth:i.offsetHeight:f?a?v.innerWidth:v.innerHeight:a?m.offsetWidth:m.offsetHeight;r({scrollHeight:x,scrollTop:Math.max(g,0),viewportHeight:y}),s==null||s(a?Jf("column-gap",getComputedStyle(d).columnGap,o):Jf("row-gap",getComputedStyle(d).rowGap,o)),h!==null&&e(h)},[e,t,o,s,i,r,a]);return Aa(c,n,l)}function US(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),c=parseFloat(a.dataset.knownSize),d=t(a,n);if(d===0&&r("Zero-sized element, this should not happen",{child:a},Ht.ERROR),d===c)continue;const h=s[s.length-1];s.length===0||h.size!==d||h.endIndex!==l-1?s.push({endIndex:l,size:d,startIndex:l}):s[s.length-1].endIndex++}return s}function Jf(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Ht.WARN),t==="normal"?0:parseInt(t??"0",10)}function Zf(e,t,n){const r=b.useRef(null),o=b.useCallback(l=>{if(!(l!=null&&l.offsetParent))return;const c=l.getBoundingClientRect(),d=c.width;let h,m;if(t){const f=t.getBoundingClientRect(),v=c.top-f.top;m=f.height-Math.max(0,v),h=v+t.scrollTop}else{const f=i.current.ownerDocument.defaultView;m=f.innerHeight-Math.max(0,c.top),h=c.top+f.scrollY}r.current={offsetTop:h,visibleHeight:m,visibleWidth:d},e(r.current)},[e,t]),{callbackRef:s,ref:i}=Aa(o,!0,n),a=b.useCallback(()=>{o(i.current)},[o,i]);return b.useEffect(()=>{var l;if(t){t.addEventListener("scroll",a);const c=new ResizeObserver(()=>{requestAnimationFrame(a)});return c.observe(t),()=>{t.removeEventListener("scroll",a),c.unobserve(t)}}else{const c=(l=i.current)==null?void 0:l.ownerDocument.defaultView;return c==null||c.addEventListener("scroll",a),c==null||c.addEventListener("resize",a),()=>{c==null||c.removeEventListener("scroll",a),c==null||c.removeEventListener("resize",a)}}},[a,t,i]),s}const Dt=Ke(()=>{const e=Be(),t=Be(),n=se(0),r=Be(),o=se(0),s=Be(),i=Be(),a=se(0),l=se(0),c=se(0),d=se(0),h=Be(),m=Be(),f=se(!1),v=se(!1),g=se(!1);return ve(ne(e,he(({scrollTop:x})=>x)),t),ve(ne(e,he(({scrollHeight:x})=>x)),i),ve(t,o),{deviation:n,fixedFooterHeight:c,fixedHeaderHeight:l,footerHeight:d,headerHeight:a,horizontalDirection:v,scrollBy:m,scrollContainerState:e,scrollHeight:i,scrollingInProgress:f,scrollTo:h,scrollTop:t,skipAnimationFrameInResizeObserver:g,smoothScrollTargetReached:r,statefulScrollTop:o,viewportHeight:s}},[],{singleton:!0}),po={lvl:0};function Qf(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 Ze(e){return e===po}function mo(e,t){if(!Ze(e))return t===e.k?e.v:t<e.k?mo(e.l,t):mo(e.r,t)}function fn(e,t,n="k"){if(Ze(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){const r=fn(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return fn(e.l,t,n)}function Zt(e,t,n){return Ze(e)?nh(t,n,1):t===e.k?vt(e,{k:t,v:n}):t<e.k?rh(vt(e,{l:Zt(e.l,t,n)})):rh(vt(e,{r:Zt(e.r,t,n)}))}function Mr(){return po}function Is(e,t,n){if(Ze(e))return[];const r=fn(e,t)[0];return WS(Pa(e,r,n))}function ja(e,t){if(Ze(e))return po;const{k:n,l:r,r:o}=e;if(t===n){if(Ze(r))return o;if(Ze(o))return r;{const[s,i]=th(r);return Ns(vt(e,{k:s,l:eh(r),v:i}))}}else return t<n?Ns(vt(e,{l:ja(r,t)})):Ns(vt(e,{r:ja(o,t)}))}function sr(e){return Ze(e)?[]:[...sr(e.l),{k:e.k,v:e.v},...sr(e.r)]}function Pa(e,t,n){if(Ze(e))return[];const{k:r,l:o,r:s,v:i}=e;let a=[];return r>t&&(a=a.concat(Pa(o,t,n))),r>=t&&r<=n&&a.push({k:r,v:i}),r<=n&&(a=a.concat(Pa(s,t,n))),a}function Ns(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(_a(t))return oh(vt(e,{lvl:n-1}));if(!Ze(t)&&!Ze(t.r))return vt(t.r,{l:vt(t,{r:t.r.l}),lvl:n,r:vt(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(_a(e))return Ma(vt(e,{lvl:n-1}));if(!Ze(r)&&!Ze(r.l)){const o=r.l,s=_a(o)?r.lvl-1:r.lvl;return vt(o,{l:vt(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:Ma(vt(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function vt(e,t){return nh(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 eh(e){return Ze(e.r)?e.l:Ns(vt(e,{r:eh(e.r)}))}function _a(e){return Ze(e)||e.lvl>e.r.lvl}function th(e){return Ze(e.r)?[e.k,e.v]:th(e.r)}function nh(e,t,n,r=po,o=po){return{k:e,l:r,lvl:n,r:o,v:t}}function rh(e){return Ma(oh(e))}function oh(e){const{l:t}=e;return!Ze(t)&&t.lvl===e.lvl?vt(t,{r:vt(e,{l:t.r})}):e}function Ma(e){const{lvl:t,r:n}=e;return!Ze(n)&&!Ze(n.r)&&n.lvl===t&&n.r.lvl===t?vt(n,{l:vt(e,{r:n.l}),lvl:t+1}):e}function WS(e){return Qf(e,({k:t,v:n})=>({index:t,value:n}))}function sh(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function go(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const Ra=Ke(()=>({recalcInProgress:se(!1)}),[],{singleton:!0});function ih(e,t,n){return e[As(e,t,n)]}function As(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 VS(e,t,n,r){const o=As(e,t,r),s=As(e,n,r,o);return e.slice(o,s+1)}function Un(e,t){return Math.round(e.getBoundingClientRect()[t])}function js(e){return!Ze(e.groupOffsetTree)}function Oa({index:e},t){return t===e?0:t<e?-1:1}function KS(){return{groupIndices:[],groupOffsetTree:Mr(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Mr()}}function qS(e,t){let n=Ze(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),Ze(e)){e=Zt(e,0,s);continue}const a=Is(e,i-1,o+1);if(a.some(eC(r)))continue;let l=!1,c=!1;for(const{end:d,start:h,value:m}of a)l?(o>=h||s===m)&&(e=ja(e,h)):(c=m!==s,l=!0),d>o&&o>=h&&m!==s&&(e=Zt(e,o+1,m));c&&(e=Zt(e,i,s))}return[e,n]}function GS(e){return typeof e.groupIndex<"u"}function YS({offset:e},t){return t===e?0:t<e?-1:1}function xo(e,t,n){if(t.length===0)return 0;const{index:r,offset:o,size:s}=ih(t,e,Oa),i=e-r,a=s*i+(i-1)*n+o;return a>0?a+n:a}function ah(e,t){if(!js(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function lh(e,t,n){if(GS(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=ah(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function XS(e,t,n,r=0){return r>0&&(t=Math.max(t,ih(e,r,Oa).offset)),Qf(VS(e,t,n,YS),QS)}function JS(e,[t,n,r,o]){t.length>0&&r("received item sizes",t,Ht.DEBUG);const s=e.sizeTree;let i=s,a=0;if(n.length>0&&Ze(s)&&t.length===2){const m=t[0].size,f=t[1].size;i=n.reduce((v,g)=>Zt(Zt(v,g,m),g+1,f),i)}else[i,a]=qS(i,t);if(i===s)return e;const{lastIndex:l,lastOffset:c,lastSize:d,offsetTree:h}=Da(e.offsetTree,a,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((m,f)=>Zt(m,f,xo(f,h,o)),Mr()),lastIndex:l,lastOffset:c,lastSize:d,offsetTree:h,sizeTree:i}}function ZS(e){return sr(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 ch(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 Da(e,t,n,r){let o=e,s=0,i=0,a=0,l=0;if(t!==0){l=As(o,t-1,Oa),a=o[l].offset;const c=fn(n,t-1);s=c[0],i=c[1],o.length&&o[l].size===fn(n,t)[1]&&(l-=1),o=o.slice(0,l+1)}else o=[];for(const{start:c,value:d}of Is(n,t,1/0)){const h=c-s,m=h*i+a+h*r;o.push({index:c,offset:m,size:d}),s=c,a=m,i=d}return{lastIndex:s,lastOffset:a,lastSize:i,offsetTree:o}}function QS(e){return{index:e.index,value:e}}function eC(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 tC={offsetHeight:"height",offsetWidth:"width"},kn=Ke(([{log:e},{recalcInProgress:t}])=>{const n=Be(),r=Be(),o=At(r,0),s=Be(),i=Be(),a=se(0),l=se([]),c=se(void 0),d=se(void 0),h=se((C,T)=>Un(C,tC[T])),m=se(void 0),f=se(0),v=KS(),g=At(ne(n,Le(l,e,f),Tn(JS,v),ot()),v),x=At(ne(l,ot(),Tn((C,T)=>({current:T,prev:C.current}),{current:[],prev:[]}),he(({prev:C})=>C)),[]);ve(ne(l,ke(C=>C.length>0),Le(g,f),he(([C,T,E])=>{const j=C.reduce((_,D,F)=>Zt(_,D,xo(D,T.offsetTree,E)||F),Mr());return{...T,groupIndices:C,groupOffsetTree:j}})),g),ve(ne(r,Le(g),ke(([C,{lastIndex:T}])=>C<T),he(([C,{lastIndex:T,lastSize:E}])=>[{endIndex:T,size:E,startIndex:C}])),n),ve(c,d);const y=At(ne(c,he(C=>C===void 0)),!0);ve(ne(d,ke(C=>C!==void 0&&Ze(ht(g).sizeTree)),he(C=>[{endIndex:0,size:C,startIndex:0}])),n);const w=Jt(ne(n,Le(g),Tn(({sizes:C},[T,E])=>({changed:E!==C,sizes:E}),{changed:!1,sizes:v}),he(C=>C.changed)));Ge(ne(a,Tn((C,T)=>({diff:C.prev-T,prev:T}),{diff:0,prev:0}),he(C=>C.diff)),C=>{const{groupIndices:T}=ht(g);if(C>0)Me(t,!0),Me(s,C+ch(C,T));else if(C<0){const E=ht(x);E.length>0&&(C-=ch(-C,E)),Me(i,C)}}),Ge(ne(a,Le(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},Ht.ERROR)});const S=Jt(s);ve(ne(s,Le(g),he(([C,T])=>{const E=T.groupIndices.length>0,j=[],_=T.lastSize;if(E){const D=mo(T.sizeTree,0);let F=0,G=0;for(;F<C;){const A=T.groupIndices[G],Y=T.groupIndices.length===G+1?1/0:T.groupIndices[G+1]-A-1;j.push({endIndex:A,size:D,startIndex:A}),j.push({endIndex:A+1+Y-1,size:_,startIndex:A+1}),G++,F+=Y+1}const K=sr(T.sizeTree);return F!==C&&K.shift(),K.reduce((A,{k:Y,v:q})=>{let W=A.ranges;return A.prevSize!==0&&(W=[...A.ranges,{endIndex:Y+C-1,size:A.prevSize,startIndex:A.prevIndex}]),{prevIndex:Y+C,prevSize:q,ranges:W}},{prevIndex:C,prevSize:0,ranges:j}).ranges}return sr(T.sizeTree).reduce((D,{k:F,v:G})=>({prevIndex:F+C,prevSize:G,ranges:[...D.ranges,{endIndex:F+C-1,size:D.prevSize,startIndex:D.prevIndex}]}),{prevIndex:0,prevSize:_,ranges:[]}).ranges})),n);const k=Jt(ne(i,Le(g,f),he(([C,{offsetTree:T},E])=>{const j=-C;return xo(j,T,E)})));return ve(ne(i,Le(g,f),he(([C,T,E])=>{if(T.groupIndices.length>0){if(Ze(T.sizeTree))return T;let j=Mr();const _=ht(x);let D=0,F=0,G=0;for(;D<-C;){G=_[F];const K=_[F+1]-G-1;F++,D+=K+1}if(j=sr(T.sizeTree).reduce((K,{k:A,v:Y})=>Zt(K,Math.max(0,A+C),Y),j),D!==-C){const K=mo(T.sizeTree,G);j=Zt(j,0,K);const A=fn(T.sizeTree,-C+1)[1];j=Zt(j,1,A)}return{...T,sizeTree:j,...Da(T.offsetTree,0,j,E)}}else{const j=sr(T.sizeTree).reduce((_,{k:D,v:F})=>Zt(_,Math.max(0,D+C),F),Mr());return{...T,sizeTree:j,...Da(T.offsetTree,0,j,E)}}})),g),{beforeUnshiftWith:S,data:m,defaultItemSize:d,firstItemIndex:a,fixedItemSize:c,gap:f,groupIndices:l,itemSize:h,listRefresh:w,shiftWith:i,shiftWithOffset:k,sizeRanges:n,sizes:g,statefulTotalCount:o,totalCount:r,trackItemSizes:y,unshiftWith:s}},rt(Hn,Ra),{singleton:!0});function nC(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const uh=Ke(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=Be(),i=Be(),a=Jt(ne(s,he(nC)));return ve(ne(a,he(l=>l.totalCount)),n),ve(ne(a,he(l=>l.groupIndices)),e),ve(ne(gt(o,t,r),ke(([l,c])=>js(c)),he(([l,c,d])=>fn(c.groupOffsetTree,Math.max(l-d,0),"v")[0]),ot(),he(l=>[l])),i),{groupCounts:s,topItemsIndexes:i}},rt(kn,Dt)),Wn=Ke(([{log:e}])=>{const t=se(!1),n=Jt(ne(t,ke(r=>r),ot()));return Ge(t,r=>{r&&ht(e)("props updated",{},Ht.DEBUG)}),{didMount:n,propsReady:t}},rt(Hn),{singleton:!0}),rC=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function dh(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!rC)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const vo=Ke(([{gap:e,listRefresh:t,sizes:n,totalCount:r},{fixedFooterHeight:o,fixedHeaderHeight:s,footerHeight:i,headerHeight:a,scrollingInProgress:l,scrollTo:c,smoothScrollTargetReached:d,viewportHeight:h},{log:m}])=>{const f=Be(),v=Be(),g=se(0);let x=null,y=null,w=null;function S(){x&&(x(),x=null),w&&(w(),w=null),y&&(clearTimeout(y),y=null),Me(l,!1)}return ve(ne(f,Le(n,h,r,g,a,i,m),Le(e,s,o),he(([[k,C,T,E,j,_,D,F],G,K,A])=>{const Y=dh(k),{align:q,behavior:W,offset:R}=Y,I=E-1,z=lh(Y,C,I);let J=xo(z,C.offsetTree,G)+_;q==="end"?(J+=K+fn(C.sizeTree,z)[1]-T+A,z===I&&(J+=D)):q==="center"?J+=(K+fn(C.sizeTree,z)[1]-T+A)/2:J-=j,R&&(J+=R);const P=O=>{S(),O?(F("retrying to scroll to",{location:k},Ht.DEBUG),Me(f,k)):(Me(v,!0),F("list did not change, scroll successful",{},Ht.DEBUG))};if(S(),W==="smooth"){let O=!1;w=Ge(t,M=>{O=O||M}),x=dn(d,()=>{P(O)})}else x=dn(ne(t,oC(150)),P);return y=setTimeout(()=>{S()},1200),Me(l,!0),F("scrolling from index to",{behavior:W,index:z,top:J},Ht.DEBUG),{behavior:W,top:J}})),c),{scrollTargetReached:v,scrollToIndex:f,topListHeight:g}},rt(kn,Dt,Hn),{singleton:!0});function oC(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function La(e,t){e==0?t():requestAnimationFrame(()=>{La(e-1,t)})}function $a(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const bo=Ke(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:s},{didMount:i}])=>{const a=se(!0),l=se(0),c=se(!0);return ve(ne(i,Le(l),ke(([d,h])=>!!h),Cn(!1)),a),ve(ne(i,Le(l),ke(([d,h])=>!!h),Cn(!1)),c),Ge(ne(gt(t,i),Le(a,n,e,c),ke(([[,d],h,{sizeTree:m},f,v])=>d&&(!Ze(m)||Ea(f))&&!h&&!v),Le(l)),([,d])=>{dn(o,()=>{Me(c,!0)}),La(4,()=>{dn(r,()=>{Me(a,!0)}),Me(s,d)})}),{initialItemFinalLocationReached:c,initialTopMostItemIndex:l,scrolledToInitialItem:a}},rt(kn,Dt,vo,Wn),{singleton:!0});function fh(e,t){return Math.abs(e-t)<1.01}const wo="up",yo="down",sC="none",iC={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},aC=0,So=Ke(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=se(!1),a=se(!0),l=Be(),c=Be(),d=se(4),h=se(aC),m=At(ne(Na(ne(Te(o),rr(1),Cn(!0)),ne(Te(o),rr(1),Cn(!1),Yf(100))),ot()),!1),f=At(ne(Na(ne(n,Cn(!0)),ne(n,Cn(!1),Yf(200))),ot()),!1);ve(ne(gt(Te(o),Te(h)),he(([w,S])=>w<=S),ot()),a),ve(ne(a,Pn(50)),c);const v=Jt(ne(gt(r,Te(s),Te(t),Te(e),Te(d)),Tn((w,[{scrollHeight:S,scrollTop:k},C,T,E,j])=>{const _=k+C-S>-j,D={scrollHeight:S,scrollTop:k,viewportHeight:C};if(_){let G,K;return k>w.state.scrollTop?(G="SCROLLED_DOWN",K=w.state.scrollTop-k):(G="SIZE_DECREASED",K=w.state.scrollTop-k||w.scrollTopDelta),{atBottom:!0,atBottomBecause:G,scrollTopDelta:K,state:D}}let F;return D.scrollHeight>w.state.scrollHeight?F="SIZE_INCREASED":C<w.state.viewportHeight?F="VIEWPORT_HEIGHT_DECREASING":k<w.state.scrollTop?F="SCROLLING_UPWARDS":F="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:F,state:D}},iC),ot((w,S)=>w&&w.atBottom===S.atBottom))),g=At(ne(r,Tn((w,{scrollHeight:S,scrollTop:k,viewportHeight:C})=>{if(fh(w.scrollHeight,S))return{changed:!1,jump:0,scrollHeight:S,scrollTop:k};{const T=S-(k+C)<1;return w.scrollTop!==k&&T?{changed:!0,jump:w.scrollTop-k,scrollHeight:S,scrollTop:k}:{changed:!0,jump:0,scrollHeight:S,scrollTop:k}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),ke(w=>w.changed),he(w=>w.jump)),0);ve(ne(v,he(w=>w.atBottom)),i),ve(ne(i,Pn(50)),l);const x=se(yo);ve(ne(r,he(({scrollTop:w})=>w),ot(),Tn((w,S)=>ht(f)?{direction:w.direction,prevScrollTop:S}:{direction:S<w.prevScrollTop?wo:yo,prevScrollTop:S},{direction:yo,prevScrollTop:0}),he(w=>w.direction)),x),ve(ne(r,Pn(50),Cn(sC)),x);const y=se(0);return ve(ne(m,ke(w=>!w),Cn(0)),y),ve(ne(o,Pn(100),Le(m),ke(([w,S])=>!!S),Tn(([w,S],[k])=>[S,k],[0,0]),he(([w,S])=>S-w)),y),{atBottomState:v,atBottomStateChange:l,atBottomThreshold:d,atTopStateChange:c,atTopThreshold:h,isAtBottom:i,isAtTop:a,isScrolling:m,lastJumpDueToItemResize:g,scrollDirection:x,scrollVelocity:y}},rt(Dt)),Ps="top",_s="bottom",hh="none";function ph(e,t,n){return typeof e=="number"?n===wo&&t===Ps||n===yo&&t===_s?e:0:n===wo?t===Ps?e.main:e.reverse:t===_s?e.main:e.reverse}function mh(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const Fa=Ke(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=Be(),i=se(0),a=se(0),l=se(0),c=At(ne(gt(Te(r),Te(o),Te(n),Te(s,go),Te(l),Te(i),Te(t),Te(e),Te(a)),he(([d,h,m,[f,v],g,x,y,w,S])=>{const k=d-w,C=x+y,T=Math.max(m-k,0);let E=hh;const j=mh(S,Ps),_=mh(S,_s);return f-=w,f+=m+y,v+=m+y,v-=w,f>d+C-j&&(E=wo),v<d-T+h+_&&(E=yo),E!==hh?[Math.max(k-m-ph(g,Ps,E)-j,0),k-T-y+h+ph(g,_s,E)+_]:null}),ke(d=>d!=null),ot(go)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:l,topListHeight:i,visibleRange:c}},rt(Dt),{singleton:!0});function lC(e,t,n){if(js(t)){const r=ah(e,t);return[{index:fn(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 Ba={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Ms(e,t,n,r,o,s){const{lastIndex:i,lastOffset:a,lastSize:l}=o;let c=0,d=0;if(e.length>0){c=e[0].offset;const g=e[e.length-1];d=g.offset+g.size}const h=n-i,m=a+h*l+(h-1)*r,f=c,v=m-d;return{bottom:d,firstItemIndex:s,items:xh(e,o,s),offsetBottom:v,offsetTop:c,top:f,topItems:xh(t,o,s),topListHeight:t.reduce((g,x)=>x.size+g,0),totalCount:n}}function gh(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=$a(t,a),c=Array.from({length:a}).map((d,h)=>({data:s[h+l],index:h+l,offset:0,size:0}));return Ms(c,[],a,o,n,r)}function xh(e,t,n){if(e.length===0)return[];if(!js(t))return e.map(c=>({...c,index:c.index+n,originalIndex:c.index}));const r=e[0].index,o=e[e.length-1].index,s=[],i=Is(t.groupOffsetTree,r,o);let a,l=0;for(const c of e){(!a||a.end<c.index)&&(a=i.shift(),l=t.groupIndices.indexOf(a.start));let d;c.index===a.start?d={index:l,type:"group"}:d={groupIndex:l,index:c.index-(l+1)+n},s.push({...d,data:c.data,offset:c.offset,originalIndex:c.index,size:c.size})}return s}const ir=Ke(([{data:e,firstItemIndex:t,gap:n,sizes:r,totalCount:o},s,{listBoundary:i,topListHeight:a,visibleRange:l},{initialTopMostItemIndex:c,scrolledToInitialItem:d},{topListHeight:h},m,{didMount:f},{recalcInProgress:v}])=>{const g=se([]),x=se(0),y=Be();ve(s.topItemsIndexes,g);const w=At(ne(gt(f,v,Te(l,go),Te(o),Te(r),Te(c),d,Te(g),Te(t),Te(n),e),ke(([T,E,,j,,,,,,,_])=>{const D=_&&_.length!==j;return T&&!E&&!D}),he(([,,[T,E],j,_,D,F,G,K,A,Y])=>{const q=_,{offsetTree:W,sizeTree:R}=q,I=ht(x);if(j===0)return{...Ba,totalCount:j};if(T===0&&E===0)return I===0?{...Ba,totalCount:j}:gh(I,D,_,K,A,Y||[]);if(Ze(R))return I>0?null:Ms(lC($a(D,j),q,Y),[],j,A,q,K);const z=[];if(G.length>0){const L=G[0],ee=G[G.length-1];let H=0;for(const $ of Is(R,L,ee)){const Z=$.value,te=Math.max($.start,L),Q=Math.min($.end,ee);for(let U=te;U<=Q;U++)z.push({data:Y==null?void 0:Y[U],index:U,offset:H,size:Z}),H+=Z}}if(!F)return Ms([],z,j,A,q,K);const J=G.length>0?G[G.length-1]+1:0,P=XS(W,T,E,J);if(P.length===0)return null;const O=j-1,M=Es([],L=>{for(const ee of P){const H=ee.value;let $=H.offset,Z=ee.start;const te=H.size;if(H.offset<T){Z+=Math.floor((T-H.offset+A)/(te+A));const U=Z-ee.start;$+=U*te+U*A}Z<J&&($+=(J-Z)*te,Z=J);const Q=Math.min(ee.end,O);for(let U=Z;U<=Q&&!($>=E);U++)L.push({data:Y==null?void 0:Y[U],index:U,offset:$,size:te}),$+=te+A}});return Ms(M,z,j,A,q,K)}),ke(T=>T!==null),ot()),Ba);ve(ne(e,ke(Ea),he(T=>T==null?void 0:T.length)),o),ve(ne(w,he(T=>T.topListHeight)),h),ve(h,a),ve(ne(w,he(T=>[T.top,T.bottom])),i),ve(ne(w,he(T=>T.items)),y);const S=Jt(ne(w,ke(({items:T})=>T.length>0),Le(o,e),ke(([{items:T},E])=>T[T.length-1].originalIndex===E-1),he(([,T,E])=>[T-1,E]),ot(go),he(([T])=>T))),k=Jt(ne(w,Pn(200),ke(({items:T,topItems:E})=>T.length>0&&T[0].originalIndex===E.length),he(({items:T})=>T[0].index),ot())),C=Jt(ne(w,ke(({items:T})=>T.length>0),he(({items:T})=>{let E=0,j=T.length-1;for(;T[E].type==="group"&&E<j;)E++;for(;T[j].type==="group"&&j>E;)j--;return{endIndex:T[j].index,startIndex:T[E].index}}),ot(sh)));return{endReached:S,initialItemCount:x,itemsRendered:y,listState:w,rangeChanged:C,startReached:k,topItemsIndexes:g,...m}},rt(kn,uh,Fa,bo,vo,So,Wn,Ra),{singleton:!0}),vh=Ke(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=Be(),i=At(ne(gt(n,e,r,t,o),he(([a,l,c,d,h])=>a+l+c+d+h.offsetBottom+h.bottom)),0);return ve(Te(i),s),{totalListHeight:i,totalListHeightChanged:s}},rt(Dt,ir),{singleton:!0}),cC=Ke(([{viewportHeight:e},{totalListHeight:t}])=>{const n=se(!1),r=At(ne(gt(n,e,t),ke(([o])=>o),he(([,o,s])=>Math.max(0,o-s)),Pn(0),ot()),0);return{alignToBottom:n,paddingTopAddition:r}},rt(Dt,vh),{singleton:!0}),bh=Ke(()=>({context:se(null)})),uC=({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,wh=Ke(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:s,scrollingInProgress:i,scrollTop:a,viewportHeight:l},{scrollToIndex:c}])=>{const d=Be();return ve(ne(d,Le(t,l,n,s,o,r,a),Le(e),he(([[h,m,f,v,g,x,y,w],S])=>{const{align:k,behavior:C,calculateViewLocation:T=uC,done:E,...j}=h,_=lh(h,m,v-1),D=xo(_,m.offsetTree,S)+g+x,F=D+fn(m.sizeTree,_)[1],G=w+x,K=w+f-y,A=T({itemBottom:F,itemTop:D,locationParams:{align:k,behavior:C,...j},viewportBottom:K,viewportTop:G});return A?E&&dn(ne(i,ke(Y=>!Y),rr(ht(i)?1:2)),E):E&&E(),A}),ke(h=>h!==null)),c),{scrollIntoView:d}},rt(kn,Dt,vo,ir,Hn),{singleton:!0});function yh(e){return e?e==="smooth"?"smooth":"auto":!1}const dC=(e,t)=>typeof e=="function"?yh(e(t)):t&&yh(e),fC=Ke(([{listRefresh:e,totalCount:t,fixedItemSize:n,data:r},{atBottomState:o,isAtBottom:s},{scrollToIndex:i},{scrolledToInitialItem:a},{didMount:l,propsReady:c},{log:d},{scrollingInProgress:h},{context:m},{scrollIntoView:f}])=>{const v=se(!1),g=Be();let x=null;function y(C){Me(i,{align:"end",behavior:C,index:"LAST"})}Ge(ne(gt(ne(Te(t),rr(1)),l),Le(Te(v),s,a,h),he(([[C,T],E,j,_,D])=>{let F=T&&_,G="auto";return F&&(G=dC(E,j||D),F=F&&!!G),{followOutputBehavior:G,shouldFollow:F,totalCount:C}}),ke(({shouldFollow:C})=>C)),({followOutputBehavior:C,totalCount:T})=>{x&&(x(),x=null),ht(n)?requestAnimationFrame(()=>{ht(d)("following output to ",{totalCount:T},Ht.DEBUG),y(C)}):x=dn(e,()=>{ht(d)("following output to ",{totalCount:T},Ht.DEBUG),y(C),x=null})});function w(C){const T=dn(o,E=>{C&&!E.atBottom&&E.notAtBottomBecause==="SIZE_INCREASED"&&!x&&(ht(d)("scrolling to bottom due to increased size",{},Ht.DEBUG),y("auto"))});setTimeout(T,100)}Ge(ne(gt(Te(v),t,c),ke(([C,,T])=>C&&T),Tn(({value:C},[,T])=>({refreshed:C===T,value:T}),{refreshed:!1,value:0}),ke(({refreshed:C})=>C),Le(v,t)),([,C])=>{ht(a)&&w(C!==!1)}),Ge(g,()=>{w(ht(v)!==!1)}),Ge(gt(Te(v),o),([C,T])=>{C&&!T.atBottom&&T.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&y("auto")});const S=se(null),k=Be();return ve(Na(ne(Te(r),he(C=>{var T;return(T=C==null?void 0:C.length)!=null?T:0})),ne(Te(t))),k),Ge(ne(gt(ne(k,rr(1)),l),Le(Te(S),a,h,m),he(([[C,T],E,j,_,D])=>T&&j&&(E==null?void 0:E({context:D,totalCount:C,scrollingInProgress:_}))),ke(C=>!!C),Pn(0)),C=>{x&&(x(),x=null),ht(n)?requestAnimationFrame(()=>{ht(d)("scrolling into view",{}),Me(f,C)}):x=dn(e,()=>{ht(d)("scrolling into view",{}),Me(f,C),x=null})}),{autoscrollToBottom:g,followOutput:v,scrollIntoViewOnChange:S}},rt(kn,So,vo,bo,Wn,Hn,Dt,bh,wh)),hC=Ke(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(ve(ne(a,Le(s),ke(([,l])=>l!==0),Le(o,r,t,n,e),he(([[,l],c,d,h,m,f=[]])=>gh(l,c,d,h,m,f))),i),{}),rt(kn,bo,ir,Wn),{singleton:!0}),pC=Ke(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=se(0);return Ge(ne(e,Le(r),ke(([,o])=>o!==0),he(([,o])=>({top:o}))),o=>{dn(ne(n,rr(1),ke(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{Me(t,o)})})}),{initialScrollTop:r}},rt(Wn,Dt,ir),{singleton:!0}),Sh=Ke(([{scrollVelocity:e}])=>{const t=se(!1),n=Be(),r=se(!1);return ve(ne(e,Le(r,t,n),ke(([o,s])=>!!s),he(([o,s,i,a])=>{const{enter:l,exit:c}=s;if(i){if(c(o,a))return!1}else if(l(o,a))return!0;return i}),ot()),t),Ge(ne(gt(t,e,n),Le(r)),([[o,s,i],a])=>{o&&a&&a.change&&a.change(s,i)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},rt(So),{singleton:!0}),za=Ke(([{scrollContainerState:e,scrollTo:t}])=>{const n=Be(),r=Be(),o=Be(),s=se(!1),i=se(void 0);return ve(ne(gt(n,r),he(([{scrollHeight:a,scrollTop:l,viewportHeight:c},{offsetTop:d}])=>({scrollHeight:a,scrollTop:Math.max(0,l-d),viewportHeight:c}))),e),ve(ne(t,Le(r),he(([a,{offsetTop:l}])=>({...a,top:a.top+l}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},rt(Dt)),mC=Ke(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:a,windowViewportRect:l}])=>{const c=Be(),d=se(void 0),h=se(null),m=se(null);return ve(a,h),ve(l,m),Ge(ne(c,Le(t,r,i,h,m,n)),([f,v,g,x,y,w,S])=>{const k=ZS(v.sizeTree);x&&y!==null&&w!==null&&(g=y.scrollTop-w.offsetTop),g-=S,f({ranges:k,scrollTop:g})}),ve(ne(d,ke(Ea),he(gC)),o),ve(ne(s,Le(d),ke(([,f])=>f!==void 0),ot(),he(([,f])=>f.ranges)),e),{getState:c,restoreStateFrom:d}},rt(kn,Dt,bo,Wn,za));function gC(e){return{align:"start",index:0,offset:e.scrollTop}}const xC=Ke(([{topItemsIndexes:e}])=>{const t=se(0);return ve(ne(t,ke(n=>n>=0),he(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},rt(ir));function Ch(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const vC=Ch(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),bC=Ke(([{deviation:e,scrollBy:t,scrollingInProgress:n,scrollTop:r},{isAtBottom:o,isScrolling:s,lastJumpDueToItemResize:i,scrollDirection:a},{listState:l},{beforeUnshiftWith:c,gap:d,shiftWithOffset:h,sizes:m},{log:f},{recalcInProgress:v}])=>{const g=Jt(ne(l,Le(i),Tn(([,y,w,S],[{bottom:k,items:C,offsetBottom:T,totalCount:E},j])=>{const _=k+T;let D=0;return w===E&&y.length>0&&C.length>0&&(C[0].originalIndex===0&&y[0].originalIndex===0||(D=_-S,D!==0&&(D+=j))),[D,C,E,_]},[0,[],0,0]),ke(([y])=>y!==0),Le(r,a,n,o,f,v),ke(([,y,w,S,,,k])=>!k&&!S&&y!==0&&w===wo),he(([[y],,,,,w])=>(w("Upward scrolling compensation",{amount:y},Ht.DEBUG),y))));function x(y){y>0?(Me(t,{behavior:"auto",top:-y}),Me(e,0)):(Me(e,0),Me(t,{behavior:"auto",top:-y}))}return Ge(ne(g,Le(e,s)),([y,w,S])=>{S&&vC()?Me(e,w-y):x(-y)}),Ge(ne(gt(At(s,!1),e,v),ke(([y,w,S])=>!y&&!S&&w!==0),he(([y,w])=>w),Pn(1)),x),ve(ne(h,he(y=>({top:-y}))),t),Ge(ne(c,Le(m,d),he(([y,{groupIndices:w,lastSize:S,sizeTree:k},C])=>{function T(E){return E*(S+C)}if(w.length===0)return T(y);{let E=0;const j=mo(k,0);let _=0,D=0;for(;_<y;){_++,E+=j;let F=w.length===D+1?1/0:w[D+1]-w[D]-1;_+F>y&&(E-=j,F=y-_+1),_+=F,E+=T(F),D++}return E}})),y=>{Me(e,y),requestAnimationFrame(()=>{Me(t,{top:y}),requestAnimationFrame(()=>{Me(e,0),Me(v,!1)})})}),{deviation:e}},rt(Dt,So,ir,kn,Hn,Ra)),wC=Ke(([e,t,n,r,o,s,i,a,l,c,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...l,...c,...d}),rt(Fa,hC,Wn,Sh,vh,pC,cC,za,wh,Hn,bh)),Th=Ke(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:r,gap:o,groupIndices:s,itemSize:i,sizeRanges:a,sizes:l,statefulTotalCount:c,totalCount:d,trackItemSizes:h},{initialItemFinalLocationReached:m,initialTopMostItemIndex:f,scrolledToInitialItem:v},g,x,y,{listState:w,topItemsIndexes:S,...k},{scrollToIndex:C},T,{topItemCount:E},{groupCounts:j},_])=>(ve(k.rangeChanged,_.scrollSeekRangeChanged),ve(ne(_.windowViewportRect,he(D=>D.visibleHeight)),g.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,gap:o,groupCounts:j,initialItemFinalLocationReached:m,initialTopMostItemIndex:f,scrolledToInitialItem:v,sizeRanges:a,topItemCount:E,topItemsIndexes:S,totalCount:d,...y,groupIndices:s,itemSize:i,listState:w,scrollToIndex:C,statefulTotalCount:c,trackItemSizes:h,...k,..._,...g,sizes:l,...x}),rt(kn,bo,Dt,mC,fC,ir,vo,bC,xC,uh,wC));function yC(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 Rs=typeof document<"u"?b.useLayoutEffect:b.useEffect;function kh(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=b.createContext({});function l(x,y){x.propsReady&&Me(x.propsReady,!1);for(const w of r){const S=x[t.required[w]];Me(S,y[w])}for(const w of o)if(w in y){const S=x[t.optional[w]];Me(S,y[w])}x.propsReady&&Me(x.propsReady,!0)}function c(x){return s.reduce((y,w)=>(y[w]=S=>{const k=x[t.methods[w]];Me(k,S)},y),{})}function d(x){return i.reduce((y,w)=>(y[w]=LS(x[t.events[w]]),y),{})}const h=b.forwardRef((x,y)=>{const{children:w,...S}=x,[k]=b.useState(()=>Es(FS(e),E=>{l(E,S)})),[C]=b.useState(Gf(d,k));Rs(()=>{for(const E of i)E in S&&Ge(C[E],S[E]);return()=>{Object.values(C).map(Ia)}},[S,C,k]),Rs(()=>{l(k,S)}),b.useImperativeHandle(y,Kf(c(k)));const T=n;return u.jsx(a.Provider,{value:k,children:n?u.jsx(T,{...yC([...r,...o,...i],S),children:w}):w})}),m=x=>{const y=b.useContext(a);return b.useCallback(w=>{Me(y[x],w)},[y,x])},f=x=>{const y=b.useContext(a)[x],w=b.useCallback(S=>Ge(y,S),[y]);return b.useSyncExternalStore(w,()=>ht(y),()=>ht(y))},v=x=>{const y=b.useContext(a)[x],[w,S]=b.useState(Gf(ht,y));return Rs(()=>Ge(y,k=>{k!==w&&S(Kf(k))}),[y,w]),w},g=b.version.startsWith("18")?f:v;return{Component:h,useEmitter:(x,y)=>{const w=b.useContext(a)[x];Rs(()=>Ge(w,y),[y,w])},useEmitterValue:g,usePublisher:m}}const Eh=b.createContext(void 0),Ih=b.createContext(void 0),Nh=typeof document<"u"?b.useLayoutEffect:b.useEffect;function Ha(e){return"self"in e}function SC(e){return"body"in e}function Ah(e,t,n,r=_r,o,s){const i=b.useRef(null),a=b.useRef(null),l=b.useRef(null),c=b.useCallback(m=>{let f,v,g;const x=m.target;if(SC(x)||Ha(x)){const w=Ha(x)?x:x.defaultView;g=s?w.scrollX:w.scrollY,f=s?w.document.documentElement.scrollWidth:w.document.documentElement.scrollHeight,v=s?w.innerWidth:w.innerHeight}else g=s?x.scrollLeft:x.scrollTop,f=s?x.scrollWidth:x.scrollHeight,v=s?x.offsetWidth:x.offsetHeight;const y=()=>{e({scrollHeight:f,scrollTop:Math.max(g,0),viewportHeight:v})};m.suppressFlushSync?y():Mo.flushSync(y),a.current!==null&&(g===a.current||g<=0||g===f-v)&&(a.current=null,t(!0),l.current&&(clearTimeout(l.current),l.current=null))},[e,t,s]);b.useEffect(()=>{const m=o||i.current;return r(o||i.current),c({suppressFlushSync:!0,target:m}),m.addEventListener("scroll",c,{passive:!0}),()=>{r(null),m.removeEventListener("scroll",c)}},[i,c,n,r,o]);function d(m){const f=i.current;if(!f||(s?"offsetWidth"in f&&f.offsetWidth===0:"offsetHeight"in f&&f.offsetHeight===0))return;const v=m.behavior==="smooth";let g,x,y;Ha(f)?(x=Math.max(Un(f.document.documentElement,s?"width":"height"),s?f.document.documentElement.scrollWidth:f.document.documentElement.scrollHeight),g=s?f.innerWidth:f.innerHeight,y=s?window.scrollX:window.scrollY):(x=f[s?"scrollWidth":"scrollHeight"],g=Un(f,s?"width":"height"),y=f[s?"scrollLeft":"scrollTop"]);const w=x-g;if(m.top=Math.ceil(Math.max(Math.min(w,m.top),0)),fh(g,x)||m.top===y){e({scrollHeight:x,scrollTop:y,viewportHeight:g}),v&&t(!0);return}v?(a.current=m.top,l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{l.current=null,a.current=null,t(!0)},1e3)):a.current=null,s&&(m={behavior:m.behavior,left:m.top}),f.scrollTo(m)}function h(m){s&&(m={behavior:m.behavior,left:m.top}),i.current.scrollBy(m)}return{scrollByCallback:h,scrollerRef:i,scrollToCallback:d}}const Ua="-webkit-sticky",jh="sticky",Wa=Ch(()=>{if(typeof document>"u")return jh;const e=document.createElement("div");return e.style.position=Ua,e.style.position===Ua?Ua:jh});function Va(e){return e}const CC=Ke(()=>{const e=se(a=>`Item ${a}`),t=se(a=>`Group ${a}`),n=se({}),r=se(Va),o=se("div"),s=se(_r),i=(a,l=null)=>At(ne(n,he(c=>c[a]),ot()),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")}}),TC=Ke(([e,t])=>({...e,...t}),rt(Th,CC)),kC=({height:e})=>u.jsx("div",{style:{height:e}}),EC={overflowAnchor:"none",position:Wa(),zIndex:1},Ph={overflowAnchor:"none"},IC={...Ph,display:"inline-block",height:"100%"},_h=b.memo(function({showTopList:e=!1}){const t=Ne("listState"),n=tn("sizeRanges"),r=Ne("useWindowScroll"),o=Ne("customScrollParent"),s=tn("windowScrollContainerState"),i=tn("scrollContainerState"),a=o||r?s:i,l=Ne("itemContent"),c=Ne("context"),d=Ne("groupContent"),h=Ne("trackItemSizes"),m=Ne("itemSize"),f=Ne("log"),v=tn("gap"),g=Ne("horizontalDirection"),{callbackRef:x}=HS(n,m,h,e?_r:a,f,v,o,g,Ne("skipAnimationFrameInResizeObserver")),[y,w]=b.useState(0);Ka("deviation",A=>{y!==A&&w(A)});const S=Ne("EmptyPlaceholder"),k=Ne("ScrollSeekPlaceholder")||kC,C=Ne("ListComponent"),T=Ne("ItemComponent"),E=Ne("GroupComponent"),j=Ne("computeItemKey"),_=Ne("isSeeking"),D=Ne("groupIndices").length>0,F=Ne("alignToBottom"),G=Ne("initialItemFinalLocationReached"),K=e?{}:{boxSizing:"border-box",...g?{display:"inline-block",height:"100%",marginLeft:y!==0?y:F?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:y!==0?y:F?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...G?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&S?u.jsx(S,{...jt(S,c)}):u.jsx(C,{...jt(C,c),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:x,style:K,children:(e?t.topItems:t.items).map(A=>{const Y=A.originalIndex,q=j(Y+t.firstItemIndex,A.data,c);return _?b.createElement(k,{...jt(k,c),height:A.size,index:A.index,key:q,type:A.type||"item",...A.type==="group"?{}:{groupIndex:A.groupIndex}}):A.type==="group"?b.createElement(E,{...jt(E,c),"data-index":Y,"data-item-index":A.index,"data-known-size":A.size,key:q,style:EC},d(A.index,c)):b.createElement(T,{...jt(T,c),...PC(T,A.data),"data-index":Y,"data-item-group-index":A.groupIndex,"data-item-index":A.index,"data-known-size":A.size,key:q,style:g?IC:Ph},D?l(A.index,A.groupIndex,A.data,c):l(A.index,A.data,c))})})}),NC={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},AC={outline:"none",overflowX:"auto",position:"relative"},Os=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),jC={position:Wa(),top:0,width:"100%",zIndex:1};function jt(e,t){if(typeof e!="string")return{context:t}}function PC(e,t){return{item:typeof e=="string"?void 0:t}}const _C=b.memo(function(){const e=Ne("HeaderComponent"),t=tn("headerHeight"),n=Ne("HeaderFooterTag"),r=or(b.useMemo(()=>s=>{t(Un(s,"height"))},[t]),!0,Ne("skipAnimationFrameInResizeObserver")),o=Ne("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...jt(e,o)})}):null}),MC=b.memo(function(){const e=Ne("FooterComponent"),t=tn("footerHeight"),n=Ne("HeaderFooterTag"),r=or(b.useMemo(()=>s=>{t(Un(s,"height"))},[t]),!0,Ne("skipAnimationFrameInResizeObserver")),o=Ne("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...jt(e,o)})}):null});function Mh({useEmitter:e,useEmitterValue:t,usePublisher:n}){return b.memo(function({children:r,style:o,context:s,...i}){const a=n("scrollContainerState"),l=t("ScrollerComponent"),c=n("smoothScrollTargetReached"),d=t("scrollerRef"),h=t("horizontalDirection")||!1,{scrollByCallback:m,scrollerRef:f,scrollToCallback:v}=Ah(a,c,l,d,void 0,h);return e("scrollTo",v),e("scrollBy",m),u.jsx(l,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:f,style:{...h?AC:NC,...o},tabIndex:0,...i,...jt(l,s),children:r})})}function Rh({useEmitter:e,useEmitterValue:t,usePublisher:n}){return b.memo(function({children:r,style:o,context:s,...i}){const a=n("windowScrollContainerState"),l=t("ScrollerComponent"),c=n("smoothScrollTargetReached"),d=t("totalListHeight"),h=t("deviation"),m=t("customScrollParent"),f=b.useRef(null),v=t("scrollerRef"),{scrollByCallback:g,scrollerRef:x,scrollToCallback:y}=Ah(a,c,l,v,m);return Nh(()=>{var w;return x.current=m||((w=f.current)==null?void 0:w.ownerDocument.defaultView),()=>{x.current=null}},[x,m]),e("windowScrollTo",y),e("scrollBy",g),u.jsx(l,{ref:f,"data-virtuoso-scroller":!0,style:{position:"relative",...o,...d!==0?{height:d+h}:{}},...i,...jt(l,s),children:r})})}const RC=({children:e})=>{const t=b.useContext(Eh),n=tn("viewportHeight"),r=tn("fixedItemHeight"),o=Ne("alignToBottom"),s=Ne("horizontalDirection"),i=b.useMemo(()=>qf(n,l=>Un(l,s?"width":"height")),[n,s]),a=or(i,!0,Ne("skipAnimationFrameInResizeObserver"));return b.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),u.jsx("div",{"data-viewport-type":"element",ref:a,style:Os(o),children:e})},OC=({children:e})=>{const t=b.useContext(Eh),n=tn("windowViewportRect"),r=tn("fixedItemHeight"),o=Ne("customScrollParent"),s=Zf(n,o,Ne("skipAnimationFrameInResizeObserver")),i=Ne("alignToBottom");return b.useEffect(()=>{t&&(r(t.itemHeight),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),u.jsx("div",{"data-viewport-type":"window",ref:s,style:Os(i),children:e})},DC=({children:e})=>{const t=Ne("TopItemListComponent")||"div",n=Ne("headerHeight"),r={...jC,marginTop:`${n}px`},o=Ne("context");return u.jsx(t,{style:r,...jt(t,o),children:e})},LC=b.memo(function(e){const t=Ne("useWindowScroll"),n=Ne("topItemsIndexes").length>0,r=Ne("customScrollParent"),o=Ne("context");return u.jsxs(r||t?BC:FC,{...e,context:o,children:[n&&u.jsx(DC,{children:u.jsx(_h,{showTopList:!0})}),u.jsxs(r||t?OC:RC,{children:[u.jsx(_C,{}),u.jsx(_h,{}),u.jsx(MC,{})]})]})}),{Component:$C,useEmitter:Ka,useEmitterValue:Ne,usePublisher:tn}=kh(TC,{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"}},LC),FC=Mh({useEmitter:Ka,useEmitterValue:Ne,usePublisher:tn}),BC=Rh({useEmitter:Ka,useEmitterValue:Ne,usePublisher:tn}),zC=$C;rt(Th,Ke(()=>{const e=se(c=>u.jsxs("td",{children:["Item $",c]})),t=se(null),n=se(c=>u.jsxs("td",{colSpan:1e3,children:["Group ",c]})),r=se(null),o=se(null),s=se({}),i=se(Va),a=se(_r),l=(c,d=null)=>At(ne(s,he(h=>h[c]),ot()),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")}})),Wa();const Oh={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},HC={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:Dh,floor:Ds,max:Co,min:qa,round:Lh}=Math;function $h(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function UC(e){return{...HC,items:e}}function Ls(e,t){return e&&e.width===t.width&&e.height===t.height}function WC(e,t){return e&&e.column===t.column&&e.row===t.row}const VC=Ke(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:r},{footerHeight:o,headerHeight:s,scrollBy:i,scrollContainerState:a,scrollTo:l,scrollTop:c,smoothScrollTargetReached:d,viewportHeight:h},m,f,{didMount:v,propsReady:g},{customScrollParent:x,useWindowScroll:y,windowScrollContainerState:w,windowScrollTo:S,windowViewportRect:k},C])=>{const T=se(0),E=se(0),j=se(Oh),_=se({height:0,width:0}),D=se({height:0,width:0}),F=Be(),G=Be(),K=se(0),A=se(null),Y=se({column:0,row:0}),q=Be(),W=Be(),R=se(!1),I=se(0),z=se(!0),J=se(!1),P=se(!1);Ge(ne(v,Le(I),ke(([$,Z])=>!!Z)),()=>{Me(z,!1)}),Ge(ne(gt(v,z,D,_,I,J),ke(([$,Z,te,Q,,U])=>$&&!Z&&te.height!==0&&Q.height!==0&&!U)),([,,,,$])=>{Me(J,!0),La(1,()=>{Me(F,$)}),dn(ne(c),()=>{Me(t,[0,0]),Me(z,!0)})}),ve(ne(W,ke($=>$!=null&&$.scrollTop>0),Cn(0)),E),Ge(ne(v,Le(W),ke(([,$])=>$!=null)),([,$])=>{$&&(Me(_,$.viewport),Me(D,$.item),Me(Y,$.gap),$.scrollTop>0&&(Me(R,!0),dn(ne(c,rr(1)),Z=>{Me(R,!1)}),Me(l,{top:$.scrollTop})))}),ve(ne(_,he(({height:$})=>$)),h),ve(ne(gt(Te(_,Ls),Te(D,Ls),Te(Y,($,Z)=>$&&$.column===Z.column&&$.row===Z.row),Te(c)),he(([$,Z,te,Q])=>({gap:te,item:Z,scrollTop:Q,viewport:$}))),q),ve(ne(gt(Te(T),r,Te(Y,WC),Te(D,Ls),Te(_,Ls),Te(A),Te(E),Te(R),Te(z),Te(I)),ke(([,,,,,,,$])=>!$),he(([$,[Z,te],Q,U,le,ie,ge,,we,Ce])=>{const{column:Ae,row:Ee}=Q,{height:st,width:lt}=U,{width:St}=le;if(ge===0&&($===0||St===0))return Oh;if(lt===0){const Et=$a(Ce,$),bt=Et+Math.max(ge-1,0);return UC($h(Et,bt,ie))}const Oe=Fh(St,lt,Ae);let qe,We;we?Z===0&&te===0&&ge>0?(qe=0,We=ge-1):(qe=Oe*Ds((Z+Ee)/(st+Ee)),We=Oe*Dh((te+Ee)/(st+Ee))-1,We=qa($-1,Co(We,Oe-1)),qe=qa(We,Co(0,qe))):(qe=0,We=-1);const je=$h(qe,We,ie),{bottom:_e,top:ct}=Bh(le,Q,U,je),kt=Dh($/Oe),nt=kt*st+(kt-1)*Ee-_e;return{bottom:_e,itemHeight:st,items:je,itemWidth:lt,offsetBottom:nt,offsetTop:ct,top:ct}})),j),ve(ne(A,ke($=>$!==null),he($=>$.length)),T),ve(ne(gt(_,D,j,Y),ke(([$,Z,{items:te}])=>te.length>0&&Z.height!==0&&$.height!==0),he(([$,Z,{items:te},Q])=>{const{bottom:U,top:le}=Bh($,Q,Z,te);return[le,U]}),ot(go)),t);const O=se(!1);ve(ne(c,Le(O),he(([$,Z])=>Z||$!==0)),O);const M=Jt(ne(gt(j,T),ke(([{items:$}])=>$.length>0),Le(O),ke(([[$,Z],te])=>{const Q=$.items[$.items.length-1].index===Z-1;return(te||$.bottom>0&&$.itemHeight>0&&$.offsetBottom===0&&$.items.length===Z)&&Q}),he(([[,$]])=>$-1),ot())),L=Jt(ne(Te(j),ke(({items:$})=>$.length>0&&$[0].index===0),Cn(0),ot())),ee=Jt(ne(Te(j),Le(R),ke(([{items:$},Z])=>$.length>0&&!Z),he(([{items:$}])=>({endIndex:$[$.length-1].index,startIndex:$[0].index})),ot(sh),Pn(0)));ve(ee,f.scrollSeekRangeChanged),ve(ne(F,Le(_,D,T,Y),he(([$,Z,te,Q,U])=>{const le=dh($),{align:ie,behavior:ge,offset:we}=le;let Ce=le.index;Ce==="LAST"&&(Ce=Q-1),Ce=Co(0,Ce,qa(Q-1,Ce));let Ae=Ga(Z,U,te,Ce);return ie==="end"?Ae=Lh(Ae-Z.height+te.height):ie==="center"&&(Ae=Lh(Ae-Z.height/2+te.height/2)),we&&(Ae+=we),{behavior:ge,top:Ae}})),l);const H=At(ne(j,he($=>$.offsetBottom+$.bottom)),0);return ve(ne(k,he($=>({height:$.visibleHeight,width:$.visibleWidth}))),_),{customScrollParent:x,data:A,deviation:K,footerHeight:o,gap:Y,headerHeight:s,increaseViewportBy:e,initialItemCount:E,itemDimensions:D,overscan:n,restoreStateFrom:W,scrollBy:i,scrollContainerState:a,scrollHeight:G,scrollTo:l,scrollToIndex:F,scrollTop:c,smoothScrollTargetReached:d,totalCount:T,useWindowScroll:y,viewportDimensions:_,windowScrollContainerState:w,windowScrollTo:S,windowViewportRect:k,...f,gridState:j,horizontalDirection:P,initialTopMostItemIndex:I,totalListHeight:H,...m,endReached:M,propsReady:g,rangeChanged:ee,startReached:L,stateChanged:q,stateRestoreInProgress:R,...C}},rt(Fa,Dt,So,Sh,Wn,za,Hn));function Fh(e,t,n){return Co(1,Ds((e+n)/(Ds(t)+n)))}function Bh(e,t,n,r){const{height:o}=n;if(o===void 0||r.length===0)return{bottom:0,top:0};const s=Ga(e,t,n,r[0].index);return{bottom:Ga(e,t,n,r[r.length-1].index)+o,top:s}}function Ga(e,t,n,r){const o=Fh(e.width,n.width,t.column),s=Ds(r/o),i=s*n.height+Co(0,s-1)*t.row;return i>0?i+t.row:i}const KC=Ke(()=>{const e=se(h=>`Item ${h}`),t=se({}),n=se(null),r=se("virtuoso-grid-item"),o=se("virtuoso-grid-list"),s=se(Va),i=se("div"),a=se(_r),l=(h,m=null)=>At(ne(t,he(f=>f[h]),ot()),m),c=se(!1),d=se(!1);return ve(Te(d),c),{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:c,reportReadyState:d,ScrollerComponent:l("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder","div")}}),qC=Ke(([e,t])=>({...e,...t}),rt(VC,KC)),GC=b.memo(function(){const e=at("gridState"),t=at("listClassName"),n=at("itemClassName"),r=at("itemContent"),o=at("computeItemKey"),s=at("isSeeking"),i=nn("scrollHeight"),a=at("ItemComponent"),l=at("ListComponent"),c=at("ScrollSeekPlaceholder"),d=at("context"),h=nn("itemDimensions"),m=nn("gap"),f=at("log"),v=at("stateRestoreInProgress"),g=nn("reportReadyState"),x=or(b.useMemo(()=>y=>{const w=y.parentElement.parentElement.scrollHeight;i(w);const S=y.firstChild;if(S){const{height:k,width:C}=S.getBoundingClientRect();h({height:k,width:C})}m({column:Hh("column-gap",getComputedStyle(y).columnGap,f),row:Hh("row-gap",getComputedStyle(y).rowGap,f)})},[i,h,m,f]),!0,!1);return Nh(()=>{e.itemHeight>0&&e.itemWidth>0&&g(!0)},[e]),v?null:u.jsx(l,{className:t,ref:x,...jt(l,d),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(y=>{const w=o(y.index,y.data,d);return s?u.jsx(c,{...jt(c,d),height:e.itemHeight,index:y.index,width:e.itemWidth},w):b.createElement(a,{...jt(a,d),className:n,"data-index":y.index,key:w},r(y.index,y.data,d))})})}),YC=b.memo(function(){const e=at("HeaderComponent"),t=nn("headerHeight"),n=at("headerFooterTag"),r=or(b.useMemo(()=>s=>{t(Un(s,"height"))},[t]),!0,!1),o=at("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...jt(e,o)})}):null}),XC=b.memo(function(){const e=at("FooterComponent"),t=nn("footerHeight"),n=at("headerFooterTag"),r=or(b.useMemo(()=>s=>{t(Un(s,"height"))},[t]),!0,!1),o=at("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...jt(e,o)})}):null}),JC=({children:e})=>{const t=b.useContext(Ih),n=nn("itemDimensions"),r=nn("viewportDimensions"),o=or(b.useMemo(()=>s=>{r(s.getBoundingClientRect())},[r]),!0,!1);return b.useEffect(()=>{t&&(r({height:t.viewportHeight,width:t.viewportWidth}),n({height:t.itemHeight,width:t.itemWidth}))},[t,r,n]),u.jsx("div",{ref:o,style:Os(!1),children:e})},ZC=({children:e})=>{const t=b.useContext(Ih),n=nn("windowViewportRect"),r=nn("itemDimensions"),o=at("customScrollParent"),s=Zf(n,o,!1);return b.useEffect(()=>{t&&(r({height:t.itemHeight,width:t.itemWidth}),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:t.viewportWidth}))},[t,n,r]),u.jsx("div",{ref:s,style:Os(!1),children:e})},QC=b.memo(function({...e}){const t=at("useWindowScroll"),n=at("customScrollParent"),r=n||t?tT:eT,o=n||t?ZC:JC,s=at("context");return u.jsx(r,{...e,...jt(r,s),children:u.jsxs(o,{children:[u.jsx(YC,{}),u.jsx(GC,{}),u.jsx(XC,{})]})})}),{useEmitter:zh,useEmitterValue:at,usePublisher:nn}=kh(qC,{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"}},QC),eT=Mh({useEmitter:zh,useEmitterValue:at,usePublisher:nn}),tT=Rh({useEmitter:zh,useEmitterValue:at,usePublisher:nn});function Hh(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Ht.WARN),t==="normal"?0:parseInt(t??"0",10)}var $s="Dialog",[Uh,_N]=ln($s),[nT,hn]=Uh($s),Wh=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:i=!0}=e,a=p.useRef(null),l=p.useRef(null),[c,d]=Dn({prop:r,defaultProp:o??!1,onChange:s,caller:$s});return u.jsx(nT,{scope:t,triggerRef:a,contentRef:l,contentId:Nt(),titleId:Nt(),descriptionId:Nt(),open:c,onOpenChange:d,onOpenToggle:p.useCallback(()=>d(h=>!h),[d]),modal:i,children:n})};Wh.displayName=$s;var Vh="DialogTrigger",Kh=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=hn(Vh,n),s=De(t,o.triggerRef);return u.jsx(xe.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Ja(o.open),...r,ref:s,onClick:ce(e.onClick,o.onOpenToggle)})});Kh.displayName=Vh;var Ya="DialogPortal",[rT,qh]=Uh(Ya,{forceMount:void 0}),Gh=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=hn(Ya,t);return u.jsx(rT,{scope:t,forceMount:n,children:p.Children.map(r,i=>u.jsx(zt,{present:n||s.open,children:u.jsx(so,{asChild:!0,container:o,children:i})}))})};Gh.displayName=Ya;var Fs="DialogOverlay",Yh=p.forwardRef((e,t)=>{const n=qh(Fs,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=hn(Fs,e.__scopeDialog);return s.modal?u.jsx(zt,{present:r||s.open,children:u.jsx(sT,{...o,ref:t})}):null});Yh.displayName=Fs;var oT=Kt.createSlot("DialogOverlay.RemoveScroll"),sT=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=hn(Fs,n);return u.jsx(xs,{as:oT,allowPinchZoom:!0,shards:[o.contentRef],children:u.jsx(xe.div,{"data-state":Ja(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),ar="DialogContent",Xh=p.forwardRef((e,t)=>{const n=qh(ar,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=hn(ar,e.__scopeDialog);return u.jsx(zt,{present:r||s.open,children:s.modal?u.jsx(iT,{...o,ref:t}):u.jsx(aT,{...o,ref:t})})});Xh.displayName=ar;var iT=p.forwardRef((e,t)=>{const n=hn(ar,e.__scopeDialog),r=p.useRef(null),o=De(t,n.contentRef,r);return p.useEffect(()=>{const s=r.current;if(s)return fa(s)},[]),u.jsx(Jh,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ce(e.onCloseAutoFocus,s=>{var i;s.preventDefault(),(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:ce(e.onPointerDownOutside,s=>{const i=s.detail.originalEvent,a=i.button===0&&i.ctrlKey===!0;(i.button===2||a)&&s.preventDefault()}),onFocusOutside:ce(e.onFocusOutside,s=>s.preventDefault())})}),aT=p.forwardRef((e,t)=>{const n=hn(ar,e.__scopeDialog),r=p.useRef(!1),o=p.useRef(!1);return u.jsx(Jh,{...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,c;(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;((c=n.triggerRef.current)==null?void 0:c.contains(i))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&o.current&&s.preventDefault()}})}),Jh=p.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=hn(ar,n),l=p.useRef(null),c=De(t,l);return Ui(),u.jsxs(u.Fragment,{children:[u.jsx(Zo,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:u.jsx(yr,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":Ja(a.open),...i,ref:c,onDismiss:()=>a.onOpenChange(!1)})}),u.jsxs(u.Fragment,{children:[u.jsx(lT,{titleId:a.titleId}),u.jsx(uT,{contentRef:l,descriptionId:a.descriptionId})]})]})}),Xa="DialogTitle",Zh=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=hn(Xa,n);return u.jsx(xe.h2,{id:o.titleId,...r,ref:t})});Zh.displayName=Xa;var Qh="DialogDescription",ep=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=hn(Qh,n);return u.jsx(xe.p,{id:o.descriptionId,...r,ref:t})});ep.displayName=Qh;var tp="DialogClose",np=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=hn(tp,n);return u.jsx(xe.button,{type:"button",...r,ref:t,onClick:ce(e.onClick,()=>o.onOpenChange(!1))})});np.displayName=tp;function Ja(e){return e?"open":"closed"}var rp="DialogTitleWarning",[MN,op]=Tb(rp,{contentName:ar,titleName:Xa,docsSlug:"dialog"}),lT=({titleId:e})=>{const t=op(rp),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
80
80
|
|
|
81
81
|
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
82
82
|
|
|
@@ -124,7 +124,7 @@ ${t}</blockquote>
|
|
|
124
124
|
${t}</tr>
|
|
125
125
|
`}tablecell(t,n){const r=n.header?"th":"td";return(n.align?`<${r} align="${n.align}">`:`<${r}>`)+t+`</${r}>
|
|
126
126
|
`}strong(t){return`<strong>${t}</strong>`}em(t){return`<em>${t}</em>`}codespan(t){return`<code>${t}</code>`}br(){return this.options.xhtml?"<br/>":"<br>"}del(t){return`<del>${t}</del>`}link(t,n,r){if(t=pp(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=pp(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 bp{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 wp{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 Kn{constructor(t){this.options=t||cr,this.options.renderer=this.options.renderer||new sl,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new bp,this.slugger=new wp}static parse(t,n){return new Kn(n).parse(t)}static parseInline(t,n){return new Kn(n).parseInline(t)}parse(t,n=!0){let r="",o,s,i,a,l,c,d,h,m,f,v,g,x,y,w,S,k,C,T;const E=t.length;for(o=0;o<E;o++){if(f=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[f.type]&&(T=this.options.extensions.renderers[f.type].call({parser:this},f),T!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(f.type))){r+=T||"";continue}switch(f.type){case"space":continue;case"hr":{r+=this.renderer.hr();continue}case"heading":{r+=this.renderer.heading(this.parseInline(f.tokens),f.depth,hp(this.parseInline(f.tokens,this.textRenderer)),this.slugger);continue}case"code":{r+=this.renderer.code(f.text,f.lang,f.escaped);continue}case"table":{for(h="",d="",a=f.header.length,s=0;s<a;s++)d+=this.renderer.tablecell(this.parseInline(f.header[s].tokens),{header:!0,align:f.align[s]});for(h+=this.renderer.tablerow(d),m="",a=f.rows.length,s=0;s<a;s++){for(c=f.rows[s],d="",l=c.length,i=0;i<l;i++)d+=this.renderer.tablecell(this.parseInline(c[i].tokens),{header:!1,align:f.align[i]});m+=this.renderer.tablerow(d)}r+=this.renderer.table(h,m);continue}case"blockquote":{m=this.parse(f.tokens),r+=this.renderer.blockquote(m);continue}case"list":{for(v=f.ordered,g=f.start,x=f.loose,a=f.items.length,m="",s=0;s<a;s++)w=f.items[s],S=w.checked,k=w.task,y="",w.task&&(C=this.renderer.checkbox(S),x?w.tokens.length>0&&w.tokens[0].type==="paragraph"?(w.tokens[0].text=C+" "+w.tokens[0].text,w.tokens[0].tokens&&w.tokens[0].tokens.length>0&&w.tokens[0].tokens[0].type==="text"&&(w.tokens[0].tokens[0].text=C+" "+w.tokens[0].tokens[0].text)):w.tokens.unshift({type:"text",text:C}):y+=C),y+=this.parse(w.tokens,x),m+=this.renderer.listitem(y,k,S);r+=this.renderer.list(m,v,g);continue}case"html":{r+=this.renderer.html(f.text);continue}case"paragraph":{r+=this.renderer.paragraph(this.parseInline(f.tokens));continue}case"text":{for(m=f.tokens?this.parseInline(f.tokens):f.text;o+1<E&&t[o+1].type==="text";)f=t[++o],m+=`
|
|
127
|
-
`+(f.tokens?this.parseInline(f.tokens):f.text);r+=n?this.renderer.paragraph(m):m;continue}default:{const
|
|
128
|
-
Please report this to https://github.com/markedjs/marked.`,e){const o="<p>An error occurred:</p><pre>"+Pt(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 yp(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...be.defaults,...s};const i=OT(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(_T(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(h){return i(h)}const c=function(h){let m;if(!h)try{r.walkTokens&&be.walkTokens(l,r.walkTokens),m=t(l,r),r.hooks&&(m=r.hooks.postprocess(m))}catch(f){h=f}return r.highlight=a,h?i(h):o(null,m)};if(!a||a.length<3||(delete r.highlight,!l.length))return c();let d=0;be.walkTokens(l,function(h){h.type==="code"&&(d++,setTimeout(()=>{a(h.text,h.lang,function(m,f){if(m)return c(m);f!=null&&f!==h.text&&(h.text=f,h.escaped=!0),d--,d===0&&c()})},0))}),d===0&&c();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(be.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&&be.walkTokens(a,r.walkTokens);let l=t(a,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(a){return i(a)}}}function be(e,t,n){return yp(Vn.lex,Kn.parse)(e,t,n)}be.options=be.setOptions=function(e){return be.defaults={...be.defaults,...e},bT(be.defaults),be},be.getDefaults=cp,be.defaults=cr,be.use=function(...e){const t=be.defaults.extensions||{renderers:{},childTokens:{}};e.forEach(n=>{const r={...n};if(r.async=be.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=be.defaults.renderer||new sl;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=be.defaults.tokenizer||new ol;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=be.defaults.hooks||new Ys;for(const s in n.hooks){const i=o[s];Ys.passThroughHooks.has(s)?o[s]=a=>{if(be.defaults.async)return Promise.resolve(n.hooks[s].call(o,a)).then(c=>i.call(o,c));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=be.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}}be.setOptions(r)})},be.walkTokens=function(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(be,r)),r.type){case"table":{for(const o of r.header)n=n.concat(be.walkTokens(o.tokens,t));for(const o of r.rows)for(const s of o)n=n.concat(be.walkTokens(s.tokens,t));break}case"list":{n=n.concat(be.walkTokens(r.items,t));break}default:be.defaults.extensions&&be.defaults.extensions.childTokens&&be.defaults.extensions.childTokens[r.type]?be.defaults.extensions.childTokens[r.type].forEach(function(o){n=n.concat(be.walkTokens(r[o],t))}):r.tokens&&(n=n.concat(be.walkTokens(r.tokens,t)))}return n},be.parseInline=yp(Vn.lexInline,Kn.parseInline),be.Parser=Kn,be.parser=Kn.parse,be.Renderer=sl,be.TextRenderer=bp,be.Lexer=Vn,be.lexer=Vn.lex,be.Tokenizer=ol,be.Slugger=wp,be.Hooks=Ys,be.parse=be,be.options,be.setOptions,be.use,be.walkTokens,be.parseInline,Kn.parse,Vn.lex;function qn({content:e,className:t="",allowHtml:n=!1,style:r}){const o=b.useMemo(()=>{if(!e||typeof e!="string"||e.trim().length===0)return"";try{if(!n){const i=e.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"").replace(/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi,"").replace(/javascript:/gi,"").replace(/on\w+\s*=/gi,"");return typeof be.parse=="function"?be.parse(i):be(i)}return typeof be.parse=="function"?be.parse(e):be(e)}catch(i){return console.error("[MarkdownContent] parse error",i),`<pre class="font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words">Error rendering markdown: ${String(i)}</pre>`}},[e,n]),s=b.useMemo(()=>{const i={color:"currentColor",...r};if(r&&r.color){const a=r.color;return{...i,"--tw-prose-body":a,"--tw-prose-headings":a,"--tw-prose-links":a,"--tw-prose-bold":a,"--tw-prose-counters":a,"--tw-prose-bullets":a,"--tw-prose-hr":a,"--tw-prose-quotes":a,"--tw-prose-quote-borders":a,"--tw-prose-captions":a,"--tw-prose-code":a,"--tw-prose-pre-code":a,"--tw-prose-pre-bg":"inherit","--tw-prose-th-borders":a,"--tw-prose-td-borders":a}}return i},[r]);return u.jsx("div",{className:oe("markdown prose prose-sm max-w-none break-words","dark:prose-invert","text-current","prose-headings:text-current prose-p:text-current prose-li:text-current prose-a:text-current prose-strong:text-current","prose-em:text-current prose-blockquote:text-current prose-table:text-current prose-td:text-current prose-th:text-current","prose-pre:font-mono prose-pre:text-xs prose-pre:bg-background/50 prose-pre:border prose-pre:rounded prose-pre:p-3 prose-pre:whitespace-pre prose-pre:overflow-x-auto","prose-code:font-mono prose-code:text-sm prose-code:bg-background/50 prose-code:px-1.5 prose-code:py-0.5 prose-code:rounded prose-code:text-current",t),style:s,dangerouslySetInnerHTML:{__html:o}})}function Sp({preview:e,idx:t}){return u.jsxs("div",{className:"space-y-2",children:[e.label&&u.jsxs("p",{className:"text-[0.65rem] uppercase tracking-wide text-muted-foreground",children:["Artifact: ",e.label]}),u.jsx("div",{className:"overflow-hidden rounded border border-border/60 bg-background/60 p-1 shadow-sm",children:u.jsx("img",{src:e.src,alt:e.alt,title:e.label,loading:"lazy",className:"h-auto max-h-[420px] w-full rounded object-contain",onLoad:()=>{},onError:n=>{console.error(`[MessageComponent] ❌ Image failed to load for artifact ${t}:`,{alt:e.alt,label:e.label,message:n.target.alt})}})})]})}const Cp={completed:{label:"Completed",badgeClass:"border border-green-200 bg-green-50 text-green-700"},success:{label:"Completed",badgeClass:"border border-green-200 bg-green-50 text-green-700"},failed:{label:"Failed",badgeClass:"border border-red-200 bg-red-50 text-red-700"},error:{label:"Failed",badgeClass:"border border-red-200 bg-red-50 text-red-700"},cancelled:{label:"Cancelled",badgeClass:"border border-orange-200 bg-orange-50 text-orange-700"},cancel:{label:"Cancelled",badgeClass:"border border-orange-200 bg-orange-50 text-orange-700"},pending:{label:"Pending",badgeClass:"border border-blue-200 bg-blue-50 text-blue-700"},processing:{label:"Processing",badgeClass:"border border-yellow-200 bg-yellow-50 text-yellow-700"}},DT=e=>{if(!e)return Cp.processing;const t=e.toLowerCase().trim();return Cp[t]??{label:t.replace(/(^\w|\s\w)/g,n=>n.toUpperCase()),badgeClass:"border border-slate-200 bg-slate-50 text-slate-800"}},LT=e=>e?e.length>10?`${e.slice(0,8)}…`:e:"";function Tp({artifact:e}){const t=DT(e.status),n=e.task_url??e.taskUrl??"";return u.jsxs("div",{className:"rounded-lg border border-blue-200/70 bg-blue-50/40 p-4 space-y-3",children:[u.jsxs("div",{className:"flex items-start justify-between gap-3",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsx("div",{className:"flex h-7 w-7 items-center justify-center rounded-full bg-blue-600/10 text-blue-600",children:u.jsx(ue.Search,{className:"h-4 w-4"})}),u.jsxs("div",{className:"space-y-1",children:[u.jsx("p",{className:"text-xs font-semibold uppercase tracking-wide text-blue-700",children:"Research Task"}),u.jsxs("p",{className:"text-[11px] text-blue-900/80",children:["Task ID: ",u.jsx("span",{className:"font-mono",children:LT(e.task_id)})]})]})]}),t&&u.jsx("span",{className:`inline-flex items-center rounded-full px-3 py-1 text-[11px] font-semibold ${t.badgeClass}`,children:t.label})]}),e.query&&u.jsxs("div",{className:"rounded border border-blue-100 bg-white/80 px-3 py-2 text-xs text-blue-900/90",children:[u.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wide text-blue-500",children:"Query"}),u.jsx("p",{className:"line-clamp-2 text-[11px] text-blue-900",children:e.query})]}),typeof e.results=="string"&&e.results.trim()&&u.jsxs("div",{className:"rounded border border-blue-100 bg-white/80 px-3 py-2 text-sm text-blue-900/90 space-y-1",children:[u.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wide text-blue-500",children:"Results"}),u.jsx(qn,{content:e.results,allowHtml:!1,className:"prose text-xs !prose-sm prose-blue dark:prose-invert"})]}),u.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[n?u.jsxs("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 rounded-full border border-blue-600/80 bg-blue-600/10 px-3 py-1 text-xs font-semibold text-blue-700 transition hover:bg-blue-600/20",children:[u.jsx("span",{children:"Go to task"}),u.jsx(ue.ExternalLink,{className:"h-3 w-3"})]}):u.jsx("span",{className:"text-xs text-muted-foreground",children:"Task link unavailable"}),e.createdAt&&u.jsxs("p",{className:"text-[10px] text-blue-700/70",children:["Started: ",new Date(e.createdAt).toLocaleTimeString()]})]})]})}function kp({artifact:e,idx:t=0}){const n=b.useMemo(()=>e?(Array.isArray(e.plots)?e.plots:[]).map(o=>sb(o)).filter(o=>o!==null):[],[e]);return(e==null?void 0:e.type)==="research_task_info"?u.jsx(Tp,{artifact:{type:"research_task_info",task_id:e.task_id,task_url:e.task_url,query:e.query,status:e.status,createdAt:e.createdAt}}):n.length>0?u.jsx("div",{className:"space-y-2",children:n.map((r,o)=>u.jsx(Sp,{preview:r,idx:o},`${t}-plot-${o}`))}):e&&typeof e=="object"?u.jsx("div",{className:"rounded-lg border border-gray-200 dark:border-gray-800 bg-gray-50 dark:bg-gray-900/20 p-4",children:u.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:["Unknown artifact type: ",u.jsx("code",{className:"font-mono",children:e.type||"unknown"})]})}):null}const il=p.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:oe("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));il.displayName="Card";const al=p.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:oe("flex flex-col space-y-1.5 p-6",e),...t}));al.displayName="CardHeader";const ll=p.forwardRef(({className:e,...t},n)=>u.jsx("h3",{ref:n,className:oe("text-2xl font-semibold leading-none tracking-tight",e),...t}));ll.displayName="CardTitle";const cl=p.forwardRef(({className:e,...t},n)=>u.jsx("p",{ref:n,className:oe("text-sm text-muted-foreground",e),...t}));cl.displayName="CardDescription";const ul=p.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:oe("p-6 pt-0",e),...t}));ul.displayName="CardContent";const Ep=p.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:oe("flex items-center p-6 pt-0",e),...t}));Ep.displayName="CardFooter";function Ip({interruptPart:e,onApprove:t,onReject:n,disabled:r,isActive:o,payload:s}){const i=e.title??"Approve the result?";let a=null;if(s!=null)if(typeof s=="string")a=u.jsx("p",{className:"text-sm leading-relaxed text-blue-800/90 dark:text-blue-200/90 whitespace-pre-wrap",children:s});else{const c=vr(s);a=u.jsx("pre",{className:"max-h-48 overflow-auto rounded bg-blue-100/60 p-2 text-xs text-blue-900/90 dark:bg-blue-900/40 dark:text-blue-100/80",children:c})}const l=o?"Please approve or reject this action to resume the workflow.":"Waiting for approval from another participant.";return u.jsxs(il,{className:oe("border-blue-200 dark:border-blue-800 bg-blue-50/50 dark:bg-blue-950/10 transition-shadow",o?"shadow-md ring-1 ring-blue-300 dark:ring-blue-500/70":"opacity-80"),children:[u.jsxs(al,{className:"pb-3",children:[u.jsx(ll,{className:"text-blue-900 dark:text-blue-100 text-base",children:i}),u.jsx(cl,{className:"text-blue-700 dark:text-blue-300 text-sm",children:l})]}),a&&u.jsx(ul,{className:"pt-0 pb-3",children:a}),u.jsx(Ep,{className:"pt-0",children:u.jsxs("div",{className:"flex gap-2 ml-auto",children:[u.jsx(Xe,{size:"sm",variant:"outline",onClick:()=>n(e),className:"border-red-300 text-red-700 hover:bg-red-50 dark:border-red-700 dark:text-red-300 dark:hover:bg-red-950/50",disabled:r||!o,children:"Reject"}),u.jsx(Xe,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",disabled:r||!o,children:"Approve"})]})})]})}const $T="prose prose-sm max-w-none break-words dark:prose-invert prose-headings:break-words prose-p:break-words prose-li:break-words prose-td:break-words prose-th:break-words prose-a:break-all prose-code:break-words prose-blockquote:break-words";function dl({data:e}){return Array.isArray(e)?e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?u.jsx("div",{className:$T,children:u.jsx("ul",{className:"list-disc pl-5",children:e.map((n,r)=>u.jsx("li",{children:String(n)},r))})}):u.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:vr(e)}):u.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:vr(e)})}function Np({message:e,isStreaming:t=!1}){const n=e.name??"tool",r=b.useMemo(()=>{const a=e.additionalKwargs??{};return Array.isArray(a.toolProgress)?[...a.toolProgress]:[]},[e]),s=r.some(a=>a.type==="tool.start"||a.type==="tool.call"||a.type==="message.start")?`Running ${n}…`:void 0;return t||r.length>0?u.jsxs("div",{className:"space-y-2",children:[u.jsxs("div",{className:"flex items-center gap-2 text-xs uppercase tracking-wide text-muted-foreground",children:[t&&u.jsx(ue.Loader,{className:"h-3 w-3 animate-spin"}),u.jsx("span",{children:s??`Running ${n}…`})]}),r.length>0&&u.jsx("div",{className:"space-y-2 text-xs text-muted-foreground",children:r.map((a,l)=>{var c;return u.jsxs("div",{className:"rounded border border-current/10 bg-muted/60 p-2 text-[11px] leading-snug",children:[u.jsxs("div",{className:"mb-1 flex items-center justify-between text-[8px] uppercase tracking-wide text-muted-foreground",children:[u.jsx("span",{children:((c=a.type)==null?void 0:c.replace(/\./g," "))??"progress"}),u.jsx("span",{children:a.idx??l+1})]}),a.content&&u.jsx("p",{className:"mt-1 text-[12px] text-foreground/90",children:a.content}),u.jsxs("div",{className:"mt-1 flex flex-wrap gap-2 text-[10px] opacity-70",children:[typeof a.factsFound=="number"&&u.jsxs("span",{children:["Facts found: ",a.factsFound]}),typeof a.isSufficient=="boolean"&&u.jsxs("span",{children:["Research ",a.isSufficient?"sufficient":"needs more data"]})]})]},`tool-progress-${n}-${l}`)})})]}):null}function Ap({className:e}){const[t,n]=b.useState(0);return b.useEffect(()=>{const r=setInterval(()=>n(o=>(o+1)%4),500);return()=>clearInterval(r)},[]),u.jsxs("span",{"aria-live":"polite",className:oe("inline-block text-xs opacity-70 ml-1",e),children:["Is thinking",".".repeat(t)]})}function jp({text:e,expanded:t,onExpandedChange:n,previewLength:r,isCompact:o}){const s=Math.max(e.length-r,0),i=e.substring(0,r);return u.jsxs("div",{className:"flex flex-col gap-1",children:[u.jsx("div",{className:oe("text-sm text-[hsl(var(--chat-bubble-user-text))]",o&&"text-xs"),children:t?u.jsx(qn,{content:e,allowHtml:!1}):u.jsxs("pre",{className:oe("font-sans whitespace-pre-wrap break-words bg-transparent p-0 m-0 text-[hsl(var(--chat-bubble-user-text))]",o&&"text-xs"),children:[i,"..."]})}),u.jsx(Xe,{type:"button",variant:"ghost",size:"sm",className:"h-6 text-xs !text-[hsl(var(--chat-bubble-user-text))]",onClick:()=>n(!t),children:t?u.jsxs(u.Fragment,{children:[u.jsx(ue.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):u.jsxs(u.Fragment,{children:[u.jsx(ue.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",s," chars)"]})})]})}function Pp({message:e,viewMode:t,isStreaming:n=!1}){const o=Oi(e).name||"tool",s=e.artifact??null,i=c=>{if(c==null)return null;const d=typeof c=="string"?Ri(c)??c:c;if(d&&typeof d=="object")return u.jsx(dl,{data:d});const h=typeof d=="string"?d:(()=>{try{return vr(d)}catch{return String(d??"")}})();return u.jsx("pre",{className:"whitespace-pre-wrap break-words font-sans text-sm text-foreground/90",children:h})},a=c=>{if(c==null)return null;const{content:d,isMarkdown:h}=Zv(c);return h?u.jsx(qn,{content:d,className:"text-current"}):i(c)},l=()=>{const c=e.content.find(m=>m.type!=="tool_call");if(!c)return u.jsx("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:u.jsxs("span",{children:["Running ",o,"…"]})});if(c.type==="text"){const f=(c.text??"").trim();if(!f)return null;const v=Qr(f);return a(v)}const d=Zr(c),h=Qr(d);return a(h)};return u.jsxs("div",{className:"space-y-2",children:[s&&u.jsx(kp,{artifact:s,idx:0}),u.jsx(Np,{message:e,isStreaming:n}),t==="expanded"&&u.jsx(u.Fragment,{children:l()})]})}function _p(e){const{allowFileOpen:t,currentThreadId:n}=e,{toast:r}=rl(),[o,s]=b.useState({}),[i,a]=b.useState(null),[l,c]=b.useState(!1),d=b.useCallback(()=>{c(!1),a(null)},[]),h=b.useCallback(f=>{a(f),c(!0)},[]),m=b.useCallback(async(f,v,g)=>{var x,y;if(!t){f.preventDefault();return}if(o[g]){f.preventDefault();return}try{const w=String(v.url??""),S=w.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);if(S){f.preventDefault();const k=S[1],C=v.name||`file_${k}`,T=v.mimeType||"application/octet-stream";h({id:k,name:C,mimeType:T});return}if(w.startsWith("data:")){f.preventDefault(),s(C=>({...C,[g]:!0}));const k=r({title:"Fetching file...",description:"",open:!0});try{const C=await eu(n??void 0);if(!C||!Array.isArray(C))throw new Error("Invalid file list response");const T=C.find(E=>!E||typeof E!="object"||!((E.filename??"")===(v.name??""))?!1:typeof v.size=="number"&&typeof E.size=="number"?E.size===v.size:!0);if(!(T!=null&&T.id))throw new Error(`File "${v.name}" is not yet available on the server`);if(!T.id||!T.filename)throw new Error("Invalid file data received from server");h({id:T.id,name:v.name||T.filename||`file_${T.id}`,mimeType:v.mimeType||T.mime_type||"application/octet-stream"}),(x=k.update)==null||x.call(k,{id:k.id,title:"Success",description:`Opened ${v.name}`,open:!0})}catch(C){console.error("Failed to fetch server file:",C);const T=C instanceof Error?C.message:"Unknown error occurred";(y=k.update)==null||y.call(k,{id:k.id,title:"Failed",description:T}),r({title:"Failed to fetch file",description:T,open:!0})}finally{s(C=>({...C,[g]:!1}))}}}catch(w){console.error("File click error:",w),s(S=>({...S,[g]:!1}))}},[t,o,r,n,h]);return{uploadingFiles:o,handleFileClick:m,fileViewerOpen:l,currentFileInfo:i,closeFileViewer:d}}function Mp(e,t){return b.useMemo(()=>{if(t)return{contentParts:[],textContent:"",toolMeta:{},imageParts:[],fileParts:[],interruptParts:[],toolRaw:"",isToolStreaming:!1};const n=e,r=Array.isArray(n.content)?n.content:[],o=n.additionalKwargs??{};return{contentParts:r,textContent:Qv(r),toolMeta:Oi(n),imageParts:r.filter(s=>s.type==="image_url"),fileParts:r.filter(s=>s.type==="file"),interruptParts:r.filter(s=>s.type==="interrupt"),toolRaw:eb(r),isToolStreaming:!!o.toolStreaming}},[e,t])}const FT={checkpoints:[],checkpointMetaByCheckpointId:new Map,timeline:[],messagePreviews:new Map,getLatest:()=>{},getCheckpoint:()=>{},getMessageAttempts:()=>[]},fl=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,hl=b.memo(function({message:t,index:n,isStreaming:r,streamingAssistantId:o,streamingDebounceMs:s,layoutSize:i,enableMessageEditing:a,editingMessageId:l,onEdit:c,onRegenerate:d,onCancelEdit:h,activeInterrupt:m,disableInterruptActions:f,onInterruptActionStart:v,onInterruptActionEnd:g,showToolMessages:x,checkpointIndex:y,onSelectCheckpoint:w}){const S=fl(t,n),k=t.role==="default_message",T=!!t.__syntheticStreaming,E=y??FT,N=!k&&"checkpointId"in t?t.checkpointId??null:null,{attemptCount:M,attemptIndex:O,attempts:F}=b.useMemo(()=>tc(t.id,N,E),[t.id,N,E]);return u.jsx("div",{className:"relative mb-4 last:mb-0","data-message-id":S,style:{minHeight:"60px",containIntrinsicSize:"auto 120px"},children:u.jsx(Xs,{message:t,messageIndex:n,isStreamingMessage:T||r&&o===t.id&&t.role==="assistant",streamingDebounceMs:s,isEditing:l===t.id,showActions:a,showTimestamp:!1,showAgentName:!0,layoutSize:i,onEdit:c,onRegenerate:()=>d(n),onCancelEdit:h,activeInterrupt:m,disableInterruptActions:f,onInterruptActionStart:v,onInterruptActionEnd:g,showToolMessages:x,attemptCount:M,attemptIndex:O,attemptMetas:F,onSelectCheckpoint:w})})});hl.displayName="MessageRow";function BT(e,t,n){const[r,o]=b.useState(e),s=b.useRef([]);return b.useEffect(()=>{if(!t){o(e),s.current=e.map(a=>a.type==="text"?a.text??"":void 0);return}const i=e.map((a,l)=>{if(a.type!=="text")return s.current[l]=void 0,a;const c=a.text??"",d=s.current[l];return n(c)?(s.current[l]=c,a):{...a,text:d??""}});o(i)},[e,t,n]),r}function zT({message:e,isToolMessage:t,showToolMessages:n,toolViewMode:r,isToolStreaming:o,contentParts:s,textContent:i,imageParts:a,fileParts:l,interruptParts:c,isStreamingMessage:d,enableStreamingMarkdownBuffer:h,renderStreamingMarkdown:m,defaultMessage:f,handleFileClick:v,uploadingFiles:g,handleInterruptApprove:x,handleInterruptReject:y,disableInterruptActions:w,messageRole:S,truncateUserMessages:k,userMessagePreviewLength:C,isUserExpanded:T,setIsUserExpanded:E,isCompactLayout:N,activeInterruptId:M,activeInterruptValue:O,iconForeground:F}){const G=b.useCallback(()=>u.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/30 rounded",children:[u.jsx(ue.Loader,{className:"h-4 w-4 text-muted-foreground"}),u.jsx("span",{className:"text-sm text-muted-foreground",children:"File upload"})]}),[]),j=BT(s,(h??!0)&&d,Rp),Y=b.useMemo(()=>j.filter(P=>P.type==="text"),[j]),q=b.useMemo(()=>Y.map(P=>P.text??"").join(""),[Y]),z=b.useMemo(()=>{if(!m)return null;const P=HT(q);return{stablePart:q.slice(0,P),tailPart:q.slice(P)}},[q,m]),R=b.useMemo(()=>{if(!z)return null;const{stablePart:P,tailPart:D}=z;return!P&&!D?null:u.jsxs("div",{className:"space-y-2",children:[P?u.jsx(qn,{content:P,allowHtml:!1}):null,D?u.jsx(qn,{content:D,allowHtml:!1}):null]})},[z]),I=b.useMemo(()=>{if(!m)return j;const P=[];let D=!1;for(const $ of j){if($.type==="text"){D||(P.push({type:"text",text:"",__streamingMarkdownAggregate:!0}),D=!0);continue}P.push($)}return P},[j,m]),U=m?I:j,J=b.useCallback(({part:P,i:D})=>{if(P.type==="text"){if(m)return null;const $=P.text??"",ee=$.trim(),H=Ri(ee);return H&&S!=="tool"?u.jsx(dl,{data:H},D):S==="user"&&k&&ee.length>C?u.jsx(jp,{text:ee,expanded:T,onExpandedChange:E,previewLength:C,isCompact:N},D):u.jsx(qn,{content:$,allowHtml:!1},D)}if(P.type==="image_url"){const $=P;return u.jsx("div",{className:"my-2",children:u.jsx("img",{src:$.url,alt:$.alt??"",loading:"lazy",className:"border rounded max-h-[420px] w-auto object-contain"})},D)}if(P.type==="file"){const $=P,ee=$.name||"file";return u.jsxs("a",{href:$.url,onClick:H=>v(H,$,D),className:`inline-flex items-center gap-2 rounded px-2 py-1 text-xs bg-gray-100 border hover:bg-gray-200
|
|
129
|
-
dark:bg-background/10 dark:border-border/30 dark:hover:bg-background/20`,children:[g[D]?u.jsx(ue.Loader,{className:"h-4 w-4 animate-spin"}):null,u.jsxs("span",{className:"truncate max-w-[180px]",children:[ee,g[D]?" (processing)":""]})]},D)}if(P.type==="interrupt"){const $=P,ee=Yo(($==null?void 0:$.id)??($==null?void 0:$.interrupt_id)),H=!!(M&&ee&&ee===M),L=H?O??($==null?void 0:$.value):$==null?void 0:$.value,Z=ee?{...$,id:ee,interrupt_id:ee}:$;return u.jsx(Ip,{interruptPart:Z,onApprove:x,onReject:y,disabled:w,isActive:H,payload:L},D)}return null},[M,O,w,v,x,y,N,T,S,k,g,C,m,E]),_=i.trim().length>0||a.length>0||l.length>0||c.length>0;if(!t&&l.length>0&&!d)return G();if(!t&&!_&&!d)return null;if(t)return n?u.jsx(Pp,{message:e,viewMode:r,isStreaming:o},e.id):null;if(!f){const P=u.jsx("div",{className:"space-y-2",children:U.map((D,$)=>m&&UT(D)?R?u.jsx("div",{className:"space-y-2",children:R},`streaming-md-${$}`):null:u.jsx(J,{part:D,i:$},$))});return d?u.jsxs("div",{"aria-busy":"true",role:"status",children:[P,u.jsx(Ap,{className:F})]}):P}return null}function Rp(e){return e?!(Io(e,/```/g)||Io(e,/`/g)||Io(e,/\*\*/g)||Io(e,/__/g)||Io(e,/~~/g)||/[^\\]\[[^\]]*$/.test(e)||/\[[^\]]*\]\([^)]*$/.test(e)):!0}function Io(e,t){const n=e.match(t);return((n==null?void 0:n.length)??0)%2!==0}function HT(e){if(!e)return 0;for(let t=e.length;t>=0;t-=1)if(Rp(e.slice(0,t)))return t;return 0}function UT(e){return e.type==="text"&&!!e.__streamingMarkdownAggregate}const WT=zr.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 Op({className:e,variant:t,...n}){return u.jsx("div",{className:oe(WT({variant:t}),e),...n})}function VT({showTimestamp:e,showAgentName:t,isToolMessage:n,iconForeground:r,agentName:o,messageIcon:s,customHeaderClass:i,customActionsClass:a,isCompactLayout:l,showActions:c,isEditing:d,messageRole:h,toolViewMode:m,toolMeta:f,onToggleToolView:v,onCopy:g,onEdit:x,onRegenerate:y,showCheckpointControls:w,attemptCount:S,attemptIndex:k,handleOlderAttemptSelect:C,handleNewerAttemptSelect:T,messageCreatedAt:E,copied:N}){return!e&&!t&&!n?null:u.jsxs("div",{className:oe("flex items-center justify-between mb-2 pb-2 border-b border-current/10",l&&"mb-1 pb-1",r,i),children:[u.jsxs("div",{className:"flex items-center gap-2",children:[s,t&&o&&u.jsx("span",{className:oe("font-medium",l?"text-xs":"text-sm"),children:o}),n&&u.jsxs(Op,{variant:"outline",className:oe("text-xs flex items-center gap-1 cursor-pointer select-none",r,"border border-current/40",l&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":m==="expanded",onClick:v,onKeyDown:M=>{(M.key==="Enter"||M.key===" ")&&(M.preventDefault(),v())},children:[u.jsx("span",{children:f.name??"Tool Output"}),f.toolCallId&&u.jsx("span",{className:"opacity-70",children:f.toolCallId.slice(0,8)}),m==="expanded"?u.jsx(ue.ChevronUp,{className:"h-3 w-3"}):u.jsx(ue.ChevronDown,{className:"h-3 w-3"})]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[w&&S>1&&u.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[u.jsx("button",{type:"button",className:oe("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",k<S-1?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{k>=S-1||C()},"aria-label":"Older attempt (back in time)",disabled:k>=S-1,children:u.jsx(ue.ChevronLeft,{className:"h-3 w-3"})}),u.jsx("div",{className:"flex items-center gap-2",children:u.jsxs("span",{className:"whitespace-nowrap",children:[S-k," / ",S]})}),u.jsx("button",{type:"button",className:oe("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",k>0?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{k<=0||T()},"aria-label":"Newer attempt (forward in time)",disabled:k<=0,children:u.jsx(ue.ChevronRight,{className:"h-3 w-3"})})]}),e&&E&&u.jsx("time",{className:oe("text-xs opacity-60",r,l&&"text-xs"),dateTime:new Date(E).toISOString(),title:new Date(E).toLocaleString(),children:new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(new Date(E))}),c&&!d&&u.jsxs("div",{className:oe("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",a),children:[u.jsx("div",{className:"relative",children:u.jsx(Xe,{variant:"ghost",size:"sm",onClick:g,className:oe("h-6 w-6 p-0 hover:bg-foreground/10",r,l&&"h-5 w-5"),"aria-label":"Copy message",title:"Copy message",children:u.jsx(ue.Copy,{className:oe(N?"text-success":r,l?"h-3 w-3":"h-4 w-4")})})}),h==="user"&&x&&u.jsx(Xe,{variant:"ghost",size:"sm",onClick:x,className:oe("h-6 w-6 p-0 hover:bg-foreground/10",r,l&&"h-5 w-5"),"aria-label":"Edit message",children:u.jsx(ue.Edit,{className:oe(r,l?"h-3 w-3":"h-4 w-4")})}),h==="assistant"&&y&&u.jsx(Xe,{variant:"ghost",size:"sm",onClick:y,className:oe("h-6 w-6 p-0 hover:bg-foreground/10",r,l&&"h-5 w-5"),"aria-label":"Regenerate response",children:u.jsx(ue.RotateCcw,{className:oe(r,l?"h-3 w-3":"h-4 w-4")})})]})]})]})}const Xs=b.memo(function({message:t,messageIndex:n,isStreamingMessage:r=!1,isEditing:o=!1,showActions:s=!0,showTimestamp:i=!0,showAgentName:a=!0,layoutSize:l="desktop",truncateUserMessages:c=!0,userMessagePreviewLength:d=500,showToolMessages:h=!0,customStyles:m={},streamingDebounceMs:f=300,renderStreamingMarkdown:v=!1,enableStreamingMarkdownBuffer:g,onEdit:x,onRegenerate:y,onCopy:w,activeInterrupt:S,disableInterruptActions:k=!1,onInterruptActionStart:C,onInterruptActionEnd:T,attemptCount:E=1,attemptIndex:N=0,onSelectCheckpoint:M,attemptMetas:O=[]}){const[F,G]=b.useState(!1),[K,j]=b.useState("preview"),[Y,q]=b.useState(!1),{currentThreadId:z}=xr(),{respondToInterrupt:R}=eo(),I=l==="phone"||l==="half-screen",U=t.role,J=U==="tool",_=b.useMemo(()=>t.role==="default_message"?t:null,[t]),P=!!_,D=!(r&&U!=="user"),{uploadingFiles:$,handleFileClick:ee,fileViewerOpen:H,currentFileInfo:L,closeFileViewer:Z}=_p({allowFileOpen:D,currentThreadId:z}),te=b.useMemo(()=>{switch(U){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))]"}},[U]),Q=Mp(t,_),{contentParts:W,imageParts:le,fileParts:ie,interruptParts:ge,textContent:we,toolMeta:Ce,toolRaw:Ae,isToolStreaming:Ee}=Q,st=g??f!==0,lt=(S==null?void 0:S.id)??(S==null?void 0:S.interrupt_id),St=Yo(lt),Oe=S==null?void 0:S.value,qe=b.useCallback(async()=>{const X=J?Ae:we;async function fe(He){if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function"){await navigator.clipboard.writeText(He);return}if(navigator.clipboard&&typeof navigator.clipboard.write=="function"&&typeof ClipboardItem<"u"){const ae=new Blob([He],{type:"text/plain"});await navigator.clipboard.write([new ClipboardItem({"text/plain":ae})]);return}throw new Error("Clipboard API not supported in this context.")}try{await fe(X),G(!0),setTimeout(()=>G(!1),2e3),w==null||w(X)}catch(He){console.error("Failed to copy:",He)}},[J,Ae,we,w]),We=b.useCallback(()=>{if(!x||!t.id)return;const X=(J?Ae:we)??"",fe="type"in t&&t.type==="default_message"?void 0:{checkpointId:t.checkpointId??null,checkpointNs:t.checkpointNs??null};x(t.id,X,fe)},[x,t.id,J,Ae,we,t]),je=b.useCallback(()=>{y==null||y(n)},[y,n]),_e=b.useCallback(()=>{j(X=>X==="expanded"?"preview":"expanded")},[]),ct=b.useCallback(()=>{const fe=oe(I?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",te);switch(U){case"user":return u.jsx(ue.User,{className:fe});case"assistant":return u.jsx(ue.Bot,{className:fe});case"tool":return u.jsx(ue.Wrench,{className:fe});default:return u.jsx(ue.Bot,{className:fe})}},[I,te,U]),kt=b.useCallback(()=>{const X="group relative mb-4 flex w-full";switch(U){case"user":return oe(X,"justify-end");case"assistant":case"tool":case"system":return oe(X,"justify-start");default:return X}},[U]),nt=b.useCallback(()=>{const X=oe("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",I&&"px-3 py-2 text-sm");if(P)return oe(X,"w-full","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40 shadow-sm");switch(U){case"user":return oe(X,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-user))] text-[hsl(var(--chat-bubble-user-text))]","border border-transparent");case"assistant":return oe(X,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40");case"tool":return oe(X,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return oe(X,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return oe(X,"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")}},[I,P,U]),Et=b.useCallback(async X=>{if(k)return;const fe=Yo((X==null?void 0:X.id)??(X==null?void 0:X.interrupt_id));if(!fe){console.warn("Interrupt part missing id",X);return}try{C==null||C(),await R(fe,!0)}catch(He){console.error("Failed to approve interrupt:",He)}finally{T==null||T()}},[k,T,C,R]),bt=b.useCallback(async X=>{if(k)return;const fe=Yo((X==null?void 0:X.id)??(X==null?void 0:X.interrupt_id));if(!fe){console.warn("Interrupt part missing id",X);return}try{C==null||C(),await R(fe,!1)}catch(He){console.error("Failed to reject interrupt:",He)}finally{T==null||T()}},[k,T,C,R]),wt=u.jsx(zT,{message:t,isToolMessage:J,showToolMessages:h,toolViewMode:K,isToolStreaming:Ee,contentParts:W,textContent:we,imageParts:le,fileParts:ie,interruptParts:ge,isStreamingMessage:r,defaultMessage:_,enableStreamingMarkdownBuffer:st,renderStreamingMarkdown:v,handleFileClick:ee,uploadingFiles:$,handleInterruptApprove:Et,handleInterruptReject:bt,disableInterruptActions:k,messageRole:U,truncateUserMessages:c,userMessagePreviewLength:d,isUserExpanded:Y,setIsUserExpanded:q,isCompactLayout:I,activeInterruptId:St,activeInterruptValue:Oe,iconForeground:te}),Ct=b.useMemo(()=>_?"Assistant":tb(t),[_,t]),on=ct(),Tt=U==="user"&&(E??1)>1&&typeof M=="function",Lt=(O==null?void 0:O.length)??0,_t=Lt>0&&N<Lt-1?O[N+1]:void 0,$e=Lt>0&&N>0?O[N-1]:void 0,ze=b.useCallback(()=>{!_t||!M||M(_t.id,void 0,!!_t.isLatestAttempt)},[_t,M]),Mt=b.useCallback(()=>{!$e||!M||M($e.id,void 0,!!$e.isLatestAttempt)},[$e,M]);return J&&!h?null:P&&_?u.jsx("div",{className:oe(kt(),m.container),children:u.jsxs("div",{className:oe(nt(),m.content),children:[u.jsxs("div",{className:"flex items-center gap-2 mb-2 pb-2 border-b border-current/10",children:[u.jsx(ue.Bot,{className:oe("h-4 w-4",te)}),a&&u.jsx("span",{className:"font-medium text-sm",children:"Assistant"})]}),u.jsx(qn,{content:_.content,className:"text-current"})]})}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:oe(kt(),m.container),children:u.jsxs("div",{className:oe(nt(),m.content),children:[u.jsx(VT,{showTimestamp:i,showAgentName:a,isToolMessage:J,iconForeground:te,agentName:Ct,messageIcon:on,customHeaderClass:m.header,customActionsClass:m.actions,isCompactLayout:I,showActions:s,isEditing:o,messageRole:U,toolViewMode:K,toolMeta:Ce,onToggleToolView:_e,onCopy:qe,onEdit:We,onRegenerate:je,showCheckpointControls:Tt,attemptCount:E,attemptIndex:N,handleOlderAttemptSelect:ze,handleNewerAttemptSelect:Mt,messageCreatedAt:t.createdAt,copied:F}),u.jsx("div",{className:"relative",children:wt}),J&&K==="expanded"&&(Ce.toolCallId||Ce.name)&&u.jsxs("div",{className:oe("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",I&&"text-xs"),children:[Ce.name&&u.jsxs("div",{children:["Function: ",Ce.name]}),Ce.toolCallId&&u.jsxs("div",{children:["Call ID: ",Ce.toolCallId]})]}),!(i||a||J)&&s&&!o&&u.jsxs("div",{className:oe("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",m.actions),children:[u.jsx(Xe,{variant:"ghost",size:"sm",onClick:()=>qe(),className:oe("h-6 w-6 p-0 hover:bg-background/50 text-current",I&&"h-5 w-5"),children:u.jsx(ue.Copy,{className:oe(F?"text-success":"text-current",I?"h-3 w-3":"h-4 w-4")})}),U==="user"&&x&&u.jsx(Xe,{variant:"ghost",size:"sm",onClick:We,className:oe("h-6 w-6 p-0 hover:bg-background/50 text-current",I&&"h-5 w-5"),children:u.jsx(ue.Edit,{className:oe("text-current",I?"h-3 w-3":"h-4 w-4")})}),U==="assistant"&&y&&u.jsx(Xe,{variant:"ghost",size:"sm",onClick:je,className:oe("h-6 w-6 p-0 hover:bg-background/50 text-current",I&&"h-5 w-5"),children:u.jsx(ue.RotateCcw,{className:oe("text-current",I?"h-3 w-3":"h-4 w-4")})})]})]})}),L&&u.jsx(lp,{isOpen:H,onClose:Z,fileId:L.id,fileName:L.name,mimeType:L.mimeType})]})},(e,t)=>{var l,c,d,h,m,f,v,g;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&mu(e.message)===mu(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateUserMessages","userMessagePreviewLength","showToolMessages"].every(x=>e[x]===t[x]),s=((l=e.customStyles)==null?void 0:l.container)===((c=t.customStyles)==null?void 0:c.container)&&((d=e.customStyles)==null?void 0:d.content)===((h=t.customStyles)==null?void 0:h.content)&&((m=e.customStyles)==null?void 0:m.actions)===((f=t.customStyles)==null?void 0:f.actions)&&((v=e.customStyles)==null?void 0:v.header)===((g=t.customStyles)==null?void 0:g.header);if(!o||!s)return!1;const i=gu(e.message),a=gu(t.message);return i.length===a.length});Xs.displayName="MessageComponent";const pl=b.forwardRef(({messages:e,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onStartReached:a,onEdit:l,onRegenerate:c,onCancelEdit:d,className:h,style:m,emptyMessage:f,followNewMessages:v=!0,isNavigatingCheckpoint:g=!1,onScrollAway:x,onAtBottom:y,activeInterrupt:w,disableInterruptActions:S=!1,onInterruptActionStart:k,onInterruptActionEnd:C,showToolMessages:T=!0,checkpointIndex:E,activeCheckpointId:N,onSelectCheckpoint:M,createSyntheticThinkingMessage:O=!0,forceSyntheticThinking:F=!1},G)=>{const K=b.useRef(null),j=b.useRef(null),Y=b.useRef(!1),q=b.useRef(!1),[z,R]=b.useState(!0),I=b.useMemo(()=>w?e.some(W=>W.role==="default_message"?!1:Array.isArray(W==null?void 0:W.content)&&W.content.some(le=>le&&le.type==="interrupt"&&(le.id??le.interrupt_id)===w.id)):!1,[w,e]),U=b.useMemo(()=>{if(!w||I)return null;const W=w.id&&String(w.id).trim()?String(w.id).trim():"pending-interrupt";let le;const ie=w.value;if(ie&&typeof ie=="object"&&!Array.isArray(ie)){const ge=ie.title;typeof ge=="string"&&ge.trim()&&(le=ge.trim())}return{id:`interrupt-${W}`,role:"system",createdAt:new Date().toISOString(),content:[{type:"interrupt",id:W,value:ie,title:le}]}},[w,I]),J=b.useMemo(()=>U?[...e,U]:e,[e,U]),_=b.useMemo(()=>{const W=n&&J.some(ie=>ie.id===n);return O&&(t||F)&&!W&&J.length>0?[...J,{id:"thinking-assistant",role:"assistant",content:[{type:"text",text:""}],createdAt:new Date().toISOString(),__syntheticStreaming:!0}]:J},[J,t,n,O,F]),P=b.useMemo(()=>T?_:_.filter(W=>(W==null?void 0:W.role)!=="tool"),[_,T]),D=b.useCallback(W=>{R(W),x&&x(!W),y&&y(W)},[x,y]),$=b.useMemo(()=>{if(a)return async()=>{if(!Y.current){Y.current=!0;try{await a()}finally{Y.current=!1}}}},[a]),ee=b.useMemo(()=>!v||g?!1:z?"auto":!1,[z,v,g]),H=b.useMemo(()=>{if(typeof f!="string")return null;const W=f.trim();return!W||P&&P.length>0?null:{id:"default-message",role:"default_message",content:W,createdAt:new Date().toISOString()}},[f,P]),L=["flex h-full flex-col md:flex-row",h].filter(Boolean).join(" "),Z=()=>H?u.jsx("div",{className:"p-6 h-full overflow-y-auto",children:u.jsx("div",{className:"w-full max-w-full",children:u.jsx(Xs,{message:H,messageIndex:0,isStreamingMessage:!1,showActions:!1,showTimestamp:!1,showAgentName:!0,layoutSize:o,onEdit:()=>{},onRegenerate:()=>{},onCancelEdit:()=>{}})})}):u.jsx("div",{className:"flex h-full items-center justify-center py-8 text-center text-muted-foreground",children:f??"No messages yet. Start a conversation!"}),te=P.length,Q=te>0;return b.useEffect(()=>{var W,le;if(te===0){q.current=!1;return}if(!q.current)if(q.current=!0,K.current&&P.length>0){const ie=P.length-1;(le=(W=K.current).scrollToIndex)==null||le.call(W,{index:ie,align:"end",behavior:"auto"})}else j.current&&(j.current.scrollTop=j.current.scrollHeight)},[te,P.length]),b.useImperativeHandle(G,()=>({scrollToLatest:()=>{var W,le;if(K.current&&P.length>0){const ie=P.length-1;(le=(W=K.current).scrollToIndex)==null||le.call(W,{index:ie,align:"end",behavior:"auto"})}else j.current&&(j.current.scrollTop=j.current.scrollHeight)},scrollToTop:()=>{var W,le;K.current&&P.length>0?(le=(W=K.current).scrollToIndex)==null||le.call(W,{index:0,align:"start",behavior:"auto"}):j.current&&(j.current.scrollTop=0)}}),[P]),u.jsx("div",{className:L,style:m,children:u.jsx("div",{className:"relative flex-1 min-h-0",children:Q?u.jsx(zC,{ref:W=>{K.current=W},scrollerRef:W=>{j.current=W instanceof HTMLDivElement?W:null},data:P,followOutput:ee,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,startReached:()=>{$&&$()},atBottomStateChange:D,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(W,le)=>fl(le,W),itemContent:(W,le)=>u.jsx(hl,{message:le,index:W,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onEdit:l,onRegenerate:c,onCancelEdit:d,activeInterrupt:w,disableInterruptActions:S,onInterruptActionStart:k,onInterruptActionEnd:C,showToolMessages:T,checkpointIndex:E,activeCheckpointId:N,onSelectCheckpoint:M})}):Z()})})});pl.displayName="MessageList";const Dp={value:""};function Rr({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:c=!0,showToolMessages:d=!0,payloadExtras:h={},customStyles:m={},onMessageSent:f,onExcelUploadSuccess:v,onError:g}){const{api:x}=Xr(),{currentThreadId:y}=xr(),{threadId:w,messages:S,isHistoryLoading:k,isLoading:C,navigateToCheckpoint:T,returnToLatest:E,checkpoint:N,checkpoints:M,interrupt:O,metadata:F,checkpointIndex:G}=eo(),{isStreaming:K,error:j,connectionState:Y,submit:q,stop:z}=$i(),R=w??y??null,I=(N==null?void 0:N.id)??null,U=(N==null?void 0:N.namespace)??null,J=(F==null?void 0:F.assemblingMessageId)??null,_=O,[P,D]=b.useState(!1),[$,ee]=b.useState(!1);b.useEffect(()=>{_||D(!1)},[_]);const H=b.useCallback(()=>{D(!0)},[]),L=b.useCallback(()=>{D(!1)},[]),Z=!!_||P,[te,Q]=b.useState(null),[W,le]=b.useState(""),[ie,ge]=b.useState(null),[we,Ce]=b.useState(null),[Ae,Ee]=b.useState(!1),[st,lt]=b.useState(null),St=b.useRef(!1),[Oe,qe]=b.useState(()=>Dp.value),We=b.useRef(Oe),je=b.useRef(null),_e=b.useCallback(ae=>{Dp.value=ae,qe(ae)},[]),[ct,kt]=b.useState(!1),nt=b.useRef(null),Et=b.useCallback(ae=>{_e(ae)},[_e]);b.useEffect(()=>{K||ee(!1)},[K]),b.useEffect(()=>{F!=null&&F.assemblingMessageId&&ee(!1)},[F==null?void 0:F.assemblingMessageId]);const[bt,wt]=b.useState("desktop");b.useEffect(()=>{const ae=()=>{const me=window.innerWidth;wt(me<640?"phone":me<1024?"tablet":"desktop")};return ae(),window.addEventListener("resize",ae),()=>window.removeEventListener("resize",ae)},[]),b.useEffect(()=>{St.current=!1},[R]),b.useEffect(()=>{We.current=Oe},[Oe]),b.useEffect(()=>{if(!te){je.current=null;return}je.current===null&&(je.current=We.current),_e(W??"")},[W,te,_e]),b.useEffect(()=>{(async()=>{if(!x.baseUrl){lt(null);return}try{const Se=(await x.getAgent("default")).uiDefaultMessage||"";lt(Se||null)}catch(me){console.warn("Failed to fetch default message:",me),lt(null)}})()},[x.baseUrl]),b.useEffect(()=>{j&&!Ae&&(g==null||g(j))},[j,Ae,g]);const Ct=async(ae,me)=>{const Se=ae.trim();if(!(!Se&&me.length===0))try{const Ve=te?(ie==null?void 0:ie.checkpointId)??I??void 0:I??void 0,it=te?(ie==null?void 0:ie.checkpointNs)??U??void 0:U??void 0;await q({text:Se||"",attachments:me,payload:h},{checkpointId:Ve,checkpointNs:it,edit:!!te,originalMessageId:te??void 0}),f==null||f(Se),ee(!0),_e(""),Ce(null),Q(null),le(""),ge(null)}catch(Ve){const it=(Ve==null?void 0:Ve.message)||"Failed to send message";Ce(it),g==null||g(it),ee(!1)}},on=b.useCallback(async ae=>{await q({attachments:[ae],payload:h},{checkpointId:I??void 0,checkpointNs:U??void 0}),v==null||v({file:ae})},[I,U,h,v,q]),Tt=b.useCallback((ae,me,Se)=>{c&&(je.current=Oe,Q(ae),le(me),_e(me),Ce(null),ge({checkpointId:(Se==null?void 0:Se.checkpointId)??null,checkpointNs:(Se==null?void 0:Se.checkpointNs)??null}))},[Oe,c,_e]),Lt=b.useCallback(()=>{Q(null),le(""),ge(null),Ce(null),_e(je.current??Oe),je.current=null},[Oe,_e]),_t=b.useCallback((ae,me,Se)=>{Tt(ae,me,Se)},[Tt]),$e=b.useCallback(ae=>{let me=null;for(let et=ae-1;et>=0;et--)if(S[et].role==="user"){me=S[et];break}if(!me)return;const Se=Array.isArray(me.content)?me.content:[],it=Se.filter(et=>(et==null?void 0:et.type)==="text").map(et=>et.text).join("")||(()=>{try{return JSON.stringify(Se,null,2)}catch{return String(Se)}})();it&&q({text:it,payload:h},{checkpointId:I??void 0,checkpointNs:U??void 0,edit:!0,originalMessageId:me.id})},[S,q,I,U,h]),ze=async ae=>{if(y){kt(!0);try{if(!ae){await E(),requestAnimationFrame(()=>{var Ve;(Ve=nt.current)==null||Ve.scrollToLatest()});return}const me=M.find(Ve=>Ve.checkpointId===ae),Se=(me==null?void 0:me.checkpointNs)??null;await T(ae,Se),requestAnimationFrame(()=>{var Ve;(Ve=nt.current)==null||Ve.scrollToTop()})}finally{kt(!1)}}},Mt=b.useCallback(async(ae,me,Se)=>{await ze(Se?null:ae)},[ze]),X=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${m.container||""}`,fe=`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 ${m.messagesArea||""}`,He=`relative flex-shrink-0 w-full border-t p-4 bg-transparent ${m.inputArea||""}`;return u.jsxs("div",{className:X,children:[!!j&&!Ae&&u.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:[u.jsx("span",{children:j}),u.jsx(Xe,{variant:"ghost",size:"sm",onClick:()=>Ee(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:u.jsx(ue.X,{size:16})})]}),u.jsxs("div",{className:`relative ${fe}`,style:r?{maxHeight:r}:void 0,children:[u.jsx(pl,{ref:nt,className:"h-full",style:{height:"100%"},messages:S,isStreaming:K,streamingAssistantId:J,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:bt,enableMessageEditing:c,editingMessageId:te,onEdit:_t,onRegenerate:$e,onCancelEdit:Lt,emptyMessage:st??void 0,isNavigatingCheckpoint:ct,activeInterrupt:_,disableInterruptActions:P,onInterruptActionStart:H,onInterruptActionEnd:L,showToolMessages:d,checkpointIndex:G,activeCheckpointId:I,onSelectCheckpoint:Mt,createSyntheticThinkingMessage:!0,forceSyntheticThinking:$}),(Y==="reconnecting"||Y==="connecting")&&u.jsx("div",{className:"pointer-events-none absolute top-3 right-3 z-20 rounded-full bg-muted/80 px-3 py-1 text-xs font-medium text-foreground shadow-sm backdrop-blur-sm dark:bg-muted/60",children:u.jsxs("span",{className:"flex items-center gap-2",children:[u.jsx(ue.Loader2,{className:"h-3 w-3 animate-spin"}),Y==="reconnecting"?"Reconnecting…":"Connecting…"]})}),Y==="error"&&u.jsx("div",{className:"pointer-events-none absolute top-3 right-3 z-20 rounded-full bg-destructive/10 px-3 py-1 text-xs font-semibold text-destructive shadow-sm",children:"Connection lost"}),C&&u.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:[u.jsx(ue.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading messages…"})]}),(k||ct)&&u.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:[u.jsx(ue.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading checkpoint…"})]})]}),u.jsxs("div",{className:He,children:[te&&u.jsx("div",{className:"mb-3 p-3 bg-blue-50 border border-blue-200 rounded-lg",children:u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(ue.Edit3,{size:16,className:"text-blue-600"}),u.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),u.jsx(Xe,{variant:"ghost",size:"sm",onClick:Lt,className:"text-blue-600 hover:bg-blue-100",children:u.jsx(ue.X,{size:16})})]})}),we&&u.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:we}),u.jsx(PS,{composerValue:Oe,onComposerChange:Et,onSend:Ct,onCancelEdit:Lt,onStop:z,editingMessageId:te,editingInitialValue:W,placeholder:te?"Edit your message...":t,isStreaming:K,disabled:Z,enableFileUpload:a,enableExcelUpload:l,onExcelUpload:on,onError:g,customStyles:m,textareaClassName:m.textarea||"",allowEmptySend:!1,inputError:we})]})]})}var Lp=1,KT=.9,qT=.8,GT=.17,ml=.1,gl=.999,YT=.9999,XT=.99,JT=/[\\\/_+.#"@\[\(\{&]/,ZT=/[\\\/_+.#"@\[\(\{&]/g,QT=/[\s-]/,$p=/[\s-]/g;function xl(e,t,n,r,o,s,i){if(s===t.length)return o===e.length?Lp:XT;var a=`${o},${s}`;if(i[a]!==void 0)return i[a];for(var l=r.charAt(s),c=n.indexOf(l,o),d=0,h,m,f,v;c>=0;)h=xl(e,t,n,r,c+1,s+1,i),h>d&&(c===o?h*=Lp:JT.test(e.charAt(c-1))?(h*=qT,f=e.slice(o,c-1).match(ZT),f&&o>0&&(h*=Math.pow(gl,f.length))):QT.test(e.charAt(c-1))?(h*=KT,v=e.slice(o,c-1).match($p),v&&o>0&&(h*=Math.pow(gl,v.length))):(h*=GT,o>0&&(h*=Math.pow(gl,c-o))),e.charAt(c)!==t.charAt(s)&&(h*=YT)),(h<ml&&n.charAt(c-1)===r.charAt(s+1)||r.charAt(s+1)===r.charAt(s)&&n.charAt(c-1)!==r.charAt(s))&&(m=xl(e,t,n,r,c+1,s+2,i),m*ml>h&&(h=m*ml)),h>d&&(d=h),c=n.indexOf(l,c+1);return i[a]=d,d}function Fp(e){return e.toLowerCase().replace($p," ")}function ek(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,xl(e,t,Fp(e),Fp(t),0,0,{})}var No='[cmdk-group=""]',vl='[cmdk-group-items=""]',tk='[cmdk-group-heading=""]',Bp='[cmdk-item=""]',zp=`${Bp}:not([aria-disabled="true"])`,bl="cmdk-item-select",Or="data-value",nk=(e,t,n)=>ek(e,t,n),Hp=p.createContext(void 0),Ao=()=>p.useContext(Hp),Up=p.createContext(void 0),wl=()=>p.useContext(Up),Wp=p.createContext(void 0),Vp=p.forwardRef((e,t)=>{let n=Dr(()=>{var _,P;return{search:"",value:(P=(_=e.value)!=null?_:e.defaultValue)!=null?P:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=Dr(()=>new Set),o=Dr(()=>new Map),s=Dr(()=>new Map),i=Dr(()=>new Set),a=Kp(e),{label:l,children:c,value:d,onValueChange:h,filter:m,shouldFilter:f,loop:v,disablePointerSelection:g=!1,vimBindings:x=!0,...y}=e,w=Nt(),S=Nt(),k=Nt(),C=p.useRef(null),T=hk();ur(()=>{if(d!==void 0){let _=d.trim();n.current.value=_,E.emit()}},[d]),ur(()=>{T(6,K)},[]);let E=p.useMemo(()=>({subscribe:_=>(i.current.add(_),()=>i.current.delete(_)),snapshot:()=>n.current,setState:(_,P,D)=>{var $,ee,H,L;if(!Object.is(n.current[_],P)){if(n.current[_]=P,_==="search")G(),O(),T(1,F);else if(_==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let Z=document.getElementById(k);Z?Z.focus():($=document.getElementById(w))==null||$.focus()}if(T(7,()=>{var Z;n.current.selectedItemId=(Z=j())==null?void 0:Z.id,E.emit()}),D||T(5,K),((ee=a.current)==null?void 0:ee.value)!==void 0){let Z=P??"";(L=(H=a.current).onValueChange)==null||L.call(H,Z);return}}E.emit()}},emit:()=>{i.current.forEach(_=>_())}}),[]),N=p.useMemo(()=>({value:(_,P,D)=>{var $;P!==(($=s.current.get(_))==null?void 0:$.value)&&(s.current.set(_,{value:P,keywords:D}),n.current.filtered.items.set(_,M(P,D)),T(2,()=>{O(),E.emit()}))},item:(_,P)=>(r.current.add(_),P&&(o.current.has(P)?o.current.get(P).add(_):o.current.set(P,new Set([_]))),T(3,()=>{G(),O(),n.current.value||F(),E.emit()}),()=>{s.current.delete(_),r.current.delete(_),n.current.filtered.items.delete(_);let D=j();T(4,()=>{G(),(D==null?void 0:D.getAttribute("id"))===_&&F(),E.emit()})}),group:_=>(o.current.has(_)||o.current.set(_,new Set),()=>{s.current.delete(_),o.current.delete(_)}),filter:()=>a.current.shouldFilter,label:l||e["aria-label"],getDisablePointerSelection:()=>a.current.disablePointerSelection,listId:w,inputId:k,labelId:S,listInnerRef:C}),[]);function M(_,P){var D,$;let ee=($=(D=a.current)==null?void 0:D.filter)!=null?$:nk;return _?ee(_,n.current.search,P):0}function O(){if(!n.current.search||a.current.shouldFilter===!1)return;let _=n.current.filtered.items,P=[];n.current.filtered.groups.forEach($=>{let ee=o.current.get($),H=0;ee.forEach(L=>{let Z=_.get(L);H=Math.max(Z,H)}),P.push([$,H])});let D=C.current;Y().sort(($,ee)=>{var H,L;let Z=$.getAttribute("id"),te=ee.getAttribute("id");return((H=_.get(te))!=null?H:0)-((L=_.get(Z))!=null?L:0)}).forEach($=>{let ee=$.closest(vl);ee?ee.appendChild($.parentElement===ee?$:$.closest(`${vl} > *`)):D.appendChild($.parentElement===D?$:$.closest(`${vl} > *`))}),P.sort(($,ee)=>ee[1]-$[1]).forEach($=>{var ee;let H=(ee=C.current)==null?void 0:ee.querySelector(`${No}[${Or}="${encodeURIComponent($[0])}"]`);H==null||H.parentElement.appendChild(H)})}function F(){let _=Y().find(D=>D.getAttribute("aria-disabled")!=="true"),P=_==null?void 0:_.getAttribute(Or);E.setState("value",P||void 0)}function G(){var _,P,D,$;if(!n.current.search||a.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let ee=0;for(let H of r.current){let L=(P=(_=s.current.get(H))==null?void 0:_.value)!=null?P:"",Z=($=(D=s.current.get(H))==null?void 0:D.keywords)!=null?$:[],te=M(L,Z);n.current.filtered.items.set(H,te),te>0&&ee++}for(let[H,L]of o.current)for(let Z of L)if(n.current.filtered.items.get(Z)>0){n.current.filtered.groups.add(H);break}n.current.filtered.count=ee}function K(){var _,P,D;let $=j();$&&(((_=$.parentElement)==null?void 0:_.firstChild)===$&&((D=(P=$.closest(No))==null?void 0:P.querySelector(tk))==null||D.scrollIntoView({block:"nearest"})),$.scrollIntoView({block:"nearest"}))}function j(){var _;return(_=C.current)==null?void 0:_.querySelector(`${Bp}[aria-selected="true"]`)}function Y(){var _;return Array.from(((_=C.current)==null?void 0:_.querySelectorAll(zp))||[])}function q(_){let P=Y()[_];P&&E.setState("value",P.getAttribute(Or))}function z(_){var P;let D=j(),$=Y(),ee=$.findIndex(L=>L===D),H=$[ee+_];(P=a.current)!=null&&P.loop&&(H=ee+_<0?$[$.length-1]:ee+_===$.length?$[0]:$[ee+_]),H&&E.setState("value",H.getAttribute(Or))}function R(_){let P=j(),D=P==null?void 0:P.closest(No),$;for(;D&&!$;)D=_>0?dk(D,No):fk(D,No),$=D==null?void 0:D.querySelector(zp);$?E.setState("value",$.getAttribute(Or)):z(_)}let I=()=>q(Y().length-1),U=_=>{_.preventDefault(),_.metaKey?I():_.altKey?R(1):z(1)},J=_=>{_.preventDefault(),_.metaKey?q(0):_.altKey?R(-1):z(-1)};return p.createElement(xe.div,{ref:t,tabIndex:-1,...y,"cmdk-root":"",onKeyDown:_=>{var P;(P=y.onKeyDown)==null||P.call(y,_);let D=_.nativeEvent.isComposing||_.keyCode===229;if(!(_.defaultPrevented||D))switch(_.key){case"n":case"j":{x&&_.ctrlKey&&U(_);break}case"ArrowDown":{U(_);break}case"p":case"k":{x&&_.ctrlKey&&J(_);break}case"ArrowUp":{J(_);break}case"Home":{_.preventDefault(),q(0);break}case"End":{_.preventDefault(),I();break}case"Enter":{_.preventDefault();let $=j();if($){let ee=new Event(bl);$.dispatchEvent(ee)}}}}},p.createElement("label",{"cmdk-label":"",htmlFor:N.inputId,id:N.labelId,style:mk},l),Js(e,_=>p.createElement(Up.Provider,{value:E},p.createElement(Hp.Provider,{value:N},_))))}),rk=p.forwardRef((e,t)=>{var n,r;let o=Nt(),s=p.useRef(null),i=p.useContext(Wp),a=Ao(),l=Kp(e),c=(r=(n=l.current)==null?void 0:n.forceMount)!=null?r:i==null?void 0:i.forceMount;ur(()=>{if(!c)return a.item(o,i==null?void 0:i.id)},[c]);let d=qp(o,s,[e.value,e.children,s],e.keywords),h=wl(),m=Gn(T=>T.value&&T.value===d.current),f=Gn(T=>c||a.filter()===!1?!0:T.search?T.filtered.items.get(o)>0:!0);p.useEffect(()=>{let T=s.current;if(!(!T||e.disabled))return T.addEventListener(bl,v),()=>T.removeEventListener(bl,v)},[f,e.onSelect,e.disabled]);function v(){var T,E;g(),(E=(T=l.current).onSelect)==null||E.call(T,d.current)}function g(){h.setState("value",d.current,!0)}if(!f)return null;let{disabled:x,value:y,onSelect:w,forceMount:S,keywords:k,...C}=e;return p.createElement(xe.div,{ref:On(s,t),...C,id:o,"cmdk-item":"",role:"option","aria-disabled":!!x,"aria-selected":!!m,"data-disabled":!!x,"data-selected":!!m,onPointerMove:x||a.getDisablePointerSelection()?void 0:g,onClick:x?void 0:v},e.children)}),ok=p.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:o,...s}=e,i=Nt(),a=p.useRef(null),l=p.useRef(null),c=Nt(),d=Ao(),h=Gn(f=>o||d.filter()===!1?!0:f.search?f.filtered.groups.has(i):!0);ur(()=>d.group(i),[]),qp(i,a,[e.value,e.heading,l]);let m=p.useMemo(()=>({id:i,forceMount:o}),[o]);return p.createElement(xe.div,{ref:On(a,t),...s,"cmdk-group":"",role:"presentation",hidden:h?void 0:!0},n&&p.createElement("div",{ref:l,"cmdk-group-heading":"","aria-hidden":!0,id:c},n),Js(e,f=>p.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?c:void 0},p.createElement(Wp.Provider,{value:m},f))))}),sk=p.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,o=p.useRef(null),s=Gn(i=>!i.search);return!n&&!s?null:p.createElement(xe.div,{ref:On(o,t),...r,"cmdk-separator":"",role:"separator"})}),ik=p.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,o=e.value!=null,s=wl(),i=Gn(c=>c.search),a=Gn(c=>c.selectedItemId),l=Ao();return p.useEffect(()=>{e.value!=null&&s.setState("search",e.value)},[e.value]),p.createElement(xe.input,{ref:t,...r,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":l.listId,"aria-labelledby":l.labelId,"aria-activedescendant":a,id:l.inputId,type:"text",value:o?e.value:i,onChange:c=>{o||s.setState("search",c.target.value),n==null||n(c.target.value)}})}),ak=p.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...o}=e,s=p.useRef(null),i=p.useRef(null),a=Gn(c=>c.selectedItemId),l=Ao();return p.useEffect(()=>{if(i.current&&s.current){let c=i.current,d=s.current,h,m=new ResizeObserver(()=>{h=requestAnimationFrame(()=>{let f=c.offsetHeight;d.style.setProperty("--cmdk-list-height",f.toFixed(1)+"px")})});return m.observe(c),()=>{cancelAnimationFrame(h),m.unobserve(c)}}},[]),p.createElement(xe.div,{ref:On(s,t),...o,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":a,"aria-label":r,id:l.listId},Js(e,c=>p.createElement("div",{ref:On(i,l.listInnerRef),"cmdk-list-sizer":""},c)))}),lk=p.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:o,contentClassName:s,container:i,...a}=e;return p.createElement(Za,{open:n,onOpenChange:r},p.createElement(Qa,{container:i},p.createElement(To,{"cmdk-overlay":"",className:o}),p.createElement(ko,{"aria-label":e.label,"cmdk-dialog":"",className:s},p.createElement(Vp,{ref:t,...a}))))}),ck=p.forwardRef((e,t)=>Gn(n=>n.filtered.count===0)?p.createElement(xe.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),uk=p.forwardRef((e,t)=>{let{progress:n,children:r,label:o="Loading...",...s}=e;return p.createElement(xe.div,{ref:t,...s,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":o},Js(e,i=>p.createElement("div",{"aria-hidden":!0},i)))}),Ut=Object.assign(Vp,{List:ak,Item:rk,Input:ik,Group:ok,Separator:sk,Dialog:lk,Empty:ck,Loading:uk});function dk(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function fk(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function Kp(e){let t=p.useRef(e);return ur(()=>{t.current=e}),t}var ur=typeof window>"u"?p.useEffect:p.useLayoutEffect;function Dr(e){let t=p.useRef();return t.current===void 0&&(t.current=e()),t}function Gn(e){let t=wl(),n=()=>e(t.snapshot());return p.useSyncExternalStore(t.subscribe,n,n)}function qp(e,t,n,r=[]){let o=p.useRef(),s=Ao();return ur(()=>{var i;let a=(()=>{var c;for(let d of n){if(typeof d=="string")return d.trim();if(typeof d=="object"&&"current"in d)return d.current?(c=d.current.textContent)==null?void 0:c.trim():o.current}})(),l=r.map(c=>c.trim());s.value(e,a,l),(i=t.current)==null||i.setAttribute(Or,a),o.current=a}),o}var hk=()=>{let[e,t]=p.useState(),n=Dr(()=>new Map);return ur(()=>{n.current.forEach(r=>r()),n.current=new Map},[e]),(r,o)=>{n.current.set(r,o),t({})}};function pk(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function Js({asChild:e,children:t},n){return e&&p.isValidElement(t)?p.cloneElement(pk(t),{ref:t.ref},n(t.props.children)):n(t)}var mk={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const yl=p.forwardRef(({className:e,...t},n)=>u.jsx(Ut,{ref:n,className:oe("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));yl.displayName=Ut.displayName;const Sl=p.forwardRef(({className:e,...t},n)=>u.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[u.jsx(ue.Search,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),u.jsx(Ut.Input,{ref:n,className:oe("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),...t})]}));Sl.displayName=Ut.Input.displayName;const Cl=p.forwardRef(({className:e,...t},n)=>u.jsx(Ut.List,{ref:n,className:oe("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));Cl.displayName=Ut.List.displayName;const Tl=p.forwardRef((e,t)=>u.jsx(Ut.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));Tl.displayName=Ut.Empty.displayName;const kl=p.forwardRef(({className:e,...t},n)=>u.jsx(Ut.Group,{ref:n,className:oe("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",e),...t}));kl.displayName=Ut.Group.displayName;const gk=p.forwardRef(({className:e,...t},n)=>u.jsx(Ut.Separator,{ref:n,className:oe("-mx-1 h-px bg-border",e),...t}));gk.displayName=Ut.Separator.displayName;const El=p.forwardRef(({className:e,...t},n)=>u.jsx(Ut.Item,{ref:n,className:oe("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected='true']:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50",e),...t}));El.displayName=Ut.Item.displayName;function Il(e,[t,n]){return Math.min(n,Math.max(t,e))}function xk(e,t){return p.useReducer((n,r)=>t[n][r]??n,e)}var Nl="ScrollArea",[Gp,RN]=ln(Nl),[vk,rn]=Gp(Nl),Yp=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,l]=p.useState(null),[c,d]=p.useState(null),[h,m]=p.useState(null),[f,v]=p.useState(null),[g,x]=p.useState(null),[y,w]=p.useState(0),[S,k]=p.useState(0),[C,T]=p.useState(!1),[E,N]=p.useState(!1),M=De(t,F=>l(F)),O=Jo(o);return u.jsx(vk,{scope:n,type:r,dir:O,scrollHideDelay:s,scrollArea:a,viewport:c,onViewportChange:d,content:h,onContentChange:m,scrollbarX:f,onScrollbarXChange:v,scrollbarXEnabled:C,onScrollbarXEnabledChange:T,scrollbarY:g,onScrollbarYChange:x,scrollbarYEnabled:E,onScrollbarYEnabledChange:N,onCornerWidthChange:w,onCornerHeightChange:k,children:u.jsx(xe.div,{dir:O,...i,ref:M,style:{position:"relative","--radix-scroll-area-corner-width":y+"px","--radix-scroll-area-corner-height":S+"px",...e.style}})})});Yp.displayName=Nl;var Xp="ScrollAreaViewport",Jp=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=rn(Xp,n),a=p.useRef(null),l=De(t,a,i.onViewportChange);return u.jsxs(u.Fragment,{children:[u.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}),u.jsx(xe.div,{"data-radix-scroll-area-viewport":"",...s,ref:l,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:u.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});Jp.displayName=Xp;var En="ScrollAreaScrollbar",Al=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=rn(En,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:i}=o,a=e.orientation==="horizontal";return p.useEffect(()=>(a?s(!0):i(!0),()=>{a?s(!1):i(!1)}),[a,s,i]),o.type==="hover"?u.jsx(bk,{...r,ref:t,forceMount:n}):o.type==="scroll"?u.jsx(wk,{...r,ref:t,forceMount:n}):o.type==="auto"?u.jsx(Zp,{...r,ref:t,forceMount:n}):o.type==="always"?u.jsx(jl,{...r,ref:t}):null});Al.displayName=En;var bk=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=rn(En,e.__scopeScrollArea),[s,i]=p.useState(!1);return p.useEffect(()=>{const a=o.scrollArea;let l=0;if(a){const c=()=>{window.clearTimeout(l),i(!0)},d=()=>{l=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",c),a.addEventListener("pointerleave",d),()=>{window.clearTimeout(l),a.removeEventListener("pointerenter",c),a.removeEventListener("pointerleave",d)}}},[o.scrollArea,o.scrollHideDelay]),u.jsx(zt,{present:n||s,children:u.jsx(Zp,{"data-state":s?"visible":"hidden",...r,ref:t})})}),wk=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=rn(En,e.__scopeScrollArea),s=e.orientation==="horizontal",i=ti(()=>l("SCROLL_END"),100),[a,l]=xk("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return p.useEffect(()=>{if(a==="idle"){const c=window.setTimeout(()=>l("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(c)}},[a,o.scrollHideDelay,l]),p.useEffect(()=>{const c=o.viewport,d=s?"scrollLeft":"scrollTop";if(c){let h=c[d];const m=()=>{const f=c[d];h!==f&&(l("SCROLL"),i()),h=f};return c.addEventListener("scroll",m),()=>c.removeEventListener("scroll",m)}},[o.viewport,s,l,i]),u.jsx(zt,{present:n||a!=="hidden",children:u.jsx(jl,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:ce(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:ce(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),Zp=p.forwardRef((e,t)=>{const n=rn(En,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=p.useState(!1),a=e.orientation==="horizontal",l=ti(()=>{if(n.viewport){const c=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?c:d)}},10);return Lr(n.viewport,l),Lr(n.content,l),u.jsx(zt,{present:r||s,children:u.jsx(jl,{"data-state":s?"visible":"hidden",...o,ref:t})})}),jl=p.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=rn(En,e.__scopeScrollArea),s=p.useRef(null),i=p.useRef(0),[a,l]=p.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),c=rm(a.viewport,a.content),d={...r,sizes:a,onSizesChange:l,hasThumb:c>0&&c<1,onThumbChange:m=>s.current=m,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:m=>i.current=m};function h(m,f){return Ek(m,i.current,a,f)}return n==="horizontal"?u.jsx(yk,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollLeft,f=om(m,a,o.dir);s.current.style.transform=`translate3d(${f}px, 0, 0)`}},onWheelScroll:m=>{o.viewport&&(o.viewport.scrollLeft=m)},onDragScroll:m=>{o.viewport&&(o.viewport.scrollLeft=h(m,o.dir))}}):n==="vertical"?u.jsx(Sk,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollTop,f=om(m,a);s.current.style.transform=`translate3d(0, ${f}px, 0)`}},onWheelScroll:m=>{o.viewport&&(o.viewport.scrollTop=m)},onDragScroll:m=>{o.viewport&&(o.viewport.scrollTop=h(m))}}):null}),yk=p.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=rn(En,e.__scopeScrollArea),[i,a]=p.useState(),l=p.useRef(null),c=De(t,l,s.onScrollbarXChange);return p.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(em,{"data-orientation":"horizontal",...o,ref:c,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":ei(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.x),onDragScroll:d=>e.onDragScroll(d.x),onWheelScroll:(d,h)=>{if(s.viewport){const m=s.viewport.scrollLeft+d.deltaX;e.onWheelScroll(m),im(m,h)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:l.current.clientWidth,paddingStart:Qs(i.paddingLeft),paddingEnd:Qs(i.paddingRight)}})}})}),Sk=p.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=rn(En,e.__scopeScrollArea),[i,a]=p.useState(),l=p.useRef(null),c=De(t,l,s.onScrollbarYChange);return p.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(em,{"data-orientation":"vertical",...o,ref:c,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":ei(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.y),onDragScroll:d=>e.onDragScroll(d.y),onWheelScroll:(d,h)=>{if(s.viewport){const m=s.viewport.scrollTop+d.deltaY;e.onWheelScroll(m),im(m,h)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:l.current.clientHeight,paddingStart:Qs(i.paddingTop),paddingEnd:Qs(i.paddingBottom)}})}})}),[Ck,Qp]=Gp(En),em=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:l,onDragScroll:c,onWheelScroll:d,onResize:h,...m}=e,f=rn(En,n),[v,g]=p.useState(null),x=De(t,M=>g(M)),y=p.useRef(null),w=p.useRef(""),S=f.viewport,k=r.content-r.viewport,C=ft(d),T=ft(l),E=ti(h,10);function N(M){if(y.current){const O=M.clientX-y.current.left,F=M.clientY-y.current.top;c({x:O,y:F})}}return p.useEffect(()=>{const M=O=>{const F=O.target;(v==null?void 0:v.contains(F))&&C(O,k)};return document.addEventListener("wheel",M,{passive:!1}),()=>document.removeEventListener("wheel",M,{passive:!1})},[S,v,k,C]),p.useEffect(T,[r,T]),Lr(v,E),Lr(f.content,E),u.jsx(Ck,{scope:n,scrollbar:v,hasThumb:o,onThumbChange:ft(s),onThumbPointerUp:ft(i),onThumbPositionChange:T,onThumbPointerDown:ft(a),children:u.jsx(xe.div,{...m,ref:x,style:{position:"absolute",...m.style},onPointerDown:ce(e.onPointerDown,M=>{M.button===0&&(M.target.setPointerCapture(M.pointerId),y.current=v.getBoundingClientRect(),w.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",f.viewport&&(f.viewport.style.scrollBehavior="auto"),N(M))}),onPointerMove:ce(e.onPointerMove,N),onPointerUp:ce(e.onPointerUp,M=>{const O=M.target;O.hasPointerCapture(M.pointerId)&&O.releasePointerCapture(M.pointerId),document.body.style.webkitUserSelect=w.current,f.viewport&&(f.viewport.style.scrollBehavior=""),y.current=null})})})}),Zs="ScrollAreaThumb",tm=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Qp(Zs,e.__scopeScrollArea);return u.jsx(zt,{present:n||o.hasThumb,children:u.jsx(Tk,{ref:t,...r})})}),Tk=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=rn(Zs,n),i=Qp(Zs,n),{onThumbPositionChange:a}=i,l=De(t,h=>i.onThumbChange(h)),c=p.useRef(void 0),d=ti(()=>{c.current&&(c.current(),c.current=void 0)},100);return p.useEffect(()=>{const h=s.viewport;if(h){const m=()=>{if(d(),!c.current){const f=Ik(h,a);c.current=f,a()}};return a(),h.addEventListener("scroll",m),()=>h.removeEventListener("scroll",m)}},[s.viewport,d,a]),u.jsx(xe.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:ce(e.onPointerDownCapture,h=>{const f=h.target.getBoundingClientRect(),v=h.clientX-f.left,g=h.clientY-f.top;i.onThumbPointerDown({x:v,y:g})}),onPointerUp:ce(e.onPointerUp,i.onThumbPointerUp)})});tm.displayName=Zs;var Pl="ScrollAreaCorner",nm=p.forwardRef((e,t)=>{const n=rn(Pl,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?u.jsx(kk,{...e,ref:t}):null});nm.displayName=Pl;var kk=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=rn(Pl,n),[s,i]=p.useState(0),[a,l]=p.useState(0),c=!!(s&&a);return Lr(o.scrollbarX,()=>{var h;const d=((h=o.scrollbarX)==null?void 0:h.offsetHeight)||0;o.onCornerHeightChange(d),l(d)}),Lr(o.scrollbarY,()=>{var h;const d=((h=o.scrollbarY)==null?void 0:h.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),c?u.jsx(xe.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 Qs(e){return e?parseInt(e,10):0}function rm(e,t){const n=e/t;return isNaN(n)?0:n}function ei(e){const t=rm(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function Ek(e,t,n,r="ltr"){const o=ei(n),s=o/2,i=t||s,a=o-i,l=n.scrollbar.paddingStart+i,c=n.scrollbar.size-n.scrollbar.paddingEnd-a,d=n.content-n.viewport,h=r==="ltr"?[0,d]:[d*-1,0];return sm([l,c],h)(e)}function om(e,t,n="ltr"){const r=ei(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],c=Il(e,l);return sm([0,i],[0,a])(c)}function sm(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 im(e,t){return e>0&&e<t}var Ik=(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 ti(e,t){const n=ft(e),r=p.useRef(0);return p.useEffect(()=>()=>window.clearTimeout(r.current),[]),p.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function Lr(e,t){const n=ft(t);yt(()=>{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 am=Yp,Nk=Jp,Ak=nm;const _l=p.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(am,{ref:r,className:oe("relative overflow-hidden",e),...n,children:[u.jsx(Nk,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),u.jsx(lm,{}),u.jsx(Ak,{})]}));_l.displayName=am.displayName;const lm=p.forwardRef(({className:e,orientation:t="vertical",...n},r)=>u.jsx(Al,{ref:r,orientation:t,className:oe("flex touch-none select-none transition-colors",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...n,children:u.jsx(tm,{className:"relative flex-1 rounded-full bg-border"})}));lm.displayName=Al.displayName;const Ml=p.forwardRef(({className:e,type:t,...n},r)=>u.jsx("input",{type:t,className:oe("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:r,...n}));Ml.displayName="Input";const jk="group relative p-3 rounded-lg cursor-pointer transition-colors border text-gray-900 dark:text-slate-100",Pk="bg-slate-700 border-slate-600 hover:bg-slate-600",_k="bg-slate-600 border-slate-500";function cm({thread:e,isActive:t,editingThreadId:n,editingTitle:r,onSelect:o,onStartEditing:s,onEditingTitleChange:i,onSaveEditing:a,onCancelEditing:l,onShare:c,onDelete:d,showEditTitle:h,showDeleteButton:m,formatDate:f,getDisplayThreadTitle:v,secondaryLine:g,itemClassName:x,activeItemClassName:y}){const w=n===e.threadId,S=t?`${y??_k}`:`${x??Pk}`,k=C=>{C.stopPropagation(),o(e.threadId)};return u.jsxs("div",{onClick:k,className:`${jk} ${S}`,children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("div",{className:"flex-1 min-w-0",children:w?u.jsxs("div",{className:"flex items-center gap-2",onClick:C=>C.stopPropagation(),children:[u.jsx(Ml,{value:r,onChange:C=>i(C.target.value),onKeyDown:C=>{C.key==="Enter"?a(e.threadId):C.key==="Escape"&&l()},className:"h-6 text-sm",autoFocus:!0}),u.jsx(Xe,{variant:"ghost",size:"sm",onClick:()=>a(e.threadId),className:"h-6 w-6 p-0",children:u.jsx(ue.Check,{size:12})}),u.jsx(Xe,{variant:"ghost",size:"sm",onClick:l,className:"h-6 w-6 p-0",children:u.jsx(ue.X,{size:12})})]}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"font-medium text-sm truncate text-gray-900 dark:text-slate-100",children:v(e)}),u.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-slate-400 mt-1",children:[u.jsx(ue.Calendar,{size:10}),u.jsx("span",{children:f(e.updatedAt||e.createdAt)})]}),g&&u.jsx("div",{className:"text-[11px] text-muted-foreground mt-1",children:g})]})}),u.jsx("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2",children:u.jsxs(Cs,{children:[u.jsx(Ts,{asChild:!0,children:u.jsx(Xe,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",children:u.jsx(ue.MoreHorizontal,{size:12})})}),u.jsxs(ho,{align:"end",sideOffset:6,className:"w-44",children:[u.jsxs(Bn,{onClick:C=>{C.preventDefault(),c(e.threadId)},children:[u.jsx(ue.Share2,{className:"mr-2 h-4 w-4"}),"Share thread"]}),h&&n!==e.threadId&&u.jsxs(Bn,{onClick:C=>{C.preventDefault(),s(e,C)},children:[u.jsx(ue.Edit3,{className:"mr-2 h-4 w-4"}),"Rename"]}),m&&d&&u.jsxs(Bn,{className:"text-red-400 hover:text-red-300",onClick:C=>{C.preventDefault(),d(e.threadId,C)},children:[u.jsx(ue.Trash2,{className:"mr-2 h-4 w-4"}),"Delete"]})]})]})})]}),t&&u.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-1 h-8 bg-blue-400 rounded-r"})]})}const um=25,dm="thread-manager-view",Mk=e=>e==="default"||e==="shared",Rk=()=>{if(typeof window>"u")return null;try{const e=window.localStorage.getItem(dm);if(Mk(e))return e}catch{}return null};function fm({defaultView:e}={}){const[t,n]=b.useState(()=>Rk()??e??"default");b.useEffect(()=>{if(!(typeof window>"u"))try{window.localStorage.setItem(dm,t)}catch{}},[t]);const r=b.useCallback(o=>{n(o)},[]);return{view:t,setView:r}}const Ok=[{key:"default",label:"My chats"},{key:"shared",label:"Shared with you"}];function ni({className:e="",showCreateButton:t=!0,showDeleteButton:n=!0,showEditTitle:r=!0,maxHeight:o="400px",customStyles:s={},currentThreadId:i=null,navigateToThread:a,onThreadSelect:l,onThreadCreate:c,onThreadDelete:d,view:h,defaultView:m,onViewChange:f,viewOptions:v,viewState:g,showHeader:x=!0,shareTargets:y,isLoadingShareTargets:w,shareTargetFilter:S}){const{threads:k,sharedThreads:C,currentThreadId:T,setCurrentThreadId:E,isLoading:N,isLoadingSharedThreads:M,actions:O,shareInFlight:F,shareStatus:G,clearShareStatus:K}=xr(),{createThread:j,deleteThread:Y,renameThread:q,shareThread:z}=O,{loadThread:R}=eo(),I=i??T,[U,J]=b.useState(Array.isArray(k)?k:[]),_=b.useRef(U.length>0),P=b.useRef(null),D=b.useRef(0),[$,ee]=b.useState(null),[H,L]=b.useState(""),[Z,te]=b.useState(!1),[Q,W]=b.useState(!1),[le,ie]=b.useState(null),[ge,we]=b.useState(""),Ce=v&&v.length>0?v:Ok,Ae=fm({defaultView:m}),Ee=g??Ae,st=h??Ee.view,lt=b.useCallback(X=>{h||Ee.setView(X),f==null||f(X)},[h,f,Ee]),St=Ce.find(X=>X.key===st)??Ce[0],Oe=X=>{ie(X),we(""),W(!0)},qe=()=>{W(!1),ie(null),we(""),K()},We=b.useCallback(async X=>{if(!(!le||F)&&X.id)try{await z(le,X.id),setTimeout(()=>qe(),600)}catch(fe){console.error("Failed to share thread:",fe)}},[qe,F,le,z]),je=b.useMemo(()=>{const X=y??[],fe=ge.trim().toLowerCase();return fe?S?X.filter(He=>S(He,fe)):X.filter(He=>`${He.label} ${He.secondaryLabel??""}`.toLowerCase().includes(fe)):X},[y,ge,S]),_e=st==="shared",ct=_e?C:U,kt=_e?M:N,nt=_e?"No shared conversations yet":"No conversations yet",Et=X=>{const fe=X.sharedAt?` • ${$e(X.sharedAt)}`:"";return`Shared by ${X.sharedByUserId}${fe}`},bt=X=>"sharedByUserId"in X;b.useEffect(()=>{const X=Array.isArray(k)?k:[];if(X.length>0){_.current=!0,J(X);return}N||(_.current=!1,J(X))},[k,N]),b.useEffect(()=>{if(!P.current)return;const X=P.current.querySelector("[data-radix-scroll-area-viewport]");if(!X)return;let fe=null,He=null;return fe=requestAnimationFrame(()=>{He=requestAnimationFrame(()=>{X.scrollTop=D.current})}),()=>{fe!==null&&cancelAnimationFrame(fe),He!==null&&cancelAnimationFrame(He)}},[U]);const wt=async X=>{try{E(X),await R(X),a==null||a(X),l==null||l(X)}catch(fe){console.error("Failed to select thread:",fe)}},Ct=async()=>{try{te(!0);const X=await j();X&&(c==null||c(X),a==null||a(X))}catch(X){console.error("Failed to create thread:",X)}finally{te(!1)}},on=async(X,fe)=>{if(fe.stopPropagation(),!!confirm("Delete this thread?")){if(P.current){const He=P.current.querySelector("[data-radix-scroll-area-viewport]");He&&(D.current=He.scrollTop)}try{await Y(X),d==null||d(X)}catch(He){console.error("Failed to delete thread:",He)}}},Tt=(X,fe)=>{fe.stopPropagation(),ee(X.threadId),L(X.title||`Thread ${X.threadId.slice(0,8)}`)},Lt=async X=>{if(H.trim())try{await q(X,H.trim()),ee(null),L("")}catch(fe){console.error("Failed to update title:",fe)}},_t=()=>{ee(null),L("")},$e=X=>{if(!X)return"";try{const fe=new Date(X),ae=new Date().getTime()-fe.getTime(),me=Math.floor(ae/(1e3*60*60*24));return me===0?fe.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):me===1?"Yesterday":me<7?`${me} days ago`:fe.toLocaleDateString()}catch{return""}},ze=X=>X.title||`Thread ${X.threadId.slice(0,8)}`,Mt=X=>{const fe=ze(X);return fe.length<=um?fe:`${fe.slice(0,um)}...`};return u.jsxs("div",{className:`flex flex-col h-full ${e} ${s.container||""}`,children:[x&&u.jsxs("div",{className:s.header||"flex flex-col gap-2 px-1 py-0 border border-slate-200 bg-white dark:border-slate-700 dark:bg-slate-900 shadow-sm",children:[t&&u.jsx("div",{className:"flex justify-end",children:u.jsxs(Xe,{onClick:Ct,disabled:Z||N,className:s.createButton||"px-3 py-2 gap-1",size:"sm",variant:"ghost",title:Z?"Creating...":"New Chat",children:[u.jsx(ue.Edit3,{size:16}),u.jsx("span",{children:"New chat"})]})}),u.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-slate-700 dark:text-slate-200 uppercase tracking-wide leading-tight",children:[u.jsx("span",{children:"Current View"}),u.jsxs(Cs,{children:[u.jsx(Ts,{asChild:!0,children:u.jsx(Xe,{variant:"outline",size:"sm",className:"text-[11px] text-slate-700 dark:text-slate-200 border border-slate-300 dark:border-slate-600 bg-white dark:bg-slate-900 hover:bg-slate-50 dark:hover:bg-slate-800 px-2 py-0",children:St.label})}),u.jsx(ho,{align:"start",sideOffset:6,className:"w-40",children:Ce.map(X=>u.jsxs(Bn,{className:"justify-between text-[12px]",onClick:fe=>{fe.preventDefault(),lt(X.key)},children:[u.jsx("span",{children:X.label}),st===X.key&&u.jsx(ue.Check,{className:"h-3 w-3"})]},X.key))})]})]})]}),u.jsx(_l,{ref:P,className:`flex-1 min-h-0 ${s.threadList||""}`,style:o?{maxHeight:o}:void 0,children:u.jsx("div",{className:"p-2 space-y-1 pb-4",children:kt?u.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-8 text-slate-400",children:[u.jsx(ue.Loader2,{className:"h-5 w-5 animate-spin"}),u.jsx("span",{className:"text-sm",children:"Loading threads…"})]}):ct.length===0?u.jsxs("div",{className:"text-center py-8 text-slate-400",children:[u.jsx(ue.MessageSquare,{className:"w-8 h-8 mx-auto mb-2 opacity-40 text-slate-500"}),u.jsx("p",{className:"text-sm text-slate-500",children:nt})]}):ct.slice().sort((X,fe)=>new Date(fe.updatedAt||fe.createdAt||"").getTime()-new Date(X.updatedAt||X.createdAt||"").getTime()).map(X=>u.jsx(cm,{thread:X,isActive:I===X.threadId,editingThreadId:$,editingTitle:H,onSelect:wt,onStartEditing:Tt,onEditingTitleChange:fe=>L(fe),onSaveEditing:Lt,onCancelEditing:_t,onShare:()=>Oe(X.threadId),onDelete:on,showEditTitle:r,showDeleteButton:n,formatDate:$e,getDisplayThreadTitle:Mt,secondaryLine:_e&&bt(X)?Et(X):void 0,itemClassName:s.threadItem,activeItemClassName:s.activeThread},X.threadId))})}),u.jsx(el,{open:Q,onOpenChange:X=>!X&&qe(),children:u.jsxs(zs,{className:"max-w-md p-0",children:[u.jsx(Hs,{children:u.jsx(Us,{children:"Share thread"})}),u.jsxs(yl,{children:[u.jsx(Sl,{autoFocus:!0,value:ge,onValueChange:X=>we(X),placeholder:"Search for recipients..."}),u.jsxs(Cl,{children:[G&&u.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-xs text-muted-foreground",children:[F&&u.jsx(ue.Loader2,{className:"h-3 w-3 animate-spin"}),u.jsx("span",{className:G.startsWith("Failed")?"text-red-500":G.startsWith("Shared")?"text-emerald-500":"text-slate-600 dark:text-slate-400",children:G})]}),u.jsx(Tl,{children:w?u.jsxs("span",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(ue.Loader2,{className:"h-4 w-4 animate-spin"}),"Loading recipients…"]}):"No matching recipients found"}),je.length>0&&u.jsx(kl,{heading:"Recipients",children:je.map(X=>u.jsx(El,{onSelect:()=>We(X),children:u.jsxs("div",{className:"flex flex-col items-start text-sm",children:[u.jsx("span",{className:"font-medium",children:X.label}),X.secondaryLabel&&u.jsx("span",{className:"text-xs text-muted-foreground",children:X.secondaryLabel})]})},X.id))})]})]})]})})]})}function Dk({layout:e="sidebar",layoutSize:t="desktop",showThreads:n=!0,className:r="",customStyles:o={},...s}){const i=c=>{const d="h-full";switch(c){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=c=>({"--chat-sidebar-width":c==="phone"?"100%":c==="tablet"?"280px":c==="half-screen"?"240px":"320px","--chat-message-max-width":c==="phone"?"95%":c==="tablet"?"90%":c==="half-screen"?"85%":"80%","--chat-input-height":c==="phone"?"120px":"100px"}),l=b.useCallback(c=>{var d;(d=s.onThreadChange)==null||d.call(s,c)},[s]);return e==="fullscreen"?u.jsx(br,{...s,onThreadChange:l,children:u.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:u.jsx(Rr,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?u.jsx(br,{...s,onThreadChange:l,children:u.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:u.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[n&&u.jsx("div",{className:`w-80 border-r flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:u.jsx(ni,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),u.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:u.jsx(Rr,{onError:s.onError,enableFileUpload:!0})})]})})}):u.jsx(br,{...s,onThreadChange:l,children:u.jsxs("div",{className:`${i(t)} flex overflow-hidden ${r} ${o.container||""}`,style:a(t),children:[n&&u.jsx("div",{className:`w-80 border-r bg-gray-50 flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:u.jsx(ni,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),u.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:u.jsx(Rr,{onError:s.onError,enableFileUpload:!0})})]})})}function Lk({apiConfig:e,className:t="",onError:n}){return u.jsx(br,{apiConfig:e,onError:n,children:u.jsx("div",{className:`h-full ${t}`,children:u.jsx(Rr,{})})})}function $k({placeholder:e,onMessageSent:t}){const[n,r]=b.useState("chat");return u.jsxs("div",{className:"flex flex-col h-full",children:[u.jsxs("div",{className:"flex border-b border-gray-200 bg-gray-50",children:[u.jsx("button",{onClick:()=>r("chat"),className:`flex-1 px-3 py-2 text-sm font-medium transition-colors ${n==="chat"?"border-b-2 border-slate-800 text-slate-800 bg-white":"text-gray-600 hover:text-gray-800"}`,children:u.jsxs("div",{className:"flex items-center justify-center gap-2",children:[u.jsx(ue.MessageSquare,{size:14}),"Chat"]})}),u.jsx("button",{onClick:()=>r("threads"),className:`flex-1 px-3 py-2 text-sm font-medium transition-colors ${n==="threads"?"border-b-2 border-slate-800 text-slate-800 bg-white":"text-gray-600 hover:text-gray-800"}`,children:u.jsxs("div",{className:"flex items-center justify-center gap-2",children:[u.jsx(ue.History,{size:14}),"History"]})})]}),u.jsx("div",{className:"flex-1 min-h-0",children:n==="chat"?u.jsx(Rr,{placeholder:e??"Ask Serti AI anything...",autoFocus:!0,className:"h-full",onMessageSent:t}):u.jsx(ni,{showCreateButton:!0,className:"h-full",onThreadSelect:()=>r("chat")})})]})}function Fk({className:e="",placeholder:t,isAuthenticated:n=!0,onMessageSent:r,widgetTitle:o="Serti AI Navigator",widgetSubtitle:s="AI-Powered Assistant",...i}){const[a,l]=b.useState(!1);return n?u.jsx(br,{...i,children:u.jsx("div",{className:`fixed bottom-6 right-6 z-[9999] transition-all duration-300 ${e}`,children:u.jsxs("div",{className:`w-96 bg-white rounded-xl shadow-2xl border border-gray-200 overflow-hidden relative ${a?"scale-75":"scale-100"}`,children:[u.jsx("div",{className:"bg-slate-800 text-white p-4 flex-shrink-0",children:u.jsxs("div",{className:"flex items-center justify-between gap-3",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsxs("div",{className:"relative h-10 w-10 rounded-full bg-gradient-to-br from-slate-500 to-slate-700 border border-white/30 flex items-center justify-center text-white text-sm font-bold",children:["S",u.jsx("span",{className:"absolute -bottom-0.5 -right-0.5 h-3 w-3 rounded-full border-2 border-slate-800 bg-emerald-400"})]}),u.jsxs("div",{className:"flex flex-col",children:[u.jsx("h3",{className:"text-lg font-semibold leading-tight",children:o}),u.jsx("p",{className:"text-xs text-white/70",children:s})]}),u.jsx("span",{className:"ml-2 inline-flex items-center justify-center rounded-full bg-red-500 px-2 py-0.5 text-[11px] font-semibold leading-none text-white",children:"1"})]}),u.jsxs("div",{className:"flex items-center gap-1",children:[u.jsx(Xe,{variant:"ghost",size:"sm",className:"text-white hover:bg-white/10 h-8 w-8 p-0",title:"Options",children:u.jsx(ue.MoreHorizontal,{size:16})}),u.jsx(Xe,{variant:"ghost",size:"sm",className:"text-white hover:bg-white/10 h-8 w-8 p-0",title:"Compose",children:u.jsx(ue.Edit3,{size:16})}),u.jsx(Xe,{variant:"ghost",size:"sm",onClick:c=>{c.stopPropagation(),l(d=>!d)},className:"text-white hover:bg-white/10 h-8 w-8 p-0",title:a?"Maximize":"Minimize",children:a?u.jsx(ue.Maximize2,{size:14}):u.jsx(ue.Minimize2,{size:14})})]})]})}),!a&&u.jsx("div",{className:"h-96 flex flex-col",children:u.jsx($k,{placeholder:t,onMessageSent:r})})]})})}):null}function Bk({label:e="New chat",children:t,className:n,variant:r="ghost",size:o="sm",...s}){return u.jsxs(Xe,{variant:r,size:o,className:oe("gap-2 rounded-full px-3 font-semibold transition-all hover:scale-[1.01]",n),...s,children:[u.jsx(ue.Edit3,{size:16}),t??e]})}var zk="Label",hm=p.forwardRef((e,t)=>u.jsx(xe.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())}}));hm.displayName=zk;var pm=hm;const Hk=zr.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),mm=p.forwardRef(({className:e,...t},n)=>u.jsx(pm,{ref:n,className:oe(Hk(),e),...t}));mm.displayName=pm.displayName;function gm(e){const t=p.useRef({value:e,previous:e});return p.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var xm=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),Uk="VisuallyHidden",ri=p.forwardRef((e,t)=>u.jsx(xe.span,{...e,ref:t,style:{...xm,...e.style}}));ri.displayName=Uk;var Wk=ri,Vk=[" ","Enter","ArrowUp","ArrowDown"],Kk=[" ","Enter"],dr="Select",[oi,si,qk]=Xo(dr),[$r,ON]=ln(dr,[qk,Er]),ii=Er(),[Gk,Yn]=$r(dr),[Yk,Xk]=$r(dr),vm=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:l,dir:c,name:d,autoComplete:h,disabled:m,required:f,form:v}=e,g=ii(t),[x,y]=p.useState(null),[w,S]=p.useState(null),[k,C]=p.useState(!1),T=Jo(c),[E,N]=Dn({prop:r,defaultProp:o??!1,onChange:s,caller:dr}),[M,O]=Dn({prop:i,defaultProp:a,onChange:l,caller:dr}),F=p.useRef(null),G=x?v||!!x.closest("form"):!0,[K,j]=p.useState(new Set),Y=Array.from(K).map(q=>q.props.value).join(";");return u.jsx(sa,{...g,children:u.jsxs(Gk,{required:f,scope:t,trigger:x,onTriggerChange:y,valueNode:w,onValueNodeChange:S,valueNodeHasChildren:k,onValueNodeHasChildrenChange:C,contentId:Nt(),value:M,onValueChange:O,open:E,onOpenChange:N,dir:T,triggerPointerDownPosRef:F,disabled:m,children:[u.jsx(oi.Provider,{scope:t,children:u.jsx(Yk,{scope:e.__scopeSelect,onNativeOptionAdd:p.useCallback(q=>{j(z=>new Set(z).add(q))},[]),onNativeOptionRemove:p.useCallback(q=>{j(z=>{const R=new Set(z);return R.delete(q),R})},[]),children:n})}),G?u.jsxs(Hm,{"aria-hidden":!0,required:f,tabIndex:-1,name:d,autoComplete:h,value:M,onChange:q=>O(q.target.value),disabled:m,form:v,children:[M===void 0?u.jsx("option",{value:""}):null,Array.from(K)]},Y):null]})})};vm.displayName=dr;var bm="SelectTrigger",wm=p.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=ii(n),i=Yn(bm,n),a=i.disabled||r,l=De(t,i.onTriggerChange),c=si(n),d=p.useRef("touch"),[h,m,f]=Wm(g=>{const x=c().filter(S=>!S.disabled),y=x.find(S=>S.value===i.value),w=Vm(x,g,y);w!==void 0&&i.onValueChange(w.value)}),v=g=>{a||(i.onOpenChange(!0),f()),g&&(i.triggerPointerDownPosRef.current={x:Math.round(g.pageX),y:Math.round(g.pageY)})};return u.jsx(ia,{asChild:!0,...s,children:u.jsx(xe.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":Um(i.value)?"":void 0,...o,ref:l,onClick:ce(o.onClick,g=>{g.currentTarget.focus(),d.current!=="mouse"&&v(g)}),onPointerDown:ce(o.onPointerDown,g=>{d.current=g.pointerType;const x=g.target;x.hasPointerCapture(g.pointerId)&&x.releasePointerCapture(g.pointerId),g.button===0&&g.ctrlKey===!1&&g.pointerType==="mouse"&&(v(g),g.preventDefault())}),onKeyDown:ce(o.onKeyDown,g=>{const x=h.current!=="";!(g.ctrlKey||g.altKey||g.metaKey)&&g.key.length===1&&m(g.key),!(x&&g.key===" ")&&Vk.includes(g.key)&&(v(),g.preventDefault())})})})});wm.displayName=bm;var ym="SelectValue",Sm=p.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=Yn(ym,n),{onValueNodeHasChildrenChange:c}=l,d=s!==void 0,h=De(t,l.onValueNodeChange);return yt(()=>{c(d)},[c,d]),u.jsx(xe.span,{...a,ref:h,style:{pointerEvents:"none"},children:Um(l.value)?u.jsx(u.Fragment,{children:i}):s})});Sm.displayName=ym;var Jk="SelectIcon",Cm=p.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return u.jsx(xe.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});Cm.displayName=Jk;var Zk="SelectPortal",Tm=e=>u.jsx(so,{asChild:!0,...e});Tm.displayName=Zk;var fr="SelectContent",km=p.forwardRef((e,t)=>{const n=Yn(fr,e.__scopeSelect),[r,o]=p.useState();if(yt(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?Hr.createPortal(u.jsx(Em,{scope:e.__scopeSelect,children:u.jsx(oi.Slot,{scope:e.__scopeSelect,children:u.jsx("div",{children:e.children})})}),s):null}return u.jsx(Im,{...e,ref:t})});km.displayName=fr;var pn=10,[Em,Xn]=$r(fr),Qk="SelectContentImpl",eE=Kt.createSlot("SelectContent.RemoveScroll"),Im=p.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:h,collisionBoundary:m,collisionPadding:f,sticky:v,hideWhenDetached:g,avoidCollisions:x,...y}=e,w=Yn(fr,n),[S,k]=p.useState(null),[C,T]=p.useState(null),E=De(t,H=>k(H)),[N,M]=p.useState(null),[O,F]=p.useState(null),G=si(n),[K,j]=p.useState(!1),Y=p.useRef(!1);p.useEffect(()=>{if(S)return fa(S)},[S]),Ui();const q=p.useCallback(H=>{const[L,...Z]=G().map(W=>W.ref.current),[te]=Z.slice(-1),Q=document.activeElement;for(const W of H)if(W===Q||(W==null||W.scrollIntoView({block:"nearest"}),W===L&&C&&(C.scrollTop=0),W===te&&C&&(C.scrollTop=C.scrollHeight),W==null||W.focus(),document.activeElement!==Q))return},[G,C]),z=p.useCallback(()=>q([N,S]),[q,N,S]);p.useEffect(()=>{K&&z()},[K,z]);const{onOpenChange:R,triggerPointerDownPosRef:I}=w;p.useEffect(()=>{if(S){let H={x:0,y:0};const L=te=>{var Q,W;H={x:Math.abs(Math.round(te.pageX)-(((Q=I.current)==null?void 0:Q.x)??0)),y:Math.abs(Math.round(te.pageY)-(((W=I.current)==null?void 0:W.y)??0))}},Z=te=>{H.x<=10&&H.y<=10?te.preventDefault():S.contains(te.target)||R(!1),document.removeEventListener("pointermove",L),I.current=null};return I.current!==null&&(document.addEventListener("pointermove",L),document.addEventListener("pointerup",Z,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",L),document.removeEventListener("pointerup",Z,{capture:!0})}}},[S,R,I]),p.useEffect(()=>{const H=()=>R(!1);return window.addEventListener("blur",H),window.addEventListener("resize",H),()=>{window.removeEventListener("blur",H),window.removeEventListener("resize",H)}},[R]);const[U,J]=Wm(H=>{const L=G().filter(Q=>!Q.disabled),Z=L.find(Q=>Q.ref.current===document.activeElement),te=Vm(L,H,Z);te&&setTimeout(()=>te.ref.current.focus())}),_=p.useCallback((H,L,Z)=>{const te=!Y.current&&!Z;(w.value!==void 0&&w.value===L||te)&&(M(H),te&&(Y.current=!0))},[w.value]),P=p.useCallback(()=>S==null?void 0:S.focus(),[S]),D=p.useCallback((H,L,Z)=>{const te=!Y.current&&!Z;(w.value!==void 0&&w.value===L||te)&&F(H)},[w.value]),$=r==="popper"?Rl:Nm,ee=$===Rl?{side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:h,collisionBoundary:m,collisionPadding:f,sticky:v,hideWhenDetached:g,avoidCollisions:x}:{};return u.jsx(Em,{scope:n,content:S,viewport:C,onViewportChange:T,itemRefCallback:_,selectedItem:N,onItemLeave:P,itemTextRefCallback:D,focusSelectedItem:z,selectedItemText:O,position:r,isPositioned:K,searchRef:U,children:u.jsx(xs,{as:eE,allowPinchZoom:!0,children:u.jsx(Zo,{asChild:!0,trapped:w.open,onMountAutoFocus:H=>{H.preventDefault()},onUnmountAutoFocus:ce(o,H=>{var L;(L=w.trigger)==null||L.focus({preventScroll:!0}),H.preventDefault()}),children:u.jsx(yr,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:H=>H.preventDefault(),onDismiss:()=>w.onOpenChange(!1),children:u.jsx($,{role:"listbox",id:w.contentId,"data-state":w.open?"open":"closed",dir:w.dir,onContextMenu:H=>H.preventDefault(),...y,...ee,onPlaced:()=>j(!0),ref:E,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:ce(y.onKeyDown,H=>{const L=H.ctrlKey||H.altKey||H.metaKey;if(H.key==="Tab"&&H.preventDefault(),!L&&H.key.length===1&&J(H.key),["ArrowUp","ArrowDown","Home","End"].includes(H.key)){let te=G().filter(Q=>!Q.disabled).map(Q=>Q.ref.current);if(["ArrowUp","End"].includes(H.key)&&(te=te.slice().reverse()),["ArrowUp","ArrowDown"].includes(H.key)){const Q=H.target,W=te.indexOf(Q);te=te.slice(W+1)}setTimeout(()=>q(te)),H.preventDefault()}})})})})})})});Im.displayName=Qk;var tE="SelectItemAlignedPosition",Nm=p.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=Yn(fr,n),i=Xn(fr,n),[a,l]=p.useState(null),[c,d]=p.useState(null),h=De(t,E=>d(E)),m=si(n),f=p.useRef(!1),v=p.useRef(!0),{viewport:g,selectedItem:x,selectedItemText:y,focusSelectedItem:w}=i,S=p.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&c&&g&&x&&y){const E=s.trigger.getBoundingClientRect(),N=c.getBoundingClientRect(),M=s.valueNode.getBoundingClientRect(),O=y.getBoundingClientRect();if(s.dir!=="rtl"){const Q=O.left-N.left,W=M.left-Q,le=E.left-W,ie=E.width+le,ge=Math.max(ie,N.width),we=window.innerWidth-pn,Ce=Il(W,[pn,Math.max(pn,we-ge)]);a.style.minWidth=ie+"px",a.style.left=Ce+"px"}else{const Q=N.right-O.right,W=window.innerWidth-M.right-Q,le=window.innerWidth-E.right-W,ie=E.width+le,ge=Math.max(ie,N.width),we=window.innerWidth-pn,Ce=Il(W,[pn,Math.max(pn,we-ge)]);a.style.minWidth=ie+"px",a.style.right=Ce+"px"}const F=m(),G=window.innerHeight-pn*2,K=g.scrollHeight,j=window.getComputedStyle(c),Y=parseInt(j.borderTopWidth,10),q=parseInt(j.paddingTop,10),z=parseInt(j.borderBottomWidth,10),R=parseInt(j.paddingBottom,10),I=Y+q+K+R+z,U=Math.min(x.offsetHeight*5,I),J=window.getComputedStyle(g),_=parseInt(J.paddingTop,10),P=parseInt(J.paddingBottom,10),D=E.top+E.height/2-pn,$=G-D,ee=x.offsetHeight/2,H=x.offsetTop+ee,L=Y+q+H,Z=I-L;if(L<=D){const Q=F.length>0&&x===F[F.length-1].ref.current;a.style.bottom="0px";const W=c.clientHeight-g.offsetTop-g.offsetHeight,le=Math.max($,ee+(Q?P:0)+W+z),ie=L+le;a.style.height=ie+"px"}else{const Q=F.length>0&&x===F[0].ref.current;a.style.top="0px";const le=Math.max(D,Y+g.offsetTop+(Q?_:0)+ee)+Z;a.style.height=le+"px",g.scrollTop=L-D+g.offsetTop}a.style.margin=`${pn}px 0`,a.style.minHeight=U+"px",a.style.maxHeight=G+"px",r==null||r(),requestAnimationFrame(()=>f.current=!0)}},[m,s.trigger,s.valueNode,a,c,g,x,y,s.dir,r]);yt(()=>S(),[S]);const[k,C]=p.useState();yt(()=>{c&&C(window.getComputedStyle(c).zIndex)},[c]);const T=p.useCallback(E=>{E&&v.current===!0&&(S(),w==null||w(),v.current=!1)},[S,w]);return u.jsx(rE,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:f,onScrollButtonChange:T,children:u.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:k},children:u.jsx(xe.div,{...o,ref:h,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Nm.displayName=tE;var nE="SelectPopperPosition",Rl=p.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=pn,...s}=e,i=ii(n);return u.jsx(aa,{...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)"}})});Rl.displayName=nE;var[rE,Ol]=$r(fr,{}),Dl="SelectViewport",Am=p.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=Xn(Dl,n),i=Ol(Dl,n),a=De(t,s.onViewportChange),l=p.useRef(0);return u.jsxs(u.Fragment,{children:[u.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}),u.jsx(oi.Slot,{scope:n,children:u.jsx(xe.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:ce(o.onScroll,c=>{const d=c.currentTarget,{contentWrapper:h,shouldExpandOnScrollRef:m}=i;if(m!=null&&m.current&&h){const f=Math.abs(l.current-d.scrollTop);if(f>0){const v=window.innerHeight-pn*2,g=parseFloat(h.style.minHeight),x=parseFloat(h.style.height),y=Math.max(g,x);if(y<v){const w=y+f,S=Math.min(v,w),k=w-S;h.style.height=S+"px",h.style.bottom==="0px"&&(d.scrollTop=k>0?k:0,h.style.justifyContent="flex-end")}}}l.current=d.scrollTop})})})]})});Am.displayName=Dl;var jm="SelectGroup",[oE,sE]=$r(jm),iE=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Nt();return u.jsx(oE,{scope:n,id:o,children:u.jsx(xe.div,{role:"group","aria-labelledby":o,...r,ref:t})})});iE.displayName=jm;var Pm="SelectLabel",_m=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=sE(Pm,n);return u.jsx(xe.div,{id:o.id,...r,ref:t})});_m.displayName=Pm;var ai="SelectItem",[aE,Mm]=$r(ai),Rm=p.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=Yn(ai,n),l=Xn(ai,n),c=a.value===r,[d,h]=p.useState(s??""),[m,f]=p.useState(!1),v=De(t,w=>{var S;return(S=l.itemRefCallback)==null?void 0:S.call(l,w,r,o)}),g=Nt(),x=p.useRef("touch"),y=()=>{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 u.jsx(aE,{scope:n,value:r,disabled:o,textId:g,isSelected:c,onItemTextChange:p.useCallback(w=>{h(S=>S||((w==null?void 0:w.textContent)??"").trim())},[]),children:u.jsx(oi.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:u.jsx(xe.div,{role:"option","aria-labelledby":g,"data-highlighted":m?"":void 0,"aria-selected":c&&m,"data-state":c?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:v,onFocus:ce(i.onFocus,()=>f(!0)),onBlur:ce(i.onBlur,()=>f(!1)),onClick:ce(i.onClick,()=>{x.current!=="mouse"&&y()}),onPointerUp:ce(i.onPointerUp,()=>{x.current==="mouse"&&y()}),onPointerDown:ce(i.onPointerDown,w=>{x.current=w.pointerType}),onPointerMove:ce(i.onPointerMove,w=>{var S;x.current=w.pointerType,o?(S=l.onItemLeave)==null||S.call(l):x.current==="mouse"&&w.currentTarget.focus({preventScroll:!0})}),onPointerLeave:ce(i.onPointerLeave,w=>{var S;w.currentTarget===document.activeElement&&((S=l.onItemLeave)==null||S.call(l))}),onKeyDown:ce(i.onKeyDown,w=>{var k;((k=l.searchRef)==null?void 0:k.current)!==""&&w.key===" "||(Kk.includes(w.key)&&y(),w.key===" "&&w.preventDefault())})})})})});Rm.displayName=ai;var jo="SelectItemText",Om=p.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=Yn(jo,n),a=Xn(jo,n),l=Mm(jo,n),c=Xk(jo,n),[d,h]=p.useState(null),m=De(t,y=>h(y),l.onItemTextChange,y=>{var w;return(w=a.itemTextRefCallback)==null?void 0:w.call(a,y,l.value,l.disabled)}),f=d==null?void 0:d.textContent,v=p.useMemo(()=>u.jsx("option",{value:l.value,disabled:l.disabled,children:f},l.value),[l.disabled,l.value,f]),{onNativeOptionAdd:g,onNativeOptionRemove:x}=c;return yt(()=>(g(v),()=>x(v)),[g,x,v]),u.jsxs(u.Fragment,{children:[u.jsx(xe.span,{id:l.textId,...s,ref:m}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?Hr.createPortal(s.children,i.valueNode):null]})});Om.displayName=jo;var Dm="SelectItemIndicator",Lm=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return Mm(Dm,n).isSelected?u.jsx(xe.span,{"aria-hidden":!0,...r,ref:t}):null});Lm.displayName=Dm;var Ll="SelectScrollUpButton",$m=p.forwardRef((e,t)=>{const n=Xn(Ll,e.__scopeSelect),r=Ol(Ll,e.__scopeSelect),[o,s]=p.useState(!1),i=De(t,r.onScrollButtonChange);return yt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const c=l.scrollTop>0;s(c)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?u.jsx(Bm,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});$m.displayName=Ll;var $l="SelectScrollDownButton",Fm=p.forwardRef((e,t)=>{const n=Xn($l,e.__scopeSelect),r=Ol($l,e.__scopeSelect),[o,s]=p.useState(!1),i=De(t,r.onScrollButtonChange);return yt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const c=l.scrollHeight-l.clientHeight,d=Math.ceil(l.scrollTop)<c;s(d)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?u.jsx(Bm,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});Fm.displayName=$l;var Bm=p.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=Xn("SelectScrollButton",n),i=p.useRef(null),a=si(n),l=p.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return p.useEffect(()=>()=>l(),[l]),yt(()=>{var d;const c=a().find(h=>h.ref.current===document.activeElement);(d=c==null?void 0:c.ref.current)==null||d.scrollIntoView({block:"nearest"})},[a]),u.jsx(xe.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:ce(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:ce(o.onPointerMove,()=>{var c;(c=s.onItemLeave)==null||c.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:ce(o.onPointerLeave,()=>{l()})})}),lE="SelectSeparator",zm=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return u.jsx(xe.div,{"aria-hidden":!0,...r,ref:t})});zm.displayName=lE;var Fl="SelectArrow",cE=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=ii(n),s=Yn(Fl,n),i=Xn(Fl,n);return s.open&&i.position==="popper"?u.jsx(la,{...o,...r,ref:t}):null});cE.displayName=Fl;var uE="SelectBubbleInput",Hm=p.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=p.useRef(null),s=De(r,o),i=gm(t);return p.useEffect(()=>{const a=o.current;if(!a)return;const l=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(l,"value").set;if(i!==t&&d){const h=new Event("change",{bubbles:!0});d.call(a,t),a.dispatchEvent(h)}},[i,t]),u.jsx(xe.select,{...n,style:{...xm,...n.style},ref:s,defaultValue:t})});Hm.displayName=uE;function Um(e){return e===""||e===void 0}function Wm(e){const t=ft(e),n=p.useRef(""),r=p.useRef(0),o=p.useCallback(i=>{const a=n.current+i;t(a),function l(c){n.current=c,window.clearTimeout(r.current),c!==""&&(r.current=window.setTimeout(()=>l(""),1e3))}(a)},[t]),s=p.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return p.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function Vm(e,t,n){const o=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=dE(e,Math.max(s,0));o.length===1&&(i=i.filter(c=>c!==n));const l=i.find(c=>c.textValue.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function dE(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var fE=vm,Km=wm,hE=Sm,pE=Cm,mE=Tm,qm=km,gE=Am,Gm=_m,Ym=Rm,xE=Om,vE=Lm,Xm=$m,Jm=Fm,Zm=zm;const bE=fE,wE=hE,Qm=p.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Km,{ref:r,className:oe("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[t,u.jsx(pE,{asChild:!0,children:u.jsx(ue.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));Qm.displayName=Km.displayName;const eg=p.forwardRef(({className:e,...t},n)=>u.jsx(Xm,{ref:n,className:oe("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(ue.ChevronUp,{className:"h-4 w-4"})}));eg.displayName=Xm.displayName;const tg=p.forwardRef(({className:e,...t},n)=>u.jsx(Jm,{ref:n,className:oe("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(ue.ChevronDown,{className:"h-4 w-4"})}));tg.displayName=Jm.displayName;const ng=p.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>u.jsx(mE,{children:u.jsxs(qm,{ref:o,className:oe("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...r,children:[u.jsx(eg,{}),u.jsx(gE,{className:oe("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),u.jsx(tg,{})]})}));ng.displayName=qm.displayName;const yE=p.forwardRef(({className:e,...t},n)=>u.jsx(Gm,{ref:n,className:oe("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));yE.displayName=Gm.displayName;const rg=p.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Ym,{ref:r,className:oe("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[u.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx(vE,{children:u.jsx(ue.Check,{className:"h-4 w-4"})})}),u.jsx(xE,{children:t})]}));rg.displayName=Ym.displayName;const SE=p.forwardRef(({className:e,...t},n)=>u.jsx(Zm,{ref:n,className:oe("-mx-1 my-1 h-px bg-muted",e),...t}));SE.displayName=Zm.displayName;var CE="Separator",og="horizontal",TE=["horizontal","vertical"],sg=p.forwardRef((e,t)=>{const{decorative:n,orientation:r=og,...o}=e,s=kE(r)?r:og,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return u.jsx(xe.div,{"data-orientation":s,...a,...o,ref:t})});sg.displayName=CE;function kE(e){return TE.includes(e)}var ig=sg;const ag=p.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>u.jsx(ig,{ref:o,decorative:n,orientation:t,className:oe("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));ag.displayName=ig.displayName;var li="Switch",[EE,DN]=ln(li),[IE,NE]=EE(li),lg=p.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:s,required:i,disabled:a,value:l="on",onCheckedChange:c,form:d,...h}=e,[m,f]=p.useState(null),v=De(t,S=>f(S)),g=p.useRef(!1),x=m?d||!!m.closest("form"):!0,[y,w]=Dn({prop:o,defaultProp:s??!1,onChange:c,caller:li});return u.jsxs(IE,{scope:n,checked:y,disabled:a,children:[u.jsx(xe.button,{type:"button",role:"switch","aria-checked":y,"aria-required":i,"data-state":fg(y),"data-disabled":a?"":void 0,disabled:a,value:l,...h,ref:v,onClick:ce(e.onClick,S=>{w(k=>!k),x&&(g.current=S.isPropagationStopped(),g.current||S.stopPropagation())})}),x&&u.jsx(dg,{control:m,bubbles:!g.current,name:r,value:l,checked:y,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});lg.displayName=li;var cg="SwitchThumb",ug=p.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=NE(cg,n);return u.jsx(xe.span,{"data-state":fg(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});ug.displayName=cg;var AE="SwitchBubbleInput",dg=p.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=p.useRef(null),a=De(i,s),l=gm(n),c=bd(t);return p.useEffect(()=>{const d=i.current;if(!d)return;const h=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(h,"checked").set;if(l!==n&&f){const v=new Event("click",{bubbles:r});f.call(d,n),d.dispatchEvent(v)}},[l,n,r]),u.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:a,style:{...o.style,...c,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});dg.displayName=AE;function fg(e){return e?"checked":"unchecked"}var hg=lg,jE=ug;const pg=p.forwardRef(({className:e,...t},n)=>u.jsx(hg,{className:oe("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...t,ref:n,children:u.jsx(jE,{className:oe("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));pg.displayName=hg.displayName;const PE=Za,_E=dT,ME=Qa,mg=p.forwardRef(({className:e,...t},n)=>u.jsx(To,{className:oe("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t,ref:n}));mg.displayName=To.displayName;const RE=zr.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"}}),gg=p.forwardRef(({side:e="right",className:t,children:n,...r},o)=>u.jsxs(ME,{children:[u.jsx(mg,{}),u.jsxs(ko,{ref:o,className:oe(RE({side:e}),t),...r,children:[n,u.jsxs(sp,{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:[u.jsx(ue.X,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));gg.displayName=ko.displayName;const xg=({className:e,...t})=>u.jsx("div",{className:oe("flex flex-col space-y-2 text-center sm:text-left",e),...t});xg.displayName="SheetHeader";const vg=p.forwardRef(({className:e,...t},n)=>u.jsx(lr,{ref:n,className:oe("text-lg font-semibold text-foreground",e),...t}));vg.displayName=lr.displayName;const bg=p.forwardRef(({className:e,...t},n)=>u.jsx(Bs,{ref:n,className:oe("text-sm text-muted-foreground",e),...t}));bg.displayName=Bs.displayName;var[ci,LN]=ln("Tooltip",[Er]),ui=Er(),wg="TooltipProvider",OE=700,Bl="tooltip.open",[DE,zl]=ci(wg),yg=e=>{const{__scopeTooltip:t,delayDuration:n=OE,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:s}=e,i=p.useRef(!0),a=p.useRef(!1),l=p.useRef(0);return p.useEffect(()=>{const c=l.current;return()=>window.clearTimeout(c)},[]),u.jsx(DE,{scope:t,isOpenDelayedRef:i,delayDuration:n,onOpen:p.useCallback(()=>{window.clearTimeout(l.current),i.current=!1},[]),onClose:p.useCallback(()=>{window.clearTimeout(l.current),l.current=window.setTimeout(()=>i.current=!0,r)},[r]),isPointerInTransitRef:a,onPointerInTransitChange:p.useCallback(c=>{a.current=c},[]),disableHoverableContent:o,children:s})};yg.displayName=wg;var Po="Tooltip",[LE,di]=ci(Po),Sg=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:s,disableHoverableContent:i,delayDuration:a}=e,l=zl(Po,e.__scopeTooltip),c=ui(t),[d,h]=p.useState(null),m=Nt(),f=p.useRef(0),v=i??l.disableHoverableContent,g=a??l.delayDuration,x=p.useRef(!1),[y,w]=Dn({prop:r,defaultProp:o??!1,onChange:E=>{E?(l.onOpen(),document.dispatchEvent(new CustomEvent(Bl))):l.onClose(),s==null||s(E)},caller:Po}),S=p.useMemo(()=>y?x.current?"delayed-open":"instant-open":"closed",[y]),k=p.useCallback(()=>{window.clearTimeout(f.current),f.current=0,x.current=!1,w(!0)},[w]),C=p.useCallback(()=>{window.clearTimeout(f.current),f.current=0,w(!1)},[w]),T=p.useCallback(()=>{window.clearTimeout(f.current),f.current=window.setTimeout(()=>{x.current=!0,w(!0),f.current=0},g)},[g,w]);return p.useEffect(()=>()=>{f.current&&(window.clearTimeout(f.current),f.current=0)},[]),u.jsx(sa,{...c,children:u.jsx(LE,{scope:t,contentId:m,open:y,stateAttribute:S,trigger:d,onTriggerChange:h,onTriggerEnter:p.useCallback(()=>{l.isOpenDelayedRef.current?T():k()},[l.isOpenDelayedRef,T,k]),onTriggerLeave:p.useCallback(()=>{v?C():(window.clearTimeout(f.current),f.current=0)},[C,v]),onOpen:k,onClose:C,disableHoverableContent:v,children:n})})};Sg.displayName=Po;var Hl="TooltipTrigger",Cg=p.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=di(Hl,n),s=zl(Hl,n),i=ui(n),a=p.useRef(null),l=De(t,a,o.onTriggerChange),c=p.useRef(!1),d=p.useRef(!1),h=p.useCallback(()=>c.current=!1,[]);return p.useEffect(()=>()=>document.removeEventListener("pointerup",h),[h]),u.jsx(ia,{asChild:!0,...i,children:u.jsx(xe.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:l,onPointerMove:ce(e.onPointerMove,m=>{m.pointerType!=="touch"&&!d.current&&!s.isPointerInTransitRef.current&&(o.onTriggerEnter(),d.current=!0)}),onPointerLeave:ce(e.onPointerLeave,()=>{o.onTriggerLeave(),d.current=!1}),onPointerDown:ce(e.onPointerDown,()=>{o.open&&o.onClose(),c.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:ce(e.onFocus,()=>{c.current||o.onOpen()}),onBlur:ce(e.onBlur,o.onClose),onClick:ce(e.onClick,o.onClose)})})});Cg.displayName=Hl;var $E="TooltipPortal",[$N,FE]=ci($E,{forceMount:void 0}),Fr="TooltipContent",Tg=p.forwardRef((e,t)=>{const n=FE(Fr,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...s}=e,i=di(Fr,e.__scopeTooltip);return u.jsx(zt,{present:r||i.open,children:i.disableHoverableContent?u.jsx(kg,{side:o,...s,ref:t}):u.jsx(BE,{side:o,...s,ref:t})})}),BE=p.forwardRef((e,t)=>{const n=di(Fr,e.__scopeTooltip),r=zl(Fr,e.__scopeTooltip),o=p.useRef(null),s=De(t,o),[i,a]=p.useState(null),{trigger:l,onClose:c}=n,d=o.current,{onPointerInTransitChange:h}=r,m=p.useCallback(()=>{a(null),h(!1)},[h]),f=p.useCallback((v,g)=>{const x=v.currentTarget,y={x:v.clientX,y:v.clientY},w=VE(y,x.getBoundingClientRect()),S=KE(y,w),k=qE(g.getBoundingClientRect()),C=YE([...S,...k]);a(C),h(!0)},[h]);return p.useEffect(()=>()=>m(),[m]),p.useEffect(()=>{if(l&&d){const v=x=>f(x,d),g=x=>f(x,l);return l.addEventListener("pointerleave",v),d.addEventListener("pointerleave",g),()=>{l.removeEventListener("pointerleave",v),d.removeEventListener("pointerleave",g)}}},[l,d,f,m]),p.useEffect(()=>{if(i){const v=g=>{const x=g.target,y={x:g.clientX,y:g.clientY},w=(l==null?void 0:l.contains(x))||(d==null?void 0:d.contains(x)),S=!GE(y,i);w?m():S&&(m(),c())};return document.addEventListener("pointermove",v),()=>document.removeEventListener("pointermove",v)}},[l,d,i,c,m]),u.jsx(kg,{...e,ref:s})}),[zE,HE]=ci(Po,{isInside:!1}),UE=Kt.createSlottable("TooltipContent"),kg=p.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:s,onPointerDownOutside:i,...a}=e,l=di(Fr,n),c=ui(n),{onClose:d}=l;return p.useEffect(()=>(document.addEventListener(Bl,d),()=>document.removeEventListener(Bl,d)),[d]),p.useEffect(()=>{if(l.trigger){const h=m=>{const f=m.target;f!=null&&f.contains(l.trigger)&&d()};return window.addEventListener("scroll",h,{capture:!0}),()=>window.removeEventListener("scroll",h,{capture:!0})}},[l.trigger,d]),u.jsx(yr,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:h=>h.preventDefault(),onDismiss:d,children:u.jsxs(aa,{"data-state":l.stateAttribute,...c,...a,ref:t,style:{...a.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[u.jsx(UE,{children:r}),u.jsx(zE,{scope:n,isInside:!0,children:u.jsx(Wk,{id:l.contentId,role:"tooltip",children:o||r})})]})})});Tg.displayName=Fr;var Eg="TooltipArrow",WE=p.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=ui(n);return HE(Eg,n).isInside?null:u.jsx(la,{...o,...r,ref:t})});WE.displayName=Eg;function VE(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),o=Math.abs(t.right-e.x),s=Math.abs(t.left-e.x);switch(Math.min(n,r,o,s)){case s:return"left";case o:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function KE(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function qE(e){const{top:t,right:n,bottom:r,left:o}=e;return[{x:o,y:t},{x:n,y:t},{x:n,y:r},{x:o,y:r}]}function GE(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],c=a.x,d=a.y,h=l.x,m=l.y;d>r!=m>r&&n<(h-c)*(r-d)/(m-d)+c&&(o=!o)}return o}function YE(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),XE(t)}function XE(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const o=e[r];for(;t.length>=2;){const s=t[t.length-1],i=t[t.length-2];if((s.x-i.x)*(o.y-i.y)>=(s.y-i.y)*(o.x-i.x))t.pop();else break}t.push(o)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const o=e[r];for(;n.length>=2;){const s=n[n.length-1],i=n[n.length-2];if((s.x-i.x)*(o.y-i.y)>=(s.y-i.y)*(o.x-i.x))n.pop();else break}n.push(o)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var JE=yg,ZE=Sg,QE=Cg,Ig=Tg;const eI=JE,tI=ZE,nI=QE,Ng=p.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(Ig,{ref:r,sideOffset:t,className:oe("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-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}));Ng.displayName=Ig.displayName;var Ul="ToastProvider",[Wl,rI,oI]=Xo("Toast"),[Ag,FN]=ln("Toast",[oI]),[sI,fi]=Ag(Ul),jg=e=>{const{__scopeToast:t,label:n="Notification",duration:r=5e3,swipeDirection:o="right",swipeThreshold:s=50,children:i}=e,[a,l]=p.useState(null),[c,d]=p.useState(0),h=p.useRef(!1),m=p.useRef(!1);return n.trim()||console.error(`Invalid prop \`label\` supplied to \`${Ul}\`. Expected non-empty \`string\`.`),u.jsx(Wl.Provider,{scope:t,children:u.jsx(sI,{scope:t,label:n,duration:r,swipeDirection:o,swipeThreshold:s,toastCount:c,viewport:a,onViewportChange:l,onToastAdd:p.useCallback(()=>d(f=>f+1),[]),onToastRemove:p.useCallback(()=>d(f=>f-1),[]),isFocusedToastEscapeKeyDownRef:h,isClosePausedRef:m,children:i})})};jg.displayName=Ul;var Pg="ToastViewport",iI=["F8"],Vl="toast.viewportPause",Kl="toast.viewportResume",_g=p.forwardRef((e,t)=>{const{__scopeToast:n,hotkey:r=iI,label:o="Notifications ({hotkey})",...s}=e,i=fi(Pg,n),a=rI(n),l=p.useRef(null),c=p.useRef(null),d=p.useRef(null),h=p.useRef(null),m=De(t,h,i.onViewportChange),f=r.join("+").replace(/Key/g,"").replace(/Digit/g,""),v=i.toastCount>0;p.useEffect(()=>{const x=y=>{var S;r.length!==0&&r.every(k=>y[k]||y.code===k)&&((S=h.current)==null||S.focus())};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[r]),p.useEffect(()=>{const x=l.current,y=h.current;if(v&&x&&y){const w=()=>{if(!i.isClosePausedRef.current){const T=new CustomEvent(Vl);y.dispatchEvent(T),i.isClosePausedRef.current=!0}},S=()=>{if(i.isClosePausedRef.current){const T=new CustomEvent(Kl);y.dispatchEvent(T),i.isClosePausedRef.current=!1}},k=T=>{!x.contains(T.relatedTarget)&&S()},C=()=>{x.contains(document.activeElement)||S()};return x.addEventListener("focusin",w),x.addEventListener("focusout",k),x.addEventListener("pointermove",w),x.addEventListener("pointerleave",C),window.addEventListener("blur",w),window.addEventListener("focus",S),()=>{x.removeEventListener("focusin",w),x.removeEventListener("focusout",k),x.removeEventListener("pointermove",w),x.removeEventListener("pointerleave",C),window.removeEventListener("blur",w),window.removeEventListener("focus",S)}}},[v,i.isClosePausedRef]);const g=p.useCallback(({tabbingDirection:x})=>{const w=a().map(S=>{const k=S.ref.current,C=[k,...bI(k)];return x==="forwards"?C:C.reverse()});return(x==="forwards"?w.reverse():w).flat()},[a]);return p.useEffect(()=>{const x=h.current;if(x){const y=w=>{var C,T,E;const S=w.altKey||w.ctrlKey||w.metaKey;if(w.key==="Tab"&&!S){const N=document.activeElement,M=w.shiftKey;if(w.target===x&&M){(C=c.current)==null||C.focus();return}const G=g({tabbingDirection:M?"backwards":"forwards"}),K=G.findIndex(j=>j===N);Yl(G.slice(K+1))?w.preventDefault():M?(T=c.current)==null||T.focus():(E=d.current)==null||E.focus()}};return x.addEventListener("keydown",y),()=>x.removeEventListener("keydown",y)}},[a,g]),u.jsxs(Fb,{ref:l,role:"region","aria-label":o.replace("{hotkey}",f),tabIndex:-1,style:{pointerEvents:v?void 0:"none"},children:[v&&u.jsx(ql,{ref:c,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"forwards"});Yl(x)}}),u.jsx(Wl.Slot,{scope:n,children:u.jsx(xe.ol,{tabIndex:-1,...s,ref:m})}),v&&u.jsx(ql,{ref:d,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"backwards"});Yl(x)}})]})});_g.displayName=Pg;var Mg="ToastFocusProxy",ql=p.forwardRef((e,t)=>{const{__scopeToast:n,onFocusFromOutsideViewport:r,...o}=e,s=fi(Mg,n);return u.jsx(ri,{tabIndex:0,...o,ref:t,style:{position:"fixed"},onFocus:i=>{var c;const a=i.relatedTarget;!((c=s.viewport)!=null&&c.contains(a))&&r()}})});ql.displayName=Mg;var _o="Toast",aI="toast.swipeStart",lI="toast.swipeMove",cI="toast.swipeCancel",uI="toast.swipeEnd",Rg=p.forwardRef((e,t)=>{const{forceMount:n,open:r,defaultOpen:o,onOpenChange:s,...i}=e,[a,l]=Dn({prop:r,defaultProp:o??!0,onChange:s,caller:_o});return u.jsx(zt,{present:n||a,children:u.jsx(hI,{open:a,...i,ref:t,onClose:()=>l(!1),onPause:ft(e.onPause),onResume:ft(e.onResume),onSwipeStart:ce(e.onSwipeStart,c=>{c.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:ce(e.onSwipeMove,c=>{const{x:d,y:h}=c.detail.delta;c.currentTarget.setAttribute("data-swipe","move"),c.currentTarget.style.setProperty("--radix-toast-swipe-move-x",`${d}px`),c.currentTarget.style.setProperty("--radix-toast-swipe-move-y",`${h}px`)}),onSwipeCancel:ce(e.onSwipeCancel,c=>{c.currentTarget.setAttribute("data-swipe","cancel"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),c.currentTarget.style.removeProperty("--radix-toast-swipe-end-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-end-y")}),onSwipeEnd:ce(e.onSwipeEnd,c=>{const{x:d,y:h}=c.detail.delta;c.currentTarget.setAttribute("data-swipe","end"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),c.currentTarget.style.setProperty("--radix-toast-swipe-end-x",`${d}px`),c.currentTarget.style.setProperty("--radix-toast-swipe-end-y",`${h}px`),l(!1)})})})});Rg.displayName=_o;var[dI,fI]=Ag(_o,{onClose(){}}),hI=p.forwardRef((e,t)=>{const{__scopeToast:n,type:r="foreground",duration:o,open:s,onClose:i,onEscapeKeyDown:a,onPause:l,onResume:c,onSwipeStart:d,onSwipeMove:h,onSwipeCancel:m,onSwipeEnd:f,...v}=e,g=fi(_o,n),[x,y]=p.useState(null),w=De(t,j=>y(j)),S=p.useRef(null),k=p.useRef(null),C=o||g.duration,T=p.useRef(0),E=p.useRef(C),N=p.useRef(0),{onToastAdd:M,onToastRemove:O}=g,F=ft(()=>{var Y;(x==null?void 0:x.contains(document.activeElement))&&((Y=g.viewport)==null||Y.focus()),i()}),G=p.useCallback(j=>{!j||j===1/0||(window.clearTimeout(N.current),T.current=new Date().getTime(),N.current=window.setTimeout(F,j))},[F]);p.useEffect(()=>{const j=g.viewport;if(j){const Y=()=>{G(E.current),c==null||c()},q=()=>{const z=new Date().getTime()-T.current;E.current=E.current-z,window.clearTimeout(N.current),l==null||l()};return j.addEventListener(Vl,q),j.addEventListener(Kl,Y),()=>{j.removeEventListener(Vl,q),j.removeEventListener(Kl,Y)}}},[g.viewport,C,l,c,G]),p.useEffect(()=>{s&&!g.isClosePausedRef.current&&G(C)},[s,C,g.isClosePausedRef,G]),p.useEffect(()=>(M(),()=>O()),[M,O]);const K=p.useMemo(()=>x?zg(x):null,[x]);return g.viewport?u.jsxs(u.Fragment,{children:[K&&u.jsx(pI,{__scopeToast:n,role:"status","aria-live":r==="foreground"?"assertive":"polite",children:K}),u.jsx(dI,{scope:n,onClose:F,children:Hr.createPortal(u.jsx(Wl.ItemSlot,{scope:n,children:u.jsx($b,{asChild:!0,onEscapeKeyDown:ce(a,()=>{g.isFocusedToastEscapeKeyDownRef.current||F(),g.isFocusedToastEscapeKeyDownRef.current=!1}),children:u.jsx(xe.li,{tabIndex:0,"data-state":s?"open":"closed","data-swipe-direction":g.swipeDirection,...v,ref:w,style:{userSelect:"none",touchAction:"none",...e.style},onKeyDown:ce(e.onKeyDown,j=>{j.key==="Escape"&&(a==null||a(j.nativeEvent),j.nativeEvent.defaultPrevented||(g.isFocusedToastEscapeKeyDownRef.current=!0,F()))}),onPointerDown:ce(e.onPointerDown,j=>{j.button===0&&(S.current={x:j.clientX,y:j.clientY})}),onPointerMove:ce(e.onPointerMove,j=>{if(!S.current)return;const Y=j.clientX-S.current.x,q=j.clientY-S.current.y,z=!!k.current,R=["left","right"].includes(g.swipeDirection),I=["left","up"].includes(g.swipeDirection)?Math.min:Math.max,U=R?I(0,Y):0,J=R?0:I(0,q),_=j.pointerType==="touch"?10:2,P={x:U,y:J},D={originalEvent:j,delta:P};z?(k.current=P,hi(lI,h,D,{discrete:!1})):Hg(P,g.swipeDirection,_)?(k.current=P,hi(aI,d,D,{discrete:!1}),j.target.setPointerCapture(j.pointerId)):(Math.abs(Y)>_||Math.abs(q)>_)&&(S.current=null)}),onPointerUp:ce(e.onPointerUp,j=>{const Y=k.current,q=j.target;if(q.hasPointerCapture(j.pointerId)&&q.releasePointerCapture(j.pointerId),k.current=null,S.current=null,Y){const z=j.currentTarget,R={originalEvent:j,delta:Y};Hg(Y,g.swipeDirection,g.swipeThreshold)?hi(uI,f,R,{discrete:!0}):hi(cI,m,R,{discrete:!0}),z.addEventListener("click",I=>I.preventDefault(),{once:!0})}})})})}),g.viewport)})]}):null}),pI=e=>{const{__scopeToast:t,children:n,...r}=e,o=fi(_o,t),[s,i]=p.useState(!1),[a,l]=p.useState(!1);return xI(()=>i(!0)),p.useEffect(()=>{const c=window.setTimeout(()=>l(!0),1e3);return()=>window.clearTimeout(c)},[]),a?null:u.jsx(so,{asChild:!0,children:u.jsx(ri,{...r,children:s&&u.jsxs(u.Fragment,{children:[o.label," ",n]})})})},mI="ToastTitle",Og=p.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(xe.div,{...r,ref:t})});Og.displayName=mI;var gI="ToastDescription",Dg=p.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(xe.div,{...r,ref:t})});Dg.displayName=gI;var Lg="ToastAction",$g=p.forwardRef((e,t)=>{const{altText:n,...r}=e;return n.trim()?u.jsx(Bg,{altText:n,asChild:!0,children:u.jsx(Gl,{...r,ref:t})}):(console.error(`Invalid prop \`altText\` supplied to \`${Lg}\`. Expected non-empty \`string\`.`),null)});$g.displayName=Lg;var Fg="ToastClose",Gl=p.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e,o=fI(Fg,n);return u.jsx(Bg,{asChild:!0,children:u.jsx(xe.button,{type:"button",...r,ref:t,onClick:ce(e.onClick,o.onClose)})})});Gl.displayName=Fg;var Bg=p.forwardRef((e,t)=>{const{__scopeToast:n,altText:r,...o}=e;return u.jsx(xe.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":r||void 0,...o,ref:t})});function zg(e){const t=[];return Array.from(e.childNodes).forEach(r=>{if(r.nodeType===r.TEXT_NODE&&r.textContent&&t.push(r.textContent),vI(r)){const o=r.ariaHidden||r.hidden||r.style.display==="none",s=r.dataset.radixToastAnnounceExclude==="";if(!o)if(s){const i=r.dataset.radixToastAnnounceAlt;i&&t.push(i)}else t.push(...zg(r))}}),t}function hi(e,t,n,{discrete:r}){const o=n.originalEvent.currentTarget,s=new CustomEvent(e,{bubbles:!0,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?Bi(o,s):o.dispatchEvent(s)}var Hg=(e,t,n=0)=>{const r=Math.abs(e.x),o=Math.abs(e.y),s=r>o;return t==="left"||t==="right"?s&&r>n:!s&&o>n};function xI(e=()=>{}){const t=ft(e);yt(()=>{let n=0,r=0;return n=window.requestAnimationFrame(()=>r=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(n),window.cancelAnimationFrame(r)}},[t])}function vI(e){return e.nodeType===e.ELEMENT_NODE}function bI(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 Yl(e){const t=document.activeElement;return e.some(n=>n===t?!0:(n.focus(),document.activeElement!==t))}var wI=jg,Ug=_g,Wg=Rg,Vg=Og,Kg=Dg,qg=$g,Gg=Gl;const yI=wI,Yg=p.forwardRef(({className:e,...t},n)=>u.jsx(Ug,{ref:n,className:oe("fixed bottom-0 right-0 z-[100] flex max-h-screen w-full flex-col p-4 md:max-w-[420px]",e),...t}));Yg.displayName=Ug.displayName;const SI=zr.cva("group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-8 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",{variants:{variant:{default:"border bg-background text-foreground",destructive:"destructive group border-destructive bg-destructive text-destructive-foreground"}},defaultVariants:{variant:"default"}}),Xg=p.forwardRef(({className:e,variant:t,...n},r)=>u.jsx(Wg,{ref:r,className:oe(SI({variant:t}),e),...n}));Xg.displayName=Wg.displayName;const CI=p.forwardRef(({className:e,...t},n)=>u.jsx(qg,{ref:n,className:oe("inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors hover:bg-secondary focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive",e),...t}));CI.displayName=qg.displayName;const Jg=p.forwardRef(({className:e,...t},n)=>u.jsx(Gg,{ref:n,className:oe("absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-2 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",e),"toast-close":"",...t,children:u.jsx(ue.X,{className:"h-4 w-4"})}));Jg.displayName=Gg.displayName;const Zg=p.forwardRef(({className:e,...t},n)=>u.jsx(Vg,{ref:n,className:oe("text-sm font-semibold",e),...t}));Zg.displayName=Vg.displayName;const Qg=p.forwardRef(({className:e,...t},n)=>u.jsx(Kg,{ref:n,className:oe("text-sm opacity-90",e),...t}));Qg.displayName=Kg.displayName;function TI(){const{toasts:e}=rl();return u.jsxs(yI,{children:[e.map(function({id:t,title:n,description:r,action:o,...s}){return u.jsxs(Xg,{...s,children:[u.jsxs("div",{className:"grid gap-1",children:[n&&u.jsx(Zg,{children:n}),r&&u.jsx(Qg,{children:r})]}),o,u.jsx(Jg,{})]},t)}),u.jsx(Yg,{})]})}var kI=(e,t,n,r,o,s,i,a)=>{let l=document.documentElement,c=["light","dark"];function d(f){(Array.isArray(e)?e:[e]).forEach(v=>{let g=v==="class",x=g&&s?o.map(y=>s[y]||y):o;g?(l.classList.remove(...x),l.classList.add(s&&s[f]?s[f]:f)):l.setAttribute(v,f)}),h(f)}function h(f){a&&c.includes(f)&&(l.style.colorScheme=f)}function m(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}if(r)d(r);else try{let f=localStorage.getItem(t)||n,v=i&&f==="system"?m():f;d(v)}catch{}},EI=p.createContext(void 0),II={setTheme:e=>{},themes:[]},NI=()=>{var e;return(e=p.useContext(EI))!=null?e:II};p.memo(({forcedTheme:e,storageKey:t,attribute:n,enableSystem:r,enableColorScheme:o,defaultTheme:s,value:i,themes:a,nonce:l,scriptProps:c})=>{let d=JSON.stringify([n,t,s,e,a,i,r,o]).slice(1,-1);return p.createElement("script",{...c,suppressHydrationWarning:!0,nonce:typeof window>"u"?l:"",dangerouslySetInnerHTML:{__html:`(${kI.toString()})(${d})`}})});var AI=e=>{switch(e){case"success":return _I;case"info":return RI;case"warning":return MI;case"error":return OI;default:return null}},jI=Array(12).fill(0),PI=({visible:e,className:t})=>b.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},b.createElement("div",{className:"sonner-spinner"},jI.map((n,r)=>b.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),_I=b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},b.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),MI=b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},b.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),RI=b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},b.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),OI=b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},b.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),DI=b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},b.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),b.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),LI=()=>{let[e,t]=b.useState(document.hidden);return b.useEffect(()=>{let n=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),e},Xl=1,$I=class{constructor(){this.subscribe=e=>(this.subscribers.push(e),()=>{let t=this.subscribers.indexOf(e);this.subscribers.splice(t,1)}),this.publish=e=>{this.subscribers.forEach(t=>t(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e]},this.create=e=>{var t;let{message:n,...r}=e,o=typeof(e==null?void 0:e.id)=="number"||((t=e.id)==null?void 0:t.length)>0?e.id:Xl++,s=this.toasts.find(a=>a.id===o),i=e.dismissible===void 0?!0:e.dismissible;return this.dismissedToasts.has(o)&&this.dismissedToasts.delete(o),s?this.toasts=this.toasts.map(a=>a.id===o?(this.publish({...a,...e,id:o,title:n}),{...a,...e,id:o,dismissible:i,title:n}):a):this.addToast({title:n,...r,dismissible:i,id:o}),o},this.dismiss=e=>(this.dismissedToasts.add(e),e||this.toasts.forEach(t=>{this.subscribers.forEach(n=>n({id:t.id,dismiss:!0}))}),this.subscribers.forEach(t=>t({id:e,dismiss:!0})),e),this.message=(e,t)=>this.create({...t,message:e}),this.error=(e,t)=>this.create({...t,message:e,type:"error"}),this.success=(e,t)=>this.create({...t,type:"success",message:e}),this.info=(e,t)=>this.create({...t,type:"info",message:e}),this.warning=(e,t)=>this.create({...t,type:"warning",message:e}),this.loading=(e,t)=>this.create({...t,type:"loading",message:e}),this.promise=(e,t)=>{if(!t)return;let n;t.loading!==void 0&&(n=this.create({...t,promise:e,type:"loading",message:t.loading,description:typeof t.description!="function"?t.description:void 0}));let r=e instanceof Promise?e:e(),o=n!==void 0,s,i=r.then(async l=>{if(s=["resolve",l],b.isValidElement(l))o=!1,this.create({id:n,type:"default",message:l});else if(BI(l)&&!l.ok){o=!1;let c=typeof t.error=="function"?await t.error(`HTTP error! status: ${l.status}`):t.error,d=typeof t.description=="function"?await t.description(`HTTP error! status: ${l.status}`):t.description;this.create({id:n,type:"error",message:c,description:d})}else if(t.success!==void 0){o=!1;let c=typeof t.success=="function"?await t.success(l):t.success,d=typeof t.description=="function"?await t.description(l):t.description;this.create({id:n,type:"success",message:c,description:d})}}).catch(async l=>{if(s=["reject",l],t.error!==void 0){o=!1;let c=typeof t.error=="function"?await t.error(l):t.error,d=typeof t.description=="function"?await t.description(l):t.description;this.create({id:n,type:"error",message:c,description:d})}}).finally(()=>{var l;o&&(this.dismiss(n),n=void 0),(l=t.finally)==null||l.call(t)}),a=()=>new Promise((l,c)=>i.then(()=>s[0]==="reject"?c(s[1]):l(s[1])).catch(c));return typeof n!="string"&&typeof n!="number"?{unwrap:a}:Object.assign(n,{unwrap:a})},this.custom=(e,t)=>{let n=(t==null?void 0:t.id)||Xl++;return this.create({jsx:e(n),id:n,...t}),n},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},Wt=new $I,FI=(e,t)=>{let n=(t==null?void 0:t.id)||Xl++;return Wt.addToast({title:e,...t,id:n}),n},BI=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",zI=FI,HI=()=>Wt.toasts,UI=()=>Wt.getActiveToasts();Object.assign(zI,{success:Wt.success,info:Wt.info,warning:Wt.warning,error:Wt.error,custom:Wt.custom,message:Wt.message,promise:Wt.promise,dismiss:Wt.dismiss,loading:Wt.loading},{getHistory:HI,getToasts:UI});function WI(e,{insertAt:t}={}){if(typeof document>"u")return;let n=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",t==="top"&&n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r),r.styleSheet?r.styleSheet.cssText=e:r.appendChild(document.createTextNode(e))}WI(`:where(html[dir="ltr"]),:where([data-sonner-toaster][dir="ltr"]){--toast-icon-margin-start: -3px;--toast-icon-margin-end: 4px;--toast-svg-margin-start: -1px;--toast-svg-margin-end: 0px;--toast-button-margin-start: auto;--toast-button-margin-end: 0;--toast-close-button-start: 0;--toast-close-button-end: unset;--toast-close-button-transform: translate(-35%, -35%)}:where(html[dir="rtl"]),:where([data-sonner-toaster][dir="rtl"]){--toast-icon-margin-start: 4px;--toast-icon-margin-end: -3px;--toast-svg-margin-start: 0px;--toast-svg-margin-end: -1px;--toast-button-margin-start: 0;--toast-button-margin-end: auto;--toast-close-button-start: unset;--toast-close-button-end: 0;--toast-close-button-transform: translate(35%, -35%)}:where([data-sonner-toaster]){position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1: hsl(0, 0%, 99%);--gray2: hsl(0, 0%, 97.3%);--gray3: hsl(0, 0%, 95.1%);--gray4: hsl(0, 0%, 93%);--gray5: hsl(0, 0%, 90.9%);--gray6: hsl(0, 0%, 88.7%);--gray7: hsl(0, 0%, 85.8%);--gray8: hsl(0, 0%, 78%);--gray9: hsl(0, 0%, 56.1%);--gray10: hsl(0, 0%, 52.3%);--gray11: hsl(0, 0%, 43.5%);--gray12: hsl(0, 0%, 9%);--border-radius: 8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:none;z-index:999999999;transition:transform .4s ease}:where([data-sonner-toaster][data-lifted="true"]){transform:translateY(-10px)}@media (hover: none) and (pointer: coarse){:where([data-sonner-toaster][data-lifted="true"]){transform:none}}:where([data-sonner-toaster][data-x-position="right"]){right:var(--offset-right)}:where([data-sonner-toaster][data-x-position="left"]){left:var(--offset-left)}:where([data-sonner-toaster][data-x-position="center"]){left:50%;transform:translate(-50%)}:where([data-sonner-toaster][data-y-position="top"]){top:var(--offset-top)}:where([data-sonner-toaster][data-y-position="bottom"]){bottom:var(--offset-bottom)}:where([data-sonner-toast]){--y: translateY(100%);--lift-amount: calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);filter:blur(0);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:none;overflow-wrap:anywhere}:where([data-sonner-toast][data-styled="true"]){padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px #0000001a;width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}:where([data-sonner-toast]:focus-visible){box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast][data-y-position="top"]){top:0;--y: translateY(-100%);--lift: 1;--lift-amount: calc(1 * var(--gap))}:where([data-sonner-toast][data-y-position="bottom"]){bottom:0;--y: translateY(100%);--lift: -1;--lift-amount: calc(var(--lift) * var(--gap))}:where([data-sonner-toast]) :where([data-description]){font-weight:400;line-height:1.4;color:inherit}:where([data-sonner-toast]) :where([data-title]){font-weight:500;line-height:1.5;color:inherit}:where([data-sonner-toast]) :where([data-icon]){display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}:where([data-sonner-toast][data-promise="true"]) :where([data-icon])>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}:where([data-sonner-toast]) :where([data-icon])>*{flex-shrink:0}:where([data-sonner-toast]) :where([data-icon]) svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}:where([data-sonner-toast]) :where([data-content]){display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;cursor:pointer;outline:none;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}:where([data-sonner-toast]) :where([data-button]):focus-visible{box-shadow:0 0 0 2px #0006}:where([data-sonner-toast]) :where([data-button]):first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}:where([data-sonner-toast]) :where([data-cancel]){color:var(--normal-text);background:rgba(0,0,0,.08)}:where([data-sonner-toast][data-theme="dark"]) :where([data-cancel]){background:rgba(255,255,255,.3)}:where([data-sonner-toast]) :where([data-close-button]){position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast] [data-close-button]{background:var(--gray1)}:where([data-sonner-toast]) :where([data-close-button]):focus-visible{box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast]) :where([data-disabled="true"]){cursor:not-allowed}:where([data-sonner-toast]):hover :where([data-close-button]):hover{background:var(--gray2);border-color:var(--gray5)}:where([data-sonner-toast][data-swiping="true"]):before{content:"";position:absolute;left:-50%;right:-50%;height:100%;z-index:-1}:where([data-sonner-toast][data-y-position="top"][data-swiping="true"]):before{bottom:50%;transform:scaleY(3) translateY(50%)}:where([data-sonner-toast][data-y-position="bottom"][data-swiping="true"]):before{top:50%;transform:scaleY(3) translateY(-50%)}:where([data-sonner-toast][data-swiping="false"][data-removed="true"]):before{content:"";position:absolute;inset:0;transform:scaleY(2)}:where([data-sonner-toast]):after{content:"";position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}:where([data-sonner-toast][data-mounted="true"]){--y: translateY(0);opacity:1}:where([data-sonner-toast][data-expanded="false"][data-front="false"]){--scale: var(--toasts-before) * .05 + 1;--y: translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}:where([data-sonner-toast])>*{transition:opacity .4s}:where([data-sonner-toast][data-expanded="false"][data-front="false"][data-styled="true"])>*{opacity:0}:where([data-sonner-toast][data-visible="false"]){opacity:0;pointer-events:none}:where([data-sonner-toast][data-mounted="true"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}:where([data-sonner-toast][data-removed="true"][data-front="true"][data-swipe-out="false"]){--y: translateY(calc(var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="false"]){--y: translateY(40%);opacity:0;transition:transform .5s,opacity .2s}:where([data-sonner-toast][data-removed="true"][data-front="false"]):before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y, 0px)) translate(var(--swipe-amount-x, 0px));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width: 600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-theme=light]{--normal-bg: #fff;--normal-border: var(--gray4);--normal-text: var(--gray12);--success-bg: hsl(143, 85%, 96%);--success-border: hsl(145, 92%, 91%);--success-text: hsl(140, 100%, 27%);--info-bg: hsl(208, 100%, 97%);--info-border: hsl(221, 91%, 91%);--info-text: hsl(210, 92%, 45%);--warning-bg: hsl(49, 100%, 97%);--warning-border: hsl(49, 91%, 91%);--warning-text: hsl(31, 92%, 45%);--error-bg: hsl(359, 100%, 97%);--error-border: hsl(359, 100%, 94%);--error-text: hsl(360, 100%, 45%)}[data-sonner-toaster][data-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg: #000;--normal-border: hsl(0, 0%, 20%);--normal-text: var(--gray1)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg: #fff;--normal-border: var(--gray3);--normal-text: var(--gray12)}[data-sonner-toaster][data-theme=dark]{--normal-bg: #000;--normal-bg-hover: hsl(0, 0%, 12%);--normal-border: hsl(0, 0%, 20%);--normal-border-hover: hsl(0, 0%, 25%);--normal-text: var(--gray1);--success-bg: hsl(150, 100%, 6%);--success-border: hsl(147, 100%, 12%);--success-text: hsl(150, 86%, 65%);--info-bg: hsl(215, 100%, 6%);--info-border: hsl(223, 100%, 12%);--info-text: hsl(216, 87%, 65%);--warning-bg: hsl(64, 100%, 6%);--warning-border: hsl(60, 100%, 12%);--warning-text: hsl(46, 87%, 65%);--error-bg: hsl(358, 76%, 10%);--error-border: hsl(357, 89%, 16%);--error-text: hsl(358, 100%, 81%)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success],[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info],[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning],[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error],[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size: 16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:nth-child(1){animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}to{opacity:.15}}@media (prefers-reduced-motion){[data-sonner-toast],[data-sonner-toast]>*,.sonner-loading-bar{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}
|
|
130
|
-
`);function pi(e){return e.label!==void 0}var VI=3,KI="32px",qI="16px",ex=4e3,GI=356,YI=14,XI=20,JI=200;function mn(...e){return e.filter(Boolean).join(" ")}function ZI(e){let[t,n]=e.split("-"),r=[];return t&&r.push(t),n&&r.push(n),r}var QI=e=>{var t,n,r,o,s,i,a,l,c,d,h;let{invert:m,toast:f,unstyled:v,interacting:g,setHeights:x,visibleToasts:y,heights:w,index:S,toasts:k,expanded:C,removeToast:T,defaultRichColors:E,closeButton:N,style:M,cancelButtonStyle:O,actionButtonStyle:F,className:G="",descriptionClassName:K="",duration:j,position:Y,gap:q,loadingIcon:z,expandByDefault:R,classNames:I,icons:U,closeButtonAriaLabel:J="Close toast",pauseWhenPageIsHidden:_}=e,[P,D]=b.useState(null),[$,ee]=b.useState(null),[H,L]=b.useState(!1),[Z,te]=b.useState(!1),[Q,W]=b.useState(!1),[le,ie]=b.useState(!1),[ge,we]=b.useState(!1),[Ce,Ae]=b.useState(0),[Ee,st]=b.useState(0),lt=b.useRef(f.duration||j||ex),St=b.useRef(null),Oe=b.useRef(null),qe=S===0,We=S+1<=y,je=f.type,_e=f.dismissible!==!1,ct=f.className||"",kt=f.descriptionClassName||"",nt=b.useMemo(()=>w.findIndex(ae=>ae.toastId===f.id)||0,[w,f.id]),Et=b.useMemo(()=>{var ae;return(ae=f.closeButton)!=null?ae:N},[f.closeButton,N]),bt=b.useMemo(()=>f.duration||j||ex,[f.duration,j]),wt=b.useRef(0),Ct=b.useRef(0),on=b.useRef(0),Tt=b.useRef(null),[Lt,_t]=Y.split("-"),$e=b.useMemo(()=>w.reduce((ae,me,Se)=>Se>=nt?ae:ae+me.height,0),[w,nt]),ze=LI(),Mt=f.invert||m,X=je==="loading";Ct.current=b.useMemo(()=>nt*q+$e,[nt,$e]),b.useEffect(()=>{lt.current=bt},[bt]),b.useEffect(()=>{L(!0)},[]),b.useEffect(()=>{let ae=Oe.current;if(ae){let me=ae.getBoundingClientRect().height;return st(me),x(Se=>[{toastId:f.id,height:me,position:f.position},...Se]),()=>x(Se=>Se.filter(Ve=>Ve.toastId!==f.id))}},[x,f.id]),b.useLayoutEffect(()=>{if(!H)return;let ae=Oe.current,me=ae.style.height;ae.style.height="auto";let Se=ae.getBoundingClientRect().height;ae.style.height=me,st(Se),x(Ve=>Ve.find(it=>it.toastId===f.id)?Ve.map(it=>it.toastId===f.id?{...it,height:Se}:it):[{toastId:f.id,height:Se,position:f.position},...Ve])},[H,f.title,f.description,x,f.id]);let fe=b.useCallback(()=>{te(!0),Ae(Ct.current),x(ae=>ae.filter(me=>me.toastId!==f.id)),setTimeout(()=>{T(f)},JI)},[f,T,x,Ct]);b.useEffect(()=>{if(f.promise&&je==="loading"||f.duration===1/0||f.type==="loading")return;let ae;return C||g||_&&ze?(()=>{if(on.current<wt.current){let me=new Date().getTime()-wt.current;lt.current=lt.current-me}on.current=new Date().getTime()})():lt.current!==1/0&&(wt.current=new Date().getTime(),ae=setTimeout(()=>{var me;(me=f.onAutoClose)==null||me.call(f,f),fe()},lt.current)),()=>clearTimeout(ae)},[C,g,f,je,_,ze,fe]),b.useEffect(()=>{f.delete&&fe()},[fe,f.delete]);function He(){var ae,me,Se;return U!=null&&U.loading?b.createElement("div",{className:mn(I==null?void 0:I.loader,(ae=f==null?void 0:f.classNames)==null?void 0:ae.loader,"sonner-loader"),"data-visible":je==="loading"},U.loading):z?b.createElement("div",{className:mn(I==null?void 0:I.loader,(me=f==null?void 0:f.classNames)==null?void 0:me.loader,"sonner-loader"),"data-visible":je==="loading"},z):b.createElement(PI,{className:mn(I==null?void 0:I.loader,(Se=f==null?void 0:f.classNames)==null?void 0:Se.loader),visible:je==="loading"})}return b.createElement("li",{tabIndex:0,ref:Oe,className:mn(G,ct,I==null?void 0:I.toast,(t=f==null?void 0:f.classNames)==null?void 0:t.toast,I==null?void 0:I.default,I==null?void 0:I[je],(n=f==null?void 0:f.classNames)==null?void 0:n[je]),"data-sonner-toast":"","data-rich-colors":(r=f.richColors)!=null?r:E,"data-styled":!(f.jsx||f.unstyled||v),"data-mounted":H,"data-promise":!!f.promise,"data-swiped":ge,"data-removed":Z,"data-visible":We,"data-y-position":Lt,"data-x-position":_t,"data-index":S,"data-front":qe,"data-swiping":Q,"data-dismissible":_e,"data-type":je,"data-invert":Mt,"data-swipe-out":le,"data-swipe-direction":$,"data-expanded":!!(C||R&&H),style:{"--index":S,"--toasts-before":S,"--z-index":k.length-S,"--offset":`${Z?Ce:Ct.current}px`,"--initial-height":R?"auto":`${Ee}px`,...M,...f.style},onDragEnd:()=>{W(!1),D(null),Tt.current=null},onPointerDown:ae=>{X||!_e||(St.current=new Date,Ae(Ct.current),ae.target.setPointerCapture(ae.pointerId),ae.target.tagName!=="BUTTON"&&(W(!0),Tt.current={x:ae.clientX,y:ae.clientY}))},onPointerUp:()=>{var ae,me,Se,Ve;if(le||!_e)return;Tt.current=null;let it=Number(((ae=Oe.current)==null?void 0:ae.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),et=Number(((me=Oe.current)==null?void 0:me.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),Qt=new Date().getTime()-((Se=St.current)==null?void 0:Se.getTime()),Re=P==="x"?it:et,pt=Math.abs(Re)/Qt;if(Math.abs(Re)>=XI||pt>.11){Ae(Ct.current),(Ve=f.onDismiss)==null||Ve.call(f,f),ee(P==="x"?it>0?"right":"left":et>0?"down":"up"),fe(),ie(!0),we(!1);return}W(!1),D(null)},onPointerMove:ae=>{var me,Se,Ve,it;if(!Tt.current||!_e||((me=window.getSelection())==null?void 0:me.toString().length)>0)return;let et=ae.clientY-Tt.current.y,Qt=ae.clientX-Tt.current.x,Re=(Se=e.swipeDirections)!=null?Se:ZI(Y);!P&&(Math.abs(Qt)>1||Math.abs(et)>1)&&D(Math.abs(Qt)>Math.abs(et)?"x":"y");let pt={x:0,y:0};P==="y"?(Re.includes("top")||Re.includes("bottom"))&&(Re.includes("top")&&et<0||Re.includes("bottom")&&et>0)&&(pt.y=et):P==="x"&&(Re.includes("left")||Re.includes("right"))&&(Re.includes("left")&&Qt<0||Re.includes("right")&&Qt>0)&&(pt.x=Qt),(Math.abs(pt.x)>0||Math.abs(pt.y)>0)&&we(!0),(Ve=Oe.current)==null||Ve.style.setProperty("--swipe-amount-x",`${pt.x}px`),(it=Oe.current)==null||it.style.setProperty("--swipe-amount-y",`${pt.y}px`)}},Et&&!f.jsx?b.createElement("button",{"aria-label":J,"data-disabled":X,"data-close-button":!0,onClick:X||!_e?()=>{}:()=>{var ae;fe(),(ae=f.onDismiss)==null||ae.call(f,f)},className:mn(I==null?void 0:I.closeButton,(o=f==null?void 0:f.classNames)==null?void 0:o.closeButton)},(s=U==null?void 0:U.close)!=null?s:DI):null,f.jsx||b.isValidElement(f.title)?f.jsx?f.jsx:typeof f.title=="function"?f.title():f.title:b.createElement(b.Fragment,null,je||f.icon||f.promise?b.createElement("div",{"data-icon":"",className:mn(I==null?void 0:I.icon,(i=f==null?void 0:f.classNames)==null?void 0:i.icon)},f.promise||f.type==="loading"&&!f.icon?f.icon||He():null,f.type!=="loading"?f.icon||(U==null?void 0:U[je])||AI(je):null):null,b.createElement("div",{"data-content":"",className:mn(I==null?void 0:I.content,(a=f==null?void 0:f.classNames)==null?void 0:a.content)},b.createElement("div",{"data-title":"",className:mn(I==null?void 0:I.title,(l=f==null?void 0:f.classNames)==null?void 0:l.title)},typeof f.title=="function"?f.title():f.title),f.description?b.createElement("div",{"data-description":"",className:mn(K,kt,I==null?void 0:I.description,(c=f==null?void 0:f.classNames)==null?void 0:c.description)},typeof f.description=="function"?f.description():f.description):null),b.isValidElement(f.cancel)?f.cancel:f.cancel&&pi(f.cancel)?b.createElement("button",{"data-button":!0,"data-cancel":!0,style:f.cancelButtonStyle||O,onClick:ae=>{var me,Se;pi(f.cancel)&&_e&&((Se=(me=f.cancel).onClick)==null||Se.call(me,ae),fe())},className:mn(I==null?void 0:I.cancelButton,(d=f==null?void 0:f.classNames)==null?void 0:d.cancelButton)},f.cancel.label):null,b.isValidElement(f.action)?f.action:f.action&&pi(f.action)?b.createElement("button",{"data-button":!0,"data-action":!0,style:f.actionButtonStyle||F,onClick:ae=>{var me,Se;pi(f.action)&&((Se=(me=f.action).onClick)==null||Se.call(me,ae),!ae.defaultPrevented&&fe())},className:mn(I==null?void 0:I.actionButton,(h=f==null?void 0:f.classNames)==null?void 0:h.actionButton)},f.action.label):null))};function tx(){if(typeof window>"u"||typeof document>"u")return"ltr";let e=document.documentElement.getAttribute("dir");return e==="auto"||!e?window.getComputedStyle(document.documentElement).direction:e}function eN(e,t){let n={};return[e,t].forEach((r,o)=>{let s=o===1,i=s?"--mobile-offset":"--offset",a=s?qI:KI;function l(c){["top","right","bottom","left"].forEach(d=>{n[`${i}-${d}`]=typeof c=="number"?`${c}px`:c})}typeof r=="number"||typeof r=="string"?l(r):typeof r=="object"?["top","right","bottom","left"].forEach(c=>{r[c]===void 0?n[`${i}-${c}`]=a:n[`${i}-${c}`]=typeof r[c]=="number"?`${r[c]}px`:r[c]}):l(a)}),n}var tN=b.forwardRef(function(e,t){let{invert:n,position:r="bottom-right",hotkey:o=["altKey","KeyT"],expand:s,closeButton:i,className:a,offset:l,mobileOffset:c,theme:d="light",richColors:h,duration:m,style:f,visibleToasts:v=VI,toastOptions:g,dir:x=tx(),gap:y=YI,loadingIcon:w,icons:S,containerAriaLabel:k="Notifications",pauseWhenPageIsHidden:C}=e,[T,E]=b.useState([]),N=b.useMemo(()=>Array.from(new Set([r].concat(T.filter(_=>_.position).map(_=>_.position)))),[T,r]),[M,O]=b.useState([]),[F,G]=b.useState(!1),[K,j]=b.useState(!1),[Y,q]=b.useState(d!=="system"?d:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),z=b.useRef(null),R=o.join("+").replace(/Key/g,"").replace(/Digit/g,""),I=b.useRef(null),U=b.useRef(!1),J=b.useCallback(_=>{E(P=>{var D;return(D=P.find($=>$.id===_.id))!=null&&D.delete||Wt.dismiss(_.id),P.filter(({id:$})=>$!==_.id)})},[]);return b.useEffect(()=>Wt.subscribe(_=>{if(_.dismiss){E(P=>P.map(D=>D.id===_.id?{...D,delete:!0}:D));return}setTimeout(()=>{Mo.flushSync(()=>{E(P=>{let D=P.findIndex($=>$.id===_.id);return D!==-1?[...P.slice(0,D),{...P[D],..._},...P.slice(D+1)]:[_,...P]})})})}),[]),b.useEffect(()=>{if(d!=="system"){q(d);return}if(d==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?q("dark"):q("light")),typeof window>"u")return;let _=window.matchMedia("(prefers-color-scheme: dark)");try{_.addEventListener("change",({matches:P})=>{q(P?"dark":"light")})}catch{_.addListener(({matches:D})=>{try{q(D?"dark":"light")}catch($){console.error($)}})}},[d]),b.useEffect(()=>{T.length<=1&&G(!1)},[T]),b.useEffect(()=>{let _=P=>{var D,$;o.every(ee=>P[ee]||P.code===ee)&&(G(!0),(D=z.current)==null||D.focus()),P.code==="Escape"&&(document.activeElement===z.current||($=z.current)!=null&&$.contains(document.activeElement))&&G(!1)};return document.addEventListener("keydown",_),()=>document.removeEventListener("keydown",_)},[o]),b.useEffect(()=>{if(z.current)return()=>{I.current&&(I.current.focus({preventScroll:!0}),I.current=null,U.current=!1)}},[z.current]),b.createElement("section",{ref:t,"aria-label":`${k} ${R}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},N.map((_,P)=>{var D;let[$,ee]=_.split("-");return T.length?b.createElement("ol",{key:_,dir:x==="auto"?tx():x,tabIndex:-1,ref:z,className:a,"data-sonner-toaster":!0,"data-theme":Y,"data-y-position":$,"data-lifted":F&&T.length>1&&!s,"data-x-position":ee,style:{"--front-toast-height":`${((D=M[0])==null?void 0:D.height)||0}px`,"--width":`${GI}px`,"--gap":`${y}px`,...f,...eN(l,c)},onBlur:H=>{U.current&&!H.currentTarget.contains(H.relatedTarget)&&(U.current=!1,I.current&&(I.current.focus({preventScroll:!0}),I.current=null))},onFocus:H=>{H.target instanceof HTMLElement&&H.target.dataset.dismissible==="false"||U.current||(U.current=!0,I.current=H.relatedTarget)},onMouseEnter:()=>G(!0),onMouseMove:()=>G(!0),onMouseLeave:()=>{K||G(!1)},onDragEnd:()=>G(!1),onPointerDown:H=>{H.target instanceof HTMLElement&&H.target.dataset.dismissible==="false"||j(!0)},onPointerUp:()=>j(!1)},T.filter(H=>!H.position&&P===0||H.position===_).map((H,L)=>{var Z,te;return b.createElement(QI,{key:H.id,icons:S,index:L,toast:H,defaultRichColors:h,duration:(Z=g==null?void 0:g.duration)!=null?Z:m,className:g==null?void 0:g.className,descriptionClassName:g==null?void 0:g.descriptionClassName,invert:n,visibleToasts:v,closeButton:(te=g==null?void 0:g.closeButton)!=null?te:i,interacting:K,position:_,style:g==null?void 0:g.style,unstyled:g==null?void 0:g.unstyled,classNames:g==null?void 0:g.classNames,cancelButtonStyle:g==null?void 0:g.cancelButtonStyle,actionButtonStyle:g==null?void 0:g.actionButtonStyle,removeToast:J,toasts:T.filter(Q=>Q.position==H.position),heights:M.filter(Q=>Q.position==H.position),setHeights:O,expandByDefault:s,gap:y,loadingIcon:w,expanded:F,pauseWhenPageIsHidden:C,swipeDirections:e.swipeDirections})})):null}))});const nN=({...e})=>{const{theme:t="system"}=NI();return u.jsx(tN,{theme:t,className:"toaster group",toastOptions:{classNames:{toast:"group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",description:"group-[.toast]:text-muted-foreground",actionButton:"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",cancelButton:"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground"}},...e})};B.Api=Hv,B.ApiClient=zv,B.ApiProvider=nu,B.ArtifactRenderer=kp,B.Badge=Op,B.Button=Xe,B.Card=il,B.CardContent=ul,B.CardDescription=cl,B.CardHeader=al,B.CardTitle=ll,B.ChatApi=qo,B.ChatApp=Dk,B.ChatInput=Uf,B.ChatInputRow=Wf,B.ChatInterface=Rr,B.ChatProviders=br,B.ChatWidget=Fk,B.Command=yl,B.CommandEmpty=Tl,B.CommandGroup=kl,B.CommandInput=Sl,B.CommandItem=El,B.CommandList=Cl,B.DEFAULT_TIMEOUT_MS=Xc,B.Dialog=el,B.DialogContent=zs,B.DialogHeader=Hs,B.DialogTitle=Us,B.DropdownMenu=Cs,B.DropdownMenuContent=ho,B.DropdownMenuItem=Bn,B.DropdownMenuTrigger=Ts,B.FileViewerModal=lp,B.HISTORY_TIMEOUT_MS=Jc,B.Input=Ml,B.InterruptPartRenderer=Ip,B.Label=mm,B.MarkdownContent=qn,B.MessageComponent=Xs,B.MessageList=pl,B.MessageRow=hl,B.NewChatButton=Bk,B.PlotArtifact=Sp,B.ResearchTaskArtifact=Tp,B.SETTINGS_STORAGE_KEY=Fi,B.ScrollArea=_l,B.Select=bE,B.SelectContent=ng,B.SelectItem=rg,B.SelectTrigger=Qm,B.SelectValue=wE,B.Separator=ag,B.Sheet=PE,B.SheetContent=gg,B.SheetDescription=bg,B.SheetHeader=xg,B.SheetTitle=vg,B.SheetTrigger=_E,B.SimpleChat=Lk,B.SimpleJsonView=dl,B.Sonner=nN,B.StreamProgress=Np,B.Switch=pg,B.Textarea=ka,B.ThinkingIndicator=Ap,B.ThreadListItem=cm,B.ThreadManager=ni,B.ThreadStateProvider=ku,B.ThreadsProvider=hu,B.TimelineColumn=vx,B.Toaster=TI,B.ToolComponent=Pp,B.Tooltip=tI,B.TooltipContent=Ng,B.TooltipProvider=eI,B.TooltipTrigger=nI,B.UserTextContent=jp,B.applySettings=Sb,B.buildCheckpointIndex=ec,B.buildCheckpointPreviewMap=ax,B.chatApiClient=Nn,B.del=ji,B.downloadFileById=Qc,B.extractConfigFields=gi,B.fileToBase64=ru,B.get=Gt,B.getChatToken=Gc,B.getCheckpointForMessage=lx,B.getCurrentSettings=yb,B.getDefaultApiConfig=Ru,B.getDefaultChatSettings=Ou,B.getFileContent=_i,B.getFileInfo=Wv,B.getMessageAttemptInfo=tc,B.getMessageDomKey=fl,B.getPreviewForMessage=mi,B.httpClient=qt,B.hydrateHistorySnapshots=Rn,B.isEnvelope=su,B.listFiles=eu,B.loadStoredSettings=Du,B.onChatTokenChanged=Yc,B.post=Ko,B.processAttachments=ou,B.put=Zc,B.readNumber=rc,B.readString=Mn,B.resolveChatBaseUrl=xn,B.saveSettings=Lu,B.setChatToken=Vo,B.toPlainObject=_n,B.unwrap=Rt,B.useApi=Xr,B.useCheckpointIndex=nc,B.useFilePreview=_p,B.useHasChatSession=vb,B.useParsedMessageContent=Mp,B.useShallowStableValue=ju,B.useStream=$i,B.useStreamingHook=$i,B.useThreadHistoryState=yu,B.useThreadManagerViewState=fm,B.useThreadState=eo,B.useThreadStateUpdater=Tu,B.useThreads=xr,B.useThreadsState=du,B.viewFileById=Uv,Object.defineProperty(B,Symbol.toStringTag,{value:"Module"})});
|
|
127
|
+
`+(f.tokens?this.parseInline(f.tokens):f.text);r+=n?this.renderer.paragraph(m):m;continue}default:{const j='Token with "'+f.type+'" type was not found.';if(this.options.silent){console.error(j);return}else throw new Error(j)}}}return r}parseInline(t,n){n=n||this.renderer;let r="",o,s,i;const a=t.length;for(o=0;o<a;o++){if(s=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[s.type]&&(i=this.options.extensions.renderers[s.type].call({parser:this},s),i!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type))){r+=i||"";continue}switch(s.type){case"escape":{r+=n.text(s.text);break}case"html":{r+=n.html(s.text);break}case"link":{r+=n.link(s.href,s.title,this.parseInline(s.tokens,n));break}case"image":{r+=n.image(s.href,s.title,s.text);break}case"strong":{r+=n.strong(this.parseInline(s.tokens,n));break}case"em":{r+=n.em(this.parseInline(s.tokens,n));break}case"codespan":{r+=n.codespan(s.text);break}case"br":{r+=n.br();break}case"del":{r+=n.del(this.parseInline(s.tokens,n));break}case"text":{r+=n.text(s.text);break}default:{const l='Token with "'+s.type+'" type was not found.';if(this.options.silent){console.error(l);return}else throw new Error(l)}}}return r}}class Ys{constructor(t){this.options=t||cr}preprocess(t){return t}postprocess(t){return t}}nx(Ys,"passThroughHooks",new Set(["preprocess","postprocess"]));function OT(e,t,n){return r=>{if(r.message+=`
|
|
128
|
+
Please report this to https://github.com/markedjs/marked.`,e){const o="<p>An error occurred:</p><pre>"+Pt(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 yp(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...be.defaults,...s};const i=OT(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(_T(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(h){return i(h)}const c=function(h){let m;if(!h)try{r.walkTokens&&be.walkTokens(l,r.walkTokens),m=t(l,r),r.hooks&&(m=r.hooks.postprocess(m))}catch(f){h=f}return r.highlight=a,h?i(h):o(null,m)};if(!a||a.length<3||(delete r.highlight,!l.length))return c();let d=0;be.walkTokens(l,function(h){h.type==="code"&&(d++,setTimeout(()=>{a(h.text,h.lang,function(m,f){if(m)return c(m);f!=null&&f!==h.text&&(h.text=f,h.escaped=!0),d--,d===0&&c()})},0))}),d===0&&c();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(be.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&&be.walkTokens(a,r.walkTokens);let l=t(a,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(a){return i(a)}}}function be(e,t,n){return yp(Vn.lex,Kn.parse)(e,t,n)}be.options=be.setOptions=function(e){return be.defaults={...be.defaults,...e},bT(be.defaults),be},be.getDefaults=cp,be.defaults=cr,be.use=function(...e){const t=be.defaults.extensions||{renderers:{},childTokens:{}};e.forEach(n=>{const r={...n};if(r.async=be.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=be.defaults.renderer||new sl;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=be.defaults.tokenizer||new ol;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=be.defaults.hooks||new Ys;for(const s in n.hooks){const i=o[s];Ys.passThroughHooks.has(s)?o[s]=a=>{if(be.defaults.async)return Promise.resolve(n.hooks[s].call(o,a)).then(c=>i.call(o,c));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=be.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}}be.setOptions(r)})},be.walkTokens=function(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(be,r)),r.type){case"table":{for(const o of r.header)n=n.concat(be.walkTokens(o.tokens,t));for(const o of r.rows)for(const s of o)n=n.concat(be.walkTokens(s.tokens,t));break}case"list":{n=n.concat(be.walkTokens(r.items,t));break}default:be.defaults.extensions&&be.defaults.extensions.childTokens&&be.defaults.extensions.childTokens[r.type]?be.defaults.extensions.childTokens[r.type].forEach(function(o){n=n.concat(be.walkTokens(r[o],t))}):r.tokens&&(n=n.concat(be.walkTokens(r.tokens,t)))}return n},be.parseInline=yp(Vn.lexInline,Kn.parseInline),be.Parser=Kn,be.parser=Kn.parse,be.Renderer=sl,be.TextRenderer=bp,be.Lexer=Vn,be.lexer=Vn.lex,be.Tokenizer=ol,be.Slugger=wp,be.Hooks=Ys,be.parse=be,be.options,be.setOptions,be.use,be.walkTokens,be.parseInline,Kn.parse,Vn.lex;function qn({content:e,className:t="",allowHtml:n=!1,style:r}){const o=b.useMemo(()=>{if(!e||typeof e!="string"||e.trim().length===0)return"";try{if(!n){const i=e.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"").replace(/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi,"").replace(/javascript:/gi,"").replace(/on\w+\s*=/gi,"");return typeof be.parse=="function"?be.parse(i):be(i)}return typeof be.parse=="function"?be.parse(e):be(e)}catch(i){return console.error("[MarkdownContent] parse error",i),`<pre class="font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words">Error rendering markdown: ${String(i)}</pre>`}},[e,n]),s=b.useMemo(()=>{const i={color:"currentColor",...r};if(r&&r.color){const a=r.color;return{...i,"--tw-prose-body":a,"--tw-prose-headings":a,"--tw-prose-links":a,"--tw-prose-bold":a,"--tw-prose-counters":a,"--tw-prose-bullets":a,"--tw-prose-hr":a,"--tw-prose-quotes":a,"--tw-prose-quote-borders":a,"--tw-prose-captions":a,"--tw-prose-code":a,"--tw-prose-pre-code":a,"--tw-prose-pre-bg":"inherit","--tw-prose-th-borders":a,"--tw-prose-td-borders":a}}return i},[r]);return u.jsx("div",{className:oe("markdown prose prose-sm max-w-none break-words","dark:prose-invert","text-current","prose-headings:text-current prose-p:text-current prose-li:text-current prose-a:text-current prose-strong:text-current","prose-em:text-current prose-blockquote:text-current prose-table:text-current prose-td:text-current prose-th:text-current","prose-pre:font-mono prose-pre:text-xs prose-pre:bg-background/50 prose-pre:border prose-pre:rounded prose-pre:p-3 prose-pre:whitespace-pre prose-pre:overflow-x-auto","prose-code:font-mono prose-code:text-sm prose-code:bg-background/50 prose-code:px-1.5 prose-code:py-0.5 prose-code:rounded prose-code:text-current",t),style:s,dangerouslySetInnerHTML:{__html:o}})}function Sp({preview:e,idx:t}){return u.jsxs("div",{className:"space-y-2",children:[e.label&&u.jsxs("p",{className:"text-[0.65rem] uppercase tracking-wide text-muted-foreground",children:["Artifact: ",e.label]}),u.jsx("div",{className:"overflow-hidden rounded border border-border/60 bg-background/60 p-1 shadow-sm",children:u.jsx("img",{src:e.src,alt:e.alt,title:e.label,loading:"lazy",className:"h-auto max-h-[420px] w-full rounded object-contain",onLoad:()=>{},onError:n=>{console.error(`[MessageComponent] ❌ Image failed to load for artifact ${t}:`,{alt:e.alt,label:e.label,message:n.target.alt})}})})]})}const Cp={completed:{label:"Completed",badgeClass:"border border-green-200 bg-green-50 text-green-700"},success:{label:"Completed",badgeClass:"border border-green-200 bg-green-50 text-green-700"},failed:{label:"Failed",badgeClass:"border border-red-200 bg-red-50 text-red-700"},error:{label:"Failed",badgeClass:"border border-red-200 bg-red-50 text-red-700"},cancelled:{label:"Cancelled",badgeClass:"border border-orange-200 bg-orange-50 text-orange-700"},cancel:{label:"Cancelled",badgeClass:"border border-orange-200 bg-orange-50 text-orange-700"},pending:{label:"Pending",badgeClass:"border border-blue-200 bg-blue-50 text-blue-700"},processing:{label:"Processing",badgeClass:"border border-yellow-200 bg-yellow-50 text-yellow-700"}},DT=e=>{if(!e)return Cp.processing;const t=e.toLowerCase().trim();return Cp[t]??{label:t.replace(/(^\w|\s\w)/g,n=>n.toUpperCase()),badgeClass:"border border-slate-200 bg-slate-50 text-slate-800"}},LT=e=>e?e.length>10?`${e.slice(0,8)}…`:e:"";function Tp({artifact:e}){const t=DT(e.status),n=e.task_url??e.taskUrl??"";return u.jsxs("div",{className:"rounded-lg border border-blue-200/70 bg-blue-50/40 p-4 space-y-3",children:[u.jsxs("div",{className:"flex items-start justify-between gap-3",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsx("div",{className:"flex h-7 w-7 items-center justify-center rounded-full bg-blue-600/10 text-blue-600",children:u.jsx(ue.Search,{className:"h-4 w-4"})}),u.jsxs("div",{className:"space-y-1",children:[u.jsx("p",{className:"text-xs font-semibold uppercase tracking-wide text-blue-700",children:"Research Task"}),u.jsxs("p",{className:"text-[11px] text-blue-900/80",children:["Task ID: ",u.jsx("span",{className:"font-mono",children:LT(e.task_id)})]})]})]}),t&&u.jsx("span",{className:`inline-flex items-center rounded-full px-3 py-1 text-[11px] font-semibold ${t.badgeClass}`,children:t.label})]}),e.query&&u.jsxs("div",{className:"rounded border border-blue-100 bg-white/80 px-3 py-2 text-xs text-blue-900/90",children:[u.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wide text-blue-500",children:"Query"}),u.jsx("p",{className:"line-clamp-2 text-[11px] text-blue-900",children:e.query})]}),typeof e.results=="string"&&e.results.trim()&&u.jsxs("div",{className:"rounded border border-blue-100 bg-white/80 px-3 py-2 text-sm text-blue-900/90 space-y-1",children:[u.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wide text-blue-500",children:"Results"}),u.jsx(qn,{content:e.results,allowHtml:!1,className:"prose text-xs !prose-sm prose-blue dark:prose-invert"})]}),u.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[n?u.jsxs("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 rounded-full border border-blue-600/80 bg-blue-600/10 px-3 py-1 text-xs font-semibold text-blue-700 transition hover:bg-blue-600/20",children:[u.jsx("span",{children:"Go to task"}),u.jsx(ue.ExternalLink,{className:"h-3 w-3"})]}):u.jsx("span",{className:"text-xs text-muted-foreground",children:"Task link unavailable"}),e.createdAt&&u.jsxs("p",{className:"text-[10px] text-blue-700/70",children:["Started: ",new Date(e.createdAt).toLocaleTimeString()]})]})]})}function kp({artifact:e,idx:t=0}){const n=b.useMemo(()=>e?(Array.isArray(e.plots)?e.plots:[]).map(o=>sb(o)).filter(o=>o!==null):[],[e]);return(e==null?void 0:e.type)==="research_task_info"?u.jsx(Tp,{artifact:{type:"research_task_info",task_id:e.task_id,task_url:e.task_url,query:e.query,status:e.status,createdAt:e.createdAt}}):n.length>0?u.jsx("div",{className:"space-y-2",children:n.map((r,o)=>u.jsx(Sp,{preview:r,idx:o},`${t}-plot-${o}`))}):e&&typeof e=="object"?u.jsx("div",{className:"rounded-lg border border-gray-200 dark:border-gray-800 bg-gray-50 dark:bg-gray-900/20 p-4",children:u.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:["Unknown artifact type: ",u.jsx("code",{className:"font-mono",children:e.type||"unknown"})]})}):null}const il=p.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:oe("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));il.displayName="Card";const al=p.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:oe("flex flex-col space-y-1.5 p-6",e),...t}));al.displayName="CardHeader";const ll=p.forwardRef(({className:e,...t},n)=>u.jsx("h3",{ref:n,className:oe("text-2xl font-semibold leading-none tracking-tight",e),...t}));ll.displayName="CardTitle";const cl=p.forwardRef(({className:e,...t},n)=>u.jsx("p",{ref:n,className:oe("text-sm text-muted-foreground",e),...t}));cl.displayName="CardDescription";const ul=p.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:oe("p-6 pt-0",e),...t}));ul.displayName="CardContent";const Ep=p.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:oe("flex items-center p-6 pt-0",e),...t}));Ep.displayName="CardFooter";function Ip({interruptPart:e,onApprove:t,onReject:n,disabled:r,isActive:o,payload:s}){const i=e.title??"Approve the result?";let a=null;if(s!=null)if(typeof s=="string")a=u.jsx("p",{className:"text-sm leading-relaxed text-blue-800/90 dark:text-blue-200/90 whitespace-pre-wrap",children:s});else{const c=vr(s);a=u.jsx("pre",{className:"max-h-48 overflow-auto rounded bg-blue-100/60 p-2 text-xs text-blue-900/90 dark:bg-blue-900/40 dark:text-blue-100/80",children:c})}const l=o?"Please approve or reject this action to resume the workflow.":"Waiting for approval from another participant.";return u.jsxs(il,{className:oe("border-blue-200 dark:border-blue-800 bg-blue-50/50 dark:bg-blue-950/10 transition-shadow",o?"shadow-md ring-1 ring-blue-300 dark:ring-blue-500/70":"opacity-80"),children:[u.jsxs(al,{className:"pb-3",children:[u.jsx(ll,{className:"text-blue-900 dark:text-blue-100 text-base",children:i}),u.jsx(cl,{className:"text-blue-700 dark:text-blue-300 text-sm",children:l})]}),a&&u.jsx(ul,{className:"pt-0 pb-3",children:a}),u.jsx(Ep,{className:"pt-0",children:u.jsxs("div",{className:"flex gap-2 ml-auto",children:[u.jsx(Xe,{size:"sm",variant:"outline",onClick:()=>n(e),className:"border-red-300 text-red-700 hover:bg-red-50 dark:border-red-700 dark:text-red-300 dark:hover:bg-red-950/50",disabled:r||!o,children:"Reject"}),u.jsx(Xe,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",disabled:r||!o,children:"Approve"})]})})]})}const $T="prose prose-sm max-w-none break-words dark:prose-invert prose-headings:break-words prose-p:break-words prose-li:break-words prose-td:break-words prose-th:break-words prose-a:break-all prose-code:break-words prose-blockquote:break-words";function dl({data:e}){return Array.isArray(e)?e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?u.jsx("div",{className:$T,children:u.jsx("ul",{className:"list-disc pl-5",children:e.map((n,r)=>u.jsx("li",{children:String(n)},r))})}):u.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:vr(e)}):u.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:vr(e)})}function Np({message:e,isStreaming:t=!1}){const n=e.name??"tool",r=b.useMemo(()=>{const a=e.additionalKwargs??{};return Array.isArray(a.toolProgress)?[...a.toolProgress]:[]},[e]),s=r.some(a=>a.type==="tool.start"||a.type==="tool.call"||a.type==="message.start")?`Running ${n}…`:void 0;return t||r.length>0?u.jsxs("div",{className:"space-y-2",children:[u.jsxs("div",{className:"flex items-center gap-2 text-xs uppercase tracking-wide text-muted-foreground",children:[t&&u.jsx(ue.Loader,{className:"h-3 w-3 animate-spin"}),u.jsx("span",{children:s??`Running ${n}…`})]}),r.length>0&&u.jsx("div",{className:"space-y-2 text-xs text-muted-foreground",children:r.map((a,l)=>{var c;return u.jsxs("div",{className:"rounded border border-current/10 bg-muted/60 p-2 text-[11px] leading-snug",children:[u.jsxs("div",{className:"mb-1 flex items-center justify-between text-[8px] uppercase tracking-wide text-muted-foreground",children:[u.jsx("span",{children:((c=a.type)==null?void 0:c.replace(/\./g," "))??"progress"}),u.jsx("span",{children:a.idx??l+1})]}),a.content&&u.jsx("p",{className:"mt-1 text-[12px] text-foreground/90",children:a.content}),u.jsxs("div",{className:"mt-1 flex flex-wrap gap-2 text-[10px] opacity-70",children:[typeof a.factsFound=="number"&&u.jsxs("span",{children:["Facts found: ",a.factsFound]}),typeof a.isSufficient=="boolean"&&u.jsxs("span",{children:["Research ",a.isSufficient?"sufficient":"needs more data"]})]})]},`tool-progress-${n}-${l}`)})})]}):null}function Ap({className:e}){const[t,n]=b.useState(0);return b.useEffect(()=>{const r=setInterval(()=>n(o=>(o+1)%4),500);return()=>clearInterval(r)},[]),u.jsxs("span",{"aria-live":"polite",className:oe("inline-block text-xs opacity-70 ml-1",e),children:["Is thinking",".".repeat(t)]})}function jp({text:e,expanded:t,onExpandedChange:n,previewLength:r,isCompact:o}){const s=Math.max(e.length-r,0),i=e.substring(0,r);return u.jsxs("div",{className:"flex flex-col gap-1",children:[u.jsx("div",{className:oe("text-sm text-[hsl(var(--chat-bubble-user-text))]",o&&"text-xs"),children:t?u.jsx(qn,{content:e,allowHtml:!1}):u.jsxs("pre",{className:oe("font-sans whitespace-pre-wrap break-words bg-transparent p-0 m-0 text-[hsl(var(--chat-bubble-user-text))]",o&&"text-xs"),children:[i,"..."]})}),u.jsx(Xe,{type:"button",variant:"ghost",size:"sm",className:"h-6 text-xs !text-[hsl(var(--chat-bubble-user-text))]",onClick:()=>n(!t),children:t?u.jsxs(u.Fragment,{children:[u.jsx(ue.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):u.jsxs(u.Fragment,{children:[u.jsx(ue.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",s," chars)"]})})]})}function Pp({message:e,viewMode:t,isStreaming:n=!1}){const o=Oi(e).name||"tool",s=e.artifact??null,i=c=>{if(c==null)return null;const d=typeof c=="string"?Ri(c)??c:c;if(d&&typeof d=="object")return u.jsx(dl,{data:d});const h=typeof d=="string"?d:(()=>{try{return vr(d)}catch{return String(d??"")}})();return u.jsx("pre",{className:"whitespace-pre-wrap break-words font-sans text-sm text-foreground/90",children:h})},a=c=>{if(c==null)return null;const{content:d,isMarkdown:h}=Zv(c);return h?u.jsx(qn,{content:d,className:"text-current"}):i(c)},l=()=>{const c=e.content.find(m=>m.type!=="tool_call");if(!c)return u.jsx("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:u.jsxs("span",{children:["Running ",o,"…"]})});if(c.type==="text"){const f=(c.text??"").trim();if(!f)return null;const v=Qr(f);return a(v)}const d=Zr(c),h=Qr(d);return a(h)};return u.jsxs("div",{className:"space-y-2",children:[s&&u.jsx(kp,{artifact:s,idx:0}),u.jsx(Np,{message:e,isStreaming:n}),t==="expanded"&&u.jsx(u.Fragment,{children:l()})]})}function _p(e){const{allowFileOpen:t,currentThreadId:n}=e,{toast:r}=rl(),[o,s]=b.useState({}),[i,a]=b.useState(null),[l,c]=b.useState(!1),d=b.useCallback(()=>{c(!1),a(null)},[]),h=b.useCallback(f=>{a(f),c(!0)},[]),m=b.useCallback(async(f,v,g)=>{var x,y;if(!t){f.preventDefault();return}if(o[g]){f.preventDefault();return}try{const w=String(v.url??""),S=w.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);if(S){f.preventDefault();const k=S[1],C=v.name||`file_${k}`,T=v.mimeType||"application/octet-stream";h({id:k,name:C,mimeType:T});return}if(w.startsWith("data:")){f.preventDefault(),s(C=>({...C,[g]:!0}));const k=r({title:"Fetching file...",description:"",open:!0});try{const C=await eu(n??void 0);if(!C||!Array.isArray(C))throw new Error("Invalid file list response");const T=C.find(E=>!E||typeof E!="object"||!((E.filename??"")===(v.name??""))?!1:typeof v.size=="number"&&typeof E.size=="number"?E.size===v.size:!0);if(!(T!=null&&T.id))throw new Error(`File "${v.name}" is not yet available on the server`);if(!T.id||!T.filename)throw new Error("Invalid file data received from server");h({id:T.id,name:v.name||T.filename||`file_${T.id}`,mimeType:v.mimeType||T.mime_type||"application/octet-stream"}),(x=k.update)==null||x.call(k,{id:k.id,title:"Success",description:`Opened ${v.name}`,open:!0})}catch(C){console.error("Failed to fetch server file:",C);const T=C instanceof Error?C.message:"Unknown error occurred";(y=k.update)==null||y.call(k,{id:k.id,title:"Failed",description:T}),r({title:"Failed to fetch file",description:T,open:!0})}finally{s(C=>({...C,[g]:!1}))}}}catch(w){console.error("File click error:",w),s(S=>({...S,[g]:!1}))}},[t,o,r,n,h]);return{uploadingFiles:o,handleFileClick:m,fileViewerOpen:l,currentFileInfo:i,closeFileViewer:d}}function Mp(e,t){return b.useMemo(()=>{if(t)return{contentParts:[],textContent:"",toolMeta:{},imageParts:[],fileParts:[],interruptParts:[],toolRaw:"",isToolStreaming:!1};const n=e,r=Array.isArray(n.content)?n.content:[],o=n.additionalKwargs??{};return{contentParts:r,textContent:Qv(r),toolMeta:Oi(n),imageParts:r.filter(s=>s.type==="image_url"),fileParts:r.filter(s=>s.type==="file"),interruptParts:r.filter(s=>s.type==="interrupt"),toolRaw:eb(r),isToolStreaming:!!o.toolStreaming}},[e,t])}const FT={checkpoints:[],checkpointMetaByCheckpointId:new Map,timeline:[],messagePreviews:new Map,getLatest:()=>{},getCheckpoint:()=>{},getMessageAttempts:()=>[]},fl=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,hl=b.memo(function({message:t,index:n,isStreaming:r,streamingAssistantId:o,streamingDebounceMs:s,layoutSize:i,enableMessageEditing:a,editingMessageId:l,onEdit:c,onRegenerate:d,onCancelEdit:h,activeInterrupt:m,disableInterruptActions:f,onInterruptActionStart:v,onInterruptActionEnd:g,showToolMessages:x,checkpointIndex:y,onSelectCheckpoint:w}){const S=fl(t,n),k=t.role==="default_message",T=!!t.__syntheticStreaming,E=y??FT,j=!k&&"checkpointId"in t?t.checkpointId??null:null,{attemptCount:_,attemptIndex:D,attempts:F}=b.useMemo(()=>tc(t.id,j,E),[t.id,j,E]);return u.jsx("div",{className:"relative mb-4 last:mb-0","data-message-id":S,style:{minHeight:"60px",containIntrinsicSize:"auto 120px"},children:u.jsx(Xs,{message:t,messageIndex:n,isStreamingMessage:T||r&&o===t.id&&t.role==="assistant",streamingDebounceMs:s,isEditing:l===t.id,showActions:a,showTimestamp:!1,showAgentName:!0,layoutSize:i,onEdit:c,onRegenerate:()=>d(n),onCancelEdit:h,activeInterrupt:m,disableInterruptActions:f,onInterruptActionStart:v,onInterruptActionEnd:g,showToolMessages:x,attemptCount:_,attemptIndex:D,attemptMetas:F,onSelectCheckpoint:w})})});hl.displayName="MessageRow";function BT(e,t,n){const[r,o]=b.useState(e),s=b.useRef([]);return b.useEffect(()=>{if(!t){o(e),s.current=e.map(a=>a.type==="text"?a.text??"":void 0);return}const i=e.map((a,l)=>{if(a.type!=="text")return s.current[l]=void 0,a;const c=a.text??"",d=s.current[l];return n(c)?(s.current[l]=c,a):{...a,text:d??""}});o(i)},[e,t,n]),r}function zT({message:e,isToolMessage:t,showToolMessages:n,toolViewMode:r,isToolStreaming:o,contentParts:s,textContent:i,imageParts:a,fileParts:l,interruptParts:c,isStreamingMessage:d,enableStreamingMarkdownBuffer:h,renderStreamingMarkdown:m,defaultMessage:f,handleFileClick:v,uploadingFiles:g,handleInterruptApprove:x,handleInterruptReject:y,disableInterruptActions:w,messageRole:S,truncateUserMessages:k,userMessagePreviewLength:C,isUserExpanded:T,setIsUserExpanded:E,isCompactLayout:j,activeInterruptId:_,activeInterruptValue:D,iconForeground:F}){const G=b.useCallback(()=>u.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/30 rounded",children:[u.jsx(ue.Loader,{className:"h-4 w-4 text-muted-foreground"}),u.jsx("span",{className:"text-sm text-muted-foreground",children:"File upload"})]}),[]),A=BT(s,(h??!0)&&d,Rp),Y=b.useMemo(()=>A.filter(O=>O.type==="text"),[A]),q=b.useMemo(()=>Y.map(O=>O.text??"").join(""),[Y]),W=b.useMemo(()=>{if(!m)return null;const O=HT(q);return{stablePart:q.slice(0,O),tailPart:q.slice(O)}},[q,m]),R=b.useMemo(()=>{if(!W)return null;const{stablePart:O,tailPart:M}=W;return!O&&!M?null:u.jsxs("div",{className:"space-y-2",children:[O?u.jsx(qn,{content:O,allowHtml:!1}):null,M?u.jsx(qn,{content:M,allowHtml:!1}):null]})},[W]),I=b.useMemo(()=>{if(!m)return A;const O=[];let M=!1;for(const L of A){if(L.type==="text"){M||(O.push({type:"text",text:"",__streamingMarkdownAggregate:!0}),M=!0);continue}O.push(L)}return O},[A,m]),z=m?I:A,J=b.useCallback(({part:O,i:M})=>{if(O.type==="text"){if(m)return null;const L=O.text??"",ee=L.trim(),H=Ri(ee);return H&&S!=="tool"?u.jsx(dl,{data:H},M):S==="user"&&k&&ee.length>C?u.jsx(jp,{text:ee,expanded:T,onExpandedChange:E,previewLength:C,isCompact:j},M):u.jsx(qn,{content:L,allowHtml:!1},M)}if(O.type==="image_url"){const L=O;return u.jsx("div",{className:"my-2",children:u.jsx("img",{src:L.url,alt:L.alt??"",loading:"lazy",className:"border rounded max-h-[420px] w-auto object-contain"})},M)}if(O.type==="file"){const L=O,ee=L.name||"file";return u.jsxs("a",{href:L.url,onClick:H=>v(H,L,M),className:`inline-flex items-center gap-2 rounded px-2 py-1 text-xs bg-gray-100 border hover:bg-gray-200
|
|
129
|
+
dark:bg-background/10 dark:border-border/30 dark:hover:bg-background/20`,children:[g[M]?u.jsx(ue.Loader,{className:"h-4 w-4 animate-spin"}):null,u.jsxs("span",{className:"truncate max-w-[180px]",children:[ee,g[M]?" (processing)":""]})]},M)}if(O.type==="interrupt"){const L=O,ee=Yo((L==null?void 0:L.id)??(L==null?void 0:L.interrupt_id)),H=!!(_&&ee&&ee===_),$=H?D??(L==null?void 0:L.value):L==null?void 0:L.value,Z=ee?{...L,id:ee,interrupt_id:ee}:L;return u.jsx(Ip,{interruptPart:Z,onApprove:x,onReject:y,disabled:w,isActive:H,payload:$},M)}return null},[_,D,w,v,x,y,j,T,S,k,g,C,m,E]),P=i.trim().length>0||a.length>0||l.length>0||c.length>0;if(!t&&l.length>0&&!d)return G();if(!t&&!P&&!d)return null;if(t)return n?u.jsx(Pp,{message:e,viewMode:r,isStreaming:o},e.id):null;if(!f){const O=u.jsx("div",{className:"space-y-2",children:z.map((M,L)=>m&&UT(M)?R?u.jsx("div",{className:"space-y-2",children:R},`streaming-md-${L}`):null:u.jsx(J,{part:M,i:L},L))});return d?u.jsxs("div",{"aria-busy":"true",role:"status",children:[O,u.jsx(Ap,{className:F})]}):O}return null}function Rp(e){return e?!(Io(e,/```/g)||Io(e,/`/g)||Io(e,/\*\*/g)||Io(e,/__/g)||Io(e,/~~/g)||/[^\\]\[[^\]]*$/.test(e)||/\[[^\]]*\]\([^)]*$/.test(e)):!0}function Io(e,t){const n=e.match(t);return((n==null?void 0:n.length)??0)%2!==0}function HT(e){if(!e)return 0;for(let t=e.length;t>=0;t-=1)if(Rp(e.slice(0,t)))return t;return 0}function UT(e){return e.type==="text"&&!!e.__streamingMarkdownAggregate}const WT=zr.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 Op({className:e,variant:t,...n}){return u.jsx("div",{className:oe(WT({variant:t}),e),...n})}function VT({showTimestamp:e,showAgentName:t,isToolMessage:n,iconForeground:r,agentName:o,messageIcon:s,customHeaderClass:i,customActionsClass:a,isCompactLayout:l,showActions:c,isEditing:d,messageRole:h,toolViewMode:m,toolMeta:f,onToggleToolView:v,onCopy:g,onEdit:x,onRegenerate:y,showCheckpointControls:w,attemptCount:S,attemptIndex:k,handleOlderAttemptSelect:C,handleNewerAttemptSelect:T,messageCreatedAt:E,copied:j}){return!e&&!t&&!n?null:u.jsxs("div",{className:oe("flex items-center justify-between mb-2 pb-2 border-b border-current/10",l&&"mb-1 pb-1",r,i),children:[u.jsxs("div",{className:"flex items-center gap-2",children:[s,t&&o&&u.jsx("span",{className:oe("font-medium",l?"text-xs":"text-sm"),children:o}),n&&u.jsxs(Op,{variant:"outline",className:oe("text-xs flex items-center gap-1 cursor-pointer select-none",r,"border border-current/40",l&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":m==="expanded",onClick:v,onKeyDown:_=>{(_.key==="Enter"||_.key===" ")&&(_.preventDefault(),v())},children:[u.jsx("span",{children:f.name??"Tool Output"}),f.toolCallId&&u.jsx("span",{className:"opacity-70",children:f.toolCallId.slice(0,8)}),m==="expanded"?u.jsx(ue.ChevronUp,{className:"h-3 w-3"}):u.jsx(ue.ChevronDown,{className:"h-3 w-3"})]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[w&&S>1&&u.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[u.jsx("button",{type:"button",className:oe("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",k<S-1?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{k>=S-1||C()},"aria-label":"Older attempt (back in time)",disabled:k>=S-1,children:u.jsx(ue.ChevronLeft,{className:"h-3 w-3"})}),u.jsx("div",{className:"flex items-center gap-2",children:u.jsxs("span",{className:"whitespace-nowrap",children:[S-k," / ",S]})}),u.jsx("button",{type:"button",className:oe("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",k>0?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{k<=0||T()},"aria-label":"Newer attempt (forward in time)",disabled:k<=0,children:u.jsx(ue.ChevronRight,{className:"h-3 w-3"})})]}),e&&E&&u.jsx("time",{className:oe("text-xs opacity-60",r,l&&"text-xs"),dateTime:new Date(E).toISOString(),title:new Date(E).toLocaleString(),children:new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(new Date(E))}),c&&!d&&u.jsxs("div",{className:oe("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",a),children:[u.jsx("div",{className:"relative",children:u.jsx(Xe,{variant:"ghost",size:"sm",onClick:g,className:oe("h-6 w-6 p-0 hover:bg-foreground/10",r,l&&"h-5 w-5"),"aria-label":"Copy message",title:"Copy message",children:u.jsx(ue.Copy,{className:oe(j?"text-success":r,l?"h-3 w-3":"h-4 w-4")})})}),h==="user"&&x&&u.jsx(Xe,{variant:"ghost",size:"sm",onClick:x,className:oe("h-6 w-6 p-0 hover:bg-foreground/10",r,l&&"h-5 w-5"),"aria-label":"Edit message",children:u.jsx(ue.Edit,{className:oe(r,l?"h-3 w-3":"h-4 w-4")})}),h==="assistant"&&y&&u.jsx(Xe,{variant:"ghost",size:"sm",onClick:y,className:oe("h-6 w-6 p-0 hover:bg-foreground/10",r,l&&"h-5 w-5"),"aria-label":"Regenerate response",children:u.jsx(ue.RotateCcw,{className:oe(r,l?"h-3 w-3":"h-4 w-4")})})]})]})]})}const Xs=b.memo(function({message:t,messageIndex:n,isStreamingMessage:r=!1,isEditing:o=!1,showActions:s=!0,showTimestamp:i=!0,showAgentName:a=!0,layoutSize:l="desktop",truncateUserMessages:c=!0,userMessagePreviewLength:d=500,showToolMessages:h=!0,customStyles:m={},streamingDebounceMs:f=300,renderStreamingMarkdown:v=!1,enableStreamingMarkdownBuffer:g,onEdit:x,onRegenerate:y,onCopy:w,activeInterrupt:S,disableInterruptActions:k=!1,onInterruptActionStart:C,onInterruptActionEnd:T,attemptCount:E=1,attemptIndex:j=0,onSelectCheckpoint:_,attemptMetas:D=[]}){const[F,G]=b.useState(!1),[K,A]=b.useState("preview"),[Y,q]=b.useState(!1),{currentThreadId:W}=xr(),{respondToInterrupt:R}=eo(),I=l==="phone"||l==="half-screen",z=t.role,J=z==="tool",P=b.useMemo(()=>t.role==="default_message"?t:null,[t]),O=!!P,M=!(r&&z!=="user"),{uploadingFiles:L,handleFileClick:ee,fileViewerOpen:H,currentFileInfo:$,closeFileViewer:Z}=_p({allowFileOpen:M,currentThreadId:W}),te=b.useMemo(()=>{switch(z){case"user":return"text-[hsl(var(--chat-bubble-user-text))]";case"assistant":return"text-[hsl(var(--chat-bubble-ai-text))]";case"tool":return"text-secondary-foreground";case"system":return"text-muted-foreground";default:return"text-[hsl(var(--chat-bubble-ai-text))]"}},[z]),Q=Mp(t,P),{contentParts:U,imageParts:le,fileParts:ie,interruptParts:ge,textContent:we,toolMeta:Ce,toolRaw:Ae,isToolStreaming:Ee}=Q,st=g??f!==0,lt=(S==null?void 0:S.id)??(S==null?void 0:S.interrupt_id),St=Yo(lt),Oe=S==null?void 0:S.value,qe=b.useCallback(async()=>{const X=J?Ae:we;async function fe(He){if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function"){await navigator.clipboard.writeText(He);return}if(navigator.clipboard&&typeof navigator.clipboard.write=="function"&&typeof ClipboardItem<"u"){const ae=new Blob([He],{type:"text/plain"});await navigator.clipboard.write([new ClipboardItem({"text/plain":ae})]);return}throw new Error("Clipboard API not supported in this context.")}try{await fe(X),G(!0),setTimeout(()=>G(!1),2e3),w==null||w(X)}catch(He){console.error("Failed to copy:",He)}},[J,Ae,we,w]),We=b.useCallback(()=>{if(!x||!t.id)return;const X=(J?Ae:we)??"",fe="type"in t&&t.type==="default_message"?void 0:{checkpointId:t.checkpointId??null,checkpointNs:t.checkpointNs??null};x(t.id,X,fe)},[x,t.id,J,Ae,we,t]),je=b.useCallback(()=>{y==null||y(n)},[y,n]),_e=b.useCallback(()=>{A(X=>X==="expanded"?"preview":"expanded")},[]),ct=b.useCallback(()=>{const fe=oe(I?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",te);switch(z){case"user":return u.jsx(ue.User,{className:fe});case"assistant":return u.jsx(ue.Bot,{className:fe});case"tool":return u.jsx(ue.Wrench,{className:fe});default:return u.jsx(ue.Bot,{className:fe})}},[I,te,z]),kt=b.useCallback(()=>{const X="group relative mb-4 flex w-full";switch(z){case"user":return oe(X,"justify-end");case"assistant":case"tool":case"system":return oe(X,"justify-start");default:return X}},[z]),nt=b.useCallback(()=>{const X=oe("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",I&&"px-3 py-2 text-sm");if(O)return oe(X,"w-full","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40 shadow-sm");switch(z){case"user":return oe(X,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-user))] text-[hsl(var(--chat-bubble-user-text))]","border border-transparent");case"assistant":return oe(X,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40");case"tool":return oe(X,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return oe(X,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return oe(X,"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")}},[I,O,z]),Et=b.useCallback(async X=>{if(k)return;const fe=Yo((X==null?void 0:X.id)??(X==null?void 0:X.interrupt_id));if(!fe){console.warn("Interrupt part missing id",X);return}try{C==null||C(),await R(fe,!0)}catch(He){console.error("Failed to approve interrupt:",He)}finally{T==null||T()}},[k,T,C,R]),bt=b.useCallback(async X=>{if(k)return;const fe=Yo((X==null?void 0:X.id)??(X==null?void 0:X.interrupt_id));if(!fe){console.warn("Interrupt part missing id",X);return}try{C==null||C(),await R(fe,!1)}catch(He){console.error("Failed to reject interrupt:",He)}finally{T==null||T()}},[k,T,C,R]),wt=u.jsx(zT,{message:t,isToolMessage:J,showToolMessages:h,toolViewMode:K,isToolStreaming:Ee,contentParts:U,textContent:we,imageParts:le,fileParts:ie,interruptParts:ge,isStreamingMessage:r,defaultMessage:P,enableStreamingMarkdownBuffer:st,renderStreamingMarkdown:v,handleFileClick:ee,uploadingFiles:L,handleInterruptApprove:Et,handleInterruptReject:bt,disableInterruptActions:k,messageRole:z,truncateUserMessages:c,userMessagePreviewLength:d,isUserExpanded:Y,setIsUserExpanded:q,isCompactLayout:I,activeInterruptId:St,activeInterruptValue:Oe,iconForeground:te}),Ct=b.useMemo(()=>P?"Assistant":tb(t),[P,t]),on=ct(),Tt=z==="user"&&(E??1)>1&&typeof _=="function",Lt=(D==null?void 0:D.length)??0,_t=Lt>0&&j<Lt-1?D[j+1]:void 0,$e=Lt>0&&j>0?D[j-1]:void 0,ze=b.useCallback(()=>{!_t||!_||_(_t.id,void 0,!!_t.isLatestAttempt)},[_t,_]),Mt=b.useCallback(()=>{!$e||!_||_($e.id,void 0,!!$e.isLatestAttempt)},[$e,_]);return J&&!h?null:O&&P?u.jsx("div",{className:oe(kt(),m.container),children:u.jsxs("div",{className:oe(nt(),m.content),children:[u.jsxs("div",{className:"flex items-center gap-2 mb-2 pb-2 border-b border-current/10",children:[u.jsx(ue.Bot,{className:oe("h-4 w-4",te)}),a&&u.jsx("span",{className:"font-medium text-sm",children:"Assistant"})]}),u.jsx(qn,{content:P.content,className:"text-current"})]})}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:oe(kt(),m.container),children:u.jsxs("div",{className:oe(nt(),m.content),children:[u.jsx(VT,{showTimestamp:i,showAgentName:a,isToolMessage:J,iconForeground:te,agentName:Ct,messageIcon:on,customHeaderClass:m.header,customActionsClass:m.actions,isCompactLayout:I,showActions:s,isEditing:o,messageRole:z,toolViewMode:K,toolMeta:Ce,onToggleToolView:_e,onCopy:qe,onEdit:We,onRegenerate:je,showCheckpointControls:Tt,attemptCount:E,attemptIndex:j,handleOlderAttemptSelect:ze,handleNewerAttemptSelect:Mt,messageCreatedAt:t.createdAt,copied:F}),u.jsx("div",{className:"relative",children:wt}),J&&K==="expanded"&&(Ce.toolCallId||Ce.name)&&u.jsxs("div",{className:oe("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",I&&"text-xs"),children:[Ce.name&&u.jsxs("div",{children:["Function: ",Ce.name]}),Ce.toolCallId&&u.jsxs("div",{children:["Call ID: ",Ce.toolCallId]})]}),!(i||a||J)&&s&&!o&&u.jsxs("div",{className:oe("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",m.actions),children:[u.jsx(Xe,{variant:"ghost",size:"sm",onClick:()=>qe(),className:oe("h-6 w-6 p-0 hover:bg-background/50 text-current",I&&"h-5 w-5"),children:u.jsx(ue.Copy,{className:oe(F?"text-success":"text-current",I?"h-3 w-3":"h-4 w-4")})}),z==="user"&&x&&u.jsx(Xe,{variant:"ghost",size:"sm",onClick:We,className:oe("h-6 w-6 p-0 hover:bg-background/50 text-current",I&&"h-5 w-5"),children:u.jsx(ue.Edit,{className:oe("text-current",I?"h-3 w-3":"h-4 w-4")})}),z==="assistant"&&y&&u.jsx(Xe,{variant:"ghost",size:"sm",onClick:je,className:oe("h-6 w-6 p-0 hover:bg-background/50 text-current",I&&"h-5 w-5"),children:u.jsx(ue.RotateCcw,{className:oe("text-current",I?"h-3 w-3":"h-4 w-4")})})]})]})}),$&&u.jsx(lp,{isOpen:H,onClose:Z,fileId:$.id,fileName:$.name,mimeType:$.mimeType})]})},(e,t)=>{var l,c,d,h,m,f,v,g;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&mu(e.message)===mu(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateUserMessages","userMessagePreviewLength","showToolMessages"].every(x=>e[x]===t[x]),s=((l=e.customStyles)==null?void 0:l.container)===((c=t.customStyles)==null?void 0:c.container)&&((d=e.customStyles)==null?void 0:d.content)===((h=t.customStyles)==null?void 0:h.content)&&((m=e.customStyles)==null?void 0:m.actions)===((f=t.customStyles)==null?void 0:f.actions)&&((v=e.customStyles)==null?void 0:v.header)===((g=t.customStyles)==null?void 0:g.header);if(!o||!s)return!1;const i=gu(e.message),a=gu(t.message);return i.length===a.length});Xs.displayName="MessageComponent";const pl=b.forwardRef(({messages:e,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onStartReached:a,onEdit:l,onRegenerate:c,onCancelEdit:d,className:h,style:m,emptyMessage:f,followNewMessages:v=!0,isNavigatingCheckpoint:g=!1,onScrollAway:x,onAtBottom:y,activeInterrupt:w,disableInterruptActions:S=!1,onInterruptActionStart:k,onInterruptActionEnd:C,showToolMessages:T=!0,checkpointIndex:E,activeCheckpointId:j,onSelectCheckpoint:_,createSyntheticThinkingMessage:D=!0,forceSyntheticThinking:F=!1},G)=>{const K=b.useRef(null),A=b.useRef(null),Y=b.useRef(!1),q=b.useRef(!1),[W,R]=b.useState(!0),I=b.useMemo(()=>w?e.some(U=>U.role==="default_message"?!1:Array.isArray(U==null?void 0:U.content)&&U.content.some(le=>le&&le.type==="interrupt"&&(le.id??le.interrupt_id)===w.id)):!1,[w,e]),z=b.useMemo(()=>{if(!w||I)return null;const U=w.id&&String(w.id).trim()?String(w.id).trim():"pending-interrupt";let le;const ie=w.value;if(ie&&typeof ie=="object"&&!Array.isArray(ie)){const ge=ie.title;typeof ge=="string"&&ge.trim()&&(le=ge.trim())}return{id:`interrupt-${U}`,role:"system",createdAt:new Date().toISOString(),content:[{type:"interrupt",id:U,value:ie,title:le}]}},[w,I]),J=b.useMemo(()=>z?[...e,z]:e,[e,z]),P=b.useMemo(()=>{const U=n&&J.some(ie=>ie.id===n);return D&&(t||F)&&!U&&J.length>0?[...J,{id:"thinking-assistant",role:"assistant",content:[{type:"text",text:""}],createdAt:new Date().toISOString(),__syntheticStreaming:!0}]:J},[J,t,n,D,F]),O=b.useMemo(()=>T?P:P.filter(U=>(U==null?void 0:U.role)!=="tool"),[P,T]),M=b.useCallback(U=>{R(U),x&&x(!U),y&&y(U)},[x,y]),L=b.useMemo(()=>{if(a)return async()=>{if(!Y.current){Y.current=!0;try{await a()}finally{Y.current=!1}}}},[a]),ee=b.useMemo(()=>!v||g?!1:W?"auto":!1,[W,v,g]),H=b.useMemo(()=>{if(typeof f!="string")return null;const U=f.trim();return!U||O&&O.length>0?null:{id:"default-message",role:"default_message",content:U,createdAt:new Date().toISOString()}},[f,O]),$=["flex h-full flex-col md:flex-row",h].filter(Boolean).join(" "),Z=()=>H?u.jsx("div",{className:"p-6 h-full overflow-y-auto",children:u.jsx("div",{className:"w-full max-w-full",children:u.jsx(Xs,{message:H,messageIndex:0,isStreamingMessage:!1,showActions:!1,showTimestamp:!1,showAgentName:!0,layoutSize:o,onEdit:()=>{},onRegenerate:()=>{},onCancelEdit:()=>{}})})}):u.jsx("div",{className:"flex h-full items-center justify-center py-8 text-center text-muted-foreground",children:f??"No messages yet. Start a conversation!"}),te=O.length,Q=te>0;return b.useEffect(()=>{var U,le;if(te===0){q.current=!1;return}if(!q.current)if(q.current=!0,K.current&&O.length>0){const ie=O.length-1;(le=(U=K.current).scrollToIndex)==null||le.call(U,{index:ie,align:"end",behavior:"auto"})}else A.current&&(A.current.scrollTop=A.current.scrollHeight)},[te,O.length]),b.useImperativeHandle(G,()=>({scrollToLatest:()=>{var U,le;if(K.current&&O.length>0){const ie=O.length-1;(le=(U=K.current).scrollToIndex)==null||le.call(U,{index:ie,align:"end",behavior:"auto"})}else A.current&&(A.current.scrollTop=A.current.scrollHeight)},scrollToTop:()=>{var U,le;K.current&&O.length>0?(le=(U=K.current).scrollToIndex)==null||le.call(U,{index:0,align:"start",behavior:"auto"}):A.current&&(A.current.scrollTop=0)}}),[O]),u.jsx("div",{className:$,style:m,children:u.jsx("div",{className:"relative flex-1 min-h-0",children:Q?u.jsx(zC,{ref:U=>{K.current=U},scrollerRef:U=>{A.current=U instanceof HTMLDivElement?U:null},data:O,followOutput:ee,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,startReached:()=>{L&&L()},atBottomStateChange:M,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(U,le)=>fl(le,U),itemContent:(U,le)=>u.jsx(hl,{message:le,index:U,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onEdit:l,onRegenerate:c,onCancelEdit:d,activeInterrupt:w,disableInterruptActions:S,onInterruptActionStart:k,onInterruptActionEnd:C,showToolMessages:T,checkpointIndex:E,activeCheckpointId:j,onSelectCheckpoint:_})}):Z()})})});pl.displayName="MessageList";const Dp={value:""};function Rr({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:c=!0,showToolMessages:d=!0,payloadExtras:h={},customStyles:m={},onMessageSent:f,onExcelUploadSuccess:v,onError:g}){const{api:x}=Xr(),{currentThreadId:y}=xr(),{threadId:w,messages:S,isHistoryLoading:k,isLoading:C,navigateToCheckpoint:T,returnToLatest:E,checkpoint:j,checkpoints:_,interrupt:D,metadata:F,checkpointIndex:G}=eo(),{isStreaming:K,error:A,connectionState:Y,submit:q,stop:W}=$i(),R=w??y??null,I=(j==null?void 0:j.id)??null,z=(j==null?void 0:j.namespace)??null,J=(F==null?void 0:F.assemblingMessageId)??null,P=D,[O,M]=b.useState(!1),[L,ee]=b.useState(!1);b.useEffect(()=>{P||M(!1)},[P]);const H=b.useCallback(()=>{M(!0)},[]),$=b.useCallback(()=>{M(!1)},[]),Z=!!P||O,[te,Q]=b.useState(null),[U,le]=b.useState(""),[ie,ge]=b.useState(null),[we,Ce]=b.useState(null),[Ae,Ee]=b.useState(!1),[st,lt]=b.useState(null),St=b.useRef(!1),[Oe,qe]=b.useState(()=>Dp.value),We=b.useRef(Oe),je=b.useRef(null),_e=b.useCallback(ae=>{Dp.value=ae,qe(ae)},[]),[ct,kt]=b.useState(!1),nt=b.useRef(null),Et=b.useCallback(ae=>{_e(ae)},[_e]);b.useEffect(()=>{K||ee(!1)},[K]),b.useEffect(()=>{F!=null&&F.assemblingMessageId&&ee(!1)},[F==null?void 0:F.assemblingMessageId]);const[bt,wt]=b.useState("desktop");b.useEffect(()=>{const ae=()=>{const me=window.innerWidth;wt(me<640?"phone":me<1024?"tablet":"desktop")};return ae(),window.addEventListener("resize",ae),()=>window.removeEventListener("resize",ae)},[]),b.useEffect(()=>{St.current=!1},[R]),b.useEffect(()=>{We.current=Oe},[Oe]),b.useEffect(()=>{if(!te){je.current=null;return}je.current===null&&(je.current=We.current),_e(U??"")},[U,te,_e]),b.useEffect(()=>{(async()=>{if(!x.baseUrl){lt(null);return}try{const Se=(await x.getAgent("default")).uiDefaultMessage||"";lt(Se||null)}catch(me){console.warn("Failed to fetch default message:",me),lt(null)}})()},[x.baseUrl]),b.useEffect(()=>{A&&!Ae&&(g==null||g(A))},[A,Ae,g]);const Ct=async(ae,me)=>{const Se=ae.trim();if(!(!Se&&me.length===0))try{const Ve=te?(ie==null?void 0:ie.checkpointId)??I??void 0:I??void 0,it=te?(ie==null?void 0:ie.checkpointNs)??z??void 0:z??void 0;await q({text:Se||"",attachments:me,payload:h},{checkpointId:Ve,checkpointNs:it,edit:!!te,originalMessageId:te??void 0}),f==null||f(Se),ee(!0),_e(""),Ce(null),Q(null),le(""),ge(null)}catch(Ve){const it=(Ve==null?void 0:Ve.message)||"Failed to send message";Ce(it),g==null||g(it),ee(!1)}},on=b.useCallback(async ae=>{await q({attachments:[ae],payload:h},{checkpointId:I??void 0,checkpointNs:z??void 0}),v==null||v({file:ae})},[I,z,h,v,q]),Tt=b.useCallback((ae,me,Se)=>{c&&(je.current=Oe,Q(ae),le(me),_e(me),Ce(null),ge({checkpointId:(Se==null?void 0:Se.checkpointId)??null,checkpointNs:(Se==null?void 0:Se.checkpointNs)??null}))},[Oe,c,_e]),Lt=b.useCallback(()=>{Q(null),le(""),ge(null),Ce(null),_e(je.current??Oe),je.current=null},[Oe,_e]),_t=b.useCallback((ae,me,Se)=>{Tt(ae,me,Se)},[Tt]),$e=b.useCallback(ae=>{let me=null;for(let et=ae-1;et>=0;et--)if(S[et].role==="user"){me=S[et];break}if(!me)return;const Se=Array.isArray(me.content)?me.content:[],it=Se.filter(et=>(et==null?void 0:et.type)==="text").map(et=>et.text).join("")||(()=>{try{return JSON.stringify(Se,null,2)}catch{return String(Se)}})();it&&q({text:it,payload:h},{checkpointId:I??void 0,checkpointNs:z??void 0,edit:!0,originalMessageId:me.id})},[S,q,I,z,h]),ze=async ae=>{if(y){kt(!0);try{if(!ae){await E(),requestAnimationFrame(()=>{var Ve;(Ve=nt.current)==null||Ve.scrollToLatest()});return}const me=_.find(Ve=>Ve.checkpointId===ae),Se=(me==null?void 0:me.checkpointNs)??null;await T(ae,Se),requestAnimationFrame(()=>{var Ve;(Ve=nt.current)==null||Ve.scrollToTop()})}finally{kt(!1)}}},Mt=b.useCallback(async(ae,me,Se)=>{await ze(Se?null:ae)},[ze]),X=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${m.container||""}`,fe=`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 ${m.messagesArea||""}`,He=`relative flex-shrink-0 w-full border-t p-4 bg-transparent ${m.inputArea||""}`;return u.jsxs("div",{className:X,children:[!!A&&!Ae&&u.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:[u.jsx("span",{children:A}),u.jsx(Xe,{variant:"ghost",size:"sm",onClick:()=>Ee(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:u.jsx(ue.X,{size:16})})]}),u.jsxs("div",{className:`relative ${fe}`,style:r?{maxHeight:r}:void 0,children:[u.jsx(pl,{ref:nt,className:"h-full",style:{height:"100%"},messages:S,isStreaming:K,streamingAssistantId:J,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:bt,enableMessageEditing:c,editingMessageId:te,onEdit:_t,onRegenerate:$e,onCancelEdit:Lt,emptyMessage:st??void 0,isNavigatingCheckpoint:ct,activeInterrupt:P,disableInterruptActions:O,onInterruptActionStart:H,onInterruptActionEnd:$,showToolMessages:d,checkpointIndex:G,activeCheckpointId:I,onSelectCheckpoint:Mt,createSyntheticThinkingMessage:!0,forceSyntheticThinking:L}),(Y==="reconnecting"||Y==="connecting")&&u.jsx("div",{className:"pointer-events-none absolute top-3 right-3 z-20 rounded-full bg-muted/80 px-3 py-1 text-xs font-medium text-foreground shadow-sm backdrop-blur-sm dark:bg-muted/60",children:u.jsxs("span",{className:"flex items-center gap-2",children:[u.jsx(ue.Loader2,{className:"h-3 w-3 animate-spin"}),Y==="reconnecting"?"Reconnecting…":"Connecting…"]})}),Y==="error"&&u.jsx("div",{className:"pointer-events-none absolute top-3 right-3 z-20 rounded-full bg-destructive/10 px-3 py-1 text-xs font-semibold text-destructive shadow-sm",children:"Connection lost"}),C&&u.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:[u.jsx(ue.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading messages…"})]}),(k||ct)&&u.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:[u.jsx(ue.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading checkpoint…"})]})]}),u.jsxs("div",{className:He,children:[te&&u.jsx("div",{className:"mb-3 p-3 bg-blue-50 border border-blue-200 rounded-lg",children:u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(ue.Edit3,{size:16,className:"text-blue-600"}),u.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),u.jsx(Xe,{variant:"ghost",size:"sm",onClick:Lt,className:"text-blue-600 hover:bg-blue-100",children:u.jsx(ue.X,{size:16})})]})}),we&&u.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:we}),u.jsx(PS,{composerValue:Oe,onComposerChange:Et,onSend:Ct,onCancelEdit:Lt,onStop:W,editingMessageId:te,editingInitialValue:U,placeholder:te?"Edit your message...":t,isStreaming:K,disabled:Z,enableFileUpload:a,enableExcelUpload:l,onExcelUpload:on,onError:g,customStyles:m,textareaClassName:m.textarea||"",allowEmptySend:!1,inputError:we})]})]})}var Lp=1,KT=.9,qT=.8,GT=.17,ml=.1,gl=.999,YT=.9999,XT=.99,JT=/[\\\/_+.#"@\[\(\{&]/,ZT=/[\\\/_+.#"@\[\(\{&]/g,QT=/[\s-]/,$p=/[\s-]/g;function xl(e,t,n,r,o,s,i){if(s===t.length)return o===e.length?Lp:XT;var a=`${o},${s}`;if(i[a]!==void 0)return i[a];for(var l=r.charAt(s),c=n.indexOf(l,o),d=0,h,m,f,v;c>=0;)h=xl(e,t,n,r,c+1,s+1,i),h>d&&(c===o?h*=Lp:JT.test(e.charAt(c-1))?(h*=qT,f=e.slice(o,c-1).match(ZT),f&&o>0&&(h*=Math.pow(gl,f.length))):QT.test(e.charAt(c-1))?(h*=KT,v=e.slice(o,c-1).match($p),v&&o>0&&(h*=Math.pow(gl,v.length))):(h*=GT,o>0&&(h*=Math.pow(gl,c-o))),e.charAt(c)!==t.charAt(s)&&(h*=YT)),(h<ml&&n.charAt(c-1)===r.charAt(s+1)||r.charAt(s+1)===r.charAt(s)&&n.charAt(c-1)!==r.charAt(s))&&(m=xl(e,t,n,r,c+1,s+2,i),m*ml>h&&(h=m*ml)),h>d&&(d=h),c=n.indexOf(l,c+1);return i[a]=d,d}function Fp(e){return e.toLowerCase().replace($p," ")}function ek(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,xl(e,t,Fp(e),Fp(t),0,0,{})}var No='[cmdk-group=""]',vl='[cmdk-group-items=""]',tk='[cmdk-group-heading=""]',Bp='[cmdk-item=""]',zp=`${Bp}:not([aria-disabled="true"])`,bl="cmdk-item-select",Or="data-value",nk=(e,t,n)=>ek(e,t,n),Hp=p.createContext(void 0),Ao=()=>p.useContext(Hp),Up=p.createContext(void 0),wl=()=>p.useContext(Up),Wp=p.createContext(void 0),Vp=p.forwardRef((e,t)=>{let n=Dr(()=>{var P,O;return{search:"",value:(O=(P=e.value)!=null?P:e.defaultValue)!=null?O:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=Dr(()=>new Set),o=Dr(()=>new Map),s=Dr(()=>new Map),i=Dr(()=>new Set),a=Kp(e),{label:l,children:c,value:d,onValueChange:h,filter:m,shouldFilter:f,loop:v,disablePointerSelection:g=!1,vimBindings:x=!0,...y}=e,w=Nt(),S=Nt(),k=Nt(),C=p.useRef(null),T=hk();ur(()=>{if(d!==void 0){let P=d.trim();n.current.value=P,E.emit()}},[d]),ur(()=>{T(6,K)},[]);let E=p.useMemo(()=>({subscribe:P=>(i.current.add(P),()=>i.current.delete(P)),snapshot:()=>n.current,setState:(P,O,M)=>{var L,ee,H,$;if(!Object.is(n.current[P],O)){if(n.current[P]=O,P==="search")G(),D(),T(1,F);else if(P==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let Z=document.getElementById(k);Z?Z.focus():(L=document.getElementById(w))==null||L.focus()}if(T(7,()=>{var Z;n.current.selectedItemId=(Z=A())==null?void 0:Z.id,E.emit()}),M||T(5,K),((ee=a.current)==null?void 0:ee.value)!==void 0){let Z=O??"";($=(H=a.current).onValueChange)==null||$.call(H,Z);return}}E.emit()}},emit:()=>{i.current.forEach(P=>P())}}),[]),j=p.useMemo(()=>({value:(P,O,M)=>{var L;O!==((L=s.current.get(P))==null?void 0:L.value)&&(s.current.set(P,{value:O,keywords:M}),n.current.filtered.items.set(P,_(O,M)),T(2,()=>{D(),E.emit()}))},item:(P,O)=>(r.current.add(P),O&&(o.current.has(O)?o.current.get(O).add(P):o.current.set(O,new Set([P]))),T(3,()=>{G(),D(),n.current.value||F(),E.emit()}),()=>{s.current.delete(P),r.current.delete(P),n.current.filtered.items.delete(P);let M=A();T(4,()=>{G(),(M==null?void 0:M.getAttribute("id"))===P&&F(),E.emit()})}),group:P=>(o.current.has(P)||o.current.set(P,new Set),()=>{s.current.delete(P),o.current.delete(P)}),filter:()=>a.current.shouldFilter,label:l||e["aria-label"],getDisablePointerSelection:()=>a.current.disablePointerSelection,listId:w,inputId:k,labelId:S,listInnerRef:C}),[]);function _(P,O){var M,L;let ee=(L=(M=a.current)==null?void 0:M.filter)!=null?L:nk;return P?ee(P,n.current.search,O):0}function D(){if(!n.current.search||a.current.shouldFilter===!1)return;let P=n.current.filtered.items,O=[];n.current.filtered.groups.forEach(L=>{let ee=o.current.get(L),H=0;ee.forEach($=>{let Z=P.get($);H=Math.max(Z,H)}),O.push([L,H])});let M=C.current;Y().sort((L,ee)=>{var H,$;let Z=L.getAttribute("id"),te=ee.getAttribute("id");return((H=P.get(te))!=null?H:0)-(($=P.get(Z))!=null?$:0)}).forEach(L=>{let ee=L.closest(vl);ee?ee.appendChild(L.parentElement===ee?L:L.closest(`${vl} > *`)):M.appendChild(L.parentElement===M?L:L.closest(`${vl} > *`))}),O.sort((L,ee)=>ee[1]-L[1]).forEach(L=>{var ee;let H=(ee=C.current)==null?void 0:ee.querySelector(`${No}[${Or}="${encodeURIComponent(L[0])}"]`);H==null||H.parentElement.appendChild(H)})}function F(){let P=Y().find(M=>M.getAttribute("aria-disabled")!=="true"),O=P==null?void 0:P.getAttribute(Or);E.setState("value",O||void 0)}function G(){var P,O,M,L;if(!n.current.search||a.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let ee=0;for(let H of r.current){let $=(O=(P=s.current.get(H))==null?void 0:P.value)!=null?O:"",Z=(L=(M=s.current.get(H))==null?void 0:M.keywords)!=null?L:[],te=_($,Z);n.current.filtered.items.set(H,te),te>0&&ee++}for(let[H,$]of o.current)for(let Z of $)if(n.current.filtered.items.get(Z)>0){n.current.filtered.groups.add(H);break}n.current.filtered.count=ee}function K(){var P,O,M;let L=A();L&&(((P=L.parentElement)==null?void 0:P.firstChild)===L&&((M=(O=L.closest(No))==null?void 0:O.querySelector(tk))==null||M.scrollIntoView({block:"nearest"})),L.scrollIntoView({block:"nearest"}))}function A(){var P;return(P=C.current)==null?void 0:P.querySelector(`${Bp}[aria-selected="true"]`)}function Y(){var P;return Array.from(((P=C.current)==null?void 0:P.querySelectorAll(zp))||[])}function q(P){let O=Y()[P];O&&E.setState("value",O.getAttribute(Or))}function W(P){var O;let M=A(),L=Y(),ee=L.findIndex($=>$===M),H=L[ee+P];(O=a.current)!=null&&O.loop&&(H=ee+P<0?L[L.length-1]:ee+P===L.length?L[0]:L[ee+P]),H&&E.setState("value",H.getAttribute(Or))}function R(P){let O=A(),M=O==null?void 0:O.closest(No),L;for(;M&&!L;)M=P>0?dk(M,No):fk(M,No),L=M==null?void 0:M.querySelector(zp);L?E.setState("value",L.getAttribute(Or)):W(P)}let I=()=>q(Y().length-1),z=P=>{P.preventDefault(),P.metaKey?I():P.altKey?R(1):W(1)},J=P=>{P.preventDefault(),P.metaKey?q(0):P.altKey?R(-1):W(-1)};return p.createElement(xe.div,{ref:t,tabIndex:-1,...y,"cmdk-root":"",onKeyDown:P=>{var O;(O=y.onKeyDown)==null||O.call(y,P);let M=P.nativeEvent.isComposing||P.keyCode===229;if(!(P.defaultPrevented||M))switch(P.key){case"n":case"j":{x&&P.ctrlKey&&z(P);break}case"ArrowDown":{z(P);break}case"p":case"k":{x&&P.ctrlKey&&J(P);break}case"ArrowUp":{J(P);break}case"Home":{P.preventDefault(),q(0);break}case"End":{P.preventDefault(),I();break}case"Enter":{P.preventDefault();let L=A();if(L){let ee=new Event(bl);L.dispatchEvent(ee)}}}}},p.createElement("label",{"cmdk-label":"",htmlFor:j.inputId,id:j.labelId,style:mk},l),Js(e,P=>p.createElement(Up.Provider,{value:E},p.createElement(Hp.Provider,{value:j},P))))}),rk=p.forwardRef((e,t)=>{var n,r;let o=Nt(),s=p.useRef(null),i=p.useContext(Wp),a=Ao(),l=Kp(e),c=(r=(n=l.current)==null?void 0:n.forceMount)!=null?r:i==null?void 0:i.forceMount;ur(()=>{if(!c)return a.item(o,i==null?void 0:i.id)},[c]);let d=qp(o,s,[e.value,e.children,s],e.keywords),h=wl(),m=Gn(T=>T.value&&T.value===d.current),f=Gn(T=>c||a.filter()===!1?!0:T.search?T.filtered.items.get(o)>0:!0);p.useEffect(()=>{let T=s.current;if(!(!T||e.disabled))return T.addEventListener(bl,v),()=>T.removeEventListener(bl,v)},[f,e.onSelect,e.disabled]);function v(){var T,E;g(),(E=(T=l.current).onSelect)==null||E.call(T,d.current)}function g(){h.setState("value",d.current,!0)}if(!f)return null;let{disabled:x,value:y,onSelect:w,forceMount:S,keywords:k,...C}=e;return p.createElement(xe.div,{ref:On(s,t),...C,id:o,"cmdk-item":"",role:"option","aria-disabled":!!x,"aria-selected":!!m,"data-disabled":!!x,"data-selected":!!m,onPointerMove:x||a.getDisablePointerSelection()?void 0:g,onClick:x?void 0:v},e.children)}),ok=p.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:o,...s}=e,i=Nt(),a=p.useRef(null),l=p.useRef(null),c=Nt(),d=Ao(),h=Gn(f=>o||d.filter()===!1?!0:f.search?f.filtered.groups.has(i):!0);ur(()=>d.group(i),[]),qp(i,a,[e.value,e.heading,l]);let m=p.useMemo(()=>({id:i,forceMount:o}),[o]);return p.createElement(xe.div,{ref:On(a,t),...s,"cmdk-group":"",role:"presentation",hidden:h?void 0:!0},n&&p.createElement("div",{ref:l,"cmdk-group-heading":"","aria-hidden":!0,id:c},n),Js(e,f=>p.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?c:void 0},p.createElement(Wp.Provider,{value:m},f))))}),sk=p.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,o=p.useRef(null),s=Gn(i=>!i.search);return!n&&!s?null:p.createElement(xe.div,{ref:On(o,t),...r,"cmdk-separator":"",role:"separator"})}),ik=p.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,o=e.value!=null,s=wl(),i=Gn(c=>c.search),a=Gn(c=>c.selectedItemId),l=Ao();return p.useEffect(()=>{e.value!=null&&s.setState("search",e.value)},[e.value]),p.createElement(xe.input,{ref:t,...r,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":l.listId,"aria-labelledby":l.labelId,"aria-activedescendant":a,id:l.inputId,type:"text",value:o?e.value:i,onChange:c=>{o||s.setState("search",c.target.value),n==null||n(c.target.value)}})}),ak=p.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...o}=e,s=p.useRef(null),i=p.useRef(null),a=Gn(c=>c.selectedItemId),l=Ao();return p.useEffect(()=>{if(i.current&&s.current){let c=i.current,d=s.current,h,m=new ResizeObserver(()=>{h=requestAnimationFrame(()=>{let f=c.offsetHeight;d.style.setProperty("--cmdk-list-height",f.toFixed(1)+"px")})});return m.observe(c),()=>{cancelAnimationFrame(h),m.unobserve(c)}}},[]),p.createElement(xe.div,{ref:On(s,t),...o,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":a,"aria-label":r,id:l.listId},Js(e,c=>p.createElement("div",{ref:On(i,l.listInnerRef),"cmdk-list-sizer":""},c)))}),lk=p.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:o,contentClassName:s,container:i,...a}=e;return p.createElement(Za,{open:n,onOpenChange:r},p.createElement(Qa,{container:i},p.createElement(To,{"cmdk-overlay":"",className:o}),p.createElement(ko,{"aria-label":e.label,"cmdk-dialog":"",className:s},p.createElement(Vp,{ref:t,...a}))))}),ck=p.forwardRef((e,t)=>Gn(n=>n.filtered.count===0)?p.createElement(xe.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),uk=p.forwardRef((e,t)=>{let{progress:n,children:r,label:o="Loading...",...s}=e;return p.createElement(xe.div,{ref:t,...s,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":o},Js(e,i=>p.createElement("div",{"aria-hidden":!0},i)))}),Ut=Object.assign(Vp,{List:ak,Item:rk,Input:ik,Group:ok,Separator:sk,Dialog:lk,Empty:ck,Loading:uk});function dk(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function fk(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function Kp(e){let t=p.useRef(e);return ur(()=>{t.current=e}),t}var ur=typeof window>"u"?p.useEffect:p.useLayoutEffect;function Dr(e){let t=p.useRef();return t.current===void 0&&(t.current=e()),t}function Gn(e){let t=wl(),n=()=>e(t.snapshot());return p.useSyncExternalStore(t.subscribe,n,n)}function qp(e,t,n,r=[]){let o=p.useRef(),s=Ao();return ur(()=>{var i;let a=(()=>{var c;for(let d of n){if(typeof d=="string")return d.trim();if(typeof d=="object"&&"current"in d)return d.current?(c=d.current.textContent)==null?void 0:c.trim():o.current}})(),l=r.map(c=>c.trim());s.value(e,a,l),(i=t.current)==null||i.setAttribute(Or,a),o.current=a}),o}var hk=()=>{let[e,t]=p.useState(),n=Dr(()=>new Map);return ur(()=>{n.current.forEach(r=>r()),n.current=new Map},[e]),(r,o)=>{n.current.set(r,o),t({})}};function pk(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function Js({asChild:e,children:t},n){return e&&p.isValidElement(t)?p.cloneElement(pk(t),{ref:t.ref},n(t.props.children)):n(t)}var mk={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const yl=p.forwardRef(({className:e,...t},n)=>u.jsx(Ut,{ref:n,className:oe("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));yl.displayName=Ut.displayName;const Sl=p.forwardRef(({className:e,...t},n)=>u.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[u.jsx(ue.Search,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),u.jsx(Ut.Input,{ref:n,className:oe("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),...t})]}));Sl.displayName=Ut.Input.displayName;const Cl=p.forwardRef(({className:e,...t},n)=>u.jsx(Ut.List,{ref:n,className:oe("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));Cl.displayName=Ut.List.displayName;const Tl=p.forwardRef((e,t)=>u.jsx(Ut.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));Tl.displayName=Ut.Empty.displayName;const kl=p.forwardRef(({className:e,...t},n)=>u.jsx(Ut.Group,{ref:n,className:oe("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",e),...t}));kl.displayName=Ut.Group.displayName;const gk=p.forwardRef(({className:e,...t},n)=>u.jsx(Ut.Separator,{ref:n,className:oe("-mx-1 h-px bg-border",e),...t}));gk.displayName=Ut.Separator.displayName;const El=p.forwardRef(({className:e,...t},n)=>u.jsx(Ut.Item,{ref:n,className:oe("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected='true']:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50",e),...t}));El.displayName=Ut.Item.displayName;function Il(e,[t,n]){return Math.min(n,Math.max(t,e))}function xk(e,t){return p.useReducer((n,r)=>t[n][r]??n,e)}var Nl="ScrollArea",[Gp,RN]=ln(Nl),[vk,rn]=Gp(Nl),Yp=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,l]=p.useState(null),[c,d]=p.useState(null),[h,m]=p.useState(null),[f,v]=p.useState(null),[g,x]=p.useState(null),[y,w]=p.useState(0),[S,k]=p.useState(0),[C,T]=p.useState(!1),[E,j]=p.useState(!1),_=De(t,F=>l(F)),D=Jo(o);return u.jsx(vk,{scope:n,type:r,dir:D,scrollHideDelay:s,scrollArea:a,viewport:c,onViewportChange:d,content:h,onContentChange:m,scrollbarX:f,onScrollbarXChange:v,scrollbarXEnabled:C,onScrollbarXEnabledChange:T,scrollbarY:g,onScrollbarYChange:x,scrollbarYEnabled:E,onScrollbarYEnabledChange:j,onCornerWidthChange:w,onCornerHeightChange:k,children:u.jsx(xe.div,{dir:D,...i,ref:_,style:{position:"relative","--radix-scroll-area-corner-width":y+"px","--radix-scroll-area-corner-height":S+"px",...e.style}})})});Yp.displayName=Nl;var Xp="ScrollAreaViewport",Jp=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=rn(Xp,n),a=p.useRef(null),l=De(t,a,i.onViewportChange);return u.jsxs(u.Fragment,{children:[u.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}),u.jsx(xe.div,{"data-radix-scroll-area-viewport":"",...s,ref:l,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:u.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});Jp.displayName=Xp;var En="ScrollAreaScrollbar",Al=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=rn(En,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:i}=o,a=e.orientation==="horizontal";return p.useEffect(()=>(a?s(!0):i(!0),()=>{a?s(!1):i(!1)}),[a,s,i]),o.type==="hover"?u.jsx(bk,{...r,ref:t,forceMount:n}):o.type==="scroll"?u.jsx(wk,{...r,ref:t,forceMount:n}):o.type==="auto"?u.jsx(Zp,{...r,ref:t,forceMount:n}):o.type==="always"?u.jsx(jl,{...r,ref:t}):null});Al.displayName=En;var bk=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=rn(En,e.__scopeScrollArea),[s,i]=p.useState(!1);return p.useEffect(()=>{const a=o.scrollArea;let l=0;if(a){const c=()=>{window.clearTimeout(l),i(!0)},d=()=>{l=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",c),a.addEventListener("pointerleave",d),()=>{window.clearTimeout(l),a.removeEventListener("pointerenter",c),a.removeEventListener("pointerleave",d)}}},[o.scrollArea,o.scrollHideDelay]),u.jsx(zt,{present:n||s,children:u.jsx(Zp,{"data-state":s?"visible":"hidden",...r,ref:t})})}),wk=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=rn(En,e.__scopeScrollArea),s=e.orientation==="horizontal",i=ti(()=>l("SCROLL_END"),100),[a,l]=xk("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return p.useEffect(()=>{if(a==="idle"){const c=window.setTimeout(()=>l("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(c)}},[a,o.scrollHideDelay,l]),p.useEffect(()=>{const c=o.viewport,d=s?"scrollLeft":"scrollTop";if(c){let h=c[d];const m=()=>{const f=c[d];h!==f&&(l("SCROLL"),i()),h=f};return c.addEventListener("scroll",m),()=>c.removeEventListener("scroll",m)}},[o.viewport,s,l,i]),u.jsx(zt,{present:n||a!=="hidden",children:u.jsx(jl,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:ce(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:ce(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),Zp=p.forwardRef((e,t)=>{const n=rn(En,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=p.useState(!1),a=e.orientation==="horizontal",l=ti(()=>{if(n.viewport){const c=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?c:d)}},10);return Lr(n.viewport,l),Lr(n.content,l),u.jsx(zt,{present:r||s,children:u.jsx(jl,{"data-state":s?"visible":"hidden",...o,ref:t})})}),jl=p.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=rn(En,e.__scopeScrollArea),s=p.useRef(null),i=p.useRef(0),[a,l]=p.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),c=rm(a.viewport,a.content),d={...r,sizes:a,onSizesChange:l,hasThumb:c>0&&c<1,onThumbChange:m=>s.current=m,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:m=>i.current=m};function h(m,f){return Ek(m,i.current,a,f)}return n==="horizontal"?u.jsx(yk,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollLeft,f=om(m,a,o.dir);s.current.style.transform=`translate3d(${f}px, 0, 0)`}},onWheelScroll:m=>{o.viewport&&(o.viewport.scrollLeft=m)},onDragScroll:m=>{o.viewport&&(o.viewport.scrollLeft=h(m,o.dir))}}):n==="vertical"?u.jsx(Sk,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollTop,f=om(m,a);s.current.style.transform=`translate3d(0, ${f}px, 0)`}},onWheelScroll:m=>{o.viewport&&(o.viewport.scrollTop=m)},onDragScroll:m=>{o.viewport&&(o.viewport.scrollTop=h(m))}}):null}),yk=p.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=rn(En,e.__scopeScrollArea),[i,a]=p.useState(),l=p.useRef(null),c=De(t,l,s.onScrollbarXChange);return p.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(em,{"data-orientation":"horizontal",...o,ref:c,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":ei(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.x),onDragScroll:d=>e.onDragScroll(d.x),onWheelScroll:(d,h)=>{if(s.viewport){const m=s.viewport.scrollLeft+d.deltaX;e.onWheelScroll(m),im(m,h)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:l.current.clientWidth,paddingStart:Qs(i.paddingLeft),paddingEnd:Qs(i.paddingRight)}})}})}),Sk=p.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=rn(En,e.__scopeScrollArea),[i,a]=p.useState(),l=p.useRef(null),c=De(t,l,s.onScrollbarYChange);return p.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(em,{"data-orientation":"vertical",...o,ref:c,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":ei(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.y),onDragScroll:d=>e.onDragScroll(d.y),onWheelScroll:(d,h)=>{if(s.viewport){const m=s.viewport.scrollTop+d.deltaY;e.onWheelScroll(m),im(m,h)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:l.current.clientHeight,paddingStart:Qs(i.paddingTop),paddingEnd:Qs(i.paddingBottom)}})}})}),[Ck,Qp]=Gp(En),em=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:l,onDragScroll:c,onWheelScroll:d,onResize:h,...m}=e,f=rn(En,n),[v,g]=p.useState(null),x=De(t,_=>g(_)),y=p.useRef(null),w=p.useRef(""),S=f.viewport,k=r.content-r.viewport,C=ft(d),T=ft(l),E=ti(h,10);function j(_){if(y.current){const D=_.clientX-y.current.left,F=_.clientY-y.current.top;c({x:D,y:F})}}return p.useEffect(()=>{const _=D=>{const F=D.target;(v==null?void 0:v.contains(F))&&C(D,k)};return document.addEventListener("wheel",_,{passive:!1}),()=>document.removeEventListener("wheel",_,{passive:!1})},[S,v,k,C]),p.useEffect(T,[r,T]),Lr(v,E),Lr(f.content,E),u.jsx(Ck,{scope:n,scrollbar:v,hasThumb:o,onThumbChange:ft(s),onThumbPointerUp:ft(i),onThumbPositionChange:T,onThumbPointerDown:ft(a),children:u.jsx(xe.div,{...m,ref:x,style:{position:"absolute",...m.style},onPointerDown:ce(e.onPointerDown,_=>{_.button===0&&(_.target.setPointerCapture(_.pointerId),y.current=v.getBoundingClientRect(),w.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",f.viewport&&(f.viewport.style.scrollBehavior="auto"),j(_))}),onPointerMove:ce(e.onPointerMove,j),onPointerUp:ce(e.onPointerUp,_=>{const D=_.target;D.hasPointerCapture(_.pointerId)&&D.releasePointerCapture(_.pointerId),document.body.style.webkitUserSelect=w.current,f.viewport&&(f.viewport.style.scrollBehavior=""),y.current=null})})})}),Zs="ScrollAreaThumb",tm=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Qp(Zs,e.__scopeScrollArea);return u.jsx(zt,{present:n||o.hasThumb,children:u.jsx(Tk,{ref:t,...r})})}),Tk=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=rn(Zs,n),i=Qp(Zs,n),{onThumbPositionChange:a}=i,l=De(t,h=>i.onThumbChange(h)),c=p.useRef(void 0),d=ti(()=>{c.current&&(c.current(),c.current=void 0)},100);return p.useEffect(()=>{const h=s.viewport;if(h){const m=()=>{if(d(),!c.current){const f=Ik(h,a);c.current=f,a()}};return a(),h.addEventListener("scroll",m),()=>h.removeEventListener("scroll",m)}},[s.viewport,d,a]),u.jsx(xe.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:ce(e.onPointerDownCapture,h=>{const f=h.target.getBoundingClientRect(),v=h.clientX-f.left,g=h.clientY-f.top;i.onThumbPointerDown({x:v,y:g})}),onPointerUp:ce(e.onPointerUp,i.onThumbPointerUp)})});tm.displayName=Zs;var Pl="ScrollAreaCorner",nm=p.forwardRef((e,t)=>{const n=rn(Pl,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?u.jsx(kk,{...e,ref:t}):null});nm.displayName=Pl;var kk=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=rn(Pl,n),[s,i]=p.useState(0),[a,l]=p.useState(0),c=!!(s&&a);return Lr(o.scrollbarX,()=>{var h;const d=((h=o.scrollbarX)==null?void 0:h.offsetHeight)||0;o.onCornerHeightChange(d),l(d)}),Lr(o.scrollbarY,()=>{var h;const d=((h=o.scrollbarY)==null?void 0:h.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),c?u.jsx(xe.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 Qs(e){return e?parseInt(e,10):0}function rm(e,t){const n=e/t;return isNaN(n)?0:n}function ei(e){const t=rm(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function Ek(e,t,n,r="ltr"){const o=ei(n),s=o/2,i=t||s,a=o-i,l=n.scrollbar.paddingStart+i,c=n.scrollbar.size-n.scrollbar.paddingEnd-a,d=n.content-n.viewport,h=r==="ltr"?[0,d]:[d*-1,0];return sm([l,c],h)(e)}function om(e,t,n="ltr"){const r=ei(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],c=Il(e,l);return sm([0,i],[0,a])(c)}function sm(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 im(e,t){return e>0&&e<t}var Ik=(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 ti(e,t){const n=ft(e),r=p.useRef(0);return p.useEffect(()=>()=>window.clearTimeout(r.current),[]),p.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function Lr(e,t){const n=ft(t);yt(()=>{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 am=Yp,Nk=Jp,Ak=nm;const _l=p.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(am,{ref:r,className:oe("relative overflow-hidden",e),...n,children:[u.jsx(Nk,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),u.jsx(lm,{}),u.jsx(Ak,{})]}));_l.displayName=am.displayName;const lm=p.forwardRef(({className:e,orientation:t="vertical",...n},r)=>u.jsx(Al,{ref:r,orientation:t,className:oe("flex touch-none select-none transition-colors",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...n,children:u.jsx(tm,{className:"relative flex-1 rounded-full bg-border"})}));lm.displayName=Al.displayName;const Ml=p.forwardRef(({className:e,type:t,...n},r)=>u.jsx("input",{type:t,className:oe("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:r,...n}));Ml.displayName="Input";const jk="group relative p-3 rounded-lg cursor-pointer transition-colors border text-gray-900 dark:text-slate-100",Pk="bg-slate-700 border-slate-600 hover:bg-slate-600",_k="bg-slate-600 border-slate-500";function cm({thread:e,isActive:t,editingThreadId:n,editingTitle:r,onSelect:o,onStartEditing:s,onEditingTitleChange:i,onSaveEditing:a,onCancelEditing:l,onShare:c,onDelete:d,showEditTitle:h,showDeleteButton:m,formatDate:f,getDisplayThreadTitle:v,secondaryLine:g,itemClassName:x,activeItemClassName:y}){const w=n===e.threadId,S=t?`${y??_k}`:`${x??Pk}`,k=C=>{C.stopPropagation(),o(e.threadId)};return u.jsxs("div",{onClick:k,className:`${jk} ${S}`,children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("div",{className:"flex-1 min-w-0",children:w?u.jsxs("div",{className:"flex items-center gap-2",onClick:C=>C.stopPropagation(),children:[u.jsx(Ml,{value:r,onChange:C=>i(C.target.value),onKeyDown:C=>{C.key==="Enter"?a(e.threadId):C.key==="Escape"&&l()},className:"h-6 text-sm",autoFocus:!0}),u.jsx(Xe,{variant:"ghost",size:"sm",onClick:()=>a(e.threadId),className:"h-6 w-6 p-0",children:u.jsx(ue.Check,{size:12})}),u.jsx(Xe,{variant:"ghost",size:"sm",onClick:l,className:"h-6 w-6 p-0",children:u.jsx(ue.X,{size:12})})]}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"font-medium text-sm truncate text-gray-900 dark:text-slate-100",children:v(e)}),u.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-slate-400 mt-1",children:[u.jsx(ue.Calendar,{size:10}),u.jsx("span",{children:f(e.updatedAt||e.createdAt)})]}),g&&u.jsx("div",{className:"text-[11px] text-muted-foreground mt-1",children:g})]})}),u.jsx("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2",children:u.jsxs(Cs,{children:[u.jsx(Ts,{asChild:!0,children:u.jsx(Xe,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",children:u.jsx(ue.MoreHorizontal,{size:12})})}),u.jsxs(ho,{align:"end",sideOffset:6,className:"w-44",children:[u.jsxs(Bn,{onClick:C=>{C.preventDefault(),c(e.threadId)},children:[u.jsx(ue.Share2,{className:"mr-2 h-4 w-4"}),"Share thread"]}),h&&n!==e.threadId&&u.jsxs(Bn,{onClick:C=>{C.preventDefault(),s(e,C)},children:[u.jsx(ue.Edit3,{className:"mr-2 h-4 w-4"}),"Rename"]}),m&&d&&u.jsxs(Bn,{className:"text-red-400 hover:text-red-300",onClick:C=>{C.preventDefault(),d(e.threadId,C)},children:[u.jsx(ue.Trash2,{className:"mr-2 h-4 w-4"}),"Delete"]})]})]})})]}),t&&u.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-1 h-8 bg-blue-400 rounded-r"})]})}const um=25,dm="thread-manager-view",Mk=e=>e==="default"||e==="shared",Rk=()=>{if(typeof window>"u")return null;try{const e=window.localStorage.getItem(dm);if(Mk(e))return e}catch{}return null};function fm({defaultView:e}={}){const[t,n]=b.useState(()=>Rk()??e??"default");b.useEffect(()=>{if(!(typeof window>"u"))try{window.localStorage.setItem(dm,t)}catch{}},[t]);const r=b.useCallback(o=>{n(o)},[]);return{view:t,setView:r}}const Ok=[{key:"default",label:"My chats"},{key:"shared",label:"Shared with you"}];function ni({className:e="",showCreateButton:t=!0,showDeleteButton:n=!0,showEditTitle:r=!0,maxHeight:o="400px",customStyles:s={},currentThreadId:i=null,navigateToThread:a,onThreadSelect:l,onThreadCreate:c,onThreadDelete:d,view:h,defaultView:m,onViewChange:f,viewOptions:v,viewState:g,showHeader:x=!0,shareTargets:y,isLoadingShareTargets:w,shareTargetFilter:S}){const{threads:k,sharedThreads:C,currentThreadId:T,setCurrentThreadId:E,isLoading:j,isLoadingSharedThreads:_,actions:D,shareInFlight:F,shareStatus:G,clearShareStatus:K}=xr(),{createThread:A,deleteThread:Y,renameThread:q,shareThread:W}=D,{loadThread:R}=eo(),I=i??T,[z,J]=b.useState(Array.isArray(k)?k:[]),P=b.useRef(z.length>0),O=b.useRef(null),M=b.useRef(0),[L,ee]=b.useState(null),[H,$]=b.useState(""),[Z,te]=b.useState(!1),[Q,U]=b.useState(!1),[le,ie]=b.useState(null),[ge,we]=b.useState(""),Ce=v&&v.length>0?v:Ok,Ae=fm({defaultView:m}),Ee=g??Ae,st=h??Ee.view,lt=b.useCallback(X=>{h||Ee.setView(X),f==null||f(X)},[h,f,Ee]),St=Ce.find(X=>X.key===st)??Ce[0],Oe=X=>{ie(X),we(""),U(!0)},qe=()=>{U(!1),ie(null),we(""),K()},We=b.useCallback(async X=>{if(!(!le||F)&&X.id)try{await W(le,X.id),setTimeout(()=>qe(),600)}catch(fe){console.error("Failed to share thread:",fe)}},[qe,F,le,W]),je=b.useMemo(()=>{const X=y??[],fe=ge.trim().toLowerCase();return fe?S?X.filter(He=>S(He,fe)):X.filter(He=>`${He.label} ${He.secondaryLabel??""}`.toLowerCase().includes(fe)):X},[y,ge,S]),_e=st==="shared",ct=_e?C:z,kt=_e?_:j,nt=_e?"No shared conversations yet":"No conversations yet",Et=X=>{const fe=X.sharedAt?` • ${$e(X.sharedAt)}`:"";return`Shared by ${X.sharedByUserId}${fe}`},bt=X=>"sharedByUserId"in X;b.useEffect(()=>{const X=Array.isArray(k)?k:[];if(X.length>0){P.current=!0,J(X);return}j||(P.current=!1,J(X))},[k,j]),b.useEffect(()=>{if(!O.current)return;const X=O.current.querySelector("[data-radix-scroll-area-viewport]");if(!X)return;let fe=null,He=null;return fe=requestAnimationFrame(()=>{He=requestAnimationFrame(()=>{X.scrollTop=M.current})}),()=>{fe!==null&&cancelAnimationFrame(fe),He!==null&&cancelAnimationFrame(He)}},[z]);const wt=async X=>{try{E(X),await R(X),a==null||a(X),l==null||l(X)}catch(fe){console.error("Failed to select thread:",fe)}},Ct=async()=>{try{te(!0);const X=await A();X&&(c==null||c(X),a==null||a(X))}catch(X){console.error("Failed to create thread:",X)}finally{te(!1)}},on=async(X,fe)=>{if(fe.stopPropagation(),!!confirm("Delete this thread?")){if(O.current){const He=O.current.querySelector("[data-radix-scroll-area-viewport]");He&&(M.current=He.scrollTop)}try{await Y(X),d==null||d(X)}catch(He){console.error("Failed to delete thread:",He)}}},Tt=(X,fe)=>{fe.stopPropagation(),ee(X.threadId),$(X.title||`Thread ${X.threadId.slice(0,8)}`)},Lt=async X=>{if(H.trim())try{await q(X,H.trim()),ee(null),$("")}catch(fe){console.error("Failed to update title:",fe)}},_t=()=>{ee(null),$("")},$e=X=>{if(!X)return"";try{const fe=new Date(X),ae=new Date().getTime()-fe.getTime(),me=Math.floor(ae/(1e3*60*60*24));return me===0?fe.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):me===1?"Yesterday":me<7?`${me} days ago`:fe.toLocaleDateString()}catch{return""}},ze=X=>X.title||`Thread ${X.threadId.slice(0,8)}`,Mt=X=>{const fe=ze(X);return fe.length<=um?fe:`${fe.slice(0,um)}...`};return u.jsxs("div",{className:`flex flex-col h-full ${e} ${s.container||""}`,children:[x&&u.jsxs("div",{className:s.header||"flex flex-col gap-2 px-1 py-0 border border-slate-200 bg-white dark:border-slate-700 dark:bg-slate-900 shadow-sm",children:[t&&u.jsx("div",{className:"flex justify-end",children:u.jsxs(Xe,{onClick:Ct,disabled:Z||j,className:s.createButton||"px-3 py-2 gap-1",size:"sm",variant:"ghost",title:Z?"Creating...":"New Chat",children:[u.jsx(ue.Edit3,{size:16}),u.jsx("span",{children:"New chat"})]})}),u.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-slate-700 dark:text-slate-200 uppercase tracking-wide leading-tight",children:[u.jsx("span",{children:"Current View"}),u.jsxs(Cs,{children:[u.jsx(Ts,{asChild:!0,children:u.jsx(Xe,{variant:"outline",size:"sm",className:"text-[11px] text-slate-700 dark:text-slate-200 border border-slate-300 dark:border-slate-600 bg-white dark:bg-slate-900 hover:bg-slate-50 dark:hover:bg-slate-800 px-2 py-0",children:St.label})}),u.jsx(ho,{align:"start",sideOffset:6,className:"w-40",children:Ce.map(X=>u.jsxs(Bn,{className:"justify-between text-[12px]",onClick:fe=>{fe.preventDefault(),lt(X.key)},children:[u.jsx("span",{children:X.label}),st===X.key&&u.jsx(ue.Check,{className:"h-3 w-3"})]},X.key))})]})]})]}),u.jsx(_l,{ref:O,className:`flex-1 min-h-0 ${s.threadList||""}`,style:o?{maxHeight:o}:void 0,children:u.jsx("div",{className:"p-2 space-y-1 pb-4",children:kt?u.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-8 text-slate-400",children:[u.jsx(ue.Loader2,{className:"h-5 w-5 animate-spin"}),u.jsx("span",{className:"text-sm",children:"Loading threads…"})]}):ct.length===0?u.jsxs("div",{className:"text-center py-8 text-slate-400",children:[u.jsx(ue.MessageSquare,{className:"w-8 h-8 mx-auto mb-2 opacity-40 text-slate-500"}),u.jsx("p",{className:"text-sm text-slate-500",children:nt})]}):ct.slice().sort((X,fe)=>new Date(fe.updatedAt||fe.createdAt||"").getTime()-new Date(X.updatedAt||X.createdAt||"").getTime()).map(X=>u.jsx(cm,{thread:X,isActive:I===X.threadId,editingThreadId:L,editingTitle:H,onSelect:wt,onStartEditing:Tt,onEditingTitleChange:fe=>$(fe),onSaveEditing:Lt,onCancelEditing:_t,onShare:()=>Oe(X.threadId),onDelete:on,showEditTitle:r,showDeleteButton:n,formatDate:$e,getDisplayThreadTitle:Mt,secondaryLine:_e&&bt(X)?Et(X):void 0,itemClassName:s.threadItem,activeItemClassName:s.activeThread},X.threadId))})}),u.jsx(el,{open:Q,onOpenChange:X=>!X&&qe(),children:u.jsxs(zs,{className:"max-w-md p-0",children:[u.jsx(Hs,{children:u.jsx(Us,{children:"Share thread"})}),u.jsxs(yl,{children:[u.jsx(Sl,{autoFocus:!0,value:ge,onValueChange:X=>we(X),placeholder:"Search for recipients..."}),u.jsxs(Cl,{children:[G&&u.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-xs text-muted-foreground",children:[F&&u.jsx(ue.Loader2,{className:"h-3 w-3 animate-spin"}),u.jsx("span",{className:G.startsWith("Failed")?"text-red-500":G.startsWith("Shared")?"text-emerald-500":"text-slate-600 dark:text-slate-400",children:G})]}),u.jsx(Tl,{children:w?u.jsxs("span",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(ue.Loader2,{className:"h-4 w-4 animate-spin"}),"Loading recipients…"]}):"No matching recipients found"}),je.length>0&&u.jsx(kl,{heading:"Recipients",children:je.map(X=>u.jsx(El,{onSelect:()=>We(X),children:u.jsxs("div",{className:"flex flex-col items-start text-sm",children:[u.jsx("span",{className:"font-medium",children:X.label}),X.secondaryLabel&&u.jsx("span",{className:"text-xs text-muted-foreground",children:X.secondaryLabel})]})},X.id))})]})]})]})})]})}function Dk({layout:e="sidebar",layoutSize:t="desktop",showThreads:n=!0,className:r="",customStyles:o={},...s}){const i=c=>{const d="h-full";switch(c){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=c=>({"--chat-sidebar-width":c==="phone"?"100%":c==="tablet"?"280px":c==="half-screen"?"240px":"320px","--chat-message-max-width":c==="phone"?"95%":c==="tablet"?"90%":c==="half-screen"?"85%":"80%","--chat-input-height":c==="phone"?"120px":"100px"}),l=b.useCallback(c=>{var d;(d=s.onThreadChange)==null||d.call(s,c)},[s]);return e==="fullscreen"?u.jsx(br,{...s,onThreadChange:l,children:u.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:u.jsx(Rr,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?u.jsx(br,{...s,onThreadChange:l,children:u.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:u.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[n&&u.jsx("div",{className:`w-80 border-r flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:u.jsx(ni,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),u.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:u.jsx(Rr,{onError:s.onError,enableFileUpload:!0})})]})})}):u.jsx(br,{...s,onThreadChange:l,children:u.jsxs("div",{className:`${i(t)} flex overflow-hidden ${r} ${o.container||""}`,style:a(t),children:[n&&u.jsx("div",{className:`w-80 border-r bg-gray-50 flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:u.jsx(ni,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),u.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:u.jsx(Rr,{onError:s.onError,enableFileUpload:!0})})]})})}function Lk({apiConfig:e,className:t="",onError:n}){return u.jsx(br,{apiConfig:e,onError:n,children:u.jsx("div",{className:`h-full ${t}`,children:u.jsx(Rr,{})})})}function $k({placeholder:e,onMessageSent:t}){const[n,r]=b.useState("chat");return u.jsxs("div",{className:"flex flex-col h-full",children:[u.jsxs("div",{className:"flex border-b border-gray-200 bg-gray-50",children:[u.jsx("button",{onClick:()=>r("chat"),className:`flex-1 px-3 py-2 text-sm font-medium transition-colors ${n==="chat"?"border-b-2 border-slate-800 text-slate-800 bg-white":"text-gray-600 hover:text-gray-800"}`,children:u.jsxs("div",{className:"flex items-center justify-center gap-2",children:[u.jsx(ue.MessageSquare,{size:14}),"Chat"]})}),u.jsx("button",{onClick:()=>r("threads"),className:`flex-1 px-3 py-2 text-sm font-medium transition-colors ${n==="threads"?"border-b-2 border-slate-800 text-slate-800 bg-white":"text-gray-600 hover:text-gray-800"}`,children:u.jsxs("div",{className:"flex items-center justify-center gap-2",children:[u.jsx(ue.History,{size:14}),"History"]})})]}),u.jsx("div",{className:"flex-1 min-h-0",children:n==="chat"?u.jsx(Rr,{placeholder:e??"Ask Serti AI anything...",autoFocus:!0,className:"h-full",onMessageSent:t}):u.jsx(ni,{showCreateButton:!0,className:"h-full",onThreadSelect:()=>r("chat")})})]})}function Fk({className:e="",placeholder:t,isAuthenticated:n=!0,onMessageSent:r,widgetTitle:o="Serti AI Navigator",widgetSubtitle:s="AI-Powered Assistant",...i}){const[a,l]=b.useState(!1);return n?u.jsx(br,{...i,children:u.jsx("div",{className:`fixed bottom-6 right-6 z-[9999] transition-all duration-300 ${e}`,children:u.jsxs("div",{className:`w-96 bg-white rounded-xl shadow-2xl border border-gray-200 overflow-hidden relative ${a?"scale-75":"scale-100"}`,children:[u.jsx("div",{className:"bg-slate-800 text-white p-4 flex-shrink-0",children:u.jsxs("div",{className:"flex items-center justify-between gap-3",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsxs("div",{className:"relative h-10 w-10 rounded-full bg-gradient-to-br from-slate-500 to-slate-700 border border-white/30 flex items-center justify-center text-white text-sm font-bold",children:["S",u.jsx("span",{className:"absolute -bottom-0.5 -right-0.5 h-3 w-3 rounded-full border-2 border-slate-800 bg-emerald-400"})]}),u.jsxs("div",{className:"flex flex-col",children:[u.jsx("h3",{className:"text-lg font-semibold leading-tight",children:o}),u.jsx("p",{className:"text-xs text-white/70",children:s})]}),u.jsx("span",{className:"ml-2 inline-flex items-center justify-center rounded-full bg-red-500 px-2 py-0.5 text-[11px] font-semibold leading-none text-white",children:"1"})]}),u.jsxs("div",{className:"flex items-center gap-1",children:[u.jsx(Xe,{variant:"ghost",size:"sm",className:"text-white hover:bg-white/10 h-8 w-8 p-0",title:"Options",children:u.jsx(ue.MoreHorizontal,{size:16})}),u.jsx(Xe,{variant:"ghost",size:"sm",className:"text-white hover:bg-white/10 h-8 w-8 p-0",title:"Compose",children:u.jsx(ue.Edit3,{size:16})}),u.jsx(Xe,{variant:"ghost",size:"sm",onClick:c=>{c.stopPropagation(),l(d=>!d)},className:"text-white hover:bg-white/10 h-8 w-8 p-0",title:a?"Maximize":"Minimize",children:a?u.jsx(ue.Maximize2,{size:14}):u.jsx(ue.Minimize2,{size:14})})]})]})}),!a&&u.jsx("div",{className:"h-96 flex flex-col",children:u.jsx($k,{placeholder:t,onMessageSent:r})})]})})}):null}function Bk({label:e="New chat",children:t,className:n,variant:r="ghost",size:o="sm",...s}){return u.jsxs(Xe,{variant:r,size:o,className:oe("gap-2 rounded-full px-3 font-semibold transition-all hover:scale-[1.01]",n),...s,children:[u.jsx(ue.Edit3,{size:16}),t??e]})}var zk="Label",hm=p.forwardRef((e,t)=>u.jsx(xe.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())}}));hm.displayName=zk;var pm=hm;const Hk=zr.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),mm=p.forwardRef(({className:e,...t},n)=>u.jsx(pm,{ref:n,className:oe(Hk(),e),...t}));mm.displayName=pm.displayName;function gm(e){const t=p.useRef({value:e,previous:e});return p.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var xm=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),Uk="VisuallyHidden",ri=p.forwardRef((e,t)=>u.jsx(xe.span,{...e,ref:t,style:{...xm,...e.style}}));ri.displayName=Uk;var Wk=ri,Vk=[" ","Enter","ArrowUp","ArrowDown"],Kk=[" ","Enter"],dr="Select",[oi,si,qk]=Xo(dr),[$r,ON]=ln(dr,[qk,Er]),ii=Er(),[Gk,Yn]=$r(dr),[Yk,Xk]=$r(dr),vm=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:l,dir:c,name:d,autoComplete:h,disabled:m,required:f,form:v}=e,g=ii(t),[x,y]=p.useState(null),[w,S]=p.useState(null),[k,C]=p.useState(!1),T=Jo(c),[E,j]=Dn({prop:r,defaultProp:o??!1,onChange:s,caller:dr}),[_,D]=Dn({prop:i,defaultProp:a,onChange:l,caller:dr}),F=p.useRef(null),G=x?v||!!x.closest("form"):!0,[K,A]=p.useState(new Set),Y=Array.from(K).map(q=>q.props.value).join(";");return u.jsx(sa,{...g,children:u.jsxs(Gk,{required:f,scope:t,trigger:x,onTriggerChange:y,valueNode:w,onValueNodeChange:S,valueNodeHasChildren:k,onValueNodeHasChildrenChange:C,contentId:Nt(),value:_,onValueChange:D,open:E,onOpenChange:j,dir:T,triggerPointerDownPosRef:F,disabled:m,children:[u.jsx(oi.Provider,{scope:t,children:u.jsx(Yk,{scope:e.__scopeSelect,onNativeOptionAdd:p.useCallback(q=>{A(W=>new Set(W).add(q))},[]),onNativeOptionRemove:p.useCallback(q=>{A(W=>{const R=new Set(W);return R.delete(q),R})},[]),children:n})}),G?u.jsxs(Hm,{"aria-hidden":!0,required:f,tabIndex:-1,name:d,autoComplete:h,value:_,onChange:q=>D(q.target.value),disabled:m,form:v,children:[_===void 0?u.jsx("option",{value:""}):null,Array.from(K)]},Y):null]})})};vm.displayName=dr;var bm="SelectTrigger",wm=p.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=ii(n),i=Yn(bm,n),a=i.disabled||r,l=De(t,i.onTriggerChange),c=si(n),d=p.useRef("touch"),[h,m,f]=Wm(g=>{const x=c().filter(S=>!S.disabled),y=x.find(S=>S.value===i.value),w=Vm(x,g,y);w!==void 0&&i.onValueChange(w.value)}),v=g=>{a||(i.onOpenChange(!0),f()),g&&(i.triggerPointerDownPosRef.current={x:Math.round(g.pageX),y:Math.round(g.pageY)})};return u.jsx(ia,{asChild:!0,...s,children:u.jsx(xe.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":Um(i.value)?"":void 0,...o,ref:l,onClick:ce(o.onClick,g=>{g.currentTarget.focus(),d.current!=="mouse"&&v(g)}),onPointerDown:ce(o.onPointerDown,g=>{d.current=g.pointerType;const x=g.target;x.hasPointerCapture(g.pointerId)&&x.releasePointerCapture(g.pointerId),g.button===0&&g.ctrlKey===!1&&g.pointerType==="mouse"&&(v(g),g.preventDefault())}),onKeyDown:ce(o.onKeyDown,g=>{const x=h.current!=="";!(g.ctrlKey||g.altKey||g.metaKey)&&g.key.length===1&&m(g.key),!(x&&g.key===" ")&&Vk.includes(g.key)&&(v(),g.preventDefault())})})})});wm.displayName=bm;var ym="SelectValue",Sm=p.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=Yn(ym,n),{onValueNodeHasChildrenChange:c}=l,d=s!==void 0,h=De(t,l.onValueNodeChange);return yt(()=>{c(d)},[c,d]),u.jsx(xe.span,{...a,ref:h,style:{pointerEvents:"none"},children:Um(l.value)?u.jsx(u.Fragment,{children:i}):s})});Sm.displayName=ym;var Jk="SelectIcon",Cm=p.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return u.jsx(xe.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});Cm.displayName=Jk;var Zk="SelectPortal",Tm=e=>u.jsx(so,{asChild:!0,...e});Tm.displayName=Zk;var fr="SelectContent",km=p.forwardRef((e,t)=>{const n=Yn(fr,e.__scopeSelect),[r,o]=p.useState();if(yt(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?Hr.createPortal(u.jsx(Em,{scope:e.__scopeSelect,children:u.jsx(oi.Slot,{scope:e.__scopeSelect,children:u.jsx("div",{children:e.children})})}),s):null}return u.jsx(Im,{...e,ref:t})});km.displayName=fr;var pn=10,[Em,Xn]=$r(fr),Qk="SelectContentImpl",eE=Kt.createSlot("SelectContent.RemoveScroll"),Im=p.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:h,collisionBoundary:m,collisionPadding:f,sticky:v,hideWhenDetached:g,avoidCollisions:x,...y}=e,w=Yn(fr,n),[S,k]=p.useState(null),[C,T]=p.useState(null),E=De(t,H=>k(H)),[j,_]=p.useState(null),[D,F]=p.useState(null),G=si(n),[K,A]=p.useState(!1),Y=p.useRef(!1);p.useEffect(()=>{if(S)return fa(S)},[S]),Ui();const q=p.useCallback(H=>{const[$,...Z]=G().map(U=>U.ref.current),[te]=Z.slice(-1),Q=document.activeElement;for(const U of H)if(U===Q||(U==null||U.scrollIntoView({block:"nearest"}),U===$&&C&&(C.scrollTop=0),U===te&&C&&(C.scrollTop=C.scrollHeight),U==null||U.focus(),document.activeElement!==Q))return},[G,C]),W=p.useCallback(()=>q([j,S]),[q,j,S]);p.useEffect(()=>{K&&W()},[K,W]);const{onOpenChange:R,triggerPointerDownPosRef:I}=w;p.useEffect(()=>{if(S){let H={x:0,y:0};const $=te=>{var Q,U;H={x:Math.abs(Math.round(te.pageX)-(((Q=I.current)==null?void 0:Q.x)??0)),y:Math.abs(Math.round(te.pageY)-(((U=I.current)==null?void 0:U.y)??0))}},Z=te=>{H.x<=10&&H.y<=10?te.preventDefault():S.contains(te.target)||R(!1),document.removeEventListener("pointermove",$),I.current=null};return I.current!==null&&(document.addEventListener("pointermove",$),document.addEventListener("pointerup",Z,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",$),document.removeEventListener("pointerup",Z,{capture:!0})}}},[S,R,I]),p.useEffect(()=>{const H=()=>R(!1);return window.addEventListener("blur",H),window.addEventListener("resize",H),()=>{window.removeEventListener("blur",H),window.removeEventListener("resize",H)}},[R]);const[z,J]=Wm(H=>{const $=G().filter(Q=>!Q.disabled),Z=$.find(Q=>Q.ref.current===document.activeElement),te=Vm($,H,Z);te&&setTimeout(()=>te.ref.current.focus())}),P=p.useCallback((H,$,Z)=>{const te=!Y.current&&!Z;(w.value!==void 0&&w.value===$||te)&&(_(H),te&&(Y.current=!0))},[w.value]),O=p.useCallback(()=>S==null?void 0:S.focus(),[S]),M=p.useCallback((H,$,Z)=>{const te=!Y.current&&!Z;(w.value!==void 0&&w.value===$||te)&&F(H)},[w.value]),L=r==="popper"?Rl:Nm,ee=L===Rl?{side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:h,collisionBoundary:m,collisionPadding:f,sticky:v,hideWhenDetached:g,avoidCollisions:x}:{};return u.jsx(Em,{scope:n,content:S,viewport:C,onViewportChange:T,itemRefCallback:P,selectedItem:j,onItemLeave:O,itemTextRefCallback:M,focusSelectedItem:W,selectedItemText:D,position:r,isPositioned:K,searchRef:z,children:u.jsx(xs,{as:eE,allowPinchZoom:!0,children:u.jsx(Zo,{asChild:!0,trapped:w.open,onMountAutoFocus:H=>{H.preventDefault()},onUnmountAutoFocus:ce(o,H=>{var $;($=w.trigger)==null||$.focus({preventScroll:!0}),H.preventDefault()}),children:u.jsx(yr,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:H=>H.preventDefault(),onDismiss:()=>w.onOpenChange(!1),children:u.jsx(L,{role:"listbox",id:w.contentId,"data-state":w.open?"open":"closed",dir:w.dir,onContextMenu:H=>H.preventDefault(),...y,...ee,onPlaced:()=>A(!0),ref:E,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:ce(y.onKeyDown,H=>{const $=H.ctrlKey||H.altKey||H.metaKey;if(H.key==="Tab"&&H.preventDefault(),!$&&H.key.length===1&&J(H.key),["ArrowUp","ArrowDown","Home","End"].includes(H.key)){let te=G().filter(Q=>!Q.disabled).map(Q=>Q.ref.current);if(["ArrowUp","End"].includes(H.key)&&(te=te.slice().reverse()),["ArrowUp","ArrowDown"].includes(H.key)){const Q=H.target,U=te.indexOf(Q);te=te.slice(U+1)}setTimeout(()=>q(te)),H.preventDefault()}})})})})})})});Im.displayName=Qk;var tE="SelectItemAlignedPosition",Nm=p.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=Yn(fr,n),i=Xn(fr,n),[a,l]=p.useState(null),[c,d]=p.useState(null),h=De(t,E=>d(E)),m=si(n),f=p.useRef(!1),v=p.useRef(!0),{viewport:g,selectedItem:x,selectedItemText:y,focusSelectedItem:w}=i,S=p.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&c&&g&&x&&y){const E=s.trigger.getBoundingClientRect(),j=c.getBoundingClientRect(),_=s.valueNode.getBoundingClientRect(),D=y.getBoundingClientRect();if(s.dir!=="rtl"){const Q=D.left-j.left,U=_.left-Q,le=E.left-U,ie=E.width+le,ge=Math.max(ie,j.width),we=window.innerWidth-pn,Ce=Il(U,[pn,Math.max(pn,we-ge)]);a.style.minWidth=ie+"px",a.style.left=Ce+"px"}else{const Q=j.right-D.right,U=window.innerWidth-_.right-Q,le=window.innerWidth-E.right-U,ie=E.width+le,ge=Math.max(ie,j.width),we=window.innerWidth-pn,Ce=Il(U,[pn,Math.max(pn,we-ge)]);a.style.minWidth=ie+"px",a.style.right=Ce+"px"}const F=m(),G=window.innerHeight-pn*2,K=g.scrollHeight,A=window.getComputedStyle(c),Y=parseInt(A.borderTopWidth,10),q=parseInt(A.paddingTop,10),W=parseInt(A.borderBottomWidth,10),R=parseInt(A.paddingBottom,10),I=Y+q+K+R+W,z=Math.min(x.offsetHeight*5,I),J=window.getComputedStyle(g),P=parseInt(J.paddingTop,10),O=parseInt(J.paddingBottom,10),M=E.top+E.height/2-pn,L=G-M,ee=x.offsetHeight/2,H=x.offsetTop+ee,$=Y+q+H,Z=I-$;if($<=M){const Q=F.length>0&&x===F[F.length-1].ref.current;a.style.bottom="0px";const U=c.clientHeight-g.offsetTop-g.offsetHeight,le=Math.max(L,ee+(Q?O:0)+U+W),ie=$+le;a.style.height=ie+"px"}else{const Q=F.length>0&&x===F[0].ref.current;a.style.top="0px";const le=Math.max(M,Y+g.offsetTop+(Q?P:0)+ee)+Z;a.style.height=le+"px",g.scrollTop=$-M+g.offsetTop}a.style.margin=`${pn}px 0`,a.style.minHeight=z+"px",a.style.maxHeight=G+"px",r==null||r(),requestAnimationFrame(()=>f.current=!0)}},[m,s.trigger,s.valueNode,a,c,g,x,y,s.dir,r]);yt(()=>S(),[S]);const[k,C]=p.useState();yt(()=>{c&&C(window.getComputedStyle(c).zIndex)},[c]);const T=p.useCallback(E=>{E&&v.current===!0&&(S(),w==null||w(),v.current=!1)},[S,w]);return u.jsx(rE,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:f,onScrollButtonChange:T,children:u.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:k},children:u.jsx(xe.div,{...o,ref:h,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Nm.displayName=tE;var nE="SelectPopperPosition",Rl=p.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=pn,...s}=e,i=ii(n);return u.jsx(aa,{...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)"}})});Rl.displayName=nE;var[rE,Ol]=$r(fr,{}),Dl="SelectViewport",Am=p.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=Xn(Dl,n),i=Ol(Dl,n),a=De(t,s.onViewportChange),l=p.useRef(0);return u.jsxs(u.Fragment,{children:[u.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}),u.jsx(oi.Slot,{scope:n,children:u.jsx(xe.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:ce(o.onScroll,c=>{const d=c.currentTarget,{contentWrapper:h,shouldExpandOnScrollRef:m}=i;if(m!=null&&m.current&&h){const f=Math.abs(l.current-d.scrollTop);if(f>0){const v=window.innerHeight-pn*2,g=parseFloat(h.style.minHeight),x=parseFloat(h.style.height),y=Math.max(g,x);if(y<v){const w=y+f,S=Math.min(v,w),k=w-S;h.style.height=S+"px",h.style.bottom==="0px"&&(d.scrollTop=k>0?k:0,h.style.justifyContent="flex-end")}}}l.current=d.scrollTop})})})]})});Am.displayName=Dl;var jm="SelectGroup",[oE,sE]=$r(jm),iE=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Nt();return u.jsx(oE,{scope:n,id:o,children:u.jsx(xe.div,{role:"group","aria-labelledby":o,...r,ref:t})})});iE.displayName=jm;var Pm="SelectLabel",_m=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=sE(Pm,n);return u.jsx(xe.div,{id:o.id,...r,ref:t})});_m.displayName=Pm;var ai="SelectItem",[aE,Mm]=$r(ai),Rm=p.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=Yn(ai,n),l=Xn(ai,n),c=a.value===r,[d,h]=p.useState(s??""),[m,f]=p.useState(!1),v=De(t,w=>{var S;return(S=l.itemRefCallback)==null?void 0:S.call(l,w,r,o)}),g=Nt(),x=p.useRef("touch"),y=()=>{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 u.jsx(aE,{scope:n,value:r,disabled:o,textId:g,isSelected:c,onItemTextChange:p.useCallback(w=>{h(S=>S||((w==null?void 0:w.textContent)??"").trim())},[]),children:u.jsx(oi.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:u.jsx(xe.div,{role:"option","aria-labelledby":g,"data-highlighted":m?"":void 0,"aria-selected":c&&m,"data-state":c?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:v,onFocus:ce(i.onFocus,()=>f(!0)),onBlur:ce(i.onBlur,()=>f(!1)),onClick:ce(i.onClick,()=>{x.current!=="mouse"&&y()}),onPointerUp:ce(i.onPointerUp,()=>{x.current==="mouse"&&y()}),onPointerDown:ce(i.onPointerDown,w=>{x.current=w.pointerType}),onPointerMove:ce(i.onPointerMove,w=>{var S;x.current=w.pointerType,o?(S=l.onItemLeave)==null||S.call(l):x.current==="mouse"&&w.currentTarget.focus({preventScroll:!0})}),onPointerLeave:ce(i.onPointerLeave,w=>{var S;w.currentTarget===document.activeElement&&((S=l.onItemLeave)==null||S.call(l))}),onKeyDown:ce(i.onKeyDown,w=>{var k;((k=l.searchRef)==null?void 0:k.current)!==""&&w.key===" "||(Kk.includes(w.key)&&y(),w.key===" "&&w.preventDefault())})})})})});Rm.displayName=ai;var jo="SelectItemText",Om=p.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=Yn(jo,n),a=Xn(jo,n),l=Mm(jo,n),c=Xk(jo,n),[d,h]=p.useState(null),m=De(t,y=>h(y),l.onItemTextChange,y=>{var w;return(w=a.itemTextRefCallback)==null?void 0:w.call(a,y,l.value,l.disabled)}),f=d==null?void 0:d.textContent,v=p.useMemo(()=>u.jsx("option",{value:l.value,disabled:l.disabled,children:f},l.value),[l.disabled,l.value,f]),{onNativeOptionAdd:g,onNativeOptionRemove:x}=c;return yt(()=>(g(v),()=>x(v)),[g,x,v]),u.jsxs(u.Fragment,{children:[u.jsx(xe.span,{id:l.textId,...s,ref:m}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?Hr.createPortal(s.children,i.valueNode):null]})});Om.displayName=jo;var Dm="SelectItemIndicator",Lm=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return Mm(Dm,n).isSelected?u.jsx(xe.span,{"aria-hidden":!0,...r,ref:t}):null});Lm.displayName=Dm;var Ll="SelectScrollUpButton",$m=p.forwardRef((e,t)=>{const n=Xn(Ll,e.__scopeSelect),r=Ol(Ll,e.__scopeSelect),[o,s]=p.useState(!1),i=De(t,r.onScrollButtonChange);return yt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const c=l.scrollTop>0;s(c)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?u.jsx(Bm,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});$m.displayName=Ll;var $l="SelectScrollDownButton",Fm=p.forwardRef((e,t)=>{const n=Xn($l,e.__scopeSelect),r=Ol($l,e.__scopeSelect),[o,s]=p.useState(!1),i=De(t,r.onScrollButtonChange);return yt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const c=l.scrollHeight-l.clientHeight,d=Math.ceil(l.scrollTop)<c;s(d)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?u.jsx(Bm,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});Fm.displayName=$l;var Bm=p.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=Xn("SelectScrollButton",n),i=p.useRef(null),a=si(n),l=p.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return p.useEffect(()=>()=>l(),[l]),yt(()=>{var d;const c=a().find(h=>h.ref.current===document.activeElement);(d=c==null?void 0:c.ref.current)==null||d.scrollIntoView({block:"nearest"})},[a]),u.jsx(xe.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:ce(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:ce(o.onPointerMove,()=>{var c;(c=s.onItemLeave)==null||c.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:ce(o.onPointerLeave,()=>{l()})})}),lE="SelectSeparator",zm=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return u.jsx(xe.div,{"aria-hidden":!0,...r,ref:t})});zm.displayName=lE;var Fl="SelectArrow",cE=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=ii(n),s=Yn(Fl,n),i=Xn(Fl,n);return s.open&&i.position==="popper"?u.jsx(la,{...o,...r,ref:t}):null});cE.displayName=Fl;var uE="SelectBubbleInput",Hm=p.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=p.useRef(null),s=De(r,o),i=gm(t);return p.useEffect(()=>{const a=o.current;if(!a)return;const l=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(l,"value").set;if(i!==t&&d){const h=new Event("change",{bubbles:!0});d.call(a,t),a.dispatchEvent(h)}},[i,t]),u.jsx(xe.select,{...n,style:{...xm,...n.style},ref:s,defaultValue:t})});Hm.displayName=uE;function Um(e){return e===""||e===void 0}function Wm(e){const t=ft(e),n=p.useRef(""),r=p.useRef(0),o=p.useCallback(i=>{const a=n.current+i;t(a),function l(c){n.current=c,window.clearTimeout(r.current),c!==""&&(r.current=window.setTimeout(()=>l(""),1e3))}(a)},[t]),s=p.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return p.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function Vm(e,t,n){const o=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=dE(e,Math.max(s,0));o.length===1&&(i=i.filter(c=>c!==n));const l=i.find(c=>c.textValue.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function dE(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var fE=vm,Km=wm,hE=Sm,pE=Cm,mE=Tm,qm=km,gE=Am,Gm=_m,Ym=Rm,xE=Om,vE=Lm,Xm=$m,Jm=Fm,Zm=zm;const bE=fE,wE=hE,Qm=p.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Km,{ref:r,className:oe("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[t,u.jsx(pE,{asChild:!0,children:u.jsx(ue.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));Qm.displayName=Km.displayName;const eg=p.forwardRef(({className:e,...t},n)=>u.jsx(Xm,{ref:n,className:oe("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(ue.ChevronUp,{className:"h-4 w-4"})}));eg.displayName=Xm.displayName;const tg=p.forwardRef(({className:e,...t},n)=>u.jsx(Jm,{ref:n,className:oe("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(ue.ChevronDown,{className:"h-4 w-4"})}));tg.displayName=Jm.displayName;const ng=p.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>u.jsx(mE,{children:u.jsxs(qm,{ref:o,className:oe("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...r,children:[u.jsx(eg,{}),u.jsx(gE,{className:oe("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),u.jsx(tg,{})]})}));ng.displayName=qm.displayName;const yE=p.forwardRef(({className:e,...t},n)=>u.jsx(Gm,{ref:n,className:oe("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));yE.displayName=Gm.displayName;const rg=p.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Ym,{ref:r,className:oe("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[u.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx(vE,{children:u.jsx(ue.Check,{className:"h-4 w-4"})})}),u.jsx(xE,{children:t})]}));rg.displayName=Ym.displayName;const SE=p.forwardRef(({className:e,...t},n)=>u.jsx(Zm,{ref:n,className:oe("-mx-1 my-1 h-px bg-muted",e),...t}));SE.displayName=Zm.displayName;var CE="Separator",og="horizontal",TE=["horizontal","vertical"],sg=p.forwardRef((e,t)=>{const{decorative:n,orientation:r=og,...o}=e,s=kE(r)?r:og,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return u.jsx(xe.div,{"data-orientation":s,...a,...o,ref:t})});sg.displayName=CE;function kE(e){return TE.includes(e)}var ig=sg;const ag=p.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>u.jsx(ig,{ref:o,decorative:n,orientation:t,className:oe("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));ag.displayName=ig.displayName;var li="Switch",[EE,DN]=ln(li),[IE,NE]=EE(li),lg=p.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:s,required:i,disabled:a,value:l="on",onCheckedChange:c,form:d,...h}=e,[m,f]=p.useState(null),v=De(t,S=>f(S)),g=p.useRef(!1),x=m?d||!!m.closest("form"):!0,[y,w]=Dn({prop:o,defaultProp:s??!1,onChange:c,caller:li});return u.jsxs(IE,{scope:n,checked:y,disabled:a,children:[u.jsx(xe.button,{type:"button",role:"switch","aria-checked":y,"aria-required":i,"data-state":fg(y),"data-disabled":a?"":void 0,disabled:a,value:l,...h,ref:v,onClick:ce(e.onClick,S=>{w(k=>!k),x&&(g.current=S.isPropagationStopped(),g.current||S.stopPropagation())})}),x&&u.jsx(dg,{control:m,bubbles:!g.current,name:r,value:l,checked:y,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});lg.displayName=li;var cg="SwitchThumb",ug=p.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=NE(cg,n);return u.jsx(xe.span,{"data-state":fg(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});ug.displayName=cg;var AE="SwitchBubbleInput",dg=p.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=p.useRef(null),a=De(i,s),l=gm(n),c=bd(t);return p.useEffect(()=>{const d=i.current;if(!d)return;const h=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(h,"checked").set;if(l!==n&&f){const v=new Event("click",{bubbles:r});f.call(d,n),d.dispatchEvent(v)}},[l,n,r]),u.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:a,style:{...o.style,...c,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});dg.displayName=AE;function fg(e){return e?"checked":"unchecked"}var hg=lg,jE=ug;const pg=p.forwardRef(({className:e,...t},n)=>u.jsx(hg,{className:oe("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...t,ref:n,children:u.jsx(jE,{className:oe("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));pg.displayName=hg.displayName;const PE=Za,_E=dT,ME=Qa,mg=p.forwardRef(({className:e,...t},n)=>u.jsx(To,{className:oe("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t,ref:n}));mg.displayName=To.displayName;const RE=zr.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"}}),gg=p.forwardRef(({side:e="right",className:t,children:n,...r},o)=>u.jsxs(ME,{children:[u.jsx(mg,{}),u.jsxs(ko,{ref:o,className:oe(RE({side:e}),t),...r,children:[n,u.jsxs(sp,{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:[u.jsx(ue.X,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));gg.displayName=ko.displayName;const xg=({className:e,...t})=>u.jsx("div",{className:oe("flex flex-col space-y-2 text-center sm:text-left",e),...t});xg.displayName="SheetHeader";const vg=p.forwardRef(({className:e,...t},n)=>u.jsx(lr,{ref:n,className:oe("text-lg font-semibold text-foreground",e),...t}));vg.displayName=lr.displayName;const bg=p.forwardRef(({className:e,...t},n)=>u.jsx(Bs,{ref:n,className:oe("text-sm text-muted-foreground",e),...t}));bg.displayName=Bs.displayName;var[ci,LN]=ln("Tooltip",[Er]),ui=Er(),wg="TooltipProvider",OE=700,Bl="tooltip.open",[DE,zl]=ci(wg),yg=e=>{const{__scopeTooltip:t,delayDuration:n=OE,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:s}=e,i=p.useRef(!0),a=p.useRef(!1),l=p.useRef(0);return p.useEffect(()=>{const c=l.current;return()=>window.clearTimeout(c)},[]),u.jsx(DE,{scope:t,isOpenDelayedRef:i,delayDuration:n,onOpen:p.useCallback(()=>{window.clearTimeout(l.current),i.current=!1},[]),onClose:p.useCallback(()=>{window.clearTimeout(l.current),l.current=window.setTimeout(()=>i.current=!0,r)},[r]),isPointerInTransitRef:a,onPointerInTransitChange:p.useCallback(c=>{a.current=c},[]),disableHoverableContent:o,children:s})};yg.displayName=wg;var Po="Tooltip",[LE,di]=ci(Po),Sg=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:s,disableHoverableContent:i,delayDuration:a}=e,l=zl(Po,e.__scopeTooltip),c=ui(t),[d,h]=p.useState(null),m=Nt(),f=p.useRef(0),v=i??l.disableHoverableContent,g=a??l.delayDuration,x=p.useRef(!1),[y,w]=Dn({prop:r,defaultProp:o??!1,onChange:E=>{E?(l.onOpen(),document.dispatchEvent(new CustomEvent(Bl))):l.onClose(),s==null||s(E)},caller:Po}),S=p.useMemo(()=>y?x.current?"delayed-open":"instant-open":"closed",[y]),k=p.useCallback(()=>{window.clearTimeout(f.current),f.current=0,x.current=!1,w(!0)},[w]),C=p.useCallback(()=>{window.clearTimeout(f.current),f.current=0,w(!1)},[w]),T=p.useCallback(()=>{window.clearTimeout(f.current),f.current=window.setTimeout(()=>{x.current=!0,w(!0),f.current=0},g)},[g,w]);return p.useEffect(()=>()=>{f.current&&(window.clearTimeout(f.current),f.current=0)},[]),u.jsx(sa,{...c,children:u.jsx(LE,{scope:t,contentId:m,open:y,stateAttribute:S,trigger:d,onTriggerChange:h,onTriggerEnter:p.useCallback(()=>{l.isOpenDelayedRef.current?T():k()},[l.isOpenDelayedRef,T,k]),onTriggerLeave:p.useCallback(()=>{v?C():(window.clearTimeout(f.current),f.current=0)},[C,v]),onOpen:k,onClose:C,disableHoverableContent:v,children:n})})};Sg.displayName=Po;var Hl="TooltipTrigger",Cg=p.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=di(Hl,n),s=zl(Hl,n),i=ui(n),a=p.useRef(null),l=De(t,a,o.onTriggerChange),c=p.useRef(!1),d=p.useRef(!1),h=p.useCallback(()=>c.current=!1,[]);return p.useEffect(()=>()=>document.removeEventListener("pointerup",h),[h]),u.jsx(ia,{asChild:!0,...i,children:u.jsx(xe.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:l,onPointerMove:ce(e.onPointerMove,m=>{m.pointerType!=="touch"&&!d.current&&!s.isPointerInTransitRef.current&&(o.onTriggerEnter(),d.current=!0)}),onPointerLeave:ce(e.onPointerLeave,()=>{o.onTriggerLeave(),d.current=!1}),onPointerDown:ce(e.onPointerDown,()=>{o.open&&o.onClose(),c.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:ce(e.onFocus,()=>{c.current||o.onOpen()}),onBlur:ce(e.onBlur,o.onClose),onClick:ce(e.onClick,o.onClose)})})});Cg.displayName=Hl;var $E="TooltipPortal",[$N,FE]=ci($E,{forceMount:void 0}),Fr="TooltipContent",Tg=p.forwardRef((e,t)=>{const n=FE(Fr,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...s}=e,i=di(Fr,e.__scopeTooltip);return u.jsx(zt,{present:r||i.open,children:i.disableHoverableContent?u.jsx(kg,{side:o,...s,ref:t}):u.jsx(BE,{side:o,...s,ref:t})})}),BE=p.forwardRef((e,t)=>{const n=di(Fr,e.__scopeTooltip),r=zl(Fr,e.__scopeTooltip),o=p.useRef(null),s=De(t,o),[i,a]=p.useState(null),{trigger:l,onClose:c}=n,d=o.current,{onPointerInTransitChange:h}=r,m=p.useCallback(()=>{a(null),h(!1)},[h]),f=p.useCallback((v,g)=>{const x=v.currentTarget,y={x:v.clientX,y:v.clientY},w=VE(y,x.getBoundingClientRect()),S=KE(y,w),k=qE(g.getBoundingClientRect()),C=YE([...S,...k]);a(C),h(!0)},[h]);return p.useEffect(()=>()=>m(),[m]),p.useEffect(()=>{if(l&&d){const v=x=>f(x,d),g=x=>f(x,l);return l.addEventListener("pointerleave",v),d.addEventListener("pointerleave",g),()=>{l.removeEventListener("pointerleave",v),d.removeEventListener("pointerleave",g)}}},[l,d,f,m]),p.useEffect(()=>{if(i){const v=g=>{const x=g.target,y={x:g.clientX,y:g.clientY},w=(l==null?void 0:l.contains(x))||(d==null?void 0:d.contains(x)),S=!GE(y,i);w?m():S&&(m(),c())};return document.addEventListener("pointermove",v),()=>document.removeEventListener("pointermove",v)}},[l,d,i,c,m]),u.jsx(kg,{...e,ref:s})}),[zE,HE]=ci(Po,{isInside:!1}),UE=Kt.createSlottable("TooltipContent"),kg=p.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:s,onPointerDownOutside:i,...a}=e,l=di(Fr,n),c=ui(n),{onClose:d}=l;return p.useEffect(()=>(document.addEventListener(Bl,d),()=>document.removeEventListener(Bl,d)),[d]),p.useEffect(()=>{if(l.trigger){const h=m=>{const f=m.target;f!=null&&f.contains(l.trigger)&&d()};return window.addEventListener("scroll",h,{capture:!0}),()=>window.removeEventListener("scroll",h,{capture:!0})}},[l.trigger,d]),u.jsx(yr,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:h=>h.preventDefault(),onDismiss:d,children:u.jsxs(aa,{"data-state":l.stateAttribute,...c,...a,ref:t,style:{...a.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[u.jsx(UE,{children:r}),u.jsx(zE,{scope:n,isInside:!0,children:u.jsx(Wk,{id:l.contentId,role:"tooltip",children:o||r})})]})})});Tg.displayName=Fr;var Eg="TooltipArrow",WE=p.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=ui(n);return HE(Eg,n).isInside?null:u.jsx(la,{...o,...r,ref:t})});WE.displayName=Eg;function VE(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),o=Math.abs(t.right-e.x),s=Math.abs(t.left-e.x);switch(Math.min(n,r,o,s)){case s:return"left";case o:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function KE(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function qE(e){const{top:t,right:n,bottom:r,left:o}=e;return[{x:o,y:t},{x:n,y:t},{x:n,y:r},{x:o,y:r}]}function GE(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],c=a.x,d=a.y,h=l.x,m=l.y;d>r!=m>r&&n<(h-c)*(r-d)/(m-d)+c&&(o=!o)}return o}function YE(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),XE(t)}function XE(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const o=e[r];for(;t.length>=2;){const s=t[t.length-1],i=t[t.length-2];if((s.x-i.x)*(o.y-i.y)>=(s.y-i.y)*(o.x-i.x))t.pop();else break}t.push(o)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const o=e[r];for(;n.length>=2;){const s=n[n.length-1],i=n[n.length-2];if((s.x-i.x)*(o.y-i.y)>=(s.y-i.y)*(o.x-i.x))n.pop();else break}n.push(o)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var JE=yg,ZE=Sg,QE=Cg,Ig=Tg;const eI=JE,tI=ZE,nI=QE,Ng=p.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(Ig,{ref:r,sideOffset:t,className:oe("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-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}));Ng.displayName=Ig.displayName;var Ul="ToastProvider",[Wl,rI,oI]=Xo("Toast"),[Ag,FN]=ln("Toast",[oI]),[sI,fi]=Ag(Ul),jg=e=>{const{__scopeToast:t,label:n="Notification",duration:r=5e3,swipeDirection:o="right",swipeThreshold:s=50,children:i}=e,[a,l]=p.useState(null),[c,d]=p.useState(0),h=p.useRef(!1),m=p.useRef(!1);return n.trim()||console.error(`Invalid prop \`label\` supplied to \`${Ul}\`. Expected non-empty \`string\`.`),u.jsx(Wl.Provider,{scope:t,children:u.jsx(sI,{scope:t,label:n,duration:r,swipeDirection:o,swipeThreshold:s,toastCount:c,viewport:a,onViewportChange:l,onToastAdd:p.useCallback(()=>d(f=>f+1),[]),onToastRemove:p.useCallback(()=>d(f=>f-1),[]),isFocusedToastEscapeKeyDownRef:h,isClosePausedRef:m,children:i})})};jg.displayName=Ul;var Pg="ToastViewport",iI=["F8"],Vl="toast.viewportPause",Kl="toast.viewportResume",_g=p.forwardRef((e,t)=>{const{__scopeToast:n,hotkey:r=iI,label:o="Notifications ({hotkey})",...s}=e,i=fi(Pg,n),a=rI(n),l=p.useRef(null),c=p.useRef(null),d=p.useRef(null),h=p.useRef(null),m=De(t,h,i.onViewportChange),f=r.join("+").replace(/Key/g,"").replace(/Digit/g,""),v=i.toastCount>0;p.useEffect(()=>{const x=y=>{var S;r.length!==0&&r.every(k=>y[k]||y.code===k)&&((S=h.current)==null||S.focus())};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[r]),p.useEffect(()=>{const x=l.current,y=h.current;if(v&&x&&y){const w=()=>{if(!i.isClosePausedRef.current){const T=new CustomEvent(Vl);y.dispatchEvent(T),i.isClosePausedRef.current=!0}},S=()=>{if(i.isClosePausedRef.current){const T=new CustomEvent(Kl);y.dispatchEvent(T),i.isClosePausedRef.current=!1}},k=T=>{!x.contains(T.relatedTarget)&&S()},C=()=>{x.contains(document.activeElement)||S()};return x.addEventListener("focusin",w),x.addEventListener("focusout",k),x.addEventListener("pointermove",w),x.addEventListener("pointerleave",C),window.addEventListener("blur",w),window.addEventListener("focus",S),()=>{x.removeEventListener("focusin",w),x.removeEventListener("focusout",k),x.removeEventListener("pointermove",w),x.removeEventListener("pointerleave",C),window.removeEventListener("blur",w),window.removeEventListener("focus",S)}}},[v,i.isClosePausedRef]);const g=p.useCallback(({tabbingDirection:x})=>{const w=a().map(S=>{const k=S.ref.current,C=[k,...bI(k)];return x==="forwards"?C:C.reverse()});return(x==="forwards"?w.reverse():w).flat()},[a]);return p.useEffect(()=>{const x=h.current;if(x){const y=w=>{var C,T,E;const S=w.altKey||w.ctrlKey||w.metaKey;if(w.key==="Tab"&&!S){const j=document.activeElement,_=w.shiftKey;if(w.target===x&&_){(C=c.current)==null||C.focus();return}const G=g({tabbingDirection:_?"backwards":"forwards"}),K=G.findIndex(A=>A===j);Yl(G.slice(K+1))?w.preventDefault():_?(T=c.current)==null||T.focus():(E=d.current)==null||E.focus()}};return x.addEventListener("keydown",y),()=>x.removeEventListener("keydown",y)}},[a,g]),u.jsxs(Fb,{ref:l,role:"region","aria-label":o.replace("{hotkey}",f),tabIndex:-1,style:{pointerEvents:v?void 0:"none"},children:[v&&u.jsx(ql,{ref:c,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"forwards"});Yl(x)}}),u.jsx(Wl.Slot,{scope:n,children:u.jsx(xe.ol,{tabIndex:-1,...s,ref:m})}),v&&u.jsx(ql,{ref:d,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"backwards"});Yl(x)}})]})});_g.displayName=Pg;var Mg="ToastFocusProxy",ql=p.forwardRef((e,t)=>{const{__scopeToast:n,onFocusFromOutsideViewport:r,...o}=e,s=fi(Mg,n);return u.jsx(ri,{tabIndex:0,...o,ref:t,style:{position:"fixed"},onFocus:i=>{var c;const a=i.relatedTarget;!((c=s.viewport)!=null&&c.contains(a))&&r()}})});ql.displayName=Mg;var _o="Toast",aI="toast.swipeStart",lI="toast.swipeMove",cI="toast.swipeCancel",uI="toast.swipeEnd",Rg=p.forwardRef((e,t)=>{const{forceMount:n,open:r,defaultOpen:o,onOpenChange:s,...i}=e,[a,l]=Dn({prop:r,defaultProp:o??!0,onChange:s,caller:_o});return u.jsx(zt,{present:n||a,children:u.jsx(hI,{open:a,...i,ref:t,onClose:()=>l(!1),onPause:ft(e.onPause),onResume:ft(e.onResume),onSwipeStart:ce(e.onSwipeStart,c=>{c.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:ce(e.onSwipeMove,c=>{const{x:d,y:h}=c.detail.delta;c.currentTarget.setAttribute("data-swipe","move"),c.currentTarget.style.setProperty("--radix-toast-swipe-move-x",`${d}px`),c.currentTarget.style.setProperty("--radix-toast-swipe-move-y",`${h}px`)}),onSwipeCancel:ce(e.onSwipeCancel,c=>{c.currentTarget.setAttribute("data-swipe","cancel"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),c.currentTarget.style.removeProperty("--radix-toast-swipe-end-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-end-y")}),onSwipeEnd:ce(e.onSwipeEnd,c=>{const{x:d,y:h}=c.detail.delta;c.currentTarget.setAttribute("data-swipe","end"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),c.currentTarget.style.setProperty("--radix-toast-swipe-end-x",`${d}px`),c.currentTarget.style.setProperty("--radix-toast-swipe-end-y",`${h}px`),l(!1)})})})});Rg.displayName=_o;var[dI,fI]=Ag(_o,{onClose(){}}),hI=p.forwardRef((e,t)=>{const{__scopeToast:n,type:r="foreground",duration:o,open:s,onClose:i,onEscapeKeyDown:a,onPause:l,onResume:c,onSwipeStart:d,onSwipeMove:h,onSwipeCancel:m,onSwipeEnd:f,...v}=e,g=fi(_o,n),[x,y]=p.useState(null),w=De(t,A=>y(A)),S=p.useRef(null),k=p.useRef(null),C=o||g.duration,T=p.useRef(0),E=p.useRef(C),j=p.useRef(0),{onToastAdd:_,onToastRemove:D}=g,F=ft(()=>{var Y;(x==null?void 0:x.contains(document.activeElement))&&((Y=g.viewport)==null||Y.focus()),i()}),G=p.useCallback(A=>{!A||A===1/0||(window.clearTimeout(j.current),T.current=new Date().getTime(),j.current=window.setTimeout(F,A))},[F]);p.useEffect(()=>{const A=g.viewport;if(A){const Y=()=>{G(E.current),c==null||c()},q=()=>{const W=new Date().getTime()-T.current;E.current=E.current-W,window.clearTimeout(j.current),l==null||l()};return A.addEventListener(Vl,q),A.addEventListener(Kl,Y),()=>{A.removeEventListener(Vl,q),A.removeEventListener(Kl,Y)}}},[g.viewport,C,l,c,G]),p.useEffect(()=>{s&&!g.isClosePausedRef.current&&G(C)},[s,C,g.isClosePausedRef,G]),p.useEffect(()=>(_(),()=>D()),[_,D]);const K=p.useMemo(()=>x?zg(x):null,[x]);return g.viewport?u.jsxs(u.Fragment,{children:[K&&u.jsx(pI,{__scopeToast:n,role:"status","aria-live":r==="foreground"?"assertive":"polite",children:K}),u.jsx(dI,{scope:n,onClose:F,children:Hr.createPortal(u.jsx(Wl.ItemSlot,{scope:n,children:u.jsx($b,{asChild:!0,onEscapeKeyDown:ce(a,()=>{g.isFocusedToastEscapeKeyDownRef.current||F(),g.isFocusedToastEscapeKeyDownRef.current=!1}),children:u.jsx(xe.li,{tabIndex:0,"data-state":s?"open":"closed","data-swipe-direction":g.swipeDirection,...v,ref:w,style:{userSelect:"none",touchAction:"none",...e.style},onKeyDown:ce(e.onKeyDown,A=>{A.key==="Escape"&&(a==null||a(A.nativeEvent),A.nativeEvent.defaultPrevented||(g.isFocusedToastEscapeKeyDownRef.current=!0,F()))}),onPointerDown:ce(e.onPointerDown,A=>{A.button===0&&(S.current={x:A.clientX,y:A.clientY})}),onPointerMove:ce(e.onPointerMove,A=>{if(!S.current)return;const Y=A.clientX-S.current.x,q=A.clientY-S.current.y,W=!!k.current,R=["left","right"].includes(g.swipeDirection),I=["left","up"].includes(g.swipeDirection)?Math.min:Math.max,z=R?I(0,Y):0,J=R?0:I(0,q),P=A.pointerType==="touch"?10:2,O={x:z,y:J},M={originalEvent:A,delta:O};W?(k.current=O,hi(lI,h,M,{discrete:!1})):Hg(O,g.swipeDirection,P)?(k.current=O,hi(aI,d,M,{discrete:!1}),A.target.setPointerCapture(A.pointerId)):(Math.abs(Y)>P||Math.abs(q)>P)&&(S.current=null)}),onPointerUp:ce(e.onPointerUp,A=>{const Y=k.current,q=A.target;if(q.hasPointerCapture(A.pointerId)&&q.releasePointerCapture(A.pointerId),k.current=null,S.current=null,Y){const W=A.currentTarget,R={originalEvent:A,delta:Y};Hg(Y,g.swipeDirection,g.swipeThreshold)?hi(uI,f,R,{discrete:!0}):hi(cI,m,R,{discrete:!0}),W.addEventListener("click",I=>I.preventDefault(),{once:!0})}})})})}),g.viewport)})]}):null}),pI=e=>{const{__scopeToast:t,children:n,...r}=e,o=fi(_o,t),[s,i]=p.useState(!1),[a,l]=p.useState(!1);return xI(()=>i(!0)),p.useEffect(()=>{const c=window.setTimeout(()=>l(!0),1e3);return()=>window.clearTimeout(c)},[]),a?null:u.jsx(so,{asChild:!0,children:u.jsx(ri,{...r,children:s&&u.jsxs(u.Fragment,{children:[o.label," ",n]})})})},mI="ToastTitle",Og=p.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(xe.div,{...r,ref:t})});Og.displayName=mI;var gI="ToastDescription",Dg=p.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(xe.div,{...r,ref:t})});Dg.displayName=gI;var Lg="ToastAction",$g=p.forwardRef((e,t)=>{const{altText:n,...r}=e;return n.trim()?u.jsx(Bg,{altText:n,asChild:!0,children:u.jsx(Gl,{...r,ref:t})}):(console.error(`Invalid prop \`altText\` supplied to \`${Lg}\`. Expected non-empty \`string\`.`),null)});$g.displayName=Lg;var Fg="ToastClose",Gl=p.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e,o=fI(Fg,n);return u.jsx(Bg,{asChild:!0,children:u.jsx(xe.button,{type:"button",...r,ref:t,onClick:ce(e.onClick,o.onClose)})})});Gl.displayName=Fg;var Bg=p.forwardRef((e,t)=>{const{__scopeToast:n,altText:r,...o}=e;return u.jsx(xe.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":r||void 0,...o,ref:t})});function zg(e){const t=[];return Array.from(e.childNodes).forEach(r=>{if(r.nodeType===r.TEXT_NODE&&r.textContent&&t.push(r.textContent),vI(r)){const o=r.ariaHidden||r.hidden||r.style.display==="none",s=r.dataset.radixToastAnnounceExclude==="";if(!o)if(s){const i=r.dataset.radixToastAnnounceAlt;i&&t.push(i)}else t.push(...zg(r))}}),t}function hi(e,t,n,{discrete:r}){const o=n.originalEvent.currentTarget,s=new CustomEvent(e,{bubbles:!0,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?Bi(o,s):o.dispatchEvent(s)}var Hg=(e,t,n=0)=>{const r=Math.abs(e.x),o=Math.abs(e.y),s=r>o;return t==="left"||t==="right"?s&&r>n:!s&&o>n};function xI(e=()=>{}){const t=ft(e);yt(()=>{let n=0,r=0;return n=window.requestAnimationFrame(()=>r=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(n),window.cancelAnimationFrame(r)}},[t])}function vI(e){return e.nodeType===e.ELEMENT_NODE}function bI(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 Yl(e){const t=document.activeElement;return e.some(n=>n===t?!0:(n.focus(),document.activeElement!==t))}var wI=jg,Ug=_g,Wg=Rg,Vg=Og,Kg=Dg,qg=$g,Gg=Gl;const yI=wI,Yg=p.forwardRef(({className:e,...t},n)=>u.jsx(Ug,{ref:n,className:oe("fixed bottom-0 right-0 z-[100] flex max-h-screen w-full flex-col p-4 md:max-w-[420px]",e),...t}));Yg.displayName=Ug.displayName;const SI=zr.cva("group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-8 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",{variants:{variant:{default:"border bg-background text-foreground",destructive:"destructive group border-destructive bg-destructive text-destructive-foreground"}},defaultVariants:{variant:"default"}}),Xg=p.forwardRef(({className:e,variant:t,...n},r)=>u.jsx(Wg,{ref:r,className:oe(SI({variant:t}),e),...n}));Xg.displayName=Wg.displayName;const CI=p.forwardRef(({className:e,...t},n)=>u.jsx(qg,{ref:n,className:oe("inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors hover:bg-secondary focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive",e),...t}));CI.displayName=qg.displayName;const Jg=p.forwardRef(({className:e,...t},n)=>u.jsx(Gg,{ref:n,className:oe("absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-2 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",e),"toast-close":"",...t,children:u.jsx(ue.X,{className:"h-4 w-4"})}));Jg.displayName=Gg.displayName;const Zg=p.forwardRef(({className:e,...t},n)=>u.jsx(Vg,{ref:n,className:oe("text-sm font-semibold",e),...t}));Zg.displayName=Vg.displayName;const Qg=p.forwardRef(({className:e,...t},n)=>u.jsx(Kg,{ref:n,className:oe("text-sm opacity-90",e),...t}));Qg.displayName=Kg.displayName;function TI(){const{toasts:e}=rl();return u.jsxs(yI,{children:[e.map(function({id:t,title:n,description:r,action:o,...s}){return u.jsxs(Xg,{...s,children:[u.jsxs("div",{className:"grid gap-1",children:[n&&u.jsx(Zg,{children:n}),r&&u.jsx(Qg,{children:r})]}),o,u.jsx(Jg,{})]},t)}),u.jsx(Yg,{})]})}var kI=(e,t,n,r,o,s,i,a)=>{let l=document.documentElement,c=["light","dark"];function d(f){(Array.isArray(e)?e:[e]).forEach(v=>{let g=v==="class",x=g&&s?o.map(y=>s[y]||y):o;g?(l.classList.remove(...x),l.classList.add(s&&s[f]?s[f]:f)):l.setAttribute(v,f)}),h(f)}function h(f){a&&c.includes(f)&&(l.style.colorScheme=f)}function m(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}if(r)d(r);else try{let f=localStorage.getItem(t)||n,v=i&&f==="system"?m():f;d(v)}catch{}},EI=p.createContext(void 0),II={setTheme:e=>{},themes:[]},NI=()=>{var e;return(e=p.useContext(EI))!=null?e:II};p.memo(({forcedTheme:e,storageKey:t,attribute:n,enableSystem:r,enableColorScheme:o,defaultTheme:s,value:i,themes:a,nonce:l,scriptProps:c})=>{let d=JSON.stringify([n,t,s,e,a,i,r,o]).slice(1,-1);return p.createElement("script",{...c,suppressHydrationWarning:!0,nonce:typeof window>"u"?l:"",dangerouslySetInnerHTML:{__html:`(${kI.toString()})(${d})`}})});var AI=e=>{switch(e){case"success":return _I;case"info":return RI;case"warning":return MI;case"error":return OI;default:return null}},jI=Array(12).fill(0),PI=({visible:e,className:t})=>b.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},b.createElement("div",{className:"sonner-spinner"},jI.map((n,r)=>b.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),_I=b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},b.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),MI=b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},b.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),RI=b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},b.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),OI=b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},b.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),DI=b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},b.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),b.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),LI=()=>{let[e,t]=b.useState(document.hidden);return b.useEffect(()=>{let n=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),e},Xl=1,$I=class{constructor(){this.subscribe=e=>(this.subscribers.push(e),()=>{let t=this.subscribers.indexOf(e);this.subscribers.splice(t,1)}),this.publish=e=>{this.subscribers.forEach(t=>t(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e]},this.create=e=>{var t;let{message:n,...r}=e,o=typeof(e==null?void 0:e.id)=="number"||((t=e.id)==null?void 0:t.length)>0?e.id:Xl++,s=this.toasts.find(a=>a.id===o),i=e.dismissible===void 0?!0:e.dismissible;return this.dismissedToasts.has(o)&&this.dismissedToasts.delete(o),s?this.toasts=this.toasts.map(a=>a.id===o?(this.publish({...a,...e,id:o,title:n}),{...a,...e,id:o,dismissible:i,title:n}):a):this.addToast({title:n,...r,dismissible:i,id:o}),o},this.dismiss=e=>(this.dismissedToasts.add(e),e||this.toasts.forEach(t=>{this.subscribers.forEach(n=>n({id:t.id,dismiss:!0}))}),this.subscribers.forEach(t=>t({id:e,dismiss:!0})),e),this.message=(e,t)=>this.create({...t,message:e}),this.error=(e,t)=>this.create({...t,message:e,type:"error"}),this.success=(e,t)=>this.create({...t,type:"success",message:e}),this.info=(e,t)=>this.create({...t,type:"info",message:e}),this.warning=(e,t)=>this.create({...t,type:"warning",message:e}),this.loading=(e,t)=>this.create({...t,type:"loading",message:e}),this.promise=(e,t)=>{if(!t)return;let n;t.loading!==void 0&&(n=this.create({...t,promise:e,type:"loading",message:t.loading,description:typeof t.description!="function"?t.description:void 0}));let r=e instanceof Promise?e:e(),o=n!==void 0,s,i=r.then(async l=>{if(s=["resolve",l],b.isValidElement(l))o=!1,this.create({id:n,type:"default",message:l});else if(BI(l)&&!l.ok){o=!1;let c=typeof t.error=="function"?await t.error(`HTTP error! status: ${l.status}`):t.error,d=typeof t.description=="function"?await t.description(`HTTP error! status: ${l.status}`):t.description;this.create({id:n,type:"error",message:c,description:d})}else if(t.success!==void 0){o=!1;let c=typeof t.success=="function"?await t.success(l):t.success,d=typeof t.description=="function"?await t.description(l):t.description;this.create({id:n,type:"success",message:c,description:d})}}).catch(async l=>{if(s=["reject",l],t.error!==void 0){o=!1;let c=typeof t.error=="function"?await t.error(l):t.error,d=typeof t.description=="function"?await t.description(l):t.description;this.create({id:n,type:"error",message:c,description:d})}}).finally(()=>{var l;o&&(this.dismiss(n),n=void 0),(l=t.finally)==null||l.call(t)}),a=()=>new Promise((l,c)=>i.then(()=>s[0]==="reject"?c(s[1]):l(s[1])).catch(c));return typeof n!="string"&&typeof n!="number"?{unwrap:a}:Object.assign(n,{unwrap:a})},this.custom=(e,t)=>{let n=(t==null?void 0:t.id)||Xl++;return this.create({jsx:e(n),id:n,...t}),n},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},Wt=new $I,FI=(e,t)=>{let n=(t==null?void 0:t.id)||Xl++;return Wt.addToast({title:e,...t,id:n}),n},BI=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",zI=FI,HI=()=>Wt.toasts,UI=()=>Wt.getActiveToasts();Object.assign(zI,{success:Wt.success,info:Wt.info,warning:Wt.warning,error:Wt.error,custom:Wt.custom,message:Wt.message,promise:Wt.promise,dismiss:Wt.dismiss,loading:Wt.loading},{getHistory:HI,getToasts:UI});function WI(e,{insertAt:t}={}){if(typeof document>"u")return;let n=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",t==="top"&&n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r),r.styleSheet?r.styleSheet.cssText=e:r.appendChild(document.createTextNode(e))}WI(`:where(html[dir="ltr"]),:where([data-sonner-toaster][dir="ltr"]){--toast-icon-margin-start: -3px;--toast-icon-margin-end: 4px;--toast-svg-margin-start: -1px;--toast-svg-margin-end: 0px;--toast-button-margin-start: auto;--toast-button-margin-end: 0;--toast-close-button-start: 0;--toast-close-button-end: unset;--toast-close-button-transform: translate(-35%, -35%)}:where(html[dir="rtl"]),:where([data-sonner-toaster][dir="rtl"]){--toast-icon-margin-start: 4px;--toast-icon-margin-end: -3px;--toast-svg-margin-start: 0px;--toast-svg-margin-end: -1px;--toast-button-margin-start: 0;--toast-button-margin-end: auto;--toast-close-button-start: unset;--toast-close-button-end: 0;--toast-close-button-transform: translate(35%, -35%)}:where([data-sonner-toaster]){position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1: hsl(0, 0%, 99%);--gray2: hsl(0, 0%, 97.3%);--gray3: hsl(0, 0%, 95.1%);--gray4: hsl(0, 0%, 93%);--gray5: hsl(0, 0%, 90.9%);--gray6: hsl(0, 0%, 88.7%);--gray7: hsl(0, 0%, 85.8%);--gray8: hsl(0, 0%, 78%);--gray9: hsl(0, 0%, 56.1%);--gray10: hsl(0, 0%, 52.3%);--gray11: hsl(0, 0%, 43.5%);--gray12: hsl(0, 0%, 9%);--border-radius: 8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:none;z-index:999999999;transition:transform .4s ease}:where([data-sonner-toaster][data-lifted="true"]){transform:translateY(-10px)}@media (hover: none) and (pointer: coarse){:where([data-sonner-toaster][data-lifted="true"]){transform:none}}:where([data-sonner-toaster][data-x-position="right"]){right:var(--offset-right)}:where([data-sonner-toaster][data-x-position="left"]){left:var(--offset-left)}:where([data-sonner-toaster][data-x-position="center"]){left:50%;transform:translate(-50%)}:where([data-sonner-toaster][data-y-position="top"]){top:var(--offset-top)}:where([data-sonner-toaster][data-y-position="bottom"]){bottom:var(--offset-bottom)}:where([data-sonner-toast]){--y: translateY(100%);--lift-amount: calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);filter:blur(0);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:none;overflow-wrap:anywhere}:where([data-sonner-toast][data-styled="true"]){padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px #0000001a;width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}:where([data-sonner-toast]:focus-visible){box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast][data-y-position="top"]){top:0;--y: translateY(-100%);--lift: 1;--lift-amount: calc(1 * var(--gap))}:where([data-sonner-toast][data-y-position="bottom"]){bottom:0;--y: translateY(100%);--lift: -1;--lift-amount: calc(var(--lift) * var(--gap))}:where([data-sonner-toast]) :where([data-description]){font-weight:400;line-height:1.4;color:inherit}:where([data-sonner-toast]) :where([data-title]){font-weight:500;line-height:1.5;color:inherit}:where([data-sonner-toast]) :where([data-icon]){display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}:where([data-sonner-toast][data-promise="true"]) :where([data-icon])>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}:where([data-sonner-toast]) :where([data-icon])>*{flex-shrink:0}:where([data-sonner-toast]) :where([data-icon]) svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}:where([data-sonner-toast]) :where([data-content]){display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;cursor:pointer;outline:none;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}:where([data-sonner-toast]) :where([data-button]):focus-visible{box-shadow:0 0 0 2px #0006}:where([data-sonner-toast]) :where([data-button]):first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}:where([data-sonner-toast]) :where([data-cancel]){color:var(--normal-text);background:rgba(0,0,0,.08)}:where([data-sonner-toast][data-theme="dark"]) :where([data-cancel]){background:rgba(255,255,255,.3)}:where([data-sonner-toast]) :where([data-close-button]){position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast] [data-close-button]{background:var(--gray1)}:where([data-sonner-toast]) :where([data-close-button]):focus-visible{box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast]) :where([data-disabled="true"]){cursor:not-allowed}:where([data-sonner-toast]):hover :where([data-close-button]):hover{background:var(--gray2);border-color:var(--gray5)}:where([data-sonner-toast][data-swiping="true"]):before{content:"";position:absolute;left:-50%;right:-50%;height:100%;z-index:-1}:where([data-sonner-toast][data-y-position="top"][data-swiping="true"]):before{bottom:50%;transform:scaleY(3) translateY(50%)}:where([data-sonner-toast][data-y-position="bottom"][data-swiping="true"]):before{top:50%;transform:scaleY(3) translateY(-50%)}:where([data-sonner-toast][data-swiping="false"][data-removed="true"]):before{content:"";position:absolute;inset:0;transform:scaleY(2)}:where([data-sonner-toast]):after{content:"";position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}:where([data-sonner-toast][data-mounted="true"]){--y: translateY(0);opacity:1}:where([data-sonner-toast][data-expanded="false"][data-front="false"]){--scale: var(--toasts-before) * .05 + 1;--y: translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}:where([data-sonner-toast])>*{transition:opacity .4s}:where([data-sonner-toast][data-expanded="false"][data-front="false"][data-styled="true"])>*{opacity:0}:where([data-sonner-toast][data-visible="false"]){opacity:0;pointer-events:none}:where([data-sonner-toast][data-mounted="true"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}:where([data-sonner-toast][data-removed="true"][data-front="true"][data-swipe-out="false"]){--y: translateY(calc(var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="false"]){--y: translateY(40%);opacity:0;transition:transform .5s,opacity .2s}:where([data-sonner-toast][data-removed="true"][data-front="false"]):before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y, 0px)) translate(var(--swipe-amount-x, 0px));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width: 600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-theme=light]{--normal-bg: #fff;--normal-border: var(--gray4);--normal-text: var(--gray12);--success-bg: hsl(143, 85%, 96%);--success-border: hsl(145, 92%, 91%);--success-text: hsl(140, 100%, 27%);--info-bg: hsl(208, 100%, 97%);--info-border: hsl(221, 91%, 91%);--info-text: hsl(210, 92%, 45%);--warning-bg: hsl(49, 100%, 97%);--warning-border: hsl(49, 91%, 91%);--warning-text: hsl(31, 92%, 45%);--error-bg: hsl(359, 100%, 97%);--error-border: hsl(359, 100%, 94%);--error-text: hsl(360, 100%, 45%)}[data-sonner-toaster][data-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg: #000;--normal-border: hsl(0, 0%, 20%);--normal-text: var(--gray1)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg: #fff;--normal-border: var(--gray3);--normal-text: var(--gray12)}[data-sonner-toaster][data-theme=dark]{--normal-bg: #000;--normal-bg-hover: hsl(0, 0%, 12%);--normal-border: hsl(0, 0%, 20%);--normal-border-hover: hsl(0, 0%, 25%);--normal-text: var(--gray1);--success-bg: hsl(150, 100%, 6%);--success-border: hsl(147, 100%, 12%);--success-text: hsl(150, 86%, 65%);--info-bg: hsl(215, 100%, 6%);--info-border: hsl(223, 100%, 12%);--info-text: hsl(216, 87%, 65%);--warning-bg: hsl(64, 100%, 6%);--warning-border: hsl(60, 100%, 12%);--warning-text: hsl(46, 87%, 65%);--error-bg: hsl(358, 76%, 10%);--error-border: hsl(357, 89%, 16%);--error-text: hsl(358, 100%, 81%)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success],[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info],[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning],[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error],[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size: 16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:nth-child(1){animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}to{opacity:.15}}@media (prefers-reduced-motion){[data-sonner-toast],[data-sonner-toast]>*,.sonner-loading-bar{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}
|
|
130
|
+
`);function pi(e){return e.label!==void 0}var VI=3,KI="32px",qI="16px",ex=4e3,GI=356,YI=14,XI=20,JI=200;function mn(...e){return e.filter(Boolean).join(" ")}function ZI(e){let[t,n]=e.split("-"),r=[];return t&&r.push(t),n&&r.push(n),r}var QI=e=>{var t,n,r,o,s,i,a,l,c,d,h;let{invert:m,toast:f,unstyled:v,interacting:g,setHeights:x,visibleToasts:y,heights:w,index:S,toasts:k,expanded:C,removeToast:T,defaultRichColors:E,closeButton:j,style:_,cancelButtonStyle:D,actionButtonStyle:F,className:G="",descriptionClassName:K="",duration:A,position:Y,gap:q,loadingIcon:W,expandByDefault:R,classNames:I,icons:z,closeButtonAriaLabel:J="Close toast",pauseWhenPageIsHidden:P}=e,[O,M]=b.useState(null),[L,ee]=b.useState(null),[H,$]=b.useState(!1),[Z,te]=b.useState(!1),[Q,U]=b.useState(!1),[le,ie]=b.useState(!1),[ge,we]=b.useState(!1),[Ce,Ae]=b.useState(0),[Ee,st]=b.useState(0),lt=b.useRef(f.duration||A||ex),St=b.useRef(null),Oe=b.useRef(null),qe=S===0,We=S+1<=y,je=f.type,_e=f.dismissible!==!1,ct=f.className||"",kt=f.descriptionClassName||"",nt=b.useMemo(()=>w.findIndex(ae=>ae.toastId===f.id)||0,[w,f.id]),Et=b.useMemo(()=>{var ae;return(ae=f.closeButton)!=null?ae:j},[f.closeButton,j]),bt=b.useMemo(()=>f.duration||A||ex,[f.duration,A]),wt=b.useRef(0),Ct=b.useRef(0),on=b.useRef(0),Tt=b.useRef(null),[Lt,_t]=Y.split("-"),$e=b.useMemo(()=>w.reduce((ae,me,Se)=>Se>=nt?ae:ae+me.height,0),[w,nt]),ze=LI(),Mt=f.invert||m,X=je==="loading";Ct.current=b.useMemo(()=>nt*q+$e,[nt,$e]),b.useEffect(()=>{lt.current=bt},[bt]),b.useEffect(()=>{$(!0)},[]),b.useEffect(()=>{let ae=Oe.current;if(ae){let me=ae.getBoundingClientRect().height;return st(me),x(Se=>[{toastId:f.id,height:me,position:f.position},...Se]),()=>x(Se=>Se.filter(Ve=>Ve.toastId!==f.id))}},[x,f.id]),b.useLayoutEffect(()=>{if(!H)return;let ae=Oe.current,me=ae.style.height;ae.style.height="auto";let Se=ae.getBoundingClientRect().height;ae.style.height=me,st(Se),x(Ve=>Ve.find(it=>it.toastId===f.id)?Ve.map(it=>it.toastId===f.id?{...it,height:Se}:it):[{toastId:f.id,height:Se,position:f.position},...Ve])},[H,f.title,f.description,x,f.id]);let fe=b.useCallback(()=>{te(!0),Ae(Ct.current),x(ae=>ae.filter(me=>me.toastId!==f.id)),setTimeout(()=>{T(f)},JI)},[f,T,x,Ct]);b.useEffect(()=>{if(f.promise&&je==="loading"||f.duration===1/0||f.type==="loading")return;let ae;return C||g||P&&ze?(()=>{if(on.current<wt.current){let me=new Date().getTime()-wt.current;lt.current=lt.current-me}on.current=new Date().getTime()})():lt.current!==1/0&&(wt.current=new Date().getTime(),ae=setTimeout(()=>{var me;(me=f.onAutoClose)==null||me.call(f,f),fe()},lt.current)),()=>clearTimeout(ae)},[C,g,f,je,P,ze,fe]),b.useEffect(()=>{f.delete&&fe()},[fe,f.delete]);function He(){var ae,me,Se;return z!=null&&z.loading?b.createElement("div",{className:mn(I==null?void 0:I.loader,(ae=f==null?void 0:f.classNames)==null?void 0:ae.loader,"sonner-loader"),"data-visible":je==="loading"},z.loading):W?b.createElement("div",{className:mn(I==null?void 0:I.loader,(me=f==null?void 0:f.classNames)==null?void 0:me.loader,"sonner-loader"),"data-visible":je==="loading"},W):b.createElement(PI,{className:mn(I==null?void 0:I.loader,(Se=f==null?void 0:f.classNames)==null?void 0:Se.loader),visible:je==="loading"})}return b.createElement("li",{tabIndex:0,ref:Oe,className:mn(G,ct,I==null?void 0:I.toast,(t=f==null?void 0:f.classNames)==null?void 0:t.toast,I==null?void 0:I.default,I==null?void 0:I[je],(n=f==null?void 0:f.classNames)==null?void 0:n[je]),"data-sonner-toast":"","data-rich-colors":(r=f.richColors)!=null?r:E,"data-styled":!(f.jsx||f.unstyled||v),"data-mounted":H,"data-promise":!!f.promise,"data-swiped":ge,"data-removed":Z,"data-visible":We,"data-y-position":Lt,"data-x-position":_t,"data-index":S,"data-front":qe,"data-swiping":Q,"data-dismissible":_e,"data-type":je,"data-invert":Mt,"data-swipe-out":le,"data-swipe-direction":L,"data-expanded":!!(C||R&&H),style:{"--index":S,"--toasts-before":S,"--z-index":k.length-S,"--offset":`${Z?Ce:Ct.current}px`,"--initial-height":R?"auto":`${Ee}px`,..._,...f.style},onDragEnd:()=>{U(!1),M(null),Tt.current=null},onPointerDown:ae=>{X||!_e||(St.current=new Date,Ae(Ct.current),ae.target.setPointerCapture(ae.pointerId),ae.target.tagName!=="BUTTON"&&(U(!0),Tt.current={x:ae.clientX,y:ae.clientY}))},onPointerUp:()=>{var ae,me,Se,Ve;if(le||!_e)return;Tt.current=null;let it=Number(((ae=Oe.current)==null?void 0:ae.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),et=Number(((me=Oe.current)==null?void 0:me.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),Qt=new Date().getTime()-((Se=St.current)==null?void 0:Se.getTime()),Re=O==="x"?it:et,pt=Math.abs(Re)/Qt;if(Math.abs(Re)>=XI||pt>.11){Ae(Ct.current),(Ve=f.onDismiss)==null||Ve.call(f,f),ee(O==="x"?it>0?"right":"left":et>0?"down":"up"),fe(),ie(!0),we(!1);return}U(!1),M(null)},onPointerMove:ae=>{var me,Se,Ve,it;if(!Tt.current||!_e||((me=window.getSelection())==null?void 0:me.toString().length)>0)return;let et=ae.clientY-Tt.current.y,Qt=ae.clientX-Tt.current.x,Re=(Se=e.swipeDirections)!=null?Se:ZI(Y);!O&&(Math.abs(Qt)>1||Math.abs(et)>1)&&M(Math.abs(Qt)>Math.abs(et)?"x":"y");let pt={x:0,y:0};O==="y"?(Re.includes("top")||Re.includes("bottom"))&&(Re.includes("top")&&et<0||Re.includes("bottom")&&et>0)&&(pt.y=et):O==="x"&&(Re.includes("left")||Re.includes("right"))&&(Re.includes("left")&&Qt<0||Re.includes("right")&&Qt>0)&&(pt.x=Qt),(Math.abs(pt.x)>0||Math.abs(pt.y)>0)&&we(!0),(Ve=Oe.current)==null||Ve.style.setProperty("--swipe-amount-x",`${pt.x}px`),(it=Oe.current)==null||it.style.setProperty("--swipe-amount-y",`${pt.y}px`)}},Et&&!f.jsx?b.createElement("button",{"aria-label":J,"data-disabled":X,"data-close-button":!0,onClick:X||!_e?()=>{}:()=>{var ae;fe(),(ae=f.onDismiss)==null||ae.call(f,f)},className:mn(I==null?void 0:I.closeButton,(o=f==null?void 0:f.classNames)==null?void 0:o.closeButton)},(s=z==null?void 0:z.close)!=null?s:DI):null,f.jsx||b.isValidElement(f.title)?f.jsx?f.jsx:typeof f.title=="function"?f.title():f.title:b.createElement(b.Fragment,null,je||f.icon||f.promise?b.createElement("div",{"data-icon":"",className:mn(I==null?void 0:I.icon,(i=f==null?void 0:f.classNames)==null?void 0:i.icon)},f.promise||f.type==="loading"&&!f.icon?f.icon||He():null,f.type!=="loading"?f.icon||(z==null?void 0:z[je])||AI(je):null):null,b.createElement("div",{"data-content":"",className:mn(I==null?void 0:I.content,(a=f==null?void 0:f.classNames)==null?void 0:a.content)},b.createElement("div",{"data-title":"",className:mn(I==null?void 0:I.title,(l=f==null?void 0:f.classNames)==null?void 0:l.title)},typeof f.title=="function"?f.title():f.title),f.description?b.createElement("div",{"data-description":"",className:mn(K,kt,I==null?void 0:I.description,(c=f==null?void 0:f.classNames)==null?void 0:c.description)},typeof f.description=="function"?f.description():f.description):null),b.isValidElement(f.cancel)?f.cancel:f.cancel&&pi(f.cancel)?b.createElement("button",{"data-button":!0,"data-cancel":!0,style:f.cancelButtonStyle||D,onClick:ae=>{var me,Se;pi(f.cancel)&&_e&&((Se=(me=f.cancel).onClick)==null||Se.call(me,ae),fe())},className:mn(I==null?void 0:I.cancelButton,(d=f==null?void 0:f.classNames)==null?void 0:d.cancelButton)},f.cancel.label):null,b.isValidElement(f.action)?f.action:f.action&&pi(f.action)?b.createElement("button",{"data-button":!0,"data-action":!0,style:f.actionButtonStyle||F,onClick:ae=>{var me,Se;pi(f.action)&&((Se=(me=f.action).onClick)==null||Se.call(me,ae),!ae.defaultPrevented&&fe())},className:mn(I==null?void 0:I.actionButton,(h=f==null?void 0:f.classNames)==null?void 0:h.actionButton)},f.action.label):null))};function tx(){if(typeof window>"u"||typeof document>"u")return"ltr";let e=document.documentElement.getAttribute("dir");return e==="auto"||!e?window.getComputedStyle(document.documentElement).direction:e}function eN(e,t){let n={};return[e,t].forEach((r,o)=>{let s=o===1,i=s?"--mobile-offset":"--offset",a=s?qI:KI;function l(c){["top","right","bottom","left"].forEach(d=>{n[`${i}-${d}`]=typeof c=="number"?`${c}px`:c})}typeof r=="number"||typeof r=="string"?l(r):typeof r=="object"?["top","right","bottom","left"].forEach(c=>{r[c]===void 0?n[`${i}-${c}`]=a:n[`${i}-${c}`]=typeof r[c]=="number"?`${r[c]}px`:r[c]}):l(a)}),n}var tN=b.forwardRef(function(e,t){let{invert:n,position:r="bottom-right",hotkey:o=["altKey","KeyT"],expand:s,closeButton:i,className:a,offset:l,mobileOffset:c,theme:d="light",richColors:h,duration:m,style:f,visibleToasts:v=VI,toastOptions:g,dir:x=tx(),gap:y=YI,loadingIcon:w,icons:S,containerAriaLabel:k="Notifications",pauseWhenPageIsHidden:C}=e,[T,E]=b.useState([]),j=b.useMemo(()=>Array.from(new Set([r].concat(T.filter(P=>P.position).map(P=>P.position)))),[T,r]),[_,D]=b.useState([]),[F,G]=b.useState(!1),[K,A]=b.useState(!1),[Y,q]=b.useState(d!=="system"?d:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),W=b.useRef(null),R=o.join("+").replace(/Key/g,"").replace(/Digit/g,""),I=b.useRef(null),z=b.useRef(!1),J=b.useCallback(P=>{E(O=>{var M;return(M=O.find(L=>L.id===P.id))!=null&&M.delete||Wt.dismiss(P.id),O.filter(({id:L})=>L!==P.id)})},[]);return b.useEffect(()=>Wt.subscribe(P=>{if(P.dismiss){E(O=>O.map(M=>M.id===P.id?{...M,delete:!0}:M));return}setTimeout(()=>{Mo.flushSync(()=>{E(O=>{let M=O.findIndex(L=>L.id===P.id);return M!==-1?[...O.slice(0,M),{...O[M],...P},...O.slice(M+1)]:[P,...O]})})})}),[]),b.useEffect(()=>{if(d!=="system"){q(d);return}if(d==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?q("dark"):q("light")),typeof window>"u")return;let P=window.matchMedia("(prefers-color-scheme: dark)");try{P.addEventListener("change",({matches:O})=>{q(O?"dark":"light")})}catch{P.addListener(({matches:M})=>{try{q(M?"dark":"light")}catch(L){console.error(L)}})}},[d]),b.useEffect(()=>{T.length<=1&&G(!1)},[T]),b.useEffect(()=>{let P=O=>{var M,L;o.every(ee=>O[ee]||O.code===ee)&&(G(!0),(M=W.current)==null||M.focus()),O.code==="Escape"&&(document.activeElement===W.current||(L=W.current)!=null&&L.contains(document.activeElement))&&G(!1)};return document.addEventListener("keydown",P),()=>document.removeEventListener("keydown",P)},[o]),b.useEffect(()=>{if(W.current)return()=>{I.current&&(I.current.focus({preventScroll:!0}),I.current=null,z.current=!1)}},[W.current]),b.createElement("section",{ref:t,"aria-label":`${k} ${R}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},j.map((P,O)=>{var M;let[L,ee]=P.split("-");return T.length?b.createElement("ol",{key:P,dir:x==="auto"?tx():x,tabIndex:-1,ref:W,className:a,"data-sonner-toaster":!0,"data-theme":Y,"data-y-position":L,"data-lifted":F&&T.length>1&&!s,"data-x-position":ee,style:{"--front-toast-height":`${((M=_[0])==null?void 0:M.height)||0}px`,"--width":`${GI}px`,"--gap":`${y}px`,...f,...eN(l,c)},onBlur:H=>{z.current&&!H.currentTarget.contains(H.relatedTarget)&&(z.current=!1,I.current&&(I.current.focus({preventScroll:!0}),I.current=null))},onFocus:H=>{H.target instanceof HTMLElement&&H.target.dataset.dismissible==="false"||z.current||(z.current=!0,I.current=H.relatedTarget)},onMouseEnter:()=>G(!0),onMouseMove:()=>G(!0),onMouseLeave:()=>{K||G(!1)},onDragEnd:()=>G(!1),onPointerDown:H=>{H.target instanceof HTMLElement&&H.target.dataset.dismissible==="false"||A(!0)},onPointerUp:()=>A(!1)},T.filter(H=>!H.position&&O===0||H.position===P).map((H,$)=>{var Z,te;return b.createElement(QI,{key:H.id,icons:S,index:$,toast:H,defaultRichColors:h,duration:(Z=g==null?void 0:g.duration)!=null?Z:m,className:g==null?void 0:g.className,descriptionClassName:g==null?void 0:g.descriptionClassName,invert:n,visibleToasts:v,closeButton:(te=g==null?void 0:g.closeButton)!=null?te:i,interacting:K,position:P,style:g==null?void 0:g.style,unstyled:g==null?void 0:g.unstyled,classNames:g==null?void 0:g.classNames,cancelButtonStyle:g==null?void 0:g.cancelButtonStyle,actionButtonStyle:g==null?void 0:g.actionButtonStyle,removeToast:J,toasts:T.filter(Q=>Q.position==H.position),heights:_.filter(Q=>Q.position==H.position),setHeights:D,expandByDefault:s,gap:y,loadingIcon:w,expanded:F,pauseWhenPageIsHidden:C,swipeDirections:e.swipeDirections})})):null}))});const nN=({...e})=>{const{theme:t="system"}=NI();return u.jsx(tN,{theme:t,className:"toaster group",toastOptions:{classNames:{toast:"group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",description:"group-[.toast]:text-muted-foreground",actionButton:"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",cancelButton:"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground"}},...e})};B.Api=Hv,B.ApiClient=zv,B.ApiProvider=nu,B.ArtifactRenderer=kp,B.Badge=Op,B.Button=Xe,B.Card=il,B.CardContent=ul,B.CardDescription=cl,B.CardHeader=al,B.CardTitle=ll,B.ChatApi=qo,B.ChatApp=Dk,B.ChatInput=Uf,B.ChatInputRow=Wf,B.ChatInterface=Rr,B.ChatProviders=br,B.ChatWidget=Fk,B.Command=yl,B.CommandEmpty=Tl,B.CommandGroup=kl,B.CommandInput=Sl,B.CommandItem=El,B.CommandList=Cl,B.DEFAULT_TIMEOUT_MS=Xc,B.Dialog=el,B.DialogContent=zs,B.DialogHeader=Hs,B.DialogTitle=Us,B.DropdownMenu=Cs,B.DropdownMenuContent=ho,B.DropdownMenuItem=Bn,B.DropdownMenuTrigger=Ts,B.FileViewerModal=lp,B.HISTORY_TIMEOUT_MS=Jc,B.Input=Ml,B.InterruptPartRenderer=Ip,B.Label=mm,B.MarkdownContent=qn,B.MessageComponent=Xs,B.MessageList=pl,B.MessageRow=hl,B.NewChatButton=Bk,B.PlotArtifact=Sp,B.ResearchTaskArtifact=Tp,B.SETTINGS_STORAGE_KEY=Fi,B.ScrollArea=_l,B.Select=bE,B.SelectContent=ng,B.SelectItem=rg,B.SelectTrigger=Qm,B.SelectValue=wE,B.Separator=ag,B.Sheet=PE,B.SheetContent=gg,B.SheetDescription=bg,B.SheetHeader=xg,B.SheetTitle=vg,B.SheetTrigger=_E,B.SimpleChat=Lk,B.SimpleJsonView=dl,B.Sonner=nN,B.StreamProgress=Np,B.Switch=pg,B.Textarea=ka,B.ThinkingIndicator=Ap,B.ThreadListItem=cm,B.ThreadManager=ni,B.ThreadStateProvider=ku,B.ThreadsProvider=hu,B.TimelineColumn=vx,B.Toaster=TI,B.ToolComponent=Pp,B.Tooltip=tI,B.TooltipContent=Ng,B.TooltipProvider=eI,B.TooltipTrigger=nI,B.UserTextContent=jp,B.applySettings=Sb,B.buildCheckpointIndex=ec,B.buildCheckpointPreviewMap=ax,B.chatApiClient=Nn,B.del=ji,B.downloadFileById=Qc,B.extractConfigFields=gi,B.fileToBase64=ru,B.get=Gt,B.getChatToken=Gc,B.getCheckpointForMessage=lx,B.getCurrentSettings=yb,B.getDefaultApiConfig=Ru,B.getDefaultChatSettings=Ou,B.getFileContent=_i,B.getFileInfo=Wv,B.getMessageAttemptInfo=tc,B.getMessageDomKey=fl,B.getPreviewForMessage=mi,B.httpClient=qt,B.hydrateHistorySnapshots=Rn,B.isEnvelope=su,B.listFiles=eu,B.loadStoredSettings=Du,B.onChatTokenChanged=Yc,B.post=Ko,B.processAttachments=ou,B.put=Zc,B.readNumber=rc,B.readString=Mn,B.resolveChatBaseUrl=xn,B.saveSettings=Lu,B.setChatToken=Vo,B.toPlainObject=_n,B.unwrap=Rt,B.useApi=Xr,B.useCheckpointIndex=nc,B.useFilePreview=_p,B.useHasChatSession=vb,B.useParsedMessageContent=Mp,B.useShallowStableValue=ju,B.useStream=$i,B.useStreamingHook=$i,B.useThreadHistoryState=yu,B.useThreadManagerViewState=fm,B.useThreadState=eo,B.useThreadStateUpdater=Tu,B.useThreads=xr,B.useThreadsState=du,B.viewFileById=Uv,Object.defineProperty(B,Symbol.toStringTag,{value:"Module"})});
|