teodor-new-chat-ui 4.3.554 → 4.3.555
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/features/streaming/utils/types.d.ts +19 -2
- package/dist/index.esm.js +2245 -2202
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +25 -25
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
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 mc;function Px(){return mc||(mc=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"),f=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),p=Symbol.for("react.offscreen"),v=Symbol.iterator,g="@@iterator";function x(N){if(N===null||typeof N!="object")return null;var
|
|
18
|
-
`+R+N}}var U=!1,Z;{var re=typeof WeakMap=="function"?WeakMap:Map;Z=new re}function
|
|
19
|
-
`),Ut=
|
|
20
|
-
`),
|
|
21
|
-
`+
|
|
17
|
+
*/var mc;function Px(){return mc||(mc=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"),f=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),p=Symbol.for("react.offscreen"),v=Symbol.iterator,g="@@iterator";function x(N){if(N===null||typeof N!="object")return null;var Q=v&&N[v]||N[g];return typeof Q=="function"?Q:null}var y=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function w(N){{for(var Q=arguments.length,ee=new Array(Q>1?Q-1:0),le=1;le<Q;le++)ee[le-1]=arguments[le];C("error",N,ee)}}function C(N,Q,ee){{var le=y.ReactDebugCurrentFrame,me=le.getStackAddendum();me!==""&&(Q+="%s",ee=ee.concat([me]));var Se=ee.map(function(be){return String(be)});Se.unshift("Warning: "+Q),Function.prototype.apply.call(console[N],console,Se)}}var E=!1,T=!1,S=!1,k=!1,A=!1,j;j=Symbol.for("react.module.reference");function F(N){return!!(typeof N=="string"||typeof N=="function"||N===r||N===s||A||N===o||N===c||N===d||k||N===p||E||T||S||typeof N=="object"&&N!==null&&(N.$$typeof===m||N.$$typeof===f||N.$$typeof===i||N.$$typeof===a||N.$$typeof===l||N.$$typeof===j||N.getModuleId!==void 0))}function D(N,Q,ee){var le=N.displayName;if(le)return le;var me=Q.displayName||Q.name||"";return me!==""?ee+"("+me+")":ee}function B(N){return N.displayName||"Context"}function G(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 Q=N;return B(Q)+".Consumer";case i:var ee=N;return B(ee._context)+".Provider";case l:return D(N,N.render,"ForwardRef");case f:var le=N.displayName||null;return le!==null?le:G(N.type)||"Memo";case m:{var me=N,Se=me._payload,be=me._init;try{return G(be(Se))}catch{return null}}}return null}var M=Object.assign,W=0,Y,z,P,I,K,te,O;function q(){}q.__reactDisabledLog=!0;function L(){{if(W===0){Y=console.log,z=console.info,P=console.warn,I=console.error,K=console.group,te=console.groupCollapsed,O=console.groupEnd;var N={configurable:!0,enumerable:!0,value:q,writable:!0};Object.defineProperties(console,{info:N,log:N,warn:N,error:N,group:N,groupCollapsed:N,groupEnd:N})}W++}}function $(){{if(W--,W===0){var N={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:M({},N,{value:Y}),info:M({},N,{value:z}),warn:M({},N,{value:P}),error:M({},N,{value:I}),group:M({},N,{value:K}),groupCollapsed:M({},N,{value:te}),groupEnd:M({},N,{value:O})})}W<0&&w("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var X=y.ReactCurrentDispatcher,R;function _(N,Q,ee){{if(R===void 0)try{throw Error()}catch(me){var le=me.stack.trim().match(/\n( *(at )?)/);R=le&&le[1]||""}return`
|
|
18
|
+
`+R+N}}var U=!1,Z;{var re=typeof WeakMap=="function"?WeakMap:Map;Z=new re}function ce(N,Q){if(!N||U)return"";{var ee=Z.get(N);if(ee!==void 0)return ee}var le;U=!0;var me=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var Se;Se=X.current,X.current=null,L();try{if(Q){var be=function(){throw Error()};if(Object.defineProperty(be.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(be,[])}catch(Xt){le=Xt}Reflect.construct(N,[],be)}else{try{be.call()}catch(Xt){le=Xt}N.call(be.prototype)}}else{try{throw Error()}catch(Xt){le=Xt}N()}}catch(Xt){if(Xt&&le&&typeof Xt.stack=="string"){for(var Ie=Xt.stack.split(`
|
|
19
|
+
`),Ut=le.stack.split(`
|
|
20
|
+
`),St=Ie.length-1,Et=Ut.length-1;St>=1&&Et>=0&&Ie[St]!==Ut[Et];)Et--;for(;St>=1&&Et>=0;St--,Et--)if(Ie[St]!==Ut[Et]){if(St!==1||Et!==1)do if(St--,Et--,Et<0||Ie[St]!==Ut[Et]){var ln=`
|
|
21
|
+
`+Ie[St].replace(" at new "," at ");return N.displayName&&ln.includes("<anonymous>")&&(ln=ln.replace("<anonymous>",N.displayName)),typeof N=="function"&&Z.set(N,ln),ln}while(St>=1&&Et>=0);break}}}finally{U=!1,X.current=Se,$(),Error.prepareStackTrace=me}var Vr=N?N.displayName||N.name:"",xr=Vr?_(Vr):"";return typeof N=="function"&&Z.set(N,xr),xr}function Ne(N,Q,ee){return ce(N,!1)}function ye(N){var Q=N.prototype;return!!(Q&&Q.isReactComponent)}function Re(N,Q,ee){if(N==null)return"";if(typeof N=="function")return ce(N,ye(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 Ne(N.render);case f:return Re(N.type,Q,ee);case m:{var le=N,me=le._payload,Se=le._init;try{return Re(Se(me),Q,ee)}catch{}}}return""}var We=Object.prototype.hasOwnProperty,Fe={},Ye=y.ReactDebugCurrentFrame;function Ve(N){if(N){var Q=N._owner,ee=Re(N.type,N._source,Q?Q.type:null);Ye.setExtraStackFrame(ee)}else Ye.setExtraStackFrame(null)}function tt(N,Q,ee,le,me){{var Se=Function.call.bind(We);for(var be in N)if(Se(N,be)){var Ie=void 0;try{if(typeof N[be]!="function"){var Ut=Error((le||"React class")+": "+ee+" type `"+be+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof N[be]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw Ut.name="Invariant Violation",Ut}Ie=N[be](Q,be,le,ee,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(St){Ie=St}Ie&&!(Ie instanceof Error)&&(Ve(me),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).",le||"React class",ee,be,typeof Ie),Ve(null)),Ie instanceof Error&&!(Ie.message in Fe)&&(Fe[Ie.message]=!0,Ve(me),w("Failed %s type: %s",ee,Ie.message),Ve(null))}}}var gt=Array.isArray;function at(N){return gt(N)}function lt(N){{var Q=typeof Symbol=="function"&&Symbol.toStringTag,ee=Q&&N[Symbol.toStringTag]||N.constructor.name||"Object";return ee}}function Me(N){try{return Ke(N),!1}catch{return!0}}function Ke(N){return""+N}function je(N){if(Me(N))return w("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",lt(N)),Ke(N)}var qe=y.ReactCurrentOwner,Be={key:!0,ref:!0,__self:!0,__source:!0},nt,ct;function ft(N){if(We.call(N,"ref")){var Q=Object.getOwnPropertyDescriptor(N,"ref").get;if(Q&&Q.isReactWarning)return!1}return N.ref!==void 0}function yt(N){if(We.call(N,"key")){var Q=Object.getOwnPropertyDescriptor(N,"key").get;if(Q&&Q.isReactWarning)return!1}return N.key!==void 0}function Tt(N,Q){typeof N.ref=="string"&&qe.current}function pt(N,Q){{var ee=function(){nt||(nt=!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)",Q))};ee.isReactWarning=!0,Object.defineProperty(N,"key",{get:ee,configurable:!0})}}function At(N,Q){{var ee=function(){ct||(ct=!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)",Q))};ee.isReactWarning=!0,Object.defineProperty(N,"ref",{get:ee,configurable:!0})}}var xt=function(N,Q,ee,le,me,Se,be){var Ie={$$typeof:t,type:N,key:Q,ref:ee,props:be,_owner:Se};return Ie._store={},Object.defineProperty(Ie._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(Ie,"_self",{configurable:!1,enumerable:!1,writable:!1,value:le}),Object.defineProperty(Ie,"_source",{configurable:!1,enumerable:!1,writable:!1,value:me}),Object.freeze&&(Object.freeze(Ie.props),Object.freeze(Ie)),Ie};function ht(N,Q,ee,le,me){{var Se,be={},Ie=null,Ut=null;ee!==void 0&&(je(ee),Ie=""+ee),yt(Q)&&(je(Q.key),Ie=""+Q.key),ft(Q)&&(Ut=Q.ref,Tt(Q,me));for(Se in Q)We.call(Q,Se)&&!Be.hasOwnProperty(Se)&&(be[Se]=Q[Se]);if(N&&N.defaultProps){var St=N.defaultProps;for(Se in St)be[Se]===void 0&&(be[Se]=St[Se])}if(Ie||Ut){var Et=typeof N=="function"?N.displayName||N.name||"Unknown":N;Ie&&pt(be,Et),Ut&&At(be,Et)}return xt(N,Ie,Ut,me,le,qe.current,be)}}var zt=y.ReactCurrentOwner,Ht=y.ReactDebugCurrentFrame;function Oe(N){if(N){var Q=N._owner,ee=Re(N.type,N._source,Q?Q.type:null);Ht.setExtraStackFrame(ee)}else Ht.setExtraStackFrame(null)}var ze;ze=!1;function kt(N){return typeof N=="object"&&N!==null&&N.$$typeof===t}function ut(){{if(zt.current){var N=G(zt.current.type);if(N)return`
|
|
22
22
|
|
|
23
|
-
Check the render method of \``+N+"`."}return""}}function
|
|
23
|
+
Check the render method of \``+N+"`."}return""}}function Pt(N){return""}var ge={};function De(N){{var Q=ut();if(!Q){var ee=typeof N=="string"?N:N.displayName||N.name;ee&&(Q=`
|
|
24
24
|
|
|
25
|
-
Check the top-level render call using <`+ee+">.")}return
|
|
25
|
+
Check the top-level render call using <`+ee+">.")}return Q}}function He(N,Q){{if(!N._store||N._store.validated||N.key!=null)return;N._store.validated=!0;var ee=De(Q);if(ge[ee])return;ge[ee]=!0;var le="";N&&N._owner&&N._owner!==zt.current&&(le=" It was passed a child from "+G(N._owner.type)+"."),Oe(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.',ee,le),Oe(null)}}function st(N,Q){{if(typeof N!="object")return;if(at(N))for(var ee=0;ee<N.length;ee++){var le=N[ee];kt(le)&&He(le,Q)}else if(kt(N))N._store&&(N._store.validated=!0);else if(N){var me=x(N);if(typeof me=="function"&&me!==N.entries)for(var Se=me.call(N),be;!(be=Se.next()).done;)kt(be.value)&&He(be.value,Q)}}}function et(N){{var Q=N.type;if(Q==null||typeof Q=="string")return;var ee;if(typeof Q=="function")ee=Q.propTypes;else if(typeof Q=="object"&&(Q.$$typeof===l||Q.$$typeof===f))ee=Q.propTypes;else return;if(ee){var le=G(Q);tt(ee,N.props,"prop",le,N)}else if(Q.PropTypes!==void 0&&!ze){ze=!0;var me=G(Q);w("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",me||"Unknown")}typeof Q.getDefaultProps=="function"&&!Q.getDefaultProps.isReactClassApproved&&w("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function dt(N){{for(var Q=Object.keys(N.props),ee=0;ee<Q.length;ee++){var le=Q[ee];if(le!=="children"&&le!=="key"){Oe(N),w("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",le),Oe(null);break}}N.ref!==null&&(Oe(N),w("Invalid attribute `ref` supplied to `React.Fragment`."),Oe(null))}}var mt={};function J(N,Q,ee,le,me,Se){{var be=F(N);if(!be){var Ie="";(N===void 0||typeof N=="object"&&N!==null&&Object.keys(N).length===0)&&(Ie+=" 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 Ut=Pt();Ut?Ie+=Ut:Ie+=ut();var St;N===null?St="null":at(N)?St="array":N!==void 0&&N.$$typeof===t?(St="<"+(G(N.type)||"Unknown")+" />",Ie=" Did you accidentally export a JSX literal instead of a component?"):St=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",St,Ie)}var Et=ht(N,Q,ee,me,Se);if(Et==null)return Et;if(be){var ln=Q.children;if(ln!==void 0)if(le)if(at(ln)){for(var Vr=0;Vr<ln.length;Vr++)st(ln[Vr],N);Object.freeze&&Object.freeze(ln)}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 st(ln,N)}if(We.call(Q,"key")){var xr=G(N),Xt=Object.keys(Q).filter(function(gN){return gN!=="key"}),sc=Xt.length>0?"{key: someKey, "+Xt.join(": ..., ")+": ...}":"{key: someKey}";if(!mt[xr+sc]){var mN=Xt.length>0?"{"+Xt.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} />`,sc,xr,mN,xr),gt[xr+sc]=!0}}return N===r?ot(Et):Qe(Et),Et}}function se(N,te,ee){return K(N,te,ee,!0)}function ae(N,te,ee){return K(N,te,ee,!1)}var me=ae,st=se;Yr.Fragment=r,Yr.jsx=me,Yr.jsxs=st}()),Yr}process.env.NODE_ENV==="production"?wi.exports=jx():wi.exports=Px();var u=wi.exports;const _x=({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(p=>{const v=d===p.id,g=(r==null?void 0:r.get(p.id))??null;return u.jsxs("button",{type:"button",disabled:!n,onClick:()=>n==null?void 0:n(p.id),className:`relative flex items-start gap-2 text-left text-[11px] transition ${v?"text-primary":"text-muted-foreground"} ${n?"hover:text-foreground":"cursor-default opacity-70"}`,children:[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:p.label||"User input"}),u.jsxs("span",{className:"text-[9px] uppercase tracking-wide text-muted-foreground/70",children:[p.step!==null?`STEP ${p.step}`:"STEP —",p.next?` - ${p.next}`:""]}),g&&u.jsx("p",{className:"text-[10px] text-muted-foreground/80 mt-1 line-clamp-2",title:g,children:g})]})]},p.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 gc(e,t){return function(){return e.apply(t,arguments)}}const{toString:Rx}=Object.prototype,{getPrototypeOf:yi}=Object,{iterator:Lo,toStringTag:xc}=Symbol,$o=(e=>t=>{const n=Rx.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),cn=e=>(e=e.toLowerCase(),t=>$o(t)===e),Fo=e=>t=>typeof t===e,{isArray:vr}=Array,br=Fo("undefined");function Xr(e){return e!==null&&!br(e)&&e.constructor!==null&&!br(e.constructor)&&Wt(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const vc=cn("ArrayBuffer");function Mx(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&vc(e.buffer),t}const Ox=Fo("string"),Wt=Fo("function"),bc=Fo("number"),Jr=e=>e!==null&&typeof e=="object",Dx=e=>e===!0||e===!1,Bo=e=>{if($o(e)!=="object")return!1;const t=yi(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(xc in e)&&!(Lo in e)},Lx=e=>{if(!Jr(e)||Xr(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},$x=cn("Date"),Fx=cn("File"),Bx=cn("Blob"),zx=cn("FileList"),Hx=e=>Jr(e)&&Wt(e.pipe),Ux=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||Wt(e.append)&&((t=$o(e))==="formdata"||t==="object"&&Wt(e.toString)&&e.toString()==="[object FormData]"))},Wx=cn("URLSearchParams"),[Vx,Kx,qx,Gx]=["ReadableStream","Request","Response","Headers"].map(cn),Yx=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Zr(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,o;if(typeof e!="object"&&(e=[e]),vr(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{if(Xr(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 wc(e,t){if(Xr(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,yc=e=>!br(e)&&e!==Jn;function Si(){const{caseless:e,skipUndefined:t}=yc(this)&&this||{},n={},r=(o,s)=>{const i=e&&wc(n,s)||s;Bo(n[i])&&Bo(o)?n[i]=Si(n[i],o):Bo(o)?n[i]=Si({},o):vr(o)?n[i]=o.slice():(!t||!br(o))&&(n[i]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&Zr(arguments[o],r);return n}const Xx=(e,t,n,{allOwnKeys:r}={})=>(Zr(t,(o,s)=>{n&&Wt(o)?e[s]=gc(o,n):e[s]=o},{allOwnKeys:r}),e),Jx=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Zx=(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)},Qx=(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&&yi(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},ev=(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},tv=e=>{if(!e)return null;if(vr(e))return e;let t=e.length;if(!bc(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},nv=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&yi(Uint8Array)),rv=(e,t)=>{const r=(e&&e[Lo]).call(e);let o;for(;(o=r.next())&&!o.done;){const s=o.value;t.call(e,s[0],s[1])}},ov=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},sv=cn("HTMLFormElement"),iv=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),Sc=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),av=cn("RegExp"),Cc=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};Zr(n,(o,s)=>{let i;(i=t(o,s,e))!==!1&&(r[s]=i||o)}),Object.defineProperties(e,r)},lv=e=>{Cc(e,(t,n)=>{if(Wt(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(Wt(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+"'")})}})},cv=(e,t)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return vr(e)?r(e):r(String(e).split(t)),n},uv=()=>{},dv=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function fv(e){return!!(e&&Wt(e.append)&&e[xc]==="FormData"&&e[Lo])}const pv=e=>{const t=new Array(10),n=(r,o)=>{if(Jr(r)){if(t.indexOf(r)>=0)return;if(Xr(r))return r;if(!("toJSON"in r)){t[o]=r;const s=vr(r)?[]:{};return Zr(r,(i,a)=>{const l=n(i,o+1);!br(l)&&(s[a]=l)}),t[o]=void 0,s}}return r};return n(e,0)},hv=cn("AsyncFunction"),mv=e=>e&&(Jr(e)||Wt(e))&&Wt(e.then)&&Wt(e.catch),Tc=((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",Wt(Jn.postMessage)),gv=typeof queueMicrotask<"u"?queueMicrotask.bind(Jn):typeof process<"u"&&process.nextTick||Tc,V={isArray:vr,isArrayBuffer:vc,isBuffer:Xr,isFormData:Ux,isArrayBufferView:Mx,isString:Ox,isNumber:bc,isBoolean:Dx,isObject:Jr,isPlainObject:Bo,isEmptyObject:Lx,isReadableStream:Vx,isRequest:Kx,isResponse:qx,isHeaders:Gx,isUndefined:br,isDate:$x,isFile:Fx,isBlob:Bx,isRegExp:av,isFunction:Wt,isStream:Hx,isURLSearchParams:Wx,isTypedArray:nv,isFileList:zx,forEach:Zr,merge:Si,extend:Xx,trim:Yx,stripBOM:Jx,inherits:Zx,toFlatObject:Qx,kindOf:$o,kindOfTest:cn,endsWith:ev,toArray:tv,forEachEntry:rv,matchAll:ov,isHTMLForm:sv,hasOwnProperty:Sc,hasOwnProp:Sc,reduceDescriptors:Cc,freezeMethods:lv,toObjectSet:cv,toCamelCase:iv,noop:uv,toFiniteNumber:dv,findKey:wc,global:Jn,isContextDefined:yc,isSpecCompliantForm:fv,toJSONObject:pv,isAsyncFn:hv,isThenable:mv,setImmediate:Tc,asap:gv,isIterable:e=>e!=null&&Wt(e[Lo])};function Ae(e,t,n,r,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),o&&(this.response=o,this.status=o.status?o.status:null)}V.inherits(Ae,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:V.toJSONObject(this.config),code:this.code,status:this.status}}});const kc=Ae.prototype,Ec={};["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=>{Ec[e]={value:e}}),Object.defineProperties(Ae,Ec),Object.defineProperty(kc,"isAxiosError",{value:!0}),Ae.from=(e,t,n,r,o,s)=>{const i=Object.create(kc);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 Ae.call(i,a,l,n,r,o),e&&i.cause==null&&Object.defineProperty(i,"cause",{value:e,configurable:!0}),i.name=e&&e.name||"Error",s&&Object.assign(i,s),i};const xv=null;function Ci(e){return V.isPlainObject(e)||V.isArray(e)}function Ic(e){return V.endsWith(e,"[]")?e.slice(0,-2):e}function Nc(e,t,n){return e?e.concat(t).map(function(o,s){return o=Ic(o),!n&&s?"["+o+"]":o}).join(n?".":""):t}function vv(e){return V.isArray(e)&&!e.some(Ci)}const bv=V.toFlatObject(V,{},null,function(t){return/^is[A-Z]/.test(t)});function zo(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 Ae("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)&&vv(v)||(V.isFileList(v)||V.endsWith(g,"[]"))&&(y=V.toArray(v)))return g=Ic(g),y.forEach(function(C,E){!(V.isUndefined(C)||C===null)&&t.append(i===!0?Nc([g],E,s):i===null?g:g+"[]",c(C))}),!1}return Ci(v)?!0:(t.append(Nc(x,g,s),c(v)),!1)}const f=[],m=Object.assign(bv,{defaultVisitor:d,convertValue:c,isVisitable:Ci});function p(v,g){if(!V.isUndefined(v)){if(f.indexOf(v)!==-1)throw Error("Circular reference detected in "+g.join("."));f.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&&p(y,g?g.concat(w):[w])}),f.pop()}}if(!V.isObject(e))throw new TypeError("data must be an object");return p(e),t}function Ac(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function Ti(e,t){this._pairs=[],e&&zo(e,this,t)}const jc=Ti.prototype;jc.append=function(t,n){this._pairs.push([t,n])},jc.toString=function(t){const n=t?function(r){return t.call(this,r,Ac)}:Ac;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function wv(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Pc(e,t,n){if(!t)return e;const r=n&&n.encode||wv;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 Ti(t,n).toString(r),s){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}class _c{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 Rc={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},yv={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:Ti,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},ki=typeof window<"u"&&typeof document<"u",Ei=typeof navigator=="object"&&navigator||void 0,Sv=ki&&(!Ei||["ReactNative","NativeScript","NS"].indexOf(Ei.product)<0),Cv=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Tv=ki&&window.location.href||"http://localhost",Rt={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:ki,hasStandardBrowserEnv:Sv,hasStandardBrowserWebWorkerEnv:Cv,navigator:Ei,origin:Tv},Symbol.toStringTag,{value:"Module"})),...yv};function kv(e,t){return zo(e,new Rt.classes.URLSearchParams,{visitor:function(n,r,o,s){return Rt.isNode&&V.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function Ev(e){return V.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function Iv(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 Mc(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]=Iv(o[i])),!a)}if(V.isFormData(e)&&V.isFunction(e.entries)){const n={};return V.forEachEntry(e,(r,o)=>{t(Ev(r),o,n,0)}),n}return null}function Nv(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 Qr={transitional:Rc,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(Mc(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 kv(t,this.formSerializer).toString();if((a=V.isFileList(t))||r.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return zo(a?{"files[]":t}:t,l&&new l,this.formSerializer)}}return s||o?(n.setContentType("application/json",!1),Nv(t)):t}],transformResponse:[function(t){const n=this.transitional||Qr.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"?Ae.from(a,Ae.ERR_BAD_RESPONSE,this,null,this.response):a}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Rt.classes.FormData,Blob:Rt.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=>{Qr.headers[e]={}});const Av=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"]),jv=e=>{const t={};let n,r,o;return e&&e.split(`
|
|
30
|
+
<%s key={someKey} {...props} />`,sc,xr,mN,xr),mt[xr+sc]=!0}}return N===r?dt(Et):et(Et),Et}}function ae(N,Q,ee){return J(N,Q,ee,!0)}function ie(N,Q,ee){return J(N,Q,ee,!1)}var Ce=ie,Ee=ae;Yr.Fragment=r,Yr.jsx=Ce,Yr.jsxs=Ee}()),Yr}process.env.NODE_ENV==="production"?wi.exports=jx():wi.exports=Px();var u=wi.exports;const _x=({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(p=>{const v=d===p.id,g=(r==null?void 0:r.get(p.id))??null;return u.jsxs("button",{type:"button",disabled:!n,onClick:()=>n==null?void 0:n(p.id),className:`relative flex items-start gap-2 text-left text-[11px] transition ${v?"text-primary":"text-muted-foreground"} ${n?"hover:text-foreground":"cursor-default opacity-70"}`,children:[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:p.label||"User input"}),u.jsxs("span",{className:"text-[9px] uppercase tracking-wide text-muted-foreground/70",children:[p.step!==null?`STEP ${p.step}`:"STEP —",p.next?` - ${p.next}`:""]}),g&&u.jsx("p",{className:"text-[10px] text-muted-foreground/80 mt-1 line-clamp-2",title:g,children:g})]})]},p.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 gc(e,t){return function(){return e.apply(t,arguments)}}const{toString:Rx}=Object.prototype,{getPrototypeOf:yi}=Object,{iterator:Lo,toStringTag:xc}=Symbol,$o=(e=>t=>{const n=Rx.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),cn=e=>(e=e.toLowerCase(),t=>$o(t)===e),Fo=e=>t=>typeof t===e,{isArray:vr}=Array,br=Fo("undefined");function Xr(e){return e!==null&&!br(e)&&e.constructor!==null&&!br(e.constructor)&&Wt(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const vc=cn("ArrayBuffer");function Mx(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&vc(e.buffer),t}const Ox=Fo("string"),Wt=Fo("function"),bc=Fo("number"),Jr=e=>e!==null&&typeof e=="object",Dx=e=>e===!0||e===!1,Bo=e=>{if($o(e)!=="object")return!1;const t=yi(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(xc in e)&&!(Lo in e)},Lx=e=>{if(!Jr(e)||Xr(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},$x=cn("Date"),Fx=cn("File"),Bx=cn("Blob"),zx=cn("FileList"),Hx=e=>Jr(e)&&Wt(e.pipe),Ux=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||Wt(e.append)&&((t=$o(e))==="formdata"||t==="object"&&Wt(e.toString)&&e.toString()==="[object FormData]"))},Wx=cn("URLSearchParams"),[Vx,Kx,qx,Gx]=["ReadableStream","Request","Response","Headers"].map(cn),Yx=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Zr(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,o;if(typeof e!="object"&&(e=[e]),vr(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{if(Xr(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 wc(e,t){if(Xr(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,yc=e=>!br(e)&&e!==Jn;function Si(){const{caseless:e,skipUndefined:t}=yc(this)&&this||{},n={},r=(o,s)=>{const i=e&&wc(n,s)||s;Bo(n[i])&&Bo(o)?n[i]=Si(n[i],o):Bo(o)?n[i]=Si({},o):vr(o)?n[i]=o.slice():(!t||!br(o))&&(n[i]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&Zr(arguments[o],r);return n}const Xx=(e,t,n,{allOwnKeys:r}={})=>(Zr(t,(o,s)=>{n&&Wt(o)?e[s]=gc(o,n):e[s]=o},{allOwnKeys:r}),e),Jx=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Zx=(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)},Qx=(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&&yi(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},ev=(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},tv=e=>{if(!e)return null;if(vr(e))return e;let t=e.length;if(!bc(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},nv=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&yi(Uint8Array)),rv=(e,t)=>{const r=(e&&e[Lo]).call(e);let o;for(;(o=r.next())&&!o.done;){const s=o.value;t.call(e,s[0],s[1])}},ov=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},sv=cn("HTMLFormElement"),iv=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),Sc=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),av=cn("RegExp"),Cc=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};Zr(n,(o,s)=>{let i;(i=t(o,s,e))!==!1&&(r[s]=i||o)}),Object.defineProperties(e,r)},lv=e=>{Cc(e,(t,n)=>{if(Wt(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(Wt(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+"'")})}})},cv=(e,t)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return vr(e)?r(e):r(String(e).split(t)),n},uv=()=>{},dv=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function fv(e){return!!(e&&Wt(e.append)&&e[xc]==="FormData"&&e[Lo])}const pv=e=>{const t=new Array(10),n=(r,o)=>{if(Jr(r)){if(t.indexOf(r)>=0)return;if(Xr(r))return r;if(!("toJSON"in r)){t[o]=r;const s=vr(r)?[]:{};return Zr(r,(i,a)=>{const l=n(i,o+1);!br(l)&&(s[a]=l)}),t[o]=void 0,s}}return r};return n(e,0)},hv=cn("AsyncFunction"),mv=e=>e&&(Jr(e)||Wt(e))&&Wt(e.then)&&Wt(e.catch),Tc=((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",Wt(Jn.postMessage)),gv=typeof queueMicrotask<"u"?queueMicrotask.bind(Jn):typeof process<"u"&&process.nextTick||Tc,V={isArray:vr,isArrayBuffer:vc,isBuffer:Xr,isFormData:Ux,isArrayBufferView:Mx,isString:Ox,isNumber:bc,isBoolean:Dx,isObject:Jr,isPlainObject:Bo,isEmptyObject:Lx,isReadableStream:Vx,isRequest:Kx,isResponse:qx,isHeaders:Gx,isUndefined:br,isDate:$x,isFile:Fx,isBlob:Bx,isRegExp:av,isFunction:Wt,isStream:Hx,isURLSearchParams:Wx,isTypedArray:nv,isFileList:zx,forEach:Zr,merge:Si,extend:Xx,trim:Yx,stripBOM:Jx,inherits:Zx,toFlatObject:Qx,kindOf:$o,kindOfTest:cn,endsWith:ev,toArray:tv,forEachEntry:rv,matchAll:ov,isHTMLForm:sv,hasOwnProperty:Sc,hasOwnProp:Sc,reduceDescriptors:Cc,freezeMethods:lv,toObjectSet:cv,toCamelCase:iv,noop:uv,toFiniteNumber:dv,findKey:wc,global:Jn,isContextDefined:yc,isSpecCompliantForm:fv,toJSONObject:pv,isAsyncFn:hv,isThenable:mv,setImmediate:Tc,asap:gv,isIterable:e=>e!=null&&Wt(e[Lo])};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 kc=Pe.prototype,Ec={};["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=>{Ec[e]={value:e}}),Object.defineProperties(Pe,Ec),Object.defineProperty(kc,"isAxiosError",{value:!0}),Pe.from=(e,t,n,r,o,s)=>{const i=Object.create(kc);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 xv=null;function Ci(e){return V.isPlainObject(e)||V.isArray(e)}function Ic(e){return V.endsWith(e,"[]")?e.slice(0,-2):e}function Nc(e,t,n){return e?e.concat(t).map(function(o,s){return o=Ic(o),!n&&s?"["+o+"]":o}).join(n?".":""):t}function vv(e){return V.isArray(e)&&!e.some(Ci)}const bv=V.toFlatObject(V,{},null,function(t){return/^is[A-Z]/.test(t)});function zo(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)&&vv(v)||(V.isFileList(v)||V.endsWith(g,"[]"))&&(y=V.toArray(v)))return g=Ic(g),y.forEach(function(C,E){!(V.isUndefined(C)||C===null)&&t.append(i===!0?Nc([g],E,s):i===null?g:g+"[]",c(C))}),!1}return Ci(v)?!0:(t.append(Nc(x,g,s),c(v)),!1)}const f=[],m=Object.assign(bv,{defaultVisitor:d,convertValue:c,isVisitable:Ci});function p(v,g){if(!V.isUndefined(v)){if(f.indexOf(v)!==-1)throw Error("Circular reference detected in "+g.join("."));f.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&&p(y,g?g.concat(w):[w])}),f.pop()}}if(!V.isObject(e))throw new TypeError("data must be an object");return p(e),t}function Ac(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function Ti(e,t){this._pairs=[],e&&zo(e,this,t)}const jc=Ti.prototype;jc.append=function(t,n){this._pairs.push([t,n])},jc.toString=function(t){const n=t?function(r){return t.call(this,r,Ac)}:Ac;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function wv(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Pc(e,t,n){if(!t)return e;const r=n&&n.encode||wv;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 Ti(t,n).toString(r),s){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}class _c{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 Rc={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},yv={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:Ti,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},ki=typeof window<"u"&&typeof document<"u",Ei=typeof navigator=="object"&&navigator||void 0,Sv=ki&&(!Ei||["ReactNative","NativeScript","NS"].indexOf(Ei.product)<0),Cv=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Tv=ki&&window.location.href||"http://localhost",_t={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:ki,hasStandardBrowserEnv:Sv,hasStandardBrowserWebWorkerEnv:Cv,navigator:Ei,origin:Tv},Symbol.toStringTag,{value:"Module"})),...yv};function kv(e,t){return zo(e,new _t.classes.URLSearchParams,{visitor:function(n,r,o,s){return _t.isNode&&V.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function Ev(e){return V.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function Iv(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 Mc(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]=Iv(o[i])),!a)}if(V.isFormData(e)&&V.isFunction(e.entries)){const n={};return V.forEachEntry(e,(r,o)=>{t(Ev(r),o,n,0)}),n}return null}function Nv(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 Qr={transitional:Rc,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(Mc(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 kv(t,this.formSerializer).toString();if((a=V.isFileList(t))||r.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return zo(a?{"files[]":t}:t,l&&new l,this.formSerializer)}}return s||o?(n.setContentType("application/json",!1),Nv(t)):t}],transformResponse:[function(t){const n=this.transitional||Qr.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:_t.classes.FormData,Blob:_t.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=>{Qr.headers[e]={}});const Av=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"]),jv=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]&&Av[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},Oc=Symbol("internals");function eo(e){return e&&String(e).trim().toLowerCase()}function Ho(e){return e===!1||e==null?e:V.isArray(e)?e.map(Ho):String(e)}function Pv(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 _v=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function Ii(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 Rv(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function Mv(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 Vt=class{constructor(t){t&&this.set(t)}set(t,n,r){const o=this;function s(a,l,c){const d=eo(l);if(!d)throw new Error("header name must be a non-empty string");const f=V.findKey(o,d);(!f||o[f]===void 0||c===!0||c===void 0&&o[f]!==!1)&&(o[f||l]=Ho(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())&&!_v(t))i(jv(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=eo(t),t){const r=V.findKey(this,t);if(r){const o=this[r];if(!n)return o;if(n===!0)return Pv(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=eo(t),t){const r=V.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||Ii(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let o=!1;function s(i){if(i=eo(i),i){const a=V.findKey(r,i);a&&(!n||Ii(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||Ii(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]=Ho(o),delete n[s];return}const a=t?Rv(s):String(s).trim();a!==s&&delete n[s],n[a]=Ho(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[Oc]=this[Oc]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=eo(i);r[a]||(Mv(o,i),r[a]=!0)}return V.isArray(t)?t.forEach(s):s(t),this}};Vt.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),V.reduceDescriptors(Vt.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),V.freezeMethods(Vt);function Ni(e,t){const n=this||Qr,r=t||n,o=Vt.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 Dc(e){return!!(e&&e.__CANCEL__)}function wr(e,t,n){Ae.call(this,e??"canceled",Ae.ERR_CANCELED,t,n),this.name="CanceledError"}V.inherits(wr,Ae,{__CANCEL__:!0});function Lc(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new Ae("Request failed with status code "+n.status,[Ae.ERR_BAD_REQUEST,Ae.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function Ov(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Dv(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 f=s,m=0;for(;f!==o;)m+=n[f++],f=f%e;if(o=(o+1)%e,o===s&&(s=(s+1)%e),c-i<t)return;const p=d&&c-d;return p?Math.round(m*1e3/p):void 0}}function Lv(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(),f=d-n;f>=r?i(c,d):(o=c,s||(s=setTimeout(()=>{s=null,i(o)},r-f)))},()=>o&&i(o)]}const Uo=(e,t,n=3)=>{let r=0;const o=Dv(50,250);return Lv(s=>{const i=s.loaded,a=s.lengthComputable?s.total:void 0,l=i-r,c=o(l),d=i<=a;r=i;const f={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(f)},n)},$c=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},Fc=e=>(...t)=>V.asap(()=>e(...t)),$v=Rt.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,Rt.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(Rt.origin),Rt.navigator&&/(msie|trident)/i.test(Rt.navigator.userAgent)):()=>!0,Fv=Rt.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 Bv(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function zv(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function Bc(e,t,n){let r=!Bv(t);return e&&(r||n==!1)?zv(e,t):t}const zc=e=>e instanceof Vt?{...e}:e;function Zn(e,t){t=t||{};const n={};function r(c,d,f,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,f,m){if(V.isUndefined(d)){if(!V.isUndefined(c))return r(void 0,c,f,m)}else return r(c,d,f,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,f){if(f in t)return r(c,d);if(f 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,f)=>o(zc(c),zc(d),f,!0)};return V.forEach(Object.keys({...e,...t}),function(d){const f=l[d]||o,m=f(e[d],t[d],d);V.isUndefined(m)&&f!==a||(n[d]=m)}),n}const Hc=e=>{const t=Zn({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=Vt.from(i),t.url=Pc(Bc(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(Rt.hasStandardBrowserEnv||Rt.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,f])=>{c.includes(d.toLowerCase())&&i.set(d,f)})}}if(Rt.hasStandardBrowserEnv&&(r&&V.isFunction(r)&&(r=r(t)),r||r!==!1&&$v(t.url))){const l=o&&s&&Fv.read(s);l&&i.set(o,l)}return t},Hv=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=Hc(e);let s=o.data;const i=Vt.from(o.headers).normalize();let{responseType:a,onUploadProgress:l,onDownloadProgress:c}=o,d,f,m,p,v;function g(){p&&p(),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 C=Vt.from("getAllResponseHeaders"in x&&x.getAllResponseHeaders()),T={data:!a||a==="text"||a==="json"?x.responseText:x.response,status:x.status,statusText:x.statusText,headers:C,config:e,request:x};Lc(function(k){n(k),g()},function(k){r(k),g()},T),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 Ae("Request aborted",Ae.ECONNABORTED,e,x)),x=null)},x.onerror=function(E){const T=E&&E.message?E.message:"Network Error",S=new Ae(T,Ae.ERR_NETWORK,e,x);S.event=E||null,r(S),x=null},x.ontimeout=function(){let E=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const T=o.transitional||Rc;o.timeoutErrorMessage&&(E=o.timeoutErrorMessage),r(new Ae(E,T.clarifyTimeoutError?Ae.ETIMEDOUT:Ae.ECONNABORTED,e,x)),x=null},s===void 0&&i.setContentType(null),"setRequestHeader"in x&&V.forEach(i.toJSON(),function(E,T){x.setRequestHeader(T,E)}),V.isUndefined(o.withCredentials)||(x.withCredentials=!!o.withCredentials),a&&a!=="json"&&(x.responseType=o.responseType),c&&([m,v]=Uo(c,!0),x.addEventListener("progress",m)),l&&x.upload&&([f,p]=Uo(l),x.upload.addEventListener("progress",f),x.upload.addEventListener("loadend",p)),(o.cancelToken||o.signal)&&(d=C=>{x&&(r(!C||C.type?new wr(null,e,x):C),x.abort(),x=null)},o.cancelToken&&o.cancelToken.subscribe(d),o.signal&&(o.signal.aborted?d():o.signal.addEventListener("abort",d)));const w=Ov(o.url);if(w&&Rt.protocols.indexOf(w)===-1){r(new Ae("Unsupported protocol "+w+":",Ae.ERR_BAD_REQUEST,e));return}x.send(s||null)})},Uv=(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 Ae?d:new wr(d instanceof Error?d.message:d))}};let i=t&&setTimeout(()=>{i=null,s(new Ae(`timeout ${t} of ms exceeded`,Ae.ETIMEDOUT))},t);const a=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(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}},Wv=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},Vv=async function*(e,t){for await(const n of Kv(e))yield*Wv(n,t)},Kv=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()}},Uc=(e,t,n,r)=>{const o=Vv(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 f=d.byteLength;if(n){let m=s+=f;n(m)}l.enqueue(new Uint8Array(d))}catch(c){throw a(c),c}},cancel(l){return a(l),o.return()}},{highWaterMark:2})},Wc=64*1024,{isFunction:Wo}=V,qv=(({Request:e,Response:t})=>({Request:e,Response:t}))(V.global),{ReadableStream:Vc,TextEncoder:Kc}=V.global,qc=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Gv=e=>{e=V.merge.call({skipUndefined:!0},qv,e);const{fetch:t,Request:n,Response:r}=e,o=t?Wo(t):typeof fetch=="function",s=Wo(n),i=Wo(r);if(!o)return!1;const a=o&&Wo(Vc),l=o&&(typeof Kc=="function"?(v=>g=>v.encode(g))(new Kc):async v=>new Uint8Array(await new n(v).arrayBuffer())),c=s&&a&&qc(()=>{let v=!1;const g=new n(Rt.origin,{body:new Vc,method:"POST",get duplex(){return v=!0,"half"}}).headers.has("Content-Type");return v&&!g}),d=i&&a&&qc(()=>V.isReadableStream(new r("").body)),f={stream:d&&(v=>v.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(v=>{!f[v]&&(f[v]=(g,x)=>{let y=g&&g[v];if(y)return y.call(g);throw new Ae(`Response type '${v}' is not supported`,Ae.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(Rt.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},p=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:C,timeout:E,onDownloadProgress:T,onUploadProgress:S,responseType:k,headers:A,withCredentials:j="same-origin",fetchOptions:F}=Hc(v),D=t||fetch;k=k?(k+"").toLowerCase():"text";let B=Uv([w,C&&C.toAbortSignal()],E),Y=null;const M=B&&B.unsubscribe&&(()=>{B.unsubscribe()});let W;try{if(S&&c&&x!=="get"&&x!=="head"&&(W=await p(A,y))!==0){let Q=new n(g,{method:"POST",body:y,duplex:"half"}),O;if(V.isFormData(y)&&(O=Q.headers.get("content-type"))&&A.setContentType(O),Q.body){const[G,L]=$c(W,Uo(Fc(S)));y=Uc(Q.body,Wc,G,L)}}V.isString(j)||(j=j?"include":"omit");const X=s&&"credentials"in n.prototype,z={...F,signal:B,method:x.toUpperCase(),headers:A.normalize().toJSON(),body:y,duplex:"half",credentials:X?j:void 0};Y=s&&new n(g,z);let P=await(s?D(Y,F):D(g,z));const I=d&&(k==="stream"||k==="response");if(d&&(T||I&&M)){const Q={};["status","statusText","headers"].forEach($=>{Q[$]=P[$]});const O=V.toFiniteNumber(P.headers.get("content-length")),[G,L]=T&&$c(O,Uo(Fc(T),!0))||[];P=new r(Uc(P.body,Wc,G,()=>{L&&L(),M&&M()}),Q)}k=k||"text";let q=await f[V.findKey(f,k)||"text"](P,v);return!I&&M&&M(),await new Promise((Q,O)=>{Lc(Q,O,{data:q,headers:Vt.from(P.headers),status:P.status,statusText:P.statusText,config:v,request:Y})})}catch(X){throw M&&M(),X&&X.name==="TypeError"&&/Load failed|fetch/i.test(X.message)?Object.assign(new Ae("Network Error",Ae.ERR_NETWORK,v,Y),{cause:X.cause||X}):Ae.from(X,X&&X.code,v,Y)}}},Yv=new Map,Gc=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=Yv;for(;a--;)l=s[a],c=d.get(l),c===void 0&&d.set(l,c=a?new Map:Gv(t)),d=c;return c};Gc();const Ai={http:xv,xhr:Hv,fetch:{get:Gc}};V.forEach(Ai,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Yc=e=>`- ${e}`,Xv=e=>V.isFunction(e)||e===null||e===!1,Xc={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,!Xv(r)&&(o=Ai[(a=String(r)).toLowerCase()],o===void 0))throw new Ae(`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[Oc]=this[Oc]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=eo(i);r[a]||(Mv(o,i),r[a]=!0)}return V.isArray(t)?t.forEach(s):s(t),this}};Vt.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),V.reduceDescriptors(Vt.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),V.freezeMethods(Vt);function Ni(e,t){const n=this||Qr,r=t||n,o=Vt.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 Dc(e){return!!(e&&e.__CANCEL__)}function wr(e,t,n){Pe.call(this,e??"canceled",Pe.ERR_CANCELED,t,n),this.name="CanceledError"}V.inherits(wr,Pe,{__CANCEL__:!0});function Lc(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 Ov(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Dv(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 f=s,m=0;for(;f!==o;)m+=n[f++],f=f%e;if(o=(o+1)%e,o===s&&(s=(s+1)%e),c-i<t)return;const p=d&&c-d;return p?Math.round(m*1e3/p):void 0}}function Lv(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(),f=d-n;f>=r?i(c,d):(o=c,s||(s=setTimeout(()=>{s=null,i(o)},r-f)))},()=>o&&i(o)]}const Uo=(e,t,n=3)=>{let r=0;const o=Dv(50,250);return Lv(s=>{const i=s.loaded,a=s.lengthComputable?s.total:void 0,l=i-r,c=o(l),d=i<=a;r=i;const f={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(f)},n)},$c=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},Fc=e=>(...t)=>V.asap(()=>e(...t)),$v=_t.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,_t.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(_t.origin),_t.navigator&&/(msie|trident)/i.test(_t.navigator.userAgent)):()=>!0,Fv=_t.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 Bv(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function zv(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function Bc(e,t,n){let r=!Bv(t);return e&&(r||n==!1)?zv(e,t):t}const zc=e=>e instanceof Vt?{...e}:e;function Zn(e,t){t=t||{};const n={};function r(c,d,f,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,f,m){if(V.isUndefined(d)){if(!V.isUndefined(c))return r(void 0,c,f,m)}else return r(c,d,f,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,f){if(f in t)return r(c,d);if(f 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,f)=>o(zc(c),zc(d),f,!0)};return V.forEach(Object.keys({...e,...t}),function(d){const f=l[d]||o,m=f(e[d],t[d],d);V.isUndefined(m)&&f!==a||(n[d]=m)}),n}const Hc=e=>{const t=Zn({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=Vt.from(i),t.url=Pc(Bc(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(_t.hasStandardBrowserEnv||_t.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,f])=>{c.includes(d.toLowerCase())&&i.set(d,f)})}}if(_t.hasStandardBrowserEnv&&(r&&V.isFunction(r)&&(r=r(t)),r||r!==!1&&$v(t.url))){const l=o&&s&&Fv.read(s);l&&i.set(o,l)}return t},Hv=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=Hc(e);let s=o.data;const i=Vt.from(o.headers).normalize();let{responseType:a,onUploadProgress:l,onDownloadProgress:c}=o,d,f,m,p,v;function g(){p&&p(),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 C=Vt.from("getAllResponseHeaders"in x&&x.getAllResponseHeaders()),T={data:!a||a==="text"||a==="json"?x.responseText:x.response,status:x.status,statusText:x.statusText,headers:C,config:e,request:x};Lc(function(k){n(k),g()},function(k){r(k),g()},T),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(E){const T=E&&E.message?E.message:"Network Error",S=new Pe(T,Pe.ERR_NETWORK,e,x);S.event=E||null,r(S),x=null},x.ontimeout=function(){let E=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const T=o.transitional||Rc;o.timeoutErrorMessage&&(E=o.timeoutErrorMessage),r(new Pe(E,T.clarifyTimeoutError?Pe.ETIMEDOUT:Pe.ECONNABORTED,e,x)),x=null},s===void 0&&i.setContentType(null),"setRequestHeader"in x&&V.forEach(i.toJSON(),function(E,T){x.setRequestHeader(T,E)}),V.isUndefined(o.withCredentials)||(x.withCredentials=!!o.withCredentials),a&&a!=="json"&&(x.responseType=o.responseType),c&&([m,v]=Uo(c,!0),x.addEventListener("progress",m)),l&&x.upload&&([f,p]=Uo(l),x.upload.addEventListener("progress",f),x.upload.addEventListener("loadend",p)),(o.cancelToken||o.signal)&&(d=C=>{x&&(r(!C||C.type?new wr(null,e,x):C),x.abort(),x=null)},o.cancelToken&&o.cancelToken.subscribe(d),o.signal&&(o.signal.aborted?d():o.signal.addEventListener("abort",d)));const w=Ov(o.url);if(w&&_t.protocols.indexOf(w)===-1){r(new Pe("Unsupported protocol "+w+":",Pe.ERR_BAD_REQUEST,e));return}x.send(s||null)})},Uv=(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 wr(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}},Wv=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},Vv=async function*(e,t){for await(const n of Kv(e))yield*Wv(n,t)},Kv=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()}},Uc=(e,t,n,r)=>{const o=Vv(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 f=d.byteLength;if(n){let m=s+=f;n(m)}l.enqueue(new Uint8Array(d))}catch(c){throw a(c),c}},cancel(l){return a(l),o.return()}},{highWaterMark:2})},Wc=64*1024,{isFunction:Wo}=V,qv=(({Request:e,Response:t})=>({Request:e,Response:t}))(V.global),{ReadableStream:Vc,TextEncoder:Kc}=V.global,qc=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Gv=e=>{e=V.merge.call({skipUndefined:!0},qv,e);const{fetch:t,Request:n,Response:r}=e,o=t?Wo(t):typeof fetch=="function",s=Wo(n),i=Wo(r);if(!o)return!1;const a=o&&Wo(Vc),l=o&&(typeof Kc=="function"?(v=>g=>v.encode(g))(new Kc):async v=>new Uint8Array(await new n(v).arrayBuffer())),c=s&&a&&qc(()=>{let v=!1;const g=new n(_t.origin,{body:new Vc,method:"POST",get duplex(){return v=!0,"half"}}).headers.has("Content-Type");return v&&!g}),d=i&&a&&qc(()=>V.isReadableStream(new r("").body)),f={stream:d&&(v=>v.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(v=>{!f[v]&&(f[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(_t.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},p=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:C,timeout:E,onDownloadProgress:T,onUploadProgress:S,responseType:k,headers:A,withCredentials:j="same-origin",fetchOptions:F}=Hc(v),D=t||fetch;k=k?(k+"").toLowerCase():"text";let B=Uv([w,C&&C.toAbortSignal()],E),G=null;const M=B&&B.unsubscribe&&(()=>{B.unsubscribe()});let W;try{if(S&&c&&x!=="get"&&x!=="head"&&(W=await p(A,y))!==0){let te=new n(g,{method:"POST",body:y,duplex:"half"}),O;if(V.isFormData(y)&&(O=te.headers.get("content-type"))&&A.setContentType(O),te.body){const[q,L]=$c(W,Uo(Fc(S)));y=Uc(te.body,Wc,q,L)}}V.isString(j)||(j=j?"include":"omit");const Y=s&&"credentials"in n.prototype,z={...F,signal:B,method:x.toUpperCase(),headers:A.normalize().toJSON(),body:y,duplex:"half",credentials:Y?j:void 0};G=s&&new n(g,z);let P=await(s?D(G,F):D(g,z));const I=d&&(k==="stream"||k==="response");if(d&&(T||I&&M)){const te={};["status","statusText","headers"].forEach($=>{te[$]=P[$]});const O=V.toFiniteNumber(P.headers.get("content-length")),[q,L]=T&&$c(O,Uo(Fc(T),!0))||[];P=new r(Uc(P.body,Wc,q,()=>{L&&L(),M&&M()}),te)}k=k||"text";let K=await f[V.findKey(f,k)||"text"](P,v);return!I&&M&&M(),await new Promise((te,O)=>{Lc(te,O,{data:K,headers:Vt.from(P.headers),status:P.status,statusText:P.statusText,config:v,request:G})})}catch(Y){throw M&&M(),Y&&Y.name==="TypeError"&&/Load failed|fetch/i.test(Y.message)?Object.assign(new Pe("Network Error",Pe.ERR_NETWORK,v,G),{cause:Y.cause||Y}):Pe.from(Y,Y&&Y.code,v,G)}}},Yv=new Map,Gc=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=Yv;for(;a--;)l=s[a],c=d.get(l),c===void 0&&d.set(l,c=a?new Map:Gv(t)),d=c;return c};Gc();const Ai={http:xv,xhr:Hv,fetch:{get:Gc}};V.forEach(Ai,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Yc=e=>`- ${e}`,Xv=e=>V.isFunction(e)||e===null||e===!1,Xc={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,!Xv(r)&&(o=Ai[(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(Yc).join(`
|
|
34
|
-
`):" "+Yc(i[0]):"as no adapter specified";throw new
|
|
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&&Ko.assertOptions(r,{silentJSONParsing:xn.transitional(xn.boolean),forcedJSONParsing:xn.transitional(xn.boolean),clarifyTimeoutError:xn.transitional(xn.boolean)},!1),o!=null&&(V.isFunction(o)?n.paramsSerializer={serialize:o}:Ko.assertOptions(o,{encode:xn.function,serialize:xn.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Ko.assertOptions(n,{baseUrl:xn.spelling("baseURL"),withXsrfToken:xn.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=Vt.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,f=0,m;if(!l){const v=[Jc.bind(this),void 0];for(v.unshift(...a),v.push(...c),m=v.length,d=Promise.resolve(n);f<m;)d=d.then(v[f++],v[f++]);return d}m=a.length;let p=n;for(;f<m;){const v=a[f++],g=a[f++];try{p=v(p)}catch(x){g.call(this,x);break}}try{d=Jc.call(this,p)}catch(v){return Promise.reject(v)}for(f=0,m=c.length;f<m;)d=d.then(c[f++],c[f++]);return d}getUri(t){t=Zn(this.defaults,t);const n=Bc(t.baseURL,t.url,t.allowAbsoluteUrls);return Pc(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 Zv=class xx{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 wr(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 xx(function(o){t=o}),cancel:t}}};function Qv(e){return function(n){return e.apply(null,n)}}function eb(e){return V.isObject(e)&&e.isAxiosError===!0}const Pi={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(Pi).forEach(([e,t])=>{Pi[t]=e});function eu(e){const t=new Qn(e),n=gc(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 eu(Zn(e,o))},n}const xt=eu(Qr);xt.Axios=Qn,xt.CanceledError=wr,xt.CancelToken=Zv,xt.isCancel=Dc,xt.VERSION=Zc,xt.toFormData=zo,xt.AxiosError=Ae,xt.Cancel=xt.CanceledError,xt.all=function(t){return Promise.all(t)},xt.spread=Qv,xt.isAxiosError=eb,xt.mergeConfig=Zn,xt.AxiosHeaders=Vt,xt.formToJSON=e=>Mc(V.isHTMLForm(e)?new FormData(e):e),xt.getAdapter=Xc.getAdapter,xt.HttpStatusCode=Pi,xt.default=xt;const{Axios:kN,AxiosError:EN,CanceledError:IN,isCancel:tu,CancelToken:NN,VERSION:AN,all:jN,Cancel:PN,isAxiosError:_N,spread:RN,toFormData:MN,AxiosHeaders:ON,HttpStatusCode:DN,formToJSON:LN,getAdapter:$N,mergeConfig:FN}=xt;let qo=null;const _i=new Set;function Ri(){return qo}function Rn(e){qo=e,_i.forEach(t=>t(e))}function Mi(e){return _i.add(e),()=>_i.delete(e)}const nu=3e4,ru=9e4,Lt=xt.create({timeout:nu,withCredentials:!0});Lt.interceptors.request.use(e=>(qo&&(e.headers.Authorization=`Bearer ${qo}`),e)),Lt.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),Rn(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 Kt(e,t){return Lt.defaults.baseURL?(await Lt.get(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}async function to(e,t,n){return Lt.defaults.baseURL?(await Lt.post(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function ou(e,t,n){return Lt.defaults.baseURL?(await Lt.put(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function Oi(e,t){return Lt.defaults.baseURL?(await Lt.delete(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}function $t(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class su{get baseUrl(){return Lt.defaults.baseURL||""}updateConfig(t){if(t.chatBaseUrl)Lt.defaults.baseURL=t.chatBaseUrl;else if(t.baseUrl){const n=t.baseUrl.replace(/\/+$/,"");n.endsWith("/chat")?Lt.defaults.baseURL=n:Lt.defaults.baseURL=`${n}/chat`}t.apiKey!==void 0?Rn(t.apiKey):t.getToken&&Rn(t.getToken())}getAuthToken(){return Ri()}setAuthToken(t){Rn(t)}onTokenChange(t){return Mi(t)}async listThreads(){const t=await Kt("/threads"),n=$t(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async listSharedThreads(){const t=await Kt("/threads/shared"),n=$t(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async createThread(t,n){const r={};t&&(r.title=t),n&&(r.project=n);const o=await to("/threads",Object.keys(r).length?r:void 0);return $t(o)}async updateThread(t,n){const r=await ou(`/threads/${t}`,{title:n});return $t(r)}async deleteThread(t){const n=await Oi(`/threads/${t}`);return $t(n)}async shareThread(t,n){const r=await to(`/threads/${t}/share`,{shared_with_user_id:n});return $t(r)}async threadInfo(t){const n=await Kt(`/threads/${t}/info`);return $t(n)}async listAgents(){const t=await Kt("/agents"),n=$t(t);return(n==null?void 0:n.items)??[]}async getAgent(t){const n=await Kt(`/agents/${t}`);return $t(n)}async getAgentSchema(t){const n=await Kt(`/agents/${t}/schema`);return $t(n)}async getState(t){const n=await Kt(`/threads/${t.threadId}/state`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return $t(n)}async getStateHistory(t){const n=await Kt(`/threads/${t.threadId}/state/history`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs},timeout:ru,signal:t.signal});return $t(n)}async cancelRun(t){const n=await to("/runs/cancel",{threadId:t});return $t(n)}async unshareThread(t,n){const r=await Oi(`/threads/${t}/share/${n}`);return $t(r)}}const Mn=new su;class iu{async fetchFileBlob(t,n){return await Kt(t,{responseType:"blob",onDownloadProgress:o=>{try{if(n&&o.lengthComputable){const s=o.loaded/o.total;n(s)}}catch{}},maxBodyLength:1/0})}async viewFileById(t,n){const r=await this.fetchFileBlob(`/files/${t}/view`,n),o=URL.createObjectURL(r);window.open(o,"_blank"),setTimeout(()=>URL.revokeObjectURL(o),6e4)}async getFileContent(t,n){return await(await this.fetchFileBlob(`/files/${t}/view`,n)).text()}async downloadFileById(t,n){const r=await this.fetchFileBlob(`/files/${t}/download`,n),o=URL.createObjectURL(r);let s=`file_${t}`;try{const a=await Kt(`/files/${t}`);s=(a==null?void 0:a.filename)??s}catch{}const i=document.createElement("a");i.href=o,i.download=s,document.body.appendChild(i),i.click(),i.remove(),setTimeout(()=>URL.revokeObjectURL(o),6e4)}async getFileInfo(t){return await Kt(`/files/${t}`)}async listFiles(t,n=50,r=0){const o={limit:n,offset:r};return t&&(o.thread_id=t),await Kt("/files",{params:o})}async uploadFile(t,n,r){const o=new FormData;return o.append("file",t),n&&o.append("thread_id",n),await to("/files/upload-form",o,{onUploadProgress:s=>{try{if(r&&s.lengthComputable){const i=s.loaded/s.total;r(i)}}catch{}}})}}const au=new iu;class tb{constructor(){ic(this,"_authBaseUrl","")}get baseUrl(){return this._authBaseUrl}updateConfig(t){if(t.authBaseUrl)this._authBaseUrl=t.authBaseUrl;else if(t.baseUrl){const n=t.baseUrl.replace(/\/+$/,"");this._authBaseUrl=`${n}/auth`}t.apiKey!==void 0?Rn(t.apiKey):t.getToken&&Rn(t.getToken())}getAuthToken(){return Ri()}setAuthToken(t){Rn(t)}onTokenChange(t){return Mi(t)}async listUsers(){const t=await Kt("/users",{baseURL:this.baseUrl});return(t==null?void 0:t.users)??[]}}const nb=new tb,lu=b.createContext(null);function cu({children:e,apiConfig:t}){const n=Mn,r=nb;if(t){const s=n.baseUrl,i=r.baseUrl,a=n.getAuthToken();(t.baseUrl||t.chatBaseUrl)&&(t.chatBaseUrl&&t.chatBaseUrl!==s||t.baseUrl&&!s.startsWith(t.baseUrl))&&n.updateConfig(t),(t.baseUrl||t.authBaseUrl)&&(t.authBaseUrl&&t.authBaseUrl!==i||t.baseUrl&&!i.startsWith(t.baseUrl))&&r.updateConfig(t),t.apiKey!==void 0&&t.apiKey!==a&&(n.updateConfig({apiKey:t.apiKey}),r.updateConfig({apiKey:t.apiKey}))}const o={token:n.getAuthToken(),setToken:s=>{n.setAuthToken(s),r.setAuthToken(s)},chatApi:n,authApi:r,fileApi:au,baseUrl:n.baseUrl};return u.jsx(lu.Provider,{value:o,children:e})}async function uu(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 du(e=[]){const t=[],n=[];for(const r of e)try{const o=await uu(r),s=r.type||"application/octet-stream";n.push({filename:r.name,data:o,mime_type:s}),s.startsWith("image/")?t.push({type:"image_url",url:`data:${s};base64,${o}`,mimeType:s,alt:r.name}):t.push({type:"file",url:`data:${s};base64,${o}`,mimeType:s,name:r.name,size:r.size,sourceType:"base64"})}catch{}return{contentParts:t,filesInfo:n}}function On(){const e=b.useContext(lu);if(!e)throw new Error("useApi must be used within ApiProvider");return e}function fu(e){return!!e&&typeof e=="object"&&"data"in e}function Di(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 no(e,t,n){return t<0||t>=e.length?e:[...e.slice(0,t),n,...e.slice(t+1)]}function rb(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 pu(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="assistant")return e[t].id;return null}function hu(e){return!e||!e.length?"":e.filter(t=>t.type==="text").map(t=>t.text??"").join("")}function mu(e,t,n,r){const o={...n};if(r!==null&&typeof r=="number"){if(typeof o.lastSeq=="number"&&r<=o.lastSeq)return{newParts:e,newMeta:o,changed:!1};o.lastSeq=r}const s=t.filter(f=>f.type==="text").map(f=>f.text??"").join(""),i=t.filter(f=>f.type!=="text"),a=o.lastText??hu(e);let l="",c=e.slice();if(s){const f=ob(a,s);if(f===""?l="":f===s?l=s:l=f,sb(a,l)&&(l=` ${l}`),l){const m=c[c.length-1];if((m==null?void 0:m.type)==="text"){const p=m.text??"",v={...m,text:p+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 ob(e,t){if(!t)return"";if(!e)return t;if(e===t)return"";const n=Math.min(e.length,t.length);for(let r=n;r>0;r--)if(e.slice(-r)===t.slice(0,r))return t.slice(r);return t}function sb(e,t){if(!e||!t)return!1;const n=e.slice(-1),r=t[0];if(!n||!r||/\s/.test(n)||/\s/.test(r))return!1;const o=a=>/[A-Za-z0-9]/.test(a),s=a=>/[A-Za-z]/.test(a);return(a=>/[.,;:!?]/.test(a))(n)&&o(r)||/[A-Z]/.test(r)&&!/[\s\(\[\{]/.test(n)?!0:o(n)&&s(r)}function ib(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 no(e,r,s)}return e}function gu(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}function ab(e={}){const t=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),[f,m]=b.useState(""),[p,v]=b.useState(null),[g,x]=b.useState(0),[y,w]=b.useState(!1),[C,E]=b.useState(null),T=b.useRef(null),S=b.useRef(!0),k=b.useRef(0),A=b.useRef(null),j=b.useRef(null),F=b.useRef(null),D=b.useRef(null),B=b.useRef({messageId:null,lastSeq:null,lastText:""}),Y=b.useCallback(z=>{o(z)},[]),M=b.useCallback(()=>{m(""),v(null),d(null),j.current=null,F.current=null,D.current=null,E(null),B.current={messageId:null,lastSeq:null,lastText:""}},[]),W=b.useCallback(()=>{var q;console.debug("[use-chat] stop() invoked - aborting stream");const z=(q=A.current)==null?void 0:q.threadId,P=()=>{var Q;(Q=T.current)==null||Q.abort(),T.current=null,A.current=null,l(!1),w(!1),k.current=0,x(0)};(z?Mn.cancelRun(z).catch(Q=>{console.warn("[use-chat] cancel run failed:",Q)}):Promise.resolve()).finally(P)},[]),X=b.useCallback((z,P,I)=>{T.current&&(T.current.abort(),T.current=null),l(!0),d(null),e.autoAppendAssistant!==!1&&m(""),v(null),j.current=null,F.current=null,D.current=null,E(null),B.current={messageId:null,lastSeq:null,lastText:""};const q=new AbortController;T.current=q;let Q=null,O=null,G=!1;return A.current={threadId:z.threadId??null,headers:{}},(async()=>{var $,J,R,_,U,Z,re,le,ke,ye,_e,ze,$e,Ge,He,nt,ft,ct;const L=Ue=>{var Re;try{const Ve=JSON.parse(JSON.stringify(Ue));return(Re=Ve==null?void 0:Ve.payload)!=null&&Re.files_info&&Array.isArray(Ve.payload.files_info)&&(Ve.payload.files_info=Ve.payload.files_info.map(Ne=>({...Ne,data:Ne!=null&&Ne.data?`<base64 ${String(Ne.data).length} chars>`:Ne==null?void 0:Ne.data}))),Ve}catch{return Ue}};try{let Ue={};try{if(r)Ue={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const Le=window.__AUTH_TOKEN__,dt=(($=window.localStorage)==null?void 0:$.getItem("authToken"))||null;let kt=null;try{const _t=(J=window.localStorage)==null?void 0:J.getItem("chat-settings");_t&&(kt=((R=JSON.parse(_t))==null?void 0:R.apiKey)||null)}catch{}const ut=Le||dt||kt||null;ut&&(Ue={Authorization:`Bearer ${ut}`})}}catch{}console.debug("[use-chat] POST",t+n,L(z));let Re={};if(typeof window<"u")try{const We=(_=window.localStorage)==null?void 0:_.getItem("authSessionId");We&&(Re={"X-Session-Id":We})}catch{}const Ve={...Ue,...Re,...s.current},Ne={"Content-Type":"application/json",Accept:"text/event-stream",...Ve},Ke=await fetch(t+n,{method:"POST",headers:Ne,body:JSON.stringify(z),signal:q.signal,credentials:i});if(A.current&&(A.current.headers=Ve),!Ke.ok||!Ke.body){const We=await Ke.text().catch(()=>"");console.debug("[use-chat] non-OK response",Ke.status,We==null?void 0:We.slice(0,500));const Le=`stream ${Ke.status}${We?": "+We:""}`;throw(U=I==null?void 0:I.onConnectionError)==null||U.call(I,Le),G=!0,Q="error",O=Le,new Error(Le)}w(!0);const Ye=Ke.body.getReader(),Ct=new TextDecoder;let Ze="",Tt=[];k.current=0,x(0);let pt=0,wt=null;const At=()=>{if(Tt.length){const We=Tt.join("");Tt=[],S.current&&m(Le=>Le+We)}wt=null},Pt=()=>{typeof window<"u"&&wt==null&&(wt=requestAnimationFrame(At))};let ht=Date.now();const mt=setInterval(()=>{var We;if(Date.now()-ht>18e5){const Le="Stream idle timeout";d(Le),Q="error",O=Le,q.abort(),(We=I==null?void 0:I.onError)==null||We.call(I,Le)}},5e3),Ht=1024*1024;try{const We=Ke.headers.get("X-Thread-Id")||Ke.headers.get("x-thread-id"),Le=Ke.headers.get("X-Thread-Created")||Ke.headers.get("x-thread-created"),dt=We??null,kt=String(Le??"").toLowerCase()==="true";for(A.current&&!A.current.threadId&&(A.current={...A.current,threadId:dt}),(Z=I==null?void 0:I.onOpen)==null||Z.call(I,{threadId:dt,created:kt});;){const{value:ut,done:_t}=await Ye.read();if(_t)break;Ze+=Ct.decode(ut,{stream:!0}),Ze.length>Ht&&(Ze="",console.warn("Stream buffer reset: exceeded 1MB"));let xe;for(;(xe=Ze.indexOf(`
|
|
34
|
+
`):" "+Yc(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:Ai};function ji(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new wr(null,e)}function Jc(e){return ji(e),e.headers=Vt.from(e.headers),e.data=Ni.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),Xc.getAdapter(e.adapter||Qr.adapter,e)(e).then(function(r){return ji(e),r.data=Ni.call(e,e.transformResponse,r),r.headers=Vt.from(r.headers),r},function(r){return Dc(r)||(ji(e),r&&r.response&&(r.response.data=Ni.call(e,e.transformResponse,r.response),r.response.headers=Vt.from(r.response.headers))),Promise.reject(r)})}const Zc="1.12.2",Vo={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Vo[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const Qc={};Vo.transitional=function(t,n,r){function o(s,i){return"[Axios v"+Zc+"] 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&&!Qc[i]&&(Qc[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}},Vo.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function Jv(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 Ko={assertOptions:Jv,validators:Vo},xn=Ko.validators;let Qn=class{constructor(t){this.defaults=t||{},this.interceptors={request:new _c,response:new _c}}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&&Ko.assertOptions(r,{silentJSONParsing:xn.transitional(xn.boolean),forcedJSONParsing:xn.transitional(xn.boolean),clarifyTimeoutError:xn.transitional(xn.boolean)},!1),o!=null&&(V.isFunction(o)?n.paramsSerializer={serialize:o}:Ko.assertOptions(o,{encode:xn.function,serialize:xn.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Ko.assertOptions(n,{baseUrl:xn.spelling("baseURL"),withXsrfToken:xn.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=Vt.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,f=0,m;if(!l){const v=[Jc.bind(this),void 0];for(v.unshift(...a),v.push(...c),m=v.length,d=Promise.resolve(n);f<m;)d=d.then(v[f++],v[f++]);return d}m=a.length;let p=n;for(;f<m;){const v=a[f++],g=a[f++];try{p=v(p)}catch(x){g.call(this,x);break}}try{d=Jc.call(this,p)}catch(v){return Promise.reject(v)}for(f=0,m=c.length;f<m;)d=d.then(c[f++],c[f++]);return d}getUri(t){t=Zn(this.defaults,t);const n=Bc(t.baseURL,t.url,t.allowAbsoluteUrls);return Pc(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 Zv=class xx{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 wr(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 xx(function(o){t=o}),cancel:t}}};function Qv(e){return function(n){return e.apply(null,n)}}function eb(e){return V.isObject(e)&&e.isAxiosError===!0}const Pi={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(Pi).forEach(([e,t])=>{Pi[t]=e});function eu(e){const t=new Qn(e),n=gc(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 eu(Zn(e,o))},n}const vt=eu(Qr);vt.Axios=Qn,vt.CanceledError=wr,vt.CancelToken=Zv,vt.isCancel=Dc,vt.VERSION=Zc,vt.toFormData=zo,vt.AxiosError=Pe,vt.Cancel=vt.CanceledError,vt.all=function(t){return Promise.all(t)},vt.spread=Qv,vt.isAxiosError=eb,vt.mergeConfig=Zn,vt.AxiosHeaders=Vt,vt.formToJSON=e=>Mc(V.isHTMLForm(e)?new FormData(e):e),vt.getAdapter=Xc.getAdapter,vt.HttpStatusCode=Pi,vt.default=vt;const{Axios:kN,AxiosError:EN,CanceledError:IN,isCancel:tu,CancelToken:NN,VERSION:AN,all:jN,Cancel:PN,isAxiosError:_N,spread:RN,toFormData:MN,AxiosHeaders:ON,HttpStatusCode:DN,formToJSON:LN,getAdapter:$N,mergeConfig:FN}=vt;let qo=null;const _i=new Set;function Ri(){return qo}function Rn(e){qo=e,_i.forEach(t=>t(e))}function Mi(e){return _i.add(e),()=>_i.delete(e)}const nu=3e4,ru=9e4,Dt=vt.create({timeout:nu,withCredentials:!0});Dt.interceptors.request.use(e=>(qo&&(e.headers.Authorization=`Bearer ${qo}`),e)),Dt.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),Rn(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 Kt(e,t){return Dt.defaults.baseURL?(await Dt.get(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}async function to(e,t,n){return Dt.defaults.baseURL?(await Dt.post(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function ou(e,t,n){return Dt.defaults.baseURL?(await Dt.put(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function Oi(e,t){return Dt.defaults.baseURL?(await Dt.delete(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}function Lt(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class su{get baseUrl(){return Dt.defaults.baseURL||""}updateConfig(t){if(t.chatBaseUrl)Dt.defaults.baseURL=t.chatBaseUrl;else if(t.baseUrl){const n=t.baseUrl.replace(/\/+$/,"");n.endsWith("/chat")?Dt.defaults.baseURL=n:Dt.defaults.baseURL=`${n}/chat`}t.apiKey!==void 0?Rn(t.apiKey):t.getToken&&Rn(t.getToken())}getAuthToken(){return Ri()}setAuthToken(t){Rn(t)}onTokenChange(t){return Mi(t)}async listThreads(){const t=await Kt("/threads"),n=Lt(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async listSharedThreads(){const t=await Kt("/threads/shared"),n=Lt(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async createThread(t,n){const r={};t&&(r.title=t),n&&(r.project=n);const o=await to("/threads",Object.keys(r).length?r:void 0);return Lt(o)}async updateThread(t,n){const r=await ou(`/threads/${t}`,{title:n});return Lt(r)}async deleteThread(t){const n=await Oi(`/threads/${t}`);return Lt(n)}async shareThread(t,n){const r=await to(`/threads/${t}/share`,{shared_with_user_id:n});return Lt(r)}async threadInfo(t){const n=await Kt(`/threads/${t}/info`);return Lt(n)}async listAgents(){const t=await Kt("/agents"),n=Lt(t);return(n==null?void 0:n.items)??[]}async getAgent(t){const n=await Kt(`/agents/${t}`);return Lt(n)}async getAgentSchema(t){const n=await Kt(`/agents/${t}/schema`);return Lt(n)}async getState(t){const n=await Kt(`/threads/${t.threadId}/state`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return Lt(n)}async getStateHistory(t){const n=await Kt(`/threads/${t.threadId}/state/history`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs},timeout:ru,signal:t.signal});return Lt(n)}async cancelRun(t){const n=await to("/runs/cancel",{threadId:t});return Lt(n)}async unshareThread(t,n){const r=await Oi(`/threads/${t}/share/${n}`);return Lt(r)}}const Mn=new su;class iu{async fetchFileBlob(t,n){return await Kt(t,{responseType:"blob",onDownloadProgress:o=>{try{if(n&&o.lengthComputable){const s=o.loaded/o.total;n(s)}}catch{}},maxBodyLength:1/0})}async viewFileById(t,n){const r=await this.fetchFileBlob(`/files/${t}/view`,n),o=URL.createObjectURL(r);window.open(o,"_blank"),setTimeout(()=>URL.revokeObjectURL(o),6e4)}async getFileContent(t,n){return await(await this.fetchFileBlob(`/files/${t}/view`,n)).text()}async downloadFileById(t,n){const r=await this.fetchFileBlob(`/files/${t}/download`,n),o=URL.createObjectURL(r);let s=`file_${t}`;try{const a=await Kt(`/files/${t}`);s=(a==null?void 0:a.filename)??s}catch{}const i=document.createElement("a");i.href=o,i.download=s,document.body.appendChild(i),i.click(),i.remove(),setTimeout(()=>URL.revokeObjectURL(o),6e4)}async getFileInfo(t){return await Kt(`/files/${t}`)}async listFiles(t,n=50,r=0){const o={limit:n,offset:r};return t&&(o.thread_id=t),await Kt("/files",{params:o})}async uploadFile(t,n,r){const o=new FormData;return o.append("file",t),n&&o.append("thread_id",n),await to("/files/upload-form",o,{onUploadProgress:s=>{try{if(r&&s.lengthComputable){const i=s.loaded/s.total;r(i)}}catch{}}})}}const au=new iu;class tb{constructor(){ic(this,"_authBaseUrl","")}get baseUrl(){return this._authBaseUrl}updateConfig(t){if(t.authBaseUrl)this._authBaseUrl=t.authBaseUrl;else if(t.baseUrl){const n=t.baseUrl.replace(/\/+$/,"");this._authBaseUrl=`${n}/auth`}t.apiKey!==void 0?Rn(t.apiKey):t.getToken&&Rn(t.getToken())}getAuthToken(){return Ri()}setAuthToken(t){Rn(t)}onTokenChange(t){return Mi(t)}async listUsers(){const t=await Kt("/users",{baseURL:this.baseUrl});return(t==null?void 0:t.users)??[]}}const nb=new tb,lu=b.createContext(null);function cu({children:e,apiConfig:t}){const n=Mn,r=nb;if(t){const s=n.baseUrl,i=r.baseUrl,a=n.getAuthToken();(t.baseUrl||t.chatBaseUrl)&&(t.chatBaseUrl&&t.chatBaseUrl!==s||t.baseUrl&&!s.startsWith(t.baseUrl))&&n.updateConfig(t),(t.baseUrl||t.authBaseUrl)&&(t.authBaseUrl&&t.authBaseUrl!==i||t.baseUrl&&!i.startsWith(t.baseUrl))&&r.updateConfig(t),t.apiKey!==void 0&&t.apiKey!==a&&(n.updateConfig({apiKey:t.apiKey}),r.updateConfig({apiKey:t.apiKey}))}const o={token:n.getAuthToken(),setToken:s=>{n.setAuthToken(s),r.setAuthToken(s)},chatApi:n,authApi:r,fileApi:au,baseUrl:n.baseUrl};return u.jsx(lu.Provider,{value:o,children:e})}async function uu(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 du(e=[]){const t=[],n=[];for(const r of e)try{const o=await uu(r),s=r.type||"application/octet-stream";n.push({filename:r.name,data:o,mime_type:s}),s.startsWith("image/")?t.push({type:"image_url",url:`data:${s};base64,${o}`,mimeType:s,alt:r.name}):t.push({type:"file",url:`data:${s};base64,${o}`,mimeType:s,name:r.name,size:r.size,sourceType:"base64"})}catch{}return{contentParts:t,filesInfo:n}}function On(){const e=b.useContext(lu);if(!e)throw new Error("useApi must be used within ApiProvider");return e}function fu(e){return!!e&&typeof e=="object"&&"data"in e}function Di(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 no(e,t,n){return t<0||t>=e.length?e:[...e.slice(0,t),n,...e.slice(t+1)]}function rb(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 pu(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="assistant")return e[t].id;return null}function hu(e){return!e||!e.length?"":e.filter(t=>t.type==="text").map(t=>t.text??"").join("")}function mu(e,t,n,r){const o={...n};if(r!==null&&typeof r=="number"){if(typeof o.lastSeq=="number"&&r<=o.lastSeq)return{newParts:e,newMeta:o,changed:!1};o.lastSeq=r}const s=t.filter(f=>f.type==="text").map(f=>f.text??"").join(""),i=t.filter(f=>f.type!=="text"),a=o.lastText??hu(e);let l="",c=e.slice();if(s){const f=ob(a,s);if(f===""?l="":f===s?l=s:l=f,sb(a,l)&&(l=` ${l}`),l){const m=c[c.length-1];if((m==null?void 0:m.type)==="text"){const p=m.text??"",v={...m,text:p+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 ob(e,t){if(!t)return"";if(!e)return t;if(e===t)return"";const n=Math.min(e.length,t.length);for(let r=n;r>0;r--)if(e.slice(-r)===t.slice(0,r))return t.slice(r);return t}function sb(e,t){if(!e||!t)return!1;const n=e.slice(-1),r=t[0];if(!n||!r||/\s/.test(n)||/\s/.test(r))return!1;const o=a=>/[A-Za-z0-9]/.test(a),s=a=>/[A-Za-z]/.test(a);return(a=>/[.,;:!?]/.test(a))(n)&&o(r)||/[A-Z]/.test(r)&&!/[\s\(\[\{]/.test(n)?!0:o(n)&&s(r)}function ib(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 no(e,r,s)}return e}function gu(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}function ab(e={}){const t=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),[f,m]=b.useState(""),[p,v]=b.useState(null),[g,x]=b.useState(0),[y,w]=b.useState(!1),[C,E]=b.useState(null),T=b.useRef(null),S=b.useRef(!0),k=b.useRef(0),A=b.useRef(null),j=b.useRef(null),F=b.useRef(null),D=b.useRef(null),B=b.useRef({messageId:null,lastSeq:null,lastText:""}),G=b.useCallback(z=>{o(z)},[]),M=b.useCallback(()=>{m(""),v(null),d(null),j.current=null,F.current=null,D.current=null,E(null),B.current={messageId:null,lastSeq:null,lastText:""}},[]),W=b.useCallback(()=>{var K;console.debug("[use-chat] stop() invoked - aborting stream");const z=(K=A.current)==null?void 0:K.threadId,P=()=>{var te;(te=T.current)==null||te.abort(),T.current=null,A.current=null,l(!1),w(!1),k.current=0,x(0)};(z?Mn.cancelRun(z).catch(te=>{console.warn("[use-chat] cancel run failed:",te)}):Promise.resolve()).finally(P)},[]),Y=b.useCallback((z,P,I)=>{T.current&&(T.current.abort(),T.current=null),l(!0),d(null),e.autoAppendAssistant!==!1&&m(""),v(null),j.current=null,F.current=null,D.current=null,E(null),B.current={messageId:null,lastSeq:null,lastText:""};const K=new AbortController;T.current=K;let te=null,O=null,q=!1;return A.current={threadId:z.threadId??null,headers:{}},(async()=>{var $,X,R,_,U,Z,re,ce,Ne,ye,Re,We,Fe,Ye,Ve,tt,gt,at,lt;const L=Me=>{var Ke;try{const je=JSON.parse(JSON.stringify(Me));return(Ke=je==null?void 0:je.payload)!=null&&Ke.files_info&&Array.isArray(je.payload.files_info)&&(je.payload.files_info=je.payload.files_info.map(qe=>({...qe,data:qe!=null&&qe.data?`<base64 ${String(qe.data).length} chars>`:qe==null?void 0:qe.data}))),je}catch{return Me}};try{let Me={};try{if(r)Me={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const ze=window.__AUTH_TOKEN__,kt=(($=window.localStorage)==null?void 0:$.getItem("authToken"))||null;let ut=null;try{const ge=(X=window.localStorage)==null?void 0:X.getItem("chat-settings");ge&&(ut=((R=JSON.parse(ge))==null?void 0:R.apiKey)||null)}catch{}const Pt=ze||kt||ut||null;Pt&&(Me={Authorization:`Bearer ${Pt}`})}}catch{}console.debug("[use-chat] POST",t+n,L(z));let Ke={};if(typeof window<"u")try{const Oe=(_=window.localStorage)==null?void 0:_.getItem("authSessionId");Oe&&(Ke={"X-Session-Id":Oe})}catch{}const je={...Me,...Ke,...s.current},qe={"Content-Type":"application/json",Accept:"text/event-stream",...je},Be=await fetch(t+n,{method:"POST",headers:qe,body:JSON.stringify(z),signal:K.signal,credentials:i});if(A.current&&(A.current.headers=je),!Be.ok||!Be.body){const Oe=await Be.text().catch(()=>"");console.debug("[use-chat] non-OK response",Be.status,Oe==null?void 0:Oe.slice(0,500));const ze=`stream ${Be.status}${Oe?": "+Oe:""}`;throw(U=I==null?void 0:I.onConnectionError)==null||U.call(I,ze),q=!0,te="error",O=ze,new Error(ze)}w(!0);const nt=Be.body.getReader(),ct=new TextDecoder;let ft="",yt=[];k.current=0,x(0);let Tt=0,pt=null;const At=()=>{if(yt.length){const Oe=yt.join("");yt=[],S.current&&m(ze=>ze+Oe)}pt=null},xt=()=>{typeof window<"u"&&pt==null&&(pt=requestAnimationFrame(At))};let ht=Date.now();const zt=setInterval(()=>{var Oe;if(Date.now()-ht>18e5){const ze="Stream idle timeout";d(ze),te="error",O=ze,K.abort(),(Oe=I==null?void 0:I.onError)==null||Oe.call(I,ze)}},5e3),Ht=1024*1024;try{const Oe=Be.headers.get("X-Thread-Id")||Be.headers.get("x-thread-id"),ze=Be.headers.get("X-Thread-Created")||Be.headers.get("x-thread-created"),kt=Oe??null,ut=String(ze??"").toLowerCase()==="true";for(A.current&&!A.current.threadId&&(A.current={...A.current,threadId:kt}),(Z=I==null?void 0:I.onOpen)==null||Z.call(I,{threadId:kt,created:ut});;){const{value:Pt,done:ge}=await nt.read();if(ge)break;ft+=ct.decode(Pt,{stream:!0}),ft.length>Ht&&(ft="",console.warn("Stream buffer reset: exceeded 1MB"));let De;for(;(De=ft.indexOf(`
|
|
36
36
|
|
|
37
|
-
`))>=0;){const
|
|
38
|
-
`);if(!Qe)continue;let ot;try{ot=JSON.parse(Qe)}catch{console.debug("[use-chat] malformed SSE:",Qe.slice(0,200));continue}const gt=fu(ot)?ot.data:ot;if(!gt){console.warn("[use-chat] dropped envelope event without payload",ot);continue}const K=gt;ht=Date.now();const se=K.seq;if(se!==void 0){if(se<=pt){console.debug("[use-chat] drop duplicate/out-of-order event",{seq:se,lastProcessedSeq:pt,type:K.type});continue}pt>0&&se>pt+1&&((re=I==null?void 0:I.onGap)==null||re.call(I,{from:pt,to:se})),pt=se,k.current=se,x(se)}if(K.type==="message.start"&&K.role==="assistant"){const ae=gu(K.model);B.current={messageId:K.id,lastSeq:se??null,lastText:""},E({id:K.id,role:"assistant",name:ae??void 0,model:K.model,createdAt:new Date().toISOString(),content:[]})}if(K.type==="checkpoint")j.current=K.checkpointId??null,F.current=K.checkpointNs??null,v(K.checkpointId??null);else if(K.type==="state_history"){D.current=K;try{const me=Xn(K).latest;me&&(j.current=me.checkpointId??null,F.current=me.checkpointNs??null,v(me.checkpointId??null))}catch(ae){console.warn("[use-chat] Failed to hydrate state_history payload",ae)}}try{P==null||P(K)}catch(ae){console.error("[use-chat] Error in onEvent callback:",ae,"for event:",K.type)}if(K.type==="message.delta"){E(me=>{const st=B.current;if(!me||st.messageId!==me.id)return me;const{newParts:N,newMeta:te,changed:ee}=mu(me.content??[],K.delta,{lastSeq:st.lastSeq,lastText:st.lastText},se??null);return ee?(B.current={...st,lastSeq:te.lastSeq??st.lastSeq,lastText:te.lastText??st.lastText},{...me,content:N}):me});const ae=K.delta.filter(me=>me.type==="text").map(me=>me.text).join("");ae&&e.autoAppendAssistant!==!1&&(Tt.push(ae),Pt())}else if(K.type==="heartbeat"){console.debug("[use-chat] heartbeat received");try{(le=I==null?void 0:I.onHeartbeat)==null||le.call(I,K)}catch(ae){console.warn("[use-chat] heartbeat callback failed",ae)}}else if(wt!==null&&cancelAnimationFrame(wt),At(),K.type==="checkpoint")v(K.checkpointId);else if(K.type==="error"){const ae=K;if(d(ae.message),Q="error",O=ae.message,ae.error_type==="auth_error"||ae.code==="TOKEN_EXPIRED"||((ke=ae.message)==null?void 0:ke.includes("token"))||((ye=ae.message)==null?void 0:ye.includes("401"))||((_e=ae.message)==null?void 0:_e.includes("unauthorized"))||((ze=ae.message)==null?void 0:ze.includes("Unauthorized"))){console.error("[use-chat] Auth error detected:",ae.message);try{($e=I==null?void 0:I.onAuthError)==null||$e.call(I,ae.message)}catch(st){console.warn("[use-chat] onAuthError handler failed",st)}q.abort()}}}}At(),Q===null&&!q.signal.aborted&&(Q="complete")}catch(We){if(We.name==="AbortError")Q=Q??"aborted";else{const Le=We.message||String(We);Q="error",O=Le,d(Le),(Ge=I==null?void 0:I.onError)==null||Ge.call(I,Le)}}finally{try{await Ye.cancel()}catch{}finally{(He=Ye.releaseLock)==null||He.call(Ye)}wt!==null&&typeof window<"u"&&window.cancelAnimationFrame(wt),clearInterval(mt)}}catch(Ue){if(Ue.name==="AbortError")Q=Q??"aborted";else{const Re=Ue.message||String(Ue);Q="error",O=Re,d(Re),(nt=I==null?void 0:I.onError)==null||nt.call(I,Re),G||((ft=I==null?void 0:I.onConnectionError)==null||ft.call(I,Re),G=!0)}}finally{const Ue=k.current,Re=j.current,Ve=F.current,Ne=D.current,Ke=Q??(q.signal.aborted?"aborted":O?"error":"complete");try{(ct=I==null?void 0:I.onClosed)==null||ct.call(I,{reason:Ke,lastSeq:Ue,lastCheckpointId:Re,lastCheckpointNs:Ve,lastStateHistory:Ne,error:O})}catch(Ye){console.warn("[use-chat] onClosed callback failed",Ye)}l(!1),w(!1),T.current=null,k.current=0,x(0),A.current=null}})(),{close:()=>q.abort()}},[t,n,r,e.autoAppendAssistant]);return b.useEffect(()=>()=>{var z;S.current=!1,(z=T.current)==null||z.abort()},[]),{isStreaming:a,error:c,assistantText:f,assistantMessage:C,lastCheckpointId:p,lastSeq:g,connected:y,stream:X,stop:W,clear:M,setToken:Y}}const lb=["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 lb){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 cb(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 xu({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),[f,m]=b.useState(null),[p,v]=b.useState([]),[g,x]=b.useState(!1),[,y]=b.useState(null),[w,C]=b.useState(null),[E,T]=b.useState(!1),S=b.useRef(a),k=b.useRef(new Map);b.useEffect(()=>{S.current=a},[a]),b.useEffect(()=>{t!==void 0&&t!==S.current&&l(t)},[t]);const A=b.useCallback(async()=>{d(!0),m(null);try{const P=await e.listThreads();i(P??[])}catch(P){const I=String(P);m(I),n==null||n(I)}finally{d(!1)}},[e,n]),j=b.useCallback(async()=>{x(!0),y(null);try{const P=await e.listSharedThreads();v(P??[])}catch(P){const I=String(P);y(I),n==null||n(I)}finally{x(!1)}},[e,n]);b.useEffect(()=>{A()},[A]),b.useEffect(()=>{j()},[j]),b.useEffect(()=>{r==null||r(a)},[a,r]);const F=b.useCallback(async(P,I)=>{try{const q=await e.createThread(P,I);return l(q.threadId),await A(),q.threadId}catch(q){const Q=String(q);return n==null||n(Q),null}},[e,n,A]),D=b.useCallback(async P=>{const I=s;i(Q=>Q.filter(O=>O.threadId!==P));const q=new AbortController;k.current.set(P,q);try{await e.deleteThread(P),S.current===P&&(l(null),o==null||o())}catch(Q){i(I);const O=String(Q);n==null||n(O)}finally{k.current.delete(P)}},[e,o,n,s]),B=b.useCallback(async(P,I)=>{try{await e.updateThread(P,I),await A()}catch(q){n==null||n(String(q))}},[e,n,A]),Y=b.useCallback(async(P,I)=>{T(!0),C("Sharing thread…");try{await e.shareThread(P,I),await j(),C("Shared successfully")}catch(q){const Q=cb(q);throw n==null||n(Q),C(`Failed to share: ${Q}`),new Error(Q)}finally{T(!1)}},[e,n,j]),M=b.useCallback(async(P,I)=>{try{await e.unshareThread(P,I),await j()}catch(q){const Q=String(q);throw n==null||n(Q),q}},[e,n,j]),W=b.useMemo(()=>({createThread:F,deleteThread:D,renameThread:B,refreshThreads:A,refreshSharedThreads:j,shareThread:Y,unshareThread:M}),[F,D,B,A,j,Y,M]),X=b.useCallback(P=>{if(!(P!=null&&P.threadId))return;const I={threadId:P.threadId,title:P.title||`Thread ${P.threadId.slice(0,8)}`,project:P.project,createdAt:P.createdAt||new Date().toISOString(),updatedAt:P.updatedAt||new Date().toISOString(),messageCount:P.messageCount??1};i(q=>{let Q=!1;const O=q.map(G=>G.threadId===I.threadId?(Q=!0,console.debug("[useThreadsState] thread_info: updating existing thread",I.threadId),{...G,title:I.title??G.title,project:I.project??G.project,updatedAt:I.updatedAt??G.updatedAt,messageCount:I.messageCount??G.messageCount}):G);return Q?O:(console.debug("[useThreadsState] thread_info: adding thread to list",I.threadId),[I,...q])})},[]),z=b.useCallback(()=>C(null),[]);return{threads:s,currentThreadId:a,currentThreadIdRef:S,setCurrentThreadId:l,isLoadingThreads:c,threadsError:f,sharedThreads:p,isLoadingSharedThreads:g,actions:W,addThreadFromEvent:X,shareInFlight:E,shareStatus:w,clearShareStatus:z}}const vu=b.createContext(null);function bu({children:e,initialThreadId:t=null,onError:n,onThreadChange:r}){const{chatApi:o}=On(),{threads:s,currentThreadId:i,setCurrentThreadId:a,currentThreadIdRef:l,isLoadingThreads:c,threadsError:d,sharedThreads:f,isLoadingSharedThreads:m,actions:p,addThreadFromEvent:v,shareInFlight:g,shareStatus:x,clearShareStatus:y}=xu({api:o,initialThreadId:t,onError:n,onThreadChange:r}),w=b.useMemo(()=>({threads:s,currentThreadId:i,setCurrentThreadId:a,currentThreadIdRef:l,isLoading:c,error:d,sharedThreads:f,isLoadingSharedThreads:m,actions:p,shareInFlight:g,shareStatus:x,clearShareStatus:y,addThreadFromEvent:v}),[s,i,a,l,c,d,f,m,p,g,x,y,v]);return u.jsx(vu.Provider,{value:w,children:e})}function yr(){const e=b.useContext(vu);if(!e)throw new Error("useThreads must be used within a ThreadsProvider");return e}function er(e){const t=e==null?void 0:e.trim();if(!t||!(t.startsWith("{")||t.startsWith("[")))return null;try{return JSON.parse(t)}catch{const n=ub(t);if(n)try{return JSON.parse(n)}catch{return null}return null}}function ub(e){let t=!1,n="";for(const o of e){if(o==="\\"){n+=o,t=!t;continue}if(o==="'"&&!t){n+='"';continue}n+=o,t=!1}return n.replace(/\bTrue\b/g,"true").replace(/\bFalse\b/g,"false").replace(/\bNone\b/g,"null")}function Li(e){return!!(e&&typeof e=="object"&&(e.type==="file"||e.mimeType||e.filename||e.sourceType==="base64"))}function Sr(e){if(typeof e=="string")return e;if(e&&typeof e=="object"){if(Array.isArray(e)){const n=e.map(Sr).filter(r=>r!==void 0);if(!n.length){console.debug("[message-utils] sanitizeForDisplay - array emptied -> returning undefined",{originalLength:e.length});return}return n}if(Li(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=Sr(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 tr(e){if(typeof e=="string")return e;if(Li(e))return"";try{const t=Sr(e);return t===void 0?"":typeof t=="string"?t:JSON.stringify(t,null,2)}catch{return""}}function wu(e){return typeof e!="string"?!1:/^[\s\n]*[-*]\s|^[\s\n]*#+\s|```|^\s*\[.*\]\(|^>\s/.test(e)}function yu(e){const t=tr(e);return typeof e=="string"&&wu(e)?{content:e,isMarkdown:!0}:{content:t,isMarkdown:!1}}function nr(e){if(e==null)return e;if(typeof e=="string"){const t=e.trim();if(t.startsWith("{")||t.startsWith("[")){const n=er(t);if(n!==null)return nr(n)}return e}return typeof e=="object"&&!Array.isArray(e)&&e.content!==void 0?nr(e.content):e}function Su(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function Yo(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 $i(e){if(e==null)return null;const t=String(e).trim();return t.length>0?t:null}function Cu(e){const t=r=>{try{const o=Sr(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 Tu(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function Fi(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 ku(e){if(!e)return"image/png";const t=e.trim();return t?t.includes("/")?t:`image/${t}`:"image/png"}function Eu(e){const t=[],n=r=>{r&&r.trim()&&t.push(r.trim())};return e&&(n(e.plotId),n(e.artifactId)),t}function Iu({base64:e,url:t,formatHint:n,extras:r}){const o=typeof e=="string"&&e.length>0,s=ku(n),i=o?`data:${s};base64,${e}`:t,a=Eu(r),l=a.length?a.join(" / "):void 0,c=l?`${l} artifact`:"artifact image";return{src:i,alt:c,label:l}}function Nu(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 Iu({base64:t,url:n,formatHint:r,extras:{plotId:e.plotId,artifactId:e.artifactId}})}function Bi(e){var n;const t=(n=e.additionalKwargs)==null?void 0:n.toolProgress;return Array.isArray(t)?t:[]}function Cr(e){if(e==null)return e;if(typeof e=="string"){const t=e.trim(),n=er(t);return n!==null?Cr(n):t}if(Array.isArray(e))return e.map(t=>Cr(t));if(typeof e=="object"){const t=e.value;if(t!==void 0)return Cr(t)}return e}function Au(e){const t=Cr(e.value);return t===e.value?e:{...e,value:t}}const db={messages:[],assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,messagesStreamMeta:{},pendingInterrupt:null};function fb(e,t){var n;switch(t.type){case"reset":return{messages:Di(((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],assemblingId:null}}}return{...e,messages:[...e.messages,r],assemblingId:null}}case"seed":{const r=Di(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=Di(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 ju(e,t.payload.ev);case"batch":{const{events:r}=t.payload;return r.length?r.reduce((o,s)=>ju(o,s),e):e}default:return e}}function pb(e=[]){const[t,n]=b.useReducer(fb,{...db,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,f)=>n({type:"seed",payload:{messages:d,...f??{}}}),prepend:d=>n({type:"prepend",payload:{messages:d}}),pushUser:(d,f)=>n({type:"user_message",payload:{message:d,editingMessageId:f}}),onEvent:l}),[l]);return{state:t,dispatch:n,...c}}function ju(e,t){var n,r,o;if(t.type==="message.start"&&t.role==="assistant"){const s=t.id,i=gu(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 mb(e,t);if(t.type==="tool.progress")return gb(e,t);if(t.type==="tool.end")return xb(e,t);if(t.type==="message.delta"){const s=e.assemblingId??pu(e.messages);if(!s)return e;const i=e.messages,a=i.findIndex(T=>T.id===s&&T.role==="assistant");if(a===-1)return e;const l=i[a],c=e.messagesStreamMeta,d=c??{},f=d[s],m=f??{lastSeq:null,lastText:hu(l.content)},p=t.seq??null;if(p!==null&&typeof p=="number"&&typeof m.lastSeq=="number"&&p<=m.lastSeq)return console.debug("[MessageReducer] skipping delta - seq <= lastSeq",{seq:p,lastSeq:m.lastSeq}),e;const{newParts:v,newMeta:g,changed:x}=mu(l.content,t.delta,m,p);if(!x)return e;const y={...l,content:v},w=no(i,a,y),C=!f||f.lastSeq!==g.lastSeq||f.lastText!==g.lastText,E=C?{...d,[s]:g}:c;return C?{...e,messages:w,messagesStreamMeta:E}:{...e,messages:w}}if(t.type==="message.end"){const s=e.assemblingId??pu(e.messages);if(!s)return{...e,assemblingId:null};const i=e.messages,a=i.findIndex(l=>l.id===s&&l.role==="assistant");if(a>=0){const l=i[a];if(!((n=l.content)==null?void 0:n.some(d=>{var f;return(d==null?void 0:d.type)==="text"&&((f=d.text)==null?void 0:f.trim())}))){console.debug("[MessageReducer] pruning assistant message with no visible text",{id:l.id,contentTypes:(r=l.content)==null?void 0:r.map(f=>f==null?void 0:f.type),contentPreview:(o=l.content)==null?void 0:o.map(f=>(f==null?void 0:f.type)==="text"?String(f.text).slice(0,100):f==null?void 0:f.type)});const d=[...i.slice(0,a),...i.slice(a+1)];return{...e,assemblingId:null,messages:d}}}return console.log("[MessageReducer] message.end - clearing assemblingId",{wasId:e.assemblingId}),{...e,assemblingId:null}}if(t.type==="checkpoint"){const s=t.checkpointNs??e.lastCheckpointNs??null,i=ib(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=Xn(t),i=s.interrupt,a=s.latest,l=i===null?rb(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 zi(e){return e.call_id??e.id??null}function Pu(e){return e.id??e.call_id??`tool-${Date.now()}-${Math.random().toString(16).slice(2)}`}function _u(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 Hi(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||Yo(r).toolCallId===t)return n}return-1}function hb(e){if(e==null)return[];const t=nr(e);if(typeof t=="string"&&t.trim())return[{type:"text",text:t}];const n=tr(t??e);return n?[{type:"text",text:n}]:[]}function Ru(e,t){const n=e.additionalKwargs??{},r=Array.isArray(n.toolProgress)?[...n.toolProgress]:[],o={...n,toolProgress:[...r,t]};return{...e,additionalKwargs:o}}function mb(e,t){const n=zi(t),r=Hi(e.messages,n),o=t.name??t.tool??void 0,s=Pu(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:no(e.messages,r,d)}}const i=_u(s,n,o,t.args);return{...e,messages:[...e.messages,i]}}function gb(e,t){const n=zi(t);if(!n)return e;const r=Hi(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=Ru(e.messages[r],o);return{...e,messages:no(e.messages,r,a)}}function xb(e,t){const n=zi(t),r=Pu(t);let o=e.messages,s=Hi(o,n);if(s===-1){const v=t.name??t.tool??void 0;o=[...o,_u(r,n,v,{})],s=o.length-1}const i=o[s],a=t.output??t.error??null,l=hb(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 f=Ru(i,d),m=t.artifact??i.artifact,p={...f,name:t.name??t.tool??i.name,content:c,artifact:m,additionalKwargs:{...f.additionalKwargs??{},toolStreaming:!1}};return{...e,messages:no(o,s,p)}}function Mu({api:e,seed:t,onError:n,currentThreadId:r,initialThreadId:o=null,initialCheckpointId:s=null,initialCheckpointNs:i=null,autoLoadInitial:a=!0,isStreaming:l,getMessages:c}){const[d,f]=b.useState(null),p=b.useMemo(()=>Xn(d),[d]).checkpoints,v=dc(p),g=v.timeline,[x,y]=b.useState(!1),[w,C]=b.useState(!1),[E,T]=b.useState(null),S=b.useRef(r),k=b.useRef(null),A=b.useRef(null),j=b.useRef(null),F=b.useRef(null),D=b.useRef(null),B=b.useRef(new Map),Y=b.useRef(null);b.useEffect(()=>{S.current=r},[r]);const M=b.useCallback(async L=>{var J,R;if(!L.threadId)return;const $=L.threadId;(J=L.onStart)==null||J.call(L),L.setLoading(!0);try{await L.action($)}catch(_){if(!tu(_)&&S.current===$){const Z=String(_);(R=L.handleError)==null||R.call(L,Z),n==null||n(Z)}throw _}finally{L.setLoading(!1)}},[n]),W=b.useCallback(async(L,$)=>{var Z;if(!L)return;const J=`${L}:${$??"latest"}`,R=B.current.get(J);if(R)return R;(Z=Y.current)==null||Z.abort();const _=new AbortController;Y.current=_;const U=M({threadId:L,setLoading:y,onStart:()=>T(null),handleError:re=>T(re),action:async re=>{const le=await e.getStateHistory({threadId:re,checkpointId:$??void 0,signal:_.signal});if(S.current!==re){console.log(`[useThreadHistoryState] Thread changed during load (was ${re}, now ${S.current}), discarding stale data`);return}const{checkpoints:ke}=Xn(le),ye=ke.find(_e=>_e.messages&&_e.messages.length>0)??($?ke.find(_e=>_e.checkpointId===$):null)??ke[0];t((ye==null?void 0:ye.messages)??[],{checkpointId:(ye==null?void 0:ye.checkpointId)??null,checkpointNs:(ye==null?void 0:ye.checkpointNs)??null,pendingInterrupt:(ye==null?void 0:ye.interrupt)??null}),f(le)}});B.current.set(J,U);try{await U}finally{B.current.delete(J),Y.current===_&&(Y.current=null)}return S.current===L&&(D.current=J),U},[e,t,M]),X=b.useCallback(async(L,$)=>{F.current=L;try{await W(L,$)}catch(J){if(!tu(J))throw J}finally{F.current===L&&(F.current=null)}},[W]),z=b.useCallback(L=>{A.current=L},[]),P=b.useCallback(L=>{j.current=L},[]),I=b.useCallback(L=>{const $=L.threadId??S.current;if(!$||S.current&&S.current!==$)return;const{checkpoints:J}=Xn(L);if(!J.length)return;const R=J.find(U=>U.messages&&U.messages.length>0)??J.find(U=>!!U.checkpointId)??J[0],_=j.current===$;!l&&!_&&t((R==null?void 0:R.messages)??[],{checkpointId:(R==null?void 0:R.checkpointId)??null,checkpointNs:(R==null?void 0:R.checkpointNs)??null,pendingInterrupt:(R==null?void 0:R.interrupt)??null}),f(L),D.current=`${$}:latest`,A.current=null,j.current===$&&(j.current=null)},[t,l]),q=b.useCallback(async(L,$)=>{const J=S.current;await M({threadId:J,setLoading:C,action:async R=>{const _=await e.getStateHistory({threadId:R,checkpointId:L,checkpointNs:$??void 0});if(S.current!==R)return;const{checkpoints:U}=Xn(_),Z=U.find(re=>re.checkpointId===L&&($?re.checkpointNs===$:!0));if(!Z){console.warn("[useThreadHistoryState] Requested checkpoint not found:",{checkpointId:L,checkpointNs:$});return}f(_),t(Z.messages??[],{checkpointId:Z.checkpointId??null,checkpointNs:Z.checkpointNs??null})}}).catch(()=>{})},[e,t,M]),Q=b.useCallback((L,$)=>{t(c(),{checkpointId:L??null,checkpointNs:$??null})},[c,t]),O=b.useCallback(async()=>{S.current&&await X(S.current)},[X]);b.useEffect(()=>{if(!a||!r||x||l)return;if(A.current===r){A.current=null,k.current=r;return}if(j.current===r){k.current=r;return}if(F.current===r){F.current=null,k.current=r;return}if(k.current===r)return;k.current=r;let L;const $=`${r}:latest`;D.current!==$&&X(r,L)},[a,r,s,i,o,x,l,X]);const G=b.useCallback(()=>{f(null),y(!1),C(!1),T(null),A.current=null,j.current=null,k.current=null,D.current=null,F.current=null},[]);return{threadCheckpoints:p,threadTimeline:g,checkpointIndex:v,isLoadingThread:x,isLoadingCheckpoint:w,threadStateError:E,loadThread:X,navigateToCheckpoint:q,setCurrentCheckpointId:Q,returnToLatest:O,handleStateHistoryEvent:I,markSkipNextLoad:z,markStreamPendingThread:P,resetHistoryState:G}}const Ou=b.createContext(null),Du=b.createContext(null);function ro(){const e=b.useContext(Ou);if(!e)throw new Error("useThreadState must be used within a ThreadStateProvider");return e}function Lu(){const e=b.useContext(Du);if(!e)throw new Error("useThreadStateUpdater must be used within a ThreadStateProvider");return e}function $u({children:e,initialThreadId:t=null,initialCheckpointId:n=null,initialCheckpointNs:r=null,autoLoadInitial:o=!0,isStreaming:s,onError:i}){const{chatApi:a}=On(),{currentThreadId:l}=yr(),{state:c,seed:d,pushUser:f,onEvent:m}=pb(),{threadCheckpoints:p,threadTimeline:v,checkpointIndex:g,isLoadingThread:x,isLoadingCheckpoint:y,threadStateError:w,loadThread:C,navigateToCheckpoint:E,setCurrentCheckpointId:T,returnToLatest:S,handleStateHistoryEvent:k,markSkipNextLoad:A,markStreamPendingThread:j,resetHistoryState:F}=Mu({api:a,seed:d,onError:i,currentThreadId:l,initialThreadId:t,initialCheckpointId:n,initialCheckpointNs:r,autoLoadInitial:o,isStreaming:s,getMessages:b.useCallback(()=>c.messages,[c.messages])}),[D,B]=b.useState(()=>async()=>{throw new Error("clearThread is not ready")}),[Y,M]=b.useState(()=>async()=>{throw new Error("respondToInterrupt is not ready")});b.useEffect(()=>{l||(d([],{}),F())},[l,d,F]);const W=b.useCallback(q=>B(()=>q),[]),X=b.useCallback(q=>M(()=>q),[]),z=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:p,checkpointIndex:g,timelineCheckpoints:v,metadata:z,isLoading:x,isLoadingCheckpoint:y,error:w,clearState:D,navigateToCheckpoint:E,setCurrentCheckpointId:T,returnToLatest:S,loadThread:C,clearThread:D,respondToInterrupt:Y,messagePreviews:g.messagePreviews,handleStateHistoryEvent:k,markSkipNextLoad:A,markStreamPendingThread:j,resetHistoryState:F,pushUser:f,onEvent:m}),[l,c,p,v,g,z,x,y,w,D,E,T,S,C,Y,g.messagePreviews,k,A,j,F,f,m]),I=b.useMemo(()=>({registerClearThread:W,registerRespondToInterrupt:X}),[W,X]);return u.jsx(Du.Provider,{value:I,children:u.jsx(Ou.Provider,{value:P,children:e})})}function Fu(e,t){if(!e)return null;const n=Pn(e);if(!n)return null;const r=Pn(n.configurable)??n;return _n(r,t)??null}function vb(e){const t=Fu(e,["checkpoint_id","checkpointId"]);if(!t)return null;const n=Fu(e,["checkpoint_ns","checkpointNs"]);return{checkpointId:t,checkpointNs:n}}function bb(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 wb(e,t){const n=[...e].sort(bb);for(const r of n){if(r.messageId!==t)continue;const o=vb(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 Bu=b.createContext(null),zu=b.createContext(!1);function yb({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{chatApi:d,baseUrl:f}=On(),m=f,{stream:p,stop:v,isStreaming:g,error:x,setToken:y}=ab({baseUrl:m}),[w,C]=b.useState(!1);return b.useEffect(()=>{C(g)},[g]),u.jsx(bu,{initialThreadId:t,onError:s,onThreadChange:a,children:u.jsx($u,{initialThreadId:t,initialCheckpointId:n,initialCheckpointNs:r,autoLoadInitial:o,onError:s,isStreaming:w,children:u.jsx(zu.Provider,{value:!0,children:u.jsx(Sb,{api:d,streamApi:{stream:p,stop:v,isStreaming:g,error:x,setToken:y},onError:s,onAuthError:i,onConnectionError:l,onToolEnd:c,children:e})})})})}function Sb({children:e,api:t,streamApi:n,onError:r,onAuthError:o,onConnectionError:s,onToolEnd:i}){const{stream:a,stop:l,isStreaming:c,error:d,setToken:f}=n,{setCurrentThreadId:m,currentThreadIdRef:p,addThreadFromEvent:v}=yr(),{checkpoint:g,timelineCheckpoints:x,handleStateHistoryEvent:y,markSkipNextLoad:w,markStreamPendingThread:C,resetHistoryState:E,pushUser:T,onEvent:S}=ro(),{registerClearThread:k,registerRespondToInterrupt:A}=Lu(),j=b.useCallback(z=>{v(z),p.current!==z.threadId&&((z.created??!p.current)&&w(z.threadId),C(z.threadId),m(z.threadId))},[v,w,C,m,p]),F=b.useCallback(z=>{z.type==="thread_info"?j(z):z.type==="state_history"?y(z):z.type==="tool.end"?(S(z),i==null||i(z)):S(z)},[j,y,S,i]),D=b.useCallback(z=>{a(z,F,{onError:P=>{console.error("[StreamingProvider] Stream error:",P),r==null||r(P)},onAuthError:P=>{console.error("[StreamingProvider] Auth error:",P),o==null||o(P)},onConnectionError:P=>{console.error("[StreamingProvider] Connection error:",P),s==null||s(P)}})},[a,F,r,o,s]),B=b.useRef(g);b.useEffect(()=>{B.current=g},[g]);const Y=b.useCallback(async(z,P,I)=>{const q=p.current;if(!q)throw new Error("No active thread to handle interrupt");const Q=z?P??!0:!1,O=B.current,G={threadId:q,checkpointId:O.id??void 0,checkpointNs:O.namespace??void 0,command:{kind:"resume",value:Q},payload:I==null?void 0:I.payload,config:I==null?void 0:I.config,nodeFilter:I==null?void 0:I.nodeFilter,branchLabel:I==null?void 0:I.branchLabel,timelineCheckpoints:I==null?void 0:I.timelineCheckpoints};D(G)},[p,D]);b.useEffect(()=>{A(Y)},[Y,A]);const M=b.useCallback(async()=>{l(),E(),m(null)},[E,m,l]);b.useEffect(()=>{k(M)},[M,k]);const W=b.useCallback(async(z,P)=>{c&&l();let I=p.current;const q=(z==null?void 0:z.text)??"",Q=(z==null?void 0:z.attachments)??[],O=(q==null?void 0:q.trim())??"",G={...(z==null?void 0:z.payload)??{}},L=Array.isArray(G.messages)?G.messages:void 0;L&&delete G.messages;const $=!!(L&&L.length),J=!!(z.contentParts&&z.contentParts.length>0);if(!I&&!O&&Q.length===0&&!$&&!J)return;if(!I){const nt=Math.floor(Date.now()/1e3).toString(16).padStart(8,"0"),ft=Array.from({length:4},()=>Math.floor(Math.random()*4294967295).toString(16).padStart(8,"0")).join("").slice(0,16);I=`${nt}${ft}`,w(I),m(I)}let R=null;z.contentParts&&z.contentParts.length>0&&(R=z.contentParts);const{contentParts:_,filesInfo:U}=R?{contentParts:R,filesInfo:[]}:await du(Q),Z=[..._];O&&Z.push({type:"text",text:q});const re=P==null?void 0:P.originalMessageId,le=!!(P!=null&&P.edit&&re),ke=!$&&Z.length>0;let ye=null;ke&&(ye={id:le?re:`msg-${Date.now()}`,role:"user",content:Z,createdAt:new Date().toISOString()},le?T(ye,re):T(ye));const _e=$?L:ye?[ye]:[],ze={...G,...U.length?{files_info:U}:{}};_e.length?ze.messages=_e:"messages"in ze||(ze.messages=[]);let $e=(P==null?void 0:P.checkpointId)??g.id??void 0,Ge=(P==null?void 0:P.checkpointNs)??g.namespace??void 0;if(le&&re){const nt=wb(x,re);$e=nt.checkpointId,Ge=nt.checkpointNs??void 0}const He={threadId:I,payload:ze,checkpointId:$e,checkpointNs:Ge,config:P==null?void 0:P.config,edit:!!(P!=null&&P.edit)};D(He)},[g,p,c,w,T,D,l,x]),X=b.useMemo(()=>({isStreaming:c,error:d,connectionState:c?"connected":"idle",submit:W,send:W,stop:l,setAuthToken:f}),[c,d,W,l,f]);return u.jsx(Bu.Provider,{value:X,children:e})}function Ui(){const e=b.useContext(Bu);if(!e)throw new Error("useStream must be used within StreamingProvider");return e}function Cb(){return b.useContext(zu)}function Hu(e){return typeof e=="object"&&e!==null}function Tb(e,t){if(Object.is(e,t))return!0;if(!Hu(e)||!Hu(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 Uu(e){const t=b.useRef(e),n=b.useRef(e);return Tb(t.current,e)||(t.current=e,n.current=e),n.current}function Tr({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 f=Uu(t),m=oo(a),p=oo(l),v=oo(i),g=oo(c),x=oo(d),y=b.useMemo(()=>({initialThreadId:n,initialCheckpointId:r,initialCheckpointNs:o,autoLoadInitial:s,onError:m,onAuthError:p,onConnectionError:v,onThreadChange:g,onToolEnd:x}),[n,r,o,s,m,p,v,g,x]);return u.jsx(cu,{apiConfig:f,children:u.jsx(yb,{...y,children:e})})}function oo(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 kr(e){if(!(typeof globalThis>"u"))return globalThis[e]}function Wu(){const e=[kr("__API_BASE_URL__"),kr("__CHAT_API_BASE_URL__"),kr("__CHAT_API_URL__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim().replace(/\/+$/,"")}function Vu(){const e=[kr("__API_AUTH_TOKEN__"),kr("__CHAT_API_KEY__"),kr("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function Ku(...e){for(const t of e)if(typeof t=="string"&&t.trim())return t.trim().replace(/\/+$/,"");return""}function qu(){const e={},t=Wu(),n=Vu();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function Gu(){const e=qu(),t=Mn.getAuthToken(),n=Wu();return{apiBaseUrl:Ku(e.baseUrl,n),apiKey:t||e.apiKey||Vu()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,darkMode:!1,enableSound:!1,messageHistory:100}}const Wi="chat-settings";function Yu(){try{const e=localStorage.getItem(Wi);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function Xu(e){try{const t={...e,apiBaseUrl:e.apiBaseUrl.trim().replace(/\/+$/,"")};localStorage.setItem(Wi,JSON.stringify(t)),t.apiKey&&Mn.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function kb(){const e=Gu(),t=Yu(),n=Mn.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:Ku(Mn.baseUrl,r,e.apiBaseUrl)}}function Eb(e){Mn.updateConfig({baseUrl:e.apiBaseUrl,apiKey:e.apiKey??void 0}),Xu(e)}function oe(...e){return bx.twMerge(vx.clsx(e))}const Ib=Kr.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=h.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?Jt.Slot:"button";return u.jsx(i,{className:oe(Ib({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 Ju(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Dn(...e){return t=>{let n=!1;const r=e.map(o=>{const s=Ju(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():Ju(e[o],null)}}}}function Me(...e){return h.useCallback(Dn(...e),e)}function Nb(e,t){const n=h.createContext(t),r=s=>{const{children:i,...a}=s,l=h.useMemo(()=>a,Object.values(a));return u.jsx(n.Provider,{value:l,children:i})};r.displayName=e+"Provider";function o(s){const i=h.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 nn(e,t=[]){let n=[];function r(s,i){const a=h.createContext(i),l=n.length;n=[...n,i];const c=f=>{var y;const{scope:m,children:p,...v}=f,g=((y=m==null?void 0:m[e])==null?void 0:y[l])||a,x=h.useMemo(()=>v,Object.values(v));return u.jsx(g.Provider,{value:x,children:p})};c.displayName=s+"Provider";function d(f,m){var g;const p=((g=m==null?void 0:m[e])==null?void 0:g[l])||a,v=h.useContext(p);if(v)return v;if(i!==void 0)return i;throw new Error(`\`${f}\` must be used within \`${s}\``)}return[c,d]}const o=()=>{const s=n.map(i=>h.createContext(i));return function(a){const l=(a==null?void 0:a[e])||s;return h.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return o.scopeName=e,[r,Ab(o,...t)]}function Ab(...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 f=l(s)[`__scope${c}`];return{...a,...f}},{});return h.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var It=globalThis!=null&&globalThis.document?h.useLayoutEffect:()=>{},jb=h[" useId ".trim().toString()]||(()=>{}),Pb=0;function jt(e){const[t,n]=h.useState(jb());return It(()=>{n(r=>r??String(Pb++))},[e]),e||(t?`radix-${t}`:"")}var _b=h[" useInsertionEffect ".trim().toString()]||It;function In({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=Rb({defaultProp:t,onChange:n}),a=e!==void 0,l=a?e:o;{const d=h.useRef(e!==void 0);h.useEffect(()=>{const f=d.current;f!==a&&console.warn(`${r} is changing from ${f?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),d.current=a},[a,r])}const c=h.useCallback(d=>{var f;if(a){const m=Mb(d)?d(e):d;m!==e&&((f=i.current)==null||f.call(i,m))}else s(d)},[a,e,s,i]);return[l,c]}function Rb({defaultProp:e,onChange:t}){const[n,r]=h.useState(e),o=h.useRef(n),s=h.useRef(t);return _b(()=>{s.current=t},[t]),h.useEffect(()=>{var i;o.current!==n&&((i=s.current)==null||i.call(s,n),o.current=n)},[n,o]),[n,r,s]}function Mb(e){return typeof e=="function"}var Ob=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],he=Ob.reduce((e,t)=>{const n=Jt.createSlot(`Primitive.${t}`),r=h.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 Vi(e,t){e&&qr.flushSync(()=>e.dispatchEvent(t))}function vt(e){const t=h.useRef(e);return h.useEffect(()=>{t.current=e}),h.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function Db(e,t=globalThis==null?void 0:globalThis.document){const n=vt(e);h.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 Lb="DismissableLayer",Ki="dismissableLayer.update",$b="dismissableLayer.pointerDownOutside",Fb="dismissableLayer.focusOutside",Zu,Qu=h.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Er=h.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...l}=e,c=h.useContext(Qu),[d,f]=h.useState(null),m=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,p]=h.useState({}),v=Me(t,k=>f(k)),g=Array.from(c.layers),[x]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),y=g.indexOf(x),w=d?g.indexOf(d):-1,C=c.layersWithOutsidePointerEventsDisabled.size>0,E=w>=y,T=zb(k=>{const A=k.target,j=[...c.branches].some(F=>F.contains(A));!E||j||(o==null||o(k),i==null||i(k),k.defaultPrevented||a==null||a())},m),S=Hb(k=>{const A=k.target;[...c.branches].some(F=>F.contains(A))||(s==null||s(k),i==null||i(k),k.defaultPrevented||a==null||a())},m);return Db(k=>{w===c.layers.size-1&&(r==null||r(k),!k.defaultPrevented&&a&&(k.preventDefault(),a()))},m),h.useEffect(()=>{if(d)return n&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(Zu=m.body.style.pointerEvents,m.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(d)),c.layers.add(d),td(),()=>{n&&c.layersWithOutsidePointerEventsDisabled.size===1&&(m.body.style.pointerEvents=Zu)}},[d,m,n,c]),h.useEffect(()=>()=>{d&&(c.layers.delete(d),c.layersWithOutsidePointerEventsDisabled.delete(d),td())},[d,c]),h.useEffect(()=>{const k=()=>p({});return document.addEventListener(Ki,k),()=>document.removeEventListener(Ki,k)},[]),u.jsx(he.div,{...l,ref:v,style:{pointerEvents:C?E?"auto":"none":void 0,...e.style},onFocusCapture:ce(e.onFocusCapture,S.onFocusCapture),onBlurCapture:ce(e.onBlurCapture,S.onBlurCapture),onPointerDownCapture:ce(e.onPointerDownCapture,T.onPointerDownCapture)})});Er.displayName=Lb;var Bb="DismissableLayerBranch",ed=h.forwardRef((e,t)=>{const n=h.useContext(Qu),r=h.useRef(null),o=Me(t,r);return h.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),u.jsx(he.div,{...e,ref:o})});ed.displayName=Bb;function zb(e,t=globalThis==null?void 0:globalThis.document){const n=vt(e),r=h.useRef(!1),o=h.useRef(()=>{});return h.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){nd($b,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 Hb(e,t=globalThis==null?void 0:globalThis.document){const n=vt(e),r=h.useRef(!1);return h.useEffect(()=>{const o=s=>{s.target&&!r.current&&nd(Fb,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 td(){const e=new CustomEvent(Ki);document.dispatchEvent(e)}function nd(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?Vi(o,s):o.dispatchEvent(s)}var Ub=Er,Wb=ed,qi="focusScope.autoFocusOnMount",Gi="focusScope.autoFocusOnUnmount",rd={bubbles:!1,cancelable:!0},Vb="FocusScope",Xo=h.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,l]=h.useState(null),c=vt(o),d=vt(s),f=h.useRef(null),m=Me(t,g=>l(g)),p=h.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;h.useEffect(()=>{if(r){let g=function(C){if(p.paused||!a)return;const E=C.target;a.contains(E)?f.current=E:Ln(f.current,{select:!0})},x=function(C){if(p.paused||!a)return;const E=C.relatedTarget;E!==null&&(a.contains(E)||Ln(f.current,{select:!0}))},y=function(C){if(document.activeElement===document.body)for(const T of C)T.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,p.paused]),h.useEffect(()=>{if(a){id.add(p);const g=document.activeElement;if(!a.contains(g)){const y=new CustomEvent(qi,rd);a.addEventListener(qi,c),a.dispatchEvent(y),y.defaultPrevented||(Kb(Jb(od(a)),{select:!0}),document.activeElement===g&&Ln(a))}return()=>{a.removeEventListener(qi,c),setTimeout(()=>{const y=new CustomEvent(Gi,rd);a.addEventListener(Gi,d),a.dispatchEvent(y),y.defaultPrevented||Ln(g??document.body,{select:!0}),a.removeEventListener(Gi,d),id.remove(p)},0)}}},[a,c,d,p]);const v=h.useCallback(g=>{if(!n&&!r||p.paused)return;const x=g.key==="Tab"&&!g.altKey&&!g.ctrlKey&&!g.metaKey,y=document.activeElement;if(x&&y){const w=g.currentTarget,[C,E]=qb(w);C&&E?!g.shiftKey&&y===E?(g.preventDefault(),n&&Ln(C,{select:!0})):g.shiftKey&&y===C&&(g.preventDefault(),n&&Ln(E,{select:!0})):y===w&&g.preventDefault()}},[n,r,p.paused]);return u.jsx(he.div,{tabIndex:-1,...i,ref:m,onKeyDown:v})});Xo.displayName=Vb;function Kb(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Ln(r,{select:t}),document.activeElement!==n)return}function qb(e){const t=od(e),n=sd(t,e),r=sd(t.reverse(),e);return[n,r]}function od(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 sd(e,t){for(const n of e)if(!Gb(n,{upTo:t}))return n}function Gb(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 Yb(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&&Yb(e)&&t&&e.select()}}var id=Xb();function Xb(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=ad(e,t),e.unshift(t)},remove(t){var n;e=ad(e,t),(n=e[0])==null||n.resume()}}}function ad(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Jb(e){return e.filter(t=>t.tagName!=="A")}var Zb="Portal",so=h.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=h.useState(!1);It(()=>s(!0),[]);const i=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?Do.createPortal(u.jsx(he.div,{...r,ref:t}),i):null});so.displayName=Zb;function Qb(e,t){return h.useReducer((n,r)=>t[n][r]??n,e)}var Ft=e=>{const{present:t,children:n}=e,r=ew(t),o=typeof n=="function"?n({present:r.isPresent}):h.Children.only(n),s=Me(r.ref,tw(o));return typeof n=="function"||r.isPresent?h.cloneElement(o,{ref:s}):null};Ft.displayName="Presence";function ew(e){const[t,n]=h.useState(),r=h.useRef(null),o=h.useRef(e),s=h.useRef("none"),i=e?"mounted":"unmounted",[a,l]=Qb(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return h.useEffect(()=>{const c=Jo(r.current);s.current=a==="mounted"?c:"none"},[a]),It(()=>{const c=r.current,d=o.current;if(d!==e){const m=s.current,p=Jo(c);e?l("MOUNT"):p==="none"||(c==null?void 0:c.display)==="none"?l("UNMOUNT"):l(d&&m!==p?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,l]),It(()=>{if(t){let c;const d=t.ownerDocument.defaultView??window,f=p=>{const g=Jo(r.current).includes(CSS.escape(p.animationName));if(p.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=p=>{p.target===t&&(s.current=Jo(r.current))};return t.addEventListener("animationstart",m),t.addEventListener("animationcancel",f),t.addEventListener("animationend",f),()=>{d.clearTimeout(c),t.removeEventListener("animationstart",m),t.removeEventListener("animationcancel",f),t.removeEventListener("animationend",f)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:h.useCallback(c=>{r.current=c?getComputedStyle(c):null,n(c)},[])}}function Jo(e){return(e==null?void 0:e.animationName)||"none"}function tw(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 Yi=0;function Xi(){h.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??ld()),document.body.insertAdjacentElement("beforeend",e[1]??ld()),Yi++,()=>{Yi===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Yi--}},[])}function ld(){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 vn=function(){return vn=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},vn.apply(this,arguments)};function cd(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 nw(e,t,n){if(n||arguments.length===2)for(var r=0,o=t.length,s;r<o;r++)(s||!(r in t))&&(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return e.concat(s||Array.prototype.slice.call(t))}typeof SuppressedError=="function"&&SuppressedError;var Zo="right-scroll-bar-position",Qo="width-before-scroll-bar",rw="with-scroll-bars-hidden",ow="--removed-body-scroll-bar-size";function Ji(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function sw(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 iw=typeof window<"u"?h.useLayoutEffect:h.useEffect,ud=new WeakMap;function aw(e,t){var n=sw(null,function(r){return e.forEach(function(o){return Ji(o,r)})});return iw(function(){var r=ud.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||Ji(a,null)}),s.forEach(function(a){o.has(a)||Ji(a,i)})}ud.set(n,e)},[e]),n}function lw(e){return e}function cw(e,t){t===void 0&&(t=lw);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 uw(e){e===void 0&&(e={});var t=cw(null);return t.options=vn({async:!0,ssr:!1},e),t}var dd=function(e){var t=e.sideCar,n=cd(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 h.createElement(r,vn({},n))};dd.isSideCarExport=!0;function dw(e,t){return e.useMedium(t),dd}var fd=uw(),Zi=function(){},es=h.forwardRef(function(e,t){var n=h.useRef(null),r=h.useState({onScrollCapture:Zi,onWheelCapture:Zi,onTouchMoveCapture:Zi}),o=r[0],s=r[1],i=e.forwardProps,a=e.children,l=e.className,c=e.removeScrollBar,d=e.enabled,f=e.shards,m=e.sideCar,p=e.noRelative,v=e.noIsolation,g=e.inert,x=e.allowPinchZoom,y=e.as,w=y===void 0?"div":y,C=e.gapMode,E=cd(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),T=m,S=aw([n,t]),k=vn(vn({},E),o);return h.createElement(h.Fragment,null,d&&h.createElement(T,{sideCar:fd,removeScrollBar:c,shards:f,noRelative:p,noIsolation:v,inert:g,setCallbacks:s,allowPinchZoom:!!x,lockRef:n,gapMode:C}),i?h.cloneElement(h.Children.only(a),vn(vn({},k),{ref:S})):h.createElement(w,vn({},k,{className:l,ref:S}),a))});es.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},es.classNames={fullWidth:Qo,zeroRight:Zo};var fw=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function pw(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=fw();return t&&e.setAttribute("nonce",t),e}function hw(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function mw(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var gw=function(){var e=0,t=null;return{add:function(n){e==0&&(t=pw())&&(hw(t,n),mw(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},xw=function(){var e=gw();return function(t,n){h.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},pd=function(){var e=xw(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},vw={left:0,top:0,right:0,gap:0},Qi=function(e){return parseInt(e||"",10)||0},bw=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[Qi(n),Qi(r),Qi(o)]},ww=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return vw;var t=bw(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])}},yw=pd(),Ir="data-scroll-locked",Sw=function(e,t,n,r){var o=e.left,s=e.top,i=e.right,a=e.gap;return n===void 0&&(n="margin"),`
|
|
37
|
+
`))>=0;){const He=ft.slice(0,De);ft=ft.slice(De+2);const st=He.split(/\r?\n/),et=[];let dt=null;for(const Ee of st){if(Ee.startsWith(":")){Ee.startsWith(": heartbeat")&&console.debug("[use-chat] SSE heartbeat comment received");continue}if(Ee){if(Ee.startsWith("event:")){const N=Ee.slice(6).trim();N&&(dt=N);continue}if(Ee.startsWith("data:")){const N=Ee.slice(5);et.push(N.startsWith(" ")?N.slice(1):N)}}}const mt=et.join(`
|
|
38
|
+
`);if(!mt)continue;let J;try{J=JSON.parse(mt)}catch{console.debug("[use-chat] malformed SSE:",mt.slice(0,200));continue}dt&&typeof J=="object"&&J!==null&&!("type"in J)&&(J.type=dt);const ae=fu(J)?J.data:J;if(!ae){console.warn("[use-chat] dropped envelope event without payload",J);continue}const ie=ae;ht=Date.now();const Ce=ie.seq;if(Ce!==void 0){if(Ce<=Tt){console.debug("[use-chat] drop duplicate/out-of-order event",{seq:Ce,lastProcessedSeq:Tt,type:ie.type});continue}Tt>0&&Ce>Tt+1&&((re=I==null?void 0:I.onGap)==null||re.call(I,{from:Tt,to:Ce})),Tt=Ce,k.current=Ce,x(Ce)}if(ie.type==="message.start"&&ie.role==="assistant"){const Ee=gu(ie.model);B.current={messageId:ie.id,lastSeq:Ce??null,lastText:""},E({id:ie.id,role:"assistant",name:Ee??void 0,model:ie.model,createdAt:new Date().toISOString(),content:[]})}if(ie.type==="checkpoint")j.current=ie.checkpointId??null,F.current=ie.checkpointNs??null,v(ie.checkpointId??null);else if(ie.type==="state_history"){D.current=ie;try{const N=Xn(ie).latest;N&&(j.current=N.checkpointId??null,F.current=N.checkpointNs??null,v(N.checkpointId??null))}catch(Ee){console.warn("[use-chat] Failed to hydrate state_history payload",Ee)}}try{P==null||P(ie)}catch(Ee){console.error("[use-chat] Error in onEvent callback:",Ee,"for event:",ie.type)}if(ie.type==="messages/partial"){const N=ie.messages;if(Array.isArray(N)&&N.length>0){const Q=N.find(ee=>ee.type==="ai");if(Q){const ee=Q.id,le=Q.content??"",me=Q.response_metadata??{};if(B.current.messageId!==ee){const be=me.model_name??me.model_provider??"assistant";B.current={messageId:ee,lastSeq:null,lastText:""},E({id:ee,role:"assistant",name:be,model:be,createdAt:new Date().toISOString(),content:[{type:"text",text:le}]})}else E(be=>!be||be.id!==ee?be:{...be,content:[{type:"text",text:le}]});const Se=B.current.lastText||"";if(le.length>Se.length){const be=le.slice(Se.length);B.current.lastText=le,e.autoAppendAssistant!==!1&&(yt.push(be),xt())}}}}else if(ie.type==="message.delta"){E(Q=>{const ee=B.current;if(!Q||ee.messageId!==Q.id)return Q;const le=ie,{newParts:me,newMeta:Se,changed:be}=mu(Q.content??[],le.delta,{lastSeq:ee.lastSeq,lastText:ee.lastText},Ce??null);return be?(B.current={...ee,lastSeq:Se.lastSeq??ee.lastSeq,lastText:Se.lastText??ee.lastText},{...Q,content:me}):Q});const N=((ce=ie.delta)==null?void 0:ce.filter(Q=>Q.type==="text").map(Q=>Q.text).join(""))??"";N&&e.autoAppendAssistant!==!1&&(yt.push(N),xt())}else if(ie.type==="heartbeat"){console.debug("[use-chat] heartbeat received");try{(Ne=I==null?void 0:I.onHeartbeat)==null||Ne.call(I,ie)}catch(Ee){console.warn("[use-chat] heartbeat callback failed",Ee)}}else if(pt!==null&&cancelAnimationFrame(pt),At(),ie.type==="checkpoint")v(ie.checkpointId);else if(ie.type==="error"){const Ee=ie;if(d(Ee.message),te="error",O=Ee.message,Ee.error_type==="auth_error"||Ee.code==="TOKEN_EXPIRED"||((ye=Ee.message)==null?void 0:ye.includes("token"))||((Re=Ee.message)==null?void 0:Re.includes("401"))||((We=Ee.message)==null?void 0:We.includes("unauthorized"))||((Fe=Ee.message)==null?void 0:Fe.includes("Unauthorized"))){console.error("[use-chat] Auth error detected:",Ee.message);try{(Ye=I==null?void 0:I.onAuthError)==null||Ye.call(I,Ee.message)}catch(Q){console.warn("[use-chat] onAuthError handler failed",Q)}K.abort()}}}}At(),te===null&&!K.signal.aborted&&(te="complete")}catch(Oe){if(Oe.name==="AbortError")te=te??"aborted";else{const ze=Oe.message||String(Oe);te="error",O=ze,d(ze),(Ve=I==null?void 0:I.onError)==null||Ve.call(I,ze)}}finally{try{await nt.cancel()}catch{}finally{(tt=nt.releaseLock)==null||tt.call(nt)}pt!==null&&typeof window<"u"&&window.cancelAnimationFrame(pt),clearInterval(zt)}}catch(Me){if(Me.name==="AbortError")te=te??"aborted";else{const Ke=Me.message||String(Me);te="error",O=Ke,d(Ke),(gt=I==null?void 0:I.onError)==null||gt.call(I,Ke),q||((at=I==null?void 0:I.onConnectionError)==null||at.call(I,Ke),q=!0)}}finally{const Me=k.current,Ke=j.current,je=F.current,qe=D.current,Be=te??(K.signal.aborted?"aborted":O?"error":"complete");try{(lt=I==null?void 0:I.onClosed)==null||lt.call(I,{reason:Be,lastSeq:Me,lastCheckpointId:Ke,lastCheckpointNs:je,lastStateHistory:qe,error:O})}catch(nt){console.warn("[use-chat] onClosed callback failed",nt)}l(!1),w(!1),T.current=null,k.current=0,x(0),A.current=null}})(),{close:()=>K.abort()}},[t,n,r,e.autoAppendAssistant]);return b.useEffect(()=>()=>{var z;S.current=!1,(z=T.current)==null||z.abort()},[]),{isStreaming:a,error:c,assistantText:f,assistantMessage:C,lastCheckpointId:p,lastSeq:g,connected:y,stream:Y,stop:W,clear:M,setToken:G}}const lb=["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 lb){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 cb(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 xu({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),[f,m]=b.useState(null),[p,v]=b.useState([]),[g,x]=b.useState(!1),[,y]=b.useState(null),[w,C]=b.useState(null),[E,T]=b.useState(!1),S=b.useRef(a),k=b.useRef(new Map);b.useEffect(()=>{S.current=a},[a]),b.useEffect(()=>{t!==void 0&&t!==S.current&&l(t)},[t]);const A=b.useCallback(async()=>{d(!0),m(null);try{const P=await e.listThreads();i(P??[])}catch(P){const I=String(P);m(I),n==null||n(I)}finally{d(!1)}},[e,n]),j=b.useCallback(async()=>{x(!0),y(null);try{const P=await e.listSharedThreads();v(P??[])}catch(P){const I=String(P);y(I),n==null||n(I)}finally{x(!1)}},[e,n]);b.useEffect(()=>{A()},[A]),b.useEffect(()=>{j()},[j]),b.useEffect(()=>{r==null||r(a)},[a,r]);const F=b.useCallback(async(P,I)=>{try{const K=await e.createThread(P,I);return l(K.threadId),await A(),K.threadId}catch(K){const te=String(K);return n==null||n(te),null}},[e,n,A]),D=b.useCallback(async P=>{const I=s;i(te=>te.filter(O=>O.threadId!==P));const K=new AbortController;k.current.set(P,K);try{await e.deleteThread(P),S.current===P&&(l(null),o==null||o())}catch(te){i(I);const O=String(te);n==null||n(O)}finally{k.current.delete(P)}},[e,o,n,s]),B=b.useCallback(async(P,I)=>{try{await e.updateThread(P,I),await A()}catch(K){n==null||n(String(K))}},[e,n,A]),G=b.useCallback(async(P,I)=>{T(!0),C("Sharing thread…");try{await e.shareThread(P,I),await j(),C("Shared successfully")}catch(K){const te=cb(K);throw n==null||n(te),C(`Failed to share: ${te}`),new Error(te)}finally{T(!1)}},[e,n,j]),M=b.useCallback(async(P,I)=>{try{await e.unshareThread(P,I),await j()}catch(K){const te=String(K);throw n==null||n(te),K}},[e,n,j]),W=b.useMemo(()=>({createThread:F,deleteThread:D,renameThread:B,refreshThreads:A,refreshSharedThreads:j,shareThread:G,unshareThread:M}),[F,D,B,A,j,G,M]),Y=b.useCallback(P=>{if(!(P!=null&&P.threadId))return;const I={threadId:P.threadId,title:P.title||`Thread ${P.threadId.slice(0,8)}`,project:P.project,createdAt:P.createdAt||new Date().toISOString(),updatedAt:P.updatedAt||new Date().toISOString(),messageCount:P.messageCount??1};i(K=>{let te=!1;const O=K.map(q=>q.threadId===I.threadId?(te=!0,console.debug("[useThreadsState] thread_info: updating existing thread",I.threadId),{...q,title:I.title??q.title,project:I.project??q.project,updatedAt:I.updatedAt??q.updatedAt,messageCount:I.messageCount??q.messageCount}):q);return te?O:(console.debug("[useThreadsState] thread_info: adding thread to list",I.threadId),[I,...K])})},[]),z=b.useCallback(()=>C(null),[]);return{threads:s,currentThreadId:a,currentThreadIdRef:S,setCurrentThreadId:l,isLoadingThreads:c,threadsError:f,sharedThreads:p,isLoadingSharedThreads:g,actions:W,addThreadFromEvent:Y,shareInFlight:E,shareStatus:w,clearShareStatus:z}}const vu=b.createContext(null);function bu({children:e,initialThreadId:t=null,onError:n,onThreadChange:r}){const{chatApi:o}=On(),{threads:s,currentThreadId:i,setCurrentThreadId:a,currentThreadIdRef:l,isLoadingThreads:c,threadsError:d,sharedThreads:f,isLoadingSharedThreads:m,actions:p,addThreadFromEvent:v,shareInFlight:g,shareStatus:x,clearShareStatus:y}=xu({api:o,initialThreadId:t,onError:n,onThreadChange:r}),w=b.useMemo(()=>({threads:s,currentThreadId:i,setCurrentThreadId:a,currentThreadIdRef:l,isLoading:c,error:d,sharedThreads:f,isLoadingSharedThreads:m,actions:p,shareInFlight:g,shareStatus:x,clearShareStatus:y,addThreadFromEvent:v}),[s,i,a,l,c,d,f,m,p,g,x,y,v]);return u.jsx(vu.Provider,{value:w,children:e})}function yr(){const e=b.useContext(vu);if(!e)throw new Error("useThreads must be used within a ThreadsProvider");return e}function er(e){const t=e==null?void 0:e.trim();if(!t||!(t.startsWith("{")||t.startsWith("[")))return null;try{return JSON.parse(t)}catch{const n=ub(t);if(n)try{return JSON.parse(n)}catch{return null}return null}}function ub(e){let t=!1,n="";for(const o of e){if(o==="\\"){n+=o,t=!t;continue}if(o==="'"&&!t){n+='"';continue}n+=o,t=!1}return n.replace(/\bTrue\b/g,"true").replace(/\bFalse\b/g,"false").replace(/\bNone\b/g,"null")}function Li(e){return!!(e&&typeof e=="object"&&(e.type==="file"||e.mimeType||e.filename||e.sourceType==="base64"))}function Sr(e){if(typeof e=="string")return e;if(e&&typeof e=="object"){if(Array.isArray(e)){const n=e.map(Sr).filter(r=>r!==void 0);if(!n.length){console.debug("[message-utils] sanitizeForDisplay - array emptied -> returning undefined",{originalLength:e.length});return}return n}if(Li(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=Sr(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 tr(e){if(typeof e=="string")return e;if(Li(e))return"";try{const t=Sr(e);return t===void 0?"":typeof t=="string"?t:JSON.stringify(t,null,2)}catch{return""}}function wu(e){return typeof e!="string"?!1:/^[\s\n]*[-*]\s|^[\s\n]*#+\s|```|^\s*\[.*\]\(|^>\s/.test(e)}function yu(e){const t=tr(e);return typeof e=="string"&&wu(e)?{content:e,isMarkdown:!0}:{content:t,isMarkdown:!1}}function nr(e){if(e==null)return e;if(typeof e=="string"){const t=e.trim();if(t.startsWith("{")||t.startsWith("[")){const n=er(t);if(n!==null)return nr(n)}return e}return typeof e=="object"&&!Array.isArray(e)&&e.content!==void 0?nr(e.content):e}function Su(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function Yo(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 $i(e){if(e==null)return null;const t=String(e).trim();return t.length>0?t:null}function Cu(e){const t=r=>{try{const o=Sr(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 Tu(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function Fi(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 ku(e){if(!e)return"image/png";const t=e.trim();return t?t.includes("/")?t:`image/${t}`:"image/png"}function Eu(e){const t=[],n=r=>{r&&r.trim()&&t.push(r.trim())};return e&&(n(e.plotId),n(e.artifactId)),t}function Iu({base64:e,url:t,formatHint:n,extras:r}){const o=typeof e=="string"&&e.length>0,s=ku(n),i=o?`data:${s};base64,${e}`:t,a=Eu(r),l=a.length?a.join(" / "):void 0,c=l?`${l} artifact`:"artifact image";return{src:i,alt:c,label:l}}function Nu(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 Iu({base64:t,url:n,formatHint:r,extras:{plotId:e.plotId,artifactId:e.artifactId}})}function Bi(e){var n;const t=(n=e.additionalKwargs)==null?void 0:n.toolProgress;return Array.isArray(t)?t:[]}function Cr(e){if(e==null)return e;if(typeof e=="string"){const t=e.trim(),n=er(t);return n!==null?Cr(n):t}if(Array.isArray(e))return e.map(t=>Cr(t));if(typeof e=="object"){const t=e.value;if(t!==void 0)return Cr(t)}return e}function Au(e){const t=Cr(e.value);return t===e.value?e:{...e,value:t}}const db={messages:[],assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,messagesStreamMeta:{},pendingInterrupt:null};function fb(e,t){var n;switch(t.type){case"reset":return{messages:Di(((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],assemblingId:null}}}return{...e,messages:[...e.messages,r],assemblingId:null}}case"seed":{const r=Di(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=Di(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 ju(e,t.payload.ev);case"batch":{const{events:r}=t.payload;return r.length?r.reduce((o,s)=>ju(o,s),e):e}default:return e}}function pb(e=[]){const[t,n]=b.useReducer(fb,{...db,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,f)=>n({type:"seed",payload:{messages:d,...f??{}}}),prepend:d=>n({type:"prepend",payload:{messages:d}}),pushUser:(d,f)=>n({type:"user_message",payload:{message:d,editingMessageId:f}}),onEvent:l}),[l]);return{state:t,dispatch:n,...c}}function ju(e,t){var n,r,o;if(t.type==="message.start"&&t.role==="assistant"){const s=t.id,i=gu(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 mb(e,t);if(t.type==="tool.progress")return gb(e,t);if(t.type==="tool.end")return xb(e,t);if(t.type==="message.delta"){const s=e.assemblingId??pu(e.messages);if(!s)return e;const i=e.messages,a=i.findIndex(T=>T.id===s&&T.role==="assistant");if(a===-1)return e;const l=i[a],c=e.messagesStreamMeta,d=c??{},f=d[s],m=f??{lastSeq:null,lastText:hu(l.content)},p=t.seq??null;if(p!==null&&typeof p=="number"&&typeof m.lastSeq=="number"&&p<=m.lastSeq)return console.debug("[MessageReducer] skipping delta - seq <= lastSeq",{seq:p,lastSeq:m.lastSeq}),e;const{newParts:v,newMeta:g,changed:x}=mu(l.content,t.delta,m,p);if(!x)return e;const y={...l,content:v},w=no(i,a,y),C=!f||f.lastSeq!==g.lastSeq||f.lastText!==g.lastText,E=C?{...d,[s]:g}:c;return C?{...e,messages:w,messagesStreamMeta:E}:{...e,messages:w}}if(t.type==="message.end"){const s=e.assemblingId??pu(e.messages);if(!s)return{...e,assemblingId:null};const i=e.messages,a=i.findIndex(l=>l.id===s&&l.role==="assistant");if(a>=0){const l=i[a];if(!((n=l.content)==null?void 0:n.some(d=>{var f;return(d==null?void 0:d.type)==="text"&&((f=d.text)==null?void 0:f.trim())}))){console.debug("[MessageReducer] pruning assistant message with no visible text",{id:l.id,contentTypes:(r=l.content)==null?void 0:r.map(f=>f==null?void 0:f.type),contentPreview:(o=l.content)==null?void 0:o.map(f=>(f==null?void 0:f.type)==="text"?String(f.text).slice(0,100):f==null?void 0:f.type)});const d=[...i.slice(0,a),...i.slice(a+1)];return{...e,assemblingId:null,messages:d}}}return console.log("[MessageReducer] message.end - clearing assemblingId",{wasId:e.assemblingId}),{...e,assemblingId:null}}if(t.type==="checkpoint"){const s=t.checkpointNs??e.lastCheckpointNs??null,i=ib(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=Xn(t),i=s.interrupt,a=s.latest,l=i===null?rb(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 zi(e){return e.call_id??e.id??null}function Pu(e){return e.id??e.call_id??`tool-${Date.now()}-${Math.random().toString(16).slice(2)}`}function _u(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 Hi(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||Yo(r).toolCallId===t)return n}return-1}function hb(e){if(e==null)return[];const t=nr(e);if(typeof t=="string"&&t.trim())return[{type:"text",text:t}];const n=tr(t??e);return n?[{type:"text",text:n}]:[]}function Ru(e,t){const n=e.additionalKwargs??{},r=Array.isArray(n.toolProgress)?[...n.toolProgress]:[],o={...n,toolProgress:[...r,t]};return{...e,additionalKwargs:o}}function mb(e,t){const n=zi(t),r=Hi(e.messages,n),o=t.name??t.tool??void 0,s=Pu(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:no(e.messages,r,d)}}const i=_u(s,n,o,t.args);return{...e,messages:[...e.messages,i]}}function gb(e,t){const n=zi(t);if(!n)return e;const r=Hi(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=Ru(e.messages[r],o);return{...e,messages:no(e.messages,r,a)}}function xb(e,t){const n=zi(t),r=Pu(t);let o=e.messages,s=Hi(o,n);if(s===-1){const v=t.name??t.tool??void 0;o=[...o,_u(r,n,v,{})],s=o.length-1}const i=o[s],a=t.output??t.error??null,l=hb(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 f=Ru(i,d),m=t.artifact??i.artifact,p={...f,name:t.name??t.tool??i.name,content:c,artifact:m,additionalKwargs:{...f.additionalKwargs??{},toolStreaming:!1}};return{...e,messages:no(o,s,p)}}function Mu({api:e,seed:t,onError:n,currentThreadId:r,initialThreadId:o=null,initialCheckpointId:s=null,initialCheckpointNs:i=null,autoLoadInitial:a=!0,isStreaming:l,getMessages:c}){const[d,f]=b.useState(null),p=b.useMemo(()=>Xn(d),[d]).checkpoints,v=dc(p),g=v.timeline,[x,y]=b.useState(!1),[w,C]=b.useState(!1),[E,T]=b.useState(null),S=b.useRef(r),k=b.useRef(null),A=b.useRef(null),j=b.useRef(null),F=b.useRef(null),D=b.useRef(null),B=b.useRef(new Map),G=b.useRef(null);b.useEffect(()=>{S.current=r},[r]);const M=b.useCallback(async L=>{var X,R;if(!L.threadId)return;const $=L.threadId;(X=L.onStart)==null||X.call(L),L.setLoading(!0);try{await L.action($)}catch(_){if(!tu(_)&&S.current===$){const Z=String(_);(R=L.handleError)==null||R.call(L,Z),n==null||n(Z)}throw _}finally{L.setLoading(!1)}},[n]),W=b.useCallback(async(L,$)=>{var Z;if(!L)return;const X=`${L}:${$??"latest"}`,R=B.current.get(X);if(R)return R;(Z=G.current)==null||Z.abort();const _=new AbortController;G.current=_;const U=M({threadId:L,setLoading:y,onStart:()=>T(null),handleError:re=>T(re),action:async re=>{const ce=await e.getStateHistory({threadId:re,checkpointId:$??void 0,signal:_.signal});if(S.current!==re){console.log(`[useThreadHistoryState] Thread changed during load (was ${re}, now ${S.current}), discarding stale data`);return}const{checkpoints:Ne}=Xn(ce),ye=Ne.find(Re=>Re.messages&&Re.messages.length>0)??($?Ne.find(Re=>Re.checkpointId===$):null)??Ne[0];t((ye==null?void 0:ye.messages)??[],{checkpointId:(ye==null?void 0:ye.checkpointId)??null,checkpointNs:(ye==null?void 0:ye.checkpointNs)??null,pendingInterrupt:(ye==null?void 0:ye.interrupt)??null}),f(ce)}});B.current.set(X,U);try{await U}finally{B.current.delete(X),G.current===_&&(G.current=null)}return S.current===L&&(D.current=X),U},[e,t,M]),Y=b.useCallback(async(L,$)=>{F.current=L;try{await W(L,$)}catch(X){if(!tu(X))throw X}finally{F.current===L&&(F.current=null)}},[W]),z=b.useCallback(L=>{A.current=L},[]),P=b.useCallback(L=>{j.current=L},[]),I=b.useCallback(L=>{const $=L.threadId??S.current;if(!$||S.current&&S.current!==$)return;const{checkpoints:X}=Xn(L);if(!X.length)return;const R=X.find(U=>U.messages&&U.messages.length>0)??X.find(U=>!!U.checkpointId)??X[0],_=j.current===$;!l&&!_&&t((R==null?void 0:R.messages)??[],{checkpointId:(R==null?void 0:R.checkpointId)??null,checkpointNs:(R==null?void 0:R.checkpointNs)??null,pendingInterrupt:(R==null?void 0:R.interrupt)??null}),f(L),D.current=`${$}:latest`,A.current=null,j.current===$&&(j.current=null)},[t,l]),K=b.useCallback(async(L,$)=>{const X=S.current;await M({threadId:X,setLoading:C,action:async R=>{const _=await e.getStateHistory({threadId:R,checkpointId:L,checkpointNs:$??void 0});if(S.current!==R)return;const{checkpoints:U}=Xn(_),Z=U.find(re=>re.checkpointId===L&&($?re.checkpointNs===$:!0));if(!Z){console.warn("[useThreadHistoryState] Requested checkpoint not found:",{checkpointId:L,checkpointNs:$});return}f(_),t(Z.messages??[],{checkpointId:Z.checkpointId??null,checkpointNs:Z.checkpointNs??null})}}).catch(()=>{})},[e,t,M]),te=b.useCallback((L,$)=>{t(c(),{checkpointId:L??null,checkpointNs:$??null})},[c,t]),O=b.useCallback(async()=>{S.current&&await Y(S.current)},[Y]);b.useEffect(()=>{if(!a||!r||x||l)return;if(A.current===r){A.current=null,k.current=r;return}if(j.current===r){k.current=r;return}if(F.current===r){F.current=null,k.current=r;return}if(k.current===r)return;k.current=r;let L;const $=`${r}:latest`;D.current!==$&&Y(r,L)},[a,r,s,i,o,x,l,Y]);const q=b.useCallback(()=>{f(null),y(!1),C(!1),T(null),A.current=null,j.current=null,k.current=null,D.current=null,F.current=null},[]);return{threadCheckpoints:p,threadTimeline:g,checkpointIndex:v,isLoadingThread:x,isLoadingCheckpoint:w,threadStateError:E,loadThread:Y,navigateToCheckpoint:K,setCurrentCheckpointId:te,returnToLatest:O,handleStateHistoryEvent:I,markSkipNextLoad:z,markStreamPendingThread:P,resetHistoryState:q}}const Ou=b.createContext(null),Du=b.createContext(null);function ro(){const e=b.useContext(Ou);if(!e)throw new Error("useThreadState must be used within a ThreadStateProvider");return e}function Lu(){const e=b.useContext(Du);if(!e)throw new Error("useThreadStateUpdater must be used within a ThreadStateProvider");return e}function $u({children:e,initialThreadId:t=null,initialCheckpointId:n=null,initialCheckpointNs:r=null,autoLoadInitial:o=!0,isStreaming:s,onError:i}){const{chatApi:a}=On(),{currentThreadId:l}=yr(),{state:c,seed:d,pushUser:f,onEvent:m}=pb(),{threadCheckpoints:p,threadTimeline:v,checkpointIndex:g,isLoadingThread:x,isLoadingCheckpoint:y,threadStateError:w,loadThread:C,navigateToCheckpoint:E,setCurrentCheckpointId:T,returnToLatest:S,handleStateHistoryEvent:k,markSkipNextLoad:A,markStreamPendingThread:j,resetHistoryState:F}=Mu({api:a,seed:d,onError:i,currentThreadId:l,initialThreadId:t,initialCheckpointId:n,initialCheckpointNs:r,autoLoadInitial:o,isStreaming:s,getMessages:b.useCallback(()=>c.messages,[c.messages])}),[D,B]=b.useState(()=>async()=>{throw new Error("clearThread is not ready")}),[G,M]=b.useState(()=>async()=>{throw new Error("respondToInterrupt is not ready")});b.useEffect(()=>{l||(d([],{}),F())},[l,d,F]);const W=b.useCallback(K=>B(()=>K),[]),Y=b.useCallback(K=>M(()=>K),[]),z=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:p,checkpointIndex:g,timelineCheckpoints:v,metadata:z,isLoading:x,isLoadingCheckpoint:y,error:w,clearState:D,navigateToCheckpoint:E,setCurrentCheckpointId:T,returnToLatest:S,loadThread:C,clearThread:D,respondToInterrupt:G,messagePreviews:g.messagePreviews,handleStateHistoryEvent:k,markSkipNextLoad:A,markStreamPendingThread:j,resetHistoryState:F,pushUser:f,onEvent:m}),[l,c,p,v,g,z,x,y,w,D,E,T,S,C,G,g.messagePreviews,k,A,j,F,f,m]),I=b.useMemo(()=>({registerClearThread:W,registerRespondToInterrupt:Y}),[W,Y]);return u.jsx(Du.Provider,{value:I,children:u.jsx(Ou.Provider,{value:P,children:e})})}function Fu(e,t){if(!e)return null;const n=Pn(e);if(!n)return null;const r=Pn(n.configurable)??n;return _n(r,t)??null}function vb(e){const t=Fu(e,["checkpoint_id","checkpointId"]);if(!t)return null;const n=Fu(e,["checkpoint_ns","checkpointNs"]);return{checkpointId:t,checkpointNs:n}}function bb(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 wb(e,t){const n=[...e].sort(bb);for(const r of n){if(r.messageId!==t)continue;const o=vb(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 Bu=b.createContext(null),zu=b.createContext(!1);function yb({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{chatApi:d,baseUrl:f}=On(),m=f,{stream:p,stop:v,isStreaming:g,error:x,setToken:y}=ab({baseUrl:m}),[w,C]=b.useState(!1);return b.useEffect(()=>{C(g)},[g]),u.jsx(bu,{initialThreadId:t,onError:s,onThreadChange:a,children:u.jsx($u,{initialThreadId:t,initialCheckpointId:n,initialCheckpointNs:r,autoLoadInitial:o,onError:s,isStreaming:w,children:u.jsx(zu.Provider,{value:!0,children:u.jsx(Sb,{api:d,streamApi:{stream:p,stop:v,isStreaming:g,error:x,setToken:y},onError:s,onAuthError:i,onConnectionError:l,onToolEnd:c,children:e})})})})}function Sb({children:e,api:t,streamApi:n,onError:r,onAuthError:o,onConnectionError:s,onToolEnd:i}){const{stream:a,stop:l,isStreaming:c,error:d,setToken:f}=n,{setCurrentThreadId:m,currentThreadIdRef:p,addThreadFromEvent:v}=yr(),{checkpoint:g,timelineCheckpoints:x,handleStateHistoryEvent:y,markSkipNextLoad:w,markStreamPendingThread:C,resetHistoryState:E,pushUser:T,onEvent:S}=ro(),{registerClearThread:k,registerRespondToInterrupt:A}=Lu(),j=b.useCallback(z=>{v(z),p.current!==z.threadId&&((z.created??!p.current)&&w(z.threadId),C(z.threadId),m(z.threadId))},[v,w,C,m,p]),F=b.useCallback(z=>{z.type==="thread_info"?j(z):z.type==="state_history"?y(z):z.type==="tool.end"?(S(z),i==null||i(z)):S(z)},[j,y,S,i]),D=b.useCallback(z=>{a(z,F,{onError:P=>{console.error("[StreamingProvider] Stream error:",P),r==null||r(P)},onAuthError:P=>{console.error("[StreamingProvider] Auth error:",P),o==null||o(P)},onConnectionError:P=>{console.error("[StreamingProvider] Connection error:",P),s==null||s(P)}})},[a,F,r,o,s]),B=b.useRef(g);b.useEffect(()=>{B.current=g},[g]);const G=b.useCallback(async(z,P,I)=>{const K=p.current;if(!K)throw new Error("No active thread to handle interrupt");const te=z?P??!0:!1,O=B.current,q={threadId:K,checkpointId:O.id??void 0,checkpointNs:O.namespace??void 0,command:{kind:"resume",value:te},payload:I==null?void 0:I.payload,config:I==null?void 0:I.config,nodeFilter:I==null?void 0:I.nodeFilter,branchLabel:I==null?void 0:I.branchLabel,timelineCheckpoints:I==null?void 0:I.timelineCheckpoints};D(q)},[p,D]);b.useEffect(()=>{A(G)},[G,A]);const M=b.useCallback(async()=>{l(),E(),m(null)},[E,m,l]);b.useEffect(()=>{k(M)},[M,k]);const W=b.useCallback(async(z,P)=>{c&&l();let I=p.current;const K=(z==null?void 0:z.text)??"",te=(z==null?void 0:z.attachments)??[],O=(K==null?void 0:K.trim())??"",q={...(z==null?void 0:z.payload)??{}},L=Array.isArray(q.messages)?q.messages:void 0;L&&delete q.messages;const $=!!(L&&L.length),X=!!(z.contentParts&&z.contentParts.length>0);if(!I&&!O&&te.length===0&&!$&&!X)return;if(!I){const tt=Math.floor(Date.now()/1e3).toString(16).padStart(8,"0"),gt=Array.from({length:4},()=>Math.floor(Math.random()*4294967295).toString(16).padStart(8,"0")).join("").slice(0,16);I=`${tt}${gt}`,w(I),m(I)}let R=null;z.contentParts&&z.contentParts.length>0&&(R=z.contentParts);const{contentParts:_,filesInfo:U}=R?{contentParts:R,filesInfo:[]}:await du(te),Z=[..._];O&&Z.push({type:"text",text:K});const re=P==null?void 0:P.originalMessageId,ce=!!(P!=null&&P.edit&&re),Ne=!$&&Z.length>0;let ye=null;Ne&&(ye={id:ce?re:`msg-${Date.now()}`,role:"user",content:Z,createdAt:new Date().toISOString()},ce?T(ye,re):T(ye));const Re=$?L:ye?[ye]:[],We={...q,...U.length?{files_info:U}:{}};Re.length?We.messages=Re:"messages"in We||(We.messages=[]);let Fe=(P==null?void 0:P.checkpointId)??g.id??void 0,Ye=(P==null?void 0:P.checkpointNs)??g.namespace??void 0;if(ce&&re){const tt=wb(x,re);Fe=tt.checkpointId,Ye=tt.checkpointNs??void 0}const Ve={threadId:I,payload:We,checkpointId:Fe,checkpointNs:Ye,config:P==null?void 0:P.config,edit:!!(P!=null&&P.edit)};D(Ve)},[g,p,c,w,T,D,l,x]),Y=b.useMemo(()=>({isStreaming:c,error:d,connectionState:c?"connected":"idle",submit:W,send:W,stop:l,setAuthToken:f}),[c,d,W,l,f]);return u.jsx(Bu.Provider,{value:Y,children:e})}function Ui(){const e=b.useContext(Bu);if(!e)throw new Error("useStream must be used within StreamingProvider");return e}function Cb(){return b.useContext(zu)}function Hu(e){return typeof e=="object"&&e!==null}function Tb(e,t){if(Object.is(e,t))return!0;if(!Hu(e)||!Hu(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 Uu(e){const t=b.useRef(e),n=b.useRef(e);return Tb(t.current,e)||(t.current=e,n.current=e),n.current}function Tr({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 f=Uu(t),m=oo(a),p=oo(l),v=oo(i),g=oo(c),x=oo(d),y=b.useMemo(()=>({initialThreadId:n,initialCheckpointId:r,initialCheckpointNs:o,autoLoadInitial:s,onError:m,onAuthError:p,onConnectionError:v,onThreadChange:g,onToolEnd:x}),[n,r,o,s,m,p,v,g,x]);return u.jsx(cu,{apiConfig:f,children:u.jsx(yb,{...y,children:e})})}function oo(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 kr(e){if(!(typeof globalThis>"u"))return globalThis[e]}function Wu(){const e=[kr("__API_BASE_URL__"),kr("__CHAT_API_BASE_URL__"),kr("__CHAT_API_URL__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim().replace(/\/+$/,"")}function Vu(){const e=[kr("__API_AUTH_TOKEN__"),kr("__CHAT_API_KEY__"),kr("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function Ku(...e){for(const t of e)if(typeof t=="string"&&t.trim())return t.trim().replace(/\/+$/,"");return""}function qu(){const e={},t=Wu(),n=Vu();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function Gu(){const e=qu(),t=Mn.getAuthToken(),n=Wu();return{apiBaseUrl:Ku(e.baseUrl,n),apiKey:t||e.apiKey||Vu()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,darkMode:!1,enableSound:!1,messageHistory:100}}const Wi="chat-settings";function Yu(){try{const e=localStorage.getItem(Wi);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function Xu(e){try{const t={...e,apiBaseUrl:e.apiBaseUrl.trim().replace(/\/+$/,"")};localStorage.setItem(Wi,JSON.stringify(t)),t.apiKey&&Mn.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function kb(){const e=Gu(),t=Yu(),n=Mn.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:Ku(Mn.baseUrl,r,e.apiBaseUrl)}}function Eb(e){Mn.updateConfig({baseUrl:e.apiBaseUrl,apiKey:e.apiKey??void 0}),Xu(e)}function oe(...e){return bx.twMerge(vx.clsx(e))}const Ib=Kr.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=h.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?Jt.Slot:"button";return u.jsx(i,{className:oe(Ib({variant:t,size:n,className:e})),ref:s,...o})});Xe.displayName="Button";function ue(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 Ju(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Dn(...e){return t=>{let n=!1;const r=e.map(o=>{const s=Ju(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():Ju(e[o],null)}}}}function Le(...e){return h.useCallback(Dn(...e),e)}function Nb(e,t){const n=h.createContext(t),r=s=>{const{children:i,...a}=s,l=h.useMemo(()=>a,Object.values(a));return u.jsx(n.Provider,{value:l,children:i})};r.displayName=e+"Provider";function o(s){const i=h.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 nn(e,t=[]){let n=[];function r(s,i){const a=h.createContext(i),l=n.length;n=[...n,i];const c=f=>{var y;const{scope:m,children:p,...v}=f,g=((y=m==null?void 0:m[e])==null?void 0:y[l])||a,x=h.useMemo(()=>v,Object.values(v));return u.jsx(g.Provider,{value:x,children:p})};c.displayName=s+"Provider";function d(f,m){var g;const p=((g=m==null?void 0:m[e])==null?void 0:g[l])||a,v=h.useContext(p);if(v)return v;if(i!==void 0)return i;throw new Error(`\`${f}\` must be used within \`${s}\``)}return[c,d]}const o=()=>{const s=n.map(i=>h.createContext(i));return function(a){const l=(a==null?void 0:a[e])||s;return h.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return o.scopeName=e,[r,Ab(o,...t)]}function Ab(...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 f=l(s)[`__scope${c}`];return{...a,...f}},{});return h.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var It=globalThis!=null&&globalThis.document?h.useLayoutEffect:()=>{},jb=h[" useId ".trim().toString()]||(()=>{}),Pb=0;function jt(e){const[t,n]=h.useState(jb());return It(()=>{n(r=>r??String(Pb++))},[e]),e||(t?`radix-${t}`:"")}var _b=h[" useInsertionEffect ".trim().toString()]||It;function In({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=Rb({defaultProp:t,onChange:n}),a=e!==void 0,l=a?e:o;{const d=h.useRef(e!==void 0);h.useEffect(()=>{const f=d.current;f!==a&&console.warn(`${r} is changing from ${f?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),d.current=a},[a,r])}const c=h.useCallback(d=>{var f;if(a){const m=Mb(d)?d(e):d;m!==e&&((f=i.current)==null||f.call(i,m))}else s(d)},[a,e,s,i]);return[l,c]}function Rb({defaultProp:e,onChange:t}){const[n,r]=h.useState(e),o=h.useRef(n),s=h.useRef(t);return _b(()=>{s.current=t},[t]),h.useEffect(()=>{var i;o.current!==n&&((i=s.current)==null||i.call(s,n),o.current=n)},[n,o]),[n,r,s]}function Mb(e){return typeof e=="function"}var Ob=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],he=Ob.reduce((e,t)=>{const n=Jt.createSlot(`Primitive.${t}`),r=h.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 Vi(e,t){e&&qr.flushSync(()=>e.dispatchEvent(t))}function bt(e){const t=h.useRef(e);return h.useEffect(()=>{t.current=e}),h.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function Db(e,t=globalThis==null?void 0:globalThis.document){const n=bt(e);h.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 Lb="DismissableLayer",Ki="dismissableLayer.update",$b="dismissableLayer.pointerDownOutside",Fb="dismissableLayer.focusOutside",Zu,Qu=h.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Er=h.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...l}=e,c=h.useContext(Qu),[d,f]=h.useState(null),m=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,p]=h.useState({}),v=Le(t,k=>f(k)),g=Array.from(c.layers),[x]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),y=g.indexOf(x),w=d?g.indexOf(d):-1,C=c.layersWithOutsidePointerEventsDisabled.size>0,E=w>=y,T=zb(k=>{const A=k.target,j=[...c.branches].some(F=>F.contains(A));!E||j||(o==null||o(k),i==null||i(k),k.defaultPrevented||a==null||a())},m),S=Hb(k=>{const A=k.target;[...c.branches].some(F=>F.contains(A))||(s==null||s(k),i==null||i(k),k.defaultPrevented||a==null||a())},m);return Db(k=>{w===c.layers.size-1&&(r==null||r(k),!k.defaultPrevented&&a&&(k.preventDefault(),a()))},m),h.useEffect(()=>{if(d)return n&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(Zu=m.body.style.pointerEvents,m.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(d)),c.layers.add(d),td(),()=>{n&&c.layersWithOutsidePointerEventsDisabled.size===1&&(m.body.style.pointerEvents=Zu)}},[d,m,n,c]),h.useEffect(()=>()=>{d&&(c.layers.delete(d),c.layersWithOutsidePointerEventsDisabled.delete(d),td())},[d,c]),h.useEffect(()=>{const k=()=>p({});return document.addEventListener(Ki,k),()=>document.removeEventListener(Ki,k)},[]),u.jsx(he.div,{...l,ref:v,style:{pointerEvents:C?E?"auto":"none":void 0,...e.style},onFocusCapture:ue(e.onFocusCapture,S.onFocusCapture),onBlurCapture:ue(e.onBlurCapture,S.onBlurCapture),onPointerDownCapture:ue(e.onPointerDownCapture,T.onPointerDownCapture)})});Er.displayName=Lb;var Bb="DismissableLayerBranch",ed=h.forwardRef((e,t)=>{const n=h.useContext(Qu),r=h.useRef(null),o=Le(t,r);return h.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),u.jsx(he.div,{...e,ref:o})});ed.displayName=Bb;function zb(e,t=globalThis==null?void 0:globalThis.document){const n=bt(e),r=h.useRef(!1),o=h.useRef(()=>{});return h.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){nd($b,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 Hb(e,t=globalThis==null?void 0:globalThis.document){const n=bt(e),r=h.useRef(!1);return h.useEffect(()=>{const o=s=>{s.target&&!r.current&&nd(Fb,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 td(){const e=new CustomEvent(Ki);document.dispatchEvent(e)}function nd(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?Vi(o,s):o.dispatchEvent(s)}var Ub=Er,Wb=ed,qi="focusScope.autoFocusOnMount",Gi="focusScope.autoFocusOnUnmount",rd={bubbles:!1,cancelable:!0},Vb="FocusScope",Xo=h.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,l]=h.useState(null),c=bt(o),d=bt(s),f=h.useRef(null),m=Le(t,g=>l(g)),p=h.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;h.useEffect(()=>{if(r){let g=function(C){if(p.paused||!a)return;const E=C.target;a.contains(E)?f.current=E:Ln(f.current,{select:!0})},x=function(C){if(p.paused||!a)return;const E=C.relatedTarget;E!==null&&(a.contains(E)||Ln(f.current,{select:!0}))},y=function(C){if(document.activeElement===document.body)for(const T of C)T.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,p.paused]),h.useEffect(()=>{if(a){id.add(p);const g=document.activeElement;if(!a.contains(g)){const y=new CustomEvent(qi,rd);a.addEventListener(qi,c),a.dispatchEvent(y),y.defaultPrevented||(Kb(Jb(od(a)),{select:!0}),document.activeElement===g&&Ln(a))}return()=>{a.removeEventListener(qi,c),setTimeout(()=>{const y=new CustomEvent(Gi,rd);a.addEventListener(Gi,d),a.dispatchEvent(y),y.defaultPrevented||Ln(g??document.body,{select:!0}),a.removeEventListener(Gi,d),id.remove(p)},0)}}},[a,c,d,p]);const v=h.useCallback(g=>{if(!n&&!r||p.paused)return;const x=g.key==="Tab"&&!g.altKey&&!g.ctrlKey&&!g.metaKey,y=document.activeElement;if(x&&y){const w=g.currentTarget,[C,E]=qb(w);C&&E?!g.shiftKey&&y===E?(g.preventDefault(),n&&Ln(C,{select:!0})):g.shiftKey&&y===C&&(g.preventDefault(),n&&Ln(E,{select:!0})):y===w&&g.preventDefault()}},[n,r,p.paused]);return u.jsx(he.div,{tabIndex:-1,...i,ref:m,onKeyDown:v})});Xo.displayName=Vb;function Kb(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Ln(r,{select:t}),document.activeElement!==n)return}function qb(e){const t=od(e),n=sd(t,e),r=sd(t.reverse(),e);return[n,r]}function od(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 sd(e,t){for(const n of e)if(!Gb(n,{upTo:t}))return n}function Gb(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 Yb(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&&Yb(e)&&t&&e.select()}}var id=Xb();function Xb(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=ad(e,t),e.unshift(t)},remove(t){var n;e=ad(e,t),(n=e[0])==null||n.resume()}}}function ad(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Jb(e){return e.filter(t=>t.tagName!=="A")}var Zb="Portal",so=h.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=h.useState(!1);It(()=>s(!0),[]);const i=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?Do.createPortal(u.jsx(he.div,{...r,ref:t}),i):null});so.displayName=Zb;function Qb(e,t){return h.useReducer((n,r)=>t[n][r]??n,e)}var $t=e=>{const{present:t,children:n}=e,r=ew(t),o=typeof n=="function"?n({present:r.isPresent}):h.Children.only(n),s=Le(r.ref,tw(o));return typeof n=="function"||r.isPresent?h.cloneElement(o,{ref:s}):null};$t.displayName="Presence";function ew(e){const[t,n]=h.useState(),r=h.useRef(null),o=h.useRef(e),s=h.useRef("none"),i=e?"mounted":"unmounted",[a,l]=Qb(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return h.useEffect(()=>{const c=Jo(r.current);s.current=a==="mounted"?c:"none"},[a]),It(()=>{const c=r.current,d=o.current;if(d!==e){const m=s.current,p=Jo(c);e?l("MOUNT"):p==="none"||(c==null?void 0:c.display)==="none"?l("UNMOUNT"):l(d&&m!==p?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,l]),It(()=>{if(t){let c;const d=t.ownerDocument.defaultView??window,f=p=>{const g=Jo(r.current).includes(CSS.escape(p.animationName));if(p.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=p=>{p.target===t&&(s.current=Jo(r.current))};return t.addEventListener("animationstart",m),t.addEventListener("animationcancel",f),t.addEventListener("animationend",f),()=>{d.clearTimeout(c),t.removeEventListener("animationstart",m),t.removeEventListener("animationcancel",f),t.removeEventListener("animationend",f)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:h.useCallback(c=>{r.current=c?getComputedStyle(c):null,n(c)},[])}}function Jo(e){return(e==null?void 0:e.animationName)||"none"}function tw(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 Yi=0;function Xi(){h.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??ld()),document.body.insertAdjacentElement("beforeend",e[1]??ld()),Yi++,()=>{Yi===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Yi--}},[])}function ld(){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 vn=function(){return vn=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},vn.apply(this,arguments)};function cd(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 nw(e,t,n){if(n||arguments.length===2)for(var r=0,o=t.length,s;r<o;r++)(s||!(r in t))&&(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return e.concat(s||Array.prototype.slice.call(t))}typeof SuppressedError=="function"&&SuppressedError;var Zo="right-scroll-bar-position",Qo="width-before-scroll-bar",rw="with-scroll-bars-hidden",ow="--removed-body-scroll-bar-size";function Ji(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function sw(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 iw=typeof window<"u"?h.useLayoutEffect:h.useEffect,ud=new WeakMap;function aw(e,t){var n=sw(null,function(r){return e.forEach(function(o){return Ji(o,r)})});return iw(function(){var r=ud.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||Ji(a,null)}),s.forEach(function(a){o.has(a)||Ji(a,i)})}ud.set(n,e)},[e]),n}function lw(e){return e}function cw(e,t){t===void 0&&(t=lw);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 uw(e){e===void 0&&(e={});var t=cw(null);return t.options=vn({async:!0,ssr:!1},e),t}var dd=function(e){var t=e.sideCar,n=cd(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 h.createElement(r,vn({},n))};dd.isSideCarExport=!0;function dw(e,t){return e.useMedium(t),dd}var fd=uw(),Zi=function(){},es=h.forwardRef(function(e,t){var n=h.useRef(null),r=h.useState({onScrollCapture:Zi,onWheelCapture:Zi,onTouchMoveCapture:Zi}),o=r[0],s=r[1],i=e.forwardProps,a=e.children,l=e.className,c=e.removeScrollBar,d=e.enabled,f=e.shards,m=e.sideCar,p=e.noRelative,v=e.noIsolation,g=e.inert,x=e.allowPinchZoom,y=e.as,w=y===void 0?"div":y,C=e.gapMode,E=cd(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),T=m,S=aw([n,t]),k=vn(vn({},E),o);return h.createElement(h.Fragment,null,d&&h.createElement(T,{sideCar:fd,removeScrollBar:c,shards:f,noRelative:p,noIsolation:v,inert:g,setCallbacks:s,allowPinchZoom:!!x,lockRef:n,gapMode:C}),i?h.cloneElement(h.Children.only(a),vn(vn({},k),{ref:S})):h.createElement(w,vn({},k,{className:l,ref:S}),a))});es.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},es.classNames={fullWidth:Qo,zeroRight:Zo};var fw=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function pw(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=fw();return t&&e.setAttribute("nonce",t),e}function hw(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function mw(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var gw=function(){var e=0,t=null;return{add:function(n){e==0&&(t=pw())&&(hw(t,n),mw(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},xw=function(){var e=gw();return function(t,n){h.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},pd=function(){var e=xw(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},vw={left:0,top:0,right:0,gap:0},Qi=function(e){return parseInt(e||"",10)||0},bw=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[Qi(n),Qi(r),Qi(o)]},ww=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return vw;var t=bw(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])}},yw=pd(),Ir="data-scroll-locked",Sw=function(e,t,n,r){var o=e.left,s=e.top,i=e.right,a=e.gap;return n===void 0&&(n="margin"),`
|
|
40
40
|
.`.concat(rw,` {
|
|
41
41
|
overflow: hidden `).concat(r,`;
|
|
42
42
|
padding-right: `).concat(a,"px ").concat(r,`;
|
|
@@ -76,11 +76,11 @@ React keys must be passed directly to JSX without using spread:
|
|
|
76
76
|
`)},hd=function(){var e=parseInt(document.body.getAttribute(Ir)||"0",10);return isFinite(e)?e:0},Cw=function(){h.useEffect(function(){return document.body.setAttribute(Ir,(hd()+1).toString()),function(){var e=hd()-1;e<=0?document.body.removeAttribute(Ir):document.body.setAttribute(Ir,e.toString())}},[])},Tw=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;Cw();var s=h.useMemo(function(){return ww(o)},[o]);return h.createElement(yw,{styles:Sw(s,!t,o,n?"":"!important")})},ea=!1;if(typeof window<"u")try{var ts=Object.defineProperty({},"passive",{get:function(){return ea=!0,!0}});window.addEventListener("test",ts,ts),window.removeEventListener("test",ts,ts)}catch{ea=!1}var Nr=ea?{passive:!1}:!1,kw=function(e){return e.tagName==="TEXTAREA"},md=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!kw(e)&&n[t]==="visible")},Ew=function(e){return md(e,"overflowY")},Iw=function(e){return md(e,"overflowX")},gd=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=xd(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},Nw=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},Aw=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},xd=function(e,t){return e==="v"?Ew(t):Iw(t)},vd=function(e,t){return e==="v"?Nw(t):Aw(t)},jw=function(e,t){return e==="h"&&t==="rtl"?-1:1},Pw=function(e,t,n,r,o){var s=jw(e,window.getComputedStyle(t).direction),i=s*r,a=n.target,l=t.contains(a),c=!1,d=i>0,f=0,m=0;do{if(!a)break;var p=vd(e,a),v=p[0],g=p[1],x=p[2],y=g-x-s*v;(v||y)&&xd(e,a)&&(f+=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(f)<1||!d&&Math.abs(m)<1)&&(c=!0),c},ns=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},bd=function(e){return[e.deltaX,e.deltaY]},wd=function(e){return e&&"current"in e?e.current:e},_w=function(e,t){return e[0]===t[0]&&e[1]===t[1]},Rw=function(e){return`
|
|
77
77
|
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
78
78
|
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
79
|
-
`)},Mw=0,Ar=[];function Ow(e){var t=h.useRef([]),n=h.useRef([0,0]),r=h.useRef(),o=h.useState(Mw++)[0],s=h.useState(pd)[0],i=h.useRef(e);h.useEffect(function(){i.current=e},[e]),h.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var g=nw([e.lockRef.current],(e.shards||[]).map(wd),!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=h.useCallback(function(g,x){if("touches"in g&&g.touches.length===2||g.type==="wheel"&&g.ctrlKey)return!i.current.allowPinchZoom;var y=ns(g),w=n.current,C="deltaX"in g?g.deltaX:w[0]-y[0],E="deltaY"in g?g.deltaY:w[1]-y[1],T,S=g.target,k=Math.abs(C)>Math.abs(E)?"h":"v";if("touches"in g&&k==="h"&&S.type==="range")return!1;var A=gd(k,S);if(!A)return!0;if(A?T=k:(T=k==="v"?"h":"v",A=gd(k,S)),!A)return!1;if(!r.current&&"changedTouches"in g&&(C||E)&&(r.current=T),!T)return!0;var j=r.current||T;return Pw(j,x,g,j==="h"?C:E)},[]),l=h.useCallback(function(g){var x=g;if(!(!Ar.length||Ar[Ar.length-1]!==s)){var y="deltaY"in x?bd(x):ns(x),w=t.current.filter(function(T){return T.name===x.type&&(T.target===x.target||x.target===T.shadowParent)&&_w(T.delta,y)})[0];if(w&&w.should){x.cancelable&&x.preventDefault();return}if(!w){var C=(i.current.shards||[]).map(wd).filter(Boolean).filter(function(T){return T.contains(x.target)}),E=C.length>0?a(x,C[0]):!i.current.noIsolation;E&&x.cancelable&&x.preventDefault()}}},[]),c=h.useCallback(function(g,x,y,w){var C={name:g,delta:x,target:y,should:w,shadowParent:Dw(y)};t.current.push(C),setTimeout(function(){t.current=t.current.filter(function(E){return E!==C})},1)},[]),d=h.useCallback(function(g){n.current=ns(g),r.current=void 0},[]),f=h.useCallback(function(g){c(g.type,bd(g),g.target,a(g,e.lockRef.current))},[]),m=h.useCallback(function(g){c(g.type,ns(g),g.target,a(g,e.lockRef.current))},[]);h.useEffect(function(){return Ar.push(s),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:m}),document.addEventListener("wheel",l,Nr),document.addEventListener("touchmove",l,Nr),document.addEventListener("touchstart",d,Nr),function(){Ar=Ar.filter(function(g){return g!==s}),document.removeEventListener("wheel",l,Nr),document.removeEventListener("touchmove",l,Nr),document.removeEventListener("touchstart",d,Nr)}},[]);var p=e.removeScrollBar,v=e.inert;return h.createElement(h.Fragment,null,v?h.createElement(s,{styles:Rw(o)}):null,p?h.createElement(Tw,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Dw(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const Lw=dw(fd,Ow);var rs=h.forwardRef(function(e,t){return h.createElement(es,vn({},e,{ref:t,sideCar:Lw}))});rs.classNames=es.classNames;var $w=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},jr=new WeakMap,os=new WeakMap,ss={},ta=0,yd=function(e){return e&&(e.host||yd(e.parentNode))},Fw=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=yd(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})},Bw=function(e,t,n,r){var o=Fw(t,Array.isArray(e)?e:[e]);ss[n]||(ss[n]=new WeakMap);var s=ss[n],i=[],a=new Set,l=new Set(o),c=function(f){!f||a.has(f)||(a.add(f),c(f.parentNode))};o.forEach(c);var d=function(f){!f||l.has(f)||Array.prototype.forEach.call(f.children,function(m){if(a.has(m))d(m);else try{var p=m.getAttribute(r),v=p!==null&&p!=="false",g=(jr.get(m)||0)+1,x=(s.get(m)||0)+1;jr.set(m,g),s.set(m,x),i.push(m),g===1&&v&&os.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(),ta++,function(){i.forEach(function(f){var m=jr.get(f)-1,p=s.get(f)-1;jr.set(f,m),s.set(f,p),m||(os.has(f)||f.removeAttribute(r),os.delete(f)),p||f.removeAttribute(n)}),ta--,ta||(jr=new WeakMap,jr=new WeakMap,os=new WeakMap,ss={})}},na=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=$w(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),Bw(r,o,n,"aria-hidden")):function(){return null}},is="Dialog",[Sd,BN]=nn(is),[zw,un]=Sd(is),Cd=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:i=!0}=e,a=h.useRef(null),l=h.useRef(null),[c,d]=In({prop:r,defaultProp:o??!1,onChange:s,caller:is});return u.jsx(zw,{scope:t,triggerRef:a,contentRef:l,contentId:jt(),titleId:jt(),descriptionId:jt(),open:c,onOpenChange:d,onOpenToggle:h.useCallback(()=>d(f=>!f),[d]),modal:i,children:n})};Cd.displayName=is;var Td="DialogTrigger",kd=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=un(Td,n),s=
|
|
79
|
+
`)},Mw=0,Ar=[];function Ow(e){var t=h.useRef([]),n=h.useRef([0,0]),r=h.useRef(),o=h.useState(Mw++)[0],s=h.useState(pd)[0],i=h.useRef(e);h.useEffect(function(){i.current=e},[e]),h.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var g=nw([e.lockRef.current],(e.shards||[]).map(wd),!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=h.useCallback(function(g,x){if("touches"in g&&g.touches.length===2||g.type==="wheel"&&g.ctrlKey)return!i.current.allowPinchZoom;var y=ns(g),w=n.current,C="deltaX"in g?g.deltaX:w[0]-y[0],E="deltaY"in g?g.deltaY:w[1]-y[1],T,S=g.target,k=Math.abs(C)>Math.abs(E)?"h":"v";if("touches"in g&&k==="h"&&S.type==="range")return!1;var A=gd(k,S);if(!A)return!0;if(A?T=k:(T=k==="v"?"h":"v",A=gd(k,S)),!A)return!1;if(!r.current&&"changedTouches"in g&&(C||E)&&(r.current=T),!T)return!0;var j=r.current||T;return Pw(j,x,g,j==="h"?C:E)},[]),l=h.useCallback(function(g){var x=g;if(!(!Ar.length||Ar[Ar.length-1]!==s)){var y="deltaY"in x?bd(x):ns(x),w=t.current.filter(function(T){return T.name===x.type&&(T.target===x.target||x.target===T.shadowParent)&&_w(T.delta,y)})[0];if(w&&w.should){x.cancelable&&x.preventDefault();return}if(!w){var C=(i.current.shards||[]).map(wd).filter(Boolean).filter(function(T){return T.contains(x.target)}),E=C.length>0?a(x,C[0]):!i.current.noIsolation;E&&x.cancelable&&x.preventDefault()}}},[]),c=h.useCallback(function(g,x,y,w){var C={name:g,delta:x,target:y,should:w,shadowParent:Dw(y)};t.current.push(C),setTimeout(function(){t.current=t.current.filter(function(E){return E!==C})},1)},[]),d=h.useCallback(function(g){n.current=ns(g),r.current=void 0},[]),f=h.useCallback(function(g){c(g.type,bd(g),g.target,a(g,e.lockRef.current))},[]),m=h.useCallback(function(g){c(g.type,ns(g),g.target,a(g,e.lockRef.current))},[]);h.useEffect(function(){return Ar.push(s),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:m}),document.addEventListener("wheel",l,Nr),document.addEventListener("touchmove",l,Nr),document.addEventListener("touchstart",d,Nr),function(){Ar=Ar.filter(function(g){return g!==s}),document.removeEventListener("wheel",l,Nr),document.removeEventListener("touchmove",l,Nr),document.removeEventListener("touchstart",d,Nr)}},[]);var p=e.removeScrollBar,v=e.inert;return h.createElement(h.Fragment,null,v?h.createElement(s,{styles:Rw(o)}):null,p?h.createElement(Tw,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Dw(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const Lw=dw(fd,Ow);var rs=h.forwardRef(function(e,t){return h.createElement(es,vn({},e,{ref:t,sideCar:Lw}))});rs.classNames=es.classNames;var $w=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},jr=new WeakMap,os=new WeakMap,ss={},ta=0,yd=function(e){return e&&(e.host||yd(e.parentNode))},Fw=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=yd(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})},Bw=function(e,t,n,r){var o=Fw(t,Array.isArray(e)?e:[e]);ss[n]||(ss[n]=new WeakMap);var s=ss[n],i=[],a=new Set,l=new Set(o),c=function(f){!f||a.has(f)||(a.add(f),c(f.parentNode))};o.forEach(c);var d=function(f){!f||l.has(f)||Array.prototype.forEach.call(f.children,function(m){if(a.has(m))d(m);else try{var p=m.getAttribute(r),v=p!==null&&p!=="false",g=(jr.get(m)||0)+1,x=(s.get(m)||0)+1;jr.set(m,g),s.set(m,x),i.push(m),g===1&&v&&os.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(),ta++,function(){i.forEach(function(f){var m=jr.get(f)-1,p=s.get(f)-1;jr.set(f,m),s.set(f,p),m||(os.has(f)||f.removeAttribute(r),os.delete(f)),p||f.removeAttribute(n)}),ta--,ta||(jr=new WeakMap,jr=new WeakMap,os=new WeakMap,ss={})}},na=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=$w(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),Bw(r,o,n,"aria-hidden")):function(){return null}},is="Dialog",[Sd,BN]=nn(is),[zw,un]=Sd(is),Cd=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:i=!0}=e,a=h.useRef(null),l=h.useRef(null),[c,d]=In({prop:r,defaultProp:o??!1,onChange:s,caller:is});return u.jsx(zw,{scope:t,triggerRef:a,contentRef:l,contentId:jt(),titleId:jt(),descriptionId:jt(),open:c,onOpenChange:d,onOpenToggle:h.useCallback(()=>d(f=>!f),[d]),modal:i,children:n})};Cd.displayName=is;var Td="DialogTrigger",kd=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=un(Td,n),s=Le(t,o.triggerRef);return u.jsx(he.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":sa(o.open),...r,ref:s,onClick:ue(e.onClick,o.onOpenToggle)})});kd.displayName=Td;var ra="DialogPortal",[Hw,Ed]=Sd(ra,{forceMount:void 0}),Id=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=un(ra,t);return u.jsx(Hw,{scope:t,forceMount:n,children:h.Children.map(r,i=>u.jsx($t,{present:n||s.open,children:u.jsx(so,{asChild:!0,container:o,children:i})}))})};Id.displayName=ra;var as="DialogOverlay",Nd=h.forwardRef((e,t)=>{const n=Ed(as,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=un(as,e.__scopeDialog);return s.modal?u.jsx($t,{present:r||s.open,children:u.jsx(Ww,{...o,ref:t})}):null});Nd.displayName=as;var Uw=Jt.createSlot("DialogOverlay.RemoveScroll"),Ww=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=un(as,n);return u.jsx(rs,{as:Uw,allowPinchZoom:!0,shards:[o.contentRef],children:u.jsx(he.div,{"data-state":sa(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),rr="DialogContent",Ad=h.forwardRef((e,t)=>{const n=Ed(rr,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=un(rr,e.__scopeDialog);return u.jsx($t,{present:r||s.open,children:s.modal?u.jsx(Vw,{...o,ref:t}):u.jsx(Kw,{...o,ref:t})})});Ad.displayName=rr;var Vw=h.forwardRef((e,t)=>{const n=un(rr,e.__scopeDialog),r=h.useRef(null),o=Le(t,n.contentRef,r);return h.useEffect(()=>{const s=r.current;if(s)return na(s)},[]),u.jsx(jd,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ue(e.onCloseAutoFocus,s=>{var i;s.preventDefault(),(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:ue(e.onPointerDownOutside,s=>{const i=s.detail.originalEvent,a=i.button===0&&i.ctrlKey===!0;(i.button===2||a)&&s.preventDefault()}),onFocusOutside:ue(e.onFocusOutside,s=>s.preventDefault())})}),Kw=h.forwardRef((e,t)=>{const n=un(rr,e.__scopeDialog),r=h.useRef(!1),o=h.useRef(!1);return u.jsx(jd,{...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()}})}),jd=h.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=un(rr,n),l=h.useRef(null),c=Le(t,l);return Xi(),u.jsxs(u.Fragment,{children:[u.jsx(Xo,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:u.jsx(Er,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":sa(a.open),...i,ref:c,onDismiss:()=>a.onOpenChange(!1)})}),u.jsxs(u.Fragment,{children:[u.jsx(qw,{titleId:a.titleId}),u.jsx(Yw,{contentRef:l,descriptionId:a.descriptionId})]})]})}),oa="DialogTitle",Pd=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=un(oa,n);return u.jsx(he.h2,{id:o.titleId,...r,ref:t})});Pd.displayName=oa;var _d="DialogDescription",Rd=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=un(_d,n);return u.jsx(he.p,{id:o.descriptionId,...r,ref:t})});Rd.displayName=_d;var Md="DialogClose",Od=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=un(Md,n);return u.jsx(he.button,{type:"button",...r,ref:t,onClick:ue(e.onClick,()=>o.onOpenChange(!1))})});Od.displayName=Md;function sa(e){return e?"open":"closed"}var Dd="DialogTitleWarning",[zN,Ld]=Nb(Dd,{contentName:rr,titleName:oa,docsSlug:"dialog"}),qw=({titleId:e})=>{const t=Ld(Dd),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
80
80
|
|
|
81
81
|
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
82
82
|
|
|
83
|
-
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return h.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},Gw="DialogDescriptionWarning",Yw=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Ld(Gw).contentName}}.`;return h.useEffect(()=>{var s;const o=(s=e.current)==null?void 0:s.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},ia=Cd,Xw=kd,aa=Id,io=Nd,ao=Ad,or=Pd,ls=Rd,$d=Od;const la=ia,Jw=aa,Fd=h.forwardRef(({className:e,...t},n)=>u.jsx(io,{ref:n,className:oe("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));Fd.displayName=io.displayName;const cs=h.forwardRef(({className:e,children:t,...n},r)=>{const o=h.useMemo(()=>{let s=!1;function i(a){h.Children.forEach(a,l=>{if(s||!h.isValidElement(l))return;const c=l.type;if(c===or||(c==null?void 0:c.displayName)===or.displayName||(c==null?void 0:c.name)==="DialogTitle"){s=!0;return}l.props&&l.props.children&&i(l.props.children)})}return i(t),s},[t]);return u.jsxs(Jw,{children:[u.jsx(Fd,{}),u.jsxs(ao,{ref:r,className:oe("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...n,children:[!o&&u.jsx(or,{className:"sr-only",children:"Dialog"}),t,u.jsxs($d,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[u.jsx(de.X,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]})});cs.displayName=ao.displayName;const us=({className:e,...t})=>u.jsx("div",{className:oe("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});us.displayName="DialogHeader";const ds=h.forwardRef(({className:e,...t},n)=>u.jsx(or,{ref:n,className:oe("text-lg font-semibold leading-none tracking-tight",e),...t}));ds.displayName=or.displayName;const Zw=h.forwardRef(({className:e,...t},n)=>u.jsx(ls,{ref:n,className:oe("text-sm text-muted-foreground",e),...t}));Zw.displayName=ls.displayName;const Qw=1,ey=1e6;let ca=0;function ty(){return ca=(ca+1)%Number.MAX_SAFE_INTEGER,ca.toString()}const ua=new Map,Bd=e=>{if(ua.has(e))return;const t=setTimeout(()=>{ua.delete(e),lo({type:"REMOVE_TOAST",toastId:e})},ey);ua.set(e,t)},ny=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,Qw)};case"UPDATE_TOAST":return{...e,toasts:e.toasts.map(n=>n.id===t.toast.id?{...n,...t.toast}:n)};case"DISMISS_TOAST":{const{toastId:n}=t;return n?Bd(n):e.toasts.forEach(r=>{Bd(r.id)}),{...e,toasts:e.toasts.map(r=>r.id===n||n===void 0?{...r,open:!1}:r)}}case"REMOVE_TOAST":return t.toastId===void 0?{...e,toasts:[]}:{...e,toasts:e.toasts.filter(n=>n.id!==t.toastId)}}},fs=[];let ps={toasts:[]};function lo(e){ps=ny(ps,e),fs.forEach(t=>{t(ps)})}function ry({...e}){const t=ty(),n=o=>lo({type:"UPDATE_TOAST",toast:{...o,id:t}}),r=()=>lo({type:"DISMISS_TOAST",toastId:t});return lo({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:o=>{o||r()}}}),{id:t,dismiss:r,update:n}}function da(){const[e,t]=h.useState(ps);return h.useEffect(()=>(fs.push(t),()=>{const n=fs.indexOf(t);n>-1&&fs.splice(n,1)}),[e]),{...e,toast:ry,dismiss:n=>lo({type:"DISMISS_TOAST",toastId:n})}}function oy({isOpen:e,onClose:t,fileId:n,fileName:r,mimeType:o}){const[s,i]=b.useState(!1),[a,l]=b.useState(null),[c,d]=b.useState(null),{toast:f}=da(),{fileApi:m}=On(),p=b.useCallback(async()=>{if(n){i(!0),d(null),l(null);try{const w=await m.getFileContent(n);l(w)}catch(w){console.error("Failed to load file:",w),d(w instanceof Error?w.message:"Failed to load file")}finally{i(!1)}}},[n]);b.useEffect(()=>{e&&n&&p()},[e,n,p]);const v=async()=>{if(n)try{await m.downloadFileById(n),f({title:"Download started",description:`Downloading ${r}`})}catch(w){console.error("Failed to download file:",w),f({title:"Download failed",description:String(w),variant:"destructive"})}},g=async()=>{if(n)try{const w=await m.getFileContent(n),C=new Blob([w],{type:o}),E=URL.createObjectURL(C);window.open(E,"_blank"),URL.revokeObjectURL(E)}catch(w){console.error("Failed to open file externally:",w),f({title:"Failed to open file",description:String(w),variant:"destructive"})}},x=()=>s?u.jsxs("div",{className:"flex items-center justify-center py-12",children:[u.jsx(de.Loader,{className:"h-8 w-8 animate-spin mr-3"}),u.jsx("span",{children:"Loading file..."})]}):c?u.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[u.jsx("div",{className:"text-red-500 mb-4",children:"⚠️"}),u.jsx("p",{className:"text-red-600 mb-4",children:c}),u.jsx(Xe,{onClick:p,variant:"outline",children:"Try Again"})]}):a?o.startsWith("image/")?u.jsx("div",{className:"flex justify-center",children:u.jsx("img",{src:`data:${o};base64,${a}`,alt:r,className:"max-w-full max-h-[70vh] object-contain rounded-lg"})}):o==="application/pdf"?u.jsx("div",{className:"w-full h-[70vh] border rounded-lg overflow-hidden",children:u.jsx("iframe",{src:`data:application/pdf;base64,${a}`,className:"w-full h-full",title:r})}):o.startsWith("text/")||o.includes("json")||o.includes("xml")?u.jsx("div",{className:"bg-gray-50 dark:bg-gray-900 rounded-lg p-4 max-h-[70vh] overflow-auto",children:u.jsx("pre",{className:"whitespace-pre-wrap font-mono text-sm",children:a})}):u.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[u.jsx(de.FileText,{className:"h-16 w-16 text-gray-400 mb-4"}),u.jsx("p",{className:"text-lg font-medium mb-2",children:r}),u.jsxs("p",{className:"text-sm text-muted-foreground mb-4",children:[o," • ",a.length," bytes"]}),u.jsx("p",{className:"text-sm text-muted-foreground",children:"This file type cannot be previewed. Use download or external view."})]}):u.jsx("div",{className:"flex items-center justify-center py-12",children:u.jsx("p",{className:"text-muted-foreground",children:"No content to display"})}),y=()=>o.startsWith("image/")?u.jsx(de.Image,{className:"h-5 w-5"}):u.jsx(de.FileText,{className:"h-5 w-5"});return u.jsx(la,{open:e,onOpenChange:t,children:u.jsxs(cs,{className:"max-w-4xl max-h-[90vh] overflow-hidden",children:[u.jsx(us,{children:u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[y(),u.jsxs("div",{children:[u.jsx(ds,{className:"text-left",children:r}),u.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:[o," • Click download or external view for full access"]})]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsxs(Xe,{variant:"outline",size:"sm",onClick:g,className:"flex items-center gap-2",children:[u.jsx(de.ExternalLink,{className:"h-4 w-4"}),"External"]}),u.jsxs(Xe,{variant:"outline",size:"sm",onClick:v,className:"flex items-center gap-2",children:[u.jsx(de.Download,{className:"h-4 w-4"}),"Download"]})]})]})}),u.jsx("div",{className:"flex-1 overflow-hidden",children:x()})]})})}function zd(){return{async:!1,baseUrl:null,breaks:!1,extensions:null,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,hooks:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:null,sanitize:!1,sanitizer:null,silent:!1,smartypants:!1,tokenizer:null,walkTokens:null,xhtml:!1}}let sr=zd();function sy(e){sr=e}const Hd=/[&<>"']/,iy=new RegExp(Hd.source,"g"),Ud=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,ay=new RegExp(Ud.source,"g"),ly={"&":"&","<":"<",">":">",'"':""","'":"'"},Wd=e=>ly[e];function Mt(e,t){if(t){if(Hd.test(e))return e.replace(iy,Wd)}else if(Ud.test(e))return e.replace(ay,Wd);return e}const cy=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function Vd(e){return e.replace(cy,(t,n)=>(n=n.toLowerCase(),n==="colon"?":":n.charAt(0)==="#"?n.charAt(1)==="x"?String.fromCharCode(parseInt(n.substring(2),16)):String.fromCharCode(+n.substring(1)):""))}const uy=/(^|[^\[])\^/g;function et(e,t){e=typeof e=="string"?e:e.source,t=t||"";const n={replace:(r,o)=>(o=o.source||o,o=o.replace(uy,"$1"),e=e.replace(r,o),n),getRegex:()=>new RegExp(e,t)};return n}const dy=/[^\w:]/g,fy=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function Kd(e,t,n){if(e){let r;try{r=decodeURIComponent(Vd(n)).replace(dy,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}t&&!fy.test(n)&&(n=gy(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const hs={},py=/^[^:]+:\/*[^/]*$/,hy=/^([^:]+:)[\s\S]*$/,my=/^([^:]+:\/*[^/]*)[\s\S]*$/;function gy(e,t){hs[" "+e]||(py.test(e)?hs[" "+e]=e+"/":hs[" "+e]=gs(e,"/",!0)),e=hs[" "+e];const n=e.indexOf(":")===-1;return t.substring(0,2)==="//"?n?t:e.replace(hy,"$1")+t:t.charAt(0)==="/"?n?t:e.replace(my,"$1")+t:e+t}const ms={exec:function(){}};function qd(e,t){const n=e.replace(/\|/g,(s,i,a)=>{let l=!1,c=i;for(;--c>=0&&a[c]==="\\";)l=!l;return l?"|":" |"}),r=n.split(/ \|/);let o=0;if(r[0].trim()||r.shift(),r.length>0&&!r[r.length-1].trim()&&r.pop(),r.length>t)r.splice(t);else for(;r.length<t;)r.push("");for(;o<r.length;o++)r[o]=r[o].trim().replace(/\\\|/g,"|");return r}function gs(e,t,n){const r=e.length;if(r===0)return"";let o=0;for(;o<r;){const s=e.charAt(r-o-1);if(s===t&&!n)o++;else if(s!==t&&n)o++;else break}return e.slice(0,r-o)}function xy(e,t){if(e.indexOf(t[1])===-1)return-1;const n=e.length;let r=0,o=0;for(;o<n;o++)if(e[o]==="\\")o++;else if(e[o]===t[0])r++;else if(e[o]===t[1]&&(r--,r<0))return o;return-1}function vy(e){e&&e.sanitize&&!e.silent&&console.warn("marked(): sanitize and sanitizer parameters are deprecated since version 0.7.0, should not be used and will be removed in the future. Read more here: https://marked.js.org/#/USING_ADVANCED.md#options")}function Gd(e,t){if(t<1)return"";let n="";for(;t>1;)t&1&&(n+=e),t>>=1,e+=e;return n+e}function Yd(e,t,n,r){const o=t.href,s=t.title?Mt(t.title):null,i=e[1].replace(/\\([\[\]])/g,"$1");if(e[0].charAt(0)!=="!"){r.state.inLink=!0;const a={type:"link",raw:n,href:o,title:s,text:i,tokens:r.inlineTokens(i)};return r.state.inLink=!1,a}return{type:"image",raw:n,href:o,title:s,text:Mt(i)}}function by(e,t){const n=e.match(/^(\s+)(?:```)/);if(n===null)return t;const r=n[1];return t.split(`
|
|
83
|
+
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return h.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},Gw="DialogDescriptionWarning",Yw=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Ld(Gw).contentName}}.`;return h.useEffect(()=>{var s;const o=(s=e.current)==null?void 0:s.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},ia=Cd,Xw=kd,aa=Id,io=Nd,ao=Ad,or=Pd,ls=Rd,$d=Od;const la=ia,Jw=aa,Fd=h.forwardRef(({className:e,...t},n)=>u.jsx(io,{ref:n,className:oe("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));Fd.displayName=io.displayName;const cs=h.forwardRef(({className:e,children:t,...n},r)=>{const o=h.useMemo(()=>{let s=!1;function i(a){h.Children.forEach(a,l=>{if(s||!h.isValidElement(l))return;const c=l.type;if(c===or||(c==null?void 0:c.displayName)===or.displayName||(c==null?void 0:c.name)==="DialogTitle"){s=!0;return}l.props&&l.props.children&&i(l.props.children)})}return i(t),s},[t]);return u.jsxs(Jw,{children:[u.jsx(Fd,{}),u.jsxs(ao,{ref:r,className:oe("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...n,children:[!o&&u.jsx(or,{className:"sr-only",children:"Dialog"}),t,u.jsxs($d,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[u.jsx(de.X,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]})});cs.displayName=ao.displayName;const us=({className:e,...t})=>u.jsx("div",{className:oe("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});us.displayName="DialogHeader";const ds=h.forwardRef(({className:e,...t},n)=>u.jsx(or,{ref:n,className:oe("text-lg font-semibold leading-none tracking-tight",e),...t}));ds.displayName=or.displayName;const Zw=h.forwardRef(({className:e,...t},n)=>u.jsx(ls,{ref:n,className:oe("text-sm text-muted-foreground",e),...t}));Zw.displayName=ls.displayName;const Qw=1,ey=1e6;let ca=0;function ty(){return ca=(ca+1)%Number.MAX_SAFE_INTEGER,ca.toString()}const ua=new Map,Bd=e=>{if(ua.has(e))return;const t=setTimeout(()=>{ua.delete(e),lo({type:"REMOVE_TOAST",toastId:e})},ey);ua.set(e,t)},ny=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,Qw)};case"UPDATE_TOAST":return{...e,toasts:e.toasts.map(n=>n.id===t.toast.id?{...n,...t.toast}:n)};case"DISMISS_TOAST":{const{toastId:n}=t;return n?Bd(n):e.toasts.forEach(r=>{Bd(r.id)}),{...e,toasts:e.toasts.map(r=>r.id===n||n===void 0?{...r,open:!1}:r)}}case"REMOVE_TOAST":return t.toastId===void 0?{...e,toasts:[]}:{...e,toasts:e.toasts.filter(n=>n.id!==t.toastId)}}},fs=[];let ps={toasts:[]};function lo(e){ps=ny(ps,e),fs.forEach(t=>{t(ps)})}function ry({...e}){const t=ty(),n=o=>lo({type:"UPDATE_TOAST",toast:{...o,id:t}}),r=()=>lo({type:"DISMISS_TOAST",toastId:t});return lo({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:o=>{o||r()}}}),{id:t,dismiss:r,update:n}}function da(){const[e,t]=h.useState(ps);return h.useEffect(()=>(fs.push(t),()=>{const n=fs.indexOf(t);n>-1&&fs.splice(n,1)}),[e]),{...e,toast:ry,dismiss:n=>lo({type:"DISMISS_TOAST",toastId:n})}}function oy({isOpen:e,onClose:t,fileId:n,fileName:r,mimeType:o}){const[s,i]=b.useState(!1),[a,l]=b.useState(null),[c,d]=b.useState(null),{toast:f}=da(),{fileApi:m}=On(),p=b.useCallback(async()=>{if(n){i(!0),d(null),l(null);try{const w=await m.getFileContent(n);l(w)}catch(w){console.error("Failed to load file:",w),d(w instanceof Error?w.message:"Failed to load file")}finally{i(!1)}}},[n]);b.useEffect(()=>{e&&n&&p()},[e,n,p]);const v=async()=>{if(n)try{await m.downloadFileById(n),f({title:"Download started",description:`Downloading ${r}`})}catch(w){console.error("Failed to download file:",w),f({title:"Download failed",description:String(w),variant:"destructive"})}},g=async()=>{if(n)try{const w=await m.getFileContent(n),C=new Blob([w],{type:o}),E=URL.createObjectURL(C);window.open(E,"_blank"),URL.revokeObjectURL(E)}catch(w){console.error("Failed to open file externally:",w),f({title:"Failed to open file",description:String(w),variant:"destructive"})}},x=()=>s?u.jsxs("div",{className:"flex items-center justify-center py-12",children:[u.jsx(de.Loader,{className:"h-8 w-8 animate-spin mr-3"}),u.jsx("span",{children:"Loading file..."})]}):c?u.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[u.jsx("div",{className:"text-red-500 mb-4",children:"⚠️"}),u.jsx("p",{className:"text-red-600 mb-4",children:c}),u.jsx(Xe,{onClick:p,variant:"outline",children:"Try Again"})]}):a?o.startsWith("image/")?u.jsx("div",{className:"flex justify-center",children:u.jsx("img",{src:`data:${o};base64,${a}`,alt:r,className:"max-w-full max-h-[70vh] object-contain rounded-lg"})}):o==="application/pdf"?u.jsx("div",{className:"w-full h-[70vh] border rounded-lg overflow-hidden",children:u.jsx("iframe",{src:`data:application/pdf;base64,${a}`,className:"w-full h-full",title:r})}):o.startsWith("text/")||o.includes("json")||o.includes("xml")?u.jsx("div",{className:"bg-gray-50 dark:bg-gray-900 rounded-lg p-4 max-h-[70vh] overflow-auto",children:u.jsx("pre",{className:"whitespace-pre-wrap font-mono text-sm",children:a})}):u.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[u.jsx(de.FileText,{className:"h-16 w-16 text-gray-400 mb-4"}),u.jsx("p",{className:"text-lg font-medium mb-2",children:r}),u.jsxs("p",{className:"text-sm text-muted-foreground mb-4",children:[o," • ",a.length," bytes"]}),u.jsx("p",{className:"text-sm text-muted-foreground",children:"This file type cannot be previewed. Use download or external view."})]}):u.jsx("div",{className:"flex items-center justify-center py-12",children:u.jsx("p",{className:"text-muted-foreground",children:"No content to display"})}),y=()=>o.startsWith("image/")?u.jsx(de.Image,{className:"h-5 w-5"}):u.jsx(de.FileText,{className:"h-5 w-5"});return u.jsx(la,{open:e,onOpenChange:t,children:u.jsxs(cs,{className:"max-w-4xl max-h-[90vh] overflow-hidden",children:[u.jsx(us,{children:u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[y(),u.jsxs("div",{children:[u.jsx(ds,{className:"text-left",children:r}),u.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:[o," • Click download or external view for full access"]})]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsxs(Xe,{variant:"outline",size:"sm",onClick:g,className:"flex items-center gap-2",children:[u.jsx(de.ExternalLink,{className:"h-4 w-4"}),"External"]}),u.jsxs(Xe,{variant:"outline",size:"sm",onClick:v,className:"flex items-center gap-2",children:[u.jsx(de.Download,{className:"h-4 w-4"}),"Download"]})]})]})}),u.jsx("div",{className:"flex-1 overflow-hidden",children:x()})]})})}function zd(){return{async:!1,baseUrl:null,breaks:!1,extensions:null,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,hooks:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:null,sanitize:!1,sanitizer:null,silent:!1,smartypants:!1,tokenizer:null,walkTokens:null,xhtml:!1}}let sr=zd();function sy(e){sr=e}const Hd=/[&<>"']/,iy=new RegExp(Hd.source,"g"),Ud=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,ay=new RegExp(Ud.source,"g"),ly={"&":"&","<":"<",">":">",'"':""","'":"'"},Wd=e=>ly[e];function Rt(e,t){if(t){if(Hd.test(e))return e.replace(iy,Wd)}else if(Ud.test(e))return e.replace(ay,Wd);return e}const cy=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function Vd(e){return e.replace(cy,(t,n)=>(n=n.toLowerCase(),n==="colon"?":":n.charAt(0)==="#"?n.charAt(1)==="x"?String.fromCharCode(parseInt(n.substring(2),16)):String.fromCharCode(+n.substring(1)):""))}const uy=/(^|[^\[])\^/g;function Ze(e,t){e=typeof e=="string"?e:e.source,t=t||"";const n={replace:(r,o)=>(o=o.source||o,o=o.replace(uy,"$1"),e=e.replace(r,o),n),getRegex:()=>new RegExp(e,t)};return n}const dy=/[^\w:]/g,fy=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function Kd(e,t,n){if(e){let r;try{r=decodeURIComponent(Vd(n)).replace(dy,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}t&&!fy.test(n)&&(n=gy(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const hs={},py=/^[^:]+:\/*[^/]*$/,hy=/^([^:]+:)[\s\S]*$/,my=/^([^:]+:\/*[^/]*)[\s\S]*$/;function gy(e,t){hs[" "+e]||(py.test(e)?hs[" "+e]=e+"/":hs[" "+e]=gs(e,"/",!0)),e=hs[" "+e];const n=e.indexOf(":")===-1;return t.substring(0,2)==="//"?n?t:e.replace(hy,"$1")+t:t.charAt(0)==="/"?n?t:e.replace(my,"$1")+t:e+t}const ms={exec:function(){}};function qd(e,t){const n=e.replace(/\|/g,(s,i,a)=>{let l=!1,c=i;for(;--c>=0&&a[c]==="\\";)l=!l;return l?"|":" |"}),r=n.split(/ \|/);let o=0;if(r[0].trim()||r.shift(),r.length>0&&!r[r.length-1].trim()&&r.pop(),r.length>t)r.splice(t);else for(;r.length<t;)r.push("");for(;o<r.length;o++)r[o]=r[o].trim().replace(/\\\|/g,"|");return r}function gs(e,t,n){const r=e.length;if(r===0)return"";let o=0;for(;o<r;){const s=e.charAt(r-o-1);if(s===t&&!n)o++;else if(s!==t&&n)o++;else break}return e.slice(0,r-o)}function xy(e,t){if(e.indexOf(t[1])===-1)return-1;const n=e.length;let r=0,o=0;for(;o<n;o++)if(e[o]==="\\")o++;else if(e[o]===t[0])r++;else if(e[o]===t[1]&&(r--,r<0))return o;return-1}function vy(e){e&&e.sanitize&&!e.silent&&console.warn("marked(): sanitize and sanitizer parameters are deprecated since version 0.7.0, should not be used and will be removed in the future. Read more here: https://marked.js.org/#/USING_ADVANCED.md#options")}function Gd(e,t){if(t<1)return"";let n="";for(;t>1;)t&1&&(n+=e),t>>=1,e+=e;return n+e}function Yd(e,t,n,r){const o=t.href,s=t.title?Rt(t.title):null,i=e[1].replace(/\\([\[\]])/g,"$1");if(e[0].charAt(0)!=="!"){r.state.inLink=!0;const a={type:"link",raw:n,href:o,title:s,text:i,tokens:r.inlineTokens(i)};return r.state.inLink=!1,a}return{type:"image",raw:n,href:o,title:s,text:Rt(i)}}function by(e,t){const n=e.match(/^(\s+)(?:```)/);if(n===null)return t;const r=n[1];return t.split(`
|
|
84
84
|
`).map(o=>{const s=o.match(/^\s+/);if(s===null)return o;const[i]=s;return i.length>=r.length?o.slice(r.length):o}).join(`
|
|
85
85
|
`)}class fa{constructor(t){this.options=t||sr}space(t){const n=this.rules.block.newline.exec(t);if(n&&n[0].length>0)return{type:"space",raw:n[0]}}code(t){const n=this.rules.block.code.exec(t);if(n){const r=n[0].replace(/^ {1,4}/gm,"");return{type:"code",raw:n[0],codeBlockStyle:"indented",text:this.options.pedantic?r:gs(r,`
|
|
86
86
|
`)}}}fences(t){const n=this.rules.block.fences.exec(t);if(n){const r=n[0],o=by(r,n[3]||"");return{type:"code",raw:r,lang:n[2]?n[2].trim().replace(this.rules.inline._escapes,"$1"):n[2],text:o}}}heading(t){const n=this.rules.block.heading.exec(t);if(n){let r=n[2].trim();if(/#$/.test(r)){const o=gs(r,"#");(this.options.pedantic||!o||/ $/.test(o))&&(r=o.trim())}return{type:"heading",raw:n[0],depth:n[1].length,text:r,tokens:this.lexer.inline(r)}}}hr(t){const n=this.rules.block.hr.exec(t);if(n)return{type:"hr",raw:n[0]}}blockquote(t){const n=this.rules.block.blockquote.exec(t);if(n){const r=n[0].replace(/^ *>[ \t]?/gm,""),o=this.lexer.state.top;this.lexer.state.top=!0;const s=this.lexer.blockTokens(r);return this.lexer.state.top=o,{type:"blockquote",raw:n[0],tokens:s,text:r}}}list(t){let n=this.rules.block.list.exec(t);if(n){let r,o,s,i,a,l,c,d,f,m,p,v,g=n[1].trim();const x=g.length>1,y={type:"list",raw:"",ordered:x,start:x?+g.slice(0,-1):"",loose:!1,items:[]};g=x?`\\d{1,9}\\${g.slice(-1)}`:`\\${g}`,this.options.pedantic&&(g=x?g:"[*+-]");const w=new RegExp(`^( {0,3}${g})((?:[ ][^\\n]*)?(?:\\n|$))`);for(;t&&(v=!1,!(!(n=w.exec(t))||this.rules.block.hr.test(t)));){if(r=n[0],t=t.substring(r.length),d=n[2].split(`
|
|
@@ -90,10 +90,10 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
|
|
|
90
90
|
`,1)[0],f=m,this.options.pedantic&&(f=f.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),!(S.test(f)||k.test(f)||E.test(f)||T.test(t)));){if(f.search(/[^ ]/)>=i||!f.trim())p+=`
|
|
91
91
|
`+f.slice(i);else{if(l||d.search(/[^ ]/)>=4||S.test(d)||k.test(d)||T.test(d))break;p+=`
|
|
92
92
|
`+f}!l&&!f.trim()&&(l=!0),r+=m+`
|
|
93
|
-
`,t=t.substring(m.length+1),d=f.slice(i)}}y.loose||(c?y.loose=!0:/\n *\n *$/.test(r)&&(c=!0)),this.options.gfm&&(o=/^\[[ xX]\] /.exec(p),o&&(s=o[0]!=="[ ] ",p=p.replace(/^\[[ xX]\] +/,""))),y.items.push({type:"list_item",raw:r,task:!!o,checked:s,loose:!1,text:p}),y.raw+=r}y.items[y.items.length-1].raw=r.trimRight(),y.items[y.items.length-1].text=p.trimRight(),y.raw=y.raw.trimRight();const C=y.items.length;for(a=0;a<C;a++)if(this.lexer.state.top=!1,y.items[a].tokens=this.lexer.blockTokens(y.items[a].text,[]),!y.loose){const E=y.items[a].tokens.filter(S=>S.type==="space"),T=E.length>0&&E.some(S=>/\n.*\n/.test(S.raw));y.loose=T}if(y.loose)for(a=0;a<C;a++)y.items[a].loose=!0;return y}}html(t){const n=this.rules.block.html.exec(t);if(n){const r={type:"html",raw:n[0],pre:!this.options.sanitizer&&(n[1]==="pre"||n[1]==="script"||n[1]==="style"),text:n[0]};if(this.options.sanitize){const o=this.options.sanitizer?this.options.sanitizer(n[0]):
|
|
93
|
+
`,t=t.substring(m.length+1),d=f.slice(i)}}y.loose||(c?y.loose=!0:/\n *\n *$/.test(r)&&(c=!0)),this.options.gfm&&(o=/^\[[ xX]\] /.exec(p),o&&(s=o[0]!=="[ ] ",p=p.replace(/^\[[ xX]\] +/,""))),y.items.push({type:"list_item",raw:r,task:!!o,checked:s,loose:!1,text:p}),y.raw+=r}y.items[y.items.length-1].raw=r.trimRight(),y.items[y.items.length-1].text=p.trimRight(),y.raw=y.raw.trimRight();const C=y.items.length;for(a=0;a<C;a++)if(this.lexer.state.top=!1,y.items[a].tokens=this.lexer.blockTokens(y.items[a].text,[]),!y.loose){const E=y.items[a].tokens.filter(S=>S.type==="space"),T=E.length>0&&E.some(S=>/\n.*\n/.test(S.raw));y.loose=T}if(y.loose)for(a=0;a<C;a++)y.items[a].loose=!0;return y}}html(t){const n=this.rules.block.html.exec(t);if(n){const r={type:"html",raw:n[0],pre:!this.options.sanitizer&&(n[1]==="pre"||n[1]==="script"||n[1]==="style"),text:n[0]};if(this.options.sanitize){const o=this.options.sanitizer?this.options.sanitizer(n[0]):Rt(n[0]);r.type="paragraph",r.text=o,r.tokens=this.lexer.inline(o)}return r}}def(t){const n=this.rules.block.def.exec(t);if(n){const r=n[1].toLowerCase().replace(/\s+/g," "),o=n[2]?n[2].replace(/^<(.*)>$/,"$1").replace(this.rules.inline._escapes,"$1"):"",s=n[3]?n[3].substring(1,n[3].length-1).replace(this.rules.inline._escapes,"$1"):n[3];return{type:"def",tag:r,raw:n[0],href:o,title:s}}}table(t){const n=this.rules.block.table.exec(t);if(n){const r={type:"table",header:qd(n[1]).map(o=>({text:o})),align:n[2].replace(/^ *|\| *$/g,"").split(/ *\| */),rows:n[3]&&n[3].trim()?n[3].replace(/\n[ \t]*$/,"").split(`
|
|
94
94
|
`):[]};if(r.header.length===r.align.length){r.raw=n[0];let o=r.align.length,s,i,a,l;for(s=0;s<o;s++)/^ *-+: *$/.test(r.align[s])?r.align[s]="right":/^ *:-+: *$/.test(r.align[s])?r.align[s]="center":/^ *:-+ *$/.test(r.align[s])?r.align[s]="left":r.align[s]=null;for(o=r.rows.length,s=0;s<o;s++)r.rows[s]=qd(r.rows[s],r.header.length).map(c=>({text:c}));for(o=r.header.length,i=0;i<o;i++)r.header[i].tokens=this.lexer.inline(r.header[i].text);for(o=r.rows.length,i=0;i<o;i++)for(l=r.rows[i],a=0;a<l.length;a++)l[a].tokens=this.lexer.inline(l[a].text);return r}}}lheading(t){const n=this.rules.block.lheading.exec(t);if(n)return{type:"heading",raw:n[0],depth:n[2].charAt(0)==="="?1:2,text:n[1],tokens:this.lexer.inline(n[1])}}paragraph(t){const n=this.rules.block.paragraph.exec(t);if(n){const r=n[1].charAt(n[1].length-1)===`
|
|
95
|
-
`?n[1].slice(0,-1):n[1];return{type:"paragraph",raw:n[0],text:r,tokens:this.lexer.inline(r)}}}text(t){const n=this.rules.block.text.exec(t);if(n)return{type:"text",raw:n[0],text:n[0],tokens:this.lexer.inline(n[0])}}escape(t){const n=this.rules.inline.escape.exec(t);if(n)return{type:"escape",raw:n[0],text:
|
|
96
|
-
]`).replace("lheading",we.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()};const pe={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:ms,tag:"^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>",link:/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/,reflink:/^!?\[(label)\]\[(ref)\]/,nolink:/^!?\[(ref)\](?:\[\])?/,reflinkSearch:"reflink|nolink(?!\\()",emStrong:{lDelim:/^(?:\*+(?:([punct_])|[^\s*]))|^_+(?:([punct*])|([^\s_]))/,rDelimAst:/^(?:[^_*\\]|\\.)*?\_\_(?:[^_*\\]|\\.)*?\*(?:[^_*\\]|\\.)*?(?=\_\_)|(?:[^*\\]|\\.)+(?=[^*])|[punct_](\*+)(?=[\s]|$)|(?:[^punct*_\s\\]|\\.)(\*+)(?=[punct_\s]|$)|[punct_\s](\*+)(?=[^punct*_\s])|[\s](\*+)(?=[punct_])|[punct_](\*+)(?=[punct_])|(?:[^punct*_\s\\]|\\.)(\*+)(?=[^punct*_\s])/,rDelimUnd:/^(?:[^_*\\]|\\.)*?\*\*(?:[^_*\\]|\\.)*?\_(?:[^_*\\]|\\.)*?(?=\*\*)|(?:[^_\\]|\\.)+(?=[^_])|[punct*](\_+)(?=[\s]|$)|(?:[^punct*_\s\\]|\\.)(\_+)(?=[punct*\s]|$)|[punct*\s](\_+)(?=[^punct*_\s])|[\s](\_+)(?=[punct*])|[punct*](\_+)(?=[punct*])/},code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,br:/^( {2,}|\\)\n(?!\s*$)/,del:ms,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,punctuation:/^([\spunctuation])/};pe._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",pe.punctuation=
|
|
95
|
+
`?n[1].slice(0,-1):n[1];return{type:"paragraph",raw:n[0],text:r,tokens:this.lexer.inline(r)}}}text(t){const n=this.rules.block.text.exec(t);if(n)return{type:"text",raw:n[0],text:n[0],tokens:this.lexer.inline(n[0])}}escape(t){const n=this.rules.inline.escape.exec(t);if(n)return{type:"escape",raw:n[0],text:Rt(n[1])}}tag(t){const n=this.rules.inline.tag.exec(t);if(n)return!this.lexer.state.inLink&&/^<a /i.test(n[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&/^<\/a>/i.test(n[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(n[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(n[0])&&(this.lexer.state.inRawBlock=!1),{type:this.options.sanitize?"text":"html",raw:n[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(n[0]):Rt(n[0]):n[0]}}link(t){const n=this.rules.inline.link.exec(t);if(n){const r=n[2].trim();if(!this.options.pedantic&&/^</.test(r)){if(!/>$/.test(r))return;const i=gs(r.slice(0,-1),"\\");if((r.length-i.length)%2===0)return}else{const i=xy(n[2],"()");if(i>-1){const l=(n[0].indexOf("!")===0?5:4)+n[1].length+i;n[2]=n[2].substring(0,i),n[0]=n[0].substring(0,l).trim(),n[3]=""}}let o=n[2],s="";if(this.options.pedantic){const i=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(o);i&&(o=i[1],s=i[3])}else s=n[3]?n[3].slice(1,-1):"";return o=o.trim(),/^</.test(o)&&(this.options.pedantic&&!/>$/.test(r)?o=o.slice(1):o=o.slice(1,-1)),Yd(n,{href:o&&o.replace(this.rules.inline._escapes,"$1"),title:s&&s.replace(this.rules.inline._escapes,"$1")},n[0],this.lexer)}}reflink(t,n){let r;if((r=this.rules.inline.reflink.exec(t))||(r=this.rules.inline.nolink.exec(t))){let o=(r[2]||r[1]).replace(/\s+/g," ");if(o=n[o.toLowerCase()],!o){const s=r[0].charAt(0);return{type:"text",raw:s,text:s}}return Yd(r,o,r[0],this.lexer)}}emStrong(t,n,r=""){let o=this.rules.inline.emStrong.lDelim.exec(t);if(!o||o[3]&&r.match(/[\p{L}\p{N}]/u))return;const s=o[1]||o[2]||"";if(!s||s&&(r===""||this.rules.inline.punctuation.exec(r))){const i=o[0].length-1;let a,l,c=i,d=0;const f=o[0][0]==="*"?this.rules.inline.emStrong.rDelimAst:this.rules.inline.emStrong.rDelimUnd;for(f.lastIndex=0,n=n.slice(-1*t.length+i);(o=f.exec(n))!=null;){if(a=o[1]||o[2]||o[3]||o[4]||o[5]||o[6],!a)continue;if(l=a.length,o[3]||o[4]){c+=l;continue}else if((o[5]||o[6])&&i%3&&!((i+l)%3)){d+=l;continue}if(c-=l,c>0)continue;l=Math.min(l,l+c+d);const m=t.slice(0,i+o.index+(o[0].length-a.length)+l);if(Math.min(i,l)%2){const v=m.slice(1,-1);return{type:"em",raw:m,text:v,tokens:this.lexer.inlineTokens(v)}}const p=m.slice(2,-2);return{type:"strong",raw:m,text:p,tokens:this.lexer.inlineTokens(p)}}}}codespan(t){const n=this.rules.inline.code.exec(t);if(n){let r=n[2].replace(/\n/g," ");const o=/[^ ]/.test(r),s=/^ /.test(r)&&/ $/.test(r);return o&&s&&(r=r.substring(1,r.length-1)),r=Rt(r,!0),{type:"codespan",raw:n[0],text:r}}}br(t){const n=this.rules.inline.br.exec(t);if(n)return{type:"br",raw:n[0]}}del(t){const n=this.rules.inline.del.exec(t);if(n)return{type:"del",raw:n[0],text:n[2],tokens:this.lexer.inlineTokens(n[2])}}autolink(t,n){const r=this.rules.inline.autolink.exec(t);if(r){let o,s;return r[2]==="@"?(o=Rt(this.options.mangle?n(r[1]):r[1]),s="mailto:"+o):(o=Rt(r[1]),s=o),{type:"link",raw:r[0],text:o,href:s,tokens:[{type:"text",raw:o,text:o}]}}}url(t,n){let r;if(r=this.rules.inline.url.exec(t)){let o,s;if(r[2]==="@")o=Rt(this.options.mangle?n(r[0]):r[0]),s="mailto:"+o;else{let i;do i=r[0],r[0]=this.rules.inline._backpedal.exec(r[0])[0];while(i!==r[0]);o=Rt(r[0]),r[1]==="www."?s="http://"+r[0]:s=r[0]}return{type:"link",raw:r[0],text:o,href:s,tokens:[{type:"text",raw:o,text:o}]}}}inlineText(t,n){const r=this.rules.inline.text.exec(t);if(r){let o;return this.lexer.state.inRawBlock?o=this.options.sanitize?this.options.sanitizer?this.options.sanitizer(r[0]):Rt(r[0]):r[0]:o=Rt(this.options.smartypants?n(r[0]):r[0]),{type:"text",raw:r[0],text:o}}}}const we={newline:/^(?: *(?:\n|$))+/,code:/^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,fences:/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,hr:/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,blockquote:/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,list:/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/,html:"^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n *)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$))",def:/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/,table:ms,lheading:/^((?:.|\n(?!\n))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,text:/^[^\n]+/};we._label=/(?!\s*\])(?:\\.|[^\[\]\\])+/,we._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,we.def=Ze(we.def).replace("label",we._label).replace("title",we._title).getRegex(),we.bullet=/(?:[*+-]|\d{1,9}[.)])/,we.listItemStart=Ze(/^( *)(bull) */).replace("bull",we.bullet).getRegex(),we.list=Ze(we.list).replace(/bull/g,we.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+we.def.source+")").getRegex(),we._tag="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",we._comment=/<!--(?!-?>)[\s\S]*?(?:-->|$)/,we.html=Ze(we.html,"i").replace("comment",we._comment).replace("tag",we._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),we.paragraph=Ze(we._paragraph).replace("hr",we.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",we._tag).getRegex(),we.blockquote=Ze(we.blockquote).replace("paragraph",we.paragraph).getRegex(),we.normal={...we},we.gfm={...we.normal,table:"^ *([^\\n ].*\\|.*)\\n {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"},we.gfm.table=Ze(we.gfm.table).replace("hr",we.hr).replace("heading"," {0,3}#{1,6} ").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",we._tag).getRegex(),we.gfm.paragraph=Ze(we._paragraph).replace("hr",we.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("table",we.gfm.table).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",we._tag).getRegex(),we.pedantic={...we.normal,html:Ze(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",we._comment).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:ms,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:Ze(we.normal._paragraph).replace("hr",we.hr).replace("heading",` *#{1,6} *[^
|
|
96
|
+
]`).replace("lheading",we.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()};const pe={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:ms,tag:"^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>",link:/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/,reflink:/^!?\[(label)\]\[(ref)\]/,nolink:/^!?\[(ref)\](?:\[\])?/,reflinkSearch:"reflink|nolink(?!\\()",emStrong:{lDelim:/^(?:\*+(?:([punct_])|[^\s*]))|^_+(?:([punct*])|([^\s_]))/,rDelimAst:/^(?:[^_*\\]|\\.)*?\_\_(?:[^_*\\]|\\.)*?\*(?:[^_*\\]|\\.)*?(?=\_\_)|(?:[^*\\]|\\.)+(?=[^*])|[punct_](\*+)(?=[\s]|$)|(?:[^punct*_\s\\]|\\.)(\*+)(?=[punct_\s]|$)|[punct_\s](\*+)(?=[^punct*_\s])|[\s](\*+)(?=[punct_])|[punct_](\*+)(?=[punct_])|(?:[^punct*_\s\\]|\\.)(\*+)(?=[^punct*_\s])/,rDelimUnd:/^(?:[^_*\\]|\\.)*?\*\*(?:[^_*\\]|\\.)*?\_(?:[^_*\\]|\\.)*?(?=\*\*)|(?:[^_\\]|\\.)+(?=[^_])|[punct*](\_+)(?=[\s]|$)|(?:[^punct*_\s\\]|\\.)(\_+)(?=[punct*\s]|$)|[punct*\s](\_+)(?=[^punct*_\s])|[\s](\_+)(?=[punct*])|[punct*](\_+)(?=[punct*])/},code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,br:/^( {2,}|\\)\n(?!\s*$)/,del:ms,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,punctuation:/^([\spunctuation])/};pe._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",pe.punctuation=Ze(pe.punctuation).replace(/punctuation/g,pe._punctuation).getRegex(),pe.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g,pe.escapedEmSt=/(?:^|[^\\])(?:\\\\)*\\[*_]/g,pe._comment=Ze(we._comment).replace("(?:-->|$)","-->").getRegex(),pe.emStrong.lDelim=Ze(pe.emStrong.lDelim).replace(/punct/g,pe._punctuation).getRegex(),pe.emStrong.rDelimAst=Ze(pe.emStrong.rDelimAst,"g").replace(/punct/g,pe._punctuation).getRegex(),pe.emStrong.rDelimUnd=Ze(pe.emStrong.rDelimUnd,"g").replace(/punct/g,pe._punctuation).getRegex(),pe._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,pe._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,pe._email=/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/,pe.autolink=Ze(pe.autolink).replace("scheme",pe._scheme).replace("email",pe._email).getRegex(),pe._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,pe.tag=Ze(pe.tag).replace("comment",pe._comment).replace("attribute",pe._attribute).getRegex(),pe._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,pe._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/,pe._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,pe.link=Ze(pe.link).replace("label",pe._label).replace("href",pe._href).replace("title",pe._title).getRegex(),pe.reflink=Ze(pe.reflink).replace("label",pe._label).replace("ref",we._label).getRegex(),pe.nolink=Ze(pe.nolink).replace("ref",we._label).getRegex(),pe.reflinkSearch=Ze(pe.reflinkSearch,"g").replace("reflink",pe.reflink).replace("nolink",pe.nolink).getRegex(),pe.normal={...pe},pe.pedantic={...pe.normal,strong:{start:/^__|\*\*/,middle:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,endAst:/\*\*(?!\*)/g,endUnd:/__(?!_)/g},em:{start:/^_|\*/,middle:/^()\*(?=\S)([\s\S]*?\S)\*(?!\*)|^_(?=\S)([\s\S]*?\S)_(?!_)/,endAst:/\*(?!\*)/g,endUnd:/_(?!_)/g},link:Ze(/^!?\[(label)\]\((.*?)\)/).replace("label",pe._label).getRegex(),reflink:Ze(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",pe._label).getRegex()},pe.gfm={...pe.normal,escape:Ze(pe.escape).replace("])","~|])").getRegex(),_extended_email:/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,url:/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},pe.gfm.url=Ze(pe.gfm.url,"i").replace("email",pe.gfm._extended_email).getRegex(),pe.breaks={...pe.gfm,br:Ze(pe.br).replace("{2,}","*").getRegex(),text:Ze(pe.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()};function wy(e){return e.replace(/---/g,"—").replace(/--/g,"–").replace(/(^|[-\u2014/(\[{"\s])'/g,"$1‘").replace(/'/g,"’").replace(/(^|[-\u2014/(\[{\u2018\s])"/g,"$1“").replace(/"/g,"”").replace(/\.{3}/g,"…")}function Xd(e){let t="",n,r;const o=e.length;for(n=0;n<o;n++)r=e.charCodeAt(n),Math.random()>.5&&(r="x"+r.toString(16)),t+="&#"+r+";";return t}class $n{constructor(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||sr,this.options.tokenizer=this.options.tokenizer||new fa,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};const n={block:we.normal,inline:pe.normal};this.options.pedantic?(n.block=we.pedantic,n.inline=pe.pedantic):this.options.gfm&&(n.block=we.gfm,this.options.breaks?n.inline=pe.breaks:n.inline=pe.gfm),this.tokenizer.rules=n}static get rules(){return{block:we,inline:pe}}static lex(t,n){return new $n(n).lex(t)}static lexInline(t,n){return new $n(n).inlineTokens(t)}lex(t){t=t.replace(/\r\n|\r/g,`
|
|
97
97
|
`),this.blockTokens(t,this.tokens);let n;for(;n=this.inlineQueue.shift();)this.inlineTokens(n.src,n.tokens);return this.tokens}blockTokens(t,n=[]){this.options.pedantic?t=t.replace(/\t/g," ").replace(/^ +$/gm,""):t=t.replace(/^( *)(\t+)/gm,(a,l,c)=>l+" ".repeat(c.length));let r,o,s,i;for(;t;)if(!(this.options.extensions&&this.options.extensions.block&&this.options.extensions.block.some(a=>(r=a.call({lexer:this},t,n))?(t=t.substring(r.raw.length),n.push(r),!0):!1))){if(r=this.tokenizer.space(t)){t=t.substring(r.raw.length),r.raw.length===1&&n.length>0?n[n.length-1].raw+=`
|
|
98
98
|
`:n.push(r);continue}if(r=this.tokenizer.code(t)){t=t.substring(r.raw.length),o=n[n.length-1],o&&(o.type==="paragraph"||o.type==="text")?(o.raw+=`
|
|
99
99
|
`+r.raw,o.text+=`
|
|
@@ -104,8 +104,8 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
|
|
|
104
104
|
`+r.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=o.text):n.push(r),i=s.length!==t.length,t=t.substring(r.raw.length);continue}if(r=this.tokenizer.text(t)){t=t.substring(r.raw.length),o=n[n.length-1],o&&o.type==="text"?(o.raw+=`
|
|
105
105
|
`+r.raw,o.text+=`
|
|
106
106
|
`+r.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=o.text):n.push(r);continue}if(t){const a="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(a);break}else throw new Error(a)}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}inlineTokens(t,n=[]){let r,o,s,i=t,a,l,c;if(this.tokens.links){const d=Object.keys(this.tokens.links);if(d.length>0)for(;(a=this.tokenizer.rules.inline.reflinkSearch.exec(i))!=null;)d.includes(a[0].slice(a[0].lastIndexOf("[")+1,-1))&&(i=i.slice(0,a.index)+"["+Gd("a",a[0].length-2)+"]"+i.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(a=this.tokenizer.rules.inline.blockSkip.exec(i))!=null;)i=i.slice(0,a.index)+"["+Gd("a",a[0].length-2)+"]"+i.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;(a=this.tokenizer.rules.inline.escapedEmSt.exec(i))!=null;)i=i.slice(0,a.index+a[0].length-2)+"++"+i.slice(this.tokenizer.rules.inline.escapedEmSt.lastIndex),this.tokenizer.rules.inline.escapedEmSt.lastIndex--;for(;t;)if(l||(c=""),l=!1,!(this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some(d=>(r=d.call({lexer:this},t,n))?(t=t.substring(r.raw.length),n.push(r),!0):!1))){if(r=this.tokenizer.escape(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.tag(t)){t=t.substring(r.raw.length),o=n[n.length-1],o&&r.type==="text"&&o.type==="text"?(o.raw+=r.raw,o.text+=r.text):n.push(r);continue}if(r=this.tokenizer.link(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(r.raw.length),o=n[n.length-1],o&&r.type==="text"&&o.type==="text"?(o.raw+=r.raw,o.text+=r.text):n.push(r);continue}if(r=this.tokenizer.emStrong(t,i,c)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.codespan(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.br(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.del(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.autolink(t,Xd)){t=t.substring(r.raw.length),n.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(t,Xd))){t=t.substring(r.raw.length),n.push(r);continue}if(s=t,this.options.extensions&&this.options.extensions.startInline){let d=1/0;const f=t.slice(1);let m;this.options.extensions.startInline.forEach(function(p){m=p.call({lexer:this},f),typeof m=="number"&&m>=0&&(d=Math.min(d,m))}),d<1/0&&d>=0&&(s=t.substring(0,d+1))}if(r=this.tokenizer.inlineText(s,wy)){t=t.substring(r.raw.length),r.raw.slice(-1)!=="_"&&(c=r.raw.slice(-1)),l=!0,o=n[n.length-1],o&&o.type==="text"?(o.raw+=r.raw,o.text+=r.text):n.push(r);continue}if(t){const d="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(d);break}else throw new Error(d)}}return n}}class pa{constructor(t){this.options=t||sr}code(t,n,r){const o=(n||"").match(/\S*/)[0];if(this.options.highlight){const s=this.options.highlight(t,o);s!=null&&s!==t&&(r=!0,t=s)}return t=t.replace(/\n$/,"")+`
|
|
107
|
-
`,o?'<pre><code class="'+this.options.langPrefix+
|
|
108
|
-
`:"<pre><code>"+(r?t:
|
|
107
|
+
`,o?'<pre><code class="'+this.options.langPrefix+Rt(o)+'">'+(r?t:Rt(t,!0))+`</code></pre>
|
|
108
|
+
`:"<pre><code>"+(r?t:Rt(t,!0))+`</code></pre>
|
|
109
109
|
`}blockquote(t){return`<blockquote>
|
|
110
110
|
${t}</blockquote>
|
|
111
111
|
`}html(t){return t}heading(t,n,r,o){if(this.options.headerIds){const s=this.options.headerPrefix+o.slug(r);return`<h${n} id="${s}">${t}</h${n}>
|
|
@@ -125,8 +125,8 @@ ${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=Kd(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=Kd(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 Jd{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 Zd{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 Fn{constructor(t){this.options=t||sr,this.options.renderer=this.options.renderer||new pa,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new Jd,this.slugger=new Zd}static parse(t,n){return new Fn(n).parse(t)}static parseInline(t,n){return new Fn(n).parseInline(t)}parse(t,n=!0){let r="",o,s,i,a,l,c,d,f,m,p,v,g,x,y,w,C,E,T,S;const k=t.length;for(o=0;o<k;o++){if(p=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[p.type]&&(S=this.options.extensions.renderers[p.type].call({parser:this},p),S!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(p.type))){r+=S||"";continue}switch(p.type){case"space":continue;case"hr":{r+=this.renderer.hr();continue}case"heading":{r+=this.renderer.heading(this.parseInline(p.tokens),p.depth,Vd(this.parseInline(p.tokens,this.textRenderer)),this.slugger);continue}case"code":{r+=this.renderer.code(p.text,p.lang,p.escaped);continue}case"table":{for(f="",d="",a=p.header.length,s=0;s<a;s++)d+=this.renderer.tablecell(this.parseInline(p.header[s].tokens),{header:!0,align:p.align[s]});for(f+=this.renderer.tablerow(d),m="",a=p.rows.length,s=0;s<a;s++){for(c=p.rows[s],d="",l=c.length,i=0;i<l;i++)d+=this.renderer.tablecell(this.parseInline(c[i].tokens),{header:!1,align:p.align[i]});m+=this.renderer.tablerow(d)}r+=this.renderer.table(f,m);continue}case"blockquote":{m=this.parse(p.tokens),r+=this.renderer.blockquote(m);continue}case"list":{for(v=p.ordered,g=p.start,x=p.loose,a=p.items.length,m="",s=0;s<a;s++)w=p.items[s],C=w.checked,E=w.task,y="",w.task&&(T=this.renderer.checkbox(C),x?w.tokens.length>0&&w.tokens[0].type==="paragraph"?(w.tokens[0].text=T+" "+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=T+" "+w.tokens[0].tokens[0].text)):w.tokens.unshift({type:"text",text:T}):y+=T),y+=this.parse(w.tokens,x),m+=this.renderer.listitem(y,E,C);r+=this.renderer.list(m,v,g);continue}case"html":{r+=this.renderer.html(p.text);continue}case"paragraph":{r+=this.renderer.paragraph(this.parseInline(p.tokens));continue}case"text":{for(m=p.tokens?this.parseInline(p.tokens):p.text;o+1<k&&t[o+1].type==="text";)p=t[++o],m+=`
|
|
127
127
|
`+(p.tokens?this.parseInline(p.tokens):p.text);r+=n?this.renderer.paragraph(m):m;continue}default:{const A='Token with "'+p.type+'" type was not found.';if(this.options.silent){console.error(A);return}else throw new Error(A)}}}return r}parseInline(t,n){n=n||this.renderer;let r="",o,s,i;const a=t.length;for(o=0;o<a;o++){if(s=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[s.type]&&(i=this.options.extensions.renderers[s.type].call({parser:this},s),i!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type))){r+=i||"";continue}switch(s.type){case"escape":{r+=n.text(s.text);break}case"html":{r+=n.html(s.text);break}case"link":{r+=n.link(s.href,s.title,this.parseInline(s.tokens,n));break}case"image":{r+=n.image(s.href,s.title,s.text);break}case"strong":{r+=n.strong(this.parseInline(s.tokens,n));break}case"em":{r+=n.em(this.parseInline(s.tokens,n));break}case"codespan":{r+=n.codespan(s.text);break}case"br":{r+=n.br();break}case"del":{r+=n.del(this.parseInline(s.tokens,n));break}case"text":{r+=n.text(s.text);break}default:{const l='Token with "'+s.type+'" type was not found.';if(this.options.silent){console.error(l);return}else throw new Error(l)}}}return r}}class xs{constructor(t){this.options=t||sr}preprocess(t){return t}postprocess(t){return t}}ic(xs,"passThroughHooks",new Set(["preprocess","postprocess"]));function yy(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>"+Mt(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 Qd(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...ve.defaults,...s};const i=yy(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(vy(r),r.hooks&&(r.hooks.options=r),o){const a=r.highlight;let l;try{r.hooks&&(n=r.hooks.preprocess(n)),l=e(n,r)}catch(f){return i(f)}const c=function(f){let m;if(!f)try{r.walkTokens&&ve.walkTokens(l,r.walkTokens),m=t(l,r),r.hooks&&(m=r.hooks.postprocess(m))}catch(p){f=p}return r.highlight=a,f?i(f):o(null,m)};if(!a||a.length<3||(delete r.highlight,!l.length))return c();let d=0;ve.walkTokens(l,function(f){f.type==="code"&&(d++,setTimeout(()=>{a(f.text,f.lang,function(m,p){if(m)return c(m);p!=null&&p!==f.text&&(f.text=p,f.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(ve.walkTokens(a,r.walkTokens)).then(()=>a):a).then(a=>t(a,r)).then(a=>r.hooks?r.hooks.postprocess(a):a).catch(i);try{r.hooks&&(n=r.hooks.preprocess(n));const a=e(n,r);r.walkTokens&&ve.walkTokens(a,r.walkTokens);let l=t(a,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(a){return i(a)}}}function ve(e,t,n){return Qd($n.lex,Fn.parse)(e,t,n)}ve.options=ve.setOptions=function(e){return ve.defaults={...ve.defaults,...e},sy(ve.defaults),ve},ve.getDefaults=zd,ve.defaults=sr,ve.use=function(...e){const t=ve.defaults.extensions||{renderers:{},childTokens:{}};e.forEach(n=>{const r={...n};if(r.async=ve.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(o=>{if(!o.name)throw new Error("extension name required");if(o.renderer){const s=t.renderers[o.name];s?t.renderers[o.name]=function(...i){let a=o.renderer.apply(this,i);return a===!1&&(a=s.apply(this,i)),a}:t.renderers[o.name]=o.renderer}if(o.tokenizer){if(!o.level||o.level!=="block"&&o.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");t[o.level]?t[o.level].unshift(o.tokenizer):t[o.level]=[o.tokenizer],o.start&&(o.level==="block"?t.startBlock?t.startBlock.push(o.start):t.startBlock=[o.start]:o.level==="inline"&&(t.startInline?t.startInline.push(o.start):t.startInline=[o.start]))}o.childTokens&&(t.childTokens[o.name]=o.childTokens)}),r.extensions=t),n.renderer){const o=ve.defaults.renderer||new pa;for(const s in n.renderer){const i=o[s];o[s]=(...a)=>{let l=n.renderer[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.renderer=o}if(n.tokenizer){const o=ve.defaults.tokenizer||new fa;for(const s in n.tokenizer){const i=o[s];o[s]=(...a)=>{let l=n.tokenizer[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.tokenizer=o}if(n.hooks){const o=ve.defaults.hooks||new xs;for(const s in n.hooks){const i=o[s];xs.passThroughHooks.has(s)?o[s]=a=>{if(ve.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=ve.defaults.walkTokens;r.walkTokens=function(s){let i=[];return i.push(n.walkTokens.call(this,s)),o&&(i=i.concat(o.call(this,s))),i}}ve.setOptions(r)})},ve.walkTokens=function(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(ve,r)),r.type){case"table":{for(const o of r.header)n=n.concat(ve.walkTokens(o.tokens,t));for(const o of r.rows)for(const s of o)n=n.concat(ve.walkTokens(s.tokens,t));break}case"list":{n=n.concat(ve.walkTokens(r.items,t));break}default:ve.defaults.extensions&&ve.defaults.extensions.childTokens&&ve.defaults.extensions.childTokens[r.type]?ve.defaults.extensions.childTokens[r.type].forEach(function(o){n=n.concat(ve.walkTokens(r[o],t))}):r.tokens&&(n=n.concat(ve.walkTokens(r.tokens,t)))}return n},ve.parseInline=Qd($n.lexInline,Fn.parseInline),ve.Parser=Fn,ve.parser=Fn.parse,ve.Renderer=pa,ve.TextRenderer=Jd,ve.Lexer=$n,ve.lexer=$n.lex,ve.Tokenizer=fa,ve.Slugger=Zd,ve.Hooks=xs,ve.parse=ve,ve.options,ve.setOptions,ve.use,ve.walkTokens,ve.parseInline,Fn.parse,$n.lex;function ir({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 ve.parse=="function"?ve.parse(i):ve(i)}return typeof ve.parse=="function"?ve.parse(e):ve(e)}catch(i){return console.error("[MarkdownContent] parse error",i),`<pre class="font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words">Error rendering markdown: ${String(i)}</pre>`}},[e,n]),s=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 ef({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})}})})]})}function tf({artifact:e,idx:t=0}){const n=b.useMemo(()=>e?(Array.isArray(e.plots)?e.plots:[]).map(o=>Nu(o)).filter(o=>o!==null):[],[e]);return n.length>0?u.jsx("div",{className:"space-y-2",children:n.map((r,o)=>u.jsx(ef,{preview:r,idx:o},`${t}-plot-${o}`))}):null}const Sy="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 vs({data:e}){return Array.isArray(e)?e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?u.jsx("div",{className:Sy,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:tr(e)}):u.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:tr(e)})}function nf({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(de.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}const ha=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:oe("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));ha.displayName="Card";const ma=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:oe("flex flex-col space-y-1.5 p-6",e),...t}));ma.displayName="CardHeader";const ga=h.forwardRef(({className:e,...t},n)=>u.jsx("h3",{ref:n,className:oe("text-2xl font-semibold leading-none tracking-tight",e),...t}));ga.displayName="CardTitle";const xa=h.forwardRef(({className:e,...t},n)=>u.jsx("p",{ref:n,className:oe("text-sm text-muted-foreground",e),...t}));xa.displayName="CardDescription";const bs=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:oe("p-6 pt-0",e),...t}));bs.displayName="CardContent";const rf=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:oe("flex items-center p-6 pt-0",e),...t}));rf.displayName="CardFooter";const Cy=e=>!!e&&typeof e=="object"&&e.type==="user_choice"&&typeof e.question=="string"&&Array.isArray(e.alternatives);function va({interruptPart:e,onApprove:t,onReject:n,onSelectAlternative:r,disabled:o,isActive:s,payload:i}){const a=Cy(i)?i:null,l=(a==null?void 0:a.question)??e.title??"Approve the result?",c=a?s?"Select one of the alternatives to continue.":"Waiting for approval from another participant.":s?"Please approve or reject this action to resume the workflow.":"Waiting for approval from another participant.";let d=null;if(!a&&i!==void 0&&i!==null)if(typeof i=="string")d=u.jsx("p",{className:"text-sm leading-relaxed text-blue-800/90 dark:text-blue-200/90 whitespace-pre-wrap",children:i});else{const f=tr(i);d=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:f})}return u.jsxs(ha,{className:oe("border-blue-200 dark:border-blue-800 bg-blue-50/50 dark:bg-blue-950/10 transition-shadow",s?"shadow-md ring-1 ring-blue-300 dark:ring-blue-500/70":"opacity-80"),children:[u.jsxs(ma,{className:"pb-3",children:[u.jsx(ga,{className:"text-blue-900 dark:text-blue-100 text-base",children:l}),u.jsx(xa,{className:"text-blue-700 dark:text-blue-300 text-sm",children:c})]}),a?u.jsx(bs,{className:"pt-0 pb-3",children:u.jsx("div",{className:"space-y-2",children:a.alternatives.map(f=>u.jsx(Xe,{size:"sm",variant:"outline",onClick:()=>r==null?void 0:r(e,f),className:"w-full justify-start text-left",disabled:o||!s,children:u.jsxs("div",{className:"flex flex-col items-start gap-1",children:[u.jsx("span",{className:"font-semibold",children:f.label}),f.description?u.jsx("span",{className:"text-xs text-muted-foreground leading-snug",children:f.description}):null]})},f.id))})}):d&&u.jsx(bs,{className:"pt-0 pb-3",children:d}),!a&&u.jsx(rf,{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:o||!s,children:"Reject"}),u.jsx(Xe,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",disabled:o||!s,children:"Approve"})]})})]})}function of({className:e}){const t=b.useRef(null);return b.useEffect(()=>{let n=0;const r=()=>{if(n=(n+1)%4,t.current){const s=".".repeat(n);t.current.textContent=`Is thinking${s}`}};r();const o=setInterval(r,500);return()=>clearInterval(o)},[]),u.jsx("span",{ref:t,"aria-live":"polite",className:oe("inline-block text-xs opacity-70 ml-1",e),children:"Is thinking"})}function sf({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(ir,{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(de.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):u.jsxs(u.Fragment,{children:[u.jsx(de.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",s," chars)"]})})]})}function Ty(e,t,n){const[r,o]=b.useState(e),s=b.useRef(e),i=b.useRef(null);return b.useEffect(()=>{s.current=e;const a=()=>{o(s.current),i.current&&(clearTimeout(i.current),i.current=null)};if(!t||n<=0){a();return}return i.current&&clearTimeout(i.current),i.current=setTimeout(()=>{a()},n),()=>{i.current&&(clearTimeout(i.current),i.current=null)}},[e,t,n]),r}function af({message:e,isToolMessage:t,showToolMessages:n,toolViewMode:r,toolExpandable:o,isToolStreaming:s,contentParts:i,textContent:a,imageParts:l,fileParts:c,interruptPart:d,isStreamingMessage:f,streamingDebounceMs:m,enableStreamingMarkdownBuffer:p,renderStreamingMarkdown:v,defaultMessage:g,handleFileClick:x,uploadingFiles:y,messageRole:w,truncateUserMessages:C,userMessagePreviewLength:E,isUserExpanded:T,setIsUserExpanded:S,isCompactLayout:k,iconForeground:A,toolConfig:j,handleInterruptApprove:F,handleInterruptReject:D,handleInterruptAlternative:B,disableInterruptActions:Y,isInterruptMessage:M}){const W=b.useCallback(()=>u.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/30 rounded",children:[u.jsx(de.Loader,{className:"h-4 w-4 text-muted-foreground"}),u.jsx("span",{className:"text-sm text-muted-foreground",children:"File upload"})]}),[]),z=Ty(i,(p??!0)&&f,m??0),P=b.useMemo(()=>z.filter(_=>_.type==="text"),[z]),I=b.useMemo(()=>P.map(_=>_.text??"").join(""),[P]),q=b.useMemo(()=>{if(!v)return null;const _=Ey(I);return{stablePart:I.slice(0,_),tailPart:I.slice(_)}},[I,v]),Q=b.useMemo(()=>{if(!q)return null;const{stablePart:_,tailPart:U}=q;return!_&&!U?null:u.jsxs("div",{className:"space-y-2",children:[_?u.jsx(ir,{content:_,allowHtml:!1}):null,U?u.jsx(ir,{content:U,allowHtml:!1}):null]})},[q]),O=b.useMemo(()=>{if(!v)return z;const _=[];let U=!1;for(const Z of z){if(Z.type==="text"){U||(_.push({type:"text",text:"",__streamingMarkdownAggregate:!0}),U=!0);continue}_.push(Z)}return _},[z,v]),L=(v?O:z).filter(_=>_.type!=="interrupt"&&_.type!=="image_url"),$=()=>!l||l.length===0?null:u.jsx("div",{className:"flex flex-wrap gap-2 mb-2",children:l.map((_,U)=>{const Z=_;return u.jsx("div",{className:"relative group",children:u.jsx("img",{src:Z.url,alt:Z.alt??"Image",loading:"lazy",onClick:()=>window.open(Z.url,"_blank"),className:"h-20 w-20 object-cover rounded-md border border-border/50 cursor-pointer hover:opacity-90 transition-opacity"})},U)})}),J=b.useCallback(({part:_,i:U})=>{if(_.type==="text"){if(v)return null;const Z=_.text??"",re=Z.trim(),le=er(re);return le&&w!=="tool"?u.jsx(vs,{data:le},U):w==="user"&&C&&re.length>E?u.jsx(sf,{text:re,expanded:T,onExpandedChange:S,previewLength:E,isCompact:k},U):u.jsx(ir,{content:Z,allowHtml:!1},U)}if(_.type==="image_url")return null;if(_.type==="file"){const Z=_,re=Z.name||"file";return u.jsxs("a",{href:Z.url,onClick:le=>x(le,Z,U),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:[y[U]?u.jsx(de.Loader,{className:"h-4 w-4 animate-spin"}):null,u.jsxs("span",{className:"truncate max-w-[180px]",children:[re,y[U]?" (processing)":""]})]},U)}return null},[x,k,T,w,C,y,E,v,S]),R=a.trim().length>0||l.length>0||c.length>0||L.length>0;if(!t&&c.length>0&&!f&&!a&&l.length===0)return W();if(!t&&!R&&!f)return null;if(t){if(!n)return null;if(M&&d){const _=d.value,U=!
|
|
130
|
-
`),d=er(c);d&&typeof d=="object"&&(r=[d])}if(!r.length)return null;const s=jy(r)??r[r.length-1];if(!s)return null;const i=s.output??s.payload??s,a=Cr(i),l=nr(a);return l&&typeof l=="object"&&!Array.isArray(l)?{kind:"dict",value:l,data:l,event:s}:{kind:"generic",value:l,event:s}},[e])}const ws=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:f=!0,toolConfig:m,customStyles:p={},streamingDebounceMs:v=300,renderStreamingMarkdown:g=!0,enableStreamingMarkdownBuffer:x,onEdit:y,onRegenerate:w,onCopy:C,getInterruptOptions:E,attemptCount:T=1,attemptIndex:S=0,onSelectCheckpoint:k,attemptMetas:A=[]}){const[j,F]=b.useState(!1),[D,B]=b.useState(!1),{currentThreadId:Y}=yr(),{respondToInterrupt:M}=ro(),[W,X]=b.useState(!1),z=l==="phone"||l==="half-screen",P=t.role,I=P==="interrupt",q=P==="tool"||I,O=!(t.role==="default_message")&&t.expandable!==void 0?t.expandable!==!1:!0,{toolRenderers:G,toolArtifactRenderers:L,getToolExpandable:$}=m??{},J=b.useMemo(()=>!$||t.role!=="tool"?!1:$(t),[$,t.id,t.role]),[R,_]=b.useState(J?"preview":"expanded");b.useEffect(()=>{_(J?"preview":"expanded")},[J,t.id]);const U=b.useMemo(()=>t.role==="default_message"?t:null,[t]),Z=!!U,re=!(r&&P!=="user"),{uploadingFiles:le,handleFileClick:ke,fileViewerOpen:ye,currentFileInfo:_e,closeFileViewer:ze}=uf({allowFileOpen:re,currentThreadId:Y}),$e=b.useMemo(()=>{switch(P){case"user":return"text-[hsl(var(--chat-bubble-user-text))]";case"assistant":return"text-[hsl(var(--chat-bubble-ai-text))]";case"interrupt":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))]"}},[P]),Ge=df(t,U),{contentParts:He,imageParts:nt,fileParts:ft,textContent:ct,toolMeta:Ue,toolRaw:Re,isToolStreaming:Ve,interruptParts:Ne}=Ge,Ke=x??v!==0,Ye=b.useMemo(()=>Ne.length?Ne[0]:null,[Ne]),Ct=b.useCallback(async()=>{const se=q?Re:ct;async function ae(me){if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function"){await navigator.clipboard.writeText(me);return}if(navigator.clipboard&&typeof navigator.clipboard.write=="function"&&typeof ClipboardItem<"u"){const st=new Blob([me],{type:"text/plain"});await navigator.clipboard.write([new ClipboardItem({"text/plain":st})]);return}throw new Error("Clipboard API not supported in this context.")}try{await ae(se),F(!0),setTimeout(()=>F(!1),2e3),C==null||C(se)}catch(me){console.error("Failed to copy:",me)}},[q,Re,ct,C]),Ze=b.useCallback(async(se,ae)=>{if(!Ye)return;if(!$i(Ye.id)){console.warn("Interrupt part missing id",Ye);return}X(!0);try{const st=E==null?void 0:E(t);await M(se,ae,st)}catch(st){console.error("Failed to respond to interrupt:",st)}finally{X(!1)}},[Ye,M]),Tt=b.useCallback(()=>Ze(!0),[Ze]),pt=b.useCallback(()=>Ze(!1),[Ze]),wt=b.useCallback((se,ae)=>{if(!ae)return;const me={alternativeId:ae.id??ae.label??void 0,alternativeLabel:ae.label};Ze(!0,me)},[Ze]),At=b.useCallback(()=>{if(!y||!t.id)return;const se=(q?Re:ct)??"",ae="type"in t&&t.type==="default_message"?void 0:{checkpointId:t.checkpointId??null,checkpointNs:t.checkpointNs??null};y(t.id,se,ae)},[y,q,Re,ct,t]),Pt=b.useCallback(()=>{w==null||w(n)},[w,n]),ht=b.useCallback(()=>{const ae=oe(z?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",$e);switch(P){case"user":return u.jsx(de.User,{className:ae});case"assistant":return u.jsx(de.Bot,{className:ae});case"tool":return u.jsx(de.Wrench,{className:ae});case"interrupt":return u.jsx(de.Bot,{className:ae});default:return u.jsx(de.Bot,{className:ae})}},[z,$e,P]),mt=b.useCallback(()=>{const se="group relative mb-4 flex w-full";switch(P){case"user":return oe(se,"justify-end");case"assistant":case"tool":case"system":case"interrupt":return oe(se,"justify-start");default:return se}},[P]),Ht=b.useCallback(()=>{const se=oe("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",z&&"px-3 py-2 text-sm");if(Z)return oe(se,"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(P){case"user":return oe(se,"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(se,"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":case"interrupt":return oe(se,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return oe(se,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return oe(se,"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")}},[z,Z,P]),We=J&&!I&&O,Le=b.useCallback(()=>{We&&_(se=>se==="expanded"?"preview":"expanded")},[We]),kt=I?"expanded":R,ut=(f||I)&&O,_t=u.jsx(af,{message:t,isToolMessage:q,showToolMessages:ut,toolViewMode:kt,toolExpandable:J,toolConfig:{toolRenderers:G,toolArtifactRenderers:L,getToolExpandable:$},isToolStreaming:Ve,contentParts:He,textContent:ct,imageParts:nt,fileParts:ft,isStreamingMessage:r,defaultMessage:U,enableStreamingMarkdownBuffer:Ke,renderStreamingMarkdown:g,streamingDebounceMs:v,handleFileClick:ke,uploadingFiles:le,messageRole:P,truncateUserMessages:c,userMessagePreviewLength:d,isUserExpanded:D,setIsUserExpanded:B,isCompactLayout:z,iconForeground:$e,interruptPart:Ye,handleInterruptApprove:Tt,handleInterruptReject:pt,handleInterruptAlternative:wt,disableInterruptActions:W,isInterruptMessage:I}),xe=b.useMemo(()=>U?"Assistant":Tu(t),[U,t]),De=ht(),Fe=P==="user"&&(T??1)>1&&typeof k=="function",rt=(A==null?void 0:A.length)??0,Qe=rt>0&&S<rt-1?A[S+1]:void 0,ot=rt>0&&S>0?A[S-1]:void 0,gt=b.useCallback(()=>{!Qe||!k||k(Qe.id,void 0,!!Qe.isLatestAttempt)},[Qe,k]),K=b.useCallback(()=>{!ot||!k||k(ot.id,void 0,!!ot.isLatestAttempt)},[ot,k]);return q&&!f?null:Z&&U?u.jsx("div",{className:oe(mt(),p.container),children:u.jsxs("div",{className:oe(Ht(),p.content),children:[u.jsxs("div",{className:"flex items-center gap-2 mb-2 pb-2 border-b border-current/10",children:[u.jsx(de.Bot,{className:oe("h-4 w-4",$e)}),a&&u.jsx("span",{className:"font-medium text-sm",children:"Assistant"})]}),u.jsx(ir,{content:U.content,className:"text-current"})]})}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:oe(mt(),p.container),children:u.jsxs("div",{className:oe(Ht(),p.content),children:[u.jsx(cf,{showTimestamp:i,showAgentName:a,isToolMessage:q,iconForeground:$e,agentName:xe,messageIcon:De,customHeaderClass:p.header,customActionsClass:p.actions,isCompactLayout:z,showActions:s,isEditing:o,messageRole:P,toolViewMode:kt,toolExpandable:J,isInterruptMessage:I,toolMeta:Ue,onToggleToolView:Le,onCopy:Ct,onEdit:At,onRegenerate:Pt,showCheckpointControls:Fe,attemptCount:T,attemptIndex:S,handleOlderAttemptSelect:gt,handleNewerAttemptSelect:K,messageCreatedAt:t.createdAt,copied:j}),u.jsx("div",{className:"relative",children:_t}),!(i||a||q)&&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",p.actions),children:[u.jsx(Xe,{variant:"ghost",size:"sm",onClick:()=>Ct(),className:oe("h-6 w-6 p-0 hover:bg-background/50 text-current",z&&"h-5 w-5"),children:u.jsx(de.Copy,{className:oe(j?"text-success":"text-current",z?"h-3 w-3":"h-4 w-4")})}),P==="user"&&y&&u.jsx(Xe,{variant:"ghost",size:"sm",onClick:At,className:oe("h-6 w-6 p-0 hover:bg-background/50 text-current",z&&"h-5 w-5"),children:u.jsx(de.Edit,{className:oe("text-current",z?"h-3 w-3":"h-4 w-4")})}),P==="assistant"&&w&&u.jsx(Xe,{variant:"ghost",size:"sm",onClick:Pt,className:oe("h-6 w-6 p-0 hover:bg-background/50 text-current",z&&"h-5 w-5"),children:u.jsx(de.RotateCcw,{className:oe("text-current",z?"h-3 w-3":"h-4 w-4")})})]})]})}),_e&&u.jsx(oy,{isOpen:ye,onClose:ze,fileId:_e.id,fileName:_e.name,mimeType:_e.mimeType})]})},(e,t)=>{var l,c,d,f,m,p,v,g;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&Fi(e.message)===Fi(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateUserMessages","userMessagePreviewLength","showToolMessages","toolConfig"].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)===((f=t.customStyles)==null?void 0:f.content)&&((m=e.customStyles)==null?void 0:m.actions)===((p=t.customStyles)==null?void 0:p.actions)&&((v=e.customStyles)==null?void 0:v.header)===((g=t.customStyles)==null?void 0:g.header);if(!o||!s)return!1;const i=Bi(e.message),a=Bi(t.message);return i.length===a.length});ws.displayName="MessageComponent";const ys=0,Bn=1,Pr=2,hf=4;function mf(e){return()=>e}function Py(e){e()}function gf(e,t){return n=>e(t(n))}function xf(e,t){return()=>e(t)}function _y(e,t){return n=>e(t,n)}function ba(e){return e!==void 0}function Ry(...e){return()=>{e.map(Py)}}function _r(){}function Ss(e,t){return t(e),e}function My(e,t){return t(e)}function it(...e){return e}function Je(e,t){return e(Bn,t)}function Pe(e,t){e(ys,t)}function wa(e){e(Pr)}function bt(e){return e(hf)}function ge(e,t){return Je(e,_y(t,ys))}function dn(e,t){const n=e(Bn,r=>{n(),t(r)});return n}function vf(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function bf(e,t){return e===t}function at(e=bf){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function Ce(e){return t=>n=>{e(n)&&t(n)}}function fe(e){return t=>gf(t,e)}function bn(e){return t=>()=>{t(e)}}function ne(e,...t){const n=Oy(...t);return(r,o)=>{switch(r){case Pr:wa(e);return;case Bn:return Je(e,n(o))}}}function wn(e,t){return n=>r=>{n(t=e(t,r))}}function ar(e){return t=>n=>{e>0?e--:t(n)}}function Nn(e){let t=null,n;return r=>o=>{t=o,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function Oe(...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);Je(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 Oy(...e){return t=>e.reduceRight(My,t)}function Dy(e){let t,n;const r=()=>t==null?void 0:t();return function(o,s){switch(o){case Bn:return s?n===s?void 0:(r(),n=s,t=Je(e,s),t):(r(),_r);case Pr:r(),n=null;return}}}function ie(e){let t=e;const n=Be();return(r,o)=>{switch(r){case ys:t=o;break;case Bn:{o(t);break}case hf:return t}return n(r,o)}}function Ot(e,t){return Ss(ie(t),n=>ge(e,n))}function Be(){const e=[];return(t,n)=>{switch(t){case ys:e.slice().forEach(r=>{r(n)});return;case Pr:e.splice(0,e.length);return;case Bn:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}}}function Zt(e){return Ss(Be(),t=>ge(e,t))}function qe(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:Ly(),singleton:n}}const Ly=()=>Symbol();function $y(e){const t=new Map,n=({constructor:r,dependencies:o,id:s,singleton:i})=>{if(i&&t.has(s))return t.get(s);const a=r(o.map(l=>n(l)));return i&&t.set(s,a),a};return n(e)}function St(...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);Je(s,l=>{n[i]=l,r=r|a,r===o&&Pe(t,n)})}),function(s,i){switch(s){case Pr:{wa(t);return}case Bn:return r===o&&i(n),Je(t,i)}}}function Se(e,t=bf){return ne(e,at(t))}function ya(...e){return function(t,n){switch(t){case Pr:return;case Bn:return Ry(...e.map(r=>Je(r,n)))}}}var qt=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(qt||{});const Fy={0:"debug",3:"error",1:"log",2:"warn"},By=()=>typeof globalThis>"u"?window:globalThis,zn=qe(()=>{const e=ie(3);return{log:ie((t,n,r=1)=>{var o;const s=(o=By().VIRTUOSO_LOG_LEVEL)!=null?o:bt(e);r>=s&&console[Fy[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0});function lr(e,t,n){return Sa(e,t,n).callbackRef}function Sa(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 zy(e,t,n,r,o,s,i,a,l){const c=b.useCallback(d=>{const f=Hy(d.children,t,a?"offsetWidth":"offsetHeight",o);let m=d.parentElement;for(;!m.dataset.virtuosoScroller;)m=m.parentElement;const p=m.lastElementChild.dataset.viewportType==="window";let v;p&&(v=m.ownerDocument.defaultView);const g=i?a?i.scrollLeft:i.scrollTop:p?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:p?a?v.document.documentElement.scrollWidth:v.document.documentElement.scrollHeight:a?m.scrollWidth:m.scrollHeight,y=i?a?i.offsetWidth:i.offsetHeight:p?a?v.innerWidth:v.innerHeight:a?m.offsetWidth:m.offsetHeight;r({scrollHeight:x,scrollTop:Math.max(g,0),viewportHeight:y}),s==null||s(a?wf("column-gap",getComputedStyle(d).columnGap,o):wf("row-gap",getComputedStyle(d).rowGap,o)),f!==null&&e(f)},[e,t,o,s,i,r,a]);return Sa(c,n,l)}function Hy(e,t,n,r){const o=e.length;if(o===0)return null;const s=[];for(let i=0;i<o;i++){const a=e.item(i);if(a.dataset.index===void 0)continue;const 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},qt.ERROR),d===c)continue;const f=s[s.length-1];s.length===0||f.size!==d||f.endIndex!==l-1?s.push({endIndex:l,size:d,startIndex:l}):s[s.length-1].endIndex++}return s}function wf(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,qt.WARN),t==="normal"?0:parseInt(t??"0",10)}function yf(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 f,m;if(t){const p=t.getBoundingClientRect(),v=c.top-p.top;m=p.height-Math.max(0,v),f=v+t.scrollTop}else{const p=i.current.ownerDocument.defaultView;m=p.innerHeight-Math.max(0,c.top),f=c.top+p.scrollY}r.current={offsetTop:f,visibleHeight:m,visibleWidth:d},e(r.current)},[e,t]),{callbackRef:s,ref:i}=Sa(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 Bt=qe(()=>{const e=Be(),t=Be(),n=ie(0),r=Be(),o=ie(0),s=Be(),i=Be(),a=ie(0),l=ie(0),c=ie(0),d=ie(0),f=Be(),m=Be(),p=ie(!1),v=ie(!1),g=ie(!1);return ge(ne(e,fe(({scrollTop:x})=>x)),t),ge(ne(e,fe(({scrollHeight:x})=>x)),i),ge(t,o),{deviation:n,fixedFooterHeight:c,fixedHeaderHeight:l,footerHeight:d,headerHeight:a,horizontalDirection:v,scrollBy:m,scrollContainerState:e,scrollHeight:i,scrollingInProgress:p,scrollTo:f,scrollTop:t,skipAnimationFrameInResizeObserver:g,smoothScrollTargetReached:r,statefulScrollTop:o,viewportHeight:s}},[],{singleton:!0}),uo={lvl:0};function Sf(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 tt(e){return e===uo}function fo(e,t){if(!tt(e))return t===e.k?e.v:t<e.k?fo(e.l,t):fo(e.r,t)}function fn(e,t,n="k"){if(tt(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 Qt(e,t,n){return tt(e)?kf(t,n,1):t===e.k?Nt(e,{k:t,v:n}):t<e.k?Ef(Nt(e,{l:Qt(e.l,t,n)})):Ef(Nt(e,{r:Qt(e.r,t,n)}))}function Rr(){return uo}function Cs(e,t,n){if(tt(e))return[];const r=fn(e,t)[0];return Uy(Ta(e,r,n))}function Ca(e,t){if(tt(e))return uo;const{k:n,l:r,r:o}=e;if(t===n){if(tt(r))return o;if(tt(o))return r;{const[s,i]=Tf(r);return Ts(Nt(e,{k:s,l:Cf(r),v:i}))}}else return t<n?Ts(Nt(e,{l:Ca(r,t)})):Ts(Nt(e,{r:Ca(o,t)}))}function cr(e){return tt(e)?[]:[...cr(e.l),{k:e.k,v:e.v},...cr(e.r)]}function Ta(e,t,n){if(tt(e))return[];const{k:r,l:o,r:s,v:i}=e;let a=[];return r>t&&(a=a.concat(Ta(o,t,n))),r>=t&&r<=n&&a.push({k:r,v:i}),r<=n&&(a=a.concat(Ta(s,t,n))),a}function Ts(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(ka(t))return If(Nt(e,{lvl:n-1}));if(!tt(t)&&!tt(t.r))return Nt(t.r,{l:Nt(t,{r:t.r.l}),lvl:n,r:Nt(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(ka(e))return Ea(Nt(e,{lvl:n-1}));if(!tt(r)&&!tt(r.l)){const o=r.l,s=ka(o)?r.lvl-1:r.lvl;return Nt(o,{l:Nt(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:Ea(Nt(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function Nt(e,t){return kf(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 Cf(e){return tt(e.r)?e.l:Ts(Nt(e,{r:Cf(e.r)}))}function ka(e){return tt(e)||e.lvl>e.r.lvl}function Tf(e){return tt(e.r)?[e.k,e.v]:Tf(e.r)}function kf(e,t,n,r=uo,o=uo){return{k:e,l:r,lvl:n,r:o,v:t}}function Ef(e){return Ea(If(e))}function If(e){const{l:t}=e;return!tt(t)&&t.lvl===e.lvl?Nt(t,{r:Nt(e,{l:t.r})}):e}function Ea(e){const{lvl:t,r:n}=e;return!tt(n)&&!tt(n.r)&&n.lvl===t&&n.r.lvl===t?Nt(n,{l:Nt(e,{r:n.l}),lvl:t+1}):e}function Uy(e){return Sf(e,({k:t,v:n})=>({index:t,value:n}))}function Nf(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function po(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const Ia=qe(()=>({recalcInProgress:ie(!1)}),[],{singleton:!0});function Af(e,t,n){return e[ks(e,t,n)]}function ks(e,t,n,r=0){let o=e.length-1;for(;r<=o;){const s=Math.floor((r+o)/2),i=e[s],a=n(i,t);if(a===0)return s;if(a===-1){if(o-r<2)return s-1;o=s-1}else{if(o===r)return s;r=s+1}}throw new Error(`Failed binary finding record in array - ${e.join(",")}, searched for ${t}`)}function Wy(e,t,n,r){const o=ks(e,t,r),s=ks(e,n,r,o);return e.slice(o,s+1)}function Hn(e,t){return Math.round(e.getBoundingClientRect()[t])}function Es(e){return!tt(e.groupOffsetTree)}function Na({index:e},t){return t===e?0:t<e?-1:1}function Vy(){return{groupIndices:[],groupOffsetTree:Rr(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Rr()}}function Ky(e,t){let n=tt(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),tt(e)){e=Qt(e,0,s);continue}const a=Cs(e,i-1,o+1);if(a.some(Qy(r)))continue;let l=!1,c=!1;for(const{end:d,start:f,value:m}of a)l?(o>=f||s===m)&&(e=Ca(e,f)):(c=m!==s,l=!0),d>o&&o>=f&&m!==s&&(e=Qt(e,o+1,m));c&&(e=Qt(e,i,s))}return[e,n]}function qy(e){return typeof e.groupIndex<"u"}function Gy({offset:e},t){return t===e?0:t<e?-1:1}function ho(e,t,n){if(t.length===0)return 0;const{index:r,offset:o,size:s}=Af(t,e,Na),i=e-r,a=s*i+(i-1)*n+o;return a>0?a+n:a}function jf(e,t){if(!Es(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function Pf(e,t,n){if(qy(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=jf(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function Yy(e,t,n,r=0){return r>0&&(t=Math.max(t,Af(e,r,Na).offset)),Sf(Wy(e,t,n,Gy),Zy)}function Xy(e,[t,n,r,o]){t.length>0&&r("received item sizes",t,qt.DEBUG);const s=e.sizeTree;let i=s,a=0;if(n.length>0&&tt(s)&&t.length===2){const m=t[0].size,p=t[1].size;i=n.reduce((v,g)=>Qt(Qt(v,g,m),g+1,p),i)}else[i,a]=Ky(i,t);if(i===s)return e;const{lastIndex:l,lastOffset:c,lastSize:d,offsetTree:f}=Aa(e.offsetTree,a,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((m,p)=>Qt(m,p,ho(p,f,o)),Rr()),lastIndex:l,lastOffset:c,lastSize:d,offsetTree:f,sizeTree:i}}function Jy(e){return cr(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 _f(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 Aa(e,t,n,r){let o=e,s=0,i=0,a=0,l=0;if(t!==0){l=ks(o,t-1,Na),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 Cs(n,t,1/0)){const f=c-s,m=f*i+a+f*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 Zy(e){return{index:e.index,value:e}}function Qy(e){const{endIndex:t,size:n,startIndex:r}=e;return o=>o.start===r&&(o.end===t||o.end===1/0)&&o.value===n}const e0={offsetHeight:"height",offsetWidth:"width"},yn=qe(([{log:e},{recalcInProgress:t}])=>{const n=Be(),r=Be(),o=Ot(r,0),s=Be(),i=Be(),a=ie(0),l=ie([]),c=ie(void 0),d=ie(void 0),f=ie((T,S)=>Hn(T,e0[S])),m=ie(void 0),p=ie(0),v=Vy(),g=Ot(ne(n,Oe(l,e,p),wn(Xy,v),at()),v),x=Ot(ne(l,at(),wn((T,S)=>({current:S,prev:T.current}),{current:[],prev:[]}),fe(({prev:T})=>T)),[]);ge(ne(l,Ce(T=>T.length>0),Oe(g,p),fe(([T,S,k])=>{const A=T.reduce((j,F,D)=>Qt(j,F,ho(F,S.offsetTree,k)||D),Rr());return{...S,groupIndices:T,groupOffsetTree:A}})),g),ge(ne(r,Oe(g),Ce(([T,{lastIndex:S}])=>T<S),fe(([T,{lastIndex:S,lastSize:k}])=>[{endIndex:S,size:k,startIndex:T}])),n),ge(c,d);const y=Ot(ne(c,fe(T=>T===void 0)),!0);ge(ne(d,Ce(T=>T!==void 0&&tt(bt(g).sizeTree)),fe(T=>[{endIndex:0,size:T,startIndex:0}])),n);const w=Zt(ne(n,Oe(g),wn(({sizes:T},[S,k])=>({changed:k!==T,sizes:k}),{changed:!1,sizes:v}),fe(T=>T.changed)));Je(ne(a,wn((T,S)=>({diff:T.prev-S,prev:S}),{diff:0,prev:0}),fe(T=>T.diff)),T=>{const{groupIndices:S}=bt(g);if(T>0)Pe(t,!0),Pe(s,T+_f(T,S));else if(T<0){const k=bt(x);k.length>0&&(T-=_f(-T,k)),Pe(i,T)}}),Je(ne(a,Oe(e)),([T,S])=>{T<0&&S("`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},qt.ERROR)});const C=Zt(s);ge(ne(s,Oe(g),fe(([T,S])=>{const k=S.groupIndices.length>0,A=[],j=S.lastSize;if(k){const F=fo(S.sizeTree,0);let D=0,B=0;for(;D<T;){const M=S.groupIndices[B],W=S.groupIndices.length===B+1?1/0:S.groupIndices[B+1]-M-1;A.push({endIndex:M,size:F,startIndex:M}),A.push({endIndex:M+1+W-1,size:j,startIndex:M+1}),B++,D+=W+1}const Y=cr(S.sizeTree);return D!==T&&Y.shift(),Y.reduce((M,{k:W,v:X})=>{let z=M.ranges;return M.prevSize!==0&&(z=[...M.ranges,{endIndex:W+T-1,size:M.prevSize,startIndex:M.prevIndex}]),{prevIndex:W+T,prevSize:X,ranges:z}},{prevIndex:T,prevSize:0,ranges:A}).ranges}return cr(S.sizeTree).reduce((F,{k:D,v:B})=>({prevIndex:D+T,prevSize:B,ranges:[...F.ranges,{endIndex:D+T-1,size:F.prevSize,startIndex:F.prevIndex}]}),{prevIndex:0,prevSize:j,ranges:[]}).ranges})),n);const E=Zt(ne(i,Oe(g,p),fe(([T,{offsetTree:S},k])=>{const A=-T;return ho(A,S,k)})));return ge(ne(i,Oe(g,p),fe(([T,S,k])=>{if(S.groupIndices.length>0){if(tt(S.sizeTree))return S;let A=Rr();const j=bt(x);let F=0,D=0,B=0;for(;F<-T;){B=j[D];const Y=j[D+1]-B-1;D++,F+=Y+1}if(A=cr(S.sizeTree).reduce((Y,{k:M,v:W})=>Qt(Y,Math.max(0,M+T),W),A),F!==-T){const Y=fo(S.sizeTree,B);A=Qt(A,0,Y);const M=fn(S.sizeTree,-T+1)[1];A=Qt(A,1,M)}return{...S,sizeTree:A,...Aa(S.offsetTree,0,A,k)}}else{const A=cr(S.sizeTree).reduce((j,{k:F,v:D})=>Qt(j,Math.max(0,F+T),D),Rr());return{...S,sizeTree:A,...Aa(S.offsetTree,0,A,k)}}})),g),{beforeUnshiftWith:C,data:m,defaultItemSize:d,firstItemIndex:a,fixedItemSize:c,gap:p,groupIndices:l,itemSize:f,listRefresh:w,shiftWith:i,shiftWithOffset:E,sizeRanges:n,sizes:g,statefulTotalCount:o,totalCount:r,trackItemSizes:y,unshiftWith:s}},it(zn,Ia),{singleton:!0});function t0(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const Rf=qe(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=Be(),i=Be(),a=Zt(ne(s,fe(t0)));return ge(ne(a,fe(l=>l.totalCount)),n),ge(ne(a,fe(l=>l.groupIndices)),e),ge(ne(St(o,t,r),Ce(([l,c])=>Es(c)),fe(([l,c,d])=>fn(c.groupOffsetTree,Math.max(l-d,0),"v")[0]),at(),fe(l=>[l])),i),{groupCounts:s,topItemsIndexes:i}},it(yn,Bt)),Un=qe(([{log:e}])=>{const t=ie(!1),n=Zt(ne(t,Ce(r=>r),at()));return Je(t,r=>{r&&bt(e)("props updated",{},qt.DEBUG)}),{didMount:n,propsReady:t}},it(zn),{singleton:!0}),n0=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function Mf(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!n0)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const mo=qe(([{gap:e,listRefresh:t,sizes:n,totalCount:r},{fixedFooterHeight:o,fixedHeaderHeight:s,footerHeight:i,headerHeight:a,scrollingInProgress:l,scrollTo:c,smoothScrollTargetReached:d,viewportHeight:f},{log:m}])=>{const p=Be(),v=Be(),g=ie(0);let x=null,y=null,w=null;function C(){x&&(x(),x=null),w&&(w(),w=null),y&&(clearTimeout(y),y=null),Pe(l,!1)}return ge(ne(p,Oe(n,f,r,g,a,i,m),Oe(e,s,o),fe(([[E,T,S,k,A,j,F,D],B,Y,M])=>{const W=Mf(E),{align:X,behavior:z,offset:P}=W,I=k-1,q=Pf(W,T,I);let Q=ho(q,T.offsetTree,B)+j;X==="end"?(Q+=Y+fn(T.sizeTree,q)[1]-S+M,q===I&&(Q+=F)):X==="center"?Q+=(Y+fn(T.sizeTree,q)[1]-S+M)/2:Q-=A,P&&(Q+=P);const O=G=>{C(),G?(D("retrying to scroll to",{location:E},qt.DEBUG),Pe(p,E)):(Pe(v,!0),D("list did not change, scroll successful",{},qt.DEBUG))};if(C(),z==="smooth"){let G=!1;w=Je(t,L=>{G=G||L}),x=dn(d,()=>{O(G)})}else x=dn(ne(t,r0(150)),O);return y=setTimeout(()=>{C()},1200),Pe(l,!0),D("scrolling from index to",{behavior:z,index:q,top:Q},qt.DEBUG),{behavior:z,top:Q}})),c),{scrollTargetReached:v,scrollToIndex:p,topListHeight:g}},it(yn,Bt,zn),{singleton:!0});function r0(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function ja(e,t){e==0?t():requestAnimationFrame(()=>{ja(e-1,t)})}function Pa(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const go=qe(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:s},{didMount:i}])=>{const a=ie(!0),l=ie(0),c=ie(!0);return ge(ne(i,Oe(l),Ce(([d,f])=>!!f),bn(!1)),a),ge(ne(i,Oe(l),Ce(([d,f])=>!!f),bn(!1)),c),Je(ne(St(t,i),Oe(a,n,e,c),Ce(([[,d],f,{sizeTree:m},p,v])=>d&&(!tt(m)||ba(p))&&!f&&!v),Oe(l)),([,d])=>{dn(o,()=>{Pe(c,!0)}),ja(4,()=>{dn(r,()=>{Pe(a,!0)}),Pe(s,d)})}),{initialItemFinalLocationReached:c,initialTopMostItemIndex:l,scrolledToInitialItem:a}},it(yn,Bt,mo,Un),{singleton:!0});function Of(e,t){return Math.abs(e-t)<1.01}const xo="up",vo="down",o0="none",s0={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},i0=0,bo=qe(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=ie(!1),a=ie(!0),l=Be(),c=Be(),d=ie(4),f=ie(i0),m=Ot(ne(ya(ne(Se(o),ar(1),bn(!0)),ne(Se(o),ar(1),bn(!1),vf(100))),at()),!1),p=Ot(ne(ya(ne(n,bn(!0)),ne(n,bn(!1),vf(200))),at()),!1);ge(ne(St(Se(o),Se(f)),fe(([w,C])=>w<=C),at()),a),ge(ne(a,Nn(50)),c);const v=Zt(ne(St(r,Se(s),Se(t),Se(e),Se(d)),wn((w,[{scrollHeight:C,scrollTop:E},T,S,k,A])=>{const j=E+T-C>-A,F={scrollHeight:C,scrollTop:E,viewportHeight:T};if(j){let B,Y;return E>w.state.scrollTop?(B="SCROLLED_DOWN",Y=w.state.scrollTop-E):(B="SIZE_DECREASED",Y=w.state.scrollTop-E||w.scrollTopDelta),{atBottom:!0,atBottomBecause:B,scrollTopDelta:Y,state:F}}let D;return F.scrollHeight>w.state.scrollHeight?D="SIZE_INCREASED":T<w.state.viewportHeight?D="VIEWPORT_HEIGHT_DECREASING":E<w.state.scrollTop?D="SCROLLING_UPWARDS":D="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:D,state:F}},s0),at((w,C)=>w&&w.atBottom===C.atBottom))),g=Ot(ne(r,wn((w,{scrollHeight:C,scrollTop:E,viewportHeight:T})=>{if(Of(w.scrollHeight,C))return{changed:!1,jump:0,scrollHeight:C,scrollTop:E};{const S=C-(E+T)<1;return w.scrollTop!==E&&S?{changed:!0,jump:w.scrollTop-E,scrollHeight:C,scrollTop:E}:{changed:!0,jump:0,scrollHeight:C,scrollTop:E}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),Ce(w=>w.changed),fe(w=>w.jump)),0);ge(ne(v,fe(w=>w.atBottom)),i),ge(ne(i,Nn(50)),l);const x=ie(vo);ge(ne(r,fe(({scrollTop:w})=>w),at(),wn((w,C)=>bt(p)?{direction:w.direction,prevScrollTop:C}:{direction:C<w.prevScrollTop?xo:vo,prevScrollTop:C},{direction:vo,prevScrollTop:0}),fe(w=>w.direction)),x),ge(ne(r,Nn(50),bn(o0)),x);const y=ie(0);return ge(ne(m,Ce(w=>!w),bn(0)),y),ge(ne(o,Nn(100),Oe(m),Ce(([w,C])=>!!C),wn(([w,C],[E])=>[C,E],[0,0]),fe(([w,C])=>C-w)),y),{atBottomState:v,atBottomStateChange:l,atBottomThreshold:d,atTopStateChange:c,atTopThreshold:f,isAtBottom:i,isAtTop:a,isScrolling:m,lastJumpDueToItemResize:g,scrollDirection:x,scrollVelocity:y}},it(Bt)),Is="top",Ns="bottom",Df="none";function Lf(e,t,n){return typeof e=="number"?n===xo&&t===Is||n===vo&&t===Ns?e:0:n===xo?t===Is?e.main:e.reverse:t===Ns?e.main:e.reverse}function $f(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const _a=qe(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=Be(),i=ie(0),a=ie(0),l=ie(0),c=Ot(ne(St(Se(r),Se(o),Se(n),Se(s,po),Se(l),Se(i),Se(t),Se(e),Se(a)),fe(([d,f,m,[p,v],g,x,y,w,C])=>{const E=d-w,T=x+y,S=Math.max(m-E,0);let k=Df;const A=$f(C,Is),j=$f(C,Ns);return p-=w,p+=m+y,v+=m+y,v-=w,p>d+T-A&&(k=xo),v<d-S+f+j&&(k=vo),k!==Df?[Math.max(E-m-Lf(g,Is,k)-A,0),E-S-y+f+Lf(g,Ns,k)+j]:null}),Ce(d=>d!=null),at(po)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:l,topListHeight:i,visibleRange:c}},it(Bt),{singleton:!0});function a0(e,t,n){if(Es(t)){const r=jf(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 Ra={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function As(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 f=n-i,m=a+f*l+(f-1)*r,p=c,v=m-d;return{bottom:d,firstItemIndex:s,items:Bf(e,o,s),offsetBottom:v,offsetTop:c,top:p,topItems:Bf(t,o,s),topListHeight:t.reduce((g,x)=>x.size+g,0),totalCount:n}}function Ff(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=Pa(t,a),c=Array.from({length:a}).map((d,f)=>({data:s[f+l],index:f+l,offset:0,size:0}));return As(c,[],a,o,n,r)}function Bf(e,t,n){if(e.length===0)return[];if(!Es(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=Cs(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 ur=qe(([{data:e,firstItemIndex:t,gap:n,sizes:r,totalCount:o},s,{listBoundary:i,topListHeight:a,visibleRange:l},{initialTopMostItemIndex:c,scrolledToInitialItem:d},{topListHeight:f},m,{didMount:p},{recalcInProgress:v}])=>{const g=ie([]),x=ie(0),y=Be();ge(s.topItemsIndexes,g);const w=Ot(ne(St(p,v,Se(l,po),Se(o),Se(r),Se(c),d,Se(g),Se(t),Se(n),e),Ce(([S,k,,A,,,,,,,j])=>{const F=j&&j.length!==A;return S&&!k&&!F}),fe(([,,[S,k],A,j,F,D,B,Y,M,W])=>{const X=j,{offsetTree:z,sizeTree:P}=X,I=bt(x);if(A===0)return{...Ra,totalCount:A};if(S===0&&k===0)return I===0?{...Ra,totalCount:A}:Ff(I,F,j,Y,M,W||[]);if(tt(P))return I>0?null:As(a0(Pa(F,A),X,W),[],A,M,X,Y);const q=[];if(B.length>0){const $=B[0],J=B[B.length-1];let R=0;for(const _ of Cs(P,$,J)){const U=_.value,Z=Math.max(_.start,$),re=Math.min(_.end,J);for(let le=Z;le<=re;le++)q.push({data:W==null?void 0:W[le],index:le,offset:R,size:U}),R+=U}}if(!D)return As([],q,A,M,X,Y);const Q=B.length>0?B[B.length-1]+1:0,O=Yy(z,S,k,Q);if(O.length===0)return null;const G=A-1,L=Ss([],$=>{for(const J of O){const R=J.value;let _=R.offset,U=J.start;const Z=R.size;if(R.offset<S){U+=Math.floor((S-R.offset+M)/(Z+M));const le=U-J.start;_+=le*Z+le*M}U<Q&&(_+=(Q-U)*Z,U=Q);const re=Math.min(J.end,G);for(let le=U;le<=re&&!(_>=k);le++)$.push({data:W==null?void 0:W[le],index:le,offset:_,size:Z}),_+=Z+M}});return As(L,q,A,M,X,Y)}),Ce(S=>S!==null),at()),Ra);ge(ne(e,Ce(ba),fe(S=>S==null?void 0:S.length)),o),ge(ne(w,fe(S=>S.topListHeight)),f),ge(f,a),ge(ne(w,fe(S=>[S.top,S.bottom])),i),ge(ne(w,fe(S=>S.items)),y);const C=Zt(ne(w,Ce(({items:S})=>S.length>0),Oe(o,e),Ce(([{items:S},k])=>S[S.length-1].originalIndex===k-1),fe(([,S,k])=>[S-1,k]),at(po),fe(([S])=>S))),E=Zt(ne(w,Nn(200),Ce(({items:S,topItems:k})=>S.length>0&&S[0].originalIndex===k.length),fe(({items:S})=>S[0].index),at())),T=Zt(ne(w,Ce(({items:S})=>S.length>0),fe(({items:S})=>{let k=0,A=S.length-1;for(;S[k].type==="group"&&k<A;)k++;for(;S[A].type==="group"&&A>k;)A--;return{endIndex:S[A].index,startIndex:S[k].index}}),at(Nf)));return{endReached:C,initialItemCount:x,itemsRendered:y,listState:w,rangeChanged:T,startReached:E,topItemsIndexes:g,...m}},it(yn,Rf,_a,go,mo,bo,Un,Ia),{singleton:!0}),zf=qe(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=Be(),i=Ot(ne(St(n,e,r,t,o),fe(([a,l,c,d,f])=>a+l+c+d+f.offsetBottom+f.bottom)),0);return ge(Se(i),s),{totalListHeight:i,totalListHeightChanged:s}},it(Bt,ur),{singleton:!0}),l0=qe(([{viewportHeight:e},{totalListHeight:t}])=>{const n=ie(!1),r=Ot(ne(St(n,e,t),Ce(([o])=>o),fe(([,o,s])=>Math.max(0,o-s)),Nn(0),at()),0);return{alignToBottom:n,paddingTopAddition:r}},it(Bt,zf),{singleton:!0}),Hf=qe(()=>({context:ie(null)})),c0=({itemBottom:e,itemTop:t,locationParams:{align:n,behavior:r,...o},viewportBottom:s,viewportTop:i})=>t<i?{...o,align:n??"start",behavior:r}:e>s?{...o,align:n??"end",behavior:r}:null,Uf=qe(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:s,scrollingInProgress:i,scrollTop:a,viewportHeight:l},{scrollToIndex:c}])=>{const d=Be();return ge(ne(d,Oe(t,l,n,s,o,r,a),Oe(e),fe(([[f,m,p,v,g,x,y,w],C])=>{const{align:E,behavior:T,calculateViewLocation:S=c0,done:k,...A}=f,j=Pf(f,m,v-1),F=ho(j,m.offsetTree,C)+g+x,D=F+fn(m.sizeTree,j)[1],B=w+x,Y=w+p-y,M=S({itemBottom:D,itemTop:F,locationParams:{align:E,behavior:T,...A},viewportBottom:Y,viewportTop:B});return M?k&&dn(ne(i,Ce(W=>!W),ar(bt(i)?1:2)),k):k&&k(),M}),Ce(f=>f!==null)),c),{scrollIntoView:d}},it(yn,Bt,mo,ur,zn),{singleton:!0});function Wf(e){return e?e==="smooth"?"smooth":"auto":!1}const u0=(e,t)=>typeof e=="function"?Wf(e(t)):t&&Wf(e),d0=qe(([{listRefresh:e,totalCount:t,fixedItemSize:n,data:r},{atBottomState:o,isAtBottom:s},{scrollToIndex:i},{scrolledToInitialItem:a},{didMount:l,propsReady:c},{log:d},{scrollingInProgress:f},{context:m},{scrollIntoView:p}])=>{const v=ie(!1),g=Be();let x=null;function y(T){Pe(i,{align:"end",behavior:T,index:"LAST"})}Je(ne(St(ne(Se(t),ar(1)),l),Oe(Se(v),s,a,f),fe(([[T,S],k,A,j,F])=>{let D=S&&j,B="auto";return D&&(B=u0(k,A||F),D=D&&!!B),{followOutputBehavior:B,shouldFollow:D,totalCount:T}}),Ce(({shouldFollow:T})=>T)),({followOutputBehavior:T,totalCount:S})=>{x&&(x(),x=null),bt(n)?requestAnimationFrame(()=>{bt(d)("following output to ",{totalCount:S},qt.DEBUG),y(T)}):x=dn(e,()=>{bt(d)("following output to ",{totalCount:S},qt.DEBUG),y(T),x=null})});function w(T){const S=dn(o,k=>{T&&!k.atBottom&&k.notAtBottomBecause==="SIZE_INCREASED"&&!x&&(bt(d)("scrolling to bottom due to increased size",{},qt.DEBUG),y("auto"))});setTimeout(S,100)}Je(ne(St(Se(v),t,c),Ce(([T,,S])=>T&&S),wn(({value:T},[,S])=>({refreshed:T===S,value:S}),{refreshed:!1,value:0}),Ce(({refreshed:T})=>T),Oe(v,t)),([,T])=>{bt(a)&&w(T!==!1)}),Je(g,()=>{w(bt(v)!==!1)}),Je(St(Se(v),o),([T,S])=>{T&&!S.atBottom&&S.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&y("auto")});const C=ie(null),E=Be();return ge(ya(ne(Se(r),fe(T=>{var S;return(S=T==null?void 0:T.length)!=null?S:0})),ne(Se(t))),E),Je(ne(St(ne(E,ar(1)),l),Oe(Se(C),a,f,m),fe(([[T,S],k,A,j,F])=>S&&A&&(k==null?void 0:k({context:F,totalCount:T,scrollingInProgress:j}))),Ce(T=>!!T),Nn(0)),T=>{x&&(x(),x=null),bt(n)?requestAnimationFrame(()=>{bt(d)("scrolling into view",{}),Pe(p,T)}):x=dn(e,()=>{bt(d)("scrolling into view",{}),Pe(p,T),x=null})}),{autoscrollToBottom:g,followOutput:v,scrollIntoViewOnChange:C}},it(yn,bo,mo,go,Un,zn,Bt,Hf,Uf)),f0=qe(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(ge(ne(a,Oe(s),Ce(([,l])=>l!==0),Oe(o,r,t,n,e),fe(([[,l],c,d,f,m,p=[]])=>Ff(l,c,d,f,m,p))),i),{}),it(yn,go,ur,Un),{singleton:!0}),p0=qe(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=ie(0);return Je(ne(e,Oe(r),Ce(([,o])=>o!==0),fe(([,o])=>({top:o}))),o=>{dn(ne(n,ar(1),Ce(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{Pe(t,o)})})}),{initialScrollTop:r}},it(Un,Bt,ur),{singleton:!0}),Vf=qe(([{scrollVelocity:e}])=>{const t=ie(!1),n=Be(),r=ie(!1);return ge(ne(e,Oe(r,t,n),Ce(([o,s])=>!!s),fe(([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}),at()),t),Je(ne(St(t,e,n),Oe(r)),([[o,s,i],a])=>{o&&a&&a.change&&a.change(s,i)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},it(bo),{singleton:!0}),Ma=qe(([{scrollContainerState:e,scrollTo:t}])=>{const n=Be(),r=Be(),o=Be(),s=ie(!1),i=ie(void 0);return ge(ne(St(n,r),fe(([{scrollHeight:a,scrollTop:l,viewportHeight:c},{offsetTop:d}])=>({scrollHeight:a,scrollTop:Math.max(0,l-d),viewportHeight:c}))),e),ge(ne(t,Oe(r),fe(([a,{offsetTop:l}])=>({...a,top:a.top+l}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},it(Bt)),h0=qe(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:a,windowViewportRect:l}])=>{const c=Be(),d=ie(void 0),f=ie(null),m=ie(null);return ge(a,f),ge(l,m),Je(ne(c,Oe(t,r,i,f,m,n)),([p,v,g,x,y,w,C])=>{const E=Jy(v.sizeTree);x&&y!==null&&w!==null&&(g=y.scrollTop-w.offsetTop),g-=C,p({ranges:E,scrollTop:g})}),ge(ne(d,Ce(ba),fe(m0)),o),ge(ne(s,Oe(d),Ce(([,p])=>p!==void 0),at(),fe(([,p])=>p.ranges)),e),{getState:c,restoreStateFrom:d}},it(yn,Bt,go,Un,Ma));function m0(e){return{align:"start",index:0,offset:e.scrollTop}}const g0=qe(([{topItemsIndexes:e}])=>{const t=ie(0);return ge(ne(t,Ce(n=>n>=0),fe(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},it(ur));function Kf(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const x0=Kf(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),v0=qe(([{deviation:e,scrollBy:t,scrollingInProgress:n,scrollTop:r},{isAtBottom:o,isScrolling:s,lastJumpDueToItemResize:i,scrollDirection:a},{listState:l},{beforeUnshiftWith:c,gap:d,shiftWithOffset:f,sizes:m},{log:p},{recalcInProgress:v}])=>{const g=Zt(ne(l,Oe(i),wn(([,y,w,C],[{bottom:E,items:T,offsetBottom:S,totalCount:k},A])=>{const j=E+S;let F=0;return w===k&&y.length>0&&T.length>0&&(T[0].originalIndex===0&&y[0].originalIndex===0||(F=j-C,F!==0&&(F+=A))),[F,T,k,j]},[0,[],0,0]),Ce(([y])=>y!==0),Oe(r,a,n,o,p,v),Ce(([,y,w,C,,,E])=>!E&&!C&&y!==0&&w===xo),fe(([[y],,,,,w])=>(w("Upward scrolling compensation",{amount:y},qt.DEBUG),y))));function x(y){y>0?(Pe(t,{behavior:"auto",top:-y}),Pe(e,0)):(Pe(e,0),Pe(t,{behavior:"auto",top:-y}))}return Je(ne(g,Oe(e,s)),([y,w,C])=>{C&&x0()?Pe(e,w-y):x(-y)}),Je(ne(St(Ot(s,!1),e,v),Ce(([y,w,C])=>!y&&!C&&w!==0),fe(([y,w])=>w),Nn(1)),x),ge(ne(f,fe(y=>({top:-y}))),t),Je(ne(c,Oe(m,d),fe(([y,{groupIndices:w,lastSize:C,sizeTree:E},T])=>{function S(k){return k*(C+T)}if(w.length===0)return S(y);{let k=0;const A=fo(E,0);let j=0,F=0;for(;j<y;){j++,k+=A;let D=w.length===F+1?1/0:w[F+1]-w[F]-1;j+D>y&&(k-=A,D=y-j+1),j+=D,k+=S(D),F++}return k}})),y=>{Pe(e,y),requestAnimationFrame(()=>{Pe(t,{top:y}),requestAnimationFrame(()=>{Pe(e,0),Pe(v,!1)})})}),{deviation:e}},it(Bt,bo,ur,yn,zn,Ia)),b0=qe(([e,t,n,r,o,s,i,a,l,c,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...l,...c,...d}),it(_a,f0,Un,Vf,zf,p0,l0,Ma,Uf,zn,Hf)),qf=qe(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:r,gap:o,groupIndices:s,itemSize:i,sizeRanges:a,sizes:l,statefulTotalCount:c,totalCount:d,trackItemSizes:f},{initialItemFinalLocationReached:m,initialTopMostItemIndex:p,scrolledToInitialItem:v},g,x,y,{listState:w,topItemsIndexes:C,...E},{scrollToIndex:T},S,{topItemCount:k},{groupCounts:A},j])=>(ge(E.rangeChanged,j.scrollSeekRangeChanged),ge(ne(j.windowViewportRect,fe(F=>F.visibleHeight)),g.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,gap:o,groupCounts:A,initialItemFinalLocationReached:m,initialTopMostItemIndex:p,scrolledToInitialItem:v,sizeRanges:a,topItemCount:k,topItemsIndexes:C,totalCount:d,...y,groupIndices:s,itemSize:i,listState:w,scrollToIndex:T,statefulTotalCount:c,trackItemSizes:f,...E,...j,...g,sizes:l,...x}),it(yn,go,Bt,h0,d0,ur,mo,v0,g0,Rf,b0));function w0(e,t){const n={},r={};let o=0;const s=e.length;for(;o<s;)r[e[o]]=1,o+=1;for(const i in t)Object.hasOwn(r,i)||(n[i]=t[i]);return n}const js=typeof document<"u"?b.useLayoutEffect:b.useEffect;function Gf(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&&Pe(x.propsReady,!1);for(const w of r){const C=x[t.required[w]];Pe(C,y[w])}for(const w of o)if(w in y){const C=x[t.optional[w]];Pe(C,y[w])}x.propsReady&&Pe(x.propsReady,!0)}function c(x){return s.reduce((y,w)=>(y[w]=C=>{const E=x[t.methods[w]];Pe(E,C)},y),{})}function d(x){return i.reduce((y,w)=>(y[w]=Dy(x[t.events[w]]),y),{})}const f=b.forwardRef((x,y)=>{const{children:w,...C}=x,[E]=b.useState(()=>Ss($y(e),k=>{l(k,C)})),[T]=b.useState(xf(d,E));js(()=>{for(const k of i)k in C&&Je(T[k],C[k]);return()=>{Object.values(T).map(wa)}},[C,T,E]),js(()=>{l(E,C)}),b.useImperativeHandle(y,mf(c(E)));const S=n;return u.jsx(a.Provider,{value:E,children:n?u.jsx(S,{...w0([...r,...o,...i],C),children:w}):w})}),m=x=>{const y=b.useContext(a);return b.useCallback(w=>{Pe(y[x],w)},[y,x])},p=x=>{const y=b.useContext(a)[x],w=b.useCallback(C=>Je(y,C),[y]);return b.useSyncExternalStore(w,()=>bt(y),()=>bt(y))},v=x=>{const y=b.useContext(a)[x],[w,C]=b.useState(xf(bt,y));return js(()=>Je(y,E=>{E!==w&&C(mf(E))}),[y,w]),w},g=b.version.startsWith("18")?p:v;return{Component:f,useEmitter:(x,y)=>{const w=b.useContext(a)[x];js(()=>Je(w,y),[y,w])},useEmitterValue:g,usePublisher:m}}const Yf=b.createContext(void 0),Xf=b.createContext(void 0),Jf=typeof document<"u"?b.useLayoutEffect:b.useEffect;function Oa(e){return"self"in e}function y0(e){return"body"in e}function Zf(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 p,v,g;const x=m.target;if(y0(x)||Oa(x)){const w=Oa(x)?x:x.defaultView;g=s?w.scrollX:w.scrollY,p=s?w.document.documentElement.scrollWidth:w.document.documentElement.scrollHeight,v=s?w.innerWidth:w.innerHeight}else g=s?x.scrollLeft:x.scrollTop,p=s?x.scrollWidth:x.scrollHeight,v=s?x.offsetWidth:x.offsetHeight;const y=()=>{e({scrollHeight:p,scrollTop:Math.max(g,0),viewportHeight:v})};m.suppressFlushSync?y():Do.flushSync(y),a.current!==null&&(g===a.current||g<=0||g===p-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 p=i.current;if(!p||(s?"offsetWidth"in p&&p.offsetWidth===0:"offsetHeight"in p&&p.offsetHeight===0))return;const v=m.behavior==="smooth";let g,x,y;Oa(p)?(x=Math.max(Hn(p.document.documentElement,s?"width":"height"),s?p.document.documentElement.scrollWidth:p.document.documentElement.scrollHeight),g=s?p.innerWidth:p.innerHeight,y=s?window.scrollX:window.scrollY):(x=p[s?"scrollWidth":"scrollHeight"],g=Hn(p,s?"width":"height"),y=p[s?"scrollLeft":"scrollTop"]);const w=x-g;if(m.top=Math.ceil(Math.max(Math.min(w,m.top),0)),Of(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}),p.scrollTo(m)}function f(m){s&&(m={behavior:m.behavior,left:m.top}),i.current.scrollBy(m)}return{scrollByCallback:f,scrollerRef:i,scrollToCallback:d}}const Da="-webkit-sticky",Qf="sticky",La=Kf(()=>{if(typeof document>"u")return Qf;const e=document.createElement("div");return e.style.position=Da,e.style.position===Da?Da:Qf});function $a(e){return e}const S0=qe(()=>{const e=ie(a=>`Item ${a}`),t=ie(a=>`Group ${a}`),n=ie({}),r=ie($a),o=ie("div"),s=ie(_r),i=(a,l=null)=>Ot(ne(n,fe(c=>c[a]),at()),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")}}),C0=qe(([e,t])=>({...e,...t}),it(qf,S0)),T0=({height:e})=>u.jsx("div",{style:{height:e}}),k0={overflowAnchor:"none",position:La(),zIndex:1},ep={overflowAnchor:"none"},E0={...ep,display:"inline-block",height:"100%"},tp=b.memo(function({showTopList:e=!1}){const t=Ie("listState"),n=rn("sizeRanges"),r=Ie("useWindowScroll"),o=Ie("customScrollParent"),s=rn("windowScrollContainerState"),i=rn("scrollContainerState"),a=o||r?s:i,l=Ie("itemContent"),c=Ie("context"),d=Ie("groupContent"),f=Ie("trackItemSizes"),m=Ie("itemSize"),p=Ie("log"),v=rn("gap"),g=Ie("horizontalDirection"),{callbackRef:x}=zy(n,m,f,e?_r:a,p,v,o,g,Ie("skipAnimationFrameInResizeObserver")),[y,w]=b.useState(0);Fa("deviation",M=>{y!==M&&w(M)});const C=Ie("EmptyPlaceholder"),E=Ie("ScrollSeekPlaceholder")||T0,T=Ie("ListComponent"),S=Ie("ItemComponent"),k=Ie("GroupComponent"),A=Ie("computeItemKey"),j=Ie("isSeeking"),F=Ie("groupIndices").length>0,D=Ie("alignToBottom"),B=Ie("initialItemFinalLocationReached"),Y=e?{}:{boxSizing:"border-box",...g?{display:"inline-block",height:"100%",marginLeft:y!==0?y:D?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:y!==0?y:D?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...B?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&C?u.jsx(C,{...Dt(C,c)}):u.jsx(T,{...Dt(T,c),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:x,style:Y,children:(e?t.topItems:t.items).map(M=>{const W=M.originalIndex,X=A(W+t.firstItemIndex,M.data,c);return j?b.createElement(E,{...Dt(E,c),height:M.size,index:M.index,key:X,type:M.type||"item",...M.type==="group"?{}:{groupIndex:M.groupIndex}}):M.type==="group"?b.createElement(k,{...Dt(k,c),"data-index":W,"data-item-index":M.index,"data-known-size":M.size,key:X,style:k0},d(M.index,c)):b.createElement(S,{...Dt(S,c),...j0(S,M.data),"data-index":W,"data-item-group-index":M.groupIndex,"data-item-index":M.index,"data-known-size":M.size,key:X,style:g?E0:ep},F?l(M.index,M.groupIndex,M.data,c):l(M.index,M.data,c))})})}),I0={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},N0={outline:"none",overflowX:"auto",position:"relative"},Ps=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),A0={position:La(),top:0,width:"100%",zIndex:1};function Dt(e,t){if(typeof e!="string")return{context:t}}function j0(e,t){return{item:typeof e=="string"?void 0:t}}const P0=b.memo(function(){const e=Ie("HeaderComponent"),t=rn("headerHeight"),n=Ie("HeaderFooterTag"),r=lr(b.useMemo(()=>s=>{t(Hn(s,"height"))},[t]),!0,Ie("skipAnimationFrameInResizeObserver")),o=Ie("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Dt(e,o)})}):null}),_0=b.memo(function(){const e=Ie("FooterComponent"),t=rn("footerHeight"),n=Ie("HeaderFooterTag"),r=lr(b.useMemo(()=>s=>{t(Hn(s,"height"))},[t]),!0,Ie("skipAnimationFrameInResizeObserver")),o=Ie("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Dt(e,o)})}):null});function np({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"),f=t("horizontalDirection")||!1,{scrollByCallback:m,scrollerRef:p,scrollToCallback:v}=Zf(a,c,l,d,void 0,f);return e("scrollTo",v),e("scrollBy",m),u.jsx(l,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:p,style:{...f?N0:I0,...o},tabIndex:0,...i,...Dt(l,s),children:r})})}function rp({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"),f=t("deviation"),m=t("customScrollParent"),p=b.useRef(null),v=t("scrollerRef"),{scrollByCallback:g,scrollerRef:x,scrollToCallback:y}=Zf(a,c,l,v,m);return Jf(()=>{var w;return x.current=m||((w=p.current)==null?void 0:w.ownerDocument.defaultView),()=>{x.current=null}},[x,m]),e("windowScrollTo",y),e("scrollBy",g),u.jsx(l,{ref:p,"data-virtuoso-scroller":!0,style:{position:"relative",...o,...d!==0?{height:d+f}:{}},...i,...Dt(l,s),children:r})})}const R0=({children:e})=>{const t=b.useContext(Yf),n=rn("viewportHeight"),r=rn("fixedItemHeight"),o=Ie("alignToBottom"),s=Ie("horizontalDirection"),i=b.useMemo(()=>gf(n,l=>Hn(l,s?"width":"height")),[n,s]),a=lr(i,!0,Ie("skipAnimationFrameInResizeObserver"));return b.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),u.jsx("div",{"data-viewport-type":"element",ref:a,style:Ps(o),children:e})},M0=({children:e})=>{const t=b.useContext(Yf),n=rn("windowViewportRect"),r=rn("fixedItemHeight"),o=Ie("customScrollParent"),s=yf(n,o,Ie("skipAnimationFrameInResizeObserver")),i=Ie("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:Ps(i),children:e})},O0=({children:e})=>{const t=Ie("TopItemListComponent")||"div",n=Ie("headerHeight"),r={...A0,marginTop:`${n}px`},o=Ie("context");return u.jsx(t,{style:r,...Dt(t,o),children:e})},D0=b.memo(function(e){const t=Ie("useWindowScroll"),n=Ie("topItemsIndexes").length>0,r=Ie("customScrollParent"),o=Ie("context");return u.jsxs(r||t?F0:$0,{...e,context:o,children:[n&&u.jsx(O0,{children:u.jsx(tp,{showTopList:!0})}),u.jsxs(r||t?M0:R0,{children:[u.jsx(P0,{}),u.jsx(tp,{}),u.jsx(_0,{})]})]})}),{Component:L0,useEmitter:Fa,useEmitterValue:Ie,usePublisher:rn}=Gf(C0,{required:{},optional:{restoreStateFrom:"restoreStateFrom",context:"context",followOutput:"followOutput",scrollIntoViewOnChange:"scrollIntoViewOnChange",itemContent:"itemContent",groupContent:"groupContent",overscan:"overscan",increaseViewportBy:"increaseViewportBy",totalCount:"totalCount",groupCounts:"groupCounts",topItemCount:"topItemCount",firstItemIndex:"firstItemIndex",initialTopMostItemIndex:"initialTopMostItemIndex",components:"components",atBottomThreshold:"atBottomThreshold",atTopThreshold:"atTopThreshold",computeItemKey:"computeItemKey",defaultItemHeight:"defaultItemHeight",fixedItemHeight:"fixedItemHeight",itemSize:"itemSize",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"HeaderFooterTag",data:"data",initialItemCount:"initialItemCount",initialScrollTop:"initialScrollTop",alignToBottom:"alignToBottom",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",horizontalDirection:"horizontalDirection",skipAnimationFrameInResizeObserver:"skipAnimationFrameInResizeObserver"},methods:{scrollToIndex:"scrollToIndex",scrollIntoView:"scrollIntoView",scrollTo:"scrollTo",scrollBy:"scrollBy",autoscrollToBottom:"autoscrollToBottom",getState:"getState"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",totalListHeightChanged:"totalListHeightChanged",itemsRendered:"itemsRendered",groupIndices:"groupIndices"}},D0),$0=np({useEmitter:Fa,useEmitterValue:Ie,usePublisher:rn}),F0=rp({useEmitter:Fa,useEmitterValue:Ie,usePublisher:rn}),B0=L0;it(qf,qe(()=>{const e=ie(c=>u.jsxs("td",{children:["Item $",c]})),t=ie(null),n=ie(c=>u.jsxs("td",{colSpan:1e3,children:["Group ",c]})),r=ie(null),o=ie(null),s=ie({}),i=ie($a),a=ie(_r),l=(c,d=null)=>Ot(ne(s,fe(f=>f[c]),at()),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")}})),La();const op={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},z0={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:sp,floor:_s,max:wo,min:Ba,round:ip}=Math;function ap(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function H0(e){return{...z0,items:e}}function Rs(e,t){return e&&e.width===t.width&&e.height===t.height}function U0(e,t){return e&&e.column===t.column&&e.row===t.row}const W0=qe(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:r},{footerHeight:o,headerHeight:s,scrollBy:i,scrollContainerState:a,scrollTo:l,scrollTop:c,smoothScrollTargetReached:d,viewportHeight:f},m,p,{didMount:v,propsReady:g},{customScrollParent:x,useWindowScroll:y,windowScrollContainerState:w,windowScrollTo:C,windowViewportRect:E},T])=>{const S=ie(0),k=ie(0),A=ie(op),j=ie({height:0,width:0}),F=ie({height:0,width:0}),D=Be(),B=Be(),Y=ie(0),M=ie(null),W=ie({column:0,row:0}),X=Be(),z=Be(),P=ie(!1),I=ie(0),q=ie(!0),Q=ie(!1),O=ie(!1);Je(ne(v,Oe(I),Ce(([_,U])=>!!U)),()=>{Pe(q,!1)}),Je(ne(St(v,q,F,j,I,Q),Ce(([_,U,Z,re,,le])=>_&&!U&&Z.height!==0&&re.height!==0&&!le)),([,,,,_])=>{Pe(Q,!0),ja(1,()=>{Pe(D,_)}),dn(ne(c),()=>{Pe(t,[0,0]),Pe(q,!0)})}),ge(ne(z,Ce(_=>_!=null&&_.scrollTop>0),bn(0)),k),Je(ne(v,Oe(z),Ce(([,_])=>_!=null)),([,_])=>{_&&(Pe(j,_.viewport),Pe(F,_.item),Pe(W,_.gap),_.scrollTop>0&&(Pe(P,!0),dn(ne(c,ar(1)),U=>{Pe(P,!1)}),Pe(l,{top:_.scrollTop})))}),ge(ne(j,fe(({height:_})=>_)),f),ge(ne(St(Se(j,Rs),Se(F,Rs),Se(W,(_,U)=>_&&_.column===U.column&&_.row===U.row),Se(c)),fe(([_,U,Z,re])=>({gap:Z,item:U,scrollTop:re,viewport:_}))),X),ge(ne(St(Se(S),r,Se(W,U0),Se(F,Rs),Se(j,Rs),Se(M),Se(k),Se(P),Se(q),Se(I)),Ce(([,,,,,,,_])=>!_),fe(([_,[U,Z],re,le,ke,ye,_e,,ze,$e])=>{const{column:Ge,row:He}=re,{height:nt,width:ft}=le,{width:ct}=ke;if(_e===0&&(_===0||ct===0))return op;if(ft===0){const Tt=Pa($e,_),pt=Tt+Math.max(_e-1,0);return H0(ap(Tt,pt,ye))}const Ue=lp(ct,ft,Ge);let Re,Ve;ze?U===0&&Z===0&&_e>0?(Re=0,Ve=_e-1):(Re=Ue*_s((U+He)/(nt+He)),Ve=Ue*sp((Z+He)/(nt+He))-1,Ve=Ba(_-1,wo(Ve,Ue-1)),Re=Ba(Ve,wo(0,Re))):(Re=0,Ve=-1);const Ne=ap(Re,Ve,ye),{bottom:Ke,top:Ye}=cp(ke,re,le,Ne),Ct=sp(_/Ue),Ze=Ct*nt+(Ct-1)*He-Ke;return{bottom:Ke,itemHeight:nt,items:Ne,itemWidth:ft,offsetBottom:Ze,offsetTop:Ye,top:Ye}})),A),ge(ne(M,Ce(_=>_!==null),fe(_=>_.length)),S),ge(ne(St(j,F,A,W),Ce(([_,U,{items:Z}])=>Z.length>0&&U.height!==0&&_.height!==0),fe(([_,U,{items:Z},re])=>{const{bottom:le,top:ke}=cp(_,re,U,Z);return[ke,le]}),at(po)),t);const G=ie(!1);ge(ne(c,Oe(G),fe(([_,U])=>U||_!==0)),G);const L=Zt(ne(St(A,S),Ce(([{items:_}])=>_.length>0),Oe(G),Ce(([[_,U],Z])=>{const re=_.items[_.items.length-1].index===U-1;return(Z||_.bottom>0&&_.itemHeight>0&&_.offsetBottom===0&&_.items.length===U)&&re}),fe(([[,_]])=>_-1),at())),$=Zt(ne(Se(A),Ce(({items:_})=>_.length>0&&_[0].index===0),bn(0),at())),J=Zt(ne(Se(A),Oe(P),Ce(([{items:_},U])=>_.length>0&&!U),fe(([{items:_}])=>({endIndex:_[_.length-1].index,startIndex:_[0].index})),at(Nf),Nn(0)));ge(J,p.scrollSeekRangeChanged),ge(ne(D,Oe(j,F,S,W),fe(([_,U,Z,re,le])=>{const ke=Mf(_),{align:ye,behavior:_e,offset:ze}=ke;let $e=ke.index;$e==="LAST"&&($e=re-1),$e=wo(0,$e,Ba(re-1,$e));let Ge=za(U,le,Z,$e);return ye==="end"?Ge=ip(Ge-U.height+Z.height):ye==="center"&&(Ge=ip(Ge-U.height/2+Z.height/2)),ze&&(Ge+=ze),{behavior:_e,top:Ge}})),l);const R=Ot(ne(A,fe(_=>_.offsetBottom+_.bottom)),0);return ge(ne(E,fe(_=>({height:_.visibleHeight,width:_.visibleWidth}))),j),{customScrollParent:x,data:M,deviation:Y,footerHeight:o,gap:W,headerHeight:s,increaseViewportBy:e,initialItemCount:k,itemDimensions:F,overscan:n,restoreStateFrom:z,scrollBy:i,scrollContainerState:a,scrollHeight:B,scrollTo:l,scrollToIndex:D,scrollTop:c,smoothScrollTargetReached:d,totalCount:S,useWindowScroll:y,viewportDimensions:j,windowScrollContainerState:w,windowScrollTo:C,windowViewportRect:E,...p,gridState:A,horizontalDirection:O,initialTopMostItemIndex:I,totalListHeight:R,...m,endReached:L,propsReady:g,rangeChanged:J,startReached:$,stateChanged:X,stateRestoreInProgress:P,...T}},it(_a,Bt,bo,Vf,Un,Ma,zn));function lp(e,t,n){return wo(1,_s((e+n)/(_s(t)+n)))}function cp(e,t,n,r){const{height:o}=n;if(o===void 0||r.length===0)return{bottom:0,top:0};const s=za(e,t,n,r[0].index);return{bottom:za(e,t,n,r[r.length-1].index)+o,top:s}}function za(e,t,n,r){const o=lp(e.width,n.width,t.column),s=_s(r/o),i=s*n.height+wo(0,s-1)*t.row;return i>0?i+t.row:i}const V0=qe(()=>{const e=ie(f=>`Item ${f}`),t=ie({}),n=ie(null),r=ie("virtuoso-grid-item"),o=ie("virtuoso-grid-list"),s=ie($a),i=ie("div"),a=ie(_r),l=(f,m=null)=>Ot(ne(t,fe(p=>p[f]),at()),m),c=ie(!1),d=ie(!1);return ge(Se(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")}}),K0=qe(([e,t])=>({...e,...t}),it(W0,V0)),q0=b.memo(function(){const e=lt("gridState"),t=lt("listClassName"),n=lt("itemClassName"),r=lt("itemContent"),o=lt("computeItemKey"),s=lt("isSeeking"),i=on("scrollHeight"),a=lt("ItemComponent"),l=lt("ListComponent"),c=lt("ScrollSeekPlaceholder"),d=lt("context"),f=on("itemDimensions"),m=on("gap"),p=lt("log"),v=lt("stateRestoreInProgress"),g=on("reportReadyState"),x=lr(b.useMemo(()=>y=>{const w=y.parentElement.parentElement.scrollHeight;i(w);const C=y.firstChild;if(C){const{height:E,width:T}=C.getBoundingClientRect();f({height:E,width:T})}m({column:dp("column-gap",getComputedStyle(y).columnGap,p),row:dp("row-gap",getComputedStyle(y).rowGap,p)})},[i,f,m,p]),!0,!1);return Jf(()=>{e.itemHeight>0&&e.itemWidth>0&&g(!0)},[e]),v?null:u.jsx(l,{className:t,ref:x,...Dt(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,{...Dt(c,d),height:e.itemHeight,index:y.index,width:e.itemWidth},w):b.createElement(a,{...Dt(a,d),className:n,"data-index":y.index,key:w},r(y.index,y.data,d))})})}),G0=b.memo(function(){const e=lt("HeaderComponent"),t=on("headerHeight"),n=lt("headerFooterTag"),r=lr(b.useMemo(()=>s=>{t(Hn(s,"height"))},[t]),!0,!1),o=lt("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Dt(e,o)})}):null}),Y0=b.memo(function(){const e=lt("FooterComponent"),t=on("footerHeight"),n=lt("headerFooterTag"),r=lr(b.useMemo(()=>s=>{t(Hn(s,"height"))},[t]),!0,!1),o=lt("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Dt(e,o)})}):null}),X0=({children:e})=>{const t=b.useContext(Xf),n=on("itemDimensions"),r=on("viewportDimensions"),o=lr(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:Ps(!1),children:e})},J0=({children:e})=>{const t=b.useContext(Xf),n=on("windowViewportRect"),r=on("itemDimensions"),o=lt("customScrollParent"),s=yf(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:Ps(!1),children:e})},Z0=b.memo(function({...e}){const t=lt("useWindowScroll"),n=lt("customScrollParent"),r=n||t?eS:Q0,o=n||t?J0:X0,s=lt("context");return u.jsx(r,{...e,...Dt(r,s),children:u.jsxs(o,{children:[u.jsx(G0,{}),u.jsx(q0,{}),u.jsx(Y0,{})]})})}),{useEmitter:up,useEmitterValue:lt,usePublisher:on}=Gf(K0,{optional:{context:"context",totalCount:"totalCount",overscan:"overscan",itemContent:"itemContent",components:"components",computeItemKey:"computeItemKey",data:"data",initialItemCount:"initialItemCount",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"headerFooterTag",listClassName:"listClassName",itemClassName:"itemClassName",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",restoreStateFrom:"restoreStateFrom",initialTopMostItemIndex:"initialTopMostItemIndex",increaseViewportBy:"increaseViewportBy"},methods:{scrollTo:"scrollTo",scrollBy:"scrollBy",scrollToIndex:"scrollToIndex"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",stateChanged:"stateChanged",readyStateChanged:"readyStateChanged"}},Z0),Q0=np({useEmitter:up,useEmitterValue:lt,usePublisher:on}),eS=rp({useEmitter:up,useEmitterValue:lt,usePublisher:on});function dp(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,qt.WARN),t==="normal"?0:parseInt(t??"0",10)}const tS={checkpoints:[],checkpointMetaByCheckpointId:new Map,timeline:[],messagePreviews:new Map,getLatest:()=>{},getCheckpoint:()=>{},getMessageAttempts:()=>[]},Ha=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,Ua=b.memo(function({message:t,index:n,isStreaming:r,streamingAssistantId:o,streamingDebounceMs:s=0,layoutSize:i,enableMessageEditing:a,editingMessageId:l,onEdit:c,onRegenerate:d,onCancelEdit:f,showToolMessages:m,checkpointIndex:p,onSelectCheckpoint:v,getMessageCustomStyles:g,getInterruptOptions:x,toolConfig:y}){const w=Ha(t,n),C=t.role==="default_message",S=!!t.__syntheticStreaming||o===t.id&&t.role==="assistant",k=p??tS,A=!C&&"checkpointId"in t?t.checkpointId??null:null,{attemptCount:j,attemptIndex:F,attempts:D}=b.useMemo(()=>uc(t.id,A,k),[t.id,A,k]),B=g==null?void 0:g(t);return u.jsx("div",{className:"relative mb-4 last:mb-0","data-message-id":w,style:{minHeight:"60px",containIntrinsicSize:"auto 120px"},children:u.jsx(ws,{message:t,messageIndex:n,isStreamingMessage:S,renderStreamingMarkdown:S,streamingDebounceMs:s,isEditing:l===t.id,showActions:a,showTimestamp:!1,showAgentName:!0,layoutSize:i,onEdit:c,onRegenerate:()=>d(n),onCancelEdit:f,getInterruptOptions:x,showToolMessages:m,attemptCount:j,attemptIndex:F,attemptMetas:D,onSelectCheckpoint:v,customStyles:B,toolConfig:y})})});Ua.displayName="MessageRow";const Wa=b.forwardRef(({messages:e,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r=0,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onStartReached:a,onEdit:l,onRegenerate:c,onCancelEdit:d,className:f,style:m,emptyMessage:p,followNewMessages:v=!0,isNavigatingCheckpoint:g=!1,onScrollAway:x,onAtBottom:y,showToolMessages:w=!0,toolConfig:C,checkpointIndex:E,activeCheckpointId:T,onSelectCheckpoint:S,createSyntheticThinkingMessage:k=!0,forceSyntheticThinking:A=!1,getMessageCustomStyles:j,getInterruptOptions:F},D)=>{const B=b.useRef(null),Y=b.useRef(null),M=b.useRef(!1),W=b.useRef(!1),X=e,z=b.useMemo(()=>{const R=n&&X.some(U=>U.id===n);return k&&(t||A)&&!R&&X.length>0?[...X,{id:"thinking-assistant",role:"assistant",content:[{type:"text",text:""}],createdAt:new Date().toISOString(),__syntheticStreaming:!0}]:X},[X,t,n,k,A]),P=b.useMemo(()=>w?z:z.filter(R=>(R==null?void 0:R.role)!=="tool"),[z,w]),I=b.useCallback(R=>{x&&x(!R),y&&y(R)},[x,y]),q=b.useMemo(()=>{if(a)return async()=>{if(!M.current){M.current=!0;try{await a()}finally{M.current=!1}}}},[a]),Q=b.useMemo(()=>!v||g?!1:"auto",[v,g]),O=b.useMemo(()=>{if(typeof p!="string")return null;const R=p.trim();return!R||P&&P.length>0?null:{id:"default-message",role:"default_message",content:R,createdAt:new Date().toISOString()}},[p,P]),G=["flex h-full flex-col md:flex-row",f].filter(Boolean).join(" "),L=()=>{if(O){const R=j==null?void 0:j(O);return u.jsx("div",{className:"p-6 h-full overflow-y-auto",children:u.jsx("div",{className:"w-full max-w-full",children:u.jsx(ws,{message:O,messageIndex:0,isStreamingMessage:!1,showActions:!1,showTimestamp:!1,showAgentName:!0,layoutSize:o,onEdit:()=>{},onRegenerate:()=>{},onCancelEdit:()=>{},customStyles:R,getInterruptOptions:F})})})}return u.jsx("div",{className:"flex h-full items-center justify-center py-8 text-center text-muted-foreground",children:p??"No messages yet. Start a conversation!"})},$=P.length,J=$>0;return b.useEffect(()=>{var R,_;if($===0){W.current=!1;return}if(!W.current)if(W.current=!0,B.current&&P.length>0){const U=P.length-1;(_=(R=B.current).scrollToIndex)==null||_.call(R,{index:U,align:"end",behavior:"auto"})}else Y.current&&(Y.current.scrollTop=Y.current.scrollHeight)},[$,P.length]),b.useImperativeHandle(D,()=>({scrollToLatest:()=>{var R,_;if(B.current&&P.length>0){const U=P.length-1;(_=(R=B.current).scrollToIndex)==null||_.call(R,{index:U,align:"end",behavior:"auto"})}else Y.current&&(Y.current.scrollTop=Y.current.scrollHeight)},scrollToTop:()=>{var R,_;B.current&&P.length>0?(_=(R=B.current).scrollToIndex)==null||_.call(R,{index:0,align:"start",behavior:"auto"}):Y.current&&(Y.current.scrollTop=0)}}),[P]),u.jsx("div",{className:G,style:m,children:u.jsx("div",{className:"relative flex-1 min-h-0",children:J?u.jsx(B0,{ref:R=>{B.current=R},scrollerRef:R=>{Y.current=R instanceof HTMLDivElement?R:null},data:P,followOutput:Q,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,startReached:()=>{q&&q()},atBottomStateChange:I,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(R,_)=>Ha(_,R),itemContent:(R,_)=>u.jsx(Ua,{message:_,index:R,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onEdit:l,onRegenerate:c,onCancelEdit:d,showToolMessages:w,toolConfig:C,checkpointIndex:E,activeCheckpointId:T,onSelectCheckpoint:S,getMessageCustomStyles:j,getInterruptOptions:F})}):L()})})});Wa.displayName="MessageList";function fp({message:e,viewMode:t,isStreaming:n=!1,toolConfig:r,expandable:o=!1}){var F;const s=Yo(e),i=e.artifact??null,a=pf(e),c=(a?Au(a):null)??a,d=e.content.find(D=>D.type!=="tool_call"),f=D=>{if(D==null)return null;const B=typeof D=="string"?er(D)??D:D;if(B&&typeof B=="object")return u.jsx(vs,{data:B});const Y=typeof B=="string"?B:(()=>{try{return tr(B)}catch{return String(B??"")}})();return u.jsx("pre",{className:"whitespace-pre-wrap break-words font-sans text-sm text-foreground/90",children:Y})},m=D=>{if(D==null)return null;const{content:B,isMarkdown:Y}=yu(D);return Y?u.jsx(ir,{content:B,className:"text-current"}):f(D)},p=D=>u.jsxs("div",{className:"space-y-2 rounded-2xl border border-muted-foreground/30 bg-white/80 p-4 shadow-sm shadow-slate-900/10",children:[u.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-[0.4em] text-muted-foreground",children:"Structured dictionary"}),u.jsx(vs,{data:D})]}),v=()=>{if((c==null?void 0:c.kind)==="generic")return m(c.value);if(!d)return null;if(d.type==="text"){const M=(d.text??"").trim();if(!M)return null;const W=nr(M);return m(W)}const D=Sr(d),B=nr(D);return m(B)},g=()=>(c==null?void 0:c.kind)==="dict"?p(c.data):v(),x=()=>{if(!y)return;if(s.name){const B=y[s.name];if(B)return B}const D=(c==null?void 0:c.kind)??(a==null?void 0:a.kind);if(D){const B=y[D];if(B)return B}return y.default},{toolRenderers:y,toolArtifactRenderers:w}=r??{},C=x(),E=g(),T=!o||t==="expanded",S=(T?C==null?void 0:C({message:e,toolMeta:s,toolPayload:c,viewMode:t,isStreaming:n}):null)??null,A=((F=(()=>{if(!w)return;const D=i==null?void 0:i.type;if(typeof D=="string"){const B=w[D];if(B)return B}return w.default})())==null?void 0:F({artifact:i,message:e,toolPayload:c,isStreaming:n}))??null,j=S??E;return u.jsxs("div",{className:"space-y-2",children:[i&&(A??u.jsx(tf,{artifact:i,idx:0})),u.jsx(nf,{message:e,isStreaming:n}),T?j:null]})}function Ms(e){const t=e+"CollectionProvider",[n,r]=nn(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=g=>{const{scope:x,children:y}=g,w=b.useRef(null),C=b.useRef(new Map).current;return u.jsx(o,{scope:x,itemMap:C,collectionRef:w,children:y})};i.displayName=t;const a=e+"CollectionSlot",l=Jt.createSlot(a),c=b.forwardRef((g,x)=>{const{scope:y,children:w}=g,C=s(a,y),E=Me(x,C.collectionRef);return u.jsx(l,{ref:E,children:w})});c.displayName=a;const d=e+"CollectionItemSlot",f="data-radix-collection-item",m=Jt.createSlot(d),p=b.forwardRef((g,x)=>{const{scope:y,children:w,...C}=g,E=b.useRef(null),T=Me(x,E),S=s(d,y);return b.useEffect(()=>(S.itemMap.set(E,{ref:E,...C}),()=>void S.itemMap.delete(E))),u.jsx(m,{[f]:"",ref:T,children:w})});p.displayName=d;function v(g){const x=s(e+"CollectionConsumer",g);return b.useCallback(()=>{const w=x.collectionRef.current;if(!w)return[];const C=Array.from(w.querySelectorAll(`[${f}]`));return Array.from(x.itemMap.values()).sort((S,k)=>C.indexOf(S.ref.current)-C.indexOf(k.ref.current))},[x.collectionRef,x.itemMap])}return[{Provider:i,Slot:c,ItemSlot:p},v,r]}var nS=h.createContext(void 0);function Os(e){const t=h.useContext(nS);return e||t||"ltr"}const rS=["top","right","bottom","left"],Wn=Math.min,en=Math.max,Ds=Math.round,Ls=Math.floor,Sn=e=>({x:e,y:e}),oS={left:"right",right:"left",bottom:"top",top:"bottom"},sS={start:"end",end:"start"};function Va(e,t,n){return en(e,Wn(t,n))}function An(e,t){return typeof e=="function"?e(t):e}function jn(e){return e.split("-")[0]}function Mr(e){return e.split("-")[1]}function Ka(e){return e==="x"?"y":"x"}function qa(e){return e==="y"?"height":"width"}const iS=new Set(["top","bottom"]);function Cn(e){return iS.has(jn(e))?"y":"x"}function Ga(e){return Ka(Cn(e))}function aS(e,t,n){n===void 0&&(n=!1);const r=Mr(e),o=Ga(e),s=qa(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=$s(i)),[i,$s(i)]}function lS(e){const t=$s(e);return[Ya(e),t,Ya(t)]}function Ya(e){return e.replace(/start|end/g,t=>sS[t])}const pp=["left","right"],hp=["right","left"],cS=["top","bottom"],uS=["bottom","top"];function dS(e,t,n){switch(e){case"top":case"bottom":return n?t?hp:pp:t?pp:hp;case"left":case"right":return t?cS:uS;default:return[]}}function fS(e,t,n,r){const o=Mr(e);let s=dS(jn(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(Ya)))),s}function $s(e){return e.replace(/left|right|bottom|top/g,t=>oS[t])}function pS(e){return{top:0,right:0,bottom:0,left:0,...e}}function mp(e){return typeof e!="number"?pS(e):{top:e,right:e,bottom:e,left:e}}function Fs(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 gp(e,t,n){let{reference:r,floating:o}=e;const s=Cn(t),i=Ga(t),a=qa(i),l=jn(t),c=s==="y",d=r.x+r.width/2-o.width/2,f=r.y+r.height/2-o.height/2,m=r[a]/2-o[a]/2;let p;switch(l){case"top":p={x:d,y:r.y-o.height};break;case"bottom":p={x:d,y:r.y+r.height};break;case"right":p={x:r.x+r.width,y:f};break;case"left":p={x:r.x-o.width,y:f};break;default:p={x:r.x,y:r.y}}switch(Mr(t)){case"start":p[i]-=m*(n&&c?-1:1);break;case"end":p[i]+=m*(n&&c?-1:1);break}return p}const hS=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:f}=gp(c,r,l),m=r,p={},v=0;for(let g=0;g<a.length;g++){const{name:x,fn:y}=a[g],{x:w,y:C,data:E,reset:T}=await y({x:d,y:f,initialPlacement:r,placement:m,strategy:o,middlewareData:p,rects:c,platform:i,elements:{reference:e,floating:t}});d=w??d,f=C??f,p={...p,[x]:{...p[x],...E}},T&&v<=50&&(v++,typeof T=="object"&&(T.placement&&(m=T.placement),T.rects&&(c=T.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):T.rects),{x:d,y:f}=gp(c,m,l)),g=-1)}return{x:d,y:f,placement:m,strategy:o,middlewareData:p}};async function yo(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:f="floating",altBoundary:m=!1,padding:p=0}=An(t,e),v=mp(p),x=a[m?f==="floating"?"reference":"floating":f],y=Fs(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=f==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,C=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),E=await(s.isElement==null?void 0:s.isElement(C))?await(s.getScale==null?void 0:s.getScale(C))||{x:1,y:1}:{x:1,y:1},T=Fs(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:w,offsetParent:C,strategy:l}):w);return{top:(y.top-T.top+v.top)/E.y,bottom:(T.bottom-y.bottom+v.bottom)/E.y,left:(y.left-T.left+v.left)/E.x,right:(T.right-y.right+v.right)/E.x}}const mS=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 f=mp(d),m={x:n,y:r},p=Ga(o),v=qa(p),g=await i.getDimensions(c),x=p==="y",y=x?"top":"left",w=x?"bottom":"right",C=x?"clientHeight":"clientWidth",E=s.reference[v]+s.reference[p]-m[p]-s.floating[v],T=m[p]-s.reference[p],S=await(i.getOffsetParent==null?void 0:i.getOffsetParent(c));let k=S?S[C]:0;(!k||!await(i.isElement==null?void 0:i.isElement(S)))&&(k=a.floating[C]||s.floating[v]);const A=E/2-T/2,j=k/2-g[v]/2-1,F=Wn(f[y],j),D=Wn(f[w],j),B=F,Y=k-g[v]-D,M=k/2-g[v]/2+A,W=Va(B,M,Y),X=!l.arrow&&Mr(o)!=null&&M!==W&&s.reference[v]/2-(M<B?F:D)-g[v]/2<0,z=X?M<B?M-B:M-Y:0;return{[p]:m[p]+z,data:{[p]:W,centerOffset:M-W-z,...X&&{alignmentOffset:z}},reset:X}}}),gS=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:f=!0,fallbackPlacements:m,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:v="none",flipAlignment:g=!0,...x}=An(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const y=jn(o),w=Cn(a),C=jn(a)===a,E=await(l.isRTL==null?void 0:l.isRTL(c.floating)),T=m||(C||!g?[$s(a)]:lS(a)),S=v!=="none";!m&&S&&T.push(...fS(a,g,v,E));const k=[a,...T],A=await yo(t,x),j=[];let F=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&j.push(A[y]),f){const M=aS(o,i,E);j.push(A[M[0]],A[M[1]])}if(F=[...F,{placement:o,overflows:j}],!j.every(M=>M<=0)){var D,B;const M=(((D=s.flip)==null?void 0:D.index)||0)+1,W=k[M];if(W&&(!(f==="alignment"?w!==Cn(W):!1)||F.every(P=>Cn(P.placement)===w?P.overflows[0]>0:!0)))return{data:{index:M,overflows:F},reset:{placement:W}};let X=(B=F.filter(z=>z.overflows[0]<=0).sort((z,P)=>z.overflows[1]-P.overflows[1])[0])==null?void 0:B.placement;if(!X)switch(p){case"bestFit":{var Y;const z=(Y=F.filter(P=>{if(S){const I=Cn(P.placement);return I===w||I==="y"}return!0}).map(P=>[P.placement,P.overflows.filter(I=>I>0).reduce((I,q)=>I+q,0)]).sort((P,I)=>P[1]-I[1])[0])==null?void 0:Y[0];z&&(X=z);break}case"initialPlacement":X=a;break}if(o!==X)return{reset:{placement:X}}}return{}}}};function xp(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function vp(e){return rS.some(t=>e[t]>=0)}const xS=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 yo(t,{...o,elementContext:"reference"}),i=xp(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:vp(i)}}}case"escaped":{const s=await yo(t,{...o,altBoundary:!0}),i=xp(s,n.floating);return{data:{escapedOffsets:i,escaped:vp(i)}}}default:return{}}}}},bp=new Set(["left","top"]);async function vS(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=Mr(n),l=Cn(n)==="y",c=bp.has(i)?-1:1,d=s&&l?-1:1,f=An(t,e);let{mainAxis:m,crossAxis:p,alignmentAxis:v}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof v=="number"&&(p=a==="end"?v*-1:v),l?{x:p*d,y:m*c}:{x:m*c,y:p*d}}const bS=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 vS(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}}}}},wS=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 yo(t,l),f=Cn(jn(o)),m=Ka(f);let p=c[m],v=c[f];if(s){const x=m==="y"?"top":"left",y=m==="y"?"bottom":"right",w=p+d[x],C=p-d[y];p=Va(w,p,C)}if(i){const x=f==="y"?"top":"left",y=f==="y"?"bottom":"right",w=v+d[x],C=v-d[y];v=Va(w,v,C)}const g=a.fn({...t,[m]:p,[f]:v});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[m]:s,[f]:i}}}}}},yS=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},f=Cn(o),m=Ka(f);let p=d[m],v=d[f];const g=An(a,t),x=typeof g=="number"?{mainAxis:g,crossAxis:0}:{mainAxis:0,crossAxis:0,...g};if(l){const C=m==="y"?"height":"width",E=s.reference[m]-s.floating[C]+x.mainAxis,T=s.reference[m]+s.reference[C]-x.mainAxis;p<E?p=E:p>T&&(p=T)}if(c){var y,w;const C=m==="y"?"width":"height",E=bp.has(jn(o)),T=s.reference[f]-s.floating[C]+(E&&((y=i.offset)==null?void 0:y[f])||0)+(E?0:x.crossAxis),S=s.reference[f]+s.reference[C]+(E?0:((w=i.offset)==null?void 0:w[f])||0)-(E?x.crossAxis:0);v<T?v=T:v>S&&(v=S)}return{[m]:p,[f]:v}}}},SS=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 yo(t,c),f=jn(o),m=Mr(o),p=Cn(o)==="y",{width:v,height:g}=s.floating;let x,y;f==="top"||f==="bottom"?(x=f,y=m===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(y=f,x=m==="end"?"top":"bottom");const w=g-d.top-d.bottom,C=v-d.left-d.right,E=Wn(g-d[x],w),T=Wn(v-d[y],C),S=!t.middlewareData.shift;let k=E,A=T;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(A=C),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(k=w),S&&!m){const F=en(d.left,0),D=en(d.right,0),B=en(d.top,0),Y=en(d.bottom,0);p?A=v-2*(F!==0||D!==0?F+D:en(d.left,d.right)):k=g-2*(B!==0||Y!==0?B+Y:en(d.top,d.bottom))}await l({...t,availableWidth:A,availableHeight:k});const j=await i.getDimensions(a.floating);return v!==j.width||g!==j.height?{reset:{rects:!0}}:{}}}};function Bs(){return typeof window<"u"}function Or(e){return wp(e)?(e.nodeName||"").toLowerCase():"#document"}function tn(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Tn(e){var t;return(t=(wp(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function wp(e){return Bs()?e instanceof Node||e instanceof tn(e).Node:!1}function pn(e){return Bs()?e instanceof Element||e instanceof tn(e).Element:!1}function kn(e){return Bs()?e instanceof HTMLElement||e instanceof tn(e).HTMLElement:!1}function yp(e){return!Bs()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof tn(e).ShadowRoot}const CS=new Set(["inline","contents"]);function So(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=hn(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!CS.has(o)}const TS=new Set(["table","td","th"]);function kS(e){return TS.has(Or(e))}const ES=[":popover-open",":modal"];function zs(e){return ES.some(t=>{try{return e.matches(t)}catch{return!1}})}const IS=["transform","translate","scale","rotate","perspective"],NS=["transform","translate","scale","rotate","perspective","filter"],AS=["paint","layout","strict","content"];function Xa(e){const t=Ja(),n=pn(e)?hn(e):e;return IS.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)||NS.some(r=>(n.willChange||"").includes(r))||AS.some(r=>(n.contain||"").includes(r))}function jS(e){let t=Vn(e);for(;kn(t)&&!Dr(t);){if(Xa(t))return t;if(zs(t))return null;t=Vn(t)}return null}function Ja(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const PS=new Set(["html","body","#document"]);function Dr(e){return PS.has(Or(e))}function hn(e){return tn(e).getComputedStyle(e)}function Hs(e){return pn(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Vn(e){if(Or(e)==="html")return e;const t=e.assignedSlot||e.parentNode||yp(e)&&e.host||Tn(e);return yp(t)?t.host:t}function Sp(e){const t=Vn(e);return Dr(t)?e.ownerDocument?e.ownerDocument.body:e.body:kn(t)&&So(t)?t:Sp(t)}function Co(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=Sp(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=tn(o);if(s){const a=Za(i);return t.concat(i,i.visualViewport||[],So(o)?o:[],a&&n?Co(a):[])}return t.concat(o,Co(o,[],n))}function Za(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Cp(e){const t=hn(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=kn(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=Ds(n)!==s||Ds(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function Qa(e){return pn(e)?e:e.contextElement}function Lr(e){const t=Qa(e);if(!kn(t))return Sn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=Cp(t);let i=(s?Ds(n.width):n.width)/r,a=(s?Ds(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const _S=Sn(0);function Tp(e){const t=tn(e);return!Ja()||!t.visualViewport?_S:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function RS(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==tn(e)?!1:t}function dr(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=Qa(e);let i=Sn(1);t&&(r?pn(r)&&(i=Lr(r)):i=Lr(e));const a=RS(s,n,r)?Tp(s):Sn(0);let l=(o.left+a.x)/i.x,c=(o.top+a.y)/i.y,d=o.width/i.x,f=o.height/i.y;if(s){const m=tn(s),p=r&&pn(r)?tn(r):r;let v=m,g=Za(v);for(;g&&r&&p!==v;){const x=Lr(g),y=g.getBoundingClientRect(),w=hn(g),C=y.left+(g.clientLeft+parseFloat(w.paddingLeft))*x.x,E=y.top+(g.clientTop+parseFloat(w.paddingTop))*x.y;l*=x.x,c*=x.y,d*=x.x,f*=x.y,l+=C,c+=E,v=tn(g),g=Za(v)}}return Fs({width:d,height:f,x:l,y:c})}function Us(e,t){const n=Hs(e).scrollLeft;return t?t.left+n:dr(Tn(e)).left+n}function kp(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-Us(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function MS(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=Tn(r),a=t?zs(t.floating):!1;if(r===i||a&&s)return n;let l={scrollLeft:0,scrollTop:0},c=Sn(1);const d=Sn(0),f=kn(r);if((f||!f&&!s)&&((Or(r)!=="body"||So(i))&&(l=Hs(r)),kn(r))){const p=dr(r);c=Lr(r),d.x=p.x+r.clientLeft,d.y=p.y+r.clientTop}const m=i&&!f&&!s?kp(i,l):Sn(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 OS(e){return Array.from(e.getClientRects())}function DS(e){const t=Tn(e),n=Hs(e),r=e.ownerDocument.body,o=en(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=en(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+Us(e);const a=-n.scrollTop;return hn(r).direction==="rtl"&&(i+=en(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const Ep=25;function LS(e,t){const n=tn(e),r=Tn(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=Ja();(!d||d&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}const c=Us(r);if(c<=0){const d=r.ownerDocument,f=d.body,m=getComputedStyle(f),p=d.compatMode==="CSS1Compat"&&parseFloat(m.marginLeft)+parseFloat(m.marginRight)||0,v=Math.abs(r.clientWidth-f.clientWidth-p);v<=Ep&&(s-=v)}else c<=Ep&&(s+=c);return{width:s,height:i,x:a,y:l}}const $S=new Set(["absolute","fixed"]);function FS(e,t){const n=dr(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=kn(e)?Lr(e):Sn(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 Ip(e,t,n){let r;if(t==="viewport")r=LS(e,n);else if(t==="document")r=DS(Tn(e));else if(pn(t))r=FS(t,n);else{const o=Tp(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Fs(r)}function Np(e,t){const n=Vn(e);return n===t||!pn(n)||Dr(n)?!1:hn(n).position==="fixed"||Np(n,t)}function BS(e,t){const n=t.get(e);if(n)return n;let r=Co(e,[],!1).filter(a=>pn(a)&&Or(a)!=="body"),o=null;const s=hn(e).position==="fixed";let i=s?Vn(e):e;for(;pn(i)&&!Dr(i);){const a=hn(i),l=Xa(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&$S.has(o.position)||So(i)&&!l&&Np(e,i))?r=r.filter(d=>d!==i):o=a,i=Vn(i)}return t.set(e,r),r}function zS(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?zs(t)?[]:BS(t,this._c):[].concat(n),r],a=i[0],l=i.reduce((c,d)=>{const f=Ip(t,d,o);return c.top=en(f.top,c.top),c.right=Wn(f.right,c.right),c.bottom=Wn(f.bottom,c.bottom),c.left=en(f.left,c.left),c},Ip(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function HS(e){const{width:t,height:n}=Cp(e);return{width:t,height:n}}function US(e,t,n){const r=kn(t),o=Tn(t),s=n==="fixed",i=dr(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=Sn(0);function c(){l.x=Us(o)}if(r||!r&&!s)if((Or(t)!=="body"||So(o))&&(a=Hs(t)),r){const p=dr(t,!0,s,t);l.x=p.x+t.clientLeft,l.y=p.y+t.clientTop}else o&&c();s&&!r&&o&&c();const d=o&&!r&&!s?kp(o,a):Sn(0),f=i.left+a.scrollLeft-l.x-d.x,m=i.top+a.scrollTop-l.y-d.y;return{x:f,y:m,width:i.width,height:i.height}}function el(e){return hn(e).position==="static"}function Ap(e,t){if(!kn(e)||hn(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Tn(e)===n&&(n=n.ownerDocument.body),n}function jp(e,t){const n=tn(e);if(zs(e))return n;if(!kn(e)){let o=Vn(e);for(;o&&!Dr(o);){if(pn(o)&&!el(o))return o;o=Vn(o)}return n}let r=Ap(e,t);for(;r&&kS(r)&&el(r);)r=Ap(r,t);return r&&Dr(r)&&el(r)&&!Xa(r)?n:r||jS(e)||n}const WS=async function(e){const t=this.getOffsetParent||jp,n=this.getDimensions,r=await n(e.floating);return{reference:US(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function VS(e){return hn(e).direction==="rtl"}const KS={convertOffsetParentRelativeRectToViewportRelativeRect:MS,getDocumentElement:Tn,getClippingRect:zS,getOffsetParent:jp,getElementRects:WS,getClientRects:OS,getDimensions:HS,getScale:Lr,isElement:pn,isRTL:VS};function Pp(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function qS(e,t){let n=null,r;const o=Tn(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:f,width:m,height:p}=c;if(a||t(),!m||!p)return;const v=Ls(f),g=Ls(o.clientWidth-(d+m)),x=Ls(o.clientHeight-(f+p)),y=Ls(d),C={rootMargin:-v+"px "+-g+"px "+-x+"px "+-y+"px",threshold:en(0,Wn(1,l))||1};let E=!0;function T(S){const k=S[0].intersectionRatio;if(k!==l){if(!E)return i();k?i(!1,k):r=setTimeout(()=>{i(!1,1e-7)},1e3)}k===1&&!Pp(c,e.getBoundingClientRect())&&i(),E=!1}try{n=new IntersectionObserver(T,{...C,root:o.ownerDocument})}catch{n=new IntersectionObserver(T,C)}n.observe(e)}return i(!0),s}function GS(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=Qa(e),d=o||s?[...c?Co(c):[],...Co(t)]:[];d.forEach(y=>{o&&y.addEventListener("scroll",n,{passive:!0}),s&&y.addEventListener("resize",n)});const f=c&&a?qS(c,n):null;let m=-1,p=null;i&&(p=new ResizeObserver(y=>{let[w]=y;w&&w.target===c&&p&&(p.unobserve(t),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var C;(C=p)==null||C.observe(t)})),n()}),c&&!l&&p.observe(c),p.observe(t));let v,g=l?dr(e):null;l&&x();function x(){const y=dr(e);g&&!Pp(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)}),f==null||f(),(y=p)==null||y.disconnect(),p=null,l&&cancelAnimationFrame(v)}}const YS=bS,XS=wS,JS=gS,ZS=SS,QS=xS,_p=mS,eC=yS,tC=(e,t,n)=>{const r=new Map,o={platform:KS,...n},s={...o.platform,_c:r};return hS(e,t,{...o,platform:s})};var nC=typeof document<"u",rC=function(){},Ws=nC?b.useLayoutEffect:rC;function Vs(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(!Vs(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)&&!Vs(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function Rp(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Mp(e,t){const n=Rp(e);return Math.round(t*n)/n}function tl(e){const t=h.useRef(e);return Ws(()=>{t.current=e}),t}function oC(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,f]=h.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[m,p]=h.useState(r);Vs(m,r)||p(r);const[v,g]=h.useState(null),[x,y]=h.useState(null),w=h.useCallback(P=>{P!==S.current&&(S.current=P,g(P))},[]),C=h.useCallback(P=>{P!==k.current&&(k.current=P,y(P))},[]),E=s||v,T=i||x,S=h.useRef(null),k=h.useRef(null),A=h.useRef(d),j=l!=null,F=tl(l),D=tl(o),B=tl(c),Y=h.useCallback(()=>{if(!S.current||!k.current)return;const P={placement:t,strategy:n,middleware:m};D.current&&(P.platform=D.current),tC(S.current,k.current,P).then(I=>{const q={...I,isPositioned:B.current!==!1};M.current&&!Vs(A.current,q)&&(A.current=q,qr.flushSync(()=>{f(q)}))})},[m,t,n,D,B]);Ws(()=>{c===!1&&A.current.isPositioned&&(A.current.isPositioned=!1,f(P=>({...P,isPositioned:!1})))},[c]);const M=h.useRef(!1);Ws(()=>(M.current=!0,()=>{M.current=!1}),[]),Ws(()=>{if(E&&(S.current=E),T&&(k.current=T),E&&T){if(F.current)return F.current(E,T,Y);Y()}},[E,T,Y,F,j]);const W=h.useMemo(()=>({reference:S,floating:k,setReference:w,setFloating:C}),[w,C]),X=h.useMemo(()=>({reference:E,floating:T}),[E,T]),z=h.useMemo(()=>{const P={position:n,left:0,top:0};if(!X.floating)return P;const I=Mp(X.floating,d.x),q=Mp(X.floating,d.y);return a?{...P,transform:"translate("+I+"px, "+q+"px)",...Rp(X.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:I,top:q}},[n,a,X.floating,d.x,d.y]);return h.useMemo(()=>({...d,update:Y,refs:W,elements:X,floatingStyles:z}),[d,Y,W,X,z])}const sC=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?_p({element:r.current,padding:o}).fn(n):{}:r?_p({element:r,padding:o}).fn(n):{}}}},iC=(e,t)=>({...YS(e),options:[e,t]}),aC=(e,t)=>({...XS(e),options:[e,t]}),lC=(e,t)=>({...eC(e),options:[e,t]}),cC=(e,t)=>({...JS(e),options:[e,t]}),uC=(e,t)=>({...ZS(e),options:[e,t]}),dC=(e,t)=>({...QS(e),options:[e,t]}),fC=(e,t)=>({...sC(e),options:[e,t]});var pC="Arrow",Op=h.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return u.jsx(he.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"})})});Op.displayName=pC;var hC=Op;function Dp(e){const[t,n]=h.useState(void 0);return It(()=>{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 nl="Popper",[Lp,$r]=nn(nl),[mC,$p]=Lp(nl),Fp=e=>{const{__scopePopper:t,children:n}=e,[r,o]=h.useState(null);return u.jsx(mC,{scope:t,anchor:r,onAnchorChange:o,children:n})};Fp.displayName=nl;var Bp="PopperAnchor",zp=h.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=$p(Bp,n),i=h.useRef(null),a=Me(t,i),l=h.useRef(null);return h.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(he.div,{...o,ref:a})});zp.displayName=Bp;var rl="PopperContent",[gC,xC]=Lp(rl),Hp=h.forwardRef((e,t)=>{var R,_,U,Z,re,le;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:f="partial",hideWhenDetached:m=!1,updatePositionStrategy:p="optimized",onPlaced:v,...g}=e,x=$p(rl,n),[y,w]=h.useState(null),C=Me(t,ke=>w(ke)),[E,T]=h.useState(null),S=Dp(E),k=(S==null?void 0:S.width)??0,A=(S==null?void 0:S.height)??0,j=r+(s!=="center"?"-"+s:""),F=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},D=Array.isArray(c)?c:[c],B=D.length>0,Y={padding:F,boundary:D.filter(bC),altBoundary:B},{refs:M,floatingStyles:W,placement:X,isPositioned:z,middlewareData:P}=oC({strategy:"fixed",placement:j,whileElementsMounted:(...ke)=>GS(...ke,{animationFrame:p==="always"}),elements:{reference:x.anchor},middleware:[iC({mainAxis:o+A,alignmentAxis:i}),l&&aC({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?lC():void 0,...Y}),l&&cC({...Y}),uC({...Y,apply:({elements:ke,rects:ye,availableWidth:_e,availableHeight:ze})=>{const{width:$e,height:Ge}=ye.reference,He=ke.floating.style;He.setProperty("--radix-popper-available-width",`${_e}px`),He.setProperty("--radix-popper-available-height",`${ze}px`),He.setProperty("--radix-popper-anchor-width",`${$e}px`),He.setProperty("--radix-popper-anchor-height",`${Ge}px`)}}),E&&fC({element:E,padding:a}),wC({arrowWidth:k,arrowHeight:A}),m&&dC({strategy:"referenceHidden",...Y})]}),[I,q]=Vp(X),Q=vt(v);It(()=>{z&&(Q==null||Q())},[z,Q]);const O=(R=P.arrow)==null?void 0:R.x,G=(_=P.arrow)==null?void 0:_.y,L=((U=P.arrow)==null?void 0:U.centerOffset)!==0,[$,J]=h.useState();return It(()=>{y&&J(window.getComputedStyle(y).zIndex)},[y]),u.jsx("div",{ref:M.setFloating,"data-radix-popper-content-wrapper":"",style:{...W,transform:z?W.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:$,"--radix-popper-transform-origin":[(Z=P.transformOrigin)==null?void 0:Z.x,(re=P.transformOrigin)==null?void 0:re.y].join(" "),...((le=P.hide)==null?void 0:le.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:u.jsx(gC,{scope:n,placedSide:I,onArrowChange:T,arrowX:O,arrowY:G,shouldHideArrow:L,children:u.jsx(he.div,{"data-side":I,"data-align":q,...g,ref:C,style:{...g.style,animation:z?void 0:"none"}})})})});Hp.displayName=rl;var Up="PopperArrow",vC={top:"bottom",right:"left",bottom:"top",left:"right"},Wp=h.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=xC(Up,r),i=vC[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(hC,{...o,ref:n,style:{...o.style,display:"block"}})})});Wp.displayName=Up;function bC(e){return e!==null}var wC=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]=Vp(n),f={start:"0%",center:"50%",end:"100%"}[d],m=(((y=o.arrow)==null?void 0:y.x)??0)+a/2,p=(((w=o.arrow)==null?void 0:w.y)??0)+l/2;let v="",g="";return c==="bottom"?(v=i?f:`${m}px`,g=`${-l}px`):c==="top"?(v=i?f:`${m}px`,g=`${r.floating.height+l}px`):c==="right"?(v=`${-l}px`,g=i?f:`${p}px`):c==="left"&&(v=`${r.floating.width+l}px`,g=i?f:`${p}px`),{data:{x:v,y:g}}}});function Vp(e){const[t,n="center"]=e.split("-");return[t,n]}var ol=Fp,sl=zp,il=Hp,al=Wp,ll="rovingFocusGroup.onEntryFocus",yC={bubbles:!1,cancelable:!0},To="RovingFocusGroup",[cl,Kp,SC]=Ms(To),[CC,qp]=nn(To,[SC]),[TC,kC]=CC(To),Gp=h.forwardRef((e,t)=>u.jsx(cl.Provider,{scope:e.__scopeRovingFocusGroup,children:u.jsx(cl.Slot,{scope:e.__scopeRovingFocusGroup,children:u.jsx(EC,{...e,ref:t})})}));Gp.displayName=To;var EC=h.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:c,preventScrollOnEntryFocus:d=!1,...f}=e,m=h.useRef(null),p=Me(t,m),v=Os(s),[g,x]=In({prop:i,defaultProp:a??null,onChange:l,caller:To}),[y,w]=h.useState(!1),C=vt(c),E=Kp(n),T=h.useRef(!1),[S,k]=h.useState(0);return h.useEffect(()=>{const A=m.current;if(A)return A.addEventListener(ll,C),()=>A.removeEventListener(ll,C)},[C]),u.jsx(TC,{scope:n,orientation:r,dir:v,loop:o,currentTabStopId:g,onItemFocus:h.useCallback(A=>x(A),[x]),onItemShiftTab:h.useCallback(()=>w(!0),[]),onFocusableItemAdd:h.useCallback(()=>k(A=>A+1),[]),onFocusableItemRemove:h.useCallback(()=>k(A=>A-1),[]),children:u.jsx(he.div,{tabIndex:y||S===0?-1:0,"data-orientation":r,...f,ref:p,style:{outline:"none",...e.style},onMouseDown:ce(e.onMouseDown,()=>{T.current=!0}),onFocus:ce(e.onFocus,A=>{const j=!T.current;if(A.target===A.currentTarget&&j&&!y){const F=new CustomEvent(ll,yC);if(A.currentTarget.dispatchEvent(F),!F.defaultPrevented){const D=E().filter(X=>X.focusable),B=D.find(X=>X.active),Y=D.find(X=>X.id===g),W=[B,Y,...D].filter(Boolean).map(X=>X.ref.current);Jp(W,d)}}T.current=!1}),onBlur:ce(e.onBlur,()=>w(!1))})})}),Yp="RovingFocusGroupItem",Xp=h.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,l=jt(),c=s||l,d=kC(Yp,n),f=d.currentTabStopId===c,m=Kp(n),{onFocusableItemAdd:p,onFocusableItemRemove:v,currentTabStopId:g}=d;return h.useEffect(()=>{if(r)return p(),()=>v()},[r,p,v]),u.jsx(cl.ItemSlot,{scope:n,id:c,focusable:r,active:o,children:u.jsx(he.span,{tabIndex:f?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=AC(x,d.orientation,d.dir);if(y!==void 0){if(x.metaKey||x.ctrlKey||x.altKey||x.shiftKey)return;x.preventDefault();let C=m().filter(E=>E.focusable).map(E=>E.ref.current);if(y==="last")C.reverse();else if(y==="prev"||y==="next"){y==="prev"&&C.reverse();const E=C.indexOf(x.currentTarget);C=d.loop?jC(C,E+1):C.slice(E+1)}setTimeout(()=>Jp(C))}}),children:typeof i=="function"?i({isCurrentTabStop:f,hasTabStop:g!=null}):i})})});Xp.displayName=Yp;var IC={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function NC(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function AC(e,t,n){const r=NC(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return IC[r]}function Jp(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function jC(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var PC=Gp,_C=Xp,ul=["Enter"," "],RC=["ArrowDown","PageUp","Home"],Zp=["ArrowUp","PageDown","End"],MC=[...RC,...Zp],OC={ltr:[...ul,"ArrowRight"],rtl:[...ul,"ArrowLeft"]},DC={ltr:["ArrowLeft"],rtl:["ArrowRight"]},ko="Menu",[Eo,LC,$C]=Ms(ko),[fr,Qp]=nn(ko,[$C,$r,qp]),Ks=$r(),eh=qp(),[FC,pr]=fr(ko),[BC,Io]=fr(ko),th=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=Ks(t),[l,c]=h.useState(null),d=h.useRef(!1),f=vt(s),m=Os(o);return h.useEffect(()=>{const p=()=>{d.current=!0,document.addEventListener("pointerdown",v,{capture:!0,once:!0}),document.addEventListener("pointermove",v,{capture:!0,once:!0})},v=()=>d.current=!1;return document.addEventListener("keydown",p,{capture:!0}),()=>{document.removeEventListener("keydown",p,{capture:!0}),document.removeEventListener("pointerdown",v,{capture:!0}),document.removeEventListener("pointermove",v,{capture:!0})}},[]),u.jsx(ol,{...a,children:u.jsx(FC,{scope:t,open:n,onOpenChange:f,content:l,onContentChange:c,children:u.jsx(BC,{scope:t,onClose:h.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:d,dir:m,modal:i,children:r})})})};th.displayName=ko;var zC="MenuAnchor",dl=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=Ks(n);return u.jsx(sl,{...o,...r,ref:t})});dl.displayName=zC;var fl="MenuPortal",[HC,nh]=fr(fl,{forceMount:void 0}),rh=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=pr(fl,t);return u.jsx(HC,{scope:t,forceMount:n,children:u.jsx(Ft,{present:n||s.open,children:u.jsx(so,{asChild:!0,container:o,children:r})})})};rh.displayName=fl;var sn="MenuContent",[UC,pl]=fr(sn),oh=h.forwardRef((e,t)=>{const n=nh(sn,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=pr(sn,e.__scopeMenu),i=Io(sn,e.__scopeMenu);return u.jsx(Eo.Provider,{scope:e.__scopeMenu,children:u.jsx(Ft,{present:r||s.open,children:u.jsx(Eo.Slot,{scope:e.__scopeMenu,children:i.modal?u.jsx(WC,{...o,ref:t}):u.jsx(VC,{...o,ref:t})})})})}),WC=h.forwardRef((e,t)=>{const n=pr(sn,e.__scopeMenu),r=h.useRef(null),o=Me(t,r);return h.useEffect(()=>{const s=r.current;if(s)return na(s)},[]),u.jsx(hl,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:ce(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),VC=h.forwardRef((e,t)=>{const n=pr(sn,e.__scopeMenu);return u.jsx(hl,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),KC=Jt.createSlot("MenuContent.ScrollLock"),hl=h.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:m,onDismiss:p,disableOutsideScroll:v,...g}=e,x=pr(sn,n),y=Io(sn,n),w=Ks(n),C=eh(n),E=LC(n),[T,S]=h.useState(null),k=h.useRef(null),A=Me(t,k,x.onContentChange),j=h.useRef(0),F=h.useRef(""),D=h.useRef(0),B=h.useRef(null),Y=h.useRef("right"),M=h.useRef(0),W=v?rs:h.Fragment,X=v?{as:KC,allowPinchZoom:!0}:void 0,z=I=>{var R,_;const q=F.current+I,Q=E().filter(U=>!U.disabled),O=document.activeElement,G=(R=Q.find(U=>U.ref.current===O))==null?void 0:R.textValue,L=Q.map(U=>U.textValue),$=oT(L,q,G),J=(_=Q.find(U=>U.textValue===$))==null?void 0:_.ref.current;(function U(Z){F.current=Z,window.clearTimeout(j.current),Z!==""&&(j.current=window.setTimeout(()=>U(""),1e3))})(q),J&&setTimeout(()=>J.focus())};h.useEffect(()=>()=>window.clearTimeout(j.current),[]),Xi();const P=h.useCallback(I=>{var Q,O;return Y.current===((Q=B.current)==null?void 0:Q.side)&&iT(I,(O=B.current)==null?void 0:O.area)},[]);return u.jsx(UC,{scope:n,searchRef:F,onItemEnter:h.useCallback(I=>{P(I)&&I.preventDefault()},[P]),onItemLeave:h.useCallback(I=>{var q;P(I)||((q=k.current)==null||q.focus(),S(null))},[P]),onTriggerLeave:h.useCallback(I=>{P(I)&&I.preventDefault()},[P]),pointerGraceTimerRef:D,onPointerGraceIntentChange:h.useCallback(I=>{B.current=I},[]),children:u.jsx(W,{...X,children:u.jsx(Xo,{asChild:!0,trapped:o,onMountAutoFocus:ce(s,I=>{var q;I.preventDefault(),(q=k.current)==null||q.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:u.jsx(Er,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:m,onDismiss:p,children:u.jsx(PC,{asChild:!0,...C,dir:y.dir,orientation:"vertical",loop:r,currentTabStopId:T,onCurrentTabStopIdChange:S,onEntryFocus:ce(l,I=>{y.isUsingKeyboardRef.current||I.preventDefault()}),preventScrollOnEntryFocus:!0,children:u.jsx(il,{role:"menu","aria-orientation":"vertical","data-state":yh(x.open),"data-radix-menu-content":"",dir:y.dir,...w,...g,ref:A,style:{outline:"none",...g.style},onKeyDown:ce(g.onKeyDown,I=>{const Q=I.target.closest("[data-radix-menu-content]")===I.currentTarget,O=I.ctrlKey||I.altKey||I.metaKey,G=I.key.length===1;Q&&(I.key==="Tab"&&I.preventDefault(),!O&&G&&z(I.key));const L=k.current;if(I.target!==L||!MC.includes(I.key))return;I.preventDefault();const J=E().filter(R=>!R.disabled).map(R=>R.ref.current);Zp.includes(I.key)&&J.reverse(),nT(J)}),onBlur:ce(e.onBlur,I=>{I.currentTarget.contains(I.target)||(window.clearTimeout(j.current),F.current="")}),onPointerMove:ce(e.onPointerMove,Ao(I=>{const q=I.target,Q=M.current!==I.clientX;if(I.currentTarget.contains(q)&&Q){const O=I.clientX>M.current?"right":"left";Y.current=O,M.current=I.clientX}}))})})})})})})});oh.displayName=sn;var qC="MenuGroup",ml=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(he.div,{role:"group",...r,ref:t})});ml.displayName=qC;var GC="MenuLabel",sh=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(he.div,{...r,ref:t})});sh.displayName=GC;var qs="MenuItem",ih="menu.itemSelect",Gs=h.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=h.useRef(null),i=Io(qs,e.__scopeMenu),a=pl(qs,e.__scopeMenu),l=Me(t,s),c=h.useRef(!1),d=()=>{const f=s.current;if(!n&&f){const m=new CustomEvent(ih,{bubbles:!0,cancelable:!0});f.addEventListener(ih,p=>r==null?void 0:r(p),{once:!0}),Vi(f,m),m.defaultPrevented?c.current=!1:i.onClose()}};return u.jsx(ah,{...o,ref:l,disabled:n,onClick:ce(e.onClick,d),onPointerDown:f=>{var m;(m=e.onPointerDown)==null||m.call(e,f),c.current=!0},onPointerUp:ce(e.onPointerUp,f=>{var m;c.current||(m=f.currentTarget)==null||m.click()}),onKeyDown:ce(e.onKeyDown,f=>{const m=a.searchRef.current!=="";n||m&&f.key===" "||ul.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});Gs.displayName=qs;var ah=h.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=pl(qs,n),a=eh(n),l=h.useRef(null),c=Me(t,l),[d,f]=h.useState(!1),[m,p]=h.useState("");return h.useEffect(()=>{const v=l.current;v&&p((v.textContent??"").trim())},[s.children]),u.jsx(Eo.ItemSlot,{scope:n,disabled:r,textValue:o??m,children:u.jsx(_C,{asChild:!0,...a,focusable:!r,children:u.jsx(he.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,Ao(v=>{r?i.onItemLeave(v):(i.onItemEnter(v),v.defaultPrevented||v.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:ce(e.onPointerLeave,Ao(v=>i.onItemLeave(v))),onFocus:ce(e.onFocus,()=>f(!0)),onBlur:ce(e.onBlur,()=>f(!1))})})})}),YC="MenuCheckboxItem",lh=h.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return u.jsx(ph,{scope:e.__scopeMenu,checked:n,children:u.jsx(Gs,{role:"menuitemcheckbox","aria-checked":Ys(n)?"mixed":n,...o,ref:t,"data-state":xl(n),onSelect:ce(o.onSelect,()=>r==null?void 0:r(Ys(n)?!0:!n),{checkForDefaultPrevented:!1})})})});lh.displayName=YC;var ch="MenuRadioGroup",[XC,JC]=fr(ch,{value:void 0,onValueChange:()=>{}}),uh=h.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=vt(r);return u.jsx(XC,{scope:e.__scopeMenu,value:n,onValueChange:s,children:u.jsx(ml,{...o,ref:t})})});uh.displayName=ch;var dh="MenuRadioItem",fh=h.forwardRef((e,t)=>{const{value:n,...r}=e,o=JC(dh,e.__scopeMenu),s=n===o.value;return u.jsx(ph,{scope:e.__scopeMenu,checked:s,children:u.jsx(Gs,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":xl(s),onSelect:ce(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});fh.displayName=dh;var gl="MenuItemIndicator",[ph,ZC]=fr(gl,{checked:!1}),hh=h.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=ZC(gl,n);return u.jsx(Ft,{present:r||Ys(s.checked)||s.checked===!0,children:u.jsx(he.span,{...o,ref:t,"data-state":xl(s.checked)})})});hh.displayName=gl;var QC="MenuSeparator",mh=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(he.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});mh.displayName=QC;var eT="MenuArrow",gh=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=Ks(n);return u.jsx(al,{...o,...r,ref:t})});gh.displayName=eT;var tT="MenuSub",[UN,xh]=fr(tT),No="MenuSubTrigger",vh=h.forwardRef((e,t)=>{const n=pr(No,e.__scopeMenu),r=Io(No,e.__scopeMenu),o=xh(No,e.__scopeMenu),s=pl(No,e.__scopeMenu),i=h.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,c={__scopeMenu:e.__scopeMenu},d=h.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return h.useEffect(()=>d,[d]),h.useEffect(()=>{const f=a.current;return()=>{window.clearTimeout(f),l(null)}},[a,l]),u.jsx(dl,{asChild:!0,...c,children:u.jsx(ah,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":yh(n.open),...e,ref:Dn(t,o.onTriggerChange),onClick:f=>{var m;(m=e.onClick)==null||m.call(e,f),!(e.disabled||f.defaultPrevented)&&(f.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:ce(e.onPointerMove,Ao(f=>{s.onItemEnter(f),!f.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(s.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),d()},100))})),onPointerLeave:ce(e.onPointerLeave,Ao(f=>{var p,v;d();const m=(p=n.content)==null?void 0:p.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"],C=m[x?"right":"left"];s.onPointerGraceIntentChange({area:[{x:f.clientX+y,y:f.clientY},{x:w,y:m.top},{x:C,y:m.top},{x:C,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(f),f.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:ce(e.onKeyDown,f=>{var p;const m=s.searchRef.current!=="";e.disabled||m&&f.key===" "||OC[r.dir].includes(f.key)&&(n.onOpenChange(!0),(p=n.content)==null||p.focus(),f.preventDefault())})})})});vh.displayName=No;var bh="MenuSubContent",wh=h.forwardRef((e,t)=>{const n=nh(sn,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=pr(sn,e.__scopeMenu),i=Io(sn,e.__scopeMenu),a=xh(bh,e.__scopeMenu),l=h.useRef(null),c=Me(t,l);return u.jsx(Eo.Provider,{scope:e.__scopeMenu,children:u.jsx(Ft,{present:r||s.open,children:u.jsx(Eo.Slot,{scope:e.__scopeMenu,children:u.jsx(hl,{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 f;i.isUsingKeyboardRef.current&&((f=l.current)==null||f.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 p;const f=d.currentTarget.contains(d.target),m=DC[i.dir].includes(d.key);f&&m&&(s.onOpenChange(!1),(p=a.trigger)==null||p.focus(),d.preventDefault())})})})})})});wh.displayName=bh;function yh(e){return e?"open":"closed"}function Ys(e){return e==="indeterminate"}function xl(e){return Ys(e)?"indeterminate":e?"checked":"unchecked"}function nT(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function rT(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function oT(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=rT(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 sT(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,f=l.x,m=l.y;d>r!=m>r&&n<(f-c)*(r-d)/(m-d)+c&&(o=!o)}return o}function iT(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return sT(n,t)}function Ao(e){return t=>t.pointerType==="mouse"?e(t):void 0}var aT=th,lT=dl,cT=rh,uT=oh,dT=ml,fT=sh,pT=Gs,hT=lh,mT=uh,gT=fh,xT=hh,vT=mh,bT=gh,wT=vh,yT=wh,Xs="DropdownMenu",[ST,WN]=nn(Xs,[Qp]),zt=Qp(),[CT,Sh]=ST(Xs),Ch=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,l=zt(t),c=h.useRef(null),[d,f]=In({prop:o,defaultProp:s??!1,onChange:i,caller:Xs});return u.jsx(CT,{scope:t,triggerId:jt(),triggerRef:c,contentId:jt(),open:d,onOpenChange:f,onOpenToggle:h.useCallback(()=>f(m=>!m),[f]),modal:a,children:u.jsx(aT,{...l,open:d,onOpenChange:f,dir:r,modal:a,children:n})})};Ch.displayName=Xs;var Th="DropdownMenuTrigger",kh=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=Sh(Th,n),i=zt(n);return u.jsx(lT,{asChild:!0,...i,children:u.jsx(he.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:Dn(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())})})})});kh.displayName=Th;var TT="DropdownMenuPortal",Eh=e=>{const{__scopeDropdownMenu:t,...n}=e,r=zt(t);return u.jsx(cT,{...r,...n})};Eh.displayName=TT;var Ih="DropdownMenuContent",Nh=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Sh(Ih,n),s=zt(n),i=h.useRef(!1);return u.jsx(uT,{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)"}})});Nh.displayName=Ih;var kT="DropdownMenuGroup",ET=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(dT,{...o,...r,ref:t})});ET.displayName=kT;var IT="DropdownMenuLabel",Ah=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(fT,{...o,...r,ref:t})});Ah.displayName=IT;var NT="DropdownMenuItem",jh=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(pT,{...o,...r,ref:t})});jh.displayName=NT;var AT="DropdownMenuCheckboxItem",Ph=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(hT,{...o,...r,ref:t})});Ph.displayName=AT;var jT="DropdownMenuRadioGroup",PT=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(mT,{...o,...r,ref:t})});PT.displayName=jT;var _T="DropdownMenuRadioItem",_h=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(gT,{...o,...r,ref:t})});_h.displayName=_T;var RT="DropdownMenuItemIndicator",Rh=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(xT,{...o,...r,ref:t})});Rh.displayName=RT;var MT="DropdownMenuSeparator",Mh=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(vT,{...o,...r,ref:t})});Mh.displayName=MT;var OT="DropdownMenuArrow",DT=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(bT,{...o,...r,ref:t})});DT.displayName=OT;var LT="DropdownMenuSubTrigger",Oh=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(wT,{...o,...r,ref:t})});Oh.displayName=LT;var $T="DropdownMenuSubContent",Dh=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=zt(n);return u.jsx(yT,{...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)"}})});Dh.displayName=$T;var FT=Ch,BT=kh,zT=Eh,Lh=Nh,$h=Ah,Fh=jh,Bh=Ph,zh=_h,Hh=Rh,Uh=Mh,Wh=Oh,Vh=Dh;const Js=FT,Zs=BT,HT=h.forwardRef(({className:e,inset:t,children:n,...r},o)=>u.jsxs(Wh,{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(de.ChevronRight,{className:"ml-auto h-4 w-4"})]}));HT.displayName=Wh.displayName;const UT=h.forwardRef(({className:e,...t},n)=>u.jsx(Vh,{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}));UT.displayName=Vh.displayName;const jo=h.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(zT,{children:u.jsx(Lh,{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})}));jo.displayName=Lh.displayName;const Kn=h.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(Fh,{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}));Kn.displayName=Fh.displayName;const WT=h.forwardRef(({className:e,children:t,checked:n,...r},o)=>u.jsxs(Bh,{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(Hh,{children:u.jsx(de.Check,{className:"h-4 w-4"})})}),t]}));WT.displayName=Bh.displayName;const VT=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(zh,{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(Hh,{children:u.jsx(de.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));VT.displayName=zh.displayName;const KT=h.forwardRef(({className:e,inset:t,...n},r)=>u.jsx($h,{ref:r,className:oe("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));KT.displayName=$h.displayName;const qT=h.forwardRef(({className:e,...t},n)=>u.jsx(Uh,{ref:n,className:oe("-mx-1 my-1 h-px bg-muted",e),...t}));qT.displayName=Uh.displayName;const vl=h.forwardRef(({className:e,...t},n)=>u.jsx("textarea",{className:oe("flex min-h-[40px] 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}));vl.displayName="Textarea";const GT=1e4;function Kh({initialValue:e="",editingMessageId:t=null,placeholder:n="Type your message...",isStreaming:r=!1,disabled:o=!1,maxLength:s=GT,value:i,onValueChange:a,onSend:l,onCancelEdit:c,onStop:d,className:f="",textareaClassName:m="",allowEmptySend:p=!1,sendButtonClassName:v,validate:g,onValidationError:x}){const y=i!==void 0,[w,C]=b.useState(e),E=(y?i:w)??"",[T,S]=b.useTransition(),k=b.useRef(null),A=b.useRef(0),j=b.useRef(null),F=b.useRef("");b.useEffect(()=>{if(!y&&(C(e??""),j.current=null,k.current)){const L=!e||e.trim()==="",$=44;L?k.current.style.height=`${$}px`:(k.current.style.height="auto",k.current.style.height=`${Math.max(k.current.scrollHeight,$)}px`)}},[e,t,y]);const[D,B]=b.useState(null),Y=b.useCallback(L=>L.length>s?`Message too long (${L.length}/${s} characters)`:null,[s]),M=b.useMemo(()=>g??Y,[g,Y]),W=b.useCallback(L=>{const $=M(L);return B($),x==null||x($),F.current=L,$},[M,x]),X=b.useCallback(()=>{const L=k.current;if(!L)return;const $=!L.value||L.value.trim()==="",J=44;if($){L.style.height=`${J}px`;return}L.style.height="auto";const R=Math.max(L.scrollHeight,J);L.style.height=`${R}px`},[]);b.useEffect(()=>{X()},[X,E]),b.useEffect(()=>{if(!D)return;const L=(E??"").trim();F.current!==L&&W(L)},[E,D,W]);const z=b.useCallback((L,{fromUser:$})=>{y||C(L),$&&(a==null||a(L))},[y,a]),P=b.useCallback(async L=>{L&&L.preventDefault();const $=(E??"").trim();if(!$&&!p||W($))return;const J=++A.current;j.current={id:J,shouldClear:!0},S(()=>{var R,_,U;try{const Z=l($);Z&&typeof Z.then=="function"?Z.then(()=>{var re,le;((re=j.current)==null?void 0:re.id)===J&&j.current.shouldClear&&(y||(C(""),k.current&&(k.current.style.height="auto"),a==null||a(""))),((le=j.current)==null?void 0:le.id)===J&&(j.current=null)}).catch(()=>{var re;((re=j.current)==null?void 0:re.id)===J&&(j.current=null)}):(((R=j.current)==null?void 0:R.id)===J&&j.current.shouldClear&&(y||(C(""),k.current&&(k.current.style.height="auto"),a==null||a(""))),((_=j.current)==null?void 0:_.id)===J&&(j.current=null))}catch{((U=j.current)==null?void 0:U.id)===J&&(j.current=null)}})},[E,l,p,y,a,W]),I=b.useCallback(L=>{const $=L.target.value;z($,{fromUser:!0}),j.current&&(j.current.shouldClear=!1),k.current&&(k.current.style.height="auto",k.current.style.height=`${k.current.scrollHeight}px`),D&&W($.trim())},[z,W,D]),q=b.useCallback(L=>{L.key==="Enter"&&!L.shiftKey?(L.preventDefault(),P()):L.key==="Escape"&&t&&(L.preventDefault(),c==null||c())},[P,t,c]),G=`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("div",{className:`w-full ${f}`,children:u.jsxs("div",{className:"flex items-end gap-2",children:[u.jsxs("div",{className:"flex-1",children:[u.jsx(vl,{ref:k,value:E,onChange:I,onKeyDown:q,placeholder:t?"Edit your message...":n,className:G,disabled:o,maxLength:s,rows:1,spellCheck:!1,autoCorrect:"off"}),D&&u.jsx("p",{className:"mt-1 text-xs text-destructive font-medium",children:D})]}),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(de.Square,{size:16})}):u.jsx(Xe,{type:"button",onClick:L=>void P(L),size:"icon",className:`shrink-0 ${v??""}`,title:t?"Save changes":"Send message",disabled:o||!E.trim()&&!p||T||r,children:u.jsx(de.Send,{size:16})})})]})})}const YT=b.memo(Kh);function qh({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:f={},enableFileUpload:m=!1,enableExcelUpload:p=!1,onExcelUpload:v,onFilesChange:g,onError:x,allowEmptySend:y=!1,inputError:w=null}){const[C,E]=b.useState([]),T=b.useRef(null),S=b.useRef(null),[k,A]=b.useState(0),[j,F]=b.useState(0),[D,B]=b.useState(!1),[Y,M]=b.useState(null),[W,X]=b.useState(null),z=b.useCallback(()=>{T.current&&(T.current.value=""),S.current&&(S.current.value=""),A($=>$+1),F($=>$+1)},[]),P=b.useCallback($=>{E(J=>{const R=[...J,...$];return g==null||g(R),R})},[g]),I=b.useCallback($=>{const J=Array.from($.target.files||[]);P(J),$.target.value=""},[P]),q=b.useCallback($=>{E(J=>{const R=J.filter((_,U)=>U!==$);return R.length===0&&z(),g==null||g(R),R})},[g,z]),Q=b.useCallback(async $=>{const J=($.target.files||[])[0];if(J&&(M(null),X(null),!!v)){B(!0);try{await v(J),M(`Uploaded ${J.name} - processing through chat stream`)}catch(R){const _=R instanceof Error?R.message:"Failed to upload Excel file";X(_),x==null||x(_)}finally{B(!1),$.target.value="",z()}}},[v,x,z]),O=b.useMemo(()=>y||C.length>0,[y,C]),G=b.useCallback(async $=>{const R=await n($,C);return C.length>0&&(E([]),g==null||g([]),z()),R},[n,z,C]),L=`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":""} ${w?"border-red-400":""} ${f.textarea||""} ${d}`;return u.jsxs(u.Fragment,{children:[(m||p)&&u.jsxs("div",{className:"mb-3 space-y-3",children:[m&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:T,type:"file",multiple:!0,onChange:I,className:"hidden"},k),C.length>0&&u.jsx("div",{className:"flex flex-wrap gap-2",children:C.map(($,J)=>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(de.Paperclip,{size:14}),u.jsx("span",{className:"truncate max-w-[150px]",children:$.name}),u.jsx(Xe,{variant:"ghost",size:"sm",onClick:()=>q(J),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 ${$.name}`,children:u.jsx(de.X,{size:12})})]},J))})]}),p&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:S,type:"file",accept:".xls,.xlsx,.xlsm",onChange:Q,className:"hidden"},j),D&&u.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(de.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),Y&&!D&&u.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:Y}),W&&!D&&u.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:W})]})]}),u.jsxs("div",{className:"flex items-end gap-2",children:[(m||p)&&u.jsxs(Js,{children:[u.jsx(Zs,{asChild:!0,children:u.jsx(Xe,{type:"button",size:"icon",variant:"outline",disabled:l||c,title:"More input actions",className:f.moreButton||"",children:u.jsx(de.Plus,{size:16})})}),u.jsxs(jo,{align:"start",sideOffset:6,className:"w-52",children:[m&&u.jsxs(Kn,{onClick:()=>{var $;return($=T.current)==null?void 0:$.click()},className:"cursor-pointer",children:[u.jsx(de.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),p&&u.jsxs(Kn,{onClick:()=>{var $;D||($=S.current)==null||$.click()},className:`cursor-pointer ${D?"opacity-60 pointer-events-none":""}`,children:[u.jsx(de.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),u.jsx("div",{className:"flex-1",children:u.jsx(YT,{initialValue:i,editingMessageId:s,value:e,onValueChange:t,placeholder:s?"Edit your message...":a,isStreaming:l,disabled:c,onSend:G,onCancelEdit:r,onStop:o,allowEmptySend:O,textareaClassName:L,sendButtonClassName:f.sendButton})})]})]})}const XT=b.memo(qh),Gh={value:""};function Fr({className:e="",placeholder:t="Type your message...",autoFocus:n=!0,maxHeight:r=void 0,streamingDebounceMs:o=500,followNewMessages:s=!0,enableFileUpload:i=!0,enableExcelUpload:a=!1,enableMessageEditing:l=!0,showToolMessages:c=!0,toolConfig:d,toolRenderers:f,toolArtifactRenderers:m,payloadExtras:p={},customStyles:v={},messageCustomStyles:g,onMessageSent:x,onExcelUploadSuccess:y,onError:w,defaultMessage:C}){const{chatApi:E}=On(),T=E.baseUrl,{currentThreadId:S}=yr(),{threadId:k,messages:A,isLoading:j,navigateToCheckpoint:F,returnToLatest:D,checkpoint:B,checkpoints:Y,interrupt:M,metadata:W,checkpointIndex:X,respondToInterrupt:z}=ro(),{isStreaming:P,error:I,connectionState:q,submit:Q,stop:O}=Ui(),G=k??S??null,L=(B==null?void 0:B.id)??null,$=(B==null?void 0:B.namespace)??null,J=(W==null?void 0:W.assemblingMessageId)??null;b.useEffect(()=>{console.log("[ChatInterface] streamingAssistantId changed:",{streamingAssistantId:J,isStreaming:P,assemblingMessageId:W==null?void 0:W.assemblingMessageId})},[J,P,W==null?void 0:W.assemblingMessageId]);const R=M,_=R?$i(R.id):null,U=_!==null?{type:"interrupt",id:_}:null,[Z,re]=b.useState(!1),[le,ke]=b.useState(!1);b.useEffect(()=>{R||re(!1)},[R]);const ye=b.useCallback(()=>{re(!0)},[]),_e=b.useCallback(()=>{re(!1)},[]),ze=b.useCallback(ee=>{},[]),$e=b.useCallback(ee=>ee.name!=="ask_user_choice",[]),Ge=d??{toolRenderers:f,toolArtifactRenderers:m,getToolExpandable:$e},He=b.useCallback(async(ee,ue,be)=>{try{ye(),await z(ee,ue,be)}catch(Ee){console.error("Failed to respond to interrupt:",Ee)}finally{_e()}},[_e,ye,z]),nt=b.useCallback(()=>He(!0),[He]),ft=b.useCallback(()=>He(!1),[He]),ct=b.useCallback((ee,ue)=>He(!0,ue),[He]),Ue=!!R||Z,[Re,Ve]=b.useState(null),[Ne,Ke]=b.useState(""),[Ye,Ct]=b.useState(null),[Ze,Tt]=b.useState(null),[pt,wt]=b.useState(!1),[At,Pt]=b.useState(null),ht=b.useRef(!1),[mt,Ht]=b.useState(()=>Gh.value),We=b.useRef(mt),Le=b.useRef(null),dt=b.useCallback(ee=>{Gh.value=ee,Ht(ee)},[]),[kt,ut]=b.useState(!1),_t=b.useRef(null),xe=b.useCallback(ee=>{dt(ee)},[dt]);b.useEffect(()=>{P||ke(!1)},[P]),b.useEffect(()=>{W!=null&&W.assemblingMessageId&&ke(!1)},[W==null?void 0:W.assemblingMessageId]);const[De,Fe]=b.useState("desktop");b.useEffect(()=>{const ee=()=>{const ue=window.innerWidth;Fe(ue<640?"phone":ue<1024?"tablet":"desktop")};return ee(),window.addEventListener("resize",ee),()=>window.removeEventListener("resize",ee)},[]),b.useEffect(()=>{ht.current=!1},[G]),b.useEffect(()=>{We.current=mt},[mt]),b.useEffect(()=>{if(!Re){Le.current=null;return}Le.current===null&&(Le.current=We.current),dt(Ne??"")},[Ne,Re,dt]),b.useEffect(()=>{if(C!==void 0){Pt(C);return}(async()=>{if(!T){Pt(null);return}try{const be=(await E.getAgent("default")).uiDefaultMessage||"";Pt(be||null)}catch(ue){console.warn("Failed to fetch default message:",ue),Pt(null)}})()},[E,T,C]),b.useEffect(()=>{I&&!pt&&(w==null||w(I))},[I,pt,w]);const rt=async(ee,ue)=>{const be=ee.trim();if(!(!be&&ue.length===0))try{const Ee=Re?(Ye==null?void 0:Ye.checkpointId)??L??void 0:L??void 0,je=Re?(Ye==null?void 0:Ye.checkpointNs)??$??void 0:$??void 0;await Q({text:be||"",attachments:ue,payload:p},{checkpointId:Ee,checkpointNs:je,edit:!!Re,originalMessageId:Re??void 0}),x==null||x(be),ke(!0),dt(""),Tt(null),Ve(null),Ke(""),Ct(null)}catch(Ee){const je=(Ee==null?void 0:Ee.message)||"Failed to send message";Tt(je),w==null||w(je),ke(!1)}},Qe=b.useCallback(async ee=>{await Q({attachments:[ee],payload:p},{checkpointId:L??void 0,checkpointNs:$??void 0}),y==null||y({file:ee})},[L,$,p,y,Q]),ot=b.useCallback((ee,ue,be)=>{l&&(Le.current=mt,Ve(ee),Ke(ue),dt(ue),Tt(null),Ct({checkpointId:(be==null?void 0:be.checkpointId)??null,checkpointNs:(be==null?void 0:be.checkpointNs)??null}))},[mt,l,dt]),gt=b.useCallback(()=>{Ve(null),Ke(""),Ct(null),Tt(null),dt(Le.current??mt),Le.current=null},[mt,dt]),K=b.useCallback((ee,ue,be)=>{ot(ee,ue,be)},[ot]),se=b.useCallback(ee=>{let ue=null;for(let Te=ee-1;Te>=0;Te--)if(A[Te].role==="user"){ue=A[Te];break}if(!ue)return;const be=Array.isArray(ue.content)?ue.content:[],je=be.filter(Te=>(Te==null?void 0:Te.type)==="text").map(Te=>Te.text).join("")||(()=>{try{return JSON.stringify(be,null,2)}catch{return String(be)}})();je&&Q({text:je,payload:p},{checkpointId:L??void 0,checkpointNs:$??void 0,edit:!0,originalMessageId:ue.id})},[A,Q,L,$,p]),ae=b.useCallback(async ee=>{if(S){ut(!0);try{if(!ee){await D(),requestAnimationFrame(()=>{var Ee;(Ee=_t.current)==null||Ee.scrollToLatest()});return}const ue=Y.find(Ee=>Ee.checkpointId===ee),be=(ue==null?void 0:ue.checkpointNs)??null;await F(ee,be),requestAnimationFrame(()=>{var Ee;(Ee=_t.current)==null||Ee.scrollToTop()})}finally{ut(!1)}}},[Y,S,_t,F,D]),me=b.useCallback(async(ee,ue,be)=>{await ae(be?null:ee)},[ae]),st=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${v.container||""}`,N=`flex-1 min-h-0 min-w-0 max-h-full w-full overflow-hidden overscroll-contain break-words break-anywhere p-4 ${R?"pb-32":""} bg-transparent ${v.messagesArea||""}`,te=`relative flex-shrink-0 w-full border-t p-4 bg-transparent ${v.inputArea||""}`;return u.jsxs("div",{className:st,children:[!!I&&!pt&&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:I}),u.jsx(Xe,{variant:"ghost",size:"sm",onClick:()=>wt(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:u.jsx(de.X,{size:16})})]}),u.jsxs("div",{className:`relative ${N}`,style:r?{maxHeight:r}:void 0,children:[u.jsx(Wa,{ref:_t,className:"h-full",style:{height:"100%"},messages:A,isStreaming:P,streamingAssistantId:J,streamingDebounceMs:o,followNewMessages:s,layoutSize:De,enableMessageEditing:l,editingMessageId:Re,onEdit:K,onRegenerate:se,onCancelEdit:gt,emptyMessage:At??void 0,isNavigatingCheckpoint:kt,showToolMessages:c,toolConfig:Ge,checkpointIndex:X,activeCheckpointId:L,onSelectCheckpoint:me,createSyntheticThinkingMessage:!0,forceSyntheticThinking:le,getMessageCustomStyles:g,getInterruptOptions:ze}),(q==="reconnecting"||q==="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(de.Loader2,{className:"h-3 w-3 animate-spin"}),q==="reconnecting"?"Reconnecting…":"Connecting…"]})}),q==="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"}),j&&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(de.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading messages…"})]}),kt&&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(de.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading checkpoint…"})]}),R&&U&&u.jsx("div",{className:"pointer-events-auto absolute inset-x-0 bottom-6 z-30 flex justify-center px-4",children:u.jsx("div",{className:"w-full max-w-3xl",children:u.jsx(va,{interruptPart:U,onApprove:nt,onReject:ft,onSelectAlternative:ct,disabled:Z,isActive:!0,payload:R.value})})})]}),u.jsxs("div",{className:te,children:[Re&&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(de.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:gt,className:"text-blue-600 hover:bg-blue-100",children:u.jsx(de.X,{size:16})})]})}),Ze&&u.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:Ze}),u.jsx(XT,{composerValue:mt,onComposerChange:xe,onSend:rt,onCancelEdit:gt,onStop:O,editingMessageId:Re,editingInitialValue:Ne,placeholder:Re?"Edit your message...":t,isStreaming:P,disabled:Ue,enableFileUpload:i,enableExcelUpload:a,onExcelUpload:Qe,onError:w,customStyles:v,textareaClassName:v.textarea||"",allowEmptySend:!1,inputError:Ze})]})]})}var Yh=1,JT=.9,ZT=.8,QT=.17,bl=.1,wl=.999,ek=.9999,tk=.99,nk=/[\\\/_+.#"@\[\(\{&]/,rk=/[\\\/_+.#"@\[\(\{&]/g,ok=/[\s-]/,Xh=/[\s-]/g;function yl(e,t,n,r,o,s,i){if(s===t.length)return o===e.length?Yh:tk;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,f,m,p,v;c>=0;)f=yl(e,t,n,r,c+1,s+1,i),f>d&&(c===o?f*=Yh:nk.test(e.charAt(c-1))?(f*=ZT,p=e.slice(o,c-1).match(rk),p&&o>0&&(f*=Math.pow(wl,p.length))):ok.test(e.charAt(c-1))?(f*=JT,v=e.slice(o,c-1).match(Xh),v&&o>0&&(f*=Math.pow(wl,v.length))):(f*=QT,o>0&&(f*=Math.pow(wl,c-o))),e.charAt(c)!==t.charAt(s)&&(f*=ek)),(f<bl&&n.charAt(c-1)===r.charAt(s+1)||r.charAt(s+1)===r.charAt(s)&&n.charAt(c-1)!==r.charAt(s))&&(m=yl(e,t,n,r,c+1,s+2,i),m*bl>f&&(f=m*bl)),f>d&&(d=f),c=n.indexOf(l,c+1);return i[a]=d,d}function Jh(e){return e.toLowerCase().replace(Xh," ")}function sk(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,yl(e,t,Jh(e),Jh(t),0,0,{})}var Po='[cmdk-group=""]',Sl='[cmdk-group-items=""]',ik='[cmdk-group-heading=""]',Zh='[cmdk-item=""]',Qh=`${Zh}:not([aria-disabled="true"])`,Cl="cmdk-item-select",Br="data-value",ak=(e,t,n)=>sk(e,t,n),em=h.createContext(void 0),_o=()=>h.useContext(em),tm=h.createContext(void 0),Tl=()=>h.useContext(tm),nm=h.createContext(void 0),rm=h.forwardRef((e,t)=>{let n=zr(()=>{var O,G;return{search:"",value:(G=(O=e.value)!=null?O:e.defaultValue)!=null?G:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=zr(()=>new Set),o=zr(()=>new Map),s=zr(()=>new Map),i=zr(()=>new Set),a=om(e),{label:l,children:c,value:d,onValueChange:f,filter:m,shouldFilter:p,loop:v,disablePointerSelection:g=!1,vimBindings:x=!0,...y}=e,w=jt(),C=jt(),E=jt(),T=h.useRef(null),S=vk();hr(()=>{if(d!==void 0){let O=d.trim();n.current.value=O,k.emit()}},[d]),hr(()=>{S(6,Y)},[]);let k=h.useMemo(()=>({subscribe:O=>(i.current.add(O),()=>i.current.delete(O)),snapshot:()=>n.current,setState:(O,G,L)=>{var $,J,R,_;if(!Object.is(n.current[O],G)){if(n.current[O]=G,O==="search")B(),F(),S(1,D);else if(O==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let U=document.getElementById(E);U?U.focus():($=document.getElementById(w))==null||$.focus()}if(S(7,()=>{var U;n.current.selectedItemId=(U=M())==null?void 0:U.id,k.emit()}),L||S(5,Y),((J=a.current)==null?void 0:J.value)!==void 0){let U=G??"";(_=(R=a.current).onValueChange)==null||_.call(R,U);return}}k.emit()}},emit:()=>{i.current.forEach(O=>O())}}),[]),A=h.useMemo(()=>({value:(O,G,L)=>{var $;G!==(($=s.current.get(O))==null?void 0:$.value)&&(s.current.set(O,{value:G,keywords:L}),n.current.filtered.items.set(O,j(G,L)),S(2,()=>{F(),k.emit()}))},item:(O,G)=>(r.current.add(O),G&&(o.current.has(G)?o.current.get(G).add(O):o.current.set(G,new Set([O]))),S(3,()=>{B(),F(),n.current.value||D(),k.emit()}),()=>{s.current.delete(O),r.current.delete(O),n.current.filtered.items.delete(O);let L=M();S(4,()=>{B(),(L==null?void 0:L.getAttribute("id"))===O&&D(),k.emit()})}),group:O=>(o.current.has(O)||o.current.set(O,new Set),()=>{s.current.delete(O),o.current.delete(O)}),filter:()=>a.current.shouldFilter,label:l||e["aria-label"],getDisablePointerSelection:()=>a.current.disablePointerSelection,listId:w,inputId:E,labelId:C,listInnerRef:T}),[]);function j(O,G){var L,$;let J=($=(L=a.current)==null?void 0:L.filter)!=null?$:ak;return O?J(O,n.current.search,G):0}function F(){if(!n.current.search||a.current.shouldFilter===!1)return;let O=n.current.filtered.items,G=[];n.current.filtered.groups.forEach($=>{let J=o.current.get($),R=0;J.forEach(_=>{let U=O.get(_);R=Math.max(U,R)}),G.push([$,R])});let L=T.current;W().sort(($,J)=>{var R,_;let U=$.getAttribute("id"),Z=J.getAttribute("id");return((R=O.get(Z))!=null?R:0)-((_=O.get(U))!=null?_:0)}).forEach($=>{let J=$.closest(Sl);J?J.appendChild($.parentElement===J?$:$.closest(`${Sl} > *`)):L.appendChild($.parentElement===L?$:$.closest(`${Sl} > *`))}),G.sort(($,J)=>J[1]-$[1]).forEach($=>{var J;let R=(J=T.current)==null?void 0:J.querySelector(`${Po}[${Br}="${encodeURIComponent($[0])}"]`);R==null||R.parentElement.appendChild(R)})}function D(){let O=W().find(L=>L.getAttribute("aria-disabled")!=="true"),G=O==null?void 0:O.getAttribute(Br);k.setState("value",G||void 0)}function B(){var O,G,L,$;if(!n.current.search||a.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let J=0;for(let R of r.current){let _=(G=(O=s.current.get(R))==null?void 0:O.value)!=null?G:"",U=($=(L=s.current.get(R))==null?void 0:L.keywords)!=null?$:[],Z=j(_,U);n.current.filtered.items.set(R,Z),Z>0&&J++}for(let[R,_]of o.current)for(let U of _)if(n.current.filtered.items.get(U)>0){n.current.filtered.groups.add(R);break}n.current.filtered.count=J}function Y(){var O,G,L;let $=M();$&&(((O=$.parentElement)==null?void 0:O.firstChild)===$&&((L=(G=$.closest(Po))==null?void 0:G.querySelector(ik))==null||L.scrollIntoView({block:"nearest"})),$.scrollIntoView({block:"nearest"}))}function M(){var O;return(O=T.current)==null?void 0:O.querySelector(`${Zh}[aria-selected="true"]`)}function W(){var O;return Array.from(((O=T.current)==null?void 0:O.querySelectorAll(Qh))||[])}function X(O){let G=W()[O];G&&k.setState("value",G.getAttribute(Br))}function z(O){var G;let L=M(),$=W(),J=$.findIndex(_=>_===L),R=$[J+O];(G=a.current)!=null&&G.loop&&(R=J+O<0?$[$.length-1]:J+O===$.length?$[0]:$[J+O]),R&&k.setState("value",R.getAttribute(Br))}function P(O){let G=M(),L=G==null?void 0:G.closest(Po),$;for(;L&&!$;)L=O>0?gk(L,Po):xk(L,Po),$=L==null?void 0:L.querySelector(Qh);$?k.setState("value",$.getAttribute(Br)):z(O)}let I=()=>X(W().length-1),q=O=>{O.preventDefault(),O.metaKey?I():O.altKey?P(1):z(1)},Q=O=>{O.preventDefault(),O.metaKey?X(0):O.altKey?P(-1):z(-1)};return h.createElement(he.div,{ref:t,tabIndex:-1,...y,"cmdk-root":"",onKeyDown:O=>{var G;(G=y.onKeyDown)==null||G.call(y,O);let L=O.nativeEvent.isComposing||O.keyCode===229;if(!(O.defaultPrevented||L))switch(O.key){case"n":case"j":{x&&O.ctrlKey&&q(O);break}case"ArrowDown":{q(O);break}case"p":case"k":{x&&O.ctrlKey&&Q(O);break}case"ArrowUp":{Q(O);break}case"Home":{O.preventDefault(),X(0);break}case"End":{O.preventDefault(),I();break}case"Enter":{O.preventDefault();let $=M();if($){let J=new Event(Cl);$.dispatchEvent(J)}}}}},h.createElement("label",{"cmdk-label":"",htmlFor:A.inputId,id:A.labelId,style:wk},l),Qs(e,O=>h.createElement(tm.Provider,{value:k},h.createElement(em.Provider,{value:A},O))))}),lk=h.forwardRef((e,t)=>{var n,r;let o=jt(),s=h.useRef(null),i=h.useContext(nm),a=_o(),l=om(e),c=(r=(n=l.current)==null?void 0:n.forceMount)!=null?r:i==null?void 0:i.forceMount;hr(()=>{if(!c)return a.item(o,i==null?void 0:i.id)},[c]);let d=sm(o,s,[e.value,e.children,s],e.keywords),f=Tl(),m=qn(S=>S.value&&S.value===d.current),p=qn(S=>c||a.filter()===!1?!0:S.search?S.filtered.items.get(o)>0:!0);h.useEffect(()=>{let S=s.current;if(!(!S||e.disabled))return S.addEventListener(Cl,v),()=>S.removeEventListener(Cl,v)},[p,e.onSelect,e.disabled]);function v(){var S,k;g(),(k=(S=l.current).onSelect)==null||k.call(S,d.current)}function g(){f.setState("value",d.current,!0)}if(!p)return null;let{disabled:x,value:y,onSelect:w,forceMount:C,keywords:E,...T}=e;return h.createElement(he.div,{ref:Dn(s,t),...T,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)}),ck=h.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:o,...s}=e,i=jt(),a=h.useRef(null),l=h.useRef(null),c=jt(),d=_o(),f=qn(p=>o||d.filter()===!1?!0:p.search?p.filtered.groups.has(i):!0);hr(()=>d.group(i),[]),sm(i,a,[e.value,e.heading,l]);let m=h.useMemo(()=>({id:i,forceMount:o}),[o]);return h.createElement(he.div,{ref:Dn(a,t),...s,"cmdk-group":"",role:"presentation",hidden:f?void 0:!0},n&&h.createElement("div",{ref:l,"cmdk-group-heading":"","aria-hidden":!0,id:c},n),Qs(e,p=>h.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?c:void 0},h.createElement(nm.Provider,{value:m},p))))}),uk=h.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,o=h.useRef(null),s=qn(i=>!i.search);return!n&&!s?null:h.createElement(he.div,{ref:Dn(o,t),...r,"cmdk-separator":"",role:"separator"})}),dk=h.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,o=e.value!=null,s=Tl(),i=qn(c=>c.search),a=qn(c=>c.selectedItemId),l=_o();return h.useEffect(()=>{e.value!=null&&s.setState("search",e.value)},[e.value]),h.createElement(he.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)}})}),fk=h.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...o}=e,s=h.useRef(null),i=h.useRef(null),a=qn(c=>c.selectedItemId),l=_o();return h.useEffect(()=>{if(i.current&&s.current){let c=i.current,d=s.current,f,m=new ResizeObserver(()=>{f=requestAnimationFrame(()=>{let p=c.offsetHeight;d.style.setProperty("--cmdk-list-height",p.toFixed(1)+"px")})});return m.observe(c),()=>{cancelAnimationFrame(f),m.unobserve(c)}}},[]),h.createElement(he.div,{ref:Dn(s,t),...o,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":a,"aria-label":r,id:l.listId},Qs(e,c=>h.createElement("div",{ref:Dn(i,l.listInnerRef),"cmdk-list-sizer":""},c)))}),pk=h.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:o,contentClassName:s,container:i,...a}=e;return h.createElement(ia,{open:n,onOpenChange:r},h.createElement(aa,{container:i},h.createElement(io,{"cmdk-overlay":"",className:o}),h.createElement(ao,{"aria-label":e.label,"cmdk-dialog":"",className:s},h.createElement(rm,{ref:t,...a}))))}),hk=h.forwardRef((e,t)=>qn(n=>n.filtered.count===0)?h.createElement(he.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),mk=h.forwardRef((e,t)=>{let{progress:n,children:r,label:o="Loading...",...s}=e;return h.createElement(he.div,{ref:t,...s,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":o},Qs(e,i=>h.createElement("div",{"aria-hidden":!0},i)))}),Gt=Object.assign(rm,{List:fk,Item:lk,Input:dk,Group:ck,Separator:uk,Dialog:pk,Empty:hk,Loading:mk});function gk(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function xk(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function om(e){let t=h.useRef(e);return hr(()=>{t.current=e}),t}var hr=typeof window>"u"?h.useEffect:h.useLayoutEffect;function zr(e){let t=h.useRef();return t.current===void 0&&(t.current=e()),t}function qn(e){let t=Tl(),n=()=>e(t.snapshot());return h.useSyncExternalStore(t.subscribe,n,n)}function sm(e,t,n,r=[]){let o=h.useRef(),s=_o();return hr(()=>{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(Br,a),o.current=a}),o}var vk=()=>{let[e,t]=h.useState(),n=zr(()=>new Map);return hr(()=>{n.current.forEach(r=>r()),n.current=new Map},[e]),(r,o)=>{n.current.set(r,o),t({})}};function bk(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function Qs({asChild:e,children:t},n){return e&&h.isValidElement(t)?h.cloneElement(bk(t),{ref:t.ref},n(t.props.children)):n(t)}var wk={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const kl=h.forwardRef(({className:e,...t},n)=>u.jsx(Gt,{ref:n,className:oe("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));kl.displayName=Gt.displayName;const El=h.forwardRef(({className:e,...t},n)=>u.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[u.jsx(de.Search,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),u.jsx(Gt.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})]}));El.displayName=Gt.Input.displayName;const Il=h.forwardRef(({className:e,...t},n)=>u.jsx(Gt.List,{ref:n,className:oe("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));Il.displayName=Gt.List.displayName;const Nl=h.forwardRef((e,t)=>u.jsx(Gt.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));Nl.displayName=Gt.Empty.displayName;const Al=h.forwardRef(({className:e,...t},n)=>u.jsx(Gt.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}));Al.displayName=Gt.Group.displayName;const yk=h.forwardRef(({className:e,...t},n)=>u.jsx(Gt.Separator,{ref:n,className:oe("-mx-1 h-px bg-border",e),...t}));yk.displayName=Gt.Separator.displayName;const jl=h.forwardRef(({className:e,...t},n)=>u.jsx(Gt.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}));jl.displayName=Gt.Item.displayName;function Pl(e,[t,n]){return Math.min(n,Math.max(t,e))}function Sk(e,t){return h.useReducer((n,r)=>t[n][r]??n,e)}var _l="ScrollArea",[im,VN]=nn(_l),[Ck,an]=im(_l),am=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,l]=h.useState(null),[c,d]=h.useState(null),[f,m]=h.useState(null),[p,v]=h.useState(null),[g,x]=h.useState(null),[y,w]=h.useState(0),[C,E]=h.useState(0),[T,S]=h.useState(!1),[k,A]=h.useState(!1),j=Me(t,D=>l(D)),F=Os(o);return u.jsx(Ck,{scope:n,type:r,dir:F,scrollHideDelay:s,scrollArea:a,viewport:c,onViewportChange:d,content:f,onContentChange:m,scrollbarX:p,onScrollbarXChange:v,scrollbarXEnabled:T,onScrollbarXEnabledChange:S,scrollbarY:g,onScrollbarYChange:x,scrollbarYEnabled:k,onScrollbarYEnabledChange:A,onCornerWidthChange:w,onCornerHeightChange:E,children:u.jsx(he.div,{dir:F,...i,ref:j,style:{position:"relative","--radix-scroll-area-corner-width":y+"px","--radix-scroll-area-corner-height":C+"px",...e.style}})})});am.displayName=_l;var lm="ScrollAreaViewport",cm=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=an(lm,n),a=h.useRef(null),l=Me(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(he.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})})]})});cm.displayName=lm;var En="ScrollAreaScrollbar",Rl=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=an(En,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:i}=o,a=e.orientation==="horizontal";return h.useEffect(()=>(a?s(!0):i(!0),()=>{a?s(!1):i(!1)}),[a,s,i]),o.type==="hover"?u.jsx(Tk,{...r,ref:t,forceMount:n}):o.type==="scroll"?u.jsx(kk,{...r,ref:t,forceMount:n}):o.type==="auto"?u.jsx(um,{...r,ref:t,forceMount:n}):o.type==="always"?u.jsx(Ml,{...r,ref:t}):null});Rl.displayName=En;var Tk=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=an(En,e.__scopeScrollArea),[s,i]=h.useState(!1);return h.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(Ft,{present:n||s,children:u.jsx(um,{"data-state":s?"visible":"hidden",...r,ref:t})})}),kk=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=an(En,e.__scopeScrollArea),s=e.orientation==="horizontal",i=ri(()=>l("SCROLL_END"),100),[a,l]=Sk("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 h.useEffect(()=>{if(a==="idle"){const c=window.setTimeout(()=>l("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(c)}},[a,o.scrollHideDelay,l]),h.useEffect(()=>{const c=o.viewport,d=s?"scrollLeft":"scrollTop";if(c){let f=c[d];const m=()=>{const p=c[d];f!==p&&(l("SCROLL"),i()),f=p};return c.addEventListener("scroll",m),()=>c.removeEventListener("scroll",m)}},[o.viewport,s,l,i]),u.jsx(Ft,{present:n||a!=="hidden",children:u.jsx(Ml,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:ce(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:ce(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),um=h.forwardRef((e,t)=>{const n=an(En,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=h.useState(!1),a=e.orientation==="horizontal",l=ri(()=>{if(n.viewport){const c=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?c:d)}},10);return Hr(n.viewport,l),Hr(n.content,l),u.jsx(Ft,{present:r||s,children:u.jsx(Ml,{"data-state":s?"visible":"hidden",...o,ref:t})})}),Ml=h.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=an(En,e.__scopeScrollArea),s=h.useRef(null),i=h.useRef(0),[a,l]=h.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),c=mm(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 f(m,p){return Pk(m,i.current,a,p)}return n==="horizontal"?u.jsx(Ek,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollLeft,p=gm(m,a,o.dir);s.current.style.transform=`translate3d(${p}px, 0, 0)`}},onWheelScroll:m=>{o.viewport&&(o.viewport.scrollLeft=m)},onDragScroll:m=>{o.viewport&&(o.viewport.scrollLeft=f(m,o.dir))}}):n==="vertical"?u.jsx(Ik,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollTop,p=gm(m,a);s.current.style.transform=`translate3d(0, ${p}px, 0)`}},onWheelScroll:m=>{o.viewport&&(o.viewport.scrollTop=m)},onDragScroll:m=>{o.viewport&&(o.viewport.scrollTop=f(m))}}):null}),Ek=h.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=an(En,e.__scopeScrollArea),[i,a]=h.useState(),l=h.useRef(null),c=Me(t,l,s.onScrollbarXChange);return h.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(fm,{"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":ni(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.x),onDragScroll:d=>e.onDragScroll(d.x),onWheelScroll:(d,f)=>{if(s.viewport){const m=s.viewport.scrollLeft+d.deltaX;e.onWheelScroll(m),vm(m,f)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:l.current.clientWidth,paddingStart:ti(i.paddingLeft),paddingEnd:ti(i.paddingRight)}})}})}),Ik=h.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=an(En,e.__scopeScrollArea),[i,a]=h.useState(),l=h.useRef(null),c=Me(t,l,s.onScrollbarYChange);return h.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(fm,{"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":ni(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.y),onDragScroll:d=>e.onDragScroll(d.y),onWheelScroll:(d,f)=>{if(s.viewport){const m=s.viewport.scrollTop+d.deltaY;e.onWheelScroll(m),vm(m,f)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:l.current.clientHeight,paddingStart:ti(i.paddingTop),paddingEnd:ti(i.paddingBottom)}})}})}),[Nk,dm]=im(En),fm=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:l,onDragScroll:c,onWheelScroll:d,onResize:f,...m}=e,p=an(En,n),[v,g]=h.useState(null),x=Me(t,j=>g(j)),y=h.useRef(null),w=h.useRef(""),C=p.viewport,E=r.content-r.viewport,T=vt(d),S=vt(l),k=ri(f,10);function A(j){if(y.current){const F=j.clientX-y.current.left,D=j.clientY-y.current.top;c({x:F,y:D})}}return h.useEffect(()=>{const j=F=>{const D=F.target;(v==null?void 0:v.contains(D))&&T(F,E)};return document.addEventListener("wheel",j,{passive:!1}),()=>document.removeEventListener("wheel",j,{passive:!1})},[C,v,E,T]),h.useEffect(S,[r,S]),Hr(v,k),Hr(p.content,k),u.jsx(Nk,{scope:n,scrollbar:v,hasThumb:o,onThumbChange:vt(s),onThumbPointerUp:vt(i),onThumbPositionChange:S,onThumbPointerDown:vt(a),children:u.jsx(he.div,{...m,ref:x,style:{position:"absolute",...m.style},onPointerDown:ce(e.onPointerDown,j=>{j.button===0&&(j.target.setPointerCapture(j.pointerId),y.current=v.getBoundingClientRect(),w.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",p.viewport&&(p.viewport.style.scrollBehavior="auto"),A(j))}),onPointerMove:ce(e.onPointerMove,A),onPointerUp:ce(e.onPointerUp,j=>{const F=j.target;F.hasPointerCapture(j.pointerId)&&F.releasePointerCapture(j.pointerId),document.body.style.webkitUserSelect=w.current,p.viewport&&(p.viewport.style.scrollBehavior=""),y.current=null})})})}),ei="ScrollAreaThumb",pm=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=dm(ei,e.__scopeScrollArea);return u.jsx(Ft,{present:n||o.hasThumb,children:u.jsx(Ak,{ref:t,...r})})}),Ak=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=an(ei,n),i=dm(ei,n),{onThumbPositionChange:a}=i,l=Me(t,f=>i.onThumbChange(f)),c=h.useRef(void 0),d=ri(()=>{c.current&&(c.current(),c.current=void 0)},100);return h.useEffect(()=>{const f=s.viewport;if(f){const m=()=>{if(d(),!c.current){const p=_k(f,a);c.current=p,a()}};return a(),f.addEventListener("scroll",m),()=>f.removeEventListener("scroll",m)}},[s.viewport,d,a]),u.jsx(he.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,f=>{const p=f.target.getBoundingClientRect(),v=f.clientX-p.left,g=f.clientY-p.top;i.onThumbPointerDown({x:v,y:g})}),onPointerUp:ce(e.onPointerUp,i.onThumbPointerUp)})});pm.displayName=ei;var Ol="ScrollAreaCorner",hm=h.forwardRef((e,t)=>{const n=an(Ol,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?u.jsx(jk,{...e,ref:t}):null});hm.displayName=Ol;var jk=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=an(Ol,n),[s,i]=h.useState(0),[a,l]=h.useState(0),c=!!(s&&a);return Hr(o.scrollbarX,()=>{var f;const d=((f=o.scrollbarX)==null?void 0:f.offsetHeight)||0;o.onCornerHeightChange(d),l(d)}),Hr(o.scrollbarY,()=>{var f;const d=((f=o.scrollbarY)==null?void 0:f.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),c?u.jsx(he.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 ti(e){return e?parseInt(e,10):0}function mm(e,t){const n=e/t;return isNaN(n)?0:n}function ni(e){const t=mm(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function Pk(e,t,n,r="ltr"){const o=ni(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,f=r==="ltr"?[0,d]:[d*-1,0];return xm([l,c],f)(e)}function gm(e,t,n="ltr"){const r=ni(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=Pl(e,l);return xm([0,i],[0,a])(c)}function xm(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 vm(e,t){return e>0&&e<t}var _k=(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 ri(e,t){const n=vt(e),r=h.useRef(0);return h.useEffect(()=>()=>window.clearTimeout(r.current),[]),h.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function Hr(e,t){const n=vt(t);It(()=>{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 bm=am,Rk=cm,Mk=hm;const Dl=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(bm,{ref:r,className:oe("relative overflow-hidden",e),...n,children:[u.jsx(Rk,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),u.jsx(wm,{}),u.jsx(Mk,{})]}));Dl.displayName=bm.displayName;const wm=h.forwardRef(({className:e,orientation:t="vertical",...n},r)=>u.jsx(Rl,{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(pm,{className:"relative flex-1 rounded-full bg-border"})}));wm.displayName=Rl.displayName;const Ll=h.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}));Ll.displayName="Input";const Ok="group relative p-3 rounded-lg cursor-pointer transition-colors border text-gray-900 dark:text-slate-100",Dk="bg-slate-700 border-slate-600 hover:bg-slate-600",Lk="bg-slate-600 border-slate-500";function $l({thread:e,isActive:t,editingThreadId:n,editingTitle:r,onSelect:o,onStartEditing:s,onEditingTitleChange:i,onSaveEditing:a,onCancelEditing:l,onShare:c,onDelete:d,showEditTitle:f,showDeleteButton:m,formatDate:p,getDisplayThreadTitle:v,secondaryLine:g,itemClassName:x,activeItemClassName:y}){var T;const w=n===e.threadId,C=t?`${y??Lk}`:`${x??Dk}`,E=S=>{S.stopPropagation(),o(e.threadId)};return u.jsxs("div",{onClick:E,className:`${Ok} ${C}`,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:S=>S.stopPropagation(),children:[u.jsx(Ll,{value:r,onChange:S=>i(S.target.value),onKeyDown:S=>{S.key==="Enter"?a(e.threadId):S.key==="Escape"&&l()},className:"h-6 text-sm",autoFocus:!0}),u.jsx(Xe,{variant:"ghost",size:"sm",onClick:()=>a(e.threadId),className:"h-6 w-6 p-0",children:u.jsx(de.Check,{size:12})}),u.jsx(Xe,{variant:"ghost",size:"sm",onClick:l,className:"h-6 w-6 p-0",children:u.jsx(de.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(de.Calendar,{size:10}),u.jsx("span",{children:p(e.updatedAt||e.createdAt)}),((T=e.project)==null?void 0:T.name)&&u.jsx("span",{className:"flex items-center gap-1.5 before:content-['•'] before:text-gray-300 dark:before:text-slate-600",children:u.jsx("span",{className:"truncate max-w-[100px]",children:e.project.name})})]}),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(Js,{children:[u.jsx(Zs,{asChild:!0,children:u.jsx(Xe,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",children:u.jsx(de.MoreHorizontal,{size:12})})}),u.jsxs(jo,{align:"end",sideOffset:6,className:"w-44",style:{zIndex:9999},children:[u.jsxs(Kn,{onClick:S=>{S.preventDefault(),c(e.threadId)},children:[u.jsx(de.Share2,{className:"mr-2 h-4 w-4"}),"Share thread"]}),f&&n!==e.threadId&&u.jsxs(Kn,{onClick:S=>{S.preventDefault(),s(e,S)},children:[u.jsx(de.Edit3,{className:"mr-2 h-4 w-4"}),"Rename"]}),m&&d&&u.jsxs(Kn,{className:"text-red-400 hover:text-red-300",onClick:S=>{S.preventDefault(),d(e.threadId,S)},children:[u.jsx(de.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"})]})}var oi="Collapsible",[$k,KN]=nn(oi),[Fk,Fl]=$k(oi),ym=h.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:o,disabled:s,onOpenChange:i,...a}=e,[l,c]=In({prop:r,defaultProp:o??!1,onChange:i,caller:oi});return u.jsx(Fk,{scope:n,disabled:s,contentId:jt(),open:l,onOpenToggle:h.useCallback(()=>c(d=>!d),[c]),children:u.jsx(he.div,{"data-state":zl(l),"data-disabled":s?"":void 0,...a,ref:t})})});ym.displayName=oi;var Sm="CollapsibleTrigger",Cm=h.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,o=Fl(Sm,n);return u.jsx(he.button,{type:"button","aria-controls":o.contentId,"aria-expanded":o.open||!1,"data-state":zl(o.open),"data-disabled":o.disabled?"":void 0,disabled:o.disabled,...r,ref:t,onClick:ce(e.onClick,o.onOpenToggle)})});Cm.displayName=Sm;var Bl="CollapsibleContent",Tm=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Fl(Bl,e.__scopeCollapsible);return u.jsx(Ft,{present:n||o.open,children:({present:s})=>u.jsx(Bk,{...r,ref:t,present:s})})});Tm.displayName=Bl;var Bk=h.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:o,...s}=e,i=Fl(Bl,n),[a,l]=h.useState(r),c=h.useRef(null),d=Me(t,c),f=h.useRef(0),m=f.current,p=h.useRef(0),v=p.current,g=i.open||a,x=h.useRef(g),y=h.useRef(void 0);return h.useEffect(()=>{const w=requestAnimationFrame(()=>x.current=!1);return()=>cancelAnimationFrame(w)},[]),It(()=>{const w=c.current;if(w){y.current=y.current||{transitionDuration:w.style.transitionDuration,animationName:w.style.animationName},w.style.transitionDuration="0s",w.style.animationName="none";const C=w.getBoundingClientRect();f.current=C.height,p.current=C.width,x.current||(w.style.transitionDuration=y.current.transitionDuration,w.style.animationName=y.current.animationName),l(r)}},[i.open,r]),u.jsx(he.div,{"data-state":zl(i.open),"data-disabled":i.disabled?"":void 0,id:i.contentId,hidden:!g,...s,ref:d,style:{"--radix-collapsible-content-height":m?`${m}px`:void 0,"--radix-collapsible-content-width":v?`${v}px`:void 0,...e.style},children:g&&o})});function zl(e){return e?"open":"closed"}var zk=ym;const Hk=zk,Uk=Cm,Wk=Tm,km=25,Em="thread-manager-view",Vk=e=>e==="default"||e==="shared",Kk=()=>{if(typeof window>"u")return null;try{const e=window.localStorage.getItem(Em);if(Vk(e))return e}catch{}return null};function Im({defaultView:e}={}){const[t,n]=b.useState(()=>Kk()??e??"default");b.useEffect(()=>{if(!(typeof window>"u"))try{window.localStorage.setItem(Em,t)}catch{}},[t]);const r=b.useCallback(o=>{n(o)},[]);return{view:t,setView:r}}const qk=[{key:"default",label:"My chats"},{key:"shared",label:"Shared with you"}];function si({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:f,defaultView:m,onViewChange:p,viewOptions:v,viewState:g,showHeader:x=!0,shareTargets:y,isLoadingShareTargets:w,shareTargetFilter:C,groupBy:E}){const{chatApi:T,authApi:S}=On(),{threads:k,sharedThreads:A,currentThreadId:j,setCurrentThreadId:F,isLoading:D,isLoadingSharedThreads:B,actions:Y,shareInFlight:M,shareStatus:W,clearShareStatus:X}=yr(),{createThread:z,deleteThread:P,renameThread:I,shareThread:q}=Y,{loadThread:Q}=ro(),O=i??j,[G,L]=b.useState(Array.isArray(k)?k:[]),$=b.useRef(G.length>0),J=b.useRef(null),R=b.useRef(0),[_,U]=b.useState(null),[Z,re]=b.useState(""),[le,ke]=b.useState(!1),[ye,_e]=b.useState(!1),[ze,$e]=b.useState(null),[Ge,He]=b.useState(""),[nt,ft]=b.useState([]),[ct,Ue]=b.useState(!1);b.useEffect(()=>{ye&&!y&&nt.length===0&&!ct&&(async()=>{Ue(!0);try{const ae=(await S.listUsers()).filter(me=>me.id||me.user_id).map(me=>({type:"user",value:me.user_id||me.id||"",id:me.user_id||me.id||"",label:me.name||me.username||me.email||"Unknown User",secondaryLabel:me.name||me.username?me.email:void 0}));ft(ae)}catch(se){console.error("Failed to load users for sharing:",se)}finally{Ue(!1)}})()},[ye,y,nt.length,ct,T]);const Re=y??nt,Ve=w??ct,Ne=v&&v.length>0?v:qk,Ke=Im({defaultView:m}),Ye=g??Ke,Ct=f??Ye.view,Ze=b.useCallback(K=>{f||Ye.setView(K),p==null||p(K)},[f,p,Ye]),Tt=Ne.find(K=>K.key===Ct)??Ne[0],pt=K=>{$e(K),He(""),_e(!0)},wt=()=>{_e(!1),$e(null),He(""),X()},At=b.useCallback(async K=>{if(!(!ze||M)&&K.id)try{await q(ze,K.id),setTimeout(()=>wt(),600)}catch(se){console.error("Failed to share thread:",se)}},[wt,M,ze,q]),Pt=b.useMemo(()=>{const K=Re,se=Ge.trim().toLowerCase();return se?C?K.filter(ae=>C(ae,se)):K.filter(ae=>`${ae.label} ${ae.secondaryLabel??""}`.toLowerCase().includes(se)):K},[y,Ge,C]),ht=Ct==="shared",mt=ht?A:G,Ht=b.useMemo(()=>{if(!E||ht)return null;const K={},se="Default";return mt.forEach(ae=>{var st,N;let me=se;E==="project"?me=((st=ae.project)==null?void 0:st.name)||((N=ae.project)==null?void 0:N.id)||se:me=ae[E]||se,K[me]||(K[me]=[]),K[me].push(ae)}),Object.keys(K).forEach(ae=>{K[ae].sort((me,st)=>new Date(st.updatedAt||st.createdAt||"").getTime()-new Date(me.updatedAt||me.createdAt||"").getTime())}),K},[mt,E,ht]),We=ht?B:D,Le=ht?"No shared conversations yet":"No conversations yet",dt=K=>{const se=K.sharedAt?` • ${Qe(K.sharedAt)}`:"";return`Shared by ${K.sharedByUserId}${se}`},kt=K=>"sharedByUserId"in K;b.useEffect(()=>{const K=Array.isArray(k)?k:[];if(K.length>0){$.current=!0,L(K);return}D||($.current=!1,L(K))},[k,D]),b.useEffect(()=>{if(!J.current)return;const K=J.current.querySelector("[data-radix-scroll-area-viewport]");if(!K)return;let se=null,ae=null;return se=requestAnimationFrame(()=>{ae=requestAnimationFrame(()=>{K.scrollTop=R.current})}),()=>{se!==null&&cancelAnimationFrame(se),ae!==null&&cancelAnimationFrame(ae)}},[G]);const ut=async K=>{try{F(K),await Q(K),a==null||a(K),l==null||l(K)}catch(se){console.error("Failed to select thread:",se)}},_t=async()=>{try{ke(!0);const K=await z();K&&(c==null||c(K),a==null||a(K))}catch(K){console.error("Failed to create thread:",K)}finally{ke(!1)}},xe=async(K,se)=>{if(se.stopPropagation(),!!confirm("Delete this thread?")){if(J.current){const ae=J.current.querySelector("[data-radix-scroll-area-viewport]");ae&&(R.current=ae.scrollTop)}try{await P(K),d==null||d(K)}catch(ae){console.error("Failed to delete thread:",ae)}}},De=(K,se)=>{se.stopPropagation(),U(K.threadId),re(K.title||`Thread ${K.threadId.slice(0,8)}`)},Fe=async K=>{if(Z.trim())try{await I(K,Z.trim()),U(null),re("")}catch(se){console.error("Failed to update title:",se)}},rt=()=>{U(null),re("")},Qe=K=>{if(!K)return"";try{const se=K.endsWith("Z")||K.includes("+")?K:`${K}Z`,ae=new Date(se),st=new Date().getTime()-ae.getTime(),N=Math.floor(st/(1e3*60*60*24));return N===0?ae.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):N===1?"Yesterday":N<7?`${N} days ago`:ae.toLocaleDateString()}catch{return""}},ot=K=>K.title||`Thread ${K.threadId.slice(0,8)}`,gt=K=>{const se=ot(K);return se.length<=km?se:`${se.slice(0,km)}...`};return u.jsxs("div",{className:`thread-manager-root 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:_t,disabled:le||D,className:s.createButton||"px-3 py-2 gap-1",size:"sm",variant:"ghost",title:le?"Creating...":"New Chat",children:[u.jsx(de.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(Js,{children:[u.jsx(Zs,{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:Tt.label})}),u.jsx(jo,{align:"start",sideOffset:6,className:"w-40",children:Ne.map(K=>u.jsxs(Kn,{className:"justify-between text-[12px]",onClick:se=>{se.preventDefault(),Ze(K.key)},children:[u.jsx("span",{children:K.label}),Ct===K.key&&u.jsx(de.Check,{className:"h-3 w-3"})]},K.key))})]})]})]}),u.jsx(Dl,{ref:J,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:We?u.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-8 text-slate-400",children:[u.jsx(de.Loader2,{className:"h-5 w-5 animate-spin"}),u.jsx("span",{className:"text-sm",children:"Loading threads…"})]}):mt.length===0?u.jsxs("div",{className:"text-center py-8 text-slate-400",children:[u.jsx(de.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:Le})]}):Ht?Object.entries(Ht).sort(([K],[se])=>{const ae="Default";return K===ae?1:se===ae?-1:K.localeCompare(se)}).map(([K,se])=>u.jsxs(Hk,{defaultOpen:!0,className:"group/collapsible",children:[u.jsxs(Uk,{className:"flex items-center w-full px-2 py-1 text-xs font-medium text-slate-500 hover:text-slate-800 dark:hover:text-slate-200",children:[u.jsx(de.ChevronRight,{className:"w-3 h-3 mr-1 transition-transform group-data-[state=open]/collapsible:rotate-90"}),K,u.jsx("span",{className:"ml-auto text-[10px] text-slate-400",children:se.length})]}),u.jsx(Wk,{children:u.jsx("div",{className:"pl-2 border-l border-slate-100 dark:border-slate-800 ml-1.5 my-1 space-y-1",children:se.map(ae=>u.jsx($l,{thread:ae,isActive:O===ae.threadId,editingThreadId:_,editingTitle:Z,onSelect:ut,onStartEditing:De,onEditingTitleChange:me=>re(me),onSaveEditing:Fe,onCancelEditing:rt,onShare:()=>pt(ae.threadId),onDelete:xe,showEditTitle:r,showDeleteButton:n,formatDate:Qe,getDisplayThreadTitle:gt,itemClassName:s.threadItem,activeItemClassName:s.activeThread},ae.threadId))})})]},K)):mt.slice().sort((K,se)=>new Date(se.updatedAt||se.createdAt||"").getTime()-new Date(K.updatedAt||K.createdAt||"").getTime()).map(K=>u.jsx($l,{thread:K,isActive:O===K.threadId,editingThreadId:_,editingTitle:Z,onSelect:ut,onStartEditing:De,onEditingTitleChange:se=>re(se),onSaveEditing:Fe,onCancelEditing:rt,onShare:()=>pt(K.threadId),onDelete:xe,showEditTitle:r,showDeleteButton:n,formatDate:Qe,getDisplayThreadTitle:gt,secondaryLine:ht&&kt(K)?dt(K):void 0,itemClassName:s.threadItem,activeItemClassName:s.activeThread},K.threadId))})}),u.jsx(la,{open:ye,onOpenChange:K=>!K&&wt(),children:u.jsxs(cs,{className:"max-w-md p-0",children:[u.jsx(us,{children:u.jsx(ds,{children:"Share thread"})}),u.jsxs(kl,{children:[u.jsx(El,{autoFocus:!0,value:Ge,onValueChange:K=>He(K),placeholder:"Search for recipients..."}),u.jsxs(Il,{children:[W&&u.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-xs text-muted-foreground",children:[M&&u.jsx(de.Loader2,{className:"h-3 w-3 animate-spin"}),u.jsx("span",{className:W.startsWith("Failed")?"text-red-500":W.startsWith("Shared")?"text-emerald-500":"text-slate-600 dark:text-slate-400",children:W})]}),u.jsx(Nl,{children:Ve?u.jsxs("span",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(de.Loader2,{className:"h-4 w-4 animate-spin"}),"Loading recipients…"]}):"No matching recipients found"}),Pt.length>0&&u.jsx(Al,{heading:"Recipients",children:Pt.map(K=>u.jsx(jl,{onSelect:()=>At(K),children:u.jsxs("div",{className:"flex flex-col items-start text-sm",children:[u.jsx("span",{className:"font-medium",children:K.label}),K.secondaryLabel&&u.jsx("span",{className:"text-xs text-muted-foreground",children:K.secondaryLabel})]})},K.id))})]})]})]})})]})}function Gk({layout:e="sidebar",layoutSize:t="desktop",showThreads:n=!0,className:r="",customStyles:o={},payloadExtras:s={},...i}){const a=d=>{const f="h-full";switch(d){case"phone":return`${f} max-w-none`;case"tablet":return`${f} max-w-4xl mx-auto`;case"half-screen":return`${f} max-w-2xl`;case"desktop":default:return`${f} max-w-7xl mx-auto`}},l=d=>({"--chat-sidebar-width":d==="phone"?"100%":d==="tablet"?"280px":d==="half-screen"?"240px":"320px","--chat-message-max-width":d==="phone"?"95%":d==="tablet"?"90%":d==="half-screen"?"85%":"80%","--chat-input-height":d==="phone"?"120px":"100px"}),c=b.useCallback(d=>{var f;(f=i.onThreadChange)==null||f.call(i,d)},[i]);return e==="fullscreen"?u.jsx(Tr,{...i,onThreadChange:c,children:u.jsx("div",{className:`${a(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:l(t),children:u.jsx(Fr,{className:"flex-1",onError:i.onError,enableFileUpload:!0,payloadExtras:s})})}):e==="tabs"?u.jsx(Tr,{...i,onThreadChange:c,children:u.jsx("div",{className:`${a(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:l(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(si,{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(Fr,{onError:i.onError,enableFileUpload:!0,payloadExtras:s})})]})})}):u.jsx(Tr,{...i,onThreadChange:c,children:u.jsxs("div",{className:`${a(t)} flex overflow-hidden ${r} ${o.container||""}`,style:l(t),children:[n&&u.jsx("div",{className:`w-80 border-r bg-gray-50 flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:u.jsx(si,{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(Fr,{onError:i.onError,enableFileUpload:!0,payloadExtras:s})})]})})}function Yk({apiConfig:e,className:t="",onError:n}){return u.jsx(Tr,{apiConfig:e,onError:n,children:u.jsx("div",{className:`h-full ${t}`,children:u.jsx(Fr,{})})})}function Xk({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(de.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(de.History,{size:14}),"History"]})})]}),u.jsx("div",{className:"flex-1 min-h-0",children:n==="chat"?u.jsx(Fr,{placeholder:e??"Ask Serti AI anything...",autoFocus:!0,className:"h-full",onMessageSent:t}):u.jsx(si,{showCreateButton:!0,className:"h-full",onThreadSelect:()=>r("chat")})})]})}function Jk({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(Tr,{...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(de.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(de.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(de.Maximize2,{size:14}):u.jsx(de.Minimize2,{size:14})})]})]})}),!a&&u.jsx("div",{className:"h-96 flex flex-col",children:u.jsx(Xk,{placeholder:t,onMessageSent:r})})]})})}):null}function Zk({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(de.Edit3,{size:16}),t??e]})}var Qk="Label",Nm=h.forwardRef((e,t)=>u.jsx(he.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())}}));Nm.displayName=Qk;var Am=Nm;const eE=Kr.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),jm=h.forwardRef(({className:e,...t},n)=>u.jsx(Am,{ref:n,className:oe(eE(),e),...t}));jm.displayName=Am.displayName;function Pm(e){const t=h.useRef({value:e,previous:e});return h.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var _m=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"}),tE="VisuallyHidden",ii=h.forwardRef((e,t)=>u.jsx(he.span,{...e,ref:t,style:{..._m,...e.style}}));ii.displayName=tE;var nE=ii,rE=[" ","Enter","ArrowUp","ArrowDown"],oE=[" ","Enter"],mr="Select",[ai,li,sE]=Ms(mr),[Ur,qN]=nn(mr,[sE,$r]),ci=$r(),[iE,Gn]=Ur(mr),[aE,lE]=Ur(mr),Rm=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:l,dir:c,name:d,autoComplete:f,disabled:m,required:p,form:v}=e,g=ci(t),[x,y]=h.useState(null),[w,C]=h.useState(null),[E,T]=h.useState(!1),S=Os(c),[k,A]=In({prop:r,defaultProp:o??!1,onChange:s,caller:mr}),[j,F]=In({prop:i,defaultProp:a,onChange:l,caller:mr}),D=h.useRef(null),B=x?v||!!x.closest("form"):!0,[Y,M]=h.useState(new Set),W=Array.from(Y).map(X=>X.props.value).join(";");return u.jsx(ol,{...g,children:u.jsxs(iE,{required:p,scope:t,trigger:x,onTriggerChange:y,valueNode:w,onValueNodeChange:C,valueNodeHasChildren:E,onValueNodeHasChildrenChange:T,contentId:jt(),value:j,onValueChange:F,open:k,onOpenChange:A,dir:S,triggerPointerDownPosRef:D,disabled:m,children:[u.jsx(ai.Provider,{scope:t,children:u.jsx(aE,{scope:e.__scopeSelect,onNativeOptionAdd:h.useCallback(X=>{M(z=>new Set(z).add(X))},[]),onNativeOptionRemove:h.useCallback(X=>{M(z=>{const P=new Set(z);return P.delete(X),P})},[]),children:n})}),B?u.jsxs(rg,{"aria-hidden":!0,required:p,tabIndex:-1,name:d,autoComplete:f,value:j,onChange:X=>F(X.target.value),disabled:m,form:v,children:[j===void 0?u.jsx("option",{value:""}):null,Array.from(Y)]},W):null]})})};Rm.displayName=mr;var Mm="SelectTrigger",Om=h.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=ci(n),i=Gn(Mm,n),a=i.disabled||r,l=Me(t,i.onTriggerChange),c=li(n),d=h.useRef("touch"),[f,m,p]=sg(g=>{const x=c().filter(C=>!C.disabled),y=x.find(C=>C.value===i.value),w=ig(x,g,y);w!==void 0&&i.onValueChange(w.value)}),v=g=>{a||(i.onOpenChange(!0),p()),g&&(i.triggerPointerDownPosRef.current={x:Math.round(g.pageX),y:Math.round(g.pageY)})};return u.jsx(sl,{asChild:!0,...s,children:u.jsx(he.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":og(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=f.current!=="";!(g.ctrlKey||g.altKey||g.metaKey)&&g.key.length===1&&m(g.key),!(x&&g.key===" ")&&rE.includes(g.key)&&(v(),g.preventDefault())})})})});Om.displayName=Mm;var Dm="SelectValue",Lm=h.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=Gn(Dm,n),{onValueNodeHasChildrenChange:c}=l,d=s!==void 0,f=Me(t,l.onValueNodeChange);return It(()=>{c(d)},[c,d]),u.jsx(he.span,{...a,ref:f,style:{pointerEvents:"none"},children:og(l.value)?u.jsx(u.Fragment,{children:i}):s})});Lm.displayName=Dm;var cE="SelectIcon",$m=h.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return u.jsx(he.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});$m.displayName=cE;var uE="SelectPortal",Fm=e=>u.jsx(so,{asChild:!0,...e});Fm.displayName=uE;var gr="SelectContent",Bm=h.forwardRef((e,t)=>{const n=Gn(gr,e.__scopeSelect),[r,o]=h.useState();if(It(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?qr.createPortal(u.jsx(zm,{scope:e.__scopeSelect,children:u.jsx(ai.Slot,{scope:e.__scopeSelect,children:u.jsx("div",{children:e.children})})}),s):null}return u.jsx(Hm,{...e,ref:t})});Bm.displayName=gr;var mn=10,[zm,Yn]=Ur(gr),dE="SelectContentImpl",fE=Jt.createSlot("SelectContent.RemoveScroll"),Hm=h.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:f,collisionBoundary:m,collisionPadding:p,sticky:v,hideWhenDetached:g,avoidCollisions:x,...y}=e,w=Gn(gr,n),[C,E]=h.useState(null),[T,S]=h.useState(null),k=Me(t,R=>E(R)),[A,j]=h.useState(null),[F,D]=h.useState(null),B=li(n),[Y,M]=h.useState(!1),W=h.useRef(!1);h.useEffect(()=>{if(C)return na(C)},[C]),Xi();const X=h.useCallback(R=>{const[_,...U]=B().map(le=>le.ref.current),[Z]=U.slice(-1),re=document.activeElement;for(const le of R)if(le===re||(le==null||le.scrollIntoView({block:"nearest"}),le===_&&T&&(T.scrollTop=0),le===Z&&T&&(T.scrollTop=T.scrollHeight),le==null||le.focus(),document.activeElement!==re))return},[B,T]),z=h.useCallback(()=>X([A,C]),[X,A,C]);h.useEffect(()=>{Y&&z()},[Y,z]);const{onOpenChange:P,triggerPointerDownPosRef:I}=w;h.useEffect(()=>{if(C){let R={x:0,y:0};const _=Z=>{var re,le;R={x:Math.abs(Math.round(Z.pageX)-(((re=I.current)==null?void 0:re.x)??0)),y:Math.abs(Math.round(Z.pageY)-(((le=I.current)==null?void 0:le.y)??0))}},U=Z=>{R.x<=10&&R.y<=10?Z.preventDefault():C.contains(Z.target)||P(!1),document.removeEventListener("pointermove",_),I.current=null};return I.current!==null&&(document.addEventListener("pointermove",_),document.addEventListener("pointerup",U,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",_),document.removeEventListener("pointerup",U,{capture:!0})}}},[C,P,I]),h.useEffect(()=>{const R=()=>P(!1);return window.addEventListener("blur",R),window.addEventListener("resize",R),()=>{window.removeEventListener("blur",R),window.removeEventListener("resize",R)}},[P]);const[q,Q]=sg(R=>{const _=B().filter(re=>!re.disabled),U=_.find(re=>re.ref.current===document.activeElement),Z=ig(_,R,U);Z&&setTimeout(()=>Z.ref.current.focus())}),O=h.useCallback((R,_,U)=>{const Z=!W.current&&!U;(w.value!==void 0&&w.value===_||Z)&&(j(R),Z&&(W.current=!0))},[w.value]),G=h.useCallback(()=>C==null?void 0:C.focus(),[C]),L=h.useCallback((R,_,U)=>{const Z=!W.current&&!U;(w.value!==void 0&&w.value===_||Z)&&D(R)},[w.value]),$=r==="popper"?Hl:Um,J=$===Hl?{side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:f,collisionBoundary:m,collisionPadding:p,sticky:v,hideWhenDetached:g,avoidCollisions:x}:{};return u.jsx(zm,{scope:n,content:C,viewport:T,onViewportChange:S,itemRefCallback:O,selectedItem:A,onItemLeave:G,itemTextRefCallback:L,focusSelectedItem:z,selectedItemText:F,position:r,isPositioned:Y,searchRef:q,children:u.jsx(rs,{as:fE,allowPinchZoom:!0,children:u.jsx(Xo,{asChild:!0,trapped:w.open,onMountAutoFocus:R=>{R.preventDefault()},onUnmountAutoFocus:ce(o,R=>{var _;(_=w.trigger)==null||_.focus({preventScroll:!0}),R.preventDefault()}),children:u.jsx(Er,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:R=>R.preventDefault(),onDismiss:()=>w.onOpenChange(!1),children:u.jsx($,{role:"listbox",id:w.contentId,"data-state":w.open?"open":"closed",dir:w.dir,onContextMenu:R=>R.preventDefault(),...y,...J,onPlaced:()=>M(!0),ref:k,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:ce(y.onKeyDown,R=>{const _=R.ctrlKey||R.altKey||R.metaKey;if(R.key==="Tab"&&R.preventDefault(),!_&&R.key.length===1&&Q(R.key),["ArrowUp","ArrowDown","Home","End"].includes(R.key)){let Z=B().filter(re=>!re.disabled).map(re=>re.ref.current);if(["ArrowUp","End"].includes(R.key)&&(Z=Z.slice().reverse()),["ArrowUp","ArrowDown"].includes(R.key)){const re=R.target,le=Z.indexOf(re);Z=Z.slice(le+1)}setTimeout(()=>X(Z)),R.preventDefault()}})})})})})})});Hm.displayName=dE;var pE="SelectItemAlignedPosition",Um=h.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=Gn(gr,n),i=Yn(gr,n),[a,l]=h.useState(null),[c,d]=h.useState(null),f=Me(t,k=>d(k)),m=li(n),p=h.useRef(!1),v=h.useRef(!0),{viewport:g,selectedItem:x,selectedItemText:y,focusSelectedItem:w}=i,C=h.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&c&&g&&x&&y){const k=s.trigger.getBoundingClientRect(),A=c.getBoundingClientRect(),j=s.valueNode.getBoundingClientRect(),F=y.getBoundingClientRect();if(s.dir!=="rtl"){const re=F.left-A.left,le=j.left-re,ke=k.left-le,ye=k.width+ke,_e=Math.max(ye,A.width),ze=window.innerWidth-mn,$e=Pl(le,[mn,Math.max(mn,ze-_e)]);a.style.minWidth=ye+"px",a.style.left=$e+"px"}else{const re=A.right-F.right,le=window.innerWidth-j.right-re,ke=window.innerWidth-k.right-le,ye=k.width+ke,_e=Math.max(ye,A.width),ze=window.innerWidth-mn,$e=Pl(le,[mn,Math.max(mn,ze-_e)]);a.style.minWidth=ye+"px",a.style.right=$e+"px"}const D=m(),B=window.innerHeight-mn*2,Y=g.scrollHeight,M=window.getComputedStyle(c),W=parseInt(M.borderTopWidth,10),X=parseInt(M.paddingTop,10),z=parseInt(M.borderBottomWidth,10),P=parseInt(M.paddingBottom,10),I=W+X+Y+P+z,q=Math.min(x.offsetHeight*5,I),Q=window.getComputedStyle(g),O=parseInt(Q.paddingTop,10),G=parseInt(Q.paddingBottom,10),L=k.top+k.height/2-mn,$=B-L,J=x.offsetHeight/2,R=x.offsetTop+J,_=W+X+R,U=I-_;if(_<=L){const re=D.length>0&&x===D[D.length-1].ref.current;a.style.bottom="0px";const le=c.clientHeight-g.offsetTop-g.offsetHeight,ke=Math.max($,J+(re?G:0)+le+z),ye=_+ke;a.style.height=ye+"px"}else{const re=D.length>0&&x===D[0].ref.current;a.style.top="0px";const ke=Math.max(L,W+g.offsetTop+(re?O:0)+J)+U;a.style.height=ke+"px",g.scrollTop=_-L+g.offsetTop}a.style.margin=`${mn}px 0`,a.style.minHeight=q+"px",a.style.maxHeight=B+"px",r==null||r(),requestAnimationFrame(()=>p.current=!0)}},[m,s.trigger,s.valueNode,a,c,g,x,y,s.dir,r]);It(()=>C(),[C]);const[E,T]=h.useState();It(()=>{c&&T(window.getComputedStyle(c).zIndex)},[c]);const S=h.useCallback(k=>{k&&v.current===!0&&(C(),w==null||w(),v.current=!1)},[C,w]);return u.jsx(mE,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:p,onScrollButtonChange:S,children:u.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:E},children:u.jsx(he.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Um.displayName=pE;var hE="SelectPopperPosition",Hl=h.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=mn,...s}=e,i=ci(n);return u.jsx(il,{...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)"}})});Hl.displayName=hE;var[mE,Ul]=Ur(gr,{}),Wl="SelectViewport",Wm=h.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=Yn(Wl,n),i=Ul(Wl,n),a=Me(t,s.onViewportChange),l=h.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(ai.Slot,{scope:n,children:u.jsx(he.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:f,shouldExpandOnScrollRef:m}=i;if(m!=null&&m.current&&f){const p=Math.abs(l.current-d.scrollTop);if(p>0){const v=window.innerHeight-mn*2,g=parseFloat(f.style.minHeight),x=parseFloat(f.style.height),y=Math.max(g,x);if(y<v){const w=y+p,C=Math.min(v,w),E=w-C;f.style.height=C+"px",f.style.bottom==="0px"&&(d.scrollTop=E>0?E:0,f.style.justifyContent="flex-end")}}}l.current=d.scrollTop})})})]})});Wm.displayName=Wl;var Vm="SelectGroup",[gE,xE]=Ur(Vm),vE=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=jt();return u.jsx(gE,{scope:n,id:o,children:u.jsx(he.div,{role:"group","aria-labelledby":o,...r,ref:t})})});vE.displayName=Vm;var Km="SelectLabel",qm=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=xE(Km,n);return u.jsx(he.div,{id:o.id,...r,ref:t})});qm.displayName=Km;var ui="SelectItem",[bE,Gm]=Ur(ui),Ym=h.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=Gn(ui,n),l=Yn(ui,n),c=a.value===r,[d,f]=h.useState(s??""),[m,p]=h.useState(!1),v=Me(t,w=>{var C;return(C=l.itemRefCallback)==null?void 0:C.call(l,w,r,o)}),g=jt(),x=h.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(bE,{scope:n,value:r,disabled:o,textId:g,isSelected:c,onItemTextChange:h.useCallback(w=>{f(C=>C||((w==null?void 0:w.textContent)??"").trim())},[]),children:u.jsx(ai.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:u.jsx(he.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,()=>p(!0)),onBlur:ce(i.onBlur,()=>p(!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 C;x.current=w.pointerType,o?(C=l.onItemLeave)==null||C.call(l):x.current==="mouse"&&w.currentTarget.focus({preventScroll:!0})}),onPointerLeave:ce(i.onPointerLeave,w=>{var C;w.currentTarget===document.activeElement&&((C=l.onItemLeave)==null||C.call(l))}),onKeyDown:ce(i.onKeyDown,w=>{var E;((E=l.searchRef)==null?void 0:E.current)!==""&&w.key===" "||(oE.includes(w.key)&&y(),w.key===" "&&w.preventDefault())})})})})});Ym.displayName=ui;var Ro="SelectItemText",Xm=h.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=Gn(Ro,n),a=Yn(Ro,n),l=Gm(Ro,n),c=lE(Ro,n),[d,f]=h.useState(null),m=Me(t,y=>f(y),l.onItemTextChange,y=>{var w;return(w=a.itemTextRefCallback)==null?void 0:w.call(a,y,l.value,l.disabled)}),p=d==null?void 0:d.textContent,v=h.useMemo(()=>u.jsx("option",{value:l.value,disabled:l.disabled,children:p},l.value),[l.disabled,l.value,p]),{onNativeOptionAdd:g,onNativeOptionRemove:x}=c;return It(()=>(g(v),()=>x(v)),[g,x,v]),u.jsxs(u.Fragment,{children:[u.jsx(he.span,{id:l.textId,...s,ref:m}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?qr.createPortal(s.children,i.valueNode):null]})});Xm.displayName=Ro;var Jm="SelectItemIndicator",Zm=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return Gm(Jm,n).isSelected?u.jsx(he.span,{"aria-hidden":!0,...r,ref:t}):null});Zm.displayName=Jm;var Vl="SelectScrollUpButton",Qm=h.forwardRef((e,t)=>{const n=Yn(Vl,e.__scopeSelect),r=Ul(Vl,e.__scopeSelect),[o,s]=h.useState(!1),i=Me(t,r.onScrollButtonChange);return It(()=>{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(tg,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});Qm.displayName=Vl;var Kl="SelectScrollDownButton",eg=h.forwardRef((e,t)=>{const n=Yn(Kl,e.__scopeSelect),r=Ul(Kl,e.__scopeSelect),[o,s]=h.useState(!1),i=Me(t,r.onScrollButtonChange);return It(()=>{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(tg,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});eg.displayName=Kl;var tg=h.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=Yn("SelectScrollButton",n),i=h.useRef(null),a=li(n),l=h.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return h.useEffect(()=>()=>l(),[l]),It(()=>{var d;const c=a().find(f=>f.ref.current===document.activeElement);(d=c==null?void 0:c.ref.current)==null||d.scrollIntoView({block:"nearest"})},[a]),u.jsx(he.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()})})}),wE="SelectSeparator",ng=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return u.jsx(he.div,{"aria-hidden":!0,...r,ref:t})});ng.displayName=wE;var ql="SelectArrow",yE=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=ci(n),s=Gn(ql,n),i=Yn(ql,n);return s.open&&i.position==="popper"?u.jsx(al,{...o,...r,ref:t}):null});yE.displayName=ql;var SE="SelectBubbleInput",rg=h.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=h.useRef(null),s=Me(r,o),i=Pm(t);return h.useEffect(()=>{const a=o.current;if(!a)return;const l=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(l,"value").set;if(i!==t&&d){const f=new Event("change",{bubbles:!0});d.call(a,t),a.dispatchEvent(f)}},[i,t]),u.jsx(he.select,{...n,style:{..._m,...n.style},ref:s,defaultValue:t})});rg.displayName=SE;function og(e){return e===""||e===void 0}function sg(e){const t=vt(e),n=h.useRef(""),r=h.useRef(0),o=h.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=h.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return h.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function ig(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=CE(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 CE(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var TE=Rm,ag=Om,kE=Lm,EE=$m,IE=Fm,lg=Bm,NE=Wm,cg=qm,ug=Ym,AE=Xm,jE=Zm,dg=Qm,fg=eg,pg=ng;const PE=TE,_E=kE,hg=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(ag,{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(EE,{asChild:!0,children:u.jsx(de.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));hg.displayName=ag.displayName;const mg=h.forwardRef(({className:e,...t},n)=>u.jsx(dg,{ref:n,className:oe("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(de.ChevronUp,{className:"h-4 w-4"})}));mg.displayName=dg.displayName;const gg=h.forwardRef(({className:e,...t},n)=>u.jsx(fg,{ref:n,className:oe("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(de.ChevronDown,{className:"h-4 w-4"})}));gg.displayName=fg.displayName;const xg=h.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>u.jsx(IE,{children:u.jsxs(lg,{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(mg,{}),u.jsx(NE,{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(gg,{})]})}));xg.displayName=lg.displayName;const RE=h.forwardRef(({className:e,...t},n)=>u.jsx(cg,{ref:n,className:oe("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));RE.displayName=cg.displayName;const vg=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(ug,{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(jE,{children:u.jsx(de.Check,{className:"h-4 w-4"})})}),u.jsx(AE,{children:t})]}));vg.displayName=ug.displayName;const ME=h.forwardRef(({className:e,...t},n)=>u.jsx(pg,{ref:n,className:oe("-mx-1 my-1 h-px bg-muted",e),...t}));ME.displayName=pg.displayName;var OE="Separator",bg="horizontal",DE=["horizontal","vertical"],wg=h.forwardRef((e,t)=>{const{decorative:n,orientation:r=bg,...o}=e,s=LE(r)?r:bg,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return u.jsx(he.div,{"data-orientation":s,...a,...o,ref:t})});wg.displayName=OE;function LE(e){return DE.includes(e)}var yg=wg;const Sg=h.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>u.jsx(yg,{ref:o,decorative:n,orientation:t,className:oe("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));Sg.displayName=yg.displayName;var di="Switch",[$E,GN]=nn(di),[FE,BE]=$E(di),Cg=h.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:s,required:i,disabled:a,value:l="on",onCheckedChange:c,form:d,...f}=e,[m,p]=h.useState(null),v=Me(t,C=>p(C)),g=h.useRef(!1),x=m?d||!!m.closest("form"):!0,[y,w]=In({prop:o,defaultProp:s??!1,onChange:c,caller:di});return u.jsxs(FE,{scope:n,checked:y,disabled:a,children:[u.jsx(he.button,{type:"button",role:"switch","aria-checked":y,"aria-required":i,"data-state":Ig(y),"data-disabled":a?"":void 0,disabled:a,value:l,...f,ref:v,onClick:ce(e.onClick,C=>{w(E=>!E),x&&(g.current=C.isPropagationStopped(),g.current||C.stopPropagation())})}),x&&u.jsx(Eg,{control:m,bubbles:!g.current,name:r,value:l,checked:y,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});Cg.displayName=di;var Tg="SwitchThumb",kg=h.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=BE(Tg,n);return u.jsx(he.span,{"data-state":Ig(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});kg.displayName=Tg;var zE="SwitchBubbleInput",Eg=h.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=h.useRef(null),a=Me(i,s),l=Pm(n),c=Dp(t);return h.useEffect(()=>{const d=i.current;if(!d)return;const f=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(f,"checked").set;if(l!==n&&p){const v=new Event("click",{bubbles:r});p.call(d,n),d.dispatchEvent(v)}},[l,n,r]),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}})});Eg.displayName=zE;function Ig(e){return e?"checked":"unchecked"}var Ng=Cg,HE=kg;const Ag=h.forwardRef(({className:e,...t},n)=>u.jsx(Ng,{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(HE,{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")})}));Ag.displayName=Ng.displayName;const UE=ia,WE=Xw,VE=aa,jg=h.forwardRef(({className:e,...t},n)=>u.jsx(io,{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}));jg.displayName=io.displayName;const KE=Kr.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"}}),Pg=h.forwardRef(({side:e="right",className:t,children:n,...r},o)=>u.jsxs(VE,{children:[u.jsx(jg,{}),u.jsxs(ao,{ref:o,className:oe(KE({side:e}),t),...r,children:[n,u.jsxs($d,{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(de.X,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Pg.displayName=ao.displayName;const _g=({className:e,...t})=>u.jsx("div",{className:oe("flex flex-col space-y-2 text-center sm:text-left",e),...t});_g.displayName="SheetHeader";const Rg=h.forwardRef(({className:e,...t},n)=>u.jsx(or,{ref:n,className:oe("text-lg font-semibold text-foreground",e),...t}));Rg.displayName=or.displayName;const Mg=h.forwardRef(({className:e,...t},n)=>u.jsx(ls,{ref:n,className:oe("text-sm text-muted-foreground",e),...t}));Mg.displayName=ls.displayName;var[fi,YN]=nn("Tooltip",[$r]),pi=$r(),Og="TooltipProvider",qE=700,Gl="tooltip.open",[GE,Yl]=fi(Og),Dg=e=>{const{__scopeTooltip:t,delayDuration:n=qE,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:s}=e,i=h.useRef(!0),a=h.useRef(!1),l=h.useRef(0);return h.useEffect(()=>{const c=l.current;return()=>window.clearTimeout(c)},[]),u.jsx(GE,{scope:t,isOpenDelayedRef:i,delayDuration:n,onOpen:h.useCallback(()=>{window.clearTimeout(l.current),i.current=!1},[]),onClose:h.useCallback(()=>{window.clearTimeout(l.current),l.current=window.setTimeout(()=>i.current=!0,r)},[r]),isPointerInTransitRef:a,onPointerInTransitChange:h.useCallback(c=>{a.current=c},[]),disableHoverableContent:o,children:s})};Dg.displayName=Og;var Mo="Tooltip",[YE,hi]=fi(Mo),Lg=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:s,disableHoverableContent:i,delayDuration:a}=e,l=Yl(Mo,e.__scopeTooltip),c=pi(t),[d,f]=h.useState(null),m=jt(),p=h.useRef(0),v=i??l.disableHoverableContent,g=a??l.delayDuration,x=h.useRef(!1),[y,w]=In({prop:r,defaultProp:o??!1,onChange:k=>{k?(l.onOpen(),document.dispatchEvent(new CustomEvent(Gl))):l.onClose(),s==null||s(k)},caller:Mo}),C=h.useMemo(()=>y?x.current?"delayed-open":"instant-open":"closed",[y]),E=h.useCallback(()=>{window.clearTimeout(p.current),p.current=0,x.current=!1,w(!0)},[w]),T=h.useCallback(()=>{window.clearTimeout(p.current),p.current=0,w(!1)},[w]),S=h.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{x.current=!0,w(!0),p.current=0},g)},[g,w]);return h.useEffect(()=>()=>{p.current&&(window.clearTimeout(p.current),p.current=0)},[]),u.jsx(ol,{...c,children:u.jsx(YE,{scope:t,contentId:m,open:y,stateAttribute:C,trigger:d,onTriggerChange:f,onTriggerEnter:h.useCallback(()=>{l.isOpenDelayedRef.current?S():E()},[l.isOpenDelayedRef,S,E]),onTriggerLeave:h.useCallback(()=>{v?T():(window.clearTimeout(p.current),p.current=0)},[T,v]),onOpen:E,onClose:T,disableHoverableContent:v,children:n})})};Lg.displayName=Mo;var Xl="TooltipTrigger",$g=h.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=hi(Xl,n),s=Yl(Xl,n),i=pi(n),a=h.useRef(null),l=Me(t,a,o.onTriggerChange),c=h.useRef(!1),d=h.useRef(!1),f=h.useCallback(()=>c.current=!1,[]);return h.useEffect(()=>()=>document.removeEventListener("pointerup",f),[f]),u.jsx(sl,{asChild:!0,...i,children:u.jsx(he.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",f,{once:!0})}),onFocus:ce(e.onFocus,()=>{c.current||o.onOpen()}),onBlur:ce(e.onBlur,o.onClose),onClick:ce(e.onClick,o.onClose)})})});$g.displayName=Xl;var XE="TooltipPortal",[XN,JE]=fi(XE,{forceMount:void 0}),Wr="TooltipContent",Fg=h.forwardRef((e,t)=>{const n=JE(Wr,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...s}=e,i=hi(Wr,e.__scopeTooltip);return u.jsx(Ft,{present:r||i.open,children:i.disableHoverableContent?u.jsx(Bg,{side:o,...s,ref:t}):u.jsx(ZE,{side:o,...s,ref:t})})}),ZE=h.forwardRef((e,t)=>{const n=hi(Wr,e.__scopeTooltip),r=Yl(Wr,e.__scopeTooltip),o=h.useRef(null),s=Me(t,o),[i,a]=h.useState(null),{trigger:l,onClose:c}=n,d=o.current,{onPointerInTransitChange:f}=r,m=h.useCallback(()=>{a(null),f(!1)},[f]),p=h.useCallback((v,g)=>{const x=v.currentTarget,y={x:v.clientX,y:v.clientY},w=rI(y,x.getBoundingClientRect()),C=oI(y,w),E=sI(g.getBoundingClientRect()),T=aI([...C,...E]);a(T),f(!0)},[f]);return h.useEffect(()=>()=>m(),[m]),h.useEffect(()=>{if(l&&d){const v=x=>p(x,d),g=x=>p(x,l);return l.addEventListener("pointerleave",v),d.addEventListener("pointerleave",g),()=>{l.removeEventListener("pointerleave",v),d.removeEventListener("pointerleave",g)}}},[l,d,p,m]),h.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)),C=!iI(y,i);w?m():C&&(m(),c())};return document.addEventListener("pointermove",v),()=>document.removeEventListener("pointermove",v)}},[l,d,i,c,m]),u.jsx(Bg,{...e,ref:s})}),[QE,eI]=fi(Mo,{isInside:!1}),tI=Jt.createSlottable("TooltipContent"),Bg=h.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:s,onPointerDownOutside:i,...a}=e,l=hi(Wr,n),c=pi(n),{onClose:d}=l;return h.useEffect(()=>(document.addEventListener(Gl,d),()=>document.removeEventListener(Gl,d)),[d]),h.useEffect(()=>{if(l.trigger){const f=m=>{const p=m.target;p!=null&&p.contains(l.trigger)&&d()};return window.addEventListener("scroll",f,{capture:!0}),()=>window.removeEventListener("scroll",f,{capture:!0})}},[l.trigger,d]),u.jsx(Er,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:f=>f.preventDefault(),onDismiss:d,children:u.jsxs(il,{"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(tI,{children:r}),u.jsx(QE,{scope:n,isInside:!0,children:u.jsx(nE,{id:l.contentId,role:"tooltip",children:o||r})})]})})});Fg.displayName=Wr;var zg="TooltipArrow",nI=h.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=pi(n);return eI(zg,n).isInside?null:u.jsx(al,{...o,...r,ref:t})});nI.displayName=zg;function rI(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 oI(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 sI(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 iI(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,f=l.x,m=l.y;d>r!=m>r&&n<(f-c)*(r-d)/(m-d)+c&&(o=!o)}return o}function aI(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),lI(t)}function lI(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 cI=Dg,uI=Lg,dI=$g,Hg=Fg;const fI=cI,pI=uI,hI=dI,Ug=h.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(Hg,{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}));Ug.displayName=Hg.displayName;var Jl="ToastProvider",[Zl,mI,gI]=Ms("Toast"),[Wg,JN]=nn("Toast",[gI]),[xI,mi]=Wg(Jl),Vg=e=>{const{__scopeToast:t,label:n="Notification",duration:r=5e3,swipeDirection:o="right",swipeThreshold:s=50,children:i}=e,[a,l]=h.useState(null),[c,d]=h.useState(0),f=h.useRef(!1),m=h.useRef(!1);return n.trim()||console.error(`Invalid prop \`label\` supplied to \`${Jl}\`. Expected non-empty \`string\`.`),u.jsx(Zl.Provider,{scope:t,children:u.jsx(xI,{scope:t,label:n,duration:r,swipeDirection:o,swipeThreshold:s,toastCount:c,viewport:a,onViewportChange:l,onToastAdd:h.useCallback(()=>d(p=>p+1),[]),onToastRemove:h.useCallback(()=>d(p=>p-1),[]),isFocusedToastEscapeKeyDownRef:f,isClosePausedRef:m,children:i})})};Vg.displayName=Jl;var Kg="ToastViewport",vI=["F8"],Ql="toast.viewportPause",ec="toast.viewportResume",qg=h.forwardRef((e,t)=>{const{__scopeToast:n,hotkey:r=vI,label:o="Notifications ({hotkey})",...s}=e,i=mi(Kg,n),a=mI(n),l=h.useRef(null),c=h.useRef(null),d=h.useRef(null),f=h.useRef(null),m=Me(t,f,i.onViewportChange),p=r.join("+").replace(/Key/g,"").replace(/Digit/g,""),v=i.toastCount>0;h.useEffect(()=>{const x=y=>{var C;r.length!==0&&r.every(E=>y[E]||y.code===E)&&((C=f.current)==null||C.focus())};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[r]),h.useEffect(()=>{const x=l.current,y=f.current;if(v&&x&&y){const w=()=>{if(!i.isClosePausedRef.current){const S=new CustomEvent(Ql);y.dispatchEvent(S),i.isClosePausedRef.current=!0}},C=()=>{if(i.isClosePausedRef.current){const S=new CustomEvent(ec);y.dispatchEvent(S),i.isClosePausedRef.current=!1}},E=S=>{!x.contains(S.relatedTarget)&&C()},T=()=>{x.contains(document.activeElement)||C()};return x.addEventListener("focusin",w),x.addEventListener("focusout",E),x.addEventListener("pointermove",w),x.addEventListener("pointerleave",T),window.addEventListener("blur",w),window.addEventListener("focus",C),()=>{x.removeEventListener("focusin",w),x.removeEventListener("focusout",E),x.removeEventListener("pointermove",w),x.removeEventListener("pointerleave",T),window.removeEventListener("blur",w),window.removeEventListener("focus",C)}}},[v,i.isClosePausedRef]);const g=h.useCallback(({tabbingDirection:x})=>{const w=a().map(C=>{const E=C.ref.current,T=[E,...PI(E)];return x==="forwards"?T:T.reverse()});return(x==="forwards"?w.reverse():w).flat()},[a]);return h.useEffect(()=>{const x=f.current;if(x){const y=w=>{var T,S,k;const C=w.altKey||w.ctrlKey||w.metaKey;if(w.key==="Tab"&&!C){const A=document.activeElement,j=w.shiftKey;if(w.target===x&&j){(T=c.current)==null||T.focus();return}const B=g({tabbingDirection:j?"backwards":"forwards"}),Y=B.findIndex(M=>M===A);rc(B.slice(Y+1))?w.preventDefault():j?(S=c.current)==null||S.focus():(k=d.current)==null||k.focus()}};return x.addEventListener("keydown",y),()=>x.removeEventListener("keydown",y)}},[a,g]),u.jsxs(Wb,{ref:l,role:"region","aria-label":o.replace("{hotkey}",p),tabIndex:-1,style:{pointerEvents:v?void 0:"none"},children:[v&&u.jsx(tc,{ref:c,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"forwards"});rc(x)}}),u.jsx(Zl.Slot,{scope:n,children:u.jsx(he.ol,{tabIndex:-1,...s,ref:m})}),v&&u.jsx(tc,{ref:d,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"backwards"});rc(x)}})]})});qg.displayName=Kg;var Gg="ToastFocusProxy",tc=h.forwardRef((e,t)=>{const{__scopeToast:n,onFocusFromOutsideViewport:r,...o}=e,s=mi(Gg,n);return u.jsx(ii,{tabIndex:0,...o,ref:t,style:{position:"fixed"},onFocus:i=>{var c;const a=i.relatedTarget;!((c=s.viewport)!=null&&c.contains(a))&&r()}})});tc.displayName=Gg;var Oo="Toast",bI="toast.swipeStart",wI="toast.swipeMove",yI="toast.swipeCancel",SI="toast.swipeEnd",Yg=h.forwardRef((e,t)=>{const{forceMount:n,open:r,defaultOpen:o,onOpenChange:s,...i}=e,[a,l]=In({prop:r,defaultProp:o??!0,onChange:s,caller:Oo});return u.jsx(Ft,{present:n||a,children:u.jsx(kI,{open:a,...i,ref:t,onClose:()=>l(!1),onPause:vt(e.onPause),onResume:vt(e.onResume),onSwipeStart:ce(e.onSwipeStart,c=>{c.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:ce(e.onSwipeMove,c=>{const{x:d,y:f}=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",`${f}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:f}=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",`${f}px`),l(!1)})})})});Yg.displayName=Oo;var[CI,TI]=Wg(Oo,{onClose(){}}),kI=h.forwardRef((e,t)=>{const{__scopeToast:n,type:r="foreground",duration:o,open:s,onClose:i,onEscapeKeyDown:a,onPause:l,onResume:c,onSwipeStart:d,onSwipeMove:f,onSwipeCancel:m,onSwipeEnd:p,...v}=e,g=mi(Oo,n),[x,y]=h.useState(null),w=Me(t,M=>y(M)),C=h.useRef(null),E=h.useRef(null),T=o||g.duration,S=h.useRef(0),k=h.useRef(T),A=h.useRef(0),{onToastAdd:j,onToastRemove:F}=g,D=vt(()=>{var W;(x==null?void 0:x.contains(document.activeElement))&&((W=g.viewport)==null||W.focus()),i()}),B=h.useCallback(M=>{!M||M===1/0||(window.clearTimeout(A.current),S.current=new Date().getTime(),A.current=window.setTimeout(D,M))},[D]);h.useEffect(()=>{const M=g.viewport;if(M){const W=()=>{B(k.current),c==null||c()},X=()=>{const z=new Date().getTime()-S.current;k.current=k.current-z,window.clearTimeout(A.current),l==null||l()};return M.addEventListener(Ql,X),M.addEventListener(ec,W),()=>{M.removeEventListener(Ql,X),M.removeEventListener(ec,W)}}},[g.viewport,T,l,c,B]),h.useEffect(()=>{s&&!g.isClosePausedRef.current&&B(T)},[s,T,g.isClosePausedRef,B]),h.useEffect(()=>(j(),()=>F()),[j,F]);const Y=h.useMemo(()=>x?nx(x):null,[x]);return g.viewport?u.jsxs(u.Fragment,{children:[Y&&u.jsx(EI,{__scopeToast:n,role:"status","aria-live":r==="foreground"?"assertive":"polite",children:Y}),u.jsx(CI,{scope:n,onClose:D,children:qr.createPortal(u.jsx(Zl.ItemSlot,{scope:n,children:u.jsx(Ub,{asChild:!0,onEscapeKeyDown:ce(a,()=>{g.isFocusedToastEscapeKeyDownRef.current||D(),g.isFocusedToastEscapeKeyDownRef.current=!1}),children:u.jsx(he.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,M=>{M.key==="Escape"&&(a==null||a(M.nativeEvent),M.nativeEvent.defaultPrevented||(g.isFocusedToastEscapeKeyDownRef.current=!0,D()))}),onPointerDown:ce(e.onPointerDown,M=>{M.button===0&&(C.current={x:M.clientX,y:M.clientY})}),onPointerMove:ce(e.onPointerMove,M=>{if(!C.current)return;const W=M.clientX-C.current.x,X=M.clientY-C.current.y,z=!!E.current,P=["left","right"].includes(g.swipeDirection),I=["left","up"].includes(g.swipeDirection)?Math.min:Math.max,q=P?I(0,W):0,Q=P?0:I(0,X),O=M.pointerType==="touch"?10:2,G={x:q,y:Q},L={originalEvent:M,delta:G};z?(E.current=G,gi(wI,f,L,{discrete:!1})):rx(G,g.swipeDirection,O)?(E.current=G,gi(bI,d,L,{discrete:!1}),M.target.setPointerCapture(M.pointerId)):(Math.abs(W)>O||Math.abs(X)>O)&&(C.current=null)}),onPointerUp:ce(e.onPointerUp,M=>{const W=E.current,X=M.target;if(X.hasPointerCapture(M.pointerId)&&X.releasePointerCapture(M.pointerId),E.current=null,C.current=null,W){const z=M.currentTarget,P={originalEvent:M,delta:W};rx(W,g.swipeDirection,g.swipeThreshold)?gi(SI,p,P,{discrete:!0}):gi(yI,m,P,{discrete:!0}),z.addEventListener("click",I=>I.preventDefault(),{once:!0})}})})})}),g.viewport)})]}):null}),EI=e=>{const{__scopeToast:t,children:n,...r}=e,o=mi(Oo,t),[s,i]=h.useState(!1),[a,l]=h.useState(!1);return AI(()=>i(!0)),h.useEffect(()=>{const c=window.setTimeout(()=>l(!0),1e3);return()=>window.clearTimeout(c)},[]),a?null:u.jsx(so,{asChild:!0,children:u.jsx(ii,{...r,children:s&&u.jsxs(u.Fragment,{children:[o.label," ",n]})})})},II="ToastTitle",Xg=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(he.div,{...r,ref:t})});Xg.displayName=II;var NI="ToastDescription",Jg=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(he.div,{...r,ref:t})});Jg.displayName=NI;var Zg="ToastAction",Qg=h.forwardRef((e,t)=>{const{altText:n,...r}=e;return n.trim()?u.jsx(tx,{altText:n,asChild:!0,children:u.jsx(nc,{...r,ref:t})}):(console.error(`Invalid prop \`altText\` supplied to \`${Zg}\`. Expected non-empty \`string\`.`),null)});Qg.displayName=Zg;var ex="ToastClose",nc=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e,o=TI(ex,n);return u.jsx(tx,{asChild:!0,children:u.jsx(he.button,{type:"button",...r,ref:t,onClick:ce(e.onClick,o.onClose)})})});nc.displayName=ex;var tx=h.forwardRef((e,t)=>{const{__scopeToast:n,altText:r,...o}=e;return u.jsx(he.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":r||void 0,...o,ref:t})});function nx(e){const t=[];return Array.from(e.childNodes).forEach(r=>{if(r.nodeType===r.TEXT_NODE&&r.textContent&&t.push(r.textContent),jI(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(...nx(r))}}),t}function gi(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?Vi(o,s):o.dispatchEvent(s)}var rx=(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 AI(e=()=>{}){const t=vt(e);It(()=>{let n=0,r=0;return n=window.requestAnimationFrame(()=>r=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(n),window.cancelAnimationFrame(r)}},[t])}function jI(e){return e.nodeType===e.ELEMENT_NODE}function PI(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function rc(e){const t=document.activeElement;return e.some(n=>n===t?!0:(n.focus(),document.activeElement!==t))}var _I=Vg,ox=qg,sx=Yg,ix=Xg,ax=Jg,lx=Qg,cx=nc;const RI=_I,ux=h.forwardRef(({className:e,...t},n)=>u.jsx(ox,{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}));ux.displayName=ox.displayName;const MI=Kr.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"}}),dx=h.forwardRef(({className:e,variant:t,...n},r)=>u.jsx(sx,{ref:r,className:oe(MI({variant:t}),e),...n}));dx.displayName=sx.displayName;const OI=h.forwardRef(({className:e,...t},n)=>u.jsx(lx,{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}));OI.displayName=lx.displayName;const fx=h.forwardRef(({className:e,...t},n)=>u.jsx(cx,{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(de.X,{className:"h-4 w-4"})}));fx.displayName=cx.displayName;const px=h.forwardRef(({className:e,...t},n)=>u.jsx(ix,{ref:n,className:oe("text-sm font-semibold",e),...t}));px.displayName=ix.displayName;const hx=h.forwardRef(({className:e,...t},n)=>u.jsx(ax,{ref:n,className:oe("text-sm opacity-90",e),...t}));hx.displayName=ax.displayName;function DI(){const{toasts:e}=da();return u.jsxs(RI,{children:[e.map(function({id:t,title:n,description:r,action:o,...s}){return u.jsxs(dx,{...s,children:[u.jsxs("div",{className:"grid gap-1",children:[n&&u.jsx(px,{children:n}),r&&u.jsx(hx,{children:r})]}),o,u.jsx(fx,{})]},t)}),u.jsx(ux,{})]})}var LI=(e,t,n,r,o,s,i,a)=>{let l=document.documentElement,c=["light","dark"];function d(p){(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[p]?s[p]:p)):l.setAttribute(v,p)}),f(p)}function f(p){a&&c.includes(p)&&(l.style.colorScheme=p)}function m(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}if(r)d(r);else try{let p=localStorage.getItem(t)||n,v=i&&p==="system"?m():p;d(v)}catch{}},$I=h.createContext(void 0),FI={setTheme:e=>{},themes:[]},BI=()=>{var e;return(e=h.useContext($I))!=null?e:FI};h.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 h.createElement("script",{...c,suppressHydrationWarning:!0,nonce:typeof window>"u"?l:"",dangerouslySetInnerHTML:{__html:`(${LI.toString()})(${d})`}})});var zI=e=>{switch(e){case"success":return WI;case"info":return KI;case"warning":return VI;case"error":return qI;default:return null}},HI=Array(12).fill(0),UI=({visible:e,className:t})=>b.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},b.createElement("div",{className:"sonner-spinner"},HI.map((n,r)=>b.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),WI=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"})),VI=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"})),KI=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"})),qI=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"})),GI=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"})),YI=()=>{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},oc=1,XI=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:oc++,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(ZI(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)||oc++;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}},Yt=new XI,JI=(e,t)=>{let n=(t==null?void 0:t.id)||oc++;return Yt.addToast({title:e,...t,id:n}),n},ZI=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",QI=JI,eN=()=>Yt.toasts,tN=()=>Yt.getActiveToasts();Object.assign(QI,{success:Yt.success,info:Yt.info,warning:Yt.warning,error:Yt.error,custom:Yt.custom,message:Yt.message,promise:Yt.promise,dismiss:Yt.dismiss,loading:Yt.loading},{getHistory:eN,getToasts:tN});function nN(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))}nN(`: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%)}
|
|
131
|
-
`);function xi(e){return e.label!==void 0}var rN=3,oN="32px",sN="16px",mx=4e3,iN=356,aN=14,lN=20,cN=200;function gn(...e){return e.filter(Boolean).join(" ")}function uN(e){let[t,n]=e.split("-"),r=[];return t&&r.push(t),n&&r.push(n),r}var dN=e=>{var t,n,r,o,s,i,a,l,c,d,f;let{invert:m,toast:p,unstyled:v,interacting:g,setHeights:x,visibleToasts:y,heights:w,index:C,toasts:E,expanded:T,removeToast:S,defaultRichColors:k,closeButton:A,style:j,cancelButtonStyle:F,actionButtonStyle:D,className:B="",descriptionClassName:Y="",duration:M,position:W,gap:X,loadingIcon:z,expandByDefault:P,classNames:I,icons:q,closeButtonAriaLabel:Q="Close toast",pauseWhenPageIsHidden:O}=e,[G,L]=b.useState(null),[$,J]=b.useState(null),[R,_]=b.useState(!1),[U,Z]=b.useState(!1),[re,le]=b.useState(!1),[ke,ye]=b.useState(!1),[_e,ze]=b.useState(!1),[$e,Ge]=b.useState(0),[He,nt]=b.useState(0),ft=b.useRef(p.duration||M||mx),ct=b.useRef(null),Ue=b.useRef(null),Re=C===0,Ve=C+1<=y,Ne=p.type,Ke=p.dismissible!==!1,Ye=p.className||"",Ct=p.descriptionClassName||"",Ze=b.useMemo(()=>w.findIndex(xe=>xe.toastId===p.id)||0,[w,p.id]),Tt=b.useMemo(()=>{var xe;return(xe=p.closeButton)!=null?xe:A},[p.closeButton,A]),pt=b.useMemo(()=>p.duration||M||mx,[p.duration,M]),wt=b.useRef(0),At=b.useRef(0),Pt=b.useRef(0),ht=b.useRef(null),[mt,Ht]=W.split("-"),We=b.useMemo(()=>w.reduce((xe,De,Fe)=>Fe>=Ze?xe:xe+De.height,0),[w,Ze]),Le=YI(),dt=p.invert||m,kt=Ne==="loading";At.current=b.useMemo(()=>Ze*X+We,[Ze,We]),b.useEffect(()=>{ft.current=pt},[pt]),b.useEffect(()=>{_(!0)},[]),b.useEffect(()=>{let xe=Ue.current;if(xe){let De=xe.getBoundingClientRect().height;return nt(De),x(Fe=>[{toastId:p.id,height:De,position:p.position},...Fe]),()=>x(Fe=>Fe.filter(rt=>rt.toastId!==p.id))}},[x,p.id]),b.useLayoutEffect(()=>{if(!R)return;let xe=Ue.current,De=xe.style.height;xe.style.height="auto";let Fe=xe.getBoundingClientRect().height;xe.style.height=De,nt(Fe),x(rt=>rt.find(Qe=>Qe.toastId===p.id)?rt.map(Qe=>Qe.toastId===p.id?{...Qe,height:Fe}:Qe):[{toastId:p.id,height:Fe,position:p.position},...rt])},[R,p.title,p.description,x,p.id]);let ut=b.useCallback(()=>{Z(!0),Ge(At.current),x(xe=>xe.filter(De=>De.toastId!==p.id)),setTimeout(()=>{S(p)},cN)},[p,S,x,At]);b.useEffect(()=>{if(p.promise&&Ne==="loading"||p.duration===1/0||p.type==="loading")return;let xe;return T||g||O&&Le?(()=>{if(Pt.current<wt.current){let De=new Date().getTime()-wt.current;ft.current=ft.current-De}Pt.current=new Date().getTime()})():ft.current!==1/0&&(wt.current=new Date().getTime(),xe=setTimeout(()=>{var De;(De=p.onAutoClose)==null||De.call(p,p),ut()},ft.current)),()=>clearTimeout(xe)},[T,g,p,Ne,O,Le,ut]),b.useEffect(()=>{p.delete&&ut()},[ut,p.delete]);function _t(){var xe,De,Fe;return q!=null&&q.loading?b.createElement("div",{className:gn(I==null?void 0:I.loader,(xe=p==null?void 0:p.classNames)==null?void 0:xe.loader,"sonner-loader"),"data-visible":Ne==="loading"},q.loading):z?b.createElement("div",{className:gn(I==null?void 0:I.loader,(De=p==null?void 0:p.classNames)==null?void 0:De.loader,"sonner-loader"),"data-visible":Ne==="loading"},z):b.createElement(UI,{className:gn(I==null?void 0:I.loader,(Fe=p==null?void 0:p.classNames)==null?void 0:Fe.loader),visible:Ne==="loading"})}return b.createElement("li",{tabIndex:0,ref:Ue,className:gn(B,Ye,I==null?void 0:I.toast,(t=p==null?void 0:p.classNames)==null?void 0:t.toast,I==null?void 0:I.default,I==null?void 0:I[Ne],(n=p==null?void 0:p.classNames)==null?void 0:n[Ne]),"data-sonner-toast":"","data-rich-colors":(r=p.richColors)!=null?r:k,"data-styled":!(p.jsx||p.unstyled||v),"data-mounted":R,"data-promise":!!p.promise,"data-swiped":_e,"data-removed":U,"data-visible":Ve,"data-y-position":mt,"data-x-position":Ht,"data-index":C,"data-front":Re,"data-swiping":re,"data-dismissible":Ke,"data-type":Ne,"data-invert":dt,"data-swipe-out":ke,"data-swipe-direction":$,"data-expanded":!!(T||P&&R),style:{"--index":C,"--toasts-before":C,"--z-index":E.length-C,"--offset":`${U?$e:At.current}px`,"--initial-height":P?"auto":`${He}px`,...j,...p.style},onDragEnd:()=>{le(!1),L(null),ht.current=null},onPointerDown:xe=>{kt||!Ke||(ct.current=new Date,Ge(At.current),xe.target.setPointerCapture(xe.pointerId),xe.target.tagName!=="BUTTON"&&(le(!0),ht.current={x:xe.clientX,y:xe.clientY}))},onPointerUp:()=>{var xe,De,Fe,rt;if(ke||!Ke)return;ht.current=null;let Qe=Number(((xe=Ue.current)==null?void 0:xe.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),ot=Number(((De=Ue.current)==null?void 0:De.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),gt=new Date().getTime()-((Fe=ct.current)==null?void 0:Fe.getTime()),K=G==="x"?Qe:ot,se=Math.abs(K)/gt;if(Math.abs(K)>=lN||se>.11){Ge(At.current),(rt=p.onDismiss)==null||rt.call(p,p),J(G==="x"?Qe>0?"right":"left":ot>0?"down":"up"),ut(),ye(!0),ze(!1);return}le(!1),L(null)},onPointerMove:xe=>{var De,Fe,rt,Qe;if(!ht.current||!Ke||((De=window.getSelection())==null?void 0:De.toString().length)>0)return;let ot=xe.clientY-ht.current.y,gt=xe.clientX-ht.current.x,K=(Fe=e.swipeDirections)!=null?Fe:uN(W);!G&&(Math.abs(gt)>1||Math.abs(ot)>1)&&L(Math.abs(gt)>Math.abs(ot)?"x":"y");let se={x:0,y:0};G==="y"?(K.includes("top")||K.includes("bottom"))&&(K.includes("top")&&ot<0||K.includes("bottom")&&ot>0)&&(se.y=ot):G==="x"&&(K.includes("left")||K.includes("right"))&&(K.includes("left")&><0||K.includes("right")&>>0)&&(se.x=gt),(Math.abs(se.x)>0||Math.abs(se.y)>0)&&ze(!0),(rt=Ue.current)==null||rt.style.setProperty("--swipe-amount-x",`${se.x}px`),(Qe=Ue.current)==null||Qe.style.setProperty("--swipe-amount-y",`${se.y}px`)}},Tt&&!p.jsx?b.createElement("button",{"aria-label":Q,"data-disabled":kt,"data-close-button":!0,onClick:kt||!Ke?()=>{}:()=>{var xe;ut(),(xe=p.onDismiss)==null||xe.call(p,p)},className:gn(I==null?void 0:I.closeButton,(o=p==null?void 0:p.classNames)==null?void 0:o.closeButton)},(s=q==null?void 0:q.close)!=null?s:GI):null,p.jsx||b.isValidElement(p.title)?p.jsx?p.jsx:typeof p.title=="function"?p.title():p.title:b.createElement(b.Fragment,null,Ne||p.icon||p.promise?b.createElement("div",{"data-icon":"",className:gn(I==null?void 0:I.icon,(i=p==null?void 0:p.classNames)==null?void 0:i.icon)},p.promise||p.type==="loading"&&!p.icon?p.icon||_t():null,p.type!=="loading"?p.icon||(q==null?void 0:q[Ne])||zI(Ne):null):null,b.createElement("div",{"data-content":"",className:gn(I==null?void 0:I.content,(a=p==null?void 0:p.classNames)==null?void 0:a.content)},b.createElement("div",{"data-title":"",className:gn(I==null?void 0:I.title,(l=p==null?void 0:p.classNames)==null?void 0:l.title)},typeof p.title=="function"?p.title():p.title),p.description?b.createElement("div",{"data-description":"",className:gn(Y,Ct,I==null?void 0:I.description,(c=p==null?void 0:p.classNames)==null?void 0:c.description)},typeof p.description=="function"?p.description():p.description):null),b.isValidElement(p.cancel)?p.cancel:p.cancel&&xi(p.cancel)?b.createElement("button",{"data-button":!0,"data-cancel":!0,style:p.cancelButtonStyle||F,onClick:xe=>{var De,Fe;xi(p.cancel)&&Ke&&((Fe=(De=p.cancel).onClick)==null||Fe.call(De,xe),ut())},className:gn(I==null?void 0:I.cancelButton,(d=p==null?void 0:p.classNames)==null?void 0:d.cancelButton)},p.cancel.label):null,b.isValidElement(p.action)?p.action:p.action&&xi(p.action)?b.createElement("button",{"data-button":!0,"data-action":!0,style:p.actionButtonStyle||D,onClick:xe=>{var De,Fe;xi(p.action)&&((Fe=(De=p.action).onClick)==null||Fe.call(De,xe),!xe.defaultPrevented&&ut())},className:gn(I==null?void 0:I.actionButton,(f=p==null?void 0:p.classNames)==null?void 0:f.actionButton)},p.action.label):null))};function gx(){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 fN(e,t){let n={};return[e,t].forEach((r,o)=>{let s=o===1,i=s?"--mobile-offset":"--offset",a=s?sN:oN;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 pN=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:f,duration:m,style:p,visibleToasts:v=rN,toastOptions:g,dir:x=gx(),gap:y=aN,loadingIcon:w,icons:C,containerAriaLabel:E="Notifications",pauseWhenPageIsHidden:T}=e,[S,k]=b.useState([]),A=b.useMemo(()=>Array.from(new Set([r].concat(S.filter(O=>O.position).map(O=>O.position)))),[S,r]),[j,F]=b.useState([]),[D,B]=b.useState(!1),[Y,M]=b.useState(!1),[W,X]=b.useState(d!=="system"?d:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),z=b.useRef(null),P=o.join("+").replace(/Key/g,"").replace(/Digit/g,""),I=b.useRef(null),q=b.useRef(!1),Q=b.useCallback(O=>{k(G=>{var L;return(L=G.find($=>$.id===O.id))!=null&&L.delete||Yt.dismiss(O.id),G.filter(({id:$})=>$!==O.id)})},[]);return b.useEffect(()=>Yt.subscribe(O=>{if(O.dismiss){k(G=>G.map(L=>L.id===O.id?{...L,delete:!0}:L));return}setTimeout(()=>{Do.flushSync(()=>{k(G=>{let L=G.findIndex($=>$.id===O.id);return L!==-1?[...G.slice(0,L),{...G[L],...O},...G.slice(L+1)]:[O,...G]})})})}),[]),b.useEffect(()=>{if(d!=="system"){X(d);return}if(d==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?X("dark"):X("light")),typeof window>"u")return;let O=window.matchMedia("(prefers-color-scheme: dark)");try{O.addEventListener("change",({matches:G})=>{X(G?"dark":"light")})}catch{O.addListener(({matches:L})=>{try{X(L?"dark":"light")}catch($){console.error($)}})}},[d]),b.useEffect(()=>{S.length<=1&&B(!1)},[S]),b.useEffect(()=>{let O=G=>{var L,$;o.every(J=>G[J]||G.code===J)&&(B(!0),(L=z.current)==null||L.focus()),G.code==="Escape"&&(document.activeElement===z.current||($=z.current)!=null&&$.contains(document.activeElement))&&B(!1)};return document.addEventListener("keydown",O),()=>document.removeEventListener("keydown",O)},[o]),b.useEffect(()=>{if(z.current)return()=>{I.current&&(I.current.focus({preventScroll:!0}),I.current=null,q.current=!1)}},[z.current]),b.createElement("section",{ref:t,"aria-label":`${E} ${P}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},A.map((O,G)=>{var L;let[$,J]=O.split("-");return S.length?b.createElement("ol",{key:O,dir:x==="auto"?gx():x,tabIndex:-1,ref:z,className:a,"data-sonner-toaster":!0,"data-theme":W,"data-y-position":$,"data-lifted":D&&S.length>1&&!s,"data-x-position":J,style:{"--front-toast-height":`${((L=j[0])==null?void 0:L.height)||0}px`,"--width":`${iN}px`,"--gap":`${y}px`,...p,...fN(l,c)},onBlur:R=>{q.current&&!R.currentTarget.contains(R.relatedTarget)&&(q.current=!1,I.current&&(I.current.focus({preventScroll:!0}),I.current=null))},onFocus:R=>{R.target instanceof HTMLElement&&R.target.dataset.dismissible==="false"||q.current||(q.current=!0,I.current=R.relatedTarget)},onMouseEnter:()=>B(!0),onMouseMove:()=>B(!0),onMouseLeave:()=>{Y||B(!1)},onDragEnd:()=>B(!1),onPointerDown:R=>{R.target instanceof HTMLElement&&R.target.dataset.dismissible==="false"||M(!0)},onPointerUp:()=>M(!1)},S.filter(R=>!R.position&&G===0||R.position===O).map((R,_)=>{var U,Z;return b.createElement(dN,{key:R.id,icons:C,index:_,toast:R,defaultRichColors:f,duration:(U=g==null?void 0:g.duration)!=null?U:m,className:g==null?void 0:g.className,descriptionClassName:g==null?void 0:g.descriptionClassName,invert:n,visibleToasts:v,closeButton:(Z=g==null?void 0:g.closeButton)!=null?Z:i,interacting:Y,position:O,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:Q,toasts:S.filter(re=>re.position==R.position),heights:j.filter(re=>re.position==R.position),setHeights:F,expandByDefault:s,gap:y,loadingIcon:w,expanded:D,pauseWhenPageIsHidden:T,swipeDirections:e.swipeDirections})})):null}))});const hN=({...e})=>{const{theme:t="system"}=BI();return u.jsx(pN,{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})};H.ApiProvider=cu,H.ArtifactRenderer=tf,H.Badge=lf,H.Button=Xe,H.Card=ha,H.CardContent=bs,H.CardDescription=xa,H.CardHeader=ma,H.CardTitle=ga,H.ChatApi=su,H.ChatApp=Gk,H.ChatInput=Kh,H.ChatInputRow=qh,H.ChatInterface=Fr,H.ChatProviders=Tr,H.ChatWidget=Jk,H.Command=kl,H.CommandEmpty=Nl,H.CommandGroup=Al,H.CommandInput=El,H.CommandItem=jl,H.CommandList=Il,H.DEFAULT_TIMEOUT_MS=nu,H.Dialog=la,H.DialogContent=cs,H.DialogHeader=us,H.DialogTitle=ds,H.DropdownMenu=Js,H.DropdownMenuContent=jo,H.DropdownMenuItem=Kn,H.DropdownMenuTrigger=Zs,H.FileApi=iu,H.HISTORY_TIMEOUT_MS=ru,H.Input=Ll,H.InterruptPartRenderer=va,H.Label=jm,H.MarkdownContent=ir,H.MessageComponent=ws,H.MessageContent=af,H.MessageHeader=cf,H.MessageList=Wa,H.MessageRow=Ua,H.NewChatButton=Zk,H.PlotArtifact=ef,H.SETTINGS_STORAGE_KEY=Wi,H.ScrollArea=Dl,H.Select=PE,H.SelectContent=xg,H.SelectItem=vg,H.SelectTrigger=hg,H.SelectValue=_E,H.Separator=Sg,H.Sheet=UE,H.SheetContent=Pg,H.SheetDescription=Mg,H.SheetHeader=_g,H.SheetTitle=Rg,H.SheetTrigger=WE,H.SimpleChat=Yk,H.SimpleJsonView=vs,H.Sonner=hN,H.StreamProgress=nf,H.Switch=Ag,H.Textarea=vl,H.ThinkingIndicator=of,H.ThreadListItem=$l,H.ThreadManager=si,H.ThreadStateProvider=$u,H.ThreadsProvider=bu,H.TimelineColumn=_x,H.Toaster=DI,H.ToolContent=fp,H.Tooltip=pI,H.TooltipContent=Ug,H.TooltipProvider=fI,H.TooltipTrigger=hI,H.UserTextContent=sf,H.applySettings=Eb,H.buildCheckpointIndex=cc,H.buildCheckpointPreviewMap=yx,H.buildLabelParts=Eu,H.chatApiClient=Mn,H.collectText=Su,H.createArtifactPreviewFromPlot=Nu,H.createArtifactPreviewFromSource=Iu,H.del=Oi,H.extractConfigFields=bi,H.extractToolContent=nr,H.extractToolMeta=Yo,H.fileApiClient=au,H.fileToBase64=uu,H.formatToolOutput=yu,H.get=Kt,H.getAgentNameFromMessage=Tu,H.getChatToken=Ri,H.getCheckpointForMessage=Sx,H.getCurrentSettings=kb,H.getDefaultApiConfig=qu,H.getDefaultChatSettings=Gu,H.getMessageAttemptInfo=uc,H.getMessageDomKey=Ha,H.getPreviewForMessage=vi,H.getToolProgress=Bi,H.httpClient=Lt,H.hydrateHistorySnapshots=Xn,H.isEnvelope=fu,H.isFileLike=Li,H.loadStoredSettings=Yu,H.looksLikeMarkdown=wu,H.messageSignature=Fi,H.normalizeInterruptId=$i,H.normalizeMimeType=ku,H.normalizeToolPayload=Au,H.normalizeToolPayloadValue=Cr,H.onChatTokenChanged=Mi,H.parseJsonSafe=er,H.post=to,H.pretty=tr,H.processAttachments=du,H.put=ou,H.readNumber=fc,H.readString=_n,H.sanitizeForDisplay=Sr,H.saveSettings=Xu,H.setChatToken=Rn,H.stringifyTool=Cu,H.toPlainObject=Pn,H.unwrap=$t,H.useApi=On,H.useCheckpointIndex=dc,H.useFilePreview=uf,H.useHasChatSession=Cb,H.useParsedMessageContent=df,H.useShallowStableValue=Uu,H.useStream=Ui,H.useStreamingHook=Ui,H.useThreadHistoryState=Mu,H.useThreadManagerViewState=Im,H.useThreadState=ro,H.useThreadStateUpdater=Lu,H.useThreads=yr,H.useThreadsState=xu,H.useToolPayload=pf,Object.defineProperty(H,Symbol.toStringTag,{value:"Module"})});
|
|
128
|
+
Please report this to https://github.com/markedjs/marked.`,e){const o="<p>An error occurred:</p><pre>"+Rt(r.message+"",!0)+"</pre>";if(t)return Promise.resolve(o);if(n){n(null,o);return}return o}if(t)return Promise.reject(r);if(n){n(r);return}throw r}}function Qd(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...ve.defaults,...s};const i=yy(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(vy(r),r.hooks&&(r.hooks.options=r),o){const a=r.highlight;let l;try{r.hooks&&(n=r.hooks.preprocess(n)),l=e(n,r)}catch(f){return i(f)}const c=function(f){let m;if(!f)try{r.walkTokens&&ve.walkTokens(l,r.walkTokens),m=t(l,r),r.hooks&&(m=r.hooks.postprocess(m))}catch(p){f=p}return r.highlight=a,f?i(f):o(null,m)};if(!a||a.length<3||(delete r.highlight,!l.length))return c();let d=0;ve.walkTokens(l,function(f){f.type==="code"&&(d++,setTimeout(()=>{a(f.text,f.lang,function(m,p){if(m)return c(m);p!=null&&p!==f.text&&(f.text=p,f.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(ve.walkTokens(a,r.walkTokens)).then(()=>a):a).then(a=>t(a,r)).then(a=>r.hooks?r.hooks.postprocess(a):a).catch(i);try{r.hooks&&(n=r.hooks.preprocess(n));const a=e(n,r);r.walkTokens&&ve.walkTokens(a,r.walkTokens);let l=t(a,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(a){return i(a)}}}function ve(e,t,n){return Qd($n.lex,Fn.parse)(e,t,n)}ve.options=ve.setOptions=function(e){return ve.defaults={...ve.defaults,...e},sy(ve.defaults),ve},ve.getDefaults=zd,ve.defaults=sr,ve.use=function(...e){const t=ve.defaults.extensions||{renderers:{},childTokens:{}};e.forEach(n=>{const r={...n};if(r.async=ve.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(o=>{if(!o.name)throw new Error("extension name required");if(o.renderer){const s=t.renderers[o.name];s?t.renderers[o.name]=function(...i){let a=o.renderer.apply(this,i);return a===!1&&(a=s.apply(this,i)),a}:t.renderers[o.name]=o.renderer}if(o.tokenizer){if(!o.level||o.level!=="block"&&o.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");t[o.level]?t[o.level].unshift(o.tokenizer):t[o.level]=[o.tokenizer],o.start&&(o.level==="block"?t.startBlock?t.startBlock.push(o.start):t.startBlock=[o.start]:o.level==="inline"&&(t.startInline?t.startInline.push(o.start):t.startInline=[o.start]))}o.childTokens&&(t.childTokens[o.name]=o.childTokens)}),r.extensions=t),n.renderer){const o=ve.defaults.renderer||new pa;for(const s in n.renderer){const i=o[s];o[s]=(...a)=>{let l=n.renderer[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.renderer=o}if(n.tokenizer){const o=ve.defaults.tokenizer||new fa;for(const s in n.tokenizer){const i=o[s];o[s]=(...a)=>{let l=n.tokenizer[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.tokenizer=o}if(n.hooks){const o=ve.defaults.hooks||new xs;for(const s in n.hooks){const i=o[s];xs.passThroughHooks.has(s)?o[s]=a=>{if(ve.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=ve.defaults.walkTokens;r.walkTokens=function(s){let i=[];return i.push(n.walkTokens.call(this,s)),o&&(i=i.concat(o.call(this,s))),i}}ve.setOptions(r)})},ve.walkTokens=function(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(ve,r)),r.type){case"table":{for(const o of r.header)n=n.concat(ve.walkTokens(o.tokens,t));for(const o of r.rows)for(const s of o)n=n.concat(ve.walkTokens(s.tokens,t));break}case"list":{n=n.concat(ve.walkTokens(r.items,t));break}default:ve.defaults.extensions&&ve.defaults.extensions.childTokens&&ve.defaults.extensions.childTokens[r.type]?ve.defaults.extensions.childTokens[r.type].forEach(function(o){n=n.concat(ve.walkTokens(r[o],t))}):r.tokens&&(n=n.concat(ve.walkTokens(r.tokens,t)))}return n},ve.parseInline=Qd($n.lexInline,Fn.parseInline),ve.Parser=Fn,ve.parser=Fn.parse,ve.Renderer=pa,ve.TextRenderer=Jd,ve.Lexer=$n,ve.lexer=$n.lex,ve.Tokenizer=fa,ve.Slugger=Zd,ve.Hooks=xs,ve.parse=ve,ve.options,ve.setOptions,ve.use,ve.walkTokens,ve.parseInline,Fn.parse,$n.lex;function ir({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 ve.parse=="function"?ve.parse(i):ve(i)}return typeof ve.parse=="function"?ve.parse(e):ve(e)}catch(i){return console.error("[MarkdownContent] parse error",i),`<pre class="font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words">Error rendering markdown: ${String(i)}</pre>`}},[e,n]),s=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 ef({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})}})})]})}function tf({artifact:e,idx:t=0}){const n=b.useMemo(()=>e?(Array.isArray(e.plots)?e.plots:[]).map(o=>Nu(o)).filter(o=>o!==null):[],[e]);return n.length>0?u.jsx("div",{className:"space-y-2",children:n.map((r,o)=>u.jsx(ef,{preview:r,idx:o},`${t}-plot-${o}`))}):null}const Sy="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 vs({data:e}){return Array.isArray(e)?e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?u.jsx("div",{className:Sy,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:tr(e)}):u.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:tr(e)})}function nf({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(de.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}const ha=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:oe("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));ha.displayName="Card";const ma=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:oe("flex flex-col space-y-1.5 p-6",e),...t}));ma.displayName="CardHeader";const ga=h.forwardRef(({className:e,...t},n)=>u.jsx("h3",{ref:n,className:oe("text-2xl font-semibold leading-none tracking-tight",e),...t}));ga.displayName="CardTitle";const xa=h.forwardRef(({className:e,...t},n)=>u.jsx("p",{ref:n,className:oe("text-sm text-muted-foreground",e),...t}));xa.displayName="CardDescription";const bs=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:oe("p-6 pt-0",e),...t}));bs.displayName="CardContent";const rf=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:oe("flex items-center p-6 pt-0",e),...t}));rf.displayName="CardFooter";const Cy=e=>!!e&&typeof e=="object"&&e.type==="user_choice"&&typeof e.question=="string"&&Array.isArray(e.alternatives);function va({interruptPart:e,onApprove:t,onReject:n,onSelectAlternative:r,disabled:o,isActive:s,payload:i}){const a=Cy(i)?i:null,l=(a==null?void 0:a.question)??e.title??"Approve the result?",c=a?s?"Select one of the alternatives to continue.":"Waiting for approval from another participant.":s?"Please approve or reject this action to resume the workflow.":"Waiting for approval from another participant.";let d=null;if(!a&&i!==void 0&&i!==null)if(typeof i=="string")d=u.jsx("p",{className:"text-sm leading-relaxed text-blue-800/90 dark:text-blue-200/90 whitespace-pre-wrap",children:i});else{const f=tr(i);d=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:f})}return u.jsxs(ha,{className:oe("border-blue-200 dark:border-blue-800 bg-blue-50/50 dark:bg-blue-950/10 transition-shadow",s?"shadow-md ring-1 ring-blue-300 dark:ring-blue-500/70":"opacity-80"),children:[u.jsxs(ma,{className:"pb-3",children:[u.jsx(ga,{className:"text-blue-900 dark:text-blue-100 text-base",children:l}),u.jsx(xa,{className:"text-blue-700 dark:text-blue-300 text-sm",children:c})]}),a?u.jsx(bs,{className:"pt-0 pb-3",children:u.jsx("div",{className:"space-y-2",children:a.alternatives.map(f=>u.jsx(Xe,{size:"sm",variant:"outline",onClick:()=>r==null?void 0:r(e,f),className:"w-full justify-start text-left",disabled:o||!s,children:u.jsxs("div",{className:"flex flex-col items-start gap-1",children:[u.jsx("span",{className:"font-semibold",children:f.label}),f.description?u.jsx("span",{className:"text-xs text-muted-foreground leading-snug",children:f.description}):null]})},f.id))})}):d&&u.jsx(bs,{className:"pt-0 pb-3",children:d}),!a&&u.jsx(rf,{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:o||!s,children:"Reject"}),u.jsx(Xe,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",disabled:o||!s,children:"Approve"})]})})]})}function of({className:e}){const t=b.useRef(null);return b.useEffect(()=>{let n=0;const r=()=>{if(n=(n+1)%4,t.current){const s=".".repeat(n);t.current.textContent=`Is thinking${s}`}};r();const o=setInterval(r,500);return()=>clearInterval(o)},[]),u.jsx("span",{ref:t,"aria-live":"polite",className:oe("inline-block text-xs opacity-70 ml-1",e),children:"Is thinking"})}function sf({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(ir,{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(de.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):u.jsxs(u.Fragment,{children:[u.jsx(de.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",s," chars)"]})})]})}function Ty(e,t,n){const[r,o]=b.useState(e),s=b.useRef(e),i=b.useRef(null);return b.useEffect(()=>{s.current=e;const a=()=>{o(s.current),i.current&&(clearTimeout(i.current),i.current=null)};if(!t||n<=0){a();return}return i.current&&clearTimeout(i.current),i.current=setTimeout(()=>{a()},n),()=>{i.current&&(clearTimeout(i.current),i.current=null)}},[e,t,n]),r}function af({message:e,isToolMessage:t,showToolMessages:n,toolViewMode:r,toolExpandable:o,isToolStreaming:s,contentParts:i,textContent:a,imageParts:l,fileParts:c,interruptPart:d,isStreamingMessage:f,streamingDebounceMs:m,enableStreamingMarkdownBuffer:p,renderStreamingMarkdown:v,defaultMessage:g,handleFileClick:x,uploadingFiles:y,messageRole:w,truncateUserMessages:C,userMessagePreviewLength:E,isUserExpanded:T,setIsUserExpanded:S,isCompactLayout:k,iconForeground:A,toolConfig:j,handleInterruptApprove:F,handleInterruptReject:D,handleInterruptAlternative:B,disableInterruptActions:G,isInterruptMessage:M}){const W=b.useCallback(()=>u.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/30 rounded",children:[u.jsx(de.Loader,{className:"h-4 w-4 text-muted-foreground"}),u.jsx("span",{className:"text-sm text-muted-foreground",children:"File upload"})]}),[]),z=Ty(i,(p??!0)&&f,m??0),P=b.useMemo(()=>z.filter(_=>_.type==="text"),[z]),I=b.useMemo(()=>P.map(_=>_.text??"").join(""),[P]),K=b.useMemo(()=>{if(!v)return null;const _=Ey(I);return{stablePart:I.slice(0,_),tailPart:I.slice(_)}},[I,v]),te=b.useMemo(()=>{if(!K)return null;const{stablePart:_,tailPart:U}=K;return!_&&!U?null:u.jsxs("div",{className:"space-y-2",children:[_?u.jsx(ir,{content:_,allowHtml:!1}):null,U?u.jsx(ir,{content:U,allowHtml:!1}):null]})},[K]),O=b.useMemo(()=>{if(!v)return z;const _=[];let U=!1;for(const Z of z){if(Z.type==="text"){U||(_.push({type:"text",text:"",__streamingMarkdownAggregate:!0}),U=!0);continue}_.push(Z)}return _},[z,v]),L=(v?O:z).filter(_=>_.type!=="interrupt"&&_.type!=="image_url"),$=()=>!l||l.length===0?null:u.jsx("div",{className:"flex flex-wrap gap-2 mb-2",children:l.map((_,U)=>{const Z=_;return u.jsx("div",{className:"relative group",children:u.jsx("img",{src:Z.url,alt:Z.alt??"Image",loading:"lazy",onClick:()=>window.open(Z.url,"_blank"),className:"h-20 w-20 object-cover rounded-md border border-border/50 cursor-pointer hover:opacity-90 transition-opacity"})},U)})}),X=b.useCallback(({part:_,i:U})=>{if(_.type==="text"){if(v)return null;const Z=_.text??"",re=Z.trim(),ce=er(re);return ce&&w!=="tool"?u.jsx(vs,{data:ce},U):w==="user"&&C&&re.length>E?u.jsx(sf,{text:re,expanded:T,onExpandedChange:S,previewLength:E,isCompact:k},U):u.jsx(ir,{content:Z,allowHtml:!1},U)}if(_.type==="image_url")return null;if(_.type==="file"){const Z=_,re=Z.name||"file";return u.jsxs("a",{href:Z.url,onClick:ce=>x(ce,Z,U),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:[y[U]?u.jsx(de.Loader,{className:"h-4 w-4 animate-spin"}):null,u.jsxs("span",{className:"truncate max-w-[180px]",children:[re,y[U]?" (processing)":""]})]},U)}return null},[x,k,T,w,C,y,E,v,S]),R=a.trim().length>0||l.length>0||c.length>0||L.length>0;if(!t&&c.length>0&&!f&&!a&&l.length===0)return W();if(!t&&!R&&!f)return null;if(t){if(!n)return null;if(M&&d){const _=d.value,U=!G,Z=F??(()=>{}),re=D??(()=>{});return u.jsx(va,{interruptPart:d,payload:_,onApprove:Z,onReject:re,onSelectAlternative:B,disabled:G,isActive:U})}return u.jsx(fp,{message:e,viewMode:r,expandable:o,isStreaming:s,toolConfig:j},e.id)}if(!g){const _=u.jsxs("div",{className:"space-y-2",children:[$(),L.map((U,Z)=>v&&Iy(U)?te?u.jsx("div",{className:"space-y-2",children:te},`streaming-md-${Z}`):null:u.jsx(X,{part:U,i:Z},Z))]});return f?u.jsxs("div",{"aria-busy":"true",role:"status",children:[_,u.jsx(of,{className:A})]}):_}return null}function ky(e){return e?!(co(e,/```/g)||co(e,/`/g)||co(e,/\*\*/g)||co(e,/__/g)||co(e,/~~/g)||/[^\\]\[[^\]]*$/.test(e)||/\[[^\]]*\]\([^)]*$/.test(e)):!0}function co(e,t){const n=e.match(t);return((n==null?void 0:n.length)??0)%2!==0}function Ey(e){if(!e)return 0;for(let t=e.length;t>=0;t-=1)if(ky(e.slice(0,t)))return t;return 0}function Iy(e){return e.type==="text"&&!!e.__streamingMarkdownAggregate}const Ny=Kr.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 lf({className:e,variant:t,...n}){return u.jsx("div",{className:oe(Ny({variant:t}),e),...n})}function cf({showTimestamp:e,showAgentName:t,isToolMessage:n,isInterruptMessage:r=!1,iconForeground:o,agentName:s,messageIcon:i,customHeaderClass:a,customActionsClass:l,isCompactLayout:c,showActions:d,isEditing:f,messageRole:m,toolViewMode:p,toolExpandable:v=!1,toolMeta:g,onToggleToolView:x,onCopy:y,onEdit:w,onRegenerate:C,showCheckpointControls:E,attemptCount:T,attemptIndex:S,handleOlderAttemptSelect:k,handleNewerAttemptSelect:A,messageCreatedAt:j,copied:F}){return!e&&!t&&!n&&!r?null:u.jsxs("div",{className:oe("flex items-center justify-between mb-2 pb-2 border-b border-current/10",c&&"mb-1 pb-1",o,a),children:[u.jsxs("div",{className:"flex items-center gap-2",children:[i,t&&s&&u.jsx("span",{className:oe("font-medium",c?"text-xs":"text-sm"),children:s}),n&&!r&&u.jsxs(lf,{variant:"outline",className:oe("text-xs flex items-center gap-1",o,"border border-current/40",c&&"text-xs h-4",v&&"cursor-pointer select-none"),role:v?"button":void 0,tabIndex:v?0:void 0,"aria-expanded":v?p==="expanded":void 0,onClick:v?x:void 0,onKeyDown:D=>{v&&(D.key==="Enter"||D.key===" ")&&(D.preventDefault(),x())},children:[u.jsx("span",{children:g.name??"Tool Output"}),g.toolCallId&&u.jsx("span",{className:"opacity-70",children:g.toolCallId.slice(0,8)}),v&&(p==="expanded"?u.jsx(de.ChevronUp,{className:"h-3 w-3"}):u.jsx(de.ChevronDown,{className:"h-3 w-3"}))]}),r&&u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:g.name??"Interrupt"})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[E&&T>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",S<T-1?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{S>=T-1||k()},"aria-label":"Older attempt (back in time)",disabled:S>=T-1,children:u.jsx(de.ChevronLeft,{className:"h-3 w-3"})}),u.jsx("div",{className:"flex items-center gap-2",children:u.jsxs("span",{className:"whitespace-nowrap",children:[T-S," / ",T]})}),u.jsx("button",{type:"button",className:oe("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",S>0?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{S<=0||A()},"aria-label":"Newer attempt (forward in time)",disabled:S<=0,children:u.jsx(de.ChevronRight,{className:"h-3 w-3"})})]}),e&&j&&u.jsx("time",{className:oe("text-xs opacity-60",o,c&&"text-xs"),dateTime:new Date(j.endsWith("Z")||j.includes("+")?j:`${j}Z`).toISOString(),title:new Date(j.endsWith("Z")||j.includes("+")?j:`${j}Z`).toLocaleString(),children:new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(new Date(j.endsWith("Z")||j.includes("+")?j:`${j}Z`))}),d&&!f&&u.jsxs("div",{className:oe("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",l),children:[u.jsx("div",{className:"relative",children:u.jsx(Xe,{variant:"ghost",size:"sm",onClick:y,className:oe("h-6 w-6 p-0 hover:bg-foreground/10",o,c&&"h-5 w-5"),"aria-label":"Copy message",title:"Copy message",children:u.jsx(de.Copy,{className:oe(F?"text-success":o,c?"h-3 w-3":"h-4 w-4")})})}),m==="user"&&w&&u.jsx(Xe,{variant:"ghost",size:"sm",onClick:w,className:oe("h-6 w-6 p-0 hover:bg-foreground/10",o,c&&"h-5 w-5"),"aria-label":"Edit message",children:u.jsx(de.Edit,{className:oe(o,c?"h-3 w-3":"h-4 w-4")})}),m==="assistant"&&C&&u.jsx(Xe,{variant:"ghost",size:"sm",onClick:C,className:oe("h-6 w-6 p-0 hover:bg-foreground/10",o,c&&"h-5 w-5"),"aria-label":"Regenerate response",children:u.jsx(de.RotateCcw,{className:oe(o,c?"h-3 w-3":"h-4 w-4")})})]})]})]})}function uf(e){const{allowFileOpen:t,currentThreadId:n}=e,{fileApi:r}=On(),{toast:o}=da(),[s,i]=b.useState({}),[a,l]=b.useState(null),[c,d]=b.useState(!1),f=b.useCallback(()=>{d(!1),l(null)},[]),m=b.useCallback(v=>{l(v),d(!0)},[]),p=b.useCallback(async(v,g,x)=>{var y,w;if(!t){v.preventDefault();return}if(s[x]){v.preventDefault();return}try{const C=String(g.url??""),E=C.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);if(E){v.preventDefault();const T=E[1],S=g.name||`file_${T}`,k=g.mimeType||"application/octet-stream";m({id:T,name:S,mimeType:k});return}if(C.startsWith("data:")){v.preventDefault(),i(S=>({...S,[x]:!0}));const T=o({title:"Fetching file...",description:"",open:!0});try{const S=await r.listFiles(n??void 0);if(!S||!Array.isArray(S))throw new Error("Invalid file list response");const k=S.find(A=>!A||typeof A!="object"||!((A.filename??"")===(g.name??""))?!1:typeof g.size=="number"&&typeof A.size=="number"?A.size===g.size:!0);if(!(k!=null&&k.id))throw new Error(`File "${g.name}" is not yet available on the server`);if(!k.id||!k.filename)throw new Error("Invalid file data received from server");m({id:k.id,name:g.name||k.filename||`file_${k.id}`,mimeType:g.mimeType||k.mime_type||"application/octet-stream"}),(y=T.update)==null||y.call(T,{id:T.id,title:"Success",description:`Opened ${g.name}`,open:!0})}catch(S){console.error("Failed to fetch server file:",S);const k=S instanceof Error?S.message:"Unknown error occurred";(w=T.update)==null||w.call(T,{id:T.id,title:"Failed",description:k}),o({title:"Failed to fetch file",description:k,open:!0})}finally{i(S=>({...S,[x]:!1}))}}}catch(C){console.error("File click error:",C),i(E=>({...E,[x]:!1}))}},[t,s,o,n,m]);return{uploadingFiles:s,handleFileClick:p,fileViewerOpen:c,currentFileInfo:a,closeFileViewer:f}}function df(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:Su(r),toolMeta:Yo(n),imageParts:r.filter(s=>s.type==="image_url"),fileParts:r.filter(s=>s.type==="file"),interruptParts:r.filter(s=>s.type==="interrupt"),toolRaw:Cu(r),isToolStreaming:!!o.toolStreaming}},[e,t])}const ff="data:";function Ay(e){if(!e)return[];const t=[],n=e.split(/\r?\n/);for(const r of n){const o=r.trim();if(!o||!o.startsWith(ff))continue;const s=o.slice(ff.length).trim();if(!s||s.toLowerCase()==="[done]")continue;const i=er(s);i&&typeof i=="object"&&t.push(i)}return t}function jy(e){for(let t=e.length-1;t>=0;t-=1){const n=e[t];if(n&&typeof n=="object"&&n.type==="tool.end")return n}return null}function pf(e){return b.useMemo(()=>{const t=e.content.filter(c=>c.type==="text");if(!t.length)return null;let r=t.flatMap(c=>Ay(c.text??""));if(!r.length){const c=t.map(f=>f.text??"").join(`
|
|
130
|
+
`),d=er(c);d&&typeof d=="object"&&(r=[d])}if(!r.length)return null;const s=jy(r)??r[r.length-1];if(!s)return null;const i=s.output??s.payload??s,a=Cr(i),l=nr(a);return l&&typeof l=="object"&&!Array.isArray(l)?{kind:"dict",value:l,data:l,event:s}:{kind:"generic",value:l,event:s}},[e])}const ws=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:f=!0,toolConfig:m,customStyles:p={},streamingDebounceMs:v=300,renderStreamingMarkdown:g=!0,enableStreamingMarkdownBuffer:x,onEdit:y,onRegenerate:w,onCopy:C,getInterruptOptions:E,attemptCount:T=1,attemptIndex:S=0,onSelectCheckpoint:k,attemptMetas:A=[]}){const[j,F]=b.useState(!1),[D,B]=b.useState(!1),{currentThreadId:G}=yr(),{respondToInterrupt:M}=ro(),[W,Y]=b.useState(!1),z=l==="phone"||l==="half-screen",P=t.role,I=P==="interrupt",K=P==="tool"||I,O=!(t.role==="default_message")&&t.expandable!==void 0?t.expandable!==!1:!0,{toolRenderers:q,toolArtifactRenderers:L,getToolExpandable:$}=m??{},X=b.useMemo(()=>!$||t.role!=="tool"?!1:$(t),[$,t.id,t.role]),[R,_]=b.useState(X?"preview":"expanded");b.useEffect(()=>{_(X?"preview":"expanded")},[X,t.id]);const U=b.useMemo(()=>t.role==="default_message"?t:null,[t]),Z=!!U,re=!(r&&P!=="user"),{uploadingFiles:ce,handleFileClick:Ne,fileViewerOpen:ye,currentFileInfo:Re,closeFileViewer:We}=uf({allowFileOpen:re,currentThreadId:G}),Fe=b.useMemo(()=>{switch(P){case"user":return"text-[hsl(var(--chat-bubble-user-text))]";case"assistant":return"text-[hsl(var(--chat-bubble-ai-text))]";case"interrupt":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))]"}},[P]),Ye=df(t,U),{contentParts:Ve,imageParts:tt,fileParts:gt,textContent:at,toolMeta:lt,toolRaw:Me,isToolStreaming:Ke,interruptParts:je}=Ye,qe=x??v!==0,Be=b.useMemo(()=>je.length?je[0]:null,[je]),nt=b.useCallback(async()=>{const ae=K?Me:at;async function ie(Ce){if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function"){await navigator.clipboard.writeText(Ce);return}if(navigator.clipboard&&typeof navigator.clipboard.write=="function"&&typeof ClipboardItem<"u"){const Ee=new Blob([Ce],{type:"text/plain"});await navigator.clipboard.write([new ClipboardItem({"text/plain":Ee})]);return}throw new Error("Clipboard API not supported in this context.")}try{await ie(ae),F(!0),setTimeout(()=>F(!1),2e3),C==null||C(ae)}catch(Ce){console.error("Failed to copy:",Ce)}},[K,Me,at,C]),ct=b.useCallback(async(ae,ie)=>{if(!Be)return;if(!$i(Be.id)){console.warn("Interrupt part missing id",Be);return}Y(!0);try{const Ee=E==null?void 0:E(t);await M(ae,ie,Ee)}catch(Ee){console.error("Failed to respond to interrupt:",Ee)}finally{Y(!1)}},[Be,M]),ft=b.useCallback(()=>ct(!0),[ct]),yt=b.useCallback(()=>ct(!1),[ct]),Tt=b.useCallback((ae,ie)=>{if(!ie)return;const Ce={alternativeId:ie.id??ie.label??void 0,alternativeLabel:ie.label};ct(!0,Ce)},[ct]),pt=b.useCallback(()=>{if(!y||!t.id)return;const ae=(K?Me:at)??"",ie="type"in t&&t.type==="default_message"?void 0:{checkpointId:t.checkpointId??null,checkpointNs:t.checkpointNs??null};y(t.id,ae,ie)},[y,K,Me,at,t]),At=b.useCallback(()=>{w==null||w(n)},[w,n]),xt=b.useCallback(()=>{const ie=oe(z?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",Fe);switch(P){case"user":return u.jsx(de.User,{className:ie});case"assistant":return u.jsx(de.Bot,{className:ie});case"tool":return u.jsx(de.Wrench,{className:ie});case"interrupt":return u.jsx(de.Bot,{className:ie});default:return u.jsx(de.Bot,{className:ie})}},[z,Fe,P]),ht=b.useCallback(()=>{const ae="group relative mb-4 flex w-full";switch(P){case"user":return oe(ae,"justify-end");case"assistant":case"tool":case"system":case"interrupt":return oe(ae,"justify-start");default:return ae}},[P]),zt=b.useCallback(()=>{const ae=oe("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",z&&"px-3 py-2 text-sm");if(Z)return oe(ae,"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(P){case"user":return oe(ae,"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(ae,"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":case"interrupt":return oe(ae,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return oe(ae,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return oe(ae,"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")}},[z,Z,P]),Ht=X&&!I&&O,Oe=b.useCallback(()=>{Ht&&_(ae=>ae==="expanded"?"preview":"expanded")},[Ht]),kt=I?"expanded":R,ut=(f||I)&&O,Pt=u.jsx(af,{message:t,isToolMessage:K,showToolMessages:ut,toolViewMode:kt,toolExpandable:X,toolConfig:{toolRenderers:q,toolArtifactRenderers:L,getToolExpandable:$},isToolStreaming:Ke,contentParts:Ve,textContent:at,imageParts:tt,fileParts:gt,isStreamingMessage:r,defaultMessage:U,enableStreamingMarkdownBuffer:qe,renderStreamingMarkdown:g,streamingDebounceMs:v,handleFileClick:Ne,uploadingFiles:ce,messageRole:P,truncateUserMessages:c,userMessagePreviewLength:d,isUserExpanded:D,setIsUserExpanded:B,isCompactLayout:z,iconForeground:Fe,interruptPart:Be,handleInterruptApprove:ft,handleInterruptReject:yt,handleInterruptAlternative:Tt,disableInterruptActions:W,isInterruptMessage:I}),ge=b.useMemo(()=>U?"Assistant":Tu(t),[U,t]),De=xt(),He=P==="user"&&(T??1)>1&&typeof k=="function",st=(A==null?void 0:A.length)??0,et=st>0&&S<st-1?A[S+1]:void 0,dt=st>0&&S>0?A[S-1]:void 0,mt=b.useCallback(()=>{!et||!k||k(et.id,void 0,!!et.isLatestAttempt)},[et,k]),J=b.useCallback(()=>{!dt||!k||k(dt.id,void 0,!!dt.isLatestAttempt)},[dt,k]);return K&&!f?null:Z&&U?u.jsx("div",{className:oe(ht(),p.container),children:u.jsxs("div",{className:oe(zt(),p.content),children:[u.jsxs("div",{className:"flex items-center gap-2 mb-2 pb-2 border-b border-current/10",children:[u.jsx(de.Bot,{className:oe("h-4 w-4",Fe)}),a&&u.jsx("span",{className:"font-medium text-sm",children:"Assistant"})]}),u.jsx(ir,{content:U.content,className:"text-current"})]})}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:oe(ht(),p.container),children:u.jsxs("div",{className:oe(zt(),p.content),children:[u.jsx(cf,{showTimestamp:i,showAgentName:a,isToolMessage:K,iconForeground:Fe,agentName:ge,messageIcon:De,customHeaderClass:p.header,customActionsClass:p.actions,isCompactLayout:z,showActions:s,isEditing:o,messageRole:P,toolViewMode:kt,toolExpandable:X,isInterruptMessage:I,toolMeta:lt,onToggleToolView:Oe,onCopy:nt,onEdit:pt,onRegenerate:At,showCheckpointControls:He,attemptCount:T,attemptIndex:S,handleOlderAttemptSelect:mt,handleNewerAttemptSelect:J,messageCreatedAt:t.createdAt,copied:j}),u.jsx("div",{className:"relative",children:Pt}),!(i||a||K)&&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",p.actions),children:[u.jsx(Xe,{variant:"ghost",size:"sm",onClick:()=>nt(),className:oe("h-6 w-6 p-0 hover:bg-background/50 text-current",z&&"h-5 w-5"),children:u.jsx(de.Copy,{className:oe(j?"text-success":"text-current",z?"h-3 w-3":"h-4 w-4")})}),P==="user"&&y&&u.jsx(Xe,{variant:"ghost",size:"sm",onClick:pt,className:oe("h-6 w-6 p-0 hover:bg-background/50 text-current",z&&"h-5 w-5"),children:u.jsx(de.Edit,{className:oe("text-current",z?"h-3 w-3":"h-4 w-4")})}),P==="assistant"&&w&&u.jsx(Xe,{variant:"ghost",size:"sm",onClick:At,className:oe("h-6 w-6 p-0 hover:bg-background/50 text-current",z&&"h-5 w-5"),children:u.jsx(de.RotateCcw,{className:oe("text-current",z?"h-3 w-3":"h-4 w-4")})})]})]})}),Re&&u.jsx(oy,{isOpen:ye,onClose:We,fileId:Re.id,fileName:Re.name,mimeType:Re.mimeType})]})},(e,t)=>{var l,c,d,f,m,p,v,g;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&Fi(e.message)===Fi(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateUserMessages","userMessagePreviewLength","showToolMessages","toolConfig"].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)===((f=t.customStyles)==null?void 0:f.content)&&((m=e.customStyles)==null?void 0:m.actions)===((p=t.customStyles)==null?void 0:p.actions)&&((v=e.customStyles)==null?void 0:v.header)===((g=t.customStyles)==null?void 0:g.header);if(!o||!s)return!1;const i=Bi(e.message),a=Bi(t.message);return i.length===a.length});ws.displayName="MessageComponent";const ys=0,Bn=1,Pr=2,hf=4;function mf(e){return()=>e}function Py(e){e()}function gf(e,t){return n=>e(t(n))}function xf(e,t){return()=>e(t)}function _y(e,t){return n=>e(t,n)}function ba(e){return e!==void 0}function Ry(...e){return()=>{e.map(Py)}}function _r(){}function Ss(e,t){return t(e),e}function My(e,t){return t(e)}function rt(...e){return e}function Je(e,t){return e(Bn,t)}function _e(e,t){e(ys,t)}function wa(e){e(Pr)}function wt(e){return e(hf)}function xe(e,t){return Je(e,_y(t,ys))}function dn(e,t){const n=e(Bn,r=>{n(),t(r)});return n}function vf(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function bf(e,t){return e===t}function ot(e=bf){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function ke(e){return t=>n=>{e(n)&&t(n)}}function fe(e){return t=>gf(t,e)}function bn(e){return t=>()=>{t(e)}}function ne(e,...t){const n=Oy(...t);return(r,o)=>{switch(r){case Pr:wa(e);return;case Bn:return Je(e,n(o))}}}function wn(e,t){return n=>r=>{n(t=e(t,r))}}function ar(e){return t=>n=>{e>0?e--:t(n)}}function Nn(e){let t=null,n;return r=>o=>{t=o,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function $e(...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);Je(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 Oy(...e){return t=>e.reduceRight(My,t)}function Dy(e){let t,n;const r=()=>t==null?void 0:t();return function(o,s){switch(o){case Bn:return s?n===s?void 0:(r(),n=s,t=Je(e,s),t):(r(),_r);case Pr:r(),n=null;return}}}function se(e){let t=e;const n=Ue();return(r,o)=>{switch(r){case ys:t=o;break;case Bn:{o(t);break}case hf:return t}return n(r,o)}}function Mt(e,t){return Ss(se(t),n=>xe(e,n))}function Ue(){const e=[];return(t,n)=>{switch(t){case ys:e.slice().forEach(r=>{r(n)});return;case Pr:e.splice(0,e.length);return;case Bn:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}}}function Zt(e){return Ss(Ue(),t=>xe(e,t))}function Ge(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:Ly(),singleton:n}}const Ly=()=>Symbol();function $y(e){const t=new Map,n=({constructor:r,dependencies:o,id:s,singleton:i})=>{if(i&&t.has(s))return t.get(s);const a=r(o.map(l=>n(l)));return i&&t.set(s,a),a};return n(e)}function Ct(...e){const t=Ue(),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);Je(s,l=>{n[i]=l,r=r|a,r===o&&_e(t,n)})}),function(s,i){switch(s){case Pr:{wa(t);return}case Bn:return r===o&&i(n),Je(t,i)}}}function Te(e,t=bf){return ne(e,ot(t))}function ya(...e){return function(t,n){switch(t){case Pr:return;case Bn:return Ry(...e.map(r=>Je(r,n)))}}}var qt=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(qt||{});const Fy={0:"debug",3:"error",1:"log",2:"warn"},By=()=>typeof globalThis>"u"?window:globalThis,zn=Ge(()=>{const e=se(3);return{log:se((t,n,r=1)=>{var o;const s=(o=By().VIRTUOSO_LOG_LEVEL)!=null?o:wt(e);r>=s&&console[Fy[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0});function lr(e,t,n){return Sa(e,t,n).callbackRef}function Sa(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 zy(e,t,n,r,o,s,i,a,l){const c=b.useCallback(d=>{const f=Hy(d.children,t,a?"offsetWidth":"offsetHeight",o);let m=d.parentElement;for(;!m.dataset.virtuosoScroller;)m=m.parentElement;const p=m.lastElementChild.dataset.viewportType==="window";let v;p&&(v=m.ownerDocument.defaultView);const g=i?a?i.scrollLeft:i.scrollTop:p?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:p?a?v.document.documentElement.scrollWidth:v.document.documentElement.scrollHeight:a?m.scrollWidth:m.scrollHeight,y=i?a?i.offsetWidth:i.offsetHeight:p?a?v.innerWidth:v.innerHeight:a?m.offsetWidth:m.offsetHeight;r({scrollHeight:x,scrollTop:Math.max(g,0),viewportHeight:y}),s==null||s(a?wf("column-gap",getComputedStyle(d).columnGap,o):wf("row-gap",getComputedStyle(d).rowGap,o)),f!==null&&e(f)},[e,t,o,s,i,r,a]);return Sa(c,n,l)}function Hy(e,t,n,r){const o=e.length;if(o===0)return null;const s=[];for(let i=0;i<o;i++){const a=e.item(i);if(a.dataset.index===void 0)continue;const 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},qt.ERROR),d===c)continue;const f=s[s.length-1];s.length===0||f.size!==d||f.endIndex!==l-1?s.push({endIndex:l,size:d,startIndex:l}):s[s.length-1].endIndex++}return s}function wf(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,qt.WARN),t==="normal"?0:parseInt(t??"0",10)}function yf(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 f,m;if(t){const p=t.getBoundingClientRect(),v=c.top-p.top;m=p.height-Math.max(0,v),f=v+t.scrollTop}else{const p=i.current.ownerDocument.defaultView;m=p.innerHeight-Math.max(0,c.top),f=c.top+p.scrollY}r.current={offsetTop:f,visibleHeight:m,visibleWidth:d},e(r.current)},[e,t]),{callbackRef:s,ref:i}=Sa(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 Ft=Ge(()=>{const e=Ue(),t=Ue(),n=se(0),r=Ue(),o=se(0),s=Ue(),i=Ue(),a=se(0),l=se(0),c=se(0),d=se(0),f=Ue(),m=Ue(),p=se(!1),v=se(!1),g=se(!1);return xe(ne(e,fe(({scrollTop:x})=>x)),t),xe(ne(e,fe(({scrollHeight:x})=>x)),i),xe(t,o),{deviation:n,fixedFooterHeight:c,fixedHeaderHeight:l,footerHeight:d,headerHeight:a,horizontalDirection:v,scrollBy:m,scrollContainerState:e,scrollHeight:i,scrollingInProgress:p,scrollTo:f,scrollTop:t,skipAnimationFrameInResizeObserver:g,smoothScrollTargetReached:r,statefulScrollTop:o,viewportHeight:s}},[],{singleton:!0}),uo={lvl:0};function Sf(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 Qe(e){return e===uo}function fo(e,t){if(!Qe(e))return t===e.k?e.v:t<e.k?fo(e.l,t):fo(e.r,t)}function fn(e,t,n="k"){if(Qe(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 Qt(e,t,n){return Qe(e)?kf(t,n,1):t===e.k?Nt(e,{k:t,v:n}):t<e.k?Ef(Nt(e,{l:Qt(e.l,t,n)})):Ef(Nt(e,{r:Qt(e.r,t,n)}))}function Rr(){return uo}function Cs(e,t,n){if(Qe(e))return[];const r=fn(e,t)[0];return Uy(Ta(e,r,n))}function Ca(e,t){if(Qe(e))return uo;const{k:n,l:r,r:o}=e;if(t===n){if(Qe(r))return o;if(Qe(o))return r;{const[s,i]=Tf(r);return Ts(Nt(e,{k:s,l:Cf(r),v:i}))}}else return t<n?Ts(Nt(e,{l:Ca(r,t)})):Ts(Nt(e,{r:Ca(o,t)}))}function cr(e){return Qe(e)?[]:[...cr(e.l),{k:e.k,v:e.v},...cr(e.r)]}function Ta(e,t,n){if(Qe(e))return[];const{k:r,l:o,r:s,v:i}=e;let a=[];return r>t&&(a=a.concat(Ta(o,t,n))),r>=t&&r<=n&&a.push({k:r,v:i}),r<=n&&(a=a.concat(Ta(s,t,n))),a}function Ts(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(ka(t))return If(Nt(e,{lvl:n-1}));if(!Qe(t)&&!Qe(t.r))return Nt(t.r,{l:Nt(t,{r:t.r.l}),lvl:n,r:Nt(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(ka(e))return Ea(Nt(e,{lvl:n-1}));if(!Qe(r)&&!Qe(r.l)){const o=r.l,s=ka(o)?r.lvl-1:r.lvl;return Nt(o,{l:Nt(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:Ea(Nt(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function Nt(e,t){return kf(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 Cf(e){return Qe(e.r)?e.l:Ts(Nt(e,{r:Cf(e.r)}))}function ka(e){return Qe(e)||e.lvl>e.r.lvl}function Tf(e){return Qe(e.r)?[e.k,e.v]:Tf(e.r)}function kf(e,t,n,r=uo,o=uo){return{k:e,l:r,lvl:n,r:o,v:t}}function Ef(e){return Ea(If(e))}function If(e){const{l:t}=e;return!Qe(t)&&t.lvl===e.lvl?Nt(t,{r:Nt(e,{l:t.r})}):e}function Ea(e){const{lvl:t,r:n}=e;return!Qe(n)&&!Qe(n.r)&&n.lvl===t&&n.r.lvl===t?Nt(n,{l:Nt(e,{r:n.l}),lvl:t+1}):e}function Uy(e){return Sf(e,({k:t,v:n})=>({index:t,value:n}))}function Nf(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function po(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const Ia=Ge(()=>({recalcInProgress:se(!1)}),[],{singleton:!0});function Af(e,t,n){return e[ks(e,t,n)]}function ks(e,t,n,r=0){let o=e.length-1;for(;r<=o;){const s=Math.floor((r+o)/2),i=e[s],a=n(i,t);if(a===0)return s;if(a===-1){if(o-r<2)return s-1;o=s-1}else{if(o===r)return s;r=s+1}}throw new Error(`Failed binary finding record in array - ${e.join(",")}, searched for ${t}`)}function Wy(e,t,n,r){const o=ks(e,t,r),s=ks(e,n,r,o);return e.slice(o,s+1)}function Hn(e,t){return Math.round(e.getBoundingClientRect()[t])}function Es(e){return!Qe(e.groupOffsetTree)}function Na({index:e},t){return t===e?0:t<e?-1:1}function Vy(){return{groupIndices:[],groupOffsetTree:Rr(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Rr()}}function Ky(e,t){let n=Qe(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),Qe(e)){e=Qt(e,0,s);continue}const a=Cs(e,i-1,o+1);if(a.some(Qy(r)))continue;let l=!1,c=!1;for(const{end:d,start:f,value:m}of a)l?(o>=f||s===m)&&(e=Ca(e,f)):(c=m!==s,l=!0),d>o&&o>=f&&m!==s&&(e=Qt(e,o+1,m));c&&(e=Qt(e,i,s))}return[e,n]}function qy(e){return typeof e.groupIndex<"u"}function Gy({offset:e},t){return t===e?0:t<e?-1:1}function ho(e,t,n){if(t.length===0)return 0;const{index:r,offset:o,size:s}=Af(t,e,Na),i=e-r,a=s*i+(i-1)*n+o;return a>0?a+n:a}function jf(e,t){if(!Es(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function Pf(e,t,n){if(qy(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=jf(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function Yy(e,t,n,r=0){return r>0&&(t=Math.max(t,Af(e,r,Na).offset)),Sf(Wy(e,t,n,Gy),Zy)}function Xy(e,[t,n,r,o]){t.length>0&&r("received item sizes",t,qt.DEBUG);const s=e.sizeTree;let i=s,a=0;if(n.length>0&&Qe(s)&&t.length===2){const m=t[0].size,p=t[1].size;i=n.reduce((v,g)=>Qt(Qt(v,g,m),g+1,p),i)}else[i,a]=Ky(i,t);if(i===s)return e;const{lastIndex:l,lastOffset:c,lastSize:d,offsetTree:f}=Aa(e.offsetTree,a,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((m,p)=>Qt(m,p,ho(p,f,o)),Rr()),lastIndex:l,lastOffset:c,lastSize:d,offsetTree:f,sizeTree:i}}function Jy(e){return cr(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 _f(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 Aa(e,t,n,r){let o=e,s=0,i=0,a=0,l=0;if(t!==0){l=ks(o,t-1,Na),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 Cs(n,t,1/0)){const f=c-s,m=f*i+a+f*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 Zy(e){return{index:e.index,value:e}}function Qy(e){const{endIndex:t,size:n,startIndex:r}=e;return o=>o.start===r&&(o.end===t||o.end===1/0)&&o.value===n}const e0={offsetHeight:"height",offsetWidth:"width"},yn=Ge(([{log:e},{recalcInProgress:t}])=>{const n=Ue(),r=Ue(),o=Mt(r,0),s=Ue(),i=Ue(),a=se(0),l=se([]),c=se(void 0),d=se(void 0),f=se((T,S)=>Hn(T,e0[S])),m=se(void 0),p=se(0),v=Vy(),g=Mt(ne(n,$e(l,e,p),wn(Xy,v),ot()),v),x=Mt(ne(l,ot(),wn((T,S)=>({current:S,prev:T.current}),{current:[],prev:[]}),fe(({prev:T})=>T)),[]);xe(ne(l,ke(T=>T.length>0),$e(g,p),fe(([T,S,k])=>{const A=T.reduce((j,F,D)=>Qt(j,F,ho(F,S.offsetTree,k)||D),Rr());return{...S,groupIndices:T,groupOffsetTree:A}})),g),xe(ne(r,$e(g),ke(([T,{lastIndex:S}])=>T<S),fe(([T,{lastIndex:S,lastSize:k}])=>[{endIndex:S,size:k,startIndex:T}])),n),xe(c,d);const y=Mt(ne(c,fe(T=>T===void 0)),!0);xe(ne(d,ke(T=>T!==void 0&&Qe(wt(g).sizeTree)),fe(T=>[{endIndex:0,size:T,startIndex:0}])),n);const w=Zt(ne(n,$e(g),wn(({sizes:T},[S,k])=>({changed:k!==T,sizes:k}),{changed:!1,sizes:v}),fe(T=>T.changed)));Je(ne(a,wn((T,S)=>({diff:T.prev-S,prev:S}),{diff:0,prev:0}),fe(T=>T.diff)),T=>{const{groupIndices:S}=wt(g);if(T>0)_e(t,!0),_e(s,T+_f(T,S));else if(T<0){const k=wt(x);k.length>0&&(T-=_f(-T,k)),_e(i,T)}}),Je(ne(a,$e(e)),([T,S])=>{T<0&&S("`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},qt.ERROR)});const C=Zt(s);xe(ne(s,$e(g),fe(([T,S])=>{const k=S.groupIndices.length>0,A=[],j=S.lastSize;if(k){const F=fo(S.sizeTree,0);let D=0,B=0;for(;D<T;){const M=S.groupIndices[B],W=S.groupIndices.length===B+1?1/0:S.groupIndices[B+1]-M-1;A.push({endIndex:M,size:F,startIndex:M}),A.push({endIndex:M+1+W-1,size:j,startIndex:M+1}),B++,D+=W+1}const G=cr(S.sizeTree);return D!==T&&G.shift(),G.reduce((M,{k:W,v:Y})=>{let z=M.ranges;return M.prevSize!==0&&(z=[...M.ranges,{endIndex:W+T-1,size:M.prevSize,startIndex:M.prevIndex}]),{prevIndex:W+T,prevSize:Y,ranges:z}},{prevIndex:T,prevSize:0,ranges:A}).ranges}return cr(S.sizeTree).reduce((F,{k:D,v:B})=>({prevIndex:D+T,prevSize:B,ranges:[...F.ranges,{endIndex:D+T-1,size:F.prevSize,startIndex:F.prevIndex}]}),{prevIndex:0,prevSize:j,ranges:[]}).ranges})),n);const E=Zt(ne(i,$e(g,p),fe(([T,{offsetTree:S},k])=>{const A=-T;return ho(A,S,k)})));return xe(ne(i,$e(g,p),fe(([T,S,k])=>{if(S.groupIndices.length>0){if(Qe(S.sizeTree))return S;let A=Rr();const j=wt(x);let F=0,D=0,B=0;for(;F<-T;){B=j[D];const G=j[D+1]-B-1;D++,F+=G+1}if(A=cr(S.sizeTree).reduce((G,{k:M,v:W})=>Qt(G,Math.max(0,M+T),W),A),F!==-T){const G=fo(S.sizeTree,B);A=Qt(A,0,G);const M=fn(S.sizeTree,-T+1)[1];A=Qt(A,1,M)}return{...S,sizeTree:A,...Aa(S.offsetTree,0,A,k)}}else{const A=cr(S.sizeTree).reduce((j,{k:F,v:D})=>Qt(j,Math.max(0,F+T),D),Rr());return{...S,sizeTree:A,...Aa(S.offsetTree,0,A,k)}}})),g),{beforeUnshiftWith:C,data:m,defaultItemSize:d,firstItemIndex:a,fixedItemSize:c,gap:p,groupIndices:l,itemSize:f,listRefresh:w,shiftWith:i,shiftWithOffset:E,sizeRanges:n,sizes:g,statefulTotalCount:o,totalCount:r,trackItemSizes:y,unshiftWith:s}},rt(zn,Ia),{singleton:!0});function t0(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const Rf=Ge(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=Ue(),i=Ue(),a=Zt(ne(s,fe(t0)));return xe(ne(a,fe(l=>l.totalCount)),n),xe(ne(a,fe(l=>l.groupIndices)),e),xe(ne(Ct(o,t,r),ke(([l,c])=>Es(c)),fe(([l,c,d])=>fn(c.groupOffsetTree,Math.max(l-d,0),"v")[0]),ot(),fe(l=>[l])),i),{groupCounts:s,topItemsIndexes:i}},rt(yn,Ft)),Un=Ge(([{log:e}])=>{const t=se(!1),n=Zt(ne(t,ke(r=>r),ot()));return Je(t,r=>{r&&wt(e)("props updated",{},qt.DEBUG)}),{didMount:n,propsReady:t}},rt(zn),{singleton:!0}),n0=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function Mf(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!n0)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const mo=Ge(([{gap:e,listRefresh:t,sizes:n,totalCount:r},{fixedFooterHeight:o,fixedHeaderHeight:s,footerHeight:i,headerHeight:a,scrollingInProgress:l,scrollTo:c,smoothScrollTargetReached:d,viewportHeight:f},{log:m}])=>{const p=Ue(),v=Ue(),g=se(0);let x=null,y=null,w=null;function C(){x&&(x(),x=null),w&&(w(),w=null),y&&(clearTimeout(y),y=null),_e(l,!1)}return xe(ne(p,$e(n,f,r,g,a,i,m),$e(e,s,o),fe(([[E,T,S,k,A,j,F,D],B,G,M])=>{const W=Mf(E),{align:Y,behavior:z,offset:P}=W,I=k-1,K=Pf(W,T,I);let te=ho(K,T.offsetTree,B)+j;Y==="end"?(te+=G+fn(T.sizeTree,K)[1]-S+M,K===I&&(te+=F)):Y==="center"?te+=(G+fn(T.sizeTree,K)[1]-S+M)/2:te-=A,P&&(te+=P);const O=q=>{C(),q?(D("retrying to scroll to",{location:E},qt.DEBUG),_e(p,E)):(_e(v,!0),D("list did not change, scroll successful",{},qt.DEBUG))};if(C(),z==="smooth"){let q=!1;w=Je(t,L=>{q=q||L}),x=dn(d,()=>{O(q)})}else x=dn(ne(t,r0(150)),O);return y=setTimeout(()=>{C()},1200),_e(l,!0),D("scrolling from index to",{behavior:z,index:K,top:te},qt.DEBUG),{behavior:z,top:te}})),c),{scrollTargetReached:v,scrollToIndex:p,topListHeight:g}},rt(yn,Ft,zn),{singleton:!0});function r0(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function ja(e,t){e==0?t():requestAnimationFrame(()=>{ja(e-1,t)})}function Pa(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const go=Ge(([{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 xe(ne(i,$e(l),ke(([d,f])=>!!f),bn(!1)),a),xe(ne(i,$e(l),ke(([d,f])=>!!f),bn(!1)),c),Je(ne(Ct(t,i),$e(a,n,e,c),ke(([[,d],f,{sizeTree:m},p,v])=>d&&(!Qe(m)||ba(p))&&!f&&!v),$e(l)),([,d])=>{dn(o,()=>{_e(c,!0)}),ja(4,()=>{dn(r,()=>{_e(a,!0)}),_e(s,d)})}),{initialItemFinalLocationReached:c,initialTopMostItemIndex:l,scrolledToInitialItem:a}},rt(yn,Ft,mo,Un),{singleton:!0});function Of(e,t){return Math.abs(e-t)<1.01}const xo="up",vo="down",o0="none",s0={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},i0=0,bo=Ge(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=se(!1),a=se(!0),l=Ue(),c=Ue(),d=se(4),f=se(i0),m=Mt(ne(ya(ne(Te(o),ar(1),bn(!0)),ne(Te(o),ar(1),bn(!1),vf(100))),ot()),!1),p=Mt(ne(ya(ne(n,bn(!0)),ne(n,bn(!1),vf(200))),ot()),!1);xe(ne(Ct(Te(o),Te(f)),fe(([w,C])=>w<=C),ot()),a),xe(ne(a,Nn(50)),c);const v=Zt(ne(Ct(r,Te(s),Te(t),Te(e),Te(d)),wn((w,[{scrollHeight:C,scrollTop:E},T,S,k,A])=>{const j=E+T-C>-A,F={scrollHeight:C,scrollTop:E,viewportHeight:T};if(j){let B,G;return E>w.state.scrollTop?(B="SCROLLED_DOWN",G=w.state.scrollTop-E):(B="SIZE_DECREASED",G=w.state.scrollTop-E||w.scrollTopDelta),{atBottom:!0,atBottomBecause:B,scrollTopDelta:G,state:F}}let D;return F.scrollHeight>w.state.scrollHeight?D="SIZE_INCREASED":T<w.state.viewportHeight?D="VIEWPORT_HEIGHT_DECREASING":E<w.state.scrollTop?D="SCROLLING_UPWARDS":D="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:D,state:F}},s0),ot((w,C)=>w&&w.atBottom===C.atBottom))),g=Mt(ne(r,wn((w,{scrollHeight:C,scrollTop:E,viewportHeight:T})=>{if(Of(w.scrollHeight,C))return{changed:!1,jump:0,scrollHeight:C,scrollTop:E};{const S=C-(E+T)<1;return w.scrollTop!==E&&S?{changed:!0,jump:w.scrollTop-E,scrollHeight:C,scrollTop:E}:{changed:!0,jump:0,scrollHeight:C,scrollTop:E}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),ke(w=>w.changed),fe(w=>w.jump)),0);xe(ne(v,fe(w=>w.atBottom)),i),xe(ne(i,Nn(50)),l);const x=se(vo);xe(ne(r,fe(({scrollTop:w})=>w),ot(),wn((w,C)=>wt(p)?{direction:w.direction,prevScrollTop:C}:{direction:C<w.prevScrollTop?xo:vo,prevScrollTop:C},{direction:vo,prevScrollTop:0}),fe(w=>w.direction)),x),xe(ne(r,Nn(50),bn(o0)),x);const y=se(0);return xe(ne(m,ke(w=>!w),bn(0)),y),xe(ne(o,Nn(100),$e(m),ke(([w,C])=>!!C),wn(([w,C],[E])=>[C,E],[0,0]),fe(([w,C])=>C-w)),y),{atBottomState:v,atBottomStateChange:l,atBottomThreshold:d,atTopStateChange:c,atTopThreshold:f,isAtBottom:i,isAtTop:a,isScrolling:m,lastJumpDueToItemResize:g,scrollDirection:x,scrollVelocity:y}},rt(Ft)),Is="top",Ns="bottom",Df="none";function Lf(e,t,n){return typeof e=="number"?n===xo&&t===Is||n===vo&&t===Ns?e:0:n===xo?t===Is?e.main:e.reverse:t===Ns?e.main:e.reverse}function $f(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const _a=Ge(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=Ue(),i=se(0),a=se(0),l=se(0),c=Mt(ne(Ct(Te(r),Te(o),Te(n),Te(s,po),Te(l),Te(i),Te(t),Te(e),Te(a)),fe(([d,f,m,[p,v],g,x,y,w,C])=>{const E=d-w,T=x+y,S=Math.max(m-E,0);let k=Df;const A=$f(C,Is),j=$f(C,Ns);return p-=w,p+=m+y,v+=m+y,v-=w,p>d+T-A&&(k=xo),v<d-S+f+j&&(k=vo),k!==Df?[Math.max(E-m-Lf(g,Is,k)-A,0),E-S-y+f+Lf(g,Ns,k)+j]:null}),ke(d=>d!=null),ot(po)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:l,topListHeight:i,visibleRange:c}},rt(Ft),{singleton:!0});function a0(e,t,n){if(Es(t)){const r=jf(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 Ra={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function As(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 f=n-i,m=a+f*l+(f-1)*r,p=c,v=m-d;return{bottom:d,firstItemIndex:s,items:Bf(e,o,s),offsetBottom:v,offsetTop:c,top:p,topItems:Bf(t,o,s),topListHeight:t.reduce((g,x)=>x.size+g,0),totalCount:n}}function Ff(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=Pa(t,a),c=Array.from({length:a}).map((d,f)=>({data:s[f+l],index:f+l,offset:0,size:0}));return As(c,[],a,o,n,r)}function Bf(e,t,n){if(e.length===0)return[];if(!Es(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=Cs(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 ur=Ge(([{data:e,firstItemIndex:t,gap:n,sizes:r,totalCount:o},s,{listBoundary:i,topListHeight:a,visibleRange:l},{initialTopMostItemIndex:c,scrolledToInitialItem:d},{topListHeight:f},m,{didMount:p},{recalcInProgress:v}])=>{const g=se([]),x=se(0),y=Ue();xe(s.topItemsIndexes,g);const w=Mt(ne(Ct(p,v,Te(l,po),Te(o),Te(r),Te(c),d,Te(g),Te(t),Te(n),e),ke(([S,k,,A,,,,,,,j])=>{const F=j&&j.length!==A;return S&&!k&&!F}),fe(([,,[S,k],A,j,F,D,B,G,M,W])=>{const Y=j,{offsetTree:z,sizeTree:P}=Y,I=wt(x);if(A===0)return{...Ra,totalCount:A};if(S===0&&k===0)return I===0?{...Ra,totalCount:A}:Ff(I,F,j,G,M,W||[]);if(Qe(P))return I>0?null:As(a0(Pa(F,A),Y,W),[],A,M,Y,G);const K=[];if(B.length>0){const $=B[0],X=B[B.length-1];let R=0;for(const _ of Cs(P,$,X)){const U=_.value,Z=Math.max(_.start,$),re=Math.min(_.end,X);for(let ce=Z;ce<=re;ce++)K.push({data:W==null?void 0:W[ce],index:ce,offset:R,size:U}),R+=U}}if(!D)return As([],K,A,M,Y,G);const te=B.length>0?B[B.length-1]+1:0,O=Yy(z,S,k,te);if(O.length===0)return null;const q=A-1,L=Ss([],$=>{for(const X of O){const R=X.value;let _=R.offset,U=X.start;const Z=R.size;if(R.offset<S){U+=Math.floor((S-R.offset+M)/(Z+M));const ce=U-X.start;_+=ce*Z+ce*M}U<te&&(_+=(te-U)*Z,U=te);const re=Math.min(X.end,q);for(let ce=U;ce<=re&&!(_>=k);ce++)$.push({data:W==null?void 0:W[ce],index:ce,offset:_,size:Z}),_+=Z+M}});return As(L,K,A,M,Y,G)}),ke(S=>S!==null),ot()),Ra);xe(ne(e,ke(ba),fe(S=>S==null?void 0:S.length)),o),xe(ne(w,fe(S=>S.topListHeight)),f),xe(f,a),xe(ne(w,fe(S=>[S.top,S.bottom])),i),xe(ne(w,fe(S=>S.items)),y);const C=Zt(ne(w,ke(({items:S})=>S.length>0),$e(o,e),ke(([{items:S},k])=>S[S.length-1].originalIndex===k-1),fe(([,S,k])=>[S-1,k]),ot(po),fe(([S])=>S))),E=Zt(ne(w,Nn(200),ke(({items:S,topItems:k})=>S.length>0&&S[0].originalIndex===k.length),fe(({items:S})=>S[0].index),ot())),T=Zt(ne(w,ke(({items:S})=>S.length>0),fe(({items:S})=>{let k=0,A=S.length-1;for(;S[k].type==="group"&&k<A;)k++;for(;S[A].type==="group"&&A>k;)A--;return{endIndex:S[A].index,startIndex:S[k].index}}),ot(Nf)));return{endReached:C,initialItemCount:x,itemsRendered:y,listState:w,rangeChanged:T,startReached:E,topItemsIndexes:g,...m}},rt(yn,Rf,_a,go,mo,bo,Un,Ia),{singleton:!0}),zf=Ge(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=Ue(),i=Mt(ne(Ct(n,e,r,t,o),fe(([a,l,c,d,f])=>a+l+c+d+f.offsetBottom+f.bottom)),0);return xe(Te(i),s),{totalListHeight:i,totalListHeightChanged:s}},rt(Ft,ur),{singleton:!0}),l0=Ge(([{viewportHeight:e},{totalListHeight:t}])=>{const n=se(!1),r=Mt(ne(Ct(n,e,t),ke(([o])=>o),fe(([,o,s])=>Math.max(0,o-s)),Nn(0),ot()),0);return{alignToBottom:n,paddingTopAddition:r}},rt(Ft,zf),{singleton:!0}),Hf=Ge(()=>({context:se(null)})),c0=({itemBottom:e,itemTop:t,locationParams:{align:n,behavior:r,...o},viewportBottom:s,viewportTop:i})=>t<i?{...o,align:n??"start",behavior:r}:e>s?{...o,align:n??"end",behavior:r}:null,Uf=Ge(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:s,scrollingInProgress:i,scrollTop:a,viewportHeight:l},{scrollToIndex:c}])=>{const d=Ue();return xe(ne(d,$e(t,l,n,s,o,r,a),$e(e),fe(([[f,m,p,v,g,x,y,w],C])=>{const{align:E,behavior:T,calculateViewLocation:S=c0,done:k,...A}=f,j=Pf(f,m,v-1),F=ho(j,m.offsetTree,C)+g+x,D=F+fn(m.sizeTree,j)[1],B=w+x,G=w+p-y,M=S({itemBottom:D,itemTop:F,locationParams:{align:E,behavior:T,...A},viewportBottom:G,viewportTop:B});return M?k&&dn(ne(i,ke(W=>!W),ar(wt(i)?1:2)),k):k&&k(),M}),ke(f=>f!==null)),c),{scrollIntoView:d}},rt(yn,Ft,mo,ur,zn),{singleton:!0});function Wf(e){return e?e==="smooth"?"smooth":"auto":!1}const u0=(e,t)=>typeof e=="function"?Wf(e(t)):t&&Wf(e),d0=Ge(([{listRefresh:e,totalCount:t,fixedItemSize:n,data:r},{atBottomState:o,isAtBottom:s},{scrollToIndex:i},{scrolledToInitialItem:a},{didMount:l,propsReady:c},{log:d},{scrollingInProgress:f},{context:m},{scrollIntoView:p}])=>{const v=se(!1),g=Ue();let x=null;function y(T){_e(i,{align:"end",behavior:T,index:"LAST"})}Je(ne(Ct(ne(Te(t),ar(1)),l),$e(Te(v),s,a,f),fe(([[T,S],k,A,j,F])=>{let D=S&&j,B="auto";return D&&(B=u0(k,A||F),D=D&&!!B),{followOutputBehavior:B,shouldFollow:D,totalCount:T}}),ke(({shouldFollow:T})=>T)),({followOutputBehavior:T,totalCount:S})=>{x&&(x(),x=null),wt(n)?requestAnimationFrame(()=>{wt(d)("following output to ",{totalCount:S},qt.DEBUG),y(T)}):x=dn(e,()=>{wt(d)("following output to ",{totalCount:S},qt.DEBUG),y(T),x=null})});function w(T){const S=dn(o,k=>{T&&!k.atBottom&&k.notAtBottomBecause==="SIZE_INCREASED"&&!x&&(wt(d)("scrolling to bottom due to increased size",{},qt.DEBUG),y("auto"))});setTimeout(S,100)}Je(ne(Ct(Te(v),t,c),ke(([T,,S])=>T&&S),wn(({value:T},[,S])=>({refreshed:T===S,value:S}),{refreshed:!1,value:0}),ke(({refreshed:T})=>T),$e(v,t)),([,T])=>{wt(a)&&w(T!==!1)}),Je(g,()=>{w(wt(v)!==!1)}),Je(Ct(Te(v),o),([T,S])=>{T&&!S.atBottom&&S.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&y("auto")});const C=se(null),E=Ue();return xe(ya(ne(Te(r),fe(T=>{var S;return(S=T==null?void 0:T.length)!=null?S:0})),ne(Te(t))),E),Je(ne(Ct(ne(E,ar(1)),l),$e(Te(C),a,f,m),fe(([[T,S],k,A,j,F])=>S&&A&&(k==null?void 0:k({context:F,totalCount:T,scrollingInProgress:j}))),ke(T=>!!T),Nn(0)),T=>{x&&(x(),x=null),wt(n)?requestAnimationFrame(()=>{wt(d)("scrolling into view",{}),_e(p,T)}):x=dn(e,()=>{wt(d)("scrolling into view",{}),_e(p,T),x=null})}),{autoscrollToBottom:g,followOutput:v,scrollIntoViewOnChange:C}},rt(yn,bo,mo,go,Un,zn,Ft,Hf,Uf)),f0=Ge(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(xe(ne(a,$e(s),ke(([,l])=>l!==0),$e(o,r,t,n,e),fe(([[,l],c,d,f,m,p=[]])=>Ff(l,c,d,f,m,p))),i),{}),rt(yn,go,ur,Un),{singleton:!0}),p0=Ge(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=se(0);return Je(ne(e,$e(r),ke(([,o])=>o!==0),fe(([,o])=>({top:o}))),o=>{dn(ne(n,ar(1),ke(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{_e(t,o)})})}),{initialScrollTop:r}},rt(Un,Ft,ur),{singleton:!0}),Vf=Ge(([{scrollVelocity:e}])=>{const t=se(!1),n=Ue(),r=se(!1);return xe(ne(e,$e(r,t,n),ke(([o,s])=>!!s),fe(([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),Je(ne(Ct(t,e,n),$e(r)),([[o,s,i],a])=>{o&&a&&a.change&&a.change(s,i)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},rt(bo),{singleton:!0}),Ma=Ge(([{scrollContainerState:e,scrollTo:t}])=>{const n=Ue(),r=Ue(),o=Ue(),s=se(!1),i=se(void 0);return xe(ne(Ct(n,r),fe(([{scrollHeight:a,scrollTop:l,viewportHeight:c},{offsetTop:d}])=>({scrollHeight:a,scrollTop:Math.max(0,l-d),viewportHeight:c}))),e),xe(ne(t,$e(r),fe(([a,{offsetTop:l}])=>({...a,top:a.top+l}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},rt(Ft)),h0=Ge(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:a,windowViewportRect:l}])=>{const c=Ue(),d=se(void 0),f=se(null),m=se(null);return xe(a,f),xe(l,m),Je(ne(c,$e(t,r,i,f,m,n)),([p,v,g,x,y,w,C])=>{const E=Jy(v.sizeTree);x&&y!==null&&w!==null&&(g=y.scrollTop-w.offsetTop),g-=C,p({ranges:E,scrollTop:g})}),xe(ne(d,ke(ba),fe(m0)),o),xe(ne(s,$e(d),ke(([,p])=>p!==void 0),ot(),fe(([,p])=>p.ranges)),e),{getState:c,restoreStateFrom:d}},rt(yn,Ft,go,Un,Ma));function m0(e){return{align:"start",index:0,offset:e.scrollTop}}const g0=Ge(([{topItemsIndexes:e}])=>{const t=se(0);return xe(ne(t,ke(n=>n>=0),fe(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},rt(ur));function Kf(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const x0=Kf(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),v0=Ge(([{deviation:e,scrollBy:t,scrollingInProgress:n,scrollTop:r},{isAtBottom:o,isScrolling:s,lastJumpDueToItemResize:i,scrollDirection:a},{listState:l},{beforeUnshiftWith:c,gap:d,shiftWithOffset:f,sizes:m},{log:p},{recalcInProgress:v}])=>{const g=Zt(ne(l,$e(i),wn(([,y,w,C],[{bottom:E,items:T,offsetBottom:S,totalCount:k},A])=>{const j=E+S;let F=0;return w===k&&y.length>0&&T.length>0&&(T[0].originalIndex===0&&y[0].originalIndex===0||(F=j-C,F!==0&&(F+=A))),[F,T,k,j]},[0,[],0,0]),ke(([y])=>y!==0),$e(r,a,n,o,p,v),ke(([,y,w,C,,,E])=>!E&&!C&&y!==0&&w===xo),fe(([[y],,,,,w])=>(w("Upward scrolling compensation",{amount:y},qt.DEBUG),y))));function x(y){y>0?(_e(t,{behavior:"auto",top:-y}),_e(e,0)):(_e(e,0),_e(t,{behavior:"auto",top:-y}))}return Je(ne(g,$e(e,s)),([y,w,C])=>{C&&x0()?_e(e,w-y):x(-y)}),Je(ne(Ct(Mt(s,!1),e,v),ke(([y,w,C])=>!y&&!C&&w!==0),fe(([y,w])=>w),Nn(1)),x),xe(ne(f,fe(y=>({top:-y}))),t),Je(ne(c,$e(m,d),fe(([y,{groupIndices:w,lastSize:C,sizeTree:E},T])=>{function S(k){return k*(C+T)}if(w.length===0)return S(y);{let k=0;const A=fo(E,0);let j=0,F=0;for(;j<y;){j++,k+=A;let D=w.length===F+1?1/0:w[F+1]-w[F]-1;j+D>y&&(k-=A,D=y-j+1),j+=D,k+=S(D),F++}return k}})),y=>{_e(e,y),requestAnimationFrame(()=>{_e(t,{top:y}),requestAnimationFrame(()=>{_e(e,0),_e(v,!1)})})}),{deviation:e}},rt(Ft,bo,ur,yn,zn,Ia)),b0=Ge(([e,t,n,r,o,s,i,a,l,c,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...l,...c,...d}),rt(_a,f0,Un,Vf,zf,p0,l0,Ma,Uf,zn,Hf)),qf=Ge(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:r,gap:o,groupIndices:s,itemSize:i,sizeRanges:a,sizes:l,statefulTotalCount:c,totalCount:d,trackItemSizes:f},{initialItemFinalLocationReached:m,initialTopMostItemIndex:p,scrolledToInitialItem:v},g,x,y,{listState:w,topItemsIndexes:C,...E},{scrollToIndex:T},S,{topItemCount:k},{groupCounts:A},j])=>(xe(E.rangeChanged,j.scrollSeekRangeChanged),xe(ne(j.windowViewportRect,fe(F=>F.visibleHeight)),g.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,gap:o,groupCounts:A,initialItemFinalLocationReached:m,initialTopMostItemIndex:p,scrolledToInitialItem:v,sizeRanges:a,topItemCount:k,topItemsIndexes:C,totalCount:d,...y,groupIndices:s,itemSize:i,listState:w,scrollToIndex:T,statefulTotalCount:c,trackItemSizes:f,...E,...j,...g,sizes:l,...x}),rt(yn,go,Ft,h0,d0,ur,mo,v0,g0,Rf,b0));function w0(e,t){const n={},r={};let o=0;const s=e.length;for(;o<s;)r[e[o]]=1,o+=1;for(const i in t)Object.hasOwn(r,i)||(n[i]=t[i]);return n}const js=typeof document<"u"?b.useLayoutEffect:b.useEffect;function Gf(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&&_e(x.propsReady,!1);for(const w of r){const C=x[t.required[w]];_e(C,y[w])}for(const w of o)if(w in y){const C=x[t.optional[w]];_e(C,y[w])}x.propsReady&&_e(x.propsReady,!0)}function c(x){return s.reduce((y,w)=>(y[w]=C=>{const E=x[t.methods[w]];_e(E,C)},y),{})}function d(x){return i.reduce((y,w)=>(y[w]=Dy(x[t.events[w]]),y),{})}const f=b.forwardRef((x,y)=>{const{children:w,...C}=x,[E]=b.useState(()=>Ss($y(e),k=>{l(k,C)})),[T]=b.useState(xf(d,E));js(()=>{for(const k of i)k in C&&Je(T[k],C[k]);return()=>{Object.values(T).map(wa)}},[C,T,E]),js(()=>{l(E,C)}),b.useImperativeHandle(y,mf(c(E)));const S=n;return u.jsx(a.Provider,{value:E,children:n?u.jsx(S,{...w0([...r,...o,...i],C),children:w}):w})}),m=x=>{const y=b.useContext(a);return b.useCallback(w=>{_e(y[x],w)},[y,x])},p=x=>{const y=b.useContext(a)[x],w=b.useCallback(C=>Je(y,C),[y]);return b.useSyncExternalStore(w,()=>wt(y),()=>wt(y))},v=x=>{const y=b.useContext(a)[x],[w,C]=b.useState(xf(wt,y));return js(()=>Je(y,E=>{E!==w&&C(mf(E))}),[y,w]),w},g=b.version.startsWith("18")?p:v;return{Component:f,useEmitter:(x,y)=>{const w=b.useContext(a)[x];js(()=>Je(w,y),[y,w])},useEmitterValue:g,usePublisher:m}}const Yf=b.createContext(void 0),Xf=b.createContext(void 0),Jf=typeof document<"u"?b.useLayoutEffect:b.useEffect;function Oa(e){return"self"in e}function y0(e){return"body"in e}function Zf(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 p,v,g;const x=m.target;if(y0(x)||Oa(x)){const w=Oa(x)?x:x.defaultView;g=s?w.scrollX:w.scrollY,p=s?w.document.documentElement.scrollWidth:w.document.documentElement.scrollHeight,v=s?w.innerWidth:w.innerHeight}else g=s?x.scrollLeft:x.scrollTop,p=s?x.scrollWidth:x.scrollHeight,v=s?x.offsetWidth:x.offsetHeight;const y=()=>{e({scrollHeight:p,scrollTop:Math.max(g,0),viewportHeight:v})};m.suppressFlushSync?y():Do.flushSync(y),a.current!==null&&(g===a.current||g<=0||g===p-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 p=i.current;if(!p||(s?"offsetWidth"in p&&p.offsetWidth===0:"offsetHeight"in p&&p.offsetHeight===0))return;const v=m.behavior==="smooth";let g,x,y;Oa(p)?(x=Math.max(Hn(p.document.documentElement,s?"width":"height"),s?p.document.documentElement.scrollWidth:p.document.documentElement.scrollHeight),g=s?p.innerWidth:p.innerHeight,y=s?window.scrollX:window.scrollY):(x=p[s?"scrollWidth":"scrollHeight"],g=Hn(p,s?"width":"height"),y=p[s?"scrollLeft":"scrollTop"]);const w=x-g;if(m.top=Math.ceil(Math.max(Math.min(w,m.top),0)),Of(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}),p.scrollTo(m)}function f(m){s&&(m={behavior:m.behavior,left:m.top}),i.current.scrollBy(m)}return{scrollByCallback:f,scrollerRef:i,scrollToCallback:d}}const Da="-webkit-sticky",Qf="sticky",La=Kf(()=>{if(typeof document>"u")return Qf;const e=document.createElement("div");return e.style.position=Da,e.style.position===Da?Da:Qf});function $a(e){return e}const S0=Ge(()=>{const e=se(a=>`Item ${a}`),t=se(a=>`Group ${a}`),n=se({}),r=se($a),o=se("div"),s=se(_r),i=(a,l=null)=>Mt(ne(n,fe(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")}}),C0=Ge(([e,t])=>({...e,...t}),rt(qf,S0)),T0=({height:e})=>u.jsx("div",{style:{height:e}}),k0={overflowAnchor:"none",position:La(),zIndex:1},ep={overflowAnchor:"none"},E0={...ep,display:"inline-block",height:"100%"},tp=b.memo(function({showTopList:e=!1}){const t=Ae("listState"),n=rn("sizeRanges"),r=Ae("useWindowScroll"),o=Ae("customScrollParent"),s=rn("windowScrollContainerState"),i=rn("scrollContainerState"),a=o||r?s:i,l=Ae("itemContent"),c=Ae("context"),d=Ae("groupContent"),f=Ae("trackItemSizes"),m=Ae("itemSize"),p=Ae("log"),v=rn("gap"),g=Ae("horizontalDirection"),{callbackRef:x}=zy(n,m,f,e?_r:a,p,v,o,g,Ae("skipAnimationFrameInResizeObserver")),[y,w]=b.useState(0);Fa("deviation",M=>{y!==M&&w(M)});const C=Ae("EmptyPlaceholder"),E=Ae("ScrollSeekPlaceholder")||T0,T=Ae("ListComponent"),S=Ae("ItemComponent"),k=Ae("GroupComponent"),A=Ae("computeItemKey"),j=Ae("isSeeking"),F=Ae("groupIndices").length>0,D=Ae("alignToBottom"),B=Ae("initialItemFinalLocationReached"),G=e?{}:{boxSizing:"border-box",...g?{display:"inline-block",height:"100%",marginLeft:y!==0?y:D?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:y!==0?y:D?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...B?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&C?u.jsx(C,{...Ot(C,c)}):u.jsx(T,{...Ot(T,c),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:x,style:G,children:(e?t.topItems:t.items).map(M=>{const W=M.originalIndex,Y=A(W+t.firstItemIndex,M.data,c);return j?b.createElement(E,{...Ot(E,c),height:M.size,index:M.index,key:Y,type:M.type||"item",...M.type==="group"?{}:{groupIndex:M.groupIndex}}):M.type==="group"?b.createElement(k,{...Ot(k,c),"data-index":W,"data-item-index":M.index,"data-known-size":M.size,key:Y,style:k0},d(M.index,c)):b.createElement(S,{...Ot(S,c),...j0(S,M.data),"data-index":W,"data-item-group-index":M.groupIndex,"data-item-index":M.index,"data-known-size":M.size,key:Y,style:g?E0:ep},F?l(M.index,M.groupIndex,M.data,c):l(M.index,M.data,c))})})}),I0={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},N0={outline:"none",overflowX:"auto",position:"relative"},Ps=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),A0={position:La(),top:0,width:"100%",zIndex:1};function Ot(e,t){if(typeof e!="string")return{context:t}}function j0(e,t){return{item:typeof e=="string"?void 0:t}}const P0=b.memo(function(){const e=Ae("HeaderComponent"),t=rn("headerHeight"),n=Ae("HeaderFooterTag"),r=lr(b.useMemo(()=>s=>{t(Hn(s,"height"))},[t]),!0,Ae("skipAnimationFrameInResizeObserver")),o=Ae("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Ot(e,o)})}):null}),_0=b.memo(function(){const e=Ae("FooterComponent"),t=rn("footerHeight"),n=Ae("HeaderFooterTag"),r=lr(b.useMemo(()=>s=>{t(Hn(s,"height"))},[t]),!0,Ae("skipAnimationFrameInResizeObserver")),o=Ae("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Ot(e,o)})}):null});function np({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"),f=t("horizontalDirection")||!1,{scrollByCallback:m,scrollerRef:p,scrollToCallback:v}=Zf(a,c,l,d,void 0,f);return e("scrollTo",v),e("scrollBy",m),u.jsx(l,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:p,style:{...f?N0:I0,...o},tabIndex:0,...i,...Ot(l,s),children:r})})}function rp({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"),f=t("deviation"),m=t("customScrollParent"),p=b.useRef(null),v=t("scrollerRef"),{scrollByCallback:g,scrollerRef:x,scrollToCallback:y}=Zf(a,c,l,v,m);return Jf(()=>{var w;return x.current=m||((w=p.current)==null?void 0:w.ownerDocument.defaultView),()=>{x.current=null}},[x,m]),e("windowScrollTo",y),e("scrollBy",g),u.jsx(l,{ref:p,"data-virtuoso-scroller":!0,style:{position:"relative",...o,...d!==0?{height:d+f}:{}},...i,...Ot(l,s),children:r})})}const R0=({children:e})=>{const t=b.useContext(Yf),n=rn("viewportHeight"),r=rn("fixedItemHeight"),o=Ae("alignToBottom"),s=Ae("horizontalDirection"),i=b.useMemo(()=>gf(n,l=>Hn(l,s?"width":"height")),[n,s]),a=lr(i,!0,Ae("skipAnimationFrameInResizeObserver"));return b.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),u.jsx("div",{"data-viewport-type":"element",ref:a,style:Ps(o),children:e})},M0=({children:e})=>{const t=b.useContext(Yf),n=rn("windowViewportRect"),r=rn("fixedItemHeight"),o=Ae("customScrollParent"),s=yf(n,o,Ae("skipAnimationFrameInResizeObserver")),i=Ae("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:Ps(i),children:e})},O0=({children:e})=>{const t=Ae("TopItemListComponent")||"div",n=Ae("headerHeight"),r={...A0,marginTop:`${n}px`},o=Ae("context");return u.jsx(t,{style:r,...Ot(t,o),children:e})},D0=b.memo(function(e){const t=Ae("useWindowScroll"),n=Ae("topItemsIndexes").length>0,r=Ae("customScrollParent"),o=Ae("context");return u.jsxs(r||t?F0:$0,{...e,context:o,children:[n&&u.jsx(O0,{children:u.jsx(tp,{showTopList:!0})}),u.jsxs(r||t?M0:R0,{children:[u.jsx(P0,{}),u.jsx(tp,{}),u.jsx(_0,{})]})]})}),{Component:L0,useEmitter:Fa,useEmitterValue:Ae,usePublisher:rn}=Gf(C0,{required:{},optional:{restoreStateFrom:"restoreStateFrom",context:"context",followOutput:"followOutput",scrollIntoViewOnChange:"scrollIntoViewOnChange",itemContent:"itemContent",groupContent:"groupContent",overscan:"overscan",increaseViewportBy:"increaseViewportBy",totalCount:"totalCount",groupCounts:"groupCounts",topItemCount:"topItemCount",firstItemIndex:"firstItemIndex",initialTopMostItemIndex:"initialTopMostItemIndex",components:"components",atBottomThreshold:"atBottomThreshold",atTopThreshold:"atTopThreshold",computeItemKey:"computeItemKey",defaultItemHeight:"defaultItemHeight",fixedItemHeight:"fixedItemHeight",itemSize:"itemSize",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"HeaderFooterTag",data:"data",initialItemCount:"initialItemCount",initialScrollTop:"initialScrollTop",alignToBottom:"alignToBottom",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",horizontalDirection:"horizontalDirection",skipAnimationFrameInResizeObserver:"skipAnimationFrameInResizeObserver"},methods:{scrollToIndex:"scrollToIndex",scrollIntoView:"scrollIntoView",scrollTo:"scrollTo",scrollBy:"scrollBy",autoscrollToBottom:"autoscrollToBottom",getState:"getState"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",totalListHeightChanged:"totalListHeightChanged",itemsRendered:"itemsRendered",groupIndices:"groupIndices"}},D0),$0=np({useEmitter:Fa,useEmitterValue:Ae,usePublisher:rn}),F0=rp({useEmitter:Fa,useEmitterValue:Ae,usePublisher:rn}),B0=L0;rt(qf,Ge(()=>{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($a),a=se(_r),l=(c,d=null)=>Mt(ne(s,fe(f=>f[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")}})),La();const op={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},z0={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:sp,floor:_s,max:wo,min:Ba,round:ip}=Math;function ap(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function H0(e){return{...z0,items:e}}function Rs(e,t){return e&&e.width===t.width&&e.height===t.height}function U0(e,t){return e&&e.column===t.column&&e.row===t.row}const W0=Ge(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:r},{footerHeight:o,headerHeight:s,scrollBy:i,scrollContainerState:a,scrollTo:l,scrollTop:c,smoothScrollTargetReached:d,viewportHeight:f},m,p,{didMount:v,propsReady:g},{customScrollParent:x,useWindowScroll:y,windowScrollContainerState:w,windowScrollTo:C,windowViewportRect:E},T])=>{const S=se(0),k=se(0),A=se(op),j=se({height:0,width:0}),F=se({height:0,width:0}),D=Ue(),B=Ue(),G=se(0),M=se(null),W=se({column:0,row:0}),Y=Ue(),z=Ue(),P=se(!1),I=se(0),K=se(!0),te=se(!1),O=se(!1);Je(ne(v,$e(I),ke(([_,U])=>!!U)),()=>{_e(K,!1)}),Je(ne(Ct(v,K,F,j,I,te),ke(([_,U,Z,re,,ce])=>_&&!U&&Z.height!==0&&re.height!==0&&!ce)),([,,,,_])=>{_e(te,!0),ja(1,()=>{_e(D,_)}),dn(ne(c),()=>{_e(t,[0,0]),_e(K,!0)})}),xe(ne(z,ke(_=>_!=null&&_.scrollTop>0),bn(0)),k),Je(ne(v,$e(z),ke(([,_])=>_!=null)),([,_])=>{_&&(_e(j,_.viewport),_e(F,_.item),_e(W,_.gap),_.scrollTop>0&&(_e(P,!0),dn(ne(c,ar(1)),U=>{_e(P,!1)}),_e(l,{top:_.scrollTop})))}),xe(ne(j,fe(({height:_})=>_)),f),xe(ne(Ct(Te(j,Rs),Te(F,Rs),Te(W,(_,U)=>_&&_.column===U.column&&_.row===U.row),Te(c)),fe(([_,U,Z,re])=>({gap:Z,item:U,scrollTop:re,viewport:_}))),Y),xe(ne(Ct(Te(S),r,Te(W,U0),Te(F,Rs),Te(j,Rs),Te(M),Te(k),Te(P),Te(K),Te(I)),ke(([,,,,,,,_])=>!_),fe(([_,[U,Z],re,ce,Ne,ye,Re,,We,Fe])=>{const{column:Ye,row:Ve}=re,{height:tt,width:gt}=ce,{width:at}=Ne;if(Re===0&&(_===0||at===0))return op;if(gt===0){const ft=Pa(Fe,_),yt=ft+Math.max(Re-1,0);return H0(ap(ft,yt,ye))}const lt=lp(at,gt,Ye);let Me,Ke;We?U===0&&Z===0&&Re>0?(Me=0,Ke=Re-1):(Me=lt*_s((U+Ve)/(tt+Ve)),Ke=lt*sp((Z+Ve)/(tt+Ve))-1,Ke=Ba(_-1,wo(Ke,lt-1)),Me=Ba(Ke,wo(0,Me))):(Me=0,Ke=-1);const je=ap(Me,Ke,ye),{bottom:qe,top:Be}=cp(Ne,re,ce,je),nt=sp(_/lt),ct=nt*tt+(nt-1)*Ve-qe;return{bottom:qe,itemHeight:tt,items:je,itemWidth:gt,offsetBottom:ct,offsetTop:Be,top:Be}})),A),xe(ne(M,ke(_=>_!==null),fe(_=>_.length)),S),xe(ne(Ct(j,F,A,W),ke(([_,U,{items:Z}])=>Z.length>0&&U.height!==0&&_.height!==0),fe(([_,U,{items:Z},re])=>{const{bottom:ce,top:Ne}=cp(_,re,U,Z);return[Ne,ce]}),ot(po)),t);const q=se(!1);xe(ne(c,$e(q),fe(([_,U])=>U||_!==0)),q);const L=Zt(ne(Ct(A,S),ke(([{items:_}])=>_.length>0),$e(q),ke(([[_,U],Z])=>{const re=_.items[_.items.length-1].index===U-1;return(Z||_.bottom>0&&_.itemHeight>0&&_.offsetBottom===0&&_.items.length===U)&&re}),fe(([[,_]])=>_-1),ot())),$=Zt(ne(Te(A),ke(({items:_})=>_.length>0&&_[0].index===0),bn(0),ot())),X=Zt(ne(Te(A),$e(P),ke(([{items:_},U])=>_.length>0&&!U),fe(([{items:_}])=>({endIndex:_[_.length-1].index,startIndex:_[0].index})),ot(Nf),Nn(0)));xe(X,p.scrollSeekRangeChanged),xe(ne(D,$e(j,F,S,W),fe(([_,U,Z,re,ce])=>{const Ne=Mf(_),{align:ye,behavior:Re,offset:We}=Ne;let Fe=Ne.index;Fe==="LAST"&&(Fe=re-1),Fe=wo(0,Fe,Ba(re-1,Fe));let Ye=za(U,ce,Z,Fe);return ye==="end"?Ye=ip(Ye-U.height+Z.height):ye==="center"&&(Ye=ip(Ye-U.height/2+Z.height/2)),We&&(Ye+=We),{behavior:Re,top:Ye}})),l);const R=Mt(ne(A,fe(_=>_.offsetBottom+_.bottom)),0);return xe(ne(E,fe(_=>({height:_.visibleHeight,width:_.visibleWidth}))),j),{customScrollParent:x,data:M,deviation:G,footerHeight:o,gap:W,headerHeight:s,increaseViewportBy:e,initialItemCount:k,itemDimensions:F,overscan:n,restoreStateFrom:z,scrollBy:i,scrollContainerState:a,scrollHeight:B,scrollTo:l,scrollToIndex:D,scrollTop:c,smoothScrollTargetReached:d,totalCount:S,useWindowScroll:y,viewportDimensions:j,windowScrollContainerState:w,windowScrollTo:C,windowViewportRect:E,...p,gridState:A,horizontalDirection:O,initialTopMostItemIndex:I,totalListHeight:R,...m,endReached:L,propsReady:g,rangeChanged:X,startReached:$,stateChanged:Y,stateRestoreInProgress:P,...T}},rt(_a,Ft,bo,Vf,Un,Ma,zn));function lp(e,t,n){return wo(1,_s((e+n)/(_s(t)+n)))}function cp(e,t,n,r){const{height:o}=n;if(o===void 0||r.length===0)return{bottom:0,top:0};const s=za(e,t,n,r[0].index);return{bottom:za(e,t,n,r[r.length-1].index)+o,top:s}}function za(e,t,n,r){const o=lp(e.width,n.width,t.column),s=_s(r/o),i=s*n.height+wo(0,s-1)*t.row;return i>0?i+t.row:i}const V0=Ge(()=>{const e=se(f=>`Item ${f}`),t=se({}),n=se(null),r=se("virtuoso-grid-item"),o=se("virtuoso-grid-list"),s=se($a),i=se("div"),a=se(_r),l=(f,m=null)=>Mt(ne(t,fe(p=>p[f]),ot()),m),c=se(!1),d=se(!1);return xe(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")}}),K0=Ge(([e,t])=>({...e,...t}),rt(W0,V0)),q0=b.memo(function(){const e=it("gridState"),t=it("listClassName"),n=it("itemClassName"),r=it("itemContent"),o=it("computeItemKey"),s=it("isSeeking"),i=on("scrollHeight"),a=it("ItemComponent"),l=it("ListComponent"),c=it("ScrollSeekPlaceholder"),d=it("context"),f=on("itemDimensions"),m=on("gap"),p=it("log"),v=it("stateRestoreInProgress"),g=on("reportReadyState"),x=lr(b.useMemo(()=>y=>{const w=y.parentElement.parentElement.scrollHeight;i(w);const C=y.firstChild;if(C){const{height:E,width:T}=C.getBoundingClientRect();f({height:E,width:T})}m({column:dp("column-gap",getComputedStyle(y).columnGap,p),row:dp("row-gap",getComputedStyle(y).rowGap,p)})},[i,f,m,p]),!0,!1);return Jf(()=>{e.itemHeight>0&&e.itemWidth>0&&g(!0)},[e]),v?null:u.jsx(l,{className:t,ref:x,...Ot(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,{...Ot(c,d),height:e.itemHeight,index:y.index,width:e.itemWidth},w):b.createElement(a,{...Ot(a,d),className:n,"data-index":y.index,key:w},r(y.index,y.data,d))})})}),G0=b.memo(function(){const e=it("HeaderComponent"),t=on("headerHeight"),n=it("headerFooterTag"),r=lr(b.useMemo(()=>s=>{t(Hn(s,"height"))},[t]),!0,!1),o=it("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Ot(e,o)})}):null}),Y0=b.memo(function(){const e=it("FooterComponent"),t=on("footerHeight"),n=it("headerFooterTag"),r=lr(b.useMemo(()=>s=>{t(Hn(s,"height"))},[t]),!0,!1),o=it("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Ot(e,o)})}):null}),X0=({children:e})=>{const t=b.useContext(Xf),n=on("itemDimensions"),r=on("viewportDimensions"),o=lr(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:Ps(!1),children:e})},J0=({children:e})=>{const t=b.useContext(Xf),n=on("windowViewportRect"),r=on("itemDimensions"),o=it("customScrollParent"),s=yf(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:Ps(!1),children:e})},Z0=b.memo(function({...e}){const t=it("useWindowScroll"),n=it("customScrollParent"),r=n||t?eS:Q0,o=n||t?J0:X0,s=it("context");return u.jsx(r,{...e,...Ot(r,s),children:u.jsxs(o,{children:[u.jsx(G0,{}),u.jsx(q0,{}),u.jsx(Y0,{})]})})}),{useEmitter:up,useEmitterValue:it,usePublisher:on}=Gf(K0,{optional:{context:"context",totalCount:"totalCount",overscan:"overscan",itemContent:"itemContent",components:"components",computeItemKey:"computeItemKey",data:"data",initialItemCount:"initialItemCount",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"headerFooterTag",listClassName:"listClassName",itemClassName:"itemClassName",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",restoreStateFrom:"restoreStateFrom",initialTopMostItemIndex:"initialTopMostItemIndex",increaseViewportBy:"increaseViewportBy"},methods:{scrollTo:"scrollTo",scrollBy:"scrollBy",scrollToIndex:"scrollToIndex"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",stateChanged:"stateChanged",readyStateChanged:"readyStateChanged"}},Z0),Q0=np({useEmitter:up,useEmitterValue:it,usePublisher:on}),eS=rp({useEmitter:up,useEmitterValue:it,usePublisher:on});function dp(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,qt.WARN),t==="normal"?0:parseInt(t??"0",10)}const tS={checkpoints:[],checkpointMetaByCheckpointId:new Map,timeline:[],messagePreviews:new Map,getLatest:()=>{},getCheckpoint:()=>{},getMessageAttempts:()=>[]},Ha=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,Ua=b.memo(function({message:t,index:n,isStreaming:r,streamingAssistantId:o,streamingDebounceMs:s=0,layoutSize:i,enableMessageEditing:a,editingMessageId:l,onEdit:c,onRegenerate:d,onCancelEdit:f,showToolMessages:m,checkpointIndex:p,onSelectCheckpoint:v,getMessageCustomStyles:g,getInterruptOptions:x,toolConfig:y}){const w=Ha(t,n),C=t.role==="default_message",S=!!t.__syntheticStreaming||o===t.id&&t.role==="assistant",k=p??tS,A=!C&&"checkpointId"in t?t.checkpointId??null:null,{attemptCount:j,attemptIndex:F,attempts:D}=b.useMemo(()=>uc(t.id,A,k),[t.id,A,k]),B=g==null?void 0:g(t);return u.jsx("div",{className:"relative mb-4 last:mb-0","data-message-id":w,style:{minHeight:"60px",containIntrinsicSize:"auto 120px"},children:u.jsx(ws,{message:t,messageIndex:n,isStreamingMessage:S,renderStreamingMarkdown:S,streamingDebounceMs:s,isEditing:l===t.id,showActions:a,showTimestamp:!1,showAgentName:!0,layoutSize:i,onEdit:c,onRegenerate:()=>d(n),onCancelEdit:f,getInterruptOptions:x,showToolMessages:m,attemptCount:j,attemptIndex:F,attemptMetas:D,onSelectCheckpoint:v,customStyles:B,toolConfig:y})})});Ua.displayName="MessageRow";const Wa=b.forwardRef(({messages:e,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r=0,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onStartReached:a,onEdit:l,onRegenerate:c,onCancelEdit:d,className:f,style:m,emptyMessage:p,followNewMessages:v=!0,isNavigatingCheckpoint:g=!1,onScrollAway:x,onAtBottom:y,showToolMessages:w=!0,toolConfig:C,checkpointIndex:E,activeCheckpointId:T,onSelectCheckpoint:S,createSyntheticThinkingMessage:k=!0,forceSyntheticThinking:A=!1,getMessageCustomStyles:j,getInterruptOptions:F},D)=>{const B=b.useRef(null),G=b.useRef(null),M=b.useRef(!1),W=b.useRef(!1),Y=e,z=b.useMemo(()=>{const R=n&&Y.some(U=>U.id===n);return k&&(t||A)&&!R&&Y.length>0?[...Y,{id:"thinking-assistant",role:"assistant",content:[{type:"text",text:""}],createdAt:new Date().toISOString(),__syntheticStreaming:!0}]:Y},[Y,t,n,k,A]),P=b.useMemo(()=>w?z:z.filter(R=>(R==null?void 0:R.role)!=="tool"),[z,w]),I=b.useCallback(R=>{x&&x(!R),y&&y(R)},[x,y]),K=b.useMemo(()=>{if(a)return async()=>{if(!M.current){M.current=!0;try{await a()}finally{M.current=!1}}}},[a]),te=b.useMemo(()=>!v||g?!1:"auto",[v,g]),O=b.useMemo(()=>{if(typeof p!="string")return null;const R=p.trim();return!R||P&&P.length>0?null:{id:"default-message",role:"default_message",content:R,createdAt:new Date().toISOString()}},[p,P]),q=["flex h-full flex-col md:flex-row",f].filter(Boolean).join(" "),L=()=>{if(O){const R=j==null?void 0:j(O);return u.jsx("div",{className:"p-6 h-full overflow-y-auto",children:u.jsx("div",{className:"w-full max-w-full",children:u.jsx(ws,{message:O,messageIndex:0,isStreamingMessage:!1,showActions:!1,showTimestamp:!1,showAgentName:!0,layoutSize:o,onEdit:()=>{},onRegenerate:()=>{},onCancelEdit:()=>{},customStyles:R,getInterruptOptions:F})})})}return u.jsx("div",{className:"flex h-full items-center justify-center py-8 text-center text-muted-foreground",children:p??"No messages yet. Start a conversation!"})},$=P.length,X=$>0;return b.useEffect(()=>{var R,_;if($===0){W.current=!1;return}if(!W.current)if(W.current=!0,B.current&&P.length>0){const U=P.length-1;(_=(R=B.current).scrollToIndex)==null||_.call(R,{index:U,align:"end",behavior:"auto"})}else G.current&&(G.current.scrollTop=G.current.scrollHeight)},[$,P.length]),b.useImperativeHandle(D,()=>({scrollToLatest:()=>{var R,_;if(B.current&&P.length>0){const U=P.length-1;(_=(R=B.current).scrollToIndex)==null||_.call(R,{index:U,align:"end",behavior:"auto"})}else G.current&&(G.current.scrollTop=G.current.scrollHeight)},scrollToTop:()=>{var R,_;B.current&&P.length>0?(_=(R=B.current).scrollToIndex)==null||_.call(R,{index:0,align:"start",behavior:"auto"}):G.current&&(G.current.scrollTop=0)}}),[P]),u.jsx("div",{className:q,style:m,children:u.jsx("div",{className:"relative flex-1 min-h-0",children:X?u.jsx(B0,{ref:R=>{B.current=R},scrollerRef:R=>{G.current=R instanceof HTMLDivElement?R:null},data:P,followOutput:te,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,startReached:()=>{K&&K()},atBottomStateChange:I,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(R,_)=>Ha(_,R),itemContent:(R,_)=>u.jsx(Ua,{message:_,index:R,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onEdit:l,onRegenerate:c,onCancelEdit:d,showToolMessages:w,toolConfig:C,checkpointIndex:E,activeCheckpointId:T,onSelectCheckpoint:S,getMessageCustomStyles:j,getInterruptOptions:F})}):L()})})});Wa.displayName="MessageList";function fp({message:e,viewMode:t,isStreaming:n=!1,toolConfig:r,expandable:o=!1}){var F;const s=Yo(e),i=e.artifact??null,a=pf(e),c=(a?Au(a):null)??a,d=e.content.find(D=>D.type!=="tool_call"),f=D=>{if(D==null)return null;const B=typeof D=="string"?er(D)??D:D;if(B&&typeof B=="object")return u.jsx(vs,{data:B});const G=typeof B=="string"?B:(()=>{try{return tr(B)}catch{return String(B??"")}})();return u.jsx("pre",{className:"whitespace-pre-wrap break-words font-sans text-sm text-foreground/90",children:G})},m=D=>{if(D==null)return null;const{content:B,isMarkdown:G}=yu(D);return G?u.jsx(ir,{content:B,className:"text-current"}):f(D)},p=D=>u.jsxs("div",{className:"space-y-2 rounded-2xl border border-muted-foreground/30 bg-white/80 p-4 shadow-sm shadow-slate-900/10",children:[u.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-[0.4em] text-muted-foreground",children:"Structured dictionary"}),u.jsx(vs,{data:D})]}),v=()=>{if((c==null?void 0:c.kind)==="generic")return m(c.value);if(!d)return null;if(d.type==="text"){const M=(d.text??"").trim();if(!M)return null;const W=nr(M);return m(W)}const D=Sr(d),B=nr(D);return m(B)},g=()=>(c==null?void 0:c.kind)==="dict"?p(c.data):v(),x=()=>{if(!y)return;if(s.name){const B=y[s.name];if(B)return B}const D=(c==null?void 0:c.kind)??(a==null?void 0:a.kind);if(D){const B=y[D];if(B)return B}return y.default},{toolRenderers:y,toolArtifactRenderers:w}=r??{},C=x(),E=g(),T=!o||t==="expanded",S=(T?C==null?void 0:C({message:e,toolMeta:s,toolPayload:c,viewMode:t,isStreaming:n}):null)??null,A=((F=(()=>{if(!w)return;const D=i==null?void 0:i.type;if(typeof D=="string"){const B=w[D];if(B)return B}return w.default})())==null?void 0:F({artifact:i,message:e,toolPayload:c,isStreaming:n}))??null,j=S??E;return u.jsxs("div",{className:"space-y-2",children:[i&&(A??u.jsx(tf,{artifact:i,idx:0})),u.jsx(nf,{message:e,isStreaming:n}),T?j:null]})}function Ms(e){const t=e+"CollectionProvider",[n,r]=nn(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=g=>{const{scope:x,children:y}=g,w=b.useRef(null),C=b.useRef(new Map).current;return u.jsx(o,{scope:x,itemMap:C,collectionRef:w,children:y})};i.displayName=t;const a=e+"CollectionSlot",l=Jt.createSlot(a),c=b.forwardRef((g,x)=>{const{scope:y,children:w}=g,C=s(a,y),E=Le(x,C.collectionRef);return u.jsx(l,{ref:E,children:w})});c.displayName=a;const d=e+"CollectionItemSlot",f="data-radix-collection-item",m=Jt.createSlot(d),p=b.forwardRef((g,x)=>{const{scope:y,children:w,...C}=g,E=b.useRef(null),T=Le(x,E),S=s(d,y);return b.useEffect(()=>(S.itemMap.set(E,{ref:E,...C}),()=>void S.itemMap.delete(E))),u.jsx(m,{[f]:"",ref:T,children:w})});p.displayName=d;function v(g){const x=s(e+"CollectionConsumer",g);return b.useCallback(()=>{const w=x.collectionRef.current;if(!w)return[];const C=Array.from(w.querySelectorAll(`[${f}]`));return Array.from(x.itemMap.values()).sort((S,k)=>C.indexOf(S.ref.current)-C.indexOf(k.ref.current))},[x.collectionRef,x.itemMap])}return[{Provider:i,Slot:c,ItemSlot:p},v,r]}var nS=h.createContext(void 0);function Os(e){const t=h.useContext(nS);return e||t||"ltr"}const rS=["top","right","bottom","left"],Wn=Math.min,en=Math.max,Ds=Math.round,Ls=Math.floor,Sn=e=>({x:e,y:e}),oS={left:"right",right:"left",bottom:"top",top:"bottom"},sS={start:"end",end:"start"};function Va(e,t,n){return en(e,Wn(t,n))}function An(e,t){return typeof e=="function"?e(t):e}function jn(e){return e.split("-")[0]}function Mr(e){return e.split("-")[1]}function Ka(e){return e==="x"?"y":"x"}function qa(e){return e==="y"?"height":"width"}const iS=new Set(["top","bottom"]);function Cn(e){return iS.has(jn(e))?"y":"x"}function Ga(e){return Ka(Cn(e))}function aS(e,t,n){n===void 0&&(n=!1);const r=Mr(e),o=Ga(e),s=qa(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=$s(i)),[i,$s(i)]}function lS(e){const t=$s(e);return[Ya(e),t,Ya(t)]}function Ya(e){return e.replace(/start|end/g,t=>sS[t])}const pp=["left","right"],hp=["right","left"],cS=["top","bottom"],uS=["bottom","top"];function dS(e,t,n){switch(e){case"top":case"bottom":return n?t?hp:pp:t?pp:hp;case"left":case"right":return t?cS:uS;default:return[]}}function fS(e,t,n,r){const o=Mr(e);let s=dS(jn(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(Ya)))),s}function $s(e){return e.replace(/left|right|bottom|top/g,t=>oS[t])}function pS(e){return{top:0,right:0,bottom:0,left:0,...e}}function mp(e){return typeof e!="number"?pS(e):{top:e,right:e,bottom:e,left:e}}function Fs(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 gp(e,t,n){let{reference:r,floating:o}=e;const s=Cn(t),i=Ga(t),a=qa(i),l=jn(t),c=s==="y",d=r.x+r.width/2-o.width/2,f=r.y+r.height/2-o.height/2,m=r[a]/2-o[a]/2;let p;switch(l){case"top":p={x:d,y:r.y-o.height};break;case"bottom":p={x:d,y:r.y+r.height};break;case"right":p={x:r.x+r.width,y:f};break;case"left":p={x:r.x-o.width,y:f};break;default:p={x:r.x,y:r.y}}switch(Mr(t)){case"start":p[i]-=m*(n&&c?-1:1);break;case"end":p[i]+=m*(n&&c?-1:1);break}return p}const hS=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:f}=gp(c,r,l),m=r,p={},v=0;for(let g=0;g<a.length;g++){const{name:x,fn:y}=a[g],{x:w,y:C,data:E,reset:T}=await y({x:d,y:f,initialPlacement:r,placement:m,strategy:o,middlewareData:p,rects:c,platform:i,elements:{reference:e,floating:t}});d=w??d,f=C??f,p={...p,[x]:{...p[x],...E}},T&&v<=50&&(v++,typeof T=="object"&&(T.placement&&(m=T.placement),T.rects&&(c=T.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):T.rects),{x:d,y:f}=gp(c,m,l)),g=-1)}return{x:d,y:f,placement:m,strategy:o,middlewareData:p}};async function yo(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:f="floating",altBoundary:m=!1,padding:p=0}=An(t,e),v=mp(p),x=a[m?f==="floating"?"reference":"floating":f],y=Fs(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=f==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,C=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),E=await(s.isElement==null?void 0:s.isElement(C))?await(s.getScale==null?void 0:s.getScale(C))||{x:1,y:1}:{x:1,y:1},T=Fs(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:w,offsetParent:C,strategy:l}):w);return{top:(y.top-T.top+v.top)/E.y,bottom:(T.bottom-y.bottom+v.bottom)/E.y,left:(y.left-T.left+v.left)/E.x,right:(T.right-y.right+v.right)/E.x}}const mS=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 f=mp(d),m={x:n,y:r},p=Ga(o),v=qa(p),g=await i.getDimensions(c),x=p==="y",y=x?"top":"left",w=x?"bottom":"right",C=x?"clientHeight":"clientWidth",E=s.reference[v]+s.reference[p]-m[p]-s.floating[v],T=m[p]-s.reference[p],S=await(i.getOffsetParent==null?void 0:i.getOffsetParent(c));let k=S?S[C]:0;(!k||!await(i.isElement==null?void 0:i.isElement(S)))&&(k=a.floating[C]||s.floating[v]);const A=E/2-T/2,j=k/2-g[v]/2-1,F=Wn(f[y],j),D=Wn(f[w],j),B=F,G=k-g[v]-D,M=k/2-g[v]/2+A,W=Va(B,M,G),Y=!l.arrow&&Mr(o)!=null&&M!==W&&s.reference[v]/2-(M<B?F:D)-g[v]/2<0,z=Y?M<B?M-B:M-G:0;return{[p]:m[p]+z,data:{[p]:W,centerOffset:M-W-z,...Y&&{alignmentOffset:z}},reset:Y}}}),gS=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:f=!0,fallbackPlacements:m,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:v="none",flipAlignment:g=!0,...x}=An(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const y=jn(o),w=Cn(a),C=jn(a)===a,E=await(l.isRTL==null?void 0:l.isRTL(c.floating)),T=m||(C||!g?[$s(a)]:lS(a)),S=v!=="none";!m&&S&&T.push(...fS(a,g,v,E));const k=[a,...T],A=await yo(t,x),j=[];let F=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&j.push(A[y]),f){const M=aS(o,i,E);j.push(A[M[0]],A[M[1]])}if(F=[...F,{placement:o,overflows:j}],!j.every(M=>M<=0)){var D,B;const M=(((D=s.flip)==null?void 0:D.index)||0)+1,W=k[M];if(W&&(!(f==="alignment"?w!==Cn(W):!1)||F.every(P=>Cn(P.placement)===w?P.overflows[0]>0:!0)))return{data:{index:M,overflows:F},reset:{placement:W}};let Y=(B=F.filter(z=>z.overflows[0]<=0).sort((z,P)=>z.overflows[1]-P.overflows[1])[0])==null?void 0:B.placement;if(!Y)switch(p){case"bestFit":{var G;const z=(G=F.filter(P=>{if(S){const I=Cn(P.placement);return I===w||I==="y"}return!0}).map(P=>[P.placement,P.overflows.filter(I=>I>0).reduce((I,K)=>I+K,0)]).sort((P,I)=>P[1]-I[1])[0])==null?void 0:G[0];z&&(Y=z);break}case"initialPlacement":Y=a;break}if(o!==Y)return{reset:{placement:Y}}}return{}}}};function xp(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function vp(e){return rS.some(t=>e[t]>=0)}const xS=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 yo(t,{...o,elementContext:"reference"}),i=xp(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:vp(i)}}}case"escaped":{const s=await yo(t,{...o,altBoundary:!0}),i=xp(s,n.floating);return{data:{escapedOffsets:i,escaped:vp(i)}}}default:return{}}}}},bp=new Set(["left","top"]);async function vS(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=Mr(n),l=Cn(n)==="y",c=bp.has(i)?-1:1,d=s&&l?-1:1,f=An(t,e);let{mainAxis:m,crossAxis:p,alignmentAxis:v}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof v=="number"&&(p=a==="end"?v*-1:v),l?{x:p*d,y:m*c}:{x:m*c,y:p*d}}const bS=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 vS(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}}}}},wS=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 yo(t,l),f=Cn(jn(o)),m=Ka(f);let p=c[m],v=c[f];if(s){const x=m==="y"?"top":"left",y=m==="y"?"bottom":"right",w=p+d[x],C=p-d[y];p=Va(w,p,C)}if(i){const x=f==="y"?"top":"left",y=f==="y"?"bottom":"right",w=v+d[x],C=v-d[y];v=Va(w,v,C)}const g=a.fn({...t,[m]:p,[f]:v});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[m]:s,[f]:i}}}}}},yS=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},f=Cn(o),m=Ka(f);let p=d[m],v=d[f];const g=An(a,t),x=typeof g=="number"?{mainAxis:g,crossAxis:0}:{mainAxis:0,crossAxis:0,...g};if(l){const C=m==="y"?"height":"width",E=s.reference[m]-s.floating[C]+x.mainAxis,T=s.reference[m]+s.reference[C]-x.mainAxis;p<E?p=E:p>T&&(p=T)}if(c){var y,w;const C=m==="y"?"width":"height",E=bp.has(jn(o)),T=s.reference[f]-s.floating[C]+(E&&((y=i.offset)==null?void 0:y[f])||0)+(E?0:x.crossAxis),S=s.reference[f]+s.reference[C]+(E?0:((w=i.offset)==null?void 0:w[f])||0)-(E?x.crossAxis:0);v<T?v=T:v>S&&(v=S)}return{[m]:p,[f]:v}}}},SS=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 yo(t,c),f=jn(o),m=Mr(o),p=Cn(o)==="y",{width:v,height:g}=s.floating;let x,y;f==="top"||f==="bottom"?(x=f,y=m===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(y=f,x=m==="end"?"top":"bottom");const w=g-d.top-d.bottom,C=v-d.left-d.right,E=Wn(g-d[x],w),T=Wn(v-d[y],C),S=!t.middlewareData.shift;let k=E,A=T;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(A=C),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(k=w),S&&!m){const F=en(d.left,0),D=en(d.right,0),B=en(d.top,0),G=en(d.bottom,0);p?A=v-2*(F!==0||D!==0?F+D:en(d.left,d.right)):k=g-2*(B!==0||G!==0?B+G:en(d.top,d.bottom))}await l({...t,availableWidth:A,availableHeight:k});const j=await i.getDimensions(a.floating);return v!==j.width||g!==j.height?{reset:{rects:!0}}:{}}}};function Bs(){return typeof window<"u"}function Or(e){return wp(e)?(e.nodeName||"").toLowerCase():"#document"}function tn(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Tn(e){var t;return(t=(wp(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function wp(e){return Bs()?e instanceof Node||e instanceof tn(e).Node:!1}function pn(e){return Bs()?e instanceof Element||e instanceof tn(e).Element:!1}function kn(e){return Bs()?e instanceof HTMLElement||e instanceof tn(e).HTMLElement:!1}function yp(e){return!Bs()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof tn(e).ShadowRoot}const CS=new Set(["inline","contents"]);function So(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=hn(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!CS.has(o)}const TS=new Set(["table","td","th"]);function kS(e){return TS.has(Or(e))}const ES=[":popover-open",":modal"];function zs(e){return ES.some(t=>{try{return e.matches(t)}catch{return!1}})}const IS=["transform","translate","scale","rotate","perspective"],NS=["transform","translate","scale","rotate","perspective","filter"],AS=["paint","layout","strict","content"];function Xa(e){const t=Ja(),n=pn(e)?hn(e):e;return IS.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)||NS.some(r=>(n.willChange||"").includes(r))||AS.some(r=>(n.contain||"").includes(r))}function jS(e){let t=Vn(e);for(;kn(t)&&!Dr(t);){if(Xa(t))return t;if(zs(t))return null;t=Vn(t)}return null}function Ja(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const PS=new Set(["html","body","#document"]);function Dr(e){return PS.has(Or(e))}function hn(e){return tn(e).getComputedStyle(e)}function Hs(e){return pn(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Vn(e){if(Or(e)==="html")return e;const t=e.assignedSlot||e.parentNode||yp(e)&&e.host||Tn(e);return yp(t)?t.host:t}function Sp(e){const t=Vn(e);return Dr(t)?e.ownerDocument?e.ownerDocument.body:e.body:kn(t)&&So(t)?t:Sp(t)}function Co(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=Sp(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=tn(o);if(s){const a=Za(i);return t.concat(i,i.visualViewport||[],So(o)?o:[],a&&n?Co(a):[])}return t.concat(o,Co(o,[],n))}function Za(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Cp(e){const t=hn(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=kn(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=Ds(n)!==s||Ds(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function Qa(e){return pn(e)?e:e.contextElement}function Lr(e){const t=Qa(e);if(!kn(t))return Sn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=Cp(t);let i=(s?Ds(n.width):n.width)/r,a=(s?Ds(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const _S=Sn(0);function Tp(e){const t=tn(e);return!Ja()||!t.visualViewport?_S:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function RS(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==tn(e)?!1:t}function dr(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=Qa(e);let i=Sn(1);t&&(r?pn(r)&&(i=Lr(r)):i=Lr(e));const a=RS(s,n,r)?Tp(s):Sn(0);let l=(o.left+a.x)/i.x,c=(o.top+a.y)/i.y,d=o.width/i.x,f=o.height/i.y;if(s){const m=tn(s),p=r&&pn(r)?tn(r):r;let v=m,g=Za(v);for(;g&&r&&p!==v;){const x=Lr(g),y=g.getBoundingClientRect(),w=hn(g),C=y.left+(g.clientLeft+parseFloat(w.paddingLeft))*x.x,E=y.top+(g.clientTop+parseFloat(w.paddingTop))*x.y;l*=x.x,c*=x.y,d*=x.x,f*=x.y,l+=C,c+=E,v=tn(g),g=Za(v)}}return Fs({width:d,height:f,x:l,y:c})}function Us(e,t){const n=Hs(e).scrollLeft;return t?t.left+n:dr(Tn(e)).left+n}function kp(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-Us(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function MS(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=Tn(r),a=t?zs(t.floating):!1;if(r===i||a&&s)return n;let l={scrollLeft:0,scrollTop:0},c=Sn(1);const d=Sn(0),f=kn(r);if((f||!f&&!s)&&((Or(r)!=="body"||So(i))&&(l=Hs(r)),kn(r))){const p=dr(r);c=Lr(r),d.x=p.x+r.clientLeft,d.y=p.y+r.clientTop}const m=i&&!f&&!s?kp(i,l):Sn(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 OS(e){return Array.from(e.getClientRects())}function DS(e){const t=Tn(e),n=Hs(e),r=e.ownerDocument.body,o=en(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=en(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+Us(e);const a=-n.scrollTop;return hn(r).direction==="rtl"&&(i+=en(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const Ep=25;function LS(e,t){const n=tn(e),r=Tn(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=Ja();(!d||d&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}const c=Us(r);if(c<=0){const d=r.ownerDocument,f=d.body,m=getComputedStyle(f),p=d.compatMode==="CSS1Compat"&&parseFloat(m.marginLeft)+parseFloat(m.marginRight)||0,v=Math.abs(r.clientWidth-f.clientWidth-p);v<=Ep&&(s-=v)}else c<=Ep&&(s+=c);return{width:s,height:i,x:a,y:l}}const $S=new Set(["absolute","fixed"]);function FS(e,t){const n=dr(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=kn(e)?Lr(e):Sn(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 Ip(e,t,n){let r;if(t==="viewport")r=LS(e,n);else if(t==="document")r=DS(Tn(e));else if(pn(t))r=FS(t,n);else{const o=Tp(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Fs(r)}function Np(e,t){const n=Vn(e);return n===t||!pn(n)||Dr(n)?!1:hn(n).position==="fixed"||Np(n,t)}function BS(e,t){const n=t.get(e);if(n)return n;let r=Co(e,[],!1).filter(a=>pn(a)&&Or(a)!=="body"),o=null;const s=hn(e).position==="fixed";let i=s?Vn(e):e;for(;pn(i)&&!Dr(i);){const a=hn(i),l=Xa(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&$S.has(o.position)||So(i)&&!l&&Np(e,i))?r=r.filter(d=>d!==i):o=a,i=Vn(i)}return t.set(e,r),r}function zS(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?zs(t)?[]:BS(t,this._c):[].concat(n),r],a=i[0],l=i.reduce((c,d)=>{const f=Ip(t,d,o);return c.top=en(f.top,c.top),c.right=Wn(f.right,c.right),c.bottom=Wn(f.bottom,c.bottom),c.left=en(f.left,c.left),c},Ip(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function HS(e){const{width:t,height:n}=Cp(e);return{width:t,height:n}}function US(e,t,n){const r=kn(t),o=Tn(t),s=n==="fixed",i=dr(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=Sn(0);function c(){l.x=Us(o)}if(r||!r&&!s)if((Or(t)!=="body"||So(o))&&(a=Hs(t)),r){const p=dr(t,!0,s,t);l.x=p.x+t.clientLeft,l.y=p.y+t.clientTop}else o&&c();s&&!r&&o&&c();const d=o&&!r&&!s?kp(o,a):Sn(0),f=i.left+a.scrollLeft-l.x-d.x,m=i.top+a.scrollTop-l.y-d.y;return{x:f,y:m,width:i.width,height:i.height}}function el(e){return hn(e).position==="static"}function Ap(e,t){if(!kn(e)||hn(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Tn(e)===n&&(n=n.ownerDocument.body),n}function jp(e,t){const n=tn(e);if(zs(e))return n;if(!kn(e)){let o=Vn(e);for(;o&&!Dr(o);){if(pn(o)&&!el(o))return o;o=Vn(o)}return n}let r=Ap(e,t);for(;r&&kS(r)&&el(r);)r=Ap(r,t);return r&&Dr(r)&&el(r)&&!Xa(r)?n:r||jS(e)||n}const WS=async function(e){const t=this.getOffsetParent||jp,n=this.getDimensions,r=await n(e.floating);return{reference:US(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function VS(e){return hn(e).direction==="rtl"}const KS={convertOffsetParentRelativeRectToViewportRelativeRect:MS,getDocumentElement:Tn,getClippingRect:zS,getOffsetParent:jp,getElementRects:WS,getClientRects:OS,getDimensions:HS,getScale:Lr,isElement:pn,isRTL:VS};function Pp(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function qS(e,t){let n=null,r;const o=Tn(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:f,width:m,height:p}=c;if(a||t(),!m||!p)return;const v=Ls(f),g=Ls(o.clientWidth-(d+m)),x=Ls(o.clientHeight-(f+p)),y=Ls(d),C={rootMargin:-v+"px "+-g+"px "+-x+"px "+-y+"px",threshold:en(0,Wn(1,l))||1};let E=!0;function T(S){const k=S[0].intersectionRatio;if(k!==l){if(!E)return i();k?i(!1,k):r=setTimeout(()=>{i(!1,1e-7)},1e3)}k===1&&!Pp(c,e.getBoundingClientRect())&&i(),E=!1}try{n=new IntersectionObserver(T,{...C,root:o.ownerDocument})}catch{n=new IntersectionObserver(T,C)}n.observe(e)}return i(!0),s}function GS(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=Qa(e),d=o||s?[...c?Co(c):[],...Co(t)]:[];d.forEach(y=>{o&&y.addEventListener("scroll",n,{passive:!0}),s&&y.addEventListener("resize",n)});const f=c&&a?qS(c,n):null;let m=-1,p=null;i&&(p=new ResizeObserver(y=>{let[w]=y;w&&w.target===c&&p&&(p.unobserve(t),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var C;(C=p)==null||C.observe(t)})),n()}),c&&!l&&p.observe(c),p.observe(t));let v,g=l?dr(e):null;l&&x();function x(){const y=dr(e);g&&!Pp(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)}),f==null||f(),(y=p)==null||y.disconnect(),p=null,l&&cancelAnimationFrame(v)}}const YS=bS,XS=wS,JS=gS,ZS=SS,QS=xS,_p=mS,eC=yS,tC=(e,t,n)=>{const r=new Map,o={platform:KS,...n},s={...o.platform,_c:r};return hS(e,t,{...o,platform:s})};var nC=typeof document<"u",rC=function(){},Ws=nC?b.useLayoutEffect:rC;function Vs(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(!Vs(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)&&!Vs(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function Rp(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Mp(e,t){const n=Rp(e);return Math.round(t*n)/n}function tl(e){const t=h.useRef(e);return Ws(()=>{t.current=e}),t}function oC(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,f]=h.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[m,p]=h.useState(r);Vs(m,r)||p(r);const[v,g]=h.useState(null),[x,y]=h.useState(null),w=h.useCallback(P=>{P!==S.current&&(S.current=P,g(P))},[]),C=h.useCallback(P=>{P!==k.current&&(k.current=P,y(P))},[]),E=s||v,T=i||x,S=h.useRef(null),k=h.useRef(null),A=h.useRef(d),j=l!=null,F=tl(l),D=tl(o),B=tl(c),G=h.useCallback(()=>{if(!S.current||!k.current)return;const P={placement:t,strategy:n,middleware:m};D.current&&(P.platform=D.current),tC(S.current,k.current,P).then(I=>{const K={...I,isPositioned:B.current!==!1};M.current&&!Vs(A.current,K)&&(A.current=K,qr.flushSync(()=>{f(K)}))})},[m,t,n,D,B]);Ws(()=>{c===!1&&A.current.isPositioned&&(A.current.isPositioned=!1,f(P=>({...P,isPositioned:!1})))},[c]);const M=h.useRef(!1);Ws(()=>(M.current=!0,()=>{M.current=!1}),[]),Ws(()=>{if(E&&(S.current=E),T&&(k.current=T),E&&T){if(F.current)return F.current(E,T,G);G()}},[E,T,G,F,j]);const W=h.useMemo(()=>({reference:S,floating:k,setReference:w,setFloating:C}),[w,C]),Y=h.useMemo(()=>({reference:E,floating:T}),[E,T]),z=h.useMemo(()=>{const P={position:n,left:0,top:0};if(!Y.floating)return P;const I=Mp(Y.floating,d.x),K=Mp(Y.floating,d.y);return a?{...P,transform:"translate("+I+"px, "+K+"px)",...Rp(Y.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:I,top:K}},[n,a,Y.floating,d.x,d.y]);return h.useMemo(()=>({...d,update:G,refs:W,elements:Y,floatingStyles:z}),[d,G,W,Y,z])}const sC=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?_p({element:r.current,padding:o}).fn(n):{}:r?_p({element:r,padding:o}).fn(n):{}}}},iC=(e,t)=>({...YS(e),options:[e,t]}),aC=(e,t)=>({...XS(e),options:[e,t]}),lC=(e,t)=>({...eC(e),options:[e,t]}),cC=(e,t)=>({...JS(e),options:[e,t]}),uC=(e,t)=>({...ZS(e),options:[e,t]}),dC=(e,t)=>({...QS(e),options:[e,t]}),fC=(e,t)=>({...sC(e),options:[e,t]});var pC="Arrow",Op=h.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return u.jsx(he.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"})})});Op.displayName=pC;var hC=Op;function Dp(e){const[t,n]=h.useState(void 0);return It(()=>{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 nl="Popper",[Lp,$r]=nn(nl),[mC,$p]=Lp(nl),Fp=e=>{const{__scopePopper:t,children:n}=e,[r,o]=h.useState(null);return u.jsx(mC,{scope:t,anchor:r,onAnchorChange:o,children:n})};Fp.displayName=nl;var Bp="PopperAnchor",zp=h.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=$p(Bp,n),i=h.useRef(null),a=Le(t,i),l=h.useRef(null);return h.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(he.div,{...o,ref:a})});zp.displayName=Bp;var rl="PopperContent",[gC,xC]=Lp(rl),Hp=h.forwardRef((e,t)=>{var R,_,U,Z,re,ce;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:f="partial",hideWhenDetached:m=!1,updatePositionStrategy:p="optimized",onPlaced:v,...g}=e,x=$p(rl,n),[y,w]=h.useState(null),C=Le(t,Ne=>w(Ne)),[E,T]=h.useState(null),S=Dp(E),k=(S==null?void 0:S.width)??0,A=(S==null?void 0:S.height)??0,j=r+(s!=="center"?"-"+s:""),F=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},D=Array.isArray(c)?c:[c],B=D.length>0,G={padding:F,boundary:D.filter(bC),altBoundary:B},{refs:M,floatingStyles:W,placement:Y,isPositioned:z,middlewareData:P}=oC({strategy:"fixed",placement:j,whileElementsMounted:(...Ne)=>GS(...Ne,{animationFrame:p==="always"}),elements:{reference:x.anchor},middleware:[iC({mainAxis:o+A,alignmentAxis:i}),l&&aC({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?lC():void 0,...G}),l&&cC({...G}),uC({...G,apply:({elements:Ne,rects:ye,availableWidth:Re,availableHeight:We})=>{const{width:Fe,height:Ye}=ye.reference,Ve=Ne.floating.style;Ve.setProperty("--radix-popper-available-width",`${Re}px`),Ve.setProperty("--radix-popper-available-height",`${We}px`),Ve.setProperty("--radix-popper-anchor-width",`${Fe}px`),Ve.setProperty("--radix-popper-anchor-height",`${Ye}px`)}}),E&&fC({element:E,padding:a}),wC({arrowWidth:k,arrowHeight:A}),m&&dC({strategy:"referenceHidden",...G})]}),[I,K]=Vp(Y),te=bt(v);It(()=>{z&&(te==null||te())},[z,te]);const O=(R=P.arrow)==null?void 0:R.x,q=(_=P.arrow)==null?void 0:_.y,L=((U=P.arrow)==null?void 0:U.centerOffset)!==0,[$,X]=h.useState();return It(()=>{y&&X(window.getComputedStyle(y).zIndex)},[y]),u.jsx("div",{ref:M.setFloating,"data-radix-popper-content-wrapper":"",style:{...W,transform:z?W.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:$,"--radix-popper-transform-origin":[(Z=P.transformOrigin)==null?void 0:Z.x,(re=P.transformOrigin)==null?void 0:re.y].join(" "),...((ce=P.hide)==null?void 0:ce.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:u.jsx(gC,{scope:n,placedSide:I,onArrowChange:T,arrowX:O,arrowY:q,shouldHideArrow:L,children:u.jsx(he.div,{"data-side":I,"data-align":K,...g,ref:C,style:{...g.style,animation:z?void 0:"none"}})})})});Hp.displayName=rl;var Up="PopperArrow",vC={top:"bottom",right:"left",bottom:"top",left:"right"},Wp=h.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=xC(Up,r),i=vC[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(hC,{...o,ref:n,style:{...o.style,display:"block"}})})});Wp.displayName=Up;function bC(e){return e!==null}var wC=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]=Vp(n),f={start:"0%",center:"50%",end:"100%"}[d],m=(((y=o.arrow)==null?void 0:y.x)??0)+a/2,p=(((w=o.arrow)==null?void 0:w.y)??0)+l/2;let v="",g="";return c==="bottom"?(v=i?f:`${m}px`,g=`${-l}px`):c==="top"?(v=i?f:`${m}px`,g=`${r.floating.height+l}px`):c==="right"?(v=`${-l}px`,g=i?f:`${p}px`):c==="left"&&(v=`${r.floating.width+l}px`,g=i?f:`${p}px`),{data:{x:v,y:g}}}});function Vp(e){const[t,n="center"]=e.split("-");return[t,n]}var ol=Fp,sl=zp,il=Hp,al=Wp,ll="rovingFocusGroup.onEntryFocus",yC={bubbles:!1,cancelable:!0},To="RovingFocusGroup",[cl,Kp,SC]=Ms(To),[CC,qp]=nn(To,[SC]),[TC,kC]=CC(To),Gp=h.forwardRef((e,t)=>u.jsx(cl.Provider,{scope:e.__scopeRovingFocusGroup,children:u.jsx(cl.Slot,{scope:e.__scopeRovingFocusGroup,children:u.jsx(EC,{...e,ref:t})})}));Gp.displayName=To;var EC=h.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:c,preventScrollOnEntryFocus:d=!1,...f}=e,m=h.useRef(null),p=Le(t,m),v=Os(s),[g,x]=In({prop:i,defaultProp:a??null,onChange:l,caller:To}),[y,w]=h.useState(!1),C=bt(c),E=Kp(n),T=h.useRef(!1),[S,k]=h.useState(0);return h.useEffect(()=>{const A=m.current;if(A)return A.addEventListener(ll,C),()=>A.removeEventListener(ll,C)},[C]),u.jsx(TC,{scope:n,orientation:r,dir:v,loop:o,currentTabStopId:g,onItemFocus:h.useCallback(A=>x(A),[x]),onItemShiftTab:h.useCallback(()=>w(!0),[]),onFocusableItemAdd:h.useCallback(()=>k(A=>A+1),[]),onFocusableItemRemove:h.useCallback(()=>k(A=>A-1),[]),children:u.jsx(he.div,{tabIndex:y||S===0?-1:0,"data-orientation":r,...f,ref:p,style:{outline:"none",...e.style},onMouseDown:ue(e.onMouseDown,()=>{T.current=!0}),onFocus:ue(e.onFocus,A=>{const j=!T.current;if(A.target===A.currentTarget&&j&&!y){const F=new CustomEvent(ll,yC);if(A.currentTarget.dispatchEvent(F),!F.defaultPrevented){const D=E().filter(Y=>Y.focusable),B=D.find(Y=>Y.active),G=D.find(Y=>Y.id===g),W=[B,G,...D].filter(Boolean).map(Y=>Y.ref.current);Jp(W,d)}}T.current=!1}),onBlur:ue(e.onBlur,()=>w(!1))})})}),Yp="RovingFocusGroupItem",Xp=h.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,l=jt(),c=s||l,d=kC(Yp,n),f=d.currentTabStopId===c,m=Kp(n),{onFocusableItemAdd:p,onFocusableItemRemove:v,currentTabStopId:g}=d;return h.useEffect(()=>{if(r)return p(),()=>v()},[r,p,v]),u.jsx(cl.ItemSlot,{scope:n,id:c,focusable:r,active:o,children:u.jsx(he.span,{tabIndex:f?0:-1,"data-orientation":d.orientation,...a,ref:t,onMouseDown:ue(e.onMouseDown,x=>{r?d.onItemFocus(c):x.preventDefault()}),onFocus:ue(e.onFocus,()=>d.onItemFocus(c)),onKeyDown:ue(e.onKeyDown,x=>{if(x.key==="Tab"&&x.shiftKey){d.onItemShiftTab();return}if(x.target!==x.currentTarget)return;const y=AC(x,d.orientation,d.dir);if(y!==void 0){if(x.metaKey||x.ctrlKey||x.altKey||x.shiftKey)return;x.preventDefault();let C=m().filter(E=>E.focusable).map(E=>E.ref.current);if(y==="last")C.reverse();else if(y==="prev"||y==="next"){y==="prev"&&C.reverse();const E=C.indexOf(x.currentTarget);C=d.loop?jC(C,E+1):C.slice(E+1)}setTimeout(()=>Jp(C))}}),children:typeof i=="function"?i({isCurrentTabStop:f,hasTabStop:g!=null}):i})})});Xp.displayName=Yp;var IC={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function NC(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function AC(e,t,n){const r=NC(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return IC[r]}function Jp(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function jC(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var PC=Gp,_C=Xp,ul=["Enter"," "],RC=["ArrowDown","PageUp","Home"],Zp=["ArrowUp","PageDown","End"],MC=[...RC,...Zp],OC={ltr:[...ul,"ArrowRight"],rtl:[...ul,"ArrowLeft"]},DC={ltr:["ArrowLeft"],rtl:["ArrowRight"]},ko="Menu",[Eo,LC,$C]=Ms(ko),[fr,Qp]=nn(ko,[$C,$r,qp]),Ks=$r(),eh=qp(),[FC,pr]=fr(ko),[BC,Io]=fr(ko),th=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=Ks(t),[l,c]=h.useState(null),d=h.useRef(!1),f=bt(s),m=Os(o);return h.useEffect(()=>{const p=()=>{d.current=!0,document.addEventListener("pointerdown",v,{capture:!0,once:!0}),document.addEventListener("pointermove",v,{capture:!0,once:!0})},v=()=>d.current=!1;return document.addEventListener("keydown",p,{capture:!0}),()=>{document.removeEventListener("keydown",p,{capture:!0}),document.removeEventListener("pointerdown",v,{capture:!0}),document.removeEventListener("pointermove",v,{capture:!0})}},[]),u.jsx(ol,{...a,children:u.jsx(FC,{scope:t,open:n,onOpenChange:f,content:l,onContentChange:c,children:u.jsx(BC,{scope:t,onClose:h.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:d,dir:m,modal:i,children:r})})})};th.displayName=ko;var zC="MenuAnchor",dl=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=Ks(n);return u.jsx(sl,{...o,...r,ref:t})});dl.displayName=zC;var fl="MenuPortal",[HC,nh]=fr(fl,{forceMount:void 0}),rh=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=pr(fl,t);return u.jsx(HC,{scope:t,forceMount:n,children:u.jsx($t,{present:n||s.open,children:u.jsx(so,{asChild:!0,container:o,children:r})})})};rh.displayName=fl;var sn="MenuContent",[UC,pl]=fr(sn),oh=h.forwardRef((e,t)=>{const n=nh(sn,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=pr(sn,e.__scopeMenu),i=Io(sn,e.__scopeMenu);return u.jsx(Eo.Provider,{scope:e.__scopeMenu,children:u.jsx($t,{present:r||s.open,children:u.jsx(Eo.Slot,{scope:e.__scopeMenu,children:i.modal?u.jsx(WC,{...o,ref:t}):u.jsx(VC,{...o,ref:t})})})})}),WC=h.forwardRef((e,t)=>{const n=pr(sn,e.__scopeMenu),r=h.useRef(null),o=Le(t,r);return h.useEffect(()=>{const s=r.current;if(s)return na(s)},[]),u.jsx(hl,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:ue(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),VC=h.forwardRef((e,t)=>{const n=pr(sn,e.__scopeMenu);return u.jsx(hl,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),KC=Jt.createSlot("MenuContent.ScrollLock"),hl=h.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:m,onDismiss:p,disableOutsideScroll:v,...g}=e,x=pr(sn,n),y=Io(sn,n),w=Ks(n),C=eh(n),E=LC(n),[T,S]=h.useState(null),k=h.useRef(null),A=Le(t,k,x.onContentChange),j=h.useRef(0),F=h.useRef(""),D=h.useRef(0),B=h.useRef(null),G=h.useRef("right"),M=h.useRef(0),W=v?rs:h.Fragment,Y=v?{as:KC,allowPinchZoom:!0}:void 0,z=I=>{var R,_;const K=F.current+I,te=E().filter(U=>!U.disabled),O=document.activeElement,q=(R=te.find(U=>U.ref.current===O))==null?void 0:R.textValue,L=te.map(U=>U.textValue),$=oT(L,K,q),X=(_=te.find(U=>U.textValue===$))==null?void 0:_.ref.current;(function U(Z){F.current=Z,window.clearTimeout(j.current),Z!==""&&(j.current=window.setTimeout(()=>U(""),1e3))})(K),X&&setTimeout(()=>X.focus())};h.useEffect(()=>()=>window.clearTimeout(j.current),[]),Xi();const P=h.useCallback(I=>{var te,O;return G.current===((te=B.current)==null?void 0:te.side)&&iT(I,(O=B.current)==null?void 0:O.area)},[]);return u.jsx(UC,{scope:n,searchRef:F,onItemEnter:h.useCallback(I=>{P(I)&&I.preventDefault()},[P]),onItemLeave:h.useCallback(I=>{var K;P(I)||((K=k.current)==null||K.focus(),S(null))},[P]),onTriggerLeave:h.useCallback(I=>{P(I)&&I.preventDefault()},[P]),pointerGraceTimerRef:D,onPointerGraceIntentChange:h.useCallback(I=>{B.current=I},[]),children:u.jsx(W,{...Y,children:u.jsx(Xo,{asChild:!0,trapped:o,onMountAutoFocus:ue(s,I=>{var K;I.preventDefault(),(K=k.current)==null||K.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:u.jsx(Er,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:m,onDismiss:p,children:u.jsx(PC,{asChild:!0,...C,dir:y.dir,orientation:"vertical",loop:r,currentTabStopId:T,onCurrentTabStopIdChange:S,onEntryFocus:ue(l,I=>{y.isUsingKeyboardRef.current||I.preventDefault()}),preventScrollOnEntryFocus:!0,children:u.jsx(il,{role:"menu","aria-orientation":"vertical","data-state":yh(x.open),"data-radix-menu-content":"",dir:y.dir,...w,...g,ref:A,style:{outline:"none",...g.style},onKeyDown:ue(g.onKeyDown,I=>{const te=I.target.closest("[data-radix-menu-content]")===I.currentTarget,O=I.ctrlKey||I.altKey||I.metaKey,q=I.key.length===1;te&&(I.key==="Tab"&&I.preventDefault(),!O&&q&&z(I.key));const L=k.current;if(I.target!==L||!MC.includes(I.key))return;I.preventDefault();const X=E().filter(R=>!R.disabled).map(R=>R.ref.current);Zp.includes(I.key)&&X.reverse(),nT(X)}),onBlur:ue(e.onBlur,I=>{I.currentTarget.contains(I.target)||(window.clearTimeout(j.current),F.current="")}),onPointerMove:ue(e.onPointerMove,Ao(I=>{const K=I.target,te=M.current!==I.clientX;if(I.currentTarget.contains(K)&&te){const O=I.clientX>M.current?"right":"left";G.current=O,M.current=I.clientX}}))})})})})})})});oh.displayName=sn;var qC="MenuGroup",ml=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(he.div,{role:"group",...r,ref:t})});ml.displayName=qC;var GC="MenuLabel",sh=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(he.div,{...r,ref:t})});sh.displayName=GC;var qs="MenuItem",ih="menu.itemSelect",Gs=h.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=h.useRef(null),i=Io(qs,e.__scopeMenu),a=pl(qs,e.__scopeMenu),l=Le(t,s),c=h.useRef(!1),d=()=>{const f=s.current;if(!n&&f){const m=new CustomEvent(ih,{bubbles:!0,cancelable:!0});f.addEventListener(ih,p=>r==null?void 0:r(p),{once:!0}),Vi(f,m),m.defaultPrevented?c.current=!1:i.onClose()}};return u.jsx(ah,{...o,ref:l,disabled:n,onClick:ue(e.onClick,d),onPointerDown:f=>{var m;(m=e.onPointerDown)==null||m.call(e,f),c.current=!0},onPointerUp:ue(e.onPointerUp,f=>{var m;c.current||(m=f.currentTarget)==null||m.click()}),onKeyDown:ue(e.onKeyDown,f=>{const m=a.searchRef.current!=="";n||m&&f.key===" "||ul.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});Gs.displayName=qs;var ah=h.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=pl(qs,n),a=eh(n),l=h.useRef(null),c=Le(t,l),[d,f]=h.useState(!1),[m,p]=h.useState("");return h.useEffect(()=>{const v=l.current;v&&p((v.textContent??"").trim())},[s.children]),u.jsx(Eo.ItemSlot,{scope:n,disabled:r,textValue:o??m,children:u.jsx(_C,{asChild:!0,...a,focusable:!r,children:u.jsx(he.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:c,onPointerMove:ue(e.onPointerMove,Ao(v=>{r?i.onItemLeave(v):(i.onItemEnter(v),v.defaultPrevented||v.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:ue(e.onPointerLeave,Ao(v=>i.onItemLeave(v))),onFocus:ue(e.onFocus,()=>f(!0)),onBlur:ue(e.onBlur,()=>f(!1))})})})}),YC="MenuCheckboxItem",lh=h.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return u.jsx(ph,{scope:e.__scopeMenu,checked:n,children:u.jsx(Gs,{role:"menuitemcheckbox","aria-checked":Ys(n)?"mixed":n,...o,ref:t,"data-state":xl(n),onSelect:ue(o.onSelect,()=>r==null?void 0:r(Ys(n)?!0:!n),{checkForDefaultPrevented:!1})})})});lh.displayName=YC;var ch="MenuRadioGroup",[XC,JC]=fr(ch,{value:void 0,onValueChange:()=>{}}),uh=h.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=bt(r);return u.jsx(XC,{scope:e.__scopeMenu,value:n,onValueChange:s,children:u.jsx(ml,{...o,ref:t})})});uh.displayName=ch;var dh="MenuRadioItem",fh=h.forwardRef((e,t)=>{const{value:n,...r}=e,o=JC(dh,e.__scopeMenu),s=n===o.value;return u.jsx(ph,{scope:e.__scopeMenu,checked:s,children:u.jsx(Gs,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":xl(s),onSelect:ue(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});fh.displayName=dh;var gl="MenuItemIndicator",[ph,ZC]=fr(gl,{checked:!1}),hh=h.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=ZC(gl,n);return u.jsx($t,{present:r||Ys(s.checked)||s.checked===!0,children:u.jsx(he.span,{...o,ref:t,"data-state":xl(s.checked)})})});hh.displayName=gl;var QC="MenuSeparator",mh=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(he.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});mh.displayName=QC;var eT="MenuArrow",gh=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=Ks(n);return u.jsx(al,{...o,...r,ref:t})});gh.displayName=eT;var tT="MenuSub",[UN,xh]=fr(tT),No="MenuSubTrigger",vh=h.forwardRef((e,t)=>{const n=pr(No,e.__scopeMenu),r=Io(No,e.__scopeMenu),o=xh(No,e.__scopeMenu),s=pl(No,e.__scopeMenu),i=h.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,c={__scopeMenu:e.__scopeMenu},d=h.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return h.useEffect(()=>d,[d]),h.useEffect(()=>{const f=a.current;return()=>{window.clearTimeout(f),l(null)}},[a,l]),u.jsx(dl,{asChild:!0,...c,children:u.jsx(ah,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":yh(n.open),...e,ref:Dn(t,o.onTriggerChange),onClick:f=>{var m;(m=e.onClick)==null||m.call(e,f),!(e.disabled||f.defaultPrevented)&&(f.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:ue(e.onPointerMove,Ao(f=>{s.onItemEnter(f),!f.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(s.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),d()},100))})),onPointerLeave:ue(e.onPointerLeave,Ao(f=>{var p,v;d();const m=(p=n.content)==null?void 0:p.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"],C=m[x?"right":"left"];s.onPointerGraceIntentChange({area:[{x:f.clientX+y,y:f.clientY},{x:w,y:m.top},{x:C,y:m.top},{x:C,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(f),f.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:ue(e.onKeyDown,f=>{var p;const m=s.searchRef.current!=="";e.disabled||m&&f.key===" "||OC[r.dir].includes(f.key)&&(n.onOpenChange(!0),(p=n.content)==null||p.focus(),f.preventDefault())})})})});vh.displayName=No;var bh="MenuSubContent",wh=h.forwardRef((e,t)=>{const n=nh(sn,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=pr(sn,e.__scopeMenu),i=Io(sn,e.__scopeMenu),a=xh(bh,e.__scopeMenu),l=h.useRef(null),c=Le(t,l);return u.jsx(Eo.Provider,{scope:e.__scopeMenu,children:u.jsx($t,{present:r||s.open,children:u.jsx(Eo.Slot,{scope:e.__scopeMenu,children:u.jsx(hl,{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 f;i.isUsingKeyboardRef.current&&((f=l.current)==null||f.focus()),d.preventDefault()},onCloseAutoFocus:d=>d.preventDefault(),onFocusOutside:ue(e.onFocusOutside,d=>{d.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:ue(e.onEscapeKeyDown,d=>{i.onClose(),d.preventDefault()}),onKeyDown:ue(e.onKeyDown,d=>{var p;const f=d.currentTarget.contains(d.target),m=DC[i.dir].includes(d.key);f&&m&&(s.onOpenChange(!1),(p=a.trigger)==null||p.focus(),d.preventDefault())})})})})})});wh.displayName=bh;function yh(e){return e?"open":"closed"}function Ys(e){return e==="indeterminate"}function xl(e){return Ys(e)?"indeterminate":e?"checked":"unchecked"}function nT(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function rT(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function oT(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=rT(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 sT(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,f=l.x,m=l.y;d>r!=m>r&&n<(f-c)*(r-d)/(m-d)+c&&(o=!o)}return o}function iT(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return sT(n,t)}function Ao(e){return t=>t.pointerType==="mouse"?e(t):void 0}var aT=th,lT=dl,cT=rh,uT=oh,dT=ml,fT=sh,pT=Gs,hT=lh,mT=uh,gT=fh,xT=hh,vT=mh,bT=gh,wT=vh,yT=wh,Xs="DropdownMenu",[ST,WN]=nn(Xs,[Qp]),Bt=Qp(),[CT,Sh]=ST(Xs),Ch=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,l=Bt(t),c=h.useRef(null),[d,f]=In({prop:o,defaultProp:s??!1,onChange:i,caller:Xs});return u.jsx(CT,{scope:t,triggerId:jt(),triggerRef:c,contentId:jt(),open:d,onOpenChange:f,onOpenToggle:h.useCallback(()=>f(m=>!m),[f]),modal:a,children:u.jsx(aT,{...l,open:d,onOpenChange:f,dir:r,modal:a,children:n})})};Ch.displayName=Xs;var Th="DropdownMenuTrigger",kh=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=Sh(Th,n),i=Bt(n);return u.jsx(lT,{asChild:!0,...i,children:u.jsx(he.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:Dn(t,s.triggerRef),onPointerDown:ue(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:ue(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});kh.displayName=Th;var TT="DropdownMenuPortal",Eh=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Bt(t);return u.jsx(cT,{...r,...n})};Eh.displayName=TT;var Ih="DropdownMenuContent",Nh=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Sh(Ih,n),s=Bt(n),i=h.useRef(!1);return u.jsx(uT,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:ue(e.onCloseAutoFocus,a=>{var l;i.current||(l=o.triggerRef.current)==null||l.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:ue(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)"}})});Nh.displayName=Ih;var kT="DropdownMenuGroup",ET=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Bt(n);return u.jsx(dT,{...o,...r,ref:t})});ET.displayName=kT;var IT="DropdownMenuLabel",Ah=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Bt(n);return u.jsx(fT,{...o,...r,ref:t})});Ah.displayName=IT;var NT="DropdownMenuItem",jh=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Bt(n);return u.jsx(pT,{...o,...r,ref:t})});jh.displayName=NT;var AT="DropdownMenuCheckboxItem",Ph=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Bt(n);return u.jsx(hT,{...o,...r,ref:t})});Ph.displayName=AT;var jT="DropdownMenuRadioGroup",PT=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Bt(n);return u.jsx(mT,{...o,...r,ref:t})});PT.displayName=jT;var _T="DropdownMenuRadioItem",_h=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Bt(n);return u.jsx(gT,{...o,...r,ref:t})});_h.displayName=_T;var RT="DropdownMenuItemIndicator",Rh=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Bt(n);return u.jsx(xT,{...o,...r,ref:t})});Rh.displayName=RT;var MT="DropdownMenuSeparator",Mh=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Bt(n);return u.jsx(vT,{...o,...r,ref:t})});Mh.displayName=MT;var OT="DropdownMenuArrow",DT=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Bt(n);return u.jsx(bT,{...o,...r,ref:t})});DT.displayName=OT;var LT="DropdownMenuSubTrigger",Oh=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Bt(n);return u.jsx(wT,{...o,...r,ref:t})});Oh.displayName=LT;var $T="DropdownMenuSubContent",Dh=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Bt(n);return u.jsx(yT,{...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)"}})});Dh.displayName=$T;var FT=Ch,BT=kh,zT=Eh,Lh=Nh,$h=Ah,Fh=jh,Bh=Ph,zh=_h,Hh=Rh,Uh=Mh,Wh=Oh,Vh=Dh;const Js=FT,Zs=BT,HT=h.forwardRef(({className:e,inset:t,children:n,...r},o)=>u.jsxs(Wh,{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(de.ChevronRight,{className:"ml-auto h-4 w-4"})]}));HT.displayName=Wh.displayName;const UT=h.forwardRef(({className:e,...t},n)=>u.jsx(Vh,{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}));UT.displayName=Vh.displayName;const jo=h.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(zT,{children:u.jsx(Lh,{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})}));jo.displayName=Lh.displayName;const Kn=h.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(Fh,{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}));Kn.displayName=Fh.displayName;const WT=h.forwardRef(({className:e,children:t,checked:n,...r},o)=>u.jsxs(Bh,{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(Hh,{children:u.jsx(de.Check,{className:"h-4 w-4"})})}),t]}));WT.displayName=Bh.displayName;const VT=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(zh,{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(Hh,{children:u.jsx(de.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));VT.displayName=zh.displayName;const KT=h.forwardRef(({className:e,inset:t,...n},r)=>u.jsx($h,{ref:r,className:oe("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));KT.displayName=$h.displayName;const qT=h.forwardRef(({className:e,...t},n)=>u.jsx(Uh,{ref:n,className:oe("-mx-1 my-1 h-px bg-muted",e),...t}));qT.displayName=Uh.displayName;const vl=h.forwardRef(({className:e,...t},n)=>u.jsx("textarea",{className:oe("flex min-h-[40px] 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}));vl.displayName="Textarea";const GT=1e4;function Kh({initialValue:e="",editingMessageId:t=null,placeholder:n="Type your message...",isStreaming:r=!1,disabled:o=!1,maxLength:s=GT,value:i,onValueChange:a,onSend:l,onCancelEdit:c,onStop:d,className:f="",textareaClassName:m="",allowEmptySend:p=!1,sendButtonClassName:v,validate:g,onValidationError:x}){const y=i!==void 0,[w,C]=b.useState(e),E=(y?i:w)??"",[T,S]=b.useTransition(),k=b.useRef(null),A=b.useRef(0),j=b.useRef(null),F=b.useRef("");b.useEffect(()=>{if(!y&&(C(e??""),j.current=null,k.current)){const L=!e||e.trim()==="",$=44;L?k.current.style.height=`${$}px`:(k.current.style.height="auto",k.current.style.height=`${Math.max(k.current.scrollHeight,$)}px`)}},[e,t,y]);const[D,B]=b.useState(null),G=b.useCallback(L=>L.length>s?`Message too long (${L.length}/${s} characters)`:null,[s]),M=b.useMemo(()=>g??G,[g,G]),W=b.useCallback(L=>{const $=M(L);return B($),x==null||x($),F.current=L,$},[M,x]),Y=b.useCallback(()=>{const L=k.current;if(!L)return;const $=!L.value||L.value.trim()==="",X=44;if($){L.style.height=`${X}px`;return}L.style.height="auto";const R=Math.max(L.scrollHeight,X);L.style.height=`${R}px`},[]);b.useEffect(()=>{Y()},[Y,E]),b.useEffect(()=>{if(!D)return;const L=(E??"").trim();F.current!==L&&W(L)},[E,D,W]);const z=b.useCallback((L,{fromUser:$})=>{y||C(L),$&&(a==null||a(L))},[y,a]),P=b.useCallback(async L=>{L&&L.preventDefault();const $=(E??"").trim();if(!$&&!p||W($))return;const X=++A.current;j.current={id:X,shouldClear:!0},S(()=>{var R,_,U;try{const Z=l($);Z&&typeof Z.then=="function"?Z.then(()=>{var re,ce;((re=j.current)==null?void 0:re.id)===X&&j.current.shouldClear&&(y||(C(""),k.current&&(k.current.style.height="auto"),a==null||a(""))),((ce=j.current)==null?void 0:ce.id)===X&&(j.current=null)}).catch(()=>{var re;((re=j.current)==null?void 0:re.id)===X&&(j.current=null)}):(((R=j.current)==null?void 0:R.id)===X&&j.current.shouldClear&&(y||(C(""),k.current&&(k.current.style.height="auto"),a==null||a(""))),((_=j.current)==null?void 0:_.id)===X&&(j.current=null))}catch{((U=j.current)==null?void 0:U.id)===X&&(j.current=null)}})},[E,l,p,y,a,W]),I=b.useCallback(L=>{const $=L.target.value;z($,{fromUser:!0}),j.current&&(j.current.shouldClear=!1),k.current&&(k.current.style.height="auto",k.current.style.height=`${k.current.scrollHeight}px`),D&&W($.trim())},[z,W,D]),K=b.useCallback(L=>{L.key==="Enter"&&!L.shiftKey?(L.preventDefault(),P()):L.key==="Escape"&&t&&(L.preventDefault(),c==null||c())},[P,t,c]),q=`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("div",{className:`w-full ${f}`,children:u.jsxs("div",{className:"flex items-end gap-2",children:[u.jsxs("div",{className:"flex-1",children:[u.jsx(vl,{ref:k,value:E,onChange:I,onKeyDown:K,placeholder:t?"Edit your message...":n,className:q,disabled:o,maxLength:s,rows:1,spellCheck:!1,autoCorrect:"off"}),D&&u.jsx("p",{className:"mt-1 text-xs text-destructive font-medium",children:D})]}),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(de.Square,{size:16})}):u.jsx(Xe,{type:"button",onClick:L=>void P(L),size:"icon",className:`shrink-0 ${v??""}`,title:t?"Save changes":"Send message",disabled:o||!E.trim()&&!p||T||r,children:u.jsx(de.Send,{size:16})})})]})})}const YT=b.memo(Kh);function qh({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:f={},enableFileUpload:m=!1,enableExcelUpload:p=!1,onExcelUpload:v,onFilesChange:g,onError:x,allowEmptySend:y=!1,inputError:w=null}){const[C,E]=b.useState([]),T=b.useRef(null),S=b.useRef(null),[k,A]=b.useState(0),[j,F]=b.useState(0),[D,B]=b.useState(!1),[G,M]=b.useState(null),[W,Y]=b.useState(null),z=b.useCallback(()=>{T.current&&(T.current.value=""),S.current&&(S.current.value=""),A($=>$+1),F($=>$+1)},[]),P=b.useCallback($=>{E(X=>{const R=[...X,...$];return g==null||g(R),R})},[g]),I=b.useCallback($=>{const X=Array.from($.target.files||[]);P(X),$.target.value=""},[P]),K=b.useCallback($=>{E(X=>{const R=X.filter((_,U)=>U!==$);return R.length===0&&z(),g==null||g(R),R})},[g,z]),te=b.useCallback(async $=>{const X=($.target.files||[])[0];if(X&&(M(null),Y(null),!!v)){B(!0);try{await v(X),M(`Uploaded ${X.name} - processing through chat stream`)}catch(R){const _=R instanceof Error?R.message:"Failed to upload Excel file";Y(_),x==null||x(_)}finally{B(!1),$.target.value="",z()}}},[v,x,z]),O=b.useMemo(()=>y||C.length>0,[y,C]),q=b.useCallback(async $=>{const R=await n($,C);return C.length>0&&(E([]),g==null||g([]),z()),R},[n,z,C]),L=`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":""} ${w?"border-red-400":""} ${f.textarea||""} ${d}`;return u.jsxs(u.Fragment,{children:[(m||p)&&u.jsxs("div",{className:"mb-3 space-y-3",children:[m&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:T,type:"file",multiple:!0,onChange:I,className:"hidden"},k),C.length>0&&u.jsx("div",{className:"flex flex-wrap gap-2",children:C.map(($,X)=>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(de.Paperclip,{size:14}),u.jsx("span",{className:"truncate max-w-[150px]",children:$.name}),u.jsx(Xe,{variant:"ghost",size:"sm",onClick:()=>K(X),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 ${$.name}`,children:u.jsx(de.X,{size:12})})]},X))})]}),p&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:S,type:"file",accept:".xls,.xlsx,.xlsm",onChange:te,className:"hidden"},j),D&&u.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(de.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}),W&&!D&&u.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:W})]})]}),u.jsxs("div",{className:"flex items-end gap-2",children:[(m||p)&&u.jsxs(Js,{children:[u.jsx(Zs,{asChild:!0,children:u.jsx(Xe,{type:"button",size:"icon",variant:"outline",disabled:l||c,title:"More input actions",className:f.moreButton||"",children:u.jsx(de.Plus,{size:16})})}),u.jsxs(jo,{align:"start",sideOffset:6,className:"w-52",children:[m&&u.jsxs(Kn,{onClick:()=>{var $;return($=T.current)==null?void 0:$.click()},className:"cursor-pointer",children:[u.jsx(de.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),p&&u.jsxs(Kn,{onClick:()=>{var $;D||($=S.current)==null||$.click()},className:`cursor-pointer ${D?"opacity-60 pointer-events-none":""}`,children:[u.jsx(de.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),u.jsx("div",{className:"flex-1",children:u.jsx(YT,{initialValue:i,editingMessageId:s,value:e,onValueChange:t,placeholder:s?"Edit your message...":a,isStreaming:l,disabled:c,onSend:q,onCancelEdit:r,onStop:o,allowEmptySend:O,textareaClassName:L,sendButtonClassName:f.sendButton})})]})]})}const XT=b.memo(qh),Gh={value:""};function Fr({className:e="",placeholder:t="Type your message...",autoFocus:n=!0,maxHeight:r=void 0,streamingDebounceMs:o=500,followNewMessages:s=!0,enableFileUpload:i=!0,enableExcelUpload:a=!1,enableMessageEditing:l=!0,showToolMessages:c=!0,toolConfig:d,toolRenderers:f,toolArtifactRenderers:m,payloadExtras:p={},customStyles:v={},messageCustomStyles:g,onMessageSent:x,onExcelUploadSuccess:y,onError:w,defaultMessage:C}){const{chatApi:E}=On(),T=E.baseUrl,{currentThreadId:S}=yr(),{threadId:k,messages:A,isLoading:j,navigateToCheckpoint:F,returnToLatest:D,checkpoint:B,checkpoints:G,interrupt:M,metadata:W,checkpointIndex:Y,respondToInterrupt:z}=ro(),{isStreaming:P,error:I,connectionState:K,submit:te,stop:O}=Ui(),q=k??S??null,L=(B==null?void 0:B.id)??null,$=(B==null?void 0:B.namespace)??null,X=(W==null?void 0:W.assemblingMessageId)??null;b.useEffect(()=>{console.log("[ChatInterface] streamingAssistantId changed:",{streamingAssistantId:X,isStreaming:P,assemblingMessageId:W==null?void 0:W.assemblingMessageId})},[X,P,W==null?void 0:W.assemblingMessageId]);const R=M,_=R?$i(R.id):null,U=_!==null?{type:"interrupt",id:_}:null,[Z,re]=b.useState(!1),[ce,Ne]=b.useState(!1);b.useEffect(()=>{R||re(!1)},[R]);const ye=b.useCallback(()=>{re(!0)},[]),Re=b.useCallback(()=>{re(!1)},[]),We=b.useCallback(ee=>{},[]),Fe=b.useCallback(ee=>ee.name!=="ask_user_choice",[]),Ye=d??{toolRenderers:f,toolArtifactRenderers:m,getToolExpandable:Fe},Ve=b.useCallback(async(ee,le,me)=>{try{ye(),await z(ee,le,me)}catch(Se){console.error("Failed to respond to interrupt:",Se)}finally{Re()}},[Re,ye,z]),tt=b.useCallback(()=>Ve(!0),[Ve]),gt=b.useCallback(()=>Ve(!1),[Ve]),at=b.useCallback((ee,le)=>Ve(!0,le),[Ve]),lt=!!R||Z,[Me,Ke]=b.useState(null),[je,qe]=b.useState(""),[Be,nt]=b.useState(null),[ct,ft]=b.useState(null),[yt,Tt]=b.useState(!1),[pt,At]=b.useState(null),xt=b.useRef(!1),[ht,zt]=b.useState(()=>Gh.value),Ht=b.useRef(ht),Oe=b.useRef(null),ze=b.useCallback(ee=>{Gh.value=ee,zt(ee)},[]),[kt,ut]=b.useState(!1),Pt=b.useRef(null),ge=b.useCallback(ee=>{ze(ee)},[ze]);b.useEffect(()=>{P||Ne(!1)},[P]),b.useEffect(()=>{W!=null&&W.assemblingMessageId&&Ne(!1)},[W==null?void 0:W.assemblingMessageId]);const[De,He]=b.useState("desktop");b.useEffect(()=>{const ee=()=>{const le=window.innerWidth;He(le<640?"phone":le<1024?"tablet":"desktop")};return ee(),window.addEventListener("resize",ee),()=>window.removeEventListener("resize",ee)},[]),b.useEffect(()=>{xt.current=!1},[q]),b.useEffect(()=>{Ht.current=ht},[ht]),b.useEffect(()=>{if(!Me){Oe.current=null;return}Oe.current===null&&(Oe.current=Ht.current),ze(je??"")},[je,Me,ze]),b.useEffect(()=>{if(C!==void 0){At(C);return}(async()=>{if(!T){At(null);return}try{const me=(await E.getAgent("default")).uiDefaultMessage||"";At(me||null)}catch(le){console.warn("Failed to fetch default message:",le),At(null)}})()},[E,T,C]),b.useEffect(()=>{I&&!yt&&(w==null||w(I))},[I,yt,w]);const st=async(ee,le)=>{const me=ee.trim();if(!(!me&&le.length===0))try{const Se=Me?(Be==null?void 0:Be.checkpointId)??L??void 0:L??void 0,be=Me?(Be==null?void 0:Be.checkpointNs)??$??void 0:$??void 0;await te({text:me||"",attachments:le,payload:p},{checkpointId:Se,checkpointNs:be,edit:!!Me,originalMessageId:Me??void 0}),x==null||x(me),Ne(!0),ze(""),ft(null),Ke(null),qe(""),nt(null)}catch(Se){const be=(Se==null?void 0:Se.message)||"Failed to send message";ft(be),w==null||w(be),Ne(!1)}},et=b.useCallback(async ee=>{await te({attachments:[ee],payload:p},{checkpointId:L??void 0,checkpointNs:$??void 0}),y==null||y({file:ee})},[L,$,p,y,te]),dt=b.useCallback((ee,le,me)=>{l&&(Oe.current=ht,Ke(ee),qe(le),ze(le),ft(null),nt({checkpointId:(me==null?void 0:me.checkpointId)??null,checkpointNs:(me==null?void 0:me.checkpointNs)??null}))},[ht,l,ze]),mt=b.useCallback(()=>{Ke(null),qe(""),nt(null),ft(null),ze(Oe.current??ht),Oe.current=null},[ht,ze]),J=b.useCallback((ee,le,me)=>{dt(ee,le,me)},[dt]),ae=b.useCallback(ee=>{let le=null;for(let Ie=ee-1;Ie>=0;Ie--)if(A[Ie].role==="user"){le=A[Ie];break}if(!le)return;const me=Array.isArray(le.content)?le.content:[],be=me.filter(Ie=>(Ie==null?void 0:Ie.type)==="text").map(Ie=>Ie.text).join("")||(()=>{try{return JSON.stringify(me,null,2)}catch{return String(me)}})();be&&te({text:be,payload:p},{checkpointId:L??void 0,checkpointNs:$??void 0,edit:!0,originalMessageId:le.id})},[A,te,L,$,p]),ie=b.useCallback(async ee=>{if(S){ut(!0);try{if(!ee){await D(),requestAnimationFrame(()=>{var Se;(Se=Pt.current)==null||Se.scrollToLatest()});return}const le=G.find(Se=>Se.checkpointId===ee),me=(le==null?void 0:le.checkpointNs)??null;await F(ee,me),requestAnimationFrame(()=>{var Se;(Se=Pt.current)==null||Se.scrollToTop()})}finally{ut(!1)}}},[G,S,Pt,F,D]),Ce=b.useCallback(async(ee,le,me)=>{await ie(me?null:ee)},[ie]),Ee=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${v.container||""}`,N=`flex-1 min-h-0 min-w-0 max-h-full w-full overflow-hidden overscroll-contain break-words break-anywhere p-4 ${R?"pb-32":""} bg-transparent ${v.messagesArea||""}`,Q=`relative flex-shrink-0 w-full border-t p-4 bg-transparent ${v.inputArea||""}`;return u.jsxs("div",{className:Ee,children:[!!I&&!yt&&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:I}),u.jsx(Xe,{variant:"ghost",size:"sm",onClick:()=>Tt(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:u.jsx(de.X,{size:16})})]}),u.jsxs("div",{className:`relative ${N}`,style:r?{maxHeight:r}:void 0,children:[u.jsx(Wa,{ref:Pt,className:"h-full",style:{height:"100%"},messages:A,isStreaming:P,streamingAssistantId:X,streamingDebounceMs:o,followNewMessages:s,layoutSize:De,enableMessageEditing:l,editingMessageId:Me,onEdit:J,onRegenerate:ae,onCancelEdit:mt,emptyMessage:pt??void 0,isNavigatingCheckpoint:kt,showToolMessages:c,toolConfig:Ye,checkpointIndex:Y,activeCheckpointId:L,onSelectCheckpoint:Ce,createSyntheticThinkingMessage:!0,forceSyntheticThinking:ce,getMessageCustomStyles:g,getInterruptOptions:We}),(K==="reconnecting"||K==="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(de.Loader2,{className:"h-3 w-3 animate-spin"}),K==="reconnecting"?"Reconnecting…":"Connecting…"]})}),K==="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"}),j&&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(de.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading messages…"})]}),kt&&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(de.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading checkpoint…"})]}),R&&U&&u.jsx("div",{className:"pointer-events-auto absolute inset-x-0 bottom-6 z-30 flex justify-center px-4",children:u.jsx("div",{className:"w-full max-w-3xl",children:u.jsx(va,{interruptPart:U,onApprove:tt,onReject:gt,onSelectAlternative:at,disabled:Z,isActive:!0,payload:R.value})})})]}),u.jsxs("div",{className:Q,children:[Me&&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(de.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:mt,className:"text-blue-600 hover:bg-blue-100",children:u.jsx(de.X,{size:16})})]})}),ct&&u.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:ct}),u.jsx(XT,{composerValue:ht,onComposerChange:ge,onSend:st,onCancelEdit:mt,onStop:O,editingMessageId:Me,editingInitialValue:je,placeholder:Me?"Edit your message...":t,isStreaming:P,disabled:lt,enableFileUpload:i,enableExcelUpload:a,onExcelUpload:et,onError:w,customStyles:v,textareaClassName:v.textarea||"",allowEmptySend:!1,inputError:ct})]})]})}var Yh=1,JT=.9,ZT=.8,QT=.17,bl=.1,wl=.999,ek=.9999,tk=.99,nk=/[\\\/_+.#"@\[\(\{&]/,rk=/[\\\/_+.#"@\[\(\{&]/g,ok=/[\s-]/,Xh=/[\s-]/g;function yl(e,t,n,r,o,s,i){if(s===t.length)return o===e.length?Yh:tk;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,f,m,p,v;c>=0;)f=yl(e,t,n,r,c+1,s+1,i),f>d&&(c===o?f*=Yh:nk.test(e.charAt(c-1))?(f*=ZT,p=e.slice(o,c-1).match(rk),p&&o>0&&(f*=Math.pow(wl,p.length))):ok.test(e.charAt(c-1))?(f*=JT,v=e.slice(o,c-1).match(Xh),v&&o>0&&(f*=Math.pow(wl,v.length))):(f*=QT,o>0&&(f*=Math.pow(wl,c-o))),e.charAt(c)!==t.charAt(s)&&(f*=ek)),(f<bl&&n.charAt(c-1)===r.charAt(s+1)||r.charAt(s+1)===r.charAt(s)&&n.charAt(c-1)!==r.charAt(s))&&(m=yl(e,t,n,r,c+1,s+2,i),m*bl>f&&(f=m*bl)),f>d&&(d=f),c=n.indexOf(l,c+1);return i[a]=d,d}function Jh(e){return e.toLowerCase().replace(Xh," ")}function sk(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,yl(e,t,Jh(e),Jh(t),0,0,{})}var Po='[cmdk-group=""]',Sl='[cmdk-group-items=""]',ik='[cmdk-group-heading=""]',Zh='[cmdk-item=""]',Qh=`${Zh}:not([aria-disabled="true"])`,Cl="cmdk-item-select",Br="data-value",ak=(e,t,n)=>sk(e,t,n),em=h.createContext(void 0),_o=()=>h.useContext(em),tm=h.createContext(void 0),Tl=()=>h.useContext(tm),nm=h.createContext(void 0),rm=h.forwardRef((e,t)=>{let n=zr(()=>{var O,q;return{search:"",value:(q=(O=e.value)!=null?O:e.defaultValue)!=null?q:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=zr(()=>new Set),o=zr(()=>new Map),s=zr(()=>new Map),i=zr(()=>new Set),a=om(e),{label:l,children:c,value:d,onValueChange:f,filter:m,shouldFilter:p,loop:v,disablePointerSelection:g=!1,vimBindings:x=!0,...y}=e,w=jt(),C=jt(),E=jt(),T=h.useRef(null),S=vk();hr(()=>{if(d!==void 0){let O=d.trim();n.current.value=O,k.emit()}},[d]),hr(()=>{S(6,G)},[]);let k=h.useMemo(()=>({subscribe:O=>(i.current.add(O),()=>i.current.delete(O)),snapshot:()=>n.current,setState:(O,q,L)=>{var $,X,R,_;if(!Object.is(n.current[O],q)){if(n.current[O]=q,O==="search")B(),F(),S(1,D);else if(O==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let U=document.getElementById(E);U?U.focus():($=document.getElementById(w))==null||$.focus()}if(S(7,()=>{var U;n.current.selectedItemId=(U=M())==null?void 0:U.id,k.emit()}),L||S(5,G),((X=a.current)==null?void 0:X.value)!==void 0){let U=q??"";(_=(R=a.current).onValueChange)==null||_.call(R,U);return}}k.emit()}},emit:()=>{i.current.forEach(O=>O())}}),[]),A=h.useMemo(()=>({value:(O,q,L)=>{var $;q!==(($=s.current.get(O))==null?void 0:$.value)&&(s.current.set(O,{value:q,keywords:L}),n.current.filtered.items.set(O,j(q,L)),S(2,()=>{F(),k.emit()}))},item:(O,q)=>(r.current.add(O),q&&(o.current.has(q)?o.current.get(q).add(O):o.current.set(q,new Set([O]))),S(3,()=>{B(),F(),n.current.value||D(),k.emit()}),()=>{s.current.delete(O),r.current.delete(O),n.current.filtered.items.delete(O);let L=M();S(4,()=>{B(),(L==null?void 0:L.getAttribute("id"))===O&&D(),k.emit()})}),group:O=>(o.current.has(O)||o.current.set(O,new Set),()=>{s.current.delete(O),o.current.delete(O)}),filter:()=>a.current.shouldFilter,label:l||e["aria-label"],getDisablePointerSelection:()=>a.current.disablePointerSelection,listId:w,inputId:E,labelId:C,listInnerRef:T}),[]);function j(O,q){var L,$;let X=($=(L=a.current)==null?void 0:L.filter)!=null?$:ak;return O?X(O,n.current.search,q):0}function F(){if(!n.current.search||a.current.shouldFilter===!1)return;let O=n.current.filtered.items,q=[];n.current.filtered.groups.forEach($=>{let X=o.current.get($),R=0;X.forEach(_=>{let U=O.get(_);R=Math.max(U,R)}),q.push([$,R])});let L=T.current;W().sort(($,X)=>{var R,_;let U=$.getAttribute("id"),Z=X.getAttribute("id");return((R=O.get(Z))!=null?R:0)-((_=O.get(U))!=null?_:0)}).forEach($=>{let X=$.closest(Sl);X?X.appendChild($.parentElement===X?$:$.closest(`${Sl} > *`)):L.appendChild($.parentElement===L?$:$.closest(`${Sl} > *`))}),q.sort(($,X)=>X[1]-$[1]).forEach($=>{var X;let R=(X=T.current)==null?void 0:X.querySelector(`${Po}[${Br}="${encodeURIComponent($[0])}"]`);R==null||R.parentElement.appendChild(R)})}function D(){let O=W().find(L=>L.getAttribute("aria-disabled")!=="true"),q=O==null?void 0:O.getAttribute(Br);k.setState("value",q||void 0)}function B(){var O,q,L,$;if(!n.current.search||a.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let X=0;for(let R of r.current){let _=(q=(O=s.current.get(R))==null?void 0:O.value)!=null?q:"",U=($=(L=s.current.get(R))==null?void 0:L.keywords)!=null?$:[],Z=j(_,U);n.current.filtered.items.set(R,Z),Z>0&&X++}for(let[R,_]of o.current)for(let U of _)if(n.current.filtered.items.get(U)>0){n.current.filtered.groups.add(R);break}n.current.filtered.count=X}function G(){var O,q,L;let $=M();$&&(((O=$.parentElement)==null?void 0:O.firstChild)===$&&((L=(q=$.closest(Po))==null?void 0:q.querySelector(ik))==null||L.scrollIntoView({block:"nearest"})),$.scrollIntoView({block:"nearest"}))}function M(){var O;return(O=T.current)==null?void 0:O.querySelector(`${Zh}[aria-selected="true"]`)}function W(){var O;return Array.from(((O=T.current)==null?void 0:O.querySelectorAll(Qh))||[])}function Y(O){let q=W()[O];q&&k.setState("value",q.getAttribute(Br))}function z(O){var q;let L=M(),$=W(),X=$.findIndex(_=>_===L),R=$[X+O];(q=a.current)!=null&&q.loop&&(R=X+O<0?$[$.length-1]:X+O===$.length?$[0]:$[X+O]),R&&k.setState("value",R.getAttribute(Br))}function P(O){let q=M(),L=q==null?void 0:q.closest(Po),$;for(;L&&!$;)L=O>0?gk(L,Po):xk(L,Po),$=L==null?void 0:L.querySelector(Qh);$?k.setState("value",$.getAttribute(Br)):z(O)}let I=()=>Y(W().length-1),K=O=>{O.preventDefault(),O.metaKey?I():O.altKey?P(1):z(1)},te=O=>{O.preventDefault(),O.metaKey?Y(0):O.altKey?P(-1):z(-1)};return h.createElement(he.div,{ref:t,tabIndex:-1,...y,"cmdk-root":"",onKeyDown:O=>{var q;(q=y.onKeyDown)==null||q.call(y,O);let L=O.nativeEvent.isComposing||O.keyCode===229;if(!(O.defaultPrevented||L))switch(O.key){case"n":case"j":{x&&O.ctrlKey&&K(O);break}case"ArrowDown":{K(O);break}case"p":case"k":{x&&O.ctrlKey&&te(O);break}case"ArrowUp":{te(O);break}case"Home":{O.preventDefault(),Y(0);break}case"End":{O.preventDefault(),I();break}case"Enter":{O.preventDefault();let $=M();if($){let X=new Event(Cl);$.dispatchEvent(X)}}}}},h.createElement("label",{"cmdk-label":"",htmlFor:A.inputId,id:A.labelId,style:wk},l),Qs(e,O=>h.createElement(tm.Provider,{value:k},h.createElement(em.Provider,{value:A},O))))}),lk=h.forwardRef((e,t)=>{var n,r;let o=jt(),s=h.useRef(null),i=h.useContext(nm),a=_o(),l=om(e),c=(r=(n=l.current)==null?void 0:n.forceMount)!=null?r:i==null?void 0:i.forceMount;hr(()=>{if(!c)return a.item(o,i==null?void 0:i.id)},[c]);let d=sm(o,s,[e.value,e.children,s],e.keywords),f=Tl(),m=qn(S=>S.value&&S.value===d.current),p=qn(S=>c||a.filter()===!1?!0:S.search?S.filtered.items.get(o)>0:!0);h.useEffect(()=>{let S=s.current;if(!(!S||e.disabled))return S.addEventListener(Cl,v),()=>S.removeEventListener(Cl,v)},[p,e.onSelect,e.disabled]);function v(){var S,k;g(),(k=(S=l.current).onSelect)==null||k.call(S,d.current)}function g(){f.setState("value",d.current,!0)}if(!p)return null;let{disabled:x,value:y,onSelect:w,forceMount:C,keywords:E,...T}=e;return h.createElement(he.div,{ref:Dn(s,t),...T,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)}),ck=h.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:o,...s}=e,i=jt(),a=h.useRef(null),l=h.useRef(null),c=jt(),d=_o(),f=qn(p=>o||d.filter()===!1?!0:p.search?p.filtered.groups.has(i):!0);hr(()=>d.group(i),[]),sm(i,a,[e.value,e.heading,l]);let m=h.useMemo(()=>({id:i,forceMount:o}),[o]);return h.createElement(he.div,{ref:Dn(a,t),...s,"cmdk-group":"",role:"presentation",hidden:f?void 0:!0},n&&h.createElement("div",{ref:l,"cmdk-group-heading":"","aria-hidden":!0,id:c},n),Qs(e,p=>h.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?c:void 0},h.createElement(nm.Provider,{value:m},p))))}),uk=h.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,o=h.useRef(null),s=qn(i=>!i.search);return!n&&!s?null:h.createElement(he.div,{ref:Dn(o,t),...r,"cmdk-separator":"",role:"separator"})}),dk=h.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,o=e.value!=null,s=Tl(),i=qn(c=>c.search),a=qn(c=>c.selectedItemId),l=_o();return h.useEffect(()=>{e.value!=null&&s.setState("search",e.value)},[e.value]),h.createElement(he.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)}})}),fk=h.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...o}=e,s=h.useRef(null),i=h.useRef(null),a=qn(c=>c.selectedItemId),l=_o();return h.useEffect(()=>{if(i.current&&s.current){let c=i.current,d=s.current,f,m=new ResizeObserver(()=>{f=requestAnimationFrame(()=>{let p=c.offsetHeight;d.style.setProperty("--cmdk-list-height",p.toFixed(1)+"px")})});return m.observe(c),()=>{cancelAnimationFrame(f),m.unobserve(c)}}},[]),h.createElement(he.div,{ref:Dn(s,t),...o,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":a,"aria-label":r,id:l.listId},Qs(e,c=>h.createElement("div",{ref:Dn(i,l.listInnerRef),"cmdk-list-sizer":""},c)))}),pk=h.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:o,contentClassName:s,container:i,...a}=e;return h.createElement(ia,{open:n,onOpenChange:r},h.createElement(aa,{container:i},h.createElement(io,{"cmdk-overlay":"",className:o}),h.createElement(ao,{"aria-label":e.label,"cmdk-dialog":"",className:s},h.createElement(rm,{ref:t,...a}))))}),hk=h.forwardRef((e,t)=>qn(n=>n.filtered.count===0)?h.createElement(he.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),mk=h.forwardRef((e,t)=>{let{progress:n,children:r,label:o="Loading...",...s}=e;return h.createElement(he.div,{ref:t,...s,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":o},Qs(e,i=>h.createElement("div",{"aria-hidden":!0},i)))}),Gt=Object.assign(rm,{List:fk,Item:lk,Input:dk,Group:ck,Separator:uk,Dialog:pk,Empty:hk,Loading:mk});function gk(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function xk(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function om(e){let t=h.useRef(e);return hr(()=>{t.current=e}),t}var hr=typeof window>"u"?h.useEffect:h.useLayoutEffect;function zr(e){let t=h.useRef();return t.current===void 0&&(t.current=e()),t}function qn(e){let t=Tl(),n=()=>e(t.snapshot());return h.useSyncExternalStore(t.subscribe,n,n)}function sm(e,t,n,r=[]){let o=h.useRef(),s=_o();return hr(()=>{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(Br,a),o.current=a}),o}var vk=()=>{let[e,t]=h.useState(),n=zr(()=>new Map);return hr(()=>{n.current.forEach(r=>r()),n.current=new Map},[e]),(r,o)=>{n.current.set(r,o),t({})}};function bk(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function Qs({asChild:e,children:t},n){return e&&h.isValidElement(t)?h.cloneElement(bk(t),{ref:t.ref},n(t.props.children)):n(t)}var wk={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const kl=h.forwardRef(({className:e,...t},n)=>u.jsx(Gt,{ref:n,className:oe("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));kl.displayName=Gt.displayName;const El=h.forwardRef(({className:e,...t},n)=>u.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[u.jsx(de.Search,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),u.jsx(Gt.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})]}));El.displayName=Gt.Input.displayName;const Il=h.forwardRef(({className:e,...t},n)=>u.jsx(Gt.List,{ref:n,className:oe("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));Il.displayName=Gt.List.displayName;const Nl=h.forwardRef((e,t)=>u.jsx(Gt.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));Nl.displayName=Gt.Empty.displayName;const Al=h.forwardRef(({className:e,...t},n)=>u.jsx(Gt.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}));Al.displayName=Gt.Group.displayName;const yk=h.forwardRef(({className:e,...t},n)=>u.jsx(Gt.Separator,{ref:n,className:oe("-mx-1 h-px bg-border",e),...t}));yk.displayName=Gt.Separator.displayName;const jl=h.forwardRef(({className:e,...t},n)=>u.jsx(Gt.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}));jl.displayName=Gt.Item.displayName;function Pl(e,[t,n]){return Math.min(n,Math.max(t,e))}function Sk(e,t){return h.useReducer((n,r)=>t[n][r]??n,e)}var _l="ScrollArea",[im,VN]=nn(_l),[Ck,an]=im(_l),am=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,l]=h.useState(null),[c,d]=h.useState(null),[f,m]=h.useState(null),[p,v]=h.useState(null),[g,x]=h.useState(null),[y,w]=h.useState(0),[C,E]=h.useState(0),[T,S]=h.useState(!1),[k,A]=h.useState(!1),j=Le(t,D=>l(D)),F=Os(o);return u.jsx(Ck,{scope:n,type:r,dir:F,scrollHideDelay:s,scrollArea:a,viewport:c,onViewportChange:d,content:f,onContentChange:m,scrollbarX:p,onScrollbarXChange:v,scrollbarXEnabled:T,onScrollbarXEnabledChange:S,scrollbarY:g,onScrollbarYChange:x,scrollbarYEnabled:k,onScrollbarYEnabledChange:A,onCornerWidthChange:w,onCornerHeightChange:E,children:u.jsx(he.div,{dir:F,...i,ref:j,style:{position:"relative","--radix-scroll-area-corner-width":y+"px","--radix-scroll-area-corner-height":C+"px",...e.style}})})});am.displayName=_l;var lm="ScrollAreaViewport",cm=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=an(lm,n),a=h.useRef(null),l=Le(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(he.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})})]})});cm.displayName=lm;var En="ScrollAreaScrollbar",Rl=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=an(En,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:i}=o,a=e.orientation==="horizontal";return h.useEffect(()=>(a?s(!0):i(!0),()=>{a?s(!1):i(!1)}),[a,s,i]),o.type==="hover"?u.jsx(Tk,{...r,ref:t,forceMount:n}):o.type==="scroll"?u.jsx(kk,{...r,ref:t,forceMount:n}):o.type==="auto"?u.jsx(um,{...r,ref:t,forceMount:n}):o.type==="always"?u.jsx(Ml,{...r,ref:t}):null});Rl.displayName=En;var Tk=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=an(En,e.__scopeScrollArea),[s,i]=h.useState(!1);return h.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($t,{present:n||s,children:u.jsx(um,{"data-state":s?"visible":"hidden",...r,ref:t})})}),kk=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=an(En,e.__scopeScrollArea),s=e.orientation==="horizontal",i=ri(()=>l("SCROLL_END"),100),[a,l]=Sk("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 h.useEffect(()=>{if(a==="idle"){const c=window.setTimeout(()=>l("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(c)}},[a,o.scrollHideDelay,l]),h.useEffect(()=>{const c=o.viewport,d=s?"scrollLeft":"scrollTop";if(c){let f=c[d];const m=()=>{const p=c[d];f!==p&&(l("SCROLL"),i()),f=p};return c.addEventListener("scroll",m),()=>c.removeEventListener("scroll",m)}},[o.viewport,s,l,i]),u.jsx($t,{present:n||a!=="hidden",children:u.jsx(Ml,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:ue(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:ue(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),um=h.forwardRef((e,t)=>{const n=an(En,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=h.useState(!1),a=e.orientation==="horizontal",l=ri(()=>{if(n.viewport){const c=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?c:d)}},10);return Hr(n.viewport,l),Hr(n.content,l),u.jsx($t,{present:r||s,children:u.jsx(Ml,{"data-state":s?"visible":"hidden",...o,ref:t})})}),Ml=h.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=an(En,e.__scopeScrollArea),s=h.useRef(null),i=h.useRef(0),[a,l]=h.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),c=mm(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 f(m,p){return Pk(m,i.current,a,p)}return n==="horizontal"?u.jsx(Ek,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollLeft,p=gm(m,a,o.dir);s.current.style.transform=`translate3d(${p}px, 0, 0)`}},onWheelScroll:m=>{o.viewport&&(o.viewport.scrollLeft=m)},onDragScroll:m=>{o.viewport&&(o.viewport.scrollLeft=f(m,o.dir))}}):n==="vertical"?u.jsx(Ik,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollTop,p=gm(m,a);s.current.style.transform=`translate3d(0, ${p}px, 0)`}},onWheelScroll:m=>{o.viewport&&(o.viewport.scrollTop=m)},onDragScroll:m=>{o.viewport&&(o.viewport.scrollTop=f(m))}}):null}),Ek=h.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=an(En,e.__scopeScrollArea),[i,a]=h.useState(),l=h.useRef(null),c=Le(t,l,s.onScrollbarXChange);return h.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(fm,{"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":ni(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.x),onDragScroll:d=>e.onDragScroll(d.x),onWheelScroll:(d,f)=>{if(s.viewport){const m=s.viewport.scrollLeft+d.deltaX;e.onWheelScroll(m),vm(m,f)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:l.current.clientWidth,paddingStart:ti(i.paddingLeft),paddingEnd:ti(i.paddingRight)}})}})}),Ik=h.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=an(En,e.__scopeScrollArea),[i,a]=h.useState(),l=h.useRef(null),c=Le(t,l,s.onScrollbarYChange);return h.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(fm,{"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":ni(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.y),onDragScroll:d=>e.onDragScroll(d.y),onWheelScroll:(d,f)=>{if(s.viewport){const m=s.viewport.scrollTop+d.deltaY;e.onWheelScroll(m),vm(m,f)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:l.current.clientHeight,paddingStart:ti(i.paddingTop),paddingEnd:ti(i.paddingBottom)}})}})}),[Nk,dm]=im(En),fm=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:l,onDragScroll:c,onWheelScroll:d,onResize:f,...m}=e,p=an(En,n),[v,g]=h.useState(null),x=Le(t,j=>g(j)),y=h.useRef(null),w=h.useRef(""),C=p.viewport,E=r.content-r.viewport,T=bt(d),S=bt(l),k=ri(f,10);function A(j){if(y.current){const F=j.clientX-y.current.left,D=j.clientY-y.current.top;c({x:F,y:D})}}return h.useEffect(()=>{const j=F=>{const D=F.target;(v==null?void 0:v.contains(D))&&T(F,E)};return document.addEventListener("wheel",j,{passive:!1}),()=>document.removeEventListener("wheel",j,{passive:!1})},[C,v,E,T]),h.useEffect(S,[r,S]),Hr(v,k),Hr(p.content,k),u.jsx(Nk,{scope:n,scrollbar:v,hasThumb:o,onThumbChange:bt(s),onThumbPointerUp:bt(i),onThumbPositionChange:S,onThumbPointerDown:bt(a),children:u.jsx(he.div,{...m,ref:x,style:{position:"absolute",...m.style},onPointerDown:ue(e.onPointerDown,j=>{j.button===0&&(j.target.setPointerCapture(j.pointerId),y.current=v.getBoundingClientRect(),w.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",p.viewport&&(p.viewport.style.scrollBehavior="auto"),A(j))}),onPointerMove:ue(e.onPointerMove,A),onPointerUp:ue(e.onPointerUp,j=>{const F=j.target;F.hasPointerCapture(j.pointerId)&&F.releasePointerCapture(j.pointerId),document.body.style.webkitUserSelect=w.current,p.viewport&&(p.viewport.style.scrollBehavior=""),y.current=null})})})}),ei="ScrollAreaThumb",pm=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=dm(ei,e.__scopeScrollArea);return u.jsx($t,{present:n||o.hasThumb,children:u.jsx(Ak,{ref:t,...r})})}),Ak=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=an(ei,n),i=dm(ei,n),{onThumbPositionChange:a}=i,l=Le(t,f=>i.onThumbChange(f)),c=h.useRef(void 0),d=ri(()=>{c.current&&(c.current(),c.current=void 0)},100);return h.useEffect(()=>{const f=s.viewport;if(f){const m=()=>{if(d(),!c.current){const p=_k(f,a);c.current=p,a()}};return a(),f.addEventListener("scroll",m),()=>f.removeEventListener("scroll",m)}},[s.viewport,d,a]),u.jsx(he.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:ue(e.onPointerDownCapture,f=>{const p=f.target.getBoundingClientRect(),v=f.clientX-p.left,g=f.clientY-p.top;i.onThumbPointerDown({x:v,y:g})}),onPointerUp:ue(e.onPointerUp,i.onThumbPointerUp)})});pm.displayName=ei;var Ol="ScrollAreaCorner",hm=h.forwardRef((e,t)=>{const n=an(Ol,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?u.jsx(jk,{...e,ref:t}):null});hm.displayName=Ol;var jk=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=an(Ol,n),[s,i]=h.useState(0),[a,l]=h.useState(0),c=!!(s&&a);return Hr(o.scrollbarX,()=>{var f;const d=((f=o.scrollbarX)==null?void 0:f.offsetHeight)||0;o.onCornerHeightChange(d),l(d)}),Hr(o.scrollbarY,()=>{var f;const d=((f=o.scrollbarY)==null?void 0:f.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),c?u.jsx(he.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 ti(e){return e?parseInt(e,10):0}function mm(e,t){const n=e/t;return isNaN(n)?0:n}function ni(e){const t=mm(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function Pk(e,t,n,r="ltr"){const o=ni(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,f=r==="ltr"?[0,d]:[d*-1,0];return xm([l,c],f)(e)}function gm(e,t,n="ltr"){const r=ni(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=Pl(e,l);return xm([0,i],[0,a])(c)}function xm(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 vm(e,t){return e>0&&e<t}var _k=(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 ri(e,t){const n=bt(e),r=h.useRef(0);return h.useEffect(()=>()=>window.clearTimeout(r.current),[]),h.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function Hr(e,t){const n=bt(t);It(()=>{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 bm=am,Rk=cm,Mk=hm;const Dl=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(bm,{ref:r,className:oe("relative overflow-hidden",e),...n,children:[u.jsx(Rk,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),u.jsx(wm,{}),u.jsx(Mk,{})]}));Dl.displayName=bm.displayName;const wm=h.forwardRef(({className:e,orientation:t="vertical",...n},r)=>u.jsx(Rl,{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(pm,{className:"relative flex-1 rounded-full bg-border"})}));wm.displayName=Rl.displayName;const Ll=h.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}));Ll.displayName="Input";const Ok="group relative p-3 rounded-lg cursor-pointer transition-colors border text-gray-900 dark:text-slate-100",Dk="bg-slate-700 border-slate-600 hover:bg-slate-600",Lk="bg-slate-600 border-slate-500";function $l({thread:e,isActive:t,editingThreadId:n,editingTitle:r,onSelect:o,onStartEditing:s,onEditingTitleChange:i,onSaveEditing:a,onCancelEditing:l,onShare:c,onDelete:d,showEditTitle:f,showDeleteButton:m,formatDate:p,getDisplayThreadTitle:v,secondaryLine:g,itemClassName:x,activeItemClassName:y}){var T;const w=n===e.threadId,C=t?`${y??Lk}`:`${x??Dk}`,E=S=>{S.stopPropagation(),o(e.threadId)};return u.jsxs("div",{onClick:E,className:`${Ok} ${C}`,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:S=>S.stopPropagation(),children:[u.jsx(Ll,{value:r,onChange:S=>i(S.target.value),onKeyDown:S=>{S.key==="Enter"?a(e.threadId):S.key==="Escape"&&l()},className:"h-6 text-sm",autoFocus:!0}),u.jsx(Xe,{variant:"ghost",size:"sm",onClick:()=>a(e.threadId),className:"h-6 w-6 p-0",children:u.jsx(de.Check,{size:12})}),u.jsx(Xe,{variant:"ghost",size:"sm",onClick:l,className:"h-6 w-6 p-0",children:u.jsx(de.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(de.Calendar,{size:10}),u.jsx("span",{children:p(e.updatedAt||e.createdAt)}),((T=e.project)==null?void 0:T.name)&&u.jsx("span",{className:"flex items-center gap-1.5 before:content-['•'] before:text-gray-300 dark:before:text-slate-600",children:u.jsx("span",{className:"truncate max-w-[100px]",children:e.project.name})})]}),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(Js,{children:[u.jsx(Zs,{asChild:!0,children:u.jsx(Xe,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",children:u.jsx(de.MoreHorizontal,{size:12})})}),u.jsxs(jo,{align:"end",sideOffset:6,className:"w-44",style:{zIndex:9999},children:[u.jsxs(Kn,{onClick:S=>{S.preventDefault(),c(e.threadId)},children:[u.jsx(de.Share2,{className:"mr-2 h-4 w-4"}),"Share thread"]}),f&&n!==e.threadId&&u.jsxs(Kn,{onClick:S=>{S.preventDefault(),s(e,S)},children:[u.jsx(de.Edit3,{className:"mr-2 h-4 w-4"}),"Rename"]}),m&&d&&u.jsxs(Kn,{className:"text-red-400 hover:text-red-300",onClick:S=>{S.preventDefault(),d(e.threadId,S)},children:[u.jsx(de.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"})]})}var oi="Collapsible",[$k,KN]=nn(oi),[Fk,Fl]=$k(oi),ym=h.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:o,disabled:s,onOpenChange:i,...a}=e,[l,c]=In({prop:r,defaultProp:o??!1,onChange:i,caller:oi});return u.jsx(Fk,{scope:n,disabled:s,contentId:jt(),open:l,onOpenToggle:h.useCallback(()=>c(d=>!d),[c]),children:u.jsx(he.div,{"data-state":zl(l),"data-disabled":s?"":void 0,...a,ref:t})})});ym.displayName=oi;var Sm="CollapsibleTrigger",Cm=h.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,o=Fl(Sm,n);return u.jsx(he.button,{type:"button","aria-controls":o.contentId,"aria-expanded":o.open||!1,"data-state":zl(o.open),"data-disabled":o.disabled?"":void 0,disabled:o.disabled,...r,ref:t,onClick:ue(e.onClick,o.onOpenToggle)})});Cm.displayName=Sm;var Bl="CollapsibleContent",Tm=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Fl(Bl,e.__scopeCollapsible);return u.jsx($t,{present:n||o.open,children:({present:s})=>u.jsx(Bk,{...r,ref:t,present:s})})});Tm.displayName=Bl;var Bk=h.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:o,...s}=e,i=Fl(Bl,n),[a,l]=h.useState(r),c=h.useRef(null),d=Le(t,c),f=h.useRef(0),m=f.current,p=h.useRef(0),v=p.current,g=i.open||a,x=h.useRef(g),y=h.useRef(void 0);return h.useEffect(()=>{const w=requestAnimationFrame(()=>x.current=!1);return()=>cancelAnimationFrame(w)},[]),It(()=>{const w=c.current;if(w){y.current=y.current||{transitionDuration:w.style.transitionDuration,animationName:w.style.animationName},w.style.transitionDuration="0s",w.style.animationName="none";const C=w.getBoundingClientRect();f.current=C.height,p.current=C.width,x.current||(w.style.transitionDuration=y.current.transitionDuration,w.style.animationName=y.current.animationName),l(r)}},[i.open,r]),u.jsx(he.div,{"data-state":zl(i.open),"data-disabled":i.disabled?"":void 0,id:i.contentId,hidden:!g,...s,ref:d,style:{"--radix-collapsible-content-height":m?`${m}px`:void 0,"--radix-collapsible-content-width":v?`${v}px`:void 0,...e.style},children:g&&o})});function zl(e){return e?"open":"closed"}var zk=ym;const Hk=zk,Uk=Cm,Wk=Tm,km=25,Em="thread-manager-view",Vk=e=>e==="default"||e==="shared",Kk=()=>{if(typeof window>"u")return null;try{const e=window.localStorage.getItem(Em);if(Vk(e))return e}catch{}return null};function Im({defaultView:e}={}){const[t,n]=b.useState(()=>Kk()??e??"default");b.useEffect(()=>{if(!(typeof window>"u"))try{window.localStorage.setItem(Em,t)}catch{}},[t]);const r=b.useCallback(o=>{n(o)},[]);return{view:t,setView:r}}const qk=[{key:"default",label:"My chats"},{key:"shared",label:"Shared with you"}];function si({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:f,defaultView:m,onViewChange:p,viewOptions:v,viewState:g,showHeader:x=!0,shareTargets:y,isLoadingShareTargets:w,shareTargetFilter:C,groupBy:E}){const{chatApi:T,authApi:S}=On(),{threads:k,sharedThreads:A,currentThreadId:j,setCurrentThreadId:F,isLoading:D,isLoadingSharedThreads:B,actions:G,shareInFlight:M,shareStatus:W,clearShareStatus:Y}=yr(),{createThread:z,deleteThread:P,renameThread:I,shareThread:K}=G,{loadThread:te}=ro(),O=i??j,[q,L]=b.useState(Array.isArray(k)?k:[]),$=b.useRef(q.length>0),X=b.useRef(null),R=b.useRef(0),[_,U]=b.useState(null),[Z,re]=b.useState(""),[ce,Ne]=b.useState(!1),[ye,Re]=b.useState(!1),[We,Fe]=b.useState(null),[Ye,Ve]=b.useState(""),[tt,gt]=b.useState([]),[at,lt]=b.useState(!1);b.useEffect(()=>{ye&&!y&&tt.length===0&&!at&&(async()=>{lt(!0);try{const ie=(await S.listUsers()).filter(Ce=>Ce.id||Ce.user_id).map(Ce=>({type:"user",value:Ce.user_id||Ce.id||"",id:Ce.user_id||Ce.id||"",label:Ce.name||Ce.username||Ce.email||"Unknown User",secondaryLabel:Ce.name||Ce.username?Ce.email:void 0}));gt(ie)}catch(ae){console.error("Failed to load users for sharing:",ae)}finally{lt(!1)}})()},[ye,y,tt.length,at,T]);const Me=y??tt,Ke=w??at,je=v&&v.length>0?v:qk,qe=Im({defaultView:m}),Be=g??qe,nt=f??Be.view,ct=b.useCallback(J=>{f||Be.setView(J),p==null||p(J)},[f,p,Be]),ft=je.find(J=>J.key===nt)??je[0],yt=J=>{Fe(J),Ve(""),Re(!0)},Tt=()=>{Re(!1),Fe(null),Ve(""),Y()},pt=b.useCallback(async J=>{if(!(!We||M)&&J.id)try{await K(We,J.id),setTimeout(()=>Tt(),600)}catch(ae){console.error("Failed to share thread:",ae)}},[Tt,M,We,K]),At=b.useMemo(()=>{const J=Me,ae=Ye.trim().toLowerCase();return ae?C?J.filter(ie=>C(ie,ae)):J.filter(ie=>`${ie.label} ${ie.secondaryLabel??""}`.toLowerCase().includes(ae)):J},[y,Ye,C]),xt=nt==="shared",ht=xt?A:q,zt=b.useMemo(()=>{if(!E||xt)return null;const J={},ae="Default";return ht.forEach(ie=>{var Ee,N;let Ce=ae;E==="project"?Ce=((Ee=ie.project)==null?void 0:Ee.name)||((N=ie.project)==null?void 0:N.id)||ae:Ce=ie[E]||ae,J[Ce]||(J[Ce]=[]),J[Ce].push(ie)}),Object.keys(J).forEach(ie=>{J[ie].sort((Ce,Ee)=>new Date(Ee.updatedAt||Ee.createdAt||"").getTime()-new Date(Ce.updatedAt||Ce.createdAt||"").getTime())}),J},[ht,E,xt]),Ht=xt?B:D,Oe=xt?"No shared conversations yet":"No conversations yet",ze=J=>{const ae=J.sharedAt?` • ${et(J.sharedAt)}`:"";return`Shared by ${J.sharedByUserId}${ae}`},kt=J=>"sharedByUserId"in J;b.useEffect(()=>{const J=Array.isArray(k)?k:[];if(J.length>0){$.current=!0,L(J);return}D||($.current=!1,L(J))},[k,D]),b.useEffect(()=>{if(!X.current)return;const J=X.current.querySelector("[data-radix-scroll-area-viewport]");if(!J)return;let ae=null,ie=null;return ae=requestAnimationFrame(()=>{ie=requestAnimationFrame(()=>{J.scrollTop=R.current})}),()=>{ae!==null&&cancelAnimationFrame(ae),ie!==null&&cancelAnimationFrame(ie)}},[q]);const ut=async J=>{try{F(J),await te(J),a==null||a(J),l==null||l(J)}catch(ae){console.error("Failed to select thread:",ae)}},Pt=async()=>{try{Ne(!0);const J=await z();J&&(c==null||c(J),a==null||a(J))}catch(J){console.error("Failed to create thread:",J)}finally{Ne(!1)}},ge=async(J,ae)=>{if(ae.stopPropagation(),!!confirm("Delete this thread?")){if(X.current){const ie=X.current.querySelector("[data-radix-scroll-area-viewport]");ie&&(R.current=ie.scrollTop)}try{await P(J),d==null||d(J)}catch(ie){console.error("Failed to delete thread:",ie)}}},De=(J,ae)=>{ae.stopPropagation(),U(J.threadId),re(J.title||`Thread ${J.threadId.slice(0,8)}`)},He=async J=>{if(Z.trim())try{await I(J,Z.trim()),U(null),re("")}catch(ae){console.error("Failed to update title:",ae)}},st=()=>{U(null),re("")},et=J=>{if(!J)return"";try{const ae=J.endsWith("Z")||J.includes("+")?J:`${J}Z`,ie=new Date(ae),Ee=new Date().getTime()-ie.getTime(),N=Math.floor(Ee/(1e3*60*60*24));return N===0?ie.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):N===1?"Yesterday":N<7?`${N} days ago`:ie.toLocaleDateString()}catch{return""}},dt=J=>J.title||`Thread ${J.threadId.slice(0,8)}`,mt=J=>{const ae=dt(J);return ae.length<=km?ae:`${ae.slice(0,km)}...`};return u.jsxs("div",{className:`thread-manager-root 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:Pt,disabled:ce||D,className:s.createButton||"px-3 py-2 gap-1",size:"sm",variant:"ghost",title:ce?"Creating...":"New Chat",children:[u.jsx(de.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(Js,{children:[u.jsx(Zs,{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:ft.label})}),u.jsx(jo,{align:"start",sideOffset:6,className:"w-40",children:je.map(J=>u.jsxs(Kn,{className:"justify-between text-[12px]",onClick:ae=>{ae.preventDefault(),ct(J.key)},children:[u.jsx("span",{children:J.label}),nt===J.key&&u.jsx(de.Check,{className:"h-3 w-3"})]},J.key))})]})]})]}),u.jsx(Dl,{ref:X,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:Ht?u.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-8 text-slate-400",children:[u.jsx(de.Loader2,{className:"h-5 w-5 animate-spin"}),u.jsx("span",{className:"text-sm",children:"Loading threads…"})]}):ht.length===0?u.jsxs("div",{className:"text-center py-8 text-slate-400",children:[u.jsx(de.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:Oe})]}):zt?Object.entries(zt).sort(([J],[ae])=>{const ie="Default";return J===ie?1:ae===ie?-1:J.localeCompare(ae)}).map(([J,ae])=>u.jsxs(Hk,{defaultOpen:!0,className:"group/collapsible",children:[u.jsxs(Uk,{className:"flex items-center w-full px-2 py-1 text-xs font-medium text-slate-500 hover:text-slate-800 dark:hover:text-slate-200",children:[u.jsx(de.ChevronRight,{className:"w-3 h-3 mr-1 transition-transform group-data-[state=open]/collapsible:rotate-90"}),J,u.jsx("span",{className:"ml-auto text-[10px] text-slate-400",children:ae.length})]}),u.jsx(Wk,{children:u.jsx("div",{className:"pl-2 border-l border-slate-100 dark:border-slate-800 ml-1.5 my-1 space-y-1",children:ae.map(ie=>u.jsx($l,{thread:ie,isActive:O===ie.threadId,editingThreadId:_,editingTitle:Z,onSelect:ut,onStartEditing:De,onEditingTitleChange:Ce=>re(Ce),onSaveEditing:He,onCancelEditing:st,onShare:()=>yt(ie.threadId),onDelete:ge,showEditTitle:r,showDeleteButton:n,formatDate:et,getDisplayThreadTitle:mt,itemClassName:s.threadItem,activeItemClassName:s.activeThread},ie.threadId))})})]},J)):ht.slice().sort((J,ae)=>new Date(ae.updatedAt||ae.createdAt||"").getTime()-new Date(J.updatedAt||J.createdAt||"").getTime()).map(J=>u.jsx($l,{thread:J,isActive:O===J.threadId,editingThreadId:_,editingTitle:Z,onSelect:ut,onStartEditing:De,onEditingTitleChange:ae=>re(ae),onSaveEditing:He,onCancelEditing:st,onShare:()=>yt(J.threadId),onDelete:ge,showEditTitle:r,showDeleteButton:n,formatDate:et,getDisplayThreadTitle:mt,secondaryLine:xt&&kt(J)?ze(J):void 0,itemClassName:s.threadItem,activeItemClassName:s.activeThread},J.threadId))})}),u.jsx(la,{open:ye,onOpenChange:J=>!J&&Tt(),children:u.jsxs(cs,{className:"max-w-md p-0",children:[u.jsx(us,{children:u.jsx(ds,{children:"Share thread"})}),u.jsxs(kl,{children:[u.jsx(El,{autoFocus:!0,value:Ye,onValueChange:J=>Ve(J),placeholder:"Search for recipients..."}),u.jsxs(Il,{children:[W&&u.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-xs text-muted-foreground",children:[M&&u.jsx(de.Loader2,{className:"h-3 w-3 animate-spin"}),u.jsx("span",{className:W.startsWith("Failed")?"text-red-500":W.startsWith("Shared")?"text-emerald-500":"text-slate-600 dark:text-slate-400",children:W})]}),u.jsx(Nl,{children:Ke?u.jsxs("span",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(de.Loader2,{className:"h-4 w-4 animate-spin"}),"Loading recipients…"]}):"No matching recipients found"}),At.length>0&&u.jsx(Al,{heading:"Recipients",children:At.map(J=>u.jsx(jl,{onSelect:()=>pt(J),children:u.jsxs("div",{className:"flex flex-col items-start text-sm",children:[u.jsx("span",{className:"font-medium",children:J.label}),J.secondaryLabel&&u.jsx("span",{className:"text-xs text-muted-foreground",children:J.secondaryLabel})]})},J.id))})]})]})]})})]})}function Gk({layout:e="sidebar",layoutSize:t="desktop",showThreads:n=!0,className:r="",customStyles:o={},payloadExtras:s={},...i}){const a=d=>{const f="h-full";switch(d){case"phone":return`${f} max-w-none`;case"tablet":return`${f} max-w-4xl mx-auto`;case"half-screen":return`${f} max-w-2xl`;case"desktop":default:return`${f} max-w-7xl mx-auto`}},l=d=>({"--chat-sidebar-width":d==="phone"?"100%":d==="tablet"?"280px":d==="half-screen"?"240px":"320px","--chat-message-max-width":d==="phone"?"95%":d==="tablet"?"90%":d==="half-screen"?"85%":"80%","--chat-input-height":d==="phone"?"120px":"100px"}),c=b.useCallback(d=>{var f;(f=i.onThreadChange)==null||f.call(i,d)},[i]);return e==="fullscreen"?u.jsx(Tr,{...i,onThreadChange:c,children:u.jsx("div",{className:`${a(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:l(t),children:u.jsx(Fr,{className:"flex-1",onError:i.onError,enableFileUpload:!0,payloadExtras:s})})}):e==="tabs"?u.jsx(Tr,{...i,onThreadChange:c,children:u.jsx("div",{className:`${a(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:l(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(si,{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(Fr,{onError:i.onError,enableFileUpload:!0,payloadExtras:s})})]})})}):u.jsx(Tr,{...i,onThreadChange:c,children:u.jsxs("div",{className:`${a(t)} flex overflow-hidden ${r} ${o.container||""}`,style:l(t),children:[n&&u.jsx("div",{className:`w-80 border-r bg-gray-50 flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:u.jsx(si,{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(Fr,{onError:i.onError,enableFileUpload:!0,payloadExtras:s})})]})})}function Yk({apiConfig:e,className:t="",onError:n}){return u.jsx(Tr,{apiConfig:e,onError:n,children:u.jsx("div",{className:`h-full ${t}`,children:u.jsx(Fr,{})})})}function Xk({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(de.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(de.History,{size:14}),"History"]})})]}),u.jsx("div",{className:"flex-1 min-h-0",children:n==="chat"?u.jsx(Fr,{placeholder:e??"Ask Serti AI anything...",autoFocus:!0,className:"h-full",onMessageSent:t}):u.jsx(si,{showCreateButton:!0,className:"h-full",onThreadSelect:()=>r("chat")})})]})}function Jk({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(Tr,{...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(de.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(de.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(de.Maximize2,{size:14}):u.jsx(de.Minimize2,{size:14})})]})]})}),!a&&u.jsx("div",{className:"h-96 flex flex-col",children:u.jsx(Xk,{placeholder:t,onMessageSent:r})})]})})}):null}function Zk({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(de.Edit3,{size:16}),t??e]})}var Qk="Label",Nm=h.forwardRef((e,t)=>u.jsx(he.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())}}));Nm.displayName=Qk;var Am=Nm;const eE=Kr.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),jm=h.forwardRef(({className:e,...t},n)=>u.jsx(Am,{ref:n,className:oe(eE(),e),...t}));jm.displayName=Am.displayName;function Pm(e){const t=h.useRef({value:e,previous:e});return h.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var _m=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"}),tE="VisuallyHidden",ii=h.forwardRef((e,t)=>u.jsx(he.span,{...e,ref:t,style:{..._m,...e.style}}));ii.displayName=tE;var nE=ii,rE=[" ","Enter","ArrowUp","ArrowDown"],oE=[" ","Enter"],mr="Select",[ai,li,sE]=Ms(mr),[Ur,qN]=nn(mr,[sE,$r]),ci=$r(),[iE,Gn]=Ur(mr),[aE,lE]=Ur(mr),Rm=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:l,dir:c,name:d,autoComplete:f,disabled:m,required:p,form:v}=e,g=ci(t),[x,y]=h.useState(null),[w,C]=h.useState(null),[E,T]=h.useState(!1),S=Os(c),[k,A]=In({prop:r,defaultProp:o??!1,onChange:s,caller:mr}),[j,F]=In({prop:i,defaultProp:a,onChange:l,caller:mr}),D=h.useRef(null),B=x?v||!!x.closest("form"):!0,[G,M]=h.useState(new Set),W=Array.from(G).map(Y=>Y.props.value).join(";");return u.jsx(ol,{...g,children:u.jsxs(iE,{required:p,scope:t,trigger:x,onTriggerChange:y,valueNode:w,onValueNodeChange:C,valueNodeHasChildren:E,onValueNodeHasChildrenChange:T,contentId:jt(),value:j,onValueChange:F,open:k,onOpenChange:A,dir:S,triggerPointerDownPosRef:D,disabled:m,children:[u.jsx(ai.Provider,{scope:t,children:u.jsx(aE,{scope:e.__scopeSelect,onNativeOptionAdd:h.useCallback(Y=>{M(z=>new Set(z).add(Y))},[]),onNativeOptionRemove:h.useCallback(Y=>{M(z=>{const P=new Set(z);return P.delete(Y),P})},[]),children:n})}),B?u.jsxs(rg,{"aria-hidden":!0,required:p,tabIndex:-1,name:d,autoComplete:f,value:j,onChange:Y=>F(Y.target.value),disabled:m,form:v,children:[j===void 0?u.jsx("option",{value:""}):null,Array.from(G)]},W):null]})})};Rm.displayName=mr;var Mm="SelectTrigger",Om=h.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=ci(n),i=Gn(Mm,n),a=i.disabled||r,l=Le(t,i.onTriggerChange),c=li(n),d=h.useRef("touch"),[f,m,p]=sg(g=>{const x=c().filter(C=>!C.disabled),y=x.find(C=>C.value===i.value),w=ig(x,g,y);w!==void 0&&i.onValueChange(w.value)}),v=g=>{a||(i.onOpenChange(!0),p()),g&&(i.triggerPointerDownPosRef.current={x:Math.round(g.pageX),y:Math.round(g.pageY)})};return u.jsx(sl,{asChild:!0,...s,children:u.jsx(he.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":og(i.value)?"":void 0,...o,ref:l,onClick:ue(o.onClick,g=>{g.currentTarget.focus(),d.current!=="mouse"&&v(g)}),onPointerDown:ue(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:ue(o.onKeyDown,g=>{const x=f.current!=="";!(g.ctrlKey||g.altKey||g.metaKey)&&g.key.length===1&&m(g.key),!(x&&g.key===" ")&&rE.includes(g.key)&&(v(),g.preventDefault())})})})});Om.displayName=Mm;var Dm="SelectValue",Lm=h.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=Gn(Dm,n),{onValueNodeHasChildrenChange:c}=l,d=s!==void 0,f=Le(t,l.onValueNodeChange);return It(()=>{c(d)},[c,d]),u.jsx(he.span,{...a,ref:f,style:{pointerEvents:"none"},children:og(l.value)?u.jsx(u.Fragment,{children:i}):s})});Lm.displayName=Dm;var cE="SelectIcon",$m=h.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return u.jsx(he.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});$m.displayName=cE;var uE="SelectPortal",Fm=e=>u.jsx(so,{asChild:!0,...e});Fm.displayName=uE;var gr="SelectContent",Bm=h.forwardRef((e,t)=>{const n=Gn(gr,e.__scopeSelect),[r,o]=h.useState();if(It(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?qr.createPortal(u.jsx(zm,{scope:e.__scopeSelect,children:u.jsx(ai.Slot,{scope:e.__scopeSelect,children:u.jsx("div",{children:e.children})})}),s):null}return u.jsx(Hm,{...e,ref:t})});Bm.displayName=gr;var mn=10,[zm,Yn]=Ur(gr),dE="SelectContentImpl",fE=Jt.createSlot("SelectContent.RemoveScroll"),Hm=h.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:f,collisionBoundary:m,collisionPadding:p,sticky:v,hideWhenDetached:g,avoidCollisions:x,...y}=e,w=Gn(gr,n),[C,E]=h.useState(null),[T,S]=h.useState(null),k=Le(t,R=>E(R)),[A,j]=h.useState(null),[F,D]=h.useState(null),B=li(n),[G,M]=h.useState(!1),W=h.useRef(!1);h.useEffect(()=>{if(C)return na(C)},[C]),Xi();const Y=h.useCallback(R=>{const[_,...U]=B().map(ce=>ce.ref.current),[Z]=U.slice(-1),re=document.activeElement;for(const ce of R)if(ce===re||(ce==null||ce.scrollIntoView({block:"nearest"}),ce===_&&T&&(T.scrollTop=0),ce===Z&&T&&(T.scrollTop=T.scrollHeight),ce==null||ce.focus(),document.activeElement!==re))return},[B,T]),z=h.useCallback(()=>Y([A,C]),[Y,A,C]);h.useEffect(()=>{G&&z()},[G,z]);const{onOpenChange:P,triggerPointerDownPosRef:I}=w;h.useEffect(()=>{if(C){let R={x:0,y:0};const _=Z=>{var re,ce;R={x:Math.abs(Math.round(Z.pageX)-(((re=I.current)==null?void 0:re.x)??0)),y:Math.abs(Math.round(Z.pageY)-(((ce=I.current)==null?void 0:ce.y)??0))}},U=Z=>{R.x<=10&&R.y<=10?Z.preventDefault():C.contains(Z.target)||P(!1),document.removeEventListener("pointermove",_),I.current=null};return I.current!==null&&(document.addEventListener("pointermove",_),document.addEventListener("pointerup",U,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",_),document.removeEventListener("pointerup",U,{capture:!0})}}},[C,P,I]),h.useEffect(()=>{const R=()=>P(!1);return window.addEventListener("blur",R),window.addEventListener("resize",R),()=>{window.removeEventListener("blur",R),window.removeEventListener("resize",R)}},[P]);const[K,te]=sg(R=>{const _=B().filter(re=>!re.disabled),U=_.find(re=>re.ref.current===document.activeElement),Z=ig(_,R,U);Z&&setTimeout(()=>Z.ref.current.focus())}),O=h.useCallback((R,_,U)=>{const Z=!W.current&&!U;(w.value!==void 0&&w.value===_||Z)&&(j(R),Z&&(W.current=!0))},[w.value]),q=h.useCallback(()=>C==null?void 0:C.focus(),[C]),L=h.useCallback((R,_,U)=>{const Z=!W.current&&!U;(w.value!==void 0&&w.value===_||Z)&&D(R)},[w.value]),$=r==="popper"?Hl:Um,X=$===Hl?{side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:f,collisionBoundary:m,collisionPadding:p,sticky:v,hideWhenDetached:g,avoidCollisions:x}:{};return u.jsx(zm,{scope:n,content:C,viewport:T,onViewportChange:S,itemRefCallback:O,selectedItem:A,onItemLeave:q,itemTextRefCallback:L,focusSelectedItem:z,selectedItemText:F,position:r,isPositioned:G,searchRef:K,children:u.jsx(rs,{as:fE,allowPinchZoom:!0,children:u.jsx(Xo,{asChild:!0,trapped:w.open,onMountAutoFocus:R=>{R.preventDefault()},onUnmountAutoFocus:ue(o,R=>{var _;(_=w.trigger)==null||_.focus({preventScroll:!0}),R.preventDefault()}),children:u.jsx(Er,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:R=>R.preventDefault(),onDismiss:()=>w.onOpenChange(!1),children:u.jsx($,{role:"listbox",id:w.contentId,"data-state":w.open?"open":"closed",dir:w.dir,onContextMenu:R=>R.preventDefault(),...y,...X,onPlaced:()=>M(!0),ref:k,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:ue(y.onKeyDown,R=>{const _=R.ctrlKey||R.altKey||R.metaKey;if(R.key==="Tab"&&R.preventDefault(),!_&&R.key.length===1&&te(R.key),["ArrowUp","ArrowDown","Home","End"].includes(R.key)){let Z=B().filter(re=>!re.disabled).map(re=>re.ref.current);if(["ArrowUp","End"].includes(R.key)&&(Z=Z.slice().reverse()),["ArrowUp","ArrowDown"].includes(R.key)){const re=R.target,ce=Z.indexOf(re);Z=Z.slice(ce+1)}setTimeout(()=>Y(Z)),R.preventDefault()}})})})})})})});Hm.displayName=dE;var pE="SelectItemAlignedPosition",Um=h.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=Gn(gr,n),i=Yn(gr,n),[a,l]=h.useState(null),[c,d]=h.useState(null),f=Le(t,k=>d(k)),m=li(n),p=h.useRef(!1),v=h.useRef(!0),{viewport:g,selectedItem:x,selectedItemText:y,focusSelectedItem:w}=i,C=h.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&c&&g&&x&&y){const k=s.trigger.getBoundingClientRect(),A=c.getBoundingClientRect(),j=s.valueNode.getBoundingClientRect(),F=y.getBoundingClientRect();if(s.dir!=="rtl"){const re=F.left-A.left,ce=j.left-re,Ne=k.left-ce,ye=k.width+Ne,Re=Math.max(ye,A.width),We=window.innerWidth-mn,Fe=Pl(ce,[mn,Math.max(mn,We-Re)]);a.style.minWidth=ye+"px",a.style.left=Fe+"px"}else{const re=A.right-F.right,ce=window.innerWidth-j.right-re,Ne=window.innerWidth-k.right-ce,ye=k.width+Ne,Re=Math.max(ye,A.width),We=window.innerWidth-mn,Fe=Pl(ce,[mn,Math.max(mn,We-Re)]);a.style.minWidth=ye+"px",a.style.right=Fe+"px"}const D=m(),B=window.innerHeight-mn*2,G=g.scrollHeight,M=window.getComputedStyle(c),W=parseInt(M.borderTopWidth,10),Y=parseInt(M.paddingTop,10),z=parseInt(M.borderBottomWidth,10),P=parseInt(M.paddingBottom,10),I=W+Y+G+P+z,K=Math.min(x.offsetHeight*5,I),te=window.getComputedStyle(g),O=parseInt(te.paddingTop,10),q=parseInt(te.paddingBottom,10),L=k.top+k.height/2-mn,$=B-L,X=x.offsetHeight/2,R=x.offsetTop+X,_=W+Y+R,U=I-_;if(_<=L){const re=D.length>0&&x===D[D.length-1].ref.current;a.style.bottom="0px";const ce=c.clientHeight-g.offsetTop-g.offsetHeight,Ne=Math.max($,X+(re?q:0)+ce+z),ye=_+Ne;a.style.height=ye+"px"}else{const re=D.length>0&&x===D[0].ref.current;a.style.top="0px";const Ne=Math.max(L,W+g.offsetTop+(re?O:0)+X)+U;a.style.height=Ne+"px",g.scrollTop=_-L+g.offsetTop}a.style.margin=`${mn}px 0`,a.style.minHeight=K+"px",a.style.maxHeight=B+"px",r==null||r(),requestAnimationFrame(()=>p.current=!0)}},[m,s.trigger,s.valueNode,a,c,g,x,y,s.dir,r]);It(()=>C(),[C]);const[E,T]=h.useState();It(()=>{c&&T(window.getComputedStyle(c).zIndex)},[c]);const S=h.useCallback(k=>{k&&v.current===!0&&(C(),w==null||w(),v.current=!1)},[C,w]);return u.jsx(mE,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:p,onScrollButtonChange:S,children:u.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:E},children:u.jsx(he.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Um.displayName=pE;var hE="SelectPopperPosition",Hl=h.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=mn,...s}=e,i=ci(n);return u.jsx(il,{...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)"}})});Hl.displayName=hE;var[mE,Ul]=Ur(gr,{}),Wl="SelectViewport",Wm=h.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=Yn(Wl,n),i=Ul(Wl,n),a=Le(t,s.onViewportChange),l=h.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(ai.Slot,{scope:n,children:u.jsx(he.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:ue(o.onScroll,c=>{const d=c.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:m}=i;if(m!=null&&m.current&&f){const p=Math.abs(l.current-d.scrollTop);if(p>0){const v=window.innerHeight-mn*2,g=parseFloat(f.style.minHeight),x=parseFloat(f.style.height),y=Math.max(g,x);if(y<v){const w=y+p,C=Math.min(v,w),E=w-C;f.style.height=C+"px",f.style.bottom==="0px"&&(d.scrollTop=E>0?E:0,f.style.justifyContent="flex-end")}}}l.current=d.scrollTop})})})]})});Wm.displayName=Wl;var Vm="SelectGroup",[gE,xE]=Ur(Vm),vE=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=jt();return u.jsx(gE,{scope:n,id:o,children:u.jsx(he.div,{role:"group","aria-labelledby":o,...r,ref:t})})});vE.displayName=Vm;var Km="SelectLabel",qm=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=xE(Km,n);return u.jsx(he.div,{id:o.id,...r,ref:t})});qm.displayName=Km;var ui="SelectItem",[bE,Gm]=Ur(ui),Ym=h.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=Gn(ui,n),l=Yn(ui,n),c=a.value===r,[d,f]=h.useState(s??""),[m,p]=h.useState(!1),v=Le(t,w=>{var C;return(C=l.itemRefCallback)==null?void 0:C.call(l,w,r,o)}),g=jt(),x=h.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(bE,{scope:n,value:r,disabled:o,textId:g,isSelected:c,onItemTextChange:h.useCallback(w=>{f(C=>C||((w==null?void 0:w.textContent)??"").trim())},[]),children:u.jsx(ai.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:u.jsx(he.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:ue(i.onFocus,()=>p(!0)),onBlur:ue(i.onBlur,()=>p(!1)),onClick:ue(i.onClick,()=>{x.current!=="mouse"&&y()}),onPointerUp:ue(i.onPointerUp,()=>{x.current==="mouse"&&y()}),onPointerDown:ue(i.onPointerDown,w=>{x.current=w.pointerType}),onPointerMove:ue(i.onPointerMove,w=>{var C;x.current=w.pointerType,o?(C=l.onItemLeave)==null||C.call(l):x.current==="mouse"&&w.currentTarget.focus({preventScroll:!0})}),onPointerLeave:ue(i.onPointerLeave,w=>{var C;w.currentTarget===document.activeElement&&((C=l.onItemLeave)==null||C.call(l))}),onKeyDown:ue(i.onKeyDown,w=>{var E;((E=l.searchRef)==null?void 0:E.current)!==""&&w.key===" "||(oE.includes(w.key)&&y(),w.key===" "&&w.preventDefault())})})})})});Ym.displayName=ui;var Ro="SelectItemText",Xm=h.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=Gn(Ro,n),a=Yn(Ro,n),l=Gm(Ro,n),c=lE(Ro,n),[d,f]=h.useState(null),m=Le(t,y=>f(y),l.onItemTextChange,y=>{var w;return(w=a.itemTextRefCallback)==null?void 0:w.call(a,y,l.value,l.disabled)}),p=d==null?void 0:d.textContent,v=h.useMemo(()=>u.jsx("option",{value:l.value,disabled:l.disabled,children:p},l.value),[l.disabled,l.value,p]),{onNativeOptionAdd:g,onNativeOptionRemove:x}=c;return It(()=>(g(v),()=>x(v)),[g,x,v]),u.jsxs(u.Fragment,{children:[u.jsx(he.span,{id:l.textId,...s,ref:m}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?qr.createPortal(s.children,i.valueNode):null]})});Xm.displayName=Ro;var Jm="SelectItemIndicator",Zm=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return Gm(Jm,n).isSelected?u.jsx(he.span,{"aria-hidden":!0,...r,ref:t}):null});Zm.displayName=Jm;var Vl="SelectScrollUpButton",Qm=h.forwardRef((e,t)=>{const n=Yn(Vl,e.__scopeSelect),r=Ul(Vl,e.__scopeSelect),[o,s]=h.useState(!1),i=Le(t,r.onScrollButtonChange);return It(()=>{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(tg,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});Qm.displayName=Vl;var Kl="SelectScrollDownButton",eg=h.forwardRef((e,t)=>{const n=Yn(Kl,e.__scopeSelect),r=Ul(Kl,e.__scopeSelect),[o,s]=h.useState(!1),i=Le(t,r.onScrollButtonChange);return It(()=>{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(tg,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});eg.displayName=Kl;var tg=h.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=Yn("SelectScrollButton",n),i=h.useRef(null),a=li(n),l=h.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return h.useEffect(()=>()=>l(),[l]),It(()=>{var d;const c=a().find(f=>f.ref.current===document.activeElement);(d=c==null?void 0:c.ref.current)==null||d.scrollIntoView({block:"nearest"})},[a]),u.jsx(he.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:ue(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:ue(o.onPointerMove,()=>{var c;(c=s.onItemLeave)==null||c.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:ue(o.onPointerLeave,()=>{l()})})}),wE="SelectSeparator",ng=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return u.jsx(he.div,{"aria-hidden":!0,...r,ref:t})});ng.displayName=wE;var ql="SelectArrow",yE=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=ci(n),s=Gn(ql,n),i=Yn(ql,n);return s.open&&i.position==="popper"?u.jsx(al,{...o,...r,ref:t}):null});yE.displayName=ql;var SE="SelectBubbleInput",rg=h.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=h.useRef(null),s=Le(r,o),i=Pm(t);return h.useEffect(()=>{const a=o.current;if(!a)return;const l=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(l,"value").set;if(i!==t&&d){const f=new Event("change",{bubbles:!0});d.call(a,t),a.dispatchEvent(f)}},[i,t]),u.jsx(he.select,{...n,style:{..._m,...n.style},ref:s,defaultValue:t})});rg.displayName=SE;function og(e){return e===""||e===void 0}function sg(e){const t=bt(e),n=h.useRef(""),r=h.useRef(0),o=h.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=h.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return h.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function ig(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=CE(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 CE(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var TE=Rm,ag=Om,kE=Lm,EE=$m,IE=Fm,lg=Bm,NE=Wm,cg=qm,ug=Ym,AE=Xm,jE=Zm,dg=Qm,fg=eg,pg=ng;const PE=TE,_E=kE,hg=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(ag,{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(EE,{asChild:!0,children:u.jsx(de.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));hg.displayName=ag.displayName;const mg=h.forwardRef(({className:e,...t},n)=>u.jsx(dg,{ref:n,className:oe("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(de.ChevronUp,{className:"h-4 w-4"})}));mg.displayName=dg.displayName;const gg=h.forwardRef(({className:e,...t},n)=>u.jsx(fg,{ref:n,className:oe("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(de.ChevronDown,{className:"h-4 w-4"})}));gg.displayName=fg.displayName;const xg=h.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>u.jsx(IE,{children:u.jsxs(lg,{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(mg,{}),u.jsx(NE,{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(gg,{})]})}));xg.displayName=lg.displayName;const RE=h.forwardRef(({className:e,...t},n)=>u.jsx(cg,{ref:n,className:oe("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));RE.displayName=cg.displayName;const vg=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(ug,{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(jE,{children:u.jsx(de.Check,{className:"h-4 w-4"})})}),u.jsx(AE,{children:t})]}));vg.displayName=ug.displayName;const ME=h.forwardRef(({className:e,...t},n)=>u.jsx(pg,{ref:n,className:oe("-mx-1 my-1 h-px bg-muted",e),...t}));ME.displayName=pg.displayName;var OE="Separator",bg="horizontal",DE=["horizontal","vertical"],wg=h.forwardRef((e,t)=>{const{decorative:n,orientation:r=bg,...o}=e,s=LE(r)?r:bg,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return u.jsx(he.div,{"data-orientation":s,...a,...o,ref:t})});wg.displayName=OE;function LE(e){return DE.includes(e)}var yg=wg;const Sg=h.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>u.jsx(yg,{ref:o,decorative:n,orientation:t,className:oe("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));Sg.displayName=yg.displayName;var di="Switch",[$E,GN]=nn(di),[FE,BE]=$E(di),Cg=h.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:s,required:i,disabled:a,value:l="on",onCheckedChange:c,form:d,...f}=e,[m,p]=h.useState(null),v=Le(t,C=>p(C)),g=h.useRef(!1),x=m?d||!!m.closest("form"):!0,[y,w]=In({prop:o,defaultProp:s??!1,onChange:c,caller:di});return u.jsxs(FE,{scope:n,checked:y,disabled:a,children:[u.jsx(he.button,{type:"button",role:"switch","aria-checked":y,"aria-required":i,"data-state":Ig(y),"data-disabled":a?"":void 0,disabled:a,value:l,...f,ref:v,onClick:ue(e.onClick,C=>{w(E=>!E),x&&(g.current=C.isPropagationStopped(),g.current||C.stopPropagation())})}),x&&u.jsx(Eg,{control:m,bubbles:!g.current,name:r,value:l,checked:y,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});Cg.displayName=di;var Tg="SwitchThumb",kg=h.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=BE(Tg,n);return u.jsx(he.span,{"data-state":Ig(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});kg.displayName=Tg;var zE="SwitchBubbleInput",Eg=h.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=h.useRef(null),a=Le(i,s),l=Pm(n),c=Dp(t);return h.useEffect(()=>{const d=i.current;if(!d)return;const f=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(f,"checked").set;if(l!==n&&p){const v=new Event("click",{bubbles:r});p.call(d,n),d.dispatchEvent(v)}},[l,n,r]),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}})});Eg.displayName=zE;function Ig(e){return e?"checked":"unchecked"}var Ng=Cg,HE=kg;const Ag=h.forwardRef(({className:e,...t},n)=>u.jsx(Ng,{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(HE,{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")})}));Ag.displayName=Ng.displayName;const UE=ia,WE=Xw,VE=aa,jg=h.forwardRef(({className:e,...t},n)=>u.jsx(io,{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}));jg.displayName=io.displayName;const KE=Kr.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"}}),Pg=h.forwardRef(({side:e="right",className:t,children:n,...r},o)=>u.jsxs(VE,{children:[u.jsx(jg,{}),u.jsxs(ao,{ref:o,className:oe(KE({side:e}),t),...r,children:[n,u.jsxs($d,{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(de.X,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Pg.displayName=ao.displayName;const _g=({className:e,...t})=>u.jsx("div",{className:oe("flex flex-col space-y-2 text-center sm:text-left",e),...t});_g.displayName="SheetHeader";const Rg=h.forwardRef(({className:e,...t},n)=>u.jsx(or,{ref:n,className:oe("text-lg font-semibold text-foreground",e),...t}));Rg.displayName=or.displayName;const Mg=h.forwardRef(({className:e,...t},n)=>u.jsx(ls,{ref:n,className:oe("text-sm text-muted-foreground",e),...t}));Mg.displayName=ls.displayName;var[fi,YN]=nn("Tooltip",[$r]),pi=$r(),Og="TooltipProvider",qE=700,Gl="tooltip.open",[GE,Yl]=fi(Og),Dg=e=>{const{__scopeTooltip:t,delayDuration:n=qE,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:s}=e,i=h.useRef(!0),a=h.useRef(!1),l=h.useRef(0);return h.useEffect(()=>{const c=l.current;return()=>window.clearTimeout(c)},[]),u.jsx(GE,{scope:t,isOpenDelayedRef:i,delayDuration:n,onOpen:h.useCallback(()=>{window.clearTimeout(l.current),i.current=!1},[]),onClose:h.useCallback(()=>{window.clearTimeout(l.current),l.current=window.setTimeout(()=>i.current=!0,r)},[r]),isPointerInTransitRef:a,onPointerInTransitChange:h.useCallback(c=>{a.current=c},[]),disableHoverableContent:o,children:s})};Dg.displayName=Og;var Mo="Tooltip",[YE,hi]=fi(Mo),Lg=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:s,disableHoverableContent:i,delayDuration:a}=e,l=Yl(Mo,e.__scopeTooltip),c=pi(t),[d,f]=h.useState(null),m=jt(),p=h.useRef(0),v=i??l.disableHoverableContent,g=a??l.delayDuration,x=h.useRef(!1),[y,w]=In({prop:r,defaultProp:o??!1,onChange:k=>{k?(l.onOpen(),document.dispatchEvent(new CustomEvent(Gl))):l.onClose(),s==null||s(k)},caller:Mo}),C=h.useMemo(()=>y?x.current?"delayed-open":"instant-open":"closed",[y]),E=h.useCallback(()=>{window.clearTimeout(p.current),p.current=0,x.current=!1,w(!0)},[w]),T=h.useCallback(()=>{window.clearTimeout(p.current),p.current=0,w(!1)},[w]),S=h.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{x.current=!0,w(!0),p.current=0},g)},[g,w]);return h.useEffect(()=>()=>{p.current&&(window.clearTimeout(p.current),p.current=0)},[]),u.jsx(ol,{...c,children:u.jsx(YE,{scope:t,contentId:m,open:y,stateAttribute:C,trigger:d,onTriggerChange:f,onTriggerEnter:h.useCallback(()=>{l.isOpenDelayedRef.current?S():E()},[l.isOpenDelayedRef,S,E]),onTriggerLeave:h.useCallback(()=>{v?T():(window.clearTimeout(p.current),p.current=0)},[T,v]),onOpen:E,onClose:T,disableHoverableContent:v,children:n})})};Lg.displayName=Mo;var Xl="TooltipTrigger",$g=h.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=hi(Xl,n),s=Yl(Xl,n),i=pi(n),a=h.useRef(null),l=Le(t,a,o.onTriggerChange),c=h.useRef(!1),d=h.useRef(!1),f=h.useCallback(()=>c.current=!1,[]);return h.useEffect(()=>()=>document.removeEventListener("pointerup",f),[f]),u.jsx(sl,{asChild:!0,...i,children:u.jsx(he.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:l,onPointerMove:ue(e.onPointerMove,m=>{m.pointerType!=="touch"&&!d.current&&!s.isPointerInTransitRef.current&&(o.onTriggerEnter(),d.current=!0)}),onPointerLeave:ue(e.onPointerLeave,()=>{o.onTriggerLeave(),d.current=!1}),onPointerDown:ue(e.onPointerDown,()=>{o.open&&o.onClose(),c.current=!0,document.addEventListener("pointerup",f,{once:!0})}),onFocus:ue(e.onFocus,()=>{c.current||o.onOpen()}),onBlur:ue(e.onBlur,o.onClose),onClick:ue(e.onClick,o.onClose)})})});$g.displayName=Xl;var XE="TooltipPortal",[XN,JE]=fi(XE,{forceMount:void 0}),Wr="TooltipContent",Fg=h.forwardRef((e,t)=>{const n=JE(Wr,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...s}=e,i=hi(Wr,e.__scopeTooltip);return u.jsx($t,{present:r||i.open,children:i.disableHoverableContent?u.jsx(Bg,{side:o,...s,ref:t}):u.jsx(ZE,{side:o,...s,ref:t})})}),ZE=h.forwardRef((e,t)=>{const n=hi(Wr,e.__scopeTooltip),r=Yl(Wr,e.__scopeTooltip),o=h.useRef(null),s=Le(t,o),[i,a]=h.useState(null),{trigger:l,onClose:c}=n,d=o.current,{onPointerInTransitChange:f}=r,m=h.useCallback(()=>{a(null),f(!1)},[f]),p=h.useCallback((v,g)=>{const x=v.currentTarget,y={x:v.clientX,y:v.clientY},w=rI(y,x.getBoundingClientRect()),C=oI(y,w),E=sI(g.getBoundingClientRect()),T=aI([...C,...E]);a(T),f(!0)},[f]);return h.useEffect(()=>()=>m(),[m]),h.useEffect(()=>{if(l&&d){const v=x=>p(x,d),g=x=>p(x,l);return l.addEventListener("pointerleave",v),d.addEventListener("pointerleave",g),()=>{l.removeEventListener("pointerleave",v),d.removeEventListener("pointerleave",g)}}},[l,d,p,m]),h.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)),C=!iI(y,i);w?m():C&&(m(),c())};return document.addEventListener("pointermove",v),()=>document.removeEventListener("pointermove",v)}},[l,d,i,c,m]),u.jsx(Bg,{...e,ref:s})}),[QE,eI]=fi(Mo,{isInside:!1}),tI=Jt.createSlottable("TooltipContent"),Bg=h.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:s,onPointerDownOutside:i,...a}=e,l=hi(Wr,n),c=pi(n),{onClose:d}=l;return h.useEffect(()=>(document.addEventListener(Gl,d),()=>document.removeEventListener(Gl,d)),[d]),h.useEffect(()=>{if(l.trigger){const f=m=>{const p=m.target;p!=null&&p.contains(l.trigger)&&d()};return window.addEventListener("scroll",f,{capture:!0}),()=>window.removeEventListener("scroll",f,{capture:!0})}},[l.trigger,d]),u.jsx(Er,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:f=>f.preventDefault(),onDismiss:d,children:u.jsxs(il,{"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(tI,{children:r}),u.jsx(QE,{scope:n,isInside:!0,children:u.jsx(nE,{id:l.contentId,role:"tooltip",children:o||r})})]})})});Fg.displayName=Wr;var zg="TooltipArrow",nI=h.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=pi(n);return eI(zg,n).isInside?null:u.jsx(al,{...o,...r,ref:t})});nI.displayName=zg;function rI(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 oI(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 sI(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 iI(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,f=l.x,m=l.y;d>r!=m>r&&n<(f-c)*(r-d)/(m-d)+c&&(o=!o)}return o}function aI(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),lI(t)}function lI(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 cI=Dg,uI=Lg,dI=$g,Hg=Fg;const fI=cI,pI=uI,hI=dI,Ug=h.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(Hg,{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}));Ug.displayName=Hg.displayName;var Jl="ToastProvider",[Zl,mI,gI]=Ms("Toast"),[Wg,JN]=nn("Toast",[gI]),[xI,mi]=Wg(Jl),Vg=e=>{const{__scopeToast:t,label:n="Notification",duration:r=5e3,swipeDirection:o="right",swipeThreshold:s=50,children:i}=e,[a,l]=h.useState(null),[c,d]=h.useState(0),f=h.useRef(!1),m=h.useRef(!1);return n.trim()||console.error(`Invalid prop \`label\` supplied to \`${Jl}\`. Expected non-empty \`string\`.`),u.jsx(Zl.Provider,{scope:t,children:u.jsx(xI,{scope:t,label:n,duration:r,swipeDirection:o,swipeThreshold:s,toastCount:c,viewport:a,onViewportChange:l,onToastAdd:h.useCallback(()=>d(p=>p+1),[]),onToastRemove:h.useCallback(()=>d(p=>p-1),[]),isFocusedToastEscapeKeyDownRef:f,isClosePausedRef:m,children:i})})};Vg.displayName=Jl;var Kg="ToastViewport",vI=["F8"],Ql="toast.viewportPause",ec="toast.viewportResume",qg=h.forwardRef((e,t)=>{const{__scopeToast:n,hotkey:r=vI,label:o="Notifications ({hotkey})",...s}=e,i=mi(Kg,n),a=mI(n),l=h.useRef(null),c=h.useRef(null),d=h.useRef(null),f=h.useRef(null),m=Le(t,f,i.onViewportChange),p=r.join("+").replace(/Key/g,"").replace(/Digit/g,""),v=i.toastCount>0;h.useEffect(()=>{const x=y=>{var C;r.length!==0&&r.every(E=>y[E]||y.code===E)&&((C=f.current)==null||C.focus())};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[r]),h.useEffect(()=>{const x=l.current,y=f.current;if(v&&x&&y){const w=()=>{if(!i.isClosePausedRef.current){const S=new CustomEvent(Ql);y.dispatchEvent(S),i.isClosePausedRef.current=!0}},C=()=>{if(i.isClosePausedRef.current){const S=new CustomEvent(ec);y.dispatchEvent(S),i.isClosePausedRef.current=!1}},E=S=>{!x.contains(S.relatedTarget)&&C()},T=()=>{x.contains(document.activeElement)||C()};return x.addEventListener("focusin",w),x.addEventListener("focusout",E),x.addEventListener("pointermove",w),x.addEventListener("pointerleave",T),window.addEventListener("blur",w),window.addEventListener("focus",C),()=>{x.removeEventListener("focusin",w),x.removeEventListener("focusout",E),x.removeEventListener("pointermove",w),x.removeEventListener("pointerleave",T),window.removeEventListener("blur",w),window.removeEventListener("focus",C)}}},[v,i.isClosePausedRef]);const g=h.useCallback(({tabbingDirection:x})=>{const w=a().map(C=>{const E=C.ref.current,T=[E,...PI(E)];return x==="forwards"?T:T.reverse()});return(x==="forwards"?w.reverse():w).flat()},[a]);return h.useEffect(()=>{const x=f.current;if(x){const y=w=>{var T,S,k;const C=w.altKey||w.ctrlKey||w.metaKey;if(w.key==="Tab"&&!C){const A=document.activeElement,j=w.shiftKey;if(w.target===x&&j){(T=c.current)==null||T.focus();return}const B=g({tabbingDirection:j?"backwards":"forwards"}),G=B.findIndex(M=>M===A);rc(B.slice(G+1))?w.preventDefault():j?(S=c.current)==null||S.focus():(k=d.current)==null||k.focus()}};return x.addEventListener("keydown",y),()=>x.removeEventListener("keydown",y)}},[a,g]),u.jsxs(Wb,{ref:l,role:"region","aria-label":o.replace("{hotkey}",p),tabIndex:-1,style:{pointerEvents:v?void 0:"none"},children:[v&&u.jsx(tc,{ref:c,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"forwards"});rc(x)}}),u.jsx(Zl.Slot,{scope:n,children:u.jsx(he.ol,{tabIndex:-1,...s,ref:m})}),v&&u.jsx(tc,{ref:d,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"backwards"});rc(x)}})]})});qg.displayName=Kg;var Gg="ToastFocusProxy",tc=h.forwardRef((e,t)=>{const{__scopeToast:n,onFocusFromOutsideViewport:r,...o}=e,s=mi(Gg,n);return u.jsx(ii,{tabIndex:0,...o,ref:t,style:{position:"fixed"},onFocus:i=>{var c;const a=i.relatedTarget;!((c=s.viewport)!=null&&c.contains(a))&&r()}})});tc.displayName=Gg;var Oo="Toast",bI="toast.swipeStart",wI="toast.swipeMove",yI="toast.swipeCancel",SI="toast.swipeEnd",Yg=h.forwardRef((e,t)=>{const{forceMount:n,open:r,defaultOpen:o,onOpenChange:s,...i}=e,[a,l]=In({prop:r,defaultProp:o??!0,onChange:s,caller:Oo});return u.jsx($t,{present:n||a,children:u.jsx(kI,{open:a,...i,ref:t,onClose:()=>l(!1),onPause:bt(e.onPause),onResume:bt(e.onResume),onSwipeStart:ue(e.onSwipeStart,c=>{c.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:ue(e.onSwipeMove,c=>{const{x:d,y:f}=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",`${f}px`)}),onSwipeCancel:ue(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:ue(e.onSwipeEnd,c=>{const{x:d,y:f}=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",`${f}px`),l(!1)})})})});Yg.displayName=Oo;var[CI,TI]=Wg(Oo,{onClose(){}}),kI=h.forwardRef((e,t)=>{const{__scopeToast:n,type:r="foreground",duration:o,open:s,onClose:i,onEscapeKeyDown:a,onPause:l,onResume:c,onSwipeStart:d,onSwipeMove:f,onSwipeCancel:m,onSwipeEnd:p,...v}=e,g=mi(Oo,n),[x,y]=h.useState(null),w=Le(t,M=>y(M)),C=h.useRef(null),E=h.useRef(null),T=o||g.duration,S=h.useRef(0),k=h.useRef(T),A=h.useRef(0),{onToastAdd:j,onToastRemove:F}=g,D=bt(()=>{var W;(x==null?void 0:x.contains(document.activeElement))&&((W=g.viewport)==null||W.focus()),i()}),B=h.useCallback(M=>{!M||M===1/0||(window.clearTimeout(A.current),S.current=new Date().getTime(),A.current=window.setTimeout(D,M))},[D]);h.useEffect(()=>{const M=g.viewport;if(M){const W=()=>{B(k.current),c==null||c()},Y=()=>{const z=new Date().getTime()-S.current;k.current=k.current-z,window.clearTimeout(A.current),l==null||l()};return M.addEventListener(Ql,Y),M.addEventListener(ec,W),()=>{M.removeEventListener(Ql,Y),M.removeEventListener(ec,W)}}},[g.viewport,T,l,c,B]),h.useEffect(()=>{s&&!g.isClosePausedRef.current&&B(T)},[s,T,g.isClosePausedRef,B]),h.useEffect(()=>(j(),()=>F()),[j,F]);const G=h.useMemo(()=>x?nx(x):null,[x]);return g.viewport?u.jsxs(u.Fragment,{children:[G&&u.jsx(EI,{__scopeToast:n,role:"status","aria-live":r==="foreground"?"assertive":"polite",children:G}),u.jsx(CI,{scope:n,onClose:D,children:qr.createPortal(u.jsx(Zl.ItemSlot,{scope:n,children:u.jsx(Ub,{asChild:!0,onEscapeKeyDown:ue(a,()=>{g.isFocusedToastEscapeKeyDownRef.current||D(),g.isFocusedToastEscapeKeyDownRef.current=!1}),children:u.jsx(he.li,{tabIndex:0,"data-state":s?"open":"closed","data-swipe-direction":g.swipeDirection,...v,ref:w,style:{userSelect:"none",touchAction:"none",...e.style},onKeyDown:ue(e.onKeyDown,M=>{M.key==="Escape"&&(a==null||a(M.nativeEvent),M.nativeEvent.defaultPrevented||(g.isFocusedToastEscapeKeyDownRef.current=!0,D()))}),onPointerDown:ue(e.onPointerDown,M=>{M.button===0&&(C.current={x:M.clientX,y:M.clientY})}),onPointerMove:ue(e.onPointerMove,M=>{if(!C.current)return;const W=M.clientX-C.current.x,Y=M.clientY-C.current.y,z=!!E.current,P=["left","right"].includes(g.swipeDirection),I=["left","up"].includes(g.swipeDirection)?Math.min:Math.max,K=P?I(0,W):0,te=P?0:I(0,Y),O=M.pointerType==="touch"?10:2,q={x:K,y:te},L={originalEvent:M,delta:q};z?(E.current=q,gi(wI,f,L,{discrete:!1})):rx(q,g.swipeDirection,O)?(E.current=q,gi(bI,d,L,{discrete:!1}),M.target.setPointerCapture(M.pointerId)):(Math.abs(W)>O||Math.abs(Y)>O)&&(C.current=null)}),onPointerUp:ue(e.onPointerUp,M=>{const W=E.current,Y=M.target;if(Y.hasPointerCapture(M.pointerId)&&Y.releasePointerCapture(M.pointerId),E.current=null,C.current=null,W){const z=M.currentTarget,P={originalEvent:M,delta:W};rx(W,g.swipeDirection,g.swipeThreshold)?gi(SI,p,P,{discrete:!0}):gi(yI,m,P,{discrete:!0}),z.addEventListener("click",I=>I.preventDefault(),{once:!0})}})})})}),g.viewport)})]}):null}),EI=e=>{const{__scopeToast:t,children:n,...r}=e,o=mi(Oo,t),[s,i]=h.useState(!1),[a,l]=h.useState(!1);return AI(()=>i(!0)),h.useEffect(()=>{const c=window.setTimeout(()=>l(!0),1e3);return()=>window.clearTimeout(c)},[]),a?null:u.jsx(so,{asChild:!0,children:u.jsx(ii,{...r,children:s&&u.jsxs(u.Fragment,{children:[o.label," ",n]})})})},II="ToastTitle",Xg=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(he.div,{...r,ref:t})});Xg.displayName=II;var NI="ToastDescription",Jg=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(he.div,{...r,ref:t})});Jg.displayName=NI;var Zg="ToastAction",Qg=h.forwardRef((e,t)=>{const{altText:n,...r}=e;return n.trim()?u.jsx(tx,{altText:n,asChild:!0,children:u.jsx(nc,{...r,ref:t})}):(console.error(`Invalid prop \`altText\` supplied to \`${Zg}\`. Expected non-empty \`string\`.`),null)});Qg.displayName=Zg;var ex="ToastClose",nc=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e,o=TI(ex,n);return u.jsx(tx,{asChild:!0,children:u.jsx(he.button,{type:"button",...r,ref:t,onClick:ue(e.onClick,o.onClose)})})});nc.displayName=ex;var tx=h.forwardRef((e,t)=>{const{__scopeToast:n,altText:r,...o}=e;return u.jsx(he.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":r||void 0,...o,ref:t})});function nx(e){const t=[];return Array.from(e.childNodes).forEach(r=>{if(r.nodeType===r.TEXT_NODE&&r.textContent&&t.push(r.textContent),jI(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(...nx(r))}}),t}function gi(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?Vi(o,s):o.dispatchEvent(s)}var rx=(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 AI(e=()=>{}){const t=bt(e);It(()=>{let n=0,r=0;return n=window.requestAnimationFrame(()=>r=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(n),window.cancelAnimationFrame(r)}},[t])}function jI(e){return e.nodeType===e.ELEMENT_NODE}function PI(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function rc(e){const t=document.activeElement;return e.some(n=>n===t?!0:(n.focus(),document.activeElement!==t))}var _I=Vg,ox=qg,sx=Yg,ix=Xg,ax=Jg,lx=Qg,cx=nc;const RI=_I,ux=h.forwardRef(({className:e,...t},n)=>u.jsx(ox,{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}));ux.displayName=ox.displayName;const MI=Kr.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"}}),dx=h.forwardRef(({className:e,variant:t,...n},r)=>u.jsx(sx,{ref:r,className:oe(MI({variant:t}),e),...n}));dx.displayName=sx.displayName;const OI=h.forwardRef(({className:e,...t},n)=>u.jsx(lx,{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}));OI.displayName=lx.displayName;const fx=h.forwardRef(({className:e,...t},n)=>u.jsx(cx,{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(de.X,{className:"h-4 w-4"})}));fx.displayName=cx.displayName;const px=h.forwardRef(({className:e,...t},n)=>u.jsx(ix,{ref:n,className:oe("text-sm font-semibold",e),...t}));px.displayName=ix.displayName;const hx=h.forwardRef(({className:e,...t},n)=>u.jsx(ax,{ref:n,className:oe("text-sm opacity-90",e),...t}));hx.displayName=ax.displayName;function DI(){const{toasts:e}=da();return u.jsxs(RI,{children:[e.map(function({id:t,title:n,description:r,action:o,...s}){return u.jsxs(dx,{...s,children:[u.jsxs("div",{className:"grid gap-1",children:[n&&u.jsx(px,{children:n}),r&&u.jsx(hx,{children:r})]}),o,u.jsx(fx,{})]},t)}),u.jsx(ux,{})]})}var LI=(e,t,n,r,o,s,i,a)=>{let l=document.documentElement,c=["light","dark"];function d(p){(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[p]?s[p]:p)):l.setAttribute(v,p)}),f(p)}function f(p){a&&c.includes(p)&&(l.style.colorScheme=p)}function m(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}if(r)d(r);else try{let p=localStorage.getItem(t)||n,v=i&&p==="system"?m():p;d(v)}catch{}},$I=h.createContext(void 0),FI={setTheme:e=>{},themes:[]},BI=()=>{var e;return(e=h.useContext($I))!=null?e:FI};h.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 h.createElement("script",{...c,suppressHydrationWarning:!0,nonce:typeof window>"u"?l:"",dangerouslySetInnerHTML:{__html:`(${LI.toString()})(${d})`}})});var zI=e=>{switch(e){case"success":return WI;case"info":return KI;case"warning":return VI;case"error":return qI;default:return null}},HI=Array(12).fill(0),UI=({visible:e,className:t})=>b.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},b.createElement("div",{className:"sonner-spinner"},HI.map((n,r)=>b.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),WI=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"})),VI=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"})),KI=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"})),qI=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"})),GI=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"})),YI=()=>{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},oc=1,XI=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:oc++,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(ZI(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)||oc++;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}},Yt=new XI,JI=(e,t)=>{let n=(t==null?void 0:t.id)||oc++;return Yt.addToast({title:e,...t,id:n}),n},ZI=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",QI=JI,eN=()=>Yt.toasts,tN=()=>Yt.getActiveToasts();Object.assign(QI,{success:Yt.success,info:Yt.info,warning:Yt.warning,error:Yt.error,custom:Yt.custom,message:Yt.message,promise:Yt.promise,dismiss:Yt.dismiss,loading:Yt.loading},{getHistory:eN,getToasts:tN});function nN(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))}nN(`: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%)}
|
|
131
|
+
`);function xi(e){return e.label!==void 0}var rN=3,oN="32px",sN="16px",mx=4e3,iN=356,aN=14,lN=20,cN=200;function gn(...e){return e.filter(Boolean).join(" ")}function uN(e){let[t,n]=e.split("-"),r=[];return t&&r.push(t),n&&r.push(n),r}var dN=e=>{var t,n,r,o,s,i,a,l,c,d,f;let{invert:m,toast:p,unstyled:v,interacting:g,setHeights:x,visibleToasts:y,heights:w,index:C,toasts:E,expanded:T,removeToast:S,defaultRichColors:k,closeButton:A,style:j,cancelButtonStyle:F,actionButtonStyle:D,className:B="",descriptionClassName:G="",duration:M,position:W,gap:Y,loadingIcon:z,expandByDefault:P,classNames:I,icons:K,closeButtonAriaLabel:te="Close toast",pauseWhenPageIsHidden:O}=e,[q,L]=b.useState(null),[$,X]=b.useState(null),[R,_]=b.useState(!1),[U,Z]=b.useState(!1),[re,ce]=b.useState(!1),[Ne,ye]=b.useState(!1),[Re,We]=b.useState(!1),[Fe,Ye]=b.useState(0),[Ve,tt]=b.useState(0),gt=b.useRef(p.duration||M||mx),at=b.useRef(null),lt=b.useRef(null),Me=C===0,Ke=C+1<=y,je=p.type,qe=p.dismissible!==!1,Be=p.className||"",nt=p.descriptionClassName||"",ct=b.useMemo(()=>w.findIndex(ge=>ge.toastId===p.id)||0,[w,p.id]),ft=b.useMemo(()=>{var ge;return(ge=p.closeButton)!=null?ge:A},[p.closeButton,A]),yt=b.useMemo(()=>p.duration||M||mx,[p.duration,M]),Tt=b.useRef(0),pt=b.useRef(0),At=b.useRef(0),xt=b.useRef(null),[ht,zt]=W.split("-"),Ht=b.useMemo(()=>w.reduce((ge,De,He)=>He>=ct?ge:ge+De.height,0),[w,ct]),Oe=YI(),ze=p.invert||m,kt=je==="loading";pt.current=b.useMemo(()=>ct*Y+Ht,[ct,Ht]),b.useEffect(()=>{gt.current=yt},[yt]),b.useEffect(()=>{_(!0)},[]),b.useEffect(()=>{let ge=lt.current;if(ge){let De=ge.getBoundingClientRect().height;return tt(De),x(He=>[{toastId:p.id,height:De,position:p.position},...He]),()=>x(He=>He.filter(st=>st.toastId!==p.id))}},[x,p.id]),b.useLayoutEffect(()=>{if(!R)return;let ge=lt.current,De=ge.style.height;ge.style.height="auto";let He=ge.getBoundingClientRect().height;ge.style.height=De,tt(He),x(st=>st.find(et=>et.toastId===p.id)?st.map(et=>et.toastId===p.id?{...et,height:He}:et):[{toastId:p.id,height:He,position:p.position},...st])},[R,p.title,p.description,x,p.id]);let ut=b.useCallback(()=>{Z(!0),Ye(pt.current),x(ge=>ge.filter(De=>De.toastId!==p.id)),setTimeout(()=>{S(p)},cN)},[p,S,x,pt]);b.useEffect(()=>{if(p.promise&&je==="loading"||p.duration===1/0||p.type==="loading")return;let ge;return T||g||O&&Oe?(()=>{if(At.current<Tt.current){let De=new Date().getTime()-Tt.current;gt.current=gt.current-De}At.current=new Date().getTime()})():gt.current!==1/0&&(Tt.current=new Date().getTime(),ge=setTimeout(()=>{var De;(De=p.onAutoClose)==null||De.call(p,p),ut()},gt.current)),()=>clearTimeout(ge)},[T,g,p,je,O,Oe,ut]),b.useEffect(()=>{p.delete&&ut()},[ut,p.delete]);function Pt(){var ge,De,He;return K!=null&&K.loading?b.createElement("div",{className:gn(I==null?void 0:I.loader,(ge=p==null?void 0:p.classNames)==null?void 0:ge.loader,"sonner-loader"),"data-visible":je==="loading"},K.loading):z?b.createElement("div",{className:gn(I==null?void 0:I.loader,(De=p==null?void 0:p.classNames)==null?void 0:De.loader,"sonner-loader"),"data-visible":je==="loading"},z):b.createElement(UI,{className:gn(I==null?void 0:I.loader,(He=p==null?void 0:p.classNames)==null?void 0:He.loader),visible:je==="loading"})}return b.createElement("li",{tabIndex:0,ref:lt,className:gn(B,Be,I==null?void 0:I.toast,(t=p==null?void 0:p.classNames)==null?void 0:t.toast,I==null?void 0:I.default,I==null?void 0:I[je],(n=p==null?void 0:p.classNames)==null?void 0:n[je]),"data-sonner-toast":"","data-rich-colors":(r=p.richColors)!=null?r:k,"data-styled":!(p.jsx||p.unstyled||v),"data-mounted":R,"data-promise":!!p.promise,"data-swiped":Re,"data-removed":U,"data-visible":Ke,"data-y-position":ht,"data-x-position":zt,"data-index":C,"data-front":Me,"data-swiping":re,"data-dismissible":qe,"data-type":je,"data-invert":ze,"data-swipe-out":Ne,"data-swipe-direction":$,"data-expanded":!!(T||P&&R),style:{"--index":C,"--toasts-before":C,"--z-index":E.length-C,"--offset":`${U?Fe:pt.current}px`,"--initial-height":P?"auto":`${Ve}px`,...j,...p.style},onDragEnd:()=>{ce(!1),L(null),xt.current=null},onPointerDown:ge=>{kt||!qe||(at.current=new Date,Ye(pt.current),ge.target.setPointerCapture(ge.pointerId),ge.target.tagName!=="BUTTON"&&(ce(!0),xt.current={x:ge.clientX,y:ge.clientY}))},onPointerUp:()=>{var ge,De,He,st;if(Ne||!qe)return;xt.current=null;let et=Number(((ge=lt.current)==null?void 0:ge.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),dt=Number(((De=lt.current)==null?void 0:De.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),mt=new Date().getTime()-((He=at.current)==null?void 0:He.getTime()),J=q==="x"?et:dt,ae=Math.abs(J)/mt;if(Math.abs(J)>=lN||ae>.11){Ye(pt.current),(st=p.onDismiss)==null||st.call(p,p),X(q==="x"?et>0?"right":"left":dt>0?"down":"up"),ut(),ye(!0),We(!1);return}ce(!1),L(null)},onPointerMove:ge=>{var De,He,st,et;if(!xt.current||!qe||((De=window.getSelection())==null?void 0:De.toString().length)>0)return;let dt=ge.clientY-xt.current.y,mt=ge.clientX-xt.current.x,J=(He=e.swipeDirections)!=null?He:uN(W);!q&&(Math.abs(mt)>1||Math.abs(dt)>1)&&L(Math.abs(mt)>Math.abs(dt)?"x":"y");let ae={x:0,y:0};q==="y"?(J.includes("top")||J.includes("bottom"))&&(J.includes("top")&&dt<0||J.includes("bottom")&&dt>0)&&(ae.y=dt):q==="x"&&(J.includes("left")||J.includes("right"))&&(J.includes("left")&&mt<0||J.includes("right")&&mt>0)&&(ae.x=mt),(Math.abs(ae.x)>0||Math.abs(ae.y)>0)&&We(!0),(st=lt.current)==null||st.style.setProperty("--swipe-amount-x",`${ae.x}px`),(et=lt.current)==null||et.style.setProperty("--swipe-amount-y",`${ae.y}px`)}},ft&&!p.jsx?b.createElement("button",{"aria-label":te,"data-disabled":kt,"data-close-button":!0,onClick:kt||!qe?()=>{}:()=>{var ge;ut(),(ge=p.onDismiss)==null||ge.call(p,p)},className:gn(I==null?void 0:I.closeButton,(o=p==null?void 0:p.classNames)==null?void 0:o.closeButton)},(s=K==null?void 0:K.close)!=null?s:GI):null,p.jsx||b.isValidElement(p.title)?p.jsx?p.jsx:typeof p.title=="function"?p.title():p.title:b.createElement(b.Fragment,null,je||p.icon||p.promise?b.createElement("div",{"data-icon":"",className:gn(I==null?void 0:I.icon,(i=p==null?void 0:p.classNames)==null?void 0:i.icon)},p.promise||p.type==="loading"&&!p.icon?p.icon||Pt():null,p.type!=="loading"?p.icon||(K==null?void 0:K[je])||zI(je):null):null,b.createElement("div",{"data-content":"",className:gn(I==null?void 0:I.content,(a=p==null?void 0:p.classNames)==null?void 0:a.content)},b.createElement("div",{"data-title":"",className:gn(I==null?void 0:I.title,(l=p==null?void 0:p.classNames)==null?void 0:l.title)},typeof p.title=="function"?p.title():p.title),p.description?b.createElement("div",{"data-description":"",className:gn(G,nt,I==null?void 0:I.description,(c=p==null?void 0:p.classNames)==null?void 0:c.description)},typeof p.description=="function"?p.description():p.description):null),b.isValidElement(p.cancel)?p.cancel:p.cancel&&xi(p.cancel)?b.createElement("button",{"data-button":!0,"data-cancel":!0,style:p.cancelButtonStyle||F,onClick:ge=>{var De,He;xi(p.cancel)&&qe&&((He=(De=p.cancel).onClick)==null||He.call(De,ge),ut())},className:gn(I==null?void 0:I.cancelButton,(d=p==null?void 0:p.classNames)==null?void 0:d.cancelButton)},p.cancel.label):null,b.isValidElement(p.action)?p.action:p.action&&xi(p.action)?b.createElement("button",{"data-button":!0,"data-action":!0,style:p.actionButtonStyle||D,onClick:ge=>{var De,He;xi(p.action)&&((He=(De=p.action).onClick)==null||He.call(De,ge),!ge.defaultPrevented&&ut())},className:gn(I==null?void 0:I.actionButton,(f=p==null?void 0:p.classNames)==null?void 0:f.actionButton)},p.action.label):null))};function gx(){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 fN(e,t){let n={};return[e,t].forEach((r,o)=>{let s=o===1,i=s?"--mobile-offset":"--offset",a=s?sN:oN;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 pN=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:f,duration:m,style:p,visibleToasts:v=rN,toastOptions:g,dir:x=gx(),gap:y=aN,loadingIcon:w,icons:C,containerAriaLabel:E="Notifications",pauseWhenPageIsHidden:T}=e,[S,k]=b.useState([]),A=b.useMemo(()=>Array.from(new Set([r].concat(S.filter(O=>O.position).map(O=>O.position)))),[S,r]),[j,F]=b.useState([]),[D,B]=b.useState(!1),[G,M]=b.useState(!1),[W,Y]=b.useState(d!=="system"?d:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),z=b.useRef(null),P=o.join("+").replace(/Key/g,"").replace(/Digit/g,""),I=b.useRef(null),K=b.useRef(!1),te=b.useCallback(O=>{k(q=>{var L;return(L=q.find($=>$.id===O.id))!=null&&L.delete||Yt.dismiss(O.id),q.filter(({id:$})=>$!==O.id)})},[]);return b.useEffect(()=>Yt.subscribe(O=>{if(O.dismiss){k(q=>q.map(L=>L.id===O.id?{...L,delete:!0}:L));return}setTimeout(()=>{Do.flushSync(()=>{k(q=>{let L=q.findIndex($=>$.id===O.id);return L!==-1?[...q.slice(0,L),{...q[L],...O},...q.slice(L+1)]:[O,...q]})})})}),[]),b.useEffect(()=>{if(d!=="system"){Y(d);return}if(d==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?Y("dark"):Y("light")),typeof window>"u")return;let O=window.matchMedia("(prefers-color-scheme: dark)");try{O.addEventListener("change",({matches:q})=>{Y(q?"dark":"light")})}catch{O.addListener(({matches:L})=>{try{Y(L?"dark":"light")}catch($){console.error($)}})}},[d]),b.useEffect(()=>{S.length<=1&&B(!1)},[S]),b.useEffect(()=>{let O=q=>{var L,$;o.every(X=>q[X]||q.code===X)&&(B(!0),(L=z.current)==null||L.focus()),q.code==="Escape"&&(document.activeElement===z.current||($=z.current)!=null&&$.contains(document.activeElement))&&B(!1)};return document.addEventListener("keydown",O),()=>document.removeEventListener("keydown",O)},[o]),b.useEffect(()=>{if(z.current)return()=>{I.current&&(I.current.focus({preventScroll:!0}),I.current=null,K.current=!1)}},[z.current]),b.createElement("section",{ref:t,"aria-label":`${E} ${P}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},A.map((O,q)=>{var L;let[$,X]=O.split("-");return S.length?b.createElement("ol",{key:O,dir:x==="auto"?gx():x,tabIndex:-1,ref:z,className:a,"data-sonner-toaster":!0,"data-theme":W,"data-y-position":$,"data-lifted":D&&S.length>1&&!s,"data-x-position":X,style:{"--front-toast-height":`${((L=j[0])==null?void 0:L.height)||0}px`,"--width":`${iN}px`,"--gap":`${y}px`,...p,...fN(l,c)},onBlur:R=>{K.current&&!R.currentTarget.contains(R.relatedTarget)&&(K.current=!1,I.current&&(I.current.focus({preventScroll:!0}),I.current=null))},onFocus:R=>{R.target instanceof HTMLElement&&R.target.dataset.dismissible==="false"||K.current||(K.current=!0,I.current=R.relatedTarget)},onMouseEnter:()=>B(!0),onMouseMove:()=>B(!0),onMouseLeave:()=>{G||B(!1)},onDragEnd:()=>B(!1),onPointerDown:R=>{R.target instanceof HTMLElement&&R.target.dataset.dismissible==="false"||M(!0)},onPointerUp:()=>M(!1)},S.filter(R=>!R.position&&q===0||R.position===O).map((R,_)=>{var U,Z;return b.createElement(dN,{key:R.id,icons:C,index:_,toast:R,defaultRichColors:f,duration:(U=g==null?void 0:g.duration)!=null?U:m,className:g==null?void 0:g.className,descriptionClassName:g==null?void 0:g.descriptionClassName,invert:n,visibleToasts:v,closeButton:(Z=g==null?void 0:g.closeButton)!=null?Z:i,interacting:G,position:O,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:te,toasts:S.filter(re=>re.position==R.position),heights:j.filter(re=>re.position==R.position),setHeights:F,expandByDefault:s,gap:y,loadingIcon:w,expanded:D,pauseWhenPageIsHidden:T,swipeDirections:e.swipeDirections})})):null}))});const hN=({...e})=>{const{theme:t="system"}=BI();return u.jsx(pN,{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})};H.ApiProvider=cu,H.ArtifactRenderer=tf,H.Badge=lf,H.Button=Xe,H.Card=ha,H.CardContent=bs,H.CardDescription=xa,H.CardHeader=ma,H.CardTitle=ga,H.ChatApi=su,H.ChatApp=Gk,H.ChatInput=Kh,H.ChatInputRow=qh,H.ChatInterface=Fr,H.ChatProviders=Tr,H.ChatWidget=Jk,H.Command=kl,H.CommandEmpty=Nl,H.CommandGroup=Al,H.CommandInput=El,H.CommandItem=jl,H.CommandList=Il,H.DEFAULT_TIMEOUT_MS=nu,H.Dialog=la,H.DialogContent=cs,H.DialogHeader=us,H.DialogTitle=ds,H.DropdownMenu=Js,H.DropdownMenuContent=jo,H.DropdownMenuItem=Kn,H.DropdownMenuTrigger=Zs,H.FileApi=iu,H.HISTORY_TIMEOUT_MS=ru,H.Input=Ll,H.InterruptPartRenderer=va,H.Label=jm,H.MarkdownContent=ir,H.MessageComponent=ws,H.MessageContent=af,H.MessageHeader=cf,H.MessageList=Wa,H.MessageRow=Ua,H.NewChatButton=Zk,H.PlotArtifact=ef,H.SETTINGS_STORAGE_KEY=Wi,H.ScrollArea=Dl,H.Select=PE,H.SelectContent=xg,H.SelectItem=vg,H.SelectTrigger=hg,H.SelectValue=_E,H.Separator=Sg,H.Sheet=UE,H.SheetContent=Pg,H.SheetDescription=Mg,H.SheetHeader=_g,H.SheetTitle=Rg,H.SheetTrigger=WE,H.SimpleChat=Yk,H.SimpleJsonView=vs,H.Sonner=hN,H.StreamProgress=nf,H.Switch=Ag,H.Textarea=vl,H.ThinkingIndicator=of,H.ThreadListItem=$l,H.ThreadManager=si,H.ThreadStateProvider=$u,H.ThreadsProvider=bu,H.TimelineColumn=_x,H.Toaster=DI,H.ToolContent=fp,H.Tooltip=pI,H.TooltipContent=Ug,H.TooltipProvider=fI,H.TooltipTrigger=hI,H.UserTextContent=sf,H.applySettings=Eb,H.buildCheckpointIndex=cc,H.buildCheckpointPreviewMap=yx,H.buildLabelParts=Eu,H.chatApiClient=Mn,H.collectText=Su,H.createArtifactPreviewFromPlot=Nu,H.createArtifactPreviewFromSource=Iu,H.del=Oi,H.extractConfigFields=bi,H.extractToolContent=nr,H.extractToolMeta=Yo,H.fileApiClient=au,H.fileToBase64=uu,H.formatToolOutput=yu,H.get=Kt,H.getAgentNameFromMessage=Tu,H.getChatToken=Ri,H.getCheckpointForMessage=Sx,H.getCurrentSettings=kb,H.getDefaultApiConfig=qu,H.getDefaultChatSettings=Gu,H.getMessageAttemptInfo=uc,H.getMessageDomKey=Ha,H.getPreviewForMessage=vi,H.getToolProgress=Bi,H.httpClient=Dt,H.hydrateHistorySnapshots=Xn,H.isEnvelope=fu,H.isFileLike=Li,H.loadStoredSettings=Yu,H.looksLikeMarkdown=wu,H.messageSignature=Fi,H.normalizeInterruptId=$i,H.normalizeMimeType=ku,H.normalizeToolPayload=Au,H.normalizeToolPayloadValue=Cr,H.onChatTokenChanged=Mi,H.parseJsonSafe=er,H.post=to,H.pretty=tr,H.processAttachments=du,H.put=ou,H.readNumber=fc,H.readString=_n,H.sanitizeForDisplay=Sr,H.saveSettings=Xu,H.setChatToken=Rn,H.stringifyTool=Cu,H.toPlainObject=Pn,H.unwrap=Lt,H.useApi=On,H.useCheckpointIndex=dc,H.useFilePreview=uf,H.useHasChatSession=Cb,H.useParsedMessageContent=df,H.useShallowStableValue=Uu,H.useStream=Ui,H.useStreamingHook=Ui,H.useThreadHistoryState=Mu,H.useThreadManagerViewState=Im,H.useThreadState=ro,H.useThreadStateUpdater=Lu,H.useThreads=yr,H.useThreadsState=xu,H.useToolPayload=pf,Object.defineProperty(H,Symbol.toStringTag,{value:"Module"})});
|
|
132
132
|
//# sourceMappingURL=index.umd.js.map
|