teodor-new-chat-ui 4.3.483 → 4.3.484

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.umd.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(U,w){typeof exports=="object"&&typeof module<"u"?w(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"],w):(U=typeof globalThis<"u"?globalThis:U||self,w(U.NewChatUI={},U.React,U.reactSlot,U.classVarianceAuthority,U.clsx,U.tailwindMerge,U.LucideReact,U.ReactDOM))})(this,function(U,w,Vt,Hr,ox,sx,le,Mo){"use strict";var l1=Object.defineProperty;var c1=(U,w,Vt)=>w in U?l1(U,w,{enumerable:!0,configurable:!0,writable:!0,value:Vt}):U[w]=Vt;var nx=(U,w,Vt)=>c1(U,typeof w!="symbol"?w+"":w,Vt);function Zl(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 p=Zl(w),Ur=Zl(Mo),Ql=120;function ix(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>Ql?`${n.slice(0,Ql-3)}…`:n:""}function xi(e){return ix(e.content)||""}function ax(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=xi(o);s&&t.set(r.checkpointId,s)}}return t}function ec(e){const t=new Map,n=[],r=new Map,o=[];for(let c=0;c<e.length;c++){const d=e[c],h=d.checkpointId,m=h??`cp-${c}`,f=d.metadata??{},v=typeof f.step=="number"?f.step:null,g=typeof f.source=="string"?f.source:null;let x=null,y=null;const b=Array.isArray(d.messages)?d.messages:[];for(const T of b)T.role==="user"&&(y||(y=T),T.id&&(x=T.id));const C=d.next&&d.next.length>0?String(d.next[0]):null,k=d.parentConfig??null,S={id:m,step:v,source:g,createdAt:d.createdAt??null,namespace:d.checkpointNs??null,parentId:d.parentId??null,next:C,parentConfig:k,userMessageId:x};if(o.push(S),h&&t.set(h,S),h&&y){const T=xi(y);T&&r.set(h,T)}n.push({id:m,messageId:x,step:v,source:g,createdAt:d.createdAt??null,next:C,parentConfig:k})}const s=new Map;for(const c of o){if(!c.userMessageId)continue;const d=s.get(c.userMessageId)??[];d.push(c),s.set(c.userMessageId,d)}for(const c of s.values()){if(!c.length)continue;c.sort((h,m)=>{const f=h.createdAt?Date.parse(h.createdAt):0;return(m.createdAt?Date.parse(m.createdAt):0)-f});const d=c.length;for(let h=0;h<c.length;h++){const m=c[h];m.attemptCount=d,m.attemptIndex=h,m.isLatestAttempt=h===0}}return{checkpoints:e,checkpointMetaByCheckpointId:t,timeline:n,messagePreviews:r,getLatest:()=>{const c=n[0];if(c)return t.get(c.id)},getCheckpoint:c=>t.get(c),getMessageAttempts:c=>{const d=[];for(const h of t.values())h.userMessageId===c&&d.push(h);return d.length?(d.sort((h,m)=>{const f=typeof h.attemptIndex=="number"?h.attemptIndex:Number.MAX_SAFE_INTEGER,v=typeof m.attemptIndex=="number"?m.attemptIndex:Number.MAX_SAFE_INTEGER;return f-v}),d):[]}}}function tc(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 lx(e,t){return e?t.getCheckpoint(e)??null:null}function nc(e){return w.useMemo(()=>ec(e),[e])}function _n(e){if(!(!e||typeof e!="object"||Array.isArray(e)))return{...e}}function Rn(e,t){if(e)for(const n of t){const r=e[n];if(typeof r=="string"&&r.trim())return r.trim()}}function rc(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 vi(e){const t=_n(e);if(t)return _n(t.configurable)??t}function Yn(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)=>cx(s,i)).filter(s=>!!s)].sort((s,i)=>oc(i.createdAt)-oc(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 cx(e,t){var C;if(!e)return null;const r=(Array.isArray((C=e.values)==null?void 0:C.messages)?e.values.messages:[]).map(k=>ux(k)).filter(k=>!!k),o=_n(e.metadata)??{},s=vi(e.config),i=_n(e.parent_config??e.parentConfig),a=vi(i),l=Rn(s,["checkpoint_id","checkpointId"]),c=Rn(s,["checkpoint_ns","checkpointNs"]),d=Rn(a,["checkpoint_id","checkpointId"]),h=Rn(a,["checkpoint_id","checkpointId"])??null,m=Rn(a,["checkpoint_ns","checkpointNs"])??null,f=_n(e.config),v=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:rc(o,["step"])??0,source:Rn(o,["source"])??null},b=r.map(k=>({...k,checkpointId:l??null}));return{checkpointId:l??null,checkpointNs:c??null,createdAt:x,parentId:d??null,messages:b,nextCursor:h,nextCursorNs:m,interrupt:px(r,t),metadata:y,config:f??null,parentConfig:i??null,next:g,tasks:v}}function ux(e){var s,i,a;if(!e||typeof e!="object")return null;const t=dx(e);if(!t)return null;const n=hx(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 dx(e){const t=typeof e.role=="string"?e.role:void 0;if(t&&fx(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 fx(e){return e==="assistant"||e==="user"||e==="system"||e==="tool"||e==="default_message"}function hx(e){return typeof e=="string"?[{type:"text",text:e}]:Array.isArray(e)?e.filter(t=>!!(t&&typeof t=="object"&&typeof t.type=="string")):[]}function px(e,t){return mx(e,t)}function mx(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 oc(e){if(!e)return 0;const t=Date.parse(e);return Number.isFinite(t)?t:0}var wi={exports:{}},Wr={};/**
1
+ (function(H,w){typeof exports=="object"&&typeof module<"u"?w(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"],w):(H=typeof globalThis<"u"?globalThis:H||self,w(H.NewChatUI={},H.React,H.reactSlot,H.classVarianceAuthority,H.clsx,H.tailwindMerge,H.LucideReact,H.ReactDOM))})(this,function(H,w,Vt,Hr,ox,sx,ce,Mo){"use strict";var l1=Object.defineProperty;var c1=(H,w,Vt)=>w in H?l1(H,w,{enumerable:!0,configurable:!0,writable:!0,value:Vt}):H[w]=Vt;var nx=(H,w,Vt)=>c1(H,typeof w!="symbol"?w+"":w,Vt);function Zl(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 p=Zl(w),Ur=Zl(Mo),Ql=120;function ix(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>Ql?`${n.slice(0,Ql-3)}…`:n:""}function xi(e){return ix(e.content)||""}function ax(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=xi(o);s&&t.set(r.checkpointId,s)}}return t}function ec(e){const t=new Map,n=[],r=new Map,o=[];for(let c=0;c<e.length;c++){const d=e[c],h=d.checkpointId,m=h??`cp-${c}`,f=d.metadata??{},v=typeof f.step=="number"?f.step:null,g=typeof f.source=="string"?f.source:null;let x=null,y=null;const b=Array.isArray(d.messages)?d.messages:[];for(const T of b)T.role==="user"&&(y||(y=T),T.id&&(x=T.id));const C=d.next&&d.next.length>0?String(d.next[0]):null,k=d.parentConfig??null,S={id:m,step:v,source:g,createdAt:d.createdAt??null,namespace:d.checkpointNs??null,parentId:d.parentId??null,next:C,parentConfig:k,userMessageId:x};if(o.push(S),h&&t.set(h,S),h&&y){const T=xi(y);T&&r.set(h,T)}n.push({id:m,messageId:x,step:v,source:g,createdAt:d.createdAt??null,next:C,parentConfig:k})}const s=new Map;for(const c of o){if(!c.userMessageId)continue;const d=s.get(c.userMessageId)??[];d.push(c),s.set(c.userMessageId,d)}for(const c of s.values()){if(!c.length)continue;c.sort((h,m)=>{const f=h.createdAt?Date.parse(h.createdAt):0;return(m.createdAt?Date.parse(m.createdAt):0)-f});const d=c.length;for(let h=0;h<c.length;h++){const m=c[h];m.attemptCount=d,m.attemptIndex=h,m.isLatestAttempt=h===0}}return{checkpoints:e,checkpointMetaByCheckpointId:t,timeline:n,messagePreviews:r,getLatest:()=>{const c=n[0];if(c)return t.get(c.id)},getCheckpoint:c=>t.get(c),getMessageAttempts:c=>{const d=[];for(const h of t.values())h.userMessageId===c&&d.push(h);return d.length?(d.sort((h,m)=>{const f=typeof h.attemptIndex=="number"?h.attemptIndex:Number.MAX_SAFE_INTEGER,v=typeof m.attemptIndex=="number"?m.attemptIndex:Number.MAX_SAFE_INTEGER;return f-v}),d):[]}}}function tc(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 lx(e,t){return e?t.getCheckpoint(e)??null:null}function nc(e){return w.useMemo(()=>ec(e),[e])}function _n(e){if(!(!e||typeof e!="object"||Array.isArray(e)))return{...e}}function Rn(e,t){if(e)for(const n of t){const r=e[n];if(typeof r=="string"&&r.trim())return r.trim()}}function rc(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 vi(e){const t=_n(e);if(t)return _n(t.configurable)??t}function Yn(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)=>cx(s,i)).filter(s=>!!s)].sort((s,i)=>oc(i.createdAt)-oc(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 cx(e,t){var C;if(!e)return null;const r=(Array.isArray((C=e.values)==null?void 0:C.messages)?e.values.messages:[]).map(k=>ux(k)).filter(k=>!!k),o=_n(e.metadata)??{},s=vi(e.config),i=_n(e.parent_config??e.parentConfig),a=vi(i),l=Rn(s,["checkpoint_id","checkpointId"]),c=Rn(s,["checkpoint_ns","checkpointNs"]),d=Rn(a,["checkpoint_id","checkpointId"]),h=Rn(a,["checkpoint_id","checkpointId"])??null,m=Rn(a,["checkpoint_ns","checkpointNs"])??null,f=_n(e.config),v=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:rc(o,["step"])??0,source:Rn(o,["source"])??null},b=r.map(k=>({...k,checkpointId:l??null}));return{checkpointId:l??null,checkpointNs:c??null,createdAt:x,parentId:d??null,messages:b,nextCursor:h,nextCursorNs:m,interrupt:px(r,t),metadata:y,config:f??null,parentConfig:i??null,next:g,tasks:v}}function ux(e){var s,i,a;if(!e||typeof e!="object")return null;const t=dx(e);if(!t)return null;const n=hx(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 dx(e){const t=typeof e.role=="string"?e.role:void 0;if(t&&fx(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 fx(e){return e==="assistant"||e==="user"||e==="system"||e==="tool"||e==="default_message"}function hx(e){return typeof e=="string"?[{type:"text",text:e}]:Array.isArray(e)?e.filter(t=>!!(t&&typeof t=="object"&&typeof t.type=="string")):[]}function px(e,t){return mx(e,t)}function mx(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 oc(e){if(!e)return 0;const t=Date.parse(e);return Number.isFinite(t)?t:0}var wi={exports:{}},Wr={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.min.js
4
4
  *
@@ -14,29 +14,29 @@
14
14
  *
15
15
  * This source code is licensed under the MIT license found in the
16
16
  * LICENSE file in the root directory of this source tree.
17
- */var ic;function xx(){return ic||(ic=1,process.env.NODE_ENV!=="production"&&function(){var e=w,t=Symbol.for("react.element"),n=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),a=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),h=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),f=Symbol.for("react.offscreen"),v=Symbol.iterator,g="@@iterator";function x(N){if(N===null||typeof N!="object")return null;var ee=v&&N[v]||N[g];return typeof ee=="function"?ee:null}var y=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function b(N){{for(var ee=arguments.length,ue=new Array(ee>1?ee-1:0),Ee=1;Ee<ee;Ee++)ue[Ee-1]=arguments[Ee];C("error",N,ue)}}function C(N,ee,ue){{var Ee=y.ReactDebugCurrentFrame,Qe=Ee.getStackAddendum();Qe!==""&&(ee+="%s",ue=ue.concat([Qe]));var st=ue.map(function(Ve){return String(Ve)});st.unshift("Warning: "+ee),Function.prototype.apply.call(console[N],console,st)}}var k=!1,S=!1,T=!1,E=!1,A=!1,R;R=Symbol.for("react.module.reference");function $(N){return!!(typeof N=="string"||typeof N=="function"||N===r||N===s||A||N===o||N===c||N===d||E||N===f||k||S||T||typeof N=="object"&&N!==null&&(N.$$typeof===m||N.$$typeof===h||N.$$typeof===i||N.$$typeof===a||N.$$typeof===l||N.$$typeof===R||N.getModuleId!==void 0))}function F(N,ee,ue){var Ee=N.displayName;if(Ee)return Ee;var Qe=ee.displayName||ee.name||"";return Qe!==""?ue+"("+Qe+")":ue}function V(N){return N.displayName||"Context"}function X(N){if(N==null)return null;if(typeof N.tag=="number"&&b("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof N=="function")return N.displayName||N.name||null;if(typeof N=="string")return N;switch(N){case r:return"Fragment";case n:return"Portal";case s:return"Profiler";case o:return"StrictMode";case c:return"Suspense";case d:return"SuspenseList"}if(typeof N=="object")switch(N.$$typeof){case a:var ee=N;return V(ee)+".Consumer";case i:var ue=N;return V(ue._context)+".Provider";case l:return F(N,N.render,"ForwardRef");case h:var Ee=N.displayName||null;return Ee!==null?Ee:X(N.type)||"Memo";case m:{var Qe=N,st=Qe._payload,Ve=Qe._init;try{return X(Ve(st))}catch{return null}}}return null}var _=Object.assign,G=0,H,z,D,I,Y,J,j;function B(){}B.__reactDisabledLog=!0;function P(){{if(G===0){H=console.log,z=console.info,D=console.warn,I=console.error,Y=console.group,J=console.groupCollapsed,j=console.groupEnd;var N={configurable:!0,enumerable:!0,value:B,writable:!0};Object.defineProperties(console,{info:N,log:N,warn:N,error:N,group:N,groupCollapsed:N,groupEnd:N})}G++}}function O(){{if(G--,G===0){var N={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:_({},N,{value:H}),info:_({},N,{value:z}),warn:_({},N,{value:D}),error:_({},N,{value:I}),group:_({},N,{value:Y}),groupCollapsed:_({},N,{value:J}),groupEnd:_({},N,{value:j})})}G<0&&b("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var K=y.ReactCurrentDispatcher,M;function L(N,ee,ue){{if(M===void 0)try{throw Error()}catch(Qe){var Ee=Qe.stack.trim().match(/\n( *(at )?)/);M=Ee&&Ee[1]||""}return`
18
- `+M+N}}var q=!1,Z;{var se=typeof WeakMap=="function"?WeakMap:Map;Z=new se}function ie(N,ee){if(!N||q)return"";{var ue=Z.get(N);if(ue!==void 0)return ue}var Ee;q=!0;var Qe=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var st;st=K.current,K.current=null,P();try{if(ee){var Ve=function(){throw Error()};if(Object.defineProperty(Ve.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Ve,[])}catch(Wt){Ee=Wt}Reflect.construct(N,[],Ve)}else{try{Ve.call()}catch(Wt){Ee=Wt}N.call(Ve.prototype)}}else{try{throw Error()}catch(Wt){Ee=Wt}N()}}catch(Wt){if(Wt&&Ee&&typeof Wt.stack=="string"){for(var ze=Wt.stack.split(`
19
- `),Lt=Ee.stack.split(`
20
- `),vt=ze.length-1,yt=Lt.length-1;vt>=1&&yt>=0&&ze[vt]!==Lt[yt];)yt--;for(;vt>=1&&yt>=0;vt--,yt--)if(ze[vt]!==Lt[yt]){if(vt!==1||yt!==1)do if(vt--,yt--,yt<0||ze[vt]!==Lt[yt]){var on=`
21
- `+ze[vt].replace(" at new "," at ");return N.displayName&&on.includes("<anonymous>")&&(on=on.replace("<anonymous>",N.displayName)),typeof N=="function"&&Z.set(N,on),on}while(vt>=1&&yt>=0);break}}}finally{q=!1,K.current=st,O(),Error.prepareStackTrace=Qe}var zr=N?N.displayName||N.name:"",hr=zr?L(zr):"";return typeof N=="function"&&Z.set(N,hr),hr}function re(N,ee,ue){return ie(N,!1)}function de(N){var ee=N.prototype;return!!(ee&&ee.isReactComponent)}function be(N,ee,ue){if(N==null)return"";if(typeof N=="function")return ie(N,de(N));if(typeof N=="string")return L(N);switch(N){case c:return L("Suspense");case d:return L("SuspenseList")}if(typeof N=="object")switch(N.$$typeof){case l:return re(N.render);case h:return be(N.type,ee,ue);case m:{var Ee=N,Qe=Ee._payload,st=Ee._init;try{return be(st(Qe),ee,ue)}catch{}}}return""}var Me=Object.prototype.hasOwnProperty,Fe={},De=y.ReactDebugCurrentFrame;function Le(N){if(N){var ee=N._owner,ue=be(N.type,N._source,ee?ee.type:null);De.setExtraStackFrame(ue)}else De.setExtraStackFrame(null)}function it(N,ee,ue,Ee,Qe){{var st=Function.call.bind(Me);for(var Ve in N)if(st(N,Ve)){var ze=void 0;try{if(typeof N[Ve]!="function"){var Lt=Error((Ee||"React class")+": "+ue+" type `"+Ve+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof N[Ve]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw Lt.name="Invariant Violation",Lt}ze=N[Ve](ee,Ve,Ee,ue,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(vt){ze=vt}ze&&!(ze instanceof Error)&&(Le(Qe),b("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",Ee||"React class",ue,Ve,typeof ze),Le(null)),ze instanceof Error&&!(ze.message in Fe)&&(Fe[ze.message]=!0,Le(Qe),b("Failed %s type: %s",ue,ze.message),Le(null))}}}var dt=Array.isArray;function Et(N){return dt(N)}function Ke(N){{var ee=typeof Symbol=="function"&&Symbol.toStringTag,ue=ee&&N[Symbol.toStringTag]||N.constructor.name||"Object";return ue}}function We(N){try{return Xe(N),!1}catch{return!0}}function Xe(N){return""+N}function ke(N){if(We(N))return b("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Ke(N)),Xe(N)}var Ue=y.ReactCurrentOwner,ut={key:!0,ref:!0,__self:!0,__source:!0},bt,Je;function Ct(N){if(Me.call(N,"ref")){var ee=Object.getOwnPropertyDescriptor(N,"ref").get;if(ee&&ee.isReactWarning)return!1}return N.ref!==void 0}function gt(N){if(Me.call(N,"key")){var ee=Object.getOwnPropertyDescriptor(N,"key").get;if(ee&&ee.isReactWarning)return!1}return N.key!==void 0}function xt(N,ee){typeof N.ref=="string"&&Ue.current}function It(N,ee){{var ue=function(){bt||(bt=!0,b("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",ee))};ue.isReactWarning=!0,Object.defineProperty(N,"key",{get:ue,configurable:!0})}}function rn(N,ee){{var ue=function(){Je||(Je=!0,b("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",ee))};ue.isReactWarning=!0,Object.defineProperty(N,"ref",{get:ue,configurable:!0})}}var Nt=function(N,ee,ue,Ee,Qe,st,Ve){var ze={$$typeof:t,type:N,key:ee,ref:ue,props:Ve,_owner:st};return ze._store={},Object.defineProperty(ze._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(ze,"_self",{configurable:!1,enumerable:!1,writable:!1,value:Ee}),Object.defineProperty(ze,"_source",{configurable:!1,enumerable:!1,writable:!1,value:Qe}),Object.freeze&&(Object.freeze(ze.props),Object.freeze(ze)),ze};function mn(N,ee,ue,Ee,Qe){{var st,Ve={},ze=null,Lt=null;ue!==void 0&&(ke(ue),ze=""+ue),gt(ee)&&(ke(ee.key),ze=""+ee.key),Ct(ee)&&(Lt=ee.ref,xt(ee,Qe));for(st in ee)Me.call(ee,st)&&!ut.hasOwnProperty(st)&&(Ve[st]=ee[st]);if(N&&N.defaultProps){var vt=N.defaultProps;for(st in vt)Ve[st]===void 0&&(Ve[st]=vt[st])}if(ze||Lt){var yt=typeof N=="function"?N.displayName||N.name||"Unknown":N;ze&&It(Ve,yt),Lt&&rn(Ve,yt)}return Nt(N,ze,Lt,Qe,Ee,Ue.current,Ve)}}var Zt=y.ReactCurrentOwner,Be=y.ReactDebugCurrentFrame;function $e(N){if(N){var ee=N._owner,ue=be(N.type,N._source,ee?ee.type:null);Be.setExtraStackFrame(ue)}else Be.setExtraStackFrame(null)}var Tt;Tt=!1;function ne(N){return typeof N=="object"&&N!==null&&N.$$typeof===t}function xe(){{if(Zt.current){var N=X(Zt.current.type);if(N)return`
17
+ */var ic;function xx(){return ic||(ic=1,process.env.NODE_ENV!=="production"&&function(){var e=w,t=Symbol.for("react.element"),n=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),a=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),h=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),f=Symbol.for("react.offscreen"),v=Symbol.iterator,g="@@iterator";function x(N){if(N===null||typeof N!="object")return null;var ee=v&&N[v]||N[g];return typeof ee=="function"?ee:null}var y=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function b(N){{for(var ee=arguments.length,de=new Array(ee>1?ee-1:0),ke=1;ke<ee;ke++)de[ke-1]=arguments[ke];C("error",N,de)}}function C(N,ee,de){{var ke=y.ReactDebugCurrentFrame,Ze=ke.getStackAddendum();Ze!==""&&(ee+="%s",de=de.concat([Ze]));var ot=de.map(function(Ke){return String(Ke)});ot.unshift("Warning: "+ee),Function.prototype.apply.call(console[N],console,ot)}}var k=!1,S=!1,T=!1,E=!1,j=!1,_;_=Symbol.for("react.module.reference");function $(N){return!!(typeof N=="string"||typeof N=="function"||N===r||N===s||j||N===o||N===c||N===d||E||N===f||k||S||T||typeof N=="object"&&N!==null&&(N.$$typeof===m||N.$$typeof===h||N.$$typeof===i||N.$$typeof===a||N.$$typeof===l||N.$$typeof===_||N.getModuleId!==void 0))}function F(N,ee,de){var ke=N.displayName;if(ke)return ke;var Ze=ee.displayName||ee.name||"";return Ze!==""?de+"("+Ze+")":de}function U(N){return N.displayName||"Context"}function X(N){if(N==null)return null;if(typeof N.tag=="number"&&b("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof N=="function")return N.displayName||N.name||null;if(typeof N=="string")return N;switch(N){case r:return"Fragment";case n:return"Portal";case s:return"Profiler";case o:return"StrictMode";case c:return"Suspense";case d:return"SuspenseList"}if(typeof N=="object")switch(N.$$typeof){case a:var ee=N;return U(ee)+".Consumer";case i:var de=N;return U(de._context)+".Provider";case l:return F(N,N.render,"ForwardRef");case h:var ke=N.displayName||null;return ke!==null?ke:X(N.type)||"Memo";case m:{var Ze=N,ot=Ze._payload,Ke=Ze._init;try{return X(Ke(ot))}catch{return null}}}return null}var R=Object.assign,K=0,W,z,O,I,G,J,P;function B(){}B.__reactDisabledLog=!0;function A(){{if(K===0){W=console.log,z=console.info,O=console.warn,I=console.error,G=console.group,J=console.groupCollapsed,P=console.groupEnd;var N={configurable:!0,enumerable:!0,value:B,writable:!0};Object.defineProperties(console,{info:N,log:N,warn:N,error:N,group:N,groupCollapsed:N,groupEnd:N})}K++}}function D(){{if(K--,K===0){var N={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:R({},N,{value:W}),info:R({},N,{value:z}),warn:R({},N,{value:O}),error:R({},N,{value:I}),group:R({},N,{value:G}),groupCollapsed:R({},N,{value:J}),groupEnd:R({},N,{value:P})})}K<0&&b("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var q=y.ReactCurrentDispatcher,M;function L(N,ee,de){{if(M===void 0)try{throw Error()}catch(Ze){var ke=Ze.stack.trim().match(/\n( *(at )?)/);M=ke&&ke[1]||""}return`
18
+ `+M+N}}var Y=!1,Z;{var oe=typeof WeakMap=="function"?WeakMap:Map;Z=new oe}function se(N,ee){if(!N||Y)return"";{var de=Z.get(N);if(de!==void 0)return de}var ke;Y=!0;var Ze=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var ot;ot=q.current,q.current=null,A();try{if(ee){var Ke=function(){throw Error()};if(Object.defineProperty(Ke.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Ke,[])}catch(Wt){ke=Wt}Reflect.construct(N,[],Ke)}else{try{Ke.call()}catch(Wt){ke=Wt}N.call(Ke.prototype)}}else{try{throw Error()}catch(Wt){ke=Wt}N()}}catch(Wt){if(Wt&&ke&&typeof Wt.stack=="string"){for(var ze=Wt.stack.split(`
19
+ `),Lt=ke.stack.split(`
20
+ `),wt=ze.length-1,Ct=Lt.length-1;wt>=1&&Ct>=0&&ze[wt]!==Lt[Ct];)Ct--;for(;wt>=1&&Ct>=0;wt--,Ct--)if(ze[wt]!==Lt[Ct]){if(wt!==1||Ct!==1)do if(wt--,Ct--,Ct<0||ze[wt]!==Lt[Ct]){var on=`
21
+ `+ze[wt].replace(" at new "," at ");return N.displayName&&on.includes("<anonymous>")&&(on=on.replace("<anonymous>",N.displayName)),typeof N=="function"&&Z.set(N,on),on}while(wt>=1&&Ct>=0);break}}}finally{Y=!1,q.current=ot,D(),Error.prepareStackTrace=Ze}var zr=N?N.displayName||N.name:"",hr=zr?L(zr):"";return typeof N=="function"&&Z.set(N,hr),hr}function ie(N,ee,de){return se(N,!1)}function le(N){var ee=N.prototype;return!!(ee&&ee.isReactComponent)}function ye(N,ee,de){if(N==null)return"";if(typeof N=="function")return se(N,le(N));if(typeof N=="string")return L(N);switch(N){case c:return L("Suspense");case d:return L("SuspenseList")}if(typeof N=="object")switch(N.$$typeof){case l:return ie(N.render);case h:return ye(N.type,ee,de);case m:{var ke=N,Ze=ke._payload,ot=ke._init;try{return ye(ot(Ze),ee,de)}catch{}}}return""}var De=Object.prototype.hasOwnProperty,We={},Pe=y.ReactDebugCurrentFrame;function $e(N){if(N){var ee=N._owner,de=ye(N.type,N._source,ee?ee.type:null);Pe.setExtraStackFrame(de)}else Pe.setExtraStackFrame(null)}function lt(N,ee,de,ke,Ze){{var ot=Function.call.bind(De);for(var Ke in N)if(ot(N,Ke)){var ze=void 0;try{if(typeof N[Ke]!="function"){var Lt=Error((ke||"React class")+": "+de+" type `"+Ke+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof N[Ke]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw Lt.name="Invariant Violation",Lt}ze=N[Ke](ee,Ke,ke,de,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(wt){ze=wt}ze&&!(ze instanceof Error)&&($e(Ze),b("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",ke||"React class",de,Ke,typeof ze),$e(null)),ze instanceof Error&&!(ze.message in We)&&(We[ze.message]=!0,$e(Ze),b("Failed %s type: %s",de,ze.message),$e(null))}}}var ut=Array.isArray;function yt(N){return ut(N)}function qe(N){{var ee=typeof Symbol=="function"&&Symbol.toStringTag,de=ee&&N[Symbol.toStringTag]||N.constructor.name||"Object";return de}}function Xe(N){try{return Ve(N),!1}catch{return!0}}function Ve(N){return""+N}function Le(N){if(Xe(N))return b("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",qe(N)),Ve(N)}var Ae=y.ReactCurrentOwner,dt={key:!0,ref:!0,__self:!0,__source:!0},Rt,tt;function st(N){if(De.call(N,"ref")){var ee=Object.getOwnPropertyDescriptor(N,"ref").get;if(ee&&ee.isReactWarning)return!1}return N.ref!==void 0}function gt(N){if(De.call(N,"key")){var ee=Object.getOwnPropertyDescriptor(N,"key").get;if(ee&&ee.isReactWarning)return!1}return N.key!==void 0}function St(N,ee){typeof N.ref=="string"&&Ae.current}function xt(N,ee){{var de=function(){Rt||(Rt=!0,b("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",ee))};de.isReactWarning=!0,Object.defineProperty(N,"key",{get:de,configurable:!0})}}function rn(N,ee){{var de=function(){tt||(tt=!0,b("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",ee))};de.isReactWarning=!0,Object.defineProperty(N,"ref",{get:de,configurable:!0})}}var It=function(N,ee,de,ke,Ze,ot,Ke){var ze={$$typeof:t,type:N,key:ee,ref:de,props:Ke,_owner:ot};return ze._store={},Object.defineProperty(ze._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(ze,"_self",{configurable:!1,enumerable:!1,writable:!1,value:ke}),Object.defineProperty(ze,"_source",{configurable:!1,enumerable:!1,writable:!1,value:Ze}),Object.freeze&&(Object.freeze(ze.props),Object.freeze(ze)),ze};function mn(N,ee,de,ke,Ze){{var ot,Ke={},ze=null,Lt=null;de!==void 0&&(Le(de),ze=""+de),gt(ee)&&(Le(ee.key),ze=""+ee.key),st(ee)&&(Lt=ee.ref,St(ee,Ze));for(ot in ee)De.call(ee,ot)&&!dt.hasOwnProperty(ot)&&(Ke[ot]=ee[ot]);if(N&&N.defaultProps){var wt=N.defaultProps;for(ot in wt)Ke[ot]===void 0&&(Ke[ot]=wt[ot])}if(ze||Lt){var Ct=typeof N=="function"?N.displayName||N.name||"Unknown":N;ze&&xt(Ke,Ct),Lt&&rn(Ke,Ct)}return It(N,ze,Lt,Ze,ke,Ae.current,Ke)}}var Zt=y.ReactCurrentOwner,Ue=y.ReactDebugCurrentFrame;function Fe(N){if(N){var ee=N._owner,de=ye(N.type,N._source,ee?ee.type:null);Ue.setExtraStackFrame(de)}else Ue.setExtraStackFrame(null)}var vt;vt=!1;function ne(N){return typeof N=="object"&&N!==null&&N.$$typeof===t}function we(){{if(Zt.current){var N=X(Zt.current.type);if(N)return`
22
22
 
23
- Check the render method of \``+N+"`."}return""}}function pe(N){return""}var ce={};function Ce(N){{var ee=xe();if(!ee){var ue=typeof N=="string"?N:N.displayName||N.name;ue&&(ee=`
23
+ Check the render method of \``+N+"`."}return""}}function pe(N){return""}var ue={};function Ce(N){{var ee=we();if(!ee){var de=typeof N=="string"?N:N.displayName||N.name;de&&(ee=`
24
24
 
25
- Check the top-level render call using <`+ue+">.")}return ee}}function qe(N,ee){{if(!N._store||N._store.validated||N.key!=null)return;N._store.validated=!0;var ue=Ce(ee);if(ce[ue])return;ce[ue]=!0;var Ee="";N&&N._owner&&N._owner!==Zt.current&&(Ee=" It was passed a child from "+X(N._owner.type)+"."),$e(N),b('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',ue,Ee),$e(null)}}function Ne(N,ee){{if(typeof N!="object")return;if(Et(N))for(var ue=0;ue<N.length;ue++){var Ee=N[ue];ne(Ee)&&qe(Ee,ee)}else if(ne(N))N._store&&(N._store.validated=!0);else if(N){var Qe=x(N);if(typeof Qe=="function"&&Qe!==N.entries)for(var st=Qe.call(N),Ve;!(Ve=st.next()).done;)ne(Ve.value)&&qe(Ve.value,ee)}}}function je(N){{var ee=N.type;if(ee==null||typeof ee=="string")return;var ue;if(typeof ee=="function")ue=ee.propTypes;else if(typeof ee=="object"&&(ee.$$typeof===l||ee.$$typeof===h))ue=ee.propTypes;else return;if(ue){var Ee=X(ee);it(ue,N.props,"prop",Ee,N)}else if(ee.PropTypes!==void 0&&!Tt){Tt=!0;var Qe=X(ee);b("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",Qe||"Unknown")}typeof ee.getDefaultProps=="function"&&!ee.getDefaultProps.isReactClassApproved&&b("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Oe(N){{for(var ee=Object.keys(N.props),ue=0;ue<ee.length;ue++){var Ee=ee[ue];if(Ee!=="children"&&Ee!=="key"){$e(N),b("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",Ee),$e(null);break}}N.ref!==null&&($e(N),b("Invalid attribute `ref` supplied to `React.Fragment`."),$e(null))}}var tt={};function ye(N,ee,ue,Ee,Qe,st){{var Ve=$(N);if(!Ve){var ze="";(N===void 0||typeof N=="object"&&N!==null&&Object.keys(N).length===0)&&(ze+=" 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 Lt=pe();Lt?ze+=Lt:ze+=xe();var vt;N===null?vt="null":Et(N)?vt="array":N!==void 0&&N.$$typeof===t?(vt="<"+(X(N.type)||"Unknown")+" />",ze=" Did you accidentally export a JSX literal instead of a component?"):vt=typeof N,b("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",vt,ze)}var yt=mn(N,ee,ue,Qe,st);if(yt==null)return yt;if(Ve){var on=ee.children;if(on!==void 0)if(Ee)if(Et(on)){for(var zr=0;zr<on.length;zr++)Ne(on[zr],N);Object.freeze&&Object.freeze(on)}else b("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Ne(on,N)}if(Me.call(ee,"key")){var hr=X(N),Wt=Object.keys(ee).filter(function(a1){return a1!=="key"}),Jl=Wt.length>0?"{key: someKey, "+Wt.join(": ..., ")+": ...}":"{key: someKey}";if(!tt[hr+Jl]){var i1=Wt.length>0?"{"+Wt.join(": ..., ")+": ...}":"{}";b(`A props object containing a "key" prop is being spread into JSX:
25
+ Check the top-level render call using <`+de+">.")}return ee}}function Ge(N,ee){{if(!N._store||N._store.validated||N.key!=null)return;N._store.validated=!0;var de=Ce(ee);if(ue[de])return;ue[de]=!0;var ke="";N&&N._owner&&N._owner!==Zt.current&&(ke=" It was passed a child from "+X(N._owner.type)+"."),Fe(N),b('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',de,ke),Fe(null)}}function kt(N,ee){{if(typeof N!="object")return;if(yt(N))for(var de=0;de<N.length;de++){var ke=N[de];ne(ke)&&Ge(ke,ee)}else if(ne(N))N._store&&(N._store.validated=!0);else if(N){var Ze=x(N);if(typeof Ze=="function"&&Ze!==N.entries)for(var ot=Ze.call(N),Ke;!(Ke=ot.next()).done;)ne(Ke.value)&&Ge(Ke.value,ee)}}}function Ie(N){{var ee=N.type;if(ee==null||typeof ee=="string")return;var de;if(typeof ee=="function")de=ee.propTypes;else if(typeof ee=="object"&&(ee.$$typeof===l||ee.$$typeof===h))de=ee.propTypes;else return;if(de){var ke=X(ee);lt(de,N.props,"prop",ke,N)}else if(ee.PropTypes!==void 0&&!vt){vt=!0;var Ze=X(ee);b("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",Ze||"Unknown")}typeof ee.getDefaultProps=="function"&&!ee.getDefaultProps.isReactClassApproved&&b("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function _e(N){{for(var ee=Object.keys(N.props),de=0;de<ee.length;de++){var ke=ee[de];if(ke!=="children"&&ke!=="key"){Fe(N),b("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",ke),Fe(null);break}}N.ref!==null&&(Fe(N),b("Invalid attribute `ref` supplied to `React.Fragment`."),Fe(null))}}var Be={};function xe(N,ee,de,ke,Ze,ot){{var Ke=$(N);if(!Ke){var ze="";(N===void 0||typeof N=="object"&&N!==null&&Object.keys(N).length===0)&&(ze+=" 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 Lt=pe();Lt?ze+=Lt:ze+=we();var wt;N===null?wt="null":yt(N)?wt="array":N!==void 0&&N.$$typeof===t?(wt="<"+(X(N.type)||"Unknown")+" />",ze=" Did you accidentally export a JSX literal instead of a component?"):wt=typeof N,b("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",wt,ze)}var Ct=mn(N,ee,de,Ze,ot);if(Ct==null)return Ct;if(Ke){var on=ee.children;if(on!==void 0)if(ke)if(yt(on)){for(var zr=0;zr<on.length;zr++)kt(on[zr],N);Object.freeze&&Object.freeze(on)}else b("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else kt(on,N)}if(De.call(ee,"key")){var hr=X(N),Wt=Object.keys(ee).filter(function(a1){return a1!=="key"}),Jl=Wt.length>0?"{key: someKey, "+Wt.join(": ..., ")+": ...}":"{key: someKey}";if(!Be[hr+Jl]){var i1=Wt.length>0?"{"+Wt.join(": ..., ")+": ...}":"{}";b(`A props object containing a "key" prop is being spread into JSX:
26
26
  let props = %s;
27
27
  <%s {...props} />
28
28
  React keys must be passed directly to JSX without using spread:
29
29
  let props = %s;
30
- <%s key={someKey} {...props} />`,Jl,hr,i1,hr),tt[hr+Jl]=!0}}return N===r?Oe(yt):je(yt),yt}}function Ye(N,ee,ue){return ye(N,ee,ue,!0)}function nt(N,ee,ue){return ye(N,ee,ue,!1)}var ft=nt,In=Ye;Vr.Fragment=r,Vr.jsx=ft,Vr.jsxs=In}()),Vr}process.env.NODE_ENV==="production"?wi.exports=gx():wi.exports=xx();var u=wi.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=w.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:wx}=Object.prototype,{getPrototypeOf:bi}=Object,{iterator:Oo,toStringTag:lc}=Symbol,Do=(e=>t=>{const n=wx.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),sn=e=>(e=e.toLowerCase(),t=>Do(t)===e),Lo=e=>t=>typeof t===e,{isArray:pr}=Array,mr=Lo("undefined");function Kr(e){return e!==null&&!mr(e)&&e.constructor!==null&&!mr(e.constructor)&&$t(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const cc=sn("ArrayBuffer");function bx(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&cc(e.buffer),t}const yx=Lo("string"),$t=Lo("function"),uc=Lo("number"),qr=e=>e!==null&&typeof e=="object",Sx=e=>e===!0||e===!1,$o=e=>{if(Do(e)!=="object")return!1;const t=bi(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(lc in e)&&!(Oo in e)},Cx=e=>{if(!qr(e)||Kr(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},Tx=sn("Date"),kx=sn("File"),Ex=sn("Blob"),Ix=sn("FileList"),Nx=e=>qr(e)&&$t(e.pipe),Ax=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||$t(e.append)&&((t=Do(e))==="formdata"||t==="object"&&$t(e.toString)&&e.toString()==="[object FormData]"))},jx=sn("URLSearchParams"),[Px,_x,Rx,Mx]=["ReadableStream","Request","Response","Headers"].map(sn),Ox=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Gr(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(Kr(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(Kr(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 Xn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,fc=e=>!mr(e)&&e!==Xn;function yi(){const{caseless:e,skipUndefined:t}=fc(this)&&this||{},n={},r=(o,s)=>{const i=e&&dc(n,s)||s;$o(n[i])&&$o(o)?n[i]=yi(n[i],o):$o(o)?n[i]=yi({},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]&&Gr(arguments[o],r);return n}const Dx=(e,t,n,{allOwnKeys:r}={})=>(Gr(t,(o,s)=>{n&&$t(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&&bi(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"&&bi(Uint8Array)),Ux=(e,t)=>{const r=(e&&e[Oo]).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=sn("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=sn("RegExp"),pc=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};Gr(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($t(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if($t(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&&$t(e.append)&&e[lc]==="FormData"&&e[Oo])}const Qx=e=>{const t=new Array(10),n=(r,o)=>{if(qr(r)){if(t.indexOf(r)>=0)return;if(Kr(r))return r;if(!("toJSON"in r)){t[o]=r;const s=pr(r)?[]:{};return Gr(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=sn("AsyncFunction"),tv=e=>e&&(qr(e)||$t(e))&&$t(e.then)&&$t(e.catch),mc=((e,t)=>e?setImmediate:t?((n,r)=>(Xn.addEventListener("message",({source:o,data:s})=>{o===Xn&&s===n&&r.length&&r.shift()()},!1),o=>{r.push(o),Xn.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",$t(Xn.postMessage)),nv=typeof queueMicrotask<"u"?queueMicrotask.bind(Xn):typeof process<"u"&&process.nextTick||mc,W={isArray:pr,isArrayBuffer:cc,isBuffer:Kr,isFormData:Ax,isArrayBufferView:bx,isString:yx,isNumber:uc,isBoolean:Sx,isObject:qr,isPlainObject:$o,isEmptyObject:Cx,isReadableStream:Px,isRequest:_x,isResponse:Rx,isHeaders:Mx,isUndefined:mr,isDate:Tx,isFile:kx,isBlob:Ex,isRegExp:qx,isFunction:$t,isStream:Nx,isURLSearchParams:jx,isTypedArray:Hx,isFileList:Ix,forEach:Gr,merge:yi,extend:Dx,trim:Ox,stripBOM:Lx,inherits:$x,toFlatObject:Fx,kindOf:Do,kindOfTest:sn,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:Xn,isContextDefined:fc,isSpecCompliantForm:Zx,toJSONObject:Qx,isAsyncFn:ev,isThenable:tv,setImmediate:mc,asap:nv,isIterable:e=>e!=null&&$t(e[Oo])};function Ae(e,t,n,r,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),o&&(this.response=o,this.status=o.status?o.status:null)}W.inherits(Ae,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:W.toJSONObject(this.config),code:this.code,status:this.status}}});const gc=Ae.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(Ae,xc),Object.defineProperty(gc,"isAxiosError",{value:!0}),Ae.from=(e,t,n,r,o,s)=>{const i=Object.create(gc);W.toFlatObject(e,i,function(d){return d!==Error.prototype},c=>c!=="isAxiosError");const a=e&&e.message?e.message:"Error",l=t==null&&e?e.code:t;return Ae.call(i,a,l,n,r,o),e&&i.cause==null&&Object.defineProperty(i,"cause",{value:e,configurable:!0}),i.name=e&&e.name||"Error",s&&Object.assign(i,s),i};const rv=null;function Si(e){return W.isPlainObject(e)||W.isArray(e)}function vc(e){return W.endsWith(e,"[]")?e.slice(0,-2):e}function wc(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 W.isArray(e)&&!e.some(Si)}const sv=W.toFlatObject(W,{},null,function(t){return/^is[A-Z]/.test(t)});function Fo(e,t,n){if(!W.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=W.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(g,x){return!W.isUndefined(x[g])});const r=n.metaTokens,o=n.visitor||d,s=n.dots,i=n.indexes,l=(n.Blob||typeof Blob<"u"&&Blob)&&W.isSpecCompliantForm(t);if(!W.isFunction(o))throw new TypeError("visitor must be a function");function c(v){if(v===null)return"";if(W.isDate(v))return v.toISOString();if(W.isBoolean(v))return v.toString();if(!l&&W.isBlob(v))throw new Ae("Blob is not supported. Use a Buffer instead.");return W.isArrayBuffer(v)||W.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(W.endsWith(g,"{}"))g=r?g:g.slice(0,-2),v=JSON.stringify(v);else if(W.isArray(v)&&ov(v)||(W.isFileList(v)||W.endsWith(g,"[]"))&&(y=W.toArray(v)))return g=vc(g),y.forEach(function(C,k){!(W.isUndefined(C)||C===null)&&t.append(i===!0?wc([g],k,s):i===null?g:g+"[]",c(C))}),!1}return Si(v)?!0:(t.append(wc(x,g,s),c(v)),!1)}const h=[],m=Object.assign(sv,{defaultVisitor:d,convertValue:c,isVisitable:Si});function f(v,g){if(!W.isUndefined(v)){if(h.indexOf(v)!==-1)throw Error("Circular reference detected in "+g.join("."));h.push(v),W.forEach(v,function(y,b){(!(W.isUndefined(y)||y===null)&&o.call(t,y,W.isString(b)?b.trim():b,g,m))===!0&&f(y,g?g.concat(b):[b])}),h.pop()}}if(!W.isObject(e))throw new TypeError("data must be an object");return f(e),t}function bc(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function Ci(e,t){this._pairs=[],e&&Fo(e,this,t)}const yc=Ci.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,bc)}:bc;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;W.isFunction(n)&&(n={serialize:n});const o=n&&n.serialize;let s;if(o?s=o(t,n):s=W.isURLSearchParams(t)?t.toString():new Ci(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){W.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:Ci,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},Ti=typeof window<"u"&&typeof document<"u",ki=typeof navigator=="object"&&navigator||void 0,lv=Ti&&(!ki||["ReactNative","NativeScript","NS"].indexOf(ki.product)<0),cv=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",uv=Ti&&window.location.href||"http://localhost",At={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Ti,hasStandardBrowserEnv:lv,hasStandardBrowserWebWorkerEnv:cv,navigator:ki,origin:uv},Symbol.toStringTag,{value:"Module"})),...av};function dv(e,t){return Fo(e,new At.classes.URLSearchParams,{visitor:function(n,r,o,s){return At.isNode&&W.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function fv(e){return W.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&&W.isArray(o)?o.length:i,l?(W.hasOwnProp(o,i)?o[i]=[o[i],r]:o[i]=r,!a):((!o[i]||!W.isObject(o[i]))&&(o[i]=[]),t(n,r,o[i],s)&&W.isArray(o[i])&&(o[i]=hv(o[i])),!a)}if(W.isFormData(e)&&W.isFunction(e.entries)){const n={};return W.forEachEntry(e,(r,o)=>{t(fv(r),o,n,0)}),n}return null}function pv(e,t,n){if(W.isString(e))try{return(t||JSON.parse)(e),W.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const Yr={transitional:Tc,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",o=r.indexOf("application/json")>-1,s=W.isObject(t);if(s&&W.isHTMLForm(t)&&(t=new FormData(t)),W.isFormData(t))return o?JSON.stringify(kc(t)):t;if(W.isArrayBuffer(t)||W.isBuffer(t)||W.isStream(t)||W.isFile(t)||W.isBlob(t)||W.isReadableStream(t))return t;if(W.isArrayBufferView(t))return t.buffer;if(W.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=W.isFileList(t))||r.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return Fo(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||Yr.transitional,r=n&&n.forcedJSONParsing,o=this.responseType==="json";if(W.isResponse(t)||W.isReadableStream(t))return t;if(t&&W.isString(t)&&(r&&!this.responseType||o)){const i=!(n&&n.silentJSONParsing)&&o;try{return JSON.parse(t,this.parseReviver)}catch(a){if(i)throw a.name==="SyntaxError"?Ae.from(a,Ae.ERR_BAD_RESPONSE,this,null,this.response):a}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:At.classes.FormData,Blob:At.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};W.forEach(["delete","get","head","post","put","patch"],e=>{Yr.headers[e]={}});const mv=W.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]&&mv[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},Ec=Symbol("internals");function Xr(e){return e&&String(e).trim().toLowerCase()}function Bo(e){return e===!1||e==null?e:W.isArray(e)?e.map(Bo):String(e)}function xv(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}const vv=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function Ei(e,t,n,r,o){if(W.isFunction(r))return r.call(this,t,n);if(o&&(t=n),!!W.isString(t)){if(W.isString(r))return t.indexOf(r)!==-1;if(W.isRegExp(r))return r.test(t)}}function wv(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function bv(e,t){const n=W.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 Ft=class{constructor(t){t&&this.set(t)}set(t,n,r){const o=this;function s(a,l,c){const d=Xr(l);if(!d)throw new Error("header name must be a non-empty string");const h=W.findKey(o,d);(!h||o[h]===void 0||c===!0||c===void 0&&o[h]!==!1)&&(o[h||l]=Bo(a))}const i=(a,l)=>W.forEach(a,(c,d)=>s(c,d,l));if(W.isPlainObject(t)||t instanceof this.constructor)i(t,n);else if(W.isString(t)&&(t=t.trim())&&!vv(t))i(gv(t),n);else if(W.isObject(t)&&W.isIterable(t)){let a={},l,c;for(const d of t){if(!W.isArray(d))throw TypeError("Object iterator must return a key-value pair");a[c=d[0]]=(l=a[c])?W.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=Xr(t),t){const r=W.findKey(this,t);if(r){const o=this[r];if(!n)return o;if(n===!0)return xv(o);if(W.isFunction(n))return n.call(this,o,r);if(W.isRegExp(n))return n.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=Xr(t),t){const r=W.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||Ei(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let o=!1;function s(i){if(i=Xr(i),i){const a=W.findKey(r,i);a&&(!n||Ei(r,r[a],a,n))&&(delete r[a],o=!0)}}return W.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||Ei(this,this[s],s,t,!0))&&(delete this[s],o=!0)}return o}normalize(t){const n=this,r={};return W.forEach(this,(o,s)=>{const i=W.findKey(r,s);if(i){n[i]=Bo(o),delete n[s];return}const a=t?wv(s):String(s).trim();a!==s&&delete n[s],n[a]=Bo(o),r[a]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return W.forEach(this,(r,o)=>{r!=null&&r!==!1&&(n[o]=t&&W.isArray(r)?r.join(", "):r)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,n])=>t+": "+n).join(`
32
- `)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const r=new this(t);return n.forEach(o=>r.set(o)),r}static accessor(t){const r=(this[Ec]=this[Ec]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=Xr(i);r[a]||(bv(o,i),r[a]=!0)}return W.isArray(t)?t.forEach(s):s(t),this}};Ft.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),W.reduceDescriptors(Ft.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),W.freezeMethods(Ft);function Ii(e,t){const n=this||Yr,r=t||n,o=Ft.from(r.headers);let s=r.data;return W.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){Ae.call(this,e??"canceled",Ae.ERR_CANCELED,t,n),this.name="CanceledError"}W.inherits(gr,Ae,{__CANCEL__:!0});function Nc(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new Ae("Request failed with status code "+n.status,[Ae.ERR_BAD_REQUEST,Ae.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function 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 zo=(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)=>W.asap(()=>e(...t)),Tv=At.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,At.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(At.origin),At.navigator&&/(msie|trident)/i.test(At.navigator.userAgent)):()=>!0,kv=At.hasStandardBrowserEnv?{write(e,t,n,r,o,s){const i=[e+"="+encodeURIComponent(t)];W.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),W.isString(r)&&i.push("path="+r),W.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 Ft?{...e}:e;function Jn(e,t){t=t||{};const n={};function r(c,d,h,m){return W.isPlainObject(c)&&W.isPlainObject(d)?W.merge.call({caseless:m},c,d):W.isPlainObject(d)?W.merge({},d):W.isArray(d)?d.slice():d}function o(c,d,h,m){if(W.isUndefined(d)){if(!W.isUndefined(c))return r(void 0,c,h,m)}else return r(c,d,h,m)}function s(c,d){if(!W.isUndefined(d))return r(void 0,d)}function i(c,d){if(W.isUndefined(d)){if(!W.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 W.forEach(Object.keys({...e,...t}),function(d){const h=l[d]||o,m=h(e[d],t[d],d);W.isUndefined(m)&&h!==a||(n[d]=m)}),n}const Rc=e=>{const t=Jn({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=Ft.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)):""))),W.isFormData(n)){if(At.hasStandardBrowserEnv||At.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(W.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(At.hasStandardBrowserEnv&&(r&&W.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=Ft.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 C=Ft.from("getAllResponseHeaders"in x&&x.getAllResponseHeaders()),S={data:!a||a==="text"||a==="json"?x.responseText:x.response,status:x.status,statusText:x.statusText,headers:C,config:e,request:x};Nc(function(E){n(E),g()},function(E){r(E),g()},S),x=null}"onloadend"in x?x.onloadend=y:x.onreadystatechange=function(){!x||x.readyState!==4||x.status===0&&!(x.responseURL&&x.responseURL.indexOf("file:")===0)||setTimeout(y)},x.onabort=function(){x&&(r(new Ae("Request aborted",Ae.ECONNABORTED,e,x)),x=null)},x.onerror=function(k){const S=k&&k.message?k.message:"Network Error",T=new Ae(S,Ae.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 S=o.transitional||Tc;o.timeoutErrorMessage&&(k=o.timeoutErrorMessage),r(new Ae(k,S.clarifyTimeoutError?Ae.ETIMEDOUT:Ae.ECONNABORTED,e,x)),x=null},s===void 0&&i.setContentType(null),"setRequestHeader"in x&&W.forEach(i.toJSON(),function(k,S){x.setRequestHeader(S,k)}),W.isUndefined(o.withCredentials)||(x.withCredentials=!!o.withCredentials),a&&a!=="json"&&(x.responseType=o.responseType),c&&([m,v]=zo(c,!0),x.addEventListener("progress",m)),l&&x.upload&&([h,f]=zo(l),x.upload.addEventListener("progress",h),x.upload.addEventListener("loadend",f)),(o.cancelToken||o.signal)&&(d=C=>{x&&(r(!C||C.type?new gr(null,e,x):C),x.abort(),x=null)},o.cancelToken&&o.cancelToken.subscribe(d),o.signal&&(o.signal.aborted?d():o.signal.addEventListener("abort",d)));const b=yv(o.url);if(b&&At.protocols.indexOf(b)===-1){r(new Ae("Unsupported protocol "+b+":",Ae.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 Ae?d:new gr(d instanceof Error?d.message:d))}};let i=t&&setTimeout(()=>{i=null,s(new Ae(`timeout ${t} of ms exceeded`,Ae.ETIMEDOUT))},t);const a=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(c=>{c.unsubscribe?c.unsubscribe(s):c.removeEventListener("abort",s)}),e=null)};e.forEach(c=>c.addEventListener("abort",s));const{signal:l}=r;return l.unsubscribe=()=>W.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:Ho}=W,Rv=(({Request:e,Response:t})=>({Request:e,Response:t}))(W.global),{ReadableStream:Dc,TextEncoder:Lc}=W.global,$c=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Mv=e=>{e=W.merge.call({skipUndefined:!0},Rv,e);const{fetch:t,Request:n,Response:r}=e,o=t?Ho(t):typeof fetch=="function",s=Ho(n),i=Ho(r);if(!o)return!1;const a=o&&Ho(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(At.origin,{body:new Dc,method:"POST",get duplex(){return v=!0,"half"}}).headers.has("Content-Type");return v&&!g}),d=i&&a&&$c(()=>W.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 Ae(`Response type '${v}' is not supported`,Ae.ERR_NOT_SUPPORT,x)})});const m=async v=>{if(v==null)return 0;if(W.isBlob(v))return v.size;if(W.isSpecCompliantForm(v))return(await new n(At.origin,{method:"POST",body:v}).arrayBuffer()).byteLength;if(W.isArrayBufferView(v)||W.isArrayBuffer(v))return v.byteLength;if(W.isURLSearchParams(v)&&(v=v+""),W.isString(v))return(await l(v)).byteLength},f=async(v,g)=>{const x=W.toFiniteNumber(v.getContentLength());return x??m(g)};return async v=>{let{url:g,method:x,data:y,signal:b,cancelToken:C,timeout:k,onDownloadProgress:S,onUploadProgress:T,responseType:E,headers:A,withCredentials:R="same-origin",fetchOptions:$}=Rc(v),F=t||fetch;E=E?(E+"").toLowerCase():"text";let V=Av([b,C&&C.toAbortSignal()],k),X=null;const _=V&&V.unsubscribe&&(()=>{V.unsubscribe()});let G;try{if(T&&c&&x!=="get"&&x!=="head"&&(G=await f(A,y))!==0){let J=new n(g,{method:"POST",body:y,duplex:"half"}),j;if(W.isFormData(y)&&(j=J.headers.get("content-type"))&&A.setContentType(j),J.body){const[B,P]=Ac(G,zo(jc(T)));y=Mc(J.body,Oc,B,P)}}W.isString(R)||(R=R?"include":"omit");const H=s&&"credentials"in n.prototype,z={...$,signal:V,method:x.toUpperCase(),headers:A.normalize().toJSON(),body:y,duplex:"half",credentials:H?R:void 0};X=s&&new n(g,z);let D=await(s?F(X,$):F(g,z));const I=d&&(E==="stream"||E==="response");if(d&&(S||I&&_)){const J={};["status","statusText","headers"].forEach(O=>{J[O]=D[O]});const j=W.toFiniteNumber(D.headers.get("content-length")),[B,P]=S&&Ac(j,zo(jc(S),!0))||[];D=new r(Mc(D.body,Oc,B,()=>{P&&P(),_&&_()}),J)}E=E||"text";let Y=await h[W.findKey(h,E)||"text"](D,v);return!I&&_&&_(),await new Promise((J,j)=>{Nc(J,j,{data:Y,headers:Ft.from(D.headers),status:D.status,statusText:D.statusText,config:v,request:X})})}catch(H){throw _&&_(),H&&H.name==="TypeError"&&/Load failed|fetch/i.test(H.message)?Object.assign(new Ae("Network Error",Ae.ERR_NETWORK,v,X),{cause:H.cause||H}):Ae.from(H,H&&H.code,v,X)}}},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 Ni={http:rv,xhr:Nv,fetch:{get:Fc}};W.forEach(Ni,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Bc=e=>`- ${e}`,Dv=e=>W.isFunction(e)||e===null||e===!1,zc={getAdapter:(e,t)=>{e=W.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=Ni[(a=String(r)).toLowerCase()],o===void 0))throw new Ae(`Unknown adapter '${a}'`);if(o&&(W.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 :
30
+ <%s key={someKey} {...props} />`,Jl,hr,i1,hr),Be[hr+Jl]=!0}}return N===r?_e(Ct):Ie(Ct),Ct}}function et(N,ee,de){return xe(N,ee,de,!0)}function Re(N,ee,de){return xe(N,ee,de,!1)}var ft=Re,In=et;Vr.Fragment=r,Vr.jsx=ft,Vr.jsxs=In}()),Vr}process.env.NODE_ENV==="production"?wi.exports=gx():wi.exports=xx();var u=wi.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=w.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:wx}=Object.prototype,{getPrototypeOf:bi}=Object,{iterator:Oo,toStringTag:lc}=Symbol,Do=(e=>t=>{const n=wx.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),sn=e=>(e=e.toLowerCase(),t=>Do(t)===e),Lo=e=>t=>typeof t===e,{isArray:pr}=Array,mr=Lo("undefined");function Kr(e){return e!==null&&!mr(e)&&e.constructor!==null&&!mr(e.constructor)&&$t(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const cc=sn("ArrayBuffer");function bx(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&cc(e.buffer),t}const yx=Lo("string"),$t=Lo("function"),uc=Lo("number"),qr=e=>e!==null&&typeof e=="object",Sx=e=>e===!0||e===!1,$o=e=>{if(Do(e)!=="object")return!1;const t=bi(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(lc in e)&&!(Oo in e)},Cx=e=>{if(!qr(e)||Kr(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},Tx=sn("Date"),kx=sn("File"),Ex=sn("Blob"),Ix=sn("FileList"),Nx=e=>qr(e)&&$t(e.pipe),Ax=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||$t(e.append)&&((t=Do(e))==="formdata"||t==="object"&&$t(e.toString)&&e.toString()==="[object FormData]"))},jx=sn("URLSearchParams"),[Px,_x,Rx,Mx]=["ReadableStream","Request","Response","Headers"].map(sn),Ox=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Gr(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(Kr(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(Kr(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 Xn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,fc=e=>!mr(e)&&e!==Xn;function yi(){const{caseless:e,skipUndefined:t}=fc(this)&&this||{},n={},r=(o,s)=>{const i=e&&dc(n,s)||s;$o(n[i])&&$o(o)?n[i]=yi(n[i],o):$o(o)?n[i]=yi({},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]&&Gr(arguments[o],r);return n}const Dx=(e,t,n,{allOwnKeys:r}={})=>(Gr(t,(o,s)=>{n&&$t(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&&bi(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"&&bi(Uint8Array)),Ux=(e,t)=>{const r=(e&&e[Oo]).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=sn("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=sn("RegExp"),pc=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};Gr(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($t(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if($t(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&&$t(e.append)&&e[lc]==="FormData"&&e[Oo])}const Qx=e=>{const t=new Array(10),n=(r,o)=>{if(qr(r)){if(t.indexOf(r)>=0)return;if(Kr(r))return r;if(!("toJSON"in r)){t[o]=r;const s=pr(r)?[]:{};return Gr(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=sn("AsyncFunction"),tv=e=>e&&(qr(e)||$t(e))&&$t(e.then)&&$t(e.catch),mc=((e,t)=>e?setImmediate:t?((n,r)=>(Xn.addEventListener("message",({source:o,data:s})=>{o===Xn&&s===n&&r.length&&r.shift()()},!1),o=>{r.push(o),Xn.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",$t(Xn.postMessage)),nv=typeof queueMicrotask<"u"?queueMicrotask.bind(Xn):typeof process<"u"&&process.nextTick||mc,V={isArray:pr,isArrayBuffer:cc,isBuffer:Kr,isFormData:Ax,isArrayBufferView:bx,isString:yx,isNumber:uc,isBoolean:Sx,isObject:qr,isPlainObject:$o,isEmptyObject:Cx,isReadableStream:Px,isRequest:_x,isResponse:Rx,isHeaders:Mx,isUndefined:mr,isDate:Tx,isFile:kx,isBlob:Ex,isRegExp:qx,isFunction:$t,isStream:Nx,isURLSearchParams:jx,isTypedArray:Hx,isFileList:Ix,forEach:Gr,merge:yi,extend:Dx,trim:Ox,stripBOM:Lx,inherits:$x,toFlatObject:Fx,kindOf:Do,kindOfTest:sn,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:Xn,isContextDefined:fc,isSpecCompliantForm:Zx,toJSONObject:Qx,isAsyncFn:ev,isThenable:tv,setImmediate:mc,asap:nv,isIterable:e=>e!=null&&$t(e[Oo])};function Ne(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(Ne,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=Ne.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(Ne,xc),Object.defineProperty(gc,"isAxiosError",{value:!0}),Ne.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 Ne.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 Si(e){return V.isPlainObject(e)||V.isArray(e)}function vc(e){return V.endsWith(e,"[]")?e.slice(0,-2):e}function wc(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(Si)}const sv=V.toFlatObject(V,{},null,function(t){return/^is[A-Z]/.test(t)});function Fo(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 Ne("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(C,k){!(V.isUndefined(C)||C===null)&&t.append(i===!0?wc([g],k,s):i===null?g:g+"[]",c(C))}),!1}return Si(v)?!0:(t.append(wc(x,g,s),c(v)),!1)}const h=[],m=Object.assign(sv,{defaultVisitor:d,convertValue:c,isVisitable:Si});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,b){(!(V.isUndefined(y)||y===null)&&o.call(t,y,V.isString(b)?b.trim():b,g,m))===!0&&f(y,g?g.concat(b):[b])}),h.pop()}}if(!V.isObject(e))throw new TypeError("data must be an object");return f(e),t}function bc(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function Ci(e,t){this._pairs=[],e&&Fo(e,this,t)}const yc=Ci.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,bc)}:bc;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 Ci(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:Ci,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},Ti=typeof window<"u"&&typeof document<"u",ki=typeof navigator=="object"&&navigator||void 0,lv=Ti&&(!ki||["ReactNative","NativeScript","NS"].indexOf(ki.product)<0),cv=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",uv=Ti&&window.location.href||"http://localhost",Nt={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Ti,hasStandardBrowserEnv:lv,hasStandardBrowserWebWorkerEnv:cv,navigator:ki,origin:uv},Symbol.toStringTag,{value:"Module"})),...av};function dv(e,t){return Fo(e,new Nt.classes.URLSearchParams,{visitor:function(n,r,o,s){return Nt.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 Yr={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 Fo(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||Yr.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"?Ne.from(a,Ne.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:Nt.classes.FormData,Blob:Nt.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=>{Yr.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]&&mv[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},Ec=Symbol("internals");function Xr(e){return e&&String(e).trim().toLowerCase()}function Bo(e){return e===!1||e==null?e:V.isArray(e)?e.map(Bo):String(e)}function xv(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}const vv=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function Ei(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 wv(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function bv(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 Ft=class{constructor(t){t&&this.set(t)}set(t,n,r){const o=this;function s(a,l,c){const d=Xr(l);if(!d)throw new Error("header name must be a non-empty string");const h=V.findKey(o,d);(!h||o[h]===void 0||c===!0||c===void 0&&o[h]!==!1)&&(o[h||l]=Bo(a))}const i=(a,l)=>V.forEach(a,(c,d)=>s(c,d,l));if(V.isPlainObject(t)||t instanceof this.constructor)i(t,n);else if(V.isString(t)&&(t=t.trim())&&!vv(t))i(gv(t),n);else if(V.isObject(t)&&V.isIterable(t)){let a={},l,c;for(const d of t){if(!V.isArray(d))throw TypeError("Object iterator must return a key-value pair");a[c=d[0]]=(l=a[c])?V.isArray(l)?[...l,d[1]]:[l,d[1]]:d[1]}i(a,n)}else t!=null&&s(n,t,r);return this}get(t,n){if(t=Xr(t),t){const r=V.findKey(this,t);if(r){const o=this[r];if(!n)return o;if(n===!0)return xv(o);if(V.isFunction(n))return n.call(this,o,r);if(V.isRegExp(n))return n.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=Xr(t),t){const r=V.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||Ei(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let o=!1;function s(i){if(i=Xr(i),i){const a=V.findKey(r,i);a&&(!n||Ei(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||Ei(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]=Bo(o),delete n[s];return}const a=t?wv(s):String(s).trim();a!==s&&delete n[s],n[a]=Bo(o),r[a]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return V.forEach(this,(r,o)=>{r!=null&&r!==!1&&(n[o]=t&&V.isArray(r)?r.join(", "):r)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,n])=>t+": "+n).join(`
32
+ `)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const r=new this(t);return n.forEach(o=>r.set(o)),r}static accessor(t){const r=(this[Ec]=this[Ec]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=Xr(i);r[a]||(bv(o,i),r[a]=!0)}return V.isArray(t)?t.forEach(s):s(t),this}};Ft.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),V.reduceDescriptors(Ft.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),V.freezeMethods(Ft);function Ii(e,t){const n=this||Yr,r=t||n,o=Ft.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){Ne.call(this,e??"canceled",Ne.ERR_CANCELED,t,n),this.name="CanceledError"}V.inherits(gr,Ne,{__CANCEL__:!0});function Nc(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new Ne("Request failed with status code "+n.status,[Ne.ERR_BAD_REQUEST,Ne.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 zo=(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=Nt.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,Nt.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(Nt.origin),Nt.navigator&&/(msie|trident)/i.test(Nt.navigator.userAgent)):()=>!0,kv=Nt.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 Ft?{...e}:e;function Jn(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=Jn({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=Ft.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(Nt.hasStandardBrowserEnv||Nt.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(Nt.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=Ft.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 C=Ft.from("getAllResponseHeaders"in x&&x.getAllResponseHeaders()),S={data:!a||a==="text"||a==="json"?x.responseText:x.response,status:x.status,statusText:x.statusText,headers:C,config:e,request:x};Nc(function(E){n(E),g()},function(E){r(E),g()},S),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 Ne("Request aborted",Ne.ECONNABORTED,e,x)),x=null)},x.onerror=function(k){const S=k&&k.message?k.message:"Network Error",T=new Ne(S,Ne.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 S=o.transitional||Tc;o.timeoutErrorMessage&&(k=o.timeoutErrorMessage),r(new Ne(k,S.clarifyTimeoutError?Ne.ETIMEDOUT:Ne.ECONNABORTED,e,x)),x=null},s===void 0&&i.setContentType(null),"setRequestHeader"in x&&V.forEach(i.toJSON(),function(k,S){x.setRequestHeader(S,k)}),V.isUndefined(o.withCredentials)||(x.withCredentials=!!o.withCredentials),a&&a!=="json"&&(x.responseType=o.responseType),c&&([m,v]=zo(c,!0),x.addEventListener("progress",m)),l&&x.upload&&([h,f]=zo(l),x.upload.addEventListener("progress",h),x.upload.addEventListener("loadend",f)),(o.cancelToken||o.signal)&&(d=C=>{x&&(r(!C||C.type?new gr(null,e,x):C),x.abort(),x=null)},o.cancelToken&&o.cancelToken.subscribe(d),o.signal&&(o.signal.aborted?d():o.signal.addEventListener("abort",d)));const b=yv(o.url);if(b&&Nt.protocols.indexOf(b)===-1){r(new Ne("Unsupported protocol "+b+":",Ne.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 Ne?d:new gr(d instanceof Error?d.message:d))}};let i=t&&setTimeout(()=>{i=null,s(new Ne(`timeout ${t} of ms exceeded`,Ne.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:Ho}=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?Ho(t):typeof fetch=="function",s=Ho(n),i=Ho(r);if(!o)return!1;const a=o&&Ho(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(Nt.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 Ne(`Response type '${v}' is not supported`,Ne.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(Nt.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:b,cancelToken:C,timeout:k,onDownloadProgress:S,onUploadProgress:T,responseType:E,headers:j,withCredentials:_="same-origin",fetchOptions:$}=Rc(v),F=t||fetch;E=E?(E+"").toLowerCase():"text";let U=Av([b,C&&C.toAbortSignal()],k),X=null;const R=U&&U.unsubscribe&&(()=>{U.unsubscribe()});let K;try{if(T&&c&&x!=="get"&&x!=="head"&&(K=await f(j,y))!==0){let J=new n(g,{method:"POST",body:y,duplex:"half"}),P;if(V.isFormData(y)&&(P=J.headers.get("content-type"))&&j.setContentType(P),J.body){const[B,A]=Ac(K,zo(jc(T)));y=Mc(J.body,Oc,B,A)}}V.isString(_)||(_=_?"include":"omit");const W=s&&"credentials"in n.prototype,z={...$,signal:U,method:x.toUpperCase(),headers:j.normalize().toJSON(),body:y,duplex:"half",credentials:W?_:void 0};X=s&&new n(g,z);let O=await(s?F(X,$):F(g,z));const I=d&&(E==="stream"||E==="response");if(d&&(S||I&&R)){const J={};["status","statusText","headers"].forEach(D=>{J[D]=O[D]});const P=V.toFiniteNumber(O.headers.get("content-length")),[B,A]=S&&Ac(P,zo(jc(S),!0))||[];O=new r(Mc(O.body,Oc,B,()=>{A&&A(),R&&R()}),J)}E=E||"text";let G=await h[V.findKey(h,E)||"text"](O,v);return!I&&R&&R(),await new Promise((J,P)=>{Nc(J,P,{data:G,headers:Ft.from(O.headers),status:O.status,statusText:O.statusText,config:v,request:X})})}catch(W){throw R&&R(),W&&W.name==="TypeError"&&/Load failed|fetch/i.test(W.message)?Object.assign(new Ne("Network Error",Ne.ERR_NETWORK,v,X),{cause:W.cause||W}):Ne.from(W,W&&W.code,v,X)}}},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 Ni={http:rv,xhr:Nv,fetch:{get:Fc}};V.forEach(Ni,(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=Ni[(a=String(r)).toLowerCase()],o===void 0))throw new Ne(`Unknown adapter '${a}'`);if(o&&(V.isFunction(o)||(o=o.get(t))))break;s[a||"#"+i]=o}if(!o){const i=Object.entries(s).map(([l,c])=>`adapter ${l} `+(c===!1?"is not supported by the environment":"is not available in the build"));let a=n?i.length>1?`since :
33
33
  `+i.map(Bc).join(`
34
- `):" "+Bc(i[0]):"as no adapter specified";throw new Ae("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return o},adapters:Ni};function Ai(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new gr(null,e)}function Hc(e){return Ai(e),e.headers=Ft.from(e.headers),e.data=Ii.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),zc.getAdapter(e.adapter||Yr.adapter,e)(e).then(function(r){return Ai(e),r.data=Ii.call(e,e.transformResponse,r),r.headers=Ft.from(r.headers),r},function(r){return Ic(r)||(Ai(e),r&&r.response&&(r.response.data=Ii.call(e,e.transformResponse,r.response),r.response.headers=Ft.from(r.response.headers))),Promise.reject(r)})}const Uc="1.12.2",Uo={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Uo[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const Wc={};Uo.transitional=function(t,n,r){function o(s,i){return"[Axios v"+Uc+"] Transitional option '"+s+"'"+i+(r?". "+r:"")}return(s,i,a)=>{if(t===!1)throw new Ae(o(i," has been removed"+(n?" in "+n:"")),Ae.ERR_DEPRECATED);return n&&!Wc[i]&&(Wc[i]=!0,console.warn(o(i," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(s,i,a):!0}},Uo.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function Lv(e,t,n){if(typeof e!="object")throw new Ae("options must be an object",Ae.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let o=r.length;for(;o-- >0;){const s=r[o],i=t[s];if(i){const a=e[s],l=a===void 0||i(a,s,e);if(l!==!0)throw new Ae("option "+s+" must be "+l,Ae.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new Ae("Unknown option "+s,Ae.ERR_BAD_OPTION)}}const Wo={assertOptions:Lv,validators:Uo},gn=Wo.validators;let Zn=class{constructor(t){this.defaults=t||{},this.interceptors={request:new Cc,response:new Cc}}async request(t,n){try{return await this._request(t,n)}catch(r){if(r instanceof Error){let o={};Error.captureStackTrace?Error.captureStackTrace(o):o=new Error;const s=o.stack?o.stack.replace(/^.+\n/,""):"";try{r.stack?s&&!String(r.stack).endsWith(s.replace(/^.+\n.+\n/,""))&&(r.stack+=`
35
- `+s):r.stack=s}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=Jn(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:s}=n;r!==void 0&&Wo.assertOptions(r,{silentJSONParsing:gn.transitional(gn.boolean),forcedJSONParsing:gn.transitional(gn.boolean),clarifyTimeoutError:gn.transitional(gn.boolean)},!1),o!=null&&(W.isFunction(o)?n.paramsSerializer={serialize:o}:Wo.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),Wo.assertOptions(n,{baseUrl:gn.spelling("baseURL"),withXsrfToken:gn.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=s&&W.merge(s.common,s[n.method]);s&&W.forEach(["delete","get","head","post","put","patch","common"],v=>{delete s[v]}),n.headers=Ft.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=Jn(this.defaults,t);const n=Pc(t.baseURL,t.url,t.allowAbsoluteUrls);return Sc(n,t.params,t.paramsSerializer)}};W.forEach(["delete","get","head","options"],function(t){Zn.prototype[t]=function(n,r){return this.request(Jn(r||{},{method:t,url:n,data:(r||{}).data}))}}),W.forEach(["post","put","patch"],function(t){function n(r){return function(s,i,a){return this.request(Jn(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}Zn.prototype[t]=n(),Zn.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 W.isObject(e)&&e.isAxiosError===!0}const ji={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(ji).forEach(([e,t])=>{ji[t]=e});function Vc(e){const t=new Zn(e),n=ac(Zn.prototype.request,t);return W.extend(n,Zn.prototype,t,{allOwnKeys:!0}),W.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return Vc(Jn(e,o))},n}const ht=Vc(Yr);ht.Axios=Zn,ht.CanceledError=gr,ht.CancelToken=$v,ht.isCancel=Ic,ht.VERSION=Uc,ht.toFormData=Fo,ht.AxiosError=Ae,ht.Cancel=ht.CanceledError,ht.all=function(t){return Promise.all(t)},ht.spread=Fv,ht.isAxiosError=Bv,ht.mergeConfig=Jn,ht.AxiosHeaders=Ft,ht.formToJSON=e=>kc(W.isHTMLForm(e)?new FormData(e):e),ht.getAdapter=zc.getAdapter,ht.HttpStatusCode=ji,ht.default=ht;const{Axios:g1,AxiosError:x1,CanceledError:v1,isCancel:Kc,CancelToken:w1,VERSION:b1,all:y1,Cancel:S1,isAxiosError:C1,spread:T1,toFormData:k1,AxiosHeaders:E1,HttpStatusCode:I1,formToJSON:N1,getAdapter:A1,mergeConfig:j1}=ht,qc=typeof window<"u"?window.__API_BASE_URL__:void 0,Gc=qc?xn(qc):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 Vo=null;const Pi=new Set;function Yc(){return Vo}function Ko(e){Vo=e,Pi.forEach(t=>t(e))}function Xc(e){return Pi.add(e),()=>Pi.delete(e)}const Jc=3e4,Zc=9e4,Kt=ht.create({...Gc?{baseURL:Gc}:{},timeout:Jc,withCredentials:!0});Kt.interceptors.request.use(e=>(Vo&&(e.headers.Authorization=`Bearer ${Vo}`),e)),Kt.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),Ko(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 qt(e,t){return Kt.defaults.baseURL?(await Kt.get(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}async function qo(e,t,n){return Kt.defaults.baseURL?(await Kt.post(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function Qc(e,t,n){return Kt.defaults.baseURL?(await Kt.put(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function _i(e,t){return Kt.defaults.baseURL?(await Kt.delete(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}function Mt(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class Go{get baseUrl(){const t=Kt.defaults.baseURL;return t?xn(String(t)):""}updateConfig(t){t.baseUrl&&(Kt.defaults.baseURL=xn(String(t.baseUrl))),t.authToken!==void 0&&Ko(t.authToken)}getAuthToken(){return Yc()}setAuthToken(t){Ko(t)}onTokenChange(t){return Xc(t)}async listThreads(){const t=await qt("/threads"),n=Mt(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async listSharedThreads(){const t=await qt("/threads/shared"),n=Mt(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async createThread(t){const r=await qo("/threads",t?{title:t}:void 0);return Mt(r)}async updateThread(t,n){const r=await Qc(`/threads/${t}`,{title:n});return Mt(r)}async deleteThread(t){const n=await _i(`/threads/${t}`);return Mt(n)}async shareThread(t,n){const r=await qo(`/threads/${t}/share`,{shared_with_user_id:n});return Mt(r)}async threadInfo(t){const n=await qt(`/threads/${t}/info`);return Mt(n)}async listAgents(){const t=await qt("/agents"),n=Mt(t);return(n==null?void 0:n.items)??[]}async getAgent(t){const n=await qt(`/agents/${t}`);return Mt(n)}async getAgentSchema(t){const n=await qt(`/agents/${t}/schema`);return Mt(n)}async getState(t){const n=await qt(`/threads/${t.threadId}/state`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return Mt(n)}async getStateHistory(t){const n=await qt(`/threads/${t.threadId}/state/history`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs},timeout:Zc,signal:t.signal});return Mt(n)}async cancelRun(t){const n=await qo("/runs/cancel",{threadId:t});return Mt(n)}async unshareThread(t,n){const r=await _i(`/threads/${t}/share/${n}`);return Mt(r)}}const Nn=new Go,zv=Go,Hv=Go;async function Ri(e,t){return await qt(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 Ri(`/files/${e}/view`,t),r=URL.createObjectURL(n);window.open(r,"_blank"),setTimeout(()=>URL.revokeObjectURL(r),6e4)}async function Mi(e,t){return await(await Ri(`/files/${e}/view`,t)).text()}async function eu(e,t){const n=await Ri(`/files/${e}/download`,t),r=URL.createObjectURL(n);let o=`file_${e}`;try{const i=await qt(`/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 qt(`/files/${e}`)}async function tu(e,t=50,n=0){const r={limit:t,offset:n};return e&&(r.thread_id=e),await qt("/files",{params:r})}const nu=w.createContext(null);function ru({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(nu.Provider,{value:r,children:e})}async function ou(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 su(e=[]){const t=[],n=[];for(const r of e)try{const o=await ou(r);n.push({filename:r.name,data:o,mime_type:r.type||"application/octet-stream"})}catch{}return{contentParts:t,filesInfo:n}}function Jr(){const e=w.useContext(nu);if(!e)throw new Error("useApi must be used within ApiProvider");return e}function iu(e){return!!e&&typeof e=="object"&&"data"in e}function Oi(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 Zr(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 au(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="assistant")return e[t].id;return null}function lu(e){return!e||!e.length?"":e.filter(t=>t.type==="text").map(t=>t.text??"").join("")}function cu(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??lu(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 uu(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=uu(e),o=uu(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 Zr(e,r,s)}return e}function du(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}function Gv(e={}){const t=w.useMemo(()=>xn(e.baseUrl),[e.baseUrl]),n=e.streamPath??"/runs/stream",[r,o]=w.useState(e.token??null),s=w.useRef(e.headers??{}),i=e.credentials??"include",[a,l]=w.useState(!1),[c,d]=w.useState(null),[h,m]=w.useState(""),[f,v]=w.useState(null),[g,x]=w.useState(0),[y,b]=w.useState(!1),[C,k]=w.useState(null),S=w.useRef(null),T=w.useRef(!0),E=w.useRef(0),A=w.useRef(null),R=w.useRef(null),$=w.useRef(null),F=w.useRef(null),V=w.useRef({messageId:null,lastSeq:null,lastText:""}),X=w.useCallback(z=>{o(z)},[]),_=w.useCallback(()=>{m(""),v(null),d(null),R.current=null,$.current=null,F.current=null,k(null),V.current={messageId:null,lastSeq:null,lastText:""}},[]),G=w.useCallback(()=>{var Y;console.debug("[use-chat] stop() invoked - aborting stream");const z=(Y=A.current)==null?void 0:Y.threadId,D=()=>{var J;(J=S.current)==null||J.abort(),S.current=null,A.current=null,l(!1),b(!1),E.current=0,x(0)};(z?Nn.cancelRun(z).catch(J=>{console.warn("[use-chat] cancel run failed:",J)}):Promise.resolve()).finally(D)},[]),H=w.useCallback((z,D,I)=>{S.current&&(S.current.abort(),S.current=null),l(!0),d(null),e.autoAppendAssistant!==!1&&m(""),v(null),R.current=null,$.current=null,F.current=null,k(null),V.current={messageId:null,lastSeq:null,lastText:""};const Y=new AbortController;S.current=Y;let J=null,j=null,B=!1;return A.current={threadId:z.threadId??null,headers:{}},(async()=>{var O,K,M,L,q,Z,se,ie,re,de,be,Me,Fe,De,Le,it,dt,Et;const P=Ke=>{var We;try{const Xe=JSON.parse(JSON.stringify(Ke));return(We=Xe==null?void 0:Xe.payload)!=null&&We.files_info&&Array.isArray(Xe.payload.files_info)&&(Xe.payload.files_info=Xe.payload.files_info.map(ke=>({...ke,data:ke!=null&&ke.data?`<base64 ${String(ke.data).length} chars>`:ke==null?void 0:ke.data}))),Xe}catch{return Ke}};try{let Ke={};try{if(r)Ke={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const $e=window.__AUTH_TOKEN__,Tt=((O=window.localStorage)==null?void 0:O.getItem("authToken"))||null;let ne=null;try{const pe=(K=window.localStorage)==null?void 0:K.getItem("chat-settings");pe&&(ne=((M=JSON.parse(pe))==null?void 0:M.apiKey)||null)}catch{}const xe=$e||Tt||ne||null;xe&&(Ke={Authorization:`Bearer ${xe}`})}}catch{}console.debug("[use-chat] POST",t+n,P(z));let We={};if(typeof window<"u")try{const Be=(L=window.localStorage)==null?void 0:L.getItem("authSessionId");Be&&(We={"X-Session-Id":Be})}catch{}const Xe={...Ke,...We,...s.current},ke={"Content-Type":"application/json",Accept:"text/event-stream",...Xe},Ue=await fetch(t+n,{method:"POST",headers:ke,body:JSON.stringify(z),signal:Y.signal,credentials:i});if(A.current&&(A.current.headers=Xe),!Ue.ok||!Ue.body){const Be=await Ue.text().catch(()=>"");console.debug("[use-chat] non-OK response",Ue.status,Be==null?void 0:Be.slice(0,500));const $e=`stream ${Ue.status}${Be?": "+Be:""}`;throw(q=I==null?void 0:I.onConnectionError)==null||q.call(I,$e),B=!0,J="error",j=$e,new Error($e)}b(!0);const ut=Ue.body.getReader(),bt=new TextDecoder;let Je="",Ct=[];E.current=0,x(0);let gt=0,xt=null;const It=()=>{if(Ct.length){const Be=Ct.join("");Ct=[],T.current&&m($e=>$e+Be)}xt=null},rn=()=>{typeof window<"u"&&xt==null&&(xt=requestAnimationFrame(It))};let Nt=Date.now();const mn=setInterval(()=>{var Be;if(Date.now()-Nt>18e5){const $e="Stream idle timeout";d($e),J="error",j=$e,Y.abort(),(Be=I==null?void 0:I.onError)==null||Be.call(I,$e)}},5e3),Zt=1024*1024;try{const Be=Ue.headers.get("X-Thread-Id")||Ue.headers.get("x-thread-id"),$e=Ue.headers.get("X-Thread-Created")||Ue.headers.get("x-thread-created"),Tt=Be??null,ne=String($e??"").toLowerCase()==="true";for(A.current&&!A.current.threadId&&(A.current={...A.current,threadId:Tt}),(Z=I==null?void 0:I.onOpen)==null||Z.call(I,{threadId:Tt,created:ne});;){const{value:xe,done:pe}=await ut.read();if(pe)break;Je+=bt.decode(xe,{stream:!0}),Je.length>Zt&&(Je="",console.warn("Stream buffer reset: exceeded 1MB"));let ce;for(;(ce=Je.indexOf(`
34
+ `):" "+Bc(i[0]):"as no adapter specified";throw new Ne("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return o},adapters:Ni};function Ai(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new gr(null,e)}function Hc(e){return Ai(e),e.headers=Ft.from(e.headers),e.data=Ii.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),zc.getAdapter(e.adapter||Yr.adapter,e)(e).then(function(r){return Ai(e),r.data=Ii.call(e,e.transformResponse,r),r.headers=Ft.from(r.headers),r},function(r){return Ic(r)||(Ai(e),r&&r.response&&(r.response.data=Ii.call(e,e.transformResponse,r.response),r.response.headers=Ft.from(r.response.headers))),Promise.reject(r)})}const Uc="1.12.2",Uo={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Uo[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const Wc={};Uo.transitional=function(t,n,r){function o(s,i){return"[Axios v"+Uc+"] Transitional option '"+s+"'"+i+(r?". "+r:"")}return(s,i,a)=>{if(t===!1)throw new Ne(o(i," has been removed"+(n?" in "+n:"")),Ne.ERR_DEPRECATED);return n&&!Wc[i]&&(Wc[i]=!0,console.warn(o(i," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(s,i,a):!0}},Uo.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function Lv(e,t,n){if(typeof e!="object")throw new Ne("options must be an object",Ne.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 Ne("option "+s+" must be "+l,Ne.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new Ne("Unknown option "+s,Ne.ERR_BAD_OPTION)}}const Wo={assertOptions:Lv,validators:Uo},gn=Wo.validators;let Zn=class{constructor(t){this.defaults=t||{},this.interceptors={request:new Cc,response:new Cc}}async request(t,n){try{return await this._request(t,n)}catch(r){if(r instanceof Error){let o={};Error.captureStackTrace?Error.captureStackTrace(o):o=new Error;const s=o.stack?o.stack.replace(/^.+\n/,""):"";try{r.stack?s&&!String(r.stack).endsWith(s.replace(/^.+\n.+\n/,""))&&(r.stack+=`
35
+ `+s):r.stack=s}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=Jn(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:s}=n;r!==void 0&&Wo.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}:Wo.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),Wo.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=Ft.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=Jn(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){Zn.prototype[t]=function(n,r){return this.request(Jn(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(Jn(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}Zn.prototype[t]=n(),Zn.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 ji={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(ji).forEach(([e,t])=>{ji[t]=e});function Vc(e){const t=new Zn(e),n=ac(Zn.prototype.request,t);return V.extend(n,Zn.prototype,t,{allOwnKeys:!0}),V.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return Vc(Jn(e,o))},n}const ht=Vc(Yr);ht.Axios=Zn,ht.CanceledError=gr,ht.CancelToken=$v,ht.isCancel=Ic,ht.VERSION=Uc,ht.toFormData=Fo,ht.AxiosError=Ne,ht.Cancel=ht.CanceledError,ht.all=function(t){return Promise.all(t)},ht.spread=Fv,ht.isAxiosError=Bv,ht.mergeConfig=Jn,ht.AxiosHeaders=Ft,ht.formToJSON=e=>kc(V.isHTMLForm(e)?new FormData(e):e),ht.getAdapter=zc.getAdapter,ht.HttpStatusCode=ji,ht.default=ht;const{Axios:g1,AxiosError:x1,CanceledError:v1,isCancel:Kc,CancelToken:w1,VERSION:b1,all:y1,Cancel:S1,isAxiosError:C1,spread:T1,toFormData:k1,AxiosHeaders:E1,HttpStatusCode:I1,formToJSON:N1,getAdapter:A1,mergeConfig:j1}=ht,qc=typeof window<"u"?window.__API_BASE_URL__:void 0,Gc=qc?xn(qc):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 Vo=null;const Pi=new Set;function Yc(){return Vo}function Ko(e){Vo=e,Pi.forEach(t=>t(e))}function Xc(e){return Pi.add(e),()=>Pi.delete(e)}const Jc=3e4,Zc=9e4,Kt=ht.create({...Gc?{baseURL:Gc}:{},timeout:Jc,withCredentials:!0});Kt.interceptors.request.use(e=>(Vo&&(e.headers.Authorization=`Bearer ${Vo}`),e)),Kt.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),Ko(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 qt(e,t){return Kt.defaults.baseURL?(await Kt.get(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}async function qo(e,t,n){return Kt.defaults.baseURL?(await Kt.post(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function Qc(e,t,n){return Kt.defaults.baseURL?(await Kt.put(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function _i(e,t){return Kt.defaults.baseURL?(await Kt.delete(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}function Mt(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class Go{get baseUrl(){const t=Kt.defaults.baseURL;return t?xn(String(t)):""}updateConfig(t){t.baseUrl&&(Kt.defaults.baseURL=xn(String(t.baseUrl))),t.authToken!==void 0&&Ko(t.authToken)}getAuthToken(){return Yc()}setAuthToken(t){Ko(t)}onTokenChange(t){return Xc(t)}async listThreads(){const t=await qt("/threads"),n=Mt(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async listSharedThreads(){const t=await qt("/threads/shared"),n=Mt(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async createThread(t){const r=await qo("/threads",t?{title:t}:void 0);return Mt(r)}async updateThread(t,n){const r=await Qc(`/threads/${t}`,{title:n});return Mt(r)}async deleteThread(t){const n=await _i(`/threads/${t}`);return Mt(n)}async shareThread(t,n){const r=await qo(`/threads/${t}/share`,{shared_with_user_id:n});return Mt(r)}async threadInfo(t){const n=await qt(`/threads/${t}/info`);return Mt(n)}async listAgents(){const t=await qt("/agents"),n=Mt(t);return(n==null?void 0:n.items)??[]}async getAgent(t){const n=await qt(`/agents/${t}`);return Mt(n)}async getAgentSchema(t){const n=await qt(`/agents/${t}/schema`);return Mt(n)}async getState(t){const n=await qt(`/threads/${t.threadId}/state`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return Mt(n)}async getStateHistory(t){const n=await qt(`/threads/${t.threadId}/state/history`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs},timeout:Zc,signal:t.signal});return Mt(n)}async cancelRun(t){const n=await qo("/runs/cancel",{threadId:t});return Mt(n)}async unshareThread(t,n){const r=await _i(`/threads/${t}/share/${n}`);return Mt(r)}}const Nn=new Go,zv=Go,Hv=Go;async function Ri(e,t){return await qt(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 Ri(`/files/${e}/view`,t),r=URL.createObjectURL(n);window.open(r,"_blank"),setTimeout(()=>URL.revokeObjectURL(r),6e4)}async function Mi(e,t){return await(await Ri(`/files/${e}/view`,t)).text()}async function eu(e,t){const n=await Ri(`/files/${e}/download`,t),r=URL.createObjectURL(n);let o=`file_${e}`;try{const i=await qt(`/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 qt(`/files/${e}`)}async function tu(e,t=50,n=0){const r={limit:t,offset:n};return e&&(r.thread_id=e),await qt("/files",{params:r})}const nu=w.createContext(null);function ru({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(nu.Provider,{value:r,children:e})}async function ou(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 su(e=[]){const t=[],n=[];for(const r of e)try{const o=await ou(r);n.push({filename:r.name,data:o,mime_type:r.type||"application/octet-stream"})}catch{}return{contentParts:t,filesInfo:n}}function Jr(){const e=w.useContext(nu);if(!e)throw new Error("useApi must be used within ApiProvider");return e}function iu(e){return!!e&&typeof e=="object"&&"data"in e}function Oi(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 Zr(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 au(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="assistant")return e[t].id;return null}function lu(e){return!e||!e.length?"":e.filter(t=>t.type==="text").map(t=>t.text??"").join("")}function cu(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??lu(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 uu(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=uu(e),o=uu(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 Zr(e,r,s)}return e}function du(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}function Gv(e={}){const t=w.useMemo(()=>xn(e.baseUrl),[e.baseUrl]),n=e.streamPath??"/runs/stream",[r,o]=w.useState(e.token??null),s=w.useRef(e.headers??{}),i=e.credentials??"include",[a,l]=w.useState(!1),[c,d]=w.useState(null),[h,m]=w.useState(""),[f,v]=w.useState(null),[g,x]=w.useState(0),[y,b]=w.useState(!1),[C,k]=w.useState(null),S=w.useRef(null),T=w.useRef(!0),E=w.useRef(0),j=w.useRef(null),_=w.useRef(null),$=w.useRef(null),F=w.useRef(null),U=w.useRef({messageId:null,lastSeq:null,lastText:""}),X=w.useCallback(z=>{o(z)},[]),R=w.useCallback(()=>{m(""),v(null),d(null),_.current=null,$.current=null,F.current=null,k(null),U.current={messageId:null,lastSeq:null,lastText:""}},[]),K=w.useCallback(()=>{var G;console.debug("[use-chat] stop() invoked - aborting stream");const z=(G=j.current)==null?void 0:G.threadId,O=()=>{var J;(J=S.current)==null||J.abort(),S.current=null,j.current=null,l(!1),b(!1),E.current=0,x(0)};(z?Nn.cancelRun(z).catch(J=>{console.warn("[use-chat] cancel run failed:",J)}):Promise.resolve()).finally(O)},[]),W=w.useCallback((z,O,I)=>{S.current&&(S.current.abort(),S.current=null),l(!0),d(null),e.autoAppendAssistant!==!1&&m(""),v(null),_.current=null,$.current=null,F.current=null,k(null),U.current={messageId:null,lastSeq:null,lastText:""};const G=new AbortController;S.current=G;let J=null,P=null,B=!1;return j.current={threadId:z.threadId??null,headers:{}},(async()=>{var D,q,M,L,Y,Z,oe,se,ie,le,ye,De,We,Pe,$e,lt,ut,yt;const A=qe=>{var Xe;try{const Ve=JSON.parse(JSON.stringify(qe));return(Xe=Ve==null?void 0:Ve.payload)!=null&&Xe.files_info&&Array.isArray(Ve.payload.files_info)&&(Ve.payload.files_info=Ve.payload.files_info.map(Le=>({...Le,data:Le!=null&&Le.data?`<base64 ${String(Le.data).length} chars>`:Le==null?void 0:Le.data}))),Ve}catch{return qe}};try{let qe={};try{if(r)qe={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const Fe=window.__AUTH_TOKEN__,vt=((D=window.localStorage)==null?void 0:D.getItem("authToken"))||null;let ne=null;try{const pe=(q=window.localStorage)==null?void 0:q.getItem("chat-settings");pe&&(ne=((M=JSON.parse(pe))==null?void 0:M.apiKey)||null)}catch{}const we=Fe||vt||ne||null;we&&(qe={Authorization:`Bearer ${we}`})}}catch{}console.debug("[use-chat] POST",t+n,A(z));let Xe={};if(typeof window<"u")try{const Ue=(L=window.localStorage)==null?void 0:L.getItem("authSessionId");Ue&&(Xe={"X-Session-Id":Ue})}catch{}const Ve={...qe,...Xe,...s.current},Le={"Content-Type":"application/json",Accept:"text/event-stream",...Ve},Ae=await fetch(t+n,{method:"POST",headers:Le,body:JSON.stringify(z),signal:G.signal,credentials:i});if(j.current&&(j.current.headers=Ve),!Ae.ok||!Ae.body){const Ue=await Ae.text().catch(()=>"");console.debug("[use-chat] non-OK response",Ae.status,Ue==null?void 0:Ue.slice(0,500));const Fe=`stream ${Ae.status}${Ue?": "+Ue:""}`;throw(Y=I==null?void 0:I.onConnectionError)==null||Y.call(I,Fe),B=!0,J="error",P=Fe,new Error(Fe)}b(!0);const dt=Ae.body.getReader(),Rt=new TextDecoder;let tt="",st=[];E.current=0,x(0);let gt=0,St=null;const xt=()=>{if(st.length){const Ue=st.join("");st=[],T.current&&m(Fe=>Fe+Ue)}St=null},rn=()=>{typeof window<"u"&&St==null&&(St=requestAnimationFrame(xt))};let It=Date.now();const mn=setInterval(()=>{var Ue;if(Date.now()-It>18e5){const Fe="Stream idle timeout";d(Fe),J="error",P=Fe,G.abort(),(Ue=I==null?void 0:I.onError)==null||Ue.call(I,Fe)}},5e3),Zt=1024*1024;try{const Ue=Ae.headers.get("X-Thread-Id")||Ae.headers.get("x-thread-id"),Fe=Ae.headers.get("X-Thread-Created")||Ae.headers.get("x-thread-created"),vt=Ue??null,ne=String(Fe??"").toLowerCase()==="true";for(j.current&&!j.current.threadId&&(j.current={...j.current,threadId:vt}),(Z=I==null?void 0:I.onOpen)==null||Z.call(I,{threadId:vt,created:ne});;){const{value:we,done:pe}=await dt.read();if(pe)break;tt+=Rt.decode(we,{stream:!0}),tt.length>Zt&&(tt="",console.warn("Stream buffer reset: exceeded 1MB"));let ue;for(;(ue=tt.indexOf(`
36
36
 
37
- `))>=0;){const Ce=Je.slice(0,ce);Je=Je.slice(ce+2);const qe=Ce.split(/\r?\n/),Ne=[];for(const nt of qe)if(!(!nt||nt.startsWith(":"))&&nt.startsWith("data:")){const ft=nt.slice(5);Ne.push(ft.startsWith(" ")?ft.slice(1):ft)}const je=Ne.join(`
38
- `);if(!je)continue;let Oe;try{Oe=JSON.parse(je)}catch{console.debug("[use-chat] malformed SSE:",je.slice(0,200));continue}const tt=iu(Oe)?Oe.data:Oe;if(!tt){console.warn("[use-chat] dropped envelope event without payload",Oe);continue}const ye=tt;Nt=Date.now();const Ye=ye.seq;if(Ye!==void 0){if(Ye<=gt){console.debug("[use-chat] drop duplicate/out-of-order event",{seq:Ye,lastProcessedSeq:gt,type:ye.type});continue}gt>0&&Ye>gt+1&&((se=I==null?void 0:I.onGap)==null||se.call(I,{from:gt,to:Ye})),gt=Ye,E.current=Ye,x(Ye)}if(ye.type==="message.start"&&ye.role==="assistant"){const nt=du(ye.model);V.current={messageId:ye.id,lastSeq:Ye??null,lastText:""},k({id:ye.id,role:"assistant",name:nt??void 0,model:ye.model,createdAt:new Date().toISOString(),content:[]})}if(ye.type==="checkpoint")R.current=ye.checkpointId??null,$.current=ye.checkpointNs??null,v(ye.checkpointId??null);else if(ye.type==="state_history"){F.current=ye;try{const ft=Yn(ye).latest;ft&&(R.current=ft.checkpointId??null,$.current=ft.checkpointNs??null,v(ft.checkpointId??null))}catch(nt){console.warn("[use-chat] Failed to hydrate state_history payload",nt)}}try{D==null||D(ye)}catch(nt){console.error("[use-chat] Error in onEvent callback:",nt,"for event:",ye.type)}if(ye.type==="message.delta"){k(ft=>{const In=V.current;if(!ft||In.messageId!==ft.id)return ft;const{newParts:N,newMeta:ee,changed:ue}=cu(ft.content??[],ye.delta,{lastSeq:In.lastSeq,lastText:In.lastText},Ye??null);return ue?(V.current={...In,lastSeq:ee.lastSeq??In.lastSeq,lastText:ee.lastText??In.lastText},{...ft,content:N}):ft});const nt=ye.delta.filter(ft=>ft.type==="text").map(ft=>ft.text).join("");nt&&e.autoAppendAssistant!==!1&&(Ct.push(nt),rn())}else if(ye.type==="heartbeat"){console.debug("[use-chat] heartbeat received");try{(ie=I==null?void 0:I.onHeartbeat)==null||ie.call(I,ye)}catch(nt){console.warn("[use-chat] heartbeat callback failed",nt)}}else if(xt!==null&&cancelAnimationFrame(xt),It(),ye.type==="checkpoint")v(ye.checkpointId);else if(ye.type==="error"){const nt=ye;if(d(nt.message),J="error",j=nt.message,nt.error_type==="auth_error"||nt.code==="TOKEN_EXPIRED"||((re=nt.message)==null?void 0:re.includes("token"))||((de=nt.message)==null?void 0:de.includes("401"))||((be=nt.message)==null?void 0:be.includes("unauthorized"))||((Me=nt.message)==null?void 0:Me.includes("Unauthorized"))){console.error("[use-chat] Auth error detected:",nt.message);try{(Fe=I==null?void 0:I.onAuthError)==null||Fe.call(I,nt.message)}catch(In){console.warn("[use-chat] onAuthError handler failed",In)}Y.abort()}}}}It(),J===null&&!Y.signal.aborted&&(J="complete")}catch(Be){if(Be.name==="AbortError")J=J??"aborted";else{const $e=Be.message||String(Be);J="error",j=$e,d($e),(De=I==null?void 0:I.onError)==null||De.call(I,$e)}}finally{try{await ut.cancel()}catch{}finally{(Le=ut.releaseLock)==null||Le.call(ut)}xt!==null&&typeof window<"u"&&window.cancelAnimationFrame(xt),clearInterval(mn)}}catch(Ke){if(Ke.name==="AbortError")J=J??"aborted";else{const We=Ke.message||String(Ke);J="error",j=We,d(We),(it=I==null?void 0:I.onError)==null||it.call(I,We),B||((dt=I==null?void 0:I.onConnectionError)==null||dt.call(I,We),B=!0)}}finally{const Ke=E.current,We=R.current,Xe=$.current,ke=F.current,Ue=J??(Y.signal.aborted?"aborted":j?"error":"complete");try{(Et=I==null?void 0:I.onClosed)==null||Et.call(I,{reason:Ue,lastSeq:Ke,lastCheckpointId:We,lastCheckpointNs:Xe,lastStateHistory:ke,error:j})}catch(ut){console.warn("[use-chat] onClosed callback failed",ut)}l(!1),b(!1),S.current=null,E.current=0,x(0),A.current=null}})(),{close:()=>Y.abort()}},[t,n,r,e.autoAppendAssistant]);return w.useEffect(()=>()=>{var z;T.current=!1,(z=S.current)==null||z.abort()},[]),{isStreaming:a,error:c,assistantText:h,assistantMessage:C,lastCheckpointId:f,lastSeq:g,connected:y,stream:H,stop:G,clear:_,setToken:X}}const Yv=["detail","message","error","description","title"];function Yo(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=Yo(t);if(n)return n}return null}if(typeof e=="object"){const t=e;for(const n of Yv){const r=Yo(t[n]);if(r)return r}if("errors"in t){const n=Yo(t.errors);if(n)return n}}return null}function Xv(e){if(!e)return"Request failed";const t=e.response,n=Yo(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 fu({api:e,initialThreadId:t=null,onError:n,onThreadChange:r,onCurrentThreadDeleted:o}){const[s,i]=w.useState([]),[a,l]=w.useState(t),[c,d]=w.useState(!1),[h,m]=w.useState(null),[f,v]=w.useState([]),[g,x]=w.useState(!1),[,y]=w.useState(null),[b,C]=w.useState(null),[k,S]=w.useState(!1),T=w.useRef(a),E=w.useRef(new Map);w.useEffect(()=>{T.current=a},[a]);const A=w.useCallback(async()=>{d(!0),m(null);try{const D=await e.listThreads();i(D??[])}catch(D){const I=String(D);m(I),n==null||n(I)}finally{d(!1)}},[e,n]),R=w.useCallback(async()=>{x(!0),y(null);try{const D=await e.listSharedThreads();v(D??[])}catch(D){const I=String(D);y(I),n==null||n(I)}finally{x(!1)}},[e,n]);w.useEffect(()=>{A()},[A]),w.useEffect(()=>{R()},[R]),w.useEffect(()=>{r==null||r(a)},[a,r]);const $=w.useCallback(async D=>{try{const I=await e.createThread(D);return l(I.threadId),await A(),I.threadId}catch(I){const Y=String(I);return n==null||n(Y),null}},[e,n,A]),F=w.useCallback(async D=>{const I=s;i(J=>J.filter(j=>j.threadId!==D));const Y=new AbortController;E.current.set(D,Y);try{await e.deleteThread(D),T.current===D&&(l(null),o==null||o())}catch(J){i(I);const j=String(J);n==null||n(j)}finally{E.current.delete(D)}},[e,o,n,s]),V=w.useCallback(async(D,I)=>{try{await e.updateThread(D,I),await A()}catch(Y){n==null||n(String(Y))}},[e,n,A]),X=w.useCallback(async(D,I)=>{S(!0),C("Sharing thread…");try{await e.shareThread(D,I),await R(),C("Shared successfully")}catch(Y){const J=Xv(Y);throw n==null||n(J),C(`Failed to share: ${J}`),new Error(J)}finally{S(!1)}},[e,n,R]),_=w.useCallback(async(D,I)=>{try{await e.unshareThread(D,I),await R()}catch(Y){const J=String(Y);throw n==null||n(J),Y}},[e,n,R]),G=w.useMemo(()=>({createThread:$,deleteThread:F,renameThread:V,refreshThreads:A,refreshSharedThreads:R,shareThread:X,unshareThread:_}),[$,F,V,A,R,X,_]),H=w.useCallback(D=>{if(!(D!=null&&D.threadId))return;const I={threadId:D.threadId,title:D.title||`Thread ${D.threadId.slice(0,8)}`,createdAt:D.createdAt||new Date().toISOString(),updatedAt:D.updatedAt||new Date().toISOString(),messageCount:D.messageCount??1};i(Y=>{let J=!1;const j=Y.map(B=>B.threadId===I.threadId?(J=!0,console.debug("[useThreadsState] thread_info: updating existing thread",I.threadId),{...B,title:I.title??B.title,updatedAt:I.updatedAt??B.updatedAt,messageCount:I.messageCount??B.messageCount}):B);return J?j:(console.debug("[useThreadsState] thread_info: adding thread to list",I.threadId),[I,...Y])})},[]),z=w.useCallback(()=>C(null),[]);return{threads:s,currentThreadId:a,currentThreadIdRef:T,setCurrentThreadId:l,isLoadingThreads:c,threadsError:h,sharedThreads:f,isLoadingSharedThreads:g,actions:G,addThreadFromEvent:H,shareInFlight:k,shareStatus:b,clearShareStatus:z}}const hu=w.createContext(null);function pu({children:e,initialThreadId:t=null,onError:n,onThreadChange:r}){const{api:o}=Jr(),{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}=fu({api:o,initialThreadId:t,onError:n,onThreadChange:r}),b=w.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(hu.Provider,{value:b,children:e})}function xr(){const e=w.useContext(hu);if(!e)throw new Error("useThreads must be used within a ThreadsProvider");return e}function Qr(e){const t=e==null?void 0:e.trim();if(!t||!(t.startsWith("{")||t.startsWith("[")))return null;try{return JSON.parse(t)}catch{const n=Jv(t);if(n)try{return JSON.parse(n)}catch{return null}return null}}function Jv(e){let t=!1,n="";for(const o of e){if(o==="\\"){n+=o,t=!t;continue}if(o==="'"&&!t){n+='"';continue}n+=o,t=!1}return n.replace(/\bTrue\b/g,"true").replace(/\bFalse\b/g,"false").replace(/\bNone\b/g,"null")}function mu(e){return!!(e&&typeof e=="object"&&(e.type==="file"||e.mimeType||e.filename||e.sourceType==="base64"))}function eo(e){if(typeof e=="string")return e;if(e&&typeof e=="object"){if(Array.isArray(e)){const n=e.map(eo).filter(r=>r!==void 0);if(!n.length){console.debug("[message-utils] sanitizeForDisplay - array emptied -> returning undefined",{originalLength:e.length});return}return n}if(mu(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=eo(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(mu(e))return"";try{const t=eo(e);return t===void 0?"":typeof t=="string"?t:JSON.stringify(t,null,2)}catch{return""}}function Zv(e){return typeof e!="string"?!1:/^[\s\n]*[-*]\s|^[\s\n]*#+\s|```|^\s*\[.*\]\(|^>\s/.test(e)}function Qv(e){const t=vr(e);return typeof e=="string"&&Zv(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=Qr(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 ew(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function Di(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 Xo(e){if(e==null)return null;const t=String(e).trim();return t.length>0?t:null}function tw(e){const t=r=>{try{const o=eo(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 nw(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function gu(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 rw(e){if(!e)return"image/png";const t=e.trim();return t?t.includes("/")?t:`image/${t}`:"image/png"}function ow(e){const t=[],n=r=>{r&&r.trim()&&t.push(r.trim())};return e&&(n(e.plotId),n(e.artifactId)),t}function sw({base64:e,url:t,formatHint:n,extras:r}){const o=typeof e=="string"&&e.length>0,s=rw(n),i=o?`data:${s};base64,${e}`:t,a=ow(r),l=a.length?a.join(" / "):void 0,c=l?`${l} artifact`:"artifact image";return{src:i,alt:c,label:l}}function iw(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 sw({base64:t,url:n,formatHint:r,extras:{plotId:e.plotId,artifactId:e.artifactId}})}function xu(e){var n;const t=(n=e.additionalKwargs)==null?void 0:n.toolProgress;return Array.isArray(t)?t:[]}const aw={messages:[],assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,messagesStreamMeta:{},pendingInterrupt:null};function lw(e,t){var n;switch(t.type){case"reset":return{messages:Oi(((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=Oi(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=Oi(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 vu(e,t.payload.ev);case"batch":{const{events:r}=t.payload;return r.length?r.reduce((o,s)=>vu(o,s),e):e}default:return e}}function cw(e=[]){const[t,n]=w.useReducer(lw,{...aw,messages:e}),r=w.useRef([]),o=w.useRef(null),s=w.useRef(null),i=w.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=w.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=w.useCallback(d=>{r.current.push(d),a()},[a]);w.useEffect(()=>()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),r.current=[]},[]);const c=w.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 vu(e,t){var n,r,o;if(t.type==="message.start"&&t.role==="assistant"){const s=t.id,i=du(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 dw(e,t);if(t.type==="tool.progress")return fw(e,t);if(t.type==="tool.end")return hw(e,t);if(t.type==="message.delta"){const s=e.assemblingId??au(e.messages);if(!s)return e;const i=e.messages,a=i.findIndex(S=>S.id===s&&S.role==="assistant");if(a===-1)return e;const l=i[a],c=e.messagesStreamMeta,d=c??{},h=d[s],m=h??{lastSeq:null,lastText:lu(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}=cu(l.content,t.delta,m,f);if(!x)return e;const y={...l,content:v},b=Zr(i,a,y),C=!h||h.lastSeq!==g.lastSeq||h.lastText!==g.lastText,k=C?{...d,[s]:g}:c;return C?{...e,messages:b,messagesStreamMeta:k}:{...e,messages:b}}if(t.type==="message.end"){const s=e.assemblingId??au(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=Yn(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 Li(e){return e.call_id??e.id??null}function wu(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 $i(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||Di(r).toolCallId===t)return n}return-1}function uw(e){if(e==null)return[];const t=wr(e);if(typeof t=="string"&&t.trim())return[{type:"text",text:t}];const n=vr(t??e);return n?[{type:"text",text:n}]:[]}function yu(e,t){const n=e.additionalKwargs??{},r=Array.isArray(n.toolProgress)?[...n.toolProgress]:[],o={...n,toolProgress:[...r,t]};return{...e,additionalKwargs:o}}function dw(e,t){const n=Li(t),r=$i(e.messages,n),o=t.name??t.tool??void 0,s=wu(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:Zr(e.messages,r,d)}}const i=bu(s,n,o,t.args);return{...e,messages:[...e.messages,i]}}function fw(e,t){const n=Li(t);if(!n)return e;const r=$i(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=yu(e.messages[r],o);return{...e,messages:Zr(e.messages,r,a)}}function hw(e,t){const n=Li(t),r=wu(t);let o=e.messages,s=$i(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=uw(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=yu(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:Zr(o,s,f)}}function Su({api:e,seed:t,onError:n,currentThreadId:r,initialThreadId:o=null,initialCheckpointId:s=null,initialCheckpointNs:i=null,autoLoadInitial:a=!0,isStreaming:l,getMessages:c}){const[d,h]=w.useState(null),f=w.useMemo(()=>Yn(d),[d]).checkpoints,v=nc(f),g=v.timeline,[x,y]=w.useState(!1),[b,C]=w.useState(!1),[k,S]=w.useState(null),T=w.useRef(r),E=w.useRef(null),A=w.useRef(null),R=w.useRef(null),$=w.useRef(null),F=w.useRef(null),V=w.useRef(new Map),X=w.useRef(null);w.useEffect(()=>{T.current=r},[r]);const _=w.useCallback(async P=>{var K,M;if(!P.threadId)return;const O=P.threadId;(K=P.onStart)==null||K.call(P),P.setLoading(!0);try{await P.action(O)}catch(L){if(!Kc(L)&&T.current===O){const Z=String(L);(M=P.handleError)==null||M.call(P,Z),n==null||n(Z)}throw L}finally{P.setLoading(!1)}},[n]),G=w.useCallback(async(P,O)=>{var Z;if(!P)return;const K=`${P}:${O??"latest"}`,M=V.current.get(K);if(M)return M;(Z=X.current)==null||Z.abort();const L=new AbortController;X.current=L;const q=_({threadId:P,setLoading:y,onStart:()=>S(null),handleError:se=>S(se),action:async se=>{const ie=await e.getStateHistory({threadId:se,checkpointId:O??void 0,signal:L.signal});if(T.current!==se){console.log(`[useThreadHistoryState] Thread changed during load (was ${se}, now ${T.current}), discarding stale data`);return}const{checkpoints:re}=Yn(ie),de=re.find(be=>be.messages&&be.messages.length>0)??(O?re.find(be=>be.checkpointId===O):null)??re[0];t((de==null?void 0:de.messages)??[],{checkpointId:(de==null?void 0:de.checkpointId)??null,checkpointNs:(de==null?void 0:de.checkpointNs)??null}),h(ie)}});V.current.set(K,q);try{await q}finally{V.current.delete(K),X.current===L&&(X.current=null)}return T.current===P&&(F.current=K),q},[e,t,_]),H=w.useCallback(async(P,O)=>{$.current=P;try{await G(P,O)}catch(K){if(!Kc(K))throw K}finally{$.current===P&&($.current=null)}},[G]),z=w.useCallback(P=>{A.current=P},[]),D=w.useCallback(P=>{R.current=P},[]),I=w.useCallback(P=>{const O=P.threadId??T.current;if(!O||T.current&&T.current!==O)return;const{checkpoints:K}=Yn(P);if(!K.length)return;const M=K.find(q=>q.messages&&q.messages.length>0)??K.find(q=>!!q.checkpointId)??K[0],L=R.current===O;!l&&!L&&t((M==null?void 0:M.messages)??[],{checkpointId:(M==null?void 0:M.checkpointId)??null,checkpointNs:(M==null?void 0:M.checkpointNs)??null}),h(P),F.current=`${O}:latest`,A.current=null,R.current===O&&(R.current=null)},[t,l]),Y=w.useCallback(async(P,O)=>{const K=T.current;await _({threadId:K,setLoading:C,action:async M=>{const L=await e.getStateHistory({threadId:M,checkpointId:P,checkpointNs:O??void 0});if(T.current!==M)return;const{checkpoints:q}=Yn(L),Z=q.find(se=>se.checkpointId===P&&(O?se.checkpointNs===O:!0));if(!Z){console.warn("[useThreadHistoryState] Requested checkpoint not found:",{checkpointId:P,checkpointNs:O});return}h(L),t(Z.messages??[],{checkpointId:Z.checkpointId??null,checkpointNs:Z.checkpointNs??null})}}).catch(()=>{})},[e,t,_]),J=w.useCallback((P,O)=>{t(c(),{checkpointId:P??null,checkpointNs:O??null})},[c,t]),j=w.useCallback(async()=>{T.current&&await H(T.current)},[H]);w.useEffect(()=>{if(!a||!r||x||l)return;if(A.current===r){A.current=null,E.current=r;return}if(R.current===r){E.current=r;return}if($.current===r){$.current=null,E.current=r;return}if(E.current===r)return;E.current=r;let P;const O=`${r}:latest`;F.current!==O&&H(r,P)},[a,r,s,i,o,x,l,H]);const B=w.useCallback(()=>{h(null),y(!1),C(!1),S(null),A.current=null,R.current=null,E.current=null,F.current=null,$.current=null},[]);return{threadCheckpoints:f,threadTimeline:g,checkpointIndex:v,isLoadingThread:x,isLoadingCheckpoint:b,threadStateError:k,loadThread:H,navigateToCheckpoint:Y,setCurrentCheckpointId:J,returnToLatest:j,handleStateHistoryEvent:I,markSkipNextLoad:z,markStreamPendingThread:D,resetHistoryState:B}}const Cu=w.createContext(null),Tu=w.createContext(null);function to(){const e=w.useContext(Cu);if(!e)throw new Error("useThreadState must be used within a ThreadStateProvider");return e}function ku(){const e=w.useContext(Tu);if(!e)throw new Error("useThreadStateUpdater must be used within a ThreadStateProvider");return e}function Eu({children:e,initialThreadId:t=null,initialCheckpointId:n=null,initialCheckpointNs:r=null,autoLoadInitial:o=!0,isStreaming:s,onError:i}){const{api:a}=Jr(),{currentThreadId:l}=xr(),{state:c,seed:d,pushUser:h,onEvent:m}=cw(),{threadCheckpoints:f,threadTimeline:v,checkpointIndex:g,isLoadingThread:x,isLoadingCheckpoint:y,threadStateError:b,loadThread:C,navigateToCheckpoint:k,setCurrentCheckpointId:S,returnToLatest:T,handleStateHistoryEvent:E,markSkipNextLoad:A,markStreamPendingThread:R,resetHistoryState:$}=Su({api:a,seed:d,onError:i,currentThreadId:l,initialThreadId:t,initialCheckpointId:n,initialCheckpointNs:r,autoLoadInitial:o,isStreaming:s,getMessages:w.useCallback(()=>c.messages,[c.messages])}),[F,V]=w.useState(()=>async()=>{throw new Error("clearThread is not ready")}),[X,_]=w.useState(()=>async()=>{throw new Error("respondToInterrupt is not ready")});w.useEffect(()=>{l||(d([],{}),$())},[l,d,$]);const G=w.useCallback(Y=>V(()=>Y),[]),H=w.useCallback(Y=>_(()=>Y),[]),z=w.useMemo(()=>({assemblingMessageId:c.assemblingId??null}),[c.assemblingId]),D=w.useMemo(()=>({threadId:l,messages:c.messages,interrupt:c.pendingInterrupt,checkpoint:{id:c.lastCheckpointId??null,namespace:c.lastCheckpointNs??null},checkpoints:f,checkpointIndex:g,timelineCheckpoints:v,metadata:z,isLoading:x,isLoadingCheckpoint:y,error:b,clearState:F,navigateToCheckpoint:k,setCurrentCheckpointId:S,returnToLatest:T,loadThread:C,clearThread:F,respondToInterrupt:X,messagePreviews:g.messagePreviews,handleStateHistoryEvent:E,markSkipNextLoad:A,markStreamPendingThread:R,resetHistoryState:$,pushUser:h,onEvent:m}),[l,c,f,v,g,z,x,y,b,F,k,S,T,C,X,g.messagePreviews,E,A,R,$,h,m]),I=w.useMemo(()=>({registerClearThread:G,registerRespondToInterrupt:H}),[G,H]);return u.jsx(Tu.Provider,{value:I,children:u.jsx(Cu.Provider,{value:D,children:e})})}function Iu(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 pw(e){const t=Iu(e,["checkpoint_id","checkpointId"]);if(!t)return null;const n=Iu(e,["checkpoint_ns","checkpointNs"]);return{checkpointId:t,checkpointNs:n}}function mw(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 gw(e,t){const n=[...e].sort(mw);for(const r of n){if(r.messageId!==t)continue;const o=pw(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 Nu=w.createContext(null),Au=w.createContext(!1);function xw({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}=Jr(),m=w.useMemo(()=>xn(h),[h]),{stream:f,stop:v,isStreaming:g,error:x,setToken:y}=Gv({baseUrl:m}),[b,C]=w.useState(!1);return w.useEffect(()=>{C(g)},[g]),u.jsx(pu,{initialThreadId:t,onError:s,onThreadChange:a,children:u.jsx(Eu,{initialThreadId:t,initialCheckpointId:n,initialCheckpointNs:r,autoLoadInitial:o,onError:s,isStreaming:b,children:u.jsx(Au.Provider,{value:!0,children:u.jsx(vw,{api:d,streamApi:{stream:f,stop:v,isStreaming:g,error:x,setToken:y},onError:s,onAuthError:i,onConnectionError:l,onToolEnd:c,children:e})})})})}function vw({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:b,markStreamPendingThread:C,resetHistoryState:k,pushUser:S,onEvent:T}=to(),{registerClearThread:E,registerRespondToInterrupt:A}=ku(),R=w.useCallback(z=>{v(z),f.current!==z.threadId&&((z.created??!f.current)&&b(z.threadId),C(z.threadId),m(z.threadId))},[v,b,C,m,f]),$=w.useCallback(z=>{z.type==="thread_info"?R(z):z.type==="state_history"?y(z):z.type==="tool.end"?i==null||i(z):T(z)},[R,y,T,i]),F=w.useCallback(z=>{a(z,$,{onError:D=>{console.error("[StreamingProvider] Stream error:",D),r==null||r(D)},onAuthError:D=>{console.error("[StreamingProvider] Auth error:",D),o==null||o(D)},onConnectionError:D=>{console.error("[StreamingProvider] Connection error:",D),s==null||s(D)}})},[a,$,r,o,s]),V=w.useRef(g);w.useEffect(()=>{V.current=g},[g]);const X=w.useCallback(async(z,D,I)=>{const Y=f.current;if(!Y)throw new Error("No active thread to handle interrupt");const J=D?I??!0:!1,j=V.current,B={threadId:Y,checkpointId:j.id??void 0,checkpointNs:j.namespace??void 0,command:{kind:"resume",value:J}};F(B)},[f,F]);w.useEffect(()=>{A(X)},[X,A]);const _=w.useCallback(async()=>{l(),k(),m(null)},[k,m,l]);w.useEffect(()=>{E(_)},[_,E]);const G=w.useCallback(async(z,D)=>{let I=f.current;const Y=(z==null?void 0:z.text)??"",J=(z==null?void 0:z.attachments)??[],j=(Y==null?void 0:Y.trim())??"",B={...(z==null?void 0:z.payload)??{}},P=Array.isArray(B.messages)?B.messages:void 0;P&&delete B.messages;const O=!!(P&&P.length);if(!I&&!j&&J.length===0&&!O)return;if(!I){const De=Math.floor(Date.now()/1e3).toString(16).padStart(8,"0"),Le=Array.from({length:4},()=>Math.floor(Math.random()*4294967295).toString(16).padStart(8,"0")).join("").slice(0,16);I=`${De}${Le}`,b(I),m(I)}const{contentParts:K,filesInfo:M}=await su(J),L=[...K];j&&L.push({type:"text",text:Y});const q=D==null?void 0:D.originalMessageId,Z=!!(D!=null&&D.edit&&q),se=!O&&L.length>0;let ie=null;se&&(ie={id:Z?q:`msg-${Date.now()}`,role:"user",content:L,createdAt:new Date().toISOString()},Z?S(ie,q):S(ie));const re=O?P:ie?[ie]:[],de={...B,...M.length?{files_info:M}:{}};re.length?de.messages=re:"messages"in de||(de.messages=[]);let be=(D==null?void 0:D.checkpointId)??g.id??void 0,Me=(D==null?void 0:D.checkpointNs)??g.namespace??void 0;if(Z&&q){const De=gw(x,q);be=De.checkpointId,Me=De.checkpointNs??void 0}const Fe={threadId:I,payload:de,checkpointId:be,checkpointNs:Me,edit:!!(D!=null&&D.edit)};F(Fe)},[g,f,b,S,F,x]),H=w.useMemo(()=>({isStreaming:c,error:d,connectionState:c?"connected":"idle",submit:G,send:G,stop:l,setAuthToken:h}),[c,d,G,l,h]);return u.jsx(Nu.Provider,{value:H,children:e})}function Fi(){const e=w.useContext(Nu);if(!e)throw new Error("useStream must be used within StreamingProvider");return e}function ww(){return w.useContext(Au)}function ju(e){return typeof e=="object"&&e!==null}function bw(e,t){if(Object.is(e,t))return!0;if(!ju(e)||!ju(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 Pu(e){const t=w.useRef(e),n=w.useRef(e);return bw(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=Pu(t),m=no(a),f=no(l),v=no(i),g=no(c),x=no(d),y=w.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(ru,{apiConfig:h,children:u.jsx(xw,{...y,children:e})})}function no(e){const t=w.useRef(e);return w.useEffect(()=>{t.current=e},[e]),w.useCallback((...n)=>{const r=t.current;if(r)return r(...n)},[])}function yr(e){if(!(typeof globalThis>"u"))return globalThis[e]}function yw(e){if(typeof e!="string")return;const t=e.trim();if(t)return xn(t)}function _u(){const e=[yr("__API_BASE_URL__"),yr("__CHAT_API_BASE_URL__"),yr("__CHAT_API_URL__")];for(const t of e){const n=yw(t);if(n)return n}}function Ru(){const e=[yr("__API_AUTH_TOKEN__"),yr("__CHAT_API_KEY__"),yr("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function Mu(...e){for(const t of e)if(typeof t=="string"&&t.trim())return xn(t);return xn()}function Ou(){const e={},t=_u(),n=Ru();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function Du(){const e=Ou(),t=Nn.getAuthToken(),n=_u();return{apiBaseUrl:Mu(e.baseUrl,Nn.baseUrl,n),apiKey:t||e.apiKey||Ru()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,darkMode:!1,enableSound:!1,messageHistory:100}}const Bi="chat-settings";function Lu(){try{const e=localStorage.getItem(Bi);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function $u(e){try{const t={...e,apiBaseUrl:xn(e.apiBaseUrl)};localStorage.setItem(Bi,JSON.stringify(t)),t.apiKey&&Nn.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function Sw(){const e=Du(),t=Lu(),n=Nn.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:Mu(Nn.baseUrl,r,e.apiBaseUrl)}}function Cw(e){Nn.updateConfig({baseUrl:e.apiBaseUrl,authToken:e.apiKey??void 0}),$u(e)}function te(...e){return sx.twMerge(ox.clsx(e))}const Tw=Hr.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"}}),et=p.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?Vt.Slot:"button";return u.jsx(i,{className:te(Tw({variant:t,size:n,className:e})),ref:s,...o})});et.displayName="Button";function ae(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 Fu(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Mn(...e){return t=>{let n=!1;const r=e.map(o=>{const s=Fu(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():Fu(e[o],null)}}}}function _e(...e){return p.useCallback(Mn(...e),e)}function kw(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 an(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,Ew(o,...t)]}function Ew(...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 kt=globalThis!=null&&globalThis.document?p.useLayoutEffect:()=>{},Iw=p[" useInsertionEffect ".trim().toString()]||kt;function On({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=Nw({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=Aw(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 Nw({defaultProp:e,onChange:t}){const[n,r]=p.useState(e),o=p.useRef(n),s=p.useRef(t);return Iw(()=>{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 Aw(e){return typeof e=="function"}var jw=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],me=jw.reduce((e,t)=>{const n=Vt.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 zi(e,t){e&&Ur.flushSync(()=>e.dispatchEvent(t))}function Jo(e){const t=e+"CollectionProvider",[n,r]=an(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=g=>{const{scope:x,children:y}=g,b=w.useRef(null),C=w.useRef(new Map).current;return u.jsx(o,{scope:x,itemMap:C,collectionRef:b,children:y})};i.displayName=t;const a=e+"CollectionSlot",l=Vt.createSlot(a),c=w.forwardRef((g,x)=>{const{scope:y,children:b}=g,C=s(a,y),k=_e(x,C.collectionRef);return u.jsx(l,{ref:k,children:b})});c.displayName=a;const d=e+"CollectionItemSlot",h="data-radix-collection-item",m=Vt.createSlot(d),f=w.forwardRef((g,x)=>{const{scope:y,children:b,...C}=g,k=w.useRef(null),S=_e(x,k),T=s(d,y);return w.useEffect(()=>(T.itemMap.set(k,{ref:k,...C}),()=>void T.itemMap.delete(k))),u.jsx(m,{[h]:"",ref:S,children:b})});f.displayName=d;function v(g){const x=s(e+"CollectionConsumer",g);return w.useCallback(()=>{const b=x.collectionRef.current;if(!b)return[];const C=Array.from(b.querySelectorAll(`[${h}]`));return Array.from(x.itemMap.values()).sort((T,E)=>C.indexOf(T.ref.current)-C.indexOf(E.ref.current))},[x.collectionRef,x.itemMap])}return[{Provider:i,Slot:c,ItemSlot:f},v,r]}var Pw=p.createContext(void 0);function Zo(e){const t=p.useContext(Pw);return e||t||"ltr"}function pt(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 _w(e,t=globalThis==null?void 0:globalThis.document){const n=pt(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 Rw="DismissableLayer",Hi="dismissableLayer.update",Mw="dismissableLayer.pointerDownOutside",Ow="dismissableLayer.focusOutside",Bu,zu=p.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Sr=p.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...l}=e,c=p.useContext(zu),[d,h]=p.useState(null),m=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,f]=p.useState({}),v=_e(t,E=>h(E)),g=Array.from(c.layers),[x]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),y=g.indexOf(x),b=d?g.indexOf(d):-1,C=c.layersWithOutsidePointerEventsDisabled.size>0,k=b>=y,S=Lw(E=>{const A=E.target,R=[...c.branches].some($=>$.contains(A));!k||R||(o==null||o(E),i==null||i(E),E.defaultPrevented||a==null||a())},m),T=$w(E=>{const A=E.target;[...c.branches].some($=>$.contains(A))||(s==null||s(E),i==null||i(E),E.defaultPrevented||a==null||a())},m);return _w(E=>{b===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&&(Bu=m.body.style.pointerEvents,m.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(d)),c.layers.add(d),Uu(),()=>{n&&c.layersWithOutsidePointerEventsDisabled.size===1&&(m.body.style.pointerEvents=Bu)}},[d,m,n,c]),p.useEffect(()=>()=>{d&&(c.layers.delete(d),c.layersWithOutsidePointerEventsDisabled.delete(d),Uu())},[d,c]),p.useEffect(()=>{const E=()=>f({});return document.addEventListener(Hi,E),()=>document.removeEventListener(Hi,E)},[]),u.jsx(me.div,{...l,ref:v,style:{pointerEvents:C?k?"auto":"none":void 0,...e.style},onFocusCapture:ae(e.onFocusCapture,T.onFocusCapture),onBlurCapture:ae(e.onBlurCapture,T.onBlurCapture),onPointerDownCapture:ae(e.onPointerDownCapture,S.onPointerDownCapture)})});Sr.displayName=Rw;var Dw="DismissableLayerBranch",Hu=p.forwardRef((e,t)=>{const n=p.useContext(zu),r=p.useRef(null),o=_e(t,r);return p.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),u.jsx(me.div,{...e,ref:o})});Hu.displayName=Dw;function Lw(e,t=globalThis==null?void 0:globalThis.document){const n=pt(e),r=p.useRef(!1),o=p.useRef(()=>{});return p.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){Wu(Mw,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 $w(e,t=globalThis==null?void 0:globalThis.document){const n=pt(e),r=p.useRef(!1);return p.useEffect(()=>{const o=s=>{s.target&&!r.current&&Wu(Ow,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 Uu(){const e=new CustomEvent(Hi);document.dispatchEvent(e)}function Wu(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?zi(o,s):o.dispatchEvent(s)}var Fw=Sr,Bw=Hu,Ui=0;function Wi(){p.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Vu()),document.body.insertAdjacentElement("beforeend",e[1]??Vu()),Ui++,()=>{Ui===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Ui--}},[])}function Vu(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var Vi="focusScope.autoFocusOnMount",Ki="focusScope.autoFocusOnUnmount",Ku={bubbles:!1,cancelable:!0},zw="FocusScope",Qo=p.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,l]=p.useState(null),c=pt(o),d=pt(s),h=p.useRef(null),m=_e(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(C){if(f.paused||!a)return;const k=C.target;a.contains(k)?h.current=k:Dn(h.current,{select:!0})},x=function(C){if(f.paused||!a)return;const k=C.relatedTarget;k!==null&&(a.contains(k)||Dn(h.current,{select:!0}))},y=function(C){if(document.activeElement===document.body)for(const S of C)S.removedNodes.length>0&&Dn(a)};document.addEventListener("focusin",g),document.addEventListener("focusout",x);const b=new MutationObserver(y);return a&&b.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",g),document.removeEventListener("focusout",x),b.disconnect()}}},[r,a,f.paused]),p.useEffect(()=>{if(a){Yu.add(f);const g=document.activeElement;if(!a.contains(g)){const y=new CustomEvent(Vi,Ku);a.addEventListener(Vi,c),a.dispatchEvent(y),y.defaultPrevented||(Hw(qw(qu(a)),{select:!0}),document.activeElement===g&&Dn(a))}return()=>{a.removeEventListener(Vi,c),setTimeout(()=>{const y=new CustomEvent(Ki,Ku);a.addEventListener(Ki,d),a.dispatchEvent(y),y.defaultPrevented||Dn(g??document.body,{select:!0}),a.removeEventListener(Ki,d),Yu.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 b=g.currentTarget,[C,k]=Uw(b);C&&k?!g.shiftKey&&y===k?(g.preventDefault(),n&&Dn(C,{select:!0})):g.shiftKey&&y===C&&(g.preventDefault(),n&&Dn(k,{select:!0})):y===b&&g.preventDefault()}},[n,r,f.paused]);return u.jsx(me.div,{tabIndex:-1,...i,ref:m,onKeyDown:v})});Qo.displayName=zw;function Hw(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Dn(r,{select:t}),document.activeElement!==n)return}function Uw(e){const t=qu(e),n=Gu(t,e),r=Gu(t.reverse(),e);return[n,r]}function qu(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 Gu(e,t){for(const n of e)if(!Ww(n,{upTo:t}))return n}function Ww(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 Vw(e){return e instanceof HTMLInputElement&&"select"in e}function Dn(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Vw(e)&&t&&e.select()}}var Yu=Kw();function Kw(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=Xu(e,t),e.unshift(t)},remove(t){var n;e=Xu(e,t),(n=e[0])==null||n.resume()}}}function Xu(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function qw(e){return e.filter(t=>t.tagName!=="A")}var Gw=p[" useId ".trim().toString()]||(()=>{}),Yw=0;function jt(e){const[t,n]=p.useState(Gw());return kt(()=>{n(r=>r??String(Yw++))},[e]),t?`radix-${t}`:""}const Xw=["top","right","bottom","left"],Ln=Math.min,Gt=Math.max,es=Math.round,ts=Math.floor,vn=e=>({x:e,y:e}),Jw={left:"right",right:"left",bottom:"top",top:"bottom"},Zw={start:"end",end:"start"};function qi(e,t,n){return Gt(e,Ln(t,n))}function An(e,t){return typeof e=="function"?e(t):e}function jn(e){return e.split("-")[0]}function Cr(e){return e.split("-")[1]}function Gi(e){return e==="x"?"y":"x"}function Yi(e){return e==="y"?"height":"width"}const Qw=new Set(["top","bottom"]);function wn(e){return Qw.has(jn(e))?"y":"x"}function Xi(e){return Gi(wn(e))}function eb(e,t,n){n===void 0&&(n=!1);const r=Cr(e),o=Xi(e),s=Yi(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=ns(i)),[i,ns(i)]}function tb(e){const t=ns(e);return[Ji(e),t,Ji(t)]}function Ji(e){return e.replace(/start|end/g,t=>Zw[t])}const Ju=["left","right"],Zu=["right","left"],nb=["top","bottom"],rb=["bottom","top"];function ob(e,t,n){switch(e){case"top":case"bottom":return n?t?Zu:Ju:t?Ju:Zu;case"left":case"right":return t?nb:rb;default:return[]}}function sb(e,t,n,r){const o=Cr(e);let s=ob(jn(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(Ji)))),s}function ns(e){return e.replace(/left|right|bottom|top/g,t=>Jw[t])}function ib(e){return{top:0,right:0,bottom:0,left:0,...e}}function Qu(e){return typeof e!="number"?ib(e):{top:e,right:e,bottom:e,left:e}}function rs(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 ed(e,t,n){let{reference:r,floating:o}=e;const s=wn(t),i=Xi(t),a=Yi(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(Cr(t)){case"start":f[i]-=m*(n&&c?-1:1);break;case"end":f[i]+=m*(n&&c?-1:1);break}return f}const ab=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}=ed(c,r,l),m=r,f={},v=0;for(let g=0;g<a.length;g++){const{name:x,fn:y}=a[g],{x:b,y:C,data:k,reset:S}=await y({x:d,y:h,initialPlacement:r,placement:m,strategy:o,middlewareData:f,rects:c,platform:i,elements:{reference:e,floating:t}});d=b??d,h=C??h,f={...f,[x]:{...f[x],...k}},S&&v<=50&&(v++,typeof S=="object"&&(S.placement&&(m=S.placement),S.rects&&(c=S.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):S.rects),{x:d,y:h}=ed(c,m,l)),g=-1)}return{x:d,y:h,placement:m,strategy:o,middlewareData:f}};async function ro(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=Qu(f),x=a[m?h==="floating"?"reference":"floating":h],y=rs(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})),b=h==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,C=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),k=await(s.isElement==null?void 0:s.isElement(C))?await(s.getScale==null?void 0:s.getScale(C))||{x:1,y:1}:{x:1,y:1},S=rs(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:b,offsetParent:C,strategy:l}):b);return{top:(y.top-S.top+v.top)/k.y,bottom:(S.bottom-y.bottom+v.bottom)/k.y,left:(y.left-S.left+v.left)/k.x,right:(S.right-y.right+v.right)/k.x}}const lb=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=Qu(d),m={x:n,y:r},f=Xi(o),v=Yi(f),g=await i.getDimensions(c),x=f==="y",y=x?"top":"left",b=x?"bottom":"right",C=x?"clientHeight":"clientWidth",k=s.reference[v]+s.reference[f]-m[f]-s.floating[v],S=m[f]-s.reference[f],T=await(i.getOffsetParent==null?void 0:i.getOffsetParent(c));let E=T?T[C]:0;(!E||!await(i.isElement==null?void 0:i.isElement(T)))&&(E=a.floating[C]||s.floating[v]);const A=k/2-S/2,R=E/2-g[v]/2-1,$=Ln(h[y],R),F=Ln(h[b],R),V=$,X=E-g[v]-F,_=E/2-g[v]/2+A,G=qi(V,_,X),H=!l.arrow&&Cr(o)!=null&&_!==G&&s.reference[v]/2-(_<V?$:F)-g[v]/2<0,z=H?_<V?_-V:_-X:0;return{[f]:m[f]+z,data:{[f]:G,centerOffset:_-G-z,...H&&{alignmentOffset:z}},reset:H}}}),cb=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),b=wn(a),C=jn(a)===a,k=await(l.isRTL==null?void 0:l.isRTL(c.floating)),S=m||(C||!g?[ns(a)]:tb(a)),T=v!=="none";!m&&T&&S.push(...sb(a,g,v,k));const E=[a,...S],A=await ro(t,x),R=[];let $=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&R.push(A[y]),h){const _=eb(o,i,k);R.push(A[_[0]],A[_[1]])}if($=[...$,{placement:o,overflows:R}],!R.every(_=>_<=0)){var F,V;const _=(((F=s.flip)==null?void 0:F.index)||0)+1,G=E[_];if(G&&(!(h==="alignment"?b!==wn(G):!1)||$.every(D=>wn(D.placement)===b?D.overflows[0]>0:!0)))return{data:{index:_,overflows:$},reset:{placement:G}};let H=(V=$.filter(z=>z.overflows[0]<=0).sort((z,D)=>z.overflows[1]-D.overflows[1])[0])==null?void 0:V.placement;if(!H)switch(f){case"bestFit":{var X;const z=(X=$.filter(D=>{if(T){const I=wn(D.placement);return I===b||I==="y"}return!0}).map(D=>[D.placement,D.overflows.filter(I=>I>0).reduce((I,Y)=>I+Y,0)]).sort((D,I)=>D[1]-I[1])[0])==null?void 0:X[0];z&&(H=z);break}case"initialPlacement":H=a;break}if(o!==H)return{reset:{placement:H}}}return{}}}};function td(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function nd(e){return Xw.some(t=>e[t]>=0)}const ub=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 ro(t,{...o,elementContext:"reference"}),i=td(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:nd(i)}}}case"escaped":{const s=await ro(t,{...o,altBoundary:!0}),i=td(s,n.floating);return{data:{escapedOffsets:i,escaped:nd(i)}}}default:return{}}}}},rd=new Set(["left","top"]);async function db(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=Cr(n),l=wn(n)==="y",c=rd.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 fb=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 db(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}}}}},hb=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:b}=x;return{x:y,y:b}}},...l}=An(e,t),c={x:n,y:r},d=await ro(t,l),h=wn(jn(o)),m=Gi(h);let f=c[m],v=c[h];if(s){const x=m==="y"?"top":"left",y=m==="y"?"bottom":"right",b=f+d[x],C=f-d[y];f=qi(b,f,C)}if(i){const x=h==="y"?"top":"left",y=h==="y"?"bottom":"right",b=v+d[x],C=v-d[y];v=qi(b,v,C)}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}}}}}},pb=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=wn(o),m=Gi(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 C=m==="y"?"height":"width",k=s.reference[m]-s.floating[C]+x.mainAxis,S=s.reference[m]+s.reference[C]-x.mainAxis;f<k?f=k:f>S&&(f=S)}if(c){var y,b;const C=m==="y"?"width":"height",k=rd.has(jn(o)),S=s.reference[h]-s.floating[C]+(k&&((y=i.offset)==null?void 0:y[h])||0)+(k?0:x.crossAxis),T=s.reference[h]+s.reference[C]+(k?0:((b=i.offset)==null?void 0:b[h])||0)-(k?x.crossAxis:0);v<S?v=S:v>T&&(v=T)}return{[m]:f,[h]:v}}}},mb=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 ro(t,c),h=jn(o),m=Cr(o),f=wn(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 b=g-d.top-d.bottom,C=v-d.left-d.right,k=Ln(g-d[x],b),S=Ln(v-d[y],C),T=!t.middlewareData.shift;let E=k,A=S;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(A=C),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(E=b),T&&!m){const $=Gt(d.left,0),F=Gt(d.right,0),V=Gt(d.top,0),X=Gt(d.bottom,0);f?A=v-2*($!==0||F!==0?$+F:Gt(d.left,d.right)):E=g-2*(V!==0||X!==0?V+X:Gt(d.top,d.bottom))}await l({...t,availableWidth:A,availableHeight:E});const R=await i.getDimensions(a.floating);return v!==R.width||g!==R.height?{reset:{rects:!0}}:{}}}};function os(){return typeof window<"u"}function Tr(e){return od(e)?(e.nodeName||"").toLowerCase():"#document"}function Yt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function bn(e){var t;return(t=(od(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function od(e){return os()?e instanceof Node||e instanceof Yt(e).Node:!1}function ln(e){return os()?e instanceof Element||e instanceof Yt(e).Element:!1}function yn(e){return os()?e instanceof HTMLElement||e instanceof Yt(e).HTMLElement:!1}function sd(e){return!os()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Yt(e).ShadowRoot}const gb=new Set(["inline","contents"]);function oo(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=cn(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!gb.has(o)}const xb=new Set(["table","td","th"]);function vb(e){return xb.has(Tr(e))}const wb=[":popover-open",":modal"];function ss(e){return wb.some(t=>{try{return e.matches(t)}catch{return!1}})}const bb=["transform","translate","scale","rotate","perspective"],yb=["transform","translate","scale","rotate","perspective","filter"],Sb=["paint","layout","strict","content"];function Zi(e){const t=Qi(),n=ln(e)?cn(e):e;return bb.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)||yb.some(r=>(n.willChange||"").includes(r))||Sb.some(r=>(n.contain||"").includes(r))}function Cb(e){let t=$n(e);for(;yn(t)&&!kr(t);){if(Zi(t))return t;if(ss(t))return null;t=$n(t)}return null}function Qi(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Tb=new Set(["html","body","#document"]);function kr(e){return Tb.has(Tr(e))}function cn(e){return Yt(e).getComputedStyle(e)}function is(e){return ln(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function $n(e){if(Tr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||sd(e)&&e.host||bn(e);return sd(t)?t.host:t}function id(e){const t=$n(e);return kr(t)?e.ownerDocument?e.ownerDocument.body:e.body:yn(t)&&oo(t)?t:id(t)}function so(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=id(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Yt(o);if(s){const a=ea(i);return t.concat(i,i.visualViewport||[],oo(o)?o:[],a&&n?so(a):[])}return t.concat(o,so(o,[],n))}function ea(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function ad(e){const t=cn(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=es(n)!==s||es(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function ta(e){return ln(e)?e:e.contextElement}function Er(e){const t=ta(e);if(!yn(t))return vn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=ad(t);let i=(s?es(n.width):n.width)/r,a=(s?es(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const kb=vn(0);function ld(e){const t=Yt(e);return!Qi()||!t.visualViewport?kb:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Eb(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Yt(e)?!1:t}function Qn(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=ta(e);let i=vn(1);t&&(r?ln(r)&&(i=Er(r)):i=Er(e));const a=Eb(s,n,r)?ld(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=Yt(s),f=r&&ln(r)?Yt(r):r;let v=m,g=ea(v);for(;g&&r&&f!==v;){const x=Er(g),y=g.getBoundingClientRect(),b=cn(g),C=y.left+(g.clientLeft+parseFloat(b.paddingLeft))*x.x,k=y.top+(g.clientTop+parseFloat(b.paddingTop))*x.y;l*=x.x,c*=x.y,d*=x.x,h*=x.y,l+=C,c+=k,v=Yt(g),g=ea(v)}}return rs({width:d,height:h,x:l,y:c})}function as(e,t){const n=is(e).scrollLeft;return t?t.left+n:Qn(bn(e)).left+n}function cd(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-as(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function Ib(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=bn(r),a=t?ss(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)&&((Tr(r)!=="body"||oo(i))&&(l=is(r)),yn(r))){const f=Qn(r);c=Er(r),d.x=f.x+r.clientLeft,d.y=f.y+r.clientTop}const m=i&&!h&&!s?cd(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 Nb(e){return Array.from(e.getClientRects())}function Ab(e){const t=bn(e),n=is(e),r=e.ownerDocument.body,o=Gt(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Gt(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+as(e);const a=-n.scrollTop;return cn(r).direction==="rtl"&&(i+=Gt(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const ud=25;function jb(e,t){const n=Yt(e),r=bn(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=Qi();(!d||d&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}const c=as(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<=ud&&(s-=v)}else c<=ud&&(s+=c);return{width:s,height:i,x:a,y:l}}const Pb=new Set(["absolute","fixed"]);function _b(e,t){const n=Qn(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=yn(e)?Er(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 dd(e,t,n){let r;if(t==="viewport")r=jb(e,n);else if(t==="document")r=Ab(bn(e));else if(ln(t))r=_b(t,n);else{const o=ld(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return rs(r)}function fd(e,t){const n=$n(e);return n===t||!ln(n)||kr(n)?!1:cn(n).position==="fixed"||fd(n,t)}function Rb(e,t){const n=t.get(e);if(n)return n;let r=so(e,[],!1).filter(a=>ln(a)&&Tr(a)!=="body"),o=null;const s=cn(e).position==="fixed";let i=s?$n(e):e;for(;ln(i)&&!kr(i);){const a=cn(i),l=Zi(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&Pb.has(o.position)||oo(i)&&!l&&fd(e,i))?r=r.filter(d=>d!==i):o=a,i=$n(i)}return t.set(e,r),r}function Mb(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?ss(t)?[]:Rb(t,this._c):[].concat(n),r],a=i[0],l=i.reduce((c,d)=>{const h=dd(t,d,o);return c.top=Gt(h.top,c.top),c.right=Ln(h.right,c.right),c.bottom=Ln(h.bottom,c.bottom),c.left=Gt(h.left,c.left),c},dd(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function Ob(e){const{width:t,height:n}=ad(e);return{width:t,height:n}}function Db(e,t,n){const r=yn(t),o=bn(t),s=n==="fixed",i=Qn(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=vn(0);function c(){l.x=as(o)}if(r||!r&&!s)if((Tr(t)!=="body"||oo(o))&&(a=is(t)),r){const f=Qn(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?cd(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 na(e){return cn(e).position==="static"}function hd(e,t){if(!yn(e)||cn(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return bn(e)===n&&(n=n.ownerDocument.body),n}function pd(e,t){const n=Yt(e);if(ss(e))return n;if(!yn(e)){let o=$n(e);for(;o&&!kr(o);){if(ln(o)&&!na(o))return o;o=$n(o)}return n}let r=hd(e,t);for(;r&&vb(r)&&na(r);)r=hd(r,t);return r&&kr(r)&&na(r)&&!Zi(r)?n:r||Cb(e)||n}const Lb=async function(e){const t=this.getOffsetParent||pd,n=this.getDimensions,r=await n(e.floating);return{reference:Db(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function $b(e){return cn(e).direction==="rtl"}const Fb={convertOffsetParentRelativeRectToViewportRelativeRect:Ib,getDocumentElement:bn,getClippingRect:Mb,getOffsetParent:pd,getElementRects:Lb,getClientRects:Nb,getDimensions:Ob,getScale:Er,isElement:ln,isRTL:$b};function md(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Bb(e,t){let n=null,r;const o=bn(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=ts(h),g=ts(o.clientWidth-(d+m)),x=ts(o.clientHeight-(h+f)),y=ts(d),C={rootMargin:-v+"px "+-g+"px "+-x+"px "+-y+"px",threshold:Gt(0,Ln(1,l))||1};let k=!0;function S(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&&!md(c,e.getBoundingClientRect())&&i(),k=!1}try{n=new IntersectionObserver(S,{...C,root:o.ownerDocument})}catch{n=new IntersectionObserver(S,C)}n.observe(e)}return i(!0),s}function zb(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=ta(e),d=o||s?[...c?so(c):[],...so(t)]:[];d.forEach(y=>{o&&y.addEventListener("scroll",n,{passive:!0}),s&&y.addEventListener("resize",n)});const h=c&&a?Bb(c,n):null;let m=-1,f=null;i&&(f=new ResizeObserver(y=>{let[b]=y;b&&b.target===c&&f&&(f.unobserve(t),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var C;(C=f)==null||C.observe(t)})),n()}),c&&!l&&f.observe(c),f.observe(t));let v,g=l?Qn(e):null;l&&x();function x(){const y=Qn(e);g&&!md(g,y)&&n(),g=y,v=requestAnimationFrame(x)}return n(),()=>{var y;d.forEach(b=>{o&&b.removeEventListener("scroll",n),s&&b.removeEventListener("resize",n)}),h==null||h(),(y=f)==null||y.disconnect(),f=null,l&&cancelAnimationFrame(v)}}const Hb=fb,Ub=hb,Wb=cb,Vb=mb,Kb=ub,gd=lb,qb=pb,Gb=(e,t,n)=>{const r=new Map,o={platform:Fb,...n},s={...o.platform,_c:r};return ab(e,t,{...o,platform:s})};var Yb=typeof document<"u",Xb=function(){},ls=Yb?w.useLayoutEffect:Xb;function cs(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(!cs(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)&&!cs(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function xd(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function vd(e,t){const n=xd(e);return Math.round(t*n)/n}function ra(e){const t=p.useRef(e);return ls(()=>{t.current=e}),t}function Jb(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);cs(m,r)||f(r);const[v,g]=p.useState(null),[x,y]=p.useState(null),b=p.useCallback(D=>{D!==T.current&&(T.current=D,g(D))},[]),C=p.useCallback(D=>{D!==E.current&&(E.current=D,y(D))},[]),k=s||v,S=i||x,T=p.useRef(null),E=p.useRef(null),A=p.useRef(d),R=l!=null,$=ra(l),F=ra(o),V=ra(c),X=p.useCallback(()=>{if(!T.current||!E.current)return;const D={placement:t,strategy:n,middleware:m};F.current&&(D.platform=F.current),Gb(T.current,E.current,D).then(I=>{const Y={...I,isPositioned:V.current!==!1};_.current&&!cs(A.current,Y)&&(A.current=Y,Ur.flushSync(()=>{h(Y)}))})},[m,t,n,F,V]);ls(()=>{c===!1&&A.current.isPositioned&&(A.current.isPositioned=!1,h(D=>({...D,isPositioned:!1})))},[c]);const _=p.useRef(!1);ls(()=>(_.current=!0,()=>{_.current=!1}),[]),ls(()=>{if(k&&(T.current=k),S&&(E.current=S),k&&S){if($.current)return $.current(k,S,X);X()}},[k,S,X,$,R]);const G=p.useMemo(()=>({reference:T,floating:E,setReference:b,setFloating:C}),[b,C]),H=p.useMemo(()=>({reference:k,floating:S}),[k,S]),z=p.useMemo(()=>{const D={position:n,left:0,top:0};if(!H.floating)return D;const I=vd(H.floating,d.x),Y=vd(H.floating,d.y);return a?{...D,transform:"translate("+I+"px, "+Y+"px)",...xd(H.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:I,top:Y}},[n,a,H.floating,d.x,d.y]);return p.useMemo(()=>({...d,update:X,refs:G,elements:H,floatingStyles:z}),[d,X,G,H,z])}const Zb=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?gd({element:r.current,padding:o}).fn(n):{}:r?gd({element:r,padding:o}).fn(n):{}}}},Qb=(e,t)=>({...Hb(e),options:[e,t]}),ey=(e,t)=>({...Ub(e),options:[e,t]}),ty=(e,t)=>({...qb(e),options:[e,t]}),ny=(e,t)=>({...Wb(e),options:[e,t]}),ry=(e,t)=>({...Vb(e),options:[e,t]}),oy=(e,t)=>({...Kb(e),options:[e,t]}),sy=(e,t)=>({...Zb(e),options:[e,t]});var iy="Arrow",wd=p.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return u.jsx(me.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"})})});wd.displayName=iy;var ay=wd;function bd(e){const[t,n]=p.useState(void 0);return kt(()=>{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 oa="Popper",[yd,Ir]=an(oa),[ly,Sd]=yd(oa),Cd=e=>{const{__scopePopper:t,children:n}=e,[r,o]=p.useState(null);return u.jsx(ly,{scope:t,anchor:r,onAnchorChange:o,children:n})};Cd.displayName=oa;var Td="PopperAnchor",kd=p.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=Sd(Td,n),i=p.useRef(null),a=_e(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(me.div,{...o,ref:a})});kd.displayName=Td;var sa="PopperContent",[cy,uy]=yd(sa),Ed=p.forwardRef((e,t)=>{var M,L,q,Z,se,ie;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=Sd(sa,n),[y,b]=p.useState(null),C=_e(t,re=>b(re)),[k,S]=p.useState(null),T=bd(k),E=(T==null?void 0:T.width)??0,A=(T==null?void 0:T.height)??0,R=r+(s!=="center"?"-"+s:""),$=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},F=Array.isArray(c)?c:[c],V=F.length>0,X={padding:$,boundary:F.filter(fy),altBoundary:V},{refs:_,floatingStyles:G,placement:H,isPositioned:z,middlewareData:D}=Jb({strategy:"fixed",placement:R,whileElementsMounted:(...re)=>zb(...re,{animationFrame:f==="always"}),elements:{reference:x.anchor},middleware:[Qb({mainAxis:o+A,alignmentAxis:i}),l&&ey({mainAxis:!0,crossAxis:!1,limiter:h==="partial"?ty():void 0,...X}),l&&ny({...X}),ry({...X,apply:({elements:re,rects:de,availableWidth:be,availableHeight:Me})=>{const{width:Fe,height:De}=de.reference,Le=re.floating.style;Le.setProperty("--radix-popper-available-width",`${be}px`),Le.setProperty("--radix-popper-available-height",`${Me}px`),Le.setProperty("--radix-popper-anchor-width",`${Fe}px`),Le.setProperty("--radix-popper-anchor-height",`${De}px`)}}),k&&sy({element:k,padding:a}),hy({arrowWidth:E,arrowHeight:A}),m&&oy({strategy:"referenceHidden",...X})]}),[I,Y]=Ad(H),J=pt(v);kt(()=>{z&&(J==null||J())},[z,J]);const j=(M=D.arrow)==null?void 0:M.x,B=(L=D.arrow)==null?void 0:L.y,P=((q=D.arrow)==null?void 0:q.centerOffset)!==0,[O,K]=p.useState();return kt(()=>{y&&K(window.getComputedStyle(y).zIndex)},[y]),u.jsx("div",{ref:_.setFloating,"data-radix-popper-content-wrapper":"",style:{...G,transform:z?G.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:O,"--radix-popper-transform-origin":[(Z=D.transformOrigin)==null?void 0:Z.x,(se=D.transformOrigin)==null?void 0:se.y].join(" "),...((ie=D.hide)==null?void 0:ie.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:u.jsx(cy,{scope:n,placedSide:I,onArrowChange:S,arrowX:j,arrowY:B,shouldHideArrow:P,children:u.jsx(me.div,{"data-side":I,"data-align":Y,...g,ref:C,style:{...g.style,animation:z?void 0:"none"}})})})});Ed.displayName=sa;var Id="PopperArrow",dy={top:"bottom",right:"left",bottom:"top",left:"right"},Nd=p.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=uy(Id,r),i=dy[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(ay,{...o,ref:n,style:{...o.style,display:"block"}})})});Nd.displayName=Id;function fy(e){return e!==null}var hy=e=>({name:"transformOrigin",options:e,fn(t){var x,y,b;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]=Ad(n),h={start:"0%",center:"50%",end:"100%"}[d],m=(((y=o.arrow)==null?void 0:y.x)??0)+a/2,f=(((b=o.arrow)==null?void 0:b.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 Ad(e){const[t,n="center"]=e.split("-");return[t,n]}var ia=Cd,aa=kd,la=Ed,ca=Nd,py="Portal",io=p.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=p.useState(!1);kt(()=>s(!0),[]);const i=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?Mo.createPortal(u.jsx(me.div,{...r,ref:t}),i):null});io.displayName=py;function my(e,t){return p.useReducer((n,r)=>t[n][r]??n,e)}var Bt=e=>{const{present:t,children:n}=e,r=gy(t),o=typeof n=="function"?n({present:r.isPresent}):p.Children.only(n),s=_e(r.ref,xy(o));return typeof n=="function"||r.isPresent?p.cloneElement(o,{ref:s}):null};Bt.displayName="Presence";function gy(e){const[t,n]=p.useState(),r=p.useRef(null),o=p.useRef(e),s=p.useRef("none"),i=e?"mounted":"unmounted",[a,l]=my(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return p.useEffect(()=>{const c=us(r.current);s.current=a==="mounted"?c:"none"},[a]),kt(()=>{const c=r.current,d=o.current;if(d!==e){const m=s.current,f=us(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]),kt(()=>{if(t){let c;const d=t.ownerDocument.defaultView??window,h=f=>{const g=us(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=us(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 us(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 ua="rovingFocusGroup.onEntryFocus",vy={bubbles:!1,cancelable:!0},ao="RovingFocusGroup",[da,jd,wy]=Jo(ao),[by,Pd]=an(ao,[wy]),[yy,Sy]=by(ao),_d=p.forwardRef((e,t)=>u.jsx(da.Provider,{scope:e.__scopeRovingFocusGroup,children:u.jsx(da.Slot,{scope:e.__scopeRovingFocusGroup,children:u.jsx(Cy,{...e,ref:t})})}));_d.displayName=ao;var Cy=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=_e(t,m),v=Zo(s),[g,x]=On({prop:i,defaultProp:a??null,onChange:l,caller:ao}),[y,b]=p.useState(!1),C=pt(c),k=jd(n),S=p.useRef(!1),[T,E]=p.useState(0);return p.useEffect(()=>{const A=m.current;if(A)return A.addEventListener(ua,C),()=>A.removeEventListener(ua,C)},[C]),u.jsx(yy,{scope:n,orientation:r,dir:v,loop:o,currentTabStopId:g,onItemFocus:p.useCallback(A=>x(A),[x]),onItemShiftTab:p.useCallback(()=>b(!0),[]),onFocusableItemAdd:p.useCallback(()=>E(A=>A+1),[]),onFocusableItemRemove:p.useCallback(()=>E(A=>A-1),[]),children:u.jsx(me.div,{tabIndex:y||T===0?-1:0,"data-orientation":r,...h,ref:f,style:{outline:"none",...e.style},onMouseDown:ae(e.onMouseDown,()=>{S.current=!0}),onFocus:ae(e.onFocus,A=>{const R=!S.current;if(A.target===A.currentTarget&&R&&!y){const $=new CustomEvent(ua,vy);if(A.currentTarget.dispatchEvent($),!$.defaultPrevented){const F=k().filter(H=>H.focusable),V=F.find(H=>H.active),X=F.find(H=>H.id===g),G=[V,X,...F].filter(Boolean).map(H=>H.ref.current);Od(G,d)}}S.current=!1}),onBlur:ae(e.onBlur,()=>b(!1))})})}),Rd="RovingFocusGroupItem",Md=p.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,l=jt(),c=s||l,d=Sy(Rd,n),h=d.currentTabStopId===c,m=jd(n),{onFocusableItemAdd:f,onFocusableItemRemove:v,currentTabStopId:g}=d;return p.useEffect(()=>{if(r)return f(),()=>v()},[r,f,v]),u.jsx(da.ItemSlot,{scope:n,id:c,focusable:r,active:o,children:u.jsx(me.span,{tabIndex:h?0:-1,"data-orientation":d.orientation,...a,ref:t,onMouseDown:ae(e.onMouseDown,x=>{r?d.onItemFocus(c):x.preventDefault()}),onFocus:ae(e.onFocus,()=>d.onItemFocus(c)),onKeyDown:ae(e.onKeyDown,x=>{if(x.key==="Tab"&&x.shiftKey){d.onItemShiftTab();return}if(x.target!==x.currentTarget)return;const y=Ey(x,d.orientation,d.dir);if(y!==void 0){if(x.metaKey||x.ctrlKey||x.altKey||x.shiftKey)return;x.preventDefault();let C=m().filter(k=>k.focusable).map(k=>k.ref.current);if(y==="last")C.reverse();else if(y==="prev"||y==="next"){y==="prev"&&C.reverse();const k=C.indexOf(x.currentTarget);C=d.loop?Iy(C,k+1):C.slice(k+1)}setTimeout(()=>Od(C))}}),children:typeof i=="function"?i({isCurrentTabStop:h,hasTabStop:g!=null}):i})})});Md.displayName=Rd;var Ty={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function ky(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Ey(e,t,n){const r=ky(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return Ty[r]}function Od(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function Iy(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Ny=_d,Ay=Md,jy=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Nr=new WeakMap,ds=new WeakMap,fs={},fa=0,Dd=function(e){return e&&(e.host||Dd(e.parentNode))},Py=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=Dd(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})},_y=function(e,t,n,r){var o=Py(t,Array.isArray(e)?e:[e]);fs[n]||(fs[n]=new WeakMap);var s=fs[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=(Nr.get(m)||0)+1,x=(s.get(m)||0)+1;Nr.set(m,g),s.set(m,x),i.push(m),g===1&&v&&ds.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(),fa++,function(){i.forEach(function(h){var m=Nr.get(h)-1,f=s.get(h)-1;Nr.set(h,m),s.set(h,f),m||(ds.has(h)||h.removeAttribute(r),ds.delete(h)),f||h.removeAttribute(n)}),fa--,fa||(Nr=new WeakMap,Nr=new WeakMap,ds=new WeakMap,fs={})}},ha=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=jy(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),_y(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 Ld(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 Ry(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 hs="right-scroll-bar-position",ps="width-before-scroll-bar",My="with-scroll-bars-hidden",Oy="--removed-body-scroll-bar-size";function pa(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function Dy(e,t){var n=w.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 Ly=typeof window<"u"?p.useLayoutEffect:p.useEffect,$d=new WeakMap;function $y(e,t){var n=Dy(null,function(r){return e.forEach(function(o){return pa(o,r)})});return Ly(function(){var r=$d.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||pa(a,null)}),s.forEach(function(a){o.has(a)||pa(a,i)})}$d.set(n,e)},[e]),n}function Fy(e){return e}function By(e,t){t===void 0&&(t=Fy);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 zy(e){e===void 0&&(e={});var t=By(null);return t.options=Sn({async:!0,ssr:!1},e),t}var Fd=function(e){var t=e.sideCar,n=Ld(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))};Fd.isSideCarExport=!0;function Hy(e,t){return e.useMedium(t),Fd}var Bd=zy(),ma=function(){},ms=p.forwardRef(function(e,t){var n=p.useRef(null),r=p.useState({onScrollCapture:ma,onWheelCapture:ma,onTouchMoveCapture:ma}),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,b=y===void 0?"div":y,C=e.gapMode,k=Ld(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),S=m,T=$y([n,t]),E=Sn(Sn({},k),o);return p.createElement(p.Fragment,null,d&&p.createElement(S,{sideCar:Bd,removeScrollBar:c,shards:h,noRelative:f,noIsolation:v,inert:g,setCallbacks:s,allowPinchZoom:!!x,lockRef:n,gapMode:C}),i?p.cloneElement(p.Children.only(a),Sn(Sn({},E),{ref:T})):p.createElement(b,Sn({},E,{className:l,ref:T}),a))});ms.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},ms.classNames={fullWidth:ps,zeroRight:hs};var Uy=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Wy(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Uy();return t&&e.setAttribute("nonce",t),e}function Vy(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Ky(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var qy=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Wy())&&(Vy(t,n),Ky(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Gy=function(){var e=qy();return function(t,n){p.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},zd=function(){var e=Gy(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},Yy={left:0,top:0,right:0,gap:0},ga=function(e){return parseInt(e||"",10)||0},Xy=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[ga(n),ga(r),ga(o)]},Jy=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Yy;var t=Xy(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])}},Zy=zd(),Ar="data-scroll-locked",Qy=function(e,t,n,r){var o=e.left,s=e.top,i=e.right,a=e.gap;return n===void 0&&(n="margin"),`
37
+ `))>=0;){const Ce=tt.slice(0,ue);tt=tt.slice(ue+2);const Ge=Ce.split(/\r?\n/),kt=[];for(const Re of Ge)if(!(!Re||Re.startsWith(":"))&&Re.startsWith("data:")){const ft=Re.slice(5);kt.push(ft.startsWith(" ")?ft.slice(1):ft)}const Ie=kt.join(`
38
+ `);if(!Ie)continue;let _e;try{_e=JSON.parse(Ie)}catch{console.debug("[use-chat] malformed SSE:",Ie.slice(0,200));continue}const Be=iu(_e)?_e.data:_e;if(!Be){console.warn("[use-chat] dropped envelope event without payload",_e);continue}const xe=Be;It=Date.now();const et=xe.seq;if(et!==void 0){if(et<=gt){console.debug("[use-chat] drop duplicate/out-of-order event",{seq:et,lastProcessedSeq:gt,type:xe.type});continue}gt>0&&et>gt+1&&((oe=I==null?void 0:I.onGap)==null||oe.call(I,{from:gt,to:et})),gt=et,E.current=et,x(et)}if(xe.type==="message.start"&&xe.role==="assistant"){const Re=du(xe.model);U.current={messageId:xe.id,lastSeq:et??null,lastText:""},k({id:xe.id,role:"assistant",name:Re??void 0,model:xe.model,createdAt:new Date().toISOString(),content:[]})}if(xe.type==="checkpoint")_.current=xe.checkpointId??null,$.current=xe.checkpointNs??null,v(xe.checkpointId??null);else if(xe.type==="state_history"){F.current=xe;try{const ft=Yn(xe).latest;ft&&(_.current=ft.checkpointId??null,$.current=ft.checkpointNs??null,v(ft.checkpointId??null))}catch(Re){console.warn("[use-chat] Failed to hydrate state_history payload",Re)}}try{O==null||O(xe)}catch(Re){console.error("[use-chat] Error in onEvent callback:",Re,"for event:",xe.type)}if(xe.type==="message.delta"){k(ft=>{const In=U.current;if(!ft||In.messageId!==ft.id)return ft;const{newParts:N,newMeta:ee,changed:de}=cu(ft.content??[],xe.delta,{lastSeq:In.lastSeq,lastText:In.lastText},et??null);return de?(U.current={...In,lastSeq:ee.lastSeq??In.lastSeq,lastText:ee.lastText??In.lastText},{...ft,content:N}):ft});const Re=xe.delta.filter(ft=>ft.type==="text").map(ft=>ft.text).join("");Re&&e.autoAppendAssistant!==!1&&(st.push(Re),rn())}else if(xe.type==="heartbeat"){console.debug("[use-chat] heartbeat received");try{(se=I==null?void 0:I.onHeartbeat)==null||se.call(I,xe)}catch(Re){console.warn("[use-chat] heartbeat callback failed",Re)}}else if(St!==null&&cancelAnimationFrame(St),xt(),xe.type==="checkpoint")v(xe.checkpointId);else if(xe.type==="error"){const Re=xe;if(d(Re.message),J="error",P=Re.message,Re.error_type==="auth_error"||Re.code==="TOKEN_EXPIRED"||((ie=Re.message)==null?void 0:ie.includes("token"))||((le=Re.message)==null?void 0:le.includes("401"))||((ye=Re.message)==null?void 0:ye.includes("unauthorized"))||((De=Re.message)==null?void 0:De.includes("Unauthorized"))){console.error("[use-chat] Auth error detected:",Re.message);try{(We=I==null?void 0:I.onAuthError)==null||We.call(I,Re.message)}catch(In){console.warn("[use-chat] onAuthError handler failed",In)}G.abort()}}}}xt(),J===null&&!G.signal.aborted&&(J="complete")}catch(Ue){if(Ue.name==="AbortError")J=J??"aborted";else{const Fe=Ue.message||String(Ue);J="error",P=Fe,d(Fe),(Pe=I==null?void 0:I.onError)==null||Pe.call(I,Fe)}}finally{try{await dt.cancel()}catch{}finally{($e=dt.releaseLock)==null||$e.call(dt)}St!==null&&typeof window<"u"&&window.cancelAnimationFrame(St),clearInterval(mn)}}catch(qe){if(qe.name==="AbortError")J=J??"aborted";else{const Xe=qe.message||String(qe);J="error",P=Xe,d(Xe),(lt=I==null?void 0:I.onError)==null||lt.call(I,Xe),B||((ut=I==null?void 0:I.onConnectionError)==null||ut.call(I,Xe),B=!0)}}finally{const qe=E.current,Xe=_.current,Ve=$.current,Le=F.current,Ae=J??(G.signal.aborted?"aborted":P?"error":"complete");try{(yt=I==null?void 0:I.onClosed)==null||yt.call(I,{reason:Ae,lastSeq:qe,lastCheckpointId:Xe,lastCheckpointNs:Ve,lastStateHistory:Le,error:P})}catch(dt){console.warn("[use-chat] onClosed callback failed",dt)}l(!1),b(!1),S.current=null,E.current=0,x(0),j.current=null}})(),{close:()=>G.abort()}},[t,n,r,e.autoAppendAssistant]);return w.useEffect(()=>()=>{var z;T.current=!1,(z=S.current)==null||z.abort()},[]),{isStreaming:a,error:c,assistantText:h,assistantMessage:C,lastCheckpointId:f,lastSeq:g,connected:y,stream:W,stop:K,clear:R,setToken:X}}const Yv=["detail","message","error","description","title"];function Yo(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=Yo(t);if(n)return n}return null}if(typeof e=="object"){const t=e;for(const n of Yv){const r=Yo(t[n]);if(r)return r}if("errors"in t){const n=Yo(t.errors);if(n)return n}}return null}function Xv(e){if(!e)return"Request failed";const t=e.response,n=Yo(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 fu({api:e,initialThreadId:t=null,onError:n,onThreadChange:r,onCurrentThreadDeleted:o}){const[s,i]=w.useState([]),[a,l]=w.useState(t),[c,d]=w.useState(!1),[h,m]=w.useState(null),[f,v]=w.useState([]),[g,x]=w.useState(!1),[,y]=w.useState(null),[b,C]=w.useState(null),[k,S]=w.useState(!1),T=w.useRef(a),E=w.useRef(new Map);w.useEffect(()=>{T.current=a},[a]);const j=w.useCallback(async()=>{d(!0),m(null);try{const O=await e.listThreads();i(O??[])}catch(O){const I=String(O);m(I),n==null||n(I)}finally{d(!1)}},[e,n]),_=w.useCallback(async()=>{x(!0),y(null);try{const O=await e.listSharedThreads();v(O??[])}catch(O){const I=String(O);y(I),n==null||n(I)}finally{x(!1)}},[e,n]);w.useEffect(()=>{j()},[j]),w.useEffect(()=>{_()},[_]),w.useEffect(()=>{r==null||r(a)},[a,r]);const $=w.useCallback(async O=>{try{const I=await e.createThread(O);return l(I.threadId),await j(),I.threadId}catch(I){const G=String(I);return n==null||n(G),null}},[e,n,j]),F=w.useCallback(async O=>{const I=s;i(J=>J.filter(P=>P.threadId!==O));const G=new AbortController;E.current.set(O,G);try{await e.deleteThread(O),T.current===O&&(l(null),o==null||o())}catch(J){i(I);const P=String(J);n==null||n(P)}finally{E.current.delete(O)}},[e,o,n,s]),U=w.useCallback(async(O,I)=>{try{await e.updateThread(O,I),await j()}catch(G){n==null||n(String(G))}},[e,n,j]),X=w.useCallback(async(O,I)=>{S(!0),C("Sharing thread…");try{await e.shareThread(O,I),await _(),C("Shared successfully")}catch(G){const J=Xv(G);throw n==null||n(J),C(`Failed to share: ${J}`),new Error(J)}finally{S(!1)}},[e,n,_]),R=w.useCallback(async(O,I)=>{try{await e.unshareThread(O,I),await _()}catch(G){const J=String(G);throw n==null||n(J),G}},[e,n,_]),K=w.useMemo(()=>({createThread:$,deleteThread:F,renameThread:U,refreshThreads:j,refreshSharedThreads:_,shareThread:X,unshareThread:R}),[$,F,U,j,_,X,R]),W=w.useCallback(O=>{if(!(O!=null&&O.threadId))return;const I={threadId:O.threadId,title:O.title||`Thread ${O.threadId.slice(0,8)}`,createdAt:O.createdAt||new Date().toISOString(),updatedAt:O.updatedAt||new Date().toISOString(),messageCount:O.messageCount??1};i(G=>{let J=!1;const P=G.map(B=>B.threadId===I.threadId?(J=!0,console.debug("[useThreadsState] thread_info: updating existing thread",I.threadId),{...B,title:I.title??B.title,updatedAt:I.updatedAt??B.updatedAt,messageCount:I.messageCount??B.messageCount}):B);return J?P:(console.debug("[useThreadsState] thread_info: adding thread to list",I.threadId),[I,...G])})},[]),z=w.useCallback(()=>C(null),[]);return{threads:s,currentThreadId:a,currentThreadIdRef:T,setCurrentThreadId:l,isLoadingThreads:c,threadsError:h,sharedThreads:f,isLoadingSharedThreads:g,actions:K,addThreadFromEvent:W,shareInFlight:k,shareStatus:b,clearShareStatus:z}}const hu=w.createContext(null);function pu({children:e,initialThreadId:t=null,onError:n,onThreadChange:r}){const{api:o}=Jr(),{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}=fu({api:o,initialThreadId:t,onError:n,onThreadChange:r}),b=w.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(hu.Provider,{value:b,children:e})}function xr(){const e=w.useContext(hu);if(!e)throw new Error("useThreads must be used within a ThreadsProvider");return e}function Qr(e){const t=e==null?void 0:e.trim();if(!t||!(t.startsWith("{")||t.startsWith("[")))return null;try{return JSON.parse(t)}catch{const n=Jv(t);if(n)try{return JSON.parse(n)}catch{return null}return null}}function Jv(e){let t=!1,n="";for(const o of e){if(o==="\\"){n+=o,t=!t;continue}if(o==="'"&&!t){n+='"';continue}n+=o,t=!1}return n.replace(/\bTrue\b/g,"true").replace(/\bFalse\b/g,"false").replace(/\bNone\b/g,"null")}function mu(e){return!!(e&&typeof e=="object"&&(e.type==="file"||e.mimeType||e.filename||e.sourceType==="base64"))}function eo(e){if(typeof e=="string")return e;if(e&&typeof e=="object"){if(Array.isArray(e)){const n=e.map(eo).filter(r=>r!==void 0);if(!n.length){console.debug("[message-utils] sanitizeForDisplay - array emptied -> returning undefined",{originalLength:e.length});return}return n}if(mu(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=eo(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(mu(e))return"";try{const t=eo(e);return t===void 0?"":typeof t=="string"?t:JSON.stringify(t,null,2)}catch{return""}}function Zv(e){return typeof e!="string"?!1:/^[\s\n]*[-*]\s|^[\s\n]*#+\s|```|^\s*\[.*\]\(|^>\s/.test(e)}function Qv(e){const t=vr(e);return typeof e=="string"&&Zv(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=Qr(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 ew(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function Di(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 Xo(e){if(e==null)return null;const t=String(e).trim();return t.length>0?t:null}function tw(e){const t=r=>{try{const o=eo(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 nw(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function gu(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 rw(e){if(!e)return"image/png";const t=e.trim();return t?t.includes("/")?t:`image/${t}`:"image/png"}function ow(e){const t=[],n=r=>{r&&r.trim()&&t.push(r.trim())};return e&&(n(e.plotId),n(e.artifactId)),t}function sw({base64:e,url:t,formatHint:n,extras:r}){const o=typeof e=="string"&&e.length>0,s=rw(n),i=o?`data:${s};base64,${e}`:t,a=ow(r),l=a.length?a.join(" / "):void 0,c=l?`${l} artifact`:"artifact image";return{src:i,alt:c,label:l}}function iw(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 sw({base64:t,url:n,formatHint:r,extras:{plotId:e.plotId,artifactId:e.artifactId}})}function xu(e){var n;const t=(n=e.additionalKwargs)==null?void 0:n.toolProgress;return Array.isArray(t)?t:[]}const aw={messages:[],assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,messagesStreamMeta:{},pendingInterrupt:null};function lw(e,t){var n;switch(t.type){case"reset":return{messages:Oi(((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=Oi(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=Oi(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 vu(e,t.payload.ev);case"batch":{const{events:r}=t.payload;return r.length?r.reduce((o,s)=>vu(o,s),e):e}default:return e}}function cw(e=[]){const[t,n]=w.useReducer(lw,{...aw,messages:e}),r=w.useRef([]),o=w.useRef(null),s=w.useRef(null),i=w.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=w.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=w.useCallback(d=>{r.current.push(d),a()},[a]);w.useEffect(()=>()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),r.current=[]},[]);const c=w.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 vu(e,t){var n,r,o;if(t.type==="message.start"&&t.role==="assistant"){const s=t.id,i=du(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 dw(e,t);if(t.type==="tool.progress")return fw(e,t);if(t.type==="tool.end")return hw(e,t);if(t.type==="message.delta"){const s=e.assemblingId??au(e.messages);if(!s)return e;const i=e.messages,a=i.findIndex(S=>S.id===s&&S.role==="assistant");if(a===-1)return e;const l=i[a],c=e.messagesStreamMeta,d=c??{},h=d[s],m=h??{lastSeq:null,lastText:lu(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}=cu(l.content,t.delta,m,f);if(!x)return e;const y={...l,content:v},b=Zr(i,a,y),C=!h||h.lastSeq!==g.lastSeq||h.lastText!==g.lastText,k=C?{...d,[s]:g}:c;return C?{...e,messages:b,messagesStreamMeta:k}:{...e,messages:b}}if(t.type==="message.end"){const s=e.assemblingId??au(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=Yn(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 Li(e){return e.call_id??e.id??null}function wu(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 $i(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||Di(r).toolCallId===t)return n}return-1}function uw(e){if(e==null)return[];const t=wr(e);if(typeof t=="string"&&t.trim())return[{type:"text",text:t}];const n=vr(t??e);return n?[{type:"text",text:n}]:[]}function yu(e,t){const n=e.additionalKwargs??{},r=Array.isArray(n.toolProgress)?[...n.toolProgress]:[],o={...n,toolProgress:[...r,t]};return{...e,additionalKwargs:o}}function dw(e,t){const n=Li(t),r=$i(e.messages,n),o=t.name??t.tool??void 0,s=wu(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:Zr(e.messages,r,d)}}const i=bu(s,n,o,t.args);return{...e,messages:[...e.messages,i]}}function fw(e,t){const n=Li(t);if(!n)return e;const r=$i(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=yu(e.messages[r],o);return{...e,messages:Zr(e.messages,r,a)}}function hw(e,t){const n=Li(t),r=wu(t);let o=e.messages,s=$i(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=uw(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=yu(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:Zr(o,s,f)}}function Su({api:e,seed:t,onError:n,currentThreadId:r,initialThreadId:o=null,initialCheckpointId:s=null,initialCheckpointNs:i=null,autoLoadInitial:a=!0,isStreaming:l,getMessages:c}){const[d,h]=w.useState(null),f=w.useMemo(()=>Yn(d),[d]).checkpoints,v=nc(f),g=v.timeline,[x,y]=w.useState(!1),[b,C]=w.useState(!1),[k,S]=w.useState(null),T=w.useRef(r),E=w.useRef(null),j=w.useRef(null),_=w.useRef(null),$=w.useRef(null),F=w.useRef(null),U=w.useRef(new Map),X=w.useRef(null);w.useEffect(()=>{T.current=r},[r]);const R=w.useCallback(async A=>{var q,M;if(!A.threadId)return;const D=A.threadId;(q=A.onStart)==null||q.call(A),A.setLoading(!0);try{await A.action(D)}catch(L){if(!Kc(L)&&T.current===D){const Z=String(L);(M=A.handleError)==null||M.call(A,Z),n==null||n(Z)}throw L}finally{A.setLoading(!1)}},[n]),K=w.useCallback(async(A,D)=>{var Z;if(!A)return;const q=`${A}:${D??"latest"}`,M=U.current.get(q);if(M)return M;(Z=X.current)==null||Z.abort();const L=new AbortController;X.current=L;const Y=R({threadId:A,setLoading:y,onStart:()=>S(null),handleError:oe=>S(oe),action:async oe=>{const se=await e.getStateHistory({threadId:oe,checkpointId:D??void 0,signal:L.signal});if(T.current!==oe){console.log(`[useThreadHistoryState] Thread changed during load (was ${oe}, now ${T.current}), discarding stale data`);return}const{checkpoints:ie}=Yn(se),le=ie.find(ye=>ye.messages&&ye.messages.length>0)??(D?ie.find(ye=>ye.checkpointId===D):null)??ie[0];t((le==null?void 0:le.messages)??[],{checkpointId:(le==null?void 0:le.checkpointId)??null,checkpointNs:(le==null?void 0:le.checkpointNs)??null}),h(se)}});U.current.set(q,Y);try{await Y}finally{U.current.delete(q),X.current===L&&(X.current=null)}return T.current===A&&(F.current=q),Y},[e,t,R]),W=w.useCallback(async(A,D)=>{$.current=A;try{await K(A,D)}catch(q){if(!Kc(q))throw q}finally{$.current===A&&($.current=null)}},[K]),z=w.useCallback(A=>{j.current=A},[]),O=w.useCallback(A=>{_.current=A},[]),I=w.useCallback(A=>{const D=A.threadId??T.current;if(!D||T.current&&T.current!==D)return;const{checkpoints:q}=Yn(A);if(!q.length)return;const M=q.find(Y=>Y.messages&&Y.messages.length>0)??q.find(Y=>!!Y.checkpointId)??q[0],L=_.current===D;!l&&!L&&t((M==null?void 0:M.messages)??[],{checkpointId:(M==null?void 0:M.checkpointId)??null,checkpointNs:(M==null?void 0:M.checkpointNs)??null}),h(A),F.current=`${D}:latest`,j.current=null,_.current===D&&(_.current=null)},[t,l]),G=w.useCallback(async(A,D)=>{const q=T.current;await R({threadId:q,setLoading:C,action:async M=>{const L=await e.getStateHistory({threadId:M,checkpointId:A,checkpointNs:D??void 0});if(T.current!==M)return;const{checkpoints:Y}=Yn(L),Z=Y.find(oe=>oe.checkpointId===A&&(D?oe.checkpointNs===D:!0));if(!Z){console.warn("[useThreadHistoryState] Requested checkpoint not found:",{checkpointId:A,checkpointNs:D});return}h(L),t(Z.messages??[],{checkpointId:Z.checkpointId??null,checkpointNs:Z.checkpointNs??null})}}).catch(()=>{})},[e,t,R]),J=w.useCallback((A,D)=>{t(c(),{checkpointId:A??null,checkpointNs:D??null})},[c,t]),P=w.useCallback(async()=>{T.current&&await W(T.current)},[W]);w.useEffect(()=>{if(!a||!r||x||l)return;if(j.current===r){j.current=null,E.current=r;return}if(_.current===r){E.current=r;return}if($.current===r){$.current=null,E.current=r;return}if(E.current===r)return;E.current=r;let A;const D=`${r}:latest`;F.current!==D&&W(r,A)},[a,r,s,i,o,x,l,W]);const B=w.useCallback(()=>{h(null),y(!1),C(!1),S(null),j.current=null,_.current=null,E.current=null,F.current=null,$.current=null},[]);return{threadCheckpoints:f,threadTimeline:g,checkpointIndex:v,isLoadingThread:x,isLoadingCheckpoint:b,threadStateError:k,loadThread:W,navigateToCheckpoint:G,setCurrentCheckpointId:J,returnToLatest:P,handleStateHistoryEvent:I,markSkipNextLoad:z,markStreamPendingThread:O,resetHistoryState:B}}const Cu=w.createContext(null),Tu=w.createContext(null);function to(){const e=w.useContext(Cu);if(!e)throw new Error("useThreadState must be used within a ThreadStateProvider");return e}function ku(){const e=w.useContext(Tu);if(!e)throw new Error("useThreadStateUpdater must be used within a ThreadStateProvider");return e}function Eu({children:e,initialThreadId:t=null,initialCheckpointId:n=null,initialCheckpointNs:r=null,autoLoadInitial:o=!0,isStreaming:s,onError:i}){const{api:a}=Jr(),{currentThreadId:l}=xr(),{state:c,seed:d,pushUser:h,onEvent:m}=cw(),{threadCheckpoints:f,threadTimeline:v,checkpointIndex:g,isLoadingThread:x,isLoadingCheckpoint:y,threadStateError:b,loadThread:C,navigateToCheckpoint:k,setCurrentCheckpointId:S,returnToLatest:T,handleStateHistoryEvent:E,markSkipNextLoad:j,markStreamPendingThread:_,resetHistoryState:$}=Su({api:a,seed:d,onError:i,currentThreadId:l,initialThreadId:t,initialCheckpointId:n,initialCheckpointNs:r,autoLoadInitial:o,isStreaming:s,getMessages:w.useCallback(()=>c.messages,[c.messages])}),[F,U]=w.useState(()=>async()=>{throw new Error("clearThread is not ready")}),[X,R]=w.useState(()=>async()=>{throw new Error("respondToInterrupt is not ready")});w.useEffect(()=>{l||(d([],{}),$())},[l,d,$]);const K=w.useCallback(G=>U(()=>G),[]),W=w.useCallback(G=>R(()=>G),[]),z=w.useMemo(()=>({assemblingMessageId:c.assemblingId??null}),[c.assemblingId]),O=w.useMemo(()=>({threadId:l,messages:c.messages,interrupt:c.pendingInterrupt,checkpoint:{id:c.lastCheckpointId??null,namespace:c.lastCheckpointNs??null},checkpoints:f,checkpointIndex:g,timelineCheckpoints:v,metadata:z,isLoading:x,isLoadingCheckpoint:y,error:b,clearState:F,navigateToCheckpoint:k,setCurrentCheckpointId:S,returnToLatest:T,loadThread:C,clearThread:F,respondToInterrupt:X,messagePreviews:g.messagePreviews,handleStateHistoryEvent:E,markSkipNextLoad:j,markStreamPendingThread:_,resetHistoryState:$,pushUser:h,onEvent:m}),[l,c,f,v,g,z,x,y,b,F,k,S,T,C,X,g.messagePreviews,E,j,_,$,h,m]),I=w.useMemo(()=>({registerClearThread:K,registerRespondToInterrupt:W}),[K,W]);return u.jsx(Tu.Provider,{value:I,children:u.jsx(Cu.Provider,{value:O,children:e})})}function Iu(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 pw(e){const t=Iu(e,["checkpoint_id","checkpointId"]);if(!t)return null;const n=Iu(e,["checkpoint_ns","checkpointNs"]);return{checkpointId:t,checkpointNs:n}}function mw(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 gw(e,t){const n=[...e].sort(mw);for(const r of n){if(r.messageId!==t)continue;const o=pw(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 Nu=w.createContext(null),Au=w.createContext(!1);function xw({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}=Jr(),m=w.useMemo(()=>xn(h),[h]),{stream:f,stop:v,isStreaming:g,error:x,setToken:y}=Gv({baseUrl:m}),[b,C]=w.useState(!1);return w.useEffect(()=>{C(g)},[g]),u.jsx(pu,{initialThreadId:t,onError:s,onThreadChange:a,children:u.jsx(Eu,{initialThreadId:t,initialCheckpointId:n,initialCheckpointNs:r,autoLoadInitial:o,onError:s,isStreaming:b,children:u.jsx(Au.Provider,{value:!0,children:u.jsx(vw,{api:d,streamApi:{stream:f,stop:v,isStreaming:g,error:x,setToken:y},onError:s,onAuthError:i,onConnectionError:l,onToolEnd:c,children:e})})})})}function vw({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:b,markStreamPendingThread:C,resetHistoryState:k,pushUser:S,onEvent:T}=to(),{registerClearThread:E,registerRespondToInterrupt:j}=ku(),_=w.useCallback(z=>{v(z),f.current!==z.threadId&&((z.created??!f.current)&&b(z.threadId),C(z.threadId),m(z.threadId))},[v,b,C,m,f]),$=w.useCallback(z=>{z.type==="thread_info"?_(z):z.type==="state_history"?y(z):z.type==="tool.end"?i==null||i(z):T(z)},[_,y,T,i]),F=w.useCallback(z=>{a(z,$,{onError:O=>{console.error("[StreamingProvider] Stream error:",O),r==null||r(O)},onAuthError:O=>{console.error("[StreamingProvider] Auth error:",O),o==null||o(O)},onConnectionError:O=>{console.error("[StreamingProvider] Connection error:",O),s==null||s(O)}})},[a,$,r,o,s]),U=w.useRef(g);w.useEffect(()=>{U.current=g},[g]);const X=w.useCallback(async(z,O,I)=>{const G=f.current;if(!G)throw new Error("No active thread to handle interrupt");const J=O?I??!0:!1,P=U.current,B={threadId:G,checkpointId:P.id??void 0,checkpointNs:P.namespace??void 0,command:{kind:"resume",value:J}};F(B)},[f,F]);w.useEffect(()=>{j(X)},[X,j]);const R=w.useCallback(async()=>{l(),k(),m(null)},[k,m,l]);w.useEffect(()=>{E(R)},[R,E]);const K=w.useCallback(async(z,O)=>{let I=f.current;const G=(z==null?void 0:z.text)??"",J=(z==null?void 0:z.attachments)??[],P=(G==null?void 0:G.trim())??"",B={...(z==null?void 0:z.payload)??{}},A=Array.isArray(B.messages)?B.messages:void 0;A&&delete B.messages;const D=!!(A&&A.length);if(!I&&!P&&J.length===0&&!D)return;if(!I){const Pe=Math.floor(Date.now()/1e3).toString(16).padStart(8,"0"),$e=Array.from({length:4},()=>Math.floor(Math.random()*4294967295).toString(16).padStart(8,"0")).join("").slice(0,16);I=`${Pe}${$e}`,b(I),m(I)}const{contentParts:q,filesInfo:M}=await su(J),L=[...q];P&&L.push({type:"text",text:G});const Y=O==null?void 0:O.originalMessageId,Z=!!(O!=null&&O.edit&&Y),oe=!D&&L.length>0;let se=null;oe&&(se={id:Z?Y:`msg-${Date.now()}`,role:"user",content:L,createdAt:new Date().toISOString()},Z?S(se,Y):S(se));const ie=D?A:se?[se]:[],le={...B,...M.length?{files_info:M}:{}};ie.length?le.messages=ie:"messages"in le||(le.messages=[]);let ye=(O==null?void 0:O.checkpointId)??g.id??void 0,De=(O==null?void 0:O.checkpointNs)??g.namespace??void 0;if(Z&&Y){const Pe=gw(x,Y);ye=Pe.checkpointId,De=Pe.checkpointNs??void 0}const We={threadId:I,payload:le,checkpointId:ye,checkpointNs:De,edit:!!(O!=null&&O.edit)};F(We)},[g,f,b,S,F,x]),W=w.useMemo(()=>({isStreaming:c,error:d,connectionState:c?"connected":"idle",submit:K,send:K,stop:l,setAuthToken:h}),[c,d,K,l,h]);return u.jsx(Nu.Provider,{value:W,children:e})}function Fi(){const e=w.useContext(Nu);if(!e)throw new Error("useStream must be used within StreamingProvider");return e}function ww(){return w.useContext(Au)}function ju(e){return typeof e=="object"&&e!==null}function bw(e,t){if(Object.is(e,t))return!0;if(!ju(e)||!ju(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 Pu(e){const t=w.useRef(e),n=w.useRef(e);return bw(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=Pu(t),m=no(a),f=no(l),v=no(i),g=no(c),x=no(d),y=w.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(ru,{apiConfig:h,children:u.jsx(xw,{...y,children:e})})}function no(e){const t=w.useRef(e);return w.useEffect(()=>{t.current=e},[e]),w.useCallback((...n)=>{const r=t.current;if(r)return r(...n)},[])}function yr(e){if(!(typeof globalThis>"u"))return globalThis[e]}function yw(e){if(typeof e!="string")return;const t=e.trim();if(t)return xn(t)}function _u(){const e=[yr("__API_BASE_URL__"),yr("__CHAT_API_BASE_URL__"),yr("__CHAT_API_URL__")];for(const t of e){const n=yw(t);if(n)return n}}function Ru(){const e=[yr("__API_AUTH_TOKEN__"),yr("__CHAT_API_KEY__"),yr("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function Mu(...e){for(const t of e)if(typeof t=="string"&&t.trim())return xn(t);return xn()}function Ou(){const e={},t=_u(),n=Ru();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function Du(){const e=Ou(),t=Nn.getAuthToken(),n=_u();return{apiBaseUrl:Mu(e.baseUrl,Nn.baseUrl,n),apiKey:t||e.apiKey||Ru()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,darkMode:!1,enableSound:!1,messageHistory:100}}const Bi="chat-settings";function Lu(){try{const e=localStorage.getItem(Bi);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function $u(e){try{const t={...e,apiBaseUrl:xn(e.apiBaseUrl)};localStorage.setItem(Bi,JSON.stringify(t)),t.apiKey&&Nn.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function Sw(){const e=Du(),t=Lu(),n=Nn.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:Mu(Nn.baseUrl,r,e.apiBaseUrl)}}function Cw(e){Nn.updateConfig({baseUrl:e.apiBaseUrl,authToken:e.apiKey??void 0}),$u(e)}function te(...e){return sx.twMerge(ox.clsx(e))}const Tw=Hr.cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),Qe=p.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?Vt.Slot:"button";return u.jsx(i,{className:te(Tw({variant:t,size:n,className:e})),ref:s,...o})});Qe.displayName="Button";function ae(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 Fu(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Mn(...e){return t=>{let n=!1;const r=e.map(o=>{const s=Fu(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():Fu(e[o],null)}}}}function Me(...e){return p.useCallback(Mn(...e),e)}function kw(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 an(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,Ew(o,...t)]}function Ew(...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 Et=globalThis!=null&&globalThis.document?p.useLayoutEffect:()=>{},Iw=p[" useInsertionEffect ".trim().toString()]||Et;function On({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=Nw({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=Aw(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 Nw({defaultProp:e,onChange:t}){const[n,r]=p.useState(e),o=p.useRef(n),s=p.useRef(t);return Iw(()=>{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 Aw(e){return typeof e=="function"}var jw=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],me=jw.reduce((e,t)=>{const n=Vt.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 zi(e,t){e&&Ur.flushSync(()=>e.dispatchEvent(t))}function Jo(e){const t=e+"CollectionProvider",[n,r]=an(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=g=>{const{scope:x,children:y}=g,b=w.useRef(null),C=w.useRef(new Map).current;return u.jsx(o,{scope:x,itemMap:C,collectionRef:b,children:y})};i.displayName=t;const a=e+"CollectionSlot",l=Vt.createSlot(a),c=w.forwardRef((g,x)=>{const{scope:y,children:b}=g,C=s(a,y),k=Me(x,C.collectionRef);return u.jsx(l,{ref:k,children:b})});c.displayName=a;const d=e+"CollectionItemSlot",h="data-radix-collection-item",m=Vt.createSlot(d),f=w.forwardRef((g,x)=>{const{scope:y,children:b,...C}=g,k=w.useRef(null),S=Me(x,k),T=s(d,y);return w.useEffect(()=>(T.itemMap.set(k,{ref:k,...C}),()=>void T.itemMap.delete(k))),u.jsx(m,{[h]:"",ref:S,children:b})});f.displayName=d;function v(g){const x=s(e+"CollectionConsumer",g);return w.useCallback(()=>{const b=x.collectionRef.current;if(!b)return[];const C=Array.from(b.querySelectorAll(`[${h}]`));return Array.from(x.itemMap.values()).sort((T,E)=>C.indexOf(T.ref.current)-C.indexOf(E.ref.current))},[x.collectionRef,x.itemMap])}return[{Provider:i,Slot:c,ItemSlot:f},v,r]}var Pw=p.createContext(void 0);function Zo(e){const t=p.useContext(Pw);return e||t||"ltr"}function pt(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 _w(e,t=globalThis==null?void 0:globalThis.document){const n=pt(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 Rw="DismissableLayer",Hi="dismissableLayer.update",Mw="dismissableLayer.pointerDownOutside",Ow="dismissableLayer.focusOutside",Bu,zu=p.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Sr=p.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...l}=e,c=p.useContext(zu),[d,h]=p.useState(null),m=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,f]=p.useState({}),v=Me(t,E=>h(E)),g=Array.from(c.layers),[x]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),y=g.indexOf(x),b=d?g.indexOf(d):-1,C=c.layersWithOutsidePointerEventsDisabled.size>0,k=b>=y,S=Lw(E=>{const j=E.target,_=[...c.branches].some($=>$.contains(j));!k||_||(o==null||o(E),i==null||i(E),E.defaultPrevented||a==null||a())},m),T=$w(E=>{const j=E.target;[...c.branches].some($=>$.contains(j))||(s==null||s(E),i==null||i(E),E.defaultPrevented||a==null||a())},m);return _w(E=>{b===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&&(Bu=m.body.style.pointerEvents,m.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(d)),c.layers.add(d),Uu(),()=>{n&&c.layersWithOutsidePointerEventsDisabled.size===1&&(m.body.style.pointerEvents=Bu)}},[d,m,n,c]),p.useEffect(()=>()=>{d&&(c.layers.delete(d),c.layersWithOutsidePointerEventsDisabled.delete(d),Uu())},[d,c]),p.useEffect(()=>{const E=()=>f({});return document.addEventListener(Hi,E),()=>document.removeEventListener(Hi,E)},[]),u.jsx(me.div,{...l,ref:v,style:{pointerEvents:C?k?"auto":"none":void 0,...e.style},onFocusCapture:ae(e.onFocusCapture,T.onFocusCapture),onBlurCapture:ae(e.onBlurCapture,T.onBlurCapture),onPointerDownCapture:ae(e.onPointerDownCapture,S.onPointerDownCapture)})});Sr.displayName=Rw;var Dw="DismissableLayerBranch",Hu=p.forwardRef((e,t)=>{const n=p.useContext(zu),r=p.useRef(null),o=Me(t,r);return p.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),u.jsx(me.div,{...e,ref:o})});Hu.displayName=Dw;function Lw(e,t=globalThis==null?void 0:globalThis.document){const n=pt(e),r=p.useRef(!1),o=p.useRef(()=>{});return p.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){Wu(Mw,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 $w(e,t=globalThis==null?void 0:globalThis.document){const n=pt(e),r=p.useRef(!1);return p.useEffect(()=>{const o=s=>{s.target&&!r.current&&Wu(Ow,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 Uu(){const e=new CustomEvent(Hi);document.dispatchEvent(e)}function Wu(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?zi(o,s):o.dispatchEvent(s)}var Fw=Sr,Bw=Hu,Ui=0;function Wi(){p.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Vu()),document.body.insertAdjacentElement("beforeend",e[1]??Vu()),Ui++,()=>{Ui===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Ui--}},[])}function Vu(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var Vi="focusScope.autoFocusOnMount",Ki="focusScope.autoFocusOnUnmount",Ku={bubbles:!1,cancelable:!0},zw="FocusScope",Qo=p.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,l]=p.useState(null),c=pt(o),d=pt(s),h=p.useRef(null),m=Me(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(C){if(f.paused||!a)return;const k=C.target;a.contains(k)?h.current=k:Dn(h.current,{select:!0})},x=function(C){if(f.paused||!a)return;const k=C.relatedTarget;k!==null&&(a.contains(k)||Dn(h.current,{select:!0}))},y=function(C){if(document.activeElement===document.body)for(const S of C)S.removedNodes.length>0&&Dn(a)};document.addEventListener("focusin",g),document.addEventListener("focusout",x);const b=new MutationObserver(y);return a&&b.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",g),document.removeEventListener("focusout",x),b.disconnect()}}},[r,a,f.paused]),p.useEffect(()=>{if(a){Yu.add(f);const g=document.activeElement;if(!a.contains(g)){const y=new CustomEvent(Vi,Ku);a.addEventListener(Vi,c),a.dispatchEvent(y),y.defaultPrevented||(Hw(qw(qu(a)),{select:!0}),document.activeElement===g&&Dn(a))}return()=>{a.removeEventListener(Vi,c),setTimeout(()=>{const y=new CustomEvent(Ki,Ku);a.addEventListener(Ki,d),a.dispatchEvent(y),y.defaultPrevented||Dn(g??document.body,{select:!0}),a.removeEventListener(Ki,d),Yu.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 b=g.currentTarget,[C,k]=Uw(b);C&&k?!g.shiftKey&&y===k?(g.preventDefault(),n&&Dn(C,{select:!0})):g.shiftKey&&y===C&&(g.preventDefault(),n&&Dn(k,{select:!0})):y===b&&g.preventDefault()}},[n,r,f.paused]);return u.jsx(me.div,{tabIndex:-1,...i,ref:m,onKeyDown:v})});Qo.displayName=zw;function Hw(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Dn(r,{select:t}),document.activeElement!==n)return}function Uw(e){const t=qu(e),n=Gu(t,e),r=Gu(t.reverse(),e);return[n,r]}function qu(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 Gu(e,t){for(const n of e)if(!Ww(n,{upTo:t}))return n}function Ww(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 Vw(e){return e instanceof HTMLInputElement&&"select"in e}function Dn(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Vw(e)&&t&&e.select()}}var Yu=Kw();function Kw(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=Xu(e,t),e.unshift(t)},remove(t){var n;e=Xu(e,t),(n=e[0])==null||n.resume()}}}function Xu(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function qw(e){return e.filter(t=>t.tagName!=="A")}var Gw=p[" useId ".trim().toString()]||(()=>{}),Yw=0;function At(e){const[t,n]=p.useState(Gw());return Et(()=>{n(r=>r??String(Yw++))},[e]),t?`radix-${t}`:""}const Xw=["top","right","bottom","left"],Ln=Math.min,Gt=Math.max,es=Math.round,ts=Math.floor,vn=e=>({x:e,y:e}),Jw={left:"right",right:"left",bottom:"top",top:"bottom"},Zw={start:"end",end:"start"};function qi(e,t,n){return Gt(e,Ln(t,n))}function An(e,t){return typeof e=="function"?e(t):e}function jn(e){return e.split("-")[0]}function Cr(e){return e.split("-")[1]}function Gi(e){return e==="x"?"y":"x"}function Yi(e){return e==="y"?"height":"width"}const Qw=new Set(["top","bottom"]);function wn(e){return Qw.has(jn(e))?"y":"x"}function Xi(e){return Gi(wn(e))}function eb(e,t,n){n===void 0&&(n=!1);const r=Cr(e),o=Xi(e),s=Yi(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=ns(i)),[i,ns(i)]}function tb(e){const t=ns(e);return[Ji(e),t,Ji(t)]}function Ji(e){return e.replace(/start|end/g,t=>Zw[t])}const Ju=["left","right"],Zu=["right","left"],nb=["top","bottom"],rb=["bottom","top"];function ob(e,t,n){switch(e){case"top":case"bottom":return n?t?Zu:Ju:t?Ju:Zu;case"left":case"right":return t?nb:rb;default:return[]}}function sb(e,t,n,r){const o=Cr(e);let s=ob(jn(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(Ji)))),s}function ns(e){return e.replace(/left|right|bottom|top/g,t=>Jw[t])}function ib(e){return{top:0,right:0,bottom:0,left:0,...e}}function Qu(e){return typeof e!="number"?ib(e):{top:e,right:e,bottom:e,left:e}}function rs(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 ed(e,t,n){let{reference:r,floating:o}=e;const s=wn(t),i=Xi(t),a=Yi(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(Cr(t)){case"start":f[i]-=m*(n&&c?-1:1);break;case"end":f[i]+=m*(n&&c?-1:1);break}return f}const ab=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}=ed(c,r,l),m=r,f={},v=0;for(let g=0;g<a.length;g++){const{name:x,fn:y}=a[g],{x:b,y:C,data:k,reset:S}=await y({x:d,y:h,initialPlacement:r,placement:m,strategy:o,middlewareData:f,rects:c,platform:i,elements:{reference:e,floating:t}});d=b??d,h=C??h,f={...f,[x]:{...f[x],...k}},S&&v<=50&&(v++,typeof S=="object"&&(S.placement&&(m=S.placement),S.rects&&(c=S.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):S.rects),{x:d,y:h}=ed(c,m,l)),g=-1)}return{x:d,y:h,placement:m,strategy:o,middlewareData:f}};async function ro(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=Qu(f),x=a[m?h==="floating"?"reference":"floating":h],y=rs(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})),b=h==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,C=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),k=await(s.isElement==null?void 0:s.isElement(C))?await(s.getScale==null?void 0:s.getScale(C))||{x:1,y:1}:{x:1,y:1},S=rs(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:b,offsetParent:C,strategy:l}):b);return{top:(y.top-S.top+v.top)/k.y,bottom:(S.bottom-y.bottom+v.bottom)/k.y,left:(y.left-S.left+v.left)/k.x,right:(S.right-y.right+v.right)/k.x}}const lb=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=Qu(d),m={x:n,y:r},f=Xi(o),v=Yi(f),g=await i.getDimensions(c),x=f==="y",y=x?"top":"left",b=x?"bottom":"right",C=x?"clientHeight":"clientWidth",k=s.reference[v]+s.reference[f]-m[f]-s.floating[v],S=m[f]-s.reference[f],T=await(i.getOffsetParent==null?void 0:i.getOffsetParent(c));let E=T?T[C]:0;(!E||!await(i.isElement==null?void 0:i.isElement(T)))&&(E=a.floating[C]||s.floating[v]);const j=k/2-S/2,_=E/2-g[v]/2-1,$=Ln(h[y],_),F=Ln(h[b],_),U=$,X=E-g[v]-F,R=E/2-g[v]/2+j,K=qi(U,R,X),W=!l.arrow&&Cr(o)!=null&&R!==K&&s.reference[v]/2-(R<U?$:F)-g[v]/2<0,z=W?R<U?R-U:R-X:0;return{[f]:m[f]+z,data:{[f]:K,centerOffset:R-K-z,...W&&{alignmentOffset:z}},reset:W}}}),cb=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),b=wn(a),C=jn(a)===a,k=await(l.isRTL==null?void 0:l.isRTL(c.floating)),S=m||(C||!g?[ns(a)]:tb(a)),T=v!=="none";!m&&T&&S.push(...sb(a,g,v,k));const E=[a,...S],j=await ro(t,x),_=[];let $=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&_.push(j[y]),h){const R=eb(o,i,k);_.push(j[R[0]],j[R[1]])}if($=[...$,{placement:o,overflows:_}],!_.every(R=>R<=0)){var F,U;const R=(((F=s.flip)==null?void 0:F.index)||0)+1,K=E[R];if(K&&(!(h==="alignment"?b!==wn(K):!1)||$.every(O=>wn(O.placement)===b?O.overflows[0]>0:!0)))return{data:{index:R,overflows:$},reset:{placement:K}};let W=(U=$.filter(z=>z.overflows[0]<=0).sort((z,O)=>z.overflows[1]-O.overflows[1])[0])==null?void 0:U.placement;if(!W)switch(f){case"bestFit":{var X;const z=(X=$.filter(O=>{if(T){const I=wn(O.placement);return I===b||I==="y"}return!0}).map(O=>[O.placement,O.overflows.filter(I=>I>0).reduce((I,G)=>I+G,0)]).sort((O,I)=>O[1]-I[1])[0])==null?void 0:X[0];z&&(W=z);break}case"initialPlacement":W=a;break}if(o!==W)return{reset:{placement:W}}}return{}}}};function td(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function nd(e){return Xw.some(t=>e[t]>=0)}const ub=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 ro(t,{...o,elementContext:"reference"}),i=td(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:nd(i)}}}case"escaped":{const s=await ro(t,{...o,altBoundary:!0}),i=td(s,n.floating);return{data:{escapedOffsets:i,escaped:nd(i)}}}default:return{}}}}},rd=new Set(["left","top"]);async function db(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=Cr(n),l=wn(n)==="y",c=rd.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 fb=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 db(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}}}}},hb=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:b}=x;return{x:y,y:b}}},...l}=An(e,t),c={x:n,y:r},d=await ro(t,l),h=wn(jn(o)),m=Gi(h);let f=c[m],v=c[h];if(s){const x=m==="y"?"top":"left",y=m==="y"?"bottom":"right",b=f+d[x],C=f-d[y];f=qi(b,f,C)}if(i){const x=h==="y"?"top":"left",y=h==="y"?"bottom":"right",b=v+d[x],C=v-d[y];v=qi(b,v,C)}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}}}}}},pb=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=wn(o),m=Gi(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 C=m==="y"?"height":"width",k=s.reference[m]-s.floating[C]+x.mainAxis,S=s.reference[m]+s.reference[C]-x.mainAxis;f<k?f=k:f>S&&(f=S)}if(c){var y,b;const C=m==="y"?"width":"height",k=rd.has(jn(o)),S=s.reference[h]-s.floating[C]+(k&&((y=i.offset)==null?void 0:y[h])||0)+(k?0:x.crossAxis),T=s.reference[h]+s.reference[C]+(k?0:((b=i.offset)==null?void 0:b[h])||0)-(k?x.crossAxis:0);v<S?v=S:v>T&&(v=T)}return{[m]:f,[h]:v}}}},mb=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 ro(t,c),h=jn(o),m=Cr(o),f=wn(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 b=g-d.top-d.bottom,C=v-d.left-d.right,k=Ln(g-d[x],b),S=Ln(v-d[y],C),T=!t.middlewareData.shift;let E=k,j=S;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(j=C),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(E=b),T&&!m){const $=Gt(d.left,0),F=Gt(d.right,0),U=Gt(d.top,0),X=Gt(d.bottom,0);f?j=v-2*($!==0||F!==0?$+F:Gt(d.left,d.right)):E=g-2*(U!==0||X!==0?U+X:Gt(d.top,d.bottom))}await l({...t,availableWidth:j,availableHeight:E});const _=await i.getDimensions(a.floating);return v!==_.width||g!==_.height?{reset:{rects:!0}}:{}}}};function os(){return typeof window<"u"}function Tr(e){return od(e)?(e.nodeName||"").toLowerCase():"#document"}function Yt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function bn(e){var t;return(t=(od(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function od(e){return os()?e instanceof Node||e instanceof Yt(e).Node:!1}function ln(e){return os()?e instanceof Element||e instanceof Yt(e).Element:!1}function yn(e){return os()?e instanceof HTMLElement||e instanceof Yt(e).HTMLElement:!1}function sd(e){return!os()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Yt(e).ShadowRoot}const gb=new Set(["inline","contents"]);function oo(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=cn(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!gb.has(o)}const xb=new Set(["table","td","th"]);function vb(e){return xb.has(Tr(e))}const wb=[":popover-open",":modal"];function ss(e){return wb.some(t=>{try{return e.matches(t)}catch{return!1}})}const bb=["transform","translate","scale","rotate","perspective"],yb=["transform","translate","scale","rotate","perspective","filter"],Sb=["paint","layout","strict","content"];function Zi(e){const t=Qi(),n=ln(e)?cn(e):e;return bb.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)||yb.some(r=>(n.willChange||"").includes(r))||Sb.some(r=>(n.contain||"").includes(r))}function Cb(e){let t=$n(e);for(;yn(t)&&!kr(t);){if(Zi(t))return t;if(ss(t))return null;t=$n(t)}return null}function Qi(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Tb=new Set(["html","body","#document"]);function kr(e){return Tb.has(Tr(e))}function cn(e){return Yt(e).getComputedStyle(e)}function is(e){return ln(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function $n(e){if(Tr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||sd(e)&&e.host||bn(e);return sd(t)?t.host:t}function id(e){const t=$n(e);return kr(t)?e.ownerDocument?e.ownerDocument.body:e.body:yn(t)&&oo(t)?t:id(t)}function so(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=id(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Yt(o);if(s){const a=ea(i);return t.concat(i,i.visualViewport||[],oo(o)?o:[],a&&n?so(a):[])}return t.concat(o,so(o,[],n))}function ea(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function ad(e){const t=cn(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=es(n)!==s||es(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function ta(e){return ln(e)?e:e.contextElement}function Er(e){const t=ta(e);if(!yn(t))return vn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=ad(t);let i=(s?es(n.width):n.width)/r,a=(s?es(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const kb=vn(0);function ld(e){const t=Yt(e);return!Qi()||!t.visualViewport?kb:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Eb(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Yt(e)?!1:t}function Qn(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=ta(e);let i=vn(1);t&&(r?ln(r)&&(i=Er(r)):i=Er(e));const a=Eb(s,n,r)?ld(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=Yt(s),f=r&&ln(r)?Yt(r):r;let v=m,g=ea(v);for(;g&&r&&f!==v;){const x=Er(g),y=g.getBoundingClientRect(),b=cn(g),C=y.left+(g.clientLeft+parseFloat(b.paddingLeft))*x.x,k=y.top+(g.clientTop+parseFloat(b.paddingTop))*x.y;l*=x.x,c*=x.y,d*=x.x,h*=x.y,l+=C,c+=k,v=Yt(g),g=ea(v)}}return rs({width:d,height:h,x:l,y:c})}function as(e,t){const n=is(e).scrollLeft;return t?t.left+n:Qn(bn(e)).left+n}function cd(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-as(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function Ib(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=bn(r),a=t?ss(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)&&((Tr(r)!=="body"||oo(i))&&(l=is(r)),yn(r))){const f=Qn(r);c=Er(r),d.x=f.x+r.clientLeft,d.y=f.y+r.clientTop}const m=i&&!h&&!s?cd(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 Nb(e){return Array.from(e.getClientRects())}function Ab(e){const t=bn(e),n=is(e),r=e.ownerDocument.body,o=Gt(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Gt(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+as(e);const a=-n.scrollTop;return cn(r).direction==="rtl"&&(i+=Gt(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const ud=25;function jb(e,t){const n=Yt(e),r=bn(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=Qi();(!d||d&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}const c=as(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<=ud&&(s-=v)}else c<=ud&&(s+=c);return{width:s,height:i,x:a,y:l}}const Pb=new Set(["absolute","fixed"]);function _b(e,t){const n=Qn(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=yn(e)?Er(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 dd(e,t,n){let r;if(t==="viewport")r=jb(e,n);else if(t==="document")r=Ab(bn(e));else if(ln(t))r=_b(t,n);else{const o=ld(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return rs(r)}function fd(e,t){const n=$n(e);return n===t||!ln(n)||kr(n)?!1:cn(n).position==="fixed"||fd(n,t)}function Rb(e,t){const n=t.get(e);if(n)return n;let r=so(e,[],!1).filter(a=>ln(a)&&Tr(a)!=="body"),o=null;const s=cn(e).position==="fixed";let i=s?$n(e):e;for(;ln(i)&&!kr(i);){const a=cn(i),l=Zi(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&Pb.has(o.position)||oo(i)&&!l&&fd(e,i))?r=r.filter(d=>d!==i):o=a,i=$n(i)}return t.set(e,r),r}function Mb(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?ss(t)?[]:Rb(t,this._c):[].concat(n),r],a=i[0],l=i.reduce((c,d)=>{const h=dd(t,d,o);return c.top=Gt(h.top,c.top),c.right=Ln(h.right,c.right),c.bottom=Ln(h.bottom,c.bottom),c.left=Gt(h.left,c.left),c},dd(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function Ob(e){const{width:t,height:n}=ad(e);return{width:t,height:n}}function Db(e,t,n){const r=yn(t),o=bn(t),s=n==="fixed",i=Qn(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=vn(0);function c(){l.x=as(o)}if(r||!r&&!s)if((Tr(t)!=="body"||oo(o))&&(a=is(t)),r){const f=Qn(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?cd(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 na(e){return cn(e).position==="static"}function hd(e,t){if(!yn(e)||cn(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return bn(e)===n&&(n=n.ownerDocument.body),n}function pd(e,t){const n=Yt(e);if(ss(e))return n;if(!yn(e)){let o=$n(e);for(;o&&!kr(o);){if(ln(o)&&!na(o))return o;o=$n(o)}return n}let r=hd(e,t);for(;r&&vb(r)&&na(r);)r=hd(r,t);return r&&kr(r)&&na(r)&&!Zi(r)?n:r||Cb(e)||n}const Lb=async function(e){const t=this.getOffsetParent||pd,n=this.getDimensions,r=await n(e.floating);return{reference:Db(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function $b(e){return cn(e).direction==="rtl"}const Fb={convertOffsetParentRelativeRectToViewportRelativeRect:Ib,getDocumentElement:bn,getClippingRect:Mb,getOffsetParent:pd,getElementRects:Lb,getClientRects:Nb,getDimensions:Ob,getScale:Er,isElement:ln,isRTL:$b};function md(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Bb(e,t){let n=null,r;const o=bn(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=ts(h),g=ts(o.clientWidth-(d+m)),x=ts(o.clientHeight-(h+f)),y=ts(d),C={rootMargin:-v+"px "+-g+"px "+-x+"px "+-y+"px",threshold:Gt(0,Ln(1,l))||1};let k=!0;function S(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&&!md(c,e.getBoundingClientRect())&&i(),k=!1}try{n=new IntersectionObserver(S,{...C,root:o.ownerDocument})}catch{n=new IntersectionObserver(S,C)}n.observe(e)}return i(!0),s}function zb(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=ta(e),d=o||s?[...c?so(c):[],...so(t)]:[];d.forEach(y=>{o&&y.addEventListener("scroll",n,{passive:!0}),s&&y.addEventListener("resize",n)});const h=c&&a?Bb(c,n):null;let m=-1,f=null;i&&(f=new ResizeObserver(y=>{let[b]=y;b&&b.target===c&&f&&(f.unobserve(t),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var C;(C=f)==null||C.observe(t)})),n()}),c&&!l&&f.observe(c),f.observe(t));let v,g=l?Qn(e):null;l&&x();function x(){const y=Qn(e);g&&!md(g,y)&&n(),g=y,v=requestAnimationFrame(x)}return n(),()=>{var y;d.forEach(b=>{o&&b.removeEventListener("scroll",n),s&&b.removeEventListener("resize",n)}),h==null||h(),(y=f)==null||y.disconnect(),f=null,l&&cancelAnimationFrame(v)}}const Hb=fb,Ub=hb,Wb=cb,Vb=mb,Kb=ub,gd=lb,qb=pb,Gb=(e,t,n)=>{const r=new Map,o={platform:Fb,...n},s={...o.platform,_c:r};return ab(e,t,{...o,platform:s})};var Yb=typeof document<"u",Xb=function(){},ls=Yb?w.useLayoutEffect:Xb;function cs(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(!cs(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)&&!cs(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function xd(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function vd(e,t){const n=xd(e);return Math.round(t*n)/n}function ra(e){const t=p.useRef(e);return ls(()=>{t.current=e}),t}function Jb(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);cs(m,r)||f(r);const[v,g]=p.useState(null),[x,y]=p.useState(null),b=p.useCallback(O=>{O!==T.current&&(T.current=O,g(O))},[]),C=p.useCallback(O=>{O!==E.current&&(E.current=O,y(O))},[]),k=s||v,S=i||x,T=p.useRef(null),E=p.useRef(null),j=p.useRef(d),_=l!=null,$=ra(l),F=ra(o),U=ra(c),X=p.useCallback(()=>{if(!T.current||!E.current)return;const O={placement:t,strategy:n,middleware:m};F.current&&(O.platform=F.current),Gb(T.current,E.current,O).then(I=>{const G={...I,isPositioned:U.current!==!1};R.current&&!cs(j.current,G)&&(j.current=G,Ur.flushSync(()=>{h(G)}))})},[m,t,n,F,U]);ls(()=>{c===!1&&j.current.isPositioned&&(j.current.isPositioned=!1,h(O=>({...O,isPositioned:!1})))},[c]);const R=p.useRef(!1);ls(()=>(R.current=!0,()=>{R.current=!1}),[]),ls(()=>{if(k&&(T.current=k),S&&(E.current=S),k&&S){if($.current)return $.current(k,S,X);X()}},[k,S,X,$,_]);const K=p.useMemo(()=>({reference:T,floating:E,setReference:b,setFloating:C}),[b,C]),W=p.useMemo(()=>({reference:k,floating:S}),[k,S]),z=p.useMemo(()=>{const O={position:n,left:0,top:0};if(!W.floating)return O;const I=vd(W.floating,d.x),G=vd(W.floating,d.y);return a?{...O,transform:"translate("+I+"px, "+G+"px)",...xd(W.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:I,top:G}},[n,a,W.floating,d.x,d.y]);return p.useMemo(()=>({...d,update:X,refs:K,elements:W,floatingStyles:z}),[d,X,K,W,z])}const Zb=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?gd({element:r.current,padding:o}).fn(n):{}:r?gd({element:r,padding:o}).fn(n):{}}}},Qb=(e,t)=>({...Hb(e),options:[e,t]}),ey=(e,t)=>({...Ub(e),options:[e,t]}),ty=(e,t)=>({...qb(e),options:[e,t]}),ny=(e,t)=>({...Wb(e),options:[e,t]}),ry=(e,t)=>({...Vb(e),options:[e,t]}),oy=(e,t)=>({...Kb(e),options:[e,t]}),sy=(e,t)=>({...Zb(e),options:[e,t]});var iy="Arrow",wd=p.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return u.jsx(me.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"})})});wd.displayName=iy;var ay=wd;function bd(e){const[t,n]=p.useState(void 0);return Et(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const s=o[0];let i,a;if("borderBoxSize"in s){const l=s.borderBoxSize,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 oa="Popper",[yd,Ir]=an(oa),[ly,Sd]=yd(oa),Cd=e=>{const{__scopePopper:t,children:n}=e,[r,o]=p.useState(null);return u.jsx(ly,{scope:t,anchor:r,onAnchorChange:o,children:n})};Cd.displayName=oa;var Td="PopperAnchor",kd=p.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=Sd(Td,n),i=p.useRef(null),a=Me(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(me.div,{...o,ref:a})});kd.displayName=Td;var sa="PopperContent",[cy,uy]=yd(sa),Ed=p.forwardRef((e,t)=>{var M,L,Y,Z,oe,se;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=Sd(sa,n),[y,b]=p.useState(null),C=Me(t,ie=>b(ie)),[k,S]=p.useState(null),T=bd(k),E=(T==null?void 0:T.width)??0,j=(T==null?void 0:T.height)??0,_=r+(s!=="center"?"-"+s:""),$=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},F=Array.isArray(c)?c:[c],U=F.length>0,X={padding:$,boundary:F.filter(fy),altBoundary:U},{refs:R,floatingStyles:K,placement:W,isPositioned:z,middlewareData:O}=Jb({strategy:"fixed",placement:_,whileElementsMounted:(...ie)=>zb(...ie,{animationFrame:f==="always"}),elements:{reference:x.anchor},middleware:[Qb({mainAxis:o+j,alignmentAxis:i}),l&&ey({mainAxis:!0,crossAxis:!1,limiter:h==="partial"?ty():void 0,...X}),l&&ny({...X}),ry({...X,apply:({elements:ie,rects:le,availableWidth:ye,availableHeight:De})=>{const{width:We,height:Pe}=le.reference,$e=ie.floating.style;$e.setProperty("--radix-popper-available-width",`${ye}px`),$e.setProperty("--radix-popper-available-height",`${De}px`),$e.setProperty("--radix-popper-anchor-width",`${We}px`),$e.setProperty("--radix-popper-anchor-height",`${Pe}px`)}}),k&&sy({element:k,padding:a}),hy({arrowWidth:E,arrowHeight:j}),m&&oy({strategy:"referenceHidden",...X})]}),[I,G]=Ad(W),J=pt(v);Et(()=>{z&&(J==null||J())},[z,J]);const P=(M=O.arrow)==null?void 0:M.x,B=(L=O.arrow)==null?void 0:L.y,A=((Y=O.arrow)==null?void 0:Y.centerOffset)!==0,[D,q]=p.useState();return Et(()=>{y&&q(window.getComputedStyle(y).zIndex)},[y]),u.jsx("div",{ref:R.setFloating,"data-radix-popper-content-wrapper":"",style:{...K,transform:z?K.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:D,"--radix-popper-transform-origin":[(Z=O.transformOrigin)==null?void 0:Z.x,(oe=O.transformOrigin)==null?void 0:oe.y].join(" "),...((se=O.hide)==null?void 0:se.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:u.jsx(cy,{scope:n,placedSide:I,onArrowChange:S,arrowX:P,arrowY:B,shouldHideArrow:A,children:u.jsx(me.div,{"data-side":I,"data-align":G,...g,ref:C,style:{...g.style,animation:z?void 0:"none"}})})})});Ed.displayName=sa;var Id="PopperArrow",dy={top:"bottom",right:"left",bottom:"top",left:"right"},Nd=p.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=uy(Id,r),i=dy[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(ay,{...o,ref:n,style:{...o.style,display:"block"}})})});Nd.displayName=Id;function fy(e){return e!==null}var hy=e=>({name:"transformOrigin",options:e,fn(t){var x,y,b;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]=Ad(n),h={start:"0%",center:"50%",end:"100%"}[d],m=(((y=o.arrow)==null?void 0:y.x)??0)+a/2,f=(((b=o.arrow)==null?void 0:b.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 Ad(e){const[t,n="center"]=e.split("-");return[t,n]}var ia=Cd,aa=kd,la=Ed,ca=Nd,py="Portal",io=p.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=p.useState(!1);Et(()=>s(!0),[]);const i=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?Mo.createPortal(u.jsx(me.div,{...r,ref:t}),i):null});io.displayName=py;function my(e,t){return p.useReducer((n,r)=>t[n][r]??n,e)}var Bt=e=>{const{present:t,children:n}=e,r=gy(t),o=typeof n=="function"?n({present:r.isPresent}):p.Children.only(n),s=Me(r.ref,xy(o));return typeof n=="function"||r.isPresent?p.cloneElement(o,{ref:s}):null};Bt.displayName="Presence";function gy(e){const[t,n]=p.useState(),r=p.useRef(null),o=p.useRef(e),s=p.useRef("none"),i=e?"mounted":"unmounted",[a,l]=my(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return p.useEffect(()=>{const c=us(r.current);s.current=a==="mounted"?c:"none"},[a]),Et(()=>{const c=r.current,d=o.current;if(d!==e){const m=s.current,f=us(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]),Et(()=>{if(t){let c;const d=t.ownerDocument.defaultView??window,h=f=>{const g=us(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=us(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 us(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 ua="rovingFocusGroup.onEntryFocus",vy={bubbles:!1,cancelable:!0},ao="RovingFocusGroup",[da,jd,wy]=Jo(ao),[by,Pd]=an(ao,[wy]),[yy,Sy]=by(ao),_d=p.forwardRef((e,t)=>u.jsx(da.Provider,{scope:e.__scopeRovingFocusGroup,children:u.jsx(da.Slot,{scope:e.__scopeRovingFocusGroup,children:u.jsx(Cy,{...e,ref:t})})}));_d.displayName=ao;var Cy=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=Me(t,m),v=Zo(s),[g,x]=On({prop:i,defaultProp:a??null,onChange:l,caller:ao}),[y,b]=p.useState(!1),C=pt(c),k=jd(n),S=p.useRef(!1),[T,E]=p.useState(0);return p.useEffect(()=>{const j=m.current;if(j)return j.addEventListener(ua,C),()=>j.removeEventListener(ua,C)},[C]),u.jsx(yy,{scope:n,orientation:r,dir:v,loop:o,currentTabStopId:g,onItemFocus:p.useCallback(j=>x(j),[x]),onItemShiftTab:p.useCallback(()=>b(!0),[]),onFocusableItemAdd:p.useCallback(()=>E(j=>j+1),[]),onFocusableItemRemove:p.useCallback(()=>E(j=>j-1),[]),children:u.jsx(me.div,{tabIndex:y||T===0?-1:0,"data-orientation":r,...h,ref:f,style:{outline:"none",...e.style},onMouseDown:ae(e.onMouseDown,()=>{S.current=!0}),onFocus:ae(e.onFocus,j=>{const _=!S.current;if(j.target===j.currentTarget&&_&&!y){const $=new CustomEvent(ua,vy);if(j.currentTarget.dispatchEvent($),!$.defaultPrevented){const F=k().filter(W=>W.focusable),U=F.find(W=>W.active),X=F.find(W=>W.id===g),K=[U,X,...F].filter(Boolean).map(W=>W.ref.current);Od(K,d)}}S.current=!1}),onBlur:ae(e.onBlur,()=>b(!1))})})}),Rd="RovingFocusGroupItem",Md=p.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,l=At(),c=s||l,d=Sy(Rd,n),h=d.currentTabStopId===c,m=jd(n),{onFocusableItemAdd:f,onFocusableItemRemove:v,currentTabStopId:g}=d;return p.useEffect(()=>{if(r)return f(),()=>v()},[r,f,v]),u.jsx(da.ItemSlot,{scope:n,id:c,focusable:r,active:o,children:u.jsx(me.span,{tabIndex:h?0:-1,"data-orientation":d.orientation,...a,ref:t,onMouseDown:ae(e.onMouseDown,x=>{r?d.onItemFocus(c):x.preventDefault()}),onFocus:ae(e.onFocus,()=>d.onItemFocus(c)),onKeyDown:ae(e.onKeyDown,x=>{if(x.key==="Tab"&&x.shiftKey){d.onItemShiftTab();return}if(x.target!==x.currentTarget)return;const y=Ey(x,d.orientation,d.dir);if(y!==void 0){if(x.metaKey||x.ctrlKey||x.altKey||x.shiftKey)return;x.preventDefault();let C=m().filter(k=>k.focusable).map(k=>k.ref.current);if(y==="last")C.reverse();else if(y==="prev"||y==="next"){y==="prev"&&C.reverse();const k=C.indexOf(x.currentTarget);C=d.loop?Iy(C,k+1):C.slice(k+1)}setTimeout(()=>Od(C))}}),children:typeof i=="function"?i({isCurrentTabStop:h,hasTabStop:g!=null}):i})})});Md.displayName=Rd;var Ty={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function ky(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Ey(e,t,n){const r=ky(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return Ty[r]}function Od(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function Iy(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Ny=_d,Ay=Md,jy=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Nr=new WeakMap,ds=new WeakMap,fs={},fa=0,Dd=function(e){return e&&(e.host||Dd(e.parentNode))},Py=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=Dd(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})},_y=function(e,t,n,r){var o=Py(t,Array.isArray(e)?e:[e]);fs[n]||(fs[n]=new WeakMap);var s=fs[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=(Nr.get(m)||0)+1,x=(s.get(m)||0)+1;Nr.set(m,g),s.set(m,x),i.push(m),g===1&&v&&ds.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(),fa++,function(){i.forEach(function(h){var m=Nr.get(h)-1,f=s.get(h)-1;Nr.set(h,m),s.set(h,f),m||(ds.has(h)||h.removeAttribute(r),ds.delete(h)),f||h.removeAttribute(n)}),fa--,fa||(Nr=new WeakMap,Nr=new WeakMap,ds=new WeakMap,fs={})}},ha=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=jy(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),_y(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 Ld(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 Ry(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 hs="right-scroll-bar-position",ps="width-before-scroll-bar",My="with-scroll-bars-hidden",Oy="--removed-body-scroll-bar-size";function pa(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function Dy(e,t){var n=w.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 Ly=typeof window<"u"?p.useLayoutEffect:p.useEffect,$d=new WeakMap;function $y(e,t){var n=Dy(null,function(r){return e.forEach(function(o){return pa(o,r)})});return Ly(function(){var r=$d.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||pa(a,null)}),s.forEach(function(a){o.has(a)||pa(a,i)})}$d.set(n,e)},[e]),n}function Fy(e){return e}function By(e,t){t===void 0&&(t=Fy);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 zy(e){e===void 0&&(e={});var t=By(null);return t.options=Sn({async:!0,ssr:!1},e),t}var Fd=function(e){var t=e.sideCar,n=Ld(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))};Fd.isSideCarExport=!0;function Hy(e,t){return e.useMedium(t),Fd}var Bd=zy(),ma=function(){},ms=p.forwardRef(function(e,t){var n=p.useRef(null),r=p.useState({onScrollCapture:ma,onWheelCapture:ma,onTouchMoveCapture:ma}),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,b=y===void 0?"div":y,C=e.gapMode,k=Ld(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),S=m,T=$y([n,t]),E=Sn(Sn({},k),o);return p.createElement(p.Fragment,null,d&&p.createElement(S,{sideCar:Bd,removeScrollBar:c,shards:h,noRelative:f,noIsolation:v,inert:g,setCallbacks:s,allowPinchZoom:!!x,lockRef:n,gapMode:C}),i?p.cloneElement(p.Children.only(a),Sn(Sn({},E),{ref:T})):p.createElement(b,Sn({},E,{className:l,ref:T}),a))});ms.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},ms.classNames={fullWidth:ps,zeroRight:hs};var Uy=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Wy(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Uy();return t&&e.setAttribute("nonce",t),e}function Vy(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Ky(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var qy=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Wy())&&(Vy(t,n),Ky(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Gy=function(){var e=qy();return function(t,n){p.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},zd=function(){var e=Gy(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},Yy={left:0,top:0,right:0,gap:0},ga=function(e){return parseInt(e||"",10)||0},Xy=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[ga(n),ga(r),ga(o)]},Jy=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Yy;var t=Xy(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])}},Zy=zd(),Ar="data-scroll-locked",Qy=function(e,t,n,r){var o=e.left,s=e.top,i=e.right,a=e.gap;return n===void 0&&(n="margin"),`
40
40
  .`.concat(My,` {
41
41
  overflow: hidden `).concat(r,`;
42
42
  padding-right: `).concat(a,"px ").concat(r,`;
@@ -76,11 +76,11 @@ React keys must be passed directly to JSX without using spread:
76
76
  `)},Hd=function(){var e=parseInt(document.body.getAttribute(Ar)||"0",10);return isFinite(e)?e:0},e0=function(){p.useEffect(function(){return document.body.setAttribute(Ar,(Hd()+1).toString()),function(){var e=Hd()-1;e<=0?document.body.removeAttribute(Ar):document.body.setAttribute(Ar,e.toString())}},[])},t0=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;e0();var s=p.useMemo(function(){return Jy(o)},[o]);return p.createElement(Zy,{styles:Qy(s,!t,o,n?"":"!important")})},xa=!1;if(typeof window<"u")try{var gs=Object.defineProperty({},"passive",{get:function(){return xa=!0,!0}});window.addEventListener("test",gs,gs),window.removeEventListener("test",gs,gs)}catch{xa=!1}var jr=xa?{passive:!1}:!1,n0=function(e){return e.tagName==="TEXTAREA"},Ud=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!n0(e)&&n[t]==="visible")},r0=function(e){return Ud(e,"overflowY")},o0=function(e){return Ud(e,"overflowX")},Wd=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=Vd(e,r);if(o){var s=Kd(e,r),i=s[1],a=s[2];if(i>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},s0=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},i0=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},Vd=function(e,t){return e==="v"?r0(t):o0(t)},Kd=function(e,t){return e==="v"?s0(t):i0(t)},a0=function(e,t){return e==="h"&&t==="rtl"?-1:1},l0=function(e,t,n,r,o){var s=a0(e,window.getComputedStyle(t).direction),i=s*r,a=n.target,l=t.contains(a),c=!1,d=i>0,h=0,m=0;do{if(!a)break;var f=Kd(e,a),v=f[0],g=f[1],x=f[2],y=g-x-s*v;(v||y)&&Vd(e,a)&&(h+=y,m+=v);var b=a.parentNode;a=b&&b.nodeType===Node.DOCUMENT_FRAGMENT_NODE?b.host:b}while(!l&&a!==document.body||l&&(t.contains(a)||t===a));return(d&&Math.abs(h)<1||!d&&Math.abs(m)<1)&&(c=!0),c},xs=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},qd=function(e){return[e.deltaX,e.deltaY]},Gd=function(e){return e&&"current"in e?e.current:e},c0=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
- `)},d0=0,Pr=[];function f0(e){var t=p.useRef([]),n=p.useRef([0,0]),r=p.useRef(),o=p.useState(d0++)[0],s=p.useState(zd)[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=Ry([e.lockRef.current],(e.shards||[]).map(Gd),!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=xs(g),b=n.current,C="deltaX"in g?g.deltaX:b[0]-y[0],k="deltaY"in g?g.deltaY:b[1]-y[1],S,T=g.target,E=Math.abs(C)>Math.abs(k)?"h":"v";if("touches"in g&&E==="h"&&T.type==="range")return!1;var A=Wd(E,T);if(!A)return!0;if(A?S=E:(S=E==="v"?"h":"v",A=Wd(E,T)),!A)return!1;if(!r.current&&"changedTouches"in g&&(C||k)&&(r.current=S),!S)return!0;var R=r.current||S;return l0(R,x,g,R==="h"?C:k)},[]),l=p.useCallback(function(g){var x=g;if(!(!Pr.length||Pr[Pr.length-1]!==s)){var y="deltaY"in x?qd(x):xs(x),b=t.current.filter(function(S){return S.name===x.type&&(S.target===x.target||x.target===S.shadowParent)&&c0(S.delta,y)})[0];if(b&&b.should){x.cancelable&&x.preventDefault();return}if(!b){var C=(i.current.shards||[]).map(Gd).filter(Boolean).filter(function(S){return S.contains(x.target)}),k=C.length>0?a(x,C[0]):!i.current.noIsolation;k&&x.cancelable&&x.preventDefault()}}},[]),c=p.useCallback(function(g,x,y,b){var C={name:g,delta:x,target:y,should:b,shadowParent:h0(y)};t.current.push(C),setTimeout(function(){t.current=t.current.filter(function(k){return k!==C})},1)},[]),d=p.useCallback(function(g){n.current=xs(g),r.current=void 0},[]),h=p.useCallback(function(g){c(g.type,qd(g),g.target,a(g,e.lockRef.current))},[]),m=p.useCallback(function(g){c(g.type,xs(g),g.target,a(g,e.lockRef.current))},[]);p.useEffect(function(){return Pr.push(s),e.setCallbacks({onScrollCapture:h,onWheelCapture:h,onTouchMoveCapture:m}),document.addEventListener("wheel",l,jr),document.addEventListener("touchmove",l,jr),document.addEventListener("touchstart",d,jr),function(){Pr=Pr.filter(function(g){return g!==s}),document.removeEventListener("wheel",l,jr),document.removeEventListener("touchmove",l,jr),document.removeEventListener("touchstart",d,jr)}},[]);var f=e.removeScrollBar,v=e.inert;return p.createElement(p.Fragment,null,v?p.createElement(s,{styles:u0(o)}):null,f?p.createElement(t0,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function h0(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const p0=Hy(Bd,f0);var vs=p.forwardRef(function(e,t){return p.createElement(ms,Sn({},e,{ref:t,sideCar:p0}))});vs.classNames=ms.classNames;var va=["Enter"," "],m0=["ArrowDown","PageUp","Home"],Yd=["ArrowUp","PageDown","End"],g0=[...m0,...Yd],x0={ltr:[...va,"ArrowRight"],rtl:[...va,"ArrowLeft"]},v0={ltr:["ArrowLeft"],rtl:["ArrowRight"]},lo="Menu",[co,w0,b0]=Jo(lo),[er,Xd]=an(lo,[b0,Ir,Pd]),ws=Ir(),Jd=Pd(),[y0,tr]=er(lo),[S0,uo]=er(lo),Zd=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=ws(t),[l,c]=p.useState(null),d=p.useRef(!1),h=pt(s),m=Zo(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(ia,{...a,children:u.jsx(y0,{scope:t,open:n,onOpenChange:h,content:l,onContentChange:c,children:u.jsx(S0,{scope:t,onClose:p.useCallback(()=>h(!1),[h]),isUsingKeyboardRef:d,dir:m,modal:i,children:r})})})};Zd.displayName=lo;var C0="MenuAnchor",wa=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=ws(n);return u.jsx(aa,{...o,...r,ref:t})});wa.displayName=C0;var ba="MenuPortal",[T0,Qd]=er(ba,{forceMount:void 0}),ef=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=tr(ba,t);return u.jsx(T0,{scope:t,forceMount:n,children:u.jsx(Bt,{present:n||s.open,children:u.jsx(io,{asChild:!0,container:o,children:r})})})};ef.displayName=ba;var Qt="MenuContent",[k0,ya]=er(Qt),tf=p.forwardRef((e,t)=>{const n=Qd(Qt,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=tr(Qt,e.__scopeMenu),i=uo(Qt,e.__scopeMenu);return u.jsx(co.Provider,{scope:e.__scopeMenu,children:u.jsx(Bt,{present:r||s.open,children:u.jsx(co.Slot,{scope:e.__scopeMenu,children:i.modal?u.jsx(E0,{...o,ref:t}):u.jsx(I0,{...o,ref:t})})})})}),E0=p.forwardRef((e,t)=>{const n=tr(Qt,e.__scopeMenu),r=p.useRef(null),o=_e(t,r);return p.useEffect(()=>{const s=r.current;if(s)return ha(s)},[]),u.jsx(Sa,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:ae(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),I0=p.forwardRef((e,t)=>{const n=tr(Qt,e.__scopeMenu);return u.jsx(Sa,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),N0=Vt.createSlot("MenuContent.ScrollLock"),Sa=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=tr(Qt,n),y=uo(Qt,n),b=ws(n),C=Jd(n),k=w0(n),[S,T]=p.useState(null),E=p.useRef(null),A=_e(t,E,x.onContentChange),R=p.useRef(0),$=p.useRef(""),F=p.useRef(0),V=p.useRef(null),X=p.useRef("right"),_=p.useRef(0),G=v?vs:p.Fragment,H=v?{as:N0,allowPinchZoom:!0}:void 0,z=I=>{var M,L;const Y=$.current+I,J=k().filter(q=>!q.disabled),j=document.activeElement,B=(M=J.find(q=>q.ref.current===j))==null?void 0:M.textValue,P=J.map(q=>q.textValue),O=B0(P,Y,B),K=(L=J.find(q=>q.textValue===O))==null?void 0:L.ref.current;(function q(Z){$.current=Z,window.clearTimeout(R.current),Z!==""&&(R.current=window.setTimeout(()=>q(""),1e3))})(Y),K&&setTimeout(()=>K.focus())};p.useEffect(()=>()=>window.clearTimeout(R.current),[]),Wi();const D=p.useCallback(I=>{var J,j;return X.current===((J=V.current)==null?void 0:J.side)&&H0(I,(j=V.current)==null?void 0:j.area)},[]);return u.jsx(k0,{scope:n,searchRef:$,onItemEnter:p.useCallback(I=>{D(I)&&I.preventDefault()},[D]),onItemLeave:p.useCallback(I=>{var Y;D(I)||((Y=E.current)==null||Y.focus(),T(null))},[D]),onTriggerLeave:p.useCallback(I=>{D(I)&&I.preventDefault()},[D]),pointerGraceTimerRef:F,onPointerGraceIntentChange:p.useCallback(I=>{V.current=I},[]),children:u.jsx(G,{...H,children:u.jsx(Qo,{asChild:!0,trapped:o,onMountAutoFocus:ae(s,I=>{var Y;I.preventDefault(),(Y=E.current)==null||Y.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:u.jsx(Sr,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:h,onInteractOutside:m,onDismiss:f,children:u.jsx(Ny,{asChild:!0,...C,dir:y.dir,orientation:"vertical",loop:r,currentTabStopId:S,onCurrentTabStopIdChange:T,onEntryFocus:ae(l,I=>{y.isUsingKeyboardRef.current||I.preventDefault()}),preventScrollOnEntryFocus:!0,children:u.jsx(la,{role:"menu","aria-orientation":"vertical","data-state":wf(x.open),"data-radix-menu-content":"",dir:y.dir,...b,...g,ref:A,style:{outline:"none",...g.style},onKeyDown:ae(g.onKeyDown,I=>{const J=I.target.closest("[data-radix-menu-content]")===I.currentTarget,j=I.ctrlKey||I.altKey||I.metaKey,B=I.key.length===1;J&&(I.key==="Tab"&&I.preventDefault(),!j&&B&&z(I.key));const P=E.current;if(I.target!==P||!g0.includes(I.key))return;I.preventDefault();const K=k().filter(M=>!M.disabled).map(M=>M.ref.current);Yd.includes(I.key)&&K.reverse(),$0(K)}),onBlur:ae(e.onBlur,I=>{I.currentTarget.contains(I.target)||(window.clearTimeout(R.current),$.current="")}),onPointerMove:ae(e.onPointerMove,ho(I=>{const Y=I.target,J=_.current!==I.clientX;if(I.currentTarget.contains(Y)&&J){const j=I.clientX>_.current?"right":"left";X.current=j,_.current=I.clientX}}))})})})})})})});tf.displayName=Qt;var A0="MenuGroup",Ca=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(me.div,{role:"group",...r,ref:t})});Ca.displayName=A0;var j0="MenuLabel",nf=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(me.div,{...r,ref:t})});nf.displayName=j0;var bs="MenuItem",rf="menu.itemSelect",ys=p.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=p.useRef(null),i=uo(bs,e.__scopeMenu),a=ya(bs,e.__scopeMenu),l=_e(t,s),c=p.useRef(!1),d=()=>{const h=s.current;if(!n&&h){const m=new CustomEvent(rf,{bubbles:!0,cancelable:!0});h.addEventListener(rf,f=>r==null?void 0:r(f),{once:!0}),zi(h,m),m.defaultPrevented?c.current=!1:i.onClose()}};return u.jsx(of,{...o,ref:l,disabled:n,onClick:ae(e.onClick,d),onPointerDown:h=>{var m;(m=e.onPointerDown)==null||m.call(e,h),c.current=!0},onPointerUp:ae(e.onPointerUp,h=>{var m;c.current||(m=h.currentTarget)==null||m.click()}),onKeyDown:ae(e.onKeyDown,h=>{const m=a.searchRef.current!=="";n||m&&h.key===" "||va.includes(h.key)&&(h.currentTarget.click(),h.preventDefault())})})});ys.displayName=bs;var of=p.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=ya(bs,n),a=Jd(n),l=p.useRef(null),c=_e(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(co.ItemSlot,{scope:n,disabled:r,textValue:o??m,children:u.jsx(Ay,{asChild:!0,...a,focusable:!r,children:u.jsx(me.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:c,onPointerMove:ae(e.onPointerMove,ho(v=>{r?i.onItemLeave(v):(i.onItemEnter(v),v.defaultPrevented||v.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:ae(e.onPointerLeave,ho(v=>i.onItemLeave(v))),onFocus:ae(e.onFocus,()=>h(!0)),onBlur:ae(e.onBlur,()=>h(!1))})})})}),P0="MenuCheckboxItem",sf=p.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return u.jsx(df,{scope:e.__scopeMenu,checked:n,children:u.jsx(ys,{role:"menuitemcheckbox","aria-checked":Ss(n)?"mixed":n,...o,ref:t,"data-state":ka(n),onSelect:ae(o.onSelect,()=>r==null?void 0:r(Ss(n)?!0:!n),{checkForDefaultPrevented:!1})})})});sf.displayName=P0;var af="MenuRadioGroup",[_0,R0]=er(af,{value:void 0,onValueChange:()=>{}}),lf=p.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=pt(r);return u.jsx(_0,{scope:e.__scopeMenu,value:n,onValueChange:s,children:u.jsx(Ca,{...o,ref:t})})});lf.displayName=af;var cf="MenuRadioItem",uf=p.forwardRef((e,t)=>{const{value:n,...r}=e,o=R0(cf,e.__scopeMenu),s=n===o.value;return u.jsx(df,{scope:e.__scopeMenu,checked:s,children:u.jsx(ys,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":ka(s),onSelect:ae(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});uf.displayName=cf;var Ta="MenuItemIndicator",[df,M0]=er(Ta,{checked:!1}),ff=p.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=M0(Ta,n);return u.jsx(Bt,{present:r||Ss(s.checked)||s.checked===!0,children:u.jsx(me.span,{...o,ref:t,"data-state":ka(s.checked)})})});ff.displayName=Ta;var O0="MenuSeparator",hf=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(me.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});hf.displayName=O0;var D0="MenuArrow",pf=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=ws(n);return u.jsx(ca,{...o,...r,ref:t})});pf.displayName=D0;var L0="MenuSub",[P1,mf]=er(L0),fo="MenuSubTrigger",gf=p.forwardRef((e,t)=>{const n=tr(fo,e.__scopeMenu),r=uo(fo,e.__scopeMenu),o=mf(fo,e.__scopeMenu),s=ya(fo,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(wa,{asChild:!0,...c,children:u.jsx(of,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":wf(n.open),...e,ref:Mn(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:ae(e.onPointerMove,ho(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:ae(e.onPointerLeave,ho(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,b=m[x?"left":"right"],C=m[x?"right":"left"];s.onPointerGraceIntentChange({area:[{x:h.clientX+y,y:h.clientY},{x:b,y:m.top},{x:C,y:m.top},{x:C,y:m.bottom},{x:b,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:ae(e.onKeyDown,h=>{var f;const m=s.searchRef.current!=="";e.disabled||m&&h.key===" "||x0[r.dir].includes(h.key)&&(n.onOpenChange(!0),(f=n.content)==null||f.focus(),h.preventDefault())})})})});gf.displayName=fo;var xf="MenuSubContent",vf=p.forwardRef((e,t)=>{const n=Qd(Qt,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=tr(Qt,e.__scopeMenu),i=uo(Qt,e.__scopeMenu),a=mf(xf,e.__scopeMenu),l=p.useRef(null),c=_e(t,l);return u.jsx(co.Provider,{scope:e.__scopeMenu,children:u.jsx(Bt,{present:r||s.open,children:u.jsx(co.Slot,{scope:e.__scopeMenu,children:u.jsx(Sa,{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:ae(e.onFocusOutside,d=>{d.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:ae(e.onEscapeKeyDown,d=>{i.onClose(),d.preventDefault()}),onKeyDown:ae(e.onKeyDown,d=>{var f;const h=d.currentTarget.contains(d.target),m=v0[i.dir].includes(d.key);h&&m&&(s.onOpenChange(!1),(f=a.trigger)==null||f.focus(),d.preventDefault())})})})})})});vf.displayName=xf;function wf(e){return e?"open":"closed"}function Ss(e){return e==="indeterminate"}function ka(e){return Ss(e)?"indeterminate":e?"checked":"unchecked"}function $0(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function F0(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function B0(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=F0(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 z0(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 H0(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return z0(n,t)}function ho(e){return t=>t.pointerType==="mouse"?e(t):void 0}var U0=Zd,W0=wa,V0=ef,K0=tf,q0=Ca,G0=nf,Y0=ys,X0=sf,J0=lf,Z0=uf,Q0=ff,eS=hf,tS=pf,nS=gf,rS=vf,Cs="DropdownMenu",[oS,_1]=an(Cs,[Xd]),Ot=Xd(),[sS,bf]=oS(Cs),yf=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,l=Ot(t),c=p.useRef(null),[d,h]=On({prop:o,defaultProp:s??!1,onChange:i,caller:Cs});return u.jsx(sS,{scope:t,triggerId:jt(),triggerRef:c,contentId:jt(),open:d,onOpenChange:h,onOpenToggle:p.useCallback(()=>h(m=>!m),[h]),modal:a,children:u.jsx(U0,{...l,open:d,onOpenChange:h,dir:r,modal:a,children:n})})};yf.displayName=Cs;var Sf="DropdownMenuTrigger",Cf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=bf(Sf,n),i=Ot(n);return u.jsx(W0,{asChild:!0,...i,children:u.jsx(me.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:Mn(t,s.triggerRef),onPointerDown:ae(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:ae(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});Cf.displayName=Sf;var iS="DropdownMenuPortal",Tf=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Ot(t);return u.jsx(V0,{...r,...n})};Tf.displayName=iS;var kf="DropdownMenuContent",Ef=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=bf(kf,n),s=Ot(n),i=p.useRef(!1);return u.jsx(K0,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:ae(e.onCloseAutoFocus,a=>{var l;i.current||(l=o.triggerRef.current)==null||l.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:ae(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)"}})});Ef.displayName=kf;var aS="DropdownMenuGroup",lS=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(q0,{...o,...r,ref:t})});lS.displayName=aS;var cS="DropdownMenuLabel",If=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(G0,{...o,...r,ref:t})});If.displayName=cS;var uS="DropdownMenuItem",Nf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(Y0,{...o,...r,ref:t})});Nf.displayName=uS;var dS="DropdownMenuCheckboxItem",Af=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(X0,{...o,...r,ref:t})});Af.displayName=dS;var fS="DropdownMenuRadioGroup",hS=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(J0,{...o,...r,ref:t})});hS.displayName=fS;var pS="DropdownMenuRadioItem",jf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(Z0,{...o,...r,ref:t})});jf.displayName=pS;var mS="DropdownMenuItemIndicator",Pf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(Q0,{...o,...r,ref:t})});Pf.displayName=mS;var gS="DropdownMenuSeparator",_f=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(eS,{...o,...r,ref:t})});_f.displayName=gS;var xS="DropdownMenuArrow",vS=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(tS,{...o,...r,ref:t})});vS.displayName=xS;var wS="DropdownMenuSubTrigger",Rf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(nS,{...o,...r,ref:t})});Rf.displayName=wS;var bS="DropdownMenuSubContent",Mf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(rS,{...o,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Mf.displayName=bS;var yS=yf,SS=Cf,CS=Tf,Of=Ef,Df=If,Lf=Nf,$f=Af,Ff=jf,Bf=Pf,zf=_f,Hf=Rf,Uf=Mf;const Ts=yS,ks=SS,TS=p.forwardRef(({className:e,inset:t,children:n,...r},o)=>u.jsxs(Hf,{ref:o,className:te("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(le.ChevronRight,{className:"ml-auto h-4 w-4"})]}));TS.displayName=Hf.displayName;const kS=p.forwardRef(({className:e,...t},n)=>u.jsx(Uf,{ref:n,className:te("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}));kS.displayName=Uf.displayName;const po=p.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(CS,{children:u.jsx(Of,{ref:r,sideOffset:t,className:te("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})}));po.displayName=Of.displayName;const Fn=p.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(Lf,{ref:r,className:te("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}));Fn.displayName=Lf.displayName;const ES=p.forwardRef(({className:e,children:t,checked:n,...r},o)=>u.jsxs($f,{ref:o,className:te("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(Bf,{children:u.jsx(le.Check,{className:"h-4 w-4"})})}),t]}));ES.displayName=$f.displayName;const IS=p.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Ff,{ref:r,className:te("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(Bf,{children:u.jsx(le.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));IS.displayName=Ff.displayName;const NS=p.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(Df,{ref:r,className:te("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));NS.displayName=Df.displayName;const AS=p.forwardRef(({className:e,...t},n)=>u.jsx(zf,{ref:n,className:te("-mx-1 my-1 h-px bg-muted",e),...t}));AS.displayName=zf.displayName;const Ea=p.forwardRef(({className:e,...t},n)=>u.jsx("textarea",{className:te("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}));Ea.displayName="Textarea";const jS=1e4;function Wf({initialValue:e="",editingMessageId:t=null,placeholder:n="Type your message...",isStreaming:r=!1,disabled:o=!1,maxLength:s=jS,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,[b,C]=w.useState(e),k=(y?i:b)??"",[S,T]=w.useTransition(),E=w.useRef(null),A=w.useRef(0),R=w.useRef(null),$=w.useRef("");w.useEffect(()=>{y||(C(e??""),R.current=null,E.current&&(E.current.style.height="auto",E.current.style.height=`${E.current.scrollHeight}px`))},[e,t,y]);const[F,V]=w.useState(null),X=w.useCallback(P=>P.length>s?`Message too long (${P.length}/${s} characters)`:null,[s]),_=w.useMemo(()=>g??X,[g,X]),G=w.useCallback(P=>{const O=_(P);return V(O),x==null||x(O),$.current=P,O},[_,x]),H=w.useCallback(()=>{const P=E.current;P&&(P.style.height="auto",P.style.height=`${P.scrollHeight}px`)},[]);w.useEffect(()=>{H()},[H,k]),w.useEffect(()=>{if(!F)return;const P=(k??"").trim();$.current!==P&&G(P)},[k,F,G]);const z=w.useCallback((P,{fromUser:O})=>{y||C(P),O&&(a==null||a(P))},[y,a]),D=w.useCallback(async P=>{P&&P.preventDefault();const O=(k??"").trim();if(!O&&!f||G(O))return;const K=++A.current;R.current={id:K,shouldClear:!0},T(()=>{var M,L,q;try{const Z=l(O);Z&&typeof Z.then=="function"?Z.then(()=>{var se,ie;((se=R.current)==null?void 0:se.id)===K&&R.current.shouldClear&&(y||(C(""),E.current&&(E.current.style.height="auto"),a==null||a(""))),((ie=R.current)==null?void 0:ie.id)===K&&(R.current=null)}).catch(()=>{var se;((se=R.current)==null?void 0:se.id)===K&&(R.current=null)}):(((M=R.current)==null?void 0:M.id)===K&&R.current.shouldClear&&(y||(C(""),E.current&&(E.current.style.height="auto"),a==null||a(""))),((L=R.current)==null?void 0:L.id)===K&&(R.current=null))}catch{((q=R.current)==null?void 0:q.id)===K&&(R.current=null)}})},[k,l,f,y,a,G]),I=w.useCallback(P=>{const O=P.target.value;z(O,{fromUser:!0}),R.current&&(R.current.shouldClear=!1),E.current&&(E.current.style.height="auto",E.current.style.height=`${E.current.scrollHeight}px`),F&&G(O.trim())},[z,G,F]),Y=w.useCallback(P=>{P.key==="Enter"&&!P.shiftKey?(P.preventDefault(),D()):P.key==="Escape"&&t&&(P.preventDefault(),c==null||c())},[D,t,c]),B=`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${t?"border-[hsl(var(--ring))] bg-[hsl(var(--card))] text-[hsl(var(--card-foreground))] dark:bg-[hsl(var(--card))] dark:text-[hsl(var(--card-foreground))]":""} ${m}`;return u.jsx("form",{onSubmit:P=>void D(P),className:`w-full ${h}`,children:u.jsxs("div",{className:"flex items-end gap-2",children:[u.jsxs("div",{className:"flex-1",children:[u.jsx(Ea,{ref:E,value:k,onChange:I,onKeyDown:Y,placeholder:t?"Edit your message...":n,className:B,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(et,{type:"button",onClick:()=>{d==null||d()},size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",disabled:o||!d,children:u.jsx(le.Square,{size:16})}):u.jsx(et,{type:"submit",size:"icon",className:`shrink-0 ${v??""}`,title:t?"Save changes":"Send message",disabled:o||!k.trim()&&!f||S,children:u.jsx(le.Send,{size:16})})})]})})}const PS=w.memo(Wf);function Vf({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[b,C]=w.useState([]),k=w.useRef(null),S=w.useRef(null),[T,E]=w.useState(0),[A,R]=w.useState(0),[$,F]=w.useState(!1),[V,X]=w.useState(null),[_,G]=w.useState(null),H=w.useCallback(()=>{k.current&&(k.current.value=""),S.current&&(S.current.value=""),E(P=>P+1),R(P=>P+1)},[]),z=w.useCallback(P=>{C(O=>[...O,...P])},[]),D=w.useCallback(P=>{const O=Array.from(P.target.files||[]);z(O),P.target.value=""},[z]),I=w.useCallback(P=>{C(O=>{const K=O.filter((M,L)=>L!==P);return K.length===0&&H(),K})},[H]),Y=w.useCallback(async P=>{const O=(P.target.files||[])[0];if(O&&(X(null),G(null),!!v)){F(!0);try{await v(O),X(`Uploaded ${O.name} - processing through chat stream`)}catch(K){const M=K instanceof Error?K.message:"Failed to upload Excel file";G(M),g==null||g(M)}finally{F(!1),P.target.value="",H()}}},[v,g,H]),J=w.useMemo(()=>x||b.length>0,[x,b]),j=w.useCallback(async P=>{const O=n(P,b);try{const K=await O;return b.length>0&&(C([]),H()),K}catch(K){throw K}},[n,H,b]),B=`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:D,className:"hidden"},T),b.length>0&&u.jsx("div",{className:"flex flex-wrap gap-2",children:b.map((P,O)=>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(le.Paperclip,{size:14}),u.jsx("span",{className:"truncate max-w-[150px]",children:P.name}),u.jsx(et,{variant:"ghost",size:"sm",onClick:()=>I(O),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 ${P.name}`,children:u.jsx(le.X,{size:12})})]},O))})]}),f&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:S,type:"file",accept:".xls,.xlsx,.xlsm",onChange:Y,className:"hidden"},A),$&&u.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(le.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),V&&!$&&u.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:V}),_&&!$&&u.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:_})]})]}),u.jsxs("div",{className:"flex items-end gap-2",children:[(m||f)&&u.jsxs(Ts,{children:[u.jsx(ks,{asChild:!0,children:u.jsx(et,{type:"button",size:"icon",variant:"outline",disabled:l||c,title:"More input actions",className:h.moreButton||"",children:u.jsx(le.Plus,{size:16})})}),u.jsxs(po,{align:"start",sideOffset:6,className:"w-52",children:[m&&u.jsxs(Fn,{onClick:()=>{var P;return(P=k.current)==null?void 0:P.click()},className:"cursor-pointer",children:[u.jsx(le.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),f&&u.jsxs(Fn,{onClick:()=>{var P;$||(P=S.current)==null||P.click()},className:`cursor-pointer ${$?"opacity-60 pointer-events-none":""}`,children:[u.jsx(le.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),u.jsx("div",{className:"flex-1",children:u.jsx(PS,{initialValue:i,editingMessageId:s,value:e,onValueChange:t,placeholder:s?"Edit your message...":a,isStreaming:l,disabled:c,onSend:j,onCancelEdit:r,onStop:o,allowEmptySend:J,textareaClassName:B,sendButtonClassName:h.sendButton})})]})]})}const _S=w.memo(Vf),Es=0,Bn=1,_r=2,Kf=4;function qf(e){return()=>e}function RS(e){e()}function Gf(e,t){return n=>e(t(n))}function Yf(e,t){return()=>e(t)}function MS(e,t){return n=>e(t,n)}function Ia(e){return e!==void 0}function OS(...e){return()=>{e.map(RS)}}function Rr(){}function Is(e,t){return t(e),e}function DS(e,t){return t(e)}function at(...e){return e}function Ze(e,t){return e(Bn,t)}function Pe(e,t){e(Es,t)}function Na(e){e(_r)}function mt(e){return e(Kf)}function ge(e,t){return Ze(e,MS(t,Es))}function un(e,t){const n=e(Bn,r=>{n(),t(r)});return n}function Xf(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function Jf(e,t){return e===t}function lt(e=Jf){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function Te(e){return t=>n=>{e(n)&&t(n)}}function fe(e){return t=>Gf(t,e)}function Cn(e){return t=>()=>{t(e)}}function Q(e,...t){const n=LS(...t);return(r,o)=>{switch(r){case _r:Na(e);return;case Bn:return Ze(e,n(o))}}}function Tn(e,t){return n=>r=>{n(t=e(t,r))}}function nr(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 Re(...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);Ze(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 LS(...e){return t=>e.reduceRight(DS,t)}function $S(e){let t,n;const r=()=>t==null?void 0:t();return function(o,s){switch(o){case Bn:return s?n===s?void 0:(r(),n=s,t=Ze(e,s),t):(r(),Rr);case _r:r(),n=null;return}}}function oe(e){let t=e;const n=He();return(r,o)=>{switch(r){case Es:t=o;break;case Bn:{o(t);break}case Kf:return t}return n(r,o)}}function Pt(e,t){return Is(oe(t),n=>ge(e,n))}function He(){const e=[];return(t,n)=>{switch(t){case Es:e.slice().forEach(r=>{r(n)});return;case _r:e.splice(0,e.length);return;case Bn:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}}}function Xt(e){return Is(He(),t=>ge(e,t))}function Ge(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:FS(),singleton:n}}const FS=()=>Symbol();function BS(e){const t=new Map,n=({constructor:r,dependencies:o,id:s,singleton:i})=>{if(i&&t.has(s))return t.get(s);const a=r(o.map(l=>n(l)));return i&&t.set(s,a),a};return n(e)}function wt(...e){const t=He(),n=new Array(e.length);let r=0;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const a=Math.pow(2,i);Ze(s,l=>{n[i]=l,r=r|a,r===o&&Pe(t,n)})}),function(s,i){switch(s){case _r:{Na(t);return}case Bn:return r===o&&i(n),Ze(t,i)}}}function Se(e,t=Jf){return Q(e,lt(t))}function Aa(...e){return function(t,n){switch(t){case _r:return;case Bn:return OS(...e.map(r=>Ze(r,n)))}}}var zt=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(zt||{});const zS={0:"debug",3:"error",1:"log",2:"warn"},HS=()=>typeof globalThis>"u"?window:globalThis,zn=Ge(()=>{const e=oe(3);return{log:oe((t,n,r=1)=>{var o;const s=(o=HS().VIRTUOSO_LOG_LEVEL)!=null?o:mt(e);r>=s&&console[zS[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0});function rr(e,t,n){return ja(e,t,n).callbackRef}function ja(e,t,n){const r=w.useRef(null);let o=i=>{};const s=w.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 US(e,t,n,r,o,s,i,a,l){const c=w.useCallback(d=>{const h=WS(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?Zf("column-gap",getComputedStyle(d).columnGap,o):Zf("row-gap",getComputedStyle(d).rowGap,o)),h!==null&&e(h)},[e,t,o,s,i,r,a]);return ja(c,n,l)}function WS(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},zt.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 Zf(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,zt.WARN),t==="normal"?0:parseInt(t??"0",10)}function Qf(e,t,n){const r=w.useRef(null),o=w.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}=ja(o,!0,n),a=w.useCallback(()=>{o(i.current)},[o,i]);return w.useEffect(()=>{var l;if(t){t.addEventListener("scroll",a);const c=new ResizeObserver(()=>{requestAnimationFrame(a)});return c.observe(t),()=>{t.removeEventListener("scroll",a),c.unobserve(t)}}else{const c=(l=i.current)==null?void 0:l.ownerDocument.defaultView;return c==null||c.addEventListener("scroll",a),c==null||c.addEventListener("resize",a),()=>{c==null||c.removeEventListener("scroll",a),c==null||c.removeEventListener("resize",a)}}},[a,t,i]),s}const Dt=Ge(()=>{const e=He(),t=He(),n=oe(0),r=He(),o=oe(0),s=He(),i=He(),a=oe(0),l=oe(0),c=oe(0),d=oe(0),h=He(),m=He(),f=oe(!1),v=oe(!1),g=oe(!1);return ge(Q(e,fe(({scrollTop:x})=>x)),t),ge(Q(e,fe(({scrollHeight:x})=>x)),i),ge(t,o),{deviation:n,fixedFooterHeight:c,fixedHeaderHeight:l,footerHeight:d,headerHeight:a,horizontalDirection:v,scrollBy:m,scrollContainerState:e,scrollHeight:i,scrollingInProgress:f,scrollTo:h,scrollTop:t,skipAnimationFrameInResizeObserver:g,smoothScrollTargetReached:r,statefulScrollTop:o,viewportHeight:s}},[],{singleton:!0}),mo={lvl:0};function eh(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 rt(e){return e===mo}function go(e,t){if(!rt(e))return t===e.k?e.v:t<e.k?go(e.l,t):go(e.r,t)}function dn(e,t,n="k"){if(rt(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){const r=dn(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return dn(e.l,t,n)}function Jt(e,t,n){return rt(e)?rh(t,n,1):t===e.k?St(e,{k:t,v:n}):t<e.k?oh(St(e,{l:Jt(e.l,t,n)})):oh(St(e,{r:Jt(e.r,t,n)}))}function Mr(){return mo}function Ns(e,t,n){if(rt(e))return[];const r=dn(e,t)[0];return VS(_a(e,r,n))}function Pa(e,t){if(rt(e))return mo;const{k:n,l:r,r:o}=e;if(t===n){if(rt(r))return o;if(rt(o))return r;{const[s,i]=nh(r);return As(St(e,{k:s,l:th(r),v:i}))}}else return t<n?As(St(e,{l:Pa(r,t)})):As(St(e,{r:Pa(o,t)}))}function or(e){return rt(e)?[]:[...or(e.l),{k:e.k,v:e.v},...or(e.r)]}function _a(e,t,n){if(rt(e))return[];const{k:r,l:o,r:s,v:i}=e;let a=[];return r>t&&(a=a.concat(_a(o,t,n))),r>=t&&r<=n&&a.push({k:r,v:i}),r<=n&&(a=a.concat(_a(s,t,n))),a}function As(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(Ra(t))return sh(St(e,{lvl:n-1}));if(!rt(t)&&!rt(t.r))return St(t.r,{l:St(t,{r:t.r.l}),lvl:n,r:St(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(Ra(e))return Ma(St(e,{lvl:n-1}));if(!rt(r)&&!rt(r.l)){const o=r.l,s=Ra(o)?r.lvl-1:r.lvl;return St(o,{l:St(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:Ma(St(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function St(e,t){return rh(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 th(e){return rt(e.r)?e.l:As(St(e,{r:th(e.r)}))}function Ra(e){return rt(e)||e.lvl>e.r.lvl}function nh(e){return rt(e.r)?[e.k,e.v]:nh(e.r)}function rh(e,t,n,r=mo,o=mo){return{k:e,l:r,lvl:n,r:o,v:t}}function oh(e){return Ma(sh(e))}function sh(e){const{l:t}=e;return!rt(t)&&t.lvl===e.lvl?St(t,{r:St(e,{l:t.r})}):e}function Ma(e){const{lvl:t,r:n}=e;return!rt(n)&&!rt(n.r)&&n.lvl===t&&n.r.lvl===t?St(n,{l:St(e,{r:n.l}),lvl:t+1}):e}function VS(e){return eh(e,({k:t,v:n})=>({index:t,value:n}))}function ih(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function xo(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const Oa=Ge(()=>({recalcInProgress:oe(!1)}),[],{singleton:!0});function ah(e,t,n){return e[js(e,t,n)]}function js(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 KS(e,t,n,r){const o=js(e,t,r),s=js(e,n,r,o);return e.slice(o,s+1)}function Hn(e,t){return Math.round(e.getBoundingClientRect()[t])}function Ps(e){return!rt(e.groupOffsetTree)}function Da({index:e},t){return t===e?0:t<e?-1:1}function qS(){return{groupIndices:[],groupOffsetTree:Mr(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Mr()}}function GS(e,t){let n=rt(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),rt(e)){e=Jt(e,0,s);continue}const a=Ns(e,i-1,o+1);if(a.some(tC(r)))continue;let l=!1,c=!1;for(const{end:d,start:h,value:m}of a)l?(o>=h||s===m)&&(e=Pa(e,h)):(c=m!==s,l=!0),d>o&&o>=h&&m!==s&&(e=Jt(e,o+1,m));c&&(e=Jt(e,i,s))}return[e,n]}function YS(e){return typeof e.groupIndex<"u"}function XS({offset:e},t){return t===e?0:t<e?-1:1}function vo(e,t,n){if(t.length===0)return 0;const{index:r,offset:o,size:s}=ah(t,e,Da),i=e-r,a=s*i+(i-1)*n+o;return a>0?a+n:a}function lh(e,t){if(!Ps(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function ch(e,t,n){if(YS(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=lh(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function JS(e,t,n,r=0){return r>0&&(t=Math.max(t,ah(e,r,Da).offset)),eh(KS(e,t,n,XS),eC)}function ZS(e,[t,n,r,o]){t.length>0&&r("received item sizes",t,zt.DEBUG);const s=e.sizeTree;let i=s,a=0;if(n.length>0&&rt(s)&&t.length===2){const m=t[0].size,f=t[1].size;i=n.reduce((v,g)=>Jt(Jt(v,g,m),g+1,f),i)}else[i,a]=GS(i,t);if(i===s)return e;const{lastIndex:l,lastOffset:c,lastSize:d,offsetTree:h}=La(e.offsetTree,a,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((m,f)=>Jt(m,f,vo(f,h,o)),Mr()),lastIndex:l,lastOffset:c,lastSize:d,offsetTree:h,sizeTree:i}}function QS(e){return or(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 uh(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 La(e,t,n,r){let o=e,s=0,i=0,a=0,l=0;if(t!==0){l=js(o,t-1,Da),a=o[l].offset;const c=dn(n,t-1);s=c[0],i=c[1],o.length&&o[l].size===dn(n,t)[1]&&(l-=1),o=o.slice(0,l+1)}else o=[];for(const{start:c,value:d}of Ns(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 eC(e){return{index:e.index,value:e}}function tC(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 nC={offsetHeight:"height",offsetWidth:"width"},kn=Ge(([{log:e},{recalcInProgress:t}])=>{const n=He(),r=He(),o=Pt(r,0),s=He(),i=He(),a=oe(0),l=oe([]),c=oe(void 0),d=oe(void 0),h=oe((S,T)=>Hn(S,nC[T])),m=oe(void 0),f=oe(0),v=qS(),g=Pt(Q(n,Re(l,e,f),Tn(ZS,v),lt()),v),x=Pt(Q(l,lt(),Tn((S,T)=>({current:T,prev:S.current}),{current:[],prev:[]}),fe(({prev:S})=>S)),[]);ge(Q(l,Te(S=>S.length>0),Re(g,f),fe(([S,T,E])=>{const A=S.reduce((R,$,F)=>Jt(R,$,vo($,T.offsetTree,E)||F),Mr());return{...T,groupIndices:S,groupOffsetTree:A}})),g),ge(Q(r,Re(g),Te(([S,{lastIndex:T}])=>S<T),fe(([S,{lastIndex:T,lastSize:E}])=>[{endIndex:T,size:E,startIndex:S}])),n),ge(c,d);const y=Pt(Q(c,fe(S=>S===void 0)),!0);ge(Q(d,Te(S=>S!==void 0&&rt(mt(g).sizeTree)),fe(S=>[{endIndex:0,size:S,startIndex:0}])),n);const b=Xt(Q(n,Re(g),Tn(({sizes:S},[T,E])=>({changed:E!==S,sizes:E}),{changed:!1,sizes:v}),fe(S=>S.changed)));Ze(Q(a,Tn((S,T)=>({diff:S.prev-T,prev:T}),{diff:0,prev:0}),fe(S=>S.diff)),S=>{const{groupIndices:T}=mt(g);if(S>0)Pe(t,!0),Pe(s,S+uh(S,T));else if(S<0){const E=mt(x);E.length>0&&(S-=uh(-S,E)),Pe(i,S)}}),Ze(Q(a,Re(e)),([S,T])=>{S<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},zt.ERROR)});const C=Xt(s);ge(Q(s,Re(g),fe(([S,T])=>{const E=T.groupIndices.length>0,A=[],R=T.lastSize;if(E){const $=go(T.sizeTree,0);let F=0,V=0;for(;F<S;){const _=T.groupIndices[V],G=T.groupIndices.length===V+1?1/0:T.groupIndices[V+1]-_-1;A.push({endIndex:_,size:$,startIndex:_}),A.push({endIndex:_+1+G-1,size:R,startIndex:_+1}),V++,F+=G+1}const X=or(T.sizeTree);return F!==S&&X.shift(),X.reduce((_,{k:G,v:H})=>{let z=_.ranges;return _.prevSize!==0&&(z=[..._.ranges,{endIndex:G+S-1,size:_.prevSize,startIndex:_.prevIndex}]),{prevIndex:G+S,prevSize:H,ranges:z}},{prevIndex:S,prevSize:0,ranges:A}).ranges}return or(T.sizeTree).reduce(($,{k:F,v:V})=>({prevIndex:F+S,prevSize:V,ranges:[...$.ranges,{endIndex:F+S-1,size:$.prevSize,startIndex:$.prevIndex}]}),{prevIndex:0,prevSize:R,ranges:[]}).ranges})),n);const k=Xt(Q(i,Re(g,f),fe(([S,{offsetTree:T},E])=>{const A=-S;return vo(A,T,E)})));return ge(Q(i,Re(g,f),fe(([S,T,E])=>{if(T.groupIndices.length>0){if(rt(T.sizeTree))return T;let A=Mr();const R=mt(x);let $=0,F=0,V=0;for(;$<-S;){V=R[F];const X=R[F+1]-V-1;F++,$+=X+1}if(A=or(T.sizeTree).reduce((X,{k:_,v:G})=>Jt(X,Math.max(0,_+S),G),A),$!==-S){const X=go(T.sizeTree,V);A=Jt(A,0,X);const _=dn(T.sizeTree,-S+1)[1];A=Jt(A,1,_)}return{...T,sizeTree:A,...La(T.offsetTree,0,A,E)}}else{const A=or(T.sizeTree).reduce((R,{k:$,v:F})=>Jt(R,Math.max(0,$+S),F),Mr());return{...T,sizeTree:A,...La(T.offsetTree,0,A,E)}}})),g),{beforeUnshiftWith:C,data:m,defaultItemSize:d,firstItemIndex:a,fixedItemSize:c,gap:f,groupIndices:l,itemSize:h,listRefresh:b,shiftWith:i,shiftWithOffset:k,sizeRanges:n,sizes:g,statefulTotalCount:o,totalCount:r,trackItemSizes:y,unshiftWith:s}},at(zn,Oa),{singleton:!0});function rC(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const dh=Ge(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=He(),i=He(),a=Xt(Q(s,fe(rC)));return ge(Q(a,fe(l=>l.totalCount)),n),ge(Q(a,fe(l=>l.groupIndices)),e),ge(Q(wt(o,t,r),Te(([l,c])=>Ps(c)),fe(([l,c,d])=>dn(c.groupOffsetTree,Math.max(l-d,0),"v")[0]),lt(),fe(l=>[l])),i),{groupCounts:s,topItemsIndexes:i}},at(kn,Dt)),Un=Ge(([{log:e}])=>{const t=oe(!1),n=Xt(Q(t,Te(r=>r),lt()));return Ze(t,r=>{r&&mt(e)("props updated",{},zt.DEBUG)}),{didMount:n,propsReady:t}},at(zn),{singleton:!0}),oC=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function fh(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!oC)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const wo=Ge(([{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=He(),v=He(),g=oe(0);let x=null,y=null,b=null;function C(){x&&(x(),x=null),b&&(b(),b=null),y&&(clearTimeout(y),y=null),Pe(l,!1)}return ge(Q(f,Re(n,h,r,g,a,i,m),Re(e,s,o),fe(([[k,S,T,E,A,R,$,F],V,X,_])=>{const G=fh(k),{align:H,behavior:z,offset:D}=G,I=E-1,Y=ch(G,S,I);let J=vo(Y,S.offsetTree,V)+R;H==="end"?(J+=X+dn(S.sizeTree,Y)[1]-T+_,Y===I&&(J+=$)):H==="center"?J+=(X+dn(S.sizeTree,Y)[1]-T+_)/2:J-=A,D&&(J+=D);const j=B=>{C(),B?(F("retrying to scroll to",{location:k},zt.DEBUG),Pe(f,k)):(Pe(v,!0),F("list did not change, scroll successful",{},zt.DEBUG))};if(C(),z==="smooth"){let B=!1;b=Ze(t,P=>{B=B||P}),x=un(d,()=>{j(B)})}else x=un(Q(t,sC(150)),j);return y=setTimeout(()=>{C()},1200),Pe(l,!0),F("scrolling from index to",{behavior:z,index:Y,top:J},zt.DEBUG),{behavior:z,top:J}})),c),{scrollTargetReached:v,scrollToIndex:f,topListHeight:g}},at(kn,Dt,zn),{singleton:!0});function sC(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function $a(e,t){e==0?t():requestAnimationFrame(()=>{$a(e-1,t)})}function Fa(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const bo=Ge(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:s},{didMount:i}])=>{const a=oe(!0),l=oe(0),c=oe(!0);return ge(Q(i,Re(l),Te(([d,h])=>!!h),Cn(!1)),a),ge(Q(i,Re(l),Te(([d,h])=>!!h),Cn(!1)),c),Ze(Q(wt(t,i),Re(a,n,e,c),Te(([[,d],h,{sizeTree:m},f,v])=>d&&(!rt(m)||Ia(f))&&!h&&!v),Re(l)),([,d])=>{un(o,()=>{Pe(c,!0)}),$a(4,()=>{un(r,()=>{Pe(a,!0)}),Pe(s,d)})}),{initialItemFinalLocationReached:c,initialTopMostItemIndex:l,scrolledToInitialItem:a}},at(kn,Dt,wo,Un),{singleton:!0});function hh(e,t){return Math.abs(e-t)<1.01}const yo="up",So="down",iC="none",aC={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},lC=0,Co=Ge(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=oe(!1),a=oe(!0),l=He(),c=He(),d=oe(4),h=oe(lC),m=Pt(Q(Aa(Q(Se(o),nr(1),Cn(!0)),Q(Se(o),nr(1),Cn(!1),Xf(100))),lt()),!1),f=Pt(Q(Aa(Q(n,Cn(!0)),Q(n,Cn(!1),Xf(200))),lt()),!1);ge(Q(wt(Se(o),Se(h)),fe(([b,C])=>b<=C),lt()),a),ge(Q(a,Pn(50)),c);const v=Xt(Q(wt(r,Se(s),Se(t),Se(e),Se(d)),Tn((b,[{scrollHeight:C,scrollTop:k},S,T,E,A])=>{const R=k+S-C>-A,$={scrollHeight:C,scrollTop:k,viewportHeight:S};if(R){let V,X;return k>b.state.scrollTop?(V="SCROLLED_DOWN",X=b.state.scrollTop-k):(V="SIZE_DECREASED",X=b.state.scrollTop-k||b.scrollTopDelta),{atBottom:!0,atBottomBecause:V,scrollTopDelta:X,state:$}}let F;return $.scrollHeight>b.state.scrollHeight?F="SIZE_INCREASED":S<b.state.viewportHeight?F="VIEWPORT_HEIGHT_DECREASING":k<b.state.scrollTop?F="SCROLLING_UPWARDS":F="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:F,state:$}},aC),lt((b,C)=>b&&b.atBottom===C.atBottom))),g=Pt(Q(r,Tn((b,{scrollHeight:C,scrollTop:k,viewportHeight:S})=>{if(hh(b.scrollHeight,C))return{changed:!1,jump:0,scrollHeight:C,scrollTop:k};{const T=C-(k+S)<1;return b.scrollTop!==k&&T?{changed:!0,jump:b.scrollTop-k,scrollHeight:C,scrollTop:k}:{changed:!0,jump:0,scrollHeight:C,scrollTop:k}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),Te(b=>b.changed),fe(b=>b.jump)),0);ge(Q(v,fe(b=>b.atBottom)),i),ge(Q(i,Pn(50)),l);const x=oe(So);ge(Q(r,fe(({scrollTop:b})=>b),lt(),Tn((b,C)=>mt(f)?{direction:b.direction,prevScrollTop:C}:{direction:C<b.prevScrollTop?yo:So,prevScrollTop:C},{direction:So,prevScrollTop:0}),fe(b=>b.direction)),x),ge(Q(r,Pn(50),Cn(iC)),x);const y=oe(0);return ge(Q(m,Te(b=>!b),Cn(0)),y),ge(Q(o,Pn(100),Re(m),Te(([b,C])=>!!C),Tn(([b,C],[k])=>[C,k],[0,0]),fe(([b,C])=>C-b)),y),{atBottomState:v,atBottomStateChange:l,atBottomThreshold:d,atTopStateChange:c,atTopThreshold:h,isAtBottom:i,isAtTop:a,isScrolling:m,lastJumpDueToItemResize:g,scrollDirection:x,scrollVelocity:y}},at(Dt)),_s="top",Rs="bottom",ph="none";function mh(e,t,n){return typeof e=="number"?n===yo&&t===_s||n===So&&t===Rs?e:0:n===yo?t===_s?e.main:e.reverse:t===Rs?e.main:e.reverse}function gh(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const Ba=Ge(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=He(),i=oe(0),a=oe(0),l=oe(0),c=Pt(Q(wt(Se(r),Se(o),Se(n),Se(s,xo),Se(l),Se(i),Se(t),Se(e),Se(a)),fe(([d,h,m,[f,v],g,x,y,b,C])=>{const k=d-b,S=x+y,T=Math.max(m-k,0);let E=ph;const A=gh(C,_s),R=gh(C,Rs);return f-=b,f+=m+y,v+=m+y,v-=b,f>d+S-A&&(E=yo),v<d-T+h+R&&(E=So),E!==ph?[Math.max(k-m-mh(g,_s,E)-A,0),k-T-y+h+mh(g,Rs,E)+R]:null}),Te(d=>d!=null),lt(xo)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:l,topListHeight:i,visibleRange:c}},at(Dt),{singleton:!0});function cC(e,t,n){if(Ps(t)){const r=lh(e,t);return[{index:dn(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 za={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Ms(e,t,n,r,o,s){const{lastIndex:i,lastOffset:a,lastSize:l}=o;let c=0,d=0;if(e.length>0){c=e[0].offset;const g=e[e.length-1];d=g.offset+g.size}const h=n-i,m=a+h*l+(h-1)*r,f=c,v=m-d;return{bottom:d,firstItemIndex:s,items:vh(e,o,s),offsetBottom:v,offsetTop:c,top:f,topItems:vh(t,o,s),topListHeight:t.reduce((g,x)=>x.size+g,0),totalCount:n}}function xh(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=Fa(t,a),c=Array.from({length:a}).map((d,h)=>({data:s[h+l],index:h+l,offset:0,size:0}));return Ms(c,[],a,o,n,r)}function vh(e,t,n){if(e.length===0)return[];if(!Ps(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=Ns(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 sr=Ge(([{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=oe([]),x=oe(0),y=He();ge(s.topItemsIndexes,g);const b=Pt(Q(wt(f,v,Se(l,xo),Se(o),Se(r),Se(c),d,Se(g),Se(t),Se(n),e),Te(([T,E,,A,,,,,,,R])=>{const $=R&&R.length!==A;return T&&!E&&!$}),fe(([,,[T,E],A,R,$,F,V,X,_,G])=>{const H=R,{offsetTree:z,sizeTree:D}=H,I=mt(x);if(A===0)return{...za,totalCount:A};if(T===0&&E===0)return I===0?{...za,totalCount:A}:xh(I,$,R,X,_,G||[]);if(rt(D))return I>0?null:Ms(cC(Fa($,A),H,G),[],A,_,H,X);const Y=[];if(V.length>0){const O=V[0],K=V[V.length-1];let M=0;for(const L of Ns(D,O,K)){const q=L.value,Z=Math.max(L.start,O),se=Math.min(L.end,K);for(let ie=Z;ie<=se;ie++)Y.push({data:G==null?void 0:G[ie],index:ie,offset:M,size:q}),M+=q}}if(!F)return Ms([],Y,A,_,H,X);const J=V.length>0?V[V.length-1]+1:0,j=JS(z,T,E,J);if(j.length===0)return null;const B=A-1,P=Is([],O=>{for(const K of j){const M=K.value;let L=M.offset,q=K.start;const Z=M.size;if(M.offset<T){q+=Math.floor((T-M.offset+_)/(Z+_));const ie=q-K.start;L+=ie*Z+ie*_}q<J&&(L+=(J-q)*Z,q=J);const se=Math.min(K.end,B);for(let ie=q;ie<=se&&!(L>=E);ie++)O.push({data:G==null?void 0:G[ie],index:ie,offset:L,size:Z}),L+=Z+_}});return Ms(P,Y,A,_,H,X)}),Te(T=>T!==null),lt()),za);ge(Q(e,Te(Ia),fe(T=>T==null?void 0:T.length)),o),ge(Q(b,fe(T=>T.topListHeight)),h),ge(h,a),ge(Q(b,fe(T=>[T.top,T.bottom])),i),ge(Q(b,fe(T=>T.items)),y);const C=Xt(Q(b,Te(({items:T})=>T.length>0),Re(o,e),Te(([{items:T},E])=>T[T.length-1].originalIndex===E-1),fe(([,T,E])=>[T-1,E]),lt(xo),fe(([T])=>T))),k=Xt(Q(b,Pn(200),Te(({items:T,topItems:E})=>T.length>0&&T[0].originalIndex===E.length),fe(({items:T})=>T[0].index),lt())),S=Xt(Q(b,Te(({items:T})=>T.length>0),fe(({items:T})=>{let E=0,A=T.length-1;for(;T[E].type==="group"&&E<A;)E++;for(;T[A].type==="group"&&A>E;)A--;return{endIndex:T[A].index,startIndex:T[E].index}}),lt(ih)));return{endReached:C,initialItemCount:x,itemsRendered:y,listState:b,rangeChanged:S,startReached:k,topItemsIndexes:g,...m}},at(kn,dh,Ba,bo,wo,Co,Un,Oa),{singleton:!0}),wh=Ge(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=He(),i=Pt(Q(wt(n,e,r,t,o),fe(([a,l,c,d,h])=>a+l+c+d+h.offsetBottom+h.bottom)),0);return ge(Se(i),s),{totalListHeight:i,totalListHeightChanged:s}},at(Dt,sr),{singleton:!0}),uC=Ge(([{viewportHeight:e},{totalListHeight:t}])=>{const n=oe(!1),r=Pt(Q(wt(n,e,t),Te(([o])=>o),fe(([,o,s])=>Math.max(0,o-s)),Pn(0),lt()),0);return{alignToBottom:n,paddingTopAddition:r}},at(Dt,wh),{singleton:!0}),bh=Ge(()=>({context:oe(null)})),dC=({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,yh=Ge(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:s,scrollingInProgress:i,scrollTop:a,viewportHeight:l},{scrollToIndex:c}])=>{const d=He();return ge(Q(d,Re(t,l,n,s,o,r,a),Re(e),fe(([[h,m,f,v,g,x,y,b],C])=>{const{align:k,behavior:S,calculateViewLocation:T=dC,done:E,...A}=h,R=ch(h,m,v-1),$=vo(R,m.offsetTree,C)+g+x,F=$+dn(m.sizeTree,R)[1],V=b+x,X=b+f-y,_=T({itemBottom:F,itemTop:$,locationParams:{align:k,behavior:S,...A},viewportBottom:X,viewportTop:V});return _?E&&un(Q(i,Te(G=>!G),nr(mt(i)?1:2)),E):E&&E(),_}),Te(h=>h!==null)),c),{scrollIntoView:d}},at(kn,Dt,wo,sr,zn),{singleton:!0});function Sh(e){return e?e==="smooth"?"smooth":"auto":!1}const fC=(e,t)=>typeof e=="function"?Sh(e(t)):t&&Sh(e),hC=Ge(([{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=oe(!1),g=He();let x=null;function y(S){Pe(i,{align:"end",behavior:S,index:"LAST"})}Ze(Q(wt(Q(Se(t),nr(1)),l),Re(Se(v),s,a,h),fe(([[S,T],E,A,R,$])=>{let F=T&&R,V="auto";return F&&(V=fC(E,A||$),F=F&&!!V),{followOutputBehavior:V,shouldFollow:F,totalCount:S}}),Te(({shouldFollow:S})=>S)),({followOutputBehavior:S,totalCount:T})=>{x&&(x(),x=null),mt(n)?requestAnimationFrame(()=>{mt(d)("following output to ",{totalCount:T},zt.DEBUG),y(S)}):x=un(e,()=>{mt(d)("following output to ",{totalCount:T},zt.DEBUG),y(S),x=null})});function b(S){const T=un(o,E=>{S&&!E.atBottom&&E.notAtBottomBecause==="SIZE_INCREASED"&&!x&&(mt(d)("scrolling to bottom due to increased size",{},zt.DEBUG),y("auto"))});setTimeout(T,100)}Ze(Q(wt(Se(v),t,c),Te(([S,,T])=>S&&T),Tn(({value:S},[,T])=>({refreshed:S===T,value:T}),{refreshed:!1,value:0}),Te(({refreshed:S})=>S),Re(v,t)),([,S])=>{mt(a)&&b(S!==!1)}),Ze(g,()=>{b(mt(v)!==!1)}),Ze(wt(Se(v),o),([S,T])=>{S&&!T.atBottom&&T.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&y("auto")});const C=oe(null),k=He();return ge(Aa(Q(Se(r),fe(S=>{var T;return(T=S==null?void 0:S.length)!=null?T:0})),Q(Se(t))),k),Ze(Q(wt(Q(k,nr(1)),l),Re(Se(C),a,h,m),fe(([[S,T],E,A,R,$])=>T&&A&&(E==null?void 0:E({context:$,totalCount:S,scrollingInProgress:R}))),Te(S=>!!S),Pn(0)),S=>{x&&(x(),x=null),mt(n)?requestAnimationFrame(()=>{mt(d)("scrolling into view",{}),Pe(f,S)}):x=un(e,()=>{mt(d)("scrolling into view",{}),Pe(f,S),x=null})}),{autoscrollToBottom:g,followOutput:v,scrollIntoViewOnChange:C}},at(kn,Co,wo,bo,Un,zn,Dt,bh,yh)),pC=Ge(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(ge(Q(a,Re(s),Te(([,l])=>l!==0),Re(o,r,t,n,e),fe(([[,l],c,d,h,m,f=[]])=>xh(l,c,d,h,m,f))),i),{}),at(kn,bo,sr,Un),{singleton:!0}),mC=Ge(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=oe(0);return Ze(Q(e,Re(r),Te(([,o])=>o!==0),fe(([,o])=>({top:o}))),o=>{un(Q(n,nr(1),Te(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{Pe(t,o)})})}),{initialScrollTop:r}},at(Un,Dt,sr),{singleton:!0}),Ch=Ge(([{scrollVelocity:e}])=>{const t=oe(!1),n=He(),r=oe(!1);return ge(Q(e,Re(r,t,n),Te(([o,s])=>!!s),fe(([o,s,i,a])=>{const{enter:l,exit:c}=s;if(i){if(c(o,a))return!1}else if(l(o,a))return!0;return i}),lt()),t),Ze(Q(wt(t,e,n),Re(r)),([[o,s,i],a])=>{o&&a&&a.change&&a.change(s,i)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},at(Co),{singleton:!0}),Ha=Ge(([{scrollContainerState:e,scrollTo:t}])=>{const n=He(),r=He(),o=He(),s=oe(!1),i=oe(void 0);return ge(Q(wt(n,r),fe(([{scrollHeight:a,scrollTop:l,viewportHeight:c},{offsetTop:d}])=>({scrollHeight:a,scrollTop:Math.max(0,l-d),viewportHeight:c}))),e),ge(Q(t,Re(r),fe(([a,{offsetTop:l}])=>({...a,top:a.top+l}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},at(Dt)),gC=Ge(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:a,windowViewportRect:l}])=>{const c=He(),d=oe(void 0),h=oe(null),m=oe(null);return ge(a,h),ge(l,m),Ze(Q(c,Re(t,r,i,h,m,n)),([f,v,g,x,y,b,C])=>{const k=QS(v.sizeTree);x&&y!==null&&b!==null&&(g=y.scrollTop-b.offsetTop),g-=C,f({ranges:k,scrollTop:g})}),ge(Q(d,Te(Ia),fe(xC)),o),ge(Q(s,Re(d),Te(([,f])=>f!==void 0),lt(),fe(([,f])=>f.ranges)),e),{getState:c,restoreStateFrom:d}},at(kn,Dt,bo,Un,Ha));function xC(e){return{align:"start",index:0,offset:e.scrollTop}}const vC=Ge(([{topItemsIndexes:e}])=>{const t=oe(0);return ge(Q(t,Te(n=>n>=0),fe(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},at(sr));function Th(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const wC=Th(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),bC=Ge(([{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=Xt(Q(l,Re(i),Tn(([,y,b,C],[{bottom:k,items:S,offsetBottom:T,totalCount:E},A])=>{const R=k+T;let $=0;return b===E&&y.length>0&&S.length>0&&(S[0].originalIndex===0&&y[0].originalIndex===0||($=R-C,$!==0&&($+=A))),[$,S,E,R]},[0,[],0,0]),Te(([y])=>y!==0),Re(r,a,n,o,f,v),Te(([,y,b,C,,,k])=>!k&&!C&&y!==0&&b===yo),fe(([[y],,,,,b])=>(b("Upward scrolling compensation",{amount:y},zt.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 Ze(Q(g,Re(e,s)),([y,b,C])=>{C&&wC()?Pe(e,b-y):x(-y)}),Ze(Q(wt(Pt(s,!1),e,v),Te(([y,b,C])=>!y&&!C&&b!==0),fe(([y,b])=>b),Pn(1)),x),ge(Q(h,fe(y=>({top:-y}))),t),Ze(Q(c,Re(m,d),fe(([y,{groupIndices:b,lastSize:C,sizeTree:k},S])=>{function T(E){return E*(C+S)}if(b.length===0)return T(y);{let E=0;const A=go(k,0);let R=0,$=0;for(;R<y;){R++,E+=A;let F=b.length===$+1?1/0:b[$+1]-b[$]-1;R+F>y&&(E-=A,F=y-R+1),R+=F,E+=T(F),$++}return E}})),y=>{Pe(e,y),requestAnimationFrame(()=>{Pe(t,{top:y}),requestAnimationFrame(()=>{Pe(e,0),Pe(v,!1)})})}),{deviation:e}},at(Dt,Co,sr,kn,zn,Oa)),yC=Ge(([e,t,n,r,o,s,i,a,l,c,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...l,...c,...d}),at(Ba,pC,Un,Ch,wh,mC,uC,Ha,yh,zn,bh)),kh=Ge(([{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:b,topItemsIndexes:C,...k},{scrollToIndex:S},T,{topItemCount:E},{groupCounts:A},R])=>(ge(k.rangeChanged,R.scrollSeekRangeChanged),ge(Q(R.windowViewportRect,fe($=>$.visibleHeight)),g.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,gap:o,groupCounts:A,initialItemFinalLocationReached:m,initialTopMostItemIndex:f,scrolledToInitialItem:v,sizeRanges:a,topItemCount:E,topItemsIndexes:C,totalCount:d,...y,groupIndices:s,itemSize:i,listState:b,scrollToIndex:S,statefulTotalCount:c,trackItemSizes:h,...k,...R,...g,sizes:l,...x}),at(kn,bo,Dt,gC,hC,sr,wo,bC,vC,dh,yC));function SC(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 Os=typeof document<"u"?w.useLayoutEffect:w.useEffect;function Eh(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=w.createContext({});function l(x,y){x.propsReady&&Pe(x.propsReady,!1);for(const b of r){const C=x[t.required[b]];Pe(C,y[b])}for(const b of o)if(b in y){const C=x[t.optional[b]];Pe(C,y[b])}x.propsReady&&Pe(x.propsReady,!0)}function c(x){return s.reduce((y,b)=>(y[b]=C=>{const k=x[t.methods[b]];Pe(k,C)},y),{})}function d(x){return i.reduce((y,b)=>(y[b]=$S(x[t.events[b]]),y),{})}const h=w.forwardRef((x,y)=>{const{children:b,...C}=x,[k]=w.useState(()=>Is(BS(e),E=>{l(E,C)})),[S]=w.useState(Yf(d,k));Os(()=>{for(const E of i)E in C&&Ze(S[E],C[E]);return()=>{Object.values(S).map(Na)}},[C,S,k]),Os(()=>{l(k,C)}),w.useImperativeHandle(y,qf(c(k)));const T=n;return u.jsx(a.Provider,{value:k,children:n?u.jsx(T,{...SC([...r,...o,...i],C),children:b}):b})}),m=x=>{const y=w.useContext(a);return w.useCallback(b=>{Pe(y[x],b)},[y,x])},f=x=>{const y=w.useContext(a)[x],b=w.useCallback(C=>Ze(y,C),[y]);return w.useSyncExternalStore(b,()=>mt(y),()=>mt(y))},v=x=>{const y=w.useContext(a)[x],[b,C]=w.useState(Yf(mt,y));return Os(()=>Ze(y,k=>{k!==b&&C(qf(k))}),[y,b]),b},g=w.version.startsWith("18")?f:v;return{Component:h,useEmitter:(x,y)=>{const b=w.useContext(a)[x];Os(()=>Ze(b,y),[y,b])},useEmitterValue:g,usePublisher:m}}const Ih=w.createContext(void 0),Nh=w.createContext(void 0),Ah=typeof document<"u"?w.useLayoutEffect:w.useEffect;function Ua(e){return"self"in e}function CC(e){return"body"in e}function jh(e,t,n,r=Rr,o,s){const i=w.useRef(null),a=w.useRef(null),l=w.useRef(null),c=w.useCallback(m=>{let f,v,g;const x=m.target;if(CC(x)||Ua(x)){const b=Ua(x)?x:x.defaultView;g=s?b.scrollX:b.scrollY,f=s?b.document.documentElement.scrollWidth:b.document.documentElement.scrollHeight,v=s?b.innerWidth:b.innerHeight}else g=s?x.scrollLeft:x.scrollTop,f=s?x.scrollWidth:x.scrollHeight,v=s?x.offsetWidth:x.offsetHeight;const y=()=>{e({scrollHeight:f,scrollTop:Math.max(g,0),viewportHeight:v})};m.suppressFlushSync?y():Mo.flushSync(y),a.current!==null&&(g===a.current||g<=0||g===f-v)&&(a.current=null,t(!0),l.current&&(clearTimeout(l.current),l.current=null))},[e,t,s]);w.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;Ua(f)?(x=Math.max(Hn(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=Hn(f,s?"width":"height"),y=f[s?"scrollLeft":"scrollTop"]);const b=x-g;if(m.top=Math.ceil(Math.max(Math.min(b,m.top),0)),hh(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 Wa="-webkit-sticky",Ph="sticky",Va=Th(()=>{if(typeof document>"u")return Ph;const e=document.createElement("div");return e.style.position=Wa,e.style.position===Wa?Wa:Ph});function Ka(e){return e}const TC=Ge(()=>{const e=oe(a=>`Item ${a}`),t=oe(a=>`Group ${a}`),n=oe({}),r=oe(Ka),o=oe("div"),s=oe(Rr),i=(a,l=null)=>Pt(Q(n,fe(c=>c[a]),lt()),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")}}),kC=Ge(([e,t])=>({...e,...t}),at(kh,TC)),EC=({height:e})=>u.jsx("div",{style:{height:e}}),IC={overflowAnchor:"none",position:Va(),zIndex:1},_h={overflowAnchor:"none"},NC={..._h,display:"inline-block",height:"100%"},Rh=w.memo(function({showTopList:e=!1}){const t=Ie("listState"),n=en("sizeRanges"),r=Ie("useWindowScroll"),o=Ie("customScrollParent"),s=en("windowScrollContainerState"),i=en("scrollContainerState"),a=o||r?s:i,l=Ie("itemContent"),c=Ie("context"),d=Ie("groupContent"),h=Ie("trackItemSizes"),m=Ie("itemSize"),f=Ie("log"),v=en("gap"),g=Ie("horizontalDirection"),{callbackRef:x}=US(n,m,h,e?Rr:a,f,v,o,g,Ie("skipAnimationFrameInResizeObserver")),[y,b]=w.useState(0);qa("deviation",_=>{y!==_&&b(_)});const C=Ie("EmptyPlaceholder"),k=Ie("ScrollSeekPlaceholder")||EC,S=Ie("ListComponent"),T=Ie("ItemComponent"),E=Ie("GroupComponent"),A=Ie("computeItemKey"),R=Ie("isSeeking"),$=Ie("groupIndices").length>0,F=Ie("alignToBottom"),V=Ie("initialItemFinalLocationReached"),X=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},...V?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&C?u.jsx(C,{..._t(C,c)}):u.jsx(S,{..._t(S,c),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:x,style:X,children:(e?t.topItems:t.items).map(_=>{const G=_.originalIndex,H=A(G+t.firstItemIndex,_.data,c);return R?w.createElement(k,{..._t(k,c),height:_.size,index:_.index,key:H,type:_.type||"item",..._.type==="group"?{}:{groupIndex:_.groupIndex}}):_.type==="group"?w.createElement(E,{..._t(E,c),"data-index":G,"data-item-index":_.index,"data-known-size":_.size,key:H,style:IC},d(_.index,c)):w.createElement(T,{..._t(T,c),..._C(T,_.data),"data-index":G,"data-item-group-index":_.groupIndex,"data-item-index":_.index,"data-known-size":_.size,key:H,style:g?NC:_h},$?l(_.index,_.groupIndex,_.data,c):l(_.index,_.data,c))})})}),AC={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},jC={outline:"none",overflowX:"auto",position:"relative"},Ds=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),PC={position:Va(),top:0,width:"100%",zIndex:1};function _t(e,t){if(typeof e!="string")return{context:t}}function _C(e,t){return{item:typeof e=="string"?void 0:t}}const RC=w.memo(function(){const e=Ie("HeaderComponent"),t=en("headerHeight"),n=Ie("HeaderFooterTag"),r=rr(w.useMemo(()=>s=>{t(Hn(s,"height"))},[t]),!0,Ie("skipAnimationFrameInResizeObserver")),o=Ie("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{..._t(e,o)})}):null}),MC=w.memo(function(){const e=Ie("FooterComponent"),t=en("footerHeight"),n=Ie("HeaderFooterTag"),r=rr(w.useMemo(()=>s=>{t(Hn(s,"height"))},[t]),!0,Ie("skipAnimationFrameInResizeObserver")),o=Ie("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{..._t(e,o)})}):null});function Mh({useEmitter:e,useEmitterValue:t,usePublisher:n}){return w.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}=jh(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?jC:AC,...o},tabIndex:0,...i,..._t(l,s),children:r})})}function Oh({useEmitter:e,useEmitterValue:t,usePublisher:n}){return w.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=w.useRef(null),v=t("scrollerRef"),{scrollByCallback:g,scrollerRef:x,scrollToCallback:y}=jh(a,c,l,v,m);return Ah(()=>{var b;return x.current=m||((b=f.current)==null?void 0:b.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,..._t(l,s),children:r})})}const OC=({children:e})=>{const t=w.useContext(Ih),n=en("viewportHeight"),r=en("fixedItemHeight"),o=Ie("alignToBottom"),s=Ie("horizontalDirection"),i=w.useMemo(()=>Gf(n,l=>Hn(l,s?"width":"height")),[n,s]),a=rr(i,!0,Ie("skipAnimationFrameInResizeObserver"));return w.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),u.jsx("div",{"data-viewport-type":"element",ref:a,style:Ds(o),children:e})},DC=({children:e})=>{const t=w.useContext(Ih),n=en("windowViewportRect"),r=en("fixedItemHeight"),o=Ie("customScrollParent"),s=Qf(n,o,Ie("skipAnimationFrameInResizeObserver")),i=Ie("alignToBottom");return w.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:Ds(i),children:e})},LC=({children:e})=>{const t=Ie("TopItemListComponent")||"div",n=Ie("headerHeight"),r={...PC,marginTop:`${n}px`},o=Ie("context");return u.jsx(t,{style:r,..._t(t,o),children:e})},$C=w.memo(function(e){const t=Ie("useWindowScroll"),n=Ie("topItemsIndexes").length>0,r=Ie("customScrollParent"),o=Ie("context");return u.jsxs(r||t?zC:BC,{...e,context:o,children:[n&&u.jsx(LC,{children:u.jsx(Rh,{showTopList:!0})}),u.jsxs(r||t?DC:OC,{children:[u.jsx(RC,{}),u.jsx(Rh,{}),u.jsx(MC,{})]})]})}),{Component:FC,useEmitter:qa,useEmitterValue:Ie,usePublisher:en}=Eh(kC,{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"}},$C),BC=Mh({useEmitter:qa,useEmitterValue:Ie,usePublisher:en}),zC=Oh({useEmitter:qa,useEmitterValue:Ie,usePublisher:en}),HC=FC;at(kh,Ge(()=>{const e=oe(c=>u.jsxs("td",{children:["Item $",c]})),t=oe(null),n=oe(c=>u.jsxs("td",{colSpan:1e3,children:["Group ",c]})),r=oe(null),o=oe(null),s=oe({}),i=oe(Ka),a=oe(Rr),l=(c,d=null)=>Pt(Q(s,fe(h=>h[c]),lt()),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")}})),Va();const Dh={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},UC={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:Lh,floor:Ls,max:To,min:Ga,round:$h}=Math;function Fh(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function WC(e){return{...UC,items:e}}function $s(e,t){return e&&e.width===t.width&&e.height===t.height}function VC(e,t){return e&&e.column===t.column&&e.row===t.row}const KC=Ge(([{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:b,windowScrollTo:C,windowViewportRect:k},S])=>{const T=oe(0),E=oe(0),A=oe(Dh),R=oe({height:0,width:0}),$=oe({height:0,width:0}),F=He(),V=He(),X=oe(0),_=oe(null),G=oe({column:0,row:0}),H=He(),z=He(),D=oe(!1),I=oe(0),Y=oe(!0),J=oe(!1),j=oe(!1);Ze(Q(v,Re(I),Te(([L,q])=>!!q)),()=>{Pe(Y,!1)}),Ze(Q(wt(v,Y,$,R,I,J),Te(([L,q,Z,se,,ie])=>L&&!q&&Z.height!==0&&se.height!==0&&!ie)),([,,,,L])=>{Pe(J,!0),$a(1,()=>{Pe(F,L)}),un(Q(c),()=>{Pe(t,[0,0]),Pe(Y,!0)})}),ge(Q(z,Te(L=>L!=null&&L.scrollTop>0),Cn(0)),E),Ze(Q(v,Re(z),Te(([,L])=>L!=null)),([,L])=>{L&&(Pe(R,L.viewport),Pe($,L.item),Pe(G,L.gap),L.scrollTop>0&&(Pe(D,!0),un(Q(c,nr(1)),q=>{Pe(D,!1)}),Pe(l,{top:L.scrollTop})))}),ge(Q(R,fe(({height:L})=>L)),h),ge(Q(wt(Se(R,$s),Se($,$s),Se(G,(L,q)=>L&&L.column===q.column&&L.row===q.row),Se(c)),fe(([L,q,Z,se])=>({gap:Z,item:q,scrollTop:se,viewport:L}))),H),ge(Q(wt(Se(T),r,Se(G,VC),Se($,$s),Se(R,$s),Se(_),Se(E),Se(D),Se(Y),Se(I)),Te(([,,,,,,,L])=>!L),fe(([L,[q,Z],se,ie,re,de,be,,Me,Fe])=>{const{column:De,row:Le}=se,{height:it,width:dt}=ie,{width:Et}=re;if(be===0&&(L===0||Et===0))return Dh;if(dt===0){const Ct=Fa(Fe,L),gt=Ct+Math.max(be-1,0);return WC(Fh(Ct,gt,de))}const Ke=Bh(Et,dt,De);let We,Xe;Me?q===0&&Z===0&&be>0?(We=0,Xe=be-1):(We=Ke*Ls((q+Le)/(it+Le)),Xe=Ke*Lh((Z+Le)/(it+Le))-1,Xe=Ga(L-1,To(Xe,Ke-1)),We=Ga(Xe,To(0,We))):(We=0,Xe=-1);const ke=Fh(We,Xe,de),{bottom:Ue,top:ut}=zh(re,se,ie,ke),bt=Lh(L/Ke),Je=bt*it+(bt-1)*Le-Ue;return{bottom:Ue,itemHeight:it,items:ke,itemWidth:dt,offsetBottom:Je,offsetTop:ut,top:ut}})),A),ge(Q(_,Te(L=>L!==null),fe(L=>L.length)),T),ge(Q(wt(R,$,A,G),Te(([L,q,{items:Z}])=>Z.length>0&&q.height!==0&&L.height!==0),fe(([L,q,{items:Z},se])=>{const{bottom:ie,top:re}=zh(L,se,q,Z);return[re,ie]}),lt(xo)),t);const B=oe(!1);ge(Q(c,Re(B),fe(([L,q])=>q||L!==0)),B);const P=Xt(Q(wt(A,T),Te(([{items:L}])=>L.length>0),Re(B),Te(([[L,q],Z])=>{const se=L.items[L.items.length-1].index===q-1;return(Z||L.bottom>0&&L.itemHeight>0&&L.offsetBottom===0&&L.items.length===q)&&se}),fe(([[,L]])=>L-1),lt())),O=Xt(Q(Se(A),Te(({items:L})=>L.length>0&&L[0].index===0),Cn(0),lt())),K=Xt(Q(Se(A),Re(D),Te(([{items:L},q])=>L.length>0&&!q),fe(([{items:L}])=>({endIndex:L[L.length-1].index,startIndex:L[0].index})),lt(ih),Pn(0)));ge(K,f.scrollSeekRangeChanged),ge(Q(F,Re(R,$,T,G),fe(([L,q,Z,se,ie])=>{const re=fh(L),{align:de,behavior:be,offset:Me}=re;let Fe=re.index;Fe==="LAST"&&(Fe=se-1),Fe=To(0,Fe,Ga(se-1,Fe));let De=Ya(q,ie,Z,Fe);return de==="end"?De=$h(De-q.height+Z.height):de==="center"&&(De=$h(De-q.height/2+Z.height/2)),Me&&(De+=Me),{behavior:be,top:De}})),l);const M=Pt(Q(A,fe(L=>L.offsetBottom+L.bottom)),0);return ge(Q(k,fe(L=>({height:L.visibleHeight,width:L.visibleWidth}))),R),{customScrollParent:x,data:_,deviation:X,footerHeight:o,gap:G,headerHeight:s,increaseViewportBy:e,initialItemCount:E,itemDimensions:$,overscan:n,restoreStateFrom:z,scrollBy:i,scrollContainerState:a,scrollHeight:V,scrollTo:l,scrollToIndex:F,scrollTop:c,smoothScrollTargetReached:d,totalCount:T,useWindowScroll:y,viewportDimensions:R,windowScrollContainerState:b,windowScrollTo:C,windowViewportRect:k,...f,gridState:A,horizontalDirection:j,initialTopMostItemIndex:I,totalListHeight:M,...m,endReached:P,propsReady:g,rangeChanged:K,startReached:O,stateChanged:H,stateRestoreInProgress:D,...S}},at(Ba,Dt,Co,Ch,Un,Ha,zn));function Bh(e,t,n){return To(1,Ls((e+n)/(Ls(t)+n)))}function zh(e,t,n,r){const{height:o}=n;if(o===void 0||r.length===0)return{bottom:0,top:0};const s=Ya(e,t,n,r[0].index);return{bottom:Ya(e,t,n,r[r.length-1].index)+o,top:s}}function Ya(e,t,n,r){const o=Bh(e.width,n.width,t.column),s=Ls(r/o),i=s*n.height+To(0,s-1)*t.row;return i>0?i+t.row:i}const qC=Ge(()=>{const e=oe(h=>`Item ${h}`),t=oe({}),n=oe(null),r=oe("virtuoso-grid-item"),o=oe("virtuoso-grid-list"),s=oe(Ka),i=oe("div"),a=oe(Rr),l=(h,m=null)=>Pt(Q(t,fe(f=>f[h]),lt()),m),c=oe(!1),d=oe(!1);return ge(Se(d),c),{components:t,computeItemKey:s,context:n,FooterComponent:l("Footer"),HeaderComponent:l("Header"),headerFooterTag:i,itemClassName:r,ItemComponent:l("Item","div"),itemContent:e,listClassName:o,ListComponent:l("List","div"),readyStateChanged:c,reportReadyState:d,ScrollerComponent:l("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder","div")}}),GC=Ge(([e,t])=>({...e,...t}),at(KC,qC)),YC=w.memo(function(){const e=ct("gridState"),t=ct("listClassName"),n=ct("itemClassName"),r=ct("itemContent"),o=ct("computeItemKey"),s=ct("isSeeking"),i=tn("scrollHeight"),a=ct("ItemComponent"),l=ct("ListComponent"),c=ct("ScrollSeekPlaceholder"),d=ct("context"),h=tn("itemDimensions"),m=tn("gap"),f=ct("log"),v=ct("stateRestoreInProgress"),g=tn("reportReadyState"),x=rr(w.useMemo(()=>y=>{const b=y.parentElement.parentElement.scrollHeight;i(b);const C=y.firstChild;if(C){const{height:k,width:S}=C.getBoundingClientRect();h({height:k,width:S})}m({column:Uh("column-gap",getComputedStyle(y).columnGap,f),row:Uh("row-gap",getComputedStyle(y).rowGap,f)})},[i,h,m,f]),!0,!1);return Ah(()=>{e.itemHeight>0&&e.itemWidth>0&&g(!0)},[e]),v?null:u.jsx(l,{className:t,ref:x,..._t(l,d),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(y=>{const b=o(y.index,y.data,d);return s?u.jsx(c,{..._t(c,d),height:e.itemHeight,index:y.index,width:e.itemWidth},b):w.createElement(a,{..._t(a,d),className:n,"data-index":y.index,key:b},r(y.index,y.data,d))})})}),XC=w.memo(function(){const e=ct("HeaderComponent"),t=tn("headerHeight"),n=ct("headerFooterTag"),r=rr(w.useMemo(()=>s=>{t(Hn(s,"height"))},[t]),!0,!1),o=ct("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{..._t(e,o)})}):null}),JC=w.memo(function(){const e=ct("FooterComponent"),t=tn("footerHeight"),n=ct("headerFooterTag"),r=rr(w.useMemo(()=>s=>{t(Hn(s,"height"))},[t]),!0,!1),o=ct("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{..._t(e,o)})}):null}),ZC=({children:e})=>{const t=w.useContext(Nh),n=tn("itemDimensions"),r=tn("viewportDimensions"),o=rr(w.useMemo(()=>s=>{r(s.getBoundingClientRect())},[r]),!0,!1);return w.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:Ds(!1),children:e})},QC=({children:e})=>{const t=w.useContext(Nh),n=tn("windowViewportRect"),r=tn("itemDimensions"),o=ct("customScrollParent"),s=Qf(n,o,!1);return w.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:Ds(!1),children:e})},eT=w.memo(function({...e}){const t=ct("useWindowScroll"),n=ct("customScrollParent"),r=n||t?nT:tT,o=n||t?QC:ZC,s=ct("context");return u.jsx(r,{...e,..._t(r,s),children:u.jsxs(o,{children:[u.jsx(XC,{}),u.jsx(YC,{}),u.jsx(JC,{})]})})}),{useEmitter:Hh,useEmitterValue:ct,usePublisher:tn}=Eh(GC,{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"}},eT),tT=Mh({useEmitter:Hh,useEmitterValue:ct,usePublisher:tn}),nT=Oh({useEmitter:Hh,useEmitterValue:ct,usePublisher:tn});function Uh(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,zt.WARN),t==="normal"?0:parseInt(t??"0",10)}var Fs="Dialog",[Wh,M1]=an(Fs),[rT,fn]=Wh(Fs),Vh=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]=On({prop:r,defaultProp:o??!1,onChange:s,caller:Fs});return u.jsx(rT,{scope:t,triggerRef:a,contentRef:l,contentId:jt(),titleId:jt(),descriptionId:jt(),open:c,onOpenChange:d,onOpenToggle:p.useCallback(()=>d(h=>!h),[d]),modal:i,children:n})};Vh.displayName=Fs;var Kh="DialogTrigger",qh=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=fn(Kh,n),s=_e(t,o.triggerRef);return u.jsx(me.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Za(o.open),...r,ref:s,onClick:ae(e.onClick,o.onOpenToggle)})});qh.displayName=Kh;var Xa="DialogPortal",[oT,Gh]=Wh(Xa,{forceMount:void 0}),Yh=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=fn(Xa,t);return u.jsx(oT,{scope:t,forceMount:n,children:p.Children.map(r,i=>u.jsx(Bt,{present:n||s.open,children:u.jsx(io,{asChild:!0,container:o,children:i})}))})};Yh.displayName=Xa;var Bs="DialogOverlay",Xh=p.forwardRef((e,t)=>{const n=Gh(Bs,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=fn(Bs,e.__scopeDialog);return s.modal?u.jsx(Bt,{present:r||s.open,children:u.jsx(iT,{...o,ref:t})}):null});Xh.displayName=Bs;var sT=Vt.createSlot("DialogOverlay.RemoveScroll"),iT=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=fn(Bs,n);return u.jsx(vs,{as:sT,allowPinchZoom:!0,shards:[o.contentRef],children:u.jsx(me.div,{"data-state":Za(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),ir="DialogContent",Jh=p.forwardRef((e,t)=>{const n=Gh(ir,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=fn(ir,e.__scopeDialog);return u.jsx(Bt,{present:r||s.open,children:s.modal?u.jsx(aT,{...o,ref:t}):u.jsx(lT,{...o,ref:t})})});Jh.displayName=ir;var aT=p.forwardRef((e,t)=>{const n=fn(ir,e.__scopeDialog),r=p.useRef(null),o=_e(t,n.contentRef,r);return p.useEffect(()=>{const s=r.current;if(s)return ha(s)},[]),u.jsx(Zh,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ae(e.onCloseAutoFocus,s=>{var i;s.preventDefault(),(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:ae(e.onPointerDownOutside,s=>{const i=s.detail.originalEvent,a=i.button===0&&i.ctrlKey===!0;(i.button===2||a)&&s.preventDefault()}),onFocusOutside:ae(e.onFocusOutside,s=>s.preventDefault())})}),lT=p.forwardRef((e,t)=>{const n=fn(ir,e.__scopeDialog),r=p.useRef(!1),o=p.useRef(!1);return u.jsx(Zh,{...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()}})}),Zh=p.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=fn(ir,n),l=p.useRef(null),c=_e(t,l);return Wi(),u.jsxs(u.Fragment,{children:[u.jsx(Qo,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:u.jsx(Sr,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":Za(a.open),...i,ref:c,onDismiss:()=>a.onOpenChange(!1)})}),u.jsxs(u.Fragment,{children:[u.jsx(cT,{titleId:a.titleId}),u.jsx(dT,{contentRef:l,descriptionId:a.descriptionId})]})]})}),Ja="DialogTitle",Qh=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=fn(Ja,n);return u.jsx(me.h2,{id:o.titleId,...r,ref:t})});Qh.displayName=Ja;var ep="DialogDescription",tp=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=fn(ep,n);return u.jsx(me.p,{id:o.descriptionId,...r,ref:t})});tp.displayName=ep;var np="DialogClose",rp=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=fn(np,n);return u.jsx(me.button,{type:"button",...r,ref:t,onClick:ae(e.onClick,()=>o.onOpenChange(!1))})});rp.displayName=np;function Za(e){return e?"open":"closed"}var op="DialogTitleWarning",[O1,sp]=kw(op,{contentName:ir,titleName:Ja,docsSlug:"dialog"}),cT=({titleId:e})=>{const t=sp(op),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
79
+ `)},d0=0,Pr=[];function f0(e){var t=p.useRef([]),n=p.useRef([0,0]),r=p.useRef(),o=p.useState(d0++)[0],s=p.useState(zd)[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=Ry([e.lockRef.current],(e.shards||[]).map(Gd),!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=xs(g),b=n.current,C="deltaX"in g?g.deltaX:b[0]-y[0],k="deltaY"in g?g.deltaY:b[1]-y[1],S,T=g.target,E=Math.abs(C)>Math.abs(k)?"h":"v";if("touches"in g&&E==="h"&&T.type==="range")return!1;var j=Wd(E,T);if(!j)return!0;if(j?S=E:(S=E==="v"?"h":"v",j=Wd(E,T)),!j)return!1;if(!r.current&&"changedTouches"in g&&(C||k)&&(r.current=S),!S)return!0;var _=r.current||S;return l0(_,x,g,_==="h"?C:k)},[]),l=p.useCallback(function(g){var x=g;if(!(!Pr.length||Pr[Pr.length-1]!==s)){var y="deltaY"in x?qd(x):xs(x),b=t.current.filter(function(S){return S.name===x.type&&(S.target===x.target||x.target===S.shadowParent)&&c0(S.delta,y)})[0];if(b&&b.should){x.cancelable&&x.preventDefault();return}if(!b){var C=(i.current.shards||[]).map(Gd).filter(Boolean).filter(function(S){return S.contains(x.target)}),k=C.length>0?a(x,C[0]):!i.current.noIsolation;k&&x.cancelable&&x.preventDefault()}}},[]),c=p.useCallback(function(g,x,y,b){var C={name:g,delta:x,target:y,should:b,shadowParent:h0(y)};t.current.push(C),setTimeout(function(){t.current=t.current.filter(function(k){return k!==C})},1)},[]),d=p.useCallback(function(g){n.current=xs(g),r.current=void 0},[]),h=p.useCallback(function(g){c(g.type,qd(g),g.target,a(g,e.lockRef.current))},[]),m=p.useCallback(function(g){c(g.type,xs(g),g.target,a(g,e.lockRef.current))},[]);p.useEffect(function(){return Pr.push(s),e.setCallbacks({onScrollCapture:h,onWheelCapture:h,onTouchMoveCapture:m}),document.addEventListener("wheel",l,jr),document.addEventListener("touchmove",l,jr),document.addEventListener("touchstart",d,jr),function(){Pr=Pr.filter(function(g){return g!==s}),document.removeEventListener("wheel",l,jr),document.removeEventListener("touchmove",l,jr),document.removeEventListener("touchstart",d,jr)}},[]);var f=e.removeScrollBar,v=e.inert;return p.createElement(p.Fragment,null,v?p.createElement(s,{styles:u0(o)}):null,f?p.createElement(t0,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function h0(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const p0=Hy(Bd,f0);var vs=p.forwardRef(function(e,t){return p.createElement(ms,Sn({},e,{ref:t,sideCar:p0}))});vs.classNames=ms.classNames;var va=["Enter"," "],m0=["ArrowDown","PageUp","Home"],Yd=["ArrowUp","PageDown","End"],g0=[...m0,...Yd],x0={ltr:[...va,"ArrowRight"],rtl:[...va,"ArrowLeft"]},v0={ltr:["ArrowLeft"],rtl:["ArrowRight"]},lo="Menu",[co,w0,b0]=Jo(lo),[er,Xd]=an(lo,[b0,Ir,Pd]),ws=Ir(),Jd=Pd(),[y0,tr]=er(lo),[S0,uo]=er(lo),Zd=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=ws(t),[l,c]=p.useState(null),d=p.useRef(!1),h=pt(s),m=Zo(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(ia,{...a,children:u.jsx(y0,{scope:t,open:n,onOpenChange:h,content:l,onContentChange:c,children:u.jsx(S0,{scope:t,onClose:p.useCallback(()=>h(!1),[h]),isUsingKeyboardRef:d,dir:m,modal:i,children:r})})})};Zd.displayName=lo;var C0="MenuAnchor",wa=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=ws(n);return u.jsx(aa,{...o,...r,ref:t})});wa.displayName=C0;var ba="MenuPortal",[T0,Qd]=er(ba,{forceMount:void 0}),ef=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=tr(ba,t);return u.jsx(T0,{scope:t,forceMount:n,children:u.jsx(Bt,{present:n||s.open,children:u.jsx(io,{asChild:!0,container:o,children:r})})})};ef.displayName=ba;var Qt="MenuContent",[k0,ya]=er(Qt),tf=p.forwardRef((e,t)=>{const n=Qd(Qt,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=tr(Qt,e.__scopeMenu),i=uo(Qt,e.__scopeMenu);return u.jsx(co.Provider,{scope:e.__scopeMenu,children:u.jsx(Bt,{present:r||s.open,children:u.jsx(co.Slot,{scope:e.__scopeMenu,children:i.modal?u.jsx(E0,{...o,ref:t}):u.jsx(I0,{...o,ref:t})})})})}),E0=p.forwardRef((e,t)=>{const n=tr(Qt,e.__scopeMenu),r=p.useRef(null),o=Me(t,r);return p.useEffect(()=>{const s=r.current;if(s)return ha(s)},[]),u.jsx(Sa,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:ae(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),I0=p.forwardRef((e,t)=>{const n=tr(Qt,e.__scopeMenu);return u.jsx(Sa,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),N0=Vt.createSlot("MenuContent.ScrollLock"),Sa=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=tr(Qt,n),y=uo(Qt,n),b=ws(n),C=Jd(n),k=w0(n),[S,T]=p.useState(null),E=p.useRef(null),j=Me(t,E,x.onContentChange),_=p.useRef(0),$=p.useRef(""),F=p.useRef(0),U=p.useRef(null),X=p.useRef("right"),R=p.useRef(0),K=v?vs:p.Fragment,W=v?{as:N0,allowPinchZoom:!0}:void 0,z=I=>{var M,L;const G=$.current+I,J=k().filter(Y=>!Y.disabled),P=document.activeElement,B=(M=J.find(Y=>Y.ref.current===P))==null?void 0:M.textValue,A=J.map(Y=>Y.textValue),D=B0(A,G,B),q=(L=J.find(Y=>Y.textValue===D))==null?void 0:L.ref.current;(function Y(Z){$.current=Z,window.clearTimeout(_.current),Z!==""&&(_.current=window.setTimeout(()=>Y(""),1e3))})(G),q&&setTimeout(()=>q.focus())};p.useEffect(()=>()=>window.clearTimeout(_.current),[]),Wi();const O=p.useCallback(I=>{var J,P;return X.current===((J=U.current)==null?void 0:J.side)&&H0(I,(P=U.current)==null?void 0:P.area)},[]);return u.jsx(k0,{scope:n,searchRef:$,onItemEnter:p.useCallback(I=>{O(I)&&I.preventDefault()},[O]),onItemLeave:p.useCallback(I=>{var G;O(I)||((G=E.current)==null||G.focus(),T(null))},[O]),onTriggerLeave:p.useCallback(I=>{O(I)&&I.preventDefault()},[O]),pointerGraceTimerRef:F,onPointerGraceIntentChange:p.useCallback(I=>{U.current=I},[]),children:u.jsx(K,{...W,children:u.jsx(Qo,{asChild:!0,trapped:o,onMountAutoFocus:ae(s,I=>{var G;I.preventDefault(),(G=E.current)==null||G.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:u.jsx(Sr,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:h,onInteractOutside:m,onDismiss:f,children:u.jsx(Ny,{asChild:!0,...C,dir:y.dir,orientation:"vertical",loop:r,currentTabStopId:S,onCurrentTabStopIdChange:T,onEntryFocus:ae(l,I=>{y.isUsingKeyboardRef.current||I.preventDefault()}),preventScrollOnEntryFocus:!0,children:u.jsx(la,{role:"menu","aria-orientation":"vertical","data-state":wf(x.open),"data-radix-menu-content":"",dir:y.dir,...b,...g,ref:j,style:{outline:"none",...g.style},onKeyDown:ae(g.onKeyDown,I=>{const J=I.target.closest("[data-radix-menu-content]")===I.currentTarget,P=I.ctrlKey||I.altKey||I.metaKey,B=I.key.length===1;J&&(I.key==="Tab"&&I.preventDefault(),!P&&B&&z(I.key));const A=E.current;if(I.target!==A||!g0.includes(I.key))return;I.preventDefault();const q=k().filter(M=>!M.disabled).map(M=>M.ref.current);Yd.includes(I.key)&&q.reverse(),$0(q)}),onBlur:ae(e.onBlur,I=>{I.currentTarget.contains(I.target)||(window.clearTimeout(_.current),$.current="")}),onPointerMove:ae(e.onPointerMove,ho(I=>{const G=I.target,J=R.current!==I.clientX;if(I.currentTarget.contains(G)&&J){const P=I.clientX>R.current?"right":"left";X.current=P,R.current=I.clientX}}))})})})})})})});tf.displayName=Qt;var A0="MenuGroup",Ca=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(me.div,{role:"group",...r,ref:t})});Ca.displayName=A0;var j0="MenuLabel",nf=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(me.div,{...r,ref:t})});nf.displayName=j0;var bs="MenuItem",rf="menu.itemSelect",ys=p.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=p.useRef(null),i=uo(bs,e.__scopeMenu),a=ya(bs,e.__scopeMenu),l=Me(t,s),c=p.useRef(!1),d=()=>{const h=s.current;if(!n&&h){const m=new CustomEvent(rf,{bubbles:!0,cancelable:!0});h.addEventListener(rf,f=>r==null?void 0:r(f),{once:!0}),zi(h,m),m.defaultPrevented?c.current=!1:i.onClose()}};return u.jsx(of,{...o,ref:l,disabled:n,onClick:ae(e.onClick,d),onPointerDown:h=>{var m;(m=e.onPointerDown)==null||m.call(e,h),c.current=!0},onPointerUp:ae(e.onPointerUp,h=>{var m;c.current||(m=h.currentTarget)==null||m.click()}),onKeyDown:ae(e.onKeyDown,h=>{const m=a.searchRef.current!=="";n||m&&h.key===" "||va.includes(h.key)&&(h.currentTarget.click(),h.preventDefault())})})});ys.displayName=bs;var of=p.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=ya(bs,n),a=Jd(n),l=p.useRef(null),c=Me(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(co.ItemSlot,{scope:n,disabled:r,textValue:o??m,children:u.jsx(Ay,{asChild:!0,...a,focusable:!r,children:u.jsx(me.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:c,onPointerMove:ae(e.onPointerMove,ho(v=>{r?i.onItemLeave(v):(i.onItemEnter(v),v.defaultPrevented||v.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:ae(e.onPointerLeave,ho(v=>i.onItemLeave(v))),onFocus:ae(e.onFocus,()=>h(!0)),onBlur:ae(e.onBlur,()=>h(!1))})})})}),P0="MenuCheckboxItem",sf=p.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return u.jsx(df,{scope:e.__scopeMenu,checked:n,children:u.jsx(ys,{role:"menuitemcheckbox","aria-checked":Ss(n)?"mixed":n,...o,ref:t,"data-state":ka(n),onSelect:ae(o.onSelect,()=>r==null?void 0:r(Ss(n)?!0:!n),{checkForDefaultPrevented:!1})})})});sf.displayName=P0;var af="MenuRadioGroup",[_0,R0]=er(af,{value:void 0,onValueChange:()=>{}}),lf=p.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=pt(r);return u.jsx(_0,{scope:e.__scopeMenu,value:n,onValueChange:s,children:u.jsx(Ca,{...o,ref:t})})});lf.displayName=af;var cf="MenuRadioItem",uf=p.forwardRef((e,t)=>{const{value:n,...r}=e,o=R0(cf,e.__scopeMenu),s=n===o.value;return u.jsx(df,{scope:e.__scopeMenu,checked:s,children:u.jsx(ys,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":ka(s),onSelect:ae(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});uf.displayName=cf;var Ta="MenuItemIndicator",[df,M0]=er(Ta,{checked:!1}),ff=p.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=M0(Ta,n);return u.jsx(Bt,{present:r||Ss(s.checked)||s.checked===!0,children:u.jsx(me.span,{...o,ref:t,"data-state":ka(s.checked)})})});ff.displayName=Ta;var O0="MenuSeparator",hf=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(me.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});hf.displayName=O0;var D0="MenuArrow",pf=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=ws(n);return u.jsx(ca,{...o,...r,ref:t})});pf.displayName=D0;var L0="MenuSub",[P1,mf]=er(L0),fo="MenuSubTrigger",gf=p.forwardRef((e,t)=>{const n=tr(fo,e.__scopeMenu),r=uo(fo,e.__scopeMenu),o=mf(fo,e.__scopeMenu),s=ya(fo,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(wa,{asChild:!0,...c,children:u.jsx(of,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":wf(n.open),...e,ref:Mn(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:ae(e.onPointerMove,ho(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:ae(e.onPointerLeave,ho(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,b=m[x?"left":"right"],C=m[x?"right":"left"];s.onPointerGraceIntentChange({area:[{x:h.clientX+y,y:h.clientY},{x:b,y:m.top},{x:C,y:m.top},{x:C,y:m.bottom},{x:b,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:ae(e.onKeyDown,h=>{var f;const m=s.searchRef.current!=="";e.disabled||m&&h.key===" "||x0[r.dir].includes(h.key)&&(n.onOpenChange(!0),(f=n.content)==null||f.focus(),h.preventDefault())})})})});gf.displayName=fo;var xf="MenuSubContent",vf=p.forwardRef((e,t)=>{const n=Qd(Qt,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=tr(Qt,e.__scopeMenu),i=uo(Qt,e.__scopeMenu),a=mf(xf,e.__scopeMenu),l=p.useRef(null),c=Me(t,l);return u.jsx(co.Provider,{scope:e.__scopeMenu,children:u.jsx(Bt,{present:r||s.open,children:u.jsx(co.Slot,{scope:e.__scopeMenu,children:u.jsx(Sa,{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:ae(e.onFocusOutside,d=>{d.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:ae(e.onEscapeKeyDown,d=>{i.onClose(),d.preventDefault()}),onKeyDown:ae(e.onKeyDown,d=>{var f;const h=d.currentTarget.contains(d.target),m=v0[i.dir].includes(d.key);h&&m&&(s.onOpenChange(!1),(f=a.trigger)==null||f.focus(),d.preventDefault())})})})})})});vf.displayName=xf;function wf(e){return e?"open":"closed"}function Ss(e){return e==="indeterminate"}function ka(e){return Ss(e)?"indeterminate":e?"checked":"unchecked"}function $0(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function F0(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function B0(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=F0(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 z0(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 H0(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return z0(n,t)}function ho(e){return t=>t.pointerType==="mouse"?e(t):void 0}var U0=Zd,W0=wa,V0=ef,K0=tf,q0=Ca,G0=nf,Y0=ys,X0=sf,J0=lf,Z0=uf,Q0=ff,eS=hf,tS=pf,nS=gf,rS=vf,Cs="DropdownMenu",[oS,_1]=an(Cs,[Xd]),Ot=Xd(),[sS,bf]=oS(Cs),yf=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,l=Ot(t),c=p.useRef(null),[d,h]=On({prop:o,defaultProp:s??!1,onChange:i,caller:Cs});return u.jsx(sS,{scope:t,triggerId:At(),triggerRef:c,contentId:At(),open:d,onOpenChange:h,onOpenToggle:p.useCallback(()=>h(m=>!m),[h]),modal:a,children:u.jsx(U0,{...l,open:d,onOpenChange:h,dir:r,modal:a,children:n})})};yf.displayName=Cs;var Sf="DropdownMenuTrigger",Cf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=bf(Sf,n),i=Ot(n);return u.jsx(W0,{asChild:!0,...i,children:u.jsx(me.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:Mn(t,s.triggerRef),onPointerDown:ae(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:ae(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});Cf.displayName=Sf;var iS="DropdownMenuPortal",Tf=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Ot(t);return u.jsx(V0,{...r,...n})};Tf.displayName=iS;var kf="DropdownMenuContent",Ef=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=bf(kf,n),s=Ot(n),i=p.useRef(!1);return u.jsx(K0,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:ae(e.onCloseAutoFocus,a=>{var l;i.current||(l=o.triggerRef.current)==null||l.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:ae(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)"}})});Ef.displayName=kf;var aS="DropdownMenuGroup",lS=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(q0,{...o,...r,ref:t})});lS.displayName=aS;var cS="DropdownMenuLabel",If=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(G0,{...o,...r,ref:t})});If.displayName=cS;var uS="DropdownMenuItem",Nf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(Y0,{...o,...r,ref:t})});Nf.displayName=uS;var dS="DropdownMenuCheckboxItem",Af=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(X0,{...o,...r,ref:t})});Af.displayName=dS;var fS="DropdownMenuRadioGroup",hS=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(J0,{...o,...r,ref:t})});hS.displayName=fS;var pS="DropdownMenuRadioItem",jf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(Z0,{...o,...r,ref:t})});jf.displayName=pS;var mS="DropdownMenuItemIndicator",Pf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(Q0,{...o,...r,ref:t})});Pf.displayName=mS;var gS="DropdownMenuSeparator",_f=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(eS,{...o,...r,ref:t})});_f.displayName=gS;var xS="DropdownMenuArrow",vS=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(tS,{...o,...r,ref:t})});vS.displayName=xS;var wS="DropdownMenuSubTrigger",Rf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(nS,{...o,...r,ref:t})});Rf.displayName=wS;var bS="DropdownMenuSubContent",Mf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(rS,{...o,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Mf.displayName=bS;var yS=yf,SS=Cf,CS=Tf,Of=Ef,Df=If,Lf=Nf,$f=Af,Ff=jf,Bf=Pf,zf=_f,Hf=Rf,Uf=Mf;const Ts=yS,ks=SS,TS=p.forwardRef(({className:e,inset:t,children:n,...r},o)=>u.jsxs(Hf,{ref:o,className:te("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(ce.ChevronRight,{className:"ml-auto h-4 w-4"})]}));TS.displayName=Hf.displayName;const kS=p.forwardRef(({className:e,...t},n)=>u.jsx(Uf,{ref:n,className:te("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}));kS.displayName=Uf.displayName;const po=p.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(CS,{children:u.jsx(Of,{ref:r,sideOffset:t,className:te("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})}));po.displayName=Of.displayName;const Fn=p.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(Lf,{ref:r,className:te("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}));Fn.displayName=Lf.displayName;const ES=p.forwardRef(({className:e,children:t,checked:n,...r},o)=>u.jsxs($f,{ref:o,className:te("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(Bf,{children:u.jsx(ce.Check,{className:"h-4 w-4"})})}),t]}));ES.displayName=$f.displayName;const IS=p.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Ff,{ref:r,className:te("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(Bf,{children:u.jsx(ce.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));IS.displayName=Ff.displayName;const NS=p.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(Df,{ref:r,className:te("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));NS.displayName=Df.displayName;const AS=p.forwardRef(({className:e,...t},n)=>u.jsx(zf,{ref:n,className:te("-mx-1 my-1 h-px bg-muted",e),...t}));AS.displayName=zf.displayName;const Ea=p.forwardRef(({className:e,...t},n)=>u.jsx("textarea",{className:te("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}));Ea.displayName="Textarea";const jS=1e4;function Wf({initialValue:e="",editingMessageId:t=null,placeholder:n="Type your message...",isStreaming:r=!1,disabled:o=!1,maxLength:s=jS,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,[b,C]=w.useState(e),k=(y?i:b)??"",[S,T]=w.useTransition(),E=w.useRef(null),j=w.useRef(0),_=w.useRef(null),$=w.useRef("");w.useEffect(()=>{y||(C(e??""),_.current=null,E.current&&(E.current.style.height="auto",E.current.style.height=`${E.current.scrollHeight}px`))},[e,t,y]);const[F,U]=w.useState(null),X=w.useCallback(A=>A.length>s?`Message too long (${A.length}/${s} characters)`:null,[s]),R=w.useMemo(()=>g??X,[g,X]),K=w.useCallback(A=>{const D=R(A);return U(D),x==null||x(D),$.current=A,D},[R,x]),W=w.useCallback(()=>{const A=E.current;A&&(A.style.height="auto",A.style.height=`${A.scrollHeight}px`)},[]);w.useEffect(()=>{W()},[W,k]),w.useEffect(()=>{if(!F)return;const A=(k??"").trim();$.current!==A&&K(A)},[k,F,K]);const z=w.useCallback((A,{fromUser:D})=>{y||C(A),D&&(a==null||a(A))},[y,a]),O=w.useCallback(async A=>{A&&A.preventDefault();const D=(k??"").trim();if(!D&&!f||K(D))return;const q=++j.current;_.current={id:q,shouldClear:!0},T(()=>{var M,L,Y;try{const Z=l(D);Z&&typeof Z.then=="function"?Z.then(()=>{var oe,se;((oe=_.current)==null?void 0:oe.id)===q&&_.current.shouldClear&&(y||(C(""),E.current&&(E.current.style.height="auto"),a==null||a(""))),((se=_.current)==null?void 0:se.id)===q&&(_.current=null)}).catch(()=>{var oe;((oe=_.current)==null?void 0:oe.id)===q&&(_.current=null)}):(((M=_.current)==null?void 0:M.id)===q&&_.current.shouldClear&&(y||(C(""),E.current&&(E.current.style.height="auto"),a==null||a(""))),((L=_.current)==null?void 0:L.id)===q&&(_.current=null))}catch{((Y=_.current)==null?void 0:Y.id)===q&&(_.current=null)}})},[k,l,f,y,a,K]),I=w.useCallback(A=>{const D=A.target.value;z(D,{fromUser:!0}),_.current&&(_.current.shouldClear=!1),E.current&&(E.current.style.height="auto",E.current.style.height=`${E.current.scrollHeight}px`),F&&K(D.trim())},[z,K,F]),G=w.useCallback(A=>{A.key==="Enter"&&!A.shiftKey?(A.preventDefault(),O()):A.key==="Escape"&&t&&(A.preventDefault(),c==null||c())},[O,t,c]),B=`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:A=>void O(A),className:`w-full ${h}`,children:u.jsxs("div",{className:"flex items-end gap-2",children:[u.jsxs("div",{className:"flex-1",children:[u.jsx(Ea,{ref:E,value:k,onChange:I,onKeyDown:G,placeholder:t?"Edit your message...":n,className:B,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(Qe,{type:"button",onClick:()=>{d==null||d()},size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",disabled:o||!d,children:u.jsx(ce.Square,{size:16})}):u.jsx(Qe,{type:"submit",size:"icon",className:`shrink-0 ${v??""}`,title:t?"Save changes":"Send message",disabled:o||!k.trim()&&!f||S,children:u.jsx(ce.Send,{size:16})})})]})})}const PS=w.memo(Wf);function Vf({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[b,C]=w.useState([]),k=w.useRef(null),S=w.useRef(null),[T,E]=w.useState(0),[j,_]=w.useState(0),[$,F]=w.useState(!1),[U,X]=w.useState(null),[R,K]=w.useState(null),W=w.useCallback(()=>{k.current&&(k.current.value=""),S.current&&(S.current.value=""),E(A=>A+1),_(A=>A+1)},[]),z=w.useCallback(A=>{C(D=>[...D,...A])},[]),O=w.useCallback(A=>{const D=Array.from(A.target.files||[]);z(D),A.target.value=""},[z]),I=w.useCallback(A=>{C(D=>{const q=D.filter((M,L)=>L!==A);return q.length===0&&W(),q})},[W]),G=w.useCallback(async A=>{const D=(A.target.files||[])[0];if(D&&(X(null),K(null),!!v)){F(!0);try{await v(D),X(`Uploaded ${D.name} - processing through chat stream`)}catch(q){const M=q instanceof Error?q.message:"Failed to upload Excel file";K(M),g==null||g(M)}finally{F(!1),A.target.value="",W()}}},[v,g,W]),J=w.useMemo(()=>x||b.length>0,[x,b]),P=w.useCallback(async A=>{const q=await n(A,b);return b.length>0&&(C([]),W()),q},[n,W,b]),B=`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:O,className:"hidden"},T),b.length>0&&u.jsx("div",{className:"flex flex-wrap gap-2",children:b.map((A,D)=>u.jsxs("div",{className:"flex items-center gap-2 bg-gray-100 dark:bg-gray-800 rounded-lg px-3 py-2 text-sm text-gray-900 dark:text-gray-100",children:[u.jsx(ce.Paperclip,{size:14}),u.jsx("span",{className:"truncate max-w-[150px]",children:A.name}),u.jsx(Qe,{variant:"ghost",size:"sm",onClick:()=>I(D),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 ${A.name}`,children:u.jsx(ce.X,{size:12})})]},D))})]}),f&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:S,type:"file",accept:".xls,.xlsx,.xlsm",onChange:G,className:"hidden"},j),$&&u.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(ce.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),U&&!$&&u.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:U}),R&&!$&&u.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:R})]})]}),u.jsxs("div",{className:"flex items-end gap-2",children:[(m||f)&&u.jsxs(Ts,{children:[u.jsx(ks,{asChild:!0,children:u.jsx(Qe,{type:"button",size:"icon",variant:"outline",disabled:l||c,title:"More input actions",className:h.moreButton||"",children:u.jsx(ce.Plus,{size:16})})}),u.jsxs(po,{align:"start",sideOffset:6,className:"w-52",children:[m&&u.jsxs(Fn,{onClick:()=>{var A;return(A=k.current)==null?void 0:A.click()},className:"cursor-pointer",children:[u.jsx(ce.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),f&&u.jsxs(Fn,{onClick:()=>{var A;$||(A=S.current)==null||A.click()},className:`cursor-pointer ${$?"opacity-60 pointer-events-none":""}`,children:[u.jsx(ce.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),u.jsx("div",{className:"flex-1",children:u.jsx(PS,{initialValue:i,editingMessageId:s,value:e,onValueChange:t,placeholder:s?"Edit your message...":a,isStreaming:l,disabled:c,onSend:P,onCancelEdit:r,onStop:o,allowEmptySend:J,textareaClassName:B,sendButtonClassName:h.sendButton})})]})]})}const _S=w.memo(Vf),Es=0,Bn=1,_r=2,Kf=4;function qf(e){return()=>e}function RS(e){e()}function Gf(e,t){return n=>e(t(n))}function Yf(e,t){return()=>e(t)}function MS(e,t){return n=>e(t,n)}function Ia(e){return e!==void 0}function OS(...e){return()=>{e.map(RS)}}function Rr(){}function Is(e,t){return t(e),e}function DS(e,t){return t(e)}function it(...e){return e}function Je(e,t){return e(Bn,t)}function je(e,t){e(Es,t)}function Na(e){e(_r)}function mt(e){return e(Kf)}function ge(e,t){return Je(e,MS(t,Es))}function un(e,t){const n=e(Bn,r=>{n(),t(r)});return n}function Xf(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function Jf(e,t){return e===t}function at(e=Jf){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function Te(e){return t=>n=>{e(n)&&t(n)}}function fe(e){return t=>Gf(t,e)}function Cn(e){return t=>()=>{t(e)}}function Q(e,...t){const n=LS(...t);return(r,o)=>{switch(r){case _r:Na(e);return;case Bn:return Je(e,n(o))}}}function Tn(e,t){return n=>r=>{n(t=e(t,r))}}function nr(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 Oe(...e){const t=new Array(e.length);let n=0,r=null;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const a=Math.pow(2,i);Je(s,l=>{const c=n;n=n|a,t[i]=l,c!==o&&n===o&&r&&(r(),r=null)})}),s=>i=>{const a=()=>{s([i].concat(t))};n===o?a():r=a}}function LS(...e){return t=>e.reduceRight(DS,t)}function $S(e){let t,n;const r=()=>t==null?void 0:t();return function(o,s){switch(o){case Bn:return s?n===s?void 0:(r(),n=s,t=Je(e,s),t):(r(),Rr);case _r:r(),n=null;return}}}function re(e){let t=e;const n=He();return(r,o)=>{switch(r){case Es:t=o;break;case Bn:{o(t);break}case Kf:return t}return n(r,o)}}function jt(e,t){return Is(re(t),n=>ge(e,n))}function He(){const e=[];return(t,n)=>{switch(t){case Es:e.slice().forEach(r=>{r(n)});return;case _r:e.splice(0,e.length);return;case Bn:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}}}function Xt(e){return Is(He(),t=>ge(e,t))}function Ye(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:FS(),singleton:n}}const FS=()=>Symbol();function BS(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 bt(...e){const t=He(),n=new Array(e.length);let r=0;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const a=Math.pow(2,i);Je(s,l=>{n[i]=l,r=r|a,r===o&&je(t,n)})}),function(s,i){switch(s){case _r:{Na(t);return}case Bn:return r===o&&i(n),Je(t,i)}}}function Se(e,t=Jf){return Q(e,at(t))}function Aa(...e){return function(t,n){switch(t){case _r:return;case Bn:return OS(...e.map(r=>Je(r,n)))}}}var zt=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(zt||{});const zS={0:"debug",3:"error",1:"log",2:"warn"},HS=()=>typeof globalThis>"u"?window:globalThis,zn=Ye(()=>{const e=re(3);return{log:re((t,n,r=1)=>{var o;const s=(o=HS().VIRTUOSO_LOG_LEVEL)!=null?o:mt(e);r>=s&&console[zS[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0});function rr(e,t,n){return ja(e,t,n).callbackRef}function ja(e,t,n){const r=w.useRef(null);let o=i=>{};const s=w.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 US(e,t,n,r,o,s,i,a,l){const c=w.useCallback(d=>{const h=WS(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?Zf("column-gap",getComputedStyle(d).columnGap,o):Zf("row-gap",getComputedStyle(d).rowGap,o)),h!==null&&e(h)},[e,t,o,s,i,r,a]);return ja(c,n,l)}function WS(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},zt.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 Zf(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,zt.WARN),t==="normal"?0:parseInt(t??"0",10)}function Qf(e,t,n){const r=w.useRef(null),o=w.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}=ja(o,!0,n),a=w.useCallback(()=>{o(i.current)},[o,i]);return w.useEffect(()=>{var l;if(t){t.addEventListener("scroll",a);const c=new ResizeObserver(()=>{requestAnimationFrame(a)});return c.observe(t),()=>{t.removeEventListener("scroll",a),c.unobserve(t)}}else{const c=(l=i.current)==null?void 0:l.ownerDocument.defaultView;return c==null||c.addEventListener("scroll",a),c==null||c.addEventListener("resize",a),()=>{c==null||c.removeEventListener("scroll",a),c==null||c.removeEventListener("resize",a)}}},[a,t,i]),s}const Dt=Ye(()=>{const e=He(),t=He(),n=re(0),r=He(),o=re(0),s=He(),i=He(),a=re(0),l=re(0),c=re(0),d=re(0),h=He(),m=He(),f=re(!1),v=re(!1),g=re(!1);return ge(Q(e,fe(({scrollTop:x})=>x)),t),ge(Q(e,fe(({scrollHeight:x})=>x)),i),ge(t,o),{deviation:n,fixedFooterHeight:c,fixedHeaderHeight:l,footerHeight:d,headerHeight:a,horizontalDirection:v,scrollBy:m,scrollContainerState:e,scrollHeight:i,scrollingInProgress:f,scrollTo:h,scrollTop:t,skipAnimationFrameInResizeObserver:g,smoothScrollTargetReached:r,statefulScrollTop:o,viewportHeight:s}},[],{singleton:!0}),mo={lvl:0};function eh(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 nt(e){return e===mo}function go(e,t){if(!nt(e))return t===e.k?e.v:t<e.k?go(e.l,t):go(e.r,t)}function dn(e,t,n="k"){if(nt(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){const r=dn(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return dn(e.l,t,n)}function Jt(e,t,n){return nt(e)?rh(t,n,1):t===e.k?Tt(e,{k:t,v:n}):t<e.k?oh(Tt(e,{l:Jt(e.l,t,n)})):oh(Tt(e,{r:Jt(e.r,t,n)}))}function Mr(){return mo}function Ns(e,t,n){if(nt(e))return[];const r=dn(e,t)[0];return VS(_a(e,r,n))}function Pa(e,t){if(nt(e))return mo;const{k:n,l:r,r:o}=e;if(t===n){if(nt(r))return o;if(nt(o))return r;{const[s,i]=nh(r);return As(Tt(e,{k:s,l:th(r),v:i}))}}else return t<n?As(Tt(e,{l:Pa(r,t)})):As(Tt(e,{r:Pa(o,t)}))}function or(e){return nt(e)?[]:[...or(e.l),{k:e.k,v:e.v},...or(e.r)]}function _a(e,t,n){if(nt(e))return[];const{k:r,l:o,r:s,v:i}=e;let a=[];return r>t&&(a=a.concat(_a(o,t,n))),r>=t&&r<=n&&a.push({k:r,v:i}),r<=n&&(a=a.concat(_a(s,t,n))),a}function As(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(Ra(t))return sh(Tt(e,{lvl:n-1}));if(!nt(t)&&!nt(t.r))return Tt(t.r,{l:Tt(t,{r:t.r.l}),lvl:n,r:Tt(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(Ra(e))return Ma(Tt(e,{lvl:n-1}));if(!nt(r)&&!nt(r.l)){const o=r.l,s=Ra(o)?r.lvl-1:r.lvl;return Tt(o,{l:Tt(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:Ma(Tt(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function Tt(e,t){return rh(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 th(e){return nt(e.r)?e.l:As(Tt(e,{r:th(e.r)}))}function Ra(e){return nt(e)||e.lvl>e.r.lvl}function nh(e){return nt(e.r)?[e.k,e.v]:nh(e.r)}function rh(e,t,n,r=mo,o=mo){return{k:e,l:r,lvl:n,r:o,v:t}}function oh(e){return Ma(sh(e))}function sh(e){const{l:t}=e;return!nt(t)&&t.lvl===e.lvl?Tt(t,{r:Tt(e,{l:t.r})}):e}function Ma(e){const{lvl:t,r:n}=e;return!nt(n)&&!nt(n.r)&&n.lvl===t&&n.r.lvl===t?Tt(n,{l:Tt(e,{r:n.l}),lvl:t+1}):e}function VS(e){return eh(e,({k:t,v:n})=>({index:t,value:n}))}function ih(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function xo(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const Oa=Ye(()=>({recalcInProgress:re(!1)}),[],{singleton:!0});function ah(e,t,n){return e[js(e,t,n)]}function js(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 KS(e,t,n,r){const o=js(e,t,r),s=js(e,n,r,o);return e.slice(o,s+1)}function Hn(e,t){return Math.round(e.getBoundingClientRect()[t])}function Ps(e){return!nt(e.groupOffsetTree)}function Da({index:e},t){return t===e?0:t<e?-1:1}function qS(){return{groupIndices:[],groupOffsetTree:Mr(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Mr()}}function GS(e,t){let n=nt(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),nt(e)){e=Jt(e,0,s);continue}const a=Ns(e,i-1,o+1);if(a.some(tC(r)))continue;let l=!1,c=!1;for(const{end:d,start:h,value:m}of a)l?(o>=h||s===m)&&(e=Pa(e,h)):(c=m!==s,l=!0),d>o&&o>=h&&m!==s&&(e=Jt(e,o+1,m));c&&(e=Jt(e,i,s))}return[e,n]}function YS(e){return typeof e.groupIndex<"u"}function XS({offset:e},t){return t===e?0:t<e?-1:1}function vo(e,t,n){if(t.length===0)return 0;const{index:r,offset:o,size:s}=ah(t,e,Da),i=e-r,a=s*i+(i-1)*n+o;return a>0?a+n:a}function lh(e,t){if(!Ps(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function ch(e,t,n){if(YS(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=lh(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function JS(e,t,n,r=0){return r>0&&(t=Math.max(t,ah(e,r,Da).offset)),eh(KS(e,t,n,XS),eC)}function ZS(e,[t,n,r,o]){t.length>0&&r("received item sizes",t,zt.DEBUG);const s=e.sizeTree;let i=s,a=0;if(n.length>0&&nt(s)&&t.length===2){const m=t[0].size,f=t[1].size;i=n.reduce((v,g)=>Jt(Jt(v,g,m),g+1,f),i)}else[i,a]=GS(i,t);if(i===s)return e;const{lastIndex:l,lastOffset:c,lastSize:d,offsetTree:h}=La(e.offsetTree,a,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((m,f)=>Jt(m,f,vo(f,h,o)),Mr()),lastIndex:l,lastOffset:c,lastSize:d,offsetTree:h,sizeTree:i}}function QS(e){return or(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 uh(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 La(e,t,n,r){let o=e,s=0,i=0,a=0,l=0;if(t!==0){l=js(o,t-1,Da),a=o[l].offset;const c=dn(n,t-1);s=c[0],i=c[1],o.length&&o[l].size===dn(n,t)[1]&&(l-=1),o=o.slice(0,l+1)}else o=[];for(const{start:c,value:d}of Ns(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 eC(e){return{index:e.index,value:e}}function tC(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 nC={offsetHeight:"height",offsetWidth:"width"},kn=Ye(([{log:e},{recalcInProgress:t}])=>{const n=He(),r=He(),o=jt(r,0),s=He(),i=He(),a=re(0),l=re([]),c=re(void 0),d=re(void 0),h=re((S,T)=>Hn(S,nC[T])),m=re(void 0),f=re(0),v=qS(),g=jt(Q(n,Oe(l,e,f),Tn(ZS,v),at()),v),x=jt(Q(l,at(),Tn((S,T)=>({current:T,prev:S.current}),{current:[],prev:[]}),fe(({prev:S})=>S)),[]);ge(Q(l,Te(S=>S.length>0),Oe(g,f),fe(([S,T,E])=>{const j=S.reduce((_,$,F)=>Jt(_,$,vo($,T.offsetTree,E)||F),Mr());return{...T,groupIndices:S,groupOffsetTree:j}})),g),ge(Q(r,Oe(g),Te(([S,{lastIndex:T}])=>S<T),fe(([S,{lastIndex:T,lastSize:E}])=>[{endIndex:T,size:E,startIndex:S}])),n),ge(c,d);const y=jt(Q(c,fe(S=>S===void 0)),!0);ge(Q(d,Te(S=>S!==void 0&&nt(mt(g).sizeTree)),fe(S=>[{endIndex:0,size:S,startIndex:0}])),n);const b=Xt(Q(n,Oe(g),Tn(({sizes:S},[T,E])=>({changed:E!==S,sizes:E}),{changed:!1,sizes:v}),fe(S=>S.changed)));Je(Q(a,Tn((S,T)=>({diff:S.prev-T,prev:T}),{diff:0,prev:0}),fe(S=>S.diff)),S=>{const{groupIndices:T}=mt(g);if(S>0)je(t,!0),je(s,S+uh(S,T));else if(S<0){const E=mt(x);E.length>0&&(S-=uh(-S,E)),je(i,S)}}),Je(Q(a,Oe(e)),([S,T])=>{S<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},zt.ERROR)});const C=Xt(s);ge(Q(s,Oe(g),fe(([S,T])=>{const E=T.groupIndices.length>0,j=[],_=T.lastSize;if(E){const $=go(T.sizeTree,0);let F=0,U=0;for(;F<S;){const R=T.groupIndices[U],K=T.groupIndices.length===U+1?1/0:T.groupIndices[U+1]-R-1;j.push({endIndex:R,size:$,startIndex:R}),j.push({endIndex:R+1+K-1,size:_,startIndex:R+1}),U++,F+=K+1}const X=or(T.sizeTree);return F!==S&&X.shift(),X.reduce((R,{k:K,v:W})=>{let z=R.ranges;return R.prevSize!==0&&(z=[...R.ranges,{endIndex:K+S-1,size:R.prevSize,startIndex:R.prevIndex}]),{prevIndex:K+S,prevSize:W,ranges:z}},{prevIndex:S,prevSize:0,ranges:j}).ranges}return or(T.sizeTree).reduce(($,{k:F,v:U})=>({prevIndex:F+S,prevSize:U,ranges:[...$.ranges,{endIndex:F+S-1,size:$.prevSize,startIndex:$.prevIndex}]}),{prevIndex:0,prevSize:_,ranges:[]}).ranges})),n);const k=Xt(Q(i,Oe(g,f),fe(([S,{offsetTree:T},E])=>{const j=-S;return vo(j,T,E)})));return ge(Q(i,Oe(g,f),fe(([S,T,E])=>{if(T.groupIndices.length>0){if(nt(T.sizeTree))return T;let j=Mr();const _=mt(x);let $=0,F=0,U=0;for(;$<-S;){U=_[F];const X=_[F+1]-U-1;F++,$+=X+1}if(j=or(T.sizeTree).reduce((X,{k:R,v:K})=>Jt(X,Math.max(0,R+S),K),j),$!==-S){const X=go(T.sizeTree,U);j=Jt(j,0,X);const R=dn(T.sizeTree,-S+1)[1];j=Jt(j,1,R)}return{...T,sizeTree:j,...La(T.offsetTree,0,j,E)}}else{const j=or(T.sizeTree).reduce((_,{k:$,v:F})=>Jt(_,Math.max(0,$+S),F),Mr());return{...T,sizeTree:j,...La(T.offsetTree,0,j,E)}}})),g),{beforeUnshiftWith:C,data:m,defaultItemSize:d,firstItemIndex:a,fixedItemSize:c,gap:f,groupIndices:l,itemSize:h,listRefresh:b,shiftWith:i,shiftWithOffset:k,sizeRanges:n,sizes:g,statefulTotalCount:o,totalCount:r,trackItemSizes:y,unshiftWith:s}},it(zn,Oa),{singleton:!0});function rC(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const dh=Ye(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=He(),i=He(),a=Xt(Q(s,fe(rC)));return ge(Q(a,fe(l=>l.totalCount)),n),ge(Q(a,fe(l=>l.groupIndices)),e),ge(Q(bt(o,t,r),Te(([l,c])=>Ps(c)),fe(([l,c,d])=>dn(c.groupOffsetTree,Math.max(l-d,0),"v")[0]),at(),fe(l=>[l])),i),{groupCounts:s,topItemsIndexes:i}},it(kn,Dt)),Un=Ye(([{log:e}])=>{const t=re(!1),n=Xt(Q(t,Te(r=>r),at()));return Je(t,r=>{r&&mt(e)("props updated",{},zt.DEBUG)}),{didMount:n,propsReady:t}},it(zn),{singleton:!0}),oC=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function fh(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!oC)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const wo=Ye(([{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=He(),v=He(),g=re(0);let x=null,y=null,b=null;function C(){x&&(x(),x=null),b&&(b(),b=null),y&&(clearTimeout(y),y=null),je(l,!1)}return ge(Q(f,Oe(n,h,r,g,a,i,m),Oe(e,s,o),fe(([[k,S,T,E,j,_,$,F],U,X,R])=>{const K=fh(k),{align:W,behavior:z,offset:O}=K,I=E-1,G=ch(K,S,I);let J=vo(G,S.offsetTree,U)+_;W==="end"?(J+=X+dn(S.sizeTree,G)[1]-T+R,G===I&&(J+=$)):W==="center"?J+=(X+dn(S.sizeTree,G)[1]-T+R)/2:J-=j,O&&(J+=O);const P=B=>{C(),B?(F("retrying to scroll to",{location:k},zt.DEBUG),je(f,k)):(je(v,!0),F("list did not change, scroll successful",{},zt.DEBUG))};if(C(),z==="smooth"){let B=!1;b=Je(t,A=>{B=B||A}),x=un(d,()=>{P(B)})}else x=un(Q(t,sC(150)),P);return y=setTimeout(()=>{C()},1200),je(l,!0),F("scrolling from index to",{behavior:z,index:G,top:J},zt.DEBUG),{behavior:z,top:J}})),c),{scrollTargetReached:v,scrollToIndex:f,topListHeight:g}},it(kn,Dt,zn),{singleton:!0});function sC(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function $a(e,t){e==0?t():requestAnimationFrame(()=>{$a(e-1,t)})}function Fa(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const bo=Ye(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:s},{didMount:i}])=>{const a=re(!0),l=re(0),c=re(!0);return ge(Q(i,Oe(l),Te(([d,h])=>!!h),Cn(!1)),a),ge(Q(i,Oe(l),Te(([d,h])=>!!h),Cn(!1)),c),Je(Q(bt(t,i),Oe(a,n,e,c),Te(([[,d],h,{sizeTree:m},f,v])=>d&&(!nt(m)||Ia(f))&&!h&&!v),Oe(l)),([,d])=>{un(o,()=>{je(c,!0)}),$a(4,()=>{un(r,()=>{je(a,!0)}),je(s,d)})}),{initialItemFinalLocationReached:c,initialTopMostItemIndex:l,scrolledToInitialItem:a}},it(kn,Dt,wo,Un),{singleton:!0});function hh(e,t){return Math.abs(e-t)<1.01}const yo="up",So="down",iC="none",aC={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},lC=0,Co=Ye(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=re(!1),a=re(!0),l=He(),c=He(),d=re(4),h=re(lC),m=jt(Q(Aa(Q(Se(o),nr(1),Cn(!0)),Q(Se(o),nr(1),Cn(!1),Xf(100))),at()),!1),f=jt(Q(Aa(Q(n,Cn(!0)),Q(n,Cn(!1),Xf(200))),at()),!1);ge(Q(bt(Se(o),Se(h)),fe(([b,C])=>b<=C),at()),a),ge(Q(a,Pn(50)),c);const v=Xt(Q(bt(r,Se(s),Se(t),Se(e),Se(d)),Tn((b,[{scrollHeight:C,scrollTop:k},S,T,E,j])=>{const _=k+S-C>-j,$={scrollHeight:C,scrollTop:k,viewportHeight:S};if(_){let U,X;return k>b.state.scrollTop?(U="SCROLLED_DOWN",X=b.state.scrollTop-k):(U="SIZE_DECREASED",X=b.state.scrollTop-k||b.scrollTopDelta),{atBottom:!0,atBottomBecause:U,scrollTopDelta:X,state:$}}let F;return $.scrollHeight>b.state.scrollHeight?F="SIZE_INCREASED":S<b.state.viewportHeight?F="VIEWPORT_HEIGHT_DECREASING":k<b.state.scrollTop?F="SCROLLING_UPWARDS":F="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:F,state:$}},aC),at((b,C)=>b&&b.atBottom===C.atBottom))),g=jt(Q(r,Tn((b,{scrollHeight:C,scrollTop:k,viewportHeight:S})=>{if(hh(b.scrollHeight,C))return{changed:!1,jump:0,scrollHeight:C,scrollTop:k};{const T=C-(k+S)<1;return b.scrollTop!==k&&T?{changed:!0,jump:b.scrollTop-k,scrollHeight:C,scrollTop:k}:{changed:!0,jump:0,scrollHeight:C,scrollTop:k}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),Te(b=>b.changed),fe(b=>b.jump)),0);ge(Q(v,fe(b=>b.atBottom)),i),ge(Q(i,Pn(50)),l);const x=re(So);ge(Q(r,fe(({scrollTop:b})=>b),at(),Tn((b,C)=>mt(f)?{direction:b.direction,prevScrollTop:C}:{direction:C<b.prevScrollTop?yo:So,prevScrollTop:C},{direction:So,prevScrollTop:0}),fe(b=>b.direction)),x),ge(Q(r,Pn(50),Cn(iC)),x);const y=re(0);return ge(Q(m,Te(b=>!b),Cn(0)),y),ge(Q(o,Pn(100),Oe(m),Te(([b,C])=>!!C),Tn(([b,C],[k])=>[C,k],[0,0]),fe(([b,C])=>C-b)),y),{atBottomState:v,atBottomStateChange:l,atBottomThreshold:d,atTopStateChange:c,atTopThreshold:h,isAtBottom:i,isAtTop:a,isScrolling:m,lastJumpDueToItemResize:g,scrollDirection:x,scrollVelocity:y}},it(Dt)),_s="top",Rs="bottom",ph="none";function mh(e,t,n){return typeof e=="number"?n===yo&&t===_s||n===So&&t===Rs?e:0:n===yo?t===_s?e.main:e.reverse:t===Rs?e.main:e.reverse}function gh(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const Ba=Ye(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=He(),i=re(0),a=re(0),l=re(0),c=jt(Q(bt(Se(r),Se(o),Se(n),Se(s,xo),Se(l),Se(i),Se(t),Se(e),Se(a)),fe(([d,h,m,[f,v],g,x,y,b,C])=>{const k=d-b,S=x+y,T=Math.max(m-k,0);let E=ph;const j=gh(C,_s),_=gh(C,Rs);return f-=b,f+=m+y,v+=m+y,v-=b,f>d+S-j&&(E=yo),v<d-T+h+_&&(E=So),E!==ph?[Math.max(k-m-mh(g,_s,E)-j,0),k-T-y+h+mh(g,Rs,E)+_]:null}),Te(d=>d!=null),at(xo)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:l,topListHeight:i,visibleRange:c}},it(Dt),{singleton:!0});function cC(e,t,n){if(Ps(t)){const r=lh(e,t);return[{index:dn(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 za={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Ms(e,t,n,r,o,s){const{lastIndex:i,lastOffset:a,lastSize:l}=o;let c=0,d=0;if(e.length>0){c=e[0].offset;const g=e[e.length-1];d=g.offset+g.size}const h=n-i,m=a+h*l+(h-1)*r,f=c,v=m-d;return{bottom:d,firstItemIndex:s,items:vh(e,o,s),offsetBottom:v,offsetTop:c,top:f,topItems:vh(t,o,s),topListHeight:t.reduce((g,x)=>x.size+g,0),totalCount:n}}function xh(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=Fa(t,a),c=Array.from({length:a}).map((d,h)=>({data:s[h+l],index:h+l,offset:0,size:0}));return Ms(c,[],a,o,n,r)}function vh(e,t,n){if(e.length===0)return[];if(!Ps(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=Ns(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 sr=Ye(([{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=re([]),x=re(0),y=He();ge(s.topItemsIndexes,g);const b=jt(Q(bt(f,v,Se(l,xo),Se(o),Se(r),Se(c),d,Se(g),Se(t),Se(n),e),Te(([T,E,,j,,,,,,,_])=>{const $=_&&_.length!==j;return T&&!E&&!$}),fe(([,,[T,E],j,_,$,F,U,X,R,K])=>{const W=_,{offsetTree:z,sizeTree:O}=W,I=mt(x);if(j===0)return{...za,totalCount:j};if(T===0&&E===0)return I===0?{...za,totalCount:j}:xh(I,$,_,X,R,K||[]);if(nt(O))return I>0?null:Ms(cC(Fa($,j),W,K),[],j,R,W,X);const G=[];if(U.length>0){const D=U[0],q=U[U.length-1];let M=0;for(const L of Ns(O,D,q)){const Y=L.value,Z=Math.max(L.start,D),oe=Math.min(L.end,q);for(let se=Z;se<=oe;se++)G.push({data:K==null?void 0:K[se],index:se,offset:M,size:Y}),M+=Y}}if(!F)return Ms([],G,j,R,W,X);const J=U.length>0?U[U.length-1]+1:0,P=JS(z,T,E,J);if(P.length===0)return null;const B=j-1,A=Is([],D=>{for(const q of P){const M=q.value;let L=M.offset,Y=q.start;const Z=M.size;if(M.offset<T){Y+=Math.floor((T-M.offset+R)/(Z+R));const se=Y-q.start;L+=se*Z+se*R}Y<J&&(L+=(J-Y)*Z,Y=J);const oe=Math.min(q.end,B);for(let se=Y;se<=oe&&!(L>=E);se++)D.push({data:K==null?void 0:K[se],index:se,offset:L,size:Z}),L+=Z+R}});return Ms(A,G,j,R,W,X)}),Te(T=>T!==null),at()),za);ge(Q(e,Te(Ia),fe(T=>T==null?void 0:T.length)),o),ge(Q(b,fe(T=>T.topListHeight)),h),ge(h,a),ge(Q(b,fe(T=>[T.top,T.bottom])),i),ge(Q(b,fe(T=>T.items)),y);const C=Xt(Q(b,Te(({items:T})=>T.length>0),Oe(o,e),Te(([{items:T},E])=>T[T.length-1].originalIndex===E-1),fe(([,T,E])=>[T-1,E]),at(xo),fe(([T])=>T))),k=Xt(Q(b,Pn(200),Te(({items:T,topItems:E})=>T.length>0&&T[0].originalIndex===E.length),fe(({items:T})=>T[0].index),at())),S=Xt(Q(b,Te(({items:T})=>T.length>0),fe(({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}}),at(ih)));return{endReached:C,initialItemCount:x,itemsRendered:y,listState:b,rangeChanged:S,startReached:k,topItemsIndexes:g,...m}},it(kn,dh,Ba,bo,wo,Co,Un,Oa),{singleton:!0}),wh=Ye(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=He(),i=jt(Q(bt(n,e,r,t,o),fe(([a,l,c,d,h])=>a+l+c+d+h.offsetBottom+h.bottom)),0);return ge(Se(i),s),{totalListHeight:i,totalListHeightChanged:s}},it(Dt,sr),{singleton:!0}),uC=Ye(([{viewportHeight:e},{totalListHeight:t}])=>{const n=re(!1),r=jt(Q(bt(n,e,t),Te(([o])=>o),fe(([,o,s])=>Math.max(0,o-s)),Pn(0),at()),0);return{alignToBottom:n,paddingTopAddition:r}},it(Dt,wh),{singleton:!0}),bh=Ye(()=>({context:re(null)})),dC=({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,yh=Ye(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:s,scrollingInProgress:i,scrollTop:a,viewportHeight:l},{scrollToIndex:c}])=>{const d=He();return ge(Q(d,Oe(t,l,n,s,o,r,a),Oe(e),fe(([[h,m,f,v,g,x,y,b],C])=>{const{align:k,behavior:S,calculateViewLocation:T=dC,done:E,...j}=h,_=ch(h,m,v-1),$=vo(_,m.offsetTree,C)+g+x,F=$+dn(m.sizeTree,_)[1],U=b+x,X=b+f-y,R=T({itemBottom:F,itemTop:$,locationParams:{align:k,behavior:S,...j},viewportBottom:X,viewportTop:U});return R?E&&un(Q(i,Te(K=>!K),nr(mt(i)?1:2)),E):E&&E(),R}),Te(h=>h!==null)),c),{scrollIntoView:d}},it(kn,Dt,wo,sr,zn),{singleton:!0});function Sh(e){return e?e==="smooth"?"smooth":"auto":!1}const fC=(e,t)=>typeof e=="function"?Sh(e(t)):t&&Sh(e),hC=Ye(([{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=re(!1),g=He();let x=null;function y(S){je(i,{align:"end",behavior:S,index:"LAST"})}Je(Q(bt(Q(Se(t),nr(1)),l),Oe(Se(v),s,a,h),fe(([[S,T],E,j,_,$])=>{let F=T&&_,U="auto";return F&&(U=fC(E,j||$),F=F&&!!U),{followOutputBehavior:U,shouldFollow:F,totalCount:S}}),Te(({shouldFollow:S})=>S)),({followOutputBehavior:S,totalCount:T})=>{x&&(x(),x=null),mt(n)?requestAnimationFrame(()=>{mt(d)("following output to ",{totalCount:T},zt.DEBUG),y(S)}):x=un(e,()=>{mt(d)("following output to ",{totalCount:T},zt.DEBUG),y(S),x=null})});function b(S){const T=un(o,E=>{S&&!E.atBottom&&E.notAtBottomBecause==="SIZE_INCREASED"&&!x&&(mt(d)("scrolling to bottom due to increased size",{},zt.DEBUG),y("auto"))});setTimeout(T,100)}Je(Q(bt(Se(v),t,c),Te(([S,,T])=>S&&T),Tn(({value:S},[,T])=>({refreshed:S===T,value:T}),{refreshed:!1,value:0}),Te(({refreshed:S})=>S),Oe(v,t)),([,S])=>{mt(a)&&b(S!==!1)}),Je(g,()=>{b(mt(v)!==!1)}),Je(bt(Se(v),o),([S,T])=>{S&&!T.atBottom&&T.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&y("auto")});const C=re(null),k=He();return ge(Aa(Q(Se(r),fe(S=>{var T;return(T=S==null?void 0:S.length)!=null?T:0})),Q(Se(t))),k),Je(Q(bt(Q(k,nr(1)),l),Oe(Se(C),a,h,m),fe(([[S,T],E,j,_,$])=>T&&j&&(E==null?void 0:E({context:$,totalCount:S,scrollingInProgress:_}))),Te(S=>!!S),Pn(0)),S=>{x&&(x(),x=null),mt(n)?requestAnimationFrame(()=>{mt(d)("scrolling into view",{}),je(f,S)}):x=un(e,()=>{mt(d)("scrolling into view",{}),je(f,S),x=null})}),{autoscrollToBottom:g,followOutput:v,scrollIntoViewOnChange:C}},it(kn,Co,wo,bo,Un,zn,Dt,bh,yh)),pC=Ye(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(ge(Q(a,Oe(s),Te(([,l])=>l!==0),Oe(o,r,t,n,e),fe(([[,l],c,d,h,m,f=[]])=>xh(l,c,d,h,m,f))),i),{}),it(kn,bo,sr,Un),{singleton:!0}),mC=Ye(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=re(0);return Je(Q(e,Oe(r),Te(([,o])=>o!==0),fe(([,o])=>({top:o}))),o=>{un(Q(n,nr(1),Te(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{je(t,o)})})}),{initialScrollTop:r}},it(Un,Dt,sr),{singleton:!0}),Ch=Ye(([{scrollVelocity:e}])=>{const t=re(!1),n=He(),r=re(!1);return ge(Q(e,Oe(r,t,n),Te(([o,s])=>!!s),fe(([o,s,i,a])=>{const{enter:l,exit:c}=s;if(i){if(c(o,a))return!1}else if(l(o,a))return!0;return i}),at()),t),Je(Q(bt(t,e,n),Oe(r)),([[o,s,i],a])=>{o&&a&&a.change&&a.change(s,i)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},it(Co),{singleton:!0}),Ha=Ye(([{scrollContainerState:e,scrollTo:t}])=>{const n=He(),r=He(),o=He(),s=re(!1),i=re(void 0);return ge(Q(bt(n,r),fe(([{scrollHeight:a,scrollTop:l,viewportHeight:c},{offsetTop:d}])=>({scrollHeight:a,scrollTop:Math.max(0,l-d),viewportHeight:c}))),e),ge(Q(t,Oe(r),fe(([a,{offsetTop:l}])=>({...a,top:a.top+l}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},it(Dt)),gC=Ye(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:a,windowViewportRect:l}])=>{const c=He(),d=re(void 0),h=re(null),m=re(null);return ge(a,h),ge(l,m),Je(Q(c,Oe(t,r,i,h,m,n)),([f,v,g,x,y,b,C])=>{const k=QS(v.sizeTree);x&&y!==null&&b!==null&&(g=y.scrollTop-b.offsetTop),g-=C,f({ranges:k,scrollTop:g})}),ge(Q(d,Te(Ia),fe(xC)),o),ge(Q(s,Oe(d),Te(([,f])=>f!==void 0),at(),fe(([,f])=>f.ranges)),e),{getState:c,restoreStateFrom:d}},it(kn,Dt,bo,Un,Ha));function xC(e){return{align:"start",index:0,offset:e.scrollTop}}const vC=Ye(([{topItemsIndexes:e}])=>{const t=re(0);return ge(Q(t,Te(n=>n>=0),fe(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},it(sr));function Th(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const wC=Th(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),bC=Ye(([{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=Xt(Q(l,Oe(i),Tn(([,y,b,C],[{bottom:k,items:S,offsetBottom:T,totalCount:E},j])=>{const _=k+T;let $=0;return b===E&&y.length>0&&S.length>0&&(S[0].originalIndex===0&&y[0].originalIndex===0||($=_-C,$!==0&&($+=j))),[$,S,E,_]},[0,[],0,0]),Te(([y])=>y!==0),Oe(r,a,n,o,f,v),Te(([,y,b,C,,,k])=>!k&&!C&&y!==0&&b===yo),fe(([[y],,,,,b])=>(b("Upward scrolling compensation",{amount:y},zt.DEBUG),y))));function x(y){y>0?(je(t,{behavior:"auto",top:-y}),je(e,0)):(je(e,0),je(t,{behavior:"auto",top:-y}))}return Je(Q(g,Oe(e,s)),([y,b,C])=>{C&&wC()?je(e,b-y):x(-y)}),Je(Q(bt(jt(s,!1),e,v),Te(([y,b,C])=>!y&&!C&&b!==0),fe(([y,b])=>b),Pn(1)),x),ge(Q(h,fe(y=>({top:-y}))),t),Je(Q(c,Oe(m,d),fe(([y,{groupIndices:b,lastSize:C,sizeTree:k},S])=>{function T(E){return E*(C+S)}if(b.length===0)return T(y);{let E=0;const j=go(k,0);let _=0,$=0;for(;_<y;){_++,E+=j;let F=b.length===$+1?1/0:b[$+1]-b[$]-1;_+F>y&&(E-=j,F=y-_+1),_+=F,E+=T(F),$++}return E}})),y=>{je(e,y),requestAnimationFrame(()=>{je(t,{top:y}),requestAnimationFrame(()=>{je(e,0),je(v,!1)})})}),{deviation:e}},it(Dt,Co,sr,kn,zn,Oa)),yC=Ye(([e,t,n,r,o,s,i,a,l,c,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...l,...c,...d}),it(Ba,pC,Un,Ch,wh,mC,uC,Ha,yh,zn,bh)),kh=Ye(([{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:b,topItemsIndexes:C,...k},{scrollToIndex:S},T,{topItemCount:E},{groupCounts:j},_])=>(ge(k.rangeChanged,_.scrollSeekRangeChanged),ge(Q(_.windowViewportRect,fe($=>$.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:C,totalCount:d,...y,groupIndices:s,itemSize:i,listState:b,scrollToIndex:S,statefulTotalCount:c,trackItemSizes:h,...k,..._,...g,sizes:l,...x}),it(kn,bo,Dt,gC,hC,sr,wo,bC,vC,dh,yC));function SC(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 Os=typeof document<"u"?w.useLayoutEffect:w.useEffect;function Eh(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=w.createContext({});function l(x,y){x.propsReady&&je(x.propsReady,!1);for(const b of r){const C=x[t.required[b]];je(C,y[b])}for(const b of o)if(b in y){const C=x[t.optional[b]];je(C,y[b])}x.propsReady&&je(x.propsReady,!0)}function c(x){return s.reduce((y,b)=>(y[b]=C=>{const k=x[t.methods[b]];je(k,C)},y),{})}function d(x){return i.reduce((y,b)=>(y[b]=$S(x[t.events[b]]),y),{})}const h=w.forwardRef((x,y)=>{const{children:b,...C}=x,[k]=w.useState(()=>Is(BS(e),E=>{l(E,C)})),[S]=w.useState(Yf(d,k));Os(()=>{for(const E of i)E in C&&Je(S[E],C[E]);return()=>{Object.values(S).map(Na)}},[C,S,k]),Os(()=>{l(k,C)}),w.useImperativeHandle(y,qf(c(k)));const T=n;return u.jsx(a.Provider,{value:k,children:n?u.jsx(T,{...SC([...r,...o,...i],C),children:b}):b})}),m=x=>{const y=w.useContext(a);return w.useCallback(b=>{je(y[x],b)},[y,x])},f=x=>{const y=w.useContext(a)[x],b=w.useCallback(C=>Je(y,C),[y]);return w.useSyncExternalStore(b,()=>mt(y),()=>mt(y))},v=x=>{const y=w.useContext(a)[x],[b,C]=w.useState(Yf(mt,y));return Os(()=>Je(y,k=>{k!==b&&C(qf(k))}),[y,b]),b},g=w.version.startsWith("18")?f:v;return{Component:h,useEmitter:(x,y)=>{const b=w.useContext(a)[x];Os(()=>Je(b,y),[y,b])},useEmitterValue:g,usePublisher:m}}const Ih=w.createContext(void 0),Nh=w.createContext(void 0),Ah=typeof document<"u"?w.useLayoutEffect:w.useEffect;function Ua(e){return"self"in e}function CC(e){return"body"in e}function jh(e,t,n,r=Rr,o,s){const i=w.useRef(null),a=w.useRef(null),l=w.useRef(null),c=w.useCallback(m=>{let f,v,g;const x=m.target;if(CC(x)||Ua(x)){const b=Ua(x)?x:x.defaultView;g=s?b.scrollX:b.scrollY,f=s?b.document.documentElement.scrollWidth:b.document.documentElement.scrollHeight,v=s?b.innerWidth:b.innerHeight}else g=s?x.scrollLeft:x.scrollTop,f=s?x.scrollWidth:x.scrollHeight,v=s?x.offsetWidth:x.offsetHeight;const y=()=>{e({scrollHeight:f,scrollTop:Math.max(g,0),viewportHeight:v})};m.suppressFlushSync?y():Mo.flushSync(y),a.current!==null&&(g===a.current||g<=0||g===f-v)&&(a.current=null,t(!0),l.current&&(clearTimeout(l.current),l.current=null))},[e,t,s]);w.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;Ua(f)?(x=Math.max(Hn(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=Hn(f,s?"width":"height"),y=f[s?"scrollLeft":"scrollTop"]);const b=x-g;if(m.top=Math.ceil(Math.max(Math.min(b,m.top),0)),hh(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 Wa="-webkit-sticky",Ph="sticky",Va=Th(()=>{if(typeof document>"u")return Ph;const e=document.createElement("div");return e.style.position=Wa,e.style.position===Wa?Wa:Ph});function Ka(e){return e}const TC=Ye(()=>{const e=re(a=>`Item ${a}`),t=re(a=>`Group ${a}`),n=re({}),r=re(Ka),o=re("div"),s=re(Rr),i=(a,l=null)=>jt(Q(n,fe(c=>c[a]),at()),l);return{components:n,computeItemKey:r,EmptyPlaceholder:i("EmptyPlaceholder"),FooterComponent:i("Footer"),GroupComponent:i("Group","div"),groupContent:t,HeaderComponent:i("Header"),HeaderFooterTag:o,ItemComponent:i("Item","div"),itemContent:e,ListComponent:i("List","div"),ScrollerComponent:i("Scroller","div"),scrollerRef:s,ScrollSeekPlaceholder:i("ScrollSeekPlaceholder"),TopItemListComponent:i("TopItemList")}}),kC=Ye(([e,t])=>({...e,...t}),it(kh,TC)),EC=({height:e})=>u.jsx("div",{style:{height:e}}),IC={overflowAnchor:"none",position:Va(),zIndex:1},_h={overflowAnchor:"none"},NC={..._h,display:"inline-block",height:"100%"},Rh=w.memo(function({showTopList:e=!1}){const t=Ee("listState"),n=en("sizeRanges"),r=Ee("useWindowScroll"),o=Ee("customScrollParent"),s=en("windowScrollContainerState"),i=en("scrollContainerState"),a=o||r?s:i,l=Ee("itemContent"),c=Ee("context"),d=Ee("groupContent"),h=Ee("trackItemSizes"),m=Ee("itemSize"),f=Ee("log"),v=en("gap"),g=Ee("horizontalDirection"),{callbackRef:x}=US(n,m,h,e?Rr:a,f,v,o,g,Ee("skipAnimationFrameInResizeObserver")),[y,b]=w.useState(0);qa("deviation",R=>{y!==R&&b(R)});const C=Ee("EmptyPlaceholder"),k=Ee("ScrollSeekPlaceholder")||EC,S=Ee("ListComponent"),T=Ee("ItemComponent"),E=Ee("GroupComponent"),j=Ee("computeItemKey"),_=Ee("isSeeking"),$=Ee("groupIndices").length>0,F=Ee("alignToBottom"),U=Ee("initialItemFinalLocationReached"),X=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},...U?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&C?u.jsx(C,{...Pt(C,c)}):u.jsx(S,{...Pt(S,c),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:x,style:X,children:(e?t.topItems:t.items).map(R=>{const K=R.originalIndex,W=j(K+t.firstItemIndex,R.data,c);return _?w.createElement(k,{...Pt(k,c),height:R.size,index:R.index,key:W,type:R.type||"item",...R.type==="group"?{}:{groupIndex:R.groupIndex}}):R.type==="group"?w.createElement(E,{...Pt(E,c),"data-index":K,"data-item-index":R.index,"data-known-size":R.size,key:W,style:IC},d(R.index,c)):w.createElement(T,{...Pt(T,c),..._C(T,R.data),"data-index":K,"data-item-group-index":R.groupIndex,"data-item-index":R.index,"data-known-size":R.size,key:W,style:g?NC:_h},$?l(R.index,R.groupIndex,R.data,c):l(R.index,R.data,c))})})}),AC={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},jC={outline:"none",overflowX:"auto",position:"relative"},Ds=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),PC={position:Va(),top:0,width:"100%",zIndex:1};function Pt(e,t){if(typeof e!="string")return{context:t}}function _C(e,t){return{item:typeof e=="string"?void 0:t}}const RC=w.memo(function(){const e=Ee("HeaderComponent"),t=en("headerHeight"),n=Ee("HeaderFooterTag"),r=rr(w.useMemo(()=>s=>{t(Hn(s,"height"))},[t]),!0,Ee("skipAnimationFrameInResizeObserver")),o=Ee("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Pt(e,o)})}):null}),MC=w.memo(function(){const e=Ee("FooterComponent"),t=en("footerHeight"),n=Ee("HeaderFooterTag"),r=rr(w.useMemo(()=>s=>{t(Hn(s,"height"))},[t]),!0,Ee("skipAnimationFrameInResizeObserver")),o=Ee("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Pt(e,o)})}):null});function Mh({useEmitter:e,useEmitterValue:t,usePublisher:n}){return w.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}=jh(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?jC:AC,...o},tabIndex:0,...i,...Pt(l,s),children:r})})}function Oh({useEmitter:e,useEmitterValue:t,usePublisher:n}){return w.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=w.useRef(null),v=t("scrollerRef"),{scrollByCallback:g,scrollerRef:x,scrollToCallback:y}=jh(a,c,l,v,m);return Ah(()=>{var b;return x.current=m||((b=f.current)==null?void 0:b.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,...Pt(l,s),children:r})})}const OC=({children:e})=>{const t=w.useContext(Ih),n=en("viewportHeight"),r=en("fixedItemHeight"),o=Ee("alignToBottom"),s=Ee("horizontalDirection"),i=w.useMemo(()=>Gf(n,l=>Hn(l,s?"width":"height")),[n,s]),a=rr(i,!0,Ee("skipAnimationFrameInResizeObserver"));return w.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),u.jsx("div",{"data-viewport-type":"element",ref:a,style:Ds(o),children:e})},DC=({children:e})=>{const t=w.useContext(Ih),n=en("windowViewportRect"),r=en("fixedItemHeight"),o=Ee("customScrollParent"),s=Qf(n,o,Ee("skipAnimationFrameInResizeObserver")),i=Ee("alignToBottom");return w.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:Ds(i),children:e})},LC=({children:e})=>{const t=Ee("TopItemListComponent")||"div",n=Ee("headerHeight"),r={...PC,marginTop:`${n}px`},o=Ee("context");return u.jsx(t,{style:r,...Pt(t,o),children:e})},$C=w.memo(function(e){const t=Ee("useWindowScroll"),n=Ee("topItemsIndexes").length>0,r=Ee("customScrollParent"),o=Ee("context");return u.jsxs(r||t?zC:BC,{...e,context:o,children:[n&&u.jsx(LC,{children:u.jsx(Rh,{showTopList:!0})}),u.jsxs(r||t?DC:OC,{children:[u.jsx(RC,{}),u.jsx(Rh,{}),u.jsx(MC,{})]})]})}),{Component:FC,useEmitter:qa,useEmitterValue:Ee,usePublisher:en}=Eh(kC,{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"}},$C),BC=Mh({useEmitter:qa,useEmitterValue:Ee,usePublisher:en}),zC=Oh({useEmitter:qa,useEmitterValue:Ee,usePublisher:en}),HC=FC;it(kh,Ye(()=>{const e=re(c=>u.jsxs("td",{children:["Item $",c]})),t=re(null),n=re(c=>u.jsxs("td",{colSpan:1e3,children:["Group ",c]})),r=re(null),o=re(null),s=re({}),i=re(Ka),a=re(Rr),l=(c,d=null)=>jt(Q(s,fe(h=>h[c]),at()),d);return{components:s,computeItemKey:i,context:t,EmptyPlaceholder:l("EmptyPlaceholder"),FillerRow:l("FillerRow"),fixedFooterContent:o,fixedHeaderContent:r,itemContent:e,groupContent:n,ScrollerComponent:l("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder"),TableBodyComponent:l("TableBody","tbody"),TableComponent:l("Table","table"),TableFooterComponent:l("TableFoot","tfoot"),TableHeadComponent:l("TableHead","thead"),TableRowComponent:l("TableRow","tr"),GroupComponent:l("Group","tr")}})),Va();const Dh={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},UC={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:Lh,floor:Ls,max:To,min:Ga,round:$h}=Math;function Fh(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function WC(e){return{...UC,items:e}}function $s(e,t){return e&&e.width===t.width&&e.height===t.height}function VC(e,t){return e&&e.column===t.column&&e.row===t.row}const KC=Ye(([{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:b,windowScrollTo:C,windowViewportRect:k},S])=>{const T=re(0),E=re(0),j=re(Dh),_=re({height:0,width:0}),$=re({height:0,width:0}),F=He(),U=He(),X=re(0),R=re(null),K=re({column:0,row:0}),W=He(),z=He(),O=re(!1),I=re(0),G=re(!0),J=re(!1),P=re(!1);Je(Q(v,Oe(I),Te(([L,Y])=>!!Y)),()=>{je(G,!1)}),Je(Q(bt(v,G,$,_,I,J),Te(([L,Y,Z,oe,,se])=>L&&!Y&&Z.height!==0&&oe.height!==0&&!se)),([,,,,L])=>{je(J,!0),$a(1,()=>{je(F,L)}),un(Q(c),()=>{je(t,[0,0]),je(G,!0)})}),ge(Q(z,Te(L=>L!=null&&L.scrollTop>0),Cn(0)),E),Je(Q(v,Oe(z),Te(([,L])=>L!=null)),([,L])=>{L&&(je(_,L.viewport),je($,L.item),je(K,L.gap),L.scrollTop>0&&(je(O,!0),un(Q(c,nr(1)),Y=>{je(O,!1)}),je(l,{top:L.scrollTop})))}),ge(Q(_,fe(({height:L})=>L)),h),ge(Q(bt(Se(_,$s),Se($,$s),Se(K,(L,Y)=>L&&L.column===Y.column&&L.row===Y.row),Se(c)),fe(([L,Y,Z,oe])=>({gap:Z,item:Y,scrollTop:oe,viewport:L}))),W),ge(Q(bt(Se(T),r,Se(K,VC),Se($,$s),Se(_,$s),Se(R),Se(E),Se(O),Se(G),Se(I)),Te(([,,,,,,,L])=>!L),fe(([L,[Y,Z],oe,se,ie,le,ye,,De,We])=>{const{column:Pe,row:$e}=oe,{height:lt,width:ut}=se,{width:yt}=ie;if(ye===0&&(L===0||yt===0))return Dh;if(ut===0){const st=Fa(We,L),gt=st+Math.max(ye-1,0);return WC(Fh(st,gt,le))}const qe=Bh(yt,ut,Pe);let Xe,Ve;De?Y===0&&Z===0&&ye>0?(Xe=0,Ve=ye-1):(Xe=qe*Ls((Y+$e)/(lt+$e)),Ve=qe*Lh((Z+$e)/(lt+$e))-1,Ve=Ga(L-1,To(Ve,qe-1)),Xe=Ga(Ve,To(0,Xe))):(Xe=0,Ve=-1);const Le=Fh(Xe,Ve,le),{bottom:Ae,top:dt}=zh(ie,oe,se,Le),Rt=Lh(L/qe),tt=Rt*lt+(Rt-1)*$e-Ae;return{bottom:Ae,itemHeight:lt,items:Le,itemWidth:ut,offsetBottom:tt,offsetTop:dt,top:dt}})),j),ge(Q(R,Te(L=>L!==null),fe(L=>L.length)),T),ge(Q(bt(_,$,j,K),Te(([L,Y,{items:Z}])=>Z.length>0&&Y.height!==0&&L.height!==0),fe(([L,Y,{items:Z},oe])=>{const{bottom:se,top:ie}=zh(L,oe,Y,Z);return[ie,se]}),at(xo)),t);const B=re(!1);ge(Q(c,Oe(B),fe(([L,Y])=>Y||L!==0)),B);const A=Xt(Q(bt(j,T),Te(([{items:L}])=>L.length>0),Oe(B),Te(([[L,Y],Z])=>{const oe=L.items[L.items.length-1].index===Y-1;return(Z||L.bottom>0&&L.itemHeight>0&&L.offsetBottom===0&&L.items.length===Y)&&oe}),fe(([[,L]])=>L-1),at())),D=Xt(Q(Se(j),Te(({items:L})=>L.length>0&&L[0].index===0),Cn(0),at())),q=Xt(Q(Se(j),Oe(O),Te(([{items:L},Y])=>L.length>0&&!Y),fe(([{items:L}])=>({endIndex:L[L.length-1].index,startIndex:L[0].index})),at(ih),Pn(0)));ge(q,f.scrollSeekRangeChanged),ge(Q(F,Oe(_,$,T,K),fe(([L,Y,Z,oe,se])=>{const ie=fh(L),{align:le,behavior:ye,offset:De}=ie;let We=ie.index;We==="LAST"&&(We=oe-1),We=To(0,We,Ga(oe-1,We));let Pe=Ya(Y,se,Z,We);return le==="end"?Pe=$h(Pe-Y.height+Z.height):le==="center"&&(Pe=$h(Pe-Y.height/2+Z.height/2)),De&&(Pe+=De),{behavior:ye,top:Pe}})),l);const M=jt(Q(j,fe(L=>L.offsetBottom+L.bottom)),0);return ge(Q(k,fe(L=>({height:L.visibleHeight,width:L.visibleWidth}))),_),{customScrollParent:x,data:R,deviation:X,footerHeight:o,gap:K,headerHeight:s,increaseViewportBy:e,initialItemCount:E,itemDimensions:$,overscan:n,restoreStateFrom:z,scrollBy:i,scrollContainerState:a,scrollHeight:U,scrollTo:l,scrollToIndex:F,scrollTop:c,smoothScrollTargetReached:d,totalCount:T,useWindowScroll:y,viewportDimensions:_,windowScrollContainerState:b,windowScrollTo:C,windowViewportRect:k,...f,gridState:j,horizontalDirection:P,initialTopMostItemIndex:I,totalListHeight:M,...m,endReached:A,propsReady:g,rangeChanged:q,startReached:D,stateChanged:W,stateRestoreInProgress:O,...S}},it(Ba,Dt,Co,Ch,Un,Ha,zn));function Bh(e,t,n){return To(1,Ls((e+n)/(Ls(t)+n)))}function zh(e,t,n,r){const{height:o}=n;if(o===void 0||r.length===0)return{bottom:0,top:0};const s=Ya(e,t,n,r[0].index);return{bottom:Ya(e,t,n,r[r.length-1].index)+o,top:s}}function Ya(e,t,n,r){const o=Bh(e.width,n.width,t.column),s=Ls(r/o),i=s*n.height+To(0,s-1)*t.row;return i>0?i+t.row:i}const qC=Ye(()=>{const e=re(h=>`Item ${h}`),t=re({}),n=re(null),r=re("virtuoso-grid-item"),o=re("virtuoso-grid-list"),s=re(Ka),i=re("div"),a=re(Rr),l=(h,m=null)=>jt(Q(t,fe(f=>f[h]),at()),m),c=re(!1),d=re(!1);return ge(Se(d),c),{components:t,computeItemKey:s,context:n,FooterComponent:l("Footer"),HeaderComponent:l("Header"),headerFooterTag:i,itemClassName:r,ItemComponent:l("Item","div"),itemContent:e,listClassName:o,ListComponent:l("List","div"),readyStateChanged:c,reportReadyState:d,ScrollerComponent:l("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder","div")}}),GC=Ye(([e,t])=>({...e,...t}),it(KC,qC)),YC=w.memo(function(){const e=ct("gridState"),t=ct("listClassName"),n=ct("itemClassName"),r=ct("itemContent"),o=ct("computeItemKey"),s=ct("isSeeking"),i=tn("scrollHeight"),a=ct("ItemComponent"),l=ct("ListComponent"),c=ct("ScrollSeekPlaceholder"),d=ct("context"),h=tn("itemDimensions"),m=tn("gap"),f=ct("log"),v=ct("stateRestoreInProgress"),g=tn("reportReadyState"),x=rr(w.useMemo(()=>y=>{const b=y.parentElement.parentElement.scrollHeight;i(b);const C=y.firstChild;if(C){const{height:k,width:S}=C.getBoundingClientRect();h({height:k,width:S})}m({column:Uh("column-gap",getComputedStyle(y).columnGap,f),row:Uh("row-gap",getComputedStyle(y).rowGap,f)})},[i,h,m,f]),!0,!1);return Ah(()=>{e.itemHeight>0&&e.itemWidth>0&&g(!0)},[e]),v?null:u.jsx(l,{className:t,ref:x,...Pt(l,d),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(y=>{const b=o(y.index,y.data,d);return s?u.jsx(c,{...Pt(c,d),height:e.itemHeight,index:y.index,width:e.itemWidth},b):w.createElement(a,{...Pt(a,d),className:n,"data-index":y.index,key:b},r(y.index,y.data,d))})})}),XC=w.memo(function(){const e=ct("HeaderComponent"),t=tn("headerHeight"),n=ct("headerFooterTag"),r=rr(w.useMemo(()=>s=>{t(Hn(s,"height"))},[t]),!0,!1),o=ct("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Pt(e,o)})}):null}),JC=w.memo(function(){const e=ct("FooterComponent"),t=tn("footerHeight"),n=ct("headerFooterTag"),r=rr(w.useMemo(()=>s=>{t(Hn(s,"height"))},[t]),!0,!1),o=ct("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Pt(e,o)})}):null}),ZC=({children:e})=>{const t=w.useContext(Nh),n=tn("itemDimensions"),r=tn("viewportDimensions"),o=rr(w.useMemo(()=>s=>{r(s.getBoundingClientRect())},[r]),!0,!1);return w.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:Ds(!1),children:e})},QC=({children:e})=>{const t=w.useContext(Nh),n=tn("windowViewportRect"),r=tn("itemDimensions"),o=ct("customScrollParent"),s=Qf(n,o,!1);return w.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:Ds(!1),children:e})},eT=w.memo(function({...e}){const t=ct("useWindowScroll"),n=ct("customScrollParent"),r=n||t?nT:tT,o=n||t?QC:ZC,s=ct("context");return u.jsx(r,{...e,...Pt(r,s),children:u.jsxs(o,{children:[u.jsx(XC,{}),u.jsx(YC,{}),u.jsx(JC,{})]})})}),{useEmitter:Hh,useEmitterValue:ct,usePublisher:tn}=Eh(GC,{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"}},eT),tT=Mh({useEmitter:Hh,useEmitterValue:ct,usePublisher:tn}),nT=Oh({useEmitter:Hh,useEmitterValue:ct,usePublisher:tn});function Uh(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,zt.WARN),t==="normal"?0:parseInt(t??"0",10)}var Fs="Dialog",[Wh,M1]=an(Fs),[rT,fn]=Wh(Fs),Vh=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]=On({prop:r,defaultProp:o??!1,onChange:s,caller:Fs});return u.jsx(rT,{scope:t,triggerRef:a,contentRef:l,contentId:At(),titleId:At(),descriptionId:At(),open:c,onOpenChange:d,onOpenToggle:p.useCallback(()=>d(h=>!h),[d]),modal:i,children:n})};Vh.displayName=Fs;var Kh="DialogTrigger",qh=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=fn(Kh,n),s=Me(t,o.triggerRef);return u.jsx(me.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Za(o.open),...r,ref:s,onClick:ae(e.onClick,o.onOpenToggle)})});qh.displayName=Kh;var Xa="DialogPortal",[oT,Gh]=Wh(Xa,{forceMount:void 0}),Yh=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=fn(Xa,t);return u.jsx(oT,{scope:t,forceMount:n,children:p.Children.map(r,i=>u.jsx(Bt,{present:n||s.open,children:u.jsx(io,{asChild:!0,container:o,children:i})}))})};Yh.displayName=Xa;var Bs="DialogOverlay",Xh=p.forwardRef((e,t)=>{const n=Gh(Bs,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=fn(Bs,e.__scopeDialog);return s.modal?u.jsx(Bt,{present:r||s.open,children:u.jsx(iT,{...o,ref:t})}):null});Xh.displayName=Bs;var sT=Vt.createSlot("DialogOverlay.RemoveScroll"),iT=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=fn(Bs,n);return u.jsx(vs,{as:sT,allowPinchZoom:!0,shards:[o.contentRef],children:u.jsx(me.div,{"data-state":Za(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),ir="DialogContent",Jh=p.forwardRef((e,t)=>{const n=Gh(ir,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=fn(ir,e.__scopeDialog);return u.jsx(Bt,{present:r||s.open,children:s.modal?u.jsx(aT,{...o,ref:t}):u.jsx(lT,{...o,ref:t})})});Jh.displayName=ir;var aT=p.forwardRef((e,t)=>{const n=fn(ir,e.__scopeDialog),r=p.useRef(null),o=Me(t,n.contentRef,r);return p.useEffect(()=>{const s=r.current;if(s)return ha(s)},[]),u.jsx(Zh,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ae(e.onCloseAutoFocus,s=>{var i;s.preventDefault(),(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:ae(e.onPointerDownOutside,s=>{const i=s.detail.originalEvent,a=i.button===0&&i.ctrlKey===!0;(i.button===2||a)&&s.preventDefault()}),onFocusOutside:ae(e.onFocusOutside,s=>s.preventDefault())})}),lT=p.forwardRef((e,t)=>{const n=fn(ir,e.__scopeDialog),r=p.useRef(!1),o=p.useRef(!1);return u.jsx(Zh,{...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()}})}),Zh=p.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=fn(ir,n),l=p.useRef(null),c=Me(t,l);return Wi(),u.jsxs(u.Fragment,{children:[u.jsx(Qo,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:u.jsx(Sr,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":Za(a.open),...i,ref:c,onDismiss:()=>a.onOpenChange(!1)})}),u.jsxs(u.Fragment,{children:[u.jsx(cT,{titleId:a.titleId}),u.jsx(dT,{contentRef:l,descriptionId:a.descriptionId})]})]})}),Ja="DialogTitle",Qh=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=fn(Ja,n);return u.jsx(me.h2,{id:o.titleId,...r,ref:t})});Qh.displayName=Ja;var ep="DialogDescription",tp=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=fn(ep,n);return u.jsx(me.p,{id:o.descriptionId,...r,ref:t})});tp.displayName=ep;var np="DialogClose",rp=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=fn(np,n);return u.jsx(me.button,{type:"button",...r,ref:t,onClick:ae(e.onClick,()=>o.onOpenChange(!1))})});rp.displayName=np;function Za(e){return e?"open":"closed"}var op="DialogTitleWarning",[O1,sp]=kw(op,{contentName:ir,titleName:Ja,docsSlug:"dialog"}),cT=({titleId:e})=>{const t=sp(op),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},uT="DialogDescriptionWarning",dT=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${sp(uT).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},Qa=Vh,fT=qh,el=Yh,ko=Xh,Eo=Jh,ar=Qh,zs=tp,ip=rp;const tl=Qa,hT=el,ap=p.forwardRef(({className:e,...t},n)=>u.jsx(ko,{ref:n,className:te("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}));ap.displayName=ko.displayName;const Hs=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===ar||(c==null?void 0:c.displayName)===ar.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(hT,{children:[u.jsx(ap,{}),u.jsxs(Eo,{ref:r,className:te("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(ar,{className:"sr-only",children:"Dialog"}),t,u.jsxs(ip,{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(le.X,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]})});Hs.displayName=Eo.displayName;const Us=({className:e,...t})=>u.jsx("div",{className:te("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});Us.displayName="DialogHeader";const Ws=p.forwardRef(({className:e,...t},n)=>u.jsx(ar,{ref:n,className:te("text-lg font-semibold leading-none tracking-tight",e),...t}));Ws.displayName=ar.displayName;const pT=p.forwardRef(({className:e,...t},n)=>u.jsx(zs,{ref:n,className:te("text-sm text-muted-foreground",e),...t}));pT.displayName=zs.displayName;const mT=1,gT=1e6;let nl=0;function xT(){return nl=(nl+1)%Number.MAX_SAFE_INTEGER,nl.toString()}const rl=new Map,lp=e=>{if(rl.has(e))return;const t=setTimeout(()=>{rl.delete(e),Io({type:"REMOVE_TOAST",toastId:e})},gT);rl.set(e,t)},vT=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,mT)};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?lp(n):e.toasts.forEach(r=>{lp(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)}}},Vs=[];let Ks={toasts:[]};function Io(e){Ks=vT(Ks,e),Vs.forEach(t=>{t(Ks)})}function wT({...e}){const t=xT(),n=o=>Io({type:"UPDATE_TOAST",toast:{...o,id:t}}),r=()=>Io({type:"DISMISS_TOAST",toastId:t});return Io({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:o=>{o||r()}}}),{id:t,dismiss:r,update:n}}function ol(){const[e,t]=p.useState(Ks);return p.useEffect(()=>(Vs.push(t),()=>{const n=Vs.indexOf(t);n>-1&&Vs.splice(n,1)}),[e]),{...e,toast:wT,dismiss:n=>Io({type:"DISMISS_TOAST",toastId:n})}}function cp({isOpen:e,onClose:t,fileId:n,fileName:r,mimeType:o}){const[s,i]=w.useState(!1),[a,l]=w.useState(null),[c,d]=w.useState(null),{toast:h}=ol(),m=w.useCallback(async()=>{if(n){i(!0),d(null),l(null);try{const y=await Mi(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]);w.useEffect(()=>{e&&n&&m()},[e,n,m]);const f=async()=>{if(n)try{await eu(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 Mi(n),b=new Blob([y],{type:o}),C=URL.createObjectURL(b);window.open(C,"_blank"),URL.revokeObjectURL(C)}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(le.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(et,{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(le.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(le.Image,{className:"h-5 w-5"}):u.jsx(le.FileText,{className:"h-5 w-5"});return u.jsx(tl,{open:e,onOpenChange:t,children:u.jsxs(Hs,{className:"max-w-4xl max-h-[90vh] overflow-hidden",children:[u.jsx(Us,{children:u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[x(),u.jsxs("div",{children:[u.jsx(Ws,{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(et,{variant:"outline",size:"sm",onClick:v,className:"flex items-center gap-2",children:[u.jsx(le.ExternalLink,{className:"h-4 w-4"}),"External"]}),u.jsxs(et,{variant:"outline",size:"sm",onClick:f,className:"flex items-center gap-2",children:[u.jsx(le.Download,{className:"h-4 w-4"}),"Download"]})]})]})}),u.jsx("div",{className:"flex-1 overflow-hidden",children:g()})]})})}function up(){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 lr=up();function bT(e){lr=e}const dp=/[&<>"']/,yT=new RegExp(dp.source,"g"),fp=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,ST=new RegExp(fp.source,"g"),CT={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},hp=e=>CT[e];function Rt(e,t){if(t){if(dp.test(e))return e.replace(yT,hp)}else if(fp.test(e))return e.replace(ST,hp);return e}const TT=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function pp(e){return e.replace(TT,(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 kT=/(^|[^\[])\^/g;function ot(e,t){e=typeof e=="string"?e:e.source,t=t||"";const n={replace:(r,o)=>(o=o.source||o,o=o.replace(kT,"$1"),e=e.replace(r,o),n),getRegex:()=>new RegExp(e,t)};return n}const ET=/[^\w:]/g,IT=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function mp(e,t,n){if(e){let r;try{r=decodeURIComponent(pp(n)).replace(ET,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}t&&!IT.test(n)&&(n=PT(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const qs={},NT=/^[^:]+:\/*[^/]*$/,AT=/^([^:]+:)[\s\S]*$/,jT=/^([^:]+:\/*[^/]*)[\s\S]*$/;function PT(e,t){qs[" "+e]||(NT.test(e)?qs[" "+e]=e+"/":qs[" "+e]=Ys(e,"/",!0)),e=qs[" "+e];const n=e.indexOf(":")===-1;return t.substring(0,2)==="//"?n?t:e.replace(AT,"$1")+t:t.charAt(0)==="/"?n?t:e.replace(jT,"$1")+t:e+t}const Gs={exec:function(){}};function gp(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 Ys(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 _T(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 RT(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 xp(e,t){if(t<1)return"";let n="";for(;t>1;)t&1&&(n+=e),t>>=1,e+=e;return n+e}function vp(e,t,n,r){const o=t.href,s=t.title?Rt(t.title):null,i=e[1].replace(/\\([\[\]])/g,"$1");if(e[0].charAt(0)!=="!"){r.state.inLink=!0;const a={type:"link",raw:n,href:o,title:s,text:i,tokens:r.inlineTokens(i)};return r.state.inLink=!1,a}return{type:"image",raw:n,href:o,title:s,text:Rt(i)}}function MT(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 p.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},uT="DialogDescriptionWarning",dT=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${sp(uT).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},Qa=Vh,fT=qh,el=Yh,ko=Xh,Eo=Jh,ar=Qh,zs=tp,ip=rp;const tl=Qa,hT=el,ap=p.forwardRef(({className:e,...t},n)=>u.jsx(ko,{ref:n,className:te("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}));ap.displayName=ko.displayName;const Hs=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===ar||(c==null?void 0:c.displayName)===ar.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(hT,{children:[u.jsx(ap,{}),u.jsxs(Eo,{ref:r,className:te("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(ar,{className:"sr-only",children:"Dialog"}),t,u.jsxs(ip,{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(ce.X,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]})});Hs.displayName=Eo.displayName;const Us=({className:e,...t})=>u.jsx("div",{className:te("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});Us.displayName="DialogHeader";const Ws=p.forwardRef(({className:e,...t},n)=>u.jsx(ar,{ref:n,className:te("text-lg font-semibold leading-none tracking-tight",e),...t}));Ws.displayName=ar.displayName;const pT=p.forwardRef(({className:e,...t},n)=>u.jsx(zs,{ref:n,className:te("text-sm text-muted-foreground",e),...t}));pT.displayName=zs.displayName;const mT=1,gT=1e6;let nl=0;function xT(){return nl=(nl+1)%Number.MAX_SAFE_INTEGER,nl.toString()}const rl=new Map,lp=e=>{if(rl.has(e))return;const t=setTimeout(()=>{rl.delete(e),Io({type:"REMOVE_TOAST",toastId:e})},gT);rl.set(e,t)},vT=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,mT)};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?lp(n):e.toasts.forEach(r=>{lp(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)}}},Vs=[];let Ks={toasts:[]};function Io(e){Ks=vT(Ks,e),Vs.forEach(t=>{t(Ks)})}function wT({...e}){const t=xT(),n=o=>Io({type:"UPDATE_TOAST",toast:{...o,id:t}}),r=()=>Io({type:"DISMISS_TOAST",toastId:t});return Io({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:o=>{o||r()}}}),{id:t,dismiss:r,update:n}}function ol(){const[e,t]=p.useState(Ks);return p.useEffect(()=>(Vs.push(t),()=>{const n=Vs.indexOf(t);n>-1&&Vs.splice(n,1)}),[e]),{...e,toast:wT,dismiss:n=>Io({type:"DISMISS_TOAST",toastId:n})}}function cp({isOpen:e,onClose:t,fileId:n,fileName:r,mimeType:o}){const[s,i]=w.useState(!1),[a,l]=w.useState(null),[c,d]=w.useState(null),{toast:h}=ol(),m=w.useCallback(async()=>{if(n){i(!0),d(null),l(null);try{const y=await Mi(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]);w.useEffect(()=>{e&&n&&m()},[e,n,m]);const f=async()=>{if(n)try{await eu(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 Mi(n),b=new Blob([y],{type:o}),C=URL.createObjectURL(b);window.open(C,"_blank"),URL.revokeObjectURL(C)}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(ce.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(Qe,{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(ce.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(ce.Image,{className:"h-5 w-5"}):u.jsx(ce.FileText,{className:"h-5 w-5"});return u.jsx(tl,{open:e,onOpenChange:t,children:u.jsxs(Hs,{className:"max-w-4xl max-h-[90vh] overflow-hidden",children:[u.jsx(Us,{children:u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[x(),u.jsxs("div",{children:[u.jsx(Ws,{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(Qe,{variant:"outline",size:"sm",onClick:v,className:"flex items-center gap-2",children:[u.jsx(ce.ExternalLink,{className:"h-4 w-4"}),"External"]}),u.jsxs(Qe,{variant:"outline",size:"sm",onClick:f,className:"flex items-center gap-2",children:[u.jsx(ce.Download,{className:"h-4 w-4"}),"Download"]})]})]})}),u.jsx("div",{className:"flex-1 overflow-hidden",children:g()})]})})}function up(){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 lr=up();function bT(e){lr=e}const dp=/[&<>"']/,yT=new RegExp(dp.source,"g"),fp=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,ST=new RegExp(fp.source,"g"),CT={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},hp=e=>CT[e];function _t(e,t){if(t){if(dp.test(e))return e.replace(yT,hp)}else if(fp.test(e))return e.replace(ST,hp);return e}const TT=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function pp(e){return e.replace(TT,(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 kT=/(^|[^\[])\^/g;function rt(e,t){e=typeof e=="string"?e:e.source,t=t||"";const n={replace:(r,o)=>(o=o.source||o,o=o.replace(kT,"$1"),e=e.replace(r,o),n),getRegex:()=>new RegExp(e,t)};return n}const ET=/[^\w:]/g,IT=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function mp(e,t,n){if(e){let r;try{r=decodeURIComponent(pp(n)).replace(ET,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}t&&!IT.test(n)&&(n=PT(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const qs={},NT=/^[^:]+:\/*[^/]*$/,AT=/^([^:]+:)[\s\S]*$/,jT=/^([^:]+:\/*[^/]*)[\s\S]*$/;function PT(e,t){qs[" "+e]||(NT.test(e)?qs[" "+e]=e+"/":qs[" "+e]=Ys(e,"/",!0)),e=qs[" "+e];const n=e.indexOf(":")===-1;return t.substring(0,2)==="//"?n?t:e.replace(AT,"$1")+t:t.charAt(0)==="/"?n?t:e.replace(jT,"$1")+t:e+t}const Gs={exec:function(){}};function gp(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 Ys(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 _T(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 RT(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 xp(e,t){if(t<1)return"";let n="";for(;t>1;)t&1&&(n+=e),t>>=1,e+=e;return n+e}function vp(e,t,n,r){const o=t.href,s=t.title?_t(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:_t(i)}}function MT(e,t){const n=e.match(/^(\s+)(?:```)/);if(n===null)return t;const r=n[1];return t.split(`
84
84
  `).map(o=>{const s=o.match(/^\s+/);if(s===null)return o;const[i]=s;return i.length>=r.length?o.slice(r.length):o}).join(`
85
85
  `)}class sl{constructor(t){this.options=t||lr}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:Ys(r,`
86
86
  `)}}}fences(t){const n=this.rules.block.fences.exec(t);if(n){const r=n[0],o=MT(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=Ys(r,"#");(this.options.pedantic||!o||/ $/.test(o))&&(r=o.trim())}return{type:"heading",raw:n[0],depth:n[1].length,text:r,tokens:this.lexer.inline(r)}}}hr(t){const n=this.rules.block.hr.exec(t);if(n)return{type:"hr",raw:n[0]}}blockquote(t){const n=this.rules.block.blockquote.exec(t);if(n){const r=n[0].replace(/^ *>[ \t]?/gm,""),o=this.lexer.state.top;this.lexer.state.top=!0;const s=this.lexer.blockTokens(r);return this.lexer.state.top=o,{type:"blockquote",raw:n[0],tokens:s,text:r}}}list(t){let n=this.rules.block.list.exec(t);if(n){let r,o,s,i,a,l,c,d,h,m,f,v,g=n[1].trim();const x=g.length>1,y={type:"list",raw:"",ordered:x,start:x?+g.slice(0,-1):"",loose:!1,items:[]};g=x?`\\d{1,9}\\${g.slice(-1)}`:`\\${g}`,this.options.pedantic&&(g=x?g:"[*+-]");const b=new RegExp(`^( {0,3}${g})((?:[ ][^\\n]*)?(?:\\n|$))`);for(;t&&(v=!1,!(!(n=b.exec(t))||this.rules.block.hr.test(t)));){if(r=n[0],t=t.substring(r.length),d=n[2].split(`
@@ -90,10 +90,10 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
90
90
  `,1)[0],h=m,this.options.pedantic&&(h=h.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),!(T.test(h)||E.test(h)||k.test(h)||S.test(t)));){if(h.search(/[^ ]/)>=i||!h.trim())f+=`
91
91
  `+h.slice(i);else{if(l||d.search(/[^ ]/)>=4||T.test(d)||E.test(d)||S.test(d))break;f+=`
92
92
  `+h}!l&&!h.trim()&&(l=!0),r+=m+`
93
- `,t=t.substring(m.length+1),d=h.slice(i)}}y.loose||(c?y.loose=!0:/\n *\n *$/.test(r)&&(c=!0)),this.options.gfm&&(o=/^\[[ xX]\] /.exec(f),o&&(s=o[0]!=="[ ] ",f=f.replace(/^\[[ xX]\] +/,""))),y.items.push({type:"list_item",raw:r,task:!!o,checked:s,loose:!1,text:f}),y.raw+=r}y.items[y.items.length-1].raw=r.trimRight(),y.items[y.items.length-1].text=f.trimRight(),y.raw=y.raw.trimRight();const C=y.items.length;for(a=0;a<C;a++)if(this.lexer.state.top=!1,y.items[a].tokens=this.lexer.blockTokens(y.items[a].text,[]),!y.loose){const k=y.items[a].tokens.filter(T=>T.type==="space"),S=k.length>0&&k.some(T=>/\n.*\n/.test(T.raw));y.loose=S}if(y.loose)for(a=0;a<C;a++)y.items[a].loose=!0;return y}}html(t){const n=this.rules.block.html.exec(t);if(n){const r={type:"html",raw:n[0],pre:!this.options.sanitizer&&(n[1]==="pre"||n[1]==="script"||n[1]==="style"),text:n[0]};if(this.options.sanitize){const o=this.options.sanitizer?this.options.sanitizer(n[0]):Rt(n[0]);r.type="paragraph",r.text=o,r.tokens=this.lexer.inline(o)}return r}}def(t){const n=this.rules.block.def.exec(t);if(n){const r=n[1].toLowerCase().replace(/\s+/g," "),o=n[2]?n[2].replace(/^<(.*)>$/,"$1").replace(this.rules.inline._escapes,"$1"):"",s=n[3]?n[3].substring(1,n[3].length-1).replace(this.rules.inline._escapes,"$1"):n[3];return{type:"def",tag:r,raw:n[0],href:o,title:s}}}table(t){const n=this.rules.block.table.exec(t);if(n){const r={type:"table",header:gp(n[1]).map(o=>({text:o})),align:n[2].replace(/^ *|\| *$/g,"").split(/ *\| */),rows:n[3]&&n[3].trim()?n[3].replace(/\n[ \t]*$/,"").split(`
93
+ `,t=t.substring(m.length+1),d=h.slice(i)}}y.loose||(c?y.loose=!0:/\n *\n *$/.test(r)&&(c=!0)),this.options.gfm&&(o=/^\[[ xX]\] /.exec(f),o&&(s=o[0]!=="[ ] ",f=f.replace(/^\[[ xX]\] +/,""))),y.items.push({type:"list_item",raw:r,task:!!o,checked:s,loose:!1,text:f}),y.raw+=r}y.items[y.items.length-1].raw=r.trimRight(),y.items[y.items.length-1].text=f.trimRight(),y.raw=y.raw.trimRight();const C=y.items.length;for(a=0;a<C;a++)if(this.lexer.state.top=!1,y.items[a].tokens=this.lexer.blockTokens(y.items[a].text,[]),!y.loose){const k=y.items[a].tokens.filter(T=>T.type==="space"),S=k.length>0&&k.some(T=>/\n.*\n/.test(T.raw));y.loose=S}if(y.loose)for(a=0;a<C;a++)y.items[a].loose=!0;return y}}html(t){const n=this.rules.block.html.exec(t);if(n){const r={type:"html",raw:n[0],pre:!this.options.sanitizer&&(n[1]==="pre"||n[1]==="script"||n[1]==="style"),text:n[0]};if(this.options.sanitize){const o=this.options.sanitizer?this.options.sanitizer(n[0]):_t(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:gp(n[1]).map(o=>({text:o})),align:n[2].replace(/^ *|\| *$/g,"").split(/ *\| */),rows:n[3]&&n[3].trim()?n[3].replace(/\n[ \t]*$/,"").split(`
94
94
  `):[]};if(r.header.length===r.align.length){r.raw=n[0];let o=r.align.length,s,i,a,l;for(s=0;s<o;s++)/^ *-+: *$/.test(r.align[s])?r.align[s]="right":/^ *:-+: *$/.test(r.align[s])?r.align[s]="center":/^ *:-+ *$/.test(r.align[s])?r.align[s]="left":r.align[s]=null;for(o=r.rows.length,s=0;s<o;s++)r.rows[s]=gp(r.rows[s],r.header.length).map(c=>({text:c}));for(o=r.header.length,i=0;i<o;i++)r.header[i].tokens=this.lexer.inline(r.header[i].text);for(o=r.rows.length,i=0;i<o;i++)for(l=r.rows[i],a=0;a<l.length;a++)l[a].tokens=this.lexer.inline(l[a].text);return r}}}lheading(t){const n=this.rules.block.lheading.exec(t);if(n)return{type:"heading",raw:n[0],depth:n[2].charAt(0)==="="?1:2,text:n[1],tokens:this.lexer.inline(n[1])}}paragraph(t){const n=this.rules.block.paragraph.exec(t);if(n){const r=n[1].charAt(n[1].length-1)===`
95
- `?n[1].slice(0,-1):n[1];return{type:"paragraph",raw:n[0],text:r,tokens:this.lexer.inline(r)}}}text(t){const n=this.rules.block.text.exec(t);if(n)return{type:"text",raw:n[0],text:n[0],tokens:this.lexer.inline(n[0])}}escape(t){const n=this.rules.inline.escape.exec(t);if(n)return{type:"escape",raw:n[0],text:Rt(n[1])}}tag(t){const n=this.rules.inline.tag.exec(t);if(n)return!this.lexer.state.inLink&&/^<a /i.test(n[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&/^<\/a>/i.test(n[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(n[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(n[0])&&(this.lexer.state.inRawBlock=!1),{type:this.options.sanitize?"text":"html",raw:n[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(n[0]):Rt(n[0]):n[0]}}link(t){const n=this.rules.inline.link.exec(t);if(n){const r=n[2].trim();if(!this.options.pedantic&&/^</.test(r)){if(!/>$/.test(r))return;const i=Ys(r.slice(0,-1),"\\");if((r.length-i.length)%2===0)return}else{const i=_T(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)),vp(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 vp(r,o,r[0],this.lexer)}}emStrong(t,n,r=""){let o=this.rules.inline.emStrong.lDelim.exec(t);if(!o||o[3]&&r.match(/[\p{L}\p{N}]/u))return;const s=o[1]||o[2]||"";if(!s||s&&(r===""||this.rules.inline.punctuation.exec(r))){const i=o[0].length-1;let a,l,c=i,d=0;const h=o[0][0]==="*"?this.rules.inline.emStrong.rDelimAst:this.rules.inline.emStrong.rDelimUnd;for(h.lastIndex=0,n=n.slice(-1*t.length+i);(o=h.exec(n))!=null;){if(a=o[1]||o[2]||o[3]||o[4]||o[5]||o[6],!a)continue;if(l=a.length,o[3]||o[4]){c+=l;continue}else if((o[5]||o[6])&&i%3&&!((i+l)%3)){d+=l;continue}if(c-=l,c>0)continue;l=Math.min(l,l+c+d);const m=t.slice(0,i+o.index+(o[0].length-a.length)+l);if(Math.min(i,l)%2){const v=m.slice(1,-1);return{type:"em",raw:m,text:v,tokens:this.lexer.inlineTokens(v)}}const f=m.slice(2,-2);return{type:"strong",raw:m,text:f,tokens:this.lexer.inlineTokens(f)}}}}codespan(t){const n=this.rules.inline.code.exec(t);if(n){let r=n[2].replace(/\n/g," ");const o=/[^ ]/.test(r),s=/^ /.test(r)&&/ $/.test(r);return o&&s&&(r=r.substring(1,r.length-1)),r=Rt(r,!0),{type:"codespan",raw:n[0],text:r}}}br(t){const n=this.rules.inline.br.exec(t);if(n)return{type:"br",raw:n[0]}}del(t){const n=this.rules.inline.del.exec(t);if(n)return{type:"del",raw:n[0],text:n[2],tokens:this.lexer.inlineTokens(n[2])}}autolink(t,n){const r=this.rules.inline.autolink.exec(t);if(r){let o,s;return r[2]==="@"?(o=Rt(this.options.mangle?n(r[1]):r[1]),s="mailto:"+o):(o=Rt(r[1]),s=o),{type:"link",raw:r[0],text:o,href:s,tokens:[{type:"text",raw:o,text:o}]}}}url(t,n){let r;if(r=this.rules.inline.url.exec(t)){let o,s;if(r[2]==="@")o=Rt(this.options.mangle?n(r[0]):r[0]),s="mailto:"+o;else{let i;do i=r[0],r[0]=this.rules.inline._backpedal.exec(r[0])[0];while(i!==r[0]);o=Rt(r[0]),r[1]==="www."?s="http://"+r[0]:s=r[0]}return{type:"link",raw:r[0],text:o,href:s,tokens:[{type:"text",raw:o,text:o}]}}}inlineText(t,n){const r=this.rules.inline.text.exec(t);if(r){let o;return this.lexer.state.inRawBlock?o=this.options.sanitize?this.options.sanitizer?this.options.sanitizer(r[0]):Rt(r[0]):r[0]:o=Rt(this.options.smartypants?n(r[0]):r[0]),{type:"text",raw:r[0],text:o}}}}const we={newline:/^(?: *(?:\n|$))+/,code:/^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,fences:/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,hr:/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,blockquote:/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,list:/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/,html:"^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n *)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$))",def:/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/,table:Gs,lheading:/^((?:.|\n(?!\n))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,text:/^[^\n]+/};we._label=/(?!\s*\])(?:\\.|[^\[\]\\])+/,we._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,we.def=ot(we.def).replace("label",we._label).replace("title",we._title).getRegex(),we.bullet=/(?:[*+-]|\d{1,9}[.)])/,we.listItemStart=ot(/^( *)(bull) */).replace("bull",we.bullet).getRegex(),we.list=ot(we.list).replace(/bull/g,we.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+we.def.source+")").getRegex(),we._tag="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",we._comment=/<!--(?!-?>)[\s\S]*?(?:-->|$)/,we.html=ot(we.html,"i").replace("comment",we._comment).replace("tag",we._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),we.paragraph=ot(we._paragraph).replace("hr",we.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",we._tag).getRegex(),we.blockquote=ot(we.blockquote).replace("paragraph",we.paragraph).getRegex(),we.normal={...we},we.gfm={...we.normal,table:"^ *([^\\n ].*\\|.*)\\n {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"},we.gfm.table=ot(we.gfm.table).replace("hr",we.hr).replace("heading"," {0,3}#{1,6} ").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",we._tag).getRegex(),we.gfm.paragraph=ot(we._paragraph).replace("hr",we.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("table",we.gfm.table).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",we._tag).getRegex(),we.pedantic={...we.normal,html:ot(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",we._comment).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Gs,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:ot(we.normal._paragraph).replace("hr",we.hr).replace("heading",` *#{1,6} *[^
96
- ]`).replace("lheading",we.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()};const he={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:Gs,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:Gs,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,punctuation:/^([\spunctuation])/};he._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",he.punctuation=ot(he.punctuation).replace(/punctuation/g,he._punctuation).getRegex(),he.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g,he.escapedEmSt=/(?:^|[^\\])(?:\\\\)*\\[*_]/g,he._comment=ot(we._comment).replace("(?:-->|$)","-->").getRegex(),he.emStrong.lDelim=ot(he.emStrong.lDelim).replace(/punct/g,he._punctuation).getRegex(),he.emStrong.rDelimAst=ot(he.emStrong.rDelimAst,"g").replace(/punct/g,he._punctuation).getRegex(),he.emStrong.rDelimUnd=ot(he.emStrong.rDelimUnd,"g").replace(/punct/g,he._punctuation).getRegex(),he._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,he._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,he._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])?)+(?![-_])/,he.autolink=ot(he.autolink).replace("scheme",he._scheme).replace("email",he._email).getRegex(),he._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,he.tag=ot(he.tag).replace("comment",he._comment).replace("attribute",he._attribute).getRegex(),he._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,he._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/,he._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,he.link=ot(he.link).replace("label",he._label).replace("href",he._href).replace("title",he._title).getRegex(),he.reflink=ot(he.reflink).replace("label",he._label).replace("ref",we._label).getRegex(),he.nolink=ot(he.nolink).replace("ref",we._label).getRegex(),he.reflinkSearch=ot(he.reflinkSearch,"g").replace("reflink",he.reflink).replace("nolink",he.nolink).getRegex(),he.normal={...he},he.pedantic={...he.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:ot(/^!?\[(label)\]\((.*?)\)/).replace("label",he._label).getRegex(),reflink:ot(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",he._label).getRegex()},he.gfm={...he.normal,escape:ot(he.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.!#$%&'*+\/=?_`{\|}~-]+@)))/},he.gfm.url=ot(he.gfm.url,"i").replace("email",he.gfm._extended_email).getRegex(),he.breaks={...he.gfm,br:ot(he.br).replace("{2,}","*").getRegex(),text:ot(he.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()};function OT(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 wp(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 Wn{constructor(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||lr,this.options.tokenizer=this.options.tokenizer||new sl,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};const n={block:we.normal,inline:he.normal};this.options.pedantic?(n.block=we.pedantic,n.inline=he.pedantic):this.options.gfm&&(n.block=we.gfm,this.options.breaks?n.inline=he.breaks:n.inline=he.gfm),this.tokenizer.rules=n}static get rules(){return{block:we,inline:he}}static lex(t,n){return new Wn(n).lex(t)}static lexInline(t,n){return new Wn(n).inlineTokens(t)}lex(t){t=t.replace(/\r\n|\r/g,`
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:_t(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]):_t(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=Ys(r.slice(0,-1),"\\");if((r.length-i.length)%2===0)return}else{const i=_T(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)),vp(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 vp(r,o,r[0],this.lexer)}}emStrong(t,n,r=""){let o=this.rules.inline.emStrong.lDelim.exec(t);if(!o||o[3]&&r.match(/[\p{L}\p{N}]/u))return;const s=o[1]||o[2]||"";if(!s||s&&(r===""||this.rules.inline.punctuation.exec(r))){const i=o[0].length-1;let a,l,c=i,d=0;const h=o[0][0]==="*"?this.rules.inline.emStrong.rDelimAst:this.rules.inline.emStrong.rDelimUnd;for(h.lastIndex=0,n=n.slice(-1*t.length+i);(o=h.exec(n))!=null;){if(a=o[1]||o[2]||o[3]||o[4]||o[5]||o[6],!a)continue;if(l=a.length,o[3]||o[4]){c+=l;continue}else if((o[5]||o[6])&&i%3&&!((i+l)%3)){d+=l;continue}if(c-=l,c>0)continue;l=Math.min(l,l+c+d);const m=t.slice(0,i+o.index+(o[0].length-a.length)+l);if(Math.min(i,l)%2){const v=m.slice(1,-1);return{type:"em",raw:m,text:v,tokens:this.lexer.inlineTokens(v)}}const f=m.slice(2,-2);return{type:"strong",raw:m,text:f,tokens:this.lexer.inlineTokens(f)}}}}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=_t(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=_t(this.options.mangle?n(r[1]):r[1]),s="mailto:"+o):(o=_t(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=_t(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=_t(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]):_t(r[0]):r[0]:o=_t(this.options.smartypants?n(r[0]):r[0]),{type:"text",raw:r[0],text:o}}}}const be={newline:/^(?: *(?:\n|$))+/,code:/^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,fences:/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,hr:/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,blockquote:/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,list:/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/,html:"^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n *)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$))",def:/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/,table:Gs,lheading:/^((?:.|\n(?!\n))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,text:/^[^\n]+/};be._label=/(?!\s*\])(?:\\.|[^\[\]\\])+/,be._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,be.def=rt(be.def).replace("label",be._label).replace("title",be._title).getRegex(),be.bullet=/(?:[*+-]|\d{1,9}[.)])/,be.listItemStart=rt(/^( *)(bull) */).replace("bull",be.bullet).getRegex(),be.list=rt(be.list).replace(/bull/g,be.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+be.def.source+")").getRegex(),be._tag="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",be._comment=/<!--(?!-?>)[\s\S]*?(?:-->|$)/,be.html=rt(be.html,"i").replace("comment",be._comment).replace("tag",be._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),be.paragraph=rt(be._paragraph).replace("hr",be.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",be._tag).getRegex(),be.blockquote=rt(be.blockquote).replace("paragraph",be.paragraph).getRegex(),be.normal={...be},be.gfm={...be.normal,table:"^ *([^\\n ].*\\|.*)\\n {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"},be.gfm.table=rt(be.gfm.table).replace("hr",be.hr).replace("heading"," {0,3}#{1,6} ").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",be._tag).getRegex(),be.gfm.paragraph=rt(be._paragraph).replace("hr",be.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("table",be.gfm.table).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",be._tag).getRegex(),be.pedantic={...be.normal,html:rt(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",be._comment).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Gs,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:rt(be.normal._paragraph).replace("hr",be.hr).replace("heading",` *#{1,6} *[^
96
+ ]`).replace("lheading",be.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()};const he={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:Gs,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:Gs,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,punctuation:/^([\spunctuation])/};he._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",he.punctuation=rt(he.punctuation).replace(/punctuation/g,he._punctuation).getRegex(),he.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g,he.escapedEmSt=/(?:^|[^\\])(?:\\\\)*\\[*_]/g,he._comment=rt(be._comment).replace("(?:-->|$)","-->").getRegex(),he.emStrong.lDelim=rt(he.emStrong.lDelim).replace(/punct/g,he._punctuation).getRegex(),he.emStrong.rDelimAst=rt(he.emStrong.rDelimAst,"g").replace(/punct/g,he._punctuation).getRegex(),he.emStrong.rDelimUnd=rt(he.emStrong.rDelimUnd,"g").replace(/punct/g,he._punctuation).getRegex(),he._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,he._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,he._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])?)+(?![-_])/,he.autolink=rt(he.autolink).replace("scheme",he._scheme).replace("email",he._email).getRegex(),he._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,he.tag=rt(he.tag).replace("comment",he._comment).replace("attribute",he._attribute).getRegex(),he._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,he._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/,he._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,he.link=rt(he.link).replace("label",he._label).replace("href",he._href).replace("title",he._title).getRegex(),he.reflink=rt(he.reflink).replace("label",he._label).replace("ref",be._label).getRegex(),he.nolink=rt(he.nolink).replace("ref",be._label).getRegex(),he.reflinkSearch=rt(he.reflinkSearch,"g").replace("reflink",he.reflink).replace("nolink",he.nolink).getRegex(),he.normal={...he},he.pedantic={...he.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:rt(/^!?\[(label)\]\((.*?)\)/).replace("label",he._label).getRegex(),reflink:rt(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",he._label).getRegex()},he.gfm={...he.normal,escape:rt(he.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.!#$%&'*+\/=?_`{\|}~-]+@)))/},he.gfm.url=rt(he.gfm.url,"i").replace("email",he.gfm._extended_email).getRegex(),he.breaks={...he.gfm,br:rt(he.br).replace("{2,}","*").getRegex(),text:rt(he.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()};function OT(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 wp(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 Wn{constructor(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||lr,this.options.tokenizer=this.options.tokenizer||new sl,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};const n={block:be.normal,inline:he.normal};this.options.pedantic?(n.block=be.pedantic,n.inline=he.pedantic):this.options.gfm&&(n.block=be.gfm,this.options.breaks?n.inline=he.breaks:n.inline=he.gfm),this.tokenizer.rules=n}static get rules(){return{block:be,inline:he}}static lex(t,n){return new Wn(n).lex(t)}static lexInline(t,n){return new Wn(n).inlineTokens(t)}lex(t){t=t.replace(/\r\n|\r/g,`
97
97
  `),this.blockTokens(t,this.tokens);let n;for(;n=this.inlineQueue.shift();)this.inlineTokens(n.src,n.tokens);return this.tokens}blockTokens(t,n=[]){this.options.pedantic?t=t.replace(/\t/g," ").replace(/^ +$/gm,""):t=t.replace(/^( *)(\t+)/gm,(a,l,c)=>l+" ".repeat(c.length));let r,o,s,i;for(;t;)if(!(this.options.extensions&&this.options.extensions.block&&this.options.extensions.block.some(a=>(r=a.call({lexer:this},t,n))?(t=t.substring(r.raw.length),n.push(r),!0):!1))){if(r=this.tokenizer.space(t)){t=t.substring(r.raw.length),r.raw.length===1&&n.length>0?n[n.length-1].raw+=`
98
98
  `:n.push(r);continue}if(r=this.tokenizer.code(t)){t=t.substring(r.raw.length),o=n[n.length-1],o&&(o.type==="paragraph"||o.type==="text")?(o.raw+=`
99
99
  `+r.raw,o.text+=`
@@ -104,8 +104,8 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
104
104
  `+r.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=o.text):n.push(r),i=s.length!==t.length,t=t.substring(r.raw.length);continue}if(r=this.tokenizer.text(t)){t=t.substring(r.raw.length),o=n[n.length-1],o&&o.type==="text"?(o.raw+=`
105
105
  `+r.raw,o.text+=`
106
106
  `+r.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=o.text):n.push(r);continue}if(t){const a="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(a);break}else throw new Error(a)}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}inlineTokens(t,n=[]){let r,o,s,i=t,a,l,c;if(this.tokens.links){const d=Object.keys(this.tokens.links);if(d.length>0)for(;(a=this.tokenizer.rules.inline.reflinkSearch.exec(i))!=null;)d.includes(a[0].slice(a[0].lastIndexOf("[")+1,-1))&&(i=i.slice(0,a.index)+"["+xp("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)+"["+xp("a",a[0].length-2)+"]"+i.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;(a=this.tokenizer.rules.inline.escapedEmSt.exec(i))!=null;)i=i.slice(0,a.index+a[0].length-2)+"++"+i.slice(this.tokenizer.rules.inline.escapedEmSt.lastIndex),this.tokenizer.rules.inline.escapedEmSt.lastIndex--;for(;t;)if(l||(c=""),l=!1,!(this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some(d=>(r=d.call({lexer:this},t,n))?(t=t.substring(r.raw.length),n.push(r),!0):!1))){if(r=this.tokenizer.escape(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.tag(t)){t=t.substring(r.raw.length),o=n[n.length-1],o&&r.type==="text"&&o.type==="text"?(o.raw+=r.raw,o.text+=r.text):n.push(r);continue}if(r=this.tokenizer.link(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(r.raw.length),o=n[n.length-1],o&&r.type==="text"&&o.type==="text"?(o.raw+=r.raw,o.text+=r.text):n.push(r);continue}if(r=this.tokenizer.emStrong(t,i,c)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.codespan(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.br(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.del(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.autolink(t,wp)){t=t.substring(r.raw.length),n.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(t,wp))){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 h=t.slice(1);let m;this.options.extensions.startInline.forEach(function(f){m=f.call({lexer:this},h),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,OT)){t=t.substring(r.raw.length),r.raw.slice(-1)!=="_"&&(c=r.raw.slice(-1)),l=!0,o=n[n.length-1],o&&o.type==="text"?(o.raw+=r.raw,o.text+=r.text):n.push(r);continue}if(t){const d="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(d);break}else throw new Error(d)}}return n}}class il{constructor(t){this.options=t||lr}code(t,n,r){const o=(n||"").match(/\S*/)[0];if(this.options.highlight){const s=this.options.highlight(t,o);s!=null&&s!==t&&(r=!0,t=s)}return t=t.replace(/\n$/,"")+`
107
- `,o?'<pre><code class="'+this.options.langPrefix+Rt(o)+'">'+(r?t:Rt(t,!0))+`</code></pre>
108
- `:"<pre><code>"+(r?t:Rt(t,!0))+`</code></pre>
107
+ `,o?'<pre><code class="'+this.options.langPrefix+_t(o)+'">'+(r?t:_t(t,!0))+`</code></pre>
108
+ `:"<pre><code>"+(r?t:_t(t,!0))+`</code></pre>
109
109
  `}blockquote(t){return`<blockquote>
110
110
  ${t}</blockquote>
111
111
  `}html(t){return t}heading(t,n,r,o){if(this.options.headerIds){const s=this.options.headerPrefix+o.slug(r);return`<h${n} id="${s}">${t}</h${n}>
@@ -124,8 +124,8 @@ ${t}</blockquote>
124
124
  ${t}</tr>
125
125
  `}tablecell(t,n){const r=n.header?"th":"td";return(n.align?`<${r} align="${n.align}">`:`<${r}>`)+t+`</${r}>
126
126
  `}strong(t){return`<strong>${t}</strong>`}em(t){return`<em>${t}</em>`}codespan(t){return`<code>${t}</code>`}br(){return this.options.xhtml?"<br/>":"<br>"}del(t){return`<del>${t}</del>`}link(t,n,r){if(t=mp(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=mp(this.options.sanitize,this.options.baseUrl,t),t===null)return r;let o=`<img src="${t}" alt="${r}"`;return n&&(o+=` title="${n}"`),o+=this.options.xhtml?"/>":">",o}text(t){return t}}class bp{strong(t){return t}em(t){return t}codespan(t){return t}del(t){return t}html(t){return t}text(t){return t}link(t,n,r){return""+r}image(t,n,r){return""+r}br(){return""}}class yp{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 Vn{constructor(t){this.options=t||lr,this.options.renderer=this.options.renderer||new il,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new bp,this.slugger=new yp}static parse(t,n){return new Vn(n).parse(t)}static parseInline(t,n){return new Vn(n).parseInline(t)}parse(t,n=!0){let r="",o,s,i,a,l,c,d,h,m,f,v,g,x,y,b,C,k,S,T;const E=t.length;for(o=0;o<E;o++){if(f=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[f.type]&&(T=this.options.extensions.renderers[f.type].call({parser:this},f),T!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(f.type))){r+=T||"";continue}switch(f.type){case"space":continue;case"hr":{r+=this.renderer.hr();continue}case"heading":{r+=this.renderer.heading(this.parseInline(f.tokens),f.depth,pp(this.parseInline(f.tokens,this.textRenderer)),this.slugger);continue}case"code":{r+=this.renderer.code(f.text,f.lang,f.escaped);continue}case"table":{for(h="",d="",a=f.header.length,s=0;s<a;s++)d+=this.renderer.tablecell(this.parseInline(f.header[s].tokens),{header:!0,align:f.align[s]});for(h+=this.renderer.tablerow(d),m="",a=f.rows.length,s=0;s<a;s++){for(c=f.rows[s],d="",l=c.length,i=0;i<l;i++)d+=this.renderer.tablecell(this.parseInline(c[i].tokens),{header:!1,align:f.align[i]});m+=this.renderer.tablerow(d)}r+=this.renderer.table(h,m);continue}case"blockquote":{m=this.parse(f.tokens),r+=this.renderer.blockquote(m);continue}case"list":{for(v=f.ordered,g=f.start,x=f.loose,a=f.items.length,m="",s=0;s<a;s++)b=f.items[s],C=b.checked,k=b.task,y="",b.task&&(S=this.renderer.checkbox(C),x?b.tokens.length>0&&b.tokens[0].type==="paragraph"?(b.tokens[0].text=S+" "+b.tokens[0].text,b.tokens[0].tokens&&b.tokens[0].tokens.length>0&&b.tokens[0].tokens[0].type==="text"&&(b.tokens[0].tokens[0].text=S+" "+b.tokens[0].tokens[0].text)):b.tokens.unshift({type:"text",text:S}):y+=S),y+=this.parse(b.tokens,x),m+=this.renderer.listitem(y,k,C);r+=this.renderer.list(m,v,g);continue}case"html":{r+=this.renderer.html(f.text);continue}case"paragraph":{r+=this.renderer.paragraph(this.parseInline(f.tokens));continue}case"text":{for(m=f.tokens?this.parseInline(f.tokens):f.text;o+1<E&&t[o+1].type==="text";)f=t[++o],m+=`
127
- `+(f.tokens?this.parseInline(f.tokens):f.text);r+=n?this.renderer.paragraph(m):m;continue}default:{const A='Token with "'+f.type+'" type was not found.';if(this.options.silent){console.error(A);return}else throw new Error(A)}}}return r}parseInline(t,n){n=n||this.renderer;let r="",o,s,i;const a=t.length;for(o=0;o<a;o++){if(s=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[s.type]&&(i=this.options.extensions.renderers[s.type].call({parser:this},s),i!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type))){r+=i||"";continue}switch(s.type){case"escape":{r+=n.text(s.text);break}case"html":{r+=n.html(s.text);break}case"link":{r+=n.link(s.href,s.title,this.parseInline(s.tokens,n));break}case"image":{r+=n.image(s.href,s.title,s.text);break}case"strong":{r+=n.strong(this.parseInline(s.tokens,n));break}case"em":{r+=n.em(this.parseInline(s.tokens,n));break}case"codespan":{r+=n.codespan(s.text);break}case"br":{r+=n.br();break}case"del":{r+=n.del(this.parseInline(s.tokens,n));break}case"text":{r+=n.text(s.text);break}default:{const l='Token with "'+s.type+'" type was not found.';if(this.options.silent){console.error(l);return}else throw new Error(l)}}}return r}}class Xs{constructor(t){this.options=t||lr}preprocess(t){return t}postprocess(t){return t}}nx(Xs,"passThroughHooks",new Set(["preprocess","postprocess"]));function DT(e,t,n){return r=>{if(r.message+=`
128
- Please report this to https://github.com/markedjs/marked.`,e){const o="<p>An error occurred:</p><pre>"+Rt(r.message+"",!0)+"</pre>";if(t)return Promise.resolve(o);if(n){n(null,o);return}return o}if(t)return Promise.reject(r);if(n){n(r);return}throw r}}function Sp(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...ve.defaults,...s};const i=DT(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(RT(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&&ve.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;ve.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(ve.walkTokens(a,r.walkTokens)).then(()=>a):a).then(a=>t(a,r)).then(a=>r.hooks?r.hooks.postprocess(a):a).catch(i);try{r.hooks&&(n=r.hooks.preprocess(n));const a=e(n,r);r.walkTokens&&ve.walkTokens(a,r.walkTokens);let l=t(a,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(a){return i(a)}}}function ve(e,t,n){return Sp(Wn.lex,Vn.parse)(e,t,n)}ve.options=ve.setOptions=function(e){return ve.defaults={...ve.defaults,...e},bT(ve.defaults),ve},ve.getDefaults=up,ve.defaults=lr,ve.use=function(...e){const t=ve.defaults.extensions||{renderers:{},childTokens:{}};e.forEach(n=>{const r={...n};if(r.async=ve.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(o=>{if(!o.name)throw new Error("extension name required");if(o.renderer){const s=t.renderers[o.name];s?t.renderers[o.name]=function(...i){let a=o.renderer.apply(this,i);return a===!1&&(a=s.apply(this,i)),a}:t.renderers[o.name]=o.renderer}if(o.tokenizer){if(!o.level||o.level!=="block"&&o.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");t[o.level]?t[o.level].unshift(o.tokenizer):t[o.level]=[o.tokenizer],o.start&&(o.level==="block"?t.startBlock?t.startBlock.push(o.start):t.startBlock=[o.start]:o.level==="inline"&&(t.startInline?t.startInline.push(o.start):t.startInline=[o.start]))}o.childTokens&&(t.childTokens[o.name]=o.childTokens)}),r.extensions=t),n.renderer){const o=ve.defaults.renderer||new il;for(const s in n.renderer){const i=o[s];o[s]=(...a)=>{let l=n.renderer[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.renderer=o}if(n.tokenizer){const o=ve.defaults.tokenizer||new sl;for(const s in n.tokenizer){const i=o[s];o[s]=(...a)=>{let l=n.tokenizer[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.tokenizer=o}if(n.hooks){const o=ve.defaults.hooks||new Xs;for(const s in n.hooks){const i=o[s];Xs.passThroughHooks.has(s)?o[s]=a=>{if(ve.defaults.async)return Promise.resolve(n.hooks[s].call(o,a)).then(c=>i.call(o,c));const l=n.hooks[s].call(o,a);return i.call(o,l)}:o[s]=(...a)=>{let l=n.hooks[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.hooks=o}if(n.walkTokens){const o=ve.defaults.walkTokens;r.walkTokens=function(s){let i=[];return i.push(n.walkTokens.call(this,s)),o&&(i=i.concat(o.call(this,s))),i}}ve.setOptions(r)})},ve.walkTokens=function(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(ve,r)),r.type){case"table":{for(const o of r.header)n=n.concat(ve.walkTokens(o.tokens,t));for(const o of r.rows)for(const s of o)n=n.concat(ve.walkTokens(s.tokens,t));break}case"list":{n=n.concat(ve.walkTokens(r.items,t));break}default:ve.defaults.extensions&&ve.defaults.extensions.childTokens&&ve.defaults.extensions.childTokens[r.type]?ve.defaults.extensions.childTokens[r.type].forEach(function(o){n=n.concat(ve.walkTokens(r[o],t))}):r.tokens&&(n=n.concat(ve.walkTokens(r.tokens,t)))}return n},ve.parseInline=Sp(Wn.lexInline,Vn.parseInline),ve.Parser=Vn,ve.parser=Vn.parse,ve.Renderer=il,ve.TextRenderer=bp,ve.Lexer=Wn,ve.lexer=Wn.lex,ve.Tokenizer=sl,ve.Slugger=yp,ve.Hooks=Xs,ve.parse=ve,ve.options,ve.setOptions,ve.use,ve.walkTokens,ve.parseInline,Vn.parse,Wn.lex;function cr({content:e,className:t="",allowHtml:n=!1,style:r}){const o=w.useMemo(()=>{if(!e||typeof e!="string"||e.trim().length===0)return"";try{if(!n){const i=e.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"").replace(/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi,"").replace(/javascript:/gi,"").replace(/on\w+\s*=/gi,"");return typeof ve.parse=="function"?ve.parse(i):ve(i)}return typeof ve.parse=="function"?ve.parse(e):ve(e)}catch(i){return console.error("[MarkdownContent] parse error",i),`<pre class="font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words">Error rendering markdown: ${String(i)}</pre>`}},[e,n]),s=w.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:te("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 Cp({preview:e,idx:t}){return u.jsxs("div",{className:"space-y-2",children:[e.label&&u.jsxs("p",{className:"text-[0.65rem] uppercase tracking-wide text-muted-foreground",children:["Artifact: ",e.label]}),u.jsx("div",{className:"overflow-hidden rounded border border-border/60 bg-background/60 p-1 shadow-sm",children:u.jsx("img",{src:e.src,alt:e.alt,title:e.label,loading:"lazy",className:"h-auto max-h-[420px] w-full rounded object-contain",onLoad:()=>{},onError:n=>{console.error(`[MessageComponent] ❌ Image failed to load for artifact ${t}:`,{alt:e.alt,label:e.label,message:n.target.alt})}})})]})}function Tp({artifact:e,idx:t=0}){const n=w.useMemo(()=>e?(Array.isArray(e.plots)?e.plots:[]).map(o=>iw(o)).filter(o=>o!==null):[],[e]);return n.length>0?u.jsx("div",{className:"space-y-2",children:n.map((r,o)=>u.jsx(Cp,{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 LT="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 Js({data:e}){return Array.isArray(e)?e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?u.jsx("div",{className:LT,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 kp({message:e,isStreaming:t=!1}){const n=e.name??"tool",r=w.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(le.Loader,{className:"h-3 w-3 animate-spin"}),u.jsx("span",{children:s??`Running ${n}…`})]}),r.length>0&&u.jsx("div",{className:"space-y-2 text-xs text-muted-foreground",children:r.map((a,l)=>{var c;return u.jsxs("div",{className:"rounded border border-current/10 bg-muted/60 p-2 text-[11px] leading-snug",children:[u.jsxs("div",{className:"mb-1 flex items-center justify-between text-[8px] uppercase tracking-wide text-muted-foreground",children:[u.jsx("span",{children:((c=a.type)==null?void 0:c.replace(/\./g," "))??"progress"}),u.jsx("span",{children:a.idx??l+1})]}),a.content&&u.jsx("p",{className:"mt-1 text-[12px] text-foreground/90",children:a.content}),u.jsxs("div",{className:"mt-1 flex flex-wrap gap-2 text-[10px] opacity-70",children:[typeof a.factsFound=="number"&&u.jsxs("span",{children:["Facts found: ",a.factsFound]}),typeof a.isSufficient=="boolean"&&u.jsxs("span",{children:["Research ",a.isSufficient?"sufficient":"needs more data"]})]})]},`tool-progress-${n}-${l}`)})})]}):null}const al=p.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:te("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));al.displayName="Card";const ll=p.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:te("flex flex-col space-y-1.5 p-6",e),...t}));ll.displayName="CardHeader";const cl=p.forwardRef(({className:e,...t},n)=>u.jsx("h3",{ref:n,className:te("text-2xl font-semibold leading-none tracking-tight",e),...t}));cl.displayName="CardTitle";const ul=p.forwardRef(({className:e,...t},n)=>u.jsx("p",{ref:n,className:te("text-sm text-muted-foreground",e),...t}));ul.displayName="CardDescription";const dl=p.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:te("p-6 pt-0",e),...t}));dl.displayName="CardContent";const Ep=p.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:te("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(al,{className:te("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(ll,{className:"pb-3",children:[u.jsx(cl,{className:"text-blue-900 dark:text-blue-100 text-base",children:i}),u.jsx(ul,{className:"text-blue-700 dark:text-blue-300 text-sm",children:l})]}),a&&u.jsx(dl,{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(et,{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(et,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",disabled:r||!o,children:"Approve"})]})})]})}function Np({className:e}){const[t,n]=w.useState(0);return w.useEffect(()=>{const r=setInterval(()=>n(o=>(o+1)%4),500);return()=>clearInterval(r)},[]),u.jsxs("span",{"aria-live":"polite",className:te("inline-block text-xs opacity-70 ml-1",e),children:["Is thinking",".".repeat(t)]})}function Ap({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:te("text-sm text-[hsl(var(--chat-bubble-user-text))]",o&&"text-xs"),children:t?u.jsx(cr,{content:e,allowHtml:!1}):u.jsxs("pre",{className:te("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(et,{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(le.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):u.jsxs(u.Fragment,{children:[u.jsx(le.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",s," chars)"]})})]})}function jp(e){const{allowFileOpen:t,currentThreadId:n}=e,{toast:r}=ol(),[o,s]=w.useState({}),[i,a]=w.useState(null),[l,c]=w.useState(!1),d=w.useCallback(()=>{c(!1),a(null)},[]),h=w.useCallback(f=>{a(f),c(!0)},[]),m=w.useCallback(async(f,v,g)=>{var x,y;if(!t){f.preventDefault();return}if(o[g]){f.preventDefault();return}try{const b=String(v.url??""),C=b.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);if(C){f.preventDefault();const k=C[1],S=v.name||`file_${k}`,T=v.mimeType||"application/octet-stream";h({id:k,name:S,mimeType:T});return}if(b.startsWith("data:")){f.preventDefault(),s(S=>({...S,[g]:!0}));const k=r({title:"Fetching file...",description:"",open:!0});try{const S=await tu(n??void 0);if(!S||!Array.isArray(S))throw new Error("Invalid file list response");const T=S.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(S){console.error("Failed to fetch server file:",S);const T=S instanceof Error?S.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(S=>({...S,[g]:!1}))}}}catch(b){console.error("File click error:",b),s(C=>({...C,[g]:!1}))}},[t,o,r,n,h]);return{uploadingFiles:o,handleFileClick:m,fileViewerOpen:l,currentFileInfo:i,closeFileViewer:d}}function Pp(e,t){return w.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:ew(r),toolMeta:Di(n),imageParts:r.filter(s=>s.type==="image_url"),fileParts:r.filter(s=>s.type==="file"),interruptParts:r.filter(s=>s.type==="interrupt"),toolRaw:tw(r),isToolStreaming:!!o.toolStreaming}},[e,t])}const _p="data:";function $T(e){if(!e)return[];const t=[],n=e.split(/\r?\n/);for(const r of n){const o=r.trim();if(!o||!o.startsWith(_p))continue;const s=o.slice(_p.length).trim();if(!s||s.toLowerCase()==="[done]")continue;const i=Qr(s);i&&typeof i=="object"&&t.push(i)}return t}function FT(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 BT(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 zT(e){return w.useMemo(()=>{const t=e.content.filter(c=>c.type==="text");if(!t.length)return null;let r=t.flatMap(c=>$T(c.text??""));if(!r.length){const c=t.map(h=>h.text??"").join(`
129
- `),d=Qr(c);d&&typeof d=="object"&&(r=[d])}if(!r.length)return null;const s=BT(r)??r[r.length-1];if(!s)return null;const i=s.output??s.payload??s,a=wr(i),l=FT(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 Rp({message:e,viewMode:t,isStreaming:n=!1,toolRenderers:r,toolArtifactRenderers:o}){var C;const s=Di(e),i=e.artifact??null,a=zT(e),l=e.content.find(k=>k.type!=="tool_call"),c=k=>{if(k==null)return null;const S=typeof k=="string"?Qr(k)??k:k;if(S&&typeof S=="object")return u.jsx(Js,{data:S});const T=typeof S=="string"?S:(()=>{try{return vr(S)}catch{return String(S??"")}})();return u.jsx("pre",{className:"whitespace-pre-wrap break-words font-sans text-sm text-foreground/90",children:T})},d=k=>{if(k==null)return null;const{content:S,isMarkdown:T}=Qv(k);return T?u.jsx(cr,{content:S,className:"text-current"}):c(k)},h=k=>u.jsxs("div",{className:"space-y-2 rounded-2xl border border-muted-foreground/30 bg-white/80 p-4 shadow-sm shadow-slate-900/10",children:[u.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-[0.4em] text-muted-foreground",children:"Structured dictionary"}),u.jsx(Js,{data:k})]}),m=()=>{if((a==null?void 0:a.kind)==="generic")return d(a.value);if(!l)return null;if(l.type==="text"){const E=(l.text??"").trim();if(!E)return null;const A=wr(E);return d(A)}const k=eo(l),S=wr(k);return d(S)},f=()=>(a==null?void 0:a.kind)==="dict"?h(a.data):m(),g=(()=>{if(r){if(s.name){const k=r[s.name];if(k)return k}if(a!=null&&a.kind){const k=r[a.kind];if(k)return k}return r.default}})(),x=(g==null?void 0:g({message:e,toolMeta:s,toolPayload:a,viewMode:t,isStreaming:n}))??null,b=((C=(()=>{if(!o)return;const k=i==null?void 0:i.type;if(typeof k=="string"){const S=o[k];if(S)return S}return o.default})())==null?void 0:C({artifact:i,message:e,toolPayload:a,isStreaming:n}))??null;return u.jsxs("div",{className:"space-y-2",children:[i&&(b??u.jsx(Tp,{artifact:i,idx:0})),u.jsx(kp,{message:e,isStreaming:n}),t==="expanded"&&u.jsx(u.Fragment,{children:x??f()})]})}const HT={checkpoints:[],checkpointMetaByCheckpointId:new Map,timeline:[],messagePreviews:new Map,getLatest:()=>{},getCheckpoint:()=>{},getMessageAttempts:()=>[]},fl=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,hl=w.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:b,getMessageCustomStyles:C,toolRenderers:k,toolArtifactRenderers:S}){const T=fl(t,n),E=t.role==="default_message",R=!!t.__syntheticStreaming,$=y??HT,F=!E&&"checkpointId"in t?t.checkpointId??null:null,{attemptCount:V,attemptIndex:X,attempts:_}=w.useMemo(()=>tc(t.id,F,$),[t.id,F,$]),G=C==null?void 0:C(t);return u.jsx("div",{className:"relative mb-4 last:mb-0","data-message-id":T,style:{minHeight:"60px",containIntrinsicSize:"auto 120px"},children:u.jsx(Zs,{message:t,messageIndex:n,isStreamingMessage:R||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:V,attemptIndex:X,attemptMetas:_,onSelectCheckpoint:b,customStyles:G,toolRenderers:k,toolArtifactRenderers:S})})});hl.displayName="MessageRow";function UT(e,t,n){const[r,o]=w.useState(e),s=w.useRef([]);return w.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 WT({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:b,messageRole:C,truncateUserMessages:k,userMessagePreviewLength:S,isUserExpanded:T,setIsUserExpanded:E,isCompactLayout:A,activeInterruptId:R,activeInterruptValue:$,iconForeground:F,toolRenderers:V,toolArtifactRenderers:X}){const _=w.useCallback(()=>u.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/30 rounded",children:[u.jsx(le.Loader,{className:"h-4 w-4 text-muted-foreground"}),u.jsx("span",{className:"text-sm text-muted-foreground",children:"File upload"})]}),[]),H=UT(s,(h??!0)&&d,Mp),z=w.useMemo(()=>H.filter(O=>O.type==="text"),[H]),D=w.useMemo(()=>z.map(O=>O.text??"").join(""),[z]),I=w.useMemo(()=>{if(!m)return null;const O=VT(D);return{stablePart:D.slice(0,O),tailPart:D.slice(O)}},[D,m]),Y=w.useMemo(()=>{if(!I)return null;const{stablePart:O,tailPart:K}=I;return!O&&!K?null:u.jsxs("div",{className:"space-y-2",children:[O?u.jsx(cr,{content:O,allowHtml:!1}):null,K?u.jsx(cr,{content:K,allowHtml:!1}):null]})},[I]),J=w.useMemo(()=>{if(!m)return H;const O=[];let K=!1;for(const M of H){if(M.type==="text"){K||(O.push({type:"text",text:"",__streamingMarkdownAggregate:!0}),K=!0);continue}O.push(M)}return O},[H,m]),j=m?J:H,B=w.useCallback(({part:O,i:K})=>{if(O.type==="text"){if(m)return null;const M=O.text??"",L=M.trim(),q=Qr(L);return q&&C!=="tool"?u.jsx(Js,{data:q},K):C==="user"&&k&&L.length>S?u.jsx(Ap,{text:L,expanded:T,onExpandedChange:E,previewLength:S,isCompact:A},K):u.jsx(cr,{content:M,allowHtml:!1},K)}if(O.type==="image_url"){const M=O;return u.jsx("div",{className:"my-2",children:u.jsx("img",{src:M.url,alt:M.alt??"",loading:"lazy",className:"border rounded max-h-[420px] w-auto object-contain"})},K)}if(O.type==="file"){const M=O,L=M.name||"file";return u.jsxs("a",{href:M.url,onClick:q=>v(q,M,K),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[K]?u.jsx(le.Loader,{className:"h-4 w-4 animate-spin"}):null,u.jsxs("span",{className:"truncate max-w-[180px]",children:[L,g[K]?" (processing)":""]})]},K)}if(O.type==="interrupt"){const M=O,L=Xo((M==null?void 0:M.id)??(M==null?void 0:M.interrupt_id)),q=!!(R&&L&&L===R),Z=q?$??(M==null?void 0:M.value):M==null?void 0:M.value,se=L?{...M,id:L,interrupt_id:L}:M;return u.jsx(Ip,{interruptPart:se,onApprove:x,onReject:y,disabled:b,isActive:q,payload:Z},K)}return null},[R,$,b,v,x,y,A,T,C,k,g,S,m,E]),P=i.trim().length>0||a.length>0||l.length>0||c.length>0;if(!t&&l.length>0&&!d)return _();if(!t&&!P&&!d)return null;if(t)return n?u.jsx(Rp,{message:e,viewMode:r,isStreaming:o,toolRenderers:V,toolArtifactRenderers:X},e.id):null;if(!f){const O=u.jsx("div",{className:"space-y-2",children:j.map((K,M)=>m&&KT(K)?Y?u.jsx("div",{className:"space-y-2",children:Y},`streaming-md-${M}`):null:u.jsx(B,{part:K,i:M},M))});return d?u.jsxs("div",{"aria-busy":"true",role:"status",children:[O,u.jsx(Np,{className:F})]}):O}return null}function Mp(e){return e?!(No(e,/```/g)||No(e,/`/g)||No(e,/\*\*/g)||No(e,/__/g)||No(e,/~~/g)||/[^\\]\[[^\]]*$/.test(e)||/\[[^\]]*\]\([^)]*$/.test(e)):!0}function No(e,t){const n=e.match(t);return((n==null?void 0:n.length)??0)%2!==0}function VT(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 KT(e){return e.type==="text"&&!!e.__streamingMarkdownAggregate}const qT=Hr.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:te(qT({variant:t}),e),...n})}function GT({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:b,attemptCount:C,attemptIndex:k,handleOlderAttemptSelect:S,handleNewerAttemptSelect:T,messageCreatedAt:E,copied:A}){return!e&&!t&&!n?null:u.jsxs("div",{className:te("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:te("font-medium",l?"text-xs":"text-sm"),children:o}),n&&u.jsxs(Op,{variant:"outline",className:te("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:R=>{(R.key==="Enter"||R.key===" ")&&(R.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(le.ChevronUp,{className:"h-3 w-3"}):u.jsx(le.ChevronDown,{className:"h-3 w-3"})]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[b&&C>1&&u.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[u.jsx("button",{type:"button",className:te("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",k<C-1?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{k>=C-1||S()},"aria-label":"Older attempt (back in time)",disabled:k>=C-1,children:u.jsx(le.ChevronLeft,{className:"h-3 w-3"})}),u.jsx("div",{className:"flex items-center gap-2",children:u.jsxs("span",{className:"whitespace-nowrap",children:[C-k," / ",C]})}),u.jsx("button",{type:"button",className:te("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(le.ChevronRight,{className:"h-3 w-3"})})]}),e&&E&&u.jsx("time",{className:te("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:te("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",a),children:[u.jsx("div",{className:"relative",children:u.jsx(et,{variant:"ghost",size:"sm",onClick:g,className:te("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(le.Copy,{className:te(A?"text-success":r,l?"h-3 w-3":"h-4 w-4")})})}),h==="user"&&x&&u.jsx(et,{variant:"ghost",size:"sm",onClick:x,className:te("h-6 w-6 p-0 hover:bg-foreground/10",r,l&&"h-5 w-5"),"aria-label":"Edit message",children:u.jsx(le.Edit,{className:te(r,l?"h-3 w-3":"h-4 w-4")})}),h==="assistant"&&y&&u.jsx(et,{variant:"ghost",size:"sm",onClick:y,className:te("h-6 w-6 p-0 hover:bg-foreground/10",r,l&&"h-5 w-5"),"aria-label":"Regenerate response",children:u.jsx(le.RotateCcw,{className:te(r,l?"h-3 w-3":"h-4 w-4")})})]})]})]})}const Zs=w.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,toolRenderers:m,toolArtifactRenderers:f,customStyles:v={},streamingDebounceMs:g=300,renderStreamingMarkdown:x=!1,enableStreamingMarkdownBuffer:y,onEdit:b,onRegenerate:C,onCopy:k,activeInterrupt:S,disableInterruptActions:T=!1,onInterruptActionStart:E,onInterruptActionEnd:A,attemptCount:R=1,attemptIndex:$=0,onSelectCheckpoint:F,attemptMetas:V=[]}){const[X,_]=w.useState(!1),[G,H]=w.useState("preview"),[z,D]=w.useState(!1),{currentThreadId:I}=xr(),{respondToInterrupt:Y}=to(),J=l==="phone"||l==="half-screen",j=t.role,B=j==="tool",P=w.useMemo(()=>t.role==="default_message"?t:null,[t]),O=!!P,K=!(r&&j!=="user"),{uploadingFiles:M,handleFileClick:L,fileViewerOpen:q,currentFileInfo:Z,closeFileViewer:se}=jp({allowFileOpen:K,currentThreadId:I}),ie=w.useMemo(()=>{switch(j){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))]"}},[j]),re=Pp(t,P),{contentParts:de,imageParts:be,fileParts:Me,interruptParts:Fe,textContent:De,toolMeta:Le,toolRaw:it,isToolStreaming:dt}=re,Et=y??g!==0,Ke=(S==null?void 0:S.id)??(S==null?void 0:S.interrupt_id),We=Xo(Ke),Xe=S==null?void 0:S.value,ke=w.useCallback(async()=>{const pe=B?it:De;async function ce(Ce){if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function"){await navigator.clipboard.writeText(Ce);return}if(navigator.clipboard&&typeof navigator.clipboard.write=="function"&&typeof ClipboardItem<"u"){const qe=new Blob([Ce],{type:"text/plain"});await navigator.clipboard.write([new ClipboardItem({"text/plain":qe})]);return}throw new Error("Clipboard API not supported in this context.")}try{await ce(pe),_(!0),setTimeout(()=>_(!1),2e3),k==null||k(pe)}catch(Ce){console.error("Failed to copy:",Ce)}},[B,it,De,k]),Ue=w.useCallback(()=>{if(!b||!t.id)return;const pe=(B?it:De)??"",ce="type"in t&&t.type==="default_message"?void 0:{checkpointId:t.checkpointId??null,checkpointNs:t.checkpointNs??null};b(t.id,pe,ce)},[b,t.id,B,it,De,t]),ut=w.useCallback(()=>{C==null||C(n)},[C,n]),bt=w.useCallback(()=>{H(pe=>pe==="expanded"?"preview":"expanded")},[]),Je=w.useCallback(()=>{const ce=te(J?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",ie);switch(j){case"user":return u.jsx(le.User,{className:ce});case"assistant":return u.jsx(le.Bot,{className:ce});case"tool":return u.jsx(le.Wrench,{className:ce});default:return u.jsx(le.Bot,{className:ce})}},[J,ie,j]),Ct=w.useCallback(()=>{const pe="group relative mb-4 flex w-full";switch(j){case"user":return te(pe,"justify-end");case"assistant":case"tool":case"system":return te(pe,"justify-start");default:return pe}},[j]),gt=w.useCallback(()=>{const pe=te("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",J&&"px-3 py-2 text-sm");if(O)return te(pe,"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(j){case"user":return te(pe,"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 te(pe,"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 te(pe,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return te(pe,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return te(pe,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40")}},[J,O,j]),xt=w.useCallback(async pe=>{if(T)return;const ce=Xo((pe==null?void 0:pe.id)??(pe==null?void 0:pe.interrupt_id));if(!ce){console.warn("Interrupt part missing id",pe);return}try{E==null||E(),await Y(ce,!0)}catch(Ce){console.error("Failed to approve interrupt:",Ce)}finally{A==null||A()}},[T,A,E,Y]),It=w.useCallback(async pe=>{if(T)return;const ce=Xo((pe==null?void 0:pe.id)??(pe==null?void 0:pe.interrupt_id));if(!ce){console.warn("Interrupt part missing id",pe);return}try{E==null||E(),await Y(ce,!1)}catch(Ce){console.error("Failed to reject interrupt:",Ce)}finally{A==null||A()}},[T,A,E,Y]),rn=u.jsx(WT,{message:t,isToolMessage:B,showToolMessages:h,toolViewMode:G,isToolStreaming:dt,contentParts:de,textContent:De,imageParts:be,fileParts:Me,interruptParts:Fe,isStreamingMessage:r,defaultMessage:P,enableStreamingMarkdownBuffer:Et,renderStreamingMarkdown:x,handleFileClick:L,uploadingFiles:M,handleInterruptApprove:xt,handleInterruptReject:It,disableInterruptActions:T,messageRole:j,truncateUserMessages:c,userMessagePreviewLength:d,isUserExpanded:z,setIsUserExpanded:D,isCompactLayout:J,activeInterruptId:We,activeInterruptValue:Xe,iconForeground:ie,toolRenderers:m,toolArtifactRenderers:f}),Nt=w.useMemo(()=>P?"Assistant":nw(t),[P,t]),mn=Je(),Zt=j==="user"&&(R??1)>1&&typeof F=="function",Be=(V==null?void 0:V.length)??0,$e=Be>0&&$<Be-1?V[$+1]:void 0,Tt=Be>0&&$>0?V[$-1]:void 0,ne=w.useCallback(()=>{!$e||!F||F($e.id,void 0,!!$e.isLatestAttempt)},[$e,F]),xe=w.useCallback(()=>{!Tt||!F||F(Tt.id,void 0,!!Tt.isLatestAttempt)},[Tt,F]);return B&&!h?null:O&&P?u.jsx("div",{className:te(Ct(),v.container),children:u.jsxs("div",{className:te(gt(),v.content),children:[u.jsxs("div",{className:"flex items-center gap-2 mb-2 pb-2 border-b border-current/10",children:[u.jsx(le.Bot,{className:te("h-4 w-4",ie)}),a&&u.jsx("span",{className:"font-medium text-sm",children:"Assistant"})]}),u.jsx(cr,{content:P.content,className:"text-current"})]})}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:te(Ct(),v.container),children:u.jsxs("div",{className:te(gt(),v.content),children:[u.jsx(GT,{showTimestamp:i,showAgentName:a,isToolMessage:B,iconForeground:ie,agentName:Nt,messageIcon:mn,customHeaderClass:v.header,customActionsClass:v.actions,isCompactLayout:J,showActions:s,isEditing:o,messageRole:j,toolViewMode:G,toolMeta:Le,onToggleToolView:bt,onCopy:ke,onEdit:Ue,onRegenerate:ut,showCheckpointControls:Zt,attemptCount:R,attemptIndex:$,handleOlderAttemptSelect:ne,handleNewerAttemptSelect:xe,messageCreatedAt:t.createdAt,copied:X}),u.jsx("div",{className:"relative",children:rn}),B&&G==="expanded"&&(Le.toolCallId||Le.name)&&u.jsxs("div",{className:te("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",J&&"text-xs"),children:[Le.name&&u.jsxs("div",{children:["Function: ",Le.name]}),Le.toolCallId&&u.jsxs("div",{children:["Call ID: ",Le.toolCallId]})]}),!(i||a||B)&&s&&!o&&u.jsxs("div",{className:te("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",v.actions),children:[u.jsx(et,{variant:"ghost",size:"sm",onClick:()=>ke(),className:te("h-6 w-6 p-0 hover:bg-background/50 text-current",J&&"h-5 w-5"),children:u.jsx(le.Copy,{className:te(X?"text-success":"text-current",J?"h-3 w-3":"h-4 w-4")})}),j==="user"&&b&&u.jsx(et,{variant:"ghost",size:"sm",onClick:Ue,className:te("h-6 w-6 p-0 hover:bg-background/50 text-current",J&&"h-5 w-5"),children:u.jsx(le.Edit,{className:te("text-current",J?"h-3 w-3":"h-4 w-4")})}),j==="assistant"&&C&&u.jsx(et,{variant:"ghost",size:"sm",onClick:ut,className:te("h-6 w-6 p-0 hover:bg-background/50 text-current",J&&"h-5 w-5"),children:u.jsx(le.RotateCcw,{className:te("text-current",J?"h-3 w-3":"h-4 w-4")})})]})]})}),Z&&u.jsx(cp,{isOpen:q,onClose:se,fileId:Z.id,fileName:Z.name,mimeType:Z.mimeType})]})},(e,t)=>{var l,c,d,h,m,f,v,g;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&gu(e.message)===gu(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateUserMessages","userMessagePreviewLength","showToolMessages","toolRenderers","toolArtifactRenderers"].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=xu(e.message),a=xu(t.message);return i.length===a.length});Zs.displayName="MessageComponent";const pl=w.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:b,disableInterruptActions:C=!1,onInterruptActionStart:k,onInterruptActionEnd:S,showToolMessages:T=!0,toolRenderers:E,toolArtifactRenderers:A,checkpointIndex:R,activeCheckpointId:$,onSelectCheckpoint:F,createSyntheticThinkingMessage:V=!0,forceSyntheticThinking:X=!1,getMessageCustomStyles:_},G)=>{const H=w.useRef(null),z=w.useRef(null),D=w.useRef(!1),I=w.useRef(!1),Y=w.useMemo(()=>b?e.some(re=>re.role==="default_message"?!1:Array.isArray(re==null?void 0:re.content)&&re.content.some(de=>de&&de.type==="interrupt"&&(de.id??de.interrupt_id)===b.id)):!1,[b,e]),J=w.useMemo(()=>{if(!b||Y)return null;const re=b.id&&String(b.id).trim()?String(b.id).trim():"pending-interrupt";let de;const be=b.value;if(be&&typeof be=="object"&&!Array.isArray(be)){const Me=be.title;typeof Me=="string"&&Me.trim()&&(de=Me.trim())}return{id:`interrupt-${re}`,role:"system",createdAt:new Date().toISOString(),content:[{type:"interrupt",id:re,value:be,title:de}]}},[b,Y]),j=w.useMemo(()=>J?[...e,J]:e,[e,J]),B=w.useMemo(()=>{const re=n&&j.some(be=>be.id===n);return V&&(t||X)&&!re&&j.length>0?[...j,{id:"thinking-assistant",role:"assistant",content:[{type:"text",text:""}],createdAt:new Date().toISOString(),__syntheticStreaming:!0}]:j},[j,t,n,V,X]),P=w.useMemo(()=>T?B:B.filter(re=>(re==null?void 0:re.role)!=="tool"),[B,T]),O=w.useCallback(re=>{x&&x(!re),y&&y(re)},[x,y]),K=w.useMemo(()=>{if(a)return async()=>{if(!D.current){D.current=!0;try{await a()}finally{D.current=!1}}}},[a]),M=w.useMemo(()=>!v||g?!1:"auto",[v,g]),L=w.useMemo(()=>{if(typeof f!="string")return null;const re=f.trim();return!re||P&&P.length>0?null:{id:"default-message",role:"default_message",content:re,createdAt:new Date().toISOString()}},[f,P]),q=["flex h-full flex-col md:flex-row",h].filter(Boolean).join(" "),Z=()=>{if(L){const re=_==null?void 0:_(L);return u.jsx("div",{className:"p-6 h-full overflow-y-auto",children:u.jsx("div",{className:"w-full max-w-full",children:u.jsx(Zs,{message:L,messageIndex:0,isStreamingMessage:!1,showActions:!1,showTimestamp:!1,showAgentName:!0,layoutSize:o,onEdit:()=>{},onRegenerate:()=>{},onCancelEdit:()=>{},customStyles:re})})})}return 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!"})},se=P.length,ie=se>0;return w.useEffect(()=>{var re,de;if(se===0){I.current=!1;return}if(!I.current)if(I.current=!0,H.current&&P.length>0){const be=P.length-1;(de=(re=H.current).scrollToIndex)==null||de.call(re,{index:be,align:"end",behavior:"auto"})}else z.current&&(z.current.scrollTop=z.current.scrollHeight)},[se,P.length]),w.useImperativeHandle(G,()=>({scrollToLatest:()=>{var re,de;if(H.current&&P.length>0){const be=P.length-1;(de=(re=H.current).scrollToIndex)==null||de.call(re,{index:be,align:"end",behavior:"auto"})}else z.current&&(z.current.scrollTop=z.current.scrollHeight)},scrollToTop:()=>{var re,de;H.current&&P.length>0?(de=(re=H.current).scrollToIndex)==null||de.call(re,{index:0,align:"start",behavior:"auto"}):z.current&&(z.current.scrollTop=0)}}),[P]),u.jsx("div",{className:q,style:m,children:u.jsx("div",{className:"relative flex-1 min-h-0",children:ie?u.jsx(HC,{ref:re=>{H.current=re},scrollerRef:re=>{z.current=re instanceof HTMLDivElement?re:null},data:P,followOutput:M,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,startReached:()=>{K&&K()},atBottomStateChange:O,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(re,de)=>fl(de,re),itemContent:(re,de)=>u.jsx(hl,{message:de,index:re,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onEdit:l,onRegenerate:c,onCancelEdit:d,activeInterrupt:b,disableInterruptActions:C,onInterruptActionStart:k,onInterruptActionEnd:S,showToolMessages:T,toolRenderers:E,toolArtifactRenderers:A,checkpointIndex:R,activeCheckpointId:$,onSelectCheckpoint:F,getMessageCustomStyles:_})}):Z()})})});pl.displayName="MessageList";const Dp={value:""};function Or({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,toolRenderers:h,toolArtifactRenderers:m,payloadExtras:f={},customStyles:v={},messageCustomStyles:g,onMessageSent:x,onExcelUploadSuccess:y,onError:b,defaultMessage:C}){const{api:k}=Jr(),{currentThreadId:S}=xr(),{threadId:T,messages:E,isLoading:A,navigateToCheckpoint:R,returnToLatest:$,checkpoint:F,checkpoints:V,interrupt:X,metadata:_,checkpointIndex:G}=to(),{isStreaming:H,error:z,connectionState:D,submit:I,stop:Y}=Fi(),J=T??S??null,j=(F==null?void 0:F.id)??null,B=(F==null?void 0:F.namespace)??null,P=(_==null?void 0:_.assemblingMessageId)??null,O=X,[K,M]=w.useState(!1),[L,q]=w.useState(!1);w.useEffect(()=>{O||M(!1)},[O]);const Z=w.useCallback(()=>{M(!0)},[]),se=w.useCallback(()=>{M(!1)},[]),ie=!!O||K,[re,de]=w.useState(null),[be,Me]=w.useState(""),[Fe,De]=w.useState(null),[Le,it]=w.useState(null),[dt,Et]=w.useState(!1),[Ke,We]=w.useState(null),Xe=w.useRef(!1),[ke,Ue]=w.useState(()=>Dp.value),ut=w.useRef(ke),bt=w.useRef(null),Je=w.useCallback(Ne=>{Dp.value=Ne,Ue(Ne)},[]),[Ct,gt]=w.useState(!1),xt=w.useRef(null),It=w.useCallback(Ne=>{Je(Ne)},[Je]);w.useEffect(()=>{H||q(!1)},[H]),w.useEffect(()=>{_!=null&&_.assemblingMessageId&&q(!1)},[_==null?void 0:_.assemblingMessageId]);const[rn,Nt]=w.useState("desktop");w.useEffect(()=>{const Ne=()=>{const je=window.innerWidth;Nt(je<640?"phone":je<1024?"tablet":"desktop")};return Ne(),window.addEventListener("resize",Ne),()=>window.removeEventListener("resize",Ne)},[]),w.useEffect(()=>{Xe.current=!1},[J]),w.useEffect(()=>{ut.current=ke},[ke]),w.useEffect(()=>{if(!re){bt.current=null;return}bt.current===null&&(bt.current=ut.current),Je(be??"")},[be,re,Je]),w.useEffect(()=>{if(C!==void 0){We(C);return}(async()=>{if(!k.baseUrl){We(null);return}try{const Oe=(await k.getAgent("default")).uiDefaultMessage||"";We(Oe||null)}catch(je){console.warn("Failed to fetch default message:",je),We(null)}})()},[k.baseUrl,C]),w.useEffect(()=>{z&&!dt&&(b==null||b(z))},[z,dt,b]);const mn=async(Ne,je)=>{const Oe=Ne.trim();if(!(!Oe&&je.length===0))try{const tt=re?(Fe==null?void 0:Fe.checkpointId)??j??void 0:j??void 0,ye=re?(Fe==null?void 0:Fe.checkpointNs)??B??void 0:B??void 0;await I({text:Oe||"",attachments:je,payload:f},{checkpointId:tt,checkpointNs:ye,edit:!!re,originalMessageId:re??void 0}),x==null||x(Oe),q(!0),Je(""),it(null),de(null),Me(""),De(null)}catch(tt){const ye=(tt==null?void 0:tt.message)||"Failed to send message";it(ye),b==null||b(ye),q(!1)}},Zt=w.useCallback(async Ne=>{await I({attachments:[Ne],payload:f},{checkpointId:j??void 0,checkpointNs:B??void 0}),y==null||y({file:Ne})},[j,B,f,y,I]),Be=w.useCallback((Ne,je,Oe)=>{c&&(bt.current=ke,de(Ne),Me(je),Je(je),it(null),De({checkpointId:(Oe==null?void 0:Oe.checkpointId)??null,checkpointNs:(Oe==null?void 0:Oe.checkpointNs)??null}))},[ke,c,Je]),$e=w.useCallback(()=>{de(null),Me(""),De(null),it(null),Je(bt.current??ke),bt.current=null},[ke,Je]),Tt=w.useCallback((Ne,je,Oe)=>{Be(Ne,je,Oe)},[Be]),ne=w.useCallback(Ne=>{let je=null;for(let Ye=Ne-1;Ye>=0;Ye--)if(E[Ye].role==="user"){je=E[Ye];break}if(!je)return;const Oe=Array.isArray(je.content)?je.content:[],ye=Oe.filter(Ye=>(Ye==null?void 0:Ye.type)==="text").map(Ye=>Ye.text).join("")||(()=>{try{return JSON.stringify(Oe,null,2)}catch{return String(Oe)}})();ye&&I({text:ye,payload:f},{checkpointId:j??void 0,checkpointNs:B??void 0,edit:!0,originalMessageId:je.id})},[E,I,j,B,f]),xe=async Ne=>{if(S){gt(!0);try{if(!Ne){await $(),requestAnimationFrame(()=>{var tt;(tt=xt.current)==null||tt.scrollToLatest()});return}const je=V.find(tt=>tt.checkpointId===Ne),Oe=(je==null?void 0:je.checkpointNs)??null;await R(Ne,Oe),requestAnimationFrame(()=>{var tt;(tt=xt.current)==null||tt.scrollToTop()})}finally{gt(!1)}}},pe=w.useCallback(async(Ne,je,Oe)=>{await xe(Oe?null:Ne)},[xe]),ce=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${v.container||""}`,Ce=`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 ${v.messagesArea||""}`,qe=`relative flex-shrink-0 w-full border-t p-4 bg-transparent ${v.inputArea||""}`;return u.jsxs("div",{className:ce,children:[!!z&&!dt&&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:z}),u.jsx(et,{variant:"ghost",size:"sm",onClick:()=>Et(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:u.jsx(le.X,{size:16})})]}),u.jsxs("div",{className:`relative ${Ce}`,style:r?{maxHeight:r}:void 0,children:[u.jsx(pl,{ref:xt,className:"h-full",style:{height:"100%"},messages:E,isStreaming:H,streamingAssistantId:P,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:rn,enableMessageEditing:c,editingMessageId:re,onEdit:Tt,onRegenerate:ne,onCancelEdit:$e,emptyMessage:Ke??void 0,isNavigatingCheckpoint:Ct,activeInterrupt:O,disableInterruptActions:K,onInterruptActionStart:Z,onInterruptActionEnd:se,showToolMessages:d,toolRenderers:h,toolArtifactRenderers:m,checkpointIndex:G,activeCheckpointId:j,onSelectCheckpoint:pe,createSyntheticThinkingMessage:!0,forceSyntheticThinking:L,getMessageCustomStyles:g}),(D==="reconnecting"||D==="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(le.Loader2,{className:"h-3 w-3 animate-spin"}),D==="reconnecting"?"Reconnecting…":"Connecting…"]})}),D==="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"}),A&&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(le.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading messages…"})]}),Ct&&u.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 bg-background/80 backdrop-blur-sm text-muted-foreground",children:[u.jsx(le.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:qe,children:[re&&u.jsx("div",{className:"mb-3 p-3 bg-blue-50 border border-blue-200 rounded-lg",children:u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(le.Edit3,{size:16,className:"text-blue-600"}),u.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),u.jsx(et,{variant:"ghost",size:"sm",onClick:$e,className:"text-blue-600 hover:bg-blue-100",children:u.jsx(le.X,{size:16})})]})}),Le&&u.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:Le}),u.jsx(_S,{composerValue:ke,onComposerChange:It,onSend:mn,onCancelEdit:$e,onStop:Y,editingMessageId:re,editingInitialValue:be,placeholder:re?"Edit your message...":t,isStreaming:H,disabled:ie,enableFileUpload:a,enableExcelUpload:l,onExcelUpload:Zt,onError:b,customStyles:v,textareaClassName:v.textarea||"",allowEmptySend:!1,inputError:Le})]})]})}var Lp=1,YT=.9,XT=.8,JT=.17,ml=.1,gl=.999,ZT=.9999,QT=.99,ek=/[\\\/_+.#"@\[\(\{&]/,tk=/[\\\/_+.#"@\[\(\{&]/g,nk=/[\s-]/,$p=/[\s-]/g;function xl(e,t,n,r,o,s,i){if(s===t.length)return o===e.length?Lp:QT;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:ek.test(e.charAt(c-1))?(h*=XT,f=e.slice(o,c-1).match(tk),f&&o>0&&(h*=Math.pow(gl,f.length))):nk.test(e.charAt(c-1))?(h*=YT,v=e.slice(o,c-1).match($p),v&&o>0&&(h*=Math.pow(gl,v.length))):(h*=JT,o>0&&(h*=Math.pow(gl,c-o))),e.charAt(c)!==t.charAt(s)&&(h*=ZT)),(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 rk(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,xl(e,t,Fp(e),Fp(t),0,0,{})}var Ao='[cmdk-group=""]',vl='[cmdk-group-items=""]',ok='[cmdk-group-heading=""]',Bp='[cmdk-item=""]',zp=`${Bp}:not([aria-disabled="true"])`,wl="cmdk-item-select",Dr="data-value",sk=(e,t,n)=>rk(e,t,n),Hp=p.createContext(void 0),jo=()=>p.useContext(Hp),Up=p.createContext(void 0),bl=()=>p.useContext(Up),Wp=p.createContext(void 0),Vp=p.forwardRef((e,t)=>{let n=Lr(()=>{var j,B;return{search:"",value:(B=(j=e.value)!=null?j:e.defaultValue)!=null?B:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=Lr(()=>new Set),o=Lr(()=>new Map),s=Lr(()=>new Map),i=Lr(()=>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,b=jt(),C=jt(),k=jt(),S=p.useRef(null),T=gk();ur(()=>{if(d!==void 0){let j=d.trim();n.current.value=j,E.emit()}},[d]),ur(()=>{T(6,X)},[]);let E=p.useMemo(()=>({subscribe:j=>(i.current.add(j),()=>i.current.delete(j)),snapshot:()=>n.current,setState:(j,B,P)=>{var O,K,M,L;if(!Object.is(n.current[j],B)){if(n.current[j]=B,j==="search")V(),$(),T(1,F);else if(j==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let q=document.getElementById(k);q?q.focus():(O=document.getElementById(b))==null||O.focus()}if(T(7,()=>{var q;n.current.selectedItemId=(q=_())==null?void 0:q.id,E.emit()}),P||T(5,X),((K=a.current)==null?void 0:K.value)!==void 0){let q=B??"";(L=(M=a.current).onValueChange)==null||L.call(M,q);return}}E.emit()}},emit:()=>{i.current.forEach(j=>j())}}),[]),A=p.useMemo(()=>({value:(j,B,P)=>{var O;B!==((O=s.current.get(j))==null?void 0:O.value)&&(s.current.set(j,{value:B,keywords:P}),n.current.filtered.items.set(j,R(B,P)),T(2,()=>{$(),E.emit()}))},item:(j,B)=>(r.current.add(j),B&&(o.current.has(B)?o.current.get(B).add(j):o.current.set(B,new Set([j]))),T(3,()=>{V(),$(),n.current.value||F(),E.emit()}),()=>{s.current.delete(j),r.current.delete(j),n.current.filtered.items.delete(j);let P=_();T(4,()=>{V(),(P==null?void 0:P.getAttribute("id"))===j&&F(),E.emit()})}),group:j=>(o.current.has(j)||o.current.set(j,new Set),()=>{s.current.delete(j),o.current.delete(j)}),filter:()=>a.current.shouldFilter,label:l||e["aria-label"],getDisablePointerSelection:()=>a.current.disablePointerSelection,listId:b,inputId:k,labelId:C,listInnerRef:S}),[]);function R(j,B){var P,O;let K=(O=(P=a.current)==null?void 0:P.filter)!=null?O:sk;return j?K(j,n.current.search,B):0}function $(){if(!n.current.search||a.current.shouldFilter===!1)return;let j=n.current.filtered.items,B=[];n.current.filtered.groups.forEach(O=>{let K=o.current.get(O),M=0;K.forEach(L=>{let q=j.get(L);M=Math.max(q,M)}),B.push([O,M])});let P=S.current;G().sort((O,K)=>{var M,L;let q=O.getAttribute("id"),Z=K.getAttribute("id");return((M=j.get(Z))!=null?M:0)-((L=j.get(q))!=null?L:0)}).forEach(O=>{let K=O.closest(vl);K?K.appendChild(O.parentElement===K?O:O.closest(`${vl} > *`)):P.appendChild(O.parentElement===P?O:O.closest(`${vl} > *`))}),B.sort((O,K)=>K[1]-O[1]).forEach(O=>{var K;let M=(K=S.current)==null?void 0:K.querySelector(`${Ao}[${Dr}="${encodeURIComponent(O[0])}"]`);M==null||M.parentElement.appendChild(M)})}function F(){let j=G().find(P=>P.getAttribute("aria-disabled")!=="true"),B=j==null?void 0:j.getAttribute(Dr);E.setState("value",B||void 0)}function V(){var j,B,P,O;if(!n.current.search||a.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let K=0;for(let M of r.current){let L=(B=(j=s.current.get(M))==null?void 0:j.value)!=null?B:"",q=(O=(P=s.current.get(M))==null?void 0:P.keywords)!=null?O:[],Z=R(L,q);n.current.filtered.items.set(M,Z),Z>0&&K++}for(let[M,L]of o.current)for(let q of L)if(n.current.filtered.items.get(q)>0){n.current.filtered.groups.add(M);break}n.current.filtered.count=K}function X(){var j,B,P;let O=_();O&&(((j=O.parentElement)==null?void 0:j.firstChild)===O&&((P=(B=O.closest(Ao))==null?void 0:B.querySelector(ok))==null||P.scrollIntoView({block:"nearest"})),O.scrollIntoView({block:"nearest"}))}function _(){var j;return(j=S.current)==null?void 0:j.querySelector(`${Bp}[aria-selected="true"]`)}function G(){var j;return Array.from(((j=S.current)==null?void 0:j.querySelectorAll(zp))||[])}function H(j){let B=G()[j];B&&E.setState("value",B.getAttribute(Dr))}function z(j){var B;let P=_(),O=G(),K=O.findIndex(L=>L===P),M=O[K+j];(B=a.current)!=null&&B.loop&&(M=K+j<0?O[O.length-1]:K+j===O.length?O[0]:O[K+j]),M&&E.setState("value",M.getAttribute(Dr))}function D(j){let B=_(),P=B==null?void 0:B.closest(Ao),O;for(;P&&!O;)P=j>0?pk(P,Ao):mk(P,Ao),O=P==null?void 0:P.querySelector(zp);O?E.setState("value",O.getAttribute(Dr)):z(j)}let I=()=>H(G().length-1),Y=j=>{j.preventDefault(),j.metaKey?I():j.altKey?D(1):z(1)},J=j=>{j.preventDefault(),j.metaKey?H(0):j.altKey?D(-1):z(-1)};return p.createElement(me.div,{ref:t,tabIndex:-1,...y,"cmdk-root":"",onKeyDown:j=>{var B;(B=y.onKeyDown)==null||B.call(y,j);let P=j.nativeEvent.isComposing||j.keyCode===229;if(!(j.defaultPrevented||P))switch(j.key){case"n":case"j":{x&&j.ctrlKey&&Y(j);break}case"ArrowDown":{Y(j);break}case"p":case"k":{x&&j.ctrlKey&&J(j);break}case"ArrowUp":{J(j);break}case"Home":{j.preventDefault(),H(0);break}case"End":{j.preventDefault(),I();break}case"Enter":{j.preventDefault();let O=_();if(O){let K=new Event(wl);O.dispatchEvent(K)}}}}},p.createElement("label",{"cmdk-label":"",htmlFor:A.inputId,id:A.labelId,style:vk},l),Qs(e,j=>p.createElement(Up.Provider,{value:E},p.createElement(Hp.Provider,{value:A},j))))}),ik=p.forwardRef((e,t)=>{var n,r;let o=jt(),s=p.useRef(null),i=p.useContext(Wp),a=jo(),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=bl(),m=Kn(T=>T.value&&T.value===d.current),f=Kn(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(wl,v),()=>T.removeEventListener(wl,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:b,forceMount:C,keywords:k,...S}=e;return p.createElement(me.div,{ref:Mn(s,t),...S,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)}),ak=p.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:o,...s}=e,i=jt(),a=p.useRef(null),l=p.useRef(null),c=jt(),d=jo(),h=Kn(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(me.div,{ref:Mn(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),Qs(e,f=>p.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?c:void 0},p.createElement(Wp.Provider,{value:m},f))))}),lk=p.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,o=p.useRef(null),s=Kn(i=>!i.search);return!n&&!s?null:p.createElement(me.div,{ref:Mn(o,t),...r,"cmdk-separator":"",role:"separator"})}),ck=p.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,o=e.value!=null,s=bl(),i=Kn(c=>c.search),a=Kn(c=>c.selectedItemId),l=jo();return p.useEffect(()=>{e.value!=null&&s.setState("search",e.value)},[e.value]),p.createElement(me.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)}})}),uk=p.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...o}=e,s=p.useRef(null),i=p.useRef(null),a=Kn(c=>c.selectedItemId),l=jo();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(me.div,{ref:Mn(s,t),...o,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":a,"aria-label":r,id:l.listId},Qs(e,c=>p.createElement("div",{ref:Mn(i,l.listInnerRef),"cmdk-list-sizer":""},c)))}),dk=p.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:o,contentClassName:s,container:i,...a}=e;return p.createElement(Qa,{open:n,onOpenChange:r},p.createElement(el,{container:i},p.createElement(ko,{"cmdk-overlay":"",className:o}),p.createElement(Eo,{"aria-label":e.label,"cmdk-dialog":"",className:s},p.createElement(Vp,{ref:t,...a}))))}),fk=p.forwardRef((e,t)=>Kn(n=>n.filtered.count===0)?p.createElement(me.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),hk=p.forwardRef((e,t)=>{let{progress:n,children:r,label:o="Loading...",...s}=e;return p.createElement(me.div,{ref:t,...s,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":o},Qs(e,i=>p.createElement("div",{"aria-hidden":!0},i)))}),Ht=Object.assign(Vp,{List:uk,Item:ik,Input:ck,Group:ak,Separator:lk,Dialog:dk,Empty:fk,Loading:hk});function pk(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function mk(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 Lr(e){let t=p.useRef();return t.current===void 0&&(t.current=e()),t}function Kn(e){let t=bl(),n=()=>e(t.snapshot());return p.useSyncExternalStore(t.subscribe,n,n)}function qp(e,t,n,r=[]){let o=p.useRef(),s=jo();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(Dr,a),o.current=a}),o}var gk=()=>{let[e,t]=p.useState(),n=Lr(()=>new Map);return ur(()=>{n.current.forEach(r=>r()),n.current=new Map},[e]),(r,o)=>{n.current.set(r,o),t({})}};function xk(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function Qs({asChild:e,children:t},n){return e&&p.isValidElement(t)?p.cloneElement(xk(t),{ref:t.ref},n(t.props.children)):n(t)}var vk={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(Ht,{ref:n,className:te("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));yl.displayName=Ht.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(le.Search,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),u.jsx(Ht.Input,{ref:n,className:te("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=Ht.Input.displayName;const Cl=p.forwardRef(({className:e,...t},n)=>u.jsx(Ht.List,{ref:n,className:te("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));Cl.displayName=Ht.List.displayName;const Tl=p.forwardRef((e,t)=>u.jsx(Ht.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));Tl.displayName=Ht.Empty.displayName;const kl=p.forwardRef(({className:e,...t},n)=>u.jsx(Ht.Group,{ref:n,className:te("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=Ht.Group.displayName;const wk=p.forwardRef(({className:e,...t},n)=>u.jsx(Ht.Separator,{ref:n,className:te("-mx-1 h-px bg-border",e),...t}));wk.displayName=Ht.Separator.displayName;const El=p.forwardRef(({className:e,...t},n)=>u.jsx(Ht.Item,{ref:n,className:te("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=Ht.Item.displayName;function Il(e,[t,n]){return Math.min(n,Math.max(t,e))}function bk(e,t){return p.useReducer((n,r)=>t[n][r]??n,e)}var Nl="ScrollArea",[Gp,D1]=an(Nl),[yk,nn]=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,b]=p.useState(0),[C,k]=p.useState(0),[S,T]=p.useState(!1),[E,A]=p.useState(!1),R=_e(t,F=>l(F)),$=Zo(o);return u.jsx(yk,{scope:n,type:r,dir:$,scrollHideDelay:s,scrollArea:a,viewport:c,onViewportChange:d,content:h,onContentChange:m,scrollbarX:f,onScrollbarXChange:v,scrollbarXEnabled:S,onScrollbarXEnabledChange:T,scrollbarY:g,onScrollbarYChange:x,scrollbarYEnabled:E,onScrollbarYEnabledChange:A,onCornerWidthChange:b,onCornerHeightChange:k,children:u.jsx(me.div,{dir:$,...i,ref:R,style:{position:"relative","--radix-scroll-area-corner-width":y+"px","--radix-scroll-area-corner-height":C+"px",...e.style}})})});Yp.displayName=Nl;var Xp="ScrollAreaViewport",Jp=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=nn(Xp,n),a=p.useRef(null),l=_e(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(me.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=nn(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(Sk,{...r,ref:t,forceMount:n}):o.type==="scroll"?u.jsx(Ck,{...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 Sk=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=nn(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(Bt,{present:n||s,children:u.jsx(Zp,{"data-state":s?"visible":"hidden",...r,ref:t})})}),Ck=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=nn(En,e.__scopeScrollArea),s=e.orientation==="horizontal",i=ri(()=>l("SCROLL_END"),100),[a,l]=bk("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(Bt,{present:n||a!=="hidden",children:u.jsx(jl,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:ae(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:ae(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),Zp=p.forwardRef((e,t)=>{const n=nn(En,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=p.useState(!1),a=e.orientation==="horizontal",l=ri(()=>{if(n.viewport){const c=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?c:d)}},10);return $r(n.viewport,l),$r(n.content,l),u.jsx(Bt,{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=nn(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 Ak(m,i.current,a,f)}return n==="horizontal"?u.jsx(Tk,{...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(kk,{...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}),Tk=p.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=nn(En,e.__scopeScrollArea),[i,a]=p.useState(),l=p.useRef(null),c=_e(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":ni(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:ti(i.paddingLeft),paddingEnd:ti(i.paddingRight)}})}})}),kk=p.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=nn(En,e.__scopeScrollArea),[i,a]=p.useState(),l=p.useRef(null),c=_e(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":ni(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:ti(i.paddingTop),paddingEnd:ti(i.paddingBottom)}})}})}),[Ek,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=nn(En,n),[v,g]=p.useState(null),x=_e(t,R=>g(R)),y=p.useRef(null),b=p.useRef(""),C=f.viewport,k=r.content-r.viewport,S=pt(d),T=pt(l),E=ri(h,10);function A(R){if(y.current){const $=R.clientX-y.current.left,F=R.clientY-y.current.top;c({x:$,y:F})}}return p.useEffect(()=>{const R=$=>{const F=$.target;(v==null?void 0:v.contains(F))&&S($,k)};return document.addEventListener("wheel",R,{passive:!1}),()=>document.removeEventListener("wheel",R,{passive:!1})},[C,v,k,S]),p.useEffect(T,[r,T]),$r(v,E),$r(f.content,E),u.jsx(Ek,{scope:n,scrollbar:v,hasThumb:o,onThumbChange:pt(s),onThumbPointerUp:pt(i),onThumbPositionChange:T,onThumbPointerDown:pt(a),children:u.jsx(me.div,{...m,ref:x,style:{position:"absolute",...m.style},onPointerDown:ae(e.onPointerDown,R=>{R.button===0&&(R.target.setPointerCapture(R.pointerId),y.current=v.getBoundingClientRect(),b.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",f.viewport&&(f.viewport.style.scrollBehavior="auto"),A(R))}),onPointerMove:ae(e.onPointerMove,A),onPointerUp:ae(e.onPointerUp,R=>{const $=R.target;$.hasPointerCapture(R.pointerId)&&$.releasePointerCapture(R.pointerId),document.body.style.webkitUserSelect=b.current,f.viewport&&(f.viewport.style.scrollBehavior=""),y.current=null})})})}),ei="ScrollAreaThumb",tm=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Qp(ei,e.__scopeScrollArea);return u.jsx(Bt,{present:n||o.hasThumb,children:u.jsx(Ik,{ref:t,...r})})}),Ik=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=nn(ei,n),i=Qp(ei,n),{onThumbPositionChange:a}=i,l=_e(t,h=>i.onThumbChange(h)),c=p.useRef(void 0),d=ri(()=>{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=jk(h,a);c.current=f,a()}};return a(),h.addEventListener("scroll",m),()=>h.removeEventListener("scroll",m)}},[s.viewport,d,a]),u.jsx(me.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:ae(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:ae(e.onPointerUp,i.onThumbPointerUp)})});tm.displayName=ei;var Pl="ScrollAreaCorner",nm=p.forwardRef((e,t)=>{const n=nn(Pl,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?u.jsx(Nk,{...e,ref:t}):null});nm.displayName=Pl;var Nk=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=nn(Pl,n),[s,i]=p.useState(0),[a,l]=p.useState(0),c=!!(s&&a);return $r(o.scrollbarX,()=>{var h;const d=((h=o.scrollbarX)==null?void 0:h.offsetHeight)||0;o.onCornerHeightChange(d),l(d)}),$r(o.scrollbarY,()=>{var h;const d=((h=o.scrollbarY)==null?void 0:h.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),c?u.jsx(me.div,{...r,ref:t,style:{width:s,height:a,position:"absolute",right:o.dir==="ltr"?0:void 0,left:o.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function ti(e){return e?parseInt(e,10):0}function rm(e,t){const n=e/t;return isNaN(n)?0:n}function ni(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 Ak(e,t,n,r="ltr"){const o=ni(n),s=o/2,i=t||s,a=o-i,l=n.scrollbar.paddingStart+i,c=n.scrollbar.size-n.scrollbar.paddingEnd-a,d=n.content-n.viewport,h=r==="ltr"?[0,d]:[d*-1,0];return sm([l,c],h)(e)}function om(e,t,n="ltr"){const r=ni(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,s=t.scrollbar.size-o,i=t.content-t.viewport,a=s-r,l=n==="ltr"?[0,i]:[i*-1,0],c=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 jk=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return function o(){const s={left:e.scrollLeft,top:e.scrollTop},i=n.left!==s.left,a=n.top!==s.top;(i||a)&&t(),n=s,r=window.requestAnimationFrame(o)}(),()=>window.cancelAnimationFrame(r)};function ri(e,t){const n=pt(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 $r(e,t){const n=pt(t);kt(()=>{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,Pk=Jp,_k=nm;const _l=p.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(am,{ref:r,className:te("relative overflow-hidden",e),...n,children:[u.jsx(Pk,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),u.jsx(lm,{}),u.jsx(_k,{})]}));_l.displayName=am.displayName;const lm=p.forwardRef(({className:e,orientation:t="vertical",...n},r)=>u.jsx(Al,{ref:r,orientation:t,className:te("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:te("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 Rk="group relative p-3 rounded-lg cursor-pointer transition-colors border text-gray-900 dark:text-slate-100",Mk="bg-slate-700 border-slate-600 hover:bg-slate-600",Ok="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 b=n===e.threadId,C=t?`${y??Ok}`:`${x??Mk}`,k=S=>{S.stopPropagation(),o(e.threadId)};return u.jsxs("div",{onClick:k,className:`${Rk} ${C}`,children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("div",{className:"flex-1 min-w-0",children:b?u.jsxs("div",{className:"flex items-center gap-2",onClick:S=>S.stopPropagation(),children:[u.jsx(Rl,{value:r,onChange:S=>i(S.target.value),onKeyDown:S=>{S.key==="Enter"?a(e.threadId):S.key==="Escape"&&l()},className:"h-6 text-sm",autoFocus:!0}),u.jsx(et,{variant:"ghost",size:"sm",onClick:()=>a(e.threadId),className:"h-6 w-6 p-0",children:u.jsx(le.Check,{size:12})}),u.jsx(et,{variant:"ghost",size:"sm",onClick:l,className:"h-6 w-6 p-0",children:u.jsx(le.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(le.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(Ts,{children:[u.jsx(ks,{asChild:!0,children:u.jsx(et,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",children:u.jsx(le.MoreHorizontal,{size:12})})}),u.jsxs(po,{align:"end",sideOffset:6,className:"w-44",children:[u.jsxs(Fn,{onClick:S=>{S.preventDefault(),c(e.threadId)},children:[u.jsx(le.Share2,{className:"mr-2 h-4 w-4"}),"Share thread"]}),h&&n!==e.threadId&&u.jsxs(Fn,{onClick:S=>{S.preventDefault(),s(e,S)},children:[u.jsx(le.Edit3,{className:"mr-2 h-4 w-4"}),"Rename"]}),m&&d&&u.jsxs(Fn,{className:"text-red-400 hover:text-red-300",onClick:S=>{S.preventDefault(),d(e.threadId,S)},children:[u.jsx(le.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",Dk=e=>e==="default"||e==="shared",Lk=()=>{if(typeof window>"u")return null;try{const e=window.localStorage.getItem(dm);if(Dk(e))return e}catch{}return null};function fm({defaultView:e}={}){const[t,n]=w.useState(()=>Lk()??e??"default");w.useEffect(()=>{if(!(typeof window>"u"))try{window.localStorage.setItem(dm,t)}catch{}},[t]);const r=w.useCallback(o=>{n(o)},[]);return{view:t,setView:r}}const $k=[{key:"default",label:"My chats"},{key:"shared",label:"Shared with you"}];function oi({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:b,shareTargetFilter:C}){const{threads:k,sharedThreads:S,currentThreadId:T,setCurrentThreadId:E,isLoading:A,isLoadingSharedThreads:R,actions:$,shareInFlight:F,shareStatus:V,clearShareStatus:X}=xr(),{createThread:_,deleteThread:G,renameThread:H,shareThread:z}=$,{loadThread:D}=to(),I=i??T,[Y,J]=w.useState(Array.isArray(k)?k:[]),j=w.useRef(Y.length>0),B=w.useRef(null),P=w.useRef(0),[O,K]=w.useState(null),[M,L]=w.useState(""),[q,Z]=w.useState(!1),[se,ie]=w.useState(!1),[re,de]=w.useState(null),[be,Me]=w.useState(""),Fe=v&&v.length>0?v:$k,De=fm({defaultView:m}),Le=g??De,it=h??Le.view,dt=w.useCallback(ne=>{h||Le.setView(ne),f==null||f(ne)},[h,f,Le]),Et=Fe.find(ne=>ne.key===it)??Fe[0],Ke=ne=>{de(ne),Me(""),ie(!0)},We=()=>{ie(!1),de(null),Me(""),X()},Xe=w.useCallback(async ne=>{if(!(!re||F)&&ne.id)try{await z(re,ne.id),setTimeout(()=>We(),600)}catch(xe){console.error("Failed to share thread:",xe)}},[We,F,re,z]),ke=w.useMemo(()=>{const ne=y??[],xe=be.trim().toLowerCase();return xe?C?ne.filter(pe=>C(pe,xe)):ne.filter(pe=>`${pe.label} ${pe.secondaryLabel??""}`.toLowerCase().includes(xe)):ne},[y,be,C]),Ue=it==="shared",ut=Ue?S:Y,bt=Ue?R:A,Je=Ue?"No shared conversations yet":"No conversations yet",Ct=ne=>{const xe=ne.sharedAt?` • ${Be(ne.sharedAt)}`:"";return`Shared by ${ne.sharedByUserId}${xe}`},gt=ne=>"sharedByUserId"in ne;w.useEffect(()=>{const ne=Array.isArray(k)?k:[];if(ne.length>0){j.current=!0,J(ne);return}A||(j.current=!1,J(ne))},[k,A]),w.useEffect(()=>{if(!B.current)return;const ne=B.current.querySelector("[data-radix-scroll-area-viewport]");if(!ne)return;let xe=null,pe=null;return xe=requestAnimationFrame(()=>{pe=requestAnimationFrame(()=>{ne.scrollTop=P.current})}),()=>{xe!==null&&cancelAnimationFrame(xe),pe!==null&&cancelAnimationFrame(pe)}},[Y]);const xt=async ne=>{try{E(ne),await D(ne),a==null||a(ne),l==null||l(ne)}catch(xe){console.error("Failed to select thread:",xe)}},It=async()=>{try{Z(!0);const ne=await _();ne&&(c==null||c(ne),a==null||a(ne))}catch(ne){console.error("Failed to create thread:",ne)}finally{Z(!1)}},rn=async(ne,xe)=>{if(xe.stopPropagation(),!!confirm("Delete this thread?")){if(B.current){const pe=B.current.querySelector("[data-radix-scroll-area-viewport]");pe&&(P.current=pe.scrollTop)}try{await G(ne),d==null||d(ne)}catch(pe){console.error("Failed to delete thread:",pe)}}},Nt=(ne,xe)=>{xe.stopPropagation(),K(ne.threadId),L(ne.title||`Thread ${ne.threadId.slice(0,8)}`)},mn=async ne=>{if(M.trim())try{await H(ne,M.trim()),K(null),L("")}catch(xe){console.error("Failed to update title:",xe)}},Zt=()=>{K(null),L("")},Be=ne=>{if(!ne)return"";try{const xe=new Date(ne),ce=new Date().getTime()-xe.getTime(),Ce=Math.floor(ce/(1e3*60*60*24));return Ce===0?xe.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):Ce===1?"Yesterday":Ce<7?`${Ce} days ago`:xe.toLocaleDateString()}catch{return""}},$e=ne=>ne.title||`Thread ${ne.threadId.slice(0,8)}`,Tt=ne=>{const xe=$e(ne);return xe.length<=um?xe:`${xe.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(et,{onClick:It,disabled:q||A,className:s.createButton||"px-3 py-2 gap-1",size:"sm",variant:"ghost",title:q?"Creating...":"New Chat",children:[u.jsx(le.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(Ts,{children:[u.jsx(ks,{asChild:!0,children:u.jsx(et,{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:Et.label})}),u.jsx(po,{align:"start",sideOffset:6,className:"w-40",children:Fe.map(ne=>u.jsxs(Fn,{className:"justify-between text-[12px]",onClick:xe=>{xe.preventDefault(),dt(ne.key)},children:[u.jsx("span",{children:ne.label}),it===ne.key&&u.jsx(le.Check,{className:"h-3 w-3"})]},ne.key))})]})]})]}),u.jsx(_l,{ref:B,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:bt?u.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-8 text-slate-400",children:[u.jsx(le.Loader2,{className:"h-5 w-5 animate-spin"}),u.jsx("span",{className:"text-sm",children:"Loading threads…"})]}):ut.length===0?u.jsxs("div",{className:"text-center py-8 text-slate-400",children:[u.jsx(le.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:Je})]}):ut.slice().sort((ne,xe)=>new Date(xe.updatedAt||xe.createdAt||"").getTime()-new Date(ne.updatedAt||ne.createdAt||"").getTime()).map(ne=>u.jsx(cm,{thread:ne,isActive:I===ne.threadId,editingThreadId:O,editingTitle:M,onSelect:xt,onStartEditing:Nt,onEditingTitleChange:xe=>L(xe),onSaveEditing:mn,onCancelEditing:Zt,onShare:()=>Ke(ne.threadId),onDelete:rn,showEditTitle:r,showDeleteButton:n,formatDate:Be,getDisplayThreadTitle:Tt,secondaryLine:Ue&&gt(ne)?Ct(ne):void 0,itemClassName:s.threadItem,activeItemClassName:s.activeThread},ne.threadId))})}),u.jsx(tl,{open:se,onOpenChange:ne=>!ne&&We(),children:u.jsxs(Hs,{className:"max-w-md p-0",children:[u.jsx(Us,{children:u.jsx(Ws,{children:"Share thread"})}),u.jsxs(yl,{children:[u.jsx(Sl,{autoFocus:!0,value:be,onValueChange:ne=>Me(ne),placeholder:"Search for recipients..."}),u.jsxs(Cl,{children:[V&&u.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-xs text-muted-foreground",children:[F&&u.jsx(le.Loader2,{className:"h-3 w-3 animate-spin"}),u.jsx("span",{className:V.startsWith("Failed")?"text-red-500":V.startsWith("Shared")?"text-emerald-500":"text-slate-600 dark:text-slate-400",children:V})]}),u.jsx(Tl,{children:b?u.jsxs("span",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(le.Loader2,{className:"h-4 w-4 animate-spin"}),"Loading recipients…"]}):"No matching recipients found"}),ke.length>0&&u.jsx(kl,{heading:"Recipients",children:ke.map(ne=>u.jsx(El,{onSelect:()=>Xe(ne),children:u.jsxs("div",{className:"flex flex-col items-start text-sm",children:[u.jsx("span",{className:"font-medium",children:ne.label}),ne.secondaryLabel&&u.jsx("span",{className:"text-xs text-muted-foreground",children:ne.secondaryLabel})]})},ne.id))})]})]})]})})]})}function Fk({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=w.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(Or,{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(oi,{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(Or,{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(oi,{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(Or,{onError:s.onError,enableFileUpload:!0})})]})})}function Bk({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(Or,{})})})}function zk({placeholder:e,onMessageSent:t}){const[n,r]=w.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(le.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(le.History,{size:14}),"History"]})})]}),u.jsx("div",{className:"flex-1 min-h-0",children:n==="chat"?u.jsx(Or,{placeholder:e??"Ask Serti AI anything...",autoFocus:!0,className:"h-full",onMessageSent:t}):u.jsx(oi,{showCreateButton:!0,className:"h-full",onThreadSelect:()=>r("chat")})})]})}function Hk({className:e="",placeholder:t,isAuthenticated:n=!0,onMessageSent:r,widgetTitle:o="Serti AI Navigator",widgetSubtitle:s="AI-Powered Assistant",...i}){const[a,l]=w.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(et,{variant:"ghost",size:"sm",className:"text-white hover:bg-white/10 h-8 w-8 p-0",title:"Options",children:u.jsx(le.MoreHorizontal,{size:16})}),u.jsx(et,{variant:"ghost",size:"sm",className:"text-white hover:bg-white/10 h-8 w-8 p-0",title:"Compose",children:u.jsx(le.Edit3,{size:16})}),u.jsx(et,{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(le.Maximize2,{size:14}):u.jsx(le.Minimize2,{size:14})})]})]})}),!a&&u.jsx("div",{className:"h-96 flex flex-col",children:u.jsx(zk,{placeholder:t,onMessageSent:r})})]})})}):null}function Uk({label:e="New chat",children:t,className:n,variant:r="ghost",size:o="sm",...s}){return u.jsxs(et,{variant:r,size:o,className:te("gap-2 rounded-full px-3 font-semibold transition-all hover:scale-[1.01]",n),...s,children:[u.jsx(le.Edit3,{size:16}),t??e]})}var Wk="Label",hm=p.forwardRef((e,t)=>u.jsx(me.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=Wk;var pm=hm;const Vk=Hr.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:te(Vk(),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"}),Kk="VisuallyHidden",si=p.forwardRef((e,t)=>u.jsx(me.span,{...e,ref:t,style:{...xm,...e.style}}));si.displayName=Kk;var qk=si,Gk=[" ","Enter","ArrowUp","ArrowDown"],Yk=[" ","Enter"],dr="Select",[ii,ai,Xk]=Jo(dr),[Fr,L1]=an(dr,[Xk,Ir]),li=Ir(),[Jk,qn]=Fr(dr),[Zk,Qk]=Fr(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=li(t),[x,y]=p.useState(null),[b,C]=p.useState(null),[k,S]=p.useState(!1),T=Zo(c),[E,A]=On({prop:r,defaultProp:o??!1,onChange:s,caller:dr}),[R,$]=On({prop:i,defaultProp:a,onChange:l,caller:dr}),F=p.useRef(null),V=x?v||!!x.closest("form"):!0,[X,_]=p.useState(new Set),G=Array.from(X).map(H=>H.props.value).join(";");return u.jsx(ia,{...g,children:u.jsxs(Jk,{required:f,scope:t,trigger:x,onTriggerChange:y,valueNode:b,onValueNodeChange:C,valueNodeHasChildren:k,onValueNodeHasChildrenChange:S,contentId:jt(),value:R,onValueChange:$,open:E,onOpenChange:A,dir:T,triggerPointerDownPosRef:F,disabled:m,children:[u.jsx(ii.Provider,{scope:t,children:u.jsx(Zk,{scope:e.__scopeSelect,onNativeOptionAdd:p.useCallback(H=>{_(z=>new Set(z).add(H))},[]),onNativeOptionRemove:p.useCallback(H=>{_(z=>{const D=new Set(z);return D.delete(H),D})},[]),children:n})}),V?u.jsxs(Hm,{"aria-hidden":!0,required:f,tabIndex:-1,name:d,autoComplete:h,value:R,onChange:H=>$(H.target.value),disabled:m,form:v,children:[R===void 0?u.jsx("option",{value:""}):null,Array.from(X)]},G):null]})})};vm.displayName=dr;var wm="SelectTrigger",bm=p.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=li(n),i=qn(wm,n),a=i.disabled||r,l=_e(t,i.onTriggerChange),c=ai(n),d=p.useRef("touch"),[h,m,f]=Wm(g=>{const x=c().filter(C=>!C.disabled),y=x.find(C=>C.value===i.value),b=Vm(x,g,y);b!==void 0&&i.onValueChange(b.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(aa,{asChild:!0,...s,children:u.jsx(me.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:ae(o.onClick,g=>{g.currentTarget.focus(),d.current!=="mouse"&&v(g)}),onPointerDown:ae(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:ae(o.onKeyDown,g=>{const x=h.current!=="";!(g.ctrlKey||g.altKey||g.metaKey)&&g.key.length===1&&m(g.key),!(x&&g.key===" ")&&Gk.includes(g.key)&&(v(),g.preventDefault())})})})});bm.displayName=wm;var ym="SelectValue",Sm=p.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=qn(ym,n),{onValueNodeHasChildrenChange:c}=l,d=s!==void 0,h=_e(t,l.onValueNodeChange);return kt(()=>{c(d)},[c,d]),u.jsx(me.span,{...a,ref:h,style:{pointerEvents:"none"},children:Um(l.value)?u.jsx(u.Fragment,{children:i}):s})});Sm.displayName=ym;var eE="SelectIcon",Cm=p.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return u.jsx(me.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});Cm.displayName=eE;var tE="SelectPortal",Tm=e=>u.jsx(io,{asChild:!0,...e});Tm.displayName=tE;var fr="SelectContent",km=p.forwardRef((e,t)=>{const n=qn(fr,e.__scopeSelect),[r,o]=p.useState();if(kt(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?Ur.createPortal(u.jsx(Em,{scope:e.__scopeSelect,children:u.jsx(ii.Slot,{scope:e.__scopeSelect,children:u.jsx("div",{children:e.children})})}),s):null}return u.jsx(Im,{...e,ref:t})});km.displayName=fr;var hn=10,[Em,Gn]=Fr(fr),nE="SelectContentImpl",rE=Vt.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,b=qn(fr,n),[C,k]=p.useState(null),[S,T]=p.useState(null),E=_e(t,M=>k(M)),[A,R]=p.useState(null),[$,F]=p.useState(null),V=ai(n),[X,_]=p.useState(!1),G=p.useRef(!1);p.useEffect(()=>{if(C)return ha(C)},[C]),Wi();const H=p.useCallback(M=>{const[L,...q]=V().map(ie=>ie.ref.current),[Z]=q.slice(-1),se=document.activeElement;for(const ie of M)if(ie===se||(ie==null||ie.scrollIntoView({block:"nearest"}),ie===L&&S&&(S.scrollTop=0),ie===Z&&S&&(S.scrollTop=S.scrollHeight),ie==null||ie.focus(),document.activeElement!==se))return},[V,S]),z=p.useCallback(()=>H([A,C]),[H,A,C]);p.useEffect(()=>{X&&z()},[X,z]);const{onOpenChange:D,triggerPointerDownPosRef:I}=b;p.useEffect(()=>{if(C){let M={x:0,y:0};const L=Z=>{var se,ie;M={x:Math.abs(Math.round(Z.pageX)-(((se=I.current)==null?void 0:se.x)??0)),y:Math.abs(Math.round(Z.pageY)-(((ie=I.current)==null?void 0:ie.y)??0))}},q=Z=>{M.x<=10&&M.y<=10?Z.preventDefault():C.contains(Z.target)||D(!1),document.removeEventListener("pointermove",L),I.current=null};return I.current!==null&&(document.addEventListener("pointermove",L),document.addEventListener("pointerup",q,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",L),document.removeEventListener("pointerup",q,{capture:!0})}}},[C,D,I]),p.useEffect(()=>{const M=()=>D(!1);return window.addEventListener("blur",M),window.addEventListener("resize",M),()=>{window.removeEventListener("blur",M),window.removeEventListener("resize",M)}},[D]);const[Y,J]=Wm(M=>{const L=V().filter(se=>!se.disabled),q=L.find(se=>se.ref.current===document.activeElement),Z=Vm(L,M,q);Z&&setTimeout(()=>Z.ref.current.focus())}),j=p.useCallback((M,L,q)=>{const Z=!G.current&&!q;(b.value!==void 0&&b.value===L||Z)&&(R(M),Z&&(G.current=!0))},[b.value]),B=p.useCallback(()=>C==null?void 0:C.focus(),[C]),P=p.useCallback((M,L,q)=>{const Z=!G.current&&!q;(b.value!==void 0&&b.value===L||Z)&&F(M)},[b.value]),O=r==="popper"?Ml:Nm,K=O===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:C,viewport:S,onViewportChange:T,itemRefCallback:j,selectedItem:A,onItemLeave:B,itemTextRefCallback:P,focusSelectedItem:z,selectedItemText:$,position:r,isPositioned:X,searchRef:Y,children:u.jsx(vs,{as:rE,allowPinchZoom:!0,children:u.jsx(Qo,{asChild:!0,trapped:b.open,onMountAutoFocus:M=>{M.preventDefault()},onUnmountAutoFocus:ae(o,M=>{var L;(L=b.trigger)==null||L.focus({preventScroll:!0}),M.preventDefault()}),children:u.jsx(Sr,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:M=>M.preventDefault(),onDismiss:()=>b.onOpenChange(!1),children:u.jsx(O,{role:"listbox",id:b.contentId,"data-state":b.open?"open":"closed",dir:b.dir,onContextMenu:M=>M.preventDefault(),...y,...K,onPlaced:()=>_(!0),ref:E,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:ae(y.onKeyDown,M=>{const L=M.ctrlKey||M.altKey||M.metaKey;if(M.key==="Tab"&&M.preventDefault(),!L&&M.key.length===1&&J(M.key),["ArrowUp","ArrowDown","Home","End"].includes(M.key)){let Z=V().filter(se=>!se.disabled).map(se=>se.ref.current);if(["ArrowUp","End"].includes(M.key)&&(Z=Z.slice().reverse()),["ArrowUp","ArrowDown"].includes(M.key)){const se=M.target,ie=Z.indexOf(se);Z=Z.slice(ie+1)}setTimeout(()=>H(Z)),M.preventDefault()}})})})})})})});Im.displayName=nE;var oE="SelectItemAlignedPosition",Nm=p.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=qn(fr,n),i=Gn(fr,n),[a,l]=p.useState(null),[c,d]=p.useState(null),h=_e(t,E=>d(E)),m=ai(n),f=p.useRef(!1),v=p.useRef(!0),{viewport:g,selectedItem:x,selectedItemText:y,focusSelectedItem:b}=i,C=p.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&c&&g&&x&&y){const E=s.trigger.getBoundingClientRect(),A=c.getBoundingClientRect(),R=s.valueNode.getBoundingClientRect(),$=y.getBoundingClientRect();if(s.dir!=="rtl"){const se=$.left-A.left,ie=R.left-se,re=E.left-ie,de=E.width+re,be=Math.max(de,A.width),Me=window.innerWidth-hn,Fe=Il(ie,[hn,Math.max(hn,Me-be)]);a.style.minWidth=de+"px",a.style.left=Fe+"px"}else{const se=A.right-$.right,ie=window.innerWidth-R.right-se,re=window.innerWidth-E.right-ie,de=E.width+re,be=Math.max(de,A.width),Me=window.innerWidth-hn,Fe=Il(ie,[hn,Math.max(hn,Me-be)]);a.style.minWidth=de+"px",a.style.right=Fe+"px"}const F=m(),V=window.innerHeight-hn*2,X=g.scrollHeight,_=window.getComputedStyle(c),G=parseInt(_.borderTopWidth,10),H=parseInt(_.paddingTop,10),z=parseInt(_.borderBottomWidth,10),D=parseInt(_.paddingBottom,10),I=G+H+X+D+z,Y=Math.min(x.offsetHeight*5,I),J=window.getComputedStyle(g),j=parseInt(J.paddingTop,10),B=parseInt(J.paddingBottom,10),P=E.top+E.height/2-hn,O=V-P,K=x.offsetHeight/2,M=x.offsetTop+K,L=G+H+M,q=I-L;if(L<=P){const se=F.length>0&&x===F[F.length-1].ref.current;a.style.bottom="0px";const ie=c.clientHeight-g.offsetTop-g.offsetHeight,re=Math.max(O,K+(se?B:0)+ie+z),de=L+re;a.style.height=de+"px"}else{const se=F.length>0&&x===F[0].ref.current;a.style.top="0px";const re=Math.max(P,G+g.offsetTop+(se?j:0)+K)+q;a.style.height=re+"px",g.scrollTop=L-P+g.offsetTop}a.style.margin=`${hn}px 0`,a.style.minHeight=Y+"px",a.style.maxHeight=V+"px",r==null||r(),requestAnimationFrame(()=>f.current=!0)}},[m,s.trigger,s.valueNode,a,c,g,x,y,s.dir,r]);kt(()=>C(),[C]);const[k,S]=p.useState();kt(()=>{c&&S(window.getComputedStyle(c).zIndex)},[c]);const T=p.useCallback(E=>{E&&v.current===!0&&(C(),b==null||b(),v.current=!1)},[C,b]);return u.jsx(iE,{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(me.div,{...o,ref:h,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Nm.displayName=oE;var sE="SelectPopperPosition",Ml=p.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=hn,...s}=e,i=li(n);return u.jsx(la,{...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=sE;var[iE,Ol]=Fr(fr,{}),Dl="SelectViewport",Am=p.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=Gn(Dl,n),i=Ol(Dl,n),a=_e(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(ii.Slot,{scope:n,children:u.jsx(me.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:ae(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-hn*2,g=parseFloat(h.style.minHeight),x=parseFloat(h.style.height),y=Math.max(g,x);if(y<v){const b=y+f,C=Math.min(v,b),k=b-C;h.style.height=C+"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",[aE,lE]=Fr(jm),cE=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=jt();return u.jsx(aE,{scope:n,id:o,children:u.jsx(me.div,{role:"group","aria-labelledby":o,...r,ref:t})})});cE.displayName=jm;var Pm="SelectLabel",_m=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=lE(Pm,n);return u.jsx(me.div,{id:o.id,...r,ref:t})});_m.displayName=Pm;var ci="SelectItem",[uE,Rm]=Fr(ci),Mm=p.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=qn(ci,n),l=Gn(ci,n),c=a.value===r,[d,h]=p.useState(s??""),[m,f]=p.useState(!1),v=_e(t,b=>{var C;return(C=l.itemRefCallback)==null?void 0:C.call(l,b,r,o)}),g=jt(),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(uE,{scope:n,value:r,disabled:o,textId:g,isSelected:c,onItemTextChange:p.useCallback(b=>{h(C=>C||((b==null?void 0:b.textContent)??"").trim())},[]),children:u.jsx(ii.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:u.jsx(me.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:ae(i.onFocus,()=>f(!0)),onBlur:ae(i.onBlur,()=>f(!1)),onClick:ae(i.onClick,()=>{x.current!=="mouse"&&y()}),onPointerUp:ae(i.onPointerUp,()=>{x.current==="mouse"&&y()}),onPointerDown:ae(i.onPointerDown,b=>{x.current=b.pointerType}),onPointerMove:ae(i.onPointerMove,b=>{var C;x.current=b.pointerType,o?(C=l.onItemLeave)==null||C.call(l):x.current==="mouse"&&b.currentTarget.focus({preventScroll:!0})}),onPointerLeave:ae(i.onPointerLeave,b=>{var C;b.currentTarget===document.activeElement&&((C=l.onItemLeave)==null||C.call(l))}),onKeyDown:ae(i.onKeyDown,b=>{var k;((k=l.searchRef)==null?void 0:k.current)!==""&&b.key===" "||(Yk.includes(b.key)&&y(),b.key===" "&&b.preventDefault())})})})})});Mm.displayName=ci;var Po="SelectItemText",Om=p.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=qn(Po,n),a=Gn(Po,n),l=Rm(Po,n),c=Qk(Po,n),[d,h]=p.useState(null),m=_e(t,y=>h(y),l.onItemTextChange,y=>{var b;return(b=a.itemTextRefCallback)==null?void 0:b.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 kt(()=>(g(v),()=>x(v)),[g,x,v]),u.jsxs(u.Fragment,{children:[u.jsx(me.span,{id:l.textId,...s,ref:m}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?Ur.createPortal(s.children,i.valueNode):null]})});Om.displayName=Po;var Dm="SelectItemIndicator",Lm=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return Rm(Dm,n).isSelected?u.jsx(me.span,{"aria-hidden":!0,...r,ref:t}):null});Lm.displayName=Dm;var Ll="SelectScrollUpButton",$m=p.forwardRef((e,t)=>{const n=Gn(Ll,e.__scopeSelect),r=Ol(Ll,e.__scopeSelect),[o,s]=p.useState(!1),i=_e(t,r.onScrollButtonChange);return kt(()=>{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=Gn($l,e.__scopeSelect),r=Ol($l,e.__scopeSelect),[o,s]=p.useState(!1),i=_e(t,r.onScrollButtonChange);return kt(()=>{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=Gn("SelectScrollButton",n),i=p.useRef(null),a=ai(n),l=p.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return p.useEffect(()=>()=>l(),[l]),kt(()=>{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(me.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:ae(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:ae(o.onPointerMove,()=>{var c;(c=s.onItemLeave)==null||c.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:ae(o.onPointerLeave,()=>{l()})})}),dE="SelectSeparator",zm=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return u.jsx(me.div,{"aria-hidden":!0,...r,ref:t})});zm.displayName=dE;var Fl="SelectArrow",fE=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=li(n),s=qn(Fl,n),i=Gn(Fl,n);return s.open&&i.position==="popper"?u.jsx(ca,{...o,...r,ref:t}):null});fE.displayName=Fl;var hE="SelectBubbleInput",Hm=p.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=p.useRef(null),s=_e(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(me.select,{...n,style:{...xm,...n.style},ref:s,defaultValue:t})});Hm.displayName=hE;function Um(e){return e===""||e===void 0}function Wm(e){const t=pt(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=pE(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 pE(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var mE=vm,Km=bm,gE=Sm,xE=Cm,vE=Tm,qm=km,wE=Am,Gm=_m,Ym=Mm,bE=Om,yE=Lm,Xm=$m,Jm=Fm,Zm=zm;const SE=mE,CE=gE,Qm=p.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Km,{ref:r,className:te("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(xE,{asChild:!0,children:u.jsx(le.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:te("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(le.ChevronUp,{className:"h-4 w-4"})}));eg.displayName=Xm.displayName;const tg=p.forwardRef(({className:e,...t},n)=>u.jsx(Jm,{ref:n,className:te("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(le.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(vE,{children:u.jsxs(qm,{ref:o,className:te("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(wE,{className:te("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 TE=p.forwardRef(({className:e,...t},n)=>u.jsx(Gm,{ref:n,className:te("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));TE.displayName=Gm.displayName;const rg=p.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Ym,{ref:r,className:te("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(yE,{children:u.jsx(le.Check,{className:"h-4 w-4"})})}),u.jsx(bE,{children:t})]}));rg.displayName=Ym.displayName;const kE=p.forwardRef(({className:e,...t},n)=>u.jsx(Zm,{ref:n,className:te("-mx-1 my-1 h-px bg-muted",e),...t}));kE.displayName=Zm.displayName;var EE="Separator",og="horizontal",IE=["horizontal","vertical"],sg=p.forwardRef((e,t)=>{const{decorative:n,orientation:r=og,...o}=e,s=NE(r)?r:og,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return u.jsx(me.div,{"data-orientation":s,...a,...o,ref:t})});sg.displayName=EE;function NE(e){return IE.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:te("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));ag.displayName=ig.displayName;var ui="Switch",[AE,$1]=an(ui),[jE,PE]=AE(ui),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=_e(t,C=>f(C)),g=p.useRef(!1),x=m?d||!!m.closest("form"):!0,[y,b]=On({prop:o,defaultProp:s??!1,onChange:c,caller:ui});return u.jsxs(jE,{scope:n,checked:y,disabled:a,children:[u.jsx(me.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:ae(e.onClick,C=>{b(k=>!k),x&&(g.current=C.isPropagationStopped(),g.current||C.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=ui;var cg="SwitchThumb",ug=p.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=PE(cg,n);return u.jsx(me.span,{"data-state":fg(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});ug.displayName=cg;var _E="SwitchBubbleInput",dg=p.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=p.useRef(null),a=_e(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=_E;function fg(e){return e?"checked":"unchecked"}var hg=lg,RE=ug;const pg=p.forwardRef(({className:e,...t},n)=>u.jsx(hg,{className:te("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(RE,{className:te("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 ME=Qa,OE=fT,DE=el,mg=p.forwardRef(({className:e,...t},n)=>u.jsx(ko,{className:te("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=ko.displayName;const LE=Hr.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(DE,{children:[u.jsx(mg,{}),u.jsxs(Eo,{ref:o,className:te(LE({side:e}),t),...r,children:[n,u.jsxs(ip,{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(le.X,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));gg.displayName=Eo.displayName;const xg=({className:e,...t})=>u.jsx("div",{className:te("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(ar,{ref:n,className:te("text-lg font-semibold text-foreground",e),...t}));vg.displayName=ar.displayName;const wg=p.forwardRef(({className:e,...t},n)=>u.jsx(zs,{ref:n,className:te("text-sm text-muted-foreground",e),...t}));wg.displayName=zs.displayName;var[di,F1]=an("Tooltip",[Ir]),fi=Ir(),bg="TooltipProvider",$E=700,Bl="tooltip.open",[FE,zl]=di(bg),yg=e=>{const{__scopeTooltip:t,delayDuration:n=$E,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(FE,{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=bg;var _o="Tooltip",[BE,hi]=di(_o),Sg=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:s,disableHoverableContent:i,delayDuration:a}=e,l=zl(_o,e.__scopeTooltip),c=fi(t),[d,h]=p.useState(null),m=jt(),f=p.useRef(0),v=i??l.disableHoverableContent,g=a??l.delayDuration,x=p.useRef(!1),[y,b]=On({prop:r,defaultProp:o??!1,onChange:E=>{E?(l.onOpen(),document.dispatchEvent(new CustomEvent(Bl))):l.onClose(),s==null||s(E)},caller:_o}),C=p.useMemo(()=>y?x.current?"delayed-open":"instant-open":"closed",[y]),k=p.useCallback(()=>{window.clearTimeout(f.current),f.current=0,x.current=!1,b(!0)},[b]),S=p.useCallback(()=>{window.clearTimeout(f.current),f.current=0,b(!1)},[b]),T=p.useCallback(()=>{window.clearTimeout(f.current),f.current=window.setTimeout(()=>{x.current=!0,b(!0),f.current=0},g)},[g,b]);return p.useEffect(()=>()=>{f.current&&(window.clearTimeout(f.current),f.current=0)},[]),u.jsx(ia,{...c,children:u.jsx(BE,{scope:t,contentId:m,open:y,stateAttribute:C,trigger:d,onTriggerChange:h,onTriggerEnter:p.useCallback(()=>{l.isOpenDelayedRef.current?T():k()},[l.isOpenDelayedRef,T,k]),onTriggerLeave:p.useCallback(()=>{v?S():(window.clearTimeout(f.current),f.current=0)},[S,v]),onOpen:k,onClose:S,disableHoverableContent:v,children:n})})};Sg.displayName=_o;var Hl="TooltipTrigger",Cg=p.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=hi(Hl,n),s=zl(Hl,n),i=fi(n),a=p.useRef(null),l=_e(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(aa,{asChild:!0,...i,children:u.jsx(me.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:l,onPointerMove:ae(e.onPointerMove,m=>{m.pointerType!=="touch"&&!d.current&&!s.isPointerInTransitRef.current&&(o.onTriggerEnter(),d.current=!0)}),onPointerLeave:ae(e.onPointerLeave,()=>{o.onTriggerLeave(),d.current=!1}),onPointerDown:ae(e.onPointerDown,()=>{o.open&&o.onClose(),c.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:ae(e.onFocus,()=>{c.current||o.onOpen()}),onBlur:ae(e.onBlur,o.onClose),onClick:ae(e.onClick,o.onClose)})})});Cg.displayName=Hl;var zE="TooltipPortal",[B1,HE]=di(zE,{forceMount:void 0}),Br="TooltipContent",Tg=p.forwardRef((e,t)=>{const n=HE(Br,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...s}=e,i=hi(Br,e.__scopeTooltip);return u.jsx(Bt,{present:r||i.open,children:i.disableHoverableContent?u.jsx(kg,{side:o,...s,ref:t}):u.jsx(UE,{side:o,...s,ref:t})})}),UE=p.forwardRef((e,t)=>{const n=hi(Br,e.__scopeTooltip),r=zl(Br,e.__scopeTooltip),o=p.useRef(null),s=_e(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},b=GE(y,x.getBoundingClientRect()),C=YE(y,b),k=XE(g.getBoundingClientRect()),S=ZE([...C,...k]);a(S),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},b=(l==null?void 0:l.contains(x))||(d==null?void 0:d.contains(x)),C=!JE(y,i);b?m():C&&(m(),c())};return document.addEventListener("pointermove",v),()=>document.removeEventListener("pointermove",v)}},[l,d,i,c,m]),u.jsx(kg,{...e,ref:s})}),[WE,VE]=di(_o,{isInside:!1}),KE=Vt.createSlottable("TooltipContent"),kg=p.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:s,onPointerDownOutside:i,...a}=e,l=hi(Br,n),c=fi(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(Sr,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:h=>h.preventDefault(),onDismiss:d,children:u.jsxs(la,{"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(KE,{children:r}),u.jsx(WE,{scope:n,isInside:!0,children:u.jsx(qk,{id:l.contentId,role:"tooltip",children:o||r})})]})})});Tg.displayName=Br;var Eg="TooltipArrow",qE=p.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=fi(n);return VE(Eg,n).isInside?null:u.jsx(ca,{...o,...r,ref:t})});qE.displayName=Eg;function GE(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 YE(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 XE(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 JE(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 ZE(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),QE(t)}function QE(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 eI=yg,tI=Sg,nI=Cg,Ig=Tg;const rI=eI,oI=tI,sI=nI,Ng=p.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(Ig,{ref:r,sideOffset:t,className:te("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,iI,aI]=Jo("Toast"),[Ag,z1]=an("Toast",[aI]),[lI,pi]=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(lI,{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",cI=["F8"],Vl="toast.viewportPause",Kl="toast.viewportResume",_g=p.forwardRef((e,t)=>{const{__scopeToast:n,hotkey:r=cI,label:o="Notifications ({hotkey})",...s}=e,i=pi(Pg,n),a=iI(n),l=p.useRef(null),c=p.useRef(null),d=p.useRef(null),h=p.useRef(null),m=_e(t,h,i.onViewportChange),f=r.join("+").replace(/Key/g,"").replace(/Digit/g,""),v=i.toastCount>0;p.useEffect(()=>{const x=y=>{var C;r.length!==0&&r.every(k=>y[k]||y.code===k)&&((C=h.current)==null||C.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 b=()=>{if(!i.isClosePausedRef.current){const T=new CustomEvent(Vl);y.dispatchEvent(T),i.isClosePausedRef.current=!0}},C=()=>{if(i.isClosePausedRef.current){const T=new CustomEvent(Kl);y.dispatchEvent(T),i.isClosePausedRef.current=!1}},k=T=>{!x.contains(T.relatedTarget)&&C()},S=()=>{x.contains(document.activeElement)||C()};return x.addEventListener("focusin",b),x.addEventListener("focusout",k),x.addEventListener("pointermove",b),x.addEventListener("pointerleave",S),window.addEventListener("blur",b),window.addEventListener("focus",C),()=>{x.removeEventListener("focusin",b),x.removeEventListener("focusout",k),x.removeEventListener("pointermove",b),x.removeEventListener("pointerleave",S),window.removeEventListener("blur",b),window.removeEventListener("focus",C)}}},[v,i.isClosePausedRef]);const g=p.useCallback(({tabbingDirection:x})=>{const b=a().map(C=>{const k=C.ref.current,S=[k,...SI(k)];return x==="forwards"?S:S.reverse()});return(x==="forwards"?b.reverse():b).flat()},[a]);return p.useEffect(()=>{const x=h.current;if(x){const y=b=>{var S,T,E;const C=b.altKey||b.ctrlKey||b.metaKey;if(b.key==="Tab"&&!C){const A=document.activeElement,R=b.shiftKey;if(b.target===x&&R){(S=c.current)==null||S.focus();return}const V=g({tabbingDirection:R?"backwards":"forwards"}),X=V.findIndex(_=>_===A);Yl(V.slice(X+1))?b.preventDefault():R?(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(Bw,{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(me.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=pi(Rg,n);return u.jsx(si,{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 Ro="Toast",uI="toast.swipeStart",dI="toast.swipeMove",fI="toast.swipeCancel",hI="toast.swipeEnd",Mg=p.forwardRef((e,t)=>{const{forceMount:n,open:r,defaultOpen:o,onOpenChange:s,...i}=e,[a,l]=On({prop:r,defaultProp:o??!0,onChange:s,caller:Ro});return u.jsx(Bt,{present:n||a,children:u.jsx(gI,{open:a,...i,ref:t,onClose:()=>l(!1),onPause:pt(e.onPause),onResume:pt(e.onResume),onSwipeStart:ae(e.onSwipeStart,c=>{c.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:ae(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:ae(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:ae(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=Ro;var[pI,mI]=Ag(Ro,{onClose(){}}),gI=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=pi(Ro,n),[x,y]=p.useState(null),b=_e(t,_=>y(_)),C=p.useRef(null),k=p.useRef(null),S=o||g.duration,T=p.useRef(0),E=p.useRef(S),A=p.useRef(0),{onToastAdd:R,onToastRemove:$}=g,F=pt(()=>{var G;(x==null?void 0:x.contains(document.activeElement))&&((G=g.viewport)==null||G.focus()),i()}),V=p.useCallback(_=>{!_||_===1/0||(window.clearTimeout(A.current),T.current=new Date().getTime(),A.current=window.setTimeout(F,_))},[F]);p.useEffect(()=>{const _=g.viewport;if(_){const G=()=>{V(E.current),c==null||c()},H=()=>{const z=new Date().getTime()-T.current;E.current=E.current-z,window.clearTimeout(A.current),l==null||l()};return _.addEventListener(Vl,H),_.addEventListener(Kl,G),()=>{_.removeEventListener(Vl,H),_.removeEventListener(Kl,G)}}},[g.viewport,S,l,c,V]),p.useEffect(()=>{s&&!g.isClosePausedRef.current&&V(S)},[s,S,g.isClosePausedRef,V]),p.useEffect(()=>(R(),()=>$()),[R,$]);const X=p.useMemo(()=>x?zg(x):null,[x]);return g.viewport?u.jsxs(u.Fragment,{children:[X&&u.jsx(xI,{__scopeToast:n,role:"status","aria-live":r==="foreground"?"assertive":"polite",children:X}),u.jsx(pI,{scope:n,onClose:F,children:Ur.createPortal(u.jsx(Wl.ItemSlot,{scope:n,children:u.jsx(Fw,{asChild:!0,onEscapeKeyDown:ae(a,()=>{g.isFocusedToastEscapeKeyDownRef.current||F(),g.isFocusedToastEscapeKeyDownRef.current=!1}),children:u.jsx(me.li,{tabIndex:0,"data-state":s?"open":"closed","data-swipe-direction":g.swipeDirection,...v,ref:b,style:{userSelect:"none",touchAction:"none",...e.style},onKeyDown:ae(e.onKeyDown,_=>{_.key==="Escape"&&(a==null||a(_.nativeEvent),_.nativeEvent.defaultPrevented||(g.isFocusedToastEscapeKeyDownRef.current=!0,F()))}),onPointerDown:ae(e.onPointerDown,_=>{_.button===0&&(C.current={x:_.clientX,y:_.clientY})}),onPointerMove:ae(e.onPointerMove,_=>{if(!C.current)return;const G=_.clientX-C.current.x,H=_.clientY-C.current.y,z=!!k.current,D=["left","right"].includes(g.swipeDirection),I=["left","up"].includes(g.swipeDirection)?Math.min:Math.max,Y=D?I(0,G):0,J=D?0:I(0,H),j=_.pointerType==="touch"?10:2,B={x:Y,y:J},P={originalEvent:_,delta:B};z?(k.current=B,mi(dI,h,P,{discrete:!1})):Hg(B,g.swipeDirection,j)?(k.current=B,mi(uI,d,P,{discrete:!1}),_.target.setPointerCapture(_.pointerId)):(Math.abs(G)>j||Math.abs(H)>j)&&(C.current=null)}),onPointerUp:ae(e.onPointerUp,_=>{const G=k.current,H=_.target;if(H.hasPointerCapture(_.pointerId)&&H.releasePointerCapture(_.pointerId),k.current=null,C.current=null,G){const z=_.currentTarget,D={originalEvent:_,delta:G};Hg(G,g.swipeDirection,g.swipeThreshold)?mi(hI,f,D,{discrete:!0}):mi(fI,m,D,{discrete:!0}),z.addEventListener("click",I=>I.preventDefault(),{once:!0})}})})})}),g.viewport)})]}):null}),xI=e=>{const{__scopeToast:t,children:n,...r}=e,o=pi(Ro,t),[s,i]=p.useState(!1),[a,l]=p.useState(!1);return bI(()=>i(!0)),p.useEffect(()=>{const c=window.setTimeout(()=>l(!0),1e3);return()=>window.clearTimeout(c)},[]),a?null:u.jsx(io,{asChild:!0,children:u.jsx(si,{...r,children:s&&u.jsxs(u.Fragment,{children:[o.label," ",n]})})})},vI="ToastTitle",Og=p.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(me.div,{...r,ref:t})});Og.displayName=vI;var wI="ToastDescription",Dg=p.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(me.div,{...r,ref:t})});Dg.displayName=wI;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=mI(Fg,n);return u.jsx(Bg,{asChild:!0,children:u.jsx(me.button,{type:"button",...r,ref:t,onClick:ae(e.onClick,o.onClose)})})});Gl.displayName=Fg;var Bg=p.forwardRef((e,t)=>{const{__scopeToast:n,altText:r,...o}=e;return u.jsx(me.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),yI(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 mi(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?zi(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 bI(e=()=>{}){const t=pt(e);kt(()=>{let n=0,r=0;return n=window.requestAnimationFrame(()=>r=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(n),window.cancelAnimationFrame(r)}},[t])}function yI(e){return e.nodeType===e.ELEMENT_NODE}function SI(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 CI=jg,Ug=_g,Wg=Mg,Vg=Og,Kg=Dg,qg=$g,Gg=Gl;const TI=CI,Yg=p.forwardRef(({className:e,...t},n)=>u.jsx(Ug,{ref:n,className:te("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 kI=Hr.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:te(kI({variant:t}),e),...n}));Xg.displayName=Wg.displayName;const EI=p.forwardRef(({className:e,...t},n)=>u.jsx(qg,{ref:n,className:te("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}));EI.displayName=qg.displayName;const Jg=p.forwardRef(({className:e,...t},n)=>u.jsx(Gg,{ref:n,className:te("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(le.X,{className:"h-4 w-4"})}));Jg.displayName=Gg.displayName;const Zg=p.forwardRef(({className:e,...t},n)=>u.jsx(Vg,{ref:n,className:te("text-sm font-semibold",e),...t}));Zg.displayName=Vg.displayName;const Qg=p.forwardRef(({className:e,...t},n)=>u.jsx(Kg,{ref:n,className:te("text-sm opacity-90",e),...t}));Qg.displayName=Kg.displayName;function II(){const{toasts:e}=ol();return u.jsxs(TI,{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 NI=(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{}},AI=p.createContext(void 0),jI={setTheme:e=>{},themes:[]},PI=()=>{var e;return(e=p.useContext(AI))!=null?e:jI};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:`(${NI.toString()})(${d})`}})});var _I=e=>{switch(e){case"success":return OI;case"info":return LI;case"warning":return DI;case"error":return $I;default:return null}},RI=Array(12).fill(0),MI=({visible:e,className:t})=>w.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},w.createElement("div",{className:"sonner-spinner"},RI.map((n,r)=>w.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),OI=w.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},w.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"})),DI=w.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},w.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"})),LI=w.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},w.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"})),$I=w.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},w.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"})),FI=w.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"},w.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),w.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),BI=()=>{let[e,t]=w.useState(document.hidden);return w.useEffect(()=>{let n=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),e},Xl=1,zI=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],w.isValidElement(l))o=!1,this.create({id:n,type:"default",message:l});else if(UI(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}},Ut=new zI,HI=(e,t)=>{let n=(t==null?void 0:t.id)||Xl++;return Ut.addToast({title:e,...t,id:n}),n},UI=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",WI=HI,VI=()=>Ut.toasts,KI=()=>Ut.getActiveToasts();Object.assign(WI,{success:Ut.success,info:Ut.info,warning:Ut.warning,error:Ut.error,custom:Ut.custom,message:Ut.message,promise:Ut.promise,dismiss:Ut.dismiss,loading:Ut.loading},{getHistory:VI,getToasts:KI});function qI(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))}qI(`: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 gi(e){return e.label!==void 0}var GI=3,YI="32px",XI="16px",ex=4e3,JI=356,ZI=14,QI=20,e1=200;function pn(...e){return e.filter(Boolean).join(" ")}function t1(e){let[t,n]=e.split("-"),r=[];return t&&r.push(t),n&&r.push(n),r}var n1=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:b,index:C,toasts:k,expanded:S,removeToast:T,defaultRichColors:E,closeButton:A,style:R,cancelButtonStyle:$,actionButtonStyle:F,className:V="",descriptionClassName:X="",duration:_,position:G,gap:H,loadingIcon:z,expandByDefault:D,classNames:I,icons:Y,closeButtonAriaLabel:J="Close toast",pauseWhenPageIsHidden:j}=e,[B,P]=w.useState(null),[O,K]=w.useState(null),[M,L]=w.useState(!1),[q,Z]=w.useState(!1),[se,ie]=w.useState(!1),[re,de]=w.useState(!1),[be,Me]=w.useState(!1),[Fe,De]=w.useState(0),[Le,it]=w.useState(0),dt=w.useRef(f.duration||_||ex),Et=w.useRef(null),Ke=w.useRef(null),We=C===0,Xe=C+1<=y,ke=f.type,Ue=f.dismissible!==!1,ut=f.className||"",bt=f.descriptionClassName||"",Je=w.useMemo(()=>b.findIndex(ce=>ce.toastId===f.id)||0,[b,f.id]),Ct=w.useMemo(()=>{var ce;return(ce=f.closeButton)!=null?ce:A},[f.closeButton,A]),gt=w.useMemo(()=>f.duration||_||ex,[f.duration,_]),xt=w.useRef(0),It=w.useRef(0),rn=w.useRef(0),Nt=w.useRef(null),[mn,Zt]=G.split("-"),Be=w.useMemo(()=>b.reduce((ce,Ce,qe)=>qe>=Je?ce:ce+Ce.height,0),[b,Je]),$e=BI(),Tt=f.invert||m,ne=ke==="loading";It.current=w.useMemo(()=>Je*H+Be,[Je,Be]),w.useEffect(()=>{dt.current=gt},[gt]),w.useEffect(()=>{L(!0)},[]),w.useEffect(()=>{let ce=Ke.current;if(ce){let Ce=ce.getBoundingClientRect().height;return it(Ce),x(qe=>[{toastId:f.id,height:Ce,position:f.position},...qe]),()=>x(qe=>qe.filter(Ne=>Ne.toastId!==f.id))}},[x,f.id]),w.useLayoutEffect(()=>{if(!M)return;let ce=Ke.current,Ce=ce.style.height;ce.style.height="auto";let qe=ce.getBoundingClientRect().height;ce.style.height=Ce,it(qe),x(Ne=>Ne.find(je=>je.toastId===f.id)?Ne.map(je=>je.toastId===f.id?{...je,height:qe}:je):[{toastId:f.id,height:qe,position:f.position},...Ne])},[M,f.title,f.description,x,f.id]);let xe=w.useCallback(()=>{Z(!0),De(It.current),x(ce=>ce.filter(Ce=>Ce.toastId!==f.id)),setTimeout(()=>{T(f)},e1)},[f,T,x,It]);w.useEffect(()=>{if(f.promise&&ke==="loading"||f.duration===1/0||f.type==="loading")return;let ce;return S||g||j&&$e?(()=>{if(rn.current<xt.current){let Ce=new Date().getTime()-xt.current;dt.current=dt.current-Ce}rn.current=new Date().getTime()})():dt.current!==1/0&&(xt.current=new Date().getTime(),ce=setTimeout(()=>{var Ce;(Ce=f.onAutoClose)==null||Ce.call(f,f),xe()},dt.current)),()=>clearTimeout(ce)},[S,g,f,ke,j,$e,xe]),w.useEffect(()=>{f.delete&&xe()},[xe,f.delete]);function pe(){var ce,Ce,qe;return Y!=null&&Y.loading?w.createElement("div",{className:pn(I==null?void 0:I.loader,(ce=f==null?void 0:f.classNames)==null?void 0:ce.loader,"sonner-loader"),"data-visible":ke==="loading"},Y.loading):z?w.createElement("div",{className:pn(I==null?void 0:I.loader,(Ce=f==null?void 0:f.classNames)==null?void 0:Ce.loader,"sonner-loader"),"data-visible":ke==="loading"},z):w.createElement(MI,{className:pn(I==null?void 0:I.loader,(qe=f==null?void 0:f.classNames)==null?void 0:qe.loader),visible:ke==="loading"})}return w.createElement("li",{tabIndex:0,ref:Ke,className:pn(V,ut,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[ke],(n=f==null?void 0:f.classNames)==null?void 0:n[ke]),"data-sonner-toast":"","data-rich-colors":(r=f.richColors)!=null?r:E,"data-styled":!(f.jsx||f.unstyled||v),"data-mounted":M,"data-promise":!!f.promise,"data-swiped":be,"data-removed":q,"data-visible":Xe,"data-y-position":mn,"data-x-position":Zt,"data-index":C,"data-front":We,"data-swiping":se,"data-dismissible":Ue,"data-type":ke,"data-invert":Tt,"data-swipe-out":re,"data-swipe-direction":O,"data-expanded":!!(S||D&&M),style:{"--index":C,"--toasts-before":C,"--z-index":k.length-C,"--offset":`${q?Fe:It.current}px`,"--initial-height":D?"auto":`${Le}px`,...R,...f.style},onDragEnd:()=>{ie(!1),P(null),Nt.current=null},onPointerDown:ce=>{ne||!Ue||(Et.current=new Date,De(It.current),ce.target.setPointerCapture(ce.pointerId),ce.target.tagName!=="BUTTON"&&(ie(!0),Nt.current={x:ce.clientX,y:ce.clientY}))},onPointerUp:()=>{var ce,Ce,qe,Ne;if(re||!Ue)return;Nt.current=null;let je=Number(((ce=Ke.current)==null?void 0:ce.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),Oe=Number(((Ce=Ke.current)==null?void 0:Ce.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),tt=new Date().getTime()-((qe=Et.current)==null?void 0:qe.getTime()),ye=B==="x"?je:Oe,Ye=Math.abs(ye)/tt;if(Math.abs(ye)>=QI||Ye>.11){De(It.current),(Ne=f.onDismiss)==null||Ne.call(f,f),K(B==="x"?je>0?"right":"left":Oe>0?"down":"up"),xe(),de(!0),Me(!1);return}ie(!1),P(null)},onPointerMove:ce=>{var Ce,qe,Ne,je;if(!Nt.current||!Ue||((Ce=window.getSelection())==null?void 0:Ce.toString().length)>0)return;let Oe=ce.clientY-Nt.current.y,tt=ce.clientX-Nt.current.x,ye=(qe=e.swipeDirections)!=null?qe:t1(G);!B&&(Math.abs(tt)>1||Math.abs(Oe)>1)&&P(Math.abs(tt)>Math.abs(Oe)?"x":"y");let Ye={x:0,y:0};B==="y"?(ye.includes("top")||ye.includes("bottom"))&&(ye.includes("top")&&Oe<0||ye.includes("bottom")&&Oe>0)&&(Ye.y=Oe):B==="x"&&(ye.includes("left")||ye.includes("right"))&&(ye.includes("left")&&tt<0||ye.includes("right")&&tt>0)&&(Ye.x=tt),(Math.abs(Ye.x)>0||Math.abs(Ye.y)>0)&&Me(!0),(Ne=Ke.current)==null||Ne.style.setProperty("--swipe-amount-x",`${Ye.x}px`),(je=Ke.current)==null||je.style.setProperty("--swipe-amount-y",`${Ye.y}px`)}},Ct&&!f.jsx?w.createElement("button",{"aria-label":J,"data-disabled":ne,"data-close-button":!0,onClick:ne||!Ue?()=>{}:()=>{var ce;xe(),(ce=f.onDismiss)==null||ce.call(f,f)},className:pn(I==null?void 0:I.closeButton,(o=f==null?void 0:f.classNames)==null?void 0:o.closeButton)},(s=Y==null?void 0:Y.close)!=null?s:FI):null,f.jsx||w.isValidElement(f.title)?f.jsx?f.jsx:typeof f.title=="function"?f.title():f.title:w.createElement(w.Fragment,null,ke||f.icon||f.promise?w.createElement("div",{"data-icon":"",className:pn(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||pe():null,f.type!=="loading"?f.icon||(Y==null?void 0:Y[ke])||_I(ke):null):null,w.createElement("div",{"data-content":"",className:pn(I==null?void 0:I.content,(a=f==null?void 0:f.classNames)==null?void 0:a.content)},w.createElement("div",{"data-title":"",className:pn(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?w.createElement("div",{"data-description":"",className:pn(X,bt,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),w.isValidElement(f.cancel)?f.cancel:f.cancel&&gi(f.cancel)?w.createElement("button",{"data-button":!0,"data-cancel":!0,style:f.cancelButtonStyle||$,onClick:ce=>{var Ce,qe;gi(f.cancel)&&Ue&&((qe=(Ce=f.cancel).onClick)==null||qe.call(Ce,ce),xe())},className:pn(I==null?void 0:I.cancelButton,(d=f==null?void 0:f.classNames)==null?void 0:d.cancelButton)},f.cancel.label):null,w.isValidElement(f.action)?f.action:f.action&&gi(f.action)?w.createElement("button",{"data-button":!0,"data-action":!0,style:f.actionButtonStyle||F,onClick:ce=>{var Ce,qe;gi(f.action)&&((qe=(Ce=f.action).onClick)==null||qe.call(Ce,ce),!ce.defaultPrevented&&xe())},className:pn(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 r1(e,t){let n={};return[e,t].forEach((r,o)=>{let s=o===1,i=s?"--mobile-offset":"--offset",a=s?XI:YI;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 o1=w.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=GI,toastOptions:g,dir:x=tx(),gap:y=ZI,loadingIcon:b,icons:C,containerAriaLabel:k="Notifications",pauseWhenPageIsHidden:S}=e,[T,E]=w.useState([]),A=w.useMemo(()=>Array.from(new Set([r].concat(T.filter(j=>j.position).map(j=>j.position)))),[T,r]),[R,$]=w.useState([]),[F,V]=w.useState(!1),[X,_]=w.useState(!1),[G,H]=w.useState(d!=="system"?d:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),z=w.useRef(null),D=o.join("+").replace(/Key/g,"").replace(/Digit/g,""),I=w.useRef(null),Y=w.useRef(!1),J=w.useCallback(j=>{E(B=>{var P;return(P=B.find(O=>O.id===j.id))!=null&&P.delete||Ut.dismiss(j.id),B.filter(({id:O})=>O!==j.id)})},[]);return w.useEffect(()=>Ut.subscribe(j=>{if(j.dismiss){E(B=>B.map(P=>P.id===j.id?{...P,delete:!0}:P));return}setTimeout(()=>{Mo.flushSync(()=>{E(B=>{let P=B.findIndex(O=>O.id===j.id);return P!==-1?[...B.slice(0,P),{...B[P],...j},...B.slice(P+1)]:[j,...B]})})})}),[]),w.useEffect(()=>{if(d!=="system"){H(d);return}if(d==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?H("dark"):H("light")),typeof window>"u")return;let j=window.matchMedia("(prefers-color-scheme: dark)");try{j.addEventListener("change",({matches:B})=>{H(B?"dark":"light")})}catch{j.addListener(({matches:P})=>{try{H(P?"dark":"light")}catch(O){console.error(O)}})}},[d]),w.useEffect(()=>{T.length<=1&&V(!1)},[T]),w.useEffect(()=>{let j=B=>{var P,O;o.every(K=>B[K]||B.code===K)&&(V(!0),(P=z.current)==null||P.focus()),B.code==="Escape"&&(document.activeElement===z.current||(O=z.current)!=null&&O.contains(document.activeElement))&&V(!1)};return document.addEventListener("keydown",j),()=>document.removeEventListener("keydown",j)},[o]),w.useEffect(()=>{if(z.current)return()=>{I.current&&(I.current.focus({preventScroll:!0}),I.current=null,Y.current=!1)}},[z.current]),w.createElement("section",{ref:t,"aria-label":`${k} ${D}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},A.map((j,B)=>{var P;let[O,K]=j.split("-");return T.length?w.createElement("ol",{key:j,dir:x==="auto"?tx():x,tabIndex:-1,ref:z,className:a,"data-sonner-toaster":!0,"data-theme":G,"data-y-position":O,"data-lifted":F&&T.length>1&&!s,"data-x-position":K,style:{"--front-toast-height":`${((P=R[0])==null?void 0:P.height)||0}px`,"--width":`${JI}px`,"--gap":`${y}px`,...f,...r1(l,c)},onBlur:M=>{Y.current&&!M.currentTarget.contains(M.relatedTarget)&&(Y.current=!1,I.current&&(I.current.focus({preventScroll:!0}),I.current=null))},onFocus:M=>{M.target instanceof HTMLElement&&M.target.dataset.dismissible==="false"||Y.current||(Y.current=!0,I.current=M.relatedTarget)},onMouseEnter:()=>V(!0),onMouseMove:()=>V(!0),onMouseLeave:()=>{X||V(!1)},onDragEnd:()=>V(!1),onPointerDown:M=>{M.target instanceof HTMLElement&&M.target.dataset.dismissible==="false"||_(!0)},onPointerUp:()=>_(!1)},T.filter(M=>!M.position&&B===0||M.position===j).map((M,L)=>{var q,Z;return w.createElement(n1,{key:M.id,icons:C,index:L,toast:M,defaultRichColors:h,duration:(q=g==null?void 0:g.duration)!=null?q:m,className:g==null?void 0:g.className,descriptionClassName:g==null?void 0:g.descriptionClassName,invert:n,visibleToasts:v,closeButton:(Z=g==null?void 0:g.closeButton)!=null?Z:i,interacting:X,position:j,style:g==null?void 0:g.style,unstyled:g==null?void 0:g.unstyled,classNames:g==null?void 0:g.classNames,cancelButtonStyle:g==null?void 0:g.cancelButtonStyle,actionButtonStyle:g==null?void 0:g.actionButtonStyle,removeToast:J,toasts:T.filter(se=>se.position==M.position),heights:R.filter(se=>se.position==M.position),setHeights:$,expandByDefault:s,gap:y,loadingIcon:b,expanded:F,pauseWhenPageIsHidden:S,swipeDirections:e.swipeDirections})})):null}))});const s1=({...e})=>{const{theme:t="system"}=PI();return u.jsx(o1,{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=ru,U.ArtifactRenderer=Tp,U.Badge=Op,U.Button=et,U.Card=al,U.CardContent=dl,U.CardDescription=ul,U.CardHeader=ll,U.CardTitle=cl,U.ChatApi=Go,U.ChatApp=Fk,U.ChatInput=Wf,U.ChatInputRow=Vf,U.ChatInterface=Or,U.ChatProviders=br,U.ChatWidget=Hk,U.Command=yl,U.CommandEmpty=Tl,U.CommandGroup=kl,U.CommandInput=Sl,U.CommandItem=El,U.CommandList=Cl,U.DEFAULT_TIMEOUT_MS=Jc,U.Dialog=tl,U.DialogContent=Hs,U.DialogHeader=Us,U.DialogTitle=Ws,U.DropdownMenu=Ts,U.DropdownMenuContent=po,U.DropdownMenuItem=Fn,U.DropdownMenuTrigger=ks,U.FileViewerModal=cp,U.HISTORY_TIMEOUT_MS=Zc,U.Input=Rl,U.InterruptPartRenderer=Ip,U.Label=mm,U.MarkdownContent=cr,U.MessageComponent=Zs,U.MessageList=pl,U.MessageRow=hl,U.NewChatButton=Uk,U.PlotArtifact=Cp,U.SETTINGS_STORAGE_KEY=Bi,U.ScrollArea=_l,U.Select=SE,U.SelectContent=ng,U.SelectItem=rg,U.SelectTrigger=Qm,U.SelectValue=CE,U.Separator=ag,U.Sheet=ME,U.SheetContent=gg,U.SheetDescription=wg,U.SheetHeader=xg,U.SheetTitle=vg,U.SheetTrigger=OE,U.SimpleChat=Bk,U.SimpleJsonView=Js,U.Sonner=s1,U.StreamProgress=kp,U.Switch=pg,U.Textarea=Ea,U.ThinkingIndicator=Np,U.ThreadListItem=cm,U.ThreadManager=oi,U.ThreadStateProvider=Eu,U.ThreadsProvider=pu,U.TimelineColumn=vx,U.Toaster=II,U.ToolComponent=Rp,U.Tooltip=oI,U.TooltipContent=Ng,U.TooltipProvider=rI,U.TooltipTrigger=sI,U.UserTextContent=Ap,U.applySettings=Cw,U.buildCheckpointIndex=ec,U.buildCheckpointPreviewMap=ax,U.chatApiClient=Nn,U.del=_i,U.downloadFileById=eu,U.extractConfigFields=vi,U.fileToBase64=ou,U.get=qt,U.getChatToken=Yc,U.getCheckpointForMessage=lx,U.getCurrentSettings=Sw,U.getDefaultApiConfig=Ou,U.getDefaultChatSettings=Du,U.getFileContent=Mi,U.getFileInfo=Wv,U.getMessageAttemptInfo=tc,U.getMessageDomKey=fl,U.getPreviewForMessage=xi,U.httpClient=Kt,U.hydrateHistorySnapshots=Yn,U.isEnvelope=iu,U.listFiles=tu,U.loadStoredSettings=Lu,U.onChatTokenChanged=Xc,U.post=qo,U.processAttachments=su,U.put=Qc,U.readNumber=rc,U.readString=Rn,U.resolveChatBaseUrl=xn,U.saveSettings=$u,U.setChatToken=Ko,U.toPlainObject=_n,U.unwrap=Mt,U.useApi=Jr,U.useCheckpointIndex=nc,U.useFilePreview=jp,U.useHasChatSession=ww,U.useParsedMessageContent=Pp,U.useShallowStableValue=Pu,U.useStream=Fi,U.useStreamingHook=Fi,U.useThreadHistoryState=Su,U.useThreadManagerViewState=fm,U.useThreadState=to,U.useThreadStateUpdater=ku,U.useThreads=xr,U.useThreadsState=fu,U.viewFileById=Uv,Object.defineProperty(U,Symbol.toStringTag,{value:"Module"})});
127
+ `+(f.tokens?this.parseInline(f.tokens):f.text);r+=n?this.renderer.paragraph(m):m;continue}default:{const j='Token with "'+f.type+'" type was not found.';if(this.options.silent){console.error(j);return}else throw new Error(j)}}}return r}parseInline(t,n){n=n||this.renderer;let r="",o,s,i;const a=t.length;for(o=0;o<a;o++){if(s=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[s.type]&&(i=this.options.extensions.renderers[s.type].call({parser:this},s),i!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type))){r+=i||"";continue}switch(s.type){case"escape":{r+=n.text(s.text);break}case"html":{r+=n.html(s.text);break}case"link":{r+=n.link(s.href,s.title,this.parseInline(s.tokens,n));break}case"image":{r+=n.image(s.href,s.title,s.text);break}case"strong":{r+=n.strong(this.parseInline(s.tokens,n));break}case"em":{r+=n.em(this.parseInline(s.tokens,n));break}case"codespan":{r+=n.codespan(s.text);break}case"br":{r+=n.br();break}case"del":{r+=n.del(this.parseInline(s.tokens,n));break}case"text":{r+=n.text(s.text);break}default:{const l='Token with "'+s.type+'" type was not found.';if(this.options.silent){console.error(l);return}else throw new Error(l)}}}return r}}class Xs{constructor(t){this.options=t||lr}preprocess(t){return t}postprocess(t){return t}}nx(Xs,"passThroughHooks",new Set(["preprocess","postprocess"]));function DT(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>"+_t(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 Sp(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...ve.defaults,...s};const i=DT(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(RT(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&&ve.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;ve.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(ve.walkTokens(a,r.walkTokens)).then(()=>a):a).then(a=>t(a,r)).then(a=>r.hooks?r.hooks.postprocess(a):a).catch(i);try{r.hooks&&(n=r.hooks.preprocess(n));const a=e(n,r);r.walkTokens&&ve.walkTokens(a,r.walkTokens);let l=t(a,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(a){return i(a)}}}function ve(e,t,n){return Sp(Wn.lex,Vn.parse)(e,t,n)}ve.options=ve.setOptions=function(e){return ve.defaults={...ve.defaults,...e},bT(ve.defaults),ve},ve.getDefaults=up,ve.defaults=lr,ve.use=function(...e){const t=ve.defaults.extensions||{renderers:{},childTokens:{}};e.forEach(n=>{const r={...n};if(r.async=ve.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(o=>{if(!o.name)throw new Error("extension name required");if(o.renderer){const s=t.renderers[o.name];s?t.renderers[o.name]=function(...i){let a=o.renderer.apply(this,i);return a===!1&&(a=s.apply(this,i)),a}:t.renderers[o.name]=o.renderer}if(o.tokenizer){if(!o.level||o.level!=="block"&&o.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");t[o.level]?t[o.level].unshift(o.tokenizer):t[o.level]=[o.tokenizer],o.start&&(o.level==="block"?t.startBlock?t.startBlock.push(o.start):t.startBlock=[o.start]:o.level==="inline"&&(t.startInline?t.startInline.push(o.start):t.startInline=[o.start]))}o.childTokens&&(t.childTokens[o.name]=o.childTokens)}),r.extensions=t),n.renderer){const o=ve.defaults.renderer||new il;for(const s in n.renderer){const i=o[s];o[s]=(...a)=>{let l=n.renderer[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.renderer=o}if(n.tokenizer){const o=ve.defaults.tokenizer||new sl;for(const s in n.tokenizer){const i=o[s];o[s]=(...a)=>{let l=n.tokenizer[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.tokenizer=o}if(n.hooks){const o=ve.defaults.hooks||new Xs;for(const s in n.hooks){const i=o[s];Xs.passThroughHooks.has(s)?o[s]=a=>{if(ve.defaults.async)return Promise.resolve(n.hooks[s].call(o,a)).then(c=>i.call(o,c));const l=n.hooks[s].call(o,a);return i.call(o,l)}:o[s]=(...a)=>{let l=n.hooks[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.hooks=o}if(n.walkTokens){const o=ve.defaults.walkTokens;r.walkTokens=function(s){let i=[];return i.push(n.walkTokens.call(this,s)),o&&(i=i.concat(o.call(this,s))),i}}ve.setOptions(r)})},ve.walkTokens=function(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(ve,r)),r.type){case"table":{for(const o of r.header)n=n.concat(ve.walkTokens(o.tokens,t));for(const o of r.rows)for(const s of o)n=n.concat(ve.walkTokens(s.tokens,t));break}case"list":{n=n.concat(ve.walkTokens(r.items,t));break}default:ve.defaults.extensions&&ve.defaults.extensions.childTokens&&ve.defaults.extensions.childTokens[r.type]?ve.defaults.extensions.childTokens[r.type].forEach(function(o){n=n.concat(ve.walkTokens(r[o],t))}):r.tokens&&(n=n.concat(ve.walkTokens(r.tokens,t)))}return n},ve.parseInline=Sp(Wn.lexInline,Vn.parseInline),ve.Parser=Vn,ve.parser=Vn.parse,ve.Renderer=il,ve.TextRenderer=bp,ve.Lexer=Wn,ve.lexer=Wn.lex,ve.Tokenizer=sl,ve.Slugger=yp,ve.Hooks=Xs,ve.parse=ve,ve.options,ve.setOptions,ve.use,ve.walkTokens,ve.parseInline,Vn.parse,Wn.lex;function cr({content:e,className:t="",allowHtml:n=!1,style:r}){const o=w.useMemo(()=>{if(!e||typeof e!="string"||e.trim().length===0)return"";try{if(!n){const i=e.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"").replace(/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi,"").replace(/javascript:/gi,"").replace(/on\w+\s*=/gi,"");return typeof ve.parse=="function"?ve.parse(i):ve(i)}return typeof ve.parse=="function"?ve.parse(e):ve(e)}catch(i){return console.error("[MarkdownContent] parse error",i),`<pre class="font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words">Error rendering markdown: ${String(i)}</pre>`}},[e,n]),s=w.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:te("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 Cp({preview:e,idx:t}){return u.jsxs("div",{className:"space-y-2",children:[e.label&&u.jsxs("p",{className:"text-[0.65rem] uppercase tracking-wide text-muted-foreground",children:["Artifact: ",e.label]}),u.jsx("div",{className:"overflow-hidden rounded border border-border/60 bg-background/60 p-1 shadow-sm",children:u.jsx("img",{src:e.src,alt:e.alt,title:e.label,loading:"lazy",className:"h-auto max-h-[420px] w-full rounded object-contain",onLoad:()=>{},onError:n=>{console.error(`[MessageComponent] ❌ Image failed to load for artifact ${t}:`,{alt:e.alt,label:e.label,message:n.target.alt})}})})]})}function Tp({artifact:e,idx:t=0}){const n=w.useMemo(()=>e?(Array.isArray(e.plots)?e.plots:[]).map(o=>iw(o)).filter(o=>o!==null):[],[e]);return n.length>0?u.jsx("div",{className:"space-y-2",children:n.map((r,o)=>u.jsx(Cp,{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 LT="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 Js({data:e}){return Array.isArray(e)?e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?u.jsx("div",{className:LT,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 kp({message:e,isStreaming:t=!1}){const n=e.name??"tool",r=w.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(ce.Loader,{className:"h-3 w-3 animate-spin"}),u.jsx("span",{children:s??`Running ${n}…`})]}),r.length>0&&u.jsx("div",{className:"space-y-2 text-xs text-muted-foreground",children:r.map((a,l)=>{var c;return u.jsxs("div",{className:"rounded border border-current/10 bg-muted/60 p-2 text-[11px] leading-snug",children:[u.jsxs("div",{className:"mb-1 flex items-center justify-between text-[8px] uppercase tracking-wide text-muted-foreground",children:[u.jsx("span",{children:((c=a.type)==null?void 0:c.replace(/\./g," "))??"progress"}),u.jsx("span",{children:a.idx??l+1})]}),a.content&&u.jsx("p",{className:"mt-1 text-[12px] text-foreground/90",children:a.content}),u.jsxs("div",{className:"mt-1 flex flex-wrap gap-2 text-[10px] opacity-70",children:[typeof a.factsFound=="number"&&u.jsxs("span",{children:["Facts found: ",a.factsFound]}),typeof a.isSufficient=="boolean"&&u.jsxs("span",{children:["Research ",a.isSufficient?"sufficient":"needs more data"]})]})]},`tool-progress-${n}-${l}`)})})]}):null}const al=p.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:te("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));al.displayName="Card";const ll=p.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:te("flex flex-col space-y-1.5 p-6",e),...t}));ll.displayName="CardHeader";const cl=p.forwardRef(({className:e,...t},n)=>u.jsx("h3",{ref:n,className:te("text-2xl font-semibold leading-none tracking-tight",e),...t}));cl.displayName="CardTitle";const ul=p.forwardRef(({className:e,...t},n)=>u.jsx("p",{ref:n,className:te("text-sm text-muted-foreground",e),...t}));ul.displayName="CardDescription";const dl=p.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:te("p-6 pt-0",e),...t}));dl.displayName="CardContent";const Ep=p.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:te("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(al,{className:te("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(ll,{className:"pb-3",children:[u.jsx(cl,{className:"text-blue-900 dark:text-blue-100 text-base",children:i}),u.jsx(ul,{className:"text-blue-700 dark:text-blue-300 text-sm",children:l})]}),a&&u.jsx(dl,{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(Qe,{size:"sm",variant:"outline",onClick:()=>n(e),className:"border-red-300 text-red-700 hover:bg-red-50 dark:border-red-700 dark:text-red-300 dark:hover:bg-red-950/50",disabled:r||!o,children:"Reject"}),u.jsx(Qe,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",disabled:r||!o,children:"Approve"})]})})]})}function Np({className:e}){const t=w.useRef(null);return w.useEffect(()=>{let n=0;const r=()=>{if(n=(n+1)%4,t.current){const s=".".repeat(n);t.current.textContent=`Is thinking${s}`}};r();const o=setInterval(r,500);return()=>clearInterval(o)},[]),u.jsx("span",{ref:t,"aria-live":"polite",className:te("inline-block text-xs opacity-70 ml-1",e),children:"Is thinking"})}function Ap({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:te("text-sm text-[hsl(var(--chat-bubble-user-text))]",o&&"text-xs"),children:t?u.jsx(cr,{content:e,allowHtml:!1}):u.jsxs("pre",{className:te("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(Qe,{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(ce.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):u.jsxs(u.Fragment,{children:[u.jsx(ce.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",s," chars)"]})})]})}function jp(e){const{allowFileOpen:t,currentThreadId:n}=e,{toast:r}=ol(),[o,s]=w.useState({}),[i,a]=w.useState(null),[l,c]=w.useState(!1),d=w.useCallback(()=>{c(!1),a(null)},[]),h=w.useCallback(f=>{a(f),c(!0)},[]),m=w.useCallback(async(f,v,g)=>{var x,y;if(!t){f.preventDefault();return}if(o[g]){f.preventDefault();return}try{const b=String(v.url??""),C=b.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);if(C){f.preventDefault();const k=C[1],S=v.name||`file_${k}`,T=v.mimeType||"application/octet-stream";h({id:k,name:S,mimeType:T});return}if(b.startsWith("data:")){f.preventDefault(),s(S=>({...S,[g]:!0}));const k=r({title:"Fetching file...",description:"",open:!0});try{const S=await tu(n??void 0);if(!S||!Array.isArray(S))throw new Error("Invalid file list response");const T=S.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(S){console.error("Failed to fetch server file:",S);const T=S instanceof Error?S.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(S=>({...S,[g]:!1}))}}}catch(b){console.error("File click error:",b),s(C=>({...C,[g]:!1}))}},[t,o,r,n,h]);return{uploadingFiles:o,handleFileClick:m,fileViewerOpen:l,currentFileInfo:i,closeFileViewer:d}}function Pp(e,t){return w.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:ew(r),toolMeta:Di(n),imageParts:r.filter(s=>s.type==="image_url"),fileParts:r.filter(s=>s.type==="file"),interruptParts:r.filter(s=>s.type==="interrupt"),toolRaw:tw(r),isToolStreaming:!!o.toolStreaming}},[e,t])}const _p="data:";function $T(e){if(!e)return[];const t=[],n=e.split(/\r?\n/);for(const r of n){const o=r.trim();if(!o||!o.startsWith(_p))continue;const s=o.slice(_p.length).trim();if(!s||s.toLowerCase()==="[done]")continue;const i=Qr(s);i&&typeof i=="object"&&t.push(i)}return t}function FT(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 BT(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 zT(e){return w.useMemo(()=>{const t=e.content.filter(c=>c.type==="text");if(!t.length)return null;let r=t.flatMap(c=>$T(c.text??""));if(!r.length){const c=t.map(h=>h.text??"").join(`
129
+ `),d=Qr(c);d&&typeof d=="object"&&(r=[d])}if(!r.length)return null;const s=BT(r)??r[r.length-1];if(!s)return null;const i=s.output??s.payload??s,a=wr(i),l=FT(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 Rp({message:e,viewMode:t,isStreaming:n=!1,toolRenderers:r,toolArtifactRenderers:o}){var C;const s=Di(e),i=e.artifact??null,a=zT(e),l=e.content.find(k=>k.type!=="tool_call"),c=k=>{if(k==null)return null;const S=typeof k=="string"?Qr(k)??k:k;if(S&&typeof S=="object")return u.jsx(Js,{data:S});const T=typeof S=="string"?S:(()=>{try{return vr(S)}catch{return String(S??"")}})();return u.jsx("pre",{className:"whitespace-pre-wrap break-words font-sans text-sm text-foreground/90",children:T})},d=k=>{if(k==null)return null;const{content:S,isMarkdown:T}=Qv(k);return T?u.jsx(cr,{content:S,className:"text-current"}):c(k)},h=k=>u.jsxs("div",{className:"space-y-2 rounded-2xl border border-muted-foreground/30 bg-white/80 p-4 shadow-sm shadow-slate-900/10",children:[u.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-[0.4em] text-muted-foreground",children:"Structured dictionary"}),u.jsx(Js,{data:k})]}),m=()=>{if((a==null?void 0:a.kind)==="generic")return d(a.value);if(!l)return null;if(l.type==="text"){const E=(l.text??"").trim();if(!E)return null;const j=wr(E);return d(j)}const k=eo(l),S=wr(k);return d(S)},f=()=>(a==null?void 0:a.kind)==="dict"?h(a.data):m(),g=(()=>{if(r){if(s.name){const k=r[s.name];if(k)return k}if(a!=null&&a.kind){const k=r[a.kind];if(k)return k}return r.default}})(),x=(g==null?void 0:g({message:e,toolMeta:s,toolPayload:a,viewMode:t,isStreaming:n}))??null,b=((C=(()=>{if(!o)return;const k=i==null?void 0:i.type;if(typeof k=="string"){const S=o[k];if(S)return S}return o.default})())==null?void 0:C({artifact:i,message:e,toolPayload:a,isStreaming:n}))??null;return u.jsxs("div",{className:"space-y-2",children:[i&&(b??u.jsx(Tp,{artifact:i,idx:0})),u.jsx(kp,{message:e,isStreaming:n}),t==="expanded"&&u.jsx(u.Fragment,{children:x??f()})]})}const HT={checkpoints:[],checkpointMetaByCheckpointId:new Map,timeline:[],messagePreviews:new Map,getLatest:()=>{},getCheckpoint:()=>{},getMessageAttempts:()=>[]},fl=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,hl=w.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:b,getMessageCustomStyles:C,toolRenderers:k,toolArtifactRenderers:S}){const T=fl(t,n),E=t.role==="default_message",_=!!t.__syntheticStreaming,$=y??HT,F=!E&&"checkpointId"in t?t.checkpointId??null:null,{attemptCount:U,attemptIndex:X,attempts:R}=w.useMemo(()=>tc(t.id,F,$),[t.id,F,$]),K=C==null?void 0:C(t);return u.jsx("div",{className:"relative mb-4 last:mb-0","data-message-id":T,style:{minHeight:"60px",containIntrinsicSize:"auto 120px"},children:u.jsx(Zs,{message:t,messageIndex:n,isStreamingMessage:_||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:U,attemptIndex:X,attemptMetas:R,onSelectCheckpoint:b,customStyles:K,toolRenderers:k,toolArtifactRenderers:S})})});hl.displayName="MessageRow";function UT(e,t,n){const[r,o]=w.useState(e),s=w.useRef([]);return w.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 WT({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:b,messageRole:C,truncateUserMessages:k,userMessagePreviewLength:S,isUserExpanded:T,setIsUserExpanded:E,isCompactLayout:j,activeInterruptId:_,activeInterruptValue:$,iconForeground:F,toolRenderers:U,toolArtifactRenderers:X}){const R=w.useCallback(()=>u.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/30 rounded",children:[u.jsx(ce.Loader,{className:"h-4 w-4 text-muted-foreground"}),u.jsx("span",{className:"text-sm text-muted-foreground",children:"File upload"})]}),[]),W=UT(s,(h??!0)&&d,Mp),z=w.useMemo(()=>W.filter(D=>D.type==="text"),[W]),O=w.useMemo(()=>z.map(D=>D.text??"").join(""),[z]),I=w.useMemo(()=>{if(!m)return null;const D=VT(O);return{stablePart:O.slice(0,D),tailPart:O.slice(D)}},[O,m]),G=w.useMemo(()=>{if(!I)return null;const{stablePart:D,tailPart:q}=I;return!D&&!q?null:u.jsxs("div",{className:"space-y-2",children:[D?u.jsx(cr,{content:D,allowHtml:!1}):null,q?u.jsx(cr,{content:q,allowHtml:!1}):null]})},[I]),J=w.useMemo(()=>{if(!m)return W;const D=[];let q=!1;for(const M of W){if(M.type==="text"){q||(D.push({type:"text",text:"",__streamingMarkdownAggregate:!0}),q=!0);continue}D.push(M)}return D},[W,m]),P=m?J:W,B=w.useCallback(({part:D,i:q})=>{if(D.type==="text"){if(m)return null;const M=D.text??"",L=M.trim(),Y=Qr(L);return Y&&C!=="tool"?u.jsx(Js,{data:Y},q):C==="user"&&k&&L.length>S?u.jsx(Ap,{text:L,expanded:T,onExpandedChange:E,previewLength:S,isCompact:j},q):u.jsx(cr,{content:M,allowHtml:!1},q)}if(D.type==="image_url"){const M=D;return u.jsx("div",{className:"my-2",children:u.jsx("img",{src:M.url,alt:M.alt??"",loading:"lazy",className:"border rounded max-h-[420px] w-auto object-contain"})},q)}if(D.type==="file"){const M=D,L=M.name||"file";return u.jsxs("a",{href:M.url,onClick:Y=>v(Y,M,q),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[q]?u.jsx(ce.Loader,{className:"h-4 w-4 animate-spin"}):null,u.jsxs("span",{className:"truncate max-w-[180px]",children:[L,g[q]?" (processing)":""]})]},q)}if(D.type==="interrupt"){const M=D,L=Xo((M==null?void 0:M.id)??(M==null?void 0:M.interrupt_id)),Y=!!(_&&L&&L===_),Z=Y?$??(M==null?void 0:M.value):M==null?void 0:M.value,oe=L?{...M,id:L,interrupt_id:L}:M;return u.jsx(Ip,{interruptPart:oe,onApprove:x,onReject:y,disabled:b,isActive:Y,payload:Z},q)}return null},[_,$,b,v,x,y,j,T,C,k,g,S,m,E]),A=i.trim().length>0||a.length>0||l.length>0||c.length>0;if(!t&&l.length>0&&!d)return R();if(!t&&!A&&!d)return null;if(t)return n?u.jsx(Rp,{message:e,viewMode:r,isStreaming:o,toolRenderers:U,toolArtifactRenderers:X},e.id):null;if(!f){const D=u.jsx("div",{className:"space-y-2",children:P.map((q,M)=>m&&KT(q)?G?u.jsx("div",{className:"space-y-2",children:G},`streaming-md-${M}`):null:u.jsx(B,{part:q,i:M},M))});return d?u.jsxs("div",{"aria-busy":"true",role:"status",children:[D,u.jsx(Np,{className:F})]}):D}return null}function Mp(e){return e?!(No(e,/```/g)||No(e,/`/g)||No(e,/\*\*/g)||No(e,/__/g)||No(e,/~~/g)||/[^\\]\[[^\]]*$/.test(e)||/\[[^\]]*\]\([^)]*$/.test(e)):!0}function No(e,t){const n=e.match(t);return((n==null?void 0:n.length)??0)%2!==0}function VT(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 KT(e){return e.type==="text"&&!!e.__streamingMarkdownAggregate}const qT=Hr.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:te(qT({variant:t}),e),...n})}function GT({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:b,attemptCount:C,attemptIndex:k,handleOlderAttemptSelect:S,handleNewerAttemptSelect:T,messageCreatedAt:E,copied:j}){return!e&&!t&&!n?null:u.jsxs("div",{className:te("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:te("font-medium",l?"text-xs":"text-sm"),children:o}),n&&u.jsxs(Op,{variant:"outline",className:te("text-xs flex items-center gap-1 cursor-pointer select-none",r,"border border-current/40",l&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":m==="expanded",onClick:v,onKeyDown:_=>{(_.key==="Enter"||_.key===" ")&&(_.preventDefault(),v())},children:[u.jsx("span",{children:f.name??"Tool Output"}),f.toolCallId&&u.jsx("span",{className:"opacity-70",children:f.toolCallId.slice(0,8)}),m==="expanded"?u.jsx(ce.ChevronUp,{className:"h-3 w-3"}):u.jsx(ce.ChevronDown,{className:"h-3 w-3"})]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[b&&C>1&&u.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[u.jsx("button",{type:"button",className:te("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",k<C-1?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{k>=C-1||S()},"aria-label":"Older attempt (back in time)",disabled:k>=C-1,children:u.jsx(ce.ChevronLeft,{className:"h-3 w-3"})}),u.jsx("div",{className:"flex items-center gap-2",children:u.jsxs("span",{className:"whitespace-nowrap",children:[C-k," / ",C]})}),u.jsx("button",{type:"button",className:te("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(ce.ChevronRight,{className:"h-3 w-3"})})]}),e&&E&&u.jsx("time",{className:te("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:te("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",a),children:[u.jsx("div",{className:"relative",children:u.jsx(Qe,{variant:"ghost",size:"sm",onClick:g,className:te("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(ce.Copy,{className:te(j?"text-success":r,l?"h-3 w-3":"h-4 w-4")})})}),h==="user"&&x&&u.jsx(Qe,{variant:"ghost",size:"sm",onClick:x,className:te("h-6 w-6 p-0 hover:bg-foreground/10",r,l&&"h-5 w-5"),"aria-label":"Edit message",children:u.jsx(ce.Edit,{className:te(r,l?"h-3 w-3":"h-4 w-4")})}),h==="assistant"&&y&&u.jsx(Qe,{variant:"ghost",size:"sm",onClick:y,className:te("h-6 w-6 p-0 hover:bg-foreground/10",r,l&&"h-5 w-5"),"aria-label":"Regenerate response",children:u.jsx(ce.RotateCcw,{className:te(r,l?"h-3 w-3":"h-4 w-4")})})]})]})]})}const Zs=w.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,toolRenderers:m,toolArtifactRenderers:f,customStyles:v={},streamingDebounceMs:g=300,renderStreamingMarkdown:x=!1,enableStreamingMarkdownBuffer:y,onEdit:b,onRegenerate:C,onCopy:k,activeInterrupt:S,disableInterruptActions:T=!1,onInterruptActionStart:E,onInterruptActionEnd:j,attemptCount:_=1,attemptIndex:$=0,onSelectCheckpoint:F,attemptMetas:U=[]}){const[X,R]=w.useState(!1),[K,W]=w.useState("preview"),[z,O]=w.useState(!1),{currentThreadId:I}=xr(),{respondToInterrupt:G}=to(),J=l==="phone"||l==="half-screen",P=t.role,B=P==="tool",A=w.useMemo(()=>t.role==="default_message"?t:null,[t]),D=!!A,q=!(r&&P!=="user"),{uploadingFiles:M,handleFileClick:L,fileViewerOpen:Y,currentFileInfo:Z,closeFileViewer:oe}=jp({allowFileOpen:q,currentThreadId:I}),se=w.useMemo(()=>{switch(P){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))]"}},[P]),ie=Pp(t,A),{contentParts:le,imageParts:ye,fileParts:De,interruptParts:We,textContent:Pe,toolMeta:$e,toolRaw:lt,isToolStreaming:ut}=ie,yt=y??g!==0,qe=(S==null?void 0:S.id)??(S==null?void 0:S.interrupt_id),Xe=Xo(qe),Ve=S==null?void 0:S.value,Le=w.useCallback(async()=>{const pe=B?lt:Pe;async function ue(Ce){if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function"){await navigator.clipboard.writeText(Ce);return}if(navigator.clipboard&&typeof navigator.clipboard.write=="function"&&typeof ClipboardItem<"u"){const Ge=new Blob([Ce],{type:"text/plain"});await navigator.clipboard.write([new ClipboardItem({"text/plain":Ge})]);return}throw new Error("Clipboard API not supported in this context.")}try{await ue(pe),R(!0),setTimeout(()=>R(!1),2e3),k==null||k(pe)}catch(Ce){console.error("Failed to copy:",Ce)}},[B,lt,Pe,k]),Ae=w.useCallback(()=>{if(!b||!t.id)return;const pe=(B?lt:Pe)??"",ue="type"in t&&t.type==="default_message"?void 0:{checkpointId:t.checkpointId??null,checkpointNs:t.checkpointNs??null};b(t.id,pe,ue)},[b,B,lt,Pe,t]),dt=w.useCallback(()=>{C==null||C(n)},[C,n]),Rt=w.useCallback(()=>{W(pe=>pe==="expanded"?"preview":"expanded")},[]),tt=w.useCallback(()=>{const ue=te(J?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",se);switch(P){case"user":return u.jsx(ce.User,{className:ue});case"assistant":return u.jsx(ce.Bot,{className:ue});case"tool":return u.jsx(ce.Wrench,{className:ue});default:return u.jsx(ce.Bot,{className:ue})}},[J,se,P]),st=w.useCallback(()=>{const pe="group relative mb-4 flex w-full";switch(P){case"user":return te(pe,"justify-end");case"assistant":case"tool":case"system":return te(pe,"justify-start");default:return pe}},[P]),gt=w.useCallback(()=>{const pe=te("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",J&&"px-3 py-2 text-sm");if(D)return te(pe,"w-full","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40 shadow-sm");switch(P){case"user":return te(pe,"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 te(pe,"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 te(pe,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return te(pe,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return te(pe,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40")}},[J,D,P]),St=w.useCallback(async pe=>{if(T)return;const ue=Xo((pe==null?void 0:pe.id)??(pe==null?void 0:pe.interrupt_id));if(!ue){console.warn("Interrupt part missing id",pe);return}try{E==null||E(),await G(ue,!0)}catch(Ce){console.error("Failed to approve interrupt:",Ce)}finally{j==null||j()}},[T,j,E,G]),xt=w.useCallback(async pe=>{if(T)return;const ue=Xo((pe==null?void 0:pe.id)??(pe==null?void 0:pe.interrupt_id));if(!ue){console.warn("Interrupt part missing id",pe);return}try{E==null||E(),await G(ue,!1)}catch(Ce){console.error("Failed to reject interrupt:",Ce)}finally{j==null||j()}},[T,j,E,G]),rn=u.jsx(WT,{message:t,isToolMessage:B,showToolMessages:h,toolViewMode:K,isToolStreaming:ut,contentParts:le,textContent:Pe,imageParts:ye,fileParts:De,interruptParts:We,isStreamingMessage:r,defaultMessage:A,enableStreamingMarkdownBuffer:yt,renderStreamingMarkdown:x,handleFileClick:L,uploadingFiles:M,handleInterruptApprove:St,handleInterruptReject:xt,disableInterruptActions:T,messageRole:P,truncateUserMessages:c,userMessagePreviewLength:d,isUserExpanded:z,setIsUserExpanded:O,isCompactLayout:J,activeInterruptId:Xe,activeInterruptValue:Ve,iconForeground:se,toolRenderers:m,toolArtifactRenderers:f}),It=w.useMemo(()=>A?"Assistant":nw(t),[A,t]),mn=tt(),Zt=P==="user"&&(_??1)>1&&typeof F=="function",Ue=(U==null?void 0:U.length)??0,Fe=Ue>0&&$<Ue-1?U[$+1]:void 0,vt=Ue>0&&$>0?U[$-1]:void 0,ne=w.useCallback(()=>{!Fe||!F||F(Fe.id,void 0,!!Fe.isLatestAttempt)},[Fe,F]),we=w.useCallback(()=>{!vt||!F||F(vt.id,void 0,!!vt.isLatestAttempt)},[vt,F]);return B&&!h?null:D&&A?u.jsx("div",{className:te(st(),v.container),children:u.jsxs("div",{className:te(gt(),v.content),children:[u.jsxs("div",{className:"flex items-center gap-2 mb-2 pb-2 border-b border-current/10",children:[u.jsx(ce.Bot,{className:te("h-4 w-4",se)}),a&&u.jsx("span",{className:"font-medium text-sm",children:"Assistant"})]}),u.jsx(cr,{content:A.content,className:"text-current"})]})}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:te(st(),v.container),children:u.jsxs("div",{className:te(gt(),v.content),children:[u.jsx(GT,{showTimestamp:i,showAgentName:a,isToolMessage:B,iconForeground:se,agentName:It,messageIcon:mn,customHeaderClass:v.header,customActionsClass:v.actions,isCompactLayout:J,showActions:s,isEditing:o,messageRole:P,toolViewMode:K,toolMeta:$e,onToggleToolView:Rt,onCopy:Le,onEdit:Ae,onRegenerate:dt,showCheckpointControls:Zt,attemptCount:_,attemptIndex:$,handleOlderAttemptSelect:ne,handleNewerAttemptSelect:we,messageCreatedAt:t.createdAt,copied:X}),u.jsx("div",{className:"relative",children:rn}),B&&K==="expanded"&&($e.toolCallId||$e.name)&&u.jsxs("div",{className:te("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",J&&"text-xs"),children:[$e.name&&u.jsxs("div",{children:["Function: ",$e.name]}),$e.toolCallId&&u.jsxs("div",{children:["Call ID: ",$e.toolCallId]})]}),!(i||a||B)&&s&&!o&&u.jsxs("div",{className:te("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",v.actions),children:[u.jsx(Qe,{variant:"ghost",size:"sm",onClick:()=>Le(),className:te("h-6 w-6 p-0 hover:bg-background/50 text-current",J&&"h-5 w-5"),children:u.jsx(ce.Copy,{className:te(X?"text-success":"text-current",J?"h-3 w-3":"h-4 w-4")})}),P==="user"&&b&&u.jsx(Qe,{variant:"ghost",size:"sm",onClick:Ae,className:te("h-6 w-6 p-0 hover:bg-background/50 text-current",J&&"h-5 w-5"),children:u.jsx(ce.Edit,{className:te("text-current",J?"h-3 w-3":"h-4 w-4")})}),P==="assistant"&&C&&u.jsx(Qe,{variant:"ghost",size:"sm",onClick:dt,className:te("h-6 w-6 p-0 hover:bg-background/50 text-current",J&&"h-5 w-5"),children:u.jsx(ce.RotateCcw,{className:te("text-current",J?"h-3 w-3":"h-4 w-4")})})]})]})}),Z&&u.jsx(cp,{isOpen:Y,onClose:oe,fileId:Z.id,fileName:Z.name,mimeType:Z.mimeType})]})},(e,t)=>{var l,c,d,h,m,f,v,g;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&gu(e.message)===gu(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateUserMessages","userMessagePreviewLength","showToolMessages","toolRenderers","toolArtifactRenderers"].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=xu(e.message),a=xu(t.message);return i.length===a.length});Zs.displayName="MessageComponent";const pl=w.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:b,disableInterruptActions:C=!1,onInterruptActionStart:k,onInterruptActionEnd:S,showToolMessages:T=!0,toolRenderers:E,toolArtifactRenderers:j,checkpointIndex:_,activeCheckpointId:$,onSelectCheckpoint:F,createSyntheticThinkingMessage:U=!0,forceSyntheticThinking:X=!1,getMessageCustomStyles:R},K)=>{const W=w.useRef(null),z=w.useRef(null),O=w.useRef(!1),I=w.useRef(!1),G=w.useMemo(()=>b?e.some(ie=>ie.role==="default_message"?!1:Array.isArray(ie==null?void 0:ie.content)&&ie.content.some(le=>le&&le.type==="interrupt"&&(le.id??le.interrupt_id)===b.id)):!1,[b,e]),J=w.useMemo(()=>{if(!b||G)return null;const ie=b.id&&String(b.id).trim()?String(b.id).trim():"pending-interrupt";let le;const ye=b.value;if(ye&&typeof ye=="object"&&!Array.isArray(ye)){const De=ye.title;typeof De=="string"&&De.trim()&&(le=De.trim())}return{id:`interrupt-${ie}`,role:"system",createdAt:new Date().toISOString(),content:[{type:"interrupt",id:ie,value:ye,title:le}]}},[b,G]),P=w.useMemo(()=>J?[...e,J]:e,[e,J]),B=w.useMemo(()=>{const ie=n&&P.some(ye=>ye.id===n);return U&&(t||X)&&!ie&&P.length>0?[...P,{id:"thinking-assistant",role:"assistant",content:[{type:"text",text:""}],createdAt:new Date().toISOString(),__syntheticStreaming:!0}]:P},[P,t,n,U,X]),A=w.useMemo(()=>T?B:B.filter(ie=>(ie==null?void 0:ie.role)!=="tool"),[B,T]),D=w.useCallback(ie=>{x&&x(!ie),y&&y(ie)},[x,y]),q=w.useMemo(()=>{if(a)return async()=>{if(!O.current){O.current=!0;try{await a()}finally{O.current=!1}}}},[a]),M=w.useMemo(()=>!v||g?!1:"auto",[v,g]),L=w.useMemo(()=>{if(typeof f!="string")return null;const ie=f.trim();return!ie||A&&A.length>0?null:{id:"default-message",role:"default_message",content:ie,createdAt:new Date().toISOString()}},[f,A]),Y=["flex h-full flex-col md:flex-row",h].filter(Boolean).join(" "),Z=()=>{if(L){const ie=R==null?void 0:R(L);return u.jsx("div",{className:"p-6 h-full overflow-y-auto",children:u.jsx("div",{className:"w-full max-w-full",children:u.jsx(Zs,{message:L,messageIndex:0,isStreamingMessage:!1,showActions:!1,showTimestamp:!1,showAgentName:!0,layoutSize:o,onEdit:()=>{},onRegenerate:()=>{},onCancelEdit:()=>{},customStyles:ie})})})}return 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!"})},oe=A.length,se=oe>0;return w.useEffect(()=>{var ie,le;if(oe===0){I.current=!1;return}if(!I.current)if(I.current=!0,W.current&&A.length>0){const ye=A.length-1;(le=(ie=W.current).scrollToIndex)==null||le.call(ie,{index:ye,align:"end",behavior:"auto"})}else z.current&&(z.current.scrollTop=z.current.scrollHeight)},[oe,A.length]),w.useImperativeHandle(K,()=>({scrollToLatest:()=>{var ie,le;if(W.current&&A.length>0){const ye=A.length-1;(le=(ie=W.current).scrollToIndex)==null||le.call(ie,{index:ye,align:"end",behavior:"auto"})}else z.current&&(z.current.scrollTop=z.current.scrollHeight)},scrollToTop:()=>{var ie,le;W.current&&A.length>0?(le=(ie=W.current).scrollToIndex)==null||le.call(ie,{index:0,align:"start",behavior:"auto"}):z.current&&(z.current.scrollTop=0)}}),[A]),u.jsx("div",{className:Y,style:m,children:u.jsx("div",{className:"relative flex-1 min-h-0",children:se?u.jsx(HC,{ref:ie=>{W.current=ie},scrollerRef:ie=>{z.current=ie instanceof HTMLDivElement?ie:null},data:A,followOutput:M,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,startReached:()=>{q&&q()},atBottomStateChange:D,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(ie,le)=>fl(le,ie),itemContent:(ie,le)=>u.jsx(hl,{message:le,index:ie,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onEdit:l,onRegenerate:c,onCancelEdit:d,activeInterrupt:b,disableInterruptActions:C,onInterruptActionStart:k,onInterruptActionEnd:S,showToolMessages:T,toolRenderers:E,toolArtifactRenderers:j,checkpointIndex:_,activeCheckpointId:$,onSelectCheckpoint:F,getMessageCustomStyles:R})}):Z()})})});pl.displayName="MessageList";const Dp={value:""};function Or({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,toolRenderers:h,toolArtifactRenderers:m,payloadExtras:f={},customStyles:v={},messageCustomStyles:g,onMessageSent:x,onExcelUploadSuccess:y,onError:b,defaultMessage:C}){const{api:k}=Jr(),S=k.baseUrl,{currentThreadId:T}=xr(),{threadId:E,messages:j,isLoading:_,navigateToCheckpoint:$,returnToLatest:F,checkpoint:U,checkpoints:X,interrupt:R,metadata:K,checkpointIndex:W}=to(),{isStreaming:z,error:O,connectionState:I,submit:G,stop:J}=Fi(),P=E??T??null,B=(U==null?void 0:U.id)??null,A=(U==null?void 0:U.namespace)??null,D=(K==null?void 0:K.assemblingMessageId)??null,q=R,[M,L]=w.useState(!1),[Y,Z]=w.useState(!1);w.useEffect(()=>{q||L(!1)},[q]);const oe=w.useCallback(()=>{L(!0)},[]),se=w.useCallback(()=>{L(!1)},[]),ie=!!q||M,[le,ye]=w.useState(null),[De,We]=w.useState(""),[Pe,$e]=w.useState(null),[lt,ut]=w.useState(null),[yt,qe]=w.useState(!1),[Xe,Ve]=w.useState(null),Le=w.useRef(!1),[Ae,dt]=w.useState(()=>Dp.value),Rt=w.useRef(Ae),tt=w.useRef(null),st=w.useCallback(Ie=>{Dp.value=Ie,dt(Ie)},[]),[gt,St]=w.useState(!1),xt=w.useRef(null),rn=w.useCallback(Ie=>{st(Ie)},[st]);w.useEffect(()=>{z||Z(!1)},[z]),w.useEffect(()=>{K!=null&&K.assemblingMessageId&&Z(!1)},[K==null?void 0:K.assemblingMessageId]);const[It,mn]=w.useState("desktop");w.useEffect(()=>{const Ie=()=>{const _e=window.innerWidth;mn(_e<640?"phone":_e<1024?"tablet":"desktop")};return Ie(),window.addEventListener("resize",Ie),()=>window.removeEventListener("resize",Ie)},[]),w.useEffect(()=>{Le.current=!1},[P]),w.useEffect(()=>{Rt.current=Ae},[Ae]),w.useEffect(()=>{if(!le){tt.current=null;return}tt.current===null&&(tt.current=Rt.current),st(De??"")},[De,le,st]),w.useEffect(()=>{if(C!==void 0){Ve(C);return}(async()=>{if(!S){Ve(null);return}try{const Be=(await k.getAgent("default")).uiDefaultMessage||"";Ve(Be||null)}catch(_e){console.warn("Failed to fetch default message:",_e),Ve(null)}})()},[k,S,C]),w.useEffect(()=>{O&&!yt&&(b==null||b(O))},[O,yt,b]);const Zt=async(Ie,_e)=>{const Be=Ie.trim();if(!(!Be&&_e.length===0))try{const xe=le?(Pe==null?void 0:Pe.checkpointId)??B??void 0:B??void 0,et=le?(Pe==null?void 0:Pe.checkpointNs)??A??void 0:A??void 0;await G({text:Be||"",attachments:_e,payload:f},{checkpointId:xe,checkpointNs:et,edit:!!le,originalMessageId:le??void 0}),x==null||x(Be),Z(!0),st(""),ut(null),ye(null),We(""),$e(null)}catch(xe){const et=(xe==null?void 0:xe.message)||"Failed to send message";ut(et),b==null||b(et),Z(!1)}},Ue=w.useCallback(async Ie=>{await G({attachments:[Ie],payload:f},{checkpointId:B??void 0,checkpointNs:A??void 0}),y==null||y({file:Ie})},[B,A,f,y,G]),Fe=w.useCallback((Ie,_e,Be)=>{c&&(tt.current=Ae,ye(Ie),We(_e),st(_e),ut(null),$e({checkpointId:(Be==null?void 0:Be.checkpointId)??null,checkpointNs:(Be==null?void 0:Be.checkpointNs)??null}))},[Ae,c,st]),vt=w.useCallback(()=>{ye(null),We(""),$e(null),ut(null),st(tt.current??Ae),tt.current=null},[Ae,st]),ne=w.useCallback((Ie,_e,Be)=>{Fe(Ie,_e,Be)},[Fe]),we=w.useCallback(Ie=>{let _e=null;for(let Re=Ie-1;Re>=0;Re--)if(j[Re].role==="user"){_e=j[Re];break}if(!_e)return;const Be=Array.isArray(_e.content)?_e.content:[],et=Be.filter(Re=>(Re==null?void 0:Re.type)==="text").map(Re=>Re.text).join("")||(()=>{try{return JSON.stringify(Be,null,2)}catch{return String(Be)}})();et&&G({text:et,payload:f},{checkpointId:B??void 0,checkpointNs:A??void 0,edit:!0,originalMessageId:_e.id})},[j,G,B,A,f]),pe=w.useCallback(async Ie=>{if(T){St(!0);try{if(!Ie){await F(),requestAnimationFrame(()=>{var xe;(xe=xt.current)==null||xe.scrollToLatest()});return}const _e=X.find(xe=>xe.checkpointId===Ie),Be=(_e==null?void 0:_e.checkpointNs)??null;await $(Ie,Be),requestAnimationFrame(()=>{var xe;(xe=xt.current)==null||xe.scrollToTop()})}finally{St(!1)}}},[X,T,xt,$,F]),ue=w.useCallback(async(Ie,_e,Be)=>{await pe(Be?null:Ie)},[pe]),Ce=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${v.container||""}`,Ge=`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 ${v.messagesArea||""}`,kt=`relative flex-shrink-0 w-full border-t p-4 bg-transparent ${v.inputArea||""}`;return u.jsxs("div",{className:Ce,children:[!!O&&!yt&&u.jsxs("div",{className:"flex-shrink-0 bg-red-50 border border-red-200 text-red-800 px-4 py-2 text-sm flex items-center justify-between",children:[u.jsx("span",{children:O}),u.jsx(Qe,{variant:"ghost",size:"sm",onClick:()=>qe(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:u.jsx(ce.X,{size:16})})]}),u.jsxs("div",{className:`relative ${Ge}`,style:r?{maxHeight:r}:void 0,children:[u.jsx(pl,{ref:xt,className:"h-full",style:{height:"100%"},messages:j,isStreaming:z,streamingAssistantId:D,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:It,enableMessageEditing:c,editingMessageId:le,onEdit:ne,onRegenerate:we,onCancelEdit:vt,emptyMessage:Xe??void 0,isNavigatingCheckpoint:gt,activeInterrupt:q,disableInterruptActions:M,onInterruptActionStart:oe,onInterruptActionEnd:se,showToolMessages:d,toolRenderers:h,toolArtifactRenderers:m,checkpointIndex:W,activeCheckpointId:B,onSelectCheckpoint:ue,createSyntheticThinkingMessage:!0,forceSyntheticThinking:Y,getMessageCustomStyles:g}),(I==="reconnecting"||I==="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(ce.Loader2,{className:"h-3 w-3 animate-spin"}),I==="reconnecting"?"Reconnecting…":"Connecting…"]})}),I==="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"}),_&&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(ce.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading messages…"})]}),gt&&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(ce.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:kt,children:[le&&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(ce.Edit3,{size:16,className:"text-blue-600"}),u.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),u.jsx(Qe,{variant:"ghost",size:"sm",onClick:vt,className:"text-blue-600 hover:bg-blue-100",children:u.jsx(ce.X,{size:16})})]})}),lt&&u.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:lt}),u.jsx(_S,{composerValue:Ae,onComposerChange:rn,onSend:Zt,onCancelEdit:vt,onStop:J,editingMessageId:le,editingInitialValue:De,placeholder:le?"Edit your message...":t,isStreaming:z,disabled:ie,enableFileUpload:a,enableExcelUpload:l,onExcelUpload:Ue,onError:b,customStyles:v,textareaClassName:v.textarea||"",allowEmptySend:!1,inputError:lt})]})]})}var Lp=1,YT=.9,XT=.8,JT=.17,ml=.1,gl=.999,ZT=.9999,QT=.99,ek=/[\\\/_+.#"@\[\(\{&]/,tk=/[\\\/_+.#"@\[\(\{&]/g,nk=/[\s-]/,$p=/[\s-]/g;function xl(e,t,n,r,o,s,i){if(s===t.length)return o===e.length?Lp:QT;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:ek.test(e.charAt(c-1))?(h*=XT,f=e.slice(o,c-1).match(tk),f&&o>0&&(h*=Math.pow(gl,f.length))):nk.test(e.charAt(c-1))?(h*=YT,v=e.slice(o,c-1).match($p),v&&o>0&&(h*=Math.pow(gl,v.length))):(h*=JT,o>0&&(h*=Math.pow(gl,c-o))),e.charAt(c)!==t.charAt(s)&&(h*=ZT)),(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 rk(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,xl(e,t,Fp(e),Fp(t),0,0,{})}var Ao='[cmdk-group=""]',vl='[cmdk-group-items=""]',ok='[cmdk-group-heading=""]',Bp='[cmdk-item=""]',zp=`${Bp}:not([aria-disabled="true"])`,wl="cmdk-item-select",Dr="data-value",sk=(e,t,n)=>rk(e,t,n),Hp=p.createContext(void 0),jo=()=>p.useContext(Hp),Up=p.createContext(void 0),bl=()=>p.useContext(Up),Wp=p.createContext(void 0),Vp=p.forwardRef((e,t)=>{let n=Lr(()=>{var P,B;return{search:"",value:(B=(P=e.value)!=null?P:e.defaultValue)!=null?B:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=Lr(()=>new Set),o=Lr(()=>new Map),s=Lr(()=>new Map),i=Lr(()=>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,b=At(),C=At(),k=At(),S=p.useRef(null),T=gk();ur(()=>{if(d!==void 0){let P=d.trim();n.current.value=P,E.emit()}},[d]),ur(()=>{T(6,X)},[]);let E=p.useMemo(()=>({subscribe:P=>(i.current.add(P),()=>i.current.delete(P)),snapshot:()=>n.current,setState:(P,B,A)=>{var D,q,M,L;if(!Object.is(n.current[P],B)){if(n.current[P]=B,P==="search")U(),$(),T(1,F);else if(P==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let Y=document.getElementById(k);Y?Y.focus():(D=document.getElementById(b))==null||D.focus()}if(T(7,()=>{var Y;n.current.selectedItemId=(Y=R())==null?void 0:Y.id,E.emit()}),A||T(5,X),((q=a.current)==null?void 0:q.value)!==void 0){let Y=B??"";(L=(M=a.current).onValueChange)==null||L.call(M,Y);return}}E.emit()}},emit:()=>{i.current.forEach(P=>P())}}),[]),j=p.useMemo(()=>({value:(P,B,A)=>{var D;B!==((D=s.current.get(P))==null?void 0:D.value)&&(s.current.set(P,{value:B,keywords:A}),n.current.filtered.items.set(P,_(B,A)),T(2,()=>{$(),E.emit()}))},item:(P,B)=>(r.current.add(P),B&&(o.current.has(B)?o.current.get(B).add(P):o.current.set(B,new Set([P]))),T(3,()=>{U(),$(),n.current.value||F(),E.emit()}),()=>{s.current.delete(P),r.current.delete(P),n.current.filtered.items.delete(P);let A=R();T(4,()=>{U(),(A==null?void 0:A.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:b,inputId:k,labelId:C,listInnerRef:S}),[]);function _(P,B){var A,D;let q=(D=(A=a.current)==null?void 0:A.filter)!=null?D:sk;return P?q(P,n.current.search,B):0}function $(){if(!n.current.search||a.current.shouldFilter===!1)return;let P=n.current.filtered.items,B=[];n.current.filtered.groups.forEach(D=>{let q=o.current.get(D),M=0;q.forEach(L=>{let Y=P.get(L);M=Math.max(Y,M)}),B.push([D,M])});let A=S.current;K().sort((D,q)=>{var M,L;let Y=D.getAttribute("id"),Z=q.getAttribute("id");return((M=P.get(Z))!=null?M:0)-((L=P.get(Y))!=null?L:0)}).forEach(D=>{let q=D.closest(vl);q?q.appendChild(D.parentElement===q?D:D.closest(`${vl} > *`)):A.appendChild(D.parentElement===A?D:D.closest(`${vl} > *`))}),B.sort((D,q)=>q[1]-D[1]).forEach(D=>{var q;let M=(q=S.current)==null?void 0:q.querySelector(`${Ao}[${Dr}="${encodeURIComponent(D[0])}"]`);M==null||M.parentElement.appendChild(M)})}function F(){let P=K().find(A=>A.getAttribute("aria-disabled")!=="true"),B=P==null?void 0:P.getAttribute(Dr);E.setState("value",B||void 0)}function U(){var P,B,A,D;if(!n.current.search||a.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let q=0;for(let M of r.current){let L=(B=(P=s.current.get(M))==null?void 0:P.value)!=null?B:"",Y=(D=(A=s.current.get(M))==null?void 0:A.keywords)!=null?D:[],Z=_(L,Y);n.current.filtered.items.set(M,Z),Z>0&&q++}for(let[M,L]of o.current)for(let Y of L)if(n.current.filtered.items.get(Y)>0){n.current.filtered.groups.add(M);break}n.current.filtered.count=q}function X(){var P,B,A;let D=R();D&&(((P=D.parentElement)==null?void 0:P.firstChild)===D&&((A=(B=D.closest(Ao))==null?void 0:B.querySelector(ok))==null||A.scrollIntoView({block:"nearest"})),D.scrollIntoView({block:"nearest"}))}function R(){var P;return(P=S.current)==null?void 0:P.querySelector(`${Bp}[aria-selected="true"]`)}function K(){var P;return Array.from(((P=S.current)==null?void 0:P.querySelectorAll(zp))||[])}function W(P){let B=K()[P];B&&E.setState("value",B.getAttribute(Dr))}function z(P){var B;let A=R(),D=K(),q=D.findIndex(L=>L===A),M=D[q+P];(B=a.current)!=null&&B.loop&&(M=q+P<0?D[D.length-1]:q+P===D.length?D[0]:D[q+P]),M&&E.setState("value",M.getAttribute(Dr))}function O(P){let B=R(),A=B==null?void 0:B.closest(Ao),D;for(;A&&!D;)A=P>0?pk(A,Ao):mk(A,Ao),D=A==null?void 0:A.querySelector(zp);D?E.setState("value",D.getAttribute(Dr)):z(P)}let I=()=>W(K().length-1),G=P=>{P.preventDefault(),P.metaKey?I():P.altKey?O(1):z(1)},J=P=>{P.preventDefault(),P.metaKey?W(0):P.altKey?O(-1):z(-1)};return p.createElement(me.div,{ref:t,tabIndex:-1,...y,"cmdk-root":"",onKeyDown:P=>{var B;(B=y.onKeyDown)==null||B.call(y,P);let A=P.nativeEvent.isComposing||P.keyCode===229;if(!(P.defaultPrevented||A))switch(P.key){case"n":case"j":{x&&P.ctrlKey&&G(P);break}case"ArrowDown":{G(P);break}case"p":case"k":{x&&P.ctrlKey&&J(P);break}case"ArrowUp":{J(P);break}case"Home":{P.preventDefault(),W(0);break}case"End":{P.preventDefault(),I();break}case"Enter":{P.preventDefault();let D=R();if(D){let q=new Event(wl);D.dispatchEvent(q)}}}}},p.createElement("label",{"cmdk-label":"",htmlFor:j.inputId,id:j.labelId,style:vk},l),Qs(e,P=>p.createElement(Up.Provider,{value:E},p.createElement(Hp.Provider,{value:j},P))))}),ik=p.forwardRef((e,t)=>{var n,r;let o=At(),s=p.useRef(null),i=p.useContext(Wp),a=jo(),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=bl(),m=Kn(T=>T.value&&T.value===d.current),f=Kn(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(wl,v),()=>T.removeEventListener(wl,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:b,forceMount:C,keywords:k,...S}=e;return p.createElement(me.div,{ref:Mn(s,t),...S,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)}),ak=p.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:o,...s}=e,i=At(),a=p.useRef(null),l=p.useRef(null),c=At(),d=jo(),h=Kn(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(me.div,{ref:Mn(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),Qs(e,f=>p.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?c:void 0},p.createElement(Wp.Provider,{value:m},f))))}),lk=p.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,o=p.useRef(null),s=Kn(i=>!i.search);return!n&&!s?null:p.createElement(me.div,{ref:Mn(o,t),...r,"cmdk-separator":"",role:"separator"})}),ck=p.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,o=e.value!=null,s=bl(),i=Kn(c=>c.search),a=Kn(c=>c.selectedItemId),l=jo();return p.useEffect(()=>{e.value!=null&&s.setState("search",e.value)},[e.value]),p.createElement(me.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)}})}),uk=p.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...o}=e,s=p.useRef(null),i=p.useRef(null),a=Kn(c=>c.selectedItemId),l=jo();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(me.div,{ref:Mn(s,t),...o,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":a,"aria-label":r,id:l.listId},Qs(e,c=>p.createElement("div",{ref:Mn(i,l.listInnerRef),"cmdk-list-sizer":""},c)))}),dk=p.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:o,contentClassName:s,container:i,...a}=e;return p.createElement(Qa,{open:n,onOpenChange:r},p.createElement(el,{container:i},p.createElement(ko,{"cmdk-overlay":"",className:o}),p.createElement(Eo,{"aria-label":e.label,"cmdk-dialog":"",className:s},p.createElement(Vp,{ref:t,...a}))))}),fk=p.forwardRef((e,t)=>Kn(n=>n.filtered.count===0)?p.createElement(me.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),hk=p.forwardRef((e,t)=>{let{progress:n,children:r,label:o="Loading...",...s}=e;return p.createElement(me.div,{ref:t,...s,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":o},Qs(e,i=>p.createElement("div",{"aria-hidden":!0},i)))}),Ht=Object.assign(Vp,{List:uk,Item:ik,Input:ck,Group:ak,Separator:lk,Dialog:dk,Empty:fk,Loading:hk});function pk(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function mk(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 Lr(e){let t=p.useRef();return t.current===void 0&&(t.current=e()),t}function Kn(e){let t=bl(),n=()=>e(t.snapshot());return p.useSyncExternalStore(t.subscribe,n,n)}function qp(e,t,n,r=[]){let o=p.useRef(),s=jo();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(Dr,a),o.current=a}),o}var gk=()=>{let[e,t]=p.useState(),n=Lr(()=>new Map);return ur(()=>{n.current.forEach(r=>r()),n.current=new Map},[e]),(r,o)=>{n.current.set(r,o),t({})}};function xk(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function Qs({asChild:e,children:t},n){return e&&p.isValidElement(t)?p.cloneElement(xk(t),{ref:t.ref},n(t.props.children)):n(t)}var vk={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(Ht,{ref:n,className:te("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));yl.displayName=Ht.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(ce.Search,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),u.jsx(Ht.Input,{ref:n,className:te("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=Ht.Input.displayName;const Cl=p.forwardRef(({className:e,...t},n)=>u.jsx(Ht.List,{ref:n,className:te("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));Cl.displayName=Ht.List.displayName;const Tl=p.forwardRef((e,t)=>u.jsx(Ht.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));Tl.displayName=Ht.Empty.displayName;const kl=p.forwardRef(({className:e,...t},n)=>u.jsx(Ht.Group,{ref:n,className:te("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=Ht.Group.displayName;const wk=p.forwardRef(({className:e,...t},n)=>u.jsx(Ht.Separator,{ref:n,className:te("-mx-1 h-px bg-border",e),...t}));wk.displayName=Ht.Separator.displayName;const El=p.forwardRef(({className:e,...t},n)=>u.jsx(Ht.Item,{ref:n,className:te("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=Ht.Item.displayName;function Il(e,[t,n]){return Math.min(n,Math.max(t,e))}function bk(e,t){return p.useReducer((n,r)=>t[n][r]??n,e)}var Nl="ScrollArea",[Gp,D1]=an(Nl),[yk,nn]=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,b]=p.useState(0),[C,k]=p.useState(0),[S,T]=p.useState(!1),[E,j]=p.useState(!1),_=Me(t,F=>l(F)),$=Zo(o);return u.jsx(yk,{scope:n,type:r,dir:$,scrollHideDelay:s,scrollArea:a,viewport:c,onViewportChange:d,content:h,onContentChange:m,scrollbarX:f,onScrollbarXChange:v,scrollbarXEnabled:S,onScrollbarXEnabledChange:T,scrollbarY:g,onScrollbarYChange:x,scrollbarYEnabled:E,onScrollbarYEnabledChange:j,onCornerWidthChange:b,onCornerHeightChange:k,children:u.jsx(me.div,{dir:$,...i,ref:_,style:{position:"relative","--radix-scroll-area-corner-width":y+"px","--radix-scroll-area-corner-height":C+"px",...e.style}})})});Yp.displayName=Nl;var Xp="ScrollAreaViewport",Jp=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=nn(Xp,n),a=p.useRef(null),l=Me(t,a,i.onViewportChange);return u.jsxs(u.Fragment,{children:[u.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:o}),u.jsx(me.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=nn(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(Sk,{...r,ref:t,forceMount:n}):o.type==="scroll"?u.jsx(Ck,{...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 Sk=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=nn(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(Bt,{present:n||s,children:u.jsx(Zp,{"data-state":s?"visible":"hidden",...r,ref:t})})}),Ck=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=nn(En,e.__scopeScrollArea),s=e.orientation==="horizontal",i=ri(()=>l("SCROLL_END"),100),[a,l]=bk("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(Bt,{present:n||a!=="hidden",children:u.jsx(jl,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:ae(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:ae(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),Zp=p.forwardRef((e,t)=>{const n=nn(En,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=p.useState(!1),a=e.orientation==="horizontal",l=ri(()=>{if(n.viewport){const c=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?c:d)}},10);return $r(n.viewport,l),$r(n.content,l),u.jsx(Bt,{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=nn(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 Ak(m,i.current,a,f)}return n==="horizontal"?u.jsx(Tk,{...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(kk,{...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}),Tk=p.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=nn(En,e.__scopeScrollArea),[i,a]=p.useState(),l=p.useRef(null),c=Me(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":ni(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:ti(i.paddingLeft),paddingEnd:ti(i.paddingRight)}})}})}),kk=p.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=nn(En,e.__scopeScrollArea),[i,a]=p.useState(),l=p.useRef(null),c=Me(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":ni(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:ti(i.paddingTop),paddingEnd:ti(i.paddingBottom)}})}})}),[Ek,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=nn(En,n),[v,g]=p.useState(null),x=Me(t,_=>g(_)),y=p.useRef(null),b=p.useRef(""),C=f.viewport,k=r.content-r.viewport,S=pt(d),T=pt(l),E=ri(h,10);function j(_){if(y.current){const $=_.clientX-y.current.left,F=_.clientY-y.current.top;c({x:$,y:F})}}return p.useEffect(()=>{const _=$=>{const F=$.target;(v==null?void 0:v.contains(F))&&S($,k)};return document.addEventListener("wheel",_,{passive:!1}),()=>document.removeEventListener("wheel",_,{passive:!1})},[C,v,k,S]),p.useEffect(T,[r,T]),$r(v,E),$r(f.content,E),u.jsx(Ek,{scope:n,scrollbar:v,hasThumb:o,onThumbChange:pt(s),onThumbPointerUp:pt(i),onThumbPositionChange:T,onThumbPointerDown:pt(a),children:u.jsx(me.div,{...m,ref:x,style:{position:"absolute",...m.style},onPointerDown:ae(e.onPointerDown,_=>{_.button===0&&(_.target.setPointerCapture(_.pointerId),y.current=v.getBoundingClientRect(),b.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",f.viewport&&(f.viewport.style.scrollBehavior="auto"),j(_))}),onPointerMove:ae(e.onPointerMove,j),onPointerUp:ae(e.onPointerUp,_=>{const $=_.target;$.hasPointerCapture(_.pointerId)&&$.releasePointerCapture(_.pointerId),document.body.style.webkitUserSelect=b.current,f.viewport&&(f.viewport.style.scrollBehavior=""),y.current=null})})})}),ei="ScrollAreaThumb",tm=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Qp(ei,e.__scopeScrollArea);return u.jsx(Bt,{present:n||o.hasThumb,children:u.jsx(Ik,{ref:t,...r})})}),Ik=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=nn(ei,n),i=Qp(ei,n),{onThumbPositionChange:a}=i,l=Me(t,h=>i.onThumbChange(h)),c=p.useRef(void 0),d=ri(()=>{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=jk(h,a);c.current=f,a()}};return a(),h.addEventListener("scroll",m),()=>h.removeEventListener("scroll",m)}},[s.viewport,d,a]),u.jsx(me.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:ae(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:ae(e.onPointerUp,i.onThumbPointerUp)})});tm.displayName=ei;var Pl="ScrollAreaCorner",nm=p.forwardRef((e,t)=>{const n=nn(Pl,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?u.jsx(Nk,{...e,ref:t}):null});nm.displayName=Pl;var Nk=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=nn(Pl,n),[s,i]=p.useState(0),[a,l]=p.useState(0),c=!!(s&&a);return $r(o.scrollbarX,()=>{var h;const d=((h=o.scrollbarX)==null?void 0:h.offsetHeight)||0;o.onCornerHeightChange(d),l(d)}),$r(o.scrollbarY,()=>{var h;const d=((h=o.scrollbarY)==null?void 0:h.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),c?u.jsx(me.div,{...r,ref:t,style:{width:s,height:a,position:"absolute",right:o.dir==="ltr"?0:void 0,left:o.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function ti(e){return e?parseInt(e,10):0}function rm(e,t){const n=e/t;return isNaN(n)?0:n}function ni(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 Ak(e,t,n,r="ltr"){const o=ni(n),s=o/2,i=t||s,a=o-i,l=n.scrollbar.paddingStart+i,c=n.scrollbar.size-n.scrollbar.paddingEnd-a,d=n.content-n.viewport,h=r==="ltr"?[0,d]:[d*-1,0];return sm([l,c],h)(e)}function om(e,t,n="ltr"){const r=ni(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,s=t.scrollbar.size-o,i=t.content-t.viewport,a=s-r,l=n==="ltr"?[0,i]:[i*-1,0],c=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 jk=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return function o(){const s={left:e.scrollLeft,top:e.scrollTop},i=n.left!==s.left,a=n.top!==s.top;(i||a)&&t(),n=s,r=window.requestAnimationFrame(o)}(),()=>window.cancelAnimationFrame(r)};function ri(e,t){const n=pt(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 $r(e,t){const n=pt(t);Et(()=>{let r=0;if(e){const o=new ResizeObserver(()=>{cancelAnimationFrame(r),r=window.requestAnimationFrame(n)});return o.observe(e),()=>{window.cancelAnimationFrame(r),o.unobserve(e)}}},[e,n])}var am=Yp,Pk=Jp,_k=nm;const _l=p.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(am,{ref:r,className:te("relative overflow-hidden",e),...n,children:[u.jsx(Pk,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),u.jsx(lm,{}),u.jsx(_k,{})]}));_l.displayName=am.displayName;const lm=p.forwardRef(({className:e,orientation:t="vertical",...n},r)=>u.jsx(Al,{ref:r,orientation:t,className:te("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:te("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 Rk="group relative p-3 rounded-lg cursor-pointer transition-colors border text-gray-900 dark:text-slate-100",Mk="bg-slate-700 border-slate-600 hover:bg-slate-600",Ok="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 b=n===e.threadId,C=t?`${y??Ok}`:`${x??Mk}`,k=S=>{S.stopPropagation(),o(e.threadId)};return u.jsxs("div",{onClick:k,className:`${Rk} ${C}`,children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("div",{className:"flex-1 min-w-0",children:b?u.jsxs("div",{className:"flex items-center gap-2",onClick:S=>S.stopPropagation(),children:[u.jsx(Rl,{value:r,onChange:S=>i(S.target.value),onKeyDown:S=>{S.key==="Enter"?a(e.threadId):S.key==="Escape"&&l()},className:"h-6 text-sm",autoFocus:!0}),u.jsx(Qe,{variant:"ghost",size:"sm",onClick:()=>a(e.threadId),className:"h-6 w-6 p-0",children:u.jsx(ce.Check,{size:12})}),u.jsx(Qe,{variant:"ghost",size:"sm",onClick:l,className:"h-6 w-6 p-0",children:u.jsx(ce.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(ce.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(Ts,{children:[u.jsx(ks,{asChild:!0,children:u.jsx(Qe,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",children:u.jsx(ce.MoreHorizontal,{size:12})})}),u.jsxs(po,{align:"end",sideOffset:6,className:"w-44",children:[u.jsxs(Fn,{onClick:S=>{S.preventDefault(),c(e.threadId)},children:[u.jsx(ce.Share2,{className:"mr-2 h-4 w-4"}),"Share thread"]}),h&&n!==e.threadId&&u.jsxs(Fn,{onClick:S=>{S.preventDefault(),s(e,S)},children:[u.jsx(ce.Edit3,{className:"mr-2 h-4 w-4"}),"Rename"]}),m&&d&&u.jsxs(Fn,{className:"text-red-400 hover:text-red-300",onClick:S=>{S.preventDefault(),d(e.threadId,S)},children:[u.jsx(ce.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",Dk=e=>e==="default"||e==="shared",Lk=()=>{if(typeof window>"u")return null;try{const e=window.localStorage.getItem(dm);if(Dk(e))return e}catch{}return null};function fm({defaultView:e}={}){const[t,n]=w.useState(()=>Lk()??e??"default");w.useEffect(()=>{if(!(typeof window>"u"))try{window.localStorage.setItem(dm,t)}catch{}},[t]);const r=w.useCallback(o=>{n(o)},[]);return{view:t,setView:r}}const $k=[{key:"default",label:"My chats"},{key:"shared",label:"Shared with you"}];function oi({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:b,shareTargetFilter:C}){const{threads:k,sharedThreads:S,currentThreadId:T,setCurrentThreadId:E,isLoading:j,isLoadingSharedThreads:_,actions:$,shareInFlight:F,shareStatus:U,clearShareStatus:X}=xr(),{createThread:R,deleteThread:K,renameThread:W,shareThread:z}=$,{loadThread:O}=to(),I=i??T,[G,J]=w.useState(Array.isArray(k)?k:[]),P=w.useRef(G.length>0),B=w.useRef(null),A=w.useRef(0),[D,q]=w.useState(null),[M,L]=w.useState(""),[Y,Z]=w.useState(!1),[oe,se]=w.useState(!1),[ie,le]=w.useState(null),[ye,De]=w.useState(""),We=v&&v.length>0?v:$k,Pe=fm({defaultView:m}),$e=g??Pe,lt=h??$e.view,ut=w.useCallback(ne=>{h||$e.setView(ne),f==null||f(ne)},[h,f,$e]),yt=We.find(ne=>ne.key===lt)??We[0],qe=ne=>{le(ne),De(""),se(!0)},Xe=()=>{se(!1),le(null),De(""),X()},Ve=w.useCallback(async ne=>{if(!(!ie||F)&&ne.id)try{await z(ie,ne.id),setTimeout(()=>Xe(),600)}catch(we){console.error("Failed to share thread:",we)}},[Xe,F,ie,z]),Le=w.useMemo(()=>{const ne=y??[],we=ye.trim().toLowerCase();return we?C?ne.filter(pe=>C(pe,we)):ne.filter(pe=>`${pe.label} ${pe.secondaryLabel??""}`.toLowerCase().includes(we)):ne},[y,ye,C]),Ae=lt==="shared",dt=Ae?S:G,Rt=Ae?_:j,tt=Ae?"No shared conversations yet":"No conversations yet",st=ne=>{const we=ne.sharedAt?` • ${Ue(ne.sharedAt)}`:"";return`Shared by ${ne.sharedByUserId}${we}`},gt=ne=>"sharedByUserId"in ne;w.useEffect(()=>{const ne=Array.isArray(k)?k:[];if(ne.length>0){P.current=!0,J(ne);return}j||(P.current=!1,J(ne))},[k,j]),w.useEffect(()=>{if(!B.current)return;const ne=B.current.querySelector("[data-radix-scroll-area-viewport]");if(!ne)return;let we=null,pe=null;return we=requestAnimationFrame(()=>{pe=requestAnimationFrame(()=>{ne.scrollTop=A.current})}),()=>{we!==null&&cancelAnimationFrame(we),pe!==null&&cancelAnimationFrame(pe)}},[G]);const St=async ne=>{try{E(ne),await O(ne),a==null||a(ne),l==null||l(ne)}catch(we){console.error("Failed to select thread:",we)}},xt=async()=>{try{Z(!0);const ne=await R();ne&&(c==null||c(ne),a==null||a(ne))}catch(ne){console.error("Failed to create thread:",ne)}finally{Z(!1)}},rn=async(ne,we)=>{if(we.stopPropagation(),!!confirm("Delete this thread?")){if(B.current){const pe=B.current.querySelector("[data-radix-scroll-area-viewport]");pe&&(A.current=pe.scrollTop)}try{await K(ne),d==null||d(ne)}catch(pe){console.error("Failed to delete thread:",pe)}}},It=(ne,we)=>{we.stopPropagation(),q(ne.threadId),L(ne.title||`Thread ${ne.threadId.slice(0,8)}`)},mn=async ne=>{if(M.trim())try{await W(ne,M.trim()),q(null),L("")}catch(we){console.error("Failed to update title:",we)}},Zt=()=>{q(null),L("")},Ue=ne=>{if(!ne)return"";try{const we=new Date(ne),ue=new Date().getTime()-we.getTime(),Ce=Math.floor(ue/(1e3*60*60*24));return Ce===0?we.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):Ce===1?"Yesterday":Ce<7?`${Ce} days ago`:we.toLocaleDateString()}catch{return""}},Fe=ne=>ne.title||`Thread ${ne.threadId.slice(0,8)}`,vt=ne=>{const we=Fe(ne);return we.length<=um?we:`${we.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(Qe,{onClick:xt,disabled:Y||j,className:s.createButton||"px-3 py-2 gap-1",size:"sm",variant:"ghost",title:Y?"Creating...":"New Chat",children:[u.jsx(ce.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(Ts,{children:[u.jsx(ks,{asChild:!0,children:u.jsx(Qe,{variant:"outline",size:"sm",className:"text-[11px] text-slate-700 dark:text-slate-200 border border-slate-300 dark:border-slate-600 bg-white dark:bg-slate-900 hover:bg-slate-50 dark:hover:bg-slate-800 px-2 py-0",children:yt.label})}),u.jsx(po,{align:"start",sideOffset:6,className:"w-40",children:We.map(ne=>u.jsxs(Fn,{className:"justify-between text-[12px]",onClick:we=>{we.preventDefault(),ut(ne.key)},children:[u.jsx("span",{children:ne.label}),lt===ne.key&&u.jsx(ce.Check,{className:"h-3 w-3"})]},ne.key))})]})]})]}),u.jsx(_l,{ref:B,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:Rt?u.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-8 text-slate-400",children:[u.jsx(ce.Loader2,{className:"h-5 w-5 animate-spin"}),u.jsx("span",{className:"text-sm",children:"Loading threads…"})]}):dt.length===0?u.jsxs("div",{className:"text-center py-8 text-slate-400",children:[u.jsx(ce.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:tt})]}):dt.slice().sort((ne,we)=>new Date(we.updatedAt||we.createdAt||"").getTime()-new Date(ne.updatedAt||ne.createdAt||"").getTime()).map(ne=>u.jsx(cm,{thread:ne,isActive:I===ne.threadId,editingThreadId:D,editingTitle:M,onSelect:St,onStartEditing:It,onEditingTitleChange:we=>L(we),onSaveEditing:mn,onCancelEditing:Zt,onShare:()=>qe(ne.threadId),onDelete:rn,showEditTitle:r,showDeleteButton:n,formatDate:Ue,getDisplayThreadTitle:vt,secondaryLine:Ae&&gt(ne)?st(ne):void 0,itemClassName:s.threadItem,activeItemClassName:s.activeThread},ne.threadId))})}),u.jsx(tl,{open:oe,onOpenChange:ne=>!ne&&Xe(),children:u.jsxs(Hs,{className:"max-w-md p-0",children:[u.jsx(Us,{children:u.jsx(Ws,{children:"Share thread"})}),u.jsxs(yl,{children:[u.jsx(Sl,{autoFocus:!0,value:ye,onValueChange:ne=>De(ne),placeholder:"Search for recipients..."}),u.jsxs(Cl,{children:[U&&u.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-xs text-muted-foreground",children:[F&&u.jsx(ce.Loader2,{className:"h-3 w-3 animate-spin"}),u.jsx("span",{className:U.startsWith("Failed")?"text-red-500":U.startsWith("Shared")?"text-emerald-500":"text-slate-600 dark:text-slate-400",children:U})]}),u.jsx(Tl,{children:b?u.jsxs("span",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(ce.Loader2,{className:"h-4 w-4 animate-spin"}),"Loading recipients…"]}):"No matching recipients found"}),Le.length>0&&u.jsx(kl,{heading:"Recipients",children:Le.map(ne=>u.jsx(El,{onSelect:()=>Ve(ne),children:u.jsxs("div",{className:"flex flex-col items-start text-sm",children:[u.jsx("span",{className:"font-medium",children:ne.label}),ne.secondaryLabel&&u.jsx("span",{className:"text-xs text-muted-foreground",children:ne.secondaryLabel})]})},ne.id))})]})]})]})})]})}function Fk({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=w.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(Or,{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(oi,{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(Or,{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(oi,{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(Or,{onError:s.onError,enableFileUpload:!0})})]})})}function Bk({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(Or,{})})})}function zk({placeholder:e,onMessageSent:t}){const[n,r]=w.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(ce.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(ce.History,{size:14}),"History"]})})]}),u.jsx("div",{className:"flex-1 min-h-0",children:n==="chat"?u.jsx(Or,{placeholder:e??"Ask Serti AI anything...",autoFocus:!0,className:"h-full",onMessageSent:t}):u.jsx(oi,{showCreateButton:!0,className:"h-full",onThreadSelect:()=>r("chat")})})]})}function Hk({className:e="",placeholder:t,isAuthenticated:n=!0,onMessageSent:r,widgetTitle:o="Serti AI Navigator",widgetSubtitle:s="AI-Powered Assistant",...i}){const[a,l]=w.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(Qe,{variant:"ghost",size:"sm",className:"text-white hover:bg-white/10 h-8 w-8 p-0",title:"Options",children:u.jsx(ce.MoreHorizontal,{size:16})}),u.jsx(Qe,{variant:"ghost",size:"sm",className:"text-white hover:bg-white/10 h-8 w-8 p-0",title:"Compose",children:u.jsx(ce.Edit3,{size:16})}),u.jsx(Qe,{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(ce.Maximize2,{size:14}):u.jsx(ce.Minimize2,{size:14})})]})]})}),!a&&u.jsx("div",{className:"h-96 flex flex-col",children:u.jsx(zk,{placeholder:t,onMessageSent:r})})]})})}):null}function Uk({label:e="New chat",children:t,className:n,variant:r="ghost",size:o="sm",...s}){return u.jsxs(Qe,{variant:r,size:o,className:te("gap-2 rounded-full px-3 font-semibold transition-all hover:scale-[1.01]",n),...s,children:[u.jsx(ce.Edit3,{size:16}),t??e]})}var Wk="Label",hm=p.forwardRef((e,t)=>u.jsx(me.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=Wk;var pm=hm;const Vk=Hr.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:te(Vk(),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"}),Kk="VisuallyHidden",si=p.forwardRef((e,t)=>u.jsx(me.span,{...e,ref:t,style:{...xm,...e.style}}));si.displayName=Kk;var qk=si,Gk=[" ","Enter","ArrowUp","ArrowDown"],Yk=[" ","Enter"],dr="Select",[ii,ai,Xk]=Jo(dr),[Fr,L1]=an(dr,[Xk,Ir]),li=Ir(),[Jk,qn]=Fr(dr),[Zk,Qk]=Fr(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=li(t),[x,y]=p.useState(null),[b,C]=p.useState(null),[k,S]=p.useState(!1),T=Zo(c),[E,j]=On({prop:r,defaultProp:o??!1,onChange:s,caller:dr}),[_,$]=On({prop:i,defaultProp:a,onChange:l,caller:dr}),F=p.useRef(null),U=x?v||!!x.closest("form"):!0,[X,R]=p.useState(new Set),K=Array.from(X).map(W=>W.props.value).join(";");return u.jsx(ia,{...g,children:u.jsxs(Jk,{required:f,scope:t,trigger:x,onTriggerChange:y,valueNode:b,onValueNodeChange:C,valueNodeHasChildren:k,onValueNodeHasChildrenChange:S,contentId:At(),value:_,onValueChange:$,open:E,onOpenChange:j,dir:T,triggerPointerDownPosRef:F,disabled:m,children:[u.jsx(ii.Provider,{scope:t,children:u.jsx(Zk,{scope:e.__scopeSelect,onNativeOptionAdd:p.useCallback(W=>{R(z=>new Set(z).add(W))},[]),onNativeOptionRemove:p.useCallback(W=>{R(z=>{const O=new Set(z);return O.delete(W),O})},[]),children:n})}),U?u.jsxs(Hm,{"aria-hidden":!0,required:f,tabIndex:-1,name:d,autoComplete:h,value:_,onChange:W=>$(W.target.value),disabled:m,form:v,children:[_===void 0?u.jsx("option",{value:""}):null,Array.from(X)]},K):null]})})};vm.displayName=dr;var wm="SelectTrigger",bm=p.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=li(n),i=qn(wm,n),a=i.disabled||r,l=Me(t,i.onTriggerChange),c=ai(n),d=p.useRef("touch"),[h,m,f]=Wm(g=>{const x=c().filter(C=>!C.disabled),y=x.find(C=>C.value===i.value),b=Vm(x,g,y);b!==void 0&&i.onValueChange(b.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(aa,{asChild:!0,...s,children:u.jsx(me.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:ae(o.onClick,g=>{g.currentTarget.focus(),d.current!=="mouse"&&v(g)}),onPointerDown:ae(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:ae(o.onKeyDown,g=>{const x=h.current!=="";!(g.ctrlKey||g.altKey||g.metaKey)&&g.key.length===1&&m(g.key),!(x&&g.key===" ")&&Gk.includes(g.key)&&(v(),g.preventDefault())})})})});bm.displayName=wm;var ym="SelectValue",Sm=p.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=qn(ym,n),{onValueNodeHasChildrenChange:c}=l,d=s!==void 0,h=Me(t,l.onValueNodeChange);return Et(()=>{c(d)},[c,d]),u.jsx(me.span,{...a,ref:h,style:{pointerEvents:"none"},children:Um(l.value)?u.jsx(u.Fragment,{children:i}):s})});Sm.displayName=ym;var eE="SelectIcon",Cm=p.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return u.jsx(me.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});Cm.displayName=eE;var tE="SelectPortal",Tm=e=>u.jsx(io,{asChild:!0,...e});Tm.displayName=tE;var fr="SelectContent",km=p.forwardRef((e,t)=>{const n=qn(fr,e.__scopeSelect),[r,o]=p.useState();if(Et(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?Ur.createPortal(u.jsx(Em,{scope:e.__scopeSelect,children:u.jsx(ii.Slot,{scope:e.__scopeSelect,children:u.jsx("div",{children:e.children})})}),s):null}return u.jsx(Im,{...e,ref:t})});km.displayName=fr;var hn=10,[Em,Gn]=Fr(fr),nE="SelectContentImpl",rE=Vt.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,b=qn(fr,n),[C,k]=p.useState(null),[S,T]=p.useState(null),E=Me(t,M=>k(M)),[j,_]=p.useState(null),[$,F]=p.useState(null),U=ai(n),[X,R]=p.useState(!1),K=p.useRef(!1);p.useEffect(()=>{if(C)return ha(C)},[C]),Wi();const W=p.useCallback(M=>{const[L,...Y]=U().map(se=>se.ref.current),[Z]=Y.slice(-1),oe=document.activeElement;for(const se of M)if(se===oe||(se==null||se.scrollIntoView({block:"nearest"}),se===L&&S&&(S.scrollTop=0),se===Z&&S&&(S.scrollTop=S.scrollHeight),se==null||se.focus(),document.activeElement!==oe))return},[U,S]),z=p.useCallback(()=>W([j,C]),[W,j,C]);p.useEffect(()=>{X&&z()},[X,z]);const{onOpenChange:O,triggerPointerDownPosRef:I}=b;p.useEffect(()=>{if(C){let M={x:0,y:0};const L=Z=>{var oe,se;M={x:Math.abs(Math.round(Z.pageX)-(((oe=I.current)==null?void 0:oe.x)??0)),y:Math.abs(Math.round(Z.pageY)-(((se=I.current)==null?void 0:se.y)??0))}},Y=Z=>{M.x<=10&&M.y<=10?Z.preventDefault():C.contains(Z.target)||O(!1),document.removeEventListener("pointermove",L),I.current=null};return I.current!==null&&(document.addEventListener("pointermove",L),document.addEventListener("pointerup",Y,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",L),document.removeEventListener("pointerup",Y,{capture:!0})}}},[C,O,I]),p.useEffect(()=>{const M=()=>O(!1);return window.addEventListener("blur",M),window.addEventListener("resize",M),()=>{window.removeEventListener("blur",M),window.removeEventListener("resize",M)}},[O]);const[G,J]=Wm(M=>{const L=U().filter(oe=>!oe.disabled),Y=L.find(oe=>oe.ref.current===document.activeElement),Z=Vm(L,M,Y);Z&&setTimeout(()=>Z.ref.current.focus())}),P=p.useCallback((M,L,Y)=>{const Z=!K.current&&!Y;(b.value!==void 0&&b.value===L||Z)&&(_(M),Z&&(K.current=!0))},[b.value]),B=p.useCallback(()=>C==null?void 0:C.focus(),[C]),A=p.useCallback((M,L,Y)=>{const Z=!K.current&&!Y;(b.value!==void 0&&b.value===L||Z)&&F(M)},[b.value]),D=r==="popper"?Ml:Nm,q=D===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:C,viewport:S,onViewportChange:T,itemRefCallback:P,selectedItem:j,onItemLeave:B,itemTextRefCallback:A,focusSelectedItem:z,selectedItemText:$,position:r,isPositioned:X,searchRef:G,children:u.jsx(vs,{as:rE,allowPinchZoom:!0,children:u.jsx(Qo,{asChild:!0,trapped:b.open,onMountAutoFocus:M=>{M.preventDefault()},onUnmountAutoFocus:ae(o,M=>{var L;(L=b.trigger)==null||L.focus({preventScroll:!0}),M.preventDefault()}),children:u.jsx(Sr,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:M=>M.preventDefault(),onDismiss:()=>b.onOpenChange(!1),children:u.jsx(D,{role:"listbox",id:b.contentId,"data-state":b.open?"open":"closed",dir:b.dir,onContextMenu:M=>M.preventDefault(),...y,...q,onPlaced:()=>R(!0),ref:E,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:ae(y.onKeyDown,M=>{const L=M.ctrlKey||M.altKey||M.metaKey;if(M.key==="Tab"&&M.preventDefault(),!L&&M.key.length===1&&J(M.key),["ArrowUp","ArrowDown","Home","End"].includes(M.key)){let Z=U().filter(oe=>!oe.disabled).map(oe=>oe.ref.current);if(["ArrowUp","End"].includes(M.key)&&(Z=Z.slice().reverse()),["ArrowUp","ArrowDown"].includes(M.key)){const oe=M.target,se=Z.indexOf(oe);Z=Z.slice(se+1)}setTimeout(()=>W(Z)),M.preventDefault()}})})})})})})});Im.displayName=nE;var oE="SelectItemAlignedPosition",Nm=p.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=qn(fr,n),i=Gn(fr,n),[a,l]=p.useState(null),[c,d]=p.useState(null),h=Me(t,E=>d(E)),m=ai(n),f=p.useRef(!1),v=p.useRef(!0),{viewport:g,selectedItem:x,selectedItemText:y,focusSelectedItem:b}=i,C=p.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&c&&g&&x&&y){const E=s.trigger.getBoundingClientRect(),j=c.getBoundingClientRect(),_=s.valueNode.getBoundingClientRect(),$=y.getBoundingClientRect();if(s.dir!=="rtl"){const oe=$.left-j.left,se=_.left-oe,ie=E.left-se,le=E.width+ie,ye=Math.max(le,j.width),De=window.innerWidth-hn,We=Il(se,[hn,Math.max(hn,De-ye)]);a.style.minWidth=le+"px",a.style.left=We+"px"}else{const oe=j.right-$.right,se=window.innerWidth-_.right-oe,ie=window.innerWidth-E.right-se,le=E.width+ie,ye=Math.max(le,j.width),De=window.innerWidth-hn,We=Il(se,[hn,Math.max(hn,De-ye)]);a.style.minWidth=le+"px",a.style.right=We+"px"}const F=m(),U=window.innerHeight-hn*2,X=g.scrollHeight,R=window.getComputedStyle(c),K=parseInt(R.borderTopWidth,10),W=parseInt(R.paddingTop,10),z=parseInt(R.borderBottomWidth,10),O=parseInt(R.paddingBottom,10),I=K+W+X+O+z,G=Math.min(x.offsetHeight*5,I),J=window.getComputedStyle(g),P=parseInt(J.paddingTop,10),B=parseInt(J.paddingBottom,10),A=E.top+E.height/2-hn,D=U-A,q=x.offsetHeight/2,M=x.offsetTop+q,L=K+W+M,Y=I-L;if(L<=A){const oe=F.length>0&&x===F[F.length-1].ref.current;a.style.bottom="0px";const se=c.clientHeight-g.offsetTop-g.offsetHeight,ie=Math.max(D,q+(oe?B:0)+se+z),le=L+ie;a.style.height=le+"px"}else{const oe=F.length>0&&x===F[0].ref.current;a.style.top="0px";const ie=Math.max(A,K+g.offsetTop+(oe?P:0)+q)+Y;a.style.height=ie+"px",g.scrollTop=L-A+g.offsetTop}a.style.margin=`${hn}px 0`,a.style.minHeight=G+"px",a.style.maxHeight=U+"px",r==null||r(),requestAnimationFrame(()=>f.current=!0)}},[m,s.trigger,s.valueNode,a,c,g,x,y,s.dir,r]);Et(()=>C(),[C]);const[k,S]=p.useState();Et(()=>{c&&S(window.getComputedStyle(c).zIndex)},[c]);const T=p.useCallback(E=>{E&&v.current===!0&&(C(),b==null||b(),v.current=!1)},[C,b]);return u.jsx(iE,{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(me.div,{...o,ref:h,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Nm.displayName=oE;var sE="SelectPopperPosition",Ml=p.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=hn,...s}=e,i=li(n);return u.jsx(la,{...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=sE;var[iE,Ol]=Fr(fr,{}),Dl="SelectViewport",Am=p.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=Gn(Dl,n),i=Ol(Dl,n),a=Me(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(ii.Slot,{scope:n,children:u.jsx(me.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:ae(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-hn*2,g=parseFloat(h.style.minHeight),x=parseFloat(h.style.height),y=Math.max(g,x);if(y<v){const b=y+f,C=Math.min(v,b),k=b-C;h.style.height=C+"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",[aE,lE]=Fr(jm),cE=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=At();return u.jsx(aE,{scope:n,id:o,children:u.jsx(me.div,{role:"group","aria-labelledby":o,...r,ref:t})})});cE.displayName=jm;var Pm="SelectLabel",_m=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=lE(Pm,n);return u.jsx(me.div,{id:o.id,...r,ref:t})});_m.displayName=Pm;var ci="SelectItem",[uE,Rm]=Fr(ci),Mm=p.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=qn(ci,n),l=Gn(ci,n),c=a.value===r,[d,h]=p.useState(s??""),[m,f]=p.useState(!1),v=Me(t,b=>{var C;return(C=l.itemRefCallback)==null?void 0:C.call(l,b,r,o)}),g=At(),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(uE,{scope:n,value:r,disabled:o,textId:g,isSelected:c,onItemTextChange:p.useCallback(b=>{h(C=>C||((b==null?void 0:b.textContent)??"").trim())},[]),children:u.jsx(ii.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:u.jsx(me.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:ae(i.onFocus,()=>f(!0)),onBlur:ae(i.onBlur,()=>f(!1)),onClick:ae(i.onClick,()=>{x.current!=="mouse"&&y()}),onPointerUp:ae(i.onPointerUp,()=>{x.current==="mouse"&&y()}),onPointerDown:ae(i.onPointerDown,b=>{x.current=b.pointerType}),onPointerMove:ae(i.onPointerMove,b=>{var C;x.current=b.pointerType,o?(C=l.onItemLeave)==null||C.call(l):x.current==="mouse"&&b.currentTarget.focus({preventScroll:!0})}),onPointerLeave:ae(i.onPointerLeave,b=>{var C;b.currentTarget===document.activeElement&&((C=l.onItemLeave)==null||C.call(l))}),onKeyDown:ae(i.onKeyDown,b=>{var k;((k=l.searchRef)==null?void 0:k.current)!==""&&b.key===" "||(Yk.includes(b.key)&&y(),b.key===" "&&b.preventDefault())})})})})});Mm.displayName=ci;var Po="SelectItemText",Om=p.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=qn(Po,n),a=Gn(Po,n),l=Rm(Po,n),c=Qk(Po,n),[d,h]=p.useState(null),m=Me(t,y=>h(y),l.onItemTextChange,y=>{var b;return(b=a.itemTextRefCallback)==null?void 0:b.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 Et(()=>(g(v),()=>x(v)),[g,x,v]),u.jsxs(u.Fragment,{children:[u.jsx(me.span,{id:l.textId,...s,ref:m}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?Ur.createPortal(s.children,i.valueNode):null]})});Om.displayName=Po;var Dm="SelectItemIndicator",Lm=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return Rm(Dm,n).isSelected?u.jsx(me.span,{"aria-hidden":!0,...r,ref:t}):null});Lm.displayName=Dm;var Ll="SelectScrollUpButton",$m=p.forwardRef((e,t)=>{const n=Gn(Ll,e.__scopeSelect),r=Ol(Ll,e.__scopeSelect),[o,s]=p.useState(!1),i=Me(t,r.onScrollButtonChange);return Et(()=>{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=Gn($l,e.__scopeSelect),r=Ol($l,e.__scopeSelect),[o,s]=p.useState(!1),i=Me(t,r.onScrollButtonChange);return Et(()=>{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=Gn("SelectScrollButton",n),i=p.useRef(null),a=ai(n),l=p.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return p.useEffect(()=>()=>l(),[l]),Et(()=>{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(me.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:ae(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:ae(o.onPointerMove,()=>{var c;(c=s.onItemLeave)==null||c.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:ae(o.onPointerLeave,()=>{l()})})}),dE="SelectSeparator",zm=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return u.jsx(me.div,{"aria-hidden":!0,...r,ref:t})});zm.displayName=dE;var Fl="SelectArrow",fE=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=li(n),s=qn(Fl,n),i=Gn(Fl,n);return s.open&&i.position==="popper"?u.jsx(ca,{...o,...r,ref:t}):null});fE.displayName=Fl;var hE="SelectBubbleInput",Hm=p.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=p.useRef(null),s=Me(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(me.select,{...n,style:{...xm,...n.style},ref:s,defaultValue:t})});Hm.displayName=hE;function Um(e){return e===""||e===void 0}function Wm(e){const t=pt(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=pE(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 pE(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var mE=vm,Km=bm,gE=Sm,xE=Cm,vE=Tm,qm=km,wE=Am,Gm=_m,Ym=Mm,bE=Om,yE=Lm,Xm=$m,Jm=Fm,Zm=zm;const SE=mE,CE=gE,Qm=p.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Km,{ref:r,className:te("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(xE,{asChild:!0,children:u.jsx(ce.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:te("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(ce.ChevronUp,{className:"h-4 w-4"})}));eg.displayName=Xm.displayName;const tg=p.forwardRef(({className:e,...t},n)=>u.jsx(Jm,{ref:n,className:te("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(ce.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(vE,{children:u.jsxs(qm,{ref:o,className:te("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(wE,{className:te("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 TE=p.forwardRef(({className:e,...t},n)=>u.jsx(Gm,{ref:n,className:te("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));TE.displayName=Gm.displayName;const rg=p.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Ym,{ref:r,className:te("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(yE,{children:u.jsx(ce.Check,{className:"h-4 w-4"})})}),u.jsx(bE,{children:t})]}));rg.displayName=Ym.displayName;const kE=p.forwardRef(({className:e,...t},n)=>u.jsx(Zm,{ref:n,className:te("-mx-1 my-1 h-px bg-muted",e),...t}));kE.displayName=Zm.displayName;var EE="Separator",og="horizontal",IE=["horizontal","vertical"],sg=p.forwardRef((e,t)=>{const{decorative:n,orientation:r=og,...o}=e,s=NE(r)?r:og,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return u.jsx(me.div,{"data-orientation":s,...a,...o,ref:t})});sg.displayName=EE;function NE(e){return IE.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:te("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));ag.displayName=ig.displayName;var ui="Switch",[AE,$1]=an(ui),[jE,PE]=AE(ui),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=Me(t,C=>f(C)),g=p.useRef(!1),x=m?d||!!m.closest("form"):!0,[y,b]=On({prop:o,defaultProp:s??!1,onChange:c,caller:ui});return u.jsxs(jE,{scope:n,checked:y,disabled:a,children:[u.jsx(me.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:ae(e.onClick,C=>{b(k=>!k),x&&(g.current=C.isPropagationStopped(),g.current||C.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=ui;var cg="SwitchThumb",ug=p.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=PE(cg,n);return u.jsx(me.span,{"data-state":fg(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});ug.displayName=cg;var _E="SwitchBubbleInput",dg=p.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=p.useRef(null),a=Me(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=_E;function fg(e){return e?"checked":"unchecked"}var hg=lg,RE=ug;const pg=p.forwardRef(({className:e,...t},n)=>u.jsx(hg,{className:te("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(RE,{className:te("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 ME=Qa,OE=fT,DE=el,mg=p.forwardRef(({className:e,...t},n)=>u.jsx(ko,{className:te("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=ko.displayName;const LE=Hr.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(DE,{children:[u.jsx(mg,{}),u.jsxs(Eo,{ref:o,className:te(LE({side:e}),t),...r,children:[n,u.jsxs(ip,{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(ce.X,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));gg.displayName=Eo.displayName;const xg=({className:e,...t})=>u.jsx("div",{className:te("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(ar,{ref:n,className:te("text-lg font-semibold text-foreground",e),...t}));vg.displayName=ar.displayName;const wg=p.forwardRef(({className:e,...t},n)=>u.jsx(zs,{ref:n,className:te("text-sm text-muted-foreground",e),...t}));wg.displayName=zs.displayName;var[di,F1]=an("Tooltip",[Ir]),fi=Ir(),bg="TooltipProvider",$E=700,Bl="tooltip.open",[FE,zl]=di(bg),yg=e=>{const{__scopeTooltip:t,delayDuration:n=$E,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(FE,{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=bg;var _o="Tooltip",[BE,hi]=di(_o),Sg=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:s,disableHoverableContent:i,delayDuration:a}=e,l=zl(_o,e.__scopeTooltip),c=fi(t),[d,h]=p.useState(null),m=At(),f=p.useRef(0),v=i??l.disableHoverableContent,g=a??l.delayDuration,x=p.useRef(!1),[y,b]=On({prop:r,defaultProp:o??!1,onChange:E=>{E?(l.onOpen(),document.dispatchEvent(new CustomEvent(Bl))):l.onClose(),s==null||s(E)},caller:_o}),C=p.useMemo(()=>y?x.current?"delayed-open":"instant-open":"closed",[y]),k=p.useCallback(()=>{window.clearTimeout(f.current),f.current=0,x.current=!1,b(!0)},[b]),S=p.useCallback(()=>{window.clearTimeout(f.current),f.current=0,b(!1)},[b]),T=p.useCallback(()=>{window.clearTimeout(f.current),f.current=window.setTimeout(()=>{x.current=!0,b(!0),f.current=0},g)},[g,b]);return p.useEffect(()=>()=>{f.current&&(window.clearTimeout(f.current),f.current=0)},[]),u.jsx(ia,{...c,children:u.jsx(BE,{scope:t,contentId:m,open:y,stateAttribute:C,trigger:d,onTriggerChange:h,onTriggerEnter:p.useCallback(()=>{l.isOpenDelayedRef.current?T():k()},[l.isOpenDelayedRef,T,k]),onTriggerLeave:p.useCallback(()=>{v?S():(window.clearTimeout(f.current),f.current=0)},[S,v]),onOpen:k,onClose:S,disableHoverableContent:v,children:n})})};Sg.displayName=_o;var Hl="TooltipTrigger",Cg=p.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=hi(Hl,n),s=zl(Hl,n),i=fi(n),a=p.useRef(null),l=Me(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(aa,{asChild:!0,...i,children:u.jsx(me.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:l,onPointerMove:ae(e.onPointerMove,m=>{m.pointerType!=="touch"&&!d.current&&!s.isPointerInTransitRef.current&&(o.onTriggerEnter(),d.current=!0)}),onPointerLeave:ae(e.onPointerLeave,()=>{o.onTriggerLeave(),d.current=!1}),onPointerDown:ae(e.onPointerDown,()=>{o.open&&o.onClose(),c.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:ae(e.onFocus,()=>{c.current||o.onOpen()}),onBlur:ae(e.onBlur,o.onClose),onClick:ae(e.onClick,o.onClose)})})});Cg.displayName=Hl;var zE="TooltipPortal",[B1,HE]=di(zE,{forceMount:void 0}),Br="TooltipContent",Tg=p.forwardRef((e,t)=>{const n=HE(Br,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...s}=e,i=hi(Br,e.__scopeTooltip);return u.jsx(Bt,{present:r||i.open,children:i.disableHoverableContent?u.jsx(kg,{side:o,...s,ref:t}):u.jsx(UE,{side:o,...s,ref:t})})}),UE=p.forwardRef((e,t)=>{const n=hi(Br,e.__scopeTooltip),r=zl(Br,e.__scopeTooltip),o=p.useRef(null),s=Me(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},b=GE(y,x.getBoundingClientRect()),C=YE(y,b),k=XE(g.getBoundingClientRect()),S=ZE([...C,...k]);a(S),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},b=(l==null?void 0:l.contains(x))||(d==null?void 0:d.contains(x)),C=!JE(y,i);b?m():C&&(m(),c())};return document.addEventListener("pointermove",v),()=>document.removeEventListener("pointermove",v)}},[l,d,i,c,m]),u.jsx(kg,{...e,ref:s})}),[WE,VE]=di(_o,{isInside:!1}),KE=Vt.createSlottable("TooltipContent"),kg=p.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:s,onPointerDownOutside:i,...a}=e,l=hi(Br,n),c=fi(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(Sr,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:h=>h.preventDefault(),onDismiss:d,children:u.jsxs(la,{"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(KE,{children:r}),u.jsx(WE,{scope:n,isInside:!0,children:u.jsx(qk,{id:l.contentId,role:"tooltip",children:o||r})})]})})});Tg.displayName=Br;var Eg="TooltipArrow",qE=p.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=fi(n);return VE(Eg,n).isInside?null:u.jsx(ca,{...o,...r,ref:t})});qE.displayName=Eg;function GE(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 YE(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 XE(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 JE(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 ZE(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),QE(t)}function QE(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 eI=yg,tI=Sg,nI=Cg,Ig=Tg;const rI=eI,oI=tI,sI=nI,Ng=p.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(Ig,{ref:r,sideOffset:t,className:te("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,iI,aI]=Jo("Toast"),[Ag,z1]=an("Toast",[aI]),[lI,pi]=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(lI,{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",cI=["F8"],Vl="toast.viewportPause",Kl="toast.viewportResume",_g=p.forwardRef((e,t)=>{const{__scopeToast:n,hotkey:r=cI,label:o="Notifications ({hotkey})",...s}=e,i=pi(Pg,n),a=iI(n),l=p.useRef(null),c=p.useRef(null),d=p.useRef(null),h=p.useRef(null),m=Me(t,h,i.onViewportChange),f=r.join("+").replace(/Key/g,"").replace(/Digit/g,""),v=i.toastCount>0;p.useEffect(()=>{const x=y=>{var C;r.length!==0&&r.every(k=>y[k]||y.code===k)&&((C=h.current)==null||C.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 b=()=>{if(!i.isClosePausedRef.current){const T=new CustomEvent(Vl);y.dispatchEvent(T),i.isClosePausedRef.current=!0}},C=()=>{if(i.isClosePausedRef.current){const T=new CustomEvent(Kl);y.dispatchEvent(T),i.isClosePausedRef.current=!1}},k=T=>{!x.contains(T.relatedTarget)&&C()},S=()=>{x.contains(document.activeElement)||C()};return x.addEventListener("focusin",b),x.addEventListener("focusout",k),x.addEventListener("pointermove",b),x.addEventListener("pointerleave",S),window.addEventListener("blur",b),window.addEventListener("focus",C),()=>{x.removeEventListener("focusin",b),x.removeEventListener("focusout",k),x.removeEventListener("pointermove",b),x.removeEventListener("pointerleave",S),window.removeEventListener("blur",b),window.removeEventListener("focus",C)}}},[v,i.isClosePausedRef]);const g=p.useCallback(({tabbingDirection:x})=>{const b=a().map(C=>{const k=C.ref.current,S=[k,...SI(k)];return x==="forwards"?S:S.reverse()});return(x==="forwards"?b.reverse():b).flat()},[a]);return p.useEffect(()=>{const x=h.current;if(x){const y=b=>{var S,T,E;const C=b.altKey||b.ctrlKey||b.metaKey;if(b.key==="Tab"&&!C){const j=document.activeElement,_=b.shiftKey;if(b.target===x&&_){(S=c.current)==null||S.focus();return}const U=g({tabbingDirection:_?"backwards":"forwards"}),X=U.findIndex(R=>R===j);Yl(U.slice(X+1))?b.preventDefault():_?(T=c.current)==null||T.focus():(E=d.current)==null||E.focus()}};return x.addEventListener("keydown",y),()=>x.removeEventListener("keydown",y)}},[a,g]),u.jsxs(Bw,{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(me.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=pi(Rg,n);return u.jsx(si,{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 Ro="Toast",uI="toast.swipeStart",dI="toast.swipeMove",fI="toast.swipeCancel",hI="toast.swipeEnd",Mg=p.forwardRef((e,t)=>{const{forceMount:n,open:r,defaultOpen:o,onOpenChange:s,...i}=e,[a,l]=On({prop:r,defaultProp:o??!0,onChange:s,caller:Ro});return u.jsx(Bt,{present:n||a,children:u.jsx(gI,{open:a,...i,ref:t,onClose:()=>l(!1),onPause:pt(e.onPause),onResume:pt(e.onResume),onSwipeStart:ae(e.onSwipeStart,c=>{c.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:ae(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:ae(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:ae(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=Ro;var[pI,mI]=Ag(Ro,{onClose(){}}),gI=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=pi(Ro,n),[x,y]=p.useState(null),b=Me(t,R=>y(R)),C=p.useRef(null),k=p.useRef(null),S=o||g.duration,T=p.useRef(0),E=p.useRef(S),j=p.useRef(0),{onToastAdd:_,onToastRemove:$}=g,F=pt(()=>{var K;(x==null?void 0:x.contains(document.activeElement))&&((K=g.viewport)==null||K.focus()),i()}),U=p.useCallback(R=>{!R||R===1/0||(window.clearTimeout(j.current),T.current=new Date().getTime(),j.current=window.setTimeout(F,R))},[F]);p.useEffect(()=>{const R=g.viewport;if(R){const K=()=>{U(E.current),c==null||c()},W=()=>{const z=new Date().getTime()-T.current;E.current=E.current-z,window.clearTimeout(j.current),l==null||l()};return R.addEventListener(Vl,W),R.addEventListener(Kl,K),()=>{R.removeEventListener(Vl,W),R.removeEventListener(Kl,K)}}},[g.viewport,S,l,c,U]),p.useEffect(()=>{s&&!g.isClosePausedRef.current&&U(S)},[s,S,g.isClosePausedRef,U]),p.useEffect(()=>(_(),()=>$()),[_,$]);const X=p.useMemo(()=>x?zg(x):null,[x]);return g.viewport?u.jsxs(u.Fragment,{children:[X&&u.jsx(xI,{__scopeToast:n,role:"status","aria-live":r==="foreground"?"assertive":"polite",children:X}),u.jsx(pI,{scope:n,onClose:F,children:Ur.createPortal(u.jsx(Wl.ItemSlot,{scope:n,children:u.jsx(Fw,{asChild:!0,onEscapeKeyDown:ae(a,()=>{g.isFocusedToastEscapeKeyDownRef.current||F(),g.isFocusedToastEscapeKeyDownRef.current=!1}),children:u.jsx(me.li,{tabIndex:0,"data-state":s?"open":"closed","data-swipe-direction":g.swipeDirection,...v,ref:b,style:{userSelect:"none",touchAction:"none",...e.style},onKeyDown:ae(e.onKeyDown,R=>{R.key==="Escape"&&(a==null||a(R.nativeEvent),R.nativeEvent.defaultPrevented||(g.isFocusedToastEscapeKeyDownRef.current=!0,F()))}),onPointerDown:ae(e.onPointerDown,R=>{R.button===0&&(C.current={x:R.clientX,y:R.clientY})}),onPointerMove:ae(e.onPointerMove,R=>{if(!C.current)return;const K=R.clientX-C.current.x,W=R.clientY-C.current.y,z=!!k.current,O=["left","right"].includes(g.swipeDirection),I=["left","up"].includes(g.swipeDirection)?Math.min:Math.max,G=O?I(0,K):0,J=O?0:I(0,W),P=R.pointerType==="touch"?10:2,B={x:G,y:J},A={originalEvent:R,delta:B};z?(k.current=B,mi(dI,h,A,{discrete:!1})):Hg(B,g.swipeDirection,P)?(k.current=B,mi(uI,d,A,{discrete:!1}),R.target.setPointerCapture(R.pointerId)):(Math.abs(K)>P||Math.abs(W)>P)&&(C.current=null)}),onPointerUp:ae(e.onPointerUp,R=>{const K=k.current,W=R.target;if(W.hasPointerCapture(R.pointerId)&&W.releasePointerCapture(R.pointerId),k.current=null,C.current=null,K){const z=R.currentTarget,O={originalEvent:R,delta:K};Hg(K,g.swipeDirection,g.swipeThreshold)?mi(hI,f,O,{discrete:!0}):mi(fI,m,O,{discrete:!0}),z.addEventListener("click",I=>I.preventDefault(),{once:!0})}})})})}),g.viewport)})]}):null}),xI=e=>{const{__scopeToast:t,children:n,...r}=e,o=pi(Ro,t),[s,i]=p.useState(!1),[a,l]=p.useState(!1);return bI(()=>i(!0)),p.useEffect(()=>{const c=window.setTimeout(()=>l(!0),1e3);return()=>window.clearTimeout(c)},[]),a?null:u.jsx(io,{asChild:!0,children:u.jsx(si,{...r,children:s&&u.jsxs(u.Fragment,{children:[o.label," ",n]})})})},vI="ToastTitle",Og=p.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(me.div,{...r,ref:t})});Og.displayName=vI;var wI="ToastDescription",Dg=p.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(me.div,{...r,ref:t})});Dg.displayName=wI;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=mI(Fg,n);return u.jsx(Bg,{asChild:!0,children:u.jsx(me.button,{type:"button",...r,ref:t,onClick:ae(e.onClick,o.onClose)})})});Gl.displayName=Fg;var Bg=p.forwardRef((e,t)=>{const{__scopeToast:n,altText:r,...o}=e;return u.jsx(me.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),yI(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 mi(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?zi(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 bI(e=()=>{}){const t=pt(e);Et(()=>{let n=0,r=0;return n=window.requestAnimationFrame(()=>r=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(n),window.cancelAnimationFrame(r)}},[t])}function yI(e){return e.nodeType===e.ELEMENT_NODE}function SI(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 CI=jg,Ug=_g,Wg=Mg,Vg=Og,Kg=Dg,qg=$g,Gg=Gl;const TI=CI,Yg=p.forwardRef(({className:e,...t},n)=>u.jsx(Ug,{ref:n,className:te("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 kI=Hr.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:te(kI({variant:t}),e),...n}));Xg.displayName=Wg.displayName;const EI=p.forwardRef(({className:e,...t},n)=>u.jsx(qg,{ref:n,className:te("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}));EI.displayName=qg.displayName;const Jg=p.forwardRef(({className:e,...t},n)=>u.jsx(Gg,{ref:n,className:te("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(ce.X,{className:"h-4 w-4"})}));Jg.displayName=Gg.displayName;const Zg=p.forwardRef(({className:e,...t},n)=>u.jsx(Vg,{ref:n,className:te("text-sm font-semibold",e),...t}));Zg.displayName=Vg.displayName;const Qg=p.forwardRef(({className:e,...t},n)=>u.jsx(Kg,{ref:n,className:te("text-sm opacity-90",e),...t}));Qg.displayName=Kg.displayName;function II(){const{toasts:e}=ol();return u.jsxs(TI,{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 NI=(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{}},AI=p.createContext(void 0),jI={setTheme:e=>{},themes:[]},PI=()=>{var e;return(e=p.useContext(AI))!=null?e:jI};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:`(${NI.toString()})(${d})`}})});var _I=e=>{switch(e){case"success":return OI;case"info":return LI;case"warning":return DI;case"error":return $I;default:return null}},RI=Array(12).fill(0),MI=({visible:e,className:t})=>w.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},w.createElement("div",{className:"sonner-spinner"},RI.map((n,r)=>w.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),OI=w.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},w.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"})),DI=w.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},w.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"})),LI=w.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},w.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"})),$I=w.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},w.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"})),FI=w.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"},w.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),w.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),BI=()=>{let[e,t]=w.useState(document.hidden);return w.useEffect(()=>{let n=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),e},Xl=1,zI=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],w.isValidElement(l))o=!1,this.create({id:n,type:"default",message:l});else if(UI(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}},Ut=new zI,HI=(e,t)=>{let n=(t==null?void 0:t.id)||Xl++;return Ut.addToast({title:e,...t,id:n}),n},UI=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",WI=HI,VI=()=>Ut.toasts,KI=()=>Ut.getActiveToasts();Object.assign(WI,{success:Ut.success,info:Ut.info,warning:Ut.warning,error:Ut.error,custom:Ut.custom,message:Ut.message,promise:Ut.promise,dismiss:Ut.dismiss,loading:Ut.loading},{getHistory:VI,getToasts:KI});function qI(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))}qI(`: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 gi(e){return e.label!==void 0}var GI=3,YI="32px",XI="16px",ex=4e3,JI=356,ZI=14,QI=20,e1=200;function pn(...e){return e.filter(Boolean).join(" ")}function t1(e){let[t,n]=e.split("-"),r=[];return t&&r.push(t),n&&r.push(n),r}var n1=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:b,index:C,toasts:k,expanded:S,removeToast:T,defaultRichColors:E,closeButton:j,style:_,cancelButtonStyle:$,actionButtonStyle:F,className:U="",descriptionClassName:X="",duration:R,position:K,gap:W,loadingIcon:z,expandByDefault:O,classNames:I,icons:G,closeButtonAriaLabel:J="Close toast",pauseWhenPageIsHidden:P}=e,[B,A]=w.useState(null),[D,q]=w.useState(null),[M,L]=w.useState(!1),[Y,Z]=w.useState(!1),[oe,se]=w.useState(!1),[ie,le]=w.useState(!1),[ye,De]=w.useState(!1),[We,Pe]=w.useState(0),[$e,lt]=w.useState(0),ut=w.useRef(f.duration||R||ex),yt=w.useRef(null),qe=w.useRef(null),Xe=C===0,Ve=C+1<=y,Le=f.type,Ae=f.dismissible!==!1,dt=f.className||"",Rt=f.descriptionClassName||"",tt=w.useMemo(()=>b.findIndex(ue=>ue.toastId===f.id)||0,[b,f.id]),st=w.useMemo(()=>{var ue;return(ue=f.closeButton)!=null?ue:j},[f.closeButton,j]),gt=w.useMemo(()=>f.duration||R||ex,[f.duration,R]),St=w.useRef(0),xt=w.useRef(0),rn=w.useRef(0),It=w.useRef(null),[mn,Zt]=K.split("-"),Ue=w.useMemo(()=>b.reduce((ue,Ce,Ge)=>Ge>=tt?ue:ue+Ce.height,0),[b,tt]),Fe=BI(),vt=f.invert||m,ne=Le==="loading";xt.current=w.useMemo(()=>tt*W+Ue,[tt,Ue]),w.useEffect(()=>{ut.current=gt},[gt]),w.useEffect(()=>{L(!0)},[]),w.useEffect(()=>{let ue=qe.current;if(ue){let Ce=ue.getBoundingClientRect().height;return lt(Ce),x(Ge=>[{toastId:f.id,height:Ce,position:f.position},...Ge]),()=>x(Ge=>Ge.filter(kt=>kt.toastId!==f.id))}},[x,f.id]),w.useLayoutEffect(()=>{if(!M)return;let ue=qe.current,Ce=ue.style.height;ue.style.height="auto";let Ge=ue.getBoundingClientRect().height;ue.style.height=Ce,lt(Ge),x(kt=>kt.find(Ie=>Ie.toastId===f.id)?kt.map(Ie=>Ie.toastId===f.id?{...Ie,height:Ge}:Ie):[{toastId:f.id,height:Ge,position:f.position},...kt])},[M,f.title,f.description,x,f.id]);let we=w.useCallback(()=>{Z(!0),Pe(xt.current),x(ue=>ue.filter(Ce=>Ce.toastId!==f.id)),setTimeout(()=>{T(f)},e1)},[f,T,x,xt]);w.useEffect(()=>{if(f.promise&&Le==="loading"||f.duration===1/0||f.type==="loading")return;let ue;return S||g||P&&Fe?(()=>{if(rn.current<St.current){let Ce=new Date().getTime()-St.current;ut.current=ut.current-Ce}rn.current=new Date().getTime()})():ut.current!==1/0&&(St.current=new Date().getTime(),ue=setTimeout(()=>{var Ce;(Ce=f.onAutoClose)==null||Ce.call(f,f),we()},ut.current)),()=>clearTimeout(ue)},[S,g,f,Le,P,Fe,we]),w.useEffect(()=>{f.delete&&we()},[we,f.delete]);function pe(){var ue,Ce,Ge;return G!=null&&G.loading?w.createElement("div",{className:pn(I==null?void 0:I.loader,(ue=f==null?void 0:f.classNames)==null?void 0:ue.loader,"sonner-loader"),"data-visible":Le==="loading"},G.loading):z?w.createElement("div",{className:pn(I==null?void 0:I.loader,(Ce=f==null?void 0:f.classNames)==null?void 0:Ce.loader,"sonner-loader"),"data-visible":Le==="loading"},z):w.createElement(MI,{className:pn(I==null?void 0:I.loader,(Ge=f==null?void 0:f.classNames)==null?void 0:Ge.loader),visible:Le==="loading"})}return w.createElement("li",{tabIndex:0,ref:qe,className:pn(U,dt,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[Le],(n=f==null?void 0:f.classNames)==null?void 0:n[Le]),"data-sonner-toast":"","data-rich-colors":(r=f.richColors)!=null?r:E,"data-styled":!(f.jsx||f.unstyled||v),"data-mounted":M,"data-promise":!!f.promise,"data-swiped":ye,"data-removed":Y,"data-visible":Ve,"data-y-position":mn,"data-x-position":Zt,"data-index":C,"data-front":Xe,"data-swiping":oe,"data-dismissible":Ae,"data-type":Le,"data-invert":vt,"data-swipe-out":ie,"data-swipe-direction":D,"data-expanded":!!(S||O&&M),style:{"--index":C,"--toasts-before":C,"--z-index":k.length-C,"--offset":`${Y?We:xt.current}px`,"--initial-height":O?"auto":`${$e}px`,..._,...f.style},onDragEnd:()=>{se(!1),A(null),It.current=null},onPointerDown:ue=>{ne||!Ae||(yt.current=new Date,Pe(xt.current),ue.target.setPointerCapture(ue.pointerId),ue.target.tagName!=="BUTTON"&&(se(!0),It.current={x:ue.clientX,y:ue.clientY}))},onPointerUp:()=>{var ue,Ce,Ge,kt;if(ie||!Ae)return;It.current=null;let Ie=Number(((ue=qe.current)==null?void 0:ue.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),_e=Number(((Ce=qe.current)==null?void 0:Ce.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),Be=new Date().getTime()-((Ge=yt.current)==null?void 0:Ge.getTime()),xe=B==="x"?Ie:_e,et=Math.abs(xe)/Be;if(Math.abs(xe)>=QI||et>.11){Pe(xt.current),(kt=f.onDismiss)==null||kt.call(f,f),q(B==="x"?Ie>0?"right":"left":_e>0?"down":"up"),we(),le(!0),De(!1);return}se(!1),A(null)},onPointerMove:ue=>{var Ce,Ge,kt,Ie;if(!It.current||!Ae||((Ce=window.getSelection())==null?void 0:Ce.toString().length)>0)return;let _e=ue.clientY-It.current.y,Be=ue.clientX-It.current.x,xe=(Ge=e.swipeDirections)!=null?Ge:t1(K);!B&&(Math.abs(Be)>1||Math.abs(_e)>1)&&A(Math.abs(Be)>Math.abs(_e)?"x":"y");let et={x:0,y:0};B==="y"?(xe.includes("top")||xe.includes("bottom"))&&(xe.includes("top")&&_e<0||xe.includes("bottom")&&_e>0)&&(et.y=_e):B==="x"&&(xe.includes("left")||xe.includes("right"))&&(xe.includes("left")&&Be<0||xe.includes("right")&&Be>0)&&(et.x=Be),(Math.abs(et.x)>0||Math.abs(et.y)>0)&&De(!0),(kt=qe.current)==null||kt.style.setProperty("--swipe-amount-x",`${et.x}px`),(Ie=qe.current)==null||Ie.style.setProperty("--swipe-amount-y",`${et.y}px`)}},st&&!f.jsx?w.createElement("button",{"aria-label":J,"data-disabled":ne,"data-close-button":!0,onClick:ne||!Ae?()=>{}:()=>{var ue;we(),(ue=f.onDismiss)==null||ue.call(f,f)},className:pn(I==null?void 0:I.closeButton,(o=f==null?void 0:f.classNames)==null?void 0:o.closeButton)},(s=G==null?void 0:G.close)!=null?s:FI):null,f.jsx||w.isValidElement(f.title)?f.jsx?f.jsx:typeof f.title=="function"?f.title():f.title:w.createElement(w.Fragment,null,Le||f.icon||f.promise?w.createElement("div",{"data-icon":"",className:pn(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||pe():null,f.type!=="loading"?f.icon||(G==null?void 0:G[Le])||_I(Le):null):null,w.createElement("div",{"data-content":"",className:pn(I==null?void 0:I.content,(a=f==null?void 0:f.classNames)==null?void 0:a.content)},w.createElement("div",{"data-title":"",className:pn(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?w.createElement("div",{"data-description":"",className:pn(X,Rt,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),w.isValidElement(f.cancel)?f.cancel:f.cancel&&gi(f.cancel)?w.createElement("button",{"data-button":!0,"data-cancel":!0,style:f.cancelButtonStyle||$,onClick:ue=>{var Ce,Ge;gi(f.cancel)&&Ae&&((Ge=(Ce=f.cancel).onClick)==null||Ge.call(Ce,ue),we())},className:pn(I==null?void 0:I.cancelButton,(d=f==null?void 0:f.classNames)==null?void 0:d.cancelButton)},f.cancel.label):null,w.isValidElement(f.action)?f.action:f.action&&gi(f.action)?w.createElement("button",{"data-button":!0,"data-action":!0,style:f.actionButtonStyle||F,onClick:ue=>{var Ce,Ge;gi(f.action)&&((Ge=(Ce=f.action).onClick)==null||Ge.call(Ce,ue),!ue.defaultPrevented&&we())},className:pn(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 r1(e,t){let n={};return[e,t].forEach((r,o)=>{let s=o===1,i=s?"--mobile-offset":"--offset",a=s?XI:YI;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 o1=w.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=GI,toastOptions:g,dir:x=tx(),gap:y=ZI,loadingIcon:b,icons:C,containerAriaLabel:k="Notifications",pauseWhenPageIsHidden:S}=e,[T,E]=w.useState([]),j=w.useMemo(()=>Array.from(new Set([r].concat(T.filter(P=>P.position).map(P=>P.position)))),[T,r]),[_,$]=w.useState([]),[F,U]=w.useState(!1),[X,R]=w.useState(!1),[K,W]=w.useState(d!=="system"?d:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),z=w.useRef(null),O=o.join("+").replace(/Key/g,"").replace(/Digit/g,""),I=w.useRef(null),G=w.useRef(!1),J=w.useCallback(P=>{E(B=>{var A;return(A=B.find(D=>D.id===P.id))!=null&&A.delete||Ut.dismiss(P.id),B.filter(({id:D})=>D!==P.id)})},[]);return w.useEffect(()=>Ut.subscribe(P=>{if(P.dismiss){E(B=>B.map(A=>A.id===P.id?{...A,delete:!0}:A));return}setTimeout(()=>{Mo.flushSync(()=>{E(B=>{let A=B.findIndex(D=>D.id===P.id);return A!==-1?[...B.slice(0,A),{...B[A],...P},...B.slice(A+1)]:[P,...B]})})})}),[]),w.useEffect(()=>{if(d!=="system"){W(d);return}if(d==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?W("dark"):W("light")),typeof window>"u")return;let P=window.matchMedia("(prefers-color-scheme: dark)");try{P.addEventListener("change",({matches:B})=>{W(B?"dark":"light")})}catch{P.addListener(({matches:A})=>{try{W(A?"dark":"light")}catch(D){console.error(D)}})}},[d]),w.useEffect(()=>{T.length<=1&&U(!1)},[T]),w.useEffect(()=>{let P=B=>{var A,D;o.every(q=>B[q]||B.code===q)&&(U(!0),(A=z.current)==null||A.focus()),B.code==="Escape"&&(document.activeElement===z.current||(D=z.current)!=null&&D.contains(document.activeElement))&&U(!1)};return document.addEventListener("keydown",P),()=>document.removeEventListener("keydown",P)},[o]),w.useEffect(()=>{if(z.current)return()=>{I.current&&(I.current.focus({preventScroll:!0}),I.current=null,G.current=!1)}},[z.current]),w.createElement("section",{ref:t,"aria-label":`${k} ${O}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},j.map((P,B)=>{var A;let[D,q]=P.split("-");return T.length?w.createElement("ol",{key:P,dir:x==="auto"?tx():x,tabIndex:-1,ref:z,className:a,"data-sonner-toaster":!0,"data-theme":K,"data-y-position":D,"data-lifted":F&&T.length>1&&!s,"data-x-position":q,style:{"--front-toast-height":`${((A=_[0])==null?void 0:A.height)||0}px`,"--width":`${JI}px`,"--gap":`${y}px`,...f,...r1(l,c)},onBlur:M=>{G.current&&!M.currentTarget.contains(M.relatedTarget)&&(G.current=!1,I.current&&(I.current.focus({preventScroll:!0}),I.current=null))},onFocus:M=>{M.target instanceof HTMLElement&&M.target.dataset.dismissible==="false"||G.current||(G.current=!0,I.current=M.relatedTarget)},onMouseEnter:()=>U(!0),onMouseMove:()=>U(!0),onMouseLeave:()=>{X||U(!1)},onDragEnd:()=>U(!1),onPointerDown:M=>{M.target instanceof HTMLElement&&M.target.dataset.dismissible==="false"||R(!0)},onPointerUp:()=>R(!1)},T.filter(M=>!M.position&&B===0||M.position===P).map((M,L)=>{var Y,Z;return w.createElement(n1,{key:M.id,icons:C,index:L,toast:M,defaultRichColors:h,duration:(Y=g==null?void 0:g.duration)!=null?Y:m,className:g==null?void 0:g.className,descriptionClassName:g==null?void 0:g.descriptionClassName,invert:n,visibleToasts:v,closeButton:(Z=g==null?void 0:g.closeButton)!=null?Z:i,interacting:X,position:P,style:g==null?void 0:g.style,unstyled:g==null?void 0:g.unstyled,classNames:g==null?void 0:g.classNames,cancelButtonStyle:g==null?void 0:g.cancelButtonStyle,actionButtonStyle:g==null?void 0:g.actionButtonStyle,removeToast:J,toasts:T.filter(oe=>oe.position==M.position),heights:_.filter(oe=>oe.position==M.position),setHeights:$,expandByDefault:s,gap:y,loadingIcon:b,expanded:F,pauseWhenPageIsHidden:S,swipeDirections:e.swipeDirections})})):null}))});const s1=({...e})=>{const{theme:t="system"}=PI();return u.jsx(o1,{theme:t,className:"toaster group",toastOptions:{classNames:{toast:"group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",description:"group-[.toast]:text-muted-foreground",actionButton:"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",cancelButton:"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground"}},...e})};H.Api=Hv,H.ApiClient=zv,H.ApiProvider=ru,H.ArtifactRenderer=Tp,H.Badge=Op,H.Button=Qe,H.Card=al,H.CardContent=dl,H.CardDescription=ul,H.CardHeader=ll,H.CardTitle=cl,H.ChatApi=Go,H.ChatApp=Fk,H.ChatInput=Wf,H.ChatInputRow=Vf,H.ChatInterface=Or,H.ChatProviders=br,H.ChatWidget=Hk,H.Command=yl,H.CommandEmpty=Tl,H.CommandGroup=kl,H.CommandInput=Sl,H.CommandItem=El,H.CommandList=Cl,H.DEFAULT_TIMEOUT_MS=Jc,H.Dialog=tl,H.DialogContent=Hs,H.DialogHeader=Us,H.DialogTitle=Ws,H.DropdownMenu=Ts,H.DropdownMenuContent=po,H.DropdownMenuItem=Fn,H.DropdownMenuTrigger=ks,H.FileViewerModal=cp,H.HISTORY_TIMEOUT_MS=Zc,H.Input=Rl,H.InterruptPartRenderer=Ip,H.Label=mm,H.MarkdownContent=cr,H.MessageComponent=Zs,H.MessageList=pl,H.MessageRow=hl,H.NewChatButton=Uk,H.PlotArtifact=Cp,H.SETTINGS_STORAGE_KEY=Bi,H.ScrollArea=_l,H.Select=SE,H.SelectContent=ng,H.SelectItem=rg,H.SelectTrigger=Qm,H.SelectValue=CE,H.Separator=ag,H.Sheet=ME,H.SheetContent=gg,H.SheetDescription=wg,H.SheetHeader=xg,H.SheetTitle=vg,H.SheetTrigger=OE,H.SimpleChat=Bk,H.SimpleJsonView=Js,H.Sonner=s1,H.StreamProgress=kp,H.Switch=pg,H.Textarea=Ea,H.ThinkingIndicator=Np,H.ThreadListItem=cm,H.ThreadManager=oi,H.ThreadStateProvider=Eu,H.ThreadsProvider=pu,H.TimelineColumn=vx,H.Toaster=II,H.ToolComponent=Rp,H.Tooltip=oI,H.TooltipContent=Ng,H.TooltipProvider=rI,H.TooltipTrigger=sI,H.UserTextContent=Ap,H.applySettings=Cw,H.buildCheckpointIndex=ec,H.buildCheckpointPreviewMap=ax,H.chatApiClient=Nn,H.del=_i,H.downloadFileById=eu,H.extractConfigFields=vi,H.fileToBase64=ou,H.get=qt,H.getChatToken=Yc,H.getCheckpointForMessage=lx,H.getCurrentSettings=Sw,H.getDefaultApiConfig=Ou,H.getDefaultChatSettings=Du,H.getFileContent=Mi,H.getFileInfo=Wv,H.getMessageAttemptInfo=tc,H.getMessageDomKey=fl,H.getPreviewForMessage=xi,H.httpClient=Kt,H.hydrateHistorySnapshots=Yn,H.isEnvelope=iu,H.listFiles=tu,H.loadStoredSettings=Lu,H.onChatTokenChanged=Xc,H.post=qo,H.processAttachments=su,H.put=Qc,H.readNumber=rc,H.readString=Rn,H.resolveChatBaseUrl=xn,H.saveSettings=$u,H.setChatToken=Ko,H.toPlainObject=_n,H.unwrap=Mt,H.useApi=Jr,H.useCheckpointIndex=nc,H.useFilePreview=jp,H.useHasChatSession=ww,H.useParsedMessageContent=Pp,H.useShallowStableValue=Pu,H.useStream=Fi,H.useStreamingHook=Fi,H.useThreadHistoryState=Su,H.useThreadManagerViewState=fm,H.useThreadState=to,H.useThreadStateUpdater=ku,H.useThreads=xr,H.useThreadsState=fu,H.viewFileById=Uv,Object.defineProperty(H,Symbol.toStringTag,{value:"Module"})});