teodor-new-chat-ui 4.3.469 → 4.3.470
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/messaging/components/message/hooks/index.d.ts +1 -0
- package/dist/features/messaging/components/message/hooks/useToolPayload.d.ts +33 -0
- package/dist/features/messaging/components/message/renderers/tool/DictPayloadRenderer.d.ts +5 -0
- package/dist/features/messaging/components/message/renderers/tool/IssuesPayloadRenderer.d.ts +6 -0
- package/dist/index.esm.js +6319 -5860
- package/dist/index.umd.js +50 -49
- package/package.json +1 -1
package/dist/index.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(U,
|
|
1
|
+
(function(U,v){typeof exports=="object"&&typeof module<"u"?v(exports,require("react"),require("@radix-ui/react-slot"),require("class-variance-authority"),require("clsx"),require("tailwind-merge"),require("lucide-react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","@radix-ui/react-slot","class-variance-authority","clsx","tailwind-merge","lucide-react","react-dom"],v):(U=typeof globalThis<"u"?globalThis:U||self,v(U.NewChatUI={},U.React,U.reactSlot,U.classVarianceAuthority,U.clsx,U.tailwindMerge,U.LucideReact,U.ReactDOM))})(this,function(U,v,qt,Ur,$x,Fx,ae,$o){"use strict";var u1=Object.defineProperty;var d1=(U,v,qt)=>v in U?u1(U,v,{enumerable:!0,configurable:!0,writable:!0,value:qt}):U[v]=qt;var Dx=(U,v,qt)=>d1(U,typeof v!="symbol"?v+"":v,qt);function uc(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const h=uc(v),Wr=uc($o),dc=120;function Bx(e){if(!Array.isArray(e))return"";const t=e.filter(r=>!!(r&&r.type==="text")).map(r=>(r.text??"").trim()).filter(Boolean);if(!t.length)return"";const n=t.join(" ").replace(/\s+/g," ").trim();return n?n.length>dc?`${n.slice(0,dc-3)}…`:n:""}function Si(e){return Bx(e.content)||""}function zx(e){var n;const t=new Map;for(const r of e){if(!r.checkpointId)continue;const o=(n=r.messages)==null?void 0:n.find(s=>s.role==="user");if(o){const s=Si(o);s&&t.set(r.checkpointId,s)}}return t}function fc(e){const t=new Map,n=[],r=new Map,o=[];for(let u=0;u<e.length;u++){const d=e[u],f=d.checkpointId,m=f??`cp-${u}`,p=d.metadata??{},b=typeof p.step=="number"?p.step:null,g=typeof p.source=="string"?p.source:null;let x=null,y=null;const w=Array.isArray(d.messages)?d.messages:[];for(const T of w)T.role==="user"&&(y||(y=T),T.id&&(x=T.id));const S=d.next&&d.next.length>0?String(d.next[0]):null,k=d.parentConfig??null,C={id:m,step:b,source:g,createdAt:d.createdAt??null,namespace:d.checkpointNs??null,parentId:d.parentId??null,next:S,parentConfig:k,userMessageId:x};if(o.push(C),f&&t.set(f,C),f&&y){const T=Si(y);T&&r.set(f,T)}n.push({id:m,messageId:x,step:b,source:g,createdAt:d.createdAt??null,next:S,parentConfig:k})}const s=new Map;for(const u of o){if(!u.userMessageId)continue;const d=s.get(u.userMessageId)??[];d.push(u),s.set(u.userMessageId,d)}for(const u of s.values()){if(!u.length)continue;u.sort((f,m)=>{const p=f.createdAt?Date.parse(f.createdAt):0;return(m.createdAt?Date.parse(m.createdAt):0)-p});const d=u.length;for(let f=0;f<u.length;f++){const m=u[f];m.attemptCount=d,m.attemptIndex=f,m.isLatestAttempt=f===0}}return{checkpoints:e,checkpointMetaByCheckpointId:t,timeline:n,messagePreviews:r,getLatest:()=>{const u=n[0];if(u)return t.get(u.id)},getCheckpoint:u=>t.get(u),getMessageAttempts:u=>{const d=[];for(const f of t.values())f.userMessageId===u&&d.push(f);return d.length?(d.sort((f,m)=>{const p=typeof f.attemptIndex=="number"?f.attemptIndex:Number.MAX_SAFE_INTEGER,b=typeof m.attemptIndex=="number"?m.attemptIndex:Number.MAX_SAFE_INTEGER;return p-b}),d):[]}}}function pc(e,t,n){if(!e)return{attemptCount:1,attemptIndex:0,attempts:[]};const r=n.getMessageAttempts(e);if(!r.length)return{attemptCount:1,attemptIndex:0,attempts:[]};let o=0;if(t){const s=r.findIndex(i=>i.id===t);s>=0&&(o=s)}return{attemptCount:r.length,attemptIndex:o,attempts:r}}function Hx(e,t){return e?t.getCheckpoint(e)??null:null}function hc(e){return v.useMemo(()=>fc(e),[e])}function Mn(e){if(!(!e||typeof e!="object"||Array.isArray(e)))return{...e}}function On(e,t){if(e)for(const n of t){const r=e[n];if(typeof r=="string"&&r.trim())return r.trim()}}function mc(e,t){if(!e)return null;for(const n of t){const r=e[n];if(typeof r=="number"&&Number.isFinite(r))return r}return null}function Ci(e){const t=Mn(e);if(t)return Mn(t.configurable)??t}function Dn(e){const r=[...(Array.isArray(e==null?void 0:e.checkpoints)?(e==null?void 0:e.checkpoints)??[]:e!=null&&e.checkpoints?Object.values(e.checkpoints):[]).map((s,i)=>Ux(s,i)).filter(s=>!!s)].sort((s,i)=>gc(i.createdAt)-gc(s.createdAt)),o=r[0]??null;return{threadId:(e==null?void 0:e.threadId)??"",latest:o,checkpoints:r,interrupt:(o==null?void 0:o.interrupt)??null}}function Ux(e,t){var S;if(!e)return null;const r=(Array.isArray((S=e.values)==null?void 0:S.messages)?e.values.messages:[]).map(k=>Wx(k)).filter(k=>!!k),o=Mn(e.metadata)??{},s=Ci(e.config),i=Mn(e.parent_config??e.parentConfig),a=Ci(i),l=On(s,["checkpoint_id","checkpointId"]),u=On(s,["checkpoint_ns","checkpointNs"]),d=On(a,["checkpoint_id","checkpointId"]),f=On(a,["checkpoint_id","checkpointId"])??null,m=On(a,["checkpoint_ns","checkpointNs"])??null,p=Mn(e.config),b=Array.isArray(e.tasks)?e.tasks.map(k=>({...k})):e.tasks??null,g=Array.isArray(e.next)?[...e.next]:e.next??null,x=typeof e.created_at=="string"&&e.created_at.trim()?e.created_at:typeof e.createdAt=="string"&&e.createdAt.trim()?e.createdAt:new Date(Date.now()-t).toISOString(),y={...o,step:mc(o,["step"])??0,source:On(o,["source"])??null},w=r.map(k=>({...k,checkpointId:l??null}));return{checkpointId:l??null,checkpointNs:u??null,createdAt:x,parentId:d??null,messages:w,nextCursor:f,nextCursorNs:m,interrupt:Gx(r,t),metadata:y,config:p??null,parentConfig:i??null,next:g,tasks:b}}function Wx(e){var s,i,a;if(!e||typeof e!="object")return null;const t=Vx(e);if(!t)return null;const n=qx(e==null?void 0:e.content);if(!n.length)return null;const r=typeof e.createdAt=="string"?e.createdAt:typeof((s=e.additional_kwargs)==null?void 0:s.created_at)=="string"?(i=e.additional_kwargs)==null?void 0:i.created_at:new Date().toISOString();return{id:typeof e.id=="string"&&e.id.trim()?e.id:`msg-${Date.now().toString(16)}-${Math.random().toString(16).slice(2)}`,role:t,name:typeof e.name=="string"?e.name:void 0,model:typeof e.model=="string"?e.model:((a=e.additional_kwargs)==null?void 0:a.model)??void 0,createdAt:r,content:n,additionalKwargs:e.additional_kwargs??void 0,responseMetadata:e.response_metadata??void 0,artifact:e.artifact??void 0,threadId:e.threadId??e.thread_id}}function Vx(e){const t=typeof e.role=="string"?e.role:void 0;if(t&&Kx(t))return t;const n=typeof e.type=="string"?e.type:void 0;if(!n)return null;switch(n){case"human":return"user";case"ai":return"assistant";case"tool":return"tool";case"system":return"system";default:return null}}function Kx(e){return e==="assistant"||e==="user"||e==="system"||e==="tool"||e==="default_message"}function qx(e){return typeof e=="string"?[{type:"text",text:e}]:Array.isArray(e)?e.filter(t=>!!(t&&typeof t=="object"&&typeof t.type=="string")):[]}function Gx(e,t){return Yx(e,t)}function Yx(e,t){var n;for(let r=e.length-1;r>=0;r--){const o=((n=e[r])==null?void 0:n.content)??[];for(let s=o.length-1;s>=0;s--){const i=o[s];if((i==null?void 0:i.type)==="interrupt"){const a=i;return{id:typeof a.id=="string"&&a.id.trim()?a.id:`interrupt-${t}-${r}-${s}`,value:a.value}}}}return null}function gc(e){if(!e)return 0;const t=Date.parse(e);return Number.isFinite(t)?t:0}var Ti={exports:{}},Vr={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.min.js
|
|
4
4
|
*
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var
|
|
9
|
+
*/var xc;function Xx(){if(xc)return Vr;xc=1;var e=v,t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,o=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function i(a,l,u){var d,f={},m=null,p=null;u!==void 0&&(m=""+u),l.key!==void 0&&(m=""+l.key),l.ref!==void 0&&(p=l.ref);for(d in l)r.call(l,d)&&!s.hasOwnProperty(d)&&(f[d]=l[d]);if(a&&a.defaultProps)for(d in l=a.defaultProps,l)f[d]===void 0&&(f[d]=l[d]);return{$$typeof:t,type:a,key:m,ref:p,props:f,_owner:o.current}}return Vr.Fragment=n,Vr.jsx=i,Vr.jsxs=i,Vr}var Kr={};/**
|
|
10
10
|
* @license React
|
|
11
11
|
* react-jsx-runtime.development.js
|
|
12
12
|
*
|
|
@@ -14,34 +14,34 @@
|
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the MIT license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var
|
|
18
|
-
`+z+N}}var ee=!1,J;{var K=typeof WeakMap=="function"?WeakMap:Map;J=new K}function Q(N,
|
|
19
|
-
`)
|
|
20
|
-
`),gt=Be.length-1,bt
|
|
21
|
-
`+Be[gt].replace(" at new "," at ");return N.displayName&&
|
|
17
|
+
*/var vc;function Jx(){return vc||(vc=1,process.env.NODE_ENV!=="production"&&function(){var e=v,t=Symbol.for("react.element"),n=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),a=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),f=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),p=Symbol.for("react.offscreen"),b=Symbol.iterator,g="@@iterator";function x(N){if(N===null||typeof N!="object")return null;var oe=b&&N[b]||N[g];return typeof oe=="function"?oe:null}var y=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function w(N){{for(var oe=arguments.length,le=new Array(oe>1?oe-1:0),Ie=1;Ie<oe;Ie++)le[Ie-1]=arguments[Ie];S("error",N,le)}}function S(N,oe,le){{var Ie=y.ReactDebugCurrentFrame,Xe=Ie.getStackAddendum();Xe!==""&&(oe+="%s",le=le.concat([Xe]));var nt=le.map(function(Ue){return String(Ue)});nt.unshift("Warning: "+oe),Function.prototype.apply.call(console[N],console,nt)}}var k=!1,C=!1,T=!1,E=!1,j=!1,_;_=Symbol.for("react.module.reference");function D(N){return!!(typeof N=="string"||typeof N=="function"||N===r||N===s||j||N===o||N===u||N===d||E||N===p||k||C||T||typeof N=="object"&&N!==null&&(N.$$typeof===m||N.$$typeof===f||N.$$typeof===i||N.$$typeof===a||N.$$typeof===l||N.$$typeof===_||N.getModuleId!==void 0))}function F(N,oe,le){var Ie=N.displayName;if(Ie)return Ie;var Xe=oe.displayName||oe.name||"";return Xe!==""?le+"("+Xe+")":le}function W(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 u:return"Suspense";case d:return"SuspenseList"}if(typeof N=="object")switch(N.$$typeof){case a:var oe=N;return W(oe)+".Consumer";case i:var le=N;return W(le._context)+".Provider";case l:return F(N,N.render,"ForwardRef");case f:var Ie=N.displayName||null;return Ie!==null?Ie:G(N.type)||"Memo";case m:{var Xe=N,nt=Xe._payload,Ue=Xe._init;try{return G(Ue(nt))}catch{return null}}}return null}var A=Object.assign,X=0,q,B,R,I,H,Y,P;function O(){}O.__reactDisabledLog=!0;function M(){{if(X===0){q=console.log,B=console.info,R=console.warn,I=console.error,H=console.group,Y=console.groupCollapsed,P=console.groupEnd;var N={configurable:!0,enumerable:!0,value:O,writable:!0};Object.defineProperties(console,{info:N,log:N,warn:N,error:N,group:N,groupCollapsed:N,groupEnd:N})}X++}}function L(){{if(X--,X===0){var N={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:A({},N,{value:q}),info:A({},N,{value:B}),warn:A({},N,{value:R}),error:A({},N,{value:I}),group:A({},N,{value:H}),groupCollapsed:A({},N,{value:Y}),groupEnd:A({},N,{value:P})})}X<0&&w("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var te=y.ReactCurrentDispatcher,z;function $(N,oe,le){{if(z===void 0)try{throw Error()}catch(Xe){var Ie=Xe.stack.trim().match(/\n( *(at )?)/);z=Ie&&Ie[1]||""}return`
|
|
18
|
+
`+z+N}}var ee=!1,J;{var K=typeof WeakMap=="function"?WeakMap:Map;J=new K}function Q(N,oe){if(!N||ee)return"";{var le=J.get(N);if(le!==void 0)return le}var Ie;ee=!0;var Xe=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var nt;nt=te.current,te.current=null,M();try{if(oe){var Ue=function(){throw Error()};if(Object.defineProperty(Ue.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Ue,[])}catch(Kt){Ie=Kt}Reflect.construct(N,[],Ue)}else{try{Ue.call()}catch(Kt){Ie=Kt}N.call(Ue.prototype)}}else{try{throw Error()}catch(Kt){Ie=Kt}N()}}catch(Kt){if(Kt&&Ie&&typeof Kt.stack=="string"){for(var Be=Kt.stack.split(`
|
|
19
|
+
`),Ft=Ie.stack.split(`
|
|
20
|
+
`),gt=Be.length-1,bt=Ft.length-1;gt>=1&&bt>=0&&Be[gt]!==Ft[bt];)bt--;for(;gt>=1&&bt>=0;gt--,bt--)if(Be[gt]!==Ft[bt]){if(gt!==1||bt!==1)do if(gt--,bt--,bt<0||Be[gt]!==Ft[bt]){var an=`
|
|
21
|
+
`+Be[gt].replace(" at new "," at ");return N.displayName&&an.includes("<anonymous>")&&(an=an.replace("<anonymous>",N.displayName)),typeof N=="function"&&J.set(N,an),an}while(gt>=1&&bt>=0);break}}}finally{ee=!1,te.current=nt,L(),Error.prepareStackTrace=Xe}var Hr=N?N.displayName||N.name:"",hr=Hr?$(Hr):"";return typeof N=="function"&&J.set(N,hr),hr}function me(N,oe,le){return Q(N,!1)}function de(N){var oe=N.prototype;return!!(oe&&oe.isReactComponent)}function ge(N,oe,le){if(N==null)return"";if(typeof N=="function")return Q(N,de(N));if(typeof N=="string")return $(N);switch(N){case u:return $("Suspense");case d:return $("SuspenseList")}if(typeof N=="object")switch(N.$$typeof){case l:return me(N.render);case f:return ge(N.type,oe,le);case m:{var Ie=N,Xe=Ie._payload,nt=Ie._init;try{return ge(nt(Xe),oe,le)}catch{}}}return""}var we=Object.prototype.hasOwnProperty,Te={},Ne=y.ReactDebugCurrentFrame;function ke(N){if(N){var oe=N._owner,le=ge(N.type,N._source,oe?oe.type:null);Ne.setExtraStackFrame(le)}else Ne.setExtraStackFrame(null)}function st(N,oe,le,Ie,Xe){{var nt=Function.call.bind(we);for(var Ue in N)if(nt(N,Ue)){var Be=void 0;try{if(typeof N[Ue]!="function"){var Ft=Error((Ie||"React class")+": "+le+" type `"+Ue+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof N[Ue]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw Ft.name="Invariant Violation",Ft}Be=N[Ue](oe,Ue,Ie,le,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(gt){Be=gt}Be&&!(Be instanceof Error)&&(ke(Xe),w("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",Ie||"React class",le,Ue,typeof Be),ke(null)),Be instanceof Error&&!(Be.message in Te)&&(Te[Be.message]=!0,ke(Xe),w("Failed %s type: %s",le,Be.message),ke(null))}}}var vt=Array.isArray;function ht(N){return vt(N)}function We(N){{var oe=typeof Symbol=="function"&&Symbol.toStringTag,le=oe&&N[Symbol.toStringTag]||N.constructor.name||"Object";return le}}function Le(N){try{return Ge(N),!1}catch{return!0}}function Ge(N){return""+N}function Me(N){if(Le(N))return w("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",We(N)),Ge(N)}var $e=y.ReactCurrentOwner,Ze={key:!0,ref:!0,__self:!0,__source:!0},Nt,it;function St(N){if(we.call(N,"ref")){var oe=Object.getOwnPropertyDescriptor(N,"ref").get;if(oe&&oe.isReactWarning)return!1}return N.ref!==void 0}function Ct(N){if(we.call(N,"key")){var oe=Object.getOwnPropertyDescriptor(N,"key").get;if(oe&&oe.isReactWarning)return!1}return N.key!==void 0}function Tt(N,oe){typeof N.ref=="string"&&$e.current}function Et(N,oe){{var le=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)",oe))};le.isReactWarning=!0,Object.defineProperty(N,"key",{get:le,configurable:!0})}}function sn(N,oe){{var le=function(){it||(it=!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)",oe))};le.isReactWarning=!0,Object.defineProperty(N,"ref",{get:le,configurable:!0})}}var At=function(N,oe,le,Ie,Xe,nt,Ue){var Be={$$typeof:t,type:N,key:oe,ref:le,props:Ue,_owner:nt};return Be._store={},Object.defineProperty(Be._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(Be,"_self",{configurable:!1,enumerable:!1,writable:!1,value:Ie}),Object.defineProperty(Be,"_source",{configurable:!1,enumerable:!1,writable:!1,value:Xe}),Object.freeze&&(Object.freeze(Be.props),Object.freeze(Be)),Be};function Vt(N,oe,le,Ie,Xe){{var nt,Ue={},Be=null,Ft=null;le!==void 0&&(Me(le),Be=""+le),Ct(oe)&&(Me(oe.key),Be=""+oe.key),St(oe)&&(Ft=oe.ref,Tt(oe,Xe));for(nt in oe)we.call(oe,nt)&&!Ze.hasOwnProperty(nt)&&(Ue[nt]=oe[nt]);if(N&&N.defaultProps){var gt=N.defaultProps;for(nt in gt)Ue[nt]===void 0&&(Ue[nt]=gt[nt])}if(Be||Ft){var bt=typeof N=="function"?N.displayName||N.name||"Unknown":N;Be&&Et(Ue,bt),Ft&&sn(Ue,bt)}return At(N,Be,Ft,Xe,Ie,$e.current,Ue)}}var It=y.ReactCurrentOwner,Fe=y.ReactDebugCurrentFrame;function Ve(N){if(N){var oe=N._owner,le=ge(N.type,N._source,oe?oe.type:null);Fe.setExtraStackFrame(le)}else Fe.setExtraStackFrame(null)}var jt;jt=!1;function Z(N){return typeof N=="object"&&N!==null&&N.$$typeof===t}function ce(){{if(It.current){var N=G(It.current.type);if(N)return`
|
|
22
22
|
|
|
23
|
-
Check the render method of \``+N+"`."}return""}}function He(N){return""}var ve={};function
|
|
23
|
+
Check the render method of \``+N+"`."}return""}}function He(N){return""}var ve={};function pe(N){{var oe=ce();if(!oe){var le=typeof N=="string"?N:N.displayName||N.name;le&&(oe=`
|
|
24
24
|
|
|
25
|
-
Check the top-level render call using <`+le+">.")}return
|
|
25
|
+
Check the top-level render call using <`+le+">.")}return oe}}function ye(N,oe){{if(!N._store||N._store.validated||N.key!=null)return;N._store.validated=!0;var le=pe(oe);if(ve[le])return;ve[le]=!0;var Ie="";N&&N._owner&&N._owner!==It.current&&(Ie=" It was passed a child from "+G(N._owner.type)+"."),Ve(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.',le,Ie),Ve(null)}}function Oe(N,oe){{if(typeof N!="object")return;if(ht(N))for(var le=0;le<N.length;le++){var Ie=N[le];Z(Ie)&&ye(Ie,oe)}else if(Z(N))N._store&&(N._store.validated=!0);else if(N){var Xe=x(N);if(typeof Xe=="function"&&Xe!==N.entries)for(var nt=Xe.call(N),Ue;!(Ue=nt.next()).done;)Z(Ue.value)&&ye(Ue.value,oe)}}}function Ke(N){{var oe=N.type;if(oe==null||typeof oe=="string")return;var le;if(typeof oe=="function")le=oe.propTypes;else if(typeof oe=="object"&&(oe.$$typeof===l||oe.$$typeof===f))le=oe.propTypes;else return;if(le){var Ie=G(oe);st(le,N.props,"prop",Ie,N)}else if(oe.PropTypes!==void 0&&!jt){jt=!0;var Xe=G(oe);w("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",Xe||"Unknown")}typeof oe.getDefaultProps=="function"&&!oe.getDefaultProps.isReactClassApproved&&w("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function lt(N){{for(var oe=Object.keys(N.props),le=0;le<oe.length;le++){var Ie=oe[le];if(Ie!=="children"&&Ie!=="key"){Ve(N),w("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",Ie),Ve(null);break}}N.ref!==null&&(Ve(N),w("Invalid attribute `ref` supplied to `React.Fragment`."),Ve(null))}}var ct={};function Re(N,oe,le,Ie,Xe,nt){{var Ue=D(N);if(!Ue){var Be="";(N===void 0||typeof N=="object"&&N!==null&&Object.keys(N).length===0)&&(Be+=" 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 Ft=He();Ft?Be+=Ft:Be+=ce();var gt;N===null?gt="null":ht(N)?gt="array":N!==void 0&&N.$$typeof===t?(gt="<"+(G(N.type)||"Unknown")+" />",Be=" Did you accidentally export a JSX literal instead of a component?"):gt=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",gt,Be)}var bt=Vt(N,oe,le,Xe,nt);if(bt==null)return bt;if(Ue){var an=oe.children;if(an!==void 0)if(Ie)if(ht(an)){for(var Hr=0;Hr<an.length;Hr++)Oe(an[Hr],N);Object.freeze&&Object.freeze(an)}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 Oe(an,N)}if(we.call(oe,"key")){var hr=G(N),Kt=Object.keys(oe).filter(function(c1){return c1!=="key"}),cc=Kt.length>0?"{key: someKey, "+Kt.join(": ..., ")+": ...}":"{key: someKey}";if(!ct[hr+cc]){var l1=Kt.length>0?"{"+Kt.join(": ..., ")+": ...}":"{}";w(`A props object containing a "key" prop is being spread into JSX:
|
|
26
26
|
let props = %s;
|
|
27
27
|
<%s {...props} />
|
|
28
28
|
React keys must be passed directly to JSX without using spread:
|
|
29
29
|
let props = %s;
|
|
30
|
-
<%s key={someKey} {...props} />`,Jl,hr,rN,hr),ct[hr+Jl]=!0}}return N===r?lt(bt):Ke(bt),bt}}function mt(N,re,le){return _e(N,re,le,!0)}function Qe(N,re,le){return _e(N,re,le,!1)}var ut=Qe,In=mt;Wr.Fragment=r,Wr.jsx=ut,Wr.jsxs=In}()),Wr}process.env.NODE_ENV==="production"?xi.exports=gx():xi.exports=xx();var u=xi.exports;const vx=({timelineEntries:e,activeCheckpointId:t,onSelectCheckpoint:n,messagePreviews:r,className:o,onHoverStart:s,onHoverEnd:i})=>{const a=e??[],l=a.length>0,c=b.useMemo(()=>l?[...a].reverse():[],[a,l]),d=t??(a.length?a[a.length-1].id:null);if(!l)return null;const m=["w-32 flex-shrink-0 flex-col border-r border-border/40 pr-2 flex bg-white text-gray-900 dark:bg-slate-900 dark:text-slate-100",o].filter(Boolean).join(" ");return u.jsxs("div",{className:m,onMouseEnter:s,onMouseLeave:i,children:[u.jsxs("div",{className:"relative flex-1 overflow-y-auto pt-4 pb-2 pr-1",children:[u.jsx("div",{className:"absolute left-0 right-0 top-1 px-2 pb-3 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:u.jsx("span",{children:"Timeline"})}),u.jsx("div",{className:"pointer-events-none absolute left-3 top-0 bottom-0 w-px bg-border/40"}),u.jsx("div",{className:"flex flex-col gap-3 pt-6 pr-2",children:c.map(f=>{const v=d===f.id,g=(r==null?void 0:r.get(f.id))??null;return u.jsxs("button",{type:"button",disabled:!n,onClick:()=>n==null?void 0:n(f.id),className:`relative flex items-start gap-2 text-left text-[11px] transition ${v?"text-primary":"text-muted-foreground"} ${n?"hover:text-foreground":"cursor-default opacity-70"}`,children:[u.jsx("span",{className:`mt-1 inline-flex h-3 w-3 items-center justify-center rounded-full border ${v?"border-primary bg-primary/10 text-primary":"border-border bg-background"}`,children:u.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${v?"bg-primary":"bg-border"}`})}),u.jsxs("span",{className:"flex-1",children:[u.jsx("span",{className:"block font-medium leading-tight",children:f.label||"User input"}),u.jsxs("span",{className:"text-[9px] uppercase tracking-wide text-muted-foreground/70",children:[f.step!==null?`STEP ${f.step}`:"STEP —",f.next?` - ${f.next}`:""]}),g&&u.jsx("p",{className:"text-[10px] text-muted-foreground/80 mt-1 line-clamp-2",title:g,children:g})]})]},f.id)})})]}),n&&u.jsx("button",{type:"button",onClick:()=>n==null?void 0:n(null),className:"mt-auto mb-3 rounded-md border border-border/70 px-2 py-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground transition hover:border-foreground/60 hover:text-foreground",children:"Latest"})]})};function ac(e,t){return function(){return e.apply(t,arguments)}}const{toString:bx}=Object.prototype,{getPrototypeOf:vi}=Object,{iterator:Mo,toStringTag:lc}=Symbol,Oo=(e=>t=>{const n=bx.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),an=e=>(e=e.toLowerCase(),t=>Oo(t)===e),Do=e=>t=>typeof t===e,{isArray:pr}=Array,mr=Do("undefined");function Vr(e){return e!==null&&!mr(e)&&e.constructor!==null&&!mr(e.constructor)&&Ft(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const cc=an("ArrayBuffer");function wx(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&cc(e.buffer),t}const yx=Do("string"),Ft=Do("function"),uc=Do("number"),Kr=e=>e!==null&&typeof e=="object",Sx=e=>e===!0||e===!1,Lo=e=>{if(Oo(e)!=="object")return!1;const t=vi(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(lc in e)&&!(Mo in e)},Cx=e=>{if(!Kr(e)||Vr(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},Tx=an("Date"),kx=an("File"),Ex=an("Blob"),Ix=an("FileList"),Nx=e=>Kr(e)&&Ft(e.pipe),Ax=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||Ft(e.append)&&((t=Oo(e))==="formdata"||t==="object"&&Ft(e.toString)&&e.toString()==="[object FormData]"))},jx=an("URLSearchParams"),[Px,_x,Rx,Mx]=["ReadableStream","Request","Response","Headers"].map(an),Ox=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function qr(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,o;if(typeof e!="object"&&(e=[e]),pr(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{if(Vr(e))return;const s=n?Object.getOwnPropertyNames(e):Object.keys(e),i=s.length;let a;for(r=0;r<i;r++)a=s[r],t.call(null,e[a],a,e)}}function dc(e,t){if(Vr(e))return null;t=t.toLowerCase();const n=Object.keys(e);let r=n.length,o;for(;r-- >0;)if(o=n[r],t===o.toLowerCase())return o;return null}const Jn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,fc=e=>!mr(e)&&e!==Jn;function bi(){const{caseless:e,skipUndefined:t}=fc(this)&&this||{},n={},r=(o,s)=>{const i=e&&dc(n,s)||s;Lo(n[i])&&Lo(o)?n[i]=bi(n[i],o):Lo(o)?n[i]=bi({},o):pr(o)?n[i]=o.slice():(!t||!mr(o))&&(n[i]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&qr(arguments[o],r);return n}const Dx=(e,t,n,{allOwnKeys:r}={})=>(qr(t,(o,s)=>{n&&Ft(o)?e[s]=ac(o,n):e[s]=o},{allOwnKeys:r}),e),Lx=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),$x=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},Fx=(e,t,n,r)=>{let o,s,i;const a={};if(t=t||{},e==null)return t;do{for(o=Object.getOwnPropertyNames(e),s=o.length;s-- >0;)i=o[s],(!r||r(i,e,t))&&!a[i]&&(t[i]=e[i],a[i]=!0);e=n!==!1&&vi(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},Bx=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return r!==-1&&r===n},zx=e=>{if(!e)return null;if(pr(e))return e;let t=e.length;if(!uc(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Hx=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&vi(Uint8Array)),Ux=(e,t)=>{const r=(e&&e[Mo]).call(e);let o;for(;(o=r.next())&&!o.done;){const s=o.value;t.call(e,s[0],s[1])}},Wx=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},Vx=an("HTMLFormElement"),Kx=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),hc=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),qx=an("RegExp"),pc=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};qr(n,(o,s)=>{let i;(i=t(o,s,e))!==!1&&(r[s]=i||o)}),Object.defineProperties(e,r)},Gx=e=>{pc(e,(t,n)=>{if(Ft(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(Ft(r)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},Yx=(e,t)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return pr(e)?r(e):r(String(e).split(t)),n},Xx=()=>{},Jx=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function Zx(e){return!!(e&&Ft(e.append)&&e[lc]==="FormData"&&e[Mo])}const Qx=e=>{const t=new Array(10),n=(r,o)=>{if(Kr(r)){if(t.indexOf(r)>=0)return;if(Vr(r))return r;if(!("toJSON"in r)){t[o]=r;const s=pr(r)?[]:{};return qr(r,(i,a)=>{const l=n(i,o+1);!mr(l)&&(s[a]=l)}),t[o]=void 0,s}}return r};return n(e,0)},ev=an("AsyncFunction"),tv=e=>e&&(Kr(e)||Ft(e))&&Ft(e.then)&&Ft(e.catch),mc=((e,t)=>e?setImmediate:t?((n,r)=>(Jn.addEventListener("message",({source:o,data:s})=>{o===Jn&&s===n&&r.length&&r.shift()()},!1),o=>{r.push(o),Jn.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",Ft(Jn.postMessage)),nv=typeof queueMicrotask<"u"?queueMicrotask.bind(Jn):typeof process<"u"&&process.nextTick||mc,V={isArray:pr,isArrayBuffer:cc,isBuffer:Vr,isFormData:Ax,isArrayBufferView:wx,isString:yx,isNumber:uc,isBoolean:Sx,isObject:Kr,isPlainObject:Lo,isEmptyObject:Cx,isReadableStream:Px,isRequest:_x,isResponse:Rx,isHeaders:Mx,isUndefined:mr,isDate:Tx,isFile:kx,isBlob:Ex,isRegExp:qx,isFunction:Ft,isStream:Nx,isURLSearchParams:jx,isTypedArray:Hx,isFileList:Ix,forEach:qr,merge:bi,extend:Dx,trim:Ox,stripBOM:Lx,inherits:$x,toFlatObject:Fx,kindOf:Oo,kindOfTest:an,endsWith:Bx,toArray:zx,forEachEntry:Ux,matchAll:Wx,isHTMLForm:Vx,hasOwnProperty:hc,hasOwnProp:hc,reduceDescriptors:pc,freezeMethods:Gx,toObjectSet:Yx,toCamelCase:Kx,noop:Xx,toFiniteNumber:Jx,findKey:dc,global:Jn,isContextDefined:fc,isSpecCompliantForm:Zx,toJSONObject:Qx,isAsyncFn:ev,isThenable:tv,setImmediate:mc,asap:nv,isIterable:e=>e!=null&&Ft(e[Mo])};function je(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(je,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:V.toJSONObject(this.config),code:this.code,status:this.status}}});const gc=je.prototype,xc={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{xc[e]={value:e}}),Object.defineProperties(je,xc),Object.defineProperty(gc,"isAxiosError",{value:!0}),je.from=(e,t,n,r,o,s)=>{const i=Object.create(gc);V.toFlatObject(e,i,function(d){return d!==Error.prototype},c=>c!=="isAxiosError");const a=e&&e.message?e.message:"Error",l=t==null&&e?e.code:t;return je.call(i,a,l,n,r,o),e&&i.cause==null&&Object.defineProperty(i,"cause",{value:e,configurable:!0}),i.name=e&&e.name||"Error",s&&Object.assign(i,s),i};const rv=null;function wi(e){return V.isPlainObject(e)||V.isArray(e)}function vc(e){return V.endsWith(e,"[]")?e.slice(0,-2):e}function bc(e,t,n){return e?e.concat(t).map(function(o,s){return o=vc(o),!n&&s?"["+o+"]":o}).join(n?".":""):t}function ov(e){return V.isArray(e)&&!e.some(wi)}const sv=V.toFlatObject(V,{},null,function(t){return/^is[A-Z]/.test(t)});function $o(e,t,n){if(!V.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=V.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(g,x){return!V.isUndefined(x[g])});const r=n.metaTokens,o=n.visitor||d,s=n.dots,i=n.indexes,l=(n.Blob||typeof Blob<"u"&&Blob)&&V.isSpecCompliantForm(t);if(!V.isFunction(o))throw new TypeError("visitor must be a function");function c(v){if(v===null)return"";if(V.isDate(v))return v.toISOString();if(V.isBoolean(v))return v.toString();if(!l&&V.isBlob(v))throw new je("Blob is not supported. Use a Buffer instead.");return V.isArrayBuffer(v)||V.isTypedArray(v)?l&&typeof Blob=="function"?new Blob([v]):Buffer.from(v):v}function d(v,g,x){let y=v;if(v&&!x&&typeof v=="object"){if(V.endsWith(g,"{}"))g=r?g:g.slice(0,-2),v=JSON.stringify(v);else if(V.isArray(v)&&ov(v)||(V.isFileList(v)||V.endsWith(g,"[]"))&&(y=V.toArray(v)))return g=vc(g),y.forEach(function(S,k){!(V.isUndefined(S)||S===null)&&t.append(i===!0?bc([g],k,s):i===null?g:g+"[]",c(S))}),!1}return wi(v)?!0:(t.append(bc(x,g,s),c(v)),!1)}const h=[],m=Object.assign(sv,{defaultVisitor:d,convertValue:c,isVisitable:wi});function f(v,g){if(!V.isUndefined(v)){if(h.indexOf(v)!==-1)throw Error("Circular reference detected in "+g.join("."));h.push(v),V.forEach(v,function(y,w){(!(V.isUndefined(y)||y===null)&&o.call(t,y,V.isString(w)?w.trim():w,g,m))===!0&&f(y,g?g.concat(w):[w])}),h.pop()}}if(!V.isObject(e))throw new TypeError("data must be an object");return f(e),t}function wc(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function yi(e,t){this._pairs=[],e&&$o(e,this,t)}const yc=yi.prototype;yc.append=function(t,n){this._pairs.push([t,n])},yc.toString=function(t){const n=t?function(r){return t.call(this,r,wc)}:wc;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function iv(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Sc(e,t,n){if(!t)return e;const r=n&&n.encode||iv;V.isFunction(n)&&(n={serialize:n});const o=n&&n.serialize;let s;if(o?s=o(t,n):s=V.isURLSearchParams(t)?t.toString():new yi(t,n).toString(r),s){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}class Cc{constructor(){this.handlers=[]}use(t,n,r){return this.handlers.push({fulfilled:t,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){V.forEach(this.handlers,function(r){r!==null&&t(r)})}}const Tc={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},av={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:yi,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},Si=typeof window<"u"&&typeof document<"u",Ci=typeof navigator=="object"&&navigator||void 0,lv=Si&&(!Ci||["ReactNative","NativeScript","NS"].indexOf(Ci.product)<0),cv=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",uv=Si&&window.location.href||"http://localhost",jt={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Si,hasStandardBrowserEnv:lv,hasStandardBrowserWebWorkerEnv:cv,navigator:Ci,origin:uv},Symbol.toStringTag,{value:"Module"})),...av};function dv(e,t){return $o(e,new jt.classes.URLSearchParams,{visitor:function(n,r,o,s){return jt.isNode&&V.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function fv(e){return V.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function hv(e){const t={},n=Object.keys(e);let r;const o=n.length;let s;for(r=0;r<o;r++)s=n[r],t[s]=e[s];return t}function kc(e){function t(n,r,o,s){let i=n[s++];if(i==="__proto__")return!0;const a=Number.isFinite(+i),l=s>=n.length;return i=!i&&V.isArray(o)?o.length:i,l?(V.hasOwnProp(o,i)?o[i]=[o[i],r]:o[i]=r,!a):((!o[i]||!V.isObject(o[i]))&&(o[i]=[]),t(n,r,o[i],s)&&V.isArray(o[i])&&(o[i]=hv(o[i])),!a)}if(V.isFormData(e)&&V.isFunction(e.entries)){const n={};return V.forEachEntry(e,(r,o)=>{t(fv(r),o,n,0)}),n}return null}function pv(e,t,n){if(V.isString(e))try{return(t||JSON.parse)(e),V.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const Gr={transitional:Tc,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",o=r.indexOf("application/json")>-1,s=V.isObject(t);if(s&&V.isHTMLForm(t)&&(t=new FormData(t)),V.isFormData(t))return o?JSON.stringify(kc(t)):t;if(V.isArrayBuffer(t)||V.isBuffer(t)||V.isStream(t)||V.isFile(t)||V.isBlob(t)||V.isReadableStream(t))return t;if(V.isArrayBufferView(t))return t.buffer;if(V.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let a;if(s){if(r.indexOf("application/x-www-form-urlencoded")>-1)return dv(t,this.formSerializer).toString();if((a=V.isFileList(t))||r.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return $o(a?{"files[]":t}:t,l&&new l,this.formSerializer)}}return s||o?(n.setContentType("application/json",!1),pv(t)):t}],transformResponse:[function(t){const n=this.transitional||Gr.transitional,r=n&&n.forcedJSONParsing,o=this.responseType==="json";if(V.isResponse(t)||V.isReadableStream(t))return t;if(t&&V.isString(t)&&(r&&!this.responseType||o)){const i=!(n&&n.silentJSONParsing)&&o;try{return JSON.parse(t,this.parseReviver)}catch(a){if(i)throw a.name==="SyntaxError"?je.from(a,je.ERR_BAD_RESPONSE,this,null,this.response):a}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:jt.classes.FormData,Blob:jt.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};V.forEach(["delete","get","head","post","put","patch"],e=>{Gr.headers[e]={}});const mv=V.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),gv=e=>{const t={};let n,r,o;return e&&e.split(`
|
|
31
|
-
`).forEach(function(i){o=i.indexOf(":"),n=i.substring(0,o).trim().toLowerCase(),r=i.substring(o+1).trim(),!(!n||t[n]&&
|
|
32
|
-
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const r=new this(t);return n.forEach(o=>r.set(o)),r}static accessor(t){const r=(this[Ec]=this[Ec]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=Yr(i);r[a]||(wv(o,i),r[a]=!0)}return V.isArray(t)?t.forEach(s):s(t),this}};Bt.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),V.reduceDescriptors(Bt.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),V.freezeMethods(Bt);function ki(e,t){const n=this||Gr,r=t||n,o=Bt.from(r.headers);let s=r.data;return V.forEach(e,function(a){s=a.call(n,s,o.normalize(),t?t.status:void 0)}),o.normalize(),s}function Ic(e){return!!(e&&e.__CANCEL__)}function gr(e,t,n){je.call(this,e??"canceled",je.ERR_CANCELED,t,n),this.name="CanceledError"}V.inherits(gr,je,{__CANCEL__:!0});function Nc(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new je("Request failed with status code "+n.status,[je.ERR_BAD_REQUEST,je.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function yv(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Sv(e,t){e=e||10;const n=new Array(e),r=new Array(e);let o=0,s=0,i;return t=t!==void 0?t:1e3,function(l){const c=Date.now(),d=r[s];i||(i=c),n[o]=l,r[o]=c;let h=s,m=0;for(;h!==o;)m+=n[h++],h=h%e;if(o=(o+1)%e,o===s&&(s=(s+1)%e),c-i<t)return;const f=d&&c-d;return f?Math.round(m*1e3/f):void 0}}function Cv(e,t){let n=0,r=1e3/t,o,s;const i=(c,d=Date.now())=>{n=d,o=null,s&&(clearTimeout(s),s=null),e(...c)};return[(...c)=>{const d=Date.now(),h=d-n;h>=r?i(c,d):(o=c,s||(s=setTimeout(()=>{s=null,i(o)},r-h)))},()=>o&&i(o)]}const Bo=(e,t,n=3)=>{let r=0;const o=Sv(50,250);return Cv(s=>{const i=s.loaded,a=s.lengthComputable?s.total:void 0,l=i-r,c=o(l),d=i<=a;r=i;const h={loaded:i,total:a,progress:a?i/a:void 0,bytes:l,rate:c||void 0,estimated:c&&a&&d?(a-i)/c:void 0,event:s,lengthComputable:a!=null,[t?"download":"upload"]:!0};e(h)},n)},Ac=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},jc=e=>(...t)=>V.asap(()=>e(...t)),Tv=jt.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,jt.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(jt.origin),jt.navigator&&/(msie|trident)/i.test(jt.navigator.userAgent)):()=>!0,kv=jt.hasStandardBrowserEnv?{write(e,t,n,r,o,s){const i=[e+"="+encodeURIComponent(t)];V.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),V.isString(r)&&i.push("path="+r),V.isString(o)&&i.push("domain="+o),s===!0&&i.push("secure"),document.cookie=i.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function Ev(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Iv(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function Pc(e,t,n){let r=!Ev(t);return e&&(r||n==!1)?Iv(e,t):t}const _c=e=>e instanceof Bt?{...e}:e;function Zn(e,t){t=t||{};const n={};function r(c,d,h,m){return V.isPlainObject(c)&&V.isPlainObject(d)?V.merge.call({caseless:m},c,d):V.isPlainObject(d)?V.merge({},d):V.isArray(d)?d.slice():d}function o(c,d,h,m){if(V.isUndefined(d)){if(!V.isUndefined(c))return r(void 0,c,h,m)}else return r(c,d,h,m)}function s(c,d){if(!V.isUndefined(d))return r(void 0,d)}function i(c,d){if(V.isUndefined(d)){if(!V.isUndefined(c))return r(void 0,c)}else return r(void 0,d)}function a(c,d,h){if(h in t)return r(c,d);if(h in e)return r(void 0,c)}const l={url:s,method:s,data:s,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:a,headers:(c,d,h)=>o(_c(c),_c(d),h,!0)};return V.forEach(Object.keys({...e,...t}),function(d){const h=l[d]||o,m=h(e[d],t[d],d);V.isUndefined(m)&&h!==a||(n[d]=m)}),n}const Rc=e=>{const t=Zn({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=Bt.from(i),t.url=Sc(Pc(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&i.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),V.isFormData(n)){if(jt.hasStandardBrowserEnv||jt.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(V.isFunction(n.getHeaders)){const l=n.getHeaders(),c=["content-type","content-length"];Object.entries(l).forEach(([d,h])=>{c.includes(d.toLowerCase())&&i.set(d,h)})}}if(jt.hasStandardBrowserEnv&&(r&&V.isFunction(r)&&(r=r(t)),r||r!==!1&&Tv(t.url))){const l=o&&s&&kv.read(s);l&&i.set(o,l)}return t},Nv=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=Rc(e);let s=o.data;const i=Bt.from(o.headers).normalize();let{responseType:a,onUploadProgress:l,onDownloadProgress:c}=o,d,h,m,f,v;function g(){f&&f(),v&&v(),o.cancelToken&&o.cancelToken.unsubscribe(d),o.signal&&o.signal.removeEventListener("abort",d)}let x=new XMLHttpRequest;x.open(o.method.toUpperCase(),o.url,!0),x.timeout=o.timeout;function y(){if(!x)return;const S=Bt.from("getAllResponseHeaders"in x&&x.getAllResponseHeaders()),C={data:!a||a==="text"||a==="json"?x.responseText:x.response,status:x.status,statusText:x.statusText,headers:S,config:e,request:x};Nc(function(E){n(E),g()},function(E){r(E),g()},C),x=null}"onloadend"in x?x.onloadend=y:x.onreadystatechange=function(){!x||x.readyState!==4||x.status===0&&!(x.responseURL&&x.responseURL.indexOf("file:")===0)||setTimeout(y)},x.onabort=function(){x&&(r(new je("Request aborted",je.ECONNABORTED,e,x)),x=null)},x.onerror=function(k){const C=k&&k.message?k.message:"Network Error",T=new je(C,je.ERR_NETWORK,e,x);T.event=k||null,r(T),x=null},x.ontimeout=function(){let k=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const C=o.transitional||Tc;o.timeoutErrorMessage&&(k=o.timeoutErrorMessage),r(new je(k,C.clarifyTimeoutError?je.ETIMEDOUT:je.ECONNABORTED,e,x)),x=null},s===void 0&&i.setContentType(null),"setRequestHeader"in x&&V.forEach(i.toJSON(),function(k,C){x.setRequestHeader(C,k)}),V.isUndefined(o.withCredentials)||(x.withCredentials=!!o.withCredentials),a&&a!=="json"&&(x.responseType=o.responseType),c&&([m,v]=Bo(c,!0),x.addEventListener("progress",m)),l&&x.upload&&([h,f]=Bo(l),x.upload.addEventListener("progress",h),x.upload.addEventListener("loadend",f)),(o.cancelToken||o.signal)&&(d=S=>{x&&(r(!S||S.type?new gr(null,e,x):S),x.abort(),x=null)},o.cancelToken&&o.cancelToken.subscribe(d),o.signal&&(o.signal.aborted?d():o.signal.addEventListener("abort",d)));const w=yv(o.url);if(w&&jt.protocols.indexOf(w)===-1){r(new je("Unsupported protocol "+w+":",je.ERR_BAD_REQUEST,e));return}x.send(s||null)})},Av=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let r=new AbortController,o;const s=function(c){if(!o){o=!0,a();const d=c instanceof Error?c:this.reason;r.abort(d instanceof je?d:new gr(d instanceof Error?d.message:d))}};let i=t&&setTimeout(()=>{i=null,s(new je(`timeout ${t} of ms exceeded`,je.ETIMEDOUT))},t);const a=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(c=>{c.unsubscribe?c.unsubscribe(s):c.removeEventListener("abort",s)}),e=null)};e.forEach(c=>c.addEventListener("abort",s));const{signal:l}=r;return l.unsubscribe=()=>V.asap(a),l}},jv=function*(e,t){let n=e.byteLength;if(n<t){yield e;return}let r=0,o;for(;r<n;)o=r+t,yield e.slice(r,o),r=o},Pv=async function*(e,t){for await(const n of _v(e))yield*jv(n,t)},_v=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:n,value:r}=await t.read();if(n)break;yield r}}finally{await t.cancel()}},Mc=(e,t,n,r)=>{const o=Pv(e,t);let s=0,i,a=l=>{i||(i=!0,r&&r(l))};return new ReadableStream({async pull(l){try{const{done:c,value:d}=await o.next();if(c){a(),l.close();return}let h=d.byteLength;if(n){let m=s+=h;n(m)}l.enqueue(new Uint8Array(d))}catch(c){throw a(c),c}},cancel(l){return a(l),o.return()}},{highWaterMark:2})},Oc=64*1024,{isFunction:zo}=V,Rv=(({Request:e,Response:t})=>({Request:e,Response:t}))(V.global),{ReadableStream:Dc,TextEncoder:Lc}=V.global,$c=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Mv=e=>{e=V.merge.call({skipUndefined:!0},Rv,e);const{fetch:t,Request:n,Response:r}=e,o=t?zo(t):typeof fetch=="function",s=zo(n),i=zo(r);if(!o)return!1;const a=o&&zo(Dc),l=o&&(typeof Lc=="function"?(v=>g=>v.encode(g))(new Lc):async v=>new Uint8Array(await new n(v).arrayBuffer())),c=s&&a&&$c(()=>{let v=!1;const g=new n(jt.origin,{body:new Dc,method:"POST",get duplex(){return v=!0,"half"}}).headers.has("Content-Type");return v&&!g}),d=i&&a&&$c(()=>V.isReadableStream(new r("").body)),h={stream:d&&(v=>v.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(v=>{!h[v]&&(h[v]=(g,x)=>{let y=g&&g[v];if(y)return y.call(g);throw new je(`Response type '${v}' is not supported`,je.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(jt.origin,{method:"POST",body:v}).arrayBuffer()).byteLength;if(V.isArrayBufferView(v)||V.isArrayBuffer(v))return v.byteLength;if(V.isURLSearchParams(v)&&(v=v+""),V.isString(v))return(await l(v)).byteLength},f=async(v,g)=>{const x=V.toFiniteNumber(v.getContentLength());return x??m(g)};return async v=>{let{url:g,method:x,data:y,signal:w,cancelToken:S,timeout:k,onDownloadProgress:C,onUploadProgress:T,responseType:E,headers:j,withCredentials:P="same-origin",fetchOptions:D}=Rc(v),F=t||fetch;E=E?(E+"").toLowerCase():"text";let W=Av([w,S&&S.toAbortSignal()],k),G=null;const A=W&&W.unsubscribe&&(()=>{W.unsubscribe()});let X;try{if(T&&c&&x!=="get"&&x!=="head"&&(X=await f(j,y))!==0){let Y=new n(g,{method:"POST",body:y,duplex:"half"}),_;if(V.isFormData(y)&&(_=Y.headers.get("content-type"))&&j.setContentType(_),Y.body){const[O,M]=Ac(X,Bo(jc(T)));y=Mc(Y.body,Oc,O,M)}}V.isString(P)||(P=P?"include":"omit");const q=s&&"credentials"in n.prototype,B={...D,signal:W,method:x.toUpperCase(),headers:j.normalize().toJSON(),body:y,duplex:"half",credentials:q?P:void 0};G=s&&new n(g,B);let R=await(s?F(G,D):F(g,B));const I=d&&(E==="stream"||E==="response");if(d&&(C||I&&A)){const Y={};["status","statusText","headers"].forEach(L=>{Y[L]=R[L]});const _=V.toFiniteNumber(R.headers.get("content-length")),[O,M]=C&&Ac(_,Bo(jc(C),!0))||[];R=new r(Mc(R.body,Oc,O,()=>{M&&M(),A&&A()}),Y)}E=E||"text";let H=await h[V.findKey(h,E)||"text"](R,v);return!I&&A&&A(),await new Promise((Y,_)=>{Nc(Y,_,{data:H,headers:Bt.from(R.headers),status:R.status,statusText:R.statusText,config:v,request:G})})}catch(q){throw A&&A(),q&&q.name==="TypeError"&&/Load failed|fetch/i.test(q.message)?Object.assign(new je("Network Error",je.ERR_NETWORK,v,G),{cause:q.cause||q}):je.from(q,q&&q.code,v,G)}}},Ov=new Map,Fc=e=>{let t=e?e.env:{};const{fetch:n,Request:r,Response:o}=t,s=[r,o,n];let i=s.length,a=i,l,c,d=Ov;for(;a--;)l=s[a],c=d.get(l),c===void 0&&d.set(l,c=a?new Map:Mv(t)),d=c;return c};Fc();const Ei={http:rv,xhr:Nv,fetch:{get:Fc}};V.forEach(Ei,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Bc=e=>`- ${e}`,Dv=e=>V.isFunction(e)||e===null||e===!1,zc={getAdapter:(e,t)=>{e=V.isArray(e)?e:[e];const{length:n}=e;let r,o;const s={};for(let i=0;i<n;i++){r=e[i];let a;if(o=r,!Dv(r)&&(o=Ei[(a=String(r)).toLowerCase()],o===void 0))throw new je(`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
|
-
`+i.map(
|
|
34
|
-
`):" "+
|
|
35
|
-
`+s):r.stack=s}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=Zn(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:s}=n;r!==void 0&&Uo.assertOptions(r,{silentJSONParsing:gn.transitional(gn.boolean),forcedJSONParsing:gn.transitional(gn.boolean),clarifyTimeoutError:gn.transitional(gn.boolean)},!1),o!=null&&(V.isFunction(o)?n.paramsSerializer={serialize:o}:Uo.assertOptions(o,{encode:gn.function,serialize:gn.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Uo.assertOptions(n,{baseUrl:gn.spelling("baseURL"),withXsrfToken:gn.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=s&&V.merge(s.common,s[n.method]);s&&V.forEach(["delete","get","head","post","put","patch","common"],v=>{delete s[v]}),n.headers=Bt.concat(i,s);const a=[];let l=!0;this.interceptors.request.forEach(function(g){typeof g.runWhen=="function"&&g.runWhen(n)===!1||(l=l&&g.synchronous,a.unshift(g.fulfilled,g.rejected))});const c=[];this.interceptors.response.forEach(function(g){c.push(g.fulfilled,g.rejected)});let d,h=0,m;if(!l){const v=[Hc.bind(this),void 0];for(v.unshift(...a),v.push(...c),m=v.length,d=Promise.resolve(n);h<m;)d=d.then(v[h++],v[h++]);return d}m=a.length;let f=n;for(;h<m;){const v=a[h++],g=a[h++];try{f=v(f)}catch(x){g.call(this,x);break}}try{d=Hc.call(this,f)}catch(v){return Promise.reject(v)}for(h=0,m=c.length;h<m;)d=d.then(c[h++],c[h++]);return d}getUri(t){t=Zn(this.defaults,t);const n=Pc(t.baseURL,t.url,t.allowAbsoluteUrls);return Sc(n,t.params,t.paramsSerializer)}};V.forEach(["delete","get","head","options"],function(t){Qn.prototype[t]=function(n,r){return this.request(Zn(r||{},{method:t,url:n,data:(r||{}).data}))}}),V.forEach(["post","put","patch"],function(t){function n(r){return function(s,i,a){return this.request(Zn(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}Qn.prototype[t]=n(),Qn.prototype[t+"Form"]=n(!0)});let $v=class rx{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(s){n=s});const r=this;this.promise.then(o=>{if(!r._listeners)return;let s=r._listeners.length;for(;s-- >0;)r._listeners[s](o);r._listeners=null}),this.promise.then=o=>{let s;const i=new Promise(a=>{r.subscribe(a),s=a}).then(o);return i.cancel=function(){r.unsubscribe(s)},i},t(function(s,i,a){r.reason||(r.reason=new gr(s,i,a),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const t=new AbortController,n=r=>{t.abort(r)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new rx(function(o){t=o}),cancel:t}}};function Fv(e){return function(n){return e.apply(null,n)}}function Bv(e){return V.isObject(e)&&e.isAxiosError===!0}const Ni={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Ni).forEach(([e,t])=>{Ni[t]=e});function Vc(e){const t=new Qn(e),n=ac(Qn.prototype.request,t);return V.extend(n,Qn.prototype,t,{allOwnKeys:!0}),V.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return Vc(Zn(e,o))},n}const dt=Vc(Gr);dt.Axios=Qn,dt.CanceledError=gr,dt.CancelToken=$v,dt.isCancel=Ic,dt.VERSION=Uc,dt.toFormData=$o,dt.AxiosError=je,dt.Cancel=dt.CanceledError,dt.all=function(t){return Promise.all(t)},dt.spread=Fv,dt.isAxiosError=Bv,dt.mergeConfig=Zn,dt.AxiosHeaders=Bt,dt.formToJSON=e=>kc(V.isHTMLForm(e)?new FormData(e):e),dt.getAdapter=zc.getAdapter,dt.HttpStatusCode=Ni,dt.default=dt;const{Axios:hN,AxiosError:pN,CanceledError:mN,isCancel:gN,CancelToken:xN,VERSION:vN,all:bN,Cancel:wN,isAxiosError:yN,spread:SN,toFormData:CN,AxiosHeaders:TN,HttpStatusCode:kN,formToJSON:EN,getAdapter:IN,mergeConfig:NN}=dt,Kc=typeof window<"u"?window.__API_BASE_URL__:void 0,qc=Kc?xn(Kc):void 0;function xn(e){const n=(e!=null&&e.trim()?e.trim():"/api/chat").replace(/\/+$/,"");return n?n.endsWith("/chat")?n:`${n}/chat`:"/api/chat"}let Wo=null;const Ai=new Set;function Gc(){return Wo}function Vo(e){Wo=e,Ai.forEach(t=>t(e))}function Yc(e){return Ai.add(e),()=>Ai.delete(e)}const Xc=3e4,Jc=9e4,Gt=dt.create({...qc?{baseURL:qc}:{},timeout:Xc,withCredentials:!0});Gt.interceptors.request.use(e=>(Wo&&(e.headers.Authorization=`Bearer ${Wo}`),e)),Gt.interceptors.response.use(e=>{if(typeof window<"u"&&(e!=null&&e.data))try{const t=e.data,n=t.data||{},r=typeof t.token=="string"&&t.token||typeof n.token=="string"&&n.token||null,o=typeof t.expires_at=="number"&&t.expires_at||typeof n.expires_at=="number"&&n.expires_at||typeof t.expiresAt=="number"&&t.expiresAt||typeof n.expiresAt=="number"&&n.expiresAt||null;r&&(localStorage.setItem("authToken",r),Vo(r)),o&&localStorage.setItem("authTokenExpiresAt",o.toString()),(r||o)&&window.dispatchEvent(new CustomEvent("smartorg:chat-token-updated",{detail:{token:r,expiresAt:o}}))}catch(t){console.warn("[chat-api] Error storing token:",t)}return e},e=>Promise.reject(e));async function Yt(e,t){return Gt.defaults.baseURL?(await Gt.get(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}async function Ko(e,t,n){return Gt.defaults.baseURL?(await Gt.post(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function Zc(e,t,n){return Gt.defaults.baseURL?(await Gt.put(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function ji(e,t){return Gt.defaults.baseURL?(await Gt.delete(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}function Ot(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class qo{get baseUrl(){const t=Gt.defaults.baseURL;return t?xn(String(t)):""}updateConfig(t){t.baseUrl&&(Gt.defaults.baseURL=xn(String(t.baseUrl))),t.authToken!==void 0&&Vo(t.authToken)}getAuthToken(){return Gc()}setAuthToken(t){Vo(t)}onTokenChange(t){return Yc(t)}async listThreads(){const t=await Yt("/threads"),n=Ot(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async listSharedThreads(){const t=await Yt("/threads/shared"),n=Ot(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async createThread(t){const r=await Ko("/threads",t?{title:t}:void 0);return Ot(r)}async updateThread(t,n){const r=await Zc(`/threads/${t}`,{title:n});return Ot(r)}async deleteThread(t){const n=await ji(`/threads/${t}`);return Ot(n)}async shareThread(t,n){const r=await Ko(`/threads/${t}/share`,{shared_with_user_id:n});return Ot(r)}async threadInfo(t){const n=await Yt(`/threads/${t}/info`);return Ot(n)}async listAgents(){const t=await Yt("/agents"),n=Ot(t);return(n==null?void 0:n.items)??[]}async getAgent(t){const n=await Yt(`/agents/${t}`);return Ot(n)}async getAgentSchema(t){const n=await Yt(`/agents/${t}/schema`);return Ot(n)}async getState(t){const n=await Yt(`/threads/${t.threadId}/state`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return Ot(n)}async getStateHistory(t){const n=await Yt(`/threads/${t.threadId}/state/history`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs},timeout:Jc});return Ot(n)}async cancelRun(t){const n=await Ko("/runs/cancel",{threadId:t});return Ot(n)}async unshareThread(t,n){const r=await ji(`/threads/${t}/share/${n}`);return Ot(r)}}const Nn=new qo,zv=qo,Hv=qo;async function Pi(e,t){return await Yt(e,{responseType:"blob",onDownloadProgress:r=>{try{if(t&&r.lengthComputable){const o=r.loaded/r.total;t(o)}}catch{}},maxBodyLength:1/0})}async function Uv(e,t){const n=await Pi(`/files/${e}/view`,t),r=URL.createObjectURL(n);window.open(r,"_blank"),setTimeout(()=>URL.revokeObjectURL(r),6e4)}async function _i(e,t){return await(await Pi(`/files/${e}/view`,t)).text()}async function Qc(e,t){const n=await Pi(`/files/${e}/download`,t),r=URL.createObjectURL(n);let o=`file_${e}`;try{const i=await Yt(`/files/${e}`);o=(i==null?void 0:i.filename)??o}catch{}const s=document.createElement("a");s.href=r,s.download=o,document.body.appendChild(s),s.click(),s.remove(),setTimeout(()=>URL.revokeObjectURL(r),6e4)}async function Wv(e){return await Yt(`/files/${e}`)}async function eu(e,t=50,n=0){const r={limit:t,offset:n};return e&&(r.thread_id=e),await Yt("/files",{params:r})}const tu=b.createContext(null);function nu({children:e,apiConfig:t}){const n=Nn;if(t){const o=n.baseUrl,s=n.getAuthToken();t.baseUrl&&t.baseUrl!==o&&n.updateConfig({baseUrl:t.baseUrl}),t.apiKey!==void 0&&t.apiKey!==s&&n.updateConfig({authToken:t.apiKey})}const r={token:n.getAuthToken(),setToken:o=>n.setAuthToken(o),api:n,baseUrl:n.baseUrl};return u.jsx(tu.Provider,{value:r,children:e})}async function ru(e){return await new Promise((t,n)=>{const r=new FileReader;r.onload=()=>{try{const o=r.result,s=new Uint8Array(o);let i="";const a=s.byteLength;for(let l=0;l<a;l++)i+=String.fromCharCode(s[l]);t(btoa(i))}catch(o){n(o)}},r.onerror=o=>n(o),r.readAsArrayBuffer(e)})}async function ou(e=[]){const t=[],n=[];for(const r of e)try{const o=await ru(r);n.push({filename:r.name,data:o,mime_type:r.type||"application/octet-stream"})}catch{}return{contentParts:t,filesInfo:n}}function Xr(){const e=b.useContext(tu);if(!e)throw new Error("useApi must be used within ApiProvider");return e}function su(e){return!!e&&typeof e=="object"&&"data"in e}function Ri(e){return e.filter(t=>{var i;if(t.role!=="assistant")return!0;const n=(t.content??[]).some(a=>{var l;return a&&a.type==="text"&&((l=a.text)==null?void 0:l.trim())}),r=(t.content??[]).some(a=>a&&a.type==="image_url"),o=(i=t.artifact)==null?void 0:i.plots,s=Array.isArray(o)&&o.length>0;return!!(n||r||s)})}function Jr(e,t,n){return t<0||t>=e.length?e:[...e.slice(0,t),n,...e.slice(t+1)]}function Vv(e){let t=!1;const n=e.map(r=>{const o=(r.content??[]).filter(s=>s.type!=="interrupt");return o.length!==r.content.length?(t=!0,{...r,content:o}):r});return t?n:e}function iu(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="assistant")return e[t].id;return null}function au(e){return!e||!e.length?"":e.filter(t=>t.type==="text").map(t=>t.text??"").join("")}function lu(e,t,n,r){const o={...n};if(r!==null&&typeof r=="number"){if(typeof o.lastSeq=="number"&&r<=o.lastSeq)return{newParts:e,newMeta:o,changed:!1};o.lastSeq=r}const s=t.filter(h=>h.type==="text").map(h=>h.text??"").join(""),i=t.filter(h=>h.type!=="text"),a=o.lastText??au(e);let l="",c=e.slice();if(s){const h=Kv(a,s);if(h===""?l="":h===s?l=s:l=h,l){const m=c[c.length-1];if((m==null?void 0:m.type)==="text"){const f=m.text??"",v={...m,text:f+l};c=[...c.slice(0,c.length-1),v]}else c=[...c,{type:"text",text:l}];o.lastText=a+l}else o.lastText=a}i.length&&(c=[...c,...i]);const d=!!(l||i.length);return{newParts:c,newMeta:o,changed:d}}function cu(e){return e.replace(/\s+/g," ").trim()}function Kv(e,t){if(!t)return"";if(!e)return t;if(e===t)return"";const n=Math.min(e.length,t.length);for(let i=n;i>0;i--)if(e.slice(-i)===t.slice(0,i))return t.slice(i);const r=cu(e),o=cu(t);if(r===o)return"";const s=Math.min(r.length,o.length);for(let i=s;i>0;i--)if(r.slice(-i)===o.slice(0,i))return t;return t}function qv(e,t,n){for(let r=e.length-1;r>=0;r--)if(e[r].role==="assistant"){const s={...e[r],checkpointId:t,checkpointNs:n??void 0};return Jr(e,r,s)}return e}function uu(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}function Gv(e={}){const t=b.useMemo(()=>xn(e.baseUrl),[e.baseUrl]),n=e.streamPath??"/runs/stream",[r,o]=b.useState(e.token??null),s=b.useRef(e.headers??{}),i=e.credentials??"include",[a,l]=b.useState(!1),[c,d]=b.useState(null),[h,m]=b.useState(""),[f,v]=b.useState(null),[g,x]=b.useState(0),[y,w]=b.useState(!1),[S,k]=b.useState(null),C=b.useRef(null),T=b.useRef(!0),E=b.useRef(0),j=b.useRef(null),P=b.useRef(null),D=b.useRef(null),F=b.useRef(null),W=b.useRef({messageId:null,lastSeq:null,lastText:""}),G=b.useCallback(B=>{o(B)},[]),A=b.useCallback(()=>{m(""),v(null),d(null),P.current=null,D.current=null,F.current=null,k(null),W.current={messageId:null,lastSeq:null,lastText:""}},[]),X=b.useCallback(()=>{var H;console.debug("[use-chat] stop() invoked - aborting stream");const B=(H=j.current)==null?void 0:H.threadId,R=()=>{var Y;(Y=C.current)==null||Y.abort(),C.current=null,j.current=null,l(!1),w(!1),E.current=0,x(0)};(B?Nn.cancelRun(B).catch(Y=>{console.warn("[use-chat] cancel run failed:",Y)}):Promise.resolve()).finally(R)},[]),q=b.useCallback((B,R,I)=>{C.current&&(C.current.abort(),C.current=null),l(!0),d(null),e.autoAppendAssistant!==!1&&m(""),v(null),P.current=null,D.current=null,F.current=null,k(null),W.current={messageId:null,lastSeq:null,lastText:""};const H=new AbortController;C.current=H;let Y=null,_=null,O=!1;return j.current={threadId:B.threadId??null,headers:{}},(async()=>{var L,te,z,$,ee,J,K,Q,pe,de,me,we,Te,Ne,ke,st,vt,pt;const M=We=>{var Le;try{const Ge=JSON.parse(JSON.stringify(We));return(Le=Ge==null?void 0:Ge.payload)!=null&&Le.files_info&&Array.isArray(Ge.payload.files_info)&&(Ge.payload.files_info=Ge.payload.files_info.map(Re=>({...Re,data:Re!=null&&Re.data?`<base64 ${String(Re.data).length} chars>`:Re==null?void 0:Re.data}))),Ge}catch{return We}};try{let We={};try{if(r)We={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const Ve=window.__AUTH_TOKEN__,At=((L=window.localStorage)==null?void 0:L.getItem("authToken"))||null;let Z=null;try{const He=(te=window.localStorage)==null?void 0:te.getItem("chat-settings");He&&(Z=((z=JSON.parse(He))==null?void 0:z.apiKey)||null)}catch{}const ce=Ve||At||Z||null;ce&&(We={Authorization:`Bearer ${ce}`})}}catch{}console.debug("[use-chat] POST",t+n,M(B));let Le={};if(typeof window<"u")try{const Fe=($=window.localStorage)==null?void 0:$.getItem("authSessionId");Fe&&(Le={"X-Session-Id":Fe})}catch{}const Ge={...We,...Le,...s.current},Re={"Content-Type":"application/json",Accept:"text/event-stream",...Ge},$e=await fetch(t+n,{method:"POST",headers:Re,body:JSON.stringify(B),signal:H.signal,credentials:i});if(j.current&&(j.current.headers=Ge),!$e.ok||!$e.body){const Fe=await $e.text().catch(()=>"");console.debug("[use-chat] non-OK response",$e.status,Fe==null?void 0:Fe.slice(0,500));const Ve=`stream ${$e.status}${Fe?": "+Fe:""}`;throw(ee=I==null?void 0:I.onConnectionError)==null||ee.call(I,Ve),O=!0,Y="error",_=Ve,new Error(Ve)}w(!0);const Ze=$e.body.getReader(),It=new TextDecoder;let it="",yt=[];E.current=0,x(0);let St=0,Ct=null;const kt=()=>{if(yt.length){const Fe=yt.join("");yt=[],T.current&&m(Ve=>Ve+Fe)}Ct=null},on=()=>{typeof window<"u"&&Ct==null&&(Ct=requestAnimationFrame(kt))};let Nt=Date.now();const Vt=setInterval(()=>{var Fe;if(Date.now()-Nt>18e5){const Ve="Stream idle timeout";d(Ve),Y="error",_=Ve,H.abort(),(Fe=I==null?void 0:I.onError)==null||Fe.call(I,Ve)}},5e3),Et=1024*1024;try{const Fe=$e.headers.get("X-Thread-Id")||$e.headers.get("x-thread-id"),Ve=$e.headers.get("X-Thread-Created")||$e.headers.get("x-thread-created"),At=Fe??null,Z=String(Ve??"").toLowerCase()==="true";for(j.current&&!j.current.threadId&&(j.current={...j.current,threadId:At}),(J=I==null?void 0:I.onOpen)==null||J.call(I,{threadId:At,created:Z});;){const{value:ce,done:He}=await Ze.read();if(He)break;it+=It.decode(ce,{stream:!0}),it.length>Et&&(it="",console.warn("Stream buffer reset: exceeded 1MB"));let ve;for(;(ve=it.indexOf(`
|
|
30
|
+
<%s key={someKey} {...props} />`,cc,hr,l1,hr),ct[hr+cc]=!0}}return N===r?lt(bt):Ke(bt),bt}}function mt(N,oe,le){return Re(N,oe,le,!0)}function Qe(N,oe,le){return Re(N,oe,le,!1)}var ut=Qe,An=mt;Kr.Fragment=r,Kr.jsx=ut,Kr.jsxs=An}()),Kr}process.env.NODE_ENV==="production"?Ti.exports=Xx():Ti.exports=Jx();var c=Ti.exports;const Zx=({timelineEntries:e,activeCheckpointId:t,onSelectCheckpoint:n,messagePreviews:r,className:o,onHoverStart:s,onHoverEnd:i})=>{const a=e??[],l=a.length>0,u=v.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 c.jsxs("div",{className:m,onMouseEnter:s,onMouseLeave:i,children:[c.jsxs("div",{className:"relative flex-1 overflow-y-auto pt-4 pb-2 pr-1",children:[c.jsx("div",{className:"absolute left-0 right-0 top-1 px-2 pb-3 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:c.jsx("span",{children:"Timeline"})}),c.jsx("div",{className:"pointer-events-none absolute left-3 top-0 bottom-0 w-px bg-border/40"}),c.jsx("div",{className:"flex flex-col gap-3 pt-6 pr-2",children:u.map(p=>{const b=d===p.id,g=(r==null?void 0:r.get(p.id))??null;return c.jsxs("button",{type:"button",disabled:!n,onClick:()=>n==null?void 0:n(p.id),className:`relative flex items-start gap-2 text-left text-[11px] transition ${b?"text-primary":"text-muted-foreground"} ${n?"hover:text-foreground":"cursor-default opacity-70"}`,children:[c.jsx("span",{className:`mt-1 inline-flex h-3 w-3 items-center justify-center rounded-full border ${b?"border-primary bg-primary/10 text-primary":"border-border bg-background"}`,children:c.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${b?"bg-primary":"bg-border"}`})}),c.jsxs("span",{className:"flex-1",children:[c.jsx("span",{className:"block font-medium leading-tight",children:p.label||"User input"}),c.jsxs("span",{className:"text-[9px] uppercase tracking-wide text-muted-foreground/70",children:[p.step!==null?`STEP ${p.step}`:"STEP —",p.next?` - ${p.next}`:""]}),g&&c.jsx("p",{className:"text-[10px] text-muted-foreground/80 mt-1 line-clamp-2",title:g,children:g})]})]},p.id)})})]}),n&&c.jsx("button",{type:"button",onClick:()=>n==null?void 0:n(null),className:"mt-auto mb-3 rounded-md border border-border/70 px-2 py-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground transition hover:border-foreground/60 hover:text-foreground",children:"Latest"})]})};function bc(e,t){return function(){return e.apply(t,arguments)}}const{toString:Qx}=Object.prototype,{getPrototypeOf:ki}=Object,{iterator:Fo,toStringTag:wc}=Symbol,Bo=(e=>t=>{const n=Qx.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),ln=e=>(e=e.toLowerCase(),t=>Bo(t)===e),zo=e=>t=>typeof t===e,{isArray:mr}=Array,gr=zo("undefined");function qr(e){return e!==null&&!gr(e)&&e.constructor!==null&&!gr(e.constructor)&&Bt(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const yc=ln("ArrayBuffer");function ev(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&yc(e.buffer),t}const tv=zo("string"),Bt=zo("function"),Sc=zo("number"),Gr=e=>e!==null&&typeof e=="object",nv=e=>e===!0||e===!1,Ho=e=>{if(Bo(e)!=="object")return!1;const t=ki(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(wc in e)&&!(Fo in e)},rv=e=>{if(!Gr(e)||qr(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},ov=ln("Date"),sv=ln("File"),iv=ln("Blob"),av=ln("FileList"),lv=e=>Gr(e)&&Bt(e.pipe),cv=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||Bt(e.append)&&((t=Bo(e))==="formdata"||t==="object"&&Bt(e.toString)&&e.toString()==="[object FormData]"))},uv=ln("URLSearchParams"),[dv,fv,pv,hv]=["ReadableStream","Request","Response","Headers"].map(ln),mv=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Yr(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,o;if(typeof e!="object"&&(e=[e]),mr(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{if(qr(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 Cc(e,t){if(qr(e))return null;t=t.toLowerCase();const n=Object.keys(e);let r=n.length,o;for(;r-- >0;)if(o=n[r],t===o.toLowerCase())return o;return null}const Zn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Tc=e=>!gr(e)&&e!==Zn;function Ei(){const{caseless:e,skipUndefined:t}=Tc(this)&&this||{},n={},r=(o,s)=>{const i=e&&Cc(n,s)||s;Ho(n[i])&&Ho(o)?n[i]=Ei(n[i],o):Ho(o)?n[i]=Ei({},o):mr(o)?n[i]=o.slice():(!t||!gr(o))&&(n[i]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&Yr(arguments[o],r);return n}const gv=(e,t,n,{allOwnKeys:r}={})=>(Yr(t,(o,s)=>{n&&Bt(o)?e[s]=bc(o,n):e[s]=o},{allOwnKeys:r}),e),xv=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),vv=(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)},bv=(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&&ki(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},wv=(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},yv=e=>{if(!e)return null;if(mr(e))return e;let t=e.length;if(!Sc(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Sv=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&ki(Uint8Array)),Cv=(e,t)=>{const r=(e&&e[Fo]).call(e);let o;for(;(o=r.next())&&!o.done;){const s=o.value;t.call(e,s[0],s[1])}},Tv=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},kv=ln("HTMLFormElement"),Ev=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),kc=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),Iv=ln("RegExp"),Ec=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};Yr(n,(o,s)=>{let i;(i=t(o,s,e))!==!1&&(r[s]=i||o)}),Object.defineProperties(e,r)},Nv=e=>{Ec(e,(t,n)=>{if(Bt(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(Bt(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+"'")})}})},Av=(e,t)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return mr(e)?r(e):r(String(e).split(t)),n},jv=()=>{},_v=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function Pv(e){return!!(e&&Bt(e.append)&&e[wc]==="FormData"&&e[Fo])}const Rv=e=>{const t=new Array(10),n=(r,o)=>{if(Gr(r)){if(t.indexOf(r)>=0)return;if(qr(r))return r;if(!("toJSON"in r)){t[o]=r;const s=mr(r)?[]:{};return Yr(r,(i,a)=>{const l=n(i,o+1);!gr(l)&&(s[a]=l)}),t[o]=void 0,s}}return r};return n(e,0)},Mv=ln("AsyncFunction"),Ov=e=>e&&(Gr(e)||Bt(e))&&Bt(e.then)&&Bt(e.catch),Ic=((e,t)=>e?setImmediate:t?((n,r)=>(Zn.addEventListener("message",({source:o,data:s})=>{o===Zn&&s===n&&r.length&&r.shift()()},!1),o=>{r.push(o),Zn.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",Bt(Zn.postMessage)),Dv=typeof queueMicrotask<"u"?queueMicrotask.bind(Zn):typeof process<"u"&&process.nextTick||Ic,V={isArray:mr,isArrayBuffer:yc,isBuffer:qr,isFormData:cv,isArrayBufferView:ev,isString:tv,isNumber:Sc,isBoolean:nv,isObject:Gr,isPlainObject:Ho,isEmptyObject:rv,isReadableStream:dv,isRequest:fv,isResponse:pv,isHeaders:hv,isUndefined:gr,isDate:ov,isFile:sv,isBlob:iv,isRegExp:Iv,isFunction:Bt,isStream:lv,isURLSearchParams:uv,isTypedArray:Sv,isFileList:av,forEach:Yr,merge:Ei,extend:gv,trim:mv,stripBOM:xv,inherits:vv,toFlatObject:bv,kindOf:Bo,kindOfTest:ln,endsWith:wv,toArray:yv,forEachEntry:Cv,matchAll:Tv,isHTMLForm:kv,hasOwnProperty:kc,hasOwnProp:kc,reduceDescriptors:Ec,freezeMethods:Nv,toObjectSet:Av,toCamelCase:Ev,noop:jv,toFiniteNumber:_v,findKey:Cc,global:Zn,isContextDefined:Tc,isSpecCompliantForm:Pv,toJSONObject:Rv,isAsyncFn:Mv,isThenable:Ov,setImmediate:Ic,asap:Dv,isIterable:e=>e!=null&&Bt(e[Fo])};function je(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(je,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 Nc=je.prototype,Ac={};["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=>{Ac[e]={value:e}}),Object.defineProperties(je,Ac),Object.defineProperty(Nc,"isAxiosError",{value:!0}),je.from=(e,t,n,r,o,s)=>{const i=Object.create(Nc);V.toFlatObject(e,i,function(d){return d!==Error.prototype},u=>u!=="isAxiosError");const a=e&&e.message?e.message:"Error",l=t==null&&e?e.code:t;return je.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 Lv=null;function Ii(e){return V.isPlainObject(e)||V.isArray(e)}function jc(e){return V.endsWith(e,"[]")?e.slice(0,-2):e}function _c(e,t,n){return e?e.concat(t).map(function(o,s){return o=jc(o),!n&&s?"["+o+"]":o}).join(n?".":""):t}function $v(e){return V.isArray(e)&&!e.some(Ii)}const Fv=V.toFlatObject(V,{},null,function(t){return/^is[A-Z]/.test(t)});function Uo(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 u(b){if(b===null)return"";if(V.isDate(b))return b.toISOString();if(V.isBoolean(b))return b.toString();if(!l&&V.isBlob(b))throw new je("Blob is not supported. Use a Buffer instead.");return V.isArrayBuffer(b)||V.isTypedArray(b)?l&&typeof Blob=="function"?new Blob([b]):Buffer.from(b):b}function d(b,g,x){let y=b;if(b&&!x&&typeof b=="object"){if(V.endsWith(g,"{}"))g=r?g:g.slice(0,-2),b=JSON.stringify(b);else if(V.isArray(b)&&$v(b)||(V.isFileList(b)||V.endsWith(g,"[]"))&&(y=V.toArray(b)))return g=jc(g),y.forEach(function(S,k){!(V.isUndefined(S)||S===null)&&t.append(i===!0?_c([g],k,s):i===null?g:g+"[]",u(S))}),!1}return Ii(b)?!0:(t.append(_c(x,g,s),u(b)),!1)}const f=[],m=Object.assign(Fv,{defaultVisitor:d,convertValue:u,isVisitable:Ii});function p(b,g){if(!V.isUndefined(b)){if(f.indexOf(b)!==-1)throw Error("Circular reference detected in "+g.join("."));f.push(b),V.forEach(b,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 Pc(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function Ni(e,t){this._pairs=[],e&&Uo(e,this,t)}const Rc=Ni.prototype;Rc.append=function(t,n){this._pairs.push([t,n])},Rc.toString=function(t){const n=t?function(r){return t.call(this,r,Pc)}:Pc;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function Bv(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Mc(e,t,n){if(!t)return e;const r=n&&n.encode||Bv;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 Ni(t,n).toString(r),s){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}class Oc{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 Dc={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},zv={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:Ni,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},Ai=typeof window<"u"&&typeof document<"u",ji=typeof navigator=="object"&&navigator||void 0,Hv=Ai&&(!ji||["ReactNative","NativeScript","NS"].indexOf(ji.product)<0),Uv=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Wv=Ai&&window.location.href||"http://localhost",_t={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Ai,hasStandardBrowserEnv:Hv,hasStandardBrowserWebWorkerEnv:Uv,navigator:ji,origin:Wv},Symbol.toStringTag,{value:"Module"})),...zv};function Vv(e,t){return Uo(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 Kv(e){return V.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function qv(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 Lc(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]=qv(o[i])),!a)}if(V.isFormData(e)&&V.isFunction(e.entries)){const n={};return V.forEachEntry(e,(r,o)=>{t(Kv(r),o,n,0)}),n}return null}function Gv(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 Xr={transitional:Dc,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(Lc(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 Vv(t,this.formSerializer).toString();if((a=V.isFileList(t))||r.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return Uo(a?{"files[]":t}:t,l&&new l,this.formSerializer)}}return s||o?(n.setContentType("application/json",!1),Gv(t)):t}],transformResponse:[function(t){const n=this.transitional||Xr.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"?je.from(a,je.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=>{Xr.headers[e]={}});const Yv=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"]),Xv=e=>{const t={};let n,r,o;return e&&e.split(`
|
|
31
|
+
`).forEach(function(i){o=i.indexOf(":"),n=i.substring(0,o).trim().toLowerCase(),r=i.substring(o+1).trim(),!(!n||t[n]&&Yv[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},$c=Symbol("internals");function Jr(e){return e&&String(e).trim().toLowerCase()}function Wo(e){return e===!1||e==null?e:V.isArray(e)?e.map(Wo):String(e)}function Jv(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 Zv=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function _i(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 Qv(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function eb(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 zt=class{constructor(t){t&&this.set(t)}set(t,n,r){const o=this;function s(a,l,u){const d=Jr(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||u===!0||u===void 0&&o[f]!==!1)&&(o[f||l]=Wo(a))}const i=(a,l)=>V.forEach(a,(u,d)=>s(u,d,l));if(V.isPlainObject(t)||t instanceof this.constructor)i(t,n);else if(V.isString(t)&&(t=t.trim())&&!Zv(t))i(Xv(t),n);else if(V.isObject(t)&&V.isIterable(t)){let a={},l,u;for(const d of t){if(!V.isArray(d))throw TypeError("Object iterator must return a key-value pair");a[u=d[0]]=(l=a[u])?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=Jr(t),t){const r=V.findKey(this,t);if(r){const o=this[r];if(!n)return o;if(n===!0)return Jv(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=Jr(t),t){const r=V.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||_i(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let o=!1;function s(i){if(i=Jr(i),i){const a=V.findKey(r,i);a&&(!n||_i(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||_i(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]=Wo(o),delete n[s];return}const a=t?Qv(s):String(s).trim();a!==s&&delete n[s],n[a]=Wo(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[$c]=this[$c]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=Jr(i);r[a]||(eb(o,i),r[a]=!0)}return V.isArray(t)?t.forEach(s):s(t),this}};zt.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),V.reduceDescriptors(zt.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),V.freezeMethods(zt);function Pi(e,t){const n=this||Xr,r=t||n,o=zt.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 Fc(e){return!!(e&&e.__CANCEL__)}function xr(e,t,n){je.call(this,e??"canceled",je.ERR_CANCELED,t,n),this.name="CanceledError"}V.inherits(xr,je,{__CANCEL__:!0});function Bc(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new je("Request failed with status code "+n.status,[je.ERR_BAD_REQUEST,je.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function tb(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function nb(e,t){e=e||10;const n=new Array(e),r=new Array(e);let o=0,s=0,i;return t=t!==void 0?t:1e3,function(l){const u=Date.now(),d=r[s];i||(i=u),n[o]=l,r[o]=u;let f=s,m=0;for(;f!==o;)m+=n[f++],f=f%e;if(o=(o+1)%e,o===s&&(s=(s+1)%e),u-i<t)return;const p=d&&u-d;return p?Math.round(m*1e3/p):void 0}}function rb(e,t){let n=0,r=1e3/t,o,s;const i=(u,d=Date.now())=>{n=d,o=null,s&&(clearTimeout(s),s=null),e(...u)};return[(...u)=>{const d=Date.now(),f=d-n;f>=r?i(u,d):(o=u,s||(s=setTimeout(()=>{s=null,i(o)},r-f)))},()=>o&&i(o)]}const Vo=(e,t,n=3)=>{let r=0;const o=nb(50,250);return rb(s=>{const i=s.loaded,a=s.lengthComputable?s.total:void 0,l=i-r,u=o(l),d=i<=a;r=i;const f={loaded:i,total:a,progress:a?i/a:void 0,bytes:l,rate:u||void 0,estimated:u&&a&&d?(a-i)/u:void 0,event:s,lengthComputable:a!=null,[t?"download":"upload"]:!0};e(f)},n)},zc=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},Hc=e=>(...t)=>V.asap(()=>e(...t)),ob=_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,sb=_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 ib(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function ab(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function Uc(e,t,n){let r=!ib(t);return e&&(r||n==!1)?ab(e,t):t}const Wc=e=>e instanceof zt?{...e}:e;function Qn(e,t){t=t||{};const n={};function r(u,d,f,m){return V.isPlainObject(u)&&V.isPlainObject(d)?V.merge.call({caseless:m},u,d):V.isPlainObject(d)?V.merge({},d):V.isArray(d)?d.slice():d}function o(u,d,f,m){if(V.isUndefined(d)){if(!V.isUndefined(u))return r(void 0,u,f,m)}else return r(u,d,f,m)}function s(u,d){if(!V.isUndefined(d))return r(void 0,d)}function i(u,d){if(V.isUndefined(d)){if(!V.isUndefined(u))return r(void 0,u)}else return r(void 0,d)}function a(u,d,f){if(f in t)return r(u,d);if(f in e)return r(void 0,u)}const l={url:s,method:s,data:s,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:a,headers:(u,d,f)=>o(Wc(u),Wc(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 Vc=e=>{const t=Qn({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=zt.from(i),t.url=Mc(Uc(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(),u=["content-type","content-length"];Object.entries(l).forEach(([d,f])=>{u.includes(d.toLowerCase())&&i.set(d,f)})}}if(_t.hasStandardBrowserEnv&&(r&&V.isFunction(r)&&(r=r(t)),r||r!==!1&&ob(t.url))){const l=o&&s&&sb.read(s);l&&i.set(o,l)}return t},lb=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=Vc(e);let s=o.data;const i=zt.from(o.headers).normalize();let{responseType:a,onUploadProgress:l,onDownloadProgress:u}=o,d,f,m,p,b;function g(){p&&p(),b&&b(),o.cancelToken&&o.cancelToken.unsubscribe(d),o.signal&&o.signal.removeEventListener("abort",d)}let x=new XMLHttpRequest;x.open(o.method.toUpperCase(),o.url,!0),x.timeout=o.timeout;function y(){if(!x)return;const S=zt.from("getAllResponseHeaders"in x&&x.getAllResponseHeaders()),C={data:!a||a==="text"||a==="json"?x.responseText:x.response,status:x.status,statusText:x.statusText,headers:S,config:e,request:x};Bc(function(E){n(E),g()},function(E){r(E),g()},C),x=null}"onloadend"in x?x.onloadend=y:x.onreadystatechange=function(){!x||x.readyState!==4||x.status===0&&!(x.responseURL&&x.responseURL.indexOf("file:")===0)||setTimeout(y)},x.onabort=function(){x&&(r(new je("Request aborted",je.ECONNABORTED,e,x)),x=null)},x.onerror=function(k){const C=k&&k.message?k.message:"Network Error",T=new je(C,je.ERR_NETWORK,e,x);T.event=k||null,r(T),x=null},x.ontimeout=function(){let k=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const C=o.transitional||Dc;o.timeoutErrorMessage&&(k=o.timeoutErrorMessage),r(new je(k,C.clarifyTimeoutError?je.ETIMEDOUT:je.ECONNABORTED,e,x)),x=null},s===void 0&&i.setContentType(null),"setRequestHeader"in x&&V.forEach(i.toJSON(),function(k,C){x.setRequestHeader(C,k)}),V.isUndefined(o.withCredentials)||(x.withCredentials=!!o.withCredentials),a&&a!=="json"&&(x.responseType=o.responseType),u&&([m,b]=Vo(u,!0),x.addEventListener("progress",m)),l&&x.upload&&([f,p]=Vo(l),x.upload.addEventListener("progress",f),x.upload.addEventListener("loadend",p)),(o.cancelToken||o.signal)&&(d=S=>{x&&(r(!S||S.type?new xr(null,e,x):S),x.abort(),x=null)},o.cancelToken&&o.cancelToken.subscribe(d),o.signal&&(o.signal.aborted?d():o.signal.addEventListener("abort",d)));const w=tb(o.url);if(w&&_t.protocols.indexOf(w)===-1){r(new je("Unsupported protocol "+w+":",je.ERR_BAD_REQUEST,e));return}x.send(s||null)})},cb=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let r=new AbortController,o;const s=function(u){if(!o){o=!0,a();const d=u instanceof Error?u:this.reason;r.abort(d instanceof je?d:new xr(d instanceof Error?d.message:d))}};let i=t&&setTimeout(()=>{i=null,s(new je(`timeout ${t} of ms exceeded`,je.ETIMEDOUT))},t);const a=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(u=>{u.unsubscribe?u.unsubscribe(s):u.removeEventListener("abort",s)}),e=null)};e.forEach(u=>u.addEventListener("abort",s));const{signal:l}=r;return l.unsubscribe=()=>V.asap(a),l}},ub=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},db=async function*(e,t){for await(const n of fb(e))yield*ub(n,t)},fb=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()}},Kc=(e,t,n,r)=>{const o=db(e,t);let s=0,i,a=l=>{i||(i=!0,r&&r(l))};return new ReadableStream({async pull(l){try{const{done:u,value:d}=await o.next();if(u){a(),l.close();return}let f=d.byteLength;if(n){let m=s+=f;n(m)}l.enqueue(new Uint8Array(d))}catch(u){throw a(u),u}},cancel(l){return a(l),o.return()}},{highWaterMark:2})},qc=64*1024,{isFunction:Ko}=V,pb=(({Request:e,Response:t})=>({Request:e,Response:t}))(V.global),{ReadableStream:Gc,TextEncoder:Yc}=V.global,Xc=(e,...t)=>{try{return!!e(...t)}catch{return!1}},hb=e=>{e=V.merge.call({skipUndefined:!0},pb,e);const{fetch:t,Request:n,Response:r}=e,o=t?Ko(t):typeof fetch=="function",s=Ko(n),i=Ko(r);if(!o)return!1;const a=o&&Ko(Gc),l=o&&(typeof Yc=="function"?(b=>g=>b.encode(g))(new Yc):async b=>new Uint8Array(await new n(b).arrayBuffer())),u=s&&a&&Xc(()=>{let b=!1;const g=new n(_t.origin,{body:new Gc,method:"POST",get duplex(){return b=!0,"half"}}).headers.has("Content-Type");return b&&!g}),d=i&&a&&Xc(()=>V.isReadableStream(new r("").body)),f={stream:d&&(b=>b.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(b=>{!f[b]&&(f[b]=(g,x)=>{let y=g&&g[b];if(y)return y.call(g);throw new je(`Response type '${b}' is not supported`,je.ERR_NOT_SUPPORT,x)})});const m=async b=>{if(b==null)return 0;if(V.isBlob(b))return b.size;if(V.isSpecCompliantForm(b))return(await new n(_t.origin,{method:"POST",body:b}).arrayBuffer()).byteLength;if(V.isArrayBufferView(b)||V.isArrayBuffer(b))return b.byteLength;if(V.isURLSearchParams(b)&&(b=b+""),V.isString(b))return(await l(b)).byteLength},p=async(b,g)=>{const x=V.toFiniteNumber(b.getContentLength());return x??m(g)};return async b=>{let{url:g,method:x,data:y,signal:w,cancelToken:S,timeout:k,onDownloadProgress:C,onUploadProgress:T,responseType:E,headers:j,withCredentials:_="same-origin",fetchOptions:D}=Vc(b),F=t||fetch;E=E?(E+"").toLowerCase():"text";let W=cb([w,S&&S.toAbortSignal()],k),G=null;const A=W&&W.unsubscribe&&(()=>{W.unsubscribe()});let X;try{if(T&&u&&x!=="get"&&x!=="head"&&(X=await p(j,y))!==0){let Y=new n(g,{method:"POST",body:y,duplex:"half"}),P;if(V.isFormData(y)&&(P=Y.headers.get("content-type"))&&j.setContentType(P),Y.body){const[O,M]=zc(X,Vo(Hc(T)));y=Kc(Y.body,qc,O,M)}}V.isString(_)||(_=_?"include":"omit");const q=s&&"credentials"in n.prototype,B={...D,signal:W,method:x.toUpperCase(),headers:j.normalize().toJSON(),body:y,duplex:"half",credentials:q?_:void 0};G=s&&new n(g,B);let R=await(s?F(G,D):F(g,B));const I=d&&(E==="stream"||E==="response");if(d&&(C||I&&A)){const Y={};["status","statusText","headers"].forEach(L=>{Y[L]=R[L]});const P=V.toFiniteNumber(R.headers.get("content-length")),[O,M]=C&&zc(P,Vo(Hc(C),!0))||[];R=new r(Kc(R.body,qc,O,()=>{M&&M(),A&&A()}),Y)}E=E||"text";let H=await f[V.findKey(f,E)||"text"](R,b);return!I&&A&&A(),await new Promise((Y,P)=>{Bc(Y,P,{data:H,headers:zt.from(R.headers),status:R.status,statusText:R.statusText,config:b,request:G})})}catch(q){throw A&&A(),q&&q.name==="TypeError"&&/Load failed|fetch/i.test(q.message)?Object.assign(new je("Network Error",je.ERR_NETWORK,b,G),{cause:q.cause||q}):je.from(q,q&&q.code,b,G)}}},mb=new Map,Jc=e=>{let t=e?e.env:{};const{fetch:n,Request:r,Response:o}=t,s=[r,o,n];let i=s.length,a=i,l,u,d=mb;for(;a--;)l=s[a],u=d.get(l),u===void 0&&d.set(l,u=a?new Map:hb(t)),d=u;return u};Jc();const Ri={http:Lv,xhr:lb,fetch:{get:Jc}};V.forEach(Ri,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Zc=e=>`- ${e}`,gb=e=>V.isFunction(e)||e===null||e===!1,Qc={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,!gb(r)&&(o=Ri[(a=String(r)).toLowerCase()],o===void 0))throw new je(`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,u])=>`adapter ${l} `+(u===!1?"is not supported by the environment":"is not available in the build"));let a=n?i.length>1?`since :
|
|
33
|
+
`+i.map(Zc).join(`
|
|
34
|
+
`):" "+Zc(i[0]):"as no adapter specified";throw new je("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return o},adapters:Ri};function Mi(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new xr(null,e)}function eu(e){return Mi(e),e.headers=zt.from(e.headers),e.data=Pi.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),Qc.getAdapter(e.adapter||Xr.adapter,e)(e).then(function(r){return Mi(e),r.data=Pi.call(e,e.transformResponse,r),r.headers=zt.from(r.headers),r},function(r){return Fc(r)||(Mi(e),r&&r.response&&(r.response.data=Pi.call(e,e.transformResponse,r.response),r.response.headers=zt.from(r.response.headers))),Promise.reject(r)})}const tu="1.12.2",qo={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{qo[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const nu={};qo.transitional=function(t,n,r){function o(s,i){return"[Axios v"+tu+"] Transitional option '"+s+"'"+i+(r?". "+r:"")}return(s,i,a)=>{if(t===!1)throw new je(o(i," has been removed"+(n?" in "+n:"")),je.ERR_DEPRECATED);return n&&!nu[i]&&(nu[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}},qo.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function xb(e,t,n){if(typeof e!="object")throw new je("options must be an object",je.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 je("option "+s+" must be "+l,je.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new je("Unknown option "+s,je.ERR_BAD_OPTION)}}const Go={assertOptions:xb,validators:qo},vn=Go.validators;let er=class{constructor(t){this.defaults=t||{},this.interceptors={request:new Oc,response:new Oc}}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=Qn(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:s}=n;r!==void 0&&Go.assertOptions(r,{silentJSONParsing:vn.transitional(vn.boolean),forcedJSONParsing:vn.transitional(vn.boolean),clarifyTimeoutError:vn.transitional(vn.boolean)},!1),o!=null&&(V.isFunction(o)?n.paramsSerializer={serialize:o}:Go.assertOptions(o,{encode:vn.function,serialize:vn.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Go.assertOptions(n,{baseUrl:vn.spelling("baseURL"),withXsrfToken:vn.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"],b=>{delete s[b]}),n.headers=zt.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 u=[];this.interceptors.response.forEach(function(g){u.push(g.fulfilled,g.rejected)});let d,f=0,m;if(!l){const b=[eu.bind(this),void 0];for(b.unshift(...a),b.push(...u),m=b.length,d=Promise.resolve(n);f<m;)d=d.then(b[f++],b[f++]);return d}m=a.length;let p=n;for(;f<m;){const b=a[f++],g=a[f++];try{p=b(p)}catch(x){g.call(this,x);break}}try{d=eu.call(this,p)}catch(b){return Promise.reject(b)}for(f=0,m=u.length;f<m;)d=d.then(u[f++],u[f++]);return d}getUri(t){t=Qn(this.defaults,t);const n=Uc(t.baseURL,t.url,t.allowAbsoluteUrls);return Mc(n,t.params,t.paramsSerializer)}};V.forEach(["delete","get","head","options"],function(t){er.prototype[t]=function(n,r){return this.request(Qn(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(Qn(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}er.prototype[t]=n(),er.prototype[t+"Form"]=n(!0)});let vb=class Lx{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 xr(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 Lx(function(o){t=o}),cancel:t}}};function bb(e){return function(n){return e.apply(null,n)}}function wb(e){return V.isObject(e)&&e.isAxiosError===!0}const Oi={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(Oi).forEach(([e,t])=>{Oi[t]=e});function ru(e){const t=new er(e),n=bc(er.prototype.request,t);return V.extend(n,er.prototype,t,{allOwnKeys:!0}),V.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return ru(Qn(e,o))},n}const dt=ru(Xr);dt.Axios=er,dt.CanceledError=xr,dt.CancelToken=vb,dt.isCancel=Fc,dt.VERSION=tu,dt.toFormData=Uo,dt.AxiosError=je,dt.Cancel=dt.CanceledError,dt.all=function(t){return Promise.all(t)},dt.spread=bb,dt.isAxiosError=wb,dt.mergeConfig=Qn,dt.AxiosHeaders=zt,dt.formToJSON=e=>Lc(V.isHTMLForm(e)?new FormData(e):e),dt.getAdapter=Qc.getAdapter,dt.HttpStatusCode=Oi,dt.default=dt;const{Axios:v1,AxiosError:b1,CanceledError:w1,isCancel:y1,CancelToken:S1,VERSION:C1,all:T1,Cancel:k1,isAxiosError:E1,spread:I1,toFormData:N1,AxiosHeaders:A1,HttpStatusCode:j1,formToJSON:_1,getAdapter:P1,mergeConfig:R1}=dt,ou=typeof window<"u"?window.__API_BASE_URL__:void 0,su=ou?bn(ou):void 0;function bn(e){const n=(e!=null&&e.trim()?e.trim():"/api/chat").replace(/\/+$/,"");return n?n.endsWith("/chat")?n:`${n}/chat`:"/api/chat"}let Yo=null;const Di=new Set;function iu(){return Yo}function Xo(e){Yo=e,Di.forEach(t=>t(e))}function au(e){return Di.add(e),()=>Di.delete(e)}const lu=3e4,cu=9e4,Gt=dt.create({...su?{baseURL:su}:{},timeout:lu,withCredentials:!0});Gt.interceptors.request.use(e=>(Yo&&(e.headers.Authorization=`Bearer ${Yo}`),e)),Gt.interceptors.response.use(e=>{if(typeof window<"u"&&(e!=null&&e.data))try{const t=e.data,n=t.data||{},r=typeof t.token=="string"&&t.token||typeof n.token=="string"&&n.token||null,o=typeof t.expires_at=="number"&&t.expires_at||typeof n.expires_at=="number"&&n.expires_at||typeof t.expiresAt=="number"&&t.expiresAt||typeof n.expiresAt=="number"&&n.expiresAt||null;r&&(localStorage.setItem("authToken",r),Xo(r)),o&&localStorage.setItem("authTokenExpiresAt",o.toString()),(r||o)&&window.dispatchEvent(new CustomEvent("smartorg:chat-token-updated",{detail:{token:r,expiresAt:o}}))}catch(t){console.warn("[chat-api] Error storing token:",t)}return e},e=>Promise.reject(e));async function Yt(e,t){return Gt.defaults.baseURL?(await Gt.get(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}async function Jo(e,t,n){return Gt.defaults.baseURL?(await Gt.post(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function uu(e,t,n){return Gt.defaults.baseURL?(await Gt.put(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function Li(e,t){return Gt.defaults.baseURL?(await Gt.delete(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}function Ot(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class Zo{get baseUrl(){const t=Gt.defaults.baseURL;return t?bn(String(t)):""}updateConfig(t){t.baseUrl&&(Gt.defaults.baseURL=bn(String(t.baseUrl))),t.authToken!==void 0&&Xo(t.authToken)}getAuthToken(){return iu()}setAuthToken(t){Xo(t)}onTokenChange(t){return au(t)}async listThreads(){const t=await Yt("/threads"),n=Ot(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async listSharedThreads(){const t=await Yt("/threads/shared"),n=Ot(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async createThread(t){const r=await Jo("/threads",t?{title:t}:void 0);return Ot(r)}async updateThread(t,n){const r=await uu(`/threads/${t}`,{title:n});return Ot(r)}async deleteThread(t){const n=await Li(`/threads/${t}`);return Ot(n)}async shareThread(t,n){const r=await Jo(`/threads/${t}/share`,{shared_with_user_id:n});return Ot(r)}async threadInfo(t){const n=await Yt(`/threads/${t}/info`);return Ot(n)}async listAgents(){const t=await Yt("/agents"),n=Ot(t);return(n==null?void 0:n.items)??[]}async getAgent(t){const n=await Yt(`/agents/${t}`);return Ot(n)}async getAgentSchema(t){const n=await Yt(`/agents/${t}/schema`);return Ot(n)}async getState(t){const n=await Yt(`/threads/${t.threadId}/state`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return Ot(n)}async getStateHistory(t){const n=await Yt(`/threads/${t.threadId}/state/history`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs},timeout:cu});return Ot(n)}async cancelRun(t){const n=await Jo("/runs/cancel",{threadId:t});return Ot(n)}async unshareThread(t,n){const r=await Li(`/threads/${t}/share/${n}`);return Ot(r)}}const jn=new Zo,yb=Zo,Sb=Zo;async function $i(e,t){return await Yt(e,{responseType:"blob",onDownloadProgress:r=>{try{if(t&&r.lengthComputable){const o=r.loaded/r.total;t(o)}}catch{}},maxBodyLength:1/0})}async function Cb(e,t){const n=await $i(`/files/${e}/view`,t),r=URL.createObjectURL(n);window.open(r,"_blank"),setTimeout(()=>URL.revokeObjectURL(r),6e4)}async function Fi(e,t){return await(await $i(`/files/${e}/view`,t)).text()}async function du(e,t){const n=await $i(`/files/${e}/download`,t),r=URL.createObjectURL(n);let o=`file_${e}`;try{const i=await Yt(`/files/${e}`);o=(i==null?void 0:i.filename)??o}catch{}const s=document.createElement("a");s.href=r,s.download=o,document.body.appendChild(s),s.click(),s.remove(),setTimeout(()=>URL.revokeObjectURL(r),6e4)}async function Tb(e){return await Yt(`/files/${e}`)}async function fu(e,t=50,n=0){const r={limit:t,offset:n};return e&&(r.thread_id=e),await Yt("/files",{params:r})}const pu=v.createContext(null);function hu({children:e,apiConfig:t}){const n=jn;if(t){const o=n.baseUrl,s=n.getAuthToken();t.baseUrl&&t.baseUrl!==o&&n.updateConfig({baseUrl:t.baseUrl}),t.apiKey!==void 0&&t.apiKey!==s&&n.updateConfig({authToken:t.apiKey})}const r={token:n.getAuthToken(),setToken:o=>n.setAuthToken(o),api:n,baseUrl:n.baseUrl};return c.jsx(pu.Provider,{value:r,children:e})}async function mu(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 gu(e=[]){const t=[],n=[];for(const r of e)try{const o=await mu(r);n.push({filename:r.name,data:o,mime_type:r.type||"application/octet-stream"})}catch{}return{contentParts:t,filesInfo:n}}function Zr(){const e=v.useContext(pu);if(!e)throw new Error("useApi must be used within ApiProvider");return e}function xu(e){return!!e&&typeof e=="object"&&"data"in e}function Bi(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 Qr(e,t,n){return t<0||t>=e.length?e:[...e.slice(0,t),n,...e.slice(t+1)]}function kb(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 vu(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="assistant")return e[t].id;return null}function bu(e){return!e||!e.length?"":e.filter(t=>t.type==="text").map(t=>t.text??"").join("")}function wu(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??bu(e);let l="",u=e.slice();if(s){const f=Eb(a,s);if(f===""?l="":f===s?l=s:l=f,l){const m=u[u.length-1];if((m==null?void 0:m.type)==="text"){const p=m.text??"",b={...m,text:p+l};u=[...u.slice(0,u.length-1),b]}else u=[...u,{type:"text",text:l}];o.lastText=a+l}else o.lastText=a}i.length&&(u=[...u,...i]);const d=!!(l||i.length);return{newParts:u,newMeta:o,changed:d}}function yu(e){return e.replace(/\s+/g," ").trim()}function Eb(e,t){if(!t)return"";if(!e)return t;if(e===t)return"";const n=Math.min(e.length,t.length);for(let i=n;i>0;i--)if(e.slice(-i)===t.slice(0,i))return t.slice(i);const r=yu(e),o=yu(t);if(r===o)return"";const s=Math.min(r.length,o.length);for(let i=s;i>0;i--)if(r.slice(-i)===o.slice(0,i))return t;return t}function 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 Qr(e,r,s)}return e}function Su(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}function Nb(e={}){const t=v.useMemo(()=>bn(e.baseUrl),[e.baseUrl]),n=e.streamPath??"/runs/stream",[r,o]=v.useState(e.token??null),s=v.useRef(e.headers??{}),i=e.credentials??"include",[a,l]=v.useState(!1),[u,d]=v.useState(null),[f,m]=v.useState(""),[p,b]=v.useState(null),[g,x]=v.useState(0),[y,w]=v.useState(!1),[S,k]=v.useState(null),C=v.useRef(null),T=v.useRef(!0),E=v.useRef(0),j=v.useRef(null),_=v.useRef(null),D=v.useRef(null),F=v.useRef(null),W=v.useRef({messageId:null,lastSeq:null,lastText:""}),G=v.useCallback(B=>{o(B)},[]),A=v.useCallback(()=>{m(""),b(null),d(null),_.current=null,D.current=null,F.current=null,k(null),W.current={messageId:null,lastSeq:null,lastText:""}},[]),X=v.useCallback(()=>{var H;console.debug("[use-chat] stop() invoked - aborting stream");const B=(H=j.current)==null?void 0:H.threadId,R=()=>{var Y;(Y=C.current)==null||Y.abort(),C.current=null,j.current=null,l(!1),w(!1),E.current=0,x(0)};(B?jn.cancelRun(B).catch(Y=>{console.warn("[use-chat] cancel run failed:",Y)}):Promise.resolve()).finally(R)},[]),q=v.useCallback((B,R,I)=>{C.current&&(C.current.abort(),C.current=null),l(!0),d(null),e.autoAppendAssistant!==!1&&m(""),b(null),_.current=null,D.current=null,F.current=null,k(null),W.current={messageId:null,lastSeq:null,lastText:""};const H=new AbortController;C.current=H;let Y=null,P=null,O=!1;return j.current={threadId:B.threadId??null,headers:{}},(async()=>{var L,te,z,$,ee,J,K,Q,me,de,ge,we,Te,Ne,ke,st,vt,ht;const M=We=>{var Le;try{const Ge=JSON.parse(JSON.stringify(We));return(Le=Ge==null?void 0:Ge.payload)!=null&&Le.files_info&&Array.isArray(Ge.payload.files_info)&&(Ge.payload.files_info=Ge.payload.files_info.map(Me=>({...Me,data:Me!=null&&Me.data?`<base64 ${String(Me.data).length} chars>`:Me==null?void 0:Me.data}))),Ge}catch{return We}};try{let We={};try{if(r)We={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const Ve=window.__AUTH_TOKEN__,jt=((L=window.localStorage)==null?void 0:L.getItem("authToken"))||null;let Z=null;try{const He=(te=window.localStorage)==null?void 0:te.getItem("chat-settings");He&&(Z=((z=JSON.parse(He))==null?void 0:z.apiKey)||null)}catch{}const ce=Ve||jt||Z||null;ce&&(We={Authorization:`Bearer ${ce}`})}}catch{}console.debug("[use-chat] POST",t+n,M(B));let Le={};if(typeof window<"u")try{const Fe=($=window.localStorage)==null?void 0:$.getItem("authSessionId");Fe&&(Le={"X-Session-Id":Fe})}catch{}const Ge={...We,...Le,...s.current},Me={"Content-Type":"application/json",Accept:"text/event-stream",...Ge},$e=await fetch(t+n,{method:"POST",headers:Me,body:JSON.stringify(B),signal:H.signal,credentials:i});if(j.current&&(j.current.headers=Ge),!$e.ok||!$e.body){const Fe=await $e.text().catch(()=>"");console.debug("[use-chat] non-OK response",$e.status,Fe==null?void 0:Fe.slice(0,500));const Ve=`stream ${$e.status}${Fe?": "+Fe:""}`;throw(ee=I==null?void 0:I.onConnectionError)==null||ee.call(I,Ve),O=!0,Y="error",P=Ve,new Error(Ve)}w(!0);const Ze=$e.body.getReader(),Nt=new TextDecoder;let it="",St=[];E.current=0,x(0);let Ct=0,Tt=null;const Et=()=>{if(St.length){const Fe=St.join("");St=[],T.current&&m(Ve=>Ve+Fe)}Tt=null},sn=()=>{typeof window<"u"&&Tt==null&&(Tt=requestAnimationFrame(Et))};let At=Date.now();const Vt=setInterval(()=>{var Fe;if(Date.now()-At>18e5){const Ve="Stream idle timeout";d(Ve),Y="error",P=Ve,H.abort(),(Fe=I==null?void 0:I.onError)==null||Fe.call(I,Ve)}},5e3),It=1024*1024;try{const Fe=$e.headers.get("X-Thread-Id")||$e.headers.get("x-thread-id"),Ve=$e.headers.get("X-Thread-Created")||$e.headers.get("x-thread-created"),jt=Fe??null,Z=String(Ve??"").toLowerCase()==="true";for(j.current&&!j.current.threadId&&(j.current={...j.current,threadId:jt}),(J=I==null?void 0:I.onOpen)==null||J.call(I,{threadId:jt,created:Z});;){const{value:ce,done:He}=await Ze.read();if(He)break;it+=Nt.decode(ce,{stream:!0}),it.length>It&&(it="",console.warn("Stream buffer reset: exceeded 1MB"));let ve;for(;(ve=it.indexOf(`
|
|
36
36
|
|
|
37
|
-
`))>=0;){const
|
|
38
|
-
`);if(!Ke)continue;let lt;try{lt=JSON.parse(Ke)}catch{console.debug("[use-chat] malformed SSE:",Ke.slice(0,200));continue}const ct=su(lt)?lt.data:lt;if(!ct){console.warn("[use-chat] dropped envelope event without payload",lt);continue}const _e=ct;Nt=Date.now();const mt=_e.seq;if(mt!==void 0){if(mt<=St){console.debug("[use-chat] drop duplicate/out-of-order event",{seq:mt,lastProcessedSeq:St,type:_e.type});continue}St>0&&mt>St+1&&((K=I==null?void 0:I.onGap)==null||K.call(I,{from:St,to:mt})),St=mt,E.current=mt,x(mt)}if(_e.type==="message.start"&&_e.role==="assistant"){const Qe=uu(_e.model);W.current={messageId:_e.id,lastSeq:mt??null,lastText:""},k({id:_e.id,role:"assistant",name:Qe??void 0,model:_e.model,createdAt:new Date().toISOString(),content:[]})}if(_e.type==="checkpoint")P.current=_e.checkpointId??null,D.current=_e.checkpointNs??null,v(_e.checkpointId??null);else if(_e.type==="state_history"){F.current=_e;try{const ut=Mn(_e).latest;ut&&(P.current=ut.checkpointId??null,D.current=ut.checkpointNs??null,v(ut.checkpointId??null))}catch(Qe){console.warn("[use-chat] Failed to hydrate state_history payload",Qe)}}try{R==null||R(_e)}catch(Qe){console.error("[use-chat] Error in onEvent callback:",Qe,"for event:",_e.type)}if(_e.type==="message.delta"){k(ut=>{const In=W.current;if(!ut||In.messageId!==ut.id)return ut;const{newParts:N,newMeta:re,changed:le}=lu(ut.content??[],_e.delta,{lastSeq:In.lastSeq,lastText:In.lastText},mt??null);return le?(W.current={...In,lastSeq:re.lastSeq??In.lastSeq,lastText:re.lastText??In.lastText},{...ut,content:N}):ut});const Qe=_e.delta.filter(ut=>ut.type==="text").map(ut=>ut.text).join("");Qe&&e.autoAppendAssistant!==!1&&(yt.push(Qe),on())}else if(_e.type==="heartbeat"){console.debug("[use-chat] heartbeat received");try{(Q=I==null?void 0:I.onHeartbeat)==null||Q.call(I,_e)}catch(Qe){console.warn("[use-chat] heartbeat callback failed",Qe)}}else if(Ct!==null&&cancelAnimationFrame(Ct),kt(),_e.type==="checkpoint")v(_e.checkpointId);else if(_e.type==="error"){const Qe=_e;if(d(Qe.message),Y="error",_=Qe.message,Qe.error_type==="auth_error"||Qe.code==="TOKEN_EXPIRED"||((pe=Qe.message)==null?void 0:pe.includes("token"))||((de=Qe.message)==null?void 0:de.includes("401"))||((me=Qe.message)==null?void 0:me.includes("unauthorized"))||((we=Qe.message)==null?void 0:we.includes("Unauthorized"))){console.error("[use-chat] Auth error detected:",Qe.message);try{(Te=I==null?void 0:I.onAuthError)==null||Te.call(I,Qe.message)}catch(In){console.warn("[use-chat] onAuthError handler failed",In)}H.abort()}}}}kt(),Y===null&&!H.signal.aborted&&(Y="complete")}catch(Fe){if(Fe.name==="AbortError")Y=Y??"aborted";else{const Ve=Fe.message||String(Fe);Y="error",_=Ve,d(Ve),(Ne=I==null?void 0:I.onError)==null||Ne.call(I,Ve)}}finally{try{await Ze.cancel()}catch{}finally{(ke=Ze.releaseLock)==null||ke.call(Ze)}Ct!==null&&typeof window<"u"&&window.cancelAnimationFrame(Ct),clearInterval(Vt)}}catch(We){if(We.name==="AbortError")Y=Y??"aborted";else{const Le=We.message||String(We);Y="error",_=Le,d(Le),(st=I==null?void 0:I.onError)==null||st.call(I,Le),O||((vt=I==null?void 0:I.onConnectionError)==null||vt.call(I,Le),O=!0)}}finally{const We=E.current,Le=P.current,Ge=D.current,Re=F.current,$e=Y??(H.signal.aborted?"aborted":_?"error":"complete");try{(pt=I==null?void 0:I.onClosed)==null||pt.call(I,{reason:$e,lastSeq:We,lastCheckpointId:Le,lastCheckpointNs:Ge,lastStateHistory:Re,error:_})}catch(Ze){console.warn("[use-chat] onClosed callback failed",Ze)}l(!1),w(!1),C.current=null,E.current=0,x(0),j.current=null}})(),{close:()=>H.abort()}},[t,n,r,e.autoAppendAssistant]);return b.useEffect(()=>()=>{var B;T.current=!1,(B=C.current)==null||B.abort()},[]),{isStreaming:a,error:c,assistantText:h,assistantMessage:S,lastCheckpointId:f,lastSeq:g,connected:y,stream:q,stop:X,clear:A,setToken:G}}const Yv=["detail","message","error","description","title"];function Go(e){if(!e)return null;if(typeof e=="string"){const t=e.trim();return t.length?t:null}if(Array.isArray(e)){for(const t of e){const n=Go(t);if(n)return n}return null}if(typeof e=="object"){const t=e;for(const n of Yv){const r=Go(t[n]);if(r)return r}if("errors"in t){const n=Go(t.errors);if(n)return n}}return null}function Xv(e){if(!e)return"Request failed";const t=e.response,n=Go(t==null?void 0:t.data);if(n)return n;if(t!=null&&t.statusText)return t.statusText;if(e instanceof Error&&e.message)return e.message;if(typeof e=="string"){const r=e.trim();if(r.length)return r}return t!=null&&t.status?`Request failed with status code ${t.status}`:"Request failed"}function du({api:e,initialThreadId:t=null,onError:n,onThreadChange:r,onCurrentThreadDeleted:o}){const[s,i]=b.useState([]),[a,l]=b.useState(t),[c,d]=b.useState(!1),[h,m]=b.useState(null),[f,v]=b.useState([]),[g,x]=b.useState(!1),[,y]=b.useState(null),[w,S]=b.useState(null),[k,C]=b.useState(!1),T=b.useRef(a),E=b.useRef(new Map);b.useEffect(()=>{T.current=a},[a]);const j=b.useCallback(async()=>{d(!0),m(null);try{const R=await e.listThreads();i(R??[])}catch(R){const I=String(R);m(I),n==null||n(I)}finally{d(!1)}},[e,n]),P=b.useCallback(async()=>{x(!0),y(null);try{const R=await e.listSharedThreads();v(R??[])}catch(R){const I=String(R);y(I),n==null||n(I)}finally{x(!1)}},[e,n]);b.useEffect(()=>{j()},[j]),b.useEffect(()=>{P()},[P]),b.useEffect(()=>{r==null||r(a)},[a,r]);const D=b.useCallback(async R=>{try{const I=await e.createThread(R);return l(I.threadId),await j(),I.threadId}catch(I){const H=String(I);return n==null||n(H),null}},[e,n,j]),F=b.useCallback(async R=>{const I=s;i(Y=>Y.filter(_=>_.threadId!==R));const H=new AbortController;E.current.set(R,H);try{await e.deleteThread(R),T.current===R&&(l(null),o==null||o())}catch(Y){i(I);const _=String(Y);n==null||n(_)}finally{E.current.delete(R)}},[e,o,n,s]),W=b.useCallback(async(R,I)=>{try{await e.updateThread(R,I),await j()}catch(H){n==null||n(String(H))}},[e,n,j]),G=b.useCallback(async(R,I)=>{C(!0),S("Sharing thread…");try{await e.shareThread(R,I),await P(),S("Shared successfully")}catch(H){const Y=Xv(H);throw n==null||n(Y),S(`Failed to share: ${Y}`),new Error(Y)}finally{C(!1)}},[e,n,P]),A=b.useCallback(async(R,I)=>{try{await e.unshareThread(R,I),await P()}catch(H){const Y=String(H);throw n==null||n(Y),H}},[e,n,P]),X=b.useMemo(()=>({createThread:D,deleteThread:F,renameThread:W,refreshThreads:j,refreshSharedThreads:P,shareThread:G,unshareThread:A}),[D,F,W,j,P,G,A]),q=b.useCallback(R=>{if(!(R!=null&&R.threadId))return;const I={threadId:R.threadId,title:R.title||`Thread ${R.threadId.slice(0,8)}`,createdAt:R.createdAt||new Date().toISOString(),updatedAt:R.updatedAt||new Date().toISOString(),messageCount:R.messageCount??1};i(H=>{let Y=!1;const _=H.map(O=>O.threadId===I.threadId?(Y=!0,console.debug("[useThreadsState] thread_info: updating existing thread",I.threadId),{...O,title:I.title??O.title,updatedAt:I.updatedAt??O.updatedAt,messageCount:I.messageCount??O.messageCount}):O);return Y?_:(console.debug("[useThreadsState] thread_info: adding thread to list",I.threadId),[I,...H])})},[]),B=b.useCallback(()=>S(null),[]);return{threads:s,currentThreadId:a,currentThreadIdRef:T,setCurrentThreadId:l,isLoadingThreads:c,threadsError:h,sharedThreads:f,isLoadingSharedThreads:g,actions:X,addThreadFromEvent:q,shareInFlight:k,shareStatus:w,clearShareStatus:B}}const fu=b.createContext(null);function hu({children:e,initialThreadId:t=null,onError:n,onThreadChange:r}){const{api:o}=Xr(),{threads:s,currentThreadId:i,setCurrentThreadId:a,currentThreadIdRef:l,isLoadingThreads:c,threadsError:d,sharedThreads:h,isLoadingSharedThreads:m,actions:f,addThreadFromEvent:v,shareInFlight:g,shareStatus:x,clearShareStatus:y}=du({api:o,initialThreadId:t,onError:n,onThreadChange:r}),w=b.useMemo(()=>({threads:s,currentThreadId:i,setCurrentThreadId:a,currentThreadIdRef:l,isLoading:c,error:d,sharedThreads:h,isLoadingSharedThreads:m,actions:f,shareInFlight:g,shareStatus:x,clearShareStatus:y,addThreadFromEvent:v}),[s,i,a,l,c,d,h,m,f,g,x,y,v]);return u.jsx(fu.Provider,{value:w,children:e})}function xr(){const e=b.useContext(fu);if(!e)throw new Error("useThreads must be used within a ThreadsProvider");return e}function Mi(e){const t=e==null?void 0:e.trim();if(!t||!(t.startsWith("{")||t.startsWith("[")))return null;try{return JSON.parse(t)}catch{return null}}function pu(e){return!!(e&&typeof e=="object"&&(e.type==="file"||e.mimeType||e.filename||e.sourceType==="base64"))}function Zr(e){if(typeof e=="string")return e;if(e&&typeof e=="object"){if(Array.isArray(e)){const n=e.map(Zr).filter(r=>r!==void 0);if(!n.length){console.debug("[message-utils] sanitizeForDisplay - array emptied -> returning undefined",{originalLength:e.length});return}return n}if(pu(e)){try{console.debug("[message-utils] sanitizeForDisplay - dropping file-like object",{sampleFilename:e&&(e.filename||e.name)?e.filename||e.name:void 0,keys:Object.keys(e||{})})}catch(n){console.debug("[message-utils] sanitizeForDisplay - dropped file-like (unable to inspect)",{err:String(n)})}return}const t={};for(const n of Object.keys(e)){const r=e[n];if(n==="data"&&typeof r=="string"&&r.length>100)t[n]=`[base64 ${r.length} chars omitted]`;else{const o=Zr(r);o!==void 0&&(t[n]=o)}}if(Object.keys(t).length)return t;try{console.debug("[message-utils] sanitizeForDisplay - object emptied -> returning undefined",{originalKeys:Object.keys(e||{})})}catch(n){console.debug("[message-utils] sanitizeForDisplay - object emptied -> returning undefined (inspect failed)",{err:String(n)})}return}return e}function vr(e){if(typeof e=="string")return e;if(pu(e))return"";try{const t=Zr(e);return t===void 0?"":typeof t=="string"?t:JSON.stringify(t,null,2)}catch{return""}}function Jv(e){return typeof e!="string"?!1:/^[\s\n]*[-*]\s|^[\s\n]*#+\s|```|^\s*\[.*\]\(|^>\s/.test(e)}function Zv(e){const t=vr(e);return typeof e=="string"&&Jv(e)?{content:e,isMarkdown:!0}:{content:t,isMarkdown:!1}}function Qr(e){if(e==null)return e;if(typeof e=="string"){const t=e.trim();if(t.startsWith("{")||t.startsWith("[")){const n=Mi(t);if(n!==null)return Qr(n)}return e}return typeof e=="object"&&!Array.isArray(e)&&e.content!==void 0?Qr(e.content):e}function Qv(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function Oi(e){const t=e.content.find(s=>s.type==="tool_call"),n=e.additionalKwargs??{},r=typeof(t==null?void 0:t.id)=="string"&&t.id||typeof n.toolCallId=="string"&&n.toolCallId||(e.id.startsWith("tool-")?e.id.slice(5):void 0);return{name:(typeof(t==null?void 0:t.name)=="string"&&t.name||typeof n.toolName=="string"&&n.toolName||e.name&&String(e.name))??void 0,toolCallId:r??void 0}}function Yo(e){if(e==null)return null;const t=String(e).trim();return t.length>0?t:null}function eb(e){const t=r=>{try{const o=Zr(r);return typeof o=="string"?o:JSON.stringify(o??"")}catch{return""}},n=e.filter(r=>r.type==="text");return n.length?t(n.map(r=>r.text).join(`
|
|
39
|
-
`)):t(e)}function tb(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function mu(e){if(e.role==="default_message")return`default:${e.content.length}`;const t=e.updatedAt??e.createdAt??"",n=Array.isArray(e.content)?e.content.map(i=>{switch(i.type){case"text":return`t:${i.text.length}`;case"image_url":return"img";case"file":return"file";case"tool_call":return"call";case"interrupt":return"interrupt";default:return"unknown"}}).join("|"):"",r="checkpointId"in e&&e.checkpointId?`cp:${e.checkpointId}`:"",o="checkpointNs"in e&&e.checkpointNs?`ns:${e.checkpointNs}`:"",s=[r,o].filter(Boolean).join("|");return`${e.id}:${t}:${n}${s?`:${s}`:""}`}function nb(e){if(!e)return"image/png";const t=e.trim();return t?t.includes("/")?t:`image/${t}`:"image/png"}function rb(e){const t=[],n=r=>{r&&r.trim()&&t.push(r.trim())};return e&&(n(e.plotId),n(e.artifactId)),t}function ob({base64:e,url:t,formatHint:n,extras:r}){const o=typeof e=="string"&&e.length>0,s=nb(n),i=o?`data:${s};base64,${e}`:t,a=rb(r),l=a.length?a.join(" / "):void 0,c=l?`${l} artifact`:"artifact image";return{src:i,alt:c,label:l}}function sb(e){var o,s;const t=((o=e.content_base64)==null?void 0:o.trim())||void 0,n=((s=e.url)==null?void 0:s.trim())||void 0,r=e.format||e.mimeType||e.mime_type;return ob({base64:t,url:n,formatHint:r,extras:{plotId:e.plotId,artifactId:e.artifactId}})}function gu(e){var n;const t=(n=e.additionalKwargs)==null?void 0:n.toolProgress;return Array.isArray(t)?t:[]}const ib={messages:[],assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,messagesStreamMeta:{},pendingInterrupt:null};function ab(e,t){var n;switch(t.type){case"reset":return{messages:Ri(((n=t.payload)==null?void 0:n.messages)??[]),assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,pendingInterrupt:null,messagesStreamMeta:{}};case"user_message":{const{message:r,editingMessageId:o}=t.payload;if(o){const s=e.messages.findIndex(i=>i.id===o);if(s>=0){const i=e.messages.slice(0,s);return{...e,messages:[...i,r]}}}return{...e,messages:[...e.messages,r]}}case"seed":{const r=Ri(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=Ri(t.payload.messages);if(!r.length)return e;const o=new Set(e.messages.map(a=>a.id)),s=r.filter(a=>!o.has(a.id));if(!s.length)return e;const i=[...s,...e.messages];return{...e,messages:i}}case"event":return xu(e,t.payload.ev);case"batch":{const{events:r}=t.payload;return r.length?r.reduce((o,s)=>xu(o,s),e):e}default:return e}}function lb(e=[]){const[t,n]=b.useReducer(ab,{...ib,messages:e}),r=b.useRef([]),o=b.useRef(null),s=b.useRef(null),i=b.useCallback(()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),o.current=null,s.current=null;const d=r.current;d.length&&(r.current=[],n({type:"batch",payload:{events:d}}))},[]),a=b.useCallback(()=>{typeof window<"u"&&typeof window.requestAnimationFrame=="function"?o.current===null&&(o.current=window.requestAnimationFrame(()=>i())):s.current===null&&(s.current=setTimeout(i,8))},[i]),l=b.useCallback(d=>{r.current.push(d),a()},[a]);b.useEffect(()=>()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),r.current=[]},[]);const c=b.useMemo(()=>({reset:d=>n({type:"reset",payload:{messages:d}}),seed:(d,h)=>n({type:"seed",payload:{messages:d,...h??{}}}),prepend:d=>n({type:"prepend",payload:{messages:d}}),pushUser:(d,h)=>n({type:"user_message",payload:{message:d,editingMessageId:h}}),onEvent:l}),[l]);return{state:t,dispatch:n,...c}}function xu(e,t){var n,r,o;if(t.type==="message.start"&&t.role==="assistant"){const s=t.id,i=uu(t.model);if(e.messages.some(c=>c.id===s)){const c=e.messagesStreamMeta??{},d={...c,[s]:c[s]??{lastSeq:t.seq??null,lastText:""}};return{...e,assemblingId:s,messagesStreamMeta:d}}const l={id:s,role:"assistant",name:i||void 0,model:t.model,createdAt:new Date().toISOString(),content:[]};return{...e,assemblingId:s,messages:[...e.messages,l]}}if(t.type==="tool.start")return ub(e,t);if(t.type==="tool.progress")return db(e,t);if(t.type==="tool.end")return fb(e,t);if(t.type==="message.delta"){const s=e.assemblingId??iu(e.messages);if(!s)return e;const i=e.messages,a=i.findIndex(C=>C.id===s&&C.role==="assistant");if(a===-1)return e;const l=i[a],c=e.messagesStreamMeta,d=c??{},h=d[s],m=h??{lastSeq:null,lastText:au(l.content)},f=t.seq??null;if(f!==null&&typeof f=="number"&&typeof m.lastSeq=="number"&&f<=m.lastSeq)return console.debug("[MessageReducer] skipping delta - seq <= lastSeq",{seq:f,lastSeq:m.lastSeq}),e;const{newParts:v,newMeta:g,changed:x}=lu(l.content,t.delta,m,f);if(!x)return e;const y={...l,content:v},w=Jr(i,a,y),S=!h||h.lastSeq!==g.lastSeq||h.lastText!==g.lastText,k=S?{...d,[s]:g}:c;return S?{...e,messages:w,messagesStreamMeta:k}:{...e,messages:w}}if(t.type==="message.end"){const s=e.assemblingId??iu(e.messages);if(!s)return{...e,assemblingId:null};const i=e.messages,a=i.findIndex(l=>l.id===s&&l.role==="assistant");if(a>=0){const l=i[a];if(!((n=l.content)==null?void 0:n.some(d=>{var h;return(d==null?void 0:d.type)==="text"&&((h=d.text)==null?void 0:h.trim())}))){console.debug("[MessageReducer] pruning assistant message with no visible text",{id:l.id,contentTypes:(r=l.content)==null?void 0:r.map(h=>h==null?void 0:h.type),contentPreview:(o=l.content)==null?void 0:o.map(h=>(h==null?void 0:h.type)==="text"?String(h.text).slice(0,100):h==null?void 0:h.type)});const d=[...i.slice(0,a),...i.slice(a+1)];return{...e,assemblingId:null,messages:d}}}return e}if(t.type==="checkpoint"){const s=t.checkpointNs??e.lastCheckpointNs??null,i=qv(e.messages,t.checkpointId,s);return{...e,lastCheckpointId:t.checkpointId,lastCheckpointNs:s,messages:i}}if(t.type==="error"){const s={id:`err-${Date.now()}`,role:"system",content:[{type:"text",text:`Error: ${t.message}`}],createdAt:new Date().toISOString()};return{...e,messages:[...e.messages,s]}}if(t.type==="state_history"){const s=Mn(t),i=s.interrupt,a=s.latest,l=i===null?Vv(e.messages):e.messages;return{...e,messages:l,pendingInterrupt:i,lastCheckpointId:(a==null?void 0:a.checkpointId)??e.lastCheckpointId,lastCheckpointNs:(a==null?void 0:a.checkpointNs)??e.lastCheckpointNs}}return t.type==="thread_info",e}function Di(e){return e.call_id??e.id??null}function vu(e){return e.id??e.call_id??`tool-${Date.now()}-${Math.random().toString(16).slice(2)}`}function bu(e,t,n,r){const o=t??`call-${Date.now()}-${Math.random().toString(16).slice(2)}`;return{id:e,role:"tool",name:n??void 0,content:[{type:"tool_call",id:o,name:n??"tool",args:r??{}}],createdAt:new Date().toISOString(),additionalKwargs:{toolCallId:o,toolName:n??void 0,toolStreaming:!0,toolProgress:[]}}}function Li(e,t){if(!t)return-1;for(let n=0;n<e.length;n+=1){const r=e[n];if(r.role!=="tool")continue;const o=r.additionalKwargs??{};if(typeof o.toolCallId=="string"&&o.toolCallId===t||Oi(r).toolCallId===t)return n}return-1}function cb(e){if(e==null)return[];const t=Qr(e);if(typeof t=="string"&&t.trim())return[{type:"text",text:t}];const n=vr(t??e);return n?[{type:"text",text:n}]:[]}function wu(e,t){const n=e.additionalKwargs??{},r=Array.isArray(n.toolProgress)?[...n.toolProgress]:[],o={...n,toolProgress:[...r,t]};return{...e,additionalKwargs:o}}function ub(e,t){const n=Di(t),r=Li(e.messages,n),o=t.name??t.tool??void 0,s=vu(t);if(r>=0){const a=e.messages[r],c={...a.additionalKwargs??{},toolStreaming:!0,toolProgress:[]},d={...a,name:o??a.name,additionalKwargs:c};return{...e,messages:Jr(e.messages,r,d)}}const i=bu(s,n,o,t.args);return{...e,messages:[...e.messages,i]}}function db(e,t){const n=Di(t);if(!n)return e;const r=Li(e.messages,n);if(r===-1)return e;const o={type:t.type,content:typeof t.content=="string"?t.content:void 0,seq:t.seq??null,timestamp:new Date().toISOString()},s=t.metadata;s&&(o.metadata=s);const i=t.idx;typeof i=="number"&&(o.idx=i);const a=wu(e.messages[r],o);return{...e,messages:Jr(e.messages,r,a)}}function fb(e,t){const n=Di(t),r=vu(t);let o=e.messages,s=Li(o,n);if(s===-1){const v=t.name??t.tool??void 0;o=[...o,bu(r,n,v,{})],s=o.length-1}const i=o[s],a=t.output??t.error??null,l=cb(a),c=[...i.content,...l],d={type:t.type,content:typeof t.output=="string"?t.output:void 0,seq:t.seq??null,timestamp:new Date().toISOString()};t.artifact&&(d.artifact=t.artifact);const h=wu(i,d),m=t.artifact??i.artifact,f={...h,name:t.name??t.tool??i.name,content:c,artifact:m,additionalKwargs:{...h.additionalKwargs??{},toolStreaming:!1}};return{...e,messages:Jr(o,s,f)}}function yu({api:e,seed:t,prepend:n,onError:r,currentThreadId:o,initialThreadId:s=null,initialCheckpointId:i=null,initialCheckpointNs:a=null,autoLoadInitial:l=!0,isStreaming:c,getMessages:d}){const[h,m]=b.useState(null),v=b.useMemo(()=>Mn(h),[h]).checkpoints,g=nc(v),x=g.timeline,[y,w]=b.useState(!1),[S,k]=b.useState(null),[C,T]=b.useState(!1),[E,j]=b.useState(!1),[P,D]=b.useState(!1),[F,W]=b.useState(null),G=b.useRef(o),A=b.useRef(null),X=b.useRef(null),q=b.useRef(null),B=b.useRef(null),R=b.useRef(null),I=b.useRef(new Map);b.useEffect(()=>{G.current=o},[o]);const H=b.useCallback(async K=>{var pe,de;if(!K.threadId)return;const Q=K.threadId;(pe=K.onStart)==null||pe.call(K),K.setLoading(!0);try{await K.action(Q)}catch(me){if(G.current===Q){const we=String(me);(de=K.handleError)==null||de.call(K,we),r==null||r(we)}throw me}finally{K.setLoading(!1)}},[r]),Y=b.useCallback(async(K,Q)=>{if(!K)return;const pe=`${K}:${Q??"latest"}`,de=I.current.get(pe);if(de)return de;const me=H({threadId:K,setLoading:T,onStart:()=>W(null),handleError:we=>W(we),action:async we=>{const Te=await e.getStateHistory({threadId:we,checkpointId:Q??void 0});if(G.current!==we){console.log(`[useThreadHistoryState] Thread changed during load (was ${we}, now ${G.current}), discarding stale data`);return}const{checkpoints:Ne}=Mn(Te),ke=Ne.find(st=>st.messages&&st.messages.length>0)??(Q?Ne.find(st=>st.checkpointId===Q):null)??Ne[0];t((ke==null?void 0:ke.messages)??[],{checkpointId:(ke==null?void 0:ke.checkpointId)??null,checkpointNs:(ke==null?void 0:ke.checkpointNs)??null}),m(Te),w(!!(ke!=null&&ke.nextCursor)),k((ke==null?void 0:ke.nextCursor)??null)}});I.current.set(pe,me);try{await me}finally{I.current.delete(pe)}return G.current===K&&(R.current=pe),me},[e,t,H]),_=b.useCallback(async(K,Q)=>{B.current=K;try{await Y(K,Q)}finally{B.current===K&&(B.current=null)}},[Y]),O=b.useCallback(K=>{X.current=K},[]),M=b.useCallback(K=>{q.current=K},[]),L=b.useCallback(K=>{const Q=K.threadId??G.current;if(!Q||G.current&&G.current!==Q)return;const{checkpoints:pe}=Mn(K);if(!pe.length)return;const de=pe.find(we=>we.messages&&we.messages.length>0)??pe.find(we=>!!we.checkpointId)??pe[0],me=q.current===Q;!c&&!me&&t((de==null?void 0:de.messages)??[],{checkpointId:(de==null?void 0:de.checkpointId)??null,checkpointNs:(de==null?void 0:de.checkpointNs)??null}),m(K),w(!!(de!=null&&de.nextCursor)),k((de==null?void 0:de.nextCursor)??null),R.current=`${Q}:latest`,X.current=null,q.current===Q&&(q.current=null)},[t,c]),te=b.useCallback(async(K,Q)=>{const pe=G.current;await H({threadId:pe,setLoading:D,action:async de=>{const me=await e.getStateHistory({threadId:de,checkpointId:K,checkpointNs:Q??void 0});if(G.current!==de){console.log(`[useThreadHistoryState] Thread changed during checkpoint navigation (was ${de}, now ${G.current}), discarding stale data`);return}const{checkpoints:we}=Mn(me),Te=we.find(Ne=>Ne.checkpointId===K&&(Q?Ne.checkpointNs===Q:!0));if(!Te){console.warn("[useThreadHistoryState] Requested checkpoint not found:",{checkpointId:K,checkpointNs:Q});return}m(me),t(Te.messages??[],{checkpointId:Te.checkpointId??null,checkpointNs:Te.checkpointNs??null})}}).catch(()=>{})},[e,t,H]),z=b.useCallback((K,Q)=>{t(d(),{checkpointId:K??null,checkpointNs:Q??null})},[d,t]),$=b.useCallback(async()=>{G.current&&await _(G.current)},[_]),ee=b.useCallback(async()=>{const K=G.current;!K||!S||await H({threadId:K,setLoading:j,action:async Q=>{const pe=await e.getStateHistory({threadId:Q,checkpointId:S});if(G.current!==Q)return;const{checkpoints:de}=Mn(pe);if(de.length>0){const me=de[de.length-1];n((me==null?void 0:me.messages)??[]),w(!!(me!=null&&me.nextCursor)),k((me==null?void 0:me.nextCursor)??null)}}}).catch(()=>{})},[e,S,r,n,H]);b.useEffect(()=>{if(!l||!o||C||c)return;if(X.current===o){X.current=null,A.current=o;return}if(q.current===o){A.current=o;return}if(B.current===o){B.current=null,A.current=o;return}if(A.current===o)return;A.current=o;let K;console.log("[useThreadHistoryState] Loading thread with latest checkpoint");const Q=`${o}:latest`;R.current!==Q&&_(o,K)},[l,o,i,a,s,C,c,_]);const J=b.useCallback(()=>{m(null),w(!1),k(null),T(!1),j(!1),D(!1),W(null),X.current=null,q.current=null,A.current=null,R.current=null,B.current=null},[]);return{threadCheckpoints:v,threadTimeline:x,checkpointIndex:g,isLoadingThread:C,isHistoryLoading:E,isLoadingCheckpoint:P,threadStateError:F,hasMoreHistory:y,loadThread:_,navigateToCheckpoint:te,loadOlderMessages:ee,setCurrentCheckpointId:z,returnToLatest:$,handleStateHistoryEvent:L,markSkipNextLoad:O,markStreamPendingThread:M,resetHistoryState:J}}const Su=b.createContext(null),Cu=b.createContext(null);function eo(){const e=b.useContext(Su);if(!e)throw new Error("useThreadState must be used within a ThreadStateProvider");return e}function Tu(){const e=b.useContext(Cu);if(!e)throw new Error("useThreadStateUpdater must be used within a ThreadStateProvider");return e}function ku({children:e,initialThreadId:t=null,initialCheckpointId:n=null,initialCheckpointNs:r=null,autoLoadInitial:o=!0,isStreaming:s,onError:i}){const{api:a}=Xr(),{currentThreadId:l}=xr(),{state:c,seed:d,prepend:h,pushUser:m,onEvent:f}=lb(),{threadCheckpoints:v,threadTimeline:g,checkpointIndex:x,isLoadingThread:y,isHistoryLoading:w,isLoadingCheckpoint:S,threadStateError:k,hasMoreHistory:C,loadThread:T,navigateToCheckpoint:E,loadOlderMessages:j,setCurrentCheckpointId:P,returnToLatest:D,handleStateHistoryEvent:F,markSkipNextLoad:W,markStreamPendingThread:G,resetHistoryState:A}=yu({api:a,seed:d,prepend:h,onError:i,currentThreadId:l,initialThreadId:t,initialCheckpointId:n,initialCheckpointNs:r,autoLoadInitial:o,isStreaming:s,getMessages:b.useCallback(()=>c.messages,[c.messages])}),[X,q]=b.useState(()=>async()=>{throw new Error("clearThread is not ready")}),[B,R]=b.useState(()=>async()=>{throw new Error("respondToInterrupt is not ready")});b.useEffect(()=>{l||(d([],{}),A())},[l,d,A]);const I=b.useCallback(M=>q(()=>M),[]),H=b.useCallback(M=>R(()=>M),[]),Y=b.useMemo(()=>({assemblingMessageId:c.assemblingId??null}),[c.assemblingId]),_=b.useMemo(()=>({threadId:l,messages:c.messages,interrupt:c.pendingInterrupt,checkpoint:{id:c.lastCheckpointId??null,namespace:c.lastCheckpointNs??null},checkpoints:v,checkpointIndex:x,timelineCheckpoints:g,metadata:Y,isLoading:y,isHistoryLoading:w,isLoadingCheckpoint:S,error:k,hasMore:C,loadOlder:j,clearState:X,navigateToCheckpoint:E,setCurrentCheckpointId:P,returnToLatest:D,loadThread:T,clearThread:X,respondToInterrupt:B,messagePreviews:x.messagePreviews,handleStateHistoryEvent:F,markSkipNextLoad:W,markStreamPendingThread:G,resetHistoryState:A,pushUser:m,onEvent:f}),[l,c,v,g,x,Y,y,w,S,k,C,j,X,E,P,D,T,B,x.messagePreviews,F,W,G,A,m,f]),O=b.useMemo(()=>({registerClearThread:I,registerRespondToInterrupt:H}),[I,H]);return u.jsx(Cu.Provider,{value:O,children:u.jsx(Su.Provider,{value:_,children:e})})}function Eu(e,t){if(!e)return null;const n=_n(e);if(!n)return null;const r=_n(n.configurable)??n;return Rn(r,t)??null}function hb(e){const t=Eu(e,["checkpoint_id","checkpointId"]);if(!t)return null;const n=Eu(e,["checkpoint_ns","checkpointNs"]);return{checkpointId:t,checkpointNs:n}}function pb(e,t){const n=typeof e.step=="number"?e.step:Number.POSITIVE_INFINITY,r=typeof t.step=="number"?t.step:Number.POSITIVE_INFINITY;if(n!==r)return n-r;const o=e.createdAt?Date.parse(e.createdAt):0,s=t.createdAt?Date.parse(t.createdAt):0;return o-s}function mb(e,t){const n=[...e].sort(pb);for(const r of n){if(r.messageId!==t)continue;const o=hb(r.parentConfig);if(!o)throw new Error(`Parent checkpoint info missing for message ${t}`);return o}throw new Error(`Message ${t} not found in timeline`)}const Iu=b.createContext(null),Nu=b.createContext(!1);function gb({children:e,initialThreadId:t=null,initialCheckpointId:n=null,initialCheckpointNs:r=null,autoLoadInitial:o=!0,onError:s,onAuthError:i,onThreadChange:a,onConnectionError:l,onToolEnd:c}){const{api:d,baseUrl:h}=Xr(),m=b.useMemo(()=>xn(h),[h]),{stream:f,stop:v,isStreaming:g,error:x,setToken:y}=Gv({baseUrl:m}),[w,S]=b.useState(!1);return b.useEffect(()=>{S(g)},[g]),u.jsx(hu,{initialThreadId:t,onError:s,onThreadChange:a,children:u.jsx(ku,{initialThreadId:t,initialCheckpointId:n,initialCheckpointNs:r,autoLoadInitial:o,onError:s,isStreaming:w,children:u.jsx(Nu.Provider,{value:!0,children:u.jsx(xb,{api:d,streamApi:{stream:f,stop:v,isStreaming:g,error:x,setToken:y},onError:s,onAuthError:i,onConnectionError:l,onToolEnd:c,children:e})})})})}function xb({children:e,api:t,streamApi:n,onError:r,onAuthError:o,onConnectionError:s,onToolEnd:i}){const{stream:a,stop:l,isStreaming:c,error:d,setToken:h}=n,{setCurrentThreadId:m,currentThreadIdRef:f,addThreadFromEvent:v}=xr(),{checkpoint:g,timelineCheckpoints:x,handleStateHistoryEvent:y,markSkipNextLoad:w,markStreamPendingThread:S,resetHistoryState:k,pushUser:C,onEvent:T}=eo(),{registerClearThread:E,registerRespondToInterrupt:j}=Tu(),P=b.useCallback(B=>{v(B),f.current!==B.threadId&&((B.created??!f.current)&&w(B.threadId),S(B.threadId),m(B.threadId))},[v,w,S,m,f]),D=b.useCallback(B=>{B.type==="thread_info"?P(B):B.type==="state_history"?y(B):B.type==="tool.end"?i==null||i(B):T(B)},[P,y,T,i]),F=b.useCallback(B=>{a(B,D,{onError:R=>{console.error("[StreamingProvider] Stream error:",R),r==null||r(R)},onAuthError:R=>{console.error("[StreamingProvider] Auth error:",R),o==null||o(R)},onConnectionError:R=>{console.error("[StreamingProvider] Connection error:",R),s==null||s(R)}})},[a,D,r,o,s]),W=b.useRef(g);b.useEffect(()=>{W.current=g},[g]);const G=b.useCallback(async(B,R,I)=>{const H=f.current;if(!H)throw new Error("No active thread to handle interrupt");const Y=R?I??!0:!1,_=W.current,O={threadId:H,checkpointId:_.id??void 0,checkpointNs:_.namespace??void 0,command:{kind:"resume",value:Y}};F(O)},[f,F]);b.useEffect(()=>{j(G)},[G,j]);const A=b.useCallback(async()=>{l(),k(),m(null);try{await t.getAgent("default")}catch(B){console.warn("[StreamingProvider] Failed to refetch agent after clearing thread:",B)}},[t,k,m,l]);b.useEffect(()=>{E(A)},[A,E]);const X=b.useCallback(async(B,R)=>{let I=f.current;const H=(B==null?void 0:B.text)??"",Y=(B==null?void 0:B.attachments)??[],_=(H==null?void 0:H.trim())??"",O={...(B==null?void 0:B.payload)??{}},M=Array.isArray(O.messages)?O.messages:void 0;M&&delete O.messages;const L=!!(M&&M.length);if(!I&&!_&&Y.length===0&&!L)return;if(!I){const Ne=Math.floor(Date.now()/1e3).toString(16).padStart(8,"0"),ke=Array.from({length:4},()=>Math.floor(Math.random()*4294967295).toString(16).padStart(8,"0")).join("").slice(0,16);I=`${Ne}${ke}`,w(I),m(I)}const{contentParts:te,filesInfo:z}=await ou(Y),$=[...te];_&&$.push({type:"text",text:H});const ee=R==null?void 0:R.originalMessageId,J=!!(R!=null&&R.edit&&ee),K=!L&&$.length>0;let Q=null;K&&(Q={id:J?ee:`msg-${Date.now()}`,role:"user",content:$,createdAt:new Date().toISOString()},J?C(Q,ee):C(Q));const pe=L?M:Q?[Q]:[],de={...O,...z.length?{files_info:z}:{}};pe.length?de.messages=pe:"messages"in de||(de.messages=[]);let me=(R==null?void 0:R.checkpointId)??g.id??void 0,we=(R==null?void 0:R.checkpointNs)??g.namespace??void 0;if(J&&ee){const Ne=mb(x,ee);me=Ne.checkpointId,we=Ne.checkpointNs??void 0}const Te={threadId:I,payload:de,checkpointId:me,checkpointNs:we,edit:!!(R!=null&&R.edit)};F(Te)},[g,f,w,C,F,x]),q=b.useMemo(()=>({isStreaming:c,error:d,connectionState:c?"connected":"idle",submit:X,send:X,stop:l,setAuthToken:h}),[c,d,X,l,h]);return u.jsx(Iu.Provider,{value:q,children:e})}function $i(){const e=b.useContext(Iu);if(!e)throw new Error("useStream must be used within StreamingProvider");return e}function vb(){return b.useContext(Nu)}function Au(e){return typeof e=="object"&&e!==null}function bb(e,t){if(Object.is(e,t))return!0;if(!Au(e)||!Au(t))return!1;const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const o of n)if(!Object.prototype.hasOwnProperty.call(t,o)||!Object.is(e[o],t[o]))return!1;return!0}function ju(e){const t=b.useRef(e),n=b.useRef(e);return bb(t.current,e)||(t.current=e,n.current=e),n.current}function br({children:e,apiConfig:t,initialThreadId:n=null,initialCheckpointId:r=null,initialCheckpointNs:o=null,autoLoadInitial:s=!0,onConnectionError:i,onError:a,onAuthError:l,onThreadChange:c,onToolEnd:d}){const h=ju(t),m=to(a),f=to(l),v=to(i),g=to(c),x=to(d),y=b.useMemo(()=>({initialThreadId:n,initialCheckpointId:r,initialCheckpointNs:o,autoLoadInitial:s,onError:m,onAuthError:f,onConnectionError:v,onThreadChange:g,onToolEnd:x}),[n,r,o,s,m,f,v,g,x]);return u.jsx(nu,{apiConfig:h,children:u.jsx(gb,{...y,children:e})})}function to(e){const t=b.useRef(e);return b.useEffect(()=>{t.current=e},[e]),b.useCallback((...n)=>{const r=t.current;if(r)return r(...n)},[])}function wr(e){if(!(typeof globalThis>"u"))return globalThis[e]}function wb(e){if(typeof e!="string")return;const t=e.trim();if(t)return xn(t)}function Pu(){const e=[wr("__API_BASE_URL__"),wr("__CHAT_API_BASE_URL__"),wr("__CHAT_API_URL__")];for(const t of e){const n=wb(t);if(n)return n}}function _u(){const e=[wr("__API_AUTH_TOKEN__"),wr("__CHAT_API_KEY__"),wr("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function Ru(...e){for(const t of e)if(typeof t=="string"&&t.trim())return xn(t);return xn()}function Mu(){const e={},t=Pu(),n=_u();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function Ou(){const e=Mu(),t=Nn.getAuthToken(),n=Pu();return{apiBaseUrl:Ru(e.baseUrl,Nn.baseUrl,n),apiKey:t||e.apiKey||_u()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,darkMode:!1,enableSound:!1,messageHistory:100}}const Fi="chat-settings";function Du(){try{const e=localStorage.getItem(Fi);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function Lu(e){try{const t={...e,apiBaseUrl:xn(e.apiBaseUrl)};localStorage.setItem(Fi,JSON.stringify(t)),t.apiKey&&Nn.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function yb(){const e=Ou(),t=Du(),n=Nn.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:Ru(Nn.baseUrl,r,e.apiBaseUrl)}}function Sb(e){Nn.updateConfig({baseUrl:e.apiBaseUrl,authToken:e.apiKey??void 0}),Lu(e)}function oe(...e){return sx.twMerge(ox.clsx(e))}const Cb=zr.cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),Je=p.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?qt.Slot:"button";return u.jsx(i,{className:oe(Cb({variant:t,size:n,className:e})),ref:s,...o})});Je.displayName="Button";function ie(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}function $u(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function On(...e){return t=>{let n=!1;const r=e.map(o=>{const s=$u(o,t);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let o=0;o<r.length;o++){const s=r[o];typeof s=="function"?s():$u(e[o],null)}}}}function Oe(...e){return p.useCallback(On(...e),e)}function Tb(e,t){const n=p.createContext(t),r=s=>{const{children:i,...a}=s,l=p.useMemo(()=>a,Object.values(a));return u.jsx(n.Provider,{value:l,children:i})};r.displayName=e+"Provider";function o(s){const i=p.useContext(n);if(i)return i;if(t!==void 0)return t;throw new Error(`\`${s}\` must be used within \`${e}\``)}return[r,o]}function ln(e,t=[]){let n=[];function r(s,i){const a=p.createContext(i),l=n.length;n=[...n,i];const c=h=>{var y;const{scope:m,children:f,...v}=h,g=((y=m==null?void 0:m[e])==null?void 0:y[l])||a,x=p.useMemo(()=>v,Object.values(v));return u.jsx(g.Provider,{value:x,children:f})};c.displayName=s+"Provider";function d(h,m){var g;const f=((g=m==null?void 0:m[e])==null?void 0:g[l])||a,v=p.useContext(f);if(v)return v;if(i!==void 0)return i;throw new Error(`\`${h}\` must be used within \`${s}\``)}return[c,d]}const o=()=>{const s=n.map(i=>p.createContext(i));return function(a){const l=(a==null?void 0:a[e])||s;return p.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return o.scopeName=e,[r,kb(o,...t)]}function kb(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(s){const i=r.reduce((a,{useScope:l,scopeName:c})=>{const h=l(s)[`__scope${c}`];return{...a,...h}},{});return p.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var Tt=globalThis!=null&&globalThis.document?p.useLayoutEffect:()=>{},Eb=p[" useInsertionEffect ".trim().toString()]||Tt;function Dn({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=Ib({defaultProp:t,onChange:n}),a=e!==void 0,l=a?e:o;{const d=p.useRef(e!==void 0);p.useEffect(()=>{const h=d.current;h!==a&&console.warn(`${r} is changing from ${h?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),d.current=a},[a,r])}const c=p.useCallback(d=>{var h;if(a){const m=Nb(d)?d(e):d;m!==e&&((h=i.current)==null||h.call(i,m))}else s(d)},[a,e,s,i]);return[l,c]}function Ib({defaultProp:e,onChange:t}){const[n,r]=p.useState(e),o=p.useRef(n),s=p.useRef(t);return Eb(()=>{s.current=t},[t]),p.useEffect(()=>{var i;o.current!==n&&((i=s.current)==null||i.call(s,n),o.current=n)},[n,o]),[n,r,s]}function Nb(e){return typeof e=="function"}var Ab=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],ge=Ab.reduce((e,t)=>{const n=qt.createSlot(`Primitive.${t}`),r=p.forwardRef((o,s)=>{const{asChild:i,...a}=o,l=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),u.jsx(l,{...a,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Bi(e,t){e&&Hr.flushSync(()=>e.dispatchEvent(t))}function Xo(e){const t=e+"CollectionProvider",[n,r]=ln(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=g=>{const{scope:x,children:y}=g,w=b.useRef(null),S=b.useRef(new Map).current;return u.jsx(o,{scope:x,itemMap:S,collectionRef:w,children:y})};i.displayName=t;const a=e+"CollectionSlot",l=qt.createSlot(a),c=b.forwardRef((g,x)=>{const{scope:y,children:w}=g,S=s(a,y),k=Oe(x,S.collectionRef);return u.jsx(l,{ref:k,children:w})});c.displayName=a;const d=e+"CollectionItemSlot",h="data-radix-collection-item",m=qt.createSlot(d),f=b.forwardRef((g,x)=>{const{scope:y,children:w,...S}=g,k=b.useRef(null),C=Oe(x,k),T=s(d,y);return b.useEffect(()=>(T.itemMap.set(k,{ref:k,...S}),()=>void T.itemMap.delete(k))),u.jsx(m,{[h]:"",ref:C,children:w})});f.displayName=d;function v(g){const x=s(e+"CollectionConsumer",g);return b.useCallback(()=>{const w=x.collectionRef.current;if(!w)return[];const S=Array.from(w.querySelectorAll(`[${h}]`));return Array.from(x.itemMap.values()).sort((T,E)=>S.indexOf(T.ref.current)-S.indexOf(E.ref.current))},[x.collectionRef,x.itemMap])}return[{Provider:i,Slot:c,ItemSlot:f},v,r]}var jb=p.createContext(void 0);function Jo(e){const t=p.useContext(jb);return e||t||"ltr"}function ft(e){const t=p.useRef(e);return p.useEffect(()=>{t.current=e}),p.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function Pb(e,t=globalThis==null?void 0:globalThis.document){const n=ft(e);p.useEffect(()=>{const r=o=>{o.key==="Escape"&&n(o)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var _b="DismissableLayer",zi="dismissableLayer.update",Rb="dismissableLayer.pointerDownOutside",Mb="dismissableLayer.focusOutside",Fu,Bu=p.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),yr=p.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...l}=e,c=p.useContext(Bu),[d,h]=p.useState(null),m=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,f]=p.useState({}),v=Oe(t,E=>h(E)),g=Array.from(c.layers),[x]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),y=g.indexOf(x),w=d?g.indexOf(d):-1,S=c.layersWithOutsidePointerEventsDisabled.size>0,k=w>=y,C=Db(E=>{const j=E.target,P=[...c.branches].some(D=>D.contains(j));!k||P||(o==null||o(E),i==null||i(E),E.defaultPrevented||a==null||a())},m),T=Lb(E=>{const j=E.target;[...c.branches].some(D=>D.contains(j))||(s==null||s(E),i==null||i(E),E.defaultPrevented||a==null||a())},m);return Pb(E=>{w===c.layers.size-1&&(r==null||r(E),!E.defaultPrevented&&a&&(E.preventDefault(),a()))},m),p.useEffect(()=>{if(d)return n&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(Fu=m.body.style.pointerEvents,m.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(d)),c.layers.add(d),Hu(),()=>{n&&c.layersWithOutsidePointerEventsDisabled.size===1&&(m.body.style.pointerEvents=Fu)}},[d,m,n,c]),p.useEffect(()=>()=>{d&&(c.layers.delete(d),c.layersWithOutsidePointerEventsDisabled.delete(d),Hu())},[d,c]),p.useEffect(()=>{const E=()=>f({});return document.addEventListener(zi,E),()=>document.removeEventListener(zi,E)},[]),u.jsx(ge.div,{...l,ref:v,style:{pointerEvents:S?k?"auto":"none":void 0,...e.style},onFocusCapture:ie(e.onFocusCapture,T.onFocusCapture),onBlurCapture:ie(e.onBlurCapture,T.onBlurCapture),onPointerDownCapture:ie(e.onPointerDownCapture,C.onPointerDownCapture)})});yr.displayName=_b;var Ob="DismissableLayerBranch",zu=p.forwardRef((e,t)=>{const n=p.useContext(Bu),r=p.useRef(null),o=Oe(t,r);return p.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),u.jsx(ge.div,{...e,ref:o})});zu.displayName=Ob;function Db(e,t=globalThis==null?void 0:globalThis.document){const n=ft(e),r=p.useRef(!1),o=p.useRef(()=>{});return p.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){Uu(Rb,n,c,{discrete:!0})};const c={originalEvent:a};a.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=l,t.addEventListener("click",o.current,{once:!0})):l()}else t.removeEventListener("click",o.current);r.current=!1},i=window.setTimeout(()=>{t.addEventListener("pointerdown",s)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",s),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function Lb(e,t=globalThis==null?void 0:globalThis.document){const n=ft(e),r=p.useRef(!1);return p.useEffect(()=>{const o=s=>{s.target&&!r.current&&Uu(Mb,n,{originalEvent:s},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function Hu(){const e=new CustomEvent(zi);document.dispatchEvent(e)}function Uu(e,t,n,{discrete:r}){const o=n.originalEvent.target,s=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?Bi(o,s):o.dispatchEvent(s)}var $b=yr,Fb=zu,Hi=0;function Ui(){p.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Wu()),document.body.insertAdjacentElement("beforeend",e[1]??Wu()),Hi++,()=>{Hi===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Hi--}},[])}function Wu(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var Wi="focusScope.autoFocusOnMount",Vi="focusScope.autoFocusOnUnmount",Vu={bubbles:!1,cancelable:!0},Bb="FocusScope",Zo=p.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,l]=p.useState(null),c=ft(o),d=ft(s),h=p.useRef(null),m=Oe(t,g=>l(g)),f=p.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;p.useEffect(()=>{if(r){let g=function(S){if(f.paused||!a)return;const k=S.target;a.contains(k)?h.current=k:Ln(h.current,{select:!0})},x=function(S){if(f.paused||!a)return;const k=S.relatedTarget;k!==null&&(a.contains(k)||Ln(h.current,{select:!0}))},y=function(S){if(document.activeElement===document.body)for(const C of S)C.removedNodes.length>0&&Ln(a)};document.addEventListener("focusin",g),document.addEventListener("focusout",x);const w=new MutationObserver(y);return a&&w.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",g),document.removeEventListener("focusout",x),w.disconnect()}}},[r,a,f.paused]),p.useEffect(()=>{if(a){Gu.add(f);const g=document.activeElement;if(!a.contains(g)){const y=new CustomEvent(Wi,Vu);a.addEventListener(Wi,c),a.dispatchEvent(y),y.defaultPrevented||(zb(Kb(Ku(a)),{select:!0}),document.activeElement===g&&Ln(a))}return()=>{a.removeEventListener(Wi,c),setTimeout(()=>{const y=new CustomEvent(Vi,Vu);a.addEventListener(Vi,d),a.dispatchEvent(y),y.defaultPrevented||Ln(g??document.body,{select:!0}),a.removeEventListener(Vi,d),Gu.remove(f)},0)}}},[a,c,d,f]);const v=p.useCallback(g=>{if(!n&&!r||f.paused)return;const x=g.key==="Tab"&&!g.altKey&&!g.ctrlKey&&!g.metaKey,y=document.activeElement;if(x&&y){const w=g.currentTarget,[S,k]=Hb(w);S&&k?!g.shiftKey&&y===k?(g.preventDefault(),n&&Ln(S,{select:!0})):g.shiftKey&&y===S&&(g.preventDefault(),n&&Ln(k,{select:!0})):y===w&&g.preventDefault()}},[n,r,f.paused]);return u.jsx(ge.div,{tabIndex:-1,...i,ref:m,onKeyDown:v})});Zo.displayName=Bb;function zb(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Ln(r,{select:t}),document.activeElement!==n)return}function Hb(e){const t=Ku(e),n=qu(t,e),r=qu(t.reverse(),e);return[n,r]}function Ku(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function qu(e,t){for(const n of e)if(!Ub(n,{upTo:t}))return n}function Ub(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function Wb(e){return e instanceof HTMLInputElement&&"select"in e}function Ln(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Wb(e)&&t&&e.select()}}var Gu=Vb();function Vb(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=Yu(e,t),e.unshift(t)},remove(t){var n;e=Yu(e,t),(n=e[0])==null||n.resume()}}}function Yu(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Kb(e){return e.filter(t=>t.tagName!=="A")}var qb=p[" useId ".trim().toString()]||(()=>{}),Gb=0;function Pt(e){const[t,n]=p.useState(qb());return Tt(()=>{n(r=>r??String(Gb++))},[e]),t?`radix-${t}`:""}const Yb=["top","right","bottom","left"],$n=Math.min,Xt=Math.max,Qo=Math.round,es=Math.floor,vn=e=>({x:e,y:e}),Xb={left:"right",right:"left",bottom:"top",top:"bottom"},Jb={start:"end",end:"start"};function Ki(e,t,n){return Xt(e,$n(t,n))}function An(e,t){return typeof e=="function"?e(t):e}function jn(e){return e.split("-")[0]}function Sr(e){return e.split("-")[1]}function qi(e){return e==="x"?"y":"x"}function Gi(e){return e==="y"?"height":"width"}const Zb=new Set(["top","bottom"]);function bn(e){return Zb.has(jn(e))?"y":"x"}function Yi(e){return qi(bn(e))}function Qb(e,t,n){n===void 0&&(n=!1);const r=Sr(e),o=Yi(e),s=Gi(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=ts(i)),[i,ts(i)]}function ew(e){const t=ts(e);return[Xi(e),t,Xi(t)]}function Xi(e){return e.replace(/start|end/g,t=>Jb[t])}const Xu=["left","right"],Ju=["right","left"],tw=["top","bottom"],nw=["bottom","top"];function rw(e,t,n){switch(e){case"top":case"bottom":return n?t?Ju:Xu:t?Xu:Ju;case"left":case"right":return t?tw:nw;default:return[]}}function ow(e,t,n,r){const o=Sr(e);let s=rw(jn(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(Xi)))),s}function ts(e){return e.replace(/left|right|bottom|top/g,t=>Xb[t])}function sw(e){return{top:0,right:0,bottom:0,left:0,...e}}function Zu(e){return typeof e!="number"?sw(e):{top:e,right:e,bottom:e,left:e}}function ns(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}function Qu(e,t,n){let{reference:r,floating:o}=e;const s=bn(t),i=Yi(t),a=Gi(i),l=jn(t),c=s==="y",d=r.x+r.width/2-o.width/2,h=r.y+r.height/2-o.height/2,m=r[a]/2-o[a]/2;let f;switch(l){case"top":f={x:d,y:r.y-o.height};break;case"bottom":f={x:d,y:r.y+r.height};break;case"right":f={x:r.x+r.width,y:h};break;case"left":f={x:r.x-o.width,y:h};break;default:f={x:r.x,y:r.y}}switch(Sr(t)){case"start":f[i]-=m*(n&&c?-1:1);break;case"end":f[i]+=m*(n&&c?-1:1);break}return f}const iw=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=n,a=s.filter(Boolean),l=await(i.isRTL==null?void 0:i.isRTL(t));let c=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:d,y:h}=Qu(c,r,l),m=r,f={},v=0;for(let g=0;g<a.length;g++){const{name:x,fn:y}=a[g],{x:w,y:S,data:k,reset:C}=await y({x:d,y:h,initialPlacement:r,placement:m,strategy:o,middlewareData:f,rects:c,platform:i,elements:{reference:e,floating:t}});d=w??d,h=S??h,f={...f,[x]:{...f[x],...k}},C&&v<=50&&(v++,typeof C=="object"&&(C.placement&&(m=C.placement),C.rects&&(c=C.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):C.rects),{x:d,y:h}=Qu(c,m,l)),g=-1)}return{x:d,y:h,placement:m,strategy:o,middlewareData:f}};async function no(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:i,elements:a,strategy:l}=e,{boundary:c="clippingAncestors",rootBoundary:d="viewport",elementContext:h="floating",altBoundary:m=!1,padding:f=0}=An(t,e),v=Zu(f),x=a[m?h==="floating"?"reference":"floating":h],y=ns(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(x)))==null||n?x:x.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:c,rootBoundary:d,strategy:l})),w=h==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,S=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),k=await(s.isElement==null?void 0:s.isElement(S))?await(s.getScale==null?void 0:s.getScale(S))||{x:1,y:1}:{x:1,y:1},C=ns(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:w,offsetParent:S,strategy:l}):w);return{top:(y.top-C.top+v.top)/k.y,bottom:(C.bottom-y.bottom+v.bottom)/k.y,left:(y.left-C.left+v.left)/k.x,right:(C.right-y.right+v.right)/k.x}}const aw=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:s,platform:i,elements:a,middlewareData:l}=t,{element:c,padding:d=0}=An(e,t)||{};if(c==null)return{};const h=Zu(d),m={x:n,y:r},f=Yi(o),v=Gi(f),g=await i.getDimensions(c),x=f==="y",y=x?"top":"left",w=x?"bottom":"right",S=x?"clientHeight":"clientWidth",k=s.reference[v]+s.reference[f]-m[f]-s.floating[v],C=m[f]-s.reference[f],T=await(i.getOffsetParent==null?void 0:i.getOffsetParent(c));let E=T?T[S]:0;(!E||!await(i.isElement==null?void 0:i.isElement(T)))&&(E=a.floating[S]||s.floating[v]);const j=k/2-C/2,P=E/2-g[v]/2-1,D=$n(h[y],P),F=$n(h[w],P),W=D,G=E-g[v]-F,A=E/2-g[v]/2+j,X=Ki(W,A,G),q=!l.arrow&&Sr(o)!=null&&A!==X&&s.reference[v]/2-(A<W?D:F)-g[v]/2<0,B=q?A<W?A-W:A-G:0;return{[f]:m[f]+B,data:{[f]:X,centerOffset:A-X-B,...q&&{alignmentOffset:B}},reset:q}}}),lw=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:s,rects:i,initialPlacement:a,platform:l,elements:c}=t,{mainAxis:d=!0,crossAxis:h=!0,fallbackPlacements:m,fallbackStrategy:f="bestFit",fallbackAxisSideDirection:v="none",flipAlignment:g=!0,...x}=An(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const y=jn(o),w=bn(a),S=jn(a)===a,k=await(l.isRTL==null?void 0:l.isRTL(c.floating)),C=m||(S||!g?[ts(a)]:ew(a)),T=v!=="none";!m&&T&&C.push(...ow(a,g,v,k));const E=[a,...C],j=await no(t,x),P=[];let D=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&P.push(j[y]),h){const A=Qb(o,i,k);P.push(j[A[0]],j[A[1]])}if(D=[...D,{placement:o,overflows:P}],!P.every(A=>A<=0)){var F,W;const A=(((F=s.flip)==null?void 0:F.index)||0)+1,X=E[A];if(X&&(!(h==="alignment"?w!==bn(X):!1)||D.every(R=>bn(R.placement)===w?R.overflows[0]>0:!0)))return{data:{index:A,overflows:D},reset:{placement:X}};let q=(W=D.filter(B=>B.overflows[0]<=0).sort((B,R)=>B.overflows[1]-R.overflows[1])[0])==null?void 0:W.placement;if(!q)switch(f){case"bestFit":{var G;const B=(G=D.filter(R=>{if(T){const I=bn(R.placement);return I===w||I==="y"}return!0}).map(R=>[R.placement,R.overflows.filter(I=>I>0).reduce((I,H)=>I+H,0)]).sort((R,I)=>R[1]-I[1])[0])==null?void 0:G[0];B&&(q=B);break}case"initialPlacement":q=a;break}if(o!==q)return{reset:{placement:q}}}return{}}}};function ed(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function td(e){return Yb.some(t=>e[t]>=0)}const cw=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=An(e,t);switch(r){case"referenceHidden":{const s=await no(t,{...o,elementContext:"reference"}),i=ed(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:td(i)}}}case"escaped":{const s=await no(t,{...o,altBoundary:!0}),i=ed(s,n.floating);return{data:{escapedOffsets:i,escaped:td(i)}}}default:return{}}}}},nd=new Set(["left","top"]);async function uw(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=jn(n),a=Sr(n),l=bn(n)==="y",c=nd.has(i)?-1:1,d=s&&l?-1:1,h=An(t,e);let{mainAxis:m,crossAxis:f,alignmentAxis:v}=typeof h=="number"?{mainAxis:h,crossAxis:0,alignmentAxis:null}:{mainAxis:h.mainAxis||0,crossAxis:h.crossAxis||0,alignmentAxis:h.alignmentAxis};return a&&typeof v=="number"&&(f=a==="end"?v*-1:v),l?{x:f*d,y:m*c}:{x:m*c,y:f*d}}const dw=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:s,placement:i,middlewareData:a}=t,l=await uw(t,e);return i===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:o+l.x,y:s+l.y,data:{...l,placement:i}}}}},fw=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o}=t,{mainAxis:s=!0,crossAxis:i=!1,limiter:a={fn:x=>{let{x:y,y:w}=x;return{x:y,y:w}}},...l}=An(e,t),c={x:n,y:r},d=await no(t,l),h=bn(jn(o)),m=qi(h);let f=c[m],v=c[h];if(s){const x=m==="y"?"top":"left",y=m==="y"?"bottom":"right",w=f+d[x],S=f-d[y];f=Ki(w,f,S)}if(i){const x=h==="y"?"top":"left",y=h==="y"?"bottom":"right",w=v+d[x],S=v-d[y];v=Ki(w,v,S)}const g=a.fn({...t,[m]:f,[h]:v});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[m]:s,[h]:i}}}}}},hw=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:s,middlewareData:i}=t,{offset:a=0,mainAxis:l=!0,crossAxis:c=!0}=An(e,t),d={x:n,y:r},h=bn(o),m=qi(h);let f=d[m],v=d[h];const g=An(a,t),x=typeof g=="number"?{mainAxis:g,crossAxis:0}:{mainAxis:0,crossAxis:0,...g};if(l){const S=m==="y"?"height":"width",k=s.reference[m]-s.floating[S]+x.mainAxis,C=s.reference[m]+s.reference[S]-x.mainAxis;f<k?f=k:f>C&&(f=C)}if(c){var y,w;const S=m==="y"?"width":"height",k=nd.has(jn(o)),C=s.reference[h]-s.floating[S]+(k&&((y=i.offset)==null?void 0:y[h])||0)+(k?0:x.crossAxis),T=s.reference[h]+s.reference[S]+(k?0:((w=i.offset)==null?void 0:w[h])||0)-(k?x.crossAxis:0);v<C?v=C:v>T&&(v=T)}return{[m]:f,[h]:v}}}},pw=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:s,platform:i,elements:a}=t,{apply:l=()=>{},...c}=An(e,t),d=await no(t,c),h=jn(o),m=Sr(o),f=bn(o)==="y",{width:v,height:g}=s.floating;let x,y;h==="top"||h==="bottom"?(x=h,y=m===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(y=h,x=m==="end"?"top":"bottom");const w=g-d.top-d.bottom,S=v-d.left-d.right,k=$n(g-d[x],w),C=$n(v-d[y],S),T=!t.middlewareData.shift;let E=k,j=C;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(j=S),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(E=w),T&&!m){const D=Xt(d.left,0),F=Xt(d.right,0),W=Xt(d.top,0),G=Xt(d.bottom,0);f?j=v-2*(D!==0||F!==0?D+F:Xt(d.left,d.right)):E=g-2*(W!==0||G!==0?W+G:Xt(d.top,d.bottom))}await l({...t,availableWidth:j,availableHeight:E});const P=await i.getDimensions(a.floating);return v!==P.width||g!==P.height?{reset:{rects:!0}}:{}}}};function rs(){return typeof window<"u"}function Cr(e){return rd(e)?(e.nodeName||"").toLowerCase():"#document"}function Jt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function wn(e){var t;return(t=(rd(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function rd(e){return rs()?e instanceof Node||e instanceof Jt(e).Node:!1}function cn(e){return rs()?e instanceof Element||e instanceof Jt(e).Element:!1}function yn(e){return rs()?e instanceof HTMLElement||e instanceof Jt(e).HTMLElement:!1}function od(e){return!rs()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Jt(e).ShadowRoot}const mw=new Set(["inline","contents"]);function ro(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=un(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!mw.has(o)}const gw=new Set(["table","td","th"]);function xw(e){return gw.has(Cr(e))}const vw=[":popover-open",":modal"];function os(e){return vw.some(t=>{try{return e.matches(t)}catch{return!1}})}const bw=["transform","translate","scale","rotate","perspective"],ww=["transform","translate","scale","rotate","perspective","filter"],yw=["paint","layout","strict","content"];function Ji(e){const t=Zi(),n=cn(e)?un(e):e;return bw.some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||ww.some(r=>(n.willChange||"").includes(r))||yw.some(r=>(n.contain||"").includes(r))}function Sw(e){let t=Fn(e);for(;yn(t)&&!Tr(t);){if(Ji(t))return t;if(os(t))return null;t=Fn(t)}return null}function Zi(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Cw=new Set(["html","body","#document"]);function Tr(e){return Cw.has(Cr(e))}function un(e){return Jt(e).getComputedStyle(e)}function ss(e){return cn(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Fn(e){if(Cr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||od(e)&&e.host||wn(e);return od(t)?t.host:t}function sd(e){const t=Fn(e);return Tr(t)?e.ownerDocument?e.ownerDocument.body:e.body:yn(t)&&ro(t)?t:sd(t)}function oo(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=sd(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Jt(o);if(s){const a=Qi(i);return t.concat(i,i.visualViewport||[],ro(o)?o:[],a&&n?oo(a):[])}return t.concat(o,oo(o,[],n))}function Qi(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function id(e){const t=un(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=yn(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=Qo(n)!==s||Qo(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function ea(e){return cn(e)?e:e.contextElement}function kr(e){const t=ea(e);if(!yn(t))return vn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=id(t);let i=(s?Qo(n.width):n.width)/r,a=(s?Qo(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const Tw=vn(0);function ad(e){const t=Jt(e);return!Zi()||!t.visualViewport?Tw:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function kw(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Jt(e)?!1:t}function er(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=ea(e);let i=vn(1);t&&(r?cn(r)&&(i=kr(r)):i=kr(e));const a=kw(s,n,r)?ad(s):vn(0);let l=(o.left+a.x)/i.x,c=(o.top+a.y)/i.y,d=o.width/i.x,h=o.height/i.y;if(s){const m=Jt(s),f=r&&cn(r)?Jt(r):r;let v=m,g=Qi(v);for(;g&&r&&f!==v;){const x=kr(g),y=g.getBoundingClientRect(),w=un(g),S=y.left+(g.clientLeft+parseFloat(w.paddingLeft))*x.x,k=y.top+(g.clientTop+parseFloat(w.paddingTop))*x.y;l*=x.x,c*=x.y,d*=x.x,h*=x.y,l+=S,c+=k,v=Jt(g),g=Qi(v)}}return ns({width:d,height:h,x:l,y:c})}function is(e,t){const n=ss(e).scrollLeft;return t?t.left+n:er(wn(e)).left+n}function ld(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-is(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function Ew(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=wn(r),a=t?os(t.floating):!1;if(r===i||a&&s)return n;let l={scrollLeft:0,scrollTop:0},c=vn(1);const d=vn(0),h=yn(r);if((h||!h&&!s)&&((Cr(r)!=="body"||ro(i))&&(l=ss(r)),yn(r))){const f=er(r);c=kr(r),d.x=f.x+r.clientLeft,d.y=f.y+r.clientTop}const m=i&&!h&&!s?ld(i,l):vn(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+d.x+m.x,y:n.y*c.y-l.scrollTop*c.y+d.y+m.y}}function Iw(e){return Array.from(e.getClientRects())}function Nw(e){const t=wn(e),n=ss(e),r=e.ownerDocument.body,o=Xt(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Xt(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+is(e);const a=-n.scrollTop;return un(r).direction==="rtl"&&(i+=Xt(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const cd=25;function Aw(e,t){const n=Jt(e),r=wn(e),o=n.visualViewport;let s=r.clientWidth,i=r.clientHeight,a=0,l=0;if(o){s=o.width,i=o.height;const d=Zi();(!d||d&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}const c=is(r);if(c<=0){const d=r.ownerDocument,h=d.body,m=getComputedStyle(h),f=d.compatMode==="CSS1Compat"&&parseFloat(m.marginLeft)+parseFloat(m.marginRight)||0,v=Math.abs(r.clientWidth-h.clientWidth-f);v<=cd&&(s-=v)}else c<=cd&&(s+=c);return{width:s,height:i,x:a,y:l}}const jw=new Set(["absolute","fixed"]);function Pw(e,t){const n=er(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=yn(e)?kr(e):vn(1),i=e.clientWidth*s.x,a=e.clientHeight*s.y,l=o*s.x,c=r*s.y;return{width:i,height:a,x:l,y:c}}function ud(e,t,n){let r;if(t==="viewport")r=Aw(e,n);else if(t==="document")r=Nw(wn(e));else if(cn(t))r=Pw(t,n);else{const o=ad(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return ns(r)}function dd(e,t){const n=Fn(e);return n===t||!cn(n)||Tr(n)?!1:un(n).position==="fixed"||dd(n,t)}function _w(e,t){const n=t.get(e);if(n)return n;let r=oo(e,[],!1).filter(a=>cn(a)&&Cr(a)!=="body"),o=null;const s=un(e).position==="fixed";let i=s?Fn(e):e;for(;cn(i)&&!Tr(i);){const a=un(i),l=Ji(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&jw.has(o.position)||ro(i)&&!l&&dd(e,i))?r=r.filter(d=>d!==i):o=a,i=Fn(i)}return t.set(e,r),r}function Rw(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?os(t)?[]:_w(t,this._c):[].concat(n),r],a=i[0],l=i.reduce((c,d)=>{const h=ud(t,d,o);return c.top=Xt(h.top,c.top),c.right=$n(h.right,c.right),c.bottom=$n(h.bottom,c.bottom),c.left=Xt(h.left,c.left),c},ud(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function Mw(e){const{width:t,height:n}=id(e);return{width:t,height:n}}function Ow(e,t,n){const r=yn(t),o=wn(t),s=n==="fixed",i=er(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=vn(0);function c(){l.x=is(o)}if(r||!r&&!s)if((Cr(t)!=="body"||ro(o))&&(a=ss(t)),r){const f=er(t,!0,s,t);l.x=f.x+t.clientLeft,l.y=f.y+t.clientTop}else o&&c();s&&!r&&o&&c();const d=o&&!r&&!s?ld(o,a):vn(0),h=i.left+a.scrollLeft-l.x-d.x,m=i.top+a.scrollTop-l.y-d.y;return{x:h,y:m,width:i.width,height:i.height}}function ta(e){return un(e).position==="static"}function fd(e,t){if(!yn(e)||un(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return wn(e)===n&&(n=n.ownerDocument.body),n}function hd(e,t){const n=Jt(e);if(os(e))return n;if(!yn(e)){let o=Fn(e);for(;o&&!Tr(o);){if(cn(o)&&!ta(o))return o;o=Fn(o)}return n}let r=fd(e,t);for(;r&&xw(r)&&ta(r);)r=fd(r,t);return r&&Tr(r)&&ta(r)&&!Ji(r)?n:r||Sw(e)||n}const Dw=async function(e){const t=this.getOffsetParent||hd,n=this.getDimensions,r=await n(e.floating);return{reference:Ow(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Lw(e){return un(e).direction==="rtl"}const $w={convertOffsetParentRelativeRectToViewportRelativeRect:Ew,getDocumentElement:wn,getClippingRect:Rw,getOffsetParent:hd,getElementRects:Dw,getClientRects:Iw,getDimensions:Mw,getScale:kr,isElement:cn,isRTL:Lw};function pd(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Fw(e,t){let n=null,r;const o=wn(e);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),s();const c=e.getBoundingClientRect(),{left:d,top:h,width:m,height:f}=c;if(a||t(),!m||!f)return;const v=es(h),g=es(o.clientWidth-(d+m)),x=es(o.clientHeight-(h+f)),y=es(d),S={rootMargin:-v+"px "+-g+"px "+-x+"px "+-y+"px",threshold:Xt(0,$n(1,l))||1};let k=!0;function C(T){const E=T[0].intersectionRatio;if(E!==l){if(!k)return i();E?i(!1,E):r=setTimeout(()=>{i(!1,1e-7)},1e3)}E===1&&!pd(c,e.getBoundingClientRect())&&i(),k=!1}try{n=new IntersectionObserver(C,{...S,root:o.ownerDocument})}catch{n=new IntersectionObserver(C,S)}n.observe(e)}return i(!0),s}function Bw(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,c=ea(e),d=o||s?[...c?oo(c):[],...oo(t)]:[];d.forEach(y=>{o&&y.addEventListener("scroll",n,{passive:!0}),s&&y.addEventListener("resize",n)});const h=c&&a?Fw(c,n):null;let m=-1,f=null;i&&(f=new ResizeObserver(y=>{let[w]=y;w&&w.target===c&&f&&(f.unobserve(t),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var S;(S=f)==null||S.observe(t)})),n()}),c&&!l&&f.observe(c),f.observe(t));let v,g=l?er(e):null;l&&x();function x(){const y=er(e);g&&!pd(g,y)&&n(),g=y,v=requestAnimationFrame(x)}return n(),()=>{var y;d.forEach(w=>{o&&w.removeEventListener("scroll",n),s&&w.removeEventListener("resize",n)}),h==null||h(),(y=f)==null||y.disconnect(),f=null,l&&cancelAnimationFrame(v)}}const zw=dw,Hw=fw,Uw=lw,Ww=pw,Vw=cw,md=aw,Kw=hw,qw=(e,t,n)=>{const r=new Map,o={platform:$w,...n},s={...o.platform,_c:r};return iw(e,t,{...o,platform:s})};var Gw=typeof document<"u",Yw=function(){},as=Gw?b.useLayoutEffect:Yw;function ls(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!ls(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){const s=o[r];if(!(s==="_owner"&&e.$$typeof)&&!ls(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function gd(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function xd(e,t){const n=gd(e);return Math.round(t*n)/n}function na(e){const t=p.useRef(e);return as(()=>{t.current=e}),t}function Xw(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:i}={},transform:a=!0,whileElementsMounted:l,open:c}=e,[d,h]=p.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[m,f]=p.useState(r);ls(m,r)||f(r);const[v,g]=p.useState(null),[x,y]=p.useState(null),w=p.useCallback(R=>{R!==T.current&&(T.current=R,g(R))},[]),S=p.useCallback(R=>{R!==E.current&&(E.current=R,y(R))},[]),k=s||v,C=i||x,T=p.useRef(null),E=p.useRef(null),j=p.useRef(d),P=l!=null,D=na(l),F=na(o),W=na(c),G=p.useCallback(()=>{if(!T.current||!E.current)return;const R={placement:t,strategy:n,middleware:m};F.current&&(R.platform=F.current),qw(T.current,E.current,R).then(I=>{const H={...I,isPositioned:W.current!==!1};A.current&&!ls(j.current,H)&&(j.current=H,Hr.flushSync(()=>{h(H)}))})},[m,t,n,F,W]);as(()=>{c===!1&&j.current.isPositioned&&(j.current.isPositioned=!1,h(R=>({...R,isPositioned:!1})))},[c]);const A=p.useRef(!1);as(()=>(A.current=!0,()=>{A.current=!1}),[]),as(()=>{if(k&&(T.current=k),C&&(E.current=C),k&&C){if(D.current)return D.current(k,C,G);G()}},[k,C,G,D,P]);const X=p.useMemo(()=>({reference:T,floating:E,setReference:w,setFloating:S}),[w,S]),q=p.useMemo(()=>({reference:k,floating:C}),[k,C]),B=p.useMemo(()=>{const R={position:n,left:0,top:0};if(!q.floating)return R;const I=xd(q.floating,d.x),H=xd(q.floating,d.y);return a?{...R,transform:"translate("+I+"px, "+H+"px)",...gd(q.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:I,top:H}},[n,a,q.floating,d.x,d.y]);return p.useMemo(()=>({...d,update:G,refs:X,elements:q,floatingStyles:B}),[d,G,X,q,B])}const Jw=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:o}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?md({element:r.current,padding:o}).fn(n):{}:r?md({element:r,padding:o}).fn(n):{}}}},Zw=(e,t)=>({...zw(e),options:[e,t]}),Qw=(e,t)=>({...Hw(e),options:[e,t]}),ey=(e,t)=>({...Kw(e),options:[e,t]}),ty=(e,t)=>({...Uw(e),options:[e,t]}),ny=(e,t)=>({...Ww(e),options:[e,t]}),ry=(e,t)=>({...Vw(e),options:[e,t]}),oy=(e,t)=>({...Jw(e),options:[e,t]});var sy="Arrow",vd=p.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return u.jsx(ge.svg,{...s,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:u.jsx("polygon",{points:"0,0 30,0 15,10"})})});vd.displayName=sy;var iy=vd;function bd(e){const[t,n]=p.useState(void 0);return Tt(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const s=o[0];let i,a;if("borderBoxSize"in s){const l=s.borderBoxSize,c=Array.isArray(l)?l[0]:l;i=c.inlineSize,a=c.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var ra="Popper",[wd,Er]=ln(ra),[ay,yd]=wd(ra),Sd=e=>{const{__scopePopper:t,children:n}=e,[r,o]=p.useState(null);return u.jsx(ay,{scope:t,anchor:r,onAnchorChange:o,children:n})};Sd.displayName=ra;var Cd="PopperAnchor",Td=p.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=yd(Cd,n),i=p.useRef(null),a=Oe(t,i),l=p.useRef(null);return p.useEffect(()=>{const c=l.current;l.current=(r==null?void 0:r.current)||i.current,c!==l.current&&s.onAnchorChange(l.current)}),r?null:u.jsx(ge.div,{...o,ref:a})});Td.displayName=Cd;var oa="PopperContent",[ly,cy]=wd(oa),kd=p.forwardRef((e,t)=>{var z,$,ee,J,K,Q;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:a=0,avoidCollisions:l=!0,collisionBoundary:c=[],collisionPadding:d=0,sticky:h="partial",hideWhenDetached:m=!1,updatePositionStrategy:f="optimized",onPlaced:v,...g}=e,x=yd(oa,n),[y,w]=p.useState(null),S=Oe(t,pe=>w(pe)),[k,C]=p.useState(null),T=bd(k),E=(T==null?void 0:T.width)??0,j=(T==null?void 0:T.height)??0,P=r+(s!=="center"?"-"+s:""),D=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},F=Array.isArray(c)?c:[c],W=F.length>0,G={padding:D,boundary:F.filter(dy),altBoundary:W},{refs:A,floatingStyles:X,placement:q,isPositioned:B,middlewareData:R}=Xw({strategy:"fixed",placement:P,whileElementsMounted:(...pe)=>Bw(...pe,{animationFrame:f==="always"}),elements:{reference:x.anchor},middleware:[Zw({mainAxis:o+j,alignmentAxis:i}),l&&Qw({mainAxis:!0,crossAxis:!1,limiter:h==="partial"?ey():void 0,...G}),l&&ty({...G}),ny({...G,apply:({elements:pe,rects:de,availableWidth:me,availableHeight:we})=>{const{width:Te,height:Ne}=de.reference,ke=pe.floating.style;ke.setProperty("--radix-popper-available-width",`${me}px`),ke.setProperty("--radix-popper-available-height",`${we}px`),ke.setProperty("--radix-popper-anchor-width",`${Te}px`),ke.setProperty("--radix-popper-anchor-height",`${Ne}px`)}}),k&&oy({element:k,padding:a}),fy({arrowWidth:E,arrowHeight:j}),m&&ry({strategy:"referenceHidden",...G})]}),[I,H]=Nd(q),Y=ft(v);Tt(()=>{B&&(Y==null||Y())},[B,Y]);const _=(z=R.arrow)==null?void 0:z.x,O=($=R.arrow)==null?void 0:$.y,M=((ee=R.arrow)==null?void 0:ee.centerOffset)!==0,[L,te]=p.useState();return Tt(()=>{y&&te(window.getComputedStyle(y).zIndex)},[y]),u.jsx("div",{ref:A.setFloating,"data-radix-popper-content-wrapper":"",style:{...X,transform:B?X.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:L,"--radix-popper-transform-origin":[(J=R.transformOrigin)==null?void 0:J.x,(K=R.transformOrigin)==null?void 0:K.y].join(" "),...((Q=R.hide)==null?void 0:Q.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:u.jsx(ly,{scope:n,placedSide:I,onArrowChange:C,arrowX:_,arrowY:O,shouldHideArrow:M,children:u.jsx(ge.div,{"data-side":I,"data-align":H,...g,ref:S,style:{...g.style,animation:B?void 0:"none"}})})})});kd.displayName=oa;var Ed="PopperArrow",uy={top:"bottom",right:"left",bottom:"top",left:"right"},Id=p.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=cy(Ed,r),i=uy[s.placedSide];return u.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:u.jsx(iy,{...o,ref:n,style:{...o.style,display:"block"}})})});Id.displayName=Ed;function dy(e){return e!==null}var fy=e=>({name:"transformOrigin",options:e,fn(t){var x,y,w;const{placement:n,rects:r,middlewareData:o}=t,i=((x=o.arrow)==null?void 0:x.centerOffset)!==0,a=i?0:e.arrowWidth,l=i?0:e.arrowHeight,[c,d]=Nd(n),h={start:"0%",center:"50%",end:"100%"}[d],m=(((y=o.arrow)==null?void 0:y.x)??0)+a/2,f=(((w=o.arrow)==null?void 0:w.y)??0)+l/2;let v="",g="";return c==="bottom"?(v=i?h:`${m}px`,g=`${-l}px`):c==="top"?(v=i?h:`${m}px`,g=`${r.floating.height+l}px`):c==="right"?(v=`${-l}px`,g=i?h:`${f}px`):c==="left"&&(v=`${r.floating.width+l}px`,g=i?h:`${f}px`),{data:{x:v,y:g}}}});function Nd(e){const[t,n="center"]=e.split("-");return[t,n]}var sa=Sd,ia=Td,aa=kd,la=Id,hy="Portal",so=p.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=p.useState(!1);Tt(()=>s(!0),[]);const i=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?Ro.createPortal(u.jsx(ge.div,{...r,ref:t}),i):null});so.displayName=hy;function py(e,t){return p.useReducer((n,r)=>t[n][r]??n,e)}var zt=e=>{const{present:t,children:n}=e,r=my(t),o=typeof n=="function"?n({present:r.isPresent}):p.Children.only(n),s=Oe(r.ref,gy(o));return typeof n=="function"||r.isPresent?p.cloneElement(o,{ref:s}):null};zt.displayName="Presence";function my(e){const[t,n]=p.useState(),r=p.useRef(null),o=p.useRef(e),s=p.useRef("none"),i=e?"mounted":"unmounted",[a,l]=py(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return p.useEffect(()=>{const c=cs(r.current);s.current=a==="mounted"?c:"none"},[a]),Tt(()=>{const c=r.current,d=o.current;if(d!==e){const m=s.current,f=cs(c);e?l("MOUNT"):f==="none"||(c==null?void 0:c.display)==="none"?l("UNMOUNT"):l(d&&m!==f?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,l]),Tt(()=>{if(t){let c;const d=t.ownerDocument.defaultView??window,h=f=>{const g=cs(r.current).includes(CSS.escape(f.animationName));if(f.target===t&&g&&(l("ANIMATION_END"),!o.current)){const x=t.style.animationFillMode;t.style.animationFillMode="forwards",c=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=x)})}},m=f=>{f.target===t&&(s.current=cs(r.current))};return t.addEventListener("animationstart",m),t.addEventListener("animationcancel",h),t.addEventListener("animationend",h),()=>{d.clearTimeout(c),t.removeEventListener("animationstart",m),t.removeEventListener("animationcancel",h),t.removeEventListener("animationend",h)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:p.useCallback(c=>{r.current=c?getComputedStyle(c):null,n(c)},[])}}function cs(e){return(e==null?void 0:e.animationName)||"none"}function gy(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var ca="rovingFocusGroup.onEntryFocus",xy={bubbles:!1,cancelable:!0},io="RovingFocusGroup",[ua,Ad,vy]=Xo(io),[by,jd]=ln(io,[vy]),[wy,yy]=by(io),Pd=p.forwardRef((e,t)=>u.jsx(ua.Provider,{scope:e.__scopeRovingFocusGroup,children:u.jsx(ua.Slot,{scope:e.__scopeRovingFocusGroup,children:u.jsx(Sy,{...e,ref:t})})}));Pd.displayName=io;var Sy=p.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:c,preventScrollOnEntryFocus:d=!1,...h}=e,m=p.useRef(null),f=Oe(t,m),v=Jo(s),[g,x]=Dn({prop:i,defaultProp:a??null,onChange:l,caller:io}),[y,w]=p.useState(!1),S=ft(c),k=Ad(n),C=p.useRef(!1),[T,E]=p.useState(0);return p.useEffect(()=>{const j=m.current;if(j)return j.addEventListener(ca,S),()=>j.removeEventListener(ca,S)},[S]),u.jsx(wy,{scope:n,orientation:r,dir:v,loop:o,currentTabStopId:g,onItemFocus:p.useCallback(j=>x(j),[x]),onItemShiftTab:p.useCallback(()=>w(!0),[]),onFocusableItemAdd:p.useCallback(()=>E(j=>j+1),[]),onFocusableItemRemove:p.useCallback(()=>E(j=>j-1),[]),children:u.jsx(ge.div,{tabIndex:y||T===0?-1:0,"data-orientation":r,...h,ref:f,style:{outline:"none",...e.style},onMouseDown:ie(e.onMouseDown,()=>{C.current=!0}),onFocus:ie(e.onFocus,j=>{const P=!C.current;if(j.target===j.currentTarget&&P&&!y){const D=new CustomEvent(ca,xy);if(j.currentTarget.dispatchEvent(D),!D.defaultPrevented){const F=k().filter(q=>q.focusable),W=F.find(q=>q.active),G=F.find(q=>q.id===g),X=[W,G,...F].filter(Boolean).map(q=>q.ref.current);Md(X,d)}}C.current=!1}),onBlur:ie(e.onBlur,()=>w(!1))})})}),_d="RovingFocusGroupItem",Rd=p.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,l=Pt(),c=s||l,d=yy(_d,n),h=d.currentTabStopId===c,m=Ad(n),{onFocusableItemAdd:f,onFocusableItemRemove:v,currentTabStopId:g}=d;return p.useEffect(()=>{if(r)return f(),()=>v()},[r,f,v]),u.jsx(ua.ItemSlot,{scope:n,id:c,focusable:r,active:o,children:u.jsx(ge.span,{tabIndex:h?0:-1,"data-orientation":d.orientation,...a,ref:t,onMouseDown:ie(e.onMouseDown,x=>{r?d.onItemFocus(c):x.preventDefault()}),onFocus:ie(e.onFocus,()=>d.onItemFocus(c)),onKeyDown:ie(e.onKeyDown,x=>{if(x.key==="Tab"&&x.shiftKey){d.onItemShiftTab();return}if(x.target!==x.currentTarget)return;const y=ky(x,d.orientation,d.dir);if(y!==void 0){if(x.metaKey||x.ctrlKey||x.altKey||x.shiftKey)return;x.preventDefault();let S=m().filter(k=>k.focusable).map(k=>k.ref.current);if(y==="last")S.reverse();else if(y==="prev"||y==="next"){y==="prev"&&S.reverse();const k=S.indexOf(x.currentTarget);S=d.loop?Ey(S,k+1):S.slice(k+1)}setTimeout(()=>Md(S))}}),children:typeof i=="function"?i({isCurrentTabStop:h,hasTabStop:g!=null}):i})})});Rd.displayName=_d;var Cy={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Ty(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function ky(e,t,n){const r=Ty(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return Cy[r]}function Md(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function Ey(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Iy=Pd,Ny=Rd,Ay=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Ir=new WeakMap,us=new WeakMap,ds={},da=0,Od=function(e){return e&&(e.host||Od(e.parentNode))},jy=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=Od(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},Py=function(e,t,n,r){var o=jy(t,Array.isArray(e)?e:[e]);ds[n]||(ds[n]=new WeakMap);var s=ds[n],i=[],a=new Set,l=new Set(o),c=function(h){!h||a.has(h)||(a.add(h),c(h.parentNode))};o.forEach(c);var d=function(h){!h||l.has(h)||Array.prototype.forEach.call(h.children,function(m){if(a.has(m))d(m);else try{var f=m.getAttribute(r),v=f!==null&&f!=="false",g=(Ir.get(m)||0)+1,x=(s.get(m)||0)+1;Ir.set(m,g),s.set(m,x),i.push(m),g===1&&v&&us.set(m,!0),x===1&&m.setAttribute(n,"true"),v||m.setAttribute(r,"true")}catch(y){console.error("aria-hidden: cannot operate on ",m,y)}})};return d(t),a.clear(),da++,function(){i.forEach(function(h){var m=Ir.get(h)-1,f=s.get(h)-1;Ir.set(h,m),s.set(h,f),m||(us.has(h)||h.removeAttribute(r),us.delete(h)),f||h.removeAttribute(n)}),da--,da||(Ir=new WeakMap,Ir=new WeakMap,us=new WeakMap,ds={})}},fa=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=Ay(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),Py(r,o,n,"aria-hidden")):function(){return null}},Sn=function(){return Sn=Object.assign||function(t){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])}return t},Sn.apply(this,arguments)};function Dd(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n}function _y(e,t,n){if(n||arguments.length===2)for(var r=0,o=t.length,s;r<o;r++)(s||!(r in t))&&(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return e.concat(s||Array.prototype.slice.call(t))}typeof SuppressedError=="function"&&SuppressedError;var fs="right-scroll-bar-position",hs="width-before-scroll-bar",Ry="with-scroll-bars-hidden",My="--removed-body-scroll-bar-size";function ha(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function Oy(e,t){var n=b.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var o=n.value;o!==r&&(n.value=r,n.callback(r,o))}}}})[0];return n.callback=t,n.facade}var Dy=typeof window<"u"?p.useLayoutEffect:p.useEffect,Ld=new WeakMap;function Ly(e,t){var n=Oy(null,function(r){return e.forEach(function(o){return ha(o,r)})});return Dy(function(){var r=Ld.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||ha(a,null)}),s.forEach(function(a){o.has(a)||ha(a,i)})}Ld.set(n,e)},[e]),n}function $y(e){return e}function Fy(e,t){t===void 0&&(t=$y);var n=[],r=!1,o={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(s){var i=t(s,r);return n.push(i),function(){n=n.filter(function(a){return a!==i})}},assignSyncMedium:function(s){for(r=!0;n.length;){var i=n;n=[],i.forEach(s)}n={push:function(a){return s(a)},filter:function(){return n}}},assignMedium:function(s){r=!0;var i=[];if(n.length){var a=n;n=[],a.forEach(s),i=n}var l=function(){var d=i;i=[],d.forEach(s)},c=function(){return Promise.resolve().then(l)};c(),n={push:function(d){i.push(d),c()},filter:function(d){return i=i.filter(d),n}}}};return o}function By(e){e===void 0&&(e={});var t=Fy(null);return t.options=Sn({async:!0,ssr:!1},e),t}var $d=function(e){var t=e.sideCar,n=Dd(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return p.createElement(r,Sn({},n))};$d.isSideCarExport=!0;function zy(e,t){return e.useMedium(t),$d}var Fd=By(),pa=function(){},ps=p.forwardRef(function(e,t){var n=p.useRef(null),r=p.useState({onScrollCapture:pa,onWheelCapture:pa,onTouchMoveCapture:pa}),o=r[0],s=r[1],i=e.forwardProps,a=e.children,l=e.className,c=e.removeScrollBar,d=e.enabled,h=e.shards,m=e.sideCar,f=e.noRelative,v=e.noIsolation,g=e.inert,x=e.allowPinchZoom,y=e.as,w=y===void 0?"div":y,S=e.gapMode,k=Dd(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=m,T=Ly([n,t]),E=Sn(Sn({},k),o);return p.createElement(p.Fragment,null,d&&p.createElement(C,{sideCar:Fd,removeScrollBar:c,shards:h,noRelative:f,noIsolation:v,inert:g,setCallbacks:s,allowPinchZoom:!!x,lockRef:n,gapMode:S}),i?p.cloneElement(p.Children.only(a),Sn(Sn({},E),{ref:T})):p.createElement(w,Sn({},E,{className:l,ref:T}),a))});ps.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},ps.classNames={fullWidth:hs,zeroRight:fs};var Hy=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Uy(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Hy();return t&&e.setAttribute("nonce",t),e}function Wy(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Vy(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var Ky=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Uy())&&(Wy(t,n),Vy(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},qy=function(){var e=Ky();return function(t,n){p.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Bd=function(){var e=qy(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},Gy={left:0,top:0,right:0,gap:0},ma=function(e){return parseInt(e||"",10)||0},Yy=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],o=t[e==="padding"?"paddingRight":"marginRight"];return[ma(n),ma(r),ma(o)]},Xy=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Gy;var t=Yy(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},Jy=Bd(),Nr="data-scroll-locked",Zy=function(e,t,n,r){var o=e.left,s=e.top,i=e.right,a=e.gap;return n===void 0&&(n="margin"),`
|
|
40
|
-
.`.concat(
|
|
37
|
+
`))>=0;){const pe=it.slice(0,ve);it=it.slice(ve+2);const ye=pe.split(/\r?\n/),Oe=[];for(const Qe of ye)if(!(!Qe||Qe.startsWith(":"))&&Qe.startsWith("data:")){const ut=Qe.slice(5);Oe.push(ut.startsWith(" ")?ut.slice(1):ut)}const Ke=Oe.join(`
|
|
38
|
+
`);if(!Ke)continue;let lt;try{lt=JSON.parse(Ke)}catch{console.debug("[use-chat] malformed SSE:",Ke.slice(0,200));continue}const ct=xu(lt)?lt.data:lt;if(!ct){console.warn("[use-chat] dropped envelope event without payload",lt);continue}const Re=ct;At=Date.now();const mt=Re.seq;if(mt!==void 0){if(mt<=Ct){console.debug("[use-chat] drop duplicate/out-of-order event",{seq:mt,lastProcessedSeq:Ct,type:Re.type});continue}Ct>0&&mt>Ct+1&&((K=I==null?void 0:I.onGap)==null||K.call(I,{from:Ct,to:mt})),Ct=mt,E.current=mt,x(mt)}if(Re.type==="message.start"&&Re.role==="assistant"){const Qe=Su(Re.model);W.current={messageId:Re.id,lastSeq:mt??null,lastText:""},k({id:Re.id,role:"assistant",name:Qe??void 0,model:Re.model,createdAt:new Date().toISOString(),content:[]})}if(Re.type==="checkpoint")_.current=Re.checkpointId??null,D.current=Re.checkpointNs??null,b(Re.checkpointId??null);else if(Re.type==="state_history"){F.current=Re;try{const ut=Dn(Re).latest;ut&&(_.current=ut.checkpointId??null,D.current=ut.checkpointNs??null,b(ut.checkpointId??null))}catch(Qe){console.warn("[use-chat] Failed to hydrate state_history payload",Qe)}}try{R==null||R(Re)}catch(Qe){console.error("[use-chat] Error in onEvent callback:",Qe,"for event:",Re.type)}if(Re.type==="message.delta"){k(ut=>{const An=W.current;if(!ut||An.messageId!==ut.id)return ut;const{newParts:N,newMeta:oe,changed:le}=wu(ut.content??[],Re.delta,{lastSeq:An.lastSeq,lastText:An.lastText},mt??null);return le?(W.current={...An,lastSeq:oe.lastSeq??An.lastSeq,lastText:oe.lastText??An.lastText},{...ut,content:N}):ut});const Qe=Re.delta.filter(ut=>ut.type==="text").map(ut=>ut.text).join("");Qe&&e.autoAppendAssistant!==!1&&(St.push(Qe),sn())}else if(Re.type==="heartbeat"){console.debug("[use-chat] heartbeat received");try{(Q=I==null?void 0:I.onHeartbeat)==null||Q.call(I,Re)}catch(Qe){console.warn("[use-chat] heartbeat callback failed",Qe)}}else if(Tt!==null&&cancelAnimationFrame(Tt),Et(),Re.type==="checkpoint")b(Re.checkpointId);else if(Re.type==="error"){const Qe=Re;if(d(Qe.message),Y="error",P=Qe.message,Qe.error_type==="auth_error"||Qe.code==="TOKEN_EXPIRED"||((me=Qe.message)==null?void 0:me.includes("token"))||((de=Qe.message)==null?void 0:de.includes("401"))||((ge=Qe.message)==null?void 0:ge.includes("unauthorized"))||((we=Qe.message)==null?void 0:we.includes("Unauthorized"))){console.error("[use-chat] Auth error detected:",Qe.message);try{(Te=I==null?void 0:I.onAuthError)==null||Te.call(I,Qe.message)}catch(An){console.warn("[use-chat] onAuthError handler failed",An)}H.abort()}}}}Et(),Y===null&&!H.signal.aborted&&(Y="complete")}catch(Fe){if(Fe.name==="AbortError")Y=Y??"aborted";else{const Ve=Fe.message||String(Fe);Y="error",P=Ve,d(Ve),(Ne=I==null?void 0:I.onError)==null||Ne.call(I,Ve)}}finally{try{await Ze.cancel()}catch{}finally{(ke=Ze.releaseLock)==null||ke.call(Ze)}Tt!==null&&typeof window<"u"&&window.cancelAnimationFrame(Tt),clearInterval(Vt)}}catch(We){if(We.name==="AbortError")Y=Y??"aborted";else{const Le=We.message||String(We);Y="error",P=Le,d(Le),(st=I==null?void 0:I.onError)==null||st.call(I,Le),O||((vt=I==null?void 0:I.onConnectionError)==null||vt.call(I,Le),O=!0)}}finally{const We=E.current,Le=_.current,Ge=D.current,Me=F.current,$e=Y??(H.signal.aborted?"aborted":P?"error":"complete");try{(ht=I==null?void 0:I.onClosed)==null||ht.call(I,{reason:$e,lastSeq:We,lastCheckpointId:Le,lastCheckpointNs:Ge,lastStateHistory:Me,error:P})}catch(Ze){console.warn("[use-chat] onClosed callback failed",Ze)}l(!1),w(!1),C.current=null,E.current=0,x(0),j.current=null}})(),{close:()=>H.abort()}},[t,n,r,e.autoAppendAssistant]);return v.useEffect(()=>()=>{var B;T.current=!1,(B=C.current)==null||B.abort()},[]),{isStreaming:a,error:u,assistantText:f,assistantMessage:S,lastCheckpointId:p,lastSeq:g,connected:y,stream:q,stop:X,clear:A,setToken:G}}const Ab=["detail","message","error","description","title"];function Qo(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=Qo(t);if(n)return n}return null}if(typeof e=="object"){const t=e;for(const n of Ab){const r=Qo(t[n]);if(r)return r}if("errors"in t){const n=Qo(t.errors);if(n)return n}}return null}function jb(e){if(!e)return"Request failed";const t=e.response,n=Qo(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 Cu({api:e,initialThreadId:t=null,onError:n,onThreadChange:r,onCurrentThreadDeleted:o}){const[s,i]=v.useState([]),[a,l]=v.useState(t),[u,d]=v.useState(!1),[f,m]=v.useState(null),[p,b]=v.useState([]),[g,x]=v.useState(!1),[,y]=v.useState(null),[w,S]=v.useState(null),[k,C]=v.useState(!1),T=v.useRef(a),E=v.useRef(new Map);v.useEffect(()=>{T.current=a},[a]);const j=v.useCallback(async()=>{d(!0),m(null);try{const R=await e.listThreads();i(R??[])}catch(R){const I=String(R);m(I),n==null||n(I)}finally{d(!1)}},[e,n]),_=v.useCallback(async()=>{x(!0),y(null);try{const R=await e.listSharedThreads();b(R??[])}catch(R){const I=String(R);y(I),n==null||n(I)}finally{x(!1)}},[e,n]);v.useEffect(()=>{j()},[j]),v.useEffect(()=>{_()},[_]),v.useEffect(()=>{r==null||r(a)},[a,r]);const D=v.useCallback(async R=>{try{const I=await e.createThread(R);return l(I.threadId),await j(),I.threadId}catch(I){const H=String(I);return n==null||n(H),null}},[e,n,j]),F=v.useCallback(async R=>{const I=s;i(Y=>Y.filter(P=>P.threadId!==R));const H=new AbortController;E.current.set(R,H);try{await e.deleteThread(R),T.current===R&&(l(null),o==null||o())}catch(Y){i(I);const P=String(Y);n==null||n(P)}finally{E.current.delete(R)}},[e,o,n,s]),W=v.useCallback(async(R,I)=>{try{await e.updateThread(R,I),await j()}catch(H){n==null||n(String(H))}},[e,n,j]),G=v.useCallback(async(R,I)=>{C(!0),S("Sharing thread…");try{await e.shareThread(R,I),await _(),S("Shared successfully")}catch(H){const Y=jb(H);throw n==null||n(Y),S(`Failed to share: ${Y}`),new Error(Y)}finally{C(!1)}},[e,n,_]),A=v.useCallback(async(R,I)=>{try{await e.unshareThread(R,I),await _()}catch(H){const Y=String(H);throw n==null||n(Y),H}},[e,n,_]),X=v.useMemo(()=>({createThread:D,deleteThread:F,renameThread:W,refreshThreads:j,refreshSharedThreads:_,shareThread:G,unshareThread:A}),[D,F,W,j,_,G,A]),q=v.useCallback(R=>{if(!(R!=null&&R.threadId))return;const I={threadId:R.threadId,title:R.title||`Thread ${R.threadId.slice(0,8)}`,createdAt:R.createdAt||new Date().toISOString(),updatedAt:R.updatedAt||new Date().toISOString(),messageCount:R.messageCount??1};i(H=>{let Y=!1;const P=H.map(O=>O.threadId===I.threadId?(Y=!0,console.debug("[useThreadsState] thread_info: updating existing thread",I.threadId),{...O,title:I.title??O.title,updatedAt:I.updatedAt??O.updatedAt,messageCount:I.messageCount??O.messageCount}):O);return Y?P:(console.debug("[useThreadsState] thread_info: adding thread to list",I.threadId),[I,...H])})},[]),B=v.useCallback(()=>S(null),[]);return{threads:s,currentThreadId:a,currentThreadIdRef:T,setCurrentThreadId:l,isLoadingThreads:u,threadsError:f,sharedThreads:p,isLoadingSharedThreads:g,actions:X,addThreadFromEvent:q,shareInFlight:k,shareStatus:w,clearShareStatus:B}}const Tu=v.createContext(null);function ku({children:e,initialThreadId:t=null,onError:n,onThreadChange:r}){const{api:o}=Zr(),{threads:s,currentThreadId:i,setCurrentThreadId:a,currentThreadIdRef:l,isLoadingThreads:u,threadsError:d,sharedThreads:f,isLoadingSharedThreads:m,actions:p,addThreadFromEvent:b,shareInFlight:g,shareStatus:x,clearShareStatus:y}=Cu({api:o,initialThreadId:t,onError:n,onThreadChange:r}),w=v.useMemo(()=>({threads:s,currentThreadId:i,setCurrentThreadId:a,currentThreadIdRef:l,isLoading:u,error:d,sharedThreads:f,isLoadingSharedThreads:m,actions:p,shareInFlight:g,shareStatus:x,clearShareStatus:y,addThreadFromEvent:b}),[s,i,a,l,u,d,f,m,p,g,x,y,b]);return c.jsx(Tu.Provider,{value:w,children:e})}function vr(){const e=v.useContext(Tu);if(!e)throw new Error("useThreads must be used within a ThreadsProvider");return e}function eo(e){const t=e==null?void 0:e.trim();if(!t||!(t.startsWith("{")||t.startsWith("[")))return null;try{return JSON.parse(t)}catch{return null}}function Eu(e){return!!(e&&typeof e=="object"&&(e.type==="file"||e.mimeType||e.filename||e.sourceType==="base64"))}function to(e){if(typeof e=="string")return e;if(e&&typeof e=="object"){if(Array.isArray(e)){const n=e.map(to).filter(r=>r!==void 0);if(!n.length){console.debug("[message-utils] sanitizeForDisplay - array emptied -> returning undefined",{originalLength:e.length});return}return n}if(Eu(e)){try{console.debug("[message-utils] sanitizeForDisplay - dropping file-like object",{sampleFilename:e&&(e.filename||e.name)?e.filename||e.name:void 0,keys:Object.keys(e||{})})}catch(n){console.debug("[message-utils] sanitizeForDisplay - dropped file-like (unable to inspect)",{err:String(n)})}return}const t={};for(const n of Object.keys(e)){const r=e[n];if(n==="data"&&typeof r=="string"&&r.length>100)t[n]=`[base64 ${r.length} chars omitted]`;else{const o=to(r);o!==void 0&&(t[n]=o)}}if(Object.keys(t).length)return t;try{console.debug("[message-utils] sanitizeForDisplay - object emptied -> returning undefined",{originalKeys:Object.keys(e||{})})}catch(n){console.debug("[message-utils] sanitizeForDisplay - object emptied -> returning undefined (inspect failed)",{err:String(n)})}return}return e}function br(e){if(typeof e=="string")return e;if(Eu(e))return"";try{const t=to(e);return t===void 0?"":typeof t=="string"?t:JSON.stringify(t,null,2)}catch{return""}}function _b(e){return typeof e!="string"?!1:/^[\s\n]*[-*]\s|^[\s\n]*#+\s|```|^\s*\[.*\]\(|^>\s/.test(e)}function Pb(e){const t=br(e);return typeof e=="string"&&_b(e)?{content:e,isMarkdown:!0}:{content:t,isMarkdown:!1}}function wr(e){if(e==null)return e;if(typeof e=="string"){const t=e.trim();if(t.startsWith("{")||t.startsWith("[")){const n=eo(t);if(n!==null)return wr(n)}return e}return typeof e=="object"&&!Array.isArray(e)&&e.content!==void 0?wr(e.content):e}function Rb(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function zi(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 es(e){if(e==null)return null;const t=String(e).trim();return t.length>0?t:null}function Mb(e){const t=r=>{try{const o=to(r);return typeof o=="string"?o:JSON.stringify(o??"")}catch{return""}},n=e.filter(r=>r.type==="text");return n.length?t(n.map(r=>r.text).join(`
|
|
39
|
+
`)):t(e)}function Ob(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function Iu(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 Db(e){if(!e)return"image/png";const t=e.trim();return t?t.includes("/")?t:`image/${t}`:"image/png"}function Lb(e){const t=[],n=r=>{r&&r.trim()&&t.push(r.trim())};return e&&(n(e.plotId),n(e.artifactId)),t}function $b({base64:e,url:t,formatHint:n,extras:r}){const o=typeof e=="string"&&e.length>0,s=Db(n),i=o?`data:${s};base64,${e}`:t,a=Lb(r),l=a.length?a.join(" / "):void 0,u=l?`${l} artifact`:"artifact image";return{src:i,alt:u,label:l}}function Fb(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 $b({base64:t,url:n,formatHint:r,extras:{plotId:e.plotId,artifactId:e.artifactId}})}function Nu(e){var n;const t=(n=e.additionalKwargs)==null?void 0:n.toolProgress;return Array.isArray(t)?t:[]}const Bb={messages:[],assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,messagesStreamMeta:{},pendingInterrupt:null};function zb(e,t){var n;switch(t.type){case"reset":return{messages:Bi(((n=t.payload)==null?void 0:n.messages)??[]),assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,pendingInterrupt:null,messagesStreamMeta:{}};case"user_message":{const{message:r,editingMessageId:o}=t.payload;if(o){const s=e.messages.findIndex(i=>i.id===o);if(s>=0){const i=e.messages.slice(0,s);return{...e,messages:[...i,r]}}}return{...e,messages:[...e.messages,r]}}case"seed":{const r=Bi(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=Bi(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 Au(e,t.payload.ev);case"batch":{const{events:r}=t.payload;return r.length?r.reduce((o,s)=>Au(o,s),e):e}default:return e}}function Hb(e=[]){const[t,n]=v.useReducer(zb,{...Bb,messages:e}),r=v.useRef([]),o=v.useRef(null),s=v.useRef(null),i=v.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=v.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=v.useCallback(d=>{r.current.push(d),a()},[a]);v.useEffect(()=>()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),r.current=[]},[]);const u=v.useMemo(()=>({reset:d=>n({type:"reset",payload:{messages:d}}),seed:(d,f)=>n({type:"seed",payload:{messages:d,...f??{}}}),prepend:d=>n({type:"prepend",payload:{messages:d}}),pushUser:(d,f)=>n({type:"user_message",payload:{message:d,editingMessageId:f}}),onEvent:l}),[l]);return{state:t,dispatch:n,...u}}function Au(e,t){var n,r,o;if(t.type==="message.start"&&t.role==="assistant"){const s=t.id,i=Su(t.model);if(e.messages.some(u=>u.id===s)){const u=e.messagesStreamMeta??{},d={...u,[s]:u[s]??{lastSeq:t.seq??null,lastText:""}};return{...e,assemblingId:s,messagesStreamMeta:d}}const l={id:s,role:"assistant",name:i||void 0,model:t.model,createdAt:new Date().toISOString(),content:[]};return{...e,assemblingId:s,messages:[...e.messages,l]}}if(t.type==="tool.start")return Wb(e,t);if(t.type==="tool.progress")return Vb(e,t);if(t.type==="tool.end")return Kb(e,t);if(t.type==="message.delta"){const s=e.assemblingId??vu(e.messages);if(!s)return e;const i=e.messages,a=i.findIndex(C=>C.id===s&&C.role==="assistant");if(a===-1)return e;const l=i[a],u=e.messagesStreamMeta,d=u??{},f=d[s],m=f??{lastSeq:null,lastText:bu(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:b,newMeta:g,changed:x}=wu(l.content,t.delta,m,p);if(!x)return e;const y={...l,content:b},w=Qr(i,a,y),S=!f||f.lastSeq!==g.lastSeq||f.lastText!==g.lastText,k=S?{...d,[s]:g}:u;return S?{...e,messages:w,messagesStreamMeta:k}:{...e,messages:w}}if(t.type==="message.end"){const s=e.assemblingId??vu(e.messages);if(!s)return{...e,assemblingId:null};const i=e.messages,a=i.findIndex(l=>l.id===s&&l.role==="assistant");if(a>=0){const l=i[a];if(!((n=l.content)==null?void 0:n.some(d=>{var f;return(d==null?void 0:d.type)==="text"&&((f=d.text)==null?void 0:f.trim())}))){console.debug("[MessageReducer] pruning assistant message with no visible text",{id:l.id,contentTypes:(r=l.content)==null?void 0:r.map(f=>f==null?void 0:f.type),contentPreview:(o=l.content)==null?void 0:o.map(f=>(f==null?void 0:f.type)==="text"?String(f.text).slice(0,100):f==null?void 0:f.type)});const d=[...i.slice(0,a),...i.slice(a+1)];return{...e,assemblingId:null,messages:d}}}return e}if(t.type==="checkpoint"){const s=t.checkpointNs??e.lastCheckpointNs??null,i=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=Dn(t),i=s.interrupt,a=s.latest,l=i===null?kb(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 Hi(e){return e.call_id??e.id??null}function ju(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 Ui(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||zi(r).toolCallId===t)return n}return-1}function Ub(e){if(e==null)return[];const t=wr(e);if(typeof t=="string"&&t.trim())return[{type:"text",text:t}];const n=br(t??e);return n?[{type:"text",text:n}]:[]}function Pu(e,t){const n=e.additionalKwargs??{},r=Array.isArray(n.toolProgress)?[...n.toolProgress]:[],o={...n,toolProgress:[...r,t]};return{...e,additionalKwargs:o}}function Wb(e,t){const n=Hi(t),r=Ui(e.messages,n),o=t.name??t.tool??void 0,s=ju(t);if(r>=0){const a=e.messages[r],u={...a.additionalKwargs??{},toolStreaming:!0,toolProgress:[]},d={...a,name:o??a.name,additionalKwargs:u};return{...e,messages:Qr(e.messages,r,d)}}const i=_u(s,n,o,t.args);return{...e,messages:[...e.messages,i]}}function Vb(e,t){const n=Hi(t);if(!n)return e;const r=Ui(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=Pu(e.messages[r],o);return{...e,messages:Qr(e.messages,r,a)}}function Kb(e,t){const n=Hi(t),r=ju(t);let o=e.messages,s=Ui(o,n);if(s===-1){const b=t.name??t.tool??void 0;o=[...o,_u(r,n,b,{})],s=o.length-1}const i=o[s],a=t.output??t.error??null,l=Ub(a),u=[...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=Pu(i,d),m=t.artifact??i.artifact,p={...f,name:t.name??t.tool??i.name,content:u,artifact:m,additionalKwargs:{...f.additionalKwargs??{},toolStreaming:!1}};return{...e,messages:Qr(o,s,p)}}function Ru({api:e,seed:t,prepend:n,onError:r,currentThreadId:o,initialThreadId:s=null,initialCheckpointId:i=null,initialCheckpointNs:a=null,autoLoadInitial:l=!0,isStreaming:u,getMessages:d}){const[f,m]=v.useState(null),b=v.useMemo(()=>Dn(f),[f]).checkpoints,g=hc(b),x=g.timeline,[y,w]=v.useState(!1),[S,k]=v.useState(null),[C,T]=v.useState(!1),[E,j]=v.useState(!1),[_,D]=v.useState(!1),[F,W]=v.useState(null),G=v.useRef(o),A=v.useRef(null),X=v.useRef(null),q=v.useRef(null),B=v.useRef(null),R=v.useRef(null),I=v.useRef(new Map);v.useEffect(()=>{G.current=o},[o]);const H=v.useCallback(async K=>{var me,de;if(!K.threadId)return;const Q=K.threadId;(me=K.onStart)==null||me.call(K),K.setLoading(!0);try{await K.action(Q)}catch(ge){if(G.current===Q){const we=String(ge);(de=K.handleError)==null||de.call(K,we),r==null||r(we)}throw ge}finally{K.setLoading(!1)}},[r]),Y=v.useCallback(async(K,Q)=>{if(!K)return;const me=`${K}:${Q??"latest"}`,de=I.current.get(me);if(de)return de;const ge=H({threadId:K,setLoading:T,onStart:()=>W(null),handleError:we=>W(we),action:async we=>{const Te=await e.getStateHistory({threadId:we,checkpointId:Q??void 0});if(G.current!==we){console.log(`[useThreadHistoryState] Thread changed during load (was ${we}, now ${G.current}), discarding stale data`);return}const{checkpoints:Ne}=Dn(Te),ke=Ne.find(st=>st.messages&&st.messages.length>0)??(Q?Ne.find(st=>st.checkpointId===Q):null)??Ne[0];t((ke==null?void 0:ke.messages)??[],{checkpointId:(ke==null?void 0:ke.checkpointId)??null,checkpointNs:(ke==null?void 0:ke.checkpointNs)??null}),m(Te),w(!!(ke!=null&&ke.nextCursor)),k((ke==null?void 0:ke.nextCursor)??null)}});I.current.set(me,ge);try{await ge}finally{I.current.delete(me)}return G.current===K&&(R.current=me),ge},[e,t,H]),P=v.useCallback(async(K,Q)=>{B.current=K;try{await Y(K,Q)}finally{B.current===K&&(B.current=null)}},[Y]),O=v.useCallback(K=>{X.current=K},[]),M=v.useCallback(K=>{q.current=K},[]),L=v.useCallback(K=>{const Q=K.threadId??G.current;if(!Q||G.current&&G.current!==Q)return;const{checkpoints:me}=Dn(K);if(!me.length)return;const de=me.find(we=>we.messages&&we.messages.length>0)??me.find(we=>!!we.checkpointId)??me[0],ge=q.current===Q;!u&&!ge&&t((de==null?void 0:de.messages)??[],{checkpointId:(de==null?void 0:de.checkpointId)??null,checkpointNs:(de==null?void 0:de.checkpointNs)??null}),m(K),w(!!(de!=null&&de.nextCursor)),k((de==null?void 0:de.nextCursor)??null),R.current=`${Q}:latest`,X.current=null,q.current===Q&&(q.current=null)},[t,u]),te=v.useCallback(async(K,Q)=>{const me=G.current;await H({threadId:me,setLoading:D,action:async de=>{const ge=await e.getStateHistory({threadId:de,checkpointId:K,checkpointNs:Q??void 0});if(G.current!==de){console.log(`[useThreadHistoryState] Thread changed during checkpoint navigation (was ${de}, now ${G.current}), discarding stale data`);return}const{checkpoints:we}=Dn(ge),Te=we.find(Ne=>Ne.checkpointId===K&&(Q?Ne.checkpointNs===Q:!0));if(!Te){console.warn("[useThreadHistoryState] Requested checkpoint not found:",{checkpointId:K,checkpointNs:Q});return}m(ge),t(Te.messages??[],{checkpointId:Te.checkpointId??null,checkpointNs:Te.checkpointNs??null})}}).catch(()=>{})},[e,t,H]),z=v.useCallback((K,Q)=>{t(d(),{checkpointId:K??null,checkpointNs:Q??null})},[d,t]),$=v.useCallback(async()=>{G.current&&await P(G.current)},[P]),ee=v.useCallback(async()=>{const K=G.current;!K||!S||await H({threadId:K,setLoading:j,action:async Q=>{const me=await e.getStateHistory({threadId:Q,checkpointId:S});if(G.current!==Q)return;const{checkpoints:de}=Dn(me);if(de.length>0){const ge=de[de.length-1];n((ge==null?void 0:ge.messages)??[]),w(!!(ge!=null&&ge.nextCursor)),k((ge==null?void 0:ge.nextCursor)??null)}}}).catch(()=>{})},[e,S,r,n,H]);v.useEffect(()=>{if(!l||!o||C||u)return;if(X.current===o){X.current=null,A.current=o;return}if(q.current===o){A.current=o;return}if(B.current===o){B.current=null,A.current=o;return}if(A.current===o)return;A.current=o;let K;console.log("[useThreadHistoryState] Loading thread with latest checkpoint");const Q=`${o}:latest`;R.current!==Q&&P(o,K)},[l,o,i,a,s,C,u,P]);const J=v.useCallback(()=>{m(null),w(!1),k(null),T(!1),j(!1),D(!1),W(null),X.current=null,q.current=null,A.current=null,R.current=null,B.current=null},[]);return{threadCheckpoints:b,threadTimeline:x,checkpointIndex:g,isLoadingThread:C,isHistoryLoading:E,isLoadingCheckpoint:_,threadStateError:F,hasMoreHistory:y,loadThread:P,navigateToCheckpoint:te,loadOlderMessages:ee,setCurrentCheckpointId:z,returnToLatest:$,handleStateHistoryEvent:L,markSkipNextLoad:O,markStreamPendingThread:M,resetHistoryState:J}}const Mu=v.createContext(null),Ou=v.createContext(null);function no(){const e=v.useContext(Mu);if(!e)throw new Error("useThreadState must be used within a ThreadStateProvider");return e}function Du(){const e=v.useContext(Ou);if(!e)throw new Error("useThreadStateUpdater must be used within a ThreadStateProvider");return e}function Lu({children:e,initialThreadId:t=null,initialCheckpointId:n=null,initialCheckpointNs:r=null,autoLoadInitial:o=!0,isStreaming:s,onError:i}){const{api:a}=Zr(),{currentThreadId:l}=vr(),{state:u,seed:d,prepend:f,pushUser:m,onEvent:p}=Hb(),{threadCheckpoints:b,threadTimeline:g,checkpointIndex:x,isLoadingThread:y,isHistoryLoading:w,isLoadingCheckpoint:S,threadStateError:k,hasMoreHistory:C,loadThread:T,navigateToCheckpoint:E,loadOlderMessages:j,setCurrentCheckpointId:_,returnToLatest:D,handleStateHistoryEvent:F,markSkipNextLoad:W,markStreamPendingThread:G,resetHistoryState:A}=Ru({api:a,seed:d,prepend:f,onError:i,currentThreadId:l,initialThreadId:t,initialCheckpointId:n,initialCheckpointNs:r,autoLoadInitial:o,isStreaming:s,getMessages:v.useCallback(()=>u.messages,[u.messages])}),[X,q]=v.useState(()=>async()=>{throw new Error("clearThread is not ready")}),[B,R]=v.useState(()=>async()=>{throw new Error("respondToInterrupt is not ready")});v.useEffect(()=>{l||(d([],{}),A())},[l,d,A]);const I=v.useCallback(M=>q(()=>M),[]),H=v.useCallback(M=>R(()=>M),[]),Y=v.useMemo(()=>({assemblingMessageId:u.assemblingId??null}),[u.assemblingId]),P=v.useMemo(()=>({threadId:l,messages:u.messages,interrupt:u.pendingInterrupt,checkpoint:{id:u.lastCheckpointId??null,namespace:u.lastCheckpointNs??null},checkpoints:b,checkpointIndex:x,timelineCheckpoints:g,metadata:Y,isLoading:y,isHistoryLoading:w,isLoadingCheckpoint:S,error:k,hasMore:C,loadOlder:j,clearState:X,navigateToCheckpoint:E,setCurrentCheckpointId:_,returnToLatest:D,loadThread:T,clearThread:X,respondToInterrupt:B,messagePreviews:x.messagePreviews,handleStateHistoryEvent:F,markSkipNextLoad:W,markStreamPendingThread:G,resetHistoryState:A,pushUser:m,onEvent:p}),[l,u,b,g,x,Y,y,w,S,k,C,j,X,E,_,D,T,B,x.messagePreviews,F,W,G,A,m,p]),O=v.useMemo(()=>({registerClearThread:I,registerRespondToInterrupt:H}),[I,H]);return c.jsx(Ou.Provider,{value:O,children:c.jsx(Mu.Provider,{value:P,children:e})})}function $u(e,t){if(!e)return null;const n=Mn(e);if(!n)return null;const r=Mn(n.configurable)??n;return On(r,t)??null}function qb(e){const t=$u(e,["checkpoint_id","checkpointId"]);if(!t)return null;const n=$u(e,["checkpoint_ns","checkpointNs"]);return{checkpointId:t,checkpointNs:n}}function Gb(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 Yb(e,t){const n=[...e].sort(Gb);for(const r of n){if(r.messageId!==t)continue;const o=qb(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 Fu=v.createContext(null),Bu=v.createContext(!1);function Xb({children:e,initialThreadId:t=null,initialCheckpointId:n=null,initialCheckpointNs:r=null,autoLoadInitial:o=!0,onError:s,onAuthError:i,onThreadChange:a,onConnectionError:l,onToolEnd:u}){const{api:d,baseUrl:f}=Zr(),m=v.useMemo(()=>bn(f),[f]),{stream:p,stop:b,isStreaming:g,error:x,setToken:y}=Nb({baseUrl:m}),[w,S]=v.useState(!1);return v.useEffect(()=>{S(g)},[g]),c.jsx(ku,{initialThreadId:t,onError:s,onThreadChange:a,children:c.jsx(Lu,{initialThreadId:t,initialCheckpointId:n,initialCheckpointNs:r,autoLoadInitial:o,onError:s,isStreaming:w,children:c.jsx(Bu.Provider,{value:!0,children:c.jsx(Jb,{api:d,streamApi:{stream:p,stop:b,isStreaming:g,error:x,setToken:y},onError:s,onAuthError:i,onConnectionError:l,onToolEnd:u,children:e})})})})}function Jb({children:e,api:t,streamApi:n,onError:r,onAuthError:o,onConnectionError:s,onToolEnd:i}){const{stream:a,stop:l,isStreaming:u,error:d,setToken:f}=n,{setCurrentThreadId:m,currentThreadIdRef:p,addThreadFromEvent:b}=vr(),{checkpoint:g,timelineCheckpoints:x,handleStateHistoryEvent:y,markSkipNextLoad:w,markStreamPendingThread:S,resetHistoryState:k,pushUser:C,onEvent:T}=no(),{registerClearThread:E,registerRespondToInterrupt:j}=Du(),_=v.useCallback(B=>{b(B),p.current!==B.threadId&&((B.created??!p.current)&&w(B.threadId),S(B.threadId),m(B.threadId))},[b,w,S,m,p]),D=v.useCallback(B=>{B.type==="thread_info"?_(B):B.type==="state_history"?y(B):B.type==="tool.end"?i==null||i(B):T(B)},[_,y,T,i]),F=v.useCallback(B=>{a(B,D,{onError:R=>{console.error("[StreamingProvider] Stream error:",R),r==null||r(R)},onAuthError:R=>{console.error("[StreamingProvider] Auth error:",R),o==null||o(R)},onConnectionError:R=>{console.error("[StreamingProvider] Connection error:",R),s==null||s(R)}})},[a,D,r,o,s]),W=v.useRef(g);v.useEffect(()=>{W.current=g},[g]);const G=v.useCallback(async(B,R,I)=>{const H=p.current;if(!H)throw new Error("No active thread to handle interrupt");const Y=R?I??!0:!1,P=W.current,O={threadId:H,checkpointId:P.id??void 0,checkpointNs:P.namespace??void 0,command:{kind:"resume",value:Y}};F(O)},[p,F]);v.useEffect(()=>{j(G)},[G,j]);const A=v.useCallback(async()=>{l(),k(),m(null);try{await t.getAgent("default")}catch(B){console.warn("[StreamingProvider] Failed to refetch agent after clearing thread:",B)}},[t,k,m,l]);v.useEffect(()=>{E(A)},[A,E]);const X=v.useCallback(async(B,R)=>{let I=p.current;const H=(B==null?void 0:B.text)??"",Y=(B==null?void 0:B.attachments)??[],P=(H==null?void 0:H.trim())??"",O={...(B==null?void 0:B.payload)??{}},M=Array.isArray(O.messages)?O.messages:void 0;M&&delete O.messages;const L=!!(M&&M.length);if(!I&&!P&&Y.length===0&&!L)return;if(!I){const Ne=Math.floor(Date.now()/1e3).toString(16).padStart(8,"0"),ke=Array.from({length:4},()=>Math.floor(Math.random()*4294967295).toString(16).padStart(8,"0")).join("").slice(0,16);I=`${Ne}${ke}`,w(I),m(I)}const{contentParts:te,filesInfo:z}=await gu(Y),$=[...te];P&&$.push({type:"text",text:H});const ee=R==null?void 0:R.originalMessageId,J=!!(R!=null&&R.edit&&ee),K=!L&&$.length>0;let Q=null;K&&(Q={id:J?ee:`msg-${Date.now()}`,role:"user",content:$,createdAt:new Date().toISOString()},J?C(Q,ee):C(Q));const me=L?M:Q?[Q]:[],de={...O,...z.length?{files_info:z}:{}};me.length?de.messages=me:"messages"in de||(de.messages=[]);let ge=(R==null?void 0:R.checkpointId)??g.id??void 0,we=(R==null?void 0:R.checkpointNs)??g.namespace??void 0;if(J&&ee){const Ne=Yb(x,ee);ge=Ne.checkpointId,we=Ne.checkpointNs??void 0}const Te={threadId:I,payload:de,checkpointId:ge,checkpointNs:we,edit:!!(R!=null&&R.edit)};F(Te)},[g,p,w,C,F,x]),q=v.useMemo(()=>({isStreaming:u,error:d,connectionState:u?"connected":"idle",submit:X,send:X,stop:l,setAuthToken:f}),[u,d,X,l,f]);return c.jsx(Fu.Provider,{value:q,children:e})}function Wi(){const e=v.useContext(Fu);if(!e)throw new Error("useStream must be used within StreamingProvider");return e}function Zb(){return v.useContext(Bu)}function zu(e){return typeof e=="object"&&e!==null}function Qb(e,t){if(Object.is(e,t))return!0;if(!zu(e)||!zu(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 Hu(e){const t=v.useRef(e),n=v.useRef(e);return Qb(t.current,e)||(t.current=e,n.current=e),n.current}function yr({children:e,apiConfig:t,initialThreadId:n=null,initialCheckpointId:r=null,initialCheckpointNs:o=null,autoLoadInitial:s=!0,onConnectionError:i,onError:a,onAuthError:l,onThreadChange:u,onToolEnd:d}){const f=Hu(t),m=ro(a),p=ro(l),b=ro(i),g=ro(u),x=ro(d),y=v.useMemo(()=>({initialThreadId:n,initialCheckpointId:r,initialCheckpointNs:o,autoLoadInitial:s,onError:m,onAuthError:p,onConnectionError:b,onThreadChange:g,onToolEnd:x}),[n,r,o,s,m,p,b,g,x]);return c.jsx(hu,{apiConfig:f,children:c.jsx(Xb,{...y,children:e})})}function ro(e){const t=v.useRef(e);return v.useEffect(()=>{t.current=e},[e]),v.useCallback((...n)=>{const r=t.current;if(r)return r(...n)},[])}function Sr(e){if(!(typeof globalThis>"u"))return globalThis[e]}function ew(e){if(typeof e!="string")return;const t=e.trim();if(t)return bn(t)}function Uu(){const e=[Sr("__API_BASE_URL__"),Sr("__CHAT_API_BASE_URL__"),Sr("__CHAT_API_URL__")];for(const t of e){const n=ew(t);if(n)return n}}function Wu(){const e=[Sr("__API_AUTH_TOKEN__"),Sr("__CHAT_API_KEY__"),Sr("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function Vu(...e){for(const t of e)if(typeof t=="string"&&t.trim())return bn(t);return bn()}function Ku(){const e={},t=Uu(),n=Wu();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function qu(){const e=Ku(),t=jn.getAuthToken(),n=Uu();return{apiBaseUrl:Vu(e.baseUrl,jn.baseUrl,n),apiKey:t||e.apiKey||Wu()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,darkMode:!1,enableSound:!1,messageHistory:100}}const Vi="chat-settings";function Gu(){try{const e=localStorage.getItem(Vi);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function Yu(e){try{const t={...e,apiBaseUrl:bn(e.apiBaseUrl)};localStorage.setItem(Vi,JSON.stringify(t)),t.apiKey&&jn.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function tw(){const e=qu(),t=Gu(),n=jn.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:Vu(jn.baseUrl,r,e.apiBaseUrl)}}function nw(e){jn.updateConfig({baseUrl:e.apiBaseUrl,authToken:e.apiKey??void 0}),Yu(e)}function ne(...e){return Fx.twMerge($x.clsx(e))}const rw=Ur.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"}}),Je=h.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?qt.Slot:"button";return c.jsx(i,{className:ne(rw({variant:t,size:n,className:e})),ref:s,...o})});Je.displayName="Button";function ie(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 Xu(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Ln(...e){return t=>{let n=!1;const r=e.map(o=>{const s=Xu(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():Xu(e[o],null)}}}}function _e(...e){return h.useCallback(Ln(...e),e)}function ow(e,t){const n=h.createContext(t),r=s=>{const{children:i,...a}=s,l=h.useMemo(()=>a,Object.values(a));return c.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 Xt(e,t=[]){let n=[];function r(s,i){const a=h.createContext(i),l=n.length;n=[...n,i];const u=f=>{var y;const{scope:m,children:p,...b}=f,g=((y=m==null?void 0:m[e])==null?void 0:y[l])||a,x=h.useMemo(()=>b,Object.values(b));return c.jsx(g.Provider,{value:x,children:p})};u.displayName=s+"Provider";function d(f,m){var g;const p=((g=m==null?void 0:m[e])==null?void 0:g[l])||a,b=h.useContext(p);if(b)return b;if(i!==void 0)return i;throw new Error(`\`${f}\` must be used within \`${s}\``)}return[u,d]}const o=()=>{const s=n.map(i=>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,sw(o,...t)]}function sw(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(s){const i=r.reduce((a,{useScope:l,scopeName:u})=>{const f=l(s)[`__scope${u}`];return{...a,...f}},{});return h.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var wt=globalThis!=null&&globalThis.document?h.useLayoutEffect:()=>{},iw=h[" useInsertionEffect ".trim().toString()]||wt;function cn({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=aw({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 u=h.useCallback(d=>{var f;if(a){const m=lw(d)?d(e):d;m!==e&&((f=i.current)==null||f.call(i,m))}else s(d)},[a,e,s,i]);return[l,u]}function aw({defaultProp:e,onChange:t}){const[n,r]=h.useState(e),o=h.useRef(n),s=h.useRef(t);return iw(()=>{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 lw(e){return typeof e=="function"}var cw=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],he=cw.reduce((e,t)=>{const n=qt.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),c.jsx(l,{...a,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Ki(e,t){e&&Wr.flushSync(()=>e.dispatchEvent(t))}function oo(e){const t=e+"CollectionProvider",[n,r]=Xt(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=g=>{const{scope:x,children:y}=g,w=v.useRef(null),S=v.useRef(new Map).current;return c.jsx(o,{scope:x,itemMap:S,collectionRef:w,children:y})};i.displayName=t;const a=e+"CollectionSlot",l=qt.createSlot(a),u=v.forwardRef((g,x)=>{const{scope:y,children:w}=g,S=s(a,y),k=_e(x,S.collectionRef);return c.jsx(l,{ref:k,children:w})});u.displayName=a;const d=e+"CollectionItemSlot",f="data-radix-collection-item",m=qt.createSlot(d),p=v.forwardRef((g,x)=>{const{scope:y,children:w,...S}=g,k=v.useRef(null),C=_e(x,k),T=s(d,y);return v.useEffect(()=>(T.itemMap.set(k,{ref:k,...S}),()=>void T.itemMap.delete(k))),c.jsx(m,{[f]:"",ref:C,children:w})});p.displayName=d;function b(g){const x=s(e+"CollectionConsumer",g);return v.useCallback(()=>{const w=x.collectionRef.current;if(!w)return[];const S=Array.from(w.querySelectorAll(`[${f}]`));return Array.from(x.itemMap.values()).sort((T,E)=>S.indexOf(T.ref.current)-S.indexOf(E.ref.current))},[x.collectionRef,x.itemMap])}return[{Provider:i,Slot:u,ItemSlot:p},b,r]}var uw=h.createContext(void 0);function so(e){const t=h.useContext(uw);return e||t||"ltr"}function ft(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 dw(e,t=globalThis==null?void 0:globalThis.document){const n=ft(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 fw="DismissableLayer",qi="dismissableLayer.update",pw="dismissableLayer.pointerDownOutside",hw="dismissableLayer.focusOutside",Ju,Zu=h.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Cr=h.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...l}=e,u=h.useContext(Zu),[d,f]=h.useState(null),m=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,p]=h.useState({}),b=_e(t,E=>f(E)),g=Array.from(u.layers),[x]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),y=g.indexOf(x),w=d?g.indexOf(d):-1,S=u.layersWithOutsidePointerEventsDisabled.size>0,k=w>=y,C=gw(E=>{const j=E.target,_=[...u.branches].some(D=>D.contains(j));!k||_||(o==null||o(E),i==null||i(E),E.defaultPrevented||a==null||a())},m),T=xw(E=>{const j=E.target;[...u.branches].some(D=>D.contains(j))||(s==null||s(E),i==null||i(E),E.defaultPrevented||a==null||a())},m);return dw(E=>{w===u.layers.size-1&&(r==null||r(E),!E.defaultPrevented&&a&&(E.preventDefault(),a()))},m),h.useEffect(()=>{if(d)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(Ju=m.body.style.pointerEvents,m.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),ed(),()=>{n&&u.layersWithOutsidePointerEventsDisabled.size===1&&(m.body.style.pointerEvents=Ju)}},[d,m,n,u]),h.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),ed())},[d,u]),h.useEffect(()=>{const E=()=>p({});return document.addEventListener(qi,E),()=>document.removeEventListener(qi,E)},[]),c.jsx(he.div,{...l,ref:b,style:{pointerEvents:S?k?"auto":"none":void 0,...e.style},onFocusCapture:ie(e.onFocusCapture,T.onFocusCapture),onBlurCapture:ie(e.onBlurCapture,T.onBlurCapture),onPointerDownCapture:ie(e.onPointerDownCapture,C.onPointerDownCapture)})});Cr.displayName=fw;var mw="DismissableLayerBranch",Qu=h.forwardRef((e,t)=>{const n=h.useContext(Zu),r=h.useRef(null),o=_e(t,r);return h.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),c.jsx(he.div,{...e,ref:o})});Qu.displayName=mw;function gw(e,t=globalThis==null?void 0:globalThis.document){const n=ft(e),r=h.useRef(!1),o=h.useRef(()=>{});return h.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){td(pw,n,u,{discrete:!0})};const u={originalEvent:a};a.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=l,t.addEventListener("click",o.current,{once:!0})):l()}else t.removeEventListener("click",o.current);r.current=!1},i=window.setTimeout(()=>{t.addEventListener("pointerdown",s)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",s),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function xw(e,t=globalThis==null?void 0:globalThis.document){const n=ft(e),r=h.useRef(!1);return h.useEffect(()=>{const o=s=>{s.target&&!r.current&&td(hw,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 ed(){const e=new CustomEvent(qi);document.dispatchEvent(e)}function td(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?Ki(o,s):o.dispatchEvent(s)}var vw=Cr,bw=Qu,Gi=0;function Yi(){h.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??nd()),document.body.insertAdjacentElement("beforeend",e[1]??nd()),Gi++,()=>{Gi===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Gi--}},[])}function nd(){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 Xi="focusScope.autoFocusOnMount",Ji="focusScope.autoFocusOnUnmount",rd={bubbles:!1,cancelable:!0},ww="FocusScope",ts=h.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,l]=h.useState(null),u=ft(o),d=ft(s),f=h.useRef(null),m=_e(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(S){if(p.paused||!a)return;const k=S.target;a.contains(k)?f.current=k:$n(f.current,{select:!0})},x=function(S){if(p.paused||!a)return;const k=S.relatedTarget;k!==null&&(a.contains(k)||$n(f.current,{select:!0}))},y=function(S){if(document.activeElement===document.body)for(const C of S)C.removedNodes.length>0&&$n(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(Xi,rd);a.addEventListener(Xi,u),a.dispatchEvent(y),y.defaultPrevented||(yw(Ew(od(a)),{select:!0}),document.activeElement===g&&$n(a))}return()=>{a.removeEventListener(Xi,u),setTimeout(()=>{const y=new CustomEvent(Ji,rd);a.addEventListener(Ji,d),a.dispatchEvent(y),y.defaultPrevented||$n(g??document.body,{select:!0}),a.removeEventListener(Ji,d),id.remove(p)},0)}}},[a,u,d,p]);const b=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,[S,k]=Sw(w);S&&k?!g.shiftKey&&y===k?(g.preventDefault(),n&&$n(S,{select:!0})):g.shiftKey&&y===S&&(g.preventDefault(),n&&$n(k,{select:!0})):y===w&&g.preventDefault()}},[n,r,p.paused]);return c.jsx(he.div,{tabIndex:-1,...i,ref:m,onKeyDown:b})});ts.displayName=ww;function yw(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if($n(r,{select:t}),document.activeElement!==n)return}function Sw(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(!Cw(n,{upTo:t}))return n}function Cw(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 Tw(e){return e instanceof HTMLInputElement&&"select"in e}function $n(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Tw(e)&&t&&e.select()}}var id=kw();function kw(){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 Ew(e){return e.filter(t=>t.tagName!=="A")}var Iw=h[" useId ".trim().toString()]||(()=>{}),Nw=0;function kt(e){const[t,n]=h.useState(Iw());return wt(()=>{n(r=>r??String(Nw++))},[e]),t?`radix-${t}`:""}const Aw=["top","right","bottom","left"],Fn=Math.min,Jt=Math.max,ns=Math.round,rs=Math.floor,wn=e=>({x:e,y:e}),jw={left:"right",right:"left",bottom:"top",top:"bottom"},_w={start:"end",end:"start"};function Zi(e,t,n){return Jt(e,Fn(t,n))}function _n(e,t){return typeof e=="function"?e(t):e}function Pn(e){return e.split("-")[0]}function Tr(e){return e.split("-")[1]}function Qi(e){return e==="x"?"y":"x"}function ea(e){return e==="y"?"height":"width"}const Pw=new Set(["top","bottom"]);function yn(e){return Pw.has(Pn(e))?"y":"x"}function ta(e){return Qi(yn(e))}function Rw(e,t,n){n===void 0&&(n=!1);const r=Tr(e),o=ta(e),s=ea(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=os(i)),[i,os(i)]}function Mw(e){const t=os(e);return[na(e),t,na(t)]}function na(e){return e.replace(/start|end/g,t=>_w[t])}const ld=["left","right"],cd=["right","left"],Ow=["top","bottom"],Dw=["bottom","top"];function Lw(e,t,n){switch(e){case"top":case"bottom":return n?t?cd:ld:t?ld:cd;case"left":case"right":return t?Ow:Dw;default:return[]}}function $w(e,t,n,r){const o=Tr(e);let s=Lw(Pn(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(na)))),s}function os(e){return e.replace(/left|right|bottom|top/g,t=>jw[t])}function Fw(e){return{top:0,right:0,bottom:0,left:0,...e}}function ud(e){return typeof e!="number"?Fw(e):{top:e,right:e,bottom:e,left:e}}function ss(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}function dd(e,t,n){let{reference:r,floating:o}=e;const s=yn(t),i=ta(t),a=ea(i),l=Pn(t),u=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(Tr(t)){case"start":p[i]-=m*(n&&u?-1:1);break;case"end":p[i]+=m*(n&&u?-1:1);break}return p}const Bw=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=n,a=s.filter(Boolean),l=await(i.isRTL==null?void 0:i.isRTL(t));let u=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:d,y:f}=dd(u,r,l),m=r,p={},b=0;for(let g=0;g<a.length;g++){const{name:x,fn:y}=a[g],{x:w,y:S,data:k,reset:C}=await y({x:d,y:f,initialPlacement:r,placement:m,strategy:o,middlewareData:p,rects:u,platform:i,elements:{reference:e,floating:t}});d=w??d,f=S??f,p={...p,[x]:{...p[x],...k}},C&&b<=50&&(b++,typeof C=="object"&&(C.placement&&(m=C.placement),C.rects&&(u=C.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):C.rects),{x:d,y:f}=dd(u,m,l)),g=-1)}return{x:d,y:f,placement:m,strategy:o,middlewareData:p}};async function io(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:i,elements:a,strategy:l}=e,{boundary:u="clippingAncestors",rootBoundary:d="viewport",elementContext:f="floating",altBoundary:m=!1,padding:p=0}=_n(t,e),b=ud(p),x=a[m?f==="floating"?"reference":"floating":f],y=ss(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:u,rootBoundary:d,strategy:l})),w=f==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,S=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),k=await(s.isElement==null?void 0:s.isElement(S))?await(s.getScale==null?void 0:s.getScale(S))||{x:1,y:1}:{x:1,y:1},C=ss(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:w,offsetParent:S,strategy:l}):w);return{top:(y.top-C.top+b.top)/k.y,bottom:(C.bottom-y.bottom+b.bottom)/k.y,left:(y.left-C.left+b.left)/k.x,right:(C.right-y.right+b.right)/k.x}}const zw=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:s,platform:i,elements:a,middlewareData:l}=t,{element:u,padding:d=0}=_n(e,t)||{};if(u==null)return{};const f=ud(d),m={x:n,y:r},p=ta(o),b=ea(p),g=await i.getDimensions(u),x=p==="y",y=x?"top":"left",w=x?"bottom":"right",S=x?"clientHeight":"clientWidth",k=s.reference[b]+s.reference[p]-m[p]-s.floating[b],C=m[p]-s.reference[p],T=await(i.getOffsetParent==null?void 0:i.getOffsetParent(u));let E=T?T[S]:0;(!E||!await(i.isElement==null?void 0:i.isElement(T)))&&(E=a.floating[S]||s.floating[b]);const j=k/2-C/2,_=E/2-g[b]/2-1,D=Fn(f[y],_),F=Fn(f[w],_),W=D,G=E-g[b]-F,A=E/2-g[b]/2+j,X=Zi(W,A,G),q=!l.arrow&&Tr(o)!=null&&A!==X&&s.reference[b]/2-(A<W?D:F)-g[b]/2<0,B=q?A<W?A-W:A-G:0;return{[p]:m[p]+B,data:{[p]:X,centerOffset:A-X-B,...q&&{alignmentOffset:B}},reset:q}}}),Hw=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:s,rects:i,initialPlacement:a,platform:l,elements:u}=t,{mainAxis:d=!0,crossAxis:f=!0,fallbackPlacements:m,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:b="none",flipAlignment:g=!0,...x}=_n(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const y=Pn(o),w=yn(a),S=Pn(a)===a,k=await(l.isRTL==null?void 0:l.isRTL(u.floating)),C=m||(S||!g?[os(a)]:Mw(a)),T=b!=="none";!m&&T&&C.push(...$w(a,g,b,k));const E=[a,...C],j=await io(t,x),_=[];let D=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&_.push(j[y]),f){const A=Rw(o,i,k);_.push(j[A[0]],j[A[1]])}if(D=[...D,{placement:o,overflows:_}],!_.every(A=>A<=0)){var F,W;const A=(((F=s.flip)==null?void 0:F.index)||0)+1,X=E[A];if(X&&(!(f==="alignment"?w!==yn(X):!1)||D.every(R=>yn(R.placement)===w?R.overflows[0]>0:!0)))return{data:{index:A,overflows:D},reset:{placement:X}};let q=(W=D.filter(B=>B.overflows[0]<=0).sort((B,R)=>B.overflows[1]-R.overflows[1])[0])==null?void 0:W.placement;if(!q)switch(p){case"bestFit":{var G;const B=(G=D.filter(R=>{if(T){const I=yn(R.placement);return I===w||I==="y"}return!0}).map(R=>[R.placement,R.overflows.filter(I=>I>0).reduce((I,H)=>I+H,0)]).sort((R,I)=>R[1]-I[1])[0])==null?void 0:G[0];B&&(q=B);break}case"initialPlacement":q=a;break}if(o!==q)return{reset:{placement:q}}}return{}}}};function fd(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function pd(e){return Aw.some(t=>e[t]>=0)}const Uw=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=_n(e,t);switch(r){case"referenceHidden":{const s=await io(t,{...o,elementContext:"reference"}),i=fd(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:pd(i)}}}case"escaped":{const s=await io(t,{...o,altBoundary:!0}),i=fd(s,n.floating);return{data:{escapedOffsets:i,escaped:pd(i)}}}default:return{}}}}},hd=new Set(["left","top"]);async function Ww(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=Pn(n),a=Tr(n),l=yn(n)==="y",u=hd.has(i)?-1:1,d=s&&l?-1:1,f=_n(t,e);let{mainAxis:m,crossAxis:p,alignmentAxis:b}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof b=="number"&&(p=a==="end"?b*-1:b),l?{x:p*d,y:m*u}:{x:m*u,y:p*d}}const Vw=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 Ww(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}}}}},Kw=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}=_n(e,t),u={x:n,y:r},d=await io(t,l),f=yn(Pn(o)),m=Qi(f);let p=u[m],b=u[f];if(s){const x=m==="y"?"top":"left",y=m==="y"?"bottom":"right",w=p+d[x],S=p-d[y];p=Zi(w,p,S)}if(i){const x=f==="y"?"top":"left",y=f==="y"?"bottom":"right",w=b+d[x],S=b-d[y];b=Zi(w,b,S)}const g=a.fn({...t,[m]:p,[f]:b});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[m]:s,[f]:i}}}}}},qw=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:s,middlewareData:i}=t,{offset:a=0,mainAxis:l=!0,crossAxis:u=!0}=_n(e,t),d={x:n,y:r},f=yn(o),m=Qi(f);let p=d[m],b=d[f];const g=_n(a,t),x=typeof g=="number"?{mainAxis:g,crossAxis:0}:{mainAxis:0,crossAxis:0,...g};if(l){const S=m==="y"?"height":"width",k=s.reference[m]-s.floating[S]+x.mainAxis,C=s.reference[m]+s.reference[S]-x.mainAxis;p<k?p=k:p>C&&(p=C)}if(u){var y,w;const S=m==="y"?"width":"height",k=hd.has(Pn(o)),C=s.reference[f]-s.floating[S]+(k&&((y=i.offset)==null?void 0:y[f])||0)+(k?0:x.crossAxis),T=s.reference[f]+s.reference[S]+(k?0:((w=i.offset)==null?void 0:w[f])||0)-(k?x.crossAxis:0);b<C?b=C:b>T&&(b=T)}return{[m]:p,[f]:b}}}},Gw=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:s,platform:i,elements:a}=t,{apply:l=()=>{},...u}=_n(e,t),d=await io(t,u),f=Pn(o),m=Tr(o),p=yn(o)==="y",{width:b,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,S=b-d.left-d.right,k=Fn(g-d[x],w),C=Fn(b-d[y],S),T=!t.middlewareData.shift;let E=k,j=C;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(j=S),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(E=w),T&&!m){const D=Jt(d.left,0),F=Jt(d.right,0),W=Jt(d.top,0),G=Jt(d.bottom,0);p?j=b-2*(D!==0||F!==0?D+F:Jt(d.left,d.right)):E=g-2*(W!==0||G!==0?W+G:Jt(d.top,d.bottom))}await l({...t,availableWidth:j,availableHeight:E});const _=await i.getDimensions(a.floating);return b!==_.width||g!==_.height?{reset:{rects:!0}}:{}}}};function is(){return typeof window<"u"}function kr(e){return md(e)?(e.nodeName||"").toLowerCase():"#document"}function Zt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Sn(e){var t;return(t=(md(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function md(e){return is()?e instanceof Node||e instanceof Zt(e).Node:!1}function un(e){return is()?e instanceof Element||e instanceof Zt(e).Element:!1}function Cn(e){return is()?e instanceof HTMLElement||e instanceof Zt(e).HTMLElement:!1}function gd(e){return!is()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Zt(e).ShadowRoot}const Yw=new Set(["inline","contents"]);function ao(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=dn(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!Yw.has(o)}const Xw=new Set(["table","td","th"]);function Jw(e){return Xw.has(kr(e))}const Zw=[":popover-open",":modal"];function as(e){return Zw.some(t=>{try{return e.matches(t)}catch{return!1}})}const Qw=["transform","translate","scale","rotate","perspective"],ey=["transform","translate","scale","rotate","perspective","filter"],ty=["paint","layout","strict","content"];function ra(e){const t=oa(),n=un(e)?dn(e):e;return Qw.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)||ey.some(r=>(n.willChange||"").includes(r))||ty.some(r=>(n.contain||"").includes(r))}function ny(e){let t=Bn(e);for(;Cn(t)&&!Er(t);){if(ra(t))return t;if(as(t))return null;t=Bn(t)}return null}function oa(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const ry=new Set(["html","body","#document"]);function Er(e){return ry.has(kr(e))}function dn(e){return Zt(e).getComputedStyle(e)}function ls(e){return un(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Bn(e){if(kr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||gd(e)&&e.host||Sn(e);return gd(t)?t.host:t}function xd(e){const t=Bn(e);return Er(t)?e.ownerDocument?e.ownerDocument.body:e.body:Cn(t)&&ao(t)?t:xd(t)}function lo(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=xd(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Zt(o);if(s){const a=sa(i);return t.concat(i,i.visualViewport||[],ao(o)?o:[],a&&n?lo(a):[])}return t.concat(o,lo(o,[],n))}function sa(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function vd(e){const t=dn(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=Cn(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=ns(n)!==s||ns(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function ia(e){return un(e)?e:e.contextElement}function Ir(e){const t=ia(e);if(!Cn(t))return wn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=vd(t);let i=(s?ns(n.width):n.width)/r,a=(s?ns(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const oy=wn(0);function bd(e){const t=Zt(e);return!oa()||!t.visualViewport?oy:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function sy(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Zt(e)?!1:t}function tr(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=ia(e);let i=wn(1);t&&(r?un(r)&&(i=Ir(r)):i=Ir(e));const a=sy(s,n,r)?bd(s):wn(0);let l=(o.left+a.x)/i.x,u=(o.top+a.y)/i.y,d=o.width/i.x,f=o.height/i.y;if(s){const m=Zt(s),p=r&&un(r)?Zt(r):r;let b=m,g=sa(b);for(;g&&r&&p!==b;){const x=Ir(g),y=g.getBoundingClientRect(),w=dn(g),S=y.left+(g.clientLeft+parseFloat(w.paddingLeft))*x.x,k=y.top+(g.clientTop+parseFloat(w.paddingTop))*x.y;l*=x.x,u*=x.y,d*=x.x,f*=x.y,l+=S,u+=k,b=Zt(g),g=sa(b)}}return ss({width:d,height:f,x:l,y:u})}function cs(e,t){const n=ls(e).scrollLeft;return t?t.left+n:tr(Sn(e)).left+n}function wd(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-cs(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function iy(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=Sn(r),a=t?as(t.floating):!1;if(r===i||a&&s)return n;let l={scrollLeft:0,scrollTop:0},u=wn(1);const d=wn(0),f=Cn(r);if((f||!f&&!s)&&((kr(r)!=="body"||ao(i))&&(l=ls(r)),Cn(r))){const p=tr(r);u=Ir(r),d.x=p.x+r.clientLeft,d.y=p.y+r.clientTop}const m=i&&!f&&!s?wd(i,l):wn(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-l.scrollLeft*u.x+d.x+m.x,y:n.y*u.y-l.scrollTop*u.y+d.y+m.y}}function ay(e){return Array.from(e.getClientRects())}function ly(e){const t=Sn(e),n=ls(e),r=e.ownerDocument.body,o=Jt(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Jt(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+cs(e);const a=-n.scrollTop;return dn(r).direction==="rtl"&&(i+=Jt(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const yd=25;function cy(e,t){const n=Zt(e),r=Sn(e),o=n.visualViewport;let s=r.clientWidth,i=r.clientHeight,a=0,l=0;if(o){s=o.width,i=o.height;const d=oa();(!d||d&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}const u=cs(r);if(u<=0){const d=r.ownerDocument,f=d.body,m=getComputedStyle(f),p=d.compatMode==="CSS1Compat"&&parseFloat(m.marginLeft)+parseFloat(m.marginRight)||0,b=Math.abs(r.clientWidth-f.clientWidth-p);b<=yd&&(s-=b)}else u<=yd&&(s+=u);return{width:s,height:i,x:a,y:l}}const uy=new Set(["absolute","fixed"]);function dy(e,t){const n=tr(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=Cn(e)?Ir(e):wn(1),i=e.clientWidth*s.x,a=e.clientHeight*s.y,l=o*s.x,u=r*s.y;return{width:i,height:a,x:l,y:u}}function Sd(e,t,n){let r;if(t==="viewport")r=cy(e,n);else if(t==="document")r=ly(Sn(e));else if(un(t))r=dy(t,n);else{const o=bd(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return ss(r)}function Cd(e,t){const n=Bn(e);return n===t||!un(n)||Er(n)?!1:dn(n).position==="fixed"||Cd(n,t)}function fy(e,t){const n=t.get(e);if(n)return n;let r=lo(e,[],!1).filter(a=>un(a)&&kr(a)!=="body"),o=null;const s=dn(e).position==="fixed";let i=s?Bn(e):e;for(;un(i)&&!Er(i);){const a=dn(i),l=ra(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&uy.has(o.position)||ao(i)&&!l&&Cd(e,i))?r=r.filter(d=>d!==i):o=a,i=Bn(i)}return t.set(e,r),r}function py(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?as(t)?[]:fy(t,this._c):[].concat(n),r],a=i[0],l=i.reduce((u,d)=>{const f=Sd(t,d,o);return u.top=Jt(f.top,u.top),u.right=Fn(f.right,u.right),u.bottom=Fn(f.bottom,u.bottom),u.left=Jt(f.left,u.left),u},Sd(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function hy(e){const{width:t,height:n}=vd(e);return{width:t,height:n}}function my(e,t,n){const r=Cn(t),o=Sn(t),s=n==="fixed",i=tr(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=wn(0);function u(){l.x=cs(o)}if(r||!r&&!s)if((kr(t)!=="body"||ao(o))&&(a=ls(t)),r){const p=tr(t,!0,s,t);l.x=p.x+t.clientLeft,l.y=p.y+t.clientTop}else o&&u();s&&!r&&o&&u();const d=o&&!r&&!s?wd(o,a):wn(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 aa(e){return dn(e).position==="static"}function Td(e,t){if(!Cn(e)||dn(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Sn(e)===n&&(n=n.ownerDocument.body),n}function kd(e,t){const n=Zt(e);if(as(e))return n;if(!Cn(e)){let o=Bn(e);for(;o&&!Er(o);){if(un(o)&&!aa(o))return o;o=Bn(o)}return n}let r=Td(e,t);for(;r&&Jw(r)&&aa(r);)r=Td(r,t);return r&&Er(r)&&aa(r)&&!ra(r)?n:r||ny(e)||n}const gy=async function(e){const t=this.getOffsetParent||kd,n=this.getDimensions,r=await n(e.floating);return{reference:my(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function xy(e){return dn(e).direction==="rtl"}const vy={convertOffsetParentRelativeRectToViewportRelativeRect:iy,getDocumentElement:Sn,getClippingRect:py,getOffsetParent:kd,getElementRects:gy,getClientRects:ay,getDimensions:hy,getScale:Ir,isElement:un,isRTL:xy};function Ed(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function by(e,t){let n=null,r;const o=Sn(e);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),s();const u=e.getBoundingClientRect(),{left:d,top:f,width:m,height:p}=u;if(a||t(),!m||!p)return;const b=rs(f),g=rs(o.clientWidth-(d+m)),x=rs(o.clientHeight-(f+p)),y=rs(d),S={rootMargin:-b+"px "+-g+"px "+-x+"px "+-y+"px",threshold:Jt(0,Fn(1,l))||1};let k=!0;function C(T){const E=T[0].intersectionRatio;if(E!==l){if(!k)return i();E?i(!1,E):r=setTimeout(()=>{i(!1,1e-7)},1e3)}E===1&&!Ed(u,e.getBoundingClientRect())&&i(),k=!1}try{n=new IntersectionObserver(C,{...S,root:o.ownerDocument})}catch{n=new IntersectionObserver(C,S)}n.observe(e)}return i(!0),s}function wy(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,u=ia(e),d=o||s?[...u?lo(u):[],...lo(t)]:[];d.forEach(y=>{o&&y.addEventListener("scroll",n,{passive:!0}),s&&y.addEventListener("resize",n)});const f=u&&a?by(u,n):null;let m=-1,p=null;i&&(p=new ResizeObserver(y=>{let[w]=y;w&&w.target===u&&p&&(p.unobserve(t),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var S;(S=p)==null||S.observe(t)})),n()}),u&&!l&&p.observe(u),p.observe(t));let b,g=l?tr(e):null;l&&x();function x(){const y=tr(e);g&&!Ed(g,y)&&n(),g=y,b=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(b)}}const yy=Vw,Sy=Kw,Cy=Hw,Ty=Gw,ky=Uw,Id=zw,Ey=qw,Iy=(e,t,n)=>{const r=new Map,o={platform:vy,...n},s={...o.platform,_c:r};return Bw(e,t,{...o,platform:s})};var Ny=typeof document<"u",Ay=function(){},us=Ny?v.useLayoutEffect:Ay;function ds(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(!ds(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)&&!ds(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function Nd(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Ad(e,t){const n=Nd(e);return Math.round(t*n)/n}function la(e){const t=h.useRef(e);return us(()=>{t.current=e}),t}function jy(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:i}={},transform:a=!0,whileElementsMounted:l,open:u}=e,[d,f]=h.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[m,p]=h.useState(r);ds(m,r)||p(r);const[b,g]=h.useState(null),[x,y]=h.useState(null),w=h.useCallback(R=>{R!==T.current&&(T.current=R,g(R))},[]),S=h.useCallback(R=>{R!==E.current&&(E.current=R,y(R))},[]),k=s||b,C=i||x,T=h.useRef(null),E=h.useRef(null),j=h.useRef(d),_=l!=null,D=la(l),F=la(o),W=la(u),G=h.useCallback(()=>{if(!T.current||!E.current)return;const R={placement:t,strategy:n,middleware:m};F.current&&(R.platform=F.current),Iy(T.current,E.current,R).then(I=>{const H={...I,isPositioned:W.current!==!1};A.current&&!ds(j.current,H)&&(j.current=H,Wr.flushSync(()=>{f(H)}))})},[m,t,n,F,W]);us(()=>{u===!1&&j.current.isPositioned&&(j.current.isPositioned=!1,f(R=>({...R,isPositioned:!1})))},[u]);const A=h.useRef(!1);us(()=>(A.current=!0,()=>{A.current=!1}),[]),us(()=>{if(k&&(T.current=k),C&&(E.current=C),k&&C){if(D.current)return D.current(k,C,G);G()}},[k,C,G,D,_]);const X=h.useMemo(()=>({reference:T,floating:E,setReference:w,setFloating:S}),[w,S]),q=h.useMemo(()=>({reference:k,floating:C}),[k,C]),B=h.useMemo(()=>{const R={position:n,left:0,top:0};if(!q.floating)return R;const I=Ad(q.floating,d.x),H=Ad(q.floating,d.y);return a?{...R,transform:"translate("+I+"px, "+H+"px)",...Nd(q.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:I,top:H}},[n,a,q.floating,d.x,d.y]);return h.useMemo(()=>({...d,update:G,refs:X,elements:q,floatingStyles:B}),[d,G,X,q,B])}const _y=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?Id({element:r.current,padding:o}).fn(n):{}:r?Id({element:r,padding:o}).fn(n):{}}}},Py=(e,t)=>({...yy(e),options:[e,t]}),Ry=(e,t)=>({...Sy(e),options:[e,t]}),My=(e,t)=>({...Ey(e),options:[e,t]}),Oy=(e,t)=>({...Cy(e),options:[e,t]}),Dy=(e,t)=>({...Ty(e),options:[e,t]}),Ly=(e,t)=>({...ky(e),options:[e,t]}),$y=(e,t)=>({..._y(e),options:[e,t]});var Fy="Arrow",jd=h.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return c.jsx(he.svg,{...s,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:c.jsx("polygon",{points:"0,0 30,0 15,10"})})});jd.displayName=Fy;var By=jd;function _d(e){const[t,n]=h.useState(void 0);return wt(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const s=o[0];let i,a;if("borderBoxSize"in s){const l=s.borderBoxSize,u=Array.isArray(l)?l[0]:l;i=u.inlineSize,a=u.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var ca="Popper",[Pd,Nr]=Xt(ca),[zy,Rd]=Pd(ca),Md=e=>{const{__scopePopper:t,children:n}=e,[r,o]=h.useState(null);return c.jsx(zy,{scope:t,anchor:r,onAnchorChange:o,children:n})};Md.displayName=ca;var Od="PopperAnchor",Dd=h.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=Rd(Od,n),i=h.useRef(null),a=_e(t,i),l=h.useRef(null);return h.useEffect(()=>{const u=l.current;l.current=(r==null?void 0:r.current)||i.current,u!==l.current&&s.onAnchorChange(l.current)}),r?null:c.jsx(he.div,{...o,ref:a})});Dd.displayName=Od;var ua="PopperContent",[Hy,Uy]=Pd(ua),Ld=h.forwardRef((e,t)=>{var z,$,ee,J,K,Q;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:a=0,avoidCollisions:l=!0,collisionBoundary:u=[],collisionPadding:d=0,sticky:f="partial",hideWhenDetached:m=!1,updatePositionStrategy:p="optimized",onPlaced:b,...g}=e,x=Rd(ua,n),[y,w]=h.useState(null),S=_e(t,me=>w(me)),[k,C]=h.useState(null),T=_d(k),E=(T==null?void 0:T.width)??0,j=(T==null?void 0:T.height)??0,_=r+(s!=="center"?"-"+s:""),D=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},F=Array.isArray(u)?u:[u],W=F.length>0,G={padding:D,boundary:F.filter(Vy),altBoundary:W},{refs:A,floatingStyles:X,placement:q,isPositioned:B,middlewareData:R}=jy({strategy:"fixed",placement:_,whileElementsMounted:(...me)=>wy(...me,{animationFrame:p==="always"}),elements:{reference:x.anchor},middleware:[Py({mainAxis:o+j,alignmentAxis:i}),l&&Ry({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?My():void 0,...G}),l&&Oy({...G}),Dy({...G,apply:({elements:me,rects:de,availableWidth:ge,availableHeight:we})=>{const{width:Te,height:Ne}=de.reference,ke=me.floating.style;ke.setProperty("--radix-popper-available-width",`${ge}px`),ke.setProperty("--radix-popper-available-height",`${we}px`),ke.setProperty("--radix-popper-anchor-width",`${Te}px`),ke.setProperty("--radix-popper-anchor-height",`${Ne}px`)}}),k&&$y({element:k,padding:a}),Ky({arrowWidth:E,arrowHeight:j}),m&&Ly({strategy:"referenceHidden",...G})]}),[I,H]=Bd(q),Y=ft(b);wt(()=>{B&&(Y==null||Y())},[B,Y]);const P=(z=R.arrow)==null?void 0:z.x,O=($=R.arrow)==null?void 0:$.y,M=((ee=R.arrow)==null?void 0:ee.centerOffset)!==0,[L,te]=h.useState();return wt(()=>{y&&te(window.getComputedStyle(y).zIndex)},[y]),c.jsx("div",{ref:A.setFloating,"data-radix-popper-content-wrapper":"",style:{...X,transform:B?X.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:L,"--radix-popper-transform-origin":[(J=R.transformOrigin)==null?void 0:J.x,(K=R.transformOrigin)==null?void 0:K.y].join(" "),...((Q=R.hide)==null?void 0:Q.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:c.jsx(Hy,{scope:n,placedSide:I,onArrowChange:C,arrowX:P,arrowY:O,shouldHideArrow:M,children:c.jsx(he.div,{"data-side":I,"data-align":H,...g,ref:S,style:{...g.style,animation:B?void 0:"none"}})})})});Ld.displayName=ua;var $d="PopperArrow",Wy={top:"bottom",right:"left",bottom:"top",left:"right"},Fd=h.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=Uy($d,r),i=Wy[s.placedSide];return c.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:c.jsx(By,{...o,ref:n,style:{...o.style,display:"block"}})})});Fd.displayName=$d;function Vy(e){return e!==null}var Ky=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,[u,d]=Bd(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 b="",g="";return u==="bottom"?(b=i?f:`${m}px`,g=`${-l}px`):u==="top"?(b=i?f:`${m}px`,g=`${r.floating.height+l}px`):u==="right"?(b=`${-l}px`,g=i?f:`${p}px`):u==="left"&&(b=`${r.floating.width+l}px`,g=i?f:`${p}px`),{data:{x:b,y:g}}}});function Bd(e){const[t,n="center"]=e.split("-");return[t,n]}var da=Md,fa=Dd,pa=Ld,ha=Fd,qy="Portal",co=h.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=h.useState(!1);wt(()=>s(!0),[]);const i=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?$o.createPortal(c.jsx(he.div,{...r,ref:t}),i):null});co.displayName=qy;function Gy(e,t){return h.useReducer((n,r)=>t[n][r]??n,e)}var Dt=e=>{const{present:t,children:n}=e,r=Yy(t),o=typeof n=="function"?n({present:r.isPresent}):h.Children.only(n),s=_e(r.ref,Xy(o));return typeof n=="function"||r.isPresent?h.cloneElement(o,{ref:s}):null};Dt.displayName="Presence";function Yy(e){const[t,n]=h.useState(),r=h.useRef(null),o=h.useRef(e),s=h.useRef("none"),i=e?"mounted":"unmounted",[a,l]=Gy(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return h.useEffect(()=>{const u=fs(r.current);s.current=a==="mounted"?u:"none"},[a]),wt(()=>{const u=r.current,d=o.current;if(d!==e){const m=s.current,p=fs(u);e?l("MOUNT"):p==="none"||(u==null?void 0:u.display)==="none"?l("UNMOUNT"):l(d&&m!==p?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,l]),wt(()=>{if(t){let u;const d=t.ownerDocument.defaultView??window,f=p=>{const g=fs(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",u=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=x)})}},m=p=>{p.target===t&&(s.current=fs(r.current))};return t.addEventListener("animationstart",m),t.addEventListener("animationcancel",f),t.addEventListener("animationend",f),()=>{d.clearTimeout(u),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(u=>{r.current=u?getComputedStyle(u):null,n(u)},[])}}function fs(e){return(e==null?void 0:e.animationName)||"none"}function Xy(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 ma="rovingFocusGroup.onEntryFocus",Jy={bubbles:!1,cancelable:!0},uo="RovingFocusGroup",[ga,zd,Zy]=oo(uo),[Qy,Hd]=Xt(uo,[Zy]),[e0,t0]=Qy(uo),Ud=h.forwardRef((e,t)=>c.jsx(ga.Provider,{scope:e.__scopeRovingFocusGroup,children:c.jsx(ga.Slot,{scope:e.__scopeRovingFocusGroup,children:c.jsx(n0,{...e,ref:t})})}));Ud.displayName=uo;var n0=h.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:u,preventScrollOnEntryFocus:d=!1,...f}=e,m=h.useRef(null),p=_e(t,m),b=so(s),[g,x]=cn({prop:i,defaultProp:a??null,onChange:l,caller:uo}),[y,w]=h.useState(!1),S=ft(u),k=zd(n),C=h.useRef(!1),[T,E]=h.useState(0);return h.useEffect(()=>{const j=m.current;if(j)return j.addEventListener(ma,S),()=>j.removeEventListener(ma,S)},[S]),c.jsx(e0,{scope:n,orientation:r,dir:b,loop:o,currentTabStopId:g,onItemFocus:h.useCallback(j=>x(j),[x]),onItemShiftTab:h.useCallback(()=>w(!0),[]),onFocusableItemAdd:h.useCallback(()=>E(j=>j+1),[]),onFocusableItemRemove:h.useCallback(()=>E(j=>j-1),[]),children:c.jsx(he.div,{tabIndex:y||T===0?-1:0,"data-orientation":r,...f,ref:p,style:{outline:"none",...e.style},onMouseDown:ie(e.onMouseDown,()=>{C.current=!0}),onFocus:ie(e.onFocus,j=>{const _=!C.current;if(j.target===j.currentTarget&&_&&!y){const D=new CustomEvent(ma,Jy);if(j.currentTarget.dispatchEvent(D),!D.defaultPrevented){const F=k().filter(q=>q.focusable),W=F.find(q=>q.active),G=F.find(q=>q.id===g),X=[W,G,...F].filter(Boolean).map(q=>q.ref.current);Kd(X,d)}}C.current=!1}),onBlur:ie(e.onBlur,()=>w(!1))})})}),Wd="RovingFocusGroupItem",Vd=h.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,l=kt(),u=s||l,d=t0(Wd,n),f=d.currentTabStopId===u,m=zd(n),{onFocusableItemAdd:p,onFocusableItemRemove:b,currentTabStopId:g}=d;return h.useEffect(()=>{if(r)return p(),()=>b()},[r,p,b]),c.jsx(ga.ItemSlot,{scope:n,id:u,focusable:r,active:o,children:c.jsx(he.span,{tabIndex:f?0:-1,"data-orientation":d.orientation,...a,ref:t,onMouseDown:ie(e.onMouseDown,x=>{r?d.onItemFocus(u):x.preventDefault()}),onFocus:ie(e.onFocus,()=>d.onItemFocus(u)),onKeyDown:ie(e.onKeyDown,x=>{if(x.key==="Tab"&&x.shiftKey){d.onItemShiftTab();return}if(x.target!==x.currentTarget)return;const y=s0(x,d.orientation,d.dir);if(y!==void 0){if(x.metaKey||x.ctrlKey||x.altKey||x.shiftKey)return;x.preventDefault();let S=m().filter(k=>k.focusable).map(k=>k.ref.current);if(y==="last")S.reverse();else if(y==="prev"||y==="next"){y==="prev"&&S.reverse();const k=S.indexOf(x.currentTarget);S=d.loop?i0(S,k+1):S.slice(k+1)}setTimeout(()=>Kd(S))}}),children:typeof i=="function"?i({isCurrentTabStop:f,hasTabStop:g!=null}):i})})});Vd.displayName=Wd;var r0={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function o0(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function s0(e,t,n){const r=o0(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return r0[r]}function Kd(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function i0(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var a0=Ud,l0=Vd,c0=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Ar=new WeakMap,ps=new WeakMap,hs={},xa=0,qd=function(e){return e&&(e.host||qd(e.parentNode))},u0=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=qd(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})},d0=function(e,t,n,r){var o=u0(t,Array.isArray(e)?e:[e]);hs[n]||(hs[n]=new WeakMap);var s=hs[n],i=[],a=new Set,l=new Set(o),u=function(f){!f||a.has(f)||(a.add(f),u(f.parentNode))};o.forEach(u);var d=function(f){!f||l.has(f)||Array.prototype.forEach.call(f.children,function(m){if(a.has(m))d(m);else try{var p=m.getAttribute(r),b=p!==null&&p!=="false",g=(Ar.get(m)||0)+1,x=(s.get(m)||0)+1;Ar.set(m,g),s.set(m,x),i.push(m),g===1&&b&&ps.set(m,!0),x===1&&m.setAttribute(n,"true"),b||m.setAttribute(r,"true")}catch(y){console.error("aria-hidden: cannot operate on ",m,y)}})};return d(t),a.clear(),xa++,function(){i.forEach(function(f){var m=Ar.get(f)-1,p=s.get(f)-1;Ar.set(f,m),s.set(f,p),m||(ps.has(f)||f.removeAttribute(r),ps.delete(f)),p||f.removeAttribute(n)}),xa--,xa||(Ar=new WeakMap,Ar=new WeakMap,ps=new WeakMap,hs={})}},va=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=c0(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),d0(r,o,n,"aria-hidden")):function(){return null}},Tn=function(){return Tn=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},Tn.apply(this,arguments)};function Gd(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 f0(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 ms="right-scroll-bar-position",gs="width-before-scroll-bar",p0="with-scroll-bars-hidden",h0="--removed-body-scroll-bar-size";function ba(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function m0(e,t){var n=v.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 g0=typeof window<"u"?h.useLayoutEffect:h.useEffect,Yd=new WeakMap;function x0(e,t){var n=m0(null,function(r){return e.forEach(function(o){return ba(o,r)})});return g0(function(){var r=Yd.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||ba(a,null)}),s.forEach(function(a){o.has(a)||ba(a,i)})}Yd.set(n,e)},[e]),n}function v0(e){return e}function b0(e,t){t===void 0&&(t=v0);var n=[],r=!1,o={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(s){var i=t(s,r);return n.push(i),function(){n=n.filter(function(a){return a!==i})}},assignSyncMedium:function(s){for(r=!0;n.length;){var i=n;n=[],i.forEach(s)}n={push:function(a){return s(a)},filter:function(){return n}}},assignMedium:function(s){r=!0;var i=[];if(n.length){var a=n;n=[],a.forEach(s),i=n}var l=function(){var d=i;i=[],d.forEach(s)},u=function(){return Promise.resolve().then(l)};u(),n={push:function(d){i.push(d),u()},filter:function(d){return i=i.filter(d),n}}}};return o}function w0(e){e===void 0&&(e={});var t=b0(null);return t.options=Tn({async:!0,ssr:!1},e),t}var Xd=function(e){var t=e.sideCar,n=Gd(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,Tn({},n))};Xd.isSideCarExport=!0;function y0(e,t){return e.useMedium(t),Xd}var Jd=w0(),wa=function(){},xs=h.forwardRef(function(e,t){var n=h.useRef(null),r=h.useState({onScrollCapture:wa,onWheelCapture:wa,onTouchMoveCapture:wa}),o=r[0],s=r[1],i=e.forwardProps,a=e.children,l=e.className,u=e.removeScrollBar,d=e.enabled,f=e.shards,m=e.sideCar,p=e.noRelative,b=e.noIsolation,g=e.inert,x=e.allowPinchZoom,y=e.as,w=y===void 0?"div":y,S=e.gapMode,k=Gd(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=m,T=x0([n,t]),E=Tn(Tn({},k),o);return h.createElement(h.Fragment,null,d&&h.createElement(C,{sideCar:Jd,removeScrollBar:u,shards:f,noRelative:p,noIsolation:b,inert:g,setCallbacks:s,allowPinchZoom:!!x,lockRef:n,gapMode:S}),i?h.cloneElement(h.Children.only(a),Tn(Tn({},E),{ref:T})):h.createElement(w,Tn({},E,{className:l,ref:T}),a))});xs.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},xs.classNames={fullWidth:gs,zeroRight:ms};var S0=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function C0(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=S0();return t&&e.setAttribute("nonce",t),e}function T0(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function k0(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var E0=function(){var e=0,t=null;return{add:function(n){e==0&&(t=C0())&&(T0(t,n),k0(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},I0=function(){var e=E0();return function(t,n){h.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Zd=function(){var e=I0(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},N0={left:0,top:0,right:0,gap:0},ya=function(e){return parseInt(e||"",10)||0},A0=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[ya(n),ya(r),ya(o)]},j0=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return N0;var t=A0(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])}},_0=Zd(),jr="data-scroll-locked",P0=function(e,t,n,r){var o=e.left,s=e.top,i=e.right,a=e.gap;return n===void 0&&(n="margin"),`
|
|
40
|
+
.`.concat(p0,` {
|
|
41
41
|
overflow: hidden `).concat(r,`;
|
|
42
42
|
padding-right: `).concat(a,"px ").concat(r,`;
|
|
43
43
|
}
|
|
44
|
-
body[`).concat(
|
|
44
|
+
body[`).concat(jr,`] {
|
|
45
45
|
overflow: hidden `).concat(r,`;
|
|
46
46
|
overscroll-behavior: contain;
|
|
47
47
|
`).concat([t&&"position: relative ".concat(r,";"),n==="margin"&&`
|
|
@@ -54,56 +54,56 @@ React keys must be passed directly to JSX without using spread:
|
|
|
54
54
|
`),n==="padding"&&"padding-right: ".concat(a,"px ").concat(r,";")].filter(Boolean).join(""),`
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
.`).concat(
|
|
57
|
+
.`).concat(ms,` {
|
|
58
58
|
right: `).concat(a,"px ").concat(r,`;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
.`).concat(
|
|
61
|
+
.`).concat(gs,` {
|
|
62
62
|
margin-right: `).concat(a,"px ").concat(r,`;
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
.`).concat(
|
|
65
|
+
.`).concat(ms," .").concat(ms,` {
|
|
66
66
|
right: 0 `).concat(r,`;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
.`).concat(
|
|
69
|
+
.`).concat(gs," .").concat(gs,` {
|
|
70
70
|
margin-right: 0 `).concat(r,`;
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
body[`).concat(
|
|
74
|
-
`).concat(
|
|
73
|
+
body[`).concat(jr,`] {
|
|
74
|
+
`).concat(h0,": ").concat(a,`px;
|
|
75
75
|
}
|
|
76
|
-
`)},
|
|
76
|
+
`)},Qd=function(){var e=parseInt(document.body.getAttribute(jr)||"0",10);return isFinite(e)?e:0},R0=function(){h.useEffect(function(){return document.body.setAttribute(jr,(Qd()+1).toString()),function(){var e=Qd()-1;e<=0?document.body.removeAttribute(jr):document.body.setAttribute(jr,e.toString())}},[])},M0=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;R0();var s=h.useMemo(function(){return j0(o)},[o]);return h.createElement(_0,{styles:P0(s,!t,o,n?"":"!important")})},Sa=!1;if(typeof window<"u")try{var vs=Object.defineProperty({},"passive",{get:function(){return Sa=!0,!0}});window.addEventListener("test",vs,vs),window.removeEventListener("test",vs,vs)}catch{Sa=!1}var _r=Sa?{passive:!1}:!1,O0=function(e){return e.tagName==="TEXTAREA"},ef=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!O0(e)&&n[t]==="visible")},D0=function(e){return ef(e,"overflowY")},L0=function(e){return ef(e,"overflowX")},tf=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=nf(e,r);if(o){var s=rf(e,r),i=s[1],a=s[2];if(i>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},$0=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},F0=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},nf=function(e,t){return e==="v"?D0(t):L0(t)},rf=function(e,t){return e==="v"?$0(t):F0(t)},B0=function(e,t){return e==="h"&&t==="rtl"?-1:1},z0=function(e,t,n,r,o){var s=B0(e,window.getComputedStyle(t).direction),i=s*r,a=n.target,l=t.contains(a),u=!1,d=i>0,f=0,m=0;do{if(!a)break;var p=rf(e,a),b=p[0],g=p[1],x=p[2],y=g-x-s*b;(b||y)&&nf(e,a)&&(f+=y,m+=b);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)&&(u=!0),u},bs=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},of=function(e){return[e.deltaX,e.deltaY]},sf=function(e){return e&&"current"in e?e.current:e},H0=function(e,t){return e[0]===t[0]&&e[1]===t[1]},U0=function(e){return`
|
|
77
77
|
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
78
78
|
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
79
|
-
`)},u0=0,jr=[];function d0(e){var t=p.useRef([]),n=p.useRef([0,0]),r=p.useRef(),o=p.useState(u0++)[0],s=p.useState(Bd)[0],i=p.useRef(e);p.useEffect(function(){i.current=e},[e]),p.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var g=_y([e.lockRef.current],(e.shards||[]).map(qd),!0).filter(Boolean);return g.forEach(function(x){return x.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),g.forEach(function(x){return x.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var a=p.useCallback(function(g,x){if("touches"in g&&g.touches.length===2||g.type==="wheel"&&g.ctrlKey)return!i.current.allowPinchZoom;var y=gs(g),w=n.current,S="deltaX"in g?g.deltaX:w[0]-y[0],k="deltaY"in g?g.deltaY:w[1]-y[1],C,T=g.target,E=Math.abs(S)>Math.abs(k)?"h":"v";if("touches"in g&&E==="h"&&T.type==="range")return!1;var j=Ud(E,T);if(!j)return!0;if(j?C=E:(C=E==="v"?"h":"v",j=Ud(E,T)),!j)return!1;if(!r.current&&"changedTouches"in g&&(S||k)&&(r.current=C),!C)return!0;var P=r.current||C;return a0(P,x,g,P==="h"?S:k)},[]),l=p.useCallback(function(g){var x=g;if(!(!jr.length||jr[jr.length-1]!==s)){var y="deltaY"in x?Kd(x):gs(x),w=t.current.filter(function(C){return C.name===x.type&&(C.target===x.target||x.target===C.shadowParent)&&l0(C.delta,y)})[0];if(w&&w.should){x.cancelable&&x.preventDefault();return}if(!w){var S=(i.current.shards||[]).map(qd).filter(Boolean).filter(function(C){return C.contains(x.target)}),k=S.length>0?a(x,S[0]):!i.current.noIsolation;k&&x.cancelable&&x.preventDefault()}}},[]),c=p.useCallback(function(g,x,y,w){var S={name:g,delta:x,target:y,should:w,shadowParent:f0(y)};t.current.push(S),setTimeout(function(){t.current=t.current.filter(function(k){return k!==S})},1)},[]),d=p.useCallback(function(g){n.current=gs(g),r.current=void 0},[]),h=p.useCallback(function(g){c(g.type,Kd(g),g.target,a(g,e.lockRef.current))},[]),m=p.useCallback(function(g){c(g.type,gs(g),g.target,a(g,e.lockRef.current))},[]);p.useEffect(function(){return jr.push(s),e.setCallbacks({onScrollCapture:h,onWheelCapture:h,onTouchMoveCapture:m}),document.addEventListener("wheel",l,Ar),document.addEventListener("touchmove",l,Ar),document.addEventListener("touchstart",d,Ar),function(){jr=jr.filter(function(g){return g!==s}),document.removeEventListener("wheel",l,Ar),document.removeEventListener("touchmove",l,Ar),document.removeEventListener("touchstart",d,Ar)}},[]);var f=e.removeScrollBar,v=e.inert;return p.createElement(p.Fragment,null,v?p.createElement(s,{styles:c0(o)}):null,f?p.createElement(e0,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function f0(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const h0=zy(Fd,d0);var xs=p.forwardRef(function(e,t){return p.createElement(ps,Sn({},e,{ref:t,sideCar:h0}))});xs.classNames=ps.classNames;var xa=["Enter"," "],p0=["ArrowDown","PageUp","Home"],Gd=["ArrowUp","PageDown","End"],m0=[...p0,...Gd],g0={ltr:[...xa,"ArrowRight"],rtl:[...xa,"ArrowLeft"]},x0={ltr:["ArrowLeft"],rtl:["ArrowRight"]},ao="Menu",[lo,v0,b0]=Xo(ao),[tr,Yd]=ln(ao,[b0,Er,jd]),vs=Er(),Xd=jd(),[w0,nr]=tr(ao),[y0,co]=tr(ao),Jd=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=vs(t),[l,c]=p.useState(null),d=p.useRef(!1),h=ft(s),m=Jo(o);return p.useEffect(()=>{const f=()=>{d.current=!0,document.addEventListener("pointerdown",v,{capture:!0,once:!0}),document.addEventListener("pointermove",v,{capture:!0,once:!0})},v=()=>d.current=!1;return document.addEventListener("keydown",f,{capture:!0}),()=>{document.removeEventListener("keydown",f,{capture:!0}),document.removeEventListener("pointerdown",v,{capture:!0}),document.removeEventListener("pointermove",v,{capture:!0})}},[]),u.jsx(sa,{...a,children:u.jsx(w0,{scope:t,open:n,onOpenChange:h,content:l,onContentChange:c,children:u.jsx(y0,{scope:t,onClose:p.useCallback(()=>h(!1),[h]),isUsingKeyboardRef:d,dir:m,modal:i,children:r})})})};Jd.displayName=ao;var S0="MenuAnchor",va=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=vs(n);return u.jsx(ia,{...o,...r,ref:t})});va.displayName=S0;var ba="MenuPortal",[C0,Zd]=tr(ba,{forceMount:void 0}),Qd=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=nr(ba,t);return u.jsx(C0,{scope:t,forceMount:n,children:u.jsx(zt,{present:n||s.open,children:u.jsx(so,{asChild:!0,container:o,children:r})})})};Qd.displayName=ba;var en="MenuContent",[T0,wa]=tr(en),ef=p.forwardRef((e,t)=>{const n=Zd(en,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=nr(en,e.__scopeMenu),i=co(en,e.__scopeMenu);return u.jsx(lo.Provider,{scope:e.__scopeMenu,children:u.jsx(zt,{present:r||s.open,children:u.jsx(lo.Slot,{scope:e.__scopeMenu,children:i.modal?u.jsx(k0,{...o,ref:t}):u.jsx(E0,{...o,ref:t})})})})}),k0=p.forwardRef((e,t)=>{const n=nr(en,e.__scopeMenu),r=p.useRef(null),o=Oe(t,r);return p.useEffect(()=>{const s=r.current;if(s)return fa(s)},[]),u.jsx(ya,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:ie(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),E0=p.forwardRef((e,t)=>{const n=nr(en,e.__scopeMenu);return u.jsx(ya,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),I0=qt.createSlot("MenuContent.ScrollLock"),ya=p.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:h,onInteractOutside:m,onDismiss:f,disableOutsideScroll:v,...g}=e,x=nr(en,n),y=co(en,n),w=vs(n),S=Xd(n),k=v0(n),[C,T]=p.useState(null),E=p.useRef(null),j=Oe(t,E,x.onContentChange),P=p.useRef(0),D=p.useRef(""),F=p.useRef(0),W=p.useRef(null),G=p.useRef("right"),A=p.useRef(0),X=v?xs:p.Fragment,q=v?{as:I0,allowPinchZoom:!0}:void 0,B=I=>{var z,$;const H=D.current+I,Y=k().filter(ee=>!ee.disabled),_=document.activeElement,O=(z=Y.find(ee=>ee.ref.current===_))==null?void 0:z.textValue,M=Y.map(ee=>ee.textValue),L=F0(M,H,O),te=($=Y.find(ee=>ee.textValue===L))==null?void 0:$.ref.current;(function ee(J){D.current=J,window.clearTimeout(P.current),J!==""&&(P.current=window.setTimeout(()=>ee(""),1e3))})(H),te&&setTimeout(()=>te.focus())};p.useEffect(()=>()=>window.clearTimeout(P.current),[]),Ui();const R=p.useCallback(I=>{var Y,_;return G.current===((Y=W.current)==null?void 0:Y.side)&&z0(I,(_=W.current)==null?void 0:_.area)},[]);return u.jsx(T0,{scope:n,searchRef:D,onItemEnter:p.useCallback(I=>{R(I)&&I.preventDefault()},[R]),onItemLeave:p.useCallback(I=>{var H;R(I)||((H=E.current)==null||H.focus(),T(null))},[R]),onTriggerLeave:p.useCallback(I=>{R(I)&&I.preventDefault()},[R]),pointerGraceTimerRef:F,onPointerGraceIntentChange:p.useCallback(I=>{W.current=I},[]),children:u.jsx(X,{...q,children:u.jsx(Zo,{asChild:!0,trapped:o,onMountAutoFocus:ie(s,I=>{var H;I.preventDefault(),(H=E.current)==null||H.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:u.jsx(yr,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:h,onInteractOutside:m,onDismiss:f,children:u.jsx(Iy,{asChild:!0,...S,dir:y.dir,orientation:"vertical",loop:r,currentTabStopId:C,onCurrentTabStopIdChange:T,onEntryFocus:ie(l,I=>{y.isUsingKeyboardRef.current||I.preventDefault()}),preventScrollOnEntryFocus:!0,children:u.jsx(aa,{role:"menu","aria-orientation":"vertical","data-state":vf(x.open),"data-radix-menu-content":"",dir:y.dir,...w,...g,ref:j,style:{outline:"none",...g.style},onKeyDown:ie(g.onKeyDown,I=>{const Y=I.target.closest("[data-radix-menu-content]")===I.currentTarget,_=I.ctrlKey||I.altKey||I.metaKey,O=I.key.length===1;Y&&(I.key==="Tab"&&I.preventDefault(),!_&&O&&B(I.key));const M=E.current;if(I.target!==M||!m0.includes(I.key))return;I.preventDefault();const te=k().filter(z=>!z.disabled).map(z=>z.ref.current);Gd.includes(I.key)&&te.reverse(),L0(te)}),onBlur:ie(e.onBlur,I=>{I.currentTarget.contains(I.target)||(window.clearTimeout(P.current),D.current="")}),onPointerMove:ie(e.onPointerMove,fo(I=>{const H=I.target,Y=A.current!==I.clientX;if(I.currentTarget.contains(H)&&Y){const _=I.clientX>A.current?"right":"left";G.current=_,A.current=I.clientX}}))})})})})})})});ef.displayName=en;var N0="MenuGroup",Sa=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(ge.div,{role:"group",...r,ref:t})});Sa.displayName=N0;var A0="MenuLabel",tf=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(ge.div,{...r,ref:t})});tf.displayName=A0;var bs="MenuItem",nf="menu.itemSelect",ws=p.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=p.useRef(null),i=co(bs,e.__scopeMenu),a=wa(bs,e.__scopeMenu),l=Oe(t,s),c=p.useRef(!1),d=()=>{const h=s.current;if(!n&&h){const m=new CustomEvent(nf,{bubbles:!0,cancelable:!0});h.addEventListener(nf,f=>r==null?void 0:r(f),{once:!0}),Bi(h,m),m.defaultPrevented?c.current=!1:i.onClose()}};return u.jsx(rf,{...o,ref:l,disabled:n,onClick:ie(e.onClick,d),onPointerDown:h=>{var m;(m=e.onPointerDown)==null||m.call(e,h),c.current=!0},onPointerUp:ie(e.onPointerUp,h=>{var m;c.current||(m=h.currentTarget)==null||m.click()}),onKeyDown:ie(e.onKeyDown,h=>{const m=a.searchRef.current!=="";n||m&&h.key===" "||xa.includes(h.key)&&(h.currentTarget.click(),h.preventDefault())})})});ws.displayName=bs;var rf=p.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=wa(bs,n),a=Xd(n),l=p.useRef(null),c=Oe(t,l),[d,h]=p.useState(!1),[m,f]=p.useState("");return p.useEffect(()=>{const v=l.current;v&&f((v.textContent??"").trim())},[s.children]),u.jsx(lo.ItemSlot,{scope:n,disabled:r,textValue:o??m,children:u.jsx(Ny,{asChild:!0,...a,focusable:!r,children:u.jsx(ge.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:c,onPointerMove:ie(e.onPointerMove,fo(v=>{r?i.onItemLeave(v):(i.onItemEnter(v),v.defaultPrevented||v.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:ie(e.onPointerLeave,fo(v=>i.onItemLeave(v))),onFocus:ie(e.onFocus,()=>h(!0)),onBlur:ie(e.onBlur,()=>h(!1))})})})}),j0="MenuCheckboxItem",of=p.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return u.jsx(uf,{scope:e.__scopeMenu,checked:n,children:u.jsx(ws,{role:"menuitemcheckbox","aria-checked":ys(n)?"mixed":n,...o,ref:t,"data-state":Ta(n),onSelect:ie(o.onSelect,()=>r==null?void 0:r(ys(n)?!0:!n),{checkForDefaultPrevented:!1})})})});of.displayName=j0;var sf="MenuRadioGroup",[P0,_0]=tr(sf,{value:void 0,onValueChange:()=>{}}),af=p.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=ft(r);return u.jsx(P0,{scope:e.__scopeMenu,value:n,onValueChange:s,children:u.jsx(Sa,{...o,ref:t})})});af.displayName=sf;var lf="MenuRadioItem",cf=p.forwardRef((e,t)=>{const{value:n,...r}=e,o=_0(lf,e.__scopeMenu),s=n===o.value;return u.jsx(uf,{scope:e.__scopeMenu,checked:s,children:u.jsx(ws,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":Ta(s),onSelect:ie(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});cf.displayName=lf;var Ca="MenuItemIndicator",[uf,R0]=tr(Ca,{checked:!1}),df=p.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=R0(Ca,n);return u.jsx(zt,{present:r||ys(s.checked)||s.checked===!0,children:u.jsx(ge.span,{...o,ref:t,"data-state":Ta(s.checked)})})});df.displayName=Ca;var M0="MenuSeparator",ff=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(ge.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});ff.displayName=M0;var O0="MenuArrow",hf=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=vs(n);return u.jsx(la,{...o,...r,ref:t})});hf.displayName=O0;var D0="MenuSub",[AN,pf]=tr(D0),uo="MenuSubTrigger",mf=p.forwardRef((e,t)=>{const n=nr(uo,e.__scopeMenu),r=co(uo,e.__scopeMenu),o=pf(uo,e.__scopeMenu),s=wa(uo,e.__scopeMenu),i=p.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,c={__scopeMenu:e.__scopeMenu},d=p.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return p.useEffect(()=>d,[d]),p.useEffect(()=>{const h=a.current;return()=>{window.clearTimeout(h),l(null)}},[a,l]),u.jsx(va,{asChild:!0,...c,children:u.jsx(rf,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":vf(n.open),...e,ref:On(t,o.onTriggerChange),onClick:h=>{var m;(m=e.onClick)==null||m.call(e,h),!(e.disabled||h.defaultPrevented)&&(h.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:ie(e.onPointerMove,fo(h=>{s.onItemEnter(h),!h.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(s.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),d()},100))})),onPointerLeave:ie(e.onPointerLeave,fo(h=>{var f,v;d();const m=(f=n.content)==null?void 0:f.getBoundingClientRect();if(m){const g=(v=n.content)==null?void 0:v.dataset.side,x=g==="right",y=x?-5:5,w=m[x?"left":"right"],S=m[x?"right":"left"];s.onPointerGraceIntentChange({area:[{x:h.clientX+y,y:h.clientY},{x:w,y:m.top},{x:S,y:m.top},{x:S,y:m.bottom},{x:w,y:m.bottom}],side:g}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(h),h.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:ie(e.onKeyDown,h=>{var f;const m=s.searchRef.current!=="";e.disabled||m&&h.key===" "||g0[r.dir].includes(h.key)&&(n.onOpenChange(!0),(f=n.content)==null||f.focus(),h.preventDefault())})})})});mf.displayName=uo;var gf="MenuSubContent",xf=p.forwardRef((e,t)=>{const n=Zd(en,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=nr(en,e.__scopeMenu),i=co(en,e.__scopeMenu),a=pf(gf,e.__scopeMenu),l=p.useRef(null),c=Oe(t,l);return u.jsx(lo.Provider,{scope:e.__scopeMenu,children:u.jsx(zt,{present:r||s.open,children:u.jsx(lo.Slot,{scope:e.__scopeMenu,children:u.jsx(ya,{id:a.contentId,"aria-labelledby":a.triggerId,...o,ref:c,align:"start",side:i.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:d=>{var h;i.isUsingKeyboardRef.current&&((h=l.current)==null||h.focus()),d.preventDefault()},onCloseAutoFocus:d=>d.preventDefault(),onFocusOutside:ie(e.onFocusOutside,d=>{d.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:ie(e.onEscapeKeyDown,d=>{i.onClose(),d.preventDefault()}),onKeyDown:ie(e.onKeyDown,d=>{var f;const h=d.currentTarget.contains(d.target),m=x0[i.dir].includes(d.key);h&&m&&(s.onOpenChange(!1),(f=a.trigger)==null||f.focus(),d.preventDefault())})})})})})});xf.displayName=gf;function vf(e){return e?"open":"closed"}function ys(e){return e==="indeterminate"}function Ta(e){return ys(e)?"indeterminate":e?"checked":"unchecked"}function L0(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function $0(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function F0(e,t,n){const o=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=$0(e,Math.max(s,0));o.length===1&&(i=i.filter(c=>c!==n));const l=i.find(c=>c.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function B0(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const a=t[s],l=t[i],c=a.x,d=a.y,h=l.x,m=l.y;d>r!=m>r&&n<(h-c)*(r-d)/(m-d)+c&&(o=!o)}return o}function z0(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return B0(n,t)}function fo(e){return t=>t.pointerType==="mouse"?e(t):void 0}var H0=Jd,U0=va,W0=Qd,V0=ef,K0=Sa,q0=tf,G0=ws,Y0=of,X0=af,J0=cf,Z0=df,Q0=ff,eS=hf,tS=mf,nS=xf,Ss="DropdownMenu",[rS,jN]=ln(Ss,[Yd]),Dt=Yd(),[oS,bf]=rS(Ss),wf=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,l=Dt(t),c=p.useRef(null),[d,h]=Dn({prop:o,defaultProp:s??!1,onChange:i,caller:Ss});return u.jsx(oS,{scope:t,triggerId:Pt(),triggerRef:c,contentId:Pt(),open:d,onOpenChange:h,onOpenToggle:p.useCallback(()=>h(m=>!m),[h]),modal:a,children:u.jsx(H0,{...l,open:d,onOpenChange:h,dir:r,modal:a,children:n})})};wf.displayName=Ss;var yf="DropdownMenuTrigger",Sf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=bf(yf,n),i=Dt(n);return u.jsx(U0,{asChild:!0,...i,children:u.jsx(ge.button,{type:"button",id:s.triggerId,"aria-haspopup":"menu","aria-expanded":s.open,"aria-controls":s.open?s.contentId:void 0,"data-state":s.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...o,ref:On(t,s.triggerRef),onPointerDown:ie(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:ie(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});Sf.displayName=yf;var sS="DropdownMenuPortal",Cf=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Dt(t);return u.jsx(W0,{...r,...n})};Cf.displayName=sS;var Tf="DropdownMenuContent",kf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=bf(Tf,n),s=Dt(n),i=p.useRef(!1);return u.jsx(V0,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:ie(e.onCloseAutoFocus,a=>{var l;i.current||(l=o.triggerRef.current)==null||l.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:ie(e.onInteractOutside,a=>{const l=a.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0,d=l.button===2||c;(!o.modal||d)&&(i.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});kf.displayName=Tf;var iS="DropdownMenuGroup",aS=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(K0,{...o,...r,ref:t})});aS.displayName=iS;var lS="DropdownMenuLabel",Ef=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(q0,{...o,...r,ref:t})});Ef.displayName=lS;var cS="DropdownMenuItem",If=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(G0,{...o,...r,ref:t})});If.displayName=cS;var uS="DropdownMenuCheckboxItem",Nf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(Y0,{...o,...r,ref:t})});Nf.displayName=uS;var dS="DropdownMenuRadioGroup",fS=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(X0,{...o,...r,ref:t})});fS.displayName=dS;var hS="DropdownMenuRadioItem",Af=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(J0,{...o,...r,ref:t})});Af.displayName=hS;var pS="DropdownMenuItemIndicator",jf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(Z0,{...o,...r,ref:t})});jf.displayName=pS;var mS="DropdownMenuSeparator",Pf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(Q0,{...o,...r,ref:t})});Pf.displayName=mS;var gS="DropdownMenuArrow",xS=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(eS,{...o,...r,ref:t})});xS.displayName=gS;var vS="DropdownMenuSubTrigger",_f=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(tS,{...o,...r,ref:t})});_f.displayName=vS;var bS="DropdownMenuSubContent",Rf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(nS,{...o,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Rf.displayName=bS;var wS=wf,yS=Sf,SS=Cf,Mf=kf,Of=Ef,Df=If,Lf=Nf,$f=Af,Ff=jf,Bf=Pf,zf=_f,Hf=Rf;const Cs=wS,Ts=yS,CS=p.forwardRef(({className:e,inset:t,children:n,...r},o)=>u.jsxs(zf,{ref:o,className:oe("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",t&&"pl-8",e),...r,children:[n,u.jsx(ae.ChevronRight,{className:"ml-auto h-4 w-4"})]}));CS.displayName=zf.displayName;const TS=p.forwardRef(({className:e,...t},n)=>u.jsx(Hf,{ref:n,className:oe("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...t}));TS.displayName=Hf.displayName;const ho=p.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(SS,{children:u.jsx(Mf,{ref:r,sideOffset:t,className:oe("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n})}));ho.displayName=Mf.displayName;const Bn=p.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(Df,{ref:r,className:oe("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...n}));Bn.displayName=Df.displayName;const kS=p.forwardRef(({className:e,children:t,checked:n,...r},o)=>u.jsxs(Lf,{ref:o,className:oe("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:n,...r,children:[u.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx(Ff,{children:u.jsx(ae.Check,{className:"h-4 w-4"})})}),t]}));kS.displayName=Lf.displayName;const ES=p.forwardRef(({className:e,children:t,...n},r)=>u.jsxs($f,{ref:r,className:oe("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[u.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx(Ff,{children:u.jsx(ae.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));ES.displayName=$f.displayName;const IS=p.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(Of,{ref:r,className:oe("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));IS.displayName=Of.displayName;const NS=p.forwardRef(({className:e,...t},n)=>u.jsx(Bf,{ref:n,className:oe("-mx-1 my-1 h-px bg-muted",e),...t}));NS.displayName=Bf.displayName;const ka=p.forwardRef(({className:e,...t},n)=>u.jsx("textarea",{className:oe("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),ref:n,...t}));ka.displayName="Textarea";const AS=1e4;function Uf({initialValue:e="",editingMessageId:t=null,placeholder:n="Type your message...",isStreaming:r=!1,disabled:o=!1,maxLength:s=AS,value:i,onValueChange:a,onSend:l,onCancelEdit:c,onStop:d,className:h="",textareaClassName:m="",allowEmptySend:f=!1,sendButtonClassName:v,validate:g,onValidationError:x}){const y=i!==void 0,[w,S]=b.useState(e),k=(y?i:w)??"",[C,T]=b.useTransition(),E=b.useRef(null),j=b.useRef(0),P=b.useRef(null),D=b.useRef("");b.useEffect(()=>{y||(S(e??""),P.current=null,E.current&&(E.current.style.height="auto",E.current.style.height=`${E.current.scrollHeight}px`))},[e,t,y]);const[F,W]=b.useState(null),G=b.useCallback(M=>M.length>s?`Message too long (${M.length}/${s} characters)`:null,[s]),A=b.useMemo(()=>g??G,[g,G]),X=b.useCallback(M=>{const L=A(M);return W(L),x==null||x(L),D.current=M,L},[A,x]),q=b.useCallback(()=>{const M=E.current;M&&(M.style.height="auto",M.style.height=`${M.scrollHeight}px`)},[]);b.useEffect(()=>{q()},[q,k]),b.useEffect(()=>{if(!F)return;const M=(k??"").trim();D.current!==M&&X(M)},[k,F,X]);const B=b.useCallback((M,{fromUser:L})=>{y||S(M),L&&(a==null||a(M))},[y,a]),R=b.useCallback(async M=>{M&&M.preventDefault();const L=(k??"").trim();if(!L&&!f||X(L))return;const te=++j.current;P.current={id:te,shouldClear:!0},T(()=>{var z,$,ee;try{const J=l(L);J&&typeof J.then=="function"?J.then(()=>{var K,Q;((K=P.current)==null?void 0:K.id)===te&&P.current.shouldClear&&(y||(S(""),E.current&&(E.current.style.height="auto"),a==null||a(""))),((Q=P.current)==null?void 0:Q.id)===te&&(P.current=null)}).catch(()=>{var K;((K=P.current)==null?void 0:K.id)===te&&(P.current=null)}):(((z=P.current)==null?void 0:z.id)===te&&P.current.shouldClear&&(y||(S(""),E.current&&(E.current.style.height="auto"),a==null||a(""))),(($=P.current)==null?void 0:$.id)===te&&(P.current=null))}catch{((ee=P.current)==null?void 0:ee.id)===te&&(P.current=null)}})},[k,l,f,y,a,X]),I=b.useCallback(M=>{const L=M.target.value;B(L,{fromUser:!0}),P.current&&(P.current.shouldClear=!1),E.current&&(E.current.style.height="auto",E.current.style.height=`${E.current.scrollHeight}px`),F&&X(L.trim())},[B,X,F]),H=b.useCallback(M=>{M.key==="Enter"&&!M.shiftKey?(M.preventDefault(),R()):M.key==="Escape"&&t&&(M.preventDefault(),c==null||c())},[R,t,c]),O=`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${t?"border-[hsl(var(--ring))] bg-[hsl(var(--card))] text-[hsl(var(--card-foreground))] dark:bg-[hsl(var(--card))] dark:text-[hsl(var(--card-foreground))]":""} ${m}`;return u.jsx("form",{onSubmit:M=>void R(M),className:`w-full ${h}`,children:u.jsxs("div",{className:"flex items-end gap-2",children:[u.jsxs("div",{className:"flex-1",children:[u.jsx(ka,{ref:E,value:k,onChange:I,onKeyDown:H,placeholder:t?"Edit your message...":n,className:O,disabled:o,maxLength:s,rows:1,spellCheck:!1,autoCorrect:"off"}),F&&u.jsx("p",{className:"mt-1 text-xs text-destructive font-medium",children:F})]}),u.jsx("div",{children:r?u.jsx(Je,{type:"button",onClick:()=>{d==null||d()},size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",disabled:o||!d,children:u.jsx(ae.Square,{size:16})}):u.jsx(Je,{type:"submit",size:"icon",className:`shrink-0 ${v??""}`,title:t?"Save changes":"Send message",disabled:o||!k.trim()&&!f||C,children:u.jsx(ae.Send,{size:16})})})]})})}const jS=b.memo(Uf);function Wf({composerValue:e,onComposerChange:t,onSend:n,onCancelEdit:r,onStop:o,editingMessageId:s=null,editingInitialValue:i="",placeholder:a="Type your message...",isStreaming:l=!1,disabled:c=!1,textareaClassName:d="",customStyles:h={},enableFileUpload:m=!1,enableExcelUpload:f=!1,onExcelUpload:v,onError:g,allowEmptySend:x=!1,inputError:y=null}){const[w,S]=b.useState([]),k=b.useRef(null),C=b.useRef(null),[T,E]=b.useState(0),[j,P]=b.useState(0),[D,F]=b.useState(!1),[W,G]=b.useState(null),[A,X]=b.useState(null),q=b.useCallback(()=>{k.current&&(k.current.value=""),C.current&&(C.current.value=""),E(M=>M+1),P(M=>M+1)},[]),B=b.useCallback(M=>{S(L=>[...L,...M])},[]),R=b.useCallback(M=>{const L=Array.from(M.target.files||[]);B(L),M.target.value=""},[B]),I=b.useCallback(M=>{S(L=>{const te=L.filter((z,$)=>$!==M);return te.length===0&&q(),te})},[q]),H=b.useCallback(async M=>{const L=(M.target.files||[])[0];if(L&&(G(null),X(null),!!v)){F(!0);try{await v(L),G(`Uploaded ${L.name} - processing through chat stream`)}catch(te){const z=te instanceof Error?te.message:"Failed to upload Excel file";X(z),g==null||g(z)}finally{F(!1),M.target.value="",q()}}},[v,g,q]),Y=b.useMemo(()=>x||w.length>0,[x,w]),_=b.useCallback(async M=>{const L=n(M,w);try{const te=await L;return w.length>0&&(S([]),q()),te}catch(te){throw te}},[n,q,w]),O=`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${s?"border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50":""} ${y?"border-red-400":""} ${h.textarea||""} ${d}`;return u.jsxs(u.Fragment,{children:[(m||f)&&u.jsxs("div",{className:"mb-3 space-y-3",children:[m&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:k,type:"file",multiple:!0,onChange:R,className:"hidden"},T),w.length>0&&u.jsx("div",{className:"flex flex-wrap gap-2",children:w.map((M,L)=>u.jsxs("div",{className:"flex items-center gap-2 bg-gray-100 dark:bg-gray-800 rounded-lg px-3 py-2 text-sm text-gray-900 dark:text-gray-100",children:[u.jsx(ae.Paperclip,{size:14}),u.jsx("span",{className:"truncate max-w-[150px]",children:M.name}),u.jsx(Je,{variant:"ghost",size:"sm",onClick:()=>I(L),className:"h-4 w-4 p-0 text-gray-500 dark:text-gray-400 hover:text-red-500 dark:hover:text-red-400","aria-label":`Remove ${M.name}`,children:u.jsx(ae.X,{size:12})})]},L))})]}),f&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:C,type:"file",accept:".xls,.xlsx,.xlsm",onChange:H,className:"hidden"},j),D&&u.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(ae.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),W&&!D&&u.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:W}),A&&!D&&u.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:A})]})]}),u.jsxs("div",{className:"flex items-end gap-2",children:[(m||f)&&u.jsxs(Cs,{children:[u.jsx(Ts,{asChild:!0,children:u.jsx(Je,{type:"button",size:"icon",variant:"outline",disabled:l||c,title:"More input actions",className:h.moreButton||"",children:u.jsx(ae.Plus,{size:16})})}),u.jsxs(ho,{align:"start",sideOffset:6,className:"w-52",children:[m&&u.jsxs(Bn,{onClick:()=>{var M;return(M=k.current)==null?void 0:M.click()},className:"cursor-pointer",children:[u.jsx(ae.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),f&&u.jsxs(Bn,{onClick:()=>{var M;D||(M=C.current)==null||M.click()},className:`cursor-pointer ${D?"opacity-60 pointer-events-none":""}`,children:[u.jsx(ae.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),u.jsx("div",{className:"flex-1",children:u.jsx(jS,{initialValue:i,editingMessageId:s,value:e,onValueChange:t,placeholder:s?"Edit your message...":a,isStreaming:l,disabled:c,onSend:_,onCancelEdit:r,onStop:o,allowEmptySend:Y,textareaClassName:O,sendButtonClassName:h.sendButton})})]})]})}const PS=b.memo(Wf),ks=0,zn=1,Pr=2,Vf=4;function Kf(e){return()=>e}function _S(e){e()}function qf(e,t){return n=>e(t(n))}function Gf(e,t){return()=>e(t)}function RS(e,t){return n=>e(t,n)}function Ea(e){return e!==void 0}function MS(...e){return()=>{e.map(_S)}}function _r(){}function Es(e,t){return t(e),e}function OS(e,t){return t(e)}function rt(...e){return e}function Ye(e,t){return e(zn,t)}function Pe(e,t){e(ks,t)}function Ia(e){e(Pr)}function ht(e){return e(Vf)}function xe(e,t){return Ye(e,RS(t,ks))}function dn(e,t){const n=e(zn,r=>{n(),t(r)});return n}function Yf(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function Xf(e,t){return e===t}function ot(e=Xf){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function Ee(e){return t=>n=>{e(n)&&t(n)}}function ue(e){return t=>qf(t,e)}function Cn(e){return t=>()=>{t(e)}}function ne(e,...t){const n=DS(...t);return(r,o)=>{switch(r){case Pr:Ia(e);return;case zn:return Ye(e,n(o))}}}function Tn(e,t){return n=>r=>{n(t=e(t,r))}}function rr(e){return t=>n=>{e>0?e--:t(n)}}function Pn(e){let t=null,n;return r=>o=>{t=o,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function De(...e){const t=new Array(e.length);let n=0,r=null;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const a=Math.pow(2,i);Ye(s,l=>{const c=n;n=n|a,t[i]=l,c!==o&&n===o&&r&&(r(),r=null)})}),s=>i=>{const a=()=>{s([i].concat(t))};n===o?a():r=a}}function DS(...e){return t=>e.reduceRight(OS,t)}function LS(e){let t,n;const r=()=>t==null?void 0:t();return function(o,s){switch(o){case zn:return s?n===s?void 0:(r(),n=s,t=Ye(e,s),t):(r(),_r);case Pr:r(),n=null;return}}}function se(e){let t=e;const n=ze();return(r,o)=>{switch(r){case ks:t=o;break;case zn:{o(t);break}case Vf:return t}return n(r,o)}}function _t(e,t){return Es(se(t),n=>xe(e,n))}function ze(){const e=[];return(t,n)=>{switch(t){case ks:e.slice().forEach(r=>{r(n)});return;case Pr:e.splice(0,e.length);return;case zn:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}}}function Zt(e){return Es(ze(),t=>xe(e,t))}function qe(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:$S(),singleton:n}}const $S=()=>Symbol();function FS(e){const t=new Map,n=({constructor:r,dependencies:o,id:s,singleton:i})=>{if(i&&t.has(s))return t.get(s);const a=r(o.map(l=>n(l)));return i&&t.set(s,a),a};return n(e)}function xt(...e){const t=ze(),n=new Array(e.length);let r=0;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const a=Math.pow(2,i);Ye(s,l=>{n[i]=l,r=r|a,r===o&&Pe(t,n)})}),function(s,i){switch(s){case Pr:{Ia(t);return}case zn:return r===o&&i(n),Ye(t,i)}}}function Ce(e,t=Xf){return ne(e,ot(t))}function Na(...e){return function(t,n){switch(t){case Pr:return;case zn:return MS(...e.map(r=>Ye(r,n)))}}}var Ht=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(Ht||{});const BS={0:"debug",3:"error",1:"log",2:"warn"},zS=()=>typeof globalThis>"u"?window:globalThis,Hn=qe(()=>{const e=se(3);return{log:se((t,n,r=1)=>{var o;const s=(o=zS().VIRTUOSO_LOG_LEVEL)!=null?o:ht(e);r>=s&&console[BS[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0});function or(e,t,n){return Aa(e,t,n).callbackRef}function Aa(e,t,n){const r=b.useRef(null);let o=i=>{};const s=b.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(i=>{const a=()=>{const l=i[0].target;l.offsetParent!==null&&e(l)};n?a():requestAnimationFrame(a)}):null,[e,n]);return o=i=>{i&&t?(s==null||s.observe(i),r.current=i):(r.current&&(s==null||s.unobserve(r.current)),r.current=null)},{callbackRef:o,ref:r}}function HS(e,t,n,r,o,s,i,a,l){const c=b.useCallback(d=>{const h=US(d.children,t,a?"offsetWidth":"offsetHeight",o);let m=d.parentElement;for(;!m.dataset.virtuosoScroller;)m=m.parentElement;const f=m.lastElementChild.dataset.viewportType==="window";let v;f&&(v=m.ownerDocument.defaultView);const g=i?a?i.scrollLeft:i.scrollTop:f?a?v.scrollX||v.document.documentElement.scrollLeft:v.scrollY||v.document.documentElement.scrollTop:a?m.scrollLeft:m.scrollTop,x=i?a?i.scrollWidth:i.scrollHeight:f?a?v.document.documentElement.scrollWidth:v.document.documentElement.scrollHeight:a?m.scrollWidth:m.scrollHeight,y=i?a?i.offsetWidth:i.offsetHeight:f?a?v.innerWidth:v.innerHeight:a?m.offsetWidth:m.offsetHeight;r({scrollHeight:x,scrollTop:Math.max(g,0),viewportHeight:y}),s==null||s(a?Jf("column-gap",getComputedStyle(d).columnGap,o):Jf("row-gap",getComputedStyle(d).rowGap,o)),h!==null&&e(h)},[e,t,o,s,i,r,a]);return Aa(c,n,l)}function US(e,t,n,r){const o=e.length;if(o===0)return null;const s=[];for(let i=0;i<o;i++){const a=e.item(i);if(a.dataset.index===void 0)continue;const l=parseInt(a.dataset.index),c=parseFloat(a.dataset.knownSize),d=t(a,n);if(d===0&&r("Zero-sized element, this should not happen",{child:a},Ht.ERROR),d===c)continue;const h=s[s.length-1];s.length===0||h.size!==d||h.endIndex!==l-1?s.push({endIndex:l,size:d,startIndex:l}):s[s.length-1].endIndex++}return s}function Jf(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Ht.WARN),t==="normal"?0:parseInt(t??"0",10)}function Zf(e,t,n){const r=b.useRef(null),o=b.useCallback(l=>{if(!(l!=null&&l.offsetParent))return;const c=l.getBoundingClientRect(),d=c.width;let h,m;if(t){const f=t.getBoundingClientRect(),v=c.top-f.top;m=f.height-Math.max(0,v),h=v+t.scrollTop}else{const f=i.current.ownerDocument.defaultView;m=f.innerHeight-Math.max(0,c.top),h=c.top+f.scrollY}r.current={offsetTop:h,visibleHeight:m,visibleWidth:d},e(r.current)},[e,t]),{callbackRef:s,ref:i}=Aa(o,!0,n),a=b.useCallback(()=>{o(i.current)},[o,i]);return b.useEffect(()=>{var l;if(t){t.addEventListener("scroll",a);const c=new ResizeObserver(()=>{requestAnimationFrame(a)});return c.observe(t),()=>{t.removeEventListener("scroll",a),c.unobserve(t)}}else{const c=(l=i.current)==null?void 0:l.ownerDocument.defaultView;return c==null||c.addEventListener("scroll",a),c==null||c.addEventListener("resize",a),()=>{c==null||c.removeEventListener("scroll",a),c==null||c.removeEventListener("resize",a)}}},[a,t,i]),s}const Lt=qe(()=>{const e=ze(),t=ze(),n=se(0),r=ze(),o=se(0),s=ze(),i=ze(),a=se(0),l=se(0),c=se(0),d=se(0),h=ze(),m=ze(),f=se(!1),v=se(!1),g=se(!1);return xe(ne(e,ue(({scrollTop:x})=>x)),t),xe(ne(e,ue(({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:f,scrollTo:h,scrollTop:t,skipAnimationFrameInResizeObserver:g,smoothScrollTargetReached:r,statefulScrollTop:o,viewportHeight:s}},[],{singleton:!0}),po={lvl:0};function Qf(e,t){const n=e.length;if(n===0)return[];let{index:r,value:o}=t(e[0]);const s=[];for(let i=1;i<n;i++){const{index:a,value:l}=t(e[i]);s.push({end:a-1,start:r,value:o}),r=a,o=l}return s.push({end:1/0,start:r,value:o}),s}function et(e){return e===po}function mo(e,t){if(!et(e))return t===e.k?e.v:t<e.k?mo(e.l,t):mo(e.r,t)}function fn(e,t,n="k"){if(et(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 et(e)?nh(t,n,1):t===e.k?wt(e,{k:t,v:n}):t<e.k?rh(wt(e,{l:Qt(e.l,t,n)})):rh(wt(e,{r:Qt(e.r,t,n)}))}function Rr(){return po}function Is(e,t,n){if(et(e))return[];const r=fn(e,t)[0];return WS(Pa(e,r,n))}function ja(e,t){if(et(e))return po;const{k:n,l:r,r:o}=e;if(t===n){if(et(r))return o;if(et(o))return r;{const[s,i]=th(r);return Ns(wt(e,{k:s,l:eh(r),v:i}))}}else return t<n?Ns(wt(e,{l:ja(r,t)})):Ns(wt(e,{r:ja(o,t)}))}function sr(e){return et(e)?[]:[...sr(e.l),{k:e.k,v:e.v},...sr(e.r)]}function Pa(e,t,n){if(et(e))return[];const{k:r,l:o,r:s,v:i}=e;let a=[];return r>t&&(a=a.concat(Pa(o,t,n))),r>=t&&r<=n&&a.push({k:r,v:i}),r<=n&&(a=a.concat(Pa(s,t,n))),a}function Ns(e){const{l:t,lvl:n,r}=e;if(r.lvl>=n-1&&t.lvl>=n-1)return e;if(n>r.lvl+1){if(_a(t))return oh(wt(e,{lvl:n-1}));if(!et(t)&&!et(t.r))return wt(t.r,{l:wt(t,{r:t.r.l}),lvl:n,r:wt(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(_a(e))return Ra(wt(e,{lvl:n-1}));if(!et(r)&&!et(r.l)){const o=r.l,s=_a(o)?r.lvl-1:r.lvl;return wt(o,{l:wt(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:Ra(wt(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function wt(e,t){return nh(t.k!==void 0?t.k:e.k,t.v!==void 0?t.v:e.v,t.lvl!==void 0?t.lvl:e.lvl,t.l!==void 0?t.l:e.l,t.r!==void 0?t.r:e.r)}function eh(e){return et(e.r)?e.l:Ns(wt(e,{r:eh(e.r)}))}function _a(e){return et(e)||e.lvl>e.r.lvl}function th(e){return et(e.r)?[e.k,e.v]:th(e.r)}function nh(e,t,n,r=po,o=po){return{k:e,l:r,lvl:n,r:o,v:t}}function rh(e){return Ra(oh(e))}function oh(e){const{l:t}=e;return!et(t)&&t.lvl===e.lvl?wt(t,{r:wt(e,{l:t.r})}):e}function Ra(e){const{lvl:t,r:n}=e;return!et(n)&&!et(n.r)&&n.lvl===t&&n.r.lvl===t?wt(n,{l:wt(e,{r:n.l}),lvl:t+1}):e}function WS(e){return Qf(e,({k:t,v:n})=>({index:t,value:n}))}function sh(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function go(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const Ma=qe(()=>({recalcInProgress:se(!1)}),[],{singleton:!0});function ih(e,t,n){return e[As(e,t,n)]}function As(e,t,n,r=0){let o=e.length-1;for(;r<=o;){const s=Math.floor((r+o)/2),i=e[s],a=n(i,t);if(a===0)return s;if(a===-1){if(o-r<2)return s-1;o=s-1}else{if(o===r)return s;r=s+1}}throw new Error(`Failed binary finding record in array - ${e.join(",")}, searched for ${t}`)}function VS(e,t,n,r){const o=As(e,t,r),s=As(e,n,r,o);return e.slice(o,s+1)}function Un(e,t){return Math.round(e.getBoundingClientRect()[t])}function js(e){return!et(e.groupOffsetTree)}function Oa({index:e},t){return t===e?0:t<e?-1:1}function KS(){return{groupIndices:[],groupOffsetTree:Rr(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Rr()}}function qS(e,t){let n=et(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),et(e)){e=Qt(e,0,s);continue}const a=Is(e,i-1,o+1);if(a.some(eC(r)))continue;let l=!1,c=!1;for(const{end:d,start:h,value:m}of a)l?(o>=h||s===m)&&(e=ja(e,h)):(c=m!==s,l=!0),d>o&&o>=h&&m!==s&&(e=Qt(e,o+1,m));c&&(e=Qt(e,i,s))}return[e,n]}function GS(e){return typeof e.groupIndex<"u"}function YS({offset:e},t){return t===e?0:t<e?-1:1}function xo(e,t,n){if(t.length===0)return 0;const{index:r,offset:o,size:s}=ih(t,e,Oa),i=e-r,a=s*i+(i-1)*n+o;return a>0?a+n:a}function ah(e,t){if(!js(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function lh(e,t,n){if(GS(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=ah(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function XS(e,t,n,r=0){return r>0&&(t=Math.max(t,ih(e,r,Oa).offset)),Qf(VS(e,t,n,YS),QS)}function JS(e,[t,n,r,o]){t.length>0&&r("received item sizes",t,Ht.DEBUG);const s=e.sizeTree;let i=s,a=0;if(n.length>0&&et(s)&&t.length===2){const m=t[0].size,f=t[1].size;i=n.reduce((v,g)=>Qt(Qt(v,g,m),g+1,f),i)}else[i,a]=qS(i,t);if(i===s)return e;const{lastIndex:l,lastOffset:c,lastSize:d,offsetTree:h}=Da(e.offsetTree,a,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((m,f)=>Qt(m,f,xo(f,h,o)),Rr()),lastIndex:l,lastOffset:c,lastSize:d,offsetTree:h,sizeTree:i}}function ZS(e){return sr(e).map(({k:t,v:n},r,o)=>{const s=o[r+1];return{endIndex:s?s.k-1:1/0,size:n,startIndex:t}})}function ch(e,t){let n=0,r=0;for(;n<e;)n+=t[r+1]-t[r]-1,r++;return r-(n===e?0:1)}function Da(e,t,n,r){let o=e,s=0,i=0,a=0,l=0;if(t!==0){l=As(o,t-1,Oa),a=o[l].offset;const c=fn(n,t-1);s=c[0],i=c[1],o.length&&o[l].size===fn(n,t)[1]&&(l-=1),o=o.slice(0,l+1)}else o=[];for(const{start:c,value:d}of Is(n,t,1/0)){const h=c-s,m=h*i+a+h*r;o.push({index:c,offset:m,size:d}),s=c,a=m,i=d}return{lastIndex:s,lastOffset:a,lastSize:i,offsetTree:o}}function QS(e){return{index:e.index,value:e}}function eC(e){const{endIndex:t,size:n,startIndex:r}=e;return o=>o.start===r&&(o.end===t||o.end===1/0)&&o.value===n}const tC={offsetHeight:"height",offsetWidth:"width"},kn=qe(([{log:e},{recalcInProgress:t}])=>{const n=ze(),r=ze(),o=_t(r,0),s=ze(),i=ze(),a=se(0),l=se([]),c=se(void 0),d=se(void 0),h=se((C,T)=>Un(C,tC[T])),m=se(void 0),f=se(0),v=KS(),g=_t(ne(n,De(l,e,f),Tn(JS,v),ot()),v),x=_t(ne(l,ot(),Tn((C,T)=>({current:T,prev:C.current}),{current:[],prev:[]}),ue(({prev:C})=>C)),[]);xe(ne(l,Ee(C=>C.length>0),De(g,f),ue(([C,T,E])=>{const j=C.reduce((P,D,F)=>Qt(P,D,xo(D,T.offsetTree,E)||F),Rr());return{...T,groupIndices:C,groupOffsetTree:j}})),g),xe(ne(r,De(g),Ee(([C,{lastIndex:T}])=>C<T),ue(([C,{lastIndex:T,lastSize:E}])=>[{endIndex:T,size:E,startIndex:C}])),n),xe(c,d);const y=_t(ne(c,ue(C=>C===void 0)),!0);xe(ne(d,Ee(C=>C!==void 0&&et(ht(g).sizeTree)),ue(C=>[{endIndex:0,size:C,startIndex:0}])),n);const w=Zt(ne(n,De(g),Tn(({sizes:C},[T,E])=>({changed:E!==C,sizes:E}),{changed:!1,sizes:v}),ue(C=>C.changed)));Ye(ne(a,Tn((C,T)=>({diff:C.prev-T,prev:T}),{diff:0,prev:0}),ue(C=>C.diff)),C=>{const{groupIndices:T}=ht(g);if(C>0)Pe(t,!0),Pe(s,C+ch(C,T));else if(C<0){const E=ht(x);E.length>0&&(C-=ch(-C,E)),Pe(i,C)}}),Ye(ne(a,De(e)),([C,T])=>{C<0&&T("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:a},Ht.ERROR)});const S=Zt(s);xe(ne(s,De(g),ue(([C,T])=>{const E=T.groupIndices.length>0,j=[],P=T.lastSize;if(E){const D=mo(T.sizeTree,0);let F=0,W=0;for(;F<C;){const A=T.groupIndices[W],X=T.groupIndices.length===W+1?1/0:T.groupIndices[W+1]-A-1;j.push({endIndex:A,size:D,startIndex:A}),j.push({endIndex:A+1+X-1,size:P,startIndex:A+1}),W++,F+=X+1}const G=sr(T.sizeTree);return F!==C&&G.shift(),G.reduce((A,{k:X,v:q})=>{let B=A.ranges;return A.prevSize!==0&&(B=[...A.ranges,{endIndex:X+C-1,size:A.prevSize,startIndex:A.prevIndex}]),{prevIndex:X+C,prevSize:q,ranges:B}},{prevIndex:C,prevSize:0,ranges:j}).ranges}return sr(T.sizeTree).reduce((D,{k:F,v:W})=>({prevIndex:F+C,prevSize:W,ranges:[...D.ranges,{endIndex:F+C-1,size:D.prevSize,startIndex:D.prevIndex}]}),{prevIndex:0,prevSize:P,ranges:[]}).ranges})),n);const k=Zt(ne(i,De(g,f),ue(([C,{offsetTree:T},E])=>{const j=-C;return xo(j,T,E)})));return xe(ne(i,De(g,f),ue(([C,T,E])=>{if(T.groupIndices.length>0){if(et(T.sizeTree))return T;let j=Rr();const P=ht(x);let D=0,F=0,W=0;for(;D<-C;){W=P[F];const G=P[F+1]-W-1;F++,D+=G+1}if(j=sr(T.sizeTree).reduce((G,{k:A,v:X})=>Qt(G,Math.max(0,A+C),X),j),D!==-C){const G=mo(T.sizeTree,W);j=Qt(j,0,G);const A=fn(T.sizeTree,-C+1)[1];j=Qt(j,1,A)}return{...T,sizeTree:j,...Da(T.offsetTree,0,j,E)}}else{const j=sr(T.sizeTree).reduce((P,{k:D,v:F})=>Qt(P,Math.max(0,D+C),F),Rr());return{...T,sizeTree:j,...Da(T.offsetTree,0,j,E)}}})),g),{beforeUnshiftWith:S,data:m,defaultItemSize:d,firstItemIndex:a,fixedItemSize:c,gap:f,groupIndices:l,itemSize:h,listRefresh:w,shiftWith:i,shiftWithOffset:k,sizeRanges:n,sizes:g,statefulTotalCount:o,totalCount:r,trackItemSizes:y,unshiftWith:s}},rt(Hn,Ma),{singleton:!0});function nC(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const uh=qe(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=ze(),i=ze(),a=Zt(ne(s,ue(nC)));return xe(ne(a,ue(l=>l.totalCount)),n),xe(ne(a,ue(l=>l.groupIndices)),e),xe(ne(xt(o,t,r),Ee(([l,c])=>js(c)),ue(([l,c,d])=>fn(c.groupOffsetTree,Math.max(l-d,0),"v")[0]),ot(),ue(l=>[l])),i),{groupCounts:s,topItemsIndexes:i}},rt(kn,Lt)),Wn=qe(([{log:e}])=>{const t=se(!1),n=Zt(ne(t,Ee(r=>r),ot()));return Ye(t,r=>{r&&ht(e)("props updated",{},Ht.DEBUG)}),{didMount:n,propsReady:t}},rt(Hn),{singleton:!0}),rC=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function dh(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!rC)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const vo=qe(([{gap:e,listRefresh:t,sizes:n,totalCount:r},{fixedFooterHeight:o,fixedHeaderHeight:s,footerHeight:i,headerHeight:a,scrollingInProgress:l,scrollTo:c,smoothScrollTargetReached:d,viewportHeight:h},{log:m}])=>{const f=ze(),v=ze(),g=se(0);let x=null,y=null,w=null;function S(){x&&(x(),x=null),w&&(w(),w=null),y&&(clearTimeout(y),y=null),Pe(l,!1)}return xe(ne(f,De(n,h,r,g,a,i,m),De(e,s,o),ue(([[k,C,T,E,j,P,D,F],W,G,A])=>{const X=dh(k),{align:q,behavior:B,offset:R}=X,I=E-1,H=lh(X,C,I);let Y=xo(H,C.offsetTree,W)+P;q==="end"?(Y+=G+fn(C.sizeTree,H)[1]-T+A,H===I&&(Y+=D)):q==="center"?Y+=(G+fn(C.sizeTree,H)[1]-T+A)/2:Y-=j,R&&(Y+=R);const _=O=>{S(),O?(F("retrying to scroll to",{location:k},Ht.DEBUG),Pe(f,k)):(Pe(v,!0),F("list did not change, scroll successful",{},Ht.DEBUG))};if(S(),B==="smooth"){let O=!1;w=Ye(t,M=>{O=O||M}),x=dn(d,()=>{_(O)})}else x=dn(ne(t,oC(150)),_);return y=setTimeout(()=>{S()},1200),Pe(l,!0),F("scrolling from index to",{behavior:B,index:H,top:Y},Ht.DEBUG),{behavior:B,top:Y}})),c),{scrollTargetReached:v,scrollToIndex:f,topListHeight:g}},rt(kn,Lt,Hn),{singleton:!0});function oC(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function La(e,t){e==0?t():requestAnimationFrame(()=>{La(e-1,t)})}function $a(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const bo=qe(([{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,De(l),Ee(([d,h])=>!!h),Cn(!1)),a),xe(ne(i,De(l),Ee(([d,h])=>!!h),Cn(!1)),c),Ye(ne(xt(t,i),De(a,n,e,c),Ee(([[,d],h,{sizeTree:m},f,v])=>d&&(!et(m)||Ea(f))&&!h&&!v),De(l)),([,d])=>{dn(o,()=>{Pe(c,!0)}),La(4,()=>{dn(r,()=>{Pe(a,!0)}),Pe(s,d)})}),{initialItemFinalLocationReached:c,initialTopMostItemIndex:l,scrolledToInitialItem:a}},rt(kn,Lt,vo,Wn),{singleton:!0});function fh(e,t){return Math.abs(e-t)<1.01}const wo="up",yo="down",sC="none",iC={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},aC=0,So=qe(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=se(!1),a=se(!0),l=ze(),c=ze(),d=se(4),h=se(aC),m=_t(ne(Na(ne(Ce(o),rr(1),Cn(!0)),ne(Ce(o),rr(1),Cn(!1),Yf(100))),ot()),!1),f=_t(ne(Na(ne(n,Cn(!0)),ne(n,Cn(!1),Yf(200))),ot()),!1);xe(ne(xt(Ce(o),Ce(h)),ue(([w,S])=>w<=S),ot()),a),xe(ne(a,Pn(50)),c);const v=Zt(ne(xt(r,Ce(s),Ce(t),Ce(e),Ce(d)),Tn((w,[{scrollHeight:S,scrollTop:k},C,T,E,j])=>{const P=k+C-S>-j,D={scrollHeight:S,scrollTop:k,viewportHeight:C};if(P){let W,G;return k>w.state.scrollTop?(W="SCROLLED_DOWN",G=w.state.scrollTop-k):(W="SIZE_DECREASED",G=w.state.scrollTop-k||w.scrollTopDelta),{atBottom:!0,atBottomBecause:W,scrollTopDelta:G,state:D}}let F;return D.scrollHeight>w.state.scrollHeight?F="SIZE_INCREASED":C<w.state.viewportHeight?F="VIEWPORT_HEIGHT_DECREASING":k<w.state.scrollTop?F="SCROLLING_UPWARDS":F="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:F,state:D}},iC),ot((w,S)=>w&&w.atBottom===S.atBottom))),g=_t(ne(r,Tn((w,{scrollHeight:S,scrollTop:k,viewportHeight:C})=>{if(fh(w.scrollHeight,S))return{changed:!1,jump:0,scrollHeight:S,scrollTop:k};{const T=S-(k+C)<1;return w.scrollTop!==k&&T?{changed:!0,jump:w.scrollTop-k,scrollHeight:S,scrollTop:k}:{changed:!0,jump:0,scrollHeight:S,scrollTop:k}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),Ee(w=>w.changed),ue(w=>w.jump)),0);xe(ne(v,ue(w=>w.atBottom)),i),xe(ne(i,Pn(50)),l);const x=se(yo);xe(ne(r,ue(({scrollTop:w})=>w),ot(),Tn((w,S)=>ht(f)?{direction:w.direction,prevScrollTop:S}:{direction:S<w.prevScrollTop?wo:yo,prevScrollTop:S},{direction:yo,prevScrollTop:0}),ue(w=>w.direction)),x),xe(ne(r,Pn(50),Cn(sC)),x);const y=se(0);return xe(ne(m,Ee(w=>!w),Cn(0)),y),xe(ne(o,Pn(100),De(m),Ee(([w,S])=>!!S),Tn(([w,S],[k])=>[S,k],[0,0]),ue(([w,S])=>S-w)),y),{atBottomState:v,atBottomStateChange:l,atBottomThreshold:d,atTopStateChange:c,atTopThreshold:h,isAtBottom:i,isAtTop:a,isScrolling:m,lastJumpDueToItemResize:g,scrollDirection:x,scrollVelocity:y}},rt(Lt)),Ps="top",_s="bottom",hh="none";function ph(e,t,n){return typeof e=="number"?n===wo&&t===Ps||n===yo&&t===_s?e:0:n===wo?t===Ps?e.main:e.reverse:t===_s?e.main:e.reverse}function mh(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const Fa=qe(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=ze(),i=se(0),a=se(0),l=se(0),c=_t(ne(xt(Ce(r),Ce(o),Ce(n),Ce(s,go),Ce(l),Ce(i),Ce(t),Ce(e),Ce(a)),ue(([d,h,m,[f,v],g,x,y,w,S])=>{const k=d-w,C=x+y,T=Math.max(m-k,0);let E=hh;const j=mh(S,Ps),P=mh(S,_s);return f-=w,f+=m+y,v+=m+y,v-=w,f>d+C-j&&(E=wo),v<d-T+h+P&&(E=yo),E!==hh?[Math.max(k-m-ph(g,Ps,E)-j,0),k-T-y+h+ph(g,_s,E)+P]:null}),Ee(d=>d!=null),ot(go)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:l,topListHeight:i,visibleRange:c}},rt(Lt),{singleton:!0});function lC(e,t,n){if(js(t)){const r=ah(e,t);return[{index:fn(t.groupOffsetTree,r)[0],offset:0,size:0},{data:n==null?void 0:n[0],index:r,offset:0,size:0}]}return[{data:n==null?void 0:n[0],index:e,offset:0,size:0}]}const Ba={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Rs(e,t,n,r,o,s){const{lastIndex:i,lastOffset:a,lastSize:l}=o;let c=0,d=0;if(e.length>0){c=e[0].offset;const g=e[e.length-1];d=g.offset+g.size}const h=n-i,m=a+h*l+(h-1)*r,f=c,v=m-d;return{bottom:d,firstItemIndex:s,items:xh(e,o,s),offsetBottom:v,offsetTop:c,top:f,topItems:xh(t,o,s),topListHeight:t.reduce((g,x)=>x.size+g,0),totalCount:n}}function gh(e,t,n,r,o,s){let i=0;if(n.groupIndices.length>0)for(const d of n.groupIndices){if(d-i>=e)break;i++}const a=e+i,l=$a(t,a),c=Array.from({length:a}).map((d,h)=>({data:s[h+l],index:h+l,offset:0,size:0}));return Rs(c,[],a,o,n,r)}function xh(e,t,n){if(e.length===0)return[];if(!js(t))return e.map(c=>({...c,index:c.index+n,originalIndex:c.index}));const r=e[0].index,o=e[e.length-1].index,s=[],i=Is(t.groupOffsetTree,r,o);let a,l=0;for(const c of e){(!a||a.end<c.index)&&(a=i.shift(),l=t.groupIndices.indexOf(a.start));let d;c.index===a.start?d={index:l,type:"group"}:d={groupIndex:l,index:c.index-(l+1)+n},s.push({...d,data:c.data,offset:c.offset,originalIndex:c.index,size:c.size})}return s}const ir=qe(([{data:e,firstItemIndex:t,gap:n,sizes:r,totalCount:o},s,{listBoundary:i,topListHeight:a,visibleRange:l},{initialTopMostItemIndex:c,scrolledToInitialItem:d},{topListHeight:h},m,{didMount:f},{recalcInProgress:v}])=>{const g=se([]),x=se(0),y=ze();xe(s.topItemsIndexes,g);const w=_t(ne(xt(f,v,Ce(l,go),Ce(o),Ce(r),Ce(c),d,Ce(g),Ce(t),Ce(n),e),Ee(([T,E,,j,,,,,,,P])=>{const D=P&&P.length!==j;return T&&!E&&!D}),ue(([,,[T,E],j,P,D,F,W,G,A,X])=>{const q=P,{offsetTree:B,sizeTree:R}=q,I=ht(x);if(j===0)return{...Ba,totalCount:j};if(T===0&&E===0)return I===0?{...Ba,totalCount:j}:gh(I,D,P,G,A,X||[]);if(et(R))return I>0?null:Rs(lC($a(D,j),q,X),[],j,A,q,G);const H=[];if(W.length>0){const L=W[0],te=W[W.length-1];let z=0;for(const $ of Is(R,L,te)){const ee=$.value,J=Math.max($.start,L),K=Math.min($.end,te);for(let Q=J;Q<=K;Q++)H.push({data:X==null?void 0:X[Q],index:Q,offset:z,size:ee}),z+=ee}}if(!F)return Rs([],H,j,A,q,G);const Y=W.length>0?W[W.length-1]+1:0,_=XS(B,T,E,Y);if(_.length===0)return null;const O=j-1,M=Es([],L=>{for(const te of _){const z=te.value;let $=z.offset,ee=te.start;const J=z.size;if(z.offset<T){ee+=Math.floor((T-z.offset+A)/(J+A));const Q=ee-te.start;$+=Q*J+Q*A}ee<Y&&($+=(Y-ee)*J,ee=Y);const K=Math.min(te.end,O);for(let Q=ee;Q<=K&&!($>=E);Q++)L.push({data:X==null?void 0:X[Q],index:Q,offset:$,size:J}),$+=J+A}});return Rs(M,H,j,A,q,G)}),Ee(T=>T!==null),ot()),Ba);xe(ne(e,Ee(Ea),ue(T=>T==null?void 0:T.length)),o),xe(ne(w,ue(T=>T.topListHeight)),h),xe(h,a),xe(ne(w,ue(T=>[T.top,T.bottom])),i),xe(ne(w,ue(T=>T.items)),y);const S=Zt(ne(w,Ee(({items:T})=>T.length>0),De(o,e),Ee(([{items:T},E])=>T[T.length-1].originalIndex===E-1),ue(([,T,E])=>[T-1,E]),ot(go),ue(([T])=>T))),k=Zt(ne(w,Pn(200),Ee(({items:T,topItems:E})=>T.length>0&&T[0].originalIndex===E.length),ue(({items:T})=>T[0].index),ot())),C=Zt(ne(w,Ee(({items:T})=>T.length>0),ue(({items:T})=>{let E=0,j=T.length-1;for(;T[E].type==="group"&&E<j;)E++;for(;T[j].type==="group"&&j>E;)j--;return{endIndex:T[j].index,startIndex:T[E].index}}),ot(sh)));return{endReached:S,initialItemCount:x,itemsRendered:y,listState:w,rangeChanged:C,startReached:k,topItemsIndexes:g,...m}},rt(kn,uh,Fa,bo,vo,So,Wn,Ma),{singleton:!0}),vh=qe(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=ze(),i=_t(ne(xt(n,e,r,t,o),ue(([a,l,c,d,h])=>a+l+c+d+h.offsetBottom+h.bottom)),0);return xe(Ce(i),s),{totalListHeight:i,totalListHeightChanged:s}},rt(Lt,ir),{singleton:!0}),cC=qe(([{viewportHeight:e},{totalListHeight:t}])=>{const n=se(!1),r=_t(ne(xt(n,e,t),Ee(([o])=>o),ue(([,o,s])=>Math.max(0,o-s)),Pn(0),ot()),0);return{alignToBottom:n,paddingTopAddition:r}},rt(Lt,vh),{singleton:!0}),bh=qe(()=>({context:se(null)})),uC=({itemBottom:e,itemTop:t,locationParams:{align:n,behavior:r,...o},viewportBottom:s,viewportTop:i})=>t<i?{...o,align:n??"start",behavior:r}:e>s?{...o,align:n??"end",behavior:r}:null,wh=qe(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:s,scrollingInProgress:i,scrollTop:a,viewportHeight:l},{scrollToIndex:c}])=>{const d=ze();return xe(ne(d,De(t,l,n,s,o,r,a),De(e),ue(([[h,m,f,v,g,x,y,w],S])=>{const{align:k,behavior:C,calculateViewLocation:T=uC,done:E,...j}=h,P=lh(h,m,v-1),D=xo(P,m.offsetTree,S)+g+x,F=D+fn(m.sizeTree,P)[1],W=w+x,G=w+f-y,A=T({itemBottom:F,itemTop:D,locationParams:{align:k,behavior:C,...j},viewportBottom:G,viewportTop:W});return A?E&&dn(ne(i,Ee(X=>!X),rr(ht(i)?1:2)),E):E&&E(),A}),Ee(h=>h!==null)),c),{scrollIntoView:d}},rt(kn,Lt,vo,ir,Hn),{singleton:!0});function yh(e){return e?e==="smooth"?"smooth":"auto":!1}const dC=(e,t)=>typeof e=="function"?yh(e(t)):t&&yh(e),fC=qe(([{listRefresh:e,totalCount:t,fixedItemSize:n,data:r},{atBottomState:o,isAtBottom:s},{scrollToIndex:i},{scrolledToInitialItem:a},{didMount:l,propsReady:c},{log:d},{scrollingInProgress:h},{context:m},{scrollIntoView:f}])=>{const v=se(!1),g=ze();let x=null;function y(C){Pe(i,{align:"end",behavior:C,index:"LAST"})}Ye(ne(xt(ne(Ce(t),rr(1)),l),De(Ce(v),s,a,h),ue(([[C,T],E,j,P,D])=>{let F=T&&P,W="auto";return F&&(W=dC(E,j||D),F=F&&!!W),{followOutputBehavior:W,shouldFollow:F,totalCount:C}}),Ee(({shouldFollow:C})=>C)),({followOutputBehavior:C,totalCount:T})=>{x&&(x(),x=null),ht(n)?requestAnimationFrame(()=>{ht(d)("following output to ",{totalCount:T},Ht.DEBUG),y(C)}):x=dn(e,()=>{ht(d)("following output to ",{totalCount:T},Ht.DEBUG),y(C),x=null})});function w(C){const T=dn(o,E=>{C&&!E.atBottom&&E.notAtBottomBecause==="SIZE_INCREASED"&&!x&&(ht(d)("scrolling to bottom due to increased size",{},Ht.DEBUG),y("auto"))});setTimeout(T,100)}Ye(ne(xt(Ce(v),t,c),Ee(([C,,T])=>C&&T),Tn(({value:C},[,T])=>({refreshed:C===T,value:T}),{refreshed:!1,value:0}),Ee(({refreshed:C})=>C),De(v,t)),([,C])=>{ht(a)&&w(C!==!1)}),Ye(g,()=>{w(ht(v)!==!1)}),Ye(xt(Ce(v),o),([C,T])=>{C&&!T.atBottom&&T.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&y("auto")});const S=se(null),k=ze();return xe(Na(ne(Ce(r),ue(C=>{var T;return(T=C==null?void 0:C.length)!=null?T:0})),ne(Ce(t))),k),Ye(ne(xt(ne(k,rr(1)),l),De(Ce(S),a,h,m),ue(([[C,T],E,j,P,D])=>T&&j&&(E==null?void 0:E({context:D,totalCount:C,scrollingInProgress:P}))),Ee(C=>!!C),Pn(0)),C=>{x&&(x(),x=null),ht(n)?requestAnimationFrame(()=>{ht(d)("scrolling into view",{}),Pe(f,C)}):x=dn(e,()=>{ht(d)("scrolling into view",{}),Pe(f,C),x=null})}),{autoscrollToBottom:g,followOutput:v,scrollIntoViewOnChange:S}},rt(kn,So,vo,bo,Wn,Hn,Lt,bh,wh)),hC=qe(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(xe(ne(a,De(s),Ee(([,l])=>l!==0),De(o,r,t,n,e),ue(([[,l],c,d,h,m,f=[]])=>gh(l,c,d,h,m,f))),i),{}),rt(kn,bo,ir,Wn),{singleton:!0}),pC=qe(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=se(0);return Ye(ne(e,De(r),Ee(([,o])=>o!==0),ue(([,o])=>({top:o}))),o=>{dn(ne(n,rr(1),Ee(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{Pe(t,o)})})}),{initialScrollTop:r}},rt(Wn,Lt,ir),{singleton:!0}),Sh=qe(([{scrollVelocity:e}])=>{const t=se(!1),n=ze(),r=se(!1);return xe(ne(e,De(r,t,n),Ee(([o,s])=>!!s),ue(([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),Ye(ne(xt(t,e,n),De(r)),([[o,s,i],a])=>{o&&a&&a.change&&a.change(s,i)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},rt(So),{singleton:!0}),za=qe(([{scrollContainerState:e,scrollTo:t}])=>{const n=ze(),r=ze(),o=ze(),s=se(!1),i=se(void 0);return xe(ne(xt(n,r),ue(([{scrollHeight:a,scrollTop:l,viewportHeight:c},{offsetTop:d}])=>({scrollHeight:a,scrollTop:Math.max(0,l-d),viewportHeight:c}))),e),xe(ne(t,De(r),ue(([a,{offsetTop:l}])=>({...a,top:a.top+l}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},rt(Lt)),mC=qe(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:a,windowViewportRect:l}])=>{const c=ze(),d=se(void 0),h=se(null),m=se(null);return xe(a,h),xe(l,m),Ye(ne(c,De(t,r,i,h,m,n)),([f,v,g,x,y,w,S])=>{const k=ZS(v.sizeTree);x&&y!==null&&w!==null&&(g=y.scrollTop-w.offsetTop),g-=S,f({ranges:k,scrollTop:g})}),xe(ne(d,Ee(Ea),ue(gC)),o),xe(ne(s,De(d),Ee(([,f])=>f!==void 0),ot(),ue(([,f])=>f.ranges)),e),{getState:c,restoreStateFrom:d}},rt(kn,Lt,bo,Wn,za));function gC(e){return{align:"start",index:0,offset:e.scrollTop}}const xC=qe(([{topItemsIndexes:e}])=>{const t=se(0);return xe(ne(t,Ee(n=>n>=0),ue(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},rt(ir));function Ch(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const vC=Ch(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),bC=qe(([{deviation:e,scrollBy:t,scrollingInProgress:n,scrollTop:r},{isAtBottom:o,isScrolling:s,lastJumpDueToItemResize:i,scrollDirection:a},{listState:l},{beforeUnshiftWith:c,gap:d,shiftWithOffset:h,sizes:m},{log:f},{recalcInProgress:v}])=>{const g=Zt(ne(l,De(i),Tn(([,y,w,S],[{bottom:k,items:C,offsetBottom:T,totalCount:E},j])=>{const P=k+T;let D=0;return w===E&&y.length>0&&C.length>0&&(C[0].originalIndex===0&&y[0].originalIndex===0||(D=P-S,D!==0&&(D+=j))),[D,C,E,P]},[0,[],0,0]),Ee(([y])=>y!==0),De(r,a,n,o,f,v),Ee(([,y,w,S,,,k])=>!k&&!S&&y!==0&&w===wo),ue(([[y],,,,,w])=>(w("Upward scrolling compensation",{amount:y},Ht.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 Ye(ne(g,De(e,s)),([y,w,S])=>{S&&vC()?Pe(e,w-y):x(-y)}),Ye(ne(xt(_t(s,!1),e,v),Ee(([y,w,S])=>!y&&!S&&w!==0),ue(([y,w])=>w),Pn(1)),x),xe(ne(h,ue(y=>({top:-y}))),t),Ye(ne(c,De(m,d),ue(([y,{groupIndices:w,lastSize:S,sizeTree:k},C])=>{function T(E){return E*(S+C)}if(w.length===0)return T(y);{let E=0;const j=mo(k,0);let P=0,D=0;for(;P<y;){P++,E+=j;let F=w.length===D+1?1/0:w[D+1]-w[D]-1;P+F>y&&(E-=j,F=y-P+1),P+=F,E+=T(F),D++}return E}})),y=>{Pe(e,y),requestAnimationFrame(()=>{Pe(t,{top:y}),requestAnimationFrame(()=>{Pe(e,0),Pe(v,!1)})})}),{deviation:e}},rt(Lt,So,ir,kn,Hn,Ma)),wC=qe(([e,t,n,r,o,s,i,a,l,c,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...l,...c,...d}),rt(Fa,hC,Wn,Sh,vh,pC,cC,za,wh,Hn,bh)),Th=qe(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:r,gap:o,groupIndices:s,itemSize:i,sizeRanges:a,sizes:l,statefulTotalCount:c,totalCount:d,trackItemSizes:h},{initialItemFinalLocationReached:m,initialTopMostItemIndex:f,scrolledToInitialItem:v},g,x,y,{listState:w,topItemsIndexes:S,...k},{scrollToIndex:C},T,{topItemCount:E},{groupCounts:j},P])=>(xe(k.rangeChanged,P.scrollSeekRangeChanged),xe(ne(P.windowViewportRect,ue(D=>D.visibleHeight)),g.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,gap:o,groupCounts:j,initialItemFinalLocationReached:m,initialTopMostItemIndex:f,scrolledToInitialItem:v,sizeRanges:a,topItemCount:E,topItemsIndexes:S,totalCount:d,...y,groupIndices:s,itemSize:i,listState:w,scrollToIndex:C,statefulTotalCount:c,trackItemSizes:h,...k,...P,...g,sizes:l,...x}),rt(kn,bo,Lt,mC,fC,ir,vo,bC,xC,uh,wC));function yC(e,t){const n={},r={};let o=0;const s=e.length;for(;o<s;)r[e[o]]=1,o+=1;for(const i in t)Object.hasOwn(r,i)||(n[i]=t[i]);return n}const Ms=typeof document<"u"?b.useLayoutEffect:b.useEffect;function kh(e,t,n){const r=Object.keys(t.required||{}),o=Object.keys(t.optional||{}),s=Object.keys(t.methods||{}),i=Object.keys(t.events||{}),a=b.createContext({});function l(x,y){x.propsReady&&Pe(x.propsReady,!1);for(const w of r){const S=x[t.required[w]];Pe(S,y[w])}for(const w of o)if(w in y){const S=x[t.optional[w]];Pe(S,y[w])}x.propsReady&&Pe(x.propsReady,!0)}function c(x){return s.reduce((y,w)=>(y[w]=S=>{const k=x[t.methods[w]];Pe(k,S)},y),{})}function d(x){return i.reduce((y,w)=>(y[w]=LS(x[t.events[w]]),y),{})}const h=b.forwardRef((x,y)=>{const{children:w,...S}=x,[k]=b.useState(()=>Es(FS(e),E=>{l(E,S)})),[C]=b.useState(Gf(d,k));Ms(()=>{for(const E of i)E in S&&Ye(C[E],S[E]);return()=>{Object.values(C).map(Ia)}},[S,C,k]),Ms(()=>{l(k,S)}),b.useImperativeHandle(y,Kf(c(k)));const T=n;return u.jsx(a.Provider,{value:k,children:n?u.jsx(T,{...yC([...r,...o,...i],S),children:w}):w})}),m=x=>{const y=b.useContext(a);return b.useCallback(w=>{Pe(y[x],w)},[y,x])},f=x=>{const y=b.useContext(a)[x],w=b.useCallback(S=>Ye(y,S),[y]);return b.useSyncExternalStore(w,()=>ht(y),()=>ht(y))},v=x=>{const y=b.useContext(a)[x],[w,S]=b.useState(Gf(ht,y));return Ms(()=>Ye(y,k=>{k!==w&&S(Kf(k))}),[y,w]),w},g=b.version.startsWith("18")?f:v;return{Component:h,useEmitter:(x,y)=>{const w=b.useContext(a)[x];Ms(()=>Ye(w,y),[y,w])},useEmitterValue:g,usePublisher:m}}const Eh=b.createContext(void 0),Ih=b.createContext(void 0),Nh=typeof document<"u"?b.useLayoutEffect:b.useEffect;function Ha(e){return"self"in e}function SC(e){return"body"in e}function Ah(e,t,n,r=_r,o,s){const i=b.useRef(null),a=b.useRef(null),l=b.useRef(null),c=b.useCallback(m=>{let f,v,g;const x=m.target;if(SC(x)||Ha(x)){const w=Ha(x)?x:x.defaultView;g=s?w.scrollX:w.scrollY,f=s?w.document.documentElement.scrollWidth:w.document.documentElement.scrollHeight,v=s?w.innerWidth:w.innerHeight}else g=s?x.scrollLeft:x.scrollTop,f=s?x.scrollWidth:x.scrollHeight,v=s?x.offsetWidth:x.offsetHeight;const y=()=>{e({scrollHeight:f,scrollTop:Math.max(g,0),viewportHeight:v})};m.suppressFlushSync?y():Ro.flushSync(y),a.current!==null&&(g===a.current||g<=0||g===f-v)&&(a.current=null,t(!0),l.current&&(clearTimeout(l.current),l.current=null))},[e,t,s]);b.useEffect(()=>{const m=o||i.current;return r(o||i.current),c({suppressFlushSync:!0,target:m}),m.addEventListener("scroll",c,{passive:!0}),()=>{r(null),m.removeEventListener("scroll",c)}},[i,c,n,r,o]);function d(m){const f=i.current;if(!f||(s?"offsetWidth"in f&&f.offsetWidth===0:"offsetHeight"in f&&f.offsetHeight===0))return;const v=m.behavior==="smooth";let g,x,y;Ha(f)?(x=Math.max(Un(f.document.documentElement,s?"width":"height"),s?f.document.documentElement.scrollWidth:f.document.documentElement.scrollHeight),g=s?f.innerWidth:f.innerHeight,y=s?window.scrollX:window.scrollY):(x=f[s?"scrollWidth":"scrollHeight"],g=Un(f,s?"width":"height"),y=f[s?"scrollLeft":"scrollTop"]);const w=x-g;if(m.top=Math.ceil(Math.max(Math.min(w,m.top),0)),fh(g,x)||m.top===y){e({scrollHeight:x,scrollTop:y,viewportHeight:g}),v&&t(!0);return}v?(a.current=m.top,l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{l.current=null,a.current=null,t(!0)},1e3)):a.current=null,s&&(m={behavior:m.behavior,left:m.top}),f.scrollTo(m)}function h(m){s&&(m={behavior:m.behavior,left:m.top}),i.current.scrollBy(m)}return{scrollByCallback:h,scrollerRef:i,scrollToCallback:d}}const Ua="-webkit-sticky",jh="sticky",Wa=Ch(()=>{if(typeof document>"u")return jh;const e=document.createElement("div");return e.style.position=Ua,e.style.position===Ua?Ua:jh});function Va(e){return e}const CC=qe(()=>{const e=se(a=>`Item ${a}`),t=se(a=>`Group ${a}`),n=se({}),r=se(Va),o=se("div"),s=se(_r),i=(a,l=null)=>_t(ne(n,ue(c=>c[a]),ot()),l);return{components:n,computeItemKey:r,EmptyPlaceholder:i("EmptyPlaceholder"),FooterComponent:i("Footer"),GroupComponent:i("Group","div"),groupContent:t,HeaderComponent:i("Header"),HeaderFooterTag:o,ItemComponent:i("Item","div"),itemContent:e,ListComponent:i("List","div"),ScrollerComponent:i("Scroller","div"),scrollerRef:s,ScrollSeekPlaceholder:i("ScrollSeekPlaceholder"),TopItemListComponent:i("TopItemList")}}),TC=qe(([e,t])=>({...e,...t}),rt(Th,CC)),kC=({height:e})=>u.jsx("div",{style:{height:e}}),EC={overflowAnchor:"none",position:Wa(),zIndex:1},Ph={overflowAnchor:"none"},IC={...Ph,display:"inline-block",height:"100%"},_h=b.memo(function({showTopList:e=!1}){const t=Ae("listState"),n=tn("sizeRanges"),r=Ae("useWindowScroll"),o=Ae("customScrollParent"),s=tn("windowScrollContainerState"),i=tn("scrollContainerState"),a=o||r?s:i,l=Ae("itemContent"),c=Ae("context"),d=Ae("groupContent"),h=Ae("trackItemSizes"),m=Ae("itemSize"),f=Ae("log"),v=tn("gap"),g=Ae("horizontalDirection"),{callbackRef:x}=HS(n,m,h,e?_r:a,f,v,o,g,Ae("skipAnimationFrameInResizeObserver")),[y,w]=b.useState(0);Ka("deviation",A=>{y!==A&&w(A)});const S=Ae("EmptyPlaceholder"),k=Ae("ScrollSeekPlaceholder")||kC,C=Ae("ListComponent"),T=Ae("ItemComponent"),E=Ae("GroupComponent"),j=Ae("computeItemKey"),P=Ae("isSeeking"),D=Ae("groupIndices").length>0,F=Ae("alignToBottom"),W=Ae("initialItemFinalLocationReached"),G=e?{}:{boxSizing:"border-box",...g?{display:"inline-block",height:"100%",marginLeft:y!==0?y:F?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:y!==0?y:F?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...W?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&S?u.jsx(S,{...Rt(S,c)}):u.jsx(C,{...Rt(C,c),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:x,style:G,children:(e?t.topItems:t.items).map(A=>{const X=A.originalIndex,q=j(X+t.firstItemIndex,A.data,c);return P?b.createElement(k,{...Rt(k,c),height:A.size,index:A.index,key:q,type:A.type||"item",...A.type==="group"?{}:{groupIndex:A.groupIndex}}):A.type==="group"?b.createElement(E,{...Rt(E,c),"data-index":X,"data-item-index":A.index,"data-known-size":A.size,key:q,style:EC},d(A.index,c)):b.createElement(T,{...Rt(T,c),...PC(T,A.data),"data-index":X,"data-item-group-index":A.groupIndex,"data-item-index":A.index,"data-known-size":A.size,key:q,style:g?IC:Ph},D?l(A.index,A.groupIndex,A.data,c):l(A.index,A.data,c))})})}),NC={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},AC={outline:"none",overflowX:"auto",position:"relative"},Os=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),jC={position:Wa(),top:0,width:"100%",zIndex:1};function Rt(e,t){if(typeof e!="string")return{context:t}}function PC(e,t){return{item:typeof e=="string"?void 0:t}}const _C=b.memo(function(){const e=Ae("HeaderComponent"),t=tn("headerHeight"),n=Ae("HeaderFooterTag"),r=or(b.useMemo(()=>s=>{t(Un(s,"height"))},[t]),!0,Ae("skipAnimationFrameInResizeObserver")),o=Ae("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Rt(e,o)})}):null}),RC=b.memo(function(){const e=Ae("FooterComponent"),t=tn("footerHeight"),n=Ae("HeaderFooterTag"),r=or(b.useMemo(()=>s=>{t(Un(s,"height"))},[t]),!0,Ae("skipAnimationFrameInResizeObserver")),o=Ae("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Rt(e,o)})}):null});function Rh({useEmitter:e,useEmitterValue:t,usePublisher:n}){return b.memo(function({children:r,style:o,context:s,...i}){const a=n("scrollContainerState"),l=t("ScrollerComponent"),c=n("smoothScrollTargetReached"),d=t("scrollerRef"),h=t("horizontalDirection")||!1,{scrollByCallback:m,scrollerRef:f,scrollToCallback:v}=Ah(a,c,l,d,void 0,h);return e("scrollTo",v),e("scrollBy",m),u.jsx(l,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:f,style:{...h?AC:NC,...o},tabIndex:0,...i,...Rt(l,s),children:r})})}function Mh({useEmitter:e,useEmitterValue:t,usePublisher:n}){return b.memo(function({children:r,style:o,context:s,...i}){const a=n("windowScrollContainerState"),l=t("ScrollerComponent"),c=n("smoothScrollTargetReached"),d=t("totalListHeight"),h=t("deviation"),m=t("customScrollParent"),f=b.useRef(null),v=t("scrollerRef"),{scrollByCallback:g,scrollerRef:x,scrollToCallback:y}=Ah(a,c,l,v,m);return Nh(()=>{var w;return x.current=m||((w=f.current)==null?void 0:w.ownerDocument.defaultView),()=>{x.current=null}},[x,m]),e("windowScrollTo",y),e("scrollBy",g),u.jsx(l,{ref:f,"data-virtuoso-scroller":!0,style:{position:"relative",...o,...d!==0?{height:d+h}:{}},...i,...Rt(l,s),children:r})})}const MC=({children:e})=>{const t=b.useContext(Eh),n=tn("viewportHeight"),r=tn("fixedItemHeight"),o=Ae("alignToBottom"),s=Ae("horizontalDirection"),i=b.useMemo(()=>qf(n,l=>Un(l,s?"width":"height")),[n,s]),a=or(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:Os(o),children:e})},OC=({children:e})=>{const t=b.useContext(Eh),n=tn("windowViewportRect"),r=tn("fixedItemHeight"),o=Ae("customScrollParent"),s=Zf(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:Os(i),children:e})},DC=({children:e})=>{const t=Ae("TopItemListComponent")||"div",n=Ae("headerHeight"),r={...jC,marginTop:`${n}px`},o=Ae("context");return u.jsx(t,{style:r,...Rt(t,o),children:e})},LC=b.memo(function(e){const t=Ae("useWindowScroll"),n=Ae("topItemsIndexes").length>0,r=Ae("customScrollParent"),o=Ae("context");return u.jsxs(r||t?BC:FC,{...e,context:o,children:[n&&u.jsx(DC,{children:u.jsx(_h,{showTopList:!0})}),u.jsxs(r||t?OC:MC,{children:[u.jsx(_C,{}),u.jsx(_h,{}),u.jsx(RC,{})]})]})}),{Component:$C,useEmitter:Ka,useEmitterValue:Ae,usePublisher:tn}=kh(TC,{required:{},optional:{restoreStateFrom:"restoreStateFrom",context:"context",followOutput:"followOutput",scrollIntoViewOnChange:"scrollIntoViewOnChange",itemContent:"itemContent",groupContent:"groupContent",overscan:"overscan",increaseViewportBy:"increaseViewportBy",totalCount:"totalCount",groupCounts:"groupCounts",topItemCount:"topItemCount",firstItemIndex:"firstItemIndex",initialTopMostItemIndex:"initialTopMostItemIndex",components:"components",atBottomThreshold:"atBottomThreshold",atTopThreshold:"atTopThreshold",computeItemKey:"computeItemKey",defaultItemHeight:"defaultItemHeight",fixedItemHeight:"fixedItemHeight",itemSize:"itemSize",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"HeaderFooterTag",data:"data",initialItemCount:"initialItemCount",initialScrollTop:"initialScrollTop",alignToBottom:"alignToBottom",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",horizontalDirection:"horizontalDirection",skipAnimationFrameInResizeObserver:"skipAnimationFrameInResizeObserver"},methods:{scrollToIndex:"scrollToIndex",scrollIntoView:"scrollIntoView",scrollTo:"scrollTo",scrollBy:"scrollBy",autoscrollToBottom:"autoscrollToBottom",getState:"getState"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",totalListHeightChanged:"totalListHeightChanged",itemsRendered:"itemsRendered",groupIndices:"groupIndices"}},LC),FC=Rh({useEmitter:Ka,useEmitterValue:Ae,usePublisher:tn}),BC=Mh({useEmitter:Ka,useEmitterValue:Ae,usePublisher:tn}),zC=$C;rt(Th,qe(()=>{const e=se(c=>u.jsxs("td",{children:["Item $",c]})),t=se(null),n=se(c=>u.jsxs("td",{colSpan:1e3,children:["Group ",c]})),r=se(null),o=se(null),s=se({}),i=se(Va),a=se(_r),l=(c,d=null)=>_t(ne(s,ue(h=>h[c]),ot()),d);return{components:s,computeItemKey:i,context:t,EmptyPlaceholder:l("EmptyPlaceholder"),FillerRow:l("FillerRow"),fixedFooterContent:o,fixedHeaderContent:r,itemContent:e,groupContent:n,ScrollerComponent:l("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder"),TableBodyComponent:l("TableBody","tbody"),TableComponent:l("Table","table"),TableFooterComponent:l("TableFoot","tfoot"),TableHeadComponent:l("TableHead","thead"),TableRowComponent:l("TableRow","tr"),GroupComponent:l("Group","tr")}})),Wa();const Oh={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},HC={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:Dh,floor:Ds,max:Co,min:qa,round:Lh}=Math;function $h(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function UC(e){return{...HC,items:e}}function Ls(e,t){return e&&e.width===t.width&&e.height===t.height}function WC(e,t){return e&&e.column===t.column&&e.row===t.row}const VC=qe(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:r},{footerHeight:o,headerHeight:s,scrollBy:i,scrollContainerState:a,scrollTo:l,scrollTop:c,smoothScrollTargetReached:d,viewportHeight:h},m,f,{didMount:v,propsReady:g},{customScrollParent:x,useWindowScroll:y,windowScrollContainerState:w,windowScrollTo:S,windowViewportRect:k},C])=>{const T=se(0),E=se(0),j=se(Oh),P=se({height:0,width:0}),D=se({height:0,width:0}),F=ze(),W=ze(),G=se(0),A=se(null),X=se({column:0,row:0}),q=ze(),B=ze(),R=se(!1),I=se(0),H=se(!0),Y=se(!1),_=se(!1);Ye(ne(v,De(I),Ee(([$,ee])=>!!ee)),()=>{Pe(H,!1)}),Ye(ne(xt(v,H,D,P,I,Y),Ee(([$,ee,J,K,,Q])=>$&&!ee&&J.height!==0&&K.height!==0&&!Q)),([,,,,$])=>{Pe(Y,!0),La(1,()=>{Pe(F,$)}),dn(ne(c),()=>{Pe(t,[0,0]),Pe(H,!0)})}),xe(ne(B,Ee($=>$!=null&&$.scrollTop>0),Cn(0)),E),Ye(ne(v,De(B),Ee(([,$])=>$!=null)),([,$])=>{$&&(Pe(P,$.viewport),Pe(D,$.item),Pe(X,$.gap),$.scrollTop>0&&(Pe(R,!0),dn(ne(c,rr(1)),ee=>{Pe(R,!1)}),Pe(l,{top:$.scrollTop})))}),xe(ne(P,ue(({height:$})=>$)),h),xe(ne(xt(Ce(P,Ls),Ce(D,Ls),Ce(X,($,ee)=>$&&$.column===ee.column&&$.row===ee.row),Ce(c)),ue(([$,ee,J,K])=>({gap:J,item:ee,scrollTop:K,viewport:$}))),q),xe(ne(xt(Ce(T),r,Ce(X,WC),Ce(D,Ls),Ce(P,Ls),Ce(A),Ce(E),Ce(R),Ce(H),Ce(I)),Ee(([,,,,,,,$])=>!$),ue(([$,[ee,J],K,Q,pe,de,me,,we,Te])=>{const{column:Ne,row:ke}=K,{height:st,width:vt}=Q,{width:pt}=pe;if(me===0&&($===0||pt===0))return Oh;if(vt===0){const yt=$a(Te,$),St=yt+Math.max(me-1,0);return UC($h(yt,St,de))}const We=Fh(pt,vt,Ne);let Le,Ge;we?ee===0&&J===0&&me>0?(Le=0,Ge=me-1):(Le=We*Ds((ee+ke)/(st+ke)),Ge=We*Dh((J+ke)/(st+ke))-1,Ge=qa($-1,Co(Ge,We-1)),Le=qa(Ge,Co(0,Le))):(Le=0,Ge=-1);const Re=$h(Le,Ge,de),{bottom:$e,top:Ze}=Bh(pe,K,Q,Re),It=Dh($/We),it=It*st+(It-1)*ke-$e;return{bottom:$e,itemHeight:st,items:Re,itemWidth:vt,offsetBottom:it,offsetTop:Ze,top:Ze}})),j),xe(ne(A,Ee($=>$!==null),ue($=>$.length)),T),xe(ne(xt(P,D,j,X),Ee(([$,ee,{items:J}])=>J.length>0&&ee.height!==0&&$.height!==0),ue(([$,ee,{items:J},K])=>{const{bottom:Q,top:pe}=Bh($,K,ee,J);return[pe,Q]}),ot(go)),t);const O=se(!1);xe(ne(c,De(O),ue(([$,ee])=>ee||$!==0)),O);const M=Zt(ne(xt(j,T),Ee(([{items:$}])=>$.length>0),De(O),Ee(([[$,ee],J])=>{const K=$.items[$.items.length-1].index===ee-1;return(J||$.bottom>0&&$.itemHeight>0&&$.offsetBottom===0&&$.items.length===ee)&&K}),ue(([[,$]])=>$-1),ot())),L=Zt(ne(Ce(j),Ee(({items:$})=>$.length>0&&$[0].index===0),Cn(0),ot())),te=Zt(ne(Ce(j),De(R),Ee(([{items:$},ee])=>$.length>0&&!ee),ue(([{items:$}])=>({endIndex:$[$.length-1].index,startIndex:$[0].index})),ot(sh),Pn(0)));xe(te,f.scrollSeekRangeChanged),xe(ne(F,De(P,D,T,X),ue(([$,ee,J,K,Q])=>{const pe=dh($),{align:de,behavior:me,offset:we}=pe;let Te=pe.index;Te==="LAST"&&(Te=K-1),Te=Co(0,Te,qa(K-1,Te));let Ne=Ga(ee,Q,J,Te);return de==="end"?Ne=Lh(Ne-ee.height+J.height):de==="center"&&(Ne=Lh(Ne-ee.height/2+J.height/2)),we&&(Ne+=we),{behavior:me,top:Ne}})),l);const z=_t(ne(j,ue($=>$.offsetBottom+$.bottom)),0);return xe(ne(k,ue($=>({height:$.visibleHeight,width:$.visibleWidth}))),P),{customScrollParent:x,data:A,deviation:G,footerHeight:o,gap:X,headerHeight:s,increaseViewportBy:e,initialItemCount:E,itemDimensions:D,overscan:n,restoreStateFrom:B,scrollBy:i,scrollContainerState:a,scrollHeight:W,scrollTo:l,scrollToIndex:F,scrollTop:c,smoothScrollTargetReached:d,totalCount:T,useWindowScroll:y,viewportDimensions:P,windowScrollContainerState:w,windowScrollTo:S,windowViewportRect:k,...f,gridState:j,horizontalDirection:_,initialTopMostItemIndex:I,totalListHeight:z,...m,endReached:M,propsReady:g,rangeChanged:te,startReached:L,stateChanged:q,stateRestoreInProgress:R,...C}},rt(Fa,Lt,So,Sh,Wn,za,Hn));function Fh(e,t,n){return Co(1,Ds((e+n)/(Ds(t)+n)))}function Bh(e,t,n,r){const{height:o}=n;if(o===void 0||r.length===0)return{bottom:0,top:0};const s=Ga(e,t,n,r[0].index);return{bottom:Ga(e,t,n,r[r.length-1].index)+o,top:s}}function Ga(e,t,n,r){const o=Fh(e.width,n.width,t.column),s=Ds(r/o),i=s*n.height+Co(0,s-1)*t.row;return i>0?i+t.row:i}const KC=qe(()=>{const e=se(h=>`Item ${h}`),t=se({}),n=se(null),r=se("virtuoso-grid-item"),o=se("virtuoso-grid-list"),s=se(Va),i=se("div"),a=se(_r),l=(h,m=null)=>_t(ne(t,ue(f=>f[h]),ot()),m),c=se(!1),d=se(!1);return xe(Ce(d),c),{components:t,computeItemKey:s,context:n,FooterComponent:l("Footer"),HeaderComponent:l("Header"),headerFooterTag:i,itemClassName:r,ItemComponent:l("Item","div"),itemContent:e,listClassName:o,ListComponent:l("List","div"),readyStateChanged:c,reportReadyState:d,ScrollerComponent:l("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder","div")}}),qC=qe(([e,t])=>({...e,...t}),rt(VC,KC)),GC=b.memo(function(){const e=at("gridState"),t=at("listClassName"),n=at("itemClassName"),r=at("itemContent"),o=at("computeItemKey"),s=at("isSeeking"),i=nn("scrollHeight"),a=at("ItemComponent"),l=at("ListComponent"),c=at("ScrollSeekPlaceholder"),d=at("context"),h=nn("itemDimensions"),m=nn("gap"),f=at("log"),v=at("stateRestoreInProgress"),g=nn("reportReadyState"),x=or(b.useMemo(()=>y=>{const w=y.parentElement.parentElement.scrollHeight;i(w);const S=y.firstChild;if(S){const{height:k,width:C}=S.getBoundingClientRect();h({height:k,width:C})}m({column:Hh("column-gap",getComputedStyle(y).columnGap,f),row:Hh("row-gap",getComputedStyle(y).rowGap,f)})},[i,h,m,f]),!0,!1);return Nh(()=>{e.itemHeight>0&&e.itemWidth>0&&g(!0)},[e]),v?null:u.jsx(l,{className:t,ref:x,...Rt(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,{...Rt(c,d),height:e.itemHeight,index:y.index,width:e.itemWidth},w):b.createElement(a,{...Rt(a,d),className:n,"data-index":y.index,key:w},r(y.index,y.data,d))})})}),YC=b.memo(function(){const e=at("HeaderComponent"),t=nn("headerHeight"),n=at("headerFooterTag"),r=or(b.useMemo(()=>s=>{t(Un(s,"height"))},[t]),!0,!1),o=at("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Rt(e,o)})}):null}),XC=b.memo(function(){const e=at("FooterComponent"),t=nn("footerHeight"),n=at("headerFooterTag"),r=or(b.useMemo(()=>s=>{t(Un(s,"height"))},[t]),!0,!1),o=at("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Rt(e,o)})}):null}),JC=({children:e})=>{const t=b.useContext(Ih),n=nn("itemDimensions"),r=nn("viewportDimensions"),o=or(b.useMemo(()=>s=>{r(s.getBoundingClientRect())},[r]),!0,!1);return b.useEffect(()=>{t&&(r({height:t.viewportHeight,width:t.viewportWidth}),n({height:t.itemHeight,width:t.itemWidth}))},[t,r,n]),u.jsx("div",{ref:o,style:Os(!1),children:e})},ZC=({children:e})=>{const t=b.useContext(Ih),n=nn("windowViewportRect"),r=nn("itemDimensions"),o=at("customScrollParent"),s=Zf(n,o,!1);return b.useEffect(()=>{t&&(r({height:t.itemHeight,width:t.itemWidth}),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:t.viewportWidth}))},[t,n,r]),u.jsx("div",{ref:s,style:Os(!1),children:e})},QC=b.memo(function({...e}){const t=at("useWindowScroll"),n=at("customScrollParent"),r=n||t?tT:eT,o=n||t?ZC:JC,s=at("context");return u.jsx(r,{...e,...Rt(r,s),children:u.jsxs(o,{children:[u.jsx(YC,{}),u.jsx(GC,{}),u.jsx(XC,{})]})})}),{useEmitter:zh,useEmitterValue:at,usePublisher:nn}=kh(qC,{optional:{context:"context",totalCount:"totalCount",overscan:"overscan",itemContent:"itemContent",components:"components",computeItemKey:"computeItemKey",data:"data",initialItemCount:"initialItemCount",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"headerFooterTag",listClassName:"listClassName",itemClassName:"itemClassName",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",restoreStateFrom:"restoreStateFrom",initialTopMostItemIndex:"initialTopMostItemIndex",increaseViewportBy:"increaseViewportBy"},methods:{scrollTo:"scrollTo",scrollBy:"scrollBy",scrollToIndex:"scrollToIndex"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",stateChanged:"stateChanged",readyStateChanged:"readyStateChanged"}},QC),eT=Rh({useEmitter:zh,useEmitterValue:at,usePublisher:nn}),tT=Mh({useEmitter:zh,useEmitterValue:at,usePublisher:nn});function Hh(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Ht.WARN),t==="normal"?0:parseInt(t??"0",10)}var $s="Dialog",[Uh,_N]=ln($s),[nT,hn]=Uh($s),Wh=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:i=!0}=e,a=p.useRef(null),l=p.useRef(null),[c,d]=Dn({prop:r,defaultProp:o??!1,onChange:s,caller:$s});return u.jsx(nT,{scope:t,triggerRef:a,contentRef:l,contentId:Pt(),titleId:Pt(),descriptionId:Pt(),open:c,onOpenChange:d,onOpenToggle:p.useCallback(()=>d(h=>!h),[d]),modal:i,children:n})};Wh.displayName=$s;var Vh="DialogTrigger",Kh=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=hn(Vh,n),s=Oe(t,o.triggerRef);return u.jsx(ge.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Ja(o.open),...r,ref:s,onClick:ie(e.onClick,o.onOpenToggle)})});Kh.displayName=Vh;var Ya="DialogPortal",[rT,qh]=Uh(Ya,{forceMount:void 0}),Gh=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=hn(Ya,t);return u.jsx(rT,{scope:t,forceMount:n,children:p.Children.map(r,i=>u.jsx(zt,{present:n||s.open,children:u.jsx(so,{asChild:!0,container:o,children:i})}))})};Gh.displayName=Ya;var Fs="DialogOverlay",Yh=p.forwardRef((e,t)=>{const n=qh(Fs,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=hn(Fs,e.__scopeDialog);return s.modal?u.jsx(zt,{present:r||s.open,children:u.jsx(sT,{...o,ref:t})}):null});Yh.displayName=Fs;var oT=qt.createSlot("DialogOverlay.RemoveScroll"),sT=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=hn(Fs,n);return u.jsx(xs,{as:oT,allowPinchZoom:!0,shards:[o.contentRef],children:u.jsx(ge.div,{"data-state":Ja(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),ar="DialogContent",Xh=p.forwardRef((e,t)=>{const n=qh(ar,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=hn(ar,e.__scopeDialog);return u.jsx(zt,{present:r||s.open,children:s.modal?u.jsx(iT,{...o,ref:t}):u.jsx(aT,{...o,ref:t})})});Xh.displayName=ar;var iT=p.forwardRef((e,t)=>{const n=hn(ar,e.__scopeDialog),r=p.useRef(null),o=Oe(t,n.contentRef,r);return p.useEffect(()=>{const s=r.current;if(s)return fa(s)},[]),u.jsx(Jh,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ie(e.onCloseAutoFocus,s=>{var i;s.preventDefault(),(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:ie(e.onPointerDownOutside,s=>{const i=s.detail.originalEvent,a=i.button===0&&i.ctrlKey===!0;(i.button===2||a)&&s.preventDefault()}),onFocusOutside:ie(e.onFocusOutside,s=>s.preventDefault())})}),aT=p.forwardRef((e,t)=>{const n=hn(ar,e.__scopeDialog),r=p.useRef(!1),o=p.useRef(!1);return u.jsx(Jh,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var i,a;(i=e.onCloseAutoFocus)==null||i.call(e,s),s.defaultPrevented||(r.current||(a=n.triggerRef.current)==null||a.focus(),s.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:s=>{var l,c;(l=e.onInteractOutside)==null||l.call(e,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const i=s.target;((c=n.triggerRef.current)==null?void 0:c.contains(i))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&o.current&&s.preventDefault()}})}),Jh=p.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=hn(ar,n),l=p.useRef(null),c=Oe(t,l);return Ui(),u.jsxs(u.Fragment,{children:[u.jsx(Zo,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:u.jsx(yr,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":Ja(a.open),...i,ref:c,onDismiss:()=>a.onOpenChange(!1)})}),u.jsxs(u.Fragment,{children:[u.jsx(lT,{titleId:a.titleId}),u.jsx(uT,{contentRef:l,descriptionId:a.descriptionId})]})]})}),Xa="DialogTitle",Zh=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=hn(Xa,n);return u.jsx(ge.h2,{id:o.titleId,...r,ref:t})});Zh.displayName=Xa;var Qh="DialogDescription",ep=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=hn(Qh,n);return u.jsx(ge.p,{id:o.descriptionId,...r,ref:t})});ep.displayName=Qh;var tp="DialogClose",np=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=hn(tp,n);return u.jsx(ge.button,{type:"button",...r,ref:t,onClick:ie(e.onClick,()=>o.onOpenChange(!1))})});np.displayName=tp;function Ja(e){return e?"open":"closed"}var rp="DialogTitleWarning",[RN,op]=Tb(rp,{contentName:ar,titleName:Xa,docsSlug:"dialog"}),lT=({titleId:e})=>{const t=op(rp),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
79
|
+
`)},W0=0,Pr=[];function V0(e){var t=h.useRef([]),n=h.useRef([0,0]),r=h.useRef(),o=h.useState(W0++)[0],s=h.useState(Zd)[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=f0([e.lockRef.current],(e.shards||[]).map(sf),!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=bs(g),w=n.current,S="deltaX"in g?g.deltaX:w[0]-y[0],k="deltaY"in g?g.deltaY:w[1]-y[1],C,T=g.target,E=Math.abs(S)>Math.abs(k)?"h":"v";if("touches"in g&&E==="h"&&T.type==="range")return!1;var j=tf(E,T);if(!j)return!0;if(j?C=E:(C=E==="v"?"h":"v",j=tf(E,T)),!j)return!1;if(!r.current&&"changedTouches"in g&&(S||k)&&(r.current=C),!C)return!0;var _=r.current||C;return z0(_,x,g,_==="h"?S:k)},[]),l=h.useCallback(function(g){var x=g;if(!(!Pr.length||Pr[Pr.length-1]!==s)){var y="deltaY"in x?of(x):bs(x),w=t.current.filter(function(C){return C.name===x.type&&(C.target===x.target||x.target===C.shadowParent)&&H0(C.delta,y)})[0];if(w&&w.should){x.cancelable&&x.preventDefault();return}if(!w){var S=(i.current.shards||[]).map(sf).filter(Boolean).filter(function(C){return C.contains(x.target)}),k=S.length>0?a(x,S[0]):!i.current.noIsolation;k&&x.cancelable&&x.preventDefault()}}},[]),u=h.useCallback(function(g,x,y,w){var S={name:g,delta:x,target:y,should:w,shadowParent:K0(y)};t.current.push(S),setTimeout(function(){t.current=t.current.filter(function(k){return k!==S})},1)},[]),d=h.useCallback(function(g){n.current=bs(g),r.current=void 0},[]),f=h.useCallback(function(g){u(g.type,of(g),g.target,a(g,e.lockRef.current))},[]),m=h.useCallback(function(g){u(g.type,bs(g),g.target,a(g,e.lockRef.current))},[]);h.useEffect(function(){return Pr.push(s),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:m}),document.addEventListener("wheel",l,_r),document.addEventListener("touchmove",l,_r),document.addEventListener("touchstart",d,_r),function(){Pr=Pr.filter(function(g){return g!==s}),document.removeEventListener("wheel",l,_r),document.removeEventListener("touchmove",l,_r),document.removeEventListener("touchstart",d,_r)}},[]);var p=e.removeScrollBar,b=e.inert;return h.createElement(h.Fragment,null,b?h.createElement(s,{styles:U0(o)}):null,p?h.createElement(M0,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function K0(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const q0=y0(Jd,V0);var ws=h.forwardRef(function(e,t){return h.createElement(xs,Tn({},e,{ref:t,sideCar:q0}))});ws.classNames=xs.classNames;var Ca=["Enter"," "],G0=["ArrowDown","PageUp","Home"],af=["ArrowUp","PageDown","End"],Y0=[...G0,...af],X0={ltr:[...Ca,"ArrowRight"],rtl:[...Ca,"ArrowLeft"]},J0={ltr:["ArrowLeft"],rtl:["ArrowRight"]},fo="Menu",[po,Z0,Q0]=oo(fo),[nr,lf]=Xt(fo,[Q0,Nr,Hd]),ys=Nr(),cf=Hd(),[eS,rr]=nr(fo),[tS,ho]=nr(fo),uf=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=ys(t),[l,u]=h.useState(null),d=h.useRef(!1),f=ft(s),m=so(o);return h.useEffect(()=>{const p=()=>{d.current=!0,document.addEventListener("pointerdown",b,{capture:!0,once:!0}),document.addEventListener("pointermove",b,{capture:!0,once:!0})},b=()=>d.current=!1;return document.addEventListener("keydown",p,{capture:!0}),()=>{document.removeEventListener("keydown",p,{capture:!0}),document.removeEventListener("pointerdown",b,{capture:!0}),document.removeEventListener("pointermove",b,{capture:!0})}},[]),c.jsx(da,{...a,children:c.jsx(eS,{scope:t,open:n,onOpenChange:f,content:l,onContentChange:u,children:c.jsx(tS,{scope:t,onClose:h.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:d,dir:m,modal:i,children:r})})})};uf.displayName=fo;var nS="MenuAnchor",Ta=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=ys(n);return c.jsx(fa,{...o,...r,ref:t})});Ta.displayName=nS;var ka="MenuPortal",[rS,df]=nr(ka,{forceMount:void 0}),ff=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=rr(ka,t);return c.jsx(rS,{scope:t,forceMount:n,children:c.jsx(Dt,{present:n||s.open,children:c.jsx(co,{asChild:!0,container:o,children:r})})})};ff.displayName=ka;var tn="MenuContent",[oS,Ea]=nr(tn),pf=h.forwardRef((e,t)=>{const n=df(tn,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=rr(tn,e.__scopeMenu),i=ho(tn,e.__scopeMenu);return c.jsx(po.Provider,{scope:e.__scopeMenu,children:c.jsx(Dt,{present:r||s.open,children:c.jsx(po.Slot,{scope:e.__scopeMenu,children:i.modal?c.jsx(sS,{...o,ref:t}):c.jsx(iS,{...o,ref:t})})})})}),sS=h.forwardRef((e,t)=>{const n=rr(tn,e.__scopeMenu),r=h.useRef(null),o=_e(t,r);return h.useEffect(()=>{const s=r.current;if(s)return va(s)},[]),c.jsx(Ia,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:ie(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),iS=h.forwardRef((e,t)=>{const n=rr(tn,e.__scopeMenu);return c.jsx(Ia,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),aS=qt.createSlot("MenuContent.ScrollLock"),Ia=h.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:m,onDismiss:p,disableOutsideScroll:b,...g}=e,x=rr(tn,n),y=ho(tn,n),w=ys(n),S=cf(n),k=Z0(n),[C,T]=h.useState(null),E=h.useRef(null),j=_e(t,E,x.onContentChange),_=h.useRef(0),D=h.useRef(""),F=h.useRef(0),W=h.useRef(null),G=h.useRef("right"),A=h.useRef(0),X=b?ws:h.Fragment,q=b?{as:aS,allowPinchZoom:!0}:void 0,B=I=>{var z,$;const H=D.current+I,Y=k().filter(ee=>!ee.disabled),P=document.activeElement,O=(z=Y.find(ee=>ee.ref.current===P))==null?void 0:z.textValue,M=Y.map(ee=>ee.textValue),L=bS(M,H,O),te=($=Y.find(ee=>ee.textValue===L))==null?void 0:$.ref.current;(function ee(J){D.current=J,window.clearTimeout(_.current),J!==""&&(_.current=window.setTimeout(()=>ee(""),1e3))})(H),te&&setTimeout(()=>te.focus())};h.useEffect(()=>()=>window.clearTimeout(_.current),[]),Yi();const R=h.useCallback(I=>{var Y,P;return G.current===((Y=W.current)==null?void 0:Y.side)&&yS(I,(P=W.current)==null?void 0:P.area)},[]);return c.jsx(oS,{scope:n,searchRef:D,onItemEnter:h.useCallback(I=>{R(I)&&I.preventDefault()},[R]),onItemLeave:h.useCallback(I=>{var H;R(I)||((H=E.current)==null||H.focus(),T(null))},[R]),onTriggerLeave:h.useCallback(I=>{R(I)&&I.preventDefault()},[R]),pointerGraceTimerRef:F,onPointerGraceIntentChange:h.useCallback(I=>{W.current=I},[]),children:c.jsx(X,{...q,children:c.jsx(ts,{asChild:!0,trapped:o,onMountAutoFocus:ie(s,I=>{var H;I.preventDefault(),(H=E.current)==null||H.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:c.jsx(Cr,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:m,onDismiss:p,children:c.jsx(a0,{asChild:!0,...S,dir:y.dir,orientation:"vertical",loop:r,currentTabStopId:C,onCurrentTabStopIdChange:T,onEntryFocus:ie(l,I=>{y.isUsingKeyboardRef.current||I.preventDefault()}),preventScrollOnEntryFocus:!0,children:c.jsx(pa,{role:"menu","aria-orientation":"vertical","data-state":jf(x.open),"data-radix-menu-content":"",dir:y.dir,...w,...g,ref:j,style:{outline:"none",...g.style},onKeyDown:ie(g.onKeyDown,I=>{const Y=I.target.closest("[data-radix-menu-content]")===I.currentTarget,P=I.ctrlKey||I.altKey||I.metaKey,O=I.key.length===1;Y&&(I.key==="Tab"&&I.preventDefault(),!P&&O&&B(I.key));const M=E.current;if(I.target!==M||!Y0.includes(I.key))return;I.preventDefault();const te=k().filter(z=>!z.disabled).map(z=>z.ref.current);af.includes(I.key)&&te.reverse(),xS(te)}),onBlur:ie(e.onBlur,I=>{I.currentTarget.contains(I.target)||(window.clearTimeout(_.current),D.current="")}),onPointerMove:ie(e.onPointerMove,go(I=>{const H=I.target,Y=A.current!==I.clientX;if(I.currentTarget.contains(H)&&Y){const P=I.clientX>A.current?"right":"left";G.current=P,A.current=I.clientX}}))})})})})})})});pf.displayName=tn;var lS="MenuGroup",Na=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(he.div,{role:"group",...r,ref:t})});Na.displayName=lS;var cS="MenuLabel",hf=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(he.div,{...r,ref:t})});hf.displayName=cS;var Ss="MenuItem",mf="menu.itemSelect",Cs=h.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=h.useRef(null),i=ho(Ss,e.__scopeMenu),a=Ea(Ss,e.__scopeMenu),l=_e(t,s),u=h.useRef(!1),d=()=>{const f=s.current;if(!n&&f){const m=new CustomEvent(mf,{bubbles:!0,cancelable:!0});f.addEventListener(mf,p=>r==null?void 0:r(p),{once:!0}),Ki(f,m),m.defaultPrevented?u.current=!1:i.onClose()}};return c.jsx(gf,{...o,ref:l,disabled:n,onClick:ie(e.onClick,d),onPointerDown:f=>{var m;(m=e.onPointerDown)==null||m.call(e,f),u.current=!0},onPointerUp:ie(e.onPointerUp,f=>{var m;u.current||(m=f.currentTarget)==null||m.click()}),onKeyDown:ie(e.onKeyDown,f=>{const m=a.searchRef.current!=="";n||m&&f.key===" "||Ca.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});Cs.displayName=Ss;var gf=h.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=Ea(Ss,n),a=cf(n),l=h.useRef(null),u=_e(t,l),[d,f]=h.useState(!1),[m,p]=h.useState("");return h.useEffect(()=>{const b=l.current;b&&p((b.textContent??"").trim())},[s.children]),c.jsx(po.ItemSlot,{scope:n,disabled:r,textValue:o??m,children:c.jsx(l0,{asChild:!0,...a,focusable:!r,children:c.jsx(he.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:u,onPointerMove:ie(e.onPointerMove,go(b=>{r?i.onItemLeave(b):(i.onItemEnter(b),b.defaultPrevented||b.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:ie(e.onPointerLeave,go(b=>i.onItemLeave(b))),onFocus:ie(e.onFocus,()=>f(!0)),onBlur:ie(e.onBlur,()=>f(!1))})})})}),uS="MenuCheckboxItem",xf=h.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return c.jsx(Sf,{scope:e.__scopeMenu,checked:n,children:c.jsx(Cs,{role:"menuitemcheckbox","aria-checked":Ts(n)?"mixed":n,...o,ref:t,"data-state":ja(n),onSelect:ie(o.onSelect,()=>r==null?void 0:r(Ts(n)?!0:!n),{checkForDefaultPrevented:!1})})})});xf.displayName=uS;var vf="MenuRadioGroup",[dS,fS]=nr(vf,{value:void 0,onValueChange:()=>{}}),bf=h.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=ft(r);return c.jsx(dS,{scope:e.__scopeMenu,value:n,onValueChange:s,children:c.jsx(Na,{...o,ref:t})})});bf.displayName=vf;var wf="MenuRadioItem",yf=h.forwardRef((e,t)=>{const{value:n,...r}=e,o=fS(wf,e.__scopeMenu),s=n===o.value;return c.jsx(Sf,{scope:e.__scopeMenu,checked:s,children:c.jsx(Cs,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":ja(s),onSelect:ie(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});yf.displayName=wf;var Aa="MenuItemIndicator",[Sf,pS]=nr(Aa,{checked:!1}),Cf=h.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=pS(Aa,n);return c.jsx(Dt,{present:r||Ts(s.checked)||s.checked===!0,children:c.jsx(he.span,{...o,ref:t,"data-state":ja(s.checked)})})});Cf.displayName=Aa;var hS="MenuSeparator",Tf=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(he.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});Tf.displayName=hS;var mS="MenuArrow",kf=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=ys(n);return c.jsx(ha,{...o,...r,ref:t})});kf.displayName=mS;var gS="MenuSub",[M1,Ef]=nr(gS),mo="MenuSubTrigger",If=h.forwardRef((e,t)=>{const n=rr(mo,e.__scopeMenu),r=ho(mo,e.__scopeMenu),o=Ef(mo,e.__scopeMenu),s=Ea(mo,e.__scopeMenu),i=h.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,u={__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]),c.jsx(Ta,{asChild:!0,...u,children:c.jsx(gf,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":jf(n.open),...e,ref:Ln(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:ie(e.onPointerMove,go(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:ie(e.onPointerLeave,go(f=>{var p,b;d();const m=(p=n.content)==null?void 0:p.getBoundingClientRect();if(m){const g=(b=n.content)==null?void 0:b.dataset.side,x=g==="right",y=x?-5:5,w=m[x?"left":"right"],S=m[x?"right":"left"];s.onPointerGraceIntentChange({area:[{x:f.clientX+y,y:f.clientY},{x:w,y:m.top},{x:S,y:m.top},{x:S,y:m.bottom},{x:w,y:m.bottom}],side:g}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(f),f.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:ie(e.onKeyDown,f=>{var p;const m=s.searchRef.current!=="";e.disabled||m&&f.key===" "||X0[r.dir].includes(f.key)&&(n.onOpenChange(!0),(p=n.content)==null||p.focus(),f.preventDefault())})})})});If.displayName=mo;var Nf="MenuSubContent",Af=h.forwardRef((e,t)=>{const n=df(tn,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=rr(tn,e.__scopeMenu),i=ho(tn,e.__scopeMenu),a=Ef(Nf,e.__scopeMenu),l=h.useRef(null),u=_e(t,l);return c.jsx(po.Provider,{scope:e.__scopeMenu,children:c.jsx(Dt,{present:r||s.open,children:c.jsx(po.Slot,{scope:e.__scopeMenu,children:c.jsx(Ia,{id:a.contentId,"aria-labelledby":a.triggerId,...o,ref:u,align:"start",side:i.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:d=>{var f;i.isUsingKeyboardRef.current&&((f=l.current)==null||f.focus()),d.preventDefault()},onCloseAutoFocus:d=>d.preventDefault(),onFocusOutside:ie(e.onFocusOutside,d=>{d.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:ie(e.onEscapeKeyDown,d=>{i.onClose(),d.preventDefault()}),onKeyDown:ie(e.onKeyDown,d=>{var p;const f=d.currentTarget.contains(d.target),m=J0[i.dir].includes(d.key);f&&m&&(s.onOpenChange(!1),(p=a.trigger)==null||p.focus(),d.preventDefault())})})})})})});Af.displayName=Nf;function jf(e){return e?"open":"closed"}function Ts(e){return e==="indeterminate"}function ja(e){return Ts(e)?"indeterminate":e?"checked":"unchecked"}function xS(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function vS(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function bS(e,t,n){const o=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=vS(e,Math.max(s,0));o.length===1&&(i=i.filter(u=>u!==n));const l=i.find(u=>u.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function wS(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const a=t[s],l=t[i],u=a.x,d=a.y,f=l.x,m=l.y;d>r!=m>r&&n<(f-u)*(r-d)/(m-d)+u&&(o=!o)}return o}function yS(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return wS(n,t)}function go(e){return t=>t.pointerType==="mouse"?e(t):void 0}var SS=uf,CS=Ta,TS=ff,kS=pf,ES=Na,IS=hf,NS=Cs,AS=xf,jS=bf,_S=yf,PS=Cf,RS=Tf,MS=kf,OS=If,DS=Af,ks="DropdownMenu",[LS,O1]=Xt(ks,[lf]),Lt=lf(),[$S,_f]=LS(ks),Pf=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,l=Lt(t),u=h.useRef(null),[d,f]=cn({prop:o,defaultProp:s??!1,onChange:i,caller:ks});return c.jsx($S,{scope:t,triggerId:kt(),triggerRef:u,contentId:kt(),open:d,onOpenChange:f,onOpenToggle:h.useCallback(()=>f(m=>!m),[f]),modal:a,children:c.jsx(SS,{...l,open:d,onOpenChange:f,dir:r,modal:a,children:n})})};Pf.displayName=ks;var Rf="DropdownMenuTrigger",Mf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=_f(Rf,n),i=Lt(n);return c.jsx(CS,{asChild:!0,...i,children:c.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:Ln(t,s.triggerRef),onPointerDown:ie(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:ie(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});Mf.displayName=Rf;var FS="DropdownMenuPortal",Of=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Lt(t);return c.jsx(TS,{...r,...n})};Of.displayName=FS;var Df="DropdownMenuContent",Lf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=_f(Df,n),s=Lt(n),i=h.useRef(!1);return c.jsx(kS,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:ie(e.onCloseAutoFocus,a=>{var l;i.current||(l=o.triggerRef.current)==null||l.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:ie(e.onInteractOutside,a=>{const l=a.detail.originalEvent,u=l.button===0&&l.ctrlKey===!0,d=l.button===2||u;(!o.modal||d)&&(i.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Lf.displayName=Df;var BS="DropdownMenuGroup",zS=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Lt(n);return c.jsx(ES,{...o,...r,ref:t})});zS.displayName=BS;var HS="DropdownMenuLabel",$f=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Lt(n);return c.jsx(IS,{...o,...r,ref:t})});$f.displayName=HS;var US="DropdownMenuItem",Ff=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Lt(n);return c.jsx(NS,{...o,...r,ref:t})});Ff.displayName=US;var WS="DropdownMenuCheckboxItem",Bf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Lt(n);return c.jsx(AS,{...o,...r,ref:t})});Bf.displayName=WS;var VS="DropdownMenuRadioGroup",KS=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Lt(n);return c.jsx(jS,{...o,...r,ref:t})});KS.displayName=VS;var qS="DropdownMenuRadioItem",zf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Lt(n);return c.jsx(_S,{...o,...r,ref:t})});zf.displayName=qS;var GS="DropdownMenuItemIndicator",Hf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Lt(n);return c.jsx(PS,{...o,...r,ref:t})});Hf.displayName=GS;var YS="DropdownMenuSeparator",Uf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Lt(n);return c.jsx(RS,{...o,...r,ref:t})});Uf.displayName=YS;var XS="DropdownMenuArrow",JS=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Lt(n);return c.jsx(MS,{...o,...r,ref:t})});JS.displayName=XS;var ZS="DropdownMenuSubTrigger",Wf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Lt(n);return c.jsx(OS,{...o,...r,ref:t})});Wf.displayName=ZS;var QS="DropdownMenuSubContent",Vf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Lt(n);return c.jsx(DS,{...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)"}})});Vf.displayName=QS;var eC=Pf,tC=Mf,nC=Of,Kf=Lf,qf=$f,Gf=Ff,Yf=Bf,Xf=zf,Jf=Hf,Zf=Uf,Qf=Wf,ep=Vf;const Es=eC,Is=tC,rC=h.forwardRef(({className:e,inset:t,children:n,...r},o)=>c.jsxs(Qf,{ref:o,className:ne("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",t&&"pl-8",e),...r,children:[n,c.jsx(ae.ChevronRight,{className:"ml-auto h-4 w-4"})]}));rC.displayName=Qf.displayName;const oC=h.forwardRef(({className:e,...t},n)=>c.jsx(ep,{ref:n,className:ne("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...t}));oC.displayName=ep.displayName;const xo=h.forwardRef(({className:e,sideOffset:t=4,...n},r)=>c.jsx(nC,{children:c.jsx(Kf,{ref:r,sideOffset:t,className:ne("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n})}));xo.displayName=Kf.displayName;const zn=h.forwardRef(({className:e,inset:t,...n},r)=>c.jsx(Gf,{ref:r,className:ne("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...n}));zn.displayName=Gf.displayName;const sC=h.forwardRef(({className:e,children:t,checked:n,...r},o)=>c.jsxs(Yf,{ref:o,className:ne("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:n,...r,children:[c.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:c.jsx(Jf,{children:c.jsx(ae.Check,{className:"h-4 w-4"})})}),t]}));sC.displayName=Yf.displayName;const iC=h.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(Xf,{ref:r,className:ne("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[c.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:c.jsx(Jf,{children:c.jsx(ae.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));iC.displayName=Xf.displayName;const aC=h.forwardRef(({className:e,inset:t,...n},r)=>c.jsx(qf,{ref:r,className:ne("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));aC.displayName=qf.displayName;const lC=h.forwardRef(({className:e,...t},n)=>c.jsx(Zf,{ref:n,className:ne("-mx-1 my-1 h-px bg-muted",e),...t}));lC.displayName=Zf.displayName;const _a=h.forwardRef(({className:e,...t},n)=>c.jsx("textarea",{className:ne("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),ref:n,...t}));_a.displayName="Textarea";const cC=1e4;function tp({initialValue:e="",editingMessageId:t=null,placeholder:n="Type your message...",isStreaming:r=!1,disabled:o=!1,maxLength:s=cC,value:i,onValueChange:a,onSend:l,onCancelEdit:u,onStop:d,className:f="",textareaClassName:m="",allowEmptySend:p=!1,sendButtonClassName:b,validate:g,onValidationError:x}){const y=i!==void 0,[w,S]=v.useState(e),k=(y?i:w)??"",[C,T]=v.useTransition(),E=v.useRef(null),j=v.useRef(0),_=v.useRef(null),D=v.useRef("");v.useEffect(()=>{y||(S(e??""),_.current=null,E.current&&(E.current.style.height="auto",E.current.style.height=`${E.current.scrollHeight}px`))},[e,t,y]);const[F,W]=v.useState(null),G=v.useCallback(M=>M.length>s?`Message too long (${M.length}/${s} characters)`:null,[s]),A=v.useMemo(()=>g??G,[g,G]),X=v.useCallback(M=>{const L=A(M);return W(L),x==null||x(L),D.current=M,L},[A,x]),q=v.useCallback(()=>{const M=E.current;M&&(M.style.height="auto",M.style.height=`${M.scrollHeight}px`)},[]);v.useEffect(()=>{q()},[q,k]),v.useEffect(()=>{if(!F)return;const M=(k??"").trim();D.current!==M&&X(M)},[k,F,X]);const B=v.useCallback((M,{fromUser:L})=>{y||S(M),L&&(a==null||a(M))},[y,a]),R=v.useCallback(async M=>{M&&M.preventDefault();const L=(k??"").trim();if(!L&&!p||X(L))return;const te=++j.current;_.current={id:te,shouldClear:!0},T(()=>{var z,$,ee;try{const J=l(L);J&&typeof J.then=="function"?J.then(()=>{var K,Q;((K=_.current)==null?void 0:K.id)===te&&_.current.shouldClear&&(y||(S(""),E.current&&(E.current.style.height="auto"),a==null||a(""))),((Q=_.current)==null?void 0:Q.id)===te&&(_.current=null)}).catch(()=>{var K;((K=_.current)==null?void 0:K.id)===te&&(_.current=null)}):(((z=_.current)==null?void 0:z.id)===te&&_.current.shouldClear&&(y||(S(""),E.current&&(E.current.style.height="auto"),a==null||a(""))),(($=_.current)==null?void 0:$.id)===te&&(_.current=null))}catch{((ee=_.current)==null?void 0:ee.id)===te&&(_.current=null)}})},[k,l,p,y,a,X]),I=v.useCallback(M=>{const L=M.target.value;B(L,{fromUser:!0}),_.current&&(_.current.shouldClear=!1),E.current&&(E.current.style.height="auto",E.current.style.height=`${E.current.scrollHeight}px`),F&&X(L.trim())},[B,X,F]),H=v.useCallback(M=>{M.key==="Enter"&&!M.shiftKey?(M.preventDefault(),R()):M.key==="Escape"&&t&&(M.preventDefault(),u==null||u())},[R,t,u]),O=`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${t?"border-[hsl(var(--ring))] bg-[hsl(var(--card))] text-[hsl(var(--card-foreground))] dark:bg-[hsl(var(--card))] dark:text-[hsl(var(--card-foreground))]":""} ${m}`;return c.jsx("form",{onSubmit:M=>void R(M),className:`w-full ${f}`,children:c.jsxs("div",{className:"flex items-end gap-2",children:[c.jsxs("div",{className:"flex-1",children:[c.jsx(_a,{ref:E,value:k,onChange:I,onKeyDown:H,placeholder:t?"Edit your message...":n,className:O,disabled:o,maxLength:s,rows:1,spellCheck:!1,autoCorrect:"off"}),F&&c.jsx("p",{className:"mt-1 text-xs text-destructive font-medium",children:F})]}),c.jsx("div",{children:r?c.jsx(Je,{type:"button",onClick:()=>{d==null||d()},size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",disabled:o||!d,children:c.jsx(ae.Square,{size:16})}):c.jsx(Je,{type:"submit",size:"icon",className:`shrink-0 ${b??""}`,title:t?"Save changes":"Send message",disabled:o||!k.trim()&&!p||C,children:c.jsx(ae.Send,{size:16})})})]})})}const uC=v.memo(tp);function np({composerValue:e,onComposerChange:t,onSend:n,onCancelEdit:r,onStop:o,editingMessageId:s=null,editingInitialValue:i="",placeholder:a="Type your message...",isStreaming:l=!1,disabled:u=!1,textareaClassName:d="",customStyles:f={},enableFileUpload:m=!1,enableExcelUpload:p=!1,onExcelUpload:b,onError:g,allowEmptySend:x=!1,inputError:y=null}){const[w,S]=v.useState([]),k=v.useRef(null),C=v.useRef(null),[T,E]=v.useState(0),[j,_]=v.useState(0),[D,F]=v.useState(!1),[W,G]=v.useState(null),[A,X]=v.useState(null),q=v.useCallback(()=>{k.current&&(k.current.value=""),C.current&&(C.current.value=""),E(M=>M+1),_(M=>M+1)},[]),B=v.useCallback(M=>{S(L=>[...L,...M])},[]),R=v.useCallback(M=>{const L=Array.from(M.target.files||[]);B(L),M.target.value=""},[B]),I=v.useCallback(M=>{S(L=>{const te=L.filter((z,$)=>$!==M);return te.length===0&&q(),te})},[q]),H=v.useCallback(async M=>{const L=(M.target.files||[])[0];if(L&&(G(null),X(null),!!b)){F(!0);try{await b(L),G(`Uploaded ${L.name} - processing through chat stream`)}catch(te){const z=te instanceof Error?te.message:"Failed to upload Excel file";X(z),g==null||g(z)}finally{F(!1),M.target.value="",q()}}},[b,g,q]),Y=v.useMemo(()=>x||w.length>0,[x,w]),P=v.useCallback(async M=>{const L=n(M,w);try{const te=await L;return w.length>0&&(S([]),q()),te}catch(te){throw te}},[n,q,w]),O=`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${s?"border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50":""} ${y?"border-red-400":""} ${f.textarea||""} ${d}`;return c.jsxs(c.Fragment,{children:[(m||p)&&c.jsxs("div",{className:"mb-3 space-y-3",children:[m&&c.jsxs(c.Fragment,{children:[c.jsx("input",{ref:k,type:"file",multiple:!0,onChange:R,className:"hidden"},T),w.length>0&&c.jsx("div",{className:"flex flex-wrap gap-2",children:w.map((M,L)=>c.jsxs("div",{className:"flex items-center gap-2 bg-gray-100 dark:bg-gray-800 rounded-lg px-3 py-2 text-sm text-gray-900 dark:text-gray-100",children:[c.jsx(ae.Paperclip,{size:14}),c.jsx("span",{className:"truncate max-w-[150px]",children:M.name}),c.jsx(Je,{variant:"ghost",size:"sm",onClick:()=>I(L),className:"h-4 w-4 p-0 text-gray-500 dark:text-gray-400 hover:text-red-500 dark:hover:text-red-400","aria-label":`Remove ${M.name}`,children:c.jsx(ae.X,{size:12})})]},L))})]}),p&&c.jsxs(c.Fragment,{children:[c.jsx("input",{ref:C,type:"file",accept:".xls,.xlsx,.xlsm",onChange:H,className:"hidden"},j),D&&c.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[c.jsx(ae.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),W&&!D&&c.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:W}),A&&!D&&c.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:A})]})]}),c.jsxs("div",{className:"flex items-end gap-2",children:[(m||p)&&c.jsxs(Es,{children:[c.jsx(Is,{asChild:!0,children:c.jsx(Je,{type:"button",size:"icon",variant:"outline",disabled:l||u,title:"More input actions",className:f.moreButton||"",children:c.jsx(ae.Plus,{size:16})})}),c.jsxs(xo,{align:"start",sideOffset:6,className:"w-52",children:[m&&c.jsxs(zn,{onClick:()=>{var M;return(M=k.current)==null?void 0:M.click()},className:"cursor-pointer",children:[c.jsx(ae.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),p&&c.jsxs(zn,{onClick:()=>{var M;D||(M=C.current)==null||M.click()},className:`cursor-pointer ${D?"opacity-60 pointer-events-none":""}`,children:[c.jsx(ae.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),c.jsx("div",{className:"flex-1",children:c.jsx(uC,{initialValue:i,editingMessageId:s,value:e,onValueChange:t,placeholder:s?"Edit your message...":a,isStreaming:l,disabled:u,onSend:P,onCancelEdit:r,onStop:o,allowEmptySend:Y,textareaClassName:O,sendButtonClassName:f.sendButton})})]})]})}const dC=v.memo(np),Ns=0,Hn=1,Rr=2,rp=4;function op(e){return()=>e}function fC(e){e()}function sp(e,t){return n=>e(t(n))}function ip(e,t){return()=>e(t)}function pC(e,t){return n=>e(t,n)}function Pa(e){return e!==void 0}function hC(...e){return()=>{e.map(fC)}}function Mr(){}function As(e,t){return t(e),e}function mC(e,t){return t(e)}function rt(...e){return e}function Ye(e,t){return e(Hn,t)}function Pe(e,t){e(Ns,t)}function Ra(e){e(Rr)}function pt(e){return e(rp)}function xe(e,t){return Ye(e,pC(t,Ns))}function fn(e,t){const n=e(Hn,r=>{n(),t(r)});return n}function ap(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function lp(e,t){return e===t}function ot(e=lp){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function Ee(e){return t=>n=>{e(n)&&t(n)}}function ue(e){return t=>sp(t,e)}function kn(e){return t=>()=>{t(e)}}function re(e,...t){const n=gC(...t);return(r,o)=>{switch(r){case Rr:Ra(e);return;case Hn:return Ye(e,n(o))}}}function En(e,t){return n=>r=>{n(t=e(t,r))}}function or(e){return t=>n=>{e>0?e--:t(n)}}function Rn(e){let t=null,n;return r=>o=>{t=o,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function De(...e){const t=new Array(e.length);let n=0,r=null;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const a=Math.pow(2,i);Ye(s,l=>{const u=n;n=n|a,t[i]=l,u!==o&&n===o&&r&&(r(),r=null)})}),s=>i=>{const a=()=>{s([i].concat(t))};n===o?a():r=a}}function gC(...e){return t=>e.reduceRight(mC,t)}function xC(e){let t,n;const r=()=>t==null?void 0:t();return function(o,s){switch(o){case Hn:return s?n===s?void 0:(r(),n=s,t=Ye(e,s),t):(r(),Mr);case Rr:r(),n=null;return}}}function se(e){let t=e;const n=ze();return(r,o)=>{switch(r){case Ns:t=o;break;case Hn:{o(t);break}case rp:return t}return n(r,o)}}function Pt(e,t){return As(se(t),n=>xe(e,n))}function ze(){const e=[];return(t,n)=>{switch(t){case Ns:e.slice().forEach(r=>{r(n)});return;case Rr:e.splice(0,e.length);return;case Hn:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}}}function Qt(e){return As(ze(),t=>xe(e,t))}function qe(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:vC(),singleton:n}}const vC=()=>Symbol();function bC(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 xt(...e){const t=ze(),n=new Array(e.length);let r=0;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const a=Math.pow(2,i);Ye(s,l=>{n[i]=l,r=r|a,r===o&&Pe(t,n)})}),function(s,i){switch(s){case Rr:{Ra(t);return}case Hn:return r===o&&i(n),Ye(t,i)}}}function Ce(e,t=lp){return re(e,ot(t))}function Ma(...e){return function(t,n){switch(t){case Rr:return;case Hn:return hC(...e.map(r=>Ye(r,n)))}}}var Ht=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(Ht||{});const wC={0:"debug",3:"error",1:"log",2:"warn"},yC=()=>typeof globalThis>"u"?window:globalThis,Un=qe(()=>{const e=se(3);return{log:se((t,n,r=1)=>{var o;const s=(o=yC().VIRTUOSO_LOG_LEVEL)!=null?o:pt(e);r>=s&&console[wC[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0});function sr(e,t,n){return Oa(e,t,n).callbackRef}function Oa(e,t,n){const r=v.useRef(null);let o=i=>{};const s=v.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 SC(e,t,n,r,o,s,i,a,l){const u=v.useCallback(d=>{const f=CC(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 b;p&&(b=m.ownerDocument.defaultView);const g=i?a?i.scrollLeft:i.scrollTop:p?a?b.scrollX||b.document.documentElement.scrollLeft:b.scrollY||b.document.documentElement.scrollTop:a?m.scrollLeft:m.scrollTop,x=i?a?i.scrollWidth:i.scrollHeight:p?a?b.document.documentElement.scrollWidth:b.document.documentElement.scrollHeight:a?m.scrollWidth:m.scrollHeight,y=i?a?i.offsetWidth:i.offsetHeight:p?a?b.innerWidth:b.innerHeight:a?m.offsetWidth:m.offsetHeight;r({scrollHeight:x,scrollTop:Math.max(g,0),viewportHeight:y}),s==null||s(a?cp("column-gap",getComputedStyle(d).columnGap,o):cp("row-gap",getComputedStyle(d).rowGap,o)),f!==null&&e(f)},[e,t,o,s,i,r,a]);return Oa(u,n,l)}function CC(e,t,n,r){const o=e.length;if(o===0)return null;const s=[];for(let i=0;i<o;i++){const a=e.item(i);if(a.dataset.index===void 0)continue;const l=parseInt(a.dataset.index),u=parseFloat(a.dataset.knownSize),d=t(a,n);if(d===0&&r("Zero-sized element, this should not happen",{child:a},Ht.ERROR),d===u)continue;const f=s[s.length-1];s.length===0||f.size!==d||f.endIndex!==l-1?s.push({endIndex:l,size:d,startIndex:l}):s[s.length-1].endIndex++}return s}function cp(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Ht.WARN),t==="normal"?0:parseInt(t??"0",10)}function up(e,t,n){const r=v.useRef(null),o=v.useCallback(l=>{if(!(l!=null&&l.offsetParent))return;const u=l.getBoundingClientRect(),d=u.width;let f,m;if(t){const p=t.getBoundingClientRect(),b=u.top-p.top;m=p.height-Math.max(0,b),f=b+t.scrollTop}else{const p=i.current.ownerDocument.defaultView;m=p.innerHeight-Math.max(0,u.top),f=u.top+p.scrollY}r.current={offsetTop:f,visibleHeight:m,visibleWidth:d},e(r.current)},[e,t]),{callbackRef:s,ref:i}=Oa(o,!0,n),a=v.useCallback(()=>{o(i.current)},[o,i]);return v.useEffect(()=>{var l;if(t){t.addEventListener("scroll",a);const u=new ResizeObserver(()=>{requestAnimationFrame(a)});return u.observe(t),()=>{t.removeEventListener("scroll",a),u.unobserve(t)}}else{const u=(l=i.current)==null?void 0:l.ownerDocument.defaultView;return u==null||u.addEventListener("scroll",a),u==null||u.addEventListener("resize",a),()=>{u==null||u.removeEventListener("scroll",a),u==null||u.removeEventListener("resize",a)}}},[a,t,i]),s}const $t=qe(()=>{const e=ze(),t=ze(),n=se(0),r=ze(),o=se(0),s=ze(),i=ze(),a=se(0),l=se(0),u=se(0),d=se(0),f=ze(),m=ze(),p=se(!1),b=se(!1),g=se(!1);return xe(re(e,ue(({scrollTop:x})=>x)),t),xe(re(e,ue(({scrollHeight:x})=>x)),i),xe(t,o),{deviation:n,fixedFooterHeight:u,fixedHeaderHeight:l,footerHeight:d,headerHeight:a,horizontalDirection:b,scrollBy:m,scrollContainerState:e,scrollHeight:i,scrollingInProgress:p,scrollTo:f,scrollTop:t,skipAnimationFrameInResizeObserver:g,smoothScrollTargetReached:r,statefulScrollTop:o,viewportHeight:s}},[],{singleton:!0}),vo={lvl:0};function dp(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 et(e){return e===vo}function bo(e,t){if(!et(e))return t===e.k?e.v:t<e.k?bo(e.l,t):bo(e.r,t)}function pn(e,t,n="k"){if(et(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){const r=pn(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return pn(e.l,t,n)}function en(e,t,n){return et(e)?hp(t,n,1):t===e.k?yt(e,{k:t,v:n}):t<e.k?mp(yt(e,{l:en(e.l,t,n)})):mp(yt(e,{r:en(e.r,t,n)}))}function Or(){return vo}function js(e,t,n){if(et(e))return[];const r=pn(e,t)[0];return TC(La(e,r,n))}function Da(e,t){if(et(e))return vo;const{k:n,l:r,r:o}=e;if(t===n){if(et(r))return o;if(et(o))return r;{const[s,i]=pp(r);return _s(yt(e,{k:s,l:fp(r),v:i}))}}else return t<n?_s(yt(e,{l:Da(r,t)})):_s(yt(e,{r:Da(o,t)}))}function ir(e){return et(e)?[]:[...ir(e.l),{k:e.k,v:e.v},...ir(e.r)]}function La(e,t,n){if(et(e))return[];const{k:r,l:o,r:s,v:i}=e;let a=[];return r>t&&(a=a.concat(La(o,t,n))),r>=t&&r<=n&&a.push({k:r,v:i}),r<=n&&(a=a.concat(La(s,t,n))),a}function _s(e){const{l:t,lvl:n,r}=e;if(r.lvl>=n-1&&t.lvl>=n-1)return e;if(n>r.lvl+1){if($a(t))return gp(yt(e,{lvl:n-1}));if(!et(t)&&!et(t.r))return yt(t.r,{l:yt(t,{r:t.r.l}),lvl:n,r:yt(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if($a(e))return Fa(yt(e,{lvl:n-1}));if(!et(r)&&!et(r.l)){const o=r.l,s=$a(o)?r.lvl-1:r.lvl;return yt(o,{l:yt(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:Fa(yt(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function yt(e,t){return hp(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 fp(e){return et(e.r)?e.l:_s(yt(e,{r:fp(e.r)}))}function $a(e){return et(e)||e.lvl>e.r.lvl}function pp(e){return et(e.r)?[e.k,e.v]:pp(e.r)}function hp(e,t,n,r=vo,o=vo){return{k:e,l:r,lvl:n,r:o,v:t}}function mp(e){return Fa(gp(e))}function gp(e){const{l:t}=e;return!et(t)&&t.lvl===e.lvl?yt(t,{r:yt(e,{l:t.r})}):e}function Fa(e){const{lvl:t,r:n}=e;return!et(n)&&!et(n.r)&&n.lvl===t&&n.r.lvl===t?yt(n,{l:yt(e,{r:n.l}),lvl:t+1}):e}function TC(e){return dp(e,({k:t,v:n})=>({index:t,value:n}))}function xp(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function wo(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const Ba=qe(()=>({recalcInProgress:se(!1)}),[],{singleton:!0});function vp(e,t,n){return e[Ps(e,t,n)]}function Ps(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 kC(e,t,n,r){const o=Ps(e,t,r),s=Ps(e,n,r,o);return e.slice(o,s+1)}function Wn(e,t){return Math.round(e.getBoundingClientRect()[t])}function Rs(e){return!et(e.groupOffsetTree)}function za({index:e},t){return t===e?0:t<e?-1:1}function EC(){return{groupIndices:[],groupOffsetTree:Or(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Or()}}function IC(e,t){let n=et(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),et(e)){e=en(e,0,s);continue}const a=js(e,i-1,o+1);if(a.some(MC(r)))continue;let l=!1,u=!1;for(const{end:d,start:f,value:m}of a)l?(o>=f||s===m)&&(e=Da(e,f)):(u=m!==s,l=!0),d>o&&o>=f&&m!==s&&(e=en(e,o+1,m));u&&(e=en(e,i,s))}return[e,n]}function NC(e){return typeof e.groupIndex<"u"}function AC({offset:e},t){return t===e?0:t<e?-1:1}function yo(e,t,n){if(t.length===0)return 0;const{index:r,offset:o,size:s}=vp(t,e,za),i=e-r,a=s*i+(i-1)*n+o;return a>0?a+n:a}function bp(e,t){if(!Rs(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function wp(e,t,n){if(NC(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=bp(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function jC(e,t,n,r=0){return r>0&&(t=Math.max(t,vp(e,r,za).offset)),dp(kC(e,t,n,AC),RC)}function _C(e,[t,n,r,o]){t.length>0&&r("received item sizes",t,Ht.DEBUG);const s=e.sizeTree;let i=s,a=0;if(n.length>0&&et(s)&&t.length===2){const m=t[0].size,p=t[1].size;i=n.reduce((b,g)=>en(en(b,g,m),g+1,p),i)}else[i,a]=IC(i,t);if(i===s)return e;const{lastIndex:l,lastOffset:u,lastSize:d,offsetTree:f}=Ha(e.offsetTree,a,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((m,p)=>en(m,p,yo(p,f,o)),Or()),lastIndex:l,lastOffset:u,lastSize:d,offsetTree:f,sizeTree:i}}function PC(e){return ir(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 yp(e,t){let n=0,r=0;for(;n<e;)n+=t[r+1]-t[r]-1,r++;return r-(n===e?0:1)}function Ha(e,t,n,r){let o=e,s=0,i=0,a=0,l=0;if(t!==0){l=Ps(o,t-1,za),a=o[l].offset;const u=pn(n,t-1);s=u[0],i=u[1],o.length&&o[l].size===pn(n,t)[1]&&(l-=1),o=o.slice(0,l+1)}else o=[];for(const{start:u,value:d}of js(n,t,1/0)){const f=u-s,m=f*i+a+f*r;o.push({index:u,offset:m,size:d}),s=u,a=m,i=d}return{lastIndex:s,lastOffset:a,lastSize:i,offsetTree:o}}function RC(e){return{index:e.index,value:e}}function MC(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 OC={offsetHeight:"height",offsetWidth:"width"},In=qe(([{log:e},{recalcInProgress:t}])=>{const n=ze(),r=ze(),o=Pt(r,0),s=ze(),i=ze(),a=se(0),l=se([]),u=se(void 0),d=se(void 0),f=se((C,T)=>Wn(C,OC[T])),m=se(void 0),p=se(0),b=EC(),g=Pt(re(n,De(l,e,p),En(_C,b),ot()),b),x=Pt(re(l,ot(),En((C,T)=>({current:T,prev:C.current}),{current:[],prev:[]}),ue(({prev:C})=>C)),[]);xe(re(l,Ee(C=>C.length>0),De(g,p),ue(([C,T,E])=>{const j=C.reduce((_,D,F)=>en(_,D,yo(D,T.offsetTree,E)||F),Or());return{...T,groupIndices:C,groupOffsetTree:j}})),g),xe(re(r,De(g),Ee(([C,{lastIndex:T}])=>C<T),ue(([C,{lastIndex:T,lastSize:E}])=>[{endIndex:T,size:E,startIndex:C}])),n),xe(u,d);const y=Pt(re(u,ue(C=>C===void 0)),!0);xe(re(d,Ee(C=>C!==void 0&&et(pt(g).sizeTree)),ue(C=>[{endIndex:0,size:C,startIndex:0}])),n);const w=Qt(re(n,De(g),En(({sizes:C},[T,E])=>({changed:E!==C,sizes:E}),{changed:!1,sizes:b}),ue(C=>C.changed)));Ye(re(a,En((C,T)=>({diff:C.prev-T,prev:T}),{diff:0,prev:0}),ue(C=>C.diff)),C=>{const{groupIndices:T}=pt(g);if(C>0)Pe(t,!0),Pe(s,C+yp(C,T));else if(C<0){const E=pt(x);E.length>0&&(C-=yp(-C,E)),Pe(i,C)}}),Ye(re(a,De(e)),([C,T])=>{C<0&&T("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:a},Ht.ERROR)});const S=Qt(s);xe(re(s,De(g),ue(([C,T])=>{const E=T.groupIndices.length>0,j=[],_=T.lastSize;if(E){const D=bo(T.sizeTree,0);let F=0,W=0;for(;F<C;){const A=T.groupIndices[W],X=T.groupIndices.length===W+1?1/0:T.groupIndices[W+1]-A-1;j.push({endIndex:A,size:D,startIndex:A}),j.push({endIndex:A+1+X-1,size:_,startIndex:A+1}),W++,F+=X+1}const G=ir(T.sizeTree);return F!==C&&G.shift(),G.reduce((A,{k:X,v:q})=>{let B=A.ranges;return A.prevSize!==0&&(B=[...A.ranges,{endIndex:X+C-1,size:A.prevSize,startIndex:A.prevIndex}]),{prevIndex:X+C,prevSize:q,ranges:B}},{prevIndex:C,prevSize:0,ranges:j}).ranges}return ir(T.sizeTree).reduce((D,{k:F,v:W})=>({prevIndex:F+C,prevSize:W,ranges:[...D.ranges,{endIndex:F+C-1,size:D.prevSize,startIndex:D.prevIndex}]}),{prevIndex:0,prevSize:_,ranges:[]}).ranges})),n);const k=Qt(re(i,De(g,p),ue(([C,{offsetTree:T},E])=>{const j=-C;return yo(j,T,E)})));return xe(re(i,De(g,p),ue(([C,T,E])=>{if(T.groupIndices.length>0){if(et(T.sizeTree))return T;let j=Or();const _=pt(x);let D=0,F=0,W=0;for(;D<-C;){W=_[F];const G=_[F+1]-W-1;F++,D+=G+1}if(j=ir(T.sizeTree).reduce((G,{k:A,v:X})=>en(G,Math.max(0,A+C),X),j),D!==-C){const G=bo(T.sizeTree,W);j=en(j,0,G);const A=pn(T.sizeTree,-C+1)[1];j=en(j,1,A)}return{...T,sizeTree:j,...Ha(T.offsetTree,0,j,E)}}else{const j=ir(T.sizeTree).reduce((_,{k:D,v:F})=>en(_,Math.max(0,D+C),F),Or());return{...T,sizeTree:j,...Ha(T.offsetTree,0,j,E)}}})),g),{beforeUnshiftWith:S,data:m,defaultItemSize:d,firstItemIndex:a,fixedItemSize:u,gap:p,groupIndices:l,itemSize:f,listRefresh:w,shiftWith:i,shiftWithOffset:k,sizeRanges:n,sizes:g,statefulTotalCount:o,totalCount:r,trackItemSizes:y,unshiftWith:s}},rt(Un,Ba),{singleton:!0});function DC(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const Sp=qe(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=ze(),i=ze(),a=Qt(re(s,ue(DC)));return xe(re(a,ue(l=>l.totalCount)),n),xe(re(a,ue(l=>l.groupIndices)),e),xe(re(xt(o,t,r),Ee(([l,u])=>Rs(u)),ue(([l,u,d])=>pn(u.groupOffsetTree,Math.max(l-d,0),"v")[0]),ot(),ue(l=>[l])),i),{groupCounts:s,topItemsIndexes:i}},rt(In,$t)),Vn=qe(([{log:e}])=>{const t=se(!1),n=Qt(re(t,Ee(r=>r),ot()));return Ye(t,r=>{r&&pt(e)("props updated",{},Ht.DEBUG)}),{didMount:n,propsReady:t}},rt(Un),{singleton:!0}),LC=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function Cp(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!LC)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const So=qe(([{gap:e,listRefresh:t,sizes:n,totalCount:r},{fixedFooterHeight:o,fixedHeaderHeight:s,footerHeight:i,headerHeight:a,scrollingInProgress:l,scrollTo:u,smoothScrollTargetReached:d,viewportHeight:f},{log:m}])=>{const p=ze(),b=ze(),g=se(0);let x=null,y=null,w=null;function S(){x&&(x(),x=null),w&&(w(),w=null),y&&(clearTimeout(y),y=null),Pe(l,!1)}return xe(re(p,De(n,f,r,g,a,i,m),De(e,s,o),ue(([[k,C,T,E,j,_,D,F],W,G,A])=>{const X=Cp(k),{align:q,behavior:B,offset:R}=X,I=E-1,H=wp(X,C,I);let Y=yo(H,C.offsetTree,W)+_;q==="end"?(Y+=G+pn(C.sizeTree,H)[1]-T+A,H===I&&(Y+=D)):q==="center"?Y+=(G+pn(C.sizeTree,H)[1]-T+A)/2:Y-=j,R&&(Y+=R);const P=O=>{S(),O?(F("retrying to scroll to",{location:k},Ht.DEBUG),Pe(p,k)):(Pe(b,!0),F("list did not change, scroll successful",{},Ht.DEBUG))};if(S(),B==="smooth"){let O=!1;w=Ye(t,M=>{O=O||M}),x=fn(d,()=>{P(O)})}else x=fn(re(t,$C(150)),P);return y=setTimeout(()=>{S()},1200),Pe(l,!0),F("scrolling from index to",{behavior:B,index:H,top:Y},Ht.DEBUG),{behavior:B,top:Y}})),u),{scrollTargetReached:b,scrollToIndex:p,topListHeight:g}},rt(In,$t,Un),{singleton:!0});function $C(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function Ua(e,t){e==0?t():requestAnimationFrame(()=>{Ua(e-1,t)})}function Wa(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const Co=qe(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:s},{didMount:i}])=>{const a=se(!0),l=se(0),u=se(!0);return xe(re(i,De(l),Ee(([d,f])=>!!f),kn(!1)),a),xe(re(i,De(l),Ee(([d,f])=>!!f),kn(!1)),u),Ye(re(xt(t,i),De(a,n,e,u),Ee(([[,d],f,{sizeTree:m},p,b])=>d&&(!et(m)||Pa(p))&&!f&&!b),De(l)),([,d])=>{fn(o,()=>{Pe(u,!0)}),Ua(4,()=>{fn(r,()=>{Pe(a,!0)}),Pe(s,d)})}),{initialItemFinalLocationReached:u,initialTopMostItemIndex:l,scrolledToInitialItem:a}},rt(In,$t,So,Vn),{singleton:!0});function Tp(e,t){return Math.abs(e-t)<1.01}const To="up",ko="down",FC="none",BC={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},zC=0,Eo=qe(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=se(!1),a=se(!0),l=ze(),u=ze(),d=se(4),f=se(zC),m=Pt(re(Ma(re(Ce(o),or(1),kn(!0)),re(Ce(o),or(1),kn(!1),ap(100))),ot()),!1),p=Pt(re(Ma(re(n,kn(!0)),re(n,kn(!1),ap(200))),ot()),!1);xe(re(xt(Ce(o),Ce(f)),ue(([w,S])=>w<=S),ot()),a),xe(re(a,Rn(50)),u);const b=Qt(re(xt(r,Ce(s),Ce(t),Ce(e),Ce(d)),En((w,[{scrollHeight:S,scrollTop:k},C,T,E,j])=>{const _=k+C-S>-j,D={scrollHeight:S,scrollTop:k,viewportHeight:C};if(_){let W,G;return k>w.state.scrollTop?(W="SCROLLED_DOWN",G=w.state.scrollTop-k):(W="SIZE_DECREASED",G=w.state.scrollTop-k||w.scrollTopDelta),{atBottom:!0,atBottomBecause:W,scrollTopDelta:G,state:D}}let F;return D.scrollHeight>w.state.scrollHeight?F="SIZE_INCREASED":C<w.state.viewportHeight?F="VIEWPORT_HEIGHT_DECREASING":k<w.state.scrollTop?F="SCROLLING_UPWARDS":F="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:F,state:D}},BC),ot((w,S)=>w&&w.atBottom===S.atBottom))),g=Pt(re(r,En((w,{scrollHeight:S,scrollTop:k,viewportHeight:C})=>{if(Tp(w.scrollHeight,S))return{changed:!1,jump:0,scrollHeight:S,scrollTop:k};{const T=S-(k+C)<1;return w.scrollTop!==k&&T?{changed:!0,jump:w.scrollTop-k,scrollHeight:S,scrollTop:k}:{changed:!0,jump:0,scrollHeight:S,scrollTop:k}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),Ee(w=>w.changed),ue(w=>w.jump)),0);xe(re(b,ue(w=>w.atBottom)),i),xe(re(i,Rn(50)),l);const x=se(ko);xe(re(r,ue(({scrollTop:w})=>w),ot(),En((w,S)=>pt(p)?{direction:w.direction,prevScrollTop:S}:{direction:S<w.prevScrollTop?To:ko,prevScrollTop:S},{direction:ko,prevScrollTop:0}),ue(w=>w.direction)),x),xe(re(r,Rn(50),kn(FC)),x);const y=se(0);return xe(re(m,Ee(w=>!w),kn(0)),y),xe(re(o,Rn(100),De(m),Ee(([w,S])=>!!S),En(([w,S],[k])=>[S,k],[0,0]),ue(([w,S])=>S-w)),y),{atBottomState:b,atBottomStateChange:l,atBottomThreshold:d,atTopStateChange:u,atTopThreshold:f,isAtBottom:i,isAtTop:a,isScrolling:m,lastJumpDueToItemResize:g,scrollDirection:x,scrollVelocity:y}},rt($t)),Ms="top",Os="bottom",kp="none";function Ep(e,t,n){return typeof e=="number"?n===To&&t===Ms||n===ko&&t===Os?e:0:n===To?t===Ms?e.main:e.reverse:t===Os?e.main:e.reverse}function Ip(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const Va=qe(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=ze(),i=se(0),a=se(0),l=se(0),u=Pt(re(xt(Ce(r),Ce(o),Ce(n),Ce(s,wo),Ce(l),Ce(i),Ce(t),Ce(e),Ce(a)),ue(([d,f,m,[p,b],g,x,y,w,S])=>{const k=d-w,C=x+y,T=Math.max(m-k,0);let E=kp;const j=Ip(S,Ms),_=Ip(S,Os);return p-=w,p+=m+y,b+=m+y,b-=w,p>d+C-j&&(E=To),b<d-T+f+_&&(E=ko),E!==kp?[Math.max(k-m-Ep(g,Ms,E)-j,0),k-T-y+f+Ep(g,Os,E)+_]:null}),Ee(d=>d!=null),ot(wo)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:l,topListHeight:i,visibleRange:u}},rt($t),{singleton:!0});function HC(e,t,n){if(Rs(t)){const r=bp(e,t);return[{index:pn(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 Ka={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Ds(e,t,n,r,o,s){const{lastIndex:i,lastOffset:a,lastSize:l}=o;let u=0,d=0;if(e.length>0){u=e[0].offset;const g=e[e.length-1];d=g.offset+g.size}const f=n-i,m=a+f*l+(f-1)*r,p=u,b=m-d;return{bottom:d,firstItemIndex:s,items:Ap(e,o,s),offsetBottom:b,offsetTop:u,top:p,topItems:Ap(t,o,s),topListHeight:t.reduce((g,x)=>x.size+g,0),totalCount:n}}function Np(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=Wa(t,a),u=Array.from({length:a}).map((d,f)=>({data:s[f+l],index:f+l,offset:0,size:0}));return Ds(u,[],a,o,n,r)}function Ap(e,t,n){if(e.length===0)return[];if(!Rs(t))return e.map(u=>({...u,index:u.index+n,originalIndex:u.index}));const r=e[0].index,o=e[e.length-1].index,s=[],i=js(t.groupOffsetTree,r,o);let a,l=0;for(const u of e){(!a||a.end<u.index)&&(a=i.shift(),l=t.groupIndices.indexOf(a.start));let d;u.index===a.start?d={index:l,type:"group"}:d={groupIndex:l,index:u.index-(l+1)+n},s.push({...d,data:u.data,offset:u.offset,originalIndex:u.index,size:u.size})}return s}const ar=qe(([{data:e,firstItemIndex:t,gap:n,sizes:r,totalCount:o},s,{listBoundary:i,topListHeight:a,visibleRange:l},{initialTopMostItemIndex:u,scrolledToInitialItem:d},{topListHeight:f},m,{didMount:p},{recalcInProgress:b}])=>{const g=se([]),x=se(0),y=ze();xe(s.topItemsIndexes,g);const w=Pt(re(xt(p,b,Ce(l,wo),Ce(o),Ce(r),Ce(u),d,Ce(g),Ce(t),Ce(n),e),Ee(([T,E,,j,,,,,,,_])=>{const D=_&&_.length!==j;return T&&!E&&!D}),ue(([,,[T,E],j,_,D,F,W,G,A,X])=>{const q=_,{offsetTree:B,sizeTree:R}=q,I=pt(x);if(j===0)return{...Ka,totalCount:j};if(T===0&&E===0)return I===0?{...Ka,totalCount:j}:Np(I,D,_,G,A,X||[]);if(et(R))return I>0?null:Ds(HC(Wa(D,j),q,X),[],j,A,q,G);const H=[];if(W.length>0){const L=W[0],te=W[W.length-1];let z=0;for(const $ of js(R,L,te)){const ee=$.value,J=Math.max($.start,L),K=Math.min($.end,te);for(let Q=J;Q<=K;Q++)H.push({data:X==null?void 0:X[Q],index:Q,offset:z,size:ee}),z+=ee}}if(!F)return Ds([],H,j,A,q,G);const Y=W.length>0?W[W.length-1]+1:0,P=jC(B,T,E,Y);if(P.length===0)return null;const O=j-1,M=As([],L=>{for(const te of P){const z=te.value;let $=z.offset,ee=te.start;const J=z.size;if(z.offset<T){ee+=Math.floor((T-z.offset+A)/(J+A));const Q=ee-te.start;$+=Q*J+Q*A}ee<Y&&($+=(Y-ee)*J,ee=Y);const K=Math.min(te.end,O);for(let Q=ee;Q<=K&&!($>=E);Q++)L.push({data:X==null?void 0:X[Q],index:Q,offset:$,size:J}),$+=J+A}});return Ds(M,H,j,A,q,G)}),Ee(T=>T!==null),ot()),Ka);xe(re(e,Ee(Pa),ue(T=>T==null?void 0:T.length)),o),xe(re(w,ue(T=>T.topListHeight)),f),xe(f,a),xe(re(w,ue(T=>[T.top,T.bottom])),i),xe(re(w,ue(T=>T.items)),y);const S=Qt(re(w,Ee(({items:T})=>T.length>0),De(o,e),Ee(([{items:T},E])=>T[T.length-1].originalIndex===E-1),ue(([,T,E])=>[T-1,E]),ot(wo),ue(([T])=>T))),k=Qt(re(w,Rn(200),Ee(({items:T,topItems:E})=>T.length>0&&T[0].originalIndex===E.length),ue(({items:T})=>T[0].index),ot())),C=Qt(re(w,Ee(({items:T})=>T.length>0),ue(({items:T})=>{let E=0,j=T.length-1;for(;T[E].type==="group"&&E<j;)E++;for(;T[j].type==="group"&&j>E;)j--;return{endIndex:T[j].index,startIndex:T[E].index}}),ot(xp)));return{endReached:S,initialItemCount:x,itemsRendered:y,listState:w,rangeChanged:C,startReached:k,topItemsIndexes:g,...m}},rt(In,Sp,Va,Co,So,Eo,Vn,Ba),{singleton:!0}),jp=qe(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=ze(),i=Pt(re(xt(n,e,r,t,o),ue(([a,l,u,d,f])=>a+l+u+d+f.offsetBottom+f.bottom)),0);return xe(Ce(i),s),{totalListHeight:i,totalListHeightChanged:s}},rt($t,ar),{singleton:!0}),UC=qe(([{viewportHeight:e},{totalListHeight:t}])=>{const n=se(!1),r=Pt(re(xt(n,e,t),Ee(([o])=>o),ue(([,o,s])=>Math.max(0,o-s)),Rn(0),ot()),0);return{alignToBottom:n,paddingTopAddition:r}},rt($t,jp),{singleton:!0}),_p=qe(()=>({context:se(null)})),WC=({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,Pp=qe(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:s,scrollingInProgress:i,scrollTop:a,viewportHeight:l},{scrollToIndex:u}])=>{const d=ze();return xe(re(d,De(t,l,n,s,o,r,a),De(e),ue(([[f,m,p,b,g,x,y,w],S])=>{const{align:k,behavior:C,calculateViewLocation:T=WC,done:E,...j}=f,_=wp(f,m,b-1),D=yo(_,m.offsetTree,S)+g+x,F=D+pn(m.sizeTree,_)[1],W=w+x,G=w+p-y,A=T({itemBottom:F,itemTop:D,locationParams:{align:k,behavior:C,...j},viewportBottom:G,viewportTop:W});return A?E&&fn(re(i,Ee(X=>!X),or(pt(i)?1:2)),E):E&&E(),A}),Ee(f=>f!==null)),u),{scrollIntoView:d}},rt(In,$t,So,ar,Un),{singleton:!0});function Rp(e){return e?e==="smooth"?"smooth":"auto":!1}const VC=(e,t)=>typeof e=="function"?Rp(e(t)):t&&Rp(e),KC=qe(([{listRefresh:e,totalCount:t,fixedItemSize:n,data:r},{atBottomState:o,isAtBottom:s},{scrollToIndex:i},{scrolledToInitialItem:a},{didMount:l,propsReady:u},{log:d},{scrollingInProgress:f},{context:m},{scrollIntoView:p}])=>{const b=se(!1),g=ze();let x=null;function y(C){Pe(i,{align:"end",behavior:C,index:"LAST"})}Ye(re(xt(re(Ce(t),or(1)),l),De(Ce(b),s,a,f),ue(([[C,T],E,j,_,D])=>{let F=T&&_,W="auto";return F&&(W=VC(E,j||D),F=F&&!!W),{followOutputBehavior:W,shouldFollow:F,totalCount:C}}),Ee(({shouldFollow:C})=>C)),({followOutputBehavior:C,totalCount:T})=>{x&&(x(),x=null),pt(n)?requestAnimationFrame(()=>{pt(d)("following output to ",{totalCount:T},Ht.DEBUG),y(C)}):x=fn(e,()=>{pt(d)("following output to ",{totalCount:T},Ht.DEBUG),y(C),x=null})});function w(C){const T=fn(o,E=>{C&&!E.atBottom&&E.notAtBottomBecause==="SIZE_INCREASED"&&!x&&(pt(d)("scrolling to bottom due to increased size",{},Ht.DEBUG),y("auto"))});setTimeout(T,100)}Ye(re(xt(Ce(b),t,u),Ee(([C,,T])=>C&&T),En(({value:C},[,T])=>({refreshed:C===T,value:T}),{refreshed:!1,value:0}),Ee(({refreshed:C})=>C),De(b,t)),([,C])=>{pt(a)&&w(C!==!1)}),Ye(g,()=>{w(pt(b)!==!1)}),Ye(xt(Ce(b),o),([C,T])=>{C&&!T.atBottom&&T.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&y("auto")});const S=se(null),k=ze();return xe(Ma(re(Ce(r),ue(C=>{var T;return(T=C==null?void 0:C.length)!=null?T:0})),re(Ce(t))),k),Ye(re(xt(re(k,or(1)),l),De(Ce(S),a,f,m),ue(([[C,T],E,j,_,D])=>T&&j&&(E==null?void 0:E({context:D,totalCount:C,scrollingInProgress:_}))),Ee(C=>!!C),Rn(0)),C=>{x&&(x(),x=null),pt(n)?requestAnimationFrame(()=>{pt(d)("scrolling into view",{}),Pe(p,C)}):x=fn(e,()=>{pt(d)("scrolling into view",{}),Pe(p,C),x=null})}),{autoscrollToBottom:g,followOutput:b,scrollIntoViewOnChange:S}},rt(In,Eo,So,Co,Vn,Un,$t,_p,Pp)),qC=qe(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(xe(re(a,De(s),Ee(([,l])=>l!==0),De(o,r,t,n,e),ue(([[,l],u,d,f,m,p=[]])=>Np(l,u,d,f,m,p))),i),{}),rt(In,Co,ar,Vn),{singleton:!0}),GC=qe(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=se(0);return Ye(re(e,De(r),Ee(([,o])=>o!==0),ue(([,o])=>({top:o}))),o=>{fn(re(n,or(1),Ee(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{Pe(t,o)})})}),{initialScrollTop:r}},rt(Vn,$t,ar),{singleton:!0}),Mp=qe(([{scrollVelocity:e}])=>{const t=se(!1),n=ze(),r=se(!1);return xe(re(e,De(r,t,n),Ee(([o,s])=>!!s),ue(([o,s,i,a])=>{const{enter:l,exit:u}=s;if(i){if(u(o,a))return!1}else if(l(o,a))return!0;return i}),ot()),t),Ye(re(xt(t,e,n),De(r)),([[o,s,i],a])=>{o&&a&&a.change&&a.change(s,i)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},rt(Eo),{singleton:!0}),qa=qe(([{scrollContainerState:e,scrollTo:t}])=>{const n=ze(),r=ze(),o=ze(),s=se(!1),i=se(void 0);return xe(re(xt(n,r),ue(([{scrollHeight:a,scrollTop:l,viewportHeight:u},{offsetTop:d}])=>({scrollHeight:a,scrollTop:Math.max(0,l-d),viewportHeight:u}))),e),xe(re(t,De(r),ue(([a,{offsetTop:l}])=>({...a,top:a.top+l}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},rt($t)),YC=qe(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:a,windowViewportRect:l}])=>{const u=ze(),d=se(void 0),f=se(null),m=se(null);return xe(a,f),xe(l,m),Ye(re(u,De(t,r,i,f,m,n)),([p,b,g,x,y,w,S])=>{const k=PC(b.sizeTree);x&&y!==null&&w!==null&&(g=y.scrollTop-w.offsetTop),g-=S,p({ranges:k,scrollTop:g})}),xe(re(d,Ee(Pa),ue(XC)),o),xe(re(s,De(d),Ee(([,p])=>p!==void 0),ot(),ue(([,p])=>p.ranges)),e),{getState:u,restoreStateFrom:d}},rt(In,$t,Co,Vn,qa));function XC(e){return{align:"start",index:0,offset:e.scrollTop}}const JC=qe(([{topItemsIndexes:e}])=>{const t=se(0);return xe(re(t,Ee(n=>n>=0),ue(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},rt(ar));function Op(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const ZC=Op(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),QC=qe(([{deviation:e,scrollBy:t,scrollingInProgress:n,scrollTop:r},{isAtBottom:o,isScrolling:s,lastJumpDueToItemResize:i,scrollDirection:a},{listState:l},{beforeUnshiftWith:u,gap:d,shiftWithOffset:f,sizes:m},{log:p},{recalcInProgress:b}])=>{const g=Qt(re(l,De(i),En(([,y,w,S],[{bottom:k,items:C,offsetBottom:T,totalCount:E},j])=>{const _=k+T;let D=0;return w===E&&y.length>0&&C.length>0&&(C[0].originalIndex===0&&y[0].originalIndex===0||(D=_-S,D!==0&&(D+=j))),[D,C,E,_]},[0,[],0,0]),Ee(([y])=>y!==0),De(r,a,n,o,p,b),Ee(([,y,w,S,,,k])=>!k&&!S&&y!==0&&w===To),ue(([[y],,,,,w])=>(w("Upward scrolling compensation",{amount:y},Ht.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 Ye(re(g,De(e,s)),([y,w,S])=>{S&&ZC()?Pe(e,w-y):x(-y)}),Ye(re(xt(Pt(s,!1),e,b),Ee(([y,w,S])=>!y&&!S&&w!==0),ue(([y,w])=>w),Rn(1)),x),xe(re(f,ue(y=>({top:-y}))),t),Ye(re(u,De(m,d),ue(([y,{groupIndices:w,lastSize:S,sizeTree:k},C])=>{function T(E){return E*(S+C)}if(w.length===0)return T(y);{let E=0;const j=bo(k,0);let _=0,D=0;for(;_<y;){_++,E+=j;let F=w.length===D+1?1/0:w[D+1]-w[D]-1;_+F>y&&(E-=j,F=y-_+1),_+=F,E+=T(F),D++}return E}})),y=>{Pe(e,y),requestAnimationFrame(()=>{Pe(t,{top:y}),requestAnimationFrame(()=>{Pe(e,0),Pe(b,!1)})})}),{deviation:e}},rt($t,Eo,ar,In,Un,Ba)),eT=qe(([e,t,n,r,o,s,i,a,l,u,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...l,...u,...d}),rt(Va,qC,Vn,Mp,jp,GC,UC,qa,Pp,Un,_p)),Dp=qe(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:r,gap:o,groupIndices:s,itemSize:i,sizeRanges:a,sizes:l,statefulTotalCount:u,totalCount:d,trackItemSizes:f},{initialItemFinalLocationReached:m,initialTopMostItemIndex:p,scrolledToInitialItem:b},g,x,y,{listState:w,topItemsIndexes:S,...k},{scrollToIndex:C},T,{topItemCount:E},{groupCounts:j},_])=>(xe(k.rangeChanged,_.scrollSeekRangeChanged),xe(re(_.windowViewportRect,ue(D=>D.visibleHeight)),g.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,gap:o,groupCounts:j,initialItemFinalLocationReached:m,initialTopMostItemIndex:p,scrolledToInitialItem:b,sizeRanges:a,topItemCount:E,topItemsIndexes:S,totalCount:d,...y,groupIndices:s,itemSize:i,listState:w,scrollToIndex:C,statefulTotalCount:u,trackItemSizes:f,...k,..._,...g,sizes:l,...x}),rt(In,Co,$t,YC,KC,ar,So,QC,JC,Sp,eT));function tT(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 Ls=typeof document<"u"?v.useLayoutEffect:v.useEffect;function Lp(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=v.createContext({});function l(x,y){x.propsReady&&Pe(x.propsReady,!1);for(const w of r){const S=x[t.required[w]];Pe(S,y[w])}for(const w of o)if(w in y){const S=x[t.optional[w]];Pe(S,y[w])}x.propsReady&&Pe(x.propsReady,!0)}function u(x){return s.reduce((y,w)=>(y[w]=S=>{const k=x[t.methods[w]];Pe(k,S)},y),{})}function d(x){return i.reduce((y,w)=>(y[w]=xC(x[t.events[w]]),y),{})}const f=v.forwardRef((x,y)=>{const{children:w,...S}=x,[k]=v.useState(()=>As(bC(e),E=>{l(E,S)})),[C]=v.useState(ip(d,k));Ls(()=>{for(const E of i)E in S&&Ye(C[E],S[E]);return()=>{Object.values(C).map(Ra)}},[S,C,k]),Ls(()=>{l(k,S)}),v.useImperativeHandle(y,op(u(k)));const T=n;return c.jsx(a.Provider,{value:k,children:n?c.jsx(T,{...tT([...r,...o,...i],S),children:w}):w})}),m=x=>{const y=v.useContext(a);return v.useCallback(w=>{Pe(y[x],w)},[y,x])},p=x=>{const y=v.useContext(a)[x],w=v.useCallback(S=>Ye(y,S),[y]);return v.useSyncExternalStore(w,()=>pt(y),()=>pt(y))},b=x=>{const y=v.useContext(a)[x],[w,S]=v.useState(ip(pt,y));return Ls(()=>Ye(y,k=>{k!==w&&S(op(k))}),[y,w]),w},g=v.version.startsWith("18")?p:b;return{Component:f,useEmitter:(x,y)=>{const w=v.useContext(a)[x];Ls(()=>Ye(w,y),[y,w])},useEmitterValue:g,usePublisher:m}}const $p=v.createContext(void 0),Fp=v.createContext(void 0),Bp=typeof document<"u"?v.useLayoutEffect:v.useEffect;function Ga(e){return"self"in e}function nT(e){return"body"in e}function zp(e,t,n,r=Mr,o,s){const i=v.useRef(null),a=v.useRef(null),l=v.useRef(null),u=v.useCallback(m=>{let p,b,g;const x=m.target;if(nT(x)||Ga(x)){const w=Ga(x)?x:x.defaultView;g=s?w.scrollX:w.scrollY,p=s?w.document.documentElement.scrollWidth:w.document.documentElement.scrollHeight,b=s?w.innerWidth:w.innerHeight}else g=s?x.scrollLeft:x.scrollTop,p=s?x.scrollWidth:x.scrollHeight,b=s?x.offsetWidth:x.offsetHeight;const y=()=>{e({scrollHeight:p,scrollTop:Math.max(g,0),viewportHeight:b})};m.suppressFlushSync?y():$o.flushSync(y),a.current!==null&&(g===a.current||g<=0||g===p-b)&&(a.current=null,t(!0),l.current&&(clearTimeout(l.current),l.current=null))},[e,t,s]);v.useEffect(()=>{const m=o||i.current;return r(o||i.current),u({suppressFlushSync:!0,target:m}),m.addEventListener("scroll",u,{passive:!0}),()=>{r(null),m.removeEventListener("scroll",u)}},[i,u,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 b=m.behavior==="smooth";let g,x,y;Ga(p)?(x=Math.max(Wn(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=Wn(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)),Tp(g,x)||m.top===y){e({scrollHeight:x,scrollTop:y,viewportHeight:g}),b&&t(!0);return}b?(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 Ya="-webkit-sticky",Hp="sticky",Xa=Op(()=>{if(typeof document>"u")return Hp;const e=document.createElement("div");return e.style.position=Ya,e.style.position===Ya?Ya:Hp});function Ja(e){return e}const rT=qe(()=>{const e=se(a=>`Item ${a}`),t=se(a=>`Group ${a}`),n=se({}),r=se(Ja),o=se("div"),s=se(Mr),i=(a,l=null)=>Pt(re(n,ue(u=>u[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")}}),oT=qe(([e,t])=>({...e,...t}),rt(Dp,rT)),sT=({height:e})=>c.jsx("div",{style:{height:e}}),iT={overflowAnchor:"none",position:Xa(),zIndex:1},Up={overflowAnchor:"none"},aT={...Up,display:"inline-block",height:"100%"},Wp=v.memo(function({showTopList:e=!1}){const t=Ae("listState"),n=nn("sizeRanges"),r=Ae("useWindowScroll"),o=Ae("customScrollParent"),s=nn("windowScrollContainerState"),i=nn("scrollContainerState"),a=o||r?s:i,l=Ae("itemContent"),u=Ae("context"),d=Ae("groupContent"),f=Ae("trackItemSizes"),m=Ae("itemSize"),p=Ae("log"),b=nn("gap"),g=Ae("horizontalDirection"),{callbackRef:x}=SC(n,m,f,e?Mr:a,p,b,o,g,Ae("skipAnimationFrameInResizeObserver")),[y,w]=v.useState(0);Za("deviation",A=>{y!==A&&w(A)});const S=Ae("EmptyPlaceholder"),k=Ae("ScrollSeekPlaceholder")||sT,C=Ae("ListComponent"),T=Ae("ItemComponent"),E=Ae("GroupComponent"),j=Ae("computeItemKey"),_=Ae("isSeeking"),D=Ae("groupIndices").length>0,F=Ae("alignToBottom"),W=Ae("initialItemFinalLocationReached"),G=e?{}:{boxSizing:"border-box",...g?{display:"inline-block",height:"100%",marginLeft:y!==0?y:F?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:y!==0?y:F?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...W?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&S?c.jsx(S,{...Rt(S,u)}):c.jsx(C,{...Rt(C,u),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:x,style:G,children:(e?t.topItems:t.items).map(A=>{const X=A.originalIndex,q=j(X+t.firstItemIndex,A.data,u);return _?v.createElement(k,{...Rt(k,u),height:A.size,index:A.index,key:q,type:A.type||"item",...A.type==="group"?{}:{groupIndex:A.groupIndex}}):A.type==="group"?v.createElement(E,{...Rt(E,u),"data-index":X,"data-item-index":A.index,"data-known-size":A.size,key:q,style:iT},d(A.index,u)):v.createElement(T,{...Rt(T,u),...dT(T,A.data),"data-index":X,"data-item-group-index":A.groupIndex,"data-item-index":A.index,"data-known-size":A.size,key:q,style:g?aT:Up},D?l(A.index,A.groupIndex,A.data,u):l(A.index,A.data,u))})})}),lT={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},cT={outline:"none",overflowX:"auto",position:"relative"},$s=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),uT={position:Xa(),top:0,width:"100%",zIndex:1};function Rt(e,t){if(typeof e!="string")return{context:t}}function dT(e,t){return{item:typeof e=="string"?void 0:t}}const fT=v.memo(function(){const e=Ae("HeaderComponent"),t=nn("headerHeight"),n=Ae("HeaderFooterTag"),r=sr(v.useMemo(()=>s=>{t(Wn(s,"height"))},[t]),!0,Ae("skipAnimationFrameInResizeObserver")),o=Ae("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...Rt(e,o)})}):null}),pT=v.memo(function(){const e=Ae("FooterComponent"),t=nn("footerHeight"),n=Ae("HeaderFooterTag"),r=sr(v.useMemo(()=>s=>{t(Wn(s,"height"))},[t]),!0,Ae("skipAnimationFrameInResizeObserver")),o=Ae("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...Rt(e,o)})}):null});function Vp({useEmitter:e,useEmitterValue:t,usePublisher:n}){return v.memo(function({children:r,style:o,context:s,...i}){const a=n("scrollContainerState"),l=t("ScrollerComponent"),u=n("smoothScrollTargetReached"),d=t("scrollerRef"),f=t("horizontalDirection")||!1,{scrollByCallback:m,scrollerRef:p,scrollToCallback:b}=zp(a,u,l,d,void 0,f);return e("scrollTo",b),e("scrollBy",m),c.jsx(l,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:p,style:{...f?cT:lT,...o},tabIndex:0,...i,...Rt(l,s),children:r})})}function Kp({useEmitter:e,useEmitterValue:t,usePublisher:n}){return v.memo(function({children:r,style:o,context:s,...i}){const a=n("windowScrollContainerState"),l=t("ScrollerComponent"),u=n("smoothScrollTargetReached"),d=t("totalListHeight"),f=t("deviation"),m=t("customScrollParent"),p=v.useRef(null),b=t("scrollerRef"),{scrollByCallback:g,scrollerRef:x,scrollToCallback:y}=zp(a,u,l,b,m);return Bp(()=>{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),c.jsx(l,{ref:p,"data-virtuoso-scroller":!0,style:{position:"relative",...o,...d!==0?{height:d+f}:{}},...i,...Rt(l,s),children:r})})}const hT=({children:e})=>{const t=v.useContext($p),n=nn("viewportHeight"),r=nn("fixedItemHeight"),o=Ae("alignToBottom"),s=Ae("horizontalDirection"),i=v.useMemo(()=>sp(n,l=>Wn(l,s?"width":"height")),[n,s]),a=sr(i,!0,Ae("skipAnimationFrameInResizeObserver"));return v.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),c.jsx("div",{"data-viewport-type":"element",ref:a,style:$s(o),children:e})},mT=({children:e})=>{const t=v.useContext($p),n=nn("windowViewportRect"),r=nn("fixedItemHeight"),o=Ae("customScrollParent"),s=up(n,o,Ae("skipAnimationFrameInResizeObserver")),i=Ae("alignToBottom");return v.useEffect(()=>{t&&(r(t.itemHeight),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),c.jsx("div",{"data-viewport-type":"window",ref:s,style:$s(i),children:e})},gT=({children:e})=>{const t=Ae("TopItemListComponent")||"div",n=Ae("headerHeight"),r={...uT,marginTop:`${n}px`},o=Ae("context");return c.jsx(t,{style:r,...Rt(t,o),children:e})},xT=v.memo(function(e){const t=Ae("useWindowScroll"),n=Ae("topItemsIndexes").length>0,r=Ae("customScrollParent"),o=Ae("context");return c.jsxs(r||t?wT:bT,{...e,context:o,children:[n&&c.jsx(gT,{children:c.jsx(Wp,{showTopList:!0})}),c.jsxs(r||t?mT:hT,{children:[c.jsx(fT,{}),c.jsx(Wp,{}),c.jsx(pT,{})]})]})}),{Component:vT,useEmitter:Za,useEmitterValue:Ae,usePublisher:nn}=Lp(oT,{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"}},xT),bT=Vp({useEmitter:Za,useEmitterValue:Ae,usePublisher:nn}),wT=Kp({useEmitter:Za,useEmitterValue:Ae,usePublisher:nn}),yT=vT;rt(Dp,qe(()=>{const e=se(u=>c.jsxs("td",{children:["Item $",u]})),t=se(null),n=se(u=>c.jsxs("td",{colSpan:1e3,children:["Group ",u]})),r=se(null),o=se(null),s=se({}),i=se(Ja),a=se(Mr),l=(u,d=null)=>Pt(re(s,ue(f=>f[u]),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")}})),Xa();const qp={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},ST={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:Gp,floor:Fs,max:Io,min:Qa,round:Yp}=Math;function Xp(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function CT(e){return{...ST,items:e}}function Bs(e,t){return e&&e.width===t.width&&e.height===t.height}function TT(e,t){return e&&e.column===t.column&&e.row===t.row}const kT=qe(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:r},{footerHeight:o,headerHeight:s,scrollBy:i,scrollContainerState:a,scrollTo:l,scrollTop:u,smoothScrollTargetReached:d,viewportHeight:f},m,p,{didMount:b,propsReady:g},{customScrollParent:x,useWindowScroll:y,windowScrollContainerState:w,windowScrollTo:S,windowViewportRect:k},C])=>{const T=se(0),E=se(0),j=se(qp),_=se({height:0,width:0}),D=se({height:0,width:0}),F=ze(),W=ze(),G=se(0),A=se(null),X=se({column:0,row:0}),q=ze(),B=ze(),R=se(!1),I=se(0),H=se(!0),Y=se(!1),P=se(!1);Ye(re(b,De(I),Ee(([$,ee])=>!!ee)),()=>{Pe(H,!1)}),Ye(re(xt(b,H,D,_,I,Y),Ee(([$,ee,J,K,,Q])=>$&&!ee&&J.height!==0&&K.height!==0&&!Q)),([,,,,$])=>{Pe(Y,!0),Ua(1,()=>{Pe(F,$)}),fn(re(u),()=>{Pe(t,[0,0]),Pe(H,!0)})}),xe(re(B,Ee($=>$!=null&&$.scrollTop>0),kn(0)),E),Ye(re(b,De(B),Ee(([,$])=>$!=null)),([,$])=>{$&&(Pe(_,$.viewport),Pe(D,$.item),Pe(X,$.gap),$.scrollTop>0&&(Pe(R,!0),fn(re(u,or(1)),ee=>{Pe(R,!1)}),Pe(l,{top:$.scrollTop})))}),xe(re(_,ue(({height:$})=>$)),f),xe(re(xt(Ce(_,Bs),Ce(D,Bs),Ce(X,($,ee)=>$&&$.column===ee.column&&$.row===ee.row),Ce(u)),ue(([$,ee,J,K])=>({gap:J,item:ee,scrollTop:K,viewport:$}))),q),xe(re(xt(Ce(T),r,Ce(X,TT),Ce(D,Bs),Ce(_,Bs),Ce(A),Ce(E),Ce(R),Ce(H),Ce(I)),Ee(([,,,,,,,$])=>!$),ue(([$,[ee,J],K,Q,me,de,ge,,we,Te])=>{const{column:Ne,row:ke}=K,{height:st,width:vt}=Q,{width:ht}=me;if(ge===0&&($===0||ht===0))return qp;if(vt===0){const St=Wa(Te,$),Ct=St+Math.max(ge-1,0);return CT(Xp(St,Ct,de))}const We=Jp(ht,vt,Ne);let Le,Ge;we?ee===0&&J===0&&ge>0?(Le=0,Ge=ge-1):(Le=We*Fs((ee+ke)/(st+ke)),Ge=We*Gp((J+ke)/(st+ke))-1,Ge=Qa($-1,Io(Ge,We-1)),Le=Qa(Ge,Io(0,Le))):(Le=0,Ge=-1);const Me=Xp(Le,Ge,de),{bottom:$e,top:Ze}=Zp(me,K,Q,Me),Nt=Gp($/We),it=Nt*st+(Nt-1)*ke-$e;return{bottom:$e,itemHeight:st,items:Me,itemWidth:vt,offsetBottom:it,offsetTop:Ze,top:Ze}})),j),xe(re(A,Ee($=>$!==null),ue($=>$.length)),T),xe(re(xt(_,D,j,X),Ee(([$,ee,{items:J}])=>J.length>0&&ee.height!==0&&$.height!==0),ue(([$,ee,{items:J},K])=>{const{bottom:Q,top:me}=Zp($,K,ee,J);return[me,Q]}),ot(wo)),t);const O=se(!1);xe(re(u,De(O),ue(([$,ee])=>ee||$!==0)),O);const M=Qt(re(xt(j,T),Ee(([{items:$}])=>$.length>0),De(O),Ee(([[$,ee],J])=>{const K=$.items[$.items.length-1].index===ee-1;return(J||$.bottom>0&&$.itemHeight>0&&$.offsetBottom===0&&$.items.length===ee)&&K}),ue(([[,$]])=>$-1),ot())),L=Qt(re(Ce(j),Ee(({items:$})=>$.length>0&&$[0].index===0),kn(0),ot())),te=Qt(re(Ce(j),De(R),Ee(([{items:$},ee])=>$.length>0&&!ee),ue(([{items:$}])=>({endIndex:$[$.length-1].index,startIndex:$[0].index})),ot(xp),Rn(0)));xe(te,p.scrollSeekRangeChanged),xe(re(F,De(_,D,T,X),ue(([$,ee,J,K,Q])=>{const me=Cp($),{align:de,behavior:ge,offset:we}=me;let Te=me.index;Te==="LAST"&&(Te=K-1),Te=Io(0,Te,Qa(K-1,Te));let Ne=el(ee,Q,J,Te);return de==="end"?Ne=Yp(Ne-ee.height+J.height):de==="center"&&(Ne=Yp(Ne-ee.height/2+J.height/2)),we&&(Ne+=we),{behavior:ge,top:Ne}})),l);const z=Pt(re(j,ue($=>$.offsetBottom+$.bottom)),0);return xe(re(k,ue($=>({height:$.visibleHeight,width:$.visibleWidth}))),_),{customScrollParent:x,data:A,deviation:G,footerHeight:o,gap:X,headerHeight:s,increaseViewportBy:e,initialItemCount:E,itemDimensions:D,overscan:n,restoreStateFrom:B,scrollBy:i,scrollContainerState:a,scrollHeight:W,scrollTo:l,scrollToIndex:F,scrollTop:u,smoothScrollTargetReached:d,totalCount:T,useWindowScroll:y,viewportDimensions:_,windowScrollContainerState:w,windowScrollTo:S,windowViewportRect:k,...p,gridState:j,horizontalDirection:P,initialTopMostItemIndex:I,totalListHeight:z,...m,endReached:M,propsReady:g,rangeChanged:te,startReached:L,stateChanged:q,stateRestoreInProgress:R,...C}},rt(Va,$t,Eo,Mp,Vn,qa,Un));function Jp(e,t,n){return Io(1,Fs((e+n)/(Fs(t)+n)))}function Zp(e,t,n,r){const{height:o}=n;if(o===void 0||r.length===0)return{bottom:0,top:0};const s=el(e,t,n,r[0].index);return{bottom:el(e,t,n,r[r.length-1].index)+o,top:s}}function el(e,t,n,r){const o=Jp(e.width,n.width,t.column),s=Fs(r/o),i=s*n.height+Io(0,s-1)*t.row;return i>0?i+t.row:i}const ET=qe(()=>{const e=se(f=>`Item ${f}`),t=se({}),n=se(null),r=se("virtuoso-grid-item"),o=se("virtuoso-grid-list"),s=se(Ja),i=se("div"),a=se(Mr),l=(f,m=null)=>Pt(re(t,ue(p=>p[f]),ot()),m),u=se(!1),d=se(!1);return xe(Ce(d),u),{components:t,computeItemKey:s,context:n,FooterComponent:l("Footer"),HeaderComponent:l("Header"),headerFooterTag:i,itemClassName:r,ItemComponent:l("Item","div"),itemContent:e,listClassName:o,ListComponent:l("List","div"),readyStateChanged:u,reportReadyState:d,ScrollerComponent:l("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder","div")}}),IT=qe(([e,t])=>({...e,...t}),rt(kT,ET)),NT=v.memo(function(){const e=at("gridState"),t=at("listClassName"),n=at("itemClassName"),r=at("itemContent"),o=at("computeItemKey"),s=at("isSeeking"),i=rn("scrollHeight"),a=at("ItemComponent"),l=at("ListComponent"),u=at("ScrollSeekPlaceholder"),d=at("context"),f=rn("itemDimensions"),m=rn("gap"),p=at("log"),b=at("stateRestoreInProgress"),g=rn("reportReadyState"),x=sr(v.useMemo(()=>y=>{const w=y.parentElement.parentElement.scrollHeight;i(w);const S=y.firstChild;if(S){const{height:k,width:C}=S.getBoundingClientRect();f({height:k,width:C})}m({column:eh("column-gap",getComputedStyle(y).columnGap,p),row:eh("row-gap",getComputedStyle(y).rowGap,p)})},[i,f,m,p]),!0,!1);return Bp(()=>{e.itemHeight>0&&e.itemWidth>0&&g(!0)},[e]),b?null:c.jsx(l,{className:t,ref:x,...Rt(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?c.jsx(u,{...Rt(u,d),height:e.itemHeight,index:y.index,width:e.itemWidth},w):v.createElement(a,{...Rt(a,d),className:n,"data-index":y.index,key:w},r(y.index,y.data,d))})})}),AT=v.memo(function(){const e=at("HeaderComponent"),t=rn("headerHeight"),n=at("headerFooterTag"),r=sr(v.useMemo(()=>s=>{t(Wn(s,"height"))},[t]),!0,!1),o=at("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...Rt(e,o)})}):null}),jT=v.memo(function(){const e=at("FooterComponent"),t=rn("footerHeight"),n=at("headerFooterTag"),r=sr(v.useMemo(()=>s=>{t(Wn(s,"height"))},[t]),!0,!1),o=at("context");return e?c.jsx(n,{ref:r,children:c.jsx(e,{...Rt(e,o)})}):null}),_T=({children:e})=>{const t=v.useContext(Fp),n=rn("itemDimensions"),r=rn("viewportDimensions"),o=sr(v.useMemo(()=>s=>{r(s.getBoundingClientRect())},[r]),!0,!1);return v.useEffect(()=>{t&&(r({height:t.viewportHeight,width:t.viewportWidth}),n({height:t.itemHeight,width:t.itemWidth}))},[t,r,n]),c.jsx("div",{ref:o,style:$s(!1),children:e})},PT=({children:e})=>{const t=v.useContext(Fp),n=rn("windowViewportRect"),r=rn("itemDimensions"),o=at("customScrollParent"),s=up(n,o,!1);return v.useEffect(()=>{t&&(r({height:t.itemHeight,width:t.itemWidth}),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:t.viewportWidth}))},[t,n,r]),c.jsx("div",{ref:s,style:$s(!1),children:e})},RT=v.memo(function({...e}){const t=at("useWindowScroll"),n=at("customScrollParent"),r=n||t?OT:MT,o=n||t?PT:_T,s=at("context");return c.jsx(r,{...e,...Rt(r,s),children:c.jsxs(o,{children:[c.jsx(AT,{}),c.jsx(NT,{}),c.jsx(jT,{})]})})}),{useEmitter:Qp,useEmitterValue:at,usePublisher:rn}=Lp(IT,{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"}},RT),MT=Vp({useEmitter:Qp,useEmitterValue:at,usePublisher:rn}),OT=Kp({useEmitter:Qp,useEmitterValue:at,usePublisher:rn});function eh(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Ht.WARN),t==="normal"?0:parseInt(t??"0",10)}var zs="Dialog",[th,L1]=Xt(zs),[DT,hn]=th(zs),nh=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:i=!0}=e,a=h.useRef(null),l=h.useRef(null),[u,d]=cn({prop:r,defaultProp:o??!1,onChange:s,caller:zs});return c.jsx(DT,{scope:t,triggerRef:a,contentRef:l,contentId:kt(),titleId:kt(),descriptionId:kt(),open:u,onOpenChange:d,onOpenToggle:h.useCallback(()=>d(f=>!f),[d]),modal:i,children:n})};nh.displayName=zs;var rh="DialogTrigger",oh=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=hn(rh,n),s=_e(t,o.triggerRef);return c.jsx(he.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":rl(o.open),...r,ref:s,onClick:ie(e.onClick,o.onOpenToggle)})});oh.displayName=rh;var tl="DialogPortal",[LT,sh]=th(tl,{forceMount:void 0}),ih=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=hn(tl,t);return c.jsx(LT,{scope:t,forceMount:n,children:h.Children.map(r,i=>c.jsx(Dt,{present:n||s.open,children:c.jsx(co,{asChild:!0,container:o,children:i})}))})};ih.displayName=tl;var Hs="DialogOverlay",ah=h.forwardRef((e,t)=>{const n=sh(Hs,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=hn(Hs,e.__scopeDialog);return s.modal?c.jsx(Dt,{present:r||s.open,children:c.jsx(FT,{...o,ref:t})}):null});ah.displayName=Hs;var $T=qt.createSlot("DialogOverlay.RemoveScroll"),FT=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=hn(Hs,n);return c.jsx(ws,{as:$T,allowPinchZoom:!0,shards:[o.contentRef],children:c.jsx(he.div,{"data-state":rl(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),lr="DialogContent",lh=h.forwardRef((e,t)=>{const n=sh(lr,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=hn(lr,e.__scopeDialog);return c.jsx(Dt,{present:r||s.open,children:s.modal?c.jsx(BT,{...o,ref:t}):c.jsx(zT,{...o,ref:t})})});lh.displayName=lr;var BT=h.forwardRef((e,t)=>{const n=hn(lr,e.__scopeDialog),r=h.useRef(null),o=_e(t,n.contentRef,r);return h.useEffect(()=>{const s=r.current;if(s)return va(s)},[]),c.jsx(ch,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ie(e.onCloseAutoFocus,s=>{var i;s.preventDefault(),(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:ie(e.onPointerDownOutside,s=>{const i=s.detail.originalEvent,a=i.button===0&&i.ctrlKey===!0;(i.button===2||a)&&s.preventDefault()}),onFocusOutside:ie(e.onFocusOutside,s=>s.preventDefault())})}),zT=h.forwardRef((e,t)=>{const n=hn(lr,e.__scopeDialog),r=h.useRef(!1),o=h.useRef(!1);return c.jsx(ch,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var i,a;(i=e.onCloseAutoFocus)==null||i.call(e,s),s.defaultPrevented||(r.current||(a=n.triggerRef.current)==null||a.focus(),s.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:s=>{var l,u;(l=e.onInteractOutside)==null||l.call(e,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const i=s.target;((u=n.triggerRef.current)==null?void 0:u.contains(i))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&o.current&&s.preventDefault()}})}),ch=h.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=hn(lr,n),l=h.useRef(null),u=_e(t,l);return Yi(),c.jsxs(c.Fragment,{children:[c.jsx(ts,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:c.jsx(Cr,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":rl(a.open),...i,ref:u,onDismiss:()=>a.onOpenChange(!1)})}),c.jsxs(c.Fragment,{children:[c.jsx(HT,{titleId:a.titleId}),c.jsx(WT,{contentRef:l,descriptionId:a.descriptionId})]})]})}),nl="DialogTitle",uh=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=hn(nl,n);return c.jsx(he.h2,{id:o.titleId,...r,ref:t})});uh.displayName=nl;var dh="DialogDescription",fh=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=hn(dh,n);return c.jsx(he.p,{id:o.descriptionId,...r,ref:t})});fh.displayName=dh;var ph="DialogClose",hh=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=hn(ph,n);return c.jsx(he.button,{type:"button",...r,ref:t,onClick:ie(e.onClick,()=>o.onOpenChange(!1))})});hh.displayName=ph;function rl(e){return e?"open":"closed"}var mh="DialogTitleWarning",[$1,gh]=ow(mh,{contentName:lr,titleName:nl,docsSlug:"dialog"}),HT=({titleId:e})=>{const t=gh(mh),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 p.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},cT="DialogDescriptionWarning",uT=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${op(cT).contentName}}.`;return p.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},Za=Wh,dT=Kh,Qa=Gh,To=Yh,ko=Xh,lr=Zh,Bs=ep,sp=np;const el=Za,fT=Qa,ip=p.forwardRef(({className:e,...t},n)=>u.jsx(To,{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}));ip.displayName=To.displayName;const zs=p.forwardRef(({className:e,children:t,...n},r)=>{const o=p.useMemo(()=>{let s=!1;function i(a){p.Children.forEach(a,l=>{if(s||!p.isValidElement(l))return;const c=l.type;if(c===lr||(c==null?void 0:c.displayName)===lr.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(fT,{children:[u.jsx(ip,{}),u.jsxs(ko,{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(lr,{className:"sr-only",children:"Dialog"}),t,u.jsxs(sp,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[u.jsx(ae.X,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]})});zs.displayName=ko.displayName;const Hs=({className:e,...t})=>u.jsx("div",{className:oe("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});Hs.displayName="DialogHeader";const Us=p.forwardRef(({className:e,...t},n)=>u.jsx(lr,{ref:n,className:oe("text-lg font-semibold leading-none tracking-tight",e),...t}));Us.displayName=lr.displayName;const hT=p.forwardRef(({className:e,...t},n)=>u.jsx(Bs,{ref:n,className:oe("text-sm text-muted-foreground",e),...t}));hT.displayName=Bs.displayName;const pT=1,mT=1e6;let tl=0;function gT(){return tl=(tl+1)%Number.MAX_SAFE_INTEGER,tl.toString()}const nl=new Map,ap=e=>{if(nl.has(e))return;const t=setTimeout(()=>{nl.delete(e),Eo({type:"REMOVE_TOAST",toastId:e})},mT);nl.set(e,t)},xT=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,pT)};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?ap(n):e.toasts.forEach(r=>{ap(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)}}},Ws=[];let Vs={toasts:[]};function Eo(e){Vs=xT(Vs,e),Ws.forEach(t=>{t(Vs)})}function vT({...e}){const t=gT(),n=o=>Eo({type:"UPDATE_TOAST",toast:{...o,id:t}}),r=()=>Eo({type:"DISMISS_TOAST",toastId:t});return Eo({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:o=>{o||r()}}}),{id:t,dismiss:r,update:n}}function rl(){const[e,t]=p.useState(Vs);return p.useEffect(()=>(Ws.push(t),()=>{const n=Ws.indexOf(t);n>-1&&Ws.splice(n,1)}),[e]),{...e,toast:vT,dismiss:n=>Eo({type:"DISMISS_TOAST",toastId:n})}}function lp({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:h}=rl(),m=b.useCallback(async()=>{if(n){i(!0),d(null),l(null);try{const y=await _i(n);l(y)}catch(y){console.error("Failed to load file:",y),d(y instanceof Error?y.message:"Failed to load file")}finally{i(!1)}}},[n]);b.useEffect(()=>{e&&n&&m()},[e,n,m]);const f=async()=>{if(n)try{await Qc(n),h({title:"Download started",description:`Downloading ${r}`})}catch(y){console.error("Failed to download file:",y),h({title:"Download failed",description:String(y),variant:"destructive"})}},v=async()=>{if(n)try{const y=await _i(n),w=new Blob([y],{type:o}),S=URL.createObjectURL(w);window.open(S,"_blank"),URL.revokeObjectURL(S)}catch(y){console.error("Failed to open file externally:",y),h({title:"Failed to open file",description:String(y),variant:"destructive"})}},g=()=>s?u.jsxs("div",{className:"flex items-center justify-center py-12",children:[u.jsx(ae.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(Je,{onClick:m,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(ae.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"})}),x=()=>o.startsWith("image/")?u.jsx(ae.Image,{className:"h-5 w-5"}):u.jsx(ae.FileText,{className:"h-5 w-5"});return u.jsx(el,{open:e,onOpenChange:t,children:u.jsxs(zs,{className:"max-w-4xl max-h-[90vh] overflow-hidden",children:[u.jsx(Hs,{children:u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[x(),u.jsxs("div",{children:[u.jsx(Us,{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(Je,{variant:"outline",size:"sm",onClick:v,className:"flex items-center gap-2",children:[u.jsx(ae.ExternalLink,{className:"h-4 w-4"}),"External"]}),u.jsxs(Je,{variant:"outline",size:"sm",onClick:f,className:"flex items-center gap-2",children:[u.jsx(ae.Download,{className:"h-4 w-4"}),"Download"]})]})]})}),u.jsx("div",{className:"flex-1 overflow-hidden",children:g()})]})})}function cp(){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 cr=cp();function bT(e){cr=e}const up=/[&<>"']/,wT=new RegExp(up.source,"g"),dp=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,yT=new RegExp(dp.source,"g"),ST={"&":"&","<":"<",">":">",'"':""","'":"'"},fp=e=>ST[e];function Mt(e,t){if(t){if(up.test(e))return e.replace(wT,fp)}else if(dp.test(e))return e.replace(yT,fp);return e}const CT=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function hp(e){return e.replace(CT,(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 TT=/(^|[^\[])\^/g;function tt(e,t){e=typeof e=="string"?e:e.source,t=t||"";const n={replace:(r,o)=>(o=o.source||o,o=o.replace(TT,"$1"),e=e.replace(r,o),n),getRegex:()=>new RegExp(e,t)};return n}const kT=/[^\w:]/g,ET=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function pp(e,t,n){if(e){let r;try{r=decodeURIComponent(hp(n)).replace(kT,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}t&&!ET.test(n)&&(n=jT(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const Ks={},IT=/^[^:]+:\/*[^/]*$/,NT=/^([^:]+:)[\s\S]*$/,AT=/^([^:]+:\/*[^/]*)[\s\S]*$/;function jT(e,t){Ks[" "+e]||(IT.test(e)?Ks[" "+e]=e+"/":Ks[" "+e]=Gs(e,"/",!0)),e=Ks[" "+e];const n=e.indexOf(":")===-1;return t.substring(0,2)==="//"?n?t:e.replace(NT,"$1")+t:t.charAt(0)==="/"?n?t:e.replace(AT,"$1")+t:e+t}const qs={exec:function(){}};function mp(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 PT(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 _T(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 gp(e,t){if(t<1)return"";let n="";for(;t>1;)t&1&&(n+=e),t>>=1,e+=e;return n+e}function xp(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 RT(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},UT="DialogDescriptionWarning",WT=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${gh(UT).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},ol=nh,VT=oh,sl=ih,No=ah,Ao=lh,cr=uh,Us=fh,xh=hh;const il=ol,KT=sl,vh=h.forwardRef(({className:e,...t},n)=>c.jsx(No,{ref:n,className:ne("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));vh.displayName=No.displayName;const Ws=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 u=l.type;if(u===cr||(u==null?void 0:u.displayName)===cr.displayName||(u==null?void 0:u.name)==="DialogTitle"){s=!0;return}l.props&&l.props.children&&i(l.props.children)})}return i(t),s},[t]);return c.jsxs(KT,{children:[c.jsx(vh,{}),c.jsxs(Ao,{ref:r,className:ne("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...n,children:[!o&&c.jsx(cr,{className:"sr-only",children:"Dialog"}),t,c.jsxs(xh,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[c.jsx(ae.X,{className:"h-4 w-4"}),c.jsx("span",{className:"sr-only",children:"Close"})]})]})]})});Ws.displayName=Ao.displayName;const Vs=({className:e,...t})=>c.jsx("div",{className:ne("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});Vs.displayName="DialogHeader";const Ks=h.forwardRef(({className:e,...t},n)=>c.jsx(cr,{ref:n,className:ne("text-lg font-semibold leading-none tracking-tight",e),...t}));Ks.displayName=cr.displayName;const qT=h.forwardRef(({className:e,...t},n)=>c.jsx(Us,{ref:n,className:ne("text-sm text-muted-foreground",e),...t}));qT.displayName=Us.displayName;const GT=1,YT=1e6;let al=0;function XT(){return al=(al+1)%Number.MAX_SAFE_INTEGER,al.toString()}const ll=new Map,bh=e=>{if(ll.has(e))return;const t=setTimeout(()=>{ll.delete(e),jo({type:"REMOVE_TOAST",toastId:e})},YT);ll.set(e,t)},JT=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,GT)};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?bh(n):e.toasts.forEach(r=>{bh(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)}}},qs=[];let Gs={toasts:[]};function jo(e){Gs=JT(Gs,e),qs.forEach(t=>{t(Gs)})}function ZT({...e}){const t=XT(),n=o=>jo({type:"UPDATE_TOAST",toast:{...o,id:t}}),r=()=>jo({type:"DISMISS_TOAST",toastId:t});return jo({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:o=>{o||r()}}}),{id:t,dismiss:r,update:n}}function cl(){const[e,t]=h.useState(Gs);return h.useEffect(()=>(qs.push(t),()=>{const n=qs.indexOf(t);n>-1&&qs.splice(n,1)}),[e]),{...e,toast:ZT,dismiss:n=>jo({type:"DISMISS_TOAST",toastId:n})}}function wh({isOpen:e,onClose:t,fileId:n,fileName:r,mimeType:o}){const[s,i]=v.useState(!1),[a,l]=v.useState(null),[u,d]=v.useState(null),{toast:f}=cl(),m=v.useCallback(async()=>{if(n){i(!0),d(null),l(null);try{const y=await Fi(n);l(y)}catch(y){console.error("Failed to load file:",y),d(y instanceof Error?y.message:"Failed to load file")}finally{i(!1)}}},[n]);v.useEffect(()=>{e&&n&&m()},[e,n,m]);const p=async()=>{if(n)try{await du(n),f({title:"Download started",description:`Downloading ${r}`})}catch(y){console.error("Failed to download file:",y),f({title:"Download failed",description:String(y),variant:"destructive"})}},b=async()=>{if(n)try{const y=await Fi(n),w=new Blob([y],{type:o}),S=URL.createObjectURL(w);window.open(S,"_blank"),URL.revokeObjectURL(S)}catch(y){console.error("Failed to open file externally:",y),f({title:"Failed to open file",description:String(y),variant:"destructive"})}},g=()=>s?c.jsxs("div",{className:"flex items-center justify-center py-12",children:[c.jsx(ae.Loader,{className:"h-8 w-8 animate-spin mr-3"}),c.jsx("span",{children:"Loading file..."})]}):u?c.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[c.jsx("div",{className:"text-red-500 mb-4",children:"⚠️"}),c.jsx("p",{className:"text-red-600 mb-4",children:u}),c.jsx(Je,{onClick:m,variant:"outline",children:"Try Again"})]}):a?o.startsWith("image/")?c.jsx("div",{className:"flex justify-center",children:c.jsx("img",{src:`data:${o};base64,${a}`,alt:r,className:"max-w-full max-h-[70vh] object-contain rounded-lg"})}):o==="application/pdf"?c.jsx("div",{className:"w-full h-[70vh] border rounded-lg overflow-hidden",children:c.jsx("iframe",{src:`data:application/pdf;base64,${a}`,className:"w-full h-full",title:r})}):o.startsWith("text/")||o.includes("json")||o.includes("xml")?c.jsx("div",{className:"bg-gray-50 dark:bg-gray-900 rounded-lg p-4 max-h-[70vh] overflow-auto",children:c.jsx("pre",{className:"whitespace-pre-wrap font-mono text-sm",children:a})}):c.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[c.jsx(ae.FileText,{className:"h-16 w-16 text-gray-400 mb-4"}),c.jsx("p",{className:"text-lg font-medium mb-2",children:r}),c.jsxs("p",{className:"text-sm text-muted-foreground mb-4",children:[o," • ",a.length," bytes"]}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"This file type cannot be previewed. Use download or external view."})]}):c.jsx("div",{className:"flex items-center justify-center py-12",children:c.jsx("p",{className:"text-muted-foreground",children:"No content to display"})}),x=()=>o.startsWith("image/")?c.jsx(ae.Image,{className:"h-5 w-5"}):c.jsx(ae.FileText,{className:"h-5 w-5"});return c.jsx(il,{open:e,onOpenChange:t,children:c.jsxs(Ws,{className:"max-w-4xl max-h-[90vh] overflow-hidden",children:[c.jsx(Vs,{children:c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[x(),c.jsxs("div",{children:[c.jsx(Ks,{className:"text-left",children:r}),c.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:[o," • Click download or external view for full access"]})]})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs(Je,{variant:"outline",size:"sm",onClick:b,className:"flex items-center gap-2",children:[c.jsx(ae.ExternalLink,{className:"h-4 w-4"}),"External"]}),c.jsxs(Je,{variant:"outline",size:"sm",onClick:p,className:"flex items-center gap-2",children:[c.jsx(ae.Download,{className:"h-4 w-4"}),"Download"]})]})]})}),c.jsx("div",{className:"flex-1 overflow-hidden",children:g()})]})})}function yh(){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 ur=yh();function QT(e){ur=e}const Sh=/[&<>"']/,ek=new RegExp(Sh.source,"g"),Ch=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,tk=new RegExp(Ch.source,"g"),nk={"&":"&","<":"<",">":">",'"':""","'":"'"},Th=e=>nk[e];function Mt(e,t){if(t){if(Sh.test(e))return e.replace(ek,Th)}else if(Ch.test(e))return e.replace(tk,Th);return e}const rk=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function kh(e){return e.replace(rk,(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 ok=/(^|[^\[])\^/g;function tt(e,t){e=typeof e=="string"?e:e.source,t=t||"";const n={replace:(r,o)=>(o=o.source||o,o=o.replace(ok,"$1"),e=e.replace(r,o),n),getRegex:()=>new RegExp(e,t)};return n}const sk=/[^\w:]/g,ik=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function Eh(e,t,n){if(e){let r;try{r=decodeURIComponent(kh(n)).replace(sk,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}t&&!ik.test(n)&&(n=uk(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const Ys={},ak=/^[^:]+:\/*[^/]*$/,lk=/^([^:]+:)[\s\S]*$/,ck=/^([^:]+:\/*[^/]*)[\s\S]*$/;function uk(e,t){Ys[" "+e]||(ak.test(e)?Ys[" "+e]=e+"/":Ys[" "+e]=Js(e,"/",!0)),e=Ys[" "+e];const n=e.indexOf(":")===-1;return t.substring(0,2)==="//"?n?t:e.replace(lk,"$1")+t:t.charAt(0)==="/"?n?t:e.replace(ck,"$1")+t:e+t}const Xs={exec:function(){}};function Ih(e,t){const n=e.replace(/\|/g,(s,i,a)=>{let l=!1,u=i;for(;--u>=0&&a[u]==="\\";)l=!l;return l?"|":" |"}),r=n.split(/ \|/);let o=0;if(r[0].trim()||r.shift(),r.length>0&&!r[r.length-1].trim()&&r.pop(),r.length>t)r.splice(t);else for(;r.length<t;)r.push("");for(;o<r.length;o++)r[o]=r[o].trim().replace(/\\\|/g,"|");return r}function Js(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 dk(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 fk(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 Nh(e,t){if(t<1)return"";let n="";for(;t>1;)t&1&&(n+=e),t>>=1,e+=e;return n+e}function Ah(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 pk(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
|
-
`)}class
|
|
86
|
-
`)}}}fences(t){const n=this.rules.block.fences.exec(t);if(n){const r=n[0],o=
|
|
87
|
-
`,1)[0].replace(/^\t+/,k=>" ".repeat(3*k.length)),
|
|
88
|
-
`,1)[0],this.options.pedantic?(i=2,
|
|
89
|
-
`,t=t.substring(
|
|
90
|
-
`,1)[0],
|
|
91
|
-
`+
|
|
92
|
-
`+
|
|
93
|
-
`,t=t.substring(m.length+1),d=
|
|
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]=
|
|
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:Mt(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]):Mt(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=
|
|
96
|
-
]`).replace("lheading",Se.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()};const fe={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:
|
|
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,
|
|
85
|
+
`)}class ul{constructor(t){this.options=t||ur}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:Js(r,`
|
|
86
|
+
`)}}}fences(t){const n=this.rules.block.fences.exec(t);if(n){const r=n[0],o=pk(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=Js(r,"#");(this.options.pedantic||!o||/ $/.test(o))&&(r=o.trim())}return{type:"heading",raw:n[0],depth:n[1].length,text:r,tokens:this.lexer.inline(r)}}}hr(t){const n=this.rules.block.hr.exec(t);if(n)return{type:"hr",raw:n[0]}}blockquote(t){const n=this.rules.block.blockquote.exec(t);if(n){const r=n[0].replace(/^ *>[ \t]?/gm,""),o=this.lexer.state.top;this.lexer.state.top=!0;const s=this.lexer.blockTokens(r);return this.lexer.state.top=o,{type:"blockquote",raw:n[0],tokens:s,text:r}}}list(t){let n=this.rules.block.list.exec(t);if(n){let r,o,s,i,a,l,u,d,f,m,p,b,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&&(b=!1,!(!(n=w.exec(t))||this.rules.block.hr.test(t)));){if(r=n[0],t=t.substring(r.length),d=n[2].split(`
|
|
87
|
+
`,1)[0].replace(/^\t+/,k=>" ".repeat(3*k.length)),f=t.split(`
|
|
88
|
+
`,1)[0],this.options.pedantic?(i=2,p=d.trimLeft()):(i=n[2].search(/[^ ]/),i=i>4?1:i,p=d.slice(i),i+=n[1].length),l=!1,!d&&/^ *$/.test(f)&&(r+=f+`
|
|
89
|
+
`,t=t.substring(f.length+1),b=!0),!b){const k=new RegExp(`^ {0,${Math.min(3,i-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),C=new RegExp(`^ {0,${Math.min(3,i-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),T=new RegExp(`^ {0,${Math.min(3,i-1)}}(?:\`\`\`|~~~)`),E=new RegExp(`^ {0,${Math.min(3,i-1)}}#`);for(;t&&(m=t.split(`
|
|
90
|
+
`,1)[0],f=m,this.options.pedantic&&(f=f.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),!(T.test(f)||E.test(f)||k.test(f)||C.test(t)));){if(f.search(/[^ ]/)>=i||!f.trim())p+=`
|
|
91
|
+
`+f.slice(i);else{if(l||d.search(/[^ ]/)>=4||T.test(d)||E.test(d)||C.test(d))break;p+=`
|
|
92
|
+
`+f}!l&&!f.trim()&&(l=!0),r+=m+`
|
|
93
|
+
`,t=t.substring(m.length+1),d=f.slice(i)}}y.loose||(u?y.loose=!0:/\n *\n *$/.test(r)&&(u=!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 S=y.items.length;for(a=0;a<S;a++)if(this.lexer.state.top=!1,y.items[a].tokens=this.lexer.blockTokens(y.items[a].text,[]),!y.loose){const k=y.items[a].tokens.filter(T=>T.type==="space"),C=k.length>0&&k.some(T=>/\n.*\n/.test(T.raw));y.loose=C}if(y.loose)for(a=0;a<S;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]):Mt(n[0]);r.type="paragraph",r.text=o,r.tokens=this.lexer.inline(o)}return r}}def(t){const n=this.rules.block.def.exec(t);if(n){const r=n[1].toLowerCase().replace(/\s+/g," "),o=n[2]?n[2].replace(/^<(.*)>$/,"$1").replace(this.rules.inline._escapes,"$1"):"",s=n[3]?n[3].substring(1,n[3].length-1).replace(this.rules.inline._escapes,"$1"):n[3];return{type:"def",tag:r,raw:n[0],href:o,title:s}}}table(t){const n=this.rules.block.table.exec(t);if(n){const r={type:"table",header:Ih(n[1]).map(o=>({text:o})),align:n[2].replace(/^ *|\| *$/g,"").split(/ *\| */),rows:n[3]&&n[3].trim()?n[3].replace(/\n[ \t]*$/,"").split(`
|
|
94
|
+
`):[]};if(r.header.length===r.align.length){r.raw=n[0];let o=r.align.length,s,i,a,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]=Ih(r.rows[s],r.header.length).map(u=>({text:u}));for(o=r.header.length,i=0;i<o;i++)r.header[i].tokens=this.lexer.inline(r.header[i].text);for(o=r.rows.length,i=0;i<o;i++)for(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:Mt(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]):Mt(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=Js(r.slice(0,-1),"\\");if((r.length-i.length)%2===0)return}else{const i=dk(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)),Ah(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 Ah(r,o,r[0],this.lexer)}}emStrong(t,n,r=""){let o=this.rules.inline.emStrong.lDelim.exec(t);if(!o||o[3]&&r.match(/[\p{L}\p{N}]/u))return;const s=o[1]||o[2]||"";if(!s||s&&(r===""||this.rules.inline.punctuation.exec(r))){const i=o[0].length-1;let a,l,u=i,d=0;const f=o[0][0]==="*"?this.rules.inline.emStrong.rDelimAst:this.rules.inline.emStrong.rDelimUnd;for(f.lastIndex=0,n=n.slice(-1*t.length+i);(o=f.exec(n))!=null;){if(a=o[1]||o[2]||o[3]||o[4]||o[5]||o[6],!a)continue;if(l=a.length,o[3]||o[4]){u+=l;continue}else if((o[5]||o[6])&&i%3&&!((i+l)%3)){d+=l;continue}if(u-=l,u>0)continue;l=Math.min(l,l+u+d);const m=t.slice(0,i+o.index+(o[0].length-a.length)+l);if(Math.min(i,l)%2){const b=m.slice(1,-1);return{type:"em",raw:m,text:b,tokens:this.lexer.inlineTokens(b)}}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=Mt(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=Mt(this.options.mangle?n(r[1]):r[1]),s="mailto:"+o):(o=Mt(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=Mt(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=Mt(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]):Mt(r[0]):r[0]:o=Mt(this.options.smartypants?n(r[0]):r[0]),{type:"text",raw:r[0],text:o}}}}const Se={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:Xs,lheading:/^((?:.|\n(?!\n))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,text:/^[^\n]+/};Se._label=/(?!\s*\])(?:\\.|[^\[\]\\])+/,Se._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,Se.def=tt(Se.def).replace("label",Se._label).replace("title",Se._title).getRegex(),Se.bullet=/(?:[*+-]|\d{1,9}[.)])/,Se.listItemStart=tt(/^( *)(bull) */).replace("bull",Se.bullet).getRegex(),Se.list=tt(Se.list).replace(/bull/g,Se.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+Se.def.source+")").getRegex(),Se._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",Se._comment=/<!--(?!-?>)[\s\S]*?(?:-->|$)/,Se.html=tt(Se.html,"i").replace("comment",Se._comment).replace("tag",Se._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Se.paragraph=tt(Se._paragraph).replace("hr",Se.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",Se._tag).getRegex(),Se.blockquote=tt(Se.blockquote).replace("paragraph",Se.paragraph).getRegex(),Se.normal={...Se},Se.gfm={...Se.normal,table:"^ *([^\\n ].*\\|.*)\\n {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"},Se.gfm.table=tt(Se.gfm.table).replace("hr",Se.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",Se._tag).getRegex(),Se.gfm.paragraph=tt(Se._paragraph).replace("hr",Se.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("table",Se.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",Se._tag).getRegex(),Se.pedantic={...Se.normal,html:tt(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Se._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:Xs,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:tt(Se.normal._paragraph).replace("hr",Se.hr).replace("heading",` *#{1,6} *[^
|
|
96
|
+
]`).replace("lheading",Se.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()};const fe={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:Xs,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:Xs,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,punctuation:/^([\spunctuation])/};fe._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",fe.punctuation=tt(fe.punctuation).replace(/punctuation/g,fe._punctuation).getRegex(),fe.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g,fe.escapedEmSt=/(?:^|[^\\])(?:\\\\)*\\[*_]/g,fe._comment=tt(Se._comment).replace("(?:-->|$)","-->").getRegex(),fe.emStrong.lDelim=tt(fe.emStrong.lDelim).replace(/punct/g,fe._punctuation).getRegex(),fe.emStrong.rDelimAst=tt(fe.emStrong.rDelimAst,"g").replace(/punct/g,fe._punctuation).getRegex(),fe.emStrong.rDelimUnd=tt(fe.emStrong.rDelimUnd,"g").replace(/punct/g,fe._punctuation).getRegex(),fe._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,fe._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,fe._email=/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/,fe.autolink=tt(fe.autolink).replace("scheme",fe._scheme).replace("email",fe._email).getRegex(),fe._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,fe.tag=tt(fe.tag).replace("comment",fe._comment).replace("attribute",fe._attribute).getRegex(),fe._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,fe._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/,fe._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,fe.link=tt(fe.link).replace("label",fe._label).replace("href",fe._href).replace("title",fe._title).getRegex(),fe.reflink=tt(fe.reflink).replace("label",fe._label).replace("ref",Se._label).getRegex(),fe.nolink=tt(fe.nolink).replace("ref",Se._label).getRegex(),fe.reflinkSearch=tt(fe.reflinkSearch,"g").replace("reflink",fe.reflink).replace("nolink",fe.nolink).getRegex(),fe.normal={...fe},fe.pedantic={...fe.normal,strong:{start:/^__|\*\*/,middle:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,endAst:/\*\*(?!\*)/g,endUnd:/__(?!_)/g},em:{start:/^_|\*/,middle:/^()\*(?=\S)([\s\S]*?\S)\*(?!\*)|^_(?=\S)([\s\S]*?\S)_(?!_)/,endAst:/\*(?!\*)/g,endUnd:/_(?!_)/g},link:tt(/^!?\[(label)\]\((.*?)\)/).replace("label",fe._label).getRegex(),reflink:tt(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",fe._label).getRegex()},fe.gfm={...fe.normal,escape:tt(fe.escape).replace("])","~|])").getRegex(),_extended_email:/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,url:/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},fe.gfm.url=tt(fe.gfm.url,"i").replace("email",fe.gfm._extended_email).getRegex(),fe.breaks={...fe.gfm,br:tt(fe.br).replace("{2,}","*").getRegex(),text:tt(fe.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()};function hk(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 jh(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 Kn{constructor(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||ur,this.options.tokenizer=this.options.tokenizer||new ul,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:Se.normal,inline:fe.normal};this.options.pedantic?(n.block=Se.pedantic,n.inline=fe.pedantic):this.options.gfm&&(n.block=Se.gfm,this.options.breaks?n.inline=fe.breaks:n.inline=fe.gfm),this.tokenizer.rules=n}static get rules(){return{block:Se,inline:fe}}static lex(t,n){return new Kn(n).lex(t)}static lexInline(t,n){return new Kn(n).inlineTokens(t)}lex(t){t=t.replace(/\r\n|\r/g,`
|
|
97
|
+
`),this.blockTokens(t,this.tokens);let n;for(;n=this.inlineQueue.shift();)this.inlineTokens(n.src,n.tokens);return this.tokens}blockTokens(t,n=[]){this.options.pedantic?t=t.replace(/\t/g," ").replace(/^ +$/gm,""):t=t.replace(/^( *)(\t+)/gm,(a,l,u)=>l+" ".repeat(u.length));let r,o,s,i;for(;t;)if(!(this.options.extensions&&this.options.extensions.block&&this.options.extensions.block.some(a=>(r=a.call({lexer:this},t,n))?(t=t.substring(r.raw.length),n.push(r),!0):!1))){if(r=this.tokenizer.space(t)){t=t.substring(r.raw.length),r.raw.length===1&&n.length>0?n[n.length-1].raw+=`
|
|
98
98
|
`:n.push(r);continue}if(r=this.tokenizer.code(t)){t=t.substring(r.raw.length),o=n[n.length-1],o&&(o.type==="paragraph"||o.type==="text")?(o.raw+=`
|
|
99
99
|
`+r.raw,o.text+=`
|
|
100
100
|
`+r.text,this.inlineQueue[this.inlineQueue.length-1].src=o.text):n.push(r);continue}if(r=this.tokenizer.fences(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.heading(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.hr(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.blockquote(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.list(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.html(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.def(t)){t=t.substring(r.raw.length),o=n[n.length-1],o&&(o.type==="paragraph"||o.type==="text")?(o.raw+=`
|
|
101
101
|
`+r.raw,o.text+=`
|
|
102
|
-
`+r.raw,this.inlineQueue[this.inlineQueue.length-1].src=o.text):this.tokens.links[r.tag]||(this.tokens.links[r.tag]={href:r.href,title:r.title});continue}if(r=this.tokenizer.table(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.lheading(t)){t=t.substring(r.raw.length),n.push(r);continue}if(s=t,this.options.extensions&&this.options.extensions.startBlock){let a=1/0;const l=t.slice(1);let
|
|
102
|
+
`+r.raw,this.inlineQueue[this.inlineQueue.length-1].src=o.text):this.tokens.links[r.tag]||(this.tokens.links[r.tag]={href:r.href,title:r.title});continue}if(r=this.tokenizer.table(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.lheading(t)){t=t.substring(r.raw.length),n.push(r);continue}if(s=t,this.options.extensions&&this.options.extensions.startBlock){let a=1/0;const l=t.slice(1);let u;this.options.extensions.startBlock.forEach(function(d){u=d.call({lexer:this},l),typeof u=="number"&&u>=0&&(a=Math.min(a,u))}),a<1/0&&a>=0&&(s=t.substring(0,a+1))}if(this.state.top&&(r=this.tokenizer.paragraph(s))){o=n[n.length-1],i&&o.type==="paragraph"?(o.raw+=`
|
|
103
103
|
`+r.raw,o.text+=`
|
|
104
104
|
`+r.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=o.text):n.push(r),i=s.length!==t.length,t=t.substring(r.raw.length);continue}if(r=this.tokenizer.text(t)){t=t.substring(r.raw.length),o=n[n.length-1],o&&o.type==="text"?(o.raw+=`
|
|
105
105
|
`+r.raw,o.text+=`
|
|
106
|
-
`+r.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=o.text):n.push(r);continue}if(t){const a="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(a);break}else throw new Error(a)}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}inlineTokens(t,n=[]){let r,o,s,i=t,a,l,
|
|
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,u;if(this.tokens.links){const d=Object.keys(this.tokens.links);if(d.length>0)for(;(a=this.tokenizer.rules.inline.reflinkSearch.exec(i))!=null;)d.includes(a[0].slice(a[0].lastIndexOf("[")+1,-1))&&(i=i.slice(0,a.index)+"["+Nh("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)+"["+Nh("a",a[0].length-2)+"]"+i.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;(a=this.tokenizer.rules.inline.escapedEmSt.exec(i))!=null;)i=i.slice(0,a.index+a[0].length-2)+"++"+i.slice(this.tokenizer.rules.inline.escapedEmSt.lastIndex),this.tokenizer.rules.inline.escapedEmSt.lastIndex--;for(;t;)if(l||(u=""),l=!1,!(this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some(d=>(r=d.call({lexer:this},t,n))?(t=t.substring(r.raw.length),n.push(r),!0):!1))){if(r=this.tokenizer.escape(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.tag(t)){t=t.substring(r.raw.length),o=n[n.length-1],o&&r.type==="text"&&o.type==="text"?(o.raw+=r.raw,o.text+=r.text):n.push(r);continue}if(r=this.tokenizer.link(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(r.raw.length),o=n[n.length-1],o&&r.type==="text"&&o.type==="text"?(o.raw+=r.raw,o.text+=r.text):n.push(r);continue}if(r=this.tokenizer.emStrong(t,i,u)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.codespan(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.br(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.del(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.autolink(t,jh)){t=t.substring(r.raw.length),n.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(t,jh))){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,hk)){t=t.substring(r.raw.length),r.raw.slice(-1)!=="_"&&(u=r.raw.slice(-1)),l=!0,o=n[n.length-1],o&&o.type==="text"?(o.raw+=r.raw,o.text+=r.text):n.push(r);continue}if(t){const d="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(d);break}else throw new Error(d)}}return n}}class dl{constructor(t){this.options=t||ur}code(t,n,r){const o=(n||"").match(/\S*/)[0];if(this.options.highlight){const s=this.options.highlight(t,o);s!=null&&s!==t&&(r=!0,t=s)}return t=t.replace(/\n$/,"")+`
|
|
107
107
|
`,o?'<pre><code class="'+this.options.langPrefix+Mt(o)+'">'+(r?t:Mt(t,!0))+`</code></pre>
|
|
108
108
|
`:"<pre><code>"+(r?t:Mt(t,!0))+`</code></pre>
|
|
109
109
|
`}blockquote(t){return`<blockquote>
|
|
@@ -123,8 +123,9 @@ ${t}</blockquote>
|
|
|
123
123
|
`}tablerow(t){return`<tr>
|
|
124
124
|
${t}</tr>
|
|
125
125
|
`}tablecell(t,n){const r=n.header?"th":"td";return(n.align?`<${r} align="${n.align}">`:`<${r}>`)+t+`</${r}>
|
|
126
|
-
`}strong(t){return`<strong>${t}</strong>`}em(t){return`<em>${t}</em>`}codespan(t){return`<code>${t}</code>`}br(){return this.options.xhtml?"<br/>":"<br>"}del(t){return`<del>${t}</del>`}link(t,n,r){if(t=
|
|
127
|
-
`+(
|
|
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 yp(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...be.defaults,...s};const i=OT(r.silent,r.async,o);if(typeof n>"u"||n===null)return i(new Error("marked(): input parameter is undefined or null"));if(typeof n!="string")return i(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(n)+", string expected"));if(_T(r),r.hooks&&(r.hooks.options=r),o){const a=r.highlight;let l;try{r.hooks&&(n=r.hooks.preprocess(n)),l=e(n,r)}catch(h){return i(h)}const c=function(h){let m;if(!h)try{r.walkTokens&&be.walkTokens(l,r.walkTokens),m=t(l,r),r.hooks&&(m=r.hooks.postprocess(m))}catch(f){h=f}return r.highlight=a,h?i(h):o(null,m)};if(!a||a.length<3||(delete r.highlight,!l.length))return c();let d=0;be.walkTokens(l,function(h){h.type==="code"&&(d++,setTimeout(()=>{a(h.text,h.lang,function(m,f){if(m)return c(m);f!=null&&f!==h.text&&(h.text=f,h.escaped=!0),d--,d===0&&c()})},0))}),d===0&&c();return}if(r.async)return Promise.resolve(r.hooks?r.hooks.preprocess(n):n).then(a=>e(a,r)).then(a=>r.walkTokens?Promise.all(be.walkTokens(a,r.walkTokens)).then(()=>a):a).then(a=>t(a,r)).then(a=>r.hooks?r.hooks.postprocess(a):a).catch(i);try{r.hooks&&(n=r.hooks.preprocess(n));const a=e(n,r);r.walkTokens&&be.walkTokens(a,r.walkTokens);let l=t(a,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(a){return i(a)}}}function be(e,t,n){return yp(Vn.lex,Kn.parse)(e,t,n)}be.options=be.setOptions=function(e){return be.defaults={...be.defaults,...e},bT(be.defaults),be},be.getDefaults=cp,be.defaults=cr,be.use=function(...e){const t=be.defaults.extensions||{renderers:{},childTokens:{}};e.forEach(n=>{const r={...n};if(r.async=be.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(o=>{if(!o.name)throw new Error("extension name required");if(o.renderer){const s=t.renderers[o.name];s?t.renderers[o.name]=function(...i){let a=o.renderer.apply(this,i);return a===!1&&(a=s.apply(this,i)),a}:t.renderers[o.name]=o.renderer}if(o.tokenizer){if(!o.level||o.level!=="block"&&o.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");t[o.level]?t[o.level].unshift(o.tokenizer):t[o.level]=[o.tokenizer],o.start&&(o.level==="block"?t.startBlock?t.startBlock.push(o.start):t.startBlock=[o.start]:o.level==="inline"&&(t.startInline?t.startInline.push(o.start):t.startInline=[o.start]))}o.childTokens&&(t.childTokens[o.name]=o.childTokens)}),r.extensions=t),n.renderer){const o=be.defaults.renderer||new sl;for(const s in n.renderer){const i=o[s];o[s]=(...a)=>{let l=n.renderer[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.renderer=o}if(n.tokenizer){const o=be.defaults.tokenizer||new ol;for(const s in n.tokenizer){const i=o[s];o[s]=(...a)=>{let l=n.tokenizer[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.tokenizer=o}if(n.hooks){const o=be.defaults.hooks||new Ys;for(const s in n.hooks){const i=o[s];Ys.passThroughHooks.has(s)?o[s]=a=>{if(be.defaults.async)return Promise.resolve(n.hooks[s].call(o,a)).then(c=>i.call(o,c));const l=n.hooks[s].call(o,a);return i.call(o,l)}:o[s]=(...a)=>{let l=n.hooks[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.hooks=o}if(n.walkTokens){const o=be.defaults.walkTokens;r.walkTokens=function(s){let i=[];return i.push(n.walkTokens.call(this,s)),o&&(i=i.concat(o.call(this,s))),i}}be.setOptions(r)})},be.walkTokens=function(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(be,r)),r.type){case"table":{for(const o of r.header)n=n.concat(be.walkTokens(o.tokens,t));for(const o of r.rows)for(const s of o)n=n.concat(be.walkTokens(s.tokens,t));break}case"list":{n=n.concat(be.walkTokens(r.items,t));break}default:be.defaults.extensions&&be.defaults.extensions.childTokens&&be.defaults.extensions.childTokens[r.type]?be.defaults.extensions.childTokens[r.type].forEach(function(o){n=n.concat(be.walkTokens(r[o],t))}):r.tokens&&(n=n.concat(be.walkTokens(r.tokens,t)))}return n},be.parseInline=yp(Vn.lexInline,Kn.parseInline),be.Parser=Kn,be.parser=Kn.parse,be.Renderer=sl,be.TextRenderer=bp,be.Lexer=Vn,be.lexer=Vn.lex,be.Tokenizer=ol,be.Slugger=wp,be.Hooks=Ys,be.parse=be,be.options,be.setOptions,be.use,be.walkTokens,be.parseInline,Kn.parse,Vn.lex;function qn({content:e,className:t="",allowHtml:n=!1,style:r}){const o=b.useMemo(()=>{if(!e||typeof e!="string"||e.trim().length===0)return"";try{if(!n){const i=e.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"").replace(/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi,"").replace(/javascript:/gi,"").replace(/on\w+\s*=/gi,"");return typeof be.parse=="function"?be.parse(i):be(i)}return typeof be.parse=="function"?be.parse(e):be(e)}catch(i){return console.error("[MarkdownContent] parse error",i),`<pre class="font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words">Error rendering markdown: ${String(i)}</pre>`}},[e,n]),s=b.useMemo(()=>{const i={color:"currentColor",...r};if(r&&r.color){const a=r.color;return{...i,"--tw-prose-body":a,"--tw-prose-headings":a,"--tw-prose-links":a,"--tw-prose-bold":a,"--tw-prose-counters":a,"--tw-prose-bullets":a,"--tw-prose-hr":a,"--tw-prose-quotes":a,"--tw-prose-quote-borders":a,"--tw-prose-captions":a,"--tw-prose-code":a,"--tw-prose-pre-code":a,"--tw-prose-pre-bg":"inherit","--tw-prose-th-borders":a,"--tw-prose-td-borders":a}}return i},[r]);return u.jsx("div",{className:oe("markdown prose prose-sm max-w-none break-words","dark:prose-invert","text-current","prose-headings:text-current prose-p:text-current prose-li:text-current prose-a:text-current prose-strong:text-current","prose-em:text-current prose-blockquote:text-current prose-table:text-current prose-td:text-current prose-th:text-current","prose-pre:font-mono prose-pre:text-xs prose-pre:bg-background/50 prose-pre:border prose-pre:rounded prose-pre:p-3 prose-pre:whitespace-pre prose-pre:overflow-x-auto","prose-code:font-mono prose-code:text-sm prose-code:bg-background/50 prose-code:px-1.5 prose-code:py-0.5 prose-code:rounded prose-code:text-current",t),style:s,dangerouslySetInnerHTML:{__html:o}})}function Sp({preview:e,idx:t}){return u.jsxs("div",{className:"space-y-2",children:[e.label&&u.jsxs("p",{className:"text-[0.65rem] uppercase tracking-wide text-muted-foreground",children:["Artifact: ",e.label]}),u.jsx("div",{className:"overflow-hidden rounded border border-border/60 bg-background/60 p-1 shadow-sm",children:u.jsx("img",{src:e.src,alt:e.alt,title:e.label,loading:"lazy",className:"h-auto max-h-[420px] w-full rounded object-contain",onLoad:()=>{},onError:n=>{console.error(`[MessageComponent] ❌ Image failed to load for artifact ${t}:`,{alt:e.alt,label:e.label,message:n.target.alt})}})})]})}const Cp={completed:{label:"Completed",badgeClass:"border border-green-200 bg-green-50 text-green-700"},success:{label:"Completed",badgeClass:"border border-green-200 bg-green-50 text-green-700"},failed:{label:"Failed",badgeClass:"border border-red-200 bg-red-50 text-red-700"},error:{label:"Failed",badgeClass:"border border-red-200 bg-red-50 text-red-700"},cancelled:{label:"Cancelled",badgeClass:"border border-orange-200 bg-orange-50 text-orange-700"},cancel:{label:"Cancelled",badgeClass:"border border-orange-200 bg-orange-50 text-orange-700"},pending:{label:"Pending",badgeClass:"border border-blue-200 bg-blue-50 text-blue-700"},processing:{label:"Processing",badgeClass:"border border-yellow-200 bg-yellow-50 text-yellow-700"}},DT=e=>{if(!e)return Cp.processing;const t=e.toLowerCase().trim();return Cp[t]??{label:t.replace(/(^\w|\s\w)/g,n=>n.toUpperCase()),badgeClass:"border border-slate-200 bg-slate-50 text-slate-800"}},LT=e=>e?e.length>10?`${e.slice(0,8)}…`:e:"";function Tp({artifact:e}){const t=DT(e.status),n=e.task_url??e.taskUrl??"";return u.jsxs("div",{className:"rounded-lg border border-blue-200/70 bg-blue-50/40 p-4 space-y-3",children:[u.jsxs("div",{className:"flex items-start justify-between gap-3",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsx("div",{className:"flex h-7 w-7 items-center justify-center rounded-full bg-blue-600/10 text-blue-600",children:u.jsx(ae.Search,{className:"h-4 w-4"})}),u.jsxs("div",{className:"space-y-1",children:[u.jsx("p",{className:"text-xs font-semibold uppercase tracking-wide text-blue-700",children:"Research Task"}),u.jsxs("p",{className:"text-[11px] text-blue-900/80",children:["Task ID: ",u.jsx("span",{className:"font-mono",children:LT(e.task_id)})]})]})]}),t&&u.jsx("span",{className:`inline-flex items-center rounded-full px-3 py-1 text-[11px] font-semibold ${t.badgeClass}`,children:t.label})]}),e.query&&u.jsxs("div",{className:"rounded border border-blue-100 bg-white/80 px-3 py-2 text-xs text-blue-900/90",children:[u.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wide text-blue-500",children:"Query"}),u.jsx("p",{className:"line-clamp-2 text-[11px] text-blue-900",children:e.query})]}),typeof e.results=="string"&&e.results.trim()&&u.jsxs("div",{className:"rounded border border-blue-100 bg-white/80 px-3 py-2 text-sm text-blue-900/90 space-y-1",children:[u.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wide text-blue-500",children:"Results"}),u.jsx(qn,{content:e.results,allowHtml:!1,className:"prose text-xs !prose-sm prose-blue dark:prose-invert"})]}),u.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[n?u.jsxs("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 rounded-full border border-blue-600/80 bg-blue-600/10 px-3 py-1 text-xs font-semibold text-blue-700 transition hover:bg-blue-600/20",children:[u.jsx("span",{children:"Go to task"}),u.jsx(ae.ExternalLink,{className:"h-3 w-3"})]}):u.jsx("span",{className:"text-xs text-muted-foreground",children:"Task link unavailable"}),e.createdAt&&u.jsxs("p",{className:"text-[10px] text-blue-700/70",children:["Started: ",new Date(e.createdAt).toLocaleTimeString()]})]})]})}function kp({artifact:e,idx:t=0}){const n=b.useMemo(()=>e?(Array.isArray(e.plots)?e.plots:[]).map(o=>sb(o)).filter(o=>o!==null):[],[e]);return(e==null?void 0:e.type)==="research_task_info"?u.jsx(Tp,{artifact:{type:"research_task_info",task_id:e.task_id,task_url:e.task_url,query:e.query,status:e.status,createdAt:e.createdAt}}):n.length>0?u.jsx("div",{className:"space-y-2",children:n.map((r,o)=>u.jsx(Sp,{preview:r,idx:o},`${t}-plot-${o}`))}):e&&typeof e=="object"?u.jsx("div",{className:"rounded-lg border border-gray-200 dark:border-gray-800 bg-gray-50 dark:bg-gray-900/20 p-4",children:u.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:["Unknown artifact type: ",u.jsx("code",{className:"font-mono",children:e.type||"unknown"})]})}):null}const il=p.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:oe("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));il.displayName="Card";const al=p.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:oe("flex flex-col space-y-1.5 p-6",e),...t}));al.displayName="CardHeader";const ll=p.forwardRef(({className:e,...t},n)=>u.jsx("h3",{ref:n,className:oe("text-2xl font-semibold leading-none tracking-tight",e),...t}));ll.displayName="CardTitle";const cl=p.forwardRef(({className:e,...t},n)=>u.jsx("p",{ref:n,className:oe("text-sm text-muted-foreground",e),...t}));cl.displayName="CardDescription";const ul=p.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:oe("p-6 pt-0",e),...t}));ul.displayName="CardContent";const Ep=p.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:oe("flex items-center p-6 pt-0",e),...t}));Ep.displayName="CardFooter";function Ip({interruptPart:e,onApprove:t,onReject:n,disabled:r,isActive:o,payload:s}){const i=e.title??"Approve the result?";let a=null;if(s!=null)if(typeof s=="string")a=u.jsx("p",{className:"text-sm leading-relaxed text-blue-800/90 dark:text-blue-200/90 whitespace-pre-wrap",children:s});else{const c=vr(s);a=u.jsx("pre",{className:"max-h-48 overflow-auto rounded bg-blue-100/60 p-2 text-xs text-blue-900/90 dark:bg-blue-900/40 dark:text-blue-100/80",children:c})}const l=o?"Please approve or reject this action to resume the workflow.":"Waiting for approval from another participant.";return u.jsxs(il,{className:oe("border-blue-200 dark:border-blue-800 bg-blue-50/50 dark:bg-blue-950/10 transition-shadow",o?"shadow-md ring-1 ring-blue-300 dark:ring-blue-500/70":"opacity-80"),children:[u.jsxs(al,{className:"pb-3",children:[u.jsx(ll,{className:"text-blue-900 dark:text-blue-100 text-base",children:i}),u.jsx(cl,{className:"text-blue-700 dark:text-blue-300 text-sm",children:l})]}),a&&u.jsx(ul,{className:"pt-0 pb-3",children:a}),u.jsx(Ep,{className:"pt-0",children:u.jsxs("div",{className:"flex gap-2 ml-auto",children:[u.jsx(Je,{size:"sm",variant:"outline",onClick:()=>n(e),className:"border-red-300 text-red-700 hover:bg-red-50 dark:border-red-700 dark:text-red-300 dark:hover:bg-red-950/50",disabled:r||!o,children:"Reject"}),u.jsx(Je,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",disabled:r||!o,children:"Approve"})]})})]})}const $T="prose prose-sm max-w-none break-words dark:prose-invert prose-headings:break-words prose-p:break-words prose-li:break-words prose-td:break-words prose-th:break-words prose-a:break-all prose-code:break-words prose-blockquote:break-words";function dl({data:e}){return Array.isArray(e)?e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?u.jsx("div",{className:$T,children:u.jsx("ul",{className:"list-disc pl-5",children:e.map((n,r)=>u.jsx("li",{children:String(n)},r))})}):u.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:vr(e)}):u.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:vr(e)})}function Np({message:e,isStreaming:t=!1}){const n=e.name??"tool",r=b.useMemo(()=>{const a=e.additionalKwargs??{};return Array.isArray(a.toolProgress)?[...a.toolProgress]:[]},[e]),s=r.some(a=>a.type==="tool.start"||a.type==="tool.call"||a.type==="message.start")?`Running ${n}…`:void 0;return t||r.length>0?u.jsxs("div",{className:"space-y-2",children:[u.jsxs("div",{className:"flex items-center gap-2 text-xs uppercase tracking-wide text-muted-foreground",children:[t&&u.jsx(ae.Loader,{className:"h-3 w-3 animate-spin"}),u.jsx("span",{children:s??`Running ${n}…`})]}),r.length>0&&u.jsx("div",{className:"space-y-2 text-xs text-muted-foreground",children:r.map((a,l)=>{var c;return u.jsxs("div",{className:"rounded border border-current/10 bg-muted/60 p-2 text-[11px] leading-snug",children:[u.jsxs("div",{className:"mb-1 flex items-center justify-between text-[8px] uppercase tracking-wide text-muted-foreground",children:[u.jsx("span",{children:((c=a.type)==null?void 0:c.replace(/\./g," "))??"progress"}),u.jsx("span",{children:a.idx??l+1})]}),a.content&&u.jsx("p",{className:"mt-1 text-[12px] text-foreground/90",children:a.content}),u.jsxs("div",{className:"mt-1 flex flex-wrap gap-2 text-[10px] opacity-70",children:[typeof a.factsFound=="number"&&u.jsxs("span",{children:["Facts found: ",a.factsFound]}),typeof a.isSufficient=="boolean"&&u.jsxs("span",{children:["Research ",a.isSufficient?"sufficient":"needs more data"]})]})]},`tool-progress-${n}-${l}`)})})]}):null}function Ap({className:e}){const[t,n]=b.useState(0);return b.useEffect(()=>{const r=setInterval(()=>n(o=>(o+1)%4),500);return()=>clearInterval(r)},[]),u.jsxs("span",{"aria-live":"polite",className:oe("inline-block text-xs opacity-70 ml-1",e),children:["Is thinking",".".repeat(t)]})}function jp({text:e,expanded:t,onExpandedChange:n,previewLength:r,isCompact:o}){const s=Math.max(e.length-r,0),i=e.substring(0,r);return u.jsxs("div",{className:"flex flex-col gap-1",children:[u.jsx("div",{className:oe("text-sm text-[hsl(var(--chat-bubble-user-text))]",o&&"text-xs"),children:t?u.jsx(qn,{content:e,allowHtml:!1}):u.jsxs("pre",{className:oe("font-sans whitespace-pre-wrap break-words bg-transparent p-0 m-0 text-[hsl(var(--chat-bubble-user-text))]",o&&"text-xs"),children:[i,"..."]})}),u.jsx(Je,{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(ae.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):u.jsxs(u.Fragment,{children:[u.jsx(ae.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",s," chars)"]})})]})}function Pp({message:e,viewMode:t,isStreaming:n=!1}){const o=Oi(e).name||"tool",s=e.artifact??null,i=c=>{if(c==null)return null;const d=typeof c=="string"?Mi(c)??c:c;if(d&&typeof d=="object")return u.jsx(dl,{data:d});const h=typeof d=="string"?d:(()=>{try{return vr(d)}catch{return String(d??"")}})();return u.jsx("pre",{className:"whitespace-pre-wrap break-words font-sans text-sm text-foreground/90",children:h})},a=c=>{if(c==null)return null;const{content:d,isMarkdown:h}=Zv(c);return h?u.jsx(qn,{content:d,className:"text-current"}):i(c)},l=()=>{const c=e.content.find(m=>m.type!=="tool_call");if(!c)return u.jsx("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:u.jsxs("span",{children:["Running ",o,"…"]})});if(c.type==="text"){const f=(c.text??"").trim();if(!f)return null;const v=Qr(f);return a(v)}const d=Zr(c),h=Qr(d);return a(h)};return u.jsxs("div",{className:"space-y-2",children:[s&&u.jsx(kp,{artifact:s,idx:0}),u.jsx(Np,{message:e,isStreaming:n}),t==="expanded"&&u.jsx(u.Fragment,{children:l()})]})}function _p(e){const{allowFileOpen:t,currentThreadId:n}=e,{toast:r}=rl(),[o,s]=b.useState({}),[i,a]=b.useState(null),[l,c]=b.useState(!1),d=b.useCallback(()=>{c(!1),a(null)},[]),h=b.useCallback(f=>{a(f),c(!0)},[]),m=b.useCallback(async(f,v,g)=>{var x,y;if(!t){f.preventDefault();return}if(o[g]){f.preventDefault();return}try{const w=String(v.url??""),S=w.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);if(S){f.preventDefault();const k=S[1],C=v.name||`file_${k}`,T=v.mimeType||"application/octet-stream";h({id:k,name:C,mimeType:T});return}if(w.startsWith("data:")){f.preventDefault(),s(C=>({...C,[g]:!0}));const k=r({title:"Fetching file...",description:"",open:!0});try{const C=await eu(n??void 0);if(!C||!Array.isArray(C))throw new Error("Invalid file list response");const T=C.find(E=>!E||typeof E!="object"||!((E.filename??"")===(v.name??""))?!1:typeof v.size=="number"&&typeof E.size=="number"?E.size===v.size:!0);if(!(T!=null&&T.id))throw new Error(`File "${v.name}" is not yet available on the server`);if(!T.id||!T.filename)throw new Error("Invalid file data received from server");h({id:T.id,name:v.name||T.filename||`file_${T.id}`,mimeType:v.mimeType||T.mime_type||"application/octet-stream"}),(x=k.update)==null||x.call(k,{id:k.id,title:"Success",description:`Opened ${v.name}`,open:!0})}catch(C){console.error("Failed to fetch server file:",C);const T=C instanceof Error?C.message:"Unknown error occurred";(y=k.update)==null||y.call(k,{id:k.id,title:"Failed",description:T}),r({title:"Failed to fetch file",description:T,open:!0})}finally{s(C=>({...C,[g]:!1}))}}}catch(w){console.error("File click error:",w),s(S=>({...S,[g]:!1}))}},[t,o,r,n,h]);return{uploadingFiles:o,handleFileClick:m,fileViewerOpen:l,currentFileInfo:i,closeFileViewer:d}}function Rp(e,t){return b.useMemo(()=>{if(t)return{contentParts:[],textContent:"",toolMeta:{},imageParts:[],fileParts:[],interruptParts:[],toolRaw:"",isToolStreaming:!1};const n=e,r=Array.isArray(n.content)?n.content:[],o=n.additionalKwargs??{};return{contentParts:r,textContent:Qv(r),toolMeta:Oi(n),imageParts:r.filter(s=>s.type==="image_url"),fileParts:r.filter(s=>s.type==="file"),interruptParts:r.filter(s=>s.type==="interrupt"),toolRaw:eb(r),isToolStreaming:!!o.toolStreaming}},[e,t])}const FT={checkpoints:[],checkpointMetaByCheckpointId:new Map,timeline:[],messagePreviews:new Map,getLatest:()=>{},getCheckpoint:()=>{},getMessageAttempts:()=>[]},fl=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,hl=b.memo(function({message:t,index:n,isStreaming:r,streamingAssistantId:o,streamingDebounceMs:s,layoutSize:i,enableMessageEditing:a,editingMessageId:l,onEdit:c,onRegenerate:d,onCancelEdit:h,activeInterrupt:m,disableInterruptActions:f,onInterruptActionStart:v,onInterruptActionEnd:g,showToolMessages:x,checkpointIndex:y,onSelectCheckpoint:w}){const S=fl(t,n),k=t.role==="default_message",T=!!t.__syntheticStreaming,E=y??FT,j=!k&&"checkpointId"in t?t.checkpointId??null:null,{attemptCount:P,attemptIndex:D,attempts:F}=b.useMemo(()=>tc(t.id,j,E),[t.id,j,E]);return u.jsx("div",{className:"relative mb-4 last:mb-0","data-message-id":S,style:{minHeight:"60px",containIntrinsicSize:"auto 120px"},children:u.jsx(Xs,{message:t,messageIndex:n,isStreamingMessage:T||r&&o===t.id&&t.role==="assistant",streamingDebounceMs:s,isEditing:l===t.id,showActions:a,showTimestamp:!1,showAgentName:!0,layoutSize:i,onEdit:c,onRegenerate:()=>d(n),onCancelEdit:h,activeInterrupt:m,disableInterruptActions:f,onInterruptActionStart:v,onInterruptActionEnd:g,showToolMessages:x,attemptCount:P,attemptIndex:D,attemptMetas:F,onSelectCheckpoint:w})})});hl.displayName="MessageRow";function BT(e,t,n){const[r,o]=b.useState(e),s=b.useRef([]);return b.useEffect(()=>{if(!t){o(e),s.current=e.map(a=>a.type==="text"?a.text??"":void 0);return}const i=e.map((a,l)=>{if(a.type!=="text")return s.current[l]=void 0,a;const c=a.text??"",d=s.current[l];return n(c)?(s.current[l]=c,a):{...a,text:d??""}});o(i)},[e,t,n]),r}function zT({message:e,isToolMessage:t,showToolMessages:n,toolViewMode:r,isToolStreaming:o,contentParts:s,textContent:i,imageParts:a,fileParts:l,interruptParts:c,isStreamingMessage:d,enableStreamingMarkdownBuffer:h,renderStreamingMarkdown:m,defaultMessage:f,handleFileClick:v,uploadingFiles:g,handleInterruptApprove:x,handleInterruptReject:y,disableInterruptActions:w,messageRole:S,truncateUserMessages:k,userMessagePreviewLength:C,isUserExpanded:T,setIsUserExpanded:E,isCompactLayout:j,activeInterruptId:P,activeInterruptValue:D,iconForeground:F}){const W=b.useCallback(()=>u.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/30 rounded",children:[u.jsx(ae.Loader,{className:"h-4 w-4 text-muted-foreground"}),u.jsx("span",{className:"text-sm text-muted-foreground",children:"File upload"})]}),[]),A=BT(s,(h??!0)&&d,Mp),X=b.useMemo(()=>A.filter(O=>O.type==="text"),[A]),q=b.useMemo(()=>X.map(O=>O.text??"").join(""),[X]),B=b.useMemo(()=>{if(!m)return null;const O=HT(q);return{stablePart:q.slice(0,O),tailPart:q.slice(O)}},[q,m]),R=b.useMemo(()=>{if(!B)return null;const{stablePart:O,tailPart:M}=B;return!O&&!M?null:u.jsxs("div",{className:"space-y-2",children:[O?u.jsx(qn,{content:O,allowHtml:!1}):null,M?u.jsx(qn,{content:M,allowHtml:!1}):null]})},[B]),I=b.useMemo(()=>{if(!m)return A;const O=[];let M=!1;for(const L of A){if(L.type==="text"){M||(O.push({type:"text",text:"",__streamingMarkdownAggregate:!0}),M=!0);continue}O.push(L)}return O},[A,m]),H=m?I:A,Y=b.useCallback(({part:O,i:M})=>{if(O.type==="text"){if(m)return null;const L=O.text??"",te=L.trim(),z=Mi(te);return z&&S!=="tool"?u.jsx(dl,{data:z},M):S==="user"&&k&&te.length>C?u.jsx(jp,{text:te,expanded:T,onExpandedChange:E,previewLength:C,isCompact:j},M):u.jsx(qn,{content:L,allowHtml:!1},M)}if(O.type==="image_url"){const L=O;return u.jsx("div",{className:"my-2",children:u.jsx("img",{src:L.url,alt:L.alt??"",loading:"lazy",className:"border rounded max-h-[420px] w-auto object-contain"})},M)}if(O.type==="file"){const L=O,te=L.name||"file";return u.jsxs("a",{href:L.url,onClick:z=>v(z,L,M),className:`inline-flex items-center gap-2 rounded px-2 py-1 text-xs bg-gray-100 border hover:bg-gray-200
|
|
129
|
-
dark:bg-background/10 dark:border-border/30 dark:hover:bg-background/20`,children:[g[M]?u.jsx(ae.Loader,{className:"h-4 w-4 animate-spin"}):null,u.jsxs("span",{className:"truncate max-w-[180px]",children:[te,g[M]?" (processing)":""]})]},M)}if(O.type==="interrupt"){const L=O,te=Yo((L==null?void 0:L.id)??(L==null?void 0:L.interrupt_id)),z=!!(P&&te&&te===P),$=z?D??(L==null?void 0:L.value):L==null?void 0:L.value,ee=te?{...L,id:te,interrupt_id:te}:L;return u.jsx(Ip,{interruptPart:ee,onApprove:x,onReject:y,disabled:w,isActive:z,payload:$},M)}return null},[P,D,w,v,x,y,j,T,S,k,g,C,m,E]),_=i.trim().length>0||a.length>0||l.length>0||c.length>0;if(!t&&l.length>0&&!d)return W();if(!t&&!_&&!d)return null;if(t)return n?u.jsx(Pp,{message:e,viewMode:r,isStreaming:o},e.id):null;if(!f){const O=u.jsx("div",{className:"space-y-2",children:H.map((M,L)=>m&&UT(M)?R?u.jsx("div",{className:"space-y-2",children:R},`streaming-md-${L}`):null:u.jsx(Y,{part:M,i:L},L))});return d?u.jsxs("div",{"aria-busy":"true",role:"status",children:[O,u.jsx(Ap,{className:F})]}):O}return null}function Mp(e){return e?!(Io(e,/```/g)||Io(e,/`/g)||Io(e,/\*\*/g)||Io(e,/__/g)||Io(e,/~~/g)||/[^\\]\[[^\]]*$/.test(e)||/\[[^\]]*\]\([^)]*$/.test(e)):!0}function Io(e,t){const n=e.match(t);return((n==null?void 0:n.length)??0)%2!==0}function HT(e){if(!e)return 0;for(let t=e.length;t>=0;t-=1)if(Mp(e.slice(0,t)))return t;return 0}function UT(e){return e.type==="text"&&!!e.__streamingMarkdownAggregate}const WT=zr.cva("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function Op({className:e,variant:t,...n}){return u.jsx("div",{className:oe(WT({variant:t}),e),...n})}function VT({showTimestamp:e,showAgentName:t,isToolMessage:n,iconForeground:r,agentName:o,messageIcon:s,customHeaderClass:i,customActionsClass:a,isCompactLayout:l,showActions:c,isEditing:d,messageRole:h,toolViewMode:m,toolMeta:f,onToggleToolView:v,onCopy:g,onEdit:x,onRegenerate:y,showCheckpointControls:w,attemptCount:S,attemptIndex:k,handleOlderAttemptSelect:C,handleNewerAttemptSelect:T,messageCreatedAt:E,copied:j}){return!e&&!t&&!n?null:u.jsxs("div",{className:oe("flex items-center justify-between mb-2 pb-2 border-b border-current/10",l&&"mb-1 pb-1",r,i),children:[u.jsxs("div",{className:"flex items-center gap-2",children:[s,t&&o&&u.jsx("span",{className:oe("font-medium",l?"text-xs":"text-sm"),children:o}),n&&u.jsxs(Op,{variant:"outline",className:oe("text-xs flex items-center gap-1 cursor-pointer select-none",r,"border border-current/40",l&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":m==="expanded",onClick:v,onKeyDown:P=>{(P.key==="Enter"||P.key===" ")&&(P.preventDefault(),v())},children:[u.jsx("span",{children:f.name??"Tool Output"}),f.toolCallId&&u.jsx("span",{className:"opacity-70",children:f.toolCallId.slice(0,8)}),m==="expanded"?u.jsx(ae.ChevronUp,{className:"h-3 w-3"}):u.jsx(ae.ChevronDown,{className:"h-3 w-3"})]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[w&&S>1&&u.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[u.jsx("button",{type:"button",className:oe("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",k<S-1?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{k>=S-1||C()},"aria-label":"Older attempt (back in time)",disabled:k>=S-1,children:u.jsx(ae.ChevronLeft,{className:"h-3 w-3"})}),u.jsx("div",{className:"flex items-center gap-2",children:u.jsxs("span",{className:"whitespace-nowrap",children:[S-k," / ",S]})}),u.jsx("button",{type:"button",className:oe("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",k>0?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{k<=0||T()},"aria-label":"Newer attempt (forward in time)",disabled:k<=0,children:u.jsx(ae.ChevronRight,{className:"h-3 w-3"})})]}),e&&E&&u.jsx("time",{className:oe("text-xs opacity-60",r,l&&"text-xs"),dateTime:new Date(E).toISOString(),title:new Date(E).toLocaleString(),children:new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(new Date(E))}),c&&!d&&u.jsxs("div",{className:oe("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",a),children:[u.jsx("div",{className:"relative",children:u.jsx(Je,{variant:"ghost",size:"sm",onClick:g,className:oe("h-6 w-6 p-0 hover:bg-foreground/10",r,l&&"h-5 w-5"),"aria-label":"Copy message",title:"Copy message",children:u.jsx(ae.Copy,{className:oe(j?"text-success":r,l?"h-3 w-3":"h-4 w-4")})})}),h==="user"&&x&&u.jsx(Je,{variant:"ghost",size:"sm",onClick:x,className:oe("h-6 w-6 p-0 hover:bg-foreground/10",r,l&&"h-5 w-5"),"aria-label":"Edit message",children:u.jsx(ae.Edit,{className:oe(r,l?"h-3 w-3":"h-4 w-4")})}),h==="assistant"&&y&&u.jsx(Je,{variant:"ghost",size:"sm",onClick:y,className:oe("h-6 w-6 p-0 hover:bg-foreground/10",r,l&&"h-5 w-5"),"aria-label":"Regenerate response",children:u.jsx(ae.RotateCcw,{className:oe(r,l?"h-3 w-3":"h-4 w-4")})})]})]})]})}const Xs=b.memo(function({message:t,messageIndex:n,isStreamingMessage:r=!1,isEditing:o=!1,showActions:s=!0,showTimestamp:i=!0,showAgentName:a=!0,layoutSize:l="desktop",truncateUserMessages:c=!0,userMessagePreviewLength:d=500,showToolMessages:h=!0,customStyles:m={},streamingDebounceMs:f=300,renderStreamingMarkdown:v=!1,enableStreamingMarkdownBuffer:g,onEdit:x,onRegenerate:y,onCopy:w,activeInterrupt:S,disableInterruptActions:k=!1,onInterruptActionStart:C,onInterruptActionEnd:T,attemptCount:E=1,attemptIndex:j=0,onSelectCheckpoint:P,attemptMetas:D=[]}){const[F,W]=b.useState(!1),[G,A]=b.useState("preview"),[X,q]=b.useState(!1),{currentThreadId:B}=xr(),{respondToInterrupt:R}=eo(),I=l==="phone"||l==="half-screen",H=t.role,Y=H==="tool",_=b.useMemo(()=>t.role==="default_message"?t:null,[t]),O=!!_,M=!(r&&H!=="user"),{uploadingFiles:L,handleFileClick:te,fileViewerOpen:z,currentFileInfo:$,closeFileViewer:ee}=_p({allowFileOpen:M,currentThreadId:B}),J=b.useMemo(()=>{switch(H){case"user":return"text-[hsl(var(--chat-bubble-user-text))]";case"assistant":return"text-[hsl(var(--chat-bubble-ai-text))]";case"tool":return"text-secondary-foreground";case"system":return"text-muted-foreground";default:return"text-[hsl(var(--chat-bubble-ai-text))]"}},[H]),K=Rp(t,_),{contentParts:Q,imageParts:pe,fileParts:de,interruptParts:me,textContent:we,toolMeta:Te,toolRaw:Ne,isToolStreaming:ke}=K,st=g??f!==0,vt=(S==null?void 0:S.id)??(S==null?void 0:S.interrupt_id),pt=Yo(vt),We=S==null?void 0:S.value,Le=b.useCallback(async()=>{const Z=Y?Ne:we;async function ce(He){if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function"){await navigator.clipboard.writeText(He);return}if(navigator.clipboard&&typeof navigator.clipboard.write=="function"&&typeof ClipboardItem<"u"){const ve=new Blob([He],{type:"text/plain"});await navigator.clipboard.write([new ClipboardItem({"text/plain":ve})]);return}throw new Error("Clipboard API not supported in this context.")}try{await ce(Z),W(!0),setTimeout(()=>W(!1),2e3),w==null||w(Z)}catch(He){console.error("Failed to copy:",He)}},[Y,Ne,we,w]),Ge=b.useCallback(()=>{if(!x||!t.id)return;const Z=(Y?Ne:we)??"",ce="type"in t&&t.type==="default_message"?void 0:{checkpointId:t.checkpointId??null,checkpointNs:t.checkpointNs??null};x(t.id,Z,ce)},[x,t.id,Y,Ne,we,t]),Re=b.useCallback(()=>{y==null||y(n)},[y,n]),$e=b.useCallback(()=>{A(Z=>Z==="expanded"?"preview":"expanded")},[]),Ze=b.useCallback(()=>{const ce=oe(I?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",J);switch(H){case"user":return u.jsx(ae.User,{className:ce});case"assistant":return u.jsx(ae.Bot,{className:ce});case"tool":return u.jsx(ae.Wrench,{className:ce});default:return u.jsx(ae.Bot,{className:ce})}},[I,J,H]),It=b.useCallback(()=>{const Z="group relative mb-4 flex w-full";switch(H){case"user":return oe(Z,"justify-end");case"assistant":case"tool":case"system":return oe(Z,"justify-start");default:return Z}},[H]),it=b.useCallback(()=>{const Z=oe("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",I&&"px-3 py-2 text-sm");if(O)return oe(Z,"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(H){case"user":return oe(Z,"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(Z,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40");case"tool":return oe(Z,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return oe(Z,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return oe(Z,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40")}},[I,O,H]),yt=b.useCallback(async Z=>{if(k)return;const ce=Yo((Z==null?void 0:Z.id)??(Z==null?void 0:Z.interrupt_id));if(!ce){console.warn("Interrupt part missing id",Z);return}try{C==null||C(),await R(ce,!0)}catch(He){console.error("Failed to approve interrupt:",He)}finally{T==null||T()}},[k,T,C,R]),St=b.useCallback(async Z=>{if(k)return;const ce=Yo((Z==null?void 0:Z.id)??(Z==null?void 0:Z.interrupt_id));if(!ce){console.warn("Interrupt part missing id",Z);return}try{C==null||C(),await R(ce,!1)}catch(He){console.error("Failed to reject interrupt:",He)}finally{T==null||T()}},[k,T,C,R]),Ct=u.jsx(zT,{message:t,isToolMessage:Y,showToolMessages:h,toolViewMode:G,isToolStreaming:ke,contentParts:Q,textContent:we,imageParts:pe,fileParts:de,interruptParts:me,isStreamingMessage:r,defaultMessage:_,enableStreamingMarkdownBuffer:st,renderStreamingMarkdown:v,handleFileClick:te,uploadingFiles:L,handleInterruptApprove:yt,handleInterruptReject:St,disableInterruptActions:k,messageRole:H,truncateUserMessages:c,userMessagePreviewLength:d,isUserExpanded:X,setIsUserExpanded:q,isCompactLayout:I,activeInterruptId:pt,activeInterruptValue:We,iconForeground:J}),kt=b.useMemo(()=>_?"Assistant":tb(t),[_,t]),on=Ze(),Nt=H==="user"&&(E??1)>1&&typeof P=="function",Vt=(D==null?void 0:D.length)??0,Et=Vt>0&&j<Vt-1?D[j+1]:void 0,Fe=Vt>0&&j>0?D[j-1]:void 0,Ve=b.useCallback(()=>{!Et||!P||P(Et.id,void 0,!!Et.isLatestAttempt)},[Et,P]),At=b.useCallback(()=>{!Fe||!P||P(Fe.id,void 0,!!Fe.isLatestAttempt)},[Fe,P]);return Y&&!h?null:O&&_?u.jsx("div",{className:oe(It(),m.container),children:u.jsxs("div",{className:oe(it(),m.content),children:[u.jsxs("div",{className:"flex items-center gap-2 mb-2 pb-2 border-b border-current/10",children:[u.jsx(ae.Bot,{className:oe("h-4 w-4",J)}),a&&u.jsx("span",{className:"font-medium text-sm",children:"Assistant"})]}),u.jsx(qn,{content:_.content,className:"text-current"})]})}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:oe(It(),m.container),children:u.jsxs("div",{className:oe(it(),m.content),children:[u.jsx(VT,{showTimestamp:i,showAgentName:a,isToolMessage:Y,iconForeground:J,agentName:kt,messageIcon:on,customHeaderClass:m.header,customActionsClass:m.actions,isCompactLayout:I,showActions:s,isEditing:o,messageRole:H,toolViewMode:G,toolMeta:Te,onToggleToolView:$e,onCopy:Le,onEdit:Ge,onRegenerate:Re,showCheckpointControls:Nt,attemptCount:E,attemptIndex:j,handleOlderAttemptSelect:Ve,handleNewerAttemptSelect:At,messageCreatedAt:t.createdAt,copied:F}),u.jsx("div",{className:"relative",children:Ct}),Y&&G==="expanded"&&(Te.toolCallId||Te.name)&&u.jsxs("div",{className:oe("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",I&&"text-xs"),children:[Te.name&&u.jsxs("div",{children:["Function: ",Te.name]}),Te.toolCallId&&u.jsxs("div",{children:["Call ID: ",Te.toolCallId]})]}),!(i||a||Y)&&s&&!o&&u.jsxs("div",{className:oe("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",m.actions),children:[u.jsx(Je,{variant:"ghost",size:"sm",onClick:()=>Le(),className:oe("h-6 w-6 p-0 hover:bg-background/50 text-current",I&&"h-5 w-5"),children:u.jsx(ae.Copy,{className:oe(F?"text-success":"text-current",I?"h-3 w-3":"h-4 w-4")})}),H==="user"&&x&&u.jsx(Je,{variant:"ghost",size:"sm",onClick:Ge,className:oe("h-6 w-6 p-0 hover:bg-background/50 text-current",I&&"h-5 w-5"),children:u.jsx(ae.Edit,{className:oe("text-current",I?"h-3 w-3":"h-4 w-4")})}),H==="assistant"&&y&&u.jsx(Je,{variant:"ghost",size:"sm",onClick:Re,className:oe("h-6 w-6 p-0 hover:bg-background/50 text-current",I&&"h-5 w-5"),children:u.jsx(ae.RotateCcw,{className:oe("text-current",I?"h-3 w-3":"h-4 w-4")})})]})]})}),$&&u.jsx(lp,{isOpen:z,onClose:ee,fileId:$.id,fileName:$.name,mimeType:$.mimeType})]})},(e,t)=>{var l,c,d,h,m,f,v,g;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&mu(e.message)===mu(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateUserMessages","userMessagePreviewLength","showToolMessages"].every(x=>e[x]===t[x]),s=((l=e.customStyles)==null?void 0:l.container)===((c=t.customStyles)==null?void 0:c.container)&&((d=e.customStyles)==null?void 0:d.content)===((h=t.customStyles)==null?void 0:h.content)&&((m=e.customStyles)==null?void 0:m.actions)===((f=t.customStyles)==null?void 0:f.actions)&&((v=e.customStyles)==null?void 0:v.header)===((g=t.customStyles)==null?void 0:g.header);if(!o||!s)return!1;const i=gu(e.message),a=gu(t.message);return i.length===a.length});Xs.displayName="MessageComponent";const pl=b.forwardRef(({messages:e,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onStartReached:a,onEdit:l,onRegenerate:c,onCancelEdit:d,className:h,style:m,emptyMessage:f,followNewMessages:v=!0,isNavigatingCheckpoint:g=!1,onScrollAway:x,onAtBottom:y,activeInterrupt:w,disableInterruptActions:S=!1,onInterruptActionStart:k,onInterruptActionEnd:C,showToolMessages:T=!0,checkpointIndex:E,activeCheckpointId:j,onSelectCheckpoint:P,createSyntheticThinkingMessage:D=!0,forceSyntheticThinking:F=!1},W)=>{const G=b.useRef(null),A=b.useRef(null),X=b.useRef(!1),q=b.useRef(!1),B=b.useMemo(()=>w?e.some(J=>J.role==="default_message"?!1:Array.isArray(J==null?void 0:J.content)&&J.content.some(K=>K&&K.type==="interrupt"&&(K.id??K.interrupt_id)===w.id)):!1,[w,e]),R=b.useMemo(()=>{if(!w||B)return null;const J=w.id&&String(w.id).trim()?String(w.id).trim():"pending-interrupt";let K;const Q=w.value;if(Q&&typeof Q=="object"&&!Array.isArray(Q)){const pe=Q.title;typeof pe=="string"&&pe.trim()&&(K=pe.trim())}return{id:`interrupt-${J}`,role:"system",createdAt:new Date().toISOString(),content:[{type:"interrupt",id:J,value:Q,title:K}]}},[w,B]),I=b.useMemo(()=>R?[...e,R]:e,[e,R]),H=b.useMemo(()=>{const J=n&&I.some(Q=>Q.id===n);return D&&(t||F)&&!J&&I.length>0?[...I,{id:"thinking-assistant",role:"assistant",content:[{type:"text",text:""}],createdAt:new Date().toISOString(),__syntheticStreaming:!0}]:I},[I,t,n,D,F]),Y=b.useMemo(()=>T?H:H.filter(J=>(J==null?void 0:J.role)!=="tool"),[H,T]),_=b.useCallback(J=>{x&&x(!J),y&&y(J)},[x,y]),O=b.useMemo(()=>{if(a)return async()=>{if(!X.current){X.current=!0;try{await a()}finally{X.current=!1}}}},[a]),M=b.useMemo(()=>!v||g?!1:"auto",[v,g]),L=b.useMemo(()=>{if(typeof f!="string")return null;const J=f.trim();return!J||Y&&Y.length>0?null:{id:"default-message",role:"default_message",content:J,createdAt:new Date().toISOString()}},[f,Y]),te=["flex h-full flex-col md:flex-row",h].filter(Boolean).join(" "),z=()=>L?u.jsx("div",{className:"p-6 h-full overflow-y-auto",children:u.jsx("div",{className:"w-full max-w-full",children:u.jsx(Xs,{message:L,messageIndex:0,isStreamingMessage:!1,showActions:!1,showTimestamp:!1,showAgentName:!0,layoutSize:o,onEdit:()=>{},onRegenerate:()=>{},onCancelEdit:()=>{}})})}):u.jsx("div",{className:"flex h-full items-center justify-center py-8 text-center text-muted-foreground",children:f??"No messages yet. Start a conversation!"}),$=Y.length,ee=$>0;return b.useEffect(()=>{var J,K;if($===0){q.current=!1;return}if(!q.current)if(q.current=!0,G.current&&Y.length>0){const Q=Y.length-1;(K=(J=G.current).scrollToIndex)==null||K.call(J,{index:Q,align:"end",behavior:"auto"})}else A.current&&(A.current.scrollTop=A.current.scrollHeight)},[$,Y.length]),b.useImperativeHandle(W,()=>({scrollToLatest:()=>{var J,K;if(G.current&&Y.length>0){const Q=Y.length-1;(K=(J=G.current).scrollToIndex)==null||K.call(J,{index:Q,align:"end",behavior:"auto"})}else A.current&&(A.current.scrollTop=A.current.scrollHeight)},scrollToTop:()=>{var J,K;G.current&&Y.length>0?(K=(J=G.current).scrollToIndex)==null||K.call(J,{index:0,align:"start",behavior:"auto"}):A.current&&(A.current.scrollTop=0)}}),[Y]),u.jsx("div",{className:te,style:m,children:u.jsx("div",{className:"relative flex-1 min-h-0",children:ee?u.jsx(zC,{ref:J=>{G.current=J},scrollerRef:J=>{A.current=J instanceof HTMLDivElement?J:null},data:Y,followOutput:M,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,startReached:()=>{O&&O()},atBottomStateChange:_,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(J,K)=>fl(K,J),itemContent:(J,K)=>u.jsx(hl,{message:K,index:J,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onEdit:l,onRegenerate:c,onCancelEdit:d,activeInterrupt:w,disableInterruptActions:S,onInterruptActionStart:k,onInterruptActionEnd:C,showToolMessages:T,checkpointIndex:E,activeCheckpointId:j,onSelectCheckpoint:P})}):z()})})});pl.displayName="MessageList";const Dp={value:""};function Mr({className:e="",placeholder:t="Type your message...",autoFocus:n=!0,maxHeight:r=void 0,streamingDebounceMs:o=500,streamingThrottleMs:s,followNewMessages:i=!0,enableFileUpload:a=!0,enableExcelUpload:l=!1,enableMessageEditing:c=!0,showToolMessages:d=!0,payloadExtras:h={},customStyles:m={},onMessageSent:f,onExcelUploadSuccess:v,onError:g,defaultMessage:x}){const{api:y}=Xr(),{currentThreadId:w}=xr(),{threadId:S,messages:k,isHistoryLoading:C,isLoading:T,navigateToCheckpoint:E,returnToLatest:j,checkpoint:P,checkpoints:D,interrupt:F,metadata:W,checkpointIndex:G}=eo(),{isStreaming:A,error:X,connectionState:q,submit:B,stop:R}=$i(),I=S??w??null,H=(P==null?void 0:P.id)??null,Y=(P==null?void 0:P.namespace)??null,_=(W==null?void 0:W.assemblingMessageId)??null,O=F,[M,L]=b.useState(!1),[te,z]=b.useState(!1);b.useEffect(()=>{O||L(!1)},[O]);const $=b.useCallback(()=>{L(!0)},[]),ee=b.useCallback(()=>{L(!1)},[]),J=!!O||M,[K,Q]=b.useState(null),[pe,de]=b.useState(""),[me,we]=b.useState(null),[Te,Ne]=b.useState(null),[ke,st]=b.useState(!1),[vt,pt]=b.useState(null),We=b.useRef(!1),[Le,Ge]=b.useState(()=>Dp.value),Re=b.useRef(Le),$e=b.useRef(null),Ze=b.useCallback(he=>{Dp.value=he,Ge(he)},[]),[It,it]=b.useState(!1),yt=b.useRef(null),St=b.useCallback(he=>{Ze(he)},[Ze]);b.useEffect(()=>{A||z(!1)},[A]),b.useEffect(()=>{W!=null&&W.assemblingMessageId&&z(!1)},[W==null?void 0:W.assemblingMessageId]);const[Ct,kt]=b.useState("desktop");b.useEffect(()=>{const he=()=>{const ye=window.innerWidth;kt(ye<640?"phone":ye<1024?"tablet":"desktop")};return he(),window.addEventListener("resize",he),()=>window.removeEventListener("resize",he)},[]),b.useEffect(()=>{We.current=!1},[I]),b.useEffect(()=>{Re.current=Le},[Le]),b.useEffect(()=>{if(!K){$e.current=null;return}$e.current===null&&($e.current=Re.current),Ze(pe??"")},[pe,K,Ze]),b.useEffect(()=>{if(x!==void 0){pt(x);return}(async()=>{if(!y.baseUrl){pt(null);return}try{const Me=(await y.getAgent("default")).uiDefaultMessage||"";pt(Me||null)}catch(ye){console.warn("Failed to fetch default message:",ye),pt(null)}})()},[y.baseUrl,x]),b.useEffect(()=>{X&&!ke&&(g==null||g(X))},[X,ke,g]);const on=async(he,ye)=>{const Me=he.trim();if(!(!Me&&ye.length===0))try{const Ke=K?(me==null?void 0:me.checkpointId)??H??void 0:H??void 0,lt=K?(me==null?void 0:me.checkpointNs)??Y??void 0:Y??void 0;await B({text:Me||"",attachments:ye,payload:h},{checkpointId:Ke,checkpointNs:lt,edit:!!K,originalMessageId:K??void 0}),f==null||f(Me),z(!0),Ze(""),Ne(null),Q(null),de(""),we(null)}catch(Ke){const lt=(Ke==null?void 0:Ke.message)||"Failed to send message";Ne(lt),g==null||g(lt),z(!1)}},Nt=b.useCallback(async he=>{await B({attachments:[he],payload:h},{checkpointId:H??void 0,checkpointNs:Y??void 0}),v==null||v({file:he})},[H,Y,h,v,B]),Vt=b.useCallback((he,ye,Me)=>{c&&($e.current=Le,Q(he),de(ye),Ze(ye),Ne(null),we({checkpointId:(Me==null?void 0:Me.checkpointId)??null,checkpointNs:(Me==null?void 0:Me.checkpointNs)??null}))},[Le,c,Ze]),Et=b.useCallback(()=>{Q(null),de(""),we(null),Ne(null),Ze($e.current??Le),$e.current=null},[Le,Ze]),Fe=b.useCallback((he,ye,Me)=>{Vt(he,ye,Me)},[Vt]),Ve=b.useCallback(he=>{let ye=null;for(let ct=he-1;ct>=0;ct--)if(k[ct].role==="user"){ye=k[ct];break}if(!ye)return;const Me=Array.isArray(ye.content)?ye.content:[],lt=Me.filter(ct=>(ct==null?void 0:ct.type)==="text").map(ct=>ct.text).join("")||(()=>{try{return JSON.stringify(Me,null,2)}catch{return String(Me)}})();lt&&B({text:lt,payload:h},{checkpointId:H??void 0,checkpointNs:Y??void 0,edit:!0,originalMessageId:ye.id})},[k,B,H,Y,h]),At=async he=>{if(w){it(!0);try{if(!he){await j(),requestAnimationFrame(()=>{var Ke;(Ke=yt.current)==null||Ke.scrollToLatest()});return}const ye=D.find(Ke=>Ke.checkpointId===he),Me=(ye==null?void 0:ye.checkpointNs)??null;await E(he,Me),requestAnimationFrame(()=>{var Ke;(Ke=yt.current)==null||Ke.scrollToTop()})}finally{it(!1)}}},Z=b.useCallback(async(he,ye,Me)=>{await At(Me?null:he)},[At]),ce=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${m.container||""}`,He=`flex-1 min-h-0 min-w-0 max-h-full w-full overflow-hidden overscroll-contain break-words break-anywhere p-4 bg-transparent ${m.messagesArea||""}`,ve=`relative flex-shrink-0 w-full border-t p-4 bg-transparent ${m.inputArea||""}`;return u.jsxs("div",{className:ce,children:[!!X&&!ke&&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:X}),u.jsx(Je,{variant:"ghost",size:"sm",onClick:()=>st(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:u.jsx(ae.X,{size:16})})]}),u.jsxs("div",{className:`relative ${He}`,style:r?{maxHeight:r}:void 0,children:[u.jsx(pl,{ref:yt,className:"h-full",style:{height:"100%"},messages:k,isStreaming:A,streamingAssistantId:_,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:Ct,enableMessageEditing:c,editingMessageId:K,onEdit:Fe,onRegenerate:Ve,onCancelEdit:Et,emptyMessage:vt??void 0,isNavigatingCheckpoint:It,activeInterrupt:O,disableInterruptActions:M,onInterruptActionStart:$,onInterruptActionEnd:ee,showToolMessages:d,checkpointIndex:G,activeCheckpointId:H,onSelectCheckpoint:Z,createSyntheticThinkingMessage:!0,forceSyntheticThinking:te}),(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(ae.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"}),T&&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(ae.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading messages…"})]}),(C||It)&&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(ae.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading checkpoint…"})]})]}),u.jsxs("div",{className:ve,children:[K&&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(ae.Edit3,{size:16,className:"text-blue-600"}),u.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),u.jsx(Je,{variant:"ghost",size:"sm",onClick:Et,className:"text-blue-600 hover:bg-blue-100",children:u.jsx(ae.X,{size:16})})]})}),Te&&u.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:Te}),u.jsx(PS,{composerValue:Le,onComposerChange:St,onSend:on,onCancelEdit:Et,onStop:R,editingMessageId:K,editingInitialValue:pe,placeholder:K?"Edit your message...":t,isStreaming:A,disabled:J,enableFileUpload:a,enableExcelUpload:l,onExcelUpload:Nt,onError:g,customStyles:m,textareaClassName:m.textarea||"",allowEmptySend:!1,inputError:Te})]})]})}var Lp=1,KT=.9,qT=.8,GT=.17,ml=.1,gl=.999,YT=.9999,XT=.99,JT=/[\\\/_+.#"@\[\(\{&]/,ZT=/[\\\/_+.#"@\[\(\{&]/g,QT=/[\s-]/,$p=/[\s-]/g;function xl(e,t,n,r,o,s,i){if(s===t.length)return o===e.length?Lp:XT;var a=`${o},${s}`;if(i[a]!==void 0)return i[a];for(var l=r.charAt(s),c=n.indexOf(l,o),d=0,h,m,f,v;c>=0;)h=xl(e,t,n,r,c+1,s+1,i),h>d&&(c===o?h*=Lp:JT.test(e.charAt(c-1))?(h*=qT,f=e.slice(o,c-1).match(ZT),f&&o>0&&(h*=Math.pow(gl,f.length))):QT.test(e.charAt(c-1))?(h*=KT,v=e.slice(o,c-1).match($p),v&&o>0&&(h*=Math.pow(gl,v.length))):(h*=GT,o>0&&(h*=Math.pow(gl,c-o))),e.charAt(c)!==t.charAt(s)&&(h*=YT)),(h<ml&&n.charAt(c-1)===r.charAt(s+1)||r.charAt(s+1)===r.charAt(s)&&n.charAt(c-1)!==r.charAt(s))&&(m=xl(e,t,n,r,c+1,s+2,i),m*ml>h&&(h=m*ml)),h>d&&(d=h),c=n.indexOf(l,c+1);return i[a]=d,d}function Fp(e){return e.toLowerCase().replace($p," ")}function ek(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,xl(e,t,Fp(e),Fp(t),0,0,{})}var No='[cmdk-group=""]',vl='[cmdk-group-items=""]',tk='[cmdk-group-heading=""]',Bp='[cmdk-item=""]',zp=`${Bp}:not([aria-disabled="true"])`,bl="cmdk-item-select",Or="data-value",nk=(e,t,n)=>ek(e,t,n),Hp=p.createContext(void 0),Ao=()=>p.useContext(Hp),Up=p.createContext(void 0),wl=()=>p.useContext(Up),Wp=p.createContext(void 0),Vp=p.forwardRef((e,t)=>{let n=Dr(()=>{var _,O;return{search:"",value:(O=(_=e.value)!=null?_:e.defaultValue)!=null?O:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=Dr(()=>new Set),o=Dr(()=>new Map),s=Dr(()=>new Map),i=Dr(()=>new Set),a=Kp(e),{label:l,children:c,value:d,onValueChange:h,filter:m,shouldFilter:f,loop:v,disablePointerSelection:g=!1,vimBindings:x=!0,...y}=e,w=Pt(),S=Pt(),k=Pt(),C=p.useRef(null),T=hk();ur(()=>{if(d!==void 0){let _=d.trim();n.current.value=_,E.emit()}},[d]),ur(()=>{T(6,G)},[]);let E=p.useMemo(()=>({subscribe:_=>(i.current.add(_),()=>i.current.delete(_)),snapshot:()=>n.current,setState:(_,O,M)=>{var L,te,z,$;if(!Object.is(n.current[_],O)){if(n.current[_]=O,_==="search")W(),D(),T(1,F);else if(_==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let ee=document.getElementById(k);ee?ee.focus():(L=document.getElementById(w))==null||L.focus()}if(T(7,()=>{var ee;n.current.selectedItemId=(ee=A())==null?void 0:ee.id,E.emit()}),M||T(5,G),((te=a.current)==null?void 0:te.value)!==void 0){let ee=O??"";($=(z=a.current).onValueChange)==null||$.call(z,ee);return}}E.emit()}},emit:()=>{i.current.forEach(_=>_())}}),[]),j=p.useMemo(()=>({value:(_,O,M)=>{var L;O!==((L=s.current.get(_))==null?void 0:L.value)&&(s.current.set(_,{value:O,keywords:M}),n.current.filtered.items.set(_,P(O,M)),T(2,()=>{D(),E.emit()}))},item:(_,O)=>(r.current.add(_),O&&(o.current.has(O)?o.current.get(O).add(_):o.current.set(O,new Set([_]))),T(3,()=>{W(),D(),n.current.value||F(),E.emit()}),()=>{s.current.delete(_),r.current.delete(_),n.current.filtered.items.delete(_);let M=A();T(4,()=>{W(),(M==null?void 0:M.getAttribute("id"))===_&&F(),E.emit()})}),group:_=>(o.current.has(_)||o.current.set(_,new Set),()=>{s.current.delete(_),o.current.delete(_)}),filter:()=>a.current.shouldFilter,label:l||e["aria-label"],getDisablePointerSelection:()=>a.current.disablePointerSelection,listId:w,inputId:k,labelId:S,listInnerRef:C}),[]);function P(_,O){var M,L;let te=(L=(M=a.current)==null?void 0:M.filter)!=null?L:nk;return _?te(_,n.current.search,O):0}function D(){if(!n.current.search||a.current.shouldFilter===!1)return;let _=n.current.filtered.items,O=[];n.current.filtered.groups.forEach(L=>{let te=o.current.get(L),z=0;te.forEach($=>{let ee=_.get($);z=Math.max(ee,z)}),O.push([L,z])});let M=C.current;X().sort((L,te)=>{var z,$;let ee=L.getAttribute("id"),J=te.getAttribute("id");return((z=_.get(J))!=null?z:0)-(($=_.get(ee))!=null?$:0)}).forEach(L=>{let te=L.closest(vl);te?te.appendChild(L.parentElement===te?L:L.closest(`${vl} > *`)):M.appendChild(L.parentElement===M?L:L.closest(`${vl} > *`))}),O.sort((L,te)=>te[1]-L[1]).forEach(L=>{var te;let z=(te=C.current)==null?void 0:te.querySelector(`${No}[${Or}="${encodeURIComponent(L[0])}"]`);z==null||z.parentElement.appendChild(z)})}function F(){let _=X().find(M=>M.getAttribute("aria-disabled")!=="true"),O=_==null?void 0:_.getAttribute(Or);E.setState("value",O||void 0)}function W(){var _,O,M,L;if(!n.current.search||a.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let te=0;for(let z of r.current){let $=(O=(_=s.current.get(z))==null?void 0:_.value)!=null?O:"",ee=(L=(M=s.current.get(z))==null?void 0:M.keywords)!=null?L:[],J=P($,ee);n.current.filtered.items.set(z,J),J>0&&te++}for(let[z,$]of o.current)for(let ee of $)if(n.current.filtered.items.get(ee)>0){n.current.filtered.groups.add(z);break}n.current.filtered.count=te}function G(){var _,O,M;let L=A();L&&(((_=L.parentElement)==null?void 0:_.firstChild)===L&&((M=(O=L.closest(No))==null?void 0:O.querySelector(tk))==null||M.scrollIntoView({block:"nearest"})),L.scrollIntoView({block:"nearest"}))}function A(){var _;return(_=C.current)==null?void 0:_.querySelector(`${Bp}[aria-selected="true"]`)}function X(){var _;return Array.from(((_=C.current)==null?void 0:_.querySelectorAll(zp))||[])}function q(_){let O=X()[_];O&&E.setState("value",O.getAttribute(Or))}function B(_){var O;let M=A(),L=X(),te=L.findIndex($=>$===M),z=L[te+_];(O=a.current)!=null&&O.loop&&(z=te+_<0?L[L.length-1]:te+_===L.length?L[0]:L[te+_]),z&&E.setState("value",z.getAttribute(Or))}function R(_){let O=A(),M=O==null?void 0:O.closest(No),L;for(;M&&!L;)M=_>0?dk(M,No):fk(M,No),L=M==null?void 0:M.querySelector(zp);L?E.setState("value",L.getAttribute(Or)):B(_)}let I=()=>q(X().length-1),H=_=>{_.preventDefault(),_.metaKey?I():_.altKey?R(1):B(1)},Y=_=>{_.preventDefault(),_.metaKey?q(0):_.altKey?R(-1):B(-1)};return p.createElement(ge.div,{ref:t,tabIndex:-1,...y,"cmdk-root":"",onKeyDown:_=>{var O;(O=y.onKeyDown)==null||O.call(y,_);let M=_.nativeEvent.isComposing||_.keyCode===229;if(!(_.defaultPrevented||M))switch(_.key){case"n":case"j":{x&&_.ctrlKey&&H(_);break}case"ArrowDown":{H(_);break}case"p":case"k":{x&&_.ctrlKey&&Y(_);break}case"ArrowUp":{Y(_);break}case"Home":{_.preventDefault(),q(0);break}case"End":{_.preventDefault(),I();break}case"Enter":{_.preventDefault();let L=A();if(L){let te=new Event(bl);L.dispatchEvent(te)}}}}},p.createElement("label",{"cmdk-label":"",htmlFor:j.inputId,id:j.labelId,style:mk},l),Js(e,_=>p.createElement(Up.Provider,{value:E},p.createElement(Hp.Provider,{value:j},_))))}),rk=p.forwardRef((e,t)=>{var n,r;let o=Pt(),s=p.useRef(null),i=p.useContext(Wp),a=Ao(),l=Kp(e),c=(r=(n=l.current)==null?void 0:n.forceMount)!=null?r:i==null?void 0:i.forceMount;ur(()=>{if(!c)return a.item(o,i==null?void 0:i.id)},[c]);let d=qp(o,s,[e.value,e.children,s],e.keywords),h=wl(),m=Gn(T=>T.value&&T.value===d.current),f=Gn(T=>c||a.filter()===!1?!0:T.search?T.filtered.items.get(o)>0:!0);p.useEffect(()=>{let T=s.current;if(!(!T||e.disabled))return T.addEventListener(bl,v),()=>T.removeEventListener(bl,v)},[f,e.onSelect,e.disabled]);function v(){var T,E;g(),(E=(T=l.current).onSelect)==null||E.call(T,d.current)}function g(){h.setState("value",d.current,!0)}if(!f)return null;let{disabled:x,value:y,onSelect:w,forceMount:S,keywords:k,...C}=e;return p.createElement(ge.div,{ref:On(s,t),...C,id:o,"cmdk-item":"",role:"option","aria-disabled":!!x,"aria-selected":!!m,"data-disabled":!!x,"data-selected":!!m,onPointerMove:x||a.getDisablePointerSelection()?void 0:g,onClick:x?void 0:v},e.children)}),ok=p.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:o,...s}=e,i=Pt(),a=p.useRef(null),l=p.useRef(null),c=Pt(),d=Ao(),h=Gn(f=>o||d.filter()===!1?!0:f.search?f.filtered.groups.has(i):!0);ur(()=>d.group(i),[]),qp(i,a,[e.value,e.heading,l]);let m=p.useMemo(()=>({id:i,forceMount:o}),[o]);return p.createElement(ge.div,{ref:On(a,t),...s,"cmdk-group":"",role:"presentation",hidden:h?void 0:!0},n&&p.createElement("div",{ref:l,"cmdk-group-heading":"","aria-hidden":!0,id:c},n),Js(e,f=>p.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?c:void 0},p.createElement(Wp.Provider,{value:m},f))))}),sk=p.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,o=p.useRef(null),s=Gn(i=>!i.search);return!n&&!s?null:p.createElement(ge.div,{ref:On(o,t),...r,"cmdk-separator":"",role:"separator"})}),ik=p.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,o=e.value!=null,s=wl(),i=Gn(c=>c.search),a=Gn(c=>c.selectedItemId),l=Ao();return p.useEffect(()=>{e.value!=null&&s.setState("search",e.value)},[e.value]),p.createElement(ge.input,{ref:t,...r,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":l.listId,"aria-labelledby":l.labelId,"aria-activedescendant":a,id:l.inputId,type:"text",value:o?e.value:i,onChange:c=>{o||s.setState("search",c.target.value),n==null||n(c.target.value)}})}),ak=p.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...o}=e,s=p.useRef(null),i=p.useRef(null),a=Gn(c=>c.selectedItemId),l=Ao();return p.useEffect(()=>{if(i.current&&s.current){let c=i.current,d=s.current,h,m=new ResizeObserver(()=>{h=requestAnimationFrame(()=>{let f=c.offsetHeight;d.style.setProperty("--cmdk-list-height",f.toFixed(1)+"px")})});return m.observe(c),()=>{cancelAnimationFrame(h),m.unobserve(c)}}},[]),p.createElement(ge.div,{ref:On(s,t),...o,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":a,"aria-label":r,id:l.listId},Js(e,c=>p.createElement("div",{ref:On(i,l.listInnerRef),"cmdk-list-sizer":""},c)))}),lk=p.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:o,contentClassName:s,container:i,...a}=e;return p.createElement(Za,{open:n,onOpenChange:r},p.createElement(Qa,{container:i},p.createElement(To,{"cmdk-overlay":"",className:o}),p.createElement(ko,{"aria-label":e.label,"cmdk-dialog":"",className:s},p.createElement(Vp,{ref:t,...a}))))}),ck=p.forwardRef((e,t)=>Gn(n=>n.filtered.count===0)?p.createElement(ge.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),uk=p.forwardRef((e,t)=>{let{progress:n,children:r,label:o="Loading...",...s}=e;return p.createElement(ge.div,{ref:t,...s,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":o},Js(e,i=>p.createElement("div",{"aria-hidden":!0},i)))}),Ut=Object.assign(Vp,{List:ak,Item:rk,Input:ik,Group:ok,Separator:sk,Dialog:lk,Empty:ck,Loading:uk});function dk(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function fk(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function Kp(e){let t=p.useRef(e);return ur(()=>{t.current=e}),t}var ur=typeof window>"u"?p.useEffect:p.useLayoutEffect;function Dr(e){let t=p.useRef();return t.current===void 0&&(t.current=e()),t}function Gn(e){let t=wl(),n=()=>e(t.snapshot());return p.useSyncExternalStore(t.subscribe,n,n)}function qp(e,t,n,r=[]){let o=p.useRef(),s=Ao();return ur(()=>{var i;let a=(()=>{var c;for(let d of n){if(typeof d=="string")return d.trim();if(typeof d=="object"&&"current"in d)return d.current?(c=d.current.textContent)==null?void 0:c.trim():o.current}})(),l=r.map(c=>c.trim());s.value(e,a,l),(i=t.current)==null||i.setAttribute(Or,a),o.current=a}),o}var hk=()=>{let[e,t]=p.useState(),n=Dr(()=>new Map);return ur(()=>{n.current.forEach(r=>r()),n.current=new Map},[e]),(r,o)=>{n.current.set(r,o),t({})}};function pk(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function Js({asChild:e,children:t},n){return e&&p.isValidElement(t)?p.cloneElement(pk(t),{ref:t.ref},n(t.props.children)):n(t)}var mk={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const yl=p.forwardRef(({className:e,...t},n)=>u.jsx(Ut,{ref:n,className:oe("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));yl.displayName=Ut.displayName;const Sl=p.forwardRef(({className:e,...t},n)=>u.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[u.jsx(ae.Search,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),u.jsx(Ut.Input,{ref:n,className:oe("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),...t})]}));Sl.displayName=Ut.Input.displayName;const Cl=p.forwardRef(({className:e,...t},n)=>u.jsx(Ut.List,{ref:n,className:oe("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));Cl.displayName=Ut.List.displayName;const Tl=p.forwardRef((e,t)=>u.jsx(Ut.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));Tl.displayName=Ut.Empty.displayName;const kl=p.forwardRef(({className:e,...t},n)=>u.jsx(Ut.Group,{ref:n,className:oe("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",e),...t}));kl.displayName=Ut.Group.displayName;const gk=p.forwardRef(({className:e,...t},n)=>u.jsx(Ut.Separator,{ref:n,className:oe("-mx-1 h-px bg-border",e),...t}));gk.displayName=Ut.Separator.displayName;const El=p.forwardRef(({className:e,...t},n)=>u.jsx(Ut.Item,{ref:n,className:oe("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected='true']:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50",e),...t}));El.displayName=Ut.Item.displayName;function Il(e,[t,n]){return Math.min(n,Math.max(t,e))}function xk(e,t){return p.useReducer((n,r)=>t[n][r]??n,e)}var Nl="ScrollArea",[Gp,MN]=ln(Nl),[vk,rn]=Gp(Nl),Yp=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,l]=p.useState(null),[c,d]=p.useState(null),[h,m]=p.useState(null),[f,v]=p.useState(null),[g,x]=p.useState(null),[y,w]=p.useState(0),[S,k]=p.useState(0),[C,T]=p.useState(!1),[E,j]=p.useState(!1),P=Oe(t,F=>l(F)),D=Jo(o);return u.jsx(vk,{scope:n,type:r,dir:D,scrollHideDelay:s,scrollArea:a,viewport:c,onViewportChange:d,content:h,onContentChange:m,scrollbarX:f,onScrollbarXChange:v,scrollbarXEnabled:C,onScrollbarXEnabledChange:T,scrollbarY:g,onScrollbarYChange:x,scrollbarYEnabled:E,onScrollbarYEnabledChange:j,onCornerWidthChange:w,onCornerHeightChange:k,children:u.jsx(ge.div,{dir:D,...i,ref:P,style:{position:"relative","--radix-scroll-area-corner-width":y+"px","--radix-scroll-area-corner-height":S+"px",...e.style}})})});Yp.displayName=Nl;var Xp="ScrollAreaViewport",Jp=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=rn(Xp,n),a=p.useRef(null),l=Oe(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(ge.div,{"data-radix-scroll-area-viewport":"",...s,ref:l,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:u.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});Jp.displayName=Xp;var En="ScrollAreaScrollbar",Al=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=rn(En,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:i}=o,a=e.orientation==="horizontal";return p.useEffect(()=>(a?s(!0):i(!0),()=>{a?s(!1):i(!1)}),[a,s,i]),o.type==="hover"?u.jsx(bk,{...r,ref:t,forceMount:n}):o.type==="scroll"?u.jsx(wk,{...r,ref:t,forceMount:n}):o.type==="auto"?u.jsx(Zp,{...r,ref:t,forceMount:n}):o.type==="always"?u.jsx(jl,{...r,ref:t}):null});Al.displayName=En;var bk=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=rn(En,e.__scopeScrollArea),[s,i]=p.useState(!1);return p.useEffect(()=>{const a=o.scrollArea;let l=0;if(a){const c=()=>{window.clearTimeout(l),i(!0)},d=()=>{l=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",c),a.addEventListener("pointerleave",d),()=>{window.clearTimeout(l),a.removeEventListener("pointerenter",c),a.removeEventListener("pointerleave",d)}}},[o.scrollArea,o.scrollHideDelay]),u.jsx(zt,{present:n||s,children:u.jsx(Zp,{"data-state":s?"visible":"hidden",...r,ref:t})})}),wk=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=rn(En,e.__scopeScrollArea),s=e.orientation==="horizontal",i=ti(()=>l("SCROLL_END"),100),[a,l]=xk("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return p.useEffect(()=>{if(a==="idle"){const c=window.setTimeout(()=>l("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(c)}},[a,o.scrollHideDelay,l]),p.useEffect(()=>{const c=o.viewport,d=s?"scrollLeft":"scrollTop";if(c){let h=c[d];const m=()=>{const f=c[d];h!==f&&(l("SCROLL"),i()),h=f};return c.addEventListener("scroll",m),()=>c.removeEventListener("scroll",m)}},[o.viewport,s,l,i]),u.jsx(zt,{present:n||a!=="hidden",children:u.jsx(jl,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:ie(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:ie(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),Zp=p.forwardRef((e,t)=>{const n=rn(En,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=p.useState(!1),a=e.orientation==="horizontal",l=ti(()=>{if(n.viewport){const c=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?c:d)}},10);return Lr(n.viewport,l),Lr(n.content,l),u.jsx(zt,{present:r||s,children:u.jsx(jl,{"data-state":s?"visible":"hidden",...o,ref:t})})}),jl=p.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=rn(En,e.__scopeScrollArea),s=p.useRef(null),i=p.useRef(0),[a,l]=p.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),c=rm(a.viewport,a.content),d={...r,sizes:a,onSizesChange:l,hasThumb:c>0&&c<1,onThumbChange:m=>s.current=m,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:m=>i.current=m};function h(m,f){return Ek(m,i.current,a,f)}return n==="horizontal"?u.jsx(yk,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollLeft,f=om(m,a,o.dir);s.current.style.transform=`translate3d(${f}px, 0, 0)`}},onWheelScroll:m=>{o.viewport&&(o.viewport.scrollLeft=m)},onDragScroll:m=>{o.viewport&&(o.viewport.scrollLeft=h(m,o.dir))}}):n==="vertical"?u.jsx(Sk,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollTop,f=om(m,a);s.current.style.transform=`translate3d(0, ${f}px, 0)`}},onWheelScroll:m=>{o.viewport&&(o.viewport.scrollTop=m)},onDragScroll:m=>{o.viewport&&(o.viewport.scrollTop=h(m))}}):null}),yk=p.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=rn(En,e.__scopeScrollArea),[i,a]=p.useState(),l=p.useRef(null),c=Oe(t,l,s.onScrollbarXChange);return p.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(em,{"data-orientation":"horizontal",...o,ref:c,sizes:n,style:{bottom:0,left:s.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:s.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":ei(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.x),onDragScroll:d=>e.onDragScroll(d.x),onWheelScroll:(d,h)=>{if(s.viewport){const m=s.viewport.scrollLeft+d.deltaX;e.onWheelScroll(m),im(m,h)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:l.current.clientWidth,paddingStart:Qs(i.paddingLeft),paddingEnd:Qs(i.paddingRight)}})}})}),Sk=p.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=rn(En,e.__scopeScrollArea),[i,a]=p.useState(),l=p.useRef(null),c=Oe(t,l,s.onScrollbarYChange);return p.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(em,{"data-orientation":"vertical",...o,ref:c,sizes:n,style:{top:0,right:s.dir==="ltr"?0:void 0,left:s.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":ei(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.y),onDragScroll:d=>e.onDragScroll(d.y),onWheelScroll:(d,h)=>{if(s.viewport){const m=s.viewport.scrollTop+d.deltaY;e.onWheelScroll(m),im(m,h)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:l.current.clientHeight,paddingStart:Qs(i.paddingTop),paddingEnd:Qs(i.paddingBottom)}})}})}),[Ck,Qp]=Gp(En),em=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:l,onDragScroll:c,onWheelScroll:d,onResize:h,...m}=e,f=rn(En,n),[v,g]=p.useState(null),x=Oe(t,P=>g(P)),y=p.useRef(null),w=p.useRef(""),S=f.viewport,k=r.content-r.viewport,C=ft(d),T=ft(l),E=ti(h,10);function j(P){if(y.current){const D=P.clientX-y.current.left,F=P.clientY-y.current.top;c({x:D,y:F})}}return p.useEffect(()=>{const P=D=>{const F=D.target;(v==null?void 0:v.contains(F))&&C(D,k)};return document.addEventListener("wheel",P,{passive:!1}),()=>document.removeEventListener("wheel",P,{passive:!1})},[S,v,k,C]),p.useEffect(T,[r,T]),Lr(v,E),Lr(f.content,E),u.jsx(Ck,{scope:n,scrollbar:v,hasThumb:o,onThumbChange:ft(s),onThumbPointerUp:ft(i),onThumbPositionChange:T,onThumbPointerDown:ft(a),children:u.jsx(ge.div,{...m,ref:x,style:{position:"absolute",...m.style},onPointerDown:ie(e.onPointerDown,P=>{P.button===0&&(P.target.setPointerCapture(P.pointerId),y.current=v.getBoundingClientRect(),w.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",f.viewport&&(f.viewport.style.scrollBehavior="auto"),j(P))}),onPointerMove:ie(e.onPointerMove,j),onPointerUp:ie(e.onPointerUp,P=>{const D=P.target;D.hasPointerCapture(P.pointerId)&&D.releasePointerCapture(P.pointerId),document.body.style.webkitUserSelect=w.current,f.viewport&&(f.viewport.style.scrollBehavior=""),y.current=null})})})}),Zs="ScrollAreaThumb",tm=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Qp(Zs,e.__scopeScrollArea);return u.jsx(zt,{present:n||o.hasThumb,children:u.jsx(Tk,{ref:t,...r})})}),Tk=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=rn(Zs,n),i=Qp(Zs,n),{onThumbPositionChange:a}=i,l=Oe(t,h=>i.onThumbChange(h)),c=p.useRef(void 0),d=ti(()=>{c.current&&(c.current(),c.current=void 0)},100);return p.useEffect(()=>{const h=s.viewport;if(h){const m=()=>{if(d(),!c.current){const f=Ik(h,a);c.current=f,a()}};return a(),h.addEventListener("scroll",m),()=>h.removeEventListener("scroll",m)}},[s.viewport,d,a]),u.jsx(ge.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:ie(e.onPointerDownCapture,h=>{const f=h.target.getBoundingClientRect(),v=h.clientX-f.left,g=h.clientY-f.top;i.onThumbPointerDown({x:v,y:g})}),onPointerUp:ie(e.onPointerUp,i.onThumbPointerUp)})});tm.displayName=Zs;var Pl="ScrollAreaCorner",nm=p.forwardRef((e,t)=>{const n=rn(Pl,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?u.jsx(kk,{...e,ref:t}):null});nm.displayName=Pl;var kk=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=rn(Pl,n),[s,i]=p.useState(0),[a,l]=p.useState(0),c=!!(s&&a);return Lr(o.scrollbarX,()=>{var h;const d=((h=o.scrollbarX)==null?void 0:h.offsetHeight)||0;o.onCornerHeightChange(d),l(d)}),Lr(o.scrollbarY,()=>{var h;const d=((h=o.scrollbarY)==null?void 0:h.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),c?u.jsx(ge.div,{...r,ref:t,style:{width:s,height:a,position:"absolute",right:o.dir==="ltr"?0:void 0,left:o.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function Qs(e){return e?parseInt(e,10):0}function rm(e,t){const n=e/t;return isNaN(n)?0:n}function ei(e){const t=rm(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function Ek(e,t,n,r="ltr"){const o=ei(n),s=o/2,i=t||s,a=o-i,l=n.scrollbar.paddingStart+i,c=n.scrollbar.size-n.scrollbar.paddingEnd-a,d=n.content-n.viewport,h=r==="ltr"?[0,d]:[d*-1,0];return sm([l,c],h)(e)}function om(e,t,n="ltr"){const r=ei(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,s=t.scrollbar.size-o,i=t.content-t.viewport,a=s-r,l=n==="ltr"?[0,i]:[i*-1,0],c=Il(e,l);return sm([0,i],[0,a])(c)}function sm(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function im(e,t){return e>0&&e<t}var Ik=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return function o(){const s={left:e.scrollLeft,top:e.scrollTop},i=n.left!==s.left,a=n.top!==s.top;(i||a)&&t(),n=s,r=window.requestAnimationFrame(o)}(),()=>window.cancelAnimationFrame(r)};function ti(e,t){const n=ft(e),r=p.useRef(0);return p.useEffect(()=>()=>window.clearTimeout(r.current),[]),p.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function Lr(e,t){const n=ft(t);Tt(()=>{let r=0;if(e){const o=new ResizeObserver(()=>{cancelAnimationFrame(r),r=window.requestAnimationFrame(n)});return o.observe(e),()=>{window.cancelAnimationFrame(r),o.unobserve(e)}}},[e,n])}var am=Yp,Nk=Jp,Ak=nm;const _l=p.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(am,{ref:r,className:oe("relative overflow-hidden",e),...n,children:[u.jsx(Nk,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),u.jsx(lm,{}),u.jsx(Ak,{})]}));_l.displayName=am.displayName;const lm=p.forwardRef(({className:e,orientation:t="vertical",...n},r)=>u.jsx(Al,{ref:r,orientation:t,className:oe("flex touch-none select-none transition-colors",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...n,children:u.jsx(tm,{className:"relative flex-1 rounded-full bg-border"})}));lm.displayName=Al.displayName;const Rl=p.forwardRef(({className:e,type:t,...n},r)=>u.jsx("input",{type:t,className:oe("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:r,...n}));Rl.displayName="Input";const jk="group relative p-3 rounded-lg cursor-pointer transition-colors border text-gray-900 dark:text-slate-100",Pk="bg-slate-700 border-slate-600 hover:bg-slate-600",_k="bg-slate-600 border-slate-500";function cm({thread:e,isActive:t,editingThreadId:n,editingTitle:r,onSelect:o,onStartEditing:s,onEditingTitleChange:i,onSaveEditing:a,onCancelEditing:l,onShare:c,onDelete:d,showEditTitle:h,showDeleteButton:m,formatDate:f,getDisplayThreadTitle:v,secondaryLine:g,itemClassName:x,activeItemClassName:y}){const w=n===e.threadId,S=t?`${y??_k}`:`${x??Pk}`,k=C=>{C.stopPropagation(),o(e.threadId)};return u.jsxs("div",{onClick:k,className:`${jk} ${S}`,children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("div",{className:"flex-1 min-w-0",children:w?u.jsxs("div",{className:"flex items-center gap-2",onClick:C=>C.stopPropagation(),children:[u.jsx(Rl,{value:r,onChange:C=>i(C.target.value),onKeyDown:C=>{C.key==="Enter"?a(e.threadId):C.key==="Escape"&&l()},className:"h-6 text-sm",autoFocus:!0}),u.jsx(Je,{variant:"ghost",size:"sm",onClick:()=>a(e.threadId),className:"h-6 w-6 p-0",children:u.jsx(ae.Check,{size:12})}),u.jsx(Je,{variant:"ghost",size:"sm",onClick:l,className:"h-6 w-6 p-0",children:u.jsx(ae.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(ae.Calendar,{size:10}),u.jsx("span",{children:f(e.updatedAt||e.createdAt)})]}),g&&u.jsx("div",{className:"text-[11px] text-muted-foreground mt-1",children:g})]})}),u.jsx("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2",children:u.jsxs(Cs,{children:[u.jsx(Ts,{asChild:!0,children:u.jsx(Je,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",children:u.jsx(ae.MoreHorizontal,{size:12})})}),u.jsxs(ho,{align:"end",sideOffset:6,className:"w-44",children:[u.jsxs(Bn,{onClick:C=>{C.preventDefault(),c(e.threadId)},children:[u.jsx(ae.Share2,{className:"mr-2 h-4 w-4"}),"Share thread"]}),h&&n!==e.threadId&&u.jsxs(Bn,{onClick:C=>{C.preventDefault(),s(e,C)},children:[u.jsx(ae.Edit3,{className:"mr-2 h-4 w-4"}),"Rename"]}),m&&d&&u.jsxs(Bn,{className:"text-red-400 hover:text-red-300",onClick:C=>{C.preventDefault(),d(e.threadId,C)},children:[u.jsx(ae.Trash2,{className:"mr-2 h-4 w-4"}),"Delete"]})]})]})})]}),t&&u.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-1 h-8 bg-blue-400 rounded-r"})]})}const um=25,dm="thread-manager-view",Rk=e=>e==="default"||e==="shared",Mk=()=>{if(typeof window>"u")return null;try{const e=window.localStorage.getItem(dm);if(Rk(e))return e}catch{}return null};function fm({defaultView:e}={}){const[t,n]=b.useState(()=>Mk()??e??"default");b.useEffect(()=>{if(!(typeof window>"u"))try{window.localStorage.setItem(dm,t)}catch{}},[t]);const r=b.useCallback(o=>{n(o)},[]);return{view:t,setView:r}}const Ok=[{key:"default",label:"My chats"},{key:"shared",label:"Shared with you"}];function ni({className:e="",showCreateButton:t=!0,showDeleteButton:n=!0,showEditTitle:r=!0,maxHeight:o="400px",customStyles:s={},currentThreadId:i=null,navigateToThread:a,onThreadSelect:l,onThreadCreate:c,onThreadDelete:d,view:h,defaultView:m,onViewChange:f,viewOptions:v,viewState:g,showHeader:x=!0,shareTargets:y,isLoadingShareTargets:w,shareTargetFilter:S}){const{threads:k,sharedThreads:C,currentThreadId:T,setCurrentThreadId:E,isLoading:j,isLoadingSharedThreads:P,actions:D,shareInFlight:F,shareStatus:W,clearShareStatus:G}=xr(),{createThread:A,deleteThread:X,renameThread:q,shareThread:B}=D,{loadThread:R}=eo(),I=i??T,[H,Y]=b.useState(Array.isArray(k)?k:[]),_=b.useRef(H.length>0),O=b.useRef(null),M=b.useRef(0),[L,te]=b.useState(null),[z,$]=b.useState(""),[ee,J]=b.useState(!1),[K,Q]=b.useState(!1),[pe,de]=b.useState(null),[me,we]=b.useState(""),Te=v&&v.length>0?v:Ok,Ne=fm({defaultView:m}),ke=g??Ne,st=h??ke.view,vt=b.useCallback(Z=>{h||ke.setView(Z),f==null||f(Z)},[h,f,ke]),pt=Te.find(Z=>Z.key===st)??Te[0],We=Z=>{de(Z),we(""),Q(!0)},Le=()=>{Q(!1),de(null),we(""),G()},Ge=b.useCallback(async Z=>{if(!(!pe||F)&&Z.id)try{await B(pe,Z.id),setTimeout(()=>Le(),600)}catch(ce){console.error("Failed to share thread:",ce)}},[Le,F,pe,B]),Re=b.useMemo(()=>{const Z=y??[],ce=me.trim().toLowerCase();return ce?S?Z.filter(He=>S(He,ce)):Z.filter(He=>`${He.label} ${He.secondaryLabel??""}`.toLowerCase().includes(ce)):Z},[y,me,S]),$e=st==="shared",Ze=$e?C:H,It=$e?P:j,it=$e?"No shared conversations yet":"No conversations yet",yt=Z=>{const ce=Z.sharedAt?` • ${Fe(Z.sharedAt)}`:"";return`Shared by ${Z.sharedByUserId}${ce}`},St=Z=>"sharedByUserId"in Z;b.useEffect(()=>{const Z=Array.isArray(k)?k:[];if(Z.length>0){_.current=!0,Y(Z);return}j||(_.current=!1,Y(Z))},[k,j]),b.useEffect(()=>{if(!O.current)return;const Z=O.current.querySelector("[data-radix-scroll-area-viewport]");if(!Z)return;let ce=null,He=null;return ce=requestAnimationFrame(()=>{He=requestAnimationFrame(()=>{Z.scrollTop=M.current})}),()=>{ce!==null&&cancelAnimationFrame(ce),He!==null&&cancelAnimationFrame(He)}},[H]);const Ct=async Z=>{try{E(Z),await R(Z),a==null||a(Z),l==null||l(Z)}catch(ce){console.error("Failed to select thread:",ce)}},kt=async()=>{try{J(!0);const Z=await A();Z&&(c==null||c(Z),a==null||a(Z))}catch(Z){console.error("Failed to create thread:",Z)}finally{J(!1)}},on=async(Z,ce)=>{if(ce.stopPropagation(),!!confirm("Delete this thread?")){if(O.current){const He=O.current.querySelector("[data-radix-scroll-area-viewport]");He&&(M.current=He.scrollTop)}try{await X(Z),d==null||d(Z)}catch(He){console.error("Failed to delete thread:",He)}}},Nt=(Z,ce)=>{ce.stopPropagation(),te(Z.threadId),$(Z.title||`Thread ${Z.threadId.slice(0,8)}`)},Vt=async Z=>{if(z.trim())try{await q(Z,z.trim()),te(null),$("")}catch(ce){console.error("Failed to update title:",ce)}},Et=()=>{te(null),$("")},Fe=Z=>{if(!Z)return"";try{const ce=new Date(Z),ve=new Date().getTime()-ce.getTime(),he=Math.floor(ve/(1e3*60*60*24));return he===0?ce.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):he===1?"Yesterday":he<7?`${he} days ago`:ce.toLocaleDateString()}catch{return""}},Ve=Z=>Z.title||`Thread ${Z.threadId.slice(0,8)}`,At=Z=>{const ce=Ve(Z);return ce.length<=um?ce:`${ce.slice(0,um)}...`};return u.jsxs("div",{className:`flex flex-col h-full ${e} ${s.container||""}`,children:[x&&u.jsxs("div",{className:s.header||"flex flex-col gap-2 px-1 py-0 border border-slate-200 bg-white dark:border-slate-700 dark:bg-slate-900 shadow-sm",children:[t&&u.jsx("div",{className:"flex justify-end",children:u.jsxs(Je,{onClick:kt,disabled:ee||j,className:s.createButton||"px-3 py-2 gap-1",size:"sm",variant:"ghost",title:ee?"Creating...":"New Chat",children:[u.jsx(ae.Edit3,{size:16}),u.jsx("span",{children:"New chat"})]})}),u.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-slate-700 dark:text-slate-200 uppercase tracking-wide leading-tight",children:[u.jsx("span",{children:"Current View"}),u.jsxs(Cs,{children:[u.jsx(Ts,{asChild:!0,children:u.jsx(Je,{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:pt.label})}),u.jsx(ho,{align:"start",sideOffset:6,className:"w-40",children:Te.map(Z=>u.jsxs(Bn,{className:"justify-between text-[12px]",onClick:ce=>{ce.preventDefault(),vt(Z.key)},children:[u.jsx("span",{children:Z.label}),st===Z.key&&u.jsx(ae.Check,{className:"h-3 w-3"})]},Z.key))})]})]})]}),u.jsx(_l,{ref:O,className:`flex-1 min-h-0 ${s.threadList||""}`,style:o?{maxHeight:o}:void 0,children:u.jsx("div",{className:"p-2 space-y-1 pb-4",children:It?u.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-8 text-slate-400",children:[u.jsx(ae.Loader2,{className:"h-5 w-5 animate-spin"}),u.jsx("span",{className:"text-sm",children:"Loading threads…"})]}):Ze.length===0?u.jsxs("div",{className:"text-center py-8 text-slate-400",children:[u.jsx(ae.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:it})]}):Ze.slice().sort((Z,ce)=>new Date(ce.updatedAt||ce.createdAt||"").getTime()-new Date(Z.updatedAt||Z.createdAt||"").getTime()).map(Z=>u.jsx(cm,{thread:Z,isActive:I===Z.threadId,editingThreadId:L,editingTitle:z,onSelect:Ct,onStartEditing:Nt,onEditingTitleChange:ce=>$(ce),onSaveEditing:Vt,onCancelEditing:Et,onShare:()=>We(Z.threadId),onDelete:on,showEditTitle:r,showDeleteButton:n,formatDate:Fe,getDisplayThreadTitle:At,secondaryLine:$e&&St(Z)?yt(Z):void 0,itemClassName:s.threadItem,activeItemClassName:s.activeThread},Z.threadId))})}),u.jsx(el,{open:K,onOpenChange:Z=>!Z&&Le(),children:u.jsxs(zs,{className:"max-w-md p-0",children:[u.jsx(Hs,{children:u.jsx(Us,{children:"Share thread"})}),u.jsxs(yl,{children:[u.jsx(Sl,{autoFocus:!0,value:me,onValueChange:Z=>we(Z),placeholder:"Search for recipients..."}),u.jsxs(Cl,{children:[W&&u.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-xs text-muted-foreground",children:[F&&u.jsx(ae.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(Tl,{children:w?u.jsxs("span",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(ae.Loader2,{className:"h-4 w-4 animate-spin"}),"Loading recipients…"]}):"No matching recipients found"}),Re.length>0&&u.jsx(kl,{heading:"Recipients",children:Re.map(Z=>u.jsx(El,{onSelect:()=>Ge(Z),children:u.jsxs("div",{className:"flex flex-col items-start text-sm",children:[u.jsx("span",{className:"font-medium",children:Z.label}),Z.secondaryLabel&&u.jsx("span",{className:"text-xs text-muted-foreground",children:Z.secondaryLabel})]})},Z.id))})]})]})]})})]})}function Dk({layout:e="sidebar",layoutSize:t="desktop",showThreads:n=!0,className:r="",customStyles:o={},...s}){const i=c=>{const d="h-full";switch(c){case"phone":return`${d} max-w-none`;case"tablet":return`${d} max-w-4xl mx-auto`;case"half-screen":return`${d} max-w-2xl`;case"desktop":default:return`${d} max-w-7xl mx-auto`}},a=c=>({"--chat-sidebar-width":c==="phone"?"100%":c==="tablet"?"280px":c==="half-screen"?"240px":"320px","--chat-message-max-width":c==="phone"?"95%":c==="tablet"?"90%":c==="half-screen"?"85%":"80%","--chat-input-height":c==="phone"?"120px":"100px"}),l=b.useCallback(c=>{var d;(d=s.onThreadChange)==null||d.call(s,c)},[s]);return e==="fullscreen"?u.jsx(br,{...s,onThreadChange:l,children:u.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:u.jsx(Mr,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?u.jsx(br,{...s,onThreadChange:l,children:u.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:u.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[n&&u.jsx("div",{className:`w-80 border-r flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:u.jsx(ni,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),u.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:u.jsx(Mr,{onError:s.onError,enableFileUpload:!0})})]})})}):u.jsx(br,{...s,onThreadChange:l,children:u.jsxs("div",{className:`${i(t)} flex overflow-hidden ${r} ${o.container||""}`,style:a(t),children:[n&&u.jsx("div",{className:`w-80 border-r bg-gray-50 flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:u.jsx(ni,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),u.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:u.jsx(Mr,{onError:s.onError,enableFileUpload:!0})})]})})}function Lk({apiConfig:e,className:t="",onError:n}){return u.jsx(br,{apiConfig:e,onError:n,children:u.jsx("div",{className:`h-full ${t}`,children:u.jsx(Mr,{})})})}function $k({placeholder:e,onMessageSent:t}){const[n,r]=b.useState("chat");return u.jsxs("div",{className:"flex flex-col h-full",children:[u.jsxs("div",{className:"flex border-b border-gray-200 bg-gray-50",children:[u.jsx("button",{onClick:()=>r("chat"),className:`flex-1 px-3 py-2 text-sm font-medium transition-colors ${n==="chat"?"border-b-2 border-slate-800 text-slate-800 bg-white":"text-gray-600 hover:text-gray-800"}`,children:u.jsxs("div",{className:"flex items-center justify-center gap-2",children:[u.jsx(ae.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(ae.History,{size:14}),"History"]})})]}),u.jsx("div",{className:"flex-1 min-h-0",children:n==="chat"?u.jsx(Mr,{placeholder:e??"Ask Serti AI anything...",autoFocus:!0,className:"h-full",onMessageSent:t}):u.jsx(ni,{showCreateButton:!0,className:"h-full",onThreadSelect:()=>r("chat")})})]})}function Fk({className:e="",placeholder:t,isAuthenticated:n=!0,onMessageSent:r,widgetTitle:o="Serti AI Navigator",widgetSubtitle:s="AI-Powered Assistant",...i}){const[a,l]=b.useState(!1);return n?u.jsx(br,{...i,children:u.jsx("div",{className:`fixed bottom-6 right-6 z-[9999] transition-all duration-300 ${e}`,children:u.jsxs("div",{className:`w-96 bg-white rounded-xl shadow-2xl border border-gray-200 overflow-hidden relative ${a?"scale-75":"scale-100"}`,children:[u.jsx("div",{className:"bg-slate-800 text-white p-4 flex-shrink-0",children:u.jsxs("div",{className:"flex items-center justify-between gap-3",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsxs("div",{className:"relative h-10 w-10 rounded-full bg-gradient-to-br from-slate-500 to-slate-700 border border-white/30 flex items-center justify-center text-white text-sm font-bold",children:["S",u.jsx("span",{className:"absolute -bottom-0.5 -right-0.5 h-3 w-3 rounded-full border-2 border-slate-800 bg-emerald-400"})]}),u.jsxs("div",{className:"flex flex-col",children:[u.jsx("h3",{className:"text-lg font-semibold leading-tight",children:o}),u.jsx("p",{className:"text-xs text-white/70",children:s})]}),u.jsx("span",{className:"ml-2 inline-flex items-center justify-center rounded-full bg-red-500 px-2 py-0.5 text-[11px] font-semibold leading-none text-white",children:"1"})]}),u.jsxs("div",{className:"flex items-center gap-1",children:[u.jsx(Je,{variant:"ghost",size:"sm",className:"text-white hover:bg-white/10 h-8 w-8 p-0",title:"Options",children:u.jsx(ae.MoreHorizontal,{size:16})}),u.jsx(Je,{variant:"ghost",size:"sm",className:"text-white hover:bg-white/10 h-8 w-8 p-0",title:"Compose",children:u.jsx(ae.Edit3,{size:16})}),u.jsx(Je,{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(ae.Maximize2,{size:14}):u.jsx(ae.Minimize2,{size:14})})]})]})}),!a&&u.jsx("div",{className:"h-96 flex flex-col",children:u.jsx($k,{placeholder:t,onMessageSent:r})})]})})}):null}function Bk({label:e="New chat",children:t,className:n,variant:r="ghost",size:o="sm",...s}){return u.jsxs(Je,{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(ae.Edit3,{size:16}),t??e]})}var zk="Label",hm=p.forwardRef((e,t)=>u.jsx(ge.label,{...e,ref:t,onMouseDown:n=>{var o;n.target.closest("button, input, select, textarea")||((o=e.onMouseDown)==null||o.call(e,n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));hm.displayName=zk;var pm=hm;const Hk=zr.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),mm=p.forwardRef(({className:e,...t},n)=>u.jsx(pm,{ref:n,className:oe(Hk(),e),...t}));mm.displayName=pm.displayName;function gm(e){const t=p.useRef({value:e,previous:e});return p.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var xm=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),Uk="VisuallyHidden",ri=p.forwardRef((e,t)=>u.jsx(ge.span,{...e,ref:t,style:{...xm,...e.style}}));ri.displayName=Uk;var Wk=ri,Vk=[" ","Enter","ArrowUp","ArrowDown"],Kk=[" ","Enter"],dr="Select",[oi,si,qk]=Xo(dr),[$r,ON]=ln(dr,[qk,Er]),ii=Er(),[Gk,Yn]=$r(dr),[Yk,Xk]=$r(dr),vm=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:l,dir:c,name:d,autoComplete:h,disabled:m,required:f,form:v}=e,g=ii(t),[x,y]=p.useState(null),[w,S]=p.useState(null),[k,C]=p.useState(!1),T=Jo(c),[E,j]=Dn({prop:r,defaultProp:o??!1,onChange:s,caller:dr}),[P,D]=Dn({prop:i,defaultProp:a,onChange:l,caller:dr}),F=p.useRef(null),W=x?v||!!x.closest("form"):!0,[G,A]=p.useState(new Set),X=Array.from(G).map(q=>q.props.value).join(";");return u.jsx(sa,{...g,children:u.jsxs(Gk,{required:f,scope:t,trigger:x,onTriggerChange:y,valueNode:w,onValueNodeChange:S,valueNodeHasChildren:k,onValueNodeHasChildrenChange:C,contentId:Pt(),value:P,onValueChange:D,open:E,onOpenChange:j,dir:T,triggerPointerDownPosRef:F,disabled:m,children:[u.jsx(oi.Provider,{scope:t,children:u.jsx(Yk,{scope:e.__scopeSelect,onNativeOptionAdd:p.useCallback(q=>{A(B=>new Set(B).add(q))},[]),onNativeOptionRemove:p.useCallback(q=>{A(B=>{const R=new Set(B);return R.delete(q),R})},[]),children:n})}),W?u.jsxs(Hm,{"aria-hidden":!0,required:f,tabIndex:-1,name:d,autoComplete:h,value:P,onChange:q=>D(q.target.value),disabled:m,form:v,children:[P===void 0?u.jsx("option",{value:""}):null,Array.from(G)]},X):null]})})};vm.displayName=dr;var bm="SelectTrigger",wm=p.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=ii(n),i=Yn(bm,n),a=i.disabled||r,l=Oe(t,i.onTriggerChange),c=si(n),d=p.useRef("touch"),[h,m,f]=Wm(g=>{const x=c().filter(S=>!S.disabled),y=x.find(S=>S.value===i.value),w=Vm(x,g,y);w!==void 0&&i.onValueChange(w.value)}),v=g=>{a||(i.onOpenChange(!0),f()),g&&(i.triggerPointerDownPosRef.current={x:Math.round(g.pageX),y:Math.round(g.pageY)})};return u.jsx(ia,{asChild:!0,...s,children:u.jsx(ge.button,{type:"button",role:"combobox","aria-controls":i.contentId,"aria-expanded":i.open,"aria-required":i.required,"aria-autocomplete":"none",dir:i.dir,"data-state":i.open?"open":"closed",disabled:a,"data-disabled":a?"":void 0,"data-placeholder":Um(i.value)?"":void 0,...o,ref:l,onClick:ie(o.onClick,g=>{g.currentTarget.focus(),d.current!=="mouse"&&v(g)}),onPointerDown:ie(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:ie(o.onKeyDown,g=>{const x=h.current!=="";!(g.ctrlKey||g.altKey||g.metaKey)&&g.key.length===1&&m(g.key),!(x&&g.key===" ")&&Vk.includes(g.key)&&(v(),g.preventDefault())})})})});wm.displayName=bm;var ym="SelectValue",Sm=p.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=Yn(ym,n),{onValueNodeHasChildrenChange:c}=l,d=s!==void 0,h=Oe(t,l.onValueNodeChange);return Tt(()=>{c(d)},[c,d]),u.jsx(ge.span,{...a,ref:h,style:{pointerEvents:"none"},children:Um(l.value)?u.jsx(u.Fragment,{children:i}):s})});Sm.displayName=ym;var Jk="SelectIcon",Cm=p.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return u.jsx(ge.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});Cm.displayName=Jk;var Zk="SelectPortal",Tm=e=>u.jsx(so,{asChild:!0,...e});Tm.displayName=Zk;var fr="SelectContent",km=p.forwardRef((e,t)=>{const n=Yn(fr,e.__scopeSelect),[r,o]=p.useState();if(Tt(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?Hr.createPortal(u.jsx(Em,{scope:e.__scopeSelect,children:u.jsx(oi.Slot,{scope:e.__scopeSelect,children:u.jsx("div",{children:e.children})})}),s):null}return u.jsx(Im,{...e,ref:t})});km.displayName=fr;var pn=10,[Em,Xn]=$r(fr),Qk="SelectContentImpl",eE=qt.createSlot("SelectContent.RemoveScroll"),Im=p.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:h,collisionBoundary:m,collisionPadding:f,sticky:v,hideWhenDetached:g,avoidCollisions:x,...y}=e,w=Yn(fr,n),[S,k]=p.useState(null),[C,T]=p.useState(null),E=Oe(t,z=>k(z)),[j,P]=p.useState(null),[D,F]=p.useState(null),W=si(n),[G,A]=p.useState(!1),X=p.useRef(!1);p.useEffect(()=>{if(S)return fa(S)},[S]),Ui();const q=p.useCallback(z=>{const[$,...ee]=W().map(Q=>Q.ref.current),[J]=ee.slice(-1),K=document.activeElement;for(const Q of z)if(Q===K||(Q==null||Q.scrollIntoView({block:"nearest"}),Q===$&&C&&(C.scrollTop=0),Q===J&&C&&(C.scrollTop=C.scrollHeight),Q==null||Q.focus(),document.activeElement!==K))return},[W,C]),B=p.useCallback(()=>q([j,S]),[q,j,S]);p.useEffect(()=>{G&&B()},[G,B]);const{onOpenChange:R,triggerPointerDownPosRef:I}=w;p.useEffect(()=>{if(S){let z={x:0,y:0};const $=J=>{var K,Q;z={x:Math.abs(Math.round(J.pageX)-(((K=I.current)==null?void 0:K.x)??0)),y:Math.abs(Math.round(J.pageY)-(((Q=I.current)==null?void 0:Q.y)??0))}},ee=J=>{z.x<=10&&z.y<=10?J.preventDefault():S.contains(J.target)||R(!1),document.removeEventListener("pointermove",$),I.current=null};return I.current!==null&&(document.addEventListener("pointermove",$),document.addEventListener("pointerup",ee,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",$),document.removeEventListener("pointerup",ee,{capture:!0})}}},[S,R,I]),p.useEffect(()=>{const z=()=>R(!1);return window.addEventListener("blur",z),window.addEventListener("resize",z),()=>{window.removeEventListener("blur",z),window.removeEventListener("resize",z)}},[R]);const[H,Y]=Wm(z=>{const $=W().filter(K=>!K.disabled),ee=$.find(K=>K.ref.current===document.activeElement),J=Vm($,z,ee);J&&setTimeout(()=>J.ref.current.focus())}),_=p.useCallback((z,$,ee)=>{const J=!X.current&&!ee;(w.value!==void 0&&w.value===$||J)&&(P(z),J&&(X.current=!0))},[w.value]),O=p.useCallback(()=>S==null?void 0:S.focus(),[S]),M=p.useCallback((z,$,ee)=>{const J=!X.current&&!ee;(w.value!==void 0&&w.value===$||J)&&F(z)},[w.value]),L=r==="popper"?Ml:Nm,te=L===Ml?{side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:h,collisionBoundary:m,collisionPadding:f,sticky:v,hideWhenDetached:g,avoidCollisions:x}:{};return u.jsx(Em,{scope:n,content:S,viewport:C,onViewportChange:T,itemRefCallback:_,selectedItem:j,onItemLeave:O,itemTextRefCallback:M,focusSelectedItem:B,selectedItemText:D,position:r,isPositioned:G,searchRef:H,children:u.jsx(xs,{as:eE,allowPinchZoom:!0,children:u.jsx(Zo,{asChild:!0,trapped:w.open,onMountAutoFocus:z=>{z.preventDefault()},onUnmountAutoFocus:ie(o,z=>{var $;($=w.trigger)==null||$.focus({preventScroll:!0}),z.preventDefault()}),children:u.jsx(yr,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:z=>z.preventDefault(),onDismiss:()=>w.onOpenChange(!1),children:u.jsx(L,{role:"listbox",id:w.contentId,"data-state":w.open?"open":"closed",dir:w.dir,onContextMenu:z=>z.preventDefault(),...y,...te,onPlaced:()=>A(!0),ref:E,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:ie(y.onKeyDown,z=>{const $=z.ctrlKey||z.altKey||z.metaKey;if(z.key==="Tab"&&z.preventDefault(),!$&&z.key.length===1&&Y(z.key),["ArrowUp","ArrowDown","Home","End"].includes(z.key)){let J=W().filter(K=>!K.disabled).map(K=>K.ref.current);if(["ArrowUp","End"].includes(z.key)&&(J=J.slice().reverse()),["ArrowUp","ArrowDown"].includes(z.key)){const K=z.target,Q=J.indexOf(K);J=J.slice(Q+1)}setTimeout(()=>q(J)),z.preventDefault()}})})})})})})});Im.displayName=Qk;var tE="SelectItemAlignedPosition",Nm=p.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=Yn(fr,n),i=Xn(fr,n),[a,l]=p.useState(null),[c,d]=p.useState(null),h=Oe(t,E=>d(E)),m=si(n),f=p.useRef(!1),v=p.useRef(!0),{viewport:g,selectedItem:x,selectedItemText:y,focusSelectedItem:w}=i,S=p.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&c&&g&&x&&y){const E=s.trigger.getBoundingClientRect(),j=c.getBoundingClientRect(),P=s.valueNode.getBoundingClientRect(),D=y.getBoundingClientRect();if(s.dir!=="rtl"){const K=D.left-j.left,Q=P.left-K,pe=E.left-Q,de=E.width+pe,me=Math.max(de,j.width),we=window.innerWidth-pn,Te=Il(Q,[pn,Math.max(pn,we-me)]);a.style.minWidth=de+"px",a.style.left=Te+"px"}else{const K=j.right-D.right,Q=window.innerWidth-P.right-K,pe=window.innerWidth-E.right-Q,de=E.width+pe,me=Math.max(de,j.width),we=window.innerWidth-pn,Te=Il(Q,[pn,Math.max(pn,we-me)]);a.style.minWidth=de+"px",a.style.right=Te+"px"}const F=m(),W=window.innerHeight-pn*2,G=g.scrollHeight,A=window.getComputedStyle(c),X=parseInt(A.borderTopWidth,10),q=parseInt(A.paddingTop,10),B=parseInt(A.borderBottomWidth,10),R=parseInt(A.paddingBottom,10),I=X+q+G+R+B,H=Math.min(x.offsetHeight*5,I),Y=window.getComputedStyle(g),_=parseInt(Y.paddingTop,10),O=parseInt(Y.paddingBottom,10),M=E.top+E.height/2-pn,L=W-M,te=x.offsetHeight/2,z=x.offsetTop+te,$=X+q+z,ee=I-$;if($<=M){const K=F.length>0&&x===F[F.length-1].ref.current;a.style.bottom="0px";const Q=c.clientHeight-g.offsetTop-g.offsetHeight,pe=Math.max(L,te+(K?O:0)+Q+B),de=$+pe;a.style.height=de+"px"}else{const K=F.length>0&&x===F[0].ref.current;a.style.top="0px";const pe=Math.max(M,X+g.offsetTop+(K?_:0)+te)+ee;a.style.height=pe+"px",g.scrollTop=$-M+g.offsetTop}a.style.margin=`${pn}px 0`,a.style.minHeight=H+"px",a.style.maxHeight=W+"px",r==null||r(),requestAnimationFrame(()=>f.current=!0)}},[m,s.trigger,s.valueNode,a,c,g,x,y,s.dir,r]);Tt(()=>S(),[S]);const[k,C]=p.useState();Tt(()=>{c&&C(window.getComputedStyle(c).zIndex)},[c]);const T=p.useCallback(E=>{E&&v.current===!0&&(S(),w==null||w(),v.current=!1)},[S,w]);return u.jsx(rE,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:f,onScrollButtonChange:T,children:u.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:k},children:u.jsx(ge.div,{...o,ref:h,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Nm.displayName=tE;var nE="SelectPopperPosition",Ml=p.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=pn,...s}=e,i=ii(n);return u.jsx(aa,{...i,...s,ref:t,align:r,collisionPadding:o,style:{boxSizing:"border-box",...s.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});Ml.displayName=nE;var[rE,Ol]=$r(fr,{}),Dl="SelectViewport",Am=p.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=Xn(Dl,n),i=Ol(Dl,n),a=Oe(t,s.onViewportChange),l=p.useRef(0);return u.jsxs(u.Fragment,{children:[u.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),u.jsx(oi.Slot,{scope:n,children:u.jsx(ge.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:ie(o.onScroll,c=>{const d=c.currentTarget,{contentWrapper:h,shouldExpandOnScrollRef:m}=i;if(m!=null&&m.current&&h){const f=Math.abs(l.current-d.scrollTop);if(f>0){const v=window.innerHeight-pn*2,g=parseFloat(h.style.minHeight),x=parseFloat(h.style.height),y=Math.max(g,x);if(y<v){const w=y+f,S=Math.min(v,w),k=w-S;h.style.height=S+"px",h.style.bottom==="0px"&&(d.scrollTop=k>0?k:0,h.style.justifyContent="flex-end")}}}l.current=d.scrollTop})})})]})});Am.displayName=Dl;var jm="SelectGroup",[oE,sE]=$r(jm),iE=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Pt();return u.jsx(oE,{scope:n,id:o,children:u.jsx(ge.div,{role:"group","aria-labelledby":o,...r,ref:t})})});iE.displayName=jm;var Pm="SelectLabel",_m=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=sE(Pm,n);return u.jsx(ge.div,{id:o.id,...r,ref:t})});_m.displayName=Pm;var ai="SelectItem",[aE,Rm]=$r(ai),Mm=p.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=Yn(ai,n),l=Xn(ai,n),c=a.value===r,[d,h]=p.useState(s??""),[m,f]=p.useState(!1),v=Oe(t,w=>{var S;return(S=l.itemRefCallback)==null?void 0:S.call(l,w,r,o)}),g=Pt(),x=p.useRef("touch"),y=()=>{o||(a.onValueChange(r),a.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return u.jsx(aE,{scope:n,value:r,disabled:o,textId:g,isSelected:c,onItemTextChange:p.useCallback(w=>{h(S=>S||((w==null?void 0:w.textContent)??"").trim())},[]),children:u.jsx(oi.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:u.jsx(ge.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:ie(i.onFocus,()=>f(!0)),onBlur:ie(i.onBlur,()=>f(!1)),onClick:ie(i.onClick,()=>{x.current!=="mouse"&&y()}),onPointerUp:ie(i.onPointerUp,()=>{x.current==="mouse"&&y()}),onPointerDown:ie(i.onPointerDown,w=>{x.current=w.pointerType}),onPointerMove:ie(i.onPointerMove,w=>{var S;x.current=w.pointerType,o?(S=l.onItemLeave)==null||S.call(l):x.current==="mouse"&&w.currentTarget.focus({preventScroll:!0})}),onPointerLeave:ie(i.onPointerLeave,w=>{var S;w.currentTarget===document.activeElement&&((S=l.onItemLeave)==null||S.call(l))}),onKeyDown:ie(i.onKeyDown,w=>{var k;((k=l.searchRef)==null?void 0:k.current)!==""&&w.key===" "||(Kk.includes(w.key)&&y(),w.key===" "&&w.preventDefault())})})})})});Mm.displayName=ai;var jo="SelectItemText",Om=p.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=Yn(jo,n),a=Xn(jo,n),l=Rm(jo,n),c=Xk(jo,n),[d,h]=p.useState(null),m=Oe(t,y=>h(y),l.onItemTextChange,y=>{var w;return(w=a.itemTextRefCallback)==null?void 0:w.call(a,y,l.value,l.disabled)}),f=d==null?void 0:d.textContent,v=p.useMemo(()=>u.jsx("option",{value:l.value,disabled:l.disabled,children:f},l.value),[l.disabled,l.value,f]),{onNativeOptionAdd:g,onNativeOptionRemove:x}=c;return Tt(()=>(g(v),()=>x(v)),[g,x,v]),u.jsxs(u.Fragment,{children:[u.jsx(ge.span,{id:l.textId,...s,ref:m}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?Hr.createPortal(s.children,i.valueNode):null]})});Om.displayName=jo;var Dm="SelectItemIndicator",Lm=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return Rm(Dm,n).isSelected?u.jsx(ge.span,{"aria-hidden":!0,...r,ref:t}):null});Lm.displayName=Dm;var Ll="SelectScrollUpButton",$m=p.forwardRef((e,t)=>{const n=Xn(Ll,e.__scopeSelect),r=Ol(Ll,e.__scopeSelect),[o,s]=p.useState(!1),i=Oe(t,r.onScrollButtonChange);return Tt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const c=l.scrollTop>0;s(c)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?u.jsx(Bm,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});$m.displayName=Ll;var $l="SelectScrollDownButton",Fm=p.forwardRef((e,t)=>{const n=Xn($l,e.__scopeSelect),r=Ol($l,e.__scopeSelect),[o,s]=p.useState(!1),i=Oe(t,r.onScrollButtonChange);return Tt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const c=l.scrollHeight-l.clientHeight,d=Math.ceil(l.scrollTop)<c;s(d)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?u.jsx(Bm,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});Fm.displayName=$l;var Bm=p.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=Xn("SelectScrollButton",n),i=p.useRef(null),a=si(n),l=p.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return p.useEffect(()=>()=>l(),[l]),Tt(()=>{var d;const c=a().find(h=>h.ref.current===document.activeElement);(d=c==null?void 0:c.ref.current)==null||d.scrollIntoView({block:"nearest"})},[a]),u.jsx(ge.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:ie(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:ie(o.onPointerMove,()=>{var c;(c=s.onItemLeave)==null||c.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:ie(o.onPointerLeave,()=>{l()})})}),lE="SelectSeparator",zm=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return u.jsx(ge.div,{"aria-hidden":!0,...r,ref:t})});zm.displayName=lE;var Fl="SelectArrow",cE=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=ii(n),s=Yn(Fl,n),i=Xn(Fl,n);return s.open&&i.position==="popper"?u.jsx(la,{...o,...r,ref:t}):null});cE.displayName=Fl;var uE="SelectBubbleInput",Hm=p.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=p.useRef(null),s=Oe(r,o),i=gm(t);return p.useEffect(()=>{const a=o.current;if(!a)return;const l=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(l,"value").set;if(i!==t&&d){const h=new Event("change",{bubbles:!0});d.call(a,t),a.dispatchEvent(h)}},[i,t]),u.jsx(ge.select,{...n,style:{...xm,...n.style},ref:s,defaultValue:t})});Hm.displayName=uE;function Um(e){return e===""||e===void 0}function Wm(e){const t=ft(e),n=p.useRef(""),r=p.useRef(0),o=p.useCallback(i=>{const a=n.current+i;t(a),function l(c){n.current=c,window.clearTimeout(r.current),c!==""&&(r.current=window.setTimeout(()=>l(""),1e3))}(a)},[t]),s=p.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return p.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function Vm(e,t,n){const o=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=dE(e,Math.max(s,0));o.length===1&&(i=i.filter(c=>c!==n));const l=i.find(c=>c.textValue.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function dE(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var fE=vm,Km=wm,hE=Sm,pE=Cm,mE=Tm,qm=km,gE=Am,Gm=_m,Ym=Mm,xE=Om,vE=Lm,Xm=$m,Jm=Fm,Zm=zm;const bE=fE,wE=hE,Qm=p.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Km,{ref:r,className:oe("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[t,u.jsx(pE,{asChild:!0,children:u.jsx(ae.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));Qm.displayName=Km.displayName;const eg=p.forwardRef(({className:e,...t},n)=>u.jsx(Xm,{ref:n,className:oe("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(ae.ChevronUp,{className:"h-4 w-4"})}));eg.displayName=Xm.displayName;const tg=p.forwardRef(({className:e,...t},n)=>u.jsx(Jm,{ref:n,className:oe("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(ae.ChevronDown,{className:"h-4 w-4"})}));tg.displayName=Jm.displayName;const ng=p.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>u.jsx(mE,{children:u.jsxs(qm,{ref:o,className:oe("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...r,children:[u.jsx(eg,{}),u.jsx(gE,{className:oe("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),u.jsx(tg,{})]})}));ng.displayName=qm.displayName;const yE=p.forwardRef(({className:e,...t},n)=>u.jsx(Gm,{ref:n,className:oe("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));yE.displayName=Gm.displayName;const rg=p.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Ym,{ref:r,className:oe("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[u.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx(vE,{children:u.jsx(ae.Check,{className:"h-4 w-4"})})}),u.jsx(xE,{children:t})]}));rg.displayName=Ym.displayName;const SE=p.forwardRef(({className:e,...t},n)=>u.jsx(Zm,{ref:n,className:oe("-mx-1 my-1 h-px bg-muted",e),...t}));SE.displayName=Zm.displayName;var CE="Separator",og="horizontal",TE=["horizontal","vertical"],sg=p.forwardRef((e,t)=>{const{decorative:n,orientation:r=og,...o}=e,s=kE(r)?r:og,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return u.jsx(ge.div,{"data-orientation":s,...a,...o,ref:t})});sg.displayName=CE;function kE(e){return TE.includes(e)}var ig=sg;const ag=p.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>u.jsx(ig,{ref:o,decorative:n,orientation:t,className:oe("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));ag.displayName=ig.displayName;var li="Switch",[EE,DN]=ln(li),[IE,NE]=EE(li),lg=p.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:s,required:i,disabled:a,value:l="on",onCheckedChange:c,form:d,...h}=e,[m,f]=p.useState(null),v=Oe(t,S=>f(S)),g=p.useRef(!1),x=m?d||!!m.closest("form"):!0,[y,w]=Dn({prop:o,defaultProp:s??!1,onChange:c,caller:li});return u.jsxs(IE,{scope:n,checked:y,disabled:a,children:[u.jsx(ge.button,{type:"button",role:"switch","aria-checked":y,"aria-required":i,"data-state":fg(y),"data-disabled":a?"":void 0,disabled:a,value:l,...h,ref:v,onClick:ie(e.onClick,S=>{w(k=>!k),x&&(g.current=S.isPropagationStopped(),g.current||S.stopPropagation())})}),x&&u.jsx(dg,{control:m,bubbles:!g.current,name:r,value:l,checked:y,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});lg.displayName=li;var cg="SwitchThumb",ug=p.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=NE(cg,n);return u.jsx(ge.span,{"data-state":fg(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});ug.displayName=cg;var AE="SwitchBubbleInput",dg=p.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=p.useRef(null),a=Oe(i,s),l=gm(n),c=bd(t);return p.useEffect(()=>{const d=i.current;if(!d)return;const h=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(h,"checked").set;if(l!==n&&f){const v=new Event("click",{bubbles:r});f.call(d,n),d.dispatchEvent(v)}},[l,n,r]),u.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:a,style:{...o.style,...c,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});dg.displayName=AE;function fg(e){return e?"checked":"unchecked"}var hg=lg,jE=ug;const pg=p.forwardRef(({className:e,...t},n)=>u.jsx(hg,{className:oe("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...t,ref:n,children:u.jsx(jE,{className:oe("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));pg.displayName=hg.displayName;const PE=Za,_E=dT,RE=Qa,mg=p.forwardRef(({className:e,...t},n)=>u.jsx(To,{className:oe("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t,ref:n}));mg.displayName=To.displayName;const ME=zr.cva("fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),gg=p.forwardRef(({side:e="right",className:t,children:n,...r},o)=>u.jsxs(RE,{children:[u.jsx(mg,{}),u.jsxs(ko,{ref:o,className:oe(ME({side:e}),t),...r,children:[n,u.jsxs(sp,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary",children:[u.jsx(ae.X,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));gg.displayName=ko.displayName;const xg=({className:e,...t})=>u.jsx("div",{className:oe("flex flex-col space-y-2 text-center sm:text-left",e),...t});xg.displayName="SheetHeader";const vg=p.forwardRef(({className:e,...t},n)=>u.jsx(lr,{ref:n,className:oe("text-lg font-semibold text-foreground",e),...t}));vg.displayName=lr.displayName;const bg=p.forwardRef(({className:e,...t},n)=>u.jsx(Bs,{ref:n,className:oe("text-sm text-muted-foreground",e),...t}));bg.displayName=Bs.displayName;var[ci,LN]=ln("Tooltip",[Er]),ui=Er(),wg="TooltipProvider",OE=700,Bl="tooltip.open",[DE,zl]=ci(wg),yg=e=>{const{__scopeTooltip:t,delayDuration:n=OE,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:s}=e,i=p.useRef(!0),a=p.useRef(!1),l=p.useRef(0);return p.useEffect(()=>{const c=l.current;return()=>window.clearTimeout(c)},[]),u.jsx(DE,{scope:t,isOpenDelayedRef:i,delayDuration:n,onOpen:p.useCallback(()=>{window.clearTimeout(l.current),i.current=!1},[]),onClose:p.useCallback(()=>{window.clearTimeout(l.current),l.current=window.setTimeout(()=>i.current=!0,r)},[r]),isPointerInTransitRef:a,onPointerInTransitChange:p.useCallback(c=>{a.current=c},[]),disableHoverableContent:o,children:s})};yg.displayName=wg;var Po="Tooltip",[LE,di]=ci(Po),Sg=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:s,disableHoverableContent:i,delayDuration:a}=e,l=zl(Po,e.__scopeTooltip),c=ui(t),[d,h]=p.useState(null),m=Pt(),f=p.useRef(0),v=i??l.disableHoverableContent,g=a??l.delayDuration,x=p.useRef(!1),[y,w]=Dn({prop:r,defaultProp:o??!1,onChange:E=>{E?(l.onOpen(),document.dispatchEvent(new CustomEvent(Bl))):l.onClose(),s==null||s(E)},caller:Po}),S=p.useMemo(()=>y?x.current?"delayed-open":"instant-open":"closed",[y]),k=p.useCallback(()=>{window.clearTimeout(f.current),f.current=0,x.current=!1,w(!0)},[w]),C=p.useCallback(()=>{window.clearTimeout(f.current),f.current=0,w(!1)},[w]),T=p.useCallback(()=>{window.clearTimeout(f.current),f.current=window.setTimeout(()=>{x.current=!0,w(!0),f.current=0},g)},[g,w]);return p.useEffect(()=>()=>{f.current&&(window.clearTimeout(f.current),f.current=0)},[]),u.jsx(sa,{...c,children:u.jsx(LE,{scope:t,contentId:m,open:y,stateAttribute:S,trigger:d,onTriggerChange:h,onTriggerEnter:p.useCallback(()=>{l.isOpenDelayedRef.current?T():k()},[l.isOpenDelayedRef,T,k]),onTriggerLeave:p.useCallback(()=>{v?C():(window.clearTimeout(f.current),f.current=0)},[C,v]),onOpen:k,onClose:C,disableHoverableContent:v,children:n})})};Sg.displayName=Po;var Hl="TooltipTrigger",Cg=p.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=di(Hl,n),s=zl(Hl,n),i=ui(n),a=p.useRef(null),l=Oe(t,a,o.onTriggerChange),c=p.useRef(!1),d=p.useRef(!1),h=p.useCallback(()=>c.current=!1,[]);return p.useEffect(()=>()=>document.removeEventListener("pointerup",h),[h]),u.jsx(ia,{asChild:!0,...i,children:u.jsx(ge.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:l,onPointerMove:ie(e.onPointerMove,m=>{m.pointerType!=="touch"&&!d.current&&!s.isPointerInTransitRef.current&&(o.onTriggerEnter(),d.current=!0)}),onPointerLeave:ie(e.onPointerLeave,()=>{o.onTriggerLeave(),d.current=!1}),onPointerDown:ie(e.onPointerDown,()=>{o.open&&o.onClose(),c.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:ie(e.onFocus,()=>{c.current||o.onOpen()}),onBlur:ie(e.onBlur,o.onClose),onClick:ie(e.onClick,o.onClose)})})});Cg.displayName=Hl;var $E="TooltipPortal",[$N,FE]=ci($E,{forceMount:void 0}),Fr="TooltipContent",Tg=p.forwardRef((e,t)=>{const n=FE(Fr,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...s}=e,i=di(Fr,e.__scopeTooltip);return u.jsx(zt,{present:r||i.open,children:i.disableHoverableContent?u.jsx(kg,{side:o,...s,ref:t}):u.jsx(BE,{side:o,...s,ref:t})})}),BE=p.forwardRef((e,t)=>{const n=di(Fr,e.__scopeTooltip),r=zl(Fr,e.__scopeTooltip),o=p.useRef(null),s=Oe(t,o),[i,a]=p.useState(null),{trigger:l,onClose:c}=n,d=o.current,{onPointerInTransitChange:h}=r,m=p.useCallback(()=>{a(null),h(!1)},[h]),f=p.useCallback((v,g)=>{const x=v.currentTarget,y={x:v.clientX,y:v.clientY},w=VE(y,x.getBoundingClientRect()),S=KE(y,w),k=qE(g.getBoundingClientRect()),C=YE([...S,...k]);a(C),h(!0)},[h]);return p.useEffect(()=>()=>m(),[m]),p.useEffect(()=>{if(l&&d){const v=x=>f(x,d),g=x=>f(x,l);return l.addEventListener("pointerleave",v),d.addEventListener("pointerleave",g),()=>{l.removeEventListener("pointerleave",v),d.removeEventListener("pointerleave",g)}}},[l,d,f,m]),p.useEffect(()=>{if(i){const v=g=>{const x=g.target,y={x:g.clientX,y:g.clientY},w=(l==null?void 0:l.contains(x))||(d==null?void 0:d.contains(x)),S=!GE(y,i);w?m():S&&(m(),c())};return document.addEventListener("pointermove",v),()=>document.removeEventListener("pointermove",v)}},[l,d,i,c,m]),u.jsx(kg,{...e,ref:s})}),[zE,HE]=ci(Po,{isInside:!1}),UE=qt.createSlottable("TooltipContent"),kg=p.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:s,onPointerDownOutside:i,...a}=e,l=di(Fr,n),c=ui(n),{onClose:d}=l;return p.useEffect(()=>(document.addEventListener(Bl,d),()=>document.removeEventListener(Bl,d)),[d]),p.useEffect(()=>{if(l.trigger){const h=m=>{const f=m.target;f!=null&&f.contains(l.trigger)&&d()};return window.addEventListener("scroll",h,{capture:!0}),()=>window.removeEventListener("scroll",h,{capture:!0})}},[l.trigger,d]),u.jsx(yr,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:h=>h.preventDefault(),onDismiss:d,children:u.jsxs(aa,{"data-state":l.stateAttribute,...c,...a,ref:t,style:{...a.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[u.jsx(UE,{children:r}),u.jsx(zE,{scope:n,isInside:!0,children:u.jsx(Wk,{id:l.contentId,role:"tooltip",children:o||r})})]})})});Tg.displayName=Fr;var Eg="TooltipArrow",WE=p.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=ui(n);return HE(Eg,n).isInside?null:u.jsx(la,{...o,...r,ref:t})});WE.displayName=Eg;function VE(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),o=Math.abs(t.right-e.x),s=Math.abs(t.left-e.x);switch(Math.min(n,r,o,s)){case s:return"left";case o:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function KE(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function qE(e){const{top:t,right:n,bottom:r,left:o}=e;return[{x:o,y:t},{x:n,y:t},{x:n,y:r},{x:o,y:r}]}function GE(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const a=t[s],l=t[i],c=a.x,d=a.y,h=l.x,m=l.y;d>r!=m>r&&n<(h-c)*(r-d)/(m-d)+c&&(o=!o)}return o}function YE(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),XE(t)}function XE(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const o=e[r];for(;t.length>=2;){const s=t[t.length-1],i=t[t.length-2];if((s.x-i.x)*(o.y-i.y)>=(s.y-i.y)*(o.x-i.x))t.pop();else break}t.push(o)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const o=e[r];for(;n.length>=2;){const s=n[n.length-1],i=n[n.length-2];if((s.x-i.x)*(o.y-i.y)>=(s.y-i.y)*(o.x-i.x))n.pop();else break}n.push(o)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var JE=yg,ZE=Sg,QE=Cg,Ig=Tg;const eI=JE,tI=ZE,nI=QE,Ng=p.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(Ig,{ref:r,sideOffset:t,className:oe("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n}));Ng.displayName=Ig.displayName;var Ul="ToastProvider",[Wl,rI,oI]=Xo("Toast"),[Ag,FN]=ln("Toast",[oI]),[sI,fi]=Ag(Ul),jg=e=>{const{__scopeToast:t,label:n="Notification",duration:r=5e3,swipeDirection:o="right",swipeThreshold:s=50,children:i}=e,[a,l]=p.useState(null),[c,d]=p.useState(0),h=p.useRef(!1),m=p.useRef(!1);return n.trim()||console.error(`Invalid prop \`label\` supplied to \`${Ul}\`. Expected non-empty \`string\`.`),u.jsx(Wl.Provider,{scope:t,children:u.jsx(sI,{scope:t,label:n,duration:r,swipeDirection:o,swipeThreshold:s,toastCount:c,viewport:a,onViewportChange:l,onToastAdd:p.useCallback(()=>d(f=>f+1),[]),onToastRemove:p.useCallback(()=>d(f=>f-1),[]),isFocusedToastEscapeKeyDownRef:h,isClosePausedRef:m,children:i})})};jg.displayName=Ul;var Pg="ToastViewport",iI=["F8"],Vl="toast.viewportPause",Kl="toast.viewportResume",_g=p.forwardRef((e,t)=>{const{__scopeToast:n,hotkey:r=iI,label:o="Notifications ({hotkey})",...s}=e,i=fi(Pg,n),a=rI(n),l=p.useRef(null),c=p.useRef(null),d=p.useRef(null),h=p.useRef(null),m=Oe(t,h,i.onViewportChange),f=r.join("+").replace(/Key/g,"").replace(/Digit/g,""),v=i.toastCount>0;p.useEffect(()=>{const x=y=>{var S;r.length!==0&&r.every(k=>y[k]||y.code===k)&&((S=h.current)==null||S.focus())};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[r]),p.useEffect(()=>{const x=l.current,y=h.current;if(v&&x&&y){const w=()=>{if(!i.isClosePausedRef.current){const T=new CustomEvent(Vl);y.dispatchEvent(T),i.isClosePausedRef.current=!0}},S=()=>{if(i.isClosePausedRef.current){const T=new CustomEvent(Kl);y.dispatchEvent(T),i.isClosePausedRef.current=!1}},k=T=>{!x.contains(T.relatedTarget)&&S()},C=()=>{x.contains(document.activeElement)||S()};return x.addEventListener("focusin",w),x.addEventListener("focusout",k),x.addEventListener("pointermove",w),x.addEventListener("pointerleave",C),window.addEventListener("blur",w),window.addEventListener("focus",S),()=>{x.removeEventListener("focusin",w),x.removeEventListener("focusout",k),x.removeEventListener("pointermove",w),x.removeEventListener("pointerleave",C),window.removeEventListener("blur",w),window.removeEventListener("focus",S)}}},[v,i.isClosePausedRef]);const g=p.useCallback(({tabbingDirection:x})=>{const w=a().map(S=>{const k=S.ref.current,C=[k,...bI(k)];return x==="forwards"?C:C.reverse()});return(x==="forwards"?w.reverse():w).flat()},[a]);return p.useEffect(()=>{const x=h.current;if(x){const y=w=>{var C,T,E;const S=w.altKey||w.ctrlKey||w.metaKey;if(w.key==="Tab"&&!S){const j=document.activeElement,P=w.shiftKey;if(w.target===x&&P){(C=c.current)==null||C.focus();return}const W=g({tabbingDirection:P?"backwards":"forwards"}),G=W.findIndex(A=>A===j);Yl(W.slice(G+1))?w.preventDefault():P?(T=c.current)==null||T.focus():(E=d.current)==null||E.focus()}};return x.addEventListener("keydown",y),()=>x.removeEventListener("keydown",y)}},[a,g]),u.jsxs(Fb,{ref:l,role:"region","aria-label":o.replace("{hotkey}",f),tabIndex:-1,style:{pointerEvents:v?void 0:"none"},children:[v&&u.jsx(ql,{ref:c,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"forwards"});Yl(x)}}),u.jsx(Wl.Slot,{scope:n,children:u.jsx(ge.ol,{tabIndex:-1,...s,ref:m})}),v&&u.jsx(ql,{ref:d,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"backwards"});Yl(x)}})]})});_g.displayName=Pg;var Rg="ToastFocusProxy",ql=p.forwardRef((e,t)=>{const{__scopeToast:n,onFocusFromOutsideViewport:r,...o}=e,s=fi(Rg,n);return u.jsx(ri,{tabIndex:0,...o,ref:t,style:{position:"fixed"},onFocus:i=>{var c;const a=i.relatedTarget;!((c=s.viewport)!=null&&c.contains(a))&&r()}})});ql.displayName=Rg;var _o="Toast",aI="toast.swipeStart",lI="toast.swipeMove",cI="toast.swipeCancel",uI="toast.swipeEnd",Mg=p.forwardRef((e,t)=>{const{forceMount:n,open:r,defaultOpen:o,onOpenChange:s,...i}=e,[a,l]=Dn({prop:r,defaultProp:o??!0,onChange:s,caller:_o});return u.jsx(zt,{present:n||a,children:u.jsx(hI,{open:a,...i,ref:t,onClose:()=>l(!1),onPause:ft(e.onPause),onResume:ft(e.onResume),onSwipeStart:ie(e.onSwipeStart,c=>{c.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:ie(e.onSwipeMove,c=>{const{x:d,y:h}=c.detail.delta;c.currentTarget.setAttribute("data-swipe","move"),c.currentTarget.style.setProperty("--radix-toast-swipe-move-x",`${d}px`),c.currentTarget.style.setProperty("--radix-toast-swipe-move-y",`${h}px`)}),onSwipeCancel:ie(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:ie(e.onSwipeEnd,c=>{const{x:d,y:h}=c.detail.delta;c.currentTarget.setAttribute("data-swipe","end"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),c.currentTarget.style.setProperty("--radix-toast-swipe-end-x",`${d}px`),c.currentTarget.style.setProperty("--radix-toast-swipe-end-y",`${h}px`),l(!1)})})})});Mg.displayName=_o;var[dI,fI]=Ag(_o,{onClose(){}}),hI=p.forwardRef((e,t)=>{const{__scopeToast:n,type:r="foreground",duration:o,open:s,onClose:i,onEscapeKeyDown:a,onPause:l,onResume:c,onSwipeStart:d,onSwipeMove:h,onSwipeCancel:m,onSwipeEnd:f,...v}=e,g=fi(_o,n),[x,y]=p.useState(null),w=Oe(t,A=>y(A)),S=p.useRef(null),k=p.useRef(null),C=o||g.duration,T=p.useRef(0),E=p.useRef(C),j=p.useRef(0),{onToastAdd:P,onToastRemove:D}=g,F=ft(()=>{var X;(x==null?void 0:x.contains(document.activeElement))&&((X=g.viewport)==null||X.focus()),i()}),W=p.useCallback(A=>{!A||A===1/0||(window.clearTimeout(j.current),T.current=new Date().getTime(),j.current=window.setTimeout(F,A))},[F]);p.useEffect(()=>{const A=g.viewport;if(A){const X=()=>{W(E.current),c==null||c()},q=()=>{const B=new Date().getTime()-T.current;E.current=E.current-B,window.clearTimeout(j.current),l==null||l()};return A.addEventListener(Vl,q),A.addEventListener(Kl,X),()=>{A.removeEventListener(Vl,q),A.removeEventListener(Kl,X)}}},[g.viewport,C,l,c,W]),p.useEffect(()=>{s&&!g.isClosePausedRef.current&&W(C)},[s,C,g.isClosePausedRef,W]),p.useEffect(()=>(P(),()=>D()),[P,D]);const G=p.useMemo(()=>x?zg(x):null,[x]);return g.viewport?u.jsxs(u.Fragment,{children:[G&&u.jsx(pI,{__scopeToast:n,role:"status","aria-live":r==="foreground"?"assertive":"polite",children:G}),u.jsx(dI,{scope:n,onClose:F,children:Hr.createPortal(u.jsx(Wl.ItemSlot,{scope:n,children:u.jsx($b,{asChild:!0,onEscapeKeyDown:ie(a,()=>{g.isFocusedToastEscapeKeyDownRef.current||F(),g.isFocusedToastEscapeKeyDownRef.current=!1}),children:u.jsx(ge.li,{tabIndex:0,"data-state":s?"open":"closed","data-swipe-direction":g.swipeDirection,...v,ref:w,style:{userSelect:"none",touchAction:"none",...e.style},onKeyDown:ie(e.onKeyDown,A=>{A.key==="Escape"&&(a==null||a(A.nativeEvent),A.nativeEvent.defaultPrevented||(g.isFocusedToastEscapeKeyDownRef.current=!0,F()))}),onPointerDown:ie(e.onPointerDown,A=>{A.button===0&&(S.current={x:A.clientX,y:A.clientY})}),onPointerMove:ie(e.onPointerMove,A=>{if(!S.current)return;const X=A.clientX-S.current.x,q=A.clientY-S.current.y,B=!!k.current,R=["left","right"].includes(g.swipeDirection),I=["left","up"].includes(g.swipeDirection)?Math.min:Math.max,H=R?I(0,X):0,Y=R?0:I(0,q),_=A.pointerType==="touch"?10:2,O={x:H,y:Y},M={originalEvent:A,delta:O};B?(k.current=O,hi(lI,h,M,{discrete:!1})):Hg(O,g.swipeDirection,_)?(k.current=O,hi(aI,d,M,{discrete:!1}),A.target.setPointerCapture(A.pointerId)):(Math.abs(X)>_||Math.abs(q)>_)&&(S.current=null)}),onPointerUp:ie(e.onPointerUp,A=>{const X=k.current,q=A.target;if(q.hasPointerCapture(A.pointerId)&&q.releasePointerCapture(A.pointerId),k.current=null,S.current=null,X){const B=A.currentTarget,R={originalEvent:A,delta:X};Hg(X,g.swipeDirection,g.swipeThreshold)?hi(uI,f,R,{discrete:!0}):hi(cI,m,R,{discrete:!0}),B.addEventListener("click",I=>I.preventDefault(),{once:!0})}})})})}),g.viewport)})]}):null}),pI=e=>{const{__scopeToast:t,children:n,...r}=e,o=fi(_o,t),[s,i]=p.useState(!1),[a,l]=p.useState(!1);return xI(()=>i(!0)),p.useEffect(()=>{const c=window.setTimeout(()=>l(!0),1e3);return()=>window.clearTimeout(c)},[]),a?null:u.jsx(so,{asChild:!0,children:u.jsx(ri,{...r,children:s&&u.jsxs(u.Fragment,{children:[o.label," ",n]})})})},mI="ToastTitle",Og=p.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(ge.div,{...r,ref:t})});Og.displayName=mI;var gI="ToastDescription",Dg=p.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(ge.div,{...r,ref:t})});Dg.displayName=gI;var Lg="ToastAction",$g=p.forwardRef((e,t)=>{const{altText:n,...r}=e;return n.trim()?u.jsx(Bg,{altText:n,asChild:!0,children:u.jsx(Gl,{...r,ref:t})}):(console.error(`Invalid prop \`altText\` supplied to \`${Lg}\`. Expected non-empty \`string\`.`),null)});$g.displayName=Lg;var Fg="ToastClose",Gl=p.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e,o=fI(Fg,n);return u.jsx(Bg,{asChild:!0,children:u.jsx(ge.button,{type:"button",...r,ref:t,onClick:ie(e.onClick,o.onClose)})})});Gl.displayName=Fg;var Bg=p.forwardRef((e,t)=>{const{__scopeToast:n,altText:r,...o}=e;return u.jsx(ge.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":r||void 0,...o,ref:t})});function zg(e){const t=[];return Array.from(e.childNodes).forEach(r=>{if(r.nodeType===r.TEXT_NODE&&r.textContent&&t.push(r.textContent),vI(r)){const o=r.ariaHidden||r.hidden||r.style.display==="none",s=r.dataset.radixToastAnnounceExclude==="";if(!o)if(s){const i=r.dataset.radixToastAnnounceAlt;i&&t.push(i)}else t.push(...zg(r))}}),t}function hi(e,t,n,{discrete:r}){const o=n.originalEvent.currentTarget,s=new CustomEvent(e,{bubbles:!0,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?Bi(o,s):o.dispatchEvent(s)}var Hg=(e,t,n=0)=>{const r=Math.abs(e.x),o=Math.abs(e.y),s=r>o;return t==="left"||t==="right"?s&&r>n:!s&&o>n};function xI(e=()=>{}){const t=ft(e);Tt(()=>{let n=0,r=0;return n=window.requestAnimationFrame(()=>r=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(n),window.cancelAnimationFrame(r)}},[t])}function vI(e){return e.nodeType===e.ELEMENT_NODE}function bI(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function Yl(e){const t=document.activeElement;return e.some(n=>n===t?!0:(n.focus(),document.activeElement!==t))}var wI=jg,Ug=_g,Wg=Mg,Vg=Og,Kg=Dg,qg=$g,Gg=Gl;const yI=wI,Yg=p.forwardRef(({className:e,...t},n)=>u.jsx(Ug,{ref:n,className:oe("fixed bottom-0 right-0 z-[100] flex max-h-screen w-full flex-col p-4 md:max-w-[420px]",e),...t}));Yg.displayName=Ug.displayName;const SI=zr.cva("group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-8 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",{variants:{variant:{default:"border bg-background text-foreground",destructive:"destructive group border-destructive bg-destructive text-destructive-foreground"}},defaultVariants:{variant:"default"}}),Xg=p.forwardRef(({className:e,variant:t,...n},r)=>u.jsx(Wg,{ref:r,className:oe(SI({variant:t}),e),...n}));Xg.displayName=Wg.displayName;const CI=p.forwardRef(({className:e,...t},n)=>u.jsx(qg,{ref:n,className:oe("inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors hover:bg-secondary focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive",e),...t}));CI.displayName=qg.displayName;const Jg=p.forwardRef(({className:e,...t},n)=>u.jsx(Gg,{ref:n,className:oe("absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-2 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",e),"toast-close":"",...t,children:u.jsx(ae.X,{className:"h-4 w-4"})}));Jg.displayName=Gg.displayName;const Zg=p.forwardRef(({className:e,...t},n)=>u.jsx(Vg,{ref:n,className:oe("text-sm font-semibold",e),...t}));Zg.displayName=Vg.displayName;const Qg=p.forwardRef(({className:e,...t},n)=>u.jsx(Kg,{ref:n,className:oe("text-sm opacity-90",e),...t}));Qg.displayName=Kg.displayName;function TI(){const{toasts:e}=rl();return u.jsxs(yI,{children:[e.map(function({id:t,title:n,description:r,action:o,...s}){return u.jsxs(Xg,{...s,children:[u.jsxs("div",{className:"grid gap-1",children:[n&&u.jsx(Zg,{children:n}),r&&u.jsx(Qg,{children:r})]}),o,u.jsx(Jg,{})]},t)}),u.jsx(Yg,{})]})}var kI=(e,t,n,r,o,s,i,a)=>{let l=document.documentElement,c=["light","dark"];function d(f){(Array.isArray(e)?e:[e]).forEach(v=>{let g=v==="class",x=g&&s?o.map(y=>s[y]||y):o;g?(l.classList.remove(...x),l.classList.add(s&&s[f]?s[f]:f)):l.setAttribute(v,f)}),h(f)}function h(f){a&&c.includes(f)&&(l.style.colorScheme=f)}function m(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}if(r)d(r);else try{let f=localStorage.getItem(t)||n,v=i&&f==="system"?m():f;d(v)}catch{}},EI=p.createContext(void 0),II={setTheme:e=>{},themes:[]},NI=()=>{var e;return(e=p.useContext(EI))!=null?e:II};p.memo(({forcedTheme:e,storageKey:t,attribute:n,enableSystem:r,enableColorScheme:o,defaultTheme:s,value:i,themes:a,nonce:l,scriptProps:c})=>{let d=JSON.stringify([n,t,s,e,a,i,r,o]).slice(1,-1);return p.createElement("script",{...c,suppressHydrationWarning:!0,nonce:typeof window>"u"?l:"",dangerouslySetInnerHTML:{__html:`(${kI.toString()})(${d})`}})});var AI=e=>{switch(e){case"success":return _I;case"info":return MI;case"warning":return RI;case"error":return OI;default:return null}},jI=Array(12).fill(0),PI=({visible:e,className:t})=>b.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},b.createElement("div",{className:"sonner-spinner"},jI.map((n,r)=>b.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),_I=b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},b.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),RI=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"})),MI=b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},b.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),OI=b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},b.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),DI=b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},b.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),b.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),LI=()=>{let[e,t]=b.useState(document.hidden);return b.useEffect(()=>{let n=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),e},Xl=1,$I=class{constructor(){this.subscribe=e=>(this.subscribers.push(e),()=>{let t=this.subscribers.indexOf(e);this.subscribers.splice(t,1)}),this.publish=e=>{this.subscribers.forEach(t=>t(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e]},this.create=e=>{var t;let{message:n,...r}=e,o=typeof(e==null?void 0:e.id)=="number"||((t=e.id)==null?void 0:t.length)>0?e.id:Xl++,s=this.toasts.find(a=>a.id===o),i=e.dismissible===void 0?!0:e.dismissible;return this.dismissedToasts.has(o)&&this.dismissedToasts.delete(o),s?this.toasts=this.toasts.map(a=>a.id===o?(this.publish({...a,...e,id:o,title:n}),{...a,...e,id:o,dismissible:i,title:n}):a):this.addToast({title:n,...r,dismissible:i,id:o}),o},this.dismiss=e=>(this.dismissedToasts.add(e),e||this.toasts.forEach(t=>{this.subscribers.forEach(n=>n({id:t.id,dismiss:!0}))}),this.subscribers.forEach(t=>t({id:e,dismiss:!0})),e),this.message=(e,t)=>this.create({...t,message:e}),this.error=(e,t)=>this.create({...t,message:e,type:"error"}),this.success=(e,t)=>this.create({...t,type:"success",message:e}),this.info=(e,t)=>this.create({...t,type:"info",message:e}),this.warning=(e,t)=>this.create({...t,type:"warning",message:e}),this.loading=(e,t)=>this.create({...t,type:"loading",message:e}),this.promise=(e,t)=>{if(!t)return;let n;t.loading!==void 0&&(n=this.create({...t,promise:e,type:"loading",message:t.loading,description:typeof t.description!="function"?t.description:void 0}));let r=e instanceof Promise?e:e(),o=n!==void 0,s,i=r.then(async l=>{if(s=["resolve",l],b.isValidElement(l))o=!1,this.create({id:n,type:"default",message:l});else if(BI(l)&&!l.ok){o=!1;let c=typeof t.error=="function"?await t.error(`HTTP error! status: ${l.status}`):t.error,d=typeof t.description=="function"?await t.description(`HTTP error! status: ${l.status}`):t.description;this.create({id:n,type:"error",message:c,description:d})}else if(t.success!==void 0){o=!1;let c=typeof t.success=="function"?await t.success(l):t.success,d=typeof t.description=="function"?await t.description(l):t.description;this.create({id:n,type:"success",message:c,description:d})}}).catch(async l=>{if(s=["reject",l],t.error!==void 0){o=!1;let c=typeof t.error=="function"?await t.error(l):t.error,d=typeof t.description=="function"?await t.description(l):t.description;this.create({id:n,type:"error",message:c,description:d})}}).finally(()=>{var l;o&&(this.dismiss(n),n=void 0),(l=t.finally)==null||l.call(t)}),a=()=>new Promise((l,c)=>i.then(()=>s[0]==="reject"?c(s[1]):l(s[1])).catch(c));return typeof n!="string"&&typeof n!="number"?{unwrap:a}:Object.assign(n,{unwrap:a})},this.custom=(e,t)=>{let n=(t==null?void 0:t.id)||Xl++;return this.create({jsx:e(n),id:n,...t}),n},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},Wt=new $I,FI=(e,t)=>{let n=(t==null?void 0:t.id)||Xl++;return Wt.addToast({title:e,...t,id:n}),n},BI=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",zI=FI,HI=()=>Wt.toasts,UI=()=>Wt.getActiveToasts();Object.assign(zI,{success:Wt.success,info:Wt.info,warning:Wt.warning,error:Wt.error,custom:Wt.custom,message:Wt.message,promise:Wt.promise,dismiss:Wt.dismiss,loading:Wt.loading},{getHistory:HI,getToasts:UI});function WI(e,{insertAt:t}={}){if(typeof document>"u")return;let n=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",t==="top"&&n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r),r.styleSheet?r.styleSheet.cssText=e:r.appendChild(document.createTextNode(e))}WI(`:where(html[dir="ltr"]),:where([data-sonner-toaster][dir="ltr"]){--toast-icon-margin-start: -3px;--toast-icon-margin-end: 4px;--toast-svg-margin-start: -1px;--toast-svg-margin-end: 0px;--toast-button-margin-start: auto;--toast-button-margin-end: 0;--toast-close-button-start: 0;--toast-close-button-end: unset;--toast-close-button-transform: translate(-35%, -35%)}:where(html[dir="rtl"]),:where([data-sonner-toaster][dir="rtl"]){--toast-icon-margin-start: 4px;--toast-icon-margin-end: -3px;--toast-svg-margin-start: 0px;--toast-svg-margin-end: -1px;--toast-button-margin-start: 0;--toast-button-margin-end: auto;--toast-close-button-start: unset;--toast-close-button-end: 0;--toast-close-button-transform: translate(35%, -35%)}:where([data-sonner-toaster]){position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1: hsl(0, 0%, 99%);--gray2: hsl(0, 0%, 97.3%);--gray3: hsl(0, 0%, 95.1%);--gray4: hsl(0, 0%, 93%);--gray5: hsl(0, 0%, 90.9%);--gray6: hsl(0, 0%, 88.7%);--gray7: hsl(0, 0%, 85.8%);--gray8: hsl(0, 0%, 78%);--gray9: hsl(0, 0%, 56.1%);--gray10: hsl(0, 0%, 52.3%);--gray11: hsl(0, 0%, 43.5%);--gray12: hsl(0, 0%, 9%);--border-radius: 8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:none;z-index:999999999;transition:transform .4s ease}:where([data-sonner-toaster][data-lifted="true"]){transform:translateY(-10px)}@media (hover: none) and (pointer: coarse){:where([data-sonner-toaster][data-lifted="true"]){transform:none}}:where([data-sonner-toaster][data-x-position="right"]){right:var(--offset-right)}:where([data-sonner-toaster][data-x-position="left"]){left:var(--offset-left)}:where([data-sonner-toaster][data-x-position="center"]){left:50%;transform:translate(-50%)}:where([data-sonner-toaster][data-y-position="top"]){top:var(--offset-top)}:where([data-sonner-toaster][data-y-position="bottom"]){bottom:var(--offset-bottom)}:where([data-sonner-toast]){--y: translateY(100%);--lift-amount: calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);filter:blur(0);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:none;overflow-wrap:anywhere}:where([data-sonner-toast][data-styled="true"]){padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px #0000001a;width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}:where([data-sonner-toast]:focus-visible){box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast][data-y-position="top"]){top:0;--y: translateY(-100%);--lift: 1;--lift-amount: calc(1 * var(--gap))}:where([data-sonner-toast][data-y-position="bottom"]){bottom:0;--y: translateY(100%);--lift: -1;--lift-amount: calc(var(--lift) * var(--gap))}:where([data-sonner-toast]) :where([data-description]){font-weight:400;line-height:1.4;color:inherit}:where([data-sonner-toast]) :where([data-title]){font-weight:500;line-height:1.5;color:inherit}:where([data-sonner-toast]) :where([data-icon]){display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}:where([data-sonner-toast][data-promise="true"]) :where([data-icon])>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}:where([data-sonner-toast]) :where([data-icon])>*{flex-shrink:0}:where([data-sonner-toast]) :where([data-icon]) svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}:where([data-sonner-toast]) :where([data-content]){display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;cursor:pointer;outline:none;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}:where([data-sonner-toast]) :where([data-button]):focus-visible{box-shadow:0 0 0 2px #0006}:where([data-sonner-toast]) :where([data-button]):first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}:where([data-sonner-toast]) :where([data-cancel]){color:var(--normal-text);background:rgba(0,0,0,.08)}:where([data-sonner-toast][data-theme="dark"]) :where([data-cancel]){background:rgba(255,255,255,.3)}:where([data-sonner-toast]) :where([data-close-button]){position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast] [data-close-button]{background:var(--gray1)}:where([data-sonner-toast]) :where([data-close-button]):focus-visible{box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast]) :where([data-disabled="true"]){cursor:not-allowed}:where([data-sonner-toast]):hover :where([data-close-button]):hover{background:var(--gray2);border-color:var(--gray5)}:where([data-sonner-toast][data-swiping="true"]):before{content:"";position:absolute;left:-50%;right:-50%;height:100%;z-index:-1}:where([data-sonner-toast][data-y-position="top"][data-swiping="true"]):before{bottom:50%;transform:scaleY(3) translateY(50%)}:where([data-sonner-toast][data-y-position="bottom"][data-swiping="true"]):before{top:50%;transform:scaleY(3) translateY(-50%)}:where([data-sonner-toast][data-swiping="false"][data-removed="true"]):before{content:"";position:absolute;inset:0;transform:scaleY(2)}:where([data-sonner-toast]):after{content:"";position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}:where([data-sonner-toast][data-mounted="true"]){--y: translateY(0);opacity:1}:where([data-sonner-toast][data-expanded="false"][data-front="false"]){--scale: var(--toasts-before) * .05 + 1;--y: translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}:where([data-sonner-toast])>*{transition:opacity .4s}:where([data-sonner-toast][data-expanded="false"][data-front="false"][data-styled="true"])>*{opacity:0}:where([data-sonner-toast][data-visible="false"]){opacity:0;pointer-events:none}:where([data-sonner-toast][data-mounted="true"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}:where([data-sonner-toast][data-removed="true"][data-front="true"][data-swipe-out="false"]){--y: translateY(calc(var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="false"]){--y: translateY(40%);opacity:0;transition:transform .5s,opacity .2s}:where([data-sonner-toast][data-removed="true"][data-front="false"]):before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y, 0px)) translate(var(--swipe-amount-x, 0px));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width: 600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-theme=light]{--normal-bg: #fff;--normal-border: var(--gray4);--normal-text: var(--gray12);--success-bg: hsl(143, 85%, 96%);--success-border: hsl(145, 92%, 91%);--success-text: hsl(140, 100%, 27%);--info-bg: hsl(208, 100%, 97%);--info-border: hsl(221, 91%, 91%);--info-text: hsl(210, 92%, 45%);--warning-bg: hsl(49, 100%, 97%);--warning-border: hsl(49, 91%, 91%);--warning-text: hsl(31, 92%, 45%);--error-bg: hsl(359, 100%, 97%);--error-border: hsl(359, 100%, 94%);--error-text: hsl(360, 100%, 45%)}[data-sonner-toaster][data-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg: #000;--normal-border: hsl(0, 0%, 20%);--normal-text: var(--gray1)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg: #fff;--normal-border: var(--gray3);--normal-text: var(--gray12)}[data-sonner-toaster][data-theme=dark]{--normal-bg: #000;--normal-bg-hover: hsl(0, 0%, 12%);--normal-border: hsl(0, 0%, 20%);--normal-border-hover: hsl(0, 0%, 25%);--normal-text: var(--gray1);--success-bg: hsl(150, 100%, 6%);--success-border: hsl(147, 100%, 12%);--success-text: hsl(150, 86%, 65%);--info-bg: hsl(215, 100%, 6%);--info-border: hsl(223, 100%, 12%);--info-text: hsl(216, 87%, 65%);--warning-bg: hsl(64, 100%, 6%);--warning-border: hsl(60, 100%, 12%);--warning-text: hsl(46, 87%, 65%);--error-bg: hsl(358, 76%, 10%);--error-border: hsl(357, 89%, 16%);--error-text: hsl(358, 100%, 81%)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success],[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info],[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning],[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error],[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size: 16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:nth-child(1){animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}to{opacity:.15}}@media (prefers-reduced-motion){[data-sonner-toast],[data-sonner-toast]>*,.sonner-loading-bar{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}
|
|
130
|
-
`);function pi(e){return e.label!==void 0}var VI=3,KI="32px",qI="16px",ex=4e3,GI=356,YI=14,XI=20,JI=200;function mn(...e){return e.filter(Boolean).join(" ")}function ZI(e){let[t,n]=e.split("-"),r=[];return t&&r.push(t),n&&r.push(n),r}var QI=e=>{var t,n,r,o,s,i,a,l,c,d,h;let{invert:m,toast:f,unstyled:v,interacting:g,setHeights:x,visibleToasts:y,heights:w,index:S,toasts:k,expanded:C,removeToast:T,defaultRichColors:E,closeButton:j,style:P,cancelButtonStyle:D,actionButtonStyle:F,className:W="",descriptionClassName:G="",duration:A,position:X,gap:q,loadingIcon:B,expandByDefault:R,classNames:I,icons:H,closeButtonAriaLabel:Y="Close toast",pauseWhenPageIsHidden:_}=e,[O,M]=b.useState(null),[L,te]=b.useState(null),[z,$]=b.useState(!1),[ee,J]=b.useState(!1),[K,Q]=b.useState(!1),[pe,de]=b.useState(!1),[me,we]=b.useState(!1),[Te,Ne]=b.useState(0),[ke,st]=b.useState(0),vt=b.useRef(f.duration||A||ex),pt=b.useRef(null),We=b.useRef(null),Le=S===0,Ge=S+1<=y,Re=f.type,$e=f.dismissible!==!1,Ze=f.className||"",It=f.descriptionClassName||"",it=b.useMemo(()=>w.findIndex(ve=>ve.toastId===f.id)||0,[w,f.id]),yt=b.useMemo(()=>{var ve;return(ve=f.closeButton)!=null?ve:j},[f.closeButton,j]),St=b.useMemo(()=>f.duration||A||ex,[f.duration,A]),Ct=b.useRef(0),kt=b.useRef(0),on=b.useRef(0),Nt=b.useRef(null),[Vt,Et]=X.split("-"),Fe=b.useMemo(()=>w.reduce((ve,he,ye)=>ye>=it?ve:ve+he.height,0),[w,it]),Ve=LI(),At=f.invert||m,Z=Re==="loading";kt.current=b.useMemo(()=>it*q+Fe,[it,Fe]),b.useEffect(()=>{vt.current=St},[St]),b.useEffect(()=>{$(!0)},[]),b.useEffect(()=>{let ve=We.current;if(ve){let he=ve.getBoundingClientRect().height;return st(he),x(ye=>[{toastId:f.id,height:he,position:f.position},...ye]),()=>x(ye=>ye.filter(Me=>Me.toastId!==f.id))}},[x,f.id]),b.useLayoutEffect(()=>{if(!z)return;let ve=We.current,he=ve.style.height;ve.style.height="auto";let ye=ve.getBoundingClientRect().height;ve.style.height=he,st(ye),x(Me=>Me.find(Ke=>Ke.toastId===f.id)?Me.map(Ke=>Ke.toastId===f.id?{...Ke,height:ye}:Ke):[{toastId:f.id,height:ye,position:f.position},...Me])},[z,f.title,f.description,x,f.id]);let ce=b.useCallback(()=>{J(!0),Ne(kt.current),x(ve=>ve.filter(he=>he.toastId!==f.id)),setTimeout(()=>{T(f)},JI)},[f,T,x,kt]);b.useEffect(()=>{if(f.promise&&Re==="loading"||f.duration===1/0||f.type==="loading")return;let ve;return C||g||_&&Ve?(()=>{if(on.current<Ct.current){let he=new Date().getTime()-Ct.current;vt.current=vt.current-he}on.current=new Date().getTime()})():vt.current!==1/0&&(Ct.current=new Date().getTime(),ve=setTimeout(()=>{var he;(he=f.onAutoClose)==null||he.call(f,f),ce()},vt.current)),()=>clearTimeout(ve)},[C,g,f,Re,_,Ve,ce]),b.useEffect(()=>{f.delete&&ce()},[ce,f.delete]);function He(){var ve,he,ye;return H!=null&&H.loading?b.createElement("div",{className:mn(I==null?void 0:I.loader,(ve=f==null?void 0:f.classNames)==null?void 0:ve.loader,"sonner-loader"),"data-visible":Re==="loading"},H.loading):B?b.createElement("div",{className:mn(I==null?void 0:I.loader,(he=f==null?void 0:f.classNames)==null?void 0:he.loader,"sonner-loader"),"data-visible":Re==="loading"},B):b.createElement(PI,{className:mn(I==null?void 0:I.loader,(ye=f==null?void 0:f.classNames)==null?void 0:ye.loader),visible:Re==="loading"})}return b.createElement("li",{tabIndex:0,ref:We,className:mn(W,Ze,I==null?void 0:I.toast,(t=f==null?void 0:f.classNames)==null?void 0:t.toast,I==null?void 0:I.default,I==null?void 0:I[Re],(n=f==null?void 0:f.classNames)==null?void 0:n[Re]),"data-sonner-toast":"","data-rich-colors":(r=f.richColors)!=null?r:E,"data-styled":!(f.jsx||f.unstyled||v),"data-mounted":z,"data-promise":!!f.promise,"data-swiped":me,"data-removed":ee,"data-visible":Ge,"data-y-position":Vt,"data-x-position":Et,"data-index":S,"data-front":Le,"data-swiping":K,"data-dismissible":$e,"data-type":Re,"data-invert":At,"data-swipe-out":pe,"data-swipe-direction":L,"data-expanded":!!(C||R&&z),style:{"--index":S,"--toasts-before":S,"--z-index":k.length-S,"--offset":`${ee?Te:kt.current}px`,"--initial-height":R?"auto":`${ke}px`,...P,...f.style},onDragEnd:()=>{Q(!1),M(null),Nt.current=null},onPointerDown:ve=>{Z||!$e||(pt.current=new Date,Ne(kt.current),ve.target.setPointerCapture(ve.pointerId),ve.target.tagName!=="BUTTON"&&(Q(!0),Nt.current={x:ve.clientX,y:ve.clientY}))},onPointerUp:()=>{var ve,he,ye,Me;if(pe||!$e)return;Nt.current=null;let Ke=Number(((ve=We.current)==null?void 0:ve.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),lt=Number(((he=We.current)==null?void 0:he.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),ct=new Date().getTime()-((ye=pt.current)==null?void 0:ye.getTime()),_e=O==="x"?Ke:lt,mt=Math.abs(_e)/ct;if(Math.abs(_e)>=XI||mt>.11){Ne(kt.current),(Me=f.onDismiss)==null||Me.call(f,f),te(O==="x"?Ke>0?"right":"left":lt>0?"down":"up"),ce(),de(!0),we(!1);return}Q(!1),M(null)},onPointerMove:ve=>{var he,ye,Me,Ke;if(!Nt.current||!$e||((he=window.getSelection())==null?void 0:he.toString().length)>0)return;let lt=ve.clientY-Nt.current.y,ct=ve.clientX-Nt.current.x,_e=(ye=e.swipeDirections)!=null?ye:ZI(X);!O&&(Math.abs(ct)>1||Math.abs(lt)>1)&&M(Math.abs(ct)>Math.abs(lt)?"x":"y");let mt={x:0,y:0};O==="y"?(_e.includes("top")||_e.includes("bottom"))&&(_e.includes("top")&<<0||_e.includes("bottom")&<>0)&&(mt.y=lt):O==="x"&&(_e.includes("left")||_e.includes("right"))&&(_e.includes("left")&&ct<0||_e.includes("right")&&ct>0)&&(mt.x=ct),(Math.abs(mt.x)>0||Math.abs(mt.y)>0)&&we(!0),(Me=We.current)==null||Me.style.setProperty("--swipe-amount-x",`${mt.x}px`),(Ke=We.current)==null||Ke.style.setProperty("--swipe-amount-y",`${mt.y}px`)}},yt&&!f.jsx?b.createElement("button",{"aria-label":Y,"data-disabled":Z,"data-close-button":!0,onClick:Z||!$e?()=>{}:()=>{var ve;ce(),(ve=f.onDismiss)==null||ve.call(f,f)},className:mn(I==null?void 0:I.closeButton,(o=f==null?void 0:f.classNames)==null?void 0:o.closeButton)},(s=H==null?void 0:H.close)!=null?s:DI):null,f.jsx||b.isValidElement(f.title)?f.jsx?f.jsx:typeof f.title=="function"?f.title():f.title:b.createElement(b.Fragment,null,Re||f.icon||f.promise?b.createElement("div",{"data-icon":"",className:mn(I==null?void 0:I.icon,(i=f==null?void 0:f.classNames)==null?void 0:i.icon)},f.promise||f.type==="loading"&&!f.icon?f.icon||He():null,f.type!=="loading"?f.icon||(H==null?void 0:H[Re])||AI(Re):null):null,b.createElement("div",{"data-content":"",className:mn(I==null?void 0:I.content,(a=f==null?void 0:f.classNames)==null?void 0:a.content)},b.createElement("div",{"data-title":"",className:mn(I==null?void 0:I.title,(l=f==null?void 0:f.classNames)==null?void 0:l.title)},typeof f.title=="function"?f.title():f.title),f.description?b.createElement("div",{"data-description":"",className:mn(G,It,I==null?void 0:I.description,(c=f==null?void 0:f.classNames)==null?void 0:c.description)},typeof f.description=="function"?f.description():f.description):null),b.isValidElement(f.cancel)?f.cancel:f.cancel&&pi(f.cancel)?b.createElement("button",{"data-button":!0,"data-cancel":!0,style:f.cancelButtonStyle||D,onClick:ve=>{var he,ye;pi(f.cancel)&&$e&&((ye=(he=f.cancel).onClick)==null||ye.call(he,ve),ce())},className:mn(I==null?void 0:I.cancelButton,(d=f==null?void 0:f.classNames)==null?void 0:d.cancelButton)},f.cancel.label):null,b.isValidElement(f.action)?f.action:f.action&&pi(f.action)?b.createElement("button",{"data-button":!0,"data-action":!0,style:f.actionButtonStyle||F,onClick:ve=>{var he,ye;pi(f.action)&&((ye=(he=f.action).onClick)==null||ye.call(he,ve),!ve.defaultPrevented&&ce())},className:mn(I==null?void 0:I.actionButton,(h=f==null?void 0:f.classNames)==null?void 0:h.actionButton)},f.action.label):null))};function tx(){if(typeof window>"u"||typeof document>"u")return"ltr";let e=document.documentElement.getAttribute("dir");return e==="auto"||!e?window.getComputedStyle(document.documentElement).direction:e}function eN(e,t){let n={};return[e,t].forEach((r,o)=>{let s=o===1,i=s?"--mobile-offset":"--offset",a=s?qI:KI;function l(c){["top","right","bottom","left"].forEach(d=>{n[`${i}-${d}`]=typeof c=="number"?`${c}px`:c})}typeof r=="number"||typeof r=="string"?l(r):typeof r=="object"?["top","right","bottom","left"].forEach(c=>{r[c]===void 0?n[`${i}-${c}`]=a:n[`${i}-${c}`]=typeof r[c]=="number"?`${r[c]}px`:r[c]}):l(a)}),n}var tN=b.forwardRef(function(e,t){let{invert:n,position:r="bottom-right",hotkey:o=["altKey","KeyT"],expand:s,closeButton:i,className:a,offset:l,mobileOffset:c,theme:d="light",richColors:h,duration:m,style:f,visibleToasts:v=VI,toastOptions:g,dir:x=tx(),gap:y=YI,loadingIcon:w,icons:S,containerAriaLabel:k="Notifications",pauseWhenPageIsHidden:C}=e,[T,E]=b.useState([]),j=b.useMemo(()=>Array.from(new Set([r].concat(T.filter(_=>_.position).map(_=>_.position)))),[T,r]),[P,D]=b.useState([]),[F,W]=b.useState(!1),[G,A]=b.useState(!1),[X,q]=b.useState(d!=="system"?d:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),B=b.useRef(null),R=o.join("+").replace(/Key/g,"").replace(/Digit/g,""),I=b.useRef(null),H=b.useRef(!1),Y=b.useCallback(_=>{E(O=>{var M;return(M=O.find(L=>L.id===_.id))!=null&&M.delete||Wt.dismiss(_.id),O.filter(({id:L})=>L!==_.id)})},[]);return b.useEffect(()=>Wt.subscribe(_=>{if(_.dismiss){E(O=>O.map(M=>M.id===_.id?{...M,delete:!0}:M));return}setTimeout(()=>{Ro.flushSync(()=>{E(O=>{let M=O.findIndex(L=>L.id===_.id);return M!==-1?[...O.slice(0,M),{...O[M],..._},...O.slice(M+1)]:[_,...O]})})})}),[]),b.useEffect(()=>{if(d!=="system"){q(d);return}if(d==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?q("dark"):q("light")),typeof window>"u")return;let _=window.matchMedia("(prefers-color-scheme: dark)");try{_.addEventListener("change",({matches:O})=>{q(O?"dark":"light")})}catch{_.addListener(({matches:M})=>{try{q(M?"dark":"light")}catch(L){console.error(L)}})}},[d]),b.useEffect(()=>{T.length<=1&&W(!1)},[T]),b.useEffect(()=>{let _=O=>{var M,L;o.every(te=>O[te]||O.code===te)&&(W(!0),(M=B.current)==null||M.focus()),O.code==="Escape"&&(document.activeElement===B.current||(L=B.current)!=null&&L.contains(document.activeElement))&&W(!1)};return document.addEventListener("keydown",_),()=>document.removeEventListener("keydown",_)},[o]),b.useEffect(()=>{if(B.current)return()=>{I.current&&(I.current.focus({preventScroll:!0}),I.current=null,H.current=!1)}},[B.current]),b.createElement("section",{ref:t,"aria-label":`${k} ${R}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},j.map((_,O)=>{var M;let[L,te]=_.split("-");return T.length?b.createElement("ol",{key:_,dir:x==="auto"?tx():x,tabIndex:-1,ref:B,className:a,"data-sonner-toaster":!0,"data-theme":X,"data-y-position":L,"data-lifted":F&&T.length>1&&!s,"data-x-position":te,style:{"--front-toast-height":`${((M=P[0])==null?void 0:M.height)||0}px`,"--width":`${GI}px`,"--gap":`${y}px`,...f,...eN(l,c)},onBlur:z=>{H.current&&!z.currentTarget.contains(z.relatedTarget)&&(H.current=!1,I.current&&(I.current.focus({preventScroll:!0}),I.current=null))},onFocus:z=>{z.target instanceof HTMLElement&&z.target.dataset.dismissible==="false"||H.current||(H.current=!0,I.current=z.relatedTarget)},onMouseEnter:()=>W(!0),onMouseMove:()=>W(!0),onMouseLeave:()=>{G||W(!1)},onDragEnd:()=>W(!1),onPointerDown:z=>{z.target instanceof HTMLElement&&z.target.dataset.dismissible==="false"||A(!0)},onPointerUp:()=>A(!1)},T.filter(z=>!z.position&&O===0||z.position===_).map((z,$)=>{var ee,J;return b.createElement(QI,{key:z.id,icons:S,index:$,toast:z,defaultRichColors:h,duration:(ee=g==null?void 0:g.duration)!=null?ee:m,className:g==null?void 0:g.className,descriptionClassName:g==null?void 0:g.descriptionClassName,invert:n,visibleToasts:v,closeButton:(J=g==null?void 0:g.closeButton)!=null?J:i,interacting:G,position:_,style:g==null?void 0:g.style,unstyled:g==null?void 0:g.unstyled,classNames:g==null?void 0:g.classNames,cancelButtonStyle:g==null?void 0:g.cancelButtonStyle,actionButtonStyle:g==null?void 0:g.actionButtonStyle,removeToast:Y,toasts:T.filter(K=>K.position==z.position),heights:P.filter(K=>K.position==z.position),setHeights:D,expandByDefault:s,gap:y,loadingIcon:w,expanded:F,pauseWhenPageIsHidden:C,swipeDirections:e.swipeDirections})})):null}))});const nN=({...e})=>{const{theme:t="system"}=NI();return u.jsx(tN,{theme:t,className:"toaster group",toastOptions:{classNames:{toast:"group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",description:"group-[.toast]:text-muted-foreground",actionButton:"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",cancelButton:"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground"}},...e})};U.Api=Hv,U.ApiClient=zv,U.ApiProvider=nu,U.ArtifactRenderer=kp,U.Badge=Op,U.Button=Je,U.Card=il,U.CardContent=ul,U.CardDescription=cl,U.CardHeader=al,U.CardTitle=ll,U.ChatApi=qo,U.ChatApp=Dk,U.ChatInput=Uf,U.ChatInputRow=Wf,U.ChatInterface=Mr,U.ChatProviders=br,U.ChatWidget=Fk,U.Command=yl,U.CommandEmpty=Tl,U.CommandGroup=kl,U.CommandInput=Sl,U.CommandItem=El,U.CommandList=Cl,U.DEFAULT_TIMEOUT_MS=Xc,U.Dialog=el,U.DialogContent=zs,U.DialogHeader=Hs,U.DialogTitle=Us,U.DropdownMenu=Cs,U.DropdownMenuContent=ho,U.DropdownMenuItem=Bn,U.DropdownMenuTrigger=Ts,U.FileViewerModal=lp,U.HISTORY_TIMEOUT_MS=Jc,U.Input=Rl,U.InterruptPartRenderer=Ip,U.Label=mm,U.MarkdownContent=qn,U.MessageComponent=Xs,U.MessageList=pl,U.MessageRow=hl,U.NewChatButton=Bk,U.PlotArtifact=Sp,U.ResearchTaskArtifact=Tp,U.SETTINGS_STORAGE_KEY=Fi,U.ScrollArea=_l,U.Select=bE,U.SelectContent=ng,U.SelectItem=rg,U.SelectTrigger=Qm,U.SelectValue=wE,U.Separator=ag,U.Sheet=PE,U.SheetContent=gg,U.SheetDescription=bg,U.SheetHeader=xg,U.SheetTitle=vg,U.SheetTrigger=_E,U.SimpleChat=Lk,U.SimpleJsonView=dl,U.Sonner=nN,U.StreamProgress=Np,U.Switch=pg,U.Textarea=ka,U.ThinkingIndicator=Ap,U.ThreadListItem=cm,U.ThreadManager=ni,U.ThreadStateProvider=ku,U.ThreadsProvider=hu,U.TimelineColumn=vx,U.Toaster=TI,U.ToolComponent=Pp,U.Tooltip=tI,U.TooltipContent=Ng,U.TooltipProvider=eI,U.TooltipTrigger=nI,U.UserTextContent=jp,U.applySettings=Sb,U.buildCheckpointIndex=ec,U.buildCheckpointPreviewMap=ax,U.chatApiClient=Nn,U.del=ji,U.downloadFileById=Qc,U.extractConfigFields=gi,U.fileToBase64=ru,U.get=Yt,U.getChatToken=Gc,U.getCheckpointForMessage=lx,U.getCurrentSettings=yb,U.getDefaultApiConfig=Mu,U.getDefaultChatSettings=Ou,U.getFileContent=_i,U.getFileInfo=Wv,U.getMessageAttemptInfo=tc,U.getMessageDomKey=fl,U.getPreviewForMessage=mi,U.httpClient=Gt,U.hydrateHistorySnapshots=Mn,U.isEnvelope=su,U.listFiles=eu,U.loadStoredSettings=Du,U.onChatTokenChanged=Yc,U.post=Ko,U.processAttachments=ou,U.put=Zc,U.readNumber=rc,U.readString=Rn,U.resolveChatBaseUrl=xn,U.saveSettings=Lu,U.setChatToken=Vo,U.toPlainObject=_n,U.unwrap=Ot,U.useApi=Xr,U.useCheckpointIndex=nc,U.useFilePreview=_p,U.useHasChatSession=vb,U.useParsedMessageContent=Rp,U.useShallowStableValue=ju,U.useStream=$i,U.useStreamingHook=$i,U.useThreadHistoryState=yu,U.useThreadManagerViewState=fm,U.useThreadState=eo,U.useThreadStateUpdater=Tu,U.useThreads=xr,U.useThreadsState=du,U.viewFileById=Uv,Object.defineProperty(U,Symbol.toStringTag,{value:"Module"})});
|
|
126
|
+
`}strong(t){return`<strong>${t}</strong>`}em(t){return`<em>${t}</em>`}codespan(t){return`<code>${t}</code>`}br(){return this.options.xhtml?"<br/>":"<br>"}del(t){return`<del>${t}</del>`}link(t,n,r){if(t=Eh(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=Eh(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 _h{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 Ph{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 qn{constructor(t){this.options=t||ur,this.options.renderer=this.options.renderer||new dl,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new _h,this.slugger=new Ph}static parse(t,n){return new qn(n).parse(t)}static parseInline(t,n){return new qn(n).parseInline(t)}parse(t,n=!0){let r="",o,s,i,a,l,u,d,f,m,p,b,g,x,y,w,S,k,C,T;const E=t.length;for(o=0;o<E;o++){if(p=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[p.type]&&(T=this.options.extensions.renderers[p.type].call({parser:this},p),T!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(p.type))){r+=T||"";continue}switch(p.type){case"space":continue;case"hr":{r+=this.renderer.hr();continue}case"heading":{r+=this.renderer.heading(this.parseInline(p.tokens),p.depth,kh(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(u=p.rows[s],d="",l=u.length,i=0;i<l;i++)d+=this.renderer.tablecell(this.parseInline(u[i].tokens),{header:!1,align:p.align[i]});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(b=p.ordered,g=p.start,x=p.loose,a=p.items.length,m="",s=0;s<a;s++)w=p.items[s],S=w.checked,k=w.task,y="",w.task&&(C=this.renderer.checkbox(S),x?w.tokens.length>0&&w.tokens[0].type==="paragraph"?(w.tokens[0].text=C+" "+w.tokens[0].text,w.tokens[0].tokens&&w.tokens[0].tokens.length>0&&w.tokens[0].tokens[0].type==="text"&&(w.tokens[0].tokens[0].text=C+" "+w.tokens[0].tokens[0].text)):w.tokens.unshift({type:"text",text:C}):y+=C),y+=this.parse(w.tokens,x),m+=this.renderer.listitem(y,k,S);r+=this.renderer.list(m,b,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<E&&t[o+1].type==="text";)p=t[++o],m+=`
|
|
127
|
+
`+(p.tokens?this.parseInline(p.tokens):p.text);r+=n?this.renderer.paragraph(m):m;continue}default:{const j='Token with "'+p.type+'" type was not found.';if(this.options.silent){console.error(j);return}else throw new Error(j)}}}return r}parseInline(t,n){n=n||this.renderer;let r="",o,s,i;const a=t.length;for(o=0;o<a;o++){if(s=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[s.type]&&(i=this.options.extensions.renderers[s.type].call({parser:this},s),i!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type))){r+=i||"";continue}switch(s.type){case"escape":{r+=n.text(s.text);break}case"html":{r+=n.html(s.text);break}case"link":{r+=n.link(s.href,s.title,this.parseInline(s.tokens,n));break}case"image":{r+=n.image(s.href,s.title,s.text);break}case"strong":{r+=n.strong(this.parseInline(s.tokens,n));break}case"em":{r+=n.em(this.parseInline(s.tokens,n));break}case"codespan":{r+=n.codespan(s.text);break}case"br":{r+=n.br();break}case"del":{r+=n.del(this.parseInline(s.tokens,n));break}case"text":{r+=n.text(s.text);break}default:{const l='Token with "'+s.type+'" type was not found.';if(this.options.silent){console.error(l);return}else throw new Error(l)}}}return r}}class Zs{constructor(t){this.options=t||ur}preprocess(t){return t}postprocess(t){return t}}Dx(Zs,"passThroughHooks",new Set(["preprocess","postprocess"]));function mk(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 Rh(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...be.defaults,...s};const i=mk(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(fk(r),r.hooks&&(r.hooks.options=r),o){const a=r.highlight;let l;try{r.hooks&&(n=r.hooks.preprocess(n)),l=e(n,r)}catch(f){return i(f)}const u=function(f){let m;if(!f)try{r.walkTokens&&be.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 u();let d=0;be.walkTokens(l,function(f){f.type==="code"&&(d++,setTimeout(()=>{a(f.text,f.lang,function(m,p){if(m)return u(m);p!=null&&p!==f.text&&(f.text=p,f.escaped=!0),d--,d===0&&u()})},0))}),d===0&&u();return}if(r.async)return Promise.resolve(r.hooks?r.hooks.preprocess(n):n).then(a=>e(a,r)).then(a=>r.walkTokens?Promise.all(be.walkTokens(a,r.walkTokens)).then(()=>a):a).then(a=>t(a,r)).then(a=>r.hooks?r.hooks.postprocess(a):a).catch(i);try{r.hooks&&(n=r.hooks.preprocess(n));const a=e(n,r);r.walkTokens&&be.walkTokens(a,r.walkTokens);let l=t(a,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(a){return i(a)}}}function be(e,t,n){return Rh(Kn.lex,qn.parse)(e,t,n)}be.options=be.setOptions=function(e){return be.defaults={...be.defaults,...e},QT(be.defaults),be},be.getDefaults=yh,be.defaults=ur,be.use=function(...e){const t=be.defaults.extensions||{renderers:{},childTokens:{}};e.forEach(n=>{const r={...n};if(r.async=be.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(o=>{if(!o.name)throw new Error("extension name required");if(o.renderer){const s=t.renderers[o.name];s?t.renderers[o.name]=function(...i){let a=o.renderer.apply(this,i);return a===!1&&(a=s.apply(this,i)),a}:t.renderers[o.name]=o.renderer}if(o.tokenizer){if(!o.level||o.level!=="block"&&o.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");t[o.level]?t[o.level].unshift(o.tokenizer):t[o.level]=[o.tokenizer],o.start&&(o.level==="block"?t.startBlock?t.startBlock.push(o.start):t.startBlock=[o.start]:o.level==="inline"&&(t.startInline?t.startInline.push(o.start):t.startInline=[o.start]))}o.childTokens&&(t.childTokens[o.name]=o.childTokens)}),r.extensions=t),n.renderer){const o=be.defaults.renderer||new dl;for(const s in n.renderer){const i=o[s];o[s]=(...a)=>{let l=n.renderer[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.renderer=o}if(n.tokenizer){const o=be.defaults.tokenizer||new ul;for(const s in n.tokenizer){const i=o[s];o[s]=(...a)=>{let l=n.tokenizer[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.tokenizer=o}if(n.hooks){const o=be.defaults.hooks||new Zs;for(const s in n.hooks){const i=o[s];Zs.passThroughHooks.has(s)?o[s]=a=>{if(be.defaults.async)return Promise.resolve(n.hooks[s].call(o,a)).then(u=>i.call(o,u));const l=n.hooks[s].call(o,a);return i.call(o,l)}:o[s]=(...a)=>{let l=n.hooks[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.hooks=o}if(n.walkTokens){const o=be.defaults.walkTokens;r.walkTokens=function(s){let i=[];return i.push(n.walkTokens.call(this,s)),o&&(i=i.concat(o.call(this,s))),i}}be.setOptions(r)})},be.walkTokens=function(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(be,r)),r.type){case"table":{for(const o of r.header)n=n.concat(be.walkTokens(o.tokens,t));for(const o of r.rows)for(const s of o)n=n.concat(be.walkTokens(s.tokens,t));break}case"list":{n=n.concat(be.walkTokens(r.items,t));break}default:be.defaults.extensions&&be.defaults.extensions.childTokens&&be.defaults.extensions.childTokens[r.type]?be.defaults.extensions.childTokens[r.type].forEach(function(o){n=n.concat(be.walkTokens(r[o],t))}):r.tokens&&(n=n.concat(be.walkTokens(r.tokens,t)))}return n},be.parseInline=Rh(Kn.lexInline,qn.parseInline),be.Parser=qn,be.parser=qn.parse,be.Renderer=dl,be.TextRenderer=_h,be.Lexer=Kn,be.lexer=Kn.lex,be.Tokenizer=ul,be.Slugger=Ph,be.Hooks=Zs,be.parse=be,be.options,be.setOptions,be.use,be.walkTokens,be.parseInline,qn.parse,Kn.lex;function Gn({content:e,className:t="",allowHtml:n=!1,style:r}){const o=v.useMemo(()=>{if(!e||typeof e!="string"||e.trim().length===0)return"";try{if(!n){const i=e.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"").replace(/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi,"").replace(/javascript:/gi,"").replace(/on\w+\s*=/gi,"");return typeof be.parse=="function"?be.parse(i):be(i)}return typeof be.parse=="function"?be.parse(e):be(e)}catch(i){return console.error("[MarkdownContent] parse error",i),`<pre class="font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words">Error rendering markdown: ${String(i)}</pre>`}},[e,n]),s=v.useMemo(()=>{const i={color:"currentColor",...r};if(r&&r.color){const a=r.color;return{...i,"--tw-prose-body":a,"--tw-prose-headings":a,"--tw-prose-links":a,"--tw-prose-bold":a,"--tw-prose-counters":a,"--tw-prose-bullets":a,"--tw-prose-hr":a,"--tw-prose-quotes":a,"--tw-prose-quote-borders":a,"--tw-prose-captions":a,"--tw-prose-code":a,"--tw-prose-pre-code":a,"--tw-prose-pre-bg":"inherit","--tw-prose-th-borders":a,"--tw-prose-td-borders":a}}return i},[r]);return c.jsx("div",{className:ne("markdown prose prose-sm max-w-none break-words","dark:prose-invert","text-current","prose-headings:text-current prose-p:text-current prose-li:text-current prose-a:text-current prose-strong:text-current","prose-em:text-current prose-blockquote:text-current prose-table:text-current prose-td:text-current prose-th:text-current","prose-pre:font-mono prose-pre:text-xs prose-pre:bg-background/50 prose-pre:border prose-pre:rounded prose-pre:p-3 prose-pre:whitespace-pre prose-pre:overflow-x-auto","prose-code:font-mono prose-code:text-sm prose-code:bg-background/50 prose-code:px-1.5 prose-code:py-0.5 prose-code:rounded prose-code:text-current",t),style:s,dangerouslySetInnerHTML:{__html:o}})}function Mh({preview:e,idx:t}){return c.jsxs("div",{className:"space-y-2",children:[e.label&&c.jsxs("p",{className:"text-[0.65rem] uppercase tracking-wide text-muted-foreground",children:["Artifact: ",e.label]}),c.jsx("div",{className:"overflow-hidden rounded border border-border/60 bg-background/60 p-1 shadow-sm",children:c.jsx("img",{src:e.src,alt:e.alt,title:e.label,loading:"lazy",className:"h-auto max-h-[420px] w-full rounded object-contain",onLoad:()=>{},onError:n=>{console.error(`[MessageComponent] ❌ Image failed to load for artifact ${t}:`,{alt:e.alt,label:e.label,message:n.target.alt})}})})]})}const Oh={completed:{label:"Completed",badgeClass:"border border-green-200 bg-green-50 text-green-700"},success:{label:"Completed",badgeClass:"border border-green-200 bg-green-50 text-green-700"},failed:{label:"Failed",badgeClass:"border border-red-200 bg-red-50 text-red-700"},error:{label:"Failed",badgeClass:"border border-red-200 bg-red-50 text-red-700"},cancelled:{label:"Cancelled",badgeClass:"border border-orange-200 bg-orange-50 text-orange-700"},cancel:{label:"Cancelled",badgeClass:"border border-orange-200 bg-orange-50 text-orange-700"},pending:{label:"Pending",badgeClass:"border border-blue-200 bg-blue-50 text-blue-700"},processing:{label:"Processing",badgeClass:"border border-yellow-200 bg-yellow-50 text-yellow-700"}},gk=e=>{if(!e)return Oh.processing;const t=e.toLowerCase().trim();return Oh[t]??{label:t.replace(/(^\w|\s\w)/g,n=>n.toUpperCase()),badgeClass:"border border-slate-200 bg-slate-50 text-slate-800"}},xk=e=>e?e.length>10?`${e.slice(0,8)}…`:e:"";function Dh({artifact:e}){const t=gk(e.status),n=e.task_url??e.taskUrl??"";return c.jsxs("div",{className:"rounded-lg border border-blue-200/70 bg-blue-50/40 p-4 space-y-3",children:[c.jsxs("div",{className:"flex items-start justify-between gap-3",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("div",{className:"flex h-7 w-7 items-center justify-center rounded-full bg-blue-600/10 text-blue-600",children:c.jsx(ae.Search,{className:"h-4 w-4"})}),c.jsxs("div",{className:"space-y-1",children:[c.jsx("p",{className:"text-xs font-semibold uppercase tracking-wide text-blue-700",children:"Research Task"}),c.jsxs("p",{className:"text-[11px] text-blue-900/80",children:["Task ID: ",c.jsx("span",{className:"font-mono",children:xk(e.task_id)})]})]})]}),t&&c.jsx("span",{className:`inline-flex items-center rounded-full px-3 py-1 text-[11px] font-semibold ${t.badgeClass}`,children:t.label})]}),e.query&&c.jsxs("div",{className:"rounded border border-blue-100 bg-white/80 px-3 py-2 text-xs text-blue-900/90",children:[c.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wide text-blue-500",children:"Query"}),c.jsx("p",{className:"line-clamp-2 text-[11px] text-blue-900",children:e.query})]}),typeof e.results=="string"&&e.results.trim()&&c.jsxs("div",{className:"rounded border border-blue-100 bg-white/80 px-3 py-2 text-sm text-blue-900/90 space-y-1",children:[c.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wide text-blue-500",children:"Results"}),c.jsx(Gn,{content:e.results,allowHtml:!1,className:"prose text-xs !prose-sm prose-blue dark:prose-invert"})]}),c.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[n?c.jsxs("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 rounded-full border border-blue-600/80 bg-blue-600/10 px-3 py-1 text-xs font-semibold text-blue-700 transition hover:bg-blue-600/20",children:[c.jsx("span",{children:"Go to task"}),c.jsx(ae.ExternalLink,{className:"h-3 w-3"})]}):c.jsx("span",{className:"text-xs text-muted-foreground",children:"Task link unavailable"}),e.createdAt&&c.jsxs("p",{className:"text-[10px] text-blue-700/70",children:["Started: ",new Date(e.createdAt).toLocaleTimeString()]})]})]})}function Lh({artifact:e,idx:t=0}){const n=v.useMemo(()=>e?(Array.isArray(e.plots)?e.plots:[]).map(o=>Fb(o)).filter(o=>o!==null):[],[e]);return(e==null?void 0:e.type)==="research_task_info"?c.jsx(Dh,{artifact:{type:"research_task_info",task_id:e.task_id,task_url:e.task_url,query:e.query,status:e.status,createdAt:e.createdAt}}):n.length>0?c.jsx("div",{className:"space-y-2",children:n.map((r,o)=>c.jsx(Mh,{preview:r,idx:o},`${t}-plot-${o}`))}):e&&typeof e=="object"?c.jsx("div",{className:"rounded-lg border border-gray-200 dark:border-gray-800 bg-gray-50 dark:bg-gray-900/20 p-4",children:c.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:["Unknown artifact type: ",c.jsx("code",{className:"font-mono",children:e.type||"unknown"})]})}):null}const fl=h.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:ne("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));fl.displayName="Card";const pl=h.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:ne("flex flex-col space-y-1.5 p-6",e),...t}));pl.displayName="CardHeader";const hl=h.forwardRef(({className:e,...t},n)=>c.jsx("h3",{ref:n,className:ne("text-2xl font-semibold leading-none tracking-tight",e),...t}));hl.displayName="CardTitle";const ml=h.forwardRef(({className:e,...t},n)=>c.jsx("p",{ref:n,className:ne("text-sm text-muted-foreground",e),...t}));ml.displayName="CardDescription";const gl=h.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:ne("p-6 pt-0",e),...t}));gl.displayName="CardContent";const $h=h.forwardRef(({className:e,...t},n)=>c.jsx("div",{ref:n,className:ne("flex items-center p-6 pt-0",e),...t}));$h.displayName="CardFooter";function Fh({interruptPart:e,onApprove:t,onReject:n,disabled:r,isActive:o,payload:s}){const i=e.title??"Approve the result?";let a=null;if(s!=null)if(typeof s=="string")a=c.jsx("p",{className:"text-sm leading-relaxed text-blue-800/90 dark:text-blue-200/90 whitespace-pre-wrap",children:s});else{const u=br(s);a=c.jsx("pre",{className:"max-h-48 overflow-auto rounded bg-blue-100/60 p-2 text-xs text-blue-900/90 dark:bg-blue-900/40 dark:text-blue-100/80",children:u})}const l=o?"Please approve or reject this action to resume the workflow.":"Waiting for approval from another participant.";return c.jsxs(fl,{className:ne("border-blue-200 dark:border-blue-800 bg-blue-50/50 dark:bg-blue-950/10 transition-shadow",o?"shadow-md ring-1 ring-blue-300 dark:ring-blue-500/70":"opacity-80"),children:[c.jsxs(pl,{className:"pb-3",children:[c.jsx(hl,{className:"text-blue-900 dark:text-blue-100 text-base",children:i}),c.jsx(ml,{className:"text-blue-700 dark:text-blue-300 text-sm",children:l})]}),a&&c.jsx(gl,{className:"pt-0 pb-3",children:a}),c.jsx($h,{className:"pt-0",children:c.jsxs("div",{className:"flex gap-2 ml-auto",children:[c.jsx(Je,{size:"sm",variant:"outline",onClick:()=>n(e),className:"border-red-300 text-red-700 hover:bg-red-50 dark:border-red-700 dark:text-red-300 dark:hover:bg-red-950/50",disabled:r||!o,children:"Reject"}),c.jsx(Je,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",disabled:r||!o,children:"Approve"})]})})]})}const vk="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 _o({data:e}){return Array.isArray(e)?e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?c.jsx("div",{className:vk,children:c.jsx("ul",{className:"list-disc pl-5",children:e.map((n,r)=>c.jsx("li",{children:String(n)},r))})}):c.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:br(e)}):c.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:br(e)})}function Bh({message:e,isStreaming:t=!1}){const n=e.name??"tool",r=v.useMemo(()=>{const a=e.additionalKwargs??{};return Array.isArray(a.toolProgress)?[...a.toolProgress]:[]},[e]),s=r.some(a=>a.type==="tool.start"||a.type==="tool.call"||a.type==="message.start")?`Running ${n}…`:void 0;return t||r.length>0?c.jsxs("div",{className:"space-y-2",children:[c.jsxs("div",{className:"flex items-center gap-2 text-xs uppercase tracking-wide text-muted-foreground",children:[t&&c.jsx(ae.Loader,{className:"h-3 w-3 animate-spin"}),c.jsx("span",{children:s??`Running ${n}…`})]}),r.length>0&&c.jsx("div",{className:"space-y-2 text-xs text-muted-foreground",children:r.map((a,l)=>{var u;return c.jsxs("div",{className:"rounded border border-current/10 bg-muted/60 p-2 text-[11px] leading-snug",children:[c.jsxs("div",{className:"mb-1 flex items-center justify-between text-[8px] uppercase tracking-wide text-muted-foreground",children:[c.jsx("span",{children:((u=a.type)==null?void 0:u.replace(/\./g," "))??"progress"}),c.jsx("span",{children:a.idx??l+1})]}),a.content&&c.jsx("p",{className:"mt-1 text-[12px] text-foreground/90",children:a.content}),c.jsxs("div",{className:"mt-1 flex flex-wrap gap-2 text-[10px] opacity-70",children:[typeof a.factsFound=="number"&&c.jsxs("span",{children:["Facts found: ",a.factsFound]}),typeof a.isSufficient=="boolean"&&c.jsxs("span",{children:["Research ",a.isSufficient?"sufficient":"needs more data"]})]})]},`tool-progress-${n}-${l}`)})})]}):null}function zh({className:e}){const[t,n]=v.useState(0);return v.useEffect(()=>{const r=setInterval(()=>n(o=>(o+1)%4),500);return()=>clearInterval(r)},[]),c.jsxs("span",{"aria-live":"polite",className:ne("inline-block text-xs opacity-70 ml-1",e),children:["Is thinking",".".repeat(t)]})}function Hh({text:e,expanded:t,onExpandedChange:n,previewLength:r,isCompact:o}){const s=Math.max(e.length-r,0),i=e.substring(0,r);return c.jsxs("div",{className:"flex flex-col gap-1",children:[c.jsx("div",{className:ne("text-sm text-[hsl(var(--chat-bubble-user-text))]",o&&"text-xs"),children:t?c.jsx(Gn,{content:e,allowHtml:!1}):c.jsxs("pre",{className:ne("font-sans whitespace-pre-wrap break-words bg-transparent p-0 m-0 text-[hsl(var(--chat-bubble-user-text))]",o&&"text-xs"),children:[i,"..."]})}),c.jsx(Je,{type:"button",variant:"ghost",size:"sm",className:"h-6 text-xs !text-[hsl(var(--chat-bubble-user-text))]",onClick:()=>n(!t),children:t?c.jsxs(c.Fragment,{children:[c.jsx(ae.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):c.jsxs(c.Fragment,{children:[c.jsx(ae.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",s," chars)"]})})]})}function bk({data:e}){const t=Object.keys(e);return t.length?c.jsxs("div",{className:"space-y-2 rounded-lg border border-muted-foreground/40 bg-background/60 p-3 text-sm",children:[c.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Structured dictionary"}),c.jsx("div",{className:"grid gap-2 text-xs text-muted-foreground",children:t.map(n=>c.jsxs("div",{className:"rounded border border-border/40 bg-background/60 p-2",children:[c.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:n}),c.jsx(_o,{data:e[n]})]},n))})]}):null}var Qs="Collapsible",[wk,Uh]=Xt(Qs),[yk,xl]=wk(Qs),Wh=h.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:o,disabled:s,onOpenChange:i,...a}=e,[l,u]=cn({prop:r,defaultProp:o??!1,onChange:i,caller:Qs});return c.jsx(yk,{scope:n,disabled:s,contentId:kt(),open:l,onOpenToggle:h.useCallback(()=>u(d=>!d),[u]),children:c.jsx(he.div,{"data-state":bl(l),"data-disabled":s?"":void 0,...a,ref:t})})});Wh.displayName=Qs;var Vh="CollapsibleTrigger",Kh=h.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,o=xl(Vh,n);return c.jsx(he.button,{type:"button","aria-controls":o.contentId,"aria-expanded":o.open||!1,"data-state":bl(o.open),"data-disabled":o.disabled?"":void 0,disabled:o.disabled,...r,ref:t,onClick:ie(e.onClick,o.onOpenToggle)})});Kh.displayName=Vh;var vl="CollapsibleContent",qh=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=xl(vl,e.__scopeCollapsible);return c.jsx(Dt,{present:n||o.open,children:({present:s})=>c.jsx(Sk,{...r,ref:t,present:s})})});qh.displayName=vl;var Sk=h.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:o,...s}=e,i=xl(vl,n),[a,l]=h.useState(r),u=h.useRef(null),d=_e(t,u),f=h.useRef(0),m=f.current,p=h.useRef(0),b=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)},[]),wt(()=>{const w=u.current;if(w){y.current=y.current||{transitionDuration:w.style.transitionDuration,animationName:w.style.animationName},w.style.transitionDuration="0s",w.style.animationName="none";const S=w.getBoundingClientRect();f.current=S.height,p.current=S.width,x.current||(w.style.transitionDuration=y.current.transitionDuration,w.style.animationName=y.current.animationName),l(r)}},[i.open,r]),c.jsx(he.div,{"data-state":bl(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":b?`${b}px`:void 0,...e.style},children:g&&o})});function bl(e){return e?"open":"closed"}var Ck=Wh,Tk=Kh,kk=qh,mn="Accordion",Ek=["Home","End","ArrowDown","ArrowUp","ArrowLeft","ArrowRight"],[wl,Ik,Nk]=oo(mn),[ei,F1]=Xt(mn,[Nk,Uh]),yl=Uh(),Gh=v.forwardRef((e,t)=>{const{type:n,...r}=e,o=r,s=r;return c.jsx(wl.Provider,{scope:e.__scopeAccordion,children:n==="multiple"?c.jsx(Pk,{...s,ref:t}):c.jsx(_k,{...o,ref:t})})});Gh.displayName=mn;var[Yh,Ak]=ei(mn),[Xh,jk]=ei(mn,{collapsible:!1}),_k=v.forwardRef((e,t)=>{const{value:n,defaultValue:r,onValueChange:o=()=>{},collapsible:s=!1,...i}=e,[a,l]=cn({prop:n,defaultProp:r??"",onChange:o,caller:mn});return c.jsx(Yh,{scope:e.__scopeAccordion,value:v.useMemo(()=>a?[a]:[],[a]),onItemOpen:l,onItemClose:v.useCallback(()=>s&&l(""),[s,l]),children:c.jsx(Xh,{scope:e.__scopeAccordion,collapsible:s,children:c.jsx(Jh,{...i,ref:t})})})}),Pk=v.forwardRef((e,t)=>{const{value:n,defaultValue:r,onValueChange:o=()=>{},...s}=e,[i,a]=cn({prop:n,defaultProp:r??[],onChange:o,caller:mn}),l=v.useCallback(d=>a((f=[])=>[...f,d]),[a]),u=v.useCallback(d=>a((f=[])=>f.filter(m=>m!==d)),[a]);return c.jsx(Yh,{scope:e.__scopeAccordion,value:i,onItemOpen:l,onItemClose:u,children:c.jsx(Xh,{scope:e.__scopeAccordion,collapsible:!0,children:c.jsx(Jh,{...s,ref:t})})})}),[Rk,ti]=ei(mn),Jh=v.forwardRef((e,t)=>{const{__scopeAccordion:n,disabled:r,dir:o,orientation:s="vertical",...i}=e,a=v.useRef(null),l=_e(a,t),u=Ik(n),f=so(o)==="ltr",m=ie(e.onKeyDown,p=>{var j;if(!Ek.includes(p.key))return;const b=p.target,g=u().filter(_=>{var D;return!((D=_.ref.current)!=null&&D.disabled)}),x=g.findIndex(_=>_.ref.current===b),y=g.length;if(x===-1)return;p.preventDefault();let w=x;const S=0,k=y-1,C=()=>{w=x+1,w>k&&(w=S)},T=()=>{w=x-1,w<S&&(w=k)};switch(p.key){case"Home":w=S;break;case"End":w=k;break;case"ArrowRight":s==="horizontal"&&(f?C():T());break;case"ArrowDown":s==="vertical"&&C();break;case"ArrowLeft":s==="horizontal"&&(f?T():C());break;case"ArrowUp":s==="vertical"&&T();break}const E=w%y;(j=g[E].ref.current)==null||j.focus()});return c.jsx(Rk,{scope:n,disabled:r,direction:o,orientation:s,children:c.jsx(wl.Slot,{scope:n,children:c.jsx(he.div,{...i,"data-orientation":s,ref:l,onKeyDown:r?void 0:m})})})}),ni="AccordionItem",[Mk,Sl]=ei(ni),Zh=v.forwardRef((e,t)=>{const{__scopeAccordion:n,value:r,...o}=e,s=ti(ni,n),i=Ak(ni,n),a=yl(n),l=kt(),u=r&&i.value.includes(r)||!1,d=s.disabled||e.disabled;return c.jsx(Mk,{scope:n,open:u,disabled:d,triggerId:l,children:c.jsx(Ck,{"data-orientation":s.orientation,"data-state":om(u),...a,...o,ref:t,disabled:d,open:u,onOpenChange:f=>{f?i.onItemOpen(r):i.onItemClose(r)}})})});Zh.displayName=ni;var Qh="AccordionHeader",em=v.forwardRef((e,t)=>{const{__scopeAccordion:n,...r}=e,o=ti(mn,n),s=Sl(Qh,n);return c.jsx(he.h3,{"data-orientation":o.orientation,"data-state":om(s.open),"data-disabled":s.disabled?"":void 0,...r,ref:t})});em.displayName=Qh;var Cl="AccordionTrigger",tm=v.forwardRef((e,t)=>{const{__scopeAccordion:n,...r}=e,o=ti(mn,n),s=Sl(Cl,n),i=jk(Cl,n),a=yl(n);return c.jsx(wl.ItemSlot,{scope:n,children:c.jsx(Tk,{"aria-disabled":s.open&&!i.collapsible||void 0,"data-orientation":o.orientation,id:s.triggerId,...a,...r,ref:t})})});tm.displayName=Cl;var nm="AccordionContent",rm=v.forwardRef((e,t)=>{const{__scopeAccordion:n,...r}=e,o=ti(mn,n),s=Sl(nm,n),i=yl(n);return c.jsx(kk,{role:"region","aria-labelledby":s.triggerId,"data-orientation":o.orientation,...i,...r,ref:t,style:{"--radix-accordion-content-height":"var(--radix-collapsible-content-height)","--radix-accordion-content-width":"var(--radix-collapsible-content-width)",...e.style}})});rm.displayName=nm;function om(e){return e?"open":"closed"}var Ok=Gh,Dk=Zh,Lk=em,sm=tm,im=rm;const $k=Ok,am=h.forwardRef(({className:e,...t},n)=>c.jsx(Dk,{ref:n,className:ne("border-b",e),...t}));am.displayName="AccordionItem";const lm=h.forwardRef(({className:e,children:t,...n},r)=>c.jsx(Lk,{className:"flex",children:c.jsxs(sm,{ref:r,className:ne("flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180",e),...n,children:[t,c.jsx(ae.ChevronDown,{className:"h-4 w-4 shrink-0 transition-transform duration-200"})]})}));lm.displayName=sm.displayName;const cm=h.forwardRef(({className:e,children:t,...n},r)=>c.jsx(im,{ref:r,className:"overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",...n,children:c.jsx("div",{className:ne("pb-4 pt-0",e),children:t})}));cm.displayName=im.displayName;function Fk({issues:e}){return e.length?c.jsxs("div",{className:"space-y-2 rounded-lg border border-muted-foreground/40 bg-background/60 p-3 text-sm",children:[c.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Parsed Issues"}),c.jsx($k,{type:"multiple",defaultValue:e.slice(0,1).map((t,n)=>t.id??`issue-${n}`),children:e.map((t,n)=>{const r=t.id??`issue-${n}`,o=t.title||t.name||r,s=t.issueType||t.type||(typeof t.status<"u"?`Status ${t.status}`:null);return c.jsxs(am,{value:r,children:[c.jsx(lm,{className:"gap-2",children:c.jsxs("div",{className:"flex flex-1 flex-col items-start text-left",children:[c.jsx("span",{className:"text-sm font-semibold text-foreground",children:o}),s?c.jsx("span",{className:"text-xs text-muted-foreground",children:s}):null]})}),c.jsxs(cm,{className:"space-y-2 text-xs text-muted-foreground",children:[t.description?c.jsx("p",{className:"text-sm text-foreground/80 leading-relaxed whitespace-pre-wrap",children:t.description}):null,c.jsx(_o,{data:t})]})]},r)})})]}):null}function um(e){const{allowFileOpen:t,currentThreadId:n}=e,{toast:r}=cl(),[o,s]=v.useState({}),[i,a]=v.useState(null),[l,u]=v.useState(!1),d=v.useCallback(()=>{u(!1),a(null)},[]),f=v.useCallback(p=>{a(p),u(!0)},[]),m=v.useCallback(async(p,b,g)=>{var x,y;if(!t){p.preventDefault();return}if(o[g]){p.preventDefault();return}try{const w=String(b.url??""),S=w.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);if(S){p.preventDefault();const k=S[1],C=b.name||`file_${k}`,T=b.mimeType||"application/octet-stream";f({id:k,name:C,mimeType:T});return}if(w.startsWith("data:")){p.preventDefault(),s(C=>({...C,[g]:!0}));const k=r({title:"Fetching file...",description:"",open:!0});try{const C=await fu(n??void 0);if(!C||!Array.isArray(C))throw new Error("Invalid file list response");const T=C.find(E=>!E||typeof E!="object"||!((E.filename??"")===(b.name??""))?!1:typeof b.size=="number"&&typeof E.size=="number"?E.size===b.size:!0);if(!(T!=null&&T.id))throw new Error(`File "${b.name}" is not yet available on the server`);if(!T.id||!T.filename)throw new Error("Invalid file data received from server");f({id:T.id,name:b.name||T.filename||`file_${T.id}`,mimeType:b.mimeType||T.mime_type||"application/octet-stream"}),(x=k.update)==null||x.call(k,{id:k.id,title:"Success",description:`Opened ${b.name}`,open:!0})}catch(C){console.error("Failed to fetch server file:",C);const T=C instanceof Error?C.message:"Unknown error occurred";(y=k.update)==null||y.call(k,{id:k.id,title:"Failed",description:T}),r({title:"Failed to fetch file",description:T,open:!0})}finally{s(C=>({...C,[g]:!1}))}}}catch(w){console.error("File click error:",w),s(S=>({...S,[g]:!1}))}},[t,o,r,n,f]);return{uploadingFiles:o,handleFileClick:m,fileViewerOpen:l,currentFileInfo:i,closeFileViewer:d}}function dm(e,t){return v.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:Rb(r),toolMeta:zi(n),imageParts:r.filter(s=>s.type==="image_url"),fileParts:r.filter(s=>s.type==="file"),interruptParts:r.filter(s=>s.type==="interrupt"),toolRaw:Mb(r),isToolStreaming:!!o.toolStreaming}},[e,t])}const fm="data:";function Bk(e){if(!e)return[];const t=[],n=e.split(/\r?\n/);for(const r of n){const o=r.trim();if(!o||!o.startsWith(fm))continue;const s=o.slice(fm.length).trim();if(!s||s.toLowerCase()==="[done]")continue;const i=eo(s);i&&typeof i=="object"&&t.push(i)}return t}function zk(e){if(!e)return null;if(Array.isArray(e))return e;if(typeof e!="object")return null;const t=e.issues;if(Array.isArray(t))return t;if(t&&typeof t=="object"){const n=t.issues;if(Array.isArray(n))return n}return null}function Hk(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 Uk(e){return v.useMemo(()=>{const t=e.content.filter(u=>u.type==="text");if(!t.length)return null;let r=t.flatMap(u=>Bk(u.text??""));if(!r.length){const u=t.map(f=>f.text??"").join(`
|
|
129
|
+
`),d=eo(u);d&&typeof d=="object"&&(r=[d])}if(!r.length)return null;const s=Hk(r)??r[r.length-1];if(!s)return null;const i=s.output??s.payload??s,a=wr(i),l=zk(a);return l&&l.length?{kind:"issues",value:a,issues:l,event:s}:a&&typeof a=="object"&&!Array.isArray(a)?{kind:"dict",value:a,data:a,event:s}:{kind:"generic",value:a,event:s}},[e])}function pm({message:e,viewMode:t,isStreaming:n=!1}){const o=zi(e).name||"tool",s=e.artifact??null,i=Uk(e),a=e.content.find(f=>f.type!=="tool_call"),l=f=>{if(f==null)return null;const m=typeof f=="string"?eo(f)??f:f;if(m&&typeof m=="object")return c.jsx(_o,{data:m});const p=typeof m=="string"?m:(()=>{try{return br(m)}catch{return String(m??"")}})();return c.jsx("pre",{className:"whitespace-pre-wrap break-words font-sans text-sm text-foreground/90",children:p})},u=f=>{if(f==null)return null;const{content:m,isMarkdown:p}=Pb(f);return p?c.jsx(Gn,{content:m,className:"text-current"}):l(f)},d=()=>{if((i==null?void 0:i.kind)==="generic")return u(i.value);if(!a)return null;if(a.type==="text"){const b=(a.text??"").trim();if(!b)return null;const g=wr(b);return u(g)}const f=to(a),m=wr(f);return u(m)};return c.jsxs("div",{className:"space-y-2",children:[s&&c.jsx(Lh,{artifact:s,idx:0}),c.jsx(Bh,{message:e,isStreaming:n}),!a&&c.jsx("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:c.jsxs("span",{children:["Running ",o,"…"]})}),t==="expanded"&&c.jsx(c.Fragment,{children:(i==null?void 0:i.kind)==="issues"?c.jsx(Fk,{issues:i.issues}):(i==null?void 0:i.kind)==="dict"?c.jsx(bk,{data:i.data}):d()})]})}const Wk={checkpoints:[],checkpointMetaByCheckpointId:new Map,timeline:[],messagePreviews:new Map,getLatest:()=>{},getCheckpoint:()=>{},getMessageAttempts:()=>[]},Tl=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,kl=v.memo(function({message:t,index:n,isStreaming:r,streamingAssistantId:o,streamingDebounceMs:s,layoutSize:i,enableMessageEditing:a,editingMessageId:l,onEdit:u,onRegenerate:d,onCancelEdit:f,activeInterrupt:m,disableInterruptActions:p,onInterruptActionStart:b,onInterruptActionEnd:g,showToolMessages:x,checkpointIndex:y,onSelectCheckpoint:w}){const S=Tl(t,n),k=t.role==="default_message",T=!!t.__syntheticStreaming,E=y??Wk,j=!k&&"checkpointId"in t?t.checkpointId??null:null,{attemptCount:_,attemptIndex:D,attempts:F}=v.useMemo(()=>pc(t.id,j,E),[t.id,j,E]);return c.jsx("div",{className:"relative mb-4 last:mb-0","data-message-id":S,style:{minHeight:"60px",containIntrinsicSize:"auto 120px"},children:c.jsx(ri,{message:t,messageIndex:n,isStreamingMessage:T||r&&o===t.id&&t.role==="assistant",streamingDebounceMs:s,isEditing:l===t.id,showActions:a,showTimestamp:!1,showAgentName:!0,layoutSize:i,onEdit:u,onRegenerate:()=>d(n),onCancelEdit:f,activeInterrupt:m,disableInterruptActions:p,onInterruptActionStart:b,onInterruptActionEnd:g,showToolMessages:x,attemptCount:_,attemptIndex:D,attemptMetas:F,onSelectCheckpoint:w})})});kl.displayName="MessageRow";function Vk(e,t,n){const[r,o]=v.useState(e),s=v.useRef([]);return v.useEffect(()=>{if(!t){o(e),s.current=e.map(a=>a.type==="text"?a.text??"":void 0);return}const i=e.map((a,l)=>{if(a.type!=="text")return s.current[l]=void 0,a;const u=a.text??"",d=s.current[l];return n(u)?(s.current[l]=u,a):{...a,text:d??""}});o(i)},[e,t,n]),r}function Kk({message:e,isToolMessage:t,showToolMessages:n,toolViewMode:r,isToolStreaming:o,contentParts:s,textContent:i,imageParts:a,fileParts:l,interruptParts:u,isStreamingMessage:d,enableStreamingMarkdownBuffer:f,renderStreamingMarkdown:m,defaultMessage:p,handleFileClick:b,uploadingFiles:g,handleInterruptApprove:x,handleInterruptReject:y,disableInterruptActions:w,messageRole:S,truncateUserMessages:k,userMessagePreviewLength:C,isUserExpanded:T,setIsUserExpanded:E,isCompactLayout:j,activeInterruptId:_,activeInterruptValue:D,iconForeground:F}){const W=v.useCallback(()=>c.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/30 rounded",children:[c.jsx(ae.Loader,{className:"h-4 w-4 text-muted-foreground"}),c.jsx("span",{className:"text-sm text-muted-foreground",children:"File upload"})]}),[]),A=Vk(s,(f??!0)&&d,hm),X=v.useMemo(()=>A.filter(O=>O.type==="text"),[A]),q=v.useMemo(()=>X.map(O=>O.text??"").join(""),[X]),B=v.useMemo(()=>{if(!m)return null;const O=qk(q);return{stablePart:q.slice(0,O),tailPart:q.slice(O)}},[q,m]),R=v.useMemo(()=>{if(!B)return null;const{stablePart:O,tailPart:M}=B;return!O&&!M?null:c.jsxs("div",{className:"space-y-2",children:[O?c.jsx(Gn,{content:O,allowHtml:!1}):null,M?c.jsx(Gn,{content:M,allowHtml:!1}):null]})},[B]),I=v.useMemo(()=>{if(!m)return A;const O=[];let M=!1;for(const L of A){if(L.type==="text"){M||(O.push({type:"text",text:"",__streamingMarkdownAggregate:!0}),M=!0);continue}O.push(L)}return O},[A,m]),H=m?I:A,Y=v.useCallback(({part:O,i:M})=>{if(O.type==="text"){if(m)return null;const L=O.text??"",te=L.trim(),z=eo(te);return z&&S!=="tool"?c.jsx(_o,{data:z},M):S==="user"&&k&&te.length>C?c.jsx(Hh,{text:te,expanded:T,onExpandedChange:E,previewLength:C,isCompact:j},M):c.jsx(Gn,{content:L,allowHtml:!1},M)}if(O.type==="image_url"){const L=O;return c.jsx("div",{className:"my-2",children:c.jsx("img",{src:L.url,alt:L.alt??"",loading:"lazy",className:"border rounded max-h-[420px] w-auto object-contain"})},M)}if(O.type==="file"){const L=O,te=L.name||"file";return c.jsxs("a",{href:L.url,onClick:z=>b(z,L,M),className:`inline-flex items-center gap-2 rounded px-2 py-1 text-xs bg-gray-100 border hover:bg-gray-200
|
|
130
|
+
dark:bg-background/10 dark:border-border/30 dark:hover:bg-background/20`,children:[g[M]?c.jsx(ae.Loader,{className:"h-4 w-4 animate-spin"}):null,c.jsxs("span",{className:"truncate max-w-[180px]",children:[te,g[M]?" (processing)":""]})]},M)}if(O.type==="interrupt"){const L=O,te=es((L==null?void 0:L.id)??(L==null?void 0:L.interrupt_id)),z=!!(_&&te&&te===_),$=z?D??(L==null?void 0:L.value):L==null?void 0:L.value,ee=te?{...L,id:te,interrupt_id:te}:L;return c.jsx(Fh,{interruptPart:ee,onApprove:x,onReject:y,disabled:w,isActive:z,payload:$},M)}return null},[_,D,w,b,x,y,j,T,S,k,g,C,m,E]),P=i.trim().length>0||a.length>0||l.length>0||u.length>0;if(!t&&l.length>0&&!d)return W();if(!t&&!P&&!d)return null;if(t)return n?c.jsx(pm,{message:e,viewMode:r,isStreaming:o},e.id):null;if(!p){const O=c.jsx("div",{className:"space-y-2",children:H.map((M,L)=>m&&Gk(M)?R?c.jsx("div",{className:"space-y-2",children:R},`streaming-md-${L}`):null:c.jsx(Y,{part:M,i:L},L))});return d?c.jsxs("div",{"aria-busy":"true",role:"status",children:[O,c.jsx(zh,{className:F})]}):O}return null}function hm(e){return e?!(Po(e,/```/g)||Po(e,/`/g)||Po(e,/\*\*/g)||Po(e,/__/g)||Po(e,/~~/g)||/[^\\]\[[^\]]*$/.test(e)||/\[[^\]]*\]\([^)]*$/.test(e)):!0}function Po(e,t){const n=e.match(t);return((n==null?void 0:n.length)??0)%2!==0}function qk(e){if(!e)return 0;for(let t=e.length;t>=0;t-=1)if(hm(e.slice(0,t)))return t;return 0}function Gk(e){return e.type==="text"&&!!e.__streamingMarkdownAggregate}const Yk=Ur.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 mm({className:e,variant:t,...n}){return c.jsx("div",{className:ne(Yk({variant:t}),e),...n})}function Xk({showTimestamp:e,showAgentName:t,isToolMessage:n,iconForeground:r,agentName:o,messageIcon:s,customHeaderClass:i,customActionsClass:a,isCompactLayout:l,showActions:u,isEditing:d,messageRole:f,toolViewMode:m,toolMeta:p,onToggleToolView:b,onCopy:g,onEdit:x,onRegenerate:y,showCheckpointControls:w,attemptCount:S,attemptIndex:k,handleOlderAttemptSelect:C,handleNewerAttemptSelect:T,messageCreatedAt:E,copied:j}){return!e&&!t&&!n?null:c.jsxs("div",{className:ne("flex items-center justify-between mb-2 pb-2 border-b border-current/10",l&&"mb-1 pb-1",r,i),children:[c.jsxs("div",{className:"flex items-center gap-2",children:[s,t&&o&&c.jsx("span",{className:ne("font-medium",l?"text-xs":"text-sm"),children:o}),n&&c.jsxs(mm,{variant:"outline",className:ne("text-xs flex items-center gap-1 cursor-pointer select-none",r,"border border-current/40",l&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":m==="expanded",onClick:b,onKeyDown:_=>{(_.key==="Enter"||_.key===" ")&&(_.preventDefault(),b())},children:[c.jsx("span",{children:p.name??"Tool Output"}),p.toolCallId&&c.jsx("span",{className:"opacity-70",children:p.toolCallId.slice(0,8)}),m==="expanded"?c.jsx(ae.ChevronUp,{className:"h-3 w-3"}):c.jsx(ae.ChevronDown,{className:"h-3 w-3"})]})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[w&&S>1&&c.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[c.jsx("button",{type:"button",className:ne("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",k<S-1?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{k>=S-1||C()},"aria-label":"Older attempt (back in time)",disabled:k>=S-1,children:c.jsx(ae.ChevronLeft,{className:"h-3 w-3"})}),c.jsx("div",{className:"flex items-center gap-2",children:c.jsxs("span",{className:"whitespace-nowrap",children:[S-k," / ",S]})}),c.jsx("button",{type:"button",className:ne("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",k>0?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{k<=0||T()},"aria-label":"Newer attempt (forward in time)",disabled:k<=0,children:c.jsx(ae.ChevronRight,{className:"h-3 w-3"})})]}),e&&E&&c.jsx("time",{className:ne("text-xs opacity-60",r,l&&"text-xs"),dateTime:new Date(E).toISOString(),title:new Date(E).toLocaleString(),children:new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(new Date(E))}),u&&!d&&c.jsxs("div",{className:ne("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",a),children:[c.jsx("div",{className:"relative",children:c.jsx(Je,{variant:"ghost",size:"sm",onClick:g,className:ne("h-6 w-6 p-0 hover:bg-foreground/10",r,l&&"h-5 w-5"),"aria-label":"Copy message",title:"Copy message",children:c.jsx(ae.Copy,{className:ne(j?"text-success":r,l?"h-3 w-3":"h-4 w-4")})})}),f==="user"&&x&&c.jsx(Je,{variant:"ghost",size:"sm",onClick:x,className:ne("h-6 w-6 p-0 hover:bg-foreground/10",r,l&&"h-5 w-5"),"aria-label":"Edit message",children:c.jsx(ae.Edit,{className:ne(r,l?"h-3 w-3":"h-4 w-4")})}),f==="assistant"&&y&&c.jsx(Je,{variant:"ghost",size:"sm",onClick:y,className:ne("h-6 w-6 p-0 hover:bg-foreground/10",r,l&&"h-5 w-5"),"aria-label":"Regenerate response",children:c.jsx(ae.RotateCcw,{className:ne(r,l?"h-3 w-3":"h-4 w-4")})})]})]})]})}const ri=v.memo(function({message:t,messageIndex:n,isStreamingMessage:r=!1,isEditing:o=!1,showActions:s=!0,showTimestamp:i=!0,showAgentName:a=!0,layoutSize:l="desktop",truncateUserMessages:u=!0,userMessagePreviewLength:d=500,showToolMessages:f=!0,customStyles:m={},streamingDebounceMs:p=300,renderStreamingMarkdown:b=!1,enableStreamingMarkdownBuffer:g,onEdit:x,onRegenerate:y,onCopy:w,activeInterrupt:S,disableInterruptActions:k=!1,onInterruptActionStart:C,onInterruptActionEnd:T,attemptCount:E=1,attemptIndex:j=0,onSelectCheckpoint:_,attemptMetas:D=[]}){const[F,W]=v.useState(!1),[G,A]=v.useState("preview"),[X,q]=v.useState(!1),{currentThreadId:B}=vr(),{respondToInterrupt:R}=no(),I=l==="phone"||l==="half-screen",H=t.role,Y=H==="tool",P=v.useMemo(()=>t.role==="default_message"?t:null,[t]),O=!!P,M=!(r&&H!=="user"),{uploadingFiles:L,handleFileClick:te,fileViewerOpen:z,currentFileInfo:$,closeFileViewer:ee}=um({allowFileOpen:M,currentThreadId:B}),J=v.useMemo(()=>{switch(H){case"user":return"text-[hsl(var(--chat-bubble-user-text))]";case"assistant":return"text-[hsl(var(--chat-bubble-ai-text))]";case"tool":return"text-secondary-foreground";case"system":return"text-muted-foreground";default:return"text-[hsl(var(--chat-bubble-ai-text))]"}},[H]),K=dm(t,P),{contentParts:Q,imageParts:me,fileParts:de,interruptParts:ge,textContent:we,toolMeta:Te,toolRaw:Ne,isToolStreaming:ke}=K,st=g??p!==0,vt=(S==null?void 0:S.id)??(S==null?void 0:S.interrupt_id),ht=es(vt),We=S==null?void 0:S.value,Le=v.useCallback(async()=>{const Z=Y?Ne:we;async function ce(He){if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function"){await navigator.clipboard.writeText(He);return}if(navigator.clipboard&&typeof navigator.clipboard.write=="function"&&typeof ClipboardItem<"u"){const ve=new Blob([He],{type:"text/plain"});await navigator.clipboard.write([new ClipboardItem({"text/plain":ve})]);return}throw new Error("Clipboard API not supported in this context.")}try{await ce(Z),W(!0),setTimeout(()=>W(!1),2e3),w==null||w(Z)}catch(He){console.error("Failed to copy:",He)}},[Y,Ne,we,w]),Ge=v.useCallback(()=>{if(!x||!t.id)return;const Z=(Y?Ne:we)??"",ce="type"in t&&t.type==="default_message"?void 0:{checkpointId:t.checkpointId??null,checkpointNs:t.checkpointNs??null};x(t.id,Z,ce)},[x,t.id,Y,Ne,we,t]),Me=v.useCallback(()=>{y==null||y(n)},[y,n]),$e=v.useCallback(()=>{A(Z=>Z==="expanded"?"preview":"expanded")},[]),Ze=v.useCallback(()=>{const ce=ne(I?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",J);switch(H){case"user":return c.jsx(ae.User,{className:ce});case"assistant":return c.jsx(ae.Bot,{className:ce});case"tool":return c.jsx(ae.Wrench,{className:ce});default:return c.jsx(ae.Bot,{className:ce})}},[I,J,H]),Nt=v.useCallback(()=>{const Z="group relative mb-4 flex w-full";switch(H){case"user":return ne(Z,"justify-end");case"assistant":case"tool":case"system":return ne(Z,"justify-start");default:return Z}},[H]),it=v.useCallback(()=>{const Z=ne("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",I&&"px-3 py-2 text-sm");if(O)return ne(Z,"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(H){case"user":return ne(Z,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-user))] text-[hsl(var(--chat-bubble-user-text))]","border border-transparent");case"assistant":return ne(Z,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40");case"tool":return ne(Z,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return ne(Z,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return ne(Z,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40")}},[I,O,H]),St=v.useCallback(async Z=>{if(k)return;const ce=es((Z==null?void 0:Z.id)??(Z==null?void 0:Z.interrupt_id));if(!ce){console.warn("Interrupt part missing id",Z);return}try{C==null||C(),await R(ce,!0)}catch(He){console.error("Failed to approve interrupt:",He)}finally{T==null||T()}},[k,T,C,R]),Ct=v.useCallback(async Z=>{if(k)return;const ce=es((Z==null?void 0:Z.id)??(Z==null?void 0:Z.interrupt_id));if(!ce){console.warn("Interrupt part missing id",Z);return}try{C==null||C(),await R(ce,!1)}catch(He){console.error("Failed to reject interrupt:",He)}finally{T==null||T()}},[k,T,C,R]),Tt=c.jsx(Kk,{message:t,isToolMessage:Y,showToolMessages:f,toolViewMode:G,isToolStreaming:ke,contentParts:Q,textContent:we,imageParts:me,fileParts:de,interruptParts:ge,isStreamingMessage:r,defaultMessage:P,enableStreamingMarkdownBuffer:st,renderStreamingMarkdown:b,handleFileClick:te,uploadingFiles:L,handleInterruptApprove:St,handleInterruptReject:Ct,disableInterruptActions:k,messageRole:H,truncateUserMessages:u,userMessagePreviewLength:d,isUserExpanded:X,setIsUserExpanded:q,isCompactLayout:I,activeInterruptId:ht,activeInterruptValue:We,iconForeground:J}),Et=v.useMemo(()=>P?"Assistant":Ob(t),[P,t]),sn=Ze(),At=H==="user"&&(E??1)>1&&typeof _=="function",Vt=(D==null?void 0:D.length)??0,It=Vt>0&&j<Vt-1?D[j+1]:void 0,Fe=Vt>0&&j>0?D[j-1]:void 0,Ve=v.useCallback(()=>{!It||!_||_(It.id,void 0,!!It.isLatestAttempt)},[It,_]),jt=v.useCallback(()=>{!Fe||!_||_(Fe.id,void 0,!!Fe.isLatestAttempt)},[Fe,_]);return Y&&!f?null:O&&P?c.jsx("div",{className:ne(Nt(),m.container),children:c.jsxs("div",{className:ne(it(),m.content),children:[c.jsxs("div",{className:"flex items-center gap-2 mb-2 pb-2 border-b border-current/10",children:[c.jsx(ae.Bot,{className:ne("h-4 w-4",J)}),a&&c.jsx("span",{className:"font-medium text-sm",children:"Assistant"})]}),c.jsx(Gn,{content:P.content,className:"text-current"})]})}):c.jsxs(c.Fragment,{children:[c.jsx("div",{className:ne(Nt(),m.container),children:c.jsxs("div",{className:ne(it(),m.content),children:[c.jsx(Xk,{showTimestamp:i,showAgentName:a,isToolMessage:Y,iconForeground:J,agentName:Et,messageIcon:sn,customHeaderClass:m.header,customActionsClass:m.actions,isCompactLayout:I,showActions:s,isEditing:o,messageRole:H,toolViewMode:G,toolMeta:Te,onToggleToolView:$e,onCopy:Le,onEdit:Ge,onRegenerate:Me,showCheckpointControls:At,attemptCount:E,attemptIndex:j,handleOlderAttemptSelect:Ve,handleNewerAttemptSelect:jt,messageCreatedAt:t.createdAt,copied:F}),c.jsx("div",{className:"relative",children:Tt}),Y&&G==="expanded"&&(Te.toolCallId||Te.name)&&c.jsxs("div",{className:ne("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",I&&"text-xs"),children:[Te.name&&c.jsxs("div",{children:["Function: ",Te.name]}),Te.toolCallId&&c.jsxs("div",{children:["Call ID: ",Te.toolCallId]})]}),!(i||a||Y)&&s&&!o&&c.jsxs("div",{className:ne("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",m.actions),children:[c.jsx(Je,{variant:"ghost",size:"sm",onClick:()=>Le(),className:ne("h-6 w-6 p-0 hover:bg-background/50 text-current",I&&"h-5 w-5"),children:c.jsx(ae.Copy,{className:ne(F?"text-success":"text-current",I?"h-3 w-3":"h-4 w-4")})}),H==="user"&&x&&c.jsx(Je,{variant:"ghost",size:"sm",onClick:Ge,className:ne("h-6 w-6 p-0 hover:bg-background/50 text-current",I&&"h-5 w-5"),children:c.jsx(ae.Edit,{className:ne("text-current",I?"h-3 w-3":"h-4 w-4")})}),H==="assistant"&&y&&c.jsx(Je,{variant:"ghost",size:"sm",onClick:Me,className:ne("h-6 w-6 p-0 hover:bg-background/50 text-current",I&&"h-5 w-5"),children:c.jsx(ae.RotateCcw,{className:ne("text-current",I?"h-3 w-3":"h-4 w-4")})})]})]})}),$&&c.jsx(wh,{isOpen:z,onClose:ee,fileId:$.id,fileName:$.name,mimeType:$.mimeType})]})},(e,t)=>{var l,u,d,f,m,p,b,g;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&Iu(e.message)===Iu(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateUserMessages","userMessagePreviewLength","showToolMessages"].every(x=>e[x]===t[x]),s=((l=e.customStyles)==null?void 0:l.container)===((u=t.customStyles)==null?void 0:u.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)&&((b=e.customStyles)==null?void 0:b.header)===((g=t.customStyles)==null?void 0:g.header);if(!o||!s)return!1;const i=Nu(e.message),a=Nu(t.message);return i.length===a.length});ri.displayName="MessageComponent";const El=v.forwardRef(({messages:e,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onStartReached:a,onEdit:l,onRegenerate:u,onCancelEdit:d,className:f,style:m,emptyMessage:p,followNewMessages:b=!0,isNavigatingCheckpoint:g=!1,onScrollAway:x,onAtBottom:y,activeInterrupt:w,disableInterruptActions:S=!1,onInterruptActionStart:k,onInterruptActionEnd:C,showToolMessages:T=!0,checkpointIndex:E,activeCheckpointId:j,onSelectCheckpoint:_,createSyntheticThinkingMessage:D=!0,forceSyntheticThinking:F=!1},W)=>{const G=v.useRef(null),A=v.useRef(null),X=v.useRef(!1),q=v.useRef(!1),B=v.useMemo(()=>w?e.some(J=>J.role==="default_message"?!1:Array.isArray(J==null?void 0:J.content)&&J.content.some(K=>K&&K.type==="interrupt"&&(K.id??K.interrupt_id)===w.id)):!1,[w,e]),R=v.useMemo(()=>{if(!w||B)return null;const J=w.id&&String(w.id).trim()?String(w.id).trim():"pending-interrupt";let K;const Q=w.value;if(Q&&typeof Q=="object"&&!Array.isArray(Q)){const me=Q.title;typeof me=="string"&&me.trim()&&(K=me.trim())}return{id:`interrupt-${J}`,role:"system",createdAt:new Date().toISOString(),content:[{type:"interrupt",id:J,value:Q,title:K}]}},[w,B]),I=v.useMemo(()=>R?[...e,R]:e,[e,R]),H=v.useMemo(()=>{const J=n&&I.some(Q=>Q.id===n);return D&&(t||F)&&!J&&I.length>0?[...I,{id:"thinking-assistant",role:"assistant",content:[{type:"text",text:""}],createdAt:new Date().toISOString(),__syntheticStreaming:!0}]:I},[I,t,n,D,F]),Y=v.useMemo(()=>T?H:H.filter(J=>(J==null?void 0:J.role)!=="tool"),[H,T]),P=v.useCallback(J=>{x&&x(!J),y&&y(J)},[x,y]),O=v.useMemo(()=>{if(a)return async()=>{if(!X.current){X.current=!0;try{await a()}finally{X.current=!1}}}},[a]),M=v.useMemo(()=>!b||g?!1:"auto",[b,g]),L=v.useMemo(()=>{if(typeof p!="string")return null;const J=p.trim();return!J||Y&&Y.length>0?null:{id:"default-message",role:"default_message",content:J,createdAt:new Date().toISOString()}},[p,Y]),te=["flex h-full flex-col md:flex-row",f].filter(Boolean).join(" "),z=()=>L?c.jsx("div",{className:"p-6 h-full overflow-y-auto",children:c.jsx("div",{className:"w-full max-w-full",children:c.jsx(ri,{message:L,messageIndex:0,isStreamingMessage:!1,showActions:!1,showTimestamp:!1,showAgentName:!0,layoutSize:o,onEdit:()=>{},onRegenerate:()=>{},onCancelEdit:()=>{}})})}):c.jsx("div",{className:"flex h-full items-center justify-center py-8 text-center text-muted-foreground",children:p??"No messages yet. Start a conversation!"}),$=Y.length,ee=$>0;return v.useEffect(()=>{var J,K;if($===0){q.current=!1;return}if(!q.current)if(q.current=!0,G.current&&Y.length>0){const Q=Y.length-1;(K=(J=G.current).scrollToIndex)==null||K.call(J,{index:Q,align:"end",behavior:"auto"})}else A.current&&(A.current.scrollTop=A.current.scrollHeight)},[$,Y.length]),v.useImperativeHandle(W,()=>({scrollToLatest:()=>{var J,K;if(G.current&&Y.length>0){const Q=Y.length-1;(K=(J=G.current).scrollToIndex)==null||K.call(J,{index:Q,align:"end",behavior:"auto"})}else A.current&&(A.current.scrollTop=A.current.scrollHeight)},scrollToTop:()=>{var J,K;G.current&&Y.length>0?(K=(J=G.current).scrollToIndex)==null||K.call(J,{index:0,align:"start",behavior:"auto"}):A.current&&(A.current.scrollTop=0)}}),[Y]),c.jsx("div",{className:te,style:m,children:c.jsx("div",{className:"relative flex-1 min-h-0",children:ee?c.jsx(yT,{ref:J=>{G.current=J},scrollerRef:J=>{A.current=J instanceof HTMLDivElement?J:null},data:Y,followOutput:M,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,startReached:()=>{O&&O()},atBottomStateChange:P,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(J,K)=>Tl(K,J),itemContent:(J,K)=>c.jsx(kl,{message:K,index:J,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onEdit:l,onRegenerate:u,onCancelEdit:d,activeInterrupt:w,disableInterruptActions:S,onInterruptActionStart:k,onInterruptActionEnd:C,showToolMessages:T,checkpointIndex:E,activeCheckpointId:j,onSelectCheckpoint:_})}):z()})})});El.displayName="MessageList";const gm={value:""};function Dr({className:e="",placeholder:t="Type your message...",autoFocus:n=!0,maxHeight:r=void 0,streamingDebounceMs:o=500,streamingThrottleMs:s,followNewMessages:i=!0,enableFileUpload:a=!0,enableExcelUpload:l=!1,enableMessageEditing:u=!0,showToolMessages:d=!0,payloadExtras:f={},customStyles:m={},onMessageSent:p,onExcelUploadSuccess:b,onError:g,defaultMessage:x}){const{api:y}=Zr(),{currentThreadId:w}=vr(),{threadId:S,messages:k,isHistoryLoading:C,isLoading:T,navigateToCheckpoint:E,returnToLatest:j,checkpoint:_,checkpoints:D,interrupt:F,metadata:W,checkpointIndex:G}=no(),{isStreaming:A,error:X,connectionState:q,submit:B,stop:R}=Wi(),I=S??w??null,H=(_==null?void 0:_.id)??null,Y=(_==null?void 0:_.namespace)??null,P=(W==null?void 0:W.assemblingMessageId)??null,O=F,[M,L]=v.useState(!1),[te,z]=v.useState(!1);v.useEffect(()=>{O||L(!1)},[O]);const $=v.useCallback(()=>{L(!0)},[]),ee=v.useCallback(()=>{L(!1)},[]),J=!!O||M,[K,Q]=v.useState(null),[me,de]=v.useState(""),[ge,we]=v.useState(null),[Te,Ne]=v.useState(null),[ke,st]=v.useState(!1),[vt,ht]=v.useState(null),We=v.useRef(!1),[Le,Ge]=v.useState(()=>gm.value),Me=v.useRef(Le),$e=v.useRef(null),Ze=v.useCallback(pe=>{gm.value=pe,Ge(pe)},[]),[Nt,it]=v.useState(!1),St=v.useRef(null),Ct=v.useCallback(pe=>{Ze(pe)},[Ze]);v.useEffect(()=>{A||z(!1)},[A]),v.useEffect(()=>{W!=null&&W.assemblingMessageId&&z(!1)},[W==null?void 0:W.assemblingMessageId]);const[Tt,Et]=v.useState("desktop");v.useEffect(()=>{const pe=()=>{const ye=window.innerWidth;Et(ye<640?"phone":ye<1024?"tablet":"desktop")};return pe(),window.addEventListener("resize",pe),()=>window.removeEventListener("resize",pe)},[]),v.useEffect(()=>{We.current=!1},[I]),v.useEffect(()=>{Me.current=Le},[Le]),v.useEffect(()=>{if(!K){$e.current=null;return}$e.current===null&&($e.current=Me.current),Ze(me??"")},[me,K,Ze]),v.useEffect(()=>{if(x!==void 0){ht(x);return}(async()=>{if(!y.baseUrl){ht(null);return}try{const Oe=(await y.getAgent("default")).uiDefaultMessage||"";ht(Oe||null)}catch(ye){console.warn("Failed to fetch default message:",ye),ht(null)}})()},[y.baseUrl,x]),v.useEffect(()=>{X&&!ke&&(g==null||g(X))},[X,ke,g]);const sn=async(pe,ye)=>{const Oe=pe.trim();if(!(!Oe&&ye.length===0))try{const Ke=K?(ge==null?void 0:ge.checkpointId)??H??void 0:H??void 0,lt=K?(ge==null?void 0:ge.checkpointNs)??Y??void 0:Y??void 0;await B({text:Oe||"",attachments:ye,payload:f},{checkpointId:Ke,checkpointNs:lt,edit:!!K,originalMessageId:K??void 0}),p==null||p(Oe),z(!0),Ze(""),Ne(null),Q(null),de(""),we(null)}catch(Ke){const lt=(Ke==null?void 0:Ke.message)||"Failed to send message";Ne(lt),g==null||g(lt),z(!1)}},At=v.useCallback(async pe=>{await B({attachments:[pe],payload:f},{checkpointId:H??void 0,checkpointNs:Y??void 0}),b==null||b({file:pe})},[H,Y,f,b,B]),Vt=v.useCallback((pe,ye,Oe)=>{u&&($e.current=Le,Q(pe),de(ye),Ze(ye),Ne(null),we({checkpointId:(Oe==null?void 0:Oe.checkpointId)??null,checkpointNs:(Oe==null?void 0:Oe.checkpointNs)??null}))},[Le,u,Ze]),It=v.useCallback(()=>{Q(null),de(""),we(null),Ne(null),Ze($e.current??Le),$e.current=null},[Le,Ze]),Fe=v.useCallback((pe,ye,Oe)=>{Vt(pe,ye,Oe)},[Vt]),Ve=v.useCallback(pe=>{let ye=null;for(let ct=pe-1;ct>=0;ct--)if(k[ct].role==="user"){ye=k[ct];break}if(!ye)return;const Oe=Array.isArray(ye.content)?ye.content:[],lt=Oe.filter(ct=>(ct==null?void 0:ct.type)==="text").map(ct=>ct.text).join("")||(()=>{try{return JSON.stringify(Oe,null,2)}catch{return String(Oe)}})();lt&&B({text:lt,payload:f},{checkpointId:H??void 0,checkpointNs:Y??void 0,edit:!0,originalMessageId:ye.id})},[k,B,H,Y,f]),jt=async pe=>{if(w){it(!0);try{if(!pe){await j(),requestAnimationFrame(()=>{var Ke;(Ke=St.current)==null||Ke.scrollToLatest()});return}const ye=D.find(Ke=>Ke.checkpointId===pe),Oe=(ye==null?void 0:ye.checkpointNs)??null;await E(pe,Oe),requestAnimationFrame(()=>{var Ke;(Ke=St.current)==null||Ke.scrollToTop()})}finally{it(!1)}}},Z=v.useCallback(async(pe,ye,Oe)=>{await jt(Oe?null:pe)},[jt]),ce=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${m.container||""}`,He=`flex-1 min-h-0 min-w-0 max-h-full w-full overflow-hidden overscroll-contain break-words break-anywhere p-4 bg-transparent ${m.messagesArea||""}`,ve=`relative flex-shrink-0 w-full border-t p-4 bg-transparent ${m.inputArea||""}`;return c.jsxs("div",{className:ce,children:[!!X&&!ke&&c.jsxs("div",{className:"flex-shrink-0 bg-red-50 border border-red-200 text-red-800 px-4 py-2 text-sm flex items-center justify-between",children:[c.jsx("span",{children:X}),c.jsx(Je,{variant:"ghost",size:"sm",onClick:()=>st(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:c.jsx(ae.X,{size:16})})]}),c.jsxs("div",{className:`relative ${He}`,style:r?{maxHeight:r}:void 0,children:[c.jsx(El,{ref:St,className:"h-full",style:{height:"100%"},messages:k,isStreaming:A,streamingAssistantId:P,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:Tt,enableMessageEditing:u,editingMessageId:K,onEdit:Fe,onRegenerate:Ve,onCancelEdit:It,emptyMessage:vt??void 0,isNavigatingCheckpoint:Nt,activeInterrupt:O,disableInterruptActions:M,onInterruptActionStart:$,onInterruptActionEnd:ee,showToolMessages:d,checkpointIndex:G,activeCheckpointId:H,onSelectCheckpoint:Z,createSyntheticThinkingMessage:!0,forceSyntheticThinking:te}),(q==="reconnecting"||q==="connecting")&&c.jsx("div",{className:"pointer-events-none absolute top-3 right-3 z-20 rounded-full bg-muted/80 px-3 py-1 text-xs font-medium text-foreground shadow-sm backdrop-blur-sm dark:bg-muted/60",children:c.jsxs("span",{className:"flex items-center gap-2",children:[c.jsx(ae.Loader2,{className:"h-3 w-3 animate-spin"}),q==="reconnecting"?"Reconnecting…":"Connecting…"]})}),q==="error"&&c.jsx("div",{className:"pointer-events-none absolute top-3 right-3 z-20 rounded-full bg-destructive/10 px-3 py-1 text-xs font-semibold text-destructive shadow-sm",children:"Connection lost"}),T&&c.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 bg-background/80 backdrop-blur-sm text-muted-foreground",children:[c.jsx(ae.Loader2,{className:"h-6 w-6 animate-spin"}),c.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading messages…"})]}),(C||Nt)&&c.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 bg-background/80 backdrop-blur-sm text-muted-foreground",children:[c.jsx(ae.Loader2,{className:"h-6 w-6 animate-spin"}),c.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading checkpoint…"})]})]}),c.jsxs("div",{className:ve,children:[K&&c.jsx("div",{className:"mb-3 p-3 bg-blue-50 border border-blue-200 rounded-lg",children:c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(ae.Edit3,{size:16,className:"text-blue-600"}),c.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),c.jsx(Je,{variant:"ghost",size:"sm",onClick:It,className:"text-blue-600 hover:bg-blue-100",children:c.jsx(ae.X,{size:16})})]})}),Te&&c.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:Te}),c.jsx(dC,{composerValue:Le,onComposerChange:Ct,onSend:sn,onCancelEdit:It,onStop:R,editingMessageId:K,editingInitialValue:me,placeholder:K?"Edit your message...":t,isStreaming:A,disabled:J,enableFileUpload:a,enableExcelUpload:l,onExcelUpload:At,onError:g,customStyles:m,textareaClassName:m.textarea||"",allowEmptySend:!1,inputError:Te})]})]})}var xm=1,Jk=.9,Zk=.8,Qk=.17,Il=.1,Nl=.999,eE=.9999,tE=.99,nE=/[\\\/_+.#"@\[\(\{&]/,rE=/[\\\/_+.#"@\[\(\{&]/g,oE=/[\s-]/,vm=/[\s-]/g;function Al(e,t,n,r,o,s,i){if(s===t.length)return o===e.length?xm:tE;var a=`${o},${s}`;if(i[a]!==void 0)return i[a];for(var l=r.charAt(s),u=n.indexOf(l,o),d=0,f,m,p,b;u>=0;)f=Al(e,t,n,r,u+1,s+1,i),f>d&&(u===o?f*=xm:nE.test(e.charAt(u-1))?(f*=Zk,p=e.slice(o,u-1).match(rE),p&&o>0&&(f*=Math.pow(Nl,p.length))):oE.test(e.charAt(u-1))?(f*=Jk,b=e.slice(o,u-1).match(vm),b&&o>0&&(f*=Math.pow(Nl,b.length))):(f*=Qk,o>0&&(f*=Math.pow(Nl,u-o))),e.charAt(u)!==t.charAt(s)&&(f*=eE)),(f<Il&&n.charAt(u-1)===r.charAt(s+1)||r.charAt(s+1)===r.charAt(s)&&n.charAt(u-1)!==r.charAt(s))&&(m=Al(e,t,n,r,u+1,s+2,i),m*Il>f&&(f=m*Il)),f>d&&(d=f),u=n.indexOf(l,u+1);return i[a]=d,d}function bm(e){return e.toLowerCase().replace(vm," ")}function sE(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,Al(e,t,bm(e),bm(t),0,0,{})}var Ro='[cmdk-group=""]',jl='[cmdk-group-items=""]',iE='[cmdk-group-heading=""]',wm='[cmdk-item=""]',ym=`${wm}:not([aria-disabled="true"])`,_l="cmdk-item-select",Lr="data-value",aE=(e,t,n)=>sE(e,t,n),Sm=h.createContext(void 0),Mo=()=>h.useContext(Sm),Cm=h.createContext(void 0),Pl=()=>h.useContext(Cm),Tm=h.createContext(void 0),km=h.forwardRef((e,t)=>{let n=$r(()=>{var P,O;return{search:"",value:(O=(P=e.value)!=null?P:e.defaultValue)!=null?O:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=$r(()=>new Set),o=$r(()=>new Map),s=$r(()=>new Map),i=$r(()=>new Set),a=Em(e),{label:l,children:u,value:d,onValueChange:f,filter:m,shouldFilter:p,loop:b,disablePointerSelection:g=!1,vimBindings:x=!0,...y}=e,w=kt(),S=kt(),k=kt(),C=h.useRef(null),T=vE();dr(()=>{if(d!==void 0){let P=d.trim();n.current.value=P,E.emit()}},[d]),dr(()=>{T(6,G)},[]);let E=h.useMemo(()=>({subscribe:P=>(i.current.add(P),()=>i.current.delete(P)),snapshot:()=>n.current,setState:(P,O,M)=>{var L,te,z,$;if(!Object.is(n.current[P],O)){if(n.current[P]=O,P==="search")W(),D(),T(1,F);else if(P==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let ee=document.getElementById(k);ee?ee.focus():(L=document.getElementById(w))==null||L.focus()}if(T(7,()=>{var ee;n.current.selectedItemId=(ee=A())==null?void 0:ee.id,E.emit()}),M||T(5,G),((te=a.current)==null?void 0:te.value)!==void 0){let ee=O??"";($=(z=a.current).onValueChange)==null||$.call(z,ee);return}}E.emit()}},emit:()=>{i.current.forEach(P=>P())}}),[]),j=h.useMemo(()=>({value:(P,O,M)=>{var L;O!==((L=s.current.get(P))==null?void 0:L.value)&&(s.current.set(P,{value:O,keywords:M}),n.current.filtered.items.set(P,_(O,M)),T(2,()=>{D(),E.emit()}))},item:(P,O)=>(r.current.add(P),O&&(o.current.has(O)?o.current.get(O).add(P):o.current.set(O,new Set([P]))),T(3,()=>{W(),D(),n.current.value||F(),E.emit()}),()=>{s.current.delete(P),r.current.delete(P),n.current.filtered.items.delete(P);let M=A();T(4,()=>{W(),(M==null?void 0:M.getAttribute("id"))===P&&F(),E.emit()})}),group:P=>(o.current.has(P)||o.current.set(P,new Set),()=>{s.current.delete(P),o.current.delete(P)}),filter:()=>a.current.shouldFilter,label:l||e["aria-label"],getDisablePointerSelection:()=>a.current.disablePointerSelection,listId:w,inputId:k,labelId:S,listInnerRef:C}),[]);function _(P,O){var M,L;let te=(L=(M=a.current)==null?void 0:M.filter)!=null?L:aE;return P?te(P,n.current.search,O):0}function D(){if(!n.current.search||a.current.shouldFilter===!1)return;let P=n.current.filtered.items,O=[];n.current.filtered.groups.forEach(L=>{let te=o.current.get(L),z=0;te.forEach($=>{let ee=P.get($);z=Math.max(ee,z)}),O.push([L,z])});let M=C.current;X().sort((L,te)=>{var z,$;let ee=L.getAttribute("id"),J=te.getAttribute("id");return((z=P.get(J))!=null?z:0)-(($=P.get(ee))!=null?$:0)}).forEach(L=>{let te=L.closest(jl);te?te.appendChild(L.parentElement===te?L:L.closest(`${jl} > *`)):M.appendChild(L.parentElement===M?L:L.closest(`${jl} > *`))}),O.sort((L,te)=>te[1]-L[1]).forEach(L=>{var te;let z=(te=C.current)==null?void 0:te.querySelector(`${Ro}[${Lr}="${encodeURIComponent(L[0])}"]`);z==null||z.parentElement.appendChild(z)})}function F(){let P=X().find(M=>M.getAttribute("aria-disabled")!=="true"),O=P==null?void 0:P.getAttribute(Lr);E.setState("value",O||void 0)}function W(){var P,O,M,L;if(!n.current.search||a.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let te=0;for(let z of r.current){let $=(O=(P=s.current.get(z))==null?void 0:P.value)!=null?O:"",ee=(L=(M=s.current.get(z))==null?void 0:M.keywords)!=null?L:[],J=_($,ee);n.current.filtered.items.set(z,J),J>0&&te++}for(let[z,$]of o.current)for(let ee of $)if(n.current.filtered.items.get(ee)>0){n.current.filtered.groups.add(z);break}n.current.filtered.count=te}function G(){var P,O,M;let L=A();L&&(((P=L.parentElement)==null?void 0:P.firstChild)===L&&((M=(O=L.closest(Ro))==null?void 0:O.querySelector(iE))==null||M.scrollIntoView({block:"nearest"})),L.scrollIntoView({block:"nearest"}))}function A(){var P;return(P=C.current)==null?void 0:P.querySelector(`${wm}[aria-selected="true"]`)}function X(){var P;return Array.from(((P=C.current)==null?void 0:P.querySelectorAll(ym))||[])}function q(P){let O=X()[P];O&&E.setState("value",O.getAttribute(Lr))}function B(P){var O;let M=A(),L=X(),te=L.findIndex($=>$===M),z=L[te+P];(O=a.current)!=null&&O.loop&&(z=te+P<0?L[L.length-1]:te+P===L.length?L[0]:L[te+P]),z&&E.setState("value",z.getAttribute(Lr))}function R(P){let O=A(),M=O==null?void 0:O.closest(Ro),L;for(;M&&!L;)M=P>0?gE(M,Ro):xE(M,Ro),L=M==null?void 0:M.querySelector(ym);L?E.setState("value",L.getAttribute(Lr)):B(P)}let I=()=>q(X().length-1),H=P=>{P.preventDefault(),P.metaKey?I():P.altKey?R(1):B(1)},Y=P=>{P.preventDefault(),P.metaKey?q(0):P.altKey?R(-1):B(-1)};return h.createElement(he.div,{ref:t,tabIndex:-1,...y,"cmdk-root":"",onKeyDown:P=>{var O;(O=y.onKeyDown)==null||O.call(y,P);let M=P.nativeEvent.isComposing||P.keyCode===229;if(!(P.defaultPrevented||M))switch(P.key){case"n":case"j":{x&&P.ctrlKey&&H(P);break}case"ArrowDown":{H(P);break}case"p":case"k":{x&&P.ctrlKey&&Y(P);break}case"ArrowUp":{Y(P);break}case"Home":{P.preventDefault(),q(0);break}case"End":{P.preventDefault(),I();break}case"Enter":{P.preventDefault();let L=A();if(L){let te=new Event(_l);L.dispatchEvent(te)}}}}},h.createElement("label",{"cmdk-label":"",htmlFor:j.inputId,id:j.labelId,style:wE},l),oi(e,P=>h.createElement(Cm.Provider,{value:E},h.createElement(Sm.Provider,{value:j},P))))}),lE=h.forwardRef((e,t)=>{var n,r;let o=kt(),s=h.useRef(null),i=h.useContext(Tm),a=Mo(),l=Em(e),u=(r=(n=l.current)==null?void 0:n.forceMount)!=null?r:i==null?void 0:i.forceMount;dr(()=>{if(!u)return a.item(o,i==null?void 0:i.id)},[u]);let d=Im(o,s,[e.value,e.children,s],e.keywords),f=Pl(),m=Yn(T=>T.value&&T.value===d.current),p=Yn(T=>u||a.filter()===!1?!0:T.search?T.filtered.items.get(o)>0:!0);h.useEffect(()=>{let T=s.current;if(!(!T||e.disabled))return T.addEventListener(_l,b),()=>T.removeEventListener(_l,b)},[p,e.onSelect,e.disabled]);function b(){var T,E;g(),(E=(T=l.current).onSelect)==null||E.call(T,d.current)}function g(){f.setState("value",d.current,!0)}if(!p)return null;let{disabled:x,value:y,onSelect:w,forceMount:S,keywords:k,...C}=e;return h.createElement(he.div,{ref:Ln(s,t),...C,id:o,"cmdk-item":"",role:"option","aria-disabled":!!x,"aria-selected":!!m,"data-disabled":!!x,"data-selected":!!m,onPointerMove:x||a.getDisablePointerSelection()?void 0:g,onClick:x?void 0:b},e.children)}),cE=h.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:o,...s}=e,i=kt(),a=h.useRef(null),l=h.useRef(null),u=kt(),d=Mo(),f=Yn(p=>o||d.filter()===!1?!0:p.search?p.filtered.groups.has(i):!0);dr(()=>d.group(i),[]),Im(i,a,[e.value,e.heading,l]);let m=h.useMemo(()=>({id:i,forceMount:o}),[o]);return h.createElement(he.div,{ref:Ln(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:u},n),oi(e,p=>h.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?u:void 0},h.createElement(Tm.Provider,{value:m},p))))}),uE=h.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,o=h.useRef(null),s=Yn(i=>!i.search);return!n&&!s?null:h.createElement(he.div,{ref:Ln(o,t),...r,"cmdk-separator":"",role:"separator"})}),dE=h.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,o=e.value!=null,s=Pl(),i=Yn(u=>u.search),a=Yn(u=>u.selectedItemId),l=Mo();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:u=>{o||s.setState("search",u.target.value),n==null||n(u.target.value)}})}),fE=h.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...o}=e,s=h.useRef(null),i=h.useRef(null),a=Yn(u=>u.selectedItemId),l=Mo();return h.useEffect(()=>{if(i.current&&s.current){let u=i.current,d=s.current,f,m=new ResizeObserver(()=>{f=requestAnimationFrame(()=>{let p=u.offsetHeight;d.style.setProperty("--cmdk-list-height",p.toFixed(1)+"px")})});return m.observe(u),()=>{cancelAnimationFrame(f),m.unobserve(u)}}},[]),h.createElement(he.div,{ref:Ln(s,t),...o,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":a,"aria-label":r,id:l.listId},oi(e,u=>h.createElement("div",{ref:Ln(i,l.listInnerRef),"cmdk-list-sizer":""},u)))}),pE=h.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:o,contentClassName:s,container:i,...a}=e;return h.createElement(ol,{open:n,onOpenChange:r},h.createElement(sl,{container:i},h.createElement(No,{"cmdk-overlay":"",className:o}),h.createElement(Ao,{"aria-label":e.label,"cmdk-dialog":"",className:s},h.createElement(km,{ref:t,...a}))))}),hE=h.forwardRef((e,t)=>Yn(n=>n.filtered.count===0)?h.createElement(he.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),mE=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},oi(e,i=>h.createElement("div",{"aria-hidden":!0},i)))}),Ut=Object.assign(km,{List:fE,Item:lE,Input:dE,Group:cE,Separator:uE,Dialog:pE,Empty:hE,Loading:mE});function gE(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function xE(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function Em(e){let t=h.useRef(e);return dr(()=>{t.current=e}),t}var dr=typeof window>"u"?h.useEffect:h.useLayoutEffect;function $r(e){let t=h.useRef();return t.current===void 0&&(t.current=e()),t}function Yn(e){let t=Pl(),n=()=>e(t.snapshot());return h.useSyncExternalStore(t.subscribe,n,n)}function Im(e,t,n,r=[]){let o=h.useRef(),s=Mo();return dr(()=>{var i;let a=(()=>{var u;for(let d of n){if(typeof d=="string")return d.trim();if(typeof d=="object"&&"current"in d)return d.current?(u=d.current.textContent)==null?void 0:u.trim():o.current}})(),l=r.map(u=>u.trim());s.value(e,a,l),(i=t.current)==null||i.setAttribute(Lr,a),o.current=a}),o}var vE=()=>{let[e,t]=h.useState(),n=$r(()=>new Map);return dr(()=>{n.current.forEach(r=>r()),n.current=new Map},[e]),(r,o)=>{n.current.set(r,o),t({})}};function bE(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function oi({asChild:e,children:t},n){return e&&h.isValidElement(t)?h.cloneElement(bE(t),{ref:t.ref},n(t.props.children)):n(t)}var wE={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const Rl=h.forwardRef(({className:e,...t},n)=>c.jsx(Ut,{ref:n,className:ne("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));Rl.displayName=Ut.displayName;const Ml=h.forwardRef(({className:e,...t},n)=>c.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[c.jsx(ae.Search,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),c.jsx(Ut.Input,{ref:n,className:ne("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),...t})]}));Ml.displayName=Ut.Input.displayName;const Ol=h.forwardRef(({className:e,...t},n)=>c.jsx(Ut.List,{ref:n,className:ne("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));Ol.displayName=Ut.List.displayName;const Dl=h.forwardRef((e,t)=>c.jsx(Ut.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));Dl.displayName=Ut.Empty.displayName;const Ll=h.forwardRef(({className:e,...t},n)=>c.jsx(Ut.Group,{ref:n,className:ne("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",e),...t}));Ll.displayName=Ut.Group.displayName;const yE=h.forwardRef(({className:e,...t},n)=>c.jsx(Ut.Separator,{ref:n,className:ne("-mx-1 h-px bg-border",e),...t}));yE.displayName=Ut.Separator.displayName;const $l=h.forwardRef(({className:e,...t},n)=>c.jsx(Ut.Item,{ref:n,className:ne("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected='true']:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50",e),...t}));$l.displayName=Ut.Item.displayName;function Fl(e,[t,n]){return Math.min(n,Math.max(t,e))}function SE(e,t){return h.useReducer((n,r)=>t[n][r]??n,e)}var Bl="ScrollArea",[Nm,B1]=Xt(Bl),[CE,on]=Nm(Bl),Am=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,l]=h.useState(null),[u,d]=h.useState(null),[f,m]=h.useState(null),[p,b]=h.useState(null),[g,x]=h.useState(null),[y,w]=h.useState(0),[S,k]=h.useState(0),[C,T]=h.useState(!1),[E,j]=h.useState(!1),_=_e(t,F=>l(F)),D=so(o);return c.jsx(CE,{scope:n,type:r,dir:D,scrollHideDelay:s,scrollArea:a,viewport:u,onViewportChange:d,content:f,onContentChange:m,scrollbarX:p,onScrollbarXChange:b,scrollbarXEnabled:C,onScrollbarXEnabledChange:T,scrollbarY:g,onScrollbarYChange:x,scrollbarYEnabled:E,onScrollbarYEnabledChange:j,onCornerWidthChange:w,onCornerHeightChange:k,children:c.jsx(he.div,{dir:D,...i,ref:_,style:{position:"relative","--radix-scroll-area-corner-width":y+"px","--radix-scroll-area-corner-height":S+"px",...e.style}})})});Am.displayName=Bl;var jm="ScrollAreaViewport",_m=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=on(jm,n),a=h.useRef(null),l=_e(t,a,i.onViewportChange);return c.jsxs(c.Fragment,{children:[c.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:o}),c.jsx(he.div,{"data-radix-scroll-area-viewport":"",...s,ref:l,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:c.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});_m.displayName=jm;var Nn="ScrollAreaScrollbar",zl=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=on(Nn,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"?c.jsx(TE,{...r,ref:t,forceMount:n}):o.type==="scroll"?c.jsx(kE,{...r,ref:t,forceMount:n}):o.type==="auto"?c.jsx(Pm,{...r,ref:t,forceMount:n}):o.type==="always"?c.jsx(Hl,{...r,ref:t}):null});zl.displayName=Nn;var TE=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=on(Nn,e.__scopeScrollArea),[s,i]=h.useState(!1);return h.useEffect(()=>{const a=o.scrollArea;let l=0;if(a){const u=()=>{window.clearTimeout(l),i(!0)},d=()=>{l=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",u),a.addEventListener("pointerleave",d),()=>{window.clearTimeout(l),a.removeEventListener("pointerenter",u),a.removeEventListener("pointerleave",d)}}},[o.scrollArea,o.scrollHideDelay]),c.jsx(Dt,{present:n||s,children:c.jsx(Pm,{"data-state":s?"visible":"hidden",...r,ref:t})})}),kE=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=on(Nn,e.__scopeScrollArea),s=e.orientation==="horizontal",i=li(()=>l("SCROLL_END"),100),[a,l]=SE("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 u=window.setTimeout(()=>l("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(u)}},[a,o.scrollHideDelay,l]),h.useEffect(()=>{const u=o.viewport,d=s?"scrollLeft":"scrollTop";if(u){let f=u[d];const m=()=>{const p=u[d];f!==p&&(l("SCROLL"),i()),f=p};return u.addEventListener("scroll",m),()=>u.removeEventListener("scroll",m)}},[o.viewport,s,l,i]),c.jsx(Dt,{present:n||a!=="hidden",children:c.jsx(Hl,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:ie(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:ie(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),Pm=h.forwardRef((e,t)=>{const n=on(Nn,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=h.useState(!1),a=e.orientation==="horizontal",l=li(()=>{if(n.viewport){const u=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?u:d)}},10);return Fr(n.viewport,l),Fr(n.content,l),c.jsx(Dt,{present:r||s,children:c.jsx(Hl,{"data-state":s?"visible":"hidden",...o,ref:t})})}),Hl=h.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=on(Nn,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}}),u=Lm(a.viewport,a.content),d={...r,sizes:a,onSizesChange:l,hasThumb:u>0&&u<1,onThumbChange:m=>s.current=m,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:m=>i.current=m};function f(m,p){return _E(m,i.current,a,p)}return n==="horizontal"?c.jsx(EE,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollLeft,p=$m(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"?c.jsx(IE,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollTop,p=$m(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}),EE=h.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=on(Nn,e.__scopeScrollArea),[i,a]=h.useState(),l=h.useRef(null),u=_e(t,l,s.onScrollbarXChange);return h.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),c.jsx(Mm,{"data-orientation":"horizontal",...o,ref:u,sizes:n,style:{bottom:0,left:s.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:s.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":ai(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),Bm(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:ii(i.paddingLeft),paddingEnd:ii(i.paddingRight)}})}})}),IE=h.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=on(Nn,e.__scopeScrollArea),[i,a]=h.useState(),l=h.useRef(null),u=_e(t,l,s.onScrollbarYChange);return h.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),c.jsx(Mm,{"data-orientation":"vertical",...o,ref:u,sizes:n,style:{top:0,right:s.dir==="ltr"?0:void 0,left:s.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":ai(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),Bm(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:ii(i.paddingTop),paddingEnd:ii(i.paddingBottom)}})}})}),[NE,Rm]=Nm(Nn),Mm=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:l,onDragScroll:u,onWheelScroll:d,onResize:f,...m}=e,p=on(Nn,n),[b,g]=h.useState(null),x=_e(t,_=>g(_)),y=h.useRef(null),w=h.useRef(""),S=p.viewport,k=r.content-r.viewport,C=ft(d),T=ft(l),E=li(f,10);function j(_){if(y.current){const D=_.clientX-y.current.left,F=_.clientY-y.current.top;u({x:D,y:F})}}return h.useEffect(()=>{const _=D=>{const F=D.target;(b==null?void 0:b.contains(F))&&C(D,k)};return document.addEventListener("wheel",_,{passive:!1}),()=>document.removeEventListener("wheel",_,{passive:!1})},[S,b,k,C]),h.useEffect(T,[r,T]),Fr(b,E),Fr(p.content,E),c.jsx(NE,{scope:n,scrollbar:b,hasThumb:o,onThumbChange:ft(s),onThumbPointerUp:ft(i),onThumbPositionChange:T,onThumbPointerDown:ft(a),children:c.jsx(he.div,{...m,ref:x,style:{position:"absolute",...m.style},onPointerDown:ie(e.onPointerDown,_=>{_.button===0&&(_.target.setPointerCapture(_.pointerId),y.current=b.getBoundingClientRect(),w.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",p.viewport&&(p.viewport.style.scrollBehavior="auto"),j(_))}),onPointerMove:ie(e.onPointerMove,j),onPointerUp:ie(e.onPointerUp,_=>{const D=_.target;D.hasPointerCapture(_.pointerId)&&D.releasePointerCapture(_.pointerId),document.body.style.webkitUserSelect=w.current,p.viewport&&(p.viewport.style.scrollBehavior=""),y.current=null})})})}),si="ScrollAreaThumb",Om=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Rm(si,e.__scopeScrollArea);return c.jsx(Dt,{present:n||o.hasThumb,children:c.jsx(AE,{ref:t,...r})})}),AE=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=on(si,n),i=Rm(si,n),{onThumbPositionChange:a}=i,l=_e(t,f=>i.onThumbChange(f)),u=h.useRef(void 0),d=li(()=>{u.current&&(u.current(),u.current=void 0)},100);return h.useEffect(()=>{const f=s.viewport;if(f){const m=()=>{if(d(),!u.current){const p=PE(f,a);u.current=p,a()}};return a(),f.addEventListener("scroll",m),()=>f.removeEventListener("scroll",m)}},[s.viewport,d,a]),c.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:ie(e.onPointerDownCapture,f=>{const p=f.target.getBoundingClientRect(),b=f.clientX-p.left,g=f.clientY-p.top;i.onThumbPointerDown({x:b,y:g})}),onPointerUp:ie(e.onPointerUp,i.onThumbPointerUp)})});Om.displayName=si;var Ul="ScrollAreaCorner",Dm=h.forwardRef((e,t)=>{const n=on(Ul,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?c.jsx(jE,{...e,ref:t}):null});Dm.displayName=Ul;var jE=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=on(Ul,n),[s,i]=h.useState(0),[a,l]=h.useState(0),u=!!(s&&a);return Fr(o.scrollbarX,()=>{var f;const d=((f=o.scrollbarX)==null?void 0:f.offsetHeight)||0;o.onCornerHeightChange(d),l(d)}),Fr(o.scrollbarY,()=>{var f;const d=((f=o.scrollbarY)==null?void 0:f.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),u?c.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 ii(e){return e?parseInt(e,10):0}function Lm(e,t){const n=e/t;return isNaN(n)?0:n}function ai(e){const t=Lm(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function _E(e,t,n,r="ltr"){const o=ai(n),s=o/2,i=t||s,a=o-i,l=n.scrollbar.paddingStart+i,u=n.scrollbar.size-n.scrollbar.paddingEnd-a,d=n.content-n.viewport,f=r==="ltr"?[0,d]:[d*-1,0];return Fm([l,u],f)(e)}function $m(e,t,n="ltr"){const r=ai(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,s=t.scrollbar.size-o,i=t.content-t.viewport,a=s-r,l=n==="ltr"?[0,i]:[i*-1,0],u=Fl(e,l);return Fm([0,i],[0,a])(u)}function Fm(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 Bm(e,t){return e>0&&e<t}var PE=(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 li(e,t){const n=ft(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 Fr(e,t){const n=ft(t);wt(()=>{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 zm=Am,RE=_m,ME=Dm;const Wl=h.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(zm,{ref:r,className:ne("relative overflow-hidden",e),...n,children:[c.jsx(RE,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),c.jsx(Hm,{}),c.jsx(ME,{})]}));Wl.displayName=zm.displayName;const Hm=h.forwardRef(({className:e,orientation:t="vertical",...n},r)=>c.jsx(zl,{ref:r,orientation:t,className:ne("flex touch-none select-none transition-colors",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...n,children:c.jsx(Om,{className:"relative flex-1 rounded-full bg-border"})}));Hm.displayName=zl.displayName;const Vl=h.forwardRef(({className:e,type:t,...n},r)=>c.jsx("input",{type:t,className:ne("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:r,...n}));Vl.displayName="Input";const OE="group relative p-3 rounded-lg cursor-pointer transition-colors border text-gray-900 dark:text-slate-100",DE="bg-slate-700 border-slate-600 hover:bg-slate-600",LE="bg-slate-600 border-slate-500";function Um({thread:e,isActive:t,editingThreadId:n,editingTitle:r,onSelect:o,onStartEditing:s,onEditingTitleChange:i,onSaveEditing:a,onCancelEditing:l,onShare:u,onDelete:d,showEditTitle:f,showDeleteButton:m,formatDate:p,getDisplayThreadTitle:b,secondaryLine:g,itemClassName:x,activeItemClassName:y}){const w=n===e.threadId,S=t?`${y??LE}`:`${x??DE}`,k=C=>{C.stopPropagation(),o(e.threadId)};return c.jsxs("div",{onClick:k,className:`${OE} ${S}`,children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("div",{className:"flex-1 min-w-0",children:w?c.jsxs("div",{className:"flex items-center gap-2",onClick:C=>C.stopPropagation(),children:[c.jsx(Vl,{value:r,onChange:C=>i(C.target.value),onKeyDown:C=>{C.key==="Enter"?a(e.threadId):C.key==="Escape"&&l()},className:"h-6 text-sm",autoFocus:!0}),c.jsx(Je,{variant:"ghost",size:"sm",onClick:()=>a(e.threadId),className:"h-6 w-6 p-0",children:c.jsx(ae.Check,{size:12})}),c.jsx(Je,{variant:"ghost",size:"sm",onClick:l,className:"h-6 w-6 p-0",children:c.jsx(ae.X,{size:12})})]}):c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"font-medium text-sm truncate text-gray-900 dark:text-slate-100",children:b(e)}),c.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-slate-400 mt-1",children:[c.jsx(ae.Calendar,{size:10}),c.jsx("span",{children:p(e.updatedAt||e.createdAt)})]}),g&&c.jsx("div",{className:"text-[11px] text-muted-foreground mt-1",children:g})]})}),c.jsx("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2",children:c.jsxs(Es,{children:[c.jsx(Is,{asChild:!0,children:c.jsx(Je,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",children:c.jsx(ae.MoreHorizontal,{size:12})})}),c.jsxs(xo,{align:"end",sideOffset:6,className:"w-44",children:[c.jsxs(zn,{onClick:C=>{C.preventDefault(),u(e.threadId)},children:[c.jsx(ae.Share2,{className:"mr-2 h-4 w-4"}),"Share thread"]}),f&&n!==e.threadId&&c.jsxs(zn,{onClick:C=>{C.preventDefault(),s(e,C)},children:[c.jsx(ae.Edit3,{className:"mr-2 h-4 w-4"}),"Rename"]}),m&&d&&c.jsxs(zn,{className:"text-red-400 hover:text-red-300",onClick:C=>{C.preventDefault(),d(e.threadId,C)},children:[c.jsx(ae.Trash2,{className:"mr-2 h-4 w-4"}),"Delete"]})]})]})})]}),t&&c.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-1 h-8 bg-blue-400 rounded-r"})]})}const Wm=25,Vm="thread-manager-view",$E=e=>e==="default"||e==="shared",FE=()=>{if(typeof window>"u")return null;try{const e=window.localStorage.getItem(Vm);if($E(e))return e}catch{}return null};function Km({defaultView:e}={}){const[t,n]=v.useState(()=>FE()??e??"default");v.useEffect(()=>{if(!(typeof window>"u"))try{window.localStorage.setItem(Vm,t)}catch{}},[t]);const r=v.useCallback(o=>{n(o)},[]);return{view:t,setView:r}}const BE=[{key:"default",label:"My chats"},{key:"shared",label:"Shared with you"}];function ci({className:e="",showCreateButton:t=!0,showDeleteButton:n=!0,showEditTitle:r=!0,maxHeight:o="400px",customStyles:s={},currentThreadId:i=null,navigateToThread:a,onThreadSelect:l,onThreadCreate:u,onThreadDelete:d,view:f,defaultView:m,onViewChange:p,viewOptions:b,viewState:g,showHeader:x=!0,shareTargets:y,isLoadingShareTargets:w,shareTargetFilter:S}){const{threads:k,sharedThreads:C,currentThreadId:T,setCurrentThreadId:E,isLoading:j,isLoadingSharedThreads:_,actions:D,shareInFlight:F,shareStatus:W,clearShareStatus:G}=vr(),{createThread:A,deleteThread:X,renameThread:q,shareThread:B}=D,{loadThread:R}=no(),I=i??T,[H,Y]=v.useState(Array.isArray(k)?k:[]),P=v.useRef(H.length>0),O=v.useRef(null),M=v.useRef(0),[L,te]=v.useState(null),[z,$]=v.useState(""),[ee,J]=v.useState(!1),[K,Q]=v.useState(!1),[me,de]=v.useState(null),[ge,we]=v.useState(""),Te=b&&b.length>0?b:BE,Ne=Km({defaultView:m}),ke=g??Ne,st=f??ke.view,vt=v.useCallback(Z=>{f||ke.setView(Z),p==null||p(Z)},[f,p,ke]),ht=Te.find(Z=>Z.key===st)??Te[0],We=Z=>{de(Z),we(""),Q(!0)},Le=()=>{Q(!1),de(null),we(""),G()},Ge=v.useCallback(async Z=>{if(!(!me||F)&&Z.id)try{await B(me,Z.id),setTimeout(()=>Le(),600)}catch(ce){console.error("Failed to share thread:",ce)}},[Le,F,me,B]),Me=v.useMemo(()=>{const Z=y??[],ce=ge.trim().toLowerCase();return ce?S?Z.filter(He=>S(He,ce)):Z.filter(He=>`${He.label} ${He.secondaryLabel??""}`.toLowerCase().includes(ce)):Z},[y,ge,S]),$e=st==="shared",Ze=$e?C:H,Nt=$e?_:j,it=$e?"No shared conversations yet":"No conversations yet",St=Z=>{const ce=Z.sharedAt?` • ${Fe(Z.sharedAt)}`:"";return`Shared by ${Z.sharedByUserId}${ce}`},Ct=Z=>"sharedByUserId"in Z;v.useEffect(()=>{const Z=Array.isArray(k)?k:[];if(Z.length>0){P.current=!0,Y(Z);return}j||(P.current=!1,Y(Z))},[k,j]),v.useEffect(()=>{if(!O.current)return;const Z=O.current.querySelector("[data-radix-scroll-area-viewport]");if(!Z)return;let ce=null,He=null;return ce=requestAnimationFrame(()=>{He=requestAnimationFrame(()=>{Z.scrollTop=M.current})}),()=>{ce!==null&&cancelAnimationFrame(ce),He!==null&&cancelAnimationFrame(He)}},[H]);const Tt=async Z=>{try{E(Z),await R(Z),a==null||a(Z),l==null||l(Z)}catch(ce){console.error("Failed to select thread:",ce)}},Et=async()=>{try{J(!0);const Z=await A();Z&&(u==null||u(Z),a==null||a(Z))}catch(Z){console.error("Failed to create thread:",Z)}finally{J(!1)}},sn=async(Z,ce)=>{if(ce.stopPropagation(),!!confirm("Delete this thread?")){if(O.current){const He=O.current.querySelector("[data-radix-scroll-area-viewport]");He&&(M.current=He.scrollTop)}try{await X(Z),d==null||d(Z)}catch(He){console.error("Failed to delete thread:",He)}}},At=(Z,ce)=>{ce.stopPropagation(),te(Z.threadId),$(Z.title||`Thread ${Z.threadId.slice(0,8)}`)},Vt=async Z=>{if(z.trim())try{await q(Z,z.trim()),te(null),$("")}catch(ce){console.error("Failed to update title:",ce)}},It=()=>{te(null),$("")},Fe=Z=>{if(!Z)return"";try{const ce=new Date(Z),ve=new Date().getTime()-ce.getTime(),pe=Math.floor(ve/(1e3*60*60*24));return pe===0?ce.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):pe===1?"Yesterday":pe<7?`${pe} days ago`:ce.toLocaleDateString()}catch{return""}},Ve=Z=>Z.title||`Thread ${Z.threadId.slice(0,8)}`,jt=Z=>{const ce=Ve(Z);return ce.length<=Wm?ce:`${ce.slice(0,Wm)}...`};return c.jsxs("div",{className:`flex flex-col h-full ${e} ${s.container||""}`,children:[x&&c.jsxs("div",{className:s.header||"flex flex-col gap-2 px-1 py-0 border border-slate-200 bg-white dark:border-slate-700 dark:bg-slate-900 shadow-sm",children:[t&&c.jsx("div",{className:"flex justify-end",children:c.jsxs(Je,{onClick:Et,disabled:ee||j,className:s.createButton||"px-3 py-2 gap-1",size:"sm",variant:"ghost",title:ee?"Creating...":"New Chat",children:[c.jsx(ae.Edit3,{size:16}),c.jsx("span",{children:"New chat"})]})}),c.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-slate-700 dark:text-slate-200 uppercase tracking-wide leading-tight",children:[c.jsx("span",{children:"Current View"}),c.jsxs(Es,{children:[c.jsx(Is,{asChild:!0,children:c.jsx(Je,{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:ht.label})}),c.jsx(xo,{align:"start",sideOffset:6,className:"w-40",children:Te.map(Z=>c.jsxs(zn,{className:"justify-between text-[12px]",onClick:ce=>{ce.preventDefault(),vt(Z.key)},children:[c.jsx("span",{children:Z.label}),st===Z.key&&c.jsx(ae.Check,{className:"h-3 w-3"})]},Z.key))})]})]})]}),c.jsx(Wl,{ref:O,className:`flex-1 min-h-0 ${s.threadList||""}`,style:o?{maxHeight:o}:void 0,children:c.jsx("div",{className:"p-2 space-y-1 pb-4",children:Nt?c.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-8 text-slate-400",children:[c.jsx(ae.Loader2,{className:"h-5 w-5 animate-spin"}),c.jsx("span",{className:"text-sm",children:"Loading threads…"})]}):Ze.length===0?c.jsxs("div",{className:"text-center py-8 text-slate-400",children:[c.jsx(ae.MessageSquare,{className:"w-8 h-8 mx-auto mb-2 opacity-40 text-slate-500"}),c.jsx("p",{className:"text-sm text-slate-500",children:it})]}):Ze.slice().sort((Z,ce)=>new Date(ce.updatedAt||ce.createdAt||"").getTime()-new Date(Z.updatedAt||Z.createdAt||"").getTime()).map(Z=>c.jsx(Um,{thread:Z,isActive:I===Z.threadId,editingThreadId:L,editingTitle:z,onSelect:Tt,onStartEditing:At,onEditingTitleChange:ce=>$(ce),onSaveEditing:Vt,onCancelEditing:It,onShare:()=>We(Z.threadId),onDelete:sn,showEditTitle:r,showDeleteButton:n,formatDate:Fe,getDisplayThreadTitle:jt,secondaryLine:$e&&Ct(Z)?St(Z):void 0,itemClassName:s.threadItem,activeItemClassName:s.activeThread},Z.threadId))})}),c.jsx(il,{open:K,onOpenChange:Z=>!Z&&Le(),children:c.jsxs(Ws,{className:"max-w-md p-0",children:[c.jsx(Vs,{children:c.jsx(Ks,{children:"Share thread"})}),c.jsxs(Rl,{children:[c.jsx(Ml,{autoFocus:!0,value:ge,onValueChange:Z=>we(Z),placeholder:"Search for recipients..."}),c.jsxs(Ol,{children:[W&&c.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-xs text-muted-foreground",children:[F&&c.jsx(ae.Loader2,{className:"h-3 w-3 animate-spin"}),c.jsx("span",{className:W.startsWith("Failed")?"text-red-500":W.startsWith("Shared")?"text-emerald-500":"text-slate-600 dark:text-slate-400",children:W})]}),c.jsx(Dl,{children:w?c.jsxs("span",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[c.jsx(ae.Loader2,{className:"h-4 w-4 animate-spin"}),"Loading recipients…"]}):"No matching recipients found"}),Me.length>0&&c.jsx(Ll,{heading:"Recipients",children:Me.map(Z=>c.jsx($l,{onSelect:()=>Ge(Z),children:c.jsxs("div",{className:"flex flex-col items-start text-sm",children:[c.jsx("span",{className:"font-medium",children:Z.label}),Z.secondaryLabel&&c.jsx("span",{className:"text-xs text-muted-foreground",children:Z.secondaryLabel})]})},Z.id))})]})]})]})})]})}function zE({layout:e="sidebar",layoutSize:t="desktop",showThreads:n=!0,className:r="",customStyles:o={},...s}){const i=u=>{const d="h-full";switch(u){case"phone":return`${d} max-w-none`;case"tablet":return`${d} max-w-4xl mx-auto`;case"half-screen":return`${d} max-w-2xl`;case"desktop":default:return`${d} max-w-7xl mx-auto`}},a=u=>({"--chat-sidebar-width":u==="phone"?"100%":u==="tablet"?"280px":u==="half-screen"?"240px":"320px","--chat-message-max-width":u==="phone"?"95%":u==="tablet"?"90%":u==="half-screen"?"85%":"80%","--chat-input-height":u==="phone"?"120px":"100px"}),l=v.useCallback(u=>{var d;(d=s.onThreadChange)==null||d.call(s,u)},[s]);return e==="fullscreen"?c.jsx(yr,{...s,onThreadChange:l,children:c.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:c.jsx(Dr,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?c.jsx(yr,{...s,onThreadChange:l,children:c.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:c.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[n&&c.jsx("div",{className:`w-80 border-r flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:c.jsx(ci,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),c.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:c.jsx(Dr,{onError:s.onError,enableFileUpload:!0})})]})})}):c.jsx(yr,{...s,onThreadChange:l,children:c.jsxs("div",{className:`${i(t)} flex overflow-hidden ${r} ${o.container||""}`,style:a(t),children:[n&&c.jsx("div",{className:`w-80 border-r bg-gray-50 flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:c.jsx(ci,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),c.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:c.jsx(Dr,{onError:s.onError,enableFileUpload:!0})})]})})}function HE({apiConfig:e,className:t="",onError:n}){return c.jsx(yr,{apiConfig:e,onError:n,children:c.jsx("div",{className:`h-full ${t}`,children:c.jsx(Dr,{})})})}function UE({placeholder:e,onMessageSent:t}){const[n,r]=v.useState("chat");return c.jsxs("div",{className:"flex flex-col h-full",children:[c.jsxs("div",{className:"flex border-b border-gray-200 bg-gray-50",children:[c.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:c.jsxs("div",{className:"flex items-center justify-center gap-2",children:[c.jsx(ae.MessageSquare,{size:14}),"Chat"]})}),c.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:c.jsxs("div",{className:"flex items-center justify-center gap-2",children:[c.jsx(ae.History,{size:14}),"History"]})})]}),c.jsx("div",{className:"flex-1 min-h-0",children:n==="chat"?c.jsx(Dr,{placeholder:e??"Ask Serti AI anything...",autoFocus:!0,className:"h-full",onMessageSent:t}):c.jsx(ci,{showCreateButton:!0,className:"h-full",onThreadSelect:()=>r("chat")})})]})}function WE({className:e="",placeholder:t,isAuthenticated:n=!0,onMessageSent:r,widgetTitle:o="Serti AI Navigator",widgetSubtitle:s="AI-Powered Assistant",...i}){const[a,l]=v.useState(!1);return n?c.jsx(yr,{...i,children:c.jsx("div",{className:`fixed bottom-6 right-6 z-[9999] transition-all duration-300 ${e}`,children:c.jsxs("div",{className:`w-96 bg-white rounded-xl shadow-2xl border border-gray-200 overflow-hidden relative ${a?"scale-75":"scale-100"}`,children:[c.jsx("div",{className:"bg-slate-800 text-white p-4 flex-shrink-0",children:c.jsxs("div",{className:"flex items-center justify-between gap-3",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[c.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",c.jsx("span",{className:"absolute -bottom-0.5 -right-0.5 h-3 w-3 rounded-full border-2 border-slate-800 bg-emerald-400"})]}),c.jsxs("div",{className:"flex flex-col",children:[c.jsx("h3",{className:"text-lg font-semibold leading-tight",children:o}),c.jsx("p",{className:"text-xs text-white/70",children:s})]}),c.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"})]}),c.jsxs("div",{className:"flex items-center gap-1",children:[c.jsx(Je,{variant:"ghost",size:"sm",className:"text-white hover:bg-white/10 h-8 w-8 p-0",title:"Options",children:c.jsx(ae.MoreHorizontal,{size:16})}),c.jsx(Je,{variant:"ghost",size:"sm",className:"text-white hover:bg-white/10 h-8 w-8 p-0",title:"Compose",children:c.jsx(ae.Edit3,{size:16})}),c.jsx(Je,{variant:"ghost",size:"sm",onClick:u=>{u.stopPropagation(),l(d=>!d)},className:"text-white hover:bg-white/10 h-8 w-8 p-0",title:a?"Maximize":"Minimize",children:a?c.jsx(ae.Maximize2,{size:14}):c.jsx(ae.Minimize2,{size:14})})]})]})}),!a&&c.jsx("div",{className:"h-96 flex flex-col",children:c.jsx(UE,{placeholder:t,onMessageSent:r})})]})})}):null}function VE({label:e="New chat",children:t,className:n,variant:r="ghost",size:o="sm",...s}){return c.jsxs(Je,{variant:r,size:o,className:ne("gap-2 rounded-full px-3 font-semibold transition-all hover:scale-[1.01]",n),...s,children:[c.jsx(ae.Edit3,{size:16}),t??e]})}var KE="Label",qm=h.forwardRef((e,t)=>c.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())}}));qm.displayName=KE;var Gm=qm;const qE=Ur.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Ym=h.forwardRef(({className:e,...t},n)=>c.jsx(Gm,{ref:n,className:ne(qE(),e),...t}));Ym.displayName=Gm.displayName;function Xm(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 Jm=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"}),GE="VisuallyHidden",ui=h.forwardRef((e,t)=>c.jsx(he.span,{...e,ref:t,style:{...Jm,...e.style}}));ui.displayName=GE;var YE=ui,XE=[" ","Enter","ArrowUp","ArrowDown"],JE=[" ","Enter"],fr="Select",[di,fi,ZE]=oo(fr),[Br,z1]=Xt(fr,[ZE,Nr]),pi=Nr(),[QE,Xn]=Br(fr),[eI,tI]=Br(fr),Zm=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:l,dir:u,name:d,autoComplete:f,disabled:m,required:p,form:b}=e,g=pi(t),[x,y]=h.useState(null),[w,S]=h.useState(null),[k,C]=h.useState(!1),T=so(u),[E,j]=cn({prop:r,defaultProp:o??!1,onChange:s,caller:fr}),[_,D]=cn({prop:i,defaultProp:a,onChange:l,caller:fr}),F=h.useRef(null),W=x?b||!!x.closest("form"):!0,[G,A]=h.useState(new Set),X=Array.from(G).map(q=>q.props.value).join(";");return c.jsx(da,{...g,children:c.jsxs(QE,{required:p,scope:t,trigger:x,onTriggerChange:y,valueNode:w,onValueNodeChange:S,valueNodeHasChildren:k,onValueNodeHasChildrenChange:C,contentId:kt(),value:_,onValueChange:D,open:E,onOpenChange:j,dir:T,triggerPointerDownPosRef:F,disabled:m,children:[c.jsx(di.Provider,{scope:t,children:c.jsx(eI,{scope:e.__scopeSelect,onNativeOptionAdd:h.useCallback(q=>{A(B=>new Set(B).add(q))},[]),onNativeOptionRemove:h.useCallback(q=>{A(B=>{const R=new Set(B);return R.delete(q),R})},[]),children:n})}),W?c.jsxs(Sg,{"aria-hidden":!0,required:p,tabIndex:-1,name:d,autoComplete:f,value:_,onChange:q=>D(q.target.value),disabled:m,form:b,children:[_===void 0?c.jsx("option",{value:""}):null,Array.from(G)]},X):null]})})};Zm.displayName=fr;var Qm="SelectTrigger",eg=h.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=pi(n),i=Xn(Qm,n),a=i.disabled||r,l=_e(t,i.onTriggerChange),u=fi(n),d=h.useRef("touch"),[f,m,p]=Tg(g=>{const x=u().filter(S=>!S.disabled),y=x.find(S=>S.value===i.value),w=kg(x,g,y);w!==void 0&&i.onValueChange(w.value)}),b=g=>{a||(i.onOpenChange(!0),p()),g&&(i.triggerPointerDownPosRef.current={x:Math.round(g.pageX),y:Math.round(g.pageY)})};return c.jsx(fa,{asChild:!0,...s,children:c.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":Cg(i.value)?"":void 0,...o,ref:l,onClick:ie(o.onClick,g=>{g.currentTarget.focus(),d.current!=="mouse"&&b(g)}),onPointerDown:ie(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"&&(b(g),g.preventDefault())}),onKeyDown:ie(o.onKeyDown,g=>{const x=f.current!=="";!(g.ctrlKey||g.altKey||g.metaKey)&&g.key.length===1&&m(g.key),!(x&&g.key===" ")&&XE.includes(g.key)&&(b(),g.preventDefault())})})})});eg.displayName=Qm;var tg="SelectValue",ng=h.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=Xn(tg,n),{onValueNodeHasChildrenChange:u}=l,d=s!==void 0,f=_e(t,l.onValueNodeChange);return wt(()=>{u(d)},[u,d]),c.jsx(he.span,{...a,ref:f,style:{pointerEvents:"none"},children:Cg(l.value)?c.jsx(c.Fragment,{children:i}):s})});ng.displayName=tg;var nI="SelectIcon",rg=h.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return c.jsx(he.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});rg.displayName=nI;var rI="SelectPortal",og=e=>c.jsx(co,{asChild:!0,...e});og.displayName=rI;var pr="SelectContent",sg=h.forwardRef((e,t)=>{const n=Xn(pr,e.__scopeSelect),[r,o]=h.useState();if(wt(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?Wr.createPortal(c.jsx(ig,{scope:e.__scopeSelect,children:c.jsx(di.Slot,{scope:e.__scopeSelect,children:c.jsx("div",{children:e.children})})}),s):null}return c.jsx(ag,{...e,ref:t})});sg.displayName=pr;var gn=10,[ig,Jn]=Br(pr),oI="SelectContentImpl",sI=qt.createSlot("SelectContent.RemoveScroll"),ag=h.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:a,sideOffset:l,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:m,collisionPadding:p,sticky:b,hideWhenDetached:g,avoidCollisions:x,...y}=e,w=Xn(pr,n),[S,k]=h.useState(null),[C,T]=h.useState(null),E=_e(t,z=>k(z)),[j,_]=h.useState(null),[D,F]=h.useState(null),W=fi(n),[G,A]=h.useState(!1),X=h.useRef(!1);h.useEffect(()=>{if(S)return va(S)},[S]),Yi();const q=h.useCallback(z=>{const[$,...ee]=W().map(Q=>Q.ref.current),[J]=ee.slice(-1),K=document.activeElement;for(const Q of z)if(Q===K||(Q==null||Q.scrollIntoView({block:"nearest"}),Q===$&&C&&(C.scrollTop=0),Q===J&&C&&(C.scrollTop=C.scrollHeight),Q==null||Q.focus(),document.activeElement!==K))return},[W,C]),B=h.useCallback(()=>q([j,S]),[q,j,S]);h.useEffect(()=>{G&&B()},[G,B]);const{onOpenChange:R,triggerPointerDownPosRef:I}=w;h.useEffect(()=>{if(S){let z={x:0,y:0};const $=J=>{var K,Q;z={x:Math.abs(Math.round(J.pageX)-(((K=I.current)==null?void 0:K.x)??0)),y:Math.abs(Math.round(J.pageY)-(((Q=I.current)==null?void 0:Q.y)??0))}},ee=J=>{z.x<=10&&z.y<=10?J.preventDefault():S.contains(J.target)||R(!1),document.removeEventListener("pointermove",$),I.current=null};return I.current!==null&&(document.addEventListener("pointermove",$),document.addEventListener("pointerup",ee,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",$),document.removeEventListener("pointerup",ee,{capture:!0})}}},[S,R,I]),h.useEffect(()=>{const z=()=>R(!1);return window.addEventListener("blur",z),window.addEventListener("resize",z),()=>{window.removeEventListener("blur",z),window.removeEventListener("resize",z)}},[R]);const[H,Y]=Tg(z=>{const $=W().filter(K=>!K.disabled),ee=$.find(K=>K.ref.current===document.activeElement),J=kg($,z,ee);J&&setTimeout(()=>J.ref.current.focus())}),P=h.useCallback((z,$,ee)=>{const J=!X.current&&!ee;(w.value!==void 0&&w.value===$||J)&&(_(z),J&&(X.current=!0))},[w.value]),O=h.useCallback(()=>S==null?void 0:S.focus(),[S]),M=h.useCallback((z,$,ee)=>{const J=!X.current&&!ee;(w.value!==void 0&&w.value===$||J)&&F(z)},[w.value]),L=r==="popper"?Kl:lg,te=L===Kl?{side:a,sideOffset:l,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:m,collisionPadding:p,sticky:b,hideWhenDetached:g,avoidCollisions:x}:{};return c.jsx(ig,{scope:n,content:S,viewport:C,onViewportChange:T,itemRefCallback:P,selectedItem:j,onItemLeave:O,itemTextRefCallback:M,focusSelectedItem:B,selectedItemText:D,position:r,isPositioned:G,searchRef:H,children:c.jsx(ws,{as:sI,allowPinchZoom:!0,children:c.jsx(ts,{asChild:!0,trapped:w.open,onMountAutoFocus:z=>{z.preventDefault()},onUnmountAutoFocus:ie(o,z=>{var $;($=w.trigger)==null||$.focus({preventScroll:!0}),z.preventDefault()}),children:c.jsx(Cr,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:z=>z.preventDefault(),onDismiss:()=>w.onOpenChange(!1),children:c.jsx(L,{role:"listbox",id:w.contentId,"data-state":w.open?"open":"closed",dir:w.dir,onContextMenu:z=>z.preventDefault(),...y,...te,onPlaced:()=>A(!0),ref:E,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:ie(y.onKeyDown,z=>{const $=z.ctrlKey||z.altKey||z.metaKey;if(z.key==="Tab"&&z.preventDefault(),!$&&z.key.length===1&&Y(z.key),["ArrowUp","ArrowDown","Home","End"].includes(z.key)){let J=W().filter(K=>!K.disabled).map(K=>K.ref.current);if(["ArrowUp","End"].includes(z.key)&&(J=J.slice().reverse()),["ArrowUp","ArrowDown"].includes(z.key)){const K=z.target,Q=J.indexOf(K);J=J.slice(Q+1)}setTimeout(()=>q(J)),z.preventDefault()}})})})})})})});ag.displayName=oI;var iI="SelectItemAlignedPosition",lg=h.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=Xn(pr,n),i=Jn(pr,n),[a,l]=h.useState(null),[u,d]=h.useState(null),f=_e(t,E=>d(E)),m=fi(n),p=h.useRef(!1),b=h.useRef(!0),{viewport:g,selectedItem:x,selectedItemText:y,focusSelectedItem:w}=i,S=h.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&u&&g&&x&&y){const E=s.trigger.getBoundingClientRect(),j=u.getBoundingClientRect(),_=s.valueNode.getBoundingClientRect(),D=y.getBoundingClientRect();if(s.dir!=="rtl"){const K=D.left-j.left,Q=_.left-K,me=E.left-Q,de=E.width+me,ge=Math.max(de,j.width),we=window.innerWidth-gn,Te=Fl(Q,[gn,Math.max(gn,we-ge)]);a.style.minWidth=de+"px",a.style.left=Te+"px"}else{const K=j.right-D.right,Q=window.innerWidth-_.right-K,me=window.innerWidth-E.right-Q,de=E.width+me,ge=Math.max(de,j.width),we=window.innerWidth-gn,Te=Fl(Q,[gn,Math.max(gn,we-ge)]);a.style.minWidth=de+"px",a.style.right=Te+"px"}const F=m(),W=window.innerHeight-gn*2,G=g.scrollHeight,A=window.getComputedStyle(u),X=parseInt(A.borderTopWidth,10),q=parseInt(A.paddingTop,10),B=parseInt(A.borderBottomWidth,10),R=parseInt(A.paddingBottom,10),I=X+q+G+R+B,H=Math.min(x.offsetHeight*5,I),Y=window.getComputedStyle(g),P=parseInt(Y.paddingTop,10),O=parseInt(Y.paddingBottom,10),M=E.top+E.height/2-gn,L=W-M,te=x.offsetHeight/2,z=x.offsetTop+te,$=X+q+z,ee=I-$;if($<=M){const K=F.length>0&&x===F[F.length-1].ref.current;a.style.bottom="0px";const Q=u.clientHeight-g.offsetTop-g.offsetHeight,me=Math.max(L,te+(K?O:0)+Q+B),de=$+me;a.style.height=de+"px"}else{const K=F.length>0&&x===F[0].ref.current;a.style.top="0px";const me=Math.max(M,X+g.offsetTop+(K?P:0)+te)+ee;a.style.height=me+"px",g.scrollTop=$-M+g.offsetTop}a.style.margin=`${gn}px 0`,a.style.minHeight=H+"px",a.style.maxHeight=W+"px",r==null||r(),requestAnimationFrame(()=>p.current=!0)}},[m,s.trigger,s.valueNode,a,u,g,x,y,s.dir,r]);wt(()=>S(),[S]);const[k,C]=h.useState();wt(()=>{u&&C(window.getComputedStyle(u).zIndex)},[u]);const T=h.useCallback(E=>{E&&b.current===!0&&(S(),w==null||w(),b.current=!1)},[S,w]);return c.jsx(lI,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:p,onScrollButtonChange:T,children:c.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:k},children:c.jsx(he.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});lg.displayName=iI;var aI="SelectPopperPosition",Kl=h.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=gn,...s}=e,i=pi(n);return c.jsx(pa,{...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)"}})});Kl.displayName=aI;var[lI,ql]=Br(pr,{}),Gl="SelectViewport",cg=h.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=Jn(Gl,n),i=ql(Gl,n),a=_e(t,s.onViewportChange),l=h.useRef(0);return c.jsxs(c.Fragment,{children:[c.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),c.jsx(di.Slot,{scope:n,children:c.jsx(he.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:ie(o.onScroll,u=>{const d=u.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:m}=i;if(m!=null&&m.current&&f){const p=Math.abs(l.current-d.scrollTop);if(p>0){const b=window.innerHeight-gn*2,g=parseFloat(f.style.minHeight),x=parseFloat(f.style.height),y=Math.max(g,x);if(y<b){const w=y+p,S=Math.min(b,w),k=w-S;f.style.height=S+"px",f.style.bottom==="0px"&&(d.scrollTop=k>0?k:0,f.style.justifyContent="flex-end")}}}l.current=d.scrollTop})})})]})});cg.displayName=Gl;var ug="SelectGroup",[cI,uI]=Br(ug),dI=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=kt();return c.jsx(cI,{scope:n,id:o,children:c.jsx(he.div,{role:"group","aria-labelledby":o,...r,ref:t})})});dI.displayName=ug;var dg="SelectLabel",fg=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=uI(dg,n);return c.jsx(he.div,{id:o.id,...r,ref:t})});fg.displayName=dg;var hi="SelectItem",[fI,pg]=Br(hi),hg=h.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=Xn(hi,n),l=Jn(hi,n),u=a.value===r,[d,f]=h.useState(s??""),[m,p]=h.useState(!1),b=_e(t,w=>{var S;return(S=l.itemRefCallback)==null?void 0:S.call(l,w,r,o)}),g=kt(),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 c.jsx(fI,{scope:n,value:r,disabled:o,textId:g,isSelected:u,onItemTextChange:h.useCallback(w=>{f(S=>S||((w==null?void 0:w.textContent)??"").trim())},[]),children:c.jsx(di.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:c.jsx(he.div,{role:"option","aria-labelledby":g,"data-highlighted":m?"":void 0,"aria-selected":u&&m,"data-state":u?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:b,onFocus:ie(i.onFocus,()=>p(!0)),onBlur:ie(i.onBlur,()=>p(!1)),onClick:ie(i.onClick,()=>{x.current!=="mouse"&&y()}),onPointerUp:ie(i.onPointerUp,()=>{x.current==="mouse"&&y()}),onPointerDown:ie(i.onPointerDown,w=>{x.current=w.pointerType}),onPointerMove:ie(i.onPointerMove,w=>{var S;x.current=w.pointerType,o?(S=l.onItemLeave)==null||S.call(l):x.current==="mouse"&&w.currentTarget.focus({preventScroll:!0})}),onPointerLeave:ie(i.onPointerLeave,w=>{var S;w.currentTarget===document.activeElement&&((S=l.onItemLeave)==null||S.call(l))}),onKeyDown:ie(i.onKeyDown,w=>{var k;((k=l.searchRef)==null?void 0:k.current)!==""&&w.key===" "||(JE.includes(w.key)&&y(),w.key===" "&&w.preventDefault())})})})})});hg.displayName=hi;var Oo="SelectItemText",mg=h.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=Xn(Oo,n),a=Jn(Oo,n),l=pg(Oo,n),u=tI(Oo,n),[d,f]=h.useState(null),m=_e(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,b=h.useMemo(()=>c.jsx("option",{value:l.value,disabled:l.disabled,children:p},l.value),[l.disabled,l.value,p]),{onNativeOptionAdd:g,onNativeOptionRemove:x}=u;return wt(()=>(g(b),()=>x(b)),[g,x,b]),c.jsxs(c.Fragment,{children:[c.jsx(he.span,{id:l.textId,...s,ref:m}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?Wr.createPortal(s.children,i.valueNode):null]})});mg.displayName=Oo;var gg="SelectItemIndicator",xg=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return pg(gg,n).isSelected?c.jsx(he.span,{"aria-hidden":!0,...r,ref:t}):null});xg.displayName=gg;var Yl="SelectScrollUpButton",vg=h.forwardRef((e,t)=>{const n=Jn(Yl,e.__scopeSelect),r=ql(Yl,e.__scopeSelect),[o,s]=h.useState(!1),i=_e(t,r.onScrollButtonChange);return wt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const u=l.scrollTop>0;s(u)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?c.jsx(wg,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});vg.displayName=Yl;var Xl="SelectScrollDownButton",bg=h.forwardRef((e,t)=>{const n=Jn(Xl,e.__scopeSelect),r=ql(Xl,e.__scopeSelect),[o,s]=h.useState(!1),i=_e(t,r.onScrollButtonChange);return wt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const u=l.scrollHeight-l.clientHeight,d=Math.ceil(l.scrollTop)<u;s(d)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?c.jsx(wg,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});bg.displayName=Xl;var wg=h.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=Jn("SelectScrollButton",n),i=h.useRef(null),a=fi(n),l=h.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return h.useEffect(()=>()=>l(),[l]),wt(()=>{var d;const u=a().find(f=>f.ref.current===document.activeElement);(d=u==null?void 0:u.ref.current)==null||d.scrollIntoView({block:"nearest"})},[a]),c.jsx(he.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:ie(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:ie(o.onPointerMove,()=>{var u;(u=s.onItemLeave)==null||u.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:ie(o.onPointerLeave,()=>{l()})})}),pI="SelectSeparator",yg=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return c.jsx(he.div,{"aria-hidden":!0,...r,ref:t})});yg.displayName=pI;var Jl="SelectArrow",hI=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=pi(n),s=Xn(Jl,n),i=Jn(Jl,n);return s.open&&i.position==="popper"?c.jsx(ha,{...o,...r,ref:t}):null});hI.displayName=Jl;var mI="SelectBubbleInput",Sg=h.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=h.useRef(null),s=_e(r,o),i=Xm(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]),c.jsx(he.select,{...n,style:{...Jm,...n.style},ref:s,defaultValue:t})});Sg.displayName=mI;function Cg(e){return e===""||e===void 0}function Tg(e){const t=ft(e),n=h.useRef(""),r=h.useRef(0),o=h.useCallback(i=>{const a=n.current+i;t(a),function l(u){n.current=u,window.clearTimeout(r.current),u!==""&&(r.current=window.setTimeout(()=>l(""),1e3))}(a)},[t]),s=h.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return h.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function kg(e,t,n){const o=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=gI(e,Math.max(s,0));o.length===1&&(i=i.filter(u=>u!==n));const l=i.find(u=>u.textValue.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function gI(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var xI=Zm,Eg=eg,vI=ng,bI=rg,wI=og,Ig=sg,yI=cg,Ng=fg,Ag=hg,SI=mg,CI=xg,jg=vg,_g=bg,Pg=yg;const TI=xI,kI=vI,Rg=h.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(Eg,{ref:r,className:ne("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[t,c.jsx(bI,{asChild:!0,children:c.jsx(ae.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));Rg.displayName=Eg.displayName;const Mg=h.forwardRef(({className:e,...t},n)=>c.jsx(jg,{ref:n,className:ne("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(ae.ChevronUp,{className:"h-4 w-4"})}));Mg.displayName=jg.displayName;const Og=h.forwardRef(({className:e,...t},n)=>c.jsx(_g,{ref:n,className:ne("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(ae.ChevronDown,{className:"h-4 w-4"})}));Og.displayName=_g.displayName;const Dg=h.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>c.jsx(wI,{children:c.jsxs(Ig,{ref:o,className:ne("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...r,children:[c.jsx(Mg,{}),c.jsx(yI,{className:ne("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),c.jsx(Og,{})]})}));Dg.displayName=Ig.displayName;const EI=h.forwardRef(({className:e,...t},n)=>c.jsx(Ng,{ref:n,className:ne("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));EI.displayName=Ng.displayName;const Lg=h.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(Ag,{ref:r,className:ne("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[c.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:c.jsx(CI,{children:c.jsx(ae.Check,{className:"h-4 w-4"})})}),c.jsx(SI,{children:t})]}));Lg.displayName=Ag.displayName;const II=h.forwardRef(({className:e,...t},n)=>c.jsx(Pg,{ref:n,className:ne("-mx-1 my-1 h-px bg-muted",e),...t}));II.displayName=Pg.displayName;var NI="Separator",$g="horizontal",AI=["horizontal","vertical"],Fg=h.forwardRef((e,t)=>{const{decorative:n,orientation:r=$g,...o}=e,s=jI(r)?r:$g,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return c.jsx(he.div,{"data-orientation":s,...a,...o,ref:t})});Fg.displayName=NI;function jI(e){return AI.includes(e)}var Bg=Fg;const zg=h.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>c.jsx(Bg,{ref:o,decorative:n,orientation:t,className:ne("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));zg.displayName=Bg.displayName;var mi="Switch",[_I,H1]=Xt(mi),[PI,RI]=_I(mi),Hg=h.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:s,required:i,disabled:a,value:l="on",onCheckedChange:u,form:d,...f}=e,[m,p]=h.useState(null),b=_e(t,S=>p(S)),g=h.useRef(!1),x=m?d||!!m.closest("form"):!0,[y,w]=cn({prop:o,defaultProp:s??!1,onChange:u,caller:mi});return c.jsxs(PI,{scope:n,checked:y,disabled:a,children:[c.jsx(he.button,{type:"button",role:"switch","aria-checked":y,"aria-required":i,"data-state":Kg(y),"data-disabled":a?"":void 0,disabled:a,value:l,...f,ref:b,onClick:ie(e.onClick,S=>{w(k=>!k),x&&(g.current=S.isPropagationStopped(),g.current||S.stopPropagation())})}),x&&c.jsx(Vg,{control:m,bubbles:!g.current,name:r,value:l,checked:y,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});Hg.displayName=mi;var Ug="SwitchThumb",Wg=h.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=RI(Ug,n);return c.jsx(he.span,{"data-state":Kg(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});Wg.displayName=Ug;var MI="SwitchBubbleInput",Vg=h.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=h.useRef(null),a=_e(i,s),l=Xm(n),u=_d(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 b=new Event("click",{bubbles:r});p.call(d,n),d.dispatchEvent(b)}},[l,n,r]),c.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:a,style:{...o.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});Vg.displayName=MI;function Kg(e){return e?"checked":"unchecked"}var qg=Hg,OI=Wg;const Gg=h.forwardRef(({className:e,...t},n)=>c.jsx(qg,{className:ne("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...t,ref:n,children:c.jsx(OI,{className:ne("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));Gg.displayName=qg.displayName;const DI=ol,LI=VT,$I=sl,Yg=h.forwardRef(({className:e,...t},n)=>c.jsx(No,{className:ne("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t,ref:n}));Yg.displayName=No.displayName;const FI=Ur.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"}}),Xg=h.forwardRef(({side:e="right",className:t,children:n,...r},o)=>c.jsxs($I,{children:[c.jsx(Yg,{}),c.jsxs(Ao,{ref:o,className:ne(FI({side:e}),t),...r,children:[n,c.jsxs(xh,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary",children:[c.jsx(ae.X,{className:"h-4 w-4"}),c.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Xg.displayName=Ao.displayName;const Jg=({className:e,...t})=>c.jsx("div",{className:ne("flex flex-col space-y-2 text-center sm:text-left",e),...t});Jg.displayName="SheetHeader";const Zg=h.forwardRef(({className:e,...t},n)=>c.jsx(cr,{ref:n,className:ne("text-lg font-semibold text-foreground",e),...t}));Zg.displayName=cr.displayName;const Qg=h.forwardRef(({className:e,...t},n)=>c.jsx(Us,{ref:n,className:ne("text-sm text-muted-foreground",e),...t}));Qg.displayName=Us.displayName;var[gi,U1]=Xt("Tooltip",[Nr]),xi=Nr(),ex="TooltipProvider",BI=700,Zl="tooltip.open",[zI,Ql]=gi(ex),tx=e=>{const{__scopeTooltip:t,delayDuration:n=BI,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 u=l.current;return()=>window.clearTimeout(u)},[]),c.jsx(zI,{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(u=>{a.current=u},[]),disableHoverableContent:o,children:s})};tx.displayName=ex;var Do="Tooltip",[HI,vi]=gi(Do),nx=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:s,disableHoverableContent:i,delayDuration:a}=e,l=Ql(Do,e.__scopeTooltip),u=xi(t),[d,f]=h.useState(null),m=kt(),p=h.useRef(0),b=i??l.disableHoverableContent,g=a??l.delayDuration,x=h.useRef(!1),[y,w]=cn({prop:r,defaultProp:o??!1,onChange:E=>{E?(l.onOpen(),document.dispatchEvent(new CustomEvent(Zl))):l.onClose(),s==null||s(E)},caller:Do}),S=h.useMemo(()=>y?x.current?"delayed-open":"instant-open":"closed",[y]),k=h.useCallback(()=>{window.clearTimeout(p.current),p.current=0,x.current=!1,w(!0)},[w]),C=h.useCallback(()=>{window.clearTimeout(p.current),p.current=0,w(!1)},[w]),T=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)},[]),c.jsx(da,{...u,children:c.jsx(HI,{scope:t,contentId:m,open:y,stateAttribute:S,trigger:d,onTriggerChange:f,onTriggerEnter:h.useCallback(()=>{l.isOpenDelayedRef.current?T():k()},[l.isOpenDelayedRef,T,k]),onTriggerLeave:h.useCallback(()=>{b?C():(window.clearTimeout(p.current),p.current=0)},[C,b]),onOpen:k,onClose:C,disableHoverableContent:b,children:n})})};nx.displayName=Do;var ec="TooltipTrigger",rx=h.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=vi(ec,n),s=Ql(ec,n),i=xi(n),a=h.useRef(null),l=_e(t,a,o.onTriggerChange),u=h.useRef(!1),d=h.useRef(!1),f=h.useCallback(()=>u.current=!1,[]);return h.useEffect(()=>()=>document.removeEventListener("pointerup",f),[f]),c.jsx(fa,{asChild:!0,...i,children:c.jsx(he.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:l,onPointerMove:ie(e.onPointerMove,m=>{m.pointerType!=="touch"&&!d.current&&!s.isPointerInTransitRef.current&&(o.onTriggerEnter(),d.current=!0)}),onPointerLeave:ie(e.onPointerLeave,()=>{o.onTriggerLeave(),d.current=!1}),onPointerDown:ie(e.onPointerDown,()=>{o.open&&o.onClose(),u.current=!0,document.addEventListener("pointerup",f,{once:!0})}),onFocus:ie(e.onFocus,()=>{u.current||o.onOpen()}),onBlur:ie(e.onBlur,o.onClose),onClick:ie(e.onClick,o.onClose)})})});rx.displayName=ec;var UI="TooltipPortal",[W1,WI]=gi(UI,{forceMount:void 0}),zr="TooltipContent",ox=h.forwardRef((e,t)=>{const n=WI(zr,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...s}=e,i=vi(zr,e.__scopeTooltip);return c.jsx(Dt,{present:r||i.open,children:i.disableHoverableContent?c.jsx(sx,{side:o,...s,ref:t}):c.jsx(VI,{side:o,...s,ref:t})})}),VI=h.forwardRef((e,t)=>{const n=vi(zr,e.__scopeTooltip),r=Ql(zr,e.__scopeTooltip),o=h.useRef(null),s=_e(t,o),[i,a]=h.useState(null),{trigger:l,onClose:u}=n,d=o.current,{onPointerInTransitChange:f}=r,m=h.useCallback(()=>{a(null),f(!1)},[f]),p=h.useCallback((b,g)=>{const x=b.currentTarget,y={x:b.clientX,y:b.clientY},w=XI(y,x.getBoundingClientRect()),S=JI(y,w),k=ZI(g.getBoundingClientRect()),C=eN([...S,...k]);a(C),f(!0)},[f]);return h.useEffect(()=>()=>m(),[m]),h.useEffect(()=>{if(l&&d){const b=x=>p(x,d),g=x=>p(x,l);return l.addEventListener("pointerleave",b),d.addEventListener("pointerleave",g),()=>{l.removeEventListener("pointerleave",b),d.removeEventListener("pointerleave",g)}}},[l,d,p,m]),h.useEffect(()=>{if(i){const b=g=>{const x=g.target,y={x:g.clientX,y:g.clientY},w=(l==null?void 0:l.contains(x))||(d==null?void 0:d.contains(x)),S=!QI(y,i);w?m():S&&(m(),u())};return document.addEventListener("pointermove",b),()=>document.removeEventListener("pointermove",b)}},[l,d,i,u,m]),c.jsx(sx,{...e,ref:s})}),[KI,qI]=gi(Do,{isInside:!1}),GI=qt.createSlottable("TooltipContent"),sx=h.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:s,onPointerDownOutside:i,...a}=e,l=vi(zr,n),u=xi(n),{onClose:d}=l;return h.useEffect(()=>(document.addEventListener(Zl,d),()=>document.removeEventListener(Zl,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]),c.jsx(Cr,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:f=>f.preventDefault(),onDismiss:d,children:c.jsxs(pa,{"data-state":l.stateAttribute,...u,...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:[c.jsx(GI,{children:r}),c.jsx(KI,{scope:n,isInside:!0,children:c.jsx(YE,{id:l.contentId,role:"tooltip",children:o||r})})]})})});ox.displayName=zr;var ix="TooltipArrow",YI=h.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=xi(n);return qI(ix,n).isInside?null:c.jsx(ha,{...o,...r,ref:t})});YI.displayName=ix;function XI(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 JI(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 ZI(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 QI(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const a=t[s],l=t[i],u=a.x,d=a.y,f=l.x,m=l.y;d>r!=m>r&&n<(f-u)*(r-d)/(m-d)+u&&(o=!o)}return o}function eN(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),tN(t)}function tN(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 nN=tx,rN=nx,oN=rx,ax=ox;const sN=nN,iN=rN,aN=oN,lx=h.forwardRef(({className:e,sideOffset:t=4,...n},r)=>c.jsx(ax,{ref:r,sideOffset:t,className:ne("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}));lx.displayName=ax.displayName;var tc="ToastProvider",[nc,lN,cN]=oo("Toast"),[cx,V1]=Xt("Toast",[cN]),[uN,bi]=cx(tc),ux=e=>{const{__scopeToast:t,label:n="Notification",duration:r=5e3,swipeDirection:o="right",swipeThreshold:s=50,children:i}=e,[a,l]=h.useState(null),[u,d]=h.useState(0),f=h.useRef(!1),m=h.useRef(!1);return n.trim()||console.error(`Invalid prop \`label\` supplied to \`${tc}\`. Expected non-empty \`string\`.`),c.jsx(nc.Provider,{scope:t,children:c.jsx(uN,{scope:t,label:n,duration:r,swipeDirection:o,swipeThreshold:s,toastCount:u,viewport:a,onViewportChange:l,onToastAdd:h.useCallback(()=>d(p=>p+1),[]),onToastRemove:h.useCallback(()=>d(p=>p-1),[]),isFocusedToastEscapeKeyDownRef:f,isClosePausedRef:m,children:i})})};ux.displayName=tc;var dx="ToastViewport",dN=["F8"],rc="toast.viewportPause",oc="toast.viewportResume",fx=h.forwardRef((e,t)=>{const{__scopeToast:n,hotkey:r=dN,label:o="Notifications ({hotkey})",...s}=e,i=bi(dx,n),a=lN(n),l=h.useRef(null),u=h.useRef(null),d=h.useRef(null),f=h.useRef(null),m=_e(t,f,i.onViewportChange),p=r.join("+").replace(/Key/g,"").replace(/Digit/g,""),b=i.toastCount>0;h.useEffect(()=>{const x=y=>{var S;r.length!==0&&r.every(k=>y[k]||y.code===k)&&((S=f.current)==null||S.focus())};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[r]),h.useEffect(()=>{const x=l.current,y=f.current;if(b&&x&&y){const w=()=>{if(!i.isClosePausedRef.current){const T=new CustomEvent(rc);y.dispatchEvent(T),i.isClosePausedRef.current=!0}},S=()=>{if(i.isClosePausedRef.current){const T=new CustomEvent(oc);y.dispatchEvent(T),i.isClosePausedRef.current=!1}},k=T=>{!x.contains(T.relatedTarget)&&S()},C=()=>{x.contains(document.activeElement)||S()};return x.addEventListener("focusin",w),x.addEventListener("focusout",k),x.addEventListener("pointermove",w),x.addEventListener("pointerleave",C),window.addEventListener("blur",w),window.addEventListener("focus",S),()=>{x.removeEventListener("focusin",w),x.removeEventListener("focusout",k),x.removeEventListener("pointermove",w),x.removeEventListener("pointerleave",C),window.removeEventListener("blur",w),window.removeEventListener("focus",S)}}},[b,i.isClosePausedRef]);const g=h.useCallback(({tabbingDirection:x})=>{const w=a().map(S=>{const k=S.ref.current,C=[k,...TN(k)];return x==="forwards"?C:C.reverse()});return(x==="forwards"?w.reverse():w).flat()},[a]);return h.useEffect(()=>{const x=f.current;if(x){const y=w=>{var C,T,E;const S=w.altKey||w.ctrlKey||w.metaKey;if(w.key==="Tab"&&!S){const j=document.activeElement,_=w.shiftKey;if(w.target===x&&_){(C=u.current)==null||C.focus();return}const W=g({tabbingDirection:_?"backwards":"forwards"}),G=W.findIndex(A=>A===j);ac(W.slice(G+1))?w.preventDefault():_?(T=u.current)==null||T.focus():(E=d.current)==null||E.focus()}};return x.addEventListener("keydown",y),()=>x.removeEventListener("keydown",y)}},[a,g]),c.jsxs(bw,{ref:l,role:"region","aria-label":o.replace("{hotkey}",p),tabIndex:-1,style:{pointerEvents:b?void 0:"none"},children:[b&&c.jsx(sc,{ref:u,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"forwards"});ac(x)}}),c.jsx(nc.Slot,{scope:n,children:c.jsx(he.ol,{tabIndex:-1,...s,ref:m})}),b&&c.jsx(sc,{ref:d,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"backwards"});ac(x)}})]})});fx.displayName=dx;var px="ToastFocusProxy",sc=h.forwardRef((e,t)=>{const{__scopeToast:n,onFocusFromOutsideViewport:r,...o}=e,s=bi(px,n);return c.jsx(ui,{tabIndex:0,...o,ref:t,style:{position:"fixed"},onFocus:i=>{var u;const a=i.relatedTarget;!((u=s.viewport)!=null&&u.contains(a))&&r()}})});sc.displayName=px;var Lo="Toast",fN="toast.swipeStart",pN="toast.swipeMove",hN="toast.swipeCancel",mN="toast.swipeEnd",hx=h.forwardRef((e,t)=>{const{forceMount:n,open:r,defaultOpen:o,onOpenChange:s,...i}=e,[a,l]=cn({prop:r,defaultProp:o??!0,onChange:s,caller:Lo});return c.jsx(Dt,{present:n||a,children:c.jsx(vN,{open:a,...i,ref:t,onClose:()=>l(!1),onPause:ft(e.onPause),onResume:ft(e.onResume),onSwipeStart:ie(e.onSwipeStart,u=>{u.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:ie(e.onSwipeMove,u=>{const{x:d,y:f}=u.detail.delta;u.currentTarget.setAttribute("data-swipe","move"),u.currentTarget.style.setProperty("--radix-toast-swipe-move-x",`${d}px`),u.currentTarget.style.setProperty("--radix-toast-swipe-move-y",`${f}px`)}),onSwipeCancel:ie(e.onSwipeCancel,u=>{u.currentTarget.setAttribute("data-swipe","cancel"),u.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),u.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),u.currentTarget.style.removeProperty("--radix-toast-swipe-end-x"),u.currentTarget.style.removeProperty("--radix-toast-swipe-end-y")}),onSwipeEnd:ie(e.onSwipeEnd,u=>{const{x:d,y:f}=u.detail.delta;u.currentTarget.setAttribute("data-swipe","end"),u.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),u.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),u.currentTarget.style.setProperty("--radix-toast-swipe-end-x",`${d}px`),u.currentTarget.style.setProperty("--radix-toast-swipe-end-y",`${f}px`),l(!1)})})})});hx.displayName=Lo;var[gN,xN]=cx(Lo,{onClose(){}}),vN=h.forwardRef((e,t)=>{const{__scopeToast:n,type:r="foreground",duration:o,open:s,onClose:i,onEscapeKeyDown:a,onPause:l,onResume:u,onSwipeStart:d,onSwipeMove:f,onSwipeCancel:m,onSwipeEnd:p,...b}=e,g=bi(Lo,n),[x,y]=h.useState(null),w=_e(t,A=>y(A)),S=h.useRef(null),k=h.useRef(null),C=o||g.duration,T=h.useRef(0),E=h.useRef(C),j=h.useRef(0),{onToastAdd:_,onToastRemove:D}=g,F=ft(()=>{var X;(x==null?void 0:x.contains(document.activeElement))&&((X=g.viewport)==null||X.focus()),i()}),W=h.useCallback(A=>{!A||A===1/0||(window.clearTimeout(j.current),T.current=new Date().getTime(),j.current=window.setTimeout(F,A))},[F]);h.useEffect(()=>{const A=g.viewport;if(A){const X=()=>{W(E.current),u==null||u()},q=()=>{const B=new Date().getTime()-T.current;E.current=E.current-B,window.clearTimeout(j.current),l==null||l()};return A.addEventListener(rc,q),A.addEventListener(oc,X),()=>{A.removeEventListener(rc,q),A.removeEventListener(oc,X)}}},[g.viewport,C,l,u,W]),h.useEffect(()=>{s&&!g.isClosePausedRef.current&&W(C)},[s,C,g.isClosePausedRef,W]),h.useEffect(()=>(_(),()=>D()),[_,D]);const G=h.useMemo(()=>x?yx(x):null,[x]);return g.viewport?c.jsxs(c.Fragment,{children:[G&&c.jsx(bN,{__scopeToast:n,role:"status","aria-live":r==="foreground"?"assertive":"polite",children:G}),c.jsx(gN,{scope:n,onClose:F,children:Wr.createPortal(c.jsx(nc.ItemSlot,{scope:n,children:c.jsx(vw,{asChild:!0,onEscapeKeyDown:ie(a,()=>{g.isFocusedToastEscapeKeyDownRef.current||F(),g.isFocusedToastEscapeKeyDownRef.current=!1}),children:c.jsx(he.li,{tabIndex:0,"data-state":s?"open":"closed","data-swipe-direction":g.swipeDirection,...b,ref:w,style:{userSelect:"none",touchAction:"none",...e.style},onKeyDown:ie(e.onKeyDown,A=>{A.key==="Escape"&&(a==null||a(A.nativeEvent),A.nativeEvent.defaultPrevented||(g.isFocusedToastEscapeKeyDownRef.current=!0,F()))}),onPointerDown:ie(e.onPointerDown,A=>{A.button===0&&(S.current={x:A.clientX,y:A.clientY})}),onPointerMove:ie(e.onPointerMove,A=>{if(!S.current)return;const X=A.clientX-S.current.x,q=A.clientY-S.current.y,B=!!k.current,R=["left","right"].includes(g.swipeDirection),I=["left","up"].includes(g.swipeDirection)?Math.min:Math.max,H=R?I(0,X):0,Y=R?0:I(0,q),P=A.pointerType==="touch"?10:2,O={x:H,y:Y},M={originalEvent:A,delta:O};B?(k.current=O,wi(pN,f,M,{discrete:!1})):Sx(O,g.swipeDirection,P)?(k.current=O,wi(fN,d,M,{discrete:!1}),A.target.setPointerCapture(A.pointerId)):(Math.abs(X)>P||Math.abs(q)>P)&&(S.current=null)}),onPointerUp:ie(e.onPointerUp,A=>{const X=k.current,q=A.target;if(q.hasPointerCapture(A.pointerId)&&q.releasePointerCapture(A.pointerId),k.current=null,S.current=null,X){const B=A.currentTarget,R={originalEvent:A,delta:X};Sx(X,g.swipeDirection,g.swipeThreshold)?wi(mN,p,R,{discrete:!0}):wi(hN,m,R,{discrete:!0}),B.addEventListener("click",I=>I.preventDefault(),{once:!0})}})})})}),g.viewport)})]}):null}),bN=e=>{const{__scopeToast:t,children:n,...r}=e,o=bi(Lo,t),[s,i]=h.useState(!1),[a,l]=h.useState(!1);return SN(()=>i(!0)),h.useEffect(()=>{const u=window.setTimeout(()=>l(!0),1e3);return()=>window.clearTimeout(u)},[]),a?null:c.jsx(co,{asChild:!0,children:c.jsx(ui,{...r,children:s&&c.jsxs(c.Fragment,{children:[o.label," ",n]})})})},wN="ToastTitle",mx=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return c.jsx(he.div,{...r,ref:t})});mx.displayName=wN;var yN="ToastDescription",gx=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return c.jsx(he.div,{...r,ref:t})});gx.displayName=yN;var xx="ToastAction",vx=h.forwardRef((e,t)=>{const{altText:n,...r}=e;return n.trim()?c.jsx(wx,{altText:n,asChild:!0,children:c.jsx(ic,{...r,ref:t})}):(console.error(`Invalid prop \`altText\` supplied to \`${xx}\`. Expected non-empty \`string\`.`),null)});vx.displayName=xx;var bx="ToastClose",ic=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e,o=xN(bx,n);return c.jsx(wx,{asChild:!0,children:c.jsx(he.button,{type:"button",...r,ref:t,onClick:ie(e.onClick,o.onClose)})})});ic.displayName=bx;var wx=h.forwardRef((e,t)=>{const{__scopeToast:n,altText:r,...o}=e;return c.jsx(he.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":r||void 0,...o,ref:t})});function yx(e){const t=[];return Array.from(e.childNodes).forEach(r=>{if(r.nodeType===r.TEXT_NODE&&r.textContent&&t.push(r.textContent),CN(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(...yx(r))}}),t}function wi(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?Ki(o,s):o.dispatchEvent(s)}var Sx=(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 SN(e=()=>{}){const t=ft(e);wt(()=>{let n=0,r=0;return n=window.requestAnimationFrame(()=>r=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(n),window.cancelAnimationFrame(r)}},[t])}function CN(e){return e.nodeType===e.ELEMENT_NODE}function TN(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 ac(e){const t=document.activeElement;return e.some(n=>n===t?!0:(n.focus(),document.activeElement!==t))}var kN=ux,Cx=fx,Tx=hx,kx=mx,Ex=gx,Ix=vx,Nx=ic;const EN=kN,Ax=h.forwardRef(({className:e,...t},n)=>c.jsx(Cx,{ref:n,className:ne("fixed bottom-0 right-0 z-[100] flex max-h-screen w-full flex-col p-4 md:max-w-[420px]",e),...t}));Ax.displayName=Cx.displayName;const IN=Ur.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"}}),jx=h.forwardRef(({className:e,variant:t,...n},r)=>c.jsx(Tx,{ref:r,className:ne(IN({variant:t}),e),...n}));jx.displayName=Tx.displayName;const NN=h.forwardRef(({className:e,...t},n)=>c.jsx(Ix,{ref:n,className:ne("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}));NN.displayName=Ix.displayName;const _x=h.forwardRef(({className:e,...t},n)=>c.jsx(Nx,{ref:n,className:ne("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:c.jsx(ae.X,{className:"h-4 w-4"})}));_x.displayName=Nx.displayName;const Px=h.forwardRef(({className:e,...t},n)=>c.jsx(kx,{ref:n,className:ne("text-sm font-semibold",e),...t}));Px.displayName=kx.displayName;const Rx=h.forwardRef(({className:e,...t},n)=>c.jsx(Ex,{ref:n,className:ne("text-sm opacity-90",e),...t}));Rx.displayName=Ex.displayName;function AN(){const{toasts:e}=cl();return c.jsxs(EN,{children:[e.map(function({id:t,title:n,description:r,action:o,...s}){return c.jsxs(jx,{...s,children:[c.jsxs("div",{className:"grid gap-1",children:[n&&c.jsx(Px,{children:n}),r&&c.jsx(Rx,{children:r})]}),o,c.jsx(_x,{})]},t)}),c.jsx(Ax,{})]})}var jN=(e,t,n,r,o,s,i,a)=>{let l=document.documentElement,u=["light","dark"];function d(p){(Array.isArray(e)?e:[e]).forEach(b=>{let g=b==="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(b,p)}),f(p)}function f(p){a&&u.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,b=i&&p==="system"?m():p;d(b)}catch{}},_N=h.createContext(void 0),PN={setTheme:e=>{},themes:[]},RN=()=>{var e;return(e=h.useContext(_N))!=null?e:PN};h.memo(({forcedTheme:e,storageKey:t,attribute:n,enableSystem:r,enableColorScheme:o,defaultTheme:s,value:i,themes:a,nonce:l,scriptProps:u})=>{let d=JSON.stringify([n,t,s,e,a,i,r,o]).slice(1,-1);return h.createElement("script",{...u,suppressHydrationWarning:!0,nonce:typeof window>"u"?l:"",dangerouslySetInnerHTML:{__html:`(${jN.toString()})(${d})`}})});var MN=e=>{switch(e){case"success":return LN;case"info":return FN;case"warning":return $N;case"error":return BN;default:return null}},ON=Array(12).fill(0),DN=({visible:e,className:t})=>v.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},v.createElement("div",{className:"sonner-spinner"},ON.map((n,r)=>v.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),LN=v.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},v.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"})),$N=v.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},v.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"})),FN=v.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},v.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"})),BN=v.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},v.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"})),zN=v.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"},v.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),v.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),HN=()=>{let[e,t]=v.useState(document.hidden);return v.useEffect(()=>{let n=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),e},lc=1,UN=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:lc++,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],v.isValidElement(l))o=!1,this.create({id:n,type:"default",message:l});else if(VN(l)&&!l.ok){o=!1;let u=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:u,description:d})}else if(t.success!==void 0){o=!1;let u=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:u,description:d})}}).catch(async l=>{if(s=["reject",l],t.error!==void 0){o=!1;let u=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:u,description:d})}}).finally(()=>{var l;o&&(this.dismiss(n),n=void 0),(l=t.finally)==null||l.call(t)}),a=()=>new Promise((l,u)=>i.then(()=>s[0]==="reject"?u(s[1]):l(s[1])).catch(u));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)||lc++;return this.create({jsx:e(n),id:n,...t}),n},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},Wt=new UN,WN=(e,t)=>{let n=(t==null?void 0:t.id)||lc++;return Wt.addToast({title:e,...t,id:n}),n},VN=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",KN=WN,qN=()=>Wt.toasts,GN=()=>Wt.getActiveToasts();Object.assign(KN,{success:Wt.success,info:Wt.info,warning:Wt.warning,error:Wt.error,custom:Wt.custom,message:Wt.message,promise:Wt.promise,dismiss:Wt.dismiss,loading:Wt.loading},{getHistory:qN,getToasts:GN});function YN(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))}YN(`: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 yi(e){return e.label!==void 0}var XN=3,JN="32px",ZN="16px",Mx=4e3,QN=356,e1=14,t1=20,n1=200;function xn(...e){return e.filter(Boolean).join(" ")}function r1(e){let[t,n]=e.split("-"),r=[];return t&&r.push(t),n&&r.push(n),r}var o1=e=>{var t,n,r,o,s,i,a,l,u,d,f;let{invert:m,toast:p,unstyled:b,interacting:g,setHeights:x,visibleToasts:y,heights:w,index:S,toasts:k,expanded:C,removeToast:T,defaultRichColors:E,closeButton:j,style:_,cancelButtonStyle:D,actionButtonStyle:F,className:W="",descriptionClassName:G="",duration:A,position:X,gap:q,loadingIcon:B,expandByDefault:R,classNames:I,icons:H,closeButtonAriaLabel:Y="Close toast",pauseWhenPageIsHidden:P}=e,[O,M]=v.useState(null),[L,te]=v.useState(null),[z,$]=v.useState(!1),[ee,J]=v.useState(!1),[K,Q]=v.useState(!1),[me,de]=v.useState(!1),[ge,we]=v.useState(!1),[Te,Ne]=v.useState(0),[ke,st]=v.useState(0),vt=v.useRef(p.duration||A||Mx),ht=v.useRef(null),We=v.useRef(null),Le=S===0,Ge=S+1<=y,Me=p.type,$e=p.dismissible!==!1,Ze=p.className||"",Nt=p.descriptionClassName||"",it=v.useMemo(()=>w.findIndex(ve=>ve.toastId===p.id)||0,[w,p.id]),St=v.useMemo(()=>{var ve;return(ve=p.closeButton)!=null?ve:j},[p.closeButton,j]),Ct=v.useMemo(()=>p.duration||A||Mx,[p.duration,A]),Tt=v.useRef(0),Et=v.useRef(0),sn=v.useRef(0),At=v.useRef(null),[Vt,It]=X.split("-"),Fe=v.useMemo(()=>w.reduce((ve,pe,ye)=>ye>=it?ve:ve+pe.height,0),[w,it]),Ve=HN(),jt=p.invert||m,Z=Me==="loading";Et.current=v.useMemo(()=>it*q+Fe,[it,Fe]),v.useEffect(()=>{vt.current=Ct},[Ct]),v.useEffect(()=>{$(!0)},[]),v.useEffect(()=>{let ve=We.current;if(ve){let pe=ve.getBoundingClientRect().height;return st(pe),x(ye=>[{toastId:p.id,height:pe,position:p.position},...ye]),()=>x(ye=>ye.filter(Oe=>Oe.toastId!==p.id))}},[x,p.id]),v.useLayoutEffect(()=>{if(!z)return;let ve=We.current,pe=ve.style.height;ve.style.height="auto";let ye=ve.getBoundingClientRect().height;ve.style.height=pe,st(ye),x(Oe=>Oe.find(Ke=>Ke.toastId===p.id)?Oe.map(Ke=>Ke.toastId===p.id?{...Ke,height:ye}:Ke):[{toastId:p.id,height:ye,position:p.position},...Oe])},[z,p.title,p.description,x,p.id]);let ce=v.useCallback(()=>{J(!0),Ne(Et.current),x(ve=>ve.filter(pe=>pe.toastId!==p.id)),setTimeout(()=>{T(p)},n1)},[p,T,x,Et]);v.useEffect(()=>{if(p.promise&&Me==="loading"||p.duration===1/0||p.type==="loading")return;let ve;return C||g||P&&Ve?(()=>{if(sn.current<Tt.current){let pe=new Date().getTime()-Tt.current;vt.current=vt.current-pe}sn.current=new Date().getTime()})():vt.current!==1/0&&(Tt.current=new Date().getTime(),ve=setTimeout(()=>{var pe;(pe=p.onAutoClose)==null||pe.call(p,p),ce()},vt.current)),()=>clearTimeout(ve)},[C,g,p,Me,P,Ve,ce]),v.useEffect(()=>{p.delete&&ce()},[ce,p.delete]);function He(){var ve,pe,ye;return H!=null&&H.loading?v.createElement("div",{className:xn(I==null?void 0:I.loader,(ve=p==null?void 0:p.classNames)==null?void 0:ve.loader,"sonner-loader"),"data-visible":Me==="loading"},H.loading):B?v.createElement("div",{className:xn(I==null?void 0:I.loader,(pe=p==null?void 0:p.classNames)==null?void 0:pe.loader,"sonner-loader"),"data-visible":Me==="loading"},B):v.createElement(DN,{className:xn(I==null?void 0:I.loader,(ye=p==null?void 0:p.classNames)==null?void 0:ye.loader),visible:Me==="loading"})}return v.createElement("li",{tabIndex:0,ref:We,className:xn(W,Ze,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[Me],(n=p==null?void 0:p.classNames)==null?void 0:n[Me]),"data-sonner-toast":"","data-rich-colors":(r=p.richColors)!=null?r:E,"data-styled":!(p.jsx||p.unstyled||b),"data-mounted":z,"data-promise":!!p.promise,"data-swiped":ge,"data-removed":ee,"data-visible":Ge,"data-y-position":Vt,"data-x-position":It,"data-index":S,"data-front":Le,"data-swiping":K,"data-dismissible":$e,"data-type":Me,"data-invert":jt,"data-swipe-out":me,"data-swipe-direction":L,"data-expanded":!!(C||R&&z),style:{"--index":S,"--toasts-before":S,"--z-index":k.length-S,"--offset":`${ee?Te:Et.current}px`,"--initial-height":R?"auto":`${ke}px`,..._,...p.style},onDragEnd:()=>{Q(!1),M(null),At.current=null},onPointerDown:ve=>{Z||!$e||(ht.current=new Date,Ne(Et.current),ve.target.setPointerCapture(ve.pointerId),ve.target.tagName!=="BUTTON"&&(Q(!0),At.current={x:ve.clientX,y:ve.clientY}))},onPointerUp:()=>{var ve,pe,ye,Oe;if(me||!$e)return;At.current=null;let Ke=Number(((ve=We.current)==null?void 0:ve.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),lt=Number(((pe=We.current)==null?void 0:pe.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),ct=new Date().getTime()-((ye=ht.current)==null?void 0:ye.getTime()),Re=O==="x"?Ke:lt,mt=Math.abs(Re)/ct;if(Math.abs(Re)>=t1||mt>.11){Ne(Et.current),(Oe=p.onDismiss)==null||Oe.call(p,p),te(O==="x"?Ke>0?"right":"left":lt>0?"down":"up"),ce(),de(!0),we(!1);return}Q(!1),M(null)},onPointerMove:ve=>{var pe,ye,Oe,Ke;if(!At.current||!$e||((pe=window.getSelection())==null?void 0:pe.toString().length)>0)return;let lt=ve.clientY-At.current.y,ct=ve.clientX-At.current.x,Re=(ye=e.swipeDirections)!=null?ye:r1(X);!O&&(Math.abs(ct)>1||Math.abs(lt)>1)&&M(Math.abs(ct)>Math.abs(lt)?"x":"y");let mt={x:0,y:0};O==="y"?(Re.includes("top")||Re.includes("bottom"))&&(Re.includes("top")&<<0||Re.includes("bottom")&<>0)&&(mt.y=lt):O==="x"&&(Re.includes("left")||Re.includes("right"))&&(Re.includes("left")&&ct<0||Re.includes("right")&&ct>0)&&(mt.x=ct),(Math.abs(mt.x)>0||Math.abs(mt.y)>0)&&we(!0),(Oe=We.current)==null||Oe.style.setProperty("--swipe-amount-x",`${mt.x}px`),(Ke=We.current)==null||Ke.style.setProperty("--swipe-amount-y",`${mt.y}px`)}},St&&!p.jsx?v.createElement("button",{"aria-label":Y,"data-disabled":Z,"data-close-button":!0,onClick:Z||!$e?()=>{}:()=>{var ve;ce(),(ve=p.onDismiss)==null||ve.call(p,p)},className:xn(I==null?void 0:I.closeButton,(o=p==null?void 0:p.classNames)==null?void 0:o.closeButton)},(s=H==null?void 0:H.close)!=null?s:zN):null,p.jsx||v.isValidElement(p.title)?p.jsx?p.jsx:typeof p.title=="function"?p.title():p.title:v.createElement(v.Fragment,null,Me||p.icon||p.promise?v.createElement("div",{"data-icon":"",className:xn(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||He():null,p.type!=="loading"?p.icon||(H==null?void 0:H[Me])||MN(Me):null):null,v.createElement("div",{"data-content":"",className:xn(I==null?void 0:I.content,(a=p==null?void 0:p.classNames)==null?void 0:a.content)},v.createElement("div",{"data-title":"",className:xn(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?v.createElement("div",{"data-description":"",className:xn(G,Nt,I==null?void 0:I.description,(u=p==null?void 0:p.classNames)==null?void 0:u.description)},typeof p.description=="function"?p.description():p.description):null),v.isValidElement(p.cancel)?p.cancel:p.cancel&&yi(p.cancel)?v.createElement("button",{"data-button":!0,"data-cancel":!0,style:p.cancelButtonStyle||D,onClick:ve=>{var pe,ye;yi(p.cancel)&&$e&&((ye=(pe=p.cancel).onClick)==null||ye.call(pe,ve),ce())},className:xn(I==null?void 0:I.cancelButton,(d=p==null?void 0:p.classNames)==null?void 0:d.cancelButton)},p.cancel.label):null,v.isValidElement(p.action)?p.action:p.action&&yi(p.action)?v.createElement("button",{"data-button":!0,"data-action":!0,style:p.actionButtonStyle||F,onClick:ve=>{var pe,ye;yi(p.action)&&((ye=(pe=p.action).onClick)==null||ye.call(pe,ve),!ve.defaultPrevented&&ce())},className:xn(I==null?void 0:I.actionButton,(f=p==null?void 0:p.classNames)==null?void 0:f.actionButton)},p.action.label):null))};function Ox(){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 s1(e,t){let n={};return[e,t].forEach((r,o)=>{let s=o===1,i=s?"--mobile-offset":"--offset",a=s?ZN:JN;function l(u){["top","right","bottom","left"].forEach(d=>{n[`${i}-${d}`]=typeof u=="number"?`${u}px`:u})}typeof r=="number"||typeof r=="string"?l(r):typeof r=="object"?["top","right","bottom","left"].forEach(u=>{r[u]===void 0?n[`${i}-${u}`]=a:n[`${i}-${u}`]=typeof r[u]=="number"?`${r[u]}px`:r[u]}):l(a)}),n}var i1=v.forwardRef(function(e,t){let{invert:n,position:r="bottom-right",hotkey:o=["altKey","KeyT"],expand:s,closeButton:i,className:a,offset:l,mobileOffset:u,theme:d="light",richColors:f,duration:m,style:p,visibleToasts:b=XN,toastOptions:g,dir:x=Ox(),gap:y=e1,loadingIcon:w,icons:S,containerAriaLabel:k="Notifications",pauseWhenPageIsHidden:C}=e,[T,E]=v.useState([]),j=v.useMemo(()=>Array.from(new Set([r].concat(T.filter(P=>P.position).map(P=>P.position)))),[T,r]),[_,D]=v.useState([]),[F,W]=v.useState(!1),[G,A]=v.useState(!1),[X,q]=v.useState(d!=="system"?d:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),B=v.useRef(null),R=o.join("+").replace(/Key/g,"").replace(/Digit/g,""),I=v.useRef(null),H=v.useRef(!1),Y=v.useCallback(P=>{E(O=>{var M;return(M=O.find(L=>L.id===P.id))!=null&&M.delete||Wt.dismiss(P.id),O.filter(({id:L})=>L!==P.id)})},[]);return v.useEffect(()=>Wt.subscribe(P=>{if(P.dismiss){E(O=>O.map(M=>M.id===P.id?{...M,delete:!0}:M));return}setTimeout(()=>{$o.flushSync(()=>{E(O=>{let M=O.findIndex(L=>L.id===P.id);return M!==-1?[...O.slice(0,M),{...O[M],...P},...O.slice(M+1)]:[P,...O]})})})}),[]),v.useEffect(()=>{if(d!=="system"){q(d);return}if(d==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?q("dark"):q("light")),typeof window>"u")return;let P=window.matchMedia("(prefers-color-scheme: dark)");try{P.addEventListener("change",({matches:O})=>{q(O?"dark":"light")})}catch{P.addListener(({matches:M})=>{try{q(M?"dark":"light")}catch(L){console.error(L)}})}},[d]),v.useEffect(()=>{T.length<=1&&W(!1)},[T]),v.useEffect(()=>{let P=O=>{var M,L;o.every(te=>O[te]||O.code===te)&&(W(!0),(M=B.current)==null||M.focus()),O.code==="Escape"&&(document.activeElement===B.current||(L=B.current)!=null&&L.contains(document.activeElement))&&W(!1)};return document.addEventListener("keydown",P),()=>document.removeEventListener("keydown",P)},[o]),v.useEffect(()=>{if(B.current)return()=>{I.current&&(I.current.focus({preventScroll:!0}),I.current=null,H.current=!1)}},[B.current]),v.createElement("section",{ref:t,"aria-label":`${k} ${R}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},j.map((P,O)=>{var M;let[L,te]=P.split("-");return T.length?v.createElement("ol",{key:P,dir:x==="auto"?Ox():x,tabIndex:-1,ref:B,className:a,"data-sonner-toaster":!0,"data-theme":X,"data-y-position":L,"data-lifted":F&&T.length>1&&!s,"data-x-position":te,style:{"--front-toast-height":`${((M=_[0])==null?void 0:M.height)||0}px`,"--width":`${QN}px`,"--gap":`${y}px`,...p,...s1(l,u)},onBlur:z=>{H.current&&!z.currentTarget.contains(z.relatedTarget)&&(H.current=!1,I.current&&(I.current.focus({preventScroll:!0}),I.current=null))},onFocus:z=>{z.target instanceof HTMLElement&&z.target.dataset.dismissible==="false"||H.current||(H.current=!0,I.current=z.relatedTarget)},onMouseEnter:()=>W(!0),onMouseMove:()=>W(!0),onMouseLeave:()=>{G||W(!1)},onDragEnd:()=>W(!1),onPointerDown:z=>{z.target instanceof HTMLElement&&z.target.dataset.dismissible==="false"||A(!0)},onPointerUp:()=>A(!1)},T.filter(z=>!z.position&&O===0||z.position===P).map((z,$)=>{var ee,J;return v.createElement(o1,{key:z.id,icons:S,index:$,toast:z,defaultRichColors:f,duration:(ee=g==null?void 0:g.duration)!=null?ee:m,className:g==null?void 0:g.className,descriptionClassName:g==null?void 0:g.descriptionClassName,invert:n,visibleToasts:b,closeButton:(J=g==null?void 0:g.closeButton)!=null?J:i,interacting:G,position:P,style:g==null?void 0:g.style,unstyled:g==null?void 0:g.unstyled,classNames:g==null?void 0:g.classNames,cancelButtonStyle:g==null?void 0:g.cancelButtonStyle,actionButtonStyle:g==null?void 0:g.actionButtonStyle,removeToast:Y,toasts:T.filter(K=>K.position==z.position),heights:_.filter(K=>K.position==z.position),setHeights:D,expandByDefault:s,gap:y,loadingIcon:w,expanded:F,pauseWhenPageIsHidden:C,swipeDirections:e.swipeDirections})})):null}))});const a1=({...e})=>{const{theme:t="system"}=RN();return c.jsx(i1,{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})};U.Api=Sb,U.ApiClient=yb,U.ApiProvider=hu,U.ArtifactRenderer=Lh,U.Badge=mm,U.Button=Je,U.Card=fl,U.CardContent=gl,U.CardDescription=ml,U.CardHeader=pl,U.CardTitle=hl,U.ChatApi=Zo,U.ChatApp=zE,U.ChatInput=tp,U.ChatInputRow=np,U.ChatInterface=Dr,U.ChatProviders=yr,U.ChatWidget=WE,U.Command=Rl,U.CommandEmpty=Dl,U.CommandGroup=Ll,U.CommandInput=Ml,U.CommandItem=$l,U.CommandList=Ol,U.DEFAULT_TIMEOUT_MS=lu,U.Dialog=il,U.DialogContent=Ws,U.DialogHeader=Vs,U.DialogTitle=Ks,U.DropdownMenu=Es,U.DropdownMenuContent=xo,U.DropdownMenuItem=zn,U.DropdownMenuTrigger=Is,U.FileViewerModal=wh,U.HISTORY_TIMEOUT_MS=cu,U.Input=Vl,U.InterruptPartRenderer=Fh,U.Label=Ym,U.MarkdownContent=Gn,U.MessageComponent=ri,U.MessageList=El,U.MessageRow=kl,U.NewChatButton=VE,U.PlotArtifact=Mh,U.ResearchTaskArtifact=Dh,U.SETTINGS_STORAGE_KEY=Vi,U.ScrollArea=Wl,U.Select=TI,U.SelectContent=Dg,U.SelectItem=Lg,U.SelectTrigger=Rg,U.SelectValue=kI,U.Separator=zg,U.Sheet=DI,U.SheetContent=Xg,U.SheetDescription=Qg,U.SheetHeader=Jg,U.SheetTitle=Zg,U.SheetTrigger=LI,U.SimpleChat=HE,U.SimpleJsonView=_o,U.Sonner=a1,U.StreamProgress=Bh,U.Switch=Gg,U.Textarea=_a,U.ThinkingIndicator=zh,U.ThreadListItem=Um,U.ThreadManager=ci,U.ThreadStateProvider=Lu,U.ThreadsProvider=ku,U.TimelineColumn=Zx,U.Toaster=AN,U.ToolComponent=pm,U.Tooltip=iN,U.TooltipContent=lx,U.TooltipProvider=sN,U.TooltipTrigger=aN,U.UserTextContent=Hh,U.applySettings=nw,U.buildCheckpointIndex=fc,U.buildCheckpointPreviewMap=zx,U.chatApiClient=jn,U.del=Li,U.downloadFileById=du,U.extractConfigFields=Ci,U.fileToBase64=mu,U.get=Yt,U.getChatToken=iu,U.getCheckpointForMessage=Hx,U.getCurrentSettings=tw,U.getDefaultApiConfig=Ku,U.getDefaultChatSettings=qu,U.getFileContent=Fi,U.getFileInfo=Tb,U.getMessageAttemptInfo=pc,U.getMessageDomKey=Tl,U.getPreviewForMessage=Si,U.httpClient=Gt,U.hydrateHistorySnapshots=Dn,U.isEnvelope=xu,U.listFiles=fu,U.loadStoredSettings=Gu,U.onChatTokenChanged=au,U.post=Jo,U.processAttachments=gu,U.put=uu,U.readNumber=mc,U.readString=On,U.resolveChatBaseUrl=bn,U.saveSettings=Yu,U.setChatToken=Xo,U.toPlainObject=Mn,U.unwrap=Ot,U.useApi=Zr,U.useCheckpointIndex=hc,U.useFilePreview=um,U.useHasChatSession=Zb,U.useParsedMessageContent=dm,U.useShallowStableValue=Hu,U.useStream=Wi,U.useStreamingHook=Wi,U.useThreadHistoryState=Ru,U.useThreadManagerViewState=Km,U.useThreadState=no,U.useThreadStateUpdater=Du,U.useThreads=vr,U.useThreadsState=Cu,U.viewFileById=Cb,Object.defineProperty(U,Symbol.toStringTag,{value:"Module"})});
|