teodor-new-chat-ui 4.3.480 → 4.3.482

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.
Files changed (20) hide show
  1. package/dist/features/messaging/components/chat/ChatInterface.d.ts +4 -3
  2. package/dist/features/messaging/components/message/MessageComponent.d.ts +2 -1
  3. package/dist/features/messaging/components/message/MessageList.d.ts +2 -1
  4. package/dist/features/messaging/components/message/MessageRow.d.ts +2 -1
  5. package/dist/features/messaging/components/message/ToolComponent.d.ts +35 -0
  6. package/dist/features/messaging/components/message/index.d.ts +2 -3
  7. package/dist/features/messaging/components/message/renderers/MessageContent.d.ts +3 -2
  8. package/dist/features/messaging/components/message/renderers/index.d.ts +6 -6
  9. package/dist/index.esm.js +6678 -6827
  10. package/dist/index.umd.js +48 -48
  11. package/package.json +1 -1
  12. package/dist/features/messaging/components/message/artifacts/ResearchTaskArtifact.d.ts +0 -18
  13. package/dist/features/messaging/components/message/tool/ToolComponent.d.ts +0 -24
  14. package/dist/features/messaging/components/message/tool/renderers/IssuesPayloadRenderer.d.ts +0 -6
  15. /package/dist/features/messaging/components/message/{tool/renderers → renderers/tool/artifacts}/ArtifactRenderer.d.ts +0 -0
  16. /package/dist/features/messaging/components/message/{artifacts → renderers/tool/artifacts/ArtifactTypes}/PlotArtifact.d.ts +0 -0
  17. /package/dist/features/messaging/components/message/{tool/renderers → renderers/tool/content}/SimpleJsonView.d.ts +0 -0
  18. /package/dist/features/messaging/components/message/{tool/renderers → renderers/tool/content}/StreamProgress.d.ts +0 -0
  19. /package/dist/features/messaging/components/message/{tool/renderers → renderers/user}/InterruptPartRenderer.d.ts +0 -0
  20. /package/dist/features/messaging/components/message/renderers/{shared → user}/UserTextContent.d.ts +0 -0
package/dist/index.umd.js CHANGED
@@ -1,4 +1,4 @@
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,Kt,Hr,lx,cx,le,Mo){"use strict";var mN=Object.defineProperty;var gN=(H,w,Kt)=>w in H?mN(H,w,{enumerable:!0,configurable:!0,writable:!0,value:Kt}):H[w]=Kt;var ix=(H,w,Kt)=>gN(H,typeof w!="symbol"?w+"":w,Kt);function Ql(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const h=Ql(w),Ur=Ql(Mo),ec=120;function ux(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>ec?`${n.slice(0,ec-3)}…`:n:""}function xi(e){return ux(e.content)||""}function dx(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 tc(e){const t=new Map,n=[],r=new Map,o=[];for(let c=0;c<e.length;c++){const d=e[c],p=d.checkpointId,m=p??`cp-${c}`,f=d.metadata??{},v=typeof f.step=="number"?f.step:null,x=typeof f.source=="string"?f.source:null;let g=null,b=null;const y=Array.isArray(d.messages)?d.messages:[];for(const T of y)T.role==="user"&&(b||(b=T),T.id&&(g=T.id));const S=d.next&&d.next.length>0?String(d.next[0]):null,k=d.parentConfig??null,C={id:m,step:v,source:x,createdAt:d.createdAt??null,namespace:d.checkpointNs??null,parentId:d.parentId??null,next:S,parentConfig:k,userMessageId:g};if(o.push(C),p&&t.set(p,C),p&&b){const T=xi(b);T&&r.set(p,T)}n.push({id:m,messageId:g,step:v,source:x,createdAt:d.createdAt??null,next:S,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((p,m)=>{const f=p.createdAt?Date.parse(p.createdAt):0;return(m.createdAt?Date.parse(m.createdAt):0)-f});const d=c.length;for(let p=0;p<c.length;p++){const m=c[p];m.attemptCount=d,m.attemptIndex=p,m.isLatestAttempt=p===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 p of t.values())p.userMessageId===c&&d.push(p);return d.length?(d.sort((p,m)=>{const f=typeof p.attemptIndex=="number"?p.attemptIndex:Number.MAX_SAFE_INTEGER,v=typeof m.attemptIndex=="number"?m.attemptIndex:Number.MAX_SAFE_INTEGER;return f-v}),d):[]}}}function nc(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 fx(e,t){return e?t.getCheckpoint(e)??null:null}function rc(e){return w.useMemo(()=>tc(e),[e])}function Pn(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 oc(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=Pn(e);if(t)return Pn(t.configurable)??t}function Xn(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)=>px(s,i)).filter(s=>!!s)].sort((s,i)=>sc(i.createdAt)-sc(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 px(e,t){var S;if(!e)return null;const r=(Array.isArray((S=e.values)==null?void 0:S.messages)?e.values.messages:[]).map(k=>hx(k)).filter(k=>!!k),o=Pn(e.metadata)??{},s=vi(e.config),i=Pn(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"]),p=Rn(a,["checkpoint_id","checkpointId"])??null,m=Rn(a,["checkpoint_ns","checkpointNs"])??null,f=Pn(e.config),v=Array.isArray(e.tasks)?e.tasks.map(k=>({...k})):e.tasks??null,x=Array.isArray(e.next)?[...e.next]:e.next??null,g=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(),b={...o,step:oc(o,["step"])??0,source:Rn(o,["source"])??null},y=r.map(k=>({...k,checkpointId:l??null}));return{checkpointId:l??null,checkpointNs:c??null,createdAt:g,parentId:d??null,messages:y,nextCursor:p,nextCursorNs:m,interrupt:vx(r,t),metadata:b,config:f??null,parentConfig:i??null,next:x,tasks:v}}function hx(e){var s,i,a;if(!e||typeof e!="object")return null;const t=mx(e);if(!t)return null;const n=xx(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 mx(e){const t=typeof e.role=="string"?e.role:void 0;if(t&&gx(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 gx(e){return e==="assistant"||e==="user"||e==="system"||e==="tool"||e==="default_message"}function xx(e){return typeof e=="string"?[{type:"text",text:e}]:Array.isArray(e)?e.filter(t=>!!(t&&typeof t=="object"&&typeof t.type=="string")):[]}function vx(e,t){return bx(e,t)}function bx(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 sc(e){if(!e)return 0;const t=Date.parse(e);return Number.isFinite(t)?t:0}var bi={exports:{}},Wr={};/**
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={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.min.js
4
4
  *
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
- */var ic;function wx(){if(ic)return Wr;ic=1;var e=w,t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,o=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function i(a,l,c){var d,p={},m=null,f=null;c!==void 0&&(m=""+c),l.key!==void 0&&(m=""+l.key),l.ref!==void 0&&(f=l.ref);for(d in l)r.call(l,d)&&!s.hasOwnProperty(d)&&(p[d]=l[d]);if(a&&a.defaultProps)for(d in l=a.defaultProps,l)p[d]===void 0&&(p[d]=l[d]);return{$$typeof:t,type:a,key:m,ref:f,props:p,_owner:o.current}}return Wr.Fragment=n,Wr.jsx=i,Wr.jsxs=i,Wr}var Vr={};/**
9
+ */var sc;function gx(){if(sc)return Wr;sc=1;var e=w,t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,o=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function i(a,l,c){var d,h={},m=null,f=null;c!==void 0&&(m=""+c),l.key!==void 0&&(m=""+l.key),l.ref!==void 0&&(f=l.ref);for(d in l)r.call(l,d)&&!s.hasOwnProperty(d)&&(h[d]=l[d]);if(a&&a.defaultProps)for(d in l=a.defaultProps,l)h[d]===void 0&&(h[d]=l[d]);return{$$typeof:t,type:a,key:m,ref:f,props:h,_owner:o.current}}return Wr.Fragment=n,Wr.jsx=i,Wr.jsxs=i,Wr}var Vr={};/**
10
10
  * @license React
11
11
  * react-jsx-runtime.development.js
12
12
  *
@@ -14,30 +14,30 @@
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 ac;function yx(){return ac||(ac=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"),p=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),f=Symbol.for("react.offscreen"),v=Symbol.iterator,x="@@iterator";function g(A){if(A===null||typeof A!="object")return null;var te=v&&A[v]||A[x];return typeof te=="function"?te:null}var b=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function y(A){{for(var te=arguments.length,ce=new Array(te>1?te-1:0),Ce=1;Ce<te;Ce++)ce[Ce-1]=arguments[Ce];S("error",A,ce)}}function S(A,te,ce){{var Ce=b.ReactDebugCurrentFrame,Je=Ce.getStackAddendum();Je!==""&&(te+="%s",ce=ce.concat([Je]));var nt=ce.map(function(Ke){return String(Ke)});nt.unshift("Warning: "+te),Function.prototype.apply.call(console[A],console,nt)}}var k=!1,C=!1,T=!1,E=!1,j=!1,P;P=Symbol.for("react.module.reference");function O(A){return!!(typeof A=="string"||typeof A=="function"||A===r||A===s||j||A===o||A===c||A===d||E||A===f||k||C||T||typeof A=="object"&&A!==null&&(A.$$typeof===m||A.$$typeof===p||A.$$typeof===i||A.$$typeof===a||A.$$typeof===l||A.$$typeof===P||A.getModuleId!==void 0))}function F(A,te,ce){var Ce=A.displayName;if(Ce)return Ce;var Je=te.displayName||te.name||"";return Je!==""?ce+"("+Je+")":ce}function q(A){return A.displayName||"Context"}function Y(A){if(A==null)return null;if(typeof A.tag=="number"&&y("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof A=="function")return A.displayName||A.name||null;if(typeof A=="string")return A;switch(A){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 A=="object")switch(A.$$typeof){case a:var te=A;return q(te)+".Consumer";case i:var ce=A;return q(ce._context)+".Provider";case l:return F(A,A.render,"ForwardRef");case p:var Ce=A.displayName||null;return Ce!==null?Ce:Y(A.type)||"Memo";case m:{var Je=A,nt=Je._payload,Ke=Je._init;try{return Y(Ke(nt))}catch{return null}}}return null}var R=Object.assign,K=0,U,W,M,I,G,X,_;function B(){}B.__reactDisabledLog=!0;function N(){{if(K===0){U=console.log,W=console.info,M=console.warn,I=console.error,G=console.group,X=console.groupCollapsed,_=console.groupEnd;var A={configurable:!0,enumerable:!0,value:B,writable:!0};Object.defineProperties(console,{info:A,log:A,warn:A,error:A,group:A,groupCollapsed:A,groupEnd:A})}K++}}function L(){{if(K--,K===0){var A={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:R({},A,{value:U}),info:R({},A,{value:W}),warn:R({},A,{value:M}),error:R({},A,{value:I}),group:R({},A,{value:G}),groupCollapsed:R({},A,{value:X}),groupEnd:R({},A,{value:_})})}K<0&&y("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var z=b.ReactCurrentDispatcher,$;function D(A,te,ce){{if($===void 0)try{throw Error()}catch(Je){var Ce=Je.stack.trim().match(/\n( *(at )?)/);$=Ce&&Ce[1]||""}return`
18
- `+$+A}}var J=!1,Q;{var ie=typeof WeakMap=="function"?WeakMap:Map;Q=new ie}function Z(A,te){if(!A||J)return"";{var ce=Q.get(A);if(ce!==void 0)return ce}var Ce;J=!0;var Je=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var nt;nt=z.current,z.current=null,N();try{if(te){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(Vt){Ce=Vt}Reflect.construct(A,[],Ke)}else{try{Ke.call()}catch(Vt){Ce=Vt}A.call(Ke.prototype)}}else{try{throw Error()}catch(Vt){Ce=Vt}A()}}catch(Vt){if(Vt&&Ce&&typeof Vt.stack=="string"){for(var We=Vt.stack.split(`
19
- `),$t=Ce.stack.split(`
20
- `),xt=We.length-1,wt=$t.length-1;xt>=1&&wt>=0&&We[xt]!==$t[wt];)wt--;for(;xt>=1&&wt>=0;xt--,wt--)if(We[xt]!==$t[wt]){if(xt!==1||wt!==1)do if(xt--,wt--,wt<0||We[xt]!==$t[wt]){var on=`
21
- `+We[xt].replace(" at new "," at ");return A.displayName&&on.includes("<anonymous>")&&(on=on.replace("<anonymous>",A.displayName)),typeof A=="function"&&Q.set(A,on),on}while(xt>=1&&wt>=0);break}}}finally{J=!1,z.current=nt,L(),Error.prepareStackTrace=Je}var zr=A?A.displayName||A.name:"",pr=zr?D(zr):"";return typeof A=="function"&&Q.set(A,pr),pr}function ue(A,te,ce){return Z(A,!1)}function he(A){var te=A.prototype;return!!(te&&te.isReactComponent)}function ke(A,te,ce){if(A==null)return"";if(typeof A=="function")return Z(A,he(A));if(typeof A=="string")return D(A);switch(A){case c:return D("Suspense");case d:return D("SuspenseList")}if(typeof A=="object")switch(A.$$typeof){case l:return ue(A.render);case p:return ke(A.type,te,ce);case m:{var Ce=A,Je=Ce._payload,nt=Ce._init;try{return ke(nt(Je),te,ce)}catch{}}}return""}var Le=Object.prototype.hasOwnProperty,$e={},je=b.ReactDebugCurrentFrame;function Be(A){if(A){var te=A._owner,ce=ke(A.type,A._source,te?te.type:null);je.setExtraStackFrame(ce)}else je.setExtraStackFrame(null)}function ct(A,te,ce,Ce,Je){{var nt=Function.call.bind(Le);for(var Ke in A)if(nt(A,Ke)){var We=void 0;try{if(typeof A[Ke]!="function"){var $t=Error((Ce||"React class")+": "+ce+" type `"+Ke+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof A[Ke]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw $t.name="Invariant Violation",$t}We=A[Ke](te,Ke,Ce,ce,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(xt){We=xt}We&&!(We instanceof Error)&&(Be(Je),y("%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).",Ce||"React class",ce,Ke,typeof We),Be(null)),We instanceof Error&&!(We.message in $e)&&($e[We.message]=!0,Be(Je),y("Failed %s type: %s",ce,We.message),Be(null))}}}var bt=Array.isArray;function kt(A){return bt(A)}function ze(A){{var te=typeof Symbol=="function"&&Symbol.toStringTag,ce=te&&A[Symbol.toStringTag]||A.constructor.name||"Object";return ce}}function Ye(A){try{return Oe(A),!1}catch{return!0}}function Oe(A){return""+A}function De(A){if(Ye(A))return y("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",ze(A)),Oe(A)}var He=b.ReactCurrentOwner,rt={key:!0,ref:!0,__self:!0,__source:!0},lt,it;function St(A){if(Le.call(A,"ref")){var te=Object.getOwnPropertyDescriptor(A,"ref").get;if(te&&te.isReactWarning)return!1}return A.ref!==void 0}function ht(A){if(Le.call(A,"key")){var te=Object.getOwnPropertyDescriptor(A,"key").get;if(te&&te.isReactWarning)return!1}return A.key!==void 0}function Ct(A,te){typeof A.ref=="string"&&He.current}function Et(A,te){{var ce=function(){lt||(lt=!0,y("%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)",te))};ce.isReactWarning=!0,Object.defineProperty(A,"key",{get:ce,configurable:!0})}}function rn(A,te){{var ce=function(){it||(it=!0,y("%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)",te))};ce.isReactWarning=!0,Object.defineProperty(A,"ref",{get:ce,configurable:!0})}}var It=function(A,te,ce,Ce,Je,nt,Ke){var We={$$typeof:t,type:A,key:te,ref:ce,props:Ke,_owner:nt};return We._store={},Object.defineProperty(We._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(We,"_self",{configurable:!1,enumerable:!1,writable:!1,value:Ce}),Object.defineProperty(We,"_source",{configurable:!1,enumerable:!1,writable:!1,value:Je}),Object.freeze&&(Object.freeze(We.props),Object.freeze(We)),We};function mn(A,te,ce,Ce,Je){{var nt,Ke={},We=null,$t=null;ce!==void 0&&(De(ce),We=""+ce),ht(te)&&(De(te.key),We=""+te.key),St(te)&&($t=te.ref,Ct(te,Je));for(nt in te)Le.call(te,nt)&&!rt.hasOwnProperty(nt)&&(Ke[nt]=te[nt]);if(A&&A.defaultProps){var xt=A.defaultProps;for(nt in xt)Ke[nt]===void 0&&(Ke[nt]=xt[nt])}if(We||$t){var wt=typeof A=="function"?A.displayName||A.name||"Unknown":A;We&&Et(Ke,wt),$t&&rn(Ke,wt)}return It(A,We,$t,Je,Ce,He.current,Ke)}}var Rt=b.ReactCurrentOwner,Fe=b.ReactDebugCurrentFrame;function Ue(A){if(A){var te=A._owner,ce=ke(A.type,A._source,te?te.type:null);Fe.setExtraStackFrame(ce)}else Fe.setExtraStackFrame(null)}var Mt;Mt=!1;function re(A){return typeof A=="object"&&A!==null&&A.$$typeof===t}function oe(){{if(Rt.current){var A=Y(Rt.current.type);if(A)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,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`
22
22
 
23
- Check the render method of \``+A+"`."}return""}}function _e(A){return""}var pe={};function Ae(A){{var te=oe();if(!te){var ce=typeof A=="string"?A:A.displayName||A.name;ce&&(te=`
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=`
24
24
 
25
- Check the top-level render call using <`+ce+">.")}return te}}function ve(A,te){{if(!A._store||A._store.validated||A.key!=null)return;A._store.validated=!0;var ce=Ae(te);if(pe[ce])return;pe[ce]=!0;var Ce="";A&&A._owner&&A._owner!==Rt.current&&(Ce=" It was passed a child from "+Y(A._owner.type)+"."),Ue(A),y('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',ce,Ce),Ue(null)}}function Ie(A,te){{if(typeof A!="object")return;if(kt(A))for(var ce=0;ce<A.length;ce++){var Ce=A[ce];re(Ce)&&ve(Ce,te)}else if(re(A))A._store&&(A._store.validated=!0);else if(A){var Je=g(A);if(typeof Je=="function"&&Je!==A.entries)for(var nt=Je.call(A),Ke;!(Ke=nt.next()).done;)re(Ke.value)&&ve(Ke.value,te)}}}function Pe(A){{var te=A.type;if(te==null||typeof te=="string")return;var ce;if(typeof te=="function")ce=te.propTypes;else if(typeof te=="object"&&(te.$$typeof===l||te.$$typeof===p))ce=te.propTypes;else return;if(ce){var Ce=Y(te);ct(ce,A.props,"prop",Ce,A)}else if(te.PropTypes!==void 0&&!Mt){Mt=!0;var Je=Y(te);y("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",Je||"Unknown")}typeof te.getDefaultProps=="function"&&!te.getDefaultProps.isReactClassApproved&&y("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Ge(A){{for(var te=Object.keys(A.props),ce=0;ce<te.length;ce++){var Ce=te[ce];if(Ce!=="children"&&Ce!=="key"){Ue(A),y("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",Ce),Ue(null);break}}A.ref!==null&&(Ue(A),y("Invalid attribute `ref` supplied to `React.Fragment`."),Ue(null))}}var mt={};function we(A,te,ce,Ce,Je,nt){{var Ke=O(A);if(!Ke){var We="";(A===void 0||typeof A=="object"&&A!==null&&Object.keys(A).length===0)&&(We+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var $t=_e();$t?We+=$t:We+=oe();var xt;A===null?xt="null":kt(A)?xt="array":A!==void 0&&A.$$typeof===t?(xt="<"+(Y(A.type)||"Unknown")+" />",We=" Did you accidentally export a JSX literal instead of a component?"):xt=typeof A,y("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",xt,We)}var wt=mn(A,te,ce,Je,nt);if(wt==null)return wt;if(Ke){var on=te.children;if(on!==void 0)if(Ce)if(kt(on)){for(var zr=0;zr<on.length;zr++)Ie(on[zr],A);Object.freeze&&Object.freeze(on)}else y("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 Ie(on,A)}if(Le.call(te,"key")){var pr=Y(A),Vt=Object.keys(te).filter(function(hN){return hN!=="key"}),Zl=Vt.length>0?"{key: someKey, "+Vt.join(": ..., ")+": ...}":"{key: someKey}";if(!mt[pr+Zl]){var pN=Vt.length>0?"{"+Vt.join(": ..., ")+": ...}":"{}";y(`A props object containing a "key" prop is being spread into JSX:
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:
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} />`,Zl,pr,pN,pr),mt[pr+Zl]=!0}}return A===r?Ge(wt):Pe(wt),wt}}function gt(A,te,ce){return we(A,te,ce,!0)}function Qe(A,te,ce){return we(A,te,ce,!1)}var ut=Qe,In=gt;Vr.Fragment=r,Vr.jsx=ut,Vr.jsxs=In}()),Vr}process.env.NODE_ENV==="production"?bi.exports=wx():bi.exports=yx();var u=bi.exports;const Sx=({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,x=(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}`:""]}),x&&u.jsx("p",{className:"text-[10px] text-muted-foreground/80 mt-1 line-clamp-2",title:x,children:x})]})]},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 lc(e,t){return function(){return e.apply(t,arguments)}}const{toString:Cx}=Object.prototype,{getPrototypeOf:wi}=Object,{iterator:Oo,toStringTag:cc}=Symbol,Do=(e=>t=>{const n=Cx.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:hr}=Array,mr=Lo("undefined");function Kr(e){return e!==null&&!mr(e)&&e.constructor!==null&&!mr(e.constructor)&&Ft(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const uc=sn("ArrayBuffer");function Tx(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&uc(e.buffer),t}const kx=Lo("string"),Ft=Lo("function"),dc=Lo("number"),qr=e=>e!==null&&typeof e=="object",Ex=e=>e===!0||e===!1,$o=e=>{if(Do(e)!=="object")return!1;const t=wi(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(cc in e)&&!(Oo in e)},Ix=e=>{if(!qr(e)||Kr(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},Nx=sn("Date"),Ax=sn("File"),jx=sn("Blob"),_x=sn("FileList"),Px=e=>qr(e)&&Ft(e.pipe),Rx=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||Ft(e.append)&&((t=Do(e))==="formdata"||t==="object"&&Ft(e.toString)&&e.toString()==="[object FormData]"))},Mx=sn("URLSearchParams"),[Ox,Dx,Lx,$x]=["ReadableStream","Request","Response","Headers"].map(sn),Fx=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]),hr(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 fc(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 Jn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,pc=e=>!mr(e)&&e!==Jn;function yi(){const{caseless:e,skipUndefined:t}=pc(this)&&this||{},n={},r=(o,s)=>{const i=e&&fc(n,s)||s;$o(n[i])&&$o(o)?n[i]=yi(n[i],o):$o(o)?n[i]=yi({},o):hr(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 Bx=(e,t,n,{allOwnKeys:r}={})=>(Gr(t,(o,s)=>{n&&Ft(o)?e[s]=lc(o,n):e[s]=o},{allOwnKeys:r}),e),zx=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Hx=(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)},Ux=(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&&wi(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},Wx=(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},Vx=e=>{if(!e)return null;if(hr(e))return e;let t=e.length;if(!dc(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Kx=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&wi(Uint8Array)),qx=(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])}},Gx=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},Yx=sn("HTMLFormElement"),Xx=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),Jx=sn("RegExp"),mc=(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)},Zx=e=>{mc(e,(t,n)=>{if(Ft(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(Ft(r)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},Qx=(e,t)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return hr(e)?r(e):r(String(e).split(t)),n},ev=()=>{},tv=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function nv(e){return!!(e&&Ft(e.append)&&e[cc]==="FormData"&&e[Oo])}const rv=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=hr(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)},ov=sn("AsyncFunction"),sv=e=>e&&(qr(e)||Ft(e))&&Ft(e.then)&&Ft(e.catch),gc=((e,t)=>e?setImmediate:t?((n,r)=>(Jn.addEventListener("message",({source:o,data:s})=>{o===Jn&&s===n&&r.length&&r.shift()()},!1),o=>{r.push(o),Jn.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",Ft(Jn.postMessage)),iv=typeof queueMicrotask<"u"?queueMicrotask.bind(Jn):typeof process<"u"&&process.nextTick||gc,V={isArray:hr,isArrayBuffer:uc,isBuffer:Kr,isFormData:Rx,isArrayBufferView:Tx,isString:kx,isNumber:dc,isBoolean:Ex,isObject:qr,isPlainObject:$o,isEmptyObject:Ix,isReadableStream:Ox,isRequest:Dx,isResponse:Lx,isHeaders:$x,isUndefined:mr,isDate:Nx,isFile:Ax,isBlob:jx,isRegExp:Jx,isFunction:Ft,isStream:Px,isURLSearchParams:Mx,isTypedArray:Kx,isFileList:_x,forEach:Gr,merge:yi,extend:Bx,trim:Fx,stripBOM:zx,inherits:Hx,toFlatObject:Ux,kindOf:Do,kindOfTest:sn,endsWith:Wx,toArray:Vx,forEachEntry:qx,matchAll:Gx,isHTMLForm:Yx,hasOwnProperty:hc,hasOwnProp:hc,reduceDescriptors:mc,freezeMethods:Zx,toObjectSet:Qx,toCamelCase:Xx,noop:ev,toFiniteNumber:tv,findKey:fc,global:Jn,isContextDefined:pc,isSpecCompliantForm:nv,toJSONObject:rv,isAsyncFn:ov,isThenable:sv,setImmediate:gc,asap:iv,isIterable:e=>e!=null&&Ft(e[Oo])};function Ee(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(Ee,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 xc=Ee.prototype,vc={};["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=>{vc[e]={value:e}}),Object.defineProperties(Ee,vc),Object.defineProperty(xc,"isAxiosError",{value:!0}),Ee.from=(e,t,n,r,o,s)=>{const i=Object.create(xc);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 Ee.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 av=null;function Si(e){return V.isPlainObject(e)||V.isArray(e)}function bc(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=bc(o),!n&&s?"["+o+"]":o}).join(n?".":""):t}function lv(e){return V.isArray(e)&&!e.some(Si)}const cv=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(x,g){return!V.isUndefined(g[x])});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 Ee("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,x,g){let b=v;if(v&&!g&&typeof v=="object"){if(V.endsWith(x,"{}"))x=r?x:x.slice(0,-2),v=JSON.stringify(v);else if(V.isArray(v)&&lv(v)||(V.isFileList(v)||V.endsWith(x,"[]"))&&(b=V.toArray(v)))return x=bc(x),b.forEach(function(S,k){!(V.isUndefined(S)||S===null)&&t.append(i===!0?wc([x],k,s):i===null?x:x+"[]",c(S))}),!1}return Si(v)?!0:(t.append(wc(g,x,s),c(v)),!1)}const p=[],m=Object.assign(cv,{defaultVisitor:d,convertValue:c,isVisitable:Si});function f(v,x){if(!V.isUndefined(v)){if(p.indexOf(v)!==-1)throw Error("Circular reference detected in "+x.join("."));p.push(v),V.forEach(v,function(b,y){(!(V.isUndefined(b)||b===null)&&o.call(t,b,V.isString(y)?y.trim():y,x,m))===!0&&f(b,x?x.concat(y):[y])}),p.pop()}}if(!V.isObject(e))throw new TypeError("data must be an object");return f(e),t}function yc(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 Sc=Ci.prototype;Sc.append=function(t,n){this._pairs.push([t,n])},Sc.toString=function(t){const n=t?function(r){return t.call(this,r,yc)}:yc;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function uv(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Cc(e,t,n){if(!t)return e;const r=n&&n.encode||uv;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 Tc{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 kc={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},dv={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,fv=Ti&&(!ki||["ReactNative","NativeScript","NS"].indexOf(ki.product)<0),pv=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",hv=Ti&&window.location.href||"http://localhost",Nt={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Ti,hasStandardBrowserEnv:fv,hasStandardBrowserWebWorkerEnv:pv,navigator:ki,origin:hv},Symbol.toStringTag,{value:"Module"})),...dv};function mv(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 gv(e){return V.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function xv(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 Ec(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]=xv(o[i])),!a)}if(V.isFormData(e)&&V.isFunction(e.entries)){const n={};return V.forEachEntry(e,(r,o)=>{t(gv(r),o,n,0)}),n}return null}function vv(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:kc,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(Ec(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 mv(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),vv(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"?Ee.from(a,Ee.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 bv=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"]),wv=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]&&bv[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},Ic=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 yv(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 Sv=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 Cv(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function Tv(e,t){const n=V.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{value:function(o,s,i){return this[r].call(this,t,o,s,i)},configurable:!0})})}let Bt=class{constructor(t){t&&this.set(t)}set(t,n,r){const o=this;function s(a,l,c){const d=Xr(l);if(!d)throw new Error("header name must be a non-empty string");const p=V.findKey(o,d);(!p||o[p]===void 0||c===!0||c===void 0&&o[p]!==!1)&&(o[p||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())&&!Sv(t))i(wv(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 yv(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?Cv(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[Ic]=this[Ic]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=Xr(i);r[a]||(Tv(o,i),r[a]=!0)}return V.isArray(t)?t.forEach(s):s(t),this}};Bt.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),V.reduceDescriptors(Bt.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),V.freezeMethods(Bt);function Ii(e,t){const n=this||Yr,r=t||n,o=Bt.from(r.headers);let s=r.data;return V.forEach(e,function(a){s=a.call(n,s,o.normalize(),t?t.status:void 0)}),o.normalize(),s}function Nc(e){return!!(e&&e.__CANCEL__)}function gr(e,t,n){Ee.call(this,e??"canceled",Ee.ERR_CANCELED,t,n),this.name="CanceledError"}V.inherits(gr,Ee,{__CANCEL__:!0});function Ac(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new Ee("Request failed with status code "+n.status,[Ee.ERR_BAD_REQUEST,Ee.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function kv(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Ev(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 p=s,m=0;for(;p!==o;)m+=n[p++],p=p%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 Iv(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(),p=d-n;p>=r?i(c,d):(o=c,s||(s=setTimeout(()=>{s=null,i(o)},r-p)))},()=>o&&i(o)]}const zo=(e,t,n=3)=>{let r=0;const o=Ev(50,250);return Iv(s=>{const i=s.loaded,a=s.lengthComputable?s.total:void 0,l=i-r,c=o(l),d=i<=a;r=i;const p={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(p)},n)},jc=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},_c=e=>(...t)=>V.asap(()=>e(...t)),Nv=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,Av=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 jv(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function _v(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function Pc(e,t,n){let r=!jv(t);return e&&(r||n==!1)?_v(e,t):t}const Rc=e=>e instanceof Bt?{...e}:e;function Zn(e,t){t=t||{};const n={};function r(c,d,p,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,p,m){if(V.isUndefined(d)){if(!V.isUndefined(c))return r(void 0,c,p,m)}else return r(c,d,p,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,p){if(p in t)return r(c,d);if(p 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,p)=>o(Rc(c),Rc(d),p,!0)};return V.forEach(Object.keys({...e,...t}),function(d){const p=l[d]||o,m=p(e[d],t[d],d);V.isUndefined(m)&&p!==a||(n[d]=m)}),n}const Mc=e=>{const t=Zn({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=Bt.from(i),t.url=Cc(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,p])=>{c.includes(d.toLowerCase())&&i.set(d,p)})}}if(Nt.hasStandardBrowserEnv&&(r&&V.isFunction(r)&&(r=r(t)),r||r!==!1&&Nv(t.url))){const l=o&&s&&Av.read(s);l&&i.set(o,l)}return t},Pv=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=Mc(e);let s=o.data;const i=Bt.from(o.headers).normalize();let{responseType:a,onUploadProgress:l,onDownloadProgress:c}=o,d,p,m,f,v;function x(){f&&f(),v&&v(),o.cancelToken&&o.cancelToken.unsubscribe(d),o.signal&&o.signal.removeEventListener("abort",d)}let g=new XMLHttpRequest;g.open(o.method.toUpperCase(),o.url,!0),g.timeout=o.timeout;function b(){if(!g)return;const S=Bt.from("getAllResponseHeaders"in g&&g.getAllResponseHeaders()),C={data:!a||a==="text"||a==="json"?g.responseText:g.response,status:g.status,statusText:g.statusText,headers:S,config:e,request:g};Ac(function(E){n(E),x()},function(E){r(E),x()},C),g=null}"onloadend"in g?g.onloadend=b:g.onreadystatechange=function(){!g||g.readyState!==4||g.status===0&&!(g.responseURL&&g.responseURL.indexOf("file:")===0)||setTimeout(b)},g.onabort=function(){g&&(r(new Ee("Request aborted",Ee.ECONNABORTED,e,g)),g=null)},g.onerror=function(k){const C=k&&k.message?k.message:"Network Error",T=new Ee(C,Ee.ERR_NETWORK,e,g);T.event=k||null,r(T),g=null},g.ontimeout=function(){let k=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const C=o.transitional||kc;o.timeoutErrorMessage&&(k=o.timeoutErrorMessage),r(new Ee(k,C.clarifyTimeoutError?Ee.ETIMEDOUT:Ee.ECONNABORTED,e,g)),g=null},s===void 0&&i.setContentType(null),"setRequestHeader"in g&&V.forEach(i.toJSON(),function(k,C){g.setRequestHeader(C,k)}),V.isUndefined(o.withCredentials)||(g.withCredentials=!!o.withCredentials),a&&a!=="json"&&(g.responseType=o.responseType),c&&([m,v]=zo(c,!0),g.addEventListener("progress",m)),l&&g.upload&&([p,f]=zo(l),g.upload.addEventListener("progress",p),g.upload.addEventListener("loadend",f)),(o.cancelToken||o.signal)&&(d=S=>{g&&(r(!S||S.type?new gr(null,e,g):S),g.abort(),g=null)},o.cancelToken&&o.cancelToken.subscribe(d),o.signal&&(o.signal.aborted?d():o.signal.addEventListener("abort",d)));const y=kv(o.url);if(y&&Nt.protocols.indexOf(y)===-1){r(new Ee("Unsupported protocol "+y+":",Ee.ERR_BAD_REQUEST,e));return}g.send(s||null)})},Rv=(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 Ee?d:new gr(d instanceof Error?d.message:d))}};let i=t&&setTimeout(()=>{i=null,s(new Ee(`timeout ${t} of ms exceeded`,Ee.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}},Mv=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},Ov=async function*(e,t){for await(const n of Dv(e))yield*Mv(n,t)},Dv=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()}},Oc=(e,t,n,r)=>{const o=Ov(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 p=d.byteLength;if(n){let m=s+=p;n(m)}l.enqueue(new Uint8Array(d))}catch(c){throw a(c),c}},cancel(l){return a(l),o.return()}},{highWaterMark:2})},Dc=64*1024,{isFunction:Ho}=V,Lv=(({Request:e,Response:t})=>({Request:e,Response:t}))(V.global),{ReadableStream:Lc,TextEncoder:$c}=V.global,Fc=(e,...t)=>{try{return!!e(...t)}catch{return!1}},$v=e=>{e=V.merge.call({skipUndefined:!0},Lv,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(Lc),l=o&&(typeof $c=="function"?(v=>x=>v.encode(x))(new $c):async v=>new Uint8Array(await new n(v).arrayBuffer())),c=s&&a&&Fc(()=>{let v=!1;const x=new n(Nt.origin,{body:new Lc,method:"POST",get duplex(){return v=!0,"half"}}).headers.has("Content-Type");return v&&!x}),d=i&&a&&Fc(()=>V.isReadableStream(new r("").body)),p={stream:d&&(v=>v.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(v=>{!p[v]&&(p[v]=(x,g)=>{let b=x&&x[v];if(b)return b.call(x);throw new Ee(`Response type '${v}' is not supported`,Ee.ERR_NOT_SUPPORT,g)})});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,x)=>{const g=V.toFiniteNumber(v.getContentLength());return g??m(x)};return async v=>{let{url:x,method:g,data:b,signal:y,cancelToken:S,timeout:k,onDownloadProgress:C,onUploadProgress:T,responseType:E,headers:j,withCredentials:P="same-origin",fetchOptions:O}=Mc(v),F=t||fetch;E=E?(E+"").toLowerCase():"text";let q=Rv([y,S&&S.toAbortSignal()],k),Y=null;const R=q&&q.unsubscribe&&(()=>{q.unsubscribe()});let K;try{if(T&&c&&g!=="get"&&g!=="head"&&(K=await f(j,b))!==0){let X=new n(x,{method:"POST",body:b,duplex:"half"}),_;if(V.isFormData(b)&&(_=X.headers.get("content-type"))&&j.setContentType(_),X.body){const[B,N]=jc(K,zo(_c(T)));b=Oc(X.body,Dc,B,N)}}V.isString(P)||(P=P?"include":"omit");const U=s&&"credentials"in n.prototype,W={...O,signal:q,method:g.toUpperCase(),headers:j.normalize().toJSON(),body:b,duplex:"half",credentials:U?P:void 0};Y=s&&new n(x,W);let M=await(s?F(Y,O):F(x,W));const I=d&&(E==="stream"||E==="response");if(d&&(C||I&&R)){const X={};["status","statusText","headers"].forEach(L=>{X[L]=M[L]});const _=V.toFiniteNumber(M.headers.get("content-length")),[B,N]=C&&jc(_,zo(_c(C),!0))||[];M=new r(Oc(M.body,Dc,B,()=>{N&&N(),R&&R()}),X)}E=E||"text";let G=await p[V.findKey(p,E)||"text"](M,v);return!I&&R&&R(),await new Promise((X,_)=>{Ac(X,_,{data:G,headers:Bt.from(M.headers),status:M.status,statusText:M.statusText,config:v,request:Y})})}catch(U){throw R&&R(),U&&U.name==="TypeError"&&/Load failed|fetch/i.test(U.message)?Object.assign(new Ee("Network Error",Ee.ERR_NETWORK,v,Y),{cause:U.cause||U}):Ee.from(U,U&&U.code,v,Y)}}},Fv=new Map,Bc=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=Fv;for(;a--;)l=s[a],c=d.get(l),c===void 0&&d.set(l,c=a?new Map:$v(t)),d=c;return c};Bc();const Ni={http:av,xhr:Pv,fetch:{get:Bc}};V.forEach(Ni,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const zc=e=>`- ${e}`,Bv=e=>V.isFunction(e)||e===null||e===!1,Hc={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,!Bv(r)&&(o=Ni[(a=String(r)).toLowerCase()],o===void 0))throw new Ee(`Unknown adapter '${a}'`);if(o&&(V.isFunction(o)||(o=o.get(t))))break;s[a||"#"+i]=o}if(!o){const i=Object.entries(s).map(([l,c])=>`adapter ${l} `+(c===!1?"is not supported by the environment":"is not available in the build"));let a=n?i.length>1?`since :
33
- `+i.map(zc).join(`
34
- `):" "+zc(i[0]):"as no adapter specified";throw new Ee("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 Uc(e){return Ai(e),e.headers=Bt.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),Hc.getAdapter(e.adapter||Yr.adapter,e)(e).then(function(r){return Ai(e),r.data=Ii.call(e,e.transformResponse,r),r.headers=Bt.from(r.headers),r},function(r){return Nc(r)||(Ai(e),r&&r.response&&(r.response.data=Ii.call(e,e.transformResponse,r.response),r.response.headers=Bt.from(r.response.headers))),Promise.reject(r)})}const Wc="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 Vc={};Uo.transitional=function(t,n,r){function o(s,i){return"[Axios v"+Wc+"] Transitional option '"+s+"'"+i+(r?". "+r:"")}return(s,i,a)=>{if(t===!1)throw new Ee(o(i," has been removed"+(n?" in "+n:"")),Ee.ERR_DEPRECATED);return n&&!Vc[i]&&(Vc[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 zv(e,t,n){if(typeof e!="object")throw new Ee("options must be an object",Ee.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 Ee("option "+s+" must be "+l,Ee.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new Ee("Unknown option "+s,Ee.ERR_BAD_OPTION)}}const Wo={assertOptions:zv,validators:Uo},gn=Wo.validators;let Qn=class{constructor(t){this.defaults=t||{},this.interceptors={request:new Tc,response:new Tc}}async request(t,n){try{return await this._request(t,n)}catch(r){if(r instanceof Error){let o={};Error.captureStackTrace?Error.captureStackTrace(o):o=new Error;const s=o.stack?o.stack.replace(/^.+\n/,""):"";try{r.stack?s&&!String(r.stack).endsWith(s.replace(/^.+\n.+\n/,""))&&(r.stack+=`
35
- `+s):r.stack=s}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=Zn(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:s}=n;r!==void 0&&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=Bt.concat(i,s);const a=[];let l=!0;this.interceptors.request.forEach(function(x){typeof x.runWhen=="function"&&x.runWhen(n)===!1||(l=l&&x.synchronous,a.unshift(x.fulfilled,x.rejected))});const c=[];this.interceptors.response.forEach(function(x){c.push(x.fulfilled,x.rejected)});let d,p=0,m;if(!l){const v=[Uc.bind(this),void 0];for(v.unshift(...a),v.push(...c),m=v.length,d=Promise.resolve(n);p<m;)d=d.then(v[p++],v[p++]);return d}m=a.length;let f=n;for(;p<m;){const v=a[p++],x=a[p++];try{f=v(f)}catch(g){x.call(this,g);break}}try{d=Uc.call(this,f)}catch(v){return Promise.reject(v)}for(p=0,m=c.length;p<m;)d=d.then(c[p++],c[p++]);return d}getUri(t){t=Zn(this.defaults,t);const n=Pc(t.baseURL,t.url,t.allowAbsoluteUrls);return Cc(n,t.params,t.paramsSerializer)}};V.forEach(["delete","get","head","options"],function(t){Qn.prototype[t]=function(n,r){return this.request(Zn(r||{},{method:t,url:n,data:(r||{}).data}))}}),V.forEach(["post","put","patch"],function(t){function n(r){return function(s,i,a){return this.request(Zn(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}Qn.prototype[t]=n(),Qn.prototype[t+"Form"]=n(!0)});let Hv=class ax{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 ax(function(o){t=o}),cancel:t}}};function Uv(e){return function(n){return e.apply(null,n)}}function Wv(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 Kc(e){const t=new Qn(e),n=lc(Qn.prototype.request,t);return V.extend(n,Qn.prototype,t,{allOwnKeys:!0}),V.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return Kc(Zn(e,o))},n}const dt=Kc(Yr);dt.Axios=Qn,dt.CanceledError=gr,dt.CancelToken=Hv,dt.isCancel=Nc,dt.VERSION=Wc,dt.toFormData=Fo,dt.AxiosError=Ee,dt.Cancel=dt.CanceledError,dt.all=function(t){return Promise.all(t)},dt.spread=Uv,dt.isAxiosError=Wv,dt.mergeConfig=Zn,dt.AxiosHeaders=Bt,dt.formToJSON=e=>Ec(V.isHTMLForm(e)?new FormData(e):e),dt.getAdapter=Hc.getAdapter,dt.HttpStatusCode=ji,dt.default=dt;const{Axios:CN,AxiosError:TN,CanceledError:kN,isCancel:qc,CancelToken:EN,VERSION:IN,all:NN,Cancel:AN,isAxiosError:jN,spread:_N,toFormData:PN,AxiosHeaders:RN,HttpStatusCode:MN,formToJSON:ON,getAdapter:DN,mergeConfig:LN}=dt,Gc=typeof window<"u"?window.__API_BASE_URL__:void 0,Yc=Gc?xn(Gc):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 _i=new Set;function Xc(){return Vo}function Ko(e){Vo=e,_i.forEach(t=>t(e))}function Jc(e){return _i.add(e),()=>_i.delete(e)}const Zc=3e4,Qc=9e4,qt=dt.create({...Yc?{baseURL:Yc}:{},timeout:Zc,withCredentials:!0});qt.interceptors.request.use(e=>(Vo&&(e.headers.Authorization=`Bearer ${Vo}`),e)),qt.interceptors.response.use(e=>{if(typeof window<"u"&&(e!=null&&e.data))try{const t=e.data,n=t.data||{},r=typeof t.token=="string"&&t.token||typeof n.token=="string"&&n.token||null,o=typeof t.expires_at=="number"&&t.expires_at||typeof n.expires_at=="number"&&n.expires_at||typeof t.expiresAt=="number"&&t.expiresAt||typeof n.expiresAt=="number"&&n.expiresAt||null;r&&(localStorage.setItem("authToken",r),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 Gt(e,t){return qt.defaults.baseURL?(await qt.get(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}async function qo(e,t,n){return qt.defaults.baseURL?(await qt.post(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function eu(e,t,n){return qt.defaults.baseURL?(await qt.put(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function Pi(e,t){return qt.defaults.baseURL?(await qt.delete(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}function Ot(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class Go{get baseUrl(){const t=qt.defaults.baseURL;return t?xn(String(t)):""}updateConfig(t){t.baseUrl&&(qt.defaults.baseURL=xn(String(t.baseUrl))),t.authToken!==void 0&&Ko(t.authToken)}getAuthToken(){return Xc()}setAuthToken(t){Ko(t)}onTokenChange(t){return Jc(t)}async listThreads(){const t=await Gt("/threads"),n=Ot(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async listSharedThreads(){const t=await Gt("/threads/shared"),n=Ot(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 Ot(r)}async updateThread(t,n){const r=await eu(`/threads/${t}`,{title:n});return Ot(r)}async deleteThread(t){const n=await Pi(`/threads/${t}`);return Ot(n)}async shareThread(t,n){const r=await qo(`/threads/${t}/share`,{shared_with_user_id:n});return Ot(r)}async threadInfo(t){const n=await Gt(`/threads/${t}/info`);return Ot(n)}async listAgents(){const t=await Gt("/agents"),n=Ot(t);return(n==null?void 0:n.items)??[]}async getAgent(t){const n=await Gt(`/agents/${t}`);return Ot(n)}async getAgentSchema(t){const n=await Gt(`/agents/${t}/schema`);return Ot(n)}async getState(t){const n=await Gt(`/threads/${t.threadId}/state`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return Ot(n)}async getStateHistory(t){const n=await Gt(`/threads/${t.threadId}/state/history`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs},timeout:Qc,signal:t.signal});return Ot(n)}async cancelRun(t){const n=await qo("/runs/cancel",{threadId:t});return Ot(n)}async unshareThread(t,n){const r=await Pi(`/threads/${t}/share/${n}`);return Ot(r)}}const Nn=new Go,Vv=Go,Kv=Go;async function Ri(e,t){return await Gt(e,{responseType:"blob",onDownloadProgress:r=>{try{if(t&&r.lengthComputable){const o=r.loaded/r.total;t(o)}}catch{}},maxBodyLength:1/0})}async function qv(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 tu(e,t){const n=await Ri(`/files/${e}/download`,t),r=URL.createObjectURL(n);let o=`file_${e}`;try{const i=await Gt(`/files/${e}`);o=(i==null?void 0:i.filename)??o}catch{}const s=document.createElement("a");s.href=r,s.download=o,document.body.appendChild(s),s.click(),s.remove(),setTimeout(()=>URL.revokeObjectURL(r),6e4)}async function Gv(e){return await Gt(`/files/${e}`)}async function nu(e,t=50,n=0){const r={limit:t,offset:n};return e&&(r.thread_id=e),await Gt("/files",{params:r})}const ru=w.createContext(null);function ou({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(ru.Provider,{value:r,children:e})}async function su(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 iu(e=[]){const t=[],n=[];for(const r of e)try{const o=await su(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(ru);if(!e)throw new Error("useApi must be used within ApiProvider");return e}function au(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 Yv(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 lu(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="assistant")return e[t].id;return null}function cu(e){return!e||!e.length?"":e.filter(t=>t.type==="text").map(t=>t.text??"").join("")}function uu(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(p=>p.type==="text").map(p=>p.text??"").join(""),i=t.filter(p=>p.type!=="text"),a=o.lastText??cu(e);let l="",c=e.slice();if(s){const p=Xv(a,s);if(p===""?l="":p===s?l=s:l=p,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 du(e){return e.replace(/\s+/g," ").trim()}function Xv(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=du(e),o=du(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 Jv(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 fu(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}function Zv(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),[p,m]=w.useState(""),[f,v]=w.useState(null),[x,g]=w.useState(0),[b,y]=w.useState(!1),[S,k]=w.useState(null),C=w.useRef(null),T=w.useRef(!0),E=w.useRef(0),j=w.useRef(null),P=w.useRef(null),O=w.useRef(null),F=w.useRef(null),q=w.useRef({messageId:null,lastSeq:null,lastText:""}),Y=w.useCallback(W=>{o(W)},[]),R=w.useCallback(()=>{m(""),v(null),d(null),P.current=null,O.current=null,F.current=null,k(null),q.current={messageId:null,lastSeq:null,lastText:""}},[]),K=w.useCallback(()=>{var G;console.debug("[use-chat] stop() invoked - aborting stream");const W=(G=j.current)==null?void 0:G.threadId,M=()=>{var X;(X=C.current)==null||X.abort(),C.current=null,j.current=null,l(!1),y(!1),E.current=0,g(0)};(W?Nn.cancelRun(W).catch(X=>{console.warn("[use-chat] cancel run failed:",X)}):Promise.resolve()).finally(M)},[]),U=w.useCallback((W,M,I)=>{C.current&&(C.current.abort(),C.current=null),l(!0),d(null),e.autoAppendAssistant!==!1&&m(""),v(null),P.current=null,O.current=null,F.current=null,k(null),q.current={messageId:null,lastSeq:null,lastText:""};const G=new AbortController;C.current=G;let X=null,_=null,B=!1;return j.current={threadId:W.threadId??null,headers:{}},(async()=>{var L,z,$,D,J,Q,ie,Z,ue,he,ke,Le,$e,je,Be,ct,bt,kt;const N=ze=>{var Ye;try{const Oe=JSON.parse(JSON.stringify(ze));return(Ye=Oe==null?void 0:Oe.payload)!=null&&Ye.files_info&&Array.isArray(Oe.payload.files_info)&&(Oe.payload.files_info=Oe.payload.files_info.map(De=>({...De,data:De!=null&&De.data?`<base64 ${String(De.data).length} chars>`:De==null?void 0:De.data}))),Oe}catch{return ze}};try{let ze={};try{if(r)ze={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const Ue=window.__AUTH_TOKEN__,Mt=((L=window.localStorage)==null?void 0:L.getItem("authToken"))||null;let re=null;try{const _e=(z=window.localStorage)==null?void 0:z.getItem("chat-settings");_e&&(re=(($=JSON.parse(_e))==null?void 0:$.apiKey)||null)}catch{}const oe=Ue||Mt||re||null;oe&&(ze={Authorization:`Bearer ${oe}`})}}catch{}console.debug("[use-chat] POST",t+n,N(W));let Ye={};if(typeof window<"u")try{const Fe=(D=window.localStorage)==null?void 0:D.getItem("authSessionId");Fe&&(Ye={"X-Session-Id":Fe})}catch{}const Oe={...ze,...Ye,...s.current},De={"Content-Type":"application/json",Accept:"text/event-stream",...Oe},He=await fetch(t+n,{method:"POST",headers:De,body:JSON.stringify(W),signal:G.signal,credentials:i});if(j.current&&(j.current.headers=Oe),!He.ok||!He.body){const Fe=await He.text().catch(()=>"");console.debug("[use-chat] non-OK response",He.status,Fe==null?void 0:Fe.slice(0,500));const Ue=`stream ${He.status}${Fe?": "+Fe:""}`;throw(J=I==null?void 0:I.onConnectionError)==null||J.call(I,Ue),B=!0,X="error",_=Ue,new Error(Ue)}y(!0);const rt=He.body.getReader(),lt=new TextDecoder;let it="",St=[];E.current=0,g(0);let ht=0,Ct=null;const Et=()=>{if(St.length){const Fe=St.join("");St=[],T.current&&m(Ue=>Ue+Fe)}Ct=null},rn=()=>{typeof window<"u"&&Ct==null&&(Ct=requestAnimationFrame(Et))};let It=Date.now();const mn=setInterval(()=>{var Fe;if(Date.now()-It>18e5){const Ue="Stream idle timeout";d(Ue),X="error",_=Ue,G.abort(),(Fe=I==null?void 0:I.onError)==null||Fe.call(I,Ue)}},5e3),Rt=1024*1024;try{const Fe=He.headers.get("X-Thread-Id")||He.headers.get("x-thread-id"),Ue=He.headers.get("X-Thread-Created")||He.headers.get("x-thread-created"),Mt=Fe??null,re=String(Ue??"").toLowerCase()==="true";for(j.current&&!j.current.threadId&&(j.current={...j.current,threadId:Mt}),(Q=I==null?void 0:I.onOpen)==null||Q.call(I,{threadId:Mt,created:re});;){const{value:oe,done:_e}=await rt.read();if(_e)break;it+=lt.decode(oe,{stream:!0}),it.length>Rt&&(it="",console.warn("Stream buffer reset: exceeded 1MB"));let pe;for(;(pe=it.indexOf(`
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 :
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(`
36
36
 
37
- `))>=0;){const Ae=it.slice(0,pe);it=it.slice(pe+2);const ve=Ae.split(/\r?\n/),Ie=[];for(const Qe of ve)if(!(!Qe||Qe.startsWith(":"))&&Qe.startsWith("data:")){const ut=Qe.slice(5);Ie.push(ut.startsWith(" ")?ut.slice(1):ut)}const Pe=Ie.join(`
38
- `);if(!Pe)continue;let Ge;try{Ge=JSON.parse(Pe)}catch{console.debug("[use-chat] malformed SSE:",Pe.slice(0,200));continue}const mt=au(Ge)?Ge.data:Ge;if(!mt){console.warn("[use-chat] dropped envelope event without payload",Ge);continue}const we=mt;It=Date.now();const gt=we.seq;if(gt!==void 0){if(gt<=ht){console.debug("[use-chat] drop duplicate/out-of-order event",{seq:gt,lastProcessedSeq:ht,type:we.type});continue}ht>0&&gt>ht+1&&((ie=I==null?void 0:I.onGap)==null||ie.call(I,{from:ht,to:gt})),ht=gt,E.current=gt,g(gt)}if(we.type==="message.start"&&we.role==="assistant"){const Qe=fu(we.model);q.current={messageId:we.id,lastSeq:gt??null,lastText:""},k({id:we.id,role:"assistant",name:Qe??void 0,model:we.model,createdAt:new Date().toISOString(),content:[]})}if(we.type==="checkpoint")P.current=we.checkpointId??null,O.current=we.checkpointNs??null,v(we.checkpointId??null);else if(we.type==="state_history"){F.current=we;try{const ut=Xn(we).latest;ut&&(P.current=ut.checkpointId??null,O.current=ut.checkpointNs??null,v(ut.checkpointId??null))}catch(Qe){console.warn("[use-chat] Failed to hydrate state_history payload",Qe)}}try{M==null||M(we)}catch(Qe){console.error("[use-chat] Error in onEvent callback:",Qe,"for event:",we.type)}if(we.type==="message.delta"){k(ut=>{const In=q.current;if(!ut||In.messageId!==ut.id)return ut;const{newParts:A,newMeta:te,changed:ce}=uu(ut.content??[],we.delta,{lastSeq:In.lastSeq,lastText:In.lastText},gt??null);return ce?(q.current={...In,lastSeq:te.lastSeq??In.lastSeq,lastText:te.lastText??In.lastText},{...ut,content:A}):ut});const Qe=we.delta.filter(ut=>ut.type==="text").map(ut=>ut.text).join("");Qe&&e.autoAppendAssistant!==!1&&(St.push(Qe),rn())}else if(we.type==="heartbeat"){console.debug("[use-chat] heartbeat received");try{(Z=I==null?void 0:I.onHeartbeat)==null||Z.call(I,we)}catch(Qe){console.warn("[use-chat] heartbeat callback failed",Qe)}}else if(Ct!==null&&cancelAnimationFrame(Ct),Et(),we.type==="checkpoint")v(we.checkpointId);else if(we.type==="error"){const Qe=we;if(d(Qe.message),X="error",_=Qe.message,Qe.error_type==="auth_error"||Qe.code==="TOKEN_EXPIRED"||((ue=Qe.message)==null?void 0:ue.includes("token"))||((he=Qe.message)==null?void 0:he.includes("401"))||((ke=Qe.message)==null?void 0:ke.includes("unauthorized"))||((Le=Qe.message)==null?void 0:Le.includes("Unauthorized"))){console.error("[use-chat] Auth error detected:",Qe.message);try{($e=I==null?void 0:I.onAuthError)==null||$e.call(I,Qe.message)}catch(In){console.warn("[use-chat] onAuthError handler failed",In)}G.abort()}}}}Et(),X===null&&!G.signal.aborted&&(X="complete")}catch(Fe){if(Fe.name==="AbortError")X=X??"aborted";else{const Ue=Fe.message||String(Fe);X="error",_=Ue,d(Ue),(je=I==null?void 0:I.onError)==null||je.call(I,Ue)}}finally{try{await rt.cancel()}catch{}finally{(Be=rt.releaseLock)==null||Be.call(rt)}Ct!==null&&typeof window<"u"&&window.cancelAnimationFrame(Ct),clearInterval(mn)}}catch(ze){if(ze.name==="AbortError")X=X??"aborted";else{const Ye=ze.message||String(ze);X="error",_=Ye,d(Ye),(ct=I==null?void 0:I.onError)==null||ct.call(I,Ye),B||((bt=I==null?void 0:I.onConnectionError)==null||bt.call(I,Ye),B=!0)}}finally{const ze=E.current,Ye=P.current,Oe=O.current,De=F.current,He=X??(G.signal.aborted?"aborted":_?"error":"complete");try{(kt=I==null?void 0:I.onClosed)==null||kt.call(I,{reason:He,lastSeq:ze,lastCheckpointId:Ye,lastCheckpointNs:Oe,lastStateHistory:De,error:_})}catch(rt){console.warn("[use-chat] onClosed callback failed",rt)}l(!1),y(!1),C.current=null,E.current=0,g(0),j.current=null}})(),{close:()=>G.abort()}},[t,n,r,e.autoAppendAssistant]);return w.useEffect(()=>()=>{var W;T.current=!1,(W=C.current)==null||W.abort()},[]),{isStreaming:a,error:c,assistantText:p,assistantMessage:S,lastCheckpointId:f,lastSeq:x,connected:b,stream:U,stop:K,clear:R,setToken:Y}}const Qv=["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 Qv){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 eb(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 pu({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),[p,m]=w.useState(null),[f,v]=w.useState([]),[x,g]=w.useState(!1),[,b]=w.useState(null),[y,S]=w.useState(null),[k,C]=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 M=await e.listThreads();i(M??[])}catch(M){const I=String(M);m(I),n==null||n(I)}finally{d(!1)}},[e,n]),P=w.useCallback(async()=>{g(!0),b(null);try{const M=await e.listSharedThreads();v(M??[])}catch(M){const I=String(M);b(I),n==null||n(I)}finally{g(!1)}},[e,n]);w.useEffect(()=>{j()},[j]),w.useEffect(()=>{P()},[P]),w.useEffect(()=>{r==null||r(a)},[a,r]);const O=w.useCallback(async M=>{try{const I=await e.createThread(M);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 M=>{const I=s;i(X=>X.filter(_=>_.threadId!==M));const G=new AbortController;E.current.set(M,G);try{await e.deleteThread(M),T.current===M&&(l(null),o==null||o())}catch(X){i(I);const _=String(X);n==null||n(_)}finally{E.current.delete(M)}},[e,o,n,s]),q=w.useCallback(async(M,I)=>{try{await e.updateThread(M,I),await j()}catch(G){n==null||n(String(G))}},[e,n,j]),Y=w.useCallback(async(M,I)=>{C(!0),S("Sharing thread…");try{await e.shareThread(M,I),await P(),S("Shared successfully")}catch(G){const X=eb(G);throw n==null||n(X),S(`Failed to share: ${X}`),new Error(X)}finally{C(!1)}},[e,n,P]),R=w.useCallback(async(M,I)=>{try{await e.unshareThread(M,I),await P()}catch(G){const X=String(G);throw n==null||n(X),G}},[e,n,P]),K=w.useMemo(()=>({createThread:O,deleteThread:F,renameThread:q,refreshThreads:j,refreshSharedThreads:P,shareThread:Y,unshareThread:R}),[O,F,q,j,P,Y,R]),U=w.useCallback(M=>{if(!(M!=null&&M.threadId))return;const I={threadId:M.threadId,title:M.title||`Thread ${M.threadId.slice(0,8)}`,createdAt:M.createdAt||new Date().toISOString(),updatedAt:M.updatedAt||new Date().toISOString(),messageCount:M.messageCount??1};i(G=>{let X=!1;const _=G.map(B=>B.threadId===I.threadId?(X=!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 X?_:(console.debug("[useThreadsState] thread_info: adding thread to list",I.threadId),[I,...G])})},[]),W=w.useCallback(()=>S(null),[]);return{threads:s,currentThreadId:a,currentThreadIdRef:T,setCurrentThreadId:l,isLoadingThreads:c,threadsError:p,sharedThreads:f,isLoadingSharedThreads:x,actions:K,addThreadFromEvent:U,shareInFlight:k,shareStatus:y,clearShareStatus:W}}const hu=w.createContext(null);function mu({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:p,isLoadingSharedThreads:m,actions:f,addThreadFromEvent:v,shareInFlight:x,shareStatus:g,clearShareStatus:b}=pu({api:o,initialThreadId:t,onError:n,onThreadChange:r}),y=w.useMemo(()=>({threads:s,currentThreadId:i,setCurrentThreadId:a,currentThreadIdRef:l,isLoading:c,error:d,sharedThreads:p,isLoadingSharedThreads:m,actions:f,shareInFlight:x,shareStatus:g,clearShareStatus:b,addThreadFromEvent:v}),[s,i,a,l,c,d,p,m,f,x,g,b,v]);return u.jsx(hu.Provider,{value:y,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=tb(t);if(n)try{return JSON.parse(n)}catch{return null}return null}}function tb(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 gu(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(gu(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(gu(e))return"";try{const t=eo(e);return t===void 0?"":typeof t=="string"?t:JSON.stringify(t,null,2)}catch{return""}}function nb(e){return typeof e!="string"?!1:/^[\s\n]*[-*]\s|^[\s\n]*#+\s|```|^\s*\[.*\]\(|^>\s/.test(e)}function rb(e){const t=vr(e);return typeof e=="string"&&nb(e)?{content:e,isMarkdown:!0}:{content:t,isMarkdown:!1}}function br(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 br(n)}return e}return typeof e=="object"&&!Array.isArray(e)&&e.content!==void 0?br(e.content):e}function ob(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 sb(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 ib(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function xu(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 ab(e){if(!e)return"image/png";const t=e.trim();return t?t.includes("/")?t:`image/${t}`:"image/png"}function lb(e){const t=[],n=r=>{r&&r.trim()&&t.push(r.trim())};return e&&(n(e.plotId),n(e.artifactId)),t}function cb({base64:e,url:t,formatHint:n,extras:r}){const o=typeof e=="string"&&e.length>0,s=ab(n),i=o?`data:${s};base64,${e}`:t,a=lb(r),l=a.length?a.join(" / "):void 0,c=l?`${l} artifact`:"artifact image";return{src:i,alt:c,label:l}}function ub(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 cb({base64:t,url:n,formatHint:r,extras:{plotId:e.plotId,artifactId:e.artifactId}})}function vu(e){var n;const t=(n=e.additionalKwargs)==null?void 0:n.toolProgress;return Array.isArray(t)?t:[]}const db={messages:[],assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,messagesStreamMeta:{},pendingInterrupt:null};function fb(e,t){var n;switch(t.type){case"reset":return{messages: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 bu(e,t.payload.ev);case"batch":{const{events:r}=t.payload;return r.length?r.reduce((o,s)=>bu(o,s),e):e}default:return e}}function pb(e=[]){const[t,n]=w.useReducer(fb,{...db,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,p)=>n({type:"seed",payload:{messages:d,...p??{}}}),prepend:d=>n({type:"prepend",payload:{messages:d}}),pushUser:(d,p)=>n({type:"user_message",payload:{message:d,editingMessageId:p}}),onEvent:l}),[l]);return{state:t,dispatch:n,...c}}function bu(e,t){var n,r,o;if(t.type==="message.start"&&t.role==="assistant"){const s=t.id,i=fu(t.model);if(e.messages.some(c=>c.id===s)){const c=e.messagesStreamMeta??{},d={...c,[s]:c[s]??{lastSeq:t.seq??null,lastText:""}};return{...e,assemblingId:s,messagesStreamMeta:d}}const l={id:s,role:"assistant",name:i||void 0,model:t.model,createdAt:new Date().toISOString(),content:[]};return{...e,assemblingId:s,messages:[...e.messages,l]}}if(t.type==="tool.start")return mb(e,t);if(t.type==="tool.progress")return gb(e,t);if(t.type==="tool.end")return xb(e,t);if(t.type==="message.delta"){const s=e.assemblingId??lu(e.messages);if(!s)return e;const i=e.messages,a=i.findIndex(C=>C.id===s&&C.role==="assistant");if(a===-1)return e;const l=i[a],c=e.messagesStreamMeta,d=c??{},p=d[s],m=p??{lastSeq:null,lastText:cu(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:x,changed:g}=uu(l.content,t.delta,m,f);if(!g)return e;const b={...l,content:v},y=Zr(i,a,b),S=!p||p.lastSeq!==x.lastSeq||p.lastText!==x.lastText,k=S?{...d,[s]:x}:c;return S?{...e,messages:y,messagesStreamMeta:k}:{...e,messages:y}}if(t.type==="message.end"){const s=e.assemblingId??lu(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 p;return(d==null?void 0:d.type)==="text"&&((p=d.text)==null?void 0:p.trim())}))){console.debug("[MessageReducer] pruning assistant message with no visible text",{id:l.id,contentTypes:(r=l.content)==null?void 0:r.map(p=>p==null?void 0:p.type),contentPreview:(o=l.content)==null?void 0:o.map(p=>(p==null?void 0:p.type)==="text"?String(p.text).slice(0,100):p==null?void 0:p.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=Jv(e.messages,t.checkpointId,s);return{...e,lastCheckpointId:t.checkpointId,lastCheckpointNs:s,messages:i}}if(t.type==="error"){const s={id:`err-${Date.now()}`,role:"system",content:[{type:"text",text:`Error: ${t.message}`}],createdAt:new Date().toISOString()};return{...e,messages:[...e.messages,s]}}if(t.type==="state_history"){const s=Xn(t),i=s.interrupt,a=s.latest,l=i===null?Yv(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 yu(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 hb(e){if(e==null)return[];const t=br(e);if(typeof t=="string"&&t.trim())return[{type:"text",text:t}];const n=vr(t??e);return n?[{type:"text",text:n}]:[]}function Su(e,t){const n=e.additionalKwargs??{},r=Array.isArray(n.toolProgress)?[...n.toolProgress]:[],o={...n,toolProgress:[...r,t]};return{...e,additionalKwargs:o}}function mb(e,t){const n=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=yu(s,n,o,t.args);return{...e,messages:[...e.messages,i]}}function gb(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=Su(e.messages[r],o);return{...e,messages:Zr(e.messages,r,a)}}function xb(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,yu(r,n,v,{})],s=o.length-1}const i=o[s],a=t.output??t.error??null,l=hb(a),c=[...i.content,...l],d={type:t.type,content:typeof t.output=="string"?t.output:void 0,seq:t.seq??null,timestamp:new Date().toISOString()};t.artifact&&(d.artifact=t.artifact);const p=Su(i,d),m=t.artifact??i.artifact,f={...p,name:t.name??t.tool??i.name,content:c,artifact:m,additionalKwargs:{...p.additionalKwargs??{},toolStreaming:!1}};return{...e,messages:Zr(o,s,f)}}function Cu({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,p]=w.useState(null),f=w.useMemo(()=>Xn(d),[d]).checkpoints,v=rc(f),x=v.timeline,[g,b]=w.useState(!1),[y,S]=w.useState(!1),[k,C]=w.useState(null),T=w.useRef(r),E=w.useRef(null),j=w.useRef(null),P=w.useRef(null),O=w.useRef(null),F=w.useRef(null),q=w.useRef(new Map),Y=w.useRef(null);w.useEffect(()=>{T.current=r},[r]);const R=w.useCallback(async N=>{var z,$;if(!N.threadId)return;const L=N.threadId;(z=N.onStart)==null||z.call(N),N.setLoading(!0);try{await N.action(L)}catch(D){if(!qc(D)&&T.current===L){const Q=String(D);($=N.handleError)==null||$.call(N,Q),n==null||n(Q)}throw D}finally{N.setLoading(!1)}},[n]),K=w.useCallback(async(N,L)=>{var Q;if(!N)return;const z=`${N}:${L??"latest"}`,$=q.current.get(z);if($)return $;(Q=Y.current)==null||Q.abort();const D=new AbortController;Y.current=D;const J=R({threadId:N,setLoading:b,onStart:()=>C(null),handleError:ie=>C(ie),action:async ie=>{const Z=await e.getStateHistory({threadId:ie,checkpointId:L??void 0,signal:D.signal});if(T.current!==ie){console.log(`[useThreadHistoryState] Thread changed during load (was ${ie}, now ${T.current}), discarding stale data`);return}const{checkpoints:ue}=Xn(Z),he=ue.find(ke=>ke.messages&&ke.messages.length>0)??(L?ue.find(ke=>ke.checkpointId===L):null)??ue[0];t((he==null?void 0:he.messages)??[],{checkpointId:(he==null?void 0:he.checkpointId)??null,checkpointNs:(he==null?void 0:he.checkpointNs)??null}),p(Z)}});q.current.set(z,J);try{await J}finally{q.current.delete(z),Y.current===D&&(Y.current=null)}return T.current===N&&(F.current=z),J},[e,t,R]),U=w.useCallback(async(N,L)=>{O.current=N;try{await K(N,L)}catch(z){if(!qc(z))throw z}finally{O.current===N&&(O.current=null)}},[K]),W=w.useCallback(N=>{j.current=N},[]),M=w.useCallback(N=>{P.current=N},[]),I=w.useCallback(N=>{const L=N.threadId??T.current;if(!L||T.current&&T.current!==L)return;const{checkpoints:z}=Xn(N);if(!z.length)return;const $=z.find(J=>J.messages&&J.messages.length>0)??z.find(J=>!!J.checkpointId)??z[0],D=P.current===L;!l&&!D&&t(($==null?void 0:$.messages)??[],{checkpointId:($==null?void 0:$.checkpointId)??null,checkpointNs:($==null?void 0:$.checkpointNs)??null}),p(N),F.current=`${L}:latest`,j.current=null,P.current===L&&(P.current=null)},[t,l]),G=w.useCallback(async(N,L)=>{const z=T.current;await R({threadId:z,setLoading:S,action:async $=>{const D=await e.getStateHistory({threadId:$,checkpointId:N,checkpointNs:L??void 0});if(T.current!==$)return;const{checkpoints:J}=Xn(D),Q=J.find(ie=>ie.checkpointId===N&&(L?ie.checkpointNs===L:!0));if(!Q){console.warn("[useThreadHistoryState] Requested checkpoint not found:",{checkpointId:N,checkpointNs:L});return}p(D),t(Q.messages??[],{checkpointId:Q.checkpointId??null,checkpointNs:Q.checkpointNs??null})}}).catch(()=>{})},[e,t,R]),X=w.useCallback((N,L)=>{t(c(),{checkpointId:N??null,checkpointNs:L??null})},[c,t]),_=w.useCallback(async()=>{T.current&&await U(T.current)},[U]);w.useEffect(()=>{if(!a||!r||g||l)return;if(j.current===r){j.current=null,E.current=r;return}if(P.current===r){E.current=r;return}if(O.current===r){O.current=null,E.current=r;return}if(E.current===r)return;E.current=r;let N;const L=`${r}:latest`;F.current!==L&&U(r,N)},[a,r,s,i,o,g,l,U]);const B=w.useCallback(()=>{p(null),b(!1),S(!1),C(null),j.current=null,P.current=null,E.current=null,F.current=null,O.current=null},[]);return{threadCheckpoints:f,threadTimeline:x,checkpointIndex:v,isLoadingThread:g,isLoadingCheckpoint:y,threadStateError:k,loadThread:U,navigateToCheckpoint:G,setCurrentCheckpointId:X,returnToLatest:_,handleStateHistoryEvent:I,markSkipNextLoad:W,markStreamPendingThread:M,resetHistoryState:B}}const Tu=w.createContext(null),ku=w.createContext(null);function to(){const e=w.useContext(Tu);if(!e)throw new Error("useThreadState must be used within a ThreadStateProvider");return e}function Eu(){const e=w.useContext(ku);if(!e)throw new Error("useThreadStateUpdater must be used within a ThreadStateProvider");return e}function Iu({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:p,onEvent:m}=pb(),{threadCheckpoints:f,threadTimeline:v,checkpointIndex:x,isLoadingThread:g,isLoadingCheckpoint:b,threadStateError:y,loadThread:S,navigateToCheckpoint:k,setCurrentCheckpointId:C,returnToLatest:T,handleStateHistoryEvent:E,markSkipNextLoad:j,markStreamPendingThread:P,resetHistoryState:O}=Cu({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,q]=w.useState(()=>async()=>{throw new Error("clearThread is not ready")}),[Y,R]=w.useState(()=>async()=>{throw new Error("respondToInterrupt is not ready")});w.useEffect(()=>{l||(d([],{}),O())},[l,d,O]);const K=w.useCallback(G=>q(()=>G),[]),U=w.useCallback(G=>R(()=>G),[]),W=w.useMemo(()=>({assemblingMessageId:c.assemblingId??null}),[c.assemblingId]),M=w.useMemo(()=>({threadId:l,messages:c.messages,interrupt:c.pendingInterrupt,checkpoint:{id:c.lastCheckpointId??null,namespace:c.lastCheckpointNs??null},checkpoints:f,checkpointIndex:x,timelineCheckpoints:v,metadata:W,isLoading:g,isLoadingCheckpoint:b,error:y,clearState:F,navigateToCheckpoint:k,setCurrentCheckpointId:C,returnToLatest:T,loadThread:S,clearThread:F,respondToInterrupt:Y,messagePreviews:x.messagePreviews,handleStateHistoryEvent:E,markSkipNextLoad:j,markStreamPendingThread:P,resetHistoryState:O,pushUser:p,onEvent:m}),[l,c,f,v,x,W,g,b,y,F,k,C,T,S,Y,x.messagePreviews,E,j,P,O,p,m]),I=w.useMemo(()=>({registerClearThread:K,registerRespondToInterrupt:U}),[K,U]);return u.jsx(ku.Provider,{value:I,children:u.jsx(Tu.Provider,{value:M,children:e})})}function Nu(e,t){if(!e)return null;const n=Pn(e);if(!n)return null;const r=Pn(n.configurable)??n;return Rn(r,t)??null}function vb(e){const t=Nu(e,["checkpoint_id","checkpointId"]);if(!t)return null;const n=Nu(e,["checkpoint_ns","checkpointNs"]);return{checkpointId:t,checkpointNs:n}}function bb(e,t){const n=typeof e.step=="number"?e.step:Number.POSITIVE_INFINITY,r=typeof t.step=="number"?t.step:Number.POSITIVE_INFINITY;if(n!==r)return n-r;const o=e.createdAt?Date.parse(e.createdAt):0,s=t.createdAt?Date.parse(t.createdAt):0;return o-s}function wb(e,t){const n=[...e].sort(bb);for(const r of n){if(r.messageId!==t)continue;const o=vb(r.parentConfig);if(!o)throw new Error(`Parent checkpoint info missing for message ${t}`);return o}throw new Error(`Message ${t} not found in timeline`)}const Au=w.createContext(null),ju=w.createContext(!1);function yb({children:e,initialThreadId:t=null,initialCheckpointId:n=null,initialCheckpointNs:r=null,autoLoadInitial:o=!0,onError:s,onAuthError:i,onThreadChange:a,onConnectionError:l,onToolEnd:c}){const{api:d,baseUrl:p}=Jr(),m=w.useMemo(()=>xn(p),[p]),{stream:f,stop:v,isStreaming:x,error:g,setToken:b}=Zv({baseUrl:m}),[y,S]=w.useState(!1);return w.useEffect(()=>{S(x)},[x]),u.jsx(mu,{initialThreadId:t,onError:s,onThreadChange:a,children:u.jsx(Iu,{initialThreadId:t,initialCheckpointId:n,initialCheckpointNs:r,autoLoadInitial:o,onError:s,isStreaming:y,children:u.jsx(ju.Provider,{value:!0,children:u.jsx(Sb,{api:d,streamApi:{stream:f,stop:v,isStreaming:x,error:g,setToken:b},onError:s,onAuthError:i,onConnectionError:l,onToolEnd:c,children:e})})})})}function Sb({children:e,api:t,streamApi:n,onError:r,onAuthError:o,onConnectionError:s,onToolEnd:i}){const{stream:a,stop:l,isStreaming:c,error:d,setToken:p}=n,{setCurrentThreadId:m,currentThreadIdRef:f,addThreadFromEvent:v}=xr(),{checkpoint:x,timelineCheckpoints:g,handleStateHistoryEvent:b,markSkipNextLoad:y,markStreamPendingThread:S,resetHistoryState:k,pushUser:C,onEvent:T}=to(),{registerClearThread:E,registerRespondToInterrupt:j}=Eu(),P=w.useCallback(W=>{v(W),f.current!==W.threadId&&((W.created??!f.current)&&y(W.threadId),S(W.threadId),m(W.threadId))},[v,y,S,m,f]),O=w.useCallback(W=>{W.type==="thread_info"?P(W):W.type==="state_history"?b(W):W.type==="tool.end"?i==null||i(W):T(W)},[P,b,T,i]),F=w.useCallback(W=>{a(W,O,{onError:M=>{console.error("[StreamingProvider] Stream error:",M),r==null||r(M)},onAuthError:M=>{console.error("[StreamingProvider] Auth error:",M),o==null||o(M)},onConnectionError:M=>{console.error("[StreamingProvider] Connection error:",M),s==null||s(M)}})},[a,O,r,o,s]),q=w.useRef(x);w.useEffect(()=>{q.current=x},[x]);const Y=w.useCallback(async(W,M,I)=>{const G=f.current;if(!G)throw new Error("No active thread to handle interrupt");const X=M?I??!0:!1,_=q.current,B={threadId:G,checkpointId:_.id??void 0,checkpointNs:_.namespace??void 0,command:{kind:"resume",value:X}};F(B)},[f,F]);w.useEffect(()=>{j(Y)},[Y,j]);const R=w.useCallback(async()=>{l(),k(),m(null)},[k,m,l]);w.useEffect(()=>{E(R)},[R,E]);const K=w.useCallback(async(W,M)=>{let I=f.current;const G=(W==null?void 0:W.text)??"",X=(W==null?void 0:W.attachments)??[],_=(G==null?void 0:G.trim())??"",B={...(W==null?void 0:W.payload)??{}},N=Array.isArray(B.messages)?B.messages:void 0;N&&delete B.messages;const L=!!(N&&N.length);if(!I&&!_&&X.length===0&&!L)return;if(!I){const je=Math.floor(Date.now()/1e3).toString(16).padStart(8,"0"),Be=Array.from({length:4},()=>Math.floor(Math.random()*4294967295).toString(16).padStart(8,"0")).join("").slice(0,16);I=`${je}${Be}`,y(I),m(I)}const{contentParts:z,filesInfo:$}=await iu(X),D=[...z];_&&D.push({type:"text",text:G});const J=M==null?void 0:M.originalMessageId,Q=!!(M!=null&&M.edit&&J),ie=!L&&D.length>0;let Z=null;ie&&(Z={id:Q?J:`msg-${Date.now()}`,role:"user",content:D,createdAt:new Date().toISOString()},Q?C(Z,J):C(Z));const ue=L?N:Z?[Z]:[],he={...B,...$.length?{files_info:$}:{}};ue.length?he.messages=ue:"messages"in he||(he.messages=[]);let ke=(M==null?void 0:M.checkpointId)??x.id??void 0,Le=(M==null?void 0:M.checkpointNs)??x.namespace??void 0;if(Q&&J){const je=wb(g,J);ke=je.checkpointId,Le=je.checkpointNs??void 0}const $e={threadId:I,payload:he,checkpointId:ke,checkpointNs:Le,edit:!!(M!=null&&M.edit)};F($e)},[x,f,y,C,F,g]),U=w.useMemo(()=>({isStreaming:c,error:d,connectionState:c?"connected":"idle",submit:K,send:K,stop:l,setAuthToken:p}),[c,d,K,l,p]);return u.jsx(Au.Provider,{value:U,children:e})}function Fi(){const e=w.useContext(Au);if(!e)throw new Error("useStream must be used within StreamingProvider");return e}function Cb(){return w.useContext(ju)}function _u(e){return typeof e=="object"&&e!==null}function Tb(e,t){if(Object.is(e,t))return!0;if(!_u(e)||!_u(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 Tb(t.current,e)||(t.current=e,n.current=e),n.current}function wr({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 p=Pu(t),m=no(a),f=no(l),v=no(i),x=no(c),g=no(d),b=w.useMemo(()=>({initialThreadId:n,initialCheckpointId:r,initialCheckpointNs:o,autoLoadInitial:s,onError:m,onAuthError:f,onConnectionError:v,onThreadChange:x,onToolEnd:g}),[n,r,o,s,m,f,v,x,g]);return u.jsx(ou,{apiConfig:p,children:u.jsx(yb,{...b,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 kb(e){if(typeof e!="string")return;const t=e.trim();if(t)return xn(t)}function Ru(){const e=[yr("__API_BASE_URL__"),yr("__CHAT_API_BASE_URL__"),yr("__CHAT_API_URL__")];for(const t of e){const n=kb(t);if(n)return n}}function Mu(){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 Ou(...e){for(const t of e)if(typeof t=="string"&&t.trim())return xn(t);return xn()}function Du(){const e={},t=Ru(),n=Mu();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function Lu(){const e=Du(),t=Nn.getAuthToken(),n=Ru();return{apiBaseUrl:Ou(e.baseUrl,Nn.baseUrl,n),apiKey:t||e.apiKey||Mu()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,darkMode:!1,enableSound:!1,messageHistory:100}}const Bi="chat-settings";function $u(){try{const e=localStorage.getItem(Bi);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function Fu(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 Eb(){const e=Lu(),t=$u(),n=Nn.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:Ou(Nn.baseUrl,r,e.apiBaseUrl)}}function Ib(e){Nn.updateConfig({baseUrl:e.apiBaseUrl,authToken:e.apiKey??void 0}),Fu(e)}function ne(...e){return cx.twMerge(lx.clsx(e))}const Nb=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"}}),Ze=h.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?Kt.Slot:"button";return u.jsx(i,{className:ne(Nb({variant:t,size:n,className:e})),ref:s,...o})});Ze.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 Bu(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=Bu(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():Bu(e[o],null)}}}}function Re(...e){return h.useCallback(Mn(...e),e)}function Ab(e,t){const n=h.createContext(t),r=s=>{const{children:i,...a}=s,l=h.useMemo(()=>a,Object.values(a));return u.jsx(n.Provider,{value:l,children:i})};r.displayName=e+"Provider";function o(s){const i=h.useContext(n);if(i)return i;if(t!==void 0)return t;throw new Error(`\`${s}\` must be used within \`${e}\``)}return[r,o]}function an(e,t=[]){let n=[];function r(s,i){const a=h.createContext(i),l=n.length;n=[...n,i];const c=p=>{var b;const{scope:m,children:f,...v}=p,x=((b=m==null?void 0:m[e])==null?void 0:b[l])||a,g=h.useMemo(()=>v,Object.values(v));return u.jsx(x.Provider,{value:g,children:f})};c.displayName=s+"Provider";function d(p,m){var x;const f=((x=m==null?void 0:m[e])==null?void 0:x[l])||a,v=h.useContext(f);if(v)return v;if(i!==void 0)return i;throw new Error(`\`${p}\` must be used within \`${s}\``)}return[c,d]}const o=()=>{const s=n.map(i=>h.createContext(i));return function(a){const l=(a==null?void 0:a[e])||s;return h.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return o.scopeName=e,[r,jb(o,...t)]}function jb(...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 p=l(s)[`__scope${c}`];return{...a,...p}},{});return h.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var Tt=globalThis!=null&&globalThis.document?h.useLayoutEffect:()=>{},_b=h[" useInsertionEffect ".trim().toString()]||Tt;function On({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=Pb({defaultProp:t,onChange:n}),a=e!==void 0,l=a?e:o;{const d=h.useRef(e!==void 0);h.useEffect(()=>{const p=d.current;p!==a&&console.warn(`${r} is changing from ${p?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),d.current=a},[a,r])}const c=h.useCallback(d=>{var p;if(a){const m=Rb(d)?d(e):d;m!==e&&((p=i.current)==null||p.call(i,m))}else s(d)},[a,e,s,i]);return[l,c]}function Pb({defaultProp:e,onChange:t}){const[n,r]=h.useState(e),o=h.useRef(n),s=h.useRef(t);return _b(()=>{s.current=t},[t]),h.useEffect(()=>{var i;o.current!==n&&((i=s.current)==null||i.call(s,n),o.current=n)},[n,o]),[n,r,s]}function Rb(e){return typeof e=="function"}var Mb=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],me=Mb.reduce((e,t)=>{const n=Kt.createSlot(`Primitive.${t}`),r=h.forwardRef((o,s)=>{const{asChild:i,...a}=o,l=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),u.jsx(l,{...a,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function 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=x=>{const{scope:g,children:b}=x,y=w.useRef(null),S=w.useRef(new Map).current;return u.jsx(o,{scope:g,itemMap:S,collectionRef:y,children:b})};i.displayName=t;const a=e+"CollectionSlot",l=Kt.createSlot(a),c=w.forwardRef((x,g)=>{const{scope:b,children:y}=x,S=s(a,b),k=Re(g,S.collectionRef);return u.jsx(l,{ref:k,children:y})});c.displayName=a;const d=e+"CollectionItemSlot",p="data-radix-collection-item",m=Kt.createSlot(d),f=w.forwardRef((x,g)=>{const{scope:b,children:y,...S}=x,k=w.useRef(null),C=Re(g,k),T=s(d,b);return w.useEffect(()=>(T.itemMap.set(k,{ref:k,...S}),()=>void T.itemMap.delete(k))),u.jsx(m,{[p]:"",ref:C,children:y})});f.displayName=d;function v(x){const g=s(e+"CollectionConsumer",x);return w.useCallback(()=>{const y=g.collectionRef.current;if(!y)return[];const S=Array.from(y.querySelectorAll(`[${p}]`));return Array.from(g.itemMap.values()).sort((T,E)=>S.indexOf(T.ref.current)-S.indexOf(E.ref.current))},[g.collectionRef,g.itemMap])}return[{Provider:i,Slot:c,ItemSlot:f},v,r]}var Ob=h.createContext(void 0);function Zo(e){const t=h.useContext(Ob);return e||t||"ltr"}function ft(e){const t=h.useRef(e);return h.useEffect(()=>{t.current=e}),h.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function Db(e,t=globalThis==null?void 0:globalThis.document){const n=ft(e);h.useEffect(()=>{const r=o=>{o.key==="Escape"&&n(o)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var Lb="DismissableLayer",Hi="dismissableLayer.update",$b="dismissableLayer.pointerDownOutside",Fb="dismissableLayer.focusOutside",zu,Hu=h.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Sr=h.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...l}=e,c=h.useContext(Hu),[d,p]=h.useState(null),m=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,f]=h.useState({}),v=Re(t,E=>p(E)),x=Array.from(c.layers),[g]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),b=x.indexOf(g),y=d?x.indexOf(d):-1,S=c.layersWithOutsidePointerEventsDisabled.size>0,k=y>=b,C=zb(E=>{const j=E.target,P=[...c.branches].some(O=>O.contains(j));!k||P||(o==null||o(E),i==null||i(E),E.defaultPrevented||a==null||a())},m),T=Hb(E=>{const j=E.target;[...c.branches].some(O=>O.contains(j))||(s==null||s(E),i==null||i(E),E.defaultPrevented||a==null||a())},m);return Db(E=>{y===c.layers.size-1&&(r==null||r(E),!E.defaultPrevented&&a&&(E.preventDefault(),a()))},m),h.useEffect(()=>{if(d)return n&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(zu=m.body.style.pointerEvents,m.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(d)),c.layers.add(d),Wu(),()=>{n&&c.layersWithOutsidePointerEventsDisabled.size===1&&(m.body.style.pointerEvents=zu)}},[d,m,n,c]),h.useEffect(()=>()=>{d&&(c.layers.delete(d),c.layersWithOutsidePointerEventsDisabled.delete(d),Wu())},[d,c]),h.useEffect(()=>{const E=()=>f({});return document.addEventListener(Hi,E),()=>document.removeEventListener(Hi,E)},[]),u.jsx(me.div,{...l,ref:v,style:{pointerEvents:S?k?"auto":"none":void 0,...e.style},onFocusCapture:ae(e.onFocusCapture,T.onFocusCapture),onBlurCapture:ae(e.onBlurCapture,T.onBlurCapture),onPointerDownCapture:ae(e.onPointerDownCapture,C.onPointerDownCapture)})});Sr.displayName=Lb;var Bb="DismissableLayerBranch",Uu=h.forwardRef((e,t)=>{const n=h.useContext(Hu),r=h.useRef(null),o=Re(t,r);return h.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})});Uu.displayName=Bb;function zb(e,t=globalThis==null?void 0:globalThis.document){const n=ft(e),r=h.useRef(!1),o=h.useRef(()=>{});return h.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){Vu($b,n,c,{discrete:!0})};const c={originalEvent:a};a.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=l,t.addEventListener("click",o.current,{once:!0})):l()}else t.removeEventListener("click",o.current);r.current=!1},i=window.setTimeout(()=>{t.addEventListener("pointerdown",s)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",s),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function Hb(e,t=globalThis==null?void 0:globalThis.document){const n=ft(e),r=h.useRef(!1);return h.useEffect(()=>{const o=s=>{s.target&&!r.current&&Vu(Fb,n,{originalEvent:s},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function Wu(){const e=new CustomEvent(Hi);document.dispatchEvent(e)}function Vu(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 Ub=Sr,Wb=Uu,Ui=0;function Wi(){h.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Ku()),document.body.insertAdjacentElement("beforeend",e[1]??Ku()),Ui++,()=>{Ui===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Ui--}},[])}function Ku(){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",qu={bubbles:!1,cancelable:!0},Vb="FocusScope",Qo=h.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,l]=h.useState(null),c=ft(o),d=ft(s),p=h.useRef(null),m=Re(t,x=>l(x)),f=h.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;h.useEffect(()=>{if(r){let x=function(S){if(f.paused||!a)return;const k=S.target;a.contains(k)?p.current=k:Dn(p.current,{select:!0})},g=function(S){if(f.paused||!a)return;const k=S.relatedTarget;k!==null&&(a.contains(k)||Dn(p.current,{select:!0}))},b=function(S){if(document.activeElement===document.body)for(const C of S)C.removedNodes.length>0&&Dn(a)};document.addEventListener("focusin",x),document.addEventListener("focusout",g);const y=new MutationObserver(b);return a&&y.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",x),document.removeEventListener("focusout",g),y.disconnect()}}},[r,a,f.paused]),h.useEffect(()=>{if(a){Xu.add(f);const x=document.activeElement;if(!a.contains(x)){const b=new CustomEvent(Vi,qu);a.addEventListener(Vi,c),a.dispatchEvent(b),b.defaultPrevented||(Kb(Jb(Gu(a)),{select:!0}),document.activeElement===x&&Dn(a))}return()=>{a.removeEventListener(Vi,c),setTimeout(()=>{const b=new CustomEvent(Ki,qu);a.addEventListener(Ki,d),a.dispatchEvent(b),b.defaultPrevented||Dn(x??document.body,{select:!0}),a.removeEventListener(Ki,d),Xu.remove(f)},0)}}},[a,c,d,f]);const v=h.useCallback(x=>{if(!n&&!r||f.paused)return;const g=x.key==="Tab"&&!x.altKey&&!x.ctrlKey&&!x.metaKey,b=document.activeElement;if(g&&b){const y=x.currentTarget,[S,k]=qb(y);S&&k?!x.shiftKey&&b===k?(x.preventDefault(),n&&Dn(S,{select:!0})):x.shiftKey&&b===S&&(x.preventDefault(),n&&Dn(k,{select:!0})):b===y&&x.preventDefault()}},[n,r,f.paused]);return u.jsx(me.div,{tabIndex:-1,...i,ref:m,onKeyDown:v})});Qo.displayName=Vb;function Kb(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Dn(r,{select:t}),document.activeElement!==n)return}function qb(e){const t=Gu(e),n=Yu(t,e),r=Yu(t.reverse(),e);return[n,r]}function Gu(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 Yu(e,t){for(const n of e)if(!Gb(n,{upTo:t}))return n}function Gb(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function Yb(e){return e instanceof HTMLInputElement&&"select"in e}function Dn(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Yb(e)&&t&&e.select()}}var Xu=Xb();function Xb(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=Ju(e,t),e.unshift(t)},remove(t){var n;e=Ju(e,t),(n=e[0])==null||n.resume()}}}function Ju(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Jb(e){return e.filter(t=>t.tagName!=="A")}var Zb=h[" useId ".trim().toString()]||(()=>{}),Qb=0;function At(e){const[t,n]=h.useState(Zb());return Tt(()=>{n(r=>r??String(Qb++))},[e]),t?`radix-${t}`:""}const ew=["top","right","bottom","left"],Ln=Math.min,Yt=Math.max,es=Math.round,ts=Math.floor,vn=e=>({x:e,y:e}),tw={left:"right",right:"left",bottom:"top",top:"bottom"},nw={start:"end",end:"start"};function qi(e,t,n){return Yt(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 rw=new Set(["top","bottom"]);function bn(e){return rw.has(jn(e))?"y":"x"}function Xi(e){return Gi(bn(e))}function ow(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 sw(e){const t=ns(e);return[Ji(e),t,Ji(t)]}function Ji(e){return e.replace(/start|end/g,t=>nw[t])}const Zu=["left","right"],Qu=["right","left"],iw=["top","bottom"],aw=["bottom","top"];function lw(e,t,n){switch(e){case"top":case"bottom":return n?t?Qu:Zu:t?Zu:Qu;case"left":case"right":return t?iw:aw;default:return[]}}function cw(e,t,n,r){const o=Cr(e);let s=lw(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=>tw[t])}function uw(e){return{top:0,right:0,bottom:0,left:0,...e}}function ed(e){return typeof e!="number"?uw(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 td(e,t,n){let{reference:r,floating:o}=e;const s=bn(t),i=Xi(t),a=Yi(i),l=jn(t),c=s==="y",d=r.x+r.width/2-o.width/2,p=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:p};break;case"left":f={x:r.x-o.width,y:p};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 dw=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:p}=td(c,r,l),m=r,f={},v=0;for(let x=0;x<a.length;x++){const{name:g,fn:b}=a[x],{x:y,y:S,data:k,reset:C}=await b({x:d,y:p,initialPlacement:r,placement:m,strategy:o,middlewareData:f,rects:c,platform:i,elements:{reference:e,floating:t}});d=y??d,p=S??p,f={...f,[g]:{...f[g],...k}},C&&v<=50&&(v++,typeof C=="object"&&(C.placement&&(m=C.placement),C.rects&&(c=C.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):C.rects),{x:d,y:p}=td(c,m,l)),x=-1)}return{x:d,y:p,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:p="floating",altBoundary:m=!1,padding:f=0}=An(t,e),v=ed(f),g=a[m?p==="floating"?"reference":"floating":p],b=rs(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(g)))==null||n?g:g.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:c,rootBoundary:d,strategy:l})),y=p==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,S=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),k=await(s.isElement==null?void 0:s.isElement(S))?await(s.getScale==null?void 0:s.getScale(S))||{x:1,y:1}:{x:1,y:1},C=rs(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:y,offsetParent:S,strategy:l}):y);return{top:(b.top-C.top+v.top)/k.y,bottom:(C.bottom-b.bottom+v.bottom)/k.y,left:(b.left-C.left+v.left)/k.x,right:(C.right-b.right+v.right)/k.x}}const fw=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 p=ed(d),m={x:n,y:r},f=Xi(o),v=Yi(f),x=await i.getDimensions(c),g=f==="y",b=g?"top":"left",y=g?"bottom":"right",S=g?"clientHeight":"clientWidth",k=s.reference[v]+s.reference[f]-m[f]-s.floating[v],C=m[f]-s.reference[f],T=await(i.getOffsetParent==null?void 0:i.getOffsetParent(c));let E=T?T[S]:0;(!E||!await(i.isElement==null?void 0:i.isElement(T)))&&(E=a.floating[S]||s.floating[v]);const j=k/2-C/2,P=E/2-x[v]/2-1,O=Ln(p[b],P),F=Ln(p[y],P),q=O,Y=E-x[v]-F,R=E/2-x[v]/2+j,K=qi(q,R,Y),U=!l.arrow&&Cr(o)!=null&&R!==K&&s.reference[v]/2-(R<q?O:F)-x[v]/2<0,W=U?R<q?R-q:R-Y:0;return{[f]:m[f]+W,data:{[f]:K,centerOffset:R-K-W,...U&&{alignmentOffset:W}},reset:U}}}),pw=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:p=!0,fallbackPlacements:m,fallbackStrategy:f="bestFit",fallbackAxisSideDirection:v="none",flipAlignment:x=!0,...g}=An(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const b=jn(o),y=bn(a),S=jn(a)===a,k=await(l.isRTL==null?void 0:l.isRTL(c.floating)),C=m||(S||!x?[ns(a)]:sw(a)),T=v!=="none";!m&&T&&C.push(...cw(a,x,v,k));const E=[a,...C],j=await ro(t,g),P=[];let O=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&P.push(j[b]),p){const R=ow(o,i,k);P.push(j[R[0]],j[R[1]])}if(O=[...O,{placement:o,overflows:P}],!P.every(R=>R<=0)){var F,q;const R=(((F=s.flip)==null?void 0:F.index)||0)+1,K=E[R];if(K&&(!(p==="alignment"?y!==bn(K):!1)||O.every(M=>bn(M.placement)===y?M.overflows[0]>0:!0)))return{data:{index:R,overflows:O},reset:{placement:K}};let U=(q=O.filter(W=>W.overflows[0]<=0).sort((W,M)=>W.overflows[1]-M.overflows[1])[0])==null?void 0:q.placement;if(!U)switch(f){case"bestFit":{var Y;const W=(Y=O.filter(M=>{if(T){const I=bn(M.placement);return I===y||I==="y"}return!0}).map(M=>[M.placement,M.overflows.filter(I=>I>0).reduce((I,G)=>I+G,0)]).sort((M,I)=>M[1]-I[1])[0])==null?void 0:Y[0];W&&(U=W);break}case"initialPlacement":U=a;break}if(o!==U)return{reset:{placement:U}}}return{}}}};function nd(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function rd(e){return ew.some(t=>e[t]>=0)}const hw=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=nd(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:rd(i)}}}case"escaped":{const s=await ro(t,{...o,altBoundary:!0}),i=nd(s,n.floating);return{data:{escapedOffsets:i,escaped:rd(i)}}}default:return{}}}}},od=new Set(["left","top"]);async function mw(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=bn(n)==="y",c=od.has(i)?-1:1,d=s&&l?-1:1,p=An(t,e);let{mainAxis:m,crossAxis:f,alignmentAxis:v}=typeof p=="number"?{mainAxis:p,crossAxis:0,alignmentAxis:null}:{mainAxis:p.mainAxis||0,crossAxis:p.crossAxis||0,alignmentAxis:p.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 gw=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 mw(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}}}}},xw=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o}=t,{mainAxis:s=!0,crossAxis:i=!1,limiter:a={fn:g=>{let{x:b,y}=g;return{x:b,y}}},...l}=An(e,t),c={x:n,y:r},d=await ro(t,l),p=bn(jn(o)),m=Gi(p);let f=c[m],v=c[p];if(s){const g=m==="y"?"top":"left",b=m==="y"?"bottom":"right",y=f+d[g],S=f-d[b];f=qi(y,f,S)}if(i){const g=p==="y"?"top":"left",b=p==="y"?"bottom":"right",y=v+d[g],S=v-d[b];v=qi(y,v,S)}const x=a.fn({...t,[m]:f,[p]:v});return{...x,data:{x:x.x-n,y:x.y-r,enabled:{[m]:s,[p]:i}}}}}},vw=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},p=bn(o),m=Gi(p);let f=d[m],v=d[p];const x=An(a,t),g=typeof x=="number"?{mainAxis:x,crossAxis:0}:{mainAxis:0,crossAxis:0,...x};if(l){const S=m==="y"?"height":"width",k=s.reference[m]-s.floating[S]+g.mainAxis,C=s.reference[m]+s.reference[S]-g.mainAxis;f<k?f=k:f>C&&(f=C)}if(c){var b,y;const S=m==="y"?"width":"height",k=od.has(jn(o)),C=s.reference[p]-s.floating[S]+(k&&((b=i.offset)==null?void 0:b[p])||0)+(k?0:g.crossAxis),T=s.reference[p]+s.reference[S]+(k?0:((y=i.offset)==null?void 0:y[p])||0)-(k?g.crossAxis:0);v<C?v=C:v>T&&(v=T)}return{[m]:f,[p]:v}}}},bw=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),p=jn(o),m=Cr(o),f=bn(o)==="y",{width:v,height:x}=s.floating;let g,b;p==="top"||p==="bottom"?(g=p,b=m===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(b=p,g=m==="end"?"top":"bottom");const y=x-d.top-d.bottom,S=v-d.left-d.right,k=Ln(x-d[g],y),C=Ln(v-d[b],S),T=!t.middlewareData.shift;let E=k,j=C;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(j=S),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(E=y),T&&!m){const O=Yt(d.left,0),F=Yt(d.right,0),q=Yt(d.top,0),Y=Yt(d.bottom,0);f?j=v-2*(O!==0||F!==0?O+F:Yt(d.left,d.right)):E=x-2*(q!==0||Y!==0?q+Y:Yt(d.top,d.bottom))}await l({...t,availableWidth:j,availableHeight:E});const P=await i.getDimensions(a.floating);return v!==P.width||x!==P.height?{reset:{rects:!0}}:{}}}};function os(){return typeof window<"u"}function Tr(e){return sd(e)?(e.nodeName||"").toLowerCase():"#document"}function Xt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function wn(e){var t;return(t=(sd(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function sd(e){return os()?e instanceof Node||e instanceof Xt(e).Node:!1}function ln(e){return os()?e instanceof Element||e instanceof Xt(e).Element:!1}function yn(e){return os()?e instanceof HTMLElement||e instanceof Xt(e).HTMLElement:!1}function id(e){return!os()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Xt(e).ShadowRoot}const ww=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)&&!ww.has(o)}const yw=new Set(["table","td","th"]);function Sw(e){return yw.has(Tr(e))}const Cw=[":popover-open",":modal"];function ss(e){return Cw.some(t=>{try{return e.matches(t)}catch{return!1}})}const Tw=["transform","translate","scale","rotate","perspective"],kw=["transform","translate","scale","rotate","perspective","filter"],Ew=["paint","layout","strict","content"];function Zi(e){const t=Qi(),n=ln(e)?cn(e):e;return Tw.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)||kw.some(r=>(n.willChange||"").includes(r))||Ew.some(r=>(n.contain||"").includes(r))}function Iw(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 Nw=new Set(["html","body","#document"]);function kr(e){return Nw.has(Tr(e))}function cn(e){return Xt(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||id(e)&&e.host||wn(e);return id(t)?t.host:t}function ad(e){const t=$n(e);return kr(t)?e.ownerDocument?e.ownerDocument.body:e.body:yn(t)&&oo(t)?t:ad(t)}function so(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=ad(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Xt(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 ld(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}=ld(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 Aw=vn(0);function cd(e){const t=Xt(e);return!Qi()||!t.visualViewport?Aw:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function jw(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Xt(e)?!1:t}function er(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=ta(e);let i=vn(1);t&&(r?ln(r)&&(i=Er(r)):i=Er(e));const a=jw(s,n,r)?cd(s):vn(0);let l=(o.left+a.x)/i.x,c=(o.top+a.y)/i.y,d=o.width/i.x,p=o.height/i.y;if(s){const m=Xt(s),f=r&&ln(r)?Xt(r):r;let v=m,x=ea(v);for(;x&&r&&f!==v;){const g=Er(x),b=x.getBoundingClientRect(),y=cn(x),S=b.left+(x.clientLeft+parseFloat(y.paddingLeft))*g.x,k=b.top+(x.clientTop+parseFloat(y.paddingTop))*g.y;l*=g.x,c*=g.y,d*=g.x,p*=g.y,l+=S,c+=k,v=Xt(x),x=ea(v)}}return rs({width:d,height:p,x:l,y:c})}function as(e,t){const n=is(e).scrollLeft;return t?t.left+n:er(wn(e)).left+n}function ud(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 _w(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=wn(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),p=yn(r);if((p||!p&&!s)&&((Tr(r)!=="body"||oo(i))&&(l=is(r)),yn(r))){const f=er(r);c=Er(r),d.x=f.x+r.clientLeft,d.y=f.y+r.clientTop}const m=i&&!p&&!s?ud(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 Pw(e){return Array.from(e.getClientRects())}function Rw(e){const t=wn(e),n=is(e),r=e.ownerDocument.body,o=Yt(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Yt(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+as(e);const a=-n.scrollTop;return cn(r).direction==="rtl"&&(i+=Yt(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const dd=25;function Mw(e,t){const n=Xt(e),r=wn(e),o=n.visualViewport;let s=r.clientWidth,i=r.clientHeight,a=0,l=0;if(o){s=o.width,i=o.height;const d=Qi();(!d||d&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}const c=as(r);if(c<=0){const d=r.ownerDocument,p=d.body,m=getComputedStyle(p),f=d.compatMode==="CSS1Compat"&&parseFloat(m.marginLeft)+parseFloat(m.marginRight)||0,v=Math.abs(r.clientWidth-p.clientWidth-f);v<=dd&&(s-=v)}else c<=dd&&(s+=c);return{width:s,height:i,x:a,y:l}}const Ow=new Set(["absolute","fixed"]);function Dw(e,t){const n=er(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 fd(e,t,n){let r;if(t==="viewport")r=Mw(e,n);else if(t==="document")r=Rw(wn(e));else if(ln(t))r=Dw(t,n);else{const o=cd(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return rs(r)}function pd(e,t){const n=$n(e);return n===t||!ln(n)||kr(n)?!1:cn(n).position==="fixed"||pd(n,t)}function Lw(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&&Ow.has(o.position)||oo(i)&&!l&&pd(e,i))?r=r.filter(d=>d!==i):o=a,i=$n(i)}return t.set(e,r),r}function $w(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?ss(t)?[]:Lw(t,this._c):[].concat(n),r],a=i[0],l=i.reduce((c,d)=>{const p=fd(t,d,o);return c.top=Yt(p.top,c.top),c.right=Ln(p.right,c.right),c.bottom=Ln(p.bottom,c.bottom),c.left=Yt(p.left,c.left),c},fd(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function Fw(e){const{width:t,height:n}=ld(e);return{width:t,height:n}}function Bw(e,t,n){const r=yn(t),o=wn(t),s=n==="fixed",i=er(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=vn(0);function c(){l.x=as(o)}if(r||!r&&!s)if((Tr(t)!=="body"||oo(o))&&(a=is(t)),r){const f=er(t,!0,s,t);l.x=f.x+t.clientLeft,l.y=f.y+t.clientTop}else o&&c();s&&!r&&o&&c();const d=o&&!r&&!s?ud(o,a):vn(0),p=i.left+a.scrollLeft-l.x-d.x,m=i.top+a.scrollTop-l.y-d.y;return{x:p,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 wn(e)===n&&(n=n.ownerDocument.body),n}function md(e,t){const n=Xt(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&&Sw(r)&&na(r);)r=hd(r,t);return r&&kr(r)&&na(r)&&!Zi(r)?n:r||Iw(e)||n}const zw=async function(e){const t=this.getOffsetParent||md,n=this.getDimensions,r=await n(e.floating);return{reference:Bw(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Hw(e){return cn(e).direction==="rtl"}const Uw={convertOffsetParentRelativeRectToViewportRelativeRect:_w,getDocumentElement:wn,getClippingRect:$w,getOffsetParent:md,getElementRects:zw,getClientRects:Pw,getDimensions:Fw,getScale:Er,isElement:ln,isRTL:Hw};function gd(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Ww(e,t){let n=null,r;const o=wn(e);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),s();const c=e.getBoundingClientRect(),{left:d,top:p,width:m,height:f}=c;if(a||t(),!m||!f)return;const v=ts(p),x=ts(o.clientWidth-(d+m)),g=ts(o.clientHeight-(p+f)),b=ts(d),S={rootMargin:-v+"px "+-x+"px "+-g+"px "+-b+"px",threshold:Yt(0,Ln(1,l))||1};let k=!0;function C(T){const E=T[0].intersectionRatio;if(E!==l){if(!k)return i();E?i(!1,E):r=setTimeout(()=>{i(!1,1e-7)},1e3)}E===1&&!gd(c,e.getBoundingClientRect())&&i(),k=!1}try{n=new IntersectionObserver(C,{...S,root:o.ownerDocument})}catch{n=new IntersectionObserver(C,S)}n.observe(e)}return i(!0),s}function Vw(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(b=>{o&&b.addEventListener("scroll",n,{passive:!0}),s&&b.addEventListener("resize",n)});const p=c&&a?Ww(c,n):null;let m=-1,f=null;i&&(f=new ResizeObserver(b=>{let[y]=b;y&&y.target===c&&f&&(f.unobserve(t),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var S;(S=f)==null||S.observe(t)})),n()}),c&&!l&&f.observe(c),f.observe(t));let v,x=l?er(e):null;l&&g();function g(){const b=er(e);x&&!gd(x,b)&&n(),x=b,v=requestAnimationFrame(g)}return n(),()=>{var b;d.forEach(y=>{o&&y.removeEventListener("scroll",n),s&&y.removeEventListener("resize",n)}),p==null||p(),(b=f)==null||b.disconnect(),f=null,l&&cancelAnimationFrame(v)}}const Kw=gw,qw=xw,Gw=pw,Yw=bw,Xw=hw,xd=fw,Jw=vw,Zw=(e,t,n)=>{const r=new Map,o={platform:Uw,...n},s={...o.platform,_c:r};return dw(e,t,{...o,platform:s})};var Qw=typeof document<"u",ey=function(){},ls=Qw?w.useLayoutEffect:ey;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 vd(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function bd(e,t){const n=vd(e);return Math.round(t*n)/n}function ra(e){const t=h.useRef(e);return ls(()=>{t.current=e}),t}function ty(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,p]=h.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[m,f]=h.useState(r);cs(m,r)||f(r);const[v,x]=h.useState(null),[g,b]=h.useState(null),y=h.useCallback(M=>{M!==T.current&&(T.current=M,x(M))},[]),S=h.useCallback(M=>{M!==E.current&&(E.current=M,b(M))},[]),k=s||v,C=i||g,T=h.useRef(null),E=h.useRef(null),j=h.useRef(d),P=l!=null,O=ra(l),F=ra(o),q=ra(c),Y=h.useCallback(()=>{if(!T.current||!E.current)return;const M={placement:t,strategy:n,middleware:m};F.current&&(M.platform=F.current),Zw(T.current,E.current,M).then(I=>{const G={...I,isPositioned:q.current!==!1};R.current&&!cs(j.current,G)&&(j.current=G,Ur.flushSync(()=>{p(G)}))})},[m,t,n,F,q]);ls(()=>{c===!1&&j.current.isPositioned&&(j.current.isPositioned=!1,p(M=>({...M,isPositioned:!1})))},[c]);const R=h.useRef(!1);ls(()=>(R.current=!0,()=>{R.current=!1}),[]),ls(()=>{if(k&&(T.current=k),C&&(E.current=C),k&&C){if(O.current)return O.current(k,C,Y);Y()}},[k,C,Y,O,P]);const K=h.useMemo(()=>({reference:T,floating:E,setReference:y,setFloating:S}),[y,S]),U=h.useMemo(()=>({reference:k,floating:C}),[k,C]),W=h.useMemo(()=>{const M={position:n,left:0,top:0};if(!U.floating)return M;const I=bd(U.floating,d.x),G=bd(U.floating,d.y);return a?{...M,transform:"translate("+I+"px, "+G+"px)",...vd(U.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:I,top:G}},[n,a,U.floating,d.x,d.y]);return h.useMemo(()=>({...d,update:Y,refs:K,elements:U,floatingStyles:W}),[d,Y,K,U,W])}const ny=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?xd({element:r.current,padding:o}).fn(n):{}:r?xd({element:r,padding:o}).fn(n):{}}}},ry=(e,t)=>({...Kw(e),options:[e,t]}),oy=(e,t)=>({...qw(e),options:[e,t]}),sy=(e,t)=>({...Jw(e),options:[e,t]}),iy=(e,t)=>({...Gw(e),options:[e,t]}),ay=(e,t)=>({...Yw(e),options:[e,t]}),ly=(e,t)=>({...Xw(e),options:[e,t]}),cy=(e,t)=>({...ny(e),options:[e,t]});var uy="Arrow",wd=h.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=uy;var dy=wd;function yd(e){const[t,n]=h.useState(void 0);return Tt(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const s=o[0];let i,a;if("borderBoxSize"in s){const l=s.borderBoxSize,c=Array.isArray(l)?l[0]:l;i=c.inlineSize,a=c.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var oa="Popper",[Sd,Ir]=an(oa),[fy,Cd]=Sd(oa),Td=e=>{const{__scopePopper:t,children:n}=e,[r,o]=h.useState(null);return u.jsx(fy,{scope:t,anchor:r,onAnchorChange:o,children:n})};Td.displayName=oa;var kd="PopperAnchor",Ed=h.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=Cd(kd,n),i=h.useRef(null),a=Re(t,i),l=h.useRef(null);return h.useEffect(()=>{const c=l.current;l.current=(r==null?void 0:r.current)||i.current,c!==l.current&&s.onAnchorChange(l.current)}),r?null:u.jsx(me.div,{...o,ref:a})});Ed.displayName=kd;var sa="PopperContent",[py,hy]=Sd(sa),Id=h.forwardRef((e,t)=>{var $,D,J,Q,ie,Z;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:p="partial",hideWhenDetached:m=!1,updatePositionStrategy:f="optimized",onPlaced:v,...x}=e,g=Cd(sa,n),[b,y]=h.useState(null),S=Re(t,ue=>y(ue)),[k,C]=h.useState(null),T=yd(k),E=(T==null?void 0:T.width)??0,j=(T==null?void 0:T.height)??0,P=r+(s!=="center"?"-"+s:""),O=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},F=Array.isArray(c)?c:[c],q=F.length>0,Y={padding:O,boundary:F.filter(gy),altBoundary:q},{refs:R,floatingStyles:K,placement:U,isPositioned:W,middlewareData:M}=ty({strategy:"fixed",placement:P,whileElementsMounted:(...ue)=>Vw(...ue,{animationFrame:f==="always"}),elements:{reference:g.anchor},middleware:[ry({mainAxis:o+j,alignmentAxis:i}),l&&oy({mainAxis:!0,crossAxis:!1,limiter:p==="partial"?sy():void 0,...Y}),l&&iy({...Y}),ay({...Y,apply:({elements:ue,rects:he,availableWidth:ke,availableHeight:Le})=>{const{width:$e,height:je}=he.reference,Be=ue.floating.style;Be.setProperty("--radix-popper-available-width",`${ke}px`),Be.setProperty("--radix-popper-available-height",`${Le}px`),Be.setProperty("--radix-popper-anchor-width",`${$e}px`),Be.setProperty("--radix-popper-anchor-height",`${je}px`)}}),k&&cy({element:k,padding:a}),xy({arrowWidth:E,arrowHeight:j}),m&&ly({strategy:"referenceHidden",...Y})]}),[I,G]=jd(U),X=ft(v);Tt(()=>{W&&(X==null||X())},[W,X]);const _=($=M.arrow)==null?void 0:$.x,B=(D=M.arrow)==null?void 0:D.y,N=((J=M.arrow)==null?void 0:J.centerOffset)!==0,[L,z]=h.useState();return Tt(()=>{b&&z(window.getComputedStyle(b).zIndex)},[b]),u.jsx("div",{ref:R.setFloating,"data-radix-popper-content-wrapper":"",style:{...K,transform:W?K.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:L,"--radix-popper-transform-origin":[(Q=M.transformOrigin)==null?void 0:Q.x,(ie=M.transformOrigin)==null?void 0:ie.y].join(" "),...((Z=M.hide)==null?void 0:Z.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:u.jsx(py,{scope:n,placedSide:I,onArrowChange:C,arrowX:_,arrowY:B,shouldHideArrow:N,children:u.jsx(me.div,{"data-side":I,"data-align":G,...x,ref:S,style:{...x.style,animation:W?void 0:"none"}})})})});Id.displayName=sa;var Nd="PopperArrow",my={top:"bottom",right:"left",bottom:"top",left:"right"},Ad=h.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=hy(Nd,r),i=my[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(dy,{...o,ref:n,style:{...o.style,display:"block"}})})});Ad.displayName=Nd;function gy(e){return e!==null}var xy=e=>({name:"transformOrigin",options:e,fn(t){var g,b,y;const{placement:n,rects:r,middlewareData:o}=t,i=((g=o.arrow)==null?void 0:g.centerOffset)!==0,a=i?0:e.arrowWidth,l=i?0:e.arrowHeight,[c,d]=jd(n),p={start:"0%",center:"50%",end:"100%"}[d],m=(((b=o.arrow)==null?void 0:b.x)??0)+a/2,f=(((y=o.arrow)==null?void 0:y.y)??0)+l/2;let v="",x="";return c==="bottom"?(v=i?p:`${m}px`,x=`${-l}px`):c==="top"?(v=i?p:`${m}px`,x=`${r.floating.height+l}px`):c==="right"?(v=`${-l}px`,x=i?p:`${f}px`):c==="left"&&(v=`${r.floating.width+l}px`,x=i?p:`${f}px`),{data:{x:v,y:x}}}});function jd(e){const[t,n="center"]=e.split("-");return[t,n]}var ia=Td,aa=Ed,la=Id,ca=Ad,vy="Portal",io=h.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=h.useState(!1);Tt(()=>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=vy;function by(e,t){return h.useReducer((n,r)=>t[n][r]??n,e)}var zt=e=>{const{present:t,children:n}=e,r=wy(t),o=typeof n=="function"?n({present:r.isPresent}):h.Children.only(n),s=Re(r.ref,yy(o));return typeof n=="function"||r.isPresent?h.cloneElement(o,{ref:s}):null};zt.displayName="Presence";function wy(e){const[t,n]=h.useState(),r=h.useRef(null),o=h.useRef(e),s=h.useRef("none"),i=e?"mounted":"unmounted",[a,l]=by(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return h.useEffect(()=>{const c=us(r.current);s.current=a==="mounted"?c:"none"},[a]),Tt(()=>{const c=r.current,d=o.current;if(d!==e){const m=s.current,f=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]),Tt(()=>{if(t){let c;const d=t.ownerDocument.defaultView??window,p=f=>{const x=us(r.current).includes(CSS.escape(f.animationName));if(f.target===t&&x&&(l("ANIMATION_END"),!o.current)){const g=t.style.animationFillMode;t.style.animationFillMode="forwards",c=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=g)})}},m=f=>{f.target===t&&(s.current=us(r.current))};return t.addEventListener("animationstart",m),t.addEventListener("animationcancel",p),t.addEventListener("animationend",p),()=>{d.clearTimeout(c),t.removeEventListener("animationstart",m),t.removeEventListener("animationcancel",p),t.removeEventListener("animationend",p)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:h.useCallback(c=>{r.current=c?getComputedStyle(c):null,n(c)},[])}}function us(e){return(e==null?void 0:e.animationName)||"none"}function yy(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",Sy={bubbles:!1,cancelable:!0},ao="RovingFocusGroup",[da,_d,Cy]=Jo(ao),[Ty,Pd]=an(ao,[Cy]),[ky,Ey]=Ty(ao),Rd=h.forwardRef((e,t)=>u.jsx(da.Provider,{scope:e.__scopeRovingFocusGroup,children:u.jsx(da.Slot,{scope:e.__scopeRovingFocusGroup,children:u.jsx(Iy,{...e,ref:t})})}));Rd.displayName=ao;var Iy=h.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:c,preventScrollOnEntryFocus:d=!1,...p}=e,m=h.useRef(null),f=Re(t,m),v=Zo(s),[x,g]=On({prop:i,defaultProp:a??null,onChange:l,caller:ao}),[b,y]=h.useState(!1),S=ft(c),k=_d(n),C=h.useRef(!1),[T,E]=h.useState(0);return h.useEffect(()=>{const j=m.current;if(j)return j.addEventListener(ua,S),()=>j.removeEventListener(ua,S)},[S]),u.jsx(ky,{scope:n,orientation:r,dir:v,loop:o,currentTabStopId:x,onItemFocus:h.useCallback(j=>g(j),[g]),onItemShiftTab:h.useCallback(()=>y(!0),[]),onFocusableItemAdd:h.useCallback(()=>E(j=>j+1),[]),onFocusableItemRemove:h.useCallback(()=>E(j=>j-1),[]),children:u.jsx(me.div,{tabIndex:b||T===0?-1:0,"data-orientation":r,...p,ref:f,style:{outline:"none",...e.style},onMouseDown:ae(e.onMouseDown,()=>{C.current=!0}),onFocus:ae(e.onFocus,j=>{const P=!C.current;if(j.target===j.currentTarget&&P&&!b){const O=new CustomEvent(ua,Sy);if(j.currentTarget.dispatchEvent(O),!O.defaultPrevented){const F=k().filter(U=>U.focusable),q=F.find(U=>U.active),Y=F.find(U=>U.id===x),K=[q,Y,...F].filter(Boolean).map(U=>U.ref.current);Dd(K,d)}}C.current=!1}),onBlur:ae(e.onBlur,()=>y(!1))})})}),Md="RovingFocusGroupItem",Od=h.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,l=At(),c=s||l,d=Ey(Md,n),p=d.currentTabStopId===c,m=_d(n),{onFocusableItemAdd:f,onFocusableItemRemove:v,currentTabStopId:x}=d;return h.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:p?0:-1,"data-orientation":d.orientation,...a,ref:t,onMouseDown:ae(e.onMouseDown,g=>{r?d.onItemFocus(c):g.preventDefault()}),onFocus:ae(e.onFocus,()=>d.onItemFocus(c)),onKeyDown:ae(e.onKeyDown,g=>{if(g.key==="Tab"&&g.shiftKey){d.onItemShiftTab();return}if(g.target!==g.currentTarget)return;const b=jy(g,d.orientation,d.dir);if(b!==void 0){if(g.metaKey||g.ctrlKey||g.altKey||g.shiftKey)return;g.preventDefault();let S=m().filter(k=>k.focusable).map(k=>k.ref.current);if(b==="last")S.reverse();else if(b==="prev"||b==="next"){b==="prev"&&S.reverse();const k=S.indexOf(g.currentTarget);S=d.loop?_y(S,k+1):S.slice(k+1)}setTimeout(()=>Dd(S))}}),children:typeof i=="function"?i({isCurrentTabStop:p,hasTabStop:x!=null}):i})})});Od.displayName=Md;var Ny={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Ay(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function jy(e,t,n){const r=Ay(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return Ny[r]}function Dd(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function _y(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Py=Rd,Ry=Od,My=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,Ld=function(e){return e&&(e.host||Ld(e.parentNode))},Oy=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=Ld(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})},Dy=function(e,t,n,r){var o=Oy(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(p){!p||a.has(p)||(a.add(p),c(p.parentNode))};o.forEach(c);var d=function(p){!p||l.has(p)||Array.prototype.forEach.call(p.children,function(m){if(a.has(m))d(m);else try{var f=m.getAttribute(r),v=f!==null&&f!=="false",x=(Nr.get(m)||0)+1,g=(s.get(m)||0)+1;Nr.set(m,x),s.set(m,g),i.push(m),x===1&&v&&ds.set(m,!0),g===1&&m.setAttribute(n,"true"),v||m.setAttribute(r,"true")}catch(b){console.error("aria-hidden: cannot operate on ",m,b)}})};return d(t),a.clear(),fa++,function(){i.forEach(function(p){var m=Nr.get(p)-1,f=s.get(p)-1;Nr.set(p,m),s.set(p,f),m||(ds.has(p)||p.removeAttribute(r),ds.delete(p)),f||p.removeAttribute(n)}),fa--,fa||(Nr=new WeakMap,Nr=new WeakMap,ds=new WeakMap,fs={})}},pa=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=My(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),Dy(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 $d(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 Ly(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 ps="right-scroll-bar-position",hs="width-before-scroll-bar",$y="with-scroll-bars-hidden",Fy="--removed-body-scroll-bar-size";function ha(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function By(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 zy=typeof window<"u"?h.useLayoutEffect:h.useEffect,Fd=new WeakMap;function Hy(e,t){var n=By(null,function(r){return e.forEach(function(o){return ha(o,r)})});return zy(function(){var r=Fd.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||ha(a,null)}),s.forEach(function(a){o.has(a)||ha(a,i)})}Fd.set(n,e)},[e]),n}function Uy(e){return e}function Wy(e,t){t===void 0&&(t=Uy);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 Vy(e){e===void 0&&(e={});var t=Wy(null);return t.options=Sn({async:!0,ssr:!1},e),t}var Bd=function(e){var t=e.sideCar,n=$d(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return h.createElement(r,Sn({},n))};Bd.isSideCarExport=!0;function Ky(e,t){return e.useMedium(t),Bd}var zd=Vy(),ma=function(){},ms=h.forwardRef(function(e,t){var n=h.useRef(null),r=h.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,p=e.shards,m=e.sideCar,f=e.noRelative,v=e.noIsolation,x=e.inert,g=e.allowPinchZoom,b=e.as,y=b===void 0?"div":b,S=e.gapMode,k=$d(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=m,T=Hy([n,t]),E=Sn(Sn({},k),o);return h.createElement(h.Fragment,null,d&&h.createElement(C,{sideCar:zd,removeScrollBar:c,shards:p,noRelative:f,noIsolation:v,inert:x,setCallbacks:s,allowPinchZoom:!!g,lockRef:n,gapMode:S}),i?h.cloneElement(h.Children.only(a),Sn(Sn({},E),{ref:T})):h.createElement(y,Sn({},E,{className:l,ref:T}),a))});ms.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},ms.classNames={fullWidth:hs,zeroRight:ps};var qy=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Gy(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=qy();return t&&e.setAttribute("nonce",t),e}function Yy(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Xy(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var Jy=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Gy())&&(Yy(t,n),Xy(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Zy=function(){var e=Jy();return function(t,n){h.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Hd=function(){var e=Zy(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},Qy={left:0,top:0,right:0,gap:0},ga=function(e){return parseInt(e||"",10)||0},e0=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)]},t0=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Qy;var t=e0(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])}},n0=Hd(),Ar="data-scroll-locked",r0=function(e,t,n,r){var o=e.left,s=e.top,i=e.right,a=e.gap;return n===void 0&&(n="margin"),`
40
- .`.concat($y,` {
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"),`
40
+ .`.concat(My,` {
41
41
  overflow: hidden `).concat(r,`;
42
42
  padding-right: `).concat(a,"px ").concat(r,`;
43
43
  }
@@ -54,46 +54,46 @@ React keys must be passed directly to JSX without using spread:
54
54
  `),n==="padding"&&"padding-right: ".concat(a,"px ").concat(r,";")].filter(Boolean).join(""),`
55
55
  }
56
56
 
57
- .`).concat(ps,` {
57
+ .`).concat(hs,` {
58
58
  right: `).concat(a,"px ").concat(r,`;
59
59
  }
60
60
 
61
- .`).concat(hs,` {
61
+ .`).concat(ps,` {
62
62
  margin-right: `).concat(a,"px ").concat(r,`;
63
63
  }
64
64
 
65
- .`).concat(ps," .").concat(ps,` {
65
+ .`).concat(hs," .").concat(hs,` {
66
66
  right: 0 `).concat(r,`;
67
67
  }
68
68
 
69
- .`).concat(hs," .").concat(hs,` {
69
+ .`).concat(ps," .").concat(ps,` {
70
70
  margin-right: 0 `).concat(r,`;
71
71
  }
72
72
 
73
73
  body[`).concat(Ar,`] {
74
- `).concat(Fy,": ").concat(a,`px;
74
+ `).concat(Oy,": ").concat(a,`px;
75
75
  }
76
- `)},Ud=function(){var e=parseInt(document.body.getAttribute(Ar)||"0",10);return isFinite(e)?e:0},o0=function(){h.useEffect(function(){return document.body.setAttribute(Ar,(Ud()+1).toString()),function(){var e=Ud()-1;e<=0?document.body.removeAttribute(Ar):document.body.setAttribute(Ar,e.toString())}},[])},s0=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;o0();var s=h.useMemo(function(){return t0(o)},[o]);return h.createElement(n0,{styles:r0(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,i0=function(e){return e.tagName==="TEXTAREA"},Wd=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!i0(e)&&n[t]==="visible")},a0=function(e){return Wd(e,"overflowY")},l0=function(e){return Wd(e,"overflowX")},Vd=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=Kd(e,r);if(o){var s=qd(e,r),i=s[1],a=s[2];if(i>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},c0=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},u0=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},Kd=function(e,t){return e==="v"?a0(t):l0(t)},qd=function(e,t){return e==="v"?c0(t):u0(t)},d0=function(e,t){return e==="h"&&t==="rtl"?-1:1},f0=function(e,t,n,r,o){var s=d0(e,window.getComputedStyle(t).direction),i=s*r,a=n.target,l=t.contains(a),c=!1,d=i>0,p=0,m=0;do{if(!a)break;var f=qd(e,a),v=f[0],x=f[1],g=f[2],b=x-g-s*v;(v||b)&&Kd(e,a)&&(p+=b,m+=v);var y=a.parentNode;a=y&&y.nodeType===Node.DOCUMENT_FRAGMENT_NODE?y.host:y}while(!l&&a!==document.body||l&&(t.contains(a)||t===a));return(d&&Math.abs(p)<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]},Gd=function(e){return[e.deltaX,e.deltaY]},Yd=function(e){return e&&"current"in e?e.current:e},p0=function(e,t){return e[0]===t[0]&&e[1]===t[1]},h0=function(e){return`
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
- `)},m0=0,_r=[];function g0(e){var t=h.useRef([]),n=h.useRef([0,0]),r=h.useRef(),o=h.useState(m0++)[0],s=h.useState(Hd)[0],i=h.useRef(e);h.useEffect(function(){i.current=e},[e]),h.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var x=Ly([e.lockRef.current],(e.shards||[]).map(Yd),!0).filter(Boolean);return x.forEach(function(g){return g.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),x.forEach(function(g){return g.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var a=h.useCallback(function(x,g){if("touches"in x&&x.touches.length===2||x.type==="wheel"&&x.ctrlKey)return!i.current.allowPinchZoom;var b=xs(x),y=n.current,S="deltaX"in x?x.deltaX:y[0]-b[0],k="deltaY"in x?x.deltaY:y[1]-b[1],C,T=x.target,E=Math.abs(S)>Math.abs(k)?"h":"v";if("touches"in x&&E==="h"&&T.type==="range")return!1;var j=Vd(E,T);if(!j)return!0;if(j?C=E:(C=E==="v"?"h":"v",j=Vd(E,T)),!j)return!1;if(!r.current&&"changedTouches"in x&&(S||k)&&(r.current=C),!C)return!0;var P=r.current||C;return f0(P,g,x,P==="h"?S:k)},[]),l=h.useCallback(function(x){var g=x;if(!(!_r.length||_r[_r.length-1]!==s)){var b="deltaY"in g?Gd(g):xs(g),y=t.current.filter(function(C){return C.name===g.type&&(C.target===g.target||g.target===C.shadowParent)&&p0(C.delta,b)})[0];if(y&&y.should){g.cancelable&&g.preventDefault();return}if(!y){var S=(i.current.shards||[]).map(Yd).filter(Boolean).filter(function(C){return C.contains(g.target)}),k=S.length>0?a(g,S[0]):!i.current.noIsolation;k&&g.cancelable&&g.preventDefault()}}},[]),c=h.useCallback(function(x,g,b,y){var S={name:x,delta:g,target:b,should:y,shadowParent:x0(b)};t.current.push(S),setTimeout(function(){t.current=t.current.filter(function(k){return k!==S})},1)},[]),d=h.useCallback(function(x){n.current=xs(x),r.current=void 0},[]),p=h.useCallback(function(x){c(x.type,Gd(x),x.target,a(x,e.lockRef.current))},[]),m=h.useCallback(function(x){c(x.type,xs(x),x.target,a(x,e.lockRef.current))},[]);h.useEffect(function(){return _r.push(s),e.setCallbacks({onScrollCapture:p,onWheelCapture:p,onTouchMoveCapture:m}),document.addEventListener("wheel",l,jr),document.addEventListener("touchmove",l,jr),document.addEventListener("touchstart",d,jr),function(){_r=_r.filter(function(x){return x!==s}),document.removeEventListener("wheel",l,jr),document.removeEventListener("touchmove",l,jr),document.removeEventListener("touchstart",d,jr)}},[]);var f=e.removeScrollBar,v=e.inert;return h.createElement(h.Fragment,null,v?h.createElement(s,{styles:h0(o)}):null,f?h.createElement(s0,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function x0(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const v0=Ky(zd,g0);var vs=h.forwardRef(function(e,t){return h.createElement(ms,Sn({},e,{ref:t,sideCar:v0}))});vs.classNames=ms.classNames;var va=["Enter"," "],b0=["ArrowDown","PageUp","Home"],Xd=["ArrowUp","PageDown","End"],w0=[...b0,...Xd],y0={ltr:[...va,"ArrowRight"],rtl:[...va,"ArrowLeft"]},S0={ltr:["ArrowLeft"],rtl:["ArrowRight"]},lo="Menu",[co,C0,T0]=Jo(lo),[tr,Jd]=an(lo,[T0,Ir,Pd]),bs=Ir(),Zd=Pd(),[k0,nr]=tr(lo),[E0,uo]=tr(lo),Qd=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=bs(t),[l,c]=h.useState(null),d=h.useRef(!1),p=ft(s),m=Zo(o);return h.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(k0,{scope:t,open:n,onOpenChange:p,content:l,onContentChange:c,children:u.jsx(E0,{scope:t,onClose:h.useCallback(()=>p(!1),[p]),isUsingKeyboardRef:d,dir:m,modal:i,children:r})})})};Qd.displayName=lo;var I0="MenuAnchor",ba=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=bs(n);return u.jsx(aa,{...o,...r,ref:t})});ba.displayName=I0;var wa="MenuPortal",[N0,ef]=tr(wa,{forceMount:void 0}),tf=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=nr(wa,t);return u.jsx(N0,{scope:t,forceMount:n,children:u.jsx(zt,{present:n||s.open,children:u.jsx(io,{asChild:!0,container:o,children:r})})})};tf.displayName=wa;var Qt="MenuContent",[A0,ya]=tr(Qt),nf=h.forwardRef((e,t)=>{const n=ef(Qt,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=nr(Qt,e.__scopeMenu),i=uo(Qt,e.__scopeMenu);return u.jsx(co.Provider,{scope:e.__scopeMenu,children:u.jsx(zt,{present:r||s.open,children:u.jsx(co.Slot,{scope:e.__scopeMenu,children:i.modal?u.jsx(j0,{...o,ref:t}):u.jsx(_0,{...o,ref:t})})})})}),j0=h.forwardRef((e,t)=>{const n=nr(Qt,e.__scopeMenu),r=h.useRef(null),o=Re(t,r);return h.useEffect(()=>{const s=r.current;if(s)return pa(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)})}),_0=h.forwardRef((e,t)=>{const n=nr(Qt,e.__scopeMenu);return u.jsx(Sa,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),P0=Kt.createSlot("MenuContent.ScrollLock"),Sa=h.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:p,onInteractOutside:m,onDismiss:f,disableOutsideScroll:v,...x}=e,g=nr(Qt,n),b=uo(Qt,n),y=bs(n),S=Zd(n),k=C0(n),[C,T]=h.useState(null),E=h.useRef(null),j=Re(t,E,g.onContentChange),P=h.useRef(0),O=h.useRef(""),F=h.useRef(0),q=h.useRef(null),Y=h.useRef("right"),R=h.useRef(0),K=v?vs:h.Fragment,U=v?{as:P0,allowPinchZoom:!0}:void 0,W=I=>{var $,D;const G=O.current+I,X=k().filter(J=>!J.disabled),_=document.activeElement,B=($=X.find(J=>J.ref.current===_))==null?void 0:$.textValue,N=X.map(J=>J.textValue),L=W0(N,G,B),z=(D=X.find(J=>J.textValue===L))==null?void 0:D.ref.current;(function J(Q){O.current=Q,window.clearTimeout(P.current),Q!==""&&(P.current=window.setTimeout(()=>J(""),1e3))})(G),z&&setTimeout(()=>z.focus())};h.useEffect(()=>()=>window.clearTimeout(P.current),[]),Wi();const M=h.useCallback(I=>{var X,_;return Y.current===((X=q.current)==null?void 0:X.side)&&K0(I,(_=q.current)==null?void 0:_.area)},[]);return u.jsx(A0,{scope:n,searchRef:O,onItemEnter:h.useCallback(I=>{M(I)&&I.preventDefault()},[M]),onItemLeave:h.useCallback(I=>{var G;M(I)||((G=E.current)==null||G.focus(),T(null))},[M]),onTriggerLeave:h.useCallback(I=>{M(I)&&I.preventDefault()},[M]),pointerGraceTimerRef:F,onPointerGraceIntentChange:h.useCallback(I=>{q.current=I},[]),children:u.jsx(K,{...U,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:p,onInteractOutside:m,onDismiss:f,children:u.jsx(Py,{asChild:!0,...S,dir:b.dir,orientation:"vertical",loop:r,currentTabStopId:C,onCurrentTabStopIdChange:T,onEntryFocus:ae(l,I=>{b.isUsingKeyboardRef.current||I.preventDefault()}),preventScrollOnEntryFocus:!0,children:u.jsx(la,{role:"menu","aria-orientation":"vertical","data-state":wf(g.open),"data-radix-menu-content":"",dir:b.dir,...y,...x,ref:j,style:{outline:"none",...x.style},onKeyDown:ae(x.onKeyDown,I=>{const X=I.target.closest("[data-radix-menu-content]")===I.currentTarget,_=I.ctrlKey||I.altKey||I.metaKey,B=I.key.length===1;X&&(I.key==="Tab"&&I.preventDefault(),!_&&B&&W(I.key));const N=E.current;if(I.target!==N||!w0.includes(I.key))return;I.preventDefault();const z=k().filter($=>!$.disabled).map($=>$.ref.current);Xd.includes(I.key)&&z.reverse(),H0(z)}),onBlur:ae(e.onBlur,I=>{I.currentTarget.contains(I.target)||(window.clearTimeout(P.current),O.current="")}),onPointerMove:ae(e.onPointerMove,po(I=>{const G=I.target,X=R.current!==I.clientX;if(I.currentTarget.contains(G)&&X){const _=I.clientX>R.current?"right":"left";Y.current=_,R.current=I.clientX}}))})})})})})})});nf.displayName=Qt;var R0="MenuGroup",Ca=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(me.div,{role:"group",...r,ref:t})});Ca.displayName=R0;var M0="MenuLabel",rf=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(me.div,{...r,ref:t})});rf.displayName=M0;var ws="MenuItem",of="menu.itemSelect",ys=h.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=h.useRef(null),i=uo(ws,e.__scopeMenu),a=ya(ws,e.__scopeMenu),l=Re(t,s),c=h.useRef(!1),d=()=>{const p=s.current;if(!n&&p){const m=new CustomEvent(of,{bubbles:!0,cancelable:!0});p.addEventListener(of,f=>r==null?void 0:r(f),{once:!0}),zi(p,m),m.defaultPrevented?c.current=!1:i.onClose()}};return u.jsx(sf,{...o,ref:l,disabled:n,onClick:ae(e.onClick,d),onPointerDown:p=>{var m;(m=e.onPointerDown)==null||m.call(e,p),c.current=!0},onPointerUp:ae(e.onPointerUp,p=>{var m;c.current||(m=p.currentTarget)==null||m.click()}),onKeyDown:ae(e.onKeyDown,p=>{const m=a.searchRef.current!=="";n||m&&p.key===" "||va.includes(p.key)&&(p.currentTarget.click(),p.preventDefault())})})});ys.displayName=ws;var sf=h.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=ya(ws,n),a=Zd(n),l=h.useRef(null),c=Re(t,l),[d,p]=h.useState(!1),[m,f]=h.useState("");return h.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(Ry,{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,po(v=>{r?i.onItemLeave(v):(i.onItemEnter(v),v.defaultPrevented||v.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:ae(e.onPointerLeave,po(v=>i.onItemLeave(v))),onFocus:ae(e.onFocus,()=>p(!0)),onBlur:ae(e.onBlur,()=>p(!1))})})})}),O0="MenuCheckboxItem",af=h.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return u.jsx(ff,{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})})})});af.displayName=O0;var lf="MenuRadioGroup",[D0,L0]=tr(lf,{value:void 0,onValueChange:()=>{}}),cf=h.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=ft(r);return u.jsx(D0,{scope:e.__scopeMenu,value:n,onValueChange:s,children:u.jsx(Ca,{...o,ref:t})})});cf.displayName=lf;var uf="MenuRadioItem",df=h.forwardRef((e,t)=>{const{value:n,...r}=e,o=L0(uf,e.__scopeMenu),s=n===o.value;return u.jsx(ff,{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})})})});df.displayName=uf;var Ta="MenuItemIndicator",[ff,$0]=tr(Ta,{checked:!1}),pf=h.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=$0(Ta,n);return u.jsx(zt,{present:r||Ss(s.checked)||s.checked===!0,children:u.jsx(me.span,{...o,ref:t,"data-state":ka(s.checked)})})});pf.displayName=Ta;var F0="MenuSeparator",hf=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(me.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});hf.displayName=F0;var B0="MenuArrow",mf=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=bs(n);return u.jsx(ca,{...o,...r,ref:t})});mf.displayName=B0;var z0="MenuSub",[$N,gf]=tr(z0),fo="MenuSubTrigger",xf=h.forwardRef((e,t)=>{const n=nr(fo,e.__scopeMenu),r=uo(fo,e.__scopeMenu),o=gf(fo,e.__scopeMenu),s=ya(fo,e.__scopeMenu),i=h.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,c={__scopeMenu:e.__scopeMenu},d=h.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return h.useEffect(()=>d,[d]),h.useEffect(()=>{const p=a.current;return()=>{window.clearTimeout(p),l(null)}},[a,l]),u.jsx(ba,{asChild:!0,...c,children:u.jsx(sf,{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:p=>{var m;(m=e.onClick)==null||m.call(e,p),!(e.disabled||p.defaultPrevented)&&(p.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:ae(e.onPointerMove,po(p=>{s.onItemEnter(p),!p.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(s.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),d()},100))})),onPointerLeave:ae(e.onPointerLeave,po(p=>{var f,v;d();const m=(f=n.content)==null?void 0:f.getBoundingClientRect();if(m){const x=(v=n.content)==null?void 0:v.dataset.side,g=x==="right",b=g?-5:5,y=m[g?"left":"right"],S=m[g?"right":"left"];s.onPointerGraceIntentChange({area:[{x:p.clientX+b,y:p.clientY},{x:y,y:m.top},{x:S,y:m.top},{x:S,y:m.bottom},{x:y,y:m.bottom}],side:x}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(p),p.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:ae(e.onKeyDown,p=>{var f;const m=s.searchRef.current!=="";e.disabled||m&&p.key===" "||y0[r.dir].includes(p.key)&&(n.onOpenChange(!0),(f=n.content)==null||f.focus(),p.preventDefault())})})})});xf.displayName=fo;var vf="MenuSubContent",bf=h.forwardRef((e,t)=>{const n=ef(Qt,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=nr(Qt,e.__scopeMenu),i=uo(Qt,e.__scopeMenu),a=gf(vf,e.__scopeMenu),l=h.useRef(null),c=Re(t,l);return u.jsx(co.Provider,{scope:e.__scopeMenu,children:u.jsx(zt,{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 p;i.isUsingKeyboardRef.current&&((p=l.current)==null||p.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 p=d.currentTarget.contains(d.target),m=S0[i.dir].includes(d.key);p&&m&&(s.onOpenChange(!1),(f=a.trigger)==null||f.focus(),d.preventDefault())})})})})})});bf.displayName=vf;function wf(e){return e?"open":"closed"}function Ss(e){return e==="indeterminate"}function ka(e){return Ss(e)?"indeterminate":e?"checked":"unchecked"}function H0(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function U0(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function W0(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=U0(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 V0(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,p=l.x,m=l.y;d>r!=m>r&&n<(p-c)*(r-d)/(m-d)+c&&(o=!o)}return o}function K0(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return V0(n,t)}function po(e){return t=>t.pointerType==="mouse"?e(t):void 0}var q0=Qd,G0=ba,Y0=tf,X0=nf,J0=Ca,Z0=rf,Q0=ys,eS=af,tS=cf,nS=df,rS=pf,oS=hf,sS=mf,iS=xf,aS=bf,Cs="DropdownMenu",[lS,FN]=an(Cs,[Jd]),Dt=Jd(),[cS,yf]=lS(Cs),Sf=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,l=Dt(t),c=h.useRef(null),[d,p]=On({prop:o,defaultProp:s??!1,onChange:i,caller:Cs});return u.jsx(cS,{scope:t,triggerId:At(),triggerRef:c,contentId:At(),open:d,onOpenChange:p,onOpenToggle:h.useCallback(()=>p(m=>!m),[p]),modal:a,children:u.jsx(q0,{...l,open:d,onOpenChange:p,dir:r,modal:a,children:n})})};Sf.displayName=Cs;var Cf="DropdownMenuTrigger",Tf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=yf(Cf,n),i=Dt(n);return u.jsx(G0,{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())})})})});Tf.displayName=Cf;var uS="DropdownMenuPortal",kf=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Dt(t);return u.jsx(Y0,{...r,...n})};kf.displayName=uS;var Ef="DropdownMenuContent",If=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=yf(Ef,n),s=Dt(n),i=h.useRef(!1);return u.jsx(X0,{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)"}})});If.displayName=Ef;var dS="DropdownMenuGroup",fS=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(J0,{...o,...r,ref:t})});fS.displayName=dS;var pS="DropdownMenuLabel",Nf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(Z0,{...o,...r,ref:t})});Nf.displayName=pS;var hS="DropdownMenuItem",Af=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(Q0,{...o,...r,ref:t})});Af.displayName=hS;var mS="DropdownMenuCheckboxItem",jf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(eS,{...o,...r,ref:t})});jf.displayName=mS;var gS="DropdownMenuRadioGroup",xS=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(tS,{...o,...r,ref:t})});xS.displayName=gS;var vS="DropdownMenuRadioItem",_f=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(nS,{...o,...r,ref:t})});_f.displayName=vS;var bS="DropdownMenuItemIndicator",Pf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(rS,{...o,...r,ref:t})});Pf.displayName=bS;var wS="DropdownMenuSeparator",Rf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(oS,{...o,...r,ref:t})});Rf.displayName=wS;var yS="DropdownMenuArrow",SS=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(sS,{...o,...r,ref:t})});SS.displayName=yS;var CS="DropdownMenuSubTrigger",Mf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(iS,{...o,...r,ref:t})});Mf.displayName=CS;var TS="DropdownMenuSubContent",Of=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(aS,{...o,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Of.displayName=TS;var kS=Sf,ES=Tf,IS=kf,Df=If,Lf=Nf,$f=Af,Ff=jf,Bf=_f,zf=Pf,Hf=Rf,Uf=Mf,Wf=Of;const Ts=kS,ks=ES,NS=h.forwardRef(({className:e,inset:t,children:n,...r},o)=>u.jsxs(Uf,{ref:o,className:ne("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",t&&"pl-8",e),...r,children:[n,u.jsx(le.ChevronRight,{className:"ml-auto h-4 w-4"})]}));NS.displayName=Uf.displayName;const AS=h.forwardRef(({className:e,...t},n)=>u.jsx(Wf,{ref:n,className:ne("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...t}));AS.displayName=Wf.displayName;const ho=h.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(IS,{children:u.jsx(Df,{ref:r,sideOffset:t,className:ne("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n})}));ho.displayName=Df.displayName;const Fn=h.forwardRef(({className:e,inset:t,...n},r)=>u.jsx($f,{ref:r,className:ne("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...n}));Fn.displayName=$f.displayName;const jS=h.forwardRef(({className:e,children:t,checked:n,...r},o)=>u.jsxs(Ff,{ref:o,className:ne("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:n,...r,children:[u.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx(zf,{children:u.jsx(le.Check,{className:"h-4 w-4"})})}),t]}));jS.displayName=Ff.displayName;const _S=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Bf,{ref:r,className:ne("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[u.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx(zf,{children:u.jsx(le.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));_S.displayName=Bf.displayName;const PS=h.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(Lf,{ref:r,className:ne("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));PS.displayName=Lf.displayName;const RS=h.forwardRef(({className:e,...t},n)=>u.jsx(Hf,{ref:n,className:ne("-mx-1 my-1 h-px bg-muted",e),...t}));RS.displayName=Hf.displayName;const Ea=h.forwardRef(({className:e,...t},n)=>u.jsx("textarea",{className:ne("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),ref:n,...t}));Ea.displayName="Textarea";const MS=1e4;function Vf({initialValue:e="",editingMessageId:t=null,placeholder:n="Type your message...",isStreaming:r=!1,disabled:o=!1,maxLength:s=MS,value:i,onValueChange:a,onSend:l,onCancelEdit:c,onStop:d,className:p="",textareaClassName:m="",allowEmptySend:f=!1,sendButtonClassName:v,validate:x,onValidationError:g}){const b=i!==void 0,[y,S]=w.useState(e),k=(b?i:y)??"",[C,T]=w.useTransition(),E=w.useRef(null),j=w.useRef(0),P=w.useRef(null),O=w.useRef("");w.useEffect(()=>{b||(S(e??""),P.current=null,E.current&&(E.current.style.height="auto",E.current.style.height=`${E.current.scrollHeight}px`))},[e,t,b]);const[F,q]=w.useState(null),Y=w.useCallback(N=>N.length>s?`Message too long (${N.length}/${s} characters)`:null,[s]),R=w.useMemo(()=>x??Y,[x,Y]),K=w.useCallback(N=>{const L=R(N);return q(L),g==null||g(L),O.current=N,L},[R,g]),U=w.useCallback(()=>{const N=E.current;N&&(N.style.height="auto",N.style.height=`${N.scrollHeight}px`)},[]);w.useEffect(()=>{U()},[U,k]),w.useEffect(()=>{if(!F)return;const N=(k??"").trim();O.current!==N&&K(N)},[k,F,K]);const W=w.useCallback((N,{fromUser:L})=>{b||S(N),L&&(a==null||a(N))},[b,a]),M=w.useCallback(async N=>{N&&N.preventDefault();const L=(k??"").trim();if(!L&&!f||K(L))return;const z=++j.current;P.current={id:z,shouldClear:!0},T(()=>{var $,D,J;try{const Q=l(L);Q&&typeof Q.then=="function"?Q.then(()=>{var ie,Z;((ie=P.current)==null?void 0:ie.id)===z&&P.current.shouldClear&&(b||(S(""),E.current&&(E.current.style.height="auto"),a==null||a(""))),((Z=P.current)==null?void 0:Z.id)===z&&(P.current=null)}).catch(()=>{var ie;((ie=P.current)==null?void 0:ie.id)===z&&(P.current=null)}):((($=P.current)==null?void 0:$.id)===z&&P.current.shouldClear&&(b||(S(""),E.current&&(E.current.style.height="auto"),a==null||a(""))),((D=P.current)==null?void 0:D.id)===z&&(P.current=null))}catch{((J=P.current)==null?void 0:J.id)===z&&(P.current=null)}})},[k,l,f,b,a,K]),I=w.useCallback(N=>{const L=N.target.value;W(L,{fromUser:!0}),P.current&&(P.current.shouldClear=!1),E.current&&(E.current.style.height="auto",E.current.style.height=`${E.current.scrollHeight}px`),F&&K(L.trim())},[W,K,F]),G=w.useCallback(N=>{N.key==="Enter"&&!N.shiftKey?(N.preventDefault(),M()):N.key==="Escape"&&t&&(N.preventDefault(),c==null||c())},[M,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:N=>void M(N),className:`w-full ${p}`,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(Ze,{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(Ze,{type:"submit",size:"icon",className:`shrink-0 ${v??""}`,title:t?"Save changes":"Send message",disabled:o||!k.trim()&&!f||C,children:u.jsx(le.Send,{size:16})})})]})})}const OS=w.memo(Vf);function Kf({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:p={},enableFileUpload:m=!1,enableExcelUpload:f=!1,onExcelUpload:v,onError:x,allowEmptySend:g=!1,inputError:b=null}){const[y,S]=w.useState([]),k=w.useRef(null),C=w.useRef(null),[T,E]=w.useState(0),[j,P]=w.useState(0),[O,F]=w.useState(!1),[q,Y]=w.useState(null),[R,K]=w.useState(null),U=w.useCallback(()=>{k.current&&(k.current.value=""),C.current&&(C.current.value=""),E(N=>N+1),P(N=>N+1)},[]),W=w.useCallback(N=>{S(L=>[...L,...N])},[]),M=w.useCallback(N=>{const L=Array.from(N.target.files||[]);W(L),N.target.value=""},[W]),I=w.useCallback(N=>{S(L=>{const z=L.filter(($,D)=>D!==N);return z.length===0&&U(),z})},[U]),G=w.useCallback(async N=>{const L=(N.target.files||[])[0];if(L&&(Y(null),K(null),!!v)){F(!0);try{await v(L),Y(`Uploaded ${L.name} - processing through chat stream`)}catch(z){const $=z instanceof Error?z.message:"Failed to upload Excel file";K($),x==null||x($)}finally{F(!1),N.target.value="",U()}}},[v,x,U]),X=w.useMemo(()=>g||y.length>0,[g,y]),_=w.useCallback(async N=>{const L=n(N,y);try{const z=await L;return y.length>0&&(S([]),U()),z}catch(z){throw z}},[n,U,y]),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":""} ${b?"border-red-400":""} ${p.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:M,className:"hidden"},T),y.length>0&&u.jsx("div",{className:"flex flex-wrap gap-2",children:y.map((N,L)=>u.jsxs("div",{className:"flex items-center gap-2 bg-gray-100 dark:bg-gray-800 rounded-lg px-3 py-2 text-sm text-gray-900 dark:text-gray-100",children:[u.jsx(le.Paperclip,{size:14}),u.jsx("span",{className:"truncate max-w-[150px]",children:N.name}),u.jsx(Ze,{variant:"ghost",size:"sm",onClick:()=>I(L),className:"h-4 w-4 p-0 text-gray-500 dark:text-gray-400 hover:text-red-500 dark:hover:text-red-400","aria-label":`Remove ${N.name}`,children:u.jsx(le.X,{size:12})})]},L))})]}),f&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:C,type:"file",accept:".xls,.xlsx,.xlsm",onChange:G,className:"hidden"},j),O&&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..."]}),q&&!O&&u.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:q}),R&&!O&&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(Ze,{type:"button",size:"icon",variant:"outline",disabled:l||c,title:"More input actions",className:p.moreButton||"",children:u.jsx(le.Plus,{size:16})})}),u.jsxs(ho,{align:"start",sideOffset:6,className:"w-52",children:[m&&u.jsxs(Fn,{onClick:()=>{var N;return(N=k.current)==null?void 0:N.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 N;O||(N=C.current)==null||N.click()},className:`cursor-pointer ${O?"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(OS,{initialValue:i,editingMessageId:s,value:e,onValueChange:t,placeholder:s?"Edit your message...":a,isStreaming:l,disabled:c,onSend:_,onCancelEdit:r,onStop:o,allowEmptySend:X,textareaClassName:B,sendButtonClassName:p.sendButton})})]})]})}const DS=w.memo(Kf),Es=0,Bn=1,Pr=2,qf=4;function Gf(e){return()=>e}function LS(e){e()}function Yf(e,t){return n=>e(t(n))}function Xf(e,t){return()=>e(t)}function $S(e,t){return n=>e(t,n)}function Ia(e){return e!==void 0}function FS(...e){return()=>{e.map(LS)}}function Rr(){}function Is(e,t){return t(e),e}function BS(e,t){return t(e)}function ot(...e){return e}function Xe(e,t){return e(Bn,t)}function Ne(e,t){e(Es,t)}function Na(e){e(Pr)}function pt(e){return e(qf)}function ge(e,t){return Xe(e,$S(t,Es))}function un(e,t){const n=e(Bn,r=>{n(),t(r)});return n}function Jf(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function Zf(e,t){return e===t}function st(e=Zf){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function Se(e){return t=>n=>{e(n)&&t(n)}}function de(e){return t=>Yf(t,e)}function Cn(e){return t=>()=>{t(e)}}function ee(e,...t){const n=zS(...t);return(r,o)=>{switch(r){case Pr:Na(e);return;case Bn:return Xe(e,n(o))}}}function Tn(e,t){return n=>r=>{n(t=e(t,r))}}function rr(e){return t=>n=>{e>0?e--:t(n)}}function _n(e){let t=null,n;return r=>o=>{t=o,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function Me(...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);Xe(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 zS(...e){return t=>e.reduceRight(BS,t)}function HS(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=Xe(e,s),t):(r(),Rr);case Pr:r(),n=null;return}}}function se(e){let t=e;const n=Ve();return(r,o)=>{switch(r){case Es:t=o;break;case Bn:{o(t);break}case qf:return t}return n(r,o)}}function jt(e,t){return Is(se(t),n=>ge(e,n))}function Ve(){const e=[];return(t,n)=>{switch(t){case Es:e.slice().forEach(r=>{r(n)});return;case Pr:e.splice(0,e.length);return;case Bn:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}}}function Jt(e){return Is(Ve(),t=>ge(e,t))}function qe(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:US(),singleton:n}}const US=()=>Symbol();function WS(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 vt(...e){const t=Ve(),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);Xe(s,l=>{n[i]=l,r=r|a,r===o&&Ne(t,n)})}),function(s,i){switch(s){case Pr:{Na(t);return}case Bn:return r===o&&i(n),Xe(t,i)}}}function ye(e,t=Zf){return ee(e,st(t))}function Aa(...e){return function(t,n){switch(t){case Pr:return;case Bn:return FS(...e.map(r=>Xe(r,n)))}}}var Ht=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(Ht||{});const VS={0:"debug",3:"error",1:"log",2:"warn"},KS=()=>typeof globalThis>"u"?window:globalThis,zn=qe(()=>{const e=se(3);return{log:se((t,n,r=1)=>{var o;const s=(o=KS().VIRTUOSO_LOG_LEVEL)!=null?o:pt(e);r>=s&&console[VS[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0});function or(e,t,n){return 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 qS(e,t,n,r,o,s,i,a,l){const c=w.useCallback(d=>{const p=GS(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 x=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,g=i?a?i.scrollWidth:i.scrollHeight:f?a?v.document.documentElement.scrollWidth:v.document.documentElement.scrollHeight:a?m.scrollWidth:m.scrollHeight,b=i?a?i.offsetWidth:i.offsetHeight:f?a?v.innerWidth:v.innerHeight:a?m.offsetWidth:m.offsetHeight;r({scrollHeight:g,scrollTop:Math.max(x,0),viewportHeight:b}),s==null||s(a?Qf("column-gap",getComputedStyle(d).columnGap,o):Qf("row-gap",getComputedStyle(d).rowGap,o)),p!==null&&e(p)},[e,t,o,s,i,r,a]);return ja(c,n,l)}function GS(e,t,n,r){const o=e.length;if(o===0)return null;const s=[];for(let i=0;i<o;i++){const a=e.item(i);if(a.dataset.index===void 0)continue;const l=parseInt(a.dataset.index),c=parseFloat(a.dataset.knownSize),d=t(a,n);if(d===0&&r("Zero-sized element, this should not happen",{child:a},Ht.ERROR),d===c)continue;const p=s[s.length-1];s.length===0||p.size!==d||p.endIndex!==l-1?s.push({endIndex:l,size:d,startIndex:l}):s[s.length-1].endIndex++}return s}function Qf(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Ht.WARN),t==="normal"?0:parseInt(t??"0",10)}function ep(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 p,m;if(t){const f=t.getBoundingClientRect(),v=c.top-f.top;m=f.height-Math.max(0,v),p=v+t.scrollTop}else{const f=i.current.ownerDocument.defaultView;m=f.innerHeight-Math.max(0,c.top),p=c.top+f.scrollY}r.current={offsetTop:p,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 Lt=qe(()=>{const e=Ve(),t=Ve(),n=se(0),r=Ve(),o=se(0),s=Ve(),i=Ve(),a=se(0),l=se(0),c=se(0),d=se(0),p=Ve(),m=Ve(),f=se(!1),v=se(!1),x=se(!1);return ge(ee(e,de(({scrollTop:g})=>g)),t),ge(ee(e,de(({scrollHeight:g})=>g)),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:p,scrollTop:t,skipAnimationFrameInResizeObserver:x,smoothScrollTargetReached:r,statefulScrollTop:o,viewportHeight:s}},[],{singleton:!0}),mo={lvl:0};function tp(e,t){const n=e.length;if(n===0)return[];let{index:r,value:o}=t(e[0]);const s=[];for(let i=1;i<n;i++){const{index:a,value:l}=t(e[i]);s.push({end:a-1,start:r,value:o}),r=a,o=l}return s.push({end:1/0,start:r,value:o}),s}function et(e){return e===mo}function go(e,t){if(!et(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(et(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 Zt(e,t,n){return et(e)?op(t,n,1):t===e.k?yt(e,{k:t,v:n}):t<e.k?sp(yt(e,{l:Zt(e.l,t,n)})):sp(yt(e,{r:Zt(e.r,t,n)}))}function Mr(){return mo}function Ns(e,t,n){if(et(e))return[];const r=dn(e,t)[0];return YS(Pa(e,r,n))}function _a(e,t){if(et(e))return mo;const{k:n,l:r,r:o}=e;if(t===n){if(et(r))return o;if(et(o))return r;{const[s,i]=rp(r);return As(yt(e,{k:s,l:np(r),v:i}))}}else return t<n?As(yt(e,{l:_a(r,t)})):As(yt(e,{r:_a(o,t)}))}function sr(e){return et(e)?[]:[...sr(e.l),{k:e.k,v:e.v},...sr(e.r)]}function Pa(e,t,n){if(et(e))return[];const{k:r,l:o,r:s,v:i}=e;let a=[];return r>t&&(a=a.concat(Pa(o,t,n))),r>=t&&r<=n&&a.push({k:r,v:i}),r<=n&&(a=a.concat(Pa(s,t,n))),a}function 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 ip(yt(e,{lvl:n-1}));if(!et(t)&&!et(t.r))return yt(t.r,{l:yt(t,{r:t.r.l}),lvl:n,r:yt(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(Ra(e))return Ma(yt(e,{lvl:n-1}));if(!et(r)&&!et(r.l)){const o=r.l,s=Ra(o)?r.lvl-1:r.lvl;return yt(o,{l:yt(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:Ma(yt(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function yt(e,t){return op(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 np(e){return et(e.r)?e.l:As(yt(e,{r:np(e.r)}))}function Ra(e){return et(e)||e.lvl>e.r.lvl}function rp(e){return et(e.r)?[e.k,e.v]:rp(e.r)}function op(e,t,n,r=mo,o=mo){return{k:e,l:r,lvl:n,r:o,v:t}}function sp(e){return Ma(ip(e))}function ip(e){const{l:t}=e;return!et(t)&&t.lvl===e.lvl?yt(t,{r:yt(e,{l:t.r})}):e}function Ma(e){const{lvl:t,r:n}=e;return!et(n)&&!et(n.r)&&n.lvl===t&&n.r.lvl===t?yt(n,{l:yt(e,{r:n.l}),lvl:t+1}):e}function YS(e){return tp(e,({k:t,v:n})=>({index:t,value:n}))}function ap(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=qe(()=>({recalcInProgress:se(!1)}),[],{singleton:!0});function lp(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 XS(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 _s(e){return!et(e.groupOffsetTree)}function Da({index:e},t){return t===e?0:t<e?-1:1}function JS(){return{groupIndices:[],groupOffsetTree:Mr(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Mr()}}function ZS(e,t){let n=et(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),et(e)){e=Zt(e,0,s);continue}const a=Ns(e,i-1,o+1);if(a.some(sC(r)))continue;let l=!1,c=!1;for(const{end:d,start:p,value:m}of a)l?(o>=p||s===m)&&(e=_a(e,p)):(c=m!==s,l=!0),d>o&&o>=p&&m!==s&&(e=Zt(e,o+1,m));c&&(e=Zt(e,i,s))}return[e,n]}function QS(e){return typeof e.groupIndex<"u"}function eC({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}=lp(t,e,Da),i=e-r,a=s*i+(i-1)*n+o;return a>0?a+n:a}function cp(e,t){if(!_s(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function up(e,t,n){if(QS(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=cp(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function tC(e,t,n,r=0){return r>0&&(t=Math.max(t,lp(e,r,Da).offset)),tp(XS(e,t,n,eC),oC)}function nC(e,[t,n,r,o]){t.length>0&&r("received item sizes",t,Ht.DEBUG);const s=e.sizeTree;let i=s,a=0;if(n.length>0&&et(s)&&t.length===2){const m=t[0].size,f=t[1].size;i=n.reduce((v,x)=>Zt(Zt(v,x,m),x+1,f),i)}else[i,a]=ZS(i,t);if(i===s)return e;const{lastIndex:l,lastOffset:c,lastSize:d,offsetTree:p}=La(e.offsetTree,a,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((m,f)=>Zt(m,f,vo(f,p,o)),Mr()),lastIndex:l,lastOffset:c,lastSize:d,offsetTree:p,sizeTree:i}}function rC(e){return sr(e).map(({k:t,v:n},r,o)=>{const s=o[r+1];return{endIndex:s?s.k-1:1/0,size:n,startIndex:t}})}function dp(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 p=c-s,m=p*i+a+p*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 oC(e){return{index:e.index,value:e}}function sC(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 iC={offsetHeight:"height",offsetWidth:"width"},kn=qe(([{log:e},{recalcInProgress:t}])=>{const n=Ve(),r=Ve(),o=jt(r,0),s=Ve(),i=Ve(),a=se(0),l=se([]),c=se(void 0),d=se(void 0),p=se((C,T)=>Hn(C,iC[T])),m=se(void 0),f=se(0),v=JS(),x=jt(ee(n,Me(l,e,f),Tn(nC,v),st()),v),g=jt(ee(l,st(),Tn((C,T)=>({current:T,prev:C.current}),{current:[],prev:[]}),de(({prev:C})=>C)),[]);ge(ee(l,Se(C=>C.length>0),Me(x,f),de(([C,T,E])=>{const j=C.reduce((P,O,F)=>Zt(P,O,vo(O,T.offsetTree,E)||F),Mr());return{...T,groupIndices:C,groupOffsetTree:j}})),x),ge(ee(r,Me(x),Se(([C,{lastIndex:T}])=>C<T),de(([C,{lastIndex:T,lastSize:E}])=>[{endIndex:T,size:E,startIndex:C}])),n),ge(c,d);const b=jt(ee(c,de(C=>C===void 0)),!0);ge(ee(d,Se(C=>C!==void 0&&et(pt(x).sizeTree)),de(C=>[{endIndex:0,size:C,startIndex:0}])),n);const y=Jt(ee(n,Me(x),Tn(({sizes:C},[T,E])=>({changed:E!==C,sizes:E}),{changed:!1,sizes:v}),de(C=>C.changed)));Xe(ee(a,Tn((C,T)=>({diff:C.prev-T,prev:T}),{diff:0,prev:0}),de(C=>C.diff)),C=>{const{groupIndices:T}=pt(x);if(C>0)Ne(t,!0),Ne(s,C+dp(C,T));else if(C<0){const E=pt(g);E.length>0&&(C-=dp(-C,E)),Ne(i,C)}}),Xe(ee(a,Me(e)),([C,T])=>{C<0&&T("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:a},Ht.ERROR)});const S=Jt(s);ge(ee(s,Me(x),de(([C,T])=>{const E=T.groupIndices.length>0,j=[],P=T.lastSize;if(E){const O=go(T.sizeTree,0);let F=0,q=0;for(;F<C;){const R=T.groupIndices[q],K=T.groupIndices.length===q+1?1/0:T.groupIndices[q+1]-R-1;j.push({endIndex:R,size:O,startIndex:R}),j.push({endIndex:R+1+K-1,size:P,startIndex:R+1}),q++,F+=K+1}const Y=sr(T.sizeTree);return F!==C&&Y.shift(),Y.reduce((R,{k:K,v:U})=>{let W=R.ranges;return R.prevSize!==0&&(W=[...R.ranges,{endIndex:K+C-1,size:R.prevSize,startIndex:R.prevIndex}]),{prevIndex:K+C,prevSize:U,ranges:W}},{prevIndex:C,prevSize:0,ranges:j}).ranges}return sr(T.sizeTree).reduce((O,{k:F,v:q})=>({prevIndex:F+C,prevSize:q,ranges:[...O.ranges,{endIndex:F+C-1,size:O.prevSize,startIndex:O.prevIndex}]}),{prevIndex:0,prevSize:P,ranges:[]}).ranges})),n);const k=Jt(ee(i,Me(x,f),de(([C,{offsetTree:T},E])=>{const j=-C;return vo(j,T,E)})));return ge(ee(i,Me(x,f),de(([C,T,E])=>{if(T.groupIndices.length>0){if(et(T.sizeTree))return T;let j=Mr();const P=pt(g);let O=0,F=0,q=0;for(;O<-C;){q=P[F];const Y=P[F+1]-q-1;F++,O+=Y+1}if(j=sr(T.sizeTree).reduce((Y,{k:R,v:K})=>Zt(Y,Math.max(0,R+C),K),j),O!==-C){const Y=go(T.sizeTree,q);j=Zt(j,0,Y);const R=dn(T.sizeTree,-C+1)[1];j=Zt(j,1,R)}return{...T,sizeTree:j,...La(T.offsetTree,0,j,E)}}else{const j=sr(T.sizeTree).reduce((P,{k:O,v:F})=>Zt(P,Math.max(0,O+C),F),Mr());return{...T,sizeTree:j,...La(T.offsetTree,0,j,E)}}})),x),{beforeUnshiftWith:S,data:m,defaultItemSize:d,firstItemIndex:a,fixedItemSize:c,gap:f,groupIndices:l,itemSize:p,listRefresh:y,shiftWith:i,shiftWithOffset:k,sizeRanges:n,sizes:x,statefulTotalCount:o,totalCount:r,trackItemSizes:b,unshiftWith:s}},ot(zn,Oa),{singleton:!0});function aC(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const fp=qe(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=Ve(),i=Ve(),a=Jt(ee(s,de(aC)));return ge(ee(a,de(l=>l.totalCount)),n),ge(ee(a,de(l=>l.groupIndices)),e),ge(ee(vt(o,t,r),Se(([l,c])=>_s(c)),de(([l,c,d])=>dn(c.groupOffsetTree,Math.max(l-d,0),"v")[0]),st(),de(l=>[l])),i),{groupCounts:s,topItemsIndexes:i}},ot(kn,Lt)),Un=qe(([{log:e}])=>{const t=se(!1),n=Jt(ee(t,Se(r=>r),st()));return Xe(t,r=>{r&&pt(e)("props updated",{},Ht.DEBUG)}),{didMount:n,propsReady:t}},ot(zn),{singleton:!0}),lC=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function pp(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!lC)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const bo=qe(([{gap:e,listRefresh:t,sizes:n,totalCount:r},{fixedFooterHeight:o,fixedHeaderHeight:s,footerHeight:i,headerHeight:a,scrollingInProgress:l,scrollTo:c,smoothScrollTargetReached:d,viewportHeight:p},{log:m}])=>{const f=Ve(),v=Ve(),x=se(0);let g=null,b=null,y=null;function S(){g&&(g(),g=null),y&&(y(),y=null),b&&(clearTimeout(b),b=null),Ne(l,!1)}return ge(ee(f,Me(n,p,r,x,a,i,m),Me(e,s,o),de(([[k,C,T,E,j,P,O,F],q,Y,R])=>{const K=pp(k),{align:U,behavior:W,offset:M}=K,I=E-1,G=up(K,C,I);let X=vo(G,C.offsetTree,q)+P;U==="end"?(X+=Y+dn(C.sizeTree,G)[1]-T+R,G===I&&(X+=O)):U==="center"?X+=(Y+dn(C.sizeTree,G)[1]-T+R)/2:X-=j,M&&(X+=M);const _=B=>{S(),B?(F("retrying to scroll to",{location:k},Ht.DEBUG),Ne(f,k)):(Ne(v,!0),F("list did not change, scroll successful",{},Ht.DEBUG))};if(S(),W==="smooth"){let B=!1;y=Xe(t,N=>{B=B||N}),g=un(d,()=>{_(B)})}else g=un(ee(t,cC(150)),_);return b=setTimeout(()=>{S()},1200),Ne(l,!0),F("scrolling from index to",{behavior:W,index:G,top:X},Ht.DEBUG),{behavior:W,top:X}})),c),{scrollTargetReached:v,scrollToIndex:f,topListHeight:x}},ot(kn,Lt,zn),{singleton:!0});function cC(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 wo=qe(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:s},{didMount:i}])=>{const a=se(!0),l=se(0),c=se(!0);return ge(ee(i,Me(l),Se(([d,p])=>!!p),Cn(!1)),a),ge(ee(i,Me(l),Se(([d,p])=>!!p),Cn(!1)),c),Xe(ee(vt(t,i),Me(a,n,e,c),Se(([[,d],p,{sizeTree:m},f,v])=>d&&(!et(m)||Ia(f))&&!p&&!v),Me(l)),([,d])=>{un(o,()=>{Ne(c,!0)}),$a(4,()=>{un(r,()=>{Ne(a,!0)}),Ne(s,d)})}),{initialItemFinalLocationReached:c,initialTopMostItemIndex:l,scrolledToInitialItem:a}},ot(kn,Lt,bo,Un),{singleton:!0});function hp(e,t){return Math.abs(e-t)<1.01}const yo="up",So="down",uC="none",dC={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},fC=0,Co=qe(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=se(!1),a=se(!0),l=Ve(),c=Ve(),d=se(4),p=se(fC),m=jt(ee(Aa(ee(ye(o),rr(1),Cn(!0)),ee(ye(o),rr(1),Cn(!1),Jf(100))),st()),!1),f=jt(ee(Aa(ee(n,Cn(!0)),ee(n,Cn(!1),Jf(200))),st()),!1);ge(ee(vt(ye(o),ye(p)),de(([y,S])=>y<=S),st()),a),ge(ee(a,_n(50)),c);const v=Jt(ee(vt(r,ye(s),ye(t),ye(e),ye(d)),Tn((y,[{scrollHeight:S,scrollTop:k},C,T,E,j])=>{const P=k+C-S>-j,O={scrollHeight:S,scrollTop:k,viewportHeight:C};if(P){let q,Y;return k>y.state.scrollTop?(q="SCROLLED_DOWN",Y=y.state.scrollTop-k):(q="SIZE_DECREASED",Y=y.state.scrollTop-k||y.scrollTopDelta),{atBottom:!0,atBottomBecause:q,scrollTopDelta:Y,state:O}}let F;return O.scrollHeight>y.state.scrollHeight?F="SIZE_INCREASED":C<y.state.viewportHeight?F="VIEWPORT_HEIGHT_DECREASING":k<y.state.scrollTop?F="SCROLLING_UPWARDS":F="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:F,state:O}},dC),st((y,S)=>y&&y.atBottom===S.atBottom))),x=jt(ee(r,Tn((y,{scrollHeight:S,scrollTop:k,viewportHeight:C})=>{if(hp(y.scrollHeight,S))return{changed:!1,jump:0,scrollHeight:S,scrollTop:k};{const T=S-(k+C)<1;return y.scrollTop!==k&&T?{changed:!0,jump:y.scrollTop-k,scrollHeight:S,scrollTop:k}:{changed:!0,jump:0,scrollHeight:S,scrollTop:k}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),Se(y=>y.changed),de(y=>y.jump)),0);ge(ee(v,de(y=>y.atBottom)),i),ge(ee(i,_n(50)),l);const g=se(So);ge(ee(r,de(({scrollTop:y})=>y),st(),Tn((y,S)=>pt(f)?{direction:y.direction,prevScrollTop:S}:{direction:S<y.prevScrollTop?yo:So,prevScrollTop:S},{direction:So,prevScrollTop:0}),de(y=>y.direction)),g),ge(ee(r,_n(50),Cn(uC)),g);const b=se(0);return ge(ee(m,Se(y=>!y),Cn(0)),b),ge(ee(o,_n(100),Me(m),Se(([y,S])=>!!S),Tn(([y,S],[k])=>[S,k],[0,0]),de(([y,S])=>S-y)),b),{atBottomState:v,atBottomStateChange:l,atBottomThreshold:d,atTopStateChange:c,atTopThreshold:p,isAtBottom:i,isAtTop:a,isScrolling:m,lastJumpDueToItemResize:x,scrollDirection:g,scrollVelocity:b}},ot(Lt)),Ps="top",Rs="bottom",mp="none";function gp(e,t,n){return typeof e=="number"?n===yo&&t===Ps||n===So&&t===Rs?e:0:n===yo?t===Ps?e.main:e.reverse:t===Rs?e.main:e.reverse}function xp(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const Ba=qe(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=Ve(),i=se(0),a=se(0),l=se(0),c=jt(ee(vt(ye(r),ye(o),ye(n),ye(s,xo),ye(l),ye(i),ye(t),ye(e),ye(a)),de(([d,p,m,[f,v],x,g,b,y,S])=>{const k=d-y,C=g+b,T=Math.max(m-k,0);let E=mp;const j=xp(S,Ps),P=xp(S,Rs);return f-=y,f+=m+b,v+=m+b,v-=y,f>d+C-j&&(E=yo),v<d-T+p+P&&(E=So),E!==mp?[Math.max(k-m-gp(x,Ps,E)-j,0),k-T-b+p+gp(x,Rs,E)+P]:null}),Se(d=>d!=null),st(xo)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:l,topListHeight:i,visibleRange:c}},ot(Lt),{singleton:!0});function pC(e,t,n){if(_s(t)){const r=cp(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 x=e[e.length-1];d=x.offset+x.size}const p=n-i,m=a+p*l+(p-1)*r,f=c,v=m-d;return{bottom:d,firstItemIndex:s,items:bp(e,o,s),offsetBottom:v,offsetTop:c,top:f,topItems:bp(t,o,s),topListHeight:t.reduce((x,g)=>g.size+x,0),totalCount:n}}function vp(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,p)=>({data:s[p+l],index:p+l,offset:0,size:0}));return Ms(c,[],a,o,n,r)}function bp(e,t,n){if(e.length===0)return[];if(!_s(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 ir=qe(([{data:e,firstItemIndex:t,gap:n,sizes:r,totalCount:o},s,{listBoundary:i,topListHeight:a,visibleRange:l},{initialTopMostItemIndex:c,scrolledToInitialItem:d},{topListHeight:p},m,{didMount:f},{recalcInProgress:v}])=>{const x=se([]),g=se(0),b=Ve();ge(s.topItemsIndexes,x);const y=jt(ee(vt(f,v,ye(l,xo),ye(o),ye(r),ye(c),d,ye(x),ye(t),ye(n),e),Se(([T,E,,j,,,,,,,P])=>{const O=P&&P.length!==j;return T&&!E&&!O}),de(([,,[T,E],j,P,O,F,q,Y,R,K])=>{const U=P,{offsetTree:W,sizeTree:M}=U,I=pt(g);if(j===0)return{...za,totalCount:j};if(T===0&&E===0)return I===0?{...za,totalCount:j}:vp(I,O,P,Y,R,K||[]);if(et(M))return I>0?null:Ms(pC(Fa(O,j),U,K),[],j,R,U,Y);const G=[];if(q.length>0){const L=q[0],z=q[q.length-1];let $=0;for(const D of Ns(M,L,z)){const J=D.value,Q=Math.max(D.start,L),ie=Math.min(D.end,z);for(let Z=Q;Z<=ie;Z++)G.push({data:K==null?void 0:K[Z],index:Z,offset:$,size:J}),$+=J}}if(!F)return Ms([],G,j,R,U,Y);const X=q.length>0?q[q.length-1]+1:0,_=tC(W,T,E,X);if(_.length===0)return null;const B=j-1,N=Is([],L=>{for(const z of _){const $=z.value;let D=$.offset,J=z.start;const Q=$.size;if($.offset<T){J+=Math.floor((T-$.offset+R)/(Q+R));const Z=J-z.start;D+=Z*Q+Z*R}J<X&&(D+=(X-J)*Q,J=X);const ie=Math.min(z.end,B);for(let Z=J;Z<=ie&&!(D>=E);Z++)L.push({data:K==null?void 0:K[Z],index:Z,offset:D,size:Q}),D+=Q+R}});return Ms(N,G,j,R,U,Y)}),Se(T=>T!==null),st()),za);ge(ee(e,Se(Ia),de(T=>T==null?void 0:T.length)),o),ge(ee(y,de(T=>T.topListHeight)),p),ge(p,a),ge(ee(y,de(T=>[T.top,T.bottom])),i),ge(ee(y,de(T=>T.items)),b);const S=Jt(ee(y,Se(({items:T})=>T.length>0),Me(o,e),Se(([{items:T},E])=>T[T.length-1].originalIndex===E-1),de(([,T,E])=>[T-1,E]),st(xo),de(([T])=>T))),k=Jt(ee(y,_n(200),Se(({items:T,topItems:E})=>T.length>0&&T[0].originalIndex===E.length),de(({items:T})=>T[0].index),st())),C=Jt(ee(y,Se(({items:T})=>T.length>0),de(({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}}),st(ap)));return{endReached:S,initialItemCount:g,itemsRendered:b,listState:y,rangeChanged:C,startReached:k,topItemsIndexes:x,...m}},ot(kn,fp,Ba,wo,bo,Co,Un,Oa),{singleton:!0}),wp=qe(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=Ve(),i=jt(ee(vt(n,e,r,t,o),de(([a,l,c,d,p])=>a+l+c+d+p.offsetBottom+p.bottom)),0);return ge(ye(i),s),{totalListHeight:i,totalListHeightChanged:s}},ot(Lt,ir),{singleton:!0}),hC=qe(([{viewportHeight:e},{totalListHeight:t}])=>{const n=se(!1),r=jt(ee(vt(n,e,t),Se(([o])=>o),de(([,o,s])=>Math.max(0,o-s)),_n(0),st()),0);return{alignToBottom:n,paddingTopAddition:r}},ot(Lt,wp),{singleton:!0}),yp=qe(()=>({context:se(null)})),mC=({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,Sp=qe(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:s,scrollingInProgress:i,scrollTop:a,viewportHeight:l},{scrollToIndex:c}])=>{const d=Ve();return ge(ee(d,Me(t,l,n,s,o,r,a),Me(e),de(([[p,m,f,v,x,g,b,y],S])=>{const{align:k,behavior:C,calculateViewLocation:T=mC,done:E,...j}=p,P=up(p,m,v-1),O=vo(P,m.offsetTree,S)+x+g,F=O+dn(m.sizeTree,P)[1],q=y+g,Y=y+f-b,R=T({itemBottom:F,itemTop:O,locationParams:{align:k,behavior:C,...j},viewportBottom:Y,viewportTop:q});return R?E&&un(ee(i,Se(K=>!K),rr(pt(i)?1:2)),E):E&&E(),R}),Se(p=>p!==null)),c),{scrollIntoView:d}},ot(kn,Lt,bo,ir,zn),{singleton:!0});function Cp(e){return e?e==="smooth"?"smooth":"auto":!1}const gC=(e,t)=>typeof e=="function"?Cp(e(t)):t&&Cp(e),xC=qe(([{listRefresh:e,totalCount:t,fixedItemSize:n,data:r},{atBottomState:o,isAtBottom:s},{scrollToIndex:i},{scrolledToInitialItem:a},{didMount:l,propsReady:c},{log:d},{scrollingInProgress:p},{context:m},{scrollIntoView:f}])=>{const v=se(!1),x=Ve();let g=null;function b(C){Ne(i,{align:"end",behavior:C,index:"LAST"})}Xe(ee(vt(ee(ye(t),rr(1)),l),Me(ye(v),s,a,p),de(([[C,T],E,j,P,O])=>{let F=T&&P,q="auto";return F&&(q=gC(E,j||O),F=F&&!!q),{followOutputBehavior:q,shouldFollow:F,totalCount:C}}),Se(({shouldFollow:C})=>C)),({followOutputBehavior:C,totalCount:T})=>{g&&(g(),g=null),pt(n)?requestAnimationFrame(()=>{pt(d)("following output to ",{totalCount:T},Ht.DEBUG),b(C)}):g=un(e,()=>{pt(d)("following output to ",{totalCount:T},Ht.DEBUG),b(C),g=null})});function y(C){const T=un(o,E=>{C&&!E.atBottom&&E.notAtBottomBecause==="SIZE_INCREASED"&&!g&&(pt(d)("scrolling to bottom due to increased size",{},Ht.DEBUG),b("auto"))});setTimeout(T,100)}Xe(ee(vt(ye(v),t,c),Se(([C,,T])=>C&&T),Tn(({value:C},[,T])=>({refreshed:C===T,value:T}),{refreshed:!1,value:0}),Se(({refreshed:C})=>C),Me(v,t)),([,C])=>{pt(a)&&y(C!==!1)}),Xe(x,()=>{y(pt(v)!==!1)}),Xe(vt(ye(v),o),([C,T])=>{C&&!T.atBottom&&T.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&b("auto")});const S=se(null),k=Ve();return ge(Aa(ee(ye(r),de(C=>{var T;return(T=C==null?void 0:C.length)!=null?T:0})),ee(ye(t))),k),Xe(ee(vt(ee(k,rr(1)),l),Me(ye(S),a,p,m),de(([[C,T],E,j,P,O])=>T&&j&&(E==null?void 0:E({context:O,totalCount:C,scrollingInProgress:P}))),Se(C=>!!C),_n(0)),C=>{g&&(g(),g=null),pt(n)?requestAnimationFrame(()=>{pt(d)("scrolling into view",{}),Ne(f,C)}):g=un(e,()=>{pt(d)("scrolling into view",{}),Ne(f,C),g=null})}),{autoscrollToBottom:x,followOutput:v,scrollIntoViewOnChange:S}},ot(kn,Co,bo,wo,Un,zn,Lt,yp,Sp)),vC=qe(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(ge(ee(a,Me(s),Se(([,l])=>l!==0),Me(o,r,t,n,e),de(([[,l],c,d,p,m,f=[]])=>vp(l,c,d,p,m,f))),i),{}),ot(kn,wo,ir,Un),{singleton:!0}),bC=qe(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=se(0);return Xe(ee(e,Me(r),Se(([,o])=>o!==0),de(([,o])=>({top:o}))),o=>{un(ee(n,rr(1),Se(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{Ne(t,o)})})}),{initialScrollTop:r}},ot(Un,Lt,ir),{singleton:!0}),Tp=qe(([{scrollVelocity:e}])=>{const t=se(!1),n=Ve(),r=se(!1);return ge(ee(e,Me(r,t,n),Se(([o,s])=>!!s),de(([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}),st()),t),Xe(ee(vt(t,e,n),Me(r)),([[o,s,i],a])=>{o&&a&&a.change&&a.change(s,i)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},ot(Co),{singleton:!0}),Ha=qe(([{scrollContainerState:e,scrollTo:t}])=>{const n=Ve(),r=Ve(),o=Ve(),s=se(!1),i=se(void 0);return ge(ee(vt(n,r),de(([{scrollHeight:a,scrollTop:l,viewportHeight:c},{offsetTop:d}])=>({scrollHeight:a,scrollTop:Math.max(0,l-d),viewportHeight:c}))),e),ge(ee(t,Me(r),de(([a,{offsetTop:l}])=>({...a,top:a.top+l}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},ot(Lt)),wC=qe(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:a,windowViewportRect:l}])=>{const c=Ve(),d=se(void 0),p=se(null),m=se(null);return ge(a,p),ge(l,m),Xe(ee(c,Me(t,r,i,p,m,n)),([f,v,x,g,b,y,S])=>{const k=rC(v.sizeTree);g&&b!==null&&y!==null&&(x=b.scrollTop-y.offsetTop),x-=S,f({ranges:k,scrollTop:x})}),ge(ee(d,Se(Ia),de(yC)),o),ge(ee(s,Me(d),Se(([,f])=>f!==void 0),st(),de(([,f])=>f.ranges)),e),{getState:c,restoreStateFrom:d}},ot(kn,Lt,wo,Un,Ha));function yC(e){return{align:"start",index:0,offset:e.scrollTop}}const SC=qe(([{topItemsIndexes:e}])=>{const t=se(0);return ge(ee(t,Se(n=>n>=0),de(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},ot(ir));function kp(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const CC=kp(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),TC=qe(([{deviation:e,scrollBy:t,scrollingInProgress:n,scrollTop:r},{isAtBottom:o,isScrolling:s,lastJumpDueToItemResize:i,scrollDirection:a},{listState:l},{beforeUnshiftWith:c,gap:d,shiftWithOffset:p,sizes:m},{log:f},{recalcInProgress:v}])=>{const x=Jt(ee(l,Me(i),Tn(([,b,y,S],[{bottom:k,items:C,offsetBottom:T,totalCount:E},j])=>{const P=k+T;let O=0;return y===E&&b.length>0&&C.length>0&&(C[0].originalIndex===0&&b[0].originalIndex===0||(O=P-S,O!==0&&(O+=j))),[O,C,E,P]},[0,[],0,0]),Se(([b])=>b!==0),Me(r,a,n,o,f,v),Se(([,b,y,S,,,k])=>!k&&!S&&b!==0&&y===yo),de(([[b],,,,,y])=>(y("Upward scrolling compensation",{amount:b},Ht.DEBUG),b))));function g(b){b>0?(Ne(t,{behavior:"auto",top:-b}),Ne(e,0)):(Ne(e,0),Ne(t,{behavior:"auto",top:-b}))}return Xe(ee(x,Me(e,s)),([b,y,S])=>{S&&CC()?Ne(e,y-b):g(-b)}),Xe(ee(vt(jt(s,!1),e,v),Se(([b,y,S])=>!b&&!S&&y!==0),de(([b,y])=>y),_n(1)),g),ge(ee(p,de(b=>({top:-b}))),t),Xe(ee(c,Me(m,d),de(([b,{groupIndices:y,lastSize:S,sizeTree:k},C])=>{function T(E){return E*(S+C)}if(y.length===0)return T(b);{let E=0;const j=go(k,0);let P=0,O=0;for(;P<b;){P++,E+=j;let F=y.length===O+1?1/0:y[O+1]-y[O]-1;P+F>b&&(E-=j,F=b-P+1),P+=F,E+=T(F),O++}return E}})),b=>{Ne(e,b),requestAnimationFrame(()=>{Ne(t,{top:b}),requestAnimationFrame(()=>{Ne(e,0),Ne(v,!1)})})}),{deviation:e}},ot(Lt,Co,ir,kn,zn,Oa)),kC=qe(([e,t,n,r,o,s,i,a,l,c,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...l,...c,...d}),ot(Ba,vC,Un,Tp,wp,bC,hC,Ha,Sp,zn,yp)),Ep=qe(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:r,gap:o,groupIndices:s,itemSize:i,sizeRanges:a,sizes:l,statefulTotalCount:c,totalCount:d,trackItemSizes:p},{initialItemFinalLocationReached:m,initialTopMostItemIndex:f,scrolledToInitialItem:v},x,g,b,{listState:y,topItemsIndexes:S,...k},{scrollToIndex:C},T,{topItemCount:E},{groupCounts:j},P])=>(ge(k.rangeChanged,P.scrollSeekRangeChanged),ge(ee(P.windowViewportRect,de(O=>O.visibleHeight)),x.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,gap:o,groupCounts:j,initialItemFinalLocationReached:m,initialTopMostItemIndex:f,scrolledToInitialItem:v,sizeRanges:a,topItemCount:E,topItemsIndexes:S,totalCount:d,...b,groupIndices:s,itemSize:i,listState:y,scrollToIndex:C,statefulTotalCount:c,trackItemSizes:p,...k,...P,...x,sizes:l,...g}),ot(kn,wo,Lt,wC,xC,ir,bo,TC,SC,fp,kC));function EC(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 Ip(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(g,b){g.propsReady&&Ne(g.propsReady,!1);for(const y of r){const S=g[t.required[y]];Ne(S,b[y])}for(const y of o)if(y in b){const S=g[t.optional[y]];Ne(S,b[y])}g.propsReady&&Ne(g.propsReady,!0)}function c(g){return s.reduce((b,y)=>(b[y]=S=>{const k=g[t.methods[y]];Ne(k,S)},b),{})}function d(g){return i.reduce((b,y)=>(b[y]=HS(g[t.events[y]]),b),{})}const p=w.forwardRef((g,b)=>{const{children:y,...S}=g,[k]=w.useState(()=>Is(WS(e),E=>{l(E,S)})),[C]=w.useState(Xf(d,k));Os(()=>{for(const E of i)E in S&&Xe(C[E],S[E]);return()=>{Object.values(C).map(Na)}},[S,C,k]),Os(()=>{l(k,S)}),w.useImperativeHandle(b,Gf(c(k)));const T=n;return u.jsx(a.Provider,{value:k,children:n?u.jsx(T,{...EC([...r,...o,...i],S),children:y}):y})}),m=g=>{const b=w.useContext(a);return w.useCallback(y=>{Ne(b[g],y)},[b,g])},f=g=>{const b=w.useContext(a)[g],y=w.useCallback(S=>Xe(b,S),[b]);return w.useSyncExternalStore(y,()=>pt(b),()=>pt(b))},v=g=>{const b=w.useContext(a)[g],[y,S]=w.useState(Xf(pt,b));return Os(()=>Xe(b,k=>{k!==y&&S(Gf(k))}),[b,y]),y},x=w.version.startsWith("18")?f:v;return{Component:p,useEmitter:(g,b)=>{const y=w.useContext(a)[g];Os(()=>Xe(y,b),[b,y])},useEmitterValue:x,usePublisher:m}}const Np=w.createContext(void 0),Ap=w.createContext(void 0),jp=typeof document<"u"?w.useLayoutEffect:w.useEffect;function Ua(e){return"self"in e}function IC(e){return"body"in e}function _p(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,x;const g=m.target;if(IC(g)||Ua(g)){const y=Ua(g)?g:g.defaultView;x=s?y.scrollX:y.scrollY,f=s?y.document.documentElement.scrollWidth:y.document.documentElement.scrollHeight,v=s?y.innerWidth:y.innerHeight}else x=s?g.scrollLeft:g.scrollTop,f=s?g.scrollWidth:g.scrollHeight,v=s?g.offsetWidth:g.offsetHeight;const b=()=>{e({scrollHeight:f,scrollTop:Math.max(x,0),viewportHeight:v})};m.suppressFlushSync?b():Mo.flushSync(b),a.current!==null&&(x===a.current||x<=0||x===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 x,g,b;Ua(f)?(g=Math.max(Hn(f.document.documentElement,s?"width":"height"),s?f.document.documentElement.scrollWidth:f.document.documentElement.scrollHeight),x=s?f.innerWidth:f.innerHeight,b=s?window.scrollX:window.scrollY):(g=f[s?"scrollWidth":"scrollHeight"],x=Hn(f,s?"width":"height"),b=f[s?"scrollLeft":"scrollTop"]);const y=g-x;if(m.top=Math.ceil(Math.max(Math.min(y,m.top),0)),hp(x,g)||m.top===b){e({scrollHeight:g,scrollTop:b,viewportHeight:x}),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 p(m){s&&(m={behavior:m.behavior,left:m.top}),i.current.scrollBy(m)}return{scrollByCallback:p,scrollerRef:i,scrollToCallback:d}}const Wa="-webkit-sticky",Pp="sticky",Va=kp(()=>{if(typeof document>"u")return Pp;const e=document.createElement("div");return e.style.position=Wa,e.style.position===Wa?Wa:Pp});function Ka(e){return e}const NC=qe(()=>{const e=se(a=>`Item ${a}`),t=se(a=>`Group ${a}`),n=se({}),r=se(Ka),o=se("div"),s=se(Rr),i=(a,l=null)=>jt(ee(n,de(c=>c[a]),st()),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")}}),AC=qe(([e,t])=>({...e,...t}),ot(Ep,NC)),jC=({height:e})=>u.jsx("div",{style:{height:e}}),_C={overflowAnchor:"none",position:Va(),zIndex:1},Rp={overflowAnchor:"none"},PC={...Rp,display:"inline-block",height:"100%"},Mp=w.memo(function({showTopList:e=!1}){const t=Te("listState"),n=en("sizeRanges"),r=Te("useWindowScroll"),o=Te("customScrollParent"),s=en("windowScrollContainerState"),i=en("scrollContainerState"),a=o||r?s:i,l=Te("itemContent"),c=Te("context"),d=Te("groupContent"),p=Te("trackItemSizes"),m=Te("itemSize"),f=Te("log"),v=en("gap"),x=Te("horizontalDirection"),{callbackRef:g}=qS(n,m,p,e?Rr:a,f,v,o,x,Te("skipAnimationFrameInResizeObserver")),[b,y]=w.useState(0);qa("deviation",R=>{b!==R&&y(R)});const S=Te("EmptyPlaceholder"),k=Te("ScrollSeekPlaceholder")||jC,C=Te("ListComponent"),T=Te("ItemComponent"),E=Te("GroupComponent"),j=Te("computeItemKey"),P=Te("isSeeking"),O=Te("groupIndices").length>0,F=Te("alignToBottom"),q=Te("initialItemFinalLocationReached"),Y=e?{}:{boxSizing:"border-box",...x?{display:"inline-block",height:"100%",marginLeft:b!==0?b:F?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:b!==0?b:F?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...q?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&S?u.jsx(S,{..._t(S,c)}):u.jsx(C,{..._t(C,c),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:g,style:Y,children:(e?t.topItems:t.items).map(R=>{const K=R.originalIndex,U=j(K+t.firstItemIndex,R.data,c);return P?w.createElement(k,{..._t(k,c),height:R.size,index:R.index,key:U,type:R.type||"item",...R.type==="group"?{}:{groupIndex:R.groupIndex}}):R.type==="group"?w.createElement(E,{..._t(E,c),"data-index":K,"data-item-index":R.index,"data-known-size":R.size,key:U,style:_C},d(R.index,c)):w.createElement(T,{..._t(T,c),...DC(T,R.data),"data-index":K,"data-item-group-index":R.groupIndex,"data-item-index":R.index,"data-known-size":R.size,key:U,style:x?PC:Rp},O?l(R.index,R.groupIndex,R.data,c):l(R.index,R.data,c))})})}),RC={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},MC={outline:"none",overflowX:"auto",position:"relative"},Ds=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),OC={position:Va(),top:0,width:"100%",zIndex:1};function _t(e,t){if(typeof e!="string")return{context:t}}function DC(e,t){return{item:typeof e=="string"?void 0:t}}const LC=w.memo(function(){const e=Te("HeaderComponent"),t=en("headerHeight"),n=Te("HeaderFooterTag"),r=or(w.useMemo(()=>s=>{t(Hn(s,"height"))},[t]),!0,Te("skipAnimationFrameInResizeObserver")),o=Te("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{..._t(e,o)})}):null}),$C=w.memo(function(){const e=Te("FooterComponent"),t=en("footerHeight"),n=Te("HeaderFooterTag"),r=or(w.useMemo(()=>s=>{t(Hn(s,"height"))},[t]),!0,Te("skipAnimationFrameInResizeObserver")),o=Te("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{..._t(e,o)})}):null});function Op({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"),p=t("horizontalDirection")||!1,{scrollByCallback:m,scrollerRef:f,scrollToCallback:v}=_p(a,c,l,d,void 0,p);return e("scrollTo",v),e("scrollBy",m),u.jsx(l,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:f,style:{...p?MC:RC,...o},tabIndex:0,...i,..._t(l,s),children:r})})}function Dp({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"),p=t("deviation"),m=t("customScrollParent"),f=w.useRef(null),v=t("scrollerRef"),{scrollByCallback:x,scrollerRef:g,scrollToCallback:b}=_p(a,c,l,v,m);return jp(()=>{var y;return g.current=m||((y=f.current)==null?void 0:y.ownerDocument.defaultView),()=>{g.current=null}},[g,m]),e("windowScrollTo",b),e("scrollBy",x),u.jsx(l,{ref:f,"data-virtuoso-scroller":!0,style:{position:"relative",...o,...d!==0?{height:d+p}:{}},...i,..._t(l,s),children:r})})}const FC=({children:e})=>{const t=w.useContext(Np),n=en("viewportHeight"),r=en("fixedItemHeight"),o=Te("alignToBottom"),s=Te("horizontalDirection"),i=w.useMemo(()=>Yf(n,l=>Hn(l,s?"width":"height")),[n,s]),a=or(i,!0,Te("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})},BC=({children:e})=>{const t=w.useContext(Np),n=en("windowViewportRect"),r=en("fixedItemHeight"),o=Te("customScrollParent"),s=ep(n,o,Te("skipAnimationFrameInResizeObserver")),i=Te("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})},zC=({children:e})=>{const t=Te("TopItemListComponent")||"div",n=Te("headerHeight"),r={...OC,marginTop:`${n}px`},o=Te("context");return u.jsx(t,{style:r,..._t(t,o),children:e})},HC=w.memo(function(e){const t=Te("useWindowScroll"),n=Te("topItemsIndexes").length>0,r=Te("customScrollParent"),o=Te("context");return u.jsxs(r||t?VC:WC,{...e,context:o,children:[n&&u.jsx(zC,{children:u.jsx(Mp,{showTopList:!0})}),u.jsxs(r||t?BC:FC,{children:[u.jsx(LC,{}),u.jsx(Mp,{}),u.jsx($C,{})]})]})}),{Component:UC,useEmitter:qa,useEmitterValue:Te,usePublisher:en}=Ip(AC,{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"}},HC),WC=Op({useEmitter:qa,useEmitterValue:Te,usePublisher:en}),VC=Dp({useEmitter:qa,useEmitterValue:Te,usePublisher:en}),KC=UC;ot(Ep,qe(()=>{const e=se(c=>u.jsxs("td",{children:["Item $",c]})),t=se(null),n=se(c=>u.jsxs("td",{colSpan:1e3,children:["Group ",c]})),r=se(null),o=se(null),s=se({}),i=se(Ka),a=se(Rr),l=(c,d=null)=>jt(ee(s,de(p=>p[c]),st()),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 Lp={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},qC={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:$p,floor:Ls,max:To,min:Ga,round:Fp}=Math;function Bp(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function GC(e){return{...qC,items:e}}function $s(e,t){return e&&e.width===t.width&&e.height===t.height}function YC(e,t){return e&&e.column===t.column&&e.row===t.row}const XC=qe(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:r},{footerHeight:o,headerHeight:s,scrollBy:i,scrollContainerState:a,scrollTo:l,scrollTop:c,smoothScrollTargetReached:d,viewportHeight:p},m,f,{didMount:v,propsReady:x},{customScrollParent:g,useWindowScroll:b,windowScrollContainerState:y,windowScrollTo:S,windowViewportRect:k},C])=>{const T=se(0),E=se(0),j=se(Lp),P=se({height:0,width:0}),O=se({height:0,width:0}),F=Ve(),q=Ve(),Y=se(0),R=se(null),K=se({column:0,row:0}),U=Ve(),W=Ve(),M=se(!1),I=se(0),G=se(!0),X=se(!1),_=se(!1);Xe(ee(v,Me(I),Se(([D,J])=>!!J)),()=>{Ne(G,!1)}),Xe(ee(vt(v,G,O,P,I,X),Se(([D,J,Q,ie,,Z])=>D&&!J&&Q.height!==0&&ie.height!==0&&!Z)),([,,,,D])=>{Ne(X,!0),$a(1,()=>{Ne(F,D)}),un(ee(c),()=>{Ne(t,[0,0]),Ne(G,!0)})}),ge(ee(W,Se(D=>D!=null&&D.scrollTop>0),Cn(0)),E),Xe(ee(v,Me(W),Se(([,D])=>D!=null)),([,D])=>{D&&(Ne(P,D.viewport),Ne(O,D.item),Ne(K,D.gap),D.scrollTop>0&&(Ne(M,!0),un(ee(c,rr(1)),J=>{Ne(M,!1)}),Ne(l,{top:D.scrollTop})))}),ge(ee(P,de(({height:D})=>D)),p),ge(ee(vt(ye(P,$s),ye(O,$s),ye(K,(D,J)=>D&&D.column===J.column&&D.row===J.row),ye(c)),de(([D,J,Q,ie])=>({gap:Q,item:J,scrollTop:ie,viewport:D}))),U),ge(ee(vt(ye(T),r,ye(K,YC),ye(O,$s),ye(P,$s),ye(R),ye(E),ye(M),ye(G),ye(I)),Se(([,,,,,,,D])=>!D),de(([D,[J,Q],ie,Z,ue,he,ke,,Le,$e])=>{const{column:je,row:Be}=ie,{height:ct,width:bt}=Z,{width:kt}=ue;if(ke===0&&(D===0||kt===0))return Lp;if(bt===0){const St=Fa($e,D),ht=St+Math.max(ke-1,0);return GC(Bp(St,ht,he))}const ze=zp(kt,bt,je);let Ye,Oe;Le?J===0&&Q===0&&ke>0?(Ye=0,Oe=ke-1):(Ye=ze*Ls((J+Be)/(ct+Be)),Oe=ze*$p((Q+Be)/(ct+Be))-1,Oe=Ga(D-1,To(Oe,ze-1)),Ye=Ga(Oe,To(0,Ye))):(Ye=0,Oe=-1);const De=Bp(Ye,Oe,he),{bottom:He,top:rt}=Hp(ue,ie,Z,De),lt=$p(D/ze),it=lt*ct+(lt-1)*Be-He;return{bottom:He,itemHeight:ct,items:De,itemWidth:bt,offsetBottom:it,offsetTop:rt,top:rt}})),j),ge(ee(R,Se(D=>D!==null),de(D=>D.length)),T),ge(ee(vt(P,O,j,K),Se(([D,J,{items:Q}])=>Q.length>0&&J.height!==0&&D.height!==0),de(([D,J,{items:Q},ie])=>{const{bottom:Z,top:ue}=Hp(D,ie,J,Q);return[ue,Z]}),st(xo)),t);const B=se(!1);ge(ee(c,Me(B),de(([D,J])=>J||D!==0)),B);const N=Jt(ee(vt(j,T),Se(([{items:D}])=>D.length>0),Me(B),Se(([[D,J],Q])=>{const ie=D.items[D.items.length-1].index===J-1;return(Q||D.bottom>0&&D.itemHeight>0&&D.offsetBottom===0&&D.items.length===J)&&ie}),de(([[,D]])=>D-1),st())),L=Jt(ee(ye(j),Se(({items:D})=>D.length>0&&D[0].index===0),Cn(0),st())),z=Jt(ee(ye(j),Me(M),Se(([{items:D},J])=>D.length>0&&!J),de(([{items:D}])=>({endIndex:D[D.length-1].index,startIndex:D[0].index})),st(ap),_n(0)));ge(z,f.scrollSeekRangeChanged),ge(ee(F,Me(P,O,T,K),de(([D,J,Q,ie,Z])=>{const ue=pp(D),{align:he,behavior:ke,offset:Le}=ue;let $e=ue.index;$e==="LAST"&&($e=ie-1),$e=To(0,$e,Ga(ie-1,$e));let je=Ya(J,Z,Q,$e);return he==="end"?je=Fp(je-J.height+Q.height):he==="center"&&(je=Fp(je-J.height/2+Q.height/2)),Le&&(je+=Le),{behavior:ke,top:je}})),l);const $=jt(ee(j,de(D=>D.offsetBottom+D.bottom)),0);return ge(ee(k,de(D=>({height:D.visibleHeight,width:D.visibleWidth}))),P),{customScrollParent:g,data:R,deviation:Y,footerHeight:o,gap:K,headerHeight:s,increaseViewportBy:e,initialItemCount:E,itemDimensions:O,overscan:n,restoreStateFrom:W,scrollBy:i,scrollContainerState:a,scrollHeight:q,scrollTo:l,scrollToIndex:F,scrollTop:c,smoothScrollTargetReached:d,totalCount:T,useWindowScroll:b,viewportDimensions:P,windowScrollContainerState:y,windowScrollTo:S,windowViewportRect:k,...f,gridState:j,horizontalDirection:_,initialTopMostItemIndex:I,totalListHeight:$,...m,endReached:N,propsReady:x,rangeChanged:z,startReached:L,stateChanged:U,stateRestoreInProgress:M,...C}},ot(Ba,Lt,Co,Tp,Un,Ha,zn));function zp(e,t,n){return To(1,Ls((e+n)/(Ls(t)+n)))}function Hp(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=zp(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 JC=qe(()=>{const e=se(p=>`Item ${p}`),t=se({}),n=se(null),r=se("virtuoso-grid-item"),o=se("virtuoso-grid-list"),s=se(Ka),i=se("div"),a=se(Rr),l=(p,m=null)=>jt(ee(t,de(f=>f[p]),st()),m),c=se(!1),d=se(!1);return ge(ye(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")}}),ZC=qe(([e,t])=>({...e,...t}),ot(XC,JC)),QC=w.memo(function(){const e=at("gridState"),t=at("listClassName"),n=at("itemClassName"),r=at("itemContent"),o=at("computeItemKey"),s=at("isSeeking"),i=tn("scrollHeight"),a=at("ItemComponent"),l=at("ListComponent"),c=at("ScrollSeekPlaceholder"),d=at("context"),p=tn("itemDimensions"),m=tn("gap"),f=at("log"),v=at("stateRestoreInProgress"),x=tn("reportReadyState"),g=or(w.useMemo(()=>b=>{const y=b.parentElement.parentElement.scrollHeight;i(y);const S=b.firstChild;if(S){const{height:k,width:C}=S.getBoundingClientRect();p({height:k,width:C})}m({column:Wp("column-gap",getComputedStyle(b).columnGap,f),row:Wp("row-gap",getComputedStyle(b).rowGap,f)})},[i,p,m,f]),!0,!1);return jp(()=>{e.itemHeight>0&&e.itemWidth>0&&x(!0)},[e]),v?null:u.jsx(l,{className:t,ref:g,..._t(l,d),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(b=>{const y=o(b.index,b.data,d);return s?u.jsx(c,{..._t(c,d),height:e.itemHeight,index:b.index,width:e.itemWidth},y):w.createElement(a,{..._t(a,d),className:n,"data-index":b.index,key:y},r(b.index,b.data,d))})})}),eT=w.memo(function(){const e=at("HeaderComponent"),t=tn("headerHeight"),n=at("headerFooterTag"),r=or(w.useMemo(()=>s=>{t(Hn(s,"height"))},[t]),!0,!1),o=at("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{..._t(e,o)})}):null}),tT=w.memo(function(){const e=at("FooterComponent"),t=tn("footerHeight"),n=at("headerFooterTag"),r=or(w.useMemo(()=>s=>{t(Hn(s,"height"))},[t]),!0,!1),o=at("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{..._t(e,o)})}):null}),nT=({children:e})=>{const t=w.useContext(Ap),n=tn("itemDimensions"),r=tn("viewportDimensions"),o=or(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})},rT=({children:e})=>{const t=w.useContext(Ap),n=tn("windowViewportRect"),r=tn("itemDimensions"),o=at("customScrollParent"),s=ep(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})},oT=w.memo(function({...e}){const t=at("useWindowScroll"),n=at("customScrollParent"),r=n||t?iT:sT,o=n||t?rT:nT,s=at("context");return u.jsx(r,{...e,..._t(r,s),children:u.jsxs(o,{children:[u.jsx(eT,{}),u.jsx(QC,{}),u.jsx(tT,{})]})})}),{useEmitter:Up,useEmitterValue:at,usePublisher:tn}=Ip(ZC,{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"}},oT),sT=Op({useEmitter:Up,useEmitterValue:at,usePublisher:tn}),iT=Dp({useEmitter:Up,useEmitterValue:at,usePublisher:tn});function Wp(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Ht.WARN),t==="normal"?0:parseInt(t??"0",10)}var Fs="Dialog",[Vp,zN]=an(Fs),[aT,fn]=Vp(Fs),Kp=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:i=!0}=e,a=h.useRef(null),l=h.useRef(null),[c,d]=On({prop:r,defaultProp:o??!1,onChange:s,caller:Fs});return u.jsx(aT,{scope:t,triggerRef:a,contentRef:l,contentId:At(),titleId:At(),descriptionId:At(),open:c,onOpenChange:d,onOpenToggle:h.useCallback(()=>d(p=>!p),[d]),modal:i,children:n})};Kp.displayName=Fs;var qp="DialogTrigger",Gp=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=fn(qp,n),s=Re(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)})});Gp.displayName=qp;var Xa="DialogPortal",[lT,Yp]=Vp(Xa,{forceMount:void 0}),Xp=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=fn(Xa,t);return u.jsx(lT,{scope:t,forceMount:n,children:h.Children.map(r,i=>u.jsx(zt,{present:n||s.open,children:u.jsx(io,{asChild:!0,container:o,children:i})}))})};Xp.displayName=Xa;var Bs="DialogOverlay",Jp=h.forwardRef((e,t)=>{const n=Yp(Bs,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=fn(Bs,e.__scopeDialog);return s.modal?u.jsx(zt,{present:r||s.open,children:u.jsx(uT,{...o,ref:t})}):null});Jp.displayName=Bs;var cT=Kt.createSlot("DialogOverlay.RemoveScroll"),uT=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=fn(Bs,n);return u.jsx(vs,{as:cT,allowPinchZoom:!0,shards:[o.contentRef],children:u.jsx(me.div,{"data-state":Za(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),ar="DialogContent",Zp=h.forwardRef((e,t)=>{const n=Yp(ar,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=fn(ar,e.__scopeDialog);return u.jsx(zt,{present:r||s.open,children:s.modal?u.jsx(dT,{...o,ref:t}):u.jsx(fT,{...o,ref:t})})});Zp.displayName=ar;var dT=h.forwardRef((e,t)=>{const n=fn(ar,e.__scopeDialog),r=h.useRef(null),o=Re(t,n.contentRef,r);return h.useEffect(()=>{const s=r.current;if(s)return pa(s)},[]),u.jsx(Qp,{...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())})}),fT=h.forwardRef((e,t)=>{const n=fn(ar,e.__scopeDialog),r=h.useRef(!1),o=h.useRef(!1);return u.jsx(Qp,{...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()}})}),Qp=h.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=fn(ar,n),l=h.useRef(null),c=Re(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(pT,{titleId:a.titleId}),u.jsx(mT,{contentRef:l,descriptionId:a.descriptionId})]})]})}),Ja="DialogTitle",eh=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=fn(Ja,n);return u.jsx(me.h2,{id:o.titleId,...r,ref:t})});eh.displayName=Ja;var th="DialogDescription",nh=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=fn(th,n);return u.jsx(me.p,{id:o.descriptionId,...r,ref:t})});nh.displayName=th;var rh="DialogClose",oh=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=fn(rh,n);return u.jsx(me.button,{type:"button",...r,ref:t,onClick:ae(e.onClick,()=>o.onOpenChange(!1))})});oh.displayName=rh;function Za(e){return e?"open":"closed"}var sh="DialogTitleWarning",[HN,ih]=Ab(sh,{contentName:ar,titleName:Ja,docsSlug:"dialog"}),pT=({titleId:e})=>{const t=ih(sh),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 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.
80
80
 
81
81
  If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
82
82
 
83
- For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return h.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},hT="DialogDescriptionWarning",mT=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${ih(hT).contentName}}.`;return h.useEffect(()=>{var s;const o=(s=e.current)==null?void 0:s.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},Qa=Kp,gT=Gp,el=Xp,ko=Jp,Eo=Zp,lr=eh,zs=nh,ah=oh;const tl=Qa,xT=el,lh=h.forwardRef(({className:e,...t},n)=>u.jsx(ko,{ref:n,className:ne("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));lh.displayName=ko.displayName;const Hs=h.forwardRef(({className:e,children:t,...n},r)=>{const o=h.useMemo(()=>{let s=!1;function i(a){h.Children.forEach(a,l=>{if(s||!h.isValidElement(l))return;const c=l.type;if(c===lr||(c==null?void 0:c.displayName)===lr.displayName||(c==null?void 0:c.name)==="DialogTitle"){s=!0;return}l.props&&l.props.children&&i(l.props.children)})}return i(t),s},[t]);return u.jsxs(xT,{children:[u.jsx(lh,{}),u.jsxs(Eo,{ref:r,className:ne("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...n,children:[!o&&u.jsx(lr,{className:"sr-only",children:"Dialog"}),t,u.jsxs(ah,{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:ne("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});Us.displayName="DialogHeader";const Ws=h.forwardRef(({className:e,...t},n)=>u.jsx(lr,{ref:n,className:ne("text-lg font-semibold leading-none tracking-tight",e),...t}));Ws.displayName=lr.displayName;const vT=h.forwardRef(({className:e,...t},n)=>u.jsx(zs,{ref:n,className:ne("text-sm text-muted-foreground",e),...t}));vT.displayName=zs.displayName;const bT=1,wT=1e6;let nl=0;function yT(){return nl=(nl+1)%Number.MAX_SAFE_INTEGER,nl.toString()}const rl=new Map,ch=e=>{if(rl.has(e))return;const t=setTimeout(()=>{rl.delete(e),Io({type:"REMOVE_TOAST",toastId:e})},wT);rl.set(e,t)},ST=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,bT)};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?ch(n):e.toasts.forEach(r=>{ch(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=ST(Ks,e),Vs.forEach(t=>{t(Ks)})}function CT({...e}){const t=yT(),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]=h.useState(Ks);return h.useEffect(()=>(Vs.push(t),()=>{const n=Vs.indexOf(t);n>-1&&Vs.splice(n,1)}),[e]),{...e,toast:CT,dismiss:n=>Io({type:"DISMISS_TOAST",toastId:n})}}function uh({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:p}=ol(),m=w.useCallback(async()=>{if(n){i(!0),d(null),l(null);try{const b=await Mi(n);l(b)}catch(b){console.error("Failed to load file:",b),d(b instanceof Error?b.message:"Failed to load file")}finally{i(!1)}}},[n]);w.useEffect(()=>{e&&n&&m()},[e,n,m]);const f=async()=>{if(n)try{await tu(n),p({title:"Download started",description:`Downloading ${r}`})}catch(b){console.error("Failed to download file:",b),p({title:"Download failed",description:String(b),variant:"destructive"})}},v=async()=>{if(n)try{const b=await Mi(n),y=new Blob([b],{type:o}),S=URL.createObjectURL(y);window.open(S,"_blank"),URL.revokeObjectURL(S)}catch(b){console.error("Failed to open file externally:",b),p({title:"Failed to open file",description:String(b),variant:"destructive"})}},x=()=>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(Ze,{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"})}),g=()=>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:[g(),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(Ze,{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(Ze,{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:x()})]})})}function dh(){return{async:!1,baseUrl:null,breaks:!1,extensions:null,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,hooks:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:null,sanitize:!1,sanitizer:null,silent:!1,smartypants:!1,tokenizer:null,walkTokens:null,xhtml:!1}}let cr=dh();function TT(e){cr=e}const fh=/[&<>"']/,kT=new RegExp(fh.source,"g"),ph=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,ET=new RegExp(ph.source,"g"),IT={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},hh=e=>IT[e];function Pt(e,t){if(t){if(fh.test(e))return e.replace(kT,hh)}else if(ph.test(e))return e.replace(ET,hh);return e}const NT=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function mh(e){return e.replace(NT,(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 AT=/(^|[^\[])\^/g;function tt(e,t){e=typeof e=="string"?e:e.source,t=t||"";const n={replace:(r,o)=>(o=o.source||o,o=o.replace(AT,"$1"),e=e.replace(r,o),n),getRegex:()=>new RegExp(e,t)};return n}const jT=/[^\w:]/g,_T=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function gh(e,t,n){if(e){let r;try{r=decodeURIComponent(mh(n)).replace(jT,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}t&&!_T.test(n)&&(n=OT(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const qs={},PT=/^[^:]+:\/*[^/]*$/,RT=/^([^:]+:)[\s\S]*$/,MT=/^([^:]+:\/*[^/]*)[\s\S]*$/;function OT(e,t){qs[" "+e]||(PT.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(RT,"$1")+t:t.charAt(0)==="/"?n?t:e.replace(MT,"$1")+t:e+t}const Gs={exec:function(){}};function xh(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 DT(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 LT(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 vh(e,t){if(t<1)return"";let n="";for(;t>1;)t&1&&(n+=e),t>>=1,e+=e;return n+e}function bh(e,t,n,r){const o=t.href,s=t.title?Pt(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:Pt(i)}}function $T(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(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(`
84
84
  `).map(o=>{const s=o.match(/^\s+/);if(s===null)return o;const[i]=s;return i.length>=r.length?o.slice(r.length):o}).join(`
85
- `)}class sl{constructor(t){this.options=t||cr}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
- `)}}}fences(t){const n=this.rules.block.fences.exec(t);if(n){const r=n[0],o=$T(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,p,m,f,v,x=n[1].trim();const g=x.length>1,b={type:"list",raw:"",ordered:g,start:g?+x.slice(0,-1):"",loose:!1,items:[]};x=g?`\\d{1,9}\\${x.slice(-1)}`:`\\${x}`,this.options.pedantic&&(x=g?x:"[*+-]");const y=new RegExp(`^( {0,3}${x})((?:[ ][^\\n]*)?(?:\\n|$))`);for(;t&&(v=!1,!(!(n=y.exec(t))||this.rules.block.hr.test(t)));){if(r=n[0],t=t.substring(r.length),d=n[2].split(`
87
- `,1)[0].replace(/^\t+/,k=>" ".repeat(3*k.length)),p=t.split(`
88
- `,1)[0],this.options.pedantic?(i=2,f=d.trimLeft()):(i=n[2].search(/[^ ]/),i=i>4?1:i,f=d.slice(i),i+=n[1].length),l=!1,!d&&/^ *$/.test(p)&&(r+=p+`
89
- `,t=t.substring(p.length+1),v=!0),!v){const k=new RegExp(`^ {0,${Math.min(3,i-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),C=new RegExp(`^ {0,${Math.min(3,i-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),T=new RegExp(`^ {0,${Math.min(3,i-1)}}(?:\`\`\`|~~~)`),E=new RegExp(`^ {0,${Math.min(3,i-1)}}#`);for(;t&&(m=t.split(`
90
- `,1)[0],p=m,this.options.pedantic&&(p=p.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),!(T.test(p)||E.test(p)||k.test(p)||C.test(t)));){if(p.search(/[^ ]/)>=i||!p.trim())f+=`
91
- `+p.slice(i);else{if(l||d.search(/[^ ]/)>=4||T.test(d)||E.test(d)||C.test(d))break;f+=`
92
- `+p}!l&&!p.trim()&&(l=!0),r+=m+`
93
- `,t=t.substring(m.length+1),d=p.slice(i)}}b.loose||(c?b.loose=!0:/\n *\n *$/.test(r)&&(c=!0)),this.options.gfm&&(o=/^\[[ xX]\] /.exec(f),o&&(s=o[0]!=="[ ] ",f=f.replace(/^\[[ xX]\] +/,""))),b.items.push({type:"list_item",raw:r,task:!!o,checked:s,loose:!1,text:f}),b.raw+=r}b.items[b.items.length-1].raw=r.trimRight(),b.items[b.items.length-1].text=f.trimRight(),b.raw=b.raw.trimRight();const S=b.items.length;for(a=0;a<S;a++)if(this.lexer.state.top=!1,b.items[a].tokens=this.lexer.blockTokens(b.items[a].text,[]),!b.loose){const k=b.items[a].tokens.filter(T=>T.type==="space"),C=k.length>0&&k.some(T=>/\n.*\n/.test(T.raw));b.loose=C}if(b.loose)for(a=0;a<S;a++)b.items[a].loose=!0;return b}}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]):Pt(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:xh(n[1]).map(o=>({text:o})),align:n[2].replace(/^ *|\| *$/g,"").split(/ *\| */),rows:n[3]&&n[3].trim()?n[3].replace(/\n[ \t]*$/,"").split(`
94
- `):[]};if(r.header.length===r.align.length){r.raw=n[0];let o=r.align.length,s,i,a,l;for(s=0;s<o;s++)/^ *-+: *$/.test(r.align[s])?r.align[s]="right":/^ *:-+: *$/.test(r.align[s])?r.align[s]="center":/^ *:-+ *$/.test(r.align[s])?r.align[s]="left":r.align[s]=null;for(o=r.rows.length,s=0;s<o;s++)r.rows[s]=xh(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:Pt(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]):Pt(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=DT(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)),bh(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 bh(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 p=o[0][0]==="*"?this.rules.inline.emStrong.rDelimAst:this.rules.inline.emStrong.rDelimUnd;for(p.lastIndex=0,n=n.slice(-1*t.length+i);(o=p.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=Pt(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=Pt(this.options.mangle?n(r[1]):r[1]),s="mailto:"+o):(o=Pt(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=Pt(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=Pt(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]):Pt(r[0]):r[0]:o=Pt(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=tt(be.def).replace("label",be._label).replace("title",be._title).getRegex(),be.bullet=/(?:[*+-]|\d{1,9}[.)])/,be.listItemStart=tt(/^( *)(bull) */).replace("bull",be.bullet).getRegex(),be.list=tt(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=tt(be.html,"i").replace("comment",be._comment).replace("tag",be._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),be.paragraph=tt(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=tt(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=tt(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=tt(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:tt(`^ *(?: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:tt(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 fe={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])/};fe._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",fe.punctuation=tt(fe.punctuation).replace(/punctuation/g,fe._punctuation).getRegex(),fe.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g,fe.escapedEmSt=/(?:^|[^\\])(?:\\\\)*\\[*_]/g,fe._comment=tt(be._comment).replace("(?:-->|$)","-->").getRegex(),fe.emStrong.lDelim=tt(fe.emStrong.lDelim).replace(/punct/g,fe._punctuation).getRegex(),fe.emStrong.rDelimAst=tt(fe.emStrong.rDelimAst,"g").replace(/punct/g,fe._punctuation).getRegex(),fe.emStrong.rDelimUnd=tt(fe.emStrong.rDelimUnd,"g").replace(/punct/g,fe._punctuation).getRegex(),fe._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,fe._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,fe._email=/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/,fe.autolink=tt(fe.autolink).replace("scheme",fe._scheme).replace("email",fe._email).getRegex(),fe._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,fe.tag=tt(fe.tag).replace("comment",fe._comment).replace("attribute",fe._attribute).getRegex(),fe._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,fe._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/,fe._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,fe.link=tt(fe.link).replace("label",fe._label).replace("href",fe._href).replace("title",fe._title).getRegex(),fe.reflink=tt(fe.reflink).replace("label",fe._label).replace("ref",be._label).getRegex(),fe.nolink=tt(fe.nolink).replace("ref",be._label).getRegex(),fe.reflinkSearch=tt(fe.reflinkSearch,"g").replace("reflink",fe.reflink).replace("nolink",fe.nolink).getRegex(),fe.normal={...fe},fe.pedantic={...fe.normal,strong:{start:/^__|\*\*/,middle:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,endAst:/\*\*(?!\*)/g,endUnd:/__(?!_)/g},em:{start:/^_|\*/,middle:/^()\*(?=\S)([\s\S]*?\S)\*(?!\*)|^_(?=\S)([\s\S]*?\S)_(?!_)/,endAst:/\*(?!\*)/g,endUnd:/_(?!_)/g},link:tt(/^!?\[(label)\]\((.*?)\)/).replace("label",fe._label).getRegex(),reflink:tt(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",fe._label).getRegex()},fe.gfm={...fe.normal,escape:tt(fe.escape).replace("])","~|])").getRegex(),_extended_email:/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,url:/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},fe.gfm.url=tt(fe.gfm.url,"i").replace("email",fe.gfm._extended_email).getRegex(),fe.breaks={...fe.gfm,br:tt(fe.br).replace("{2,}","*").getRegex(),text:tt(fe.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()};function FT(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 wh(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||cr,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:fe.normal};this.options.pedantic?(n.block=be.pedantic,n.inline=fe.pedantic):this.options.gfm&&(n.block=be.gfm,this.options.breaks?n.inline=fe.breaks:n.inline=fe.gfm),this.tokenizer.rules=n}static get rules(){return{block:be,inline:fe}}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,`
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
+ `)}}}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(`
87
+ `,1)[0].replace(/^\t+/,k=>" ".repeat(3*k.length)),h=t.split(`
88
+ `,1)[0],this.options.pedantic?(i=2,f=d.trimLeft()):(i=n[2].search(/[^ ]/),i=i>4?1:i,f=d.slice(i),i+=n[1].length),l=!1,!d&&/^ *$/.test(h)&&(r+=h+`
89
+ `,t=t.substring(h.length+1),v=!0),!v){const k=new RegExp(`^ {0,${Math.min(3,i-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),S=new RegExp(`^ {0,${Math.min(3,i-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),T=new RegExp(`^ {0,${Math.min(3,i-1)}}(?:\`\`\`|~~~)`),E=new RegExp(`^ {0,${Math.min(3,i-1)}}#`);for(;t&&(m=t.split(`
90
+ `,1)[0],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
+ `+h.slice(i);else{if(l||d.search(/[^ ]/)>=4||T.test(d)||E.test(d)||S.test(d))break;f+=`
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(`
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,`
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+=`
@@ -103,9 +103,9 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
103
103
  `+r.raw,o.text+=`
104
104
  `+r.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=o.text):n.push(r),i=s.length!==t.length,t=t.substring(r.raw.length);continue}if(r=this.tokenizer.text(t)){t=t.substring(r.raw.length),o=n[n.length-1],o&&o.type==="text"?(o.raw+=`
105
105
  `+r.raw,o.text+=`
106
- `+r.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=o.text):n.push(r);continue}if(t){const a="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(a);break}else throw new Error(a)}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}inlineTokens(t,n=[]){let r,o,s,i=t,a,l,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)+"["+vh("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)+"["+vh("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,wh)){t=t.substring(r.raw.length),n.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(t,wh))){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 p=t.slice(1);let m;this.options.extensions.startInline.forEach(function(f){m=f.call({lexer:this},p),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,FT)){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||cr}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+Pt(o)+'">'+(r?t:Pt(t,!0))+`</code></pre>
108
- `:"<pre><code>"+(r?t:Pt(t,!0))+`</code></pre>
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>
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}>
@@ -123,9 +123,9 @@ ${t}</blockquote>
123
123
  `}tablerow(t){return`<tr>
124
124
  ${t}</tr>
125
125
  `}tablecell(t,n){const r=n.header?"th":"td";return(n.align?`<${r} align="${n.align}">`:`<${r}>`)+t+`</${r}>
126
- `}strong(t){return`<strong>${t}</strong>`}em(t){return`<em>${t}</em>`}codespan(t){return`<code>${t}</code>`}br(){return this.options.xhtml?"<br/>":"<br>"}del(t){return`<del>${t}</del>`}link(t,n,r){if(t=gh(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=gh(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 yh{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 Sh{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||cr,this.options.renderer=this.options.renderer||new il,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new yh,this.slugger=new Sh}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,p,m,f,v,x,g,b,y,S,k,C,T;const E=t.length;for(o=0;o<E;o++){if(f=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[f.type]&&(T=this.options.extensions.renderers[f.type].call({parser:this},f),T!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(f.type))){r+=T||"";continue}switch(f.type){case"space":continue;case"hr":{r+=this.renderer.hr();continue}case"heading":{r+=this.renderer.heading(this.parseInline(f.tokens),f.depth,mh(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(p="",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(p+=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(p,m);continue}case"blockquote":{m=this.parse(f.tokens),r+=this.renderer.blockquote(m);continue}case"list":{for(v=f.ordered,x=f.start,g=f.loose,a=f.items.length,m="",s=0;s<a;s++)y=f.items[s],S=y.checked,k=y.task,b="",y.task&&(C=this.renderer.checkbox(S),g?y.tokens.length>0&&y.tokens[0].type==="paragraph"?(y.tokens[0].text=C+" "+y.tokens[0].text,y.tokens[0].tokens&&y.tokens[0].tokens.length>0&&y.tokens[0].tokens[0].type==="text"&&(y.tokens[0].tokens[0].text=C+" "+y.tokens[0].tokens[0].text)):y.tokens.unshift({type:"text",text:C}):b+=C),b+=this.parse(y.tokens,g),m+=this.renderer.listitem(b,k,S);r+=this.renderer.list(m,v,x);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 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||cr}preprocess(t){return t}postprocess(t){return t}}ix(Xs,"passThroughHooks",new Set(["preprocess","postprocess"]));function BT(e,t,n){return r=>{if(r.message+=`
128
- Please report this to https://github.com/markedjs/marked.`,e){const o="<p>An error occurred:</p><pre>"+Pt(r.message+"",!0)+"</pre>";if(t)return Promise.resolve(o);if(n){n(null,o);return}return o}if(t)return Promise.reject(r);if(n){n(r);return}throw r}}function Ch(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...xe.defaults,...s};const i=BT(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(LT(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(p){return i(p)}const c=function(p){let m;if(!p)try{r.walkTokens&&xe.walkTokens(l,r.walkTokens),m=t(l,r),r.hooks&&(m=r.hooks.postprocess(m))}catch(f){p=f}return r.highlight=a,p?i(p):o(null,m)};if(!a||a.length<3||(delete r.highlight,!l.length))return c();let d=0;xe.walkTokens(l,function(p){p.type==="code"&&(d++,setTimeout(()=>{a(p.text,p.lang,function(m,f){if(m)return c(m);f!=null&&f!==p.text&&(p.text=f,p.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(xe.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&&xe.walkTokens(a,r.walkTokens);let l=t(a,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(a){return i(a)}}}function xe(e,t,n){return Ch(Wn.lex,Vn.parse)(e,t,n)}xe.options=xe.setOptions=function(e){return xe.defaults={...xe.defaults,...e},TT(xe.defaults),xe},xe.getDefaults=dh,xe.defaults=cr,xe.use=function(...e){const t=xe.defaults.extensions||{renderers:{},childTokens:{}};e.forEach(n=>{const r={...n};if(r.async=xe.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=xe.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=xe.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=xe.defaults.hooks||new Xs;for(const s in n.hooks){const i=o[s];Xs.passThroughHooks.has(s)?o[s]=a=>{if(xe.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=xe.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}}xe.setOptions(r)})},xe.walkTokens=function(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(xe,r)),r.type){case"table":{for(const o of r.header)n=n.concat(xe.walkTokens(o.tokens,t));for(const o of r.rows)for(const s of o)n=n.concat(xe.walkTokens(s.tokens,t));break}case"list":{n=n.concat(xe.walkTokens(r.items,t));break}default:xe.defaults.extensions&&xe.defaults.extensions.childTokens&&xe.defaults.extensions.childTokens[r.type]?xe.defaults.extensions.childTokens[r.type].forEach(function(o){n=n.concat(xe.walkTokens(r[o],t))}):r.tokens&&(n=n.concat(xe.walkTokens(r.tokens,t)))}return n},xe.parseInline=Ch(Wn.lexInline,Vn.parseInline),xe.Parser=Vn,xe.parser=Vn.parse,xe.Renderer=il,xe.TextRenderer=yh,xe.Lexer=Wn,xe.lexer=Wn.lex,xe.Tokenizer=sl,xe.Slugger=Sh,xe.Hooks=Xs,xe.parse=xe,xe.options,xe.setOptions,xe.use,xe.walkTokens,xe.parseInline,Vn.parse,Wn.lex;function Kn({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 xe.parse=="function"?xe.parse(i):xe(i)}return typeof xe.parse=="function"?xe.parse(e):xe(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:ne("markdown prose prose-sm max-w-none break-words","dark:prose-invert","text-current","prose-headings:text-current prose-p:text-current prose-li:text-current prose-a:text-current prose-strong:text-current","prose-em:text-current prose-blockquote:text-current prose-table:text-current prose-td:text-current prose-th:text-current","prose-pre:font-mono prose-pre:text-xs prose-pre:bg-background/50 prose-pre:border prose-pre:rounded prose-pre:p-3 prose-pre:whitespace-pre prose-pre:overflow-x-auto","prose-code:font-mono prose-code:text-sm prose-code:bg-background/50 prose-code:px-1.5 prose-code:py-0.5 prose-code:rounded prose-code:text-current",t),style:s,dangerouslySetInnerHTML:{__html:o}})}function Th({preview:e,idx:t}){return u.jsxs("div",{className:"space-y-2",children:[e.label&&u.jsxs("p",{className:"text-[0.65rem] uppercase tracking-wide text-muted-foreground",children:["Artifact: ",e.label]}),u.jsx("div",{className:"overflow-hidden rounded border border-border/60 bg-background/60 p-1 shadow-sm",children:u.jsx("img",{src:e.src,alt:e.alt,title:e.label,loading:"lazy",className:"h-auto max-h-[420px] w-full rounded object-contain",onLoad:()=>{},onError:n=>{console.error(`[MessageComponent] ❌ Image failed to load for artifact ${t}:`,{alt:e.alt,label:e.label,message:n.target.alt})}})})]})}const kh={completed:{label:"Completed",badgeClass:"border border-green-200 bg-green-50 text-green-700"},success:{label:"Completed",badgeClass:"border border-green-200 bg-green-50 text-green-700"},failed:{label:"Failed",badgeClass:"border border-red-200 bg-red-50 text-red-700"},error:{label:"Failed",badgeClass:"border border-red-200 bg-red-50 text-red-700"},cancelled:{label:"Cancelled",badgeClass:"border border-orange-200 bg-orange-50 text-orange-700"},cancel:{label:"Cancelled",badgeClass:"border border-orange-200 bg-orange-50 text-orange-700"},pending:{label:"Pending",badgeClass:"border border-blue-200 bg-blue-50 text-blue-700"},processing:{label:"Processing",badgeClass:"border border-yellow-200 bg-yellow-50 text-yellow-700"}},zT=e=>{if(!e)return kh.processing;const t=e.toLowerCase().trim();return kh[t]??{label:t.replace(/(^\w|\s\w)/g,n=>n.toUpperCase()),badgeClass:"border border-slate-200 bg-slate-50 text-slate-800"}},HT=e=>e?e.length>10?`${e.slice(0,8)}…`:e:"";function Eh({artifact:e}){const t=zT(e.status),n=e.task_url??e.taskUrl??"";return u.jsxs("div",{className:"rounded-lg border border-blue-200/70 bg-blue-50/40 p-4 space-y-3",children:[u.jsxs("div",{className:"flex items-start justify-between gap-3",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsx("div",{className:"flex h-7 w-7 items-center justify-center rounded-full bg-blue-600/10 text-blue-600",children:u.jsx(le.Search,{className:"h-4 w-4"})}),u.jsxs("div",{className:"space-y-1",children:[u.jsx("p",{className:"text-xs font-semibold uppercase tracking-wide text-blue-700",children:"Research Task"}),u.jsxs("p",{className:"text-[11px] text-blue-900/80",children:["Task ID: ",u.jsx("span",{className:"font-mono",children:HT(e.task_id)})]})]})]}),t&&u.jsx("span",{className:`inline-flex items-center rounded-full px-3 py-1 text-[11px] font-semibold ${t.badgeClass}`,children:t.label})]}),e.query&&u.jsxs("div",{className:"rounded border border-blue-100 bg-white/80 px-3 py-2 text-xs text-blue-900/90",children:[u.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wide text-blue-500",children:"Query"}),u.jsx("p",{className:"line-clamp-2 text-[11px] text-blue-900",children:e.query})]}),typeof e.results=="string"&&e.results.trim()&&u.jsxs("div",{className:"rounded border border-blue-100 bg-white/80 px-3 py-2 text-sm text-blue-900/90 space-y-1",children:[u.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wide text-blue-500",children:"Results"}),u.jsx(Kn,{content:e.results,allowHtml:!1,className:"prose text-xs !prose-sm prose-blue dark:prose-invert"})]}),u.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[n?u.jsxs("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 rounded-full border border-blue-600/80 bg-blue-600/10 px-3 py-1 text-xs font-semibold text-blue-700 transition hover:bg-blue-600/20",children:[u.jsx("span",{children:"Go to task"}),u.jsx(le.ExternalLink,{className:"h-3 w-3"})]}):u.jsx("span",{className:"text-xs text-muted-foreground",children:"Task link unavailable"}),e.createdAt&&u.jsxs("p",{className:"text-[10px] text-blue-700/70",children:["Started: ",new Date(e.createdAt).toLocaleTimeString()]})]})]})}function Ih({artifact:e,idx:t=0}){const n=w.useMemo(()=>e?(Array.isArray(e.plots)?e.plots:[]).map(o=>ub(o)).filter(o=>o!==null):[],[e]);return(e==null?void 0:e.type)==="research_task_info"?u.jsx(Eh,{artifact:{type:"research_task_info",task_id:e.task_id,task_url:e.task_url,query:e.query,status:e.status,createdAt:e.createdAt}}):n.length>0?u.jsx("div",{className:"space-y-2",children:n.map((r,o)=>u.jsx(Th,{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 al=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:ne("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));al.displayName="Card";const ll=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:ne("flex flex-col space-y-1.5 p-6",e),...t}));ll.displayName="CardHeader";const cl=h.forwardRef(({className:e,...t},n)=>u.jsx("h3",{ref:n,className:ne("text-2xl font-semibold leading-none tracking-tight",e),...t}));cl.displayName="CardTitle";const ul=h.forwardRef(({className:e,...t},n)=>u.jsx("p",{ref:n,className:ne("text-sm text-muted-foreground",e),...t}));ul.displayName="CardDescription";const dl=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:ne("p-6 pt-0",e),...t}));dl.displayName="CardContent";const Nh=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:ne("flex items-center p-6 pt-0",e),...t}));Nh.displayName="CardFooter";function Ah({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:ne("border-blue-200 dark:border-blue-800 bg-blue-50/50 dark:bg-blue-950/10 transition-shadow",o?"shadow-md ring-1 ring-blue-300 dark:ring-blue-500/70":"opacity-80"),children:[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(Nh,{className:"pt-0",children:u.jsxs("div",{className:"flex gap-2 ml-auto",children:[u.jsx(Ze,{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(Ze,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",disabled:r||!o,children:"Approve"})]})})]})}const UT="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:UT,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 jh({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}function _h({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:ne("inline-block text-xs opacity-70 ml-1",e),children:["Is thinking",".".repeat(t)]})}function Ph({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:ne("text-sm text-[hsl(var(--chat-bubble-user-text))]",o&&"text-xs"),children:t?u.jsx(Kn,{content:e,allowHtml:!1}):u.jsxs("pre",{className:ne("font-sans whitespace-pre-wrap break-words bg-transparent p-0 m-0 text-[hsl(var(--chat-bubble-user-text))]",o&&"text-xs"),children:[i,"..."]})}),u.jsx(Ze,{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)"]})})]})}const Rh={desirability:"from-[#ffd6e6] to-[#ffb7cf]",feasibility:"from-[#fff6ca] to-[#ffe58f]",viability:"from-[#d5f2cf] to-[#b3e7b4]",other:"from-[#dfe7ff] to-[#c4d6ff]"};function fl(e){return(e.type??"other").toLowerCase()}function WT({issues:e}){if(!e.length)return null;const t=w.useMemo(()=>{const n={};return e.forEach(r=>{const o=fl(r).toUpperCase();n[o]||(n[o]=[]),n[o].push(r)}),n},[e]);return u.jsxs("div",{className:"rounded-3xl border border-muted-foreground/30 bg-background/80 p-4 shadow-lg shadow-slate-900/5",children:[u.jsxs("div",{className:"flex items-center justify-between border-b border-muted-foreground/20 pb-2",children:[u.jsx("div",{className:"text-xs font-semibold uppercase tracking-[0.4em] text-muted-foreground",children:"Issue Sticky Notes"}),u.jsxs("div",{className:"text-xs font-semibold text-muted-foreground",children:[e.length," total"]})]}),u.jsx("div",{className:"mt-4 flex w-full flex-col gap-6",children:Object.entries(t).map(([n,r])=>u.jsxs("details",{className:"w-full rounded-2xl border border-muted-foreground/30 bg-white/80 p-4 shadow-sm shadow-slate-900/10",children:[u.jsxs("summary",{className:"cursor-pointer text-[11px] font-semibold uppercase tracking-[0.4em] text-muted-foreground",children:[n," (",r.length,")"]}),u.jsx("div",{className:"mt-3 space-y-3",children:r.map((o,s)=>{const i=o.title||o.name||`Issue ${s+1}`,a=Rh[fl(o)]?fl(o):"other";return u.jsxs("div",{className:`relative overflow-hidden rounded-2xl border border-muted-foreground/30 bg-gradient-to-br p-4 text-sm font-medium text-foreground/90 shadow-[0_20px_30px_rgba(15,23,42,0.15)] ${Rh[a]}`,children:[u.jsx("div",{className:"text-base font-semibold text-foreground",children:i}),o.description?u.jsxs("details",{className:"mt-2 rounded-xl border border-border/40 bg-background/60 p-2 text-[12px] text-foreground/80",children:[u.jsx("summary",{className:"cursor-pointer font-semibold uppercase tracking-[0.3em] text-foreground/80",children:"View description"}),u.jsx("p",{className:"mt-2 text-xs leading-5 text-foreground/80",children:o.description})]}):null]},o.id??`${n}-${s}`)})})]},n))})]})}function Mh(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)},[]),p=w.useCallback(f=>{a(f),c(!0)},[]),m=w.useCallback(async(f,v,x)=>{var g,b;if(!t){f.preventDefault();return}if(o[x]){f.preventDefault();return}try{const y=String(v.url??""),S=y.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);if(S){f.preventDefault();const k=S[1],C=v.name||`file_${k}`,T=v.mimeType||"application/octet-stream";p({id:k,name:C,mimeType:T});return}if(y.startsWith("data:")){f.preventDefault(),s(C=>({...C,[x]:!0}));const k=r({title:"Fetching file...",description:"",open:!0});try{const C=await nu(n??void 0);if(!C||!Array.isArray(C))throw new Error("Invalid file list response");const T=C.find(E=>!E||typeof E!="object"||!((E.filename??"")===(v.name??""))?!1:typeof v.size=="number"&&typeof E.size=="number"?E.size===v.size:!0);if(!(T!=null&&T.id))throw new Error(`File "${v.name}" is not yet available on the server`);if(!T.id||!T.filename)throw new Error("Invalid file data received from server");p({id:T.id,name:v.name||T.filename||`file_${T.id}`,mimeType:v.mimeType||T.mime_type||"application/octet-stream"}),(g=k.update)==null||g.call(k,{id:k.id,title:"Success",description:`Opened ${v.name}`,open:!0})}catch(C){console.error("Failed to fetch server file:",C);const T=C instanceof Error?C.message:"Unknown error occurred";(b=k.update)==null||b.call(k,{id:k.id,title:"Failed",description:T}),r({title:"Failed to fetch file",description:T,open:!0})}finally{s(C=>({...C,[x]:!1}))}}}catch(y){console.error("File click error:",y),s(S=>({...S,[x]:!1}))}},[t,o,r,n,p]);return{uploadingFiles:o,handleFileClick:m,fileViewerOpen:l,currentFileInfo:i,closeFileViewer:d}}function Oh(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:ob(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:sb(r),isToolStreaming:!!o.toolStreaming}},[e,t])}const Dh="data:";function VT(e){if(!e)return[];const t=[],n=e.split(/\r?\n/);for(const r of n){const o=r.trim();if(!o||!o.startsWith(Dh))continue;const s=o.slice(Dh.length).trim();if(!s||s.toLowerCase()==="[done]")continue;const i=Qr(s);i&&typeof i=="object"&&t.push(i)}return t}function KT(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 qT(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 GT(e){return w.useMemo(()=>{const t=e.content.filter(c=>c.type==="text");if(!t.length)return null;let r=t.flatMap(c=>VT(c.text??""));if(!r.length){const c=t.map(p=>p.text??"").join(`
129
- `),d=Qr(c);d&&typeof d=="object"&&(r=[d])}if(!r.length)return null;const s=qT(r)??r[r.length-1];if(!s)return null;const i=s.output??s.payload??s,a=br(i),l=KT(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 Lh({message:e,viewMode:t,isStreaming:n=!1,toolRenderers:r}){const o=Di(e),s=e.artifact??null,i=GT(e),a=e.content.find(g=>g.type!=="tool_call"),l=g=>{if(g==null)return null;const b=typeof g=="string"?Qr(g)??g:g;if(b&&typeof b=="object")return u.jsx(Js,{data:b});const y=typeof b=="string"?b:(()=>{try{return vr(b)}catch{return String(b??"")}})();return u.jsx("pre",{className:"whitespace-pre-wrap break-words font-sans text-sm text-foreground/90",children:y})},c=g=>{if(g==null)return null;const{content:b,isMarkdown:y}=rb(g);return y?u.jsx(Kn,{content:b,className:"text-current"}):l(g)},d=g=>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:g})]}),p=()=>{if((i==null?void 0:i.kind)==="generic")return c(i.value);if(!a)return null;if(a.type==="text"){const S=(a.text??"").trim();if(!S)return null;const k=br(S);return c(k)}const g=eo(a),b=br(g);return c(b)},m=()=>{const g=(i==null?void 0:i.kind)==="issues"?i.issues:void 0,b=(i==null?void 0:i.kind)==="dict"?i.data:void 0,y=b&&Array.isArray(b.issues)?b.issues:void 0,S=g??y;return S&&S.length>0?u.jsx(WT,{issues:S}):(i==null?void 0:i.kind)==="dict"?d(i.data):p()},v=(()=>{if(r){if(o.name){const g=r[o.name];if(g)return g}if(i!=null&&i.kind){const g=r[i.kind];if(g)return g}return r.default}})(),x=(v==null?void 0:v({message:e,toolMeta:o,toolPayload:i,viewMode:t,isStreaming:n}))??null;return u.jsxs("div",{className:"space-y-2",children:[s&&u.jsx(Ih,{artifact:s,idx:0}),u.jsx(jh,{message:e,isStreaming:n}),t==="expanded"&&u.jsx(u.Fragment,{children:x??m()})]})}const YT={checkpoints:[],checkpointMetaByCheckpointId:new Map,timeline:[],messagePreviews:new Map,getLatest:()=>{},getCheckpoint:()=>{},getMessageAttempts:()=>[]},pl=(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:p,activeInterrupt:m,disableInterruptActions:f,onInterruptActionStart:v,onInterruptActionEnd:x,showToolMessages:g,checkpointIndex:b,onSelectCheckpoint:y,getMessageCustomStyles:S,toolRenderers:k}){const C=pl(t,n),T=t.role==="default_message",j=!!t.__syntheticStreaming,P=b??YT,O=!T&&"checkpointId"in t?t.checkpointId??null:null,{attemptCount:F,attemptIndex:q,attempts:Y}=w.useMemo(()=>nc(t.id,O,P),[t.id,O,P]),R=S==null?void 0:S(t);return u.jsx("div",{className:"relative mb-4 last:mb-0","data-message-id":C,style:{minHeight:"60px",containIntrinsicSize:"auto 120px"},children:u.jsx(Zs,{message:t,messageIndex:n,isStreamingMessage:j||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:p,activeInterrupt:m,disableInterruptActions:f,onInterruptActionStart:v,onInterruptActionEnd:x,showToolMessages:g,attemptCount:F,attemptIndex:q,attemptMetas:Y,onSelectCheckpoint:y,customStyles:R,toolRenderers:k})})});hl.displayName="MessageRow";function XT(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 JT({message:e,isToolMessage:t,showToolMessages:n,toolViewMode:r,isToolStreaming:o,contentParts:s,textContent:i,imageParts:a,fileParts:l,interruptParts:c,isStreamingMessage:d,enableStreamingMarkdownBuffer:p,renderStreamingMarkdown:m,defaultMessage:f,handleFileClick:v,uploadingFiles:x,handleInterruptApprove:g,handleInterruptReject:b,disableInterruptActions:y,messageRole:S,truncateUserMessages:k,userMessagePreviewLength:C,isUserExpanded:T,setIsUserExpanded:E,isCompactLayout:j,activeInterruptId:P,activeInterruptValue:O,iconForeground:F,toolRenderers:q}){const Y=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"})]}),[]),K=XT(s,(p??!0)&&d,$h),U=w.useMemo(()=>K.filter(N=>N.type==="text"),[K]),W=w.useMemo(()=>U.map(N=>N.text??"").join(""),[U]),M=w.useMemo(()=>{if(!m)return null;const N=ZT(W);return{stablePart:W.slice(0,N),tailPart:W.slice(N)}},[W,m]),I=w.useMemo(()=>{if(!M)return null;const{stablePart:N,tailPart:L}=M;return!N&&!L?null:u.jsxs("div",{className:"space-y-2",children:[N?u.jsx(Kn,{content:N,allowHtml:!1}):null,L?u.jsx(Kn,{content:L,allowHtml:!1}):null]})},[M]),G=w.useMemo(()=>{if(!m)return K;const N=[];let L=!1;for(const z of K){if(z.type==="text"){L||(N.push({type:"text",text:"",__streamingMarkdownAggregate:!0}),L=!0);continue}N.push(z)}return N},[K,m]),X=m?G:K,_=w.useCallback(({part:N,i:L})=>{if(N.type==="text"){if(m)return null;const z=N.text??"",$=z.trim(),D=Qr($);return D&&S!=="tool"?u.jsx(Js,{data:D},L):S==="user"&&k&&$.length>C?u.jsx(Ph,{text:$,expanded:T,onExpandedChange:E,previewLength:C,isCompact:j},L):u.jsx(Kn,{content:z,allowHtml:!1},L)}if(N.type==="image_url"){const z=N;return u.jsx("div",{className:"my-2",children:u.jsx("img",{src:z.url,alt:z.alt??"",loading:"lazy",className:"border rounded max-h-[420px] w-auto object-contain"})},L)}if(N.type==="file"){const z=N,$=z.name||"file";return u.jsxs("a",{href:z.url,onClick:D=>v(D,z,L),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:[x[L]?u.jsx(le.Loader,{className:"h-4 w-4 animate-spin"}):null,u.jsxs("span",{className:"truncate max-w-[180px]",children:[$,x[L]?" (processing)":""]})]},L)}if(N.type==="interrupt"){const z=N,$=Xo((z==null?void 0:z.id)??(z==null?void 0:z.interrupt_id)),D=!!(P&&$&&$===P),J=D?O??(z==null?void 0:z.value):z==null?void 0:z.value,Q=$?{...z,id:$,interrupt_id:$}:z;return u.jsx(Ah,{interruptPart:Q,onApprove:g,onReject:b,disabled:y,isActive:D,payload:J},L)}return null},[P,O,y,v,g,b,j,T,S,k,x,C,m,E]),B=i.trim().length>0||a.length>0||l.length>0||c.length>0;if(!t&&l.length>0&&!d)return Y();if(!t&&!B&&!d)return null;if(t)return n?u.jsx(Lh,{message:e,viewMode:r,isStreaming:o,toolRenderers:q},e.id):null;if(!f){const N=u.jsx("div",{className:"space-y-2",children:X.map((L,z)=>m&&QT(L)?I?u.jsx("div",{className:"space-y-2",children:I},`streaming-md-${z}`):null:u.jsx(_,{part:L,i:z},z))});return d?u.jsxs("div",{"aria-busy":"true",role:"status",children:[N,u.jsx(_h,{className:F})]}):N}return null}function $h(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 ZT(e){if(!e)return 0;for(let t=e.length;t>=0;t-=1)if($h(e.slice(0,t)))return t;return 0}function QT(e){return e.type==="text"&&!!e.__streamingMarkdownAggregate}const ek=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 Fh({className:e,variant:t,...n}){return u.jsx("div",{className:ne(ek({variant:t}),e),...n})}function tk({showTimestamp:e,showAgentName:t,isToolMessage:n,iconForeground:r,agentName:o,messageIcon:s,customHeaderClass:i,customActionsClass:a,isCompactLayout:l,showActions:c,isEditing:d,messageRole:p,toolViewMode:m,toolMeta:f,onToggleToolView:v,onCopy:x,onEdit:g,onRegenerate:b,showCheckpointControls:y,attemptCount:S,attemptIndex:k,handleOlderAttemptSelect:C,handleNewerAttemptSelect:T,messageCreatedAt:E,copied:j}){return!e&&!t&&!n?null:u.jsxs("div",{className:ne("flex items-center justify-between mb-2 pb-2 border-b border-current/10",l&&"mb-1 pb-1",r,i),children:[u.jsxs("div",{className:"flex items-center gap-2",children:[s,t&&o&&u.jsx("span",{className:ne("font-medium",l?"text-xs":"text-sm"),children:o}),n&&u.jsxs(Fh,{variant:"outline",className:ne("text-xs flex items-center gap-1 cursor-pointer select-none",r,"border border-current/40",l&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":m==="expanded",onClick:v,onKeyDown:P=>{(P.key==="Enter"||P.key===" ")&&(P.preventDefault(),v())},children:[u.jsx("span",{children:f.name??"Tool Output"}),f.toolCallId&&u.jsx("span",{className:"opacity-70",children:f.toolCallId.slice(0,8)}),m==="expanded"?u.jsx(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:[y&&S>1&&u.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[u.jsx("button",{type:"button",className:ne("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",k<S-1?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{k>=S-1||C()},"aria-label":"Older attempt (back in time)",disabled:k>=S-1,children: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:[S-k," / ",S]})}),u.jsx("button",{type:"button",className:ne("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",k>0?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{k<=0||T()},"aria-label":"Newer attempt (forward in time)",disabled:k<=0,children:u.jsx(le.ChevronRight,{className:"h-3 w-3"})})]}),e&&E&&u.jsx("time",{className:ne("text-xs opacity-60",r,l&&"text-xs"),dateTime:new Date(E).toISOString(),title:new Date(E).toLocaleString(),children:new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(new Date(E))}),c&&!d&&u.jsxs("div",{className:ne("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",a),children:[u.jsx("div",{className:"relative",children:u.jsx(Ze,{variant:"ghost",size:"sm",onClick:x,className:ne("h-6 w-6 p-0 hover:bg-foreground/10",r,l&&"h-5 w-5"),"aria-label":"Copy message",title:"Copy message",children:u.jsx(le.Copy,{className:ne(j?"text-success":r,l?"h-3 w-3":"h-4 w-4")})})}),p==="user"&&g&&u.jsx(Ze,{variant:"ghost",size:"sm",onClick:g,className:ne("h-6 w-6 p-0 hover:bg-foreground/10",r,l&&"h-5 w-5"),"aria-label":"Edit message",children:u.jsx(le.Edit,{className:ne(r,l?"h-3 w-3":"h-4 w-4")})}),p==="assistant"&&b&&u.jsx(Ze,{variant:"ghost",size:"sm",onClick:b,className:ne("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:ne(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:p=!0,toolRenderers:m,customStyles:f={},streamingDebounceMs:v=300,renderStreamingMarkdown:x=!1,enableStreamingMarkdownBuffer:g,onEdit:b,onRegenerate:y,onCopy:S,activeInterrupt:k,disableInterruptActions:C=!1,onInterruptActionStart:T,onInterruptActionEnd:E,attemptCount:j=1,attemptIndex:P=0,onSelectCheckpoint:O,attemptMetas:F=[]}){const[q,Y]=w.useState(!1),[R,K]=w.useState("preview"),[U,W]=w.useState(!1),{currentThreadId:M}=xr(),{respondToInterrupt:I}=to(),G=l==="phone"||l==="half-screen",X=t.role,_=X==="tool",B=w.useMemo(()=>t.role==="default_message"?t:null,[t]),N=!!B,L=!(r&&X!=="user"),{uploadingFiles:z,handleFileClick:$,fileViewerOpen:D,currentFileInfo:J,closeFileViewer:Q}=Mh({allowFileOpen:L,currentThreadId:M}),ie=w.useMemo(()=>{switch(X){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))]"}},[X]),Z=Oh(t,B),{contentParts:ue,imageParts:he,fileParts:ke,interruptParts:Le,textContent:$e,toolMeta:je,toolRaw:Be,isToolStreaming:ct}=Z,bt=g??v!==0,kt=(k==null?void 0:k.id)??(k==null?void 0:k.interrupt_id),ze=Xo(kt),Ye=k==null?void 0:k.value,Oe=w.useCallback(async()=>{const oe=_?Be:$e;async function _e(pe){if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function"){await navigator.clipboard.writeText(pe);return}if(navigator.clipboard&&typeof navigator.clipboard.write=="function"&&typeof ClipboardItem<"u"){const Ae=new Blob([pe],{type:"text/plain"});await navigator.clipboard.write([new ClipboardItem({"text/plain":Ae})]);return}throw new Error("Clipboard API not supported in this context.")}try{await _e(oe),Y(!0),setTimeout(()=>Y(!1),2e3),S==null||S(oe)}catch(pe){console.error("Failed to copy:",pe)}},[_,Be,$e,S]),De=w.useCallback(()=>{if(!b||!t.id)return;const oe=(_?Be:$e)??"",_e="type"in t&&t.type==="default_message"?void 0:{checkpointId:t.checkpointId??null,checkpointNs:t.checkpointNs??null};b(t.id,oe,_e)},[b,t.id,_,Be,$e,t]),He=w.useCallback(()=>{y==null||y(n)},[y,n]),rt=w.useCallback(()=>{K(oe=>oe==="expanded"?"preview":"expanded")},[]),lt=w.useCallback(()=>{const _e=ne(G?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",ie);switch(X){case"user":return u.jsx(le.User,{className:_e});case"assistant":return u.jsx(le.Bot,{className:_e});case"tool":return u.jsx(le.Wrench,{className:_e});default:return u.jsx(le.Bot,{className:_e})}},[G,ie,X]),it=w.useCallback(()=>{const oe="group relative mb-4 flex w-full";switch(X){case"user":return ne(oe,"justify-end");case"assistant":case"tool":case"system":return ne(oe,"justify-start");default:return oe}},[X]),St=w.useCallback(()=>{const oe=ne("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",G&&"px-3 py-2 text-sm");if(N)return ne(oe,"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(X){case"user":return ne(oe,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-user))] text-[hsl(var(--chat-bubble-user-text))]","border border-transparent");case"assistant":return ne(oe,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40");case"tool":return ne(oe,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return ne(oe,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return ne(oe,"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")}},[G,N,X]),ht=w.useCallback(async oe=>{if(C)return;const _e=Xo((oe==null?void 0:oe.id)??(oe==null?void 0:oe.interrupt_id));if(!_e){console.warn("Interrupt part missing id",oe);return}try{T==null||T(),await I(_e,!0)}catch(pe){console.error("Failed to approve interrupt:",pe)}finally{E==null||E()}},[C,E,T,I]),Ct=w.useCallback(async oe=>{if(C)return;const _e=Xo((oe==null?void 0:oe.id)??(oe==null?void 0:oe.interrupt_id));if(!_e){console.warn("Interrupt part missing id",oe);return}try{T==null||T(),await I(_e,!1)}catch(pe){console.error("Failed to reject interrupt:",pe)}finally{E==null||E()}},[C,E,T,I]),Et=u.jsx(JT,{message:t,isToolMessage:_,showToolMessages:p,toolViewMode:R,isToolStreaming:ct,contentParts:ue,textContent:$e,imageParts:he,fileParts:ke,interruptParts:Le,isStreamingMessage:r,defaultMessage:B,enableStreamingMarkdownBuffer:bt,renderStreamingMarkdown:x,handleFileClick:$,uploadingFiles:z,handleInterruptApprove:ht,handleInterruptReject:Ct,disableInterruptActions:C,messageRole:X,truncateUserMessages:c,userMessagePreviewLength:d,isUserExpanded:U,setIsUserExpanded:W,isCompactLayout:G,activeInterruptId:ze,activeInterruptValue:Ye,iconForeground:ie,toolRenderers:m}),rn=w.useMemo(()=>B?"Assistant":ib(t),[B,t]),It=lt(),mn=X==="user"&&(j??1)>1&&typeof O=="function",Rt=(F==null?void 0:F.length)??0,Fe=Rt>0&&P<Rt-1?F[P+1]:void 0,Ue=Rt>0&&P>0?F[P-1]:void 0,Mt=w.useCallback(()=>{!Fe||!O||O(Fe.id,void 0,!!Fe.isLatestAttempt)},[Fe,O]),re=w.useCallback(()=>{!Ue||!O||O(Ue.id,void 0,!!Ue.isLatestAttempt)},[Ue,O]);return _&&!p?null:N&&B?u.jsx("div",{className:ne(it(),f.container),children:u.jsxs("div",{className:ne(St(),f.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:ne("h-4 w-4",ie)}),a&&u.jsx("span",{className:"font-medium text-sm",children:"Assistant"})]}),u.jsx(Kn,{content:B.content,className:"text-current"})]})}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:ne(it(),f.container),children:u.jsxs("div",{className:ne(St(),f.content),children:[u.jsx(tk,{showTimestamp:i,showAgentName:a,isToolMessage:_,iconForeground:ie,agentName:rn,messageIcon:It,customHeaderClass:f.header,customActionsClass:f.actions,isCompactLayout:G,showActions:s,isEditing:o,messageRole:X,toolViewMode:R,toolMeta:je,onToggleToolView:rt,onCopy:Oe,onEdit:De,onRegenerate:He,showCheckpointControls:mn,attemptCount:j,attemptIndex:P,handleOlderAttemptSelect:Mt,handleNewerAttemptSelect:re,messageCreatedAt:t.createdAt,copied:q}),u.jsx("div",{className:"relative",children:Et}),_&&R==="expanded"&&(je.toolCallId||je.name)&&u.jsxs("div",{className:ne("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",G&&"text-xs"),children:[je.name&&u.jsxs("div",{children:["Function: ",je.name]}),je.toolCallId&&u.jsxs("div",{children:["Call ID: ",je.toolCallId]})]}),!(i||a||_)&&s&&!o&&u.jsxs("div",{className:ne("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",f.actions),children:[u.jsx(Ze,{variant:"ghost",size:"sm",onClick:()=>Oe(),className:ne("h-6 w-6 p-0 hover:bg-background/50 text-current",G&&"h-5 w-5"),children:u.jsx(le.Copy,{className:ne(q?"text-success":"text-current",G?"h-3 w-3":"h-4 w-4")})}),X==="user"&&b&&u.jsx(Ze,{variant:"ghost",size:"sm",onClick:De,className:ne("h-6 w-6 p-0 hover:bg-background/50 text-current",G&&"h-5 w-5"),children:u.jsx(le.Edit,{className:ne("text-current",G?"h-3 w-3":"h-4 w-4")})}),X==="assistant"&&y&&u.jsx(Ze,{variant:"ghost",size:"sm",onClick:He,className:ne("h-6 w-6 p-0 hover:bg-background/50 text-current",G&&"h-5 w-5"),children:u.jsx(le.RotateCcw,{className:ne("text-current",G?"h-3 w-3":"h-4 w-4")})})]})]})}),J&&u.jsx(uh,{isOpen:D,onClose:Q,fileId:J.id,fileName:J.name,mimeType:J.mimeType})]})},(e,t)=>{var l,c,d,p,m,f,v,x;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&xu(e.message)===xu(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateUserMessages","userMessagePreviewLength","showToolMessages","toolRenderers"].every(g=>e[g]===t[g]),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)===((p=t.customStyles)==null?void 0:p.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)===((x=t.customStyles)==null?void 0:x.header);if(!o||!s)return!1;const i=vu(e.message),a=vu(t.message);return i.length===a.length});Zs.displayName="MessageComponent";const ml=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:p,style:m,emptyMessage:f,followNewMessages:v=!0,isNavigatingCheckpoint:x=!1,onScrollAway:g,onAtBottom:b,activeInterrupt:y,disableInterruptActions:S=!1,onInterruptActionStart:k,onInterruptActionEnd:C,showToolMessages:T=!0,toolRenderers:E,checkpointIndex:j,activeCheckpointId:P,onSelectCheckpoint:O,createSyntheticThinkingMessage:F=!0,forceSyntheticThinking:q=!1,getMessageCustomStyles:Y},R)=>{const K=w.useRef(null),U=w.useRef(null),W=w.useRef(!1),M=w.useRef(!1),I=w.useMemo(()=>y?e.some(Z=>Z.role==="default_message"?!1:Array.isArray(Z==null?void 0:Z.content)&&Z.content.some(ue=>ue&&ue.type==="interrupt"&&(ue.id??ue.interrupt_id)===y.id)):!1,[y,e]),G=w.useMemo(()=>{if(!y||I)return null;const Z=y.id&&String(y.id).trim()?String(y.id).trim():"pending-interrupt";let ue;const he=y.value;if(he&&typeof he=="object"&&!Array.isArray(he)){const ke=he.title;typeof ke=="string"&&ke.trim()&&(ue=ke.trim())}return{id:`interrupt-${Z}`,role:"system",createdAt:new Date().toISOString(),content:[{type:"interrupt",id:Z,value:he,title:ue}]}},[y,I]),X=w.useMemo(()=>G?[...e,G]:e,[e,G]),_=w.useMemo(()=>{const Z=n&&X.some(he=>he.id===n);return F&&(t||q)&&!Z&&X.length>0?[...X,{id:"thinking-assistant",role:"assistant",content:[{type:"text",text:""}],createdAt:new Date().toISOString(),__syntheticStreaming:!0}]:X},[X,t,n,F,q]),B=w.useMemo(()=>T?_:_.filter(Z=>(Z==null?void 0:Z.role)!=="tool"),[_,T]),N=w.useCallback(Z=>{g&&g(!Z),b&&b(Z)},[g,b]),L=w.useMemo(()=>{if(a)return async()=>{if(!W.current){W.current=!0;try{await a()}finally{W.current=!1}}}},[a]),z=w.useMemo(()=>!v||x?!1:"auto",[v,x]),$=w.useMemo(()=>{if(typeof f!="string")return null;const Z=f.trim();return!Z||B&&B.length>0?null:{id:"default-message",role:"default_message",content:Z,createdAt:new Date().toISOString()}},[f,B]),D=["flex h-full flex-col md:flex-row",p].filter(Boolean).join(" "),J=()=>{if($){const Z=Y==null?void 0:Y($);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:$,messageIndex:0,isStreamingMessage:!1,showActions:!1,showTimestamp:!1,showAgentName:!0,layoutSize:o,onEdit:()=>{},onRegenerate:()=>{},onCancelEdit:()=>{},customStyles:Z})})})}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!"})},Q=B.length,ie=Q>0;return w.useEffect(()=>{var Z,ue;if(Q===0){M.current=!1;return}if(!M.current)if(M.current=!0,K.current&&B.length>0){const he=B.length-1;(ue=(Z=K.current).scrollToIndex)==null||ue.call(Z,{index:he,align:"end",behavior:"auto"})}else U.current&&(U.current.scrollTop=U.current.scrollHeight)},[Q,B.length]),w.useImperativeHandle(R,()=>({scrollToLatest:()=>{var Z,ue;if(K.current&&B.length>0){const he=B.length-1;(ue=(Z=K.current).scrollToIndex)==null||ue.call(Z,{index:he,align:"end",behavior:"auto"})}else U.current&&(U.current.scrollTop=U.current.scrollHeight)},scrollToTop:()=>{var Z,ue;K.current&&B.length>0?(ue=(Z=K.current).scrollToIndex)==null||ue.call(Z,{index:0,align:"start",behavior:"auto"}):U.current&&(U.current.scrollTop=0)}}),[B]),u.jsx("div",{className:D,style:m,children:u.jsx("div",{className:"relative flex-1 min-h-0",children:ie?u.jsx(KC,{ref:Z=>{K.current=Z},scrollerRef:Z=>{U.current=Z instanceof HTMLDivElement?Z:null},data:B,followOutput:z,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,startReached:()=>{L&&L()},atBottomStateChange:N,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(Z,ue)=>pl(ue,Z),itemContent:(Z,ue)=>u.jsx(hl,{message:ue,index:Z,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onEdit:l,onRegenerate:c,onCancelEdit:d,activeInterrupt:y,disableInterruptActions:S,onInterruptActionStart:k,onInterruptActionEnd:C,showToolMessages:T,toolRenderers:E,checkpointIndex:j,activeCheckpointId:P,onSelectCheckpoint:O,getMessageCustomStyles:Y})}):J()})})});ml.displayName="MessageList";const Bh={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:p,payloadExtras:m={},customStyles:f={},messageCustomStyles:v,onMessageSent:x,onExcelUploadSuccess:g,onError:b,defaultMessage:y}){const{api:S}=Jr(),{currentThreadId:k}=xr(),{threadId:C,messages:T,isLoading:E,navigateToCheckpoint:j,returnToLatest:P,checkpoint:O,checkpoints:F,interrupt:q,metadata:Y,checkpointIndex:R}=to(),{isStreaming:K,error:U,connectionState:W,submit:M,stop:I}=Fi(),G=C??k??null,X=(O==null?void 0:O.id)??null,_=(O==null?void 0:O.namespace)??null,B=(Y==null?void 0:Y.assemblingMessageId)??null,N=q,[L,z]=w.useState(!1),[$,D]=w.useState(!1);w.useEffect(()=>{N||z(!1)},[N]);const J=w.useCallback(()=>{z(!0)},[]),Q=w.useCallback(()=>{z(!1)},[]),ie=!!N||L,[Z,ue]=w.useState(null),[he,ke]=w.useState(""),[Le,$e]=w.useState(null),[je,Be]=w.useState(null),[ct,bt]=w.useState(!1),[kt,ze]=w.useState(null),Ye=w.useRef(!1),[Oe,De]=w.useState(()=>Bh.value),He=w.useRef(Oe),rt=w.useRef(null),lt=w.useCallback(ve=>{Bh.value=ve,De(ve)},[]),[it,St]=w.useState(!1),ht=w.useRef(null),Ct=w.useCallback(ve=>{lt(ve)},[lt]);w.useEffect(()=>{K||D(!1)},[K]),w.useEffect(()=>{Y!=null&&Y.assemblingMessageId&&D(!1)},[Y==null?void 0:Y.assemblingMessageId]);const[Et,rn]=w.useState("desktop");w.useEffect(()=>{const ve=()=>{const Ie=window.innerWidth;rn(Ie<640?"phone":Ie<1024?"tablet":"desktop")};return ve(),window.addEventListener("resize",ve),()=>window.removeEventListener("resize",ve)},[]),w.useEffect(()=>{Ye.current=!1},[G]),w.useEffect(()=>{He.current=Oe},[Oe]),w.useEffect(()=>{if(!Z){rt.current=null;return}rt.current===null&&(rt.current=He.current),lt(he??"")},[he,Z,lt]),w.useEffect(()=>{if(y!==void 0){ze(y);return}(async()=>{if(!S.baseUrl){ze(null);return}try{const Pe=(await S.getAgent("default")).uiDefaultMessage||"";ze(Pe||null)}catch(Ie){console.warn("Failed to fetch default message:",Ie),ze(null)}})()},[S.baseUrl,y]),w.useEffect(()=>{U&&!ct&&(b==null||b(U))},[U,ct,b]);const It=async(ve,Ie)=>{const Pe=ve.trim();if(!(!Pe&&Ie.length===0))try{const Ge=Z?(Le==null?void 0:Le.checkpointId)??X??void 0:X??void 0,mt=Z?(Le==null?void 0:Le.checkpointNs)??_??void 0:_??void 0;await M({text:Pe||"",attachments:Ie,payload:m},{checkpointId:Ge,checkpointNs:mt,edit:!!Z,originalMessageId:Z??void 0}),x==null||x(Pe),D(!0),lt(""),Be(null),ue(null),ke(""),$e(null)}catch(Ge){const mt=(Ge==null?void 0:Ge.message)||"Failed to send message";Be(mt),b==null||b(mt),D(!1)}},mn=w.useCallback(async ve=>{await M({attachments:[ve],payload:m},{checkpointId:X??void 0,checkpointNs:_??void 0}),g==null||g({file:ve})},[X,_,m,g,M]),Rt=w.useCallback((ve,Ie,Pe)=>{c&&(rt.current=Oe,ue(ve),ke(Ie),lt(Ie),Be(null),$e({checkpointId:(Pe==null?void 0:Pe.checkpointId)??null,checkpointNs:(Pe==null?void 0:Pe.checkpointNs)??null}))},[Oe,c,lt]),Fe=w.useCallback(()=>{ue(null),ke(""),$e(null),Be(null),lt(rt.current??Oe),rt.current=null},[Oe,lt]),Ue=w.useCallback((ve,Ie,Pe)=>{Rt(ve,Ie,Pe)},[Rt]),Mt=w.useCallback(ve=>{let Ie=null;for(let we=ve-1;we>=0;we--)if(T[we].role==="user"){Ie=T[we];break}if(!Ie)return;const Pe=Array.isArray(Ie.content)?Ie.content:[],mt=Pe.filter(we=>(we==null?void 0:we.type)==="text").map(we=>we.text).join("")||(()=>{try{return JSON.stringify(Pe,null,2)}catch{return String(Pe)}})();mt&&M({text:mt,payload:m},{checkpointId:X??void 0,checkpointNs:_??void 0,edit:!0,originalMessageId:Ie.id})},[T,M,X,_,m]),re=async ve=>{if(k){St(!0);try{if(!ve){await P(),requestAnimationFrame(()=>{var Ge;(Ge=ht.current)==null||Ge.scrollToLatest()});return}const Ie=F.find(Ge=>Ge.checkpointId===ve),Pe=(Ie==null?void 0:Ie.checkpointNs)??null;await j(ve,Pe),requestAnimationFrame(()=>{var Ge;(Ge=ht.current)==null||Ge.scrollToTop()})}finally{St(!1)}}},oe=w.useCallback(async(ve,Ie,Pe)=>{await re(Pe?null:ve)},[re]),_e=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${f.container||""}`,pe=`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 ${f.messagesArea||""}`,Ae=`relative flex-shrink-0 w-full border-t p-4 bg-transparent ${f.inputArea||""}`;return u.jsxs("div",{className:_e,children:[!!U&&!ct&&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:U}),u.jsx(Ze,{variant:"ghost",size:"sm",onClick:()=>bt(!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 ${pe}`,style:r?{maxHeight:r}:void 0,children:[u.jsx(ml,{ref:ht,className:"h-full",style:{height:"100%"},messages:T,isStreaming:K,streamingAssistantId:B,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:Et,enableMessageEditing:c,editingMessageId:Z,onEdit:Ue,onRegenerate:Mt,onCancelEdit:Fe,emptyMessage:kt??void 0,isNavigatingCheckpoint:it,activeInterrupt:N,disableInterruptActions:L,onInterruptActionStart:J,onInterruptActionEnd:Q,showToolMessages:d,toolRenderers:p,checkpointIndex:R,activeCheckpointId:X,onSelectCheckpoint:oe,createSyntheticThinkingMessage:!0,forceSyntheticThinking:$,getMessageCustomStyles:v}),(W==="reconnecting"||W==="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"}),W==="reconnecting"?"Reconnecting…":"Connecting…"]})}),W==="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"}),E&&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…"})]}),it&&u.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 bg-background/80 backdrop-blur-sm text-muted-foreground",children:[u.jsx(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:Ae,children:[Z&&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(Ze,{variant:"ghost",size:"sm",onClick:Fe,className:"text-blue-600 hover:bg-blue-100",children:u.jsx(le.X,{size:16})})]})}),je&&u.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:je}),u.jsx(DS,{composerValue:Oe,onComposerChange:Ct,onSend:It,onCancelEdit:Fe,onStop:I,editingMessageId:Z,editingInitialValue:he,placeholder:Z?"Edit your message...":t,isStreaming:K,disabled:ie,enableFileUpload:a,enableExcelUpload:l,onExcelUpload:mn,onError:b,customStyles:f,textareaClassName:f.textarea||"",allowEmptySend:!1,inputError:je})]})]})}var zh=1,nk=.9,rk=.8,ok=.17,gl=.1,xl=.999,sk=.9999,ik=.99,ak=/[\\\/_+.#"@\[\(\{&]/,lk=/[\\\/_+.#"@\[\(\{&]/g,ck=/[\s-]/,Hh=/[\s-]/g;function vl(e,t,n,r,o,s,i){if(s===t.length)return o===e.length?zh:ik;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,p,m,f,v;c>=0;)p=vl(e,t,n,r,c+1,s+1,i),p>d&&(c===o?p*=zh:ak.test(e.charAt(c-1))?(p*=rk,f=e.slice(o,c-1).match(lk),f&&o>0&&(p*=Math.pow(xl,f.length))):ck.test(e.charAt(c-1))?(p*=nk,v=e.slice(o,c-1).match(Hh),v&&o>0&&(p*=Math.pow(xl,v.length))):(p*=ok,o>0&&(p*=Math.pow(xl,c-o))),e.charAt(c)!==t.charAt(s)&&(p*=sk)),(p<gl&&n.charAt(c-1)===r.charAt(s+1)||r.charAt(s+1)===r.charAt(s)&&n.charAt(c-1)!==r.charAt(s))&&(m=vl(e,t,n,r,c+1,s+2,i),m*gl>p&&(p=m*gl)),p>d&&(d=p),c=n.indexOf(l,c+1);return i[a]=d,d}function Uh(e){return e.toLowerCase().replace(Hh," ")}function uk(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,vl(e,t,Uh(e),Uh(t),0,0,{})}var Ao='[cmdk-group=""]',bl='[cmdk-group-items=""]',dk='[cmdk-group-heading=""]',Wh='[cmdk-item=""]',Vh=`${Wh}:not([aria-disabled="true"])`,wl="cmdk-item-select",Dr="data-value",fk=(e,t,n)=>uk(e,t,n),Kh=h.createContext(void 0),jo=()=>h.useContext(Kh),qh=h.createContext(void 0),yl=()=>h.useContext(qh),Gh=h.createContext(void 0),Yh=h.forwardRef((e,t)=>{let n=Lr(()=>{var _,B;return{search:"",value:(B=(_=e.value)!=null?_: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=Xh(e),{label:l,children:c,value:d,onValueChange:p,filter:m,shouldFilter:f,loop:v,disablePointerSelection:x=!1,vimBindings:g=!0,...b}=e,y=At(),S=At(),k=At(),C=h.useRef(null),T=Ck();ur(()=>{if(d!==void 0){let _=d.trim();n.current.value=_,E.emit()}},[d]),ur(()=>{T(6,Y)},[]);let E=h.useMemo(()=>({subscribe:_=>(i.current.add(_),()=>i.current.delete(_)),snapshot:()=>n.current,setState:(_,B,N)=>{var L,z,$,D;if(!Object.is(n.current[_],B)){if(n.current[_]=B,_==="search")q(),O(),T(1,F);else if(_==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let J=document.getElementById(k);J?J.focus():(L=document.getElementById(y))==null||L.focus()}if(T(7,()=>{var J;n.current.selectedItemId=(J=R())==null?void 0:J.id,E.emit()}),N||T(5,Y),((z=a.current)==null?void 0:z.value)!==void 0){let J=B??"";(D=($=a.current).onValueChange)==null||D.call($,J);return}}E.emit()}},emit:()=>{i.current.forEach(_=>_())}}),[]),j=h.useMemo(()=>({value:(_,B,N)=>{var L;B!==((L=s.current.get(_))==null?void 0:L.value)&&(s.current.set(_,{value:B,keywords:N}),n.current.filtered.items.set(_,P(B,N)),T(2,()=>{O(),E.emit()}))},item:(_,B)=>(r.current.add(_),B&&(o.current.has(B)?o.current.get(B).add(_):o.current.set(B,new Set([_]))),T(3,()=>{q(),O(),n.current.value||F(),E.emit()}),()=>{s.current.delete(_),r.current.delete(_),n.current.filtered.items.delete(_);let N=R();T(4,()=>{q(),(N==null?void 0:N.getAttribute("id"))===_&&F(),E.emit()})}),group:_=>(o.current.has(_)||o.current.set(_,new Set),()=>{s.current.delete(_),o.current.delete(_)}),filter:()=>a.current.shouldFilter,label:l||e["aria-label"],getDisablePointerSelection:()=>a.current.disablePointerSelection,listId:y,inputId:k,labelId:S,listInnerRef:C}),[]);function P(_,B){var N,L;let z=(L=(N=a.current)==null?void 0:N.filter)!=null?L:fk;return _?z(_,n.current.search,B):0}function O(){if(!n.current.search||a.current.shouldFilter===!1)return;let _=n.current.filtered.items,B=[];n.current.filtered.groups.forEach(L=>{let z=o.current.get(L),$=0;z.forEach(D=>{let J=_.get(D);$=Math.max(J,$)}),B.push([L,$])});let N=C.current;K().sort((L,z)=>{var $,D;let J=L.getAttribute("id"),Q=z.getAttribute("id");return(($=_.get(Q))!=null?$:0)-((D=_.get(J))!=null?D:0)}).forEach(L=>{let z=L.closest(bl);z?z.appendChild(L.parentElement===z?L:L.closest(`${bl} > *`)):N.appendChild(L.parentElement===N?L:L.closest(`${bl} > *`))}),B.sort((L,z)=>z[1]-L[1]).forEach(L=>{var z;let $=(z=C.current)==null?void 0:z.querySelector(`${Ao}[${Dr}="${encodeURIComponent(L[0])}"]`);$==null||$.parentElement.appendChild($)})}function F(){let _=K().find(N=>N.getAttribute("aria-disabled")!=="true"),B=_==null?void 0:_.getAttribute(Dr);E.setState("value",B||void 0)}function q(){var _,B,N,L;if(!n.current.search||a.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let z=0;for(let $ of r.current){let D=(B=(_=s.current.get($))==null?void 0:_.value)!=null?B:"",J=(L=(N=s.current.get($))==null?void 0:N.keywords)!=null?L:[],Q=P(D,J);n.current.filtered.items.set($,Q),Q>0&&z++}for(let[$,D]of o.current)for(let J of D)if(n.current.filtered.items.get(J)>0){n.current.filtered.groups.add($);break}n.current.filtered.count=z}function Y(){var _,B,N;let L=R();L&&(((_=L.parentElement)==null?void 0:_.firstChild)===L&&((N=(B=L.closest(Ao))==null?void 0:B.querySelector(dk))==null||N.scrollIntoView({block:"nearest"})),L.scrollIntoView({block:"nearest"}))}function R(){var _;return(_=C.current)==null?void 0:_.querySelector(`${Wh}[aria-selected="true"]`)}function K(){var _;return Array.from(((_=C.current)==null?void 0:_.querySelectorAll(Vh))||[])}function U(_){let B=K()[_];B&&E.setState("value",B.getAttribute(Dr))}function W(_){var B;let N=R(),L=K(),z=L.findIndex(D=>D===N),$=L[z+_];(B=a.current)!=null&&B.loop&&($=z+_<0?L[L.length-1]:z+_===L.length?L[0]:L[z+_]),$&&E.setState("value",$.getAttribute(Dr))}function M(_){let B=R(),N=B==null?void 0:B.closest(Ao),L;for(;N&&!L;)N=_>0?yk(N,Ao):Sk(N,Ao),L=N==null?void 0:N.querySelector(Vh);L?E.setState("value",L.getAttribute(Dr)):W(_)}let I=()=>U(K().length-1),G=_=>{_.preventDefault(),_.metaKey?I():_.altKey?M(1):W(1)},X=_=>{_.preventDefault(),_.metaKey?U(0):_.altKey?M(-1):W(-1)};return h.createElement(me.div,{ref:t,tabIndex:-1,...b,"cmdk-root":"",onKeyDown:_=>{var B;(B=b.onKeyDown)==null||B.call(b,_);let N=_.nativeEvent.isComposing||_.keyCode===229;if(!(_.defaultPrevented||N))switch(_.key){case"n":case"j":{g&&_.ctrlKey&&G(_);break}case"ArrowDown":{G(_);break}case"p":case"k":{g&&_.ctrlKey&&X(_);break}case"ArrowUp":{X(_);break}case"Home":{_.preventDefault(),U(0);break}case"End":{_.preventDefault(),I();break}case"Enter":{_.preventDefault();let L=R();if(L){let z=new Event(wl);L.dispatchEvent(z)}}}}},h.createElement("label",{"cmdk-label":"",htmlFor:j.inputId,id:j.labelId,style:kk},l),Qs(e,_=>h.createElement(qh.Provider,{value:E},h.createElement(Kh.Provider,{value:j},_))))}),pk=h.forwardRef((e,t)=>{var n,r;let o=At(),s=h.useRef(null),i=h.useContext(Gh),a=jo(),l=Xh(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=Jh(o,s,[e.value,e.children,s],e.keywords),p=yl(),m=qn(T=>T.value&&T.value===d.current),f=qn(T=>c||a.filter()===!1?!0:T.search?T.filtered.items.get(o)>0:!0);h.useEffect(()=>{let T=s.current;if(!(!T||e.disabled))return T.addEventListener(wl,v),()=>T.removeEventListener(wl,v)},[f,e.onSelect,e.disabled]);function v(){var T,E;x(),(E=(T=l.current).onSelect)==null||E.call(T,d.current)}function x(){p.setState("value",d.current,!0)}if(!f)return null;let{disabled:g,value:b,onSelect:y,forceMount:S,keywords:k,...C}=e;return h.createElement(me.div,{ref:Mn(s,t),...C,id:o,"cmdk-item":"",role:"option","aria-disabled":!!g,"aria-selected":!!m,"data-disabled":!!g,"data-selected":!!m,onPointerMove:g||a.getDisablePointerSelection()?void 0:x,onClick:g?void 0:v},e.children)}),hk=h.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:o,...s}=e,i=At(),a=h.useRef(null),l=h.useRef(null),c=At(),d=jo(),p=qn(f=>o||d.filter()===!1?!0:f.search?f.filtered.groups.has(i):!0);ur(()=>d.group(i),[]),Jh(i,a,[e.value,e.heading,l]);let m=h.useMemo(()=>({id:i,forceMount:o}),[o]);return h.createElement(me.div,{ref:Mn(a,t),...s,"cmdk-group":"",role:"presentation",hidden:p?void 0:!0},n&&h.createElement("div",{ref:l,"cmdk-group-heading":"","aria-hidden":!0,id:c},n),Qs(e,f=>h.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?c:void 0},h.createElement(Gh.Provider,{value:m},f))))}),mk=h.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,o=h.useRef(null),s=qn(i=>!i.search);return!n&&!s?null:h.createElement(me.div,{ref:Mn(o,t),...r,"cmdk-separator":"",role:"separator"})}),gk=h.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,o=e.value!=null,s=yl(),i=qn(c=>c.search),a=qn(c=>c.selectedItemId),l=jo();return h.useEffect(()=>{e.value!=null&&s.setState("search",e.value)},[e.value]),h.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)}})}),xk=h.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...o}=e,s=h.useRef(null),i=h.useRef(null),a=qn(c=>c.selectedItemId),l=jo();return h.useEffect(()=>{if(i.current&&s.current){let c=i.current,d=s.current,p,m=new ResizeObserver(()=>{p=requestAnimationFrame(()=>{let f=c.offsetHeight;d.style.setProperty("--cmdk-list-height",f.toFixed(1)+"px")})});return m.observe(c),()=>{cancelAnimationFrame(p),m.unobserve(c)}}},[]),h.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=>h.createElement("div",{ref:Mn(i,l.listInnerRef),"cmdk-list-sizer":""},c)))}),vk=h.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:o,contentClassName:s,container:i,...a}=e;return h.createElement(Qa,{open:n,onOpenChange:r},h.createElement(el,{container:i},h.createElement(ko,{"cmdk-overlay":"",className:o}),h.createElement(Eo,{"aria-label":e.label,"cmdk-dialog":"",className:s},h.createElement(Yh,{ref:t,...a}))))}),bk=h.forwardRef((e,t)=>qn(n=>n.filtered.count===0)?h.createElement(me.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),wk=h.forwardRef((e,t)=>{let{progress:n,children:r,label:o="Loading...",...s}=e;return h.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=>h.createElement("div",{"aria-hidden":!0},i)))}),Ut=Object.assign(Yh,{List:xk,Item:pk,Input:gk,Group:hk,Separator:mk,Dialog:vk,Empty:bk,Loading:wk});function yk(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function Sk(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function Xh(e){let t=h.useRef(e);return ur(()=>{t.current=e}),t}var ur=typeof window>"u"?h.useEffect:h.useLayoutEffect;function Lr(e){let t=h.useRef();return t.current===void 0&&(t.current=e()),t}function qn(e){let t=yl(),n=()=>e(t.snapshot());return h.useSyncExternalStore(t.subscribe,n,n)}function Jh(e,t,n,r=[]){let o=h.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 Ck=()=>{let[e,t]=h.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 Tk(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function Qs({asChild:e,children:t},n){return e&&h.isValidElement(t)?h.cloneElement(Tk(t),{ref:t.ref},n(t.props.children)):n(t)}var kk={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const Sl=h.forwardRef(({className:e,...t},n)=>u.jsx(Ut,{ref:n,className:ne("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));Sl.displayName=Ut.displayName;const Cl=h.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(Ut.Input,{ref:n,className:ne("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),...t})]}));Cl.displayName=Ut.Input.displayName;const Tl=h.forwardRef(({className:e,...t},n)=>u.jsx(Ut.List,{ref:n,className:ne("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));Tl.displayName=Ut.List.displayName;const kl=h.forwardRef((e,t)=>u.jsx(Ut.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));kl.displayName=Ut.Empty.displayName;const El=h.forwardRef(({className:e,...t},n)=>u.jsx(Ut.Group,{ref:n,className:ne("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",e),...t}));El.displayName=Ut.Group.displayName;const Ek=h.forwardRef(({className:e,...t},n)=>u.jsx(Ut.Separator,{ref:n,className:ne("-mx-1 h-px bg-border",e),...t}));Ek.displayName=Ut.Separator.displayName;const Il=h.forwardRef(({className:e,...t},n)=>u.jsx(Ut.Item,{ref:n,className:ne("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected='true']:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50",e),...t}));Il.displayName=Ut.Item.displayName;function Nl(e,[t,n]){return Math.min(n,Math.max(t,e))}function Ik(e,t){return h.useReducer((n,r)=>t[n][r]??n,e)}var Al="ScrollArea",[Zh,UN]=an(Al),[Nk,nn]=Zh(Al),Qh=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,l]=h.useState(null),[c,d]=h.useState(null),[p,m]=h.useState(null),[f,v]=h.useState(null),[x,g]=h.useState(null),[b,y]=h.useState(0),[S,k]=h.useState(0),[C,T]=h.useState(!1),[E,j]=h.useState(!1),P=Re(t,F=>l(F)),O=Zo(o);return u.jsx(Nk,{scope:n,type:r,dir:O,scrollHideDelay:s,scrollArea:a,viewport:c,onViewportChange:d,content:p,onContentChange:m,scrollbarX:f,onScrollbarXChange:v,scrollbarXEnabled:C,onScrollbarXEnabledChange:T,scrollbarY:x,onScrollbarYChange:g,scrollbarYEnabled:E,onScrollbarYEnabledChange:j,onCornerWidthChange:y,onCornerHeightChange:k,children:u.jsx(me.div,{dir:O,...i,ref:P,style:{position:"relative","--radix-scroll-area-corner-width":b+"px","--radix-scroll-area-corner-height":S+"px",...e.style}})})});Qh.displayName=Al;var em="ScrollAreaViewport",tm=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=nn(em,n),a=h.useRef(null),l=Re(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})})]})});tm.displayName=em;var En="ScrollAreaScrollbar",jl=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=nn(En,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:i}=o,a=e.orientation==="horizontal";return h.useEffect(()=>(a?s(!0):i(!0),()=>{a?s(!1):i(!1)}),[a,s,i]),o.type==="hover"?u.jsx(Ak,{...r,ref:t,forceMount:n}):o.type==="scroll"?u.jsx(jk,{...r,ref:t,forceMount:n}):o.type==="auto"?u.jsx(nm,{...r,ref:t,forceMount:n}):o.type==="always"?u.jsx(_l,{...r,ref:t}):null});jl.displayName=En;var Ak=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=nn(En,e.__scopeScrollArea),[s,i]=h.useState(!1);return h.useEffect(()=>{const a=o.scrollArea;let l=0;if(a){const c=()=>{window.clearTimeout(l),i(!0)},d=()=>{l=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",c),a.addEventListener("pointerleave",d),()=>{window.clearTimeout(l),a.removeEventListener("pointerenter",c),a.removeEventListener("pointerleave",d)}}},[o.scrollArea,o.scrollHideDelay]),u.jsx(zt,{present:n||s,children:u.jsx(nm,{"data-state":s?"visible":"hidden",...r,ref:t})})}),jk=h.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]=Ik("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return h.useEffect(()=>{if(a==="idle"){const c=window.setTimeout(()=>l("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(c)}},[a,o.scrollHideDelay,l]),h.useEffect(()=>{const c=o.viewport,d=s?"scrollLeft":"scrollTop";if(c){let p=c[d];const m=()=>{const f=c[d];p!==f&&(l("SCROLL"),i()),p=f};return c.addEventListener("scroll",m),()=>c.removeEventListener("scroll",m)}},[o.viewport,s,l,i]),u.jsx(zt,{present:n||a!=="hidden",children:u.jsx(_l,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:ae(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:ae(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),nm=h.forwardRef((e,t)=>{const n=nn(En,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=h.useState(!1),a=e.orientation==="horizontal",l=ri(()=>{if(n.viewport){const c=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?c:d)}},10);return $r(n.viewport,l),$r(n.content,l),u.jsx(zt,{present:r||s,children:u.jsx(_l,{"data-state":s?"visible":"hidden",...o,ref:t})})}),_l=h.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=nn(En,e.__scopeScrollArea),s=h.useRef(null),i=h.useRef(0),[a,l]=h.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),c=am(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 p(m,f){return Dk(m,i.current,a,f)}return n==="horizontal"?u.jsx(_k,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollLeft,f=lm(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=p(m,o.dir))}}):n==="vertical"?u.jsx(Pk,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollTop,f=lm(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=p(m))}}):null}),_k=h.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=nn(En,e.__scopeScrollArea),[i,a]=h.useState(),l=h.useRef(null),c=Re(t,l,s.onScrollbarXChange);return h.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(om,{"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,p)=>{if(s.viewport){const m=s.viewport.scrollLeft+d.deltaX;e.onWheelScroll(m),um(m,p)&&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)}})}})}),Pk=h.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=nn(En,e.__scopeScrollArea),[i,a]=h.useState(),l=h.useRef(null),c=Re(t,l,s.onScrollbarYChange);return h.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(om,{"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,p)=>{if(s.viewport){const m=s.viewport.scrollTop+d.deltaY;e.onWheelScroll(m),um(m,p)&&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)}})}})}),[Rk,rm]=Zh(En),om=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:l,onDragScroll:c,onWheelScroll:d,onResize:p,...m}=e,f=nn(En,n),[v,x]=h.useState(null),g=Re(t,P=>x(P)),b=h.useRef(null),y=h.useRef(""),S=f.viewport,k=r.content-r.viewport,C=ft(d),T=ft(l),E=ri(p,10);function j(P){if(b.current){const O=P.clientX-b.current.left,F=P.clientY-b.current.top;c({x:O,y:F})}}return h.useEffect(()=>{const P=O=>{const F=O.target;(v==null?void 0:v.contains(F))&&C(O,k)};return document.addEventListener("wheel",P,{passive:!1}),()=>document.removeEventListener("wheel",P,{passive:!1})},[S,v,k,C]),h.useEffect(T,[r,T]),$r(v,E),$r(f.content,E),u.jsx(Rk,{scope:n,scrollbar:v,hasThumb:o,onThumbChange:ft(s),onThumbPointerUp:ft(i),onThumbPositionChange:T,onThumbPointerDown:ft(a),children:u.jsx(me.div,{...m,ref:g,style:{position:"absolute",...m.style},onPointerDown:ae(e.onPointerDown,P=>{P.button===0&&(P.target.setPointerCapture(P.pointerId),b.current=v.getBoundingClientRect(),y.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",f.viewport&&(f.viewport.style.scrollBehavior="auto"),j(P))}),onPointerMove:ae(e.onPointerMove,j),onPointerUp:ae(e.onPointerUp,P=>{const O=P.target;O.hasPointerCapture(P.pointerId)&&O.releasePointerCapture(P.pointerId),document.body.style.webkitUserSelect=y.current,f.viewport&&(f.viewport.style.scrollBehavior=""),b.current=null})})})}),ei="ScrollAreaThumb",sm=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=rm(ei,e.__scopeScrollArea);return u.jsx(zt,{present:n||o.hasThumb,children:u.jsx(Mk,{ref:t,...r})})}),Mk=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=nn(ei,n),i=rm(ei,n),{onThumbPositionChange:a}=i,l=Re(t,p=>i.onThumbChange(p)),c=h.useRef(void 0),d=ri(()=>{c.current&&(c.current(),c.current=void 0)},100);return h.useEffect(()=>{const p=s.viewport;if(p){const m=()=>{if(d(),!c.current){const f=Lk(p,a);c.current=f,a()}};return a(),p.addEventListener("scroll",m),()=>p.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,p=>{const f=p.target.getBoundingClientRect(),v=p.clientX-f.left,x=p.clientY-f.top;i.onThumbPointerDown({x:v,y:x})}),onPointerUp:ae(e.onPointerUp,i.onThumbPointerUp)})});sm.displayName=ei;var Pl="ScrollAreaCorner",im=h.forwardRef((e,t)=>{const n=nn(Pl,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?u.jsx(Ok,{...e,ref:t}):null});im.displayName=Pl;var Ok=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=nn(Pl,n),[s,i]=h.useState(0),[a,l]=h.useState(0),c=!!(s&&a);return $r(o.scrollbarX,()=>{var p;const d=((p=o.scrollbarX)==null?void 0:p.offsetHeight)||0;o.onCornerHeightChange(d),l(d)}),$r(o.scrollbarY,()=>{var p;const d=((p=o.scrollbarY)==null?void 0:p.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 am(e,t){const n=e/t;return isNaN(n)?0:n}function ni(e){const t=am(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function Dk(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,p=r==="ltr"?[0,d]:[d*-1,0];return cm([l,c],p)(e)}function lm(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=Nl(e,l);return cm([0,i],[0,a])(c)}function cm(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 um(e,t){return e>0&&e<t}var Lk=(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=ft(e),r=h.useRef(0);return h.useEffect(()=>()=>window.clearTimeout(r.current),[]),h.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function $r(e,t){const n=ft(t);Tt(()=>{let r=0;if(e){const o=new ResizeObserver(()=>{cancelAnimationFrame(r),r=window.requestAnimationFrame(n)});return o.observe(e),()=>{window.cancelAnimationFrame(r),o.unobserve(e)}}},[e,n])}var dm=Qh,$k=tm,Fk=im;const Rl=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(dm,{ref:r,className:ne("relative overflow-hidden",e),...n,children:[u.jsx($k,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),u.jsx(fm,{}),u.jsx(Fk,{})]}));Rl.displayName=dm.displayName;const fm=h.forwardRef(({className:e,orientation:t="vertical",...n},r)=>u.jsx(jl,{ref:r,orientation:t,className:ne("flex touch-none select-none transition-colors",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...n,children:u.jsx(sm,{className:"relative flex-1 rounded-full bg-border"})}));fm.displayName=jl.displayName;const Ml=h.forwardRef(({className:e,type:t,...n},r)=>u.jsx("input",{type:t,className:ne("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:r,...n}));Ml.displayName="Input";const Bk="group relative p-3 rounded-lg cursor-pointer transition-colors border text-gray-900 dark:text-slate-100",zk="bg-slate-700 border-slate-600 hover:bg-slate-600",Hk="bg-slate-600 border-slate-500";function pm({thread:e,isActive:t,editingThreadId:n,editingTitle:r,onSelect:o,onStartEditing:s,onEditingTitleChange:i,onSaveEditing:a,onCancelEditing:l,onShare:c,onDelete:d,showEditTitle:p,showDeleteButton:m,formatDate:f,getDisplayThreadTitle:v,secondaryLine:x,itemClassName:g,activeItemClassName:b}){const y=n===e.threadId,S=t?`${b??Hk}`:`${g??zk}`,k=C=>{C.stopPropagation(),o(e.threadId)};return u.jsxs("div",{onClick:k,className:`${Bk} ${S}`,children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("div",{className:"flex-1 min-w-0",children:y?u.jsxs("div",{className:"flex items-center gap-2",onClick:C=>C.stopPropagation(),children:[u.jsx(Ml,{value:r,onChange:C=>i(C.target.value),onKeyDown:C=>{C.key==="Enter"?a(e.threadId):C.key==="Escape"&&l()},className:"h-6 text-sm",autoFocus:!0}),u.jsx(Ze,{variant:"ghost",size:"sm",onClick:()=>a(e.threadId),className:"h-6 w-6 p-0",children:u.jsx(le.Check,{size:12})}),u.jsx(Ze,{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)})]}),x&&u.jsx("div",{className:"text-[11px] text-muted-foreground mt-1",children:x})]})}),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(Ze,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",children:u.jsx(le.MoreHorizontal,{size:12})})}),u.jsxs(ho,{align:"end",sideOffset:6,className:"w-44",children:[u.jsxs(Fn,{onClick:C=>{C.preventDefault(),c(e.threadId)},children:[u.jsx(le.Share2,{className:"mr-2 h-4 w-4"}),"Share thread"]}),p&&n!==e.threadId&&u.jsxs(Fn,{onClick:C=>{C.preventDefault(),s(e,C)},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:C=>{C.preventDefault(),d(e.threadId,C)},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 hm=25,mm="thread-manager-view",Uk=e=>e==="default"||e==="shared",Wk=()=>{if(typeof window>"u")return null;try{const e=window.localStorage.getItem(mm);if(Uk(e))return e}catch{}return null};function gm({defaultView:e}={}){const[t,n]=w.useState(()=>Wk()??e??"default");w.useEffect(()=>{if(!(typeof window>"u"))try{window.localStorage.setItem(mm,t)}catch{}},[t]);const r=w.useCallback(o=>{n(o)},[]);return{view:t,setView:r}}const Vk=[{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:p,defaultView:m,onViewChange:f,viewOptions:v,viewState:x,showHeader:g=!0,shareTargets:b,isLoadingShareTargets:y,shareTargetFilter:S}){const{threads:k,sharedThreads:C,currentThreadId:T,setCurrentThreadId:E,isLoading:j,isLoadingSharedThreads:P,actions:O,shareInFlight:F,shareStatus:q,clearShareStatus:Y}=xr(),{createThread:R,deleteThread:K,renameThread:U,shareThread:W}=O,{loadThread:M}=to(),I=i??T,[G,X]=w.useState(Array.isArray(k)?k:[]),_=w.useRef(G.length>0),B=w.useRef(null),N=w.useRef(0),[L,z]=w.useState(null),[$,D]=w.useState(""),[J,Q]=w.useState(!1),[ie,Z]=w.useState(!1),[ue,he]=w.useState(null),[ke,Le]=w.useState(""),$e=v&&v.length>0?v:Vk,je=gm({defaultView:m}),Be=x??je,ct=p??Be.view,bt=w.useCallback(re=>{p||Be.setView(re),f==null||f(re)},[p,f,Be]),kt=$e.find(re=>re.key===ct)??$e[0],ze=re=>{he(re),Le(""),Z(!0)},Ye=()=>{Z(!1),he(null),Le(""),Y()},Oe=w.useCallback(async re=>{if(!(!ue||F)&&re.id)try{await W(ue,re.id),setTimeout(()=>Ye(),600)}catch(oe){console.error("Failed to share thread:",oe)}},[Ye,F,ue,W]),De=w.useMemo(()=>{const re=b??[],oe=ke.trim().toLowerCase();return oe?S?re.filter(_e=>S(_e,oe)):re.filter(_e=>`${_e.label} ${_e.secondaryLabel??""}`.toLowerCase().includes(oe)):re},[b,ke,S]),He=ct==="shared",rt=He?C:G,lt=He?P:j,it=He?"No shared conversations yet":"No conversations yet",St=re=>{const oe=re.sharedAt?` • ${Fe(re.sharedAt)}`:"";return`Shared by ${re.sharedByUserId}${oe}`},ht=re=>"sharedByUserId"in re;w.useEffect(()=>{const re=Array.isArray(k)?k:[];if(re.length>0){_.current=!0,X(re);return}j||(_.current=!1,X(re))},[k,j]),w.useEffect(()=>{if(!B.current)return;const re=B.current.querySelector("[data-radix-scroll-area-viewport]");if(!re)return;let oe=null,_e=null;return oe=requestAnimationFrame(()=>{_e=requestAnimationFrame(()=>{re.scrollTop=N.current})}),()=>{oe!==null&&cancelAnimationFrame(oe),_e!==null&&cancelAnimationFrame(_e)}},[G]);const Ct=async re=>{try{E(re),await M(re),a==null||a(re),l==null||l(re)}catch(oe){console.error("Failed to select thread:",oe)}},Et=async()=>{try{Q(!0);const re=await R();re&&(c==null||c(re),a==null||a(re))}catch(re){console.error("Failed to create thread:",re)}finally{Q(!1)}},rn=async(re,oe)=>{if(oe.stopPropagation(),!!confirm("Delete this thread?")){if(B.current){const _e=B.current.querySelector("[data-radix-scroll-area-viewport]");_e&&(N.current=_e.scrollTop)}try{await K(re),d==null||d(re)}catch(_e){console.error("Failed to delete thread:",_e)}}},It=(re,oe)=>{oe.stopPropagation(),z(re.threadId),D(re.title||`Thread ${re.threadId.slice(0,8)}`)},mn=async re=>{if($.trim())try{await U(re,$.trim()),z(null),D("")}catch(oe){console.error("Failed to update title:",oe)}},Rt=()=>{z(null),D("")},Fe=re=>{if(!re)return"";try{const oe=new Date(re),pe=new Date().getTime()-oe.getTime(),Ae=Math.floor(pe/(1e3*60*60*24));return Ae===0?oe.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):Ae===1?"Yesterday":Ae<7?`${Ae} days ago`:oe.toLocaleDateString()}catch{return""}},Ue=re=>re.title||`Thread ${re.threadId.slice(0,8)}`,Mt=re=>{const oe=Ue(re);return oe.length<=hm?oe:`${oe.slice(0,hm)}...`};return u.jsxs("div",{className:`flex flex-col h-full ${e} ${s.container||""}`,children:[g&&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(Ze,{onClick:Et,disabled:J||j,className:s.createButton||"px-3 py-2 gap-1",size:"sm",variant:"ghost",title:J?"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(Ze,{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:kt.label})}),u.jsx(ho,{align:"start",sideOffset:6,className:"w-40",children:$e.map(re=>u.jsxs(Fn,{className:"justify-between text-[12px]",onClick:oe=>{oe.preventDefault(),bt(re.key)},children:[u.jsx("span",{children:re.label}),ct===re.key&&u.jsx(le.Check,{className:"h-3 w-3"})]},re.key))})]})]})]}),u.jsx(Rl,{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:lt?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…"})]}):rt.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:it})]}):rt.slice().sort((re,oe)=>new Date(oe.updatedAt||oe.createdAt||"").getTime()-new Date(re.updatedAt||re.createdAt||"").getTime()).map(re=>u.jsx(pm,{thread:re,isActive:I===re.threadId,editingThreadId:L,editingTitle:$,onSelect:Ct,onStartEditing:It,onEditingTitleChange:oe=>D(oe),onSaveEditing:mn,onCancelEditing:Rt,onShare:()=>ze(re.threadId),onDelete:rn,showEditTitle:r,showDeleteButton:n,formatDate:Fe,getDisplayThreadTitle:Mt,secondaryLine:He&&ht(re)?St(re):void 0,itemClassName:s.threadItem,activeItemClassName:s.activeThread},re.threadId))})}),u.jsx(tl,{open:ie,onOpenChange:re=>!re&&Ye(),children:u.jsxs(Hs,{className:"max-w-md p-0",children:[u.jsx(Us,{children:u.jsx(Ws,{children:"Share thread"})}),u.jsxs(Sl,{children:[u.jsx(Cl,{autoFocus:!0,value:ke,onValueChange:re=>Le(re),placeholder:"Search for recipients..."}),u.jsxs(Tl,{children:[q&&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:q.startsWith("Failed")?"text-red-500":q.startsWith("Shared")?"text-emerald-500":"text-slate-600 dark:text-slate-400",children:q})]}),u.jsx(kl,{children:y?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"}),De.length>0&&u.jsx(El,{heading:"Recipients",children:De.map(re=>u.jsx(Il,{onSelect:()=>Oe(re),children:u.jsxs("div",{className:"flex flex-col items-start text-sm",children:[u.jsx("span",{className:"font-medium",children:re.label}),re.secondaryLabel&&u.jsx("span",{className:"text-xs text-muted-foreground",children:re.secondaryLabel})]})},re.id))})]})]})]})})]})}function Kk({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(wr,{...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(wr,{...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(wr,{...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 qk({apiConfig:e,className:t="",onError:n}){return u.jsx(wr,{apiConfig:e,onError:n,children:u.jsx("div",{className:`h-full ${t}`,children:u.jsx(Or,{})})})}function Gk({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 Yk({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(wr,{...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(Ze,{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(Ze,{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(Ze,{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(Gk,{placeholder:t,onMessageSent:r})})]})})}):null}function Xk({label:e="New chat",children:t,className:n,variant:r="ghost",size:o="sm",...s}){return u.jsxs(Ze,{variant:r,size:o,className:ne("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 Jk="Label",xm=h.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())}}));xm.displayName=Jk;var vm=xm;const Zk=Hr.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),bm=h.forwardRef(({className:e,...t},n)=>u.jsx(vm,{ref:n,className:ne(Zk(),e),...t}));bm.displayName=vm.displayName;function wm(e){const t=h.useRef({value:e,previous:e});return h.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var ym=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"}),Qk="VisuallyHidden",si=h.forwardRef((e,t)=>u.jsx(me.span,{...e,ref:t,style:{...ym,...e.style}}));si.displayName=Qk;var eE=si,tE=[" ","Enter","ArrowUp","ArrowDown"],nE=[" ","Enter"],dr="Select",[ii,ai,rE]=Jo(dr),[Fr,WN]=an(dr,[rE,Ir]),li=Ir(),[oE,Gn]=Fr(dr),[sE,iE]=Fr(dr),Sm=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:l,dir:c,name:d,autoComplete:p,disabled:m,required:f,form:v}=e,x=li(t),[g,b]=h.useState(null),[y,S]=h.useState(null),[k,C]=h.useState(!1),T=Zo(c),[E,j]=On({prop:r,defaultProp:o??!1,onChange:s,caller:dr}),[P,O]=On({prop:i,defaultProp:a,onChange:l,caller:dr}),F=h.useRef(null),q=g?v||!!g.closest("form"):!0,[Y,R]=h.useState(new Set),K=Array.from(Y).map(U=>U.props.value).join(";");return u.jsx(ia,{...x,children:u.jsxs(oE,{required:f,scope:t,trigger:g,onTriggerChange:b,valueNode:y,onValueNodeChange:S,valueNodeHasChildren:k,onValueNodeHasChildrenChange:C,contentId:At(),value:P,onValueChange:O,open:E,onOpenChange:j,dir:T,triggerPointerDownPosRef:F,disabled:m,children:[u.jsx(ii.Provider,{scope:t,children:u.jsx(sE,{scope:e.__scopeSelect,onNativeOptionAdd:h.useCallback(U=>{R(W=>new Set(W).add(U))},[]),onNativeOptionRemove:h.useCallback(U=>{R(W=>{const M=new Set(W);return M.delete(U),M})},[]),children:n})}),q?u.jsxs(Km,{"aria-hidden":!0,required:f,tabIndex:-1,name:d,autoComplete:p,value:P,onChange:U=>O(U.target.value),disabled:m,form:v,children:[P===void 0?u.jsx("option",{value:""}):null,Array.from(Y)]},K):null]})})};Sm.displayName=dr;var Cm="SelectTrigger",Tm=h.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=li(n),i=Gn(Cm,n),a=i.disabled||r,l=Re(t,i.onTriggerChange),c=ai(n),d=h.useRef("touch"),[p,m,f]=Gm(x=>{const g=c().filter(S=>!S.disabled),b=g.find(S=>S.value===i.value),y=Ym(g,x,b);y!==void 0&&i.onValueChange(y.value)}),v=x=>{a||(i.onOpenChange(!0),f()),x&&(i.triggerPointerDownPosRef.current={x:Math.round(x.pageX),y:Math.round(x.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":qm(i.value)?"":void 0,...o,ref:l,onClick:ae(o.onClick,x=>{x.currentTarget.focus(),d.current!=="mouse"&&v(x)}),onPointerDown:ae(o.onPointerDown,x=>{d.current=x.pointerType;const g=x.target;g.hasPointerCapture(x.pointerId)&&g.releasePointerCapture(x.pointerId),x.button===0&&x.ctrlKey===!1&&x.pointerType==="mouse"&&(v(x),x.preventDefault())}),onKeyDown:ae(o.onKeyDown,x=>{const g=p.current!=="";!(x.ctrlKey||x.altKey||x.metaKey)&&x.key.length===1&&m(x.key),!(g&&x.key===" ")&&tE.includes(x.key)&&(v(),x.preventDefault())})})})});Tm.displayName=Cm;var km="SelectValue",Em=h.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=Gn(km,n),{onValueNodeHasChildrenChange:c}=l,d=s!==void 0,p=Re(t,l.onValueNodeChange);return Tt(()=>{c(d)},[c,d]),u.jsx(me.span,{...a,ref:p,style:{pointerEvents:"none"},children:qm(l.value)?u.jsx(u.Fragment,{children:i}):s})});Em.displayName=km;var aE="SelectIcon",Im=h.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return u.jsx(me.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});Im.displayName=aE;var lE="SelectPortal",Nm=e=>u.jsx(io,{asChild:!0,...e});Nm.displayName=lE;var fr="SelectContent",Am=h.forwardRef((e,t)=>{const n=Gn(fr,e.__scopeSelect),[r,o]=h.useState();if(Tt(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?Ur.createPortal(u.jsx(jm,{scope:e.__scopeSelect,children:u.jsx(ii.Slot,{scope:e.__scopeSelect,children:u.jsx("div",{children:e.children})})}),s):null}return u.jsx(_m,{...e,ref:t})});Am.displayName=fr;var pn=10,[jm,Yn]=Fr(fr),cE="SelectContentImpl",uE=Kt.createSlot("SelectContent.RemoveScroll"),_m=h.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:p,collisionBoundary:m,collisionPadding:f,sticky:v,hideWhenDetached:x,avoidCollisions:g,...b}=e,y=Gn(fr,n),[S,k]=h.useState(null),[C,T]=h.useState(null),E=Re(t,$=>k($)),[j,P]=h.useState(null),[O,F]=h.useState(null),q=ai(n),[Y,R]=h.useState(!1),K=h.useRef(!1);h.useEffect(()=>{if(S)return pa(S)},[S]),Wi();const U=h.useCallback($=>{const[D,...J]=q().map(Z=>Z.ref.current),[Q]=J.slice(-1),ie=document.activeElement;for(const Z of $)if(Z===ie||(Z==null||Z.scrollIntoView({block:"nearest"}),Z===D&&C&&(C.scrollTop=0),Z===Q&&C&&(C.scrollTop=C.scrollHeight),Z==null||Z.focus(),document.activeElement!==ie))return},[q,C]),W=h.useCallback(()=>U([j,S]),[U,j,S]);h.useEffect(()=>{Y&&W()},[Y,W]);const{onOpenChange:M,triggerPointerDownPosRef:I}=y;h.useEffect(()=>{if(S){let $={x:0,y:0};const D=Q=>{var ie,Z;$={x:Math.abs(Math.round(Q.pageX)-(((ie=I.current)==null?void 0:ie.x)??0)),y:Math.abs(Math.round(Q.pageY)-(((Z=I.current)==null?void 0:Z.y)??0))}},J=Q=>{$.x<=10&&$.y<=10?Q.preventDefault():S.contains(Q.target)||M(!1),document.removeEventListener("pointermove",D),I.current=null};return I.current!==null&&(document.addEventListener("pointermove",D),document.addEventListener("pointerup",J,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",D),document.removeEventListener("pointerup",J,{capture:!0})}}},[S,M,I]),h.useEffect(()=>{const $=()=>M(!1);return window.addEventListener("blur",$),window.addEventListener("resize",$),()=>{window.removeEventListener("blur",$),window.removeEventListener("resize",$)}},[M]);const[G,X]=Gm($=>{const D=q().filter(ie=>!ie.disabled),J=D.find(ie=>ie.ref.current===document.activeElement),Q=Ym(D,$,J);Q&&setTimeout(()=>Q.ref.current.focus())}),_=h.useCallback(($,D,J)=>{const Q=!K.current&&!J;(y.value!==void 0&&y.value===D||Q)&&(P($),Q&&(K.current=!0))},[y.value]),B=h.useCallback(()=>S==null?void 0:S.focus(),[S]),N=h.useCallback(($,D,J)=>{const Q=!K.current&&!J;(y.value!==void 0&&y.value===D||Q)&&F($)},[y.value]),L=r==="popper"?Ol:Pm,z=L===Ol?{side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:p,collisionBoundary:m,collisionPadding:f,sticky:v,hideWhenDetached:x,avoidCollisions:g}:{};return u.jsx(jm,{scope:n,content:S,viewport:C,onViewportChange:T,itemRefCallback:_,selectedItem:j,onItemLeave:B,itemTextRefCallback:N,focusSelectedItem:W,selectedItemText:O,position:r,isPositioned:Y,searchRef:G,children:u.jsx(vs,{as:uE,allowPinchZoom:!0,children:u.jsx(Qo,{asChild:!0,trapped:y.open,onMountAutoFocus:$=>{$.preventDefault()},onUnmountAutoFocus:ae(o,$=>{var D;(D=y.trigger)==null||D.focus({preventScroll:!0}),$.preventDefault()}),children:u.jsx(Sr,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:$=>$.preventDefault(),onDismiss:()=>y.onOpenChange(!1),children:u.jsx(L,{role:"listbox",id:y.contentId,"data-state":y.open?"open":"closed",dir:y.dir,onContextMenu:$=>$.preventDefault(),...b,...z,onPlaced:()=>R(!0),ref:E,style:{display:"flex",flexDirection:"column",outline:"none",...b.style},onKeyDown:ae(b.onKeyDown,$=>{const D=$.ctrlKey||$.altKey||$.metaKey;if($.key==="Tab"&&$.preventDefault(),!D&&$.key.length===1&&X($.key),["ArrowUp","ArrowDown","Home","End"].includes($.key)){let Q=q().filter(ie=>!ie.disabled).map(ie=>ie.ref.current);if(["ArrowUp","End"].includes($.key)&&(Q=Q.slice().reverse()),["ArrowUp","ArrowDown"].includes($.key)){const ie=$.target,Z=Q.indexOf(ie);Q=Q.slice(Z+1)}setTimeout(()=>U(Q)),$.preventDefault()}})})})})})})});_m.displayName=cE;var dE="SelectItemAlignedPosition",Pm=h.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=Gn(fr,n),i=Yn(fr,n),[a,l]=h.useState(null),[c,d]=h.useState(null),p=Re(t,E=>d(E)),m=ai(n),f=h.useRef(!1),v=h.useRef(!0),{viewport:x,selectedItem:g,selectedItemText:b,focusSelectedItem:y}=i,S=h.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&c&&x&&g&&b){const E=s.trigger.getBoundingClientRect(),j=c.getBoundingClientRect(),P=s.valueNode.getBoundingClientRect(),O=b.getBoundingClientRect();if(s.dir!=="rtl"){const ie=O.left-j.left,Z=P.left-ie,ue=E.left-Z,he=E.width+ue,ke=Math.max(he,j.width),Le=window.innerWidth-pn,$e=Nl(Z,[pn,Math.max(pn,Le-ke)]);a.style.minWidth=he+"px",a.style.left=$e+"px"}else{const ie=j.right-O.right,Z=window.innerWidth-P.right-ie,ue=window.innerWidth-E.right-Z,he=E.width+ue,ke=Math.max(he,j.width),Le=window.innerWidth-pn,$e=Nl(Z,[pn,Math.max(pn,Le-ke)]);a.style.minWidth=he+"px",a.style.right=$e+"px"}const F=m(),q=window.innerHeight-pn*2,Y=x.scrollHeight,R=window.getComputedStyle(c),K=parseInt(R.borderTopWidth,10),U=parseInt(R.paddingTop,10),W=parseInt(R.borderBottomWidth,10),M=parseInt(R.paddingBottom,10),I=K+U+Y+M+W,G=Math.min(g.offsetHeight*5,I),X=window.getComputedStyle(x),_=parseInt(X.paddingTop,10),B=parseInt(X.paddingBottom,10),N=E.top+E.height/2-pn,L=q-N,z=g.offsetHeight/2,$=g.offsetTop+z,D=K+U+$,J=I-D;if(D<=N){const ie=F.length>0&&g===F[F.length-1].ref.current;a.style.bottom="0px";const Z=c.clientHeight-x.offsetTop-x.offsetHeight,ue=Math.max(L,z+(ie?B:0)+Z+W),he=D+ue;a.style.height=he+"px"}else{const ie=F.length>0&&g===F[0].ref.current;a.style.top="0px";const ue=Math.max(N,K+x.offsetTop+(ie?_:0)+z)+J;a.style.height=ue+"px",x.scrollTop=D-N+x.offsetTop}a.style.margin=`${pn}px 0`,a.style.minHeight=G+"px",a.style.maxHeight=q+"px",r==null||r(),requestAnimationFrame(()=>f.current=!0)}},[m,s.trigger,s.valueNode,a,c,x,g,b,s.dir,r]);Tt(()=>S(),[S]);const[k,C]=h.useState();Tt(()=>{c&&C(window.getComputedStyle(c).zIndex)},[c]);const T=h.useCallback(E=>{E&&v.current===!0&&(S(),y==null||y(),v.current=!1)},[S,y]);return u.jsx(pE,{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:p,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Pm.displayName=dE;var fE="SelectPopperPosition",Ol=h.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=pn,...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)"}})});Ol.displayName=fE;var[pE,Dl]=Fr(fr,{}),Ll="SelectViewport",Rm=h.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=Yn(Ll,n),i=Dl(Ll,n),a=Re(t,s.onViewportChange),l=h.useRef(0);return u.jsxs(u.Fragment,{children:[u.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),u.jsx(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:p,shouldExpandOnScrollRef:m}=i;if(m!=null&&m.current&&p){const f=Math.abs(l.current-d.scrollTop);if(f>0){const v=window.innerHeight-pn*2,x=parseFloat(p.style.minHeight),g=parseFloat(p.style.height),b=Math.max(x,g);if(b<v){const y=b+f,S=Math.min(v,y),k=y-S;p.style.height=S+"px",p.style.bottom==="0px"&&(d.scrollTop=k>0?k:0,p.style.justifyContent="flex-end")}}}l.current=d.scrollTop})})})]})});Rm.displayName=Ll;var Mm="SelectGroup",[hE,mE]=Fr(Mm),gE=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=At();return u.jsx(hE,{scope:n,id:o,children:u.jsx(me.div,{role:"group","aria-labelledby":o,...r,ref:t})})});gE.displayName=Mm;var Om="SelectLabel",Dm=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=mE(Om,n);return u.jsx(me.div,{id:o.id,...r,ref:t})});Dm.displayName=Om;var ci="SelectItem",[xE,Lm]=Fr(ci),$m=h.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=Gn(ci,n),l=Yn(ci,n),c=a.value===r,[d,p]=h.useState(s??""),[m,f]=h.useState(!1),v=Re(t,y=>{var S;return(S=l.itemRefCallback)==null?void 0:S.call(l,y,r,o)}),x=At(),g=h.useRef("touch"),b=()=>{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(xE,{scope:n,value:r,disabled:o,textId:x,isSelected:c,onItemTextChange:h.useCallback(y=>{p(S=>S||((y==null?void 0:y.textContent)??"").trim())},[]),children:u.jsx(ii.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:u.jsx(me.div,{role:"option","aria-labelledby":x,"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,()=>{g.current!=="mouse"&&b()}),onPointerUp:ae(i.onPointerUp,()=>{g.current==="mouse"&&b()}),onPointerDown:ae(i.onPointerDown,y=>{g.current=y.pointerType}),onPointerMove:ae(i.onPointerMove,y=>{var S;g.current=y.pointerType,o?(S=l.onItemLeave)==null||S.call(l):g.current==="mouse"&&y.currentTarget.focus({preventScroll:!0})}),onPointerLeave:ae(i.onPointerLeave,y=>{var S;y.currentTarget===document.activeElement&&((S=l.onItemLeave)==null||S.call(l))}),onKeyDown:ae(i.onKeyDown,y=>{var k;((k=l.searchRef)==null?void 0:k.current)!==""&&y.key===" "||(nE.includes(y.key)&&b(),y.key===" "&&y.preventDefault())})})})})});$m.displayName=ci;var _o="SelectItemText",Fm=h.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=Gn(_o,n),a=Yn(_o,n),l=Lm(_o,n),c=iE(_o,n),[d,p]=h.useState(null),m=Re(t,b=>p(b),l.onItemTextChange,b=>{var y;return(y=a.itemTextRefCallback)==null?void 0:y.call(a,b,l.value,l.disabled)}),f=d==null?void 0:d.textContent,v=h.useMemo(()=>u.jsx("option",{value:l.value,disabled:l.disabled,children:f},l.value),[l.disabled,l.value,f]),{onNativeOptionAdd:x,onNativeOptionRemove:g}=c;return Tt(()=>(x(v),()=>g(v)),[x,g,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]})});Fm.displayName=_o;var Bm="SelectItemIndicator",zm=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return Lm(Bm,n).isSelected?u.jsx(me.span,{"aria-hidden":!0,...r,ref:t}):null});zm.displayName=Bm;var $l="SelectScrollUpButton",Hm=h.forwardRef((e,t)=>{const n=Yn($l,e.__scopeSelect),r=Dl($l,e.__scopeSelect),[o,s]=h.useState(!1),i=Re(t,r.onScrollButtonChange);return Tt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const c=l.scrollTop>0;s(c)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?u.jsx(Wm,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});Hm.displayName=$l;var Fl="SelectScrollDownButton",Um=h.forwardRef((e,t)=>{const n=Yn(Fl,e.__scopeSelect),r=Dl(Fl,e.__scopeSelect),[o,s]=h.useState(!1),i=Re(t,r.onScrollButtonChange);return Tt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const c=l.scrollHeight-l.clientHeight,d=Math.ceil(l.scrollTop)<c;s(d)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?u.jsx(Wm,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});Um.displayName=Fl;var Wm=h.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=Yn("SelectScrollButton",n),i=h.useRef(null),a=ai(n),l=h.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return h.useEffect(()=>()=>l(),[l]),Tt(()=>{var d;const c=a().find(p=>p.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()})})}),vE="SelectSeparator",Vm=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return u.jsx(me.div,{"aria-hidden":!0,...r,ref:t})});Vm.displayName=vE;var Bl="SelectArrow",bE=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=li(n),s=Gn(Bl,n),i=Yn(Bl,n);return s.open&&i.position==="popper"?u.jsx(ca,{...o,...r,ref:t}):null});bE.displayName=Bl;var wE="SelectBubbleInput",Km=h.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=h.useRef(null),s=Re(r,o),i=wm(t);return h.useEffect(()=>{const a=o.current;if(!a)return;const l=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(l,"value").set;if(i!==t&&d){const p=new Event("change",{bubbles:!0});d.call(a,t),a.dispatchEvent(p)}},[i,t]),u.jsx(me.select,{...n,style:{...ym,...n.style},ref:s,defaultValue:t})});Km.displayName=wE;function qm(e){return e===""||e===void 0}function Gm(e){const t=ft(e),n=h.useRef(""),r=h.useRef(0),o=h.useCallback(i=>{const a=n.current+i;t(a),function l(c){n.current=c,window.clearTimeout(r.current),c!==""&&(r.current=window.setTimeout(()=>l(""),1e3))}(a)},[t]),s=h.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return h.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function Ym(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=yE(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 yE(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var SE=Sm,Xm=Tm,CE=Em,TE=Im,kE=Nm,Jm=Am,EE=Rm,Zm=Dm,Qm=$m,IE=Fm,NE=zm,eg=Hm,tg=Um,ng=Vm;const AE=SE,jE=CE,rg=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Xm,{ref:r,className:ne("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[t,u.jsx(TE,{asChild:!0,children:u.jsx(le.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));rg.displayName=Xm.displayName;const og=h.forwardRef(({className:e,...t},n)=>u.jsx(eg,{ref:n,className:ne("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(le.ChevronUp,{className:"h-4 w-4"})}));og.displayName=eg.displayName;const sg=h.forwardRef(({className:e,...t},n)=>u.jsx(tg,{ref:n,className:ne("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(le.ChevronDown,{className:"h-4 w-4"})}));sg.displayName=tg.displayName;const ig=h.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>u.jsx(kE,{children:u.jsxs(Jm,{ref:o,className:ne("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...r,children:[u.jsx(og,{}),u.jsx(EE,{className:ne("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),u.jsx(sg,{})]})}));ig.displayName=Jm.displayName;const _E=h.forwardRef(({className:e,...t},n)=>u.jsx(Zm,{ref:n,className:ne("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));_E.displayName=Zm.displayName;const ag=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Qm,{ref:r,className:ne("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[u.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx(NE,{children:u.jsx(le.Check,{className:"h-4 w-4"})})}),u.jsx(IE,{children:t})]}));ag.displayName=Qm.displayName;const PE=h.forwardRef(({className:e,...t},n)=>u.jsx(ng,{ref:n,className:ne("-mx-1 my-1 h-px bg-muted",e),...t}));PE.displayName=ng.displayName;var RE="Separator",lg="horizontal",ME=["horizontal","vertical"],cg=h.forwardRef((e,t)=>{const{decorative:n,orientation:r=lg,...o}=e,s=OE(r)?r:lg,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})});cg.displayName=RE;function OE(e){return ME.includes(e)}var ug=cg;const dg=h.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>u.jsx(ug,{ref:o,decorative:n,orientation:t,className:ne("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));dg.displayName=ug.displayName;var ui="Switch",[DE,VN]=an(ui),[LE,$E]=DE(ui),fg=h.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:s,required:i,disabled:a,value:l="on",onCheckedChange:c,form:d,...p}=e,[m,f]=h.useState(null),v=Re(t,S=>f(S)),x=h.useRef(!1),g=m?d||!!m.closest("form"):!0,[b,y]=On({prop:o,defaultProp:s??!1,onChange:c,caller:ui});return u.jsxs(LE,{scope:n,checked:b,disabled:a,children:[u.jsx(me.button,{type:"button",role:"switch","aria-checked":b,"aria-required":i,"data-state":gg(b),"data-disabled":a?"":void 0,disabled:a,value:l,...p,ref:v,onClick:ae(e.onClick,S=>{y(k=>!k),g&&(x.current=S.isPropagationStopped(),x.current||S.stopPropagation())})}),g&&u.jsx(mg,{control:m,bubbles:!x.current,name:r,value:l,checked:b,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});fg.displayName=ui;var pg="SwitchThumb",hg=h.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=$E(pg,n);return u.jsx(me.span,{"data-state":gg(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});hg.displayName=pg;var FE="SwitchBubbleInput",mg=h.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=h.useRef(null),a=Re(i,s),l=wm(n),c=yd(t);return h.useEffect(()=>{const d=i.current;if(!d)return;const p=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(p,"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}})});mg.displayName=FE;function gg(e){return e?"checked":"unchecked"}var xg=fg,BE=hg;const vg=h.forwardRef(({className:e,...t},n)=>u.jsx(xg,{className:ne("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...t,ref:n,children:u.jsx(BE,{className:ne("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));vg.displayName=xg.displayName;const zE=Qa,HE=gT,UE=el,bg=h.forwardRef(({className:e,...t},n)=>u.jsx(ko,{className:ne("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t,ref:n}));bg.displayName=ko.displayName;const WE=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"}}),wg=h.forwardRef(({side:e="right",className:t,children:n,...r},o)=>u.jsxs(UE,{children:[u.jsx(bg,{}),u.jsxs(Eo,{ref:o,className:ne(WE({side:e}),t),...r,children:[n,u.jsxs(ah,{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"})]})]})]}));wg.displayName=Eo.displayName;const yg=({className:e,...t})=>u.jsx("div",{className:ne("flex flex-col space-y-2 text-center sm:text-left",e),...t});yg.displayName="SheetHeader";const Sg=h.forwardRef(({className:e,...t},n)=>u.jsx(lr,{ref:n,className:ne("text-lg font-semibold text-foreground",e),...t}));Sg.displayName=lr.displayName;const Cg=h.forwardRef(({className:e,...t},n)=>u.jsx(zs,{ref:n,className:ne("text-sm text-muted-foreground",e),...t}));Cg.displayName=zs.displayName;var[di,KN]=an("Tooltip",[Ir]),fi=Ir(),Tg="TooltipProvider",VE=700,zl="tooltip.open",[KE,Hl]=di(Tg),kg=e=>{const{__scopeTooltip:t,delayDuration:n=VE,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:s}=e,i=h.useRef(!0),a=h.useRef(!1),l=h.useRef(0);return h.useEffect(()=>{const c=l.current;return()=>window.clearTimeout(c)},[]),u.jsx(KE,{scope:t,isOpenDelayedRef:i,delayDuration:n,onOpen:h.useCallback(()=>{window.clearTimeout(l.current),i.current=!1},[]),onClose:h.useCallback(()=>{window.clearTimeout(l.current),l.current=window.setTimeout(()=>i.current=!0,r)},[r]),isPointerInTransitRef:a,onPointerInTransitChange:h.useCallback(c=>{a.current=c},[]),disableHoverableContent:o,children:s})};kg.displayName=Tg;var Po="Tooltip",[qE,pi]=di(Po),Eg=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:s,disableHoverableContent:i,delayDuration:a}=e,l=Hl(Po,e.__scopeTooltip),c=fi(t),[d,p]=h.useState(null),m=At(),f=h.useRef(0),v=i??l.disableHoverableContent,x=a??l.delayDuration,g=h.useRef(!1),[b,y]=On({prop:r,defaultProp:o??!1,onChange:E=>{E?(l.onOpen(),document.dispatchEvent(new CustomEvent(zl))):l.onClose(),s==null||s(E)},caller:Po}),S=h.useMemo(()=>b?g.current?"delayed-open":"instant-open":"closed",[b]),k=h.useCallback(()=>{window.clearTimeout(f.current),f.current=0,g.current=!1,y(!0)},[y]),C=h.useCallback(()=>{window.clearTimeout(f.current),f.current=0,y(!1)},[y]),T=h.useCallback(()=>{window.clearTimeout(f.current),f.current=window.setTimeout(()=>{g.current=!0,y(!0),f.current=0},x)},[x,y]);return h.useEffect(()=>()=>{f.current&&(window.clearTimeout(f.current),f.current=0)},[]),u.jsx(ia,{...c,children:u.jsx(qE,{scope:t,contentId:m,open:b,stateAttribute:S,trigger:d,onTriggerChange:p,onTriggerEnter:h.useCallback(()=>{l.isOpenDelayedRef.current?T():k()},[l.isOpenDelayedRef,T,k]),onTriggerLeave:h.useCallback(()=>{v?C():(window.clearTimeout(f.current),f.current=0)},[C,v]),onOpen:k,onClose:C,disableHoverableContent:v,children:n})})};Eg.displayName=Po;var Ul="TooltipTrigger",Ig=h.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=pi(Ul,n),s=Hl(Ul,n),i=fi(n),a=h.useRef(null),l=Re(t,a,o.onTriggerChange),c=h.useRef(!1),d=h.useRef(!1),p=h.useCallback(()=>c.current=!1,[]);return h.useEffect(()=>()=>document.removeEventListener("pointerup",p),[p]),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",p,{once:!0})}),onFocus:ae(e.onFocus,()=>{c.current||o.onOpen()}),onBlur:ae(e.onBlur,o.onClose),onClick:ae(e.onClick,o.onClose)})})});Ig.displayName=Ul;var GE="TooltipPortal",[qN,YE]=di(GE,{forceMount:void 0}),Br="TooltipContent",Ng=h.forwardRef((e,t)=>{const n=YE(Br,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...s}=e,i=pi(Br,e.__scopeTooltip);return u.jsx(zt,{present:r||i.open,children:i.disableHoverableContent?u.jsx(Ag,{side:o,...s,ref:t}):u.jsx(XE,{side:o,...s,ref:t})})}),XE=h.forwardRef((e,t)=>{const n=pi(Br,e.__scopeTooltip),r=Hl(Br,e.__scopeTooltip),o=h.useRef(null),s=Re(t,o),[i,a]=h.useState(null),{trigger:l,onClose:c}=n,d=o.current,{onPointerInTransitChange:p}=r,m=h.useCallback(()=>{a(null),p(!1)},[p]),f=h.useCallback((v,x)=>{const g=v.currentTarget,b={x:v.clientX,y:v.clientY},y=tI(b,g.getBoundingClientRect()),S=nI(b,y),k=rI(x.getBoundingClientRect()),C=sI([...S,...k]);a(C),p(!0)},[p]);return h.useEffect(()=>()=>m(),[m]),h.useEffect(()=>{if(l&&d){const v=g=>f(g,d),x=g=>f(g,l);return l.addEventListener("pointerleave",v),d.addEventListener("pointerleave",x),()=>{l.removeEventListener("pointerleave",v),d.removeEventListener("pointerleave",x)}}},[l,d,f,m]),h.useEffect(()=>{if(i){const v=x=>{const g=x.target,b={x:x.clientX,y:x.clientY},y=(l==null?void 0:l.contains(g))||(d==null?void 0:d.contains(g)),S=!oI(b,i);y?m():S&&(m(),c())};return document.addEventListener("pointermove",v),()=>document.removeEventListener("pointermove",v)}},[l,d,i,c,m]),u.jsx(Ag,{...e,ref:s})}),[JE,ZE]=di(Po,{isInside:!1}),QE=Kt.createSlottable("TooltipContent"),Ag=h.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:s,onPointerDownOutside:i,...a}=e,l=pi(Br,n),c=fi(n),{onClose:d}=l;return h.useEffect(()=>(document.addEventListener(zl,d),()=>document.removeEventListener(zl,d)),[d]),h.useEffect(()=>{if(l.trigger){const p=m=>{const f=m.target;f!=null&&f.contains(l.trigger)&&d()};return window.addEventListener("scroll",p,{capture:!0}),()=>window.removeEventListener("scroll",p,{capture:!0})}},[l.trigger,d]),u.jsx(Sr,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:p=>p.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(QE,{children:r}),u.jsx(JE,{scope:n,isInside:!0,children:u.jsx(eE,{id:l.contentId,role:"tooltip",children:o||r})})]})})});Ng.displayName=Br;var jg="TooltipArrow",eI=h.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=fi(n);return ZE(jg,n).isInside?null:u.jsx(ca,{...o,...r,ref:t})});eI.displayName=jg;function tI(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 nI(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 rI(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 oI(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,p=l.x,m=l.y;d>r!=m>r&&n<(p-c)*(r-d)/(m-d)+c&&(o=!o)}return o}function sI(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),iI(t)}function iI(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 aI=kg,lI=Eg,cI=Ig,_g=Ng;const uI=aI,dI=lI,fI=cI,Pg=h.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(_g,{ref:r,sideOffset:t,className:ne("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n}));Pg.displayName=_g.displayName;var Wl="ToastProvider",[Vl,pI,hI]=Jo("Toast"),[Rg,GN]=an("Toast",[hI]),[mI,hi]=Rg(Wl),Mg=e=>{const{__scopeToast:t,label:n="Notification",duration:r=5e3,swipeDirection:o="right",swipeThreshold:s=50,children:i}=e,[a,l]=h.useState(null),[c,d]=h.useState(0),p=h.useRef(!1),m=h.useRef(!1);return n.trim()||console.error(`Invalid prop \`label\` supplied to \`${Wl}\`. Expected non-empty \`string\`.`),u.jsx(Vl.Provider,{scope:t,children:u.jsx(mI,{scope:t,label:n,duration:r,swipeDirection:o,swipeThreshold:s,toastCount:c,viewport:a,onViewportChange:l,onToastAdd:h.useCallback(()=>d(f=>f+1),[]),onToastRemove:h.useCallback(()=>d(f=>f-1),[]),isFocusedToastEscapeKeyDownRef:p,isClosePausedRef:m,children:i})})};Mg.displayName=Wl;var Og="ToastViewport",gI=["F8"],Kl="toast.viewportPause",ql="toast.viewportResume",Dg=h.forwardRef((e,t)=>{const{__scopeToast:n,hotkey:r=gI,label:o="Notifications ({hotkey})",...s}=e,i=hi(Og,n),a=pI(n),l=h.useRef(null),c=h.useRef(null),d=h.useRef(null),p=h.useRef(null),m=Re(t,p,i.onViewportChange),f=r.join("+").replace(/Key/g,"").replace(/Digit/g,""),v=i.toastCount>0;h.useEffect(()=>{const g=b=>{var S;r.length!==0&&r.every(k=>b[k]||b.code===k)&&((S=p.current)==null||S.focus())};return document.addEventListener("keydown",g),()=>document.removeEventListener("keydown",g)},[r]),h.useEffect(()=>{const g=l.current,b=p.current;if(v&&g&&b){const y=()=>{if(!i.isClosePausedRef.current){const T=new CustomEvent(Kl);b.dispatchEvent(T),i.isClosePausedRef.current=!0}},S=()=>{if(i.isClosePausedRef.current){const T=new CustomEvent(ql);b.dispatchEvent(T),i.isClosePausedRef.current=!1}},k=T=>{!g.contains(T.relatedTarget)&&S()},C=()=>{g.contains(document.activeElement)||S()};return g.addEventListener("focusin",y),g.addEventListener("focusout",k),g.addEventListener("pointermove",y),g.addEventListener("pointerleave",C),window.addEventListener("blur",y),window.addEventListener("focus",S),()=>{g.removeEventListener("focusin",y),g.removeEventListener("focusout",k),g.removeEventListener("pointermove",y),g.removeEventListener("pointerleave",C),window.removeEventListener("blur",y),window.removeEventListener("focus",S)}}},[v,i.isClosePausedRef]);const x=h.useCallback(({tabbingDirection:g})=>{const y=a().map(S=>{const k=S.ref.current,C=[k,...AI(k)];return g==="forwards"?C:C.reverse()});return(g==="forwards"?y.reverse():y).flat()},[a]);return h.useEffect(()=>{const g=p.current;if(g){const b=y=>{var C,T,E;const S=y.altKey||y.ctrlKey||y.metaKey;if(y.key==="Tab"&&!S){const j=document.activeElement,P=y.shiftKey;if(y.target===g&&P){(C=c.current)==null||C.focus();return}const q=x({tabbingDirection:P?"backwards":"forwards"}),Y=q.findIndex(R=>R===j);Xl(q.slice(Y+1))?y.preventDefault():P?(T=c.current)==null||T.focus():(E=d.current)==null||E.focus()}};return g.addEventListener("keydown",b),()=>g.removeEventListener("keydown",b)}},[a,x]),u.jsxs(Wb,{ref:l,role:"region","aria-label":o.replace("{hotkey}",f),tabIndex:-1,style:{pointerEvents:v?void 0:"none"},children:[v&&u.jsx(Gl,{ref:c,onFocusFromOutsideViewport:()=>{const g=x({tabbingDirection:"forwards"});Xl(g)}}),u.jsx(Vl.Slot,{scope:n,children:u.jsx(me.ol,{tabIndex:-1,...s,ref:m})}),v&&u.jsx(Gl,{ref:d,onFocusFromOutsideViewport:()=>{const g=x({tabbingDirection:"backwards"});Xl(g)}})]})});Dg.displayName=Og;var Lg="ToastFocusProxy",Gl=h.forwardRef((e,t)=>{const{__scopeToast:n,onFocusFromOutsideViewport:r,...o}=e,s=hi(Lg,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()}})});Gl.displayName=Lg;var Ro="Toast",xI="toast.swipeStart",vI="toast.swipeMove",bI="toast.swipeCancel",wI="toast.swipeEnd",$g=h.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(zt,{present:n||a,children:u.jsx(CI,{open:a,...i,ref:t,onClose:()=>l(!1),onPause:ft(e.onPause),onResume:ft(e.onResume),onSwipeStart:ae(e.onSwipeStart,c=>{c.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:ae(e.onSwipeMove,c=>{const{x:d,y:p}=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",`${p}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:p}=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",`${p}px`),l(!1)})})})});$g.displayName=Ro;var[yI,SI]=Rg(Ro,{onClose(){}}),CI=h.forwardRef((e,t)=>{const{__scopeToast:n,type:r="foreground",duration:o,open:s,onClose:i,onEscapeKeyDown:a,onPause:l,onResume:c,onSwipeStart:d,onSwipeMove:p,onSwipeCancel:m,onSwipeEnd:f,...v}=e,x=hi(Ro,n),[g,b]=h.useState(null),y=Re(t,R=>b(R)),S=h.useRef(null),k=h.useRef(null),C=o||x.duration,T=h.useRef(0),E=h.useRef(C),j=h.useRef(0),{onToastAdd:P,onToastRemove:O}=x,F=ft(()=>{var K;(g==null?void 0:g.contains(document.activeElement))&&((K=x.viewport)==null||K.focus()),i()}),q=h.useCallback(R=>{!R||R===1/0||(window.clearTimeout(j.current),T.current=new Date().getTime(),j.current=window.setTimeout(F,R))},[F]);h.useEffect(()=>{const R=x.viewport;if(R){const K=()=>{q(E.current),c==null||c()},U=()=>{const W=new Date().getTime()-T.current;E.current=E.current-W,window.clearTimeout(j.current),l==null||l()};return R.addEventListener(Kl,U),R.addEventListener(ql,K),()=>{R.removeEventListener(Kl,U),R.removeEventListener(ql,K)}}},[x.viewport,C,l,c,q]),h.useEffect(()=>{s&&!x.isClosePausedRef.current&&q(C)},[s,C,x.isClosePausedRef,q]),h.useEffect(()=>(P(),()=>O()),[P,O]);const Y=h.useMemo(()=>g?Vg(g):null,[g]);return x.viewport?u.jsxs(u.Fragment,{children:[Y&&u.jsx(TI,{__scopeToast:n,role:"status","aria-live":r==="foreground"?"assertive":"polite",children:Y}),u.jsx(yI,{scope:n,onClose:F,children:Ur.createPortal(u.jsx(Vl.ItemSlot,{scope:n,children:u.jsx(Ub,{asChild:!0,onEscapeKeyDown:ae(a,()=>{x.isFocusedToastEscapeKeyDownRef.current||F(),x.isFocusedToastEscapeKeyDownRef.current=!1}),children:u.jsx(me.li,{tabIndex:0,"data-state":s?"open":"closed","data-swipe-direction":x.swipeDirection,...v,ref:y,style:{userSelect:"none",touchAction:"none",...e.style},onKeyDown:ae(e.onKeyDown,R=>{R.key==="Escape"&&(a==null||a(R.nativeEvent),R.nativeEvent.defaultPrevented||(x.isFocusedToastEscapeKeyDownRef.current=!0,F()))}),onPointerDown:ae(e.onPointerDown,R=>{R.button===0&&(S.current={x:R.clientX,y:R.clientY})}),onPointerMove:ae(e.onPointerMove,R=>{if(!S.current)return;const K=R.clientX-S.current.x,U=R.clientY-S.current.y,W=!!k.current,M=["left","right"].includes(x.swipeDirection),I=["left","up"].includes(x.swipeDirection)?Math.min:Math.max,G=M?I(0,K):0,X=M?0:I(0,U),_=R.pointerType==="touch"?10:2,B={x:G,y:X},N={originalEvent:R,delta:B};W?(k.current=B,mi(vI,p,N,{discrete:!1})):Kg(B,x.swipeDirection,_)?(k.current=B,mi(xI,d,N,{discrete:!1}),R.target.setPointerCapture(R.pointerId)):(Math.abs(K)>_||Math.abs(U)>_)&&(S.current=null)}),onPointerUp:ae(e.onPointerUp,R=>{const K=k.current,U=R.target;if(U.hasPointerCapture(R.pointerId)&&U.releasePointerCapture(R.pointerId),k.current=null,S.current=null,K){const W=R.currentTarget,M={originalEvent:R,delta:K};Kg(K,x.swipeDirection,x.swipeThreshold)?mi(wI,f,M,{discrete:!0}):mi(bI,m,M,{discrete:!0}),W.addEventListener("click",I=>I.preventDefault(),{once:!0})}})})})}),x.viewport)})]}):null}),TI=e=>{const{__scopeToast:t,children:n,...r}=e,o=hi(Ro,t),[s,i]=h.useState(!1),[a,l]=h.useState(!1);return II(()=>i(!0)),h.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]})})})},kI="ToastTitle",Fg=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(me.div,{...r,ref:t})});Fg.displayName=kI;var EI="ToastDescription",Bg=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(me.div,{...r,ref:t})});Bg.displayName=EI;var zg="ToastAction",Hg=h.forwardRef((e,t)=>{const{altText:n,...r}=e;return n.trim()?u.jsx(Wg,{altText:n,asChild:!0,children:u.jsx(Yl,{...r,ref:t})}):(console.error(`Invalid prop \`altText\` supplied to \`${zg}\`. Expected non-empty \`string\`.`),null)});Hg.displayName=zg;var Ug="ToastClose",Yl=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e,o=SI(Ug,n);return u.jsx(Wg,{asChild:!0,children:u.jsx(me.button,{type:"button",...r,ref:t,onClick:ae(e.onClick,o.onClose)})})});Yl.displayName=Ug;var Wg=h.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 Vg(e){const t=[];return Array.from(e.childNodes).forEach(r=>{if(r.nodeType===r.TEXT_NODE&&r.textContent&&t.push(r.textContent),NI(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(...Vg(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 Kg=(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 II(e=()=>{}){const t=ft(e);Tt(()=>{let n=0,r=0;return n=window.requestAnimationFrame(()=>r=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(n),window.cancelAnimationFrame(r)}},[t])}function NI(e){return e.nodeType===e.ELEMENT_NODE}function AI(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 Xl(e){const t=document.activeElement;return e.some(n=>n===t?!0:(n.focus(),document.activeElement!==t))}var jI=Mg,qg=Dg,Gg=$g,Yg=Fg,Xg=Bg,Jg=Hg,Zg=Yl;const _I=jI,Qg=h.forwardRef(({className:e,...t},n)=>u.jsx(qg,{ref:n,className:ne("fixed bottom-0 right-0 z-[100] flex max-h-screen w-full flex-col p-4 md:max-w-[420px]",e),...t}));Qg.displayName=qg.displayName;const PI=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"}}),ex=h.forwardRef(({className:e,variant:t,...n},r)=>u.jsx(Gg,{ref:r,className:ne(PI({variant:t}),e),...n}));ex.displayName=Gg.displayName;const RI=h.forwardRef(({className:e,...t},n)=>u.jsx(Jg,{ref:n,className:ne("inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors hover:bg-secondary focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive",e),...t}));RI.displayName=Jg.displayName;const tx=h.forwardRef(({className:e,...t},n)=>u.jsx(Zg,{ref:n,className:ne("absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-2 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",e),"toast-close":"",...t,children:u.jsx(le.X,{className:"h-4 w-4"})}));tx.displayName=Zg.displayName;const nx=h.forwardRef(({className:e,...t},n)=>u.jsx(Yg,{ref:n,className:ne("text-sm font-semibold",e),...t}));nx.displayName=Yg.displayName;const rx=h.forwardRef(({className:e,...t},n)=>u.jsx(Xg,{ref:n,className:ne("text-sm opacity-90",e),...t}));rx.displayName=Xg.displayName;function MI(){const{toasts:e}=ol();return u.jsxs(_I,{children:[e.map(function({id:t,title:n,description:r,action:o,...s}){return u.jsxs(ex,{...s,children:[u.jsxs("div",{className:"grid gap-1",children:[n&&u.jsx(nx,{children:n}),r&&u.jsx(rx,{children:r})]}),o,u.jsx(tx,{})]},t)}),u.jsx(Qg,{})]})}var OI=(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 x=v==="class",g=x&&s?o.map(b=>s[b]||b):o;x?(l.classList.remove(...g),l.classList.add(s&&s[f]?s[f]:f)):l.setAttribute(v,f)}),p(f)}function p(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{}},DI=h.createContext(void 0),LI={setTheme:e=>{},themes:[]},$I=()=>{var e;return(e=h.useContext(DI))!=null?e:LI};h.memo(({forcedTheme:e,storageKey:t,attribute:n,enableSystem:r,enableColorScheme:o,defaultTheme:s,value:i,themes:a,nonce:l,scriptProps:c})=>{let d=JSON.stringify([n,t,s,e,a,i,r,o]).slice(1,-1);return h.createElement("script",{...c,suppressHydrationWarning:!0,nonce:typeof window>"u"?l:"",dangerouslySetInnerHTML:{__html:`(${OI.toString()})(${d})`}})});var FI=e=>{switch(e){case"success":return HI;case"info":return WI;case"warning":return UI;case"error":return VI;default:return null}},BI=Array(12).fill(0),zI=({visible:e,className:t})=>w.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},w.createElement("div",{className:"sonner-spinner"},BI.map((n,r)=>w.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),HI=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"})),UI=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"})),WI=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"})),VI=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"})),KI=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"})),qI=()=>{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},Jl=1,GI=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:Jl++,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(XI(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)||Jl++;return this.create({jsx:e(n),id:n,...t}),n},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},Wt=new GI,YI=(e,t)=>{let n=(t==null?void 0:t.id)||Jl++;return Wt.addToast({title:e,...t,id:n}),n},XI=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",JI=YI,ZI=()=>Wt.toasts,QI=()=>Wt.getActiveToasts();Object.assign(JI,{success:Wt.success,info:Wt.info,warning:Wt.warning,error:Wt.error,custom:Wt.custom,message:Wt.message,promise:Wt.promise,dismiss:Wt.dismiss,loading:Wt.loading},{getHistory:ZI,getToasts:QI});function eN(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))}eN(`: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 tN=3,nN="32px",rN="16px",ox=4e3,oN=356,sN=14,iN=20,aN=200;function hn(...e){return e.filter(Boolean).join(" ")}function lN(e){let[t,n]=e.split("-"),r=[];return t&&r.push(t),n&&r.push(n),r}var cN=e=>{var t,n,r,o,s,i,a,l,c,d,p;let{invert:m,toast:f,unstyled:v,interacting:x,setHeights:g,visibleToasts:b,heights:y,index:S,toasts:k,expanded:C,removeToast:T,defaultRichColors:E,closeButton:j,style:P,cancelButtonStyle:O,actionButtonStyle:F,className:q="",descriptionClassName:Y="",duration:R,position:K,gap:U,loadingIcon:W,expandByDefault:M,classNames:I,icons:G,closeButtonAriaLabel:X="Close toast",pauseWhenPageIsHidden:_}=e,[B,N]=w.useState(null),[L,z]=w.useState(null),[$,D]=w.useState(!1),[J,Q]=w.useState(!1),[ie,Z]=w.useState(!1),[ue,he]=w.useState(!1),[ke,Le]=w.useState(!1),[$e,je]=w.useState(0),[Be,ct]=w.useState(0),bt=w.useRef(f.duration||R||ox),kt=w.useRef(null),ze=w.useRef(null),Ye=S===0,Oe=S+1<=b,De=f.type,He=f.dismissible!==!1,rt=f.className||"",lt=f.descriptionClassName||"",it=w.useMemo(()=>y.findIndex(pe=>pe.toastId===f.id)||0,[y,f.id]),St=w.useMemo(()=>{var pe;return(pe=f.closeButton)!=null?pe:j},[f.closeButton,j]),ht=w.useMemo(()=>f.duration||R||ox,[f.duration,R]),Ct=w.useRef(0),Et=w.useRef(0),rn=w.useRef(0),It=w.useRef(null),[mn,Rt]=K.split("-"),Fe=w.useMemo(()=>y.reduce((pe,Ae,ve)=>ve>=it?pe:pe+Ae.height,0),[y,it]),Ue=qI(),Mt=f.invert||m,re=De==="loading";Et.current=w.useMemo(()=>it*U+Fe,[it,Fe]),w.useEffect(()=>{bt.current=ht},[ht]),w.useEffect(()=>{D(!0)},[]),w.useEffect(()=>{let pe=ze.current;if(pe){let Ae=pe.getBoundingClientRect().height;return ct(Ae),g(ve=>[{toastId:f.id,height:Ae,position:f.position},...ve]),()=>g(ve=>ve.filter(Ie=>Ie.toastId!==f.id))}},[g,f.id]),w.useLayoutEffect(()=>{if(!$)return;let pe=ze.current,Ae=pe.style.height;pe.style.height="auto";let ve=pe.getBoundingClientRect().height;pe.style.height=Ae,ct(ve),g(Ie=>Ie.find(Pe=>Pe.toastId===f.id)?Ie.map(Pe=>Pe.toastId===f.id?{...Pe,height:ve}:Pe):[{toastId:f.id,height:ve,position:f.position},...Ie])},[$,f.title,f.description,g,f.id]);let oe=w.useCallback(()=>{Q(!0),je(Et.current),g(pe=>pe.filter(Ae=>Ae.toastId!==f.id)),setTimeout(()=>{T(f)},aN)},[f,T,g,Et]);w.useEffect(()=>{if(f.promise&&De==="loading"||f.duration===1/0||f.type==="loading")return;let pe;return C||x||_&&Ue?(()=>{if(rn.current<Ct.current){let Ae=new Date().getTime()-Ct.current;bt.current=bt.current-Ae}rn.current=new Date().getTime()})():bt.current!==1/0&&(Ct.current=new Date().getTime(),pe=setTimeout(()=>{var Ae;(Ae=f.onAutoClose)==null||Ae.call(f,f),oe()},bt.current)),()=>clearTimeout(pe)},[C,x,f,De,_,Ue,oe]),w.useEffect(()=>{f.delete&&oe()},[oe,f.delete]);function _e(){var pe,Ae,ve;return G!=null&&G.loading?w.createElement("div",{className:hn(I==null?void 0:I.loader,(pe=f==null?void 0:f.classNames)==null?void 0:pe.loader,"sonner-loader"),"data-visible":De==="loading"},G.loading):W?w.createElement("div",{className:hn(I==null?void 0:I.loader,(Ae=f==null?void 0:f.classNames)==null?void 0:Ae.loader,"sonner-loader"),"data-visible":De==="loading"},W):w.createElement(zI,{className:hn(I==null?void 0:I.loader,(ve=f==null?void 0:f.classNames)==null?void 0:ve.loader),visible:De==="loading"})}return w.createElement("li",{tabIndex:0,ref:ze,className:hn(q,rt,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[De],(n=f==null?void 0:f.classNames)==null?void 0:n[De]),"data-sonner-toast":"","data-rich-colors":(r=f.richColors)!=null?r:E,"data-styled":!(f.jsx||f.unstyled||v),"data-mounted":$,"data-promise":!!f.promise,"data-swiped":ke,"data-removed":J,"data-visible":Oe,"data-y-position":mn,"data-x-position":Rt,"data-index":S,"data-front":Ye,"data-swiping":ie,"data-dismissible":He,"data-type":De,"data-invert":Mt,"data-swipe-out":ue,"data-swipe-direction":L,"data-expanded":!!(C||M&&$),style:{"--index":S,"--toasts-before":S,"--z-index":k.length-S,"--offset":`${J?$e:Et.current}px`,"--initial-height":M?"auto":`${Be}px`,...P,...f.style},onDragEnd:()=>{Z(!1),N(null),It.current=null},onPointerDown:pe=>{re||!He||(kt.current=new Date,je(Et.current),pe.target.setPointerCapture(pe.pointerId),pe.target.tagName!=="BUTTON"&&(Z(!0),It.current={x:pe.clientX,y:pe.clientY}))},onPointerUp:()=>{var pe,Ae,ve,Ie;if(ue||!He)return;It.current=null;let Pe=Number(((pe=ze.current)==null?void 0:pe.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),Ge=Number(((Ae=ze.current)==null?void 0:Ae.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),mt=new Date().getTime()-((ve=kt.current)==null?void 0:ve.getTime()),we=B==="x"?Pe:Ge,gt=Math.abs(we)/mt;if(Math.abs(we)>=iN||gt>.11){je(Et.current),(Ie=f.onDismiss)==null||Ie.call(f,f),z(B==="x"?Pe>0?"right":"left":Ge>0?"down":"up"),oe(),he(!0),Le(!1);return}Z(!1),N(null)},onPointerMove:pe=>{var Ae,ve,Ie,Pe;if(!It.current||!He||((Ae=window.getSelection())==null?void 0:Ae.toString().length)>0)return;let Ge=pe.clientY-It.current.y,mt=pe.clientX-It.current.x,we=(ve=e.swipeDirections)!=null?ve:lN(K);!B&&(Math.abs(mt)>1||Math.abs(Ge)>1)&&N(Math.abs(mt)>Math.abs(Ge)?"x":"y");let gt={x:0,y:0};B==="y"?(we.includes("top")||we.includes("bottom"))&&(we.includes("top")&&Ge<0||we.includes("bottom")&&Ge>0)&&(gt.y=Ge):B==="x"&&(we.includes("left")||we.includes("right"))&&(we.includes("left")&&mt<0||we.includes("right")&&mt>0)&&(gt.x=mt),(Math.abs(gt.x)>0||Math.abs(gt.y)>0)&&Le(!0),(Ie=ze.current)==null||Ie.style.setProperty("--swipe-amount-x",`${gt.x}px`),(Pe=ze.current)==null||Pe.style.setProperty("--swipe-amount-y",`${gt.y}px`)}},St&&!f.jsx?w.createElement("button",{"aria-label":X,"data-disabled":re,"data-close-button":!0,onClick:re||!He?()=>{}:()=>{var pe;oe(),(pe=f.onDismiss)==null||pe.call(f,f)},className:hn(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:KI):null,f.jsx||w.isValidElement(f.title)?f.jsx?f.jsx:typeof f.title=="function"?f.title():f.title:w.createElement(w.Fragment,null,De||f.icon||f.promise?w.createElement("div",{"data-icon":"",className:hn(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||_e():null,f.type!=="loading"?f.icon||(G==null?void 0:G[De])||FI(De):null):null,w.createElement("div",{"data-content":"",className:hn(I==null?void 0:I.content,(a=f==null?void 0:f.classNames)==null?void 0:a.content)},w.createElement("div",{"data-title":"",className:hn(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:hn(Y,lt,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||O,onClick:pe=>{var Ae,ve;gi(f.cancel)&&He&&((ve=(Ae=f.cancel).onClick)==null||ve.call(Ae,pe),oe())},className:hn(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:pe=>{var Ae,ve;gi(f.action)&&((ve=(Ae=f.action).onClick)==null||ve.call(Ae,pe),!pe.defaultPrevented&&oe())},className:hn(I==null?void 0:I.actionButton,(p=f==null?void 0:f.classNames)==null?void 0:p.actionButton)},f.action.label):null))};function sx(){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 uN(e,t){let n={};return[e,t].forEach((r,o)=>{let s=o===1,i=s?"--mobile-offset":"--offset",a=s?rN:nN;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 dN=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:p,duration:m,style:f,visibleToasts:v=tN,toastOptions:x,dir:g=sx(),gap:b=sN,loadingIcon:y,icons:S,containerAriaLabel:k="Notifications",pauseWhenPageIsHidden:C}=e,[T,E]=w.useState([]),j=w.useMemo(()=>Array.from(new Set([r].concat(T.filter(_=>_.position).map(_=>_.position)))),[T,r]),[P,O]=w.useState([]),[F,q]=w.useState(!1),[Y,R]=w.useState(!1),[K,U]=w.useState(d!=="system"?d:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),W=w.useRef(null),M=o.join("+").replace(/Key/g,"").replace(/Digit/g,""),I=w.useRef(null),G=w.useRef(!1),X=w.useCallback(_=>{E(B=>{var N;return(N=B.find(L=>L.id===_.id))!=null&&N.delete||Wt.dismiss(_.id),B.filter(({id:L})=>L!==_.id)})},[]);return w.useEffect(()=>Wt.subscribe(_=>{if(_.dismiss){E(B=>B.map(N=>N.id===_.id?{...N,delete:!0}:N));return}setTimeout(()=>{Mo.flushSync(()=>{E(B=>{let N=B.findIndex(L=>L.id===_.id);return N!==-1?[...B.slice(0,N),{...B[N],..._},...B.slice(N+1)]:[_,...B]})})})}),[]),w.useEffect(()=>{if(d!=="system"){U(d);return}if(d==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?U("dark"):U("light")),typeof window>"u")return;let _=window.matchMedia("(prefers-color-scheme: dark)");try{_.addEventListener("change",({matches:B})=>{U(B?"dark":"light")})}catch{_.addListener(({matches:N})=>{try{U(N?"dark":"light")}catch(L){console.error(L)}})}},[d]),w.useEffect(()=>{T.length<=1&&q(!1)},[T]),w.useEffect(()=>{let _=B=>{var N,L;o.every(z=>B[z]||B.code===z)&&(q(!0),(N=W.current)==null||N.focus()),B.code==="Escape"&&(document.activeElement===W.current||(L=W.current)!=null&&L.contains(document.activeElement))&&q(!1)};return document.addEventListener("keydown",_),()=>document.removeEventListener("keydown",_)},[o]),w.useEffect(()=>{if(W.current)return()=>{I.current&&(I.current.focus({preventScroll:!0}),I.current=null,G.current=!1)}},[W.current]),w.createElement("section",{ref:t,"aria-label":`${k} ${M}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},j.map((_,B)=>{var N;let[L,z]=_.split("-");return T.length?w.createElement("ol",{key:_,dir:g==="auto"?sx():g,tabIndex:-1,ref:W,className:a,"data-sonner-toaster":!0,"data-theme":K,"data-y-position":L,"data-lifted":F&&T.length>1&&!s,"data-x-position":z,style:{"--front-toast-height":`${((N=P[0])==null?void 0:N.height)||0}px`,"--width":`${oN}px`,"--gap":`${b}px`,...f,...uN(l,c)},onBlur:$=>{G.current&&!$.currentTarget.contains($.relatedTarget)&&(G.current=!1,I.current&&(I.current.focus({preventScroll:!0}),I.current=null))},onFocus:$=>{$.target instanceof HTMLElement&&$.target.dataset.dismissible==="false"||G.current||(G.current=!0,I.current=$.relatedTarget)},onMouseEnter:()=>q(!0),onMouseMove:()=>q(!0),onMouseLeave:()=>{Y||q(!1)},onDragEnd:()=>q(!1),onPointerDown:$=>{$.target instanceof HTMLElement&&$.target.dataset.dismissible==="false"||R(!0)},onPointerUp:()=>R(!1)},T.filter($=>!$.position&&B===0||$.position===_).map(($,D)=>{var J,Q;return w.createElement(cN,{key:$.id,icons:S,index:D,toast:$,defaultRichColors:p,duration:(J=x==null?void 0:x.duration)!=null?J:m,className:x==null?void 0:x.className,descriptionClassName:x==null?void 0:x.descriptionClassName,invert:n,visibleToasts:v,closeButton:(Q=x==null?void 0:x.closeButton)!=null?Q:i,interacting:Y,position:_,style:x==null?void 0:x.style,unstyled:x==null?void 0:x.unstyled,classNames:x==null?void 0:x.classNames,cancelButtonStyle:x==null?void 0:x.cancelButtonStyle,actionButtonStyle:x==null?void 0:x.actionButtonStyle,removeToast:X,toasts:T.filter(ie=>ie.position==$.position),heights:P.filter(ie=>ie.position==$.position),setHeights:O,expandByDefault:s,gap:b,loadingIcon:y,expanded:F,pauseWhenPageIsHidden:C,swipeDirections:e.swipeDirections})})):null}))});const fN=({...e})=>{const{theme:t="system"}=$I();return u.jsx(dN,{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=Kv,H.ApiClient=Vv,H.ApiProvider=ou,H.ArtifactRenderer=Ih,H.Badge=Fh,H.Button=Ze,H.Card=al,H.CardContent=dl,H.CardDescription=ul,H.CardHeader=ll,H.CardTitle=cl,H.ChatApi=Go,H.ChatApp=Kk,H.ChatInput=Vf,H.ChatInputRow=Kf,H.ChatInterface=Or,H.ChatProviders=wr,H.ChatWidget=Yk,H.Command=Sl,H.CommandEmpty=kl,H.CommandGroup=El,H.CommandInput=Cl,H.CommandItem=Il,H.CommandList=Tl,H.DEFAULT_TIMEOUT_MS=Zc,H.Dialog=tl,H.DialogContent=Hs,H.DialogHeader=Us,H.DialogTitle=Ws,H.DropdownMenu=Ts,H.DropdownMenuContent=ho,H.DropdownMenuItem=Fn,H.DropdownMenuTrigger=ks,H.FileViewerModal=uh,H.HISTORY_TIMEOUT_MS=Qc,H.Input=Ml,H.InterruptPartRenderer=Ah,H.Label=bm,H.MarkdownContent=Kn,H.MessageComponent=Zs,H.MessageList=ml,H.MessageRow=hl,H.NewChatButton=Xk,H.PlotArtifact=Th,H.ResearchTaskArtifact=Eh,H.SETTINGS_STORAGE_KEY=Bi,H.ScrollArea=Rl,H.Select=AE,H.SelectContent=ig,H.SelectItem=ag,H.SelectTrigger=rg,H.SelectValue=jE,H.Separator=dg,H.Sheet=zE,H.SheetContent=wg,H.SheetDescription=Cg,H.SheetHeader=yg,H.SheetTitle=Sg,H.SheetTrigger=HE,H.SimpleChat=qk,H.SimpleJsonView=Js,H.Sonner=fN,H.StreamProgress=jh,H.Switch=vg,H.Textarea=Ea,H.ThinkingIndicator=_h,H.ThreadListItem=pm,H.ThreadManager=oi,H.ThreadStateProvider=Iu,H.ThreadsProvider=mu,H.TimelineColumn=Sx,H.Toaster=MI,H.ToolComponent=Lh,H.Tooltip=dI,H.TooltipContent=Pg,H.TooltipProvider=uI,H.TooltipTrigger=fI,H.UserTextContent=Ph,H.applySettings=Ib,H.buildCheckpointIndex=tc,H.buildCheckpointPreviewMap=dx,H.chatApiClient=Nn,H.del=Pi,H.downloadFileById=tu,H.extractConfigFields=vi,H.fileToBase64=su,H.get=Gt,H.getChatToken=Xc,H.getCheckpointForMessage=fx,H.getCurrentSettings=Eb,H.getDefaultApiConfig=Du,H.getDefaultChatSettings=Lu,H.getFileContent=Mi,H.getFileInfo=Gv,H.getMessageAttemptInfo=nc,H.getMessageDomKey=pl,H.getPreviewForMessage=xi,H.httpClient=qt,H.hydrateHistorySnapshots=Xn,H.isEnvelope=au,H.listFiles=nu,H.loadStoredSettings=$u,H.onChatTokenChanged=Jc,H.post=qo,H.processAttachments=iu,H.put=eu,H.readNumber=oc,H.readString=Rn,H.resolveChatBaseUrl=xn,H.saveSettings=Fu,H.setChatToken=Ko,H.toPlainObject=Pn,H.unwrap=Ot,H.useApi=Jr,H.useCheckpointIndex=rc,H.useFilePreview=Mh,H.useHasChatSession=Cb,H.useParsedMessageContent=Oh,H.useShallowStableValue=Pu,H.useStream=Fi,H.useStreamingHook=Fi,H.useThreadHistoryState=Cu,H.useThreadManagerViewState=gm,H.useThreadState=to,H.useThreadStateUpdater=Eu,H.useThreads=xr,H.useThreadsState=pu,H.viewFileById=qv,Object.defineProperty(H,Symbol.toStringTag,{value:"Module"})});
126
+ `}strong(t){return`<strong>${t}</strong>`}em(t){return`<em>${t}</em>`}codespan(t){return`<code>${t}</code>`}br(){return this.options.xhtml?"<br/>":"<br>"}del(t){return`<del>${t}</del>`}link(t,n,r){if(t=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"})});