teodor-new-chat-ui 4.3.500 → 4.3.503

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.umd.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(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,qt,Wr,cx,ux,le,Lo){"use strict";var mN=Object.defineProperty;var gN=(H,w,qt)=>w in H?mN(H,w,{enumerable:!0,configurable:!0,writable:!0,value:qt}):H[w]=qt;var ax=(H,w,qt)=>gN(H,typeof w!="symbol"?w+"":w,qt);var ix;var bi=typeof document<"u"?document.currentScript:null;function nc(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=nc(w),Vr=nc(Lo),rc=120;function dx(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>rc?`${n.slice(0,rc-3)}…`:n:""}function yi(e){return dx(e.content)||""}function fx(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=yi(o);s&&t.set(r.checkpointId,s)}}return t}function oc(e){const t=new Map,n=[],r=new Map,o=[];for(let l=0;l<e.length;l++){const d=e[l],f=d.checkpointId,m=f??`cp-${l}`,p=d.metadata??{},v=typeof p.step=="number"?p.step:null,g=typeof p.source=="string"?p.source:null;let x=null,y=null;const b=Array.isArray(d.messages)?d.messages:[];for(const C of b)C.role==="user"&&(y||(y=C),C.id&&(x=C.id));const T=d.next&&d.next.length>0?String(d.next[0]):null,E=d.parentConfig??null,S={id:m,step:v,source:g,createdAt:d.createdAt??null,namespace:d.checkpointNs??null,parentId:d.parentId??null,next:T,parentConfig:E,userMessageId:x};if(o.push(S),f&&t.set(f,S),f&&y){const C=yi(y);C&&r.set(f,C)}n.push({id:m,messageId:x,step:v,source:g,createdAt:d.createdAt??null,next:T,parentConfig:E})}const s=new Map;for(const l of o){if(!l.userMessageId)continue;const d=s.get(l.userMessageId)??[];d.push(l),s.set(l.userMessageId,d)}for(const l of s.values()){if(!l.length)continue;l.sort((f,m)=>{const p=f.createdAt?Date.parse(f.createdAt):0;return(m.createdAt?Date.parse(m.createdAt):0)-p});const d=l.length;for(let f=0;f<l.length;f++){const m=l[f];m.attemptCount=d,m.attemptIndex=f,m.isLatestAttempt=f===0}}return{checkpoints:e,checkpointMetaByCheckpointId:t,timeline:n,messagePreviews:r,getLatest:()=>{const l=n[0];if(l)return t.get(l.id)},getCheckpoint:l=>t.get(l),getMessageAttempts:l=>{const d=[];for(const f of t.values())f.userMessageId===l&&d.push(f);return d.length?(d.sort((f,m)=>{const p=typeof f.attemptIndex=="number"?f.attemptIndex:Number.MAX_SAFE_INTEGER,v=typeof m.attemptIndex=="number"?m.attemptIndex:Number.MAX_SAFE_INTEGER;return p-v}),d):[]}}}function sc(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 px(e,t){return e?t.getCheckpoint(e)??null:null}function ic(e){return w.useMemo(()=>oc(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 ac(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 Si(e){const t=_n(e);if(t)return _n(t.configurable)??t}const hx={},hr=typeof{url:typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:bi&&bi.tagName.toUpperCase()==="SCRIPT"&&bi.src||new URL("index.umd.js",document.baseURI).href}<"u"?hx:void 0,Kr=!(((ix=hr==null?void 0:hr.VITE_DEBUG_HISTORY_INTERRUPTS)==null?void 0:ix.toLowerCase())==="false"||(hr==null?void 0:hr.VITE_DEBUG_HISTORY_INTERRUPTS)==="0");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)=>mx(s,i)).filter(s=>!!s)].sort((s,i)=>lc(i.createdAt)-lc(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 mx(e,t){var S,C;if(!e)return null;const r=(Array.isArray((S=e.values)==null?void 0:S.messages)?e.values.messages:[]).map(k=>gx(k)).filter(k=>!!k),o=_n(e.metadata)??{},s=Si(e.config),i=_n(e.parent_config??e.parentConfig),a=Si(i),c=Rn(s,["checkpoint_id","checkpointId"]),l=Rn(s,["checkpoint_ns","checkpointNs"]),d=Rn(a,["checkpoint_id","checkpointId"]),f=Rn(a,["checkpoint_id","checkpointId"])??null,m=Rn(a,["checkpoint_ns","checkpointNs"])??null,p=_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:ac(o,["step"])??0,source:Rn(o,["source"])??null},b=r.map(k=>({...k,checkpointId:c??null})),T=(C=e.values)==null?void 0:C.interrupts,E=Array.isArray(e.interrupts)?e.interrupts:Array.isArray(T)?T:[];return{checkpointId:c??null,checkpointNs:l??null,createdAt:x,parentId:d??null,messages:b,nextCursor:f,nextCursorNs:m,interrupt:bx(r,E,t,c??null,l??null),metadata:y,config:p??null,parentConfig:i??null,next:g,tasks:v}}function gx(e){var s,i,a;if(!e||typeof e!="object")return null;const t=xx(e);if(!t)return null;const n=wx(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 xx(e){const t=typeof e.role=="string"?e.role:void 0;if(t&&vx(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 vx(e){return e==="assistant"||e==="user"||e==="system"||e==="tool"||e==="default_message"}function wx(e){return typeof e=="string"?[{type:"text",text:e}]:Array.isArray(e)?e.filter(t=>!!(t&&typeof t=="object"&&typeof t.type=="string")):[]}function bx(e,t,n,r,o){const s=t.length,i=yx(e,n);if(Kr&&console.debug("[historyUtils] deriveInterruptFromSnapshot",{checkpointId:r,checkpointNs:o,fallbackIndex:n,messageCount:e.length,rawInterruptCount:s,messageInterrupt:i,rawInterrupts:t.slice(Math.max(0,s-3))}),i)return Kr&&console.debug("[historyUtils] interrupt found in messages",i),i;for(let a=s-1;a>=0;a-=1){const c=t[a];if(!c||typeof c!="object"){Kr&&console.debug("[historyUtils] skipping invalid raw interrupt entry",{entry:c,index:a});continue}const l=c,d=l.value??c;if(d==null){Kr&&console.debug("[historyUtils] skipping raw interrupt without value",{entry:c,index:a});continue}const m={id:typeof l.id=="string"&&l.id.trim()?l.id:`interrupt-${r??n}-${a}`,value:d};return Kr&&console.debug("[historyUtils] interrupt derived from raw entry",m),m}return null}function yx(e,t){var n;for(let r=e.length-1;r>=0;r--){const o=((n=e[r])==null?void 0:n.content)??[];for(let s=o.length-1;s>=0;s--){const i=o[s];if((i==null?void 0:i.type)==="interrupt"){const a=i;return{id:typeof a.id=="string"&&a.id.trim()?a.id:`interrupt-${t}-${r}-${s}`,value:a.value}}}}return null}function lc(e){if(!e)return 0;const t=Date.parse(e);return Number.isFinite(t)?t:0}var Ci={exports:{}},qr={};/**
1
+ (function($,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):($=typeof globalThis<"u"?globalThis:$||self,w($.NewChatUI={},$.React,$.reactSlot,$.classVarianceAuthority,$.clsx,$.tailwindMerge,$.LucideReact,$.ReactDOM))})(this,function($,w,qt,Kr,wx,bx,le,Lo){"use strict";var mN=Object.defineProperty;var gN=($,w,qt)=>w in $?mN($,w,{enumerable:!0,configurable:!0,writable:!0,value:qt}):$[w]=qt;var xx=($,w,qt)=>gN($,typeof w!="symbol"?w+"":w,qt);var gx;var yi=typeof document<"u"?document.currentScript:null;function ic(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=ic(w),qr=ic(Lo),ac=120;function yx(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>ac?`${n.slice(0,ac-3)}…`:n:""}function Si(e){return yx(e.content)||""}function Sx(e){var n;const t=new Map;for(const r of e){if(!r.checkpointId)continue;const o=(n=r.messages)==null?void 0:n.find(s=>s.role==="user");if(o){const s=Si(o);s&&t.set(r.checkpointId,s)}}return t}function lc(e){const t=new Map,n=[],r=new Map,o=[];for(let l=0;l<e.length;l++){const d=e[l],f=d.checkpointId,m=f??`cp-${l}`,p=d.metadata??{},v=typeof p.step=="number"?p.step:null,g=typeof p.source=="string"?p.source:null;let x=null,y=null;const b=Array.isArray(d.messages)?d.messages:[];for(const C of b)C.role==="user"&&(y||(y=C),C.id&&(x=C.id));const T=d.next&&d.next.length>0?String(d.next[0]):null,E=d.parentConfig??null,S={id:m,step:v,source:g,createdAt:d.createdAt??null,namespace:d.checkpointNs??null,parentId:d.parentId??null,next:T,parentConfig:E,userMessageId:x};if(o.push(S),f&&t.set(f,S),f&&y){const C=Si(y);C&&r.set(f,C)}n.push({id:m,messageId:x,step:v,source:g,createdAt:d.createdAt??null,next:T,parentConfig:E})}const s=new Map;for(const l of o){if(!l.userMessageId)continue;const d=s.get(l.userMessageId)??[];d.push(l),s.set(l.userMessageId,d)}for(const l of s.values()){if(!l.length)continue;l.sort((f,m)=>{const p=f.createdAt?Date.parse(f.createdAt):0;return(m.createdAt?Date.parse(m.createdAt):0)-p});const d=l.length;for(let f=0;f<l.length;f++){const m=l[f];m.attemptCount=d,m.attemptIndex=f,m.isLatestAttempt=f===0}}return{checkpoints:e,checkpointMetaByCheckpointId:t,timeline:n,messagePreviews:r,getLatest:()=>{const l=n[0];if(l)return t.get(l.id)},getCheckpoint:l=>t.get(l),getMessageAttempts:l=>{const d=[];for(const f of t.values())f.userMessageId===l&&d.push(f);return d.length?(d.sort((f,m)=>{const p=typeof f.attemptIndex=="number"?f.attemptIndex:Number.MAX_SAFE_INTEGER,v=typeof m.attemptIndex=="number"?m.attemptIndex:Number.MAX_SAFE_INTEGER;return p-v}),d):[]}}}function cc(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 Cx(e,t){return e?t.getCheckpoint(e)??null:null}function uc(e){return w.useMemo(()=>lc(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 dc(e,t){if(!e)return null;for(const n of t){const r=e[n];if(typeof r=="number"&&Number.isFinite(r))return r}return null}function Ci(e){const t=_n(e);if(t)return _n(t.configurable)??t}const Tx={},xr=typeof{url:typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:yi&&yi.tagName.toUpperCase()==="SCRIPT"&&yi.src||new URL("index.umd.js",document.baseURI).href}<"u"?Tx:void 0,Gr=!(((gx=xr==null?void 0:xr.VITE_DEBUG_HISTORY_INTERRUPTS)==null?void 0:gx.toLowerCase())==="false"||(xr==null?void 0:xr.VITE_DEBUG_HISTORY_INTERRUPTS)==="0");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)=>kx(s,i)).filter(s=>!!s)].sort((s,i)=>fc(i.createdAt)-fc(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 kx(e,t){var S,C;if(!e)return null;const r=(Array.isArray((S=e.values)==null?void 0:S.messages)?e.values.messages:[]).map(k=>Ex(k)).filter(k=>!!k),o=_n(e.metadata)??{},s=Ci(e.config),i=_n(e.parent_config??e.parentConfig),a=Ci(i),c=Rn(s,["checkpoint_id","checkpointId"]),l=Rn(s,["checkpoint_ns","checkpointNs"]),d=Rn(a,["checkpoint_id","checkpointId"]),f=Rn(a,["checkpoint_id","checkpointId"])??null,m=Rn(a,["checkpoint_ns","checkpointNs"])??null,p=_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:dc(o,["step"])??0,source:Rn(o,["source"])??null},b=r.map(k=>({...k,checkpointId:c??null})),T=(C=e.values)==null?void 0:C.interrupts,E=Array.isArray(e.interrupts)?e.interrupts:Array.isArray(T)?T:[];return{checkpointId:c??null,checkpointNs:l??null,createdAt:x,parentId:d??null,messages:b,nextCursor:f,nextCursorNs:m,interrupt:Px(r,E,t,c??null,l??null),metadata:y,config:p??null,parentConfig:i??null,next:g,tasks:v}}function Ex(e){var s,i,a;if(!e||typeof e!="object")return null;const t=Ix(e);if(!t)return null;const n=Ax(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 Ix(e){const t=typeof e.role=="string"?e.role:void 0;if(t&&Nx(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 Nx(e){return e==="assistant"||e==="user"||e==="system"||e==="tool"||e==="default_message"}function Ax(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,n,r,o){const s=t.length,i=jx(e,n);if(Gr&&console.debug("[historyUtils] deriveInterruptFromSnapshot",{checkpointId:r,checkpointNs:o,fallbackIndex:n,messageCount:e.length,rawInterruptCount:s,messageInterrupt:i,rawInterrupts:t.slice(Math.max(0,s-3))}),i)return Gr&&console.debug("[historyUtils] interrupt found in messages",i),i;for(let a=s-1;a>=0;a-=1){const c=t[a];if(!c||typeof c!="object"){Gr&&console.debug("[historyUtils] skipping invalid raw interrupt entry",{entry:c,index:a});continue}const l=c,d=l.value??c;if(d==null){Gr&&console.debug("[historyUtils] skipping raw interrupt without value",{entry:c,index:a});continue}const m={id:typeof l.id=="string"&&l.id.trim()?l.id:`interrupt-${r??n}-${a}`,value:d};return Gr&&console.debug("[historyUtils] interrupt derived from raw entry",m),m}return null}function jx(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 fc(e){if(!e)return 0;const t=Date.parse(e);return Number.isFinite(t)?t:0}var Ti={exports:{}},Yr={};/**
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 cc;function Sx(){if(cc)return qr;cc=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,c,l){var d,f={},m=null,p=null;l!==void 0&&(m=""+l),c.key!==void 0&&(m=""+c.key),c.ref!==void 0&&(p=c.ref);for(d in c)r.call(c,d)&&!s.hasOwnProperty(d)&&(f[d]=c[d]);if(a&&a.defaultProps)for(d in c=a.defaultProps,c)f[d]===void 0&&(f[d]=c[d]);return{$$typeof:t,type:a,key:m,ref:p,props:f,_owner:o.current}}return qr.Fragment=n,qr.jsx=i,qr.jsxs=i,qr}var Gr={};/**
9
+ */var pc;function _x(){if(pc)return Yr;pc=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,c,l){var d,f={},m=null,p=null;l!==void 0&&(m=""+l),c.key!==void 0&&(m=""+c.key),c.ref!==void 0&&(p=c.ref);for(d in c)r.call(c,d)&&!s.hasOwnProperty(d)&&(f[d]=c[d]);if(a&&a.defaultProps)for(d in c=a.defaultProps,c)f[d]===void 0&&(f[d]=c[d]);return{$$typeof:t,type:a,key:m,ref:p,props:f,_owner:o.current}}return Yr.Fragment=n,Yr.jsx=i,Yr.jsxs=i,Yr}var Xr={};/**
10
10
  * @license React
11
11
  * react-jsx-runtime.development.js
12
12
  *
@@ -14,34 +14,34 @@
14
14
  *
15
15
  * This source code is licensed under the MIT license found in the
16
16
  * LICENSE file in the root directory of this source tree.
17
- */var uc;function Cx(){return uc||(uc=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"),c=Symbol.for("react.forward_ref"),l=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),f=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),p=Symbol.for("react.offscreen"),v=Symbol.iterator,g="@@iterator";function x(N){if(N===null||typeof N!="object")return null;var Z=v&&N[v]||N[g];return typeof Z=="function"?Z:null}var y=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function b(N){{for(var Z=arguments.length,re=new Array(Z>1?Z-1:0),de=1;de<Z;de++)re[de-1]=arguments[de];T("error",N,re)}}function T(N,Z,re){{var de=y.ReactDebugCurrentFrame,Me=de.getStackAddendum();Me!==""&&(Z+="%s",re=re.concat([Me]));var Oe=re.map(function(We){return String(We)});Oe.unshift("Warning: "+Z),Function.prototype.apply.call(console[N],console,Oe)}}var E=!1,S=!1,C=!1,k=!1,A=!1,P;P=Symbol.for("react.module.reference");function L(N){return!!(typeof N=="string"||typeof N=="function"||N===r||N===s||A||N===o||N===l||N===d||k||N===p||E||S||C||typeof N=="object"&&N!==null&&(N.$$typeof===m||N.$$typeof===f||N.$$typeof===i||N.$$typeof===a||N.$$typeof===c||N.$$typeof===P||N.getModuleId!==void 0))}function F(N,Z,re){var de=N.displayName;if(de)return de;var Me=Z.displayName||Z.name||"";return Me!==""?re+"("+Me+")":re}function K(N){return N.displayName||"Context"}function J(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 l:return"Suspense";case d:return"SuspenseList"}if(typeof N=="object")switch(N.$$typeof){case a:var Z=N;return K(Z)+".Consumer";case i:var re=N;return K(re._context)+".Provider";case c:return F(N,N.render,"ForwardRef");case f:var de=N.displayName||null;return de!==null?de:J(N.type)||"Memo";case m:{var Me=N,Oe=Me._payload,We=Me._init;try{return J(We(Oe))}catch{return null}}}return null}var _=Object.assign,Y=0,q,W,D,I,G,X,M;function B(){}B.__reactDisabledLog=!0;function R(){{if(Y===0){q=console.log,W=console.info,D=console.warn,I=console.error,G=console.group,X=console.groupCollapsed,M=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})}Y++}}function $(){{if(Y--,Y===0){var N={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:_({},N,{value:q}),info:_({},N,{value:W}),warn:_({},N,{value:D}),error:_({},N,{value:I}),group:_({},N,{value:G}),groupCollapsed:_({},N,{value:X}),groupEnd:_({},N,{value:M})})}Y<0&&b("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var z=y.ReactCurrentDispatcher,O;function j(N,Z,re){{if(O===void 0)try{throw Error()}catch(Me){var de=Me.stack.trim().match(/\n( *(at )?)/);O=de&&de[1]||""}return`
18
- `+O+N}}var U=!1,Q;{var se=typeof WeakMap=="function"?WeakMap:Map;Q=new se}function ie(N,Z){if(!N||U)return"";{var re=Q.get(N);if(re!==void 0)return re}var de;U=!0;var Me=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var Oe;Oe=z.current,z.current=null,R();try{if(Z){var We=function(){throw Error()};if(Object.defineProperty(We.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(We,[])}catch(Kt){de=Kt}Reflect.construct(N,[],We)}else{try{We.call()}catch(Kt){de=Kt}N.call(We.prototype)}}else{try{throw Error()}catch(Kt){de=Kt}N()}}catch(Kt){if(Kt&&de&&typeof Kt.stack=="string"){for(var Be=Kt.stack.split(`
17
+ */var hc;function Rx(){return hc||(hc=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"),c=Symbol.for("react.forward_ref"),l=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),f=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),p=Symbol.for("react.offscreen"),v=Symbol.iterator,g="@@iterator";function x(N){if(N===null||typeof N!="object")return null;var Z=v&&N[v]||N[g];return typeof Z=="function"?Z:null}var y=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function b(N){{for(var Z=arguments.length,re=new Array(Z>1?Z-1:0),de=1;de<Z;de++)re[de-1]=arguments[de];T("error",N,re)}}function T(N,Z,re){{var de=y.ReactDebugCurrentFrame,Me=de.getStackAddendum();Me!==""&&(Z+="%s",re=re.concat([Me]));var Oe=re.map(function(We){return String(We)});Oe.unshift("Warning: "+Z),Function.prototype.apply.call(console[N],console,Oe)}}var E=!1,S=!1,C=!1,k=!1,A=!1,j;j=Symbol.for("react.module.reference");function L(N){return!!(typeof N=="string"||typeof N=="function"||N===r||N===s||A||N===o||N===l||N===d||k||N===p||E||S||C||typeof N=="object"&&N!==null&&(N.$$typeof===m||N.$$typeof===f||N.$$typeof===i||N.$$typeof===a||N.$$typeof===c||N.$$typeof===j||N.getModuleId!==void 0))}function B(N,Z,re){var de=N.displayName;if(de)return de;var Me=Z.displayName||Z.name||"";return Me!==""?re+"("+Me+")":re}function K(N){return N.displayName||"Context"}function J(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 l:return"Suspense";case d:return"SuspenseList"}if(typeof N=="object")switch(N.$$typeof){case a:var Z=N;return K(Z)+".Consumer";case i:var re=N;return K(re._context)+".Provider";case c:return B(N,N.render,"ForwardRef");case f:var de=N.displayName||null;return de!==null?de:J(N.type)||"Memo";case m:{var Me=N,Oe=Me._payload,We=Me._init;try{return J(We(Oe))}catch{return null}}}return null}var _=Object.assign,Y=0,q,W,D,I,G,X,M;function z(){}z.__reactDisabledLog=!0;function R(){{if(Y===0){q=console.log,W=console.info,D=console.warn,I=console.error,G=console.group,X=console.groupCollapsed,M=console.groupEnd;var N={configurable:!0,enumerable:!0,value:z,writable:!0};Object.defineProperties(console,{info:N,log:N,warn:N,error:N,group:N,groupCollapsed:N,groupEnd:N})}Y++}}function F(){{if(Y--,Y===0){var N={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:_({},N,{value:q}),info:_({},N,{value:W}),warn:_({},N,{value:D}),error:_({},N,{value:I}),group:_({},N,{value:G}),groupCollapsed:_({},N,{value:X}),groupEnd:_({},N,{value:M})})}Y<0&&b("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var H=y.ReactCurrentDispatcher,O;function P(N,Z,re){{if(O===void 0)try{throw Error()}catch(Me){var de=Me.stack.trim().match(/\n( *(at )?)/);O=de&&de[1]||""}return`
18
+ `+O+N}}var U=!1,Q;{var se=typeof WeakMap=="function"?WeakMap:Map;Q=new se}function ie(N,Z){if(!N||U)return"";{var re=Q.get(N);if(re!==void 0)return re}var de;U=!0;var Me=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var Oe;Oe=H.current,H.current=null,R();try{if(Z){var We=function(){throw Error()};if(Object.defineProperty(We.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(We,[])}catch(Kt){de=Kt}Reflect.construct(N,[],We)}else{try{We.call()}catch(Kt){de=Kt}N.call(We.prototype)}}else{try{throw Error()}catch(Kt){de=Kt}N()}}catch(Kt){if(Kt&&de&&typeof Kt.stack=="string"){for(var Be=Kt.stack.split(`
19
19
  `),Ft=de.stack.split(`
20
20
  `),vt=Be.length-1,yt=Ft.length-1;vt>=1&&yt>=0&&Be[vt]!==Ft[yt];)yt--;for(;vt>=1&&yt>=0;vt--,yt--)if(Be[vt]!==Ft[yt]){if(vt!==1||yt!==1)do if(vt--,yt--,yt<0||Be[vt]!==Ft[yt]){var an=`
21
- `+Be[vt].replace(" at new "," at ");return N.displayName&&an.includes("<anonymous>")&&(an=an.replace("<anonymous>",N.displayName)),typeof N=="function"&&Q.set(N,an),an}while(vt>=1&&yt>=0);break}}}finally{U=!1,z.current=Oe,$(),Error.prepareStackTrace=Me}var Ur=N?N.displayName||N.name:"",pr=Ur?j(Ur):"";return typeof N=="function"&&Q.set(N,pr),pr}function Se(N,Z,re){return ie(N,!1)}function xe(N){var Z=N.prototype;return!!(Z&&Z.isReactComponent)}function Re(N,Z,re){if(N==null)return"";if(typeof N=="function")return ie(N,xe(N));if(typeof N=="string")return j(N);switch(N){case l:return j("Suspense");case d:return j("SuspenseList")}if(typeof N=="object")switch(N.$$typeof){case c:return Se(N.render);case f:return Re(N.type,Z,re);case m:{var de=N,Me=de._payload,Oe=de._init;try{return Re(Oe(Me),Z,re)}catch{}}}return""}var Ve=Object.prototype.hasOwnProperty,De={},Ge=y.ReactDebugCurrentFrame;function He(N){if(N){var Z=N._owner,re=Re(N.type,N._source,Z?Z.type:null);Ge.setExtraStackFrame(re)}else Ge.setExtraStackFrame(null)}function ot(N,Z,re,de,Me){{var Oe=Function.call.bind(Ve);for(var We in N)if(Oe(N,We)){var Be=void 0;try{if(typeof N[We]!="function"){var Ft=Error((de||"React class")+": "+re+" type `"+We+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof N[We]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw Ft.name="Invariant Violation",Ft}Be=N[We](Z,We,de,re,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(vt){Be=vt}Be&&!(Be instanceof Error)&&(He(Me),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).",de||"React class",re,We,typeof Be),He(null)),Be instanceof Error&&!(Be.message in De)&&(De[Be.message]=!0,He(Me),b("Failed %s type: %s",re,Be.message),He(null))}}}var ut=Array.isArray;function nt(N){return ut(N)}function Le(N){{var Z=typeof Symbol=="function"&&Symbol.toStringTag,re=Z&&N[Symbol.toStringTag]||N.constructor.name||"Object";return re}}function Ke(N){try{return $e(N),!1}catch{return!0}}function $e(N){return""+N}function Te(N){if(Ke(N))return b("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Le(N)),$e(N)}var Ae=y.ReactCurrentOwner,dt={key:!0,ref:!0,__self:!0,__source:!0},Et,at;function It(N){if(Ve.call(N,"ref")){var Z=Object.getOwnPropertyDescriptor(N,"ref").get;if(Z&&Z.isReactWarning)return!1}return N.ref!==void 0}function bt(N){if(Ve.call(N,"key")){var Z=Object.getOwnPropertyDescriptor(N,"key").get;if(Z&&Z.isReactWarning)return!1}return N.key!==void 0}function ft(N,Z){typeof N.ref=="string"&&Ae.current}function Nt(N,Z){{var re=function(){Et||(Et=!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)",Z))};re.isReactWarning=!0,Object.defineProperty(N,"key",{get:re,configurable:!0})}}function At(N,Z){{var re=function(){at||(at=!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)",Z))};re.isReactWarning=!0,Object.defineProperty(N,"ref",{get:re,configurable:!0})}}var Ct=function(N,Z,re,de,Me,Oe,We){var Be={$$typeof:t,type:N,key:Z,ref:re,props:We,_owner:Oe};return Be._store={},Object.defineProperty(Be._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(Be,"_self",{configurable:!1,enumerable:!1,writable:!1,value:de}),Object.defineProperty(Be,"_source",{configurable:!1,enumerable:!1,writable:!1,value:Me}),Object.freeze&&(Object.freeze(Be.props),Object.freeze(Be)),Be};function on(N,Z,re,de,Me){{var Oe,We={},Be=null,Ft=null;re!==void 0&&(Te(re),Be=""+re),bt(Z)&&(Te(Z.key),Be=""+Z.key),It(Z)&&(Ft=Z.ref,ft(Z,Me));for(Oe in Z)Ve.call(Z,Oe)&&!dt.hasOwnProperty(Oe)&&(We[Oe]=Z[Oe]);if(N&&N.defaultProps){var vt=N.defaultProps;for(Oe in vt)We[Oe]===void 0&&(We[Oe]=vt[Oe])}if(Be||Ft){var yt=typeof N=="function"?N.displayName||N.name||"Unknown":N;Be&&Nt(We,yt),Ft&&At(We,yt)}return Ct(N,Be,Ft,Me,de,Ae.current,We)}}var Tt=y.ReactCurrentOwner,Ie=y.ReactDebugCurrentFrame;function Ue(N){if(N){var Z=N._owner,re=Re(N.type,N._source,Z?Z.type:null);Ie.setExtraStackFrame(re)}else Ie.setExtraStackFrame(null)}var jt;jt=!1;function te(N){return typeof N=="object"&&N!==null&&N.$$typeof===t}function ge(){{if(Tt.current){var N=J(Tt.current.type);if(N)return`
21
+ `+Be[vt].replace(" at new "," at ");return N.displayName&&an.includes("<anonymous>")&&(an=an.replace("<anonymous>",N.displayName)),typeof N=="function"&&Q.set(N,an),an}while(vt>=1&&yt>=0);break}}}finally{U=!1,H.current=Oe,F(),Error.prepareStackTrace=Me}var Vr=N?N.displayName||N.name:"",gr=Vr?P(Vr):"";return typeof N=="function"&&Q.set(N,gr),gr}function Se(N,Z,re){return ie(N,!1)}function xe(N){var Z=N.prototype;return!!(Z&&Z.isReactComponent)}function Re(N,Z,re){if(N==null)return"";if(typeof N=="function")return ie(N,xe(N));if(typeof N=="string")return P(N);switch(N){case l:return P("Suspense");case d:return P("SuspenseList")}if(typeof N=="object")switch(N.$$typeof){case c:return Se(N.render);case f:return Re(N.type,Z,re);case m:{var de=N,Me=de._payload,Oe=de._init;try{return Re(Oe(Me),Z,re)}catch{}}}return""}var Ve=Object.prototype.hasOwnProperty,De={},Ge=y.ReactDebugCurrentFrame;function He(N){if(N){var Z=N._owner,re=Re(N.type,N._source,Z?Z.type:null);Ge.setExtraStackFrame(re)}else Ge.setExtraStackFrame(null)}function ot(N,Z,re,de,Me){{var Oe=Function.call.bind(Ve);for(var We in N)if(Oe(N,We)){var Be=void 0;try{if(typeof N[We]!="function"){var Ft=Error((de||"React class")+": "+re+" type `"+We+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof N[We]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw Ft.name="Invariant Violation",Ft}Be=N[We](Z,We,de,re,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(vt){Be=vt}Be&&!(Be instanceof Error)&&(He(Me),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).",de||"React class",re,We,typeof Be),He(null)),Be instanceof Error&&!(Be.message in De)&&(De[Be.message]=!0,He(Me),b("Failed %s type: %s",re,Be.message),He(null))}}}var ut=Array.isArray;function nt(N){return ut(N)}function Le(N){{var Z=typeof Symbol=="function"&&Symbol.toStringTag,re=Z&&N[Symbol.toStringTag]||N.constructor.name||"Object";return re}}function Ke(N){try{return $e(N),!1}catch{return!0}}function $e(N){return""+N}function Te(N){if(Ke(N))return b("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Le(N)),$e(N)}var Ae=y.ReactCurrentOwner,dt={key:!0,ref:!0,__self:!0,__source:!0},Et,at;function It(N){if(Ve.call(N,"ref")){var Z=Object.getOwnPropertyDescriptor(N,"ref").get;if(Z&&Z.isReactWarning)return!1}return N.ref!==void 0}function bt(N){if(Ve.call(N,"key")){var Z=Object.getOwnPropertyDescriptor(N,"key").get;if(Z&&Z.isReactWarning)return!1}return N.key!==void 0}function ft(N,Z){typeof N.ref=="string"&&Ae.current}function Nt(N,Z){{var re=function(){Et||(Et=!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)",Z))};re.isReactWarning=!0,Object.defineProperty(N,"key",{get:re,configurable:!0})}}function At(N,Z){{var re=function(){at||(at=!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)",Z))};re.isReactWarning=!0,Object.defineProperty(N,"ref",{get:re,configurable:!0})}}var Ct=function(N,Z,re,de,Me,Oe,We){var Be={$$typeof:t,type:N,key:Z,ref:re,props:We,_owner:Oe};return Be._store={},Object.defineProperty(Be._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(Be,"_self",{configurable:!1,enumerable:!1,writable:!1,value:de}),Object.defineProperty(Be,"_source",{configurable:!1,enumerable:!1,writable:!1,value:Me}),Object.freeze&&(Object.freeze(Be.props),Object.freeze(Be)),Be};function on(N,Z,re,de,Me){{var Oe,We={},Be=null,Ft=null;re!==void 0&&(Te(re),Be=""+re),bt(Z)&&(Te(Z.key),Be=""+Z.key),It(Z)&&(Ft=Z.ref,ft(Z,Me));for(Oe in Z)Ve.call(Z,Oe)&&!dt.hasOwnProperty(Oe)&&(We[Oe]=Z[Oe]);if(N&&N.defaultProps){var vt=N.defaultProps;for(Oe in vt)We[Oe]===void 0&&(We[Oe]=vt[Oe])}if(Be||Ft){var yt=typeof N=="function"?N.displayName||N.name||"Unknown":N;Be&&Nt(We,yt),Ft&&At(We,yt)}return Ct(N,Be,Ft,Me,de,Ae.current,We)}}var Tt=y.ReactCurrentOwner,Ie=y.ReactDebugCurrentFrame;function Ue(N){if(N){var Z=N._owner,re=Re(N.type,N._source,Z?Z.type:null);Ie.setExtraStackFrame(re)}else Ie.setExtraStackFrame(null)}var Pt;Pt=!1;function te(N){return typeof N=="object"&&N!==null&&N.$$typeof===t}function ge(){{if(Tt.current){var N=J(Tt.current.type);if(N)return`
22
22
 
23
23
  Check the render method of \``+N+"`."}return""}}function rt(N){return""}var fe={};function ke(N){{var Z=ge();if(!Z){var re=typeof N=="string"?N:N.displayName||N.name;re&&(Z=`
24
24
 
25
- Check the top-level render call using <`+re+">.")}return Z}}function Fe(N,Z){{if(!N._store||N._store.validated||N.key!=null)return;N._store.validated=!0;var re=ke(Z);if(fe[re])return;fe[re]=!0;var de="";N&&N._owner&&N._owner!==Tt.current&&(de=" It was passed a child from "+J(N._owner.type)+"."),Ue(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.',re,de),Ue(null)}}function ht(N,Z){{if(typeof N!="object")return;if(nt(N))for(var re=0;re<N.length;re++){var de=N[re];te(de)&&Fe(de,Z)}else if(te(N))N._store&&(N._store.validated=!0);else if(N){var Me=x(N);if(typeof Me=="function"&&Me!==N.entries)for(var Oe=Me.call(N),We;!(We=Oe.next()).done;)te(We.value)&&Fe(We.value,Z)}}}function pt(N){{var Z=N.type;if(Z==null||typeof Z=="string")return;var re;if(typeof Z=="function")re=Z.propTypes;else if(typeof Z=="object"&&(Z.$$typeof===c||Z.$$typeof===f))re=Z.propTypes;else return;if(re){var de=J(Z);ot(re,N.props,"prop",de,N)}else if(Z.PropTypes!==void 0&&!jt){jt=!0;var Me=J(Z);b("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",Me||"Unknown")}typeof Z.getDefaultProps=="function"&&!Z.getDefaultProps.isReactClassApproved&&b("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function je(N){{for(var Z=Object.keys(N.props),re=0;re<Z.length;re++){var de=Z[re];if(de!=="children"&&de!=="key"){Ue(N),b("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",de),Ue(null);break}}N.ref!==null&&(Ue(N),b("Invalid attribute `ref` supplied to `React.Fragment`."),Ue(null))}}var Ye={};function we(N,Z,re,de,Me,Oe){{var We=L(N);if(!We){var Be="";(N===void 0||typeof N=="object"&&N!==null&&Object.keys(N).length===0)&&(Be+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var Ft=rt();Ft?Be+=Ft:Be+=ge();var vt;N===null?vt="null":nt(N)?vt="array":N!==void 0&&N.$$typeof===t?(vt="<"+(J(N.type)||"Unknown")+" />",Be=" 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,Be)}var yt=on(N,Z,re,Me,Oe);if(yt==null)return yt;if(We){var an=Z.children;if(an!==void 0)if(de)if(nt(an)){for(var Ur=0;Ur<an.length;Ur++)ht(an[Ur],N);Object.freeze&&Object.freeze(an)}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 ht(an,N)}if(Ve.call(Z,"key")){var pr=J(N),Kt=Object.keys(Z).filter(function(hN){return hN!=="key"}),tc=Kt.length>0?"{key: someKey, "+Kt.join(": ..., ")+": ...}":"{key: someKey}";if(!Ye[pr+tc]){var pN=Kt.length>0?"{"+Kt.join(": ..., ")+": ...}":"{}";b(`A props object containing a "key" prop is being spread into JSX:
25
+ Check the top-level render call using <`+re+">.")}return Z}}function Fe(N,Z){{if(!N._store||N._store.validated||N.key!=null)return;N._store.validated=!0;var re=ke(Z);if(fe[re])return;fe[re]=!0;var de="";N&&N._owner&&N._owner!==Tt.current&&(de=" It was passed a child from "+J(N._owner.type)+"."),Ue(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.',re,de),Ue(null)}}function ht(N,Z){{if(typeof N!="object")return;if(nt(N))for(var re=0;re<N.length;re++){var de=N[re];te(de)&&Fe(de,Z)}else if(te(N))N._store&&(N._store.validated=!0);else if(N){var Me=x(N);if(typeof Me=="function"&&Me!==N.entries)for(var Oe=Me.call(N),We;!(We=Oe.next()).done;)te(We.value)&&Fe(We.value,Z)}}}function pt(N){{var Z=N.type;if(Z==null||typeof Z=="string")return;var re;if(typeof Z=="function")re=Z.propTypes;else if(typeof Z=="object"&&(Z.$$typeof===c||Z.$$typeof===f))re=Z.propTypes;else return;if(re){var de=J(Z);ot(re,N.props,"prop",de,N)}else if(Z.PropTypes!==void 0&&!Pt){Pt=!0;var Me=J(Z);b("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",Me||"Unknown")}typeof Z.getDefaultProps=="function"&&!Z.getDefaultProps.isReactClassApproved&&b("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Pe(N){{for(var Z=Object.keys(N.props),re=0;re<Z.length;re++){var de=Z[re];if(de!=="children"&&de!=="key"){Ue(N),b("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",de),Ue(null);break}}N.ref!==null&&(Ue(N),b("Invalid attribute `ref` supplied to `React.Fragment`."),Ue(null))}}var Ye={};function we(N,Z,re,de,Me,Oe){{var We=L(N);if(!We){var Be="";(N===void 0||typeof N=="object"&&N!==null&&Object.keys(N).length===0)&&(Be+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var Ft=rt();Ft?Be+=Ft:Be+=ge();var vt;N===null?vt="null":nt(N)?vt="array":N!==void 0&&N.$$typeof===t?(vt="<"+(J(N.type)||"Unknown")+" />",Be=" 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,Be)}var yt=on(N,Z,re,Me,Oe);if(yt==null)return yt;if(We){var an=Z.children;if(an!==void 0)if(de)if(nt(an)){for(var Vr=0;Vr<an.length;Vr++)ht(an[Vr],N);Object.freeze&&Object.freeze(an)}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 ht(an,N)}if(Ve.call(Z,"key")){var gr=J(N),Kt=Object.keys(Z).filter(function(hN){return hN!=="key"}),sc=Kt.length>0?"{key: someKey, "+Kt.join(": ..., ")+": ...}":"{key: someKey}";if(!Ye[gr+sc]){var pN=Kt.length>0?"{"+Kt.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} />`,tc,pr,pN,pr),Ye[pr+tc]=!0}}return N===r?je(yt):pt(yt),yt}}function Qe(N,Z,re){return we(N,Z,re,!0)}function Xe(N,Z,re){return we(N,Z,re,!1)}var ct=Xe,sn=Qe;Gr.Fragment=r,Gr.jsx=ct,Gr.jsxs=sn}()),Gr}process.env.NODE_ENV==="production"?Ci.exports=Sx():Ci.exports=Cx();var u=Ci.exports;const Tx=({timelineEntries:e,activeCheckpointId:t,onSelectCheckpoint:n,messagePreviews:r,className:o,onHoverStart:s,onHoverEnd:i})=>{const a=e??[],c=a.length>0,l=w.useMemo(()=>c?[...a].reverse():[],[a,c]),d=t??(a.length?a[a.length-1].id:null);if(!c)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:l.map(p=>{const v=d===p.id,g=(r==null?void 0:r.get(p.id))??null;return u.jsxs("button",{type:"button",disabled:!n,onClick:()=>n==null?void 0:n(p.id),className:`relative flex items-start gap-2 text-left text-[11px] transition ${v?"text-primary":"text-muted-foreground"} ${n?"hover:text-foreground":"cursor-default opacity-70"}`,children:[u.jsx("span",{className:`mt-1 inline-flex h-3 w-3 items-center justify-center rounded-full border ${v?"border-primary bg-primary/10 text-primary":"border-border bg-background"}`,children:u.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${v?"bg-primary":"bg-border"}`})}),u.jsxs("span",{className:"flex-1",children:[u.jsx("span",{className:"block font-medium leading-tight",children:p.label||"User input"}),u.jsxs("span",{className:"text-[9px] uppercase tracking-wide text-muted-foreground/70",children:[p.step!==null?`STEP ${p.step}`:"STEP —",p.next?` - ${p.next}`:""]}),g&&u.jsx("p",{className:"text-[10px] text-muted-foreground/80 mt-1 line-clamp-2",title:g,children:g})]})]},p.id)})})]}),n&&u.jsx("button",{type:"button",onClick:()=>n==null?void 0:n(null),className:"mt-auto mb-3 rounded-md border border-border/70 px-2 py-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground transition hover:border-foreground/60 hover:text-foreground",children:"Latest"})]})};function dc(e,t){return function(){return e.apply(t,arguments)}}const{toString:kx}=Object.prototype,{getPrototypeOf:Ti}=Object,{iterator:$o,toStringTag:fc}=Symbol,Fo=(e=>t=>{const n=kx.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),ln=e=>(e=e.toLowerCase(),t=>Fo(t)===e),Bo=e=>t=>typeof t===e,{isArray:mr}=Array,gr=Bo("undefined");function Yr(e){return e!==null&&!gr(e)&&e.constructor!==null&&!gr(e.constructor)&&Bt(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const pc=ln("ArrayBuffer");function Ex(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&pc(e.buffer),t}const Ix=Bo("string"),Bt=Bo("function"),hc=Bo("number"),Xr=e=>e!==null&&typeof e=="object",Nx=e=>e===!0||e===!1,zo=e=>{if(Fo(e)!=="object")return!1;const t=Ti(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(fc in e)&&!($o in e)},Ax=e=>{if(!Xr(e)||Yr(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},jx=ln("Date"),Px=ln("File"),_x=ln("Blob"),Rx=ln("FileList"),Mx=e=>Xr(e)&&Bt(e.pipe),Ox=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||Bt(e.append)&&((t=Fo(e))==="formdata"||t==="object"&&Bt(e.toString)&&e.toString()==="[object FormData]"))},Dx=ln("URLSearchParams"),[Lx,$x,Fx,Bx]=["ReadableStream","Request","Response","Headers"].map(ln),zx=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Jr(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,o;if(typeof e!="object"&&(e=[e]),mr(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{if(Yr(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 mc(e,t){if(Yr(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,gc=e=>!gr(e)&&e!==Xn;function ki(){const{caseless:e,skipUndefined:t}=gc(this)&&this||{},n={},r=(o,s)=>{const i=e&&mc(n,s)||s;zo(n[i])&&zo(o)?n[i]=ki(n[i],o):zo(o)?n[i]=ki({},o):mr(o)?n[i]=o.slice():(!t||!gr(o))&&(n[i]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&Jr(arguments[o],r);return n}const Hx=(e,t,n,{allOwnKeys:r}={})=>(Jr(t,(o,s)=>{n&&Bt(o)?e[s]=dc(o,n):e[s]=o},{allOwnKeys:r}),e),Ux=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Wx=(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)},Vx=(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&&Ti(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},Kx=(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},qx=e=>{if(!e)return null;if(mr(e))return e;let t=e.length;if(!hc(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Gx=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&Ti(Uint8Array)),Yx=(e,t)=>{const r=(e&&e[$o]).call(e);let o;for(;(o=r.next())&&!o.done;){const s=o.value;t.call(e,s[0],s[1])}},Xx=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},Jx=ln("HTMLFormElement"),Zx=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),xc=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),Qx=ln("RegExp"),vc=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};Jr(n,(o,s)=>{let i;(i=t(o,s,e))!==!1&&(r[s]=i||o)}),Object.defineProperties(e,r)},ev=e=>{vc(e,(t,n)=>{if(Bt(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(Bt(r)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},tv=(e,t)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return mr(e)?r(e):r(String(e).split(t)),n},nv=()=>{},rv=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function ov(e){return!!(e&&Bt(e.append)&&e[fc]==="FormData"&&e[$o])}const sv=e=>{const t=new Array(10),n=(r,o)=>{if(Xr(r)){if(t.indexOf(r)>=0)return;if(Yr(r))return r;if(!("toJSON"in r)){t[o]=r;const s=mr(r)?[]:{};return Jr(r,(i,a)=>{const c=n(i,o+1);!gr(c)&&(s[a]=c)}),t[o]=void 0,s}}return r};return n(e,0)},iv=ln("AsyncFunction"),av=e=>e&&(Xr(e)||Bt(e))&&Bt(e.then)&&Bt(e.catch),wc=((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",Bt(Xn.postMessage)),lv=typeof queueMicrotask<"u"?queueMicrotask.bind(Xn):typeof process<"u"&&process.nextTick||wc,V={isArray:mr,isArrayBuffer:pc,isBuffer:Yr,isFormData:Ox,isArrayBufferView:Ex,isString:Ix,isNumber:hc,isBoolean:Nx,isObject:Xr,isPlainObject:zo,isEmptyObject:Ax,isReadableStream:Lx,isRequest:$x,isResponse:Fx,isHeaders:Bx,isUndefined:gr,isDate:jx,isFile:Px,isBlob:_x,isRegExp:Qx,isFunction:Bt,isStream:Mx,isURLSearchParams:Dx,isTypedArray:Gx,isFileList:Rx,forEach:Jr,merge:ki,extend:Hx,trim:zx,stripBOM:Ux,inherits:Wx,toFlatObject:Vx,kindOf:Fo,kindOfTest:ln,endsWith:Kx,toArray:qx,forEachEntry:Yx,matchAll:Xx,isHTMLForm:Jx,hasOwnProperty:xc,hasOwnProp:xc,reduceDescriptors:vc,freezeMethods:ev,toObjectSet:tv,toCamelCase:Zx,noop:nv,toFiniteNumber:rv,findKey:mc,global:Xn,isContextDefined:gc,isSpecCompliantForm:ov,toJSONObject:sv,isAsyncFn:iv,isThenable:av,setImmediate:wc,asap:lv,isIterable:e=>e!=null&&Bt(e[$o])};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 bc=Ee.prototype,yc={};["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=>{yc[e]={value:e}}),Object.defineProperties(Ee,yc),Object.defineProperty(bc,"isAxiosError",{value:!0}),Ee.from=(e,t,n,r,o,s)=>{const i=Object.create(bc);V.toFlatObject(e,i,function(d){return d!==Error.prototype},l=>l!=="isAxiosError");const a=e&&e.message?e.message:"Error",c=t==null&&e?e.code:t;return Ee.call(i,a,c,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 cv=null;function Ei(e){return V.isPlainObject(e)||V.isArray(e)}function Sc(e){return V.endsWith(e,"[]")?e.slice(0,-2):e}function Cc(e,t,n){return e?e.concat(t).map(function(o,s){return o=Sc(o),!n&&s?"["+o+"]":o}).join(n?".":""):t}function uv(e){return V.isArray(e)&&!e.some(Ei)}const dv=V.toFlatObject(V,{},null,function(t){return/^is[A-Z]/.test(t)});function Ho(e,t,n){if(!V.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=V.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(g,x){return!V.isUndefined(x[g])});const r=n.metaTokens,o=n.visitor||d,s=n.dots,i=n.indexes,c=(n.Blob||typeof Blob<"u"&&Blob)&&V.isSpecCompliantForm(t);if(!V.isFunction(o))throw new TypeError("visitor must be a function");function l(v){if(v===null)return"";if(V.isDate(v))return v.toISOString();if(V.isBoolean(v))return v.toString();if(!c&&V.isBlob(v))throw new Ee("Blob is not supported. Use a Buffer instead.");return V.isArrayBuffer(v)||V.isTypedArray(v)?c&&typeof Blob=="function"?new Blob([v]):Buffer.from(v):v}function d(v,g,x){let y=v;if(v&&!x&&typeof v=="object"){if(V.endsWith(g,"{}"))g=r?g:g.slice(0,-2),v=JSON.stringify(v);else if(V.isArray(v)&&uv(v)||(V.isFileList(v)||V.endsWith(g,"[]"))&&(y=V.toArray(v)))return g=Sc(g),y.forEach(function(T,E){!(V.isUndefined(T)||T===null)&&t.append(i===!0?Cc([g],E,s):i===null?g:g+"[]",l(T))}),!1}return Ei(v)?!0:(t.append(Cc(x,g,s),l(v)),!1)}const f=[],m=Object.assign(dv,{defaultVisitor:d,convertValue:l,isVisitable:Ei});function p(v,g){if(!V.isUndefined(v)){if(f.indexOf(v)!==-1)throw Error("Circular reference detected in "+g.join("."));f.push(v),V.forEach(v,function(y,b){(!(V.isUndefined(y)||y===null)&&o.call(t,y,V.isString(b)?b.trim():b,g,m))===!0&&p(y,g?g.concat(b):[b])}),f.pop()}}if(!V.isObject(e))throw new TypeError("data must be an object");return p(e),t}function Tc(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function Ii(e,t){this._pairs=[],e&&Ho(e,this,t)}const kc=Ii.prototype;kc.append=function(t,n){this._pairs.push([t,n])},kc.toString=function(t){const n=t?function(r){return t.call(this,r,Tc)}:Tc;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function fv(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Ec(e,t,n){if(!t)return e;const r=n&&n.encode||fv;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 Ii(t,n).toString(r),s){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}class Ic{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 Nc={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},pv={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:Ii,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},Ni=typeof window<"u"&&typeof document<"u",Ai=typeof navigator=="object"&&navigator||void 0,hv=Ni&&(!Ai||["ReactNative","NativeScript","NS"].indexOf(Ai.product)<0),mv=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",gv=Ni&&window.location.href||"http://localhost",Pt={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Ni,hasStandardBrowserEnv:hv,hasStandardBrowserWebWorkerEnv:mv,navigator:Ai,origin:gv},Symbol.toStringTag,{value:"Module"})),...pv};function xv(e,t){return Ho(e,new Pt.classes.URLSearchParams,{visitor:function(n,r,o,s){return Pt.isNode&&V.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function vv(e){return V.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function wv(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 Ac(e){function t(n,r,o,s){let i=n[s++];if(i==="__proto__")return!0;const a=Number.isFinite(+i),c=s>=n.length;return i=!i&&V.isArray(o)?o.length:i,c?(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]=wv(o[i])),!a)}if(V.isFormData(e)&&V.isFunction(e.entries)){const n={};return V.forEachEntry(e,(r,o)=>{t(vv(r),o,n,0)}),n}return null}function bv(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 Zr={transitional:Nc,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(Ac(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 xv(t,this.formSerializer).toString();if((a=V.isFileList(t))||r.indexOf("multipart/form-data")>-1){const c=this.env&&this.env.FormData;return Ho(a?{"files[]":t}:t,c&&new c,this.formSerializer)}}return s||o?(n.setContentType("application/json",!1),bv(t)):t}],transformResponse:[function(t){const n=this.transitional||Zr.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:Pt.classes.FormData,Blob:Pt.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=>{Zr.headers[e]={}});const yv=V.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),Sv=e=>{const t={};let n,r,o;return e&&e.split(`
31
- `).forEach(function(i){o=i.indexOf(":"),n=i.substring(0,o).trim().toLowerCase(),r=i.substring(o+1).trim(),!(!n||t[n]&&yv[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},jc=Symbol("internals");function Qr(e){return e&&String(e).trim().toLowerCase()}function Uo(e){return e===!1||e==null?e:V.isArray(e)?e.map(Uo):String(e)}function Cv(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 Tv=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function ji(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 kv(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function Ev(e,t){const n=V.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{value:function(o,s,i){return this[r].call(this,t,o,s,i)},configurable:!0})})}let zt=class{constructor(t){t&&this.set(t)}set(t,n,r){const o=this;function s(a,c,l){const d=Qr(c);if(!d)throw new Error("header name must be a non-empty string");const f=V.findKey(o,d);(!f||o[f]===void 0||l===!0||l===void 0&&o[f]!==!1)&&(o[f||c]=Uo(a))}const i=(a,c)=>V.forEach(a,(l,d)=>s(l,d,c));if(V.isPlainObject(t)||t instanceof this.constructor)i(t,n);else if(V.isString(t)&&(t=t.trim())&&!Tv(t))i(Sv(t),n);else if(V.isObject(t)&&V.isIterable(t)){let a={},c,l;for(const d of t){if(!V.isArray(d))throw TypeError("Object iterator must return a key-value pair");a[l=d[0]]=(c=a[l])?V.isArray(c)?[...c,d[1]]:[c,d[1]]:d[1]}i(a,n)}else t!=null&&s(n,t,r);return this}get(t,n){if(t=Qr(t),t){const r=V.findKey(this,t);if(r){const o=this[r];if(!n)return o;if(n===!0)return Cv(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=Qr(t),t){const r=V.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||ji(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let o=!1;function s(i){if(i=Qr(i),i){const a=V.findKey(r,i);a&&(!n||ji(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||ji(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]=Uo(o),delete n[s];return}const a=t?kv(s):String(s).trim();a!==s&&delete n[s],n[a]=Uo(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[jc]=this[jc]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=Qr(i);r[a]||(Ev(o,i),r[a]=!0)}return V.isArray(t)?t.forEach(s):s(t),this}};zt.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),V.reduceDescriptors(zt.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),V.freezeMethods(zt);function Pi(e,t){const n=this||Zr,r=t||n,o=zt.from(r.headers);let s=r.data;return V.forEach(e,function(a){s=a.call(n,s,o.normalize(),t?t.status:void 0)}),o.normalize(),s}function Pc(e){return!!(e&&e.__CANCEL__)}function xr(e,t,n){Ee.call(this,e??"canceled",Ee.ERR_CANCELED,t,n),this.name="CanceledError"}V.inherits(xr,Ee,{__CANCEL__:!0});function _c(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 Iv(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Nv(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(c){const l=Date.now(),d=r[s];i||(i=l),n[o]=c,r[o]=l;let f=s,m=0;for(;f!==o;)m+=n[f++],f=f%e;if(o=(o+1)%e,o===s&&(s=(s+1)%e),l-i<t)return;const p=d&&l-d;return p?Math.round(m*1e3/p):void 0}}function Av(e,t){let n=0,r=1e3/t,o,s;const i=(l,d=Date.now())=>{n=d,o=null,s&&(clearTimeout(s),s=null),e(...l)};return[(...l)=>{const d=Date.now(),f=d-n;f>=r?i(l,d):(o=l,s||(s=setTimeout(()=>{s=null,i(o)},r-f)))},()=>o&&i(o)]}const Wo=(e,t,n=3)=>{let r=0;const o=Nv(50,250);return Av(s=>{const i=s.loaded,a=s.lengthComputable?s.total:void 0,c=i-r,l=o(c),d=i<=a;r=i;const f={loaded:i,total:a,progress:a?i/a:void 0,bytes:c,rate:l||void 0,estimated:l&&a&&d?(a-i)/l:void 0,event:s,lengthComputable:a!=null,[t?"download":"upload"]:!0};e(f)},n)},Rc=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},Mc=e=>(...t)=>V.asap(()=>e(...t)),jv=Pt.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,Pt.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(Pt.origin),Pt.navigator&&/(msie|trident)/i.test(Pt.navigator.userAgent)):()=>!0,Pv=Pt.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 _v(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Rv(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function Oc(e,t,n){let r=!_v(t);return e&&(r||n==!1)?Rv(e,t):t}const Dc=e=>e instanceof zt?{...e}:e;function Jn(e,t){t=t||{};const n={};function r(l,d,f,m){return V.isPlainObject(l)&&V.isPlainObject(d)?V.merge.call({caseless:m},l,d):V.isPlainObject(d)?V.merge({},d):V.isArray(d)?d.slice():d}function o(l,d,f,m){if(V.isUndefined(d)){if(!V.isUndefined(l))return r(void 0,l,f,m)}else return r(l,d,f,m)}function s(l,d){if(!V.isUndefined(d))return r(void 0,d)}function i(l,d){if(V.isUndefined(d)){if(!V.isUndefined(l))return r(void 0,l)}else return r(void 0,d)}function a(l,d,f){if(f in t)return r(l,d);if(f in e)return r(void 0,l)}const c={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:(l,d,f)=>o(Dc(l),Dc(d),f,!0)};return V.forEach(Object.keys({...e,...t}),function(d){const f=c[d]||o,m=f(e[d],t[d],d);V.isUndefined(m)&&f!==a||(n[d]=m)}),n}const Lc=e=>{const t=Jn({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=zt.from(i),t.url=Ec(Oc(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(Pt.hasStandardBrowserEnv||Pt.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(V.isFunction(n.getHeaders)){const c=n.getHeaders(),l=["content-type","content-length"];Object.entries(c).forEach(([d,f])=>{l.includes(d.toLowerCase())&&i.set(d,f)})}}if(Pt.hasStandardBrowserEnv&&(r&&V.isFunction(r)&&(r=r(t)),r||r!==!1&&jv(t.url))){const c=o&&s&&Pv.read(s);c&&i.set(o,c)}return t},Mv=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=Lc(e);let s=o.data;const i=zt.from(o.headers).normalize();let{responseType:a,onUploadProgress:c,onDownloadProgress:l}=o,d,f,m,p,v;function g(){p&&p(),v&&v(),o.cancelToken&&o.cancelToken.unsubscribe(d),o.signal&&o.signal.removeEventListener("abort",d)}let x=new XMLHttpRequest;x.open(o.method.toUpperCase(),o.url,!0),x.timeout=o.timeout;function y(){if(!x)return;const T=zt.from("getAllResponseHeaders"in x&&x.getAllResponseHeaders()),S={data:!a||a==="text"||a==="json"?x.responseText:x.response,status:x.status,statusText:x.statusText,headers:T,config:e,request:x};_c(function(k){n(k),g()},function(k){r(k),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 Ee("Request aborted",Ee.ECONNABORTED,e,x)),x=null)},x.onerror=function(E){const S=E&&E.message?E.message:"Network Error",C=new Ee(S,Ee.ERR_NETWORK,e,x);C.event=E||null,r(C),x=null},x.ontimeout=function(){let E=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const S=o.transitional||Nc;o.timeoutErrorMessage&&(E=o.timeoutErrorMessage),r(new Ee(E,S.clarifyTimeoutError?Ee.ETIMEDOUT:Ee.ECONNABORTED,e,x)),x=null},s===void 0&&i.setContentType(null),"setRequestHeader"in x&&V.forEach(i.toJSON(),function(E,S){x.setRequestHeader(S,E)}),V.isUndefined(o.withCredentials)||(x.withCredentials=!!o.withCredentials),a&&a!=="json"&&(x.responseType=o.responseType),l&&([m,v]=Wo(l,!0),x.addEventListener("progress",m)),c&&x.upload&&([f,p]=Wo(c),x.upload.addEventListener("progress",f),x.upload.addEventListener("loadend",p)),(o.cancelToken||o.signal)&&(d=T=>{x&&(r(!T||T.type?new xr(null,e,x):T),x.abort(),x=null)},o.cancelToken&&o.cancelToken.subscribe(d),o.signal&&(o.signal.aborted?d():o.signal.addEventListener("abort",d)));const b=Iv(o.url);if(b&&Pt.protocols.indexOf(b)===-1){r(new Ee("Unsupported protocol "+b+":",Ee.ERR_BAD_REQUEST,e));return}x.send(s||null)})},Ov=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let r=new AbortController,o;const s=function(l){if(!o){o=!0,a();const d=l instanceof Error?l:this.reason;r.abort(d instanceof Ee?d:new xr(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(l=>{l.unsubscribe?l.unsubscribe(s):l.removeEventListener("abort",s)}),e=null)};e.forEach(l=>l.addEventListener("abort",s));const{signal:c}=r;return c.unsubscribe=()=>V.asap(a),c}},Dv=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},Lv=async function*(e,t){for await(const n of $v(e))yield*Dv(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()}},$c=(e,t,n,r)=>{const o=Lv(e,t);let s=0,i,a=c=>{i||(i=!0,r&&r(c))};return new ReadableStream({async pull(c){try{const{done:l,value:d}=await o.next();if(l){a(),c.close();return}let f=d.byteLength;if(n){let m=s+=f;n(m)}c.enqueue(new Uint8Array(d))}catch(l){throw a(l),l}},cancel(c){return a(c),o.return()}},{highWaterMark:2})},Fc=64*1024,{isFunction:Vo}=V,Fv=(({Request:e,Response:t})=>({Request:e,Response:t}))(V.global),{ReadableStream:Bc,TextEncoder:zc}=V.global,Hc=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Bv=e=>{e=V.merge.call({skipUndefined:!0},Fv,e);const{fetch:t,Request:n,Response:r}=e,o=t?Vo(t):typeof fetch=="function",s=Vo(n),i=Vo(r);if(!o)return!1;const a=o&&Vo(Bc),c=o&&(typeof zc=="function"?(v=>g=>v.encode(g))(new zc):async v=>new Uint8Array(await new n(v).arrayBuffer())),l=s&&a&&Hc(()=>{let v=!1;const g=new n(Pt.origin,{body:new Bc,method:"POST",get duplex(){return v=!0,"half"}}).headers.has("Content-Type");return v&&!g}),d=i&&a&&Hc(()=>V.isReadableStream(new r("").body)),f={stream:d&&(v=>v.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(v=>{!f[v]&&(f[v]=(g,x)=>{let y=g&&g[v];if(y)return y.call(g);throw new Ee(`Response type '${v}' is not supported`,Ee.ERR_NOT_SUPPORT,x)})});const m=async v=>{if(v==null)return 0;if(V.isBlob(v))return v.size;if(V.isSpecCompliantForm(v))return(await new n(Pt.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 c(v)).byteLength},p=async(v,g)=>{const x=V.toFiniteNumber(v.getContentLength());return x??m(g)};return async v=>{let{url:g,method:x,data:y,signal:b,cancelToken:T,timeout:E,onDownloadProgress:S,onUploadProgress:C,responseType:k,headers:A,withCredentials:P="same-origin",fetchOptions:L}=Lc(v),F=t||fetch;k=k?(k+"").toLowerCase():"text";let K=Ov([b,T&&T.toAbortSignal()],E),J=null;const _=K&&K.unsubscribe&&(()=>{K.unsubscribe()});let Y;try{if(C&&l&&x!=="get"&&x!=="head"&&(Y=await p(A,y))!==0){let X=new n(g,{method:"POST",body:y,duplex:"half"}),M;if(V.isFormData(y)&&(M=X.headers.get("content-type"))&&A.setContentType(M),X.body){const[B,R]=Rc(Y,Wo(Mc(C)));y=$c(X.body,Fc,B,R)}}V.isString(P)||(P=P?"include":"omit");const q=s&&"credentials"in n.prototype,W={...L,signal:K,method:x.toUpperCase(),headers:A.normalize().toJSON(),body:y,duplex:"half",credentials:q?P:void 0};J=s&&new n(g,W);let D=await(s?F(J,L):F(g,W));const I=d&&(k==="stream"||k==="response");if(d&&(S||I&&_)){const X={};["status","statusText","headers"].forEach($=>{X[$]=D[$]});const M=V.toFiniteNumber(D.headers.get("content-length")),[B,R]=S&&Rc(M,Wo(Mc(S),!0))||[];D=new r($c(D.body,Fc,B,()=>{R&&R(),_&&_()}),X)}k=k||"text";let G=await f[V.findKey(f,k)||"text"](D,v);return!I&&_&&_(),await new Promise((X,M)=>{_c(X,M,{data:G,headers:zt.from(D.headers),status:D.status,statusText:D.statusText,config:v,request:J})})}catch(q){throw _&&_(),q&&q.name==="TypeError"&&/Load failed|fetch/i.test(q.message)?Object.assign(new Ee("Network Error",Ee.ERR_NETWORK,v,J),{cause:q.cause||q}):Ee.from(q,q&&q.code,v,J)}}},zv=new Map,Uc=e=>{let t=e?e.env:{};const{fetch:n,Request:r,Response:o}=t,s=[r,o,n];let i=s.length,a=i,c,l,d=zv;for(;a--;)c=s[a],l=d.get(c),l===void 0&&d.set(c,l=a?new Map:Bv(t)),d=l;return l};Uc();const _i={http:cv,xhr:Mv,fetch:{get:Uc}};V.forEach(_i,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Wc=e=>`- ${e}`,Hv=e=>V.isFunction(e)||e===null||e===!1,Vc={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,!Hv(r)&&(o=_i[(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(([c,l])=>`adapter ${c} `+(l===!1?"is not supported by the environment":"is not available in the build"));let a=n?i.length>1?`since :
33
- `+i.map(Wc).join(`
34
- `):" "+Wc(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:_i};function Ri(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new xr(null,e)}function Kc(e){return Ri(e),e.headers=zt.from(e.headers),e.data=Pi.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),Vc.getAdapter(e.adapter||Zr.adapter,e)(e).then(function(r){return Ri(e),r.data=Pi.call(e,e.transformResponse,r),r.headers=zt.from(r.headers),r},function(r){return Pc(r)||(Ri(e),r&&r.response&&(r.response.data=Pi.call(e,e.transformResponse,r.response),r.response.headers=zt.from(r.response.headers))),Promise.reject(r)})}const qc="1.12.2",Ko={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Ko[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const Gc={};Ko.transitional=function(t,n,r){function o(s,i){return"[Axios v"+qc+"] 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&&!Gc[i]&&(Gc[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}},Ko.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function Uv(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],c=a===void 0||i(a,s,e);if(c!==!0)throw new Ee("option "+s+" must be "+c,Ee.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new Ee("Unknown option "+s,Ee.ERR_BAD_OPTION)}}const qo={assertOptions:Uv,validators:Ko},xn=qo.validators;let Zn=class{constructor(t){this.defaults=t||{},this.interceptors={request:new Ic,response:new Ic}}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&&qo.assertOptions(r,{silentJSONParsing:xn.transitional(xn.boolean),forcedJSONParsing:xn.transitional(xn.boolean),clarifyTimeoutError:xn.transitional(xn.boolean)},!1),o!=null&&(V.isFunction(o)?n.paramsSerializer={serialize:o}:qo.assertOptions(o,{encode:xn.function,serialize:xn.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),qo.assertOptions(n,{baseUrl:xn.spelling("baseURL"),withXsrfToken:xn.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=s&&V.merge(s.common,s[n.method]);s&&V.forEach(["delete","get","head","post","put","patch","common"],v=>{delete s[v]}),n.headers=zt.concat(i,s);const a=[];let c=!0;this.interceptors.request.forEach(function(g){typeof g.runWhen=="function"&&g.runWhen(n)===!1||(c=c&&g.synchronous,a.unshift(g.fulfilled,g.rejected))});const l=[];this.interceptors.response.forEach(function(g){l.push(g.fulfilled,g.rejected)});let d,f=0,m;if(!c){const v=[Kc.bind(this),void 0];for(v.unshift(...a),v.push(...l),m=v.length,d=Promise.resolve(n);f<m;)d=d.then(v[f++],v[f++]);return d}m=a.length;let p=n;for(;f<m;){const v=a[f++],g=a[f++];try{p=v(p)}catch(x){g.call(this,x);break}}try{d=Kc.call(this,p)}catch(v){return Promise.reject(v)}for(f=0,m=l.length;f<m;)d=d.then(l[f++],l[f++]);return d}getUri(t){t=Jn(this.defaults,t);const n=Oc(t.baseURL,t.url,t.allowAbsoluteUrls);return Ec(n,t.params,t.paramsSerializer)}};V.forEach(["delete","get","head","options"],function(t){Zn.prototype[t]=function(n,r){return this.request(Jn(r||{},{method:t,url:n,data:(r||{}).data}))}}),V.forEach(["post","put","patch"],function(t){function n(r){return function(s,i,a){return this.request(Jn(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}Zn.prototype[t]=n(),Zn.prototype[t+"Form"]=n(!0)});let Wv=class lx{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(s){n=s});const r=this;this.promise.then(o=>{if(!r._listeners)return;let s=r._listeners.length;for(;s-- >0;)r._listeners[s](o);r._listeners=null}),this.promise.then=o=>{let s;const i=new Promise(a=>{r.subscribe(a),s=a}).then(o);return i.cancel=function(){r.unsubscribe(s)},i},t(function(s,i,a){r.reason||(r.reason=new xr(s,i,a),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const t=new AbortController,n=r=>{t.abort(r)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new lx(function(o){t=o}),cancel:t}}};function Vv(e){return function(n){return e.apply(null,n)}}function Kv(e){return V.isObject(e)&&e.isAxiosError===!0}const Mi={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(Mi).forEach(([e,t])=>{Mi[t]=e});function Yc(e){const t=new Zn(e),n=dc(Zn.prototype.request,t);return V.extend(n,Zn.prototype,t,{allOwnKeys:!0}),V.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return Yc(Jn(e,o))},n}const mt=Yc(Zr);mt.Axios=Zn,mt.CanceledError=xr,mt.CancelToken=Wv,mt.isCancel=Pc,mt.VERSION=qc,mt.toFormData=Ho,mt.AxiosError=Ee,mt.Cancel=mt.CanceledError,mt.all=function(t){return Promise.all(t)},mt.spread=Vv,mt.isAxiosError=Kv,mt.mergeConfig=Jn,mt.AxiosHeaders=zt,mt.formToJSON=e=>Ac(V.isHTMLForm(e)?new FormData(e):e),mt.getAdapter=Vc.getAdapter,mt.HttpStatusCode=Mi,mt.default=mt;const{Axios:TN,AxiosError:kN,CanceledError:EN,isCancel:Xc,CancelToken:IN,VERSION:NN,all:AN,Cancel:jN,isAxiosError:PN,spread:_N,toFormData:RN,AxiosHeaders:MN,HttpStatusCode:ON,formToJSON:DN,getAdapter:LN,mergeConfig:$N}=mt,Jc=typeof window<"u"?window.__API_BASE_URL__:void 0,Zc=Jc?vn(Jc):void 0;function vn(e){const n=(e!=null&&e.trim()?e.trim():"/api/chat").replace(/\/+$/,"");return n?n.endsWith("/chat")?n:`${n}/chat`:"/api/chat"}let Go=null;const Oi=new Set;function Qc(){return Go}function Yo(e){Go=e,Oi.forEach(t=>t(e))}function eu(e){return Oi.add(e),()=>Oi.delete(e)}const tu=3e4,nu=9e4,Gt=mt.create({...Zc?{baseURL:Zc}:{},timeout:tu,withCredentials:!0});Gt.interceptors.request.use(e=>(Go&&(e.headers.Authorization=`Bearer ${Go}`),e)),Gt.interceptors.response.use(e=>{if(typeof window<"u"&&(e!=null&&e.data))try{const t=e.data,n=t.data||{},r=typeof t.token=="string"&&t.token||typeof n.token=="string"&&n.token||null,o=typeof t.expires_at=="number"&&t.expires_at||typeof n.expires_at=="number"&&n.expires_at||typeof t.expiresAt=="number"&&t.expiresAt||typeof n.expiresAt=="number"&&n.expiresAt||null;r&&(localStorage.setItem("authToken",r),Yo(r)),o&&localStorage.setItem("authTokenExpiresAt",o.toString()),(r||o)&&window.dispatchEvent(new CustomEvent("smartorg:chat-token-updated",{detail:{token:r,expiresAt:o}}))}catch(t){console.warn("[chat-api] Error storing token:",t)}return e},e=>Promise.reject(e));async function Yt(e,t){return Gt.defaults.baseURL?(await Gt.get(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}async function Xo(e,t,n){return Gt.defaults.baseURL?(await Gt.post(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function ru(e,t,n){return Gt.defaults.baseURL?(await Gt.put(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function Di(e,t){return Gt.defaults.baseURL?(await Gt.delete(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}function Dt(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class Jo{get baseUrl(){const t=Gt.defaults.baseURL;return t?vn(String(t)):""}updateConfig(t){t.baseUrl&&(Gt.defaults.baseURL=vn(String(t.baseUrl))),t.authToken!==void 0&&Yo(t.authToken)}getAuthToken(){return Qc()}setAuthToken(t){Yo(t)}onTokenChange(t){return eu(t)}async listThreads(){const t=await Yt("/threads"),n=Dt(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async listSharedThreads(){const t=await Yt("/threads/shared"),n=Dt(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async createThread(t){const r=await Xo("/threads",t?{title:t}:void 0);return Dt(r)}async updateThread(t,n){const r=await ru(`/threads/${t}`,{title:n});return Dt(r)}async deleteThread(t){const n=await Di(`/threads/${t}`);return Dt(n)}async shareThread(t,n){const r=await Xo(`/threads/${t}/share`,{shared_with_user_id:n});return Dt(r)}async threadInfo(t){const n=await Yt(`/threads/${t}/info`);return Dt(n)}async listAgents(){const t=await Yt("/agents"),n=Dt(t);return(n==null?void 0:n.items)??[]}async getAgent(t){const n=await Yt(`/agents/${t}`);return Dt(n)}async getAgentSchema(t){const n=await Yt(`/agents/${t}/schema`);return Dt(n)}async getState(t){const n=await Yt(`/threads/${t.threadId}/state`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return Dt(n)}async getStateHistory(t){const n=await Yt(`/threads/${t.threadId}/state/history`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs},timeout:nu,signal:t.signal});return Dt(n)}async cancelRun(t){const n=await Xo("/runs/cancel",{threadId:t});return Dt(n)}async unshareThread(t,n){const r=await Di(`/threads/${t}/share/${n}`);return Dt(r)}}const Nn=new Jo,qv=Jo,Gv=Jo;async function Li(e,t){return await Yt(e,{responseType:"blob",onDownloadProgress:r=>{try{if(t&&r.lengthComputable){const o=r.loaded/r.total;t(o)}}catch{}},maxBodyLength:1/0})}async function Yv(e,t){const n=await Li(`/files/${e}/view`,t),r=URL.createObjectURL(n);window.open(r,"_blank"),setTimeout(()=>URL.revokeObjectURL(r),6e4)}async function $i(e,t){return await(await Li(`/files/${e}/view`,t)).text()}async function ou(e,t){const n=await Li(`/files/${e}/download`,t),r=URL.createObjectURL(n);let o=`file_${e}`;try{const i=await Yt(`/files/${e}`);o=(i==null?void 0:i.filename)??o}catch{}const s=document.createElement("a");s.href=r,s.download=o,document.body.appendChild(s),s.click(),s.remove(),setTimeout(()=>URL.revokeObjectURL(r),6e4)}async function Xv(e){return await Yt(`/files/${e}`)}async function su(e,t=50,n=0){const r={limit:t,offset:n};return e&&(r.thread_id=e),await Yt("/files",{params:r})}const iu=w.createContext(null);function au({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(iu.Provider,{value:r,children:e})}async function lu(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 c=0;c<a;c++)i+=String.fromCharCode(s[c]);t(btoa(i))}catch(o){n(o)}},r.onerror=o=>n(o),r.readAsArrayBuffer(e)})}async function cu(e=[]){const t=[],n=[];for(const r of e)try{const o=await lu(r);n.push({filename:r.name,data:o,mime_type:r.type||"application/octet-stream"})}catch{}return{contentParts:t,filesInfo:n}}function eo(){const e=w.useContext(iu);if(!e)throw new Error("useApi must be used within ApiProvider");return e}function uu(e){return!!e&&typeof e=="object"&&"data"in e}function Fi(e){return e.filter(t=>{var i;if(t.role!=="assistant")return!0;const n=(t.content??[]).some(a=>{var c;return a&&a.type==="text"&&((c=a.text)==null?void 0:c.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 to(e,t,n){return t<0||t>=e.length?e:[...e.slice(0,t),n,...e.slice(t+1)]}function Jv(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 du(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="assistant")return e[t].id;return null}function fu(e){return!e||!e.length?"":e.filter(t=>t.type==="text").map(t=>t.text??"").join("")}function pu(e,t,n,r){const o={...n};if(r!==null&&typeof r=="number"){if(typeof o.lastSeq=="number"&&r<=o.lastSeq)return{newParts:e,newMeta:o,changed:!1};o.lastSeq=r}const s=t.filter(f=>f.type==="text").map(f=>f.text??"").join(""),i=t.filter(f=>f.type!=="text"),a=o.lastText??fu(e);let c="",l=e.slice();if(s){const f=Zv(a,s);if(f===""?c="":f===s?c=s:c=f,c){const m=l[l.length-1];if((m==null?void 0:m.type)==="text"){const p=m.text??"",v={...m,text:p+c};l=[...l.slice(0,l.length-1),v]}else l=[...l,{type:"text",text:c}];o.lastText=a+c}else o.lastText=a}i.length&&(l=[...l,...i]);const d=!!(c||i.length);return{newParts:l,newMeta:o,changed:d}}function hu(e){return e.replace(/\s+/g," ").trim()}function Zv(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=hu(e),o=hu(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 to(e,r,s)}return e}function mu(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}function ew(e={}){const t=w.useMemo(()=>vn(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,c]=w.useState(!1),[l,d]=w.useState(null),[f,m]=w.useState(""),[p,v]=w.useState(null),[g,x]=w.useState(0),[y,b]=w.useState(!1),[T,E]=w.useState(null),S=w.useRef(null),C=w.useRef(!0),k=w.useRef(0),A=w.useRef(null),P=w.useRef(null),L=w.useRef(null),F=w.useRef(null),K=w.useRef({messageId:null,lastSeq:null,lastText:""}),J=w.useCallback(W=>{o(W)},[]),_=w.useCallback(()=>{m(""),v(null),d(null),P.current=null,L.current=null,F.current=null,E(null),K.current={messageId:null,lastSeq:null,lastText:""}},[]),Y=w.useCallback(()=>{var G;console.debug("[use-chat] stop() invoked - aborting stream");const W=(G=A.current)==null?void 0:G.threadId,D=()=>{var X;(X=S.current)==null||X.abort(),S.current=null,A.current=null,c(!1),b(!1),k.current=0,x(0)};(W?Nn.cancelRun(W).catch(X=>{console.warn("[use-chat] cancel run failed:",X)}):Promise.resolve()).finally(D)},[]),q=w.useCallback((W,D,I)=>{S.current&&(S.current.abort(),S.current=null),c(!0),d(null),e.autoAppendAssistant!==!1&&m(""),v(null),P.current=null,L.current=null,F.current=null,E(null),K.current={messageId:null,lastSeq:null,lastText:""};const G=new AbortController;S.current=G;let X=null,M=null,B=!1;return A.current={threadId:W.threadId??null,headers:{}},(async()=>{var $,z,O,j,U,Q,se,ie,Se,xe,Re,Ve,De,Ge,He,ot,ut,nt;const R=Le=>{var Ke;try{const $e=JSON.parse(JSON.stringify(Le));return(Ke=$e==null?void 0:$e.payload)!=null&&Ke.files_info&&Array.isArray($e.payload.files_info)&&($e.payload.files_info=$e.payload.files_info.map(Te=>({...Te,data:Te!=null&&Te.data?`<base64 ${String(Te.data).length} chars>`:Te==null?void 0:Te.data}))),$e}catch{return Le}};try{let Le={};try{if(r)Le={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const Ue=window.__AUTH_TOKEN__,jt=(($=window.localStorage)==null?void 0:$.getItem("authToken"))||null;let te=null;try{const rt=(z=window.localStorage)==null?void 0:z.getItem("chat-settings");rt&&(te=((O=JSON.parse(rt))==null?void 0:O.apiKey)||null)}catch{}const ge=Ue||jt||te||null;ge&&(Le={Authorization:`Bearer ${ge}`})}}catch{}console.debug("[use-chat] POST",t+n,R(W));let Ke={};if(typeof window<"u")try{const Ie=(j=window.localStorage)==null?void 0:j.getItem("authSessionId");Ie&&(Ke={"X-Session-Id":Ie})}catch{}const $e={...Le,...Ke,...s.current},Te={"Content-Type":"application/json",Accept:"text/event-stream",...$e},Ae=await fetch(t+n,{method:"POST",headers:Te,body:JSON.stringify(W),signal:G.signal,credentials:i});if(A.current&&(A.current.headers=$e),!Ae.ok||!Ae.body){const Ie=await Ae.text().catch(()=>"");console.debug("[use-chat] non-OK response",Ae.status,Ie==null?void 0:Ie.slice(0,500));const Ue=`stream ${Ae.status}${Ie?": "+Ie:""}`;throw(U=I==null?void 0:I.onConnectionError)==null||U.call(I,Ue),B=!0,X="error",M=Ue,new Error(Ue)}b(!0);const dt=Ae.body.getReader(),Et=new TextDecoder;let at="",It=[];k.current=0,x(0);let bt=0,ft=null;const Nt=()=>{if(It.length){const Ie=It.join("");It=[],C.current&&m(Ue=>Ue+Ie)}ft=null},At=()=>{typeof window<"u"&&ft==null&&(ft=requestAnimationFrame(Nt))};let Ct=Date.now();const on=setInterval(()=>{var Ie;if(Date.now()-Ct>18e5){const Ue="Stream idle timeout";d(Ue),X="error",M=Ue,G.abort(),(Ie=I==null?void 0:I.onError)==null||Ie.call(I,Ue)}},5e3),Tt=1024*1024;try{const Ie=Ae.headers.get("X-Thread-Id")||Ae.headers.get("x-thread-id"),Ue=Ae.headers.get("X-Thread-Created")||Ae.headers.get("x-thread-created"),jt=Ie??null,te=String(Ue??"").toLowerCase()==="true";for(A.current&&!A.current.threadId&&(A.current={...A.current,threadId:jt}),(Q=I==null?void 0:I.onOpen)==null||Q.call(I,{threadId:jt,created:te});;){const{value:ge,done:rt}=await dt.read();if(rt)break;at+=Et.decode(ge,{stream:!0}),at.length>Tt&&(at="",console.warn("Stream buffer reset: exceeded 1MB"));let fe;for(;(fe=at.indexOf(`
30
+ <%s key={someKey} {...props} />`,sc,gr,pN,gr),Ye[gr+sc]=!0}}return N===r?Pe(yt):pt(yt),yt}}function Qe(N,Z,re){return we(N,Z,re,!0)}function Xe(N,Z,re){return we(N,Z,re,!1)}var ct=Xe,sn=Qe;Xr.Fragment=r,Xr.jsx=ct,Xr.jsxs=sn}()),Xr}process.env.NODE_ENV==="production"?Ti.exports=_x():Ti.exports=Rx();var u=Ti.exports;const Mx=({timelineEntries:e,activeCheckpointId:t,onSelectCheckpoint:n,messagePreviews:r,className:o,onHoverStart:s,onHoverEnd:i})=>{const a=e??[],c=a.length>0,l=w.useMemo(()=>c?[...a].reverse():[],[a,c]),d=t??(a.length?a[a.length-1].id:null);if(!c)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:l.map(p=>{const v=d===p.id,g=(r==null?void 0:r.get(p.id))??null;return u.jsxs("button",{type:"button",disabled:!n,onClick:()=>n==null?void 0:n(p.id),className:`relative flex items-start gap-2 text-left text-[11px] transition ${v?"text-primary":"text-muted-foreground"} ${n?"hover:text-foreground":"cursor-default opacity-70"}`,children:[u.jsx("span",{className:`mt-1 inline-flex h-3 w-3 items-center justify-center rounded-full border ${v?"border-primary bg-primary/10 text-primary":"border-border bg-background"}`,children:u.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${v?"bg-primary":"bg-border"}`})}),u.jsxs("span",{className:"flex-1",children:[u.jsx("span",{className:"block font-medium leading-tight",children:p.label||"User input"}),u.jsxs("span",{className:"text-[9px] uppercase tracking-wide text-muted-foreground/70",children:[p.step!==null?`STEP ${p.step}`:"STEP —",p.next?` - ${p.next}`:""]}),g&&u.jsx("p",{className:"text-[10px] text-muted-foreground/80 mt-1 line-clamp-2",title:g,children:g})]})]},p.id)})})]}),n&&u.jsx("button",{type:"button",onClick:()=>n==null?void 0:n(null),className:"mt-auto mb-3 rounded-md border border-border/70 px-2 py-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground transition hover:border-foreground/60 hover:text-foreground",children:"Latest"})]})};function mc(e,t){return function(){return e.apply(t,arguments)}}const{toString:Ox}=Object.prototype,{getPrototypeOf:ki}=Object,{iterator:$o,toStringTag:gc}=Symbol,Fo=(e=>t=>{const n=Ox.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),ln=e=>(e=e.toLowerCase(),t=>Fo(t)===e),Bo=e=>t=>typeof t===e,{isArray:vr}=Array,wr=Bo("undefined");function Jr(e){return e!==null&&!wr(e)&&e.constructor!==null&&!wr(e.constructor)&&Bt(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const xc=ln("ArrayBuffer");function Dx(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&xc(e.buffer),t}const Lx=Bo("string"),Bt=Bo("function"),vc=Bo("number"),Zr=e=>e!==null&&typeof e=="object",$x=e=>e===!0||e===!1,zo=e=>{if(Fo(e)!=="object")return!1;const t=ki(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(gc in e)&&!($o in e)},Fx=e=>{if(!Zr(e)||Jr(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},Bx=ln("Date"),zx=ln("File"),Hx=ln("Blob"),Ux=ln("FileList"),Wx=e=>Zr(e)&&Bt(e.pipe),Vx=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||Bt(e.append)&&((t=Fo(e))==="formdata"||t==="object"&&Bt(e.toString)&&e.toString()==="[object FormData]"))},Kx=ln("URLSearchParams"),[qx,Gx,Yx,Xx]=["ReadableStream","Request","Response","Headers"].map(ln),Jx=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Qr(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,o;if(typeof e!="object"&&(e=[e]),vr(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{if(Jr(e))return;const s=n?Object.getOwnPropertyNames(e):Object.keys(e),i=s.length;let a;for(r=0;r<i;r++)a=s[r],t.call(null,e[a],a,e)}}function wc(e,t){if(Jr(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,bc=e=>!wr(e)&&e!==Xn;function Ei(){const{caseless:e,skipUndefined:t}=bc(this)&&this||{},n={},r=(o,s)=>{const i=e&&wc(n,s)||s;zo(n[i])&&zo(o)?n[i]=Ei(n[i],o):zo(o)?n[i]=Ei({},o):vr(o)?n[i]=o.slice():(!t||!wr(o))&&(n[i]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&Qr(arguments[o],r);return n}const Zx=(e,t,n,{allOwnKeys:r}={})=>(Qr(t,(o,s)=>{n&&Bt(o)?e[s]=mc(o,n):e[s]=o},{allOwnKeys:r}),e),Qx=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),ev=(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)},tv=(e,t,n,r)=>{let o,s,i;const a={};if(t=t||{},e==null)return t;do{for(o=Object.getOwnPropertyNames(e),s=o.length;s-- >0;)i=o[s],(!r||r(i,e,t))&&!a[i]&&(t[i]=e[i],a[i]=!0);e=n!==!1&&ki(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},nv=(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},rv=e=>{if(!e)return null;if(vr(e))return e;let t=e.length;if(!vc(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},ov=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&ki(Uint8Array)),sv=(e,t)=>{const r=(e&&e[$o]).call(e);let o;for(;(o=r.next())&&!o.done;){const s=o.value;t.call(e,s[0],s[1])}},iv=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},av=ln("HTMLFormElement"),lv=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),yc=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),cv=ln("RegExp"),Sc=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};Qr(n,(o,s)=>{let i;(i=t(o,s,e))!==!1&&(r[s]=i||o)}),Object.defineProperties(e,r)},uv=e=>{Sc(e,(t,n)=>{if(Bt(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(Bt(r)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},dv=(e,t)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return vr(e)?r(e):r(String(e).split(t)),n},fv=()=>{},pv=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function hv(e){return!!(e&&Bt(e.append)&&e[gc]==="FormData"&&e[$o])}const mv=e=>{const t=new Array(10),n=(r,o)=>{if(Zr(r)){if(t.indexOf(r)>=0)return;if(Jr(r))return r;if(!("toJSON"in r)){t[o]=r;const s=vr(r)?[]:{};return Qr(r,(i,a)=>{const c=n(i,o+1);!wr(c)&&(s[a]=c)}),t[o]=void 0,s}}return r};return n(e,0)},gv=ln("AsyncFunction"),xv=e=>e&&(Zr(e)||Bt(e))&&Bt(e.then)&&Bt(e.catch),Cc=((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",Bt(Xn.postMessage)),vv=typeof queueMicrotask<"u"?queueMicrotask.bind(Xn):typeof process<"u"&&process.nextTick||Cc,V={isArray:vr,isArrayBuffer:xc,isBuffer:Jr,isFormData:Vx,isArrayBufferView:Dx,isString:Lx,isNumber:vc,isBoolean:$x,isObject:Zr,isPlainObject:zo,isEmptyObject:Fx,isReadableStream:qx,isRequest:Gx,isResponse:Yx,isHeaders:Xx,isUndefined:wr,isDate:Bx,isFile:zx,isBlob:Hx,isRegExp:cv,isFunction:Bt,isStream:Wx,isURLSearchParams:Kx,isTypedArray:ov,isFileList:Ux,forEach:Qr,merge:Ei,extend:Zx,trim:Jx,stripBOM:Qx,inherits:ev,toFlatObject:tv,kindOf:Fo,kindOfTest:ln,endsWith:nv,toArray:rv,forEachEntry:sv,matchAll:iv,isHTMLForm:av,hasOwnProperty:yc,hasOwnProp:yc,reduceDescriptors:Sc,freezeMethods:uv,toObjectSet:dv,toCamelCase:lv,noop:fv,toFiniteNumber:pv,findKey:wc,global:Xn,isContextDefined:bc,isSpecCompliantForm:hv,toJSONObject:mv,isAsyncFn:gv,isThenable:xv,setImmediate:Cc,asap:vv,isIterable:e=>e!=null&&Bt(e[$o])};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 Tc=Ee.prototype,kc={};["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=>{kc[e]={value:e}}),Object.defineProperties(Ee,kc),Object.defineProperty(Tc,"isAxiosError",{value:!0}),Ee.from=(e,t,n,r,o,s)=>{const i=Object.create(Tc);V.toFlatObject(e,i,function(d){return d!==Error.prototype},l=>l!=="isAxiosError");const a=e&&e.message?e.message:"Error",c=t==null&&e?e.code:t;return Ee.call(i,a,c,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 wv=null;function Ii(e){return V.isPlainObject(e)||V.isArray(e)}function Ec(e){return V.endsWith(e,"[]")?e.slice(0,-2):e}function Ic(e,t,n){return e?e.concat(t).map(function(o,s){return o=Ec(o),!n&&s?"["+o+"]":o}).join(n?".":""):t}function bv(e){return V.isArray(e)&&!e.some(Ii)}const yv=V.toFlatObject(V,{},null,function(t){return/^is[A-Z]/.test(t)});function Ho(e,t,n){if(!V.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=V.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(g,x){return!V.isUndefined(x[g])});const r=n.metaTokens,o=n.visitor||d,s=n.dots,i=n.indexes,c=(n.Blob||typeof Blob<"u"&&Blob)&&V.isSpecCompliantForm(t);if(!V.isFunction(o))throw new TypeError("visitor must be a function");function l(v){if(v===null)return"";if(V.isDate(v))return v.toISOString();if(V.isBoolean(v))return v.toString();if(!c&&V.isBlob(v))throw new Ee("Blob is not supported. Use a Buffer instead.");return V.isArrayBuffer(v)||V.isTypedArray(v)?c&&typeof Blob=="function"?new Blob([v]):Buffer.from(v):v}function d(v,g,x){let y=v;if(v&&!x&&typeof v=="object"){if(V.endsWith(g,"{}"))g=r?g:g.slice(0,-2),v=JSON.stringify(v);else if(V.isArray(v)&&bv(v)||(V.isFileList(v)||V.endsWith(g,"[]"))&&(y=V.toArray(v)))return g=Ec(g),y.forEach(function(T,E){!(V.isUndefined(T)||T===null)&&t.append(i===!0?Ic([g],E,s):i===null?g:g+"[]",l(T))}),!1}return Ii(v)?!0:(t.append(Ic(x,g,s),l(v)),!1)}const f=[],m=Object.assign(yv,{defaultVisitor:d,convertValue:l,isVisitable:Ii});function p(v,g){if(!V.isUndefined(v)){if(f.indexOf(v)!==-1)throw Error("Circular reference detected in "+g.join("."));f.push(v),V.forEach(v,function(y,b){(!(V.isUndefined(y)||y===null)&&o.call(t,y,V.isString(b)?b.trim():b,g,m))===!0&&p(y,g?g.concat(b):[b])}),f.pop()}}if(!V.isObject(e))throw new TypeError("data must be an object");return p(e),t}function Nc(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function Ni(e,t){this._pairs=[],e&&Ho(e,this,t)}const Ac=Ni.prototype;Ac.append=function(t,n){this._pairs.push([t,n])},Ac.toString=function(t){const n=t?function(r){return t.call(this,r,Nc)}:Nc;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function Sv(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Pc(e,t,n){if(!t)return e;const r=n&&n.encode||Sv;V.isFunction(n)&&(n={serialize:n});const o=n&&n.serialize;let s;if(o?s=o(t,n):s=V.isURLSearchParams(t)?t.toString():new Ni(t,n).toString(r),s){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}class jc{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 _c={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Cv={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:Ni,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},Ai=typeof window<"u"&&typeof document<"u",Pi=typeof navigator=="object"&&navigator||void 0,Tv=Ai&&(!Pi||["ReactNative","NativeScript","NS"].indexOf(Pi.product)<0),kv=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Ev=Ai&&window.location.href||"http://localhost",jt={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Ai,hasStandardBrowserEnv:Tv,hasStandardBrowserWebWorkerEnv:kv,navigator:Pi,origin:Ev},Symbol.toStringTag,{value:"Module"})),...Cv};function Iv(e,t){return Ho(e,new jt.classes.URLSearchParams,{visitor:function(n,r,o,s){return jt.isNode&&V.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function Nv(e){return V.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function Av(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 Rc(e){function t(n,r,o,s){let i=n[s++];if(i==="__proto__")return!0;const a=Number.isFinite(+i),c=s>=n.length;return i=!i&&V.isArray(o)?o.length:i,c?(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]=Av(o[i])),!a)}if(V.isFormData(e)&&V.isFunction(e.entries)){const n={};return V.forEachEntry(e,(r,o)=>{t(Nv(r),o,n,0)}),n}return null}function Pv(e,t,n){if(V.isString(e))try{return(t||JSON.parse)(e),V.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const eo={transitional:_c,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(Rc(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 Iv(t,this.formSerializer).toString();if((a=V.isFileList(t))||r.indexOf("multipart/form-data")>-1){const c=this.env&&this.env.FormData;return Ho(a?{"files[]":t}:t,c&&new c,this.formSerializer)}}return s||o?(n.setContentType("application/json",!1),Pv(t)):t}],transformResponse:[function(t){const n=this.transitional||eo.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:jt.classes.FormData,Blob:jt.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};V.forEach(["delete","get","head","post","put","patch"],e=>{eo.headers[e]={}});const jv=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"]),_v=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]&&jv[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},Mc=Symbol("internals");function to(e){return e&&String(e).trim().toLowerCase()}function Uo(e){return e===!1||e==null?e:V.isArray(e)?e.map(Uo):String(e)}function Rv(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 Mv=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function ji(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 Ov(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function Dv(e,t){const n=V.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{value:function(o,s,i){return this[r].call(this,t,o,s,i)},configurable:!0})})}let zt=class{constructor(t){t&&this.set(t)}set(t,n,r){const o=this;function s(a,c,l){const d=to(c);if(!d)throw new Error("header name must be a non-empty string");const f=V.findKey(o,d);(!f||o[f]===void 0||l===!0||l===void 0&&o[f]!==!1)&&(o[f||c]=Uo(a))}const i=(a,c)=>V.forEach(a,(l,d)=>s(l,d,c));if(V.isPlainObject(t)||t instanceof this.constructor)i(t,n);else if(V.isString(t)&&(t=t.trim())&&!Mv(t))i(_v(t),n);else if(V.isObject(t)&&V.isIterable(t)){let a={},c,l;for(const d of t){if(!V.isArray(d))throw TypeError("Object iterator must return a key-value pair");a[l=d[0]]=(c=a[l])?V.isArray(c)?[...c,d[1]]:[c,d[1]]:d[1]}i(a,n)}else t!=null&&s(n,t,r);return this}get(t,n){if(t=to(t),t){const r=V.findKey(this,t);if(r){const o=this[r];if(!n)return o;if(n===!0)return Rv(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=to(t),t){const r=V.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||ji(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let o=!1;function s(i){if(i=to(i),i){const a=V.findKey(r,i);a&&(!n||ji(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||ji(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]=Uo(o),delete n[s];return}const a=t?Ov(s):String(s).trim();a!==s&&delete n[s],n[a]=Uo(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[Mc]=this[Mc]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=to(i);r[a]||(Dv(o,i),r[a]=!0)}return V.isArray(t)?t.forEach(s):s(t),this}};zt.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),V.reduceDescriptors(zt.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),V.freezeMethods(zt);function _i(e,t){const n=this||eo,r=t||n,o=zt.from(r.headers);let s=r.data;return V.forEach(e,function(a){s=a.call(n,s,o.normalize(),t?t.status:void 0)}),o.normalize(),s}function Oc(e){return!!(e&&e.__CANCEL__)}function br(e,t,n){Ee.call(this,e??"canceled",Ee.ERR_CANCELED,t,n),this.name="CanceledError"}V.inherits(br,Ee,{__CANCEL__:!0});function Dc(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 Lv(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function $v(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(c){const l=Date.now(),d=r[s];i||(i=l),n[o]=c,r[o]=l;let f=s,m=0;for(;f!==o;)m+=n[f++],f=f%e;if(o=(o+1)%e,o===s&&(s=(s+1)%e),l-i<t)return;const p=d&&l-d;return p?Math.round(m*1e3/p):void 0}}function Fv(e,t){let n=0,r=1e3/t,o,s;const i=(l,d=Date.now())=>{n=d,o=null,s&&(clearTimeout(s),s=null),e(...l)};return[(...l)=>{const d=Date.now(),f=d-n;f>=r?i(l,d):(o=l,s||(s=setTimeout(()=>{s=null,i(o)},r-f)))},()=>o&&i(o)]}const Wo=(e,t,n=3)=>{let r=0;const o=$v(50,250);return Fv(s=>{const i=s.loaded,a=s.lengthComputable?s.total:void 0,c=i-r,l=o(c),d=i<=a;r=i;const f={loaded:i,total:a,progress:a?i/a:void 0,bytes:c,rate:l||void 0,estimated:l&&a&&d?(a-i)/l:void 0,event:s,lengthComputable:a!=null,[t?"download":"upload"]:!0};e(f)},n)},Lc=(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)),Bv=jt.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,jt.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(jt.origin),jt.navigator&&/(msie|trident)/i.test(jt.navigator.userAgent)):()=>!0,zv=jt.hasStandardBrowserEnv?{write(e,t,n,r,o,s){const i=[e+"="+encodeURIComponent(t)];V.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),V.isString(r)&&i.push("path="+r),V.isString(o)&&i.push("domain="+o),s===!0&&i.push("secure"),document.cookie=i.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function Hv(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Uv(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function Fc(e,t,n){let r=!Hv(t);return e&&(r||n==!1)?Uv(e,t):t}const Bc=e=>e instanceof zt?{...e}:e;function Jn(e,t){t=t||{};const n={};function r(l,d,f,m){return V.isPlainObject(l)&&V.isPlainObject(d)?V.merge.call({caseless:m},l,d):V.isPlainObject(d)?V.merge({},d):V.isArray(d)?d.slice():d}function o(l,d,f,m){if(V.isUndefined(d)){if(!V.isUndefined(l))return r(void 0,l,f,m)}else return r(l,d,f,m)}function s(l,d){if(!V.isUndefined(d))return r(void 0,d)}function i(l,d){if(V.isUndefined(d)){if(!V.isUndefined(l))return r(void 0,l)}else return r(void 0,d)}function a(l,d,f){if(f in t)return r(l,d);if(f in e)return r(void 0,l)}const c={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:(l,d,f)=>o(Bc(l),Bc(d),f,!0)};return V.forEach(Object.keys({...e,...t}),function(d){const f=c[d]||o,m=f(e[d],t[d],d);V.isUndefined(m)&&f!==a||(n[d]=m)}),n}const zc=e=>{const t=Jn({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=zt.from(i),t.url=Pc(Fc(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&i.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),V.isFormData(n)){if(jt.hasStandardBrowserEnv||jt.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(V.isFunction(n.getHeaders)){const c=n.getHeaders(),l=["content-type","content-length"];Object.entries(c).forEach(([d,f])=>{l.includes(d.toLowerCase())&&i.set(d,f)})}}if(jt.hasStandardBrowserEnv&&(r&&V.isFunction(r)&&(r=r(t)),r||r!==!1&&Bv(t.url))){const c=o&&s&&zv.read(s);c&&i.set(o,c)}return t},Wv=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=zc(e);let s=o.data;const i=zt.from(o.headers).normalize();let{responseType:a,onUploadProgress:c,onDownloadProgress:l}=o,d,f,m,p,v;function g(){p&&p(),v&&v(),o.cancelToken&&o.cancelToken.unsubscribe(d),o.signal&&o.signal.removeEventListener("abort",d)}let x=new XMLHttpRequest;x.open(o.method.toUpperCase(),o.url,!0),x.timeout=o.timeout;function y(){if(!x)return;const T=zt.from("getAllResponseHeaders"in x&&x.getAllResponseHeaders()),S={data:!a||a==="text"||a==="json"?x.responseText:x.response,status:x.status,statusText:x.statusText,headers:T,config:e,request:x};Dc(function(k){n(k),g()},function(k){r(k),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 Ee("Request aborted",Ee.ECONNABORTED,e,x)),x=null)},x.onerror=function(E){const S=E&&E.message?E.message:"Network Error",C=new Ee(S,Ee.ERR_NETWORK,e,x);C.event=E||null,r(C),x=null},x.ontimeout=function(){let E=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const S=o.transitional||_c;o.timeoutErrorMessage&&(E=o.timeoutErrorMessage),r(new Ee(E,S.clarifyTimeoutError?Ee.ETIMEDOUT:Ee.ECONNABORTED,e,x)),x=null},s===void 0&&i.setContentType(null),"setRequestHeader"in x&&V.forEach(i.toJSON(),function(E,S){x.setRequestHeader(S,E)}),V.isUndefined(o.withCredentials)||(x.withCredentials=!!o.withCredentials),a&&a!=="json"&&(x.responseType=o.responseType),l&&([m,v]=Wo(l,!0),x.addEventListener("progress",m)),c&&x.upload&&([f,p]=Wo(c),x.upload.addEventListener("progress",f),x.upload.addEventListener("loadend",p)),(o.cancelToken||o.signal)&&(d=T=>{x&&(r(!T||T.type?new br(null,e,x):T),x.abort(),x=null)},o.cancelToken&&o.cancelToken.subscribe(d),o.signal&&(o.signal.aborted?d():o.signal.addEventListener("abort",d)));const b=Lv(o.url);if(b&&jt.protocols.indexOf(b)===-1){r(new Ee("Unsupported protocol "+b+":",Ee.ERR_BAD_REQUEST,e));return}x.send(s||null)})},Vv=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let r=new AbortController,o;const s=function(l){if(!o){o=!0,a();const d=l instanceof Error?l:this.reason;r.abort(d instanceof Ee?d:new br(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(l=>{l.unsubscribe?l.unsubscribe(s):l.removeEventListener("abort",s)}),e=null)};e.forEach(l=>l.addEventListener("abort",s));const{signal:c}=r;return c.unsubscribe=()=>V.asap(a),c}},Kv=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},qv=async function*(e,t){for await(const n of Gv(e))yield*Kv(n,t)},Gv=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()}},Hc=(e,t,n,r)=>{const o=qv(e,t);let s=0,i,a=c=>{i||(i=!0,r&&r(c))};return new ReadableStream({async pull(c){try{const{done:l,value:d}=await o.next();if(l){a(),c.close();return}let f=d.byteLength;if(n){let m=s+=f;n(m)}c.enqueue(new Uint8Array(d))}catch(l){throw a(l),l}},cancel(c){return a(c),o.return()}},{highWaterMark:2})},Uc=64*1024,{isFunction:Vo}=V,Yv=(({Request:e,Response:t})=>({Request:e,Response:t}))(V.global),{ReadableStream:Wc,TextEncoder:Vc}=V.global,Kc=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Xv=e=>{e=V.merge.call({skipUndefined:!0},Yv,e);const{fetch:t,Request:n,Response:r}=e,o=t?Vo(t):typeof fetch=="function",s=Vo(n),i=Vo(r);if(!o)return!1;const a=o&&Vo(Wc),c=o&&(typeof Vc=="function"?(v=>g=>v.encode(g))(new Vc):async v=>new Uint8Array(await new n(v).arrayBuffer())),l=s&&a&&Kc(()=>{let v=!1;const g=new n(jt.origin,{body:new Wc,method:"POST",get duplex(){return v=!0,"half"}}).headers.has("Content-Type");return v&&!g}),d=i&&a&&Kc(()=>V.isReadableStream(new r("").body)),f={stream:d&&(v=>v.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(v=>{!f[v]&&(f[v]=(g,x)=>{let y=g&&g[v];if(y)return y.call(g);throw new Ee(`Response type '${v}' is not supported`,Ee.ERR_NOT_SUPPORT,x)})});const m=async v=>{if(v==null)return 0;if(V.isBlob(v))return v.size;if(V.isSpecCompliantForm(v))return(await new n(jt.origin,{method:"POST",body:v}).arrayBuffer()).byteLength;if(V.isArrayBufferView(v)||V.isArrayBuffer(v))return v.byteLength;if(V.isURLSearchParams(v)&&(v=v+""),V.isString(v))return(await c(v)).byteLength},p=async(v,g)=>{const x=V.toFiniteNumber(v.getContentLength());return x??m(g)};return async v=>{let{url:g,method:x,data:y,signal:b,cancelToken:T,timeout:E,onDownloadProgress:S,onUploadProgress:C,responseType:k,headers:A,withCredentials:j="same-origin",fetchOptions:L}=zc(v),B=t||fetch;k=k?(k+"").toLowerCase():"text";let K=Vv([b,T&&T.toAbortSignal()],E),J=null;const _=K&&K.unsubscribe&&(()=>{K.unsubscribe()});let Y;try{if(C&&l&&x!=="get"&&x!=="head"&&(Y=await p(A,y))!==0){let X=new n(g,{method:"POST",body:y,duplex:"half"}),M;if(V.isFormData(y)&&(M=X.headers.get("content-type"))&&A.setContentType(M),X.body){const[z,R]=Lc(Y,Wo($c(C)));y=Hc(X.body,Uc,z,R)}}V.isString(j)||(j=j?"include":"omit");const q=s&&"credentials"in n.prototype,W={...L,signal:K,method:x.toUpperCase(),headers:A.normalize().toJSON(),body:y,duplex:"half",credentials:q?j:void 0};J=s&&new n(g,W);let D=await(s?B(J,L):B(g,W));const I=d&&(k==="stream"||k==="response");if(d&&(S||I&&_)){const X={};["status","statusText","headers"].forEach(F=>{X[F]=D[F]});const M=V.toFiniteNumber(D.headers.get("content-length")),[z,R]=S&&Lc(M,Wo($c(S),!0))||[];D=new r(Hc(D.body,Uc,z,()=>{R&&R(),_&&_()}),X)}k=k||"text";let G=await f[V.findKey(f,k)||"text"](D,v);return!I&&_&&_(),await new Promise((X,M)=>{Dc(X,M,{data:G,headers:zt.from(D.headers),status:D.status,statusText:D.statusText,config:v,request:J})})}catch(q){throw _&&_(),q&&q.name==="TypeError"&&/Load failed|fetch/i.test(q.message)?Object.assign(new Ee("Network Error",Ee.ERR_NETWORK,v,J),{cause:q.cause||q}):Ee.from(q,q&&q.code,v,J)}}},Jv=new Map,qc=e=>{let t=e?e.env:{};const{fetch:n,Request:r,Response:o}=t,s=[r,o,n];let i=s.length,a=i,c,l,d=Jv;for(;a--;)c=s[a],l=d.get(c),l===void 0&&d.set(c,l=a?new Map:Xv(t)),d=l;return l};qc();const Ri={http:wv,xhr:Wv,fetch:{get:qc}};V.forEach(Ri,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Gc=e=>`- ${e}`,Zv=e=>V.isFunction(e)||e===null||e===!1,Yc={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,!Zv(r)&&(o=Ri[(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(([c,l])=>`adapter ${c} `+(l===!1?"is not supported by the environment":"is not available in the build"));let a=n?i.length>1?`since :
33
+ `+i.map(Gc).join(`
34
+ `):" "+Gc(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:Ri};function Mi(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new br(null,e)}function Xc(e){return Mi(e),e.headers=zt.from(e.headers),e.data=_i.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),Yc.getAdapter(e.adapter||eo.adapter,e)(e).then(function(r){return Mi(e),r.data=_i.call(e,e.transformResponse,r),r.headers=zt.from(r.headers),r},function(r){return Oc(r)||(Mi(e),r&&r.response&&(r.response.data=_i.call(e,e.transformResponse,r.response),r.response.headers=zt.from(r.response.headers))),Promise.reject(r)})}const Jc="1.12.2",Ko={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Ko[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const Zc={};Ko.transitional=function(t,n,r){function o(s,i){return"[Axios v"+Jc+"] 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&&!Zc[i]&&(Zc[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}},Ko.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function Qv(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],c=a===void 0||i(a,s,e);if(c!==!0)throw new Ee("option "+s+" must be "+c,Ee.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new Ee("Unknown option "+s,Ee.ERR_BAD_OPTION)}}const qo={assertOptions:Qv,validators:Ko},xn=qo.validators;let Zn=class{constructor(t){this.defaults=t||{},this.interceptors={request:new jc,response:new jc}}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&&qo.assertOptions(r,{silentJSONParsing:xn.transitional(xn.boolean),forcedJSONParsing:xn.transitional(xn.boolean),clarifyTimeoutError:xn.transitional(xn.boolean)},!1),o!=null&&(V.isFunction(o)?n.paramsSerializer={serialize:o}:qo.assertOptions(o,{encode:xn.function,serialize:xn.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),qo.assertOptions(n,{baseUrl:xn.spelling("baseURL"),withXsrfToken:xn.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=s&&V.merge(s.common,s[n.method]);s&&V.forEach(["delete","get","head","post","put","patch","common"],v=>{delete s[v]}),n.headers=zt.concat(i,s);const a=[];let c=!0;this.interceptors.request.forEach(function(g){typeof g.runWhen=="function"&&g.runWhen(n)===!1||(c=c&&g.synchronous,a.unshift(g.fulfilled,g.rejected))});const l=[];this.interceptors.response.forEach(function(g){l.push(g.fulfilled,g.rejected)});let d,f=0,m;if(!c){const v=[Xc.bind(this),void 0];for(v.unshift(...a),v.push(...l),m=v.length,d=Promise.resolve(n);f<m;)d=d.then(v[f++],v[f++]);return d}m=a.length;let p=n;for(;f<m;){const v=a[f++],g=a[f++];try{p=v(p)}catch(x){g.call(this,x);break}}try{d=Xc.call(this,p)}catch(v){return Promise.reject(v)}for(f=0,m=l.length;f<m;)d=d.then(l[f++],l[f++]);return d}getUri(t){t=Jn(this.defaults,t);const n=Fc(t.baseURL,t.url,t.allowAbsoluteUrls);return Pc(n,t.params,t.paramsSerializer)}};V.forEach(["delete","get","head","options"],function(t){Zn.prototype[t]=function(n,r){return this.request(Jn(r||{},{method:t,url:n,data:(r||{}).data}))}}),V.forEach(["post","put","patch"],function(t){function n(r){return function(s,i,a){return this.request(Jn(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}Zn.prototype[t]=n(),Zn.prototype[t+"Form"]=n(!0)});let ew=class vx{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 br(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 vx(function(o){t=o}),cancel:t}}};function tw(e){return function(n){return e.apply(null,n)}}function nw(e){return V.isObject(e)&&e.isAxiosError===!0}const Oi={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Oi).forEach(([e,t])=>{Oi[t]=e});function Qc(e){const t=new Zn(e),n=mc(Zn.prototype.request,t);return V.extend(n,Zn.prototype,t,{allOwnKeys:!0}),V.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return Qc(Jn(e,o))},n}const mt=Qc(eo);mt.Axios=Zn,mt.CanceledError=br,mt.CancelToken=ew,mt.isCancel=Oc,mt.VERSION=Jc,mt.toFormData=Ho,mt.AxiosError=Ee,mt.Cancel=mt.CanceledError,mt.all=function(t){return Promise.all(t)},mt.spread=tw,mt.isAxiosError=nw,mt.mergeConfig=Jn,mt.AxiosHeaders=zt,mt.formToJSON=e=>Rc(V.isHTMLForm(e)?new FormData(e):e),mt.getAdapter=Yc.getAdapter,mt.HttpStatusCode=Oi,mt.default=mt;const{Axios:TN,AxiosError:kN,CanceledError:EN,isCancel:eu,CancelToken:IN,VERSION:NN,all:AN,Cancel:PN,isAxiosError:jN,spread:_N,toFormData:RN,AxiosHeaders:MN,HttpStatusCode:ON,formToJSON:DN,getAdapter:LN,mergeConfig:$N}=mt,tu=typeof window<"u"?window.__API_BASE_URL__:void 0,nu=tu?vn(tu):void 0;function vn(e){const n=(e!=null&&e.trim()?e.trim():"/api/chat").replace(/\/+$/,"");return n?n.endsWith("/chat")?n:`${n}/chat`:"/api/chat"}let Go=null;const Di=new Set;function ru(){return Go}function Yo(e){Go=e,Di.forEach(t=>t(e))}function ou(e){return Di.add(e),()=>Di.delete(e)}const su=3e4,iu=9e4,Gt=mt.create({...nu?{baseURL:nu}:{},timeout:su,withCredentials:!0});Gt.interceptors.request.use(e=>(Go&&(e.headers.Authorization=`Bearer ${Go}`),e)),Gt.interceptors.response.use(e=>{if(typeof window<"u"&&(e!=null&&e.data))try{const t=e.data,n=t.data||{},r=typeof t.token=="string"&&t.token||typeof n.token=="string"&&n.token||null,o=typeof t.expires_at=="number"&&t.expires_at||typeof n.expires_at=="number"&&n.expires_at||typeof t.expiresAt=="number"&&t.expiresAt||typeof n.expiresAt=="number"&&n.expiresAt||null;r&&(localStorage.setItem("authToken",r),Yo(r)),o&&localStorage.setItem("authTokenExpiresAt",o.toString()),(r||o)&&window.dispatchEvent(new CustomEvent("smartorg:chat-token-updated",{detail:{token:r,expiresAt:o}}))}catch(t){console.warn("[chat-api] Error storing token:",t)}return e},e=>Promise.reject(e));async function Yt(e,t){return Gt.defaults.baseURL?(await Gt.get(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}async function Xo(e,t,n){return Gt.defaults.baseURL?(await Gt.post(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function au(e,t,n){return Gt.defaults.baseURL?(await Gt.put(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function Li(e,t){return Gt.defaults.baseURL?(await Gt.delete(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}function Dt(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class Jo{get baseUrl(){const t=Gt.defaults.baseURL;return t?vn(String(t)):""}updateConfig(t){t.baseUrl&&(Gt.defaults.baseURL=vn(String(t.baseUrl))),t.authToken!==void 0&&Yo(t.authToken)}getAuthToken(){return ru()}setAuthToken(t){Yo(t)}onTokenChange(t){return ou(t)}async listThreads(){const t=await Yt("/threads"),n=Dt(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async listSharedThreads(){const t=await Yt("/threads/shared"),n=Dt(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async createThread(t){const r=await Xo("/threads",t?{title:t}:void 0);return Dt(r)}async updateThread(t,n){const r=await au(`/threads/${t}`,{title:n});return Dt(r)}async deleteThread(t){const n=await Li(`/threads/${t}`);return Dt(n)}async shareThread(t,n){const r=await Xo(`/threads/${t}/share`,{shared_with_user_id:n});return Dt(r)}async threadInfo(t){const n=await Yt(`/threads/${t}/info`);return Dt(n)}async listAgents(){const t=await Yt("/agents"),n=Dt(t);return(n==null?void 0:n.items)??[]}async getAgent(t){const n=await Yt(`/agents/${t}`);return Dt(n)}async getAgentSchema(t){const n=await Yt(`/agents/${t}/schema`);return Dt(n)}async getState(t){const n=await Yt(`/threads/${t.threadId}/state`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return Dt(n)}async getStateHistory(t){const n=await Yt(`/threads/${t.threadId}/state/history`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs},timeout:iu,signal:t.signal});return Dt(n)}async cancelRun(t){const n=await Xo("/runs/cancel",{threadId:t});return Dt(n)}async unshareThread(t,n){const r=await Li(`/threads/${t}/share/${n}`);return Dt(r)}}const Nn=new Jo,rw=Jo,ow=Jo;async function $i(e,t){return await Yt(e,{responseType:"blob",onDownloadProgress:r=>{try{if(t&&r.lengthComputable){const o=r.loaded/r.total;t(o)}}catch{}},maxBodyLength:1/0})}async function sw(e,t){const n=await $i(`/files/${e}/view`,t),r=URL.createObjectURL(n);window.open(r,"_blank"),setTimeout(()=>URL.revokeObjectURL(r),6e4)}async function Fi(e,t){return await(await $i(`/files/${e}/view`,t)).text()}async function lu(e,t){const n=await $i(`/files/${e}/download`,t),r=URL.createObjectURL(n);let o=`file_${e}`;try{const i=await Yt(`/files/${e}`);o=(i==null?void 0:i.filename)??o}catch{}const s=document.createElement("a");s.href=r,s.download=o,document.body.appendChild(s),s.click(),s.remove(),setTimeout(()=>URL.revokeObjectURL(r),6e4)}async function iw(e){return await Yt(`/files/${e}`)}async function cu(e,t=50,n=0){const r={limit:t,offset:n};return e&&(r.thread_id=e),await Yt("/files",{params:r})}const uu=w.createContext(null);function du({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(uu.Provider,{value:r,children:e})}async function fu(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 c=0;c<a;c++)i+=String.fromCharCode(s[c]);t(btoa(i))}catch(o){n(o)}},r.onerror=o=>n(o),r.readAsArrayBuffer(e)})}async function pu(e=[]){const t=[],n=[];for(const r of e)try{const o=await fu(r);n.push({filename:r.name,data:o,mime_type:r.type||"application/octet-stream"})}catch{}return{contentParts:t,filesInfo:n}}function no(){const e=w.useContext(uu);if(!e)throw new Error("useApi must be used within ApiProvider");return e}function hu(e){return!!e&&typeof e=="object"&&"data"in e}function Bi(e){return e.filter(t=>{var i;if(t.role!=="assistant")return!0;const n=(t.content??[]).some(a=>{var c;return a&&a.type==="text"&&((c=a.text)==null?void 0:c.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 ro(e,t,n){return t<0||t>=e.length?e:[...e.slice(0,t),n,...e.slice(t+1)]}function aw(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 mu(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="assistant")return e[t].id;return null}function gu(e){return!e||!e.length?"":e.filter(t=>t.type==="text").map(t=>t.text??"").join("")}function xu(e,t,n,r){const o={...n};if(r!==null&&typeof r=="number"){if(typeof o.lastSeq=="number"&&r<=o.lastSeq)return{newParts:e,newMeta:o,changed:!1};o.lastSeq=r}const s=t.filter(f=>f.type==="text").map(f=>f.text??"").join(""),i=t.filter(f=>f.type!=="text"),a=o.lastText??gu(e);let c="",l=e.slice();if(s){const f=lw(a,s);if(f===""?c="":f===s?c=s:c=f,c){const m=l[l.length-1];if((m==null?void 0:m.type)==="text"){const p=m.text??"",v={...m,text:p+c};l=[...l.slice(0,l.length-1),v]}else l=[...l,{type:"text",text:c}];o.lastText=a+c}else o.lastText=a}i.length&&(l=[...l,...i]);const d=!!(c||i.length);return{newParts:l,newMeta:o,changed:d}}function vu(e){return e.replace(/\s+/g," ").trim()}function lw(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=vu(e),o=vu(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 cw(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 ro(e,r,s)}return e}function wu(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}function uw(e={}){const t=w.useMemo(()=>vn(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,c]=w.useState(!1),[l,d]=w.useState(null),[f,m]=w.useState(""),[p,v]=w.useState(null),[g,x]=w.useState(0),[y,b]=w.useState(!1),[T,E]=w.useState(null),S=w.useRef(null),C=w.useRef(!0),k=w.useRef(0),A=w.useRef(null),j=w.useRef(null),L=w.useRef(null),B=w.useRef(null),K=w.useRef({messageId:null,lastSeq:null,lastText:""}),J=w.useCallback(W=>{o(W)},[]),_=w.useCallback(()=>{m(""),v(null),d(null),j.current=null,L.current=null,B.current=null,E(null),K.current={messageId:null,lastSeq:null,lastText:""}},[]),Y=w.useCallback(()=>{var G;console.debug("[use-chat] stop() invoked - aborting stream");const W=(G=A.current)==null?void 0:G.threadId,D=()=>{var X;(X=S.current)==null||X.abort(),S.current=null,A.current=null,c(!1),b(!1),k.current=0,x(0)};(W?Nn.cancelRun(W).catch(X=>{console.warn("[use-chat] cancel run failed:",X)}):Promise.resolve()).finally(D)},[]),q=w.useCallback((W,D,I)=>{S.current&&(S.current.abort(),S.current=null),c(!0),d(null),e.autoAppendAssistant!==!1&&m(""),v(null),j.current=null,L.current=null,B.current=null,E(null),K.current={messageId:null,lastSeq:null,lastText:""};const G=new AbortController;S.current=G;let X=null,M=null,z=!1;return A.current={threadId:W.threadId??null,headers:{}},(async()=>{var F,H,O,P,U,Q,se,ie,Se,xe,Re,Ve,De,Ge,He,ot,ut,nt;const R=Le=>{var Ke;try{const $e=JSON.parse(JSON.stringify(Le));return(Ke=$e==null?void 0:$e.payload)!=null&&Ke.files_info&&Array.isArray($e.payload.files_info)&&($e.payload.files_info=$e.payload.files_info.map(Te=>({...Te,data:Te!=null&&Te.data?`<base64 ${String(Te.data).length} chars>`:Te==null?void 0:Te.data}))),$e}catch{return Le}};try{let Le={};try{if(r)Le={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const Ue=window.__AUTH_TOKEN__,Pt=((F=window.localStorage)==null?void 0:F.getItem("authToken"))||null;let te=null;try{const rt=(H=window.localStorage)==null?void 0:H.getItem("chat-settings");rt&&(te=((O=JSON.parse(rt))==null?void 0:O.apiKey)||null)}catch{}const ge=Ue||Pt||te||null;ge&&(Le={Authorization:`Bearer ${ge}`})}}catch{}console.debug("[use-chat] POST",t+n,R(W));let Ke={};if(typeof window<"u")try{const Ie=(P=window.localStorage)==null?void 0:P.getItem("authSessionId");Ie&&(Ke={"X-Session-Id":Ie})}catch{}const $e={...Le,...Ke,...s.current},Te={"Content-Type":"application/json",Accept:"text/event-stream",...$e},Ae=await fetch(t+n,{method:"POST",headers:Te,body:JSON.stringify(W),signal:G.signal,credentials:i});if(A.current&&(A.current.headers=$e),!Ae.ok||!Ae.body){const Ie=await Ae.text().catch(()=>"");console.debug("[use-chat] non-OK response",Ae.status,Ie==null?void 0:Ie.slice(0,500));const Ue=`stream ${Ae.status}${Ie?": "+Ie:""}`;throw(U=I==null?void 0:I.onConnectionError)==null||U.call(I,Ue),z=!0,X="error",M=Ue,new Error(Ue)}b(!0);const dt=Ae.body.getReader(),Et=new TextDecoder;let at="",It=[];k.current=0,x(0);let bt=0,ft=null;const Nt=()=>{if(It.length){const Ie=It.join("");It=[],C.current&&m(Ue=>Ue+Ie)}ft=null},At=()=>{typeof window<"u"&&ft==null&&(ft=requestAnimationFrame(Nt))};let Ct=Date.now();const on=setInterval(()=>{var Ie;if(Date.now()-Ct>18e5){const Ue="Stream idle timeout";d(Ue),X="error",M=Ue,G.abort(),(Ie=I==null?void 0:I.onError)==null||Ie.call(I,Ue)}},5e3),Tt=1024*1024;try{const Ie=Ae.headers.get("X-Thread-Id")||Ae.headers.get("x-thread-id"),Ue=Ae.headers.get("X-Thread-Created")||Ae.headers.get("x-thread-created"),Pt=Ie??null,te=String(Ue??"").toLowerCase()==="true";for(A.current&&!A.current.threadId&&(A.current={...A.current,threadId:Pt}),(Q=I==null?void 0:I.onOpen)==null||Q.call(I,{threadId:Pt,created:te});;){const{value:ge,done:rt}=await dt.read();if(rt)break;at+=Et.decode(ge,{stream:!0}),at.length>Tt&&(at="",console.warn("Stream buffer reset: exceeded 1MB"));let fe;for(;(fe=at.indexOf(`
36
36
 
37
37
  `))>=0;){const ke=at.slice(0,fe);at=at.slice(fe+2);const Fe=ke.split(/\r?\n/),ht=[];for(const Xe of Fe)if(!(!Xe||Xe.startsWith(":"))&&Xe.startsWith("data:")){const ct=Xe.slice(5);ht.push(ct.startsWith(" ")?ct.slice(1):ct)}const pt=ht.join(`
38
- `);if(!pt)continue;let je;try{je=JSON.parse(pt)}catch{console.debug("[use-chat] malformed SSE:",pt.slice(0,200));continue}const Ye=uu(je)?je.data:je;if(!Ye){console.warn("[use-chat] dropped envelope event without payload",je);continue}const we=Ye;Ct=Date.now();const Qe=we.seq;if(Qe!==void 0){if(Qe<=bt){console.debug("[use-chat] drop duplicate/out-of-order event",{seq:Qe,lastProcessedSeq:bt,type:we.type});continue}bt>0&&Qe>bt+1&&((se=I==null?void 0:I.onGap)==null||se.call(I,{from:bt,to:Qe})),bt=Qe,k.current=Qe,x(Qe)}if(we.type==="message.start"&&we.role==="assistant"){const Xe=mu(we.model);K.current={messageId:we.id,lastSeq:Qe??null,lastText:""},E({id:we.id,role:"assistant",name:Xe??void 0,model:we.model,createdAt:new Date().toISOString(),content:[]})}if(we.type==="checkpoint")P.current=we.checkpointId??null,L.current=we.checkpointNs??null,v(we.checkpointId??null);else if(we.type==="state_history"){F.current=we;try{const ct=Yn(we).latest;ct&&(P.current=ct.checkpointId??null,L.current=ct.checkpointNs??null,v(ct.checkpointId??null))}catch(Xe){console.warn("[use-chat] Failed to hydrate state_history payload",Xe)}}try{D==null||D(we)}catch(Xe){console.error("[use-chat] Error in onEvent callback:",Xe,"for event:",we.type)}if(we.type==="message.delta"){E(ct=>{const sn=K.current;if(!ct||sn.messageId!==ct.id)return ct;const{newParts:N,newMeta:Z,changed:re}=pu(ct.content??[],we.delta,{lastSeq:sn.lastSeq,lastText:sn.lastText},Qe??null);return re?(K.current={...sn,lastSeq:Z.lastSeq??sn.lastSeq,lastText:Z.lastText??sn.lastText},{...ct,content:N}):ct});const Xe=we.delta.filter(ct=>ct.type==="text").map(ct=>ct.text).join("");Xe&&e.autoAppendAssistant!==!1&&(It.push(Xe),At())}else if(we.type==="heartbeat"){console.debug("[use-chat] heartbeat received");try{(ie=I==null?void 0:I.onHeartbeat)==null||ie.call(I,we)}catch(Xe){console.warn("[use-chat] heartbeat callback failed",Xe)}}else if(ft!==null&&cancelAnimationFrame(ft),Nt(),we.type==="checkpoint")v(we.checkpointId);else if(we.type==="error"){const Xe=we;if(d(Xe.message),X="error",M=Xe.message,Xe.error_type==="auth_error"||Xe.code==="TOKEN_EXPIRED"||((Se=Xe.message)==null?void 0:Se.includes("token"))||((xe=Xe.message)==null?void 0:xe.includes("401"))||((Re=Xe.message)==null?void 0:Re.includes("unauthorized"))||((Ve=Xe.message)==null?void 0:Ve.includes("Unauthorized"))){console.error("[use-chat] Auth error detected:",Xe.message);try{(De=I==null?void 0:I.onAuthError)==null||De.call(I,Xe.message)}catch(sn){console.warn("[use-chat] onAuthError handler failed",sn)}G.abort()}}}}Nt(),X===null&&!G.signal.aborted&&(X="complete")}catch(Ie){if(Ie.name==="AbortError")X=X??"aborted";else{const Ue=Ie.message||String(Ie);X="error",M=Ue,d(Ue),(Ge=I==null?void 0:I.onError)==null||Ge.call(I,Ue)}}finally{try{await dt.cancel()}catch{}finally{(He=dt.releaseLock)==null||He.call(dt)}ft!==null&&typeof window<"u"&&window.cancelAnimationFrame(ft),clearInterval(on)}}catch(Le){if(Le.name==="AbortError")X=X??"aborted";else{const Ke=Le.message||String(Le);X="error",M=Ke,d(Ke),(ot=I==null?void 0:I.onError)==null||ot.call(I,Ke),B||((ut=I==null?void 0:I.onConnectionError)==null||ut.call(I,Ke),B=!0)}}finally{const Le=k.current,Ke=P.current,$e=L.current,Te=F.current,Ae=X??(G.signal.aborted?"aborted":M?"error":"complete");try{(nt=I==null?void 0:I.onClosed)==null||nt.call(I,{reason:Ae,lastSeq:Le,lastCheckpointId:Ke,lastCheckpointNs:$e,lastStateHistory:Te,error:M})}catch(dt){console.warn("[use-chat] onClosed callback failed",dt)}c(!1),b(!1),S.current=null,k.current=0,x(0),A.current=null}})(),{close:()=>G.abort()}},[t,n,r,e.autoAppendAssistant]);return w.useEffect(()=>()=>{var W;C.current=!1,(W=S.current)==null||W.abort()},[]),{isStreaming:a,error:l,assistantText:f,assistantMessage:T,lastCheckpointId:p,lastSeq:g,connected:y,stream:q,stop:Y,clear:_,setToken:J}}const tw=["detail","message","error","description","title"];function Zo(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=Zo(t);if(n)return n}return null}if(typeof e=="object"){const t=e;for(const n of tw){const r=Zo(t[n]);if(r)return r}if("errors"in t){const n=Zo(t.errors);if(n)return n}}return null}function nw(e){if(!e)return"Request failed";const t=e.response,n=Zo(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 gu({api:e,initialThreadId:t=null,onError:n,onThreadChange:r,onCurrentThreadDeleted:o}){const[s,i]=w.useState([]),[a,c]=w.useState(t),[l,d]=w.useState(!1),[f,m]=w.useState(null),[p,v]=w.useState([]),[g,x]=w.useState(!1),[,y]=w.useState(null),[b,T]=w.useState(null),[E,S]=w.useState(!1),C=w.useRef(a),k=w.useRef(new Map);w.useEffect(()=>{C.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]),P=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(()=>{P()},[P]),w.useEffect(()=>{r==null||r(a)},[a,r]);const L=w.useCallback(async D=>{try{const I=await e.createThread(D);return c(I.threadId),await A(),I.threadId}catch(I){const G=String(I);return n==null||n(G),null}},[e,n,A]),F=w.useCallback(async D=>{const I=s;i(X=>X.filter(M=>M.threadId!==D));const G=new AbortController;k.current.set(D,G);try{await e.deleteThread(D),C.current===D&&(c(null),o==null||o())}catch(X){i(I);const M=String(X);n==null||n(M)}finally{k.current.delete(D)}},[e,o,n,s]),K=w.useCallback(async(D,I)=>{try{await e.updateThread(D,I),await A()}catch(G){n==null||n(String(G))}},[e,n,A]),J=w.useCallback(async(D,I)=>{S(!0),T("Sharing thread…");try{await e.shareThread(D,I),await P(),T("Shared successfully")}catch(G){const X=nw(G);throw n==null||n(X),T(`Failed to share: ${X}`),new Error(X)}finally{S(!1)}},[e,n,P]),_=w.useCallback(async(D,I)=>{try{await e.unshareThread(D,I),await P()}catch(G){const X=String(G);throw n==null||n(X),G}},[e,n,P]),Y=w.useMemo(()=>({createThread:L,deleteThread:F,renameThread:K,refreshThreads:A,refreshSharedThreads:P,shareThread:J,unshareThread:_}),[L,F,K,A,P,J,_]),q=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(G=>{let X=!1;const M=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?M:(console.debug("[useThreadsState] thread_info: adding thread to list",I.threadId),[I,...G])})},[]),W=w.useCallback(()=>T(null),[]);return{threads:s,currentThreadId:a,currentThreadIdRef:C,setCurrentThreadId:c,isLoadingThreads:l,threadsError:f,sharedThreads:p,isLoadingSharedThreads:g,actions:Y,addThreadFromEvent:q,shareInFlight:E,shareStatus:b,clearShareStatus:W}}const xu=w.createContext(null);function vu({children:e,initialThreadId:t=null,onError:n,onThreadChange:r}){const{api:o}=eo(),{threads:s,currentThreadId:i,setCurrentThreadId:a,currentThreadIdRef:c,isLoadingThreads:l,threadsError:d,sharedThreads:f,isLoadingSharedThreads:m,actions:p,addThreadFromEvent:v,shareInFlight:g,shareStatus:x,clearShareStatus:y}=gu({api:o,initialThreadId:t,onError:n,onThreadChange:r}),b=w.useMemo(()=>({threads:s,currentThreadId:i,setCurrentThreadId:a,currentThreadIdRef:c,isLoading:l,error:d,sharedThreads:f,isLoadingSharedThreads:m,actions:p,shareInFlight:g,shareStatus:x,clearShareStatus:y,addThreadFromEvent:v}),[s,i,a,c,l,d,f,m,p,g,x,y,v]);return u.jsx(xu.Provider,{value:b,children:e})}function vr(){const e=w.useContext(xu);if(!e)throw new Error("useThreads must be used within a ThreadsProvider");return e}function wr(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=rw(t);if(n)try{return JSON.parse(n)}catch{return null}return null}}function rw(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 wu(e){return!!(e&&typeof e=="object"&&(e.type==="file"||e.mimeType||e.filename||e.sourceType==="base64"))}function no(e){if(typeof e=="string")return e;if(e&&typeof e=="object"){if(Array.isArray(e)){const n=e.map(no).filter(r=>r!==void 0);if(!n.length){console.debug("[message-utils] sanitizeForDisplay - array emptied -> returning undefined",{originalLength:e.length});return}return n}if(wu(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=no(r);o!==void 0&&(t[n]=o)}}if(Object.keys(t).length)return t;try{console.debug("[message-utils] sanitizeForDisplay - object emptied -> returning undefined",{originalKeys:Object.keys(e||{})})}catch(n){console.debug("[message-utils] sanitizeForDisplay - object emptied -> returning undefined (inspect failed)",{err:String(n)})}return}return e}function br(e){if(typeof e=="string")return e;if(wu(e))return"";try{const t=no(e);return t===void 0?"":typeof t=="string"?t:JSON.stringify(t,null,2)}catch{return""}}function ow(e){return typeof e!="string"?!1:/^[\s\n]*[-*]\s|^[\s\n]*#+\s|```|^\s*\[.*\]\(|^>\s/.test(e)}function sw(e){const t=br(e);return typeof e=="string"&&ow(e)?{content:e,isMarkdown:!0}:{content:t,isMarkdown:!1}}function yr(e){if(e==null)return e;if(typeof e=="string"){const t=e.trim();if(t.startsWith("{")||t.startsWith("[")){const n=wr(t);if(n!==null)return yr(n)}return e}return typeof e=="object"&&!Array.isArray(e)&&e.content!==void 0?yr(e.content):e}function iw(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function Bi(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 bu(e){if(e==null)return null;const t=String(e).trim();return t.length>0?t:null}function aw(e){const t=r=>{try{const o=no(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 lw(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function yu(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 cw(e){if(!e)return"image/png";const t=e.trim();return t?t.includes("/")?t:`image/${t}`:"image/png"}function uw(e){const t=[],n=r=>{r&&r.trim()&&t.push(r.trim())};return e&&(n(e.plotId),n(e.artifactId)),t}function dw({base64:e,url:t,formatHint:n,extras:r}){const o=typeof e=="string"&&e.length>0,s=cw(n),i=o?`data:${s};base64,${e}`:t,a=uw(r),c=a.length?a.join(" / "):void 0,l=c?`${c} artifact`:"artifact image";return{src:i,alt:l,label:c}}function fw(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 dw({base64:t,url:n,formatHint:r,extras:{plotId:e.plotId,artifactId:e.artifactId}})}function Su(e){var n;const t=(n=e.additionalKwargs)==null?void 0:n.toolProgress;return Array.isArray(t)?t:[]}function ro(e){if(e==null)return e;if(typeof e=="string"){const t=e.trim(),n=wr(t);return n!==null?ro(n):t}if(Array.isArray(e))return e.map(t=>ro(t));if(typeof e=="object"){const t=e.value;if(t!==void 0)return ro(t)}return e}function pw(e){const t=ro(e.value);return t===e.value?e:{...e,value:t}}const hw={messages:[],assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,messagesStreamMeta:{},pendingInterrupt:null};function mw(e,t){var n;switch(t.type){case"reset":return{messages:Fi(((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=Fi(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=Fi(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 Cu(e,t.payload.ev);case"batch":{const{events:r}=t.payload;return r.length?r.reduce((o,s)=>Cu(o,s),e):e}default:return e}}function gw(e=[]){const[t,n]=w.useReducer(mw,{...hw,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]),c=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 l=w.useMemo(()=>({reset:d=>n({type:"reset",payload:{messages:d}}),seed:(d,f)=>n({type:"seed",payload:{messages:d,...f??{}}}),prepend:d=>n({type:"prepend",payload:{messages:d}}),pushUser:(d,f)=>n({type:"user_message",payload:{message:d,editingMessageId:f}}),onEvent:c}),[c]);return{state:t,dispatch:n,...l}}function Cu(e,t){var n,r,o;if(t.type==="message.start"&&t.role==="assistant"){const s=t.id,i=mu(t.model);if(e.messages.some(l=>l.id===s)){const l=e.messagesStreamMeta??{},d={...l,[s]:l[s]??{lastSeq:t.seq??null,lastText:""}};return{...e,assemblingId:s,messagesStreamMeta:d}}const c={id:s,role:"assistant",name:i||void 0,model:t.model,createdAt:new Date().toISOString(),content:[]};return{...e,assemblingId:s,messages:[...e.messages,c]}}if(t.type==="tool.start")return vw(e,t);if(t.type==="tool.progress")return ww(e,t);if(t.type==="tool.end")return bw(e,t);if(t.type==="message.delta"){const s=e.assemblingId??du(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 c=i[a],l=e.messagesStreamMeta,d=l??{},f=d[s],m=f??{lastSeq:null,lastText:fu(c.content)},p=t.seq??null;if(p!==null&&typeof p=="number"&&typeof m.lastSeq=="number"&&p<=m.lastSeq)return console.debug("[MessageReducer] skipping delta - seq <= lastSeq",{seq:p,lastSeq:m.lastSeq}),e;const{newParts:v,newMeta:g,changed:x}=pu(c.content,t.delta,m,p);if(!x)return e;const y={...c,content:v},b=to(i,a,y),T=!f||f.lastSeq!==g.lastSeq||f.lastText!==g.lastText,E=T?{...d,[s]:g}:l;return T?{...e,messages:b,messagesStreamMeta:E}:{...e,messages:b}}if(t.type==="message.end"){const s=e.assemblingId??du(e.messages);if(!s)return{...e,assemblingId:null};const i=e.messages,a=i.findIndex(c=>c.id===s&&c.role==="assistant");if(a>=0){const c=i[a];if(!((n=c.content)==null?void 0:n.some(d=>{var f;return(d==null?void 0:d.type)==="text"&&((f=d.text)==null?void 0:f.trim())}))){console.debug("[MessageReducer] pruning assistant message with no visible text",{id:c.id,contentTypes:(r=c.content)==null?void 0:r.map(f=>f==null?void 0:f.type),contentPreview:(o=c.content)==null?void 0:o.map(f=>(f==null?void 0:f.type)==="text"?String(f.text).slice(0,100):f==null?void 0:f.type)});const d=[...i.slice(0,a),...i.slice(a+1)];return{...e,assemblingId:null,messages:d}}}return e}if(t.type==="checkpoint"){const s=t.checkpointNs??e.lastCheckpointNs??null,i=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,c=i===null?Jv(e.messages):e.messages;return{...e,messages:c,pendingInterrupt:i,lastCheckpointId:(a==null?void 0:a.checkpointId)??e.lastCheckpointId,lastCheckpointNs:(a==null?void 0:a.checkpointNs)??e.lastCheckpointNs}}return t.type==="thread_info",e}function zi(e){return e.call_id??e.id??null}function Tu(e){return e.id??e.call_id??`tool-${Date.now()}-${Math.random().toString(16).slice(2)}`}function ku(e,t,n,r){const o=t??`call-${Date.now()}-${Math.random().toString(16).slice(2)}`;return{id:e,role:"tool",name:n??void 0,content:[{type:"tool_call",id:o,name:n??"tool",args:r??{}}],createdAt:new Date().toISOString(),additionalKwargs:{toolCallId:o,toolName:n??void 0,toolStreaming:!0,toolProgress:[]}}}function Hi(e,t){if(!t)return-1;for(let n=0;n<e.length;n+=1){const r=e[n];if(r.role!=="tool")continue;const o=r.additionalKwargs??{};if(typeof o.toolCallId=="string"&&o.toolCallId===t||Bi(r).toolCallId===t)return n}return-1}function xw(e){if(e==null)return[];const t=yr(e);if(typeof t=="string"&&t.trim())return[{type:"text",text:t}];const n=br(t??e);return n?[{type:"text",text:n}]:[]}function Eu(e,t){const n=e.additionalKwargs??{},r=Array.isArray(n.toolProgress)?[...n.toolProgress]:[],o={...n,toolProgress:[...r,t]};return{...e,additionalKwargs:o}}function vw(e,t){const n=zi(t),r=Hi(e.messages,n),o=t.name??t.tool??void 0,s=Tu(t);if(r>=0){const a=e.messages[r],l={...a.additionalKwargs??{},toolStreaming:!0,toolProgress:[]},d={...a,name:o??a.name,additionalKwargs:l};return{...e,messages:to(e.messages,r,d)}}const i=ku(s,n,o,t.args);return{...e,messages:[...e.messages,i]}}function ww(e,t){const n=zi(t);if(!n)return e;const r=Hi(e.messages,n);if(r===-1)return e;const o={type:t.type,content:typeof t.content=="string"?t.content:void 0,seq:t.seq??null,timestamp:new Date().toISOString()},s=t.metadata;s&&(o.metadata=s);const i=t.idx;typeof i=="number"&&(o.idx=i);const a=Eu(e.messages[r],o);return{...e,messages:to(e.messages,r,a)}}function bw(e,t){const n=zi(t),r=Tu(t);let o=e.messages,s=Hi(o,n);if(s===-1){const v=t.name??t.tool??void 0;o=[...o,ku(r,n,v,{})],s=o.length-1}const i=o[s],a=t.output??t.error??null,c=xw(a),l=[...i.content,...c],d={type:t.type,content:typeof t.output=="string"?t.output:void 0,seq:t.seq??null,timestamp:new Date().toISOString()};t.artifact&&(d.artifact=t.artifact);const f=Eu(i,d),m=t.artifact??i.artifact,p={...f,name:t.name??t.tool??i.name,content:l,artifact:m,additionalKwargs:{...f.additionalKwargs??{},toolStreaming:!1}};return{...e,messages:to(o,s,p)}}function Iu({api:e,seed:t,onError:n,currentThreadId:r,initialThreadId:o=null,initialCheckpointId:s=null,initialCheckpointNs:i=null,autoLoadInitial:a=!0,isStreaming:c,getMessages:l}){const[d,f]=w.useState(null),p=w.useMemo(()=>Yn(d),[d]).checkpoints,v=ic(p),g=v.timeline,[x,y]=w.useState(!1),[b,T]=w.useState(!1),[E,S]=w.useState(null),C=w.useRef(r),k=w.useRef(null),A=w.useRef(null),P=w.useRef(null),L=w.useRef(null),F=w.useRef(null),K=w.useRef(new Map),J=w.useRef(null);w.useEffect(()=>{C.current=r},[r]);const _=w.useCallback(async R=>{var z,O;if(!R.threadId)return;const $=R.threadId;(z=R.onStart)==null||z.call(R),R.setLoading(!0);try{await R.action($)}catch(j){if(!Xc(j)&&C.current===$){const Q=String(j);(O=R.handleError)==null||O.call(R,Q),n==null||n(Q)}throw j}finally{R.setLoading(!1)}},[n]),Y=w.useCallback(async(R,$)=>{var Q;if(!R)return;const z=`${R}:${$??"latest"}`,O=K.current.get(z);if(O)return O;(Q=J.current)==null||Q.abort();const j=new AbortController;J.current=j;const U=_({threadId:R,setLoading:y,onStart:()=>S(null),handleError:se=>S(se),action:async se=>{const ie=await e.getStateHistory({threadId:se,checkpointId:$??void 0,signal:j.signal});if(C.current!==se){console.log(`[useThreadHistoryState] Thread changed during load (was ${se}, now ${C.current}), discarding stale data`);return}const{checkpoints:Se}=Yn(ie),xe=Se.find(Re=>Re.messages&&Re.messages.length>0)??($?Se.find(Re=>Re.checkpointId===$):null)??Se[0];t((xe==null?void 0:xe.messages)??[],{checkpointId:(xe==null?void 0:xe.checkpointId)??null,checkpointNs:(xe==null?void 0:xe.checkpointNs)??null,pendingInterrupt:(xe==null?void 0:xe.interrupt)??null}),f(ie)}});K.current.set(z,U);try{await U}finally{K.current.delete(z),J.current===j&&(J.current=null)}return C.current===R&&(F.current=z),U},[e,t,_]),q=w.useCallback(async(R,$)=>{L.current=R;try{await Y(R,$)}catch(z){if(!Xc(z))throw z}finally{L.current===R&&(L.current=null)}},[Y]),W=w.useCallback(R=>{A.current=R},[]),D=w.useCallback(R=>{P.current=R},[]),I=w.useCallback(R=>{const $=R.threadId??C.current;if(!$||C.current&&C.current!==$)return;const{checkpoints:z}=Yn(R);if(!z.length)return;const O=z.find(U=>U.messages&&U.messages.length>0)??z.find(U=>!!U.checkpointId)??z[0],j=P.current===$;!c&&!j&&t((O==null?void 0:O.messages)??[],{checkpointId:(O==null?void 0:O.checkpointId)??null,checkpointNs:(O==null?void 0:O.checkpointNs)??null,pendingInterrupt:(O==null?void 0:O.interrupt)??null}),f(R),F.current=`${$}:latest`,A.current=null,P.current===$&&(P.current=null)},[t,c]),G=w.useCallback(async(R,$)=>{const z=C.current;await _({threadId:z,setLoading:T,action:async O=>{const j=await e.getStateHistory({threadId:O,checkpointId:R,checkpointNs:$??void 0});if(C.current!==O)return;const{checkpoints:U}=Yn(j),Q=U.find(se=>se.checkpointId===R&&($?se.checkpointNs===$:!0));if(!Q){console.warn("[useThreadHistoryState] Requested checkpoint not found:",{checkpointId:R,checkpointNs:$});return}f(j),t(Q.messages??[],{checkpointId:Q.checkpointId??null,checkpointNs:Q.checkpointNs??null})}}).catch(()=>{})},[e,t,_]),X=w.useCallback((R,$)=>{t(l(),{checkpointId:R??null,checkpointNs:$??null})},[l,t]),M=w.useCallback(async()=>{C.current&&await q(C.current)},[q]);w.useEffect(()=>{if(!a||!r||x||c)return;if(A.current===r){A.current=null,k.current=r;return}if(P.current===r){k.current=r;return}if(L.current===r){L.current=null,k.current=r;return}if(k.current===r)return;k.current=r;let R;const $=`${r}:latest`;F.current!==$&&q(r,R)},[a,r,s,i,o,x,c,q]);const B=w.useCallback(()=>{f(null),y(!1),T(!1),S(null),A.current=null,P.current=null,k.current=null,F.current=null,L.current=null},[]);return{threadCheckpoints:p,threadTimeline:g,checkpointIndex:v,isLoadingThread:x,isLoadingCheckpoint:b,threadStateError:E,loadThread:q,navigateToCheckpoint:G,setCurrentCheckpointId:X,returnToLatest:M,handleStateHistoryEvent:I,markSkipNextLoad:W,markStreamPendingThread:D,resetHistoryState:B}}const Nu=w.createContext(null),Au=w.createContext(null);function oo(){const e=w.useContext(Nu);if(!e)throw new Error("useThreadState must be used within a ThreadStateProvider");return e}function ju(){const e=w.useContext(Au);if(!e)throw new Error("useThreadStateUpdater must be used within a ThreadStateProvider");return e}function Pu({children:e,initialThreadId:t=null,initialCheckpointId:n=null,initialCheckpointNs:r=null,autoLoadInitial:o=!0,isStreaming:s,onError:i}){const{api:a}=eo(),{currentThreadId:c}=vr(),{state:l,seed:d,pushUser:f,onEvent:m}=gw(),{threadCheckpoints:p,threadTimeline:v,checkpointIndex:g,isLoadingThread:x,isLoadingCheckpoint:y,threadStateError:b,loadThread:T,navigateToCheckpoint:E,setCurrentCheckpointId:S,returnToLatest:C,handleStateHistoryEvent:k,markSkipNextLoad:A,markStreamPendingThread:P,resetHistoryState:L}=Iu({api:a,seed:d,onError:i,currentThreadId:c,initialThreadId:t,initialCheckpointId:n,initialCheckpointNs:r,autoLoadInitial:o,isStreaming:s,getMessages:w.useCallback(()=>l.messages,[l.messages])}),[F,K]=w.useState(()=>async()=>{throw new Error("clearThread is not ready")}),[J,_]=w.useState(()=>async()=>{throw new Error("respondToInterrupt is not ready")});w.useEffect(()=>{c||(d([],{}),L())},[c,d,L]);const Y=w.useCallback(G=>K(()=>G),[]),q=w.useCallback(G=>_(()=>G),[]),W=w.useMemo(()=>({assemblingMessageId:l.assemblingId??null}),[l.assemblingId]),D=w.useMemo(()=>({threadId:c,messages:l.messages,interrupt:l.pendingInterrupt,checkpoint:{id:l.lastCheckpointId??null,namespace:l.lastCheckpointNs??null},checkpoints:p,checkpointIndex:g,timelineCheckpoints:v,metadata:W,isLoading:x,isLoadingCheckpoint:y,error:b,clearState:F,navigateToCheckpoint:E,setCurrentCheckpointId:S,returnToLatest:C,loadThread:T,clearThread:F,respondToInterrupt:J,messagePreviews:g.messagePreviews,handleStateHistoryEvent:k,markSkipNextLoad:A,markStreamPendingThread:P,resetHistoryState:L,pushUser:f,onEvent:m}),[c,l,p,v,g,W,x,y,b,F,E,S,C,T,J,g.messagePreviews,k,A,P,L,f,m]),I=w.useMemo(()=>({registerClearThread:Y,registerRespondToInterrupt:q}),[Y,q]);return u.jsx(Au.Provider,{value:I,children:u.jsx(Nu.Provider,{value:D,children:e})})}function _u(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 yw(e){const t=_u(e,["checkpoint_id","checkpointId"]);if(!t)return null;const n=_u(e,["checkpoint_ns","checkpointNs"]);return{checkpointId:t,checkpointNs:n}}function Sw(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 Cw(e,t){const n=[...e].sort(Sw);for(const r of n){if(r.messageId!==t)continue;const o=yw(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 Ru=w.createContext(null),Mu=w.createContext(!1);function Tw({children:e,initialThreadId:t=null,initialCheckpointId:n=null,initialCheckpointNs:r=null,autoLoadInitial:o=!0,onError:s,onAuthError:i,onThreadChange:a,onConnectionError:c,onToolEnd:l}){const{api:d,baseUrl:f}=eo(),m=w.useMemo(()=>vn(f),[f]),{stream:p,stop:v,isStreaming:g,error:x,setToken:y}=ew({baseUrl:m}),[b,T]=w.useState(!1);return w.useEffect(()=>{T(g)},[g]),u.jsx(vu,{initialThreadId:t,onError:s,onThreadChange:a,children:u.jsx(Pu,{initialThreadId:t,initialCheckpointId:n,initialCheckpointNs:r,autoLoadInitial:o,onError:s,isStreaming:b,children:u.jsx(Mu.Provider,{value:!0,children:u.jsx(kw,{api:d,streamApi:{stream:p,stop:v,isStreaming:g,error:x,setToken:y},onError:s,onAuthError:i,onConnectionError:c,onToolEnd:l,children:e})})})})}function kw({children:e,api:t,streamApi:n,onError:r,onAuthError:o,onConnectionError:s,onToolEnd:i}){const{stream:a,stop:c,isStreaming:l,error:d,setToken:f}=n,{setCurrentThreadId:m,currentThreadIdRef:p,addThreadFromEvent:v}=vr(),{checkpoint:g,timelineCheckpoints:x,handleStateHistoryEvent:y,markSkipNextLoad:b,markStreamPendingThread:T,resetHistoryState:E,pushUser:S,onEvent:C}=oo(),{registerClearThread:k,registerRespondToInterrupt:A}=ju(),P=w.useCallback(W=>{v(W),p.current!==W.threadId&&((W.created??!p.current)&&b(W.threadId),T(W.threadId),m(W.threadId))},[v,b,T,m,p]),L=w.useCallback(W=>{W.type==="thread_info"?P(W):W.type==="state_history"?y(W):W.type==="tool.end"?i==null||i(W):C(W)},[P,y,C,i]),F=w.useCallback(W=>{a(W,L,{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,L,r,o,s]),K=w.useRef(g);w.useEffect(()=>{K.current=g},[g]);const J=w.useCallback(async(W,D,I)=>{const G=p.current;if(!G)throw new Error("No active thread to handle interrupt");const X=W?D??!0:!1,M=K.current,B={threadId:G,checkpointId:M.id??void 0,checkpointNs:M.namespace??void 0,command:{kind:"resume",value:X},payload:I==null?void 0:I.payload,config:I==null?void 0:I.config,nodeFilter:I==null?void 0:I.nodeFilter,branchLabel:I==null?void 0:I.branchLabel,active_agent:I==null?void 0:I.active_agent,timelineCheckpoints:I==null?void 0:I.timelineCheckpoints};F(B)},[p,F]);w.useEffect(()=>{A(J)},[J,A]);const _=w.useCallback(async()=>{c(),E(),m(null)},[E,m,c]);w.useEffect(()=>{k(_)},[_,k]);const Y=w.useCallback(async(W,D)=>{let I=p.current;const G=(W==null?void 0:W.text)??"",X=(W==null?void 0:W.attachments)??[],M=(G==null?void 0:G.trim())??"",B={...(W==null?void 0:W.payload)??{}},R=Array.isArray(B.messages)?B.messages:void 0;R&&delete B.messages;const $=!!(R&&R.length);if(!I&&!M&&X.length===0&&!$)return;if(!I){const Ge=Math.floor(Date.now()/1e3).toString(16).padStart(8,"0"),He=Array.from({length:4},()=>Math.floor(Math.random()*4294967295).toString(16).padStart(8,"0")).join("").slice(0,16);I=`${Ge}${He}`,b(I),m(I)}const{contentParts:z,filesInfo:O}=await cu(X),j=[...z];M&&j.push({type:"text",text:G});const U=D==null?void 0:D.originalMessageId,Q=!!(D!=null&&D.edit&&U),se=!$&&j.length>0;let ie=null;se&&(ie={id:Q?U:`msg-${Date.now()}`,role:"user",content:j,createdAt:new Date().toISOString()},Q?S(ie,U):S(ie));const Se=$?R:ie?[ie]:[],xe={...B,...O.length?{files_info:O}:{}};Se.length?xe.messages=Se:"messages"in xe||(xe.messages=[]);let Re=(D==null?void 0:D.checkpointId)??g.id??void 0,Ve=(D==null?void 0:D.checkpointNs)??g.namespace??void 0;if(Q&&U){const Ge=Cw(x,U);Re=Ge.checkpointId,Ve=Ge.checkpointNs??void 0}const De={threadId:I,payload:xe,checkpointId:Re,checkpointNs:Ve,edit:!!(D!=null&&D.edit)};F(De)},[g,p,b,S,F,x]),q=w.useMemo(()=>({isStreaming:l,error:d,connectionState:l?"connected":"idle",submit:Y,send:Y,stop:c,setAuthToken:f}),[l,d,Y,c,f]);return u.jsx(Ru.Provider,{value:q,children:e})}function Ui(){const e=w.useContext(Ru);if(!e)throw new Error("useStream must be used within StreamingProvider");return e}function Ew(){return w.useContext(Mu)}function Ou(e){return typeof e=="object"&&e!==null}function Iw(e,t){if(Object.is(e,t))return!0;if(!Ou(e)||!Ou(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 Du(e){const t=w.useRef(e),n=w.useRef(e);return Iw(t.current,e)||(t.current=e,n.current=e),n.current}function Sr({children:e,apiConfig:t,initialThreadId:n=null,initialCheckpointId:r=null,initialCheckpointNs:o=null,autoLoadInitial:s=!0,onConnectionError:i,onError:a,onAuthError:c,onThreadChange:l,onToolEnd:d}){const f=Du(t),m=so(a),p=so(c),v=so(i),g=so(l),x=so(d),y=w.useMemo(()=>({initialThreadId:n,initialCheckpointId:r,initialCheckpointNs:o,autoLoadInitial:s,onError:m,onAuthError:p,onConnectionError:v,onThreadChange:g,onToolEnd:x}),[n,r,o,s,m,p,v,g,x]);return u.jsx(au,{apiConfig:f,children:u.jsx(Tw,{...y,children:e})})}function so(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 Cr(e){if(!(typeof globalThis>"u"))return globalThis[e]}function Nw(e){if(typeof e!="string")return;const t=e.trim();if(t)return vn(t)}function Lu(){const e=[Cr("__API_BASE_URL__"),Cr("__CHAT_API_BASE_URL__"),Cr("__CHAT_API_URL__")];for(const t of e){const n=Nw(t);if(n)return n}}function $u(){const e=[Cr("__API_AUTH_TOKEN__"),Cr("__CHAT_API_KEY__"),Cr("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function Fu(...e){for(const t of e)if(typeof t=="string"&&t.trim())return vn(t);return vn()}function Bu(){const e={},t=Lu(),n=$u();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function zu(){const e=Bu(),t=Nn.getAuthToken(),n=Lu();return{apiBaseUrl:Fu(e.baseUrl,Nn.baseUrl,n),apiKey:t||e.apiKey||$u()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,darkMode:!1,enableSound:!1,messageHistory:100}}const Wi="chat-settings";function Hu(){try{const e=localStorage.getItem(Wi);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function Uu(e){try{const t={...e,apiBaseUrl:vn(e.apiBaseUrl)};localStorage.setItem(Wi,JSON.stringify(t)),t.apiKey&&Nn.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function Aw(){const e=zu(),t=Hu(),n=Nn.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:Fu(Nn.baseUrl,r,e.apiBaseUrl)}}function jw(e){Nn.updateConfig({baseUrl:e.apiBaseUrl,authToken:e.apiKey??void 0}),Uu(e)}function ne(...e){return ux.twMerge(cx.clsx(e))}const Pw=Wr.cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),Je=h.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?qt.Slot:"button";return u.jsx(i,{className:ne(Pw({variant:t,size:n,className:e})),ref:s,...o})});Je.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 Wu(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=Wu(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():Wu(e[o],null)}}}}function Pe(...e){return h.useCallback(Mn(...e),e)}function _w(e,t){const n=h.createContext(t),r=s=>{const{children:i,...a}=s,c=h.useMemo(()=>a,Object.values(a));return u.jsx(n.Provider,{value:c,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 cn(e,t=[]){let n=[];function r(s,i){const a=h.createContext(i),c=n.length;n=[...n,i];const l=f=>{var y;const{scope:m,children:p,...v}=f,g=((y=m==null?void 0:m[e])==null?void 0:y[c])||a,x=h.useMemo(()=>v,Object.values(v));return u.jsx(g.Provider,{value:x,children:p})};l.displayName=s+"Provider";function d(f,m){var g;const p=((g=m==null?void 0:m[e])==null?void 0:g[c])||a,v=h.useContext(p);if(v)return v;if(i!==void 0)return i;throw new Error(`\`${f}\` must be used within \`${s}\``)}return[l,d]}const o=()=>{const s=n.map(i=>h.createContext(i));return function(a){const c=(a==null?void 0:a[e])||s;return h.useMemo(()=>({[`__scope${e}`]:{...a,[e]:c}}),[a,c])}};return o.scopeName=e,[r,Rw(o,...t)]}function Rw(...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:c,scopeName:l})=>{const f=c(s)[`__scope${l}`];return{...a,...f}},{});return h.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var kt=globalThis!=null&&globalThis.document?h.useLayoutEffect:()=>{},Mw=h[" useInsertionEffect ".trim().toString()]||kt;function On({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=Ow({defaultProp:t,onChange:n}),a=e!==void 0,c=a?e:o;{const d=h.useRef(e!==void 0);h.useEffect(()=>{const f=d.current;f!==a&&console.warn(`${r} is changing from ${f?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),d.current=a},[a,r])}const l=h.useCallback(d=>{var f;if(a){const m=Dw(d)?d(e):d;m!==e&&((f=i.current)==null||f.call(i,m))}else s(d)},[a,e,s,i]);return[c,l]}function Ow({defaultProp:e,onChange:t}){const[n,r]=h.useState(e),o=h.useRef(n),s=h.useRef(t);return Mw(()=>{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 Dw(e){return typeof e=="function"}var Lw=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],pe=Lw.reduce((e,t)=>{const n=qt.createSlot(`Primitive.${t}`),r=h.forwardRef((o,s)=>{const{asChild:i,...a}=o,c=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),u.jsx(c,{...a,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Vi(e,t){e&&Vr.flushSync(()=>e.dispatchEvent(t))}function Qo(e){const t=e+"CollectionProvider",[n,r]=cn(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=g=>{const{scope:x,children:y}=g,b=w.useRef(null),T=w.useRef(new Map).current;return u.jsx(o,{scope:x,itemMap:T,collectionRef:b,children:y})};i.displayName=t;const a=e+"CollectionSlot",c=qt.createSlot(a),l=w.forwardRef((g,x)=>{const{scope:y,children:b}=g,T=s(a,y),E=Pe(x,T.collectionRef);return u.jsx(c,{ref:E,children:b})});l.displayName=a;const d=e+"CollectionItemSlot",f="data-radix-collection-item",m=qt.createSlot(d),p=w.forwardRef((g,x)=>{const{scope:y,children:b,...T}=g,E=w.useRef(null),S=Pe(x,E),C=s(d,y);return w.useEffect(()=>(C.itemMap.set(E,{ref:E,...T}),()=>void C.itemMap.delete(E))),u.jsx(m,{[f]:"",ref:S,children:b})});p.displayName=d;function v(g){const x=s(e+"CollectionConsumer",g);return w.useCallback(()=>{const b=x.collectionRef.current;if(!b)return[];const T=Array.from(b.querySelectorAll(`[${f}]`));return Array.from(x.itemMap.values()).sort((C,k)=>T.indexOf(C.ref.current)-T.indexOf(k.ref.current))},[x.collectionRef,x.itemMap])}return[{Provider:i,Slot:l,ItemSlot:p},v,r]}var $w=h.createContext(void 0);function es(e){const t=h.useContext($w);return e||t||"ltr"}function gt(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 Fw(e,t=globalThis==null?void 0:globalThis.document){const n=gt(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 Bw="DismissableLayer",Ki="dismissableLayer.update",zw="dismissableLayer.pointerDownOutside",Hw="dismissableLayer.focusOutside",Vu,Ku=h.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Tr=h.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...c}=e,l=h.useContext(Ku),[d,f]=h.useState(null),m=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,p]=h.useState({}),v=Pe(t,k=>f(k)),g=Array.from(l.layers),[x]=[...l.layersWithOutsidePointerEventsDisabled].slice(-1),y=g.indexOf(x),b=d?g.indexOf(d):-1,T=l.layersWithOutsidePointerEventsDisabled.size>0,E=b>=y,S=Ww(k=>{const A=k.target,P=[...l.branches].some(L=>L.contains(A));!E||P||(o==null||o(k),i==null||i(k),k.defaultPrevented||a==null||a())},m),C=Vw(k=>{const A=k.target;[...l.branches].some(L=>L.contains(A))||(s==null||s(k),i==null||i(k),k.defaultPrevented||a==null||a())},m);return Fw(k=>{b===l.layers.size-1&&(r==null||r(k),!k.defaultPrevented&&a&&(k.preventDefault(),a()))},m),h.useEffect(()=>{if(d)return n&&(l.layersWithOutsidePointerEventsDisabled.size===0&&(Vu=m.body.style.pointerEvents,m.body.style.pointerEvents="none"),l.layersWithOutsidePointerEventsDisabled.add(d)),l.layers.add(d),Gu(),()=>{n&&l.layersWithOutsidePointerEventsDisabled.size===1&&(m.body.style.pointerEvents=Vu)}},[d,m,n,l]),h.useEffect(()=>()=>{d&&(l.layers.delete(d),l.layersWithOutsidePointerEventsDisabled.delete(d),Gu())},[d,l]),h.useEffect(()=>{const k=()=>p({});return document.addEventListener(Ki,k),()=>document.removeEventListener(Ki,k)},[]),u.jsx(pe.div,{...c,ref:v,style:{pointerEvents:T?E?"auto":"none":void 0,...e.style},onFocusCapture:ae(e.onFocusCapture,C.onFocusCapture),onBlurCapture:ae(e.onBlurCapture,C.onBlurCapture),onPointerDownCapture:ae(e.onPointerDownCapture,S.onPointerDownCapture)})});Tr.displayName=Bw;var Uw="DismissableLayerBranch",qu=h.forwardRef((e,t)=>{const n=h.useContext(Ku),r=h.useRef(null),o=Pe(t,r);return h.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),u.jsx(pe.div,{...e,ref:o})});qu.displayName=Uw;function Ww(e,t=globalThis==null?void 0:globalThis.document){const n=gt(e),r=h.useRef(!1),o=h.useRef(()=>{});return h.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let c=function(){Yu(zw,n,l,{discrete:!0})};const l={originalEvent:a};a.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=c,t.addEventListener("click",o.current,{once:!0})):c()}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 Vw(e,t=globalThis==null?void 0:globalThis.document){const n=gt(e),r=h.useRef(!1);return h.useEffect(()=>{const o=s=>{s.target&&!r.current&&Yu(Hw,n,{originalEvent:s},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function Gu(){const e=new CustomEvent(Ki);document.dispatchEvent(e)}function Yu(e,t,n,{discrete:r}){const o=n.originalEvent.target,s=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?Vi(o,s):o.dispatchEvent(s)}var Kw=Tr,qw=qu,qi=0;function Gi(){h.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Xu()),document.body.insertAdjacentElement("beforeend",e[1]??Xu()),qi++,()=>{qi===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),qi--}},[])}function Xu(){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 Yi="focusScope.autoFocusOnMount",Xi="focusScope.autoFocusOnUnmount",Ju={bubbles:!1,cancelable:!0},Gw="FocusScope",ts=h.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,c]=h.useState(null),l=gt(o),d=gt(s),f=h.useRef(null),m=Pe(t,g=>c(g)),p=h.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;h.useEffect(()=>{if(r){let g=function(T){if(p.paused||!a)return;const E=T.target;a.contains(E)?f.current=E:Dn(f.current,{select:!0})},x=function(T){if(p.paused||!a)return;const E=T.relatedTarget;E!==null&&(a.contains(E)||Dn(f.current,{select:!0}))},y=function(T){if(document.activeElement===document.body)for(const S of T)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,p.paused]),h.useEffect(()=>{if(a){ed.add(p);const g=document.activeElement;if(!a.contains(g)){const y=new CustomEvent(Yi,Ju);a.addEventListener(Yi,l),a.dispatchEvent(y),y.defaultPrevented||(Yw(eb(Zu(a)),{select:!0}),document.activeElement===g&&Dn(a))}return()=>{a.removeEventListener(Yi,l),setTimeout(()=>{const y=new CustomEvent(Xi,Ju);a.addEventListener(Xi,d),a.dispatchEvent(y),y.defaultPrevented||Dn(g??document.body,{select:!0}),a.removeEventListener(Xi,d),ed.remove(p)},0)}}},[a,l,d,p]);const v=h.useCallback(g=>{if(!n&&!r||p.paused)return;const x=g.key==="Tab"&&!g.altKey&&!g.ctrlKey&&!g.metaKey,y=document.activeElement;if(x&&y){const b=g.currentTarget,[T,E]=Xw(b);T&&E?!g.shiftKey&&y===E?(g.preventDefault(),n&&Dn(T,{select:!0})):g.shiftKey&&y===T&&(g.preventDefault(),n&&Dn(E,{select:!0})):y===b&&g.preventDefault()}},[n,r,p.paused]);return u.jsx(pe.div,{tabIndex:-1,...i,ref:m,onKeyDown:v})});ts.displayName=Gw;function Yw(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Dn(r,{select:t}),document.activeElement!==n)return}function Xw(e){const t=Zu(e),n=Qu(t,e),r=Qu(t.reverse(),e);return[n,r]}function Zu(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function Qu(e,t){for(const n of e)if(!Jw(n,{upTo:t}))return n}function Jw(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 Zw(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&&Zw(e)&&t&&e.select()}}var ed=Qw();function Qw(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=td(e,t),e.unshift(t)},remove(t){var n;e=td(e,t),(n=e[0])==null||n.resume()}}}function td(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function eb(e){return e.filter(t=>t.tagName!=="A")}var tb=h[" useId ".trim().toString()]||(()=>{}),nb=0;function _t(e){const[t,n]=h.useState(tb());return kt(()=>{n(r=>r??String(nb++))},[e]),t?`radix-${t}`:""}const rb=["top","right","bottom","left"],Ln=Math.min,Xt=Math.max,ns=Math.round,rs=Math.floor,wn=e=>({x:e,y:e}),ob={left:"right",right:"left",bottom:"top",top:"bottom"},sb={start:"end",end:"start"};function Ji(e,t,n){return Xt(e,Ln(t,n))}function An(e,t){return typeof e=="function"?e(t):e}function jn(e){return e.split("-")[0]}function kr(e){return e.split("-")[1]}function Zi(e){return e==="x"?"y":"x"}function Qi(e){return e==="y"?"height":"width"}const ib=new Set(["top","bottom"]);function bn(e){return ib.has(jn(e))?"y":"x"}function ea(e){return Zi(bn(e))}function ab(e,t,n){n===void 0&&(n=!1);const r=kr(e),o=ea(e),s=Qi(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=os(i)),[i,os(i)]}function lb(e){const t=os(e);return[ta(e),t,ta(t)]}function ta(e){return e.replace(/start|end/g,t=>sb[t])}const nd=["left","right"],rd=["right","left"],cb=["top","bottom"],ub=["bottom","top"];function db(e,t,n){switch(e){case"top":case"bottom":return n?t?rd:nd:t?nd:rd;case"left":case"right":return t?cb:ub;default:return[]}}function fb(e,t,n,r){const o=kr(e);let s=db(jn(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(ta)))),s}function os(e){return e.replace(/left|right|bottom|top/g,t=>ob[t])}function pb(e){return{top:0,right:0,bottom:0,left:0,...e}}function od(e){return typeof e!="number"?pb(e):{top:e,right:e,bottom:e,left:e}}function ss(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}function sd(e,t,n){let{reference:r,floating:o}=e;const s=bn(t),i=ea(t),a=Qi(i),c=jn(t),l=s==="y",d=r.x+r.width/2-o.width/2,f=r.y+r.height/2-o.height/2,m=r[a]/2-o[a]/2;let p;switch(c){case"top":p={x:d,y:r.y-o.height};break;case"bottom":p={x:d,y:r.y+r.height};break;case"right":p={x:r.x+r.width,y:f};break;case"left":p={x:r.x-o.width,y:f};break;default:p={x:r.x,y:r.y}}switch(kr(t)){case"start":p[i]-=m*(n&&l?-1:1);break;case"end":p[i]+=m*(n&&l?-1:1);break}return p}const hb=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=n,a=s.filter(Boolean),c=await(i.isRTL==null?void 0:i.isRTL(t));let l=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:d,y:f}=sd(l,r,c),m=r,p={},v=0;for(let g=0;g<a.length;g++){const{name:x,fn:y}=a[g],{x:b,y:T,data:E,reset:S}=await y({x:d,y:f,initialPlacement:r,placement:m,strategy:o,middlewareData:p,rects:l,platform:i,elements:{reference:e,floating:t}});d=b??d,f=T??f,p={...p,[x]:{...p[x],...E}},S&&v<=50&&(v++,typeof S=="object"&&(S.placement&&(m=S.placement),S.rects&&(l=S.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):S.rects),{x:d,y:f}=sd(l,m,c)),g=-1)}return{x:d,y:f,placement:m,strategy:o,middlewareData:p}};async function io(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:i,elements:a,strategy:c}=e,{boundary:l="clippingAncestors",rootBoundary:d="viewport",elementContext:f="floating",altBoundary:m=!1,padding:p=0}=An(t,e),v=od(p),x=a[m?f==="floating"?"reference":"floating":f],y=ss(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(x)))==null||n?x:x.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:l,rootBoundary:d,strategy:c})),b=f==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,T=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),E=await(s.isElement==null?void 0:s.isElement(T))?await(s.getScale==null?void 0:s.getScale(T))||{x:1,y:1}:{x:1,y:1},S=ss(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:b,offsetParent:T,strategy:c}):b);return{top:(y.top-S.top+v.top)/E.y,bottom:(S.bottom-y.bottom+v.bottom)/E.y,left:(y.left-S.left+v.left)/E.x,right:(S.right-y.right+v.right)/E.x}}const mb=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:s,platform:i,elements:a,middlewareData:c}=t,{element:l,padding:d=0}=An(e,t)||{};if(l==null)return{};const f=od(d),m={x:n,y:r},p=ea(o),v=Qi(p),g=await i.getDimensions(l),x=p==="y",y=x?"top":"left",b=x?"bottom":"right",T=x?"clientHeight":"clientWidth",E=s.reference[v]+s.reference[p]-m[p]-s.floating[v],S=m[p]-s.reference[p],C=await(i.getOffsetParent==null?void 0:i.getOffsetParent(l));let k=C?C[T]:0;(!k||!await(i.isElement==null?void 0:i.isElement(C)))&&(k=a.floating[T]||s.floating[v]);const A=E/2-S/2,P=k/2-g[v]/2-1,L=Ln(f[y],P),F=Ln(f[b],P),K=L,J=k-g[v]-F,_=k/2-g[v]/2+A,Y=Ji(K,_,J),q=!c.arrow&&kr(o)!=null&&_!==Y&&s.reference[v]/2-(_<K?L:F)-g[v]/2<0,W=q?_<K?_-K:_-J:0;return{[p]:m[p]+W,data:{[p]:Y,centerOffset:_-Y-W,...q&&{alignmentOffset:W}},reset:q}}}),gb=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:c,elements:l}=t,{mainAxis:d=!0,crossAxis:f=!0,fallbackPlacements:m,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:v="none",flipAlignment:g=!0,...x}=An(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const y=jn(o),b=bn(a),T=jn(a)===a,E=await(c.isRTL==null?void 0:c.isRTL(l.floating)),S=m||(T||!g?[os(a)]:lb(a)),C=v!=="none";!m&&C&&S.push(...fb(a,g,v,E));const k=[a,...S],A=await io(t,x),P=[];let L=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&P.push(A[y]),f){const _=ab(o,i,E);P.push(A[_[0]],A[_[1]])}if(L=[...L,{placement:o,overflows:P}],!P.every(_=>_<=0)){var F,K;const _=(((F=s.flip)==null?void 0:F.index)||0)+1,Y=k[_];if(Y&&(!(f==="alignment"?b!==bn(Y):!1)||L.every(D=>bn(D.placement)===b?D.overflows[0]>0:!0)))return{data:{index:_,overflows:L},reset:{placement:Y}};let q=(K=L.filter(W=>W.overflows[0]<=0).sort((W,D)=>W.overflows[1]-D.overflows[1])[0])==null?void 0:K.placement;if(!q)switch(p){case"bestFit":{var J;const W=(J=L.filter(D=>{if(C){const I=bn(D.placement);return I===b||I==="y"}return!0}).map(D=>[D.placement,D.overflows.filter(I=>I>0).reduce((I,G)=>I+G,0)]).sort((D,I)=>D[1]-I[1])[0])==null?void 0:J[0];W&&(q=W);break}case"initialPlacement":q=a;break}if(o!==q)return{reset:{placement:q}}}return{}}}};function id(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function ad(e){return rb.some(t=>e[t]>=0)}const xb=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 io(t,{...o,elementContext:"reference"}),i=id(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:ad(i)}}}case"escaped":{const s=await io(t,{...o,altBoundary:!0}),i=id(s,n.floating);return{data:{escapedOffsets:i,escaped:ad(i)}}}default:return{}}}}},ld=new Set(["left","top"]);async function vb(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=kr(n),c=bn(n)==="y",l=ld.has(i)?-1:1,d=s&&c?-1:1,f=An(t,e);let{mainAxis:m,crossAxis:p,alignmentAxis:v}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof v=="number"&&(p=a==="end"?v*-1:v),c?{x:p*d,y:m*l}:{x:m*l,y:p*d}}const wb=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,c=await vb(t,e);return i===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:o+c.x,y:s+c.y,data:{...c,placement:i}}}}},bb=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}}},...c}=An(e,t),l={x:n,y:r},d=await io(t,c),f=bn(jn(o)),m=Zi(f);let p=l[m],v=l[f];if(s){const x=m==="y"?"top":"left",y=m==="y"?"bottom":"right",b=p+d[x],T=p-d[y];p=Ji(b,p,T)}if(i){const x=f==="y"?"top":"left",y=f==="y"?"bottom":"right",b=v+d[x],T=v-d[y];v=Ji(b,v,T)}const g=a.fn({...t,[m]:p,[f]:v});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[m]:s,[f]:i}}}}}},yb=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:c=!0,crossAxis:l=!0}=An(e,t),d={x:n,y:r},f=bn(o),m=Zi(f);let p=d[m],v=d[f];const g=An(a,t),x=typeof g=="number"?{mainAxis:g,crossAxis:0}:{mainAxis:0,crossAxis:0,...g};if(c){const T=m==="y"?"height":"width",E=s.reference[m]-s.floating[T]+x.mainAxis,S=s.reference[m]+s.reference[T]-x.mainAxis;p<E?p=E:p>S&&(p=S)}if(l){var y,b;const T=m==="y"?"width":"height",E=ld.has(jn(o)),S=s.reference[f]-s.floating[T]+(E&&((y=i.offset)==null?void 0:y[f])||0)+(E?0:x.crossAxis),C=s.reference[f]+s.reference[T]+(E?0:((b=i.offset)==null?void 0:b[f])||0)-(E?x.crossAxis:0);v<S?v=S:v>C&&(v=C)}return{[m]:p,[f]:v}}}},Sb=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:c=()=>{},...l}=An(e,t),d=await io(t,l),f=jn(o),m=kr(o),p=bn(o)==="y",{width:v,height:g}=s.floating;let x,y;f==="top"||f==="bottom"?(x=f,y=m===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(y=f,x=m==="end"?"top":"bottom");const b=g-d.top-d.bottom,T=v-d.left-d.right,E=Ln(g-d[x],b),S=Ln(v-d[y],T),C=!t.middlewareData.shift;let k=E,A=S;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(A=T),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(k=b),C&&!m){const L=Xt(d.left,0),F=Xt(d.right,0),K=Xt(d.top,0),J=Xt(d.bottom,0);p?A=v-2*(L!==0||F!==0?L+F:Xt(d.left,d.right)):k=g-2*(K!==0||J!==0?K+J:Xt(d.top,d.bottom))}await c({...t,availableWidth:A,availableHeight:k});const P=await i.getDimensions(a.floating);return v!==P.width||g!==P.height?{reset:{rects:!0}}:{}}}};function is(){return typeof window<"u"}function Er(e){return cd(e)?(e.nodeName||"").toLowerCase():"#document"}function Jt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function yn(e){var t;return(t=(cd(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function cd(e){return is()?e instanceof Node||e instanceof Jt(e).Node:!1}function un(e){return is()?e instanceof Element||e instanceof Jt(e).Element:!1}function Sn(e){return is()?e instanceof HTMLElement||e instanceof Jt(e).HTMLElement:!1}function ud(e){return!is()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Jt(e).ShadowRoot}const Cb=new Set(["inline","contents"]);function ao(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=dn(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!Cb.has(o)}const Tb=new Set(["table","td","th"]);function kb(e){return Tb.has(Er(e))}const Eb=[":popover-open",":modal"];function as(e){return Eb.some(t=>{try{return e.matches(t)}catch{return!1}})}const Ib=["transform","translate","scale","rotate","perspective"],Nb=["transform","translate","scale","rotate","perspective","filter"],Ab=["paint","layout","strict","content"];function na(e){const t=ra(),n=un(e)?dn(e):e;return Ib.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)||Nb.some(r=>(n.willChange||"").includes(r))||Ab.some(r=>(n.contain||"").includes(r))}function jb(e){let t=$n(e);for(;Sn(t)&&!Ir(t);){if(na(t))return t;if(as(t))return null;t=$n(t)}return null}function ra(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Pb=new Set(["html","body","#document"]);function Ir(e){return Pb.has(Er(e))}function dn(e){return Jt(e).getComputedStyle(e)}function ls(e){return un(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function $n(e){if(Er(e)==="html")return e;const t=e.assignedSlot||e.parentNode||ud(e)&&e.host||yn(e);return ud(t)?t.host:t}function dd(e){const t=$n(e);return Ir(t)?e.ownerDocument?e.ownerDocument.body:e.body:Sn(t)&&ao(t)?t:dd(t)}function lo(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=dd(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Jt(o);if(s){const a=oa(i);return t.concat(i,i.visualViewport||[],ao(o)?o:[],a&&n?lo(a):[])}return t.concat(o,lo(o,[],n))}function oa(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function fd(e){const t=dn(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=Sn(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=ns(n)!==s||ns(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function sa(e){return un(e)?e:e.contextElement}function Nr(e){const t=sa(e);if(!Sn(t))return wn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=fd(t);let i=(s?ns(n.width):n.width)/r,a=(s?ns(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const _b=wn(0);function pd(e){const t=Jt(e);return!ra()||!t.visualViewport?_b:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Rb(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Jt(e)?!1:t}function Qn(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=sa(e);let i=wn(1);t&&(r?un(r)&&(i=Nr(r)):i=Nr(e));const a=Rb(s,n,r)?pd(s):wn(0);let c=(o.left+a.x)/i.x,l=(o.top+a.y)/i.y,d=o.width/i.x,f=o.height/i.y;if(s){const m=Jt(s),p=r&&un(r)?Jt(r):r;let v=m,g=oa(v);for(;g&&r&&p!==v;){const x=Nr(g),y=g.getBoundingClientRect(),b=dn(g),T=y.left+(g.clientLeft+parseFloat(b.paddingLeft))*x.x,E=y.top+(g.clientTop+parseFloat(b.paddingTop))*x.y;c*=x.x,l*=x.y,d*=x.x,f*=x.y,c+=T,l+=E,v=Jt(g),g=oa(v)}}return ss({width:d,height:f,x:c,y:l})}function cs(e,t){const n=ls(e).scrollLeft;return t?t.left+n:Qn(yn(e)).left+n}function hd(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-cs(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function Mb(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=yn(r),a=t?as(t.floating):!1;if(r===i||a&&s)return n;let c={scrollLeft:0,scrollTop:0},l=wn(1);const d=wn(0),f=Sn(r);if((f||!f&&!s)&&((Er(r)!=="body"||ao(i))&&(c=ls(r)),Sn(r))){const p=Qn(r);l=Nr(r),d.x=p.x+r.clientLeft,d.y=p.y+r.clientTop}const m=i&&!f&&!s?hd(i,c):wn(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+d.x+m.x,y:n.y*l.y-c.scrollTop*l.y+d.y+m.y}}function Ob(e){return Array.from(e.getClientRects())}function Db(e){const t=yn(e),n=ls(e),r=e.ownerDocument.body,o=Xt(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Xt(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+cs(e);const a=-n.scrollTop;return dn(r).direction==="rtl"&&(i+=Xt(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const md=25;function Lb(e,t){const n=Jt(e),r=yn(e),o=n.visualViewport;let s=r.clientWidth,i=r.clientHeight,a=0,c=0;if(o){s=o.width,i=o.height;const d=ra();(!d||d&&t==="fixed")&&(a=o.offsetLeft,c=o.offsetTop)}const l=cs(r);if(l<=0){const d=r.ownerDocument,f=d.body,m=getComputedStyle(f),p=d.compatMode==="CSS1Compat"&&parseFloat(m.marginLeft)+parseFloat(m.marginRight)||0,v=Math.abs(r.clientWidth-f.clientWidth-p);v<=md&&(s-=v)}else l<=md&&(s+=l);return{width:s,height:i,x:a,y:c}}const $b=new Set(["absolute","fixed"]);function Fb(e,t){const n=Qn(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=Sn(e)?Nr(e):wn(1),i=e.clientWidth*s.x,a=e.clientHeight*s.y,c=o*s.x,l=r*s.y;return{width:i,height:a,x:c,y:l}}function gd(e,t,n){let r;if(t==="viewport")r=Lb(e,n);else if(t==="document")r=Db(yn(e));else if(un(t))r=Fb(t,n);else{const o=pd(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return ss(r)}function xd(e,t){const n=$n(e);return n===t||!un(n)||Ir(n)?!1:dn(n).position==="fixed"||xd(n,t)}function Bb(e,t){const n=t.get(e);if(n)return n;let r=lo(e,[],!1).filter(a=>un(a)&&Er(a)!=="body"),o=null;const s=dn(e).position==="fixed";let i=s?$n(e):e;for(;un(i)&&!Ir(i);){const a=dn(i),c=na(i);!c&&a.position==="fixed"&&(o=null),(s?!c&&!o:!c&&a.position==="static"&&!!o&&$b.has(o.position)||ao(i)&&!c&&xd(e,i))?r=r.filter(d=>d!==i):o=a,i=$n(i)}return t.set(e,r),r}function zb(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?as(t)?[]:Bb(t,this._c):[].concat(n),r],a=i[0],c=i.reduce((l,d)=>{const f=gd(t,d,o);return l.top=Xt(f.top,l.top),l.right=Ln(f.right,l.right),l.bottom=Ln(f.bottom,l.bottom),l.left=Xt(f.left,l.left),l},gd(t,a,o));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function Hb(e){const{width:t,height:n}=fd(e);return{width:t,height:n}}function Ub(e,t,n){const r=Sn(t),o=yn(t),s=n==="fixed",i=Qn(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const c=wn(0);function l(){c.x=cs(o)}if(r||!r&&!s)if((Er(t)!=="body"||ao(o))&&(a=ls(t)),r){const p=Qn(t,!0,s,t);c.x=p.x+t.clientLeft,c.y=p.y+t.clientTop}else o&&l();s&&!r&&o&&l();const d=o&&!r&&!s?hd(o,a):wn(0),f=i.left+a.scrollLeft-c.x-d.x,m=i.top+a.scrollTop-c.y-d.y;return{x:f,y:m,width:i.width,height:i.height}}function ia(e){return dn(e).position==="static"}function vd(e,t){if(!Sn(e)||dn(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return yn(e)===n&&(n=n.ownerDocument.body),n}function wd(e,t){const n=Jt(e);if(as(e))return n;if(!Sn(e)){let o=$n(e);for(;o&&!Ir(o);){if(un(o)&&!ia(o))return o;o=$n(o)}return n}let r=vd(e,t);for(;r&&kb(r)&&ia(r);)r=vd(r,t);return r&&Ir(r)&&ia(r)&&!na(r)?n:r||jb(e)||n}const Wb=async function(e){const t=this.getOffsetParent||wd,n=this.getDimensions,r=await n(e.floating);return{reference:Ub(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Vb(e){return dn(e).direction==="rtl"}const Kb={convertOffsetParentRelativeRectToViewportRelativeRect:Mb,getDocumentElement:yn,getClippingRect:zb,getOffsetParent:wd,getElementRects:Wb,getClientRects:Ob,getDimensions:Hb,getScale:Nr,isElement:un,isRTL:Vb};function bd(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function qb(e,t){let n=null,r;const o=yn(e);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,c){a===void 0&&(a=!1),c===void 0&&(c=1),s();const l=e.getBoundingClientRect(),{left:d,top:f,width:m,height:p}=l;if(a||t(),!m||!p)return;const v=rs(f),g=rs(o.clientWidth-(d+m)),x=rs(o.clientHeight-(f+p)),y=rs(d),T={rootMargin:-v+"px "+-g+"px "+-x+"px "+-y+"px",threshold:Xt(0,Ln(1,c))||1};let E=!0;function S(C){const k=C[0].intersectionRatio;if(k!==c){if(!E)return i();k?i(!1,k):r=setTimeout(()=>{i(!1,1e-7)},1e3)}k===1&&!bd(l,e.getBoundingClientRect())&&i(),E=!1}try{n=new IntersectionObserver(S,{...T,root:o.ownerDocument})}catch{n=new IntersectionObserver(S,T)}n.observe(e)}return i(!0),s}function Gb(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:c=!1}=r,l=sa(e),d=o||s?[...l?lo(l):[],...lo(t)]:[];d.forEach(y=>{o&&y.addEventListener("scroll",n,{passive:!0}),s&&y.addEventListener("resize",n)});const f=l&&a?qb(l,n):null;let m=-1,p=null;i&&(p=new ResizeObserver(y=>{let[b]=y;b&&b.target===l&&p&&(p.unobserve(t),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var T;(T=p)==null||T.observe(t)})),n()}),l&&!c&&p.observe(l),p.observe(t));let v,g=c?Qn(e):null;c&&x();function x(){const y=Qn(e);g&&!bd(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)}),f==null||f(),(y=p)==null||y.disconnect(),p=null,c&&cancelAnimationFrame(v)}}const Yb=wb,Xb=bb,Jb=gb,Zb=Sb,Qb=xb,yd=mb,ey=yb,ty=(e,t,n)=>{const r=new Map,o={platform:Kb,...n},s={...o.platform,_c:r};return hb(e,t,{...o,platform:s})};var ny=typeof document<"u",ry=function(){},us=ny?w.useLayoutEffect:ry;function ds(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!ds(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){const s=o[r];if(!(s==="_owner"&&e.$$typeof)&&!ds(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function Sd(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Cd(e,t){const n=Sd(e);return Math.round(t*n)/n}function aa(e){const t=h.useRef(e);return us(()=>{t.current=e}),t}function oy(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:c,open:l}=e,[d,f]=h.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[m,p]=h.useState(r);ds(m,r)||p(r);const[v,g]=h.useState(null),[x,y]=h.useState(null),b=h.useCallback(D=>{D!==C.current&&(C.current=D,g(D))},[]),T=h.useCallback(D=>{D!==k.current&&(k.current=D,y(D))},[]),E=s||v,S=i||x,C=h.useRef(null),k=h.useRef(null),A=h.useRef(d),P=c!=null,L=aa(c),F=aa(o),K=aa(l),J=h.useCallback(()=>{if(!C.current||!k.current)return;const D={placement:t,strategy:n,middleware:m};F.current&&(D.platform=F.current),ty(C.current,k.current,D).then(I=>{const G={...I,isPositioned:K.current!==!1};_.current&&!ds(A.current,G)&&(A.current=G,Vr.flushSync(()=>{f(G)}))})},[m,t,n,F,K]);us(()=>{l===!1&&A.current.isPositioned&&(A.current.isPositioned=!1,f(D=>({...D,isPositioned:!1})))},[l]);const _=h.useRef(!1);us(()=>(_.current=!0,()=>{_.current=!1}),[]),us(()=>{if(E&&(C.current=E),S&&(k.current=S),E&&S){if(L.current)return L.current(E,S,J);J()}},[E,S,J,L,P]);const Y=h.useMemo(()=>({reference:C,floating:k,setReference:b,setFloating:T}),[b,T]),q=h.useMemo(()=>({reference:E,floating:S}),[E,S]),W=h.useMemo(()=>{const D={position:n,left:0,top:0};if(!q.floating)return D;const I=Cd(q.floating,d.x),G=Cd(q.floating,d.y);return a?{...D,transform:"translate("+I+"px, "+G+"px)",...Sd(q.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:I,top:G}},[n,a,q.floating,d.x,d.y]);return h.useMemo(()=>({...d,update:J,refs:Y,elements:q,floatingStyles:W}),[d,J,Y,q,W])}const sy=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?yd({element:r.current,padding:o}).fn(n):{}:r?yd({element:r,padding:o}).fn(n):{}}}},iy=(e,t)=>({...Yb(e),options:[e,t]}),ay=(e,t)=>({...Xb(e),options:[e,t]}),ly=(e,t)=>({...ey(e),options:[e,t]}),cy=(e,t)=>({...Jb(e),options:[e,t]}),uy=(e,t)=>({...Zb(e),options:[e,t]}),dy=(e,t)=>({...Qb(e),options:[e,t]}),fy=(e,t)=>({...sy(e),options:[e,t]});var py="Arrow",Td=h.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return u.jsx(pe.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"})})});Td.displayName=py;var hy=Td;function kd(e){const[t,n]=h.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 c=s.borderBoxSize,l=Array.isArray(c)?c[0]:c;i=l.inlineSize,a=l.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 la="Popper",[Ed,Ar]=cn(la),[my,Id]=Ed(la),Nd=e=>{const{__scopePopper:t,children:n}=e,[r,o]=h.useState(null);return u.jsx(my,{scope:t,anchor:r,onAnchorChange:o,children:n})};Nd.displayName=la;var Ad="PopperAnchor",jd=h.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=Id(Ad,n),i=h.useRef(null),a=Pe(t,i),c=h.useRef(null);return h.useEffect(()=>{const l=c.current;c.current=(r==null?void 0:r.current)||i.current,l!==c.current&&s.onAnchorChange(c.current)}),r?null:u.jsx(pe.div,{...o,ref:a})});jd.displayName=Ad;var ca="PopperContent",[gy,xy]=Ed(ca),Pd=h.forwardRef((e,t)=>{var O,j,U,Q,se,ie;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:a=0,avoidCollisions:c=!0,collisionBoundary:l=[],collisionPadding:d=0,sticky:f="partial",hideWhenDetached:m=!1,updatePositionStrategy:p="optimized",onPlaced:v,...g}=e,x=Id(ca,n),[y,b]=h.useState(null),T=Pe(t,Se=>b(Se)),[E,S]=h.useState(null),C=kd(E),k=(C==null?void 0:C.width)??0,A=(C==null?void 0:C.height)??0,P=r+(s!=="center"?"-"+s:""),L=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},F=Array.isArray(l)?l:[l],K=F.length>0,J={padding:L,boundary:F.filter(wy),altBoundary:K},{refs:_,floatingStyles:Y,placement:q,isPositioned:W,middlewareData:D}=oy({strategy:"fixed",placement:P,whileElementsMounted:(...Se)=>Gb(...Se,{animationFrame:p==="always"}),elements:{reference:x.anchor},middleware:[iy({mainAxis:o+A,alignmentAxis:i}),c&&ay({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?ly():void 0,...J}),c&&cy({...J}),uy({...J,apply:({elements:Se,rects:xe,availableWidth:Re,availableHeight:Ve})=>{const{width:De,height:Ge}=xe.reference,He=Se.floating.style;He.setProperty("--radix-popper-available-width",`${Re}px`),He.setProperty("--radix-popper-available-height",`${Ve}px`),He.setProperty("--radix-popper-anchor-width",`${De}px`),He.setProperty("--radix-popper-anchor-height",`${Ge}px`)}}),E&&fy({element:E,padding:a}),by({arrowWidth:k,arrowHeight:A}),m&&dy({strategy:"referenceHidden",...J})]}),[I,G]=Md(q),X=gt(v);kt(()=>{W&&(X==null||X())},[W,X]);const M=(O=D.arrow)==null?void 0:O.x,B=(j=D.arrow)==null?void 0:j.y,R=((U=D.arrow)==null?void 0:U.centerOffset)!==0,[$,z]=h.useState();return kt(()=>{y&&z(window.getComputedStyle(y).zIndex)},[y]),u.jsx("div",{ref:_.setFloating,"data-radix-popper-content-wrapper":"",style:{...Y,transform:W?Y.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:$,"--radix-popper-transform-origin":[(Q=D.transformOrigin)==null?void 0:Q.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(gy,{scope:n,placedSide:I,onArrowChange:S,arrowX:M,arrowY:B,shouldHideArrow:R,children:u.jsx(pe.div,{"data-side":I,"data-align":G,...g,ref:T,style:{...g.style,animation:W?void 0:"none"}})})})});Pd.displayName=ca;var _d="PopperArrow",vy={top:"bottom",right:"left",bottom:"top",left:"right"},Rd=h.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=xy(_d,r),i=vy[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(hy,{...o,ref:n,style:{...o.style,display:"block"}})})});Rd.displayName=_d;function wy(e){return e!==null}var by=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,c=i?0:e.arrowHeight,[l,d]=Md(n),f={start:"0%",center:"50%",end:"100%"}[d],m=(((y=o.arrow)==null?void 0:y.x)??0)+a/2,p=(((b=o.arrow)==null?void 0:b.y)??0)+c/2;let v="",g="";return l==="bottom"?(v=i?f:`${m}px`,g=`${-c}px`):l==="top"?(v=i?f:`${m}px`,g=`${r.floating.height+c}px`):l==="right"?(v=`${-c}px`,g=i?f:`${p}px`):l==="left"&&(v=`${r.floating.width+c}px`,g=i?f:`${p}px`),{data:{x:v,y:g}}}});function Md(e){const[t,n="center"]=e.split("-");return[t,n]}var ua=Nd,da=jd,fa=Pd,pa=Rd,yy="Portal",co=h.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=h.useState(!1);kt(()=>s(!0),[]);const i=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?Lo.createPortal(u.jsx(pe.div,{...r,ref:t}),i):null});co.displayName=yy;function Sy(e,t){return h.useReducer((n,r)=>t[n][r]??n,e)}var Ht=e=>{const{present:t,children:n}=e,r=Cy(t),o=typeof n=="function"?n({present:r.isPresent}):h.Children.only(n),s=Pe(r.ref,Ty(o));return typeof n=="function"||r.isPresent?h.cloneElement(o,{ref:s}):null};Ht.displayName="Presence";function Cy(e){const[t,n]=h.useState(),r=h.useRef(null),o=h.useRef(e),s=h.useRef("none"),i=e?"mounted":"unmounted",[a,c]=Sy(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return h.useEffect(()=>{const l=fs(r.current);s.current=a==="mounted"?l:"none"},[a]),kt(()=>{const l=r.current,d=o.current;if(d!==e){const m=s.current,p=fs(l);e?c("MOUNT"):p==="none"||(l==null?void 0:l.display)==="none"?c("UNMOUNT"):c(d&&m!==p?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,c]),kt(()=>{if(t){let l;const d=t.ownerDocument.defaultView??window,f=p=>{const g=fs(r.current).includes(CSS.escape(p.animationName));if(p.target===t&&g&&(c("ANIMATION_END"),!o.current)){const x=t.style.animationFillMode;t.style.animationFillMode="forwards",l=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=x)})}},m=p=>{p.target===t&&(s.current=fs(r.current))};return t.addEventListener("animationstart",m),t.addEventListener("animationcancel",f),t.addEventListener("animationend",f),()=>{d.clearTimeout(l),t.removeEventListener("animationstart",m),t.removeEventListener("animationcancel",f),t.removeEventListener("animationend",f)}}else c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:h.useCallback(l=>{r.current=l?getComputedStyle(l):null,n(l)},[])}}function fs(e){return(e==null?void 0:e.animationName)||"none"}function Ty(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 ha="rovingFocusGroup.onEntryFocus",ky={bubbles:!1,cancelable:!0},uo="RovingFocusGroup",[ma,Od,Ey]=Qo(uo),[Iy,Dd]=cn(uo,[Ey]),[Ny,Ay]=Iy(uo),Ld=h.forwardRef((e,t)=>u.jsx(ma.Provider,{scope:e.__scopeRovingFocusGroup,children:u.jsx(ma.Slot,{scope:e.__scopeRovingFocusGroup,children:u.jsx(jy,{...e,ref:t})})}));Ld.displayName=uo;var jy=h.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:c,onEntryFocus:l,preventScrollOnEntryFocus:d=!1,...f}=e,m=h.useRef(null),p=Pe(t,m),v=es(s),[g,x]=On({prop:i,defaultProp:a??null,onChange:c,caller:uo}),[y,b]=h.useState(!1),T=gt(l),E=Od(n),S=h.useRef(!1),[C,k]=h.useState(0);return h.useEffect(()=>{const A=m.current;if(A)return A.addEventListener(ha,T),()=>A.removeEventListener(ha,T)},[T]),u.jsx(Ny,{scope:n,orientation:r,dir:v,loop:o,currentTabStopId:g,onItemFocus:h.useCallback(A=>x(A),[x]),onItemShiftTab:h.useCallback(()=>b(!0),[]),onFocusableItemAdd:h.useCallback(()=>k(A=>A+1),[]),onFocusableItemRemove:h.useCallback(()=>k(A=>A-1),[]),children:u.jsx(pe.div,{tabIndex:y||C===0?-1:0,"data-orientation":r,...f,ref:p,style:{outline:"none",...e.style},onMouseDown:ae(e.onMouseDown,()=>{S.current=!0}),onFocus:ae(e.onFocus,A=>{const P=!S.current;if(A.target===A.currentTarget&&P&&!y){const L=new CustomEvent(ha,ky);if(A.currentTarget.dispatchEvent(L),!L.defaultPrevented){const F=E().filter(q=>q.focusable),K=F.find(q=>q.active),J=F.find(q=>q.id===g),Y=[K,J,...F].filter(Boolean).map(q=>q.ref.current);Bd(Y,d)}}S.current=!1}),onBlur:ae(e.onBlur,()=>b(!1))})})}),$d="RovingFocusGroupItem",Fd=h.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,c=_t(),l=s||c,d=Ay($d,n),f=d.currentTabStopId===l,m=Od(n),{onFocusableItemAdd:p,onFocusableItemRemove:v,currentTabStopId:g}=d;return h.useEffect(()=>{if(r)return p(),()=>v()},[r,p,v]),u.jsx(ma.ItemSlot,{scope:n,id:l,focusable:r,active:o,children:u.jsx(pe.span,{tabIndex:f?0:-1,"data-orientation":d.orientation,...a,ref:t,onMouseDown:ae(e.onMouseDown,x=>{r?d.onItemFocus(l):x.preventDefault()}),onFocus:ae(e.onFocus,()=>d.onItemFocus(l)),onKeyDown:ae(e.onKeyDown,x=>{if(x.key==="Tab"&&x.shiftKey){d.onItemShiftTab();return}if(x.target!==x.currentTarget)return;const y=Ry(x,d.orientation,d.dir);if(y!==void 0){if(x.metaKey||x.ctrlKey||x.altKey||x.shiftKey)return;x.preventDefault();let T=m().filter(E=>E.focusable).map(E=>E.ref.current);if(y==="last")T.reverse();else if(y==="prev"||y==="next"){y==="prev"&&T.reverse();const E=T.indexOf(x.currentTarget);T=d.loop?My(T,E+1):T.slice(E+1)}setTimeout(()=>Bd(T))}}),children:typeof i=="function"?i({isCurrentTabStop:f,hasTabStop:g!=null}):i})})});Fd.displayName=$d;var Py={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function _y(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Ry(e,t,n){const r=_y(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return Py[r]}function Bd(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function My(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Oy=Ld,Dy=Fd,Ly=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},jr=new WeakMap,ps=new WeakMap,hs={},ga=0,zd=function(e){return e&&(e.host||zd(e.parentNode))},$y=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=zd(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})},Fy=function(e,t,n,r){var o=$y(t,Array.isArray(e)?e:[e]);hs[n]||(hs[n]=new WeakMap);var s=hs[n],i=[],a=new Set,c=new Set(o),l=function(f){!f||a.has(f)||(a.add(f),l(f.parentNode))};o.forEach(l);var d=function(f){!f||c.has(f)||Array.prototype.forEach.call(f.children,function(m){if(a.has(m))d(m);else try{var p=m.getAttribute(r),v=p!==null&&p!=="false",g=(jr.get(m)||0)+1,x=(s.get(m)||0)+1;jr.set(m,g),s.set(m,x),i.push(m),g===1&&v&&ps.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(),ga++,function(){i.forEach(function(f){var m=jr.get(f)-1,p=s.get(f)-1;jr.set(f,m),s.set(f,p),m||(ps.has(f)||f.removeAttribute(r),ps.delete(f)),p||f.removeAttribute(n)}),ga--,ga||(jr=new WeakMap,jr=new WeakMap,ps=new WeakMap,hs={})}},xa=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=Ly(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),Fy(r,o,n,"aria-hidden")):function(){return null}},Cn=function(){return Cn=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},Cn.apply(this,arguments)};function Hd(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 By(e,t,n){if(n||arguments.length===2)for(var r=0,o=t.length,s;r<o;r++)(s||!(r in t))&&(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return e.concat(s||Array.prototype.slice.call(t))}typeof SuppressedError=="function"&&SuppressedError;var ms="right-scroll-bar-position",gs="width-before-scroll-bar",zy="with-scroll-bars-hidden",Hy="--removed-body-scroll-bar-size";function va(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function Uy(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 Wy=typeof window<"u"?h.useLayoutEffect:h.useEffect,Ud=new WeakMap;function Vy(e,t){var n=Uy(null,function(r){return e.forEach(function(o){return va(o,r)})});return Wy(function(){var r=Ud.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||va(a,null)}),s.forEach(function(a){o.has(a)||va(a,i)})}Ud.set(n,e)},[e]),n}function Ky(e){return e}function qy(e,t){t===void 0&&(t=Ky);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 c=function(){var d=i;i=[],d.forEach(s)},l=function(){return Promise.resolve().then(c)};l(),n={push:function(d){i.push(d),l()},filter:function(d){return i=i.filter(d),n}}}};return o}function Gy(e){e===void 0&&(e={});var t=qy(null);return t.options=Cn({async:!0,ssr:!1},e),t}var Wd=function(e){var t=e.sideCar,n=Hd(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,Cn({},n))};Wd.isSideCarExport=!0;function Yy(e,t){return e.useMedium(t),Wd}var Vd=Gy(),wa=function(){},xs=h.forwardRef(function(e,t){var n=h.useRef(null),r=h.useState({onScrollCapture:wa,onWheelCapture:wa,onTouchMoveCapture:wa}),o=r[0],s=r[1],i=e.forwardProps,a=e.children,c=e.className,l=e.removeScrollBar,d=e.enabled,f=e.shards,m=e.sideCar,p=e.noRelative,v=e.noIsolation,g=e.inert,x=e.allowPinchZoom,y=e.as,b=y===void 0?"div":y,T=e.gapMode,E=Hd(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),S=m,C=Vy([n,t]),k=Cn(Cn({},E),o);return h.createElement(h.Fragment,null,d&&h.createElement(S,{sideCar:Vd,removeScrollBar:l,shards:f,noRelative:p,noIsolation:v,inert:g,setCallbacks:s,allowPinchZoom:!!x,lockRef:n,gapMode:T}),i?h.cloneElement(h.Children.only(a),Cn(Cn({},k),{ref:C})):h.createElement(b,Cn({},k,{className:c,ref:C}),a))});xs.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},xs.classNames={fullWidth:gs,zeroRight:ms};var Xy=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Jy(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Xy();return t&&e.setAttribute("nonce",t),e}function Zy(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Qy(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var e0=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Jy())&&(Zy(t,n),Qy(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},t0=function(){var e=e0();return function(t,n){h.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Kd=function(){var e=t0(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},n0={left:0,top:0,right:0,gap:0},ba=function(e){return parseInt(e||"",10)||0},r0=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[ba(n),ba(r),ba(o)]},o0=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return n0;var t=r0(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])}},s0=Kd(),Pr="data-scroll-locked",i0=function(e,t,n,r){var o=e.left,s=e.top,i=e.right,a=e.gap;return n===void 0&&(n="margin"),`
38
+ `);if(!pt)continue;let Pe;try{Pe=JSON.parse(pt)}catch{console.debug("[use-chat] malformed SSE:",pt.slice(0,200));continue}const Ye=hu(Pe)?Pe.data:Pe;if(!Ye){console.warn("[use-chat] dropped envelope event without payload",Pe);continue}const we=Ye;Ct=Date.now();const Qe=we.seq;if(Qe!==void 0){if(Qe<=bt){console.debug("[use-chat] drop duplicate/out-of-order event",{seq:Qe,lastProcessedSeq:bt,type:we.type});continue}bt>0&&Qe>bt+1&&((se=I==null?void 0:I.onGap)==null||se.call(I,{from:bt,to:Qe})),bt=Qe,k.current=Qe,x(Qe)}if(we.type==="message.start"&&we.role==="assistant"){const Xe=wu(we.model);K.current={messageId:we.id,lastSeq:Qe??null,lastText:""},E({id:we.id,role:"assistant",name:Xe??void 0,model:we.model,createdAt:new Date().toISOString(),content:[]})}if(we.type==="checkpoint")j.current=we.checkpointId??null,L.current=we.checkpointNs??null,v(we.checkpointId??null);else if(we.type==="state_history"){B.current=we;try{const ct=Yn(we).latest;ct&&(j.current=ct.checkpointId??null,L.current=ct.checkpointNs??null,v(ct.checkpointId??null))}catch(Xe){console.warn("[use-chat] Failed to hydrate state_history payload",Xe)}}try{D==null||D(we)}catch(Xe){console.error("[use-chat] Error in onEvent callback:",Xe,"for event:",we.type)}if(we.type==="message.delta"){E(ct=>{const sn=K.current;if(!ct||sn.messageId!==ct.id)return ct;const{newParts:N,newMeta:Z,changed:re}=xu(ct.content??[],we.delta,{lastSeq:sn.lastSeq,lastText:sn.lastText},Qe??null);return re?(K.current={...sn,lastSeq:Z.lastSeq??sn.lastSeq,lastText:Z.lastText??sn.lastText},{...ct,content:N}):ct});const Xe=we.delta.filter(ct=>ct.type==="text").map(ct=>ct.text).join("");Xe&&e.autoAppendAssistant!==!1&&(It.push(Xe),At())}else if(we.type==="heartbeat"){console.debug("[use-chat] heartbeat received");try{(ie=I==null?void 0:I.onHeartbeat)==null||ie.call(I,we)}catch(Xe){console.warn("[use-chat] heartbeat callback failed",Xe)}}else if(ft!==null&&cancelAnimationFrame(ft),Nt(),we.type==="checkpoint")v(we.checkpointId);else if(we.type==="error"){const Xe=we;if(d(Xe.message),X="error",M=Xe.message,Xe.error_type==="auth_error"||Xe.code==="TOKEN_EXPIRED"||((Se=Xe.message)==null?void 0:Se.includes("token"))||((xe=Xe.message)==null?void 0:xe.includes("401"))||((Re=Xe.message)==null?void 0:Re.includes("unauthorized"))||((Ve=Xe.message)==null?void 0:Ve.includes("Unauthorized"))){console.error("[use-chat] Auth error detected:",Xe.message);try{(De=I==null?void 0:I.onAuthError)==null||De.call(I,Xe.message)}catch(sn){console.warn("[use-chat] onAuthError handler failed",sn)}G.abort()}}}}Nt(),X===null&&!G.signal.aborted&&(X="complete")}catch(Ie){if(Ie.name==="AbortError")X=X??"aborted";else{const Ue=Ie.message||String(Ie);X="error",M=Ue,d(Ue),(Ge=I==null?void 0:I.onError)==null||Ge.call(I,Ue)}}finally{try{await dt.cancel()}catch{}finally{(He=dt.releaseLock)==null||He.call(dt)}ft!==null&&typeof window<"u"&&window.cancelAnimationFrame(ft),clearInterval(on)}}catch(Le){if(Le.name==="AbortError")X=X??"aborted";else{const Ke=Le.message||String(Le);X="error",M=Ke,d(Ke),(ot=I==null?void 0:I.onError)==null||ot.call(I,Ke),z||((ut=I==null?void 0:I.onConnectionError)==null||ut.call(I,Ke),z=!0)}}finally{const Le=k.current,Ke=j.current,$e=L.current,Te=B.current,Ae=X??(G.signal.aborted?"aborted":M?"error":"complete");try{(nt=I==null?void 0:I.onClosed)==null||nt.call(I,{reason:Ae,lastSeq:Le,lastCheckpointId:Ke,lastCheckpointNs:$e,lastStateHistory:Te,error:M})}catch(dt){console.warn("[use-chat] onClosed callback failed",dt)}c(!1),b(!1),S.current=null,k.current=0,x(0),A.current=null}})(),{close:()=>G.abort()}},[t,n,r,e.autoAppendAssistant]);return w.useEffect(()=>()=>{var W;C.current=!1,(W=S.current)==null||W.abort()},[]),{isStreaming:a,error:l,assistantText:f,assistantMessage:T,lastCheckpointId:p,lastSeq:g,connected:y,stream:q,stop:Y,clear:_,setToken:J}}const dw=["detail","message","error","description","title"];function Zo(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=Zo(t);if(n)return n}return null}if(typeof e=="object"){const t=e;for(const n of dw){const r=Zo(t[n]);if(r)return r}if("errors"in t){const n=Zo(t.errors);if(n)return n}}return null}function fw(e){if(!e)return"Request failed";const t=e.response,n=Zo(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 bu({api:e,initialThreadId:t=null,onError:n,onThreadChange:r,onCurrentThreadDeleted:o}){const[s,i]=w.useState([]),[a,c]=w.useState(t),[l,d]=w.useState(!1),[f,m]=w.useState(null),[p,v]=w.useState([]),[g,x]=w.useState(!1),[,y]=w.useState(null),[b,T]=w.useState(null),[E,S]=w.useState(!1),C=w.useRef(a),k=w.useRef(new Map);w.useEffect(()=>{C.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]),j=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(()=>{j()},[j]),w.useEffect(()=>{r==null||r(a)},[a,r]);const L=w.useCallback(async D=>{try{const I=await e.createThread(D);return c(I.threadId),await A(),I.threadId}catch(I){const G=String(I);return n==null||n(G),null}},[e,n,A]),B=w.useCallback(async D=>{const I=s;i(X=>X.filter(M=>M.threadId!==D));const G=new AbortController;k.current.set(D,G);try{await e.deleteThread(D),C.current===D&&(c(null),o==null||o())}catch(X){i(I);const M=String(X);n==null||n(M)}finally{k.current.delete(D)}},[e,o,n,s]),K=w.useCallback(async(D,I)=>{try{await e.updateThread(D,I),await A()}catch(G){n==null||n(String(G))}},[e,n,A]),J=w.useCallback(async(D,I)=>{S(!0),T("Sharing thread…");try{await e.shareThread(D,I),await j(),T("Shared successfully")}catch(G){const X=fw(G);throw n==null||n(X),T(`Failed to share: ${X}`),new Error(X)}finally{S(!1)}},[e,n,j]),_=w.useCallback(async(D,I)=>{try{await e.unshareThread(D,I),await j()}catch(G){const X=String(G);throw n==null||n(X),G}},[e,n,j]),Y=w.useMemo(()=>({createThread:L,deleteThread:B,renameThread:K,refreshThreads:A,refreshSharedThreads:j,shareThread:J,unshareThread:_}),[L,B,K,A,j,J,_]),q=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(G=>{let X=!1;const M=G.map(z=>z.threadId===I.threadId?(X=!0,console.debug("[useThreadsState] thread_info: updating existing thread",I.threadId),{...z,title:I.title??z.title,updatedAt:I.updatedAt??z.updatedAt,messageCount:I.messageCount??z.messageCount}):z);return X?M:(console.debug("[useThreadsState] thread_info: adding thread to list",I.threadId),[I,...G])})},[]),W=w.useCallback(()=>T(null),[]);return{threads:s,currentThreadId:a,currentThreadIdRef:C,setCurrentThreadId:c,isLoadingThreads:l,threadsError:f,sharedThreads:p,isLoadingSharedThreads:g,actions:Y,addThreadFromEvent:q,shareInFlight:E,shareStatus:b,clearShareStatus:W}}const yu=w.createContext(null);function Su({children:e,initialThreadId:t=null,onError:n,onThreadChange:r}){const{api:o}=no(),{threads:s,currentThreadId:i,setCurrentThreadId:a,currentThreadIdRef:c,isLoadingThreads:l,threadsError:d,sharedThreads:f,isLoadingSharedThreads:m,actions:p,addThreadFromEvent:v,shareInFlight:g,shareStatus:x,clearShareStatus:y}=bu({api:o,initialThreadId:t,onError:n,onThreadChange:r}),b=w.useMemo(()=>({threads:s,currentThreadId:i,setCurrentThreadId:a,currentThreadIdRef:c,isLoading:l,error:d,sharedThreads:f,isLoadingSharedThreads:m,actions:p,shareInFlight:g,shareStatus:x,clearShareStatus:y,addThreadFromEvent:v}),[s,i,a,c,l,d,f,m,p,g,x,y,v]);return u.jsx(yu.Provider,{value:b,children:e})}function yr(){const e=w.useContext(yu);if(!e)throw new Error("useThreads must be used within a ThreadsProvider");return e}function Qn(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=pw(t);if(n)try{return JSON.parse(n)}catch{return null}return null}}function pw(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 zi(e){return!!(e&&typeof e=="object"&&(e.type==="file"||e.mimeType||e.filename||e.sourceType==="base64"))}function Sr(e){if(typeof e=="string")return e;if(e&&typeof e=="object"){if(Array.isArray(e)){const n=e.map(Sr).filter(r=>r!==void 0);if(!n.length){console.debug("[message-utils] sanitizeForDisplay - array emptied -> returning undefined",{originalLength:e.length});return}return n}if(zi(e)){try{console.debug("[message-utils] sanitizeForDisplay - dropping file-like object",{sampleFilename:e&&(e.filename||e.name)?e.filename||e.name:void 0,keys:Object.keys(e||{})})}catch(n){console.debug("[message-utils] sanitizeForDisplay - dropped file-like (unable to inspect)",{err:String(n)})}return}const t={};for(const n of Object.keys(e)){const r=e[n];if(n==="data"&&typeof r=="string"&&r.length>100)t[n]=`[base64 ${r.length} chars omitted]`;else{const o=Sr(r);o!==void 0&&(t[n]=o)}}if(Object.keys(t).length)return t;try{console.debug("[message-utils] sanitizeForDisplay - object emptied -> returning undefined",{originalKeys:Object.keys(e||{})})}catch(n){console.debug("[message-utils] sanitizeForDisplay - object emptied -> returning undefined (inspect failed)",{err:String(n)})}return}return e}function er(e){if(typeof e=="string")return e;if(zi(e))return"";try{const t=Sr(e);return t===void 0?"":typeof t=="string"?t:JSON.stringify(t,null,2)}catch{return""}}function Cu(e){return typeof e!="string"?!1:/^[\s\n]*[-*]\s|^[\s\n]*#+\s|```|^\s*\[.*\]\(|^>\s/.test(e)}function Tu(e){const t=er(e);return typeof e=="string"&&Cu(e)?{content:e,isMarkdown:!0}:{content:t,isMarkdown:!1}}function tr(e){if(e==null)return e;if(typeof e=="string"){const t=e.trim();if(t.startsWith("{")||t.startsWith("[")){const n=Qn(t);if(n!==null)return tr(n)}return e}return typeof e=="object"&&!Array.isArray(e)&&e.content!==void 0?tr(e.content):e}function ku(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function Qo(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 Hi(e){if(e==null)return null;const t=String(e).trim();return t.length>0?t:null}function Eu(e){const t=r=>{try{const o=Sr(r);return typeof o=="string"?o:JSON.stringify(o??"")}catch{return""}},n=e.filter(r=>r.type==="text");return n.length?t(n.map(r=>r.text).join(`
39
+ `)):t(e)}function Iu(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function Ui(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 Nu(e){if(!e)return"image/png";const t=e.trim();return t?t.includes("/")?t:`image/${t}`:"image/png"}function Au(e){const t=[],n=r=>{r&&r.trim()&&t.push(r.trim())};return e&&(n(e.plotId),n(e.artifactId)),t}function Pu({base64:e,url:t,formatHint:n,extras:r}){const o=typeof e=="string"&&e.length>0,s=Nu(n),i=o?`data:${s};base64,${e}`:t,a=Au(r),c=a.length?a.join(" / "):void 0,l=c?`${c} artifact`:"artifact image";return{src:i,alt:l,label:c}}function ju(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 Pu({base64:t,url:n,formatHint:r,extras:{plotId:e.plotId,artifactId:e.artifactId}})}function Wi(e){var n;const t=(n=e.additionalKwargs)==null?void 0:n.toolProgress;return Array.isArray(t)?t:[]}function Cr(e){if(e==null)return e;if(typeof e=="string"){const t=e.trim(),n=Qn(t);return n!==null?Cr(n):t}if(Array.isArray(e))return e.map(t=>Cr(t));if(typeof e=="object"){const t=e.value;if(t!==void 0)return Cr(t)}return e}function _u(e){const t=Cr(e.value);return t===e.value?e:{...e,value:t}}const hw={messages:[],assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,messagesStreamMeta:{},pendingInterrupt:null};function mw(e,t){var n;switch(t.type){case"reset":return{messages:Bi(((n=t.payload)==null?void 0:n.messages)??[]),assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,pendingInterrupt:null,messagesStreamMeta:{}};case"user_message":{const{message:r,editingMessageId:o}=t.payload;if(o){const s=e.messages.findIndex(i=>i.id===o);if(s>=0){const i=e.messages.slice(0,s);return{...e,messages:[...i,r]}}}return{...e,messages:[...e.messages,r]}}case"seed":{const r=Bi(t.payload.messages),o={...e,messages:r,assemblingId:null,pendingInterrupt:t.payload.pendingInterrupt??null};return Object.prototype.hasOwnProperty.call(t.payload,"checkpointId")&&(o.lastCheckpointId=t.payload.checkpointId??null),Object.prototype.hasOwnProperty.call(t.payload,"checkpointNs")&&(o.lastCheckpointNs=t.payload.checkpointNs??null),o}case"prepend":{const r=Bi(t.payload.messages);if(!r.length)return e;const o=new Set(e.messages.map(a=>a.id)),s=r.filter(a=>!o.has(a.id));if(!s.length)return e;const i=[...s,...e.messages];return{...e,messages:i}}case"event":return Ru(e,t.payload.ev);case"batch":{const{events:r}=t.payload;return r.length?r.reduce((o,s)=>Ru(o,s),e):e}default:return e}}function gw(e=[]){const[t,n]=w.useReducer(mw,{...hw,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]),c=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 l=w.useMemo(()=>({reset:d=>n({type:"reset",payload:{messages:d}}),seed:(d,f)=>n({type:"seed",payload:{messages:d,...f??{}}}),prepend:d=>n({type:"prepend",payload:{messages:d}}),pushUser:(d,f)=>n({type:"user_message",payload:{message:d,editingMessageId:f}}),onEvent:c}),[c]);return{state:t,dispatch:n,...l}}function Ru(e,t){var n,r,o;if(t.type==="message.start"&&t.role==="assistant"){const s=t.id,i=wu(t.model);if(e.messages.some(l=>l.id===s)){const l=e.messagesStreamMeta??{},d={...l,[s]:l[s]??{lastSeq:t.seq??null,lastText:""}};return{...e,assemblingId:s,messagesStreamMeta:d}}const c={id:s,role:"assistant",name:i||void 0,model:t.model,createdAt:new Date().toISOString(),content:[]};return{...e,assemblingId:s,messages:[...e.messages,c]}}if(t.type==="tool.start")return vw(e,t);if(t.type==="tool.progress")return ww(e,t);if(t.type==="tool.end")return bw(e,t);if(t.type==="message.delta"){const s=e.assemblingId??mu(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 c=i[a],l=e.messagesStreamMeta,d=l??{},f=d[s],m=f??{lastSeq:null,lastText:gu(c.content)},p=t.seq??null;if(p!==null&&typeof p=="number"&&typeof m.lastSeq=="number"&&p<=m.lastSeq)return console.debug("[MessageReducer] skipping delta - seq <= lastSeq",{seq:p,lastSeq:m.lastSeq}),e;const{newParts:v,newMeta:g,changed:x}=xu(c.content,t.delta,m,p);if(!x)return e;const y={...c,content:v},b=ro(i,a,y),T=!f||f.lastSeq!==g.lastSeq||f.lastText!==g.lastText,E=T?{...d,[s]:g}:l;return T?{...e,messages:b,messagesStreamMeta:E}:{...e,messages:b}}if(t.type==="message.end"){const s=e.assemblingId??mu(e.messages);if(!s)return{...e,assemblingId:null};const i=e.messages,a=i.findIndex(c=>c.id===s&&c.role==="assistant");if(a>=0){const c=i[a];if(!((n=c.content)==null?void 0:n.some(d=>{var f;return(d==null?void 0:d.type)==="text"&&((f=d.text)==null?void 0:f.trim())}))){console.debug("[MessageReducer] pruning assistant message with no visible text",{id:c.id,contentTypes:(r=c.content)==null?void 0:r.map(f=>f==null?void 0:f.type),contentPreview:(o=c.content)==null?void 0:o.map(f=>(f==null?void 0:f.type)==="text"?String(f.text).slice(0,100):f==null?void 0:f.type)});const d=[...i.slice(0,a),...i.slice(a+1)];return{...e,assemblingId:null,messages:d}}}return e}if(t.type==="checkpoint"){const s=t.checkpointNs??e.lastCheckpointNs??null,i=cw(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,c=i===null?aw(e.messages):e.messages;return{...e,messages:c,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 Vi(e){return e.call_id??e.id??null}function Mu(e){return e.id??e.call_id??`tool-${Date.now()}-${Math.random().toString(16).slice(2)}`}function Ou(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 Ki(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||Qo(r).toolCallId===t)return n}return-1}function xw(e){if(e==null)return[];const t=tr(e);if(typeof t=="string"&&t.trim())return[{type:"text",text:t}];const n=er(t??e);return n?[{type:"text",text:n}]:[]}function Du(e,t){const n=e.additionalKwargs??{},r=Array.isArray(n.toolProgress)?[...n.toolProgress]:[],o={...n,toolProgress:[...r,t]};return{...e,additionalKwargs:o}}function vw(e,t){const n=Vi(t),r=Ki(e.messages,n),o=t.name??t.tool??void 0,s=Mu(t);if(r>=0){const a=e.messages[r],l={...a.additionalKwargs??{},toolStreaming:!0,toolProgress:[]},d={...a,name:o??a.name,additionalKwargs:l};return{...e,messages:ro(e.messages,r,d)}}const i=Ou(s,n,o,t.args);return{...e,messages:[...e.messages,i]}}function ww(e,t){const n=Vi(t);if(!n)return e;const r=Ki(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=Du(e.messages[r],o);return{...e,messages:ro(e.messages,r,a)}}function bw(e,t){const n=Vi(t),r=Mu(t);let o=e.messages,s=Ki(o,n);if(s===-1){const v=t.name??t.tool??void 0;o=[...o,Ou(r,n,v,{})],s=o.length-1}const i=o[s],a=t.output??t.error??null,c=xw(a),l=[...i.content,...c],d={type:t.type,content:typeof t.output=="string"?t.output:void 0,seq:t.seq??null,timestamp:new Date().toISOString()};t.artifact&&(d.artifact=t.artifact);const f=Du(i,d),m=t.artifact??i.artifact,p={...f,name:t.name??t.tool??i.name,content:l,artifact:m,additionalKwargs:{...f.additionalKwargs??{},toolStreaming:!1}};return{...e,messages:ro(o,s,p)}}function Lu({api:e,seed:t,onError:n,currentThreadId:r,initialThreadId:o=null,initialCheckpointId:s=null,initialCheckpointNs:i=null,autoLoadInitial:a=!0,isStreaming:c,getMessages:l}){const[d,f]=w.useState(null),p=w.useMemo(()=>Yn(d),[d]).checkpoints,v=uc(p),g=v.timeline,[x,y]=w.useState(!1),[b,T]=w.useState(!1),[E,S]=w.useState(null),C=w.useRef(r),k=w.useRef(null),A=w.useRef(null),j=w.useRef(null),L=w.useRef(null),B=w.useRef(null),K=w.useRef(new Map),J=w.useRef(null);w.useEffect(()=>{C.current=r},[r]);const _=w.useCallback(async R=>{var H,O;if(!R.threadId)return;const F=R.threadId;(H=R.onStart)==null||H.call(R),R.setLoading(!0);try{await R.action(F)}catch(P){if(!eu(P)&&C.current===F){const Q=String(P);(O=R.handleError)==null||O.call(R,Q),n==null||n(Q)}throw P}finally{R.setLoading(!1)}},[n]),Y=w.useCallback(async(R,F)=>{var Q;if(!R)return;const H=`${R}:${F??"latest"}`,O=K.current.get(H);if(O)return O;(Q=J.current)==null||Q.abort();const P=new AbortController;J.current=P;const U=_({threadId:R,setLoading:y,onStart:()=>S(null),handleError:se=>S(se),action:async se=>{const ie=await e.getStateHistory({threadId:se,checkpointId:F??void 0,signal:P.signal});if(C.current!==se){console.log(`[useThreadHistoryState] Thread changed during load (was ${se}, now ${C.current}), discarding stale data`);return}const{checkpoints:Se}=Yn(ie),xe=Se.find(Re=>Re.messages&&Re.messages.length>0)??(F?Se.find(Re=>Re.checkpointId===F):null)??Se[0];t((xe==null?void 0:xe.messages)??[],{checkpointId:(xe==null?void 0:xe.checkpointId)??null,checkpointNs:(xe==null?void 0:xe.checkpointNs)??null,pendingInterrupt:(xe==null?void 0:xe.interrupt)??null}),f(ie)}});K.current.set(H,U);try{await U}finally{K.current.delete(H),J.current===P&&(J.current=null)}return C.current===R&&(B.current=H),U},[e,t,_]),q=w.useCallback(async(R,F)=>{L.current=R;try{await Y(R,F)}catch(H){if(!eu(H))throw H}finally{L.current===R&&(L.current=null)}},[Y]),W=w.useCallback(R=>{A.current=R},[]),D=w.useCallback(R=>{j.current=R},[]),I=w.useCallback(R=>{const F=R.threadId??C.current;if(!F||C.current&&C.current!==F)return;const{checkpoints:H}=Yn(R);if(!H.length)return;const O=H.find(U=>U.messages&&U.messages.length>0)??H.find(U=>!!U.checkpointId)??H[0],P=j.current===F;!c&&!P&&t((O==null?void 0:O.messages)??[],{checkpointId:(O==null?void 0:O.checkpointId)??null,checkpointNs:(O==null?void 0:O.checkpointNs)??null,pendingInterrupt:(O==null?void 0:O.interrupt)??null}),f(R),B.current=`${F}:latest`,A.current=null,j.current===F&&(j.current=null)},[t,c]),G=w.useCallback(async(R,F)=>{const H=C.current;await _({threadId:H,setLoading:T,action:async O=>{const P=await e.getStateHistory({threadId:O,checkpointId:R,checkpointNs:F??void 0});if(C.current!==O)return;const{checkpoints:U}=Yn(P),Q=U.find(se=>se.checkpointId===R&&(F?se.checkpointNs===F:!0));if(!Q){console.warn("[useThreadHistoryState] Requested checkpoint not found:",{checkpointId:R,checkpointNs:F});return}f(P),t(Q.messages??[],{checkpointId:Q.checkpointId??null,checkpointNs:Q.checkpointNs??null})}}).catch(()=>{})},[e,t,_]),X=w.useCallback((R,F)=>{t(l(),{checkpointId:R??null,checkpointNs:F??null})},[l,t]),M=w.useCallback(async()=>{C.current&&await q(C.current)},[q]);w.useEffect(()=>{if(!a||!r||x||c)return;if(A.current===r){A.current=null,k.current=r;return}if(j.current===r){k.current=r;return}if(L.current===r){L.current=null,k.current=r;return}if(k.current===r)return;k.current=r;let R;const F=`${r}:latest`;B.current!==F&&q(r,R)},[a,r,s,i,o,x,c,q]);const z=w.useCallback(()=>{f(null),y(!1),T(!1),S(null),A.current=null,j.current=null,k.current=null,B.current=null,L.current=null},[]);return{threadCheckpoints:p,threadTimeline:g,checkpointIndex:v,isLoadingThread:x,isLoadingCheckpoint:b,threadStateError:E,loadThread:q,navigateToCheckpoint:G,setCurrentCheckpointId:X,returnToLatest:M,handleStateHistoryEvent:I,markSkipNextLoad:W,markStreamPendingThread:D,resetHistoryState:z}}const $u=w.createContext(null),Fu=w.createContext(null);function oo(){const e=w.useContext($u);if(!e)throw new Error("useThreadState must be used within a ThreadStateProvider");return e}function Bu(){const e=w.useContext(Fu);if(!e)throw new Error("useThreadStateUpdater must be used within a ThreadStateProvider");return e}function zu({children:e,initialThreadId:t=null,initialCheckpointId:n=null,initialCheckpointNs:r=null,autoLoadInitial:o=!0,isStreaming:s,onError:i}){const{api:a}=no(),{currentThreadId:c}=yr(),{state:l,seed:d,pushUser:f,onEvent:m}=gw(),{threadCheckpoints:p,threadTimeline:v,checkpointIndex:g,isLoadingThread:x,isLoadingCheckpoint:y,threadStateError:b,loadThread:T,navigateToCheckpoint:E,setCurrentCheckpointId:S,returnToLatest:C,handleStateHistoryEvent:k,markSkipNextLoad:A,markStreamPendingThread:j,resetHistoryState:L}=Lu({api:a,seed:d,onError:i,currentThreadId:c,initialThreadId:t,initialCheckpointId:n,initialCheckpointNs:r,autoLoadInitial:o,isStreaming:s,getMessages:w.useCallback(()=>l.messages,[l.messages])}),[B,K]=w.useState(()=>async()=>{throw new Error("clearThread is not ready")}),[J,_]=w.useState(()=>async()=>{throw new Error("respondToInterrupt is not ready")});w.useEffect(()=>{c||(d([],{}),L())},[c,d,L]);const Y=w.useCallback(G=>K(()=>G),[]),q=w.useCallback(G=>_(()=>G),[]),W=w.useMemo(()=>({assemblingMessageId:l.assemblingId??null}),[l.assemblingId]),D=w.useMemo(()=>({threadId:c,messages:l.messages,interrupt:l.pendingInterrupt,checkpoint:{id:l.lastCheckpointId??null,namespace:l.lastCheckpointNs??null},checkpoints:p,checkpointIndex:g,timelineCheckpoints:v,metadata:W,isLoading:x,isLoadingCheckpoint:y,error:b,clearState:B,navigateToCheckpoint:E,setCurrentCheckpointId:S,returnToLatest:C,loadThread:T,clearThread:B,respondToInterrupt:J,messagePreviews:g.messagePreviews,handleStateHistoryEvent:k,markSkipNextLoad:A,markStreamPendingThread:j,resetHistoryState:L,pushUser:f,onEvent:m}),[c,l,p,v,g,W,x,y,b,B,E,S,C,T,J,g.messagePreviews,k,A,j,L,f,m]),I=w.useMemo(()=>({registerClearThread:Y,registerRespondToInterrupt:q}),[Y,q]);return u.jsx(Fu.Provider,{value:I,children:u.jsx($u.Provider,{value:D,children:e})})}function Hu(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 yw(e){const t=Hu(e,["checkpoint_id","checkpointId"]);if(!t)return null;const n=Hu(e,["checkpoint_ns","checkpointNs"]);return{checkpointId:t,checkpointNs:n}}function Sw(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 Cw(e,t){const n=[...e].sort(Sw);for(const r of n){if(r.messageId!==t)continue;const o=yw(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 Uu=w.createContext(null),Wu=w.createContext(!1);function Tw({children:e,initialThreadId:t=null,initialCheckpointId:n=null,initialCheckpointNs:r=null,autoLoadInitial:o=!0,onError:s,onAuthError:i,onThreadChange:a,onConnectionError:c,onToolEnd:l}){const{api:d,baseUrl:f}=no(),m=w.useMemo(()=>vn(f),[f]),{stream:p,stop:v,isStreaming:g,error:x,setToken:y}=uw({baseUrl:m}),[b,T]=w.useState(!1);return w.useEffect(()=>{T(g)},[g]),u.jsx(Su,{initialThreadId:t,onError:s,onThreadChange:a,children:u.jsx(zu,{initialThreadId:t,initialCheckpointId:n,initialCheckpointNs:r,autoLoadInitial:o,onError:s,isStreaming:b,children:u.jsx(Wu.Provider,{value:!0,children:u.jsx(kw,{api:d,streamApi:{stream:p,stop:v,isStreaming:g,error:x,setToken:y},onError:s,onAuthError:i,onConnectionError:c,onToolEnd:l,children:e})})})})}function kw({children:e,api:t,streamApi:n,onError:r,onAuthError:o,onConnectionError:s,onToolEnd:i}){const{stream:a,stop:c,isStreaming:l,error:d,setToken:f}=n,{setCurrentThreadId:m,currentThreadIdRef:p,addThreadFromEvent:v}=yr(),{checkpoint:g,timelineCheckpoints:x,handleStateHistoryEvent:y,markSkipNextLoad:b,markStreamPendingThread:T,resetHistoryState:E,pushUser:S,onEvent:C}=oo(),{registerClearThread:k,registerRespondToInterrupt:A}=Bu(),j=w.useCallback(W=>{v(W),p.current!==W.threadId&&((W.created??!p.current)&&b(W.threadId),T(W.threadId),m(W.threadId))},[v,b,T,m,p]),L=w.useCallback(W=>{W.type==="thread_info"?j(W):W.type==="state_history"?y(W):W.type==="tool.end"?i==null||i(W):C(W)},[j,y,C,i]),B=w.useCallback(W=>{a(W,L,{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,L,r,o,s]),K=w.useRef(g);w.useEffect(()=>{K.current=g},[g]);const J=w.useCallback(async(W,D,I)=>{const G=p.current;if(!G)throw new Error("No active thread to handle interrupt");const X=W?D??!0:!1,M=K.current,z={threadId:G,checkpointId:M.id??void 0,checkpointNs:M.namespace??void 0,command:{kind:"resume",value:X},payload:I==null?void 0:I.payload,config:I==null?void 0:I.config,nodeFilter:I==null?void 0:I.nodeFilter,branchLabel:I==null?void 0:I.branchLabel,active_agent:I==null?void 0:I.active_agent,timelineCheckpoints:I==null?void 0:I.timelineCheckpoints};B(z)},[p,B]);w.useEffect(()=>{A(J)},[J,A]);const _=w.useCallback(async()=>{c(),E(),m(null)},[E,m,c]);w.useEffect(()=>{k(_)},[_,k]);const Y=w.useCallback(async(W,D)=>{let I=p.current;const G=(W==null?void 0:W.text)??"",X=(W==null?void 0:W.attachments)??[],M=(G==null?void 0:G.trim())??"",z={...(W==null?void 0:W.payload)??{}},R=Array.isArray(z.messages)?z.messages:void 0;R&&delete z.messages;const F=!!(R&&R.length);if(!I&&!M&&X.length===0&&!F)return;if(!I){const Ge=Math.floor(Date.now()/1e3).toString(16).padStart(8,"0"),He=Array.from({length:4},()=>Math.floor(Math.random()*4294967295).toString(16).padStart(8,"0")).join("").slice(0,16);I=`${Ge}${He}`,b(I),m(I)}const{contentParts:H,filesInfo:O}=await pu(X),P=[...H];M&&P.push({type:"text",text:G});const U=D==null?void 0:D.originalMessageId,Q=!!(D!=null&&D.edit&&U),se=!F&&P.length>0;let ie=null;se&&(ie={id:Q?U:`msg-${Date.now()}`,role:"user",content:P,createdAt:new Date().toISOString()},Q?S(ie,U):S(ie));const Se=F?R:ie?[ie]:[],xe={...z,...O.length?{files_info:O}:{}};Se.length?xe.messages=Se:"messages"in xe||(xe.messages=[]);let Re=(D==null?void 0:D.checkpointId)??g.id??void 0,Ve=(D==null?void 0:D.checkpointNs)??g.namespace??void 0;if(Q&&U){const Ge=Cw(x,U);Re=Ge.checkpointId,Ve=Ge.checkpointNs??void 0}const De={threadId:I,payload:xe,checkpointId:Re,checkpointNs:Ve,edit:!!(D!=null&&D.edit)};B(De)},[g,p,b,S,B,x]),q=w.useMemo(()=>({isStreaming:l,error:d,connectionState:l?"connected":"idle",submit:Y,send:Y,stop:c,setAuthToken:f}),[l,d,Y,c,f]);return u.jsx(Uu.Provider,{value:q,children:e})}function qi(){const e=w.useContext(Uu);if(!e)throw new Error("useStream must be used within StreamingProvider");return e}function Ew(){return w.useContext(Wu)}function Vu(e){return typeof e=="object"&&e!==null}function Iw(e,t){if(Object.is(e,t))return!0;if(!Vu(e)||!Vu(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 Ku(e){const t=w.useRef(e),n=w.useRef(e);return Iw(t.current,e)||(t.current=e,n.current=e),n.current}function Tr({children:e,apiConfig:t,initialThreadId:n=null,initialCheckpointId:r=null,initialCheckpointNs:o=null,autoLoadInitial:s=!0,onConnectionError:i,onError:a,onAuthError:c,onThreadChange:l,onToolEnd:d}){const f=Ku(t),m=so(a),p=so(c),v=so(i),g=so(l),x=so(d),y=w.useMemo(()=>({initialThreadId:n,initialCheckpointId:r,initialCheckpointNs:o,autoLoadInitial:s,onError:m,onAuthError:p,onConnectionError:v,onThreadChange:g,onToolEnd:x}),[n,r,o,s,m,p,v,g,x]);return u.jsx(du,{apiConfig:f,children:u.jsx(Tw,{...y,children:e})})}function so(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 kr(e){if(!(typeof globalThis>"u"))return globalThis[e]}function Nw(e){if(typeof e!="string")return;const t=e.trim();if(t)return vn(t)}function qu(){const e=[kr("__API_BASE_URL__"),kr("__CHAT_API_BASE_URL__"),kr("__CHAT_API_URL__")];for(const t of e){const n=Nw(t);if(n)return n}}function Gu(){const e=[kr("__API_AUTH_TOKEN__"),kr("__CHAT_API_KEY__"),kr("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function Yu(...e){for(const t of e)if(typeof t=="string"&&t.trim())return vn(t);return vn()}function Xu(){const e={},t=qu(),n=Gu();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function Ju(){const e=Xu(),t=Nn.getAuthToken(),n=qu();return{apiBaseUrl:Yu(e.baseUrl,Nn.baseUrl,n),apiKey:t||e.apiKey||Gu()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,darkMode:!1,enableSound:!1,messageHistory:100}}const Gi="chat-settings";function Zu(){try{const e=localStorage.getItem(Gi);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function Qu(e){try{const t={...e,apiBaseUrl:vn(e.apiBaseUrl)};localStorage.setItem(Gi,JSON.stringify(t)),t.apiKey&&Nn.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function Aw(){const e=Ju(),t=Zu(),n=Nn.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:Yu(Nn.baseUrl,r,e.apiBaseUrl)}}function Pw(e){Nn.updateConfig({baseUrl:e.apiBaseUrl,authToken:e.apiKey??void 0}),Qu(e)}function ne(...e){return bx.twMerge(wx.clsx(e))}const jw=Kr.cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),Je=h.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?qt.Slot:"button";return u.jsx(i,{className:ne(jw({variant:t,size:n,className:e})),ref:s,...o})});Je.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 ed(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=ed(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():ed(e[o],null)}}}}function je(...e){return h.useCallback(Mn(...e),e)}function _w(e,t){const n=h.createContext(t),r=s=>{const{children:i,...a}=s,c=h.useMemo(()=>a,Object.values(a));return u.jsx(n.Provider,{value:c,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 cn(e,t=[]){let n=[];function r(s,i){const a=h.createContext(i),c=n.length;n=[...n,i];const l=f=>{var y;const{scope:m,children:p,...v}=f,g=((y=m==null?void 0:m[e])==null?void 0:y[c])||a,x=h.useMemo(()=>v,Object.values(v));return u.jsx(g.Provider,{value:x,children:p})};l.displayName=s+"Provider";function d(f,m){var g;const p=((g=m==null?void 0:m[e])==null?void 0:g[c])||a,v=h.useContext(p);if(v)return v;if(i!==void 0)return i;throw new Error(`\`${f}\` must be used within \`${s}\``)}return[l,d]}const o=()=>{const s=n.map(i=>h.createContext(i));return function(a){const c=(a==null?void 0:a[e])||s;return h.useMemo(()=>({[`__scope${e}`]:{...a,[e]:c}}),[a,c])}};return o.scopeName=e,[r,Rw(o,...t)]}function Rw(...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:c,scopeName:l})=>{const f=c(s)[`__scope${l}`];return{...a,...f}},{});return h.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var kt=globalThis!=null&&globalThis.document?h.useLayoutEffect:()=>{},Mw=h[" useInsertionEffect ".trim().toString()]||kt;function On({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=Ow({defaultProp:t,onChange:n}),a=e!==void 0,c=a?e:o;{const d=h.useRef(e!==void 0);h.useEffect(()=>{const f=d.current;f!==a&&console.warn(`${r} is changing from ${f?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),d.current=a},[a,r])}const l=h.useCallback(d=>{var f;if(a){const m=Dw(d)?d(e):d;m!==e&&((f=i.current)==null||f.call(i,m))}else s(d)},[a,e,s,i]);return[c,l]}function Ow({defaultProp:e,onChange:t}){const[n,r]=h.useState(e),o=h.useRef(n),s=h.useRef(t);return Mw(()=>{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 Dw(e){return typeof e=="function"}var Lw=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],pe=Lw.reduce((e,t)=>{const n=qt.createSlot(`Primitive.${t}`),r=h.forwardRef((o,s)=>{const{asChild:i,...a}=o,c=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),u.jsx(c,{...a,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Yi(e,t){e&&qr.flushSync(()=>e.dispatchEvent(t))}function es(e){const t=e+"CollectionProvider",[n,r]=cn(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=g=>{const{scope:x,children:y}=g,b=w.useRef(null),T=w.useRef(new Map).current;return u.jsx(o,{scope:x,itemMap:T,collectionRef:b,children:y})};i.displayName=t;const a=e+"CollectionSlot",c=qt.createSlot(a),l=w.forwardRef((g,x)=>{const{scope:y,children:b}=g,T=s(a,y),E=je(x,T.collectionRef);return u.jsx(c,{ref:E,children:b})});l.displayName=a;const d=e+"CollectionItemSlot",f="data-radix-collection-item",m=qt.createSlot(d),p=w.forwardRef((g,x)=>{const{scope:y,children:b,...T}=g,E=w.useRef(null),S=je(x,E),C=s(d,y);return w.useEffect(()=>(C.itemMap.set(E,{ref:E,...T}),()=>void C.itemMap.delete(E))),u.jsx(m,{[f]:"",ref:S,children:b})});p.displayName=d;function v(g){const x=s(e+"CollectionConsumer",g);return w.useCallback(()=>{const b=x.collectionRef.current;if(!b)return[];const T=Array.from(b.querySelectorAll(`[${f}]`));return Array.from(x.itemMap.values()).sort((C,k)=>T.indexOf(C.ref.current)-T.indexOf(k.ref.current))},[x.collectionRef,x.itemMap])}return[{Provider:i,Slot:l,ItemSlot:p},v,r]}var $w=h.createContext(void 0);function ts(e){const t=h.useContext($w);return e||t||"ltr"}function gt(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 Fw(e,t=globalThis==null?void 0:globalThis.document){const n=gt(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 Bw="DismissableLayer",Xi="dismissableLayer.update",zw="dismissableLayer.pointerDownOutside",Hw="dismissableLayer.focusOutside",td,nd=h.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Er=h.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...c}=e,l=h.useContext(nd),[d,f]=h.useState(null),m=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,p]=h.useState({}),v=je(t,k=>f(k)),g=Array.from(l.layers),[x]=[...l.layersWithOutsidePointerEventsDisabled].slice(-1),y=g.indexOf(x),b=d?g.indexOf(d):-1,T=l.layersWithOutsidePointerEventsDisabled.size>0,E=b>=y,S=Ww(k=>{const A=k.target,j=[...l.branches].some(L=>L.contains(A));!E||j||(o==null||o(k),i==null||i(k),k.defaultPrevented||a==null||a())},m),C=Vw(k=>{const A=k.target;[...l.branches].some(L=>L.contains(A))||(s==null||s(k),i==null||i(k),k.defaultPrevented||a==null||a())},m);return Fw(k=>{b===l.layers.size-1&&(r==null||r(k),!k.defaultPrevented&&a&&(k.preventDefault(),a()))},m),h.useEffect(()=>{if(d)return n&&(l.layersWithOutsidePointerEventsDisabled.size===0&&(td=m.body.style.pointerEvents,m.body.style.pointerEvents="none"),l.layersWithOutsidePointerEventsDisabled.add(d)),l.layers.add(d),od(),()=>{n&&l.layersWithOutsidePointerEventsDisabled.size===1&&(m.body.style.pointerEvents=td)}},[d,m,n,l]),h.useEffect(()=>()=>{d&&(l.layers.delete(d),l.layersWithOutsidePointerEventsDisabled.delete(d),od())},[d,l]),h.useEffect(()=>{const k=()=>p({});return document.addEventListener(Xi,k),()=>document.removeEventListener(Xi,k)},[]),u.jsx(pe.div,{...c,ref:v,style:{pointerEvents:T?E?"auto":"none":void 0,...e.style},onFocusCapture:ae(e.onFocusCapture,C.onFocusCapture),onBlurCapture:ae(e.onBlurCapture,C.onBlurCapture),onPointerDownCapture:ae(e.onPointerDownCapture,S.onPointerDownCapture)})});Er.displayName=Bw;var Uw="DismissableLayerBranch",rd=h.forwardRef((e,t)=>{const n=h.useContext(nd),r=h.useRef(null),o=je(t,r);return h.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),u.jsx(pe.div,{...e,ref:o})});rd.displayName=Uw;function Ww(e,t=globalThis==null?void 0:globalThis.document){const n=gt(e),r=h.useRef(!1),o=h.useRef(()=>{});return h.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let c=function(){sd(zw,n,l,{discrete:!0})};const l={originalEvent:a};a.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=c,t.addEventListener("click",o.current,{once:!0})):c()}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 Vw(e,t=globalThis==null?void 0:globalThis.document){const n=gt(e),r=h.useRef(!1);return h.useEffect(()=>{const o=s=>{s.target&&!r.current&&sd(Hw,n,{originalEvent:s},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function od(){const e=new CustomEvent(Xi);document.dispatchEvent(e)}function sd(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?Yi(o,s):o.dispatchEvent(s)}var Kw=Er,qw=rd,Ji=0;function Zi(){h.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??id()),document.body.insertAdjacentElement("beforeend",e[1]??id()),Ji++,()=>{Ji===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Ji--}},[])}function id(){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 Qi="focusScope.autoFocusOnMount",ea="focusScope.autoFocusOnUnmount",ad={bubbles:!1,cancelable:!0},Gw="FocusScope",ns=h.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,c]=h.useState(null),l=gt(o),d=gt(s),f=h.useRef(null),m=je(t,g=>c(g)),p=h.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;h.useEffect(()=>{if(r){let g=function(T){if(p.paused||!a)return;const E=T.target;a.contains(E)?f.current=E:Dn(f.current,{select:!0})},x=function(T){if(p.paused||!a)return;const E=T.relatedTarget;E!==null&&(a.contains(E)||Dn(f.current,{select:!0}))},y=function(T){if(document.activeElement===document.body)for(const S of T)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,p.paused]),h.useEffect(()=>{if(a){ud.add(p);const g=document.activeElement;if(!a.contains(g)){const y=new CustomEvent(Qi,ad);a.addEventListener(Qi,l),a.dispatchEvent(y),y.defaultPrevented||(Yw(eb(ld(a)),{select:!0}),document.activeElement===g&&Dn(a))}return()=>{a.removeEventListener(Qi,l),setTimeout(()=>{const y=new CustomEvent(ea,ad);a.addEventListener(ea,d),a.dispatchEvent(y),y.defaultPrevented||Dn(g??document.body,{select:!0}),a.removeEventListener(ea,d),ud.remove(p)},0)}}},[a,l,d,p]);const v=h.useCallback(g=>{if(!n&&!r||p.paused)return;const x=g.key==="Tab"&&!g.altKey&&!g.ctrlKey&&!g.metaKey,y=document.activeElement;if(x&&y){const b=g.currentTarget,[T,E]=Xw(b);T&&E?!g.shiftKey&&y===E?(g.preventDefault(),n&&Dn(T,{select:!0})):g.shiftKey&&y===T&&(g.preventDefault(),n&&Dn(E,{select:!0})):y===b&&g.preventDefault()}},[n,r,p.paused]);return u.jsx(pe.div,{tabIndex:-1,...i,ref:m,onKeyDown:v})});ns.displayName=Gw;function Yw(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Dn(r,{select:t}),document.activeElement!==n)return}function Xw(e){const t=ld(e),n=cd(t,e),r=cd(t.reverse(),e);return[n,r]}function ld(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 cd(e,t){for(const n of e)if(!Jw(n,{upTo:t}))return n}function Jw(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 Zw(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&&Zw(e)&&t&&e.select()}}var ud=Qw();function Qw(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=dd(e,t),e.unshift(t)},remove(t){var n;e=dd(e,t),(n=e[0])==null||n.resume()}}}function dd(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function eb(e){return e.filter(t=>t.tagName!=="A")}var tb=h[" useId ".trim().toString()]||(()=>{}),nb=0;function _t(e){const[t,n]=h.useState(tb());return kt(()=>{n(r=>r??String(nb++))},[e]),t?`radix-${t}`:""}const rb=["top","right","bottom","left"],Ln=Math.min,Xt=Math.max,rs=Math.round,os=Math.floor,wn=e=>({x:e,y:e}),ob={left:"right",right:"left",bottom:"top",top:"bottom"},sb={start:"end",end:"start"};function ta(e,t,n){return Xt(e,Ln(t,n))}function An(e,t){return typeof e=="function"?e(t):e}function Pn(e){return e.split("-")[0]}function Ir(e){return e.split("-")[1]}function na(e){return e==="x"?"y":"x"}function ra(e){return e==="y"?"height":"width"}const ib=new Set(["top","bottom"]);function bn(e){return ib.has(Pn(e))?"y":"x"}function oa(e){return na(bn(e))}function ab(e,t,n){n===void 0&&(n=!1);const r=Ir(e),o=oa(e),s=ra(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=ss(i)),[i,ss(i)]}function lb(e){const t=ss(e);return[sa(e),t,sa(t)]}function sa(e){return e.replace(/start|end/g,t=>sb[t])}const fd=["left","right"],pd=["right","left"],cb=["top","bottom"],ub=["bottom","top"];function db(e,t,n){switch(e){case"top":case"bottom":return n?t?pd:fd:t?fd:pd;case"left":case"right":return t?cb:ub;default:return[]}}function fb(e,t,n,r){const o=Ir(e);let s=db(Pn(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(sa)))),s}function ss(e){return e.replace(/left|right|bottom|top/g,t=>ob[t])}function pb(e){return{top:0,right:0,bottom:0,left:0,...e}}function hd(e){return typeof e!="number"?pb(e):{top:e,right:e,bottom:e,left:e}}function is(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 md(e,t,n){let{reference:r,floating:o}=e;const s=bn(t),i=oa(t),a=ra(i),c=Pn(t),l=s==="y",d=r.x+r.width/2-o.width/2,f=r.y+r.height/2-o.height/2,m=r[a]/2-o[a]/2;let p;switch(c){case"top":p={x:d,y:r.y-o.height};break;case"bottom":p={x:d,y:r.y+r.height};break;case"right":p={x:r.x+r.width,y:f};break;case"left":p={x:r.x-o.width,y:f};break;default:p={x:r.x,y:r.y}}switch(Ir(t)){case"start":p[i]-=m*(n&&l?-1:1);break;case"end":p[i]+=m*(n&&l?-1:1);break}return p}const hb=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=n,a=s.filter(Boolean),c=await(i.isRTL==null?void 0:i.isRTL(t));let l=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:d,y:f}=md(l,r,c),m=r,p={},v=0;for(let g=0;g<a.length;g++){const{name:x,fn:y}=a[g],{x:b,y:T,data:E,reset:S}=await y({x:d,y:f,initialPlacement:r,placement:m,strategy:o,middlewareData:p,rects:l,platform:i,elements:{reference:e,floating:t}});d=b??d,f=T??f,p={...p,[x]:{...p[x],...E}},S&&v<=50&&(v++,typeof S=="object"&&(S.placement&&(m=S.placement),S.rects&&(l=S.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):S.rects),{x:d,y:f}=md(l,m,c)),g=-1)}return{x:d,y:f,placement:m,strategy:o,middlewareData:p}};async function io(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:i,elements:a,strategy:c}=e,{boundary:l="clippingAncestors",rootBoundary:d="viewport",elementContext:f="floating",altBoundary:m=!1,padding:p=0}=An(t,e),v=hd(p),x=a[m?f==="floating"?"reference":"floating":f],y=is(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:l,rootBoundary:d,strategy:c})),b=f==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,T=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),E=await(s.isElement==null?void 0:s.isElement(T))?await(s.getScale==null?void 0:s.getScale(T))||{x:1,y:1}:{x:1,y:1},S=is(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:b,offsetParent:T,strategy:c}):b);return{top:(y.top-S.top+v.top)/E.y,bottom:(S.bottom-y.bottom+v.bottom)/E.y,left:(y.left-S.left+v.left)/E.x,right:(S.right-y.right+v.right)/E.x}}const mb=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:s,platform:i,elements:a,middlewareData:c}=t,{element:l,padding:d=0}=An(e,t)||{};if(l==null)return{};const f=hd(d),m={x:n,y:r},p=oa(o),v=ra(p),g=await i.getDimensions(l),x=p==="y",y=x?"top":"left",b=x?"bottom":"right",T=x?"clientHeight":"clientWidth",E=s.reference[v]+s.reference[p]-m[p]-s.floating[v],S=m[p]-s.reference[p],C=await(i.getOffsetParent==null?void 0:i.getOffsetParent(l));let k=C?C[T]:0;(!k||!await(i.isElement==null?void 0:i.isElement(C)))&&(k=a.floating[T]||s.floating[v]);const A=E/2-S/2,j=k/2-g[v]/2-1,L=Ln(f[y],j),B=Ln(f[b],j),K=L,J=k-g[v]-B,_=k/2-g[v]/2+A,Y=ta(K,_,J),q=!c.arrow&&Ir(o)!=null&&_!==Y&&s.reference[v]/2-(_<K?L:B)-g[v]/2<0,W=q?_<K?_-K:_-J:0;return{[p]:m[p]+W,data:{[p]:Y,centerOffset:_-Y-W,...q&&{alignmentOffset:W}},reset:q}}}),gb=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:c,elements:l}=t,{mainAxis:d=!0,crossAxis:f=!0,fallbackPlacements:m,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:v="none",flipAlignment:g=!0,...x}=An(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const y=Pn(o),b=bn(a),T=Pn(a)===a,E=await(c.isRTL==null?void 0:c.isRTL(l.floating)),S=m||(T||!g?[ss(a)]:lb(a)),C=v!=="none";!m&&C&&S.push(...fb(a,g,v,E));const k=[a,...S],A=await io(t,x),j=[];let L=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&j.push(A[y]),f){const _=ab(o,i,E);j.push(A[_[0]],A[_[1]])}if(L=[...L,{placement:o,overflows:j}],!j.every(_=>_<=0)){var B,K;const _=(((B=s.flip)==null?void 0:B.index)||0)+1,Y=k[_];if(Y&&(!(f==="alignment"?b!==bn(Y):!1)||L.every(D=>bn(D.placement)===b?D.overflows[0]>0:!0)))return{data:{index:_,overflows:L},reset:{placement:Y}};let q=(K=L.filter(W=>W.overflows[0]<=0).sort((W,D)=>W.overflows[1]-D.overflows[1])[0])==null?void 0:K.placement;if(!q)switch(p){case"bestFit":{var J;const W=(J=L.filter(D=>{if(C){const I=bn(D.placement);return I===b||I==="y"}return!0}).map(D=>[D.placement,D.overflows.filter(I=>I>0).reduce((I,G)=>I+G,0)]).sort((D,I)=>D[1]-I[1])[0])==null?void 0:J[0];W&&(q=W);break}case"initialPlacement":q=a;break}if(o!==q)return{reset:{placement:q}}}return{}}}};function gd(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function xd(e){return rb.some(t=>e[t]>=0)}const xb=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 io(t,{...o,elementContext:"reference"}),i=gd(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:xd(i)}}}case"escaped":{const s=await io(t,{...o,altBoundary:!0}),i=gd(s,n.floating);return{data:{escapedOffsets:i,escaped:xd(i)}}}default:return{}}}}},vd=new Set(["left","top"]);async function vb(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=Pn(n),a=Ir(n),c=bn(n)==="y",l=vd.has(i)?-1:1,d=s&&c?-1:1,f=An(t,e);let{mainAxis:m,crossAxis:p,alignmentAxis:v}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof v=="number"&&(p=a==="end"?v*-1:v),c?{x:p*d,y:m*l}:{x:m*l,y:p*d}}const wb=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,c=await vb(t,e);return i===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:o+c.x,y:s+c.y,data:{...c,placement:i}}}}},bb=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}}},...c}=An(e,t),l={x:n,y:r},d=await io(t,c),f=bn(Pn(o)),m=na(f);let p=l[m],v=l[f];if(s){const x=m==="y"?"top":"left",y=m==="y"?"bottom":"right",b=p+d[x],T=p-d[y];p=ta(b,p,T)}if(i){const x=f==="y"?"top":"left",y=f==="y"?"bottom":"right",b=v+d[x],T=v-d[y];v=ta(b,v,T)}const g=a.fn({...t,[m]:p,[f]:v});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[m]:s,[f]:i}}}}}},yb=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:c=!0,crossAxis:l=!0}=An(e,t),d={x:n,y:r},f=bn(o),m=na(f);let p=d[m],v=d[f];const g=An(a,t),x=typeof g=="number"?{mainAxis:g,crossAxis:0}:{mainAxis:0,crossAxis:0,...g};if(c){const T=m==="y"?"height":"width",E=s.reference[m]-s.floating[T]+x.mainAxis,S=s.reference[m]+s.reference[T]-x.mainAxis;p<E?p=E:p>S&&(p=S)}if(l){var y,b;const T=m==="y"?"width":"height",E=vd.has(Pn(o)),S=s.reference[f]-s.floating[T]+(E&&((y=i.offset)==null?void 0:y[f])||0)+(E?0:x.crossAxis),C=s.reference[f]+s.reference[T]+(E?0:((b=i.offset)==null?void 0:b[f])||0)-(E?x.crossAxis:0);v<S?v=S:v>C&&(v=C)}return{[m]:p,[f]:v}}}},Sb=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:c=()=>{},...l}=An(e,t),d=await io(t,l),f=Pn(o),m=Ir(o),p=bn(o)==="y",{width:v,height:g}=s.floating;let x,y;f==="top"||f==="bottom"?(x=f,y=m===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(y=f,x=m==="end"?"top":"bottom");const b=g-d.top-d.bottom,T=v-d.left-d.right,E=Ln(g-d[x],b),S=Ln(v-d[y],T),C=!t.middlewareData.shift;let k=E,A=S;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(A=T),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(k=b),C&&!m){const L=Xt(d.left,0),B=Xt(d.right,0),K=Xt(d.top,0),J=Xt(d.bottom,0);p?A=v-2*(L!==0||B!==0?L+B:Xt(d.left,d.right)):k=g-2*(K!==0||J!==0?K+J:Xt(d.top,d.bottom))}await c({...t,availableWidth:A,availableHeight:k});const j=await i.getDimensions(a.floating);return v!==j.width||g!==j.height?{reset:{rects:!0}}:{}}}};function as(){return typeof window<"u"}function Nr(e){return wd(e)?(e.nodeName||"").toLowerCase():"#document"}function Jt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function yn(e){var t;return(t=(wd(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function wd(e){return as()?e instanceof Node||e instanceof Jt(e).Node:!1}function un(e){return as()?e instanceof Element||e instanceof Jt(e).Element:!1}function Sn(e){return as()?e instanceof HTMLElement||e instanceof Jt(e).HTMLElement:!1}function bd(e){return!as()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Jt(e).ShadowRoot}const Cb=new Set(["inline","contents"]);function ao(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=dn(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!Cb.has(o)}const Tb=new Set(["table","td","th"]);function kb(e){return Tb.has(Nr(e))}const Eb=[":popover-open",":modal"];function ls(e){return Eb.some(t=>{try{return e.matches(t)}catch{return!1}})}const Ib=["transform","translate","scale","rotate","perspective"],Nb=["transform","translate","scale","rotate","perspective","filter"],Ab=["paint","layout","strict","content"];function ia(e){const t=aa(),n=un(e)?dn(e):e;return Ib.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)||Nb.some(r=>(n.willChange||"").includes(r))||Ab.some(r=>(n.contain||"").includes(r))}function Pb(e){let t=$n(e);for(;Sn(t)&&!Ar(t);){if(ia(t))return t;if(ls(t))return null;t=$n(t)}return null}function aa(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const jb=new Set(["html","body","#document"]);function Ar(e){return jb.has(Nr(e))}function dn(e){return Jt(e).getComputedStyle(e)}function cs(e){return un(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function $n(e){if(Nr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||bd(e)&&e.host||yn(e);return bd(t)?t.host:t}function yd(e){const t=$n(e);return Ar(t)?e.ownerDocument?e.ownerDocument.body:e.body:Sn(t)&&ao(t)?t:yd(t)}function lo(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=yd(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Jt(o);if(s){const a=la(i);return t.concat(i,i.visualViewport||[],ao(o)?o:[],a&&n?lo(a):[])}return t.concat(o,lo(o,[],n))}function la(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Sd(e){const t=dn(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=Sn(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=rs(n)!==s||rs(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function ca(e){return un(e)?e:e.contextElement}function Pr(e){const t=ca(e);if(!Sn(t))return wn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=Sd(t);let i=(s?rs(n.width):n.width)/r,a=(s?rs(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const _b=wn(0);function Cd(e){const t=Jt(e);return!aa()||!t.visualViewport?_b:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Rb(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Jt(e)?!1:t}function nr(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=ca(e);let i=wn(1);t&&(r?un(r)&&(i=Pr(r)):i=Pr(e));const a=Rb(s,n,r)?Cd(s):wn(0);let c=(o.left+a.x)/i.x,l=(o.top+a.y)/i.y,d=o.width/i.x,f=o.height/i.y;if(s){const m=Jt(s),p=r&&un(r)?Jt(r):r;let v=m,g=la(v);for(;g&&r&&p!==v;){const x=Pr(g),y=g.getBoundingClientRect(),b=dn(g),T=y.left+(g.clientLeft+parseFloat(b.paddingLeft))*x.x,E=y.top+(g.clientTop+parseFloat(b.paddingTop))*x.y;c*=x.x,l*=x.y,d*=x.x,f*=x.y,c+=T,l+=E,v=Jt(g),g=la(v)}}return is({width:d,height:f,x:c,y:l})}function us(e,t){const n=cs(e).scrollLeft;return t?t.left+n:nr(yn(e)).left+n}function Td(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-us(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function Mb(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=yn(r),a=t?ls(t.floating):!1;if(r===i||a&&s)return n;let c={scrollLeft:0,scrollTop:0},l=wn(1);const d=wn(0),f=Sn(r);if((f||!f&&!s)&&((Nr(r)!=="body"||ao(i))&&(c=cs(r)),Sn(r))){const p=nr(r);l=Pr(r),d.x=p.x+r.clientLeft,d.y=p.y+r.clientTop}const m=i&&!f&&!s?Td(i,c):wn(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+d.x+m.x,y:n.y*l.y-c.scrollTop*l.y+d.y+m.y}}function Ob(e){return Array.from(e.getClientRects())}function Db(e){const t=yn(e),n=cs(e),r=e.ownerDocument.body,o=Xt(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Xt(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+us(e);const a=-n.scrollTop;return dn(r).direction==="rtl"&&(i+=Xt(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const kd=25;function Lb(e,t){const n=Jt(e),r=yn(e),o=n.visualViewport;let s=r.clientWidth,i=r.clientHeight,a=0,c=0;if(o){s=o.width,i=o.height;const d=aa();(!d||d&&t==="fixed")&&(a=o.offsetLeft,c=o.offsetTop)}const l=us(r);if(l<=0){const d=r.ownerDocument,f=d.body,m=getComputedStyle(f),p=d.compatMode==="CSS1Compat"&&parseFloat(m.marginLeft)+parseFloat(m.marginRight)||0,v=Math.abs(r.clientWidth-f.clientWidth-p);v<=kd&&(s-=v)}else l<=kd&&(s+=l);return{width:s,height:i,x:a,y:c}}const $b=new Set(["absolute","fixed"]);function Fb(e,t){const n=nr(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=Sn(e)?Pr(e):wn(1),i=e.clientWidth*s.x,a=e.clientHeight*s.y,c=o*s.x,l=r*s.y;return{width:i,height:a,x:c,y:l}}function Ed(e,t,n){let r;if(t==="viewport")r=Lb(e,n);else if(t==="document")r=Db(yn(e));else if(un(t))r=Fb(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 is(r)}function Id(e,t){const n=$n(e);return n===t||!un(n)||Ar(n)?!1:dn(n).position==="fixed"||Id(n,t)}function Bb(e,t){const n=t.get(e);if(n)return n;let r=lo(e,[],!1).filter(a=>un(a)&&Nr(a)!=="body"),o=null;const s=dn(e).position==="fixed";let i=s?$n(e):e;for(;un(i)&&!Ar(i);){const a=dn(i),c=ia(i);!c&&a.position==="fixed"&&(o=null),(s?!c&&!o:!c&&a.position==="static"&&!!o&&$b.has(o.position)||ao(i)&&!c&&Id(e,i))?r=r.filter(d=>d!==i):o=a,i=$n(i)}return t.set(e,r),r}function zb(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?ls(t)?[]:Bb(t,this._c):[].concat(n),r],a=i[0],c=i.reduce((l,d)=>{const f=Ed(t,d,o);return l.top=Xt(f.top,l.top),l.right=Ln(f.right,l.right),l.bottom=Ln(f.bottom,l.bottom),l.left=Xt(f.left,l.left),l},Ed(t,a,o));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function Hb(e){const{width:t,height:n}=Sd(e);return{width:t,height:n}}function Ub(e,t,n){const r=Sn(t),o=yn(t),s=n==="fixed",i=nr(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const c=wn(0);function l(){c.x=us(o)}if(r||!r&&!s)if((Nr(t)!=="body"||ao(o))&&(a=cs(t)),r){const p=nr(t,!0,s,t);c.x=p.x+t.clientLeft,c.y=p.y+t.clientTop}else o&&l();s&&!r&&o&&l();const d=o&&!r&&!s?Td(o,a):wn(0),f=i.left+a.scrollLeft-c.x-d.x,m=i.top+a.scrollTop-c.y-d.y;return{x:f,y:m,width:i.width,height:i.height}}function ua(e){return dn(e).position==="static"}function Nd(e,t){if(!Sn(e)||dn(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return yn(e)===n&&(n=n.ownerDocument.body),n}function Ad(e,t){const n=Jt(e);if(ls(e))return n;if(!Sn(e)){let o=$n(e);for(;o&&!Ar(o);){if(un(o)&&!ua(o))return o;o=$n(o)}return n}let r=Nd(e,t);for(;r&&kb(r)&&ua(r);)r=Nd(r,t);return r&&Ar(r)&&ua(r)&&!ia(r)?n:r||Pb(e)||n}const Wb=async function(e){const t=this.getOffsetParent||Ad,n=this.getDimensions,r=await n(e.floating);return{reference:Ub(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Vb(e){return dn(e).direction==="rtl"}const Kb={convertOffsetParentRelativeRectToViewportRelativeRect:Mb,getDocumentElement:yn,getClippingRect:zb,getOffsetParent:Ad,getElementRects:Wb,getClientRects:Ob,getDimensions:Hb,getScale:Pr,isElement:un,isRTL:Vb};function Pd(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function qb(e,t){let n=null,r;const o=yn(e);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,c){a===void 0&&(a=!1),c===void 0&&(c=1),s();const l=e.getBoundingClientRect(),{left:d,top:f,width:m,height:p}=l;if(a||t(),!m||!p)return;const v=os(f),g=os(o.clientWidth-(d+m)),x=os(o.clientHeight-(f+p)),y=os(d),T={rootMargin:-v+"px "+-g+"px "+-x+"px "+-y+"px",threshold:Xt(0,Ln(1,c))||1};let E=!0;function S(C){const k=C[0].intersectionRatio;if(k!==c){if(!E)return i();k?i(!1,k):r=setTimeout(()=>{i(!1,1e-7)},1e3)}k===1&&!Pd(l,e.getBoundingClientRect())&&i(),E=!1}try{n=new IntersectionObserver(S,{...T,root:o.ownerDocument})}catch{n=new IntersectionObserver(S,T)}n.observe(e)}return i(!0),s}function Gb(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:c=!1}=r,l=ca(e),d=o||s?[...l?lo(l):[],...lo(t)]:[];d.forEach(y=>{o&&y.addEventListener("scroll",n,{passive:!0}),s&&y.addEventListener("resize",n)});const f=l&&a?qb(l,n):null;let m=-1,p=null;i&&(p=new ResizeObserver(y=>{let[b]=y;b&&b.target===l&&p&&(p.unobserve(t),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var T;(T=p)==null||T.observe(t)})),n()}),l&&!c&&p.observe(l),p.observe(t));let v,g=c?nr(e):null;c&&x();function x(){const y=nr(e);g&&!Pd(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)}),f==null||f(),(y=p)==null||y.disconnect(),p=null,c&&cancelAnimationFrame(v)}}const Yb=wb,Xb=bb,Jb=gb,Zb=Sb,Qb=xb,jd=mb,ey=yb,ty=(e,t,n)=>{const r=new Map,o={platform:Kb,...n},s={...o.platform,_c:r};return hb(e,t,{...o,platform:s})};var ny=typeof document<"u",ry=function(){},ds=ny?w.useLayoutEffect:ry;function fs(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(!fs(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)&&!fs(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function _d(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Rd(e,t){const n=_d(e);return Math.round(t*n)/n}function da(e){const t=h.useRef(e);return ds(()=>{t.current=e}),t}function oy(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:c,open:l}=e,[d,f]=h.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[m,p]=h.useState(r);fs(m,r)||p(r);const[v,g]=h.useState(null),[x,y]=h.useState(null),b=h.useCallback(D=>{D!==C.current&&(C.current=D,g(D))},[]),T=h.useCallback(D=>{D!==k.current&&(k.current=D,y(D))},[]),E=s||v,S=i||x,C=h.useRef(null),k=h.useRef(null),A=h.useRef(d),j=c!=null,L=da(c),B=da(o),K=da(l),J=h.useCallback(()=>{if(!C.current||!k.current)return;const D={placement:t,strategy:n,middleware:m};B.current&&(D.platform=B.current),ty(C.current,k.current,D).then(I=>{const G={...I,isPositioned:K.current!==!1};_.current&&!fs(A.current,G)&&(A.current=G,qr.flushSync(()=>{f(G)}))})},[m,t,n,B,K]);ds(()=>{l===!1&&A.current.isPositioned&&(A.current.isPositioned=!1,f(D=>({...D,isPositioned:!1})))},[l]);const _=h.useRef(!1);ds(()=>(_.current=!0,()=>{_.current=!1}),[]),ds(()=>{if(E&&(C.current=E),S&&(k.current=S),E&&S){if(L.current)return L.current(E,S,J);J()}},[E,S,J,L,j]);const Y=h.useMemo(()=>({reference:C,floating:k,setReference:b,setFloating:T}),[b,T]),q=h.useMemo(()=>({reference:E,floating:S}),[E,S]),W=h.useMemo(()=>{const D={position:n,left:0,top:0};if(!q.floating)return D;const I=Rd(q.floating,d.x),G=Rd(q.floating,d.y);return a?{...D,transform:"translate("+I+"px, "+G+"px)",..._d(q.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:I,top:G}},[n,a,q.floating,d.x,d.y]);return h.useMemo(()=>({...d,update:J,refs:Y,elements:q,floatingStyles:W}),[d,J,Y,q,W])}const sy=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?jd({element:r.current,padding:o}).fn(n):{}:r?jd({element:r,padding:o}).fn(n):{}}}},iy=(e,t)=>({...Yb(e),options:[e,t]}),ay=(e,t)=>({...Xb(e),options:[e,t]}),ly=(e,t)=>({...ey(e),options:[e,t]}),cy=(e,t)=>({...Jb(e),options:[e,t]}),uy=(e,t)=>({...Zb(e),options:[e,t]}),dy=(e,t)=>({...Qb(e),options:[e,t]}),fy=(e,t)=>({...sy(e),options:[e,t]});var py="Arrow",Md=h.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return u.jsx(pe.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"})})});Md.displayName=py;var hy=Md;function Od(e){const[t,n]=h.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 c=s.borderBoxSize,l=Array.isArray(c)?c[0]:c;i=l.inlineSize,a=l.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 fa="Popper",[Dd,jr]=cn(fa),[my,Ld]=Dd(fa),$d=e=>{const{__scopePopper:t,children:n}=e,[r,o]=h.useState(null);return u.jsx(my,{scope:t,anchor:r,onAnchorChange:o,children:n})};$d.displayName=fa;var Fd="PopperAnchor",Bd=h.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=Ld(Fd,n),i=h.useRef(null),a=je(t,i),c=h.useRef(null);return h.useEffect(()=>{const l=c.current;c.current=(r==null?void 0:r.current)||i.current,l!==c.current&&s.onAnchorChange(c.current)}),r?null:u.jsx(pe.div,{...o,ref:a})});Bd.displayName=Fd;var pa="PopperContent",[gy,xy]=Dd(pa),zd=h.forwardRef((e,t)=>{var O,P,U,Q,se,ie;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:a=0,avoidCollisions:c=!0,collisionBoundary:l=[],collisionPadding:d=0,sticky:f="partial",hideWhenDetached:m=!1,updatePositionStrategy:p="optimized",onPlaced:v,...g}=e,x=Ld(pa,n),[y,b]=h.useState(null),T=je(t,Se=>b(Se)),[E,S]=h.useState(null),C=Od(E),k=(C==null?void 0:C.width)??0,A=(C==null?void 0:C.height)??0,j=r+(s!=="center"?"-"+s:""),L=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},B=Array.isArray(l)?l:[l],K=B.length>0,J={padding:L,boundary:B.filter(wy),altBoundary:K},{refs:_,floatingStyles:Y,placement:q,isPositioned:W,middlewareData:D}=oy({strategy:"fixed",placement:j,whileElementsMounted:(...Se)=>Gb(...Se,{animationFrame:p==="always"}),elements:{reference:x.anchor},middleware:[iy({mainAxis:o+A,alignmentAxis:i}),c&&ay({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?ly():void 0,...J}),c&&cy({...J}),uy({...J,apply:({elements:Se,rects:xe,availableWidth:Re,availableHeight:Ve})=>{const{width:De,height:Ge}=xe.reference,He=Se.floating.style;He.setProperty("--radix-popper-available-width",`${Re}px`),He.setProperty("--radix-popper-available-height",`${Ve}px`),He.setProperty("--radix-popper-anchor-width",`${De}px`),He.setProperty("--radix-popper-anchor-height",`${Ge}px`)}}),E&&fy({element:E,padding:a}),by({arrowWidth:k,arrowHeight:A}),m&&dy({strategy:"referenceHidden",...J})]}),[I,G]=Wd(q),X=gt(v);kt(()=>{W&&(X==null||X())},[W,X]);const M=(O=D.arrow)==null?void 0:O.x,z=(P=D.arrow)==null?void 0:P.y,R=((U=D.arrow)==null?void 0:U.centerOffset)!==0,[F,H]=h.useState();return kt(()=>{y&&H(window.getComputedStyle(y).zIndex)},[y]),u.jsx("div",{ref:_.setFloating,"data-radix-popper-content-wrapper":"",style:{...Y,transform:W?Y.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:F,"--radix-popper-transform-origin":[(Q=D.transformOrigin)==null?void 0:Q.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(gy,{scope:n,placedSide:I,onArrowChange:S,arrowX:M,arrowY:z,shouldHideArrow:R,children:u.jsx(pe.div,{"data-side":I,"data-align":G,...g,ref:T,style:{...g.style,animation:W?void 0:"none"}})})})});zd.displayName=pa;var Hd="PopperArrow",vy={top:"bottom",right:"left",bottom:"top",left:"right"},Ud=h.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=xy(Hd,r),i=vy[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(hy,{...o,ref:n,style:{...o.style,display:"block"}})})});Ud.displayName=Hd;function wy(e){return e!==null}var by=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,c=i?0:e.arrowHeight,[l,d]=Wd(n),f={start:"0%",center:"50%",end:"100%"}[d],m=(((y=o.arrow)==null?void 0:y.x)??0)+a/2,p=(((b=o.arrow)==null?void 0:b.y)??0)+c/2;let v="",g="";return l==="bottom"?(v=i?f:`${m}px`,g=`${-c}px`):l==="top"?(v=i?f:`${m}px`,g=`${r.floating.height+c}px`):l==="right"?(v=`${-c}px`,g=i?f:`${p}px`):l==="left"&&(v=`${r.floating.width+c}px`,g=i?f:`${p}px`),{data:{x:v,y:g}}}});function Wd(e){const[t,n="center"]=e.split("-");return[t,n]}var ha=$d,ma=Bd,ga=zd,xa=Ud,yy="Portal",co=h.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=h.useState(!1);kt(()=>s(!0),[]);const i=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?Lo.createPortal(u.jsx(pe.div,{...r,ref:t}),i):null});co.displayName=yy;function Sy(e,t){return h.useReducer((n,r)=>t[n][r]??n,e)}var Ht=e=>{const{present:t,children:n}=e,r=Cy(t),o=typeof n=="function"?n({present:r.isPresent}):h.Children.only(n),s=je(r.ref,Ty(o));return typeof n=="function"||r.isPresent?h.cloneElement(o,{ref:s}):null};Ht.displayName="Presence";function Cy(e){const[t,n]=h.useState(),r=h.useRef(null),o=h.useRef(e),s=h.useRef("none"),i=e?"mounted":"unmounted",[a,c]=Sy(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return h.useEffect(()=>{const l=ps(r.current);s.current=a==="mounted"?l:"none"},[a]),kt(()=>{const l=r.current,d=o.current;if(d!==e){const m=s.current,p=ps(l);e?c("MOUNT"):p==="none"||(l==null?void 0:l.display)==="none"?c("UNMOUNT"):c(d&&m!==p?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,c]),kt(()=>{if(t){let l;const d=t.ownerDocument.defaultView??window,f=p=>{const g=ps(r.current).includes(CSS.escape(p.animationName));if(p.target===t&&g&&(c("ANIMATION_END"),!o.current)){const x=t.style.animationFillMode;t.style.animationFillMode="forwards",l=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=x)})}},m=p=>{p.target===t&&(s.current=ps(r.current))};return t.addEventListener("animationstart",m),t.addEventListener("animationcancel",f),t.addEventListener("animationend",f),()=>{d.clearTimeout(l),t.removeEventListener("animationstart",m),t.removeEventListener("animationcancel",f),t.removeEventListener("animationend",f)}}else c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:h.useCallback(l=>{r.current=l?getComputedStyle(l):null,n(l)},[])}}function ps(e){return(e==null?void 0:e.animationName)||"none"}function Ty(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 va="rovingFocusGroup.onEntryFocus",ky={bubbles:!1,cancelable:!0},uo="RovingFocusGroup",[wa,Vd,Ey]=es(uo),[Iy,Kd]=cn(uo,[Ey]),[Ny,Ay]=Iy(uo),qd=h.forwardRef((e,t)=>u.jsx(wa.Provider,{scope:e.__scopeRovingFocusGroup,children:u.jsx(wa.Slot,{scope:e.__scopeRovingFocusGroup,children:u.jsx(Py,{...e,ref:t})})}));qd.displayName=uo;var Py=h.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:c,onEntryFocus:l,preventScrollOnEntryFocus:d=!1,...f}=e,m=h.useRef(null),p=je(t,m),v=ts(s),[g,x]=On({prop:i,defaultProp:a??null,onChange:c,caller:uo}),[y,b]=h.useState(!1),T=gt(l),E=Vd(n),S=h.useRef(!1),[C,k]=h.useState(0);return h.useEffect(()=>{const A=m.current;if(A)return A.addEventListener(va,T),()=>A.removeEventListener(va,T)},[T]),u.jsx(Ny,{scope:n,orientation:r,dir:v,loop:o,currentTabStopId:g,onItemFocus:h.useCallback(A=>x(A),[x]),onItemShiftTab:h.useCallback(()=>b(!0),[]),onFocusableItemAdd:h.useCallback(()=>k(A=>A+1),[]),onFocusableItemRemove:h.useCallback(()=>k(A=>A-1),[]),children:u.jsx(pe.div,{tabIndex:y||C===0?-1:0,"data-orientation":r,...f,ref:p,style:{outline:"none",...e.style},onMouseDown:ae(e.onMouseDown,()=>{S.current=!0}),onFocus:ae(e.onFocus,A=>{const j=!S.current;if(A.target===A.currentTarget&&j&&!y){const L=new CustomEvent(va,ky);if(A.currentTarget.dispatchEvent(L),!L.defaultPrevented){const B=E().filter(q=>q.focusable),K=B.find(q=>q.active),J=B.find(q=>q.id===g),Y=[K,J,...B].filter(Boolean).map(q=>q.ref.current);Xd(Y,d)}}S.current=!1}),onBlur:ae(e.onBlur,()=>b(!1))})})}),Gd="RovingFocusGroupItem",Yd=h.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,c=_t(),l=s||c,d=Ay(Gd,n),f=d.currentTabStopId===l,m=Vd(n),{onFocusableItemAdd:p,onFocusableItemRemove:v,currentTabStopId:g}=d;return h.useEffect(()=>{if(r)return p(),()=>v()},[r,p,v]),u.jsx(wa.ItemSlot,{scope:n,id:l,focusable:r,active:o,children:u.jsx(pe.span,{tabIndex:f?0:-1,"data-orientation":d.orientation,...a,ref:t,onMouseDown:ae(e.onMouseDown,x=>{r?d.onItemFocus(l):x.preventDefault()}),onFocus:ae(e.onFocus,()=>d.onItemFocus(l)),onKeyDown:ae(e.onKeyDown,x=>{if(x.key==="Tab"&&x.shiftKey){d.onItemShiftTab();return}if(x.target!==x.currentTarget)return;const y=Ry(x,d.orientation,d.dir);if(y!==void 0){if(x.metaKey||x.ctrlKey||x.altKey||x.shiftKey)return;x.preventDefault();let T=m().filter(E=>E.focusable).map(E=>E.ref.current);if(y==="last")T.reverse();else if(y==="prev"||y==="next"){y==="prev"&&T.reverse();const E=T.indexOf(x.currentTarget);T=d.loop?My(T,E+1):T.slice(E+1)}setTimeout(()=>Xd(T))}}),children:typeof i=="function"?i({isCurrentTabStop:f,hasTabStop:g!=null}):i})})});Yd.displayName=Gd;var jy={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function _y(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Ry(e,t,n){const r=_y(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return jy[r]}function Xd(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function My(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Oy=qd,Dy=Yd,Ly=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},_r=new WeakMap,hs=new WeakMap,ms={},ba=0,Jd=function(e){return e&&(e.host||Jd(e.parentNode))},$y=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=Jd(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})},Fy=function(e,t,n,r){var o=$y(t,Array.isArray(e)?e:[e]);ms[n]||(ms[n]=new WeakMap);var s=ms[n],i=[],a=new Set,c=new Set(o),l=function(f){!f||a.has(f)||(a.add(f),l(f.parentNode))};o.forEach(l);var d=function(f){!f||c.has(f)||Array.prototype.forEach.call(f.children,function(m){if(a.has(m))d(m);else try{var p=m.getAttribute(r),v=p!==null&&p!=="false",g=(_r.get(m)||0)+1,x=(s.get(m)||0)+1;_r.set(m,g),s.set(m,x),i.push(m),g===1&&v&&hs.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(),ba++,function(){i.forEach(function(f){var m=_r.get(f)-1,p=s.get(f)-1;_r.set(f,m),s.set(f,p),m||(hs.has(f)||f.removeAttribute(r),hs.delete(f)),p||f.removeAttribute(n)}),ba--,ba||(_r=new WeakMap,_r=new WeakMap,hs=new WeakMap,ms={})}},ya=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=Ly(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),Fy(r,o,n,"aria-hidden")):function(){return null}},Cn=function(){return Cn=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},Cn.apply(this,arguments)};function Zd(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 By(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 gs="right-scroll-bar-position",xs="width-before-scroll-bar",zy="with-scroll-bars-hidden",Hy="--removed-body-scroll-bar-size";function Sa(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function Uy(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 Wy=typeof window<"u"?h.useLayoutEffect:h.useEffect,Qd=new WeakMap;function Vy(e,t){var n=Uy(null,function(r){return e.forEach(function(o){return Sa(o,r)})});return Wy(function(){var r=Qd.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||Sa(a,null)}),s.forEach(function(a){o.has(a)||Sa(a,i)})}Qd.set(n,e)},[e]),n}function Ky(e){return e}function qy(e,t){t===void 0&&(t=Ky);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 c=function(){var d=i;i=[],d.forEach(s)},l=function(){return Promise.resolve().then(c)};l(),n={push:function(d){i.push(d),l()},filter:function(d){return i=i.filter(d),n}}}};return o}function Gy(e){e===void 0&&(e={});var t=qy(null);return t.options=Cn({async:!0,ssr:!1},e),t}var ef=function(e){var t=e.sideCar,n=Zd(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,Cn({},n))};ef.isSideCarExport=!0;function Yy(e,t){return e.useMedium(t),ef}var tf=Gy(),Ca=function(){},vs=h.forwardRef(function(e,t){var n=h.useRef(null),r=h.useState({onScrollCapture:Ca,onWheelCapture:Ca,onTouchMoveCapture:Ca}),o=r[0],s=r[1],i=e.forwardProps,a=e.children,c=e.className,l=e.removeScrollBar,d=e.enabled,f=e.shards,m=e.sideCar,p=e.noRelative,v=e.noIsolation,g=e.inert,x=e.allowPinchZoom,y=e.as,b=y===void 0?"div":y,T=e.gapMode,E=Zd(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),S=m,C=Vy([n,t]),k=Cn(Cn({},E),o);return h.createElement(h.Fragment,null,d&&h.createElement(S,{sideCar:tf,removeScrollBar:l,shards:f,noRelative:p,noIsolation:v,inert:g,setCallbacks:s,allowPinchZoom:!!x,lockRef:n,gapMode:T}),i?h.cloneElement(h.Children.only(a),Cn(Cn({},k),{ref:C})):h.createElement(b,Cn({},k,{className:c,ref:C}),a))});vs.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},vs.classNames={fullWidth:xs,zeroRight:gs};var Xy=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Jy(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Xy();return t&&e.setAttribute("nonce",t),e}function Zy(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Qy(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var e0=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Jy())&&(Zy(t,n),Qy(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},t0=function(){var e=e0();return function(t,n){h.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},nf=function(){var e=t0(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},n0={left:0,top:0,right:0,gap:0},Ta=function(e){return parseInt(e||"",10)||0},r0=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[Ta(n),Ta(r),Ta(o)]},o0=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return n0;var t=r0(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])}},s0=nf(),Rr="data-scroll-locked",i0=function(e,t,n,r){var o=e.left,s=e.top,i=e.right,a=e.gap;return n===void 0&&(n="margin"),`
40
40
  .`.concat(zy,` {
41
41
  overflow: hidden `).concat(r,`;
42
42
  padding-right: `).concat(a,"px ").concat(r,`;
43
43
  }
44
- body[`).concat(Pr,`] {
44
+ body[`).concat(Rr,`] {
45
45
  overflow: hidden `).concat(r,`;
46
46
  overscroll-behavior: contain;
47
47
  `).concat([t&&"position: relative ".concat(r,";"),n==="margin"&&`
@@ -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(ms,` {
57
+ .`).concat(gs,` {
58
58
  right: `).concat(a,"px ").concat(r,`;
59
59
  }
60
60
 
61
- .`).concat(gs,` {
61
+ .`).concat(xs,` {
62
62
  margin-right: `).concat(a,"px ").concat(r,`;
63
63
  }
64
64
 
65
- .`).concat(ms," .").concat(ms,` {
65
+ .`).concat(gs," .").concat(gs,` {
66
66
  right: 0 `).concat(r,`;
67
67
  }
68
68
 
69
- .`).concat(gs," .").concat(gs,` {
69
+ .`).concat(xs," .").concat(xs,` {
70
70
  margin-right: 0 `).concat(r,`;
71
71
  }
72
72
 
73
- body[`).concat(Pr,`] {
73
+ body[`).concat(Rr,`] {
74
74
  `).concat(Hy,": ").concat(a,`px;
75
75
  }
76
- `)},qd=function(){var e=parseInt(document.body.getAttribute(Pr)||"0",10);return isFinite(e)?e:0},a0=function(){h.useEffect(function(){return document.body.setAttribute(Pr,(qd()+1).toString()),function(){var e=qd()-1;e<=0?document.body.removeAttribute(Pr):document.body.setAttribute(Pr,e.toString())}},[])},l0=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;a0();var s=h.useMemo(function(){return o0(o)},[o]);return h.createElement(s0,{styles:i0(s,!t,o,n?"":"!important")})},ya=!1;if(typeof window<"u")try{var vs=Object.defineProperty({},"passive",{get:function(){return ya=!0,!0}});window.addEventListener("test",vs,vs),window.removeEventListener("test",vs,vs)}catch{ya=!1}var _r=ya?{passive:!1}:!1,c0=function(e){return e.tagName==="TEXTAREA"},Gd=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!c0(e)&&n[t]==="visible")},u0=function(e){return Gd(e,"overflowY")},d0=function(e){return Gd(e,"overflowX")},Yd=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=Xd(e,r);if(o){var s=Jd(e,r),i=s[1],a=s[2];if(i>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},f0=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},p0=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},Xd=function(e,t){return e==="v"?u0(t):d0(t)},Jd=function(e,t){return e==="v"?f0(t):p0(t)},h0=function(e,t){return e==="h"&&t==="rtl"?-1:1},m0=function(e,t,n,r,o){var s=h0(e,window.getComputedStyle(t).direction),i=s*r,a=n.target,c=t.contains(a),l=!1,d=i>0,f=0,m=0;do{if(!a)break;var p=Jd(e,a),v=p[0],g=p[1],x=p[2],y=g-x-s*v;(v||y)&&Xd(e,a)&&(f+=y,m+=v);var b=a.parentNode;a=b&&b.nodeType===Node.DOCUMENT_FRAGMENT_NODE?b.host:b}while(!c&&a!==document.body||c&&(t.contains(a)||t===a));return(d&&Math.abs(f)<1||!d&&Math.abs(m)<1)&&(l=!0),l},ws=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Zd=function(e){return[e.deltaX,e.deltaY]},Qd=function(e){return e&&"current"in e?e.current:e},g0=function(e,t){return e[0]===t[0]&&e[1]===t[1]},x0=function(e){return`
76
+ `)},rf=function(){var e=parseInt(document.body.getAttribute(Rr)||"0",10);return isFinite(e)?e:0},a0=function(){h.useEffect(function(){return document.body.setAttribute(Rr,(rf()+1).toString()),function(){var e=rf()-1;e<=0?document.body.removeAttribute(Rr):document.body.setAttribute(Rr,e.toString())}},[])},l0=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;a0();var s=h.useMemo(function(){return o0(o)},[o]);return h.createElement(s0,{styles:i0(s,!t,o,n?"":"!important")})},ka=!1;if(typeof window<"u")try{var ws=Object.defineProperty({},"passive",{get:function(){return ka=!0,!0}});window.addEventListener("test",ws,ws),window.removeEventListener("test",ws,ws)}catch{ka=!1}var Mr=ka?{passive:!1}:!1,c0=function(e){return e.tagName==="TEXTAREA"},of=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!c0(e)&&n[t]==="visible")},u0=function(e){return of(e,"overflowY")},d0=function(e){return of(e,"overflowX")},sf=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=af(e,r);if(o){var s=lf(e,r),i=s[1],a=s[2];if(i>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},f0=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},p0=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},af=function(e,t){return e==="v"?u0(t):d0(t)},lf=function(e,t){return e==="v"?f0(t):p0(t)},h0=function(e,t){return e==="h"&&t==="rtl"?-1:1},m0=function(e,t,n,r,o){var s=h0(e,window.getComputedStyle(t).direction),i=s*r,a=n.target,c=t.contains(a),l=!1,d=i>0,f=0,m=0;do{if(!a)break;var p=lf(e,a),v=p[0],g=p[1],x=p[2],y=g-x-s*v;(v||y)&&af(e,a)&&(f+=y,m+=v);var b=a.parentNode;a=b&&b.nodeType===Node.DOCUMENT_FRAGMENT_NODE?b.host:b}while(!c&&a!==document.body||c&&(t.contains(a)||t===a));return(d&&Math.abs(f)<1||!d&&Math.abs(m)<1)&&(l=!0),l},bs=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},cf=function(e){return[e.deltaX,e.deltaY]},uf=function(e){return e&&"current"in e?e.current:e},g0=function(e,t){return e[0]===t[0]&&e[1]===t[1]},x0=function(e){return`
77
77
  .block-interactivity-`.concat(e,` {pointer-events: none;}
78
78
  .allow-interactivity-`).concat(e,` {pointer-events: all;}
79
- `)},v0=0,Rr=[];function w0(e){var t=h.useRef([]),n=h.useRef([0,0]),r=h.useRef(),o=h.useState(v0++)[0],s=h.useState(Kd)[0],i=h.useRef(e);h.useEffect(function(){i.current=e},[e]),h.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var g=By([e.lockRef.current],(e.shards||[]).map(Qd),!0).filter(Boolean);return g.forEach(function(x){return x.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),g.forEach(function(x){return x.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var a=h.useCallback(function(g,x){if("touches"in g&&g.touches.length===2||g.type==="wheel"&&g.ctrlKey)return!i.current.allowPinchZoom;var y=ws(g),b=n.current,T="deltaX"in g?g.deltaX:b[0]-y[0],E="deltaY"in g?g.deltaY:b[1]-y[1],S,C=g.target,k=Math.abs(T)>Math.abs(E)?"h":"v";if("touches"in g&&k==="h"&&C.type==="range")return!1;var A=Yd(k,C);if(!A)return!0;if(A?S=k:(S=k==="v"?"h":"v",A=Yd(k,C)),!A)return!1;if(!r.current&&"changedTouches"in g&&(T||E)&&(r.current=S),!S)return!0;var P=r.current||S;return m0(P,x,g,P==="h"?T:E)},[]),c=h.useCallback(function(g){var x=g;if(!(!Rr.length||Rr[Rr.length-1]!==s)){var y="deltaY"in x?Zd(x):ws(x),b=t.current.filter(function(S){return S.name===x.type&&(S.target===x.target||x.target===S.shadowParent)&&g0(S.delta,y)})[0];if(b&&b.should){x.cancelable&&x.preventDefault();return}if(!b){var T=(i.current.shards||[]).map(Qd).filter(Boolean).filter(function(S){return S.contains(x.target)}),E=T.length>0?a(x,T[0]):!i.current.noIsolation;E&&x.cancelable&&x.preventDefault()}}},[]),l=h.useCallback(function(g,x,y,b){var T={name:g,delta:x,target:y,should:b,shadowParent:b0(y)};t.current.push(T),setTimeout(function(){t.current=t.current.filter(function(E){return E!==T})},1)},[]),d=h.useCallback(function(g){n.current=ws(g),r.current=void 0},[]),f=h.useCallback(function(g){l(g.type,Zd(g),g.target,a(g,e.lockRef.current))},[]),m=h.useCallback(function(g){l(g.type,ws(g),g.target,a(g,e.lockRef.current))},[]);h.useEffect(function(){return Rr.push(s),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:m}),document.addEventListener("wheel",c,_r),document.addEventListener("touchmove",c,_r),document.addEventListener("touchstart",d,_r),function(){Rr=Rr.filter(function(g){return g!==s}),document.removeEventListener("wheel",c,_r),document.removeEventListener("touchmove",c,_r),document.removeEventListener("touchstart",d,_r)}},[]);var p=e.removeScrollBar,v=e.inert;return h.createElement(h.Fragment,null,v?h.createElement(s,{styles:x0(o)}):null,p?h.createElement(l0,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function b0(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const y0=Yy(Vd,w0);var bs=h.forwardRef(function(e,t){return h.createElement(xs,Cn({},e,{ref:t,sideCar:y0}))});bs.classNames=xs.classNames;var Sa=["Enter"," "],S0=["ArrowDown","PageUp","Home"],ef=["ArrowUp","PageDown","End"],C0=[...S0,...ef],T0={ltr:[...Sa,"ArrowRight"],rtl:[...Sa,"ArrowLeft"]},k0={ltr:["ArrowLeft"],rtl:["ArrowRight"]},fo="Menu",[po,E0,I0]=Qo(fo),[er,tf]=cn(fo,[I0,Ar,Dd]),ys=Ar(),nf=Dd(),[N0,tr]=er(fo),[A0,ho]=er(fo),rf=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=ys(t),[c,l]=h.useState(null),d=h.useRef(!1),f=gt(s),m=es(o);return h.useEffect(()=>{const p=()=>{d.current=!0,document.addEventListener("pointerdown",v,{capture:!0,once:!0}),document.addEventListener("pointermove",v,{capture:!0,once:!0})},v=()=>d.current=!1;return document.addEventListener("keydown",p,{capture:!0}),()=>{document.removeEventListener("keydown",p,{capture:!0}),document.removeEventListener("pointerdown",v,{capture:!0}),document.removeEventListener("pointermove",v,{capture:!0})}},[]),u.jsx(ua,{...a,children:u.jsx(N0,{scope:t,open:n,onOpenChange:f,content:c,onContentChange:l,children:u.jsx(A0,{scope:t,onClose:h.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:d,dir:m,modal:i,children:r})})})};rf.displayName=fo;var j0="MenuAnchor",Ca=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=ys(n);return u.jsx(da,{...o,...r,ref:t})});Ca.displayName=j0;var Ta="MenuPortal",[P0,of]=er(Ta,{forceMount:void 0}),sf=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=tr(Ta,t);return u.jsx(P0,{scope:t,forceMount:n,children:u.jsx(Ht,{present:n||s.open,children:u.jsx(co,{asChild:!0,container:o,children:r})})})};sf.displayName=Ta;var en="MenuContent",[_0,ka]=er(en),af=h.forwardRef((e,t)=>{const n=of(en,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=tr(en,e.__scopeMenu),i=ho(en,e.__scopeMenu);return u.jsx(po.Provider,{scope:e.__scopeMenu,children:u.jsx(Ht,{present:r||s.open,children:u.jsx(po.Slot,{scope:e.__scopeMenu,children:i.modal?u.jsx(R0,{...o,ref:t}):u.jsx(M0,{...o,ref:t})})})})}),R0=h.forwardRef((e,t)=>{const n=tr(en,e.__scopeMenu),r=h.useRef(null),o=Pe(t,r);return h.useEffect(()=>{const s=r.current;if(s)return xa(s)},[]),u.jsx(Ea,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:ae(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),M0=h.forwardRef((e,t)=>{const n=tr(en,e.__scopeMenu);return u.jsx(Ea,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),O0=qt.createSlot("MenuContent.ScrollLock"),Ea=h.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEntryFocus:c,onEscapeKeyDown:l,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:m,onDismiss:p,disableOutsideScroll:v,...g}=e,x=tr(en,n),y=ho(en,n),b=ys(n),T=nf(n),E=E0(n),[S,C]=h.useState(null),k=h.useRef(null),A=Pe(t,k,x.onContentChange),P=h.useRef(0),L=h.useRef(""),F=h.useRef(0),K=h.useRef(null),J=h.useRef("right"),_=h.useRef(0),Y=v?bs:h.Fragment,q=v?{as:O0,allowPinchZoom:!0}:void 0,W=I=>{var O,j;const G=L.current+I,X=E().filter(U=>!U.disabled),M=document.activeElement,B=(O=X.find(U=>U.ref.current===M))==null?void 0:O.textValue,R=X.map(U=>U.textValue),$=q0(R,G,B),z=(j=X.find(U=>U.textValue===$))==null?void 0:j.ref.current;(function U(Q){L.current=Q,window.clearTimeout(P.current),Q!==""&&(P.current=window.setTimeout(()=>U(""),1e3))})(G),z&&setTimeout(()=>z.focus())};h.useEffect(()=>()=>window.clearTimeout(P.current),[]),Gi();const D=h.useCallback(I=>{var X,M;return J.current===((X=K.current)==null?void 0:X.side)&&Y0(I,(M=K.current)==null?void 0:M.area)},[]);return u.jsx(_0,{scope:n,searchRef:L,onItemEnter:h.useCallback(I=>{D(I)&&I.preventDefault()},[D]),onItemLeave:h.useCallback(I=>{var G;D(I)||((G=k.current)==null||G.focus(),C(null))},[D]),onTriggerLeave:h.useCallback(I=>{D(I)&&I.preventDefault()},[D]),pointerGraceTimerRef:F,onPointerGraceIntentChange:h.useCallback(I=>{K.current=I},[]),children:u.jsx(Y,{...q,children:u.jsx(ts,{asChild:!0,trapped:o,onMountAutoFocus:ae(s,I=>{var G;I.preventDefault(),(G=k.current)==null||G.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:u.jsx(Tr,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:l,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:m,onDismiss:p,children:u.jsx(Oy,{asChild:!0,...T,dir:y.dir,orientation:"vertical",loop:r,currentTabStopId:S,onCurrentTabStopIdChange:C,onEntryFocus:ae(c,I=>{y.isUsingKeyboardRef.current||I.preventDefault()}),preventScrollOnEntryFocus:!0,children:u.jsx(fa,{role:"menu","aria-orientation":"vertical","data-state":Tf(x.open),"data-radix-menu-content":"",dir:y.dir,...b,...g,ref:A,style:{outline:"none",...g.style},onKeyDown:ae(g.onKeyDown,I=>{const X=I.target.closest("[data-radix-menu-content]")===I.currentTarget,M=I.ctrlKey||I.altKey||I.metaKey,B=I.key.length===1;X&&(I.key==="Tab"&&I.preventDefault(),!M&&B&&W(I.key));const R=k.current;if(I.target!==R||!C0.includes(I.key))return;I.preventDefault();const z=E().filter(O=>!O.disabled).map(O=>O.ref.current);ef.includes(I.key)&&z.reverse(),V0(z)}),onBlur:ae(e.onBlur,I=>{I.currentTarget.contains(I.target)||(window.clearTimeout(P.current),L.current="")}),onPointerMove:ae(e.onPointerMove,go(I=>{const G=I.target,X=_.current!==I.clientX;if(I.currentTarget.contains(G)&&X){const M=I.clientX>_.current?"right":"left";J.current=M,_.current=I.clientX}}))})})})})})})});af.displayName=en;var D0="MenuGroup",Ia=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(pe.div,{role:"group",...r,ref:t})});Ia.displayName=D0;var L0="MenuLabel",lf=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(pe.div,{...r,ref:t})});lf.displayName=L0;var Ss="MenuItem",cf="menu.itemSelect",Cs=h.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=h.useRef(null),i=ho(Ss,e.__scopeMenu),a=ka(Ss,e.__scopeMenu),c=Pe(t,s),l=h.useRef(!1),d=()=>{const f=s.current;if(!n&&f){const m=new CustomEvent(cf,{bubbles:!0,cancelable:!0});f.addEventListener(cf,p=>r==null?void 0:r(p),{once:!0}),Vi(f,m),m.defaultPrevented?l.current=!1:i.onClose()}};return u.jsx(uf,{...o,ref:c,disabled:n,onClick:ae(e.onClick,d),onPointerDown:f=>{var m;(m=e.onPointerDown)==null||m.call(e,f),l.current=!0},onPointerUp:ae(e.onPointerUp,f=>{var m;l.current||(m=f.currentTarget)==null||m.click()}),onKeyDown:ae(e.onKeyDown,f=>{const m=a.searchRef.current!=="";n||m&&f.key===" "||Sa.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});Cs.displayName=Ss;var uf=h.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=ka(Ss,n),a=nf(n),c=h.useRef(null),l=Pe(t,c),[d,f]=h.useState(!1),[m,p]=h.useState("");return h.useEffect(()=>{const v=c.current;v&&p((v.textContent??"").trim())},[s.children]),u.jsx(po.ItemSlot,{scope:n,disabled:r,textValue:o??m,children:u.jsx(Dy,{asChild:!0,...a,focusable:!r,children:u.jsx(pe.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:l,onPointerMove:ae(e.onPointerMove,go(v=>{r?i.onItemLeave(v):(i.onItemEnter(v),v.defaultPrevented||v.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:ae(e.onPointerLeave,go(v=>i.onItemLeave(v))),onFocus:ae(e.onFocus,()=>f(!0)),onBlur:ae(e.onBlur,()=>f(!1))})})})}),$0="MenuCheckboxItem",df=h.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return u.jsx(gf,{scope:e.__scopeMenu,checked:n,children:u.jsx(Cs,{role:"menuitemcheckbox","aria-checked":Ts(n)?"mixed":n,...o,ref:t,"data-state":Aa(n),onSelect:ae(o.onSelect,()=>r==null?void 0:r(Ts(n)?!0:!n),{checkForDefaultPrevented:!1})})})});df.displayName=$0;var ff="MenuRadioGroup",[F0,B0]=er(ff,{value:void 0,onValueChange:()=>{}}),pf=h.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=gt(r);return u.jsx(F0,{scope:e.__scopeMenu,value:n,onValueChange:s,children:u.jsx(Ia,{...o,ref:t})})});pf.displayName=ff;var hf="MenuRadioItem",mf=h.forwardRef((e,t)=>{const{value:n,...r}=e,o=B0(hf,e.__scopeMenu),s=n===o.value;return u.jsx(gf,{scope:e.__scopeMenu,checked:s,children:u.jsx(Cs,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":Aa(s),onSelect:ae(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});mf.displayName=hf;var Na="MenuItemIndicator",[gf,z0]=er(Na,{checked:!1}),xf=h.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=z0(Na,n);return u.jsx(Ht,{present:r||Ts(s.checked)||s.checked===!0,children:u.jsx(pe.span,{...o,ref:t,"data-state":Aa(s.checked)})})});xf.displayName=Na;var H0="MenuSeparator",vf=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(pe.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});vf.displayName=H0;var U0="MenuArrow",wf=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=ys(n);return u.jsx(pa,{...o,...r,ref:t})});wf.displayName=U0;var W0="MenuSub",[FN,bf]=er(W0),mo="MenuSubTrigger",yf=h.forwardRef((e,t)=>{const n=tr(mo,e.__scopeMenu),r=ho(mo,e.__scopeMenu),o=bf(mo,e.__scopeMenu),s=ka(mo,e.__scopeMenu),i=h.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:c}=s,l={__scopeMenu:e.__scopeMenu},d=h.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return h.useEffect(()=>d,[d]),h.useEffect(()=>{const f=a.current;return()=>{window.clearTimeout(f),c(null)}},[a,c]),u.jsx(Ca,{asChild:!0,...l,children:u.jsx(uf,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":Tf(n.open),...e,ref:Mn(t,o.onTriggerChange),onClick:f=>{var m;(m=e.onClick)==null||m.call(e,f),!(e.disabled||f.defaultPrevented)&&(f.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:ae(e.onPointerMove,go(f=>{s.onItemEnter(f),!f.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(s.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),d()},100))})),onPointerLeave:ae(e.onPointerLeave,go(f=>{var p,v;d();const m=(p=n.content)==null?void 0:p.getBoundingClientRect();if(m){const g=(v=n.content)==null?void 0:v.dataset.side,x=g==="right",y=x?-5:5,b=m[x?"left":"right"],T=m[x?"right":"left"];s.onPointerGraceIntentChange({area:[{x:f.clientX+y,y:f.clientY},{x:b,y:m.top},{x:T,y:m.top},{x:T,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(f),f.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:ae(e.onKeyDown,f=>{var p;const m=s.searchRef.current!=="";e.disabled||m&&f.key===" "||T0[r.dir].includes(f.key)&&(n.onOpenChange(!0),(p=n.content)==null||p.focus(),f.preventDefault())})})})});yf.displayName=mo;var Sf="MenuSubContent",Cf=h.forwardRef((e,t)=>{const n=of(en,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=tr(en,e.__scopeMenu),i=ho(en,e.__scopeMenu),a=bf(Sf,e.__scopeMenu),c=h.useRef(null),l=Pe(t,c);return u.jsx(po.Provider,{scope:e.__scopeMenu,children:u.jsx(Ht,{present:r||s.open,children:u.jsx(po.Slot,{scope:e.__scopeMenu,children:u.jsx(Ea,{id:a.contentId,"aria-labelledby":a.triggerId,...o,ref:l,align:"start",side:i.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:d=>{var f;i.isUsingKeyboardRef.current&&((f=c.current)==null||f.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 p;const f=d.currentTarget.contains(d.target),m=k0[i.dir].includes(d.key);f&&m&&(s.onOpenChange(!1),(p=a.trigger)==null||p.focus(),d.preventDefault())})})})})})});Cf.displayName=Sf;function Tf(e){return e?"open":"closed"}function Ts(e){return e==="indeterminate"}function Aa(e){return Ts(e)?"indeterminate":e?"checked":"unchecked"}function V0(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function K0(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function q0(e,t,n){const o=t.length>1&&Array.from(t).every(l=>l===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=K0(e,Math.max(s,0));o.length===1&&(i=i.filter(l=>l!==n));const c=i.find(l=>l.toLowerCase().startsWith(o.toLowerCase()));return c!==n?c:void 0}function G0(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],c=t[i],l=a.x,d=a.y,f=c.x,m=c.y;d>r!=m>r&&n<(f-l)*(r-d)/(m-d)+l&&(o=!o)}return o}function Y0(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return G0(n,t)}function go(e){return t=>t.pointerType==="mouse"?e(t):void 0}var X0=rf,J0=Ca,Z0=sf,Q0=af,eS=Ia,tS=lf,nS=Cs,rS=df,oS=pf,sS=mf,iS=xf,aS=vf,lS=wf,cS=yf,uS=Cf,ks="DropdownMenu",[dS,BN]=cn(ks,[tf]),Lt=tf(),[fS,kf]=dS(ks),Ef=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,c=Lt(t),l=h.useRef(null),[d,f]=On({prop:o,defaultProp:s??!1,onChange:i,caller:ks});return u.jsx(fS,{scope:t,triggerId:_t(),triggerRef:l,contentId:_t(),open:d,onOpenChange:f,onOpenToggle:h.useCallback(()=>f(m=>!m),[f]),modal:a,children:u.jsx(X0,{...c,open:d,onOpenChange:f,dir:r,modal:a,children:n})})};Ef.displayName=ks;var If="DropdownMenuTrigger",Nf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=kf(If,n),i=Lt(n);return u.jsx(J0,{asChild:!0,...i,children:u.jsx(pe.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())})})})});Nf.displayName=If;var pS="DropdownMenuPortal",Af=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Lt(t);return u.jsx(Z0,{...r,...n})};Af.displayName=pS;var jf="DropdownMenuContent",Pf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=kf(jf,n),s=Lt(n),i=h.useRef(!1);return u.jsx(Q0,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:ae(e.onCloseAutoFocus,a=>{var c;i.current||(c=o.triggerRef.current)==null||c.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:ae(e.onInteractOutside,a=>{const c=a.detail.originalEvent,l=c.button===0&&c.ctrlKey===!0,d=c.button===2||l;(!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)"}})});Pf.displayName=jf;var hS="DropdownMenuGroup",mS=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Lt(n);return u.jsx(eS,{...o,...r,ref:t})});mS.displayName=hS;var gS="DropdownMenuLabel",_f=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Lt(n);return u.jsx(tS,{...o,...r,ref:t})});_f.displayName=gS;var xS="DropdownMenuItem",Rf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Lt(n);return u.jsx(nS,{...o,...r,ref:t})});Rf.displayName=xS;var vS="DropdownMenuCheckboxItem",Mf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Lt(n);return u.jsx(rS,{...o,...r,ref:t})});Mf.displayName=vS;var wS="DropdownMenuRadioGroup",bS=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Lt(n);return u.jsx(oS,{...o,...r,ref:t})});bS.displayName=wS;var yS="DropdownMenuRadioItem",Of=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Lt(n);return u.jsx(sS,{...o,...r,ref:t})});Of.displayName=yS;var SS="DropdownMenuItemIndicator",Df=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Lt(n);return u.jsx(iS,{...o,...r,ref:t})});Df.displayName=SS;var CS="DropdownMenuSeparator",Lf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Lt(n);return u.jsx(aS,{...o,...r,ref:t})});Lf.displayName=CS;var TS="DropdownMenuArrow",kS=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Lt(n);return u.jsx(lS,{...o,...r,ref:t})});kS.displayName=TS;var ES="DropdownMenuSubTrigger",$f=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Lt(n);return u.jsx(cS,{...o,...r,ref:t})});$f.displayName=ES;var IS="DropdownMenuSubContent",Ff=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Lt(n);return u.jsx(uS,{...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)"}})});Ff.displayName=IS;var NS=Ef,AS=Nf,jS=Af,Bf=Pf,zf=_f,Hf=Rf,Uf=Mf,Wf=Of,Vf=Df,Kf=Lf,qf=$f,Gf=Ff;const Es=NS,Is=AS,PS=h.forwardRef(({className:e,inset:t,children:n,...r},o)=>u.jsxs(qf,{ref:o,className:ne("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",t&&"pl-8",e),...r,children:[n,u.jsx(le.ChevronRight,{className:"ml-auto h-4 w-4"})]}));PS.displayName=qf.displayName;const _S=h.forwardRef(({className:e,...t},n)=>u.jsx(Gf,{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}));_S.displayName=Gf.displayName;const xo=h.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(jS,{children:u.jsx(Bf,{ref:r,sideOffset:t,className:ne("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n})}));xo.displayName=Bf.displayName;const Fn=h.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(Hf,{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=Hf.displayName;const RS=h.forwardRef(({className:e,children:t,checked:n,...r},o)=>u.jsxs(Uf,{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(Vf,{children:u.jsx(le.Check,{className:"h-4 w-4"})})}),t]}));RS.displayName=Uf.displayName;const MS=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Wf,{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(Vf,{children:u.jsx(le.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));MS.displayName=Wf.displayName;const OS=h.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(zf,{ref:r,className:ne("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));OS.displayName=zf.displayName;const DS=h.forwardRef(({className:e,...t},n)=>u.jsx(Kf,{ref:n,className:ne("-mx-1 my-1 h-px bg-muted",e),...t}));DS.displayName=Kf.displayName;const ja=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}));ja.displayName="Textarea";const LS=1e4;function Yf({initialValue:e="",editingMessageId:t=null,placeholder:n="Type your message...",isStreaming:r=!1,disabled:o=!1,maxLength:s=LS,value:i,onValueChange:a,onSend:c,onCancelEdit:l,onStop:d,className:f="",textareaClassName:m="",allowEmptySend:p=!1,sendButtonClassName:v,validate:g,onValidationError:x}){const y=i!==void 0,[b,T]=w.useState(e),E=(y?i:b)??"",[S,C]=w.useTransition(),k=w.useRef(null),A=w.useRef(0),P=w.useRef(null),L=w.useRef("");w.useEffect(()=>{y||(T(e??""),P.current=null,k.current&&(k.current.style.height="auto",k.current.style.height=`${k.current.scrollHeight}px`))},[e,t,y]);const[F,K]=w.useState(null),J=w.useCallback(R=>R.length>s?`Message too long (${R.length}/${s} characters)`:null,[s]),_=w.useMemo(()=>g??J,[g,J]),Y=w.useCallback(R=>{const $=_(R);return K($),x==null||x($),L.current=R,$},[_,x]),q=w.useCallback(()=>{const R=k.current;R&&(R.style.height="auto",R.style.height=`${R.scrollHeight}px`)},[]);w.useEffect(()=>{q()},[q,E]),w.useEffect(()=>{if(!F)return;const R=(E??"").trim();L.current!==R&&Y(R)},[E,F,Y]);const W=w.useCallback((R,{fromUser:$})=>{y||T(R),$&&(a==null||a(R))},[y,a]),D=w.useCallback(async R=>{R&&R.preventDefault();const $=(E??"").trim();if(!$&&!p||Y($))return;const z=++A.current;P.current={id:z,shouldClear:!0},C(()=>{var O,j,U;try{const Q=c($);Q&&typeof Q.then=="function"?Q.then(()=>{var se,ie;((se=P.current)==null?void 0:se.id)===z&&P.current.shouldClear&&(y||(T(""),k.current&&(k.current.style.height="auto"),a==null||a(""))),((ie=P.current)==null?void 0:ie.id)===z&&(P.current=null)}).catch(()=>{var se;((se=P.current)==null?void 0:se.id)===z&&(P.current=null)}):(((O=P.current)==null?void 0:O.id)===z&&P.current.shouldClear&&(y||(T(""),k.current&&(k.current.style.height="auto"),a==null||a(""))),((j=P.current)==null?void 0:j.id)===z&&(P.current=null))}catch{((U=P.current)==null?void 0:U.id)===z&&(P.current=null)}})},[E,c,p,y,a,Y]),I=w.useCallback(R=>{const $=R.target.value;W($,{fromUser:!0}),P.current&&(P.current.shouldClear=!1),k.current&&(k.current.style.height="auto",k.current.style.height=`${k.current.scrollHeight}px`),F&&Y($.trim())},[W,Y,F]),G=w.useCallback(R=>{R.key==="Enter"&&!R.shiftKey?(R.preventDefault(),D()):R.key==="Escape"&&t&&(R.preventDefault(),l==null||l())},[D,t,l]),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:R=>void D(R),className:`w-full ${f}`,children:u.jsxs("div",{className:"flex items-end gap-2",children:[u.jsxs("div",{className:"flex-1",children:[u.jsx(ja,{ref:k,value:E,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(Je,{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(Je,{type:"submit",size:"icon",className:`shrink-0 ${v??""}`,title:t?"Save changes":"Send message",disabled:o||!E.trim()&&!p||S,children:u.jsx(le.Send,{size:16})})})]})})}const $S=w.memo(Yf);function Xf({composerValue:e,onComposerChange:t,onSend:n,onCancelEdit:r,onStop:o,editingMessageId:s=null,editingInitialValue:i="",placeholder:a="Type your message...",isStreaming:c=!1,disabled:l=!1,textareaClassName:d="",customStyles:f={},enableFileUpload:m=!1,enableExcelUpload:p=!1,onExcelUpload:v,onError:g,allowEmptySend:x=!1,inputError:y=null}){const[b,T]=w.useState([]),E=w.useRef(null),S=w.useRef(null),[C,k]=w.useState(0),[A,P]=w.useState(0),[L,F]=w.useState(!1),[K,J]=w.useState(null),[_,Y]=w.useState(null),q=w.useCallback(()=>{E.current&&(E.current.value=""),S.current&&(S.current.value=""),k(R=>R+1),P(R=>R+1)},[]),W=w.useCallback(R=>{T($=>[...$,...R])},[]),D=w.useCallback(R=>{const $=Array.from(R.target.files||[]);W($),R.target.value=""},[W]),I=w.useCallback(R=>{T($=>{const z=$.filter((O,j)=>j!==R);return z.length===0&&q(),z})},[q]),G=w.useCallback(async R=>{const $=(R.target.files||[])[0];if($&&(J(null),Y(null),!!v)){F(!0);try{await v($),J(`Uploaded ${$.name} - processing through chat stream`)}catch(z){const O=z instanceof Error?z.message:"Failed to upload Excel file";Y(O),g==null||g(O)}finally{F(!1),R.target.value="",q()}}},[v,g,q]),X=w.useMemo(()=>x||b.length>0,[x,b]),M=w.useCallback(async R=>{const z=await n(R,b);return b.length>0&&(T([]),q()),z},[n,q,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":""} ${f.textarea||""} ${d}`;return u.jsxs(u.Fragment,{children:[(m||p)&&u.jsxs("div",{className:"mb-3 space-y-3",children:[m&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:E,type:"file",multiple:!0,onChange:D,className:"hidden"},C),b.length>0&&u.jsx("div",{className:"flex flex-wrap gap-2",children:b.map((R,$)=>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:R.name}),u.jsx(Je,{variant:"ghost",size:"sm",onClick:()=>I($),className:"h-4 w-4 p-0 text-gray-500 dark:text-gray-400 hover:text-red-500 dark:hover:text-red-400","aria-label":`Remove ${R.name}`,children:u.jsx(le.X,{size:12})})]},$))})]}),p&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:S,type:"file",accept:".xls,.xlsx,.xlsm",onChange:G,className:"hidden"},A),L&&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..."]}),K&&!L&&u.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:K}),_&&!L&&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||p)&&u.jsxs(Es,{children:[u.jsx(Is,{asChild:!0,children:u.jsx(Je,{type:"button",size:"icon",variant:"outline",disabled:c||l,title:"More input actions",className:f.moreButton||"",children:u.jsx(le.Plus,{size:16})})}),u.jsxs(xo,{align:"start",sideOffset:6,className:"w-52",children:[m&&u.jsxs(Fn,{onClick:()=>{var R;return(R=E.current)==null?void 0:R.click()},className:"cursor-pointer",children:[u.jsx(le.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),p&&u.jsxs(Fn,{onClick:()=>{var R;L||(R=S.current)==null||R.click()},className:`cursor-pointer ${L?"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($S,{initialValue:i,editingMessageId:s,value:e,onValueChange:t,placeholder:s?"Edit your message...":a,isStreaming:c,disabled:l,onSend:M,onCancelEdit:r,onStop:o,allowEmptySend:X,textareaClassName:B,sendButtonClassName:f.sendButton})})]})]})}const FS=w.memo(Xf),Ns=0,Bn=1,Mr=2,Jf=4;function Zf(e){return()=>e}function BS(e){e()}function Qf(e,t){return n=>e(t(n))}function ep(e,t){return()=>e(t)}function zS(e,t){return n=>e(t,n)}function Pa(e){return e!==void 0}function HS(...e){return()=>{e.map(BS)}}function Or(){}function As(e,t){return t(e),e}function US(e,t){return t(e)}function st(...e){return e}function Ze(e,t){return e(Bn,t)}function Ne(e,t){e(Ns,t)}function _a(e){e(Mr)}function xt(e){return e(Jf)}function he(e,t){return Ze(e,zS(t,Ns))}function fn(e,t){const n=e(Bn,r=>{n(),t(r)});return n}function tp(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function np(e,t){return e===t}function it(e=np){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function ye(e){return t=>n=>{e(n)&&t(n)}}function ce(e){return t=>Qf(t,e)}function Tn(e){return t=>()=>{t(e)}}function ee(e,...t){const n=WS(...t);return(r,o)=>{switch(r){case Mr:_a(e);return;case Bn:return Ze(e,n(o))}}}function kn(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 _e(...e){const t=new Array(e.length);let n=0,r=null;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const a=Math.pow(2,i);Ze(s,c=>{const l=n;n=n|a,t[i]=c,l!==o&&n===o&&r&&(r(),r=null)})}),s=>i=>{const a=()=>{s([i].concat(t))};n===o?a():r=a}}function WS(...e){return t=>e.reduceRight(US,t)}function VS(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(),Or);case Mr:r(),n=null;return}}}function oe(e){let t=e;const n=ze();return(r,o)=>{switch(r){case Ns:t=o;break;case Bn:{o(t);break}case Jf:return t}return n(r,o)}}function Rt(e,t){return As(oe(t),n=>he(e,n))}function ze(){const e=[];return(t,n)=>{switch(t){case Ns:e.slice().forEach(r=>{r(n)});return;case Mr:e.splice(0,e.length);return;case Bn:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}}}function Zt(e){return As(ze(),t=>he(e,t))}function qe(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:KS(),singleton:n}}const KS=()=>Symbol();function qS(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(c=>n(c)));return i&&t.set(s,a),a};return n(e)}function wt(...e){const t=ze(),n=new Array(e.length);let r=0;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const a=Math.pow(2,i);Ze(s,c=>{n[i]=c,r=r|a,r===o&&Ne(t,n)})}),function(s,i){switch(s){case Mr:{_a(t);return}case Bn:return r===o&&i(n),Ze(t,i)}}}function be(e,t=np){return ee(e,it(t))}function Ra(...e){return function(t,n){switch(t){case Mr:return;case Bn:return HS(...e.map(r=>Ze(r,n)))}}}var Ut=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(Ut||{});const GS={0:"debug",3:"error",1:"log",2:"warn"},YS=()=>typeof globalThis>"u"?window:globalThis,zn=qe(()=>{const e=oe(3);return{log:oe((t,n,r=1)=>{var o;const s=(o=YS().VIRTUOSO_LOG_LEVEL)!=null?o:xt(e);r>=s&&console[GS[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 Ma(e,t,n).callbackRef}function Ma(e,t,n){const r=w.useRef(null);let o=i=>{};const s=w.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(i=>{const a=()=>{const c=i[0].target;c.offsetParent!==null&&e(c)};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 XS(e,t,n,r,o,s,i,a,c){const l=w.useCallback(d=>{const f=JS(d.children,t,a?"offsetWidth":"offsetHeight",o);let m=d.parentElement;for(;!m.dataset.virtuosoScroller;)m=m.parentElement;const p=m.lastElementChild.dataset.viewportType==="window";let v;p&&(v=m.ownerDocument.defaultView);const g=i?a?i.scrollLeft:i.scrollTop:p?a?v.scrollX||v.document.documentElement.scrollLeft:v.scrollY||v.document.documentElement.scrollTop:a?m.scrollLeft:m.scrollTop,x=i?a?i.scrollWidth:i.scrollHeight:p?a?v.document.documentElement.scrollWidth:v.document.documentElement.scrollHeight:a?m.scrollWidth:m.scrollHeight,y=i?a?i.offsetWidth:i.offsetHeight:p?a?v.innerWidth:v.innerHeight:a?m.offsetWidth:m.offsetHeight;r({scrollHeight:x,scrollTop:Math.max(g,0),viewportHeight:y}),s==null||s(a?rp("column-gap",getComputedStyle(d).columnGap,o):rp("row-gap",getComputedStyle(d).rowGap,o)),f!==null&&e(f)},[e,t,o,s,i,r,a]);return Ma(l,n,c)}function JS(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 c=parseInt(a.dataset.index),l=parseFloat(a.dataset.knownSize),d=t(a,n);if(d===0&&r("Zero-sized element, this should not happen",{child:a},Ut.ERROR),d===l)continue;const f=s[s.length-1];s.length===0||f.size!==d||f.endIndex!==c-1?s.push({endIndex:c,size:d,startIndex:c}):s[s.length-1].endIndex++}return s}function rp(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Ut.WARN),t==="normal"?0:parseInt(t??"0",10)}function op(e,t,n){const r=w.useRef(null),o=w.useCallback(c=>{if(!(c!=null&&c.offsetParent))return;const l=c.getBoundingClientRect(),d=l.width;let f,m;if(t){const p=t.getBoundingClientRect(),v=l.top-p.top;m=p.height-Math.max(0,v),f=v+t.scrollTop}else{const p=i.current.ownerDocument.defaultView;m=p.innerHeight-Math.max(0,l.top),f=l.top+p.scrollY}r.current={offsetTop:f,visibleHeight:m,visibleWidth:d},e(r.current)},[e,t]),{callbackRef:s,ref:i}=Ma(o,!0,n),a=w.useCallback(()=>{o(i.current)},[o,i]);return w.useEffect(()=>{var c;if(t){t.addEventListener("scroll",a);const l=new ResizeObserver(()=>{requestAnimationFrame(a)});return l.observe(t),()=>{t.removeEventListener("scroll",a),l.unobserve(t)}}else{const l=(c=i.current)==null?void 0:c.ownerDocument.defaultView;return l==null||l.addEventListener("scroll",a),l==null||l.addEventListener("resize",a),()=>{l==null||l.removeEventListener("scroll",a),l==null||l.removeEventListener("resize",a)}}},[a,t,i]),s}const $t=qe(()=>{const e=ze(),t=ze(),n=oe(0),r=ze(),o=oe(0),s=ze(),i=ze(),a=oe(0),c=oe(0),l=oe(0),d=oe(0),f=ze(),m=ze(),p=oe(!1),v=oe(!1),g=oe(!1);return he(ee(e,ce(({scrollTop:x})=>x)),t),he(ee(e,ce(({scrollHeight:x})=>x)),i),he(t,o),{deviation:n,fixedFooterHeight:l,fixedHeaderHeight:c,footerHeight:d,headerHeight:a,horizontalDirection:v,scrollBy:m,scrollContainerState:e,scrollHeight:i,scrollingInProgress:p,scrollTo:f,scrollTop:t,skipAnimationFrameInResizeObserver:g,smoothScrollTargetReached:r,statefulScrollTop:o,viewportHeight:s}},[],{singleton:!0}),vo={lvl:0};function sp(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:c}=t(e[i]);s.push({end:a-1,start:r,value:o}),r=a,o=c}return s.push({end:1/0,start:r,value:o}),s}function et(e){return e===vo}function wo(e,t){if(!et(e))return t===e.k?e.v:t<e.k?wo(e.l,t):wo(e.r,t)}function pn(e,t,n="k"){if(et(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){const r=pn(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return pn(e.l,t,n)}function Qt(e,t,n){return et(e)?lp(t,n,1):t===e.k?St(e,{k:t,v:n}):t<e.k?cp(St(e,{l:Qt(e.l,t,n)})):cp(St(e,{r:Qt(e.r,t,n)}))}function Dr(){return vo}function js(e,t,n){if(et(e))return[];const r=pn(e,t)[0];return ZS(Da(e,r,n))}function Oa(e,t){if(et(e))return vo;const{k:n,l:r,r:o}=e;if(t===n){if(et(r))return o;if(et(o))return r;{const[s,i]=ap(r);return Ps(St(e,{k:s,l:ip(r),v:i}))}}else return t<n?Ps(St(e,{l:Oa(r,t)})):Ps(St(e,{r:Oa(o,t)}))}function or(e){return et(e)?[]:[...or(e.l),{k:e.k,v:e.v},...or(e.r)]}function Da(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(Da(o,t,n))),r>=t&&r<=n&&a.push({k:r,v:i}),r<=n&&(a=a.concat(Da(s,t,n))),a}function Ps(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(La(t))return up(St(e,{lvl:n-1}));if(!et(t)&&!et(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(La(e))return $a(St(e,{lvl:n-1}));if(!et(r)&&!et(r.l)){const o=r.l,s=La(o)?r.lvl-1:r.lvl;return St(o,{l:St(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:$a(St(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function St(e,t){return lp(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 ip(e){return et(e.r)?e.l:Ps(St(e,{r:ip(e.r)}))}function La(e){return et(e)||e.lvl>e.r.lvl}function ap(e){return et(e.r)?[e.k,e.v]:ap(e.r)}function lp(e,t,n,r=vo,o=vo){return{k:e,l:r,lvl:n,r:o,v:t}}function cp(e){return $a(up(e))}function up(e){const{l:t}=e;return!et(t)&&t.lvl===e.lvl?St(t,{r:St(e,{l:t.r})}):e}function $a(e){const{lvl:t,r:n}=e;return!et(n)&&!et(n.r)&&n.lvl===t&&n.r.lvl===t?St(n,{l:St(e,{r:n.l}),lvl:t+1}):e}function ZS(e){return sp(e,({k:t,v:n})=>({index:t,value:n}))}function dp(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function bo(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const Fa=qe(()=>({recalcInProgress:oe(!1)}),[],{singleton:!0});function fp(e,t,n){return e[_s(e,t,n)]}function _s(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 QS(e,t,n,r){const o=_s(e,t,r),s=_s(e,n,r,o);return e.slice(o,s+1)}function Hn(e,t){return Math.round(e.getBoundingClientRect()[t])}function Rs(e){return!et(e.groupOffsetTree)}function Ba({index:e},t){return t===e?0:t<e?-1:1}function eC(){return{groupIndices:[],groupOffsetTree:Dr(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Dr()}}function tC(e,t){let n=et(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),et(e)){e=Qt(e,0,s);continue}const a=js(e,i-1,o+1);if(a.some(lC(r)))continue;let c=!1,l=!1;for(const{end:d,start:f,value:m}of a)c?(o>=f||s===m)&&(e=Oa(e,f)):(l=m!==s,c=!0),d>o&&o>=f&&m!==s&&(e=Qt(e,o+1,m));l&&(e=Qt(e,i,s))}return[e,n]}function nC(e){return typeof e.groupIndex<"u"}function rC({offset:e},t){return t===e?0:t<e?-1:1}function yo(e,t,n){if(t.length===0)return 0;const{index:r,offset:o,size:s}=fp(t,e,Ba),i=e-r,a=s*i+(i-1)*n+o;return a>0?a+n:a}function pp(e,t){if(!Rs(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function hp(e,t,n){if(nC(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=pp(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function oC(e,t,n,r=0){return r>0&&(t=Math.max(t,fp(e,r,Ba).offset)),sp(QS(e,t,n,rC),aC)}function sC(e,[t,n,r,o]){t.length>0&&r("received item sizes",t,Ut.DEBUG);const s=e.sizeTree;let i=s,a=0;if(n.length>0&&et(s)&&t.length===2){const m=t[0].size,p=t[1].size;i=n.reduce((v,g)=>Qt(Qt(v,g,m),g+1,p),i)}else[i,a]=tC(i,t);if(i===s)return e;const{lastIndex:c,lastOffset:l,lastSize:d,offsetTree:f}=za(e.offsetTree,a,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((m,p)=>Qt(m,p,yo(p,f,o)),Dr()),lastIndex:c,lastOffset:l,lastSize:d,offsetTree:f,sizeTree:i}}function iC(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 mp(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 za(e,t,n,r){let o=e,s=0,i=0,a=0,c=0;if(t!==0){c=_s(o,t-1,Ba),a=o[c].offset;const l=pn(n,t-1);s=l[0],i=l[1],o.length&&o[c].size===pn(n,t)[1]&&(c-=1),o=o.slice(0,c+1)}else o=[];for(const{start:l,value:d}of js(n,t,1/0)){const f=l-s,m=f*i+a+f*r;o.push({index:l,offset:m,size:d}),s=l,a=m,i=d}return{lastIndex:s,lastOffset:a,lastSize:i,offsetTree:o}}function aC(e){return{index:e.index,value:e}}function lC(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 cC={offsetHeight:"height",offsetWidth:"width"},En=qe(([{log:e},{recalcInProgress:t}])=>{const n=ze(),r=ze(),o=Rt(r,0),s=ze(),i=ze(),a=oe(0),c=oe([]),l=oe(void 0),d=oe(void 0),f=oe((S,C)=>Hn(S,cC[C])),m=oe(void 0),p=oe(0),v=eC(),g=Rt(ee(n,_e(c,e,p),kn(sC,v),it()),v),x=Rt(ee(c,it(),kn((S,C)=>({current:C,prev:S.current}),{current:[],prev:[]}),ce(({prev:S})=>S)),[]);he(ee(c,ye(S=>S.length>0),_e(g,p),ce(([S,C,k])=>{const A=S.reduce((P,L,F)=>Qt(P,L,yo(L,C.offsetTree,k)||F),Dr());return{...C,groupIndices:S,groupOffsetTree:A}})),g),he(ee(r,_e(g),ye(([S,{lastIndex:C}])=>S<C),ce(([S,{lastIndex:C,lastSize:k}])=>[{endIndex:C,size:k,startIndex:S}])),n),he(l,d);const y=Rt(ee(l,ce(S=>S===void 0)),!0);he(ee(d,ye(S=>S!==void 0&&et(xt(g).sizeTree)),ce(S=>[{endIndex:0,size:S,startIndex:0}])),n);const b=Zt(ee(n,_e(g),kn(({sizes:S},[C,k])=>({changed:k!==S,sizes:k}),{changed:!1,sizes:v}),ce(S=>S.changed)));Ze(ee(a,kn((S,C)=>({diff:S.prev-C,prev:C}),{diff:0,prev:0}),ce(S=>S.diff)),S=>{const{groupIndices:C}=xt(g);if(S>0)Ne(t,!0),Ne(s,S+mp(S,C));else if(S<0){const k=xt(x);k.length>0&&(S-=mp(-S,k)),Ne(i,S)}}),Ze(ee(a,_e(e)),([S,C])=>{S<0&&C("`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},Ut.ERROR)});const T=Zt(s);he(ee(s,_e(g),ce(([S,C])=>{const k=C.groupIndices.length>0,A=[],P=C.lastSize;if(k){const L=wo(C.sizeTree,0);let F=0,K=0;for(;F<S;){const _=C.groupIndices[K],Y=C.groupIndices.length===K+1?1/0:C.groupIndices[K+1]-_-1;A.push({endIndex:_,size:L,startIndex:_}),A.push({endIndex:_+1+Y-1,size:P,startIndex:_+1}),K++,F+=Y+1}const J=or(C.sizeTree);return F!==S&&J.shift(),J.reduce((_,{k:Y,v:q})=>{let W=_.ranges;return _.prevSize!==0&&(W=[..._.ranges,{endIndex:Y+S-1,size:_.prevSize,startIndex:_.prevIndex}]),{prevIndex:Y+S,prevSize:q,ranges:W}},{prevIndex:S,prevSize:0,ranges:A}).ranges}return or(C.sizeTree).reduce((L,{k:F,v:K})=>({prevIndex:F+S,prevSize:K,ranges:[...L.ranges,{endIndex:F+S-1,size:L.prevSize,startIndex:L.prevIndex}]}),{prevIndex:0,prevSize:P,ranges:[]}).ranges})),n);const E=Zt(ee(i,_e(g,p),ce(([S,{offsetTree:C},k])=>{const A=-S;return yo(A,C,k)})));return he(ee(i,_e(g,p),ce(([S,C,k])=>{if(C.groupIndices.length>0){if(et(C.sizeTree))return C;let A=Dr();const P=xt(x);let L=0,F=0,K=0;for(;L<-S;){K=P[F];const J=P[F+1]-K-1;F++,L+=J+1}if(A=or(C.sizeTree).reduce((J,{k:_,v:Y})=>Qt(J,Math.max(0,_+S),Y),A),L!==-S){const J=wo(C.sizeTree,K);A=Qt(A,0,J);const _=pn(C.sizeTree,-S+1)[1];A=Qt(A,1,_)}return{...C,sizeTree:A,...za(C.offsetTree,0,A,k)}}else{const A=or(C.sizeTree).reduce((P,{k:L,v:F})=>Qt(P,Math.max(0,L+S),F),Dr());return{...C,sizeTree:A,...za(C.offsetTree,0,A,k)}}})),g),{beforeUnshiftWith:T,data:m,defaultItemSize:d,firstItemIndex:a,fixedItemSize:l,gap:p,groupIndices:c,itemSize:f,listRefresh:b,shiftWith:i,shiftWithOffset:E,sizeRanges:n,sizes:g,statefulTotalCount:o,totalCount:r,trackItemSizes:y,unshiftWith:s}},st(zn,Fa),{singleton:!0});function uC(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const gp=qe(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=ze(),i=ze(),a=Zt(ee(s,ce(uC)));return he(ee(a,ce(c=>c.totalCount)),n),he(ee(a,ce(c=>c.groupIndices)),e),he(ee(wt(o,t,r),ye(([c,l])=>Rs(l)),ce(([c,l,d])=>pn(l.groupOffsetTree,Math.max(c-d,0),"v")[0]),it(),ce(c=>[c])),i),{groupCounts:s,topItemsIndexes:i}},st(En,$t)),Un=qe(([{log:e}])=>{const t=oe(!1),n=Zt(ee(t,ye(r=>r),it()));return Ze(t,r=>{r&&xt(e)("props updated",{},Ut.DEBUG)}),{didMount:n,propsReady:t}},st(zn),{singleton:!0}),dC=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function xp(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!dC)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const So=qe(([{gap:e,listRefresh:t,sizes:n,totalCount:r},{fixedFooterHeight:o,fixedHeaderHeight:s,footerHeight:i,headerHeight:a,scrollingInProgress:c,scrollTo:l,smoothScrollTargetReached:d,viewportHeight:f},{log:m}])=>{const p=ze(),v=ze(),g=oe(0);let x=null,y=null,b=null;function T(){x&&(x(),x=null),b&&(b(),b=null),y&&(clearTimeout(y),y=null),Ne(c,!1)}return he(ee(p,_e(n,f,r,g,a,i,m),_e(e,s,o),ce(([[E,S,C,k,A,P,L,F],K,J,_])=>{const Y=xp(E),{align:q,behavior:W,offset:D}=Y,I=k-1,G=hp(Y,S,I);let X=yo(G,S.offsetTree,K)+P;q==="end"?(X+=J+pn(S.sizeTree,G)[1]-C+_,G===I&&(X+=L)):q==="center"?X+=(J+pn(S.sizeTree,G)[1]-C+_)/2:X-=A,D&&(X+=D);const M=B=>{T(),B?(F("retrying to scroll to",{location:E},Ut.DEBUG),Ne(p,E)):(Ne(v,!0),F("list did not change, scroll successful",{},Ut.DEBUG))};if(T(),W==="smooth"){let B=!1;b=Ze(t,R=>{B=B||R}),x=fn(d,()=>{M(B)})}else x=fn(ee(t,fC(150)),M);return y=setTimeout(()=>{T()},1200),Ne(c,!0),F("scrolling from index to",{behavior:W,index:G,top:X},Ut.DEBUG),{behavior:W,top:X}})),l),{scrollTargetReached:v,scrollToIndex:p,topListHeight:g}},st(En,$t,zn),{singleton:!0});function fC(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function Ha(e,t){e==0?t():requestAnimationFrame(()=>{Ha(e-1,t)})}function Ua(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const Co=qe(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:s},{didMount:i}])=>{const a=oe(!0),c=oe(0),l=oe(!0);return he(ee(i,_e(c),ye(([d,f])=>!!f),Tn(!1)),a),he(ee(i,_e(c),ye(([d,f])=>!!f),Tn(!1)),l),Ze(ee(wt(t,i),_e(a,n,e,l),ye(([[,d],f,{sizeTree:m},p,v])=>d&&(!et(m)||Pa(p))&&!f&&!v),_e(c)),([,d])=>{fn(o,()=>{Ne(l,!0)}),Ha(4,()=>{fn(r,()=>{Ne(a,!0)}),Ne(s,d)})}),{initialItemFinalLocationReached:l,initialTopMostItemIndex:c,scrolledToInitialItem:a}},st(En,$t,So,Un),{singleton:!0});function vp(e,t){return Math.abs(e-t)<1.01}const To="up",ko="down",pC="none",hC={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},mC=0,Eo=qe(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=oe(!1),a=oe(!0),c=ze(),l=ze(),d=oe(4),f=oe(mC),m=Rt(ee(Ra(ee(be(o),nr(1),Tn(!0)),ee(be(o),nr(1),Tn(!1),tp(100))),it()),!1),p=Rt(ee(Ra(ee(n,Tn(!0)),ee(n,Tn(!1),tp(200))),it()),!1);he(ee(wt(be(o),be(f)),ce(([b,T])=>b<=T),it()),a),he(ee(a,Pn(50)),l);const v=Zt(ee(wt(r,be(s),be(t),be(e),be(d)),kn((b,[{scrollHeight:T,scrollTop:E},S,C,k,A])=>{const P=E+S-T>-A,L={scrollHeight:T,scrollTop:E,viewportHeight:S};if(P){let K,J;return E>b.state.scrollTop?(K="SCROLLED_DOWN",J=b.state.scrollTop-E):(K="SIZE_DECREASED",J=b.state.scrollTop-E||b.scrollTopDelta),{atBottom:!0,atBottomBecause:K,scrollTopDelta:J,state:L}}let F;return L.scrollHeight>b.state.scrollHeight?F="SIZE_INCREASED":S<b.state.viewportHeight?F="VIEWPORT_HEIGHT_DECREASING":E<b.state.scrollTop?F="SCROLLING_UPWARDS":F="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:F,state:L}},hC),it((b,T)=>b&&b.atBottom===T.atBottom))),g=Rt(ee(r,kn((b,{scrollHeight:T,scrollTop:E,viewportHeight:S})=>{if(vp(b.scrollHeight,T))return{changed:!1,jump:0,scrollHeight:T,scrollTop:E};{const C=T-(E+S)<1;return b.scrollTop!==E&&C?{changed:!0,jump:b.scrollTop-E,scrollHeight:T,scrollTop:E}:{changed:!0,jump:0,scrollHeight:T,scrollTop:E}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),ye(b=>b.changed),ce(b=>b.jump)),0);he(ee(v,ce(b=>b.atBottom)),i),he(ee(i,Pn(50)),c);const x=oe(ko);he(ee(r,ce(({scrollTop:b})=>b),it(),kn((b,T)=>xt(p)?{direction:b.direction,prevScrollTop:T}:{direction:T<b.prevScrollTop?To:ko,prevScrollTop:T},{direction:ko,prevScrollTop:0}),ce(b=>b.direction)),x),he(ee(r,Pn(50),Tn(pC)),x);const y=oe(0);return he(ee(m,ye(b=>!b),Tn(0)),y),he(ee(o,Pn(100),_e(m),ye(([b,T])=>!!T),kn(([b,T],[E])=>[T,E],[0,0]),ce(([b,T])=>T-b)),y),{atBottomState:v,atBottomStateChange:c,atBottomThreshold:d,atTopStateChange:l,atTopThreshold:f,isAtBottom:i,isAtTop:a,isScrolling:m,lastJumpDueToItemResize:g,scrollDirection:x,scrollVelocity:y}},st($t)),Ms="top",Os="bottom",wp="none";function bp(e,t,n){return typeof e=="number"?n===To&&t===Ms||n===ko&&t===Os?e:0:n===To?t===Ms?e.main:e.reverse:t===Os?e.main:e.reverse}function yp(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const Wa=qe(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=ze(),i=oe(0),a=oe(0),c=oe(0),l=Rt(ee(wt(be(r),be(o),be(n),be(s,bo),be(c),be(i),be(t),be(e),be(a)),ce(([d,f,m,[p,v],g,x,y,b,T])=>{const E=d-b,S=x+y,C=Math.max(m-E,0);let k=wp;const A=yp(T,Ms),P=yp(T,Os);return p-=b,p+=m+y,v+=m+y,v-=b,p>d+S-A&&(k=To),v<d-C+f+P&&(k=ko),k!==wp?[Math.max(E-m-bp(g,Ms,k)-A,0),E-C-y+f+bp(g,Os,k)+P]:null}),ye(d=>d!=null),it(bo)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:c,topListHeight:i,visibleRange:l}},st($t),{singleton:!0});function gC(e,t,n){if(Rs(t)){const r=pp(e,t);return[{index:pn(t.groupOffsetTree,r)[0],offset:0,size:0},{data:n==null?void 0:n[0],index:r,offset:0,size:0}]}return[{data:n==null?void 0:n[0],index:e,offset:0,size:0}]}const Va={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Ds(e,t,n,r,o,s){const{lastIndex:i,lastOffset:a,lastSize:c}=o;let l=0,d=0;if(e.length>0){l=e[0].offset;const g=e[e.length-1];d=g.offset+g.size}const f=n-i,m=a+f*c+(f-1)*r,p=l,v=m-d;return{bottom:d,firstItemIndex:s,items:Cp(e,o,s),offsetBottom:v,offsetTop:l,top:p,topItems:Cp(t,o,s),topListHeight:t.reduce((g,x)=>x.size+g,0),totalCount:n}}function Sp(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,c=Ua(t,a),l=Array.from({length:a}).map((d,f)=>({data:s[f+c],index:f+c,offset:0,size:0}));return Ds(l,[],a,o,n,r)}function Cp(e,t,n){if(e.length===0)return[];if(!Rs(t))return e.map(l=>({...l,index:l.index+n,originalIndex:l.index}));const r=e[0].index,o=e[e.length-1].index,s=[],i=js(t.groupOffsetTree,r,o);let a,c=0;for(const l of e){(!a||a.end<l.index)&&(a=i.shift(),c=t.groupIndices.indexOf(a.start));let d;l.index===a.start?d={index:c,type:"group"}:d={groupIndex:c,index:l.index-(c+1)+n},s.push({...d,data:l.data,offset:l.offset,originalIndex:l.index,size:l.size})}return s}const sr=qe(([{data:e,firstItemIndex:t,gap:n,sizes:r,totalCount:o},s,{listBoundary:i,topListHeight:a,visibleRange:c},{initialTopMostItemIndex:l,scrolledToInitialItem:d},{topListHeight:f},m,{didMount:p},{recalcInProgress:v}])=>{const g=oe([]),x=oe(0),y=ze();he(s.topItemsIndexes,g);const b=Rt(ee(wt(p,v,be(c,bo),be(o),be(r),be(l),d,be(g),be(t),be(n),e),ye(([C,k,,A,,,,,,,P])=>{const L=P&&P.length!==A;return C&&!k&&!L}),ce(([,,[C,k],A,P,L,F,K,J,_,Y])=>{const q=P,{offsetTree:W,sizeTree:D}=q,I=xt(x);if(A===0)return{...Va,totalCount:A};if(C===0&&k===0)return I===0?{...Va,totalCount:A}:Sp(I,L,P,J,_,Y||[]);if(et(D))return I>0?null:Ds(gC(Ua(L,A),q,Y),[],A,_,q,J);const G=[];if(K.length>0){const $=K[0],z=K[K.length-1];let O=0;for(const j of js(D,$,z)){const U=j.value,Q=Math.max(j.start,$),se=Math.min(j.end,z);for(let ie=Q;ie<=se;ie++)G.push({data:Y==null?void 0:Y[ie],index:ie,offset:O,size:U}),O+=U}}if(!F)return Ds([],G,A,_,q,J);const X=K.length>0?K[K.length-1]+1:0,M=oC(W,C,k,X);if(M.length===0)return null;const B=A-1,R=As([],$=>{for(const z of M){const O=z.value;let j=O.offset,U=z.start;const Q=O.size;if(O.offset<C){U+=Math.floor((C-O.offset+_)/(Q+_));const ie=U-z.start;j+=ie*Q+ie*_}U<X&&(j+=(X-U)*Q,U=X);const se=Math.min(z.end,B);for(let ie=U;ie<=se&&!(j>=k);ie++)$.push({data:Y==null?void 0:Y[ie],index:ie,offset:j,size:Q}),j+=Q+_}});return Ds(R,G,A,_,q,J)}),ye(C=>C!==null),it()),Va);he(ee(e,ye(Pa),ce(C=>C==null?void 0:C.length)),o),he(ee(b,ce(C=>C.topListHeight)),f),he(f,a),he(ee(b,ce(C=>[C.top,C.bottom])),i),he(ee(b,ce(C=>C.items)),y);const T=Zt(ee(b,ye(({items:C})=>C.length>0),_e(o,e),ye(([{items:C},k])=>C[C.length-1].originalIndex===k-1),ce(([,C,k])=>[C-1,k]),it(bo),ce(([C])=>C))),E=Zt(ee(b,Pn(200),ye(({items:C,topItems:k})=>C.length>0&&C[0].originalIndex===k.length),ce(({items:C})=>C[0].index),it())),S=Zt(ee(b,ye(({items:C})=>C.length>0),ce(({items:C})=>{let k=0,A=C.length-1;for(;C[k].type==="group"&&k<A;)k++;for(;C[A].type==="group"&&A>k;)A--;return{endIndex:C[A].index,startIndex:C[k].index}}),it(dp)));return{endReached:T,initialItemCount:x,itemsRendered:y,listState:b,rangeChanged:S,startReached:E,topItemsIndexes:g,...m}},st(En,gp,Wa,Co,So,Eo,Un,Fa),{singleton:!0}),Tp=qe(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=ze(),i=Rt(ee(wt(n,e,r,t,o),ce(([a,c,l,d,f])=>a+c+l+d+f.offsetBottom+f.bottom)),0);return he(be(i),s),{totalListHeight:i,totalListHeightChanged:s}},st($t,sr),{singleton:!0}),xC=qe(([{viewportHeight:e},{totalListHeight:t}])=>{const n=oe(!1),r=Rt(ee(wt(n,e,t),ye(([o])=>o),ce(([,o,s])=>Math.max(0,o-s)),Pn(0),it()),0);return{alignToBottom:n,paddingTopAddition:r}},st($t,Tp),{singleton:!0}),kp=qe(()=>({context:oe(null)})),vC=({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,Ep=qe(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:s,scrollingInProgress:i,scrollTop:a,viewportHeight:c},{scrollToIndex:l}])=>{const d=ze();return he(ee(d,_e(t,c,n,s,o,r,a),_e(e),ce(([[f,m,p,v,g,x,y,b],T])=>{const{align:E,behavior:S,calculateViewLocation:C=vC,done:k,...A}=f,P=hp(f,m,v-1),L=yo(P,m.offsetTree,T)+g+x,F=L+pn(m.sizeTree,P)[1],K=b+x,J=b+p-y,_=C({itemBottom:F,itemTop:L,locationParams:{align:E,behavior:S,...A},viewportBottom:J,viewportTop:K});return _?k&&fn(ee(i,ye(Y=>!Y),nr(xt(i)?1:2)),k):k&&k(),_}),ye(f=>f!==null)),l),{scrollIntoView:d}},st(En,$t,So,sr,zn),{singleton:!0});function Ip(e){return e?e==="smooth"?"smooth":"auto":!1}const wC=(e,t)=>typeof e=="function"?Ip(e(t)):t&&Ip(e),bC=qe(([{listRefresh:e,totalCount:t,fixedItemSize:n,data:r},{atBottomState:o,isAtBottom:s},{scrollToIndex:i},{scrolledToInitialItem:a},{didMount:c,propsReady:l},{log:d},{scrollingInProgress:f},{context:m},{scrollIntoView:p}])=>{const v=oe(!1),g=ze();let x=null;function y(S){Ne(i,{align:"end",behavior:S,index:"LAST"})}Ze(ee(wt(ee(be(t),nr(1)),c),_e(be(v),s,a,f),ce(([[S,C],k,A,P,L])=>{let F=C&&P,K="auto";return F&&(K=wC(k,A||L),F=F&&!!K),{followOutputBehavior:K,shouldFollow:F,totalCount:S}}),ye(({shouldFollow:S})=>S)),({followOutputBehavior:S,totalCount:C})=>{x&&(x(),x=null),xt(n)?requestAnimationFrame(()=>{xt(d)("following output to ",{totalCount:C},Ut.DEBUG),y(S)}):x=fn(e,()=>{xt(d)("following output to ",{totalCount:C},Ut.DEBUG),y(S),x=null})});function b(S){const C=fn(o,k=>{S&&!k.atBottom&&k.notAtBottomBecause==="SIZE_INCREASED"&&!x&&(xt(d)("scrolling to bottom due to increased size",{},Ut.DEBUG),y("auto"))});setTimeout(C,100)}Ze(ee(wt(be(v),t,l),ye(([S,,C])=>S&&C),kn(({value:S},[,C])=>({refreshed:S===C,value:C}),{refreshed:!1,value:0}),ye(({refreshed:S})=>S),_e(v,t)),([,S])=>{xt(a)&&b(S!==!1)}),Ze(g,()=>{b(xt(v)!==!1)}),Ze(wt(be(v),o),([S,C])=>{S&&!C.atBottom&&C.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&y("auto")});const T=oe(null),E=ze();return he(Ra(ee(be(r),ce(S=>{var C;return(C=S==null?void 0:S.length)!=null?C:0})),ee(be(t))),E),Ze(ee(wt(ee(E,nr(1)),c),_e(be(T),a,f,m),ce(([[S,C],k,A,P,L])=>C&&A&&(k==null?void 0:k({context:L,totalCount:S,scrollingInProgress:P}))),ye(S=>!!S),Pn(0)),S=>{x&&(x(),x=null),xt(n)?requestAnimationFrame(()=>{xt(d)("scrolling into view",{}),Ne(p,S)}):x=fn(e,()=>{xt(d)("scrolling into view",{}),Ne(p,S),x=null})}),{autoscrollToBottom:g,followOutput:v,scrollIntoViewOnChange:T}},st(En,Eo,So,Co,Un,zn,$t,kp,Ep)),yC=qe(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(he(ee(a,_e(s),ye(([,c])=>c!==0),_e(o,r,t,n,e),ce(([[,c],l,d,f,m,p=[]])=>Sp(c,l,d,f,m,p))),i),{}),st(En,Co,sr,Un),{singleton:!0}),SC=qe(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=oe(0);return Ze(ee(e,_e(r),ye(([,o])=>o!==0),ce(([,o])=>({top:o}))),o=>{fn(ee(n,nr(1),ye(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{Ne(t,o)})})}),{initialScrollTop:r}},st(Un,$t,sr),{singleton:!0}),Np=qe(([{scrollVelocity:e}])=>{const t=oe(!1),n=ze(),r=oe(!1);return he(ee(e,_e(r,t,n),ye(([o,s])=>!!s),ce(([o,s,i,a])=>{const{enter:c,exit:l}=s;if(i){if(l(o,a))return!1}else if(c(o,a))return!0;return i}),it()),t),Ze(ee(wt(t,e,n),_e(r)),([[o,s,i],a])=>{o&&a&&a.change&&a.change(s,i)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},st(Eo),{singleton:!0}),Ka=qe(([{scrollContainerState:e,scrollTo:t}])=>{const n=ze(),r=ze(),o=ze(),s=oe(!1),i=oe(void 0);return he(ee(wt(n,r),ce(([{scrollHeight:a,scrollTop:c,viewportHeight:l},{offsetTop:d}])=>({scrollHeight:a,scrollTop:Math.max(0,c-d),viewportHeight:l}))),e),he(ee(t,_e(r),ce(([a,{offsetTop:c}])=>({...a,top:a.top+c}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},st($t)),CC=qe(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:a,windowViewportRect:c}])=>{const l=ze(),d=oe(void 0),f=oe(null),m=oe(null);return he(a,f),he(c,m),Ze(ee(l,_e(t,r,i,f,m,n)),([p,v,g,x,y,b,T])=>{const E=iC(v.sizeTree);x&&y!==null&&b!==null&&(g=y.scrollTop-b.offsetTop),g-=T,p({ranges:E,scrollTop:g})}),he(ee(d,ye(Pa),ce(TC)),o),he(ee(s,_e(d),ye(([,p])=>p!==void 0),it(),ce(([,p])=>p.ranges)),e),{getState:l,restoreStateFrom:d}},st(En,$t,Co,Un,Ka));function TC(e){return{align:"start",index:0,offset:e.scrollTop}}const kC=qe(([{topItemsIndexes:e}])=>{const t=oe(0);return he(ee(t,ye(n=>n>=0),ce(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},st(sr));function Ap(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const EC=Ap(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),IC=qe(([{deviation:e,scrollBy:t,scrollingInProgress:n,scrollTop:r},{isAtBottom:o,isScrolling:s,lastJumpDueToItemResize:i,scrollDirection:a},{listState:c},{beforeUnshiftWith:l,gap:d,shiftWithOffset:f,sizes:m},{log:p},{recalcInProgress:v}])=>{const g=Zt(ee(c,_e(i),kn(([,y,b,T],[{bottom:E,items:S,offsetBottom:C,totalCount:k},A])=>{const P=E+C;let L=0;return b===k&&y.length>0&&S.length>0&&(S[0].originalIndex===0&&y[0].originalIndex===0||(L=P-T,L!==0&&(L+=A))),[L,S,k,P]},[0,[],0,0]),ye(([y])=>y!==0),_e(r,a,n,o,p,v),ye(([,y,b,T,,,E])=>!E&&!T&&y!==0&&b===To),ce(([[y],,,,,b])=>(b("Upward scrolling compensation",{amount:y},Ut.DEBUG),y))));function x(y){y>0?(Ne(t,{behavior:"auto",top:-y}),Ne(e,0)):(Ne(e,0),Ne(t,{behavior:"auto",top:-y}))}return Ze(ee(g,_e(e,s)),([y,b,T])=>{T&&EC()?Ne(e,b-y):x(-y)}),Ze(ee(wt(Rt(s,!1),e,v),ye(([y,b,T])=>!y&&!T&&b!==0),ce(([y,b])=>b),Pn(1)),x),he(ee(f,ce(y=>({top:-y}))),t),Ze(ee(l,_e(m,d),ce(([y,{groupIndices:b,lastSize:T,sizeTree:E},S])=>{function C(k){return k*(T+S)}if(b.length===0)return C(y);{let k=0;const A=wo(E,0);let P=0,L=0;for(;P<y;){P++,k+=A;let F=b.length===L+1?1/0:b[L+1]-b[L]-1;P+F>y&&(k-=A,F=y-P+1),P+=F,k+=C(F),L++}return k}})),y=>{Ne(e,y),requestAnimationFrame(()=>{Ne(t,{top:y}),requestAnimationFrame(()=>{Ne(e,0),Ne(v,!1)})})}),{deviation:e}},st($t,Eo,sr,En,zn,Fa)),NC=qe(([e,t,n,r,o,s,i,a,c,l,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...c,...l,...d}),st(Wa,yC,Un,Np,Tp,SC,xC,Ka,Ep,zn,kp)),jp=qe(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:r,gap:o,groupIndices:s,itemSize:i,sizeRanges:a,sizes:c,statefulTotalCount:l,totalCount:d,trackItemSizes:f},{initialItemFinalLocationReached:m,initialTopMostItemIndex:p,scrolledToInitialItem:v},g,x,y,{listState:b,topItemsIndexes:T,...E},{scrollToIndex:S},C,{topItemCount:k},{groupCounts:A},P])=>(he(E.rangeChanged,P.scrollSeekRangeChanged),he(ee(P.windowViewportRect,ce(L=>L.visibleHeight)),g.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,gap:o,groupCounts:A,initialItemFinalLocationReached:m,initialTopMostItemIndex:p,scrolledToInitialItem:v,sizeRanges:a,topItemCount:k,topItemsIndexes:T,totalCount:d,...y,groupIndices:s,itemSize:i,listState:b,scrollToIndex:S,statefulTotalCount:l,trackItemSizes:f,...E,...P,...g,sizes:c,...x}),st(En,Co,$t,CC,bC,sr,So,IC,kC,gp,NC));function AC(e,t){const n={},r={};let o=0;const s=e.length;for(;o<s;)r[e[o]]=1,o+=1;for(const i in t)Object.hasOwn(r,i)||(n[i]=t[i]);return n}const Ls=typeof document<"u"?w.useLayoutEffect:w.useEffect;function Pp(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 c(x,y){x.propsReady&&Ne(x.propsReady,!1);for(const b of r){const T=x[t.required[b]];Ne(T,y[b])}for(const b of o)if(b in y){const T=x[t.optional[b]];Ne(T,y[b])}x.propsReady&&Ne(x.propsReady,!0)}function l(x){return s.reduce((y,b)=>(y[b]=T=>{const E=x[t.methods[b]];Ne(E,T)},y),{})}function d(x){return i.reduce((y,b)=>(y[b]=VS(x[t.events[b]]),y),{})}const f=w.forwardRef((x,y)=>{const{children:b,...T}=x,[E]=w.useState(()=>As(qS(e),k=>{c(k,T)})),[S]=w.useState(ep(d,E));Ls(()=>{for(const k of i)k in T&&Ze(S[k],T[k]);return()=>{Object.values(S).map(_a)}},[T,S,E]),Ls(()=>{c(E,T)}),w.useImperativeHandle(y,Zf(l(E)));const C=n;return u.jsx(a.Provider,{value:E,children:n?u.jsx(C,{...AC([...r,...o,...i],T),children:b}):b})}),m=x=>{const y=w.useContext(a);return w.useCallback(b=>{Ne(y[x],b)},[y,x])},p=x=>{const y=w.useContext(a)[x],b=w.useCallback(T=>Ze(y,T),[y]);return w.useSyncExternalStore(b,()=>xt(y),()=>xt(y))},v=x=>{const y=w.useContext(a)[x],[b,T]=w.useState(ep(xt,y));return Ls(()=>Ze(y,E=>{E!==b&&T(Zf(E))}),[y,b]),b},g=w.version.startsWith("18")?p:v;return{Component:f,useEmitter:(x,y)=>{const b=w.useContext(a)[x];Ls(()=>Ze(b,y),[y,b])},useEmitterValue:g,usePublisher:m}}const _p=w.createContext(void 0),Rp=w.createContext(void 0),Mp=typeof document<"u"?w.useLayoutEffect:w.useEffect;function qa(e){return"self"in e}function jC(e){return"body"in e}function Op(e,t,n,r=Or,o,s){const i=w.useRef(null),a=w.useRef(null),c=w.useRef(null),l=w.useCallback(m=>{let p,v,g;const x=m.target;if(jC(x)||qa(x)){const b=qa(x)?x:x.defaultView;g=s?b.scrollX:b.scrollY,p=s?b.document.documentElement.scrollWidth:b.document.documentElement.scrollHeight,v=s?b.innerWidth:b.innerHeight}else g=s?x.scrollLeft:x.scrollTop,p=s?x.scrollWidth:x.scrollHeight,v=s?x.offsetWidth:x.offsetHeight;const y=()=>{e({scrollHeight:p,scrollTop:Math.max(g,0),viewportHeight:v})};m.suppressFlushSync?y():Lo.flushSync(y),a.current!==null&&(g===a.current||g<=0||g===p-v)&&(a.current=null,t(!0),c.current&&(clearTimeout(c.current),c.current=null))},[e,t,s]);w.useEffect(()=>{const m=o||i.current;return r(o||i.current),l({suppressFlushSync:!0,target:m}),m.addEventListener("scroll",l,{passive:!0}),()=>{r(null),m.removeEventListener("scroll",l)}},[i,l,n,r,o]);function d(m){const p=i.current;if(!p||(s?"offsetWidth"in p&&p.offsetWidth===0:"offsetHeight"in p&&p.offsetHeight===0))return;const v=m.behavior==="smooth";let g,x,y;qa(p)?(x=Math.max(Hn(p.document.documentElement,s?"width":"height"),s?p.document.documentElement.scrollWidth:p.document.documentElement.scrollHeight),g=s?p.innerWidth:p.innerHeight,y=s?window.scrollX:window.scrollY):(x=p[s?"scrollWidth":"scrollHeight"],g=Hn(p,s?"width":"height"),y=p[s?"scrollLeft":"scrollTop"]);const b=x-g;if(m.top=Math.ceil(Math.max(Math.min(b,m.top),0)),vp(g,x)||m.top===y){e({scrollHeight:x,scrollTop:y,viewportHeight:g}),v&&t(!0);return}v?(a.current=m.top,c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{c.current=null,a.current=null,t(!0)},1e3)):a.current=null,s&&(m={behavior:m.behavior,left:m.top}),p.scrollTo(m)}function f(m){s&&(m={behavior:m.behavior,left:m.top}),i.current.scrollBy(m)}return{scrollByCallback:f,scrollerRef:i,scrollToCallback:d}}const Ga="-webkit-sticky",Dp="sticky",Ya=Ap(()=>{if(typeof document>"u")return Dp;const e=document.createElement("div");return e.style.position=Ga,e.style.position===Ga?Ga:Dp});function Xa(e){return e}const PC=qe(()=>{const e=oe(a=>`Item ${a}`),t=oe(a=>`Group ${a}`),n=oe({}),r=oe(Xa),o=oe("div"),s=oe(Or),i=(a,c=null)=>Rt(ee(n,ce(l=>l[a]),it()),c);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")}}),_C=qe(([e,t])=>({...e,...t}),st(jp,PC)),RC=({height:e})=>u.jsx("div",{style:{height:e}}),MC={overflowAnchor:"none",position:Ya(),zIndex:1},Lp={overflowAnchor:"none"},OC={...Lp,display:"inline-block",height:"100%"},$p=w.memo(function({showTopList:e=!1}){const t=Ce("listState"),n=tn("sizeRanges"),r=Ce("useWindowScroll"),o=Ce("customScrollParent"),s=tn("windowScrollContainerState"),i=tn("scrollContainerState"),a=o||r?s:i,c=Ce("itemContent"),l=Ce("context"),d=Ce("groupContent"),f=Ce("trackItemSizes"),m=Ce("itemSize"),p=Ce("log"),v=tn("gap"),g=Ce("horizontalDirection"),{callbackRef:x}=XS(n,m,f,e?Or:a,p,v,o,g,Ce("skipAnimationFrameInResizeObserver")),[y,b]=w.useState(0);Ja("deviation",_=>{y!==_&&b(_)});const T=Ce("EmptyPlaceholder"),E=Ce("ScrollSeekPlaceholder")||RC,S=Ce("ListComponent"),C=Ce("ItemComponent"),k=Ce("GroupComponent"),A=Ce("computeItemKey"),P=Ce("isSeeking"),L=Ce("groupIndices").length>0,F=Ce("alignToBottom"),K=Ce("initialItemFinalLocationReached"),J=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},...K?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&T?u.jsx(T,{...Mt(T,l)}):u.jsx(S,{...Mt(S,l),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:x,style:J,children:(e?t.topItems:t.items).map(_=>{const Y=_.originalIndex,q=A(Y+t.firstItemIndex,_.data,l);return P?w.createElement(E,{...Mt(E,l),height:_.size,index:_.index,key:q,type:_.type||"item",..._.type==="group"?{}:{groupIndex:_.groupIndex}}):_.type==="group"?w.createElement(k,{...Mt(k,l),"data-index":Y,"data-item-index":_.index,"data-known-size":_.size,key:q,style:MC},d(_.index,l)):w.createElement(C,{...Mt(C,l),...FC(C,_.data),"data-index":Y,"data-item-group-index":_.groupIndex,"data-item-index":_.index,"data-known-size":_.size,key:q,style:g?OC:Lp},L?c(_.index,_.groupIndex,_.data,l):c(_.index,_.data,l))})})}),DC={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},LC={outline:"none",overflowX:"auto",position:"relative"},$s=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),$C={position:Ya(),top:0,width:"100%",zIndex:1};function Mt(e,t){if(typeof e!="string")return{context:t}}function FC(e,t){return{item:typeof e=="string"?void 0:t}}const BC=w.memo(function(){const e=Ce("HeaderComponent"),t=tn("headerHeight"),n=Ce("HeaderFooterTag"),r=rr(w.useMemo(()=>s=>{t(Hn(s,"height"))},[t]),!0,Ce("skipAnimationFrameInResizeObserver")),o=Ce("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Mt(e,o)})}):null}),zC=w.memo(function(){const e=Ce("FooterComponent"),t=tn("footerHeight"),n=Ce("HeaderFooterTag"),r=rr(w.useMemo(()=>s=>{t(Hn(s,"height"))},[t]),!0,Ce("skipAnimationFrameInResizeObserver")),o=Ce("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Mt(e,o)})}):null});function Fp({useEmitter:e,useEmitterValue:t,usePublisher:n}){return w.memo(function({children:r,style:o,context:s,...i}){const a=n("scrollContainerState"),c=t("ScrollerComponent"),l=n("smoothScrollTargetReached"),d=t("scrollerRef"),f=t("horizontalDirection")||!1,{scrollByCallback:m,scrollerRef:p,scrollToCallback:v}=Op(a,l,c,d,void 0,f);return e("scrollTo",v),e("scrollBy",m),u.jsx(c,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:p,style:{...f?LC:DC,...o},tabIndex:0,...i,...Mt(c,s),children:r})})}function Bp({useEmitter:e,useEmitterValue:t,usePublisher:n}){return w.memo(function({children:r,style:o,context:s,...i}){const a=n("windowScrollContainerState"),c=t("ScrollerComponent"),l=n("smoothScrollTargetReached"),d=t("totalListHeight"),f=t("deviation"),m=t("customScrollParent"),p=w.useRef(null),v=t("scrollerRef"),{scrollByCallback:g,scrollerRef:x,scrollToCallback:y}=Op(a,l,c,v,m);return Mp(()=>{var b;return x.current=m||((b=p.current)==null?void 0:b.ownerDocument.defaultView),()=>{x.current=null}},[x,m]),e("windowScrollTo",y),e("scrollBy",g),u.jsx(c,{ref:p,"data-virtuoso-scroller":!0,style:{position:"relative",...o,...d!==0?{height:d+f}:{}},...i,...Mt(c,s),children:r})})}const HC=({children:e})=>{const t=w.useContext(_p),n=tn("viewportHeight"),r=tn("fixedItemHeight"),o=Ce("alignToBottom"),s=Ce("horizontalDirection"),i=w.useMemo(()=>Qf(n,c=>Hn(c,s?"width":"height")),[n,s]),a=rr(i,!0,Ce("skipAnimationFrameInResizeObserver"));return w.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),u.jsx("div",{"data-viewport-type":"element",ref:a,style:$s(o),children:e})},UC=({children:e})=>{const t=w.useContext(_p),n=tn("windowViewportRect"),r=tn("fixedItemHeight"),o=Ce("customScrollParent"),s=op(n,o,Ce("skipAnimationFrameInResizeObserver")),i=Ce("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:$s(i),children:e})},WC=({children:e})=>{const t=Ce("TopItemListComponent")||"div",n=Ce("headerHeight"),r={...$C,marginTop:`${n}px`},o=Ce("context");return u.jsx(t,{style:r,...Mt(t,o),children:e})},VC=w.memo(function(e){const t=Ce("useWindowScroll"),n=Ce("topItemsIndexes").length>0,r=Ce("customScrollParent"),o=Ce("context");return u.jsxs(r||t?GC:qC,{...e,context:o,children:[n&&u.jsx(WC,{children:u.jsx($p,{showTopList:!0})}),u.jsxs(r||t?UC:HC,{children:[u.jsx(BC,{}),u.jsx($p,{}),u.jsx(zC,{})]})]})}),{Component:KC,useEmitter:Ja,useEmitterValue:Ce,usePublisher:tn}=Pp(_C,{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"}},VC),qC=Fp({useEmitter:Ja,useEmitterValue:Ce,usePublisher:tn}),GC=Bp({useEmitter:Ja,useEmitterValue:Ce,usePublisher:tn}),YC=KC;st(jp,qe(()=>{const e=oe(l=>u.jsxs("td",{children:["Item $",l]})),t=oe(null),n=oe(l=>u.jsxs("td",{colSpan:1e3,children:["Group ",l]})),r=oe(null),o=oe(null),s=oe({}),i=oe(Xa),a=oe(Or),c=(l,d=null)=>Rt(ee(s,ce(f=>f[l]),it()),d);return{components:s,computeItemKey:i,context:t,EmptyPlaceholder:c("EmptyPlaceholder"),FillerRow:c("FillerRow"),fixedFooterContent:o,fixedHeaderContent:r,itemContent:e,groupContent:n,ScrollerComponent:c("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:c("ScrollSeekPlaceholder"),TableBodyComponent:c("TableBody","tbody"),TableComponent:c("Table","table"),TableFooterComponent:c("TableFoot","tfoot"),TableHeadComponent:c("TableHead","thead"),TableRowComponent:c("TableRow","tr"),GroupComponent:c("Group","tr")}})),Ya();const zp={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},XC={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:Hp,floor:Fs,max:Io,min:Za,round:Up}=Math;function Wp(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function JC(e){return{...XC,items:e}}function Bs(e,t){return e&&e.width===t.width&&e.height===t.height}function ZC(e,t){return e&&e.column===t.column&&e.row===t.row}const QC=qe(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:r},{footerHeight:o,headerHeight:s,scrollBy:i,scrollContainerState:a,scrollTo:c,scrollTop:l,smoothScrollTargetReached:d,viewportHeight:f},m,p,{didMount:v,propsReady:g},{customScrollParent:x,useWindowScroll:y,windowScrollContainerState:b,windowScrollTo:T,windowViewportRect:E},S])=>{const C=oe(0),k=oe(0),A=oe(zp),P=oe({height:0,width:0}),L=oe({height:0,width:0}),F=ze(),K=ze(),J=oe(0),_=oe(null),Y=oe({column:0,row:0}),q=ze(),W=ze(),D=oe(!1),I=oe(0),G=oe(!0),X=oe(!1),M=oe(!1);Ze(ee(v,_e(I),ye(([j,U])=>!!U)),()=>{Ne(G,!1)}),Ze(ee(wt(v,G,L,P,I,X),ye(([j,U,Q,se,,ie])=>j&&!U&&Q.height!==0&&se.height!==0&&!ie)),([,,,,j])=>{Ne(X,!0),Ha(1,()=>{Ne(F,j)}),fn(ee(l),()=>{Ne(t,[0,0]),Ne(G,!0)})}),he(ee(W,ye(j=>j!=null&&j.scrollTop>0),Tn(0)),k),Ze(ee(v,_e(W),ye(([,j])=>j!=null)),([,j])=>{j&&(Ne(P,j.viewport),Ne(L,j.item),Ne(Y,j.gap),j.scrollTop>0&&(Ne(D,!0),fn(ee(l,nr(1)),U=>{Ne(D,!1)}),Ne(c,{top:j.scrollTop})))}),he(ee(P,ce(({height:j})=>j)),f),he(ee(wt(be(P,Bs),be(L,Bs),be(Y,(j,U)=>j&&j.column===U.column&&j.row===U.row),be(l)),ce(([j,U,Q,se])=>({gap:Q,item:U,scrollTop:se,viewport:j}))),q),he(ee(wt(be(C),r,be(Y,ZC),be(L,Bs),be(P,Bs),be(_),be(k),be(D),be(G),be(I)),ye(([,,,,,,,j])=>!j),ce(([j,[U,Q],se,ie,Se,xe,Re,,Ve,De])=>{const{column:Ge,row:He}=se,{height:ot,width:ut}=ie,{width:nt}=Se;if(Re===0&&(j===0||nt===0))return zp;if(ut===0){const It=Ua(De,j),bt=It+Math.max(Re-1,0);return JC(Wp(It,bt,xe))}const Le=Vp(nt,ut,Ge);let Ke,$e;Ve?U===0&&Q===0&&Re>0?(Ke=0,$e=Re-1):(Ke=Le*Fs((U+He)/(ot+He)),$e=Le*Hp((Q+He)/(ot+He))-1,$e=Za(j-1,Io($e,Le-1)),Ke=Za($e,Io(0,Ke))):(Ke=0,$e=-1);const Te=Wp(Ke,$e,xe),{bottom:Ae,top:dt}=Kp(Se,se,ie,Te),Et=Hp(j/Le),at=Et*ot+(Et-1)*He-Ae;return{bottom:Ae,itemHeight:ot,items:Te,itemWidth:ut,offsetBottom:at,offsetTop:dt,top:dt}})),A),he(ee(_,ye(j=>j!==null),ce(j=>j.length)),C),he(ee(wt(P,L,A,Y),ye(([j,U,{items:Q}])=>Q.length>0&&U.height!==0&&j.height!==0),ce(([j,U,{items:Q},se])=>{const{bottom:ie,top:Se}=Kp(j,se,U,Q);return[Se,ie]}),it(bo)),t);const B=oe(!1);he(ee(l,_e(B),ce(([j,U])=>U||j!==0)),B);const R=Zt(ee(wt(A,C),ye(([{items:j}])=>j.length>0),_e(B),ye(([[j,U],Q])=>{const se=j.items[j.items.length-1].index===U-1;return(Q||j.bottom>0&&j.itemHeight>0&&j.offsetBottom===0&&j.items.length===U)&&se}),ce(([[,j]])=>j-1),it())),$=Zt(ee(be(A),ye(({items:j})=>j.length>0&&j[0].index===0),Tn(0),it())),z=Zt(ee(be(A),_e(D),ye(([{items:j},U])=>j.length>0&&!U),ce(([{items:j}])=>({endIndex:j[j.length-1].index,startIndex:j[0].index})),it(dp),Pn(0)));he(z,p.scrollSeekRangeChanged),he(ee(F,_e(P,L,C,Y),ce(([j,U,Q,se,ie])=>{const Se=xp(j),{align:xe,behavior:Re,offset:Ve}=Se;let De=Se.index;De==="LAST"&&(De=se-1),De=Io(0,De,Za(se-1,De));let Ge=Qa(U,ie,Q,De);return xe==="end"?Ge=Up(Ge-U.height+Q.height):xe==="center"&&(Ge=Up(Ge-U.height/2+Q.height/2)),Ve&&(Ge+=Ve),{behavior:Re,top:Ge}})),c);const O=Rt(ee(A,ce(j=>j.offsetBottom+j.bottom)),0);return he(ee(E,ce(j=>({height:j.visibleHeight,width:j.visibleWidth}))),P),{customScrollParent:x,data:_,deviation:J,footerHeight:o,gap:Y,headerHeight:s,increaseViewportBy:e,initialItemCount:k,itemDimensions:L,overscan:n,restoreStateFrom:W,scrollBy:i,scrollContainerState:a,scrollHeight:K,scrollTo:c,scrollToIndex:F,scrollTop:l,smoothScrollTargetReached:d,totalCount:C,useWindowScroll:y,viewportDimensions:P,windowScrollContainerState:b,windowScrollTo:T,windowViewportRect:E,...p,gridState:A,horizontalDirection:M,initialTopMostItemIndex:I,totalListHeight:O,...m,endReached:R,propsReady:g,rangeChanged:z,startReached:$,stateChanged:q,stateRestoreInProgress:D,...S}},st(Wa,$t,Eo,Np,Un,Ka,zn));function Vp(e,t,n){return Io(1,Fs((e+n)/(Fs(t)+n)))}function Kp(e,t,n,r){const{height:o}=n;if(o===void 0||r.length===0)return{bottom:0,top:0};const s=Qa(e,t,n,r[0].index);return{bottom:Qa(e,t,n,r[r.length-1].index)+o,top:s}}function Qa(e,t,n,r){const o=Vp(e.width,n.width,t.column),s=Fs(r/o),i=s*n.height+Io(0,s-1)*t.row;return i>0?i+t.row:i}const eT=qe(()=>{const e=oe(f=>`Item ${f}`),t=oe({}),n=oe(null),r=oe("virtuoso-grid-item"),o=oe("virtuoso-grid-list"),s=oe(Xa),i=oe("div"),a=oe(Or),c=(f,m=null)=>Rt(ee(t,ce(p=>p[f]),it()),m),l=oe(!1),d=oe(!1);return he(be(d),l),{components:t,computeItemKey:s,context:n,FooterComponent:c("Footer"),HeaderComponent:c("Header"),headerFooterTag:i,itemClassName:r,ItemComponent:c("Item","div"),itemContent:e,listClassName:o,ListComponent:c("List","div"),readyStateChanged:l,reportReadyState:d,ScrollerComponent:c("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:c("ScrollSeekPlaceholder","div")}}),tT=qe(([e,t])=>({...e,...t}),st(QC,eT)),nT=w.memo(function(){const e=lt("gridState"),t=lt("listClassName"),n=lt("itemClassName"),r=lt("itemContent"),o=lt("computeItemKey"),s=lt("isSeeking"),i=nn("scrollHeight"),a=lt("ItemComponent"),c=lt("ListComponent"),l=lt("ScrollSeekPlaceholder"),d=lt("context"),f=nn("itemDimensions"),m=nn("gap"),p=lt("log"),v=lt("stateRestoreInProgress"),g=nn("reportReadyState"),x=rr(w.useMemo(()=>y=>{const b=y.parentElement.parentElement.scrollHeight;i(b);const T=y.firstChild;if(T){const{height:E,width:S}=T.getBoundingClientRect();f({height:E,width:S})}m({column:Gp("column-gap",getComputedStyle(y).columnGap,p),row:Gp("row-gap",getComputedStyle(y).rowGap,p)})},[i,f,m,p]),!0,!1);return Mp(()=>{e.itemHeight>0&&e.itemWidth>0&&g(!0)},[e]),v?null:u.jsx(c,{className:t,ref:x,...Mt(c,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(l,{...Mt(l,d),height:e.itemHeight,index:y.index,width:e.itemWidth},b):w.createElement(a,{...Mt(a,d),className:n,"data-index":y.index,key:b},r(y.index,y.data,d))})})}),rT=w.memo(function(){const e=lt("HeaderComponent"),t=nn("headerHeight"),n=lt("headerFooterTag"),r=rr(w.useMemo(()=>s=>{t(Hn(s,"height"))},[t]),!0,!1),o=lt("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Mt(e,o)})}):null}),oT=w.memo(function(){const e=lt("FooterComponent"),t=nn("footerHeight"),n=lt("headerFooterTag"),r=rr(w.useMemo(()=>s=>{t(Hn(s,"height"))},[t]),!0,!1),o=lt("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Mt(e,o)})}):null}),sT=({children:e})=>{const t=w.useContext(Rp),n=nn("itemDimensions"),r=nn("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:$s(!1),children:e})},iT=({children:e})=>{const t=w.useContext(Rp),n=nn("windowViewportRect"),r=nn("itemDimensions"),o=lt("customScrollParent"),s=op(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:$s(!1),children:e})},aT=w.memo(function({...e}){const t=lt("useWindowScroll"),n=lt("customScrollParent"),r=n||t?cT:lT,o=n||t?iT:sT,s=lt("context");return u.jsx(r,{...e,...Mt(r,s),children:u.jsxs(o,{children:[u.jsx(rT,{}),u.jsx(nT,{}),u.jsx(oT,{})]})})}),{useEmitter:qp,useEmitterValue:lt,usePublisher:nn}=Pp(tT,{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"}},aT),lT=Fp({useEmitter:qp,useEmitterValue:lt,usePublisher:nn}),cT=Bp({useEmitter:qp,useEmitterValue:lt,usePublisher:nn});function Gp(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Ut.WARN),t==="normal"?0:parseInt(t??"0",10)}var zs="Dialog",[Yp,HN]=cn(zs),[uT,hn]=Yp(zs),Xp=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:i=!0}=e,a=h.useRef(null),c=h.useRef(null),[l,d]=On({prop:r,defaultProp:o??!1,onChange:s,caller:zs});return u.jsx(uT,{scope:t,triggerRef:a,contentRef:c,contentId:_t(),titleId:_t(),descriptionId:_t(),open:l,onOpenChange:d,onOpenToggle:h.useCallback(()=>d(f=>!f),[d]),modal:i,children:n})};Xp.displayName=zs;var Jp="DialogTrigger",Zp=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=hn(Jp,n),s=Pe(t,o.triggerRef);return u.jsx(pe.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":nl(o.open),...r,ref:s,onClick:ae(e.onClick,o.onOpenToggle)})});Zp.displayName=Jp;var el="DialogPortal",[dT,Qp]=Yp(el,{forceMount:void 0}),eh=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=hn(el,t);return u.jsx(dT,{scope:t,forceMount:n,children:h.Children.map(r,i=>u.jsx(Ht,{present:n||s.open,children:u.jsx(co,{asChild:!0,container:o,children:i})}))})};eh.displayName=el;var Hs="DialogOverlay",th=h.forwardRef((e,t)=>{const n=Qp(Hs,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=hn(Hs,e.__scopeDialog);return s.modal?u.jsx(Ht,{present:r||s.open,children:u.jsx(pT,{...o,ref:t})}):null});th.displayName=Hs;var fT=qt.createSlot("DialogOverlay.RemoveScroll"),pT=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=hn(Hs,n);return u.jsx(bs,{as:fT,allowPinchZoom:!0,shards:[o.contentRef],children:u.jsx(pe.div,{"data-state":nl(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),ir="DialogContent",nh=h.forwardRef((e,t)=>{const n=Qp(ir,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=hn(ir,e.__scopeDialog);return u.jsx(Ht,{present:r||s.open,children:s.modal?u.jsx(hT,{...o,ref:t}):u.jsx(mT,{...o,ref:t})})});nh.displayName=ir;var hT=h.forwardRef((e,t)=>{const n=hn(ir,e.__scopeDialog),r=h.useRef(null),o=Pe(t,n.contentRef,r);return h.useEffect(()=>{const s=r.current;if(s)return xa(s)},[]),u.jsx(rh,{...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())})}),mT=h.forwardRef((e,t)=>{const n=hn(ir,e.__scopeDialog),r=h.useRef(!1),o=h.useRef(!1);return u.jsx(rh,{...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 c,l;(c=e.onInteractOutside)==null||c.call(e,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const i=s.target;((l=n.triggerRef.current)==null?void 0:l.contains(i))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&o.current&&s.preventDefault()}})}),rh=h.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=hn(ir,n),c=h.useRef(null),l=Pe(t,c);return Gi(),u.jsxs(u.Fragment,{children:[u.jsx(ts,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:u.jsx(Tr,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":nl(a.open),...i,ref:l,onDismiss:()=>a.onOpenChange(!1)})}),u.jsxs(u.Fragment,{children:[u.jsx(gT,{titleId:a.titleId}),u.jsx(vT,{contentRef:c,descriptionId:a.descriptionId})]})]})}),tl="DialogTitle",oh=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=hn(tl,n);return u.jsx(pe.h2,{id:o.titleId,...r,ref:t})});oh.displayName=tl;var sh="DialogDescription",ih=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=hn(sh,n);return u.jsx(pe.p,{id:o.descriptionId,...r,ref:t})});ih.displayName=sh;var ah="DialogClose",lh=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=hn(ah,n);return u.jsx(pe.button,{type:"button",...r,ref:t,onClick:ae(e.onClick,()=>o.onOpenChange(!1))})});lh.displayName=ah;function nl(e){return e?"open":"closed"}var ch="DialogTitleWarning",[UN,uh]=_w(ch,{contentName:ir,titleName:tl,docsSlug:"dialog"}),gT=({titleId:e})=>{const t=uh(ch),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
79
+ `)},v0=0,Or=[];function w0(e){var t=h.useRef([]),n=h.useRef([0,0]),r=h.useRef(),o=h.useState(v0++)[0],s=h.useState(nf)[0],i=h.useRef(e);h.useEffect(function(){i.current=e},[e]),h.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var g=By([e.lockRef.current],(e.shards||[]).map(uf),!0).filter(Boolean);return g.forEach(function(x){return x.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),g.forEach(function(x){return x.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var a=h.useCallback(function(g,x){if("touches"in g&&g.touches.length===2||g.type==="wheel"&&g.ctrlKey)return!i.current.allowPinchZoom;var y=bs(g),b=n.current,T="deltaX"in g?g.deltaX:b[0]-y[0],E="deltaY"in g?g.deltaY:b[1]-y[1],S,C=g.target,k=Math.abs(T)>Math.abs(E)?"h":"v";if("touches"in g&&k==="h"&&C.type==="range")return!1;var A=sf(k,C);if(!A)return!0;if(A?S=k:(S=k==="v"?"h":"v",A=sf(k,C)),!A)return!1;if(!r.current&&"changedTouches"in g&&(T||E)&&(r.current=S),!S)return!0;var j=r.current||S;return m0(j,x,g,j==="h"?T:E)},[]),c=h.useCallback(function(g){var x=g;if(!(!Or.length||Or[Or.length-1]!==s)){var y="deltaY"in x?cf(x):bs(x),b=t.current.filter(function(S){return S.name===x.type&&(S.target===x.target||x.target===S.shadowParent)&&g0(S.delta,y)})[0];if(b&&b.should){x.cancelable&&x.preventDefault();return}if(!b){var T=(i.current.shards||[]).map(uf).filter(Boolean).filter(function(S){return S.contains(x.target)}),E=T.length>0?a(x,T[0]):!i.current.noIsolation;E&&x.cancelable&&x.preventDefault()}}},[]),l=h.useCallback(function(g,x,y,b){var T={name:g,delta:x,target:y,should:b,shadowParent:b0(y)};t.current.push(T),setTimeout(function(){t.current=t.current.filter(function(E){return E!==T})},1)},[]),d=h.useCallback(function(g){n.current=bs(g),r.current=void 0},[]),f=h.useCallback(function(g){l(g.type,cf(g),g.target,a(g,e.lockRef.current))},[]),m=h.useCallback(function(g){l(g.type,bs(g),g.target,a(g,e.lockRef.current))},[]);h.useEffect(function(){return Or.push(s),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:m}),document.addEventListener("wheel",c,Mr),document.addEventListener("touchmove",c,Mr),document.addEventListener("touchstart",d,Mr),function(){Or=Or.filter(function(g){return g!==s}),document.removeEventListener("wheel",c,Mr),document.removeEventListener("touchmove",c,Mr),document.removeEventListener("touchstart",d,Mr)}},[]);var p=e.removeScrollBar,v=e.inert;return h.createElement(h.Fragment,null,v?h.createElement(s,{styles:x0(o)}):null,p?h.createElement(l0,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function b0(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const y0=Yy(tf,w0);var ys=h.forwardRef(function(e,t){return h.createElement(vs,Cn({},e,{ref:t,sideCar:y0}))});ys.classNames=vs.classNames;var Ea=["Enter"," "],S0=["ArrowDown","PageUp","Home"],df=["ArrowUp","PageDown","End"],C0=[...S0,...df],T0={ltr:[...Ea,"ArrowRight"],rtl:[...Ea,"ArrowLeft"]},k0={ltr:["ArrowLeft"],rtl:["ArrowRight"]},fo="Menu",[po,E0,I0]=es(fo),[rr,ff]=cn(fo,[I0,jr,Kd]),Ss=jr(),pf=Kd(),[N0,or]=rr(fo),[A0,ho]=rr(fo),hf=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=Ss(t),[c,l]=h.useState(null),d=h.useRef(!1),f=gt(s),m=ts(o);return h.useEffect(()=>{const p=()=>{d.current=!0,document.addEventListener("pointerdown",v,{capture:!0,once:!0}),document.addEventListener("pointermove",v,{capture:!0,once:!0})},v=()=>d.current=!1;return document.addEventListener("keydown",p,{capture:!0}),()=>{document.removeEventListener("keydown",p,{capture:!0}),document.removeEventListener("pointerdown",v,{capture:!0}),document.removeEventListener("pointermove",v,{capture:!0})}},[]),u.jsx(ha,{...a,children:u.jsx(N0,{scope:t,open:n,onOpenChange:f,content:c,onContentChange:l,children:u.jsx(A0,{scope:t,onClose:h.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:d,dir:m,modal:i,children:r})})})};hf.displayName=fo;var P0="MenuAnchor",Ia=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=Ss(n);return u.jsx(ma,{...o,...r,ref:t})});Ia.displayName=P0;var Na="MenuPortal",[j0,mf]=rr(Na,{forceMount:void 0}),gf=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=or(Na,t);return u.jsx(j0,{scope:t,forceMount:n,children:u.jsx(Ht,{present:n||s.open,children:u.jsx(co,{asChild:!0,container:o,children:r})})})};gf.displayName=Na;var en="MenuContent",[_0,Aa]=rr(en),xf=h.forwardRef((e,t)=>{const n=mf(en,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=or(en,e.__scopeMenu),i=ho(en,e.__scopeMenu);return u.jsx(po.Provider,{scope:e.__scopeMenu,children:u.jsx(Ht,{present:r||s.open,children:u.jsx(po.Slot,{scope:e.__scopeMenu,children:i.modal?u.jsx(R0,{...o,ref:t}):u.jsx(M0,{...o,ref:t})})})})}),R0=h.forwardRef((e,t)=>{const n=or(en,e.__scopeMenu),r=h.useRef(null),o=je(t,r);return h.useEffect(()=>{const s=r.current;if(s)return ya(s)},[]),u.jsx(Pa,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:ae(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),M0=h.forwardRef((e,t)=>{const n=or(en,e.__scopeMenu);return u.jsx(Pa,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),O0=qt.createSlot("MenuContent.ScrollLock"),Pa=h.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEntryFocus:c,onEscapeKeyDown:l,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:m,onDismiss:p,disableOutsideScroll:v,...g}=e,x=or(en,n),y=ho(en,n),b=Ss(n),T=pf(n),E=E0(n),[S,C]=h.useState(null),k=h.useRef(null),A=je(t,k,x.onContentChange),j=h.useRef(0),L=h.useRef(""),B=h.useRef(0),K=h.useRef(null),J=h.useRef("right"),_=h.useRef(0),Y=v?ys:h.Fragment,q=v?{as:O0,allowPinchZoom:!0}:void 0,W=I=>{var O,P;const G=L.current+I,X=E().filter(U=>!U.disabled),M=document.activeElement,z=(O=X.find(U=>U.ref.current===M))==null?void 0:O.textValue,R=X.map(U=>U.textValue),F=q0(R,G,z),H=(P=X.find(U=>U.textValue===F))==null?void 0:P.ref.current;(function U(Q){L.current=Q,window.clearTimeout(j.current),Q!==""&&(j.current=window.setTimeout(()=>U(""),1e3))})(G),H&&setTimeout(()=>H.focus())};h.useEffect(()=>()=>window.clearTimeout(j.current),[]),Zi();const D=h.useCallback(I=>{var X,M;return J.current===((X=K.current)==null?void 0:X.side)&&Y0(I,(M=K.current)==null?void 0:M.area)},[]);return u.jsx(_0,{scope:n,searchRef:L,onItemEnter:h.useCallback(I=>{D(I)&&I.preventDefault()},[D]),onItemLeave:h.useCallback(I=>{var G;D(I)||((G=k.current)==null||G.focus(),C(null))},[D]),onTriggerLeave:h.useCallback(I=>{D(I)&&I.preventDefault()},[D]),pointerGraceTimerRef:B,onPointerGraceIntentChange:h.useCallback(I=>{K.current=I},[]),children:u.jsx(Y,{...q,children:u.jsx(ns,{asChild:!0,trapped:o,onMountAutoFocus:ae(s,I=>{var G;I.preventDefault(),(G=k.current)==null||G.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:u.jsx(Er,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:l,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:m,onDismiss:p,children:u.jsx(Oy,{asChild:!0,...T,dir:y.dir,orientation:"vertical",loop:r,currentTabStopId:S,onCurrentTabStopIdChange:C,onEntryFocus:ae(c,I=>{y.isUsingKeyboardRef.current||I.preventDefault()}),preventScrollOnEntryFocus:!0,children:u.jsx(ga,{role:"menu","aria-orientation":"vertical","data-state":Mf(x.open),"data-radix-menu-content":"",dir:y.dir,...b,...g,ref:A,style:{outline:"none",...g.style},onKeyDown:ae(g.onKeyDown,I=>{const X=I.target.closest("[data-radix-menu-content]")===I.currentTarget,M=I.ctrlKey||I.altKey||I.metaKey,z=I.key.length===1;X&&(I.key==="Tab"&&I.preventDefault(),!M&&z&&W(I.key));const R=k.current;if(I.target!==R||!C0.includes(I.key))return;I.preventDefault();const H=E().filter(O=>!O.disabled).map(O=>O.ref.current);df.includes(I.key)&&H.reverse(),V0(H)}),onBlur:ae(e.onBlur,I=>{I.currentTarget.contains(I.target)||(window.clearTimeout(j.current),L.current="")}),onPointerMove:ae(e.onPointerMove,go(I=>{const G=I.target,X=_.current!==I.clientX;if(I.currentTarget.contains(G)&&X){const M=I.clientX>_.current?"right":"left";J.current=M,_.current=I.clientX}}))})})})})})})});xf.displayName=en;var D0="MenuGroup",ja=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(pe.div,{role:"group",...r,ref:t})});ja.displayName=D0;var L0="MenuLabel",vf=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(pe.div,{...r,ref:t})});vf.displayName=L0;var Cs="MenuItem",wf="menu.itemSelect",Ts=h.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=h.useRef(null),i=ho(Cs,e.__scopeMenu),a=Aa(Cs,e.__scopeMenu),c=je(t,s),l=h.useRef(!1),d=()=>{const f=s.current;if(!n&&f){const m=new CustomEvent(wf,{bubbles:!0,cancelable:!0});f.addEventListener(wf,p=>r==null?void 0:r(p),{once:!0}),Yi(f,m),m.defaultPrevented?l.current=!1:i.onClose()}};return u.jsx(bf,{...o,ref:c,disabled:n,onClick:ae(e.onClick,d),onPointerDown:f=>{var m;(m=e.onPointerDown)==null||m.call(e,f),l.current=!0},onPointerUp:ae(e.onPointerUp,f=>{var m;l.current||(m=f.currentTarget)==null||m.click()}),onKeyDown:ae(e.onKeyDown,f=>{const m=a.searchRef.current!=="";n||m&&f.key===" "||Ea.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});Ts.displayName=Cs;var bf=h.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=Aa(Cs,n),a=pf(n),c=h.useRef(null),l=je(t,c),[d,f]=h.useState(!1),[m,p]=h.useState("");return h.useEffect(()=>{const v=c.current;v&&p((v.textContent??"").trim())},[s.children]),u.jsx(po.ItemSlot,{scope:n,disabled:r,textValue:o??m,children:u.jsx(Dy,{asChild:!0,...a,focusable:!r,children:u.jsx(pe.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:l,onPointerMove:ae(e.onPointerMove,go(v=>{r?i.onItemLeave(v):(i.onItemEnter(v),v.defaultPrevented||v.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:ae(e.onPointerLeave,go(v=>i.onItemLeave(v))),onFocus:ae(e.onFocus,()=>f(!0)),onBlur:ae(e.onBlur,()=>f(!1))})})})}),$0="MenuCheckboxItem",yf=h.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return u.jsx(Ef,{scope:e.__scopeMenu,checked:n,children:u.jsx(Ts,{role:"menuitemcheckbox","aria-checked":ks(n)?"mixed":n,...o,ref:t,"data-state":Ra(n),onSelect:ae(o.onSelect,()=>r==null?void 0:r(ks(n)?!0:!n),{checkForDefaultPrevented:!1})})})});yf.displayName=$0;var Sf="MenuRadioGroup",[F0,B0]=rr(Sf,{value:void 0,onValueChange:()=>{}}),Cf=h.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=gt(r);return u.jsx(F0,{scope:e.__scopeMenu,value:n,onValueChange:s,children:u.jsx(ja,{...o,ref:t})})});Cf.displayName=Sf;var Tf="MenuRadioItem",kf=h.forwardRef((e,t)=>{const{value:n,...r}=e,o=B0(Tf,e.__scopeMenu),s=n===o.value;return u.jsx(Ef,{scope:e.__scopeMenu,checked:s,children:u.jsx(Ts,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":Ra(s),onSelect:ae(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});kf.displayName=Tf;var _a="MenuItemIndicator",[Ef,z0]=rr(_a,{checked:!1}),If=h.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=z0(_a,n);return u.jsx(Ht,{present:r||ks(s.checked)||s.checked===!0,children:u.jsx(pe.span,{...o,ref:t,"data-state":Ra(s.checked)})})});If.displayName=_a;var H0="MenuSeparator",Nf=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(pe.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});Nf.displayName=H0;var U0="MenuArrow",Af=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=Ss(n);return u.jsx(xa,{...o,...r,ref:t})});Af.displayName=U0;var W0="MenuSub",[FN,Pf]=rr(W0),mo="MenuSubTrigger",jf=h.forwardRef((e,t)=>{const n=or(mo,e.__scopeMenu),r=ho(mo,e.__scopeMenu),o=Pf(mo,e.__scopeMenu),s=Aa(mo,e.__scopeMenu),i=h.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:c}=s,l={__scopeMenu:e.__scopeMenu},d=h.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return h.useEffect(()=>d,[d]),h.useEffect(()=>{const f=a.current;return()=>{window.clearTimeout(f),c(null)}},[a,c]),u.jsx(Ia,{asChild:!0,...l,children:u.jsx(bf,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":Mf(n.open),...e,ref:Mn(t,o.onTriggerChange),onClick:f=>{var m;(m=e.onClick)==null||m.call(e,f),!(e.disabled||f.defaultPrevented)&&(f.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:ae(e.onPointerMove,go(f=>{s.onItemEnter(f),!f.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(s.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),d()},100))})),onPointerLeave:ae(e.onPointerLeave,go(f=>{var p,v;d();const m=(p=n.content)==null?void 0:p.getBoundingClientRect();if(m){const g=(v=n.content)==null?void 0:v.dataset.side,x=g==="right",y=x?-5:5,b=m[x?"left":"right"],T=m[x?"right":"left"];s.onPointerGraceIntentChange({area:[{x:f.clientX+y,y:f.clientY},{x:b,y:m.top},{x:T,y:m.top},{x:T,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(f),f.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:ae(e.onKeyDown,f=>{var p;const m=s.searchRef.current!=="";e.disabled||m&&f.key===" "||T0[r.dir].includes(f.key)&&(n.onOpenChange(!0),(p=n.content)==null||p.focus(),f.preventDefault())})})})});jf.displayName=mo;var _f="MenuSubContent",Rf=h.forwardRef((e,t)=>{const n=mf(en,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=or(en,e.__scopeMenu),i=ho(en,e.__scopeMenu),a=Pf(_f,e.__scopeMenu),c=h.useRef(null),l=je(t,c);return u.jsx(po.Provider,{scope:e.__scopeMenu,children:u.jsx(Ht,{present:r||s.open,children:u.jsx(po.Slot,{scope:e.__scopeMenu,children:u.jsx(Pa,{id:a.contentId,"aria-labelledby":a.triggerId,...o,ref:l,align:"start",side:i.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:d=>{var f;i.isUsingKeyboardRef.current&&((f=c.current)==null||f.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 p;const f=d.currentTarget.contains(d.target),m=k0[i.dir].includes(d.key);f&&m&&(s.onOpenChange(!1),(p=a.trigger)==null||p.focus(),d.preventDefault())})})})})})});Rf.displayName=_f;function Mf(e){return e?"open":"closed"}function ks(e){return e==="indeterminate"}function Ra(e){return ks(e)?"indeterminate":e?"checked":"unchecked"}function V0(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function K0(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function q0(e,t,n){const o=t.length>1&&Array.from(t).every(l=>l===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=K0(e,Math.max(s,0));o.length===1&&(i=i.filter(l=>l!==n));const c=i.find(l=>l.toLowerCase().startsWith(o.toLowerCase()));return c!==n?c:void 0}function G0(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],c=t[i],l=a.x,d=a.y,f=c.x,m=c.y;d>r!=m>r&&n<(f-l)*(r-d)/(m-d)+l&&(o=!o)}return o}function Y0(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return G0(n,t)}function go(e){return t=>t.pointerType==="mouse"?e(t):void 0}var X0=hf,J0=Ia,Z0=gf,Q0=xf,eS=ja,tS=vf,nS=Ts,rS=yf,oS=Cf,sS=kf,iS=If,aS=Nf,lS=Af,cS=jf,uS=Rf,Es="DropdownMenu",[dS,BN]=cn(Es,[ff]),Lt=ff(),[fS,Of]=dS(Es),Df=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,c=Lt(t),l=h.useRef(null),[d,f]=On({prop:o,defaultProp:s??!1,onChange:i,caller:Es});return u.jsx(fS,{scope:t,triggerId:_t(),triggerRef:l,contentId:_t(),open:d,onOpenChange:f,onOpenToggle:h.useCallback(()=>f(m=>!m),[f]),modal:a,children:u.jsx(X0,{...c,open:d,onOpenChange:f,dir:r,modal:a,children:n})})};Df.displayName=Es;var Lf="DropdownMenuTrigger",$f=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=Of(Lf,n),i=Lt(n);return u.jsx(J0,{asChild:!0,...i,children:u.jsx(pe.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())})})})});$f.displayName=Lf;var pS="DropdownMenuPortal",Ff=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Lt(t);return u.jsx(Z0,{...r,...n})};Ff.displayName=pS;var Bf="DropdownMenuContent",zf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Of(Bf,n),s=Lt(n),i=h.useRef(!1);return u.jsx(Q0,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:ae(e.onCloseAutoFocus,a=>{var c;i.current||(c=o.triggerRef.current)==null||c.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:ae(e.onInteractOutside,a=>{const c=a.detail.originalEvent,l=c.button===0&&c.ctrlKey===!0,d=c.button===2||l;(!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)"}})});zf.displayName=Bf;var hS="DropdownMenuGroup",mS=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Lt(n);return u.jsx(eS,{...o,...r,ref:t})});mS.displayName=hS;var gS="DropdownMenuLabel",Hf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Lt(n);return u.jsx(tS,{...o,...r,ref:t})});Hf.displayName=gS;var xS="DropdownMenuItem",Uf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Lt(n);return u.jsx(nS,{...o,...r,ref:t})});Uf.displayName=xS;var vS="DropdownMenuCheckboxItem",Wf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Lt(n);return u.jsx(rS,{...o,...r,ref:t})});Wf.displayName=vS;var wS="DropdownMenuRadioGroup",bS=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Lt(n);return u.jsx(oS,{...o,...r,ref:t})});bS.displayName=wS;var yS="DropdownMenuRadioItem",Vf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Lt(n);return u.jsx(sS,{...o,...r,ref:t})});Vf.displayName=yS;var SS="DropdownMenuItemIndicator",Kf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Lt(n);return u.jsx(iS,{...o,...r,ref:t})});Kf.displayName=SS;var CS="DropdownMenuSeparator",qf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Lt(n);return u.jsx(aS,{...o,...r,ref:t})});qf.displayName=CS;var TS="DropdownMenuArrow",kS=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Lt(n);return u.jsx(lS,{...o,...r,ref:t})});kS.displayName=TS;var ES="DropdownMenuSubTrigger",Gf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Lt(n);return u.jsx(cS,{...o,...r,ref:t})});Gf.displayName=ES;var IS="DropdownMenuSubContent",Yf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Lt(n);return u.jsx(uS,{...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)"}})});Yf.displayName=IS;var NS=Df,AS=$f,PS=Ff,Xf=zf,Jf=Hf,Zf=Uf,Qf=Wf,ep=Vf,tp=Kf,np=qf,rp=Gf,op=Yf;const Is=NS,Ns=AS,jS=h.forwardRef(({className:e,inset:t,children:n,...r},o)=>u.jsxs(rp,{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"})]}));jS.displayName=rp.displayName;const _S=h.forwardRef(({className:e,...t},n)=>u.jsx(op,{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}));_S.displayName=op.displayName;const xo=h.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(PS,{children:u.jsx(Xf,{ref:r,sideOffset:t,className:ne("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n})}));xo.displayName=Xf.displayName;const Fn=h.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(Zf,{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=Zf.displayName;const RS=h.forwardRef(({className:e,children:t,checked:n,...r},o)=>u.jsxs(Qf,{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(tp,{children:u.jsx(le.Check,{className:"h-4 w-4"})})}),t]}));RS.displayName=Qf.displayName;const MS=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(ep,{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(tp,{children:u.jsx(le.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));MS.displayName=ep.displayName;const OS=h.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(Jf,{ref:r,className:ne("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));OS.displayName=Jf.displayName;const DS=h.forwardRef(({className:e,...t},n)=>u.jsx(np,{ref:n,className:ne("-mx-1 my-1 h-px bg-muted",e),...t}));DS.displayName=np.displayName;const Ma=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}));Ma.displayName="Textarea";const LS=1e4;function sp({initialValue:e="",editingMessageId:t=null,placeholder:n="Type your message...",isStreaming:r=!1,disabled:o=!1,maxLength:s=LS,value:i,onValueChange:a,onSend:c,onCancelEdit:l,onStop:d,className:f="",textareaClassName:m="",allowEmptySend:p=!1,sendButtonClassName:v,validate:g,onValidationError:x}){const y=i!==void 0,[b,T]=w.useState(e),E=(y?i:b)??"",[S,C]=w.useTransition(),k=w.useRef(null),A=w.useRef(0),j=w.useRef(null),L=w.useRef("");w.useEffect(()=>{y||(T(e??""),j.current=null,k.current&&(k.current.style.height="auto",k.current.style.height=`${k.current.scrollHeight}px`))},[e,t,y]);const[B,K]=w.useState(null),J=w.useCallback(R=>R.length>s?`Message too long (${R.length}/${s} characters)`:null,[s]),_=w.useMemo(()=>g??J,[g,J]),Y=w.useCallback(R=>{const F=_(R);return K(F),x==null||x(F),L.current=R,F},[_,x]),q=w.useCallback(()=>{const R=k.current;R&&(R.style.height="auto",R.style.height=`${R.scrollHeight}px`)},[]);w.useEffect(()=>{q()},[q,E]),w.useEffect(()=>{if(!B)return;const R=(E??"").trim();L.current!==R&&Y(R)},[E,B,Y]);const W=w.useCallback((R,{fromUser:F})=>{y||T(R),F&&(a==null||a(R))},[y,a]),D=w.useCallback(async R=>{R&&R.preventDefault();const F=(E??"").trim();if(!F&&!p||Y(F))return;const H=++A.current;j.current={id:H,shouldClear:!0},C(()=>{var O,P,U;try{const Q=c(F);Q&&typeof Q.then=="function"?Q.then(()=>{var se,ie;((se=j.current)==null?void 0:se.id)===H&&j.current.shouldClear&&(y||(T(""),k.current&&(k.current.style.height="auto"),a==null||a(""))),((ie=j.current)==null?void 0:ie.id)===H&&(j.current=null)}).catch(()=>{var se;((se=j.current)==null?void 0:se.id)===H&&(j.current=null)}):(((O=j.current)==null?void 0:O.id)===H&&j.current.shouldClear&&(y||(T(""),k.current&&(k.current.style.height="auto"),a==null||a(""))),((P=j.current)==null?void 0:P.id)===H&&(j.current=null))}catch{((U=j.current)==null?void 0:U.id)===H&&(j.current=null)}})},[E,c,p,y,a,Y]),I=w.useCallback(R=>{const F=R.target.value;W(F,{fromUser:!0}),j.current&&(j.current.shouldClear=!1),k.current&&(k.current.style.height="auto",k.current.style.height=`${k.current.scrollHeight}px`),B&&Y(F.trim())},[W,Y,B]),G=w.useCallback(R=>{R.key==="Enter"&&!R.shiftKey?(R.preventDefault(),D()):R.key==="Escape"&&t&&(R.preventDefault(),l==null||l())},[D,t,l]),z=`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:R=>void D(R),className:`w-full ${f}`,children:u.jsxs("div",{className:"flex items-end gap-2",children:[u.jsxs("div",{className:"flex-1",children:[u.jsx(Ma,{ref:k,value:E,onChange:I,onKeyDown:G,placeholder:t?"Edit your message...":n,className:z,disabled:o,maxLength:s,rows:1,spellCheck:!1,autoCorrect:"off"}),B&&u.jsx("p",{className:"mt-1 text-xs text-destructive font-medium",children:B})]}),u.jsx("div",{children:r?u.jsx(Je,{type:"button",onClick:()=>{d==null||d()},size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",disabled:o||!d,children:u.jsx(le.Square,{size:16})}):u.jsx(Je,{type:"submit",size:"icon",className:`shrink-0 ${v??""}`,title:t?"Save changes":"Send message",disabled:o||!E.trim()&&!p||S,children:u.jsx(le.Send,{size:16})})})]})})}const $S=w.memo(sp);function ip({composerValue:e,onComposerChange:t,onSend:n,onCancelEdit:r,onStop:o,editingMessageId:s=null,editingInitialValue:i="",placeholder:a="Type your message...",isStreaming:c=!1,disabled:l=!1,textareaClassName:d="",customStyles:f={},enableFileUpload:m=!1,enableExcelUpload:p=!1,onExcelUpload:v,onError:g,allowEmptySend:x=!1,inputError:y=null}){const[b,T]=w.useState([]),E=w.useRef(null),S=w.useRef(null),[C,k]=w.useState(0),[A,j]=w.useState(0),[L,B]=w.useState(!1),[K,J]=w.useState(null),[_,Y]=w.useState(null),q=w.useCallback(()=>{E.current&&(E.current.value=""),S.current&&(S.current.value=""),k(R=>R+1),j(R=>R+1)},[]),W=w.useCallback(R=>{T(F=>[...F,...R])},[]),D=w.useCallback(R=>{const F=Array.from(R.target.files||[]);W(F),R.target.value=""},[W]),I=w.useCallback(R=>{T(F=>{const H=F.filter((O,P)=>P!==R);return H.length===0&&q(),H})},[q]),G=w.useCallback(async R=>{const F=(R.target.files||[])[0];if(F&&(J(null),Y(null),!!v)){B(!0);try{await v(F),J(`Uploaded ${F.name} - processing through chat stream`)}catch(H){const O=H instanceof Error?H.message:"Failed to upload Excel file";Y(O),g==null||g(O)}finally{B(!1),R.target.value="",q()}}},[v,g,q]),X=w.useMemo(()=>x||b.length>0,[x,b]),M=w.useCallback(async R=>{const H=await n(R,b);return b.length>0&&(T([]),q()),H},[n,q,b]),z=`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${s?"border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50":""} ${y?"border-red-400":""} ${f.textarea||""} ${d}`;return u.jsxs(u.Fragment,{children:[(m||p)&&u.jsxs("div",{className:"mb-3 space-y-3",children:[m&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:E,type:"file",multiple:!0,onChange:D,className:"hidden"},C),b.length>0&&u.jsx("div",{className:"flex flex-wrap gap-2",children:b.map((R,F)=>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:R.name}),u.jsx(Je,{variant:"ghost",size:"sm",onClick:()=>I(F),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 ${R.name}`,children:u.jsx(le.X,{size:12})})]},F))})]}),p&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:S,type:"file",accept:".xls,.xlsx,.xlsm",onChange:G,className:"hidden"},A),L&&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..."]}),K&&!L&&u.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:K}),_&&!L&&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||p)&&u.jsxs(Is,{children:[u.jsx(Ns,{asChild:!0,children:u.jsx(Je,{type:"button",size:"icon",variant:"outline",disabled:c||l,title:"More input actions",className:f.moreButton||"",children:u.jsx(le.Plus,{size:16})})}),u.jsxs(xo,{align:"start",sideOffset:6,className:"w-52",children:[m&&u.jsxs(Fn,{onClick:()=>{var R;return(R=E.current)==null?void 0:R.click()},className:"cursor-pointer",children:[u.jsx(le.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),p&&u.jsxs(Fn,{onClick:()=>{var R;L||(R=S.current)==null||R.click()},className:`cursor-pointer ${L?"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($S,{initialValue:i,editingMessageId:s,value:e,onValueChange:t,placeholder:s?"Edit your message...":a,isStreaming:c,disabled:l,onSend:M,onCancelEdit:r,onStop:o,allowEmptySend:X,textareaClassName:z,sendButtonClassName:f.sendButton})})]})]})}const FS=w.memo(ip),As=0,Bn=1,Dr=2,ap=4;function lp(e){return()=>e}function BS(e){e()}function cp(e,t){return n=>e(t(n))}function up(e,t){return()=>e(t)}function zS(e,t){return n=>e(t,n)}function Oa(e){return e!==void 0}function HS(...e){return()=>{e.map(BS)}}function Lr(){}function Ps(e,t){return t(e),e}function US(e,t){return t(e)}function st(...e){return e}function Ze(e,t){return e(Bn,t)}function Ne(e,t){e(As,t)}function Da(e){e(Dr)}function xt(e){return e(ap)}function he(e,t){return Ze(e,zS(t,As))}function fn(e,t){const n=e(Bn,r=>{n(),t(r)});return n}function dp(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function fp(e,t){return e===t}function it(e=fp){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function ye(e){return t=>n=>{e(n)&&t(n)}}function ce(e){return t=>cp(t,e)}function Tn(e){return t=>()=>{t(e)}}function ee(e,...t){const n=WS(...t);return(r,o)=>{switch(r){case Dr:Da(e);return;case Bn:return Ze(e,n(o))}}}function kn(e,t){return n=>r=>{n(t=e(t,r))}}function sr(e){return t=>n=>{e>0?e--:t(n)}}function jn(e){let t=null,n;return r=>o=>{t=o,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function _e(...e){const t=new Array(e.length);let n=0,r=null;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const a=Math.pow(2,i);Ze(s,c=>{const l=n;n=n|a,t[i]=c,l!==o&&n===o&&r&&(r(),r=null)})}),s=>i=>{const a=()=>{s([i].concat(t))};n===o?a():r=a}}function WS(...e){return t=>e.reduceRight(US,t)}function VS(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(),Lr);case Dr:r(),n=null;return}}}function oe(e){let t=e;const n=ze();return(r,o)=>{switch(r){case As:t=o;break;case Bn:{o(t);break}case ap:return t}return n(r,o)}}function Rt(e,t){return Ps(oe(t),n=>he(e,n))}function ze(){const e=[];return(t,n)=>{switch(t){case As:e.slice().forEach(r=>{r(n)});return;case Dr:e.splice(0,e.length);return;case Bn:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}}}function Zt(e){return Ps(ze(),t=>he(e,t))}function qe(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:KS(),singleton:n}}const KS=()=>Symbol();function qS(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(c=>n(c)));return i&&t.set(s,a),a};return n(e)}function wt(...e){const t=ze(),n=new Array(e.length);let r=0;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const a=Math.pow(2,i);Ze(s,c=>{n[i]=c,r=r|a,r===o&&Ne(t,n)})}),function(s,i){switch(s){case Dr:{Da(t);return}case Bn:return r===o&&i(n),Ze(t,i)}}}function be(e,t=fp){return ee(e,it(t))}function La(...e){return function(t,n){switch(t){case Dr:return;case Bn:return HS(...e.map(r=>Ze(r,n)))}}}var Ut=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(Ut||{});const GS={0:"debug",3:"error",1:"log",2:"warn"},YS=()=>typeof globalThis>"u"?window:globalThis,zn=qe(()=>{const e=oe(3);return{log:oe((t,n,r=1)=>{var o;const s=(o=YS().VIRTUOSO_LOG_LEVEL)!=null?o:xt(e);r>=s&&console[GS[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0});function ir(e,t,n){return $a(e,t,n).callbackRef}function $a(e,t,n){const r=w.useRef(null);let o=i=>{};const s=w.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(i=>{const a=()=>{const c=i[0].target;c.offsetParent!==null&&e(c)};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 XS(e,t,n,r,o,s,i,a,c){const l=w.useCallback(d=>{const f=JS(d.children,t,a?"offsetWidth":"offsetHeight",o);let m=d.parentElement;for(;!m.dataset.virtuosoScroller;)m=m.parentElement;const p=m.lastElementChild.dataset.viewportType==="window";let v;p&&(v=m.ownerDocument.defaultView);const g=i?a?i.scrollLeft:i.scrollTop:p?a?v.scrollX||v.document.documentElement.scrollLeft:v.scrollY||v.document.documentElement.scrollTop:a?m.scrollLeft:m.scrollTop,x=i?a?i.scrollWidth:i.scrollHeight:p?a?v.document.documentElement.scrollWidth:v.document.documentElement.scrollHeight:a?m.scrollWidth:m.scrollHeight,y=i?a?i.offsetWidth:i.offsetHeight:p?a?v.innerWidth:v.innerHeight:a?m.offsetWidth:m.offsetHeight;r({scrollHeight:x,scrollTop:Math.max(g,0),viewportHeight:y}),s==null||s(a?pp("column-gap",getComputedStyle(d).columnGap,o):pp("row-gap",getComputedStyle(d).rowGap,o)),f!==null&&e(f)},[e,t,o,s,i,r,a]);return $a(l,n,c)}function JS(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 c=parseInt(a.dataset.index),l=parseFloat(a.dataset.knownSize),d=t(a,n);if(d===0&&r("Zero-sized element, this should not happen",{child:a},Ut.ERROR),d===l)continue;const f=s[s.length-1];s.length===0||f.size!==d||f.endIndex!==c-1?s.push({endIndex:c,size:d,startIndex:c}):s[s.length-1].endIndex++}return s}function pp(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Ut.WARN),t==="normal"?0:parseInt(t??"0",10)}function hp(e,t,n){const r=w.useRef(null),o=w.useCallback(c=>{if(!(c!=null&&c.offsetParent))return;const l=c.getBoundingClientRect(),d=l.width;let f,m;if(t){const p=t.getBoundingClientRect(),v=l.top-p.top;m=p.height-Math.max(0,v),f=v+t.scrollTop}else{const p=i.current.ownerDocument.defaultView;m=p.innerHeight-Math.max(0,l.top),f=l.top+p.scrollY}r.current={offsetTop:f,visibleHeight:m,visibleWidth:d},e(r.current)},[e,t]),{callbackRef:s,ref:i}=$a(o,!0,n),a=w.useCallback(()=>{o(i.current)},[o,i]);return w.useEffect(()=>{var c;if(t){t.addEventListener("scroll",a);const l=new ResizeObserver(()=>{requestAnimationFrame(a)});return l.observe(t),()=>{t.removeEventListener("scroll",a),l.unobserve(t)}}else{const l=(c=i.current)==null?void 0:c.ownerDocument.defaultView;return l==null||l.addEventListener("scroll",a),l==null||l.addEventListener("resize",a),()=>{l==null||l.removeEventListener("scroll",a),l==null||l.removeEventListener("resize",a)}}},[a,t,i]),s}const $t=qe(()=>{const e=ze(),t=ze(),n=oe(0),r=ze(),o=oe(0),s=ze(),i=ze(),a=oe(0),c=oe(0),l=oe(0),d=oe(0),f=ze(),m=ze(),p=oe(!1),v=oe(!1),g=oe(!1);return he(ee(e,ce(({scrollTop:x})=>x)),t),he(ee(e,ce(({scrollHeight:x})=>x)),i),he(t,o),{deviation:n,fixedFooterHeight:l,fixedHeaderHeight:c,footerHeight:d,headerHeight:a,horizontalDirection:v,scrollBy:m,scrollContainerState:e,scrollHeight:i,scrollingInProgress:p,scrollTo:f,scrollTop:t,skipAnimationFrameInResizeObserver:g,smoothScrollTargetReached:r,statefulScrollTop:o,viewportHeight:s}},[],{singleton:!0}),vo={lvl:0};function mp(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:c}=t(e[i]);s.push({end:a-1,start:r,value:o}),r=a,o=c}return s.push({end:1/0,start:r,value:o}),s}function et(e){return e===vo}function wo(e,t){if(!et(e))return t===e.k?e.v:t<e.k?wo(e.l,t):wo(e.r,t)}function pn(e,t,n="k"){if(et(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){const r=pn(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return pn(e.l,t,n)}function Qt(e,t,n){return et(e)?vp(t,n,1):t===e.k?St(e,{k:t,v:n}):t<e.k?wp(St(e,{l:Qt(e.l,t,n)})):wp(St(e,{r:Qt(e.r,t,n)}))}function $r(){return vo}function js(e,t,n){if(et(e))return[];const r=pn(e,t)[0];return ZS(Ba(e,r,n))}function Fa(e,t){if(et(e))return vo;const{k:n,l:r,r:o}=e;if(t===n){if(et(r))return o;if(et(o))return r;{const[s,i]=xp(r);return _s(St(e,{k:s,l:gp(r),v:i}))}}else return t<n?_s(St(e,{l:Fa(r,t)})):_s(St(e,{r:Fa(o,t)}))}function ar(e){return et(e)?[]:[...ar(e.l),{k:e.k,v:e.v},...ar(e.r)]}function Ba(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(Ba(o,t,n))),r>=t&&r<=n&&a.push({k:r,v:i}),r<=n&&(a=a.concat(Ba(s,t,n))),a}function _s(e){const{l:t,lvl:n,r}=e;if(r.lvl>=n-1&&t.lvl>=n-1)return e;if(n>r.lvl+1){if(za(t))return bp(St(e,{lvl:n-1}));if(!et(t)&&!et(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(za(e))return Ha(St(e,{lvl:n-1}));if(!et(r)&&!et(r.l)){const o=r.l,s=za(o)?r.lvl-1:r.lvl;return St(o,{l:St(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:Ha(St(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function St(e,t){return vp(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 gp(e){return et(e.r)?e.l:_s(St(e,{r:gp(e.r)}))}function za(e){return et(e)||e.lvl>e.r.lvl}function xp(e){return et(e.r)?[e.k,e.v]:xp(e.r)}function vp(e,t,n,r=vo,o=vo){return{k:e,l:r,lvl:n,r:o,v:t}}function wp(e){return Ha(bp(e))}function bp(e){const{l:t}=e;return!et(t)&&t.lvl===e.lvl?St(t,{r:St(e,{l:t.r})}):e}function Ha(e){const{lvl:t,r:n}=e;return!et(n)&&!et(n.r)&&n.lvl===t&&n.r.lvl===t?St(n,{l:St(e,{r:n.l}),lvl:t+1}):e}function ZS(e){return mp(e,({k:t,v:n})=>({index:t,value:n}))}function yp(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function bo(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const Ua=qe(()=>({recalcInProgress:oe(!1)}),[],{singleton:!0});function Sp(e,t,n){return e[Rs(e,t,n)]}function Rs(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 QS(e,t,n,r){const o=Rs(e,t,r),s=Rs(e,n,r,o);return e.slice(o,s+1)}function Hn(e,t){return Math.round(e.getBoundingClientRect()[t])}function Ms(e){return!et(e.groupOffsetTree)}function Wa({index:e},t){return t===e?0:t<e?-1:1}function eC(){return{groupIndices:[],groupOffsetTree:$r(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:$r()}}function tC(e,t){let n=et(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),et(e)){e=Qt(e,0,s);continue}const a=js(e,i-1,o+1);if(a.some(lC(r)))continue;let c=!1,l=!1;for(const{end:d,start:f,value:m}of a)c?(o>=f||s===m)&&(e=Fa(e,f)):(l=m!==s,c=!0),d>o&&o>=f&&m!==s&&(e=Qt(e,o+1,m));l&&(e=Qt(e,i,s))}return[e,n]}function nC(e){return typeof e.groupIndex<"u"}function rC({offset:e},t){return t===e?0:t<e?-1:1}function yo(e,t,n){if(t.length===0)return 0;const{index:r,offset:o,size:s}=Sp(t,e,Wa),i=e-r,a=s*i+(i-1)*n+o;return a>0?a+n:a}function Cp(e,t){if(!Ms(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function Tp(e,t,n){if(nC(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 oC(e,t,n,r=0){return r>0&&(t=Math.max(t,Sp(e,r,Wa).offset)),mp(QS(e,t,n,rC),aC)}function sC(e,[t,n,r,o]){t.length>0&&r("received item sizes",t,Ut.DEBUG);const s=e.sizeTree;let i=s,a=0;if(n.length>0&&et(s)&&t.length===2){const m=t[0].size,p=t[1].size;i=n.reduce((v,g)=>Qt(Qt(v,g,m),g+1,p),i)}else[i,a]=tC(i,t);if(i===s)return e;const{lastIndex:c,lastOffset:l,lastSize:d,offsetTree:f}=Va(e.offsetTree,a,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((m,p)=>Qt(m,p,yo(p,f,o)),$r()),lastIndex:c,lastOffset:l,lastSize:d,offsetTree:f,sizeTree:i}}function iC(e){return ar(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 kp(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 Va(e,t,n,r){let o=e,s=0,i=0,a=0,c=0;if(t!==0){c=Rs(o,t-1,Wa),a=o[c].offset;const l=pn(n,t-1);s=l[0],i=l[1],o.length&&o[c].size===pn(n,t)[1]&&(c-=1),o=o.slice(0,c+1)}else o=[];for(const{start:l,value:d}of js(n,t,1/0)){const f=l-s,m=f*i+a+f*r;o.push({index:l,offset:m,size:d}),s=l,a=m,i=d}return{lastIndex:s,lastOffset:a,lastSize:i,offsetTree:o}}function aC(e){return{index:e.index,value:e}}function lC(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 cC={offsetHeight:"height",offsetWidth:"width"},En=qe(([{log:e},{recalcInProgress:t}])=>{const n=ze(),r=ze(),o=Rt(r,0),s=ze(),i=ze(),a=oe(0),c=oe([]),l=oe(void 0),d=oe(void 0),f=oe((S,C)=>Hn(S,cC[C])),m=oe(void 0),p=oe(0),v=eC(),g=Rt(ee(n,_e(c,e,p),kn(sC,v),it()),v),x=Rt(ee(c,it(),kn((S,C)=>({current:C,prev:S.current}),{current:[],prev:[]}),ce(({prev:S})=>S)),[]);he(ee(c,ye(S=>S.length>0),_e(g,p),ce(([S,C,k])=>{const A=S.reduce((j,L,B)=>Qt(j,L,yo(L,C.offsetTree,k)||B),$r());return{...C,groupIndices:S,groupOffsetTree:A}})),g),he(ee(r,_e(g),ye(([S,{lastIndex:C}])=>S<C),ce(([S,{lastIndex:C,lastSize:k}])=>[{endIndex:C,size:k,startIndex:S}])),n),he(l,d);const y=Rt(ee(l,ce(S=>S===void 0)),!0);he(ee(d,ye(S=>S!==void 0&&et(xt(g).sizeTree)),ce(S=>[{endIndex:0,size:S,startIndex:0}])),n);const b=Zt(ee(n,_e(g),kn(({sizes:S},[C,k])=>({changed:k!==S,sizes:k}),{changed:!1,sizes:v}),ce(S=>S.changed)));Ze(ee(a,kn((S,C)=>({diff:S.prev-C,prev:C}),{diff:0,prev:0}),ce(S=>S.diff)),S=>{const{groupIndices:C}=xt(g);if(S>0)Ne(t,!0),Ne(s,S+kp(S,C));else if(S<0){const k=xt(x);k.length>0&&(S-=kp(-S,k)),Ne(i,S)}}),Ze(ee(a,_e(e)),([S,C])=>{S<0&&C("`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},Ut.ERROR)});const T=Zt(s);he(ee(s,_e(g),ce(([S,C])=>{const k=C.groupIndices.length>0,A=[],j=C.lastSize;if(k){const L=wo(C.sizeTree,0);let B=0,K=0;for(;B<S;){const _=C.groupIndices[K],Y=C.groupIndices.length===K+1?1/0:C.groupIndices[K+1]-_-1;A.push({endIndex:_,size:L,startIndex:_}),A.push({endIndex:_+1+Y-1,size:j,startIndex:_+1}),K++,B+=Y+1}const J=ar(C.sizeTree);return B!==S&&J.shift(),J.reduce((_,{k:Y,v:q})=>{let W=_.ranges;return _.prevSize!==0&&(W=[..._.ranges,{endIndex:Y+S-1,size:_.prevSize,startIndex:_.prevIndex}]),{prevIndex:Y+S,prevSize:q,ranges:W}},{prevIndex:S,prevSize:0,ranges:A}).ranges}return ar(C.sizeTree).reduce((L,{k:B,v:K})=>({prevIndex:B+S,prevSize:K,ranges:[...L.ranges,{endIndex:B+S-1,size:L.prevSize,startIndex:L.prevIndex}]}),{prevIndex:0,prevSize:j,ranges:[]}).ranges})),n);const E=Zt(ee(i,_e(g,p),ce(([S,{offsetTree:C},k])=>{const A=-S;return yo(A,C,k)})));return he(ee(i,_e(g,p),ce(([S,C,k])=>{if(C.groupIndices.length>0){if(et(C.sizeTree))return C;let A=$r();const j=xt(x);let L=0,B=0,K=0;for(;L<-S;){K=j[B];const J=j[B+1]-K-1;B++,L+=J+1}if(A=ar(C.sizeTree).reduce((J,{k:_,v:Y})=>Qt(J,Math.max(0,_+S),Y),A),L!==-S){const J=wo(C.sizeTree,K);A=Qt(A,0,J);const _=pn(C.sizeTree,-S+1)[1];A=Qt(A,1,_)}return{...C,sizeTree:A,...Va(C.offsetTree,0,A,k)}}else{const A=ar(C.sizeTree).reduce((j,{k:L,v:B})=>Qt(j,Math.max(0,L+S),B),$r());return{...C,sizeTree:A,...Va(C.offsetTree,0,A,k)}}})),g),{beforeUnshiftWith:T,data:m,defaultItemSize:d,firstItemIndex:a,fixedItemSize:l,gap:p,groupIndices:c,itemSize:f,listRefresh:b,shiftWith:i,shiftWithOffset:E,sizeRanges:n,sizes:g,statefulTotalCount:o,totalCount:r,trackItemSizes:y,unshiftWith:s}},st(zn,Ua),{singleton:!0});function uC(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const Ep=qe(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=ze(),i=ze(),a=Zt(ee(s,ce(uC)));return he(ee(a,ce(c=>c.totalCount)),n),he(ee(a,ce(c=>c.groupIndices)),e),he(ee(wt(o,t,r),ye(([c,l])=>Ms(l)),ce(([c,l,d])=>pn(l.groupOffsetTree,Math.max(c-d,0),"v")[0]),it(),ce(c=>[c])),i),{groupCounts:s,topItemsIndexes:i}},st(En,$t)),Un=qe(([{log:e}])=>{const t=oe(!1),n=Zt(ee(t,ye(r=>r),it()));return Ze(t,r=>{r&&xt(e)("props updated",{},Ut.DEBUG)}),{didMount:n,propsReady:t}},st(zn),{singleton:!0}),dC=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function Ip(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!dC)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const So=qe(([{gap:e,listRefresh:t,sizes:n,totalCount:r},{fixedFooterHeight:o,fixedHeaderHeight:s,footerHeight:i,headerHeight:a,scrollingInProgress:c,scrollTo:l,smoothScrollTargetReached:d,viewportHeight:f},{log:m}])=>{const p=ze(),v=ze(),g=oe(0);let x=null,y=null,b=null;function T(){x&&(x(),x=null),b&&(b(),b=null),y&&(clearTimeout(y),y=null),Ne(c,!1)}return he(ee(p,_e(n,f,r,g,a,i,m),_e(e,s,o),ce(([[E,S,C,k,A,j,L,B],K,J,_])=>{const Y=Ip(E),{align:q,behavior:W,offset:D}=Y,I=k-1,G=Tp(Y,S,I);let X=yo(G,S.offsetTree,K)+j;q==="end"?(X+=J+pn(S.sizeTree,G)[1]-C+_,G===I&&(X+=L)):q==="center"?X+=(J+pn(S.sizeTree,G)[1]-C+_)/2:X-=A,D&&(X+=D);const M=z=>{T(),z?(B("retrying to scroll to",{location:E},Ut.DEBUG),Ne(p,E)):(Ne(v,!0),B("list did not change, scroll successful",{},Ut.DEBUG))};if(T(),W==="smooth"){let z=!1;b=Ze(t,R=>{z=z||R}),x=fn(d,()=>{M(z)})}else x=fn(ee(t,fC(150)),M);return y=setTimeout(()=>{T()},1200),Ne(c,!0),B("scrolling from index to",{behavior:W,index:G,top:X},Ut.DEBUG),{behavior:W,top:X}})),l),{scrollTargetReached:v,scrollToIndex:p,topListHeight:g}},st(En,$t,zn),{singleton:!0});function fC(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function Ka(e,t){e==0?t():requestAnimationFrame(()=>{Ka(e-1,t)})}function qa(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const Co=qe(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:s},{didMount:i}])=>{const a=oe(!0),c=oe(0),l=oe(!0);return he(ee(i,_e(c),ye(([d,f])=>!!f),Tn(!1)),a),he(ee(i,_e(c),ye(([d,f])=>!!f),Tn(!1)),l),Ze(ee(wt(t,i),_e(a,n,e,l),ye(([[,d],f,{sizeTree:m},p,v])=>d&&(!et(m)||Oa(p))&&!f&&!v),_e(c)),([,d])=>{fn(o,()=>{Ne(l,!0)}),Ka(4,()=>{fn(r,()=>{Ne(a,!0)}),Ne(s,d)})}),{initialItemFinalLocationReached:l,initialTopMostItemIndex:c,scrolledToInitialItem:a}},st(En,$t,So,Un),{singleton:!0});function Np(e,t){return Math.abs(e-t)<1.01}const To="up",ko="down",pC="none",hC={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},mC=0,Eo=qe(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=oe(!1),a=oe(!0),c=ze(),l=ze(),d=oe(4),f=oe(mC),m=Rt(ee(La(ee(be(o),sr(1),Tn(!0)),ee(be(o),sr(1),Tn(!1),dp(100))),it()),!1),p=Rt(ee(La(ee(n,Tn(!0)),ee(n,Tn(!1),dp(200))),it()),!1);he(ee(wt(be(o),be(f)),ce(([b,T])=>b<=T),it()),a),he(ee(a,jn(50)),l);const v=Zt(ee(wt(r,be(s),be(t),be(e),be(d)),kn((b,[{scrollHeight:T,scrollTop:E},S,C,k,A])=>{const j=E+S-T>-A,L={scrollHeight:T,scrollTop:E,viewportHeight:S};if(j){let K,J;return E>b.state.scrollTop?(K="SCROLLED_DOWN",J=b.state.scrollTop-E):(K="SIZE_DECREASED",J=b.state.scrollTop-E||b.scrollTopDelta),{atBottom:!0,atBottomBecause:K,scrollTopDelta:J,state:L}}let B;return L.scrollHeight>b.state.scrollHeight?B="SIZE_INCREASED":S<b.state.viewportHeight?B="VIEWPORT_HEIGHT_DECREASING":E<b.state.scrollTop?B="SCROLLING_UPWARDS":B="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:B,state:L}},hC),it((b,T)=>b&&b.atBottom===T.atBottom))),g=Rt(ee(r,kn((b,{scrollHeight:T,scrollTop:E,viewportHeight:S})=>{if(Np(b.scrollHeight,T))return{changed:!1,jump:0,scrollHeight:T,scrollTop:E};{const C=T-(E+S)<1;return b.scrollTop!==E&&C?{changed:!0,jump:b.scrollTop-E,scrollHeight:T,scrollTop:E}:{changed:!0,jump:0,scrollHeight:T,scrollTop:E}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),ye(b=>b.changed),ce(b=>b.jump)),0);he(ee(v,ce(b=>b.atBottom)),i),he(ee(i,jn(50)),c);const x=oe(ko);he(ee(r,ce(({scrollTop:b})=>b),it(),kn((b,T)=>xt(p)?{direction:b.direction,prevScrollTop:T}:{direction:T<b.prevScrollTop?To:ko,prevScrollTop:T},{direction:ko,prevScrollTop:0}),ce(b=>b.direction)),x),he(ee(r,jn(50),Tn(pC)),x);const y=oe(0);return he(ee(m,ye(b=>!b),Tn(0)),y),he(ee(o,jn(100),_e(m),ye(([b,T])=>!!T),kn(([b,T],[E])=>[T,E],[0,0]),ce(([b,T])=>T-b)),y),{atBottomState:v,atBottomStateChange:c,atBottomThreshold:d,atTopStateChange:l,atTopThreshold:f,isAtBottom:i,isAtTop:a,isScrolling:m,lastJumpDueToItemResize:g,scrollDirection:x,scrollVelocity:y}},st($t)),Os="top",Ds="bottom",Ap="none";function Pp(e,t,n){return typeof e=="number"?n===To&&t===Os||n===ko&&t===Ds?e:0:n===To?t===Os?e.main:e.reverse:t===Ds?e.main:e.reverse}function jp(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const Ga=qe(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=ze(),i=oe(0),a=oe(0),c=oe(0),l=Rt(ee(wt(be(r),be(o),be(n),be(s,bo),be(c),be(i),be(t),be(e),be(a)),ce(([d,f,m,[p,v],g,x,y,b,T])=>{const E=d-b,S=x+y,C=Math.max(m-E,0);let k=Ap;const A=jp(T,Os),j=jp(T,Ds);return p-=b,p+=m+y,v+=m+y,v-=b,p>d+S-A&&(k=To),v<d-C+f+j&&(k=ko),k!==Ap?[Math.max(E-m-Pp(g,Os,k)-A,0),E-C-y+f+Pp(g,Ds,k)+j]:null}),ye(d=>d!=null),it(bo)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:c,topListHeight:i,visibleRange:l}},st($t),{singleton:!0});function gC(e,t,n){if(Ms(t)){const r=Cp(e,t);return[{index:pn(t.groupOffsetTree,r)[0],offset:0,size:0},{data:n==null?void 0:n[0],index:r,offset:0,size:0}]}return[{data:n==null?void 0:n[0],index:e,offset:0,size:0}]}const Ya={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Ls(e,t,n,r,o,s){const{lastIndex:i,lastOffset:a,lastSize:c}=o;let l=0,d=0;if(e.length>0){l=e[0].offset;const g=e[e.length-1];d=g.offset+g.size}const f=n-i,m=a+f*c+(f-1)*r,p=l,v=m-d;return{bottom:d,firstItemIndex:s,items:Rp(e,o,s),offsetBottom:v,offsetTop:l,top:p,topItems:Rp(t,o,s),topListHeight:t.reduce((g,x)=>x.size+g,0),totalCount:n}}function _p(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,c=qa(t,a),l=Array.from({length:a}).map((d,f)=>({data:s[f+c],index:f+c,offset:0,size:0}));return Ls(l,[],a,o,n,r)}function Rp(e,t,n){if(e.length===0)return[];if(!Ms(t))return e.map(l=>({...l,index:l.index+n,originalIndex:l.index}));const r=e[0].index,o=e[e.length-1].index,s=[],i=js(t.groupOffsetTree,r,o);let a,c=0;for(const l of e){(!a||a.end<l.index)&&(a=i.shift(),c=t.groupIndices.indexOf(a.start));let d;l.index===a.start?d={index:c,type:"group"}:d={groupIndex:c,index:l.index-(c+1)+n},s.push({...d,data:l.data,offset:l.offset,originalIndex:l.index,size:l.size})}return s}const lr=qe(([{data:e,firstItemIndex:t,gap:n,sizes:r,totalCount:o},s,{listBoundary:i,topListHeight:a,visibleRange:c},{initialTopMostItemIndex:l,scrolledToInitialItem:d},{topListHeight:f},m,{didMount:p},{recalcInProgress:v}])=>{const g=oe([]),x=oe(0),y=ze();he(s.topItemsIndexes,g);const b=Rt(ee(wt(p,v,be(c,bo),be(o),be(r),be(l),d,be(g),be(t),be(n),e),ye(([C,k,,A,,,,,,,j])=>{const L=j&&j.length!==A;return C&&!k&&!L}),ce(([,,[C,k],A,j,L,B,K,J,_,Y])=>{const q=j,{offsetTree:W,sizeTree:D}=q,I=xt(x);if(A===0)return{...Ya,totalCount:A};if(C===0&&k===0)return I===0?{...Ya,totalCount:A}:_p(I,L,j,J,_,Y||[]);if(et(D))return I>0?null:Ls(gC(qa(L,A),q,Y),[],A,_,q,J);const G=[];if(K.length>0){const F=K[0],H=K[K.length-1];let O=0;for(const P of js(D,F,H)){const U=P.value,Q=Math.max(P.start,F),se=Math.min(P.end,H);for(let ie=Q;ie<=se;ie++)G.push({data:Y==null?void 0:Y[ie],index:ie,offset:O,size:U}),O+=U}}if(!B)return Ls([],G,A,_,q,J);const X=K.length>0?K[K.length-1]+1:0,M=oC(W,C,k,X);if(M.length===0)return null;const z=A-1,R=Ps([],F=>{for(const H of M){const O=H.value;let P=O.offset,U=H.start;const Q=O.size;if(O.offset<C){U+=Math.floor((C-O.offset+_)/(Q+_));const ie=U-H.start;P+=ie*Q+ie*_}U<X&&(P+=(X-U)*Q,U=X);const se=Math.min(H.end,z);for(let ie=U;ie<=se&&!(P>=k);ie++)F.push({data:Y==null?void 0:Y[ie],index:ie,offset:P,size:Q}),P+=Q+_}});return Ls(R,G,A,_,q,J)}),ye(C=>C!==null),it()),Ya);he(ee(e,ye(Oa),ce(C=>C==null?void 0:C.length)),o),he(ee(b,ce(C=>C.topListHeight)),f),he(f,a),he(ee(b,ce(C=>[C.top,C.bottom])),i),he(ee(b,ce(C=>C.items)),y);const T=Zt(ee(b,ye(({items:C})=>C.length>0),_e(o,e),ye(([{items:C},k])=>C[C.length-1].originalIndex===k-1),ce(([,C,k])=>[C-1,k]),it(bo),ce(([C])=>C))),E=Zt(ee(b,jn(200),ye(({items:C,topItems:k})=>C.length>0&&C[0].originalIndex===k.length),ce(({items:C})=>C[0].index),it())),S=Zt(ee(b,ye(({items:C})=>C.length>0),ce(({items:C})=>{let k=0,A=C.length-1;for(;C[k].type==="group"&&k<A;)k++;for(;C[A].type==="group"&&A>k;)A--;return{endIndex:C[A].index,startIndex:C[k].index}}),it(yp)));return{endReached:T,initialItemCount:x,itemsRendered:y,listState:b,rangeChanged:S,startReached:E,topItemsIndexes:g,...m}},st(En,Ep,Ga,Co,So,Eo,Un,Ua),{singleton:!0}),Mp=qe(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=ze(),i=Rt(ee(wt(n,e,r,t,o),ce(([a,c,l,d,f])=>a+c+l+d+f.offsetBottom+f.bottom)),0);return he(be(i),s),{totalListHeight:i,totalListHeightChanged:s}},st($t,lr),{singleton:!0}),xC=qe(([{viewportHeight:e},{totalListHeight:t}])=>{const n=oe(!1),r=Rt(ee(wt(n,e,t),ye(([o])=>o),ce(([,o,s])=>Math.max(0,o-s)),jn(0),it()),0);return{alignToBottom:n,paddingTopAddition:r}},st($t,Mp),{singleton:!0}),Op=qe(()=>({context:oe(null)})),vC=({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,Dp=qe(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:s,scrollingInProgress:i,scrollTop:a,viewportHeight:c},{scrollToIndex:l}])=>{const d=ze();return he(ee(d,_e(t,c,n,s,o,r,a),_e(e),ce(([[f,m,p,v,g,x,y,b],T])=>{const{align:E,behavior:S,calculateViewLocation:C=vC,done:k,...A}=f,j=Tp(f,m,v-1),L=yo(j,m.offsetTree,T)+g+x,B=L+pn(m.sizeTree,j)[1],K=b+x,J=b+p-y,_=C({itemBottom:B,itemTop:L,locationParams:{align:E,behavior:S,...A},viewportBottom:J,viewportTop:K});return _?k&&fn(ee(i,ye(Y=>!Y),sr(xt(i)?1:2)),k):k&&k(),_}),ye(f=>f!==null)),l),{scrollIntoView:d}},st(En,$t,So,lr,zn),{singleton:!0});function Lp(e){return e?e==="smooth"?"smooth":"auto":!1}const wC=(e,t)=>typeof e=="function"?Lp(e(t)):t&&Lp(e),bC=qe(([{listRefresh:e,totalCount:t,fixedItemSize:n,data:r},{atBottomState:o,isAtBottom:s},{scrollToIndex:i},{scrolledToInitialItem:a},{didMount:c,propsReady:l},{log:d},{scrollingInProgress:f},{context:m},{scrollIntoView:p}])=>{const v=oe(!1),g=ze();let x=null;function y(S){Ne(i,{align:"end",behavior:S,index:"LAST"})}Ze(ee(wt(ee(be(t),sr(1)),c),_e(be(v),s,a,f),ce(([[S,C],k,A,j,L])=>{let B=C&&j,K="auto";return B&&(K=wC(k,A||L),B=B&&!!K),{followOutputBehavior:K,shouldFollow:B,totalCount:S}}),ye(({shouldFollow:S})=>S)),({followOutputBehavior:S,totalCount:C})=>{x&&(x(),x=null),xt(n)?requestAnimationFrame(()=>{xt(d)("following output to ",{totalCount:C},Ut.DEBUG),y(S)}):x=fn(e,()=>{xt(d)("following output to ",{totalCount:C},Ut.DEBUG),y(S),x=null})});function b(S){const C=fn(o,k=>{S&&!k.atBottom&&k.notAtBottomBecause==="SIZE_INCREASED"&&!x&&(xt(d)("scrolling to bottom due to increased size",{},Ut.DEBUG),y("auto"))});setTimeout(C,100)}Ze(ee(wt(be(v),t,l),ye(([S,,C])=>S&&C),kn(({value:S},[,C])=>({refreshed:S===C,value:C}),{refreshed:!1,value:0}),ye(({refreshed:S})=>S),_e(v,t)),([,S])=>{xt(a)&&b(S!==!1)}),Ze(g,()=>{b(xt(v)!==!1)}),Ze(wt(be(v),o),([S,C])=>{S&&!C.atBottom&&C.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&y("auto")});const T=oe(null),E=ze();return he(La(ee(be(r),ce(S=>{var C;return(C=S==null?void 0:S.length)!=null?C:0})),ee(be(t))),E),Ze(ee(wt(ee(E,sr(1)),c),_e(be(T),a,f,m),ce(([[S,C],k,A,j,L])=>C&&A&&(k==null?void 0:k({context:L,totalCount:S,scrollingInProgress:j}))),ye(S=>!!S),jn(0)),S=>{x&&(x(),x=null),xt(n)?requestAnimationFrame(()=>{xt(d)("scrolling into view",{}),Ne(p,S)}):x=fn(e,()=>{xt(d)("scrolling into view",{}),Ne(p,S),x=null})}),{autoscrollToBottom:g,followOutput:v,scrollIntoViewOnChange:T}},st(En,Eo,So,Co,Un,zn,$t,Op,Dp)),yC=qe(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(he(ee(a,_e(s),ye(([,c])=>c!==0),_e(o,r,t,n,e),ce(([[,c],l,d,f,m,p=[]])=>_p(c,l,d,f,m,p))),i),{}),st(En,Co,lr,Un),{singleton:!0}),SC=qe(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=oe(0);return Ze(ee(e,_e(r),ye(([,o])=>o!==0),ce(([,o])=>({top:o}))),o=>{fn(ee(n,sr(1),ye(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{Ne(t,o)})})}),{initialScrollTop:r}},st(Un,$t,lr),{singleton:!0}),$p=qe(([{scrollVelocity:e}])=>{const t=oe(!1),n=ze(),r=oe(!1);return he(ee(e,_e(r,t,n),ye(([o,s])=>!!s),ce(([o,s,i,a])=>{const{enter:c,exit:l}=s;if(i){if(l(o,a))return!1}else if(c(o,a))return!0;return i}),it()),t),Ze(ee(wt(t,e,n),_e(r)),([[o,s,i],a])=>{o&&a&&a.change&&a.change(s,i)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},st(Eo),{singleton:!0}),Xa=qe(([{scrollContainerState:e,scrollTo:t}])=>{const n=ze(),r=ze(),o=ze(),s=oe(!1),i=oe(void 0);return he(ee(wt(n,r),ce(([{scrollHeight:a,scrollTop:c,viewportHeight:l},{offsetTop:d}])=>({scrollHeight:a,scrollTop:Math.max(0,c-d),viewportHeight:l}))),e),he(ee(t,_e(r),ce(([a,{offsetTop:c}])=>({...a,top:a.top+c}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},st($t)),CC=qe(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:a,windowViewportRect:c}])=>{const l=ze(),d=oe(void 0),f=oe(null),m=oe(null);return he(a,f),he(c,m),Ze(ee(l,_e(t,r,i,f,m,n)),([p,v,g,x,y,b,T])=>{const E=iC(v.sizeTree);x&&y!==null&&b!==null&&(g=y.scrollTop-b.offsetTop),g-=T,p({ranges:E,scrollTop:g})}),he(ee(d,ye(Oa),ce(TC)),o),he(ee(s,_e(d),ye(([,p])=>p!==void 0),it(),ce(([,p])=>p.ranges)),e),{getState:l,restoreStateFrom:d}},st(En,$t,Co,Un,Xa));function TC(e){return{align:"start",index:0,offset:e.scrollTop}}const kC=qe(([{topItemsIndexes:e}])=>{const t=oe(0);return he(ee(t,ye(n=>n>=0),ce(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},st(lr));function Fp(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const EC=Fp(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),IC=qe(([{deviation:e,scrollBy:t,scrollingInProgress:n,scrollTop:r},{isAtBottom:o,isScrolling:s,lastJumpDueToItemResize:i,scrollDirection:a},{listState:c},{beforeUnshiftWith:l,gap:d,shiftWithOffset:f,sizes:m},{log:p},{recalcInProgress:v}])=>{const g=Zt(ee(c,_e(i),kn(([,y,b,T],[{bottom:E,items:S,offsetBottom:C,totalCount:k},A])=>{const j=E+C;let L=0;return b===k&&y.length>0&&S.length>0&&(S[0].originalIndex===0&&y[0].originalIndex===0||(L=j-T,L!==0&&(L+=A))),[L,S,k,j]},[0,[],0,0]),ye(([y])=>y!==0),_e(r,a,n,o,p,v),ye(([,y,b,T,,,E])=>!E&&!T&&y!==0&&b===To),ce(([[y],,,,,b])=>(b("Upward scrolling compensation",{amount:y},Ut.DEBUG),y))));function x(y){y>0?(Ne(t,{behavior:"auto",top:-y}),Ne(e,0)):(Ne(e,0),Ne(t,{behavior:"auto",top:-y}))}return Ze(ee(g,_e(e,s)),([y,b,T])=>{T&&EC()?Ne(e,b-y):x(-y)}),Ze(ee(wt(Rt(s,!1),e,v),ye(([y,b,T])=>!y&&!T&&b!==0),ce(([y,b])=>b),jn(1)),x),he(ee(f,ce(y=>({top:-y}))),t),Ze(ee(l,_e(m,d),ce(([y,{groupIndices:b,lastSize:T,sizeTree:E},S])=>{function C(k){return k*(T+S)}if(b.length===0)return C(y);{let k=0;const A=wo(E,0);let j=0,L=0;for(;j<y;){j++,k+=A;let B=b.length===L+1?1/0:b[L+1]-b[L]-1;j+B>y&&(k-=A,B=y-j+1),j+=B,k+=C(B),L++}return k}})),y=>{Ne(e,y),requestAnimationFrame(()=>{Ne(t,{top:y}),requestAnimationFrame(()=>{Ne(e,0),Ne(v,!1)})})}),{deviation:e}},st($t,Eo,lr,En,zn,Ua)),NC=qe(([e,t,n,r,o,s,i,a,c,l,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...c,...l,...d}),st(Ga,yC,Un,$p,Mp,SC,xC,Xa,Dp,zn,Op)),Bp=qe(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:r,gap:o,groupIndices:s,itemSize:i,sizeRanges:a,sizes:c,statefulTotalCount:l,totalCount:d,trackItemSizes:f},{initialItemFinalLocationReached:m,initialTopMostItemIndex:p,scrolledToInitialItem:v},g,x,y,{listState:b,topItemsIndexes:T,...E},{scrollToIndex:S},C,{topItemCount:k},{groupCounts:A},j])=>(he(E.rangeChanged,j.scrollSeekRangeChanged),he(ee(j.windowViewportRect,ce(L=>L.visibleHeight)),g.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,gap:o,groupCounts:A,initialItemFinalLocationReached:m,initialTopMostItemIndex:p,scrolledToInitialItem:v,sizeRanges:a,topItemCount:k,topItemsIndexes:T,totalCount:d,...y,groupIndices:s,itemSize:i,listState:b,scrollToIndex:S,statefulTotalCount:l,trackItemSizes:f,...E,...j,...g,sizes:c,...x}),st(En,Co,$t,CC,bC,lr,So,IC,kC,Ep,NC));function AC(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 $s=typeof document<"u"?w.useLayoutEffect:w.useEffect;function zp(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 c(x,y){x.propsReady&&Ne(x.propsReady,!1);for(const b of r){const T=x[t.required[b]];Ne(T,y[b])}for(const b of o)if(b in y){const T=x[t.optional[b]];Ne(T,y[b])}x.propsReady&&Ne(x.propsReady,!0)}function l(x){return s.reduce((y,b)=>(y[b]=T=>{const E=x[t.methods[b]];Ne(E,T)},y),{})}function d(x){return i.reduce((y,b)=>(y[b]=VS(x[t.events[b]]),y),{})}const f=w.forwardRef((x,y)=>{const{children:b,...T}=x,[E]=w.useState(()=>Ps(qS(e),k=>{c(k,T)})),[S]=w.useState(up(d,E));$s(()=>{for(const k of i)k in T&&Ze(S[k],T[k]);return()=>{Object.values(S).map(Da)}},[T,S,E]),$s(()=>{c(E,T)}),w.useImperativeHandle(y,lp(l(E)));const C=n;return u.jsx(a.Provider,{value:E,children:n?u.jsx(C,{...AC([...r,...o,...i],T),children:b}):b})}),m=x=>{const y=w.useContext(a);return w.useCallback(b=>{Ne(y[x],b)},[y,x])},p=x=>{const y=w.useContext(a)[x],b=w.useCallback(T=>Ze(y,T),[y]);return w.useSyncExternalStore(b,()=>xt(y),()=>xt(y))},v=x=>{const y=w.useContext(a)[x],[b,T]=w.useState(up(xt,y));return $s(()=>Ze(y,E=>{E!==b&&T(lp(E))}),[y,b]),b},g=w.version.startsWith("18")?p:v;return{Component:f,useEmitter:(x,y)=>{const b=w.useContext(a)[x];$s(()=>Ze(b,y),[y,b])},useEmitterValue:g,usePublisher:m}}const Hp=w.createContext(void 0),Up=w.createContext(void 0),Wp=typeof document<"u"?w.useLayoutEffect:w.useEffect;function Ja(e){return"self"in e}function PC(e){return"body"in e}function Vp(e,t,n,r=Lr,o,s){const i=w.useRef(null),a=w.useRef(null),c=w.useRef(null),l=w.useCallback(m=>{let p,v,g;const x=m.target;if(PC(x)||Ja(x)){const b=Ja(x)?x:x.defaultView;g=s?b.scrollX:b.scrollY,p=s?b.document.documentElement.scrollWidth:b.document.documentElement.scrollHeight,v=s?b.innerWidth:b.innerHeight}else g=s?x.scrollLeft:x.scrollTop,p=s?x.scrollWidth:x.scrollHeight,v=s?x.offsetWidth:x.offsetHeight;const y=()=>{e({scrollHeight:p,scrollTop:Math.max(g,0),viewportHeight:v})};m.suppressFlushSync?y():Lo.flushSync(y),a.current!==null&&(g===a.current||g<=0||g===p-v)&&(a.current=null,t(!0),c.current&&(clearTimeout(c.current),c.current=null))},[e,t,s]);w.useEffect(()=>{const m=o||i.current;return r(o||i.current),l({suppressFlushSync:!0,target:m}),m.addEventListener("scroll",l,{passive:!0}),()=>{r(null),m.removeEventListener("scroll",l)}},[i,l,n,r,o]);function d(m){const p=i.current;if(!p||(s?"offsetWidth"in p&&p.offsetWidth===0:"offsetHeight"in p&&p.offsetHeight===0))return;const v=m.behavior==="smooth";let g,x,y;Ja(p)?(x=Math.max(Hn(p.document.documentElement,s?"width":"height"),s?p.document.documentElement.scrollWidth:p.document.documentElement.scrollHeight),g=s?p.innerWidth:p.innerHeight,y=s?window.scrollX:window.scrollY):(x=p[s?"scrollWidth":"scrollHeight"],g=Hn(p,s?"width":"height"),y=p[s?"scrollLeft":"scrollTop"]);const b=x-g;if(m.top=Math.ceil(Math.max(Math.min(b,m.top),0)),Np(g,x)||m.top===y){e({scrollHeight:x,scrollTop:y,viewportHeight:g}),v&&t(!0);return}v?(a.current=m.top,c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{c.current=null,a.current=null,t(!0)},1e3)):a.current=null,s&&(m={behavior:m.behavior,left:m.top}),p.scrollTo(m)}function f(m){s&&(m={behavior:m.behavior,left:m.top}),i.current.scrollBy(m)}return{scrollByCallback:f,scrollerRef:i,scrollToCallback:d}}const Za="-webkit-sticky",Kp="sticky",Qa=Fp(()=>{if(typeof document>"u")return Kp;const e=document.createElement("div");return e.style.position=Za,e.style.position===Za?Za:Kp});function el(e){return e}const jC=qe(()=>{const e=oe(a=>`Item ${a}`),t=oe(a=>`Group ${a}`),n=oe({}),r=oe(el),o=oe("div"),s=oe(Lr),i=(a,c=null)=>Rt(ee(n,ce(l=>l[a]),it()),c);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")}}),_C=qe(([e,t])=>({...e,...t}),st(Bp,jC)),RC=({height:e})=>u.jsx("div",{style:{height:e}}),MC={overflowAnchor:"none",position:Qa(),zIndex:1},qp={overflowAnchor:"none"},OC={...qp,display:"inline-block",height:"100%"},Gp=w.memo(function({showTopList:e=!1}){const t=Ce("listState"),n=tn("sizeRanges"),r=Ce("useWindowScroll"),o=Ce("customScrollParent"),s=tn("windowScrollContainerState"),i=tn("scrollContainerState"),a=o||r?s:i,c=Ce("itemContent"),l=Ce("context"),d=Ce("groupContent"),f=Ce("trackItemSizes"),m=Ce("itemSize"),p=Ce("log"),v=tn("gap"),g=Ce("horizontalDirection"),{callbackRef:x}=XS(n,m,f,e?Lr:a,p,v,o,g,Ce("skipAnimationFrameInResizeObserver")),[y,b]=w.useState(0);tl("deviation",_=>{y!==_&&b(_)});const T=Ce("EmptyPlaceholder"),E=Ce("ScrollSeekPlaceholder")||RC,S=Ce("ListComponent"),C=Ce("ItemComponent"),k=Ce("GroupComponent"),A=Ce("computeItemKey"),j=Ce("isSeeking"),L=Ce("groupIndices").length>0,B=Ce("alignToBottom"),K=Ce("initialItemFinalLocationReached"),J=e?{}:{boxSizing:"border-box",...g?{display:"inline-block",height:"100%",marginLeft:y!==0?y:B?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:y!==0?y:B?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...K?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&T?u.jsx(T,{...Mt(T,l)}):u.jsx(S,{...Mt(S,l),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:x,style:J,children:(e?t.topItems:t.items).map(_=>{const Y=_.originalIndex,q=A(Y+t.firstItemIndex,_.data,l);return j?w.createElement(E,{...Mt(E,l),height:_.size,index:_.index,key:q,type:_.type||"item",..._.type==="group"?{}:{groupIndex:_.groupIndex}}):_.type==="group"?w.createElement(k,{...Mt(k,l),"data-index":Y,"data-item-index":_.index,"data-known-size":_.size,key:q,style:MC},d(_.index,l)):w.createElement(C,{...Mt(C,l),...FC(C,_.data),"data-index":Y,"data-item-group-index":_.groupIndex,"data-item-index":_.index,"data-known-size":_.size,key:q,style:g?OC:qp},L?c(_.index,_.groupIndex,_.data,l):c(_.index,_.data,l))})})}),DC={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},LC={outline:"none",overflowX:"auto",position:"relative"},Fs=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),$C={position:Qa(),top:0,width:"100%",zIndex:1};function Mt(e,t){if(typeof e!="string")return{context:t}}function FC(e,t){return{item:typeof e=="string"?void 0:t}}const BC=w.memo(function(){const e=Ce("HeaderComponent"),t=tn("headerHeight"),n=Ce("HeaderFooterTag"),r=ir(w.useMemo(()=>s=>{t(Hn(s,"height"))},[t]),!0,Ce("skipAnimationFrameInResizeObserver")),o=Ce("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Mt(e,o)})}):null}),zC=w.memo(function(){const e=Ce("FooterComponent"),t=tn("footerHeight"),n=Ce("HeaderFooterTag"),r=ir(w.useMemo(()=>s=>{t(Hn(s,"height"))},[t]),!0,Ce("skipAnimationFrameInResizeObserver")),o=Ce("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Mt(e,o)})}):null});function Yp({useEmitter:e,useEmitterValue:t,usePublisher:n}){return w.memo(function({children:r,style:o,context:s,...i}){const a=n("scrollContainerState"),c=t("ScrollerComponent"),l=n("smoothScrollTargetReached"),d=t("scrollerRef"),f=t("horizontalDirection")||!1,{scrollByCallback:m,scrollerRef:p,scrollToCallback:v}=Vp(a,l,c,d,void 0,f);return e("scrollTo",v),e("scrollBy",m),u.jsx(c,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:p,style:{...f?LC:DC,...o},tabIndex:0,...i,...Mt(c,s),children:r})})}function Xp({useEmitter:e,useEmitterValue:t,usePublisher:n}){return w.memo(function({children:r,style:o,context:s,...i}){const a=n("windowScrollContainerState"),c=t("ScrollerComponent"),l=n("smoothScrollTargetReached"),d=t("totalListHeight"),f=t("deviation"),m=t("customScrollParent"),p=w.useRef(null),v=t("scrollerRef"),{scrollByCallback:g,scrollerRef:x,scrollToCallback:y}=Vp(a,l,c,v,m);return Wp(()=>{var b;return x.current=m||((b=p.current)==null?void 0:b.ownerDocument.defaultView),()=>{x.current=null}},[x,m]),e("windowScrollTo",y),e("scrollBy",g),u.jsx(c,{ref:p,"data-virtuoso-scroller":!0,style:{position:"relative",...o,...d!==0?{height:d+f}:{}},...i,...Mt(c,s),children:r})})}const HC=({children:e})=>{const t=w.useContext(Hp),n=tn("viewportHeight"),r=tn("fixedItemHeight"),o=Ce("alignToBottom"),s=Ce("horizontalDirection"),i=w.useMemo(()=>cp(n,c=>Hn(c,s?"width":"height")),[n,s]),a=ir(i,!0,Ce("skipAnimationFrameInResizeObserver"));return w.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),u.jsx("div",{"data-viewport-type":"element",ref:a,style:Fs(o),children:e})},UC=({children:e})=>{const t=w.useContext(Hp),n=tn("windowViewportRect"),r=tn("fixedItemHeight"),o=Ce("customScrollParent"),s=hp(n,o,Ce("skipAnimationFrameInResizeObserver")),i=Ce("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:Fs(i),children:e})},WC=({children:e})=>{const t=Ce("TopItemListComponent")||"div",n=Ce("headerHeight"),r={...$C,marginTop:`${n}px`},o=Ce("context");return u.jsx(t,{style:r,...Mt(t,o),children:e})},VC=w.memo(function(e){const t=Ce("useWindowScroll"),n=Ce("topItemsIndexes").length>0,r=Ce("customScrollParent"),o=Ce("context");return u.jsxs(r||t?GC:qC,{...e,context:o,children:[n&&u.jsx(WC,{children:u.jsx(Gp,{showTopList:!0})}),u.jsxs(r||t?UC:HC,{children:[u.jsx(BC,{}),u.jsx(Gp,{}),u.jsx(zC,{})]})]})}),{Component:KC,useEmitter:tl,useEmitterValue:Ce,usePublisher:tn}=zp(_C,{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"}},VC),qC=Yp({useEmitter:tl,useEmitterValue:Ce,usePublisher:tn}),GC=Xp({useEmitter:tl,useEmitterValue:Ce,usePublisher:tn}),YC=KC;st(Bp,qe(()=>{const e=oe(l=>u.jsxs("td",{children:["Item $",l]})),t=oe(null),n=oe(l=>u.jsxs("td",{colSpan:1e3,children:["Group ",l]})),r=oe(null),o=oe(null),s=oe({}),i=oe(el),a=oe(Lr),c=(l,d=null)=>Rt(ee(s,ce(f=>f[l]),it()),d);return{components:s,computeItemKey:i,context:t,EmptyPlaceholder:c("EmptyPlaceholder"),FillerRow:c("FillerRow"),fixedFooterContent:o,fixedHeaderContent:r,itemContent:e,groupContent:n,ScrollerComponent:c("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:c("ScrollSeekPlaceholder"),TableBodyComponent:c("TableBody","tbody"),TableComponent:c("Table","table"),TableFooterComponent:c("TableFoot","tfoot"),TableHeadComponent:c("TableHead","thead"),TableRowComponent:c("TableRow","tr"),GroupComponent:c("Group","tr")}})),Qa();const Jp={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},XC={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:Zp,floor:Bs,max:Io,min:nl,round:Qp}=Math;function eh(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function JC(e){return{...XC,items:e}}function zs(e,t){return e&&e.width===t.width&&e.height===t.height}function ZC(e,t){return e&&e.column===t.column&&e.row===t.row}const QC=qe(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:r},{footerHeight:o,headerHeight:s,scrollBy:i,scrollContainerState:a,scrollTo:c,scrollTop:l,smoothScrollTargetReached:d,viewportHeight:f},m,p,{didMount:v,propsReady:g},{customScrollParent:x,useWindowScroll:y,windowScrollContainerState:b,windowScrollTo:T,windowViewportRect:E},S])=>{const C=oe(0),k=oe(0),A=oe(Jp),j=oe({height:0,width:0}),L=oe({height:0,width:0}),B=ze(),K=ze(),J=oe(0),_=oe(null),Y=oe({column:0,row:0}),q=ze(),W=ze(),D=oe(!1),I=oe(0),G=oe(!0),X=oe(!1),M=oe(!1);Ze(ee(v,_e(I),ye(([P,U])=>!!U)),()=>{Ne(G,!1)}),Ze(ee(wt(v,G,L,j,I,X),ye(([P,U,Q,se,,ie])=>P&&!U&&Q.height!==0&&se.height!==0&&!ie)),([,,,,P])=>{Ne(X,!0),Ka(1,()=>{Ne(B,P)}),fn(ee(l),()=>{Ne(t,[0,0]),Ne(G,!0)})}),he(ee(W,ye(P=>P!=null&&P.scrollTop>0),Tn(0)),k),Ze(ee(v,_e(W),ye(([,P])=>P!=null)),([,P])=>{P&&(Ne(j,P.viewport),Ne(L,P.item),Ne(Y,P.gap),P.scrollTop>0&&(Ne(D,!0),fn(ee(l,sr(1)),U=>{Ne(D,!1)}),Ne(c,{top:P.scrollTop})))}),he(ee(j,ce(({height:P})=>P)),f),he(ee(wt(be(j,zs),be(L,zs),be(Y,(P,U)=>P&&P.column===U.column&&P.row===U.row),be(l)),ce(([P,U,Q,se])=>({gap:Q,item:U,scrollTop:se,viewport:P}))),q),he(ee(wt(be(C),r,be(Y,ZC),be(L,zs),be(j,zs),be(_),be(k),be(D),be(G),be(I)),ye(([,,,,,,,P])=>!P),ce(([P,[U,Q],se,ie,Se,xe,Re,,Ve,De])=>{const{column:Ge,row:He}=se,{height:ot,width:ut}=ie,{width:nt}=Se;if(Re===0&&(P===0||nt===0))return Jp;if(ut===0){const It=qa(De,P),bt=It+Math.max(Re-1,0);return JC(eh(It,bt,xe))}const Le=th(nt,ut,Ge);let Ke,$e;Ve?U===0&&Q===0&&Re>0?(Ke=0,$e=Re-1):(Ke=Le*Bs((U+He)/(ot+He)),$e=Le*Zp((Q+He)/(ot+He))-1,$e=nl(P-1,Io($e,Le-1)),Ke=nl($e,Io(0,Ke))):(Ke=0,$e=-1);const Te=eh(Ke,$e,xe),{bottom:Ae,top:dt}=nh(Se,se,ie,Te),Et=Zp(P/Le),at=Et*ot+(Et-1)*He-Ae;return{bottom:Ae,itemHeight:ot,items:Te,itemWidth:ut,offsetBottom:at,offsetTop:dt,top:dt}})),A),he(ee(_,ye(P=>P!==null),ce(P=>P.length)),C),he(ee(wt(j,L,A,Y),ye(([P,U,{items:Q}])=>Q.length>0&&U.height!==0&&P.height!==0),ce(([P,U,{items:Q},se])=>{const{bottom:ie,top:Se}=nh(P,se,U,Q);return[Se,ie]}),it(bo)),t);const z=oe(!1);he(ee(l,_e(z),ce(([P,U])=>U||P!==0)),z);const R=Zt(ee(wt(A,C),ye(([{items:P}])=>P.length>0),_e(z),ye(([[P,U],Q])=>{const se=P.items[P.items.length-1].index===U-1;return(Q||P.bottom>0&&P.itemHeight>0&&P.offsetBottom===0&&P.items.length===U)&&se}),ce(([[,P]])=>P-1),it())),F=Zt(ee(be(A),ye(({items:P})=>P.length>0&&P[0].index===0),Tn(0),it())),H=Zt(ee(be(A),_e(D),ye(([{items:P},U])=>P.length>0&&!U),ce(([{items:P}])=>({endIndex:P[P.length-1].index,startIndex:P[0].index})),it(yp),jn(0)));he(H,p.scrollSeekRangeChanged),he(ee(B,_e(j,L,C,Y),ce(([P,U,Q,se,ie])=>{const Se=Ip(P),{align:xe,behavior:Re,offset:Ve}=Se;let De=Se.index;De==="LAST"&&(De=se-1),De=Io(0,De,nl(se-1,De));let Ge=rl(U,ie,Q,De);return xe==="end"?Ge=Qp(Ge-U.height+Q.height):xe==="center"&&(Ge=Qp(Ge-U.height/2+Q.height/2)),Ve&&(Ge+=Ve),{behavior:Re,top:Ge}})),c);const O=Rt(ee(A,ce(P=>P.offsetBottom+P.bottom)),0);return he(ee(E,ce(P=>({height:P.visibleHeight,width:P.visibleWidth}))),j),{customScrollParent:x,data:_,deviation:J,footerHeight:o,gap:Y,headerHeight:s,increaseViewportBy:e,initialItemCount:k,itemDimensions:L,overscan:n,restoreStateFrom:W,scrollBy:i,scrollContainerState:a,scrollHeight:K,scrollTo:c,scrollToIndex:B,scrollTop:l,smoothScrollTargetReached:d,totalCount:C,useWindowScroll:y,viewportDimensions:j,windowScrollContainerState:b,windowScrollTo:T,windowViewportRect:E,...p,gridState:A,horizontalDirection:M,initialTopMostItemIndex:I,totalListHeight:O,...m,endReached:R,propsReady:g,rangeChanged:H,startReached:F,stateChanged:q,stateRestoreInProgress:D,...S}},st(Ga,$t,Eo,$p,Un,Xa,zn));function th(e,t,n){return Io(1,Bs((e+n)/(Bs(t)+n)))}function nh(e,t,n,r){const{height:o}=n;if(o===void 0||r.length===0)return{bottom:0,top:0};const s=rl(e,t,n,r[0].index);return{bottom:rl(e,t,n,r[r.length-1].index)+o,top:s}}function rl(e,t,n,r){const o=th(e.width,n.width,t.column),s=Bs(r/o),i=s*n.height+Io(0,s-1)*t.row;return i>0?i+t.row:i}const eT=qe(()=>{const e=oe(f=>`Item ${f}`),t=oe({}),n=oe(null),r=oe("virtuoso-grid-item"),o=oe("virtuoso-grid-list"),s=oe(el),i=oe("div"),a=oe(Lr),c=(f,m=null)=>Rt(ee(t,ce(p=>p[f]),it()),m),l=oe(!1),d=oe(!1);return he(be(d),l),{components:t,computeItemKey:s,context:n,FooterComponent:c("Footer"),HeaderComponent:c("Header"),headerFooterTag:i,itemClassName:r,ItemComponent:c("Item","div"),itemContent:e,listClassName:o,ListComponent:c("List","div"),readyStateChanged:l,reportReadyState:d,ScrollerComponent:c("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:c("ScrollSeekPlaceholder","div")}}),tT=qe(([e,t])=>({...e,...t}),st(QC,eT)),nT=w.memo(function(){const e=lt("gridState"),t=lt("listClassName"),n=lt("itemClassName"),r=lt("itemContent"),o=lt("computeItemKey"),s=lt("isSeeking"),i=nn("scrollHeight"),a=lt("ItemComponent"),c=lt("ListComponent"),l=lt("ScrollSeekPlaceholder"),d=lt("context"),f=nn("itemDimensions"),m=nn("gap"),p=lt("log"),v=lt("stateRestoreInProgress"),g=nn("reportReadyState"),x=ir(w.useMemo(()=>y=>{const b=y.parentElement.parentElement.scrollHeight;i(b);const T=y.firstChild;if(T){const{height:E,width:S}=T.getBoundingClientRect();f({height:E,width:S})}m({column:oh("column-gap",getComputedStyle(y).columnGap,p),row:oh("row-gap",getComputedStyle(y).rowGap,p)})},[i,f,m,p]),!0,!1);return Wp(()=>{e.itemHeight>0&&e.itemWidth>0&&g(!0)},[e]),v?null:u.jsx(c,{className:t,ref:x,...Mt(c,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(l,{...Mt(l,d),height:e.itemHeight,index:y.index,width:e.itemWidth},b):w.createElement(a,{...Mt(a,d),className:n,"data-index":y.index,key:b},r(y.index,y.data,d))})})}),rT=w.memo(function(){const e=lt("HeaderComponent"),t=nn("headerHeight"),n=lt("headerFooterTag"),r=ir(w.useMemo(()=>s=>{t(Hn(s,"height"))},[t]),!0,!1),o=lt("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Mt(e,o)})}):null}),oT=w.memo(function(){const e=lt("FooterComponent"),t=nn("footerHeight"),n=lt("headerFooterTag"),r=ir(w.useMemo(()=>s=>{t(Hn(s,"height"))},[t]),!0,!1),o=lt("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Mt(e,o)})}):null}),sT=({children:e})=>{const t=w.useContext(Up),n=nn("itemDimensions"),r=nn("viewportDimensions"),o=ir(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:Fs(!1),children:e})},iT=({children:e})=>{const t=w.useContext(Up),n=nn("windowViewportRect"),r=nn("itemDimensions"),o=lt("customScrollParent"),s=hp(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:Fs(!1),children:e})},aT=w.memo(function({...e}){const t=lt("useWindowScroll"),n=lt("customScrollParent"),r=n||t?cT:lT,o=n||t?iT:sT,s=lt("context");return u.jsx(r,{...e,...Mt(r,s),children:u.jsxs(o,{children:[u.jsx(rT,{}),u.jsx(nT,{}),u.jsx(oT,{})]})})}),{useEmitter:rh,useEmitterValue:lt,usePublisher:nn}=zp(tT,{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"}},aT),lT=Yp({useEmitter:rh,useEmitterValue:lt,usePublisher:nn}),cT=Xp({useEmitter:rh,useEmitterValue:lt,usePublisher:nn});function oh(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Ut.WARN),t==="normal"?0:parseInt(t??"0",10)}var Hs="Dialog",[sh,HN]=cn(Hs),[uT,hn]=sh(Hs),ih=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:i=!0}=e,a=h.useRef(null),c=h.useRef(null),[l,d]=On({prop:r,defaultProp:o??!1,onChange:s,caller:Hs});return u.jsx(uT,{scope:t,triggerRef:a,contentRef:c,contentId:_t(),titleId:_t(),descriptionId:_t(),open:l,onOpenChange:d,onOpenToggle:h.useCallback(()=>d(f=>!f),[d]),modal:i,children:n})};ih.displayName=Hs;var ah="DialogTrigger",lh=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=hn(ah,n),s=je(t,o.triggerRef);return u.jsx(pe.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":il(o.open),...r,ref:s,onClick:ae(e.onClick,o.onOpenToggle)})});lh.displayName=ah;var ol="DialogPortal",[dT,ch]=sh(ol,{forceMount:void 0}),uh=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=hn(ol,t);return u.jsx(dT,{scope:t,forceMount:n,children:h.Children.map(r,i=>u.jsx(Ht,{present:n||s.open,children:u.jsx(co,{asChild:!0,container:o,children:i})}))})};uh.displayName=ol;var Us="DialogOverlay",dh=h.forwardRef((e,t)=>{const n=ch(Us,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=hn(Us,e.__scopeDialog);return s.modal?u.jsx(Ht,{present:r||s.open,children:u.jsx(pT,{...o,ref:t})}):null});dh.displayName=Us;var fT=qt.createSlot("DialogOverlay.RemoveScroll"),pT=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=hn(Us,n);return u.jsx(ys,{as:fT,allowPinchZoom:!0,shards:[o.contentRef],children:u.jsx(pe.div,{"data-state":il(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),cr="DialogContent",fh=h.forwardRef((e,t)=>{const n=ch(cr,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=hn(cr,e.__scopeDialog);return u.jsx(Ht,{present:r||s.open,children:s.modal?u.jsx(hT,{...o,ref:t}):u.jsx(mT,{...o,ref:t})})});fh.displayName=cr;var hT=h.forwardRef((e,t)=>{const n=hn(cr,e.__scopeDialog),r=h.useRef(null),o=je(t,n.contentRef,r);return h.useEffect(()=>{const s=r.current;if(s)return ya(s)},[]),u.jsx(ph,{...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())})}),mT=h.forwardRef((e,t)=>{const n=hn(cr,e.__scopeDialog),r=h.useRef(!1),o=h.useRef(!1);return u.jsx(ph,{...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 c,l;(c=e.onInteractOutside)==null||c.call(e,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const i=s.target;((l=n.triggerRef.current)==null?void 0:l.contains(i))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&o.current&&s.preventDefault()}})}),ph=h.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=hn(cr,n),c=h.useRef(null),l=je(t,c);return Zi(),u.jsxs(u.Fragment,{children:[u.jsx(ns,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:u.jsx(Er,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":il(a.open),...i,ref:l,onDismiss:()=>a.onOpenChange(!1)})}),u.jsxs(u.Fragment,{children:[u.jsx(gT,{titleId:a.titleId}),u.jsx(vT,{contentRef:c,descriptionId:a.descriptionId})]})]})}),sl="DialogTitle",hh=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=hn(sl,n);return u.jsx(pe.h2,{id:o.titleId,...r,ref:t})});hh.displayName=sl;var mh="DialogDescription",gh=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=hn(mh,n);return u.jsx(pe.p,{id:o.descriptionId,...r,ref:t})});gh.displayName=mh;var xh="DialogClose",vh=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=hn(xh,n);return u.jsx(pe.button,{type:"button",...r,ref:t,onClick:ae(e.onClick,()=>o.onOpenChange(!1))})});vh.displayName=xh;function il(e){return e?"open":"closed"}var wh="DialogTitleWarning",[UN,bh]=_w(wh,{contentName:cr,titleName:sl,docsSlug:"dialog"}),gT=({titleId:e})=>{const t=bh(wh),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},xT="DialogDescriptionWarning",vT=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${uh(xT).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},rl=Xp,wT=Zp,ol=eh,No=th,Ao=nh,ar=oh,Us=ih,dh=lh;const sl=rl,bT=ol,fh=h.forwardRef(({className:e,...t},n)=>u.jsx(No,{ref:n,className:ne("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));fh.displayName=No.displayName;const Ws=h.forwardRef(({className:e,children:t,...n},r)=>{const o=h.useMemo(()=>{let s=!1;function i(a){h.Children.forEach(a,c=>{if(s||!h.isValidElement(c))return;const l=c.type;if(l===ar||(l==null?void 0:l.displayName)===ar.displayName||(l==null?void 0:l.name)==="DialogTitle"){s=!0;return}c.props&&c.props.children&&i(c.props.children)})}return i(t),s},[t]);return u.jsxs(bT,{children:[u.jsx(fh,{}),u.jsxs(Ao,{ref:r,className:ne("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...n,children:[!o&&u.jsx(ar,{className:"sr-only",children:"Dialog"}),t,u.jsxs(dh,{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"})]})]})]})});Ws.displayName=Ao.displayName;const Vs=({className:e,...t})=>u.jsx("div",{className:ne("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});Vs.displayName="DialogHeader";const Ks=h.forwardRef(({className:e,...t},n)=>u.jsx(ar,{ref:n,className:ne("text-lg font-semibold leading-none tracking-tight",e),...t}));Ks.displayName=ar.displayName;const yT=h.forwardRef(({className:e,...t},n)=>u.jsx(Us,{ref:n,className:ne("text-sm text-muted-foreground",e),...t}));yT.displayName=Us.displayName;const ST=1,CT=1e6;let il=0;function TT(){return il=(il+1)%Number.MAX_SAFE_INTEGER,il.toString()}const al=new Map,ph=e=>{if(al.has(e))return;const t=setTimeout(()=>{al.delete(e),jo({type:"REMOVE_TOAST",toastId:e})},CT);al.set(e,t)},kT=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,ST)};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?ph(n):e.toasts.forEach(r=>{ph(r.id)}),{...e,toasts:e.toasts.map(r=>r.id===n||n===void 0?{...r,open:!1}:r)}}case"REMOVE_TOAST":return t.toastId===void 0?{...e,toasts:[]}:{...e,toasts:e.toasts.filter(n=>n.id!==t.toastId)}}},qs=[];let Gs={toasts:[]};function jo(e){Gs=kT(Gs,e),qs.forEach(t=>{t(Gs)})}function ET({...e}){const t=TT(),n=o=>jo({type:"UPDATE_TOAST",toast:{...o,id:t}}),r=()=>jo({type:"DISMISS_TOAST",toastId:t});return jo({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:o=>{o||r()}}}),{id:t,dismiss:r,update:n}}function ll(){const[e,t]=h.useState(Gs);return h.useEffect(()=>(qs.push(t),()=>{const n=qs.indexOf(t);n>-1&&qs.splice(n,1)}),[e]),{...e,toast:ET,dismiss:n=>jo({type:"DISMISS_TOAST",toastId:n})}}function hh({isOpen:e,onClose:t,fileId:n,fileName:r,mimeType:o}){const[s,i]=w.useState(!1),[a,c]=w.useState(null),[l,d]=w.useState(null),{toast:f}=ll(),m=w.useCallback(async()=>{if(n){i(!0),d(null),c(null);try{const y=await $i(n);c(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 p=async()=>{if(n)try{await ou(n),f({title:"Download started",description:`Downloading ${r}`})}catch(y){console.error("Failed to download file:",y),f({title:"Download failed",description:String(y),variant:"destructive"})}},v=async()=>{if(n)try{const y=await $i(n),b=new Blob([y],{type:o}),T=URL.createObjectURL(b);window.open(T,"_blank"),URL.revokeObjectURL(T)}catch(y){console.error("Failed to open file externally:",y),f({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..."})]}):l?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:l}),u.jsx(Je,{onClick:m,variant:"outline",children:"Try Again"})]}):a?o.startsWith("image/")?u.jsx("div",{className:"flex justify-center",children:u.jsx("img",{src:`data:${o};base64,${a}`,alt:r,className:"max-w-full max-h-[70vh] object-contain rounded-lg"})}):o==="application/pdf"?u.jsx("div",{className:"w-full h-[70vh] border rounded-lg overflow-hidden",children:u.jsx("iframe",{src:`data:application/pdf;base64,${a}`,className:"w-full h-full",title:r})}):o.startsWith("text/")||o.includes("json")||o.includes("xml")?u.jsx("div",{className:"bg-gray-50 dark:bg-gray-900 rounded-lg p-4 max-h-[70vh] overflow-auto",children:u.jsx("pre",{className:"whitespace-pre-wrap font-mono text-sm",children:a})}):u.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[u.jsx(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(sl,{open:e,onOpenChange:t,children:u.jsxs(Ws,{className:"max-w-4xl max-h-[90vh] overflow-hidden",children:[u.jsx(Vs,{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(Ks,{className:"text-left",children:r}),u.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:[o," • Click download or external view for full access"]})]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsxs(Je,{variant:"outline",size:"sm",onClick:v,className:"flex items-center gap-2",children:[u.jsx(le.ExternalLink,{className:"h-4 w-4"}),"External"]}),u.jsxs(Je,{variant:"outline",size:"sm",onClick:p,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 mh(){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=mh();function IT(e){lr=e}const gh=/[&<>"']/,NT=new RegExp(gh.source,"g"),xh=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,AT=new RegExp(xh.source,"g"),jT={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},vh=e=>jT[e];function Ot(e,t){if(t){if(gh.test(e))return e.replace(NT,vh)}else if(xh.test(e))return e.replace(AT,vh);return e}const PT=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function wh(e){return e.replace(PT,(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 _T=/(^|[^\[])\^/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(_T,"$1"),e=e.replace(r,o),n),getRegex:()=>new RegExp(e,t)};return n}const RT=/[^\w:]/g,MT=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function bh(e,t,n){if(e){let r;try{r=decodeURIComponent(wh(n)).replace(RT,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}t&&!MT.test(n)&&(n=$T(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const Ys={},OT=/^[^:]+:\/*[^/]*$/,DT=/^([^:]+:)[\s\S]*$/,LT=/^([^:]+:\/*[^/]*)[\s\S]*$/;function $T(e,t){Ys[" "+e]||(OT.test(e)?Ys[" "+e]=e+"/":Ys[" "+e]=Js(e,"/",!0)),e=Ys[" "+e];const n=e.indexOf(":")===-1;return t.substring(0,2)==="//"?n?t:e.replace(DT,"$1")+t:t.charAt(0)==="/"?n?t:e.replace(LT,"$1")+t:e+t}const Xs={exec:function(){}};function yh(e,t){const n=e.replace(/\|/g,(s,i,a)=>{let c=!1,l=i;for(;--l>=0&&a[l]==="\\";)c=!c;return c?"|":" |"}),r=n.split(/ \|/);let o=0;if(r[0].trim()||r.shift(),r.length>0&&!r[r.length-1].trim()&&r.pop(),r.length>t)r.splice(t);else for(;r.length<t;)r.push("");for(;o<r.length;o++)r[o]=r[o].trim().replace(/\\\|/g,"|");return r}function Js(e,t,n){const r=e.length;if(r===0)return"";let o=0;for(;o<r;){const s=e.charAt(r-o-1);if(s===t&&!n)o++;else if(s!==t&&n)o++;else break}return e.slice(0,r-o)}function FT(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 BT(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 Sh(e,t){if(t<1)return"";let n="";for(;t>1;)t&1&&(n+=e),t>>=1,e+=e;return n+e}function Ch(e,t,n,r){const o=t.href,s=t.title?Ot(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:Ot(i)}}function zT(e,t){const n=e.match(/^(\s+)(?:```)/);if(n===null)return t;const r=n[1];return t.split(`
83
+ For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return h.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},xT="DialogDescriptionWarning",vT=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${bh(xT).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},al=ih,wT=lh,ll=uh,No=dh,Ao=fh,ur=hh,Ws=gh,yh=vh;const cl=al,bT=ll,Sh=h.forwardRef(({className:e,...t},n)=>u.jsx(No,{ref:n,className:ne("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));Sh.displayName=No.displayName;const Vs=h.forwardRef(({className:e,children:t,...n},r)=>{const o=h.useMemo(()=>{let s=!1;function i(a){h.Children.forEach(a,c=>{if(s||!h.isValidElement(c))return;const l=c.type;if(l===ur||(l==null?void 0:l.displayName)===ur.displayName||(l==null?void 0:l.name)==="DialogTitle"){s=!0;return}c.props&&c.props.children&&i(c.props.children)})}return i(t),s},[t]);return u.jsxs(bT,{children:[u.jsx(Sh,{}),u.jsxs(Ao,{ref:r,className:ne("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...n,children:[!o&&u.jsx(ur,{className:"sr-only",children:"Dialog"}),t,u.jsxs(yh,{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"})]})]})]})});Vs.displayName=Ao.displayName;const Ks=({className:e,...t})=>u.jsx("div",{className:ne("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});Ks.displayName="DialogHeader";const qs=h.forwardRef(({className:e,...t},n)=>u.jsx(ur,{ref:n,className:ne("text-lg font-semibold leading-none tracking-tight",e),...t}));qs.displayName=ur.displayName;const yT=h.forwardRef(({className:e,...t},n)=>u.jsx(Ws,{ref:n,className:ne("text-sm text-muted-foreground",e),...t}));yT.displayName=Ws.displayName;const ST=1,CT=1e6;let ul=0;function TT(){return ul=(ul+1)%Number.MAX_SAFE_INTEGER,ul.toString()}const dl=new Map,Ch=e=>{if(dl.has(e))return;const t=setTimeout(()=>{dl.delete(e),Po({type:"REMOVE_TOAST",toastId:e})},CT);dl.set(e,t)},kT=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,ST)};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)}}},Gs=[];let Ys={toasts:[]};function Po(e){Ys=kT(Ys,e),Gs.forEach(t=>{t(Ys)})}function ET({...e}){const t=TT(),n=o=>Po({type:"UPDATE_TOAST",toast:{...o,id:t}}),r=()=>Po({type:"DISMISS_TOAST",toastId:t});return Po({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:o=>{o||r()}}}),{id:t,dismiss:r,update:n}}function fl(){const[e,t]=h.useState(Ys);return h.useEffect(()=>(Gs.push(t),()=>{const n=Gs.indexOf(t);n>-1&&Gs.splice(n,1)}),[e]),{...e,toast:ET,dismiss:n=>Po({type:"DISMISS_TOAST",toastId:n})}}function Th({isOpen:e,onClose:t,fileId:n,fileName:r,mimeType:o}){const[s,i]=w.useState(!1),[a,c]=w.useState(null),[l,d]=w.useState(null),{toast:f}=fl(),m=w.useCallback(async()=>{if(n){i(!0),d(null),c(null);try{const y=await Fi(n);c(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 p=async()=>{if(n)try{await lu(n),f({title:"Download started",description:`Downloading ${r}`})}catch(y){console.error("Failed to download file:",y),f({title:"Download failed",description:String(y),variant:"destructive"})}},v=async()=>{if(n)try{const y=await Fi(n),b=new Blob([y],{type:o}),T=URL.createObjectURL(b);window.open(T,"_blank"),URL.revokeObjectURL(T)}catch(y){console.error("Failed to open file externally:",y),f({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..."})]}):l?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:l}),u.jsx(Je,{onClick:m,variant:"outline",children:"Try Again"})]}):a?o.startsWith("image/")?u.jsx("div",{className:"flex justify-center",children:u.jsx("img",{src:`data:${o};base64,${a}`,alt:r,className:"max-w-full max-h-[70vh] object-contain rounded-lg"})}):o==="application/pdf"?u.jsx("div",{className:"w-full h-[70vh] border rounded-lg overflow-hidden",children:u.jsx("iframe",{src:`data:application/pdf;base64,${a}`,className:"w-full h-full",title:r})}):o.startsWith("text/")||o.includes("json")||o.includes("xml")?u.jsx("div",{className:"bg-gray-50 dark:bg-gray-900 rounded-lg p-4 max-h-[70vh] overflow-auto",children:u.jsx("pre",{className:"whitespace-pre-wrap font-mono text-sm",children:a})}):u.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[u.jsx(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(cl,{open:e,onOpenChange:t,children:u.jsxs(Vs,{className:"max-w-4xl max-h-[90vh] overflow-hidden",children:[u.jsx(Ks,{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(qs,{className:"text-left",children:r}),u.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:[o," • Click download or external view for full access"]})]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsxs(Je,{variant:"outline",size:"sm",onClick:v,className:"flex items-center gap-2",children:[u.jsx(le.ExternalLink,{className:"h-4 w-4"}),"External"]}),u.jsxs(Je,{variant:"outline",size:"sm",onClick:p,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 kh(){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 dr=kh();function IT(e){dr=e}const Eh=/[&<>"']/,NT=new RegExp(Eh.source,"g"),Ih=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,AT=new RegExp(Ih.source,"g"),PT={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Nh=e=>PT[e];function Ot(e,t){if(t){if(Eh.test(e))return e.replace(NT,Nh)}else if(Ih.test(e))return e.replace(AT,Nh);return e}const jT=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function Ah(e){return e.replace(jT,(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 _T=/(^|[^\[])\^/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(_T,"$1"),e=e.replace(r,o),n),getRegex:()=>new RegExp(e,t)};return n}const RT=/[^\w:]/g,MT=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function Ph(e,t,n){if(e){let r;try{r=decodeURIComponent(Ah(n)).replace(RT,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}t&&!MT.test(n)&&(n=$T(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const Xs={},OT=/^[^:]+:\/*[^/]*$/,DT=/^([^:]+:)[\s\S]*$/,LT=/^([^:]+:\/*[^/]*)[\s\S]*$/;function $T(e,t){Xs[" "+e]||(OT.test(e)?Xs[" "+e]=e+"/":Xs[" "+e]=Zs(e,"/",!0)),e=Xs[" "+e];const n=e.indexOf(":")===-1;return t.substring(0,2)==="//"?n?t:e.replace(DT,"$1")+t:t.charAt(0)==="/"?n?t:e.replace(LT,"$1")+t:e+t}const Js={exec:function(){}};function jh(e,t){const n=e.replace(/\|/g,(s,i,a)=>{let c=!1,l=i;for(;--l>=0&&a[l]==="\\";)c=!c;return c?"|":" |"}),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 Zs(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 FT(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 BT(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 _h(e,t){if(t<1)return"";let n="";for(;t>1;)t&1&&(n+=e),t>>=1,e+=e;return n+e}function Rh(e,t,n,r){const o=t.href,s=t.title?Ot(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:Ot(i)}}function zT(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 cl{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:Js(r,`
86
- `)}}}fences(t){const n=this.rules.block.fences.exec(t);if(n){const r=n[0],o=zT(r,n[3]||"");return{type:"code",raw:r,lang:n[2]?n[2].trim().replace(this.rules.inline._escapes,"$1"):n[2],text:o}}}heading(t){const n=this.rules.block.heading.exec(t);if(n){let r=n[2].trim();if(/#$/.test(r)){const o=Js(r,"#");(this.options.pedantic||!o||/ $/.test(o))&&(r=o.trim())}return{type:"heading",raw:n[0],depth:n[1].length,text:r,tokens:this.lexer.inline(r)}}}hr(t){const n=this.rules.block.hr.exec(t);if(n)return{type:"hr",raw:n[0]}}blockquote(t){const n=this.rules.block.blockquote.exec(t);if(n){const r=n[0].replace(/^ *>[ \t]?/gm,""),o=this.lexer.state.top;this.lexer.state.top=!0;const s=this.lexer.blockTokens(r);return this.lexer.state.top=o,{type:"blockquote",raw:n[0],tokens:s,text:r}}}list(t){let n=this.rules.block.list.exec(t);if(n){let r,o,s,i,a,c,l,d,f,m,p,v,g=n[1].trim();const x=g.length>1,y={type:"list",raw:"",ordered:x,start:x?+g.slice(0,-1):"",loose:!1,items:[]};g=x?`\\d{1,9}\\${g.slice(-1)}`:`\\${g}`,this.options.pedantic&&(g=x?g:"[*+-]");const 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(`
85
+ `)}class pl{constructor(t){this.options=t||dr}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:Zs(r,`
86
+ `)}}}fences(t){const n=this.rules.block.fences.exec(t);if(n){const r=n[0],o=zT(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=Zs(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,c,l,d,f,m,p,v,g=n[1].trim();const x=g.length>1,y={type:"list",raw:"",ordered:x,start:x?+g.slice(0,-1):"",loose:!1,items:[]};g=x?`\\d{1,9}\\${g.slice(-1)}`:`\\${g}`,this.options.pedantic&&(g=x?g:"[*+-]");const 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
87
  `,1)[0].replace(/^\t+/,E=>" ".repeat(3*E.length)),f=t.split(`
88
88
  `,1)[0],this.options.pedantic?(i=2,p=d.trimLeft()):(i=n[2].search(/[^ ]/),i=i>4?1:i,p=d.slice(i),i+=n[1].length),c=!1,!d&&/^ *$/.test(f)&&(r+=f+`
89
89
  `,t=t.substring(f.length+1),v=!0),!v){const E=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+|$)`),C=new RegExp(`^ {0,${Math.min(3,i-1)}}(?:\`\`\`|~~~)`),k=new RegExp(`^ {0,${Math.min(3,i-1)}}#`);for(;t&&(m=t.split(`
90
90
  `,1)[0],f=m,this.options.pedantic&&(f=f.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),!(C.test(f)||k.test(f)||E.test(f)||S.test(t)));){if(f.search(/[^ ]/)>=i||!f.trim())p+=`
91
91
  `+f.slice(i);else{if(c||d.search(/[^ ]/)>=4||C.test(d)||k.test(d)||S.test(d))break;p+=`
92
92
  `+f}!c&&!f.trim()&&(c=!0),r+=m+`
93
- `,t=t.substring(m.length+1),d=f.slice(i)}}y.loose||(l?y.loose=!0:/\n *\n *$/.test(r)&&(l=!0)),this.options.gfm&&(o=/^\[[ xX]\] /.exec(p),o&&(s=o[0]!=="[ ] ",p=p.replace(/^\[[ xX]\] +/,""))),y.items.push({type:"list_item",raw:r,task:!!o,checked:s,loose:!1,text:p}),y.raw+=r}y.items[y.items.length-1].raw=r.trimRight(),y.items[y.items.length-1].text=p.trimRight(),y.raw=y.raw.trimRight();const T=y.items.length;for(a=0;a<T;a++)if(this.lexer.state.top=!1,y.items[a].tokens=this.lexer.blockTokens(y.items[a].text,[]),!y.loose){const E=y.items[a].tokens.filter(C=>C.type==="space"),S=E.length>0&&E.some(C=>/\n.*\n/.test(C.raw));y.loose=S}if(y.loose)for(a=0;a<T;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]):Ot(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:yh(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,c;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]=yh(r.rows[s],r.header.length).map(l=>({text:l}));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(c=r.rows[i],a=0;a<c.length;a++)c[a].tokens=this.lexer.inline(c[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:Ot(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]):Ot(n[0]):n[0]}}link(t){const n=this.rules.inline.link.exec(t);if(n){const r=n[2].trim();if(!this.options.pedantic&&/^</.test(r)){if(!/>$/.test(r))return;const i=Js(r.slice(0,-1),"\\");if((r.length-i.length)%2===0)return}else{const i=FT(n[2],"()");if(i>-1){const c=(n[0].indexOf("!")===0?5:4)+n[1].length+i;n[2]=n[2].substring(0,i),n[0]=n[0].substring(0,c).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)),Ch(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 Ch(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,c,l=i,d=0;const f=o[0][0]==="*"?this.rules.inline.emStrong.rDelimAst:this.rules.inline.emStrong.rDelimUnd;for(f.lastIndex=0,n=n.slice(-1*t.length+i);(o=f.exec(n))!=null;){if(a=o[1]||o[2]||o[3]||o[4]||o[5]||o[6],!a)continue;if(c=a.length,o[3]||o[4]){l+=c;continue}else if((o[5]||o[6])&&i%3&&!((i+c)%3)){d+=c;continue}if(l-=c,l>0)continue;c=Math.min(c,c+l+d);const m=t.slice(0,i+o.index+(o[0].length-a.length)+c);if(Math.min(i,c)%2){const v=m.slice(1,-1);return{type:"em",raw:m,text:v,tokens:this.lexer.inlineTokens(v)}}const p=m.slice(2,-2);return{type:"strong",raw:m,text:p,tokens:this.lexer.inlineTokens(p)}}}}codespan(t){const n=this.rules.inline.code.exec(t);if(n){let r=n[2].replace(/\n/g," ");const o=/[^ ]/.test(r),s=/^ /.test(r)&&/ $/.test(r);return o&&s&&(r=r.substring(1,r.length-1)),r=Ot(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=Ot(this.options.mangle?n(r[1]):r[1]),s="mailto:"+o):(o=Ot(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=Ot(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=Ot(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]):Ot(r[0]):r[0]:o=Ot(this.options.smartypants?n(r[0]):r[0]),{type:"text",raw:r[0],text:o}}}}const ve={newline:/^(?: *(?:\n|$))+/,code:/^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,fences:/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,hr:/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,blockquote:/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,list:/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/,html:"^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n *)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$))",def:/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/,table:Xs,lheading:/^((?:.|\n(?!\n))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,text:/^[^\n]+/};ve._label=/(?!\s*\])(?:\\.|[^\[\]\\])+/,ve._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,ve.def=tt(ve.def).replace("label",ve._label).replace("title",ve._title).getRegex(),ve.bullet=/(?:[*+-]|\d{1,9}[.)])/,ve.listItemStart=tt(/^( *)(bull) */).replace("bull",ve.bullet).getRegex(),ve.list=tt(ve.list).replace(/bull/g,ve.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+ve.def.source+")").getRegex(),ve._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",ve._comment=/<!--(?!-?>)[\s\S]*?(?:-->|$)/,ve.html=tt(ve.html,"i").replace("comment",ve._comment).replace("tag",ve._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),ve.paragraph=tt(ve._paragraph).replace("hr",ve.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",ve._tag).getRegex(),ve.blockquote=tt(ve.blockquote).replace("paragraph",ve.paragraph).getRegex(),ve.normal={...ve},ve.gfm={...ve.normal,table:"^ *([^\\n ].*\\|.*)\\n {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"},ve.gfm.table=tt(ve.gfm.table).replace("hr",ve.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",ve._tag).getRegex(),ve.gfm.paragraph=tt(ve._paragraph).replace("hr",ve.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("table",ve.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",ve._tag).getRegex(),ve.pedantic={...ve.normal,html:tt(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",ve._comment).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Xs,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:tt(ve.normal._paragraph).replace("hr",ve.hr).replace("heading",` *#{1,6} *[^
96
- ]`).replace("lheading",ve.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()};const ue={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:Xs,tag:"^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>",link:/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/,reflink:/^!?\[(label)\]\[(ref)\]/,nolink:/^!?\[(ref)\](?:\[\])?/,reflinkSearch:"reflink|nolink(?!\\()",emStrong:{lDelim:/^(?:\*+(?:([punct_])|[^\s*]))|^_+(?:([punct*])|([^\s_]))/,rDelimAst:/^(?:[^_*\\]|\\.)*?\_\_(?:[^_*\\]|\\.)*?\*(?:[^_*\\]|\\.)*?(?=\_\_)|(?:[^*\\]|\\.)+(?=[^*])|[punct_](\*+)(?=[\s]|$)|(?:[^punct*_\s\\]|\\.)(\*+)(?=[punct_\s]|$)|[punct_\s](\*+)(?=[^punct*_\s])|[\s](\*+)(?=[punct_])|[punct_](\*+)(?=[punct_])|(?:[^punct*_\s\\]|\\.)(\*+)(?=[^punct*_\s])/,rDelimUnd:/^(?:[^_*\\]|\\.)*?\*\*(?:[^_*\\]|\\.)*?\_(?:[^_*\\]|\\.)*?(?=\*\*)|(?:[^_\\]|\\.)+(?=[^_])|[punct*](\_+)(?=[\s]|$)|(?:[^punct*_\s\\]|\\.)(\_+)(?=[punct*\s]|$)|[punct*\s](\_+)(?=[^punct*_\s])|[\s](\_+)(?=[punct*])|[punct*](\_+)(?=[punct*])/},code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,br:/^( {2,}|\\)\n(?!\s*$)/,del:Xs,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,punctuation:/^([\spunctuation])/};ue._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",ue.punctuation=tt(ue.punctuation).replace(/punctuation/g,ue._punctuation).getRegex(),ue.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g,ue.escapedEmSt=/(?:^|[^\\])(?:\\\\)*\\[*_]/g,ue._comment=tt(ve._comment).replace("(?:-->|$)","-->").getRegex(),ue.emStrong.lDelim=tt(ue.emStrong.lDelim).replace(/punct/g,ue._punctuation).getRegex(),ue.emStrong.rDelimAst=tt(ue.emStrong.rDelimAst,"g").replace(/punct/g,ue._punctuation).getRegex(),ue.emStrong.rDelimUnd=tt(ue.emStrong.rDelimUnd,"g").replace(/punct/g,ue._punctuation).getRegex(),ue._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,ue._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,ue._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])?)+(?![-_])/,ue.autolink=tt(ue.autolink).replace("scheme",ue._scheme).replace("email",ue._email).getRegex(),ue._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,ue.tag=tt(ue.tag).replace("comment",ue._comment).replace("attribute",ue._attribute).getRegex(),ue._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,ue._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/,ue._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,ue.link=tt(ue.link).replace("label",ue._label).replace("href",ue._href).replace("title",ue._title).getRegex(),ue.reflink=tt(ue.reflink).replace("label",ue._label).replace("ref",ve._label).getRegex(),ue.nolink=tt(ue.nolink).replace("ref",ve._label).getRegex(),ue.reflinkSearch=tt(ue.reflinkSearch,"g").replace("reflink",ue.reflink).replace("nolink",ue.nolink).getRegex(),ue.normal={...ue},ue.pedantic={...ue.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",ue._label).getRegex(),reflink:tt(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",ue._label).getRegex()},ue.gfm={...ue.normal,escape:tt(ue.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.!#$%&'*+\/=?_`{\|}~-]+@)))/},ue.gfm.url=tt(ue.gfm.url,"i").replace("email",ue.gfm._extended_email).getRegex(),ue.breaks={...ue.gfm,br:tt(ue.br).replace("{2,}","*").getRegex(),text:tt(ue.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()};function HT(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 Th(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 cl,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:ve.normal,inline:ue.normal};this.options.pedantic?(n.block=ve.pedantic,n.inline=ue.pedantic):this.options.gfm&&(n.block=ve.gfm,this.options.breaks?n.inline=ue.breaks:n.inline=ue.gfm),this.tokenizer.rules=n}static get rules(){return{block:ve,inline:ue}}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,`
93
+ `,t=t.substring(m.length+1),d=f.slice(i)}}y.loose||(l?y.loose=!0:/\n *\n *$/.test(r)&&(l=!0)),this.options.gfm&&(o=/^\[[ xX]\] /.exec(p),o&&(s=o[0]!=="[ ] ",p=p.replace(/^\[[ xX]\] +/,""))),y.items.push({type:"list_item",raw:r,task:!!o,checked:s,loose:!1,text:p}),y.raw+=r}y.items[y.items.length-1].raw=r.trimRight(),y.items[y.items.length-1].text=p.trimRight(),y.raw=y.raw.trimRight();const T=y.items.length;for(a=0;a<T;a++)if(this.lexer.state.top=!1,y.items[a].tokens=this.lexer.blockTokens(y.items[a].text,[]),!y.loose){const E=y.items[a].tokens.filter(C=>C.type==="space"),S=E.length>0&&E.some(C=>/\n.*\n/.test(C.raw));y.loose=S}if(y.loose)for(a=0;a<T;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]):Ot(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:jh(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,c;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]=jh(r.rows[s],r.header.length).map(l=>({text:l}));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(c=r.rows[i],a=0;a<c.length;a++)c[a].tokens=this.lexer.inline(c[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:Ot(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]):Ot(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=Zs(r.slice(0,-1),"\\");if((r.length-i.length)%2===0)return}else{const i=FT(n[2],"()");if(i>-1){const c=(n[0].indexOf("!")===0?5:4)+n[1].length+i;n[2]=n[2].substring(0,i),n[0]=n[0].substring(0,c).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)),Rh(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 Rh(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,c,l=i,d=0;const f=o[0][0]==="*"?this.rules.inline.emStrong.rDelimAst:this.rules.inline.emStrong.rDelimUnd;for(f.lastIndex=0,n=n.slice(-1*t.length+i);(o=f.exec(n))!=null;){if(a=o[1]||o[2]||o[3]||o[4]||o[5]||o[6],!a)continue;if(c=a.length,o[3]||o[4]){l+=c;continue}else if((o[5]||o[6])&&i%3&&!((i+c)%3)){d+=c;continue}if(l-=c,l>0)continue;c=Math.min(c,c+l+d);const m=t.slice(0,i+o.index+(o[0].length-a.length)+c);if(Math.min(i,c)%2){const v=m.slice(1,-1);return{type:"em",raw:m,text:v,tokens:this.lexer.inlineTokens(v)}}const p=m.slice(2,-2);return{type:"strong",raw:m,text:p,tokens:this.lexer.inlineTokens(p)}}}}codespan(t){const n=this.rules.inline.code.exec(t);if(n){let r=n[2].replace(/\n/g," ");const o=/[^ ]/.test(r),s=/^ /.test(r)&&/ $/.test(r);return o&&s&&(r=r.substring(1,r.length-1)),r=Ot(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=Ot(this.options.mangle?n(r[1]):r[1]),s="mailto:"+o):(o=Ot(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=Ot(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=Ot(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]):Ot(r[0]):r[0]:o=Ot(this.options.smartypants?n(r[0]):r[0]),{type:"text",raw:r[0],text:o}}}}const ve={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:Js,lheading:/^((?:.|\n(?!\n))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,text:/^[^\n]+/};ve._label=/(?!\s*\])(?:\\.|[^\[\]\\])+/,ve._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,ve.def=tt(ve.def).replace("label",ve._label).replace("title",ve._title).getRegex(),ve.bullet=/(?:[*+-]|\d{1,9}[.)])/,ve.listItemStart=tt(/^( *)(bull) */).replace("bull",ve.bullet).getRegex(),ve.list=tt(ve.list).replace(/bull/g,ve.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+ve.def.source+")").getRegex(),ve._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",ve._comment=/<!--(?!-?>)[\s\S]*?(?:-->|$)/,ve.html=tt(ve.html,"i").replace("comment",ve._comment).replace("tag",ve._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),ve.paragraph=tt(ve._paragraph).replace("hr",ve.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",ve._tag).getRegex(),ve.blockquote=tt(ve.blockquote).replace("paragraph",ve.paragraph).getRegex(),ve.normal={...ve},ve.gfm={...ve.normal,table:"^ *([^\\n ].*\\|.*)\\n {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"},ve.gfm.table=tt(ve.gfm.table).replace("hr",ve.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",ve._tag).getRegex(),ve.gfm.paragraph=tt(ve._paragraph).replace("hr",ve.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("table",ve.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",ve._tag).getRegex(),ve.pedantic={...ve.normal,html:tt(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",ve._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:Js,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:tt(ve.normal._paragraph).replace("hr",ve.hr).replace("heading",` *#{1,6} *[^
96
+ ]`).replace("lheading",ve.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()};const ue={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:Js,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:Js,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,punctuation:/^([\spunctuation])/};ue._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",ue.punctuation=tt(ue.punctuation).replace(/punctuation/g,ue._punctuation).getRegex(),ue.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g,ue.escapedEmSt=/(?:^|[^\\])(?:\\\\)*\\[*_]/g,ue._comment=tt(ve._comment).replace("(?:-->|$)","-->").getRegex(),ue.emStrong.lDelim=tt(ue.emStrong.lDelim).replace(/punct/g,ue._punctuation).getRegex(),ue.emStrong.rDelimAst=tt(ue.emStrong.rDelimAst,"g").replace(/punct/g,ue._punctuation).getRegex(),ue.emStrong.rDelimUnd=tt(ue.emStrong.rDelimUnd,"g").replace(/punct/g,ue._punctuation).getRegex(),ue._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,ue._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,ue._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])?)+(?![-_])/,ue.autolink=tt(ue.autolink).replace("scheme",ue._scheme).replace("email",ue._email).getRegex(),ue._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,ue.tag=tt(ue.tag).replace("comment",ue._comment).replace("attribute",ue._attribute).getRegex(),ue._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,ue._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/,ue._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,ue.link=tt(ue.link).replace("label",ue._label).replace("href",ue._href).replace("title",ue._title).getRegex(),ue.reflink=tt(ue.reflink).replace("label",ue._label).replace("ref",ve._label).getRegex(),ue.nolink=tt(ue.nolink).replace("ref",ve._label).getRegex(),ue.reflinkSearch=tt(ue.reflinkSearch,"g").replace("reflink",ue.reflink).replace("nolink",ue.nolink).getRegex(),ue.normal={...ue},ue.pedantic={...ue.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",ue._label).getRegex(),reflink:tt(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",ue._label).getRegex()},ue.gfm={...ue.normal,escape:tt(ue.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.!#$%&'*+\/=?_`{\|}~-]+@)))/},ue.gfm.url=tt(ue.gfm.url,"i").replace("email",ue.gfm._extended_email).getRegex(),ue.breaks={...ue.gfm,br:tt(ue.br).replace("{2,}","*").getRegex(),text:tt(ue.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()};function HT(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 Mh(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||dr,this.options.tokenizer=this.options.tokenizer||new pl,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:ve.normal,inline:ue.normal};this.options.pedantic?(n.block=ve.pedantic,n.inline=ue.pedantic):this.options.gfm&&(n.block=ve.gfm,this.options.breaks?n.inline=ue.breaks:n.inline=ue.gfm),this.tokenizer.rules=n}static get rules(){return{block:ve,inline:ue}}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,c,l)=>c+" ".repeat(l.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,7 +103,7 @@ 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,c,l;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)+"["+Sh("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)+"["+Sh("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(c||(l=""),c=!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,l)){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,Th)){t=t.substring(r.raw.length),n.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(t,Th))){t=t.substring(r.raw.length),n.push(r);continue}if(s=t,this.options.extensions&&this.options.extensions.startInline){let d=1/0;const f=t.slice(1);let m;this.options.extensions.startInline.forEach(function(p){m=p.call({lexer:this},f),typeof m=="number"&&m>=0&&(d=Math.min(d,m))}),d<1/0&&d>=0&&(s=t.substring(0,d+1))}if(r=this.tokenizer.inlineText(s,HT)){t=t.substring(r.raw.length),r.raw.slice(-1)!=="_"&&(l=r.raw.slice(-1)),c=!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 ul{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$/,"")+`
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,c,l;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)+"["+_h("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)+"["+_h("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(c||(l=""),c=!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,l)){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,Mh)){t=t.substring(r.raw.length),n.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(t,Mh))){t=t.substring(r.raw.length),n.push(r);continue}if(s=t,this.options.extensions&&this.options.extensions.startInline){let d=1/0;const f=t.slice(1);let m;this.options.extensions.startInline.forEach(function(p){m=p.call({lexer:this},f),typeof m=="number"&&m>=0&&(d=Math.min(d,m))}),d<1/0&&d>=0&&(s=t.substring(0,d+1))}if(r=this.tokenizer.inlineText(s,HT)){t=t.substring(r.raw.length),r.raw.slice(-1)!=="_"&&(l=r.raw.slice(-1)),c=!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 hl{constructor(t){this.options=t||dr}code(t,n,r){const o=(n||"").match(/\S*/)[0];if(this.options.highlight){const s=this.options.highlight(t,o);s!=null&&s!==t&&(r=!0,t=s)}return t=t.replace(/\n$/,"")+`
107
107
  `,o?'<pre><code class="'+this.options.langPrefix+Ot(o)+'">'+(r?t:Ot(t,!0))+`</code></pre>
108
108
  `:"<pre><code>"+(r?t:Ot(t,!0))+`</code></pre>
109
109
  `}blockquote(t){return`<blockquote>
@@ -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=bh(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=bh(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 kh{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 Eh{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 ul,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new kh,this.slugger=new Eh}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,c,l,d,f,m,p,v,g,x,y,b,T,E,S,C;const k=t.length;for(o=0;o<k;o++){if(p=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[p.type]&&(C=this.options.extensions.renderers[p.type].call({parser:this},p),C!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(p.type))){r+=C||"";continue}switch(p.type){case"space":continue;case"hr":{r+=this.renderer.hr();continue}case"heading":{r+=this.renderer.heading(this.parseInline(p.tokens),p.depth,wh(this.parseInline(p.tokens,this.textRenderer)),this.slugger);continue}case"code":{r+=this.renderer.code(p.text,p.lang,p.escaped);continue}case"table":{for(f="",d="",a=p.header.length,s=0;s<a;s++)d+=this.renderer.tablecell(this.parseInline(p.header[s].tokens),{header:!0,align:p.align[s]});for(f+=this.renderer.tablerow(d),m="",a=p.rows.length,s=0;s<a;s++){for(l=p.rows[s],d="",c=l.length,i=0;i<c;i++)d+=this.renderer.tablecell(this.parseInline(l[i].tokens),{header:!1,align:p.align[i]});m+=this.renderer.tablerow(d)}r+=this.renderer.table(f,m);continue}case"blockquote":{m=this.parse(p.tokens),r+=this.renderer.blockquote(m);continue}case"list":{for(v=p.ordered,g=p.start,x=p.loose,a=p.items.length,m="",s=0;s<a;s++)b=p.items[s],T=b.checked,E=b.task,y="",b.task&&(S=this.renderer.checkbox(T),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,E,T);r+=this.renderer.list(m,v,g);continue}case"html":{r+=this.renderer.html(p.text);continue}case"paragraph":{r+=this.renderer.paragraph(this.parseInline(p.tokens));continue}case"text":{for(m=p.tokens?this.parseInline(p.tokens):p.text;o+1<k&&t[o+1].type==="text";)p=t[++o],m+=`
127
- `+(p.tokens?this.parseInline(p.tokens):p.text);r+=n?this.renderer.paragraph(m):m;continue}default:{const A='Token with "'+p.type+'" type was not found.';if(this.options.silent){console.error(A);return}else throw new Error(A)}}}return r}parseInline(t,n){n=n||this.renderer;let r="",o,s,i;const a=t.length;for(o=0;o<a;o++){if(s=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[s.type]&&(i=this.options.extensions.renderers[s.type].call({parser:this},s),i!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type))){r+=i||"";continue}switch(s.type){case"escape":{r+=n.text(s.text);break}case"html":{r+=n.html(s.text);break}case"link":{r+=n.link(s.href,s.title,this.parseInline(s.tokens,n));break}case"image":{r+=n.image(s.href,s.title,s.text);break}case"strong":{r+=n.strong(this.parseInline(s.tokens,n));break}case"em":{r+=n.em(this.parseInline(s.tokens,n));break}case"codespan":{r+=n.codespan(s.text);break}case"br":{r+=n.br();break}case"del":{r+=n.del(this.parseInline(s.tokens,n));break}case"text":{r+=n.text(s.text);break}default:{const c='Token with "'+s.type+'" type was not found.';if(this.options.silent){console.error(c);return}else throw new Error(c)}}}return r}}class Zs{constructor(t){this.options=t||lr}preprocess(t){return t}postprocess(t){return t}}ax(Zs,"passThroughHooks",new Set(["preprocess","postprocess"]));function UT(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>"+Ot(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 Ih(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...me.defaults,...s};const i=UT(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(BT(r),r.hooks&&(r.hooks.options=r),o){const a=r.highlight;let c;try{r.hooks&&(n=r.hooks.preprocess(n)),c=e(n,r)}catch(f){return i(f)}const l=function(f){let m;if(!f)try{r.walkTokens&&me.walkTokens(c,r.walkTokens),m=t(c,r),r.hooks&&(m=r.hooks.postprocess(m))}catch(p){f=p}return r.highlight=a,f?i(f):o(null,m)};if(!a||a.length<3||(delete r.highlight,!c.length))return l();let d=0;me.walkTokens(c,function(f){f.type==="code"&&(d++,setTimeout(()=>{a(f.text,f.lang,function(m,p){if(m)return l(m);p!=null&&p!==f.text&&(f.text=p,f.escaped=!0),d--,d===0&&l()})},0))}),d===0&&l();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(me.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&&me.walkTokens(a,r.walkTokens);let c=t(a,r);return r.hooks&&(c=r.hooks.postprocess(c)),c}catch(a){return i(a)}}}function me(e,t,n){return Ih(Wn.lex,Vn.parse)(e,t,n)}me.options=me.setOptions=function(e){return me.defaults={...me.defaults,...e},IT(me.defaults),me},me.getDefaults=mh,me.defaults=lr,me.use=function(...e){const t=me.defaults.extensions||{renderers:{},childTokens:{}};e.forEach(n=>{const r={...n};if(r.async=me.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=me.defaults.renderer||new ul;for(const s in n.renderer){const i=o[s];o[s]=(...a)=>{let c=n.renderer[s].apply(o,a);return c===!1&&(c=i.apply(o,a)),c}}r.renderer=o}if(n.tokenizer){const o=me.defaults.tokenizer||new cl;for(const s in n.tokenizer){const i=o[s];o[s]=(...a)=>{let c=n.tokenizer[s].apply(o,a);return c===!1&&(c=i.apply(o,a)),c}}r.tokenizer=o}if(n.hooks){const o=me.defaults.hooks||new Zs;for(const s in n.hooks){const i=o[s];Zs.passThroughHooks.has(s)?o[s]=a=>{if(me.defaults.async)return Promise.resolve(n.hooks[s].call(o,a)).then(l=>i.call(o,l));const c=n.hooks[s].call(o,a);return i.call(o,c)}:o[s]=(...a)=>{let c=n.hooks[s].apply(o,a);return c===!1&&(c=i.apply(o,a)),c}}r.hooks=o}if(n.walkTokens){const o=me.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}}me.setOptions(r)})},me.walkTokens=function(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(me,r)),r.type){case"table":{for(const o of r.header)n=n.concat(me.walkTokens(o.tokens,t));for(const o of r.rows)for(const s of o)n=n.concat(me.walkTokens(s.tokens,t));break}case"list":{n=n.concat(me.walkTokens(r.items,t));break}default:me.defaults.extensions&&me.defaults.extensions.childTokens&&me.defaults.extensions.childTokens[r.type]?me.defaults.extensions.childTokens[r.type].forEach(function(o){n=n.concat(me.walkTokens(r[o],t))}):r.tokens&&(n=n.concat(me.walkTokens(r.tokens,t)))}return n},me.parseInline=Ih(Wn.lexInline,Vn.parseInline),me.Parser=Vn,me.parser=Vn.parse,me.Renderer=ul,me.TextRenderer=kh,me.Lexer=Wn,me.lexer=Wn.lex,me.Tokenizer=cl,me.Slugger=Eh,me.Hooks=Zs,me.parse=me,me.options,me.setOptions,me.use,me.walkTokens,me.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 me.parse=="function"?me.parse(i):me(i)}return typeof me.parse=="function"?me.parse(e):me(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 Nh({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 Ah({artifact:e,idx:t=0}){const n=w.useMemo(()=>e?(Array.isArray(e.plots)?e.plots:[]).map(o=>fw(o)).filter(o=>o!==null):[],[e]);return n.length>0?u.jsx("div",{className:"space-y-2",children:n.map((r,o)=>u.jsx(Nh,{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 WT="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 Qs({data:e}){return Array.isArray(e)?e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?u.jsx("div",{className:WT,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:br(e)}):u.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:br(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,c)=>{var l;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:((l=a.type)==null?void 0:l.replace(/\./g," "))??"progress"}),u.jsx("span",{children:a.idx??c+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}-${c}`)})})]}):null}const dl=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}));dl.displayName="Card";const fl=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:ne("flex flex-col space-y-1.5 p-6",e),...t}));fl.displayName="CardHeader";const pl=h.forwardRef(({className:e,...t},n)=>u.jsx("h3",{ref:n,className:ne("text-2xl font-semibold leading-none tracking-tight",e),...t}));pl.displayName="CardTitle";const hl=h.forwardRef(({className:e,...t},n)=>u.jsx("p",{ref:n,className:ne("text-sm text-muted-foreground",e),...t}));hl.displayName="CardDescription";const ei=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:ne("p-6 pt-0",e),...t}));ei.displayName="CardContent";const Ph=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:ne("flex items-center p-6 pt-0",e),...t}));Ph.displayName="CardFooter";const VT=e=>!!e&&typeof e=="object"&&e.type==="user_choice"&&typeof e.question=="string"&&Array.isArray(e.alternatives);function ml({interruptPart:e,onApprove:t,onReject:n,onSelectAlternative:r,disabled:o,isActive:s,payload:i}){const a=VT(i)?i:null,c=(a==null?void 0:a.question)??e.title??"Approve the result?",l=a?s?"Select one of the alternatives to continue.":"Waiting for approval from another participant.":s?"Please approve or reject this action to resume the workflow.":"Waiting for approval from another participant.";let d=null;if(!a&&i!==void 0&&i!==null)if(typeof i=="string")d=u.jsx("p",{className:"text-sm leading-relaxed text-blue-800/90 dark:text-blue-200/90 whitespace-pre-wrap",children:i});else{const f=br(i);d=u.jsx("pre",{className:"max-h-48 overflow-auto rounded bg-blue-100/60 p-2 text-xs text-blue-900/90 dark:bg-blue-900/40 dark:text-blue-100/80",children:f})}return u.jsxs(dl,{className:ne("border-blue-200 dark:border-blue-800 bg-blue-50/50 dark:bg-blue-950/10 transition-shadow",s?"shadow-md ring-1 ring-blue-300 dark:ring-blue-500/70":"opacity-80"),children:[u.jsxs(fl,{className:"pb-3",children:[u.jsx(pl,{className:"text-blue-900 dark:text-blue-100 text-base",children:c}),u.jsx(hl,{className:"text-blue-700 dark:text-blue-300 text-sm",children:l})]}),a?u.jsx(ei,{className:"pt-0 pb-3",children:u.jsx("div",{className:"space-y-2",children:a.alternatives.map(f=>u.jsx(Je,{size:"sm",variant:"outline",onClick:()=>r==null?void 0:r(e,f),className:"w-full justify-start text-left",disabled:o||!s,children:u.jsxs("div",{className:"flex flex-col items-start gap-1",children:[u.jsx("span",{className:"font-semibold",children:f.label}),f.description?u.jsx("span",{className:"text-xs text-muted-foreground leading-snug",children:f.description}):null]})},f.id))})}):d&&u.jsx(ei,{className:"pt-0 pb-3",children:d}),!a&&u.jsx(Ph,{className:"pt-0",children:u.jsxs("div",{className:"flex gap-2 ml-auto",children:[u.jsx(Je,{size:"sm",variant:"outline",onClick:()=>n(e),className:"border-red-300 text-red-700 hover:bg-red-50 dark:border-red-700 dark:text-red-300 dark:hover:bg-red-950/50",disabled:o||!s,children:"Reject"}),u.jsx(Je,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",disabled:o||!s,children:"Approve"})]})})]})}function _h({className:e}){const t=w.useRef(null);return w.useEffect(()=>{let n=0;const r=()=>{if(n=(n+1)%4,t.current){const s=".".repeat(n);t.current.textContent=`Is thinking${s}`}};r();const o=setInterval(r,500);return()=>clearInterval(o)},[]),u.jsx("span",{ref:t,"aria-live":"polite",className:ne("inline-block text-xs opacity-70 ml-1",e),children:"Is thinking"})}function Rh({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(cr,{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(Je,{type:"button",variant:"ghost",size:"sm",className:"h-6 text-xs !text-[hsl(var(--chat-bubble-user-text))]",onClick:()=>n(!t),children:t?u.jsxs(u.Fragment,{children:[u.jsx(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 Mh(e){const{allowFileOpen:t,currentThreadId:n}=e,{toast:r}=ll(),[o,s]=w.useState({}),[i,a]=w.useState(null),[c,l]=w.useState(!1),d=w.useCallback(()=>{l(!1),a(null)},[]),f=w.useCallback(p=>{a(p),l(!0)},[]),m=w.useCallback(async(p,v,g)=>{var x,y;if(!t){p.preventDefault();return}if(o[g]){p.preventDefault();return}try{const b=String(v.url??""),T=b.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);if(T){p.preventDefault();const E=T[1],S=v.name||`file_${E}`,C=v.mimeType||"application/octet-stream";f({id:E,name:S,mimeType:C});return}if(b.startsWith("data:")){p.preventDefault(),s(S=>({...S,[g]:!0}));const E=r({title:"Fetching file...",description:"",open:!0});try{const S=await su(n??void 0);if(!S||!Array.isArray(S))throw new Error("Invalid file list response");const C=S.find(k=>!k||typeof k!="object"||!((k.filename??"")===(v.name??""))?!1:typeof v.size=="number"&&typeof k.size=="number"?k.size===v.size:!0);if(!(C!=null&&C.id))throw new Error(`File "${v.name}" is not yet available on the server`);if(!C.id||!C.filename)throw new Error("Invalid file data received from server");f({id:C.id,name:v.name||C.filename||`file_${C.id}`,mimeType:v.mimeType||C.mime_type||"application/octet-stream"}),(x=E.update)==null||x.call(E,{id:E.id,title:"Success",description:`Opened ${v.name}`,open:!0})}catch(S){console.error("Failed to fetch server file:",S);const C=S instanceof Error?S.message:"Unknown error occurred";(y=E.update)==null||y.call(E,{id:E.id,title:"Failed",description:C}),r({title:"Failed to fetch file",description:C,open:!0})}finally{s(S=>({...S,[g]:!1}))}}}catch(b){console.error("File click error:",b),s(T=>({...T,[g]:!1}))}},[t,o,r,n,f]);return{uploadingFiles:o,handleFileClick:m,fileViewerOpen:c,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:iw(r),toolMeta:Bi(n),imageParts:r.filter(s=>s.type==="image_url"),fileParts:r.filter(s=>s.type==="file"),interruptParts:r.filter(s=>s.type==="interrupt"),toolRaw:aw(r),isToolStreaming:!!o.toolStreaming}},[e,t])}const Dh="data:";function KT(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=wr(s);i&&typeof i=="object"&&t.push(i)}return t}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(l=>l.type==="text");if(!t.length)return null;let r=t.flatMap(l=>KT(l.text??""));if(!r.length){const l=t.map(f=>f.text??"").join(`
129
- `),d=wr(l);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=ro(i),c=yr(a);return c&&typeof c=="object"&&!Array.isArray(c)?{kind:"dict",value:c,data:c,event:s}:{kind:"generic",value:c,event:s}},[e])}function Lh({message:e,viewMode:t,isStreaming:n=!1,toolRenderers:r,toolArtifactRenderers:o}){var S;const s=Bi(e),i=e.artifact??null,a=GT(e),l=(a?pw(a):null)??a,d=e.content.find(C=>C.type!=="tool_call"),f=C=>{if(C==null)return null;const k=typeof C=="string"?wr(C)??C:C;if(k&&typeof k=="object")return u.jsx(Qs,{data:k});const A=typeof k=="string"?k:(()=>{try{return br(k)}catch{return String(k??"")}})();return u.jsx("pre",{className:"whitespace-pre-wrap break-words font-sans text-sm text-foreground/90",children:A})},m=C=>{if(C==null)return null;const{content:k,isMarkdown:A}=sw(C);return A?u.jsx(cr,{content:k,className:"text-current"}):f(C)},p=C=>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(Qs,{data:C})]}),v=()=>{if((l==null?void 0:l.kind)==="generic")return m(l.value);if(!d)return null;if(d.type==="text"){const P=(d.text??"").trim();if(!P)return null;const L=yr(P);return m(L)}const C=no(d),k=yr(C);return m(k)},g=()=>(l==null?void 0:l.kind)==="dict"?p(l.data):v(),y=(()=>{if(!r)return;if(s.name){const k=r[s.name];if(k)return k}const C=(l==null?void 0:l.kind)??(a==null?void 0:a.kind);if(C){const k=r[C];if(k)return k}return r.default})(),b=(y==null?void 0:y({message:e,toolMeta:s,toolPayload:l,viewMode:t,isStreaming:n}))??null,E=((S=(()=>{if(!o)return;const C=i==null?void 0:i.type;if(typeof C=="string"){const k=o[C];if(k)return k}return o.default})())==null?void 0:S({artifact:i,message:e,toolPayload:l,isStreaming:n}))??null;return u.jsxs("div",{className:"space-y-2",children:[i&&(E??u.jsx(Ah,{artifact:i,idx:0})),u.jsx(jh,{message:e,isStreaming:n}),t==="expanded"&&u.jsx(u.Fragment,{children:b??g()})]})}const YT={checkpoints:[],checkpointMetaByCheckpointId:new Map,timeline:[],messagePreviews:new Map,getLatest:()=>{},getCheckpoint:()=>{},getMessageAttempts:()=>[]},gl=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,xl=w.memo(function({message:t,index:n,isStreaming:r,streamingAssistantId:o,streamingDebounceMs:s,layoutSize:i,enableMessageEditing:a,editingMessageId:c,onEdit:l,onRegenerate:d,onCancelEdit:f,showToolMessages:m,checkpointIndex:p,onSelectCheckpoint:v,getMessageCustomStyles:g,getInterruptOptions:x,toolRenderers:y,toolArtifactRenderers:b}){const T=gl(t,n),E=t.role==="default_message",C=!!t.__syntheticStreaming,k=p??YT,A=!E&&"checkpointId"in t?t.checkpointId??null:null,{attemptCount:P,attemptIndex:L,attempts:F}=w.useMemo(()=>sc(t.id,A,k),[t.id,A,k]),K=g==null?void 0:g(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(ti,{message:t,messageIndex:n,isStreamingMessage:C||r&&o===t.id&&t.role==="assistant",streamingDebounceMs:s,isEditing:c===t.id,showActions:a,showTimestamp:!1,showAgentName:!0,layoutSize:i,onEdit:l,onRegenerate:()=>d(n),onCancelEdit:f,getInterruptOptions:x,showToolMessages:m,attemptCount:P,attemptIndex:L,attemptMetas:F,onSelectCheckpoint:v,customStyles:K,toolRenderers:y,toolArtifactRenderers:b})})});xl.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,c)=>{if(a.type!=="text")return s.current[c]=void 0,a;const l=a.text??"",d=s.current[c];return n(l)?(s.current[c]=l,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:c,interruptPart:l,isStreamingMessage:d,enableStreamingMarkdownBuffer:f,renderStreamingMarkdown:m,defaultMessage:p,handleFileClick:v,uploadingFiles:g,messageRole:x,truncateUserMessages:y,userMessagePreviewLength:b,isUserExpanded:T,setIsUserExpanded:E,isCompactLayout:S,iconForeground:C,toolRenderers:k,toolArtifactRenderers:A,handleInterruptApprove:P,handleInterruptReject:L,handleInterruptAlternative:F,disableInterruptActions:K,isInterruptMessage:J}){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"})]}),[]),q=XT(s,(f??!0)&&d,$h),W=w.useMemo(()=>q.filter(z=>z.type==="text"),[q]),D=w.useMemo(()=>W.map(z=>z.text??"").join(""),[W]),I=w.useMemo(()=>{if(!m)return null;const z=ZT(D);return{stablePart:D.slice(0,z),tailPart:D.slice(z)}},[D,m]),G=w.useMemo(()=>{if(!I)return null;const{stablePart:z,tailPart:O}=I;return!z&&!O?null:u.jsxs("div",{className:"space-y-2",children:[z?u.jsx(cr,{content:z,allowHtml:!1}):null,O?u.jsx(cr,{content:O,allowHtml:!1}):null]})},[I]),X=w.useMemo(()=>{if(!m)return q;const z=[];let O=!1;for(const j of q){if(j.type==="text"){O||(z.push({type:"text",text:"",__streamingMarkdownAggregate:!0}),O=!0);continue}z.push(j)}return z},[q,m]),B=(m?X:q).filter(z=>z.type!=="interrupt"),R=w.useCallback(({part:z,i:O})=>{if(z.type==="text"){if(m)return null;const j=z.text??"",U=j.trim(),Q=wr(U);return Q&&x!=="tool"?u.jsx(Qs,{data:Q},O):x==="user"&&y&&U.length>b?u.jsx(Rh,{text:U,expanded:T,onExpandedChange:E,previewLength:b,isCompact:S},O):u.jsx(cr,{content:j,allowHtml:!1},O)}if(z.type==="image_url"){const j=z;return u.jsx("div",{className:"my-2",children:u.jsx("img",{src:j.url,alt:j.alt??"",loading:"lazy",className:"border rounded max-h-[420px] w-auto object-contain"})},O)}if(z.type==="file"){const j=z,U=j.name||"file";return u.jsxs("a",{href:j.url,onClick:Q=>v(Q,j,O),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[O]?u.jsx(le.Loader,{className:"h-4 w-4 animate-spin"}):null,u.jsxs("span",{className:"truncate max-w-[180px]",children:[U,g[O]?" (processing)":""]})]},O)}return null},[v,S,T,x,y,g,b,m,E]),$=i.trim().length>0||a.length>0||c.length>0||B.length>0;if(!t&&c.length>0&&!d)return _();if(!t&&!$&&!d)return null;if(t){if(!n)return null;if(J&&l){const z=l.value,O=!K,j=P??(()=>{}),U=L??(()=>{});return u.jsx(ml,{interruptPart:l,payload:z,onApprove:j,onReject:U,onSelectAlternative:F,disabled:K,isActive:O})}return u.jsx(Lh,{message:e,viewMode:r,isStreaming:o,toolRenderers:k,toolArtifactRenderers:A},e.id)}if(!p){const z=u.jsx("div",{className:"space-y-2",children:B.map((O,j)=>m&&QT(O)?G?u.jsx("div",{className:"space-y-2",children:G},`streaming-md-${j}`):null:u.jsx(R,{part:O,i:j},j))});return d?u.jsxs("div",{"aria-busy":"true",role:"status",children:[z,u.jsx(_h,{className:C})]}):z}return null}function $h(e){return e?!(Po(e,/```/g)||Po(e,/`/g)||Po(e,/\*\*/g)||Po(e,/__/g)||Po(e,/~~/g)||/[^\\]\[[^\]]*$/.test(e)||/\[[^\]]*\]\([^)]*$/.test(e)):!0}function Po(e,t){const n=e.match(t);return((n==null?void 0:n.length)??0)%2!==0}function 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=Wr.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,isInterruptMessage:r=!1,iconForeground:o,agentName:s,messageIcon:i,customHeaderClass:a,customActionsClass:c,isCompactLayout:l,showActions:d,isEditing:f,messageRole:m,toolViewMode:p,toolMeta:v,onToggleToolView:g,onCopy:x,onEdit:y,onRegenerate:b,showCheckpointControls:T,attemptCount:E,attemptIndex:S,handleOlderAttemptSelect:C,handleNewerAttemptSelect:k,messageCreatedAt:A,copied:P}){return!e&&!t&&!n&&!r?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",o,a),children:[u.jsxs("div",{className:"flex items-center gap-2",children:[i,t&&s&&u.jsx("span",{className:ne("font-medium",l?"text-xs":"text-sm"),children:s}),n&&!r&&u.jsxs(Fh,{variant:"outline",className:ne("text-xs flex items-center gap-1 cursor-pointer select-none",o,"border border-current/40",l&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":p==="expanded",onClick:g,onKeyDown:L=>{(L.key==="Enter"||L.key===" ")&&(L.preventDefault(),g())},children:[u.jsx("span",{children:v.name??"Tool Output"}),v.toolCallId&&u.jsx("span",{className:"opacity-70",children:v.toolCallId.slice(0,8)}),p==="expanded"?u.jsx(le.ChevronUp,{className:"h-3 w-3"}):u.jsx(le.ChevronDown,{className:"h-3 w-3"})]}),r&&u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:v.name??"Interrupt"})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[T&&E>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",S<E-1?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{S>=E-1||C()},"aria-label":"Older attempt (back in time)",disabled:S>=E-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:[E-S," / ",E]})}),u.jsx("button",{type:"button",className:ne("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",S>0?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{S<=0||k()},"aria-label":"Newer attempt (forward in time)",disabled:S<=0,children:u.jsx(le.ChevronRight,{className:"h-3 w-3"})})]}),e&&A&&u.jsx("time",{className:ne("text-xs opacity-60",o,l&&"text-xs"),dateTime:new Date(A).toISOString(),title:new Date(A).toLocaleString(),children:new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(new Date(A))}),d&&!f&&u.jsxs("div",{className:ne("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",c),children:[u.jsx("div",{className:"relative",children:u.jsx(Je,{variant:"ghost",size:"sm",onClick:x,className:ne("h-6 w-6 p-0 hover:bg-foreground/10",o,l&&"h-5 w-5"),"aria-label":"Copy message",title:"Copy message",children:u.jsx(le.Copy,{className:ne(P?"text-success":o,l?"h-3 w-3":"h-4 w-4")})})}),m==="user"&&y&&u.jsx(Je,{variant:"ghost",size:"sm",onClick:y,className:ne("h-6 w-6 p-0 hover:bg-foreground/10",o,l&&"h-5 w-5"),"aria-label":"Edit message",children:u.jsx(le.Edit,{className:ne(o,l?"h-3 w-3":"h-4 w-4")})}),m==="assistant"&&b&&u.jsx(Je,{variant:"ghost",size:"sm",onClick:b,className:ne("h-6 w-6 p-0 hover:bg-foreground/10",o,l&&"h-5 w-5"),"aria-label":"Regenerate response",children:u.jsx(le.RotateCcw,{className:ne(o,l?"h-3 w-3":"h-4 w-4")})})]})]})]})}const ti=w.memo(function({message:t,messageIndex:n,isStreamingMessage:r=!1,isEditing:o=!1,showActions:s=!0,showTimestamp:i=!0,showAgentName:a=!0,layoutSize:c="desktop",truncateUserMessages:l=!0,userMessagePreviewLength:d=500,showToolMessages:f=!0,toolRenderers:m,toolArtifactRenderers:p,customStyles:v={},streamingDebounceMs:g=300,renderStreamingMarkdown:x=!1,enableStreamingMarkdownBuffer:y,onEdit:b,onRegenerate:T,onCopy:E,getInterruptOptions:S,attemptCount:C=1,attemptIndex:k=0,onSelectCheckpoint:A,attemptMetas:P=[]}){const[L,F]=w.useState(!1),[K,J]=w.useState("preview"),[_,Y]=w.useState(!1),{currentThreadId:q}=vr(),{respondToInterrupt:W}=oo(),[D,I]=w.useState(!1),G=c==="phone"||c==="half-screen",X=t.role,M=X==="interrupt",B=X==="tool"||M,$=!(t.role==="default_message")&&t.expandable!==void 0?t.expandable!==!1:!0,z=w.useMemo(()=>t.role==="default_message"?t:null,[t]),O=!!z,j=!(r&&X!=="user"),{uploadingFiles:U,handleFileClick:Q,fileViewerOpen:se,currentFileInfo:ie,closeFileViewer:Se}=Mh({allowFileOpen:j,currentThreadId:q}),xe=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"interrupt":return"text-[hsl(var(--chat-bubble-ai-text))]";case"tool":return"text-secondary-foreground";case"system":return"text-muted-foreground";default:return"text-[hsl(var(--chat-bubble-ai-text))]"}},[X]),Re=Oh(t,z),{contentParts:Ve,imageParts:De,fileParts:Ge,textContent:He,toolMeta:ot,toolRaw:ut,isToolStreaming:nt,interruptParts:Le}=Re,Ke=y??g!==0,$e=w.useMemo(()=>Le.length?Le[0]:null,[Le]),Te=w.useCallback(async()=>{const je=B?ut:He;async function Ye(we){if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function"){await navigator.clipboard.writeText(we);return}if(navigator.clipboard&&typeof navigator.clipboard.write=="function"&&typeof ClipboardItem<"u"){const Qe=new Blob([we],{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 Ye(je),F(!0),setTimeout(()=>F(!1),2e3),E==null||E(je)}catch(we){console.error("Failed to copy:",we)}},[B,ut,He,E]),Ae=w.useCallback(async(je,Ye)=>{if(!$e)return;if(!bu($e.id)){console.warn("Interrupt part missing id",$e);return}I(!0);try{const Qe=S==null?void 0:S(t);await W(je,Ye,Qe)}catch(Qe){console.error("Failed to respond to interrupt:",Qe)}finally{I(!1)}},[$e,W]),dt=w.useCallback(()=>Ae(!0),[Ae]),Et=w.useCallback(()=>Ae(!1),[Ae]),at=w.useCallback((je,Ye)=>{if(!Ye)return;const we={alternativeId:Ye.id??Ye.label??void 0,alternativeLabel:Ye.label};Ae(!0,we)},[Ae]),It=w.useCallback(()=>{if(!b||!t.id)return;const je=(B?ut:He)??"",Ye="type"in t&&t.type==="default_message"?void 0:{checkpointId:t.checkpointId??null,checkpointNs:t.checkpointNs??null};b(t.id,je,Ye)},[b,B,ut,He,t]),bt=w.useCallback(()=>{T==null||T(n)},[T,n]),ft=!M&&$,Nt=w.useCallback(()=>{ft&&J(je=>je==="expanded"?"preview":"expanded")},[ft]),Ct=M?"expanded":K,on=w.useCallback(()=>{const Ye=ne(G?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",xe);switch(X){case"user":return u.jsx(le.User,{className:Ye});case"assistant":return u.jsx(le.Bot,{className:Ye});case"tool":return u.jsx(le.Wrench,{className:Ye});case"interrupt":return u.jsx(le.Bot,{className:Ye});default:return u.jsx(le.Bot,{className:Ye})}},[G,xe,X]),Tt=w.useCallback(()=>{const je="group relative mb-4 flex w-full";switch(X){case"user":return ne(je,"justify-end");case"assistant":case"tool":case"system":case"interrupt":return ne(je,"justify-start");default:return je}},[X]),Ie=w.useCallback(()=>{const je=ne("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",G&&"px-3 py-2 text-sm");if(O)return ne(je,"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(je,"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(je,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40");case"tool":case"interrupt":return ne(je,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return ne(je,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return ne(je,"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,O,X]),Ue=(f||M)&&$,jt=u.jsx(JT,{message:t,isToolMessage:B,showToolMessages:Ue,toolViewMode:Ct,isToolStreaming:nt,contentParts:Ve,textContent:He,imageParts:De,fileParts:Ge,isStreamingMessage:r,defaultMessage:z,enableStreamingMarkdownBuffer:Ke,renderStreamingMarkdown:x,handleFileClick:Q,uploadingFiles:U,messageRole:X,truncateUserMessages:l,userMessagePreviewLength:d,isUserExpanded:_,setIsUserExpanded:Y,isCompactLayout:G,iconForeground:xe,toolRenderers:m,toolArtifactRenderers:p,interruptPart:$e,handleInterruptApprove:dt,handleInterruptReject:Et,handleInterruptAlternative:at,disableInterruptActions:D,isInterruptMessage:M}),te=w.useMemo(()=>z?"Assistant":lw(t),[z,t]),ge=on(),rt=X==="user"&&(C??1)>1&&typeof A=="function",fe=(P==null?void 0:P.length)??0,ke=fe>0&&k<fe-1?P[k+1]:void 0,Fe=fe>0&&k>0?P[k-1]:void 0,ht=w.useCallback(()=>{!ke||!A||A(ke.id,void 0,!!ke.isLatestAttempt)},[ke,A]),pt=w.useCallback(()=>{!Fe||!A||A(Fe.id,void 0,!!Fe.isLatestAttempt)},[Fe,A]);return B&&!f?null:O&&z?u.jsx("div",{className:ne(Tt(),v.container),children:u.jsxs("div",{className:ne(Ie(),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:ne("h-4 w-4",xe)}),a&&u.jsx("span",{className:"font-medium text-sm",children:"Assistant"})]}),u.jsx(cr,{content:z.content,className:"text-current"})]})}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:ne(Tt(),v.container),children:u.jsxs("div",{className:ne(Ie(),v.content),children:[u.jsx(tk,{showTimestamp:i,showAgentName:a,isToolMessage:B,iconForeground:xe,agentName:te,messageIcon:ge,customHeaderClass:v.header,customActionsClass:v.actions,isCompactLayout:G,showActions:s,isEditing:o,messageRole:X,toolViewMode:Ct,isInterruptMessage:M,toolMeta:ot,onToggleToolView:Nt,onCopy:Te,onEdit:It,onRegenerate:bt,showCheckpointControls:rt,attemptCount:C,attemptIndex:k,handleOlderAttemptSelect:ht,handleNewerAttemptSelect:pt,messageCreatedAt:t.createdAt,copied:L}),u.jsx("div",{className:"relative",children:jt}),B&&Ct==="expanded"&&(ot.toolCallId||ot.name)&&u.jsxs("div",{className:ne("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",G&&"text-xs"),children:[ot.name&&u.jsxs("div",{children:["Function: ",ot.name]}),ot.toolCallId&&u.jsxs("div",{children:["Call ID: ",ot.toolCallId]})]}),!(i||a||B)&&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",v.actions),children:[u.jsx(Je,{variant:"ghost",size:"sm",onClick:()=>Te(),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(L?"text-success":"text-current",G?"h-3 w-3":"h-4 w-4")})}),X==="user"&&b&&u.jsx(Je,{variant:"ghost",size:"sm",onClick:It,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"&&T&&u.jsx(Je,{variant:"ghost",size:"sm",onClick:bt,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")})})]})]})}),ie&&u.jsx(hh,{isOpen:se,onClose:Se,fileId:ie.id,fileName:ie.name,mimeType:ie.mimeType})]})},(e,t)=>{var c,l,d,f,m,p,v,g;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&yu(e.message)===yu(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateUserMessages","userMessagePreviewLength","showToolMessages","toolRenderers","toolArtifactRenderers"].every(x=>e[x]===t[x]),s=((c=e.customStyles)==null?void 0:c.container)===((l=t.customStyles)==null?void 0:l.container)&&((d=e.customStyles)==null?void 0:d.content)===((f=t.customStyles)==null?void 0:f.content)&&((m=e.customStyles)==null?void 0:m.actions)===((p=t.customStyles)==null?void 0:p.actions)&&((v=e.customStyles)==null?void 0:v.header)===((g=t.customStyles)==null?void 0:g.header);if(!o||!s)return!1;const i=Su(e.message),a=Su(t.message);return i.length===a.length});ti.displayName="MessageComponent";const vl=w.forwardRef(({messages:e,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onStartReached:a,onEdit:c,onRegenerate:l,onCancelEdit:d,className:f,style:m,emptyMessage:p,followNewMessages:v=!0,isNavigatingCheckpoint:g=!1,onScrollAway:x,onAtBottom:y,showToolMessages:b=!0,toolRenderers:T,toolArtifactRenderers:E,checkpointIndex:S,activeCheckpointId:C,onSelectCheckpoint:k,createSyntheticThinkingMessage:A=!0,forceSyntheticThinking:P=!1,getMessageCustomStyles:L,getInterruptOptions:F},K)=>{const J=w.useRef(null),_=w.useRef(null),Y=w.useRef(!1),q=w.useRef(!1),W=e,D=w.useMemo(()=>{const j=n&&W.some(Q=>Q.id===n);return A&&(t||P)&&!j&&W.length>0?[...W,{id:"thinking-assistant",role:"assistant",content:[{type:"text",text:""}],createdAt:new Date().toISOString(),__syntheticStreaming:!0}]:W},[W,t,n,A,P]),I=w.useMemo(()=>b?D:D.filter(j=>(j==null?void 0:j.role)!=="tool"),[D,b]),G=w.useCallback(j=>{x&&x(!j),y&&y(j)},[x,y]),X=w.useMemo(()=>{if(a)return async()=>{if(!Y.current){Y.current=!0;try{await a()}finally{Y.current=!1}}}},[a]),M=w.useMemo(()=>!v||g?!1:"auto",[v,g]),B=w.useMemo(()=>{if(typeof p!="string")return null;const j=p.trim();return!j||I&&I.length>0?null:{id:"default-message",role:"default_message",content:j,createdAt:new Date().toISOString()}},[p,I]),R=["flex h-full flex-col md:flex-row",f].filter(Boolean).join(" "),$=()=>{if(B){const j=L==null?void 0:L(B);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(ti,{message:B,messageIndex:0,isStreamingMessage:!1,showActions:!1,showTimestamp:!1,showAgentName:!0,layoutSize:o,onEdit:()=>{},onRegenerate:()=>{},onCancelEdit:()=>{},customStyles:j,getInterruptOptions:F})})})}return u.jsx("div",{className:"flex h-full items-center justify-center py-8 text-center text-muted-foreground",children:p??"No messages yet. Start a conversation!"})},z=I.length,O=z>0;return w.useEffect(()=>{var j,U;if(z===0){q.current=!1;return}if(!q.current)if(q.current=!0,J.current&&I.length>0){const Q=I.length-1;(U=(j=J.current).scrollToIndex)==null||U.call(j,{index:Q,align:"end",behavior:"auto"})}else _.current&&(_.current.scrollTop=_.current.scrollHeight)},[z,I.length]),w.useImperativeHandle(K,()=>({scrollToLatest:()=>{var j,U;if(J.current&&I.length>0){const Q=I.length-1;(U=(j=J.current).scrollToIndex)==null||U.call(j,{index:Q,align:"end",behavior:"auto"})}else _.current&&(_.current.scrollTop=_.current.scrollHeight)},scrollToTop:()=>{var j,U;J.current&&I.length>0?(U=(j=J.current).scrollToIndex)==null||U.call(j,{index:0,align:"start",behavior:"auto"}):_.current&&(_.current.scrollTop=0)}}),[I]),u.jsx("div",{className:R,style:m,children:u.jsx("div",{className:"relative flex-1 min-h-0",children:O?u.jsx(YC,{ref:j=>{J.current=j},scrollerRef:j=>{_.current=j instanceof HTMLDivElement?j:null},data:I,followOutput:M,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,startReached:()=>{X&&X()},atBottomStateChange:G,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(j,U)=>gl(U,j),itemContent:(j,U)=>u.jsx(xl,{message:U,index:j,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onEdit:c,onRegenerate:l,onCancelEdit:d,showToolMessages:b,toolRenderers:T,toolArtifactRenderers:E,checkpointIndex:S,activeCheckpointId:C,onSelectCheckpoint:k,getMessageCustomStyles:L,getInterruptOptions:F})}):$()})})});vl.displayName="MessageList";const Bh={value:""};function Lr({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:c=!1,enableMessageEditing:l=!0,showToolMessages:d=!0,toolRenderers:f,toolArtifactRenderers:m,payloadExtras:p={},customStyles:v={},messageCustomStyles:g,onMessageSent:x,onExcelUploadSuccess:y,onError:b,defaultMessage:T}){const{api:E}=eo(),S=E.baseUrl,{currentThreadId:C}=vr(),{threadId:k,messages:A,isLoading:P,navigateToCheckpoint:L,returnToLatest:F,checkpoint:K,checkpoints:J,interrupt:_,metadata:Y,checkpointIndex:q,respondToInterrupt:W}=oo(),{isStreaming:D,error:I,connectionState:G,submit:X,stop:M}=Ui(),B=k??C??null,R=(K==null?void 0:K.id)??null,$=(K==null?void 0:K.namespace)??null,z=(Y==null?void 0:Y.assemblingMessageId)??null,O=_,j=O?bu(O.id):null,U=j!==null?{type:"interrupt",id:j}:null,[Q,se]=w.useState(!1),[ie,Se]=w.useState(!1);w.useEffect(()=>{O||se(!1)},[O]);const xe=w.useCallback(()=>{se(!0)},[]),Re=w.useCallback(()=>{se(!1)},[]),Ve=w.useCallback(N=>{},[]),De=w.useCallback(async(N,Z,re)=>{try{xe(),await W(N,Z,re)}catch(de){console.error("Failed to respond to interrupt:",de)}finally{Re()}},[Re,xe,W]),Ge=w.useCallback(()=>De(!0),[De]),He=w.useCallback(()=>De(!1),[De]),ot=w.useCallback((N,Z)=>De(!0,Z),[De]),ut=!!O||Q,[nt,Le]=w.useState(null),[Ke,$e]=w.useState(""),[Te,Ae]=w.useState(null),[dt,Et]=w.useState(null),[at,It]=w.useState(!1),[bt,ft]=w.useState(null),Nt=w.useRef(!1),[At,Ct]=w.useState(()=>Bh.value),on=w.useRef(At),Tt=w.useRef(null),Ie=w.useCallback(N=>{Bh.value=N,Ct(N)},[]),[Ue,jt]=w.useState(!1),te=w.useRef(null),ge=w.useCallback(N=>{Ie(N)},[Ie]);w.useEffect(()=>{D||Se(!1)},[D]),w.useEffect(()=>{Y!=null&&Y.assemblingMessageId&&Se(!1)},[Y==null?void 0:Y.assemblingMessageId]);const[rt,fe]=w.useState("desktop");w.useEffect(()=>{const N=()=>{const Z=window.innerWidth;fe(Z<640?"phone":Z<1024?"tablet":"desktop")};return N(),window.addEventListener("resize",N),()=>window.removeEventListener("resize",N)},[]),w.useEffect(()=>{Nt.current=!1},[B]),w.useEffect(()=>{on.current=At},[At]),w.useEffect(()=>{if(!nt){Tt.current=null;return}Tt.current===null&&(Tt.current=on.current),Ie(Ke??"")},[Ke,nt,Ie]),w.useEffect(()=>{if(T!==void 0){ft(T);return}(async()=>{if(!S){ft(null);return}try{const re=(await E.getAgent("default")).uiDefaultMessage||"";ft(re||null)}catch(Z){console.warn("Failed to fetch default message:",Z),ft(null)}})()},[E,S,T]),w.useEffect(()=>{I&&!at&&(b==null||b(I))},[I,at,b]);const ke=async(N,Z)=>{const re=N.trim();if(!(!re&&Z.length===0))try{const de=nt?(Te==null?void 0:Te.checkpointId)??R??void 0:R??void 0,Me=nt?(Te==null?void 0:Te.checkpointNs)??$??void 0:$??void 0;await X({text:re||"",attachments:Z,payload:p},{checkpointId:de,checkpointNs:Me,edit:!!nt,originalMessageId:nt??void 0}),x==null||x(re),Se(!0),Ie(""),Et(null),Le(null),$e(""),Ae(null)}catch(de){const Me=(de==null?void 0:de.message)||"Failed to send message";Et(Me),b==null||b(Me),Se(!1)}},Fe=w.useCallback(async N=>{await X({attachments:[N],payload:p},{checkpointId:R??void 0,checkpointNs:$??void 0}),y==null||y({file:N})},[R,$,p,y,X]),ht=w.useCallback((N,Z,re)=>{l&&(Tt.current=At,Le(N),$e(Z),Ie(Z),Et(null),Ae({checkpointId:(re==null?void 0:re.checkpointId)??null,checkpointNs:(re==null?void 0:re.checkpointNs)??null}))},[At,l,Ie]),pt=w.useCallback(()=>{Le(null),$e(""),Ae(null),Et(null),Ie(Tt.current??At),Tt.current=null},[At,Ie]),je=w.useCallback((N,Z,re)=>{ht(N,Z,re)},[ht]),Ye=w.useCallback(N=>{let Z=null;for(let Oe=N-1;Oe>=0;Oe--)if(A[Oe].role==="user"){Z=A[Oe];break}if(!Z)return;const re=Array.isArray(Z.content)?Z.content:[],Me=re.filter(Oe=>(Oe==null?void 0:Oe.type)==="text").map(Oe=>Oe.text).join("")||(()=>{try{return JSON.stringify(re,null,2)}catch{return String(re)}})();Me&&X({text:Me,payload:p},{checkpointId:R??void 0,checkpointNs:$??void 0,edit:!0,originalMessageId:Z.id})},[A,X,R,$,p]),we=w.useCallback(async N=>{if(C){jt(!0);try{if(!N){await F(),requestAnimationFrame(()=>{var de;(de=te.current)==null||de.scrollToLatest()});return}const Z=J.find(de=>de.checkpointId===N),re=(Z==null?void 0:Z.checkpointNs)??null;await L(N,re),requestAnimationFrame(()=>{var de;(de=te.current)==null||de.scrollToTop()})}finally{jt(!1)}}},[J,C,te,L,F]),Qe=w.useCallback(async(N,Z,re)=>{await we(re?null:N)},[we]),Xe=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${v.container||""}`,ct=`flex-1 min-h-0 min-w-0 max-h-full w-full overflow-hidden overscroll-contain break-words break-anywhere p-4 ${O?"pb-32":""} bg-transparent ${v.messagesArea||""}`,sn=`relative flex-shrink-0 w-full border-t p-4 bg-transparent ${v.inputArea||""}`;return u.jsxs("div",{className:Xe,children:[!!I&&!at&&u.jsxs("div",{className:"flex-shrink-0 bg-red-50 border border-red-200 text-red-800 px-4 py-2 text-sm flex items-center justify-between",children:[u.jsx("span",{children:I}),u.jsx(Je,{variant:"ghost",size:"sm",onClick:()=>It(!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 ${ct}`,style:r?{maxHeight:r}:void 0,children:[u.jsx(vl,{ref:te,className:"h-full",style:{height:"100%"},messages:A,isStreaming:D,streamingAssistantId:z,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:rt,enableMessageEditing:l,editingMessageId:nt,onEdit:je,onRegenerate:Ye,onCancelEdit:pt,emptyMessage:bt??void 0,isNavigatingCheckpoint:Ue,showToolMessages:d,toolRenderers:f,toolArtifactRenderers:m,checkpointIndex:q,activeCheckpointId:R,onSelectCheckpoint:Qe,createSyntheticThinkingMessage:!0,forceSyntheticThinking:ie,getMessageCustomStyles:g,getInterruptOptions:Ve}),(G==="reconnecting"||G==="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"}),G==="reconnecting"?"Reconnecting…":"Connecting…"]})}),G==="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"}),P&&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…"})]}),Ue&&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…"})]}),O&&U&&u.jsx("div",{className:"pointer-events-auto absolute inset-x-0 bottom-6 z-30 flex justify-center px-4",children:u.jsx("div",{className:"w-full max-w-3xl",children:u.jsx(ml,{interruptPart:U,onApprove:Ge,onReject:He,onSelectAlternative:ot,disabled:Q,isActive:!0,payload:O.value})})})]}),u.jsxs("div",{className:sn,children:[nt&&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(Je,{variant:"ghost",size:"sm",onClick:pt,className:"text-blue-600 hover:bg-blue-100",children:u.jsx(le.X,{size:16})})]})}),dt&&u.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:dt}),u.jsx(FS,{composerValue:At,onComposerChange:ge,onSend:ke,onCancelEdit:pt,onStop:M,editingMessageId:nt,editingInitialValue:Ke,placeholder:nt?"Edit your message...":t,isStreaming:D,disabled:ut,enableFileUpload:a,enableExcelUpload:c,onExcelUpload:Fe,onError:b,customStyles:v,textareaClassName:v.textarea||"",allowEmptySend:!1,inputError:dt})]})]})}var zh=1,nk=.9,rk=.8,ok=.17,wl=.1,bl=.999,sk=.9999,ik=.99,ak=/[\\\/_+.#"@\[\(\{&]/,lk=/[\\\/_+.#"@\[\(\{&]/g,ck=/[\s-]/,Hh=/[\s-]/g;function yl(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 c=r.charAt(s),l=n.indexOf(c,o),d=0,f,m,p,v;l>=0;)f=yl(e,t,n,r,l+1,s+1,i),f>d&&(l===o?f*=zh:ak.test(e.charAt(l-1))?(f*=rk,p=e.slice(o,l-1).match(lk),p&&o>0&&(f*=Math.pow(bl,p.length))):ck.test(e.charAt(l-1))?(f*=nk,v=e.slice(o,l-1).match(Hh),v&&o>0&&(f*=Math.pow(bl,v.length))):(f*=ok,o>0&&(f*=Math.pow(bl,l-o))),e.charAt(l)!==t.charAt(s)&&(f*=sk)),(f<wl&&n.charAt(l-1)===r.charAt(s+1)||r.charAt(s+1)===r.charAt(s)&&n.charAt(l-1)!==r.charAt(s))&&(m=yl(e,t,n,r,l+1,s+2,i),m*wl>f&&(f=m*wl)),f>d&&(d=f),l=n.indexOf(c,l+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,yl(e,t,Uh(e),Uh(t),0,0,{})}var _o='[cmdk-group=""]',Sl='[cmdk-group-items=""]',dk='[cmdk-group-heading=""]',Wh='[cmdk-item=""]',Vh=`${Wh}:not([aria-disabled="true"])`,Cl="cmdk-item-select",$r="data-value",fk=(e,t,n)=>uk(e,t,n),Kh=h.createContext(void 0),Ro=()=>h.useContext(Kh),qh=h.createContext(void 0),Tl=()=>h.useContext(qh),Gh=h.createContext(void 0),Yh=h.forwardRef((e,t)=>{let n=Fr(()=>{var M,B;return{search:"",value:(B=(M=e.value)!=null?M:e.defaultValue)!=null?B:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=Fr(()=>new Set),o=Fr(()=>new Map),s=Fr(()=>new Map),i=Fr(()=>new Set),a=Xh(e),{label:c,children:l,value:d,onValueChange:f,filter:m,shouldFilter:p,loop:v,disablePointerSelection:g=!1,vimBindings:x=!0,...y}=e,b=_t(),T=_t(),E=_t(),S=h.useRef(null),C=Ck();ur(()=>{if(d!==void 0){let M=d.trim();n.current.value=M,k.emit()}},[d]),ur(()=>{C(6,J)},[]);let k=h.useMemo(()=>({subscribe:M=>(i.current.add(M),()=>i.current.delete(M)),snapshot:()=>n.current,setState:(M,B,R)=>{var $,z,O,j;if(!Object.is(n.current[M],B)){if(n.current[M]=B,M==="search")K(),L(),C(1,F);else if(M==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let U=document.getElementById(E);U?U.focus():($=document.getElementById(b))==null||$.focus()}if(C(7,()=>{var U;n.current.selectedItemId=(U=_())==null?void 0:U.id,k.emit()}),R||C(5,J),((z=a.current)==null?void 0:z.value)!==void 0){let U=B??"";(j=(O=a.current).onValueChange)==null||j.call(O,U);return}}k.emit()}},emit:()=>{i.current.forEach(M=>M())}}),[]),A=h.useMemo(()=>({value:(M,B,R)=>{var $;B!==(($=s.current.get(M))==null?void 0:$.value)&&(s.current.set(M,{value:B,keywords:R}),n.current.filtered.items.set(M,P(B,R)),C(2,()=>{L(),k.emit()}))},item:(M,B)=>(r.current.add(M),B&&(o.current.has(B)?o.current.get(B).add(M):o.current.set(B,new Set([M]))),C(3,()=>{K(),L(),n.current.value||F(),k.emit()}),()=>{s.current.delete(M),r.current.delete(M),n.current.filtered.items.delete(M);let R=_();C(4,()=>{K(),(R==null?void 0:R.getAttribute("id"))===M&&F(),k.emit()})}),group:M=>(o.current.has(M)||o.current.set(M,new Set),()=>{s.current.delete(M),o.current.delete(M)}),filter:()=>a.current.shouldFilter,label:c||e["aria-label"],getDisablePointerSelection:()=>a.current.disablePointerSelection,listId:b,inputId:E,labelId:T,listInnerRef:S}),[]);function P(M,B){var R,$;let z=($=(R=a.current)==null?void 0:R.filter)!=null?$:fk;return M?z(M,n.current.search,B):0}function L(){if(!n.current.search||a.current.shouldFilter===!1)return;let M=n.current.filtered.items,B=[];n.current.filtered.groups.forEach($=>{let z=o.current.get($),O=0;z.forEach(j=>{let U=M.get(j);O=Math.max(U,O)}),B.push([$,O])});let R=S.current;Y().sort(($,z)=>{var O,j;let U=$.getAttribute("id"),Q=z.getAttribute("id");return((O=M.get(Q))!=null?O:0)-((j=M.get(U))!=null?j:0)}).forEach($=>{let z=$.closest(Sl);z?z.appendChild($.parentElement===z?$:$.closest(`${Sl} > *`)):R.appendChild($.parentElement===R?$:$.closest(`${Sl} > *`))}),B.sort(($,z)=>z[1]-$[1]).forEach($=>{var z;let O=(z=S.current)==null?void 0:z.querySelector(`${_o}[${$r}="${encodeURIComponent($[0])}"]`);O==null||O.parentElement.appendChild(O)})}function F(){let M=Y().find(R=>R.getAttribute("aria-disabled")!=="true"),B=M==null?void 0:M.getAttribute($r);k.setState("value",B||void 0)}function K(){var M,B,R,$;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 O of r.current){let j=(B=(M=s.current.get(O))==null?void 0:M.value)!=null?B:"",U=($=(R=s.current.get(O))==null?void 0:R.keywords)!=null?$:[],Q=P(j,U);n.current.filtered.items.set(O,Q),Q>0&&z++}for(let[O,j]of o.current)for(let U of j)if(n.current.filtered.items.get(U)>0){n.current.filtered.groups.add(O);break}n.current.filtered.count=z}function J(){var M,B,R;let $=_();$&&(((M=$.parentElement)==null?void 0:M.firstChild)===$&&((R=(B=$.closest(_o))==null?void 0:B.querySelector(dk))==null||R.scrollIntoView({block:"nearest"})),$.scrollIntoView({block:"nearest"}))}function _(){var M;return(M=S.current)==null?void 0:M.querySelector(`${Wh}[aria-selected="true"]`)}function Y(){var M;return Array.from(((M=S.current)==null?void 0:M.querySelectorAll(Vh))||[])}function q(M){let B=Y()[M];B&&k.setState("value",B.getAttribute($r))}function W(M){var B;let R=_(),$=Y(),z=$.findIndex(j=>j===R),O=$[z+M];(B=a.current)!=null&&B.loop&&(O=z+M<0?$[$.length-1]:z+M===$.length?$[0]:$[z+M]),O&&k.setState("value",O.getAttribute($r))}function D(M){let B=_(),R=B==null?void 0:B.closest(_o),$;for(;R&&!$;)R=M>0?yk(R,_o):Sk(R,_o),$=R==null?void 0:R.querySelector(Vh);$?k.setState("value",$.getAttribute($r)):W(M)}let I=()=>q(Y().length-1),G=M=>{M.preventDefault(),M.metaKey?I():M.altKey?D(1):W(1)},X=M=>{M.preventDefault(),M.metaKey?q(0):M.altKey?D(-1):W(-1)};return h.createElement(pe.div,{ref:t,tabIndex:-1,...y,"cmdk-root":"",onKeyDown:M=>{var B;(B=y.onKeyDown)==null||B.call(y,M);let R=M.nativeEvent.isComposing||M.keyCode===229;if(!(M.defaultPrevented||R))switch(M.key){case"n":case"j":{x&&M.ctrlKey&&G(M);break}case"ArrowDown":{G(M);break}case"p":case"k":{x&&M.ctrlKey&&X(M);break}case"ArrowUp":{X(M);break}case"Home":{M.preventDefault(),q(0);break}case"End":{M.preventDefault(),I();break}case"Enter":{M.preventDefault();let $=_();if($){let z=new Event(Cl);$.dispatchEvent(z)}}}}},h.createElement("label",{"cmdk-label":"",htmlFor:A.inputId,id:A.labelId,style:kk},c),ni(e,M=>h.createElement(qh.Provider,{value:k},h.createElement(Kh.Provider,{value:A},M))))}),pk=h.forwardRef((e,t)=>{var n,r;let o=_t(),s=h.useRef(null),i=h.useContext(Gh),a=Ro(),c=Xh(e),l=(r=(n=c.current)==null?void 0:n.forceMount)!=null?r:i==null?void 0:i.forceMount;ur(()=>{if(!l)return a.item(o,i==null?void 0:i.id)},[l]);let d=Jh(o,s,[e.value,e.children,s],e.keywords),f=Tl(),m=Kn(C=>C.value&&C.value===d.current),p=Kn(C=>l||a.filter()===!1?!0:C.search?C.filtered.items.get(o)>0:!0);h.useEffect(()=>{let C=s.current;if(!(!C||e.disabled))return C.addEventListener(Cl,v),()=>C.removeEventListener(Cl,v)},[p,e.onSelect,e.disabled]);function v(){var C,k;g(),(k=(C=c.current).onSelect)==null||k.call(C,d.current)}function g(){f.setState("value",d.current,!0)}if(!p)return null;let{disabled:x,value:y,onSelect:b,forceMount:T,keywords:E,...S}=e;return h.createElement(pe.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)}),hk=h.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:o,...s}=e,i=_t(),a=h.useRef(null),c=h.useRef(null),l=_t(),d=Ro(),f=Kn(p=>o||d.filter()===!1?!0:p.search?p.filtered.groups.has(i):!0);ur(()=>d.group(i),[]),Jh(i,a,[e.value,e.heading,c]);let m=h.useMemo(()=>({id:i,forceMount:o}),[o]);return h.createElement(pe.div,{ref:Mn(a,t),...s,"cmdk-group":"",role:"presentation",hidden:f?void 0:!0},n&&h.createElement("div",{ref:c,"cmdk-group-heading":"","aria-hidden":!0,id:l},n),ni(e,p=>h.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?l:void 0},h.createElement(Gh.Provider,{value:m},p))))}),mk=h.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,o=h.useRef(null),s=Kn(i=>!i.search);return!n&&!s?null:h.createElement(pe.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=Tl(),i=Kn(l=>l.search),a=Kn(l=>l.selectedItemId),c=Ro();return h.useEffect(()=>{e.value!=null&&s.setState("search",e.value)},[e.value]),h.createElement(pe.input,{ref:t,...r,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":c.listId,"aria-labelledby":c.labelId,"aria-activedescendant":a,id:c.inputId,type:"text",value:o?e.value:i,onChange:l=>{o||s.setState("search",l.target.value),n==null||n(l.target.value)}})}),xk=h.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...o}=e,s=h.useRef(null),i=h.useRef(null),a=Kn(l=>l.selectedItemId),c=Ro();return h.useEffect(()=>{if(i.current&&s.current){let l=i.current,d=s.current,f,m=new ResizeObserver(()=>{f=requestAnimationFrame(()=>{let p=l.offsetHeight;d.style.setProperty("--cmdk-list-height",p.toFixed(1)+"px")})});return m.observe(l),()=>{cancelAnimationFrame(f),m.unobserve(l)}}},[]),h.createElement(pe.div,{ref:Mn(s,t),...o,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":a,"aria-label":r,id:c.listId},ni(e,l=>h.createElement("div",{ref:Mn(i,c.listInnerRef),"cmdk-list-sizer":""},l)))}),vk=h.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:o,contentClassName:s,container:i,...a}=e;return h.createElement(rl,{open:n,onOpenChange:r},h.createElement(ol,{container:i},h.createElement(No,{"cmdk-overlay":"",className:o}),h.createElement(Ao,{"aria-label":e.label,"cmdk-dialog":"",className:s},h.createElement(Yh,{ref:t,...a}))))}),wk=h.forwardRef((e,t)=>Kn(n=>n.filtered.count===0)?h.createElement(pe.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),bk=h.forwardRef((e,t)=>{let{progress:n,children:r,label:o="Loading...",...s}=e;return h.createElement(pe.div,{ref:t,...s,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":o},ni(e,i=>h.createElement("div",{"aria-hidden":!0},i)))}),Wt=Object.assign(Yh,{List:xk,Item:pk,Input:gk,Group:hk,Separator:mk,Dialog:vk,Empty:wk,Loading:bk});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 Fr(e){let t=h.useRef();return t.current===void 0&&(t.current=e()),t}function Kn(e){let t=Tl(),n=()=>e(t.snapshot());return h.useSyncExternalStore(t.subscribe,n,n)}function Jh(e,t,n,r=[]){let o=h.useRef(),s=Ro();return ur(()=>{var i;let a=(()=>{var l;for(let d of n){if(typeof d=="string")return d.trim();if(typeof d=="object"&&"current"in d)return d.current?(l=d.current.textContent)==null?void 0:l.trim():o.current}})(),c=r.map(l=>l.trim());s.value(e,a,c),(i=t.current)==null||i.setAttribute($r,a),o.current=a}),o}var Ck=()=>{let[e,t]=h.useState(),n=Fr(()=>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 ni({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 kl=h.forwardRef(({className:e,...t},n)=>u.jsx(Wt,{ref:n,className:ne("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));kl.displayName=Wt.displayName;const El=h.forwardRef(({className:e,...t},n)=>u.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[u.jsx(le.Search,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),u.jsx(Wt.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})]}));El.displayName=Wt.Input.displayName;const Il=h.forwardRef(({className:e,...t},n)=>u.jsx(Wt.List,{ref:n,className:ne("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));Il.displayName=Wt.List.displayName;const Nl=h.forwardRef((e,t)=>u.jsx(Wt.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));Nl.displayName=Wt.Empty.displayName;const Al=h.forwardRef(({className:e,...t},n)=>u.jsx(Wt.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}));Al.displayName=Wt.Group.displayName;const Ek=h.forwardRef(({className:e,...t},n)=>u.jsx(Wt.Separator,{ref:n,className:ne("-mx-1 h-px bg-border",e),...t}));Ek.displayName=Wt.Separator.displayName;const jl=h.forwardRef(({className:e,...t},n)=>u.jsx(Wt.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}));jl.displayName=Wt.Item.displayName;function Pl(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 _l="ScrollArea",[Zh,WN]=cn(_l),[Nk,rn]=Zh(_l),Qh=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,c]=h.useState(null),[l,d]=h.useState(null),[f,m]=h.useState(null),[p,v]=h.useState(null),[g,x]=h.useState(null),[y,b]=h.useState(0),[T,E]=h.useState(0),[S,C]=h.useState(!1),[k,A]=h.useState(!1),P=Pe(t,F=>c(F)),L=es(o);return u.jsx(Nk,{scope:n,type:r,dir:L,scrollHideDelay:s,scrollArea:a,viewport:l,onViewportChange:d,content:f,onContentChange:m,scrollbarX:p,onScrollbarXChange:v,scrollbarXEnabled:S,onScrollbarXEnabledChange:C,scrollbarY:g,onScrollbarYChange:x,scrollbarYEnabled:k,onScrollbarYEnabledChange:A,onCornerWidthChange:b,onCornerHeightChange:E,children:u.jsx(pe.div,{dir:L,...i,ref:P,style:{position:"relative","--radix-scroll-area-corner-width":y+"px","--radix-scroll-area-corner-height":T+"px",...e.style}})})});Qh.displayName=_l;var em="ScrollAreaViewport",tm=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=rn(em,n),a=h.useRef(null),c=Pe(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(pe.div,{"data-radix-scroll-area-viewport":"",...s,ref:c,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 In="ScrollAreaScrollbar",Rl=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=rn(In,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(Ml,{...r,ref:t}):null});Rl.displayName=In;var Ak=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=rn(In,e.__scopeScrollArea),[s,i]=h.useState(!1);return h.useEffect(()=>{const a=o.scrollArea;let c=0;if(a){const l=()=>{window.clearTimeout(c),i(!0)},d=()=>{c=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",l),a.addEventListener("pointerleave",d),()=>{window.clearTimeout(c),a.removeEventListener("pointerenter",l),a.removeEventListener("pointerleave",d)}}},[o.scrollArea,o.scrollHideDelay]),u.jsx(Ht,{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=rn(In,e.__scopeScrollArea),s=e.orientation==="horizontal",i=ii(()=>c("SCROLL_END"),100),[a,c]=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 l=window.setTimeout(()=>c("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(l)}},[a,o.scrollHideDelay,c]),h.useEffect(()=>{const l=o.viewport,d=s?"scrollLeft":"scrollTop";if(l){let f=l[d];const m=()=>{const p=l[d];f!==p&&(c("SCROLL"),i()),f=p};return l.addEventListener("scroll",m),()=>l.removeEventListener("scroll",m)}},[o.viewport,s,c,i]),u.jsx(Ht,{present:n||a!=="hidden",children:u.jsx(Ml,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:ae(e.onPointerEnter,()=>c("POINTER_ENTER")),onPointerLeave:ae(e.onPointerLeave,()=>c("POINTER_LEAVE"))})})}),nm=h.forwardRef((e,t)=>{const n=rn(In,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=h.useState(!1),a=e.orientation==="horizontal",c=ii(()=>{if(n.viewport){const l=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?l:d)}},10);return Br(n.viewport,c),Br(n.content,c),u.jsx(Ht,{present:r||s,children:u.jsx(Ml,{"data-state":s?"visible":"hidden",...o,ref:t})})}),Ml=h.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=rn(In,e.__scopeScrollArea),s=h.useRef(null),i=h.useRef(0),[a,c]=h.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),l=am(a.viewport,a.content),d={...r,sizes:a,onSizesChange:c,hasThumb:l>0&&l<1,onThumbChange:m=>s.current=m,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:m=>i.current=m};function f(m,p){return Dk(m,i.current,a,p)}return n==="horizontal"?u.jsx(Pk,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollLeft,p=lm(m,a,o.dir);s.current.style.transform=`translate3d(${p}px, 0, 0)`}},onWheelScroll:m=>{o.viewport&&(o.viewport.scrollLeft=m)},onDragScroll:m=>{o.viewport&&(o.viewport.scrollLeft=f(m,o.dir))}}):n==="vertical"?u.jsx(_k,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollTop,p=lm(m,a);s.current.style.transform=`translate3d(0, ${p}px, 0)`}},onWheelScroll:m=>{o.viewport&&(o.viewport.scrollTop=m)},onDragScroll:m=>{o.viewport&&(o.viewport.scrollTop=f(m))}}):null}),Pk=h.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=rn(In,e.__scopeScrollArea),[i,a]=h.useState(),c=h.useRef(null),l=Pe(t,c,s.onScrollbarXChange);return h.useEffect(()=>{c.current&&a(getComputedStyle(c.current))},[c]),u.jsx(om,{"data-orientation":"horizontal",...o,ref:l,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":si(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.x),onDragScroll:d=>e.onDragScroll(d.x),onWheelScroll:(d,f)=>{if(s.viewport){const m=s.viewport.scrollLeft+d.deltaX;e.onWheelScroll(m),um(m,f)&&d.preventDefault()}},onResize:()=>{c.current&&s.viewport&&i&&r({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:oi(i.paddingLeft),paddingEnd:oi(i.paddingRight)}})}})}),_k=h.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=rn(In,e.__scopeScrollArea),[i,a]=h.useState(),c=h.useRef(null),l=Pe(t,c,s.onScrollbarYChange);return h.useEffect(()=>{c.current&&a(getComputedStyle(c.current))},[c]),u.jsx(om,{"data-orientation":"vertical",...o,ref:l,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":si(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.y),onDragScroll:d=>e.onDragScroll(d.y),onWheelScroll:(d,f)=>{if(s.viewport){const m=s.viewport.scrollTop+d.deltaY;e.onWheelScroll(m),um(m,f)&&d.preventDefault()}},onResize:()=>{c.current&&s.viewport&&i&&r({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:oi(i.paddingTop),paddingEnd:oi(i.paddingBottom)}})}})}),[Rk,rm]=Zh(In),om=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:c,onDragScroll:l,onWheelScroll:d,onResize:f,...m}=e,p=rn(In,n),[v,g]=h.useState(null),x=Pe(t,P=>g(P)),y=h.useRef(null),b=h.useRef(""),T=p.viewport,E=r.content-r.viewport,S=gt(d),C=gt(c),k=ii(f,10);function A(P){if(y.current){const L=P.clientX-y.current.left,F=P.clientY-y.current.top;l({x:L,y:F})}}return h.useEffect(()=>{const P=L=>{const F=L.target;(v==null?void 0:v.contains(F))&&S(L,E)};return document.addEventListener("wheel",P,{passive:!1}),()=>document.removeEventListener("wheel",P,{passive:!1})},[T,v,E,S]),h.useEffect(C,[r,C]),Br(v,k),Br(p.content,k),u.jsx(Rk,{scope:n,scrollbar:v,hasThumb:o,onThumbChange:gt(s),onThumbPointerUp:gt(i),onThumbPositionChange:C,onThumbPointerDown:gt(a),children:u.jsx(pe.div,{...m,ref:x,style:{position:"absolute",...m.style},onPointerDown:ae(e.onPointerDown,P=>{P.button===0&&(P.target.setPointerCapture(P.pointerId),y.current=v.getBoundingClientRect(),b.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",p.viewport&&(p.viewport.style.scrollBehavior="auto"),A(P))}),onPointerMove:ae(e.onPointerMove,A),onPointerUp:ae(e.onPointerUp,P=>{const L=P.target;L.hasPointerCapture(P.pointerId)&&L.releasePointerCapture(P.pointerId),document.body.style.webkitUserSelect=b.current,p.viewport&&(p.viewport.style.scrollBehavior=""),y.current=null})})})}),ri="ScrollAreaThumb",sm=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=rm(ri,e.__scopeScrollArea);return u.jsx(Ht,{present:n||o.hasThumb,children:u.jsx(Mk,{ref:t,...r})})}),Mk=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=rn(ri,n),i=rm(ri,n),{onThumbPositionChange:a}=i,c=Pe(t,f=>i.onThumbChange(f)),l=h.useRef(void 0),d=ii(()=>{l.current&&(l.current(),l.current=void 0)},100);return h.useEffect(()=>{const f=s.viewport;if(f){const m=()=>{if(d(),!l.current){const p=Lk(f,a);l.current=p,a()}};return a(),f.addEventListener("scroll",m),()=>f.removeEventListener("scroll",m)}},[s.viewport,d,a]),u.jsx(pe.div,{"data-state":i.hasThumb?"visible":"hidden",...o,ref:c,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:ae(e.onPointerDownCapture,f=>{const p=f.target.getBoundingClientRect(),v=f.clientX-p.left,g=f.clientY-p.top;i.onThumbPointerDown({x:v,y:g})}),onPointerUp:ae(e.onPointerUp,i.onThumbPointerUp)})});sm.displayName=ri;var Ol="ScrollAreaCorner",im=h.forwardRef((e,t)=>{const n=rn(Ol,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?u.jsx(Ok,{...e,ref:t}):null});im.displayName=Ol;var Ok=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=rn(Ol,n),[s,i]=h.useState(0),[a,c]=h.useState(0),l=!!(s&&a);return Br(o.scrollbarX,()=>{var f;const d=((f=o.scrollbarX)==null?void 0:f.offsetHeight)||0;o.onCornerHeightChange(d),c(d)}),Br(o.scrollbarY,()=>{var f;const d=((f=o.scrollbarY)==null?void 0:f.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),l?u.jsx(pe.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 oi(e){return e?parseInt(e,10):0}function am(e,t){const n=e/t;return isNaN(n)?0:n}function si(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=si(n),s=o/2,i=t||s,a=o-i,c=n.scrollbar.paddingStart+i,l=n.scrollbar.size-n.scrollbar.paddingEnd-a,d=n.content-n.viewport,f=r==="ltr"?[0,d]:[d*-1,0];return cm([c,l],f)(e)}function lm(e,t,n="ltr"){const r=si(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,s=t.scrollbar.size-o,i=t.content-t.viewport,a=s-r,c=n==="ltr"?[0,i]:[i*-1,0],l=Pl(e,c);return cm([0,i],[0,a])(l)}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 ii(e,t){const n=gt(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 Br(e,t){const n=gt(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 dm=Qh,$k=tm,Fk=im;const Dl=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,{})]}));Dl.displayName=dm.displayName;const fm=h.forwardRef(({className:e,orientation:t="vertical",...n},r)=>u.jsx(Rl,{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=Rl.displayName;const Ll=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}));Ll.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:c,onShare:l,onDelete:d,showEditTitle:f,showDeleteButton:m,formatDate:p,getDisplayThreadTitle:v,secondaryLine:g,itemClassName:x,activeItemClassName:y}){const b=n===e.threadId,T=t?`${y??Hk}`:`${x??zk}`,E=S=>{S.stopPropagation(),o(e.threadId)};return u.jsxs("div",{onClick:E,className:`${Bk} ${T}`,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(Ll,{value:r,onChange:S=>i(S.target.value),onKeyDown:S=>{S.key==="Enter"?a(e.threadId):S.key==="Escape"&&c()},className:"h-6 text-sm",autoFocus:!0}),u.jsx(Je,{variant:"ghost",size:"sm",onClick:()=>a(e.threadId),className:"h-6 w-6 p-0",children:u.jsx(le.Check,{size:12})}),u.jsx(Je,{variant:"ghost",size:"sm",onClick:c,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:p(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(Es,{children:[u.jsx(Is,{asChild:!0,children:u.jsx(Je,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",children:u.jsx(le.MoreHorizontal,{size:12})})}),u.jsxs(xo,{align:"end",sideOffset:6,className:"w-44",children:[u.jsxs(Fn,{onClick:S=>{S.preventDefault(),l(e.threadId)},children:[u.jsx(le.Share2,{className:"mr-2 h-4 w-4"}),"Share thread"]}),f&&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 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 ai({className:e="",showCreateButton:t=!0,showDeleteButton:n=!0,showEditTitle:r=!0,maxHeight:o="400px",customStyles:s={},currentThreadId:i=null,navigateToThread:a,onThreadSelect:c,onThreadCreate:l,onThreadDelete:d,view:f,defaultView:m,onViewChange:p,viewOptions:v,viewState:g,showHeader:x=!0,shareTargets:y,isLoadingShareTargets:b,shareTargetFilter:T}){const{threads:E,sharedThreads:S,currentThreadId:C,setCurrentThreadId:k,isLoading:A,isLoadingSharedThreads:P,actions:L,shareInFlight:F,shareStatus:K,clearShareStatus:J}=vr(),{createThread:_,deleteThread:Y,renameThread:q,shareThread:W}=L,{loadThread:D}=oo(),I=i??C,[G,X]=w.useState(Array.isArray(E)?E:[]),M=w.useRef(G.length>0),B=w.useRef(null),R=w.useRef(0),[$,z]=w.useState(null),[O,j]=w.useState(""),[U,Q]=w.useState(!1),[se,ie]=w.useState(!1),[Se,xe]=w.useState(null),[Re,Ve]=w.useState(""),De=v&&v.length>0?v:Vk,Ge=gm({defaultView:m}),He=g??Ge,ot=f??He.view,ut=w.useCallback(te=>{f||He.setView(te),p==null||p(te)},[f,p,He]),nt=De.find(te=>te.key===ot)??De[0],Le=te=>{xe(te),Ve(""),ie(!0)},Ke=()=>{ie(!1),xe(null),Ve(""),J()},$e=w.useCallback(async te=>{if(!(!Se||F)&&te.id)try{await W(Se,te.id),setTimeout(()=>Ke(),600)}catch(ge){console.error("Failed to share thread:",ge)}},[Ke,F,Se,W]),Te=w.useMemo(()=>{const te=y??[],ge=Re.trim().toLowerCase();return ge?T?te.filter(rt=>T(rt,ge)):te.filter(rt=>`${rt.label} ${rt.secondaryLabel??""}`.toLowerCase().includes(ge)):te},[y,Re,T]),Ae=ot==="shared",dt=Ae?S:G,Et=Ae?P:A,at=Ae?"No shared conversations yet":"No conversations yet",It=te=>{const ge=te.sharedAt?` • ${Ie(te.sharedAt)}`:"";return`Shared by ${te.sharedByUserId}${ge}`},bt=te=>"sharedByUserId"in te;w.useEffect(()=>{const te=Array.isArray(E)?E:[];if(te.length>0){M.current=!0,X(te);return}A||(M.current=!1,X(te))},[E,A]),w.useEffect(()=>{if(!B.current)return;const te=B.current.querySelector("[data-radix-scroll-area-viewport]");if(!te)return;let ge=null,rt=null;return ge=requestAnimationFrame(()=>{rt=requestAnimationFrame(()=>{te.scrollTop=R.current})}),()=>{ge!==null&&cancelAnimationFrame(ge),rt!==null&&cancelAnimationFrame(rt)}},[G]);const ft=async te=>{try{k(te),await D(te),a==null||a(te),c==null||c(te)}catch(ge){console.error("Failed to select thread:",ge)}},Nt=async()=>{try{Q(!0);const te=await _();te&&(l==null||l(te),a==null||a(te))}catch(te){console.error("Failed to create thread:",te)}finally{Q(!1)}},At=async(te,ge)=>{if(ge.stopPropagation(),!!confirm("Delete this thread?")){if(B.current){const rt=B.current.querySelector("[data-radix-scroll-area-viewport]");rt&&(R.current=rt.scrollTop)}try{await Y(te),d==null||d(te)}catch(rt){console.error("Failed to delete thread:",rt)}}},Ct=(te,ge)=>{ge.stopPropagation(),z(te.threadId),j(te.title||`Thread ${te.threadId.slice(0,8)}`)},on=async te=>{if(O.trim())try{await q(te,O.trim()),z(null),j("")}catch(ge){console.error("Failed to update title:",ge)}},Tt=()=>{z(null),j("")},Ie=te=>{if(!te)return"";try{const ge=new Date(te),fe=new Date().getTime()-ge.getTime(),ke=Math.floor(fe/(1e3*60*60*24));return ke===0?ge.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):ke===1?"Yesterday":ke<7?`${ke} days ago`:ge.toLocaleDateString()}catch{return""}},Ue=te=>te.title||`Thread ${te.threadId.slice(0,8)}`,jt=te=>{const ge=Ue(te);return ge.length<=hm?ge:`${ge.slice(0,hm)}...`};return u.jsxs("div",{className:`flex flex-col h-full ${e} ${s.container||""}`,children:[x&&u.jsxs("div",{className:s.header||"flex flex-col gap-2 px-1 py-0 border border-slate-200 bg-white dark:border-slate-700 dark:bg-slate-900 shadow-sm",children:[t&&u.jsx("div",{className:"flex justify-end",children:u.jsxs(Je,{onClick:Nt,disabled:U||A,className:s.createButton||"px-3 py-2 gap-1",size:"sm",variant:"ghost",title:U?"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(Es,{children:[u.jsx(Is,{asChild:!0,children:u.jsx(Je,{variant:"outline",size:"sm",className:"text-[11px] text-slate-700 dark:text-slate-200 border border-slate-300 dark:border-slate-600 bg-white dark:bg-slate-900 hover:bg-slate-50 dark:hover:bg-slate-800 px-2 py-0",children:nt.label})}),u.jsx(xo,{align:"start",sideOffset:6,className:"w-40",children:De.map(te=>u.jsxs(Fn,{className:"justify-between text-[12px]",onClick:ge=>{ge.preventDefault(),ut(te.key)},children:[u.jsx("span",{children:te.label}),ot===te.key&&u.jsx(le.Check,{className:"h-3 w-3"})]},te.key))})]})]})]}),u.jsx(Dl,{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:Et?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…"})]}):dt.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:at})]}):dt.slice().sort((te,ge)=>new Date(ge.updatedAt||ge.createdAt||"").getTime()-new Date(te.updatedAt||te.createdAt||"").getTime()).map(te=>u.jsx(pm,{thread:te,isActive:I===te.threadId,editingThreadId:$,editingTitle:O,onSelect:ft,onStartEditing:Ct,onEditingTitleChange:ge=>j(ge),onSaveEditing:on,onCancelEditing:Tt,onShare:()=>Le(te.threadId),onDelete:At,showEditTitle:r,showDeleteButton:n,formatDate:Ie,getDisplayThreadTitle:jt,secondaryLine:Ae&&bt(te)?It(te):void 0,itemClassName:s.threadItem,activeItemClassName:s.activeThread},te.threadId))})}),u.jsx(sl,{open:se,onOpenChange:te=>!te&&Ke(),children:u.jsxs(Ws,{className:"max-w-md p-0",children:[u.jsx(Vs,{children:u.jsx(Ks,{children:"Share thread"})}),u.jsxs(kl,{children:[u.jsx(El,{autoFocus:!0,value:Re,onValueChange:te=>Ve(te),placeholder:"Search for recipients..."}),u.jsxs(Il,{children:[K&&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:K.startsWith("Failed")?"text-red-500":K.startsWith("Shared")?"text-emerald-500":"text-slate-600 dark:text-slate-400",children:K})]}),u.jsx(Nl,{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"}),Te.length>0&&u.jsx(Al,{heading:"Recipients",children:Te.map(te=>u.jsx(jl,{onSelect:()=>$e(te),children:u.jsxs("div",{className:"flex flex-col items-start text-sm",children:[u.jsx("span",{className:"font-medium",children:te.label}),te.secondaryLabel&&u.jsx("span",{className:"text-xs text-muted-foreground",children:te.secondaryLabel})]})},te.id))})]})]})]})})]})}function Kk({layout:e="sidebar",layoutSize:t="desktop",showThreads:n=!0,className:r="",customStyles:o={},...s}){const i=l=>{const d="h-full";switch(l){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=l=>({"--chat-sidebar-width":l==="phone"?"100%":l==="tablet"?"280px":l==="half-screen"?"240px":"320px","--chat-message-max-width":l==="phone"?"95%":l==="tablet"?"90%":l==="half-screen"?"85%":"80%","--chat-input-height":l==="phone"?"120px":"100px"}),c=w.useCallback(l=>{var d;(d=s.onThreadChange)==null||d.call(s,l)},[s]);return e==="fullscreen"?u.jsx(Sr,{...s,onThreadChange:c,children:u.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:u.jsx(Lr,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?u.jsx(Sr,{...s,onThreadChange:c,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(ai,{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(Lr,{onError:s.onError,enableFileUpload:!0})})]})})}):u.jsx(Sr,{...s,onThreadChange:c,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(ai,{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(Lr,{onError:s.onError,enableFileUpload:!0})})]})})}function qk({apiConfig:e,className:t="",onError:n}){return u.jsx(Sr,{apiConfig:e,onError:n,children:u.jsx("div",{className:`h-full ${t}`,children:u.jsx(Lr,{})})})}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(Lr,{placeholder:e??"Ask Serti AI anything...",autoFocus:!0,className:"h-full",onMessageSent:t}):u.jsx(ai,{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,c]=w.useState(!1);return n?u.jsx(Sr,{...i,children:u.jsx("div",{className:`fixed bottom-6 right-6 z-[9999] transition-all duration-300 ${e}`,children:u.jsxs("div",{className:`w-96 bg-white rounded-xl shadow-2xl border border-gray-200 overflow-hidden relative ${a?"scale-75":"scale-100"}`,children:[u.jsx("div",{className:"bg-slate-800 text-white p-4 flex-shrink-0",children:u.jsxs("div",{className:"flex items-center justify-between gap-3",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsxs("div",{className:"relative h-10 w-10 rounded-full bg-gradient-to-br from-slate-500 to-slate-700 border border-white/30 flex items-center justify-center text-white text-sm font-bold",children:["S",u.jsx("span",{className:"absolute -bottom-0.5 -right-0.5 h-3 w-3 rounded-full border-2 border-slate-800 bg-emerald-400"})]}),u.jsxs("div",{className:"flex flex-col",children:[u.jsx("h3",{className:"text-lg font-semibold leading-tight",children:o}),u.jsx("p",{className:"text-xs text-white/70",children:s})]}),u.jsx("span",{className:"ml-2 inline-flex items-center justify-center rounded-full bg-red-500 px-2 py-0.5 text-[11px] font-semibold leading-none text-white",children:"1"})]}),u.jsxs("div",{className:"flex items-center gap-1",children:[u.jsx(Je,{variant:"ghost",size:"sm",className:"text-white hover:bg-white/10 h-8 w-8 p-0",title:"Options",children:u.jsx(le.MoreHorizontal,{size:16})}),u.jsx(Je,{variant:"ghost",size:"sm",className:"text-white hover:bg-white/10 h-8 w-8 p-0",title:"Compose",children:u.jsx(le.Edit3,{size:16})}),u.jsx(Je,{variant:"ghost",size:"sm",onClick:l=>{l.stopPropagation(),c(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(Je,{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(pe.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=Wr.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),wm=h.forwardRef(({className:e,...t},n)=>u.jsx(vm,{ref:n,className:ne(Zk(),e),...t}));wm.displayName=vm.displayName;function bm(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",li=h.forwardRef((e,t)=>u.jsx(pe.span,{...e,ref:t,style:{...ym,...e.style}}));li.displayName=Qk;var eE=li,tE=[" ","Enter","ArrowUp","ArrowDown"],nE=[" ","Enter"],dr="Select",[ci,ui,rE]=Qo(dr),[zr,VN]=cn(dr,[rE,Ar]),di=Ar(),[oE,qn]=zr(dr),[sE,iE]=zr(dr),Sm=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:c,dir:l,name:d,autoComplete:f,disabled:m,required:p,form:v}=e,g=di(t),[x,y]=h.useState(null),[b,T]=h.useState(null),[E,S]=h.useState(!1),C=es(l),[k,A]=On({prop:r,defaultProp:o??!1,onChange:s,caller:dr}),[P,L]=On({prop:i,defaultProp:a,onChange:c,caller:dr}),F=h.useRef(null),K=x?v||!!x.closest("form"):!0,[J,_]=h.useState(new Set),Y=Array.from(J).map(q=>q.props.value).join(";");return u.jsx(ua,{...g,children:u.jsxs(oE,{required:p,scope:t,trigger:x,onTriggerChange:y,valueNode:b,onValueNodeChange:T,valueNodeHasChildren:E,onValueNodeHasChildrenChange:S,contentId:_t(),value:P,onValueChange:L,open:k,onOpenChange:A,dir:C,triggerPointerDownPosRef:F,disabled:m,children:[u.jsx(ci.Provider,{scope:t,children:u.jsx(sE,{scope:e.__scopeSelect,onNativeOptionAdd:h.useCallback(q=>{_(W=>new Set(W).add(q))},[]),onNativeOptionRemove:h.useCallback(q=>{_(W=>{const D=new Set(W);return D.delete(q),D})},[]),children:n})}),K?u.jsxs(Km,{"aria-hidden":!0,required:p,tabIndex:-1,name:d,autoComplete:f,value:P,onChange:q=>L(q.target.value),disabled:m,form:v,children:[P===void 0?u.jsx("option",{value:""}):null,Array.from(J)]},Y):null]})})};Sm.displayName=dr;var Cm="SelectTrigger",Tm=h.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=di(n),i=qn(Cm,n),a=i.disabled||r,c=Pe(t,i.onTriggerChange),l=ui(n),d=h.useRef("touch"),[f,m,p]=Gm(g=>{const x=l().filter(T=>!T.disabled),y=x.find(T=>T.value===i.value),b=Ym(x,g,y);b!==void 0&&i.onValueChange(b.value)}),v=g=>{a||(i.onOpenChange(!0),p()),g&&(i.triggerPointerDownPosRef.current={x:Math.round(g.pageX),y:Math.round(g.pageY)})};return u.jsx(da,{asChild:!0,...s,children:u.jsx(pe.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:c,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=f.current!=="";!(g.ctrlKey||g.altKey||g.metaKey)&&g.key.length===1&&m(g.key),!(x&&g.key===" ")&&tE.includes(g.key)&&(v(),g.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,c=qn(km,n),{onValueNodeHasChildrenChange:l}=c,d=s!==void 0,f=Pe(t,c.onValueNodeChange);return kt(()=>{l(d)},[l,d]),u.jsx(pe.span,{...a,ref:f,style:{pointerEvents:"none"},children:qm(c.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(pe.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});Im.displayName=aE;var lE="SelectPortal",Nm=e=>u.jsx(co,{asChild:!0,...e});Nm.displayName=lE;var fr="SelectContent",Am=h.forwardRef((e,t)=>{const n=qn(fr,e.__scopeSelect),[r,o]=h.useState();if(kt(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?Vr.createPortal(u.jsx(jm,{scope:e.__scopeSelect,children:u.jsx(ci.Slot,{scope:e.__scopeSelect,children:u.jsx("div",{children:e.children})})}),s):null}return u.jsx(Pm,{...e,ref:t})});Am.displayName=fr;var mn=10,[jm,Gn]=zr(fr),cE="SelectContentImpl",uE=qt.createSlot("SelectContent.RemoveScroll"),Pm=h.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:a,sideOffset:c,align:l,alignOffset:d,arrowPadding:f,collisionBoundary:m,collisionPadding:p,sticky:v,hideWhenDetached:g,avoidCollisions:x,...y}=e,b=qn(fr,n),[T,E]=h.useState(null),[S,C]=h.useState(null),k=Pe(t,O=>E(O)),[A,P]=h.useState(null),[L,F]=h.useState(null),K=ui(n),[J,_]=h.useState(!1),Y=h.useRef(!1);h.useEffect(()=>{if(T)return xa(T)},[T]),Gi();const q=h.useCallback(O=>{const[j,...U]=K().map(ie=>ie.ref.current),[Q]=U.slice(-1),se=document.activeElement;for(const ie of O)if(ie===se||(ie==null||ie.scrollIntoView({block:"nearest"}),ie===j&&S&&(S.scrollTop=0),ie===Q&&S&&(S.scrollTop=S.scrollHeight),ie==null||ie.focus(),document.activeElement!==se))return},[K,S]),W=h.useCallback(()=>q([A,T]),[q,A,T]);h.useEffect(()=>{J&&W()},[J,W]);const{onOpenChange:D,triggerPointerDownPosRef:I}=b;h.useEffect(()=>{if(T){let O={x:0,y:0};const j=Q=>{var se,ie;O={x:Math.abs(Math.round(Q.pageX)-(((se=I.current)==null?void 0:se.x)??0)),y:Math.abs(Math.round(Q.pageY)-(((ie=I.current)==null?void 0:ie.y)??0))}},U=Q=>{O.x<=10&&O.y<=10?Q.preventDefault():T.contains(Q.target)||D(!1),document.removeEventListener("pointermove",j),I.current=null};return I.current!==null&&(document.addEventListener("pointermove",j),document.addEventListener("pointerup",U,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",j),document.removeEventListener("pointerup",U,{capture:!0})}}},[T,D,I]),h.useEffect(()=>{const O=()=>D(!1);return window.addEventListener("blur",O),window.addEventListener("resize",O),()=>{window.removeEventListener("blur",O),window.removeEventListener("resize",O)}},[D]);const[G,X]=Gm(O=>{const j=K().filter(se=>!se.disabled),U=j.find(se=>se.ref.current===document.activeElement),Q=Ym(j,O,U);Q&&setTimeout(()=>Q.ref.current.focus())}),M=h.useCallback((O,j,U)=>{const Q=!Y.current&&!U;(b.value!==void 0&&b.value===j||Q)&&(P(O),Q&&(Y.current=!0))},[b.value]),B=h.useCallback(()=>T==null?void 0:T.focus(),[T]),R=h.useCallback((O,j,U)=>{const Q=!Y.current&&!U;(b.value!==void 0&&b.value===j||Q)&&F(O)},[b.value]),$=r==="popper"?$l:_m,z=$===$l?{side:a,sideOffset:c,align:l,alignOffset:d,arrowPadding:f,collisionBoundary:m,collisionPadding:p,sticky:v,hideWhenDetached:g,avoidCollisions:x}:{};return u.jsx(jm,{scope:n,content:T,viewport:S,onViewportChange:C,itemRefCallback:M,selectedItem:A,onItemLeave:B,itemTextRefCallback:R,focusSelectedItem:W,selectedItemText:L,position:r,isPositioned:J,searchRef:G,children:u.jsx(bs,{as:uE,allowPinchZoom:!0,children:u.jsx(ts,{asChild:!0,trapped:b.open,onMountAutoFocus:O=>{O.preventDefault()},onUnmountAutoFocus:ae(o,O=>{var j;(j=b.trigger)==null||j.focus({preventScroll:!0}),O.preventDefault()}),children:u.jsx(Tr,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:O=>O.preventDefault(),onDismiss:()=>b.onOpenChange(!1),children:u.jsx($,{role:"listbox",id:b.contentId,"data-state":b.open?"open":"closed",dir:b.dir,onContextMenu:O=>O.preventDefault(),...y,...z,onPlaced:()=>_(!0),ref:k,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:ae(y.onKeyDown,O=>{const j=O.ctrlKey||O.altKey||O.metaKey;if(O.key==="Tab"&&O.preventDefault(),!j&&O.key.length===1&&X(O.key),["ArrowUp","ArrowDown","Home","End"].includes(O.key)){let Q=K().filter(se=>!se.disabled).map(se=>se.ref.current);if(["ArrowUp","End"].includes(O.key)&&(Q=Q.slice().reverse()),["ArrowUp","ArrowDown"].includes(O.key)){const se=O.target,ie=Q.indexOf(se);Q=Q.slice(ie+1)}setTimeout(()=>q(Q)),O.preventDefault()}})})})})})})});Pm.displayName=cE;var dE="SelectItemAlignedPosition",_m=h.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=qn(fr,n),i=Gn(fr,n),[a,c]=h.useState(null),[l,d]=h.useState(null),f=Pe(t,k=>d(k)),m=ui(n),p=h.useRef(!1),v=h.useRef(!0),{viewport:g,selectedItem:x,selectedItemText:y,focusSelectedItem:b}=i,T=h.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&l&&g&&x&&y){const k=s.trigger.getBoundingClientRect(),A=l.getBoundingClientRect(),P=s.valueNode.getBoundingClientRect(),L=y.getBoundingClientRect();if(s.dir!=="rtl"){const se=L.left-A.left,ie=P.left-se,Se=k.left-ie,xe=k.width+Se,Re=Math.max(xe,A.width),Ve=window.innerWidth-mn,De=Pl(ie,[mn,Math.max(mn,Ve-Re)]);a.style.minWidth=xe+"px",a.style.left=De+"px"}else{const se=A.right-L.right,ie=window.innerWidth-P.right-se,Se=window.innerWidth-k.right-ie,xe=k.width+Se,Re=Math.max(xe,A.width),Ve=window.innerWidth-mn,De=Pl(ie,[mn,Math.max(mn,Ve-Re)]);a.style.minWidth=xe+"px",a.style.right=De+"px"}const F=m(),K=window.innerHeight-mn*2,J=g.scrollHeight,_=window.getComputedStyle(l),Y=parseInt(_.borderTopWidth,10),q=parseInt(_.paddingTop,10),W=parseInt(_.borderBottomWidth,10),D=parseInt(_.paddingBottom,10),I=Y+q+J+D+W,G=Math.min(x.offsetHeight*5,I),X=window.getComputedStyle(g),M=parseInt(X.paddingTop,10),B=parseInt(X.paddingBottom,10),R=k.top+k.height/2-mn,$=K-R,z=x.offsetHeight/2,O=x.offsetTop+z,j=Y+q+O,U=I-j;if(j<=R){const se=F.length>0&&x===F[F.length-1].ref.current;a.style.bottom="0px";const ie=l.clientHeight-g.offsetTop-g.offsetHeight,Se=Math.max($,z+(se?B:0)+ie+W),xe=j+Se;a.style.height=xe+"px"}else{const se=F.length>0&&x===F[0].ref.current;a.style.top="0px";const Se=Math.max(R,Y+g.offsetTop+(se?M:0)+z)+U;a.style.height=Se+"px",g.scrollTop=j-R+g.offsetTop}a.style.margin=`${mn}px 0`,a.style.minHeight=G+"px",a.style.maxHeight=K+"px",r==null||r(),requestAnimationFrame(()=>p.current=!0)}},[m,s.trigger,s.valueNode,a,l,g,x,y,s.dir,r]);kt(()=>T(),[T]);const[E,S]=h.useState();kt(()=>{l&&S(window.getComputedStyle(l).zIndex)},[l]);const C=h.useCallback(k=>{k&&v.current===!0&&(T(),b==null||b(),v.current=!1)},[T,b]);return u.jsx(pE,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:p,onScrollButtonChange:C,children:u.jsx("div",{ref:c,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:E},children:u.jsx(pe.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});_m.displayName=dE;var fE="SelectPopperPosition",$l=h.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=mn,...s}=e,i=di(n);return u.jsx(fa,{...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)"}})});$l.displayName=fE;var[pE,Fl]=zr(fr,{}),Bl="SelectViewport",Rm=h.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=Gn(Bl,n),i=Fl(Bl,n),a=Pe(t,s.onViewportChange),c=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(ci.Slot,{scope:n,children:u.jsx(pe.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:ae(o.onScroll,l=>{const d=l.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:m}=i;if(m!=null&&m.current&&f){const p=Math.abs(c.current-d.scrollTop);if(p>0){const v=window.innerHeight-mn*2,g=parseFloat(f.style.minHeight),x=parseFloat(f.style.height),y=Math.max(g,x);if(y<v){const b=y+p,T=Math.min(v,b),E=b-T;f.style.height=T+"px",f.style.bottom==="0px"&&(d.scrollTop=E>0?E:0,f.style.justifyContent="flex-end")}}}c.current=d.scrollTop})})})]})});Rm.displayName=Bl;var Mm="SelectGroup",[hE,mE]=zr(Mm),gE=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=_t();return u.jsx(hE,{scope:n,id:o,children:u.jsx(pe.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(pe.div,{id:o.id,...r,ref:t})});Dm.displayName=Om;var fi="SelectItem",[xE,Lm]=zr(fi),$m=h.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=qn(fi,n),c=Gn(fi,n),l=a.value===r,[d,f]=h.useState(s??""),[m,p]=h.useState(!1),v=Pe(t,b=>{var T;return(T=c.itemRefCallback)==null?void 0:T.call(c,b,r,o)}),g=_t(),x=h.useRef("touch"),y=()=>{o||(a.onValueChange(r),a.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return u.jsx(xE,{scope:n,value:r,disabled:o,textId:g,isSelected:l,onItemTextChange:h.useCallback(b=>{f(T=>T||((b==null?void 0:b.textContent)??"").trim())},[]),children:u.jsx(ci.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:u.jsx(pe.div,{role:"option","aria-labelledby":g,"data-highlighted":m?"":void 0,"aria-selected":l&&m,"data-state":l?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:v,onFocus:ae(i.onFocus,()=>p(!0)),onBlur:ae(i.onBlur,()=>p(!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 T;x.current=b.pointerType,o?(T=c.onItemLeave)==null||T.call(c):x.current==="mouse"&&b.currentTarget.focus({preventScroll:!0})}),onPointerLeave:ae(i.onPointerLeave,b=>{var T;b.currentTarget===document.activeElement&&((T=c.onItemLeave)==null||T.call(c))}),onKeyDown:ae(i.onKeyDown,b=>{var E;((E=c.searchRef)==null?void 0:E.current)!==""&&b.key===" "||(nE.includes(b.key)&&y(),b.key===" "&&b.preventDefault())})})})})});$m.displayName=fi;var Mo="SelectItemText",Fm=h.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=qn(Mo,n),a=Gn(Mo,n),c=Lm(Mo,n),l=iE(Mo,n),[d,f]=h.useState(null),m=Pe(t,y=>f(y),c.onItemTextChange,y=>{var b;return(b=a.itemTextRefCallback)==null?void 0:b.call(a,y,c.value,c.disabled)}),p=d==null?void 0:d.textContent,v=h.useMemo(()=>u.jsx("option",{value:c.value,disabled:c.disabled,children:p},c.value),[c.disabled,c.value,p]),{onNativeOptionAdd:g,onNativeOptionRemove:x}=l;return kt(()=>(g(v),()=>x(v)),[g,x,v]),u.jsxs(u.Fragment,{children:[u.jsx(pe.span,{id:c.textId,...s,ref:m}),c.isSelected&&i.valueNode&&!i.valueNodeHasChildren?Vr.createPortal(s.children,i.valueNode):null]})});Fm.displayName=Mo;var Bm="SelectItemIndicator",zm=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return Lm(Bm,n).isSelected?u.jsx(pe.span,{"aria-hidden":!0,...r,ref:t}):null});zm.displayName=Bm;var zl="SelectScrollUpButton",Hm=h.forwardRef((e,t)=>{const n=Gn(zl,e.__scopeSelect),r=Fl(zl,e.__scopeSelect),[o,s]=h.useState(!1),i=Pe(t,r.onScrollButtonChange);return kt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const l=c.scrollTop>0;s(l)};const c=n.viewport;return a(),c.addEventListener("scroll",a),()=>c.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?u.jsx(Wm,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:c}=n;a&&c&&(a.scrollTop=a.scrollTop-c.offsetHeight)}}):null});Hm.displayName=zl;var Hl="SelectScrollDownButton",Um=h.forwardRef((e,t)=>{const n=Gn(Hl,e.__scopeSelect),r=Fl(Hl,e.__scopeSelect),[o,s]=h.useState(!1),i=Pe(t,r.onScrollButtonChange);return kt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const l=c.scrollHeight-c.clientHeight,d=Math.ceil(c.scrollTop)<l;s(d)};const c=n.viewport;return a(),c.addEventListener("scroll",a),()=>c.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?u.jsx(Wm,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:c}=n;a&&c&&(a.scrollTop=a.scrollTop+c.offsetHeight)}}):null});Um.displayName=Hl;var Wm=h.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=Gn("SelectScrollButton",n),i=h.useRef(null),a=ui(n),c=h.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return h.useEffect(()=>()=>c(),[c]),kt(()=>{var d;const l=a().find(f=>f.ref.current===document.activeElement);(d=l==null?void 0:l.ref.current)==null||d.scrollIntoView({block:"nearest"})},[a]),u.jsx(pe.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 l;(l=s.onItemLeave)==null||l.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:ae(o.onPointerLeave,()=>{c()})})}),vE="SelectSeparator",Vm=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return u.jsx(pe.div,{"aria-hidden":!0,...r,ref:t})});Vm.displayName=vE;var Ul="SelectArrow",wE=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=di(n),s=qn(Ul,n),i=Gn(Ul,n);return s.open&&i.position==="popper"?u.jsx(pa,{...o,...r,ref:t}):null});wE.displayName=Ul;var bE="SelectBubbleInput",Km=h.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=h.useRef(null),s=Pe(r,o),i=bm(t);return h.useEffect(()=>{const a=o.current;if(!a)return;const c=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(c,"value").set;if(i!==t&&d){const f=new Event("change",{bubbles:!0});d.call(a,t),a.dispatchEvent(f)}},[i,t]),u.jsx(pe.select,{...n,style:{...ym,...n.style},ref:s,defaultValue:t})});Km.displayName=bE;function qm(e){return e===""||e===void 0}function Gm(e){const t=gt(e),n=h.useRef(""),r=h.useRef(0),o=h.useCallback(i=>{const a=n.current+i;t(a),function c(l){n.current=l,window.clearTimeout(r.current),l!==""&&(r.current=window.setTimeout(()=>c(""),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(l=>l===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(l=>l!==n));const c=i.find(l=>l.textValue.toLowerCase().startsWith(o.toLowerCase()));return c!==n?c: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 PE=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}));PE.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 _E=h.forwardRef(({className:e,...t},n)=>u.jsx(ng,{ref:n,className:ne("-mx-1 my-1 h-px bg-muted",e),...t}));_E.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(pe.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 pi="Switch",[DE,KN]=cn(pi),[LE,$E]=DE(pi),fg=h.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:s,required:i,disabled:a,value:c="on",onCheckedChange:l,form:d,...f}=e,[m,p]=h.useState(null),v=Pe(t,T=>p(T)),g=h.useRef(!1),x=m?d||!!m.closest("form"):!0,[y,b]=On({prop:o,defaultProp:s??!1,onChange:l,caller:pi});return u.jsxs(LE,{scope:n,checked:y,disabled:a,children:[u.jsx(pe.button,{type:"button",role:"switch","aria-checked":y,"aria-required":i,"data-state":gg(y),"data-disabled":a?"":void 0,disabled:a,value:c,...f,ref:v,onClick:ae(e.onClick,T=>{b(E=>!E),x&&(g.current=T.isPropagationStopped(),g.current||T.stopPropagation())})}),x&&u.jsx(mg,{control:m,bubbles:!g.current,name:r,value:c,checked:y,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});fg.displayName=pi;var pg="SwitchThumb",hg=h.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=$E(pg,n);return u.jsx(pe.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=Pe(i,s),c=bm(n),l=kd(t);return h.useEffect(()=>{const d=i.current;if(!d)return;const f=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(f,"checked").set;if(c!==n&&p){const v=new Event("click",{bubbles:r});p.call(d,n),d.dispatchEvent(v)}},[c,n,r]),u.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:a,style:{...o.style,...l,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=rl,HE=wT,UE=ol,wg=h.forwardRef(({className:e,...t},n)=>u.jsx(No,{className:ne("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t,ref:n}));wg.displayName=No.displayName;const WE=Wr.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"}}),bg=h.forwardRef(({side:e="right",className:t,children:n,...r},o)=>u.jsxs(UE,{children:[u.jsx(wg,{}),u.jsxs(Ao,{ref:o,className:ne(WE({side:e}),t),...r,children:[n,u.jsxs(dh,{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"})]})]})]}));bg.displayName=Ao.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(ar,{ref:n,className:ne("text-lg font-semibold text-foreground",e),...t}));Sg.displayName=ar.displayName;const Cg=h.forwardRef(({className:e,...t},n)=>u.jsx(Us,{ref:n,className:ne("text-sm text-muted-foreground",e),...t}));Cg.displayName=Us.displayName;var[hi,qN]=cn("Tooltip",[Ar]),mi=Ar(),Tg="TooltipProvider",VE=700,Wl="tooltip.open",[KE,Vl]=hi(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),c=h.useRef(0);return h.useEffect(()=>{const l=c.current;return()=>window.clearTimeout(l)},[]),u.jsx(KE,{scope:t,isOpenDelayedRef:i,delayDuration:n,onOpen:h.useCallback(()=>{window.clearTimeout(c.current),i.current=!1},[]),onClose:h.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>i.current=!0,r)},[r]),isPointerInTransitRef:a,onPointerInTransitChange:h.useCallback(l=>{a.current=l},[]),disableHoverableContent:o,children:s})};kg.displayName=Tg;var Oo="Tooltip",[qE,gi]=hi(Oo),Eg=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:s,disableHoverableContent:i,delayDuration:a}=e,c=Vl(Oo,e.__scopeTooltip),l=mi(t),[d,f]=h.useState(null),m=_t(),p=h.useRef(0),v=i??c.disableHoverableContent,g=a??c.delayDuration,x=h.useRef(!1),[y,b]=On({prop:r,defaultProp:o??!1,onChange:k=>{k?(c.onOpen(),document.dispatchEvent(new CustomEvent(Wl))):c.onClose(),s==null||s(k)},caller:Oo}),T=h.useMemo(()=>y?x.current?"delayed-open":"instant-open":"closed",[y]),E=h.useCallback(()=>{window.clearTimeout(p.current),p.current=0,x.current=!1,b(!0)},[b]),S=h.useCallback(()=>{window.clearTimeout(p.current),p.current=0,b(!1)},[b]),C=h.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{x.current=!0,b(!0),p.current=0},g)},[g,b]);return h.useEffect(()=>()=>{p.current&&(window.clearTimeout(p.current),p.current=0)},[]),u.jsx(ua,{...l,children:u.jsx(qE,{scope:t,contentId:m,open:y,stateAttribute:T,trigger:d,onTriggerChange:f,onTriggerEnter:h.useCallback(()=>{c.isOpenDelayedRef.current?C():E()},[c.isOpenDelayedRef,C,E]),onTriggerLeave:h.useCallback(()=>{v?S():(window.clearTimeout(p.current),p.current=0)},[S,v]),onOpen:E,onClose:S,disableHoverableContent:v,children:n})})};Eg.displayName=Oo;var Kl="TooltipTrigger",Ig=h.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=gi(Kl,n),s=Vl(Kl,n),i=mi(n),a=h.useRef(null),c=Pe(t,a,o.onTriggerChange),l=h.useRef(!1),d=h.useRef(!1),f=h.useCallback(()=>l.current=!1,[]);return h.useEffect(()=>()=>document.removeEventListener("pointerup",f),[f]),u.jsx(da,{asChild:!0,...i,children:u.jsx(pe.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:c,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(),l.current=!0,document.addEventListener("pointerup",f,{once:!0})}),onFocus:ae(e.onFocus,()=>{l.current||o.onOpen()}),onBlur:ae(e.onBlur,o.onClose),onClick:ae(e.onClick,o.onClose)})})});Ig.displayName=Kl;var GE="TooltipPortal",[GN,YE]=hi(GE,{forceMount:void 0}),Hr="TooltipContent",Ng=h.forwardRef((e,t)=>{const n=YE(Hr,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...s}=e,i=gi(Hr,e.__scopeTooltip);return u.jsx(Ht,{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=gi(Hr,e.__scopeTooltip),r=Vl(Hr,e.__scopeTooltip),o=h.useRef(null),s=Pe(t,o),[i,a]=h.useState(null),{trigger:c,onClose:l}=n,d=o.current,{onPointerInTransitChange:f}=r,m=h.useCallback(()=>{a(null),f(!1)},[f]),p=h.useCallback((v,g)=>{const x=v.currentTarget,y={x:v.clientX,y:v.clientY},b=tI(y,x.getBoundingClientRect()),T=nI(y,b),E=rI(g.getBoundingClientRect()),S=sI([...T,...E]);a(S),f(!0)},[f]);return h.useEffect(()=>()=>m(),[m]),h.useEffect(()=>{if(c&&d){const v=x=>p(x,d),g=x=>p(x,c);return c.addEventListener("pointerleave",v),d.addEventListener("pointerleave",g),()=>{c.removeEventListener("pointerleave",v),d.removeEventListener("pointerleave",g)}}},[c,d,p,m]),h.useEffect(()=>{if(i){const v=g=>{const x=g.target,y={x:g.clientX,y:g.clientY},b=(c==null?void 0:c.contains(x))||(d==null?void 0:d.contains(x)),T=!oI(y,i);b?m():T&&(m(),l())};return document.addEventListener("pointermove",v),()=>document.removeEventListener("pointermove",v)}},[c,d,i,l,m]),u.jsx(Ag,{...e,ref:s})}),[JE,ZE]=hi(Oo,{isInside:!1}),QE=qt.createSlottable("TooltipContent"),Ag=h.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:s,onPointerDownOutside:i,...a}=e,c=gi(Hr,n),l=mi(n),{onClose:d}=c;return h.useEffect(()=>(document.addEventListener(Wl,d),()=>document.removeEventListener(Wl,d)),[d]),h.useEffect(()=>{if(c.trigger){const f=m=>{const p=m.target;p!=null&&p.contains(c.trigger)&&d()};return window.addEventListener("scroll",f,{capture:!0}),()=>window.removeEventListener("scroll",f,{capture:!0})}},[c.trigger,d]),u.jsx(Tr,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:f=>f.preventDefault(),onDismiss:d,children:u.jsxs(fa,{"data-state":c.stateAttribute,...l,...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:c.contentId,role:"tooltip",children:o||r})})]})})});Ng.displayName=Hr;var jg="TooltipArrow",eI=h.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=mi(n);return ZE(jg,n).isInside?null:u.jsx(pa,{...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],c=t[i],l=a.x,d=a.y,f=c.x,m=c.y;d>r!=m>r&&n<(f-l)*(r-d)/(m-d)+l&&(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,Pg=Ng;const uI=aI,dI=lI,fI=cI,_g=h.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(Pg,{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}));_g.displayName=Pg.displayName;var ql="ToastProvider",[Gl,pI,hI]=Qo("Toast"),[Rg,YN]=cn("Toast",[hI]),[mI,xi]=Rg(ql),Mg=e=>{const{__scopeToast:t,label:n="Notification",duration:r=5e3,swipeDirection:o="right",swipeThreshold:s=50,children:i}=e,[a,c]=h.useState(null),[l,d]=h.useState(0),f=h.useRef(!1),m=h.useRef(!1);return n.trim()||console.error(`Invalid prop \`label\` supplied to \`${ql}\`. Expected non-empty \`string\`.`),u.jsx(Gl.Provider,{scope:t,children:u.jsx(mI,{scope:t,label:n,duration:r,swipeDirection:o,swipeThreshold:s,toastCount:l,viewport:a,onViewportChange:c,onToastAdd:h.useCallback(()=>d(p=>p+1),[]),onToastRemove:h.useCallback(()=>d(p=>p-1),[]),isFocusedToastEscapeKeyDownRef:f,isClosePausedRef:m,children:i})})};Mg.displayName=ql;var Og="ToastViewport",gI=["F8"],Yl="toast.viewportPause",Xl="toast.viewportResume",Dg=h.forwardRef((e,t)=>{const{__scopeToast:n,hotkey:r=gI,label:o="Notifications ({hotkey})",...s}=e,i=xi(Og,n),a=pI(n),c=h.useRef(null),l=h.useRef(null),d=h.useRef(null),f=h.useRef(null),m=Pe(t,f,i.onViewportChange),p=r.join("+").replace(/Key/g,"").replace(/Digit/g,""),v=i.toastCount>0;h.useEffect(()=>{const x=y=>{var T;r.length!==0&&r.every(E=>y[E]||y.code===E)&&((T=f.current)==null||T.focus())};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[r]),h.useEffect(()=>{const x=c.current,y=f.current;if(v&&x&&y){const b=()=>{if(!i.isClosePausedRef.current){const C=new CustomEvent(Yl);y.dispatchEvent(C),i.isClosePausedRef.current=!0}},T=()=>{if(i.isClosePausedRef.current){const C=new CustomEvent(Xl);y.dispatchEvent(C),i.isClosePausedRef.current=!1}},E=C=>{!x.contains(C.relatedTarget)&&T()},S=()=>{x.contains(document.activeElement)||T()};return x.addEventListener("focusin",b),x.addEventListener("focusout",E),x.addEventListener("pointermove",b),x.addEventListener("pointerleave",S),window.addEventListener("blur",b),window.addEventListener("focus",T),()=>{x.removeEventListener("focusin",b),x.removeEventListener("focusout",E),x.removeEventListener("pointermove",b),x.removeEventListener("pointerleave",S),window.removeEventListener("blur",b),window.removeEventListener("focus",T)}}},[v,i.isClosePausedRef]);const g=h.useCallback(({tabbingDirection:x})=>{const b=a().map(T=>{const E=T.ref.current,S=[E,...AI(E)];return x==="forwards"?S:S.reverse()});return(x==="forwards"?b.reverse():b).flat()},[a]);return h.useEffect(()=>{const x=f.current;if(x){const y=b=>{var S,C,k;const T=b.altKey||b.ctrlKey||b.metaKey;if(b.key==="Tab"&&!T){const A=document.activeElement,P=b.shiftKey;if(b.target===x&&P){(S=l.current)==null||S.focus();return}const K=g({tabbingDirection:P?"backwards":"forwards"}),J=K.findIndex(_=>_===A);Ql(K.slice(J+1))?b.preventDefault():P?(C=l.current)==null||C.focus():(k=d.current)==null||k.focus()}};return x.addEventListener("keydown",y),()=>x.removeEventListener("keydown",y)}},[a,g]),u.jsxs(qw,{ref:c,role:"region","aria-label":o.replace("{hotkey}",p),tabIndex:-1,style:{pointerEvents:v?void 0:"none"},children:[v&&u.jsx(Jl,{ref:l,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"forwards"});Ql(x)}}),u.jsx(Gl.Slot,{scope:n,children:u.jsx(pe.ol,{tabIndex:-1,...s,ref:m})}),v&&u.jsx(Jl,{ref:d,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"backwards"});Ql(x)}})]})});Dg.displayName=Og;var Lg="ToastFocusProxy",Jl=h.forwardRef((e,t)=>{const{__scopeToast:n,onFocusFromOutsideViewport:r,...o}=e,s=xi(Lg,n);return u.jsx(li,{tabIndex:0,...o,ref:t,style:{position:"fixed"},onFocus:i=>{var l;const a=i.relatedTarget;!((l=s.viewport)!=null&&l.contains(a))&&r()}})});Jl.displayName=Lg;var Do="Toast",xI="toast.swipeStart",vI="toast.swipeMove",wI="toast.swipeCancel",bI="toast.swipeEnd",$g=h.forwardRef((e,t)=>{const{forceMount:n,open:r,defaultOpen:o,onOpenChange:s,...i}=e,[a,c]=On({prop:r,defaultProp:o??!0,onChange:s,caller:Do});return u.jsx(Ht,{present:n||a,children:u.jsx(CI,{open:a,...i,ref:t,onClose:()=>c(!1),onPause:gt(e.onPause),onResume:gt(e.onResume),onSwipeStart:ae(e.onSwipeStart,l=>{l.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:ae(e.onSwipeMove,l=>{const{x:d,y:f}=l.detail.delta;l.currentTarget.setAttribute("data-swipe","move"),l.currentTarget.style.setProperty("--radix-toast-swipe-move-x",`${d}px`),l.currentTarget.style.setProperty("--radix-toast-swipe-move-y",`${f}px`)}),onSwipeCancel:ae(e.onSwipeCancel,l=>{l.currentTarget.setAttribute("data-swipe","cancel"),l.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),l.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),l.currentTarget.style.removeProperty("--radix-toast-swipe-end-x"),l.currentTarget.style.removeProperty("--radix-toast-swipe-end-y")}),onSwipeEnd:ae(e.onSwipeEnd,l=>{const{x:d,y:f}=l.detail.delta;l.currentTarget.setAttribute("data-swipe","end"),l.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),l.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),l.currentTarget.style.setProperty("--radix-toast-swipe-end-x",`${d}px`),l.currentTarget.style.setProperty("--radix-toast-swipe-end-y",`${f}px`),c(!1)})})})});$g.displayName=Do;var[yI,SI]=Rg(Do,{onClose(){}}),CI=h.forwardRef((e,t)=>{const{__scopeToast:n,type:r="foreground",duration:o,open:s,onClose:i,onEscapeKeyDown:a,onPause:c,onResume:l,onSwipeStart:d,onSwipeMove:f,onSwipeCancel:m,onSwipeEnd:p,...v}=e,g=xi(Do,n),[x,y]=h.useState(null),b=Pe(t,_=>y(_)),T=h.useRef(null),E=h.useRef(null),S=o||g.duration,C=h.useRef(0),k=h.useRef(S),A=h.useRef(0),{onToastAdd:P,onToastRemove:L}=g,F=gt(()=>{var Y;(x==null?void 0:x.contains(document.activeElement))&&((Y=g.viewport)==null||Y.focus()),i()}),K=h.useCallback(_=>{!_||_===1/0||(window.clearTimeout(A.current),C.current=new Date().getTime(),A.current=window.setTimeout(F,_))},[F]);h.useEffect(()=>{const _=g.viewport;if(_){const Y=()=>{K(k.current),l==null||l()},q=()=>{const W=new Date().getTime()-C.current;k.current=k.current-W,window.clearTimeout(A.current),c==null||c()};return _.addEventListener(Yl,q),_.addEventListener(Xl,Y),()=>{_.removeEventListener(Yl,q),_.removeEventListener(Xl,Y)}}},[g.viewport,S,c,l,K]),h.useEffect(()=>{s&&!g.isClosePausedRef.current&&K(S)},[s,S,g.isClosePausedRef,K]),h.useEffect(()=>(P(),()=>L()),[P,L]);const J=h.useMemo(()=>x?Vg(x):null,[x]);return g.viewport?u.jsxs(u.Fragment,{children:[J&&u.jsx(TI,{__scopeToast:n,role:"status","aria-live":r==="foreground"?"assertive":"polite",children:J}),u.jsx(yI,{scope:n,onClose:F,children:Vr.createPortal(u.jsx(Gl.ItemSlot,{scope:n,children:u.jsx(Kw,{asChild:!0,onEscapeKeyDown:ae(a,()=>{g.isFocusedToastEscapeKeyDownRef.current||F(),g.isFocusedToastEscapeKeyDownRef.current=!1}),children:u.jsx(pe.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&&(T.current={x:_.clientX,y:_.clientY})}),onPointerMove:ae(e.onPointerMove,_=>{if(!T.current)return;const Y=_.clientX-T.current.x,q=_.clientY-T.current.y,W=!!E.current,D=["left","right"].includes(g.swipeDirection),I=["left","up"].includes(g.swipeDirection)?Math.min:Math.max,G=D?I(0,Y):0,X=D?0:I(0,q),M=_.pointerType==="touch"?10:2,B={x:G,y:X},R={originalEvent:_,delta:B};W?(E.current=B,vi(vI,f,R,{discrete:!1})):Kg(B,g.swipeDirection,M)?(E.current=B,vi(xI,d,R,{discrete:!1}),_.target.setPointerCapture(_.pointerId)):(Math.abs(Y)>M||Math.abs(q)>M)&&(T.current=null)}),onPointerUp:ae(e.onPointerUp,_=>{const Y=E.current,q=_.target;if(q.hasPointerCapture(_.pointerId)&&q.releasePointerCapture(_.pointerId),E.current=null,T.current=null,Y){const W=_.currentTarget,D={originalEvent:_,delta:Y};Kg(Y,g.swipeDirection,g.swipeThreshold)?vi(bI,p,D,{discrete:!0}):vi(wI,m,D,{discrete:!0}),W.addEventListener("click",I=>I.preventDefault(),{once:!0})}})})})}),g.viewport)})]}):null}),TI=e=>{const{__scopeToast:t,children:n,...r}=e,o=xi(Do,t),[s,i]=h.useState(!1),[a,c]=h.useState(!1);return II(()=>i(!0)),h.useEffect(()=>{const l=window.setTimeout(()=>c(!0),1e3);return()=>window.clearTimeout(l)},[]),a?null:u.jsx(co,{asChild:!0,children:u.jsx(li,{...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(pe.div,{...r,ref:t})});Fg.displayName=kI;var EI="ToastDescription",Bg=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(pe.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(Zl,{...r,ref:t})}):(console.error(`Invalid prop \`altText\` supplied to \`${zg}\`. Expected non-empty \`string\`.`),null)});Hg.displayName=zg;var Ug="ToastClose",Zl=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e,o=SI(Ug,n);return u.jsx(Wg,{asChild:!0,children:u.jsx(pe.button,{type:"button",...r,ref:t,onClick:ae(e.onClick,o.onClose)})})});Zl.displayName=Ug;var Wg=h.forwardRef((e,t)=>{const{__scopeToast:n,altText:r,...o}=e;return u.jsx(pe.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 vi(e,t,n,{discrete:r}){const o=n.originalEvent.currentTarget,s=new CustomEvent(e,{bubbles:!0,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?Vi(o,s):o.dispatchEvent(s)}var 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=gt(e);kt(()=>{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 Ql(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=Zl;const PI=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 _I=Wr.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(_I({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}=ll();return u.jsxs(PI,{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 c=document.documentElement,l=["light","dark"];function d(p){(Array.isArray(e)?e:[e]).forEach(v=>{let g=v==="class",x=g&&s?o.map(y=>s[y]||y):o;g?(c.classList.remove(...x),c.classList.add(s&&s[p]?s[p]:p)):c.setAttribute(v,p)}),f(p)}function f(p){a&&l.includes(p)&&(c.style.colorScheme=p)}function m(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}if(r)d(r);else try{let p=localStorage.getItem(t)||n,v=i&&p==="system"?m():p;d(v)}catch{}},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:c,scriptProps:l})=>{let d=JSON.stringify([n,t,s,e,a,i,r,o]).slice(1,-1);return h.createElement("script",{...l,suppressHydrationWarning:!0,nonce:typeof window>"u"?c:"",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},ec=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:ec++,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 c=>{if(s=["resolve",c],w.isValidElement(c))o=!1,this.create({id:n,type:"default",message:c});else if(XI(c)&&!c.ok){o=!1;let l=typeof t.error=="function"?await t.error(`HTTP error! status: ${c.status}`):t.error,d=typeof t.description=="function"?await t.description(`HTTP error! status: ${c.status}`):t.description;this.create({id:n,type:"error",message:l,description:d})}else if(t.success!==void 0){o=!1;let l=typeof t.success=="function"?await t.success(c):t.success,d=typeof t.description=="function"?await t.description(c):t.description;this.create({id:n,type:"success",message:l,description:d})}}).catch(async c=>{if(s=["reject",c],t.error!==void 0){o=!1;let l=typeof t.error=="function"?await t.error(c):t.error,d=typeof t.description=="function"?await t.description(c):t.description;this.create({id:n,type:"error",message:l,description:d})}}).finally(()=>{var c;o&&(this.dismiss(n),n=void 0),(c=t.finally)==null||c.call(t)}),a=()=>new Promise((c,l)=>i.then(()=>s[0]==="reject"?l(s[1]):c(s[1])).catch(l));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)||ec++;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}},Vt=new GI,YI=(e,t)=>{let n=(t==null?void 0:t.id)||ec++;return Vt.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=()=>Vt.toasts,QI=()=>Vt.getActiveToasts();Object.assign(JI,{success:Vt.success,info:Vt.info,warning:Vt.warning,error:Vt.error,custom:Vt.custom,message:Vt.message,promise:Vt.promise,dismiss:Vt.dismiss,loading:Vt.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 wi(e){return e.label!==void 0}var tN=3,nN="32px",rN="16px",ox=4e3,oN=356,sN=14,iN=20,aN=200;function gn(...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,c,l,d,f;let{invert:m,toast:p,unstyled:v,interacting:g,setHeights:x,visibleToasts:y,heights:b,index:T,toasts:E,expanded:S,removeToast:C,defaultRichColors:k,closeButton:A,style:P,cancelButtonStyle:L,actionButtonStyle:F,className:K="",descriptionClassName:J="",duration:_,position:Y,gap:q,loadingIcon:W,expandByDefault:D,classNames:I,icons:G,closeButtonAriaLabel:X="Close toast",pauseWhenPageIsHidden:M}=e,[B,R]=w.useState(null),[$,z]=w.useState(null),[O,j]=w.useState(!1),[U,Q]=w.useState(!1),[se,ie]=w.useState(!1),[Se,xe]=w.useState(!1),[Re,Ve]=w.useState(!1),[De,Ge]=w.useState(0),[He,ot]=w.useState(0),ut=w.useRef(p.duration||_||ox),nt=w.useRef(null),Le=w.useRef(null),Ke=T===0,$e=T+1<=y,Te=p.type,Ae=p.dismissible!==!1,dt=p.className||"",Et=p.descriptionClassName||"",at=w.useMemo(()=>b.findIndex(fe=>fe.toastId===p.id)||0,[b,p.id]),It=w.useMemo(()=>{var fe;return(fe=p.closeButton)!=null?fe:A},[p.closeButton,A]),bt=w.useMemo(()=>p.duration||_||ox,[p.duration,_]),ft=w.useRef(0),Nt=w.useRef(0),At=w.useRef(0),Ct=w.useRef(null),[on,Tt]=Y.split("-"),Ie=w.useMemo(()=>b.reduce((fe,ke,Fe)=>Fe>=at?fe:fe+ke.height,0),[b,at]),Ue=qI(),jt=p.invert||m,te=Te==="loading";Nt.current=w.useMemo(()=>at*q+Ie,[at,Ie]),w.useEffect(()=>{ut.current=bt},[bt]),w.useEffect(()=>{j(!0)},[]),w.useEffect(()=>{let fe=Le.current;if(fe){let ke=fe.getBoundingClientRect().height;return ot(ke),x(Fe=>[{toastId:p.id,height:ke,position:p.position},...Fe]),()=>x(Fe=>Fe.filter(ht=>ht.toastId!==p.id))}},[x,p.id]),w.useLayoutEffect(()=>{if(!O)return;let fe=Le.current,ke=fe.style.height;fe.style.height="auto";let Fe=fe.getBoundingClientRect().height;fe.style.height=ke,ot(Fe),x(ht=>ht.find(pt=>pt.toastId===p.id)?ht.map(pt=>pt.toastId===p.id?{...pt,height:Fe}:pt):[{toastId:p.id,height:Fe,position:p.position},...ht])},[O,p.title,p.description,x,p.id]);let ge=w.useCallback(()=>{Q(!0),Ge(Nt.current),x(fe=>fe.filter(ke=>ke.toastId!==p.id)),setTimeout(()=>{C(p)},aN)},[p,C,x,Nt]);w.useEffect(()=>{if(p.promise&&Te==="loading"||p.duration===1/0||p.type==="loading")return;let fe;return S||g||M&&Ue?(()=>{if(At.current<ft.current){let ke=new Date().getTime()-ft.current;ut.current=ut.current-ke}At.current=new Date().getTime()})():ut.current!==1/0&&(ft.current=new Date().getTime(),fe=setTimeout(()=>{var ke;(ke=p.onAutoClose)==null||ke.call(p,p),ge()},ut.current)),()=>clearTimeout(fe)},[S,g,p,Te,M,Ue,ge]),w.useEffect(()=>{p.delete&&ge()},[ge,p.delete]);function rt(){var fe,ke,Fe;return G!=null&&G.loading?w.createElement("div",{className:gn(I==null?void 0:I.loader,(fe=p==null?void 0:p.classNames)==null?void 0:fe.loader,"sonner-loader"),"data-visible":Te==="loading"},G.loading):W?w.createElement("div",{className:gn(I==null?void 0:I.loader,(ke=p==null?void 0:p.classNames)==null?void 0:ke.loader,"sonner-loader"),"data-visible":Te==="loading"},W):w.createElement(zI,{className:gn(I==null?void 0:I.loader,(Fe=p==null?void 0:p.classNames)==null?void 0:Fe.loader),visible:Te==="loading"})}return w.createElement("li",{tabIndex:0,ref:Le,className:gn(K,dt,I==null?void 0:I.toast,(t=p==null?void 0:p.classNames)==null?void 0:t.toast,I==null?void 0:I.default,I==null?void 0:I[Te],(n=p==null?void 0:p.classNames)==null?void 0:n[Te]),"data-sonner-toast":"","data-rich-colors":(r=p.richColors)!=null?r:k,"data-styled":!(p.jsx||p.unstyled||v),"data-mounted":O,"data-promise":!!p.promise,"data-swiped":Re,"data-removed":U,"data-visible":$e,"data-y-position":on,"data-x-position":Tt,"data-index":T,"data-front":Ke,"data-swiping":se,"data-dismissible":Ae,"data-type":Te,"data-invert":jt,"data-swipe-out":Se,"data-swipe-direction":$,"data-expanded":!!(S||D&&O),style:{"--index":T,"--toasts-before":T,"--z-index":E.length-T,"--offset":`${U?De:Nt.current}px`,"--initial-height":D?"auto":`${He}px`,...P,...p.style},onDragEnd:()=>{ie(!1),R(null),Ct.current=null},onPointerDown:fe=>{te||!Ae||(nt.current=new Date,Ge(Nt.current),fe.target.setPointerCapture(fe.pointerId),fe.target.tagName!=="BUTTON"&&(ie(!0),Ct.current={x:fe.clientX,y:fe.clientY}))},onPointerUp:()=>{var fe,ke,Fe,ht;if(Se||!Ae)return;Ct.current=null;let pt=Number(((fe=Le.current)==null?void 0:fe.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),je=Number(((ke=Le.current)==null?void 0:ke.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),Ye=new Date().getTime()-((Fe=nt.current)==null?void 0:Fe.getTime()),we=B==="x"?pt:je,Qe=Math.abs(we)/Ye;if(Math.abs(we)>=iN||Qe>.11){Ge(Nt.current),(ht=p.onDismiss)==null||ht.call(p,p),z(B==="x"?pt>0?"right":"left":je>0?"down":"up"),ge(),xe(!0),Ve(!1);return}ie(!1),R(null)},onPointerMove:fe=>{var ke,Fe,ht,pt;if(!Ct.current||!Ae||((ke=window.getSelection())==null?void 0:ke.toString().length)>0)return;let je=fe.clientY-Ct.current.y,Ye=fe.clientX-Ct.current.x,we=(Fe=e.swipeDirections)!=null?Fe:lN(Y);!B&&(Math.abs(Ye)>1||Math.abs(je)>1)&&R(Math.abs(Ye)>Math.abs(je)?"x":"y");let Qe={x:0,y:0};B==="y"?(we.includes("top")||we.includes("bottom"))&&(we.includes("top")&&je<0||we.includes("bottom")&&je>0)&&(Qe.y=je):B==="x"&&(we.includes("left")||we.includes("right"))&&(we.includes("left")&&Ye<0||we.includes("right")&&Ye>0)&&(Qe.x=Ye),(Math.abs(Qe.x)>0||Math.abs(Qe.y)>0)&&Ve(!0),(ht=Le.current)==null||ht.style.setProperty("--swipe-amount-x",`${Qe.x}px`),(pt=Le.current)==null||pt.style.setProperty("--swipe-amount-y",`${Qe.y}px`)}},It&&!p.jsx?w.createElement("button",{"aria-label":X,"data-disabled":te,"data-close-button":!0,onClick:te||!Ae?()=>{}:()=>{var fe;ge(),(fe=p.onDismiss)==null||fe.call(p,p)},className:gn(I==null?void 0:I.closeButton,(o=p==null?void 0:p.classNames)==null?void 0:o.closeButton)},(s=G==null?void 0:G.close)!=null?s:KI):null,p.jsx||w.isValidElement(p.title)?p.jsx?p.jsx:typeof p.title=="function"?p.title():p.title:w.createElement(w.Fragment,null,Te||p.icon||p.promise?w.createElement("div",{"data-icon":"",className:gn(I==null?void 0:I.icon,(i=p==null?void 0:p.classNames)==null?void 0:i.icon)},p.promise||p.type==="loading"&&!p.icon?p.icon||rt():null,p.type!=="loading"?p.icon||(G==null?void 0:G[Te])||FI(Te):null):null,w.createElement("div",{"data-content":"",className:gn(I==null?void 0:I.content,(a=p==null?void 0:p.classNames)==null?void 0:a.content)},w.createElement("div",{"data-title":"",className:gn(I==null?void 0:I.title,(c=p==null?void 0:p.classNames)==null?void 0:c.title)},typeof p.title=="function"?p.title():p.title),p.description?w.createElement("div",{"data-description":"",className:gn(J,Et,I==null?void 0:I.description,(l=p==null?void 0:p.classNames)==null?void 0:l.description)},typeof p.description=="function"?p.description():p.description):null),w.isValidElement(p.cancel)?p.cancel:p.cancel&&wi(p.cancel)?w.createElement("button",{"data-button":!0,"data-cancel":!0,style:p.cancelButtonStyle||L,onClick:fe=>{var ke,Fe;wi(p.cancel)&&Ae&&((Fe=(ke=p.cancel).onClick)==null||Fe.call(ke,fe),ge())},className:gn(I==null?void 0:I.cancelButton,(d=p==null?void 0:p.classNames)==null?void 0:d.cancelButton)},p.cancel.label):null,w.isValidElement(p.action)?p.action:p.action&&wi(p.action)?w.createElement("button",{"data-button":!0,"data-action":!0,style:p.actionButtonStyle||F,onClick:fe=>{var ke,Fe;wi(p.action)&&((Fe=(ke=p.action).onClick)==null||Fe.call(ke,fe),!fe.defaultPrevented&&ge())},className:gn(I==null?void 0:I.actionButton,(f=p==null?void 0:p.classNames)==null?void 0:f.actionButton)},p.action.label):null))};function 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 c(l){["top","right","bottom","left"].forEach(d=>{n[`${i}-${d}`]=typeof l=="number"?`${l}px`:l})}typeof r=="number"||typeof r=="string"?c(r):typeof r=="object"?["top","right","bottom","left"].forEach(l=>{r[l]===void 0?n[`${i}-${l}`]=a:n[`${i}-${l}`]=typeof r[l]=="number"?`${r[l]}px`:r[l]}):c(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:c,mobileOffset:l,theme:d="light",richColors:f,duration:m,style:p,visibleToasts:v=tN,toastOptions:g,dir:x=sx(),gap:y=sN,loadingIcon:b,icons:T,containerAriaLabel:E="Notifications",pauseWhenPageIsHidden:S}=e,[C,k]=w.useState([]),A=w.useMemo(()=>Array.from(new Set([r].concat(C.filter(M=>M.position).map(M=>M.position)))),[C,r]),[P,L]=w.useState([]),[F,K]=w.useState(!1),[J,_]=w.useState(!1),[Y,q]=w.useState(d!=="system"?d:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),W=w.useRef(null),D=o.join("+").replace(/Key/g,"").replace(/Digit/g,""),I=w.useRef(null),G=w.useRef(!1),X=w.useCallback(M=>{k(B=>{var R;return(R=B.find($=>$.id===M.id))!=null&&R.delete||Vt.dismiss(M.id),B.filter(({id:$})=>$!==M.id)})},[]);return w.useEffect(()=>Vt.subscribe(M=>{if(M.dismiss){k(B=>B.map(R=>R.id===M.id?{...R,delete:!0}:R));return}setTimeout(()=>{Lo.flushSync(()=>{k(B=>{let R=B.findIndex($=>$.id===M.id);return R!==-1?[...B.slice(0,R),{...B[R],...M},...B.slice(R+1)]:[M,...B]})})})}),[]),w.useEffect(()=>{if(d!=="system"){q(d);return}if(d==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?q("dark"):q("light")),typeof window>"u")return;let M=window.matchMedia("(prefers-color-scheme: dark)");try{M.addEventListener("change",({matches:B})=>{q(B?"dark":"light")})}catch{M.addListener(({matches:R})=>{try{q(R?"dark":"light")}catch($){console.error($)}})}},[d]),w.useEffect(()=>{C.length<=1&&K(!1)},[C]),w.useEffect(()=>{let M=B=>{var R,$;o.every(z=>B[z]||B.code===z)&&(K(!0),(R=W.current)==null||R.focus()),B.code==="Escape"&&(document.activeElement===W.current||($=W.current)!=null&&$.contains(document.activeElement))&&K(!1)};return document.addEventListener("keydown",M),()=>document.removeEventListener("keydown",M)},[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":`${E} ${D}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},A.map((M,B)=>{var R;let[$,z]=M.split("-");return C.length?w.createElement("ol",{key:M,dir:x==="auto"?sx():x,tabIndex:-1,ref:W,className:a,"data-sonner-toaster":!0,"data-theme":Y,"data-y-position":$,"data-lifted":F&&C.length>1&&!s,"data-x-position":z,style:{"--front-toast-height":`${((R=P[0])==null?void 0:R.height)||0}px`,"--width":`${oN}px`,"--gap":`${y}px`,...p,...uN(c,l)},onBlur:O=>{G.current&&!O.currentTarget.contains(O.relatedTarget)&&(G.current=!1,I.current&&(I.current.focus({preventScroll:!0}),I.current=null))},onFocus:O=>{O.target instanceof HTMLElement&&O.target.dataset.dismissible==="false"||G.current||(G.current=!0,I.current=O.relatedTarget)},onMouseEnter:()=>K(!0),onMouseMove:()=>K(!0),onMouseLeave:()=>{J||K(!1)},onDragEnd:()=>K(!1),onPointerDown:O=>{O.target instanceof HTMLElement&&O.target.dataset.dismissible==="false"||_(!0)},onPointerUp:()=>_(!1)},C.filter(O=>!O.position&&B===0||O.position===M).map((O,j)=>{var U,Q;return w.createElement(cN,{key:O.id,icons:T,index:j,toast:O,defaultRichColors:f,duration:(U=g==null?void 0:g.duration)!=null?U:m,className:g==null?void 0:g.className,descriptionClassName:g==null?void 0:g.descriptionClassName,invert:n,visibleToasts:v,closeButton:(Q=g==null?void 0:g.closeButton)!=null?Q:i,interacting:J,position:M,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:X,toasts:C.filter(se=>se.position==O.position),heights:P.filter(se=>se.position==O.position),setHeights:L,expandByDefault:s,gap:y,loadingIcon:b,expanded:F,pauseWhenPageIsHidden:S,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=Gv,H.ApiClient=qv,H.ApiProvider=au,H.ArtifactRenderer=Ah,H.Badge=Fh,H.Button=Je,H.Card=dl,H.CardContent=ei,H.CardDescription=hl,H.CardHeader=fl,H.CardTitle=pl,H.ChatApi=Jo,H.ChatApp=Kk,H.ChatInput=Yf,H.ChatInputRow=Xf,H.ChatInterface=Lr,H.ChatProviders=Sr,H.ChatWidget=Yk,H.Command=kl,H.CommandEmpty=Nl,H.CommandGroup=Al,H.CommandInput=El,H.CommandItem=jl,H.CommandList=Il,H.DEFAULT_TIMEOUT_MS=tu,H.Dialog=sl,H.DialogContent=Ws,H.DialogHeader=Vs,H.DialogTitle=Ks,H.DropdownMenu=Es,H.DropdownMenuContent=xo,H.DropdownMenuItem=Fn,H.DropdownMenuTrigger=Is,H.FileViewerModal=hh,H.HISTORY_TIMEOUT_MS=nu,H.Input=Ll,H.InterruptPartRenderer=ml,H.Label=wm,H.MarkdownContent=cr,H.MessageComponent=ti,H.MessageList=vl,H.MessageRow=xl,H.NewChatButton=Xk,H.PlotArtifact=Nh,H.SETTINGS_STORAGE_KEY=Wi,H.ScrollArea=Dl,H.Select=AE,H.SelectContent=ig,H.SelectItem=ag,H.SelectTrigger=rg,H.SelectValue=jE,H.Separator=dg,H.Sheet=zE,H.SheetContent=bg,H.SheetDescription=Cg,H.SheetHeader=yg,H.SheetTitle=Sg,H.SheetTrigger=HE,H.SimpleChat=qk,H.SimpleJsonView=Qs,H.Sonner=fN,H.StreamProgress=jh,H.Switch=vg,H.Textarea=ja,H.ThinkingIndicator=_h,H.ThreadListItem=pm,H.ThreadManager=ai,H.ThreadStateProvider=Pu,H.ThreadsProvider=vu,H.TimelineColumn=Tx,H.Toaster=MI,H.ToolComponent=Lh,H.Tooltip=dI,H.TooltipContent=_g,H.TooltipProvider=uI,H.TooltipTrigger=fI,H.UserTextContent=Rh,H.applySettings=jw,H.buildCheckpointIndex=oc,H.buildCheckpointPreviewMap=fx,H.chatApiClient=Nn,H.del=Di,H.downloadFileById=ou,H.extractConfigFields=Si,H.fileToBase64=lu,H.get=Yt,H.getChatToken=Qc,H.getCheckpointForMessage=px,H.getCurrentSettings=Aw,H.getDefaultApiConfig=Bu,H.getDefaultChatSettings=zu,H.getFileContent=$i,H.getFileInfo=Xv,H.getMessageAttemptInfo=sc,H.getMessageDomKey=gl,H.getPreviewForMessage=yi,H.httpClient=Gt,H.hydrateHistorySnapshots=Yn,H.isEnvelope=uu,H.listFiles=su,H.loadStoredSettings=Hu,H.onChatTokenChanged=eu,H.post=Xo,H.processAttachments=cu,H.put=ru,H.readNumber=ac,H.readString=Rn,H.resolveChatBaseUrl=vn,H.saveSettings=Uu,H.setChatToken=Yo,H.toPlainObject=_n,H.unwrap=Dt,H.useApi=eo,H.useCheckpointIndex=ic,H.useFilePreview=Mh,H.useHasChatSession=Ew,H.useParsedMessageContent=Oh,H.useShallowStableValue=Du,H.useStream=Ui,H.useStreamingHook=Ui,H.useThreadHistoryState=Iu,H.useThreadManagerViewState=gm,H.useThreadState=oo,H.useThreadStateUpdater=ju,H.useThreads=vr,H.useThreadsState=gu,H.viewFileById=Yv,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=Ph(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=Ph(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 Oh{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 Dh{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||dr,this.options.renderer=this.options.renderer||new hl,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new Oh,this.slugger=new Dh}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,c,l,d,f,m,p,v,g,x,y,b,T,E,S,C;const k=t.length;for(o=0;o<k;o++){if(p=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[p.type]&&(C=this.options.extensions.renderers[p.type].call({parser:this},p),C!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(p.type))){r+=C||"";continue}switch(p.type){case"space":continue;case"hr":{r+=this.renderer.hr();continue}case"heading":{r+=this.renderer.heading(this.parseInline(p.tokens),p.depth,Ah(this.parseInline(p.tokens,this.textRenderer)),this.slugger);continue}case"code":{r+=this.renderer.code(p.text,p.lang,p.escaped);continue}case"table":{for(f="",d="",a=p.header.length,s=0;s<a;s++)d+=this.renderer.tablecell(this.parseInline(p.header[s].tokens),{header:!0,align:p.align[s]});for(f+=this.renderer.tablerow(d),m="",a=p.rows.length,s=0;s<a;s++){for(l=p.rows[s],d="",c=l.length,i=0;i<c;i++)d+=this.renderer.tablecell(this.parseInline(l[i].tokens),{header:!1,align:p.align[i]});m+=this.renderer.tablerow(d)}r+=this.renderer.table(f,m);continue}case"blockquote":{m=this.parse(p.tokens),r+=this.renderer.blockquote(m);continue}case"list":{for(v=p.ordered,g=p.start,x=p.loose,a=p.items.length,m="",s=0;s<a;s++)b=p.items[s],T=b.checked,E=b.task,y="",b.task&&(S=this.renderer.checkbox(T),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,E,T);r+=this.renderer.list(m,v,g);continue}case"html":{r+=this.renderer.html(p.text);continue}case"paragraph":{r+=this.renderer.paragraph(this.parseInline(p.tokens));continue}case"text":{for(m=p.tokens?this.parseInline(p.tokens):p.text;o+1<k&&t[o+1].type==="text";)p=t[++o],m+=`
127
+ `+(p.tokens?this.parseInline(p.tokens):p.text);r+=n?this.renderer.paragraph(m):m;continue}default:{const A='Token with "'+p.type+'" type was not found.';if(this.options.silent){console.error(A);return}else throw new Error(A)}}}return r}parseInline(t,n){n=n||this.renderer;let r="",o,s,i;const a=t.length;for(o=0;o<a;o++){if(s=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[s.type]&&(i=this.options.extensions.renderers[s.type].call({parser:this},s),i!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type))){r+=i||"";continue}switch(s.type){case"escape":{r+=n.text(s.text);break}case"html":{r+=n.html(s.text);break}case"link":{r+=n.link(s.href,s.title,this.parseInline(s.tokens,n));break}case"image":{r+=n.image(s.href,s.title,s.text);break}case"strong":{r+=n.strong(this.parseInline(s.tokens,n));break}case"em":{r+=n.em(this.parseInline(s.tokens,n));break}case"codespan":{r+=n.codespan(s.text);break}case"br":{r+=n.br();break}case"del":{r+=n.del(this.parseInline(s.tokens,n));break}case"text":{r+=n.text(s.text);break}default:{const c='Token with "'+s.type+'" type was not found.';if(this.options.silent){console.error(c);return}else throw new Error(c)}}}return r}}class Qs{constructor(t){this.options=t||dr}preprocess(t){return t}postprocess(t){return t}}xx(Qs,"passThroughHooks",new Set(["preprocess","postprocess"]));function UT(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>"+Ot(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 Lh(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...me.defaults,...s};const i=UT(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(BT(r),r.hooks&&(r.hooks.options=r),o){const a=r.highlight;let c;try{r.hooks&&(n=r.hooks.preprocess(n)),c=e(n,r)}catch(f){return i(f)}const l=function(f){let m;if(!f)try{r.walkTokens&&me.walkTokens(c,r.walkTokens),m=t(c,r),r.hooks&&(m=r.hooks.postprocess(m))}catch(p){f=p}return r.highlight=a,f?i(f):o(null,m)};if(!a||a.length<3||(delete r.highlight,!c.length))return l();let d=0;me.walkTokens(c,function(f){f.type==="code"&&(d++,setTimeout(()=>{a(f.text,f.lang,function(m,p){if(m)return l(m);p!=null&&p!==f.text&&(f.text=p,f.escaped=!0),d--,d===0&&l()})},0))}),d===0&&l();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(me.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&&me.walkTokens(a,r.walkTokens);let c=t(a,r);return r.hooks&&(c=r.hooks.postprocess(c)),c}catch(a){return i(a)}}}function me(e,t,n){return Lh(Wn.lex,Vn.parse)(e,t,n)}me.options=me.setOptions=function(e){return me.defaults={...me.defaults,...e},IT(me.defaults),me},me.getDefaults=kh,me.defaults=dr,me.use=function(...e){const t=me.defaults.extensions||{renderers:{},childTokens:{}};e.forEach(n=>{const r={...n};if(r.async=me.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=me.defaults.renderer||new hl;for(const s in n.renderer){const i=o[s];o[s]=(...a)=>{let c=n.renderer[s].apply(o,a);return c===!1&&(c=i.apply(o,a)),c}}r.renderer=o}if(n.tokenizer){const o=me.defaults.tokenizer||new pl;for(const s in n.tokenizer){const i=o[s];o[s]=(...a)=>{let c=n.tokenizer[s].apply(o,a);return c===!1&&(c=i.apply(o,a)),c}}r.tokenizer=o}if(n.hooks){const o=me.defaults.hooks||new Qs;for(const s in n.hooks){const i=o[s];Qs.passThroughHooks.has(s)?o[s]=a=>{if(me.defaults.async)return Promise.resolve(n.hooks[s].call(o,a)).then(l=>i.call(o,l));const c=n.hooks[s].call(o,a);return i.call(o,c)}:o[s]=(...a)=>{let c=n.hooks[s].apply(o,a);return c===!1&&(c=i.apply(o,a)),c}}r.hooks=o}if(n.walkTokens){const o=me.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}}me.setOptions(r)})},me.walkTokens=function(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(me,r)),r.type){case"table":{for(const o of r.header)n=n.concat(me.walkTokens(o.tokens,t));for(const o of r.rows)for(const s of o)n=n.concat(me.walkTokens(s.tokens,t));break}case"list":{n=n.concat(me.walkTokens(r.items,t));break}default:me.defaults.extensions&&me.defaults.extensions.childTokens&&me.defaults.extensions.childTokens[r.type]?me.defaults.extensions.childTokens[r.type].forEach(function(o){n=n.concat(me.walkTokens(r[o],t))}):r.tokens&&(n=n.concat(me.walkTokens(r.tokens,t)))}return n},me.parseInline=Lh(Wn.lexInline,Vn.parseInline),me.Parser=Vn,me.parser=Vn.parse,me.Renderer=hl,me.TextRenderer=Oh,me.Lexer=Wn,me.lexer=Wn.lex,me.Tokenizer=pl,me.Slugger=Dh,me.Hooks=Qs,me.parse=me,me.options,me.setOptions,me.use,me.walkTokens,me.parseInline,Vn.parse,Wn.lex;function fr({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 me.parse=="function"?me.parse(i):me(i)}return typeof me.parse=="function"?me.parse(e):me(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 $h({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 Fh({artifact:e,idx:t=0}){const n=w.useMemo(()=>e?(Array.isArray(e.plots)?e.plots:[]).map(o=>ju(o)).filter(o=>o!==null):[],[e]);return n.length>0?u.jsx("div",{className:"space-y-2",children:n.map((r,o)=>u.jsx($h,{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 WT="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 ei({data:e}){return Array.isArray(e)?e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?u.jsx("div",{className:WT,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:er(e)}):u.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:er(e)})}function Bh({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,c)=>{var l;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:((l=a.type)==null?void 0:l.replace(/\./g," "))??"progress"}),u.jsx("span",{children:a.idx??c+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}-${c}`)})})]}):null}const ml=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}));ml.displayName="Card";const gl=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:ne("flex flex-col space-y-1.5 p-6",e),...t}));gl.displayName="CardHeader";const xl=h.forwardRef(({className:e,...t},n)=>u.jsx("h3",{ref:n,className:ne("text-2xl font-semibold leading-none tracking-tight",e),...t}));xl.displayName="CardTitle";const vl=h.forwardRef(({className:e,...t},n)=>u.jsx("p",{ref:n,className:ne("text-sm text-muted-foreground",e),...t}));vl.displayName="CardDescription";const ti=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:ne("p-6 pt-0",e),...t}));ti.displayName="CardContent";const zh=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:ne("flex items-center p-6 pt-0",e),...t}));zh.displayName="CardFooter";const VT=e=>!!e&&typeof e=="object"&&e.type==="user_choice"&&typeof e.question=="string"&&Array.isArray(e.alternatives);function wl({interruptPart:e,onApprove:t,onReject:n,onSelectAlternative:r,disabled:o,isActive:s,payload:i}){const a=VT(i)?i:null,c=(a==null?void 0:a.question)??e.title??"Approve the result?",l=a?s?"Select one of the alternatives to continue.":"Waiting for approval from another participant.":s?"Please approve or reject this action to resume the workflow.":"Waiting for approval from another participant.";let d=null;if(!a&&i!==void 0&&i!==null)if(typeof i=="string")d=u.jsx("p",{className:"text-sm leading-relaxed text-blue-800/90 dark:text-blue-200/90 whitespace-pre-wrap",children:i});else{const f=er(i);d=u.jsx("pre",{className:"max-h-48 overflow-auto rounded bg-blue-100/60 p-2 text-xs text-blue-900/90 dark:bg-blue-900/40 dark:text-blue-100/80",children:f})}return u.jsxs(ml,{className:ne("border-blue-200 dark:border-blue-800 bg-blue-50/50 dark:bg-blue-950/10 transition-shadow",s?"shadow-md ring-1 ring-blue-300 dark:ring-blue-500/70":"opacity-80"),children:[u.jsxs(gl,{className:"pb-3",children:[u.jsx(xl,{className:"text-blue-900 dark:text-blue-100 text-base",children:c}),u.jsx(vl,{className:"text-blue-700 dark:text-blue-300 text-sm",children:l})]}),a?u.jsx(ti,{className:"pt-0 pb-3",children:u.jsx("div",{className:"space-y-2",children:a.alternatives.map(f=>u.jsx(Je,{size:"sm",variant:"outline",onClick:()=>r==null?void 0:r(e,f),className:"w-full justify-start text-left",disabled:o||!s,children:u.jsxs("div",{className:"flex flex-col items-start gap-1",children:[u.jsx("span",{className:"font-semibold",children:f.label}),f.description?u.jsx("span",{className:"text-xs text-muted-foreground leading-snug",children:f.description}):null]})},f.id))})}):d&&u.jsx(ti,{className:"pt-0 pb-3",children:d}),!a&&u.jsx(zh,{className:"pt-0",children:u.jsxs("div",{className:"flex gap-2 ml-auto",children:[u.jsx(Je,{size:"sm",variant:"outline",onClick:()=>n(e),className:"border-red-300 text-red-700 hover:bg-red-50 dark:border-red-700 dark:text-red-300 dark:hover:bg-red-950/50",disabled:o||!s,children:"Reject"}),u.jsx(Je,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",disabled:o||!s,children:"Approve"})]})})]})}function Hh({className:e}){const t=w.useRef(null);return w.useEffect(()=>{let n=0;const r=()=>{if(n=(n+1)%4,t.current){const s=".".repeat(n);t.current.textContent=`Is thinking${s}`}};r();const o=setInterval(r,500);return()=>clearInterval(o)},[]),u.jsx("span",{ref:t,"aria-live":"polite",className:ne("inline-block text-xs opacity-70 ml-1",e),children:"Is thinking"})}function Uh({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(fr,{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(Je,{type:"button",variant:"ghost",size:"sm",className:"h-6 text-xs !text-[hsl(var(--chat-bubble-user-text))]",onClick:()=>n(!t),children:t?u.jsxs(u.Fragment,{children:[u.jsx(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 Wh(e){const{allowFileOpen:t,currentThreadId:n}=e,{toast:r}=fl(),[o,s]=w.useState({}),[i,a]=w.useState(null),[c,l]=w.useState(!1),d=w.useCallback(()=>{l(!1),a(null)},[]),f=w.useCallback(p=>{a(p),l(!0)},[]),m=w.useCallback(async(p,v,g)=>{var x,y;if(!t){p.preventDefault();return}if(o[g]){p.preventDefault();return}try{const b=String(v.url??""),T=b.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);if(T){p.preventDefault();const E=T[1],S=v.name||`file_${E}`,C=v.mimeType||"application/octet-stream";f({id:E,name:S,mimeType:C});return}if(b.startsWith("data:")){p.preventDefault(),s(S=>({...S,[g]:!0}));const E=r({title:"Fetching file...",description:"",open:!0});try{const S=await cu(n??void 0);if(!S||!Array.isArray(S))throw new Error("Invalid file list response");const C=S.find(k=>!k||typeof k!="object"||!((k.filename??"")===(v.name??""))?!1:typeof v.size=="number"&&typeof k.size=="number"?k.size===v.size:!0);if(!(C!=null&&C.id))throw new Error(`File "${v.name}" is not yet available on the server`);if(!C.id||!C.filename)throw new Error("Invalid file data received from server");f({id:C.id,name:v.name||C.filename||`file_${C.id}`,mimeType:v.mimeType||C.mime_type||"application/octet-stream"}),(x=E.update)==null||x.call(E,{id:E.id,title:"Success",description:`Opened ${v.name}`,open:!0})}catch(S){console.error("Failed to fetch server file:",S);const C=S instanceof Error?S.message:"Unknown error occurred";(y=E.update)==null||y.call(E,{id:E.id,title:"Failed",description:C}),r({title:"Failed to fetch file",description:C,open:!0})}finally{s(S=>({...S,[g]:!1}))}}}catch(b){console.error("File click error:",b),s(T=>({...T,[g]:!1}))}},[t,o,r,n,f]);return{uploadingFiles:o,handleFileClick:m,fileViewerOpen:c,currentFileInfo:i,closeFileViewer:d}}function Vh(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:ku(r),toolMeta:Qo(n),imageParts:r.filter(s=>s.type==="image_url"),fileParts:r.filter(s=>s.type==="file"),interruptParts:r.filter(s=>s.type==="interrupt"),toolRaw:Eu(r),isToolStreaming:!!o.toolStreaming}},[e,t])}const Kh="data:";function KT(e){if(!e)return[];const t=[],n=e.split(/\r?\n/);for(const r of n){const o=r.trim();if(!o||!o.startsWith(Kh))continue;const s=o.slice(Kh.length).trim();if(!s||s.toLowerCase()==="[done]")continue;const i=Qn(s);i&&typeof i=="object"&&t.push(i)}return t}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(l=>l.type==="text");if(!t.length)return null;let r=t.flatMap(l=>KT(l.text??""));if(!r.length){const l=t.map(f=>f.text??"").join(`
129
+ `),d=Qn(l);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=Cr(i),c=tr(a);return c&&typeof c=="object"&&!Array.isArray(c)?{kind:"dict",value:c,data:c,event:s}:{kind:"generic",value:c,event:s}},[e])}function qh({message:e,viewMode:t,isStreaming:n=!1,toolRenderers:r,toolArtifactRenderers:o}){var S;const s=Qo(e),i=e.artifact??null,a=GT(e),l=(a?_u(a):null)??a,d=e.content.find(C=>C.type!=="tool_call"),f=C=>{if(C==null)return null;const k=typeof C=="string"?Qn(C)??C:C;if(k&&typeof k=="object")return u.jsx(ei,{data:k});const A=typeof k=="string"?k:(()=>{try{return er(k)}catch{return String(k??"")}})();return u.jsx("pre",{className:"whitespace-pre-wrap break-words font-sans text-sm text-foreground/90",children:A})},m=C=>{if(C==null)return null;const{content:k,isMarkdown:A}=Tu(C);return A?u.jsx(fr,{content:k,className:"text-current"}):f(C)},p=C=>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(ei,{data:C})]}),v=()=>{if((l==null?void 0:l.kind)==="generic")return m(l.value);if(!d)return null;if(d.type==="text"){const j=(d.text??"").trim();if(!j)return null;const L=tr(j);return m(L)}const C=Sr(d),k=tr(C);return m(k)},g=()=>(l==null?void 0:l.kind)==="dict"?p(l.data):v(),y=(()=>{if(!r)return;if(s.name){const k=r[s.name];if(k)return k}const C=(l==null?void 0:l.kind)??(a==null?void 0:a.kind);if(C){const k=r[C];if(k)return k}return r.default})(),b=(y==null?void 0:y({message:e,toolMeta:s,toolPayload:l,viewMode:t,isStreaming:n}))??null,E=((S=(()=>{if(!o)return;const C=i==null?void 0:i.type;if(typeof C=="string"){const k=o[C];if(k)return k}return o.default})())==null?void 0:S({artifact:i,message:e,toolPayload:l,isStreaming:n}))??null;return u.jsxs("div",{className:"space-y-2",children:[i&&(E??u.jsx(Fh,{artifact:i,idx:0})),u.jsx(Bh,{message:e,isStreaming:n}),t==="expanded"&&u.jsx(u.Fragment,{children:b??g()})]})}const YT={checkpoints:[],checkpointMetaByCheckpointId:new Map,timeline:[],messagePreviews:new Map,getLatest:()=>{},getCheckpoint:()=>{},getMessageAttempts:()=>[]},bl=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,yl=w.memo(function({message:t,index:n,isStreaming:r,streamingAssistantId:o,streamingDebounceMs:s,layoutSize:i,enableMessageEditing:a,editingMessageId:c,onEdit:l,onRegenerate:d,onCancelEdit:f,showToolMessages:m,checkpointIndex:p,onSelectCheckpoint:v,getMessageCustomStyles:g,getInterruptOptions:x,toolRenderers:y,toolArtifactRenderers:b}){const T=bl(t,n),E=t.role==="default_message",C=!!t.__syntheticStreaming,k=p??YT,A=!E&&"checkpointId"in t?t.checkpointId??null:null,{attemptCount:j,attemptIndex:L,attempts:B}=w.useMemo(()=>cc(t.id,A,k),[t.id,A,k]),K=g==null?void 0:g(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(ni,{message:t,messageIndex:n,isStreamingMessage:C||r&&o===t.id&&t.role==="assistant",streamingDebounceMs:s,isEditing:c===t.id,showActions:a,showTimestamp:!1,showAgentName:!0,layoutSize:i,onEdit:l,onRegenerate:()=>d(n),onCancelEdit:f,getInterruptOptions:x,showToolMessages:m,attemptCount:j,attemptIndex:L,attemptMetas:B,onSelectCheckpoint:v,customStyles:K,toolRenderers:y,toolArtifactRenderers:b})})});yl.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,c)=>{if(a.type!=="text")return s.current[c]=void 0,a;const l=a.text??"",d=s.current[c];return n(l)?(s.current[c]=l,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:c,interruptPart:l,isStreamingMessage:d,enableStreamingMarkdownBuffer:f,renderStreamingMarkdown:m,defaultMessage:p,handleFileClick:v,uploadingFiles:g,messageRole:x,truncateUserMessages:y,userMessagePreviewLength:b,isUserExpanded:T,setIsUserExpanded:E,isCompactLayout:S,iconForeground:C,toolRenderers:k,toolArtifactRenderers:A,handleInterruptApprove:j,handleInterruptReject:L,handleInterruptAlternative:B,disableInterruptActions:K,isInterruptMessage:J}){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"})]}),[]),q=XT(s,(f??!0)&&d,Gh),W=w.useMemo(()=>q.filter(H=>H.type==="text"),[q]),D=w.useMemo(()=>W.map(H=>H.text??"").join(""),[W]),I=w.useMemo(()=>{if(!m)return null;const H=ZT(D);return{stablePart:D.slice(0,H),tailPart:D.slice(H)}},[D,m]),G=w.useMemo(()=>{if(!I)return null;const{stablePart:H,tailPart:O}=I;return!H&&!O?null:u.jsxs("div",{className:"space-y-2",children:[H?u.jsx(fr,{content:H,allowHtml:!1}):null,O?u.jsx(fr,{content:O,allowHtml:!1}):null]})},[I]),X=w.useMemo(()=>{if(!m)return q;const H=[];let O=!1;for(const P of q){if(P.type==="text"){O||(H.push({type:"text",text:"",__streamingMarkdownAggregate:!0}),O=!0);continue}H.push(P)}return H},[q,m]),z=(m?X:q).filter(H=>H.type!=="interrupt"),R=w.useCallback(({part:H,i:O})=>{if(H.type==="text"){if(m)return null;const P=H.text??"",U=P.trim(),Q=Qn(U);return Q&&x!=="tool"?u.jsx(ei,{data:Q},O):x==="user"&&y&&U.length>b?u.jsx(Uh,{text:U,expanded:T,onExpandedChange:E,previewLength:b,isCompact:S},O):u.jsx(fr,{content:P,allowHtml:!1},O)}if(H.type==="image_url"){const P=H;return u.jsx("div",{className:"my-2",children:u.jsx("img",{src:P.url,alt:P.alt??"",loading:"lazy",className:"border rounded max-h-[420px] w-auto object-contain"})},O)}if(H.type==="file"){const P=H,U=P.name||"file";return u.jsxs("a",{href:P.url,onClick:Q=>v(Q,P,O),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[O]?u.jsx(le.Loader,{className:"h-4 w-4 animate-spin"}):null,u.jsxs("span",{className:"truncate max-w-[180px]",children:[U,g[O]?" (processing)":""]})]},O)}return null},[v,S,T,x,y,g,b,m,E]),F=i.trim().length>0||a.length>0||c.length>0||z.length>0;if(!t&&c.length>0&&!d)return _();if(!t&&!F&&!d)return null;if(t){if(!n)return null;if(J&&l){const H=l.value,O=!K,P=j??(()=>{}),U=L??(()=>{});return u.jsx(wl,{interruptPart:l,payload:H,onApprove:P,onReject:U,onSelectAlternative:B,disabled:K,isActive:O})}return u.jsx(qh,{message:e,viewMode:r,isStreaming:o,toolRenderers:k,toolArtifactRenderers:A},e.id)}if(!p){const H=u.jsx("div",{className:"space-y-2",children:z.map((O,P)=>m&&QT(O)?G?u.jsx("div",{className:"space-y-2",children:G},`streaming-md-${P}`):null:u.jsx(R,{part:O,i:P},P))});return d?u.jsxs("div",{"aria-busy":"true",role:"status",children:[H,u.jsx(Hh,{className:C})]}):H}return null}function Gh(e){return e?!(jo(e,/```/g)||jo(e,/`/g)||jo(e,/\*\*/g)||jo(e,/__/g)||jo(e,/~~/g)||/[^\\]\[[^\]]*$/.test(e)||/\[[^\]]*\]\([^)]*$/.test(e)):!0}function jo(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(Gh(e.slice(0,t)))return t;return 0}function QT(e){return e.type==="text"&&!!e.__streamingMarkdownAggregate}const ek=Kr.cva("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function Yh({className:e,variant:t,...n}){return u.jsx("div",{className:ne(ek({variant:t}),e),...n})}function tk({showTimestamp:e,showAgentName:t,isToolMessage:n,isInterruptMessage:r=!1,iconForeground:o,agentName:s,messageIcon:i,customHeaderClass:a,customActionsClass:c,isCompactLayout:l,showActions:d,isEditing:f,messageRole:m,toolViewMode:p,toolMeta:v,onToggleToolView:g,onCopy:x,onEdit:y,onRegenerate:b,showCheckpointControls:T,attemptCount:E,attemptIndex:S,handleOlderAttemptSelect:C,handleNewerAttemptSelect:k,messageCreatedAt:A,copied:j}){return!e&&!t&&!n&&!r?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",o,a),children:[u.jsxs("div",{className:"flex items-center gap-2",children:[i,t&&s&&u.jsx("span",{className:ne("font-medium",l?"text-xs":"text-sm"),children:s}),n&&!r&&u.jsxs(Yh,{variant:"outline",className:ne("text-xs flex items-center gap-1 cursor-pointer select-none",o,"border border-current/40",l&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":p==="expanded",onClick:g,onKeyDown:L=>{(L.key==="Enter"||L.key===" ")&&(L.preventDefault(),g())},children:[u.jsx("span",{children:v.name??"Tool Output"}),v.toolCallId&&u.jsx("span",{className:"opacity-70",children:v.toolCallId.slice(0,8)}),p==="expanded"?u.jsx(le.ChevronUp,{className:"h-3 w-3"}):u.jsx(le.ChevronDown,{className:"h-3 w-3"})]}),r&&u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:v.name??"Interrupt"})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[T&&E>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",S<E-1?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{S>=E-1||C()},"aria-label":"Older attempt (back in time)",disabled:S>=E-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:[E-S," / ",E]})}),u.jsx("button",{type:"button",className:ne("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",S>0?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{S<=0||k()},"aria-label":"Newer attempt (forward in time)",disabled:S<=0,children:u.jsx(le.ChevronRight,{className:"h-3 w-3"})})]}),e&&A&&u.jsx("time",{className:ne("text-xs opacity-60",o,l&&"text-xs"),dateTime:new Date(A).toISOString(),title:new Date(A).toLocaleString(),children:new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(new Date(A))}),d&&!f&&u.jsxs("div",{className:ne("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",c),children:[u.jsx("div",{className:"relative",children:u.jsx(Je,{variant:"ghost",size:"sm",onClick:x,className:ne("h-6 w-6 p-0 hover:bg-foreground/10",o,l&&"h-5 w-5"),"aria-label":"Copy message",title:"Copy message",children:u.jsx(le.Copy,{className:ne(j?"text-success":o,l?"h-3 w-3":"h-4 w-4")})})}),m==="user"&&y&&u.jsx(Je,{variant:"ghost",size:"sm",onClick:y,className:ne("h-6 w-6 p-0 hover:bg-foreground/10",o,l&&"h-5 w-5"),"aria-label":"Edit message",children:u.jsx(le.Edit,{className:ne(o,l?"h-3 w-3":"h-4 w-4")})}),m==="assistant"&&b&&u.jsx(Je,{variant:"ghost",size:"sm",onClick:b,className:ne("h-6 w-6 p-0 hover:bg-foreground/10",o,l&&"h-5 w-5"),"aria-label":"Regenerate response",children:u.jsx(le.RotateCcw,{className:ne(o,l?"h-3 w-3":"h-4 w-4")})})]})]})]})}const ni=w.memo(function({message:t,messageIndex:n,isStreamingMessage:r=!1,isEditing:o=!1,showActions:s=!0,showTimestamp:i=!0,showAgentName:a=!0,layoutSize:c="desktop",truncateUserMessages:l=!0,userMessagePreviewLength:d=500,showToolMessages:f=!0,toolRenderers:m,toolArtifactRenderers:p,customStyles:v={},streamingDebounceMs:g=300,renderStreamingMarkdown:x=!1,enableStreamingMarkdownBuffer:y,onEdit:b,onRegenerate:T,onCopy:E,getInterruptOptions:S,attemptCount:C=1,attemptIndex:k=0,onSelectCheckpoint:A,attemptMetas:j=[]}){const[L,B]=w.useState(!1),[K,J]=w.useState("preview"),[_,Y]=w.useState(!1),{currentThreadId:q}=yr(),{respondToInterrupt:W}=oo(),[D,I]=w.useState(!1),G=c==="phone"||c==="half-screen",X=t.role,M=X==="interrupt",z=X==="tool"||M,F=!(t.role==="default_message")&&t.expandable!==void 0?t.expandable!==!1:!0,H=w.useMemo(()=>t.role==="default_message"?t:null,[t]),O=!!H,P=!(r&&X!=="user"),{uploadingFiles:U,handleFileClick:Q,fileViewerOpen:se,currentFileInfo:ie,closeFileViewer:Se}=Wh({allowFileOpen:P,currentThreadId:q}),xe=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"interrupt":return"text-[hsl(var(--chat-bubble-ai-text))]";case"tool":return"text-secondary-foreground";case"system":return"text-muted-foreground";default:return"text-[hsl(var(--chat-bubble-ai-text))]"}},[X]),Re=Vh(t,H),{contentParts:Ve,imageParts:De,fileParts:Ge,textContent:He,toolMeta:ot,toolRaw:ut,isToolStreaming:nt,interruptParts:Le}=Re,Ke=y??g!==0,$e=w.useMemo(()=>Le.length?Le[0]:null,[Le]),Te=w.useCallback(async()=>{const Pe=z?ut:He;async function Ye(we){if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function"){await navigator.clipboard.writeText(we);return}if(navigator.clipboard&&typeof navigator.clipboard.write=="function"&&typeof ClipboardItem<"u"){const Qe=new Blob([we],{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 Ye(Pe),B(!0),setTimeout(()=>B(!1),2e3),E==null||E(Pe)}catch(we){console.error("Failed to copy:",we)}},[z,ut,He,E]),Ae=w.useCallback(async(Pe,Ye)=>{if(!$e)return;if(!Hi($e.id)){console.warn("Interrupt part missing id",$e);return}I(!0);try{const Qe=S==null?void 0:S(t);await W(Pe,Ye,Qe)}catch(Qe){console.error("Failed to respond to interrupt:",Qe)}finally{I(!1)}},[$e,W]),dt=w.useCallback(()=>Ae(!0),[Ae]),Et=w.useCallback(()=>Ae(!1),[Ae]),at=w.useCallback((Pe,Ye)=>{if(!Ye)return;const we={alternativeId:Ye.id??Ye.label??void 0,alternativeLabel:Ye.label};Ae(!0,we)},[Ae]),It=w.useCallback(()=>{if(!b||!t.id)return;const Pe=(z?ut:He)??"",Ye="type"in t&&t.type==="default_message"?void 0:{checkpointId:t.checkpointId??null,checkpointNs:t.checkpointNs??null};b(t.id,Pe,Ye)},[b,z,ut,He,t]),bt=w.useCallback(()=>{T==null||T(n)},[T,n]),ft=!M&&F,Nt=w.useCallback(()=>{ft&&J(Pe=>Pe==="expanded"?"preview":"expanded")},[ft]),Ct=M?"expanded":K,on=w.useCallback(()=>{const Ye=ne(G?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",xe);switch(X){case"user":return u.jsx(le.User,{className:Ye});case"assistant":return u.jsx(le.Bot,{className:Ye});case"tool":return u.jsx(le.Wrench,{className:Ye});case"interrupt":return u.jsx(le.Bot,{className:Ye});default:return u.jsx(le.Bot,{className:Ye})}},[G,xe,X]),Tt=w.useCallback(()=>{const Pe="group relative mb-4 flex w-full";switch(X){case"user":return ne(Pe,"justify-end");case"assistant":case"tool":case"system":case"interrupt":return ne(Pe,"justify-start");default:return Pe}},[X]),Ie=w.useCallback(()=>{const Pe=ne("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",G&&"px-3 py-2 text-sm");if(O)return ne(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(X){case"user":return ne(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 ne(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":case"interrupt":return ne(Pe,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return ne(Pe,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return ne(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")}},[G,O,X]),Ue=(f||M)&&F,Pt=u.jsx(JT,{message:t,isToolMessage:z,showToolMessages:Ue,toolViewMode:Ct,isToolStreaming:nt,contentParts:Ve,textContent:He,imageParts:De,fileParts:Ge,isStreamingMessage:r,defaultMessage:H,enableStreamingMarkdownBuffer:Ke,renderStreamingMarkdown:x,handleFileClick:Q,uploadingFiles:U,messageRole:X,truncateUserMessages:l,userMessagePreviewLength:d,isUserExpanded:_,setIsUserExpanded:Y,isCompactLayout:G,iconForeground:xe,toolRenderers:m,toolArtifactRenderers:p,interruptPart:$e,handleInterruptApprove:dt,handleInterruptReject:Et,handleInterruptAlternative:at,disableInterruptActions:D,isInterruptMessage:M}),te=w.useMemo(()=>H?"Assistant":Iu(t),[H,t]),ge=on(),rt=X==="user"&&(C??1)>1&&typeof A=="function",fe=(j==null?void 0:j.length)??0,ke=fe>0&&k<fe-1?j[k+1]:void 0,Fe=fe>0&&k>0?j[k-1]:void 0,ht=w.useCallback(()=>{!ke||!A||A(ke.id,void 0,!!ke.isLatestAttempt)},[ke,A]),pt=w.useCallback(()=>{!Fe||!A||A(Fe.id,void 0,!!Fe.isLatestAttempt)},[Fe,A]);return z&&!f?null:O&&H?u.jsx("div",{className:ne(Tt(),v.container),children:u.jsxs("div",{className:ne(Ie(),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:ne("h-4 w-4",xe)}),a&&u.jsx("span",{className:"font-medium text-sm",children:"Assistant"})]}),u.jsx(fr,{content:H.content,className:"text-current"})]})}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:ne(Tt(),v.container),children:u.jsxs("div",{className:ne(Ie(),v.content),children:[u.jsx(tk,{showTimestamp:i,showAgentName:a,isToolMessage:z,iconForeground:xe,agentName:te,messageIcon:ge,customHeaderClass:v.header,customActionsClass:v.actions,isCompactLayout:G,showActions:s,isEditing:o,messageRole:X,toolViewMode:Ct,isInterruptMessage:M,toolMeta:ot,onToggleToolView:Nt,onCopy:Te,onEdit:It,onRegenerate:bt,showCheckpointControls:rt,attemptCount:C,attemptIndex:k,handleOlderAttemptSelect:ht,handleNewerAttemptSelect:pt,messageCreatedAt:t.createdAt,copied:L}),u.jsx("div",{className:"relative",children:Pt}),z&&Ct==="expanded"&&(ot.toolCallId||ot.name)&&u.jsxs("div",{className:ne("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",G&&"text-xs"),children:[ot.name&&u.jsxs("div",{children:["Function: ",ot.name]}),ot.toolCallId&&u.jsxs("div",{children:["Call ID: ",ot.toolCallId]})]}),!(i||a||z)&&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",v.actions),children:[u.jsx(Je,{variant:"ghost",size:"sm",onClick:()=>Te(),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(L?"text-success":"text-current",G?"h-3 w-3":"h-4 w-4")})}),X==="user"&&b&&u.jsx(Je,{variant:"ghost",size:"sm",onClick:It,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"&&T&&u.jsx(Je,{variant:"ghost",size:"sm",onClick:bt,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")})})]})]})}),ie&&u.jsx(Th,{isOpen:se,onClose:Se,fileId:ie.id,fileName:ie.name,mimeType:ie.mimeType})]})},(e,t)=>{var c,l,d,f,m,p,v,g;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&Ui(e.message)===Ui(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateUserMessages","userMessagePreviewLength","showToolMessages","toolRenderers","toolArtifactRenderers"].every(x=>e[x]===t[x]),s=((c=e.customStyles)==null?void 0:c.container)===((l=t.customStyles)==null?void 0:l.container)&&((d=e.customStyles)==null?void 0:d.content)===((f=t.customStyles)==null?void 0:f.content)&&((m=e.customStyles)==null?void 0:m.actions)===((p=t.customStyles)==null?void 0:p.actions)&&((v=e.customStyles)==null?void 0:v.header)===((g=t.customStyles)==null?void 0:g.header);if(!o||!s)return!1;const i=Wi(e.message),a=Wi(t.message);return i.length===a.length});ni.displayName="MessageComponent";const Sl=w.forwardRef(({messages:e,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onStartReached:a,onEdit:c,onRegenerate:l,onCancelEdit:d,className:f,style:m,emptyMessage:p,followNewMessages:v=!0,isNavigatingCheckpoint:g=!1,onScrollAway:x,onAtBottom:y,showToolMessages:b=!0,toolRenderers:T,toolArtifactRenderers:E,checkpointIndex:S,activeCheckpointId:C,onSelectCheckpoint:k,createSyntheticThinkingMessage:A=!0,forceSyntheticThinking:j=!1,getMessageCustomStyles:L,getInterruptOptions:B},K)=>{const J=w.useRef(null),_=w.useRef(null),Y=w.useRef(!1),q=w.useRef(!1),W=e,D=w.useMemo(()=>{const P=n&&W.some(Q=>Q.id===n);return A&&(t||j)&&!P&&W.length>0?[...W,{id:"thinking-assistant",role:"assistant",content:[{type:"text",text:""}],createdAt:new Date().toISOString(),__syntheticStreaming:!0}]:W},[W,t,n,A,j]),I=w.useMemo(()=>b?D:D.filter(P=>(P==null?void 0:P.role)!=="tool"),[D,b]),G=w.useCallback(P=>{x&&x(!P),y&&y(P)},[x,y]),X=w.useMemo(()=>{if(a)return async()=>{if(!Y.current){Y.current=!0;try{await a()}finally{Y.current=!1}}}},[a]),M=w.useMemo(()=>!v||g?!1:"auto",[v,g]),z=w.useMemo(()=>{if(typeof p!="string")return null;const P=p.trim();return!P||I&&I.length>0?null:{id:"default-message",role:"default_message",content:P,createdAt:new Date().toISOString()}},[p,I]),R=["flex h-full flex-col md:flex-row",f].filter(Boolean).join(" "),F=()=>{if(z){const P=L==null?void 0:L(z);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(ni,{message:z,messageIndex:0,isStreamingMessage:!1,showActions:!1,showTimestamp:!1,showAgentName:!0,layoutSize:o,onEdit:()=>{},onRegenerate:()=>{},onCancelEdit:()=>{},customStyles:P,getInterruptOptions:B})})})}return u.jsx("div",{className:"flex h-full items-center justify-center py-8 text-center text-muted-foreground",children:p??"No messages yet. Start a conversation!"})},H=I.length,O=H>0;return w.useEffect(()=>{var P,U;if(H===0){q.current=!1;return}if(!q.current)if(q.current=!0,J.current&&I.length>0){const Q=I.length-1;(U=(P=J.current).scrollToIndex)==null||U.call(P,{index:Q,align:"end",behavior:"auto"})}else _.current&&(_.current.scrollTop=_.current.scrollHeight)},[H,I.length]),w.useImperativeHandle(K,()=>({scrollToLatest:()=>{var P,U;if(J.current&&I.length>0){const Q=I.length-1;(U=(P=J.current).scrollToIndex)==null||U.call(P,{index:Q,align:"end",behavior:"auto"})}else _.current&&(_.current.scrollTop=_.current.scrollHeight)},scrollToTop:()=>{var P,U;J.current&&I.length>0?(U=(P=J.current).scrollToIndex)==null||U.call(P,{index:0,align:"start",behavior:"auto"}):_.current&&(_.current.scrollTop=0)}}),[I]),u.jsx("div",{className:R,style:m,children:u.jsx("div",{className:"relative flex-1 min-h-0",children:O?u.jsx(YC,{ref:P=>{J.current=P},scrollerRef:P=>{_.current=P instanceof HTMLDivElement?P:null},data:I,followOutput:M,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,startReached:()=>{X&&X()},atBottomStateChange:G,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(P,U)=>bl(U,P),itemContent:(P,U)=>u.jsx(yl,{message:U,index:P,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onEdit:c,onRegenerate:l,onCancelEdit:d,showToolMessages:b,toolRenderers:T,toolArtifactRenderers:E,checkpointIndex:S,activeCheckpointId:C,onSelectCheckpoint:k,getMessageCustomStyles:L,getInterruptOptions:B})}):F()})})});Sl.displayName="MessageList";const Xh={value:""};function Fr({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:c=!1,enableMessageEditing:l=!0,showToolMessages:d=!0,toolRenderers:f,toolArtifactRenderers:m,payloadExtras:p={},customStyles:v={},messageCustomStyles:g,onMessageSent:x,onExcelUploadSuccess:y,onError:b,defaultMessage:T}){const{api:E}=no(),S=E.baseUrl,{currentThreadId:C}=yr(),{threadId:k,messages:A,isLoading:j,navigateToCheckpoint:L,returnToLatest:B,checkpoint:K,checkpoints:J,interrupt:_,metadata:Y,checkpointIndex:q,respondToInterrupt:W}=oo(),{isStreaming:D,error:I,connectionState:G,submit:X,stop:M}=qi(),z=k??C??null,R=(K==null?void 0:K.id)??null,F=(K==null?void 0:K.namespace)??null,H=(Y==null?void 0:Y.assemblingMessageId)??null,O=_,P=O?Hi(O.id):null,U=P!==null?{type:"interrupt",id:P}:null,[Q,se]=w.useState(!1),[ie,Se]=w.useState(!1);w.useEffect(()=>{O||se(!1)},[O]);const xe=w.useCallback(()=>{se(!0)},[]),Re=w.useCallback(()=>{se(!1)},[]),Ve=w.useCallback(N=>{},[]),De=w.useCallback(async(N,Z,re)=>{try{xe(),await W(N,Z,re)}catch(de){console.error("Failed to respond to interrupt:",de)}finally{Re()}},[Re,xe,W]),Ge=w.useCallback(()=>De(!0),[De]),He=w.useCallback(()=>De(!1),[De]),ot=w.useCallback((N,Z)=>De(!0,Z),[De]),ut=!!O||Q,[nt,Le]=w.useState(null),[Ke,$e]=w.useState(""),[Te,Ae]=w.useState(null),[dt,Et]=w.useState(null),[at,It]=w.useState(!1),[bt,ft]=w.useState(null),Nt=w.useRef(!1),[At,Ct]=w.useState(()=>Xh.value),on=w.useRef(At),Tt=w.useRef(null),Ie=w.useCallback(N=>{Xh.value=N,Ct(N)},[]),[Ue,Pt]=w.useState(!1),te=w.useRef(null),ge=w.useCallback(N=>{Ie(N)},[Ie]);w.useEffect(()=>{D||Se(!1)},[D]),w.useEffect(()=>{Y!=null&&Y.assemblingMessageId&&Se(!1)},[Y==null?void 0:Y.assemblingMessageId]);const[rt,fe]=w.useState("desktop");w.useEffect(()=>{const N=()=>{const Z=window.innerWidth;fe(Z<640?"phone":Z<1024?"tablet":"desktop")};return N(),window.addEventListener("resize",N),()=>window.removeEventListener("resize",N)},[]),w.useEffect(()=>{Nt.current=!1},[z]),w.useEffect(()=>{on.current=At},[At]),w.useEffect(()=>{if(!nt){Tt.current=null;return}Tt.current===null&&(Tt.current=on.current),Ie(Ke??"")},[Ke,nt,Ie]),w.useEffect(()=>{if(T!==void 0){ft(T);return}(async()=>{if(!S){ft(null);return}try{const re=(await E.getAgent("default")).uiDefaultMessage||"";ft(re||null)}catch(Z){console.warn("Failed to fetch default message:",Z),ft(null)}})()},[E,S,T]),w.useEffect(()=>{I&&!at&&(b==null||b(I))},[I,at,b]);const ke=async(N,Z)=>{const re=N.trim();if(!(!re&&Z.length===0))try{const de=nt?(Te==null?void 0:Te.checkpointId)??R??void 0:R??void 0,Me=nt?(Te==null?void 0:Te.checkpointNs)??F??void 0:F??void 0;await X({text:re||"",attachments:Z,payload:p},{checkpointId:de,checkpointNs:Me,edit:!!nt,originalMessageId:nt??void 0}),x==null||x(re),Se(!0),Ie(""),Et(null),Le(null),$e(""),Ae(null)}catch(de){const Me=(de==null?void 0:de.message)||"Failed to send message";Et(Me),b==null||b(Me),Se(!1)}},Fe=w.useCallback(async N=>{await X({attachments:[N],payload:p},{checkpointId:R??void 0,checkpointNs:F??void 0}),y==null||y({file:N})},[R,F,p,y,X]),ht=w.useCallback((N,Z,re)=>{l&&(Tt.current=At,Le(N),$e(Z),Ie(Z),Et(null),Ae({checkpointId:(re==null?void 0:re.checkpointId)??null,checkpointNs:(re==null?void 0:re.checkpointNs)??null}))},[At,l,Ie]),pt=w.useCallback(()=>{Le(null),$e(""),Ae(null),Et(null),Ie(Tt.current??At),Tt.current=null},[At,Ie]),Pe=w.useCallback((N,Z,re)=>{ht(N,Z,re)},[ht]),Ye=w.useCallback(N=>{let Z=null;for(let Oe=N-1;Oe>=0;Oe--)if(A[Oe].role==="user"){Z=A[Oe];break}if(!Z)return;const re=Array.isArray(Z.content)?Z.content:[],Me=re.filter(Oe=>(Oe==null?void 0:Oe.type)==="text").map(Oe=>Oe.text).join("")||(()=>{try{return JSON.stringify(re,null,2)}catch{return String(re)}})();Me&&X({text:Me,payload:p},{checkpointId:R??void 0,checkpointNs:F??void 0,edit:!0,originalMessageId:Z.id})},[A,X,R,F,p]),we=w.useCallback(async N=>{if(C){Pt(!0);try{if(!N){await B(),requestAnimationFrame(()=>{var de;(de=te.current)==null||de.scrollToLatest()});return}const Z=J.find(de=>de.checkpointId===N),re=(Z==null?void 0:Z.checkpointNs)??null;await L(N,re),requestAnimationFrame(()=>{var de;(de=te.current)==null||de.scrollToTop()})}finally{Pt(!1)}}},[J,C,te,L,B]),Qe=w.useCallback(async(N,Z,re)=>{await we(re?null:N)},[we]),Xe=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${v.container||""}`,ct=`flex-1 min-h-0 min-w-0 max-h-full w-full overflow-hidden overscroll-contain break-words break-anywhere p-4 ${O?"pb-32":""} bg-transparent ${v.messagesArea||""}`,sn=`relative flex-shrink-0 w-full border-t p-4 bg-transparent ${v.inputArea||""}`;return u.jsxs("div",{className:Xe,children:[!!I&&!at&&u.jsxs("div",{className:"flex-shrink-0 bg-red-50 border border-red-200 text-red-800 px-4 py-2 text-sm flex items-center justify-between",children:[u.jsx("span",{children:I}),u.jsx(Je,{variant:"ghost",size:"sm",onClick:()=>It(!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 ${ct}`,style:r?{maxHeight:r}:void 0,children:[u.jsx(Sl,{ref:te,className:"h-full",style:{height:"100%"},messages:A,isStreaming:D,streamingAssistantId:H,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:rt,enableMessageEditing:l,editingMessageId:nt,onEdit:Pe,onRegenerate:Ye,onCancelEdit:pt,emptyMessage:bt??void 0,isNavigatingCheckpoint:Ue,showToolMessages:d,toolRenderers:f,toolArtifactRenderers:m,checkpointIndex:q,activeCheckpointId:R,onSelectCheckpoint:Qe,createSyntheticThinkingMessage:!0,forceSyntheticThinking:ie,getMessageCustomStyles:g,getInterruptOptions:Ve}),(G==="reconnecting"||G==="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"}),G==="reconnecting"?"Reconnecting…":"Connecting…"]})}),G==="error"&&u.jsx("div",{className:"pointer-events-none absolute top-3 right-3 z-20 rounded-full bg-destructive/10 px-3 py-1 text-xs font-semibold text-destructive shadow-sm",children:"Connection lost"}),j&&u.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 bg-background/80 backdrop-blur-sm text-muted-foreground",children:[u.jsx(le.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading messages…"})]}),Ue&&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…"})]}),O&&U&&u.jsx("div",{className:"pointer-events-auto absolute inset-x-0 bottom-6 z-30 flex justify-center px-4",children:u.jsx("div",{className:"w-full max-w-3xl",children:u.jsx(wl,{interruptPart:U,onApprove:Ge,onReject:He,onSelectAlternative:ot,disabled:Q,isActive:!0,payload:O.value})})})]}),u.jsxs("div",{className:sn,children:[nt&&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(Je,{variant:"ghost",size:"sm",onClick:pt,className:"text-blue-600 hover:bg-blue-100",children:u.jsx(le.X,{size:16})})]})}),dt&&u.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:dt}),u.jsx(FS,{composerValue:At,onComposerChange:ge,onSend:ke,onCancelEdit:pt,onStop:M,editingMessageId:nt,editingInitialValue:Ke,placeholder:nt?"Edit your message...":t,isStreaming:D,disabled:ut,enableFileUpload:a,enableExcelUpload:c,onExcelUpload:Fe,onError:b,customStyles:v,textareaClassName:v.textarea||"",allowEmptySend:!1,inputError:dt})]})]})}var Jh=1,nk=.9,rk=.8,ok=.17,Cl=.1,Tl=.999,sk=.9999,ik=.99,ak=/[\\\/_+.#"@\[\(\{&]/,lk=/[\\\/_+.#"@\[\(\{&]/g,ck=/[\s-]/,Zh=/[\s-]/g;function kl(e,t,n,r,o,s,i){if(s===t.length)return o===e.length?Jh:ik;var a=`${o},${s}`;if(i[a]!==void 0)return i[a];for(var c=r.charAt(s),l=n.indexOf(c,o),d=0,f,m,p,v;l>=0;)f=kl(e,t,n,r,l+1,s+1,i),f>d&&(l===o?f*=Jh:ak.test(e.charAt(l-1))?(f*=rk,p=e.slice(o,l-1).match(lk),p&&o>0&&(f*=Math.pow(Tl,p.length))):ck.test(e.charAt(l-1))?(f*=nk,v=e.slice(o,l-1).match(Zh),v&&o>0&&(f*=Math.pow(Tl,v.length))):(f*=ok,o>0&&(f*=Math.pow(Tl,l-o))),e.charAt(l)!==t.charAt(s)&&(f*=sk)),(f<Cl&&n.charAt(l-1)===r.charAt(s+1)||r.charAt(s+1)===r.charAt(s)&&n.charAt(l-1)!==r.charAt(s))&&(m=kl(e,t,n,r,l+1,s+2,i),m*Cl>f&&(f=m*Cl)),f>d&&(d=f),l=n.indexOf(c,l+1);return i[a]=d,d}function Qh(e){return e.toLowerCase().replace(Zh," ")}function uk(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,kl(e,t,Qh(e),Qh(t),0,0,{})}var _o='[cmdk-group=""]',El='[cmdk-group-items=""]',dk='[cmdk-group-heading=""]',em='[cmdk-item=""]',tm=`${em}:not([aria-disabled="true"])`,Il="cmdk-item-select",Br="data-value",fk=(e,t,n)=>uk(e,t,n),nm=h.createContext(void 0),Ro=()=>h.useContext(nm),rm=h.createContext(void 0),Nl=()=>h.useContext(rm),om=h.createContext(void 0),sm=h.forwardRef((e,t)=>{let n=zr(()=>{var M,z;return{search:"",value:(z=(M=e.value)!=null?M:e.defaultValue)!=null?z:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=zr(()=>new Set),o=zr(()=>new Map),s=zr(()=>new Map),i=zr(()=>new Set),a=im(e),{label:c,children:l,value:d,onValueChange:f,filter:m,shouldFilter:p,loop:v,disablePointerSelection:g=!1,vimBindings:x=!0,...y}=e,b=_t(),T=_t(),E=_t(),S=h.useRef(null),C=Ck();pr(()=>{if(d!==void 0){let M=d.trim();n.current.value=M,k.emit()}},[d]),pr(()=>{C(6,J)},[]);let k=h.useMemo(()=>({subscribe:M=>(i.current.add(M),()=>i.current.delete(M)),snapshot:()=>n.current,setState:(M,z,R)=>{var F,H,O,P;if(!Object.is(n.current[M],z)){if(n.current[M]=z,M==="search")K(),L(),C(1,B);else if(M==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let U=document.getElementById(E);U?U.focus():(F=document.getElementById(b))==null||F.focus()}if(C(7,()=>{var U;n.current.selectedItemId=(U=_())==null?void 0:U.id,k.emit()}),R||C(5,J),((H=a.current)==null?void 0:H.value)!==void 0){let U=z??"";(P=(O=a.current).onValueChange)==null||P.call(O,U);return}}k.emit()}},emit:()=>{i.current.forEach(M=>M())}}),[]),A=h.useMemo(()=>({value:(M,z,R)=>{var F;z!==((F=s.current.get(M))==null?void 0:F.value)&&(s.current.set(M,{value:z,keywords:R}),n.current.filtered.items.set(M,j(z,R)),C(2,()=>{L(),k.emit()}))},item:(M,z)=>(r.current.add(M),z&&(o.current.has(z)?o.current.get(z).add(M):o.current.set(z,new Set([M]))),C(3,()=>{K(),L(),n.current.value||B(),k.emit()}),()=>{s.current.delete(M),r.current.delete(M),n.current.filtered.items.delete(M);let R=_();C(4,()=>{K(),(R==null?void 0:R.getAttribute("id"))===M&&B(),k.emit()})}),group:M=>(o.current.has(M)||o.current.set(M,new Set),()=>{s.current.delete(M),o.current.delete(M)}),filter:()=>a.current.shouldFilter,label:c||e["aria-label"],getDisablePointerSelection:()=>a.current.disablePointerSelection,listId:b,inputId:E,labelId:T,listInnerRef:S}),[]);function j(M,z){var R,F;let H=(F=(R=a.current)==null?void 0:R.filter)!=null?F:fk;return M?H(M,n.current.search,z):0}function L(){if(!n.current.search||a.current.shouldFilter===!1)return;let M=n.current.filtered.items,z=[];n.current.filtered.groups.forEach(F=>{let H=o.current.get(F),O=0;H.forEach(P=>{let U=M.get(P);O=Math.max(U,O)}),z.push([F,O])});let R=S.current;Y().sort((F,H)=>{var O,P;let U=F.getAttribute("id"),Q=H.getAttribute("id");return((O=M.get(Q))!=null?O:0)-((P=M.get(U))!=null?P:0)}).forEach(F=>{let H=F.closest(El);H?H.appendChild(F.parentElement===H?F:F.closest(`${El} > *`)):R.appendChild(F.parentElement===R?F:F.closest(`${El} > *`))}),z.sort((F,H)=>H[1]-F[1]).forEach(F=>{var H;let O=(H=S.current)==null?void 0:H.querySelector(`${_o}[${Br}="${encodeURIComponent(F[0])}"]`);O==null||O.parentElement.appendChild(O)})}function B(){let M=Y().find(R=>R.getAttribute("aria-disabled")!=="true"),z=M==null?void 0:M.getAttribute(Br);k.setState("value",z||void 0)}function K(){var M,z,R,F;if(!n.current.search||a.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let H=0;for(let O of r.current){let P=(z=(M=s.current.get(O))==null?void 0:M.value)!=null?z:"",U=(F=(R=s.current.get(O))==null?void 0:R.keywords)!=null?F:[],Q=j(P,U);n.current.filtered.items.set(O,Q),Q>0&&H++}for(let[O,P]of o.current)for(let U of P)if(n.current.filtered.items.get(U)>0){n.current.filtered.groups.add(O);break}n.current.filtered.count=H}function J(){var M,z,R;let F=_();F&&(((M=F.parentElement)==null?void 0:M.firstChild)===F&&((R=(z=F.closest(_o))==null?void 0:z.querySelector(dk))==null||R.scrollIntoView({block:"nearest"})),F.scrollIntoView({block:"nearest"}))}function _(){var M;return(M=S.current)==null?void 0:M.querySelector(`${em}[aria-selected="true"]`)}function Y(){var M;return Array.from(((M=S.current)==null?void 0:M.querySelectorAll(tm))||[])}function q(M){let z=Y()[M];z&&k.setState("value",z.getAttribute(Br))}function W(M){var z;let R=_(),F=Y(),H=F.findIndex(P=>P===R),O=F[H+M];(z=a.current)!=null&&z.loop&&(O=H+M<0?F[F.length-1]:H+M===F.length?F[0]:F[H+M]),O&&k.setState("value",O.getAttribute(Br))}function D(M){let z=_(),R=z==null?void 0:z.closest(_o),F;for(;R&&!F;)R=M>0?yk(R,_o):Sk(R,_o),F=R==null?void 0:R.querySelector(tm);F?k.setState("value",F.getAttribute(Br)):W(M)}let I=()=>q(Y().length-1),G=M=>{M.preventDefault(),M.metaKey?I():M.altKey?D(1):W(1)},X=M=>{M.preventDefault(),M.metaKey?q(0):M.altKey?D(-1):W(-1)};return h.createElement(pe.div,{ref:t,tabIndex:-1,...y,"cmdk-root":"",onKeyDown:M=>{var z;(z=y.onKeyDown)==null||z.call(y,M);let R=M.nativeEvent.isComposing||M.keyCode===229;if(!(M.defaultPrevented||R))switch(M.key){case"n":case"j":{x&&M.ctrlKey&&G(M);break}case"ArrowDown":{G(M);break}case"p":case"k":{x&&M.ctrlKey&&X(M);break}case"ArrowUp":{X(M);break}case"Home":{M.preventDefault(),q(0);break}case"End":{M.preventDefault(),I();break}case"Enter":{M.preventDefault();let F=_();if(F){let H=new Event(Il);F.dispatchEvent(H)}}}}},h.createElement("label",{"cmdk-label":"",htmlFor:A.inputId,id:A.labelId,style:kk},c),ri(e,M=>h.createElement(rm.Provider,{value:k},h.createElement(nm.Provider,{value:A},M))))}),pk=h.forwardRef((e,t)=>{var n,r;let o=_t(),s=h.useRef(null),i=h.useContext(om),a=Ro(),c=im(e),l=(r=(n=c.current)==null?void 0:n.forceMount)!=null?r:i==null?void 0:i.forceMount;pr(()=>{if(!l)return a.item(o,i==null?void 0:i.id)},[l]);let d=am(o,s,[e.value,e.children,s],e.keywords),f=Nl(),m=Kn(C=>C.value&&C.value===d.current),p=Kn(C=>l||a.filter()===!1?!0:C.search?C.filtered.items.get(o)>0:!0);h.useEffect(()=>{let C=s.current;if(!(!C||e.disabled))return C.addEventListener(Il,v),()=>C.removeEventListener(Il,v)},[p,e.onSelect,e.disabled]);function v(){var C,k;g(),(k=(C=c.current).onSelect)==null||k.call(C,d.current)}function g(){f.setState("value",d.current,!0)}if(!p)return null;let{disabled:x,value:y,onSelect:b,forceMount:T,keywords:E,...S}=e;return h.createElement(pe.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)}),hk=h.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:o,...s}=e,i=_t(),a=h.useRef(null),c=h.useRef(null),l=_t(),d=Ro(),f=Kn(p=>o||d.filter()===!1?!0:p.search?p.filtered.groups.has(i):!0);pr(()=>d.group(i),[]),am(i,a,[e.value,e.heading,c]);let m=h.useMemo(()=>({id:i,forceMount:o}),[o]);return h.createElement(pe.div,{ref:Mn(a,t),...s,"cmdk-group":"",role:"presentation",hidden:f?void 0:!0},n&&h.createElement("div",{ref:c,"cmdk-group-heading":"","aria-hidden":!0,id:l},n),ri(e,p=>h.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?l:void 0},h.createElement(om.Provider,{value:m},p))))}),mk=h.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,o=h.useRef(null),s=Kn(i=>!i.search);return!n&&!s?null:h.createElement(pe.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=Nl(),i=Kn(l=>l.search),a=Kn(l=>l.selectedItemId),c=Ro();return h.useEffect(()=>{e.value!=null&&s.setState("search",e.value)},[e.value]),h.createElement(pe.input,{ref:t,...r,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":c.listId,"aria-labelledby":c.labelId,"aria-activedescendant":a,id:c.inputId,type:"text",value:o?e.value:i,onChange:l=>{o||s.setState("search",l.target.value),n==null||n(l.target.value)}})}),xk=h.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...o}=e,s=h.useRef(null),i=h.useRef(null),a=Kn(l=>l.selectedItemId),c=Ro();return h.useEffect(()=>{if(i.current&&s.current){let l=i.current,d=s.current,f,m=new ResizeObserver(()=>{f=requestAnimationFrame(()=>{let p=l.offsetHeight;d.style.setProperty("--cmdk-list-height",p.toFixed(1)+"px")})});return m.observe(l),()=>{cancelAnimationFrame(f),m.unobserve(l)}}},[]),h.createElement(pe.div,{ref:Mn(s,t),...o,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":a,"aria-label":r,id:c.listId},ri(e,l=>h.createElement("div",{ref:Mn(i,c.listInnerRef),"cmdk-list-sizer":""},l)))}),vk=h.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:o,contentClassName:s,container:i,...a}=e;return h.createElement(al,{open:n,onOpenChange:r},h.createElement(ll,{container:i},h.createElement(No,{"cmdk-overlay":"",className:o}),h.createElement(Ao,{"aria-label":e.label,"cmdk-dialog":"",className:s},h.createElement(sm,{ref:t,...a}))))}),wk=h.forwardRef((e,t)=>Kn(n=>n.filtered.count===0)?h.createElement(pe.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),bk=h.forwardRef((e,t)=>{let{progress:n,children:r,label:o="Loading...",...s}=e;return h.createElement(pe.div,{ref:t,...s,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":o},ri(e,i=>h.createElement("div",{"aria-hidden":!0},i)))}),Wt=Object.assign(sm,{List:xk,Item:pk,Input:gk,Group:hk,Separator:mk,Dialog:vk,Empty:wk,Loading:bk});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 im(e){let t=h.useRef(e);return pr(()=>{t.current=e}),t}var pr=typeof window>"u"?h.useEffect:h.useLayoutEffect;function zr(e){let t=h.useRef();return t.current===void 0&&(t.current=e()),t}function Kn(e){let t=Nl(),n=()=>e(t.snapshot());return h.useSyncExternalStore(t.subscribe,n,n)}function am(e,t,n,r=[]){let o=h.useRef(),s=Ro();return pr(()=>{var i;let a=(()=>{var l;for(let d of n){if(typeof d=="string")return d.trim();if(typeof d=="object"&&"current"in d)return d.current?(l=d.current.textContent)==null?void 0:l.trim():o.current}})(),c=r.map(l=>l.trim());s.value(e,a,c),(i=t.current)==null||i.setAttribute(Br,a),o.current=a}),o}var Ck=()=>{let[e,t]=h.useState(),n=zr(()=>new Map);return pr(()=>{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 ri({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 Al=h.forwardRef(({className:e,...t},n)=>u.jsx(Wt,{ref:n,className:ne("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));Al.displayName=Wt.displayName;const Pl=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(Wt.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})]}));Pl.displayName=Wt.Input.displayName;const jl=h.forwardRef(({className:e,...t},n)=>u.jsx(Wt.List,{ref:n,className:ne("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));jl.displayName=Wt.List.displayName;const _l=h.forwardRef((e,t)=>u.jsx(Wt.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));_l.displayName=Wt.Empty.displayName;const Rl=h.forwardRef(({className:e,...t},n)=>u.jsx(Wt.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}));Rl.displayName=Wt.Group.displayName;const Ek=h.forwardRef(({className:e,...t},n)=>u.jsx(Wt.Separator,{ref:n,className:ne("-mx-1 h-px bg-border",e),...t}));Ek.displayName=Wt.Separator.displayName;const Ml=h.forwardRef(({className:e,...t},n)=>u.jsx(Wt.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}));Ml.displayName=Wt.Item.displayName;function Ol(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 Dl="ScrollArea",[lm,WN]=cn(Dl),[Nk,rn]=lm(Dl),cm=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,c]=h.useState(null),[l,d]=h.useState(null),[f,m]=h.useState(null),[p,v]=h.useState(null),[g,x]=h.useState(null),[y,b]=h.useState(0),[T,E]=h.useState(0),[S,C]=h.useState(!1),[k,A]=h.useState(!1),j=je(t,B=>c(B)),L=ts(o);return u.jsx(Nk,{scope:n,type:r,dir:L,scrollHideDelay:s,scrollArea:a,viewport:l,onViewportChange:d,content:f,onContentChange:m,scrollbarX:p,onScrollbarXChange:v,scrollbarXEnabled:S,onScrollbarXEnabledChange:C,scrollbarY:g,onScrollbarYChange:x,scrollbarYEnabled:k,onScrollbarYEnabledChange:A,onCornerWidthChange:b,onCornerHeightChange:E,children:u.jsx(pe.div,{dir:L,...i,ref:j,style:{position:"relative","--radix-scroll-area-corner-width":y+"px","--radix-scroll-area-corner-height":T+"px",...e.style}})})});cm.displayName=Dl;var um="ScrollAreaViewport",dm=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=rn(um,n),a=h.useRef(null),c=je(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(pe.div,{"data-radix-scroll-area-viewport":"",...s,ref:c,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})})]})});dm.displayName=um;var In="ScrollAreaScrollbar",Ll=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=rn(In,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(Pk,{...r,ref:t,forceMount:n}):o.type==="auto"?u.jsx(fm,{...r,ref:t,forceMount:n}):o.type==="always"?u.jsx($l,{...r,ref:t}):null});Ll.displayName=In;var Ak=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=rn(In,e.__scopeScrollArea),[s,i]=h.useState(!1);return h.useEffect(()=>{const a=o.scrollArea;let c=0;if(a){const l=()=>{window.clearTimeout(c),i(!0)},d=()=>{c=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",l),a.addEventListener("pointerleave",d),()=>{window.clearTimeout(c),a.removeEventListener("pointerenter",l),a.removeEventListener("pointerleave",d)}}},[o.scrollArea,o.scrollHideDelay]),u.jsx(Ht,{present:n||s,children:u.jsx(fm,{"data-state":s?"visible":"hidden",...r,ref:t})})}),Pk=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=rn(In,e.__scopeScrollArea),s=e.orientation==="horizontal",i=ai(()=>c("SCROLL_END"),100),[a,c]=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 l=window.setTimeout(()=>c("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(l)}},[a,o.scrollHideDelay,c]),h.useEffect(()=>{const l=o.viewport,d=s?"scrollLeft":"scrollTop";if(l){let f=l[d];const m=()=>{const p=l[d];f!==p&&(c("SCROLL"),i()),f=p};return l.addEventListener("scroll",m),()=>l.removeEventListener("scroll",m)}},[o.viewport,s,c,i]),u.jsx(Ht,{present:n||a!=="hidden",children:u.jsx($l,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:ae(e.onPointerEnter,()=>c("POINTER_ENTER")),onPointerLeave:ae(e.onPointerLeave,()=>c("POINTER_LEAVE"))})})}),fm=h.forwardRef((e,t)=>{const n=rn(In,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=h.useState(!1),a=e.orientation==="horizontal",c=ai(()=>{if(n.viewport){const l=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?l:d)}},10);return Hr(n.viewport,c),Hr(n.content,c),u.jsx(Ht,{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=rn(In,e.__scopeScrollArea),s=h.useRef(null),i=h.useRef(0),[a,c]=h.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),l=xm(a.viewport,a.content),d={...r,sizes:a,onSizesChange:c,hasThumb:l>0&&l<1,onThumbChange:m=>s.current=m,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:m=>i.current=m};function f(m,p){return Dk(m,i.current,a,p)}return n==="horizontal"?u.jsx(jk,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollLeft,p=vm(m,a,o.dir);s.current.style.transform=`translate3d(${p}px, 0, 0)`}},onWheelScroll:m=>{o.viewport&&(o.viewport.scrollLeft=m)},onDragScroll:m=>{o.viewport&&(o.viewport.scrollLeft=f(m,o.dir))}}):n==="vertical"?u.jsx(_k,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollTop,p=vm(m,a);s.current.style.transform=`translate3d(0, ${p}px, 0)`}},onWheelScroll:m=>{o.viewport&&(o.viewport.scrollTop=m)},onDragScroll:m=>{o.viewport&&(o.viewport.scrollTop=f(m))}}):null}),jk=h.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=rn(In,e.__scopeScrollArea),[i,a]=h.useState(),c=h.useRef(null),l=je(t,c,s.onScrollbarXChange);return h.useEffect(()=>{c.current&&a(getComputedStyle(c.current))},[c]),u.jsx(hm,{"data-orientation":"horizontal",...o,ref:l,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":ii(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.x),onDragScroll:d=>e.onDragScroll(d.x),onWheelScroll:(d,f)=>{if(s.viewport){const m=s.viewport.scrollLeft+d.deltaX;e.onWheelScroll(m),bm(m,f)&&d.preventDefault()}},onResize:()=>{c.current&&s.viewport&&i&&r({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:si(i.paddingLeft),paddingEnd:si(i.paddingRight)}})}})}),_k=h.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=rn(In,e.__scopeScrollArea),[i,a]=h.useState(),c=h.useRef(null),l=je(t,c,s.onScrollbarYChange);return h.useEffect(()=>{c.current&&a(getComputedStyle(c.current))},[c]),u.jsx(hm,{"data-orientation":"vertical",...o,ref:l,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":ii(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.y),onDragScroll:d=>e.onDragScroll(d.y),onWheelScroll:(d,f)=>{if(s.viewport){const m=s.viewport.scrollTop+d.deltaY;e.onWheelScroll(m),bm(m,f)&&d.preventDefault()}},onResize:()=>{c.current&&s.viewport&&i&&r({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:si(i.paddingTop),paddingEnd:si(i.paddingBottom)}})}})}),[Rk,pm]=lm(In),hm=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:c,onDragScroll:l,onWheelScroll:d,onResize:f,...m}=e,p=rn(In,n),[v,g]=h.useState(null),x=je(t,j=>g(j)),y=h.useRef(null),b=h.useRef(""),T=p.viewport,E=r.content-r.viewport,S=gt(d),C=gt(c),k=ai(f,10);function A(j){if(y.current){const L=j.clientX-y.current.left,B=j.clientY-y.current.top;l({x:L,y:B})}}return h.useEffect(()=>{const j=L=>{const B=L.target;(v==null?void 0:v.contains(B))&&S(L,E)};return document.addEventListener("wheel",j,{passive:!1}),()=>document.removeEventListener("wheel",j,{passive:!1})},[T,v,E,S]),h.useEffect(C,[r,C]),Hr(v,k),Hr(p.content,k),u.jsx(Rk,{scope:n,scrollbar:v,hasThumb:o,onThumbChange:gt(s),onThumbPointerUp:gt(i),onThumbPositionChange:C,onThumbPointerDown:gt(a),children:u.jsx(pe.div,{...m,ref:x,style:{position:"absolute",...m.style},onPointerDown:ae(e.onPointerDown,j=>{j.button===0&&(j.target.setPointerCapture(j.pointerId),y.current=v.getBoundingClientRect(),b.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",p.viewport&&(p.viewport.style.scrollBehavior="auto"),A(j))}),onPointerMove:ae(e.onPointerMove,A),onPointerUp:ae(e.onPointerUp,j=>{const L=j.target;L.hasPointerCapture(j.pointerId)&&L.releasePointerCapture(j.pointerId),document.body.style.webkitUserSelect=b.current,p.viewport&&(p.viewport.style.scrollBehavior=""),y.current=null})})})}),oi="ScrollAreaThumb",mm=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=pm(oi,e.__scopeScrollArea);return u.jsx(Ht,{present:n||o.hasThumb,children:u.jsx(Mk,{ref:t,...r})})}),Mk=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=rn(oi,n),i=pm(oi,n),{onThumbPositionChange:a}=i,c=je(t,f=>i.onThumbChange(f)),l=h.useRef(void 0),d=ai(()=>{l.current&&(l.current(),l.current=void 0)},100);return h.useEffect(()=>{const f=s.viewport;if(f){const m=()=>{if(d(),!l.current){const p=Lk(f,a);l.current=p,a()}};return a(),f.addEventListener("scroll",m),()=>f.removeEventListener("scroll",m)}},[s.viewport,d,a]),u.jsx(pe.div,{"data-state":i.hasThumb?"visible":"hidden",...o,ref:c,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:ae(e.onPointerDownCapture,f=>{const p=f.target.getBoundingClientRect(),v=f.clientX-p.left,g=f.clientY-p.top;i.onThumbPointerDown({x:v,y:g})}),onPointerUp:ae(e.onPointerUp,i.onThumbPointerUp)})});mm.displayName=oi;var Fl="ScrollAreaCorner",gm=h.forwardRef((e,t)=>{const n=rn(Fl,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?u.jsx(Ok,{...e,ref:t}):null});gm.displayName=Fl;var Ok=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=rn(Fl,n),[s,i]=h.useState(0),[a,c]=h.useState(0),l=!!(s&&a);return Hr(o.scrollbarX,()=>{var f;const d=((f=o.scrollbarX)==null?void 0:f.offsetHeight)||0;o.onCornerHeightChange(d),c(d)}),Hr(o.scrollbarY,()=>{var f;const d=((f=o.scrollbarY)==null?void 0:f.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),l?u.jsx(pe.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 si(e){return e?parseInt(e,10):0}function xm(e,t){const n=e/t;return isNaN(n)?0:n}function ii(e){const t=xm(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=ii(n),s=o/2,i=t||s,a=o-i,c=n.scrollbar.paddingStart+i,l=n.scrollbar.size-n.scrollbar.paddingEnd-a,d=n.content-n.viewport,f=r==="ltr"?[0,d]:[d*-1,0];return wm([c,l],f)(e)}function vm(e,t,n="ltr"){const r=ii(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,s=t.scrollbar.size-o,i=t.content-t.viewport,a=s-r,c=n==="ltr"?[0,i]:[i*-1,0],l=Ol(e,c);return wm([0,i],[0,a])(l)}function wm(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function bm(e,t){return e>0&&e<t}var 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 ai(e,t){const n=gt(e),r=h.useRef(0);return h.useEffect(()=>()=>window.clearTimeout(r.current),[]),h.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function Hr(e,t){const n=gt(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 ym=cm,$k=dm,Fk=gm;const Bl=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(ym,{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(Sm,{}),u.jsx(Fk,{})]}));Bl.displayName=ym.displayName;const Sm=h.forwardRef(({className:e,orientation:t="vertical",...n},r)=>u.jsx(Ll,{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(mm,{className:"relative flex-1 rounded-full bg-border"})}));Sm.displayName=Ll.displayName;const zl=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}));zl.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 Cm({thread:e,isActive:t,editingThreadId:n,editingTitle:r,onSelect:o,onStartEditing:s,onEditingTitleChange:i,onSaveEditing:a,onCancelEditing:c,onShare:l,onDelete:d,showEditTitle:f,showDeleteButton:m,formatDate:p,getDisplayThreadTitle:v,secondaryLine:g,itemClassName:x,activeItemClassName:y}){const b=n===e.threadId,T=t?`${y??Hk}`:`${x??zk}`,E=S=>{S.stopPropagation(),o(e.threadId)};return u.jsxs("div",{onClick:E,className:`${Bk} ${T}`,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(zl,{value:r,onChange:S=>i(S.target.value),onKeyDown:S=>{S.key==="Enter"?a(e.threadId):S.key==="Escape"&&c()},className:"h-6 text-sm",autoFocus:!0}),u.jsx(Je,{variant:"ghost",size:"sm",onClick:()=>a(e.threadId),className:"h-6 w-6 p-0",children:u.jsx(le.Check,{size:12})}),u.jsx(Je,{variant:"ghost",size:"sm",onClick:c,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:p(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(Is,{children:[u.jsx(Ns,{asChild:!0,children:u.jsx(Je,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",children:u.jsx(le.MoreHorizontal,{size:12})})}),u.jsxs(xo,{align:"end",sideOffset:6,className:"w-44",children:[u.jsxs(Fn,{onClick:S=>{S.preventDefault(),l(e.threadId)},children:[u.jsx(le.Share2,{className:"mr-2 h-4 w-4"}),"Share thread"]}),f&&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 Tm=25,km="thread-manager-view",Uk=e=>e==="default"||e==="shared",Wk=()=>{if(typeof window>"u")return null;try{const e=window.localStorage.getItem(km);if(Uk(e))return e}catch{}return null};function Em({defaultView:e}={}){const[t,n]=w.useState(()=>Wk()??e??"default");w.useEffect(()=>{if(!(typeof window>"u"))try{window.localStorage.setItem(km,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 li({className:e="",showCreateButton:t=!0,showDeleteButton:n=!0,showEditTitle:r=!0,maxHeight:o="400px",customStyles:s={},currentThreadId:i=null,navigateToThread:a,onThreadSelect:c,onThreadCreate:l,onThreadDelete:d,view:f,defaultView:m,onViewChange:p,viewOptions:v,viewState:g,showHeader:x=!0,shareTargets:y,isLoadingShareTargets:b,shareTargetFilter:T}){const{threads:E,sharedThreads:S,currentThreadId:C,setCurrentThreadId:k,isLoading:A,isLoadingSharedThreads:j,actions:L,shareInFlight:B,shareStatus:K,clearShareStatus:J}=yr(),{createThread:_,deleteThread:Y,renameThread:q,shareThread:W}=L,{loadThread:D}=oo(),I=i??C,[G,X]=w.useState(Array.isArray(E)?E:[]),M=w.useRef(G.length>0),z=w.useRef(null),R=w.useRef(0),[F,H]=w.useState(null),[O,P]=w.useState(""),[U,Q]=w.useState(!1),[se,ie]=w.useState(!1),[Se,xe]=w.useState(null),[Re,Ve]=w.useState(""),De=v&&v.length>0?v:Vk,Ge=Em({defaultView:m}),He=g??Ge,ot=f??He.view,ut=w.useCallback(te=>{f||He.setView(te),p==null||p(te)},[f,p,He]),nt=De.find(te=>te.key===ot)??De[0],Le=te=>{xe(te),Ve(""),ie(!0)},Ke=()=>{ie(!1),xe(null),Ve(""),J()},$e=w.useCallback(async te=>{if(!(!Se||B)&&te.id)try{await W(Se,te.id),setTimeout(()=>Ke(),600)}catch(ge){console.error("Failed to share thread:",ge)}},[Ke,B,Se,W]),Te=w.useMemo(()=>{const te=y??[],ge=Re.trim().toLowerCase();return ge?T?te.filter(rt=>T(rt,ge)):te.filter(rt=>`${rt.label} ${rt.secondaryLabel??""}`.toLowerCase().includes(ge)):te},[y,Re,T]),Ae=ot==="shared",dt=Ae?S:G,Et=Ae?j:A,at=Ae?"No shared conversations yet":"No conversations yet",It=te=>{const ge=te.sharedAt?` • ${Ie(te.sharedAt)}`:"";return`Shared by ${te.sharedByUserId}${ge}`},bt=te=>"sharedByUserId"in te;w.useEffect(()=>{const te=Array.isArray(E)?E:[];if(te.length>0){M.current=!0,X(te);return}A||(M.current=!1,X(te))},[E,A]),w.useEffect(()=>{if(!z.current)return;const te=z.current.querySelector("[data-radix-scroll-area-viewport]");if(!te)return;let ge=null,rt=null;return ge=requestAnimationFrame(()=>{rt=requestAnimationFrame(()=>{te.scrollTop=R.current})}),()=>{ge!==null&&cancelAnimationFrame(ge),rt!==null&&cancelAnimationFrame(rt)}},[G]);const ft=async te=>{try{k(te),await D(te),a==null||a(te),c==null||c(te)}catch(ge){console.error("Failed to select thread:",ge)}},Nt=async()=>{try{Q(!0);const te=await _();te&&(l==null||l(te),a==null||a(te))}catch(te){console.error("Failed to create thread:",te)}finally{Q(!1)}},At=async(te,ge)=>{if(ge.stopPropagation(),!!confirm("Delete this thread?")){if(z.current){const rt=z.current.querySelector("[data-radix-scroll-area-viewport]");rt&&(R.current=rt.scrollTop)}try{await Y(te),d==null||d(te)}catch(rt){console.error("Failed to delete thread:",rt)}}},Ct=(te,ge)=>{ge.stopPropagation(),H(te.threadId),P(te.title||`Thread ${te.threadId.slice(0,8)}`)},on=async te=>{if(O.trim())try{await q(te,O.trim()),H(null),P("")}catch(ge){console.error("Failed to update title:",ge)}},Tt=()=>{H(null),P("")},Ie=te=>{if(!te)return"";try{const ge=new Date(te),fe=new Date().getTime()-ge.getTime(),ke=Math.floor(fe/(1e3*60*60*24));return ke===0?ge.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):ke===1?"Yesterday":ke<7?`${ke} days ago`:ge.toLocaleDateString()}catch{return""}},Ue=te=>te.title||`Thread ${te.threadId.slice(0,8)}`,Pt=te=>{const ge=Ue(te);return ge.length<=Tm?ge:`${ge.slice(0,Tm)}...`};return u.jsxs("div",{className:`flex flex-col h-full ${e} ${s.container||""}`,children:[x&&u.jsxs("div",{className:s.header||"flex flex-col gap-2 px-1 py-0 border border-slate-200 bg-white dark:border-slate-700 dark:bg-slate-900 shadow-sm",children:[t&&u.jsx("div",{className:"flex justify-end",children:u.jsxs(Je,{onClick:Nt,disabled:U||A,className:s.createButton||"px-3 py-2 gap-1",size:"sm",variant:"ghost",title:U?"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(Is,{children:[u.jsx(Ns,{asChild:!0,children:u.jsx(Je,{variant:"outline",size:"sm",className:"text-[11px] text-slate-700 dark:text-slate-200 border border-slate-300 dark:border-slate-600 bg-white dark:bg-slate-900 hover:bg-slate-50 dark:hover:bg-slate-800 px-2 py-0",children:nt.label})}),u.jsx(xo,{align:"start",sideOffset:6,className:"w-40",children:De.map(te=>u.jsxs(Fn,{className:"justify-between text-[12px]",onClick:ge=>{ge.preventDefault(),ut(te.key)},children:[u.jsx("span",{children:te.label}),ot===te.key&&u.jsx(le.Check,{className:"h-3 w-3"})]},te.key))})]})]})]}),u.jsx(Bl,{ref:z,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:Et?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…"})]}):dt.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:at})]}):dt.slice().sort((te,ge)=>new Date(ge.updatedAt||ge.createdAt||"").getTime()-new Date(te.updatedAt||te.createdAt||"").getTime()).map(te=>u.jsx(Cm,{thread:te,isActive:I===te.threadId,editingThreadId:F,editingTitle:O,onSelect:ft,onStartEditing:Ct,onEditingTitleChange:ge=>P(ge),onSaveEditing:on,onCancelEditing:Tt,onShare:()=>Le(te.threadId),onDelete:At,showEditTitle:r,showDeleteButton:n,formatDate:Ie,getDisplayThreadTitle:Pt,secondaryLine:Ae&&bt(te)?It(te):void 0,itemClassName:s.threadItem,activeItemClassName:s.activeThread},te.threadId))})}),u.jsx(cl,{open:se,onOpenChange:te=>!te&&Ke(),children:u.jsxs(Vs,{className:"max-w-md p-0",children:[u.jsx(Ks,{children:u.jsx(qs,{children:"Share thread"})}),u.jsxs(Al,{children:[u.jsx(Pl,{autoFocus:!0,value:Re,onValueChange:te=>Ve(te),placeholder:"Search for recipients..."}),u.jsxs(jl,{children:[K&&u.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-xs text-muted-foreground",children:[B&&u.jsx(le.Loader2,{className:"h-3 w-3 animate-spin"}),u.jsx("span",{className:K.startsWith("Failed")?"text-red-500":K.startsWith("Shared")?"text-emerald-500":"text-slate-600 dark:text-slate-400",children:K})]}),u.jsx(_l,{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"}),Te.length>0&&u.jsx(Rl,{heading:"Recipients",children:Te.map(te=>u.jsx(Ml,{onSelect:()=>$e(te),children:u.jsxs("div",{className:"flex flex-col items-start text-sm",children:[u.jsx("span",{className:"font-medium",children:te.label}),te.secondaryLabel&&u.jsx("span",{className:"text-xs text-muted-foreground",children:te.secondaryLabel})]})},te.id))})]})]})]})})]})}function Kk({layout:e="sidebar",layoutSize:t="desktop",showThreads:n=!0,className:r="",customStyles:o={},...s}){const i=l=>{const d="h-full";switch(l){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=l=>({"--chat-sidebar-width":l==="phone"?"100%":l==="tablet"?"280px":l==="half-screen"?"240px":"320px","--chat-message-max-width":l==="phone"?"95%":l==="tablet"?"90%":l==="half-screen"?"85%":"80%","--chat-input-height":l==="phone"?"120px":"100px"}),c=w.useCallback(l=>{var d;(d=s.onThreadChange)==null||d.call(s,l)},[s]);return e==="fullscreen"?u.jsx(Tr,{...s,onThreadChange:c,children:u.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:u.jsx(Fr,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?u.jsx(Tr,{...s,onThreadChange:c,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(li,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),u.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:u.jsx(Fr,{onError:s.onError,enableFileUpload:!0})})]})})}):u.jsx(Tr,{...s,onThreadChange:c,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(li,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),u.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:u.jsx(Fr,{onError:s.onError,enableFileUpload:!0})})]})})}function qk({apiConfig:e,className:t="",onError:n}){return u.jsx(Tr,{apiConfig:e,onError:n,children:u.jsx("div",{className:`h-full ${t}`,children:u.jsx(Fr,{})})})}function 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(Fr,{placeholder:e??"Ask Serti AI anything...",autoFocus:!0,className:"h-full",onMessageSent:t}):u.jsx(li,{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,c]=w.useState(!1);return n?u.jsx(Tr,{...i,children:u.jsx("div",{className:`fixed bottom-6 right-6 z-[9999] transition-all duration-300 ${e}`,children:u.jsxs("div",{className:`w-96 bg-white rounded-xl shadow-2xl border border-gray-200 overflow-hidden relative ${a?"scale-75":"scale-100"}`,children:[u.jsx("div",{className:"bg-slate-800 text-white p-4 flex-shrink-0",children:u.jsxs("div",{className:"flex items-center justify-between gap-3",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsxs("div",{className:"relative h-10 w-10 rounded-full bg-gradient-to-br from-slate-500 to-slate-700 border border-white/30 flex items-center justify-center text-white text-sm font-bold",children:["S",u.jsx("span",{className:"absolute -bottom-0.5 -right-0.5 h-3 w-3 rounded-full border-2 border-slate-800 bg-emerald-400"})]}),u.jsxs("div",{className:"flex flex-col",children:[u.jsx("h3",{className:"text-lg font-semibold leading-tight",children:o}),u.jsx("p",{className:"text-xs text-white/70",children:s})]}),u.jsx("span",{className:"ml-2 inline-flex items-center justify-center rounded-full bg-red-500 px-2 py-0.5 text-[11px] font-semibold leading-none text-white",children:"1"})]}),u.jsxs("div",{className:"flex items-center gap-1",children:[u.jsx(Je,{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(Je,{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(Je,{variant:"ghost",size:"sm",onClick:l=>{l.stopPropagation(),c(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(Je,{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",Im=h.forwardRef((e,t)=>u.jsx(pe.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())}}));Im.displayName=Jk;var Nm=Im;const Zk=Kr.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Am=h.forwardRef(({className:e,...t},n)=>u.jsx(Nm,{ref:n,className:ne(Zk(),e),...t}));Am.displayName=Nm.displayName;function Pm(e){const t=h.useRef({value:e,previous:e});return h.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var jm=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),Qk="VisuallyHidden",ci=h.forwardRef((e,t)=>u.jsx(pe.span,{...e,ref:t,style:{...jm,...e.style}}));ci.displayName=Qk;var eE=ci,tE=[" ","Enter","ArrowUp","ArrowDown"],nE=[" ","Enter"],hr="Select",[ui,di,rE]=es(hr),[Ur,VN]=cn(hr,[rE,jr]),fi=jr(),[oE,qn]=Ur(hr),[sE,iE]=Ur(hr),_m=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:c,dir:l,name:d,autoComplete:f,disabled:m,required:p,form:v}=e,g=fi(t),[x,y]=h.useState(null),[b,T]=h.useState(null),[E,S]=h.useState(!1),C=ts(l),[k,A]=On({prop:r,defaultProp:o??!1,onChange:s,caller:hr}),[j,L]=On({prop:i,defaultProp:a,onChange:c,caller:hr}),B=h.useRef(null),K=x?v||!!x.closest("form"):!0,[J,_]=h.useState(new Set),Y=Array.from(J).map(q=>q.props.value).join(";");return u.jsx(ha,{...g,children:u.jsxs(oE,{required:p,scope:t,trigger:x,onTriggerChange:y,valueNode:b,onValueNodeChange:T,valueNodeHasChildren:E,onValueNodeHasChildrenChange:S,contentId:_t(),value:j,onValueChange:L,open:k,onOpenChange:A,dir:C,triggerPointerDownPosRef:B,disabled:m,children:[u.jsx(ui.Provider,{scope:t,children:u.jsx(sE,{scope:e.__scopeSelect,onNativeOptionAdd:h.useCallback(q=>{_(W=>new Set(W).add(q))},[]),onNativeOptionRemove:h.useCallback(q=>{_(W=>{const D=new Set(W);return D.delete(q),D})},[]),children:n})}),K?u.jsxs(ng,{"aria-hidden":!0,required:p,tabIndex:-1,name:d,autoComplete:f,value:j,onChange:q=>L(q.target.value),disabled:m,form:v,children:[j===void 0?u.jsx("option",{value:""}):null,Array.from(J)]},Y):null]})})};_m.displayName=hr;var Rm="SelectTrigger",Mm=h.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=fi(n),i=qn(Rm,n),a=i.disabled||r,c=je(t,i.onTriggerChange),l=di(n),d=h.useRef("touch"),[f,m,p]=og(g=>{const x=l().filter(T=>!T.disabled),y=x.find(T=>T.value===i.value),b=sg(x,g,y);b!==void 0&&i.onValueChange(b.value)}),v=g=>{a||(i.onOpenChange(!0),p()),g&&(i.triggerPointerDownPosRef.current={x:Math.round(g.pageX),y:Math.round(g.pageY)})};return u.jsx(ma,{asChild:!0,...s,children:u.jsx(pe.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":rg(i.value)?"":void 0,...o,ref:c,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=f.current!=="";!(g.ctrlKey||g.altKey||g.metaKey)&&g.key.length===1&&m(g.key),!(x&&g.key===" ")&&tE.includes(g.key)&&(v(),g.preventDefault())})})})});Mm.displayName=Rm;var Om="SelectValue",Dm=h.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,c=qn(Om,n),{onValueNodeHasChildrenChange:l}=c,d=s!==void 0,f=je(t,c.onValueNodeChange);return kt(()=>{l(d)},[l,d]),u.jsx(pe.span,{...a,ref:f,style:{pointerEvents:"none"},children:rg(c.value)?u.jsx(u.Fragment,{children:i}):s})});Dm.displayName=Om;var aE="SelectIcon",Lm=h.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return u.jsx(pe.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});Lm.displayName=aE;var lE="SelectPortal",$m=e=>u.jsx(co,{asChild:!0,...e});$m.displayName=lE;var mr="SelectContent",Fm=h.forwardRef((e,t)=>{const n=qn(mr,e.__scopeSelect),[r,o]=h.useState();if(kt(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?qr.createPortal(u.jsx(Bm,{scope:e.__scopeSelect,children:u.jsx(ui.Slot,{scope:e.__scopeSelect,children:u.jsx("div",{children:e.children})})}),s):null}return u.jsx(zm,{...e,ref:t})});Fm.displayName=mr;var mn=10,[Bm,Gn]=Ur(mr),cE="SelectContentImpl",uE=qt.createSlot("SelectContent.RemoveScroll"),zm=h.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:a,sideOffset:c,align:l,alignOffset:d,arrowPadding:f,collisionBoundary:m,collisionPadding:p,sticky:v,hideWhenDetached:g,avoidCollisions:x,...y}=e,b=qn(mr,n),[T,E]=h.useState(null),[S,C]=h.useState(null),k=je(t,O=>E(O)),[A,j]=h.useState(null),[L,B]=h.useState(null),K=di(n),[J,_]=h.useState(!1),Y=h.useRef(!1);h.useEffect(()=>{if(T)return ya(T)},[T]),Zi();const q=h.useCallback(O=>{const[P,...U]=K().map(ie=>ie.ref.current),[Q]=U.slice(-1),se=document.activeElement;for(const ie of O)if(ie===se||(ie==null||ie.scrollIntoView({block:"nearest"}),ie===P&&S&&(S.scrollTop=0),ie===Q&&S&&(S.scrollTop=S.scrollHeight),ie==null||ie.focus(),document.activeElement!==se))return},[K,S]),W=h.useCallback(()=>q([A,T]),[q,A,T]);h.useEffect(()=>{J&&W()},[J,W]);const{onOpenChange:D,triggerPointerDownPosRef:I}=b;h.useEffect(()=>{if(T){let O={x:0,y:0};const P=Q=>{var se,ie;O={x:Math.abs(Math.round(Q.pageX)-(((se=I.current)==null?void 0:se.x)??0)),y:Math.abs(Math.round(Q.pageY)-(((ie=I.current)==null?void 0:ie.y)??0))}},U=Q=>{O.x<=10&&O.y<=10?Q.preventDefault():T.contains(Q.target)||D(!1),document.removeEventListener("pointermove",P),I.current=null};return I.current!==null&&(document.addEventListener("pointermove",P),document.addEventListener("pointerup",U,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",P),document.removeEventListener("pointerup",U,{capture:!0})}}},[T,D,I]),h.useEffect(()=>{const O=()=>D(!1);return window.addEventListener("blur",O),window.addEventListener("resize",O),()=>{window.removeEventListener("blur",O),window.removeEventListener("resize",O)}},[D]);const[G,X]=og(O=>{const P=K().filter(se=>!se.disabled),U=P.find(se=>se.ref.current===document.activeElement),Q=sg(P,O,U);Q&&setTimeout(()=>Q.ref.current.focus())}),M=h.useCallback((O,P,U)=>{const Q=!Y.current&&!U;(b.value!==void 0&&b.value===P||Q)&&(j(O),Q&&(Y.current=!0))},[b.value]),z=h.useCallback(()=>T==null?void 0:T.focus(),[T]),R=h.useCallback((O,P,U)=>{const Q=!Y.current&&!U;(b.value!==void 0&&b.value===P||Q)&&B(O)},[b.value]),F=r==="popper"?Hl:Hm,H=F===Hl?{side:a,sideOffset:c,align:l,alignOffset:d,arrowPadding:f,collisionBoundary:m,collisionPadding:p,sticky:v,hideWhenDetached:g,avoidCollisions:x}:{};return u.jsx(Bm,{scope:n,content:T,viewport:S,onViewportChange:C,itemRefCallback:M,selectedItem:A,onItemLeave:z,itemTextRefCallback:R,focusSelectedItem:W,selectedItemText:L,position:r,isPositioned:J,searchRef:G,children:u.jsx(ys,{as:uE,allowPinchZoom:!0,children:u.jsx(ns,{asChild:!0,trapped:b.open,onMountAutoFocus:O=>{O.preventDefault()},onUnmountAutoFocus:ae(o,O=>{var P;(P=b.trigger)==null||P.focus({preventScroll:!0}),O.preventDefault()}),children:u.jsx(Er,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:O=>O.preventDefault(),onDismiss:()=>b.onOpenChange(!1),children:u.jsx(F,{role:"listbox",id:b.contentId,"data-state":b.open?"open":"closed",dir:b.dir,onContextMenu:O=>O.preventDefault(),...y,...H,onPlaced:()=>_(!0),ref:k,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:ae(y.onKeyDown,O=>{const P=O.ctrlKey||O.altKey||O.metaKey;if(O.key==="Tab"&&O.preventDefault(),!P&&O.key.length===1&&X(O.key),["ArrowUp","ArrowDown","Home","End"].includes(O.key)){let Q=K().filter(se=>!se.disabled).map(se=>se.ref.current);if(["ArrowUp","End"].includes(O.key)&&(Q=Q.slice().reverse()),["ArrowUp","ArrowDown"].includes(O.key)){const se=O.target,ie=Q.indexOf(se);Q=Q.slice(ie+1)}setTimeout(()=>q(Q)),O.preventDefault()}})})})})})})});zm.displayName=cE;var dE="SelectItemAlignedPosition",Hm=h.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=qn(mr,n),i=Gn(mr,n),[a,c]=h.useState(null),[l,d]=h.useState(null),f=je(t,k=>d(k)),m=di(n),p=h.useRef(!1),v=h.useRef(!0),{viewport:g,selectedItem:x,selectedItemText:y,focusSelectedItem:b}=i,T=h.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&l&&g&&x&&y){const k=s.trigger.getBoundingClientRect(),A=l.getBoundingClientRect(),j=s.valueNode.getBoundingClientRect(),L=y.getBoundingClientRect();if(s.dir!=="rtl"){const se=L.left-A.left,ie=j.left-se,Se=k.left-ie,xe=k.width+Se,Re=Math.max(xe,A.width),Ve=window.innerWidth-mn,De=Ol(ie,[mn,Math.max(mn,Ve-Re)]);a.style.minWidth=xe+"px",a.style.left=De+"px"}else{const se=A.right-L.right,ie=window.innerWidth-j.right-se,Se=window.innerWidth-k.right-ie,xe=k.width+Se,Re=Math.max(xe,A.width),Ve=window.innerWidth-mn,De=Ol(ie,[mn,Math.max(mn,Ve-Re)]);a.style.minWidth=xe+"px",a.style.right=De+"px"}const B=m(),K=window.innerHeight-mn*2,J=g.scrollHeight,_=window.getComputedStyle(l),Y=parseInt(_.borderTopWidth,10),q=parseInt(_.paddingTop,10),W=parseInt(_.borderBottomWidth,10),D=parseInt(_.paddingBottom,10),I=Y+q+J+D+W,G=Math.min(x.offsetHeight*5,I),X=window.getComputedStyle(g),M=parseInt(X.paddingTop,10),z=parseInt(X.paddingBottom,10),R=k.top+k.height/2-mn,F=K-R,H=x.offsetHeight/2,O=x.offsetTop+H,P=Y+q+O,U=I-P;if(P<=R){const se=B.length>0&&x===B[B.length-1].ref.current;a.style.bottom="0px";const ie=l.clientHeight-g.offsetTop-g.offsetHeight,Se=Math.max(F,H+(se?z:0)+ie+W),xe=P+Se;a.style.height=xe+"px"}else{const se=B.length>0&&x===B[0].ref.current;a.style.top="0px";const Se=Math.max(R,Y+g.offsetTop+(se?M:0)+H)+U;a.style.height=Se+"px",g.scrollTop=P-R+g.offsetTop}a.style.margin=`${mn}px 0`,a.style.minHeight=G+"px",a.style.maxHeight=K+"px",r==null||r(),requestAnimationFrame(()=>p.current=!0)}},[m,s.trigger,s.valueNode,a,l,g,x,y,s.dir,r]);kt(()=>T(),[T]);const[E,S]=h.useState();kt(()=>{l&&S(window.getComputedStyle(l).zIndex)},[l]);const C=h.useCallback(k=>{k&&v.current===!0&&(T(),b==null||b(),v.current=!1)},[T,b]);return u.jsx(pE,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:p,onScrollButtonChange:C,children:u.jsx("div",{ref:c,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:E},children:u.jsx(pe.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Hm.displayName=dE;var fE="SelectPopperPosition",Hl=h.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=mn,...s}=e,i=fi(n);return u.jsx(ga,{...i,...s,ref:t,align:r,collisionPadding:o,style:{boxSizing:"border-box",...s.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});Hl.displayName=fE;var[pE,Ul]=Ur(mr,{}),Wl="SelectViewport",Um=h.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=Gn(Wl,n),i=Ul(Wl,n),a=je(t,s.onViewportChange),c=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(ui.Slot,{scope:n,children:u.jsx(pe.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:ae(o.onScroll,l=>{const d=l.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:m}=i;if(m!=null&&m.current&&f){const p=Math.abs(c.current-d.scrollTop);if(p>0){const v=window.innerHeight-mn*2,g=parseFloat(f.style.minHeight),x=parseFloat(f.style.height),y=Math.max(g,x);if(y<v){const b=y+p,T=Math.min(v,b),E=b-T;f.style.height=T+"px",f.style.bottom==="0px"&&(d.scrollTop=E>0?E:0,f.style.justifyContent="flex-end")}}}c.current=d.scrollTop})})})]})});Um.displayName=Wl;var Wm="SelectGroup",[hE,mE]=Ur(Wm),gE=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=_t();return u.jsx(hE,{scope:n,id:o,children:u.jsx(pe.div,{role:"group","aria-labelledby":o,...r,ref:t})})});gE.displayName=Wm;var Vm="SelectLabel",Km=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=mE(Vm,n);return u.jsx(pe.div,{id:o.id,...r,ref:t})});Km.displayName=Vm;var pi="SelectItem",[xE,qm]=Ur(pi),Gm=h.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=qn(pi,n),c=Gn(pi,n),l=a.value===r,[d,f]=h.useState(s??""),[m,p]=h.useState(!1),v=je(t,b=>{var T;return(T=c.itemRefCallback)==null?void 0:T.call(c,b,r,o)}),g=_t(),x=h.useRef("touch"),y=()=>{o||(a.onValueChange(r),a.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return u.jsx(xE,{scope:n,value:r,disabled:o,textId:g,isSelected:l,onItemTextChange:h.useCallback(b=>{f(T=>T||((b==null?void 0:b.textContent)??"").trim())},[]),children:u.jsx(ui.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:u.jsx(pe.div,{role:"option","aria-labelledby":g,"data-highlighted":m?"":void 0,"aria-selected":l&&m,"data-state":l?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:v,onFocus:ae(i.onFocus,()=>p(!0)),onBlur:ae(i.onBlur,()=>p(!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 T;x.current=b.pointerType,o?(T=c.onItemLeave)==null||T.call(c):x.current==="mouse"&&b.currentTarget.focus({preventScroll:!0})}),onPointerLeave:ae(i.onPointerLeave,b=>{var T;b.currentTarget===document.activeElement&&((T=c.onItemLeave)==null||T.call(c))}),onKeyDown:ae(i.onKeyDown,b=>{var E;((E=c.searchRef)==null?void 0:E.current)!==""&&b.key===" "||(nE.includes(b.key)&&y(),b.key===" "&&b.preventDefault())})})})})});Gm.displayName=pi;var Mo="SelectItemText",Ym=h.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=qn(Mo,n),a=Gn(Mo,n),c=qm(Mo,n),l=iE(Mo,n),[d,f]=h.useState(null),m=je(t,y=>f(y),c.onItemTextChange,y=>{var b;return(b=a.itemTextRefCallback)==null?void 0:b.call(a,y,c.value,c.disabled)}),p=d==null?void 0:d.textContent,v=h.useMemo(()=>u.jsx("option",{value:c.value,disabled:c.disabled,children:p},c.value),[c.disabled,c.value,p]),{onNativeOptionAdd:g,onNativeOptionRemove:x}=l;return kt(()=>(g(v),()=>x(v)),[g,x,v]),u.jsxs(u.Fragment,{children:[u.jsx(pe.span,{id:c.textId,...s,ref:m}),c.isSelected&&i.valueNode&&!i.valueNodeHasChildren?qr.createPortal(s.children,i.valueNode):null]})});Ym.displayName=Mo;var Xm="SelectItemIndicator",Jm=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return qm(Xm,n).isSelected?u.jsx(pe.span,{"aria-hidden":!0,...r,ref:t}):null});Jm.displayName=Xm;var Vl="SelectScrollUpButton",Zm=h.forwardRef((e,t)=>{const n=Gn(Vl,e.__scopeSelect),r=Ul(Vl,e.__scopeSelect),[o,s]=h.useState(!1),i=je(t,r.onScrollButtonChange);return kt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const l=c.scrollTop>0;s(l)};const c=n.viewport;return a(),c.addEventListener("scroll",a),()=>c.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?u.jsx(eg,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:c}=n;a&&c&&(a.scrollTop=a.scrollTop-c.offsetHeight)}}):null});Zm.displayName=Vl;var Kl="SelectScrollDownButton",Qm=h.forwardRef((e,t)=>{const n=Gn(Kl,e.__scopeSelect),r=Ul(Kl,e.__scopeSelect),[o,s]=h.useState(!1),i=je(t,r.onScrollButtonChange);return kt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const l=c.scrollHeight-c.clientHeight,d=Math.ceil(c.scrollTop)<l;s(d)};const c=n.viewport;return a(),c.addEventListener("scroll",a),()=>c.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?u.jsx(eg,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:c}=n;a&&c&&(a.scrollTop=a.scrollTop+c.offsetHeight)}}):null});Qm.displayName=Kl;var eg=h.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=Gn("SelectScrollButton",n),i=h.useRef(null),a=di(n),c=h.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return h.useEffect(()=>()=>c(),[c]),kt(()=>{var d;const l=a().find(f=>f.ref.current===document.activeElement);(d=l==null?void 0:l.ref.current)==null||d.scrollIntoView({block:"nearest"})},[a]),u.jsx(pe.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 l;(l=s.onItemLeave)==null||l.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:ae(o.onPointerLeave,()=>{c()})})}),vE="SelectSeparator",tg=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return u.jsx(pe.div,{"aria-hidden":!0,...r,ref:t})});tg.displayName=vE;var ql="SelectArrow",wE=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=fi(n),s=qn(ql,n),i=Gn(ql,n);return s.open&&i.position==="popper"?u.jsx(xa,{...o,...r,ref:t}):null});wE.displayName=ql;var bE="SelectBubbleInput",ng=h.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=h.useRef(null),s=je(r,o),i=Pm(t);return h.useEffect(()=>{const a=o.current;if(!a)return;const c=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(c,"value").set;if(i!==t&&d){const f=new Event("change",{bubbles:!0});d.call(a,t),a.dispatchEvent(f)}},[i,t]),u.jsx(pe.select,{...n,style:{...jm,...n.style},ref:s,defaultValue:t})});ng.displayName=bE;function rg(e){return e===""||e===void 0}function og(e){const t=gt(e),n=h.useRef(""),r=h.useRef(0),o=h.useCallback(i=>{const a=n.current+i;t(a),function c(l){n.current=l,window.clearTimeout(r.current),l!==""&&(r.current=window.setTimeout(()=>c(""),1e3))}(a)},[t]),s=h.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return h.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function sg(e,t,n){const o=t.length>1&&Array.from(t).every(l=>l===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(l=>l!==n));const c=i.find(l=>l.textValue.toLowerCase().startsWith(o.toLowerCase()));return c!==n?c:void 0}function yE(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var SE=_m,ig=Mm,CE=Dm,TE=Lm,kE=$m,ag=Fm,EE=Um,lg=Km,cg=Gm,IE=Ym,NE=Jm,ug=Zm,dg=Qm,fg=tg;const AE=SE,PE=CE,pg=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(ig,{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"})})]}));pg.displayName=ig.displayName;const hg=h.forwardRef(({className:e,...t},n)=>u.jsx(ug,{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"})}));hg.displayName=ug.displayName;const mg=h.forwardRef(({className:e,...t},n)=>u.jsx(dg,{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"})}));mg.displayName=dg.displayName;const gg=h.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>u.jsx(kE,{children:u.jsxs(ag,{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(hg,{}),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(mg,{})]})}));gg.displayName=ag.displayName;const jE=h.forwardRef(({className:e,...t},n)=>u.jsx(lg,{ref:n,className:ne("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));jE.displayName=lg.displayName;const xg=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(cg,{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})]}));xg.displayName=cg.displayName;const _E=h.forwardRef(({className:e,...t},n)=>u.jsx(fg,{ref:n,className:ne("-mx-1 my-1 h-px bg-muted",e),...t}));_E.displayName=fg.displayName;var RE="Separator",vg="horizontal",ME=["horizontal","vertical"],wg=h.forwardRef((e,t)=>{const{decorative:n,orientation:r=vg,...o}=e,s=OE(r)?r:vg,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return u.jsx(pe.div,{"data-orientation":s,...a,...o,ref:t})});wg.displayName=RE;function OE(e){return ME.includes(e)}var bg=wg;const yg=h.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>u.jsx(bg,{ref:o,decorative:n,orientation:t,className:ne("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));yg.displayName=bg.displayName;var hi="Switch",[DE,KN]=cn(hi),[LE,$E]=DE(hi),Sg=h.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:s,required:i,disabled:a,value:c="on",onCheckedChange:l,form:d,...f}=e,[m,p]=h.useState(null),v=je(t,T=>p(T)),g=h.useRef(!1),x=m?d||!!m.closest("form"):!0,[y,b]=On({prop:o,defaultProp:s??!1,onChange:l,caller:hi});return u.jsxs(LE,{scope:n,checked:y,disabled:a,children:[u.jsx(pe.button,{type:"button",role:"switch","aria-checked":y,"aria-required":i,"data-state":Eg(y),"data-disabled":a?"":void 0,disabled:a,value:c,...f,ref:v,onClick:ae(e.onClick,T=>{b(E=>!E),x&&(g.current=T.isPropagationStopped(),g.current||T.stopPropagation())})}),x&&u.jsx(kg,{control:m,bubbles:!g.current,name:r,value:c,checked:y,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});Sg.displayName=hi;var Cg="SwitchThumb",Tg=h.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=$E(Cg,n);return u.jsx(pe.span,{"data-state":Eg(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});Tg.displayName=Cg;var FE="SwitchBubbleInput",kg=h.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=h.useRef(null),a=je(i,s),c=Pm(n),l=Od(t);return h.useEffect(()=>{const d=i.current;if(!d)return;const f=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(f,"checked").set;if(c!==n&&p){const v=new Event("click",{bubbles:r});p.call(d,n),d.dispatchEvent(v)}},[c,n,r]),u.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:a,style:{...o.style,...l,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});kg.displayName=FE;function Eg(e){return e?"checked":"unchecked"}var Ig=Sg,BE=Tg;const Ng=h.forwardRef(({className:e,...t},n)=>u.jsx(Ig,{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")})}));Ng.displayName=Ig.displayName;const zE=al,HE=wT,UE=ll,Ag=h.forwardRef(({className:e,...t},n)=>u.jsx(No,{className:ne("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t,ref:n}));Ag.displayName=No.displayName;const WE=Kr.cva("fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),Pg=h.forwardRef(({side:e="right",className:t,children:n,...r},o)=>u.jsxs(UE,{children:[u.jsx(Ag,{}),u.jsxs(Ao,{ref:o,className:ne(WE({side:e}),t),...r,children:[n,u.jsxs(yh,{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"})]})]})]}));Pg.displayName=Ao.displayName;const jg=({className:e,...t})=>u.jsx("div",{className:ne("flex flex-col space-y-2 text-center sm:text-left",e),...t});jg.displayName="SheetHeader";const _g=h.forwardRef(({className:e,...t},n)=>u.jsx(ur,{ref:n,className:ne("text-lg font-semibold text-foreground",e),...t}));_g.displayName=ur.displayName;const Rg=h.forwardRef(({className:e,...t},n)=>u.jsx(Ws,{ref:n,className:ne("text-sm text-muted-foreground",e),...t}));Rg.displayName=Ws.displayName;var[mi,qN]=cn("Tooltip",[jr]),gi=jr(),Mg="TooltipProvider",VE=700,Gl="tooltip.open",[KE,Yl]=mi(Mg),Og=e=>{const{__scopeTooltip:t,delayDuration:n=VE,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:s}=e,i=h.useRef(!0),a=h.useRef(!1),c=h.useRef(0);return h.useEffect(()=>{const l=c.current;return()=>window.clearTimeout(l)},[]),u.jsx(KE,{scope:t,isOpenDelayedRef:i,delayDuration:n,onOpen:h.useCallback(()=>{window.clearTimeout(c.current),i.current=!1},[]),onClose:h.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>i.current=!0,r)},[r]),isPointerInTransitRef:a,onPointerInTransitChange:h.useCallback(l=>{a.current=l},[]),disableHoverableContent:o,children:s})};Og.displayName=Mg;var Oo="Tooltip",[qE,xi]=mi(Oo),Dg=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:s,disableHoverableContent:i,delayDuration:a}=e,c=Yl(Oo,e.__scopeTooltip),l=gi(t),[d,f]=h.useState(null),m=_t(),p=h.useRef(0),v=i??c.disableHoverableContent,g=a??c.delayDuration,x=h.useRef(!1),[y,b]=On({prop:r,defaultProp:o??!1,onChange:k=>{k?(c.onOpen(),document.dispatchEvent(new CustomEvent(Gl))):c.onClose(),s==null||s(k)},caller:Oo}),T=h.useMemo(()=>y?x.current?"delayed-open":"instant-open":"closed",[y]),E=h.useCallback(()=>{window.clearTimeout(p.current),p.current=0,x.current=!1,b(!0)},[b]),S=h.useCallback(()=>{window.clearTimeout(p.current),p.current=0,b(!1)},[b]),C=h.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{x.current=!0,b(!0),p.current=0},g)},[g,b]);return h.useEffect(()=>()=>{p.current&&(window.clearTimeout(p.current),p.current=0)},[]),u.jsx(ha,{...l,children:u.jsx(qE,{scope:t,contentId:m,open:y,stateAttribute:T,trigger:d,onTriggerChange:f,onTriggerEnter:h.useCallback(()=>{c.isOpenDelayedRef.current?C():E()},[c.isOpenDelayedRef,C,E]),onTriggerLeave:h.useCallback(()=>{v?S():(window.clearTimeout(p.current),p.current=0)},[S,v]),onOpen:E,onClose:S,disableHoverableContent:v,children:n})})};Dg.displayName=Oo;var Xl="TooltipTrigger",Lg=h.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=xi(Xl,n),s=Yl(Xl,n),i=gi(n),a=h.useRef(null),c=je(t,a,o.onTriggerChange),l=h.useRef(!1),d=h.useRef(!1),f=h.useCallback(()=>l.current=!1,[]);return h.useEffect(()=>()=>document.removeEventListener("pointerup",f),[f]),u.jsx(ma,{asChild:!0,...i,children:u.jsx(pe.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:c,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(),l.current=!0,document.addEventListener("pointerup",f,{once:!0})}),onFocus:ae(e.onFocus,()=>{l.current||o.onOpen()}),onBlur:ae(e.onBlur,o.onClose),onClick:ae(e.onClick,o.onClose)})})});Lg.displayName=Xl;var GE="TooltipPortal",[GN,YE]=mi(GE,{forceMount:void 0}),Wr="TooltipContent",$g=h.forwardRef((e,t)=>{const n=YE(Wr,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...s}=e,i=xi(Wr,e.__scopeTooltip);return u.jsx(Ht,{present:r||i.open,children:i.disableHoverableContent?u.jsx(Fg,{side:o,...s,ref:t}):u.jsx(XE,{side:o,...s,ref:t})})}),XE=h.forwardRef((e,t)=>{const n=xi(Wr,e.__scopeTooltip),r=Yl(Wr,e.__scopeTooltip),o=h.useRef(null),s=je(t,o),[i,a]=h.useState(null),{trigger:c,onClose:l}=n,d=o.current,{onPointerInTransitChange:f}=r,m=h.useCallback(()=>{a(null),f(!1)},[f]),p=h.useCallback((v,g)=>{const x=v.currentTarget,y={x:v.clientX,y:v.clientY},b=tI(y,x.getBoundingClientRect()),T=nI(y,b),E=rI(g.getBoundingClientRect()),S=sI([...T,...E]);a(S),f(!0)},[f]);return h.useEffect(()=>()=>m(),[m]),h.useEffect(()=>{if(c&&d){const v=x=>p(x,d),g=x=>p(x,c);return c.addEventListener("pointerleave",v),d.addEventListener("pointerleave",g),()=>{c.removeEventListener("pointerleave",v),d.removeEventListener("pointerleave",g)}}},[c,d,p,m]),h.useEffect(()=>{if(i){const v=g=>{const x=g.target,y={x:g.clientX,y:g.clientY},b=(c==null?void 0:c.contains(x))||(d==null?void 0:d.contains(x)),T=!oI(y,i);b?m():T&&(m(),l())};return document.addEventListener("pointermove",v),()=>document.removeEventListener("pointermove",v)}},[c,d,i,l,m]),u.jsx(Fg,{...e,ref:s})}),[JE,ZE]=mi(Oo,{isInside:!1}),QE=qt.createSlottable("TooltipContent"),Fg=h.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:s,onPointerDownOutside:i,...a}=e,c=xi(Wr,n),l=gi(n),{onClose:d}=c;return h.useEffect(()=>(document.addEventListener(Gl,d),()=>document.removeEventListener(Gl,d)),[d]),h.useEffect(()=>{if(c.trigger){const f=m=>{const p=m.target;p!=null&&p.contains(c.trigger)&&d()};return window.addEventListener("scroll",f,{capture:!0}),()=>window.removeEventListener("scroll",f,{capture:!0})}},[c.trigger,d]),u.jsx(Er,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:f=>f.preventDefault(),onDismiss:d,children:u.jsxs(ga,{"data-state":c.stateAttribute,...l,...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:c.contentId,role:"tooltip",children:o||r})})]})})});$g.displayName=Wr;var Bg="TooltipArrow",eI=h.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=gi(n);return ZE(Bg,n).isInside?null:u.jsx(xa,{...o,...r,ref:t})});eI.displayName=Bg;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],c=t[i],l=a.x,d=a.y,f=c.x,m=c.y;d>r!=m>r&&n<(f-l)*(r-d)/(m-d)+l&&(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=Og,lI=Dg,cI=Lg,zg=$g;const uI=aI,dI=lI,fI=cI,Hg=h.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(zg,{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}));Hg.displayName=zg.displayName;var Jl="ToastProvider",[Zl,pI,hI]=es("Toast"),[Ug,YN]=cn("Toast",[hI]),[mI,vi]=Ug(Jl),Wg=e=>{const{__scopeToast:t,label:n="Notification",duration:r=5e3,swipeDirection:o="right",swipeThreshold:s=50,children:i}=e,[a,c]=h.useState(null),[l,d]=h.useState(0),f=h.useRef(!1),m=h.useRef(!1);return n.trim()||console.error(`Invalid prop \`label\` supplied to \`${Jl}\`. Expected non-empty \`string\`.`),u.jsx(Zl.Provider,{scope:t,children:u.jsx(mI,{scope:t,label:n,duration:r,swipeDirection:o,swipeThreshold:s,toastCount:l,viewport:a,onViewportChange:c,onToastAdd:h.useCallback(()=>d(p=>p+1),[]),onToastRemove:h.useCallback(()=>d(p=>p-1),[]),isFocusedToastEscapeKeyDownRef:f,isClosePausedRef:m,children:i})})};Wg.displayName=Jl;var Vg="ToastViewport",gI=["F8"],Ql="toast.viewportPause",ec="toast.viewportResume",Kg=h.forwardRef((e,t)=>{const{__scopeToast:n,hotkey:r=gI,label:o="Notifications ({hotkey})",...s}=e,i=vi(Vg,n),a=pI(n),c=h.useRef(null),l=h.useRef(null),d=h.useRef(null),f=h.useRef(null),m=je(t,f,i.onViewportChange),p=r.join("+").replace(/Key/g,"").replace(/Digit/g,""),v=i.toastCount>0;h.useEffect(()=>{const x=y=>{var T;r.length!==0&&r.every(E=>y[E]||y.code===E)&&((T=f.current)==null||T.focus())};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[r]),h.useEffect(()=>{const x=c.current,y=f.current;if(v&&x&&y){const b=()=>{if(!i.isClosePausedRef.current){const C=new CustomEvent(Ql);y.dispatchEvent(C),i.isClosePausedRef.current=!0}},T=()=>{if(i.isClosePausedRef.current){const C=new CustomEvent(ec);y.dispatchEvent(C),i.isClosePausedRef.current=!1}},E=C=>{!x.contains(C.relatedTarget)&&T()},S=()=>{x.contains(document.activeElement)||T()};return x.addEventListener("focusin",b),x.addEventListener("focusout",E),x.addEventListener("pointermove",b),x.addEventListener("pointerleave",S),window.addEventListener("blur",b),window.addEventListener("focus",T),()=>{x.removeEventListener("focusin",b),x.removeEventListener("focusout",E),x.removeEventListener("pointermove",b),x.removeEventListener("pointerleave",S),window.removeEventListener("blur",b),window.removeEventListener("focus",T)}}},[v,i.isClosePausedRef]);const g=h.useCallback(({tabbingDirection:x})=>{const b=a().map(T=>{const E=T.ref.current,S=[E,...AI(E)];return x==="forwards"?S:S.reverse()});return(x==="forwards"?b.reverse():b).flat()},[a]);return h.useEffect(()=>{const x=f.current;if(x){const y=b=>{var S,C,k;const T=b.altKey||b.ctrlKey||b.metaKey;if(b.key==="Tab"&&!T){const A=document.activeElement,j=b.shiftKey;if(b.target===x&&j){(S=l.current)==null||S.focus();return}const K=g({tabbingDirection:j?"backwards":"forwards"}),J=K.findIndex(_=>_===A);rc(K.slice(J+1))?b.preventDefault():j?(C=l.current)==null||C.focus():(k=d.current)==null||k.focus()}};return x.addEventListener("keydown",y),()=>x.removeEventListener("keydown",y)}},[a,g]),u.jsxs(qw,{ref:c,role:"region","aria-label":o.replace("{hotkey}",p),tabIndex:-1,style:{pointerEvents:v?void 0:"none"},children:[v&&u.jsx(tc,{ref:l,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"forwards"});rc(x)}}),u.jsx(Zl.Slot,{scope:n,children:u.jsx(pe.ol,{tabIndex:-1,...s,ref:m})}),v&&u.jsx(tc,{ref:d,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"backwards"});rc(x)}})]})});Kg.displayName=Vg;var qg="ToastFocusProxy",tc=h.forwardRef((e,t)=>{const{__scopeToast:n,onFocusFromOutsideViewport:r,...o}=e,s=vi(qg,n);return u.jsx(ci,{tabIndex:0,...o,ref:t,style:{position:"fixed"},onFocus:i=>{var l;const a=i.relatedTarget;!((l=s.viewport)!=null&&l.contains(a))&&r()}})});tc.displayName=qg;var Do="Toast",xI="toast.swipeStart",vI="toast.swipeMove",wI="toast.swipeCancel",bI="toast.swipeEnd",Gg=h.forwardRef((e,t)=>{const{forceMount:n,open:r,defaultOpen:o,onOpenChange:s,...i}=e,[a,c]=On({prop:r,defaultProp:o??!0,onChange:s,caller:Do});return u.jsx(Ht,{present:n||a,children:u.jsx(CI,{open:a,...i,ref:t,onClose:()=>c(!1),onPause:gt(e.onPause),onResume:gt(e.onResume),onSwipeStart:ae(e.onSwipeStart,l=>{l.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:ae(e.onSwipeMove,l=>{const{x:d,y:f}=l.detail.delta;l.currentTarget.setAttribute("data-swipe","move"),l.currentTarget.style.setProperty("--radix-toast-swipe-move-x",`${d}px`),l.currentTarget.style.setProperty("--radix-toast-swipe-move-y",`${f}px`)}),onSwipeCancel:ae(e.onSwipeCancel,l=>{l.currentTarget.setAttribute("data-swipe","cancel"),l.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),l.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),l.currentTarget.style.removeProperty("--radix-toast-swipe-end-x"),l.currentTarget.style.removeProperty("--radix-toast-swipe-end-y")}),onSwipeEnd:ae(e.onSwipeEnd,l=>{const{x:d,y:f}=l.detail.delta;l.currentTarget.setAttribute("data-swipe","end"),l.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),l.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),l.currentTarget.style.setProperty("--radix-toast-swipe-end-x",`${d}px`),l.currentTarget.style.setProperty("--radix-toast-swipe-end-y",`${f}px`),c(!1)})})})});Gg.displayName=Do;var[yI,SI]=Ug(Do,{onClose(){}}),CI=h.forwardRef((e,t)=>{const{__scopeToast:n,type:r="foreground",duration:o,open:s,onClose:i,onEscapeKeyDown:a,onPause:c,onResume:l,onSwipeStart:d,onSwipeMove:f,onSwipeCancel:m,onSwipeEnd:p,...v}=e,g=vi(Do,n),[x,y]=h.useState(null),b=je(t,_=>y(_)),T=h.useRef(null),E=h.useRef(null),S=o||g.duration,C=h.useRef(0),k=h.useRef(S),A=h.useRef(0),{onToastAdd:j,onToastRemove:L}=g,B=gt(()=>{var Y;(x==null?void 0:x.contains(document.activeElement))&&((Y=g.viewport)==null||Y.focus()),i()}),K=h.useCallback(_=>{!_||_===1/0||(window.clearTimeout(A.current),C.current=new Date().getTime(),A.current=window.setTimeout(B,_))},[B]);h.useEffect(()=>{const _=g.viewport;if(_){const Y=()=>{K(k.current),l==null||l()},q=()=>{const W=new Date().getTime()-C.current;k.current=k.current-W,window.clearTimeout(A.current),c==null||c()};return _.addEventListener(Ql,q),_.addEventListener(ec,Y),()=>{_.removeEventListener(Ql,q),_.removeEventListener(ec,Y)}}},[g.viewport,S,c,l,K]),h.useEffect(()=>{s&&!g.isClosePausedRef.current&&K(S)},[s,S,g.isClosePausedRef,K]),h.useEffect(()=>(j(),()=>L()),[j,L]);const J=h.useMemo(()=>x?tx(x):null,[x]);return g.viewport?u.jsxs(u.Fragment,{children:[J&&u.jsx(TI,{__scopeToast:n,role:"status","aria-live":r==="foreground"?"assertive":"polite",children:J}),u.jsx(yI,{scope:n,onClose:B,children:qr.createPortal(u.jsx(Zl.ItemSlot,{scope:n,children:u.jsx(Kw,{asChild:!0,onEscapeKeyDown:ae(a,()=>{g.isFocusedToastEscapeKeyDownRef.current||B(),g.isFocusedToastEscapeKeyDownRef.current=!1}),children:u.jsx(pe.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,B()))}),onPointerDown:ae(e.onPointerDown,_=>{_.button===0&&(T.current={x:_.clientX,y:_.clientY})}),onPointerMove:ae(e.onPointerMove,_=>{if(!T.current)return;const Y=_.clientX-T.current.x,q=_.clientY-T.current.y,W=!!E.current,D=["left","right"].includes(g.swipeDirection),I=["left","up"].includes(g.swipeDirection)?Math.min:Math.max,G=D?I(0,Y):0,X=D?0:I(0,q),M=_.pointerType==="touch"?10:2,z={x:G,y:X},R={originalEvent:_,delta:z};W?(E.current=z,wi(vI,f,R,{discrete:!1})):nx(z,g.swipeDirection,M)?(E.current=z,wi(xI,d,R,{discrete:!1}),_.target.setPointerCapture(_.pointerId)):(Math.abs(Y)>M||Math.abs(q)>M)&&(T.current=null)}),onPointerUp:ae(e.onPointerUp,_=>{const Y=E.current,q=_.target;if(q.hasPointerCapture(_.pointerId)&&q.releasePointerCapture(_.pointerId),E.current=null,T.current=null,Y){const W=_.currentTarget,D={originalEvent:_,delta:Y};nx(Y,g.swipeDirection,g.swipeThreshold)?wi(bI,p,D,{discrete:!0}):wi(wI,m,D,{discrete:!0}),W.addEventListener("click",I=>I.preventDefault(),{once:!0})}})})})}),g.viewport)})]}):null}),TI=e=>{const{__scopeToast:t,children:n,...r}=e,o=vi(Do,t),[s,i]=h.useState(!1),[a,c]=h.useState(!1);return II(()=>i(!0)),h.useEffect(()=>{const l=window.setTimeout(()=>c(!0),1e3);return()=>window.clearTimeout(l)},[]),a?null:u.jsx(co,{asChild:!0,children:u.jsx(ci,{...r,children:s&&u.jsxs(u.Fragment,{children:[o.label," ",n]})})})},kI="ToastTitle",Yg=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(pe.div,{...r,ref:t})});Yg.displayName=kI;var EI="ToastDescription",Xg=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(pe.div,{...r,ref:t})});Xg.displayName=EI;var Jg="ToastAction",Zg=h.forwardRef((e,t)=>{const{altText:n,...r}=e;return n.trim()?u.jsx(ex,{altText:n,asChild:!0,children:u.jsx(nc,{...r,ref:t})}):(console.error(`Invalid prop \`altText\` supplied to \`${Jg}\`. Expected non-empty \`string\`.`),null)});Zg.displayName=Jg;var Qg="ToastClose",nc=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e,o=SI(Qg,n);return u.jsx(ex,{asChild:!0,children:u.jsx(pe.button,{type:"button",...r,ref:t,onClick:ae(e.onClick,o.onClose)})})});nc.displayName=Qg;var ex=h.forwardRef((e,t)=>{const{__scopeToast:n,altText:r,...o}=e;return u.jsx(pe.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":r||void 0,...o,ref:t})});function tx(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(...tx(r))}}),t}function wi(e,t,n,{discrete:r}){const o=n.originalEvent.currentTarget,s=new CustomEvent(e,{bubbles:!0,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?Yi(o,s):o.dispatchEvent(s)}var nx=(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=gt(e);kt(()=>{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 rc(e){const t=document.activeElement;return e.some(n=>n===t?!0:(n.focus(),document.activeElement!==t))}var PI=Wg,rx=Kg,ox=Gg,sx=Yg,ix=Xg,ax=Zg,lx=nc;const jI=PI,cx=h.forwardRef(({className:e,...t},n)=>u.jsx(rx,{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}));cx.displayName=rx.displayName;const _I=Kr.cva("group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-8 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",{variants:{variant:{default:"border bg-background text-foreground",destructive:"destructive group border-destructive bg-destructive text-destructive-foreground"}},defaultVariants:{variant:"default"}}),ux=h.forwardRef(({className:e,variant:t,...n},r)=>u.jsx(ox,{ref:r,className:ne(_I({variant:t}),e),...n}));ux.displayName=ox.displayName;const RI=h.forwardRef(({className:e,...t},n)=>u.jsx(ax,{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=ax.displayName;const dx=h.forwardRef(({className:e,...t},n)=>u.jsx(lx,{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"})}));dx.displayName=lx.displayName;const fx=h.forwardRef(({className:e,...t},n)=>u.jsx(sx,{ref:n,className:ne("text-sm font-semibold",e),...t}));fx.displayName=sx.displayName;const px=h.forwardRef(({className:e,...t},n)=>u.jsx(ix,{ref:n,className:ne("text-sm opacity-90",e),...t}));px.displayName=ix.displayName;function MI(){const{toasts:e}=fl();return u.jsxs(jI,{children:[e.map(function({id:t,title:n,description:r,action:o,...s}){return u.jsxs(ux,{...s,children:[u.jsxs("div",{className:"grid gap-1",children:[n&&u.jsx(fx,{children:n}),r&&u.jsx(px,{children:r})]}),o,u.jsx(dx,{})]},t)}),u.jsx(cx,{})]})}var OI=(e,t,n,r,o,s,i,a)=>{let c=document.documentElement,l=["light","dark"];function d(p){(Array.isArray(e)?e:[e]).forEach(v=>{let g=v==="class",x=g&&s?o.map(y=>s[y]||y):o;g?(c.classList.remove(...x),c.classList.add(s&&s[p]?s[p]:p)):c.setAttribute(v,p)}),f(p)}function f(p){a&&l.includes(p)&&(c.style.colorScheme=p)}function m(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}if(r)d(r);else try{let p=localStorage.getItem(t)||n,v=i&&p==="system"?m():p;d(v)}catch{}},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:c,scriptProps:l})=>{let d=JSON.stringify([n,t,s,e,a,i,r,o]).slice(1,-1);return h.createElement("script",{...l,suppressHydrationWarning:!0,nonce:typeof window>"u"?c:"",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},oc=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:oc++,s=this.toasts.find(a=>a.id===o),i=e.dismissible===void 0?!0:e.dismissible;return this.dismissedToasts.has(o)&&this.dismissedToasts.delete(o),s?this.toasts=this.toasts.map(a=>a.id===o?(this.publish({...a,...e,id:o,title:n}),{...a,...e,id:o,dismissible:i,title:n}):a):this.addToast({title:n,...r,dismissible:i,id:o}),o},this.dismiss=e=>(this.dismissedToasts.add(e),e||this.toasts.forEach(t=>{this.subscribers.forEach(n=>n({id:t.id,dismiss:!0}))}),this.subscribers.forEach(t=>t({id:e,dismiss:!0})),e),this.message=(e,t)=>this.create({...t,message:e}),this.error=(e,t)=>this.create({...t,message:e,type:"error"}),this.success=(e,t)=>this.create({...t,type:"success",message:e}),this.info=(e,t)=>this.create({...t,type:"info",message:e}),this.warning=(e,t)=>this.create({...t,type:"warning",message:e}),this.loading=(e,t)=>this.create({...t,type:"loading",message:e}),this.promise=(e,t)=>{if(!t)return;let n;t.loading!==void 0&&(n=this.create({...t,promise:e,type:"loading",message:t.loading,description:typeof t.description!="function"?t.description:void 0}));let r=e instanceof Promise?e:e(),o=n!==void 0,s,i=r.then(async c=>{if(s=["resolve",c],w.isValidElement(c))o=!1,this.create({id:n,type:"default",message:c});else if(XI(c)&&!c.ok){o=!1;let l=typeof t.error=="function"?await t.error(`HTTP error! status: ${c.status}`):t.error,d=typeof t.description=="function"?await t.description(`HTTP error! status: ${c.status}`):t.description;this.create({id:n,type:"error",message:l,description:d})}else if(t.success!==void 0){o=!1;let l=typeof t.success=="function"?await t.success(c):t.success,d=typeof t.description=="function"?await t.description(c):t.description;this.create({id:n,type:"success",message:l,description:d})}}).catch(async c=>{if(s=["reject",c],t.error!==void 0){o=!1;let l=typeof t.error=="function"?await t.error(c):t.error,d=typeof t.description=="function"?await t.description(c):t.description;this.create({id:n,type:"error",message:l,description:d})}}).finally(()=>{var c;o&&(this.dismiss(n),n=void 0),(c=t.finally)==null||c.call(t)}),a=()=>new Promise((c,l)=>i.then(()=>s[0]==="reject"?l(s[1]):c(s[1])).catch(l));return typeof n!="string"&&typeof n!="number"?{unwrap:a}:Object.assign(n,{unwrap:a})},this.custom=(e,t)=>{let n=(t==null?void 0:t.id)||oc++;return this.create({jsx:e(n),id:n,...t}),n},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},Vt=new GI,YI=(e,t)=>{let n=(t==null?void 0:t.id)||oc++;return Vt.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=()=>Vt.toasts,QI=()=>Vt.getActiveToasts();Object.assign(JI,{success:Vt.success,info:Vt.info,warning:Vt.warning,error:Vt.error,custom:Vt.custom,message:Vt.message,promise:Vt.promise,dismiss:Vt.dismiss,loading:Vt.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 bi(e){return e.label!==void 0}var tN=3,nN="32px",rN="16px",hx=4e3,oN=356,sN=14,iN=20,aN=200;function gn(...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,c,l,d,f;let{invert:m,toast:p,unstyled:v,interacting:g,setHeights:x,visibleToasts:y,heights:b,index:T,toasts:E,expanded:S,removeToast:C,defaultRichColors:k,closeButton:A,style:j,cancelButtonStyle:L,actionButtonStyle:B,className:K="",descriptionClassName:J="",duration:_,position:Y,gap:q,loadingIcon:W,expandByDefault:D,classNames:I,icons:G,closeButtonAriaLabel:X="Close toast",pauseWhenPageIsHidden:M}=e,[z,R]=w.useState(null),[F,H]=w.useState(null),[O,P]=w.useState(!1),[U,Q]=w.useState(!1),[se,ie]=w.useState(!1),[Se,xe]=w.useState(!1),[Re,Ve]=w.useState(!1),[De,Ge]=w.useState(0),[He,ot]=w.useState(0),ut=w.useRef(p.duration||_||hx),nt=w.useRef(null),Le=w.useRef(null),Ke=T===0,$e=T+1<=y,Te=p.type,Ae=p.dismissible!==!1,dt=p.className||"",Et=p.descriptionClassName||"",at=w.useMemo(()=>b.findIndex(fe=>fe.toastId===p.id)||0,[b,p.id]),It=w.useMemo(()=>{var fe;return(fe=p.closeButton)!=null?fe:A},[p.closeButton,A]),bt=w.useMemo(()=>p.duration||_||hx,[p.duration,_]),ft=w.useRef(0),Nt=w.useRef(0),At=w.useRef(0),Ct=w.useRef(null),[on,Tt]=Y.split("-"),Ie=w.useMemo(()=>b.reduce((fe,ke,Fe)=>Fe>=at?fe:fe+ke.height,0),[b,at]),Ue=qI(),Pt=p.invert||m,te=Te==="loading";Nt.current=w.useMemo(()=>at*q+Ie,[at,Ie]),w.useEffect(()=>{ut.current=bt},[bt]),w.useEffect(()=>{P(!0)},[]),w.useEffect(()=>{let fe=Le.current;if(fe){let ke=fe.getBoundingClientRect().height;return ot(ke),x(Fe=>[{toastId:p.id,height:ke,position:p.position},...Fe]),()=>x(Fe=>Fe.filter(ht=>ht.toastId!==p.id))}},[x,p.id]),w.useLayoutEffect(()=>{if(!O)return;let fe=Le.current,ke=fe.style.height;fe.style.height="auto";let Fe=fe.getBoundingClientRect().height;fe.style.height=ke,ot(Fe),x(ht=>ht.find(pt=>pt.toastId===p.id)?ht.map(pt=>pt.toastId===p.id?{...pt,height:Fe}:pt):[{toastId:p.id,height:Fe,position:p.position},...ht])},[O,p.title,p.description,x,p.id]);let ge=w.useCallback(()=>{Q(!0),Ge(Nt.current),x(fe=>fe.filter(ke=>ke.toastId!==p.id)),setTimeout(()=>{C(p)},aN)},[p,C,x,Nt]);w.useEffect(()=>{if(p.promise&&Te==="loading"||p.duration===1/0||p.type==="loading")return;let fe;return S||g||M&&Ue?(()=>{if(At.current<ft.current){let ke=new Date().getTime()-ft.current;ut.current=ut.current-ke}At.current=new Date().getTime()})():ut.current!==1/0&&(ft.current=new Date().getTime(),fe=setTimeout(()=>{var ke;(ke=p.onAutoClose)==null||ke.call(p,p),ge()},ut.current)),()=>clearTimeout(fe)},[S,g,p,Te,M,Ue,ge]),w.useEffect(()=>{p.delete&&ge()},[ge,p.delete]);function rt(){var fe,ke,Fe;return G!=null&&G.loading?w.createElement("div",{className:gn(I==null?void 0:I.loader,(fe=p==null?void 0:p.classNames)==null?void 0:fe.loader,"sonner-loader"),"data-visible":Te==="loading"},G.loading):W?w.createElement("div",{className:gn(I==null?void 0:I.loader,(ke=p==null?void 0:p.classNames)==null?void 0:ke.loader,"sonner-loader"),"data-visible":Te==="loading"},W):w.createElement(zI,{className:gn(I==null?void 0:I.loader,(Fe=p==null?void 0:p.classNames)==null?void 0:Fe.loader),visible:Te==="loading"})}return w.createElement("li",{tabIndex:0,ref:Le,className:gn(K,dt,I==null?void 0:I.toast,(t=p==null?void 0:p.classNames)==null?void 0:t.toast,I==null?void 0:I.default,I==null?void 0:I[Te],(n=p==null?void 0:p.classNames)==null?void 0:n[Te]),"data-sonner-toast":"","data-rich-colors":(r=p.richColors)!=null?r:k,"data-styled":!(p.jsx||p.unstyled||v),"data-mounted":O,"data-promise":!!p.promise,"data-swiped":Re,"data-removed":U,"data-visible":$e,"data-y-position":on,"data-x-position":Tt,"data-index":T,"data-front":Ke,"data-swiping":se,"data-dismissible":Ae,"data-type":Te,"data-invert":Pt,"data-swipe-out":Se,"data-swipe-direction":F,"data-expanded":!!(S||D&&O),style:{"--index":T,"--toasts-before":T,"--z-index":E.length-T,"--offset":`${U?De:Nt.current}px`,"--initial-height":D?"auto":`${He}px`,...j,...p.style},onDragEnd:()=>{ie(!1),R(null),Ct.current=null},onPointerDown:fe=>{te||!Ae||(nt.current=new Date,Ge(Nt.current),fe.target.setPointerCapture(fe.pointerId),fe.target.tagName!=="BUTTON"&&(ie(!0),Ct.current={x:fe.clientX,y:fe.clientY}))},onPointerUp:()=>{var fe,ke,Fe,ht;if(Se||!Ae)return;Ct.current=null;let pt=Number(((fe=Le.current)==null?void 0:fe.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),Pe=Number(((ke=Le.current)==null?void 0:ke.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),Ye=new Date().getTime()-((Fe=nt.current)==null?void 0:Fe.getTime()),we=z==="x"?pt:Pe,Qe=Math.abs(we)/Ye;if(Math.abs(we)>=iN||Qe>.11){Ge(Nt.current),(ht=p.onDismiss)==null||ht.call(p,p),H(z==="x"?pt>0?"right":"left":Pe>0?"down":"up"),ge(),xe(!0),Ve(!1);return}ie(!1),R(null)},onPointerMove:fe=>{var ke,Fe,ht,pt;if(!Ct.current||!Ae||((ke=window.getSelection())==null?void 0:ke.toString().length)>0)return;let Pe=fe.clientY-Ct.current.y,Ye=fe.clientX-Ct.current.x,we=(Fe=e.swipeDirections)!=null?Fe:lN(Y);!z&&(Math.abs(Ye)>1||Math.abs(Pe)>1)&&R(Math.abs(Ye)>Math.abs(Pe)?"x":"y");let Qe={x:0,y:0};z==="y"?(we.includes("top")||we.includes("bottom"))&&(we.includes("top")&&Pe<0||we.includes("bottom")&&Pe>0)&&(Qe.y=Pe):z==="x"&&(we.includes("left")||we.includes("right"))&&(we.includes("left")&&Ye<0||we.includes("right")&&Ye>0)&&(Qe.x=Ye),(Math.abs(Qe.x)>0||Math.abs(Qe.y)>0)&&Ve(!0),(ht=Le.current)==null||ht.style.setProperty("--swipe-amount-x",`${Qe.x}px`),(pt=Le.current)==null||pt.style.setProperty("--swipe-amount-y",`${Qe.y}px`)}},It&&!p.jsx?w.createElement("button",{"aria-label":X,"data-disabled":te,"data-close-button":!0,onClick:te||!Ae?()=>{}:()=>{var fe;ge(),(fe=p.onDismiss)==null||fe.call(p,p)},className:gn(I==null?void 0:I.closeButton,(o=p==null?void 0:p.classNames)==null?void 0:o.closeButton)},(s=G==null?void 0:G.close)!=null?s:KI):null,p.jsx||w.isValidElement(p.title)?p.jsx?p.jsx:typeof p.title=="function"?p.title():p.title:w.createElement(w.Fragment,null,Te||p.icon||p.promise?w.createElement("div",{"data-icon":"",className:gn(I==null?void 0:I.icon,(i=p==null?void 0:p.classNames)==null?void 0:i.icon)},p.promise||p.type==="loading"&&!p.icon?p.icon||rt():null,p.type!=="loading"?p.icon||(G==null?void 0:G[Te])||FI(Te):null):null,w.createElement("div",{"data-content":"",className:gn(I==null?void 0:I.content,(a=p==null?void 0:p.classNames)==null?void 0:a.content)},w.createElement("div",{"data-title":"",className:gn(I==null?void 0:I.title,(c=p==null?void 0:p.classNames)==null?void 0:c.title)},typeof p.title=="function"?p.title():p.title),p.description?w.createElement("div",{"data-description":"",className:gn(J,Et,I==null?void 0:I.description,(l=p==null?void 0:p.classNames)==null?void 0:l.description)},typeof p.description=="function"?p.description():p.description):null),w.isValidElement(p.cancel)?p.cancel:p.cancel&&bi(p.cancel)?w.createElement("button",{"data-button":!0,"data-cancel":!0,style:p.cancelButtonStyle||L,onClick:fe=>{var ke,Fe;bi(p.cancel)&&Ae&&((Fe=(ke=p.cancel).onClick)==null||Fe.call(ke,fe),ge())},className:gn(I==null?void 0:I.cancelButton,(d=p==null?void 0:p.classNames)==null?void 0:d.cancelButton)},p.cancel.label):null,w.isValidElement(p.action)?p.action:p.action&&bi(p.action)?w.createElement("button",{"data-button":!0,"data-action":!0,style:p.actionButtonStyle||B,onClick:fe=>{var ke,Fe;bi(p.action)&&((Fe=(ke=p.action).onClick)==null||Fe.call(ke,fe),!fe.defaultPrevented&&ge())},className:gn(I==null?void 0:I.actionButton,(f=p==null?void 0:p.classNames)==null?void 0:f.actionButton)},p.action.label):null))};function mx(){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 c(l){["top","right","bottom","left"].forEach(d=>{n[`${i}-${d}`]=typeof l=="number"?`${l}px`:l})}typeof r=="number"||typeof r=="string"?c(r):typeof r=="object"?["top","right","bottom","left"].forEach(l=>{r[l]===void 0?n[`${i}-${l}`]=a:n[`${i}-${l}`]=typeof r[l]=="number"?`${r[l]}px`:r[l]}):c(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:c,mobileOffset:l,theme:d="light",richColors:f,duration:m,style:p,visibleToasts:v=tN,toastOptions:g,dir:x=mx(),gap:y=sN,loadingIcon:b,icons:T,containerAriaLabel:E="Notifications",pauseWhenPageIsHidden:S}=e,[C,k]=w.useState([]),A=w.useMemo(()=>Array.from(new Set([r].concat(C.filter(M=>M.position).map(M=>M.position)))),[C,r]),[j,L]=w.useState([]),[B,K]=w.useState(!1),[J,_]=w.useState(!1),[Y,q]=w.useState(d!=="system"?d:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),W=w.useRef(null),D=o.join("+").replace(/Key/g,"").replace(/Digit/g,""),I=w.useRef(null),G=w.useRef(!1),X=w.useCallback(M=>{k(z=>{var R;return(R=z.find(F=>F.id===M.id))!=null&&R.delete||Vt.dismiss(M.id),z.filter(({id:F})=>F!==M.id)})},[]);return w.useEffect(()=>Vt.subscribe(M=>{if(M.dismiss){k(z=>z.map(R=>R.id===M.id?{...R,delete:!0}:R));return}setTimeout(()=>{Lo.flushSync(()=>{k(z=>{let R=z.findIndex(F=>F.id===M.id);return R!==-1?[...z.slice(0,R),{...z[R],...M},...z.slice(R+1)]:[M,...z]})})})}),[]),w.useEffect(()=>{if(d!=="system"){q(d);return}if(d==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?q("dark"):q("light")),typeof window>"u")return;let M=window.matchMedia("(prefers-color-scheme: dark)");try{M.addEventListener("change",({matches:z})=>{q(z?"dark":"light")})}catch{M.addListener(({matches:R})=>{try{q(R?"dark":"light")}catch(F){console.error(F)}})}},[d]),w.useEffect(()=>{C.length<=1&&K(!1)},[C]),w.useEffect(()=>{let M=z=>{var R,F;o.every(H=>z[H]||z.code===H)&&(K(!0),(R=W.current)==null||R.focus()),z.code==="Escape"&&(document.activeElement===W.current||(F=W.current)!=null&&F.contains(document.activeElement))&&K(!1)};return document.addEventListener("keydown",M),()=>document.removeEventListener("keydown",M)},[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":`${E} ${D}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},A.map((M,z)=>{var R;let[F,H]=M.split("-");return C.length?w.createElement("ol",{key:M,dir:x==="auto"?mx():x,tabIndex:-1,ref:W,className:a,"data-sonner-toaster":!0,"data-theme":Y,"data-y-position":F,"data-lifted":B&&C.length>1&&!s,"data-x-position":H,style:{"--front-toast-height":`${((R=j[0])==null?void 0:R.height)||0}px`,"--width":`${oN}px`,"--gap":`${y}px`,...p,...uN(c,l)},onBlur:O=>{G.current&&!O.currentTarget.contains(O.relatedTarget)&&(G.current=!1,I.current&&(I.current.focus({preventScroll:!0}),I.current=null))},onFocus:O=>{O.target instanceof HTMLElement&&O.target.dataset.dismissible==="false"||G.current||(G.current=!0,I.current=O.relatedTarget)},onMouseEnter:()=>K(!0),onMouseMove:()=>K(!0),onMouseLeave:()=>{J||K(!1)},onDragEnd:()=>K(!1),onPointerDown:O=>{O.target instanceof HTMLElement&&O.target.dataset.dismissible==="false"||_(!0)},onPointerUp:()=>_(!1)},C.filter(O=>!O.position&&z===0||O.position===M).map((O,P)=>{var U,Q;return w.createElement(cN,{key:O.id,icons:T,index:P,toast:O,defaultRichColors:f,duration:(U=g==null?void 0:g.duration)!=null?U:m,className:g==null?void 0:g.className,descriptionClassName:g==null?void 0:g.descriptionClassName,invert:n,visibleToasts:v,closeButton:(Q=g==null?void 0:g.closeButton)!=null?Q:i,interacting:J,position:M,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:X,toasts:C.filter(se=>se.position==O.position),heights:j.filter(se=>se.position==O.position),setHeights:L,expandByDefault:s,gap:y,loadingIcon:b,expanded:B,pauseWhenPageIsHidden:S,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})};$.Api=ow,$.ApiClient=rw,$.ApiProvider=du,$.ArtifactRenderer=Fh,$.Badge=Yh,$.Button=Je,$.Card=ml,$.CardContent=ti,$.CardDescription=vl,$.CardHeader=gl,$.CardTitle=xl,$.ChatApi=Jo,$.ChatApp=Kk,$.ChatInput=sp,$.ChatInputRow=ip,$.ChatInterface=Fr,$.ChatProviders=Tr,$.ChatWidget=Yk,$.Command=Al,$.CommandEmpty=_l,$.CommandGroup=Rl,$.CommandInput=Pl,$.CommandItem=Ml,$.CommandList=jl,$.DEFAULT_TIMEOUT_MS=su,$.Dialog=cl,$.DialogContent=Vs,$.DialogHeader=Ks,$.DialogTitle=qs,$.DropdownMenu=Is,$.DropdownMenuContent=xo,$.DropdownMenuItem=Fn,$.DropdownMenuTrigger=Ns,$.FileViewerModal=Th,$.HISTORY_TIMEOUT_MS=iu,$.Input=zl,$.InterruptPartRenderer=wl,$.Label=Am,$.MarkdownContent=fr,$.MessageComponent=ni,$.MessageList=Sl,$.MessageRow=yl,$.NewChatButton=Xk,$.PlotArtifact=$h,$.SETTINGS_STORAGE_KEY=Gi,$.ScrollArea=Bl,$.Select=AE,$.SelectContent=gg,$.SelectItem=xg,$.SelectTrigger=pg,$.SelectValue=PE,$.Separator=yg,$.Sheet=zE,$.SheetContent=Pg,$.SheetDescription=Rg,$.SheetHeader=jg,$.SheetTitle=_g,$.SheetTrigger=HE,$.SimpleChat=qk,$.SimpleJsonView=ei,$.Sonner=fN,$.StreamProgress=Bh,$.Switch=Ng,$.Textarea=Ma,$.ThinkingIndicator=Hh,$.ThreadListItem=Cm,$.ThreadManager=li,$.ThreadStateProvider=zu,$.ThreadsProvider=Su,$.TimelineColumn=Mx,$.Toaster=MI,$.ToolComponent=qh,$.Tooltip=dI,$.TooltipContent=Hg,$.TooltipProvider=uI,$.TooltipTrigger=fI,$.UserTextContent=Uh,$.applySettings=Pw,$.buildCheckpointIndex=lc,$.buildCheckpointPreviewMap=Sx,$.buildLabelParts=Au,$.chatApiClient=Nn,$.collectText=ku,$.createArtifactPreviewFromPlot=ju,$.createArtifactPreviewFromSource=Pu,$.del=Li,$.downloadFileById=lu,$.extractConfigFields=Ci,$.extractToolContent=tr,$.extractToolMeta=Qo,$.fileToBase64=fu,$.formatToolOutput=Tu,$.get=Yt,$.getAgentNameFromMessage=Iu,$.getChatToken=ru,$.getCheckpointForMessage=Cx,$.getCurrentSettings=Aw,$.getDefaultApiConfig=Xu,$.getDefaultChatSettings=Ju,$.getFileContent=Fi,$.getFileInfo=iw,$.getMessageAttemptInfo=cc,$.getMessageDomKey=bl,$.getPreviewForMessage=Si,$.getToolProgress=Wi,$.httpClient=Gt,$.hydrateHistorySnapshots=Yn,$.isEnvelope=hu,$.isFileLike=zi,$.listFiles=cu,$.loadStoredSettings=Zu,$.looksLikeMarkdown=Cu,$.messageSignature=Ui,$.normalizeInterruptId=Hi,$.normalizeMimeType=Nu,$.normalizeToolPayload=_u,$.normalizeToolPayloadValue=Cr,$.onChatTokenChanged=ou,$.parseJsonSafe=Qn,$.post=Xo,$.pretty=er,$.processAttachments=pu,$.put=au,$.readNumber=dc,$.readString=Rn,$.resolveChatBaseUrl=vn,$.sanitizeForDisplay=Sr,$.saveSettings=Qu,$.setChatToken=Yo,$.stringifyTool=Eu,$.toPlainObject=_n,$.unwrap=Dt,$.useApi=no,$.useCheckpointIndex=uc,$.useFilePreview=Wh,$.useHasChatSession=Ew,$.useParsedMessageContent=Vh,$.useShallowStableValue=Ku,$.useStream=qi,$.useStreamingHook=qi,$.useThreadHistoryState=Lu,$.useThreadManagerViewState=Em,$.useThreadState=oo,$.useThreadStateUpdater=Bu,$.useThreads=yr,$.useThreadsState=bu,$.viewFileById=sw,Object.defineProperty($,Symbol.toStringTag,{value:"Module"})});