teodor-new-chat-ui 4.3.412 → 4.3.413

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(B,b){typeof exports=="object"&&typeof module<"u"?b(exports,require("react"),require("@radix-ui/react-slot"),require("class-variance-authority"),require("clsx"),require("tailwind-merge"),require("react-dom"),require("lucide-react")):typeof define=="function"&&define.amd?define(["exports","react","@radix-ui/react-slot","class-variance-authority","clsx","tailwind-merge","react-dom","lucide-react"],b):(B=typeof globalThis<"u"?globalThis:B||self,b(B.NewChatUI={},B.React,B.reactSlot,B.classVarianceAuthority,B.clsx,B.tailwindMerge,B.ReactDOM,B.LucideReact))})(this,function(B,b,Vt,Dr,Xg,Jg,No,ue){"use strict";var MI=Object.defineProperty;var RI=(B,b,Vt)=>b in B?MI(B,b,{enumerable:!0,configurable:!0,writable:!0,value:Vt}):B[b]=Vt;var Gg=(B,b,Vt)=>RI(B,typeof b!="symbol"?b+"":b,Vt);function Xl(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=Xl(b),Lr=Xl(No);function Jl(e,t){var d;let n=[],r=null,o={},s={},i=null,a=null,l=null;if(!(e&&"type"in e&&e.type==="default_message")&&e){const p=e,m=p.checkpointId??null;o=p.additionalKwargs??{},s=p.responseMetadata??{};const f=m?t.checkpointMetaById.get(m)??null:null;i=typeof o.step=="number"?o.step:typeof s.step=="number"?s.step:(f==null?void 0:f.step)??null;const v=typeof o.source=="string"?o.source:typeof s.source=="string"?s.source:(f==null?void 0:f.source)??null;a=v?String(v):null;const g=i!==null&&a?`${i}:${a}`:null;if(g&&t.checkpointIndexByKey.has(g)?n=t.checkpointIndexByKey.get(g)??[]:m&&f&&(n=[f]),r=m??((d=n[0])==null?void 0:d.id)??null,l=m?t.attemptMetaById.get(m)??null:null,!l&&p.role==="user"&&p.id&&t.userMessageIdToAttempts.has(p.id)){const x=t.userMessageIdToAttempts.get(p.id);if(x&&x.length>0){const y=x[0].checkpointId;l=t.attemptMetaById.get(y)??null}}if(!l&&n.length>0){const x=t.attemptMetaById.get(n[0].id);x&&(l=x)}if(l&&l.attemptCount>1){const x=l.baseUserMessageId;if(x){const y=[];for(const[w,S]of t.attemptMetaById.entries())if(S.baseUserMessageId===x){const k=t.checkpointMetaById.get(w);k&&y.push(k)}y.length>0&&(y.sort((w,S)=>{const k=w.createdAt?Date.parse(w.createdAt):0;return(S.createdAt?Date.parse(S.createdAt):0)-k}),n=y)}}}return{checkpointCandidates:n,defaultCheckpointId:r,resolvedStep:i,resolvedSource:a}}function Zl(e,t){return b.useMemo(()=>Jl(e,t),[e,t])}function Ql(e){const t=new Map;for(const o of e){const s=o.messages??[];if(!o.checkpointId)continue;let i;for(let l=s.length-1;l>=0;l--){const c=s[l];if(c.role==="user"&&c.id){i=c.id;break}}if(!i)continue;const a=t.get(i)??[];a.push({checkpoint:o,timestamp:Date.parse(o.createdAt??"0")}),t.set(i,a)}const n=new Map,r=new Map;for(const[o,s]of t.entries()){if(!s.length)continue;const i=s.length;i>1&&s.sort((l,c)=>c.timestamp-l.timestamp);const a=[];for(let l=0;l<s.length;l++){const{checkpoint:c}=s[l],d=c.checkpointId;if(!d)continue;const p={attemptIndex:l,attemptCount:i,isLatestAttempt:l===0,baseUserMessageId:o};n.set(d,p),i>1&&a.push({checkpointId:d,attemptIndex:p.attemptIndex,attemptCount:p.attemptCount,isLatestAttempt:p.isLatestAttempt})}a.length&&r.set(o,a)}return{attemptMetaById:n,userMessageIdToAttempts:r}}const ec=120;function Zg(e){if(!Array.isArray(e))return"";const t=e.filter(r=>!!(r&&r.type==="text")).map(r=>(r.text??"").trim()).filter(Boolean);if(!t.length)return"";const n=t.join(" ").replace(/\s+/g," ").trim();return n?n.length>ec?`${n.slice(0,ec-3)}…`:n:""}function ui(e){return Zg(e.content)||""}function Qg(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=ui(o);s&&t.set(r.checkpointId,s)}}return t}function tc(e){const t=new Map,n=new Map,r=[],o=new Map;for(let p=0;p<e.length;p++){const m=e[p],f=m.checkpointId,v=f??`cp-${p}`,g=m.metadata??{},x=typeof g.step=="number"?g.step:null,y=typeof g.source=="string"?g.source:null,w={id:v,step:x,source:y,createdAt:m.createdAt??null,namespace:m.checkpointNs??null,parentId:m.parentId??null};if(f&&(t.set(f,w),x!==null&&y)){const T=`${x}:${y}`,E=n.get(T);E?E.push(w):n.set(T,[w])}let S=null,k=null;const C=Array.isArray(m.messages)?m.messages:[];for(const T of C)T.role==="user"&&(k||(k=T),T.id&&(S=T.id));if(f&&k){const T=ui(k);T&&o.set(f,T)}r.push({id:v,messageId:S,step:x,source:y,createdAt:m.createdAt??null,next:m.next&&m.next.length>0?String(m.next[0]):null,parentConfig:m.parentConfig??null})}const{attemptMetaById:s,userMessageIdToAttempts:i}=Ql(e),a=new Map;for(const[p,m]of t.entries()){const f=s.get(p);f?a.set(p,{...m,attemptIndex:f.attemptIndex,attemptCount:f.attemptCount,isLatestAttempt:f.isLatestAttempt,baseUserMessageId:f.baseUserMessageId??null}):a.set(p,{...m,attemptIndex:0,attemptCount:1,isLatestAttempt:!0,baseUserMessageId:null})}return{checkpoints:e,checkpointMetaById:t,checkpointIndexByKey:n,attemptMetaById:a,userMessageIdToAttempts:i,timeline:r,messagePreviews:o,getLatest:()=>{const p=r[0];if(p)return t.get(p.id)},getCheckpoint:p=>t.get(p),getAttempts:p=>i.get(p)??[]}}function nc(e){return b.useMemo(()=>tc(e),[e])}function cr(e){if(!(!e||typeof e!="object"||Array.isArray(e)))return{...e}}function Vn(e,t){if(e)for(const n of t){const r=e[n];if(typeof r=="string"&&r.trim())return r.trim()}}function rc(e,t){if(!e)return null;for(const n of t){const r=e[n];if(typeof r=="number"&&Number.isFinite(r))return r}return null}function di(e){const t=cr(e);if(t)return cr(t.configurable)??t}function Nn(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)=>ex(s,i)).filter(s=>!!s)].sort((s,i)=>oc(i.createdAt)-oc(s.createdAt)),o=r[0]??null;return{threadId:(e==null?void 0:e.threadId)??"",latest:o,checkpoints:r,interrupt:(o==null?void 0:o.interrupt)??null}}function ex(e,t){var w;if(!e)return null;const r=(Array.isArray((w=e.values)==null?void 0:w.messages)?e.values.messages:[]).filter(S=>!!(S&&typeof S=="object"&&typeof S.role=="string")),o=cr(e.metadata)??{},s=di(e.config),i=cr(e.parent_config??e.parentConfig),a=di(i),l=Vn(s,["checkpoint_id","checkpointId"]),c=Vn(s,["checkpoint_ns","checkpointNs"]),d=Vn(a,["checkpoint_id","checkpointId"]),p=Vn(a,["checkpoint_id","checkpointId"])??null,m=Vn(a,["checkpoint_ns","checkpointNs"])??null,f=cr(e.config),v=Array.isArray(e.tasks)?e.tasks.map(S=>({...S})):e.tasks??null,g=Array.isArray(e.next)?[...e.next]:e.next??null,x=typeof e.created_at=="string"&&e.created_at.trim()?e.created_at:typeof e.createdAt=="string"&&e.createdAt.trim()?e.createdAt:new Date(Date.now()-t).toISOString(),y={...o,step:rc(o,["step"])??0,source:Vn(o,["source"])??null};return{checkpointId:l??null,checkpointNs:c??null,createdAt:x,parentId:d??null,messages:r,nextCursor:p,nextCursorNs:m,interrupt:tx(r,t),metadata:y,config:f??null,parentConfig:i??null,next:g,tasks:v}}function tx(e,t){return nx(e,t)}function nx(e,t){var n;for(let r=e.length-1;r>=0;r--){const o=((n=e[r])==null?void 0:n.content)??[];for(let s=o.length-1;s>=0;s--){const i=o[s];if((i==null?void 0:i.type)==="interrupt"){const a=i;return{id:typeof a.id=="string"&&a.id.trim()?a.id:`interrupt-${t}-${r}-${s}`,value:a.value}}}}return null}function oc(e){if(!e)return 0;const t=Date.parse(e);return Number.isFinite(t)?t:0}var fi={exports:{}},$r={};/**
1
+ (function(F,b){typeof exports=="object"&&typeof module<"u"?b(exports,require("react"),require("@radix-ui/react-slot"),require("class-variance-authority"),require("clsx"),require("tailwind-merge"),require("react-dom"),require("lucide-react")):typeof define=="function"&&define.amd?define(["exports","react","@radix-ui/react-slot","class-variance-authority","clsx","tailwind-merge","react-dom","lucide-react"],b):(F=typeof globalThis<"u"?globalThis:F||self,b(F.NewChatUI={},F.React,F.reactSlot,F.classVarianceAuthority,F.clsx,F.tailwindMerge,F.ReactDOM,F.LucideReact))})(this,function(F,b,Vt,Dr,Jg,Zg,No,ue){"use strict";var MI=Object.defineProperty;var RI=(F,b,Vt)=>b in F?MI(F,b,{enumerable:!0,configurable:!0,writable:!0,value:Vt}):F[b]=Vt;var Yg=(F,b,Vt)=>RI(F,typeof b!="symbol"?b+"":b,Vt);function Xl(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=Xl(b),Lr=Xl(No);function Jl(e,t){var d;let n=[],r=null,o={},s={},i=null,a=null,l=null;if(!(e&&"type"in e&&e.type==="default_message")&&e){const p=e,m=p.checkpointId??null;o=p.additionalKwargs??{},s=p.responseMetadata??{};const f=m?t.checkpointMetaById.get(m)??null:null;i=typeof o.step=="number"?o.step:typeof s.step=="number"?s.step:(f==null?void 0:f.step)??null;const v=typeof o.source=="string"?o.source:typeof s.source=="string"?s.source:(f==null?void 0:f.source)??null;a=v?String(v):null;const g=i!==null&&a?`${i}:${a}`:null;if(g&&t.checkpointIndexByKey.has(g)?n=t.checkpointIndexByKey.get(g)??[]:m&&f&&(n=[f]),r=m??((d=n[0])==null?void 0:d.id)??null,l=m?t.attemptMetaById.get(m)??null:null,!l&&p.role==="user"&&p.id&&t.userMessageIdToAttempts.has(p.id)){const x=t.userMessageIdToAttempts.get(p.id);if(x&&x.length>0){const y=x[0].checkpointId;l=t.attemptMetaById.get(y)??null}}if(!l&&n.length>0){const x=t.attemptMetaById.get(n[0].id);x&&(l=x)}if(l&&l.attemptCount>1){const x=l.baseUserMessageId;if(x){const y=[];for(const[w,S]of t.attemptMetaById.entries())if(S.baseUserMessageId===x){const k=t.checkpointMetaById.get(w);k&&y.push(k)}y.length>0&&(y.sort((w,S)=>{const k=w.createdAt?Date.parse(w.createdAt):0;return(S.createdAt?Date.parse(S.createdAt):0)-k}),n=y)}}}return{checkpointCandidates:n,defaultCheckpointId:r,resolvedStep:i,resolvedSource:a}}function Zl(e,t){return b.useMemo(()=>Jl(e,t),[e,t])}function Ql(e){const t=new Map;for(const o of e){const s=o.messages??[];if(!o.checkpointId)continue;let i;for(let l=s.length-1;l>=0;l--){const c=s[l];if(c.role==="user"&&c.id){i=c.id;break}}if(!i)continue;const a=t.get(i)??[];a.push({checkpoint:o,timestamp:Date.parse(o.createdAt??"0")}),t.set(i,a)}const n=new Map,r=new Map;for(const[o,s]of t.entries()){if(!s.length)continue;const i=s.length;i>1&&s.sort((l,c)=>c.timestamp-l.timestamp);const a=[];for(let l=0;l<s.length;l++){const{checkpoint:c}=s[l],d=c.checkpointId;if(!d)continue;const p={attemptIndex:l,attemptCount:i,isLatestAttempt:l===0,baseUserMessageId:o};n.set(d,p),i>1&&a.push({checkpointId:d,attemptIndex:p.attemptIndex,attemptCount:p.attemptCount,isLatestAttempt:p.isLatestAttempt})}a.length&&r.set(o,a)}return{attemptMetaById:n,userMessageIdToAttempts:r}}const ec=120;function Qg(e){if(!Array.isArray(e))return"";const t=e.filter(r=>!!(r&&r.type==="text")).map(r=>(r.text??"").trim()).filter(Boolean);if(!t.length)return"";const n=t.join(" ").replace(/\s+/g," ").trim();return n?n.length>ec?`${n.slice(0,ec-3)}…`:n:""}function ui(e){return Qg(e.content)||""}function ex(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=ui(o);s&&t.set(r.checkpointId,s)}}return t}function tc(e){const t=new Map,n=new Map,r=[],o=new Map;for(let p=0;p<e.length;p++){const m=e[p],f=m.checkpointId,v=f??`cp-${p}`,g=m.metadata??{},x=typeof g.step=="number"?g.step:null,y=typeof g.source=="string"?g.source:null,w={id:v,step:x,source:y,createdAt:m.createdAt??null,namespace:m.checkpointNs??null,parentId:m.parentId??null};if(f&&(t.set(f,w),x!==null&&y)){const T=`${x}:${y}`,E=n.get(T);E?E.push(w):n.set(T,[w])}let S=null,k=null;const C=Array.isArray(m.messages)?m.messages:[];for(const T of C)T.role==="user"&&(k||(k=T),T.id&&(S=T.id));if(f&&k){const T=ui(k);T&&o.set(f,T)}r.push({id:v,messageId:S,step:x,source:y,createdAt:m.createdAt??null,next:m.next&&m.next.length>0?String(m.next[0]):null,parentConfig:m.parentConfig??null})}const{attemptMetaById:s,userMessageIdToAttempts:i}=Ql(e),a=new Map;for(const[p,m]of t.entries()){const f=s.get(p);f?a.set(p,{...m,attemptIndex:f.attemptIndex,attemptCount:f.attemptCount,isLatestAttempt:f.isLatestAttempt,baseUserMessageId:f.baseUserMessageId??null}):a.set(p,{...m,attemptIndex:0,attemptCount:1,isLatestAttempt:!0,baseUserMessageId:null})}return{checkpoints:e,checkpointMetaById:t,checkpointIndexByKey:n,attemptMetaById:a,userMessageIdToAttempts:i,timeline:r,messagePreviews:o,getLatest:()=>{const p=r[0];if(p)return t.get(p.id)},getCheckpoint:p=>t.get(p),getAttempts:p=>i.get(p)??[]}}function nc(e){return b.useMemo(()=>tc(e),[e])}function cr(e){if(!(!e||typeof e!="object"||Array.isArray(e)))return{...e}}function Vn(e,t){if(e)for(const n of t){const r=e[n];if(typeof r=="string"&&r.trim())return r.trim()}}function rc(e,t){if(!e)return null;for(const n of t){const r=e[n];if(typeof r=="number"&&Number.isFinite(r))return r}return null}function di(e){const t=cr(e);if(t)return cr(t.configurable)??t}function Nn(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)=>tx(s,i)).filter(s=>!!s)].sort((s,i)=>oc(i.createdAt)-oc(s.createdAt)),o=r[0]??null;return{threadId:(e==null?void 0:e.threadId)??"",latest:o,checkpoints:r,interrupt:(o==null?void 0:o.interrupt)??null}}function tx(e,t){var w;if(!e)return null;const r=(Array.isArray((w=e.values)==null?void 0:w.messages)?e.values.messages:[]).filter(S=>!!(S&&typeof S=="object"&&typeof S.role=="string")),o=cr(e.metadata)??{},s=di(e.config),i=cr(e.parent_config??e.parentConfig),a=di(i),l=Vn(s,["checkpoint_id","checkpointId"]),c=Vn(s,["checkpoint_ns","checkpointNs"]),d=Vn(a,["checkpoint_id","checkpointId"]),p=Vn(a,["checkpoint_id","checkpointId"])??null,m=Vn(a,["checkpoint_ns","checkpointNs"])??null,f=cr(e.config),v=Array.isArray(e.tasks)?e.tasks.map(S=>({...S})):e.tasks??null,g=Array.isArray(e.next)?[...e.next]:e.next??null,x=typeof e.created_at=="string"&&e.created_at.trim()?e.created_at:typeof e.createdAt=="string"&&e.createdAt.trim()?e.createdAt:new Date(Date.now()-t).toISOString(),y={...o,step:rc(o,["step"])??0,source:Vn(o,["source"])??null};return{checkpointId:l??null,checkpointNs:c??null,createdAt:x,parentId:d??null,messages:r,nextCursor:p,nextCursorNs:m,interrupt:nx(r,t),metadata:y,config:f??null,parentConfig:i??null,next:g,tasks:v}}function nx(e,t){return rx(e,t)}function rx(e,t){var n;for(let r=e.length-1;r>=0;r--){const o=((n=e[r])==null?void 0:n.content)??[];for(let s=o.length-1;s>=0;s--){const i=o[s];if((i==null?void 0:i.type)==="interrupt"){const a=i;return{id:typeof a.id=="string"&&a.id.trim()?a.id:`interrupt-${t}-${r}-${s}`,value:a.value}}}}return null}function oc(e){if(!e)return 0;const t=Date.parse(e);return Number.isFinite(t)?t:0}var fi={exports:{}},$r={};/**
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 sc;function rx(){if(sc)return $r;sc=1;var e=b,t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,o=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function i(a,l,c){var d,p={},m=null,f=null;c!==void 0&&(m=""+c),l.key!==void 0&&(m=""+l.key),l.ref!==void 0&&(f=l.ref);for(d in l)r.call(l,d)&&!s.hasOwnProperty(d)&&(p[d]=l[d]);if(a&&a.defaultProps)for(d in l=a.defaultProps,l)p[d]===void 0&&(p[d]=l[d]);return{$$typeof:t,type:a,key:m,ref:f,props:p,_owner:o.current}}return $r.Fragment=n,$r.jsx=i,$r.jsxs=i,$r}var Fr={};/**
9
+ */var sc;function ox(){if(sc)return $r;sc=1;var e=b,t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,o=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function i(a,l,c){var d,p={},m=null,f=null;c!==void 0&&(m=""+c),l.key!==void 0&&(m=""+l.key),l.ref!==void 0&&(f=l.ref);for(d in l)r.call(l,d)&&!s.hasOwnProperty(d)&&(p[d]=l[d]);if(a&&a.defaultProps)for(d in l=a.defaultProps,l)p[d]===void 0&&(p[d]=l[d]);return{$$typeof:t,type:a,key:m,ref:f,props:p,_owner:o.current}}return $r.Fragment=n,$r.jsx=i,$r.jsxs=i,$r}var Fr={};/**
10
10
  * @license React
11
11
  * react-jsx-runtime.development.js
12
12
  *
@@ -14,30 +14,30 @@
14
14
  *
15
15
  * This source code is licensed under the MIT license found in the
16
16
  * LICENSE file in the root directory of this source tree.
17
- */var ic;function ox(){return ic||(ic=1,process.env.NODE_ENV!=="production"&&function(){var e=b,t=Symbol.for("react.element"),n=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),a=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),p=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),f=Symbol.for("react.offscreen"),v=Symbol.iterator,g="@@iterator";function x(A){if(A===null||typeof A!="object")return null;var te=v&&A[v]||A[g];return typeof te=="function"?te:null}var y=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function w(A){{for(var te=arguments.length,fe=new Array(te>1?te-1:0),Ne=1;Ne<te;Ne++)fe[Ne-1]=arguments[Ne];S("error",A,fe)}}function S(A,te,fe){{var Ne=y.ReactDebugCurrentFrame,ce=Ne.getStackAddendum();ce!==""&&(te+="%s",fe=fe.concat([ce]));var ve=fe.map(function(pe){return String(pe)});ve.unshift("Warning: "+te),Function.prototype.apply.call(console[A],console,ve)}}var k=!1,C=!1,T=!1,E=!1,_=!1,R;R=Symbol.for("react.module.reference");function L(A){return!!(typeof A=="string"||typeof A=="function"||A===r||A===s||_||A===o||A===c||A===d||E||A===f||k||C||T||typeof A=="object"&&A!==null&&(A.$$typeof===m||A.$$typeof===p||A.$$typeof===i||A.$$typeof===a||A.$$typeof===l||A.$$typeof===R||A.getModuleId!==void 0))}function H(A,te,fe){var Ne=A.displayName;if(Ne)return Ne;var ce=te.displayName||te.name||"";return ce!==""?fe+"("+ce+")":fe}function K(A){return A.displayName||"Context"}function F(A){if(A==null)return null;if(typeof A.tag=="number"&&w("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof A=="function")return A.displayName||A.name||null;if(typeof A=="string")return A;switch(A){case r:return"Fragment";case n:return"Portal";case s:return"Profiler";case o:return"StrictMode";case c:return"Suspense";case d:return"SuspenseList"}if(typeof A=="object")switch(A.$$typeof){case a:var te=A;return K(te)+".Consumer";case i:var fe=A;return K(fe._context)+".Provider";case l:return H(A,A.render,"ForwardRef");case p:var Ne=A.displayName||null;return Ne!==null?Ne:F(A.type)||"Memo";case m:{var ce=A,ve=ce._payload,pe=ce._init;try{return F(pe(ve))}catch{return null}}}return null}var I=Object.assign,W=0,N,U,O,j,q,J,P;function M(){}M.__reactDisabledLog=!0;function G(){{if(W===0){N=console.log,U=console.info,O=console.warn,j=console.error,q=console.group,J=console.groupCollapsed,P=console.groupEnd;var A={configurable:!0,enumerable:!0,value:M,writable:!0};Object.defineProperties(console,{info:A,log:A,warn:A,error:A,group:A,groupCollapsed:A,groupEnd:A})}W++}}function Z(){{if(W--,W===0){var A={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:I({},A,{value:N}),info:I({},A,{value:U}),warn:I({},A,{value:O}),error:I({},A,{value:j}),group:I({},A,{value:q}),groupCollapsed:I({},A,{value:J}),groupEnd:I({},A,{value:P})})}W<0&&w("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var se=y.ReactCurrentDispatcher,V;function D(A,te,fe){{if(V===void 0)try{throw Error()}catch(ce){var Ne=ce.stack.trim().match(/\n( *(at )?)/);V=Ne&&Ne[1]||""}return`
17
+ */var ic;function sx(){return ic||(ic=1,process.env.NODE_ENV!=="production"&&function(){var e=b,t=Symbol.for("react.element"),n=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),a=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),p=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),f=Symbol.for("react.offscreen"),v=Symbol.iterator,g="@@iterator";function x(A){if(A===null||typeof A!="object")return null;var te=v&&A[v]||A[g];return typeof te=="function"?te:null}var y=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function w(A){{for(var te=arguments.length,fe=new Array(te>1?te-1:0),Ne=1;Ne<te;Ne++)fe[Ne-1]=arguments[Ne];S("error",A,fe)}}function S(A,te,fe){{var Ne=y.ReactDebugCurrentFrame,ce=Ne.getStackAddendum();ce!==""&&(te+="%s",fe=fe.concat([ce]));var ve=fe.map(function(pe){return String(pe)});ve.unshift("Warning: "+te),Function.prototype.apply.call(console[A],console,ve)}}var k=!1,C=!1,T=!1,E=!1,_=!1,R;R=Symbol.for("react.module.reference");function L(A){return!!(typeof A=="string"||typeof A=="function"||A===r||A===s||_||A===o||A===c||A===d||E||A===f||k||C||T||typeof A=="object"&&A!==null&&(A.$$typeof===m||A.$$typeof===p||A.$$typeof===i||A.$$typeof===a||A.$$typeof===l||A.$$typeof===R||A.getModuleId!==void 0))}function H(A,te,fe){var Ne=A.displayName;if(Ne)return Ne;var ce=te.displayName||te.name||"";return ce!==""?fe+"("+ce+")":fe}function K(A){return A.displayName||"Context"}function B(A){if(A==null)return null;if(typeof A.tag=="number"&&w("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof A=="function")return A.displayName||A.name||null;if(typeof A=="string")return A;switch(A){case r:return"Fragment";case n:return"Portal";case s:return"Profiler";case o:return"StrictMode";case c:return"Suspense";case d:return"SuspenseList"}if(typeof A=="object")switch(A.$$typeof){case a:var te=A;return K(te)+".Consumer";case i:var fe=A;return K(fe._context)+".Provider";case l:return H(A,A.render,"ForwardRef");case p:var Ne=A.displayName||null;return Ne!==null?Ne:B(A.type)||"Memo";case m:{var ce=A,ve=ce._payload,pe=ce._init;try{return B(pe(ve))}catch{return null}}}return null}var I=Object.assign,W=0,N,U,O,j,q,J,P;function M(){}M.__reactDisabledLog=!0;function G(){{if(W===0){N=console.log,U=console.info,O=console.warn,j=console.error,q=console.group,J=console.groupCollapsed,P=console.groupEnd;var A={configurable:!0,enumerable:!0,value:M,writable:!0};Object.defineProperties(console,{info:A,log:A,warn:A,error:A,group:A,groupCollapsed:A,groupEnd:A})}W++}}function Z(){{if(W--,W===0){var A={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:I({},A,{value:N}),info:I({},A,{value:U}),warn:I({},A,{value:O}),error:I({},A,{value:j}),group:I({},A,{value:q}),groupCollapsed:I({},A,{value:J}),groupEnd:I({},A,{value:P})})}W<0&&w("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var se=y.ReactCurrentDispatcher,V;function D(A,te,fe){{if(V===void 0)try{throw Error()}catch(ce){var Ne=ce.stack.trim().match(/\n( *(at )?)/);V=Ne&&Ne[1]||""}return`
18
18
  `+V+A}}var X=!1,Q;{var ae=typeof WeakMap=="function"?WeakMap:Map;Q=new ae}function $(A,te){if(!A||X)return"";{var fe=Q.get(A);if(fe!==void 0)return fe}var Ne;X=!0;var ce=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var ve;ve=se.current,se.current=null,G();try{if(te){var pe=function(){throw Error()};if(Object.defineProperty(pe.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(pe,[])}catch(Wt){Ne=Wt}Reflect.construct(A,[],pe)}else{try{pe.call()}catch(Wt){Ne=Wt}A.call(pe.prototype)}}else{try{throw Error()}catch(Wt){Ne=Wt}A()}}catch(Wt){if(Wt&&Ne&&typeof Wt.stack=="string"){for(var Te=Wt.stack.split(`
19
19
  `),bt=Ne.stack.split(`
20
20
  `),Je=Te.length-1,yt=bt.length-1;Je>=1&&yt>=0&&Te[Je]!==bt[yt];)yt--;for(;Je>=1&&yt>=0;Je--,yt--)if(Te[Je]!==bt[yt]){if(Je!==1||yt!==1)do if(Je--,yt--,yt<0||Te[Je]!==bt[yt]){var rn=`
21
- `+Te[Je].replace(" at new "," at ");return A.displayName&&rn.includes("<anonymous>")&&(rn=rn.replace("<anonymous>",A.displayName)),typeof A=="function"&&Q.set(A,rn),rn}while(Je>=1&&yt>=0);break}}}finally{X=!1,se.current=ve,Z(),Error.prepareStackTrace=ce}var Or=A?A.displayName||A.name:"",lr=Or?D(Or):"";return typeof A=="function"&&Q.set(A,lr),lr}function re(A,te,fe){return $(A,!1)}function we(A){var te=A.prototype;return!!(te&&te.isReactComponent)}function de(A,te,fe){if(A==null)return"";if(typeof A=="function")return $(A,we(A));if(typeof A=="string")return D(A);switch(A){case c:return D("Suspense");case d:return D("SuspenseList")}if(typeof A=="object")switch(A.$$typeof){case l:return re(A.render);case p:return de(A.type,te,fe);case m:{var Ne=A,ce=Ne._payload,ve=Ne._init;try{return de(ve(ce),te,fe)}catch{}}}return""}var xe=Object.prototype.hasOwnProperty,Ee={},Be=y.ReactDebugCurrentFrame;function We(A){if(A){var te=A._owner,fe=de(A.type,A._source,te?te.type:null);Be.setExtraStackFrame(fe)}else Be.setExtraStackFrame(null)}function je(A,te,fe,Ne,ce){{var ve=Function.call.bind(xe);for(var pe in A)if(ve(A,pe)){var Te=void 0;try{if(typeof A[pe]!="function"){var bt=Error((Ne||"React class")+": "+fe+" type `"+pe+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof A[pe]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw bt.name="Invariant Violation",bt}Te=A[pe](te,pe,Ne,fe,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(Je){Te=Je}Te&&!(Te instanceof Error)&&(We(ce),w("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",Ne||"React class",fe,pe,typeof Te),We(null)),Te instanceof Error&&!(Te.message in Ee)&&(Ee[Te.message]=!0,We(ce),w("Failed %s type: %s",fe,Te.message),We(null))}}}var Ve=Array.isArray;function Xe(A){return Ve(A)}function ze(A){{var te=typeof Symbol=="function"&&Symbol.toStringTag,fe=te&&A[Symbol.toStringTag]||A.constructor.name||"Object";return fe}}function Ge(A){try{return rt(A),!1}catch{return!0}}function rt(A){return""+A}function nt(A){if(Ge(A))return w("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",ze(A)),rt(A)}var et=y.ReactCurrentOwner,xt={key:!0,ref:!0,__self:!0,__source:!0},vt,dt;function Et(A){if(xe.call(A,"ref")){var te=Object.getOwnPropertyDescriptor(A,"ref").get;if(te&&te.isReactWarning)return!1}return A.ref!==void 0}function Dt(A){if(xe.call(A,"key")){var te=Object.getOwnPropertyDescriptor(A,"key").get;if(te&&te.isReactWarning)return!1}return A.key!==void 0}function $e(A,te){typeof A.ref=="string"&&et.current}function Pt(A,te){{var fe=function(){vt||(vt=!0,w("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",te))};fe.isReactWarning=!0,Object.defineProperty(A,"key",{get:fe,configurable:!0})}}function nn(A,te){{var fe=function(){dt||(dt=!0,w("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",te))};fe.isReactWarning=!0,Object.defineProperty(A,"ref",{get:fe,configurable:!0})}}var Me=function(A,te,fe,Ne,ce,ve,pe){var Te={$$typeof:t,type:A,key:te,ref:fe,props:pe,_owner:ve};return Te._store={},Object.defineProperty(Te._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(Te,"_self",{configurable:!1,enumerable:!1,writable:!1,value:Ne}),Object.defineProperty(Te,"_source",{configurable:!1,enumerable:!1,writable:!1,value:ce}),Object.freeze&&(Object.freeze(Te.props),Object.freeze(Te)),Te};function Ke(A,te,fe,Ne,ce){{var ve,pe={},Te=null,bt=null;fe!==void 0&&(nt(fe),Te=""+fe),Dt(te)&&(nt(te.key),Te=""+te.key),Et(te)&&(bt=te.ref,$e(te,ce));for(ve in te)xe.call(te,ve)&&!xt.hasOwnProperty(ve)&&(pe[ve]=te[ve]);if(A&&A.defaultProps){var Je=A.defaultProps;for(ve in Je)pe[ve]===void 0&&(pe[ve]=Je[ve])}if(Te||bt){var yt=typeof A=="function"?A.displayName||A.name||"Unknown":A;Te&&Pt(pe,yt),bt&&nn(pe,yt)}return Me(A,Te,bt,ce,Ne,et.current,pe)}}var Ct=y.ReactCurrentOwner,Ze=y.ReactDebugCurrentFrame;function pt(A){if(A){var te=A._owner,fe=de(A.type,A._source,te?te.type:null);Ze.setExtraStackFrame(fe)}else Ze.setExtraStackFrame(null)}var le;le=!1;function Y(A){return typeof A=="object"&&A!==null&&A.$$typeof===t}function ge(){{if(Ct.current){var A=F(Ct.current.type);if(A)return`
21
+ `+Te[Je].replace(" at new "," at ");return A.displayName&&rn.includes("<anonymous>")&&(rn=rn.replace("<anonymous>",A.displayName)),typeof A=="function"&&Q.set(A,rn),rn}while(Je>=1&&yt>=0);break}}}finally{X=!1,se.current=ve,Z(),Error.prepareStackTrace=ce}var Or=A?A.displayName||A.name:"",lr=Or?D(Or):"";return typeof A=="function"&&Q.set(A,lr),lr}function re(A,te,fe){return $(A,!1)}function we(A){var te=A.prototype;return!!(te&&te.isReactComponent)}function de(A,te,fe){if(A==null)return"";if(typeof A=="function")return $(A,we(A));if(typeof A=="string")return D(A);switch(A){case c:return D("Suspense");case d:return D("SuspenseList")}if(typeof A=="object")switch(A.$$typeof){case l:return re(A.render);case p:return de(A.type,te,fe);case m:{var Ne=A,ce=Ne._payload,ve=Ne._init;try{return de(ve(ce),te,fe)}catch{}}}return""}var xe=Object.prototype.hasOwnProperty,Ee={},Be=y.ReactDebugCurrentFrame;function We(A){if(A){var te=A._owner,fe=de(A.type,A._source,te?te.type:null);Be.setExtraStackFrame(fe)}else Be.setExtraStackFrame(null)}function je(A,te,fe,Ne,ce){{var ve=Function.call.bind(xe);for(var pe in A)if(ve(A,pe)){var Te=void 0;try{if(typeof A[pe]!="function"){var bt=Error((Ne||"React class")+": "+fe+" type `"+pe+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof A[pe]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw bt.name="Invariant Violation",bt}Te=A[pe](te,pe,Ne,fe,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(Je){Te=Je}Te&&!(Te instanceof Error)&&(We(ce),w("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",Ne||"React class",fe,pe,typeof Te),We(null)),Te instanceof Error&&!(Te.message in Ee)&&(Ee[Te.message]=!0,We(ce),w("Failed %s type: %s",fe,Te.message),We(null))}}}var Ve=Array.isArray;function Xe(A){return Ve(A)}function ze(A){{var te=typeof Symbol=="function"&&Symbol.toStringTag,fe=te&&A[Symbol.toStringTag]||A.constructor.name||"Object";return fe}}function Ge(A){try{return rt(A),!1}catch{return!0}}function rt(A){return""+A}function nt(A){if(Ge(A))return w("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",ze(A)),rt(A)}var et=y.ReactCurrentOwner,xt={key:!0,ref:!0,__self:!0,__source:!0},vt,dt;function Et(A){if(xe.call(A,"ref")){var te=Object.getOwnPropertyDescriptor(A,"ref").get;if(te&&te.isReactWarning)return!1}return A.ref!==void 0}function Dt(A){if(xe.call(A,"key")){var te=Object.getOwnPropertyDescriptor(A,"key").get;if(te&&te.isReactWarning)return!1}return A.key!==void 0}function $e(A,te){typeof A.ref=="string"&&et.current}function Pt(A,te){{var fe=function(){vt||(vt=!0,w("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",te))};fe.isReactWarning=!0,Object.defineProperty(A,"key",{get:fe,configurable:!0})}}function nn(A,te){{var fe=function(){dt||(dt=!0,w("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",te))};fe.isReactWarning=!0,Object.defineProperty(A,"ref",{get:fe,configurable:!0})}}var Me=function(A,te,fe,Ne,ce,ve,pe){var Te={$$typeof:t,type:A,key:te,ref:fe,props:pe,_owner:ve};return Te._store={},Object.defineProperty(Te._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(Te,"_self",{configurable:!1,enumerable:!1,writable:!1,value:Ne}),Object.defineProperty(Te,"_source",{configurable:!1,enumerable:!1,writable:!1,value:ce}),Object.freeze&&(Object.freeze(Te.props),Object.freeze(Te)),Te};function Ke(A,te,fe,Ne,ce){{var ve,pe={},Te=null,bt=null;fe!==void 0&&(nt(fe),Te=""+fe),Dt(te)&&(nt(te.key),Te=""+te.key),Et(te)&&(bt=te.ref,$e(te,ce));for(ve in te)xe.call(te,ve)&&!xt.hasOwnProperty(ve)&&(pe[ve]=te[ve]);if(A&&A.defaultProps){var Je=A.defaultProps;for(ve in Je)pe[ve]===void 0&&(pe[ve]=Je[ve])}if(Te||bt){var yt=typeof A=="function"?A.displayName||A.name||"Unknown":A;Te&&Pt(pe,yt),bt&&nn(pe,yt)}return Me(A,Te,bt,ce,Ne,et.current,pe)}}var Ct=y.ReactCurrentOwner,Ze=y.ReactDebugCurrentFrame;function pt(A){if(A){var te=A._owner,fe=de(A.type,A._source,te?te.type:null);Ze.setExtraStackFrame(fe)}else Ze.setExtraStackFrame(null)}var le;le=!1;function Y(A){return typeof A=="object"&&A!==null&&A.$$typeof===t}function ge(){{if(Ct.current){var A=B(Ct.current.type);if(A)return`
22
22
 
23
23
  Check the render method of \``+A+"`."}return""}}function it(A){return""}var Ce={};function Oe(A){{var te=ge();if(!te){var fe=typeof A=="string"?A:A.displayName||A.name;fe&&(te=`
24
24
 
25
- Check the top-level render call using <`+fe+">.")}return te}}function qe(A,te){{if(!A._store||A._store.validated||A.key!=null)return;A._store.validated=!0;var fe=Oe(te);if(Ce[fe])return;Ce[fe]=!0;var Ne="";A&&A._owner&&A._owner!==Ct.current&&(Ne=" It was passed a child from "+F(A._owner.type)+"."),pt(A),w('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',fe,Ne),pt(null)}}function Tt(A,te){{if(typeof A!="object")return;if(Xe(A))for(var fe=0;fe<A.length;fe++){var Ne=A[fe];Y(Ne)&&qe(Ne,te)}else if(Y(A))A._store&&(A._store.validated=!0);else if(A){var ce=x(A);if(typeof ce=="function"&&ce!==A.entries)for(var ve=ce.call(A),pe;!(pe=ve.next()).done;)Y(pe.value)&&qe(pe.value,te)}}}function He(A){{var te=A.type;if(te==null||typeof te=="string")return;var fe;if(typeof te=="function")fe=te.propTypes;else if(typeof te=="object"&&(te.$$typeof===l||te.$$typeof===p))fe=te.propTypes;else return;if(fe){var Ne=F(te);je(fe,A.props,"prop",Ne,A)}else if(te.PropTypes!==void 0&&!le){le=!0;var ce=F(te);w("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",ce||"Unknown")}typeof te.getDefaultProps=="function"&&!te.getDefaultProps.isReactClassApproved&&w("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function ft(A){{for(var te=Object.keys(A.props),fe=0;fe<te.length;fe++){var Ne=te[fe];if(Ne!=="children"&&Ne!=="key"){pt(A),w("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",Ne),pt(null);break}}A.ref!==null&&(pt(A),w("Invalid attribute `ref` supplied to `React.Fragment`."),pt(null))}}var Fe={};function tt(A,te,fe,Ne,ce,ve){{var pe=L(A);if(!pe){var Te="";(A===void 0||typeof A=="object"&&A!==null&&Object.keys(A).length===0)&&(Te+=" 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 bt=it();bt?Te+=bt:Te+=ge();var Je;A===null?Je="null":Xe(A)?Je="array":A!==void 0&&A.$$typeof===t?(Je="<"+(F(A.type)||"Unknown")+" />",Te=" Did you accidentally export a JSX literal instead of a component?"):Je=typeof A,w("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",Je,Te)}var yt=Ke(A,te,fe,ce,ve);if(yt==null)return yt;if(pe){var rn=te.children;if(rn!==void 0)if(Ne)if(Xe(rn)){for(var Or=0;Or<rn.length;Or++)Tt(rn[Or],A);Object.freeze&&Object.freeze(rn)}else w("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Tt(rn,A)}if(xe.call(te,"key")){var lr=F(A),Wt=Object.keys(te).filter(function(PI){return PI!=="key"}),Yl=Wt.length>0?"{key: someKey, "+Wt.join(": ..., ")+": ...}":"{key: someKey}";if(!Fe[lr+Yl]){var _I=Wt.length>0?"{"+Wt.join(": ..., ")+": ...}":"{}";w(`A props object containing a "key" prop is being spread into JSX:
25
+ Check the top-level render call using <`+fe+">.")}return te}}function qe(A,te){{if(!A._store||A._store.validated||A.key!=null)return;A._store.validated=!0;var fe=Oe(te);if(Ce[fe])return;Ce[fe]=!0;var Ne="";A&&A._owner&&A._owner!==Ct.current&&(Ne=" It was passed a child from "+B(A._owner.type)+"."),pt(A),w('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',fe,Ne),pt(null)}}function Tt(A,te){{if(typeof A!="object")return;if(Xe(A))for(var fe=0;fe<A.length;fe++){var Ne=A[fe];Y(Ne)&&qe(Ne,te)}else if(Y(A))A._store&&(A._store.validated=!0);else if(A){var ce=x(A);if(typeof ce=="function"&&ce!==A.entries)for(var ve=ce.call(A),pe;!(pe=ve.next()).done;)Y(pe.value)&&qe(pe.value,te)}}}function He(A){{var te=A.type;if(te==null||typeof te=="string")return;var fe;if(typeof te=="function")fe=te.propTypes;else if(typeof te=="object"&&(te.$$typeof===l||te.$$typeof===p))fe=te.propTypes;else return;if(fe){var Ne=B(te);je(fe,A.props,"prop",Ne,A)}else if(te.PropTypes!==void 0&&!le){le=!0;var ce=B(te);w("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",ce||"Unknown")}typeof te.getDefaultProps=="function"&&!te.getDefaultProps.isReactClassApproved&&w("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function ft(A){{for(var te=Object.keys(A.props),fe=0;fe<te.length;fe++){var Ne=te[fe];if(Ne!=="children"&&Ne!=="key"){pt(A),w("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",Ne),pt(null);break}}A.ref!==null&&(pt(A),w("Invalid attribute `ref` supplied to `React.Fragment`."),pt(null))}}var Fe={};function tt(A,te,fe,Ne,ce,ve){{var pe=L(A);if(!pe){var Te="";(A===void 0||typeof A=="object"&&A!==null&&Object.keys(A).length===0)&&(Te+=" 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 bt=it();bt?Te+=bt:Te+=ge();var Je;A===null?Je="null":Xe(A)?Je="array":A!==void 0&&A.$$typeof===t?(Je="<"+(B(A.type)||"Unknown")+" />",Te=" Did you accidentally export a JSX literal instead of a component?"):Je=typeof A,w("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",Je,Te)}var yt=Ke(A,te,fe,ce,ve);if(yt==null)return yt;if(pe){var rn=te.children;if(rn!==void 0)if(Ne)if(Xe(rn)){for(var Or=0;Or<rn.length;Or++)Tt(rn[Or],A);Object.freeze&&Object.freeze(rn)}else w("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Tt(rn,A)}if(xe.call(te,"key")){var lr=B(A),Wt=Object.keys(te).filter(function(PI){return PI!=="key"}),Yl=Wt.length>0?"{key: someKey, "+Wt.join(": ..., ")+": ...}":"{key: someKey}";if(!Fe[lr+Yl]){var _I=Wt.length>0?"{"+Wt.join(": ..., ")+": ...}":"{}";w(`A props object containing a "key" prop is being spread into JSX:
26
26
  let props = %s;
27
27
  <%s {...props} />
28
28
  React keys must be passed directly to JSX without using spread:
29
29
  let props = %s;
30
- <%s key={someKey} {...props} />`,Yl,lr,_I,lr),Fe[lr+Yl]=!0}}return A===r?ft(yt):He(yt),yt}}function Ut(A,te,fe){return tt(A,te,fe,!0)}function ql(A,te,fe){return tt(A,te,fe,!1)}var Gl=ql,ci=Ut;Fr.Fragment=r,Fr.jsx=Gl,Fr.jsxs=ci}()),Fr}process.env.NODE_ENV==="production"?fi.exports=rx():fi.exports=ox();var u=fi.exports;const sx=({timelineEntries:e,activeCheckpointId:t,onSelectCheckpoint:n,messagePreviews:r,className:o,onHoverStart:s,onHoverEnd:i})=>{const a=e??[],l=a.length>0,c=b.useMemo(()=>l?[...a].reverse():[],[a,l]),d=t??(a.length?a[a.length-1].id:null);if(!l)return null;const m=["w-32 flex-shrink-0 flex-col border-r border-border/40 pr-2 flex bg-white text-gray-900 dark:bg-slate-900 dark:text-slate-100",o].filter(Boolean).join(" ");return u.jsxs("div",{className:m,onMouseEnter:s,onMouseLeave:i,children:[u.jsxs("div",{className:"relative flex-1 overflow-y-auto pt-4 pb-2 pr-1",children:[u.jsx("div",{className:"absolute left-0 right-0 top-1 px-2 pb-3 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:u.jsx("span",{children:"Timeline"})}),u.jsx("div",{className:"pointer-events-none absolute left-3 top-0 bottom-0 w-px bg-border/40"}),u.jsx("div",{className:"flex flex-col gap-3 pt-6 pr-2",children:c.map(f=>{const v=d===f.id,g=(r==null?void 0:r.get(f.id))??null;return u.jsxs("button",{type:"button",disabled:!n,onClick:()=>n==null?void 0:n(f.id),className:`relative flex items-start gap-2 text-left text-[11px] transition ${v?"text-primary":"text-muted-foreground"} ${n?"hover:text-foreground":"cursor-default opacity-70"}`,children:[u.jsx("span",{className:`mt-1 inline-flex h-3 w-3 items-center justify-center rounded-full border ${v?"border-primary bg-primary/10 text-primary":"border-border bg-background"}`,children:u.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${v?"bg-primary":"bg-border"}`})}),u.jsxs("span",{className:"flex-1",children:[u.jsx("span",{className:"block font-medium leading-tight",children:f.label||"User input"}),u.jsxs("span",{className:"text-[9px] uppercase tracking-wide text-muted-foreground/70",children:[f.step!==null?`STEP ${f.step}`:"STEP —",f.next?` - ${f.next}`:""]}),g&&u.jsx("p",{className:"text-[10px] text-muted-foreground/80 mt-1 line-clamp-2",title:g,children:g})]})]},f.id)})})]}),n&&u.jsx("button",{type:"button",onClick:()=>n==null?void 0:n(null),className:"mt-auto mb-3 rounded-md border border-border/70 px-2 py-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground transition hover:border-foreground/60 hover:text-foreground",children:"Latest"})]})};function ac(e,t){return function(){return e.apply(t,arguments)}}const{toString:ix}=Object.prototype,{getPrototypeOf:pi}=Object,{iterator:Ao,toStringTag:lc}=Symbol,jo=(e=>t=>{const n=ix.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),on=e=>(e=e.toLowerCase(),t=>jo(t)===e),_o=e=>t=>typeof t===e,{isArray:ur}=Array,dr=_o("undefined");function Br(e){return e!==null&&!dr(e)&&e.constructor!==null&&!dr(e.constructor)&&Lt(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const cc=on("ArrayBuffer");function ax(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&cc(e.buffer),t}const lx=_o("string"),Lt=_o("function"),uc=_o("number"),zr=e=>e!==null&&typeof e=="object",cx=e=>e===!0||e===!1,Po=e=>{if(jo(e)!=="object")return!1;const t=pi(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(lc in e)&&!(Ao in e)},ux=e=>{if(!zr(e)||Br(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},dx=on("Date"),fx=on("File"),px=on("Blob"),hx=on("FileList"),mx=e=>zr(e)&&Lt(e.pipe),gx=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||Lt(e.append)&&((t=jo(e))==="formdata"||t==="object"&&Lt(e.toString)&&e.toString()==="[object FormData]"))},xx=on("URLSearchParams"),[vx,wx,bx,yx]=["ReadableStream","Request","Response","Headers"].map(on),Sx=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Hr(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,o;if(typeof e!="object"&&(e=[e]),ur(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{if(Br(e))return;const s=n?Object.getOwnPropertyNames(e):Object.keys(e),i=s.length;let a;for(r=0;r<i;r++)a=s[r],t.call(null,e[a],a,e)}}function dc(e,t){if(Br(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 Kn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,fc=e=>!dr(e)&&e!==Kn;function hi(){const{caseless:e,skipUndefined:t}=fc(this)&&this||{},n={},r=(o,s)=>{const i=e&&dc(n,s)||s;Po(n[i])&&Po(o)?n[i]=hi(n[i],o):Po(o)?n[i]=hi({},o):ur(o)?n[i]=o.slice():(!t||!dr(o))&&(n[i]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&Hr(arguments[o],r);return n}const Cx=(e,t,n,{allOwnKeys:r}={})=>(Hr(t,(o,s)=>{n&&Lt(o)?e[s]=ac(o,n):e[s]=o},{allOwnKeys:r}),e),Tx=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),kx=(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)},Ex=(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&&pi(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},Ix=(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},Nx=e=>{if(!e)return null;if(ur(e))return e;let t=e.length;if(!uc(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Ax=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&pi(Uint8Array)),jx=(e,t)=>{const r=(e&&e[Ao]).call(e);let o;for(;(o=r.next())&&!o.done;){const s=o.value;t.call(e,s[0],s[1])}},_x=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},Px=on("HTMLFormElement"),Mx=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),pc=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),Rx=on("RegExp"),hc=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};Hr(n,(o,s)=>{let i;(i=t(o,s,e))!==!1&&(r[s]=i||o)}),Object.defineProperties(e,r)},Ox=e=>{hc(e,(t,n)=>{if(Lt(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(Lt(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+"'")})}})},Dx=(e,t)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return ur(e)?r(e):r(String(e).split(t)),n},Lx=()=>{},$x=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function Fx(e){return!!(e&&Lt(e.append)&&e[lc]==="FormData"&&e[Ao])}const Bx=e=>{const t=new Array(10),n=(r,o)=>{if(zr(r)){if(t.indexOf(r)>=0)return;if(Br(r))return r;if(!("toJSON"in r)){t[o]=r;const s=ur(r)?[]:{};return Hr(r,(i,a)=>{const l=n(i,o+1);!dr(l)&&(s[a]=l)}),t[o]=void 0,s}}return r};return n(e,0)},zx=on("AsyncFunction"),Hx=e=>e&&(zr(e)||Lt(e))&&Lt(e.then)&&Lt(e.catch),mc=((e,t)=>e?setImmediate:t?((n,r)=>(Kn.addEventListener("message",({source:o,data:s})=>{o===Kn&&s===n&&r.length&&r.shift()()},!1),o=>{r.push(o),Kn.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",Lt(Kn.postMessage)),Ux=typeof queueMicrotask<"u"?queueMicrotask.bind(Kn):typeof process<"u"&&process.nextTick||mc,z={isArray:ur,isArrayBuffer:cc,isBuffer:Br,isFormData:gx,isArrayBufferView:ax,isString:lx,isNumber:uc,isBoolean:cx,isObject:zr,isPlainObject:Po,isEmptyObject:ux,isReadableStream:vx,isRequest:wx,isResponse:bx,isHeaders:yx,isUndefined:dr,isDate:dx,isFile:fx,isBlob:px,isRegExp:Rx,isFunction:Lt,isStream:mx,isURLSearchParams:xx,isTypedArray:Ax,isFileList:hx,forEach:Hr,merge:hi,extend:Cx,trim:Sx,stripBOM:Tx,inherits:kx,toFlatObject:Ex,kindOf:jo,kindOfTest:on,endsWith:Ix,toArray:Nx,forEachEntry:jx,matchAll:_x,isHTMLForm:Px,hasOwnProperty:pc,hasOwnProp:pc,reduceDescriptors:hc,freezeMethods:Ox,toObjectSet:Dx,toCamelCase:Mx,noop:Lx,toFiniteNumber:$x,findKey:dc,global:Kn,isContextDefined:fc,isSpecCompliantForm:Fx,toJSONObject:Bx,isAsyncFn:zx,isThenable:Hx,setImmediate:mc,asap:Ux,isIterable:e=>e!=null&&Lt(e[Ao])};function Pe(e,t,n,r,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),o&&(this.response=o,this.status=o.status?o.status:null)}z.inherits(Pe,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:z.toJSONObject(this.config),code:this.code,status:this.status}}});const gc=Pe.prototype,xc={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{xc[e]={value:e}}),Object.defineProperties(Pe,xc),Object.defineProperty(gc,"isAxiosError",{value:!0}),Pe.from=(e,t,n,r,o,s)=>{const i=Object.create(gc);z.toFlatObject(e,i,function(d){return d!==Error.prototype},c=>c!=="isAxiosError");const a=e&&e.message?e.message:"Error",l=t==null&&e?e.code:t;return Pe.call(i,a,l,n,r,o),e&&i.cause==null&&Object.defineProperty(i,"cause",{value:e,configurable:!0}),i.name=e&&e.name||"Error",s&&Object.assign(i,s),i};const Wx=null;function mi(e){return z.isPlainObject(e)||z.isArray(e)}function vc(e){return z.endsWith(e,"[]")?e.slice(0,-2):e}function wc(e,t,n){return e?e.concat(t).map(function(o,s){return o=vc(o),!n&&s?"["+o+"]":o}).join(n?".":""):t}function Vx(e){return z.isArray(e)&&!e.some(mi)}const Kx=z.toFlatObject(z,{},null,function(t){return/^is[A-Z]/.test(t)});function Mo(e,t,n){if(!z.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=z.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(g,x){return!z.isUndefined(x[g])});const r=n.metaTokens,o=n.visitor||d,s=n.dots,i=n.indexes,l=(n.Blob||typeof Blob<"u"&&Blob)&&z.isSpecCompliantForm(t);if(!z.isFunction(o))throw new TypeError("visitor must be a function");function c(v){if(v===null)return"";if(z.isDate(v))return v.toISOString();if(z.isBoolean(v))return v.toString();if(!l&&z.isBlob(v))throw new Pe("Blob is not supported. Use a Buffer instead.");return z.isArrayBuffer(v)||z.isTypedArray(v)?l&&typeof Blob=="function"?new Blob([v]):Buffer.from(v):v}function d(v,g,x){let y=v;if(v&&!x&&typeof v=="object"){if(z.endsWith(g,"{}"))g=r?g:g.slice(0,-2),v=JSON.stringify(v);else if(z.isArray(v)&&Vx(v)||(z.isFileList(v)||z.endsWith(g,"[]"))&&(y=z.toArray(v)))return g=vc(g),y.forEach(function(S,k){!(z.isUndefined(S)||S===null)&&t.append(i===!0?wc([g],k,s):i===null?g:g+"[]",c(S))}),!1}return mi(v)?!0:(t.append(wc(x,g,s),c(v)),!1)}const p=[],m=Object.assign(Kx,{defaultVisitor:d,convertValue:c,isVisitable:mi});function f(v,g){if(!z.isUndefined(v)){if(p.indexOf(v)!==-1)throw Error("Circular reference detected in "+g.join("."));p.push(v),z.forEach(v,function(y,w){(!(z.isUndefined(y)||y===null)&&o.call(t,y,z.isString(w)?w.trim():w,g,m))===!0&&f(y,g?g.concat(w):[w])}),p.pop()}}if(!z.isObject(e))throw new TypeError("data must be an object");return f(e),t}function bc(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function gi(e,t){this._pairs=[],e&&Mo(e,this,t)}const yc=gi.prototype;yc.append=function(t,n){this._pairs.push([t,n])},yc.toString=function(t){const n=t?function(r){return t.call(this,r,bc)}:bc;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function qx(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Sc(e,t,n){if(!t)return e;const r=n&&n.encode||qx;z.isFunction(n)&&(n={serialize:n});const o=n&&n.serialize;let s;if(o?s=o(t,n):s=z.isURLSearchParams(t)?t.toString():new gi(t,n).toString(r),s){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}class Cc{constructor(){this.handlers=[]}use(t,n,r){return this.handlers.push({fulfilled:t,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){z.forEach(this.handlers,function(r){r!==null&&t(r)})}}const Tc={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Gx={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:gi,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},xi=typeof window<"u"&&typeof document<"u",vi=typeof navigator=="object"&&navigator||void 0,Yx=xi&&(!vi||["ReactNative","NativeScript","NS"].indexOf(vi.product)<0),Xx=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Jx=xi&&window.location.href||"http://localhost",It={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:xi,hasStandardBrowserEnv:Yx,hasStandardBrowserWebWorkerEnv:Xx,navigator:vi,origin:Jx},Symbol.toStringTag,{value:"Module"})),...Gx};function Zx(e,t){return Mo(e,new It.classes.URLSearchParams,{visitor:function(n,r,o,s){return It.isNode&&z.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function Qx(e){return z.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function ev(e){const t={},n=Object.keys(e);let r;const o=n.length;let s;for(r=0;r<o;r++)s=n[r],t[s]=e[s];return t}function kc(e){function t(n,r,o,s){let i=n[s++];if(i==="__proto__")return!0;const a=Number.isFinite(+i),l=s>=n.length;return i=!i&&z.isArray(o)?o.length:i,l?(z.hasOwnProp(o,i)?o[i]=[o[i],r]:o[i]=r,!a):((!o[i]||!z.isObject(o[i]))&&(o[i]=[]),t(n,r,o[i],s)&&z.isArray(o[i])&&(o[i]=ev(o[i])),!a)}if(z.isFormData(e)&&z.isFunction(e.entries)){const n={};return z.forEachEntry(e,(r,o)=>{t(Qx(r),o,n,0)}),n}return null}function tv(e,t,n){if(z.isString(e))try{return(t||JSON.parse)(e),z.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const Ur={transitional:Tc,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",o=r.indexOf("application/json")>-1,s=z.isObject(t);if(s&&z.isHTMLForm(t)&&(t=new FormData(t)),z.isFormData(t))return o?JSON.stringify(kc(t)):t;if(z.isArrayBuffer(t)||z.isBuffer(t)||z.isStream(t)||z.isFile(t)||z.isBlob(t)||z.isReadableStream(t))return t;if(z.isArrayBufferView(t))return t.buffer;if(z.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 Zx(t,this.formSerializer).toString();if((a=z.isFileList(t))||r.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return Mo(a?{"files[]":t}:t,l&&new l,this.formSerializer)}}return s||o?(n.setContentType("application/json",!1),tv(t)):t}],transformResponse:[function(t){const n=this.transitional||Ur.transitional,r=n&&n.forcedJSONParsing,o=this.responseType==="json";if(z.isResponse(t)||z.isReadableStream(t))return t;if(t&&z.isString(t)&&(r&&!this.responseType||o)){const i=!(n&&n.silentJSONParsing)&&o;try{return JSON.parse(t,this.parseReviver)}catch(a){if(i)throw a.name==="SyntaxError"?Pe.from(a,Pe.ERR_BAD_RESPONSE,this,null,this.response):a}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:It.classes.FormData,Blob:It.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};z.forEach(["delete","get","head","post","put","patch"],e=>{Ur.headers[e]={}});const nv=z.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"]),rv=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]&&nv[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},Ec=Symbol("internals");function Wr(e){return e&&String(e).trim().toLowerCase()}function Ro(e){return e===!1||e==null?e:z.isArray(e)?e.map(Ro):String(e)}function ov(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}const sv=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function wi(e,t,n,r,o){if(z.isFunction(r))return r.call(this,t,n);if(o&&(t=n),!!z.isString(t)){if(z.isString(r))return t.indexOf(r)!==-1;if(z.isRegExp(r))return r.test(t)}}function iv(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function av(e,t){const n=z.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 $t=class{constructor(t){t&&this.set(t)}set(t,n,r){const o=this;function s(a,l,c){const d=Wr(l);if(!d)throw new Error("header name must be a non-empty string");const p=z.findKey(o,d);(!p||o[p]===void 0||c===!0||c===void 0&&o[p]!==!1)&&(o[p||l]=Ro(a))}const i=(a,l)=>z.forEach(a,(c,d)=>s(c,d,l));if(z.isPlainObject(t)||t instanceof this.constructor)i(t,n);else if(z.isString(t)&&(t=t.trim())&&!sv(t))i(rv(t),n);else if(z.isObject(t)&&z.isIterable(t)){let a={},l,c;for(const d of t){if(!z.isArray(d))throw TypeError("Object iterator must return a key-value pair");a[c=d[0]]=(l=a[c])?z.isArray(l)?[...l,d[1]]:[l,d[1]]:d[1]}i(a,n)}else t!=null&&s(n,t,r);return this}get(t,n){if(t=Wr(t),t){const r=z.findKey(this,t);if(r){const o=this[r];if(!n)return o;if(n===!0)return ov(o);if(z.isFunction(n))return n.call(this,o,r);if(z.isRegExp(n))return n.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=Wr(t),t){const r=z.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||wi(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let o=!1;function s(i){if(i=Wr(i),i){const a=z.findKey(r,i);a&&(!n||wi(r,r[a],a,n))&&(delete r[a],o=!0)}}return z.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||wi(this,this[s],s,t,!0))&&(delete this[s],o=!0)}return o}normalize(t){const n=this,r={};return z.forEach(this,(o,s)=>{const i=z.findKey(r,s);if(i){n[i]=Ro(o),delete n[s];return}const a=t?iv(s):String(s).trim();a!==s&&delete n[s],n[a]=Ro(o),r[a]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return z.forEach(this,(r,o)=>{r!=null&&r!==!1&&(n[o]=t&&z.isArray(r)?r.join(", "):r)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,n])=>t+": "+n).join(`
32
- `)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const r=new this(t);return n.forEach(o=>r.set(o)),r}static accessor(t){const r=(this[Ec]=this[Ec]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=Wr(i);r[a]||(av(o,i),r[a]=!0)}return z.isArray(t)?t.forEach(s):s(t),this}};$t.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),z.reduceDescriptors($t.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),z.freezeMethods($t);function bi(e,t){const n=this||Ur,r=t||n,o=$t.from(r.headers);let s=r.data;return z.forEach(e,function(a){s=a.call(n,s,o.normalize(),t?t.status:void 0)}),o.normalize(),s}function Ic(e){return!!(e&&e.__CANCEL__)}function fr(e,t,n){Pe.call(this,e??"canceled",Pe.ERR_CANCELED,t,n),this.name="CanceledError"}z.inherits(fr,Pe,{__CANCEL__:!0});function Nc(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new Pe("Request failed with status code "+n.status,[Pe.ERR_BAD_REQUEST,Pe.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function lv(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function cv(e,t){e=e||10;const n=new Array(e),r=new Array(e);let o=0,s=0,i;return t=t!==void 0?t:1e3,function(l){const c=Date.now(),d=r[s];i||(i=c),n[o]=l,r[o]=c;let p=s,m=0;for(;p!==o;)m+=n[p++],p=p%e;if(o=(o+1)%e,o===s&&(s=(s+1)%e),c-i<t)return;const f=d&&c-d;return f?Math.round(m*1e3/f):void 0}}function uv(e,t){let n=0,r=1e3/t,o,s;const i=(c,d=Date.now())=>{n=d,o=null,s&&(clearTimeout(s),s=null),e(...c)};return[(...c)=>{const d=Date.now(),p=d-n;p>=r?i(c,d):(o=c,s||(s=setTimeout(()=>{s=null,i(o)},r-p)))},()=>o&&i(o)]}const Oo=(e,t,n=3)=>{let r=0;const o=cv(50,250);return uv(s=>{const i=s.loaded,a=s.lengthComputable?s.total:void 0,l=i-r,c=o(l),d=i<=a;r=i;const p={loaded:i,total:a,progress:a?i/a:void 0,bytes:l,rate:c||void 0,estimated:c&&a&&d?(a-i)/c:void 0,event:s,lengthComputable:a!=null,[t?"download":"upload"]:!0};e(p)},n)},Ac=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},jc=e=>(...t)=>z.asap(()=>e(...t)),dv=It.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,It.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(It.origin),It.navigator&&/(msie|trident)/i.test(It.navigator.userAgent)):()=>!0,fv=It.hasStandardBrowserEnv?{write(e,t,n,r,o,s){const i=[e+"="+encodeURIComponent(t)];z.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),z.isString(r)&&i.push("path="+r),z.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 pv(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function hv(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function _c(e,t,n){let r=!pv(t);return e&&(r||n==!1)?hv(e,t):t}const Pc=e=>e instanceof $t?{...e}:e;function qn(e,t){t=t||{};const n={};function r(c,d,p,m){return z.isPlainObject(c)&&z.isPlainObject(d)?z.merge.call({caseless:m},c,d):z.isPlainObject(d)?z.merge({},d):z.isArray(d)?d.slice():d}function o(c,d,p,m){if(z.isUndefined(d)){if(!z.isUndefined(c))return r(void 0,c,p,m)}else return r(c,d,p,m)}function s(c,d){if(!z.isUndefined(d))return r(void 0,d)}function i(c,d){if(z.isUndefined(d)){if(!z.isUndefined(c))return r(void 0,c)}else return r(void 0,d)}function a(c,d,p){if(p in t)return r(c,d);if(p in e)return r(void 0,c)}const l={url:s,method:s,data:s,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:a,headers:(c,d,p)=>o(Pc(c),Pc(d),p,!0)};return z.forEach(Object.keys({...e,...t}),function(d){const p=l[d]||o,m=p(e[d],t[d],d);z.isUndefined(m)&&p!==a||(n[d]=m)}),n}const Mc=e=>{const t=qn({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=$t.from(i),t.url=Sc(_c(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&i.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),z.isFormData(n)){if(It.hasStandardBrowserEnv||It.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(z.isFunction(n.getHeaders)){const l=n.getHeaders(),c=["content-type","content-length"];Object.entries(l).forEach(([d,p])=>{c.includes(d.toLowerCase())&&i.set(d,p)})}}if(It.hasStandardBrowserEnv&&(r&&z.isFunction(r)&&(r=r(t)),r||r!==!1&&dv(t.url))){const l=o&&s&&fv.read(s);l&&i.set(o,l)}return t},mv=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=Mc(e);let s=o.data;const i=$t.from(o.headers).normalize();let{responseType:a,onUploadProgress:l,onDownloadProgress:c}=o,d,p,m,f,v;function g(){f&&f(),v&&v(),o.cancelToken&&o.cancelToken.unsubscribe(d),o.signal&&o.signal.removeEventListener("abort",d)}let x=new XMLHttpRequest;x.open(o.method.toUpperCase(),o.url,!0),x.timeout=o.timeout;function y(){if(!x)return;const S=$t.from("getAllResponseHeaders"in x&&x.getAllResponseHeaders()),C={data:!a||a==="text"||a==="json"?x.responseText:x.response,status:x.status,statusText:x.statusText,headers:S,config:e,request:x};Nc(function(E){n(E),g()},function(E){r(E),g()},C),x=null}"onloadend"in x?x.onloadend=y:x.onreadystatechange=function(){!x||x.readyState!==4||x.status===0&&!(x.responseURL&&x.responseURL.indexOf("file:")===0)||setTimeout(y)},x.onabort=function(){x&&(r(new Pe("Request aborted",Pe.ECONNABORTED,e,x)),x=null)},x.onerror=function(k){const C=k&&k.message?k.message:"Network Error",T=new Pe(C,Pe.ERR_NETWORK,e,x);T.event=k||null,r(T),x=null},x.ontimeout=function(){let k=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const C=o.transitional||Tc;o.timeoutErrorMessage&&(k=o.timeoutErrorMessage),r(new Pe(k,C.clarifyTimeoutError?Pe.ETIMEDOUT:Pe.ECONNABORTED,e,x)),x=null},s===void 0&&i.setContentType(null),"setRequestHeader"in x&&z.forEach(i.toJSON(),function(k,C){x.setRequestHeader(C,k)}),z.isUndefined(o.withCredentials)||(x.withCredentials=!!o.withCredentials),a&&a!=="json"&&(x.responseType=o.responseType),c&&([m,v]=Oo(c,!0),x.addEventListener("progress",m)),l&&x.upload&&([p,f]=Oo(l),x.upload.addEventListener("progress",p),x.upload.addEventListener("loadend",f)),(o.cancelToken||o.signal)&&(d=S=>{x&&(r(!S||S.type?new fr(null,e,x):S),x.abort(),x=null)},o.cancelToken&&o.cancelToken.subscribe(d),o.signal&&(o.signal.aborted?d():o.signal.addEventListener("abort",d)));const w=lv(o.url);if(w&&It.protocols.indexOf(w)===-1){r(new Pe("Unsupported protocol "+w+":",Pe.ERR_BAD_REQUEST,e));return}x.send(s||null)})},gv=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let r=new AbortController,o;const s=function(c){if(!o){o=!0,a();const d=c instanceof Error?c:this.reason;r.abort(d instanceof Pe?d:new fr(d instanceof Error?d.message:d))}};let i=t&&setTimeout(()=>{i=null,s(new Pe(`timeout ${t} of ms exceeded`,Pe.ETIMEDOUT))},t);const a=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(c=>{c.unsubscribe?c.unsubscribe(s):c.removeEventListener("abort",s)}),e=null)};e.forEach(c=>c.addEventListener("abort",s));const{signal:l}=r;return l.unsubscribe=()=>z.asap(a),l}},xv=function*(e,t){let n=e.byteLength;if(n<t){yield e;return}let r=0,o;for(;r<n;)o=r+t,yield e.slice(r,o),r=o},vv=async function*(e,t){for await(const n of wv(e))yield*xv(n,t)},wv=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()}},Rc=(e,t,n,r)=>{const o=vv(e,t);let s=0,i,a=l=>{i||(i=!0,r&&r(l))};return new ReadableStream({async pull(l){try{const{done:c,value:d}=await o.next();if(c){a(),l.close();return}let p=d.byteLength;if(n){let m=s+=p;n(m)}l.enqueue(new Uint8Array(d))}catch(c){throw a(c),c}},cancel(l){return a(l),o.return()}},{highWaterMark:2})},Oc=64*1024,{isFunction:Do}=z,bv=(({Request:e,Response:t})=>({Request:e,Response:t}))(z.global),{ReadableStream:Dc,TextEncoder:Lc}=z.global,$c=(e,...t)=>{try{return!!e(...t)}catch{return!1}},yv=e=>{e=z.merge.call({skipUndefined:!0},bv,e);const{fetch:t,Request:n,Response:r}=e,o=t?Do(t):typeof fetch=="function",s=Do(n),i=Do(r);if(!o)return!1;const a=o&&Do(Dc),l=o&&(typeof Lc=="function"?(v=>g=>v.encode(g))(new Lc):async v=>new Uint8Array(await new n(v).arrayBuffer())),c=s&&a&&$c(()=>{let v=!1;const g=new n(It.origin,{body:new Dc,method:"POST",get duplex(){return v=!0,"half"}}).headers.has("Content-Type");return v&&!g}),d=i&&a&&$c(()=>z.isReadableStream(new r("").body)),p={stream:d&&(v=>v.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(v=>{!p[v]&&(p[v]=(g,x)=>{let y=g&&g[v];if(y)return y.call(g);throw new Pe(`Response type '${v}' is not supported`,Pe.ERR_NOT_SUPPORT,x)})});const m=async v=>{if(v==null)return 0;if(z.isBlob(v))return v.size;if(z.isSpecCompliantForm(v))return(await new n(It.origin,{method:"POST",body:v}).arrayBuffer()).byteLength;if(z.isArrayBufferView(v)||z.isArrayBuffer(v))return v.byteLength;if(z.isURLSearchParams(v)&&(v=v+""),z.isString(v))return(await l(v)).byteLength},f=async(v,g)=>{const x=z.toFiniteNumber(v.getContentLength());return x??m(g)};return async v=>{let{url:g,method:x,data:y,signal:w,cancelToken:S,timeout:k,onDownloadProgress:C,onUploadProgress:T,responseType:E,headers:_,withCredentials:R="same-origin",fetchOptions:L}=Mc(v),H=t||fetch;E=E?(E+"").toLowerCase():"text";let K=gv([w,S&&S.toAbortSignal()],k),F=null;const I=K&&K.unsubscribe&&(()=>{K.unsubscribe()});let W;try{if(T&&c&&x!=="get"&&x!=="head"&&(W=await f(_,y))!==0){let J=new n(g,{method:"POST",body:y,duplex:"half"}),P;if(z.isFormData(y)&&(P=J.headers.get("content-type"))&&_.setContentType(P),J.body){const[M,G]=Ac(W,Oo(jc(T)));y=Rc(J.body,Oc,M,G)}}z.isString(R)||(R=R?"include":"omit");const N=s&&"credentials"in n.prototype,U={...L,signal:K,method:x.toUpperCase(),headers:_.normalize().toJSON(),body:y,duplex:"half",credentials:N?R:void 0};F=s&&new n(g,U);let O=await(s?H(F,L):H(g,U));const j=d&&(E==="stream"||E==="response");if(d&&(C||j&&I)){const J={};["status","statusText","headers"].forEach(Z=>{J[Z]=O[Z]});const P=z.toFiniteNumber(O.headers.get("content-length")),[M,G]=C&&Ac(P,Oo(jc(C),!0))||[];O=new r(Rc(O.body,Oc,M,()=>{G&&G(),I&&I()}),J)}E=E||"text";let q=await p[z.findKey(p,E)||"text"](O,v);return!j&&I&&I(),await new Promise((J,P)=>{Nc(J,P,{data:q,headers:$t.from(O.headers),status:O.status,statusText:O.statusText,config:v,request:F})})}catch(N){throw I&&I(),N&&N.name==="TypeError"&&/Load failed|fetch/i.test(N.message)?Object.assign(new Pe("Network Error",Pe.ERR_NETWORK,v,F),{cause:N.cause||N}):Pe.from(N,N&&N.code,v,F)}}},Sv=new Map,Fc=e=>{let t=e?e.env:{};const{fetch:n,Request:r,Response:o}=t,s=[r,o,n];let i=s.length,a=i,l,c,d=Sv;for(;a--;)l=s[a],c=d.get(l),c===void 0&&d.set(l,c=a?new Map:yv(t)),d=c;return c};Fc();const yi={http:Wx,xhr:mv,fetch:{get:Fc}};z.forEach(yi,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Bc=e=>`- ${e}`,Cv=e=>z.isFunction(e)||e===null||e===!1,zc={getAdapter:(e,t)=>{e=z.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,!Cv(r)&&(o=yi[(a=String(r)).toLowerCase()],o===void 0))throw new Pe(`Unknown adapter '${a}'`);if(o&&(z.isFunction(o)||(o=o.get(t))))break;s[a||"#"+i]=o}if(!o){const i=Object.entries(s).map(([l,c])=>`adapter ${l} `+(c===!1?"is not supported by the environment":"is not available in the build"));let a=n?i.length>1?`since :
30
+ <%s key={someKey} {...props} />`,Yl,lr,_I,lr),Fe[lr+Yl]=!0}}return A===r?ft(yt):He(yt),yt}}function Ut(A,te,fe){return tt(A,te,fe,!0)}function ql(A,te,fe){return tt(A,te,fe,!1)}var Gl=ql,ci=Ut;Fr.Fragment=r,Fr.jsx=Gl,Fr.jsxs=ci}()),Fr}process.env.NODE_ENV==="production"?fi.exports=ox():fi.exports=sx();var u=fi.exports;const ix=({timelineEntries:e,activeCheckpointId:t,onSelectCheckpoint:n,messagePreviews:r,className:o,onHoverStart:s,onHoverEnd:i})=>{const a=e??[],l=a.length>0,c=b.useMemo(()=>l?[...a].reverse():[],[a,l]),d=t??(a.length?a[a.length-1].id:null);if(!l)return null;const m=["w-32 flex-shrink-0 flex-col border-r border-border/40 pr-2 flex bg-white text-gray-900 dark:bg-slate-900 dark:text-slate-100",o].filter(Boolean).join(" ");return u.jsxs("div",{className:m,onMouseEnter:s,onMouseLeave:i,children:[u.jsxs("div",{className:"relative flex-1 overflow-y-auto pt-4 pb-2 pr-1",children:[u.jsx("div",{className:"absolute left-0 right-0 top-1 px-2 pb-3 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:u.jsx("span",{children:"Timeline"})}),u.jsx("div",{className:"pointer-events-none absolute left-3 top-0 bottom-0 w-px bg-border/40"}),u.jsx("div",{className:"flex flex-col gap-3 pt-6 pr-2",children:c.map(f=>{const v=d===f.id,g=(r==null?void 0:r.get(f.id))??null;return u.jsxs("button",{type:"button",disabled:!n,onClick:()=>n==null?void 0:n(f.id),className:`relative flex items-start gap-2 text-left text-[11px] transition ${v?"text-primary":"text-muted-foreground"} ${n?"hover:text-foreground":"cursor-default opacity-70"}`,children:[u.jsx("span",{className:`mt-1 inline-flex h-3 w-3 items-center justify-center rounded-full border ${v?"border-primary bg-primary/10 text-primary":"border-border bg-background"}`,children:u.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${v?"bg-primary":"bg-border"}`})}),u.jsxs("span",{className:"flex-1",children:[u.jsx("span",{className:"block font-medium leading-tight",children:f.label||"User input"}),u.jsxs("span",{className:"text-[9px] uppercase tracking-wide text-muted-foreground/70",children:[f.step!==null?`STEP ${f.step}`:"STEP —",f.next?` - ${f.next}`:""]}),g&&u.jsx("p",{className:"text-[10px] text-muted-foreground/80 mt-1 line-clamp-2",title:g,children:g})]})]},f.id)})})]}),n&&u.jsx("button",{type:"button",onClick:()=>n==null?void 0:n(null),className:"mt-auto mb-3 rounded-md border border-border/70 px-2 py-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground transition hover:border-foreground/60 hover:text-foreground",children:"Latest"})]})};function ac(e,t){return function(){return e.apply(t,arguments)}}const{toString:ax}=Object.prototype,{getPrototypeOf:pi}=Object,{iterator:Ao,toStringTag:lc}=Symbol,jo=(e=>t=>{const n=ax.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),on=e=>(e=e.toLowerCase(),t=>jo(t)===e),_o=e=>t=>typeof t===e,{isArray:ur}=Array,dr=_o("undefined");function Br(e){return e!==null&&!dr(e)&&e.constructor!==null&&!dr(e.constructor)&&Lt(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const cc=on("ArrayBuffer");function lx(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&cc(e.buffer),t}const cx=_o("string"),Lt=_o("function"),uc=_o("number"),zr=e=>e!==null&&typeof e=="object",ux=e=>e===!0||e===!1,Po=e=>{if(jo(e)!=="object")return!1;const t=pi(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(lc in e)&&!(Ao in e)},dx=e=>{if(!zr(e)||Br(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},fx=on("Date"),px=on("File"),hx=on("Blob"),mx=on("FileList"),gx=e=>zr(e)&&Lt(e.pipe),xx=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||Lt(e.append)&&((t=jo(e))==="formdata"||t==="object"&&Lt(e.toString)&&e.toString()==="[object FormData]"))},vx=on("URLSearchParams"),[wx,bx,yx,Sx]=["ReadableStream","Request","Response","Headers"].map(on),Cx=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Hr(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,o;if(typeof e!="object"&&(e=[e]),ur(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{if(Br(e))return;const s=n?Object.getOwnPropertyNames(e):Object.keys(e),i=s.length;let a;for(r=0;r<i;r++)a=s[r],t.call(null,e[a],a,e)}}function dc(e,t){if(Br(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 Kn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,fc=e=>!dr(e)&&e!==Kn;function hi(){const{caseless:e,skipUndefined:t}=fc(this)&&this||{},n={},r=(o,s)=>{const i=e&&dc(n,s)||s;Po(n[i])&&Po(o)?n[i]=hi(n[i],o):Po(o)?n[i]=hi({},o):ur(o)?n[i]=o.slice():(!t||!dr(o))&&(n[i]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&Hr(arguments[o],r);return n}const Tx=(e,t,n,{allOwnKeys:r}={})=>(Hr(t,(o,s)=>{n&&Lt(o)?e[s]=ac(o,n):e[s]=o},{allOwnKeys:r}),e),kx=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Ex=(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)},Ix=(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&&pi(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},Nx=(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},Ax=e=>{if(!e)return null;if(ur(e))return e;let t=e.length;if(!uc(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},jx=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&pi(Uint8Array)),_x=(e,t)=>{const r=(e&&e[Ao]).call(e);let o;for(;(o=r.next())&&!o.done;){const s=o.value;t.call(e,s[0],s[1])}},Px=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},Mx=on("HTMLFormElement"),Rx=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),pc=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),Ox=on("RegExp"),hc=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};Hr(n,(o,s)=>{let i;(i=t(o,s,e))!==!1&&(r[s]=i||o)}),Object.defineProperties(e,r)},Dx=e=>{hc(e,(t,n)=>{if(Lt(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(Lt(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+"'")})}})},Lx=(e,t)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return ur(e)?r(e):r(String(e).split(t)),n},$x=()=>{},Fx=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function Bx(e){return!!(e&&Lt(e.append)&&e[lc]==="FormData"&&e[Ao])}const zx=e=>{const t=new Array(10),n=(r,o)=>{if(zr(r)){if(t.indexOf(r)>=0)return;if(Br(r))return r;if(!("toJSON"in r)){t[o]=r;const s=ur(r)?[]:{};return Hr(r,(i,a)=>{const l=n(i,o+1);!dr(l)&&(s[a]=l)}),t[o]=void 0,s}}return r};return n(e,0)},Hx=on("AsyncFunction"),Ux=e=>e&&(zr(e)||Lt(e))&&Lt(e.then)&&Lt(e.catch),mc=((e,t)=>e?setImmediate:t?((n,r)=>(Kn.addEventListener("message",({source:o,data:s})=>{o===Kn&&s===n&&r.length&&r.shift()()},!1),o=>{r.push(o),Kn.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",Lt(Kn.postMessage)),Wx=typeof queueMicrotask<"u"?queueMicrotask.bind(Kn):typeof process<"u"&&process.nextTick||mc,z={isArray:ur,isArrayBuffer:cc,isBuffer:Br,isFormData:xx,isArrayBufferView:lx,isString:cx,isNumber:uc,isBoolean:ux,isObject:zr,isPlainObject:Po,isEmptyObject:dx,isReadableStream:wx,isRequest:bx,isResponse:yx,isHeaders:Sx,isUndefined:dr,isDate:fx,isFile:px,isBlob:hx,isRegExp:Ox,isFunction:Lt,isStream:gx,isURLSearchParams:vx,isTypedArray:jx,isFileList:mx,forEach:Hr,merge:hi,extend:Tx,trim:Cx,stripBOM:kx,inherits:Ex,toFlatObject:Ix,kindOf:jo,kindOfTest:on,endsWith:Nx,toArray:Ax,forEachEntry:_x,matchAll:Px,isHTMLForm:Mx,hasOwnProperty:pc,hasOwnProp:pc,reduceDescriptors:hc,freezeMethods:Dx,toObjectSet:Lx,toCamelCase:Rx,noop:$x,toFiniteNumber:Fx,findKey:dc,global:Kn,isContextDefined:fc,isSpecCompliantForm:Bx,toJSONObject:zx,isAsyncFn:Hx,isThenable:Ux,setImmediate:mc,asap:Wx,isIterable:e=>e!=null&&Lt(e[Ao])};function Pe(e,t,n,r,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),o&&(this.response=o,this.status=o.status?o.status:null)}z.inherits(Pe,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:z.toJSONObject(this.config),code:this.code,status:this.status}}});const gc=Pe.prototype,xc={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{xc[e]={value:e}}),Object.defineProperties(Pe,xc),Object.defineProperty(gc,"isAxiosError",{value:!0}),Pe.from=(e,t,n,r,o,s)=>{const i=Object.create(gc);z.toFlatObject(e,i,function(d){return d!==Error.prototype},c=>c!=="isAxiosError");const a=e&&e.message?e.message:"Error",l=t==null&&e?e.code:t;return Pe.call(i,a,l,n,r,o),e&&i.cause==null&&Object.defineProperty(i,"cause",{value:e,configurable:!0}),i.name=e&&e.name||"Error",s&&Object.assign(i,s),i};const Vx=null;function mi(e){return z.isPlainObject(e)||z.isArray(e)}function vc(e){return z.endsWith(e,"[]")?e.slice(0,-2):e}function wc(e,t,n){return e?e.concat(t).map(function(o,s){return o=vc(o),!n&&s?"["+o+"]":o}).join(n?".":""):t}function Kx(e){return z.isArray(e)&&!e.some(mi)}const qx=z.toFlatObject(z,{},null,function(t){return/^is[A-Z]/.test(t)});function Mo(e,t,n){if(!z.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=z.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(g,x){return!z.isUndefined(x[g])});const r=n.metaTokens,o=n.visitor||d,s=n.dots,i=n.indexes,l=(n.Blob||typeof Blob<"u"&&Blob)&&z.isSpecCompliantForm(t);if(!z.isFunction(o))throw new TypeError("visitor must be a function");function c(v){if(v===null)return"";if(z.isDate(v))return v.toISOString();if(z.isBoolean(v))return v.toString();if(!l&&z.isBlob(v))throw new Pe("Blob is not supported. Use a Buffer instead.");return z.isArrayBuffer(v)||z.isTypedArray(v)?l&&typeof Blob=="function"?new Blob([v]):Buffer.from(v):v}function d(v,g,x){let y=v;if(v&&!x&&typeof v=="object"){if(z.endsWith(g,"{}"))g=r?g:g.slice(0,-2),v=JSON.stringify(v);else if(z.isArray(v)&&Kx(v)||(z.isFileList(v)||z.endsWith(g,"[]"))&&(y=z.toArray(v)))return g=vc(g),y.forEach(function(S,k){!(z.isUndefined(S)||S===null)&&t.append(i===!0?wc([g],k,s):i===null?g:g+"[]",c(S))}),!1}return mi(v)?!0:(t.append(wc(x,g,s),c(v)),!1)}const p=[],m=Object.assign(qx,{defaultVisitor:d,convertValue:c,isVisitable:mi});function f(v,g){if(!z.isUndefined(v)){if(p.indexOf(v)!==-1)throw Error("Circular reference detected in "+g.join("."));p.push(v),z.forEach(v,function(y,w){(!(z.isUndefined(y)||y===null)&&o.call(t,y,z.isString(w)?w.trim():w,g,m))===!0&&f(y,g?g.concat(w):[w])}),p.pop()}}if(!z.isObject(e))throw new TypeError("data must be an object");return f(e),t}function bc(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function gi(e,t){this._pairs=[],e&&Mo(e,this,t)}const yc=gi.prototype;yc.append=function(t,n){this._pairs.push([t,n])},yc.toString=function(t){const n=t?function(r){return t.call(this,r,bc)}:bc;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function Gx(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Sc(e,t,n){if(!t)return e;const r=n&&n.encode||Gx;z.isFunction(n)&&(n={serialize:n});const o=n&&n.serialize;let s;if(o?s=o(t,n):s=z.isURLSearchParams(t)?t.toString():new gi(t,n).toString(r),s){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}class Cc{constructor(){this.handlers=[]}use(t,n,r){return this.handlers.push({fulfilled:t,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){z.forEach(this.handlers,function(r){r!==null&&t(r)})}}const Tc={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Yx={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:gi,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},xi=typeof window<"u"&&typeof document<"u",vi=typeof navigator=="object"&&navigator||void 0,Xx=xi&&(!vi||["ReactNative","NativeScript","NS"].indexOf(vi.product)<0),Jx=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Zx=xi&&window.location.href||"http://localhost",It={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:xi,hasStandardBrowserEnv:Xx,hasStandardBrowserWebWorkerEnv:Jx,navigator:vi,origin:Zx},Symbol.toStringTag,{value:"Module"})),...Yx};function Qx(e,t){return Mo(e,new It.classes.URLSearchParams,{visitor:function(n,r,o,s){return It.isNode&&z.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function ev(e){return z.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function tv(e){const t={},n=Object.keys(e);let r;const o=n.length;let s;for(r=0;r<o;r++)s=n[r],t[s]=e[s];return t}function kc(e){function t(n,r,o,s){let i=n[s++];if(i==="__proto__")return!0;const a=Number.isFinite(+i),l=s>=n.length;return i=!i&&z.isArray(o)?o.length:i,l?(z.hasOwnProp(o,i)?o[i]=[o[i],r]:o[i]=r,!a):((!o[i]||!z.isObject(o[i]))&&(o[i]=[]),t(n,r,o[i],s)&&z.isArray(o[i])&&(o[i]=tv(o[i])),!a)}if(z.isFormData(e)&&z.isFunction(e.entries)){const n={};return z.forEachEntry(e,(r,o)=>{t(ev(r),o,n,0)}),n}return null}function nv(e,t,n){if(z.isString(e))try{return(t||JSON.parse)(e),z.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const Ur={transitional:Tc,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",o=r.indexOf("application/json")>-1,s=z.isObject(t);if(s&&z.isHTMLForm(t)&&(t=new FormData(t)),z.isFormData(t))return o?JSON.stringify(kc(t)):t;if(z.isArrayBuffer(t)||z.isBuffer(t)||z.isStream(t)||z.isFile(t)||z.isBlob(t)||z.isReadableStream(t))return t;if(z.isArrayBufferView(t))return t.buffer;if(z.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 Qx(t,this.formSerializer).toString();if((a=z.isFileList(t))||r.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return Mo(a?{"files[]":t}:t,l&&new l,this.formSerializer)}}return s||o?(n.setContentType("application/json",!1),nv(t)):t}],transformResponse:[function(t){const n=this.transitional||Ur.transitional,r=n&&n.forcedJSONParsing,o=this.responseType==="json";if(z.isResponse(t)||z.isReadableStream(t))return t;if(t&&z.isString(t)&&(r&&!this.responseType||o)){const i=!(n&&n.silentJSONParsing)&&o;try{return JSON.parse(t,this.parseReviver)}catch(a){if(i)throw a.name==="SyntaxError"?Pe.from(a,Pe.ERR_BAD_RESPONSE,this,null,this.response):a}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:It.classes.FormData,Blob:It.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};z.forEach(["delete","get","head","post","put","patch"],e=>{Ur.headers[e]={}});const rv=z.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"]),ov=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]&&rv[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},Ec=Symbol("internals");function Wr(e){return e&&String(e).trim().toLowerCase()}function Ro(e){return e===!1||e==null?e:z.isArray(e)?e.map(Ro):String(e)}function sv(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 iv=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function wi(e,t,n,r,o){if(z.isFunction(r))return r.call(this,t,n);if(o&&(t=n),!!z.isString(t)){if(z.isString(r))return t.indexOf(r)!==-1;if(z.isRegExp(r))return r.test(t)}}function av(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function lv(e,t){const n=z.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 $t=class{constructor(t){t&&this.set(t)}set(t,n,r){const o=this;function s(a,l,c){const d=Wr(l);if(!d)throw new Error("header name must be a non-empty string");const p=z.findKey(o,d);(!p||o[p]===void 0||c===!0||c===void 0&&o[p]!==!1)&&(o[p||l]=Ro(a))}const i=(a,l)=>z.forEach(a,(c,d)=>s(c,d,l));if(z.isPlainObject(t)||t instanceof this.constructor)i(t,n);else if(z.isString(t)&&(t=t.trim())&&!iv(t))i(ov(t),n);else if(z.isObject(t)&&z.isIterable(t)){let a={},l,c;for(const d of t){if(!z.isArray(d))throw TypeError("Object iterator must return a key-value pair");a[c=d[0]]=(l=a[c])?z.isArray(l)?[...l,d[1]]:[l,d[1]]:d[1]}i(a,n)}else t!=null&&s(n,t,r);return this}get(t,n){if(t=Wr(t),t){const r=z.findKey(this,t);if(r){const o=this[r];if(!n)return o;if(n===!0)return sv(o);if(z.isFunction(n))return n.call(this,o,r);if(z.isRegExp(n))return n.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=Wr(t),t){const r=z.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||wi(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let o=!1;function s(i){if(i=Wr(i),i){const a=z.findKey(r,i);a&&(!n||wi(r,r[a],a,n))&&(delete r[a],o=!0)}}return z.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||wi(this,this[s],s,t,!0))&&(delete this[s],o=!0)}return o}normalize(t){const n=this,r={};return z.forEach(this,(o,s)=>{const i=z.findKey(r,s);if(i){n[i]=Ro(o),delete n[s];return}const a=t?av(s):String(s).trim();a!==s&&delete n[s],n[a]=Ro(o),r[a]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return z.forEach(this,(r,o)=>{r!=null&&r!==!1&&(n[o]=t&&z.isArray(r)?r.join(", "):r)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,n])=>t+": "+n).join(`
32
+ `)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const r=new this(t);return n.forEach(o=>r.set(o)),r}static accessor(t){const r=(this[Ec]=this[Ec]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=Wr(i);r[a]||(lv(o,i),r[a]=!0)}return z.isArray(t)?t.forEach(s):s(t),this}};$t.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),z.reduceDescriptors($t.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),z.freezeMethods($t);function bi(e,t){const n=this||Ur,r=t||n,o=$t.from(r.headers);let s=r.data;return z.forEach(e,function(a){s=a.call(n,s,o.normalize(),t?t.status:void 0)}),o.normalize(),s}function Ic(e){return!!(e&&e.__CANCEL__)}function fr(e,t,n){Pe.call(this,e??"canceled",Pe.ERR_CANCELED,t,n),this.name="CanceledError"}z.inherits(fr,Pe,{__CANCEL__:!0});function Nc(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new Pe("Request failed with status code "+n.status,[Pe.ERR_BAD_REQUEST,Pe.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function cv(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function uv(e,t){e=e||10;const n=new Array(e),r=new Array(e);let o=0,s=0,i;return t=t!==void 0?t:1e3,function(l){const c=Date.now(),d=r[s];i||(i=c),n[o]=l,r[o]=c;let p=s,m=0;for(;p!==o;)m+=n[p++],p=p%e;if(o=(o+1)%e,o===s&&(s=(s+1)%e),c-i<t)return;const f=d&&c-d;return f?Math.round(m*1e3/f):void 0}}function dv(e,t){let n=0,r=1e3/t,o,s;const i=(c,d=Date.now())=>{n=d,o=null,s&&(clearTimeout(s),s=null),e(...c)};return[(...c)=>{const d=Date.now(),p=d-n;p>=r?i(c,d):(o=c,s||(s=setTimeout(()=>{s=null,i(o)},r-p)))},()=>o&&i(o)]}const Oo=(e,t,n=3)=>{let r=0;const o=uv(50,250);return dv(s=>{const i=s.loaded,a=s.lengthComputable?s.total:void 0,l=i-r,c=o(l),d=i<=a;r=i;const p={loaded:i,total:a,progress:a?i/a:void 0,bytes:l,rate:c||void 0,estimated:c&&a&&d?(a-i)/c:void 0,event:s,lengthComputable:a!=null,[t?"download":"upload"]:!0};e(p)},n)},Ac=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},jc=e=>(...t)=>z.asap(()=>e(...t)),fv=It.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,It.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(It.origin),It.navigator&&/(msie|trident)/i.test(It.navigator.userAgent)):()=>!0,pv=It.hasStandardBrowserEnv?{write(e,t,n,r,o,s){const i=[e+"="+encodeURIComponent(t)];z.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),z.isString(r)&&i.push("path="+r),z.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 mv(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function _c(e,t,n){let r=!hv(t);return e&&(r||n==!1)?mv(e,t):t}const Pc=e=>e instanceof $t?{...e}:e;function qn(e,t){t=t||{};const n={};function r(c,d,p,m){return z.isPlainObject(c)&&z.isPlainObject(d)?z.merge.call({caseless:m},c,d):z.isPlainObject(d)?z.merge({},d):z.isArray(d)?d.slice():d}function o(c,d,p,m){if(z.isUndefined(d)){if(!z.isUndefined(c))return r(void 0,c,p,m)}else return r(c,d,p,m)}function s(c,d){if(!z.isUndefined(d))return r(void 0,d)}function i(c,d){if(z.isUndefined(d)){if(!z.isUndefined(c))return r(void 0,c)}else return r(void 0,d)}function a(c,d,p){if(p in t)return r(c,d);if(p in e)return r(void 0,c)}const l={url:s,method:s,data:s,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:a,headers:(c,d,p)=>o(Pc(c),Pc(d),p,!0)};return z.forEach(Object.keys({...e,...t}),function(d){const p=l[d]||o,m=p(e[d],t[d],d);z.isUndefined(m)&&p!==a||(n[d]=m)}),n}const Mc=e=>{const t=qn({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=$t.from(i),t.url=Sc(_c(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&i.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),z.isFormData(n)){if(It.hasStandardBrowserEnv||It.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(z.isFunction(n.getHeaders)){const l=n.getHeaders(),c=["content-type","content-length"];Object.entries(l).forEach(([d,p])=>{c.includes(d.toLowerCase())&&i.set(d,p)})}}if(It.hasStandardBrowserEnv&&(r&&z.isFunction(r)&&(r=r(t)),r||r!==!1&&fv(t.url))){const l=o&&s&&pv.read(s);l&&i.set(o,l)}return t},gv=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=Mc(e);let s=o.data;const i=$t.from(o.headers).normalize();let{responseType:a,onUploadProgress:l,onDownloadProgress:c}=o,d,p,m,f,v;function g(){f&&f(),v&&v(),o.cancelToken&&o.cancelToken.unsubscribe(d),o.signal&&o.signal.removeEventListener("abort",d)}let x=new XMLHttpRequest;x.open(o.method.toUpperCase(),o.url,!0),x.timeout=o.timeout;function y(){if(!x)return;const S=$t.from("getAllResponseHeaders"in x&&x.getAllResponseHeaders()),C={data:!a||a==="text"||a==="json"?x.responseText:x.response,status:x.status,statusText:x.statusText,headers:S,config:e,request:x};Nc(function(E){n(E),g()},function(E){r(E),g()},C),x=null}"onloadend"in x?x.onloadend=y:x.onreadystatechange=function(){!x||x.readyState!==4||x.status===0&&!(x.responseURL&&x.responseURL.indexOf("file:")===0)||setTimeout(y)},x.onabort=function(){x&&(r(new Pe("Request aborted",Pe.ECONNABORTED,e,x)),x=null)},x.onerror=function(k){const C=k&&k.message?k.message:"Network Error",T=new Pe(C,Pe.ERR_NETWORK,e,x);T.event=k||null,r(T),x=null},x.ontimeout=function(){let k=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const C=o.transitional||Tc;o.timeoutErrorMessage&&(k=o.timeoutErrorMessage),r(new Pe(k,C.clarifyTimeoutError?Pe.ETIMEDOUT:Pe.ECONNABORTED,e,x)),x=null},s===void 0&&i.setContentType(null),"setRequestHeader"in x&&z.forEach(i.toJSON(),function(k,C){x.setRequestHeader(C,k)}),z.isUndefined(o.withCredentials)||(x.withCredentials=!!o.withCredentials),a&&a!=="json"&&(x.responseType=o.responseType),c&&([m,v]=Oo(c,!0),x.addEventListener("progress",m)),l&&x.upload&&([p,f]=Oo(l),x.upload.addEventListener("progress",p),x.upload.addEventListener("loadend",f)),(o.cancelToken||o.signal)&&(d=S=>{x&&(r(!S||S.type?new fr(null,e,x):S),x.abort(),x=null)},o.cancelToken&&o.cancelToken.subscribe(d),o.signal&&(o.signal.aborted?d():o.signal.addEventListener("abort",d)));const w=cv(o.url);if(w&&It.protocols.indexOf(w)===-1){r(new Pe("Unsupported protocol "+w+":",Pe.ERR_BAD_REQUEST,e));return}x.send(s||null)})},xv=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let r=new AbortController,o;const s=function(c){if(!o){o=!0,a();const d=c instanceof Error?c:this.reason;r.abort(d instanceof Pe?d:new fr(d instanceof Error?d.message:d))}};let i=t&&setTimeout(()=>{i=null,s(new Pe(`timeout ${t} of ms exceeded`,Pe.ETIMEDOUT))},t);const a=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(c=>{c.unsubscribe?c.unsubscribe(s):c.removeEventListener("abort",s)}),e=null)};e.forEach(c=>c.addEventListener("abort",s));const{signal:l}=r;return l.unsubscribe=()=>z.asap(a),l}},vv=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},wv=async function*(e,t){for await(const n of bv(e))yield*vv(n,t)},bv=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()}},Rc=(e,t,n,r)=>{const o=wv(e,t);let s=0,i,a=l=>{i||(i=!0,r&&r(l))};return new ReadableStream({async pull(l){try{const{done:c,value:d}=await o.next();if(c){a(),l.close();return}let p=d.byteLength;if(n){let m=s+=p;n(m)}l.enqueue(new Uint8Array(d))}catch(c){throw a(c),c}},cancel(l){return a(l),o.return()}},{highWaterMark:2})},Oc=64*1024,{isFunction:Do}=z,yv=(({Request:e,Response:t})=>({Request:e,Response:t}))(z.global),{ReadableStream:Dc,TextEncoder:Lc}=z.global,$c=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Sv=e=>{e=z.merge.call({skipUndefined:!0},yv,e);const{fetch:t,Request:n,Response:r}=e,o=t?Do(t):typeof fetch=="function",s=Do(n),i=Do(r);if(!o)return!1;const a=o&&Do(Dc),l=o&&(typeof Lc=="function"?(v=>g=>v.encode(g))(new Lc):async v=>new Uint8Array(await new n(v).arrayBuffer())),c=s&&a&&$c(()=>{let v=!1;const g=new n(It.origin,{body:new Dc,method:"POST",get duplex(){return v=!0,"half"}}).headers.has("Content-Type");return v&&!g}),d=i&&a&&$c(()=>z.isReadableStream(new r("").body)),p={stream:d&&(v=>v.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(v=>{!p[v]&&(p[v]=(g,x)=>{let y=g&&g[v];if(y)return y.call(g);throw new Pe(`Response type '${v}' is not supported`,Pe.ERR_NOT_SUPPORT,x)})});const m=async v=>{if(v==null)return 0;if(z.isBlob(v))return v.size;if(z.isSpecCompliantForm(v))return(await new n(It.origin,{method:"POST",body:v}).arrayBuffer()).byteLength;if(z.isArrayBufferView(v)||z.isArrayBuffer(v))return v.byteLength;if(z.isURLSearchParams(v)&&(v=v+""),z.isString(v))return(await l(v)).byteLength},f=async(v,g)=>{const x=z.toFiniteNumber(v.getContentLength());return x??m(g)};return async v=>{let{url:g,method:x,data:y,signal:w,cancelToken:S,timeout:k,onDownloadProgress:C,onUploadProgress:T,responseType:E,headers:_,withCredentials:R="same-origin",fetchOptions:L}=Mc(v),H=t||fetch;E=E?(E+"").toLowerCase():"text";let K=xv([w,S&&S.toAbortSignal()],k),B=null;const I=K&&K.unsubscribe&&(()=>{K.unsubscribe()});let W;try{if(T&&c&&x!=="get"&&x!=="head"&&(W=await f(_,y))!==0){let J=new n(g,{method:"POST",body:y,duplex:"half"}),P;if(z.isFormData(y)&&(P=J.headers.get("content-type"))&&_.setContentType(P),J.body){const[M,G]=Ac(W,Oo(jc(T)));y=Rc(J.body,Oc,M,G)}}z.isString(R)||(R=R?"include":"omit");const N=s&&"credentials"in n.prototype,U={...L,signal:K,method:x.toUpperCase(),headers:_.normalize().toJSON(),body:y,duplex:"half",credentials:N?R:void 0};B=s&&new n(g,U);let O=await(s?H(B,L):H(g,U));const j=d&&(E==="stream"||E==="response");if(d&&(C||j&&I)){const J={};["status","statusText","headers"].forEach(Z=>{J[Z]=O[Z]});const P=z.toFiniteNumber(O.headers.get("content-length")),[M,G]=C&&Ac(P,Oo(jc(C),!0))||[];O=new r(Rc(O.body,Oc,M,()=>{G&&G(),I&&I()}),J)}E=E||"text";let q=await p[z.findKey(p,E)||"text"](O,v);return!j&&I&&I(),await new Promise((J,P)=>{Nc(J,P,{data:q,headers:$t.from(O.headers),status:O.status,statusText:O.statusText,config:v,request:B})})}catch(N){throw I&&I(),N&&N.name==="TypeError"&&/Load failed|fetch/i.test(N.message)?Object.assign(new Pe("Network Error",Pe.ERR_NETWORK,v,B),{cause:N.cause||N}):Pe.from(N,N&&N.code,v,B)}}},Cv=new Map,Fc=e=>{let t=e?e.env:{};const{fetch:n,Request:r,Response:o}=t,s=[r,o,n];let i=s.length,a=i,l,c,d=Cv;for(;a--;)l=s[a],c=d.get(l),c===void 0&&d.set(l,c=a?new Map:Sv(t)),d=c;return c};Fc();const yi={http:Vx,xhr:gv,fetch:{get:Fc}};z.forEach(yi,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Bc=e=>`- ${e}`,Tv=e=>z.isFunction(e)||e===null||e===!1,zc={getAdapter:(e,t)=>{e=z.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,!Tv(r)&&(o=yi[(a=String(r)).toLowerCase()],o===void 0))throw new Pe(`Unknown adapter '${a}'`);if(o&&(z.isFunction(o)||(o=o.get(t))))break;s[a||"#"+i]=o}if(!o){const i=Object.entries(s).map(([l,c])=>`adapter ${l} `+(c===!1?"is not supported by the environment":"is not available in the build"));let a=n?i.length>1?`since :
33
33
  `+i.map(Bc).join(`
34
- `):" "+Bc(i[0]):"as no adapter specified";throw new Pe("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return o},adapters:yi};function Si(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new fr(null,e)}function Hc(e){return Si(e),e.headers=$t.from(e.headers),e.data=bi.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),zc.getAdapter(e.adapter||Ur.adapter,e)(e).then(function(r){return Si(e),r.data=bi.call(e,e.transformResponse,r),r.headers=$t.from(r.headers),r},function(r){return Ic(r)||(Si(e),r&&r.response&&(r.response.data=bi.call(e,e.transformResponse,r.response),r.response.headers=$t.from(r.response.headers))),Promise.reject(r)})}const Uc="1.12.2",Lo={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Lo[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const Wc={};Lo.transitional=function(t,n,r){function o(s,i){return"[Axios v"+Uc+"] Transitional option '"+s+"'"+i+(r?". "+r:"")}return(s,i,a)=>{if(t===!1)throw new Pe(o(i," has been removed"+(n?" in "+n:"")),Pe.ERR_DEPRECATED);return n&&!Wc[i]&&(Wc[i]=!0,console.warn(o(i," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(s,i,a):!0}},Lo.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function Tv(e,t,n){if(typeof e!="object")throw new Pe("options must be an object",Pe.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let o=r.length;for(;o-- >0;){const s=r[o],i=t[s];if(i){const a=e[s],l=a===void 0||i(a,s,e);if(l!==!0)throw new Pe("option "+s+" must be "+l,Pe.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new Pe("Unknown option "+s,Pe.ERR_BAD_OPTION)}}const $o={assertOptions:Tv,validators:Lo},hn=$o.validators;let Gn=class{constructor(t){this.defaults=t||{},this.interceptors={request:new Cc,response:new Cc}}async request(t,n){try{return await this._request(t,n)}catch(r){if(r instanceof Error){let o={};Error.captureStackTrace?Error.captureStackTrace(o):o=new Error;const s=o.stack?o.stack.replace(/^.+\n/,""):"";try{r.stack?s&&!String(r.stack).endsWith(s.replace(/^.+\n.+\n/,""))&&(r.stack+=`
35
- `+s):r.stack=s}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=qn(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:s}=n;r!==void 0&&$o.assertOptions(r,{silentJSONParsing:hn.transitional(hn.boolean),forcedJSONParsing:hn.transitional(hn.boolean),clarifyTimeoutError:hn.transitional(hn.boolean)},!1),o!=null&&(z.isFunction(o)?n.paramsSerializer={serialize:o}:$o.assertOptions(o,{encode:hn.function,serialize:hn.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),$o.assertOptions(n,{baseUrl:hn.spelling("baseURL"),withXsrfToken:hn.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=s&&z.merge(s.common,s[n.method]);s&&z.forEach(["delete","get","head","post","put","patch","common"],v=>{delete s[v]}),n.headers=$t.concat(i,s);const a=[];let l=!0;this.interceptors.request.forEach(function(g){typeof g.runWhen=="function"&&g.runWhen(n)===!1||(l=l&&g.synchronous,a.unshift(g.fulfilled,g.rejected))});const c=[];this.interceptors.response.forEach(function(g){c.push(g.fulfilled,g.rejected)});let d,p=0,m;if(!l){const v=[Hc.bind(this),void 0];for(v.unshift(...a),v.push(...c),m=v.length,d=Promise.resolve(n);p<m;)d=d.then(v[p++],v[p++]);return d}m=a.length;let f=n;for(;p<m;){const v=a[p++],g=a[p++];try{f=v(f)}catch(x){g.call(this,x);break}}try{d=Hc.call(this,f)}catch(v){return Promise.reject(v)}for(p=0,m=c.length;p<m;)d=d.then(c[p++],c[p++]);return d}getUri(t){t=qn(this.defaults,t);const n=_c(t.baseURL,t.url,t.allowAbsoluteUrls);return Sc(n,t.params,t.paramsSerializer)}};z.forEach(["delete","get","head","options"],function(t){Gn.prototype[t]=function(n,r){return this.request(qn(r||{},{method:t,url:n,data:(r||{}).data}))}}),z.forEach(["post","put","patch"],function(t){function n(r){return function(s,i,a){return this.request(qn(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}Gn.prototype[t]=n(),Gn.prototype[t+"Form"]=n(!0)});let kv=class Yg{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 fr(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 Yg(function(o){t=o}),cancel:t}}};function Ev(e){return function(n){return e.apply(null,n)}}function Iv(e){return z.isObject(e)&&e.isAxiosError===!0}const Ci={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(Ci).forEach(([e,t])=>{Ci[t]=e});function Vc(e){const t=new Gn(e),n=ac(Gn.prototype.request,t);return z.extend(n,Gn.prototype,t,{allOwnKeys:!0}),z.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return Vc(qn(e,o))},n}const ht=Vc(Ur);ht.Axios=Gn,ht.CanceledError=fr,ht.CancelToken=kv,ht.isCancel=Ic,ht.VERSION=Uc,ht.toFormData=Mo,ht.AxiosError=Pe,ht.Cancel=ht.CanceledError,ht.all=function(t){return Promise.all(t)},ht.spread=Ev,ht.isAxiosError=Iv,ht.mergeConfig=qn,ht.AxiosHeaders=$t,ht.formToJSON=e=>kc(z.isHTMLForm(e)?new FormData(e):e),ht.getAdapter=zc.getAdapter,ht.HttpStatusCode=Ci,ht.default=ht;const{Axios:zI,AxiosError:HI,CanceledError:UI,isCancel:WI,CancelToken:VI,VERSION:KI,all:qI,Cancel:GI,isAxiosError:YI,spread:XI,toFormData:JI,AxiosHeaders:ZI,HttpStatusCode:QI,formToJSON:e1,getAdapter:t1,mergeConfig:n1}=ht,Kc=typeof window<"u"?window.__API_BASE_URL__:void 0,qc=Kc?mn(Kc):void 0;function mn(e){const n=(e!=null&&e.trim()?e.trim():"/api/chat").replace(/\/+$/,"");return n?n.endsWith("/chat")?n:`${n}/chat`:"/api/chat"}let Fo=null;const Ti=new Set;function Gc(){return Fo}function Bo(e){Fo=e,Ti.forEach(t=>t(e))}function Yc(e){return Ti.add(e),()=>Ti.delete(e)}const Xc=3e4,Jc=9e4,Kt=ht.create({...qc?{baseURL:qc}:{},timeout:Xc,withCredentials:!0});Kt.interceptors.request.use(e=>(Fo&&(e.headers.Authorization=`Bearer ${Fo}`),e)),Kt.interceptors.response.use(e=>{if(typeof window<"u"&&(e!=null&&e.data))try{const t=e.data,n=t.data||{},r=typeof t.token=="string"&&t.token||typeof n.token=="string"&&n.token||null,o=typeof t.expires_at=="number"&&t.expires_at||typeof n.expires_at=="number"&&n.expires_at||typeof t.expiresAt=="number"&&t.expiresAt||typeof n.expiresAt=="number"&&n.expiresAt||null;r&&(localStorage.setItem("authToken",r),Bo(r)),o&&localStorage.setItem("authTokenExpiresAt",o.toString()),(r||o)&&window.dispatchEvent(new CustomEvent("smartorg:chat-token-updated",{detail:{token:r,expiresAt:o}}))}catch(t){console.warn("[chat-api] Error storing token:",t)}return e},e=>Promise.reject(e));async function qt(e,t){return Kt.defaults.baseURL?(await Kt.get(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}async function zo(e,t,n){return Kt.defaults.baseURL?(await Kt.post(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function Zc(e,t,n){return Kt.defaults.baseURL?(await Kt.put(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function ki(e,t){return Kt.defaults.baseURL?(await Kt.delete(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}function Mt(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class Ho{get baseUrl(){const t=Kt.defaults.baseURL;return t?mn(String(t)):""}updateConfig(t){t.baseUrl&&(Kt.defaults.baseURL=mn(String(t.baseUrl))),t.authToken!==void 0&&Bo(t.authToken)}getAuthToken(){return Gc()}setAuthToken(t){Bo(t)}onTokenChange(t){return Yc(t)}async listThreads(){const t=await qt("/threads"),n=Mt(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async listSharedThreads(){const t=await qt("/threads/shared"),n=Mt(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async createThread(t){const r=await zo("/threads",t?{title:t}:void 0);return Mt(r)}async updateThread(t,n){const r=await Zc(`/threads/${t}`,{title:n});return Mt(r)}async deleteThread(t){const n=await ki(`/threads/${t}`);return Mt(n)}async shareThread(t,n){const r=await zo(`/threads/${t}/share`,{shared_with_user_id:n});return Mt(r)}async threadInfo(t){const n=await qt(`/threads/${t}/info`);return Mt(n)}async listAgents(){const t=await qt("/agents"),n=Mt(t);return(n==null?void 0:n.items)??[]}async getAgent(t){const n=await qt(`/agents/${t}`);return Mt(n)}async getAgentSchema(t){const n=await qt(`/agents/${t}/schema`);return Mt(n)}async getState(t){const n=await qt(`/threads/${t.threadId}/state`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return Mt(n)}async getStateHistory(t){const n=await qt(`/threads/${t.threadId}/state/history`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs},timeout:Jc});return Mt(n)}async cancelRun(t){const n=await zo("/runs/cancel",{threadId:t});return Mt(n)}async unshareThread(t,n){const r=await ki(`/threads/${t}/share/${n}`);return Mt(r)}}const An=new Ho,Nv=Ho,Av=Ho;async function Ei(e,t){return await qt(e,{responseType:"blob",onDownloadProgress:r=>{try{if(t&&r.lengthComputable){const o=r.loaded/r.total;t(o)}}catch{}},maxBodyLength:1/0})}async function jv(e,t){const n=await Ei(`/files/${e}/view`,t),r=URL.createObjectURL(n);window.open(r,"_blank"),setTimeout(()=>URL.revokeObjectURL(r),6e4)}async function Ii(e,t){return await(await Ei(`/files/${e}/view`,t)).text()}async function Qc(e,t){const n=await Ei(`/files/${e}/download`,t),r=URL.createObjectURL(n);let o=`file_${e}`;try{const i=await qt(`/files/${e}`);o=(i==null?void 0:i.filename)??o}catch{}const s=document.createElement("a");s.href=r,s.download=o,document.body.appendChild(s),s.click(),s.remove(),setTimeout(()=>URL.revokeObjectURL(r),6e4)}async function _v(e){return await qt(`/files/${e}`)}async function eu(e,t=50,n=0){const r={limit:t,offset:n};return e&&(r.thread_id=e),await qt("/files",{params:r})}const tu=b.createContext(null);function nu({children:e,apiConfig:t}){const n=An;if(t){const o=n.baseUrl,s=n.getAuthToken();t.baseUrl&&t.baseUrl!==o&&n.updateConfig({baseUrl:t.baseUrl}),t.apiKey!==void 0&&t.apiKey!==s&&n.updateConfig({authToken:t.apiKey})}const r={token:n.getAuthToken(),setToken:o=>n.setAuthToken(o),api:n,baseUrl:n.baseUrl};return u.jsx(tu.Provider,{value:r,children:e})}async function ru(e){return await new Promise((t,n)=>{const r=new FileReader;r.onload=()=>{try{const o=r.result,s=new Uint8Array(o);let i="";const a=s.byteLength;for(let l=0;l<a;l++)i+=String.fromCharCode(s[l]);t(btoa(i))}catch(o){n(o)}},r.onerror=o=>n(o),r.readAsArrayBuffer(e)})}async function ou(e=[]){const t=[],n=[];for(const r of e)try{const o=await ru(r);n.push({filename:r.name,data:o,mime_type:r.type||"application/octet-stream"})}catch{}return{contentParts:t,filesInfo:n}}function Vr(){const e=b.useContext(tu);if(!e)throw new Error("useApi must be used within ApiProvider");return e}function su(e){return!!e&&typeof e=="object"&&e.protocolVersion==="v1"&&"data"in e}function Pv(e={}){const t=b.useMemo(()=>mn(e.baseUrl),[e.baseUrl]),n=e.streamPath??"/runs/stream",[r,o]=b.useState(e.token??null),s=b.useRef(e.headers??{}),i=e.credentials??"include",[a,l]=b.useState(!1),[c,d]=b.useState(null),[p,m]=b.useState(""),[f,v]=b.useState(null),[g,x]=b.useState(0),[y,w]=b.useState(!1),S=b.useRef(null),k=b.useRef(!0),C=b.useRef(0),T=b.useRef(null),E=b.useRef(null),_=b.useRef(null),R=b.useRef(null),L=b.useCallback(I=>{o(I)},[]),H=b.useCallback(()=>{m(""),v(null),d(null),E.current=null,_.current=null,R.current=null},[]),K=b.useCallback(()=>{var I;console.debug("[use-chat] stop() invoked - aborting stream"),(I=S.current)==null||I.abort(),S.current=null,T.current=null,l(!1),w(!1),C.current=0,x(0)},[]),F=b.useCallback((I,W,N)=>{S.current&&(S.current.abort(),S.current=null),l(!0),d(null),e.autoAppendAssistant!==!1&&m(""),v(null),E.current=null,_.current=null,R.current=null;const U=new AbortController;S.current=U;let O=null,j=null,q=!1;return T.current={threadId:I.threadId??null,headers:{}},(async()=>{var P,M,G,Z,se,V,D,X,Q,ae,$,re,we,de,xe,Ee,Be,We;const J=je=>{var Ve;try{const Xe=JSON.parse(JSON.stringify(je));return(Ve=Xe==null?void 0:Xe.payload)!=null&&Ve.files_info&&Array.isArray(Xe.payload.files_info)&&(Xe.payload.files_info=Xe.payload.files_info.map(ze=>({...ze,data:ze!=null&&ze.data?`<base64 ${String(ze.data).length} chars>`:ze==null?void 0:ze.data}))),Xe}catch{return je}};try{let je={};try{if(r)je={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const Ke=window.__AUTH_TOKEN__,Ct=((P=window.localStorage)==null?void 0:P.getItem("authToken"))||null;let Ze=null;try{const le=(M=window.localStorage)==null?void 0:M.getItem("chat-settings");le&&(Ze=((G=JSON.parse(le))==null?void 0:G.apiKey)||null)}catch{}const pt=Ke||Ct||Ze||null;pt&&(je={Authorization:`Bearer ${pt}`})}}catch{}console.debug("[use-chat] POST",t+n,J(I));let Ve={};if(typeof window<"u")try{const Me=(Z=window.localStorage)==null?void 0:Z.getItem("authSessionId");Me&&(Ve={"X-Session-Id":Me})}catch{}const Xe={...je,...Ve,...s.current},ze={"Content-Type":"application/json",Accept:"text/event-stream",...Xe},Ge=await fetch(t+n,{method:"POST",headers:ze,body:JSON.stringify(I),signal:U.signal,credentials:i});if(T.current&&(T.current.headers=Xe),!Ge.ok||!Ge.body){const Me=await Ge.text().catch(()=>"");console.debug("[use-chat] non-OK response",Ge.status,Me==null?void 0:Me.slice(0,500));const Ke=`stream ${Ge.status}${Me?": "+Me:""}`;throw(se=N==null?void 0:N.onConnectionError)==null||se.call(N,Ke),q=!0,O="error",j=Ke,new Error(Ke)}w(!0);const rt=Ge.body.getReader(),nt=new TextDecoder;let et="",xt=[];C.current=0,x(0);let vt=0,dt=null;const Et=()=>{if(xt.length){const Me=xt.join("");xt=[],k.current&&m(Ke=>Ke+Me)}dt=null},Dt=()=>{typeof window<"u"&&dt==null&&(dt=requestAnimationFrame(Et))};let $e=Date.now();const Pt=setInterval(()=>{var Me;if(Date.now()-$e>18e5){const Ke="Stream idle timeout";d(Ke),O="error",j=Ke,U.abort(),(Me=N==null?void 0:N.onError)==null||Me.call(N,Ke)}},5e3),nn=1024*1024;try{const Me=Ge.headers.get("X-Thread-Id")||Ge.headers.get("x-thread-id"),Ke=Ge.headers.get("X-Thread-Created")||Ge.headers.get("x-thread-created"),Ct=Me??null,Ze=String(Ke??"").toLowerCase()==="true";for(T.current&&!T.current.threadId&&(T.current={...T.current,threadId:Ct}),(V=N==null?void 0:N.onOpen)==null||V.call(N,{threadId:Ct,created:Ze});;){const{value:pt,done:le}=await rt.read();if(le)break;et+=nt.decode(pt,{stream:!0}),et.length>nn&&(et="",console.warn("Stream buffer reset: exceeded 1MB"));let Y;for(;(Y=et.indexOf(`
34
+ `):" "+Bc(i[0]):"as no adapter specified";throw new Pe("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return o},adapters:yi};function Si(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new fr(null,e)}function Hc(e){return Si(e),e.headers=$t.from(e.headers),e.data=bi.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),zc.getAdapter(e.adapter||Ur.adapter,e)(e).then(function(r){return Si(e),r.data=bi.call(e,e.transformResponse,r),r.headers=$t.from(r.headers),r},function(r){return Ic(r)||(Si(e),r&&r.response&&(r.response.data=bi.call(e,e.transformResponse,r.response),r.response.headers=$t.from(r.response.headers))),Promise.reject(r)})}const Uc="1.12.2",Lo={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Lo[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const Wc={};Lo.transitional=function(t,n,r){function o(s,i){return"[Axios v"+Uc+"] Transitional option '"+s+"'"+i+(r?". "+r:"")}return(s,i,a)=>{if(t===!1)throw new Pe(o(i," has been removed"+(n?" in "+n:"")),Pe.ERR_DEPRECATED);return n&&!Wc[i]&&(Wc[i]=!0,console.warn(o(i," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(s,i,a):!0}},Lo.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function kv(e,t,n){if(typeof e!="object")throw new Pe("options must be an object",Pe.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let o=r.length;for(;o-- >0;){const s=r[o],i=t[s];if(i){const a=e[s],l=a===void 0||i(a,s,e);if(l!==!0)throw new Pe("option "+s+" must be "+l,Pe.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new Pe("Unknown option "+s,Pe.ERR_BAD_OPTION)}}const $o={assertOptions:kv,validators:Lo},hn=$o.validators;let Gn=class{constructor(t){this.defaults=t||{},this.interceptors={request:new Cc,response:new Cc}}async request(t,n){try{return await this._request(t,n)}catch(r){if(r instanceof Error){let o={};Error.captureStackTrace?Error.captureStackTrace(o):o=new Error;const s=o.stack?o.stack.replace(/^.+\n/,""):"";try{r.stack?s&&!String(r.stack).endsWith(s.replace(/^.+\n.+\n/,""))&&(r.stack+=`
35
+ `+s):r.stack=s}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=qn(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:s}=n;r!==void 0&&$o.assertOptions(r,{silentJSONParsing:hn.transitional(hn.boolean),forcedJSONParsing:hn.transitional(hn.boolean),clarifyTimeoutError:hn.transitional(hn.boolean)},!1),o!=null&&(z.isFunction(o)?n.paramsSerializer={serialize:o}:$o.assertOptions(o,{encode:hn.function,serialize:hn.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),$o.assertOptions(n,{baseUrl:hn.spelling("baseURL"),withXsrfToken:hn.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=s&&z.merge(s.common,s[n.method]);s&&z.forEach(["delete","get","head","post","put","patch","common"],v=>{delete s[v]}),n.headers=$t.concat(i,s);const a=[];let l=!0;this.interceptors.request.forEach(function(g){typeof g.runWhen=="function"&&g.runWhen(n)===!1||(l=l&&g.synchronous,a.unshift(g.fulfilled,g.rejected))});const c=[];this.interceptors.response.forEach(function(g){c.push(g.fulfilled,g.rejected)});let d,p=0,m;if(!l){const v=[Hc.bind(this),void 0];for(v.unshift(...a),v.push(...c),m=v.length,d=Promise.resolve(n);p<m;)d=d.then(v[p++],v[p++]);return d}m=a.length;let f=n;for(;p<m;){const v=a[p++],g=a[p++];try{f=v(f)}catch(x){g.call(this,x);break}}try{d=Hc.call(this,f)}catch(v){return Promise.reject(v)}for(p=0,m=c.length;p<m;)d=d.then(c[p++],c[p++]);return d}getUri(t){t=qn(this.defaults,t);const n=_c(t.baseURL,t.url,t.allowAbsoluteUrls);return Sc(n,t.params,t.paramsSerializer)}};z.forEach(["delete","get","head","options"],function(t){Gn.prototype[t]=function(n,r){return this.request(qn(r||{},{method:t,url:n,data:(r||{}).data}))}}),z.forEach(["post","put","patch"],function(t){function n(r){return function(s,i,a){return this.request(qn(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}Gn.prototype[t]=n(),Gn.prototype[t+"Form"]=n(!0)});let Ev=class Xg{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 fr(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 Xg(function(o){t=o}),cancel:t}}};function Iv(e){return function(n){return e.apply(null,n)}}function Nv(e){return z.isObject(e)&&e.isAxiosError===!0}const Ci={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(Ci).forEach(([e,t])=>{Ci[t]=e});function Vc(e){const t=new Gn(e),n=ac(Gn.prototype.request,t);return z.extend(n,Gn.prototype,t,{allOwnKeys:!0}),z.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return Vc(qn(e,o))},n}const ht=Vc(Ur);ht.Axios=Gn,ht.CanceledError=fr,ht.CancelToken=Ev,ht.isCancel=Ic,ht.VERSION=Uc,ht.toFormData=Mo,ht.AxiosError=Pe,ht.Cancel=ht.CanceledError,ht.all=function(t){return Promise.all(t)},ht.spread=Iv,ht.isAxiosError=Nv,ht.mergeConfig=qn,ht.AxiosHeaders=$t,ht.formToJSON=e=>kc(z.isHTMLForm(e)?new FormData(e):e),ht.getAdapter=zc.getAdapter,ht.HttpStatusCode=Ci,ht.default=ht;const{Axios:zI,AxiosError:HI,CanceledError:UI,isCancel:WI,CancelToken:VI,VERSION:KI,all:qI,Cancel:GI,isAxiosError:YI,spread:XI,toFormData:JI,AxiosHeaders:ZI,HttpStatusCode:QI,formToJSON:e1,getAdapter:t1,mergeConfig:n1}=ht,Kc=typeof window<"u"?window.__API_BASE_URL__:void 0,qc=Kc?mn(Kc):void 0;function mn(e){const n=(e!=null&&e.trim()?e.trim():"/api/chat").replace(/\/+$/,"");return n?n.endsWith("/chat")?n:`${n}/chat`:"/api/chat"}let Fo=null;const Ti=new Set;function Gc(){return Fo}function Bo(e){Fo=e,Ti.forEach(t=>t(e))}function Yc(e){return Ti.add(e),()=>Ti.delete(e)}const Xc=3e4,Jc=9e4,Kt=ht.create({...qc?{baseURL:qc}:{},timeout:Xc,withCredentials:!0});Kt.interceptors.request.use(e=>(Fo&&(e.headers.Authorization=`Bearer ${Fo}`),e)),Kt.interceptors.response.use(e=>{if(typeof window<"u"&&(e!=null&&e.data))try{const t=e.data,n=t.data||{},r=typeof t.token=="string"&&t.token||typeof n.token=="string"&&n.token||null,o=typeof t.expires_at=="number"&&t.expires_at||typeof n.expires_at=="number"&&n.expires_at||typeof t.expiresAt=="number"&&t.expiresAt||typeof n.expiresAt=="number"&&n.expiresAt||null;r&&(localStorage.setItem("authToken",r),Bo(r)),o&&localStorage.setItem("authTokenExpiresAt",o.toString()),(r||o)&&window.dispatchEvent(new CustomEvent("smartorg:chat-token-updated",{detail:{token:r,expiresAt:o}}))}catch(t){console.warn("[chat-api] Error storing token:",t)}return e},e=>Promise.reject(e));async function qt(e,t){return Kt.defaults.baseURL?(await Kt.get(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}async function zo(e,t,n){return Kt.defaults.baseURL?(await Kt.post(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function Zc(e,t,n){return Kt.defaults.baseURL?(await Kt.put(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function ki(e,t){return Kt.defaults.baseURL?(await Kt.delete(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}function Mt(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class Ho{get baseUrl(){const t=Kt.defaults.baseURL;return t?mn(String(t)):""}updateConfig(t){t.baseUrl&&(Kt.defaults.baseURL=mn(String(t.baseUrl))),t.authToken!==void 0&&Bo(t.authToken)}getAuthToken(){return Gc()}setAuthToken(t){Bo(t)}onTokenChange(t){return Yc(t)}async listThreads(){const t=await qt("/threads"),n=Mt(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async listSharedThreads(){const t=await qt("/threads/shared"),n=Mt(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async createThread(t){const r=await zo("/threads",t?{title:t}:void 0);return Mt(r)}async updateThread(t,n){const r=await Zc(`/threads/${t}`,{title:n});return Mt(r)}async deleteThread(t){const n=await ki(`/threads/${t}`);return Mt(n)}async shareThread(t,n){const r=await zo(`/threads/${t}/share`,{shared_with_user_id:n});return Mt(r)}async threadInfo(t){const n=await qt(`/threads/${t}/info`);return Mt(n)}async listAgents(){const t=await qt("/agents"),n=Mt(t);return(n==null?void 0:n.items)??[]}async getAgent(t){const n=await qt(`/agents/${t}`);return Mt(n)}async getAgentSchema(t){const n=await qt(`/agents/${t}/schema`);return Mt(n)}async getState(t){const n=await qt(`/threads/${t.threadId}/state`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return Mt(n)}async getStateHistory(t){const n=await qt(`/threads/${t.threadId}/state/history`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs},timeout:Jc});return Mt(n)}async cancelRun(t){const n=await zo("/runs/cancel",{threadId:t});return Mt(n)}async unshareThread(t,n){const r=await ki(`/threads/${t}/share/${n}`);return Mt(r)}}const An=new Ho,Av=Ho,jv=Ho;async function Ei(e,t){return await qt(e,{responseType:"blob",onDownloadProgress:r=>{try{if(t&&r.lengthComputable){const o=r.loaded/r.total;t(o)}}catch{}},maxBodyLength:1/0})}async function _v(e,t){const n=await Ei(`/files/${e}/view`,t),r=URL.createObjectURL(n);window.open(r,"_blank"),setTimeout(()=>URL.revokeObjectURL(r),6e4)}async function Ii(e,t){return await(await Ei(`/files/${e}/view`,t)).text()}async function Qc(e,t){const n=await Ei(`/files/${e}/download`,t),r=URL.createObjectURL(n);let o=`file_${e}`;try{const i=await qt(`/files/${e}`);o=(i==null?void 0:i.filename)??o}catch{}const s=document.createElement("a");s.href=r,s.download=o,document.body.appendChild(s),s.click(),s.remove(),setTimeout(()=>URL.revokeObjectURL(r),6e4)}async function Pv(e){return await qt(`/files/${e}`)}async function eu(e,t=50,n=0){const r={limit:t,offset:n};return e&&(r.thread_id=e),await qt("/files",{params:r})}const tu=b.createContext(null);function nu({children:e,apiConfig:t}){const n=An;if(t){const o=n.baseUrl,s=n.getAuthToken();t.baseUrl&&t.baseUrl!==o&&n.updateConfig({baseUrl:t.baseUrl}),t.apiKey!==void 0&&t.apiKey!==s&&n.updateConfig({authToken:t.apiKey})}const r={token:n.getAuthToken(),setToken:o=>n.setAuthToken(o),api:n,baseUrl:n.baseUrl};return u.jsx(tu.Provider,{value:r,children:e})}async function ru(e){return await new Promise((t,n)=>{const r=new FileReader;r.onload=()=>{try{const o=r.result,s=new Uint8Array(o);let i="";const a=s.byteLength;for(let l=0;l<a;l++)i+=String.fromCharCode(s[l]);t(btoa(i))}catch(o){n(o)}},r.onerror=o=>n(o),r.readAsArrayBuffer(e)})}async function ou(e=[]){const t=[],n=[];for(const r of e)try{const o=await ru(r);n.push({filename:r.name,data:o,mime_type:r.type||"application/octet-stream"})}catch{}return{contentParts:t,filesInfo:n}}function Vr(){const e=b.useContext(tu);if(!e)throw new Error("useApi must be used within ApiProvider");return e}function su(e){return!!e&&typeof e=="object"&&e.protocolVersion==="v1"&&"data"in e}function Mv(e={}){const t=b.useMemo(()=>mn(e.baseUrl),[e.baseUrl]),n=e.streamPath??"/runs/stream",[r,o]=b.useState(e.token??null),s=b.useRef(e.headers??{}),i=e.credentials??"include",[a,l]=b.useState(!1),[c,d]=b.useState(null),[p,m]=b.useState(""),[f,v]=b.useState(null),[g,x]=b.useState(0),[y,w]=b.useState(!1),S=b.useRef(null),k=b.useRef(!0),C=b.useRef(0),T=b.useRef(null),E=b.useRef(null),_=b.useRef(null),R=b.useRef(null),L=b.useCallback(I=>{o(I)},[]),H=b.useCallback(()=>{m(""),v(null),d(null),E.current=null,_.current=null,R.current=null},[]),K=b.useCallback(()=>{var I;console.debug("[use-chat] stop() invoked - aborting stream"),(I=S.current)==null||I.abort(),S.current=null,T.current=null,l(!1),w(!1),C.current=0,x(0)},[]),B=b.useCallback((I,W,N)=>{S.current&&(S.current.abort(),S.current=null),l(!0),d(null),e.autoAppendAssistant!==!1&&m(""),v(null),E.current=null,_.current=null,R.current=null;const U=new AbortController;S.current=U;let O=null,j=null,q=!1;return T.current={threadId:I.threadId??null,headers:{}},(async()=>{var P,M,G,Z,se,V,D,X,Q,ae,$,re,we,de,xe,Ee,Be,We;const J=je=>{var Ve;try{const Xe=JSON.parse(JSON.stringify(je));return(Ve=Xe==null?void 0:Xe.payload)!=null&&Ve.files_info&&Array.isArray(Xe.payload.files_info)&&(Xe.payload.files_info=Xe.payload.files_info.map(ze=>({...ze,data:ze!=null&&ze.data?`<base64 ${String(ze.data).length} chars>`:ze==null?void 0:ze.data}))),Xe}catch{return je}};try{let je={};try{if(r)je={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const Ke=window.__AUTH_TOKEN__,Ct=((P=window.localStorage)==null?void 0:P.getItem("authToken"))||null;let Ze=null;try{const le=(M=window.localStorage)==null?void 0:M.getItem("chat-settings");le&&(Ze=((G=JSON.parse(le))==null?void 0:G.apiKey)||null)}catch{}const pt=Ke||Ct||Ze||null;pt&&(je={Authorization:`Bearer ${pt}`})}}catch{}console.debug("[use-chat] POST",t+n,J(I));let Ve={};if(typeof window<"u")try{const Me=(Z=window.localStorage)==null?void 0:Z.getItem("authSessionId");Me&&(Ve={"X-Session-Id":Me})}catch{}const Xe={...je,...Ve,...s.current},ze={"Content-Type":"application/json",Accept:"text/event-stream",...Xe},Ge=await fetch(t+n,{method:"POST",headers:ze,body:JSON.stringify(I),signal:U.signal,credentials:i});if(T.current&&(T.current.headers=Xe),!Ge.ok||!Ge.body){const Me=await Ge.text().catch(()=>"");console.debug("[use-chat] non-OK response",Ge.status,Me==null?void 0:Me.slice(0,500));const Ke=`stream ${Ge.status}${Me?": "+Me:""}`;throw(se=N==null?void 0:N.onConnectionError)==null||se.call(N,Ke),q=!0,O="error",j=Ke,new Error(Ke)}w(!0);const rt=Ge.body.getReader(),nt=new TextDecoder;let et="",xt=[];C.current=0,x(0);let vt=0,dt=null;const Et=()=>{if(xt.length){const Me=xt.join("");xt=[],k.current&&m(Ke=>Ke+Me)}dt=null},Dt=()=>{typeof window<"u"&&dt==null&&(dt=requestAnimationFrame(Et))};let $e=Date.now();const Pt=setInterval(()=>{var Me;if(Date.now()-$e>18e5){const Ke="Stream idle timeout";d(Ke),O="error",j=Ke,U.abort(),(Me=N==null?void 0:N.onError)==null||Me.call(N,Ke)}},5e3),nn=1024*1024;try{const Me=Ge.headers.get("X-Thread-Id")||Ge.headers.get("x-thread-id"),Ke=Ge.headers.get("X-Thread-Created")||Ge.headers.get("x-thread-created"),Ct=Me??null,Ze=String(Ke??"").toLowerCase()==="true";for(T.current&&!T.current.threadId&&(T.current={...T.current,threadId:Ct}),(V=N==null?void 0:N.onOpen)==null||V.call(N,{threadId:Ct,created:Ze});;){const{value:pt,done:le}=await rt.read();if(le)break;et+=nt.decode(pt,{stream:!0}),et.length>nn&&(et="",console.warn("Stream buffer reset: exceeded 1MB"));let Y;for(;(Y=et.indexOf(`
36
36
 
37
37
  `))>=0;){const ge=et.slice(0,Y);et=et.slice(Y+2);const it=ge.split(/\r?\n/),Ce=[];for(const Fe of it)if(!(!Fe||Fe.startsWith(":"))&&Fe.startsWith("data:")){const tt=Fe.slice(5);Ce.push(tt.startsWith(" ")?tt.slice(1):tt)}const Oe=Ce.join(`
38
- `);if(!Oe)continue;let qe;try{qe=JSON.parse(Oe)}catch{console.debug("[use-chat] malformed SSE:",Oe.slice(0,200));continue}const Tt=su(qe)?qe.data:qe;if(!Tt){console.warn("[use-chat] dropped envelope event without payload",qe);continue}const He=Tt;$e=Date.now();const ft=He.seq;if(ft!==void 0){if(ft<=vt){console.debug("[use-chat] drop duplicate/out-of-order event",{seq:ft,lastProcessedSeq:vt,type:He.type});continue}vt>0&&ft>vt+1&&((D=N==null?void 0:N.onGap)==null||D.call(N,{from:vt,to:ft})),vt=ft,C.current=ft,x(ft)}if(He.type==="checkpoint")E.current=He.checkpointId??null,_.current=He.checkpointNs??null,v(He.checkpointId??null);else if(He.type==="state_history"){R.current=He;try{const tt=Nn(He).latest;tt&&(E.current=tt.checkpointId??null,_.current=tt.checkpointNs??null,v(tt.checkpointId??null))}catch(Fe){console.warn("[use-chat] Failed to hydrate state_history payload",Fe)}}try{W==null||W(He)}catch(Fe){console.error("[use-chat] Error in onEvent callback:",Fe,"for event:",He.type)}if(He.type==="message.delta"){const Fe=He.delta.filter(tt=>tt.type==="text").map(tt=>tt.text).join("");Fe&&e.autoAppendAssistant!==!1&&(xt.push(Fe),Dt())}else if(He.type==="heartbeat"){console.debug("[use-chat] heartbeat received");try{(X=N==null?void 0:N.onHeartbeat)==null||X.call(N,He)}catch(Fe){console.warn("[use-chat] heartbeat callback failed",Fe)}}else if(dt!==null&&cancelAnimationFrame(dt),Et(),He.type==="checkpoint")v(He.checkpointId);else if(He.type==="error"){const Fe=He;if(d(Fe.message),O="error",j=Fe.message,Fe.error_type==="auth_error"||Fe.code==="TOKEN_EXPIRED"||((Q=Fe.message)==null?void 0:Q.includes("token"))||((ae=Fe.message)==null?void 0:ae.includes("401"))||(($=Fe.message)==null?void 0:$.includes("unauthorized"))||((re=Fe.message)==null?void 0:re.includes("Unauthorized"))){console.error("[use-chat] Auth error detected:",Fe.message);try{(we=N==null?void 0:N.onAuthError)==null||we.call(N,Fe.message)}catch(Ut){console.warn("[use-chat] onAuthError handler failed",Ut)}U.abort()}}}}Et(),O===null&&!U.signal.aborted&&(O="complete")}catch(Me){if(Me.name==="AbortError")O=O??"aborted";else{const Ke=Me.message||String(Me);O="error",j=Ke,d(Ke),(de=N==null?void 0:N.onError)==null||de.call(N,Ke)}}finally{try{await rt.cancel()}catch{}finally{(xe=rt.releaseLock)==null||xe.call(rt)}dt!==null&&typeof window<"u"&&window.cancelAnimationFrame(dt),clearInterval(Pt)}}catch(je){if(je.name==="AbortError")O=O??"aborted";else{const Ve=je.message||String(je);O="error",j=Ve,d(Ve),(Ee=N==null?void 0:N.onError)==null||Ee.call(N,Ve),q||((Be=N==null?void 0:N.onConnectionError)==null||Be.call(N,Ve),q=!0)}}finally{const je=C.current,Ve=E.current,Xe=_.current,ze=R.current,Ge=O??(U.signal.aborted?"aborted":j?"error":"complete");try{(We=N==null?void 0:N.onClosed)==null||We.call(N,{reason:Ge,lastSeq:je,lastCheckpointId:Ve,lastCheckpointNs:Xe,lastStateHistory:ze,error:j})}catch(rt){console.warn("[use-chat] onClosed callback failed",rt)}l(!1),w(!1),S.current=null,C.current=0,x(0),T.current=null}})(),{close:()=>U.abort()}},[t,n,r,e.autoAppendAssistant]);return b.useEffect(()=>()=>{var I;k.current=!1,(I=S.current)==null||I.abort()},[]),{isStreaming:a,error:c,assistantText:p,lastCheckpointId:f,lastSeq:g,connected:y,stream:F,stop:K,clear:H,setToken:L}}const Mv=["detail","message","error","description","title"];function Uo(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=Uo(t);if(n)return n}return null}if(typeof e=="object"){const t=e;for(const n of Mv){const r=Uo(t[n]);if(r)return r}if("errors"in t){const n=Uo(t.errors);if(n)return n}}return null}function Rv(e){if(!e)return"Request failed";const t=e.response,n=Uo(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 iu({api:e,initialThreadId:t=null,onError:n,onThreadChange:r,onCurrentThreadDeleted:o}){const[s,i]=b.useState([]),[a,l]=b.useState(t),[c,d]=b.useState(!1),[p,m]=b.useState(null),[f,v]=b.useState([]),[g,x]=b.useState(!1),[,y]=b.useState(null),[w,S]=b.useState(null),[k,C]=b.useState(!1),T=b.useRef(a),E=b.useRef(new Map);b.useEffect(()=>{T.current=a},[a]);const _=b.useCallback(async()=>{d(!0),m(null);try{const O=await e.listThreads();i(O??[])}catch(O){const j=String(O);m(j),n==null||n(j)}finally{d(!1)}},[e,n]),R=b.useCallback(async()=>{x(!0),y(null);try{const O=await e.listSharedThreads();v(O??[])}catch(O){const j=String(O);y(j),n==null||n(j)}finally{x(!1)}},[e,n]);b.useEffect(()=>{_()},[_]),b.useEffect(()=>{R()},[R]),b.useEffect(()=>{r==null||r(a)},[a,r]);const L=b.useCallback(async O=>{try{const j=await e.createThread(O);return l(j.threadId),await _(),j.threadId}catch(j){const q=String(j);return n==null||n(q),null}},[e,n,_]),H=b.useCallback(async O=>{const j=s;i(J=>J.filter(P=>P.threadId!==O));const q=new AbortController;E.current.set(O,q);try{await e.deleteThread(O),T.current===O&&(l(null),o==null||o())}catch(J){i(j);const P=String(J);n==null||n(P)}finally{E.current.delete(O)}},[e,o,n,s]),K=b.useCallback(async(O,j)=>{try{await e.updateThread(O,j),await _()}catch(q){n==null||n(String(q))}},[e,n,_]),F=b.useCallback(async(O,j)=>{C(!0),S("Sharing thread…");try{await e.shareThread(O,j),await R(),S("Shared successfully")}catch(q){const J=Rv(q);throw n==null||n(J),S(`Failed to share: ${J}`),new Error(J)}finally{C(!1)}},[e,n,R]),I=b.useCallback(async(O,j)=>{try{await e.unshareThread(O,j),await R()}catch(q){const J=String(q);throw n==null||n(J),q}},[e,n,R]),W=b.useMemo(()=>({createThread:L,deleteThread:H,renameThread:K,refreshThreads:_,refreshSharedThreads:R,shareThread:F,unshareThread:I}),[L,H,K,_,R,F,I]),N=b.useCallback(O=>{if(!(O!=null&&O.threadId))return;const j={threadId:O.threadId,title:O.title||`Thread ${O.threadId.slice(0,8)}`,createdAt:O.createdAt||new Date().toISOString(),updatedAt:O.updatedAt||new Date().toISOString(),messageCount:O.messageCount??1};i(q=>{let J=!1;const P=q.map(M=>M.threadId===j.threadId?(J=!0,console.debug("[useThreadsState] thread_info: updating existing thread",j.threadId),{...M,title:j.title??M.title,updatedAt:j.updatedAt??M.updatedAt,messageCount:j.messageCount??M.messageCount}):M);return J?P:(console.debug("[useThreadsState] thread_info: adding thread to list",j.threadId),[j,...q])})},[]),U=b.useCallback(()=>S(null),[]);return{threads:s,currentThreadId:a,currentThreadIdRef:T,setCurrentThreadId:l,isLoadingThreads:c,threadsError:p,sharedThreads:f,isLoadingSharedThreads:g,actions:W,addThreadFromEvent:N,shareInFlight:k,shareStatus:w,clearShareStatus:U}}const au=b.createContext(null);function lu({children:e,initialThreadId:t=null,onError:n,onThreadChange:r}){const{api:o}=Vr(),{threads:s,currentThreadId:i,setCurrentThreadId:a,currentThreadIdRef:l,isLoadingThreads:c,threadsError:d,sharedThreads:p,isLoadingSharedThreads:m,actions:f,addThreadFromEvent:v,shareInFlight:g,shareStatus:x,clearShareStatus:y}=iu({api:o,initialThreadId:t,onError:n,onThreadChange:r}),w=b.useMemo(()=>({threads:s,currentThreadId:i,setCurrentThreadId:a,currentThreadIdRef:l,isLoading:c,error:d,sharedThreads:p,isLoadingSharedThreads:m,actions:f,shareInFlight:g,shareStatus:x,clearShareStatus:y,addThreadFromEvent:v}),[s,i,a,l,c,d,p,m,f,g,x,y,v]);return u.jsx(au.Provider,{value:w,children:e})}function pr(){const e=b.useContext(au);if(!e)throw new Error("useThreads must be used within a ThreadsProvider");return e}function Ni(e){const t=e==null?void 0:e.trim();if(!t||!(t.startsWith("{")||t.startsWith("[")))return null;try{return JSON.parse(t)}catch{return null}}function cu(e){return!!(e&&typeof e=="object"&&(e.type==="file"||e.mimeType||e.filename||e.sourceType==="base64"))}function Kr(e){if(typeof e=="string")return e;if(e&&typeof e=="object"){if(Array.isArray(e)){const n=e.map(Kr).filter(r=>r!==void 0);if(!n.length){console.debug("[message-utils] sanitizeForDisplay - array emptied -> returning undefined",{originalLength:e.length});return}return n}if(cu(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=Kr(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 hr(e){if(typeof e=="string")return e;if(cu(e))return"";try{const t=Kr(e);return t===void 0?"":typeof t=="string"?t:JSON.stringify(t,null,2)}catch{return""}}function Ov(e){return typeof e!="string"?!1:/^[\s\n]*[-*]\s|^[\s\n]*#+\s|```|^\s*\[.*\]\(|^>\s/.test(e)}function Dv(e){const t=hr(e);return typeof e=="string"&&Ov(e)?{content:e,isMarkdown:!0}:{content:t,isMarkdown:!1}}function qr(e){if(e==null)return e;if(typeof e=="string"){const t=e.trim();if(t.startsWith("{")||t.startsWith("[")){const n=Ni(t);if(n!==null)return qr(n)}return e}return typeof e=="object"&&!Array.isArray(e)&&e.content!==void 0?qr(e.content):e}function Lv(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function Ai(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 Wo(e){if(e==null)return null;const t=String(e).trim();return t.length>0?t:null}function $v(e){const t=r=>{try{const o=Kr(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 Fv(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function uu(e){if("type"in e&&e.type==="default_message")return`default:${e.content.length}`;const t=e.updatedAt??e.createdAt??"",n=Array.isArray(e.content)?e.content.map(r=>{switch(r.type){case"text":return`t:${r.text.length}`;case"image_url":return"img";case"file":return"file";case"tool_call":return"call";case"interrupt":return"interrupt";default:return"unknown"}}).join("|"):"";return`${e.id}:${t}:${n}`}function Bv(e){if(!e)return"image/png";const t=e.trim();return t?t.includes("/")?t:`image/${t}`:"image/png"}function zv(e){const t=[],n=r=>{r&&r.trim()&&t.push(r.trim())};return e&&(n(e.plotId),n(e.artifactId)),t}function Hv({base64:e,url:t,formatHint:n,extras:r}){const o=typeof e=="string"&&e.length>0,s=Bv(n),i=o?`data:${s};base64,${e}`:t,a=zv(r),l=a.length?a.join(" / "):void 0,c=l?`${l} artifact`:"artifact image";return{src:i,alt:c,label:l}}function Uv(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 Hv({base64:t,url:n,formatHint:r,extras:{plotId:e.plotId,artifactId:e.artifactId}})}function du(e){var n;const t=(n=e.additionalKwargs)==null?void 0:n.toolProgress;return Array.isArray(t)?t:[]}function ji(e){return e.filter(t=>{var i;if(t.role!=="assistant")return!0;const n=(t.content??[]).some(a=>{var l;return a&&a.type==="text"&&((l=a.text)==null?void 0:l.trim())}),r=(t.content??[]).some(a=>a&&a.type==="image_url"),o=(i=t.artifact)==null?void 0:i.plots,s=Array.isArray(o)&&o.length>0;return!!(n||r||s)})}function Gr(e,t,n){return t<0||t>=e.length?e:[...e.slice(0,t),n,...e.slice(t+1)]}function Wv(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 fu(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="assistant")return e[t].id;return null}function pu(e){return!e||!e.length?"":e.filter(t=>t.type==="text").map(t=>t.text??"").join("")}function Vv(e,t,n,r){const o={...n};if(r!==null&&typeof r=="number"){if(typeof o.lastSeq=="number"&&r<=o.lastSeq)return{newParts:e,newMeta:o,changed:!1};o.lastSeq=r}const s=t.filter(p=>p.type==="text").map(p=>p.text??"").join(""),i=t.filter(p=>p.type!=="text"),a=o.lastText??pu(e);let l="",c=e.slice();if(s){const p=Kv(a,s);if(p===""?l="":p===s?l=s:l=p,l){const m=c[c.length-1];if((m==null?void 0:m.type)==="text"){const f=m.text??"",v={...m,text:f+l};c=[...c.slice(0,c.length-1),v]}else c=[...c,{type:"text",text:l}];o.lastText=a+l}else o.lastText=a}i.length&&(c=[...c,...i]);const d=!!(l||i.length);return{newParts:c,newMeta:o,changed:d}}function hu(e){return e.replace(/\s+/g," ").trim()}function Kv(e,t){if(!t)return"";if(!e)return t;if(e===t)return"";const n=Math.min(e.length,t.length);for(let i=n;i>0;i--)if(e.slice(-i)===t.slice(0,i))return t.slice(i);const r=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 Gr(e,r,s)}return e}function Gv(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}const Yv={messages:[],assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,messagesStreamMeta:{},pendingInterrupt:null};function Xv(e,t){var n;switch(t.type){case"reset":return{messages:ji(((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=ji(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=ji(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 mu(e,t.payload.ev);case"batch":{const{events:r}=t.payload;return r.length?r.reduce((o,s)=>mu(o,s),e):e}default:return e}}function Jv(e=[]){const[t,n]=b.useReducer(Xv,{...Yv,messages:e}),r=b.useRef([]),o=b.useRef(null),s=b.useRef(null),i=b.useCallback(()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),o.current=null,s.current=null;const d=r.current;d.length&&(r.current=[],n({type:"batch",payload:{events:d}}))},[]),a=b.useCallback(()=>{typeof window<"u"&&typeof window.requestAnimationFrame=="function"?o.current===null&&(o.current=window.requestAnimationFrame(()=>i())):s.current===null&&(s.current=setTimeout(i,8))},[i]),l=b.useCallback(d=>{r.current.push(d),a()},[a]);b.useEffect(()=>()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),r.current=[]},[]);const c=b.useMemo(()=>({reset:d=>n({type:"reset",payload:{messages:d}}),seed:(d,p)=>n({type:"seed",payload:{messages:d,...p??{}}}),prepend:d=>n({type:"prepend",payload:{messages:d}}),pushUser:(d,p)=>n({type:"user_message",payload:{message:d,editingMessageId:p}}),onEvent:l}),[l]);return{state:t,dispatch:n,...c}}function mu(e,t){var n,r,o;if(t.type==="message.start"&&t.role==="assistant"){const s=t.id,i=Gv(t.model);if(e.messages.some(c=>c.id===s)){const c=e.messagesStreamMeta??{},d={...c,[s]:c[s]??{lastSeq:t.seq??null,lastText:""}};return{...e,assemblingId:s,messagesStreamMeta:d}}const l={id:s,role:"assistant",name:i||void 0,model:t.model,createdAt:new Date().toISOString(),content:[]};return{...e,assemblingId:s,messages:[...e.messages,l]}}if(t.type==="tool.start")return Qv(e,t);if(t.type==="tool.progress")return ew(e,t);if(t.type==="tool.end")return tw(e,t);if(t.type==="message.delta"){const s=e.assemblingId??fu(e.messages);if(!s)return e;const i=e.messages,a=i.findIndex(C=>C.id===s&&C.role==="assistant");if(a===-1)return e;const l=i[a],c=e.messagesStreamMeta,d=c??{},p=d[s],m=p??{lastSeq:null,lastText:pu(l.content)},f=t.seq??null;if(f!==null&&typeof f=="number"&&typeof m.lastSeq=="number"&&f<=m.lastSeq)return console.debug("[MessageReducer] skipping delta - seq <= lastSeq",{seq:f,lastSeq:m.lastSeq}),e;const{newParts:v,newMeta:g,changed:x}=Vv(l.content,t.delta,m,f);if(!x)return e;const y={...l,content:v},w=Gr(i,a,y),S=!p||p.lastSeq!==g.lastSeq||p.lastText!==g.lastText,k=S?{...d,[s]:g}:c;return S?{...e,messages:w,messagesStreamMeta:k}:{...e,messages:w}}if(t.type==="message.end"){const s=e.assemblingId??fu(e.messages);if(!s)return{...e,assemblingId:null};const i=e.messages,a=i.findIndex(l=>l.id===s&&l.role==="assistant");if(a>=0){const l=i[a];if(!((n=l.content)==null?void 0:n.some(d=>{var p;return(d==null?void 0:d.type)==="text"&&((p=d.text)==null?void 0:p.trim())}))){console.debug("[MessageReducer] pruning assistant message with no visible text",{id:l.id,contentTypes:(r=l.content)==null?void 0:r.map(p=>p==null?void 0:p.type),contentPreview:(o=l.content)==null?void 0:o.map(p=>(p==null?void 0:p.type)==="text"?String(p.text).slice(0,100):p==null?void 0:p.type)});const d=[...i.slice(0,a),...i.slice(a+1)];return{...e,assemblingId:null,messages:d}}}return e}if(t.type==="checkpoint"){const s=t.checkpointNs??e.lastCheckpointNs??null,i=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=Nn(t),i=s.interrupt,a=s.latest,l=i===null?Wv(e.messages):e.messages;return{...e,messages:l,pendingInterrupt:i,lastCheckpointId:(a==null?void 0:a.checkpointId)??e.lastCheckpointId,lastCheckpointNs:(a==null?void 0:a.checkpointNs)??e.lastCheckpointNs}}return t.type==="thread_info",e}function _i(e){return e.call_id??e.id??null}function gu(e){return e.id??e.call_id??`tool-${Date.now()}-${Math.random().toString(16).slice(2)}`}function xu(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 Pi(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||Ai(r).toolCallId===t)return n}return-1}function Zv(e){if(e==null)return[];const t=qr(e);if(typeof t=="string"&&t.trim())return[{type:"text",text:t}];const n=hr(t??e);return n?[{type:"text",text:n}]:[]}function vu(e,t){const n=e.additionalKwargs??{},r=Array.isArray(n.toolProgress)?[...n.toolProgress]:[],o={...n,toolProgress:[...r,t]};return{...e,additionalKwargs:o}}function Qv(e,t){const n=_i(t),r=Pi(e.messages,n),o=t.name??t.tool??void 0,s=gu(t);if(r>=0){const a=e.messages[r],c={...a.additionalKwargs??{},toolStreaming:!0,toolProgress:[]},d={...a,name:o??a.name,additionalKwargs:c};return{...e,messages:Gr(e.messages,r,d)}}const i=xu(s,n,o,t.args);return{...e,messages:[...e.messages,i]}}function ew(e,t){const n=_i(t);if(!n)return e;const r=Pi(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=vu(e.messages[r],o);return{...e,messages:Gr(e.messages,r,a)}}function tw(e,t){const n=_i(t),r=gu(t);let o=e.messages,s=Pi(o,n);if(s===-1){const v=t.name??t.tool??void 0;o=[...o,xu(r,n,v,{})],s=o.length-1}const i=o[s],a=t.output??t.error??null,l=Zv(a),c=[...i.content,...l],d={type:t.type,content:typeof t.output=="string"?t.output:void 0,seq:t.seq??null,timestamp:new Date().toISOString()};t.artifact&&(d.artifact=t.artifact);const p=vu(i,d),m=t.artifact??i.artifact,f={...p,name:t.name??t.tool??i.name,content:c,artifact:m,additionalKwargs:{...p.additionalKwargs??{},toolStreaming:!1}};return{...e,messages:Gr(o,s,f)}}function wu({api:e,seed:t,prepend:n,onError:r,currentThreadId:o,initialThreadId:s=null,initialCheckpointId:i=null,initialCheckpointNs:a=null,autoLoadInitial:l=!0,isStreaming:c,getMessages:d}){const[p,m]=b.useState(null),v=b.useMemo(()=>Nn(p),[p]).checkpoints,g=nc(v),x=g.timeline,[y,w]=b.useState(!1),[S,k]=b.useState(null),[C,T]=b.useState(!1),[E,_]=b.useState(!1),[R,L]=b.useState(!1),[H,K]=b.useState(null),F=b.useRef(o),I=b.useRef(null),W=b.useRef(null),N=b.useRef(null),U=b.useRef(null),O=b.useRef(!1),j=b.useRef(null),q=b.useRef(new Map);b.useEffect(()=>{F.current=o},[o]);const J=b.useCallback(async $=>{var we,de;if(!$.threadId)return;const re=$.threadId;(we=$.onStart)==null||we.call($),$.setLoading(!0);try{await $.action(re)}catch(xe){if(F.current===re){const Ee=String(xe);(de=$.handleError)==null||de.call($,Ee),r==null||r(Ee)}throw xe}finally{$.setLoading(!1)}},[r]),P=b.useCallback(async($,re)=>{if(!$)return;const we=`${$}:${re??"latest"}`,de=q.current.get(we);if(de)return de;const xe=J({threadId:$,setLoading:T,onStart:()=>K(null),handleError:Ee=>K(Ee),action:async Ee=>{const Be=await e.getStateHistory({threadId:Ee,checkpointId:re??void 0});if(F.current!==Ee){console.log(`[useThreadHistoryState] Thread changed during load (was ${Ee}, now ${F.current}), discarding stale data`);return}const{checkpoints:We}=Nn(Be),je=We.find(Ve=>Ve.messages&&Ve.messages.length>0)??(re?We.find(Ve=>Ve.checkpointId===re):null)??We[0];t((je==null?void 0:je.messages)??[],{checkpointId:(je==null?void 0:je.checkpointId)??null,checkpointNs:(je==null?void 0:je.checkpointNs)??null}),m(Be),w(!!(je!=null&&je.nextCursor)),k((je==null?void 0:je.nextCursor)??null)}});q.current.set(we,xe);try{await xe}finally{q.current.delete(we)}return F.current===$&&(j.current=we),xe},[e,t,J]),M=b.useCallback(async($,re)=>{U.current=$;try{await P($,re)}finally{U.current===$&&(U.current=null)}},[P]),G=b.useCallback($=>{W.current=$},[]),Z=b.useCallback($=>{N.current=$},[]),se=b.useCallback($=>{const re=$.threadId??F.current;if(!re||F.current&&F.current!==re)return;const{checkpoints:we}=Nn($);if(!we.length)return;const de=we.find(xe=>xe.messages&&xe.messages.length>0)??we.find(xe=>!!xe.checkpointId)??we[0];t((de==null?void 0:de.messages)??[],{checkpointId:(de==null?void 0:de.checkpointId)??null,checkpointNs:(de==null?void 0:de.checkpointNs)??null}),m($),w(!!(de!=null&&de.nextCursor)),k((de==null?void 0:de.nextCursor)??null),j.current=`${re}:latest`,W.current=null,N.current=null},[t]),V=b.useCallback(async($,re)=>{const we=F.current;await J({threadId:we,setLoading:L,action:async de=>{const xe=await e.getStateHistory({threadId:de,checkpointId:$,checkpointNs:re??void 0});if(F.current!==de){console.log(`[useThreadHistoryState] Thread changed during checkpoint navigation (was ${de}, now ${F.current}), discarding stale data`);return}const{checkpoints:Ee}=Nn(xe),Be=Ee.find(We=>We.checkpointId===$&&(re?We.checkpointNs===re:!0));if(!Be){console.warn("[useThreadHistoryState] Requested checkpoint not found:",{checkpointId:$,checkpointNs:re});return}m(xe),t(Be.messages??[],{checkpointId:Be.checkpointId??null,checkpointNs:Be.checkpointNs??null})}}).catch(()=>{})},[e,t,J]),D=b.useCallback(($,re)=>{t(d(),{checkpointId:$??null,checkpointNs:re??null})},[d,t]),X=b.useCallback(async()=>{F.current&&await M(F.current)},[M]),Q=b.useCallback(async()=>{const $=F.current;!$||!S||await J({threadId:$,setLoading:_,action:async re=>{const we=await e.getStateHistory({threadId:re,checkpointId:S});if(F.current!==re)return;const{checkpoints:de}=Nn(we);if(de.length>0){const xe=de[de.length-1];n((xe==null?void 0:xe.messages)??[]),w(!!(xe!=null&&xe.nextCursor)),k((xe==null?void 0:xe.nextCursor)??null)}}}).catch(()=>{})},[e,S,r,n,J]);b.useEffect(()=>{if(!l||!o||C||c)return;if(W.current===o){W.current=null,I.current=o;return}if(N.current===o){I.current=o;return}if(U.current===o){U.current=null,I.current=o;return}if(I.current===o)return;I.current=o;const $=!O.current&&!!i&&o===s;let re;$&&i?(re=i,O.current=!0,console.log("[useThreadHistoryState] Loading thread with checkpoint:",re,a?`(ns: ${a})`:"")):console.log("[useThreadHistoryState] Loading thread with latest checkpoint");const we=`${o}:${re??"latest"}`;j.current!==we&&M(o,re)},[l,o,i,a,s,C,c,M]);const ae=b.useCallback(()=>{m(null),w(!1),k(null),T(!1),_(!1),L(!1),K(null),W.current=null,N.current=null,I.current=null,j.current=null,U.current=null},[]);return{threadCheckpoints:v,threadTimeline:x,checkpointIndex:g,isLoadingThread:C,isHistoryLoading:E,isLoadingCheckpoint:R,threadStateError:H,hasMoreHistory:y,loadThread:M,navigateToCheckpoint:V,loadOlderMessages:Q,setCurrentCheckpointId:D,returnToLatest:X,handleStateHistoryEvent:se,markSkipNextLoad:G,markStreamPendingThread:Z,resetHistoryState:ae}}const bu=b.createContext(null),yu=b.createContext(null);function Yr(){const e=b.useContext(bu);if(!e)throw new Error("useThreadState must be used within a ThreadStateProvider");return e}function Su(){const e=b.useContext(yu);if(!e)throw new Error("useThreadStateUpdater must be used within a ThreadStateProvider");return e}function Cu({children:e,initialThreadId:t=null,initialCheckpointId:n=null,initialCheckpointNs:r=null,autoLoadInitial:o=!0,isStreaming:s,onError:i}){const{api:a}=Vr(),{currentThreadId:l}=pr(),{state:c,seed:d,prepend:p,pushUser:m,onEvent:f}=Jv(),{threadCheckpoints:v,threadTimeline:g,checkpointIndex:x,isLoadingThread:y,isHistoryLoading:w,isLoadingCheckpoint:S,threadStateError:k,hasMoreHistory:C,loadThread:T,navigateToCheckpoint:E,loadOlderMessages:_,setCurrentCheckpointId:R,returnToLatest:L,handleStateHistoryEvent:H,markSkipNextLoad:K,markStreamPendingThread:F,resetHistoryState:I}=wu({api:a,seed:d,prepend:p,onError:i,currentThreadId:l,initialThreadId:t,initialCheckpointId:n,initialCheckpointNs:r,autoLoadInitial:o,isStreaming:s,getMessages:b.useCallback(()=>c.messages,[c.messages])}),[W,N]=b.useState(()=>async()=>{throw new Error("clearThread is not ready")}),[U,O]=b.useState(()=>async()=>{throw new Error("respondToInterrupt is not ready")});b.useEffect(()=>{l||(d([],{}),I())},[l,d,I]);const j=b.useCallback(G=>N(()=>G),[]),q=b.useCallback(G=>O(()=>G),[]),J=b.useMemo(()=>{const G=c.assemblingId??null;return G?{assemblingMessageId:G}:null},[c.assemblingId]),P=b.useMemo(()=>({threadId:l,messages:c.messages,interrupt:c.pendingInterrupt,checkpoint:{id:c.lastCheckpointId??null,namespace:c.lastCheckpointNs??null},checkpoints:v,checkpointIndex:x,timelineCheckpoints:g,metadata:J,isLoading:y,isHistoryLoading:w,isLoadingCheckpoint:S,error:k,hasMore:C,loadOlder:_,clearState:W,navigateToCheckpoint:E,setCurrentCheckpointId:R,returnToLatest:L,loadThread:T,clearThread:W,respondToInterrupt:U,messagePreviews:x.messagePreviews,handleStateHistoryEvent:H,markSkipNextLoad:K,markStreamPendingThread:F,resetHistoryState:I,pushUser:m,onEvent:f}),[l,c,v,g,x,J,y,w,S,k,C,_,W,E,R,L,T,U,x.messagePreviews,H,K,F,I,m,f]),M=b.useMemo(()=>({registerClearThread:j,registerRespondToInterrupt:q}),[j,q]);return u.jsx(yu.Provider,{value:M,children:u.jsx(bu.Provider,{value:P,children:e})})}const Tu=b.createContext(null),ku=b.createContext(!1);function nw({children:e,initialThreadId:t=null,initialCheckpointId:n=null,initialCheckpointNs:r=null,autoLoadInitial:o=!0,onError:s,onAuthError:i,onThreadChange:a,onConnectionError:l,onToolEnd:c}){const{api:d,baseUrl:p}=Vr(),m=b.useMemo(()=>mn(p),[p]),{stream:f,stop:v,isStreaming:g,error:x,setToken:y}=Pv({baseUrl:m}),[w,S]=b.useState(!1);return b.useEffect(()=>{S(g)},[g]),u.jsx(lu,{initialThreadId:t,onError:s,onThreadChange:a,children:u.jsx(Cu,{initialThreadId:t,initialCheckpointId:n,initialCheckpointNs:r,autoLoadInitial:o,onError:s,isStreaming:w,children:u.jsx(ku.Provider,{value:!0,children:u.jsx(rw,{api:d,streamApi:{stream:f,stop:v,isStreaming:g,error:x,setToken:y},onError:s,onAuthError:i,onConnectionError:l,onToolEnd:c,children:e})})})})}function rw({children:e,api:t,streamApi:n,onError:r,onAuthError:o,onConnectionError:s,onToolEnd:i}){const{stream:a,stop:l,isStreaming:c,error:d,setToken:p}=n,{setCurrentThreadId:m,currentThreadIdRef:f,addThreadFromEvent:v}=pr(),{checkpoint:g,timelineCheckpoints:x,handleStateHistoryEvent:y,markSkipNextLoad:w,markStreamPendingThread:S,resetHistoryState:k,pushUser:C,onEvent:T}=Yr(),{registerClearThread:E,registerRespondToInterrupt:_}=Su(),R=b.useCallback(N=>{v(N),f.current!==N.threadId&&((N.created??!f.current)&&w(N.threadId),S(N.threadId),m(N.threadId))},[v,w,S,m,f]),L=b.useCallback(N=>{N.type==="thread_info"?R(N):N.type==="state_history"?y(N):N.type==="tool.end"?i==null||i(N):T(N)},[R,y,T,i]),H=b.useCallback(N=>{a(N,L,{onError:U=>{console.error("[StreamingProvider] Stream error:",U),r==null||r(U)},onAuthError:U=>{console.error("[StreamingProvider] Auth error:",U),o==null||o(U)},onConnectionError:U=>{console.error("[StreamingProvider] Connection error:",U),s==null||s(U)}})},[a,L,r,o,s]),K=b.useCallback(async(N,U,O)=>{const j=f.current;if(!j)throw new Error("No active thread to handle interrupt");const q=U?O??!0:!1,J={threadId:j,checkpointId:g.id??void 0,checkpointNs:g.namespace??void 0,command:{kind:"resume",value:q}};H(J)},[g,f,H]);b.useEffect(()=>{_(K)},[K,_]);const F=b.useCallback(async()=>{l(),k(),m(null);try{await t.getAgent("default")}catch(N){console.warn("[StreamingProvider] Failed to refetch agent after clearing thread:",N)}},[t,k,m,l]);b.useEffect(()=>{E(F)},[F,E]);const I=b.useCallback(async(N,U)=>{let O=f.current;const j=(N==null?void 0:N.text)??"",q=(N==null?void 0:N.attachments)??[],J=(j==null?void 0:j.trim())??"",P={...(N==null?void 0:N.payload)??{}},M=Array.isArray(P.messages)?P.messages:void 0;M&&delete P.messages;const G=!!(M&&M.length);if(!O&&!J&&q.length===0&&!G)return;if(!O){const de=Math.floor(Date.now()/1e3).toString(16).padStart(8,"0"),xe=Array.from({length:4},()=>Math.floor(Math.random()*4294967295).toString(16).padStart(8,"0")).join("").slice(0,16);O=`${de}${xe}`,w(O),m(O)}const{contentParts:Z,filesInfo:se}=await ou(q),V=[...Z];J&&V.push({type:"text",text:j});const D=U==null?void 0:U.originalMessageId,X=!!(U!=null&&U.edit&&D),Q=!G&&V.length>0;let ae=null;Q&&(ae={id:X?D:`msg-${Date.now()}`,role:"user",content:V,createdAt:new Date().toISOString()},X?C(ae,D):C(ae));const $=G?M:ae?[ae]:[],re={...P,...se.length?{files_info:se}:{}};$.length?re.messages=$:"messages"in re||(re.messages=[]);const we={threadId:O,payload:re,checkpointId:g.id??void 0,checkpointNs:g.namespace??void 0,edit:!!(U!=null&&U.edit),timelineCheckpoints:x};H(we)},[g,f,w,C,H,x]),W=b.useMemo(()=>({isStreaming:c,error:d,connectionState:c?"connected":"idle",submit:I,send:I,stop:l,setAuthToken:p}),[c,d,I,l,p]);return u.jsx(Tu.Provider,{value:W,children:e})}function Mi(){const e=b.useContext(Tu);if(!e)throw new Error("useStream must be used within StreamingProvider");return e}function ow(){return b.useContext(ku)}function Xr({children:e,apiConfig:t,initialThreadId:n=null,initialCheckpointId:r=null,initialCheckpointNs:o=null,autoLoadInitial:s=!0,onConnectionError:i,onError:a,onAuthError:l,onThreadChange:c,onToolEnd:d}){return u.jsx(nu,{apiConfig:t,children:u.jsx(nw,{initialThreadId:n,initialCheckpointId:r,initialCheckpointNs:o,autoLoadInitial:s,onError:a,onAuthError:l,onConnectionError:i,onThreadChange:c,onToolEnd:d,children:e})})}function mr(e){if(!(typeof globalThis>"u"))return globalThis[e]}function sw(e){if(typeof e!="string")return;const t=e.trim();if(t)return mn(t)}function Eu(){const e=[mr("__API_BASE_URL__"),mr("__CHAT_API_BASE_URL__"),mr("__CHAT_API_URL__")];for(const t of e){const n=sw(t);if(n)return n}}function Iu(){const e=[mr("__API_AUTH_TOKEN__"),mr("__CHAT_API_KEY__"),mr("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function Nu(...e){for(const t of e)if(typeof t=="string"&&t.trim())return mn(t);return mn()}function Au(){const e={},t=Eu(),n=Iu();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function ju(){const e=Au(),t=An.getAuthToken(),n=Eu();return{apiBaseUrl:Nu(e.baseUrl,An.baseUrl,n),apiKey:t||e.apiKey||Iu()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,darkMode:!1,enableSound:!1,messageHistory:100}}const Ri="chat-settings";function _u(){try{const e=localStorage.getItem(Ri);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function Pu(e){try{const t={...e,apiBaseUrl:mn(e.apiBaseUrl)};localStorage.setItem(Ri,JSON.stringify(t)),t.apiKey&&An.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function iw(){const e=ju(),t=_u(),n=An.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:Nu(An.baseUrl,r,e.apiBaseUrl)}}function aw(e){An.updateConfig({baseUrl:e.apiBaseUrl,authToken:e.apiKey??void 0}),Pu(e)}function ne(...e){return Jg.twMerge(Xg.clsx(e))}const lw=Dr.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"}}),at=h.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?Vt.Slot:"button";return u.jsx(i,{className:ne(lw({variant:t,size:n,className:e})),ref:s,...o})});at.displayName="Button";function ie(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}function Mu(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function jn(...e){return t=>{let n=!1;const r=e.map(o=>{const s=Mu(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():Mu(e[o],null)}}}}function De(...e){return h.useCallback(jn(...e),e)}function cw(e,t){const n=h.createContext(t),r=s=>{const{children:i,...a}=s,l=h.useMemo(()=>a,Object.values(a));return u.jsx(n.Provider,{value:l,children:i})};r.displayName=e+"Provider";function o(s){const i=h.useContext(n);if(i)return i;if(t!==void 0)return t;throw new Error(`\`${s}\` must be used within \`${e}\``)}return[r,o]}function sn(e,t=[]){let n=[];function r(s,i){const a=h.createContext(i),l=n.length;n=[...n,i];const c=p=>{var y;const{scope:m,children:f,...v}=p,g=((y=m==null?void 0:m[e])==null?void 0:y[l])||a,x=h.useMemo(()=>v,Object.values(v));return u.jsx(g.Provider,{value:x,children:f})};c.displayName=s+"Provider";function d(p,m){var g;const f=((g=m==null?void 0:m[e])==null?void 0:g[l])||a,v=h.useContext(f);if(v)return v;if(i!==void 0)return i;throw new Error(`\`${p}\` must be used within \`${s}\``)}return[c,d]}const o=()=>{const s=n.map(i=>h.createContext(i));return function(a){const l=(a==null?void 0:a[e])||s;return h.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return o.scopeName=e,[r,uw(o,...t)]}function uw(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(s){const i=r.reduce((a,{useScope:l,scopeName:c})=>{const p=l(s)[`__scope${c}`];return{...a,...p}},{});return h.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var kt=globalThis!=null&&globalThis.document?h.useLayoutEffect:()=>{},dw=h[" useInsertionEffect ".trim().toString()]||kt;function _n({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=fw({defaultProp:t,onChange:n}),a=e!==void 0,l=a?e:o;{const d=h.useRef(e!==void 0);h.useEffect(()=>{const p=d.current;p!==a&&console.warn(`${r} is changing from ${p?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),d.current=a},[a,r])}const c=h.useCallback(d=>{var p;if(a){const m=pw(d)?d(e):d;m!==e&&((p=i.current)==null||p.call(i,m))}else s(d)},[a,e,s,i]);return[l,c]}function fw({defaultProp:e,onChange:t}){const[n,r]=h.useState(e),o=h.useRef(n),s=h.useRef(t);return dw(()=>{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 pw(e){return typeof e=="function"}var hw=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],be=hw.reduce((e,t)=>{const n=Vt.createSlot(`Primitive.${t}`),r=h.forwardRef((o,s)=>{const{asChild:i,...a}=o,l=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),u.jsx(l,{...a,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Oi(e,t){e&&Lr.flushSync(()=>e.dispatchEvent(t))}function Vo(e){const t=e+"CollectionProvider",[n,r]=sn(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=g=>{const{scope:x,children:y}=g,w=b.useRef(null),S=b.useRef(new Map).current;return u.jsx(o,{scope:x,itemMap:S,collectionRef:w,children:y})};i.displayName=t;const a=e+"CollectionSlot",l=Vt.createSlot(a),c=b.forwardRef((g,x)=>{const{scope:y,children:w}=g,S=s(a,y),k=De(x,S.collectionRef);return u.jsx(l,{ref:k,children:w})});c.displayName=a;const d=e+"CollectionItemSlot",p="data-radix-collection-item",m=Vt.createSlot(d),f=b.forwardRef((g,x)=>{const{scope:y,children:w,...S}=g,k=b.useRef(null),C=De(x,k),T=s(d,y);return b.useEffect(()=>(T.itemMap.set(k,{ref:k,...S}),()=>void T.itemMap.delete(k))),u.jsx(m,{[p]:"",ref:C,children:w})});f.displayName=d;function v(g){const x=s(e+"CollectionConsumer",g);return b.useCallback(()=>{const w=x.collectionRef.current;if(!w)return[];const S=Array.from(w.querySelectorAll(`[${p}]`));return Array.from(x.itemMap.values()).sort((T,E)=>S.indexOf(T.ref.current)-S.indexOf(E.ref.current))},[x.collectionRef,x.itemMap])}return[{Provider:i,Slot:c,ItemSlot:f},v,r]}var mw=h.createContext(void 0);function Ko(e){const t=h.useContext(mw);return e||t||"ltr"}function mt(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 gw(e,t=globalThis==null?void 0:globalThis.document){const n=mt(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 xw="DismissableLayer",Di="dismissableLayer.update",vw="dismissableLayer.pointerDownOutside",ww="dismissableLayer.focusOutside",Ru,Ou=h.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),gr=h.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...l}=e,c=h.useContext(Ou),[d,p]=h.useState(null),m=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,f]=h.useState({}),v=De(t,E=>p(E)),g=Array.from(c.layers),[x]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),y=g.indexOf(x),w=d?g.indexOf(d):-1,S=c.layersWithOutsidePointerEventsDisabled.size>0,k=w>=y,C=yw(E=>{const _=E.target,R=[...c.branches].some(L=>L.contains(_));!k||R||(o==null||o(E),i==null||i(E),E.defaultPrevented||a==null||a())},m),T=Sw(E=>{const _=E.target;[...c.branches].some(L=>L.contains(_))||(s==null||s(E),i==null||i(E),E.defaultPrevented||a==null||a())},m);return gw(E=>{w===c.layers.size-1&&(r==null||r(E),!E.defaultPrevented&&a&&(E.preventDefault(),a()))},m),h.useEffect(()=>{if(d)return n&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(Ru=m.body.style.pointerEvents,m.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(d)),c.layers.add(d),Lu(),()=>{n&&c.layersWithOutsidePointerEventsDisabled.size===1&&(m.body.style.pointerEvents=Ru)}},[d,m,n,c]),h.useEffect(()=>()=>{d&&(c.layers.delete(d),c.layersWithOutsidePointerEventsDisabled.delete(d),Lu())},[d,c]),h.useEffect(()=>{const E=()=>f({});return document.addEventListener(Di,E),()=>document.removeEventListener(Di,E)},[]),u.jsx(be.div,{...l,ref:v,style:{pointerEvents:S?k?"auto":"none":void 0,...e.style},onFocusCapture:ie(e.onFocusCapture,T.onFocusCapture),onBlurCapture:ie(e.onBlurCapture,T.onBlurCapture),onPointerDownCapture:ie(e.onPointerDownCapture,C.onPointerDownCapture)})});gr.displayName=xw;var bw="DismissableLayerBranch",Du=h.forwardRef((e,t)=>{const n=h.useContext(Ou),r=h.useRef(null),o=De(t,r);return h.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),u.jsx(be.div,{...e,ref:o})});Du.displayName=bw;function yw(e,t=globalThis==null?void 0:globalThis.document){const n=mt(e),r=h.useRef(!1),o=h.useRef(()=>{});return h.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){$u(vw,n,c,{discrete:!0})};const c={originalEvent:a};a.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=l,t.addEventListener("click",o.current,{once:!0})):l()}else t.removeEventListener("click",o.current);r.current=!1},i=window.setTimeout(()=>{t.addEventListener("pointerdown",s)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",s),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function Sw(e,t=globalThis==null?void 0:globalThis.document){const n=mt(e),r=h.useRef(!1);return h.useEffect(()=>{const o=s=>{s.target&&!r.current&&$u(ww,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 Lu(){const e=new CustomEvent(Di);document.dispatchEvent(e)}function $u(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?Oi(o,s):o.dispatchEvent(s)}var Cw=gr,Tw=Du,Li=0;function $i(){h.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Fu()),document.body.insertAdjacentElement("beforeend",e[1]??Fu()),Li++,()=>{Li===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Li--}},[])}function Fu(){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 Fi="focusScope.autoFocusOnMount",Bi="focusScope.autoFocusOnUnmount",Bu={bubbles:!1,cancelable:!0},kw="FocusScope",qo=h.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,l]=h.useState(null),c=mt(o),d=mt(s),p=h.useRef(null),m=De(t,g=>l(g)),f=h.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;h.useEffect(()=>{if(r){let g=function(S){if(f.paused||!a)return;const k=S.target;a.contains(k)?p.current=k:Pn(p.current,{select:!0})},x=function(S){if(f.paused||!a)return;const k=S.relatedTarget;k!==null&&(a.contains(k)||Pn(p.current,{select:!0}))},y=function(S){if(document.activeElement===document.body)for(const C of S)C.removedNodes.length>0&&Pn(a)};document.addEventListener("focusin",g),document.addEventListener("focusout",x);const w=new MutationObserver(y);return a&&w.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",g),document.removeEventListener("focusout",x),w.disconnect()}}},[r,a,f.paused]),h.useEffect(()=>{if(a){Uu.add(f);const g=document.activeElement;if(!a.contains(g)){const y=new CustomEvent(Fi,Bu);a.addEventListener(Fi,c),a.dispatchEvent(y),y.defaultPrevented||(Ew(_w(zu(a)),{select:!0}),document.activeElement===g&&Pn(a))}return()=>{a.removeEventListener(Fi,c),setTimeout(()=>{const y=new CustomEvent(Bi,Bu);a.addEventListener(Bi,d),a.dispatchEvent(y),y.defaultPrevented||Pn(g??document.body,{select:!0}),a.removeEventListener(Bi,d),Uu.remove(f)},0)}}},[a,c,d,f]);const v=h.useCallback(g=>{if(!n&&!r||f.paused)return;const x=g.key==="Tab"&&!g.altKey&&!g.ctrlKey&&!g.metaKey,y=document.activeElement;if(x&&y){const w=g.currentTarget,[S,k]=Iw(w);S&&k?!g.shiftKey&&y===k?(g.preventDefault(),n&&Pn(S,{select:!0})):g.shiftKey&&y===S&&(g.preventDefault(),n&&Pn(k,{select:!0})):y===w&&g.preventDefault()}},[n,r,f.paused]);return u.jsx(be.div,{tabIndex:-1,...i,ref:m,onKeyDown:v})});qo.displayName=kw;function Ew(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Pn(r,{select:t}),document.activeElement!==n)return}function Iw(e){const t=zu(e),n=Hu(t,e),r=Hu(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 Hu(e,t){for(const n of e)if(!Nw(n,{upTo:t}))return n}function Nw(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 Aw(e){return e instanceof HTMLInputElement&&"select"in e}function Pn(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Aw(e)&&t&&e.select()}}var Uu=jw();function jw(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=Wu(e,t),e.unshift(t)},remove(t){var n;e=Wu(e,t),(n=e[0])==null||n.resume()}}}function Wu(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function _w(e){return e.filter(t=>t.tagName!=="A")}var Pw=h[" useId ".trim().toString()]||(()=>{}),Mw=0;function Nt(e){const[t,n]=h.useState(Pw());return kt(()=>{n(r=>r??String(Mw++))},[e]),t?`radix-${t}`:""}const Rw=["top","right","bottom","left"],Mn=Math.min,Gt=Math.max,Go=Math.round,Yo=Math.floor,gn=e=>({x:e,y:e}),Ow={left:"right",right:"left",bottom:"top",top:"bottom"},Dw={start:"end",end:"start"};function zi(e,t,n){return Gt(e,Mn(t,n))}function kn(e,t){return typeof e=="function"?e(t):e}function En(e){return e.split("-")[0]}function xr(e){return e.split("-")[1]}function Hi(e){return e==="x"?"y":"x"}function Ui(e){return e==="y"?"height":"width"}const Lw=new Set(["top","bottom"]);function xn(e){return Lw.has(En(e))?"y":"x"}function Wi(e){return Hi(xn(e))}function $w(e,t,n){n===void 0&&(n=!1);const r=xr(e),o=Wi(e),s=Ui(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=Xo(i)),[i,Xo(i)]}function Fw(e){const t=Xo(e);return[Vi(e),t,Vi(t)]}function Vi(e){return e.replace(/start|end/g,t=>Dw[t])}const Vu=["left","right"],Ku=["right","left"],Bw=["top","bottom"],zw=["bottom","top"];function Hw(e,t,n){switch(e){case"top":case"bottom":return n?t?Ku:Vu:t?Vu:Ku;case"left":case"right":return t?Bw:zw;default:return[]}}function Uw(e,t,n,r){const o=xr(e);let s=Hw(En(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(Vi)))),s}function Xo(e){return e.replace(/left|right|bottom|top/g,t=>Ow[t])}function Ww(e){return{top:0,right:0,bottom:0,left:0,...e}}function qu(e){return typeof e!="number"?Ww(e):{top:e,right:e,bottom:e,left:e}}function Jo(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 Gu(e,t,n){let{reference:r,floating:o}=e;const s=xn(t),i=Wi(t),a=Ui(i),l=En(t),c=s==="y",d=r.x+r.width/2-o.width/2,p=r.y+r.height/2-o.height/2,m=r[a]/2-o[a]/2;let f;switch(l){case"top":f={x:d,y:r.y-o.height};break;case"bottom":f={x:d,y:r.y+r.height};break;case"right":f={x:r.x+r.width,y:p};break;case"left":f={x:r.x-o.width,y:p};break;default:f={x:r.x,y:r.y}}switch(xr(t)){case"start":f[i]-=m*(n&&c?-1:1);break;case"end":f[i]+=m*(n&&c?-1:1);break}return f}const Vw=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=n,a=s.filter(Boolean),l=await(i.isRTL==null?void 0:i.isRTL(t));let c=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:d,y:p}=Gu(c,r,l),m=r,f={},v=0;for(let g=0;g<a.length;g++){const{name:x,fn:y}=a[g],{x:w,y:S,data:k,reset:C}=await y({x:d,y:p,initialPlacement:r,placement:m,strategy:o,middlewareData:f,rects:c,platform:i,elements:{reference:e,floating:t}});d=w??d,p=S??p,f={...f,[x]:{...f[x],...k}},C&&v<=50&&(v++,typeof C=="object"&&(C.placement&&(m=C.placement),C.rects&&(c=C.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):C.rects),{x:d,y:p}=Gu(c,m,l)),g=-1)}return{x:d,y:p,placement:m,strategy:o,middlewareData:f}};async function Jr(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:i,elements:a,strategy:l}=e,{boundary:c="clippingAncestors",rootBoundary:d="viewport",elementContext:p="floating",altBoundary:m=!1,padding:f=0}=kn(t,e),v=qu(f),x=a[m?p==="floating"?"reference":"floating":p],y=Jo(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(x)))==null||n?x:x.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:c,rootBoundary:d,strategy:l})),w=p==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,S=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),k=await(s.isElement==null?void 0:s.isElement(S))?await(s.getScale==null?void 0:s.getScale(S))||{x:1,y:1}:{x:1,y:1},C=Jo(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:w,offsetParent:S,strategy:l}):w);return{top:(y.top-C.top+v.top)/k.y,bottom:(C.bottom-y.bottom+v.bottom)/k.y,left:(y.left-C.left+v.left)/k.x,right:(C.right-y.right+v.right)/k.x}}const Kw=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:s,platform:i,elements:a,middlewareData:l}=t,{element:c,padding:d=0}=kn(e,t)||{};if(c==null)return{};const p=qu(d),m={x:n,y:r},f=Wi(o),v=Ui(f),g=await i.getDimensions(c),x=f==="y",y=x?"top":"left",w=x?"bottom":"right",S=x?"clientHeight":"clientWidth",k=s.reference[v]+s.reference[f]-m[f]-s.floating[v],C=m[f]-s.reference[f],T=await(i.getOffsetParent==null?void 0:i.getOffsetParent(c));let E=T?T[S]:0;(!E||!await(i.isElement==null?void 0:i.isElement(T)))&&(E=a.floating[S]||s.floating[v]);const _=k/2-C/2,R=E/2-g[v]/2-1,L=Mn(p[y],R),H=Mn(p[w],R),K=L,F=E-g[v]-H,I=E/2-g[v]/2+_,W=zi(K,I,F),N=!l.arrow&&xr(o)!=null&&I!==W&&s.reference[v]/2-(I<K?L:H)-g[v]/2<0,U=N?I<K?I-K:I-F:0;return{[f]:m[f]+U,data:{[f]:W,centerOffset:I-W-U,...N&&{alignmentOffset:U}},reset:N}}}),qw=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:s,rects:i,initialPlacement:a,platform:l,elements:c}=t,{mainAxis:d=!0,crossAxis:p=!0,fallbackPlacements:m,fallbackStrategy:f="bestFit",fallbackAxisSideDirection:v="none",flipAlignment:g=!0,...x}=kn(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const y=En(o),w=xn(a),S=En(a)===a,k=await(l.isRTL==null?void 0:l.isRTL(c.floating)),C=m||(S||!g?[Xo(a)]:Fw(a)),T=v!=="none";!m&&T&&C.push(...Uw(a,g,v,k));const E=[a,...C],_=await Jr(t,x),R=[];let L=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&R.push(_[y]),p){const I=$w(o,i,k);R.push(_[I[0]],_[I[1]])}if(L=[...L,{placement:o,overflows:R}],!R.every(I=>I<=0)){var H,K;const I=(((H=s.flip)==null?void 0:H.index)||0)+1,W=E[I];if(W&&(!(p==="alignment"?w!==xn(W):!1)||L.every(O=>xn(O.placement)===w?O.overflows[0]>0:!0)))return{data:{index:I,overflows:L},reset:{placement:W}};let N=(K=L.filter(U=>U.overflows[0]<=0).sort((U,O)=>U.overflows[1]-O.overflows[1])[0])==null?void 0:K.placement;if(!N)switch(f){case"bestFit":{var F;const U=(F=L.filter(O=>{if(T){const j=xn(O.placement);return j===w||j==="y"}return!0}).map(O=>[O.placement,O.overflows.filter(j=>j>0).reduce((j,q)=>j+q,0)]).sort((O,j)=>O[1]-j[1])[0])==null?void 0:F[0];U&&(N=U);break}case"initialPlacement":N=a;break}if(o!==N)return{reset:{placement:N}}}return{}}}};function Yu(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Xu(e){return Rw.some(t=>e[t]>=0)}const Gw=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=kn(e,t);switch(r){case"referenceHidden":{const s=await Jr(t,{...o,elementContext:"reference"}),i=Yu(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:Xu(i)}}}case"escaped":{const s=await Jr(t,{...o,altBoundary:!0}),i=Yu(s,n.floating);return{data:{escapedOffsets:i,escaped:Xu(i)}}}default:return{}}}}},Ju=new Set(["left","top"]);async function Yw(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=En(n),a=xr(n),l=xn(n)==="y",c=Ju.has(i)?-1:1,d=s&&l?-1:1,p=kn(t,e);let{mainAxis:m,crossAxis:f,alignmentAxis:v}=typeof p=="number"?{mainAxis:p,crossAxis:0,alignmentAxis:null}:{mainAxis:p.mainAxis||0,crossAxis:p.crossAxis||0,alignmentAxis:p.alignmentAxis};return a&&typeof v=="number"&&(f=a==="end"?v*-1:v),l?{x:f*d,y:m*c}:{x:m*c,y:f*d}}const Xw=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:s,placement:i,middlewareData:a}=t,l=await Yw(t,e);return i===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:o+l.x,y:s+l.y,data:{...l,placement:i}}}}},Jw=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o}=t,{mainAxis:s=!0,crossAxis:i=!1,limiter:a={fn:x=>{let{x:y,y:w}=x;return{x:y,y:w}}},...l}=kn(e,t),c={x:n,y:r},d=await Jr(t,l),p=xn(En(o)),m=Hi(p);let f=c[m],v=c[p];if(s){const x=m==="y"?"top":"left",y=m==="y"?"bottom":"right",w=f+d[x],S=f-d[y];f=zi(w,f,S)}if(i){const x=p==="y"?"top":"left",y=p==="y"?"bottom":"right",w=v+d[x],S=v-d[y];v=zi(w,v,S)}const g=a.fn({...t,[m]:f,[p]:v});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[m]:s,[p]:i}}}}}},Zw=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:s,middlewareData:i}=t,{offset:a=0,mainAxis:l=!0,crossAxis:c=!0}=kn(e,t),d={x:n,y:r},p=xn(o),m=Hi(p);let f=d[m],v=d[p];const g=kn(a,t),x=typeof g=="number"?{mainAxis:g,crossAxis:0}:{mainAxis:0,crossAxis:0,...g};if(l){const S=m==="y"?"height":"width",k=s.reference[m]-s.floating[S]+x.mainAxis,C=s.reference[m]+s.reference[S]-x.mainAxis;f<k?f=k:f>C&&(f=C)}if(c){var y,w;const S=m==="y"?"width":"height",k=Ju.has(En(o)),C=s.reference[p]-s.floating[S]+(k&&((y=i.offset)==null?void 0:y[p])||0)+(k?0:x.crossAxis),T=s.reference[p]+s.reference[S]+(k?0:((w=i.offset)==null?void 0:w[p])||0)-(k?x.crossAxis:0);v<C?v=C:v>T&&(v=T)}return{[m]:f,[p]:v}}}},Qw=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:s,platform:i,elements:a}=t,{apply:l=()=>{},...c}=kn(e,t),d=await Jr(t,c),p=En(o),m=xr(o),f=xn(o)==="y",{width:v,height:g}=s.floating;let x,y;p==="top"||p==="bottom"?(x=p,y=m===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(y=p,x=m==="end"?"top":"bottom");const w=g-d.top-d.bottom,S=v-d.left-d.right,k=Mn(g-d[x],w),C=Mn(v-d[y],S),T=!t.middlewareData.shift;let E=k,_=C;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(_=S),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(E=w),T&&!m){const L=Gt(d.left,0),H=Gt(d.right,0),K=Gt(d.top,0),F=Gt(d.bottom,0);f?_=v-2*(L!==0||H!==0?L+H:Gt(d.left,d.right)):E=g-2*(K!==0||F!==0?K+F:Gt(d.top,d.bottom))}await l({...t,availableWidth:_,availableHeight:E});const R=await i.getDimensions(a.floating);return v!==R.width||g!==R.height?{reset:{rects:!0}}:{}}}};function Zo(){return typeof window<"u"}function vr(e){return Zu(e)?(e.nodeName||"").toLowerCase():"#document"}function Yt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function vn(e){var t;return(t=(Zu(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Zu(e){return Zo()?e instanceof Node||e instanceof Yt(e).Node:!1}function an(e){return Zo()?e instanceof Element||e instanceof Yt(e).Element:!1}function wn(e){return Zo()?e instanceof HTMLElement||e instanceof Yt(e).HTMLElement:!1}function Qu(e){return!Zo()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Yt(e).ShadowRoot}const eb=new Set(["inline","contents"]);function Zr(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=ln(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!eb.has(o)}const tb=new Set(["table","td","th"]);function nb(e){return tb.has(vr(e))}const rb=[":popover-open",":modal"];function Qo(e){return rb.some(t=>{try{return e.matches(t)}catch{return!1}})}const ob=["transform","translate","scale","rotate","perspective"],sb=["transform","translate","scale","rotate","perspective","filter"],ib=["paint","layout","strict","content"];function Ki(e){const t=qi(),n=an(e)?ln(e):e;return ob.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)||sb.some(r=>(n.willChange||"").includes(r))||ib.some(r=>(n.contain||"").includes(r))}function ab(e){let t=Rn(e);for(;wn(t)&&!wr(t);){if(Ki(t))return t;if(Qo(t))return null;t=Rn(t)}return null}function qi(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const lb=new Set(["html","body","#document"]);function wr(e){return lb.has(vr(e))}function ln(e){return Yt(e).getComputedStyle(e)}function es(e){return an(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Rn(e){if(vr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Qu(e)&&e.host||vn(e);return Qu(t)?t.host:t}function ed(e){const t=Rn(e);return wr(t)?e.ownerDocument?e.ownerDocument.body:e.body:wn(t)&&Zr(t)?t:ed(t)}function Qr(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=ed(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Yt(o);if(s){const a=Gi(i);return t.concat(i,i.visualViewport||[],Zr(o)?o:[],a&&n?Qr(a):[])}return t.concat(o,Qr(o,[],n))}function Gi(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function td(e){const t=ln(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=wn(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=Go(n)!==s||Go(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function Yi(e){return an(e)?e:e.contextElement}function br(e){const t=Yi(e);if(!wn(t))return gn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=td(t);let i=(s?Go(n.width):n.width)/r,a=(s?Go(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const cb=gn(0);function nd(e){const t=Yt(e);return!qi()||!t.visualViewport?cb:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function ub(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Yt(e)?!1:t}function Yn(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=Yi(e);let i=gn(1);t&&(r?an(r)&&(i=br(r)):i=br(e));const a=ub(s,n,r)?nd(s):gn(0);let l=(o.left+a.x)/i.x,c=(o.top+a.y)/i.y,d=o.width/i.x,p=o.height/i.y;if(s){const m=Yt(s),f=r&&an(r)?Yt(r):r;let v=m,g=Gi(v);for(;g&&r&&f!==v;){const x=br(g),y=g.getBoundingClientRect(),w=ln(g),S=y.left+(g.clientLeft+parseFloat(w.paddingLeft))*x.x,k=y.top+(g.clientTop+parseFloat(w.paddingTop))*x.y;l*=x.x,c*=x.y,d*=x.x,p*=x.y,l+=S,c+=k,v=Yt(g),g=Gi(v)}}return Jo({width:d,height:p,x:l,y:c})}function ts(e,t){const n=es(e).scrollLeft;return t?t.left+n:Yn(vn(e)).left+n}function rd(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-ts(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function db(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=vn(r),a=t?Qo(t.floating):!1;if(r===i||a&&s)return n;let l={scrollLeft:0,scrollTop:0},c=gn(1);const d=gn(0),p=wn(r);if((p||!p&&!s)&&((vr(r)!=="body"||Zr(i))&&(l=es(r)),wn(r))){const f=Yn(r);c=br(r),d.x=f.x+r.clientLeft,d.y=f.y+r.clientTop}const m=i&&!p&&!s?rd(i,l):gn(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+d.x+m.x,y:n.y*c.y-l.scrollTop*c.y+d.y+m.y}}function fb(e){return Array.from(e.getClientRects())}function pb(e){const t=vn(e),n=es(e),r=e.ownerDocument.body,o=Gt(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Gt(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+ts(e);const a=-n.scrollTop;return ln(r).direction==="rtl"&&(i+=Gt(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const od=25;function hb(e,t){const n=Yt(e),r=vn(e),o=n.visualViewport;let s=r.clientWidth,i=r.clientHeight,a=0,l=0;if(o){s=o.width,i=o.height;const d=qi();(!d||d&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}const c=ts(r);if(c<=0){const d=r.ownerDocument,p=d.body,m=getComputedStyle(p),f=d.compatMode==="CSS1Compat"&&parseFloat(m.marginLeft)+parseFloat(m.marginRight)||0,v=Math.abs(r.clientWidth-p.clientWidth-f);v<=od&&(s-=v)}else c<=od&&(s+=c);return{width:s,height:i,x:a,y:l}}const mb=new Set(["absolute","fixed"]);function gb(e,t){const n=Yn(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=wn(e)?br(e):gn(1),i=e.clientWidth*s.x,a=e.clientHeight*s.y,l=o*s.x,c=r*s.y;return{width:i,height:a,x:l,y:c}}function sd(e,t,n){let r;if(t==="viewport")r=hb(e,n);else if(t==="document")r=pb(vn(e));else if(an(t))r=gb(t,n);else{const o=nd(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Jo(r)}function id(e,t){const n=Rn(e);return n===t||!an(n)||wr(n)?!1:ln(n).position==="fixed"||id(n,t)}function xb(e,t){const n=t.get(e);if(n)return n;let r=Qr(e,[],!1).filter(a=>an(a)&&vr(a)!=="body"),o=null;const s=ln(e).position==="fixed";let i=s?Rn(e):e;for(;an(i)&&!wr(i);){const a=ln(i),l=Ki(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&mb.has(o.position)||Zr(i)&&!l&&id(e,i))?r=r.filter(d=>d!==i):o=a,i=Rn(i)}return t.set(e,r),r}function vb(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?Qo(t)?[]:xb(t,this._c):[].concat(n),r],a=i[0],l=i.reduce((c,d)=>{const p=sd(t,d,o);return c.top=Gt(p.top,c.top),c.right=Mn(p.right,c.right),c.bottom=Mn(p.bottom,c.bottom),c.left=Gt(p.left,c.left),c},sd(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function wb(e){const{width:t,height:n}=td(e);return{width:t,height:n}}function bb(e,t,n){const r=wn(t),o=vn(t),s=n==="fixed",i=Yn(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=gn(0);function c(){l.x=ts(o)}if(r||!r&&!s)if((vr(t)!=="body"||Zr(o))&&(a=es(t)),r){const f=Yn(t,!0,s,t);l.x=f.x+t.clientLeft,l.y=f.y+t.clientTop}else o&&c();s&&!r&&o&&c();const d=o&&!r&&!s?rd(o,a):gn(0),p=i.left+a.scrollLeft-l.x-d.x,m=i.top+a.scrollTop-l.y-d.y;return{x:p,y:m,width:i.width,height:i.height}}function Xi(e){return ln(e).position==="static"}function ad(e,t){if(!wn(e)||ln(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return vn(e)===n&&(n=n.ownerDocument.body),n}function ld(e,t){const n=Yt(e);if(Qo(e))return n;if(!wn(e)){let o=Rn(e);for(;o&&!wr(o);){if(an(o)&&!Xi(o))return o;o=Rn(o)}return n}let r=ad(e,t);for(;r&&nb(r)&&Xi(r);)r=ad(r,t);return r&&wr(r)&&Xi(r)&&!Ki(r)?n:r||ab(e)||n}const yb=async function(e){const t=this.getOffsetParent||ld,n=this.getDimensions,r=await n(e.floating);return{reference:bb(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Sb(e){return ln(e).direction==="rtl"}const Cb={convertOffsetParentRelativeRectToViewportRelativeRect:db,getDocumentElement:vn,getClippingRect:vb,getOffsetParent:ld,getElementRects:yb,getClientRects:fb,getDimensions:wb,getScale:br,isElement:an,isRTL:Sb};function cd(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Tb(e,t){let n=null,r;const o=vn(e);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),s();const c=e.getBoundingClientRect(),{left:d,top:p,width:m,height:f}=c;if(a||t(),!m||!f)return;const v=Yo(p),g=Yo(o.clientWidth-(d+m)),x=Yo(o.clientHeight-(p+f)),y=Yo(d),S={rootMargin:-v+"px "+-g+"px "+-x+"px "+-y+"px",threshold:Gt(0,Mn(1,l))||1};let k=!0;function C(T){const E=T[0].intersectionRatio;if(E!==l){if(!k)return i();E?i(!1,E):r=setTimeout(()=>{i(!1,1e-7)},1e3)}E===1&&!cd(c,e.getBoundingClientRect())&&i(),k=!1}try{n=new IntersectionObserver(C,{...S,root:o.ownerDocument})}catch{n=new IntersectionObserver(C,S)}n.observe(e)}return i(!0),s}function kb(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,c=Yi(e),d=o||s?[...c?Qr(c):[],...Qr(t)]:[];d.forEach(y=>{o&&y.addEventListener("scroll",n,{passive:!0}),s&&y.addEventListener("resize",n)});const p=c&&a?Tb(c,n):null;let m=-1,f=null;i&&(f=new ResizeObserver(y=>{let[w]=y;w&&w.target===c&&f&&(f.unobserve(t),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var S;(S=f)==null||S.observe(t)})),n()}),c&&!l&&f.observe(c),f.observe(t));let v,g=l?Yn(e):null;l&&x();function x(){const y=Yn(e);g&&!cd(g,y)&&n(),g=y,v=requestAnimationFrame(x)}return n(),()=>{var y;d.forEach(w=>{o&&w.removeEventListener("scroll",n),s&&w.removeEventListener("resize",n)}),p==null||p(),(y=f)==null||y.disconnect(),f=null,l&&cancelAnimationFrame(v)}}const Eb=Xw,Ib=Jw,Nb=qw,Ab=Qw,jb=Gw,ud=Kw,_b=Zw,Pb=(e,t,n)=>{const r=new Map,o={platform:Cb,...n},s={...o.platform,_c:r};return Vw(e,t,{...o,platform:s})};var Mb=typeof document<"u",Rb=function(){},ns=Mb?b.useLayoutEffect:Rb;function rs(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(!rs(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)&&!rs(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function dd(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function fd(e,t){const n=dd(e);return Math.round(t*n)/n}function Ji(e){const t=h.useRef(e);return ns(()=>{t.current=e}),t}function Ob(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:i}={},transform:a=!0,whileElementsMounted:l,open:c}=e,[d,p]=h.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[m,f]=h.useState(r);rs(m,r)||f(r);const[v,g]=h.useState(null),[x,y]=h.useState(null),w=h.useCallback(O=>{O!==T.current&&(T.current=O,g(O))},[]),S=h.useCallback(O=>{O!==E.current&&(E.current=O,y(O))},[]),k=s||v,C=i||x,T=h.useRef(null),E=h.useRef(null),_=h.useRef(d),R=l!=null,L=Ji(l),H=Ji(o),K=Ji(c),F=h.useCallback(()=>{if(!T.current||!E.current)return;const O={placement:t,strategy:n,middleware:m};H.current&&(O.platform=H.current),Pb(T.current,E.current,O).then(j=>{const q={...j,isPositioned:K.current!==!1};I.current&&!rs(_.current,q)&&(_.current=q,Lr.flushSync(()=>{p(q)}))})},[m,t,n,H,K]);ns(()=>{c===!1&&_.current.isPositioned&&(_.current.isPositioned=!1,p(O=>({...O,isPositioned:!1})))},[c]);const I=h.useRef(!1);ns(()=>(I.current=!0,()=>{I.current=!1}),[]),ns(()=>{if(k&&(T.current=k),C&&(E.current=C),k&&C){if(L.current)return L.current(k,C,F);F()}},[k,C,F,L,R]);const W=h.useMemo(()=>({reference:T,floating:E,setReference:w,setFloating:S}),[w,S]),N=h.useMemo(()=>({reference:k,floating:C}),[k,C]),U=h.useMemo(()=>{const O={position:n,left:0,top:0};if(!N.floating)return O;const j=fd(N.floating,d.x),q=fd(N.floating,d.y);return a?{...O,transform:"translate("+j+"px, "+q+"px)",...dd(N.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:j,top:q}},[n,a,N.floating,d.x,d.y]);return h.useMemo(()=>({...d,update:F,refs:W,elements:N,floatingStyles:U}),[d,F,W,N,U])}const Db=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?ud({element:r.current,padding:o}).fn(n):{}:r?ud({element:r,padding:o}).fn(n):{}}}},Lb=(e,t)=>({...Eb(e),options:[e,t]}),$b=(e,t)=>({...Ib(e),options:[e,t]}),Fb=(e,t)=>({..._b(e),options:[e,t]}),Bb=(e,t)=>({...Nb(e),options:[e,t]}),zb=(e,t)=>({...Ab(e),options:[e,t]}),Hb=(e,t)=>({...jb(e),options:[e,t]}),Ub=(e,t)=>({...Db(e),options:[e,t]});var Wb="Arrow",pd=h.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return u.jsx(be.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"})})});pd.displayName=Wb;var Vb=pd;function hd(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 l=s.borderBoxSize,c=Array.isArray(l)?l[0]:l;i=c.inlineSize,a=c.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var Zi="Popper",[md,yr]=sn(Zi),[Kb,gd]=md(Zi),xd=e=>{const{__scopePopper:t,children:n}=e,[r,o]=h.useState(null);return u.jsx(Kb,{scope:t,anchor:r,onAnchorChange:o,children:n})};xd.displayName=Zi;var vd="PopperAnchor",wd=h.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=gd(vd,n),i=h.useRef(null),a=De(t,i),l=h.useRef(null);return h.useEffect(()=>{const c=l.current;l.current=(r==null?void 0:r.current)||i.current,c!==l.current&&s.onAnchorChange(l.current)}),r?null:u.jsx(be.div,{...o,ref:a})});wd.displayName=vd;var Qi="PopperContent",[qb,Gb]=md(Qi),bd=h.forwardRef((e,t)=>{var V,D,X,Q,ae,$;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:a=0,avoidCollisions:l=!0,collisionBoundary:c=[],collisionPadding:d=0,sticky:p="partial",hideWhenDetached:m=!1,updatePositionStrategy:f="optimized",onPlaced:v,...g}=e,x=gd(Qi,n),[y,w]=h.useState(null),S=De(t,re=>w(re)),[k,C]=h.useState(null),T=hd(k),E=(T==null?void 0:T.width)??0,_=(T==null?void 0:T.height)??0,R=r+(s!=="center"?"-"+s:""),L=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},H=Array.isArray(c)?c:[c],K=H.length>0,F={padding:L,boundary:H.filter(Xb),altBoundary:K},{refs:I,floatingStyles:W,placement:N,isPositioned:U,middlewareData:O}=Ob({strategy:"fixed",placement:R,whileElementsMounted:(...re)=>kb(...re,{animationFrame:f==="always"}),elements:{reference:x.anchor},middleware:[Lb({mainAxis:o+_,alignmentAxis:i}),l&&$b({mainAxis:!0,crossAxis:!1,limiter:p==="partial"?Fb():void 0,...F}),l&&Bb({...F}),zb({...F,apply:({elements:re,rects:we,availableWidth:de,availableHeight:xe})=>{const{width:Ee,height:Be}=we.reference,We=re.floating.style;We.setProperty("--radix-popper-available-width",`${de}px`),We.setProperty("--radix-popper-available-height",`${xe}px`),We.setProperty("--radix-popper-anchor-width",`${Ee}px`),We.setProperty("--radix-popper-anchor-height",`${Be}px`)}}),k&&Ub({element:k,padding:a}),Jb({arrowWidth:E,arrowHeight:_}),m&&Hb({strategy:"referenceHidden",...F})]}),[j,q]=Cd(N),J=mt(v);kt(()=>{U&&(J==null||J())},[U,J]);const P=(V=O.arrow)==null?void 0:V.x,M=(D=O.arrow)==null?void 0:D.y,G=((X=O.arrow)==null?void 0:X.centerOffset)!==0,[Z,se]=h.useState();return kt(()=>{y&&se(window.getComputedStyle(y).zIndex)},[y]),u.jsx("div",{ref:I.setFloating,"data-radix-popper-content-wrapper":"",style:{...W,transform:U?W.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Z,"--radix-popper-transform-origin":[(Q=O.transformOrigin)==null?void 0:Q.x,(ae=O.transformOrigin)==null?void 0:ae.y].join(" "),...(($=O.hide)==null?void 0:$.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:u.jsx(qb,{scope:n,placedSide:j,onArrowChange:C,arrowX:P,arrowY:M,shouldHideArrow:G,children:u.jsx(be.div,{"data-side":j,"data-align":q,...g,ref:S,style:{...g.style,animation:U?void 0:"none"}})})})});bd.displayName=Qi;var yd="PopperArrow",Yb={top:"bottom",right:"left",bottom:"top",left:"right"},Sd=h.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=Gb(yd,r),i=Yb[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(Vb,{...o,ref:n,style:{...o.style,display:"block"}})})});Sd.displayName=yd;function Xb(e){return e!==null}var Jb=e=>({name:"transformOrigin",options:e,fn(t){var x,y,w;const{placement:n,rects:r,middlewareData:o}=t,i=((x=o.arrow)==null?void 0:x.centerOffset)!==0,a=i?0:e.arrowWidth,l=i?0:e.arrowHeight,[c,d]=Cd(n),p={start:"0%",center:"50%",end:"100%"}[d],m=(((y=o.arrow)==null?void 0:y.x)??0)+a/2,f=(((w=o.arrow)==null?void 0:w.y)??0)+l/2;let v="",g="";return c==="bottom"?(v=i?p:`${m}px`,g=`${-l}px`):c==="top"?(v=i?p:`${m}px`,g=`${r.floating.height+l}px`):c==="right"?(v=`${-l}px`,g=i?p:`${f}px`):c==="left"&&(v=`${r.floating.width+l}px`,g=i?p:`${f}px`),{data:{x:v,y:g}}}});function Cd(e){const[t,n="center"]=e.split("-");return[t,n]}var ea=xd,ta=wd,na=bd,ra=Sd,Zb="Portal",eo=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?No.createPortal(u.jsx(be.div,{...r,ref:t}),i):null});eo.displayName=Zb;function Qb(e,t){return h.useReducer((n,r)=>t[n][r]??n,e)}var Ft=e=>{const{present:t,children:n}=e,r=ey(t),o=typeof n=="function"?n({present:r.isPresent}):h.Children.only(n),s=De(r.ref,ty(o));return typeof n=="function"||r.isPresent?h.cloneElement(o,{ref:s}):null};Ft.displayName="Presence";function ey(e){const[t,n]=h.useState(),r=h.useRef(null),o=h.useRef(e),s=h.useRef("none"),i=e?"mounted":"unmounted",[a,l]=Qb(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return h.useEffect(()=>{const c=os(r.current);s.current=a==="mounted"?c:"none"},[a]),kt(()=>{const c=r.current,d=o.current;if(d!==e){const m=s.current,f=os(c);e?l("MOUNT"):f==="none"||(c==null?void 0:c.display)==="none"?l("UNMOUNT"):l(d&&m!==f?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,l]),kt(()=>{if(t){let c;const d=t.ownerDocument.defaultView??window,p=f=>{const g=os(r.current).includes(CSS.escape(f.animationName));if(f.target===t&&g&&(l("ANIMATION_END"),!o.current)){const x=t.style.animationFillMode;t.style.animationFillMode="forwards",c=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=x)})}},m=f=>{f.target===t&&(s.current=os(r.current))};return t.addEventListener("animationstart",m),t.addEventListener("animationcancel",p),t.addEventListener("animationend",p),()=>{d.clearTimeout(c),t.removeEventListener("animationstart",m),t.removeEventListener("animationcancel",p),t.removeEventListener("animationend",p)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:h.useCallback(c=>{r.current=c?getComputedStyle(c):null,n(c)},[])}}function os(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 oa="rovingFocusGroup.onEntryFocus",ny={bubbles:!1,cancelable:!0},to="RovingFocusGroup",[sa,Td,ry]=Vo(to),[oy,kd]=sn(to,[ry]),[sy,iy]=oy(to),Ed=h.forwardRef((e,t)=>u.jsx(sa.Provider,{scope:e.__scopeRovingFocusGroup,children:u.jsx(sa.Slot,{scope:e.__scopeRovingFocusGroup,children:u.jsx(ay,{...e,ref:t})})}));Ed.displayName=to;var ay=h.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:c,preventScrollOnEntryFocus:d=!1,...p}=e,m=h.useRef(null),f=De(t,m),v=Ko(s),[g,x]=_n({prop:i,defaultProp:a??null,onChange:l,caller:to}),[y,w]=h.useState(!1),S=mt(c),k=Td(n),C=h.useRef(!1),[T,E]=h.useState(0);return h.useEffect(()=>{const _=m.current;if(_)return _.addEventListener(oa,S),()=>_.removeEventListener(oa,S)},[S]),u.jsx(sy,{scope:n,orientation:r,dir:v,loop:o,currentTabStopId:g,onItemFocus:h.useCallback(_=>x(_),[x]),onItemShiftTab:h.useCallback(()=>w(!0),[]),onFocusableItemAdd:h.useCallback(()=>E(_=>_+1),[]),onFocusableItemRemove:h.useCallback(()=>E(_=>_-1),[]),children:u.jsx(be.div,{tabIndex:y||T===0?-1:0,"data-orientation":r,...p,ref:f,style:{outline:"none",...e.style},onMouseDown:ie(e.onMouseDown,()=>{C.current=!0}),onFocus:ie(e.onFocus,_=>{const R=!C.current;if(_.target===_.currentTarget&&R&&!y){const L=new CustomEvent(oa,ny);if(_.currentTarget.dispatchEvent(L),!L.defaultPrevented){const H=k().filter(N=>N.focusable),K=H.find(N=>N.active),F=H.find(N=>N.id===g),W=[K,F,...H].filter(Boolean).map(N=>N.ref.current);Ad(W,d)}}C.current=!1}),onBlur:ie(e.onBlur,()=>w(!1))})})}),Id="RovingFocusGroupItem",Nd=h.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,l=Nt(),c=s||l,d=iy(Id,n),p=d.currentTabStopId===c,m=Td(n),{onFocusableItemAdd:f,onFocusableItemRemove:v,currentTabStopId:g}=d;return h.useEffect(()=>{if(r)return f(),()=>v()},[r,f,v]),u.jsx(sa.ItemSlot,{scope:n,id:c,focusable:r,active:o,children:u.jsx(be.span,{tabIndex:p?0:-1,"data-orientation":d.orientation,...a,ref:t,onMouseDown:ie(e.onMouseDown,x=>{r?d.onItemFocus(c):x.preventDefault()}),onFocus:ie(e.onFocus,()=>d.onItemFocus(c)),onKeyDown:ie(e.onKeyDown,x=>{if(x.key==="Tab"&&x.shiftKey){d.onItemShiftTab();return}if(x.target!==x.currentTarget)return;const y=uy(x,d.orientation,d.dir);if(y!==void 0){if(x.metaKey||x.ctrlKey||x.altKey||x.shiftKey)return;x.preventDefault();let S=m().filter(k=>k.focusable).map(k=>k.ref.current);if(y==="last")S.reverse();else if(y==="prev"||y==="next"){y==="prev"&&S.reverse();const k=S.indexOf(x.currentTarget);S=d.loop?dy(S,k+1):S.slice(k+1)}setTimeout(()=>Ad(S))}}),children:typeof i=="function"?i({isCurrentTabStop:p,hasTabStop:g!=null}):i})})});Nd.displayName=Id;var ly={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function cy(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function uy(e,t,n){const r=cy(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return ly[r]}function Ad(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function dy(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var fy=Ed,py=Nd,hy=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Sr=new WeakMap,ss=new WeakMap,is={},ia=0,jd=function(e){return e&&(e.host||jd(e.parentNode))},my=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})},gy=function(e,t,n,r){var o=my(t,Array.isArray(e)?e:[e]);is[n]||(is[n]=new WeakMap);var s=is[n],i=[],a=new Set,l=new Set(o),c=function(p){!p||a.has(p)||(a.add(p),c(p.parentNode))};o.forEach(c);var d=function(p){!p||l.has(p)||Array.prototype.forEach.call(p.children,function(m){if(a.has(m))d(m);else try{var f=m.getAttribute(r),v=f!==null&&f!=="false",g=(Sr.get(m)||0)+1,x=(s.get(m)||0)+1;Sr.set(m,g),s.set(m,x),i.push(m),g===1&&v&&ss.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(),ia++,function(){i.forEach(function(p){var m=Sr.get(p)-1,f=s.get(p)-1;Sr.set(p,m),s.set(p,f),m||(ss.has(p)||p.removeAttribute(r),ss.delete(p)),f||p.removeAttribute(n)}),ia--,ia||(Sr=new WeakMap,Sr=new WeakMap,ss=new WeakMap,is={})}},aa=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=hy(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),gy(r,o,n,"aria-hidden")):function(){return null}},bn=function(){return bn=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},bn.apply(this,arguments)};function _d(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n}function xy(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 as="right-scroll-bar-position",ls="width-before-scroll-bar",vy="with-scroll-bars-hidden",wy="--removed-body-scroll-bar-size";function la(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function by(e,t){var n=b.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var o=n.value;o!==r&&(n.value=r,n.callback(r,o))}}}})[0];return n.callback=t,n.facade}var yy=typeof window<"u"?h.useLayoutEffect:h.useEffect,Pd=new WeakMap;function Sy(e,t){var n=by(null,function(r){return e.forEach(function(o){return la(o,r)})});return yy(function(){var r=Pd.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||la(a,null)}),s.forEach(function(a){o.has(a)||la(a,i)})}Pd.set(n,e)},[e]),n}function Cy(e){return e}function Ty(e,t){t===void 0&&(t=Cy);var n=[],r=!1,o={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(s){var i=t(s,r);return n.push(i),function(){n=n.filter(function(a){return a!==i})}},assignSyncMedium:function(s){for(r=!0;n.length;){var i=n;n=[],i.forEach(s)}n={push:function(a){return s(a)},filter:function(){return n}}},assignMedium:function(s){r=!0;var i=[];if(n.length){var a=n;n=[],a.forEach(s),i=n}var l=function(){var d=i;i=[],d.forEach(s)},c=function(){return Promise.resolve().then(l)};c(),n={push:function(d){i.push(d),c()},filter:function(d){return i=i.filter(d),n}}}};return o}function ky(e){e===void 0&&(e={});var t=Ty(null);return t.options=bn({async:!0,ssr:!1},e),t}var Md=function(e){var t=e.sideCar,n=_d(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return h.createElement(r,bn({},n))};Md.isSideCarExport=!0;function Ey(e,t){return e.useMedium(t),Md}var Rd=ky(),ca=function(){},cs=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,l=e.className,c=e.removeScrollBar,d=e.enabled,p=e.shards,m=e.sideCar,f=e.noRelative,v=e.noIsolation,g=e.inert,x=e.allowPinchZoom,y=e.as,w=y===void 0?"div":y,S=e.gapMode,k=_d(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=m,T=Sy([n,t]),E=bn(bn({},k),o);return h.createElement(h.Fragment,null,d&&h.createElement(C,{sideCar:Rd,removeScrollBar:c,shards:p,noRelative:f,noIsolation:v,inert:g,setCallbacks:s,allowPinchZoom:!!x,lockRef:n,gapMode:S}),i?h.cloneElement(h.Children.only(a),bn(bn({},E),{ref:T})):h.createElement(w,bn({},E,{className:l,ref:T}),a))});cs.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},cs.classNames={fullWidth:ls,zeroRight:as};var Iy=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Ny(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Iy();return t&&e.setAttribute("nonce",t),e}function Ay(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function jy(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var _y=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Ny())&&(Ay(t,n),jy(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Py=function(){var e=_y();return function(t,n){h.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Od=function(){var e=Py(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},My={left:0,top:0,right:0,gap:0},ua=function(e){return parseInt(e||"",10)||0},Ry=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[ua(n),ua(r),ua(o)]},Oy=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return My;var t=Ry(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])}},Dy=Od(),Cr="data-scroll-locked",Ly=function(e,t,n,r){var o=e.left,s=e.top,i=e.right,a=e.gap;return n===void 0&&(n="margin"),`
40
- .`.concat(vy,` {
38
+ `);if(!Oe)continue;let qe;try{qe=JSON.parse(Oe)}catch{console.debug("[use-chat] malformed SSE:",Oe.slice(0,200));continue}const Tt=su(qe)?qe.data:qe;if(!Tt){console.warn("[use-chat] dropped envelope event without payload",qe);continue}const He=Tt;$e=Date.now();const ft=He.seq;if(ft!==void 0){if(ft<=vt){console.debug("[use-chat] drop duplicate/out-of-order event",{seq:ft,lastProcessedSeq:vt,type:He.type});continue}vt>0&&ft>vt+1&&((D=N==null?void 0:N.onGap)==null||D.call(N,{from:vt,to:ft})),vt=ft,C.current=ft,x(ft)}if(He.type==="checkpoint")E.current=He.checkpointId??null,_.current=He.checkpointNs??null,v(He.checkpointId??null);else if(He.type==="state_history"){R.current=He;try{const tt=Nn(He).latest;tt&&(E.current=tt.checkpointId??null,_.current=tt.checkpointNs??null,v(tt.checkpointId??null))}catch(Fe){console.warn("[use-chat] Failed to hydrate state_history payload",Fe)}}try{W==null||W(He)}catch(Fe){console.error("[use-chat] Error in onEvent callback:",Fe,"for event:",He.type)}if(He.type==="message.delta"){const Fe=He.delta.filter(tt=>tt.type==="text").map(tt=>tt.text).join("");Fe&&e.autoAppendAssistant!==!1&&(xt.push(Fe),Dt())}else if(He.type==="heartbeat"){console.debug("[use-chat] heartbeat received");try{(X=N==null?void 0:N.onHeartbeat)==null||X.call(N,He)}catch(Fe){console.warn("[use-chat] heartbeat callback failed",Fe)}}else if(dt!==null&&cancelAnimationFrame(dt),Et(),He.type==="checkpoint")v(He.checkpointId);else if(He.type==="error"){const Fe=He;if(d(Fe.message),O="error",j=Fe.message,Fe.error_type==="auth_error"||Fe.code==="TOKEN_EXPIRED"||((Q=Fe.message)==null?void 0:Q.includes("token"))||((ae=Fe.message)==null?void 0:ae.includes("401"))||(($=Fe.message)==null?void 0:$.includes("unauthorized"))||((re=Fe.message)==null?void 0:re.includes("Unauthorized"))){console.error("[use-chat] Auth error detected:",Fe.message);try{(we=N==null?void 0:N.onAuthError)==null||we.call(N,Fe.message)}catch(Ut){console.warn("[use-chat] onAuthError handler failed",Ut)}U.abort()}}}}Et(),O===null&&!U.signal.aborted&&(O="complete")}catch(Me){if(Me.name==="AbortError")O=O??"aborted";else{const Ke=Me.message||String(Me);O="error",j=Ke,d(Ke),(de=N==null?void 0:N.onError)==null||de.call(N,Ke)}}finally{try{await rt.cancel()}catch{}finally{(xe=rt.releaseLock)==null||xe.call(rt)}dt!==null&&typeof window<"u"&&window.cancelAnimationFrame(dt),clearInterval(Pt)}}catch(je){if(je.name==="AbortError")O=O??"aborted";else{const Ve=je.message||String(je);O="error",j=Ve,d(Ve),(Ee=N==null?void 0:N.onError)==null||Ee.call(N,Ve),q||((Be=N==null?void 0:N.onConnectionError)==null||Be.call(N,Ve),q=!0)}}finally{const je=C.current,Ve=E.current,Xe=_.current,ze=R.current,Ge=O??(U.signal.aborted?"aborted":j?"error":"complete");try{(We=N==null?void 0:N.onClosed)==null||We.call(N,{reason:Ge,lastSeq:je,lastCheckpointId:Ve,lastCheckpointNs:Xe,lastStateHistory:ze,error:j})}catch(rt){console.warn("[use-chat] onClosed callback failed",rt)}l(!1),w(!1),S.current=null,C.current=0,x(0),T.current=null}})(),{close:()=>U.abort()}},[t,n,r,e.autoAppendAssistant]);return b.useEffect(()=>()=>{var I;k.current=!1,(I=S.current)==null||I.abort()},[]),{isStreaming:a,error:c,assistantText:p,lastCheckpointId:f,lastSeq:g,connected:y,stream:B,stop:K,clear:H,setToken:L}}const Rv=["detail","message","error","description","title"];function Uo(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=Uo(t);if(n)return n}return null}if(typeof e=="object"){const t=e;for(const n of Rv){const r=Uo(t[n]);if(r)return r}if("errors"in t){const n=Uo(t.errors);if(n)return n}}return null}function Ov(e){if(!e)return"Request failed";const t=e.response,n=Uo(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 iu({api:e,initialThreadId:t=null,onError:n,onThreadChange:r,onCurrentThreadDeleted:o}){const[s,i]=b.useState([]),[a,l]=b.useState(t),[c,d]=b.useState(!1),[p,m]=b.useState(null),[f,v]=b.useState([]),[g,x]=b.useState(!1),[,y]=b.useState(null),[w,S]=b.useState(null),[k,C]=b.useState(!1),T=b.useRef(a),E=b.useRef(new Map);b.useEffect(()=>{T.current=a},[a]);const _=b.useCallback(async()=>{d(!0),m(null);try{const O=await e.listThreads();i(O??[])}catch(O){const j=String(O);m(j),n==null||n(j)}finally{d(!1)}},[e,n]),R=b.useCallback(async()=>{x(!0),y(null);try{const O=await e.listSharedThreads();v(O??[])}catch(O){const j=String(O);y(j),n==null||n(j)}finally{x(!1)}},[e,n]);b.useEffect(()=>{_()},[_]),b.useEffect(()=>{R()},[R]),b.useEffect(()=>{r==null||r(a)},[a,r]);const L=b.useCallback(async O=>{try{const j=await e.createThread(O);return l(j.threadId),await _(),j.threadId}catch(j){const q=String(j);return n==null||n(q),null}},[e,n,_]),H=b.useCallback(async O=>{const j=s;i(J=>J.filter(P=>P.threadId!==O));const q=new AbortController;E.current.set(O,q);try{await e.deleteThread(O),T.current===O&&(l(null),o==null||o())}catch(J){i(j);const P=String(J);n==null||n(P)}finally{E.current.delete(O)}},[e,o,n,s]),K=b.useCallback(async(O,j)=>{try{await e.updateThread(O,j),await _()}catch(q){n==null||n(String(q))}},[e,n,_]),B=b.useCallback(async(O,j)=>{C(!0),S("Sharing thread…");try{await e.shareThread(O,j),await R(),S("Shared successfully")}catch(q){const J=Ov(q);throw n==null||n(J),S(`Failed to share: ${J}`),new Error(J)}finally{C(!1)}},[e,n,R]),I=b.useCallback(async(O,j)=>{try{await e.unshareThread(O,j),await R()}catch(q){const J=String(q);throw n==null||n(J),q}},[e,n,R]),W=b.useMemo(()=>({createThread:L,deleteThread:H,renameThread:K,refreshThreads:_,refreshSharedThreads:R,shareThread:B,unshareThread:I}),[L,H,K,_,R,B,I]),N=b.useCallback(O=>{if(!(O!=null&&O.threadId))return;const j={threadId:O.threadId,title:O.title||`Thread ${O.threadId.slice(0,8)}`,createdAt:O.createdAt||new Date().toISOString(),updatedAt:O.updatedAt||new Date().toISOString(),messageCount:O.messageCount??1};i(q=>{let J=!1;const P=q.map(M=>M.threadId===j.threadId?(J=!0,console.debug("[useThreadsState] thread_info: updating existing thread",j.threadId),{...M,title:j.title??M.title,updatedAt:j.updatedAt??M.updatedAt,messageCount:j.messageCount??M.messageCount}):M);return J?P:(console.debug("[useThreadsState] thread_info: adding thread to list",j.threadId),[j,...q])})},[]),U=b.useCallback(()=>S(null),[]);return{threads:s,currentThreadId:a,currentThreadIdRef:T,setCurrentThreadId:l,isLoadingThreads:c,threadsError:p,sharedThreads:f,isLoadingSharedThreads:g,actions:W,addThreadFromEvent:N,shareInFlight:k,shareStatus:w,clearShareStatus:U}}const au=b.createContext(null);function lu({children:e,initialThreadId:t=null,onError:n,onThreadChange:r}){const{api:o}=Vr(),{threads:s,currentThreadId:i,setCurrentThreadId:a,currentThreadIdRef:l,isLoadingThreads:c,threadsError:d,sharedThreads:p,isLoadingSharedThreads:m,actions:f,addThreadFromEvent:v,shareInFlight:g,shareStatus:x,clearShareStatus:y}=iu({api:o,initialThreadId:t,onError:n,onThreadChange:r}),w=b.useMemo(()=>({threads:s,currentThreadId:i,setCurrentThreadId:a,currentThreadIdRef:l,isLoading:c,error:d,sharedThreads:p,isLoadingSharedThreads:m,actions:f,shareInFlight:g,shareStatus:x,clearShareStatus:y,addThreadFromEvent:v}),[s,i,a,l,c,d,p,m,f,g,x,y,v]);return u.jsx(au.Provider,{value:w,children:e})}function pr(){const e=b.useContext(au);if(!e)throw new Error("useThreads must be used within a ThreadsProvider");return e}function Ni(e){const t=e==null?void 0:e.trim();if(!t||!(t.startsWith("{")||t.startsWith("[")))return null;try{return JSON.parse(t)}catch{return null}}function cu(e){return!!(e&&typeof e=="object"&&(e.type==="file"||e.mimeType||e.filename||e.sourceType==="base64"))}function Kr(e){if(typeof e=="string")return e;if(e&&typeof e=="object"){if(Array.isArray(e)){const n=e.map(Kr).filter(r=>r!==void 0);if(!n.length){console.debug("[message-utils] sanitizeForDisplay - array emptied -> returning undefined",{originalLength:e.length});return}return n}if(cu(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=Kr(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 hr(e){if(typeof e=="string")return e;if(cu(e))return"";try{const t=Kr(e);return t===void 0?"":typeof t=="string"?t:JSON.stringify(t,null,2)}catch{return""}}function Dv(e){return typeof e!="string"?!1:/^[\s\n]*[-*]\s|^[\s\n]*#+\s|```|^\s*\[.*\]\(|^>\s/.test(e)}function Lv(e){const t=hr(e);return typeof e=="string"&&Dv(e)?{content:e,isMarkdown:!0}:{content:t,isMarkdown:!1}}function qr(e){if(e==null)return e;if(typeof e=="string"){const t=e.trim();if(t.startsWith("{")||t.startsWith("[")){const n=Ni(t);if(n!==null)return qr(n)}return e}return typeof e=="object"&&!Array.isArray(e)&&e.content!==void 0?qr(e.content):e}function $v(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function Ai(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 Wo(e){if(e==null)return null;const t=String(e).trim();return t.length>0?t:null}function Fv(e){const t=r=>{try{const o=Kr(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 Bv(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function uu(e){if("type"in e&&e.type==="default_message")return`default:${e.content.length}`;const t=e.updatedAt??e.createdAt??"",n=Array.isArray(e.content)?e.content.map(r=>{switch(r.type){case"text":return`t:${r.text.length}`;case"image_url":return"img";case"file":return"file";case"tool_call":return"call";case"interrupt":return"interrupt";default:return"unknown"}}).join("|"):"";return`${e.id}:${t}:${n}`}function zv(e){if(!e)return"image/png";const t=e.trim();return t?t.includes("/")?t:`image/${t}`:"image/png"}function Hv(e){const t=[],n=r=>{r&&r.trim()&&t.push(r.trim())};return e&&(n(e.plotId),n(e.artifactId)),t}function Uv({base64:e,url:t,formatHint:n,extras:r}){const o=typeof e=="string"&&e.length>0,s=zv(n),i=o?`data:${s};base64,${e}`:t,a=Hv(r),l=a.length?a.join(" / "):void 0,c=l?`${l} artifact`:"artifact image";return{src:i,alt:c,label:l}}function Wv(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 Uv({base64:t,url:n,formatHint:r,extras:{plotId:e.plotId,artifactId:e.artifactId}})}function du(e){var n;const t=(n=e.additionalKwargs)==null?void 0:n.toolProgress;return Array.isArray(t)?t:[]}function ji(e){return e.filter(t=>{var i;if(t.role!=="assistant")return!0;const n=(t.content??[]).some(a=>{var l;return a&&a.type==="text"&&((l=a.text)==null?void 0:l.trim())}),r=(t.content??[]).some(a=>a&&a.type==="image_url"),o=(i=t.artifact)==null?void 0:i.plots,s=Array.isArray(o)&&o.length>0;return!!(n||r||s)})}function Gr(e,t,n){return t<0||t>=e.length?e:[...e.slice(0,t),n,...e.slice(t+1)]}function Vv(e){let t=!1;const n=e.map(r=>{const o=(r.content??[]).filter(s=>s.type!=="interrupt");return o.length!==r.content.length?(t=!0,{...r,content:o}):r});return t?n:e}function fu(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="assistant")return e[t].id;return null}function pu(e){return!e||!e.length?"":e.filter(t=>t.type==="text").map(t=>t.text??"").join("")}function Kv(e,t,n,r){const o={...n};if(r!==null&&typeof r=="number"){if(typeof o.lastSeq=="number"&&r<=o.lastSeq)return{newParts:e,newMeta:o,changed:!1};o.lastSeq=r}const s=t.filter(p=>p.type==="text").map(p=>p.text??"").join(""),i=t.filter(p=>p.type!=="text"),a=o.lastText??pu(e);let l="",c=e.slice();if(s){const p=qv(a,s);if(p===""?l="":p===s?l=s:l=p,l){const m=c[c.length-1];if((m==null?void 0:m.type)==="text"){const f=m.text??"",v={...m,text:f+l};c=[...c.slice(0,c.length-1),v]}else c=[...c,{type:"text",text:l}];o.lastText=a+l}else o.lastText=a}i.length&&(c=[...c,...i]);const d=!!(l||i.length);return{newParts:c,newMeta:o,changed:d}}function hu(e){return e.replace(/\s+/g," ").trim()}function qv(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 Gv(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 Gr(e,r,s)}return e}function Yv(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}const Xv={messages:[],assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,messagesStreamMeta:{},pendingInterrupt:null};function Jv(e,t){var n;switch(t.type){case"reset":return{messages:ji(((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=ji(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=ji(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 mu(e,t.payload.ev);case"batch":{const{events:r}=t.payload;return r.length?r.reduce((o,s)=>mu(o,s),e):e}default:return e}}function Zv(e=[]){const[t,n]=b.useReducer(Jv,{...Xv,messages:e}),r=b.useRef([]),o=b.useRef(null),s=b.useRef(null),i=b.useCallback(()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),o.current=null,s.current=null;const d=r.current;d.length&&(r.current=[],n({type:"batch",payload:{events:d}}))},[]),a=b.useCallback(()=>{typeof window<"u"&&typeof window.requestAnimationFrame=="function"?o.current===null&&(o.current=window.requestAnimationFrame(()=>i())):s.current===null&&(s.current=setTimeout(i,8))},[i]),l=b.useCallback(d=>{r.current.push(d),a()},[a]);b.useEffect(()=>()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),r.current=[]},[]);const c=b.useMemo(()=>({reset:d=>n({type:"reset",payload:{messages:d}}),seed:(d,p)=>n({type:"seed",payload:{messages:d,...p??{}}}),prepend:d=>n({type:"prepend",payload:{messages:d}}),pushUser:(d,p)=>n({type:"user_message",payload:{message:d,editingMessageId:p}}),onEvent:l}),[l]);return{state:t,dispatch:n,...c}}function mu(e,t){var n,r,o;if(t.type==="message.start"&&t.role==="assistant"){const s=t.id,i=Yv(t.model);if(e.messages.some(c=>c.id===s)){const c=e.messagesStreamMeta??{},d={...c,[s]:c[s]??{lastSeq:t.seq??null,lastText:""}};return{...e,assemblingId:s,messagesStreamMeta:d}}const l={id:s,role:"assistant",name:i||void 0,model:t.model,createdAt:new Date().toISOString(),content:[]};return{...e,assemblingId:s,messages:[...e.messages,l]}}if(t.type==="tool.start")return ew(e,t);if(t.type==="tool.progress")return tw(e,t);if(t.type==="tool.end")return nw(e,t);if(t.type==="message.delta"){const s=e.assemblingId??fu(e.messages);if(!s)return e;const i=e.messages,a=i.findIndex(C=>C.id===s&&C.role==="assistant");if(a===-1)return e;const l=i[a],c=e.messagesStreamMeta,d=c??{},p=d[s],m=p??{lastSeq:null,lastText:pu(l.content)},f=t.seq??null;if(f!==null&&typeof f=="number"&&typeof m.lastSeq=="number"&&f<=m.lastSeq)return console.debug("[MessageReducer] skipping delta - seq <= lastSeq",{seq:f,lastSeq:m.lastSeq}),e;const{newParts:v,newMeta:g,changed:x}=Kv(l.content,t.delta,m,f);if(!x)return e;const y={...l,content:v},w=Gr(i,a,y),S=!p||p.lastSeq!==g.lastSeq||p.lastText!==g.lastText,k=S?{...d,[s]:g}:c;return S?{...e,messages:w,messagesStreamMeta:k}:{...e,messages:w}}if(t.type==="message.end"){const s=e.assemblingId??fu(e.messages);if(!s)return{...e,assemblingId:null};const i=e.messages,a=i.findIndex(l=>l.id===s&&l.role==="assistant");if(a>=0){const l=i[a];if(!((n=l.content)==null?void 0:n.some(d=>{var p;return(d==null?void 0:d.type)==="text"&&((p=d.text)==null?void 0:p.trim())}))){console.debug("[MessageReducer] pruning assistant message with no visible text",{id:l.id,contentTypes:(r=l.content)==null?void 0:r.map(p=>p==null?void 0:p.type),contentPreview:(o=l.content)==null?void 0:o.map(p=>(p==null?void 0:p.type)==="text"?String(p.text).slice(0,100):p==null?void 0:p.type)});const d=[...i.slice(0,a),...i.slice(a+1)];return{...e,assemblingId:null,messages:d}}}return e}if(t.type==="checkpoint"){const s=t.checkpointNs??e.lastCheckpointNs??null,i=Gv(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=Nn(t),i=s.interrupt,a=s.latest,l=i===null?Vv(e.messages):e.messages;return{...e,messages:l,pendingInterrupt:i,lastCheckpointId:(a==null?void 0:a.checkpointId)??e.lastCheckpointId,lastCheckpointNs:(a==null?void 0:a.checkpointNs)??e.lastCheckpointNs}}return t.type==="thread_info",e}function _i(e){return e.call_id??e.id??null}function gu(e){return e.id??e.call_id??`tool-${Date.now()}-${Math.random().toString(16).slice(2)}`}function xu(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 Pi(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||Ai(r).toolCallId===t)return n}return-1}function Qv(e){if(e==null)return[];const t=qr(e);if(typeof t=="string"&&t.trim())return[{type:"text",text:t}];const n=hr(t??e);return n?[{type:"text",text:n}]:[]}function vu(e,t){const n=e.additionalKwargs??{},r=Array.isArray(n.toolProgress)?[...n.toolProgress]:[],o={...n,toolProgress:[...r,t]};return{...e,additionalKwargs:o}}function ew(e,t){const n=_i(t),r=Pi(e.messages,n),o=t.name??t.tool??void 0,s=gu(t);if(r>=0){const a=e.messages[r],c={...a.additionalKwargs??{},toolStreaming:!0,toolProgress:[]},d={...a,name:o??a.name,additionalKwargs:c};return{...e,messages:Gr(e.messages,r,d)}}const i=xu(s,n,o,t.args);return{...e,messages:[...e.messages,i]}}function tw(e,t){const n=_i(t);if(!n)return e;const r=Pi(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=vu(e.messages[r],o);return{...e,messages:Gr(e.messages,r,a)}}function nw(e,t){const n=_i(t),r=gu(t);let o=e.messages,s=Pi(o,n);if(s===-1){const v=t.name??t.tool??void 0;o=[...o,xu(r,n,v,{})],s=o.length-1}const i=o[s],a=t.output??t.error??null,l=Qv(a),c=[...i.content,...l],d={type:t.type,content:typeof t.output=="string"?t.output:void 0,seq:t.seq??null,timestamp:new Date().toISOString()};t.artifact&&(d.artifact=t.artifact);const p=vu(i,d),m=t.artifact??i.artifact,f={...p,name:t.name??t.tool??i.name,content:c,artifact:m,additionalKwargs:{...p.additionalKwargs??{},toolStreaming:!1}};return{...e,messages:Gr(o,s,f)}}function wu({api:e,seed:t,prepend:n,onError:r,currentThreadId:o,initialThreadId:s=null,initialCheckpointId:i=null,initialCheckpointNs:a=null,autoLoadInitial:l=!0,isStreaming:c,getMessages:d}){const[p,m]=b.useState(null),v=b.useMemo(()=>Nn(p),[p]).checkpoints,g=nc(v),x=g.timeline,[y,w]=b.useState(!1),[S,k]=b.useState(null),[C,T]=b.useState(!1),[E,_]=b.useState(!1),[R,L]=b.useState(!1),[H,K]=b.useState(null),B=b.useRef(o),I=b.useRef(null),W=b.useRef(null),N=b.useRef(null),U=b.useRef(null),O=b.useRef(!1),j=b.useRef(null),q=b.useRef(new Map);b.useEffect(()=>{B.current=o},[o]);const J=b.useCallback(async $=>{var we,de;if(!$.threadId)return;const re=$.threadId;(we=$.onStart)==null||we.call($),$.setLoading(!0);try{await $.action(re)}catch(xe){if(B.current===re){const Ee=String(xe);(de=$.handleError)==null||de.call($,Ee),r==null||r(Ee)}throw xe}finally{$.setLoading(!1)}},[r]),P=b.useCallback(async($,re)=>{if(!$)return;const we=`${$}:${re??"latest"}`,de=q.current.get(we);if(de)return de;const xe=J({threadId:$,setLoading:T,onStart:()=>K(null),handleError:Ee=>K(Ee),action:async Ee=>{const Be=await e.getStateHistory({threadId:Ee,checkpointId:re??void 0});if(B.current!==Ee){console.log(`[useThreadHistoryState] Thread changed during load (was ${Ee}, now ${B.current}), discarding stale data`);return}const{checkpoints:We}=Nn(Be),je=We.find(Ve=>Ve.messages&&Ve.messages.length>0)??(re?We.find(Ve=>Ve.checkpointId===re):null)??We[0];t((je==null?void 0:je.messages)??[],{checkpointId:(je==null?void 0:je.checkpointId)??null,checkpointNs:(je==null?void 0:je.checkpointNs)??null}),m(Be),w(!!(je!=null&&je.nextCursor)),k((je==null?void 0:je.nextCursor)??null)}});q.current.set(we,xe);try{await xe}finally{q.current.delete(we)}return B.current===$&&(j.current=we),xe},[e,t,J]),M=b.useCallback(async($,re)=>{U.current=$;try{await P($,re)}finally{U.current===$&&(U.current=null)}},[P]),G=b.useCallback($=>{W.current=$},[]),Z=b.useCallback($=>{N.current=$},[]),se=b.useCallback($=>{const re=$.threadId??B.current;if(!re||B.current&&B.current!==re)return;const{checkpoints:we}=Nn($);if(!we.length)return;const de=we.find(xe=>xe.messages&&xe.messages.length>0)??we.find(xe=>!!xe.checkpointId)??we[0];t((de==null?void 0:de.messages)??[],{checkpointId:(de==null?void 0:de.checkpointId)??null,checkpointNs:(de==null?void 0:de.checkpointNs)??null}),m($),w(!!(de!=null&&de.nextCursor)),k((de==null?void 0:de.nextCursor)??null),j.current=`${re}:latest`,W.current=null,N.current=null},[t]),V=b.useCallback(async($,re)=>{const we=B.current;await J({threadId:we,setLoading:L,action:async de=>{const xe=await e.getStateHistory({threadId:de,checkpointId:$,checkpointNs:re??void 0});if(B.current!==de){console.log(`[useThreadHistoryState] Thread changed during checkpoint navigation (was ${de}, now ${B.current}), discarding stale data`);return}const{checkpoints:Ee}=Nn(xe),Be=Ee.find(We=>We.checkpointId===$&&(re?We.checkpointNs===re:!0));if(!Be){console.warn("[useThreadHistoryState] Requested checkpoint not found:",{checkpointId:$,checkpointNs:re});return}m(xe),t(Be.messages??[],{checkpointId:Be.checkpointId??null,checkpointNs:Be.checkpointNs??null})}}).catch(()=>{})},[e,t,J]),D=b.useCallback(($,re)=>{t(d(),{checkpointId:$??null,checkpointNs:re??null})},[d,t]),X=b.useCallback(async()=>{B.current&&await M(B.current)},[M]),Q=b.useCallback(async()=>{const $=B.current;!$||!S||await J({threadId:$,setLoading:_,action:async re=>{const we=await e.getStateHistory({threadId:re,checkpointId:S});if(B.current!==re)return;const{checkpoints:de}=Nn(we);if(de.length>0){const xe=de[de.length-1];n((xe==null?void 0:xe.messages)??[]),w(!!(xe!=null&&xe.nextCursor)),k((xe==null?void 0:xe.nextCursor)??null)}}}).catch(()=>{})},[e,S,r,n,J]);b.useEffect(()=>{if(!l||!o||C||c)return;if(W.current===o){W.current=null,I.current=o;return}if(N.current===o){I.current=o;return}if(U.current===o){U.current=null,I.current=o;return}if(I.current===o)return;I.current=o;const $=!O.current&&!!i&&o===s;let re;$&&i?(re=i,O.current=!0,console.log("[useThreadHistoryState] Loading thread with checkpoint:",re,a?`(ns: ${a})`:"")):console.log("[useThreadHistoryState] Loading thread with latest checkpoint");const we=`${o}:${re??"latest"}`;j.current!==we&&M(o,re)},[l,o,i,a,s,C,c,M]);const ae=b.useCallback(()=>{m(null),w(!1),k(null),T(!1),_(!1),L(!1),K(null),W.current=null,N.current=null,I.current=null,j.current=null,U.current=null},[]);return{threadCheckpoints:v,threadTimeline:x,checkpointIndex:g,isLoadingThread:C,isHistoryLoading:E,isLoadingCheckpoint:R,threadStateError:H,hasMoreHistory:y,loadThread:M,navigateToCheckpoint:V,loadOlderMessages:Q,setCurrentCheckpointId:D,returnToLatest:X,handleStateHistoryEvent:se,markSkipNextLoad:G,markStreamPendingThread:Z,resetHistoryState:ae}}const bu=b.createContext(null),yu=b.createContext(null);function Yr(){const e=b.useContext(bu);if(!e)throw new Error("useThreadState must be used within a ThreadStateProvider");return e}function Su(){const e=b.useContext(yu);if(!e)throw new Error("useThreadStateUpdater must be used within a ThreadStateProvider");return e}function Cu({children:e,initialThreadId:t=null,initialCheckpointId:n=null,initialCheckpointNs:r=null,autoLoadInitial:o=!0,isStreaming:s,onError:i}){const{api:a}=Vr(),{currentThreadId:l}=pr(),{state:c,seed:d,prepend:p,pushUser:m,onEvent:f}=Zv(),{threadCheckpoints:v,threadTimeline:g,checkpointIndex:x,isLoadingThread:y,isHistoryLoading:w,isLoadingCheckpoint:S,threadStateError:k,hasMoreHistory:C,loadThread:T,navigateToCheckpoint:E,loadOlderMessages:_,setCurrentCheckpointId:R,returnToLatest:L,handleStateHistoryEvent:H,markSkipNextLoad:K,markStreamPendingThread:B,resetHistoryState:I}=wu({api:a,seed:d,prepend:p,onError:i,currentThreadId:l,initialThreadId:t,initialCheckpointId:n,initialCheckpointNs:r,autoLoadInitial:o,isStreaming:s,getMessages:b.useCallback(()=>c.messages,[c.messages])}),[W,N]=b.useState(()=>async()=>{throw new Error("clearThread is not ready")}),[U,O]=b.useState(()=>async()=>{throw new Error("respondToInterrupt is not ready")});b.useEffect(()=>{l||(d([],{}),I())},[l,d,I]);const j=b.useCallback(G=>N(()=>G),[]),q=b.useCallback(G=>O(()=>G),[]),J=b.useMemo(()=>{const G=c.assemblingId??null;return G?{assemblingMessageId:G}:null},[c.assemblingId]),P=b.useMemo(()=>({threadId:l,messages:c.messages,interrupt:c.pendingInterrupt,checkpoint:{id:c.lastCheckpointId??null,namespace:c.lastCheckpointNs??null},checkpoints:v,checkpointIndex:x,timelineCheckpoints:g,metadata:J,isLoading:y,isHistoryLoading:w,isLoadingCheckpoint:S,error:k,hasMore:C,loadOlder:_,clearState:W,navigateToCheckpoint:E,setCurrentCheckpointId:R,returnToLatest:L,loadThread:T,clearThread:W,respondToInterrupt:U,messagePreviews:x.messagePreviews,handleStateHistoryEvent:H,markSkipNextLoad:K,markStreamPendingThread:B,resetHistoryState:I,pushUser:m,onEvent:f}),[l,c,v,g,x,J,y,w,S,k,C,_,W,E,R,L,T,U,x.messagePreviews,H,K,B,I,m,f]),M=b.useMemo(()=>({registerClearThread:j,registerRespondToInterrupt:q}),[j,q]);return u.jsx(yu.Provider,{value:M,children:u.jsx(bu.Provider,{value:P,children:e})})}const Tu=b.createContext(null),ku=b.createContext(!1);function rw({children:e,initialThreadId:t=null,initialCheckpointId:n=null,initialCheckpointNs:r=null,autoLoadInitial:o=!0,onError:s,onAuthError:i,onThreadChange:a,onConnectionError:l,onToolEnd:c}){const{api:d,baseUrl:p}=Vr(),m=b.useMemo(()=>mn(p),[p]),{stream:f,stop:v,isStreaming:g,error:x,setToken:y}=Mv({baseUrl:m}),[w,S]=b.useState(!1);return b.useEffect(()=>{S(g)},[g]),u.jsx(lu,{initialThreadId:t,onError:s,onThreadChange:a,children:u.jsx(Cu,{initialThreadId:t,initialCheckpointId:n,initialCheckpointNs:r,autoLoadInitial:o,onError:s,isStreaming:w,children:u.jsx(ku.Provider,{value:!0,children:u.jsx(ow,{api:d,streamApi:{stream:f,stop:v,isStreaming:g,error:x,setToken:y},onError:s,onAuthError:i,onConnectionError:l,onToolEnd:c,children:e})})})})}function ow({children:e,api:t,streamApi:n,onError:r,onAuthError:o,onConnectionError:s,onToolEnd:i}){const{stream:a,stop:l,isStreaming:c,error:d,setToken:p}=n,{setCurrentThreadId:m,currentThreadIdRef:f,addThreadFromEvent:v}=pr(),{checkpoint:g,timelineCheckpoints:x,handleStateHistoryEvent:y,markSkipNextLoad:w,markStreamPendingThread:S,resetHistoryState:k,pushUser:C,onEvent:T}=Yr(),{registerClearThread:E,registerRespondToInterrupt:_}=Su(),R=b.useCallback(N=>{v(N),f.current!==N.threadId&&((N.created??!f.current)&&w(N.threadId),S(N.threadId),m(N.threadId))},[v,w,S,m,f]),L=b.useCallback(N=>{N.type==="thread_info"?R(N):N.type==="state_history"?y(N):N.type==="tool.end"?i==null||i(N):T(N)},[R,y,T,i]),H=b.useCallback(N=>{a(N,L,{onError:U=>{console.error("[StreamingProvider] Stream error:",U),r==null||r(U)},onAuthError:U=>{console.error("[StreamingProvider] Auth error:",U),o==null||o(U)},onConnectionError:U=>{console.error("[StreamingProvider] Connection error:",U),s==null||s(U)}})},[a,L,r,o,s]),K=b.useCallback(async(N,U,O)=>{const j=f.current;if(!j)throw new Error("No active thread to handle interrupt");const q=U?O??!0:!1,J={threadId:j,checkpointId:g.id??void 0,checkpointNs:g.namespace??void 0,command:{kind:"resume",value:q}};H(J)},[g,f,H]);b.useEffect(()=>{_(K)},[K,_]);const B=b.useCallback(async()=>{l(),k(),m(null);try{await t.getAgent("default")}catch(N){console.warn("[StreamingProvider] Failed to refetch agent after clearing thread:",N)}},[t,k,m,l]);b.useEffect(()=>{E(B)},[B,E]);const I=b.useCallback(async(N,U)=>{let O=f.current;const j=(N==null?void 0:N.text)??"",q=(N==null?void 0:N.attachments)??[],J=(j==null?void 0:j.trim())??"",P={...(N==null?void 0:N.payload)??{}},M=Array.isArray(P.messages)?P.messages:void 0;M&&delete P.messages;const G=!!(M&&M.length);if(!O&&!J&&q.length===0&&!G)return;if(!O){const de=Math.floor(Date.now()/1e3).toString(16).padStart(8,"0"),xe=Array.from({length:4},()=>Math.floor(Math.random()*4294967295).toString(16).padStart(8,"0")).join("").slice(0,16);O=`${de}${xe}`,w(O),m(O)}const{contentParts:Z,filesInfo:se}=await ou(q),V=[...Z];J&&V.push({type:"text",text:j});const D=U==null?void 0:U.originalMessageId,X=!!(U!=null&&U.edit&&D),Q=!G&&V.length>0;let ae=null;Q&&(ae={id:X?D:`msg-${Date.now()}`,role:"user",content:V,createdAt:new Date().toISOString()},X?C(ae,D):C(ae));const $=G?M:ae?[ae]:[],re={...P,...se.length?{files_info:se}:{}};$.length?re.messages=$:"messages"in re||(re.messages=[]);const we={threadId:O,payload:re,checkpointId:g.id??void 0,checkpointNs:g.namespace??void 0,edit:!!(U!=null&&U.edit),timelineCheckpoints:x};H(we)},[g,f,w,C,H,x]),W=b.useMemo(()=>({isStreaming:c,error:d,connectionState:c?"connected":"idle",submit:I,send:I,stop:l,setAuthToken:p}),[c,d,I,l,p]);return u.jsx(Tu.Provider,{value:W,children:e})}function Mi(){const e=b.useContext(Tu);if(!e)throw new Error("useStream must be used within StreamingProvider");return e}function sw(){return b.useContext(ku)}function Xr({children:e,apiConfig:t,initialThreadId:n=null,initialCheckpointId:r=null,initialCheckpointNs:o=null,autoLoadInitial:s=!0,onConnectionError:i,onError:a,onAuthError:l,onThreadChange:c,onToolEnd:d}){return u.jsx(nu,{apiConfig:t,children:u.jsx(rw,{initialThreadId:n,initialCheckpointId:r,initialCheckpointNs:o,autoLoadInitial:s,onError:a,onAuthError:l,onConnectionError:i,onThreadChange:c,onToolEnd:d,children:e})})}function mr(e){if(!(typeof globalThis>"u"))return globalThis[e]}function iw(e){if(typeof e!="string")return;const t=e.trim();if(t)return mn(t)}function Eu(){const e=[mr("__API_BASE_URL__"),mr("__CHAT_API_BASE_URL__"),mr("__CHAT_API_URL__")];for(const t of e){const n=iw(t);if(n)return n}}function Iu(){const e=[mr("__API_AUTH_TOKEN__"),mr("__CHAT_API_KEY__"),mr("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function Nu(...e){for(const t of e)if(typeof t=="string"&&t.trim())return mn(t);return mn()}function Au(){const e={},t=Eu(),n=Iu();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function ju(){const e=Au(),t=An.getAuthToken(),n=Eu();return{apiBaseUrl:Nu(e.baseUrl,An.baseUrl,n),apiKey:t||e.apiKey||Iu()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,darkMode:!1,enableSound:!1,messageHistory:100}}const Ri="chat-settings";function _u(){try{const e=localStorage.getItem(Ri);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function Pu(e){try{const t={...e,apiBaseUrl:mn(e.apiBaseUrl)};localStorage.setItem(Ri,JSON.stringify(t)),t.apiKey&&An.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function aw(){const e=ju(),t=_u(),n=An.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:Nu(An.baseUrl,r,e.apiBaseUrl)}}function lw(e){An.updateConfig({baseUrl:e.apiBaseUrl,authToken:e.apiKey??void 0}),Pu(e)}function ne(...e){return Zg.twMerge(Jg.clsx(e))}const cw=Dr.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"}}),at=h.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?Vt.Slot:"button";return u.jsx(i,{className:ne(cw({variant:t,size:n,className:e})),ref:s,...o})});at.displayName="Button";function ie(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}function Mu(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function jn(...e){return t=>{let n=!1;const r=e.map(o=>{const s=Mu(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():Mu(e[o],null)}}}}function De(...e){return h.useCallback(jn(...e),e)}function uw(e,t){const n=h.createContext(t),r=s=>{const{children:i,...a}=s,l=h.useMemo(()=>a,Object.values(a));return u.jsx(n.Provider,{value:l,children:i})};r.displayName=e+"Provider";function o(s){const i=h.useContext(n);if(i)return i;if(t!==void 0)return t;throw new Error(`\`${s}\` must be used within \`${e}\``)}return[r,o]}function sn(e,t=[]){let n=[];function r(s,i){const a=h.createContext(i),l=n.length;n=[...n,i];const c=p=>{var y;const{scope:m,children:f,...v}=p,g=((y=m==null?void 0:m[e])==null?void 0:y[l])||a,x=h.useMemo(()=>v,Object.values(v));return u.jsx(g.Provider,{value:x,children:f})};c.displayName=s+"Provider";function d(p,m){var g;const f=((g=m==null?void 0:m[e])==null?void 0:g[l])||a,v=h.useContext(f);if(v)return v;if(i!==void 0)return i;throw new Error(`\`${p}\` must be used within \`${s}\``)}return[c,d]}const o=()=>{const s=n.map(i=>h.createContext(i));return function(a){const l=(a==null?void 0:a[e])||s;return h.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return o.scopeName=e,[r,dw(o,...t)]}function dw(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(s){const i=r.reduce((a,{useScope:l,scopeName:c})=>{const p=l(s)[`__scope${c}`];return{...a,...p}},{});return h.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var kt=globalThis!=null&&globalThis.document?h.useLayoutEffect:()=>{},fw=h[" useInsertionEffect ".trim().toString()]||kt;function _n({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=pw({defaultProp:t,onChange:n}),a=e!==void 0,l=a?e:o;{const d=h.useRef(e!==void 0);h.useEffect(()=>{const p=d.current;p!==a&&console.warn(`${r} is changing from ${p?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),d.current=a},[a,r])}const c=h.useCallback(d=>{var p;if(a){const m=hw(d)?d(e):d;m!==e&&((p=i.current)==null||p.call(i,m))}else s(d)},[a,e,s,i]);return[l,c]}function pw({defaultProp:e,onChange:t}){const[n,r]=h.useState(e),o=h.useRef(n),s=h.useRef(t);return fw(()=>{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 hw(e){return typeof e=="function"}var mw=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],be=mw.reduce((e,t)=>{const n=Vt.createSlot(`Primitive.${t}`),r=h.forwardRef((o,s)=>{const{asChild:i,...a}=o,l=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),u.jsx(l,{...a,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Oi(e,t){e&&Lr.flushSync(()=>e.dispatchEvent(t))}function Vo(e){const t=e+"CollectionProvider",[n,r]=sn(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=g=>{const{scope:x,children:y}=g,w=b.useRef(null),S=b.useRef(new Map).current;return u.jsx(o,{scope:x,itemMap:S,collectionRef:w,children:y})};i.displayName=t;const a=e+"CollectionSlot",l=Vt.createSlot(a),c=b.forwardRef((g,x)=>{const{scope:y,children:w}=g,S=s(a,y),k=De(x,S.collectionRef);return u.jsx(l,{ref:k,children:w})});c.displayName=a;const d=e+"CollectionItemSlot",p="data-radix-collection-item",m=Vt.createSlot(d),f=b.forwardRef((g,x)=>{const{scope:y,children:w,...S}=g,k=b.useRef(null),C=De(x,k),T=s(d,y);return b.useEffect(()=>(T.itemMap.set(k,{ref:k,...S}),()=>void T.itemMap.delete(k))),u.jsx(m,{[p]:"",ref:C,children:w})});f.displayName=d;function v(g){const x=s(e+"CollectionConsumer",g);return b.useCallback(()=>{const w=x.collectionRef.current;if(!w)return[];const S=Array.from(w.querySelectorAll(`[${p}]`));return Array.from(x.itemMap.values()).sort((T,E)=>S.indexOf(T.ref.current)-S.indexOf(E.ref.current))},[x.collectionRef,x.itemMap])}return[{Provider:i,Slot:c,ItemSlot:f},v,r]}var gw=h.createContext(void 0);function Ko(e){const t=h.useContext(gw);return e||t||"ltr"}function mt(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 xw(e,t=globalThis==null?void 0:globalThis.document){const n=mt(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 vw="DismissableLayer",Di="dismissableLayer.update",ww="dismissableLayer.pointerDownOutside",bw="dismissableLayer.focusOutside",Ru,Ou=h.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),gr=h.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...l}=e,c=h.useContext(Ou),[d,p]=h.useState(null),m=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,f]=h.useState({}),v=De(t,E=>p(E)),g=Array.from(c.layers),[x]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),y=g.indexOf(x),w=d?g.indexOf(d):-1,S=c.layersWithOutsidePointerEventsDisabled.size>0,k=w>=y,C=Sw(E=>{const _=E.target,R=[...c.branches].some(L=>L.contains(_));!k||R||(o==null||o(E),i==null||i(E),E.defaultPrevented||a==null||a())},m),T=Cw(E=>{const _=E.target;[...c.branches].some(L=>L.contains(_))||(s==null||s(E),i==null||i(E),E.defaultPrevented||a==null||a())},m);return xw(E=>{w===c.layers.size-1&&(r==null||r(E),!E.defaultPrevented&&a&&(E.preventDefault(),a()))},m),h.useEffect(()=>{if(d)return n&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(Ru=m.body.style.pointerEvents,m.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(d)),c.layers.add(d),Lu(),()=>{n&&c.layersWithOutsidePointerEventsDisabled.size===1&&(m.body.style.pointerEvents=Ru)}},[d,m,n,c]),h.useEffect(()=>()=>{d&&(c.layers.delete(d),c.layersWithOutsidePointerEventsDisabled.delete(d),Lu())},[d,c]),h.useEffect(()=>{const E=()=>f({});return document.addEventListener(Di,E),()=>document.removeEventListener(Di,E)},[]),u.jsx(be.div,{...l,ref:v,style:{pointerEvents:S?k?"auto":"none":void 0,...e.style},onFocusCapture:ie(e.onFocusCapture,T.onFocusCapture),onBlurCapture:ie(e.onBlurCapture,T.onBlurCapture),onPointerDownCapture:ie(e.onPointerDownCapture,C.onPointerDownCapture)})});gr.displayName=vw;var yw="DismissableLayerBranch",Du=h.forwardRef((e,t)=>{const n=h.useContext(Ou),r=h.useRef(null),o=De(t,r);return h.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),u.jsx(be.div,{...e,ref:o})});Du.displayName=yw;function Sw(e,t=globalThis==null?void 0:globalThis.document){const n=mt(e),r=h.useRef(!1),o=h.useRef(()=>{});return h.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){$u(ww,n,c,{discrete:!0})};const c={originalEvent:a};a.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=l,t.addEventListener("click",o.current,{once:!0})):l()}else t.removeEventListener("click",o.current);r.current=!1},i=window.setTimeout(()=>{t.addEventListener("pointerdown",s)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",s),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function Cw(e,t=globalThis==null?void 0:globalThis.document){const n=mt(e),r=h.useRef(!1);return h.useEffect(()=>{const o=s=>{s.target&&!r.current&&$u(bw,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 Lu(){const e=new CustomEvent(Di);document.dispatchEvent(e)}function $u(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?Oi(o,s):o.dispatchEvent(s)}var Tw=gr,kw=Du,Li=0;function $i(){h.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Fu()),document.body.insertAdjacentElement("beforeend",e[1]??Fu()),Li++,()=>{Li===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Li--}},[])}function Fu(){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 Fi="focusScope.autoFocusOnMount",Bi="focusScope.autoFocusOnUnmount",Bu={bubbles:!1,cancelable:!0},Ew="FocusScope",qo=h.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,l]=h.useState(null),c=mt(o),d=mt(s),p=h.useRef(null),m=De(t,g=>l(g)),f=h.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;h.useEffect(()=>{if(r){let g=function(S){if(f.paused||!a)return;const k=S.target;a.contains(k)?p.current=k:Pn(p.current,{select:!0})},x=function(S){if(f.paused||!a)return;const k=S.relatedTarget;k!==null&&(a.contains(k)||Pn(p.current,{select:!0}))},y=function(S){if(document.activeElement===document.body)for(const C of S)C.removedNodes.length>0&&Pn(a)};document.addEventListener("focusin",g),document.addEventListener("focusout",x);const w=new MutationObserver(y);return a&&w.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",g),document.removeEventListener("focusout",x),w.disconnect()}}},[r,a,f.paused]),h.useEffect(()=>{if(a){Uu.add(f);const g=document.activeElement;if(!a.contains(g)){const y=new CustomEvent(Fi,Bu);a.addEventListener(Fi,c),a.dispatchEvent(y),y.defaultPrevented||(Iw(Pw(zu(a)),{select:!0}),document.activeElement===g&&Pn(a))}return()=>{a.removeEventListener(Fi,c),setTimeout(()=>{const y=new CustomEvent(Bi,Bu);a.addEventListener(Bi,d),a.dispatchEvent(y),y.defaultPrevented||Pn(g??document.body,{select:!0}),a.removeEventListener(Bi,d),Uu.remove(f)},0)}}},[a,c,d,f]);const v=h.useCallback(g=>{if(!n&&!r||f.paused)return;const x=g.key==="Tab"&&!g.altKey&&!g.ctrlKey&&!g.metaKey,y=document.activeElement;if(x&&y){const w=g.currentTarget,[S,k]=Nw(w);S&&k?!g.shiftKey&&y===k?(g.preventDefault(),n&&Pn(S,{select:!0})):g.shiftKey&&y===S&&(g.preventDefault(),n&&Pn(k,{select:!0})):y===w&&g.preventDefault()}},[n,r,f.paused]);return u.jsx(be.div,{tabIndex:-1,...i,ref:m,onKeyDown:v})});qo.displayName=Ew;function Iw(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Pn(r,{select:t}),document.activeElement!==n)return}function Nw(e){const t=zu(e),n=Hu(t,e),r=Hu(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 Hu(e,t){for(const n of e)if(!Aw(n,{upTo:t}))return n}function Aw(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 jw(e){return e instanceof HTMLInputElement&&"select"in e}function Pn(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&jw(e)&&t&&e.select()}}var Uu=_w();function _w(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=Wu(e,t),e.unshift(t)},remove(t){var n;e=Wu(e,t),(n=e[0])==null||n.resume()}}}function Wu(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Pw(e){return e.filter(t=>t.tagName!=="A")}var Mw=h[" useId ".trim().toString()]||(()=>{}),Rw=0;function Nt(e){const[t,n]=h.useState(Mw());return kt(()=>{n(r=>r??String(Rw++))},[e]),t?`radix-${t}`:""}const Ow=["top","right","bottom","left"],Mn=Math.min,Gt=Math.max,Go=Math.round,Yo=Math.floor,gn=e=>({x:e,y:e}),Dw={left:"right",right:"left",bottom:"top",top:"bottom"},Lw={start:"end",end:"start"};function zi(e,t,n){return Gt(e,Mn(t,n))}function kn(e,t){return typeof e=="function"?e(t):e}function En(e){return e.split("-")[0]}function xr(e){return e.split("-")[1]}function Hi(e){return e==="x"?"y":"x"}function Ui(e){return e==="y"?"height":"width"}const $w=new Set(["top","bottom"]);function xn(e){return $w.has(En(e))?"y":"x"}function Wi(e){return Hi(xn(e))}function Fw(e,t,n){n===void 0&&(n=!1);const r=xr(e),o=Wi(e),s=Ui(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=Xo(i)),[i,Xo(i)]}function Bw(e){const t=Xo(e);return[Vi(e),t,Vi(t)]}function Vi(e){return e.replace(/start|end/g,t=>Lw[t])}const Vu=["left","right"],Ku=["right","left"],zw=["top","bottom"],Hw=["bottom","top"];function Uw(e,t,n){switch(e){case"top":case"bottom":return n?t?Ku:Vu:t?Vu:Ku;case"left":case"right":return t?zw:Hw;default:return[]}}function Ww(e,t,n,r){const o=xr(e);let s=Uw(En(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(Vi)))),s}function Xo(e){return e.replace(/left|right|bottom|top/g,t=>Dw[t])}function Vw(e){return{top:0,right:0,bottom:0,left:0,...e}}function qu(e){return typeof e!="number"?Vw(e):{top:e,right:e,bottom:e,left:e}}function Jo(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 Gu(e,t,n){let{reference:r,floating:o}=e;const s=xn(t),i=Wi(t),a=Ui(i),l=En(t),c=s==="y",d=r.x+r.width/2-o.width/2,p=r.y+r.height/2-o.height/2,m=r[a]/2-o[a]/2;let f;switch(l){case"top":f={x:d,y:r.y-o.height};break;case"bottom":f={x:d,y:r.y+r.height};break;case"right":f={x:r.x+r.width,y:p};break;case"left":f={x:r.x-o.width,y:p};break;default:f={x:r.x,y:r.y}}switch(xr(t)){case"start":f[i]-=m*(n&&c?-1:1);break;case"end":f[i]+=m*(n&&c?-1:1);break}return f}const Kw=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=n,a=s.filter(Boolean),l=await(i.isRTL==null?void 0:i.isRTL(t));let c=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:d,y:p}=Gu(c,r,l),m=r,f={},v=0;for(let g=0;g<a.length;g++){const{name:x,fn:y}=a[g],{x:w,y:S,data:k,reset:C}=await y({x:d,y:p,initialPlacement:r,placement:m,strategy:o,middlewareData:f,rects:c,platform:i,elements:{reference:e,floating:t}});d=w??d,p=S??p,f={...f,[x]:{...f[x],...k}},C&&v<=50&&(v++,typeof C=="object"&&(C.placement&&(m=C.placement),C.rects&&(c=C.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):C.rects),{x:d,y:p}=Gu(c,m,l)),g=-1)}return{x:d,y:p,placement:m,strategy:o,middlewareData:f}};async function Jr(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:i,elements:a,strategy:l}=e,{boundary:c="clippingAncestors",rootBoundary:d="viewport",elementContext:p="floating",altBoundary:m=!1,padding:f=0}=kn(t,e),v=qu(f),x=a[m?p==="floating"?"reference":"floating":p],y=Jo(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(x)))==null||n?x:x.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:c,rootBoundary:d,strategy:l})),w=p==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,S=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),k=await(s.isElement==null?void 0:s.isElement(S))?await(s.getScale==null?void 0:s.getScale(S))||{x:1,y:1}:{x:1,y:1},C=Jo(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:w,offsetParent:S,strategy:l}):w);return{top:(y.top-C.top+v.top)/k.y,bottom:(C.bottom-y.bottom+v.bottom)/k.y,left:(y.left-C.left+v.left)/k.x,right:(C.right-y.right+v.right)/k.x}}const qw=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:s,platform:i,elements:a,middlewareData:l}=t,{element:c,padding:d=0}=kn(e,t)||{};if(c==null)return{};const p=qu(d),m={x:n,y:r},f=Wi(o),v=Ui(f),g=await i.getDimensions(c),x=f==="y",y=x?"top":"left",w=x?"bottom":"right",S=x?"clientHeight":"clientWidth",k=s.reference[v]+s.reference[f]-m[f]-s.floating[v],C=m[f]-s.reference[f],T=await(i.getOffsetParent==null?void 0:i.getOffsetParent(c));let E=T?T[S]:0;(!E||!await(i.isElement==null?void 0:i.isElement(T)))&&(E=a.floating[S]||s.floating[v]);const _=k/2-C/2,R=E/2-g[v]/2-1,L=Mn(p[y],R),H=Mn(p[w],R),K=L,B=E-g[v]-H,I=E/2-g[v]/2+_,W=zi(K,I,B),N=!l.arrow&&xr(o)!=null&&I!==W&&s.reference[v]/2-(I<K?L:H)-g[v]/2<0,U=N?I<K?I-K:I-B:0;return{[f]:m[f]+U,data:{[f]:W,centerOffset:I-W-U,...N&&{alignmentOffset:U}},reset:N}}}),Gw=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:s,rects:i,initialPlacement:a,platform:l,elements:c}=t,{mainAxis:d=!0,crossAxis:p=!0,fallbackPlacements:m,fallbackStrategy:f="bestFit",fallbackAxisSideDirection:v="none",flipAlignment:g=!0,...x}=kn(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const y=En(o),w=xn(a),S=En(a)===a,k=await(l.isRTL==null?void 0:l.isRTL(c.floating)),C=m||(S||!g?[Xo(a)]:Bw(a)),T=v!=="none";!m&&T&&C.push(...Ww(a,g,v,k));const E=[a,...C],_=await Jr(t,x),R=[];let L=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&R.push(_[y]),p){const I=Fw(o,i,k);R.push(_[I[0]],_[I[1]])}if(L=[...L,{placement:o,overflows:R}],!R.every(I=>I<=0)){var H,K;const I=(((H=s.flip)==null?void 0:H.index)||0)+1,W=E[I];if(W&&(!(p==="alignment"?w!==xn(W):!1)||L.every(O=>xn(O.placement)===w?O.overflows[0]>0:!0)))return{data:{index:I,overflows:L},reset:{placement:W}};let N=(K=L.filter(U=>U.overflows[0]<=0).sort((U,O)=>U.overflows[1]-O.overflows[1])[0])==null?void 0:K.placement;if(!N)switch(f){case"bestFit":{var B;const U=(B=L.filter(O=>{if(T){const j=xn(O.placement);return j===w||j==="y"}return!0}).map(O=>[O.placement,O.overflows.filter(j=>j>0).reduce((j,q)=>j+q,0)]).sort((O,j)=>O[1]-j[1])[0])==null?void 0:B[0];U&&(N=U);break}case"initialPlacement":N=a;break}if(o!==N)return{reset:{placement:N}}}return{}}}};function Yu(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Xu(e){return Ow.some(t=>e[t]>=0)}const Yw=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=kn(e,t);switch(r){case"referenceHidden":{const s=await Jr(t,{...o,elementContext:"reference"}),i=Yu(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:Xu(i)}}}case"escaped":{const s=await Jr(t,{...o,altBoundary:!0}),i=Yu(s,n.floating);return{data:{escapedOffsets:i,escaped:Xu(i)}}}default:return{}}}}},Ju=new Set(["left","top"]);async function Xw(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=En(n),a=xr(n),l=xn(n)==="y",c=Ju.has(i)?-1:1,d=s&&l?-1:1,p=kn(t,e);let{mainAxis:m,crossAxis:f,alignmentAxis:v}=typeof p=="number"?{mainAxis:p,crossAxis:0,alignmentAxis:null}:{mainAxis:p.mainAxis||0,crossAxis:p.crossAxis||0,alignmentAxis:p.alignmentAxis};return a&&typeof v=="number"&&(f=a==="end"?v*-1:v),l?{x:f*d,y:m*c}:{x:m*c,y:f*d}}const Jw=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:s,placement:i,middlewareData:a}=t,l=await Xw(t,e);return i===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:o+l.x,y:s+l.y,data:{...l,placement:i}}}}},Zw=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o}=t,{mainAxis:s=!0,crossAxis:i=!1,limiter:a={fn:x=>{let{x:y,y:w}=x;return{x:y,y:w}}},...l}=kn(e,t),c={x:n,y:r},d=await Jr(t,l),p=xn(En(o)),m=Hi(p);let f=c[m],v=c[p];if(s){const x=m==="y"?"top":"left",y=m==="y"?"bottom":"right",w=f+d[x],S=f-d[y];f=zi(w,f,S)}if(i){const x=p==="y"?"top":"left",y=p==="y"?"bottom":"right",w=v+d[x],S=v-d[y];v=zi(w,v,S)}const g=a.fn({...t,[m]:f,[p]:v});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[m]:s,[p]:i}}}}}},Qw=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:s,middlewareData:i}=t,{offset:a=0,mainAxis:l=!0,crossAxis:c=!0}=kn(e,t),d={x:n,y:r},p=xn(o),m=Hi(p);let f=d[m],v=d[p];const g=kn(a,t),x=typeof g=="number"?{mainAxis:g,crossAxis:0}:{mainAxis:0,crossAxis:0,...g};if(l){const S=m==="y"?"height":"width",k=s.reference[m]-s.floating[S]+x.mainAxis,C=s.reference[m]+s.reference[S]-x.mainAxis;f<k?f=k:f>C&&(f=C)}if(c){var y,w;const S=m==="y"?"width":"height",k=Ju.has(En(o)),C=s.reference[p]-s.floating[S]+(k&&((y=i.offset)==null?void 0:y[p])||0)+(k?0:x.crossAxis),T=s.reference[p]+s.reference[S]+(k?0:((w=i.offset)==null?void 0:w[p])||0)-(k?x.crossAxis:0);v<C?v=C:v>T&&(v=T)}return{[m]:f,[p]:v}}}},eb=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:s,platform:i,elements:a}=t,{apply:l=()=>{},...c}=kn(e,t),d=await Jr(t,c),p=En(o),m=xr(o),f=xn(o)==="y",{width:v,height:g}=s.floating;let x,y;p==="top"||p==="bottom"?(x=p,y=m===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(y=p,x=m==="end"?"top":"bottom");const w=g-d.top-d.bottom,S=v-d.left-d.right,k=Mn(g-d[x],w),C=Mn(v-d[y],S),T=!t.middlewareData.shift;let E=k,_=C;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(_=S),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(E=w),T&&!m){const L=Gt(d.left,0),H=Gt(d.right,0),K=Gt(d.top,0),B=Gt(d.bottom,0);f?_=v-2*(L!==0||H!==0?L+H:Gt(d.left,d.right)):E=g-2*(K!==0||B!==0?K+B:Gt(d.top,d.bottom))}await l({...t,availableWidth:_,availableHeight:E});const R=await i.getDimensions(a.floating);return v!==R.width||g!==R.height?{reset:{rects:!0}}:{}}}};function Zo(){return typeof window<"u"}function vr(e){return Zu(e)?(e.nodeName||"").toLowerCase():"#document"}function Yt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function vn(e){var t;return(t=(Zu(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Zu(e){return Zo()?e instanceof Node||e instanceof Yt(e).Node:!1}function an(e){return Zo()?e instanceof Element||e instanceof Yt(e).Element:!1}function wn(e){return Zo()?e instanceof HTMLElement||e instanceof Yt(e).HTMLElement:!1}function Qu(e){return!Zo()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Yt(e).ShadowRoot}const tb=new Set(["inline","contents"]);function Zr(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=ln(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!tb.has(o)}const nb=new Set(["table","td","th"]);function rb(e){return nb.has(vr(e))}const ob=[":popover-open",":modal"];function Qo(e){return ob.some(t=>{try{return e.matches(t)}catch{return!1}})}const sb=["transform","translate","scale","rotate","perspective"],ib=["transform","translate","scale","rotate","perspective","filter"],ab=["paint","layout","strict","content"];function Ki(e){const t=qi(),n=an(e)?ln(e):e;return sb.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)||ib.some(r=>(n.willChange||"").includes(r))||ab.some(r=>(n.contain||"").includes(r))}function lb(e){let t=Rn(e);for(;wn(t)&&!wr(t);){if(Ki(t))return t;if(Qo(t))return null;t=Rn(t)}return null}function qi(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const cb=new Set(["html","body","#document"]);function wr(e){return cb.has(vr(e))}function ln(e){return Yt(e).getComputedStyle(e)}function es(e){return an(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Rn(e){if(vr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Qu(e)&&e.host||vn(e);return Qu(t)?t.host:t}function ed(e){const t=Rn(e);return wr(t)?e.ownerDocument?e.ownerDocument.body:e.body:wn(t)&&Zr(t)?t:ed(t)}function Qr(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=ed(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Yt(o);if(s){const a=Gi(i);return t.concat(i,i.visualViewport||[],Zr(o)?o:[],a&&n?Qr(a):[])}return t.concat(o,Qr(o,[],n))}function Gi(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function td(e){const t=ln(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=wn(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=Go(n)!==s||Go(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function Yi(e){return an(e)?e:e.contextElement}function br(e){const t=Yi(e);if(!wn(t))return gn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=td(t);let i=(s?Go(n.width):n.width)/r,a=(s?Go(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const ub=gn(0);function nd(e){const t=Yt(e);return!qi()||!t.visualViewport?ub:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function db(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Yt(e)?!1:t}function Yn(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=Yi(e);let i=gn(1);t&&(r?an(r)&&(i=br(r)):i=br(e));const a=db(s,n,r)?nd(s):gn(0);let l=(o.left+a.x)/i.x,c=(o.top+a.y)/i.y,d=o.width/i.x,p=o.height/i.y;if(s){const m=Yt(s),f=r&&an(r)?Yt(r):r;let v=m,g=Gi(v);for(;g&&r&&f!==v;){const x=br(g),y=g.getBoundingClientRect(),w=ln(g),S=y.left+(g.clientLeft+parseFloat(w.paddingLeft))*x.x,k=y.top+(g.clientTop+parseFloat(w.paddingTop))*x.y;l*=x.x,c*=x.y,d*=x.x,p*=x.y,l+=S,c+=k,v=Yt(g),g=Gi(v)}}return Jo({width:d,height:p,x:l,y:c})}function ts(e,t){const n=es(e).scrollLeft;return t?t.left+n:Yn(vn(e)).left+n}function rd(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-ts(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function fb(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=vn(r),a=t?Qo(t.floating):!1;if(r===i||a&&s)return n;let l={scrollLeft:0,scrollTop:0},c=gn(1);const d=gn(0),p=wn(r);if((p||!p&&!s)&&((vr(r)!=="body"||Zr(i))&&(l=es(r)),wn(r))){const f=Yn(r);c=br(r),d.x=f.x+r.clientLeft,d.y=f.y+r.clientTop}const m=i&&!p&&!s?rd(i,l):gn(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+d.x+m.x,y:n.y*c.y-l.scrollTop*c.y+d.y+m.y}}function pb(e){return Array.from(e.getClientRects())}function hb(e){const t=vn(e),n=es(e),r=e.ownerDocument.body,o=Gt(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Gt(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+ts(e);const a=-n.scrollTop;return ln(r).direction==="rtl"&&(i+=Gt(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const od=25;function mb(e,t){const n=Yt(e),r=vn(e),o=n.visualViewport;let s=r.clientWidth,i=r.clientHeight,a=0,l=0;if(o){s=o.width,i=o.height;const d=qi();(!d||d&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}const c=ts(r);if(c<=0){const d=r.ownerDocument,p=d.body,m=getComputedStyle(p),f=d.compatMode==="CSS1Compat"&&parseFloat(m.marginLeft)+parseFloat(m.marginRight)||0,v=Math.abs(r.clientWidth-p.clientWidth-f);v<=od&&(s-=v)}else c<=od&&(s+=c);return{width:s,height:i,x:a,y:l}}const gb=new Set(["absolute","fixed"]);function xb(e,t){const n=Yn(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=wn(e)?br(e):gn(1),i=e.clientWidth*s.x,a=e.clientHeight*s.y,l=o*s.x,c=r*s.y;return{width:i,height:a,x:l,y:c}}function sd(e,t,n){let r;if(t==="viewport")r=mb(e,n);else if(t==="document")r=hb(vn(e));else if(an(t))r=xb(t,n);else{const o=nd(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Jo(r)}function id(e,t){const n=Rn(e);return n===t||!an(n)||wr(n)?!1:ln(n).position==="fixed"||id(n,t)}function vb(e,t){const n=t.get(e);if(n)return n;let r=Qr(e,[],!1).filter(a=>an(a)&&vr(a)!=="body"),o=null;const s=ln(e).position==="fixed";let i=s?Rn(e):e;for(;an(i)&&!wr(i);){const a=ln(i),l=Ki(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&gb.has(o.position)||Zr(i)&&!l&&id(e,i))?r=r.filter(d=>d!==i):o=a,i=Rn(i)}return t.set(e,r),r}function wb(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?Qo(t)?[]:vb(t,this._c):[].concat(n),r],a=i[0],l=i.reduce((c,d)=>{const p=sd(t,d,o);return c.top=Gt(p.top,c.top),c.right=Mn(p.right,c.right),c.bottom=Mn(p.bottom,c.bottom),c.left=Gt(p.left,c.left),c},sd(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function bb(e){const{width:t,height:n}=td(e);return{width:t,height:n}}function yb(e,t,n){const r=wn(t),o=vn(t),s=n==="fixed",i=Yn(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=gn(0);function c(){l.x=ts(o)}if(r||!r&&!s)if((vr(t)!=="body"||Zr(o))&&(a=es(t)),r){const f=Yn(t,!0,s,t);l.x=f.x+t.clientLeft,l.y=f.y+t.clientTop}else o&&c();s&&!r&&o&&c();const d=o&&!r&&!s?rd(o,a):gn(0),p=i.left+a.scrollLeft-l.x-d.x,m=i.top+a.scrollTop-l.y-d.y;return{x:p,y:m,width:i.width,height:i.height}}function Xi(e){return ln(e).position==="static"}function ad(e,t){if(!wn(e)||ln(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return vn(e)===n&&(n=n.ownerDocument.body),n}function ld(e,t){const n=Yt(e);if(Qo(e))return n;if(!wn(e)){let o=Rn(e);for(;o&&!wr(o);){if(an(o)&&!Xi(o))return o;o=Rn(o)}return n}let r=ad(e,t);for(;r&&rb(r)&&Xi(r);)r=ad(r,t);return r&&wr(r)&&Xi(r)&&!Ki(r)?n:r||lb(e)||n}const Sb=async function(e){const t=this.getOffsetParent||ld,n=this.getDimensions,r=await n(e.floating);return{reference:yb(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Cb(e){return ln(e).direction==="rtl"}const Tb={convertOffsetParentRelativeRectToViewportRelativeRect:fb,getDocumentElement:vn,getClippingRect:wb,getOffsetParent:ld,getElementRects:Sb,getClientRects:pb,getDimensions:bb,getScale:br,isElement:an,isRTL:Cb};function cd(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function kb(e,t){let n=null,r;const o=vn(e);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),s();const c=e.getBoundingClientRect(),{left:d,top:p,width:m,height:f}=c;if(a||t(),!m||!f)return;const v=Yo(p),g=Yo(o.clientWidth-(d+m)),x=Yo(o.clientHeight-(p+f)),y=Yo(d),S={rootMargin:-v+"px "+-g+"px "+-x+"px "+-y+"px",threshold:Gt(0,Mn(1,l))||1};let k=!0;function C(T){const E=T[0].intersectionRatio;if(E!==l){if(!k)return i();E?i(!1,E):r=setTimeout(()=>{i(!1,1e-7)},1e3)}E===1&&!cd(c,e.getBoundingClientRect())&&i(),k=!1}try{n=new IntersectionObserver(C,{...S,root:o.ownerDocument})}catch{n=new IntersectionObserver(C,S)}n.observe(e)}return i(!0),s}function Eb(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,c=Yi(e),d=o||s?[...c?Qr(c):[],...Qr(t)]:[];d.forEach(y=>{o&&y.addEventListener("scroll",n,{passive:!0}),s&&y.addEventListener("resize",n)});const p=c&&a?kb(c,n):null;let m=-1,f=null;i&&(f=new ResizeObserver(y=>{let[w]=y;w&&w.target===c&&f&&(f.unobserve(t),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var S;(S=f)==null||S.observe(t)})),n()}),c&&!l&&f.observe(c),f.observe(t));let v,g=l?Yn(e):null;l&&x();function x(){const y=Yn(e);g&&!cd(g,y)&&n(),g=y,v=requestAnimationFrame(x)}return n(),()=>{var y;d.forEach(w=>{o&&w.removeEventListener("scroll",n),s&&w.removeEventListener("resize",n)}),p==null||p(),(y=f)==null||y.disconnect(),f=null,l&&cancelAnimationFrame(v)}}const Ib=Jw,Nb=Zw,Ab=Gw,jb=eb,_b=Yw,ud=qw,Pb=Qw,Mb=(e,t,n)=>{const r=new Map,o={platform:Tb,...n},s={...o.platform,_c:r};return Kw(e,t,{...o,platform:s})};var Rb=typeof document<"u",Ob=function(){},ns=Rb?b.useLayoutEffect:Ob;function rs(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(!rs(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)&&!rs(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function dd(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function fd(e,t){const n=dd(e);return Math.round(t*n)/n}function Ji(e){const t=h.useRef(e);return ns(()=>{t.current=e}),t}function Db(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:i}={},transform:a=!0,whileElementsMounted:l,open:c}=e,[d,p]=h.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[m,f]=h.useState(r);rs(m,r)||f(r);const[v,g]=h.useState(null),[x,y]=h.useState(null),w=h.useCallback(O=>{O!==T.current&&(T.current=O,g(O))},[]),S=h.useCallback(O=>{O!==E.current&&(E.current=O,y(O))},[]),k=s||v,C=i||x,T=h.useRef(null),E=h.useRef(null),_=h.useRef(d),R=l!=null,L=Ji(l),H=Ji(o),K=Ji(c),B=h.useCallback(()=>{if(!T.current||!E.current)return;const O={placement:t,strategy:n,middleware:m};H.current&&(O.platform=H.current),Mb(T.current,E.current,O).then(j=>{const q={...j,isPositioned:K.current!==!1};I.current&&!rs(_.current,q)&&(_.current=q,Lr.flushSync(()=>{p(q)}))})},[m,t,n,H,K]);ns(()=>{c===!1&&_.current.isPositioned&&(_.current.isPositioned=!1,p(O=>({...O,isPositioned:!1})))},[c]);const I=h.useRef(!1);ns(()=>(I.current=!0,()=>{I.current=!1}),[]),ns(()=>{if(k&&(T.current=k),C&&(E.current=C),k&&C){if(L.current)return L.current(k,C,B);B()}},[k,C,B,L,R]);const W=h.useMemo(()=>({reference:T,floating:E,setReference:w,setFloating:S}),[w,S]),N=h.useMemo(()=>({reference:k,floating:C}),[k,C]),U=h.useMemo(()=>{const O={position:n,left:0,top:0};if(!N.floating)return O;const j=fd(N.floating,d.x),q=fd(N.floating,d.y);return a?{...O,transform:"translate("+j+"px, "+q+"px)",...dd(N.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:j,top:q}},[n,a,N.floating,d.x,d.y]);return h.useMemo(()=>({...d,update:B,refs:W,elements:N,floatingStyles:U}),[d,B,W,N,U])}const Lb=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?ud({element:r.current,padding:o}).fn(n):{}:r?ud({element:r,padding:o}).fn(n):{}}}},$b=(e,t)=>({...Ib(e),options:[e,t]}),Fb=(e,t)=>({...Nb(e),options:[e,t]}),Bb=(e,t)=>({...Pb(e),options:[e,t]}),zb=(e,t)=>({...Ab(e),options:[e,t]}),Hb=(e,t)=>({...jb(e),options:[e,t]}),Ub=(e,t)=>({..._b(e),options:[e,t]}),Wb=(e,t)=>({...Lb(e),options:[e,t]});var Vb="Arrow",pd=h.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return u.jsx(be.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"})})});pd.displayName=Vb;var Kb=pd;function hd(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 l=s.borderBoxSize,c=Array.isArray(l)?l[0]:l;i=c.inlineSize,a=c.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var Zi="Popper",[md,yr]=sn(Zi),[qb,gd]=md(Zi),xd=e=>{const{__scopePopper:t,children:n}=e,[r,o]=h.useState(null);return u.jsx(qb,{scope:t,anchor:r,onAnchorChange:o,children:n})};xd.displayName=Zi;var vd="PopperAnchor",wd=h.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=gd(vd,n),i=h.useRef(null),a=De(t,i),l=h.useRef(null);return h.useEffect(()=>{const c=l.current;l.current=(r==null?void 0:r.current)||i.current,c!==l.current&&s.onAnchorChange(l.current)}),r?null:u.jsx(be.div,{...o,ref:a})});wd.displayName=vd;var Qi="PopperContent",[Gb,Yb]=md(Qi),bd=h.forwardRef((e,t)=>{var V,D,X,Q,ae,$;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:a=0,avoidCollisions:l=!0,collisionBoundary:c=[],collisionPadding:d=0,sticky:p="partial",hideWhenDetached:m=!1,updatePositionStrategy:f="optimized",onPlaced:v,...g}=e,x=gd(Qi,n),[y,w]=h.useState(null),S=De(t,re=>w(re)),[k,C]=h.useState(null),T=hd(k),E=(T==null?void 0:T.width)??0,_=(T==null?void 0:T.height)??0,R=r+(s!=="center"?"-"+s:""),L=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},H=Array.isArray(c)?c:[c],K=H.length>0,B={padding:L,boundary:H.filter(Jb),altBoundary:K},{refs:I,floatingStyles:W,placement:N,isPositioned:U,middlewareData:O}=Db({strategy:"fixed",placement:R,whileElementsMounted:(...re)=>Eb(...re,{animationFrame:f==="always"}),elements:{reference:x.anchor},middleware:[$b({mainAxis:o+_,alignmentAxis:i}),l&&Fb({mainAxis:!0,crossAxis:!1,limiter:p==="partial"?Bb():void 0,...B}),l&&zb({...B}),Hb({...B,apply:({elements:re,rects:we,availableWidth:de,availableHeight:xe})=>{const{width:Ee,height:Be}=we.reference,We=re.floating.style;We.setProperty("--radix-popper-available-width",`${de}px`),We.setProperty("--radix-popper-available-height",`${xe}px`),We.setProperty("--radix-popper-anchor-width",`${Ee}px`),We.setProperty("--radix-popper-anchor-height",`${Be}px`)}}),k&&Wb({element:k,padding:a}),Zb({arrowWidth:E,arrowHeight:_}),m&&Ub({strategy:"referenceHidden",...B})]}),[j,q]=Cd(N),J=mt(v);kt(()=>{U&&(J==null||J())},[U,J]);const P=(V=O.arrow)==null?void 0:V.x,M=(D=O.arrow)==null?void 0:D.y,G=((X=O.arrow)==null?void 0:X.centerOffset)!==0,[Z,se]=h.useState();return kt(()=>{y&&se(window.getComputedStyle(y).zIndex)},[y]),u.jsx("div",{ref:I.setFloating,"data-radix-popper-content-wrapper":"",style:{...W,transform:U?W.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Z,"--radix-popper-transform-origin":[(Q=O.transformOrigin)==null?void 0:Q.x,(ae=O.transformOrigin)==null?void 0:ae.y].join(" "),...(($=O.hide)==null?void 0:$.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:u.jsx(Gb,{scope:n,placedSide:j,onArrowChange:C,arrowX:P,arrowY:M,shouldHideArrow:G,children:u.jsx(be.div,{"data-side":j,"data-align":q,...g,ref:S,style:{...g.style,animation:U?void 0:"none"}})})})});bd.displayName=Qi;var yd="PopperArrow",Xb={top:"bottom",right:"left",bottom:"top",left:"right"},Sd=h.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=Yb(yd,r),i=Xb[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(Kb,{...o,ref:n,style:{...o.style,display:"block"}})})});Sd.displayName=yd;function Jb(e){return e!==null}var Zb=e=>({name:"transformOrigin",options:e,fn(t){var x,y,w;const{placement:n,rects:r,middlewareData:o}=t,i=((x=o.arrow)==null?void 0:x.centerOffset)!==0,a=i?0:e.arrowWidth,l=i?0:e.arrowHeight,[c,d]=Cd(n),p={start:"0%",center:"50%",end:"100%"}[d],m=(((y=o.arrow)==null?void 0:y.x)??0)+a/2,f=(((w=o.arrow)==null?void 0:w.y)??0)+l/2;let v="",g="";return c==="bottom"?(v=i?p:`${m}px`,g=`${-l}px`):c==="top"?(v=i?p:`${m}px`,g=`${r.floating.height+l}px`):c==="right"?(v=`${-l}px`,g=i?p:`${f}px`):c==="left"&&(v=`${r.floating.width+l}px`,g=i?p:`${f}px`),{data:{x:v,y:g}}}});function Cd(e){const[t,n="center"]=e.split("-");return[t,n]}var ea=xd,ta=wd,na=bd,ra=Sd,Qb="Portal",eo=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?No.createPortal(u.jsx(be.div,{...r,ref:t}),i):null});eo.displayName=Qb;function ey(e,t){return h.useReducer((n,r)=>t[n][r]??n,e)}var Ft=e=>{const{present:t,children:n}=e,r=ty(t),o=typeof n=="function"?n({present:r.isPresent}):h.Children.only(n),s=De(r.ref,ny(o));return typeof n=="function"||r.isPresent?h.cloneElement(o,{ref:s}):null};Ft.displayName="Presence";function ty(e){const[t,n]=h.useState(),r=h.useRef(null),o=h.useRef(e),s=h.useRef("none"),i=e?"mounted":"unmounted",[a,l]=ey(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return h.useEffect(()=>{const c=os(r.current);s.current=a==="mounted"?c:"none"},[a]),kt(()=>{const c=r.current,d=o.current;if(d!==e){const m=s.current,f=os(c);e?l("MOUNT"):f==="none"||(c==null?void 0:c.display)==="none"?l("UNMOUNT"):l(d&&m!==f?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,l]),kt(()=>{if(t){let c;const d=t.ownerDocument.defaultView??window,p=f=>{const g=os(r.current).includes(CSS.escape(f.animationName));if(f.target===t&&g&&(l("ANIMATION_END"),!o.current)){const x=t.style.animationFillMode;t.style.animationFillMode="forwards",c=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=x)})}},m=f=>{f.target===t&&(s.current=os(r.current))};return t.addEventListener("animationstart",m),t.addEventListener("animationcancel",p),t.addEventListener("animationend",p),()=>{d.clearTimeout(c),t.removeEventListener("animationstart",m),t.removeEventListener("animationcancel",p),t.removeEventListener("animationend",p)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:h.useCallback(c=>{r.current=c?getComputedStyle(c):null,n(c)},[])}}function os(e){return(e==null?void 0:e.animationName)||"none"}function ny(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 oa="rovingFocusGroup.onEntryFocus",ry={bubbles:!1,cancelable:!0},to="RovingFocusGroup",[sa,Td,oy]=Vo(to),[sy,kd]=sn(to,[oy]),[iy,ay]=sy(to),Ed=h.forwardRef((e,t)=>u.jsx(sa.Provider,{scope:e.__scopeRovingFocusGroup,children:u.jsx(sa.Slot,{scope:e.__scopeRovingFocusGroup,children:u.jsx(ly,{...e,ref:t})})}));Ed.displayName=to;var ly=h.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:c,preventScrollOnEntryFocus:d=!1,...p}=e,m=h.useRef(null),f=De(t,m),v=Ko(s),[g,x]=_n({prop:i,defaultProp:a??null,onChange:l,caller:to}),[y,w]=h.useState(!1),S=mt(c),k=Td(n),C=h.useRef(!1),[T,E]=h.useState(0);return h.useEffect(()=>{const _=m.current;if(_)return _.addEventListener(oa,S),()=>_.removeEventListener(oa,S)},[S]),u.jsx(iy,{scope:n,orientation:r,dir:v,loop:o,currentTabStopId:g,onItemFocus:h.useCallback(_=>x(_),[x]),onItemShiftTab:h.useCallback(()=>w(!0),[]),onFocusableItemAdd:h.useCallback(()=>E(_=>_+1),[]),onFocusableItemRemove:h.useCallback(()=>E(_=>_-1),[]),children:u.jsx(be.div,{tabIndex:y||T===0?-1:0,"data-orientation":r,...p,ref:f,style:{outline:"none",...e.style},onMouseDown:ie(e.onMouseDown,()=>{C.current=!0}),onFocus:ie(e.onFocus,_=>{const R=!C.current;if(_.target===_.currentTarget&&R&&!y){const L=new CustomEvent(oa,ry);if(_.currentTarget.dispatchEvent(L),!L.defaultPrevented){const H=k().filter(N=>N.focusable),K=H.find(N=>N.active),B=H.find(N=>N.id===g),W=[K,B,...H].filter(Boolean).map(N=>N.ref.current);Ad(W,d)}}C.current=!1}),onBlur:ie(e.onBlur,()=>w(!1))})})}),Id="RovingFocusGroupItem",Nd=h.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,l=Nt(),c=s||l,d=ay(Id,n),p=d.currentTabStopId===c,m=Td(n),{onFocusableItemAdd:f,onFocusableItemRemove:v,currentTabStopId:g}=d;return h.useEffect(()=>{if(r)return f(),()=>v()},[r,f,v]),u.jsx(sa.ItemSlot,{scope:n,id:c,focusable:r,active:o,children:u.jsx(be.span,{tabIndex:p?0:-1,"data-orientation":d.orientation,...a,ref:t,onMouseDown:ie(e.onMouseDown,x=>{r?d.onItemFocus(c):x.preventDefault()}),onFocus:ie(e.onFocus,()=>d.onItemFocus(c)),onKeyDown:ie(e.onKeyDown,x=>{if(x.key==="Tab"&&x.shiftKey){d.onItemShiftTab();return}if(x.target!==x.currentTarget)return;const y=dy(x,d.orientation,d.dir);if(y!==void 0){if(x.metaKey||x.ctrlKey||x.altKey||x.shiftKey)return;x.preventDefault();let S=m().filter(k=>k.focusable).map(k=>k.ref.current);if(y==="last")S.reverse();else if(y==="prev"||y==="next"){y==="prev"&&S.reverse();const k=S.indexOf(x.currentTarget);S=d.loop?fy(S,k+1):S.slice(k+1)}setTimeout(()=>Ad(S))}}),children:typeof i=="function"?i({isCurrentTabStop:p,hasTabStop:g!=null}):i})})});Nd.displayName=Id;var cy={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function uy(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function dy(e,t,n){const r=uy(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return cy[r]}function Ad(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function fy(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var py=Ed,hy=Nd,my=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Sr=new WeakMap,ss=new WeakMap,is={},ia=0,jd=function(e){return e&&(e.host||jd(e.parentNode))},gy=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})},xy=function(e,t,n,r){var o=gy(t,Array.isArray(e)?e:[e]);is[n]||(is[n]=new WeakMap);var s=is[n],i=[],a=new Set,l=new Set(o),c=function(p){!p||a.has(p)||(a.add(p),c(p.parentNode))};o.forEach(c);var d=function(p){!p||l.has(p)||Array.prototype.forEach.call(p.children,function(m){if(a.has(m))d(m);else try{var f=m.getAttribute(r),v=f!==null&&f!=="false",g=(Sr.get(m)||0)+1,x=(s.get(m)||0)+1;Sr.set(m,g),s.set(m,x),i.push(m),g===1&&v&&ss.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(),ia++,function(){i.forEach(function(p){var m=Sr.get(p)-1,f=s.get(p)-1;Sr.set(p,m),s.set(p,f),m||(ss.has(p)||p.removeAttribute(r),ss.delete(p)),f||p.removeAttribute(n)}),ia--,ia||(Sr=new WeakMap,Sr=new WeakMap,ss=new WeakMap,is={})}},aa=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=my(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),xy(r,o,n,"aria-hidden")):function(){return null}},bn=function(){return bn=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},bn.apply(this,arguments)};function _d(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n}function vy(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 as="right-scroll-bar-position",ls="width-before-scroll-bar",wy="with-scroll-bars-hidden",by="--removed-body-scroll-bar-size";function la(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function yy(e,t){var n=b.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var o=n.value;o!==r&&(n.value=r,n.callback(r,o))}}}})[0];return n.callback=t,n.facade}var Sy=typeof window<"u"?h.useLayoutEffect:h.useEffect,Pd=new WeakMap;function Cy(e,t){var n=yy(null,function(r){return e.forEach(function(o){return la(o,r)})});return Sy(function(){var r=Pd.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||la(a,null)}),s.forEach(function(a){o.has(a)||la(a,i)})}Pd.set(n,e)},[e]),n}function Ty(e){return e}function ky(e,t){t===void 0&&(t=Ty);var n=[],r=!1,o={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(s){var i=t(s,r);return n.push(i),function(){n=n.filter(function(a){return a!==i})}},assignSyncMedium:function(s){for(r=!0;n.length;){var i=n;n=[],i.forEach(s)}n={push:function(a){return s(a)},filter:function(){return n}}},assignMedium:function(s){r=!0;var i=[];if(n.length){var a=n;n=[],a.forEach(s),i=n}var l=function(){var d=i;i=[],d.forEach(s)},c=function(){return Promise.resolve().then(l)};c(),n={push:function(d){i.push(d),c()},filter:function(d){return i=i.filter(d),n}}}};return o}function Ey(e){e===void 0&&(e={});var t=ky(null);return t.options=bn({async:!0,ssr:!1},e),t}var Md=function(e){var t=e.sideCar,n=_d(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return h.createElement(r,bn({},n))};Md.isSideCarExport=!0;function Iy(e,t){return e.useMedium(t),Md}var Rd=Ey(),ca=function(){},cs=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,l=e.className,c=e.removeScrollBar,d=e.enabled,p=e.shards,m=e.sideCar,f=e.noRelative,v=e.noIsolation,g=e.inert,x=e.allowPinchZoom,y=e.as,w=y===void 0?"div":y,S=e.gapMode,k=_d(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=m,T=Cy([n,t]),E=bn(bn({},k),o);return h.createElement(h.Fragment,null,d&&h.createElement(C,{sideCar:Rd,removeScrollBar:c,shards:p,noRelative:f,noIsolation:v,inert:g,setCallbacks:s,allowPinchZoom:!!x,lockRef:n,gapMode:S}),i?h.cloneElement(h.Children.only(a),bn(bn({},E),{ref:T})):h.createElement(w,bn({},E,{className:l,ref:T}),a))});cs.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},cs.classNames={fullWidth:ls,zeroRight:as};var Ny=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Ay(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Ny();return t&&e.setAttribute("nonce",t),e}function jy(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function _y(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var Py=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Ay())&&(jy(t,n),_y(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},My=function(){var e=Py();return function(t,n){h.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Od=function(){var e=My(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},Ry={left:0,top:0,right:0,gap:0},ua=function(e){return parseInt(e||"",10)||0},Oy=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[ua(n),ua(r),ua(o)]},Dy=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Ry;var t=Oy(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])}},Ly=Od(),Cr="data-scroll-locked",$y=function(e,t,n,r){var o=e.left,s=e.top,i=e.right,a=e.gap;return n===void 0&&(n="margin"),`
40
+ .`.concat(wy,` {
41
41
  overflow: hidden `).concat(r,`;
42
42
  padding-right: `).concat(a,"px ").concat(r,`;
43
43
  }
@@ -71,19 +71,19 @@ React keys must be passed directly to JSX without using spread:
71
71
  }
72
72
 
73
73
  body[`).concat(Cr,`] {
74
- `).concat(wy,": ").concat(a,`px;
74
+ `).concat(by,": ").concat(a,`px;
75
75
  }
76
- `)},Dd=function(){var e=parseInt(document.body.getAttribute(Cr)||"0",10);return isFinite(e)?e:0},$y=function(){h.useEffect(function(){return document.body.setAttribute(Cr,(Dd()+1).toString()),function(){var e=Dd()-1;e<=0?document.body.removeAttribute(Cr):document.body.setAttribute(Cr,e.toString())}},[])},Fy=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;$y();var s=h.useMemo(function(){return Oy(o)},[o]);return h.createElement(Dy,{styles:Ly(s,!t,o,n?"":"!important")})},da=!1;if(typeof window<"u")try{var us=Object.defineProperty({},"passive",{get:function(){return da=!0,!0}});window.addEventListener("test",us,us),window.removeEventListener("test",us,us)}catch{da=!1}var Tr=da?{passive:!1}:!1,By=function(e){return e.tagName==="TEXTAREA"},Ld=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!By(e)&&n[t]==="visible")},zy=function(e){return Ld(e,"overflowY")},Hy=function(e){return Ld(e,"overflowX")},$d=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=Fd(e,r);if(o){var s=Bd(e,r),i=s[1],a=s[2];if(i>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},Uy=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},Wy=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},Fd=function(e,t){return e==="v"?zy(t):Hy(t)},Bd=function(e,t){return e==="v"?Uy(t):Wy(t)},Vy=function(e,t){return e==="h"&&t==="rtl"?-1:1},Ky=function(e,t,n,r,o){var s=Vy(e,window.getComputedStyle(t).direction),i=s*r,a=n.target,l=t.contains(a),c=!1,d=i>0,p=0,m=0;do{if(!a)break;var f=Bd(e,a),v=f[0],g=f[1],x=f[2],y=g-x-s*v;(v||y)&&Fd(e,a)&&(p+=y,m+=v);var w=a.parentNode;a=w&&w.nodeType===Node.DOCUMENT_FRAGMENT_NODE?w.host:w}while(!l&&a!==document.body||l&&(t.contains(a)||t===a));return(d&&Math.abs(p)<1||!d&&Math.abs(m)<1)&&(c=!0),c},ds=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},zd=function(e){return[e.deltaX,e.deltaY]},Hd=function(e){return e&&"current"in e?e.current:e},qy=function(e,t){return e[0]===t[0]&&e[1]===t[1]},Gy=function(e){return`
76
+ `)},Dd=function(){var e=parseInt(document.body.getAttribute(Cr)||"0",10);return isFinite(e)?e:0},Fy=function(){h.useEffect(function(){return document.body.setAttribute(Cr,(Dd()+1).toString()),function(){var e=Dd()-1;e<=0?document.body.removeAttribute(Cr):document.body.setAttribute(Cr,e.toString())}},[])},By=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;Fy();var s=h.useMemo(function(){return Dy(o)},[o]);return h.createElement(Ly,{styles:$y(s,!t,o,n?"":"!important")})},da=!1;if(typeof window<"u")try{var us=Object.defineProperty({},"passive",{get:function(){return da=!0,!0}});window.addEventListener("test",us,us),window.removeEventListener("test",us,us)}catch{da=!1}var Tr=da?{passive:!1}:!1,zy=function(e){return e.tagName==="TEXTAREA"},Ld=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!zy(e)&&n[t]==="visible")},Hy=function(e){return Ld(e,"overflowY")},Uy=function(e){return Ld(e,"overflowX")},$d=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=Fd(e,r);if(o){var s=Bd(e,r),i=s[1],a=s[2];if(i>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},Wy=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},Vy=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},Fd=function(e,t){return e==="v"?Hy(t):Uy(t)},Bd=function(e,t){return e==="v"?Wy(t):Vy(t)},Ky=function(e,t){return e==="h"&&t==="rtl"?-1:1},qy=function(e,t,n,r,o){var s=Ky(e,window.getComputedStyle(t).direction),i=s*r,a=n.target,l=t.contains(a),c=!1,d=i>0,p=0,m=0;do{if(!a)break;var f=Bd(e,a),v=f[0],g=f[1],x=f[2],y=g-x-s*v;(v||y)&&Fd(e,a)&&(p+=y,m+=v);var w=a.parentNode;a=w&&w.nodeType===Node.DOCUMENT_FRAGMENT_NODE?w.host:w}while(!l&&a!==document.body||l&&(t.contains(a)||t===a));return(d&&Math.abs(p)<1||!d&&Math.abs(m)<1)&&(c=!0),c},ds=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},zd=function(e){return[e.deltaX,e.deltaY]},Hd=function(e){return e&&"current"in e?e.current:e},Gy=function(e,t){return e[0]===t[0]&&e[1]===t[1]},Yy=function(e){return`
77
77
  .block-interactivity-`.concat(e,` {pointer-events: none;}
78
78
  .allow-interactivity-`).concat(e,` {pointer-events: all;}
79
- `)},Yy=0,kr=[];function Xy(e){var t=h.useRef([]),n=h.useRef([0,0]),r=h.useRef(),o=h.useState(Yy++)[0],s=h.useState(Od)[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=xy([e.lockRef.current],(e.shards||[]).map(Hd),!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=ds(g),w=n.current,S="deltaX"in g?g.deltaX:w[0]-y[0],k="deltaY"in g?g.deltaY:w[1]-y[1],C,T=g.target,E=Math.abs(S)>Math.abs(k)?"h":"v";if("touches"in g&&E==="h"&&T.type==="range")return!1;var _=$d(E,T);if(!_)return!0;if(_?C=E:(C=E==="v"?"h":"v",_=$d(E,T)),!_)return!1;if(!r.current&&"changedTouches"in g&&(S||k)&&(r.current=C),!C)return!0;var R=r.current||C;return Ky(R,x,g,R==="h"?S:k)},[]),l=h.useCallback(function(g){var x=g;if(!(!kr.length||kr[kr.length-1]!==s)){var y="deltaY"in x?zd(x):ds(x),w=t.current.filter(function(C){return C.name===x.type&&(C.target===x.target||x.target===C.shadowParent)&&qy(C.delta,y)})[0];if(w&&w.should){x.cancelable&&x.preventDefault();return}if(!w){var S=(i.current.shards||[]).map(Hd).filter(Boolean).filter(function(C){return C.contains(x.target)}),k=S.length>0?a(x,S[0]):!i.current.noIsolation;k&&x.cancelable&&x.preventDefault()}}},[]),c=h.useCallback(function(g,x,y,w){var S={name:g,delta:x,target:y,should:w,shadowParent:Jy(y)};t.current.push(S),setTimeout(function(){t.current=t.current.filter(function(k){return k!==S})},1)},[]),d=h.useCallback(function(g){n.current=ds(g),r.current=void 0},[]),p=h.useCallback(function(g){c(g.type,zd(g),g.target,a(g,e.lockRef.current))},[]),m=h.useCallback(function(g){c(g.type,ds(g),g.target,a(g,e.lockRef.current))},[]);h.useEffect(function(){return kr.push(s),e.setCallbacks({onScrollCapture:p,onWheelCapture:p,onTouchMoveCapture:m}),document.addEventListener("wheel",l,Tr),document.addEventListener("touchmove",l,Tr),document.addEventListener("touchstart",d,Tr),function(){kr=kr.filter(function(g){return g!==s}),document.removeEventListener("wheel",l,Tr),document.removeEventListener("touchmove",l,Tr),document.removeEventListener("touchstart",d,Tr)}},[]);var f=e.removeScrollBar,v=e.inert;return h.createElement(h.Fragment,null,v?h.createElement(s,{styles:Gy(o)}):null,f?h.createElement(Fy,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Jy(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const Zy=Ey(Rd,Xy);var fs=h.forwardRef(function(e,t){return h.createElement(cs,bn({},e,{ref:t,sideCar:Zy}))});fs.classNames=cs.classNames;var fa=["Enter"," "],Qy=["ArrowDown","PageUp","Home"],Ud=["ArrowUp","PageDown","End"],e0=[...Qy,...Ud],t0={ltr:[...fa,"ArrowRight"],rtl:[...fa,"ArrowLeft"]},n0={ltr:["ArrowLeft"],rtl:["ArrowRight"]},no="Menu",[ro,r0,o0]=Vo(no),[Xn,Wd]=sn(no,[o0,yr,kd]),ps=yr(),Vd=kd(),[s0,Jn]=Xn(no),[i0,oo]=Xn(no),Kd=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=ps(t),[l,c]=h.useState(null),d=h.useRef(!1),p=mt(s),m=Ko(o);return h.useEffect(()=>{const f=()=>{d.current=!0,document.addEventListener("pointerdown",v,{capture:!0,once:!0}),document.addEventListener("pointermove",v,{capture:!0,once:!0})},v=()=>d.current=!1;return document.addEventListener("keydown",f,{capture:!0}),()=>{document.removeEventListener("keydown",f,{capture:!0}),document.removeEventListener("pointerdown",v,{capture:!0}),document.removeEventListener("pointermove",v,{capture:!0})}},[]),u.jsx(ea,{...a,children:u.jsx(s0,{scope:t,open:n,onOpenChange:p,content:l,onContentChange:c,children:u.jsx(i0,{scope:t,onClose:h.useCallback(()=>p(!1),[p]),isUsingKeyboardRef:d,dir:m,modal:i,children:r})})})};Kd.displayName=no;var a0="MenuAnchor",pa=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=ps(n);return u.jsx(ta,{...o,...r,ref:t})});pa.displayName=a0;var ha="MenuPortal",[l0,qd]=Xn(ha,{forceMount:void 0}),Gd=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=Jn(ha,t);return u.jsx(l0,{scope:t,forceMount:n,children:u.jsx(Ft,{present:n||s.open,children:u.jsx(eo,{asChild:!0,container:o,children:r})})})};Gd.displayName=ha;var Zt="MenuContent",[c0,ma]=Xn(Zt),Yd=h.forwardRef((e,t)=>{const n=qd(Zt,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=Jn(Zt,e.__scopeMenu),i=oo(Zt,e.__scopeMenu);return u.jsx(ro.Provider,{scope:e.__scopeMenu,children:u.jsx(Ft,{present:r||s.open,children:u.jsx(ro.Slot,{scope:e.__scopeMenu,children:i.modal?u.jsx(u0,{...o,ref:t}):u.jsx(d0,{...o,ref:t})})})})}),u0=h.forwardRef((e,t)=>{const n=Jn(Zt,e.__scopeMenu),r=h.useRef(null),o=De(t,r);return h.useEffect(()=>{const s=r.current;if(s)return aa(s)},[]),u.jsx(ga,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:ie(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),d0=h.forwardRef((e,t)=>{const n=Jn(Zt,e.__scopeMenu);return u.jsx(ga,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),f0=Vt.createSlot("MenuContent.ScrollLock"),ga=h.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:p,onInteractOutside:m,onDismiss:f,disableOutsideScroll:v,...g}=e,x=Jn(Zt,n),y=oo(Zt,n),w=ps(n),S=Vd(n),k=r0(n),[C,T]=h.useState(null),E=h.useRef(null),_=De(t,E,x.onContentChange),R=h.useRef(0),L=h.useRef(""),H=h.useRef(0),K=h.useRef(null),F=h.useRef("right"),I=h.useRef(0),W=v?fs:h.Fragment,N=v?{as:f0,allowPinchZoom:!0}:void 0,U=j=>{var V,D;const q=L.current+j,J=k().filter(X=>!X.disabled),P=document.activeElement,M=(V=J.find(X=>X.ref.current===P))==null?void 0:V.textValue,G=J.map(X=>X.textValue),Z=T0(G,q,M),se=(D=J.find(X=>X.textValue===Z))==null?void 0:D.ref.current;(function X(Q){L.current=Q,window.clearTimeout(R.current),Q!==""&&(R.current=window.setTimeout(()=>X(""),1e3))})(q),se&&setTimeout(()=>se.focus())};h.useEffect(()=>()=>window.clearTimeout(R.current),[]),$i();const O=h.useCallback(j=>{var J,P;return F.current===((J=K.current)==null?void 0:J.side)&&E0(j,(P=K.current)==null?void 0:P.area)},[]);return u.jsx(c0,{scope:n,searchRef:L,onItemEnter:h.useCallback(j=>{O(j)&&j.preventDefault()},[O]),onItemLeave:h.useCallback(j=>{var q;O(j)||((q=E.current)==null||q.focus(),T(null))},[O]),onTriggerLeave:h.useCallback(j=>{O(j)&&j.preventDefault()},[O]),pointerGraceTimerRef:H,onPointerGraceIntentChange:h.useCallback(j=>{K.current=j},[]),children:u.jsx(W,{...N,children:u.jsx(qo,{asChild:!0,trapped:o,onMountAutoFocus:ie(s,j=>{var q;j.preventDefault(),(q=E.current)==null||q.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:u.jsx(gr,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:p,onInteractOutside:m,onDismiss:f,children:u.jsx(fy,{asChild:!0,...S,dir:y.dir,orientation:"vertical",loop:r,currentTabStopId:C,onCurrentTabStopIdChange:T,onEntryFocus:ie(l,j=>{y.isUsingKeyboardRef.current||j.preventDefault()}),preventScrollOnEntryFocus:!0,children:u.jsx(na,{role:"menu","aria-orientation":"vertical","data-state":pf(x.open),"data-radix-menu-content":"",dir:y.dir,...w,...g,ref:_,style:{outline:"none",...g.style},onKeyDown:ie(g.onKeyDown,j=>{const J=j.target.closest("[data-radix-menu-content]")===j.currentTarget,P=j.ctrlKey||j.altKey||j.metaKey,M=j.key.length===1;J&&(j.key==="Tab"&&j.preventDefault(),!P&&M&&U(j.key));const G=E.current;if(j.target!==G||!e0.includes(j.key))return;j.preventDefault();const se=k().filter(V=>!V.disabled).map(V=>V.ref.current);Ud.includes(j.key)&&se.reverse(),S0(se)}),onBlur:ie(e.onBlur,j=>{j.currentTarget.contains(j.target)||(window.clearTimeout(R.current),L.current="")}),onPointerMove:ie(e.onPointerMove,io(j=>{const q=j.target,J=I.current!==j.clientX;if(j.currentTarget.contains(q)&&J){const P=j.clientX>I.current?"right":"left";F.current=P,I.current=j.clientX}}))})})})})})})});Yd.displayName=Zt;var p0="MenuGroup",xa=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(be.div,{role:"group",...r,ref:t})});xa.displayName=p0;var h0="MenuLabel",Xd=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(be.div,{...r,ref:t})});Xd.displayName=h0;var hs="MenuItem",Jd="menu.itemSelect",ms=h.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=h.useRef(null),i=oo(hs,e.__scopeMenu),a=ma(hs,e.__scopeMenu),l=De(t,s),c=h.useRef(!1),d=()=>{const p=s.current;if(!n&&p){const m=new CustomEvent(Jd,{bubbles:!0,cancelable:!0});p.addEventListener(Jd,f=>r==null?void 0:r(f),{once:!0}),Oi(p,m),m.defaultPrevented?c.current=!1:i.onClose()}};return u.jsx(Zd,{...o,ref:l,disabled:n,onClick:ie(e.onClick,d),onPointerDown:p=>{var m;(m=e.onPointerDown)==null||m.call(e,p),c.current=!0},onPointerUp:ie(e.onPointerUp,p=>{var m;c.current||(m=p.currentTarget)==null||m.click()}),onKeyDown:ie(e.onKeyDown,p=>{const m=a.searchRef.current!=="";n||m&&p.key===" "||fa.includes(p.key)&&(p.currentTarget.click(),p.preventDefault())})})});ms.displayName=hs;var Zd=h.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=ma(hs,n),a=Vd(n),l=h.useRef(null),c=De(t,l),[d,p]=h.useState(!1),[m,f]=h.useState("");return h.useEffect(()=>{const v=l.current;v&&f((v.textContent??"").trim())},[s.children]),u.jsx(ro.ItemSlot,{scope:n,disabled:r,textValue:o??m,children:u.jsx(py,{asChild:!0,...a,focusable:!r,children:u.jsx(be.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:c,onPointerMove:ie(e.onPointerMove,io(v=>{r?i.onItemLeave(v):(i.onItemEnter(v),v.defaultPrevented||v.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:ie(e.onPointerLeave,io(v=>i.onItemLeave(v))),onFocus:ie(e.onFocus,()=>p(!0)),onBlur:ie(e.onBlur,()=>p(!1))})})})}),m0="MenuCheckboxItem",Qd=h.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return u.jsx(of,{scope:e.__scopeMenu,checked:n,children:u.jsx(ms,{role:"menuitemcheckbox","aria-checked":gs(n)?"mixed":n,...o,ref:t,"data-state":wa(n),onSelect:ie(o.onSelect,()=>r==null?void 0:r(gs(n)?!0:!n),{checkForDefaultPrevented:!1})})})});Qd.displayName=m0;var ef="MenuRadioGroup",[g0,x0]=Xn(ef,{value:void 0,onValueChange:()=>{}}),tf=h.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=mt(r);return u.jsx(g0,{scope:e.__scopeMenu,value:n,onValueChange:s,children:u.jsx(xa,{...o,ref:t})})});tf.displayName=ef;var nf="MenuRadioItem",rf=h.forwardRef((e,t)=>{const{value:n,...r}=e,o=x0(nf,e.__scopeMenu),s=n===o.value;return u.jsx(of,{scope:e.__scopeMenu,checked:s,children:u.jsx(ms,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":wa(s),onSelect:ie(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});rf.displayName=nf;var va="MenuItemIndicator",[of,v0]=Xn(va,{checked:!1}),sf=h.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=v0(va,n);return u.jsx(Ft,{present:r||gs(s.checked)||s.checked===!0,children:u.jsx(be.span,{...o,ref:t,"data-state":wa(s.checked)})})});sf.displayName=va;var w0="MenuSeparator",af=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(be.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});af.displayName=w0;var b0="MenuArrow",lf=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=ps(n);return u.jsx(ra,{...o,...r,ref:t})});lf.displayName=b0;var y0="MenuSub",[r1,cf]=Xn(y0),so="MenuSubTrigger",uf=h.forwardRef((e,t)=>{const n=Jn(so,e.__scopeMenu),r=oo(so,e.__scopeMenu),o=cf(so,e.__scopeMenu),s=ma(so,e.__scopeMenu),i=h.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,c={__scopeMenu:e.__scopeMenu},d=h.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return h.useEffect(()=>d,[d]),h.useEffect(()=>{const p=a.current;return()=>{window.clearTimeout(p),l(null)}},[a,l]),u.jsx(pa,{asChild:!0,...c,children:u.jsx(Zd,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":pf(n.open),...e,ref:jn(t,o.onTriggerChange),onClick:p=>{var m;(m=e.onClick)==null||m.call(e,p),!(e.disabled||p.defaultPrevented)&&(p.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:ie(e.onPointerMove,io(p=>{s.onItemEnter(p),!p.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(s.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),d()},100))})),onPointerLeave:ie(e.onPointerLeave,io(p=>{var f,v;d();const m=(f=n.content)==null?void 0:f.getBoundingClientRect();if(m){const g=(v=n.content)==null?void 0:v.dataset.side,x=g==="right",y=x?-5:5,w=m[x?"left":"right"],S=m[x?"right":"left"];s.onPointerGraceIntentChange({area:[{x:p.clientX+y,y:p.clientY},{x:w,y:m.top},{x:S,y:m.top},{x:S,y:m.bottom},{x:w,y:m.bottom}],side:g}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(p),p.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:ie(e.onKeyDown,p=>{var f;const m=s.searchRef.current!=="";e.disabled||m&&p.key===" "||t0[r.dir].includes(p.key)&&(n.onOpenChange(!0),(f=n.content)==null||f.focus(),p.preventDefault())})})})});uf.displayName=so;var df="MenuSubContent",ff=h.forwardRef((e,t)=>{const n=qd(Zt,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=Jn(Zt,e.__scopeMenu),i=oo(Zt,e.__scopeMenu),a=cf(df,e.__scopeMenu),l=h.useRef(null),c=De(t,l);return u.jsx(ro.Provider,{scope:e.__scopeMenu,children:u.jsx(Ft,{present:r||s.open,children:u.jsx(ro.Slot,{scope:e.__scopeMenu,children:u.jsx(ga,{id:a.contentId,"aria-labelledby":a.triggerId,...o,ref:c,align:"start",side:i.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:d=>{var p;i.isUsingKeyboardRef.current&&((p=l.current)==null||p.focus()),d.preventDefault()},onCloseAutoFocus:d=>d.preventDefault(),onFocusOutside:ie(e.onFocusOutside,d=>{d.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:ie(e.onEscapeKeyDown,d=>{i.onClose(),d.preventDefault()}),onKeyDown:ie(e.onKeyDown,d=>{var f;const p=d.currentTarget.contains(d.target),m=n0[i.dir].includes(d.key);p&&m&&(s.onOpenChange(!1),(f=a.trigger)==null||f.focus(),d.preventDefault())})})})})})});ff.displayName=df;function pf(e){return e?"open":"closed"}function gs(e){return e==="indeterminate"}function wa(e){return gs(e)?"indeterminate":e?"checked":"unchecked"}function S0(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function C0(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function T0(e,t,n){const o=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=C0(e,Math.max(s,0));o.length===1&&(i=i.filter(c=>c!==n));const l=i.find(c=>c.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function k0(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const a=t[s],l=t[i],c=a.x,d=a.y,p=l.x,m=l.y;d>r!=m>r&&n<(p-c)*(r-d)/(m-d)+c&&(o=!o)}return o}function E0(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return k0(n,t)}function io(e){return t=>t.pointerType==="mouse"?e(t):void 0}var I0=Kd,N0=pa,A0=Gd,j0=Yd,_0=xa,P0=Xd,M0=ms,R0=Qd,O0=tf,D0=rf,L0=sf,$0=af,F0=lf,B0=uf,z0=ff,xs="DropdownMenu",[H0,o1]=sn(xs,[Wd]),Rt=Wd(),[U0,hf]=H0(xs),mf=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,l=Rt(t),c=h.useRef(null),[d,p]=_n({prop:o,defaultProp:s??!1,onChange:i,caller:xs});return u.jsx(U0,{scope:t,triggerId:Nt(),triggerRef:c,contentId:Nt(),open:d,onOpenChange:p,onOpenToggle:h.useCallback(()=>p(m=>!m),[p]),modal:a,children:u.jsx(I0,{...l,open:d,onOpenChange:p,dir:r,modal:a,children:n})})};mf.displayName=xs;var gf="DropdownMenuTrigger",xf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=hf(gf,n),i=Rt(n);return u.jsx(N0,{asChild:!0,...i,children:u.jsx(be.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:jn(t,s.triggerRef),onPointerDown:ie(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:ie(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});xf.displayName=gf;var W0="DropdownMenuPortal",vf=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Rt(t);return u.jsx(A0,{...r,...n})};vf.displayName=W0;var wf="DropdownMenuContent",bf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=hf(wf,n),s=Rt(n),i=h.useRef(!1);return u.jsx(j0,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:ie(e.onCloseAutoFocus,a=>{var l;i.current||(l=o.triggerRef.current)==null||l.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:ie(e.onInteractOutside,a=>{const l=a.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0,d=l.button===2||c;(!o.modal||d)&&(i.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});bf.displayName=wf;var V0="DropdownMenuGroup",K0=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Rt(n);return u.jsx(_0,{...o,...r,ref:t})});K0.displayName=V0;var q0="DropdownMenuLabel",yf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Rt(n);return u.jsx(P0,{...o,...r,ref:t})});yf.displayName=q0;var G0="DropdownMenuItem",Sf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Rt(n);return u.jsx(M0,{...o,...r,ref:t})});Sf.displayName=G0;var Y0="DropdownMenuCheckboxItem",Cf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Rt(n);return u.jsx(R0,{...o,...r,ref:t})});Cf.displayName=Y0;var X0="DropdownMenuRadioGroup",J0=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Rt(n);return u.jsx(O0,{...o,...r,ref:t})});J0.displayName=X0;var Z0="DropdownMenuRadioItem",Tf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Rt(n);return u.jsx(D0,{...o,...r,ref:t})});Tf.displayName=Z0;var Q0="DropdownMenuItemIndicator",kf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Rt(n);return u.jsx(L0,{...o,...r,ref:t})});kf.displayName=Q0;var eS="DropdownMenuSeparator",Ef=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Rt(n);return u.jsx($0,{...o,...r,ref:t})});Ef.displayName=eS;var tS="DropdownMenuArrow",nS=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Rt(n);return u.jsx(F0,{...o,...r,ref:t})});nS.displayName=tS;var rS="DropdownMenuSubTrigger",If=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Rt(n);return u.jsx(B0,{...o,...r,ref:t})});If.displayName=rS;var oS="DropdownMenuSubContent",Nf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Rt(n);return u.jsx(z0,{...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)"}})});Nf.displayName=oS;var sS=mf,iS=xf,aS=vf,Af=bf,jf=yf,_f=Sf,Pf=Cf,Mf=Tf,Rf=kf,Of=Ef,Df=If,Lf=Nf;const vs=sS,ws=iS,lS=h.forwardRef(({className:e,inset:t,children:n,...r},o)=>u.jsxs(Df,{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(ue.ChevronRight,{className:"ml-auto h-4 w-4"})]}));lS.displayName=Df.displayName;const cS=h.forwardRef(({className:e,...t},n)=>u.jsx(Lf,{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}));cS.displayName=Lf.displayName;const ao=h.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(aS,{children:u.jsx(Af,{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})}));ao.displayName=Af.displayName;const On=h.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(_f,{ref:r,className:ne("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...n}));On.displayName=_f.displayName;const uS=h.forwardRef(({className:e,children:t,checked:n,...r},o)=>u.jsxs(Pf,{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(Rf,{children:u.jsx(ue.Check,{className:"h-4 w-4"})})}),t]}));uS.displayName=Pf.displayName;const dS=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Mf,{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(Rf,{children:u.jsx(ue.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));dS.displayName=Mf.displayName;const fS=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}));fS.displayName=jf.displayName;const pS=h.forwardRef(({className:e,...t},n)=>u.jsx(Of,{ref:n,className:ne("-mx-1 my-1 h-px bg-muted",e),...t}));pS.displayName=Of.displayName;const ba=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}));ba.displayName="Textarea";const hS=1e4;function $f({initialValue:e="",editingMessageId:t=null,placeholder:n="Type your message...",isStreaming:r=!1,disabled:o=!1,maxLength:s=hS,value:i,onValueChange:a,onSend:l,onCancelEdit:c,onStop:d,className:p="",textareaClassName:m="",allowEmptySend:f=!1,validate:v,onValidationError:g}){const x=i!==void 0,[y,w]=b.useState(e),S=(x?i:y)??"",[k,C]=b.useTransition(),T=b.useRef(null),E=b.useRef(0),_=b.useRef(null),R=b.useRef("");b.useEffect(()=>{x||(w(e??""),_.current=null,T.current&&(T.current.style.height="auto",T.current.style.height=`${T.current.scrollHeight}px`))},[e,t,x]);const[L,H]=b.useState(null),K=b.useCallback(M=>M.length>s?`Message too long (${M.length}/${s} characters)`:null,[s]),F=b.useMemo(()=>v??K,[v,K]),I=b.useCallback(M=>{const G=F(M);return H(G),g==null||g(G),R.current=M,G},[F,g]),W=b.useCallback(()=>{const M=T.current;M&&(M.style.height="auto",M.style.height=`${M.scrollHeight}px`)},[]);b.useEffect(()=>{W()},[W,S]),b.useEffect(()=>{if(!L)return;const M=(S??"").trim();R.current!==M&&I(M)},[S,L,I]);const N=b.useCallback((M,{fromUser:G})=>{x||w(M),G&&(a==null||a(M))},[x,a]),U=b.useCallback(async M=>{M&&M.preventDefault();const G=(S??"").trim();if(!G&&!f||I(G))return;const Z=++E.current;_.current={id:Z,shouldClear:!0},C(()=>{var se,V,D;try{const X=l(G);X&&typeof X.then=="function"?X.then(()=>{var Q,ae;((Q=_.current)==null?void 0:Q.id)===Z&&_.current.shouldClear&&(x||(w(""),T.current&&(T.current.style.height="auto"),a==null||a(""))),((ae=_.current)==null?void 0:ae.id)===Z&&(_.current=null)}).catch(()=>{var Q;((Q=_.current)==null?void 0:Q.id)===Z&&(_.current=null)}):(((se=_.current)==null?void 0:se.id)===Z&&_.current.shouldClear&&(x||(w(""),T.current&&(T.current.style.height="auto"),a==null||a(""))),((V=_.current)==null?void 0:V.id)===Z&&(_.current=null))}catch{((D=_.current)==null?void 0:D.id)===Z&&(_.current=null)}})},[S,l,f,x,a,I]),O=b.useCallback(M=>{const G=M.target.value;N(G,{fromUser:!0}),_.current&&(_.current.shouldClear=!1),T.current&&(T.current.style.height="auto",T.current.style.height=`${T.current.scrollHeight}px`),L&&I(G.trim())},[N,I,L]),j=b.useCallback(M=>{M.key==="Enter"&&!M.shiftKey?(M.preventDefault(),U()):M.key==="Escape"&&t&&(M.preventDefault(),c==null||c())},[U,t,c]),P=`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${t?"border-[hsl(var(--ring))] bg-[hsl(var(--card))] text-[hsl(var(--card-foreground))] dark:bg-[hsl(var(--card))] dark:text-[hsl(var(--card-foreground))]":""} ${m}`;return u.jsx("form",{onSubmit:M=>void U(M),className:`w-full ${p}`,children:u.jsxs("div",{className:"flex items-end gap-2",children:[u.jsxs("div",{className:"flex-1",children:[u.jsx(ba,{ref:T,value:S,onChange:O,onKeyDown:j,placeholder:t?"Edit your message...":n,className:P,disabled:o,maxLength:s,rows:1,spellCheck:!1,autoCorrect:"off"}),L&&u.jsx("p",{className:"mt-1 text-xs text-destructive font-medium",children:L})]}),u.jsx("div",{children:r?u.jsx(at,{type:"button",onClick:()=>{d==null||d()},size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",disabled:o||!d,children:u.jsx(ue.Square,{size:16})}):u.jsx(at,{type:"submit",size:"icon",className:"shrink-0",title:t?"Save changes":"Send message",disabled:o||!S.trim()&&!f||k,children:u.jsx(ue.Send,{size:16})})})]})})}const mS=b.memo($f),bs=0,Dn=1,Er=2,Ff=4;function Bf(e){return()=>e}function gS(e){e()}function zf(e,t){return n=>e(t(n))}function Hf(e,t){return()=>e(t)}function xS(e,t){return n=>e(t,n)}function ya(e){return e!==void 0}function vS(...e){return()=>{e.map(gS)}}function Ir(){}function ys(e,t){return t(e),e}function wS(e,t){return t(e)}function lt(...e){return e}function Qe(e,t){return e(Dn,t)}function Re(e,t){e(bs,t)}function Sa(e){e(Er)}function gt(e){return e(Ff)}function ye(e,t){return Qe(e,xS(t,bs))}function cn(e,t){const n=e(Dn,r=>{n(),t(r)});return n}function Uf(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function Wf(e,t){return e===t}function ct(e=Wf){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function Ae(e){return t=>n=>{e(n)&&t(n)}}function he(e){return t=>zf(t,e)}function yn(e){return t=>()=>{t(e)}}function ee(e,...t){const n=bS(...t);return(r,o)=>{switch(r){case Er:Sa(e);return;case Dn:return Qe(e,n(o))}}}function Sn(e,t){return n=>r=>{n(t=e(t,r))}}function Zn(e){return t=>n=>{e>0?e--:t(n)}}function In(e){let t=null,n;return r=>o=>{t=o,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function Le(...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);Qe(s,l=>{const c=n;n=n|a,t[i]=l,c!==o&&n===o&&r&&(r(),r=null)})}),s=>i=>{const a=()=>{s([i].concat(t))};n===o?a():r=a}}function bS(...e){return t=>e.reduceRight(wS,t)}function yS(e){let t,n;const r=()=>t==null?void 0:t();return function(o,s){switch(o){case Dn:return s?n===s?void 0:(r(),n=s,t=Qe(e,s),t):(r(),Ir);case Er:r(),n=null;return}}}function oe(e){let t=e;const n=Ue();return(r,o)=>{switch(r){case bs:t=o;break;case Dn:{o(t);break}case Ff:return t}return n(r,o)}}function At(e,t){return ys(oe(t),n=>ye(e,n))}function Ue(){const e=[];return(t,n)=>{switch(t){case bs:e.slice().forEach(r=>{r(n)});return;case Er:e.splice(0,e.length);return;case Dn:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}}}function Xt(e){return ys(Ue(),t=>ye(e,t))}function Ye(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:SS(),singleton:n}}const SS=()=>Symbol();function CS(e){const t=new Map,n=({constructor:r,dependencies:o,id:s,singleton:i})=>{if(i&&t.has(s))return t.get(s);const a=r(o.map(l=>n(l)));return i&&t.set(s,a),a};return n(e)}function wt(...e){const t=Ue(),n=new Array(e.length);let r=0;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const a=Math.pow(2,i);Qe(s,l=>{n[i]=l,r=r|a,r===o&&Re(t,n)})}),function(s,i){switch(s){case Er:{Sa(t);return}case Dn:return r===o&&i(n),Qe(t,i)}}}function Ie(e,t=Wf){return ee(e,ct(t))}function Ca(...e){return function(t,n){switch(t){case Er:return;case Dn:return vS(...e.map(r=>Qe(r,n)))}}}var Bt=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(Bt||{});const TS={0:"debug",3:"error",1:"log",2:"warn"},kS=()=>typeof globalThis>"u"?window:globalThis,Ln=Ye(()=>{const e=oe(3);return{log:oe((t,n,r=1)=>{var o;const s=(o=kS().VIRTUOSO_LOG_LEVEL)!=null?o:gt(e);r>=s&&console[TS[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0});function Qn(e,t,n){return Ta(e,t,n).callbackRef}function Ta(e,t,n){const r=b.useRef(null);let o=i=>{};const s=b.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(i=>{const a=()=>{const l=i[0].target;l.offsetParent!==null&&e(l)};n?a():requestAnimationFrame(a)}):null,[e,n]);return o=i=>{i&&t?(s==null||s.observe(i),r.current=i):(r.current&&(s==null||s.unobserve(r.current)),r.current=null)},{callbackRef:o,ref:r}}function ES(e,t,n,r,o,s,i,a,l){const c=b.useCallback(d=>{const p=IS(d.children,t,a?"offsetWidth":"offsetHeight",o);let m=d.parentElement;for(;!m.dataset.virtuosoScroller;)m=m.parentElement;const f=m.lastElementChild.dataset.viewportType==="window";let v;f&&(v=m.ownerDocument.defaultView);const g=i?a?i.scrollLeft:i.scrollTop:f?a?v.scrollX||v.document.documentElement.scrollLeft:v.scrollY||v.document.documentElement.scrollTop:a?m.scrollLeft:m.scrollTop,x=i?a?i.scrollWidth:i.scrollHeight:f?a?v.document.documentElement.scrollWidth:v.document.documentElement.scrollHeight:a?m.scrollWidth:m.scrollHeight,y=i?a?i.offsetWidth:i.offsetHeight:f?a?v.innerWidth:v.innerHeight:a?m.offsetWidth:m.offsetHeight;r({scrollHeight:x,scrollTop:Math.max(g,0),viewportHeight:y}),s==null||s(a?Vf("column-gap",getComputedStyle(d).columnGap,o):Vf("row-gap",getComputedStyle(d).rowGap,o)),p!==null&&e(p)},[e,t,o,s,i,r,a]);return Ta(c,n,l)}function IS(e,t,n,r){const o=e.length;if(o===0)return null;const s=[];for(let i=0;i<o;i++){const a=e.item(i);if(a.dataset.index===void 0)continue;const l=parseInt(a.dataset.index),c=parseFloat(a.dataset.knownSize),d=t(a,n);if(d===0&&r("Zero-sized element, this should not happen",{child:a},Bt.ERROR),d===c)continue;const p=s[s.length-1];s.length===0||p.size!==d||p.endIndex!==l-1?s.push({endIndex:l,size:d,startIndex:l}):s[s.length-1].endIndex++}return s}function Vf(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Bt.WARN),t==="normal"?0:parseInt(t??"0",10)}function Kf(e,t,n){const r=b.useRef(null),o=b.useCallback(l=>{if(!(l!=null&&l.offsetParent))return;const c=l.getBoundingClientRect(),d=c.width;let p,m;if(t){const f=t.getBoundingClientRect(),v=c.top-f.top;m=f.height-Math.max(0,v),p=v+t.scrollTop}else{const f=i.current.ownerDocument.defaultView;m=f.innerHeight-Math.max(0,c.top),p=c.top+f.scrollY}r.current={offsetTop:p,visibleHeight:m,visibleWidth:d},e(r.current)},[e,t]),{callbackRef:s,ref:i}=Ta(o,!0,n),a=b.useCallback(()=>{o(i.current)},[o,i]);return b.useEffect(()=>{var l;if(t){t.addEventListener("scroll",a);const c=new ResizeObserver(()=>{requestAnimationFrame(a)});return c.observe(t),()=>{t.removeEventListener("scroll",a),c.unobserve(t)}}else{const c=(l=i.current)==null?void 0:l.ownerDocument.defaultView;return c==null||c.addEventListener("scroll",a),c==null||c.addEventListener("resize",a),()=>{c==null||c.removeEventListener("scroll",a),c==null||c.removeEventListener("resize",a)}}},[a,t,i]),s}const Ot=Ye(()=>{const e=Ue(),t=Ue(),n=oe(0),r=Ue(),o=oe(0),s=Ue(),i=Ue(),a=oe(0),l=oe(0),c=oe(0),d=oe(0),p=Ue(),m=Ue(),f=oe(!1),v=oe(!1),g=oe(!1);return ye(ee(e,he(({scrollTop:x})=>x)),t),ye(ee(e,he(({scrollHeight:x})=>x)),i),ye(t,o),{deviation:n,fixedFooterHeight:c,fixedHeaderHeight:l,footerHeight:d,headerHeight:a,horizontalDirection:v,scrollBy:m,scrollContainerState:e,scrollHeight:i,scrollingInProgress:f,scrollTo:p,scrollTop:t,skipAnimationFrameInResizeObserver:g,smoothScrollTargetReached:r,statefulScrollTop:o,viewportHeight:s}},[],{singleton:!0}),lo={lvl:0};function qf(e,t){const n=e.length;if(n===0)return[];let{index:r,value:o}=t(e[0]);const s=[];for(let i=1;i<n;i++){const{index:a,value:l}=t(e[i]);s.push({end:a-1,start:r,value:o}),r=a,o=l}return s.push({end:1/0,start:r,value:o}),s}function ot(e){return e===lo}function co(e,t){if(!ot(e))return t===e.k?e.v:t<e.k?co(e.l,t):co(e.r,t)}function un(e,t,n="k"){if(ot(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){const r=un(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return un(e.l,t,n)}function Jt(e,t,n){return ot(e)?Xf(t,n,1):t===e.k?St(e,{k:t,v:n}):t<e.k?Jf(St(e,{l:Jt(e.l,t,n)})):Jf(St(e,{r:Jt(e.r,t,n)}))}function Nr(){return lo}function Ss(e,t,n){if(ot(e))return[];const r=un(e,t)[0];return NS(Ea(e,r,n))}function ka(e,t){if(ot(e))return lo;const{k:n,l:r,r:o}=e;if(t===n){if(ot(r))return o;if(ot(o))return r;{const[s,i]=Yf(r);return Cs(St(e,{k:s,l:Gf(r),v:i}))}}else return t<n?Cs(St(e,{l:ka(r,t)})):Cs(St(e,{r:ka(o,t)}))}function er(e){return ot(e)?[]:[...er(e.l),{k:e.k,v:e.v},...er(e.r)]}function Ea(e,t,n){if(ot(e))return[];const{k:r,l:o,r:s,v:i}=e;let a=[];return r>t&&(a=a.concat(Ea(o,t,n))),r>=t&&r<=n&&a.push({k:r,v:i}),r<=n&&(a=a.concat(Ea(s,t,n))),a}function Cs(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(Ia(t))return Zf(St(e,{lvl:n-1}));if(!ot(t)&&!ot(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(Ia(e))return Na(St(e,{lvl:n-1}));if(!ot(r)&&!ot(r.l)){const o=r.l,s=Ia(o)?r.lvl-1:r.lvl;return St(o,{l:St(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:Na(St(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function St(e,t){return Xf(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 Gf(e){return ot(e.r)?e.l:Cs(St(e,{r:Gf(e.r)}))}function Ia(e){return ot(e)||e.lvl>e.r.lvl}function Yf(e){return ot(e.r)?[e.k,e.v]:Yf(e.r)}function Xf(e,t,n,r=lo,o=lo){return{k:e,l:r,lvl:n,r:o,v:t}}function Jf(e){return Na(Zf(e))}function Zf(e){const{l:t}=e;return!ot(t)&&t.lvl===e.lvl?St(t,{r:St(e,{l:t.r})}):e}function Na(e){const{lvl:t,r:n}=e;return!ot(n)&&!ot(n.r)&&n.lvl===t&&n.r.lvl===t?St(n,{l:St(e,{r:n.l}),lvl:t+1}):e}function NS(e){return qf(e,({k:t,v:n})=>({index:t,value:n}))}function Qf(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function uo(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const Aa=Ye(()=>({recalcInProgress:oe(!1)}),[],{singleton:!0});function ep(e,t,n){return e[Ts(e,t,n)]}function Ts(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 AS(e,t,n,r){const o=Ts(e,t,r),s=Ts(e,n,r,o);return e.slice(o,s+1)}function $n(e,t){return Math.round(e.getBoundingClientRect()[t])}function ks(e){return!ot(e.groupOffsetTree)}function ja({index:e},t){return t===e?0:t<e?-1:1}function jS(){return{groupIndices:[],groupOffsetTree:Nr(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Nr()}}function _S(e,t){let n=ot(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),ot(e)){e=Jt(e,0,s);continue}const a=Ss(e,i-1,o+1);if(a.some($S(r)))continue;let l=!1,c=!1;for(const{end:d,start:p,value:m}of a)l?(o>=p||s===m)&&(e=ka(e,p)):(c=m!==s,l=!0),d>o&&o>=p&&m!==s&&(e=Jt(e,o+1,m));c&&(e=Jt(e,i,s))}return[e,n]}function PS(e){return typeof e.groupIndex<"u"}function MS({offset:e},t){return t===e?0:t<e?-1:1}function fo(e,t,n){if(t.length===0)return 0;const{index:r,offset:o,size:s}=ep(t,e,ja),i=e-r,a=s*i+(i-1)*n+o;return a>0?a+n:a}function tp(e,t){if(!ks(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function np(e,t,n){if(PS(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=tp(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function RS(e,t,n,r=0){return r>0&&(t=Math.max(t,ep(e,r,ja).offset)),qf(AS(e,t,n,MS),LS)}function OS(e,[t,n,r,o]){t.length>0&&r("received item sizes",t,Bt.DEBUG);const s=e.sizeTree;let i=s,a=0;if(n.length>0&&ot(s)&&t.length===2){const m=t[0].size,f=t[1].size;i=n.reduce((v,g)=>Jt(Jt(v,g,m),g+1,f),i)}else[i,a]=_S(i,t);if(i===s)return e;const{lastIndex:l,lastOffset:c,lastSize:d,offsetTree:p}=_a(e.offsetTree,a,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((m,f)=>Jt(m,f,fo(f,p,o)),Nr()),lastIndex:l,lastOffset:c,lastSize:d,offsetTree:p,sizeTree:i}}function DS(e){return er(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 rp(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 _a(e,t,n,r){let o=e,s=0,i=0,a=0,l=0;if(t!==0){l=Ts(o,t-1,ja),a=o[l].offset;const c=un(n,t-1);s=c[0],i=c[1],o.length&&o[l].size===un(n,t)[1]&&(l-=1),o=o.slice(0,l+1)}else o=[];for(const{start:c,value:d}of Ss(n,t,1/0)){const p=c-s,m=p*i+a+p*r;o.push({index:c,offset:m,size:d}),s=c,a=m,i=d}return{lastIndex:s,lastOffset:a,lastSize:i,offsetTree:o}}function LS(e){return{index:e.index,value:e}}function $S(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 FS={offsetHeight:"height",offsetWidth:"width"},Cn=Ye(([{log:e},{recalcInProgress:t}])=>{const n=Ue(),r=Ue(),o=At(r,0),s=Ue(),i=Ue(),a=oe(0),l=oe([]),c=oe(void 0),d=oe(void 0),p=oe((C,T)=>$n(C,FS[T])),m=oe(void 0),f=oe(0),v=jS(),g=At(ee(n,Le(l,e,f),Sn(OS,v),ct()),v),x=At(ee(l,ct(),Sn((C,T)=>({current:T,prev:C.current}),{current:[],prev:[]}),he(({prev:C})=>C)),[]);ye(ee(l,Ae(C=>C.length>0),Le(g,f),he(([C,T,E])=>{const _=C.reduce((R,L,H)=>Jt(R,L,fo(L,T.offsetTree,E)||H),Nr());return{...T,groupIndices:C,groupOffsetTree:_}})),g),ye(ee(r,Le(g),Ae(([C,{lastIndex:T}])=>C<T),he(([C,{lastIndex:T,lastSize:E}])=>[{endIndex:T,size:E,startIndex:C}])),n),ye(c,d);const y=At(ee(c,he(C=>C===void 0)),!0);ye(ee(d,Ae(C=>C!==void 0&&ot(gt(g).sizeTree)),he(C=>[{endIndex:0,size:C,startIndex:0}])),n);const w=Xt(ee(n,Le(g),Sn(({sizes:C},[T,E])=>({changed:E!==C,sizes:E}),{changed:!1,sizes:v}),he(C=>C.changed)));Qe(ee(a,Sn((C,T)=>({diff:C.prev-T,prev:T}),{diff:0,prev:0}),he(C=>C.diff)),C=>{const{groupIndices:T}=gt(g);if(C>0)Re(t,!0),Re(s,C+rp(C,T));else if(C<0){const E=gt(x);E.length>0&&(C-=rp(-C,E)),Re(i,C)}}),Qe(ee(a,Le(e)),([C,T])=>{C<0&&T("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:a},Bt.ERROR)});const S=Xt(s);ye(ee(s,Le(g),he(([C,T])=>{const E=T.groupIndices.length>0,_=[],R=T.lastSize;if(E){const L=co(T.sizeTree,0);let H=0,K=0;for(;H<C;){const I=T.groupIndices[K],W=T.groupIndices.length===K+1?1/0:T.groupIndices[K+1]-I-1;_.push({endIndex:I,size:L,startIndex:I}),_.push({endIndex:I+1+W-1,size:R,startIndex:I+1}),K++,H+=W+1}const F=er(T.sizeTree);return H!==C&&F.shift(),F.reduce((I,{k:W,v:N})=>{let U=I.ranges;return I.prevSize!==0&&(U=[...I.ranges,{endIndex:W+C-1,size:I.prevSize,startIndex:I.prevIndex}]),{prevIndex:W+C,prevSize:N,ranges:U}},{prevIndex:C,prevSize:0,ranges:_}).ranges}return er(T.sizeTree).reduce((L,{k:H,v:K})=>({prevIndex:H+C,prevSize:K,ranges:[...L.ranges,{endIndex:H+C-1,size:L.prevSize,startIndex:L.prevIndex}]}),{prevIndex:0,prevSize:R,ranges:[]}).ranges})),n);const k=Xt(ee(i,Le(g,f),he(([C,{offsetTree:T},E])=>{const _=-C;return fo(_,T,E)})));return ye(ee(i,Le(g,f),he(([C,T,E])=>{if(T.groupIndices.length>0){if(ot(T.sizeTree))return T;let _=Nr();const R=gt(x);let L=0,H=0,K=0;for(;L<-C;){K=R[H];const F=R[H+1]-K-1;H++,L+=F+1}if(_=er(T.sizeTree).reduce((F,{k:I,v:W})=>Jt(F,Math.max(0,I+C),W),_),L!==-C){const F=co(T.sizeTree,K);_=Jt(_,0,F);const I=un(T.sizeTree,-C+1)[1];_=Jt(_,1,I)}return{...T,sizeTree:_,..._a(T.offsetTree,0,_,E)}}else{const _=er(T.sizeTree).reduce((R,{k:L,v:H})=>Jt(R,Math.max(0,L+C),H),Nr());return{...T,sizeTree:_,..._a(T.offsetTree,0,_,E)}}})),g),{beforeUnshiftWith:S,data:m,defaultItemSize:d,firstItemIndex:a,fixedItemSize:c,gap:f,groupIndices:l,itemSize:p,listRefresh:w,shiftWith:i,shiftWithOffset:k,sizeRanges:n,sizes:g,statefulTotalCount:o,totalCount:r,trackItemSizes:y,unshiftWith:s}},lt(Ln,Aa),{singleton:!0});function BS(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const op=Ye(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=Ue(),i=Ue(),a=Xt(ee(s,he(BS)));return ye(ee(a,he(l=>l.totalCount)),n),ye(ee(a,he(l=>l.groupIndices)),e),ye(ee(wt(o,t,r),Ae(([l,c])=>ks(c)),he(([l,c,d])=>un(c.groupOffsetTree,Math.max(l-d,0),"v")[0]),ct(),he(l=>[l])),i),{groupCounts:s,topItemsIndexes:i}},lt(Cn,Ot)),Fn=Ye(([{log:e}])=>{const t=oe(!1),n=Xt(ee(t,Ae(r=>r),ct()));return Qe(t,r=>{r&&gt(e)("props updated",{},Bt.DEBUG)}),{didMount:n,propsReady:t}},lt(Ln),{singleton:!0}),zS=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function sp(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!zS)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const po=Ye(([{gap:e,listRefresh:t,sizes:n,totalCount:r},{fixedFooterHeight:o,fixedHeaderHeight:s,footerHeight:i,headerHeight:a,scrollingInProgress:l,scrollTo:c,smoothScrollTargetReached:d,viewportHeight:p},{log:m}])=>{const f=Ue(),v=Ue(),g=oe(0);let x=null,y=null,w=null;function S(){x&&(x(),x=null),w&&(w(),w=null),y&&(clearTimeout(y),y=null),Re(l,!1)}return ye(ee(f,Le(n,p,r,g,a,i,m),Le(e,s,o),he(([[k,C,T,E,_,R,L,H],K,F,I])=>{const W=sp(k),{align:N,behavior:U,offset:O}=W,j=E-1,q=np(W,C,j);let J=fo(q,C.offsetTree,K)+R;N==="end"?(J+=F+un(C.sizeTree,q)[1]-T+I,q===j&&(J+=L)):N==="center"?J+=(F+un(C.sizeTree,q)[1]-T+I)/2:J-=_,O&&(J+=O);const P=M=>{S(),M?(H("retrying to scroll to",{location:k},Bt.DEBUG),Re(f,k)):(Re(v,!0),H("list did not change, scroll successful",{},Bt.DEBUG))};if(S(),U==="smooth"){let M=!1;w=Qe(t,G=>{M=M||G}),x=cn(d,()=>{P(M)})}else x=cn(ee(t,HS(150)),P);return y=setTimeout(()=>{S()},1200),Re(l,!0),H("scrolling from index to",{behavior:U,index:q,top:J},Bt.DEBUG),{behavior:U,top:J}})),c),{scrollTargetReached:v,scrollToIndex:f,topListHeight:g}},lt(Cn,Ot,Ln),{singleton:!0});function HS(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function Pa(e,t){e==0?t():requestAnimationFrame(()=>{Pa(e-1,t)})}function Ma(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const ho=Ye(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:s},{didMount:i}])=>{const a=oe(!0),l=oe(0),c=oe(!0);return ye(ee(i,Le(l),Ae(([d,p])=>!!p),yn(!1)),a),ye(ee(i,Le(l),Ae(([d,p])=>!!p),yn(!1)),c),Qe(ee(wt(t,i),Le(a,n,e,c),Ae(([[,d],p,{sizeTree:m},f,v])=>d&&(!ot(m)||ya(f))&&!p&&!v),Le(l)),([,d])=>{cn(o,()=>{Re(c,!0)}),Pa(4,()=>{cn(r,()=>{Re(a,!0)}),Re(s,d)})}),{initialItemFinalLocationReached:c,initialTopMostItemIndex:l,scrolledToInitialItem:a}},lt(Cn,Ot,po,Fn),{singleton:!0});function ip(e,t){return Math.abs(e-t)<1.01}const mo="up",go="down",US="none",WS={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},VS=0,xo=Ye(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=oe(!1),a=oe(!0),l=Ue(),c=Ue(),d=oe(4),p=oe(VS),m=At(ee(Ca(ee(Ie(o),Zn(1),yn(!0)),ee(Ie(o),Zn(1),yn(!1),Uf(100))),ct()),!1),f=At(ee(Ca(ee(n,yn(!0)),ee(n,yn(!1),Uf(200))),ct()),!1);ye(ee(wt(Ie(o),Ie(p)),he(([w,S])=>w<=S),ct()),a),ye(ee(a,In(50)),c);const v=Xt(ee(wt(r,Ie(s),Ie(t),Ie(e),Ie(d)),Sn((w,[{scrollHeight:S,scrollTop:k},C,T,E,_])=>{const R=k+C-S>-_,L={scrollHeight:S,scrollTop:k,viewportHeight:C};if(R){let K,F;return k>w.state.scrollTop?(K="SCROLLED_DOWN",F=w.state.scrollTop-k):(K="SIZE_DECREASED",F=w.state.scrollTop-k||w.scrollTopDelta),{atBottom:!0,atBottomBecause:K,scrollTopDelta:F,state:L}}let H;return L.scrollHeight>w.state.scrollHeight?H="SIZE_INCREASED":C<w.state.viewportHeight?H="VIEWPORT_HEIGHT_DECREASING":k<w.state.scrollTop?H="SCROLLING_UPWARDS":H="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:H,state:L}},WS),ct((w,S)=>w&&w.atBottom===S.atBottom))),g=At(ee(r,Sn((w,{scrollHeight:S,scrollTop:k,viewportHeight:C})=>{if(ip(w.scrollHeight,S))return{changed:!1,jump:0,scrollHeight:S,scrollTop:k};{const T=S-(k+C)<1;return w.scrollTop!==k&&T?{changed:!0,jump:w.scrollTop-k,scrollHeight:S,scrollTop:k}:{changed:!0,jump:0,scrollHeight:S,scrollTop:k}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),Ae(w=>w.changed),he(w=>w.jump)),0);ye(ee(v,he(w=>w.atBottom)),i),ye(ee(i,In(50)),l);const x=oe(go);ye(ee(r,he(({scrollTop:w})=>w),ct(),Sn((w,S)=>gt(f)?{direction:w.direction,prevScrollTop:S}:{direction:S<w.prevScrollTop?mo:go,prevScrollTop:S},{direction:go,prevScrollTop:0}),he(w=>w.direction)),x),ye(ee(r,In(50),yn(US)),x);const y=oe(0);return ye(ee(m,Ae(w=>!w),yn(0)),y),ye(ee(o,In(100),Le(m),Ae(([w,S])=>!!S),Sn(([w,S],[k])=>[S,k],[0,0]),he(([w,S])=>S-w)),y),{atBottomState:v,atBottomStateChange:l,atBottomThreshold:d,atTopStateChange:c,atTopThreshold:p,isAtBottom:i,isAtTop:a,isScrolling:m,lastJumpDueToItemResize:g,scrollDirection:x,scrollVelocity:y}},lt(Ot)),Es="top",Is="bottom",ap="none";function lp(e,t,n){return typeof e=="number"?n===mo&&t===Es||n===go&&t===Is?e:0:n===mo?t===Es?e.main:e.reverse:t===Is?e.main:e.reverse}function cp(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const Ra=Ye(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=Ue(),i=oe(0),a=oe(0),l=oe(0),c=At(ee(wt(Ie(r),Ie(o),Ie(n),Ie(s,uo),Ie(l),Ie(i),Ie(t),Ie(e),Ie(a)),he(([d,p,m,[f,v],g,x,y,w,S])=>{const k=d-w,C=x+y,T=Math.max(m-k,0);let E=ap;const _=cp(S,Es),R=cp(S,Is);return f-=w,f+=m+y,v+=m+y,v-=w,f>d+C-_&&(E=mo),v<d-T+p+R&&(E=go),E!==ap?[Math.max(k-m-lp(g,Es,E)-_,0),k-T-y+p+lp(g,Is,E)+R]:null}),Ae(d=>d!=null),ct(uo)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:l,topListHeight:i,visibleRange:c}},lt(Ot),{singleton:!0});function KS(e,t,n){if(ks(t)){const r=tp(e,t);return[{index:un(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 Oa={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Ns(e,t,n,r,o,s){const{lastIndex:i,lastOffset:a,lastSize:l}=o;let c=0,d=0;if(e.length>0){c=e[0].offset;const g=e[e.length-1];d=g.offset+g.size}const p=n-i,m=a+p*l+(p-1)*r,f=c,v=m-d;return{bottom:d,firstItemIndex:s,items:dp(e,o,s),offsetBottom:v,offsetTop:c,top:f,topItems:dp(t,o,s),topListHeight:t.reduce((g,x)=>x.size+g,0),totalCount:n}}function up(e,t,n,r,o,s){let i=0;if(n.groupIndices.length>0)for(const d of n.groupIndices){if(d-i>=e)break;i++}const a=e+i,l=Ma(t,a),c=Array.from({length:a}).map((d,p)=>({data:s[p+l],index:p+l,offset:0,size:0}));return Ns(c,[],a,o,n,r)}function dp(e,t,n){if(e.length===0)return[];if(!ks(t))return e.map(c=>({...c,index:c.index+n,originalIndex:c.index}));const r=e[0].index,o=e[e.length-1].index,s=[],i=Ss(t.groupOffsetTree,r,o);let a,l=0;for(const c of e){(!a||a.end<c.index)&&(a=i.shift(),l=t.groupIndices.indexOf(a.start));let d;c.index===a.start?d={index:l,type:"group"}:d={groupIndex:l,index:c.index-(l+1)+n},s.push({...d,data:c.data,offset:c.offset,originalIndex:c.index,size:c.size})}return s}const tr=Ye(([{data:e,firstItemIndex:t,gap:n,sizes:r,totalCount:o},s,{listBoundary:i,topListHeight:a,visibleRange:l},{initialTopMostItemIndex:c,scrolledToInitialItem:d},{topListHeight:p},m,{didMount:f},{recalcInProgress:v}])=>{const g=oe([]),x=oe(0),y=Ue();ye(s.topItemsIndexes,g);const w=At(ee(wt(f,v,Ie(l,uo),Ie(o),Ie(r),Ie(c),d,Ie(g),Ie(t),Ie(n),e),Ae(([T,E,,_,,,,,,,R])=>{const L=R&&R.length!==_;return T&&!E&&!L}),he(([,,[T,E],_,R,L,H,K,F,I,W])=>{const N=R,{offsetTree:U,sizeTree:O}=N,j=gt(x);if(_===0)return{...Oa,totalCount:_};if(T===0&&E===0)return j===0?{...Oa,totalCount:_}:up(j,L,R,F,I,W||[]);if(ot(O))return j>0?null:Ns(KS(Ma(L,_),N,W),[],_,I,N,F);const q=[];if(K.length>0){const Z=K[0],se=K[K.length-1];let V=0;for(const D of Ss(O,Z,se)){const X=D.value,Q=Math.max(D.start,Z),ae=Math.min(D.end,se);for(let $=Q;$<=ae;$++)q.push({data:W==null?void 0:W[$],index:$,offset:V,size:X}),V+=X}}if(!H)return Ns([],q,_,I,N,F);const J=K.length>0?K[K.length-1]+1:0,P=RS(U,T,E,J);if(P.length===0)return null;const M=_-1,G=ys([],Z=>{for(const se of P){const V=se.value;let D=V.offset,X=se.start;const Q=V.size;if(V.offset<T){X+=Math.floor((T-V.offset+I)/(Q+I));const $=X-se.start;D+=$*Q+$*I}X<J&&(D+=(J-X)*Q,X=J);const ae=Math.min(se.end,M);for(let $=X;$<=ae&&!(D>=E);$++)Z.push({data:W==null?void 0:W[$],index:$,offset:D,size:Q}),D+=Q+I}});return Ns(G,q,_,I,N,F)}),Ae(T=>T!==null),ct()),Oa);ye(ee(e,Ae(ya),he(T=>T==null?void 0:T.length)),o),ye(ee(w,he(T=>T.topListHeight)),p),ye(p,a),ye(ee(w,he(T=>[T.top,T.bottom])),i),ye(ee(w,he(T=>T.items)),y);const S=Xt(ee(w,Ae(({items:T})=>T.length>0),Le(o,e),Ae(([{items:T},E])=>T[T.length-1].originalIndex===E-1),he(([,T,E])=>[T-1,E]),ct(uo),he(([T])=>T))),k=Xt(ee(w,In(200),Ae(({items:T,topItems:E})=>T.length>0&&T[0].originalIndex===E.length),he(({items:T})=>T[0].index),ct())),C=Xt(ee(w,Ae(({items:T})=>T.length>0),he(({items:T})=>{let E=0,_=T.length-1;for(;T[E].type==="group"&&E<_;)E++;for(;T[_].type==="group"&&_>E;)_--;return{endIndex:T[_].index,startIndex:T[E].index}}),ct(Qf)));return{endReached:S,initialItemCount:x,itemsRendered:y,listState:w,rangeChanged:C,startReached:k,topItemsIndexes:g,...m}},lt(Cn,op,Ra,ho,po,xo,Fn,Aa),{singleton:!0}),fp=Ye(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=Ue(),i=At(ee(wt(n,e,r,t,o),he(([a,l,c,d,p])=>a+l+c+d+p.offsetBottom+p.bottom)),0);return ye(Ie(i),s),{totalListHeight:i,totalListHeightChanged:s}},lt(Ot,tr),{singleton:!0}),qS=Ye(([{viewportHeight:e},{totalListHeight:t}])=>{const n=oe(!1),r=At(ee(wt(n,e,t),Ae(([o])=>o),he(([,o,s])=>Math.max(0,o-s)),In(0),ct()),0);return{alignToBottom:n,paddingTopAddition:r}},lt(Ot,fp),{singleton:!0}),pp=Ye(()=>({context:oe(null)})),GS=({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,hp=Ye(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:s,scrollingInProgress:i,scrollTop:a,viewportHeight:l},{scrollToIndex:c}])=>{const d=Ue();return ye(ee(d,Le(t,l,n,s,o,r,a),Le(e),he(([[p,m,f,v,g,x,y,w],S])=>{const{align:k,behavior:C,calculateViewLocation:T=GS,done:E,..._}=p,R=np(p,m,v-1),L=fo(R,m.offsetTree,S)+g+x,H=L+un(m.sizeTree,R)[1],K=w+x,F=w+f-y,I=T({itemBottom:H,itemTop:L,locationParams:{align:k,behavior:C,..._},viewportBottom:F,viewportTop:K});return I?E&&cn(ee(i,Ae(W=>!W),Zn(gt(i)?1:2)),E):E&&E(),I}),Ae(p=>p!==null)),c),{scrollIntoView:d}},lt(Cn,Ot,po,tr,Ln),{singleton:!0});function mp(e){return e?e==="smooth"?"smooth":"auto":!1}const YS=(e,t)=>typeof e=="function"?mp(e(t)):t&&mp(e),XS=Ye(([{listRefresh:e,totalCount:t,fixedItemSize:n,data:r},{atBottomState:o,isAtBottom:s},{scrollToIndex:i},{scrolledToInitialItem:a},{didMount:l,propsReady:c},{log:d},{scrollingInProgress:p},{context:m},{scrollIntoView:f}])=>{const v=oe(!1),g=Ue();let x=null;function y(C){Re(i,{align:"end",behavior:C,index:"LAST"})}Qe(ee(wt(ee(Ie(t),Zn(1)),l),Le(Ie(v),s,a,p),he(([[C,T],E,_,R,L])=>{let H=T&&R,K="auto";return H&&(K=YS(E,_||L),H=H&&!!K),{followOutputBehavior:K,shouldFollow:H,totalCount:C}}),Ae(({shouldFollow:C})=>C)),({followOutputBehavior:C,totalCount:T})=>{x&&(x(),x=null),gt(n)?requestAnimationFrame(()=>{gt(d)("following output to ",{totalCount:T},Bt.DEBUG),y(C)}):x=cn(e,()=>{gt(d)("following output to ",{totalCount:T},Bt.DEBUG),y(C),x=null})});function w(C){const T=cn(o,E=>{C&&!E.atBottom&&E.notAtBottomBecause==="SIZE_INCREASED"&&!x&&(gt(d)("scrolling to bottom due to increased size",{},Bt.DEBUG),y("auto"))});setTimeout(T,100)}Qe(ee(wt(Ie(v),t,c),Ae(([C,,T])=>C&&T),Sn(({value:C},[,T])=>({refreshed:C===T,value:T}),{refreshed:!1,value:0}),Ae(({refreshed:C})=>C),Le(v,t)),([,C])=>{gt(a)&&w(C!==!1)}),Qe(g,()=>{w(gt(v)!==!1)}),Qe(wt(Ie(v),o),([C,T])=>{C&&!T.atBottom&&T.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&y("auto")});const S=oe(null),k=Ue();return ye(Ca(ee(Ie(r),he(C=>{var T;return(T=C==null?void 0:C.length)!=null?T:0})),ee(Ie(t))),k),Qe(ee(wt(ee(k,Zn(1)),l),Le(Ie(S),a,p,m),he(([[C,T],E,_,R,L])=>T&&_&&(E==null?void 0:E({context:L,totalCount:C,scrollingInProgress:R}))),Ae(C=>!!C),In(0)),C=>{x&&(x(),x=null),gt(n)?requestAnimationFrame(()=>{gt(d)("scrolling into view",{}),Re(f,C)}):x=cn(e,()=>{gt(d)("scrolling into view",{}),Re(f,C),x=null})}),{autoscrollToBottom:g,followOutput:v,scrollIntoViewOnChange:S}},lt(Cn,xo,po,ho,Fn,Ln,Ot,pp,hp)),JS=Ye(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(ye(ee(a,Le(s),Ae(([,l])=>l!==0),Le(o,r,t,n,e),he(([[,l],c,d,p,m,f=[]])=>up(l,c,d,p,m,f))),i),{}),lt(Cn,ho,tr,Fn),{singleton:!0}),ZS=Ye(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=oe(0);return Qe(ee(e,Le(r),Ae(([,o])=>o!==0),he(([,o])=>({top:o}))),o=>{cn(ee(n,Zn(1),Ae(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{Re(t,o)})})}),{initialScrollTop:r}},lt(Fn,Ot,tr),{singleton:!0}),gp=Ye(([{scrollVelocity:e}])=>{const t=oe(!1),n=Ue(),r=oe(!1);return ye(ee(e,Le(r,t,n),Ae(([o,s])=>!!s),he(([o,s,i,a])=>{const{enter:l,exit:c}=s;if(i){if(c(o,a))return!1}else if(l(o,a))return!0;return i}),ct()),t),Qe(ee(wt(t,e,n),Le(r)),([[o,s,i],a])=>{o&&a&&a.change&&a.change(s,i)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},lt(xo),{singleton:!0}),Da=Ye(([{scrollContainerState:e,scrollTo:t}])=>{const n=Ue(),r=Ue(),o=Ue(),s=oe(!1),i=oe(void 0);return ye(ee(wt(n,r),he(([{scrollHeight:a,scrollTop:l,viewportHeight:c},{offsetTop:d}])=>({scrollHeight:a,scrollTop:Math.max(0,l-d),viewportHeight:c}))),e),ye(ee(t,Le(r),he(([a,{offsetTop:l}])=>({...a,top:a.top+l}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},lt(Ot)),QS=Ye(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:a,windowViewportRect:l}])=>{const c=Ue(),d=oe(void 0),p=oe(null),m=oe(null);return ye(a,p),ye(l,m),Qe(ee(c,Le(t,r,i,p,m,n)),([f,v,g,x,y,w,S])=>{const k=DS(v.sizeTree);x&&y!==null&&w!==null&&(g=y.scrollTop-w.offsetTop),g-=S,f({ranges:k,scrollTop:g})}),ye(ee(d,Ae(ya),he(eC)),o),ye(ee(s,Le(d),Ae(([,f])=>f!==void 0),ct(),he(([,f])=>f.ranges)),e),{getState:c,restoreStateFrom:d}},lt(Cn,Ot,ho,Fn,Da));function eC(e){return{align:"start",index:0,offset:e.scrollTop}}const tC=Ye(([{topItemsIndexes:e}])=>{const t=oe(0);return ye(ee(t,Ae(n=>n>=0),he(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},lt(tr));function xp(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const nC=xp(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),rC=Ye(([{deviation:e,scrollBy:t,scrollingInProgress:n,scrollTop:r},{isAtBottom:o,isScrolling:s,lastJumpDueToItemResize:i,scrollDirection:a},{listState:l},{beforeUnshiftWith:c,gap:d,shiftWithOffset:p,sizes:m},{log:f},{recalcInProgress:v}])=>{const g=Xt(ee(l,Le(i),Sn(([,y,w,S],[{bottom:k,items:C,offsetBottom:T,totalCount:E},_])=>{const R=k+T;let L=0;return w===E&&y.length>0&&C.length>0&&(C[0].originalIndex===0&&y[0].originalIndex===0||(L=R-S,L!==0&&(L+=_))),[L,C,E,R]},[0,[],0,0]),Ae(([y])=>y!==0),Le(r,a,n,o,f,v),Ae(([,y,w,S,,,k])=>!k&&!S&&y!==0&&w===mo),he(([[y],,,,,w])=>(w("Upward scrolling compensation",{amount:y},Bt.DEBUG),y))));function x(y){y>0?(Re(t,{behavior:"auto",top:-y}),Re(e,0)):(Re(e,0),Re(t,{behavior:"auto",top:-y}))}return Qe(ee(g,Le(e,s)),([y,w,S])=>{S&&nC()?Re(e,w-y):x(-y)}),Qe(ee(wt(At(s,!1),e,v),Ae(([y,w,S])=>!y&&!S&&w!==0),he(([y,w])=>w),In(1)),x),ye(ee(p,he(y=>({top:-y}))),t),Qe(ee(c,Le(m,d),he(([y,{groupIndices:w,lastSize:S,sizeTree:k},C])=>{function T(E){return E*(S+C)}if(w.length===0)return T(y);{let E=0;const _=co(k,0);let R=0,L=0;for(;R<y;){R++,E+=_;let H=w.length===L+1?1/0:w[L+1]-w[L]-1;R+H>y&&(E-=_,H=y-R+1),R+=H,E+=T(H),L++}return E}})),y=>{Re(e,y),requestAnimationFrame(()=>{Re(t,{top:y}),requestAnimationFrame(()=>{Re(e,0),Re(v,!1)})})}),{deviation:e}},lt(Ot,xo,tr,Cn,Ln,Aa)),oC=Ye(([e,t,n,r,o,s,i,a,l,c,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...l,...c,...d}),lt(Ra,JS,Fn,gp,fp,ZS,qS,Da,hp,Ln,pp)),vp=Ye(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:r,gap:o,groupIndices:s,itemSize:i,sizeRanges:a,sizes:l,statefulTotalCount:c,totalCount:d,trackItemSizes:p},{initialItemFinalLocationReached:m,initialTopMostItemIndex:f,scrolledToInitialItem:v},g,x,y,{listState:w,topItemsIndexes:S,...k},{scrollToIndex:C},T,{topItemCount:E},{groupCounts:_},R])=>(ye(k.rangeChanged,R.scrollSeekRangeChanged),ye(ee(R.windowViewportRect,he(L=>L.visibleHeight)),g.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,gap:o,groupCounts:_,initialItemFinalLocationReached:m,initialTopMostItemIndex:f,scrolledToInitialItem:v,sizeRanges:a,topItemCount:E,topItemsIndexes:S,totalCount:d,...y,groupIndices:s,itemSize:i,listState:w,scrollToIndex:C,statefulTotalCount:c,trackItemSizes:p,...k,...R,...g,sizes:l,...x}),lt(Cn,ho,Ot,QS,XS,tr,po,rC,tC,op,oC));function sC(e,t){const n={},r={};let o=0;const s=e.length;for(;o<s;)r[e[o]]=1,o+=1;for(const i in t)Object.hasOwn(r,i)||(n[i]=t[i]);return n}const As=typeof document<"u"?b.useLayoutEffect:b.useEffect;function wp(e,t,n){const r=Object.keys(t.required||{}),o=Object.keys(t.optional||{}),s=Object.keys(t.methods||{}),i=Object.keys(t.events||{}),a=b.createContext({});function l(x,y){x.propsReady&&Re(x.propsReady,!1);for(const w of r){const S=x[t.required[w]];Re(S,y[w])}for(const w of o)if(w in y){const S=x[t.optional[w]];Re(S,y[w])}x.propsReady&&Re(x.propsReady,!0)}function c(x){return s.reduce((y,w)=>(y[w]=S=>{const k=x[t.methods[w]];Re(k,S)},y),{})}function d(x){return i.reduce((y,w)=>(y[w]=yS(x[t.events[w]]),y),{})}const p=b.forwardRef((x,y)=>{const{children:w,...S}=x,[k]=b.useState(()=>ys(CS(e),E=>{l(E,S)})),[C]=b.useState(Hf(d,k));As(()=>{for(const E of i)E in S&&Qe(C[E],S[E]);return()=>{Object.values(C).map(Sa)}},[S,C,k]),As(()=>{l(k,S)}),b.useImperativeHandle(y,Bf(c(k)));const T=n;return u.jsx(a.Provider,{value:k,children:n?u.jsx(T,{...sC([...r,...o,...i],S),children:w}):w})}),m=x=>{const y=b.useContext(a);return b.useCallback(w=>{Re(y[x],w)},[y,x])},f=x=>{const y=b.useContext(a)[x],w=b.useCallback(S=>Qe(y,S),[y]);return b.useSyncExternalStore(w,()=>gt(y),()=>gt(y))},v=x=>{const y=b.useContext(a)[x],[w,S]=b.useState(Hf(gt,y));return As(()=>Qe(y,k=>{k!==w&&S(Bf(k))}),[y,w]),w},g=b.version.startsWith("18")?f:v;return{Component:p,useEmitter:(x,y)=>{const w=b.useContext(a)[x];As(()=>Qe(w,y),[y,w])},useEmitterValue:g,usePublisher:m}}const bp=b.createContext(void 0),yp=b.createContext(void 0),Sp=typeof document<"u"?b.useLayoutEffect:b.useEffect;function La(e){return"self"in e}function iC(e){return"body"in e}function Cp(e,t,n,r=Ir,o,s){const i=b.useRef(null),a=b.useRef(null),l=b.useRef(null),c=b.useCallback(m=>{let f,v,g;const x=m.target;if(iC(x)||La(x)){const w=La(x)?x:x.defaultView;g=s?w.scrollX:w.scrollY,f=s?w.document.documentElement.scrollWidth:w.document.documentElement.scrollHeight,v=s?w.innerWidth:w.innerHeight}else g=s?x.scrollLeft:x.scrollTop,f=s?x.scrollWidth:x.scrollHeight,v=s?x.offsetWidth:x.offsetHeight;const y=()=>{e({scrollHeight:f,scrollTop:Math.max(g,0),viewportHeight:v})};m.suppressFlushSync?y():No.flushSync(y),a.current!==null&&(g===a.current||g<=0||g===f-v)&&(a.current=null,t(!0),l.current&&(clearTimeout(l.current),l.current=null))},[e,t,s]);b.useEffect(()=>{const m=o||i.current;return r(o||i.current),c({suppressFlushSync:!0,target:m}),m.addEventListener("scroll",c,{passive:!0}),()=>{r(null),m.removeEventListener("scroll",c)}},[i,c,n,r,o]);function d(m){const f=i.current;if(!f||(s?"offsetWidth"in f&&f.offsetWidth===0:"offsetHeight"in f&&f.offsetHeight===0))return;const v=m.behavior==="smooth";let g,x,y;La(f)?(x=Math.max($n(f.document.documentElement,s?"width":"height"),s?f.document.documentElement.scrollWidth:f.document.documentElement.scrollHeight),g=s?f.innerWidth:f.innerHeight,y=s?window.scrollX:window.scrollY):(x=f[s?"scrollWidth":"scrollHeight"],g=$n(f,s?"width":"height"),y=f[s?"scrollLeft":"scrollTop"]);const w=x-g;if(m.top=Math.ceil(Math.max(Math.min(w,m.top),0)),ip(g,x)||m.top===y){e({scrollHeight:x,scrollTop:y,viewportHeight:g}),v&&t(!0);return}v?(a.current=m.top,l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{l.current=null,a.current=null,t(!0)},1e3)):a.current=null,s&&(m={behavior:m.behavior,left:m.top}),f.scrollTo(m)}function p(m){s&&(m={behavior:m.behavior,left:m.top}),i.current.scrollBy(m)}return{scrollByCallback:p,scrollerRef:i,scrollToCallback:d}}const $a="-webkit-sticky",Tp="sticky",Fa=xp(()=>{if(typeof document>"u")return Tp;const e=document.createElement("div");return e.style.position=$a,e.style.position===$a?$a:Tp});function Ba(e){return e}const aC=Ye(()=>{const e=oe(a=>`Item ${a}`),t=oe(a=>`Group ${a}`),n=oe({}),r=oe(Ba),o=oe("div"),s=oe(Ir),i=(a,l=null)=>At(ee(n,he(c=>c[a]),ct()),l);return{components:n,computeItemKey:r,EmptyPlaceholder:i("EmptyPlaceholder"),FooterComponent:i("Footer"),GroupComponent:i("Group","div"),groupContent:t,HeaderComponent:i("Header"),HeaderFooterTag:o,ItemComponent:i("Item","div"),itemContent:e,ListComponent:i("List","div"),ScrollerComponent:i("Scroller","div"),scrollerRef:s,ScrollSeekPlaceholder:i("ScrollSeekPlaceholder"),TopItemListComponent:i("TopItemList")}}),lC=Ye(([e,t])=>({...e,...t}),lt(vp,aC)),cC=({height:e})=>u.jsx("div",{style:{height:e}}),uC={overflowAnchor:"none",position:Fa(),zIndex:1},kp={overflowAnchor:"none"},dC={...kp,display:"inline-block",height:"100%"},Ep=b.memo(function({showTopList:e=!1}){const t=_e("listState"),n=Qt("sizeRanges"),r=_e("useWindowScroll"),o=_e("customScrollParent"),s=Qt("windowScrollContainerState"),i=Qt("scrollContainerState"),a=o||r?s:i,l=_e("itemContent"),c=_e("context"),d=_e("groupContent"),p=_e("trackItemSizes"),m=_e("itemSize"),f=_e("log"),v=Qt("gap"),g=_e("horizontalDirection"),{callbackRef:x}=ES(n,m,p,e?Ir:a,f,v,o,g,_e("skipAnimationFrameInResizeObserver")),[y,w]=b.useState(0);za("deviation",I=>{y!==I&&w(I)});const S=_e("EmptyPlaceholder"),k=_e("ScrollSeekPlaceholder")||cC,C=_e("ListComponent"),T=_e("ItemComponent"),E=_e("GroupComponent"),_=_e("computeItemKey"),R=_e("isSeeking"),L=_e("groupIndices").length>0,H=_e("alignToBottom"),K=_e("initialItemFinalLocationReached"),F=e?{}:{boxSizing:"border-box",...g?{display:"inline-block",height:"100%",marginLeft:y!==0?y:H?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:y!==0?y:H?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...K?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&S?u.jsx(S,{...jt(S,c)}):u.jsx(C,{...jt(C,c),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:x,style:F,children:(e?t.topItems:t.items).map(I=>{const W=I.originalIndex,N=_(W+t.firstItemIndex,I.data,c);return R?b.createElement(k,{...jt(k,c),height:I.size,index:I.index,key:N,type:I.type||"item",...I.type==="group"?{}:{groupIndex:I.groupIndex}}):I.type==="group"?b.createElement(E,{...jt(E,c),"data-index":W,"data-item-index":I.index,"data-known-size":I.size,key:N,style:uC},d(I.index,c)):b.createElement(T,{...jt(T,c),...mC(T,I.data),"data-index":W,"data-item-group-index":I.groupIndex,"data-item-index":I.index,"data-known-size":I.size,key:N,style:g?dC:kp},L?l(I.index,I.groupIndex,I.data,c):l(I.index,I.data,c))})})}),fC={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},pC={outline:"none",overflowX:"auto",position:"relative"},js=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),hC={position:Fa(),top:0,width:"100%",zIndex:1};function jt(e,t){if(typeof e!="string")return{context:t}}function mC(e,t){return{item:typeof e=="string"?void 0:t}}const gC=b.memo(function(){const e=_e("HeaderComponent"),t=Qt("headerHeight"),n=_e("HeaderFooterTag"),r=Qn(b.useMemo(()=>s=>{t($n(s,"height"))},[t]),!0,_e("skipAnimationFrameInResizeObserver")),o=_e("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...jt(e,o)})}):null}),xC=b.memo(function(){const e=_e("FooterComponent"),t=Qt("footerHeight"),n=_e("HeaderFooterTag"),r=Qn(b.useMemo(()=>s=>{t($n(s,"height"))},[t]),!0,_e("skipAnimationFrameInResizeObserver")),o=_e("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...jt(e,o)})}):null});function Ip({useEmitter:e,useEmitterValue:t,usePublisher:n}){return b.memo(function({children:r,style:o,context:s,...i}){const a=n("scrollContainerState"),l=t("ScrollerComponent"),c=n("smoothScrollTargetReached"),d=t("scrollerRef"),p=t("horizontalDirection")||!1,{scrollByCallback:m,scrollerRef:f,scrollToCallback:v}=Cp(a,c,l,d,void 0,p);return e("scrollTo",v),e("scrollBy",m),u.jsx(l,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:f,style:{...p?pC:fC,...o},tabIndex:0,...i,...jt(l,s),children:r})})}function Np({useEmitter:e,useEmitterValue:t,usePublisher:n}){return b.memo(function({children:r,style:o,context:s,...i}){const a=n("windowScrollContainerState"),l=t("ScrollerComponent"),c=n("smoothScrollTargetReached"),d=t("totalListHeight"),p=t("deviation"),m=t("customScrollParent"),f=b.useRef(null),v=t("scrollerRef"),{scrollByCallback:g,scrollerRef:x,scrollToCallback:y}=Cp(a,c,l,v,m);return Sp(()=>{var w;return x.current=m||((w=f.current)==null?void 0:w.ownerDocument.defaultView),()=>{x.current=null}},[x,m]),e("windowScrollTo",y),e("scrollBy",g),u.jsx(l,{ref:f,"data-virtuoso-scroller":!0,style:{position:"relative",...o,...d!==0?{height:d+p}:{}},...i,...jt(l,s),children:r})})}const vC=({children:e})=>{const t=b.useContext(bp),n=Qt("viewportHeight"),r=Qt("fixedItemHeight"),o=_e("alignToBottom"),s=_e("horizontalDirection"),i=b.useMemo(()=>zf(n,l=>$n(l,s?"width":"height")),[n,s]),a=Qn(i,!0,_e("skipAnimationFrameInResizeObserver"));return b.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),u.jsx("div",{"data-viewport-type":"element",ref:a,style:js(o),children:e})},wC=({children:e})=>{const t=b.useContext(bp),n=Qt("windowViewportRect"),r=Qt("fixedItemHeight"),o=_e("customScrollParent"),s=Kf(n,o,_e("skipAnimationFrameInResizeObserver")),i=_e("alignToBottom");return b.useEffect(()=>{t&&(r(t.itemHeight),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),u.jsx("div",{"data-viewport-type":"window",ref:s,style:js(i),children:e})},bC=({children:e})=>{const t=_e("TopItemListComponent")||"div",n=_e("headerHeight"),r={...hC,marginTop:`${n}px`},o=_e("context");return u.jsx(t,{style:r,...jt(t,o),children:e})},yC=b.memo(function(e){const t=_e("useWindowScroll"),n=_e("topItemsIndexes").length>0,r=_e("customScrollParent"),o=_e("context");return u.jsxs(r||t?TC:CC,{...e,context:o,children:[n&&u.jsx(bC,{children:u.jsx(Ep,{showTopList:!0})}),u.jsxs(r||t?wC:vC,{children:[u.jsx(gC,{}),u.jsx(Ep,{}),u.jsx(xC,{})]})]})}),{Component:SC,useEmitter:za,useEmitterValue:_e,usePublisher:Qt}=wp(lC,{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"}},yC),CC=Ip({useEmitter:za,useEmitterValue:_e,usePublisher:Qt}),TC=Np({useEmitter:za,useEmitterValue:_e,usePublisher:Qt}),kC=SC;lt(vp,Ye(()=>{const e=oe(c=>u.jsxs("td",{children:["Item $",c]})),t=oe(null),n=oe(c=>u.jsxs("td",{colSpan:1e3,children:["Group ",c]})),r=oe(null),o=oe(null),s=oe({}),i=oe(Ba),a=oe(Ir),l=(c,d=null)=>At(ee(s,he(p=>p[c]),ct()),d);return{components:s,computeItemKey:i,context:t,EmptyPlaceholder:l("EmptyPlaceholder"),FillerRow:l("FillerRow"),fixedFooterContent:o,fixedHeaderContent:r,itemContent:e,groupContent:n,ScrollerComponent:l("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder"),TableBodyComponent:l("TableBody","tbody"),TableComponent:l("Table","table"),TableFooterComponent:l("TableFoot","tfoot"),TableHeadComponent:l("TableHead","thead"),TableRowComponent:l("TableRow","tr"),GroupComponent:l("Group","tr")}})),Fa();const Ap={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},EC={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:jp,floor:_s,max:vo,min:Ha,round:_p}=Math;function Pp(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function IC(e){return{...EC,items:e}}function Ps(e,t){return e&&e.width===t.width&&e.height===t.height}function NC(e,t){return e&&e.column===t.column&&e.row===t.row}const AC=Ye(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:r},{footerHeight:o,headerHeight:s,scrollBy:i,scrollContainerState:a,scrollTo:l,scrollTop:c,smoothScrollTargetReached:d,viewportHeight:p},m,f,{didMount:v,propsReady:g},{customScrollParent:x,useWindowScroll:y,windowScrollContainerState:w,windowScrollTo:S,windowViewportRect:k},C])=>{const T=oe(0),E=oe(0),_=oe(Ap),R=oe({height:0,width:0}),L=oe({height:0,width:0}),H=Ue(),K=Ue(),F=oe(0),I=oe(null),W=oe({column:0,row:0}),N=Ue(),U=Ue(),O=oe(!1),j=oe(0),q=oe(!0),J=oe(!1),P=oe(!1);Qe(ee(v,Le(j),Ae(([D,X])=>!!X)),()=>{Re(q,!1)}),Qe(ee(wt(v,q,L,R,j,J),Ae(([D,X,Q,ae,,$])=>D&&!X&&Q.height!==0&&ae.height!==0&&!$)),([,,,,D])=>{Re(J,!0),Pa(1,()=>{Re(H,D)}),cn(ee(c),()=>{Re(t,[0,0]),Re(q,!0)})}),ye(ee(U,Ae(D=>D!=null&&D.scrollTop>0),yn(0)),E),Qe(ee(v,Le(U),Ae(([,D])=>D!=null)),([,D])=>{D&&(Re(R,D.viewport),Re(L,D.item),Re(W,D.gap),D.scrollTop>0&&(Re(O,!0),cn(ee(c,Zn(1)),X=>{Re(O,!1)}),Re(l,{top:D.scrollTop})))}),ye(ee(R,he(({height:D})=>D)),p),ye(ee(wt(Ie(R,Ps),Ie(L,Ps),Ie(W,(D,X)=>D&&D.column===X.column&&D.row===X.row),Ie(c)),he(([D,X,Q,ae])=>({gap:Q,item:X,scrollTop:ae,viewport:D}))),N),ye(ee(wt(Ie(T),r,Ie(W,NC),Ie(L,Ps),Ie(R,Ps),Ie(I),Ie(E),Ie(O),Ie(q),Ie(j)),Ae(([,,,,,,,D])=>!D),he(([D,[X,Q],ae,$,re,we,de,,xe,Ee])=>{const{column:Be,row:We}=ae,{height:je,width:Ve}=$,{width:Xe}=re;if(de===0&&(D===0||Xe===0))return Ap;if(Ve===0){const Et=Ma(Ee,D),Dt=Et+Math.max(de-1,0);return IC(Pp(Et,Dt,we))}const ze=Mp(Xe,Ve,Be);let Ge,rt;xe?X===0&&Q===0&&de>0?(Ge=0,rt=de-1):(Ge=ze*_s((X+We)/(je+We)),rt=ze*jp((Q+We)/(je+We))-1,rt=Ha(D-1,vo(rt,ze-1)),Ge=Ha(rt,vo(0,Ge))):(Ge=0,rt=-1);const nt=Pp(Ge,rt,we),{bottom:et,top:xt}=Rp(re,ae,$,nt),vt=jp(D/ze),dt=vt*je+(vt-1)*We-et;return{bottom:et,itemHeight:je,items:nt,itemWidth:Ve,offsetBottom:dt,offsetTop:xt,top:xt}})),_),ye(ee(I,Ae(D=>D!==null),he(D=>D.length)),T),ye(ee(wt(R,L,_,W),Ae(([D,X,{items:Q}])=>Q.length>0&&X.height!==0&&D.height!==0),he(([D,X,{items:Q},ae])=>{const{bottom:$,top:re}=Rp(D,ae,X,Q);return[re,$]}),ct(uo)),t);const M=oe(!1);ye(ee(c,Le(M),he(([D,X])=>X||D!==0)),M);const G=Xt(ee(wt(_,T),Ae(([{items:D}])=>D.length>0),Le(M),Ae(([[D,X],Q])=>{const ae=D.items[D.items.length-1].index===X-1;return(Q||D.bottom>0&&D.itemHeight>0&&D.offsetBottom===0&&D.items.length===X)&&ae}),he(([[,D]])=>D-1),ct())),Z=Xt(ee(Ie(_),Ae(({items:D})=>D.length>0&&D[0].index===0),yn(0),ct())),se=Xt(ee(Ie(_),Le(O),Ae(([{items:D},X])=>D.length>0&&!X),he(([{items:D}])=>({endIndex:D[D.length-1].index,startIndex:D[0].index})),ct(Qf),In(0)));ye(se,f.scrollSeekRangeChanged),ye(ee(H,Le(R,L,T,W),he(([D,X,Q,ae,$])=>{const re=sp(D),{align:we,behavior:de,offset:xe}=re;let Ee=re.index;Ee==="LAST"&&(Ee=ae-1),Ee=vo(0,Ee,Ha(ae-1,Ee));let Be=Ua(X,$,Q,Ee);return we==="end"?Be=_p(Be-X.height+Q.height):we==="center"&&(Be=_p(Be-X.height/2+Q.height/2)),xe&&(Be+=xe),{behavior:de,top:Be}})),l);const V=At(ee(_,he(D=>D.offsetBottom+D.bottom)),0);return ye(ee(k,he(D=>({height:D.visibleHeight,width:D.visibleWidth}))),R),{customScrollParent:x,data:I,deviation:F,footerHeight:o,gap:W,headerHeight:s,increaseViewportBy:e,initialItemCount:E,itemDimensions:L,overscan:n,restoreStateFrom:U,scrollBy:i,scrollContainerState:a,scrollHeight:K,scrollTo:l,scrollToIndex:H,scrollTop:c,smoothScrollTargetReached:d,totalCount:T,useWindowScroll:y,viewportDimensions:R,windowScrollContainerState:w,windowScrollTo:S,windowViewportRect:k,...f,gridState:_,horizontalDirection:P,initialTopMostItemIndex:j,totalListHeight:V,...m,endReached:G,propsReady:g,rangeChanged:se,startReached:Z,stateChanged:N,stateRestoreInProgress:O,...C}},lt(Ra,Ot,xo,gp,Fn,Da,Ln));function Mp(e,t,n){return vo(1,_s((e+n)/(_s(t)+n)))}function Rp(e,t,n,r){const{height:o}=n;if(o===void 0||r.length===0)return{bottom:0,top:0};const s=Ua(e,t,n,r[0].index);return{bottom:Ua(e,t,n,r[r.length-1].index)+o,top:s}}function Ua(e,t,n,r){const o=Mp(e.width,n.width,t.column),s=_s(r/o),i=s*n.height+vo(0,s-1)*t.row;return i>0?i+t.row:i}const jC=Ye(()=>{const e=oe(p=>`Item ${p}`),t=oe({}),n=oe(null),r=oe("virtuoso-grid-item"),o=oe("virtuoso-grid-list"),s=oe(Ba),i=oe("div"),a=oe(Ir),l=(p,m=null)=>At(ee(t,he(f=>f[p]),ct()),m),c=oe(!1),d=oe(!1);return ye(Ie(d),c),{components:t,computeItemKey:s,context:n,FooterComponent:l("Footer"),HeaderComponent:l("Header"),headerFooterTag:i,itemClassName:r,ItemComponent:l("Item","div"),itemContent:e,listClassName:o,ListComponent:l("List","div"),readyStateChanged:c,reportReadyState:d,ScrollerComponent:l("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder","div")}}),_C=Ye(([e,t])=>({...e,...t}),lt(AC,jC)),PC=b.memo(function(){const e=ut("gridState"),t=ut("listClassName"),n=ut("itemClassName"),r=ut("itemContent"),o=ut("computeItemKey"),s=ut("isSeeking"),i=en("scrollHeight"),a=ut("ItemComponent"),l=ut("ListComponent"),c=ut("ScrollSeekPlaceholder"),d=ut("context"),p=en("itemDimensions"),m=en("gap"),f=ut("log"),v=ut("stateRestoreInProgress"),g=en("reportReadyState"),x=Qn(b.useMemo(()=>y=>{const w=y.parentElement.parentElement.scrollHeight;i(w);const S=y.firstChild;if(S){const{height:k,width:C}=S.getBoundingClientRect();p({height:k,width:C})}m({column:Dp("column-gap",getComputedStyle(y).columnGap,f),row:Dp("row-gap",getComputedStyle(y).rowGap,f)})},[i,p,m,f]),!0,!1);return Sp(()=>{e.itemHeight>0&&e.itemWidth>0&&g(!0)},[e]),v?null:u.jsx(l,{className:t,ref:x,...jt(l,d),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(y=>{const w=o(y.index,y.data,d);return s?u.jsx(c,{...jt(c,d),height:e.itemHeight,index:y.index,width:e.itemWidth},w):b.createElement(a,{...jt(a,d),className:n,"data-index":y.index,key:w},r(y.index,y.data,d))})})}),MC=b.memo(function(){const e=ut("HeaderComponent"),t=en("headerHeight"),n=ut("headerFooterTag"),r=Qn(b.useMemo(()=>s=>{t($n(s,"height"))},[t]),!0,!1),o=ut("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...jt(e,o)})}):null}),RC=b.memo(function(){const e=ut("FooterComponent"),t=en("footerHeight"),n=ut("headerFooterTag"),r=Qn(b.useMemo(()=>s=>{t($n(s,"height"))},[t]),!0,!1),o=ut("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...jt(e,o)})}):null}),OC=({children:e})=>{const t=b.useContext(yp),n=en("itemDimensions"),r=en("viewportDimensions"),o=Qn(b.useMemo(()=>s=>{r(s.getBoundingClientRect())},[r]),!0,!1);return b.useEffect(()=>{t&&(r({height:t.viewportHeight,width:t.viewportWidth}),n({height:t.itemHeight,width:t.itemWidth}))},[t,r,n]),u.jsx("div",{ref:o,style:js(!1),children:e})},DC=({children:e})=>{const t=b.useContext(yp),n=en("windowViewportRect"),r=en("itemDimensions"),o=ut("customScrollParent"),s=Kf(n,o,!1);return b.useEffect(()=>{t&&(r({height:t.itemHeight,width:t.itemWidth}),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:t.viewportWidth}))},[t,n,r]),u.jsx("div",{ref:s,style:js(!1),children:e})},LC=b.memo(function({...e}){const t=ut("useWindowScroll"),n=ut("customScrollParent"),r=n||t?FC:$C,o=n||t?DC:OC,s=ut("context");return u.jsx(r,{...e,...jt(r,s),children:u.jsxs(o,{children:[u.jsx(MC,{}),u.jsx(PC,{}),u.jsx(RC,{})]})})}),{useEmitter:Op,useEmitterValue:ut,usePublisher:en}=wp(_C,{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"}},LC),$C=Ip({useEmitter:Op,useEmitterValue:ut,usePublisher:en}),FC=Np({useEmitter:Op,useEmitterValue:ut,usePublisher:en});function Dp(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Bt.WARN),t==="normal"?0:parseInt(t??"0",10)}const BC=Dr.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 Lp({className:e,variant:t,...n}){return u.jsx("div",{className:ne(BC({variant:t}),e),...n})}var Ms="Dialog",[$p,i1]=sn(Ms),[zC,dn]=$p(Ms),Fp=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:i=!0}=e,a=h.useRef(null),l=h.useRef(null),[c,d]=_n({prop:r,defaultProp:o??!1,onChange:s,caller:Ms});return u.jsx(zC,{scope:t,triggerRef:a,contentRef:l,contentId:Nt(),titleId:Nt(),descriptionId:Nt(),open:c,onOpenChange:d,onOpenToggle:h.useCallback(()=>d(p=>!p),[d]),modal:i,children:n})};Fp.displayName=Ms;var Bp="DialogTrigger",zp=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=dn(Bp,n),s=De(t,o.triggerRef);return u.jsx(be.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Ka(o.open),...r,ref:s,onClick:ie(e.onClick,o.onOpenToggle)})});zp.displayName=Bp;var Wa="DialogPortal",[HC,Hp]=$p(Wa,{forceMount:void 0}),Up=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=dn(Wa,t);return u.jsx(HC,{scope:t,forceMount:n,children:h.Children.map(r,i=>u.jsx(Ft,{present:n||s.open,children:u.jsx(eo,{asChild:!0,container:o,children:i})}))})};Up.displayName=Wa;var Rs="DialogOverlay",Wp=h.forwardRef((e,t)=>{const n=Hp(Rs,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=dn(Rs,e.__scopeDialog);return s.modal?u.jsx(Ft,{present:r||s.open,children:u.jsx(WC,{...o,ref:t})}):null});Wp.displayName=Rs;var UC=Vt.createSlot("DialogOverlay.RemoveScroll"),WC=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=dn(Rs,n);return u.jsx(fs,{as:UC,allowPinchZoom:!0,shards:[o.contentRef],children:u.jsx(be.div,{"data-state":Ka(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),nr="DialogContent",Vp=h.forwardRef((e,t)=>{const n=Hp(nr,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=dn(nr,e.__scopeDialog);return u.jsx(Ft,{present:r||s.open,children:s.modal?u.jsx(VC,{...o,ref:t}):u.jsx(KC,{...o,ref:t})})});Vp.displayName=nr;var VC=h.forwardRef((e,t)=>{const n=dn(nr,e.__scopeDialog),r=h.useRef(null),o=De(t,n.contentRef,r);return h.useEffect(()=>{const s=r.current;if(s)return aa(s)},[]),u.jsx(Kp,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ie(e.onCloseAutoFocus,s=>{var i;s.preventDefault(),(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:ie(e.onPointerDownOutside,s=>{const i=s.detail.originalEvent,a=i.button===0&&i.ctrlKey===!0;(i.button===2||a)&&s.preventDefault()}),onFocusOutside:ie(e.onFocusOutside,s=>s.preventDefault())})}),KC=h.forwardRef((e,t)=>{const n=dn(nr,e.__scopeDialog),r=h.useRef(!1),o=h.useRef(!1);return u.jsx(Kp,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var i,a;(i=e.onCloseAutoFocus)==null||i.call(e,s),s.defaultPrevented||(r.current||(a=n.triggerRef.current)==null||a.focus(),s.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:s=>{var l,c;(l=e.onInteractOutside)==null||l.call(e,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const i=s.target;((c=n.triggerRef.current)==null?void 0:c.contains(i))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&o.current&&s.preventDefault()}})}),Kp=h.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=dn(nr,n),l=h.useRef(null),c=De(t,l);return $i(),u.jsxs(u.Fragment,{children:[u.jsx(qo,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:u.jsx(gr,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":Ka(a.open),...i,ref:c,onDismiss:()=>a.onOpenChange(!1)})}),u.jsxs(u.Fragment,{children:[u.jsx(qC,{titleId:a.titleId}),u.jsx(YC,{contentRef:l,descriptionId:a.descriptionId})]})]})}),Va="DialogTitle",qp=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=dn(Va,n);return u.jsx(be.h2,{id:o.titleId,...r,ref:t})});qp.displayName=Va;var Gp="DialogDescription",Yp=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=dn(Gp,n);return u.jsx(be.p,{id:o.descriptionId,...r,ref:t})});Yp.displayName=Gp;var Xp="DialogClose",Jp=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=dn(Xp,n);return u.jsx(be.button,{type:"button",...r,ref:t,onClick:ie(e.onClick,()=>o.onOpenChange(!1))})});Jp.displayName=Xp;function Ka(e){return e?"open":"closed"}var Zp="DialogTitleWarning",[a1,Qp]=cw(Zp,{contentName:nr,titleName:Va,docsSlug:"dialog"}),qC=({titleId:e})=>{const t=Qp(Zp),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
79
+ `)},Xy=0,kr=[];function Jy(e){var t=h.useRef([]),n=h.useRef([0,0]),r=h.useRef(),o=h.useState(Xy++)[0],s=h.useState(Od)[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=vy([e.lockRef.current],(e.shards||[]).map(Hd),!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=ds(g),w=n.current,S="deltaX"in g?g.deltaX:w[0]-y[0],k="deltaY"in g?g.deltaY:w[1]-y[1],C,T=g.target,E=Math.abs(S)>Math.abs(k)?"h":"v";if("touches"in g&&E==="h"&&T.type==="range")return!1;var _=$d(E,T);if(!_)return!0;if(_?C=E:(C=E==="v"?"h":"v",_=$d(E,T)),!_)return!1;if(!r.current&&"changedTouches"in g&&(S||k)&&(r.current=C),!C)return!0;var R=r.current||C;return qy(R,x,g,R==="h"?S:k)},[]),l=h.useCallback(function(g){var x=g;if(!(!kr.length||kr[kr.length-1]!==s)){var y="deltaY"in x?zd(x):ds(x),w=t.current.filter(function(C){return C.name===x.type&&(C.target===x.target||x.target===C.shadowParent)&&Gy(C.delta,y)})[0];if(w&&w.should){x.cancelable&&x.preventDefault();return}if(!w){var S=(i.current.shards||[]).map(Hd).filter(Boolean).filter(function(C){return C.contains(x.target)}),k=S.length>0?a(x,S[0]):!i.current.noIsolation;k&&x.cancelable&&x.preventDefault()}}},[]),c=h.useCallback(function(g,x,y,w){var S={name:g,delta:x,target:y,should:w,shadowParent:Zy(y)};t.current.push(S),setTimeout(function(){t.current=t.current.filter(function(k){return k!==S})},1)},[]),d=h.useCallback(function(g){n.current=ds(g),r.current=void 0},[]),p=h.useCallback(function(g){c(g.type,zd(g),g.target,a(g,e.lockRef.current))},[]),m=h.useCallback(function(g){c(g.type,ds(g),g.target,a(g,e.lockRef.current))},[]);h.useEffect(function(){return kr.push(s),e.setCallbacks({onScrollCapture:p,onWheelCapture:p,onTouchMoveCapture:m}),document.addEventListener("wheel",l,Tr),document.addEventListener("touchmove",l,Tr),document.addEventListener("touchstart",d,Tr),function(){kr=kr.filter(function(g){return g!==s}),document.removeEventListener("wheel",l,Tr),document.removeEventListener("touchmove",l,Tr),document.removeEventListener("touchstart",d,Tr)}},[]);var f=e.removeScrollBar,v=e.inert;return h.createElement(h.Fragment,null,v?h.createElement(s,{styles:Yy(o)}):null,f?h.createElement(By,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Zy(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const Qy=Iy(Rd,Jy);var fs=h.forwardRef(function(e,t){return h.createElement(cs,bn({},e,{ref:t,sideCar:Qy}))});fs.classNames=cs.classNames;var fa=["Enter"," "],e0=["ArrowDown","PageUp","Home"],Ud=["ArrowUp","PageDown","End"],t0=[...e0,...Ud],n0={ltr:[...fa,"ArrowRight"],rtl:[...fa,"ArrowLeft"]},r0={ltr:["ArrowLeft"],rtl:["ArrowRight"]},no="Menu",[ro,o0,s0]=Vo(no),[Xn,Wd]=sn(no,[s0,yr,kd]),ps=yr(),Vd=kd(),[i0,Jn]=Xn(no),[a0,oo]=Xn(no),Kd=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=ps(t),[l,c]=h.useState(null),d=h.useRef(!1),p=mt(s),m=Ko(o);return h.useEffect(()=>{const f=()=>{d.current=!0,document.addEventListener("pointerdown",v,{capture:!0,once:!0}),document.addEventListener("pointermove",v,{capture:!0,once:!0})},v=()=>d.current=!1;return document.addEventListener("keydown",f,{capture:!0}),()=>{document.removeEventListener("keydown",f,{capture:!0}),document.removeEventListener("pointerdown",v,{capture:!0}),document.removeEventListener("pointermove",v,{capture:!0})}},[]),u.jsx(ea,{...a,children:u.jsx(i0,{scope:t,open:n,onOpenChange:p,content:l,onContentChange:c,children:u.jsx(a0,{scope:t,onClose:h.useCallback(()=>p(!1),[p]),isUsingKeyboardRef:d,dir:m,modal:i,children:r})})})};Kd.displayName=no;var l0="MenuAnchor",pa=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=ps(n);return u.jsx(ta,{...o,...r,ref:t})});pa.displayName=l0;var ha="MenuPortal",[c0,qd]=Xn(ha,{forceMount:void 0}),Gd=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=Jn(ha,t);return u.jsx(c0,{scope:t,forceMount:n,children:u.jsx(Ft,{present:n||s.open,children:u.jsx(eo,{asChild:!0,container:o,children:r})})})};Gd.displayName=ha;var Zt="MenuContent",[u0,ma]=Xn(Zt),Yd=h.forwardRef((e,t)=>{const n=qd(Zt,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=Jn(Zt,e.__scopeMenu),i=oo(Zt,e.__scopeMenu);return u.jsx(ro.Provider,{scope:e.__scopeMenu,children:u.jsx(Ft,{present:r||s.open,children:u.jsx(ro.Slot,{scope:e.__scopeMenu,children:i.modal?u.jsx(d0,{...o,ref:t}):u.jsx(f0,{...o,ref:t})})})})}),d0=h.forwardRef((e,t)=>{const n=Jn(Zt,e.__scopeMenu),r=h.useRef(null),o=De(t,r);return h.useEffect(()=>{const s=r.current;if(s)return aa(s)},[]),u.jsx(ga,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:ie(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),f0=h.forwardRef((e,t)=>{const n=Jn(Zt,e.__scopeMenu);return u.jsx(ga,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),p0=Vt.createSlot("MenuContent.ScrollLock"),ga=h.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:p,onInteractOutside:m,onDismiss:f,disableOutsideScroll:v,...g}=e,x=Jn(Zt,n),y=oo(Zt,n),w=ps(n),S=Vd(n),k=o0(n),[C,T]=h.useState(null),E=h.useRef(null),_=De(t,E,x.onContentChange),R=h.useRef(0),L=h.useRef(""),H=h.useRef(0),K=h.useRef(null),B=h.useRef("right"),I=h.useRef(0),W=v?fs:h.Fragment,N=v?{as:p0,allowPinchZoom:!0}:void 0,U=j=>{var V,D;const q=L.current+j,J=k().filter(X=>!X.disabled),P=document.activeElement,M=(V=J.find(X=>X.ref.current===P))==null?void 0:V.textValue,G=J.map(X=>X.textValue),Z=k0(G,q,M),se=(D=J.find(X=>X.textValue===Z))==null?void 0:D.ref.current;(function X(Q){L.current=Q,window.clearTimeout(R.current),Q!==""&&(R.current=window.setTimeout(()=>X(""),1e3))})(q),se&&setTimeout(()=>se.focus())};h.useEffect(()=>()=>window.clearTimeout(R.current),[]),$i();const O=h.useCallback(j=>{var J,P;return B.current===((J=K.current)==null?void 0:J.side)&&I0(j,(P=K.current)==null?void 0:P.area)},[]);return u.jsx(u0,{scope:n,searchRef:L,onItemEnter:h.useCallback(j=>{O(j)&&j.preventDefault()},[O]),onItemLeave:h.useCallback(j=>{var q;O(j)||((q=E.current)==null||q.focus(),T(null))},[O]),onTriggerLeave:h.useCallback(j=>{O(j)&&j.preventDefault()},[O]),pointerGraceTimerRef:H,onPointerGraceIntentChange:h.useCallback(j=>{K.current=j},[]),children:u.jsx(W,{...N,children:u.jsx(qo,{asChild:!0,trapped:o,onMountAutoFocus:ie(s,j=>{var q;j.preventDefault(),(q=E.current)==null||q.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:u.jsx(gr,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:p,onInteractOutside:m,onDismiss:f,children:u.jsx(py,{asChild:!0,...S,dir:y.dir,orientation:"vertical",loop:r,currentTabStopId:C,onCurrentTabStopIdChange:T,onEntryFocus:ie(l,j=>{y.isUsingKeyboardRef.current||j.preventDefault()}),preventScrollOnEntryFocus:!0,children:u.jsx(na,{role:"menu","aria-orientation":"vertical","data-state":pf(x.open),"data-radix-menu-content":"",dir:y.dir,...w,...g,ref:_,style:{outline:"none",...g.style},onKeyDown:ie(g.onKeyDown,j=>{const J=j.target.closest("[data-radix-menu-content]")===j.currentTarget,P=j.ctrlKey||j.altKey||j.metaKey,M=j.key.length===1;J&&(j.key==="Tab"&&j.preventDefault(),!P&&M&&U(j.key));const G=E.current;if(j.target!==G||!t0.includes(j.key))return;j.preventDefault();const se=k().filter(V=>!V.disabled).map(V=>V.ref.current);Ud.includes(j.key)&&se.reverse(),C0(se)}),onBlur:ie(e.onBlur,j=>{j.currentTarget.contains(j.target)||(window.clearTimeout(R.current),L.current="")}),onPointerMove:ie(e.onPointerMove,io(j=>{const q=j.target,J=I.current!==j.clientX;if(j.currentTarget.contains(q)&&J){const P=j.clientX>I.current?"right":"left";B.current=P,I.current=j.clientX}}))})})})})})})});Yd.displayName=Zt;var h0="MenuGroup",xa=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(be.div,{role:"group",...r,ref:t})});xa.displayName=h0;var m0="MenuLabel",Xd=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(be.div,{...r,ref:t})});Xd.displayName=m0;var hs="MenuItem",Jd="menu.itemSelect",ms=h.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=h.useRef(null),i=oo(hs,e.__scopeMenu),a=ma(hs,e.__scopeMenu),l=De(t,s),c=h.useRef(!1),d=()=>{const p=s.current;if(!n&&p){const m=new CustomEvent(Jd,{bubbles:!0,cancelable:!0});p.addEventListener(Jd,f=>r==null?void 0:r(f),{once:!0}),Oi(p,m),m.defaultPrevented?c.current=!1:i.onClose()}};return u.jsx(Zd,{...o,ref:l,disabled:n,onClick:ie(e.onClick,d),onPointerDown:p=>{var m;(m=e.onPointerDown)==null||m.call(e,p),c.current=!0},onPointerUp:ie(e.onPointerUp,p=>{var m;c.current||(m=p.currentTarget)==null||m.click()}),onKeyDown:ie(e.onKeyDown,p=>{const m=a.searchRef.current!=="";n||m&&p.key===" "||fa.includes(p.key)&&(p.currentTarget.click(),p.preventDefault())})})});ms.displayName=hs;var Zd=h.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=ma(hs,n),a=Vd(n),l=h.useRef(null),c=De(t,l),[d,p]=h.useState(!1),[m,f]=h.useState("");return h.useEffect(()=>{const v=l.current;v&&f((v.textContent??"").trim())},[s.children]),u.jsx(ro.ItemSlot,{scope:n,disabled:r,textValue:o??m,children:u.jsx(hy,{asChild:!0,...a,focusable:!r,children:u.jsx(be.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:c,onPointerMove:ie(e.onPointerMove,io(v=>{r?i.onItemLeave(v):(i.onItemEnter(v),v.defaultPrevented||v.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:ie(e.onPointerLeave,io(v=>i.onItemLeave(v))),onFocus:ie(e.onFocus,()=>p(!0)),onBlur:ie(e.onBlur,()=>p(!1))})})})}),g0="MenuCheckboxItem",Qd=h.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return u.jsx(of,{scope:e.__scopeMenu,checked:n,children:u.jsx(ms,{role:"menuitemcheckbox","aria-checked":gs(n)?"mixed":n,...o,ref:t,"data-state":wa(n),onSelect:ie(o.onSelect,()=>r==null?void 0:r(gs(n)?!0:!n),{checkForDefaultPrevented:!1})})})});Qd.displayName=g0;var ef="MenuRadioGroup",[x0,v0]=Xn(ef,{value:void 0,onValueChange:()=>{}}),tf=h.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=mt(r);return u.jsx(x0,{scope:e.__scopeMenu,value:n,onValueChange:s,children:u.jsx(xa,{...o,ref:t})})});tf.displayName=ef;var nf="MenuRadioItem",rf=h.forwardRef((e,t)=>{const{value:n,...r}=e,o=v0(nf,e.__scopeMenu),s=n===o.value;return u.jsx(of,{scope:e.__scopeMenu,checked:s,children:u.jsx(ms,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":wa(s),onSelect:ie(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});rf.displayName=nf;var va="MenuItemIndicator",[of,w0]=Xn(va,{checked:!1}),sf=h.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=w0(va,n);return u.jsx(Ft,{present:r||gs(s.checked)||s.checked===!0,children:u.jsx(be.span,{...o,ref:t,"data-state":wa(s.checked)})})});sf.displayName=va;var b0="MenuSeparator",af=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(be.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});af.displayName=b0;var y0="MenuArrow",lf=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=ps(n);return u.jsx(ra,{...o,...r,ref:t})});lf.displayName=y0;var S0="MenuSub",[r1,cf]=Xn(S0),so="MenuSubTrigger",uf=h.forwardRef((e,t)=>{const n=Jn(so,e.__scopeMenu),r=oo(so,e.__scopeMenu),o=cf(so,e.__scopeMenu),s=ma(so,e.__scopeMenu),i=h.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,c={__scopeMenu:e.__scopeMenu},d=h.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return h.useEffect(()=>d,[d]),h.useEffect(()=>{const p=a.current;return()=>{window.clearTimeout(p),l(null)}},[a,l]),u.jsx(pa,{asChild:!0,...c,children:u.jsx(Zd,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":pf(n.open),...e,ref:jn(t,o.onTriggerChange),onClick:p=>{var m;(m=e.onClick)==null||m.call(e,p),!(e.disabled||p.defaultPrevented)&&(p.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:ie(e.onPointerMove,io(p=>{s.onItemEnter(p),!p.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(s.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),d()},100))})),onPointerLeave:ie(e.onPointerLeave,io(p=>{var f,v;d();const m=(f=n.content)==null?void 0:f.getBoundingClientRect();if(m){const g=(v=n.content)==null?void 0:v.dataset.side,x=g==="right",y=x?-5:5,w=m[x?"left":"right"],S=m[x?"right":"left"];s.onPointerGraceIntentChange({area:[{x:p.clientX+y,y:p.clientY},{x:w,y:m.top},{x:S,y:m.top},{x:S,y:m.bottom},{x:w,y:m.bottom}],side:g}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(p),p.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:ie(e.onKeyDown,p=>{var f;const m=s.searchRef.current!=="";e.disabled||m&&p.key===" "||n0[r.dir].includes(p.key)&&(n.onOpenChange(!0),(f=n.content)==null||f.focus(),p.preventDefault())})})})});uf.displayName=so;var df="MenuSubContent",ff=h.forwardRef((e,t)=>{const n=qd(Zt,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=Jn(Zt,e.__scopeMenu),i=oo(Zt,e.__scopeMenu),a=cf(df,e.__scopeMenu),l=h.useRef(null),c=De(t,l);return u.jsx(ro.Provider,{scope:e.__scopeMenu,children:u.jsx(Ft,{present:r||s.open,children:u.jsx(ro.Slot,{scope:e.__scopeMenu,children:u.jsx(ga,{id:a.contentId,"aria-labelledby":a.triggerId,...o,ref:c,align:"start",side:i.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:d=>{var p;i.isUsingKeyboardRef.current&&((p=l.current)==null||p.focus()),d.preventDefault()},onCloseAutoFocus:d=>d.preventDefault(),onFocusOutside:ie(e.onFocusOutside,d=>{d.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:ie(e.onEscapeKeyDown,d=>{i.onClose(),d.preventDefault()}),onKeyDown:ie(e.onKeyDown,d=>{var f;const p=d.currentTarget.contains(d.target),m=r0[i.dir].includes(d.key);p&&m&&(s.onOpenChange(!1),(f=a.trigger)==null||f.focus(),d.preventDefault())})})})})})});ff.displayName=df;function pf(e){return e?"open":"closed"}function gs(e){return e==="indeterminate"}function wa(e){return gs(e)?"indeterminate":e?"checked":"unchecked"}function C0(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function T0(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function k0(e,t,n){const o=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=T0(e,Math.max(s,0));o.length===1&&(i=i.filter(c=>c!==n));const l=i.find(c=>c.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function E0(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const a=t[s],l=t[i],c=a.x,d=a.y,p=l.x,m=l.y;d>r!=m>r&&n<(p-c)*(r-d)/(m-d)+c&&(o=!o)}return o}function I0(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return E0(n,t)}function io(e){return t=>t.pointerType==="mouse"?e(t):void 0}var N0=Kd,A0=pa,j0=Gd,_0=Yd,P0=xa,M0=Xd,R0=ms,O0=Qd,D0=tf,L0=rf,$0=sf,F0=af,B0=lf,z0=uf,H0=ff,xs="DropdownMenu",[U0,o1]=sn(xs,[Wd]),Rt=Wd(),[W0,hf]=U0(xs),mf=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,l=Rt(t),c=h.useRef(null),[d,p]=_n({prop:o,defaultProp:s??!1,onChange:i,caller:xs});return u.jsx(W0,{scope:t,triggerId:Nt(),triggerRef:c,contentId:Nt(),open:d,onOpenChange:p,onOpenToggle:h.useCallback(()=>p(m=>!m),[p]),modal:a,children:u.jsx(N0,{...l,open:d,onOpenChange:p,dir:r,modal:a,children:n})})};mf.displayName=xs;var gf="DropdownMenuTrigger",xf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=hf(gf,n),i=Rt(n);return u.jsx(A0,{asChild:!0,...i,children:u.jsx(be.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:jn(t,s.triggerRef),onPointerDown:ie(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:ie(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});xf.displayName=gf;var V0="DropdownMenuPortal",vf=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Rt(t);return u.jsx(j0,{...r,...n})};vf.displayName=V0;var wf="DropdownMenuContent",bf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=hf(wf,n),s=Rt(n),i=h.useRef(!1);return u.jsx(_0,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:ie(e.onCloseAutoFocus,a=>{var l;i.current||(l=o.triggerRef.current)==null||l.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:ie(e.onInteractOutside,a=>{const l=a.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0,d=l.button===2||c;(!o.modal||d)&&(i.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});bf.displayName=wf;var K0="DropdownMenuGroup",q0=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Rt(n);return u.jsx(P0,{...o,...r,ref:t})});q0.displayName=K0;var G0="DropdownMenuLabel",yf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Rt(n);return u.jsx(M0,{...o,...r,ref:t})});yf.displayName=G0;var Y0="DropdownMenuItem",Sf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Rt(n);return u.jsx(R0,{...o,...r,ref:t})});Sf.displayName=Y0;var X0="DropdownMenuCheckboxItem",Cf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Rt(n);return u.jsx(O0,{...o,...r,ref:t})});Cf.displayName=X0;var J0="DropdownMenuRadioGroup",Z0=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Rt(n);return u.jsx(D0,{...o,...r,ref:t})});Z0.displayName=J0;var Q0="DropdownMenuRadioItem",Tf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Rt(n);return u.jsx(L0,{...o,...r,ref:t})});Tf.displayName=Q0;var eS="DropdownMenuItemIndicator",kf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Rt(n);return u.jsx($0,{...o,...r,ref:t})});kf.displayName=eS;var tS="DropdownMenuSeparator",Ef=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Rt(n);return u.jsx(F0,{...o,...r,ref:t})});Ef.displayName=tS;var nS="DropdownMenuArrow",rS=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Rt(n);return u.jsx(B0,{...o,...r,ref:t})});rS.displayName=nS;var oS="DropdownMenuSubTrigger",If=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Rt(n);return u.jsx(z0,{...o,...r,ref:t})});If.displayName=oS;var sS="DropdownMenuSubContent",Nf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Rt(n);return u.jsx(H0,{...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)"}})});Nf.displayName=sS;var iS=mf,aS=xf,lS=vf,Af=bf,jf=yf,_f=Sf,Pf=Cf,Mf=Tf,Rf=kf,Of=Ef,Df=If,Lf=Nf;const vs=iS,ws=aS,cS=h.forwardRef(({className:e,inset:t,children:n,...r},o)=>u.jsxs(Df,{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(ue.ChevronRight,{className:"ml-auto h-4 w-4"})]}));cS.displayName=Df.displayName;const uS=h.forwardRef(({className:e,...t},n)=>u.jsx(Lf,{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}));uS.displayName=Lf.displayName;const ao=h.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(lS,{children:u.jsx(Af,{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})}));ao.displayName=Af.displayName;const On=h.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(_f,{ref:r,className:ne("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...n}));On.displayName=_f.displayName;const dS=h.forwardRef(({className:e,children:t,checked:n,...r},o)=>u.jsxs(Pf,{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(Rf,{children:u.jsx(ue.Check,{className:"h-4 w-4"})})}),t]}));dS.displayName=Pf.displayName;const fS=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Mf,{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(Rf,{children:u.jsx(ue.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));fS.displayName=Mf.displayName;const pS=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}));pS.displayName=jf.displayName;const hS=h.forwardRef(({className:e,...t},n)=>u.jsx(Of,{ref:n,className:ne("-mx-1 my-1 h-px bg-muted",e),...t}));hS.displayName=Of.displayName;const ba=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}));ba.displayName="Textarea";const mS=1e4;function $f({initialValue:e="",editingMessageId:t=null,placeholder:n="Type your message...",isStreaming:r=!1,disabled:o=!1,maxLength:s=mS,value:i,onValueChange:a,onSend:l,onCancelEdit:c,onStop:d,className:p="",textareaClassName:m="",allowEmptySend:f=!1,validate:v,onValidationError:g}){const x=i!==void 0,[y,w]=b.useState(e),S=(x?i:y)??"",[k,C]=b.useTransition(),T=b.useRef(null),E=b.useRef(0),_=b.useRef(null),R=b.useRef("");b.useEffect(()=>{x||(w(e??""),_.current=null,T.current&&(T.current.style.height="auto",T.current.style.height=`${T.current.scrollHeight}px`))},[e,t,x]);const[L,H]=b.useState(null),K=b.useCallback(M=>M.length>s?`Message too long (${M.length}/${s} characters)`:null,[s]),B=b.useMemo(()=>v??K,[v,K]),I=b.useCallback(M=>{const G=B(M);return H(G),g==null||g(G),R.current=M,G},[B,g]),W=b.useCallback(()=>{const M=T.current;M&&(M.style.height="auto",M.style.height=`${M.scrollHeight}px`)},[]);b.useEffect(()=>{W()},[W,S]),b.useEffect(()=>{if(!L)return;const M=(S??"").trim();R.current!==M&&I(M)},[S,L,I]);const N=b.useCallback((M,{fromUser:G})=>{x||w(M),G&&(a==null||a(M))},[x,a]),U=b.useCallback(async M=>{M&&M.preventDefault();const G=(S??"").trim();if(!G&&!f||I(G))return;const Z=++E.current;_.current={id:Z,shouldClear:!0},C(()=>{var se,V,D;try{const X=l(G);X&&typeof X.then=="function"?X.then(()=>{var Q,ae;((Q=_.current)==null?void 0:Q.id)===Z&&_.current.shouldClear&&(x||(w(""),T.current&&(T.current.style.height="auto"),a==null||a(""))),((ae=_.current)==null?void 0:ae.id)===Z&&(_.current=null)}).catch(()=>{var Q;((Q=_.current)==null?void 0:Q.id)===Z&&(_.current=null)}):(((se=_.current)==null?void 0:se.id)===Z&&_.current.shouldClear&&(x||(w(""),T.current&&(T.current.style.height="auto"),a==null||a(""))),((V=_.current)==null?void 0:V.id)===Z&&(_.current=null))}catch{((D=_.current)==null?void 0:D.id)===Z&&(_.current=null)}})},[S,l,f,x,a,I]),O=b.useCallback(M=>{const G=M.target.value;N(G,{fromUser:!0}),_.current&&(_.current.shouldClear=!1),T.current&&(T.current.style.height="auto",T.current.style.height=`${T.current.scrollHeight}px`),L&&I(G.trim())},[N,I,L]),j=b.useCallback(M=>{M.key==="Enter"&&!M.shiftKey?(M.preventDefault(),U()):M.key==="Escape"&&t&&(M.preventDefault(),c==null||c())},[U,t,c]),P=`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${t?"border-[hsl(var(--ring))] bg-[hsl(var(--card))] text-[hsl(var(--card-foreground))] dark:bg-[hsl(var(--card))] dark:text-[hsl(var(--card-foreground))]":""} ${m}`;return u.jsx("form",{onSubmit:M=>void U(M),className:`w-full ${p}`,children:u.jsxs("div",{className:"flex items-end gap-2",children:[u.jsxs("div",{className:"flex-1",children:[u.jsx(ba,{ref:T,value:S,onChange:O,onKeyDown:j,placeholder:t?"Edit your message...":n,className:P,disabled:o,maxLength:s,rows:1,spellCheck:!1,autoCorrect:"off"}),L&&u.jsx("p",{className:"mt-1 text-xs text-destructive font-medium",children:L})]}),u.jsx("div",{children:r?u.jsx(at,{type:"button",onClick:()=>{d==null||d()},size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",disabled:o||!d,children:u.jsx(ue.Square,{size:16})}):u.jsx(at,{type:"submit",size:"icon",className:"shrink-0",title:t?"Save changes":"Send message",disabled:o||!S.trim()&&!f||k,children:u.jsx(ue.Send,{size:16})})})]})})}const gS=b.memo($f),bs=0,Dn=1,Er=2,Ff=4;function Bf(e){return()=>e}function xS(e){e()}function zf(e,t){return n=>e(t(n))}function Hf(e,t){return()=>e(t)}function vS(e,t){return n=>e(t,n)}function ya(e){return e!==void 0}function wS(...e){return()=>{e.map(xS)}}function Ir(){}function ys(e,t){return t(e),e}function bS(e,t){return t(e)}function lt(...e){return e}function Qe(e,t){return e(Dn,t)}function Re(e,t){e(bs,t)}function Sa(e){e(Er)}function gt(e){return e(Ff)}function ye(e,t){return Qe(e,vS(t,bs))}function cn(e,t){const n=e(Dn,r=>{n(),t(r)});return n}function Uf(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function Wf(e,t){return e===t}function ct(e=Wf){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function Ae(e){return t=>n=>{e(n)&&t(n)}}function he(e){return t=>zf(t,e)}function yn(e){return t=>()=>{t(e)}}function ee(e,...t){const n=yS(...t);return(r,o)=>{switch(r){case Er:Sa(e);return;case Dn:return Qe(e,n(o))}}}function Sn(e,t){return n=>r=>{n(t=e(t,r))}}function Zn(e){return t=>n=>{e>0?e--:t(n)}}function In(e){let t=null,n;return r=>o=>{t=o,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function Le(...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);Qe(s,l=>{const c=n;n=n|a,t[i]=l,c!==o&&n===o&&r&&(r(),r=null)})}),s=>i=>{const a=()=>{s([i].concat(t))};n===o?a():r=a}}function yS(...e){return t=>e.reduceRight(bS,t)}function SS(e){let t,n;const r=()=>t==null?void 0:t();return function(o,s){switch(o){case Dn:return s?n===s?void 0:(r(),n=s,t=Qe(e,s),t):(r(),Ir);case Er:r(),n=null;return}}}function oe(e){let t=e;const n=Ue();return(r,o)=>{switch(r){case bs:t=o;break;case Dn:{o(t);break}case Ff:return t}return n(r,o)}}function At(e,t){return ys(oe(t),n=>ye(e,n))}function Ue(){const e=[];return(t,n)=>{switch(t){case bs:e.slice().forEach(r=>{r(n)});return;case Er:e.splice(0,e.length);return;case Dn:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}}}function Xt(e){return ys(Ue(),t=>ye(e,t))}function Ye(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:CS(),singleton:n}}const CS=()=>Symbol();function TS(e){const t=new Map,n=({constructor:r,dependencies:o,id:s,singleton:i})=>{if(i&&t.has(s))return t.get(s);const a=r(o.map(l=>n(l)));return i&&t.set(s,a),a};return n(e)}function wt(...e){const t=Ue(),n=new Array(e.length);let r=0;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const a=Math.pow(2,i);Qe(s,l=>{n[i]=l,r=r|a,r===o&&Re(t,n)})}),function(s,i){switch(s){case Er:{Sa(t);return}case Dn:return r===o&&i(n),Qe(t,i)}}}function Ie(e,t=Wf){return ee(e,ct(t))}function Ca(...e){return function(t,n){switch(t){case Er:return;case Dn:return wS(...e.map(r=>Qe(r,n)))}}}var Bt=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(Bt||{});const kS={0:"debug",3:"error",1:"log",2:"warn"},ES=()=>typeof globalThis>"u"?window:globalThis,Ln=Ye(()=>{const e=oe(3);return{log:oe((t,n,r=1)=>{var o;const s=(o=ES().VIRTUOSO_LOG_LEVEL)!=null?o:gt(e);r>=s&&console[kS[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0});function Qn(e,t,n){return Ta(e,t,n).callbackRef}function Ta(e,t,n){const r=b.useRef(null);let o=i=>{};const s=b.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(i=>{const a=()=>{const l=i[0].target;l.offsetParent!==null&&e(l)};n?a():requestAnimationFrame(a)}):null,[e,n]);return o=i=>{i&&t?(s==null||s.observe(i),r.current=i):(r.current&&(s==null||s.unobserve(r.current)),r.current=null)},{callbackRef:o,ref:r}}function IS(e,t,n,r,o,s,i,a,l){const c=b.useCallback(d=>{const p=NS(d.children,t,a?"offsetWidth":"offsetHeight",o);let m=d.parentElement;for(;!m.dataset.virtuosoScroller;)m=m.parentElement;const f=m.lastElementChild.dataset.viewportType==="window";let v;f&&(v=m.ownerDocument.defaultView);const g=i?a?i.scrollLeft:i.scrollTop:f?a?v.scrollX||v.document.documentElement.scrollLeft:v.scrollY||v.document.documentElement.scrollTop:a?m.scrollLeft:m.scrollTop,x=i?a?i.scrollWidth:i.scrollHeight:f?a?v.document.documentElement.scrollWidth:v.document.documentElement.scrollHeight:a?m.scrollWidth:m.scrollHeight,y=i?a?i.offsetWidth:i.offsetHeight:f?a?v.innerWidth:v.innerHeight:a?m.offsetWidth:m.offsetHeight;r({scrollHeight:x,scrollTop:Math.max(g,0),viewportHeight:y}),s==null||s(a?Vf("column-gap",getComputedStyle(d).columnGap,o):Vf("row-gap",getComputedStyle(d).rowGap,o)),p!==null&&e(p)},[e,t,o,s,i,r,a]);return Ta(c,n,l)}function NS(e,t,n,r){const o=e.length;if(o===0)return null;const s=[];for(let i=0;i<o;i++){const a=e.item(i);if(a.dataset.index===void 0)continue;const l=parseInt(a.dataset.index),c=parseFloat(a.dataset.knownSize),d=t(a,n);if(d===0&&r("Zero-sized element, this should not happen",{child:a},Bt.ERROR),d===c)continue;const p=s[s.length-1];s.length===0||p.size!==d||p.endIndex!==l-1?s.push({endIndex:l,size:d,startIndex:l}):s[s.length-1].endIndex++}return s}function Vf(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Bt.WARN),t==="normal"?0:parseInt(t??"0",10)}function Kf(e,t,n){const r=b.useRef(null),o=b.useCallback(l=>{if(!(l!=null&&l.offsetParent))return;const c=l.getBoundingClientRect(),d=c.width;let p,m;if(t){const f=t.getBoundingClientRect(),v=c.top-f.top;m=f.height-Math.max(0,v),p=v+t.scrollTop}else{const f=i.current.ownerDocument.defaultView;m=f.innerHeight-Math.max(0,c.top),p=c.top+f.scrollY}r.current={offsetTop:p,visibleHeight:m,visibleWidth:d},e(r.current)},[e,t]),{callbackRef:s,ref:i}=Ta(o,!0,n),a=b.useCallback(()=>{o(i.current)},[o,i]);return b.useEffect(()=>{var l;if(t){t.addEventListener("scroll",a);const c=new ResizeObserver(()=>{requestAnimationFrame(a)});return c.observe(t),()=>{t.removeEventListener("scroll",a),c.unobserve(t)}}else{const c=(l=i.current)==null?void 0:l.ownerDocument.defaultView;return c==null||c.addEventListener("scroll",a),c==null||c.addEventListener("resize",a),()=>{c==null||c.removeEventListener("scroll",a),c==null||c.removeEventListener("resize",a)}}},[a,t,i]),s}const Ot=Ye(()=>{const e=Ue(),t=Ue(),n=oe(0),r=Ue(),o=oe(0),s=Ue(),i=Ue(),a=oe(0),l=oe(0),c=oe(0),d=oe(0),p=Ue(),m=Ue(),f=oe(!1),v=oe(!1),g=oe(!1);return ye(ee(e,he(({scrollTop:x})=>x)),t),ye(ee(e,he(({scrollHeight:x})=>x)),i),ye(t,o),{deviation:n,fixedFooterHeight:c,fixedHeaderHeight:l,footerHeight:d,headerHeight:a,horizontalDirection:v,scrollBy:m,scrollContainerState:e,scrollHeight:i,scrollingInProgress:f,scrollTo:p,scrollTop:t,skipAnimationFrameInResizeObserver:g,smoothScrollTargetReached:r,statefulScrollTop:o,viewportHeight:s}},[],{singleton:!0}),lo={lvl:0};function qf(e,t){const n=e.length;if(n===0)return[];let{index:r,value:o}=t(e[0]);const s=[];for(let i=1;i<n;i++){const{index:a,value:l}=t(e[i]);s.push({end:a-1,start:r,value:o}),r=a,o=l}return s.push({end:1/0,start:r,value:o}),s}function ot(e){return e===lo}function co(e,t){if(!ot(e))return t===e.k?e.v:t<e.k?co(e.l,t):co(e.r,t)}function un(e,t,n="k"){if(ot(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){const r=un(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return un(e.l,t,n)}function Jt(e,t,n){return ot(e)?Xf(t,n,1):t===e.k?St(e,{k:t,v:n}):t<e.k?Jf(St(e,{l:Jt(e.l,t,n)})):Jf(St(e,{r:Jt(e.r,t,n)}))}function Nr(){return lo}function Ss(e,t,n){if(ot(e))return[];const r=un(e,t)[0];return AS(Ea(e,r,n))}function ka(e,t){if(ot(e))return lo;const{k:n,l:r,r:o}=e;if(t===n){if(ot(r))return o;if(ot(o))return r;{const[s,i]=Yf(r);return Cs(St(e,{k:s,l:Gf(r),v:i}))}}else return t<n?Cs(St(e,{l:ka(r,t)})):Cs(St(e,{r:ka(o,t)}))}function er(e){return ot(e)?[]:[...er(e.l),{k:e.k,v:e.v},...er(e.r)]}function Ea(e,t,n){if(ot(e))return[];const{k:r,l:o,r:s,v:i}=e;let a=[];return r>t&&(a=a.concat(Ea(o,t,n))),r>=t&&r<=n&&a.push({k:r,v:i}),r<=n&&(a=a.concat(Ea(s,t,n))),a}function Cs(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(Ia(t))return Zf(St(e,{lvl:n-1}));if(!ot(t)&&!ot(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(Ia(e))return Na(St(e,{lvl:n-1}));if(!ot(r)&&!ot(r.l)){const o=r.l,s=Ia(o)?r.lvl-1:r.lvl;return St(o,{l:St(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:Na(St(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function St(e,t){return Xf(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 Gf(e){return ot(e.r)?e.l:Cs(St(e,{r:Gf(e.r)}))}function Ia(e){return ot(e)||e.lvl>e.r.lvl}function Yf(e){return ot(e.r)?[e.k,e.v]:Yf(e.r)}function Xf(e,t,n,r=lo,o=lo){return{k:e,l:r,lvl:n,r:o,v:t}}function Jf(e){return Na(Zf(e))}function Zf(e){const{l:t}=e;return!ot(t)&&t.lvl===e.lvl?St(t,{r:St(e,{l:t.r})}):e}function Na(e){const{lvl:t,r:n}=e;return!ot(n)&&!ot(n.r)&&n.lvl===t&&n.r.lvl===t?St(n,{l:St(e,{r:n.l}),lvl:t+1}):e}function AS(e){return qf(e,({k:t,v:n})=>({index:t,value:n}))}function Qf(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function uo(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const Aa=Ye(()=>({recalcInProgress:oe(!1)}),[],{singleton:!0});function ep(e,t,n){return e[Ts(e,t,n)]}function Ts(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 jS(e,t,n,r){const o=Ts(e,t,r),s=Ts(e,n,r,o);return e.slice(o,s+1)}function $n(e,t){return Math.round(e.getBoundingClientRect()[t])}function ks(e){return!ot(e.groupOffsetTree)}function ja({index:e},t){return t===e?0:t<e?-1:1}function _S(){return{groupIndices:[],groupOffsetTree:Nr(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Nr()}}function PS(e,t){let n=ot(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),ot(e)){e=Jt(e,0,s);continue}const a=Ss(e,i-1,o+1);if(a.some(FS(r)))continue;let l=!1,c=!1;for(const{end:d,start:p,value:m}of a)l?(o>=p||s===m)&&(e=ka(e,p)):(c=m!==s,l=!0),d>o&&o>=p&&m!==s&&(e=Jt(e,o+1,m));c&&(e=Jt(e,i,s))}return[e,n]}function MS(e){return typeof e.groupIndex<"u"}function RS({offset:e},t){return t===e?0:t<e?-1:1}function fo(e,t,n){if(t.length===0)return 0;const{index:r,offset:o,size:s}=ep(t,e,ja),i=e-r,a=s*i+(i-1)*n+o;return a>0?a+n:a}function tp(e,t){if(!ks(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function np(e,t,n){if(MS(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=tp(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function OS(e,t,n,r=0){return r>0&&(t=Math.max(t,ep(e,r,ja).offset)),qf(jS(e,t,n,RS),$S)}function DS(e,[t,n,r,o]){t.length>0&&r("received item sizes",t,Bt.DEBUG);const s=e.sizeTree;let i=s,a=0;if(n.length>0&&ot(s)&&t.length===2){const m=t[0].size,f=t[1].size;i=n.reduce((v,g)=>Jt(Jt(v,g,m),g+1,f),i)}else[i,a]=PS(i,t);if(i===s)return e;const{lastIndex:l,lastOffset:c,lastSize:d,offsetTree:p}=_a(e.offsetTree,a,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((m,f)=>Jt(m,f,fo(f,p,o)),Nr()),lastIndex:l,lastOffset:c,lastSize:d,offsetTree:p,sizeTree:i}}function LS(e){return er(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 rp(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 _a(e,t,n,r){let o=e,s=0,i=0,a=0,l=0;if(t!==0){l=Ts(o,t-1,ja),a=o[l].offset;const c=un(n,t-1);s=c[0],i=c[1],o.length&&o[l].size===un(n,t)[1]&&(l-=1),o=o.slice(0,l+1)}else o=[];for(const{start:c,value:d}of Ss(n,t,1/0)){const p=c-s,m=p*i+a+p*r;o.push({index:c,offset:m,size:d}),s=c,a=m,i=d}return{lastIndex:s,lastOffset:a,lastSize:i,offsetTree:o}}function $S(e){return{index:e.index,value:e}}function FS(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 BS={offsetHeight:"height",offsetWidth:"width"},Cn=Ye(([{log:e},{recalcInProgress:t}])=>{const n=Ue(),r=Ue(),o=At(r,0),s=Ue(),i=Ue(),a=oe(0),l=oe([]),c=oe(void 0),d=oe(void 0),p=oe((C,T)=>$n(C,BS[T])),m=oe(void 0),f=oe(0),v=_S(),g=At(ee(n,Le(l,e,f),Sn(DS,v),ct()),v),x=At(ee(l,ct(),Sn((C,T)=>({current:T,prev:C.current}),{current:[],prev:[]}),he(({prev:C})=>C)),[]);ye(ee(l,Ae(C=>C.length>0),Le(g,f),he(([C,T,E])=>{const _=C.reduce((R,L,H)=>Jt(R,L,fo(L,T.offsetTree,E)||H),Nr());return{...T,groupIndices:C,groupOffsetTree:_}})),g),ye(ee(r,Le(g),Ae(([C,{lastIndex:T}])=>C<T),he(([C,{lastIndex:T,lastSize:E}])=>[{endIndex:T,size:E,startIndex:C}])),n),ye(c,d);const y=At(ee(c,he(C=>C===void 0)),!0);ye(ee(d,Ae(C=>C!==void 0&&ot(gt(g).sizeTree)),he(C=>[{endIndex:0,size:C,startIndex:0}])),n);const w=Xt(ee(n,Le(g),Sn(({sizes:C},[T,E])=>({changed:E!==C,sizes:E}),{changed:!1,sizes:v}),he(C=>C.changed)));Qe(ee(a,Sn((C,T)=>({diff:C.prev-T,prev:T}),{diff:0,prev:0}),he(C=>C.diff)),C=>{const{groupIndices:T}=gt(g);if(C>0)Re(t,!0),Re(s,C+rp(C,T));else if(C<0){const E=gt(x);E.length>0&&(C-=rp(-C,E)),Re(i,C)}}),Qe(ee(a,Le(e)),([C,T])=>{C<0&&T("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:a},Bt.ERROR)});const S=Xt(s);ye(ee(s,Le(g),he(([C,T])=>{const E=T.groupIndices.length>0,_=[],R=T.lastSize;if(E){const L=co(T.sizeTree,0);let H=0,K=0;for(;H<C;){const I=T.groupIndices[K],W=T.groupIndices.length===K+1?1/0:T.groupIndices[K+1]-I-1;_.push({endIndex:I,size:L,startIndex:I}),_.push({endIndex:I+1+W-1,size:R,startIndex:I+1}),K++,H+=W+1}const B=er(T.sizeTree);return H!==C&&B.shift(),B.reduce((I,{k:W,v:N})=>{let U=I.ranges;return I.prevSize!==0&&(U=[...I.ranges,{endIndex:W+C-1,size:I.prevSize,startIndex:I.prevIndex}]),{prevIndex:W+C,prevSize:N,ranges:U}},{prevIndex:C,prevSize:0,ranges:_}).ranges}return er(T.sizeTree).reduce((L,{k:H,v:K})=>({prevIndex:H+C,prevSize:K,ranges:[...L.ranges,{endIndex:H+C-1,size:L.prevSize,startIndex:L.prevIndex}]}),{prevIndex:0,prevSize:R,ranges:[]}).ranges})),n);const k=Xt(ee(i,Le(g,f),he(([C,{offsetTree:T},E])=>{const _=-C;return fo(_,T,E)})));return ye(ee(i,Le(g,f),he(([C,T,E])=>{if(T.groupIndices.length>0){if(ot(T.sizeTree))return T;let _=Nr();const R=gt(x);let L=0,H=0,K=0;for(;L<-C;){K=R[H];const B=R[H+1]-K-1;H++,L+=B+1}if(_=er(T.sizeTree).reduce((B,{k:I,v:W})=>Jt(B,Math.max(0,I+C),W),_),L!==-C){const B=co(T.sizeTree,K);_=Jt(_,0,B);const I=un(T.sizeTree,-C+1)[1];_=Jt(_,1,I)}return{...T,sizeTree:_,..._a(T.offsetTree,0,_,E)}}else{const _=er(T.sizeTree).reduce((R,{k:L,v:H})=>Jt(R,Math.max(0,L+C),H),Nr());return{...T,sizeTree:_,..._a(T.offsetTree,0,_,E)}}})),g),{beforeUnshiftWith:S,data:m,defaultItemSize:d,firstItemIndex:a,fixedItemSize:c,gap:f,groupIndices:l,itemSize:p,listRefresh:w,shiftWith:i,shiftWithOffset:k,sizeRanges:n,sizes:g,statefulTotalCount:o,totalCount:r,trackItemSizes:y,unshiftWith:s}},lt(Ln,Aa),{singleton:!0});function zS(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const op=Ye(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=Ue(),i=Ue(),a=Xt(ee(s,he(zS)));return ye(ee(a,he(l=>l.totalCount)),n),ye(ee(a,he(l=>l.groupIndices)),e),ye(ee(wt(o,t,r),Ae(([l,c])=>ks(c)),he(([l,c,d])=>un(c.groupOffsetTree,Math.max(l-d,0),"v")[0]),ct(),he(l=>[l])),i),{groupCounts:s,topItemsIndexes:i}},lt(Cn,Ot)),Fn=Ye(([{log:e}])=>{const t=oe(!1),n=Xt(ee(t,Ae(r=>r),ct()));return Qe(t,r=>{r&&gt(e)("props updated",{},Bt.DEBUG)}),{didMount:n,propsReady:t}},lt(Ln),{singleton:!0}),HS=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function sp(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!HS)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const po=Ye(([{gap:e,listRefresh:t,sizes:n,totalCount:r},{fixedFooterHeight:o,fixedHeaderHeight:s,footerHeight:i,headerHeight:a,scrollingInProgress:l,scrollTo:c,smoothScrollTargetReached:d,viewportHeight:p},{log:m}])=>{const f=Ue(),v=Ue(),g=oe(0);let x=null,y=null,w=null;function S(){x&&(x(),x=null),w&&(w(),w=null),y&&(clearTimeout(y),y=null),Re(l,!1)}return ye(ee(f,Le(n,p,r,g,a,i,m),Le(e,s,o),he(([[k,C,T,E,_,R,L,H],K,B,I])=>{const W=sp(k),{align:N,behavior:U,offset:O}=W,j=E-1,q=np(W,C,j);let J=fo(q,C.offsetTree,K)+R;N==="end"?(J+=B+un(C.sizeTree,q)[1]-T+I,q===j&&(J+=L)):N==="center"?J+=(B+un(C.sizeTree,q)[1]-T+I)/2:J-=_,O&&(J+=O);const P=M=>{S(),M?(H("retrying to scroll to",{location:k},Bt.DEBUG),Re(f,k)):(Re(v,!0),H("list did not change, scroll successful",{},Bt.DEBUG))};if(S(),U==="smooth"){let M=!1;w=Qe(t,G=>{M=M||G}),x=cn(d,()=>{P(M)})}else x=cn(ee(t,US(150)),P);return y=setTimeout(()=>{S()},1200),Re(l,!0),H("scrolling from index to",{behavior:U,index:q,top:J},Bt.DEBUG),{behavior:U,top:J}})),c),{scrollTargetReached:v,scrollToIndex:f,topListHeight:g}},lt(Cn,Ot,Ln),{singleton:!0});function US(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function Pa(e,t){e==0?t():requestAnimationFrame(()=>{Pa(e-1,t)})}function Ma(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const ho=Ye(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:s},{didMount:i}])=>{const a=oe(!0),l=oe(0),c=oe(!0);return ye(ee(i,Le(l),Ae(([d,p])=>!!p),yn(!1)),a),ye(ee(i,Le(l),Ae(([d,p])=>!!p),yn(!1)),c),Qe(ee(wt(t,i),Le(a,n,e,c),Ae(([[,d],p,{sizeTree:m},f,v])=>d&&(!ot(m)||ya(f))&&!p&&!v),Le(l)),([,d])=>{cn(o,()=>{Re(c,!0)}),Pa(4,()=>{cn(r,()=>{Re(a,!0)}),Re(s,d)})}),{initialItemFinalLocationReached:c,initialTopMostItemIndex:l,scrolledToInitialItem:a}},lt(Cn,Ot,po,Fn),{singleton:!0});function ip(e,t){return Math.abs(e-t)<1.01}const mo="up",go="down",WS="none",VS={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},KS=0,xo=Ye(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=oe(!1),a=oe(!0),l=Ue(),c=Ue(),d=oe(4),p=oe(KS),m=At(ee(Ca(ee(Ie(o),Zn(1),yn(!0)),ee(Ie(o),Zn(1),yn(!1),Uf(100))),ct()),!1),f=At(ee(Ca(ee(n,yn(!0)),ee(n,yn(!1),Uf(200))),ct()),!1);ye(ee(wt(Ie(o),Ie(p)),he(([w,S])=>w<=S),ct()),a),ye(ee(a,In(50)),c);const v=Xt(ee(wt(r,Ie(s),Ie(t),Ie(e),Ie(d)),Sn((w,[{scrollHeight:S,scrollTop:k},C,T,E,_])=>{const R=k+C-S>-_,L={scrollHeight:S,scrollTop:k,viewportHeight:C};if(R){let K,B;return k>w.state.scrollTop?(K="SCROLLED_DOWN",B=w.state.scrollTop-k):(K="SIZE_DECREASED",B=w.state.scrollTop-k||w.scrollTopDelta),{atBottom:!0,atBottomBecause:K,scrollTopDelta:B,state:L}}let H;return L.scrollHeight>w.state.scrollHeight?H="SIZE_INCREASED":C<w.state.viewportHeight?H="VIEWPORT_HEIGHT_DECREASING":k<w.state.scrollTop?H="SCROLLING_UPWARDS":H="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:H,state:L}},VS),ct((w,S)=>w&&w.atBottom===S.atBottom))),g=At(ee(r,Sn((w,{scrollHeight:S,scrollTop:k,viewportHeight:C})=>{if(ip(w.scrollHeight,S))return{changed:!1,jump:0,scrollHeight:S,scrollTop:k};{const T=S-(k+C)<1;return w.scrollTop!==k&&T?{changed:!0,jump:w.scrollTop-k,scrollHeight:S,scrollTop:k}:{changed:!0,jump:0,scrollHeight:S,scrollTop:k}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),Ae(w=>w.changed),he(w=>w.jump)),0);ye(ee(v,he(w=>w.atBottom)),i),ye(ee(i,In(50)),l);const x=oe(go);ye(ee(r,he(({scrollTop:w})=>w),ct(),Sn((w,S)=>gt(f)?{direction:w.direction,prevScrollTop:S}:{direction:S<w.prevScrollTop?mo:go,prevScrollTop:S},{direction:go,prevScrollTop:0}),he(w=>w.direction)),x),ye(ee(r,In(50),yn(WS)),x);const y=oe(0);return ye(ee(m,Ae(w=>!w),yn(0)),y),ye(ee(o,In(100),Le(m),Ae(([w,S])=>!!S),Sn(([w,S],[k])=>[S,k],[0,0]),he(([w,S])=>S-w)),y),{atBottomState:v,atBottomStateChange:l,atBottomThreshold:d,atTopStateChange:c,atTopThreshold:p,isAtBottom:i,isAtTop:a,isScrolling:m,lastJumpDueToItemResize:g,scrollDirection:x,scrollVelocity:y}},lt(Ot)),Es="top",Is="bottom",ap="none";function lp(e,t,n){return typeof e=="number"?n===mo&&t===Es||n===go&&t===Is?e:0:n===mo?t===Es?e.main:e.reverse:t===Is?e.main:e.reverse}function cp(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const Ra=Ye(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=Ue(),i=oe(0),a=oe(0),l=oe(0),c=At(ee(wt(Ie(r),Ie(o),Ie(n),Ie(s,uo),Ie(l),Ie(i),Ie(t),Ie(e),Ie(a)),he(([d,p,m,[f,v],g,x,y,w,S])=>{const k=d-w,C=x+y,T=Math.max(m-k,0);let E=ap;const _=cp(S,Es),R=cp(S,Is);return f-=w,f+=m+y,v+=m+y,v-=w,f>d+C-_&&(E=mo),v<d-T+p+R&&(E=go),E!==ap?[Math.max(k-m-lp(g,Es,E)-_,0),k-T-y+p+lp(g,Is,E)+R]:null}),Ae(d=>d!=null),ct(uo)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:l,topListHeight:i,visibleRange:c}},lt(Ot),{singleton:!0});function qS(e,t,n){if(ks(t)){const r=tp(e,t);return[{index:un(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 Oa={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Ns(e,t,n,r,o,s){const{lastIndex:i,lastOffset:a,lastSize:l}=o;let c=0,d=0;if(e.length>0){c=e[0].offset;const g=e[e.length-1];d=g.offset+g.size}const p=n-i,m=a+p*l+(p-1)*r,f=c,v=m-d;return{bottom:d,firstItemIndex:s,items:dp(e,o,s),offsetBottom:v,offsetTop:c,top:f,topItems:dp(t,o,s),topListHeight:t.reduce((g,x)=>x.size+g,0),totalCount:n}}function up(e,t,n,r,o,s){let i=0;if(n.groupIndices.length>0)for(const d of n.groupIndices){if(d-i>=e)break;i++}const a=e+i,l=Ma(t,a),c=Array.from({length:a}).map((d,p)=>({data:s[p+l],index:p+l,offset:0,size:0}));return Ns(c,[],a,o,n,r)}function dp(e,t,n){if(e.length===0)return[];if(!ks(t))return e.map(c=>({...c,index:c.index+n,originalIndex:c.index}));const r=e[0].index,o=e[e.length-1].index,s=[],i=Ss(t.groupOffsetTree,r,o);let a,l=0;for(const c of e){(!a||a.end<c.index)&&(a=i.shift(),l=t.groupIndices.indexOf(a.start));let d;c.index===a.start?d={index:l,type:"group"}:d={groupIndex:l,index:c.index-(l+1)+n},s.push({...d,data:c.data,offset:c.offset,originalIndex:c.index,size:c.size})}return s}const tr=Ye(([{data:e,firstItemIndex:t,gap:n,sizes:r,totalCount:o},s,{listBoundary:i,topListHeight:a,visibleRange:l},{initialTopMostItemIndex:c,scrolledToInitialItem:d},{topListHeight:p},m,{didMount:f},{recalcInProgress:v}])=>{const g=oe([]),x=oe(0),y=Ue();ye(s.topItemsIndexes,g);const w=At(ee(wt(f,v,Ie(l,uo),Ie(o),Ie(r),Ie(c),d,Ie(g),Ie(t),Ie(n),e),Ae(([T,E,,_,,,,,,,R])=>{const L=R&&R.length!==_;return T&&!E&&!L}),he(([,,[T,E],_,R,L,H,K,B,I,W])=>{const N=R,{offsetTree:U,sizeTree:O}=N,j=gt(x);if(_===0)return{...Oa,totalCount:_};if(T===0&&E===0)return j===0?{...Oa,totalCount:_}:up(j,L,R,B,I,W||[]);if(ot(O))return j>0?null:Ns(qS(Ma(L,_),N,W),[],_,I,N,B);const q=[];if(K.length>0){const Z=K[0],se=K[K.length-1];let V=0;for(const D of Ss(O,Z,se)){const X=D.value,Q=Math.max(D.start,Z),ae=Math.min(D.end,se);for(let $=Q;$<=ae;$++)q.push({data:W==null?void 0:W[$],index:$,offset:V,size:X}),V+=X}}if(!H)return Ns([],q,_,I,N,B);const J=K.length>0?K[K.length-1]+1:0,P=OS(U,T,E,J);if(P.length===0)return null;const M=_-1,G=ys([],Z=>{for(const se of P){const V=se.value;let D=V.offset,X=se.start;const Q=V.size;if(V.offset<T){X+=Math.floor((T-V.offset+I)/(Q+I));const $=X-se.start;D+=$*Q+$*I}X<J&&(D+=(J-X)*Q,X=J);const ae=Math.min(se.end,M);for(let $=X;$<=ae&&!(D>=E);$++)Z.push({data:W==null?void 0:W[$],index:$,offset:D,size:Q}),D+=Q+I}});return Ns(G,q,_,I,N,B)}),Ae(T=>T!==null),ct()),Oa);ye(ee(e,Ae(ya),he(T=>T==null?void 0:T.length)),o),ye(ee(w,he(T=>T.topListHeight)),p),ye(p,a),ye(ee(w,he(T=>[T.top,T.bottom])),i),ye(ee(w,he(T=>T.items)),y);const S=Xt(ee(w,Ae(({items:T})=>T.length>0),Le(o,e),Ae(([{items:T},E])=>T[T.length-1].originalIndex===E-1),he(([,T,E])=>[T-1,E]),ct(uo),he(([T])=>T))),k=Xt(ee(w,In(200),Ae(({items:T,topItems:E})=>T.length>0&&T[0].originalIndex===E.length),he(({items:T})=>T[0].index),ct())),C=Xt(ee(w,Ae(({items:T})=>T.length>0),he(({items:T})=>{let E=0,_=T.length-1;for(;T[E].type==="group"&&E<_;)E++;for(;T[_].type==="group"&&_>E;)_--;return{endIndex:T[_].index,startIndex:T[E].index}}),ct(Qf)));return{endReached:S,initialItemCount:x,itemsRendered:y,listState:w,rangeChanged:C,startReached:k,topItemsIndexes:g,...m}},lt(Cn,op,Ra,ho,po,xo,Fn,Aa),{singleton:!0}),fp=Ye(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=Ue(),i=At(ee(wt(n,e,r,t,o),he(([a,l,c,d,p])=>a+l+c+d+p.offsetBottom+p.bottom)),0);return ye(Ie(i),s),{totalListHeight:i,totalListHeightChanged:s}},lt(Ot,tr),{singleton:!0}),GS=Ye(([{viewportHeight:e},{totalListHeight:t}])=>{const n=oe(!1),r=At(ee(wt(n,e,t),Ae(([o])=>o),he(([,o,s])=>Math.max(0,o-s)),In(0),ct()),0);return{alignToBottom:n,paddingTopAddition:r}},lt(Ot,fp),{singleton:!0}),pp=Ye(()=>({context:oe(null)})),YS=({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,hp=Ye(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:s,scrollingInProgress:i,scrollTop:a,viewportHeight:l},{scrollToIndex:c}])=>{const d=Ue();return ye(ee(d,Le(t,l,n,s,o,r,a),Le(e),he(([[p,m,f,v,g,x,y,w],S])=>{const{align:k,behavior:C,calculateViewLocation:T=YS,done:E,..._}=p,R=np(p,m,v-1),L=fo(R,m.offsetTree,S)+g+x,H=L+un(m.sizeTree,R)[1],K=w+x,B=w+f-y,I=T({itemBottom:H,itemTop:L,locationParams:{align:k,behavior:C,..._},viewportBottom:B,viewportTop:K});return I?E&&cn(ee(i,Ae(W=>!W),Zn(gt(i)?1:2)),E):E&&E(),I}),Ae(p=>p!==null)),c),{scrollIntoView:d}},lt(Cn,Ot,po,tr,Ln),{singleton:!0});function mp(e){return e?e==="smooth"?"smooth":"auto":!1}const XS=(e,t)=>typeof e=="function"?mp(e(t)):t&&mp(e),JS=Ye(([{listRefresh:e,totalCount:t,fixedItemSize:n,data:r},{atBottomState:o,isAtBottom:s},{scrollToIndex:i},{scrolledToInitialItem:a},{didMount:l,propsReady:c},{log:d},{scrollingInProgress:p},{context:m},{scrollIntoView:f}])=>{const v=oe(!1),g=Ue();let x=null;function y(C){Re(i,{align:"end",behavior:C,index:"LAST"})}Qe(ee(wt(ee(Ie(t),Zn(1)),l),Le(Ie(v),s,a,p),he(([[C,T],E,_,R,L])=>{let H=T&&R,K="auto";return H&&(K=XS(E,_||L),H=H&&!!K),{followOutputBehavior:K,shouldFollow:H,totalCount:C}}),Ae(({shouldFollow:C})=>C)),({followOutputBehavior:C,totalCount:T})=>{x&&(x(),x=null),gt(n)?requestAnimationFrame(()=>{gt(d)("following output to ",{totalCount:T},Bt.DEBUG),y(C)}):x=cn(e,()=>{gt(d)("following output to ",{totalCount:T},Bt.DEBUG),y(C),x=null})});function w(C){const T=cn(o,E=>{C&&!E.atBottom&&E.notAtBottomBecause==="SIZE_INCREASED"&&!x&&(gt(d)("scrolling to bottom due to increased size",{},Bt.DEBUG),y("auto"))});setTimeout(T,100)}Qe(ee(wt(Ie(v),t,c),Ae(([C,,T])=>C&&T),Sn(({value:C},[,T])=>({refreshed:C===T,value:T}),{refreshed:!1,value:0}),Ae(({refreshed:C})=>C),Le(v,t)),([,C])=>{gt(a)&&w(C!==!1)}),Qe(g,()=>{w(gt(v)!==!1)}),Qe(wt(Ie(v),o),([C,T])=>{C&&!T.atBottom&&T.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&y("auto")});const S=oe(null),k=Ue();return ye(Ca(ee(Ie(r),he(C=>{var T;return(T=C==null?void 0:C.length)!=null?T:0})),ee(Ie(t))),k),Qe(ee(wt(ee(k,Zn(1)),l),Le(Ie(S),a,p,m),he(([[C,T],E,_,R,L])=>T&&_&&(E==null?void 0:E({context:L,totalCount:C,scrollingInProgress:R}))),Ae(C=>!!C),In(0)),C=>{x&&(x(),x=null),gt(n)?requestAnimationFrame(()=>{gt(d)("scrolling into view",{}),Re(f,C)}):x=cn(e,()=>{gt(d)("scrolling into view",{}),Re(f,C),x=null})}),{autoscrollToBottom:g,followOutput:v,scrollIntoViewOnChange:S}},lt(Cn,xo,po,ho,Fn,Ln,Ot,pp,hp)),ZS=Ye(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(ye(ee(a,Le(s),Ae(([,l])=>l!==0),Le(o,r,t,n,e),he(([[,l],c,d,p,m,f=[]])=>up(l,c,d,p,m,f))),i),{}),lt(Cn,ho,tr,Fn),{singleton:!0}),QS=Ye(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=oe(0);return Qe(ee(e,Le(r),Ae(([,o])=>o!==0),he(([,o])=>({top:o}))),o=>{cn(ee(n,Zn(1),Ae(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{Re(t,o)})})}),{initialScrollTop:r}},lt(Fn,Ot,tr),{singleton:!0}),gp=Ye(([{scrollVelocity:e}])=>{const t=oe(!1),n=Ue(),r=oe(!1);return ye(ee(e,Le(r,t,n),Ae(([o,s])=>!!s),he(([o,s,i,a])=>{const{enter:l,exit:c}=s;if(i){if(c(o,a))return!1}else if(l(o,a))return!0;return i}),ct()),t),Qe(ee(wt(t,e,n),Le(r)),([[o,s,i],a])=>{o&&a&&a.change&&a.change(s,i)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},lt(xo),{singleton:!0}),Da=Ye(([{scrollContainerState:e,scrollTo:t}])=>{const n=Ue(),r=Ue(),o=Ue(),s=oe(!1),i=oe(void 0);return ye(ee(wt(n,r),he(([{scrollHeight:a,scrollTop:l,viewportHeight:c},{offsetTop:d}])=>({scrollHeight:a,scrollTop:Math.max(0,l-d),viewportHeight:c}))),e),ye(ee(t,Le(r),he(([a,{offsetTop:l}])=>({...a,top:a.top+l}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},lt(Ot)),eC=Ye(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:a,windowViewportRect:l}])=>{const c=Ue(),d=oe(void 0),p=oe(null),m=oe(null);return ye(a,p),ye(l,m),Qe(ee(c,Le(t,r,i,p,m,n)),([f,v,g,x,y,w,S])=>{const k=LS(v.sizeTree);x&&y!==null&&w!==null&&(g=y.scrollTop-w.offsetTop),g-=S,f({ranges:k,scrollTop:g})}),ye(ee(d,Ae(ya),he(tC)),o),ye(ee(s,Le(d),Ae(([,f])=>f!==void 0),ct(),he(([,f])=>f.ranges)),e),{getState:c,restoreStateFrom:d}},lt(Cn,Ot,ho,Fn,Da));function tC(e){return{align:"start",index:0,offset:e.scrollTop}}const nC=Ye(([{topItemsIndexes:e}])=>{const t=oe(0);return ye(ee(t,Ae(n=>n>=0),he(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},lt(tr));function xp(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const rC=xp(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),oC=Ye(([{deviation:e,scrollBy:t,scrollingInProgress:n,scrollTop:r},{isAtBottom:o,isScrolling:s,lastJumpDueToItemResize:i,scrollDirection:a},{listState:l},{beforeUnshiftWith:c,gap:d,shiftWithOffset:p,sizes:m},{log:f},{recalcInProgress:v}])=>{const g=Xt(ee(l,Le(i),Sn(([,y,w,S],[{bottom:k,items:C,offsetBottom:T,totalCount:E},_])=>{const R=k+T;let L=0;return w===E&&y.length>0&&C.length>0&&(C[0].originalIndex===0&&y[0].originalIndex===0||(L=R-S,L!==0&&(L+=_))),[L,C,E,R]},[0,[],0,0]),Ae(([y])=>y!==0),Le(r,a,n,o,f,v),Ae(([,y,w,S,,,k])=>!k&&!S&&y!==0&&w===mo),he(([[y],,,,,w])=>(w("Upward scrolling compensation",{amount:y},Bt.DEBUG),y))));function x(y){y>0?(Re(t,{behavior:"auto",top:-y}),Re(e,0)):(Re(e,0),Re(t,{behavior:"auto",top:-y}))}return Qe(ee(g,Le(e,s)),([y,w,S])=>{S&&rC()?Re(e,w-y):x(-y)}),Qe(ee(wt(At(s,!1),e,v),Ae(([y,w,S])=>!y&&!S&&w!==0),he(([y,w])=>w),In(1)),x),ye(ee(p,he(y=>({top:-y}))),t),Qe(ee(c,Le(m,d),he(([y,{groupIndices:w,lastSize:S,sizeTree:k},C])=>{function T(E){return E*(S+C)}if(w.length===0)return T(y);{let E=0;const _=co(k,0);let R=0,L=0;for(;R<y;){R++,E+=_;let H=w.length===L+1?1/0:w[L+1]-w[L]-1;R+H>y&&(E-=_,H=y-R+1),R+=H,E+=T(H),L++}return E}})),y=>{Re(e,y),requestAnimationFrame(()=>{Re(t,{top:y}),requestAnimationFrame(()=>{Re(e,0),Re(v,!1)})})}),{deviation:e}},lt(Ot,xo,tr,Cn,Ln,Aa)),sC=Ye(([e,t,n,r,o,s,i,a,l,c,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...l,...c,...d}),lt(Ra,ZS,Fn,gp,fp,QS,GS,Da,hp,Ln,pp)),vp=Ye(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:r,gap:o,groupIndices:s,itemSize:i,sizeRanges:a,sizes:l,statefulTotalCount:c,totalCount:d,trackItemSizes:p},{initialItemFinalLocationReached:m,initialTopMostItemIndex:f,scrolledToInitialItem:v},g,x,y,{listState:w,topItemsIndexes:S,...k},{scrollToIndex:C},T,{topItemCount:E},{groupCounts:_},R])=>(ye(k.rangeChanged,R.scrollSeekRangeChanged),ye(ee(R.windowViewportRect,he(L=>L.visibleHeight)),g.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,gap:o,groupCounts:_,initialItemFinalLocationReached:m,initialTopMostItemIndex:f,scrolledToInitialItem:v,sizeRanges:a,topItemCount:E,topItemsIndexes:S,totalCount:d,...y,groupIndices:s,itemSize:i,listState:w,scrollToIndex:C,statefulTotalCount:c,trackItemSizes:p,...k,...R,...g,sizes:l,...x}),lt(Cn,ho,Ot,eC,JS,tr,po,oC,nC,op,sC));function iC(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 As=typeof document<"u"?b.useLayoutEffect:b.useEffect;function wp(e,t,n){const r=Object.keys(t.required||{}),o=Object.keys(t.optional||{}),s=Object.keys(t.methods||{}),i=Object.keys(t.events||{}),a=b.createContext({});function l(x,y){x.propsReady&&Re(x.propsReady,!1);for(const w of r){const S=x[t.required[w]];Re(S,y[w])}for(const w of o)if(w in y){const S=x[t.optional[w]];Re(S,y[w])}x.propsReady&&Re(x.propsReady,!0)}function c(x){return s.reduce((y,w)=>(y[w]=S=>{const k=x[t.methods[w]];Re(k,S)},y),{})}function d(x){return i.reduce((y,w)=>(y[w]=SS(x[t.events[w]]),y),{})}const p=b.forwardRef((x,y)=>{const{children:w,...S}=x,[k]=b.useState(()=>ys(TS(e),E=>{l(E,S)})),[C]=b.useState(Hf(d,k));As(()=>{for(const E of i)E in S&&Qe(C[E],S[E]);return()=>{Object.values(C).map(Sa)}},[S,C,k]),As(()=>{l(k,S)}),b.useImperativeHandle(y,Bf(c(k)));const T=n;return u.jsx(a.Provider,{value:k,children:n?u.jsx(T,{...iC([...r,...o,...i],S),children:w}):w})}),m=x=>{const y=b.useContext(a);return b.useCallback(w=>{Re(y[x],w)},[y,x])},f=x=>{const y=b.useContext(a)[x],w=b.useCallback(S=>Qe(y,S),[y]);return b.useSyncExternalStore(w,()=>gt(y),()=>gt(y))},v=x=>{const y=b.useContext(a)[x],[w,S]=b.useState(Hf(gt,y));return As(()=>Qe(y,k=>{k!==w&&S(Bf(k))}),[y,w]),w},g=b.version.startsWith("18")?f:v;return{Component:p,useEmitter:(x,y)=>{const w=b.useContext(a)[x];As(()=>Qe(w,y),[y,w])},useEmitterValue:g,usePublisher:m}}const bp=b.createContext(void 0),yp=b.createContext(void 0),Sp=typeof document<"u"?b.useLayoutEffect:b.useEffect;function La(e){return"self"in e}function aC(e){return"body"in e}function Cp(e,t,n,r=Ir,o,s){const i=b.useRef(null),a=b.useRef(null),l=b.useRef(null),c=b.useCallback(m=>{let f,v,g;const x=m.target;if(aC(x)||La(x)){const w=La(x)?x:x.defaultView;g=s?w.scrollX:w.scrollY,f=s?w.document.documentElement.scrollWidth:w.document.documentElement.scrollHeight,v=s?w.innerWidth:w.innerHeight}else g=s?x.scrollLeft:x.scrollTop,f=s?x.scrollWidth:x.scrollHeight,v=s?x.offsetWidth:x.offsetHeight;const y=()=>{e({scrollHeight:f,scrollTop:Math.max(g,0),viewportHeight:v})};m.suppressFlushSync?y():No.flushSync(y),a.current!==null&&(g===a.current||g<=0||g===f-v)&&(a.current=null,t(!0),l.current&&(clearTimeout(l.current),l.current=null))},[e,t,s]);b.useEffect(()=>{const m=o||i.current;return r(o||i.current),c({suppressFlushSync:!0,target:m}),m.addEventListener("scroll",c,{passive:!0}),()=>{r(null),m.removeEventListener("scroll",c)}},[i,c,n,r,o]);function d(m){const f=i.current;if(!f||(s?"offsetWidth"in f&&f.offsetWidth===0:"offsetHeight"in f&&f.offsetHeight===0))return;const v=m.behavior==="smooth";let g,x,y;La(f)?(x=Math.max($n(f.document.documentElement,s?"width":"height"),s?f.document.documentElement.scrollWidth:f.document.documentElement.scrollHeight),g=s?f.innerWidth:f.innerHeight,y=s?window.scrollX:window.scrollY):(x=f[s?"scrollWidth":"scrollHeight"],g=$n(f,s?"width":"height"),y=f[s?"scrollLeft":"scrollTop"]);const w=x-g;if(m.top=Math.ceil(Math.max(Math.min(w,m.top),0)),ip(g,x)||m.top===y){e({scrollHeight:x,scrollTop:y,viewportHeight:g}),v&&t(!0);return}v?(a.current=m.top,l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{l.current=null,a.current=null,t(!0)},1e3)):a.current=null,s&&(m={behavior:m.behavior,left:m.top}),f.scrollTo(m)}function p(m){s&&(m={behavior:m.behavior,left:m.top}),i.current.scrollBy(m)}return{scrollByCallback:p,scrollerRef:i,scrollToCallback:d}}const $a="-webkit-sticky",Tp="sticky",Fa=xp(()=>{if(typeof document>"u")return Tp;const e=document.createElement("div");return e.style.position=$a,e.style.position===$a?$a:Tp});function Ba(e){return e}const lC=Ye(()=>{const e=oe(a=>`Item ${a}`),t=oe(a=>`Group ${a}`),n=oe({}),r=oe(Ba),o=oe("div"),s=oe(Ir),i=(a,l=null)=>At(ee(n,he(c=>c[a]),ct()),l);return{components:n,computeItemKey:r,EmptyPlaceholder:i("EmptyPlaceholder"),FooterComponent:i("Footer"),GroupComponent:i("Group","div"),groupContent:t,HeaderComponent:i("Header"),HeaderFooterTag:o,ItemComponent:i("Item","div"),itemContent:e,ListComponent:i("List","div"),ScrollerComponent:i("Scroller","div"),scrollerRef:s,ScrollSeekPlaceholder:i("ScrollSeekPlaceholder"),TopItemListComponent:i("TopItemList")}}),cC=Ye(([e,t])=>({...e,...t}),lt(vp,lC)),uC=({height:e})=>u.jsx("div",{style:{height:e}}),dC={overflowAnchor:"none",position:Fa(),zIndex:1},kp={overflowAnchor:"none"},fC={...kp,display:"inline-block",height:"100%"},Ep=b.memo(function({showTopList:e=!1}){const t=_e("listState"),n=Qt("sizeRanges"),r=_e("useWindowScroll"),o=_e("customScrollParent"),s=Qt("windowScrollContainerState"),i=Qt("scrollContainerState"),a=o||r?s:i,l=_e("itemContent"),c=_e("context"),d=_e("groupContent"),p=_e("trackItemSizes"),m=_e("itemSize"),f=_e("log"),v=Qt("gap"),g=_e("horizontalDirection"),{callbackRef:x}=IS(n,m,p,e?Ir:a,f,v,o,g,_e("skipAnimationFrameInResizeObserver")),[y,w]=b.useState(0);za("deviation",I=>{y!==I&&w(I)});const S=_e("EmptyPlaceholder"),k=_e("ScrollSeekPlaceholder")||uC,C=_e("ListComponent"),T=_e("ItemComponent"),E=_e("GroupComponent"),_=_e("computeItemKey"),R=_e("isSeeking"),L=_e("groupIndices").length>0,H=_e("alignToBottom"),K=_e("initialItemFinalLocationReached"),B=e?{}:{boxSizing:"border-box",...g?{display:"inline-block",height:"100%",marginLeft:y!==0?y:H?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:y!==0?y:H?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...K?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&S?u.jsx(S,{...jt(S,c)}):u.jsx(C,{...jt(C,c),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:x,style:B,children:(e?t.topItems:t.items).map(I=>{const W=I.originalIndex,N=_(W+t.firstItemIndex,I.data,c);return R?b.createElement(k,{...jt(k,c),height:I.size,index:I.index,key:N,type:I.type||"item",...I.type==="group"?{}:{groupIndex:I.groupIndex}}):I.type==="group"?b.createElement(E,{...jt(E,c),"data-index":W,"data-item-index":I.index,"data-known-size":I.size,key:N,style:dC},d(I.index,c)):b.createElement(T,{...jt(T,c),...gC(T,I.data),"data-index":W,"data-item-group-index":I.groupIndex,"data-item-index":I.index,"data-known-size":I.size,key:N,style:g?fC:kp},L?l(I.index,I.groupIndex,I.data,c):l(I.index,I.data,c))})})}),pC={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},hC={outline:"none",overflowX:"auto",position:"relative"},js=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),mC={position:Fa(),top:0,width:"100%",zIndex:1};function jt(e,t){if(typeof e!="string")return{context:t}}function gC(e,t){return{item:typeof e=="string"?void 0:t}}const xC=b.memo(function(){const e=_e("HeaderComponent"),t=Qt("headerHeight"),n=_e("HeaderFooterTag"),r=Qn(b.useMemo(()=>s=>{t($n(s,"height"))},[t]),!0,_e("skipAnimationFrameInResizeObserver")),o=_e("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...jt(e,o)})}):null}),vC=b.memo(function(){const e=_e("FooterComponent"),t=Qt("footerHeight"),n=_e("HeaderFooterTag"),r=Qn(b.useMemo(()=>s=>{t($n(s,"height"))},[t]),!0,_e("skipAnimationFrameInResizeObserver")),o=_e("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...jt(e,o)})}):null});function Ip({useEmitter:e,useEmitterValue:t,usePublisher:n}){return b.memo(function({children:r,style:o,context:s,...i}){const a=n("scrollContainerState"),l=t("ScrollerComponent"),c=n("smoothScrollTargetReached"),d=t("scrollerRef"),p=t("horizontalDirection")||!1,{scrollByCallback:m,scrollerRef:f,scrollToCallback:v}=Cp(a,c,l,d,void 0,p);return e("scrollTo",v),e("scrollBy",m),u.jsx(l,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:f,style:{...p?hC:pC,...o},tabIndex:0,...i,...jt(l,s),children:r})})}function Np({useEmitter:e,useEmitterValue:t,usePublisher:n}){return b.memo(function({children:r,style:o,context:s,...i}){const a=n("windowScrollContainerState"),l=t("ScrollerComponent"),c=n("smoothScrollTargetReached"),d=t("totalListHeight"),p=t("deviation"),m=t("customScrollParent"),f=b.useRef(null),v=t("scrollerRef"),{scrollByCallback:g,scrollerRef:x,scrollToCallback:y}=Cp(a,c,l,v,m);return Sp(()=>{var w;return x.current=m||((w=f.current)==null?void 0:w.ownerDocument.defaultView),()=>{x.current=null}},[x,m]),e("windowScrollTo",y),e("scrollBy",g),u.jsx(l,{ref:f,"data-virtuoso-scroller":!0,style:{position:"relative",...o,...d!==0?{height:d+p}:{}},...i,...jt(l,s),children:r})})}const wC=({children:e})=>{const t=b.useContext(bp),n=Qt("viewportHeight"),r=Qt("fixedItemHeight"),o=_e("alignToBottom"),s=_e("horizontalDirection"),i=b.useMemo(()=>zf(n,l=>$n(l,s?"width":"height")),[n,s]),a=Qn(i,!0,_e("skipAnimationFrameInResizeObserver"));return b.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),u.jsx("div",{"data-viewport-type":"element",ref:a,style:js(o),children:e})},bC=({children:e})=>{const t=b.useContext(bp),n=Qt("windowViewportRect"),r=Qt("fixedItemHeight"),o=_e("customScrollParent"),s=Kf(n,o,_e("skipAnimationFrameInResizeObserver")),i=_e("alignToBottom");return b.useEffect(()=>{t&&(r(t.itemHeight),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),u.jsx("div",{"data-viewport-type":"window",ref:s,style:js(i),children:e})},yC=({children:e})=>{const t=_e("TopItemListComponent")||"div",n=_e("headerHeight"),r={...mC,marginTop:`${n}px`},o=_e("context");return u.jsx(t,{style:r,...jt(t,o),children:e})},SC=b.memo(function(e){const t=_e("useWindowScroll"),n=_e("topItemsIndexes").length>0,r=_e("customScrollParent"),o=_e("context");return u.jsxs(r||t?kC:TC,{...e,context:o,children:[n&&u.jsx(yC,{children:u.jsx(Ep,{showTopList:!0})}),u.jsxs(r||t?bC:wC,{children:[u.jsx(xC,{}),u.jsx(Ep,{}),u.jsx(vC,{})]})]})}),{Component:CC,useEmitter:za,useEmitterValue:_e,usePublisher:Qt}=wp(cC,{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"}},SC),TC=Ip({useEmitter:za,useEmitterValue:_e,usePublisher:Qt}),kC=Np({useEmitter:za,useEmitterValue:_e,usePublisher:Qt}),EC=CC;lt(vp,Ye(()=>{const e=oe(c=>u.jsxs("td",{children:["Item $",c]})),t=oe(null),n=oe(c=>u.jsxs("td",{colSpan:1e3,children:["Group ",c]})),r=oe(null),o=oe(null),s=oe({}),i=oe(Ba),a=oe(Ir),l=(c,d=null)=>At(ee(s,he(p=>p[c]),ct()),d);return{components:s,computeItemKey:i,context:t,EmptyPlaceholder:l("EmptyPlaceholder"),FillerRow:l("FillerRow"),fixedFooterContent:o,fixedHeaderContent:r,itemContent:e,groupContent:n,ScrollerComponent:l("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder"),TableBodyComponent:l("TableBody","tbody"),TableComponent:l("Table","table"),TableFooterComponent:l("TableFoot","tfoot"),TableHeadComponent:l("TableHead","thead"),TableRowComponent:l("TableRow","tr"),GroupComponent:l("Group","tr")}})),Fa();const Ap={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},IC={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:jp,floor:_s,max:vo,min:Ha,round:_p}=Math;function Pp(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function NC(e){return{...IC,items:e}}function Ps(e,t){return e&&e.width===t.width&&e.height===t.height}function AC(e,t){return e&&e.column===t.column&&e.row===t.row}const jC=Ye(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:r},{footerHeight:o,headerHeight:s,scrollBy:i,scrollContainerState:a,scrollTo:l,scrollTop:c,smoothScrollTargetReached:d,viewportHeight:p},m,f,{didMount:v,propsReady:g},{customScrollParent:x,useWindowScroll:y,windowScrollContainerState:w,windowScrollTo:S,windowViewportRect:k},C])=>{const T=oe(0),E=oe(0),_=oe(Ap),R=oe({height:0,width:0}),L=oe({height:0,width:0}),H=Ue(),K=Ue(),B=oe(0),I=oe(null),W=oe({column:0,row:0}),N=Ue(),U=Ue(),O=oe(!1),j=oe(0),q=oe(!0),J=oe(!1),P=oe(!1);Qe(ee(v,Le(j),Ae(([D,X])=>!!X)),()=>{Re(q,!1)}),Qe(ee(wt(v,q,L,R,j,J),Ae(([D,X,Q,ae,,$])=>D&&!X&&Q.height!==0&&ae.height!==0&&!$)),([,,,,D])=>{Re(J,!0),Pa(1,()=>{Re(H,D)}),cn(ee(c),()=>{Re(t,[0,0]),Re(q,!0)})}),ye(ee(U,Ae(D=>D!=null&&D.scrollTop>0),yn(0)),E),Qe(ee(v,Le(U),Ae(([,D])=>D!=null)),([,D])=>{D&&(Re(R,D.viewport),Re(L,D.item),Re(W,D.gap),D.scrollTop>0&&(Re(O,!0),cn(ee(c,Zn(1)),X=>{Re(O,!1)}),Re(l,{top:D.scrollTop})))}),ye(ee(R,he(({height:D})=>D)),p),ye(ee(wt(Ie(R,Ps),Ie(L,Ps),Ie(W,(D,X)=>D&&D.column===X.column&&D.row===X.row),Ie(c)),he(([D,X,Q,ae])=>({gap:Q,item:X,scrollTop:ae,viewport:D}))),N),ye(ee(wt(Ie(T),r,Ie(W,AC),Ie(L,Ps),Ie(R,Ps),Ie(I),Ie(E),Ie(O),Ie(q),Ie(j)),Ae(([,,,,,,,D])=>!D),he(([D,[X,Q],ae,$,re,we,de,,xe,Ee])=>{const{column:Be,row:We}=ae,{height:je,width:Ve}=$,{width:Xe}=re;if(de===0&&(D===0||Xe===0))return Ap;if(Ve===0){const Et=Ma(Ee,D),Dt=Et+Math.max(de-1,0);return NC(Pp(Et,Dt,we))}const ze=Mp(Xe,Ve,Be);let Ge,rt;xe?X===0&&Q===0&&de>0?(Ge=0,rt=de-1):(Ge=ze*_s((X+We)/(je+We)),rt=ze*jp((Q+We)/(je+We))-1,rt=Ha(D-1,vo(rt,ze-1)),Ge=Ha(rt,vo(0,Ge))):(Ge=0,rt=-1);const nt=Pp(Ge,rt,we),{bottom:et,top:xt}=Rp(re,ae,$,nt),vt=jp(D/ze),dt=vt*je+(vt-1)*We-et;return{bottom:et,itemHeight:je,items:nt,itemWidth:Ve,offsetBottom:dt,offsetTop:xt,top:xt}})),_),ye(ee(I,Ae(D=>D!==null),he(D=>D.length)),T),ye(ee(wt(R,L,_,W),Ae(([D,X,{items:Q}])=>Q.length>0&&X.height!==0&&D.height!==0),he(([D,X,{items:Q},ae])=>{const{bottom:$,top:re}=Rp(D,ae,X,Q);return[re,$]}),ct(uo)),t);const M=oe(!1);ye(ee(c,Le(M),he(([D,X])=>X||D!==0)),M);const G=Xt(ee(wt(_,T),Ae(([{items:D}])=>D.length>0),Le(M),Ae(([[D,X],Q])=>{const ae=D.items[D.items.length-1].index===X-1;return(Q||D.bottom>0&&D.itemHeight>0&&D.offsetBottom===0&&D.items.length===X)&&ae}),he(([[,D]])=>D-1),ct())),Z=Xt(ee(Ie(_),Ae(({items:D})=>D.length>0&&D[0].index===0),yn(0),ct())),se=Xt(ee(Ie(_),Le(O),Ae(([{items:D},X])=>D.length>0&&!X),he(([{items:D}])=>({endIndex:D[D.length-1].index,startIndex:D[0].index})),ct(Qf),In(0)));ye(se,f.scrollSeekRangeChanged),ye(ee(H,Le(R,L,T,W),he(([D,X,Q,ae,$])=>{const re=sp(D),{align:we,behavior:de,offset:xe}=re;let Ee=re.index;Ee==="LAST"&&(Ee=ae-1),Ee=vo(0,Ee,Ha(ae-1,Ee));let Be=Ua(X,$,Q,Ee);return we==="end"?Be=_p(Be-X.height+Q.height):we==="center"&&(Be=_p(Be-X.height/2+Q.height/2)),xe&&(Be+=xe),{behavior:de,top:Be}})),l);const V=At(ee(_,he(D=>D.offsetBottom+D.bottom)),0);return ye(ee(k,he(D=>({height:D.visibleHeight,width:D.visibleWidth}))),R),{customScrollParent:x,data:I,deviation:B,footerHeight:o,gap:W,headerHeight:s,increaseViewportBy:e,initialItemCount:E,itemDimensions:L,overscan:n,restoreStateFrom:U,scrollBy:i,scrollContainerState:a,scrollHeight:K,scrollTo:l,scrollToIndex:H,scrollTop:c,smoothScrollTargetReached:d,totalCount:T,useWindowScroll:y,viewportDimensions:R,windowScrollContainerState:w,windowScrollTo:S,windowViewportRect:k,...f,gridState:_,horizontalDirection:P,initialTopMostItemIndex:j,totalListHeight:V,...m,endReached:G,propsReady:g,rangeChanged:se,startReached:Z,stateChanged:N,stateRestoreInProgress:O,...C}},lt(Ra,Ot,xo,gp,Fn,Da,Ln));function Mp(e,t,n){return vo(1,_s((e+n)/(_s(t)+n)))}function Rp(e,t,n,r){const{height:o}=n;if(o===void 0||r.length===0)return{bottom:0,top:0};const s=Ua(e,t,n,r[0].index);return{bottom:Ua(e,t,n,r[r.length-1].index)+o,top:s}}function Ua(e,t,n,r){const o=Mp(e.width,n.width,t.column),s=_s(r/o),i=s*n.height+vo(0,s-1)*t.row;return i>0?i+t.row:i}const _C=Ye(()=>{const e=oe(p=>`Item ${p}`),t=oe({}),n=oe(null),r=oe("virtuoso-grid-item"),o=oe("virtuoso-grid-list"),s=oe(Ba),i=oe("div"),a=oe(Ir),l=(p,m=null)=>At(ee(t,he(f=>f[p]),ct()),m),c=oe(!1),d=oe(!1);return ye(Ie(d),c),{components:t,computeItemKey:s,context:n,FooterComponent:l("Footer"),HeaderComponent:l("Header"),headerFooterTag:i,itemClassName:r,ItemComponent:l("Item","div"),itemContent:e,listClassName:o,ListComponent:l("List","div"),readyStateChanged:c,reportReadyState:d,ScrollerComponent:l("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder","div")}}),PC=Ye(([e,t])=>({...e,...t}),lt(jC,_C)),MC=b.memo(function(){const e=ut("gridState"),t=ut("listClassName"),n=ut("itemClassName"),r=ut("itemContent"),o=ut("computeItemKey"),s=ut("isSeeking"),i=en("scrollHeight"),a=ut("ItemComponent"),l=ut("ListComponent"),c=ut("ScrollSeekPlaceholder"),d=ut("context"),p=en("itemDimensions"),m=en("gap"),f=ut("log"),v=ut("stateRestoreInProgress"),g=en("reportReadyState"),x=Qn(b.useMemo(()=>y=>{const w=y.parentElement.parentElement.scrollHeight;i(w);const S=y.firstChild;if(S){const{height:k,width:C}=S.getBoundingClientRect();p({height:k,width:C})}m({column:Dp("column-gap",getComputedStyle(y).columnGap,f),row:Dp("row-gap",getComputedStyle(y).rowGap,f)})},[i,p,m,f]),!0,!1);return Sp(()=>{e.itemHeight>0&&e.itemWidth>0&&g(!0)},[e]),v?null:u.jsx(l,{className:t,ref:x,...jt(l,d),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(y=>{const w=o(y.index,y.data,d);return s?u.jsx(c,{...jt(c,d),height:e.itemHeight,index:y.index,width:e.itemWidth},w):b.createElement(a,{...jt(a,d),className:n,"data-index":y.index,key:w},r(y.index,y.data,d))})})}),RC=b.memo(function(){const e=ut("HeaderComponent"),t=en("headerHeight"),n=ut("headerFooterTag"),r=Qn(b.useMemo(()=>s=>{t($n(s,"height"))},[t]),!0,!1),o=ut("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...jt(e,o)})}):null}),OC=b.memo(function(){const e=ut("FooterComponent"),t=en("footerHeight"),n=ut("headerFooterTag"),r=Qn(b.useMemo(()=>s=>{t($n(s,"height"))},[t]),!0,!1),o=ut("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...jt(e,o)})}):null}),DC=({children:e})=>{const t=b.useContext(yp),n=en("itemDimensions"),r=en("viewportDimensions"),o=Qn(b.useMemo(()=>s=>{r(s.getBoundingClientRect())},[r]),!0,!1);return b.useEffect(()=>{t&&(r({height:t.viewportHeight,width:t.viewportWidth}),n({height:t.itemHeight,width:t.itemWidth}))},[t,r,n]),u.jsx("div",{ref:o,style:js(!1),children:e})},LC=({children:e})=>{const t=b.useContext(yp),n=en("windowViewportRect"),r=en("itemDimensions"),o=ut("customScrollParent"),s=Kf(n,o,!1);return b.useEffect(()=>{t&&(r({height:t.itemHeight,width:t.itemWidth}),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:t.viewportWidth}))},[t,n,r]),u.jsx("div",{ref:s,style:js(!1),children:e})},$C=b.memo(function({...e}){const t=ut("useWindowScroll"),n=ut("customScrollParent"),r=n||t?BC:FC,o=n||t?LC:DC,s=ut("context");return u.jsx(r,{...e,...jt(r,s),children:u.jsxs(o,{children:[u.jsx(RC,{}),u.jsx(MC,{}),u.jsx(OC,{})]})})}),{useEmitter:Op,useEmitterValue:ut,usePublisher:en}=wp(PC,{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"}},$C),FC=Ip({useEmitter:Op,useEmitterValue:ut,usePublisher:en}),BC=Np({useEmitter:Op,useEmitterValue:ut,usePublisher:en});function Dp(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Bt.WARN),t==="normal"?0:parseInt(t??"0",10)}const zC=Dr.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 Lp({className:e,variant:t,...n}){return u.jsx("div",{className:ne(zC({variant:t}),e),...n})}var Ms="Dialog",[$p,i1]=sn(Ms),[HC,dn]=$p(Ms),Fp=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:i=!0}=e,a=h.useRef(null),l=h.useRef(null),[c,d]=_n({prop:r,defaultProp:o??!1,onChange:s,caller:Ms});return u.jsx(HC,{scope:t,triggerRef:a,contentRef:l,contentId:Nt(),titleId:Nt(),descriptionId:Nt(),open:c,onOpenChange:d,onOpenToggle:h.useCallback(()=>d(p=>!p),[d]),modal:i,children:n})};Fp.displayName=Ms;var Bp="DialogTrigger",zp=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=dn(Bp,n),s=De(t,o.triggerRef);return u.jsx(be.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Ka(o.open),...r,ref:s,onClick:ie(e.onClick,o.onOpenToggle)})});zp.displayName=Bp;var Wa="DialogPortal",[UC,Hp]=$p(Wa,{forceMount:void 0}),Up=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=dn(Wa,t);return u.jsx(UC,{scope:t,forceMount:n,children:h.Children.map(r,i=>u.jsx(Ft,{present:n||s.open,children:u.jsx(eo,{asChild:!0,container:o,children:i})}))})};Up.displayName=Wa;var Rs="DialogOverlay",Wp=h.forwardRef((e,t)=>{const n=Hp(Rs,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=dn(Rs,e.__scopeDialog);return s.modal?u.jsx(Ft,{present:r||s.open,children:u.jsx(VC,{...o,ref:t})}):null});Wp.displayName=Rs;var WC=Vt.createSlot("DialogOverlay.RemoveScroll"),VC=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=dn(Rs,n);return u.jsx(fs,{as:WC,allowPinchZoom:!0,shards:[o.contentRef],children:u.jsx(be.div,{"data-state":Ka(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),nr="DialogContent",Vp=h.forwardRef((e,t)=>{const n=Hp(nr,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=dn(nr,e.__scopeDialog);return u.jsx(Ft,{present:r||s.open,children:s.modal?u.jsx(KC,{...o,ref:t}):u.jsx(qC,{...o,ref:t})})});Vp.displayName=nr;var KC=h.forwardRef((e,t)=>{const n=dn(nr,e.__scopeDialog),r=h.useRef(null),o=De(t,n.contentRef,r);return h.useEffect(()=>{const s=r.current;if(s)return aa(s)},[]),u.jsx(Kp,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ie(e.onCloseAutoFocus,s=>{var i;s.preventDefault(),(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:ie(e.onPointerDownOutside,s=>{const i=s.detail.originalEvent,a=i.button===0&&i.ctrlKey===!0;(i.button===2||a)&&s.preventDefault()}),onFocusOutside:ie(e.onFocusOutside,s=>s.preventDefault())})}),qC=h.forwardRef((e,t)=>{const n=dn(nr,e.__scopeDialog),r=h.useRef(!1),o=h.useRef(!1);return u.jsx(Kp,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var i,a;(i=e.onCloseAutoFocus)==null||i.call(e,s),s.defaultPrevented||(r.current||(a=n.triggerRef.current)==null||a.focus(),s.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:s=>{var l,c;(l=e.onInteractOutside)==null||l.call(e,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const i=s.target;((c=n.triggerRef.current)==null?void 0:c.contains(i))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&o.current&&s.preventDefault()}})}),Kp=h.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=dn(nr,n),l=h.useRef(null),c=De(t,l);return $i(),u.jsxs(u.Fragment,{children:[u.jsx(qo,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:u.jsx(gr,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":Ka(a.open),...i,ref:c,onDismiss:()=>a.onOpenChange(!1)})}),u.jsxs(u.Fragment,{children:[u.jsx(GC,{titleId:a.titleId}),u.jsx(XC,{contentRef:l,descriptionId:a.descriptionId})]})]})}),Va="DialogTitle",qp=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=dn(Va,n);return u.jsx(be.h2,{id:o.titleId,...r,ref:t})});qp.displayName=Va;var Gp="DialogDescription",Yp=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=dn(Gp,n);return u.jsx(be.p,{id:o.descriptionId,...r,ref:t})});Yp.displayName=Gp;var Xp="DialogClose",Jp=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=dn(Xp,n);return u.jsx(be.button,{type:"button",...r,ref:t,onClick:ie(e.onClick,()=>o.onOpenChange(!1))})});Jp.displayName=Xp;function Ka(e){return e?"open":"closed"}var Zp="DialogTitleWarning",[a1,Qp]=uw(Zp,{contentName:nr,titleName:Va,docsSlug:"dialog"}),GC=({titleId:e})=>{const t=Qp(Zp),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},GC="DialogDescriptionWarning",YC=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Qp(GC).contentName}}.`;return h.useEffect(()=>{var s;const o=(s=e.current)==null?void 0:s.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},qa=Fp,XC=zp,Ga=Up,wo=Wp,bo=Vp,rr=qp,Os=Yp,eh=Jp;const Ya=qa,JC=Ga,th=h.forwardRef(({className:e,...t},n)=>u.jsx(wo,{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}));th.displayName=wo.displayName;const Ds=h.forwardRef(({className:e,children:t,...n},r)=>{const o=h.useMemo(()=>{let s=!1;function i(a){h.Children.forEach(a,l=>{if(s||!h.isValidElement(l))return;const c=l.type;if(c===rr||(c==null?void 0:c.displayName)===rr.displayName||(c==null?void 0:c.name)==="DialogTitle"){s=!0;return}l.props&&l.props.children&&i(l.props.children)})}return i(t),s},[t]);return u.jsxs(JC,{children:[u.jsx(th,{}),u.jsxs(bo,{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(rr,{className:"sr-only",children:"Dialog"}),t,u.jsxs(eh,{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(ue.X,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]})});Ds.displayName=bo.displayName;const Ls=({className:e,...t})=>u.jsx("div",{className:ne("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});Ls.displayName="DialogHeader";const $s=h.forwardRef(({className:e,...t},n)=>u.jsx(rr,{ref:n,className:ne("text-lg font-semibold leading-none tracking-tight",e),...t}));$s.displayName=rr.displayName;const ZC=h.forwardRef(({className:e,...t},n)=>u.jsx(Os,{ref:n,className:ne("text-sm text-muted-foreground",e),...t}));ZC.displayName=Os.displayName;const QC=1,eT=1e6;let Xa=0;function tT(){return Xa=(Xa+1)%Number.MAX_SAFE_INTEGER,Xa.toString()}const Ja=new Map,nh=e=>{if(Ja.has(e))return;const t=setTimeout(()=>{Ja.delete(e),yo({type:"REMOVE_TOAST",toastId:e})},eT);Ja.set(e,t)},nT=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,QC)};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?nh(n):e.toasts.forEach(r=>{nh(r.id)}),{...e,toasts:e.toasts.map(r=>r.id===n||n===void 0?{...r,open:!1}:r)}}case"REMOVE_TOAST":return t.toastId===void 0?{...e,toasts:[]}:{...e,toasts:e.toasts.filter(n=>n.id!==t.toastId)}}},Fs=[];let Bs={toasts:[]};function yo(e){Bs=nT(Bs,e),Fs.forEach(t=>{t(Bs)})}function rT({...e}){const t=tT(),n=o=>yo({type:"UPDATE_TOAST",toast:{...o,id:t}}),r=()=>yo({type:"DISMISS_TOAST",toastId:t});return yo({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:o=>{o||r()}}}),{id:t,dismiss:r,update:n}}function Za(){const[e,t]=h.useState(Bs);return h.useEffect(()=>(Fs.push(t),()=>{const n=Fs.indexOf(t);n>-1&&Fs.splice(n,1)}),[e]),{...e,toast:rT,dismiss:n=>yo({type:"DISMISS_TOAST",toastId:n})}}function rh({isOpen:e,onClose:t,fileId:n,fileName:r,mimeType:o}){const[s,i]=b.useState(!1),[a,l]=b.useState(null),[c,d]=b.useState(null),{toast:p}=Za(),m=b.useCallback(async()=>{if(n){i(!0),d(null),l(null);try{const y=await Ii(n);l(y)}catch(y){console.error("Failed to load file:",y),d(y instanceof Error?y.message:"Failed to load file")}finally{i(!1)}}},[n]);b.useEffect(()=>{e&&n&&m()},[e,n,m]);const f=async()=>{if(n)try{await Qc(n),p({title:"Download started",description:`Downloading ${r}`})}catch(y){console.error("Failed to download file:",y),p({title:"Download failed",description:String(y),variant:"destructive"})}},v=async()=>{if(n)try{const y=await Ii(n),w=new Blob([y],{type:o}),S=URL.createObjectURL(w);window.open(S,"_blank"),URL.revokeObjectURL(S)}catch(y){console.error("Failed to open file externally:",y),p({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(ue.Loader,{className:"h-8 w-8 animate-spin mr-3"}),u.jsx("span",{children:"Loading file..."})]}):c?u.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[u.jsx("div",{className:"text-red-500 mb-4",children:"⚠️"}),u.jsx("p",{className:"text-red-600 mb-4",children:c}),u.jsx(at,{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(ue.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(ue.Image,{className:"h-5 w-5"}):u.jsx(ue.FileText,{className:"h-5 w-5"});return u.jsx(Ya,{open:e,onOpenChange:t,children:u.jsxs(Ds,{className:"max-w-4xl max-h-[90vh] overflow-hidden",children:[u.jsx(Ls,{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($s,{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(at,{variant:"outline",size:"sm",onClick:v,className:"flex items-center gap-2",children:[u.jsx(ue.ExternalLink,{className:"h-4 w-4"}),"External"]}),u.jsxs(at,{variant:"outline",size:"sm",onClick:f,className:"flex items-center gap-2",children:[u.jsx(ue.Download,{className:"h-4 w-4"}),"Download"]})]})]})}),u.jsx("div",{className:"flex-1 overflow-hidden",children:g()})]})})}function oh(){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 or=oh();function oT(e){or=e}const sh=/[&<>"']/,sT=new RegExp(sh.source,"g"),ih=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,iT=new RegExp(ih.source,"g"),aT={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},ah=e=>aT[e];function _t(e,t){if(t){if(sh.test(e))return e.replace(sT,ah)}else if(ih.test(e))return e.replace(iT,ah);return e}const lT=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function lh(e){return e.replace(lT,(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 cT=/(^|[^\[])\^/g;function st(e,t){e=typeof e=="string"?e:e.source,t=t||"";const n={replace:(r,o)=>(o=o.source||o,o=o.replace(cT,"$1"),e=e.replace(r,o),n),getRegex:()=>new RegExp(e,t)};return n}const uT=/[^\w:]/g,dT=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function ch(e,t,n){if(e){let r;try{r=decodeURIComponent(lh(n)).replace(uT,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}t&&!dT.test(n)&&(n=mT(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const zs={},fT=/^[^:]+:\/*[^/]*$/,pT=/^([^:]+:)[\s\S]*$/,hT=/^([^:]+:\/*[^/]*)[\s\S]*$/;function mT(e,t){zs[" "+e]||(fT.test(e)?zs[" "+e]=e+"/":zs[" "+e]=Us(e,"/",!0)),e=zs[" "+e];const n=e.indexOf(":")===-1;return t.substring(0,2)==="//"?n?t:e.replace(pT,"$1")+t:t.charAt(0)==="/"?n?t:e.replace(hT,"$1")+t:e+t}const Hs={exec:function(){}};function uh(e,t){const n=e.replace(/\|/g,(s,i,a)=>{let l=!1,c=i;for(;--c>=0&&a[c]==="\\";)l=!l;return l?"|":" |"}),r=n.split(/ \|/);let o=0;if(r[0].trim()||r.shift(),r.length>0&&!r[r.length-1].trim()&&r.pop(),r.length>t)r.splice(t);else for(;r.length<t;)r.push("");for(;o<r.length;o++)r[o]=r[o].trim().replace(/\\\|/g,"|");return r}function Us(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 gT(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 xT(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 dh(e,t){if(t<1)return"";let n="";for(;t>1;)t&1&&(n+=e),t>>=1,e+=e;return n+e}function fh(e,t,n,r){const o=t.href,s=t.title?_t(t.title):null,i=e[1].replace(/\\([\[\]])/g,"$1");if(e[0].charAt(0)!=="!"){r.state.inLink=!0;const a={type:"link",raw:n,href:o,title:s,text:i,tokens:r.inlineTokens(i)};return r.state.inLink=!1,a}return{type:"image",raw:n,href:o,title:s,text:_t(i)}}function vT(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},YC="DialogDescriptionWarning",XC=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Qp(YC).contentName}}.`;return h.useEffect(()=>{var s;const o=(s=e.current)==null?void 0:s.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},qa=Fp,JC=zp,Ga=Up,wo=Wp,bo=Vp,rr=qp,Os=Yp,eh=Jp;const Ya=qa,ZC=Ga,th=h.forwardRef(({className:e,...t},n)=>u.jsx(wo,{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}));th.displayName=wo.displayName;const Ds=h.forwardRef(({className:e,children:t,...n},r)=>{const o=h.useMemo(()=>{let s=!1;function i(a){h.Children.forEach(a,l=>{if(s||!h.isValidElement(l))return;const c=l.type;if(c===rr||(c==null?void 0:c.displayName)===rr.displayName||(c==null?void 0:c.name)==="DialogTitle"){s=!0;return}l.props&&l.props.children&&i(l.props.children)})}return i(t),s},[t]);return u.jsxs(ZC,{children:[u.jsx(th,{}),u.jsxs(bo,{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(rr,{className:"sr-only",children:"Dialog"}),t,u.jsxs(eh,{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(ue.X,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]})});Ds.displayName=bo.displayName;const Ls=({className:e,...t})=>u.jsx("div",{className:ne("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});Ls.displayName="DialogHeader";const $s=h.forwardRef(({className:e,...t},n)=>u.jsx(rr,{ref:n,className:ne("text-lg font-semibold leading-none tracking-tight",e),...t}));$s.displayName=rr.displayName;const QC=h.forwardRef(({className:e,...t},n)=>u.jsx(Os,{ref:n,className:ne("text-sm text-muted-foreground",e),...t}));QC.displayName=Os.displayName;const eT=1,tT=1e6;let Xa=0;function nT(){return Xa=(Xa+1)%Number.MAX_SAFE_INTEGER,Xa.toString()}const Ja=new Map,nh=e=>{if(Ja.has(e))return;const t=setTimeout(()=>{Ja.delete(e),yo({type:"REMOVE_TOAST",toastId:e})},tT);Ja.set(e,t)},rT=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,eT)};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?nh(n):e.toasts.forEach(r=>{nh(r.id)}),{...e,toasts:e.toasts.map(r=>r.id===n||n===void 0?{...r,open:!1}:r)}}case"REMOVE_TOAST":return t.toastId===void 0?{...e,toasts:[]}:{...e,toasts:e.toasts.filter(n=>n.id!==t.toastId)}}},Fs=[];let Bs={toasts:[]};function yo(e){Bs=rT(Bs,e),Fs.forEach(t=>{t(Bs)})}function oT({...e}){const t=nT(),n=o=>yo({type:"UPDATE_TOAST",toast:{...o,id:t}}),r=()=>yo({type:"DISMISS_TOAST",toastId:t});return yo({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:o=>{o||r()}}}),{id:t,dismiss:r,update:n}}function Za(){const[e,t]=h.useState(Bs);return h.useEffect(()=>(Fs.push(t),()=>{const n=Fs.indexOf(t);n>-1&&Fs.splice(n,1)}),[e]),{...e,toast:oT,dismiss:n=>yo({type:"DISMISS_TOAST",toastId:n})}}function rh({isOpen:e,onClose:t,fileId:n,fileName:r,mimeType:o}){const[s,i]=b.useState(!1),[a,l]=b.useState(null),[c,d]=b.useState(null),{toast:p}=Za(),m=b.useCallback(async()=>{if(n){i(!0),d(null),l(null);try{const y=await Ii(n);l(y)}catch(y){console.error("Failed to load file:",y),d(y instanceof Error?y.message:"Failed to load file")}finally{i(!1)}}},[n]);b.useEffect(()=>{e&&n&&m()},[e,n,m]);const f=async()=>{if(n)try{await Qc(n),p({title:"Download started",description:`Downloading ${r}`})}catch(y){console.error("Failed to download file:",y),p({title:"Download failed",description:String(y),variant:"destructive"})}},v=async()=>{if(n)try{const y=await Ii(n),w=new Blob([y],{type:o}),S=URL.createObjectURL(w);window.open(S,"_blank"),URL.revokeObjectURL(S)}catch(y){console.error("Failed to open file externally:",y),p({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(ue.Loader,{className:"h-8 w-8 animate-spin mr-3"}),u.jsx("span",{children:"Loading file..."})]}):c?u.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[u.jsx("div",{className:"text-red-500 mb-4",children:"⚠️"}),u.jsx("p",{className:"text-red-600 mb-4",children:c}),u.jsx(at,{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(ue.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(ue.Image,{className:"h-5 w-5"}):u.jsx(ue.FileText,{className:"h-5 w-5"});return u.jsx(Ya,{open:e,onOpenChange:t,children:u.jsxs(Ds,{className:"max-w-4xl max-h-[90vh] overflow-hidden",children:[u.jsx(Ls,{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($s,{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(at,{variant:"outline",size:"sm",onClick:v,className:"flex items-center gap-2",children:[u.jsx(ue.ExternalLink,{className:"h-4 w-4"}),"External"]}),u.jsxs(at,{variant:"outline",size:"sm",onClick:f,className:"flex items-center gap-2",children:[u.jsx(ue.Download,{className:"h-4 w-4"}),"Download"]})]})]})}),u.jsx("div",{className:"flex-1 overflow-hidden",children:g()})]})})}function oh(){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 or=oh();function sT(e){or=e}const sh=/[&<>"']/,iT=new RegExp(sh.source,"g"),ih=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,aT=new RegExp(ih.source,"g"),lT={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},ah=e=>lT[e];function _t(e,t){if(t){if(sh.test(e))return e.replace(iT,ah)}else if(ih.test(e))return e.replace(aT,ah);return e}const cT=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function lh(e){return e.replace(cT,(t,n)=>(n=n.toLowerCase(),n==="colon"?":":n.charAt(0)==="#"?n.charAt(1)==="x"?String.fromCharCode(parseInt(n.substring(2),16)):String.fromCharCode(+n.substring(1)):""))}const uT=/(^|[^\[])\^/g;function st(e,t){e=typeof e=="string"?e:e.source,t=t||"";const n={replace:(r,o)=>(o=o.source||o,o=o.replace(uT,"$1"),e=e.replace(r,o),n),getRegex:()=>new RegExp(e,t)};return n}const dT=/[^\w:]/g,fT=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function ch(e,t,n){if(e){let r;try{r=decodeURIComponent(lh(n)).replace(dT,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}t&&!fT.test(n)&&(n=gT(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const zs={},pT=/^[^:]+:\/*[^/]*$/,hT=/^([^:]+:)[\s\S]*$/,mT=/^([^:]+:\/*[^/]*)[\s\S]*$/;function gT(e,t){zs[" "+e]||(pT.test(e)?zs[" "+e]=e+"/":zs[" "+e]=Us(e,"/",!0)),e=zs[" "+e];const n=e.indexOf(":")===-1;return t.substring(0,2)==="//"?n?t:e.replace(hT,"$1")+t:t.charAt(0)==="/"?n?t:e.replace(mT,"$1")+t:e+t}const Hs={exec:function(){}};function uh(e,t){const n=e.replace(/\|/g,(s,i,a)=>{let l=!1,c=i;for(;--c>=0&&a[c]==="\\";)l=!l;return l?"|":" |"}),r=n.split(/ \|/);let o=0;if(r[0].trim()||r.shift(),r.length>0&&!r[r.length-1].trim()&&r.pop(),r.length>t)r.splice(t);else for(;r.length<t;)r.push("");for(;o<r.length;o++)r[o]=r[o].trim().replace(/\\\|/g,"|");return r}function Us(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 xT(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 vT(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 dh(e,t){if(t<1)return"";let n="";for(;t>1;)t&1&&(n+=e),t>>=1,e+=e;return n+e}function fh(e,t,n,r){const o=t.href,s=t.title?_t(t.title):null,i=e[1].replace(/\\([\[\]])/g,"$1");if(e[0].charAt(0)!=="!"){r.state.inLink=!0;const a={type:"link",raw:n,href:o,title:s,text:i,tokens:r.inlineTokens(i)};return r.state.inLink=!1,a}return{type:"image",raw:n,href:o,title:s,text:_t(i)}}function wT(e,t){const n=e.match(/^(\s+)(?:```)/);if(n===null)return t;const r=n[1];return t.split(`
84
84
  `).map(o=>{const s=o.match(/^\s+/);if(s===null)return o;const[i]=s;return i.length>=r.length?o.slice(r.length):o}).join(`
85
85
  `)}class Qa{constructor(t){this.options=t||or}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:Us(r,`
86
- `)}}}fences(t){const n=this.rules.block.fences.exec(t);if(n){const r=n[0],o=vT(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=Us(r,"#");(this.options.pedantic||!o||/ $/.test(o))&&(r=o.trim())}return{type:"heading",raw:n[0],depth:n[1].length,text:r,tokens:this.lexer.inline(r)}}}hr(t){const n=this.rules.block.hr.exec(t);if(n)return{type:"hr",raw:n[0]}}blockquote(t){const n=this.rules.block.blockquote.exec(t);if(n){const r=n[0].replace(/^ *>[ \t]?/gm,""),o=this.lexer.state.top;this.lexer.state.top=!0;const s=this.lexer.blockTokens(r);return this.lexer.state.top=o,{type:"blockquote",raw:n[0],tokens:s,text:r}}}list(t){let n=this.rules.block.list.exec(t);if(n){let r,o,s,i,a,l,c,d,p,m,f,v,g=n[1].trim();const x=g.length>1,y={type:"list",raw:"",ordered:x,start:x?+g.slice(0,-1):"",loose:!1,items:[]};g=x?`\\d{1,9}\\${g.slice(-1)}`:`\\${g}`,this.options.pedantic&&(g=x?g:"[*+-]");const w=new RegExp(`^( {0,3}${g})((?:[ ][^\\n]*)?(?:\\n|$))`);for(;t&&(v=!1,!(!(n=w.exec(t))||this.rules.block.hr.test(t)));){if(r=n[0],t=t.substring(r.length),d=n[2].split(`
86
+ `)}}}fences(t){const n=this.rules.block.fences.exec(t);if(n){const r=n[0],o=wT(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=Us(r,"#");(this.options.pedantic||!o||/ $/.test(o))&&(r=o.trim())}return{type:"heading",raw:n[0],depth:n[1].length,text:r,tokens:this.lexer.inline(r)}}}hr(t){const n=this.rules.block.hr.exec(t);if(n)return{type:"hr",raw:n[0]}}blockquote(t){const n=this.rules.block.blockquote.exec(t);if(n){const r=n[0].replace(/^ *>[ \t]?/gm,""),o=this.lexer.state.top;this.lexer.state.top=!0;const s=this.lexer.blockTokens(r);return this.lexer.state.top=o,{type:"blockquote",raw:n[0],tokens:s,text:r}}}list(t){let n=this.rules.block.list.exec(t);if(n){let r,o,s,i,a,l,c,d,p,m,f,v,g=n[1].trim();const x=g.length>1,y={type:"list",raw:"",ordered:x,start:x?+g.slice(0,-1):"",loose:!1,items:[]};g=x?`\\d{1,9}\\${g.slice(-1)}`:`\\${g}`,this.options.pedantic&&(g=x?g:"[*+-]");const w=new RegExp(`^( {0,3}${g})((?:[ ][^\\n]*)?(?:\\n|$))`);for(;t&&(v=!1,!(!(n=w.exec(t))||this.rules.block.hr.test(t)));){if(r=n[0],t=t.substring(r.length),d=n[2].split(`
87
87
  `,1)[0].replace(/^\t+/,k=>" ".repeat(3*k.length)),p=t.split(`
88
88
  `,1)[0],this.options.pedantic?(i=2,f=d.trimLeft()):(i=n[2].search(/[^ ]/),i=i>4?1:i,f=d.slice(i),i+=n[1].length),l=!1,!d&&/^ *$/.test(p)&&(r+=p+`
89
89
  `,t=t.substring(p.length+1),v=!0),!v){const k=new RegExp(`^ {0,${Math.min(3,i-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),C=new RegExp(`^ {0,${Math.min(3,i-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),T=new RegExp(`^ {0,${Math.min(3,i-1)}}(?:\`\`\`|~~~)`),E=new RegExp(`^ {0,${Math.min(3,i-1)}}#`);for(;t&&(m=t.split(`
@@ -92,8 +92,8 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
92
92
  `+p}!l&&!p.trim()&&(l=!0),r+=m+`
93
93
  `,t=t.substring(m.length+1),d=p.slice(i)}}y.loose||(c?y.loose=!0:/\n *\n *$/.test(r)&&(c=!0)),this.options.gfm&&(o=/^\[[ xX]\] /.exec(f),o&&(s=o[0]!=="[ ] ",f=f.replace(/^\[[ xX]\] +/,""))),y.items.push({type:"list_item",raw:r,task:!!o,checked:s,loose:!1,text:f}),y.raw+=r}y.items[y.items.length-1].raw=r.trimRight(),y.items[y.items.length-1].text=f.trimRight(),y.raw=y.raw.trimRight();const S=y.items.length;for(a=0;a<S;a++)if(this.lexer.state.top=!1,y.items[a].tokens=this.lexer.blockTokens(y.items[a].text,[]),!y.loose){const k=y.items[a].tokens.filter(T=>T.type==="space"),C=k.length>0&&k.some(T=>/\n.*\n/.test(T.raw));y.loose=C}if(y.loose)for(a=0;a<S;a++)y.items[a].loose=!0;return y}}html(t){const n=this.rules.block.html.exec(t);if(n){const r={type:"html",raw:n[0],pre:!this.options.sanitizer&&(n[1]==="pre"||n[1]==="script"||n[1]==="style"),text:n[0]};if(this.options.sanitize){const o=this.options.sanitizer?this.options.sanitizer(n[0]):_t(n[0]);r.type="paragraph",r.text=o,r.tokens=this.lexer.inline(o)}return r}}def(t){const n=this.rules.block.def.exec(t);if(n){const r=n[1].toLowerCase().replace(/\s+/g," "),o=n[2]?n[2].replace(/^<(.*)>$/,"$1").replace(this.rules.inline._escapes,"$1"):"",s=n[3]?n[3].substring(1,n[3].length-1).replace(this.rules.inline._escapes,"$1"):n[3];return{type:"def",tag:r,raw:n[0],href:o,title:s}}}table(t){const n=this.rules.block.table.exec(t);if(n){const r={type:"table",header:uh(n[1]).map(o=>({text:o})),align:n[2].replace(/^ *|\| *$/g,"").split(/ *\| */),rows:n[3]&&n[3].trim()?n[3].replace(/\n[ \t]*$/,"").split(`
94
94
  `):[]};if(r.header.length===r.align.length){r.raw=n[0];let o=r.align.length,s,i,a,l;for(s=0;s<o;s++)/^ *-+: *$/.test(r.align[s])?r.align[s]="right":/^ *:-+: *$/.test(r.align[s])?r.align[s]="center":/^ *:-+ *$/.test(r.align[s])?r.align[s]="left":r.align[s]=null;for(o=r.rows.length,s=0;s<o;s++)r.rows[s]=uh(r.rows[s],r.header.length).map(c=>({text:c}));for(o=r.header.length,i=0;i<o;i++)r.header[i].tokens=this.lexer.inline(r.header[i].text);for(o=r.rows.length,i=0;i<o;i++)for(l=r.rows[i],a=0;a<l.length;a++)l[a].tokens=this.lexer.inline(l[a].text);return r}}}lheading(t){const n=this.rules.block.lheading.exec(t);if(n)return{type:"heading",raw:n[0],depth:n[2].charAt(0)==="="?1:2,text:n[1],tokens:this.lexer.inline(n[1])}}paragraph(t){const n=this.rules.block.paragraph.exec(t);if(n){const r=n[1].charAt(n[1].length-1)===`
95
- `?n[1].slice(0,-1):n[1];return{type:"paragraph",raw:n[0],text:r,tokens:this.lexer.inline(r)}}}text(t){const n=this.rules.block.text.exec(t);if(n)return{type:"text",raw:n[0],text:n[0],tokens:this.lexer.inline(n[0])}}escape(t){const n=this.rules.inline.escape.exec(t);if(n)return{type:"escape",raw:n[0],text:_t(n[1])}}tag(t){const n=this.rules.inline.tag.exec(t);if(n)return!this.lexer.state.inLink&&/^<a /i.test(n[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&/^<\/a>/i.test(n[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(n[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(n[0])&&(this.lexer.state.inRawBlock=!1),{type:this.options.sanitize?"text":"html",raw:n[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(n[0]):_t(n[0]):n[0]}}link(t){const n=this.rules.inline.link.exec(t);if(n){const r=n[2].trim();if(!this.options.pedantic&&/^</.test(r)){if(!/>$/.test(r))return;const i=Us(r.slice(0,-1),"\\");if((r.length-i.length)%2===0)return}else{const i=gT(n[2],"()");if(i>-1){const l=(n[0].indexOf("!")===0?5:4)+n[1].length+i;n[2]=n[2].substring(0,i),n[0]=n[0].substring(0,l).trim(),n[3]=""}}let o=n[2],s="";if(this.options.pedantic){const i=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(o);i&&(o=i[1],s=i[3])}else s=n[3]?n[3].slice(1,-1):"";return o=o.trim(),/^</.test(o)&&(this.options.pedantic&&!/>$/.test(r)?o=o.slice(1):o=o.slice(1,-1)),fh(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 fh(r,o,r[0],this.lexer)}}emStrong(t,n,r=""){let o=this.rules.inline.emStrong.lDelim.exec(t);if(!o||o[3]&&r.match(/[\p{L}\p{N}]/u))return;const s=o[1]||o[2]||"";if(!s||s&&(r===""||this.rules.inline.punctuation.exec(r))){const i=o[0].length-1;let a,l,c=i,d=0;const p=o[0][0]==="*"?this.rules.inline.emStrong.rDelimAst:this.rules.inline.emStrong.rDelimUnd;for(p.lastIndex=0,n=n.slice(-1*t.length+i);(o=p.exec(n))!=null;){if(a=o[1]||o[2]||o[3]||o[4]||o[5]||o[6],!a)continue;if(l=a.length,o[3]||o[4]){c+=l;continue}else if((o[5]||o[6])&&i%3&&!((i+l)%3)){d+=l;continue}if(c-=l,c>0)continue;l=Math.min(l,l+c+d);const m=t.slice(0,i+o.index+(o[0].length-a.length)+l);if(Math.min(i,l)%2){const v=m.slice(1,-1);return{type:"em",raw:m,text:v,tokens:this.lexer.inlineTokens(v)}}const f=m.slice(2,-2);return{type:"strong",raw:m,text:f,tokens:this.lexer.inlineTokens(f)}}}}codespan(t){const n=this.rules.inline.code.exec(t);if(n){let r=n[2].replace(/\n/g," ");const o=/[^ ]/.test(r),s=/^ /.test(r)&&/ $/.test(r);return o&&s&&(r=r.substring(1,r.length-1)),r=_t(r,!0),{type:"codespan",raw:n[0],text:r}}}br(t){const n=this.rules.inline.br.exec(t);if(n)return{type:"br",raw:n[0]}}del(t){const n=this.rules.inline.del.exec(t);if(n)return{type:"del",raw:n[0],text:n[2],tokens:this.lexer.inlineTokens(n[2])}}autolink(t,n){const r=this.rules.inline.autolink.exec(t);if(r){let o,s;return r[2]==="@"?(o=_t(this.options.mangle?n(r[1]):r[1]),s="mailto:"+o):(o=_t(r[1]),s=o),{type:"link",raw:r[0],text:o,href:s,tokens:[{type:"text",raw:o,text:o}]}}}url(t,n){let r;if(r=this.rules.inline.url.exec(t)){let o,s;if(r[2]==="@")o=_t(this.options.mangle?n(r[0]):r[0]),s="mailto:"+o;else{let i;do i=r[0],r[0]=this.rules.inline._backpedal.exec(r[0])[0];while(i!==r[0]);o=_t(r[0]),r[1]==="www."?s="http://"+r[0]:s=r[0]}return{type:"link",raw:r[0],text:o,href:s,tokens:[{type:"text",raw:o,text:o}]}}}inlineText(t,n){const r=this.rules.inline.text.exec(t);if(r){let o;return this.lexer.state.inRawBlock?o=this.options.sanitize?this.options.sanitizer?this.options.sanitizer(r[0]):_t(r[0]):r[0]:o=_t(this.options.smartypants?n(r[0]):r[0]),{type:"text",raw:r[0],text:o}}}}const ke={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:Hs,lheading:/^((?:.|\n(?!\n))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,text:/^[^\n]+/};ke._label=/(?!\s*\])(?:\\.|[^\[\]\\])+/,ke._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,ke.def=st(ke.def).replace("label",ke._label).replace("title",ke._title).getRegex(),ke.bullet=/(?:[*+-]|\d{1,9}[.)])/,ke.listItemStart=st(/^( *)(bull) */).replace("bull",ke.bullet).getRegex(),ke.list=st(ke.list).replace(/bull/g,ke.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+ke.def.source+")").getRegex(),ke._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",ke._comment=/<!--(?!-?>)[\s\S]*?(?:-->|$)/,ke.html=st(ke.html,"i").replace("comment",ke._comment).replace("tag",ke._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),ke.paragraph=st(ke._paragraph).replace("hr",ke.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",ke._tag).getRegex(),ke.blockquote=st(ke.blockquote).replace("paragraph",ke.paragraph).getRegex(),ke.normal={...ke},ke.gfm={...ke.normal,table:"^ *([^\\n ].*\\|.*)\\n {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"},ke.gfm.table=st(ke.gfm.table).replace("hr",ke.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",ke._tag).getRegex(),ke.gfm.paragraph=st(ke._paragraph).replace("hr",ke.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("table",ke.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",ke._tag).getRegex(),ke.pedantic={...ke.normal,html:st(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",ke._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:Hs,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:st(ke.normal._paragraph).replace("hr",ke.hr).replace("heading",` *#{1,6} *[^
96
- ]`).replace("lheading",ke.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()};const me={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:Hs,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:Hs,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,punctuation:/^([\spunctuation])/};me._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",me.punctuation=st(me.punctuation).replace(/punctuation/g,me._punctuation).getRegex(),me.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g,me.escapedEmSt=/(?:^|[^\\])(?:\\\\)*\\[*_]/g,me._comment=st(ke._comment).replace("(?:-->|$)","-->").getRegex(),me.emStrong.lDelim=st(me.emStrong.lDelim).replace(/punct/g,me._punctuation).getRegex(),me.emStrong.rDelimAst=st(me.emStrong.rDelimAst,"g").replace(/punct/g,me._punctuation).getRegex(),me.emStrong.rDelimUnd=st(me.emStrong.rDelimUnd,"g").replace(/punct/g,me._punctuation).getRegex(),me._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,me._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,me._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])?)+(?![-_])/,me.autolink=st(me.autolink).replace("scheme",me._scheme).replace("email",me._email).getRegex(),me._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,me.tag=st(me.tag).replace("comment",me._comment).replace("attribute",me._attribute).getRegex(),me._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,me._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/,me._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,me.link=st(me.link).replace("label",me._label).replace("href",me._href).replace("title",me._title).getRegex(),me.reflink=st(me.reflink).replace("label",me._label).replace("ref",ke._label).getRegex(),me.nolink=st(me.nolink).replace("ref",ke._label).getRegex(),me.reflinkSearch=st(me.reflinkSearch,"g").replace("reflink",me.reflink).replace("nolink",me.nolink).getRegex(),me.normal={...me},me.pedantic={...me.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:st(/^!?\[(label)\]\((.*?)\)/).replace("label",me._label).getRegex(),reflink:st(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",me._label).getRegex()},me.gfm={...me.normal,escape:st(me.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.!#$%&'*+\/=?_`{\|}~-]+@)))/},me.gfm.url=st(me.gfm.url,"i").replace("email",me.gfm._extended_email).getRegex(),me.breaks={...me.gfm,br:st(me.br).replace("{2,}","*").getRegex(),text:st(me.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()};function wT(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 ph(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 Bn{constructor(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||or,this.options.tokenizer=this.options.tokenizer||new Qa,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:ke.normal,inline:me.normal};this.options.pedantic?(n.block=ke.pedantic,n.inline=me.pedantic):this.options.gfm&&(n.block=ke.gfm,this.options.breaks?n.inline=me.breaks:n.inline=me.gfm),this.tokenizer.rules=n}static get rules(){return{block:ke,inline:me}}static lex(t,n){return new Bn(n).lex(t)}static lexInline(t,n){return new Bn(n).inlineTokens(t)}lex(t){t=t.replace(/\r\n|\r/g,`
95
+ `?n[1].slice(0,-1):n[1];return{type:"paragraph",raw:n[0],text:r,tokens:this.lexer.inline(r)}}}text(t){const n=this.rules.block.text.exec(t);if(n)return{type:"text",raw:n[0],text:n[0],tokens:this.lexer.inline(n[0])}}escape(t){const n=this.rules.inline.escape.exec(t);if(n)return{type:"escape",raw:n[0],text:_t(n[1])}}tag(t){const n=this.rules.inline.tag.exec(t);if(n)return!this.lexer.state.inLink&&/^<a /i.test(n[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&/^<\/a>/i.test(n[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(n[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(n[0])&&(this.lexer.state.inRawBlock=!1),{type:this.options.sanitize?"text":"html",raw:n[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(n[0]):_t(n[0]):n[0]}}link(t){const n=this.rules.inline.link.exec(t);if(n){const r=n[2].trim();if(!this.options.pedantic&&/^</.test(r)){if(!/>$/.test(r))return;const i=Us(r.slice(0,-1),"\\");if((r.length-i.length)%2===0)return}else{const i=xT(n[2],"()");if(i>-1){const l=(n[0].indexOf("!")===0?5:4)+n[1].length+i;n[2]=n[2].substring(0,i),n[0]=n[0].substring(0,l).trim(),n[3]=""}}let o=n[2],s="";if(this.options.pedantic){const i=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(o);i&&(o=i[1],s=i[3])}else s=n[3]?n[3].slice(1,-1):"";return o=o.trim(),/^</.test(o)&&(this.options.pedantic&&!/>$/.test(r)?o=o.slice(1):o=o.slice(1,-1)),fh(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 fh(r,o,r[0],this.lexer)}}emStrong(t,n,r=""){let o=this.rules.inline.emStrong.lDelim.exec(t);if(!o||o[3]&&r.match(/[\p{L}\p{N}]/u))return;const s=o[1]||o[2]||"";if(!s||s&&(r===""||this.rules.inline.punctuation.exec(r))){const i=o[0].length-1;let a,l,c=i,d=0;const p=o[0][0]==="*"?this.rules.inline.emStrong.rDelimAst:this.rules.inline.emStrong.rDelimUnd;for(p.lastIndex=0,n=n.slice(-1*t.length+i);(o=p.exec(n))!=null;){if(a=o[1]||o[2]||o[3]||o[4]||o[5]||o[6],!a)continue;if(l=a.length,o[3]||o[4]){c+=l;continue}else if((o[5]||o[6])&&i%3&&!((i+l)%3)){d+=l;continue}if(c-=l,c>0)continue;l=Math.min(l,l+c+d);const m=t.slice(0,i+o.index+(o[0].length-a.length)+l);if(Math.min(i,l)%2){const v=m.slice(1,-1);return{type:"em",raw:m,text:v,tokens:this.lexer.inlineTokens(v)}}const f=m.slice(2,-2);return{type:"strong",raw:m,text:f,tokens:this.lexer.inlineTokens(f)}}}}codespan(t){const n=this.rules.inline.code.exec(t);if(n){let r=n[2].replace(/\n/g," ");const o=/[^ ]/.test(r),s=/^ /.test(r)&&/ $/.test(r);return o&&s&&(r=r.substring(1,r.length-1)),r=_t(r,!0),{type:"codespan",raw:n[0],text:r}}}br(t){const n=this.rules.inline.br.exec(t);if(n)return{type:"br",raw:n[0]}}del(t){const n=this.rules.inline.del.exec(t);if(n)return{type:"del",raw:n[0],text:n[2],tokens:this.lexer.inlineTokens(n[2])}}autolink(t,n){const r=this.rules.inline.autolink.exec(t);if(r){let o,s;return r[2]==="@"?(o=_t(this.options.mangle?n(r[1]):r[1]),s="mailto:"+o):(o=_t(r[1]),s=o),{type:"link",raw:r[0],text:o,href:s,tokens:[{type:"text",raw:o,text:o}]}}}url(t,n){let r;if(r=this.rules.inline.url.exec(t)){let o,s;if(r[2]==="@")o=_t(this.options.mangle?n(r[0]):r[0]),s="mailto:"+o;else{let i;do i=r[0],r[0]=this.rules.inline._backpedal.exec(r[0])[0];while(i!==r[0]);o=_t(r[0]),r[1]==="www."?s="http://"+r[0]:s=r[0]}return{type:"link",raw:r[0],text:o,href:s,tokens:[{type:"text",raw:o,text:o}]}}}inlineText(t,n){const r=this.rules.inline.text.exec(t);if(r){let o;return this.lexer.state.inRawBlock?o=this.options.sanitize?this.options.sanitizer?this.options.sanitizer(r[0]):_t(r[0]):r[0]:o=_t(this.options.smartypants?n(r[0]):r[0]),{type:"text",raw:r[0],text:o}}}}const ke={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:Hs,lheading:/^((?:.|\n(?!\n))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,text:/^[^\n]+/};ke._label=/(?!\s*\])(?:\\.|[^\[\]\\])+/,ke._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,ke.def=st(ke.def).replace("label",ke._label).replace("title",ke._title).getRegex(),ke.bullet=/(?:[*+-]|\d{1,9}[.)])/,ke.listItemStart=st(/^( *)(bull) */).replace("bull",ke.bullet).getRegex(),ke.list=st(ke.list).replace(/bull/g,ke.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+ke.def.source+")").getRegex(),ke._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",ke._comment=/<!--(?!-?>)[\s\S]*?(?:-->|$)/,ke.html=st(ke.html,"i").replace("comment",ke._comment).replace("tag",ke._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),ke.paragraph=st(ke._paragraph).replace("hr",ke.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",ke._tag).getRegex(),ke.blockquote=st(ke.blockquote).replace("paragraph",ke.paragraph).getRegex(),ke.normal={...ke},ke.gfm={...ke.normal,table:"^ *([^\\n ].*\\|.*)\\n {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"},ke.gfm.table=st(ke.gfm.table).replace("hr",ke.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",ke._tag).getRegex(),ke.gfm.paragraph=st(ke._paragraph).replace("hr",ke.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("table",ke.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",ke._tag).getRegex(),ke.pedantic={...ke.normal,html:st(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",ke._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:Hs,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:st(ke.normal._paragraph).replace("hr",ke.hr).replace("heading",` *#{1,6} *[^
96
+ ]`).replace("lheading",ke.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()};const me={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:Hs,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:Hs,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,punctuation:/^([\spunctuation])/};me._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",me.punctuation=st(me.punctuation).replace(/punctuation/g,me._punctuation).getRegex(),me.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g,me.escapedEmSt=/(?:^|[^\\])(?:\\\\)*\\[*_]/g,me._comment=st(ke._comment).replace("(?:-->|$)","-->").getRegex(),me.emStrong.lDelim=st(me.emStrong.lDelim).replace(/punct/g,me._punctuation).getRegex(),me.emStrong.rDelimAst=st(me.emStrong.rDelimAst,"g").replace(/punct/g,me._punctuation).getRegex(),me.emStrong.rDelimUnd=st(me.emStrong.rDelimUnd,"g").replace(/punct/g,me._punctuation).getRegex(),me._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,me._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,me._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])?)+(?![-_])/,me.autolink=st(me.autolink).replace("scheme",me._scheme).replace("email",me._email).getRegex(),me._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,me.tag=st(me.tag).replace("comment",me._comment).replace("attribute",me._attribute).getRegex(),me._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,me._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/,me._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,me.link=st(me.link).replace("label",me._label).replace("href",me._href).replace("title",me._title).getRegex(),me.reflink=st(me.reflink).replace("label",me._label).replace("ref",ke._label).getRegex(),me.nolink=st(me.nolink).replace("ref",ke._label).getRegex(),me.reflinkSearch=st(me.reflinkSearch,"g").replace("reflink",me.reflink).replace("nolink",me.nolink).getRegex(),me.normal={...me},me.pedantic={...me.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:st(/^!?\[(label)\]\((.*?)\)/).replace("label",me._label).getRegex(),reflink:st(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",me._label).getRegex()},me.gfm={...me.normal,escape:st(me.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.!#$%&'*+\/=?_`{\|}~-]+@)))/},me.gfm.url=st(me.gfm.url,"i").replace("email",me.gfm._extended_email).getRegex(),me.breaks={...me.gfm,br:st(me.br).replace("{2,}","*").getRegex(),text:st(me.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()};function bT(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 ph(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 Bn{constructor(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||or,this.options.tokenizer=this.options.tokenizer||new Qa,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:ke.normal,inline:me.normal};this.options.pedantic?(n.block=ke.pedantic,n.inline=me.pedantic):this.options.gfm&&(n.block=ke.gfm,this.options.breaks?n.inline=me.breaks:n.inline=me.gfm),this.tokenizer.rules=n}static get rules(){return{block:ke,inline:me}}static lex(t,n){return new Bn(n).lex(t)}static lexInline(t,n){return new Bn(n).inlineTokens(t)}lex(t){t=t.replace(/\r\n|\r/g,`
97
97
  `),this.blockTokens(t,this.tokens);let n;for(;n=this.inlineQueue.shift();)this.inlineTokens(n.src,n.tokens);return this.tokens}blockTokens(t,n=[]){this.options.pedantic?t=t.replace(/\t/g," ").replace(/^ +$/gm,""):t=t.replace(/^( *)(\t+)/gm,(a,l,c)=>l+" ".repeat(c.length));let r,o,s,i;for(;t;)if(!(this.options.extensions&&this.options.extensions.block&&this.options.extensions.block.some(a=>(r=a.call({lexer:this},t,n))?(t=t.substring(r.raw.length),n.push(r),!0):!1))){if(r=this.tokenizer.space(t)){t=t.substring(r.raw.length),r.raw.length===1&&n.length>0?n[n.length-1].raw+=`
98
98
  `:n.push(r);continue}if(r=this.tokenizer.code(t)){t=t.substring(r.raw.length),o=n[n.length-1],o&&(o.type==="paragraph"||o.type==="text")?(o.raw+=`
99
99
  `+r.raw,o.text+=`
@@ -103,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,l,c;if(this.tokens.links){const d=Object.keys(this.tokens.links);if(d.length>0)for(;(a=this.tokenizer.rules.inline.reflinkSearch.exec(i))!=null;)d.includes(a[0].slice(a[0].lastIndexOf("[")+1,-1))&&(i=i.slice(0,a.index)+"["+dh("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)+"["+dh("a",a[0].length-2)+"]"+i.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;(a=this.tokenizer.rules.inline.escapedEmSt.exec(i))!=null;)i=i.slice(0,a.index+a[0].length-2)+"++"+i.slice(this.tokenizer.rules.inline.escapedEmSt.lastIndex),this.tokenizer.rules.inline.escapedEmSt.lastIndex--;for(;t;)if(l||(c=""),l=!1,!(this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some(d=>(r=d.call({lexer:this},t,n))?(t=t.substring(r.raw.length),n.push(r),!0):!1))){if(r=this.tokenizer.escape(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.tag(t)){t=t.substring(r.raw.length),o=n[n.length-1],o&&r.type==="text"&&o.type==="text"?(o.raw+=r.raw,o.text+=r.text):n.push(r);continue}if(r=this.tokenizer.link(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(r.raw.length),o=n[n.length-1],o&&r.type==="text"&&o.type==="text"?(o.raw+=r.raw,o.text+=r.text):n.push(r);continue}if(r=this.tokenizer.emStrong(t,i,c)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.codespan(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.br(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.del(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.autolink(t,ph)){t=t.substring(r.raw.length),n.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(t,ph))){t=t.substring(r.raw.length),n.push(r);continue}if(s=t,this.options.extensions&&this.options.extensions.startInline){let d=1/0;const p=t.slice(1);let m;this.options.extensions.startInline.forEach(function(f){m=f.call({lexer:this},p),typeof m=="number"&&m>=0&&(d=Math.min(d,m))}),d<1/0&&d>=0&&(s=t.substring(0,d+1))}if(r=this.tokenizer.inlineText(s,wT)){t=t.substring(r.raw.length),r.raw.slice(-1)!=="_"&&(c=r.raw.slice(-1)),l=!0,o=n[n.length-1],o&&o.type==="text"?(o.raw+=r.raw,o.text+=r.text):n.push(r);continue}if(t){const d="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(d);break}else throw new Error(d)}}return n}}class el{constructor(t){this.options=t||or}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,l,c;if(this.tokens.links){const d=Object.keys(this.tokens.links);if(d.length>0)for(;(a=this.tokenizer.rules.inline.reflinkSearch.exec(i))!=null;)d.includes(a[0].slice(a[0].lastIndexOf("[")+1,-1))&&(i=i.slice(0,a.index)+"["+dh("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)+"["+dh("a",a[0].length-2)+"]"+i.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;(a=this.tokenizer.rules.inline.escapedEmSt.exec(i))!=null;)i=i.slice(0,a.index+a[0].length-2)+"++"+i.slice(this.tokenizer.rules.inline.escapedEmSt.lastIndex),this.tokenizer.rules.inline.escapedEmSt.lastIndex--;for(;t;)if(l||(c=""),l=!1,!(this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some(d=>(r=d.call({lexer:this},t,n))?(t=t.substring(r.raw.length),n.push(r),!0):!1))){if(r=this.tokenizer.escape(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.tag(t)){t=t.substring(r.raw.length),o=n[n.length-1],o&&r.type==="text"&&o.type==="text"?(o.raw+=r.raw,o.text+=r.text):n.push(r);continue}if(r=this.tokenizer.link(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(r.raw.length),o=n[n.length-1],o&&r.type==="text"&&o.type==="text"?(o.raw+=r.raw,o.text+=r.text):n.push(r);continue}if(r=this.tokenizer.emStrong(t,i,c)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.codespan(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.br(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.del(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.autolink(t,ph)){t=t.substring(r.raw.length),n.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(t,ph))){t=t.substring(r.raw.length),n.push(r);continue}if(s=t,this.options.extensions&&this.options.extensions.startInline){let d=1/0;const p=t.slice(1);let m;this.options.extensions.startInline.forEach(function(f){m=f.call({lexer:this},p),typeof m=="number"&&m>=0&&(d=Math.min(d,m))}),d<1/0&&d>=0&&(s=t.substring(0,d+1))}if(r=this.tokenizer.inlineText(s,bT)){t=t.substring(r.raw.length),r.raw.slice(-1)!=="_"&&(c=r.raw.slice(-1)),l=!0,o=n[n.length-1],o&&o.type==="text"?(o.raw+=r.raw,o.text+=r.text):n.push(r);continue}if(t){const d="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(d);break}else throw new Error(d)}}return n}}class el{constructor(t){this.options=t||or}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+_t(o)+'">'+(r?t:_t(t,!0))+`</code></pre>
108
108
  `:"<pre><code>"+(r?t:_t(t,!0))+`</code></pre>
109
109
  `}blockquote(t){return`<blockquote>
@@ -124,7 +124,7 @@ ${t}</blockquote>
124
124
  ${t}</tr>
125
125
  `}tablecell(t,n){const r=n.header?"th":"td";return(n.align?`<${r} align="${n.align}">`:`<${r}>`)+t+`</${r}>
126
126
  `}strong(t){return`<strong>${t}</strong>`}em(t){return`<em>${t}</em>`}codespan(t){return`<code>${t}</code>`}br(){return this.options.xhtml?"<br/>":"<br>"}del(t){return`<del>${t}</del>`}link(t,n,r){if(t=ch(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=ch(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 hh{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 mh{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 zn{constructor(t){this.options=t||or,this.options.renderer=this.options.renderer||new el,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new hh,this.slugger=new mh}static parse(t,n){return new zn(n).parse(t)}static parseInline(t,n){return new zn(n).parseInline(t)}parse(t,n=!0){let r="",o,s,i,a,l,c,d,p,m,f,v,g,x,y,w,S,k,C,T;const E=t.length;for(o=0;o<E;o++){if(f=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[f.type]&&(T=this.options.extensions.renderers[f.type].call({parser:this},f),T!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(f.type))){r+=T||"";continue}switch(f.type){case"space":continue;case"hr":{r+=this.renderer.hr();continue}case"heading":{r+=this.renderer.heading(this.parseInline(f.tokens),f.depth,lh(this.parseInline(f.tokens,this.textRenderer)),this.slugger);continue}case"code":{r+=this.renderer.code(f.text,f.lang,f.escaped);continue}case"table":{for(p="",d="",a=f.header.length,s=0;s<a;s++)d+=this.renderer.tablecell(this.parseInline(f.header[s].tokens),{header:!0,align:f.align[s]});for(p+=this.renderer.tablerow(d),m="",a=f.rows.length,s=0;s<a;s++){for(c=f.rows[s],d="",l=c.length,i=0;i<l;i++)d+=this.renderer.tablecell(this.parseInline(c[i].tokens),{header:!1,align:f.align[i]});m+=this.renderer.tablerow(d)}r+=this.renderer.table(p,m);continue}case"blockquote":{m=this.parse(f.tokens),r+=this.renderer.blockquote(m);continue}case"list":{for(v=f.ordered,g=f.start,x=f.loose,a=f.items.length,m="",s=0;s<a;s++)w=f.items[s],S=w.checked,k=w.task,y="",w.task&&(C=this.renderer.checkbox(S),x?w.tokens.length>0&&w.tokens[0].type==="paragraph"?(w.tokens[0].text=C+" "+w.tokens[0].text,w.tokens[0].tokens&&w.tokens[0].tokens.length>0&&w.tokens[0].tokens[0].type==="text"&&(w.tokens[0].tokens[0].text=C+" "+w.tokens[0].tokens[0].text)):w.tokens.unshift({type:"text",text:C}):y+=C),y+=this.parse(w.tokens,x),m+=this.renderer.listitem(y,k,S);r+=this.renderer.list(m,v,g);continue}case"html":{r+=this.renderer.html(f.text);continue}case"paragraph":{r+=this.renderer.paragraph(this.parseInline(f.tokens));continue}case"text":{for(m=f.tokens?this.parseInline(f.tokens):f.text;o+1<E&&t[o+1].type==="text";)f=t[++o],m+=`
127
- `+(f.tokens?this.parseInline(f.tokens):f.text);r+=n?this.renderer.paragraph(m):m;continue}default:{const _='Token with "'+f.type+'" type was not found.';if(this.options.silent){console.error(_);return}else throw new Error(_)}}}return r}parseInline(t,n){n=n||this.renderer;let r="",o,s,i;const a=t.length;for(o=0;o<a;o++){if(s=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[s.type]&&(i=this.options.extensions.renderers[s.type].call({parser:this},s),i!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type))){r+=i||"";continue}switch(s.type){case"escape":{r+=n.text(s.text);break}case"html":{r+=n.html(s.text);break}case"link":{r+=n.link(s.href,s.title,this.parseInline(s.tokens,n));break}case"image":{r+=n.image(s.href,s.title,s.text);break}case"strong":{r+=n.strong(this.parseInline(s.tokens,n));break}case"em":{r+=n.em(this.parseInline(s.tokens,n));break}case"codespan":{r+=n.codespan(s.text);break}case"br":{r+=n.br();break}case"del":{r+=n.del(this.parseInline(s.tokens,n));break}case"text":{r+=n.text(s.text);break}default:{const l='Token with "'+s.type+'" type was not found.';if(this.options.silent){console.error(l);return}else throw new Error(l)}}}return r}}class Ws{constructor(t){this.options=t||or}preprocess(t){return t}postprocess(t){return t}}Gg(Ws,"passThroughHooks",new Set(["preprocess","postprocess"]));function bT(e,t,n){return r=>{if(r.message+=`
128
- Please report this to https://github.com/markedjs/marked.`,e){const o="<p>An error occurred:</p><pre>"+_t(r.message+"",!0)+"</pre>";if(t)return Promise.resolve(o);if(n){n(null,o);return}return o}if(t)return Promise.reject(r);if(n){n(r);return}throw r}}function gh(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...Se.defaults,...s};const i=bT(r.silent,r.async,o);if(typeof n>"u"||n===null)return i(new Error("marked(): input parameter is undefined or null"));if(typeof n!="string")return i(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(n)+", string expected"));if(xT(r),r.hooks&&(r.hooks.options=r),o){const a=r.highlight;let l;try{r.hooks&&(n=r.hooks.preprocess(n)),l=e(n,r)}catch(p){return i(p)}const c=function(p){let m;if(!p)try{r.walkTokens&&Se.walkTokens(l,r.walkTokens),m=t(l,r),r.hooks&&(m=r.hooks.postprocess(m))}catch(f){p=f}return r.highlight=a,p?i(p):o(null,m)};if(!a||a.length<3||(delete r.highlight,!l.length))return c();let d=0;Se.walkTokens(l,function(p){p.type==="code"&&(d++,setTimeout(()=>{a(p.text,p.lang,function(m,f){if(m)return c(m);f!=null&&f!==p.text&&(p.text=f,p.escaped=!0),d--,d===0&&c()})},0))}),d===0&&c();return}if(r.async)return Promise.resolve(r.hooks?r.hooks.preprocess(n):n).then(a=>e(a,r)).then(a=>r.walkTokens?Promise.all(Se.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&&Se.walkTokens(a,r.walkTokens);let l=t(a,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(a){return i(a)}}}function Se(e,t,n){return gh(Bn.lex,zn.parse)(e,t,n)}Se.options=Se.setOptions=function(e){return Se.defaults={...Se.defaults,...e},oT(Se.defaults),Se},Se.getDefaults=oh,Se.defaults=or,Se.use=function(...e){const t=Se.defaults.extensions||{renderers:{},childTokens:{}};e.forEach(n=>{const r={...n};if(r.async=Se.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=Se.defaults.renderer||new el;for(const s in n.renderer){const i=o[s];o[s]=(...a)=>{let l=n.renderer[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.renderer=o}if(n.tokenizer){const o=Se.defaults.tokenizer||new Qa;for(const s in n.tokenizer){const i=o[s];o[s]=(...a)=>{let l=n.tokenizer[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.tokenizer=o}if(n.hooks){const o=Se.defaults.hooks||new Ws;for(const s in n.hooks){const i=o[s];Ws.passThroughHooks.has(s)?o[s]=a=>{if(Se.defaults.async)return Promise.resolve(n.hooks[s].call(o,a)).then(c=>i.call(o,c));const l=n.hooks[s].call(o,a);return i.call(o,l)}:o[s]=(...a)=>{let l=n.hooks[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.hooks=o}if(n.walkTokens){const o=Se.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}}Se.setOptions(r)})},Se.walkTokens=function(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(Se,r)),r.type){case"table":{for(const o of r.header)n=n.concat(Se.walkTokens(o.tokens,t));for(const o of r.rows)for(const s of o)n=n.concat(Se.walkTokens(s.tokens,t));break}case"list":{n=n.concat(Se.walkTokens(r.items,t));break}default:Se.defaults.extensions&&Se.defaults.extensions.childTokens&&Se.defaults.extensions.childTokens[r.type]?Se.defaults.extensions.childTokens[r.type].forEach(function(o){n=n.concat(Se.walkTokens(r[o],t))}):r.tokens&&(n=n.concat(Se.walkTokens(r.tokens,t)))}return n},Se.parseInline=gh(Bn.lexInline,zn.parseInline),Se.Parser=zn,Se.parser=zn.parse,Se.Renderer=el,Se.TextRenderer=hh,Se.Lexer=Bn,Se.lexer=Bn.lex,Se.Tokenizer=Qa,Se.Slugger=mh,Se.Hooks=Ws,Se.parse=Se,Se.options,Se.setOptions,Se.use,Se.walkTokens,Se.parseInline,zn.parse,Bn.lex;function Ar({content:e,className:t="",allowHtml:n=!1,style:r}){const o=b.useMemo(()=>{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 Se.parse=="function"?Se.parse(i):Se(i)}return typeof Se.parse=="function"?Se.parse(e):Se(e)}catch(i){return console.error("[MarkdownContent] parse error",i),`<pre class="font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words">Error rendering markdown: ${String(i)}</pre>`}},[e,n]),s=b.useMemo(()=>{const i={color:"currentColor",...r};if(r&&r.color){const a=r.color;return{...i,"--tw-prose-body":a,"--tw-prose-headings":a,"--tw-prose-links":a,"--tw-prose-bold":a,"--tw-prose-counters":a,"--tw-prose-bullets":a,"--tw-prose-hr":a,"--tw-prose-quotes":a,"--tw-prose-quote-borders":a,"--tw-prose-captions":a,"--tw-prose-code":a,"--tw-prose-pre-code":a,"--tw-prose-pre-bg":"inherit","--tw-prose-th-borders":a,"--tw-prose-td-borders":a}}return i},[r]);return u.jsx("div",{className: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 yT(e,t){return b.useMemo(()=>{if(t)return{contentParts:[],textContent:"",toolMeta:{},imageParts:[],fileParts:[],interruptParts:[],toolRaw:"",isToolStreaming:!1};const n=e,r=Array.isArray(n.content)?n.content:[],o=n.additionalKwargs??{};return{contentParts:r,textContent:Lv(r),toolMeta:Ai(n),imageParts:r.filter(s=>s.type==="image_url"),fileParts:r.filter(s=>s.type==="file"),interruptParts:r.filter(s=>s.type==="interrupt"),toolRaw:$v(r),isToolStreaming:!!o.toolStreaming}},[e,t])}function xh({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 vh({artifact:e}){const[t,n]=b.useState("bg-yellow-500/20 text-yellow-700 dark:text-yellow-300"),[r,o]=b.useState(u.jsx(ue.Clock,{className:"w-4 h-4"})),[s,i]=b.useState("Processing");return b.useEffect(()=>{switch(e.status||"processing"){case"completed":n("bg-green-500/20 text-green-700 dark:text-green-300"),o(u.jsx(ue.CheckCircle,{className:"w-4 h-4"})),i("Completed");break;case"failed":n("bg-red-500/20 text-red-700 dark:text-red-300"),o(u.jsx(ue.ExternalLink,{className:"w-4 h-4 rotate-45"})),i("Failed");break;case"pending":n("bg-blue-500/20 text-blue-700 dark:text-blue-300"),o(u.jsx(ue.Clock,{className:"w-4 h-4"})),i("Pending");break;default:n("bg-yellow-500/20 text-yellow-700 dark:text-yellow-300"),o(u.jsx(ue.Clock,{className:"w-4 h-4"})),i("Processing")}},[e.status]),u.jsxs("div",{className:"rounded-lg border border-blue-200 dark:border-blue-900/50 bg-blue-50 dark:bg-blue-950/20 p-4 space-y-3",children:[u.jsxs("div",{className:"flex items-start gap-3",children:[u.jsx("div",{className:"mt-1 flex-shrink-0",children:u.jsx(ue.Search,{className:"w-5 h-5 text-blue-600 dark:text-blue-400"})}),u.jsxs("div",{className:"flex-1 min-w-0",children:[u.jsx("h3",{className:"font-semibold text-blue-900 dark:text-blue-100",children:"Research Task"}),u.jsxs("p",{className:"text-sm text-blue-700 dark:text-blue-300 mt-1",children:["Task ID: ",u.jsxs("code",{className:"font-mono text-xs bg-blue-100 dark:bg-blue-900/30 px-2 py-1 rounded",children:[e.task_id.slice(0,8),"..."]})]})]})]}),u.jsxs("div",{className:`inline-flex items-center gap-2 px-3 py-1 rounded-full text-sm font-medium ${t}`,children:[r,u.jsx("span",{children:s})]}),e.query&&u.jsxs("div",{className:"text-sm text-blue-800 dark:text-blue-200 bg-white dark:bg-blue-900/30 rounded px-3 py-2",children:[u.jsx("p",{className:"font-medium text-xs text-blue-600 dark:text-blue-400 mb-1",children:"Query:"}),u.jsx("p",{className:"line-clamp-2",children:e.query})]}),typeof e.results=="string"&&e.results.trim()&&u.jsxs("div",{className:"text-sm text-blue-900 dark:text-blue-100 bg-white dark:bg-blue-900/30 rounded px-3 py-2 space-y-2",children:[u.jsx("p",{className:"font-semibold text-xs text-blue-600 dark:text-blue-400",children:"Results:"}),u.jsx(Ar,{content:e.results,allowHtml:!1,className:"prose text-xs !prose-sm prose-blue dark:prose-invert"})]}),e.progress_url&&u.jsx("div",{className:"pt-2",children:u.jsxs("a",{href:e.progress_url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white dark:bg-blue-700 dark:hover:bg-blue-600 rounded-md text-sm font-medium transition-colors",children:[u.jsx("span",{children:"Monitor Progress"}),u.jsx(ue.ExternalLink,{className:"w-3.5 h-3.5"})]})}),e.createdAt&&u.jsxs("p",{className:"text-xs text-blue-600 dark:text-blue-400",children:["Started: ",new Date(e.createdAt).toLocaleTimeString()]})]})}function wh({artifact:e,idx:t=0}){const n=b.useMemo(()=>e?(Array.isArray(e.plots)?e.plots:[]).map(o=>Uv(o)).filter(o=>o!==null):[],[e]);return(e==null?void 0:e.type)==="research_task_info"?u.jsx(vh,{artifact:{type:"research_task_info",task_id:e.task_id,progress_url:e.progress_url,query:e.query,status:e.status,createdAt:e.createdAt}}):n.length>0?u.jsx("div",{className:"space-y-2",children:n.map((r,o)=>u.jsx(xh,{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 tl=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}));tl.displayName="Card";const nl=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:ne("flex flex-col space-y-1.5 p-6",e),...t}));nl.displayName="CardHeader";const rl=h.forwardRef(({className:e,...t},n)=>u.jsx("h3",{ref:n,className:ne("text-2xl font-semibold leading-none tracking-tight",e),...t}));rl.displayName="CardTitle";const ol=h.forwardRef(({className:e,...t},n)=>u.jsx("p",{ref:n,className:ne("text-sm text-muted-foreground",e),...t}));ol.displayName="CardDescription";const sl=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:ne("p-6 pt-0",e),...t}));sl.displayName="CardContent";const bh=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:ne("flex items-center p-6 pt-0",e),...t}));bh.displayName="CardFooter";function yh({interruptPart:e,onApprove:t,onReject:n,disabled:r,isActive:o,payload:s}){const i=e.title??"Approve the result?";let a=null;if(s!=null)if(typeof s=="string")a=u.jsx("p",{className:"text-sm leading-relaxed text-blue-800/90 dark:text-blue-200/90 whitespace-pre-wrap",children:s});else{const c=hr(s);a=u.jsx("pre",{className:"max-h-48 overflow-auto rounded bg-blue-100/60 p-2 text-xs text-blue-900/90 dark:bg-blue-900/40 dark:text-blue-100/80",children:c})}const l=o?"Please approve or reject this action to resume the workflow.":"Waiting for approval from another participant.";return u.jsxs(tl,{className:ne("border-blue-200 dark:border-blue-800 bg-blue-50/50 dark:bg-blue-950/10 transition-shadow",o?"shadow-md ring-1 ring-blue-300 dark:ring-blue-500/70":"opacity-80"),children:[u.jsxs(nl,{className:"pb-3",children:[u.jsx(rl,{className:"text-blue-900 dark:text-blue-100 text-base",children:i}),u.jsx(ol,{className:"text-blue-700 dark:text-blue-300 text-sm",children:l})]}),a&&u.jsx(sl,{className:"pt-0 pb-3",children:a}),u.jsx(bh,{className:"pt-0",children:u.jsxs("div",{className:"flex gap-2 ml-auto",children:[u.jsx(at,{size:"sm",variant:"outline",onClick:()=>n(e),className:"border-red-300 text-red-700 hover:bg-red-50 dark:border-red-700 dark:text-red-300 dark:hover:bg-red-950/50",disabled:r||!o,children:"Reject"}),u.jsx(at,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",disabled:r||!o,children:"Approve"})]})})]})}const ST="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 il({data:e}){return Array.isArray(e)?e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?u.jsx("div",{className:ST,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:hr(e)}):u.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:hr(e)})}function Sh({message:e,isStreaming:t=!1}){const n=e.name??"tool",r=b.useMemo(()=>{const a=e.additionalKwargs??{};return Array.isArray(a.toolProgress)?[...a.toolProgress]:[]},[e]),s=r.some(a=>a.type==="tool.start"||a.type==="tool.call"||a.type==="message.start")?`Running ${n}…`:void 0;return t||r.length>0?u.jsxs("div",{className:"space-y-2",children:[u.jsxs("div",{className:"flex items-center gap-2 text-xs uppercase tracking-wide text-muted-foreground",children:[t&&u.jsx(ue.Loader,{className:"h-3 w-3 animate-spin"}),u.jsx("span",{children:s??`Running ${n}…`})]}),r.length>0&&u.jsx("div",{className:"space-y-2 text-xs text-muted-foreground",children:r.map((a,l)=>{var c;return u.jsxs("div",{className:"rounded border border-current/10 bg-muted/60 p-2 text-[11px] leading-snug",children:[u.jsxs("div",{className:"mb-1 flex items-center justify-between text-[8px] uppercase tracking-wide text-muted-foreground",children:[u.jsx("span",{children:((c=a.type)==null?void 0:c.replace(/\./g," "))??"progress"}),u.jsx("span",{children:a.idx??l+1})]}),a.content&&u.jsx("p",{className:"mt-1 text-[12px] text-foreground/90",children:a.content}),u.jsxs("div",{className:"mt-1 flex flex-wrap gap-2 text-[10px] opacity-70",children:[typeof a.factsFound=="number"&&u.jsxs("span",{children:["Facts found: ",a.factsFound]}),typeof a.isSufficient=="boolean"&&u.jsxs("span",{children:["Research ",a.isSufficient?"sufficient":"needs more data"]})]})]},`tool-progress-${n}-${l}`)})})]}):null}function Ch({message:e,viewMode:t,isStreaming:n=!1}){const o=Ai(e).name||"tool",s=l=>{if(l==null)return null;const c=typeof l=="string"?Ni(l)??l:l;if(c&&typeof c=="object")return u.jsx(il,{data:c});const d=typeof c=="string"?c:(()=>{try{return hr(c)}catch{return String(c??"")}})();return u.jsx("pre",{className:"whitespace-pre-wrap break-words font-sans text-sm text-foreground/90",children:d})},i=l=>{if(l==null)return null;const{content:c,isMarkdown:d}=Dv(l);return d?u.jsx(Ar,{content:c,className:"text-current"}):s(l)},a=()=>{const l=e.content.find(p=>p.type!=="tool_call");if(!l)return u.jsx("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:u.jsxs("span",{children:["Running ",o,"…"]})});if(l.type==="text"){const m=(l.text??"").trim();if(!m)return null;const f=qr(m);return i(f)}const c=Kr(l),d=qr(c);return i(d)};return u.jsxs("div",{className:"space-y-2",children:[u.jsx(Sh,{message:e,isStreaming:n}),t==="expanded"&&a()]})}function Th({className:e}){const[t,n]=b.useState(0);return b.useEffect(()=>{const r=setInterval(()=>n(o=>(o+1)%4),500);return()=>clearInterval(r)},[]),u.jsxs("span",{"aria-live":"polite",className:ne("inline-block text-xs opacity-70 ml-1",e),children:["Is thinking",".".repeat(t)]})}function kh({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(Ar,{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(at,{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(ue.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):u.jsxs(u.Fragment,{children:[u.jsx(ue.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",s," chars)"]})})]})}function Eh({message:e,isToolMessage:t,showToolMessages:n,artifactToRender:r,toolViewMode:o,isToolStreaming:s,contentParts:i,textContent:a,imageParts:l,fileParts:c,interruptParts:d,isStreamingMessage:p,defaultMessage:m,handleFileClick:f,uploadingFiles:v,handleInterruptApprove:g,handleInterruptReject:x,disableInterruptActions:y,messageRole:w,truncateUserMessages:S,userMessagePreviewLength:k,isUserExpanded:C,setIsUserExpanded:T,isCompactLayout:E,activeInterruptId:_,activeInterruptValue:R,iconForeground:L}){const H=b.useCallback(()=>u.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/30 rounded",children:[u.jsx(ue.Paperclip,{className:"h-4 w-4 text-muted-foreground"}),u.jsx("span",{className:"text-sm text-muted-foreground",children:"File upload"})]}),[]),K=b.useCallback(({part:I,i:W})=>{if(I.type==="text"){const N=I.text??"",U=N.trim(),O=Ni(U);return O&&w!=="tool"?u.jsx(il,{data:O},W):w==="user"&&S&&U.length>k?u.jsx(kh,{text:U,expanded:C,onExpandedChange:T,previewLength:k,isCompact:E},W):u.jsx(Ar,{content:N,allowHtml:!1},W)}if(I.type==="image_url"){const N=I;return u.jsx("div",{className:"my-2",children:u.jsx("img",{src:N.url,alt:N.alt??"",loading:"lazy",className:"border rounded max-h-[420px] w-auto object-contain"})},W)}if(I.type==="file"){const N=I,U=N.name||"file";return u.jsxs("a",{href:N.url,onClick:O=>f(O.nativeEvent,N,W),className:`inline-flex items-center gap-2 rounded px-2 py-1 text-xs bg-gray-100 border hover:bg-gray-200
129
- dark:bg-background/10 dark:border-border/30 dark:hover:bg-background/20`,children:[v[W]?u.jsx(ue.Loader,{className:"h-4 w-4 animate-spin"}):null,u.jsxs("span",{className:"truncate max-w-[180px]",children:[U,v[W]?" (processing)":""]})]},W)}if(I.type==="interrupt"){const N=I,U=Wo((N==null?void 0:N.id)??(N==null?void 0:N.interrupt_id)),O=!!(_&&U&&U===_),j=O?R??(N==null?void 0:N.value):N==null?void 0:N.value,q=U?{...N,id:U,interrupt_id:U}:N;return u.jsx(yh,{interruptPart:q,onApprove:g,onReject:x,disabled:y,isActive:O,payload:j},W)}return null},[f,v,g,x,w,S,k,C,E,_,R,y]),F=a.trim().length>0||l.length>0||c.length>0||d.length>0;if(!t&&c.length>0&&!p)return H();if(!t&&!F&&!p)return null;if(t)return!n&&r?null:n?u.jsx(Ch,{message:e,viewMode:o,isStreaming:s},e.id):null;if(!m){const I=u.jsx("div",{className:"space-y-2",children:i.map((W,N)=>u.jsx(K,{part:W,i:N},N))});return p?u.jsxs("div",{"aria-busy":"true",role:"status",children:[I,u.jsx(Th,{className:L})]}):I}return null}function Ih(e){const{allowFileOpen:t,currentThreadId:n}=e,{toast:r}=Za(),[o,s]=b.useState({}),[i,a]=b.useState(null),[l,c]=b.useState(!1),d=b.useCallback(()=>{c(!1),a(null)},[]),p=b.useCallback(f=>{a(f),c(!0)},[]),m=b.useCallback(async(f,v,g)=>{var x,y;if(!t){f.preventDefault();return}if(o[g]){f.preventDefault();return}try{const w=String(v.url??""),S=w.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);if(S){f.preventDefault();const k=S[1],C=v.name||`file_${k}`,T=v.mimeType||"application/octet-stream";p({id:k,name:C,mimeType:T});return}if(w.startsWith("data:")){f.preventDefault(),s(C=>({...C,[g]:!0}));const k=r({title:"Fetching file...",description:"",open:!0});try{const C=await eu(n??void 0);if(!C||!Array.isArray(C))throw new Error("Invalid file list response");const T=C.find(E=>!E||typeof E!="object"||!((E.filename??"")===(v.name??""))?!1:typeof v.size=="number"&&typeof E.size=="number"?E.size===v.size:!0);if(!(T!=null&&T.id))throw new Error(`File "${v.name}" is not yet available on the server`);if(!T.id||!T.filename)throw new Error("Invalid file data received from server");p({id:T.id,name:v.name||T.filename||`file_${T.id}`,mimeType:v.mimeType||T.mime_type||"application/octet-stream"}),(x=k.update)==null||x.call(k,{id:k.id,title:"Success",description:`Opened ${v.name}`,open:!0})}catch(C){console.error("Failed to fetch server file:",C);const T=C instanceof Error?C.message:"Unknown error occurred";(y=k.update)==null||y.call(k,{id:k.id,title:"Failed",description:T}),r({title:"Failed to fetch file",description:T,open:!0})}finally{s(C=>({...C,[g]:!1}))}}}catch(w){console.error("File click error:",w),s(S=>({...S,[g]:!1}))}},[t,o,r,n,p]);return{uploadingFiles:o,handleFileClick:m,fileViewerOpen:l,currentFileInfo:i,closeFileViewer:d}}const Vs=b.memo(function({message:t,messageIndex:n,isStreamingMessage:r=!1,isEditing:o=!1,showActions:s=!0,showTimestamp:i=!0,showAgentName:a=!0,layoutSize:l="desktop",truncateUserMessages:c=!0,userMessagePreviewLength:d=500,showToolMessages:p=!0,showArtifactPreviews:m=!0,customStyles:f={},onEdit:v,onRegenerate:g,onCancelEdit:x,onCopy:y,activeInterrupt:w,disableInterruptActions:S=!1,onInterruptActionStart:k,onInterruptActionEnd:C,checkpointCandidates:T=[],activeCheckpointId:E=null,onSelectCheckpoint:_,defaultCheckpointId:R=null,messageParentCheckpointId:L=null}){const[H,K]=b.useState(!1),[F,I]=b.useState("preview"),[W,N]=b.useState(!1),{currentThreadId:U}=pr(),{respondToInterrupt:O}=Yr(),j=l==="phone"||l==="half-screen",q=t.role,J=q==="tool",P=b.useMemo(()=>"type"in t&&t.type==="default_message"?t:null,[t]),M=!!P,G=!(r&&q!=="user"),{uploadingFiles:Z,handleFileClick:se,fileViewerOpen:V,currentFileInfo:D,closeFileViewer:X}=Ih({allowFileOpen:G,currentThreadId:U}),Q=b.useMemo(()=>{switch(q){case"user":return"text-[hsl(var(--chat-bubble-user-text))]";case"assistant":return"text-[hsl(var(--chat-bubble-ai-text))]";case"tool":return"text-secondary-foreground";case"system":return"text-muted-foreground";default:return"text-[hsl(var(--chat-bubble-ai-text))]"}},[q]),ae=yT(t,P),{contentParts:$,imageParts:re,fileParts:we,interruptParts:de,textContent:xe,toolMeta:Ee,toolRaw:Be,isToolStreaming:We}=ae,je=(w==null?void 0:w.id)??(w==null?void 0:w.interrupt_id),Ve=Wo(je),Xe=w==null?void 0:w.value,ze=b.useMemo(()=>P||!m?null:t.artifact||null,[P,t,m]),Ge=b.useCallback(async()=>{const le=J?Be:xe;async function Y(ge){if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function"){await navigator.clipboard.writeText(ge);return}if(navigator.clipboard&&typeof navigator.clipboard.write=="function"&&typeof ClipboardItem<"u"){const it=new Blob([ge],{type:"text/plain"});await navigator.clipboard.write([new ClipboardItem({"text/plain":it})]);return}throw new Error("Clipboard API not supported in this context.")}try{await Y(le),K(!0),setTimeout(()=>K(!1),2e3),y==null||y(le)}catch(ge){console.error("Failed to copy:",ge)}},[J,Be,xe,y]),rt=b.useCallback(()=>{if(!v||!t.id)return;const le=(J?Be:xe)??"",Y="type"in t&&t.type==="default_message"?void 0:{checkpointId:t.checkpointId??null,checkpointNs:t.checkpointNs??null};v(t.id,le,Y)},[v,t.id,J,Be,xe,t]),nt=b.useCallback(()=>{g==null||g(n)},[g,n]),et=b.useCallback(()=>{const Y=ne(j?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",Q);switch(q){case"user":return u.jsx(ue.User,{className:Y});case"assistant":return u.jsx(ue.Bot,{className:Y});case"tool":return u.jsx(ue.Wrench,{className:Y});default:return u.jsx(ue.Bot,{className:Y})}},[j,Q,q]),xt=b.useCallback(()=>{const le="group relative mb-4 flex w-full";switch(q){case"user":return ne(le,"justify-end");case"assistant":case"tool":case"system":return ne(le,"justify-start");default:return le}},[q]),vt=b.useCallback(()=>{const le=ne("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",j&&"px-3 py-2 text-sm");if(M)return ne(le,"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(q){case"user":return ne(le,"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(le,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40");case"tool":return ne(le,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return ne(le,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return ne(le,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40")}},[j,M,q]),dt=b.useCallback(async le=>{if(S)return;const Y=Wo((le==null?void 0:le.id)??(le==null?void 0:le.interrupt_id));if(!Y){console.warn("Interrupt part missing id",le);return}try{k==null||k(),await O(Y,!0)}catch(ge){console.error("Failed to approve interrupt:",ge)}finally{C==null||C()}},[S,C,k,O]),Et=b.useCallback(async le=>{if(S)return;const Y=Wo((le==null?void 0:le.id)??(le==null?void 0:le.interrupt_id));if(!Y){console.warn("Interrupt part missing id",le);return}try{k==null||k(),await O(Y,!1)}catch(ge){console.error("Failed to reject interrupt:",ge)}finally{C==null||C()}},[S,C,k,O]),Dt=b.useMemo(()=>P?"Assistant":Fv(t),[P,t]),$e=b.useMemo(()=>P?[]:Array.isArray(T)?T:[],[T,P]),Pt=b.useMemo(()=>{var le;return $e.length?R&&$e.some(Y=>Y.id===R)?R:((le=$e[0])==null?void 0:le.id)??null:null},[R,$e]),Me=b.useMemo(()=>!$e.length||!E?null:$e.some(le=>le.id===E)?E:null,[E,$e])??Pt,Ke=q==="user"&&$e.length>0&&typeof _=="function",Ct=b.useCallback((le,Y=!1)=>{if(!_)return;const ge=(le==null?void 0:le.id)??null,it=(le==null?void 0:le.parentId)??L??null;_(ge,it,Y)},[L,_]),Ze=b.useMemo(()=>Me?$e.findIndex(le=>le.id===Me):-1,[Me,$e]),pt=b.useMemo(()=>Ze<0?null:$e[Ze]??null,[Ze,$e]);return J&&!p&&!ze?null:M&&P?u.jsx("div",{className:ne(xt(),f.container),children:u.jsxs("div",{className:ne(vt(),f.content),children:[u.jsxs("div",{className:"flex items-center gap-2 mb-2 pb-2 border-b border-current/10",children:[u.jsx(ue.Bot,{className:ne("h-4 w-4",Q)}),a&&u.jsx("span",{className:"font-medium text-sm",children:"Assistant"})]}),u.jsx(Ar,{content:P.content,className:"text-current"})]})}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:ne(xt(),f.container),children:u.jsxs("div",{className:ne(vt(),f.content),children:[(i||a||J)&&u.jsxs("div",{className:ne("flex items-center justify-between mb-2 pb-2 border-b border-current/10",j&&"mb-1 pb-1",Q,f.header),children:[u.jsxs("div",{className:"flex items-center gap-2",children:[et(),a&&Dt&&u.jsx("span",{className:ne("font-medium",j?"text-xs":"text-sm"),children:Dt}),J&&u.jsxs(Lp,{variant:"outline",className:ne("text-xs flex items-center gap-1 cursor-pointer select-none",Q,"border border-current/40",j&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":F==="expanded",onClick:()=>I(le=>le==="expanded"?"preview":"expanded"),onKeyDown:le=>{(le.key==="Enter"||le.key===" ")&&(le.preventDefault(),I(Y=>Y==="expanded"?"preview":"expanded"))},children:[u.jsx("span",{children:Ee.name??"Tool Output"}),Ee.toolCallId&&u.jsx("span",{className:"opacity-70",children:Ee.toolCallId.slice(0,8)}),F==="expanded"?u.jsx(ue.ChevronUp,{className:"h-3 w-3"}):u.jsx(ue.ChevronDown,{className:"h-3 w-3"})]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[Ke&&pt&&Ze>=0&&u.jsx("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("button",{type:"button",className:ne("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",Ze<$e.length-1?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{if(Ze>=$e.length-1)return;const le=$e[Ze+1];le&&Ct(le)},"aria-label":"Older checkpoint (back in time)",disabled:Ze>=$e.length-1,children:u.jsx(ue.ChevronLeft,{className:"h-3 w-3"})}),u.jsx("div",{className:"flex items-center gap-2",children:u.jsxs("span",{className:"whitespace-nowrap",children:[$e.length-Ze," / ",$e.length]})}),u.jsx("button",{type:"button",className:ne("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",Ze>0?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{if(!(Ze<=0))if(Ze===1)Ct(null,!0);else{const le=$e[Ze-1];le&&Ct(le,!1)}},"aria-label":"Newer checkpoint (forward in time)",disabled:Ze<=0,children:u.jsx(ue.ChevronRight,{className:"h-3 w-3"})})]})}),i&&t.createdAt&&u.jsx("time",{className:ne("text-xs opacity-60",Q,j&&"text-xs"),dateTime:new Date(t.createdAt).toISOString(),title:new Date(t.createdAt).toLocaleString(),children:new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(new Date(t.createdAt))}),s&&!o&&u.jsxs("div",{className:ne("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",f.actions),children:[u.jsx("div",{className:"relative",children:u.jsx(at,{variant:"ghost",size:"sm",onClick:()=>Ge(),className:ne("h-6 w-6 p-0 hover:bg-foreground/10",Q,j&&"h-5 w-5"),"aria-label":"Copy message",title:"Copy message",children:u.jsx(ue.Copy,{className:ne(H?"text-success":Q,j?"h-3 w-3":"h-4 w-4")})})}),q==="user"&&v&&u.jsx(at,{variant:"ghost",size:"sm",onClick:rt,className:ne("h-6 w-6 p-0 hover:bg-foreground/10",Q,j&&"h-5 w-5"),"aria-label":"Edit message",children:u.jsx(ue.Edit,{className:ne(Q,j?"h-3 w-3":"h-4 w-4")})}),q==="assistant"&&g&&u.jsx(at,{variant:"ghost",size:"sm",onClick:nt,className:ne("h-6 w-6 p-0 hover:bg-foreground/10",Q,j&&"h-5 w-5"),"aria-label":"Regenerate response",children:u.jsx(ue.RotateCcw,{className:ne(Q,j?"h-3 w-3":"h-4 w-4")})})]})]})]}),u.jsxs("div",{className:"relative",children:[u.jsx(Eh,{message:t,isToolMessage:J,showToolMessages:p,artifactToRender:ze,toolViewMode:F,isToolStreaming:We,contentParts:$,textContent:xe,imageParts:re,fileParts:we,interruptParts:de,isStreamingMessage:r,defaultMessage:P,handleFileClick:se,uploadingFiles:Z,handleInterruptApprove:dt,handleInterruptReject:Et,disableInterruptActions:S,messageRole:q,truncateUserMessages:c,userMessagePreviewLength:d,isUserExpanded:W,setIsUserExpanded:N,isCompactLayout:j,activeInterruptId:Ve,activeInterruptValue:Xe,iconForeground:Q}),m&&ze&&u.jsx("div",{className:"mt-3",children:u.jsx(wh,{artifact:ze,idx:0})})]}),J&&F==="expanded"&&(Ee.toolCallId||Ee.name)&&u.jsxs("div",{className:ne("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",j&&"text-xs"),children:[Ee.name&&u.jsxs("div",{children:["Function: ",Ee.name]}),Ee.toolCallId&&u.jsxs("div",{children:["Call ID: ",Ee.toolCallId]})]}),!(i||a||J)&&s&&!o&&u.jsxs("div",{className:ne("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",f.actions),children:[u.jsx(at,{variant:"ghost",size:"sm",onClick:()=>Ge(),className:ne("h-6 w-6 p-0 hover:bg-background/50 text-current",j&&"h-5 w-5"),children:u.jsx(ue.Copy,{className:ne(H?"text-success":"text-current",j?"h-3 w-3":"h-4 w-4")})}),q==="user"&&v&&u.jsx(at,{variant:"ghost",size:"sm",onClick:rt,className:ne("h-6 w-6 p-0 hover:bg-background/50 text-current",j&&"h-5 w-5"),children:u.jsx(ue.Edit,{className:ne("text-current",j?"h-3 w-3":"h-4 w-4")})}),q==="assistant"&&g&&u.jsx(at,{variant:"ghost",size:"sm",onClick:nt,className:ne("h-6 w-6 p-0 hover:bg-background/50 text-current",j&&"h-5 w-5"),children:u.jsx(ue.RotateCcw,{className:ne("text-current",j?"h-3 w-3":"h-4 w-4")})})]})]})}),D&&u.jsx(rh,{isOpen:V,onClose:X,fileId:D.id,fileName:D.name,mimeType:D.mimeType})]})},(e,t)=>{var l,c,d,p,m,f,v,g;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&uu(e.message)===uu(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateUserMessages","userMessagePreviewLength","showToolMessages"].every(x=>e[x]===t[x]),s=((l=e.customStyles)==null?void 0:l.container)===((c=t.customStyles)==null?void 0:c.container)&&((d=e.customStyles)==null?void 0:d.content)===((p=t.customStyles)==null?void 0:p.content)&&((m=e.customStyles)==null?void 0:m.actions)===((f=t.customStyles)==null?void 0:f.actions)&&((v=e.customStyles)==null?void 0:v.header)===((g=t.customStyles)==null?void 0:g.header);if(!o||!s)return!1;const i=du(e.message),a=du(t.message);return i.length===a.length});Vs.displayName="MessageComponent";const al=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,ll=b.memo(function({message:t,index:n,isStreaming:r,streamingAssistantId:o,streamingDebounceMs:s,layoutSize:i,enableMessageEditing:a,editingMessageId:l,onEdit:c,onRegenerate:d,onCancelEdit:p,activeInterrupt:m,disableInterruptActions:f,onInterruptActionStart:v,onInterruptActionEnd:g,showToolMessages:x,showArtifactPreviews:y,checkpointIndex:w,activeCheckpointId:S,onSelectCheckpoint:k}){const C=al(t,n),T="type"in t&&t.type==="default_message",_=!!t.__syntheticStreaming,{checkpointCandidates:R,defaultCheckpointId:L}=Zl(t,w??{checkpoints:[],checkpointMetaById:new Map,checkpointIndexByKey:new Map,attemptMetaById:new Map,userMessageIdToAttempts:new Map,timeline:[],messagePreviews:new Map,getLatest:()=>{},getCheckpoint:()=>{},getAttempts:()=>[]}),H=t&&!T?t.additionalKwargs??{}:{},K=t&&!T?t.responseMetadata??{}:{},F=(()=>{if(typeof H.parentCheckpointId=="string")return H.parentCheckpointId;if(typeof K.parentCheckpointId=="string")return K.parentCheckpointId})();return u.jsx("div",{className:"relative mb-4 last:mb-0","data-message-id":C,style:{minHeight:"60px",containIntrinsicSize:"auto 120px"},children:u.jsx(Vs,{message:t,messageIndex:n,isStreamingMessage:_||r&&o===t.id,streamingDebounceMs:s,isEditing:l===t.id,showActions:a,showTimestamp:!1,showAgentName:!0,layoutSize:i,onEdit:c,onRegenerate:()=>d(n),onCancelEdit:p,activeInterrupt:m,disableInterruptActions:f,onInterruptActionStart:v,onInterruptActionEnd:g,showToolMessages:x,showArtifactPreviews:y,checkpointCandidates:R,activeCheckpointId:S??null,onSelectCheckpoint:k,defaultCheckpointId:L,messageParentCheckpointId:F})})});ll.displayName="MessageRow";const cl=b.forwardRef(({messages:e,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onStartReached:a,onEdit:l,onRegenerate:c,onCancelEdit:d,className:p,style:m,emptyMessage:f,followNewMessages:v=!0,isNavigatingCheckpoint:g=!1,onScrollAway:x,onAtBottom:y,activeInterrupt:w,disableInterruptActions:S=!1,onInterruptActionStart:k,onInterruptActionEnd:C,showToolMessages:T=!0,showArtifactPreviews:E=!0,checkpointIndex:_,activeCheckpointId:R,onSelectCheckpoint:L,createSyntheticThinkingMessage:H=!0},K)=>{const F=b.useRef(null),I=b.useRef(null),W=b.useRef(!1),N=b.useRef(!1),[U,O]=b.useState(!0),j=b.useMemo(()=>w?e.some($=>"type"in $&&$.type==="default_message"?!1:Array.isArray($==null?void 0:$.content)&&$.content.some(re=>re&&re.type==="interrupt"&&(re.id??re.interrupt_id)===w.id)):!1,[w,e]),q=b.useMemo(()=>{if(!w||j)return null;const $=w.id&&String(w.id).trim()?String(w.id).trim():"pending-interrupt";let re;const we=w.value;if(we&&typeof we=="object"&&!Array.isArray(we)){const de=we.title;typeof de=="string"&&de.trim()&&(re=de.trim())}return{id:`interrupt-${$}`,role:"system",createdAt:new Date().toISOString(),content:[{type:"interrupt",id:$,value:we,title:re}]}},[w,j]),J=b.useMemo(()=>q?[...e,q]:e,[e,q]),P=b.useMemo(()=>!H||!t?J:!J.some(re=>re.role==="assistant")&&J.length>0?[...J,{id:"thinking-assistant",role:"assistant",content:[],createdAt:new Date().toISOString(),__syntheticStreaming:!0}]:J,[J,t,H]),M=b.useMemo(()=>T?P:P.filter($=>($==null?void 0:$.role)!=="tool"),[P,T]),G=b.useCallback($=>{O($),x&&x(!$),y&&y($)},[x,y]),Z=b.useMemo(()=>{if(a)return async()=>{if(!W.current){W.current=!0;try{await a()}finally{W.current=!1}}}},[a]),se=b.useMemo(()=>!v||g?!1:U?"auto":!1,[U,v,g]),V=b.useMemo(()=>{if(typeof f!="string")return null;const $=f.trim();return $?{id:"default-message",role:"assistant",type:"default_message",content:$,createdAt:new Date().toISOString()}:null},[f]),D=["flex h-full flex-col md:flex-row",p].filter(Boolean).join(" "),X=()=>V?u.jsx("div",{className:"p-6 h-full overflow-y-auto",children:u.jsx("div",{className:"w-full max-w-full",children:u.jsx(Vs,{message:V,messageIndex:0,isStreamingMessage:!1,showActions:!1,showTimestamp:!1,showAgentName:!0,layoutSize:o,onEdit:()=>{},onRegenerate:()=>{},onCancelEdit:()=>{},showArtifactPreviews:E})})}):u.jsx("div",{className:"flex h-full items-center justify-center py-8 text-center text-muted-foreground",children:f??"No messages yet. Start a conversation!"}),Q=M.length,ae=Q>0;return b.useEffect(()=>{var $,re;if(Q===0){N.current=!1;return}if(!N.current)if(N.current=!0,F.current&&M.length>0){const we=M.length-1;(re=($=F.current).scrollToIndex)==null||re.call($,{index:we,align:"end",behavior:"auto"})}else I.current&&(I.current.scrollTop=I.current.scrollHeight)},[Q,M.length]),b.useImperativeHandle(K,()=>({scrollToLatest:()=>{var $,re;if(F.current&&M.length>0){const we=M.length-1;(re=($=F.current).scrollToIndex)==null||re.call($,{index:we,align:"end",behavior:"auto"})}else I.current&&(I.current.scrollTop=I.current.scrollHeight)},scrollToTop:()=>{var $,re;F.current&&M.length>0?(re=($=F.current).scrollToIndex)==null||re.call($,{index:0,align:"start",behavior:"auto"}):I.current&&(I.current.scrollTop=0)}}),[M]),u.jsx("div",{className:D,style:m,children:u.jsx("div",{className:"relative flex-1 min-h-0",children:ae?u.jsx(kC,{ref:$=>{F.current=$},scrollerRef:$=>{I.current=$ instanceof HTMLDivElement?$:null},data:M,followOutput:se,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,startReached:()=>{Z&&Z()},atBottomStateChange:G,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:($,re)=>al(re,$),itemContent:($,re)=>u.jsx(ll,{message:re,index:$,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onEdit:l,onRegenerate:c,onCancelEdit:d,activeInterrupt:w,disableInterruptActions:S,onInterruptActionStart:k,onInterruptActionEnd:C,showToolMessages:T,showArtifactPreviews:E,checkpointIndex:_,activeCheckpointId:R,onSelectCheckpoint:L})}):X()})})});cl.displayName="MessageList";const Nh={value:""};function So({className:e="",placeholder:t="Type your message...",autoFocus:n=!0,maxHeight:r=void 0,streamingDebounceMs:o=500,streamingThrottleMs:s,followNewMessages:i=!0,enableFileUpload:a=!0,enableExcelUpload:l=!1,enableMessageEditing:c=!0,showToolMessages:d=!0,showArtifactPreviews:p=!0,customStyles:m={},onMessageSent:f,onExcelUploadSuccess:v,onError:g}){const{api:x}=Vr(),{currentThreadId:y}=pr(),{threadId:w,messages:S,isHistoryLoading:k,isLoading:C,navigateToCheckpoint:T,returnToLatest:E,checkpoint:_,checkpoints:R,interrupt:L,metadata:H,checkpointIndex:K}=Yr(),{isStreaming:F,error:I,connectionState:W,submit:N,stop:U}=Mi(),O=w??y??null,j=(_==null?void 0:_.id)??null,q=(_==null?void 0:_.namespace)??null,J=(H==null?void 0:H.assemblingMessageId)??null,P=L,[M,G]=b.useState(!1);b.useEffect(()=>{P||G(!1)},[P]);const Z=b.useCallback(()=>{G(!0)},[]),se=b.useCallback(()=>{G(!1)},[]),V=!!P||M,[D,X]=b.useState(null),[Q,ae]=b.useState(""),[$,re]=b.useState(null),[we,de]=b.useState(null),[xe,Ee]=b.useState([]),[Be,We]=b.useState(0),[je,Ve]=b.useState(0),[Xe,ze]=b.useState(!1),[Ge,rt]=b.useState(null),[nt,et]=b.useState(null),[xt,vt]=b.useState(!1),[dt,Et]=b.useState(null),Dt=b.useRef(!1),[$e,Pt]=b.useState(()=>Nh.value),nn=b.useRef($e),Me=b.useRef(null),Ke=b.useCallback(ce=>{Nh.value=ce,Pt(ce)},[]),[Ct,Ze]=b.useState(!1),pt=b.useRef(null),le=b.useRef(null),Y=b.useRef(null),ge=b.useCallback(()=>{le.current&&(le.current.value=""),Y.current&&(Y.current.value=""),We(ce=>ce+1),Ve(ce=>ce+1)},[]),it=b.useCallback(ce=>{Ke(ce)},[Ke]),Ce=b.useRef(!1);b.useEffect(()=>{Ce.current&&!F&&(Ee([]),ge()),Ce.current=F},[F,ge]);const[Oe,qe]=b.useState("desktop");b.useEffect(()=>{const ce=()=>{const ve=window.innerWidth;qe(ve<640?"phone":ve<1024?"tablet":"desktop")};return ce(),window.addEventListener("resize",ce),()=>window.removeEventListener("resize",ce)},[]),b.useEffect(()=>{Dt.current=!1},[O]),b.useEffect(()=>{nn.current=$e},[$e]),b.useEffect(()=>{if(!D){Me.current=null;return}Me.current===null&&(Me.current=nn.current),Ke(Q??"")},[Q,D,Ke]),b.useEffect(()=>{(async()=>{if(!x.baseUrl){Et(null);return}try{const pe=(await x.getAgent("default")).uiDefaultMessage||"";Et(pe||null)}catch(ve){console.warn("Failed to fetch default message:",ve),Et(null)}})()},[x.baseUrl]),b.useEffect(()=>{I&&!xt&&(g==null||g(I))},[I,xt,g]);const Tt=async ce=>{const ve=ce.trim();if(!(!ve&&xe.length===0))try{const pe=D?($==null?void 0:$.checkpointId)??j??void 0:j??void 0,Te=D?($==null?void 0:$.checkpointNs)??q??void 0:q??void 0;await N({text:ve||"",attachments:xe},{checkpointId:pe,checkpointNs:Te,edit:!!D,originalMessageId:D??void 0}),f==null||f(ve),Ke(""),de(null),Ee([]),ge(),X(null),ae(""),re(null)}catch(pe){const Te=(pe==null?void 0:pe.message)||"Failed to send message";de(Te),g==null||g(Te)}},He=b.useCallback((ce,ve,pe)=>{c&&(Me.current=$e,X(ce),ae(ve),Ke(ve),de(null),re({checkpointId:(pe==null?void 0:pe.checkpointId)??null,checkpointNs:(pe==null?void 0:pe.checkpointNs)??null}))},[$e,c,Ke]),ft=b.useCallback(()=>{X(null),ae(""),re(null),de(null),Ke(Me.current??$e),Me.current=null},[$e,Ke]),Fe=b.useCallback((ce,ve,pe)=>{He(ce,ve,pe)},[He]),tt=b.useCallback(ce=>{let ve=null;for(let Je=ce-1;Je>=0;Je--)if(S[Je].role==="user"){ve=S[Je];break}if(!ve)return;const pe=Array.isArray(ve.content)?ve.content:[],bt=pe.filter(Je=>(Je==null?void 0:Je.type)==="text").map(Je=>Je.text).join("")||(()=>{try{return JSON.stringify(pe,null,2)}catch{return String(pe)}})();bt&&N({text:bt},{checkpointId:j??void 0,checkpointNs:q??void 0,edit:!0,originalMessageId:ve.id})},[S,N,j,q]),Ut=ce=>{const ve=Array.from(ce.target.files||[]);Ee(pe=>[...pe,...ve]),ce.target.value=""},ql=ce=>{Ee(ve=>{const pe=ve.filter((Te,bt)=>ce!==bt);return pe.length===0&&ge(),pe})},Gl=async ce=>{const ve=(ce.target.files||[])[0];if(ve){rt(null),et(null),ze(!0);try{await N({attachments:[ve]},{checkpointId:j??void 0,checkpointNs:q??void 0});const pe=`Uploaded ${ve.name} - processing through chat stream`;et(pe)}catch(pe){const Te=pe instanceof Error?pe.message:"Failed to upload Excel file";console.error("Excel upload failed",pe),rt(Te),g==null||g(Te)}finally{ze(!1),ce.target.value="",ge()}}},ci=async ce=>{if(y){Ze(!0);try{if(!ce){await E(),requestAnimationFrame(()=>{var Te;(Te=pt.current)==null||Te.scrollToLatest()});return}const ve=R.find(Te=>Te.checkpointId===ce),pe=(ve==null?void 0:ve.checkpointNs)??null;await T(ce,pe),requestAnimationFrame(()=>{var Te;(Te=pt.current)==null||Te.scrollToTop()})}finally{Ze(!1)}}},A=b.useCallback(async(ce,ve,pe)=>{await ci(pe?null:ce)},[ci]),te=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${m.container||""}`,fe=`flex-1 min-h-0 min-w-0 max-h-full w-full overflow-hidden overscroll-contain break-words break-anywhere p-4 bg-transparent ${m.messagesArea||""}`,Ne=`relative flex-shrink-0 w-full border-t p-4 bg-transparent ${m.inputArea||""}`;return u.jsxs("div",{className:te,children:[!!I&&!xt&&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(at,{variant:"ghost",size:"sm",onClick:()=>vt(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:u.jsx(ue.X,{size:16})})]}),u.jsxs("div",{className:`relative ${fe}`,style:r?{maxHeight:r}:void 0,children:[u.jsx(cl,{ref:pt,className:"h-full",style:{height:"100%"},messages:S,isStreaming:F,streamingAssistantId:J,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:Oe,enableMessageEditing:c,editingMessageId:D,onEdit:Fe,onRegenerate:tt,onCancelEdit:ft,emptyMessage:dt??void 0,isNavigatingCheckpoint:Ct,activeInterrupt:P,disableInterruptActions:M,onInterruptActionStart:Z,onInterruptActionEnd:se,showToolMessages:d,showArtifactPreviews:p,checkpointIndex:K,activeCheckpointId:j,onSelectCheckpoint:A,createSyntheticThinkingMessage:!0}),(W==="reconnecting"||W==="connecting")&&u.jsx("div",{className:"pointer-events-none absolute top-3 right-3 z-20 rounded-full bg-muted/80 px-3 py-1 text-xs font-medium text-foreground shadow-sm backdrop-blur-sm dark:bg-muted/60",children:u.jsxs("span",{className:"flex items-center gap-2",children:[u.jsx(ue.Loader2,{className:"h-3 w-3 animate-spin"}),W==="reconnecting"?"Reconnecting…":"Connecting…"]})}),W==="error"&&u.jsx("div",{className:"pointer-events-none absolute top-3 right-3 z-20 rounded-full bg-destructive/10 px-3 py-1 text-xs font-semibold text-destructive shadow-sm",children:"Connection lost"}),C&&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(ue.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading messages…"})]}),(k||Ct)&&u.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 bg-background/80 backdrop-blur-sm text-muted-foreground",children:[u.jsx(ue.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading checkpoint…"})]})]}),u.jsxs("div",{className:Ne,children:[D&&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(ue.Edit3,{size:16,className:"text-blue-600"}),u.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),u.jsx(at,{variant:"ghost",size:"sm",onClick:ft,className:"text-blue-600 hover:bg-blue-100",children:u.jsx(ue.X,{size:16})})]})}),(a||l)&&u.jsxs("div",{className:"mb-3 space-y-3",children:[a&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:le,type:"file",multiple:!0,onChange:ce=>Ut(ce),className:"hidden"},Be),xe.length>0&&u.jsx("div",{className:"flex flex-wrap gap-2",children:xe.map((ce,ve)=>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(ue.Paperclip,{size:14}),u.jsx("span",{className:"truncate max-w-[150px]",children:ce.name}),u.jsx(at,{variant:"ghost",size:"sm",onClick:()=>ql(ve),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 ${ce.name}`,children:u.jsx(ue.X,{size:12})})]},ve))})]}),l&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:Y,type:"file",accept:".xls,.xlsx,.xlsm",onChange:Gl,className:"hidden"},je),Xe&&u.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(ue.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),nt&&!Xe&&u.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:nt}),Ge&&!Xe&&u.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:Ge})]})]}),we&&u.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:we}),u.jsxs("div",{className:"flex items-end gap-2",children:[(a||l)&&u.jsxs(vs,{children:[u.jsx(ws,{asChild:!0,children:u.jsx(at,{type:"button",size:"icon",variant:"outline",disabled:F||V,title:"More input actions",className:m.moreButton||"",children:u.jsx(ue.Plus,{size:16})})}),u.jsxs(ao,{align:"start",sideOffset:6,className:"w-52",children:[a&&u.jsxs(On,{onClick:()=>{var ce;return(ce=le.current)==null?void 0:ce.click()},className:"cursor-pointer",children:[u.jsx(ue.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),l&&u.jsxs(On,{onClick:()=>{var ce;Xe||(ce=Y.current)==null||ce.click()},className:`cursor-pointer ${Xe?"opacity-60 pointer-events-none":""}`,children:[u.jsx(ue.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),u.jsx("div",{className:"flex-1",children:u.jsx(mS,{initialValue:Q,editingMessageId:D,value:$e,onValueChange:it,placeholder:D?"Edit your message...":t,isStreaming:F,disabled:V,onSend:Tt,onCancelEdit:ft,onStop:U,allowEmptySend:xe.length>0,textareaClassName:`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${D?"border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50":""} ${we?"border-red-400":""} ${m.textarea||""}`})})]})]})]})}var Ah=1,CT=.9,TT=.8,kT=.17,ul=.1,dl=.999,ET=.9999,IT=.99,NT=/[\\\/_+.#"@\[\(\{&]/,AT=/[\\\/_+.#"@\[\(\{&]/g,jT=/[\s-]/,jh=/[\s-]/g;function fl(e,t,n,r,o,s,i){if(s===t.length)return o===e.length?Ah:IT;var a=`${o},${s}`;if(i[a]!==void 0)return i[a];for(var l=r.charAt(s),c=n.indexOf(l,o),d=0,p,m,f,v;c>=0;)p=fl(e,t,n,r,c+1,s+1,i),p>d&&(c===o?p*=Ah:NT.test(e.charAt(c-1))?(p*=TT,f=e.slice(o,c-1).match(AT),f&&o>0&&(p*=Math.pow(dl,f.length))):jT.test(e.charAt(c-1))?(p*=CT,v=e.slice(o,c-1).match(jh),v&&o>0&&(p*=Math.pow(dl,v.length))):(p*=kT,o>0&&(p*=Math.pow(dl,c-o))),e.charAt(c)!==t.charAt(s)&&(p*=ET)),(p<ul&&n.charAt(c-1)===r.charAt(s+1)||r.charAt(s+1)===r.charAt(s)&&n.charAt(c-1)!==r.charAt(s))&&(m=fl(e,t,n,r,c+1,s+2,i),m*ul>p&&(p=m*ul)),p>d&&(d=p),c=n.indexOf(l,c+1);return i[a]=d,d}function _h(e){return e.toLowerCase().replace(jh," ")}function _T(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,fl(e,t,_h(e),_h(t),0,0,{})}var Co='[cmdk-group=""]',pl='[cmdk-group-items=""]',PT='[cmdk-group-heading=""]',Ph='[cmdk-item=""]',Mh=`${Ph}:not([aria-disabled="true"])`,hl="cmdk-item-select",jr="data-value",MT=(e,t,n)=>_T(e,t,n),Rh=h.createContext(void 0),To=()=>h.useContext(Rh),Oh=h.createContext(void 0),ml=()=>h.useContext(Oh),Dh=h.createContext(void 0),Lh=h.forwardRef((e,t)=>{let n=_r(()=>{var P,M;return{search:"",value:(M=(P=e.value)!=null?P:e.defaultValue)!=null?M:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=_r(()=>new Set),o=_r(()=>new Map),s=_r(()=>new Map),i=_r(()=>new Set),a=$h(e),{label:l,children:c,value:d,onValueChange:p,filter:m,shouldFilter:f,loop:v,disablePointerSelection:g=!1,vimBindings:x=!0,...y}=e,w=Nt(),S=Nt(),k=Nt(),C=h.useRef(null),T=WT();sr(()=>{if(d!==void 0){let P=d.trim();n.current.value=P,E.emit()}},[d]),sr(()=>{T(6,F)},[]);let E=h.useMemo(()=>({subscribe:P=>(i.current.add(P),()=>i.current.delete(P)),snapshot:()=>n.current,setState:(P,M,G)=>{var Z,se,V,D;if(!Object.is(n.current[P],M)){if(n.current[P]=M,P==="search")K(),L(),T(1,H);else if(P==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let X=document.getElementById(k);X?X.focus():(Z=document.getElementById(w))==null||Z.focus()}if(T(7,()=>{var X;n.current.selectedItemId=(X=I())==null?void 0:X.id,E.emit()}),G||T(5,F),((se=a.current)==null?void 0:se.value)!==void 0){let X=M??"";(D=(V=a.current).onValueChange)==null||D.call(V,X);return}}E.emit()}},emit:()=>{i.current.forEach(P=>P())}}),[]),_=h.useMemo(()=>({value:(P,M,G)=>{var Z;M!==((Z=s.current.get(P))==null?void 0:Z.value)&&(s.current.set(P,{value:M,keywords:G}),n.current.filtered.items.set(P,R(M,G)),T(2,()=>{L(),E.emit()}))},item:(P,M)=>(r.current.add(P),M&&(o.current.has(M)?o.current.get(M).add(P):o.current.set(M,new Set([P]))),T(3,()=>{K(),L(),n.current.value||H(),E.emit()}),()=>{s.current.delete(P),r.current.delete(P),n.current.filtered.items.delete(P);let G=I();T(4,()=>{K(),(G==null?void 0:G.getAttribute("id"))===P&&H(),E.emit()})}),group:P=>(o.current.has(P)||o.current.set(P,new Set),()=>{s.current.delete(P),o.current.delete(P)}),filter:()=>a.current.shouldFilter,label:l||e["aria-label"],getDisablePointerSelection:()=>a.current.disablePointerSelection,listId:w,inputId:k,labelId:S,listInnerRef:C}),[]);function R(P,M){var G,Z;let se=(Z=(G=a.current)==null?void 0:G.filter)!=null?Z:MT;return P?se(P,n.current.search,M):0}function L(){if(!n.current.search||a.current.shouldFilter===!1)return;let P=n.current.filtered.items,M=[];n.current.filtered.groups.forEach(Z=>{let se=o.current.get(Z),V=0;se.forEach(D=>{let X=P.get(D);V=Math.max(X,V)}),M.push([Z,V])});let G=C.current;W().sort((Z,se)=>{var V,D;let X=Z.getAttribute("id"),Q=se.getAttribute("id");return((V=P.get(Q))!=null?V:0)-((D=P.get(X))!=null?D:0)}).forEach(Z=>{let se=Z.closest(pl);se?se.appendChild(Z.parentElement===se?Z:Z.closest(`${pl} > *`)):G.appendChild(Z.parentElement===G?Z:Z.closest(`${pl} > *`))}),M.sort((Z,se)=>se[1]-Z[1]).forEach(Z=>{var se;let V=(se=C.current)==null?void 0:se.querySelector(`${Co}[${jr}="${encodeURIComponent(Z[0])}"]`);V==null||V.parentElement.appendChild(V)})}function H(){let P=W().find(G=>G.getAttribute("aria-disabled")!=="true"),M=P==null?void 0:P.getAttribute(jr);E.setState("value",M||void 0)}function K(){var P,M,G,Z;if(!n.current.search||a.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let se=0;for(let V of r.current){let D=(M=(P=s.current.get(V))==null?void 0:P.value)!=null?M:"",X=(Z=(G=s.current.get(V))==null?void 0:G.keywords)!=null?Z:[],Q=R(D,X);n.current.filtered.items.set(V,Q),Q>0&&se++}for(let[V,D]of o.current)for(let X of D)if(n.current.filtered.items.get(X)>0){n.current.filtered.groups.add(V);break}n.current.filtered.count=se}function F(){var P,M,G;let Z=I();Z&&(((P=Z.parentElement)==null?void 0:P.firstChild)===Z&&((G=(M=Z.closest(Co))==null?void 0:M.querySelector(PT))==null||G.scrollIntoView({block:"nearest"})),Z.scrollIntoView({block:"nearest"}))}function I(){var P;return(P=C.current)==null?void 0:P.querySelector(`${Ph}[aria-selected="true"]`)}function W(){var P;return Array.from(((P=C.current)==null?void 0:P.querySelectorAll(Mh))||[])}function N(P){let M=W()[P];M&&E.setState("value",M.getAttribute(jr))}function U(P){var M;let G=I(),Z=W(),se=Z.findIndex(D=>D===G),V=Z[se+P];(M=a.current)!=null&&M.loop&&(V=se+P<0?Z[Z.length-1]:se+P===Z.length?Z[0]:Z[se+P]),V&&E.setState("value",V.getAttribute(jr))}function O(P){let M=I(),G=M==null?void 0:M.closest(Co),Z;for(;G&&!Z;)G=P>0?HT(G,Co):UT(G,Co),Z=G==null?void 0:G.querySelector(Mh);Z?E.setState("value",Z.getAttribute(jr)):U(P)}let j=()=>N(W().length-1),q=P=>{P.preventDefault(),P.metaKey?j():P.altKey?O(1):U(1)},J=P=>{P.preventDefault(),P.metaKey?N(0):P.altKey?O(-1):U(-1)};return h.createElement(be.div,{ref:t,tabIndex:-1,...y,"cmdk-root":"",onKeyDown:P=>{var M;(M=y.onKeyDown)==null||M.call(y,P);let G=P.nativeEvent.isComposing||P.keyCode===229;if(!(P.defaultPrevented||G))switch(P.key){case"n":case"j":{x&&P.ctrlKey&&q(P);break}case"ArrowDown":{q(P);break}case"p":case"k":{x&&P.ctrlKey&&J(P);break}case"ArrowUp":{J(P);break}case"Home":{P.preventDefault(),N(0);break}case"End":{P.preventDefault(),j();break}case"Enter":{P.preventDefault();let Z=I();if(Z){let se=new Event(hl);Z.dispatchEvent(se)}}}}},h.createElement("label",{"cmdk-label":"",htmlFor:_.inputId,id:_.labelId,style:KT},l),Ks(e,P=>h.createElement(Oh.Provider,{value:E},h.createElement(Rh.Provider,{value:_},P))))}),RT=h.forwardRef((e,t)=>{var n,r;let o=Nt(),s=h.useRef(null),i=h.useContext(Dh),a=To(),l=$h(e),c=(r=(n=l.current)==null?void 0:n.forceMount)!=null?r:i==null?void 0:i.forceMount;sr(()=>{if(!c)return a.item(o,i==null?void 0:i.id)},[c]);let d=Fh(o,s,[e.value,e.children,s],e.keywords),p=ml(),m=Hn(T=>T.value&&T.value===d.current),f=Hn(T=>c||a.filter()===!1?!0:T.search?T.filtered.items.get(o)>0:!0);h.useEffect(()=>{let T=s.current;if(!(!T||e.disabled))return T.addEventListener(hl,v),()=>T.removeEventListener(hl,v)},[f,e.onSelect,e.disabled]);function v(){var T,E;g(),(E=(T=l.current).onSelect)==null||E.call(T,d.current)}function g(){p.setState("value",d.current,!0)}if(!f)return null;let{disabled:x,value:y,onSelect:w,forceMount:S,keywords:k,...C}=e;return h.createElement(be.div,{ref:jn(s,t),...C,id:o,"cmdk-item":"",role:"option","aria-disabled":!!x,"aria-selected":!!m,"data-disabled":!!x,"data-selected":!!m,onPointerMove:x||a.getDisablePointerSelection()?void 0:g,onClick:x?void 0:v},e.children)}),OT=h.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:o,...s}=e,i=Nt(),a=h.useRef(null),l=h.useRef(null),c=Nt(),d=To(),p=Hn(f=>o||d.filter()===!1?!0:f.search?f.filtered.groups.has(i):!0);sr(()=>d.group(i),[]),Fh(i,a,[e.value,e.heading,l]);let m=h.useMemo(()=>({id:i,forceMount:o}),[o]);return h.createElement(be.div,{ref:jn(a,t),...s,"cmdk-group":"",role:"presentation",hidden:p?void 0:!0},n&&h.createElement("div",{ref:l,"cmdk-group-heading":"","aria-hidden":!0,id:c},n),Ks(e,f=>h.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?c:void 0},h.createElement(Dh.Provider,{value:m},f))))}),DT=h.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,o=h.useRef(null),s=Hn(i=>!i.search);return!n&&!s?null:h.createElement(be.div,{ref:jn(o,t),...r,"cmdk-separator":"",role:"separator"})}),LT=h.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,o=e.value!=null,s=ml(),i=Hn(c=>c.search),a=Hn(c=>c.selectedItemId),l=To();return h.useEffect(()=>{e.value!=null&&s.setState("search",e.value)},[e.value]),h.createElement(be.input,{ref:t,...r,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":l.listId,"aria-labelledby":l.labelId,"aria-activedescendant":a,id:l.inputId,type:"text",value:o?e.value:i,onChange:c=>{o||s.setState("search",c.target.value),n==null||n(c.target.value)}})}),$T=h.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...o}=e,s=h.useRef(null),i=h.useRef(null),a=Hn(c=>c.selectedItemId),l=To();return h.useEffect(()=>{if(i.current&&s.current){let c=i.current,d=s.current,p,m=new ResizeObserver(()=>{p=requestAnimationFrame(()=>{let f=c.offsetHeight;d.style.setProperty("--cmdk-list-height",f.toFixed(1)+"px")})});return m.observe(c),()=>{cancelAnimationFrame(p),m.unobserve(c)}}},[]),h.createElement(be.div,{ref:jn(s,t),...o,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":a,"aria-label":r,id:l.listId},Ks(e,c=>h.createElement("div",{ref:jn(i,l.listInnerRef),"cmdk-list-sizer":""},c)))}),FT=h.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:o,contentClassName:s,container:i,...a}=e;return h.createElement(qa,{open:n,onOpenChange:r},h.createElement(Ga,{container:i},h.createElement(wo,{"cmdk-overlay":"",className:o}),h.createElement(bo,{"aria-label":e.label,"cmdk-dialog":"",className:s},h.createElement(Lh,{ref:t,...a}))))}),BT=h.forwardRef((e,t)=>Hn(n=>n.filtered.count===0)?h.createElement(be.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),zT=h.forwardRef((e,t)=>{let{progress:n,children:r,label:o="Loading...",...s}=e;return h.createElement(be.div,{ref:t,...s,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":o},Ks(e,i=>h.createElement("div",{"aria-hidden":!0},i)))}),zt=Object.assign(Lh,{List:$T,Item:RT,Input:LT,Group:OT,Separator:DT,Dialog:FT,Empty:BT,Loading:zT});function HT(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function UT(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function $h(e){let t=h.useRef(e);return sr(()=>{t.current=e}),t}var sr=typeof window>"u"?h.useEffect:h.useLayoutEffect;function _r(e){let t=h.useRef();return t.current===void 0&&(t.current=e()),t}function Hn(e){let t=ml(),n=()=>e(t.snapshot());return h.useSyncExternalStore(t.subscribe,n,n)}function Fh(e,t,n,r=[]){let o=h.useRef(),s=To();return sr(()=>{var i;let a=(()=>{var c;for(let d of n){if(typeof d=="string")return d.trim();if(typeof d=="object"&&"current"in d)return d.current?(c=d.current.textContent)==null?void 0:c.trim():o.current}})(),l=r.map(c=>c.trim());s.value(e,a,l),(i=t.current)==null||i.setAttribute(jr,a),o.current=a}),o}var WT=()=>{let[e,t]=h.useState(),n=_r(()=>new Map);return sr(()=>{n.current.forEach(r=>r()),n.current=new Map},[e]),(r,o)=>{n.current.set(r,o),t({})}};function VT(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function Ks({asChild:e,children:t},n){return e&&h.isValidElement(t)?h.cloneElement(VT(t),{ref:t.ref},n(t.props.children)):n(t)}var KT={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const gl=h.forwardRef(({className:e,...t},n)=>u.jsx(zt,{ref:n,className:ne("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));gl.displayName=zt.displayName;const xl=h.forwardRef(({className:e,...t},n)=>u.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[u.jsx(ue.Search,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),u.jsx(zt.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})]}));xl.displayName=zt.Input.displayName;const vl=h.forwardRef(({className:e,...t},n)=>u.jsx(zt.List,{ref:n,className:ne("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));vl.displayName=zt.List.displayName;const wl=h.forwardRef((e,t)=>u.jsx(zt.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));wl.displayName=zt.Empty.displayName;const bl=h.forwardRef(({className:e,...t},n)=>u.jsx(zt.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}));bl.displayName=zt.Group.displayName;const qT=h.forwardRef(({className:e,...t},n)=>u.jsx(zt.Separator,{ref:n,className:ne("-mx-1 h-px bg-border",e),...t}));qT.displayName=zt.Separator.displayName;const yl=h.forwardRef(({className:e,...t},n)=>u.jsx(zt.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}));yl.displayName=zt.Item.displayName;function Sl(e,[t,n]){return Math.min(n,Math.max(t,e))}function GT(e,t){return h.useReducer((n,r)=>t[n][r]??n,e)}var Cl="ScrollArea",[Bh,l1]=sn(Cl),[YT,tn]=Bh(Cl),zh=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,l]=h.useState(null),[c,d]=h.useState(null),[p,m]=h.useState(null),[f,v]=h.useState(null),[g,x]=h.useState(null),[y,w]=h.useState(0),[S,k]=h.useState(0),[C,T]=h.useState(!1),[E,_]=h.useState(!1),R=De(t,H=>l(H)),L=Ko(o);return u.jsx(YT,{scope:n,type:r,dir:L,scrollHideDelay:s,scrollArea:a,viewport:c,onViewportChange:d,content:p,onContentChange:m,scrollbarX:f,onScrollbarXChange:v,scrollbarXEnabled:C,onScrollbarXEnabledChange:T,scrollbarY:g,onScrollbarYChange:x,scrollbarYEnabled:E,onScrollbarYEnabledChange:_,onCornerWidthChange:w,onCornerHeightChange:k,children:u.jsx(be.div,{dir:L,...i,ref:R,style:{position:"relative","--radix-scroll-area-corner-width":y+"px","--radix-scroll-area-corner-height":S+"px",...e.style}})})});zh.displayName=Cl;var Hh="ScrollAreaViewport",Uh=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=tn(Hh,n),a=h.useRef(null),l=De(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(be.div,{"data-radix-scroll-area-viewport":"",...s,ref:l,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:u.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});Uh.displayName=Hh;var Tn="ScrollAreaScrollbar",Tl=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=tn(Tn,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(XT,{...r,ref:t,forceMount:n}):o.type==="scroll"?u.jsx(JT,{...r,ref:t,forceMount:n}):o.type==="auto"?u.jsx(Wh,{...r,ref:t,forceMount:n}):o.type==="always"?u.jsx(kl,{...r,ref:t}):null});Tl.displayName=Tn;var XT=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=tn(Tn,e.__scopeScrollArea),[s,i]=h.useState(!1);return h.useEffect(()=>{const a=o.scrollArea;let l=0;if(a){const c=()=>{window.clearTimeout(l),i(!0)},d=()=>{l=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",c),a.addEventListener("pointerleave",d),()=>{window.clearTimeout(l),a.removeEventListener("pointerenter",c),a.removeEventListener("pointerleave",d)}}},[o.scrollArea,o.scrollHideDelay]),u.jsx(Ft,{present:n||s,children:u.jsx(Wh,{"data-state":s?"visible":"hidden",...r,ref:t})})}),JT=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=tn(Tn,e.__scopeScrollArea),s=e.orientation==="horizontal",i=Xs(()=>l("SCROLL_END"),100),[a,l]=GT("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return h.useEffect(()=>{if(a==="idle"){const c=window.setTimeout(()=>l("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(c)}},[a,o.scrollHideDelay,l]),h.useEffect(()=>{const c=o.viewport,d=s?"scrollLeft":"scrollTop";if(c){let p=c[d];const m=()=>{const f=c[d];p!==f&&(l("SCROLL"),i()),p=f};return c.addEventListener("scroll",m),()=>c.removeEventListener("scroll",m)}},[o.viewport,s,l,i]),u.jsx(Ft,{present:n||a!=="hidden",children:u.jsx(kl,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:ie(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:ie(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),Wh=h.forwardRef((e,t)=>{const n=tn(Tn,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=h.useState(!1),a=e.orientation==="horizontal",l=Xs(()=>{if(n.viewport){const c=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?c:d)}},10);return Pr(n.viewport,l),Pr(n.content,l),u.jsx(Ft,{present:r||s,children:u.jsx(kl,{"data-state":s?"visible":"hidden",...o,ref:t})})}),kl=h.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=tn(Tn,e.__scopeScrollArea),s=h.useRef(null),i=h.useRef(0),[a,l]=h.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),c=Yh(a.viewport,a.content),d={...r,sizes:a,onSizesChange:l,hasThumb:c>0&&c<1,onThumbChange:m=>s.current=m,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:m=>i.current=m};function p(m,f){return rk(m,i.current,a,f)}return n==="horizontal"?u.jsx(ZT,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollLeft,f=Xh(m,a,o.dir);s.current.style.transform=`translate3d(${f}px, 0, 0)`}},onWheelScroll:m=>{o.viewport&&(o.viewport.scrollLeft=m)},onDragScroll:m=>{o.viewport&&(o.viewport.scrollLeft=p(m,o.dir))}}):n==="vertical"?u.jsx(QT,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollTop,f=Xh(m,a);s.current.style.transform=`translate3d(0, ${f}px, 0)`}},onWheelScroll:m=>{o.viewport&&(o.viewport.scrollTop=m)},onDragScroll:m=>{o.viewport&&(o.viewport.scrollTop=p(m))}}):null}),ZT=h.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=tn(Tn,e.__scopeScrollArea),[i,a]=h.useState(),l=h.useRef(null),c=De(t,l,s.onScrollbarXChange);return h.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(Kh,{"data-orientation":"horizontal",...o,ref:c,sizes:n,style:{bottom:0,left:s.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:s.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":Ys(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.x),onDragScroll:d=>e.onDragScroll(d.x),onWheelScroll:(d,p)=>{if(s.viewport){const m=s.viewport.scrollLeft+d.deltaX;e.onWheelScroll(m),Zh(m,p)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:l.current.clientWidth,paddingStart:Gs(i.paddingLeft),paddingEnd:Gs(i.paddingRight)}})}})}),QT=h.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=tn(Tn,e.__scopeScrollArea),[i,a]=h.useState(),l=h.useRef(null),c=De(t,l,s.onScrollbarYChange);return h.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(Kh,{"data-orientation":"vertical",...o,ref:c,sizes:n,style:{top:0,right:s.dir==="ltr"?0:void 0,left:s.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":Ys(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.y),onDragScroll:d=>e.onDragScroll(d.y),onWheelScroll:(d,p)=>{if(s.viewport){const m=s.viewport.scrollTop+d.deltaY;e.onWheelScroll(m),Zh(m,p)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:l.current.clientHeight,paddingStart:Gs(i.paddingTop),paddingEnd:Gs(i.paddingBottom)}})}})}),[ek,Vh]=Bh(Tn),Kh=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:l,onDragScroll:c,onWheelScroll:d,onResize:p,...m}=e,f=tn(Tn,n),[v,g]=h.useState(null),x=De(t,R=>g(R)),y=h.useRef(null),w=h.useRef(""),S=f.viewport,k=r.content-r.viewport,C=mt(d),T=mt(l),E=Xs(p,10);function _(R){if(y.current){const L=R.clientX-y.current.left,H=R.clientY-y.current.top;c({x:L,y:H})}}return h.useEffect(()=>{const R=L=>{const H=L.target;(v==null?void 0:v.contains(H))&&C(L,k)};return document.addEventListener("wheel",R,{passive:!1}),()=>document.removeEventListener("wheel",R,{passive:!1})},[S,v,k,C]),h.useEffect(T,[r,T]),Pr(v,E),Pr(f.content,E),u.jsx(ek,{scope:n,scrollbar:v,hasThumb:o,onThumbChange:mt(s),onThumbPointerUp:mt(i),onThumbPositionChange:T,onThumbPointerDown:mt(a),children:u.jsx(be.div,{...m,ref:x,style:{position:"absolute",...m.style},onPointerDown:ie(e.onPointerDown,R=>{R.button===0&&(R.target.setPointerCapture(R.pointerId),y.current=v.getBoundingClientRect(),w.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",f.viewport&&(f.viewport.style.scrollBehavior="auto"),_(R))}),onPointerMove:ie(e.onPointerMove,_),onPointerUp:ie(e.onPointerUp,R=>{const L=R.target;L.hasPointerCapture(R.pointerId)&&L.releasePointerCapture(R.pointerId),document.body.style.webkitUserSelect=w.current,f.viewport&&(f.viewport.style.scrollBehavior=""),y.current=null})})})}),qs="ScrollAreaThumb",qh=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Vh(qs,e.__scopeScrollArea);return u.jsx(Ft,{present:n||o.hasThumb,children:u.jsx(tk,{ref:t,...r})})}),tk=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=tn(qs,n),i=Vh(qs,n),{onThumbPositionChange:a}=i,l=De(t,p=>i.onThumbChange(p)),c=h.useRef(void 0),d=Xs(()=>{c.current&&(c.current(),c.current=void 0)},100);return h.useEffect(()=>{const p=s.viewport;if(p){const m=()=>{if(d(),!c.current){const f=ok(p,a);c.current=f,a()}};return a(),p.addEventListener("scroll",m),()=>p.removeEventListener("scroll",m)}},[s.viewport,d,a]),u.jsx(be.div,{"data-state":i.hasThumb?"visible":"hidden",...o,ref:l,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:ie(e.onPointerDownCapture,p=>{const f=p.target.getBoundingClientRect(),v=p.clientX-f.left,g=p.clientY-f.top;i.onThumbPointerDown({x:v,y:g})}),onPointerUp:ie(e.onPointerUp,i.onThumbPointerUp)})});qh.displayName=qs;var El="ScrollAreaCorner",Gh=h.forwardRef((e,t)=>{const n=tn(El,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?u.jsx(nk,{...e,ref:t}):null});Gh.displayName=El;var nk=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=tn(El,n),[s,i]=h.useState(0),[a,l]=h.useState(0),c=!!(s&&a);return Pr(o.scrollbarX,()=>{var p;const d=((p=o.scrollbarX)==null?void 0:p.offsetHeight)||0;o.onCornerHeightChange(d),l(d)}),Pr(o.scrollbarY,()=>{var p;const d=((p=o.scrollbarY)==null?void 0:p.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),c?u.jsx(be.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 Gs(e){return e?parseInt(e,10):0}function Yh(e,t){const n=e/t;return isNaN(n)?0:n}function Ys(e){const t=Yh(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function rk(e,t,n,r="ltr"){const o=Ys(n),s=o/2,i=t||s,a=o-i,l=n.scrollbar.paddingStart+i,c=n.scrollbar.size-n.scrollbar.paddingEnd-a,d=n.content-n.viewport,p=r==="ltr"?[0,d]:[d*-1,0];return Jh([l,c],p)(e)}function Xh(e,t,n="ltr"){const r=Ys(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,s=t.scrollbar.size-o,i=t.content-t.viewport,a=s-r,l=n==="ltr"?[0,i]:[i*-1,0],c=Sl(e,l);return Jh([0,i],[0,a])(c)}function Jh(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 Zh(e,t){return e>0&&e<t}var ok=(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 Xs(e,t){const n=mt(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 Pr(e,t){const n=mt(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 Qh=zh,sk=Uh,ik=Gh;const Il=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Qh,{ref:r,className:ne("relative overflow-hidden",e),...n,children:[u.jsx(sk,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),u.jsx(em,{}),u.jsx(ik,{})]}));Il.displayName=Qh.displayName;const em=h.forwardRef(({className:e,orientation:t="vertical",...n},r)=>u.jsx(Tl,{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(qh,{className:"relative flex-1 rounded-full bg-border"})}));em.displayName=Tl.displayName;const Nl=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}));Nl.displayName="Input";const ak="group relative p-3 rounded-lg cursor-pointer transition-colors border text-gray-900 dark:text-slate-100",lk="bg-slate-700 border-slate-600 hover:bg-slate-600",ck="bg-slate-600 border-slate-500";function tm({thread:e,isActive:t,editingThreadId:n,editingTitle:r,onSelect:o,onStartEditing:s,onEditingTitleChange:i,onSaveEditing:a,onCancelEditing:l,onShare:c,onDelete:d,showEditTitle:p,showDeleteButton:m,formatDate:f,getDisplayThreadTitle:v,secondaryLine:g,itemClassName:x,activeItemClassName:y}){const w=n===e.threadId,S=t?`${y??ck}`:`${x??lk}`,k=C=>{C.stopPropagation(),o(e.threadId)};return u.jsxs("div",{onClick:k,className:`${ak} ${S}`,children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("div",{className:"flex-1 min-w-0",children:w?u.jsxs("div",{className:"flex items-center gap-2",onClick:C=>C.stopPropagation(),children:[u.jsx(Nl,{value:r,onChange:C=>i(C.target.value),onKeyDown:C=>{C.key==="Enter"?a(e.threadId):C.key==="Escape"&&l()},className:"h-6 text-sm",autoFocus:!0}),u.jsx(at,{variant:"ghost",size:"sm",onClick:()=>a(e.threadId),className:"h-6 w-6 p-0",children:u.jsx(ue.Check,{size:12})}),u.jsx(at,{variant:"ghost",size:"sm",onClick:l,className:"h-6 w-6 p-0",children:u.jsx(ue.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(ue.Calendar,{size:10}),u.jsx("span",{children:f(e.updatedAt||e.createdAt)})]}),g&&u.jsx("div",{className:"text-[11px] text-muted-foreground mt-1",children:g})]})}),u.jsx("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2",children:u.jsxs(vs,{children:[u.jsx(ws,{asChild:!0,children:u.jsx(at,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",children:u.jsx(ue.MoreHorizontal,{size:12})})}),u.jsxs(ao,{align:"end",sideOffset:6,className:"w-44",children:[u.jsxs(On,{onClick:C=>{C.preventDefault(),c(e.threadId)},children:[u.jsx(ue.Share2,{className:"mr-2 h-4 w-4"}),"Share thread"]}),p&&n!==e.threadId&&u.jsxs(On,{onClick:C=>{C.preventDefault(),s(e,C)},children:[u.jsx(ue.Edit3,{className:"mr-2 h-4 w-4"}),"Rename"]}),m&&d&&u.jsxs(On,{className:"text-red-400 hover:text-red-300",onClick:C=>{C.preventDefault(),d(e.threadId,C)},children:[u.jsx(ue.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 nm=25,rm="thread-manager-view",uk=e=>e==="default"||e==="shared",dk=()=>{if(typeof window>"u")return null;try{const e=window.localStorage.getItem(rm);if(uk(e))return e}catch{}return null};function om({defaultView:e}={}){const[t,n]=b.useState(()=>dk()??e??"default");b.useEffect(()=>{if(!(typeof window>"u"))try{window.localStorage.setItem(rm,t)}catch{}},[t]);const r=b.useCallback(o=>{n(o)},[]);return{view:t,setView:r}}const fk=[{key:"default",label:"My chats"},{key:"shared",label:"Shared with you"}];function Al({className:e="",showCreateButton:t=!0,showDeleteButton:n=!0,showEditTitle:r=!0,maxHeight:o="400px",customStyles:s={},currentThreadId:i=null,navigateToThread:a,onThreadSelect:l,onThreadCreate:c,onThreadDelete:d,view:p,defaultView:m,onViewChange:f,viewOptions:v,viewState:g,showHeader:x=!0,shareTargets:y,isLoadingShareTargets:w,shareTargetFilter:S}){const{threads:k,sharedThreads:C,currentThreadId:T,setCurrentThreadId:E,isLoading:_,isLoadingSharedThreads:R,actions:L,shareInFlight:H,shareStatus:K,clearShareStatus:F}=pr(),{createThread:I,deleteThread:W,renameThread:N,shareThread:U}=L,{loadThread:O}=Yr(),j=i??T,[q,J]=b.useState(Array.isArray(k)?k:[]),P=b.useRef(q.length>0),M=b.useRef(null),G=b.useRef(0),[Z,se]=b.useState(null),[V,D]=b.useState(""),[X,Q]=b.useState(!1),[ae,$]=b.useState(!1),[re,we]=b.useState(null),[de,xe]=b.useState(""),Ee=v&&v.length>0?v:fk,Be=om({defaultView:m}),We=g??Be,je=p??We.view,Ve=b.useCallback(Y=>{p||We.setView(Y),f==null||f(Y)},[p,f,We]),Xe=Ee.find(Y=>Y.key===je)??Ee[0],ze=Y=>{we(Y),xe(""),$(!0)},Ge=()=>{$(!1),we(null),xe(""),F()},rt=b.useCallback(async Y=>{if(!(!re||H)&&Y.id)try{await U(re,Y.id),setTimeout(()=>Ge(),600)}catch(ge){console.error("Failed to share thread:",ge)}},[Ge,H,re,U]),nt=b.useMemo(()=>{const Y=y??[],ge=de.trim().toLowerCase();return ge?S?Y.filter(it=>S(it,ge)):Y.filter(it=>`${it.label} ${it.secondaryLabel??""}`.toLowerCase().includes(ge)):Y},[y,de,S]),et=je==="shared",xt=et?C:q,vt=et?R:_,dt=et?"No shared conversations yet":"No conversations yet",Et=Y=>{const ge=Y.sharedAt?` • ${Ze(Y.sharedAt)}`:"";return`Shared by ${Y.sharedByUserId}${ge}`},Dt=Y=>"sharedByUserId"in Y;b.useEffect(()=>{const Y=Array.isArray(k)?k:[];if(Y.length>0){P.current=!0,J(Y);return}_||(P.current=!1,J(Y))},[k,_]),b.useEffect(()=>{if(!M.current)return;const Y=M.current.querySelector("[data-radix-scroll-area-viewport]");if(!Y)return;let ge=null,it=null;return ge=requestAnimationFrame(()=>{it=requestAnimationFrame(()=>{Y.scrollTop=G.current})}),()=>{ge!==null&&cancelAnimationFrame(ge),it!==null&&cancelAnimationFrame(it)}},[q]);const $e=async Y=>{try{E(Y),await O(Y),a==null||a(Y),l==null||l(Y)}catch(ge){console.error("Failed to select thread:",ge)}},Pt=async()=>{try{Q(!0);const Y=await I();Y&&(c==null||c(Y),a==null||a(Y))}catch(Y){console.error("Failed to create thread:",Y)}finally{Q(!1)}},nn=async(Y,ge)=>{if(ge.stopPropagation(),!!confirm("Delete this thread?")){if(M.current){const it=M.current.querySelector("[data-radix-scroll-area-viewport]");it&&(G.current=it.scrollTop)}try{await W(Y),d==null||d(Y)}catch(it){console.error("Failed to delete thread:",it)}}},Me=(Y,ge)=>{ge.stopPropagation(),se(Y.threadId),D(Y.title||`Thread ${Y.threadId.slice(0,8)}`)},Ke=async Y=>{if(V.trim())try{await N(Y,V.trim()),se(null),D("")}catch(ge){console.error("Failed to update title:",ge)}},Ct=()=>{se(null),D("")},Ze=Y=>{if(!Y)return"";try{const ge=new Date(Y),Ce=new Date().getTime()-ge.getTime(),Oe=Math.floor(Ce/(1e3*60*60*24));return Oe===0?ge.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):Oe===1?"Yesterday":Oe<7?`${Oe} days ago`:ge.toLocaleDateString()}catch{return""}},pt=Y=>Y.title||`Thread ${Y.threadId.slice(0,8)}`,le=Y=>{const ge=pt(Y);return ge.length<=nm?ge:`${ge.slice(0,nm)}...`};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(at,{onClick:Pt,disabled:X||_,className:s.createButton||"px-3 py-2 gap-1",size:"sm",variant:"ghost",title:X?"Creating...":"New Chat",children:[u.jsx(ue.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(vs,{children:[u.jsx(ws,{asChild:!0,children:u.jsx(at,{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:Xe.label})}),u.jsx(ao,{align:"start",sideOffset:6,className:"w-40",children:Ee.map(Y=>u.jsxs(On,{className:"justify-between text-[12px]",onClick:ge=>{ge.preventDefault(),Ve(Y.key)},children:[u.jsx("span",{children:Y.label}),je===Y.key&&u.jsx(ue.Check,{className:"h-3 w-3"})]},Y.key))})]})]})]}),u.jsx(Il,{ref:M,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:vt?u.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-8 text-slate-400",children:[u.jsx(ue.Loader2,{className:"h-5 w-5 animate-spin"}),u.jsx("span",{className:"text-sm",children:"Loading threads…"})]}):xt.length===0?u.jsxs("div",{className:"text-center py-8 text-slate-400",children:[u.jsx(ue.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:dt})]}):xt.slice().sort((Y,ge)=>new Date(ge.updatedAt||ge.createdAt||"").getTime()-new Date(Y.updatedAt||Y.createdAt||"").getTime()).map(Y=>u.jsx(tm,{thread:Y,isActive:j===Y.threadId,editingThreadId:Z,editingTitle:V,onSelect:$e,onStartEditing:Me,onEditingTitleChange:ge=>D(ge),onSaveEditing:Ke,onCancelEditing:Ct,onShare:()=>ze(Y.threadId),onDelete:nn,showEditTitle:r,showDeleteButton:n,formatDate:Ze,getDisplayThreadTitle:le,secondaryLine:et&&Dt(Y)?Et(Y):void 0,itemClassName:s.threadItem,activeItemClassName:s.activeThread},Y.threadId))})}),u.jsx(Ya,{open:ae,onOpenChange:Y=>!Y&&Ge(),children:u.jsxs(Ds,{className:"max-w-md p-0",children:[u.jsx(Ls,{children:u.jsx($s,{children:"Share thread"})}),u.jsxs(gl,{children:[u.jsx(xl,{autoFocus:!0,value:de,onValueChange:Y=>xe(Y),placeholder:"Search for recipients..."}),u.jsxs(vl,{children:[K&&u.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-xs text-muted-foreground",children:[H&&u.jsx(ue.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(wl,{children:w?u.jsxs("span",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(ue.Loader2,{className:"h-4 w-4 animate-spin"}),"Loading recipients…"]}):"No matching recipients found"}),nt.length>0&&u.jsx(bl,{heading:"Recipients",children:nt.map(Y=>u.jsx(yl,{onSelect:()=>rt(Y),children:u.jsxs("div",{className:"flex flex-col items-start text-sm",children:[u.jsx("span",{className:"font-medium",children:Y.label}),Y.secondaryLabel&&u.jsx("span",{className:"text-xs text-muted-foreground",children:Y.secondaryLabel})]})},Y.id))})]})]})]})})]})}function pk({layout:e="sidebar",layoutSize:t="desktop",showThreads:n=!0,className:r="",customStyles:o={},...s}){const i=c=>{const d="h-full";switch(c){case"phone":return`${d} max-w-none`;case"tablet":return`${d} max-w-4xl mx-auto`;case"half-screen":return`${d} max-w-2xl`;case"desktop":default:return`${d} max-w-7xl mx-auto`}},a=c=>({"--chat-sidebar-width":c==="phone"?"100%":c==="tablet"?"280px":c==="half-screen"?"240px":"320px","--chat-message-max-width":c==="phone"?"95%":c==="tablet"?"90%":c==="half-screen"?"85%":"80%","--chat-input-height":c==="phone"?"120px":"100px"}),l=b.useCallback(c=>{var d;(d=s.onThreadChange)==null||d.call(s,c)},[s]);return e==="fullscreen"?u.jsx(Xr,{...s,onThreadChange:l,children:u.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:u.jsx(So,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?u.jsx(Xr,{...s,onThreadChange:l,children:u.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:u.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[n&&u.jsx("div",{className:`w-80 border-r flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:u.jsx(Al,{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(So,{onError:s.onError,enableFileUpload:!0})})]})})}):u.jsx(Xr,{...s,onThreadChange:l,children:u.jsxs("div",{className:`${i(t)} flex overflow-hidden ${r} ${o.container||""}`,style:a(t),children:[n&&u.jsx("div",{className:`w-80 border-r bg-gray-50 flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:u.jsx(Al,{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(So,{onError:s.onError,enableFileUpload:!0})})]})})}function hk({apiConfig:e,className:t="",onError:n}){return u.jsx(Xr,{apiConfig:e,onError:n,children:u.jsx("div",{className:`h-full ${t}`,children:u.jsx(So,{})})})}var mk="Label",sm=h.forwardRef((e,t)=>u.jsx(be.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())}}));sm.displayName=mk;var im=sm;const gk=Dr.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(im,{ref:n,className:ne(gk(),e),...t}));am.displayName=im.displayName;function lm(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 cm=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"}),xk="VisuallyHidden",Js=h.forwardRef((e,t)=>u.jsx(be.span,{...e,ref:t,style:{...cm,...e.style}}));Js.displayName=xk;var vk=Js,wk=[" ","Enter","ArrowUp","ArrowDown"],bk=[" ","Enter"],ir="Select",[Zs,Qs,yk]=Vo(ir),[Mr,c1]=sn(ir,[yk,yr]),ei=yr(),[Sk,Un]=Mr(ir),[Ck,Tk]=Mr(ir),um=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:l,dir:c,name:d,autoComplete:p,disabled:m,required:f,form:v}=e,g=ei(t),[x,y]=h.useState(null),[w,S]=h.useState(null),[k,C]=h.useState(!1),T=Ko(c),[E,_]=_n({prop:r,defaultProp:o??!1,onChange:s,caller:ir}),[R,L]=_n({prop:i,defaultProp:a,onChange:l,caller:ir}),H=h.useRef(null),K=x?v||!!x.closest("form"):!0,[F,I]=h.useState(new Set),W=Array.from(F).map(N=>N.props.value).join(";");return u.jsx(ea,{...g,children:u.jsxs(Sk,{required:f,scope:t,trigger:x,onTriggerChange:y,valueNode:w,onValueNodeChange:S,valueNodeHasChildren:k,onValueNodeHasChildrenChange:C,contentId:Nt(),value:R,onValueChange:L,open:E,onOpenChange:_,dir:T,triggerPointerDownPosRef:H,disabled:m,children:[u.jsx(Zs.Provider,{scope:t,children:u.jsx(Ck,{scope:e.__scopeSelect,onNativeOptionAdd:h.useCallback(N=>{I(U=>new Set(U).add(N))},[]),onNativeOptionRemove:h.useCallback(N=>{I(U=>{const O=new Set(U);return O.delete(N),O})},[]),children:n})}),K?u.jsxs(Rm,{"aria-hidden":!0,required:f,tabIndex:-1,name:d,autoComplete:p,value:R,onChange:N=>L(N.target.value),disabled:m,form:v,children:[R===void 0?u.jsx("option",{value:""}):null,Array.from(F)]},W):null]})})};um.displayName=ir;var dm="SelectTrigger",fm=h.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=ei(n),i=Un(dm,n),a=i.disabled||r,l=De(t,i.onTriggerChange),c=Qs(n),d=h.useRef("touch"),[p,m,f]=Dm(g=>{const x=c().filter(S=>!S.disabled),y=x.find(S=>S.value===i.value),w=Lm(x,g,y);w!==void 0&&i.onValueChange(w.value)}),v=g=>{a||(i.onOpenChange(!0),f()),g&&(i.triggerPointerDownPosRef.current={x:Math.round(g.pageX),y:Math.round(g.pageY)})};return u.jsx(ta,{asChild:!0,...s,children:u.jsx(be.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":Om(i.value)?"":void 0,...o,ref:l,onClick:ie(o.onClick,g=>{g.currentTarget.focus(),d.current!=="mouse"&&v(g)}),onPointerDown:ie(o.onPointerDown,g=>{d.current=g.pointerType;const x=g.target;x.hasPointerCapture(g.pointerId)&&x.releasePointerCapture(g.pointerId),g.button===0&&g.ctrlKey===!1&&g.pointerType==="mouse"&&(v(g),g.preventDefault())}),onKeyDown:ie(o.onKeyDown,g=>{const x=p.current!=="";!(g.ctrlKey||g.altKey||g.metaKey)&&g.key.length===1&&m(g.key),!(x&&g.key===" ")&&wk.includes(g.key)&&(v(),g.preventDefault())})})})});fm.displayName=dm;var pm="SelectValue",hm=h.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=Un(pm,n),{onValueNodeHasChildrenChange:c}=l,d=s!==void 0,p=De(t,l.onValueNodeChange);return kt(()=>{c(d)},[c,d]),u.jsx(be.span,{...a,ref:p,style:{pointerEvents:"none"},children:Om(l.value)?u.jsx(u.Fragment,{children:i}):s})});hm.displayName=pm;var kk="SelectIcon",mm=h.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return u.jsx(be.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});mm.displayName=kk;var Ek="SelectPortal",gm=e=>u.jsx(eo,{asChild:!0,...e});gm.displayName=Ek;var ar="SelectContent",xm=h.forwardRef((e,t)=>{const n=Un(ar,e.__scopeSelect),[r,o]=h.useState();if(kt(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?Lr.createPortal(u.jsx(vm,{scope:e.__scopeSelect,children:u.jsx(Zs.Slot,{scope:e.__scopeSelect,children:u.jsx("div",{children:e.children})})}),s):null}return u.jsx(wm,{...e,ref:t})});xm.displayName=ar;var fn=10,[vm,Wn]=Mr(ar),Ik="SelectContentImpl",Nk=Vt.createSlot("SelectContent.RemoveScroll"),wm=h.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:p,collisionBoundary:m,collisionPadding:f,sticky:v,hideWhenDetached:g,avoidCollisions:x,...y}=e,w=Un(ar,n),[S,k]=h.useState(null),[C,T]=h.useState(null),E=De(t,V=>k(V)),[_,R]=h.useState(null),[L,H]=h.useState(null),K=Qs(n),[F,I]=h.useState(!1),W=h.useRef(!1);h.useEffect(()=>{if(S)return aa(S)},[S]),$i();const N=h.useCallback(V=>{const[D,...X]=K().map($=>$.ref.current),[Q]=X.slice(-1),ae=document.activeElement;for(const $ of V)if($===ae||($==null||$.scrollIntoView({block:"nearest"}),$===D&&C&&(C.scrollTop=0),$===Q&&C&&(C.scrollTop=C.scrollHeight),$==null||$.focus(),document.activeElement!==ae))return},[K,C]),U=h.useCallback(()=>N([_,S]),[N,_,S]);h.useEffect(()=>{F&&U()},[F,U]);const{onOpenChange:O,triggerPointerDownPosRef:j}=w;h.useEffect(()=>{if(S){let V={x:0,y:0};const D=Q=>{var ae,$;V={x:Math.abs(Math.round(Q.pageX)-(((ae=j.current)==null?void 0:ae.x)??0)),y:Math.abs(Math.round(Q.pageY)-((($=j.current)==null?void 0:$.y)??0))}},X=Q=>{V.x<=10&&V.y<=10?Q.preventDefault():S.contains(Q.target)||O(!1),document.removeEventListener("pointermove",D),j.current=null};return j.current!==null&&(document.addEventListener("pointermove",D),document.addEventListener("pointerup",X,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",D),document.removeEventListener("pointerup",X,{capture:!0})}}},[S,O,j]),h.useEffect(()=>{const V=()=>O(!1);return window.addEventListener("blur",V),window.addEventListener("resize",V),()=>{window.removeEventListener("blur",V),window.removeEventListener("resize",V)}},[O]);const[q,J]=Dm(V=>{const D=K().filter(ae=>!ae.disabled),X=D.find(ae=>ae.ref.current===document.activeElement),Q=Lm(D,V,X);Q&&setTimeout(()=>Q.ref.current.focus())}),P=h.useCallback((V,D,X)=>{const Q=!W.current&&!X;(w.value!==void 0&&w.value===D||Q)&&(R(V),Q&&(W.current=!0))},[w.value]),M=h.useCallback(()=>S==null?void 0:S.focus(),[S]),G=h.useCallback((V,D,X)=>{const Q=!W.current&&!X;(w.value!==void 0&&w.value===D||Q)&&H(V)},[w.value]),Z=r==="popper"?jl:bm,se=Z===jl?{side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:p,collisionBoundary:m,collisionPadding:f,sticky:v,hideWhenDetached:g,avoidCollisions:x}:{};return u.jsx(vm,{scope:n,content:S,viewport:C,onViewportChange:T,itemRefCallback:P,selectedItem:_,onItemLeave:M,itemTextRefCallback:G,focusSelectedItem:U,selectedItemText:L,position:r,isPositioned:F,searchRef:q,children:u.jsx(fs,{as:Nk,allowPinchZoom:!0,children:u.jsx(qo,{asChild:!0,trapped:w.open,onMountAutoFocus:V=>{V.preventDefault()},onUnmountAutoFocus:ie(o,V=>{var D;(D=w.trigger)==null||D.focus({preventScroll:!0}),V.preventDefault()}),children:u.jsx(gr,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:V=>V.preventDefault(),onDismiss:()=>w.onOpenChange(!1),children:u.jsx(Z,{role:"listbox",id:w.contentId,"data-state":w.open?"open":"closed",dir:w.dir,onContextMenu:V=>V.preventDefault(),...y,...se,onPlaced:()=>I(!0),ref:E,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:ie(y.onKeyDown,V=>{const D=V.ctrlKey||V.altKey||V.metaKey;if(V.key==="Tab"&&V.preventDefault(),!D&&V.key.length===1&&J(V.key),["ArrowUp","ArrowDown","Home","End"].includes(V.key)){let Q=K().filter(ae=>!ae.disabled).map(ae=>ae.ref.current);if(["ArrowUp","End"].includes(V.key)&&(Q=Q.slice().reverse()),["ArrowUp","ArrowDown"].includes(V.key)){const ae=V.target,$=Q.indexOf(ae);Q=Q.slice($+1)}setTimeout(()=>N(Q)),V.preventDefault()}})})})})})})});wm.displayName=Ik;var Ak="SelectItemAlignedPosition",bm=h.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=Un(ar,n),i=Wn(ar,n),[a,l]=h.useState(null),[c,d]=h.useState(null),p=De(t,E=>d(E)),m=Qs(n),f=h.useRef(!1),v=h.useRef(!0),{viewport:g,selectedItem:x,selectedItemText:y,focusSelectedItem:w}=i,S=h.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&c&&g&&x&&y){const E=s.trigger.getBoundingClientRect(),_=c.getBoundingClientRect(),R=s.valueNode.getBoundingClientRect(),L=y.getBoundingClientRect();if(s.dir!=="rtl"){const ae=L.left-_.left,$=R.left-ae,re=E.left-$,we=E.width+re,de=Math.max(we,_.width),xe=window.innerWidth-fn,Ee=Sl($,[fn,Math.max(fn,xe-de)]);a.style.minWidth=we+"px",a.style.left=Ee+"px"}else{const ae=_.right-L.right,$=window.innerWidth-R.right-ae,re=window.innerWidth-E.right-$,we=E.width+re,de=Math.max(we,_.width),xe=window.innerWidth-fn,Ee=Sl($,[fn,Math.max(fn,xe-de)]);a.style.minWidth=we+"px",a.style.right=Ee+"px"}const H=m(),K=window.innerHeight-fn*2,F=g.scrollHeight,I=window.getComputedStyle(c),W=parseInt(I.borderTopWidth,10),N=parseInt(I.paddingTop,10),U=parseInt(I.borderBottomWidth,10),O=parseInt(I.paddingBottom,10),j=W+N+F+O+U,q=Math.min(x.offsetHeight*5,j),J=window.getComputedStyle(g),P=parseInt(J.paddingTop,10),M=parseInt(J.paddingBottom,10),G=E.top+E.height/2-fn,Z=K-G,se=x.offsetHeight/2,V=x.offsetTop+se,D=W+N+V,X=j-D;if(D<=G){const ae=H.length>0&&x===H[H.length-1].ref.current;a.style.bottom="0px";const $=c.clientHeight-g.offsetTop-g.offsetHeight,re=Math.max(Z,se+(ae?M:0)+$+U),we=D+re;a.style.height=we+"px"}else{const ae=H.length>0&&x===H[0].ref.current;a.style.top="0px";const re=Math.max(G,W+g.offsetTop+(ae?P:0)+se)+X;a.style.height=re+"px",g.scrollTop=D-G+g.offsetTop}a.style.margin=`${fn}px 0`,a.style.minHeight=q+"px",a.style.maxHeight=K+"px",r==null||r(),requestAnimationFrame(()=>f.current=!0)}},[m,s.trigger,s.valueNode,a,c,g,x,y,s.dir,r]);kt(()=>S(),[S]);const[k,C]=h.useState();kt(()=>{c&&C(window.getComputedStyle(c).zIndex)},[c]);const T=h.useCallback(E=>{E&&v.current===!0&&(S(),w==null||w(),v.current=!1)},[S,w]);return u.jsx(_k,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:f,onScrollButtonChange:T,children:u.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:k},children:u.jsx(be.div,{...o,ref:p,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});bm.displayName=Ak;var jk="SelectPopperPosition",jl=h.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=fn,...s}=e,i=ei(n);return u.jsx(na,{...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)"}})});jl.displayName=jk;var[_k,_l]=Mr(ar,{}),Pl="SelectViewport",ym=h.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=Wn(Pl,n),i=_l(Pl,n),a=De(t,s.onViewportChange),l=h.useRef(0);return u.jsxs(u.Fragment,{children:[u.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),u.jsx(Zs.Slot,{scope:n,children:u.jsx(be.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:ie(o.onScroll,c=>{const d=c.currentTarget,{contentWrapper:p,shouldExpandOnScrollRef:m}=i;if(m!=null&&m.current&&p){const f=Math.abs(l.current-d.scrollTop);if(f>0){const v=window.innerHeight-fn*2,g=parseFloat(p.style.minHeight),x=parseFloat(p.style.height),y=Math.max(g,x);if(y<v){const w=y+f,S=Math.min(v,w),k=w-S;p.style.height=S+"px",p.style.bottom==="0px"&&(d.scrollTop=k>0?k:0,p.style.justifyContent="flex-end")}}}l.current=d.scrollTop})})})]})});ym.displayName=Pl;var Sm="SelectGroup",[Pk,Mk]=Mr(Sm),Rk=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Nt();return u.jsx(Pk,{scope:n,id:o,children:u.jsx(be.div,{role:"group","aria-labelledby":o,...r,ref:t})})});Rk.displayName=Sm;var Cm="SelectLabel",Tm=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Mk(Cm,n);return u.jsx(be.div,{id:o.id,...r,ref:t})});Tm.displayName=Cm;var ti="SelectItem",[Ok,km]=Mr(ti),Em=h.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=Un(ti,n),l=Wn(ti,n),c=a.value===r,[d,p]=h.useState(s??""),[m,f]=h.useState(!1),v=De(t,w=>{var S;return(S=l.itemRefCallback)==null?void 0:S.call(l,w,r,o)}),g=Nt(),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(Ok,{scope:n,value:r,disabled:o,textId:g,isSelected:c,onItemTextChange:h.useCallback(w=>{p(S=>S||((w==null?void 0:w.textContent)??"").trim())},[]),children:u.jsx(Zs.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:u.jsx(be.div,{role:"option","aria-labelledby":g,"data-highlighted":m?"":void 0,"aria-selected":c&&m,"data-state":c?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:v,onFocus:ie(i.onFocus,()=>f(!0)),onBlur:ie(i.onBlur,()=>f(!1)),onClick:ie(i.onClick,()=>{x.current!=="mouse"&&y()}),onPointerUp:ie(i.onPointerUp,()=>{x.current==="mouse"&&y()}),onPointerDown:ie(i.onPointerDown,w=>{x.current=w.pointerType}),onPointerMove:ie(i.onPointerMove,w=>{var S;x.current=w.pointerType,o?(S=l.onItemLeave)==null||S.call(l):x.current==="mouse"&&w.currentTarget.focus({preventScroll:!0})}),onPointerLeave:ie(i.onPointerLeave,w=>{var S;w.currentTarget===document.activeElement&&((S=l.onItemLeave)==null||S.call(l))}),onKeyDown:ie(i.onKeyDown,w=>{var k;((k=l.searchRef)==null?void 0:k.current)!==""&&w.key===" "||(bk.includes(w.key)&&y(),w.key===" "&&w.preventDefault())})})})})});Em.displayName=ti;var ko="SelectItemText",Im=h.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=Un(ko,n),a=Wn(ko,n),l=km(ko,n),c=Tk(ko,n),[d,p]=h.useState(null),m=De(t,y=>p(y),l.onItemTextChange,y=>{var w;return(w=a.itemTextRefCallback)==null?void 0:w.call(a,y,l.value,l.disabled)}),f=d==null?void 0:d.textContent,v=h.useMemo(()=>u.jsx("option",{value:l.value,disabled:l.disabled,children:f},l.value),[l.disabled,l.value,f]),{onNativeOptionAdd:g,onNativeOptionRemove:x}=c;return kt(()=>(g(v),()=>x(v)),[g,x,v]),u.jsxs(u.Fragment,{children:[u.jsx(be.span,{id:l.textId,...s,ref:m}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?Lr.createPortal(s.children,i.valueNode):null]})});Im.displayName=ko;var Nm="SelectItemIndicator",Am=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return km(Nm,n).isSelected?u.jsx(be.span,{"aria-hidden":!0,...r,ref:t}):null});Am.displayName=Nm;var Ml="SelectScrollUpButton",jm=h.forwardRef((e,t)=>{const n=Wn(Ml,e.__scopeSelect),r=_l(Ml,e.__scopeSelect),[o,s]=h.useState(!1),i=De(t,r.onScrollButtonChange);return kt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const c=l.scrollTop>0;s(c)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?u.jsx(Pm,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});jm.displayName=Ml;var Rl="SelectScrollDownButton",_m=h.forwardRef((e,t)=>{const n=Wn(Rl,e.__scopeSelect),r=_l(Rl,e.__scopeSelect),[o,s]=h.useState(!1),i=De(t,r.onScrollButtonChange);return kt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const c=l.scrollHeight-l.clientHeight,d=Math.ceil(l.scrollTop)<c;s(d)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?u.jsx(Pm,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});_m.displayName=Rl;var Pm=h.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=Wn("SelectScrollButton",n),i=h.useRef(null),a=Qs(n),l=h.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return h.useEffect(()=>()=>l(),[l]),kt(()=>{var d;const c=a().find(p=>p.ref.current===document.activeElement);(d=c==null?void 0:c.ref.current)==null||d.scrollIntoView({block:"nearest"})},[a]),u.jsx(be.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:ie(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:ie(o.onPointerMove,()=>{var c;(c=s.onItemLeave)==null||c.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:ie(o.onPointerLeave,()=>{l()})})}),Dk="SelectSeparator",Mm=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return u.jsx(be.div,{"aria-hidden":!0,...r,ref:t})});Mm.displayName=Dk;var Ol="SelectArrow",Lk=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=ei(n),s=Un(Ol,n),i=Wn(Ol,n);return s.open&&i.position==="popper"?u.jsx(ra,{...o,...r,ref:t}):null});Lk.displayName=Ol;var $k="SelectBubbleInput",Rm=h.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=h.useRef(null),s=De(r,o),i=lm(t);return h.useEffect(()=>{const a=o.current;if(!a)return;const l=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(l,"value").set;if(i!==t&&d){const p=new Event("change",{bubbles:!0});d.call(a,t),a.dispatchEvent(p)}},[i,t]),u.jsx(be.select,{...n,style:{...cm,...n.style},ref:s,defaultValue:t})});Rm.displayName=$k;function Om(e){return e===""||e===void 0}function Dm(e){const t=mt(e),n=h.useRef(""),r=h.useRef(0),o=h.useCallback(i=>{const a=n.current+i;t(a),function l(c){n.current=c,window.clearTimeout(r.current),c!==""&&(r.current=window.setTimeout(()=>l(""),1e3))}(a)},[t]),s=h.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return h.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function Lm(e,t,n){const o=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=Fk(e,Math.max(s,0));o.length===1&&(i=i.filter(c=>c!==n));const l=i.find(c=>c.textValue.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function Fk(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Bk=um,$m=fm,zk=hm,Hk=mm,Uk=gm,Fm=xm,Wk=ym,Bm=Tm,zm=Em,Vk=Im,Kk=Am,Hm=jm,Um=_m,Wm=Mm;const qk=Bk,Gk=zk,Vm=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs($m,{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(Hk,{asChild:!0,children:u.jsx(ue.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));Vm.displayName=$m.displayName;const Km=h.forwardRef(({className:e,...t},n)=>u.jsx(Hm,{ref:n,className:ne("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(ue.ChevronUp,{className:"h-4 w-4"})}));Km.displayName=Hm.displayName;const qm=h.forwardRef(({className:e,...t},n)=>u.jsx(Um,{ref:n,className:ne("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(ue.ChevronDown,{className:"h-4 w-4"})}));qm.displayName=Um.displayName;const Gm=h.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>u.jsx(Uk,{children:u.jsxs(Fm,{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(Km,{}),u.jsx(Wk,{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(qm,{})]})}));Gm.displayName=Fm.displayName;const Yk=h.forwardRef(({className:e,...t},n)=>u.jsx(Bm,{ref:n,className:ne("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));Yk.displayName=Bm.displayName;const Ym=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(zm,{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(Kk,{children:u.jsx(ue.Check,{className:"h-4 w-4"})})}),u.jsx(Vk,{children:t})]}));Ym.displayName=zm.displayName;const Xk=h.forwardRef(({className:e,...t},n)=>u.jsx(Wm,{ref:n,className:ne("-mx-1 my-1 h-px bg-muted",e),...t}));Xk.displayName=Wm.displayName;var Jk="Separator",Xm="horizontal",Zk=["horizontal","vertical"],Jm=h.forwardRef((e,t)=>{const{decorative:n,orientation:r=Xm,...o}=e,s=Qk(r)?r:Xm,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return u.jsx(be.div,{"data-orientation":s,...a,...o,ref:t})});Jm.displayName=Jk;function Qk(e){return Zk.includes(e)}var Zm=Jm;const Qm=h.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>u.jsx(Zm,{ref:o,decorative:n,orientation:t,className:ne("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));Qm.displayName=Zm.displayName;var ni="Switch",[eE,u1]=sn(ni),[tE,nE]=eE(ni),eg=h.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:s,required:i,disabled:a,value:l="on",onCheckedChange:c,form:d,...p}=e,[m,f]=h.useState(null),v=De(t,S=>f(S)),g=h.useRef(!1),x=m?d||!!m.closest("form"):!0,[y,w]=_n({prop:o,defaultProp:s??!1,onChange:c,caller:ni});return u.jsxs(tE,{scope:n,checked:y,disabled:a,children:[u.jsx(be.button,{type:"button",role:"switch","aria-checked":y,"aria-required":i,"data-state":og(y),"data-disabled":a?"":void 0,disabled:a,value:l,...p,ref:v,onClick:ie(e.onClick,S=>{w(k=>!k),x&&(g.current=S.isPropagationStopped(),g.current||S.stopPropagation())})}),x&&u.jsx(rg,{control:m,bubbles:!g.current,name:r,value:l,checked:y,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});eg.displayName=ni;var tg="SwitchThumb",ng=h.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=nE(tg,n);return u.jsx(be.span,{"data-state":og(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});ng.displayName=tg;var rE="SwitchBubbleInput",rg=h.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=h.useRef(null),a=De(i,s),l=lm(n),c=hd(t);return h.useEffect(()=>{const d=i.current;if(!d)return;const p=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(p,"checked").set;if(l!==n&&f){const v=new Event("click",{bubbles:r});f.call(d,n),d.dispatchEvent(v)}},[l,n,r]),u.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:a,style:{...o.style,...c,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});rg.displayName=rE;function og(e){return e?"checked":"unchecked"}var sg=eg,oE=ng;const ig=h.forwardRef(({className:e,...t},n)=>u.jsx(sg,{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(oE,{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")})}));ig.displayName=sg.displayName;const sE=qa,iE=XC,aE=Ga,ag=h.forwardRef(({className:e,...t},n)=>u.jsx(wo,{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=wo.displayName;const lE=Dr.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"}}),lg=h.forwardRef(({side:e="right",className:t,children:n,...r},o)=>u.jsxs(aE,{children:[u.jsx(ag,{}),u.jsxs(bo,{ref:o,className:ne(lE({side:e}),t),...r,children:[n,u.jsxs(eh,{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(ue.X,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));lg.displayName=bo.displayName;const cg=({className:e,...t})=>u.jsx("div",{className:ne("flex flex-col space-y-2 text-center sm:text-left",e),...t});cg.displayName="SheetHeader";const ug=h.forwardRef(({className:e,...t},n)=>u.jsx(rr,{ref:n,className:ne("text-lg font-semibold text-foreground",e),...t}));ug.displayName=rr.displayName;const dg=h.forwardRef(({className:e,...t},n)=>u.jsx(Os,{ref:n,className:ne("text-sm text-muted-foreground",e),...t}));dg.displayName=Os.displayName;var[ri,d1]=sn("Tooltip",[yr]),oi=yr(),fg="TooltipProvider",cE=700,Dl="tooltip.open",[uE,Ll]=ri(fg),pg=e=>{const{__scopeTooltip:t,delayDuration:n=cE,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:s}=e,i=h.useRef(!0),a=h.useRef(!1),l=h.useRef(0);return h.useEffect(()=>{const c=l.current;return()=>window.clearTimeout(c)},[]),u.jsx(uE,{scope:t,isOpenDelayedRef:i,delayDuration:n,onOpen:h.useCallback(()=>{window.clearTimeout(l.current),i.current=!1},[]),onClose:h.useCallback(()=>{window.clearTimeout(l.current),l.current=window.setTimeout(()=>i.current=!0,r)},[r]),isPointerInTransitRef:a,onPointerInTransitChange:h.useCallback(c=>{a.current=c},[]),disableHoverableContent:o,children:s})};pg.displayName=fg;var Eo="Tooltip",[dE,si]=ri(Eo),hg=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:s,disableHoverableContent:i,delayDuration:a}=e,l=Ll(Eo,e.__scopeTooltip),c=oi(t),[d,p]=h.useState(null),m=Nt(),f=h.useRef(0),v=i??l.disableHoverableContent,g=a??l.delayDuration,x=h.useRef(!1),[y,w]=_n({prop:r,defaultProp:o??!1,onChange:E=>{E?(l.onOpen(),document.dispatchEvent(new CustomEvent(Dl))):l.onClose(),s==null||s(E)},caller:Eo}),S=h.useMemo(()=>y?x.current?"delayed-open":"instant-open":"closed",[y]),k=h.useCallback(()=>{window.clearTimeout(f.current),f.current=0,x.current=!1,w(!0)},[w]),C=h.useCallback(()=>{window.clearTimeout(f.current),f.current=0,w(!1)},[w]),T=h.useCallback(()=>{window.clearTimeout(f.current),f.current=window.setTimeout(()=>{x.current=!0,w(!0),f.current=0},g)},[g,w]);return h.useEffect(()=>()=>{f.current&&(window.clearTimeout(f.current),f.current=0)},[]),u.jsx(ea,{...c,children:u.jsx(dE,{scope:t,contentId:m,open:y,stateAttribute:S,trigger:d,onTriggerChange:p,onTriggerEnter:h.useCallback(()=>{l.isOpenDelayedRef.current?T():k()},[l.isOpenDelayedRef,T,k]),onTriggerLeave:h.useCallback(()=>{v?C():(window.clearTimeout(f.current),f.current=0)},[C,v]),onOpen:k,onClose:C,disableHoverableContent:v,children:n})})};hg.displayName=Eo;var $l="TooltipTrigger",mg=h.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=si($l,n),s=Ll($l,n),i=oi(n),a=h.useRef(null),l=De(t,a,o.onTriggerChange),c=h.useRef(!1),d=h.useRef(!1),p=h.useCallback(()=>c.current=!1,[]);return h.useEffect(()=>()=>document.removeEventListener("pointerup",p),[p]),u.jsx(ta,{asChild:!0,...i,children:u.jsx(be.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:l,onPointerMove:ie(e.onPointerMove,m=>{m.pointerType!=="touch"&&!d.current&&!s.isPointerInTransitRef.current&&(o.onTriggerEnter(),d.current=!0)}),onPointerLeave:ie(e.onPointerLeave,()=>{o.onTriggerLeave(),d.current=!1}),onPointerDown:ie(e.onPointerDown,()=>{o.open&&o.onClose(),c.current=!0,document.addEventListener("pointerup",p,{once:!0})}),onFocus:ie(e.onFocus,()=>{c.current||o.onOpen()}),onBlur:ie(e.onBlur,o.onClose),onClick:ie(e.onClick,o.onClose)})})});mg.displayName=$l;var fE="TooltipPortal",[f1,pE]=ri(fE,{forceMount:void 0}),Rr="TooltipContent",gg=h.forwardRef((e,t)=>{const n=pE(Rr,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...s}=e,i=si(Rr,e.__scopeTooltip);return u.jsx(Ft,{present:r||i.open,children:i.disableHoverableContent?u.jsx(xg,{side:o,...s,ref:t}):u.jsx(hE,{side:o,...s,ref:t})})}),hE=h.forwardRef((e,t)=>{const n=si(Rr,e.__scopeTooltip),r=Ll(Rr,e.__scopeTooltip),o=h.useRef(null),s=De(t,o),[i,a]=h.useState(null),{trigger:l,onClose:c}=n,d=o.current,{onPointerInTransitChange:p}=r,m=h.useCallback(()=>{a(null),p(!1)},[p]),f=h.useCallback((v,g)=>{const x=v.currentTarget,y={x:v.clientX,y:v.clientY},w=wE(y,x.getBoundingClientRect()),S=bE(y,w),k=yE(g.getBoundingClientRect()),C=CE([...S,...k]);a(C),p(!0)},[p]);return h.useEffect(()=>()=>m(),[m]),h.useEffect(()=>{if(l&&d){const v=x=>f(x,d),g=x=>f(x,l);return l.addEventListener("pointerleave",v),d.addEventListener("pointerleave",g),()=>{l.removeEventListener("pointerleave",v),d.removeEventListener("pointerleave",g)}}},[l,d,f,m]),h.useEffect(()=>{if(i){const v=g=>{const x=g.target,y={x:g.clientX,y:g.clientY},w=(l==null?void 0:l.contains(x))||(d==null?void 0:d.contains(x)),S=!SE(y,i);w?m():S&&(m(),c())};return document.addEventListener("pointermove",v),()=>document.removeEventListener("pointermove",v)}},[l,d,i,c,m]),u.jsx(xg,{...e,ref:s})}),[mE,gE]=ri(Eo,{isInside:!1}),xE=Vt.createSlottable("TooltipContent"),xg=h.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:s,onPointerDownOutside:i,...a}=e,l=si(Rr,n),c=oi(n),{onClose:d}=l;return h.useEffect(()=>(document.addEventListener(Dl,d),()=>document.removeEventListener(Dl,d)),[d]),h.useEffect(()=>{if(l.trigger){const p=m=>{const f=m.target;f!=null&&f.contains(l.trigger)&&d()};return window.addEventListener("scroll",p,{capture:!0}),()=>window.removeEventListener("scroll",p,{capture:!0})}},[l.trigger,d]),u.jsx(gr,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:p=>p.preventDefault(),onDismiss:d,children:u.jsxs(na,{"data-state":l.stateAttribute,...c,...a,ref:t,style:{...a.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[u.jsx(xE,{children:r}),u.jsx(mE,{scope:n,isInside:!0,children:u.jsx(vk,{id:l.contentId,role:"tooltip",children:o||r})})]})})});gg.displayName=Rr;var vg="TooltipArrow",vE=h.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=oi(n);return gE(vg,n).isInside?null:u.jsx(ra,{...o,...r,ref:t})});vE.displayName=vg;function wE(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 bE(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 yE(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 SE(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const a=t[s],l=t[i],c=a.x,d=a.y,p=l.x,m=l.y;d>r!=m>r&&n<(p-c)*(r-d)/(m-d)+c&&(o=!o)}return o}function CE(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),TE(t)}function TE(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 kE=pg,EE=hg,IE=mg,wg=gg;const NE=kE,AE=EE,jE=IE,bg=h.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(wg,{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}));bg.displayName=wg.displayName;var Fl="ToastProvider",[Bl,_E,PE]=Vo("Toast"),[yg,p1]=sn("Toast",[PE]),[ME,ii]=yg(Fl),Sg=e=>{const{__scopeToast:t,label:n="Notification",duration:r=5e3,swipeDirection:o="right",swipeThreshold:s=50,children:i}=e,[a,l]=h.useState(null),[c,d]=h.useState(0),p=h.useRef(!1),m=h.useRef(!1);return n.trim()||console.error(`Invalid prop \`label\` supplied to \`${Fl}\`. Expected non-empty \`string\`.`),u.jsx(Bl.Provider,{scope:t,children:u.jsx(ME,{scope:t,label:n,duration:r,swipeDirection:o,swipeThreshold:s,toastCount:c,viewport:a,onViewportChange:l,onToastAdd:h.useCallback(()=>d(f=>f+1),[]),onToastRemove:h.useCallback(()=>d(f=>f-1),[]),isFocusedToastEscapeKeyDownRef:p,isClosePausedRef:m,children:i})})};Sg.displayName=Fl;var Cg="ToastViewport",RE=["F8"],zl="toast.viewportPause",Hl="toast.viewportResume",Tg=h.forwardRef((e,t)=>{const{__scopeToast:n,hotkey:r=RE,label:o="Notifications ({hotkey})",...s}=e,i=ii(Cg,n),a=_E(n),l=h.useRef(null),c=h.useRef(null),d=h.useRef(null),p=h.useRef(null),m=De(t,p,i.onViewportChange),f=r.join("+").replace(/Key/g,"").replace(/Digit/g,""),v=i.toastCount>0;h.useEffect(()=>{const x=y=>{var S;r.length!==0&&r.every(k=>y[k]||y.code===k)&&((S=p.current)==null||S.focus())};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[r]),h.useEffect(()=>{const x=l.current,y=p.current;if(v&&x&&y){const w=()=>{if(!i.isClosePausedRef.current){const T=new CustomEvent(zl);y.dispatchEvent(T),i.isClosePausedRef.current=!0}},S=()=>{if(i.isClosePausedRef.current){const T=new CustomEvent(Hl);y.dispatchEvent(T),i.isClosePausedRef.current=!1}},k=T=>{!x.contains(T.relatedTarget)&&S()},C=()=>{x.contains(document.activeElement)||S()};return x.addEventListener("focusin",w),x.addEventListener("focusout",k),x.addEventListener("pointermove",w),x.addEventListener("pointerleave",C),window.addEventListener("blur",w),window.addEventListener("focus",S),()=>{x.removeEventListener("focusin",w),x.removeEventListener("focusout",k),x.removeEventListener("pointermove",w),x.removeEventListener("pointerleave",C),window.removeEventListener("blur",w),window.removeEventListener("focus",S)}}},[v,i.isClosePausedRef]);const g=h.useCallback(({tabbingDirection:x})=>{const w=a().map(S=>{const k=S.ref.current,C=[k,...qE(k)];return x==="forwards"?C:C.reverse()});return(x==="forwards"?w.reverse():w).flat()},[a]);return h.useEffect(()=>{const x=p.current;if(x){const y=w=>{var C,T,E;const S=w.altKey||w.ctrlKey||w.metaKey;if(w.key==="Tab"&&!S){const _=document.activeElement,R=w.shiftKey;if(w.target===x&&R){(C=c.current)==null||C.focus();return}const K=g({tabbingDirection:R?"backwards":"forwards"}),F=K.findIndex(I=>I===_);Vl(K.slice(F+1))?w.preventDefault():R?(T=c.current)==null||T.focus():(E=d.current)==null||E.focus()}};return x.addEventListener("keydown",y),()=>x.removeEventListener("keydown",y)}},[a,g]),u.jsxs(Tw,{ref:l,role:"region","aria-label":o.replace("{hotkey}",f),tabIndex:-1,style:{pointerEvents:v?void 0:"none"},children:[v&&u.jsx(Ul,{ref:c,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"forwards"});Vl(x)}}),u.jsx(Bl.Slot,{scope:n,children:u.jsx(be.ol,{tabIndex:-1,...s,ref:m})}),v&&u.jsx(Ul,{ref:d,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"backwards"});Vl(x)}})]})});Tg.displayName=Cg;var kg="ToastFocusProxy",Ul=h.forwardRef((e,t)=>{const{__scopeToast:n,onFocusFromOutsideViewport:r,...o}=e,s=ii(kg,n);return u.jsx(Js,{tabIndex:0,...o,ref:t,style:{position:"fixed"},onFocus:i=>{var c;const a=i.relatedTarget;!((c=s.viewport)!=null&&c.contains(a))&&r()}})});Ul.displayName=kg;var Io="Toast",OE="toast.swipeStart",DE="toast.swipeMove",LE="toast.swipeCancel",$E="toast.swipeEnd",Eg=h.forwardRef((e,t)=>{const{forceMount:n,open:r,defaultOpen:o,onOpenChange:s,...i}=e,[a,l]=_n({prop:r,defaultProp:o??!0,onChange:s,caller:Io});return u.jsx(Ft,{present:n||a,children:u.jsx(zE,{open:a,...i,ref:t,onClose:()=>l(!1),onPause:mt(e.onPause),onResume:mt(e.onResume),onSwipeStart:ie(e.onSwipeStart,c=>{c.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:ie(e.onSwipeMove,c=>{const{x:d,y:p}=c.detail.delta;c.currentTarget.setAttribute("data-swipe","move"),c.currentTarget.style.setProperty("--radix-toast-swipe-move-x",`${d}px`),c.currentTarget.style.setProperty("--radix-toast-swipe-move-y",`${p}px`)}),onSwipeCancel:ie(e.onSwipeCancel,c=>{c.currentTarget.setAttribute("data-swipe","cancel"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),c.currentTarget.style.removeProperty("--radix-toast-swipe-end-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-end-y")}),onSwipeEnd:ie(e.onSwipeEnd,c=>{const{x:d,y:p}=c.detail.delta;c.currentTarget.setAttribute("data-swipe","end"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),c.currentTarget.style.setProperty("--radix-toast-swipe-end-x",`${d}px`),c.currentTarget.style.setProperty("--radix-toast-swipe-end-y",`${p}px`),l(!1)})})})});Eg.displayName=Io;var[FE,BE]=yg(Io,{onClose(){}}),zE=h.forwardRef((e,t)=>{const{__scopeToast:n,type:r="foreground",duration:o,open:s,onClose:i,onEscapeKeyDown:a,onPause:l,onResume:c,onSwipeStart:d,onSwipeMove:p,onSwipeCancel:m,onSwipeEnd:f,...v}=e,g=ii(Io,n),[x,y]=h.useState(null),w=De(t,I=>y(I)),S=h.useRef(null),k=h.useRef(null),C=o||g.duration,T=h.useRef(0),E=h.useRef(C),_=h.useRef(0),{onToastAdd:R,onToastRemove:L}=g,H=mt(()=>{var W;(x==null?void 0:x.contains(document.activeElement))&&((W=g.viewport)==null||W.focus()),i()}),K=h.useCallback(I=>{!I||I===1/0||(window.clearTimeout(_.current),T.current=new Date().getTime(),_.current=window.setTimeout(H,I))},[H]);h.useEffect(()=>{const I=g.viewport;if(I){const W=()=>{K(E.current),c==null||c()},N=()=>{const U=new Date().getTime()-T.current;E.current=E.current-U,window.clearTimeout(_.current),l==null||l()};return I.addEventListener(zl,N),I.addEventListener(Hl,W),()=>{I.removeEventListener(zl,N),I.removeEventListener(Hl,W)}}},[g.viewport,C,l,c,K]),h.useEffect(()=>{s&&!g.isClosePausedRef.current&&K(C)},[s,C,g.isClosePausedRef,K]),h.useEffect(()=>(R(),()=>L()),[R,L]);const F=h.useMemo(()=>x?Mg(x):null,[x]);return g.viewport?u.jsxs(u.Fragment,{children:[F&&u.jsx(HE,{__scopeToast:n,role:"status","aria-live":r==="foreground"?"assertive":"polite",children:F}),u.jsx(FE,{scope:n,onClose:H,children:Lr.createPortal(u.jsx(Bl.ItemSlot,{scope:n,children:u.jsx(Cw,{asChild:!0,onEscapeKeyDown:ie(a,()=>{g.isFocusedToastEscapeKeyDownRef.current||H(),g.isFocusedToastEscapeKeyDownRef.current=!1}),children:u.jsx(be.li,{tabIndex:0,"data-state":s?"open":"closed","data-swipe-direction":g.swipeDirection,...v,ref:w,style:{userSelect:"none",touchAction:"none",...e.style},onKeyDown:ie(e.onKeyDown,I=>{I.key==="Escape"&&(a==null||a(I.nativeEvent),I.nativeEvent.defaultPrevented||(g.isFocusedToastEscapeKeyDownRef.current=!0,H()))}),onPointerDown:ie(e.onPointerDown,I=>{I.button===0&&(S.current={x:I.clientX,y:I.clientY})}),onPointerMove:ie(e.onPointerMove,I=>{if(!S.current)return;const W=I.clientX-S.current.x,N=I.clientY-S.current.y,U=!!k.current,O=["left","right"].includes(g.swipeDirection),j=["left","up"].includes(g.swipeDirection)?Math.min:Math.max,q=O?j(0,W):0,J=O?0:j(0,N),P=I.pointerType==="touch"?10:2,M={x:q,y:J},G={originalEvent:I,delta:M};U?(k.current=M,ai(DE,p,G,{discrete:!1})):Rg(M,g.swipeDirection,P)?(k.current=M,ai(OE,d,G,{discrete:!1}),I.target.setPointerCapture(I.pointerId)):(Math.abs(W)>P||Math.abs(N)>P)&&(S.current=null)}),onPointerUp:ie(e.onPointerUp,I=>{const W=k.current,N=I.target;if(N.hasPointerCapture(I.pointerId)&&N.releasePointerCapture(I.pointerId),k.current=null,S.current=null,W){const U=I.currentTarget,O={originalEvent:I,delta:W};Rg(W,g.swipeDirection,g.swipeThreshold)?ai($E,f,O,{discrete:!0}):ai(LE,m,O,{discrete:!0}),U.addEventListener("click",j=>j.preventDefault(),{once:!0})}})})})}),g.viewport)})]}):null}),HE=e=>{const{__scopeToast:t,children:n,...r}=e,o=ii(Io,t),[s,i]=h.useState(!1),[a,l]=h.useState(!1);return VE(()=>i(!0)),h.useEffect(()=>{const c=window.setTimeout(()=>l(!0),1e3);return()=>window.clearTimeout(c)},[]),a?null:u.jsx(eo,{asChild:!0,children:u.jsx(Js,{...r,children:s&&u.jsxs(u.Fragment,{children:[o.label," ",n]})})})},UE="ToastTitle",Ig=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(be.div,{...r,ref:t})});Ig.displayName=UE;var WE="ToastDescription",Ng=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(be.div,{...r,ref:t})});Ng.displayName=WE;var Ag="ToastAction",jg=h.forwardRef((e,t)=>{const{altText:n,...r}=e;return n.trim()?u.jsx(Pg,{altText:n,asChild:!0,children:u.jsx(Wl,{...r,ref:t})}):(console.error(`Invalid prop \`altText\` supplied to \`${Ag}\`. Expected non-empty \`string\`.`),null)});jg.displayName=Ag;var _g="ToastClose",Wl=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e,o=BE(_g,n);return u.jsx(Pg,{asChild:!0,children:u.jsx(be.button,{type:"button",...r,ref:t,onClick:ie(e.onClick,o.onClose)})})});Wl.displayName=_g;var Pg=h.forwardRef((e,t)=>{const{__scopeToast:n,altText:r,...o}=e;return u.jsx(be.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":r||void 0,...o,ref:t})});function Mg(e){const t=[];return Array.from(e.childNodes).forEach(r=>{if(r.nodeType===r.TEXT_NODE&&r.textContent&&t.push(r.textContent),KE(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(...Mg(r))}}),t}function ai(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?Oi(o,s):o.dispatchEvent(s)}var Rg=(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 VE(e=()=>{}){const t=mt(e);kt(()=>{let n=0,r=0;return n=window.requestAnimationFrame(()=>r=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(n),window.cancelAnimationFrame(r)}},[t])}function KE(e){return e.nodeType===e.ELEMENT_NODE}function qE(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 Vl(e){const t=document.activeElement;return e.some(n=>n===t?!0:(n.focus(),document.activeElement!==t))}var GE=Sg,Og=Tg,Dg=Eg,Lg=Ig,$g=Ng,Fg=jg,Bg=Wl;const YE=GE,zg=h.forwardRef(({className:e,...t},n)=>u.jsx(Og,{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}));zg.displayName=Og.displayName;const XE=Dr.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"}}),Hg=h.forwardRef(({className:e,variant:t,...n},r)=>u.jsx(Dg,{ref:r,className:ne(XE({variant:t}),e),...n}));Hg.displayName=Dg.displayName;const JE=h.forwardRef(({className:e,...t},n)=>u.jsx(Fg,{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}));JE.displayName=Fg.displayName;const Ug=h.forwardRef(({className:e,...t},n)=>u.jsx(Bg,{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(ue.X,{className:"h-4 w-4"})}));Ug.displayName=Bg.displayName;const Wg=h.forwardRef(({className:e,...t},n)=>u.jsx(Lg,{ref:n,className:ne("text-sm font-semibold",e),...t}));Wg.displayName=Lg.displayName;const Vg=h.forwardRef(({className:e,...t},n)=>u.jsx($g,{ref:n,className:ne("text-sm opacity-90",e),...t}));Vg.displayName=$g.displayName;function ZE(){const{toasts:e}=Za();return u.jsxs(YE,{children:[e.map(function({id:t,title:n,description:r,action:o,...s}){return u.jsxs(Hg,{...s,children:[u.jsxs("div",{className:"grid gap-1",children:[n&&u.jsx(Wg,{children:n}),r&&u.jsx(Vg,{children:r})]}),o,u.jsx(Ug,{})]},t)}),u.jsx(zg,{})]})}var QE=(e,t,n,r,o,s,i,a)=>{let l=document.documentElement,c=["light","dark"];function d(f){(Array.isArray(e)?e:[e]).forEach(v=>{let g=v==="class",x=g&&s?o.map(y=>s[y]||y):o;g?(l.classList.remove(...x),l.classList.add(s&&s[f]?s[f]:f)):l.setAttribute(v,f)}),p(f)}function p(f){a&&c.includes(f)&&(l.style.colorScheme=f)}function m(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}if(r)d(r);else try{let f=localStorage.getItem(t)||n,v=i&&f==="system"?m():f;d(v)}catch{}},eI=h.createContext(void 0),tI={setTheme:e=>{},themes:[]},nI=()=>{var e;return(e=h.useContext(eI))!=null?e:tI};h.memo(({forcedTheme:e,storageKey:t,attribute:n,enableSystem:r,enableColorScheme:o,defaultTheme:s,value:i,themes:a,nonce:l,scriptProps:c})=>{let d=JSON.stringify([n,t,s,e,a,i,r,o]).slice(1,-1);return h.createElement("script",{...c,suppressHydrationWarning:!0,nonce:typeof window>"u"?l:"",dangerouslySetInnerHTML:{__html:`(${QE.toString()})(${d})`}})});var rI=e=>{switch(e){case"success":return iI;case"info":return lI;case"warning":return aI;case"error":return cI;default:return null}},oI=Array(12).fill(0),sI=({visible:e,className:t})=>b.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},b.createElement("div",{className:"sonner-spinner"},oI.map((n,r)=>b.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),iI=b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},b.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),aI=b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},b.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),lI=b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},b.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),cI=b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},b.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),uI=b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},b.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),b.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),dI=()=>{let[e,t]=b.useState(document.hidden);return b.useEffect(()=>{let n=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),e},Kl=1,fI=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:Kl++,s=this.toasts.find(a=>a.id===o),i=e.dismissible===void 0?!0:e.dismissible;return this.dismissedToasts.has(o)&&this.dismissedToasts.delete(o),s?this.toasts=this.toasts.map(a=>a.id===o?(this.publish({...a,...e,id:o,title:n}),{...a,...e,id:o,dismissible:i,title:n}):a):this.addToast({title:n,...r,dismissible:i,id:o}),o},this.dismiss=e=>(this.dismissedToasts.add(e),e||this.toasts.forEach(t=>{this.subscribers.forEach(n=>n({id:t.id,dismiss:!0}))}),this.subscribers.forEach(t=>t({id:e,dismiss:!0})),e),this.message=(e,t)=>this.create({...t,message:e}),this.error=(e,t)=>this.create({...t,message:e,type:"error"}),this.success=(e,t)=>this.create({...t,type:"success",message:e}),this.info=(e,t)=>this.create({...t,type:"info",message:e}),this.warning=(e,t)=>this.create({...t,type:"warning",message:e}),this.loading=(e,t)=>this.create({...t,type:"loading",message:e}),this.promise=(e,t)=>{if(!t)return;let n;t.loading!==void 0&&(n=this.create({...t,promise:e,type:"loading",message:t.loading,description:typeof t.description!="function"?t.description:void 0}));let r=e instanceof Promise?e:e(),o=n!==void 0,s,i=r.then(async l=>{if(s=["resolve",l],b.isValidElement(l))o=!1,this.create({id:n,type:"default",message:l});else if(hI(l)&&!l.ok){o=!1;let c=typeof t.error=="function"?await t.error(`HTTP error! status: ${l.status}`):t.error,d=typeof t.description=="function"?await t.description(`HTTP error! status: ${l.status}`):t.description;this.create({id:n,type:"error",message:c,description:d})}else if(t.success!==void 0){o=!1;let c=typeof t.success=="function"?await t.success(l):t.success,d=typeof t.description=="function"?await t.description(l):t.description;this.create({id:n,type:"success",message:c,description:d})}}).catch(async l=>{if(s=["reject",l],t.error!==void 0){o=!1;let c=typeof t.error=="function"?await t.error(l):t.error,d=typeof t.description=="function"?await t.description(l):t.description;this.create({id:n,type:"error",message:c,description:d})}}).finally(()=>{var l;o&&(this.dismiss(n),n=void 0),(l=t.finally)==null||l.call(t)}),a=()=>new Promise((l,c)=>i.then(()=>s[0]==="reject"?c(s[1]):l(s[1])).catch(c));return typeof n!="string"&&typeof n!="number"?{unwrap:a}:Object.assign(n,{unwrap:a})},this.custom=(e,t)=>{let n=(t==null?void 0:t.id)||Kl++;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}},Ht=new fI,pI=(e,t)=>{let n=(t==null?void 0:t.id)||Kl++;return Ht.addToast({title:e,...t,id:n}),n},hI=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",mI=pI,gI=()=>Ht.toasts,xI=()=>Ht.getActiveToasts();Object.assign(mI,{success:Ht.success,info:Ht.info,warning:Ht.warning,error:Ht.error,custom:Ht.custom,message:Ht.message,promise:Ht.promise,dismiss:Ht.dismiss,loading:Ht.loading},{getHistory:gI,getToasts:xI});function vI(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))}vI(`:where(html[dir="ltr"]),:where([data-sonner-toaster][dir="ltr"]){--toast-icon-margin-start: -3px;--toast-icon-margin-end: 4px;--toast-svg-margin-start: -1px;--toast-svg-margin-end: 0px;--toast-button-margin-start: auto;--toast-button-margin-end: 0;--toast-close-button-start: 0;--toast-close-button-end: unset;--toast-close-button-transform: translate(-35%, -35%)}:where(html[dir="rtl"]),:where([data-sonner-toaster][dir="rtl"]){--toast-icon-margin-start: 4px;--toast-icon-margin-end: -3px;--toast-svg-margin-start: 0px;--toast-svg-margin-end: -1px;--toast-button-margin-start: 0;--toast-button-margin-end: auto;--toast-close-button-start: unset;--toast-close-button-end: 0;--toast-close-button-transform: translate(35%, -35%)}:where([data-sonner-toaster]){position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1: hsl(0, 0%, 99%);--gray2: hsl(0, 0%, 97.3%);--gray3: hsl(0, 0%, 95.1%);--gray4: hsl(0, 0%, 93%);--gray5: hsl(0, 0%, 90.9%);--gray6: hsl(0, 0%, 88.7%);--gray7: hsl(0, 0%, 85.8%);--gray8: hsl(0, 0%, 78%);--gray9: hsl(0, 0%, 56.1%);--gray10: hsl(0, 0%, 52.3%);--gray11: hsl(0, 0%, 43.5%);--gray12: hsl(0, 0%, 9%);--border-radius: 8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:none;z-index:999999999;transition:transform .4s ease}:where([data-sonner-toaster][data-lifted="true"]){transform:translateY(-10px)}@media (hover: none) and (pointer: coarse){:where([data-sonner-toaster][data-lifted="true"]){transform:none}}:where([data-sonner-toaster][data-x-position="right"]){right:var(--offset-right)}:where([data-sonner-toaster][data-x-position="left"]){left:var(--offset-left)}:where([data-sonner-toaster][data-x-position="center"]){left:50%;transform:translate(-50%)}:where([data-sonner-toaster][data-y-position="top"]){top:var(--offset-top)}:where([data-sonner-toaster][data-y-position="bottom"]){bottom:var(--offset-bottom)}:where([data-sonner-toast]){--y: translateY(100%);--lift-amount: calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);filter:blur(0);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:none;overflow-wrap:anywhere}:where([data-sonner-toast][data-styled="true"]){padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px #0000001a;width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}:where([data-sonner-toast]:focus-visible){box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast][data-y-position="top"]){top:0;--y: translateY(-100%);--lift: 1;--lift-amount: calc(1 * var(--gap))}:where([data-sonner-toast][data-y-position="bottom"]){bottom:0;--y: translateY(100%);--lift: -1;--lift-amount: calc(var(--lift) * var(--gap))}:where([data-sonner-toast]) :where([data-description]){font-weight:400;line-height:1.4;color:inherit}:where([data-sonner-toast]) :where([data-title]){font-weight:500;line-height:1.5;color:inherit}:where([data-sonner-toast]) :where([data-icon]){display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}:where([data-sonner-toast][data-promise="true"]) :where([data-icon])>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}:where([data-sonner-toast]) :where([data-icon])>*{flex-shrink:0}:where([data-sonner-toast]) :where([data-icon]) svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}:where([data-sonner-toast]) :where([data-content]){display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;cursor:pointer;outline:none;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}:where([data-sonner-toast]) :where([data-button]):focus-visible{box-shadow:0 0 0 2px #0006}:where([data-sonner-toast]) :where([data-button]):first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}:where([data-sonner-toast]) :where([data-cancel]){color:var(--normal-text);background:rgba(0,0,0,.08)}:where([data-sonner-toast][data-theme="dark"]) :where([data-cancel]){background:rgba(255,255,255,.3)}:where([data-sonner-toast]) :where([data-close-button]){position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast] [data-close-button]{background:var(--gray1)}:where([data-sonner-toast]) :where([data-close-button]):focus-visible{box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast]) :where([data-disabled="true"]){cursor:not-allowed}:where([data-sonner-toast]):hover :where([data-close-button]):hover{background:var(--gray2);border-color:var(--gray5)}:where([data-sonner-toast][data-swiping="true"]):before{content:"";position:absolute;left:-50%;right:-50%;height:100%;z-index:-1}:where([data-sonner-toast][data-y-position="top"][data-swiping="true"]):before{bottom:50%;transform:scaleY(3) translateY(50%)}:where([data-sonner-toast][data-y-position="bottom"][data-swiping="true"]):before{top:50%;transform:scaleY(3) translateY(-50%)}:where([data-sonner-toast][data-swiping="false"][data-removed="true"]):before{content:"";position:absolute;inset:0;transform:scaleY(2)}:where([data-sonner-toast]):after{content:"";position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}:where([data-sonner-toast][data-mounted="true"]){--y: translateY(0);opacity:1}:where([data-sonner-toast][data-expanded="false"][data-front="false"]){--scale: var(--toasts-before) * .05 + 1;--y: translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}:where([data-sonner-toast])>*{transition:opacity .4s}:where([data-sonner-toast][data-expanded="false"][data-front="false"][data-styled="true"])>*{opacity:0}:where([data-sonner-toast][data-visible="false"]){opacity:0;pointer-events:none}:where([data-sonner-toast][data-mounted="true"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}:where([data-sonner-toast][data-removed="true"][data-front="true"][data-swipe-out="false"]){--y: translateY(calc(var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="false"]){--y: translateY(40%);opacity:0;transition:transform .5s,opacity .2s}:where([data-sonner-toast][data-removed="true"][data-front="false"]):before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y, 0px)) translate(var(--swipe-amount-x, 0px));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width: 600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-theme=light]{--normal-bg: #fff;--normal-border: var(--gray4);--normal-text: var(--gray12);--success-bg: hsl(143, 85%, 96%);--success-border: hsl(145, 92%, 91%);--success-text: hsl(140, 100%, 27%);--info-bg: hsl(208, 100%, 97%);--info-border: hsl(221, 91%, 91%);--info-text: hsl(210, 92%, 45%);--warning-bg: hsl(49, 100%, 97%);--warning-border: hsl(49, 91%, 91%);--warning-text: hsl(31, 92%, 45%);--error-bg: hsl(359, 100%, 97%);--error-border: hsl(359, 100%, 94%);--error-text: hsl(360, 100%, 45%)}[data-sonner-toaster][data-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg: #000;--normal-border: hsl(0, 0%, 20%);--normal-text: var(--gray1)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg: #fff;--normal-border: var(--gray3);--normal-text: var(--gray12)}[data-sonner-toaster][data-theme=dark]{--normal-bg: #000;--normal-bg-hover: hsl(0, 0%, 12%);--normal-border: hsl(0, 0%, 20%);--normal-border-hover: hsl(0, 0%, 25%);--normal-text: var(--gray1);--success-bg: hsl(150, 100%, 6%);--success-border: hsl(147, 100%, 12%);--success-text: hsl(150, 86%, 65%);--info-bg: hsl(215, 100%, 6%);--info-border: hsl(223, 100%, 12%);--info-text: hsl(216, 87%, 65%);--warning-bg: hsl(64, 100%, 6%);--warning-border: hsl(60, 100%, 12%);--warning-text: hsl(46, 87%, 65%);--error-bg: hsl(358, 76%, 10%);--error-border: hsl(357, 89%, 16%);--error-text: hsl(358, 100%, 81%)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success],[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info],[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning],[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error],[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size: 16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:nth-child(1){animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}to{opacity:.15}}@media (prefers-reduced-motion){[data-sonner-toast],[data-sonner-toast]>*,.sonner-loading-bar{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}
130
- `);function li(e){return e.label!==void 0}var wI=3,bI="32px",yI="16px",Kg=4e3,SI=356,CI=14,TI=20,kI=200;function pn(...e){return e.filter(Boolean).join(" ")}function EI(e){let[t,n]=e.split("-"),r=[];return t&&r.push(t),n&&r.push(n),r}var II=e=>{var t,n,r,o,s,i,a,l,c,d,p;let{invert:m,toast:f,unstyled:v,interacting:g,setHeights:x,visibleToasts:y,heights:w,index:S,toasts:k,expanded:C,removeToast:T,defaultRichColors:E,closeButton:_,style:R,cancelButtonStyle:L,actionButtonStyle:H,className:K="",descriptionClassName:F="",duration:I,position:W,gap:N,loadingIcon:U,expandByDefault:O,classNames:j,icons:q,closeButtonAriaLabel:J="Close toast",pauseWhenPageIsHidden:P}=e,[M,G]=b.useState(null),[Z,se]=b.useState(null),[V,D]=b.useState(!1),[X,Q]=b.useState(!1),[ae,$]=b.useState(!1),[re,we]=b.useState(!1),[de,xe]=b.useState(!1),[Ee,Be]=b.useState(0),[We,je]=b.useState(0),Ve=b.useRef(f.duration||I||Kg),Xe=b.useRef(null),ze=b.useRef(null),Ge=S===0,rt=S+1<=y,nt=f.type,et=f.dismissible!==!1,xt=f.className||"",vt=f.descriptionClassName||"",dt=b.useMemo(()=>w.findIndex(Ce=>Ce.toastId===f.id)||0,[w,f.id]),Et=b.useMemo(()=>{var Ce;return(Ce=f.closeButton)!=null?Ce:_},[f.closeButton,_]),Dt=b.useMemo(()=>f.duration||I||Kg,[f.duration,I]),$e=b.useRef(0),Pt=b.useRef(0),nn=b.useRef(0),Me=b.useRef(null),[Ke,Ct]=W.split("-"),Ze=b.useMemo(()=>w.reduce((Ce,Oe,qe)=>qe>=dt?Ce:Ce+Oe.height,0),[w,dt]),pt=dI(),le=f.invert||m,Y=nt==="loading";Pt.current=b.useMemo(()=>dt*N+Ze,[dt,Ze]),b.useEffect(()=>{Ve.current=Dt},[Dt]),b.useEffect(()=>{D(!0)},[]),b.useEffect(()=>{let Ce=ze.current;if(Ce){let Oe=Ce.getBoundingClientRect().height;return je(Oe),x(qe=>[{toastId:f.id,height:Oe,position:f.position},...qe]),()=>x(qe=>qe.filter(Tt=>Tt.toastId!==f.id))}},[x,f.id]),b.useLayoutEffect(()=>{if(!V)return;let Ce=ze.current,Oe=Ce.style.height;Ce.style.height="auto";let qe=Ce.getBoundingClientRect().height;Ce.style.height=Oe,je(qe),x(Tt=>Tt.find(He=>He.toastId===f.id)?Tt.map(He=>He.toastId===f.id?{...He,height:qe}:He):[{toastId:f.id,height:qe,position:f.position},...Tt])},[V,f.title,f.description,x,f.id]);let ge=b.useCallback(()=>{Q(!0),Be(Pt.current),x(Ce=>Ce.filter(Oe=>Oe.toastId!==f.id)),setTimeout(()=>{T(f)},kI)},[f,T,x,Pt]);b.useEffect(()=>{if(f.promise&&nt==="loading"||f.duration===1/0||f.type==="loading")return;let Ce;return C||g||P&&pt?(()=>{if(nn.current<$e.current){let Oe=new Date().getTime()-$e.current;Ve.current=Ve.current-Oe}nn.current=new Date().getTime()})():Ve.current!==1/0&&($e.current=new Date().getTime(),Ce=setTimeout(()=>{var Oe;(Oe=f.onAutoClose)==null||Oe.call(f,f),ge()},Ve.current)),()=>clearTimeout(Ce)},[C,g,f,nt,P,pt,ge]),b.useEffect(()=>{f.delete&&ge()},[ge,f.delete]);function it(){var Ce,Oe,qe;return q!=null&&q.loading?b.createElement("div",{className:pn(j==null?void 0:j.loader,(Ce=f==null?void 0:f.classNames)==null?void 0:Ce.loader,"sonner-loader"),"data-visible":nt==="loading"},q.loading):U?b.createElement("div",{className:pn(j==null?void 0:j.loader,(Oe=f==null?void 0:f.classNames)==null?void 0:Oe.loader,"sonner-loader"),"data-visible":nt==="loading"},U):b.createElement(sI,{className:pn(j==null?void 0:j.loader,(qe=f==null?void 0:f.classNames)==null?void 0:qe.loader),visible:nt==="loading"})}return b.createElement("li",{tabIndex:0,ref:ze,className:pn(K,xt,j==null?void 0:j.toast,(t=f==null?void 0:f.classNames)==null?void 0:t.toast,j==null?void 0:j.default,j==null?void 0:j[nt],(n=f==null?void 0:f.classNames)==null?void 0:n[nt]),"data-sonner-toast":"","data-rich-colors":(r=f.richColors)!=null?r:E,"data-styled":!(f.jsx||f.unstyled||v),"data-mounted":V,"data-promise":!!f.promise,"data-swiped":de,"data-removed":X,"data-visible":rt,"data-y-position":Ke,"data-x-position":Ct,"data-index":S,"data-front":Ge,"data-swiping":ae,"data-dismissible":et,"data-type":nt,"data-invert":le,"data-swipe-out":re,"data-swipe-direction":Z,"data-expanded":!!(C||O&&V),style:{"--index":S,"--toasts-before":S,"--z-index":k.length-S,"--offset":`${X?Ee:Pt.current}px`,"--initial-height":O?"auto":`${We}px`,...R,...f.style},onDragEnd:()=>{$(!1),G(null),Me.current=null},onPointerDown:Ce=>{Y||!et||(Xe.current=new Date,Be(Pt.current),Ce.target.setPointerCapture(Ce.pointerId),Ce.target.tagName!=="BUTTON"&&($(!0),Me.current={x:Ce.clientX,y:Ce.clientY}))},onPointerUp:()=>{var Ce,Oe,qe,Tt;if(re||!et)return;Me.current=null;let He=Number(((Ce=ze.current)==null?void 0:Ce.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),ft=Number(((Oe=ze.current)==null?void 0:Oe.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),Fe=new Date().getTime()-((qe=Xe.current)==null?void 0:qe.getTime()),tt=M==="x"?He:ft,Ut=Math.abs(tt)/Fe;if(Math.abs(tt)>=TI||Ut>.11){Be(Pt.current),(Tt=f.onDismiss)==null||Tt.call(f,f),se(M==="x"?He>0?"right":"left":ft>0?"down":"up"),ge(),we(!0),xe(!1);return}$(!1),G(null)},onPointerMove:Ce=>{var Oe,qe,Tt,He;if(!Me.current||!et||((Oe=window.getSelection())==null?void 0:Oe.toString().length)>0)return;let ft=Ce.clientY-Me.current.y,Fe=Ce.clientX-Me.current.x,tt=(qe=e.swipeDirections)!=null?qe:EI(W);!M&&(Math.abs(Fe)>1||Math.abs(ft)>1)&&G(Math.abs(Fe)>Math.abs(ft)?"x":"y");let Ut={x:0,y:0};M==="y"?(tt.includes("top")||tt.includes("bottom"))&&(tt.includes("top")&&ft<0||tt.includes("bottom")&&ft>0)&&(Ut.y=ft):M==="x"&&(tt.includes("left")||tt.includes("right"))&&(tt.includes("left")&&Fe<0||tt.includes("right")&&Fe>0)&&(Ut.x=Fe),(Math.abs(Ut.x)>0||Math.abs(Ut.y)>0)&&xe(!0),(Tt=ze.current)==null||Tt.style.setProperty("--swipe-amount-x",`${Ut.x}px`),(He=ze.current)==null||He.style.setProperty("--swipe-amount-y",`${Ut.y}px`)}},Et&&!f.jsx?b.createElement("button",{"aria-label":J,"data-disabled":Y,"data-close-button":!0,onClick:Y||!et?()=>{}:()=>{var Ce;ge(),(Ce=f.onDismiss)==null||Ce.call(f,f)},className:pn(j==null?void 0:j.closeButton,(o=f==null?void 0:f.classNames)==null?void 0:o.closeButton)},(s=q==null?void 0:q.close)!=null?s:uI):null,f.jsx||b.isValidElement(f.title)?f.jsx?f.jsx:typeof f.title=="function"?f.title():f.title:b.createElement(b.Fragment,null,nt||f.icon||f.promise?b.createElement("div",{"data-icon":"",className:pn(j==null?void 0:j.icon,(i=f==null?void 0:f.classNames)==null?void 0:i.icon)},f.promise||f.type==="loading"&&!f.icon?f.icon||it():null,f.type!=="loading"?f.icon||(q==null?void 0:q[nt])||rI(nt):null):null,b.createElement("div",{"data-content":"",className:pn(j==null?void 0:j.content,(a=f==null?void 0:f.classNames)==null?void 0:a.content)},b.createElement("div",{"data-title":"",className:pn(j==null?void 0:j.title,(l=f==null?void 0:f.classNames)==null?void 0:l.title)},typeof f.title=="function"?f.title():f.title),f.description?b.createElement("div",{"data-description":"",className:pn(F,vt,j==null?void 0:j.description,(c=f==null?void 0:f.classNames)==null?void 0:c.description)},typeof f.description=="function"?f.description():f.description):null),b.isValidElement(f.cancel)?f.cancel:f.cancel&&li(f.cancel)?b.createElement("button",{"data-button":!0,"data-cancel":!0,style:f.cancelButtonStyle||L,onClick:Ce=>{var Oe,qe;li(f.cancel)&&et&&((qe=(Oe=f.cancel).onClick)==null||qe.call(Oe,Ce),ge())},className:pn(j==null?void 0:j.cancelButton,(d=f==null?void 0:f.classNames)==null?void 0:d.cancelButton)},f.cancel.label):null,b.isValidElement(f.action)?f.action:f.action&&li(f.action)?b.createElement("button",{"data-button":!0,"data-action":!0,style:f.actionButtonStyle||H,onClick:Ce=>{var Oe,qe;li(f.action)&&((qe=(Oe=f.action).onClick)==null||qe.call(Oe,Ce),!Ce.defaultPrevented&&ge())},className:pn(j==null?void 0:j.actionButton,(p=f==null?void 0:f.classNames)==null?void 0:p.actionButton)},f.action.label):null))};function qg(){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 NI(e,t){let n={};return[e,t].forEach((r,o)=>{let s=o===1,i=s?"--mobile-offset":"--offset",a=s?yI:bI;function l(c){["top","right","bottom","left"].forEach(d=>{n[`${i}-${d}`]=typeof c=="number"?`${c}px`:c})}typeof r=="number"||typeof r=="string"?l(r):typeof r=="object"?["top","right","bottom","left"].forEach(c=>{r[c]===void 0?n[`${i}-${c}`]=a:n[`${i}-${c}`]=typeof r[c]=="number"?`${r[c]}px`:r[c]}):l(a)}),n}var AI=b.forwardRef(function(e,t){let{invert:n,position:r="bottom-right",hotkey:o=["altKey","KeyT"],expand:s,closeButton:i,className:a,offset:l,mobileOffset:c,theme:d="light",richColors:p,duration:m,style:f,visibleToasts:v=wI,toastOptions:g,dir:x=qg(),gap:y=CI,loadingIcon:w,icons:S,containerAriaLabel:k="Notifications",pauseWhenPageIsHidden:C}=e,[T,E]=b.useState([]),_=b.useMemo(()=>Array.from(new Set([r].concat(T.filter(P=>P.position).map(P=>P.position)))),[T,r]),[R,L]=b.useState([]),[H,K]=b.useState(!1),[F,I]=b.useState(!1),[W,N]=b.useState(d!=="system"?d:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),U=b.useRef(null),O=o.join("+").replace(/Key/g,"").replace(/Digit/g,""),j=b.useRef(null),q=b.useRef(!1),J=b.useCallback(P=>{E(M=>{var G;return(G=M.find(Z=>Z.id===P.id))!=null&&G.delete||Ht.dismiss(P.id),M.filter(({id:Z})=>Z!==P.id)})},[]);return b.useEffect(()=>Ht.subscribe(P=>{if(P.dismiss){E(M=>M.map(G=>G.id===P.id?{...G,delete:!0}:G));return}setTimeout(()=>{No.flushSync(()=>{E(M=>{let G=M.findIndex(Z=>Z.id===P.id);return G!==-1?[...M.slice(0,G),{...M[G],...P},...M.slice(G+1)]:[P,...M]})})})}),[]),b.useEffect(()=>{if(d!=="system"){N(d);return}if(d==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?N("dark"):N("light")),typeof window>"u")return;let P=window.matchMedia("(prefers-color-scheme: dark)");try{P.addEventListener("change",({matches:M})=>{N(M?"dark":"light")})}catch{P.addListener(({matches:G})=>{try{N(G?"dark":"light")}catch(Z){console.error(Z)}})}},[d]),b.useEffect(()=>{T.length<=1&&K(!1)},[T]),b.useEffect(()=>{let P=M=>{var G,Z;o.every(se=>M[se]||M.code===se)&&(K(!0),(G=U.current)==null||G.focus()),M.code==="Escape"&&(document.activeElement===U.current||(Z=U.current)!=null&&Z.contains(document.activeElement))&&K(!1)};return document.addEventListener("keydown",P),()=>document.removeEventListener("keydown",P)},[o]),b.useEffect(()=>{if(U.current)return()=>{j.current&&(j.current.focus({preventScroll:!0}),j.current=null,q.current=!1)}},[U.current]),b.createElement("section",{ref:t,"aria-label":`${k} ${O}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},_.map((P,M)=>{var G;let[Z,se]=P.split("-");return T.length?b.createElement("ol",{key:P,dir:x==="auto"?qg():x,tabIndex:-1,ref:U,className:a,"data-sonner-toaster":!0,"data-theme":W,"data-y-position":Z,"data-lifted":H&&T.length>1&&!s,"data-x-position":se,style:{"--front-toast-height":`${((G=R[0])==null?void 0:G.height)||0}px`,"--width":`${SI}px`,"--gap":`${y}px`,...f,...NI(l,c)},onBlur:V=>{q.current&&!V.currentTarget.contains(V.relatedTarget)&&(q.current=!1,j.current&&(j.current.focus({preventScroll:!0}),j.current=null))},onFocus:V=>{V.target instanceof HTMLElement&&V.target.dataset.dismissible==="false"||q.current||(q.current=!0,j.current=V.relatedTarget)},onMouseEnter:()=>K(!0),onMouseMove:()=>K(!0),onMouseLeave:()=>{F||K(!1)},onDragEnd:()=>K(!1),onPointerDown:V=>{V.target instanceof HTMLElement&&V.target.dataset.dismissible==="false"||I(!0)},onPointerUp:()=>I(!1)},T.filter(V=>!V.position&&M===0||V.position===P).map((V,D)=>{var X,Q;return b.createElement(II,{key:V.id,icons:S,index:D,toast:V,defaultRichColors:p,duration:(X=g==null?void 0:g.duration)!=null?X: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:F,position:P,style:g==null?void 0:g.style,unstyled:g==null?void 0:g.unstyled,classNames:g==null?void 0:g.classNames,cancelButtonStyle:g==null?void 0:g.cancelButtonStyle,actionButtonStyle:g==null?void 0:g.actionButtonStyle,removeToast:J,toasts:T.filter(ae=>ae.position==V.position),heights:R.filter(ae=>ae.position==V.position),setHeights:L,expandByDefault:s,gap:y,loadingIcon:w,expanded:H,pauseWhenPageIsHidden:C,swipeDirections:e.swipeDirections})})):null}))});const jI=({...e})=>{const{theme:t="system"}=nI();return u.jsx(AI,{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})};B.Api=Av,B.ApiClient=Nv,B.ApiProvider=nu,B.ArtifactRenderer=wh,B.Badge=Lp,B.Button=at,B.Card=tl,B.CardContent=sl,B.CardDescription=ol,B.CardHeader=nl,B.CardTitle=rl,B.ChatApi=Ho,B.ChatApp=pk,B.ChatInput=$f,B.ChatInterface=So,B.ChatProviders=Xr,B.Command=gl,B.CommandEmpty=wl,B.CommandGroup=bl,B.CommandInput=xl,B.CommandItem=yl,B.CommandList=vl,B.DEFAULT_TIMEOUT_MS=Xc,B.Dialog=Ya,B.DialogContent=Ds,B.DialogHeader=Ls,B.DialogTitle=$s,B.DropdownMenu=vs,B.DropdownMenuContent=ao,B.DropdownMenuItem=On,B.DropdownMenuTrigger=ws,B.FileViewerModal=rh,B.HISTORY_TIMEOUT_MS=Jc,B.Input=Nl,B.InterruptPartRenderer=yh,B.Label=am,B.MarkdownContent=Ar,B.MessageBody=Eh,B.MessageComponent=Vs,B.MessageList=cl,B.MessageRow=ll,B.PlotArtifact=xh,B.ResearchTaskArtifact=vh,B.SETTINGS_STORAGE_KEY=Ri,B.ScrollArea=Il,B.Select=qk,B.SelectContent=Gm,B.SelectItem=Ym,B.SelectTrigger=Vm,B.SelectValue=Gk,B.Separator=Qm,B.Sheet=sE,B.SheetContent=lg,B.SheetDescription=dg,B.SheetHeader=cg,B.SheetTitle=ug,B.SheetTrigger=iE,B.SimpleChat=hk,B.SimpleJsonView=il,B.Sonner=jI,B.StreamProgress=Sh,B.Switch=ig,B.Textarea=ba,B.ThinkingIndicator=Th,B.ThreadListItem=tm,B.ThreadManager=Al,B.ThreadStateProvider=Cu,B.ThreadsProvider=lu,B.TimelineColumn=sx,B.Toaster=ZE,B.ToolComponent=Ch,B.Tooltip=AE,B.TooltipContent=bg,B.TooltipProvider=NE,B.TooltipTrigger=jE,B.UserTextContent=kh,B.applySettings=aw,B.buildAttemptMaps=Ql,B.buildCheckpointIndex=tc,B.buildCheckpointPreviewMap=Qg,B.chatApiClient=An,B.del=ki,B.downloadFileById=Qc,B.extractConfigFields=di,B.fileToBase64=ru,B.get=qt,B.getChatToken=Gc,B.getCurrentSettings=iw,B.getDefaultApiConfig=Au,B.getDefaultChatSettings=ju,B.getFileContent=Ii,B.getFileInfo=_v,B.getMessageDomKey=al,B.getPreviewForMessage=ui,B.httpClient=Kt,B.hydrateHistorySnapshots=Nn,B.isEnvelope=su,B.listFiles=eu,B.loadStoredSettings=_u,B.onChatTokenChanged=Yc,B.post=zo,B.processAttachments=ou,B.put=Zc,B.readNumber=rc,B.readString=Vn,B.resolveChatBaseUrl=mn,B.resolveMessageMetadata=Jl,B.saveSettings=Pu,B.setChatToken=Bo,B.toPlainObject=cr,B.unwrap=Mt,B.useApi=Vr,B.useCheckpointIndex=nc,B.useFilePreview=Ih,B.useHasChatSession=ow,B.useMessageMetadata=Zl,B.useStream=Mi,B.useStreamingHook=Mi,B.useThreadHistoryState=wu,B.useThreadManagerViewState=om,B.useThreadState=Yr,B.useThreadStateUpdater=Su,B.useThreads=pr,B.useThreadsState=iu,B.viewFileById=jv,Object.defineProperty(B,Symbol.toStringTag,{value:"Module"})});
127
+ `+(f.tokens?this.parseInline(f.tokens):f.text);r+=n?this.renderer.paragraph(m):m;continue}default:{const _='Token with "'+f.type+'" type was not found.';if(this.options.silent){console.error(_);return}else throw new Error(_)}}}return r}parseInline(t,n){n=n||this.renderer;let r="",o,s,i;const a=t.length;for(o=0;o<a;o++){if(s=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[s.type]&&(i=this.options.extensions.renderers[s.type].call({parser:this},s),i!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type))){r+=i||"";continue}switch(s.type){case"escape":{r+=n.text(s.text);break}case"html":{r+=n.html(s.text);break}case"link":{r+=n.link(s.href,s.title,this.parseInline(s.tokens,n));break}case"image":{r+=n.image(s.href,s.title,s.text);break}case"strong":{r+=n.strong(this.parseInline(s.tokens,n));break}case"em":{r+=n.em(this.parseInline(s.tokens,n));break}case"codespan":{r+=n.codespan(s.text);break}case"br":{r+=n.br();break}case"del":{r+=n.del(this.parseInline(s.tokens,n));break}case"text":{r+=n.text(s.text);break}default:{const l='Token with "'+s.type+'" type was not found.';if(this.options.silent){console.error(l);return}else throw new Error(l)}}}return r}}class Ws{constructor(t){this.options=t||or}preprocess(t){return t}postprocess(t){return t}}Yg(Ws,"passThroughHooks",new Set(["preprocess","postprocess"]));function yT(e,t,n){return r=>{if(r.message+=`
128
+ Please report this to https://github.com/markedjs/marked.`,e){const o="<p>An error occurred:</p><pre>"+_t(r.message+"",!0)+"</pre>";if(t)return Promise.resolve(o);if(n){n(null,o);return}return o}if(t)return Promise.reject(r);if(n){n(r);return}throw r}}function gh(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...Se.defaults,...s};const i=yT(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(vT(r),r.hooks&&(r.hooks.options=r),o){const a=r.highlight;let l;try{r.hooks&&(n=r.hooks.preprocess(n)),l=e(n,r)}catch(p){return i(p)}const c=function(p){let m;if(!p)try{r.walkTokens&&Se.walkTokens(l,r.walkTokens),m=t(l,r),r.hooks&&(m=r.hooks.postprocess(m))}catch(f){p=f}return r.highlight=a,p?i(p):o(null,m)};if(!a||a.length<3||(delete r.highlight,!l.length))return c();let d=0;Se.walkTokens(l,function(p){p.type==="code"&&(d++,setTimeout(()=>{a(p.text,p.lang,function(m,f){if(m)return c(m);f!=null&&f!==p.text&&(p.text=f,p.escaped=!0),d--,d===0&&c()})},0))}),d===0&&c();return}if(r.async)return Promise.resolve(r.hooks?r.hooks.preprocess(n):n).then(a=>e(a,r)).then(a=>r.walkTokens?Promise.all(Se.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&&Se.walkTokens(a,r.walkTokens);let l=t(a,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(a){return i(a)}}}function Se(e,t,n){return gh(Bn.lex,zn.parse)(e,t,n)}Se.options=Se.setOptions=function(e){return Se.defaults={...Se.defaults,...e},sT(Se.defaults),Se},Se.getDefaults=oh,Se.defaults=or,Se.use=function(...e){const t=Se.defaults.extensions||{renderers:{},childTokens:{}};e.forEach(n=>{const r={...n};if(r.async=Se.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=Se.defaults.renderer||new el;for(const s in n.renderer){const i=o[s];o[s]=(...a)=>{let l=n.renderer[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.renderer=o}if(n.tokenizer){const o=Se.defaults.tokenizer||new Qa;for(const s in n.tokenizer){const i=o[s];o[s]=(...a)=>{let l=n.tokenizer[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.tokenizer=o}if(n.hooks){const o=Se.defaults.hooks||new Ws;for(const s in n.hooks){const i=o[s];Ws.passThroughHooks.has(s)?o[s]=a=>{if(Se.defaults.async)return Promise.resolve(n.hooks[s].call(o,a)).then(c=>i.call(o,c));const l=n.hooks[s].call(o,a);return i.call(o,l)}:o[s]=(...a)=>{let l=n.hooks[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.hooks=o}if(n.walkTokens){const o=Se.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}}Se.setOptions(r)})},Se.walkTokens=function(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(Se,r)),r.type){case"table":{for(const o of r.header)n=n.concat(Se.walkTokens(o.tokens,t));for(const o of r.rows)for(const s of o)n=n.concat(Se.walkTokens(s.tokens,t));break}case"list":{n=n.concat(Se.walkTokens(r.items,t));break}default:Se.defaults.extensions&&Se.defaults.extensions.childTokens&&Se.defaults.extensions.childTokens[r.type]?Se.defaults.extensions.childTokens[r.type].forEach(function(o){n=n.concat(Se.walkTokens(r[o],t))}):r.tokens&&(n=n.concat(Se.walkTokens(r.tokens,t)))}return n},Se.parseInline=gh(Bn.lexInline,zn.parseInline),Se.Parser=zn,Se.parser=zn.parse,Se.Renderer=el,Se.TextRenderer=hh,Se.Lexer=Bn,Se.lexer=Bn.lex,Se.Tokenizer=Qa,Se.Slugger=mh,Se.Hooks=Ws,Se.parse=Se,Se.options,Se.setOptions,Se.use,Se.walkTokens,Se.parseInline,zn.parse,Bn.lex;function Ar({content:e,className:t="",allowHtml:n=!1,style:r}){const o=b.useMemo(()=>{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 Se.parse=="function"?Se.parse(i):Se(i)}return typeof Se.parse=="function"?Se.parse(e):Se(e)}catch(i){return console.error("[MarkdownContent] parse error",i),`<pre class="font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words">Error rendering markdown: ${String(i)}</pre>`}},[e,n]),s=b.useMemo(()=>{const i={color:"currentColor",...r};if(r&&r.color){const a=r.color;return{...i,"--tw-prose-body":a,"--tw-prose-headings":a,"--tw-prose-links":a,"--tw-prose-bold":a,"--tw-prose-counters":a,"--tw-prose-bullets":a,"--tw-prose-hr":a,"--tw-prose-quotes":a,"--tw-prose-quote-borders":a,"--tw-prose-captions":a,"--tw-prose-code":a,"--tw-prose-pre-code":a,"--tw-prose-pre-bg":"inherit","--tw-prose-th-borders":a,"--tw-prose-td-borders":a}}return i},[r]);return u.jsx("div",{className: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 xh({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 vh({artifact:e}){const[t,n]=b.useState("bg-yellow-500/20 text-yellow-700 dark:text-yellow-300"),[r,o]=b.useState(u.jsx(ue.Clock,{className:"w-4 h-4"})),[s,i]=b.useState("Processing");return b.useEffect(()=>{switch(e.status||"processing"){case"completed":n("bg-green-500/20 text-green-700 dark:text-green-300"),o(u.jsx(ue.CheckCircle,{className:"w-4 h-4"})),i("Completed");break;case"failed":n("bg-red-500/20 text-red-700 dark:text-red-300"),o(u.jsx(ue.ExternalLink,{className:"w-4 h-4 rotate-45"})),i("Failed");break;case"pending":n("bg-blue-500/20 text-blue-700 dark:text-blue-300"),o(u.jsx(ue.Clock,{className:"w-4 h-4"})),i("Pending");break;default:n("bg-yellow-500/20 text-yellow-700 dark:text-yellow-300"),o(u.jsx(ue.Clock,{className:"w-4 h-4"})),i("Processing")}},[e.status]),u.jsxs("div",{className:"rounded-lg border border-blue-200 dark:border-blue-900/50 bg-blue-50 dark:bg-blue-950/20 p-4 space-y-3",children:[u.jsxs("div",{className:"flex items-start gap-3",children:[u.jsx("div",{className:"mt-1 flex-shrink-0",children:u.jsx(ue.Search,{className:"w-5 h-5 text-blue-600 dark:text-blue-400"})}),u.jsxs("div",{className:"flex-1 min-w-0",children:[u.jsx("h3",{className:"font-semibold text-blue-900 dark:text-blue-100",children:"Research Task"}),u.jsxs("p",{className:"text-sm text-blue-700 dark:text-blue-300 mt-1",children:["Task ID: ",u.jsxs("code",{className:"font-mono text-xs bg-blue-100 dark:bg-blue-900/30 px-2 py-1 rounded",children:[e.task_id.slice(0,8),"..."]})]})]})]}),u.jsxs("div",{className:`inline-flex items-center gap-2 px-3 py-1 rounded-full text-sm font-medium ${t}`,children:[r,u.jsx("span",{children:s})]}),e.query&&u.jsxs("div",{className:"text-sm text-blue-800 dark:text-blue-200 bg-white dark:bg-blue-900/30 rounded px-3 py-2",children:[u.jsx("p",{className:"font-medium text-xs text-blue-600 dark:text-blue-400 mb-1",children:"Query:"}),u.jsx("p",{className:"line-clamp-2",children:e.query})]}),typeof e.results=="string"&&e.results.trim()&&u.jsxs("div",{className:"text-sm text-blue-900 dark:text-blue-100 bg-white dark:bg-blue-900/30 rounded px-3 py-2 space-y-2",children:[u.jsx("p",{className:"font-semibold text-xs text-blue-600 dark:text-blue-400",children:"Results:"}),u.jsx(Ar,{content:e.results,allowHtml:!1,className:"prose text-xs !prose-sm prose-blue dark:prose-invert"})]}),e.progress_url&&u.jsx("div",{className:"pt-2",children:u.jsxs("a",{href:e.progress_url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white dark:bg-blue-700 dark:hover:bg-blue-600 rounded-md text-sm font-medium transition-colors",children:[u.jsx("span",{children:"Monitor Progress"}),u.jsx(ue.ExternalLink,{className:"w-3.5 h-3.5"})]})}),e.createdAt&&u.jsxs("p",{className:"text-xs text-blue-600 dark:text-blue-400",children:["Started: ",new Date(e.createdAt).toLocaleTimeString()]})]})}function wh({artifact:e,idx:t=0}){const n=b.useMemo(()=>e?(Array.isArray(e.plots)?e.plots:[]).map(o=>Wv(o)).filter(o=>o!==null):[],[e]);return(e==null?void 0:e.type)==="research_task_info"?u.jsx(vh,{artifact:{type:"research_task_info",task_id:e.task_id,progress_url:e.progress_url,query:e.query,status:e.status,createdAt:e.createdAt}}):n.length>0?u.jsx("div",{className:"space-y-2",children:n.map((r,o)=>u.jsx(xh,{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 tl=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}));tl.displayName="Card";const nl=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:ne("flex flex-col space-y-1.5 p-6",e),...t}));nl.displayName="CardHeader";const rl=h.forwardRef(({className:e,...t},n)=>u.jsx("h3",{ref:n,className:ne("text-2xl font-semibold leading-none tracking-tight",e),...t}));rl.displayName="CardTitle";const ol=h.forwardRef(({className:e,...t},n)=>u.jsx("p",{ref:n,className:ne("text-sm text-muted-foreground",e),...t}));ol.displayName="CardDescription";const sl=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:ne("p-6 pt-0",e),...t}));sl.displayName="CardContent";const bh=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:ne("flex items-center p-6 pt-0",e),...t}));bh.displayName="CardFooter";function yh({interruptPart:e,onApprove:t,onReject:n,disabled:r,isActive:o,payload:s}){const i=e.title??"Approve the result?";let a=null;if(s!=null)if(typeof s=="string")a=u.jsx("p",{className:"text-sm leading-relaxed text-blue-800/90 dark:text-blue-200/90 whitespace-pre-wrap",children:s});else{const c=hr(s);a=u.jsx("pre",{className:"max-h-48 overflow-auto rounded bg-blue-100/60 p-2 text-xs text-blue-900/90 dark:bg-blue-900/40 dark:text-blue-100/80",children:c})}const l=o?"Please approve or reject this action to resume the workflow.":"Waiting for approval from another participant.";return u.jsxs(tl,{className:ne("border-blue-200 dark:border-blue-800 bg-blue-50/50 dark:bg-blue-950/10 transition-shadow",o?"shadow-md ring-1 ring-blue-300 dark:ring-blue-500/70":"opacity-80"),children:[u.jsxs(nl,{className:"pb-3",children:[u.jsx(rl,{className:"text-blue-900 dark:text-blue-100 text-base",children:i}),u.jsx(ol,{className:"text-blue-700 dark:text-blue-300 text-sm",children:l})]}),a&&u.jsx(sl,{className:"pt-0 pb-3",children:a}),u.jsx(bh,{className:"pt-0",children:u.jsxs("div",{className:"flex gap-2 ml-auto",children:[u.jsx(at,{size:"sm",variant:"outline",onClick:()=>n(e),className:"border-red-300 text-red-700 hover:bg-red-50 dark:border-red-700 dark:text-red-300 dark:hover:bg-red-950/50",disabled:r||!o,children:"Reject"}),u.jsx(at,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",disabled:r||!o,children:"Approve"})]})})]})}const ST="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 il({data:e}){return Array.isArray(e)?e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?u.jsx("div",{className:ST,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:hr(e)}):u.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:hr(e)})}function Sh({message:e,isStreaming:t=!1}){const n=e.name??"tool",r=b.useMemo(()=>{const a=e.additionalKwargs??{};return Array.isArray(a.toolProgress)?[...a.toolProgress]:[]},[e]),s=r.some(a=>a.type==="tool.start"||a.type==="tool.call"||a.type==="message.start")?`Running ${n}…`:void 0;return t||r.length>0?u.jsxs("div",{className:"space-y-2",children:[u.jsxs("div",{className:"flex items-center gap-2 text-xs uppercase tracking-wide text-muted-foreground",children:[t&&u.jsx(ue.Loader,{className:"h-3 w-3 animate-spin"}),u.jsx("span",{children:s??`Running ${n}…`})]}),r.length>0&&u.jsx("div",{className:"space-y-2 text-xs text-muted-foreground",children:r.map((a,l)=>{var c;return u.jsxs("div",{className:"rounded border border-current/10 bg-muted/60 p-2 text-[11px] leading-snug",children:[u.jsxs("div",{className:"mb-1 flex items-center justify-between text-[8px] uppercase tracking-wide text-muted-foreground",children:[u.jsx("span",{children:((c=a.type)==null?void 0:c.replace(/\./g," "))??"progress"}),u.jsx("span",{children:a.idx??l+1})]}),a.content&&u.jsx("p",{className:"mt-1 text-[12px] text-foreground/90",children:a.content}),u.jsxs("div",{className:"mt-1 flex flex-wrap gap-2 text-[10px] opacity-70",children:[typeof a.factsFound=="number"&&u.jsxs("span",{children:["Facts found: ",a.factsFound]}),typeof a.isSufficient=="boolean"&&u.jsxs("span",{children:["Research ",a.isSufficient?"sufficient":"needs more data"]})]})]},`tool-progress-${n}-${l}`)})})]}):null}function Ch({message:e,viewMode:t,isStreaming:n=!1}){const o=Ai(e).name||"tool",s=l=>{if(l==null)return null;const c=typeof l=="string"?Ni(l)??l:l;if(c&&typeof c=="object")return u.jsx(il,{data:c});const d=typeof c=="string"?c:(()=>{try{return hr(c)}catch{return String(c??"")}})();return u.jsx("pre",{className:"whitespace-pre-wrap break-words font-sans text-sm text-foreground/90",children:d})},i=l=>{if(l==null)return null;const{content:c,isMarkdown:d}=Lv(l);return d?u.jsx(Ar,{content:c,className:"text-current"}):s(l)},a=()=>{const l=e.content.find(p=>p.type!=="tool_call");if(!l)return u.jsx("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:u.jsxs("span",{children:["Running ",o,"…"]})});if(l.type==="text"){const m=(l.text??"").trim();if(!m)return null;const f=qr(m);return i(f)}const c=Kr(l),d=qr(c);return i(d)};return u.jsxs("div",{className:"space-y-2",children:[u.jsx(Sh,{message:e,isStreaming:n}),t==="expanded"&&a()]})}function Th({className:e}){const[t,n]=b.useState(0);return b.useEffect(()=>{const r=setInterval(()=>n(o=>(o+1)%4),500);return()=>clearInterval(r)},[]),u.jsxs("span",{"aria-live":"polite",className:ne("inline-block text-xs opacity-70 ml-1",e),children:["Is thinking",".".repeat(t)]})}function kh({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(Ar,{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(at,{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(ue.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):u.jsxs(u.Fragment,{children:[u.jsx(ue.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",s," chars)"]})})]})}function Eh({message:e,isToolMessage:t,showToolMessages:n,artifactToRender:r,toolViewMode:o,isToolStreaming:s,contentParts:i,textContent:a,imageParts:l,fileParts:c,interruptParts:d,isStreamingMessage:p,defaultMessage:m,handleFileClick:f,uploadingFiles:v,handleInterruptApprove:g,handleInterruptReject:x,disableInterruptActions:y,messageRole:w,truncateUserMessages:S,userMessagePreviewLength:k,isUserExpanded:C,setIsUserExpanded:T,isCompactLayout:E,activeInterruptId:_,activeInterruptValue:R,iconForeground:L}){const H=b.useCallback(()=>u.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/30 rounded",children:[u.jsx(ue.Paperclip,{className:"h-4 w-4 text-muted-foreground"}),u.jsx("span",{className:"text-sm text-muted-foreground",children:"File upload"})]}),[]),K=b.useCallback(({part:I,i:W})=>{if(I.type==="text"){const N=I.text??"",U=N.trim(),O=Ni(U);return O&&w!=="tool"?u.jsx(il,{data:O},W):w==="user"&&S&&U.length>k?u.jsx(kh,{text:U,expanded:C,onExpandedChange:T,previewLength:k,isCompact:E},W):u.jsx(Ar,{content:N,allowHtml:!1},W)}if(I.type==="image_url"){const N=I;return u.jsx("div",{className:"my-2",children:u.jsx("img",{src:N.url,alt:N.alt??"",loading:"lazy",className:"border rounded max-h-[420px] w-auto object-contain"})},W)}if(I.type==="file"){const N=I,U=N.name||"file";return u.jsxs("a",{href:N.url,onClick:O=>f(O.nativeEvent,N,W),className:`inline-flex items-center gap-2 rounded px-2 py-1 text-xs bg-gray-100 border hover:bg-gray-200
129
+ dark:bg-background/10 dark:border-border/30 dark:hover:bg-background/20`,children:[v[W]?u.jsx(ue.Loader,{className:"h-4 w-4 animate-spin"}):null,u.jsxs("span",{className:"truncate max-w-[180px]",children:[U,v[W]?" (processing)":""]})]},W)}if(I.type==="interrupt"){const N=I,U=Wo((N==null?void 0:N.id)??(N==null?void 0:N.interrupt_id)),O=!!(_&&U&&U===_),j=O?R??(N==null?void 0:N.value):N==null?void 0:N.value,q=U?{...N,id:U,interrupt_id:U}:N;return u.jsx(yh,{interruptPart:q,onApprove:g,onReject:x,disabled:y,isActive:O,payload:j},W)}return null},[f,v,g,x,w,S,k,C,E,_,R,y]),B=a.trim().length>0||l.length>0||c.length>0||d.length>0;if(!t&&c.length>0&&!p)return H();if(!t&&!B&&!p)return null;if(t)return!n&&r?null:n?u.jsx(Ch,{message:e,viewMode:o,isStreaming:s},e.id):null;if(!m){const I=u.jsx("div",{className:"space-y-2",children:i.map((W,N)=>u.jsx(K,{part:W,i:N},N))});return p?u.jsxs("div",{"aria-busy":"true",role:"status",children:[I,u.jsx(Th,{className:L})]}):I}return null}function Ih(e){const{allowFileOpen:t,currentThreadId:n}=e,{toast:r}=Za(),[o,s]=b.useState({}),[i,a]=b.useState(null),[l,c]=b.useState(!1),d=b.useCallback(()=>{c(!1),a(null)},[]),p=b.useCallback(f=>{a(f),c(!0)},[]),m=b.useCallback(async(f,v,g)=>{var x,y;if(!t){f.preventDefault();return}if(o[g]){f.preventDefault();return}try{const w=String(v.url??""),S=w.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);if(S){f.preventDefault();const k=S[1],C=v.name||`file_${k}`,T=v.mimeType||"application/octet-stream";p({id:k,name:C,mimeType:T});return}if(w.startsWith("data:")){f.preventDefault(),s(C=>({...C,[g]:!0}));const k=r({title:"Fetching file...",description:"",open:!0});try{const C=await eu(n??void 0);if(!C||!Array.isArray(C))throw new Error("Invalid file list response");const T=C.find(E=>!E||typeof E!="object"||!((E.filename??"")===(v.name??""))?!1:typeof v.size=="number"&&typeof E.size=="number"?E.size===v.size:!0);if(!(T!=null&&T.id))throw new Error(`File "${v.name}" is not yet available on the server`);if(!T.id||!T.filename)throw new Error("Invalid file data received from server");p({id:T.id,name:v.name||T.filename||`file_${T.id}`,mimeType:v.mimeType||T.mime_type||"application/octet-stream"}),(x=k.update)==null||x.call(k,{id:k.id,title:"Success",description:`Opened ${v.name}`,open:!0})}catch(C){console.error("Failed to fetch server file:",C);const T=C instanceof Error?C.message:"Unknown error occurred";(y=k.update)==null||y.call(k,{id:k.id,title:"Failed",description:T}),r({title:"Failed to fetch file",description:T,open:!0})}finally{s(C=>({...C,[g]:!1}))}}}catch(w){console.error("File click error:",w),s(S=>({...S,[g]:!1}))}},[t,o,r,n,p]);return{uploadingFiles:o,handleFileClick:m,fileViewerOpen:l,currentFileInfo:i,closeFileViewer:d}}function Nh(e,t){return b.useMemo(()=>{if(t)return{contentParts:[],textContent:"",toolMeta:{},imageParts:[],fileParts:[],interruptParts:[],toolRaw:"",isToolStreaming:!1};const n=e,r=Array.isArray(n.content)?n.content:[],o=n.additionalKwargs??{};return{contentParts:r,textContent:$v(r),toolMeta:Ai(n),imageParts:r.filter(s=>s.type==="image_url"),fileParts:r.filter(s=>s.type==="file"),interruptParts:r.filter(s=>s.type==="interrupt"),toolRaw:Fv(r),isToolStreaming:!!o.toolStreaming}},[e,t])}const Vs=b.memo(function({message:t,messageIndex:n,isStreamingMessage:r=!1,isEditing:o=!1,showActions:s=!0,showTimestamp:i=!0,showAgentName:a=!0,layoutSize:l="desktop",truncateUserMessages:c=!0,userMessagePreviewLength:d=500,showToolMessages:p=!0,showArtifactPreviews:m=!0,customStyles:f={},onEdit:v,onRegenerate:g,onCancelEdit:x,onCopy:y,activeInterrupt:w,disableInterruptActions:S=!1,onInterruptActionStart:k,onInterruptActionEnd:C,checkpointCandidates:T=[],activeCheckpointId:E=null,onSelectCheckpoint:_,defaultCheckpointId:R=null,messageParentCheckpointId:L=null}){const[H,K]=b.useState(!1),[B,I]=b.useState("preview"),[W,N]=b.useState(!1),{currentThreadId:U}=pr(),{respondToInterrupt:O}=Yr(),j=l==="phone"||l==="half-screen",q=t.role,J=q==="tool",P=b.useMemo(()=>"type"in t&&t.type==="default_message"?t:null,[t]),M=!!P,G=!(r&&q!=="user"),{uploadingFiles:Z,handleFileClick:se,fileViewerOpen:V,currentFileInfo:D,closeFileViewer:X}=Ih({allowFileOpen:G,currentThreadId:U}),Q=b.useMemo(()=>{switch(q){case"user":return"text-[hsl(var(--chat-bubble-user-text))]";case"assistant":return"text-[hsl(var(--chat-bubble-ai-text))]";case"tool":return"text-secondary-foreground";case"system":return"text-muted-foreground";default:return"text-[hsl(var(--chat-bubble-ai-text))]"}},[q]),ae=Nh(t,P),{contentParts:$,imageParts:re,fileParts:we,interruptParts:de,textContent:xe,toolMeta:Ee,toolRaw:Be,isToolStreaming:We}=ae,je=(w==null?void 0:w.id)??(w==null?void 0:w.interrupt_id),Ve=Wo(je),Xe=w==null?void 0:w.value,ze=b.useMemo(()=>P||!m?null:t.artifact||null,[P,t,m]),Ge=b.useCallback(async()=>{const le=J?Be:xe;async function Y(ge){if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function"){await navigator.clipboard.writeText(ge);return}if(navigator.clipboard&&typeof navigator.clipboard.write=="function"&&typeof ClipboardItem<"u"){const it=new Blob([ge],{type:"text/plain"});await navigator.clipboard.write([new ClipboardItem({"text/plain":it})]);return}throw new Error("Clipboard API not supported in this context.")}try{await Y(le),K(!0),setTimeout(()=>K(!1),2e3),y==null||y(le)}catch(ge){console.error("Failed to copy:",ge)}},[J,Be,xe,y]),rt=b.useCallback(()=>{if(!v||!t.id)return;const le=(J?Be:xe)??"",Y="type"in t&&t.type==="default_message"?void 0:{checkpointId:t.checkpointId??null,checkpointNs:t.checkpointNs??null};v(t.id,le,Y)},[v,t.id,J,Be,xe,t]),nt=b.useCallback(()=>{g==null||g(n)},[g,n]),et=b.useCallback(()=>{const Y=ne(j?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",Q);switch(q){case"user":return u.jsx(ue.User,{className:Y});case"assistant":return u.jsx(ue.Bot,{className:Y});case"tool":return u.jsx(ue.Wrench,{className:Y});default:return u.jsx(ue.Bot,{className:Y})}},[j,Q,q]),xt=b.useCallback(()=>{const le="group relative mb-4 flex w-full";switch(q){case"user":return ne(le,"justify-end");case"assistant":case"tool":case"system":return ne(le,"justify-start");default:return le}},[q]),vt=b.useCallback(()=>{const le=ne("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",j&&"px-3 py-2 text-sm");if(M)return ne(le,"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(q){case"user":return ne(le,"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(le,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40");case"tool":return ne(le,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return ne(le,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return ne(le,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40")}},[j,M,q]),dt=b.useCallback(async le=>{if(S)return;const Y=Wo((le==null?void 0:le.id)??(le==null?void 0:le.interrupt_id));if(!Y){console.warn("Interrupt part missing id",le);return}try{k==null||k(),await O(Y,!0)}catch(ge){console.error("Failed to approve interrupt:",ge)}finally{C==null||C()}},[S,C,k,O]),Et=b.useCallback(async le=>{if(S)return;const Y=Wo((le==null?void 0:le.id)??(le==null?void 0:le.interrupt_id));if(!Y){console.warn("Interrupt part missing id",le);return}try{k==null||k(),await O(Y,!1)}catch(ge){console.error("Failed to reject interrupt:",ge)}finally{C==null||C()}},[S,C,k,O]),Dt=b.useMemo(()=>P?"Assistant":Bv(t),[P,t]),$e=b.useMemo(()=>P?[]:Array.isArray(T)?T:[],[T,P]),Pt=b.useMemo(()=>{var le;return $e.length?R&&$e.some(Y=>Y.id===R)?R:((le=$e[0])==null?void 0:le.id)??null:null},[R,$e]),Me=b.useMemo(()=>!$e.length||!E?null:$e.some(le=>le.id===E)?E:null,[E,$e])??Pt,Ke=q==="user"&&$e.length>0&&typeof _=="function",Ct=b.useCallback((le,Y=!1)=>{if(!_)return;const ge=(le==null?void 0:le.id)??null,it=(le==null?void 0:le.parentId)??L??null;_(ge,it,Y)},[L,_]),Ze=b.useMemo(()=>Me?$e.findIndex(le=>le.id===Me):-1,[Me,$e]),pt=b.useMemo(()=>Ze<0?null:$e[Ze]??null,[Ze,$e]);return J&&!p&&!ze?null:M&&P?u.jsx("div",{className:ne(xt(),f.container),children:u.jsxs("div",{className:ne(vt(),f.content),children:[u.jsxs("div",{className:"flex items-center gap-2 mb-2 pb-2 border-b border-current/10",children:[u.jsx(ue.Bot,{className:ne("h-4 w-4",Q)}),a&&u.jsx("span",{className:"font-medium text-sm",children:"Assistant"})]}),u.jsx(Ar,{content:P.content,className:"text-current"})]})}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:ne(xt(),f.container),children:u.jsxs("div",{className:ne(vt(),f.content),children:[(i||a||J)&&u.jsxs("div",{className:ne("flex items-center justify-between mb-2 pb-2 border-b border-current/10",j&&"mb-1 pb-1",Q,f.header),children:[u.jsxs("div",{className:"flex items-center gap-2",children:[et(),a&&Dt&&u.jsx("span",{className:ne("font-medium",j?"text-xs":"text-sm"),children:Dt}),J&&u.jsxs(Lp,{variant:"outline",className:ne("text-xs flex items-center gap-1 cursor-pointer select-none",Q,"border border-current/40",j&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":B==="expanded",onClick:()=>I(le=>le==="expanded"?"preview":"expanded"),onKeyDown:le=>{(le.key==="Enter"||le.key===" ")&&(le.preventDefault(),I(Y=>Y==="expanded"?"preview":"expanded"))},children:[u.jsx("span",{children:Ee.name??"Tool Output"}),Ee.toolCallId&&u.jsx("span",{className:"opacity-70",children:Ee.toolCallId.slice(0,8)}),B==="expanded"?u.jsx(ue.ChevronUp,{className:"h-3 w-3"}):u.jsx(ue.ChevronDown,{className:"h-3 w-3"})]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[Ke&&pt&&Ze>=0&&u.jsx("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("button",{type:"button",className:ne("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",Ze<$e.length-1?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{if(Ze>=$e.length-1)return;const le=$e[Ze+1];le&&Ct(le)},"aria-label":"Older checkpoint (back in time)",disabled:Ze>=$e.length-1,children:u.jsx(ue.ChevronLeft,{className:"h-3 w-3"})}),u.jsx("div",{className:"flex items-center gap-2",children:u.jsxs("span",{className:"whitespace-nowrap",children:[$e.length-Ze," / ",$e.length]})}),u.jsx("button",{type:"button",className:ne("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",Ze>0?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{if(!(Ze<=0))if(Ze===1)Ct(null,!0);else{const le=$e[Ze-1];le&&Ct(le,!1)}},"aria-label":"Newer checkpoint (forward in time)",disabled:Ze<=0,children:u.jsx(ue.ChevronRight,{className:"h-3 w-3"})})]})}),i&&t.createdAt&&u.jsx("time",{className:ne("text-xs opacity-60",Q,j&&"text-xs"),dateTime:new Date(t.createdAt).toISOString(),title:new Date(t.createdAt).toLocaleString(),children:new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(new Date(t.createdAt))}),s&&!o&&u.jsxs("div",{className:ne("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",f.actions),children:[u.jsx("div",{className:"relative",children:u.jsx(at,{variant:"ghost",size:"sm",onClick:()=>Ge(),className:ne("h-6 w-6 p-0 hover:bg-foreground/10",Q,j&&"h-5 w-5"),"aria-label":"Copy message",title:"Copy message",children:u.jsx(ue.Copy,{className:ne(H?"text-success":Q,j?"h-3 w-3":"h-4 w-4")})})}),q==="user"&&v&&u.jsx(at,{variant:"ghost",size:"sm",onClick:rt,className:ne("h-6 w-6 p-0 hover:bg-foreground/10",Q,j&&"h-5 w-5"),"aria-label":"Edit message",children:u.jsx(ue.Edit,{className:ne(Q,j?"h-3 w-3":"h-4 w-4")})}),q==="assistant"&&g&&u.jsx(at,{variant:"ghost",size:"sm",onClick:nt,className:ne("h-6 w-6 p-0 hover:bg-foreground/10",Q,j&&"h-5 w-5"),"aria-label":"Regenerate response",children:u.jsx(ue.RotateCcw,{className:ne(Q,j?"h-3 w-3":"h-4 w-4")})})]})]})]}),u.jsxs("div",{className:"relative",children:[u.jsx(Eh,{message:t,isToolMessage:J,showToolMessages:p,artifactToRender:ze,toolViewMode:B,isToolStreaming:We,contentParts:$,textContent:xe,imageParts:re,fileParts:we,interruptParts:de,isStreamingMessage:r,defaultMessage:P,handleFileClick:se,uploadingFiles:Z,handleInterruptApprove:dt,handleInterruptReject:Et,disableInterruptActions:S,messageRole:q,truncateUserMessages:c,userMessagePreviewLength:d,isUserExpanded:W,setIsUserExpanded:N,isCompactLayout:j,activeInterruptId:Ve,activeInterruptValue:Xe,iconForeground:Q}),m&&ze&&u.jsx("div",{className:"mt-3",children:u.jsx(wh,{artifact:ze,idx:0})})]}),J&&B==="expanded"&&(Ee.toolCallId||Ee.name)&&u.jsxs("div",{className:ne("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",j&&"text-xs"),children:[Ee.name&&u.jsxs("div",{children:["Function: ",Ee.name]}),Ee.toolCallId&&u.jsxs("div",{children:["Call ID: ",Ee.toolCallId]})]}),!(i||a||J)&&s&&!o&&u.jsxs("div",{className:ne("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",f.actions),children:[u.jsx(at,{variant:"ghost",size:"sm",onClick:()=>Ge(),className:ne("h-6 w-6 p-0 hover:bg-background/50 text-current",j&&"h-5 w-5"),children:u.jsx(ue.Copy,{className:ne(H?"text-success":"text-current",j?"h-3 w-3":"h-4 w-4")})}),q==="user"&&v&&u.jsx(at,{variant:"ghost",size:"sm",onClick:rt,className:ne("h-6 w-6 p-0 hover:bg-background/50 text-current",j&&"h-5 w-5"),children:u.jsx(ue.Edit,{className:ne("text-current",j?"h-3 w-3":"h-4 w-4")})}),q==="assistant"&&g&&u.jsx(at,{variant:"ghost",size:"sm",onClick:nt,className:ne("h-6 w-6 p-0 hover:bg-background/50 text-current",j&&"h-5 w-5"),children:u.jsx(ue.RotateCcw,{className:ne("text-current",j?"h-3 w-3":"h-4 w-4")})})]})]})}),D&&u.jsx(rh,{isOpen:V,onClose:X,fileId:D.id,fileName:D.name,mimeType:D.mimeType})]})},(e,t)=>{var l,c,d,p,m,f,v,g;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&uu(e.message)===uu(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateUserMessages","userMessagePreviewLength","showToolMessages"].every(x=>e[x]===t[x]),s=((l=e.customStyles)==null?void 0:l.container)===((c=t.customStyles)==null?void 0:c.container)&&((d=e.customStyles)==null?void 0:d.content)===((p=t.customStyles)==null?void 0:p.content)&&((m=e.customStyles)==null?void 0:m.actions)===((f=t.customStyles)==null?void 0:f.actions)&&((v=e.customStyles)==null?void 0:v.header)===((g=t.customStyles)==null?void 0:g.header);if(!o||!s)return!1;const i=du(e.message),a=du(t.message);return i.length===a.length});Vs.displayName="MessageComponent";const al=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,ll=b.memo(function({message:t,index:n,isStreaming:r,streamingAssistantId:o,streamingDebounceMs:s,layoutSize:i,enableMessageEditing:a,editingMessageId:l,onEdit:c,onRegenerate:d,onCancelEdit:p,activeInterrupt:m,disableInterruptActions:f,onInterruptActionStart:v,onInterruptActionEnd:g,showToolMessages:x,showArtifactPreviews:y,checkpointIndex:w,activeCheckpointId:S,onSelectCheckpoint:k}){const C=al(t,n),T="type"in t&&t.type==="default_message",_=!!t.__syntheticStreaming,{checkpointCandidates:R,defaultCheckpointId:L}=Zl(t,w??{checkpoints:[],checkpointMetaById:new Map,checkpointIndexByKey:new Map,attemptMetaById:new Map,userMessageIdToAttempts:new Map,timeline:[],messagePreviews:new Map,getLatest:()=>{},getCheckpoint:()=>{},getAttempts:()=>[]}),H=t&&!T?t.additionalKwargs??{}:{},K=t&&!T?t.responseMetadata??{}:{},B=(()=>{if(typeof H.parentCheckpointId=="string")return H.parentCheckpointId;if(typeof K.parentCheckpointId=="string")return K.parentCheckpointId})();return u.jsx("div",{className:"relative mb-4 last:mb-0","data-message-id":C,style:{minHeight:"60px",containIntrinsicSize:"auto 120px"},children:u.jsx(Vs,{message:t,messageIndex:n,isStreamingMessage:_||r&&o===t.id,streamingDebounceMs:s,isEditing:l===t.id,showActions:a,showTimestamp:!1,showAgentName:!0,layoutSize:i,onEdit:c,onRegenerate:()=>d(n),onCancelEdit:p,activeInterrupt:m,disableInterruptActions:f,onInterruptActionStart:v,onInterruptActionEnd:g,showToolMessages:x,showArtifactPreviews:y,checkpointCandidates:R,activeCheckpointId:S??null,onSelectCheckpoint:k,defaultCheckpointId:L,messageParentCheckpointId:B})})});ll.displayName="MessageRow";const cl=b.forwardRef(({messages:e,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onStartReached:a,onEdit:l,onRegenerate:c,onCancelEdit:d,className:p,style:m,emptyMessage:f,followNewMessages:v=!0,isNavigatingCheckpoint:g=!1,onScrollAway:x,onAtBottom:y,activeInterrupt:w,disableInterruptActions:S=!1,onInterruptActionStart:k,onInterruptActionEnd:C,showToolMessages:T=!0,showArtifactPreviews:E=!0,checkpointIndex:_,activeCheckpointId:R,onSelectCheckpoint:L,createSyntheticThinkingMessage:H=!0},K)=>{const B=b.useRef(null),I=b.useRef(null),W=b.useRef(!1),N=b.useRef(!1),[U,O]=b.useState(!0),j=b.useMemo(()=>w?e.some($=>"type"in $&&$.type==="default_message"?!1:Array.isArray($==null?void 0:$.content)&&$.content.some(re=>re&&re.type==="interrupt"&&(re.id??re.interrupt_id)===w.id)):!1,[w,e]),q=b.useMemo(()=>{if(!w||j)return null;const $=w.id&&String(w.id).trim()?String(w.id).trim():"pending-interrupt";let re;const we=w.value;if(we&&typeof we=="object"&&!Array.isArray(we)){const de=we.title;typeof de=="string"&&de.trim()&&(re=de.trim())}return{id:`interrupt-${$}`,role:"system",createdAt:new Date().toISOString(),content:[{type:"interrupt",id:$,value:we,title:re}]}},[w,j]),J=b.useMemo(()=>q?[...e,q]:e,[e,q]),P=b.useMemo(()=>!H||!t?J:!J.some(re=>re.role==="assistant")&&J.length>0?[...J,{id:"thinking-assistant",role:"assistant",content:[],createdAt:new Date().toISOString(),__syntheticStreaming:!0}]:J,[J,t,H]),M=b.useMemo(()=>T?P:P.filter($=>($==null?void 0:$.role)!=="tool"),[P,T]),G=b.useCallback($=>{O($),x&&x(!$),y&&y($)},[x,y]),Z=b.useMemo(()=>{if(a)return async()=>{if(!W.current){W.current=!0;try{await a()}finally{W.current=!1}}}},[a]),se=b.useMemo(()=>!v||g?!1:U?"auto":!1,[U,v,g]),V=b.useMemo(()=>{if(typeof f!="string")return null;const $=f.trim();return $?{id:"default-message",role:"assistant",type:"default_message",content:$,createdAt:new Date().toISOString()}:null},[f]),D=["flex h-full flex-col md:flex-row",p].filter(Boolean).join(" "),X=()=>V?u.jsx("div",{className:"p-6 h-full overflow-y-auto",children:u.jsx("div",{className:"w-full max-w-full",children:u.jsx(Vs,{message:V,messageIndex:0,isStreamingMessage:!1,showActions:!1,showTimestamp:!1,showAgentName:!0,layoutSize:o,onEdit:()=>{},onRegenerate:()=>{},onCancelEdit:()=>{},showArtifactPreviews:E})})}):u.jsx("div",{className:"flex h-full items-center justify-center py-8 text-center text-muted-foreground",children:f??"No messages yet. Start a conversation!"}),Q=M.length,ae=Q>0;return b.useEffect(()=>{var $,re;if(Q===0){N.current=!1;return}if(!N.current)if(N.current=!0,B.current&&M.length>0){const we=M.length-1;(re=($=B.current).scrollToIndex)==null||re.call($,{index:we,align:"end",behavior:"auto"})}else I.current&&(I.current.scrollTop=I.current.scrollHeight)},[Q,M.length]),b.useImperativeHandle(K,()=>({scrollToLatest:()=>{var $,re;if(B.current&&M.length>0){const we=M.length-1;(re=($=B.current).scrollToIndex)==null||re.call($,{index:we,align:"end",behavior:"auto"})}else I.current&&(I.current.scrollTop=I.current.scrollHeight)},scrollToTop:()=>{var $,re;B.current&&M.length>0?(re=($=B.current).scrollToIndex)==null||re.call($,{index:0,align:"start",behavior:"auto"}):I.current&&(I.current.scrollTop=0)}}),[M]),u.jsx("div",{className:D,style:m,children:u.jsx("div",{className:"relative flex-1 min-h-0",children:ae?u.jsx(EC,{ref:$=>{B.current=$},scrollerRef:$=>{I.current=$ instanceof HTMLDivElement?$:null},data:M,followOutput:se,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,startReached:()=>{Z&&Z()},atBottomStateChange:G,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:($,re)=>al(re,$),itemContent:($,re)=>u.jsx(ll,{message:re,index:$,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onEdit:l,onRegenerate:c,onCancelEdit:d,activeInterrupt:w,disableInterruptActions:S,onInterruptActionStart:k,onInterruptActionEnd:C,showToolMessages:T,showArtifactPreviews:E,checkpointIndex:_,activeCheckpointId:R,onSelectCheckpoint:L})}):X()})})});cl.displayName="MessageList";const Ah={value:""};function So({className:e="",placeholder:t="Type your message...",autoFocus:n=!0,maxHeight:r=void 0,streamingDebounceMs:o=500,streamingThrottleMs:s,followNewMessages:i=!0,enableFileUpload:a=!0,enableExcelUpload:l=!1,enableMessageEditing:c=!0,showToolMessages:d=!0,showArtifactPreviews:p=!0,customStyles:m={},onMessageSent:f,onExcelUploadSuccess:v,onError:g}){const{api:x}=Vr(),{currentThreadId:y}=pr(),{threadId:w,messages:S,isHistoryLoading:k,isLoading:C,navigateToCheckpoint:T,returnToLatest:E,checkpoint:_,checkpoints:R,interrupt:L,metadata:H,checkpointIndex:K}=Yr(),{isStreaming:B,error:I,connectionState:W,submit:N,stop:U}=Mi(),O=w??y??null,j=(_==null?void 0:_.id)??null,q=(_==null?void 0:_.namespace)??null,J=(H==null?void 0:H.assemblingMessageId)??null,P=L,[M,G]=b.useState(!1);b.useEffect(()=>{P||G(!1)},[P]);const Z=b.useCallback(()=>{G(!0)},[]),se=b.useCallback(()=>{G(!1)},[]),V=!!P||M,[D,X]=b.useState(null),[Q,ae]=b.useState(""),[$,re]=b.useState(null),[we,de]=b.useState(null),[xe,Ee]=b.useState([]),[Be,We]=b.useState(0),[je,Ve]=b.useState(0),[Xe,ze]=b.useState(!1),[Ge,rt]=b.useState(null),[nt,et]=b.useState(null),[xt,vt]=b.useState(!1),[dt,Et]=b.useState(null),Dt=b.useRef(!1),[$e,Pt]=b.useState(()=>Ah.value),nn=b.useRef($e),Me=b.useRef(null),Ke=b.useCallback(ce=>{Ah.value=ce,Pt(ce)},[]),[Ct,Ze]=b.useState(!1),pt=b.useRef(null),le=b.useRef(null),Y=b.useRef(null),ge=b.useCallback(()=>{le.current&&(le.current.value=""),Y.current&&(Y.current.value=""),We(ce=>ce+1),Ve(ce=>ce+1)},[]),it=b.useCallback(ce=>{Ke(ce)},[Ke]),Ce=b.useRef(!1);b.useEffect(()=>{Ce.current&&!B&&(Ee([]),ge()),Ce.current=B},[B,ge]);const[Oe,qe]=b.useState("desktop");b.useEffect(()=>{const ce=()=>{const ve=window.innerWidth;qe(ve<640?"phone":ve<1024?"tablet":"desktop")};return ce(),window.addEventListener("resize",ce),()=>window.removeEventListener("resize",ce)},[]),b.useEffect(()=>{Dt.current=!1},[O]),b.useEffect(()=>{nn.current=$e},[$e]),b.useEffect(()=>{if(!D){Me.current=null;return}Me.current===null&&(Me.current=nn.current),Ke(Q??"")},[Q,D,Ke]),b.useEffect(()=>{(async()=>{if(!x.baseUrl){Et(null);return}try{const pe=(await x.getAgent("default")).uiDefaultMessage||"";Et(pe||null)}catch(ve){console.warn("Failed to fetch default message:",ve),Et(null)}})()},[x.baseUrl]),b.useEffect(()=>{I&&!xt&&(g==null||g(I))},[I,xt,g]);const Tt=async ce=>{const ve=ce.trim();if(!(!ve&&xe.length===0))try{const pe=D?($==null?void 0:$.checkpointId)??j??void 0:j??void 0,Te=D?($==null?void 0:$.checkpointNs)??q??void 0:q??void 0;await N({text:ve||"",attachments:xe},{checkpointId:pe,checkpointNs:Te,edit:!!D,originalMessageId:D??void 0}),f==null||f(ve),Ke(""),de(null),Ee([]),ge(),X(null),ae(""),re(null)}catch(pe){const Te=(pe==null?void 0:pe.message)||"Failed to send message";de(Te),g==null||g(Te)}},He=b.useCallback((ce,ve,pe)=>{c&&(Me.current=$e,X(ce),ae(ve),Ke(ve),de(null),re({checkpointId:(pe==null?void 0:pe.checkpointId)??null,checkpointNs:(pe==null?void 0:pe.checkpointNs)??null}))},[$e,c,Ke]),ft=b.useCallback(()=>{X(null),ae(""),re(null),de(null),Ke(Me.current??$e),Me.current=null},[$e,Ke]),Fe=b.useCallback((ce,ve,pe)=>{He(ce,ve,pe)},[He]),tt=b.useCallback(ce=>{let ve=null;for(let Je=ce-1;Je>=0;Je--)if(S[Je].role==="user"){ve=S[Je];break}if(!ve)return;const pe=Array.isArray(ve.content)?ve.content:[],bt=pe.filter(Je=>(Je==null?void 0:Je.type)==="text").map(Je=>Je.text).join("")||(()=>{try{return JSON.stringify(pe,null,2)}catch{return String(pe)}})();bt&&N({text:bt},{checkpointId:j??void 0,checkpointNs:q??void 0,edit:!0,originalMessageId:ve.id})},[S,N,j,q]),Ut=ce=>{const ve=Array.from(ce.target.files||[]);Ee(pe=>[...pe,...ve]),ce.target.value=""},ql=ce=>{Ee(ve=>{const pe=ve.filter((Te,bt)=>ce!==bt);return pe.length===0&&ge(),pe})},Gl=async ce=>{const ve=(ce.target.files||[])[0];if(ve){rt(null),et(null),ze(!0);try{await N({attachments:[ve]},{checkpointId:j??void 0,checkpointNs:q??void 0});const pe=`Uploaded ${ve.name} - processing through chat stream`;et(pe)}catch(pe){const Te=pe instanceof Error?pe.message:"Failed to upload Excel file";console.error("Excel upload failed",pe),rt(Te),g==null||g(Te)}finally{ze(!1),ce.target.value="",ge()}}},ci=async ce=>{if(y){Ze(!0);try{if(!ce){await E(),requestAnimationFrame(()=>{var Te;(Te=pt.current)==null||Te.scrollToLatest()});return}const ve=R.find(Te=>Te.checkpointId===ce),pe=(ve==null?void 0:ve.checkpointNs)??null;await T(ce,pe),requestAnimationFrame(()=>{var Te;(Te=pt.current)==null||Te.scrollToTop()})}finally{Ze(!1)}}},A=b.useCallback(async(ce,ve,pe)=>{await ci(pe?null:ce)},[ci]),te=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${m.container||""}`,fe=`flex-1 min-h-0 min-w-0 max-h-full w-full overflow-hidden overscroll-contain break-words break-anywhere p-4 bg-transparent ${m.messagesArea||""}`,Ne=`relative flex-shrink-0 w-full border-t p-4 bg-transparent ${m.inputArea||""}`;return u.jsxs("div",{className:te,children:[!!I&&!xt&&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(at,{variant:"ghost",size:"sm",onClick:()=>vt(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:u.jsx(ue.X,{size:16})})]}),u.jsxs("div",{className:`relative ${fe}`,style:r?{maxHeight:r}:void 0,children:[u.jsx(cl,{ref:pt,className:"h-full",style:{height:"100%"},messages:S,isStreaming:B,streamingAssistantId:J,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:Oe,enableMessageEditing:c,editingMessageId:D,onEdit:Fe,onRegenerate:tt,onCancelEdit:ft,emptyMessage:dt??void 0,isNavigatingCheckpoint:Ct,activeInterrupt:P,disableInterruptActions:M,onInterruptActionStart:Z,onInterruptActionEnd:se,showToolMessages:d,showArtifactPreviews:p,checkpointIndex:K,activeCheckpointId:j,onSelectCheckpoint:A,createSyntheticThinkingMessage:!0}),(W==="reconnecting"||W==="connecting")&&u.jsx("div",{className:"pointer-events-none absolute top-3 right-3 z-20 rounded-full bg-muted/80 px-3 py-1 text-xs font-medium text-foreground shadow-sm backdrop-blur-sm dark:bg-muted/60",children:u.jsxs("span",{className:"flex items-center gap-2",children:[u.jsx(ue.Loader2,{className:"h-3 w-3 animate-spin"}),W==="reconnecting"?"Reconnecting…":"Connecting…"]})}),W==="error"&&u.jsx("div",{className:"pointer-events-none absolute top-3 right-3 z-20 rounded-full bg-destructive/10 px-3 py-1 text-xs font-semibold text-destructive shadow-sm",children:"Connection lost"}),C&&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(ue.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading messages…"})]}),(k||Ct)&&u.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 bg-background/80 backdrop-blur-sm text-muted-foreground",children:[u.jsx(ue.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading checkpoint…"})]})]}),u.jsxs("div",{className:Ne,children:[D&&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(ue.Edit3,{size:16,className:"text-blue-600"}),u.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),u.jsx(at,{variant:"ghost",size:"sm",onClick:ft,className:"text-blue-600 hover:bg-blue-100",children:u.jsx(ue.X,{size:16})})]})}),(a||l)&&u.jsxs("div",{className:"mb-3 space-y-3",children:[a&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:le,type:"file",multiple:!0,onChange:ce=>Ut(ce),className:"hidden"},Be),xe.length>0&&u.jsx("div",{className:"flex flex-wrap gap-2",children:xe.map((ce,ve)=>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(ue.Paperclip,{size:14}),u.jsx("span",{className:"truncate max-w-[150px]",children:ce.name}),u.jsx(at,{variant:"ghost",size:"sm",onClick:()=>ql(ve),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 ${ce.name}`,children:u.jsx(ue.X,{size:12})})]},ve))})]}),l&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:Y,type:"file",accept:".xls,.xlsx,.xlsm",onChange:Gl,className:"hidden"},je),Xe&&u.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(ue.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),nt&&!Xe&&u.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:nt}),Ge&&!Xe&&u.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:Ge})]})]}),we&&u.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:we}),u.jsxs("div",{className:"flex items-end gap-2",children:[(a||l)&&u.jsxs(vs,{children:[u.jsx(ws,{asChild:!0,children:u.jsx(at,{type:"button",size:"icon",variant:"outline",disabled:B||V,title:"More input actions",className:m.moreButton||"",children:u.jsx(ue.Plus,{size:16})})}),u.jsxs(ao,{align:"start",sideOffset:6,className:"w-52",children:[a&&u.jsxs(On,{onClick:()=>{var ce;return(ce=le.current)==null?void 0:ce.click()},className:"cursor-pointer",children:[u.jsx(ue.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),l&&u.jsxs(On,{onClick:()=>{var ce;Xe||(ce=Y.current)==null||ce.click()},className:`cursor-pointer ${Xe?"opacity-60 pointer-events-none":""}`,children:[u.jsx(ue.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),u.jsx("div",{className:"flex-1",children:u.jsx(gS,{initialValue:Q,editingMessageId:D,value:$e,onValueChange:it,placeholder:D?"Edit your message...":t,isStreaming:B,disabled:V,onSend:Tt,onCancelEdit:ft,onStop:U,allowEmptySend:xe.length>0,textareaClassName:`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${D?"border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50":""} ${we?"border-red-400":""} ${m.textarea||""}`})})]})]})]})}var jh=1,CT=.9,TT=.8,kT=.17,ul=.1,dl=.999,ET=.9999,IT=.99,NT=/[\\\/_+.#"@\[\(\{&]/,AT=/[\\\/_+.#"@\[\(\{&]/g,jT=/[\s-]/,_h=/[\s-]/g;function fl(e,t,n,r,o,s,i){if(s===t.length)return o===e.length?jh:IT;var a=`${o},${s}`;if(i[a]!==void 0)return i[a];for(var l=r.charAt(s),c=n.indexOf(l,o),d=0,p,m,f,v;c>=0;)p=fl(e,t,n,r,c+1,s+1,i),p>d&&(c===o?p*=jh:NT.test(e.charAt(c-1))?(p*=TT,f=e.slice(o,c-1).match(AT),f&&o>0&&(p*=Math.pow(dl,f.length))):jT.test(e.charAt(c-1))?(p*=CT,v=e.slice(o,c-1).match(_h),v&&o>0&&(p*=Math.pow(dl,v.length))):(p*=kT,o>0&&(p*=Math.pow(dl,c-o))),e.charAt(c)!==t.charAt(s)&&(p*=ET)),(p<ul&&n.charAt(c-1)===r.charAt(s+1)||r.charAt(s+1)===r.charAt(s)&&n.charAt(c-1)!==r.charAt(s))&&(m=fl(e,t,n,r,c+1,s+2,i),m*ul>p&&(p=m*ul)),p>d&&(d=p),c=n.indexOf(l,c+1);return i[a]=d,d}function Ph(e){return e.toLowerCase().replace(_h," ")}function _T(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,fl(e,t,Ph(e),Ph(t),0,0,{})}var Co='[cmdk-group=""]',pl='[cmdk-group-items=""]',PT='[cmdk-group-heading=""]',Mh='[cmdk-item=""]',Rh=`${Mh}:not([aria-disabled="true"])`,hl="cmdk-item-select",jr="data-value",MT=(e,t,n)=>_T(e,t,n),Oh=h.createContext(void 0),To=()=>h.useContext(Oh),Dh=h.createContext(void 0),ml=()=>h.useContext(Dh),Lh=h.createContext(void 0),$h=h.forwardRef((e,t)=>{let n=_r(()=>{var P,M;return{search:"",value:(M=(P=e.value)!=null?P:e.defaultValue)!=null?M:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=_r(()=>new Set),o=_r(()=>new Map),s=_r(()=>new Map),i=_r(()=>new Set),a=Fh(e),{label:l,children:c,value:d,onValueChange:p,filter:m,shouldFilter:f,loop:v,disablePointerSelection:g=!1,vimBindings:x=!0,...y}=e,w=Nt(),S=Nt(),k=Nt(),C=h.useRef(null),T=WT();sr(()=>{if(d!==void 0){let P=d.trim();n.current.value=P,E.emit()}},[d]),sr(()=>{T(6,B)},[]);let E=h.useMemo(()=>({subscribe:P=>(i.current.add(P),()=>i.current.delete(P)),snapshot:()=>n.current,setState:(P,M,G)=>{var Z,se,V,D;if(!Object.is(n.current[P],M)){if(n.current[P]=M,P==="search")K(),L(),T(1,H);else if(P==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let X=document.getElementById(k);X?X.focus():(Z=document.getElementById(w))==null||Z.focus()}if(T(7,()=>{var X;n.current.selectedItemId=(X=I())==null?void 0:X.id,E.emit()}),G||T(5,B),((se=a.current)==null?void 0:se.value)!==void 0){let X=M??"";(D=(V=a.current).onValueChange)==null||D.call(V,X);return}}E.emit()}},emit:()=>{i.current.forEach(P=>P())}}),[]),_=h.useMemo(()=>({value:(P,M,G)=>{var Z;M!==((Z=s.current.get(P))==null?void 0:Z.value)&&(s.current.set(P,{value:M,keywords:G}),n.current.filtered.items.set(P,R(M,G)),T(2,()=>{L(),E.emit()}))},item:(P,M)=>(r.current.add(P),M&&(o.current.has(M)?o.current.get(M).add(P):o.current.set(M,new Set([P]))),T(3,()=>{K(),L(),n.current.value||H(),E.emit()}),()=>{s.current.delete(P),r.current.delete(P),n.current.filtered.items.delete(P);let G=I();T(4,()=>{K(),(G==null?void 0:G.getAttribute("id"))===P&&H(),E.emit()})}),group:P=>(o.current.has(P)||o.current.set(P,new Set),()=>{s.current.delete(P),o.current.delete(P)}),filter:()=>a.current.shouldFilter,label:l||e["aria-label"],getDisablePointerSelection:()=>a.current.disablePointerSelection,listId:w,inputId:k,labelId:S,listInnerRef:C}),[]);function R(P,M){var G,Z;let se=(Z=(G=a.current)==null?void 0:G.filter)!=null?Z:MT;return P?se(P,n.current.search,M):0}function L(){if(!n.current.search||a.current.shouldFilter===!1)return;let P=n.current.filtered.items,M=[];n.current.filtered.groups.forEach(Z=>{let se=o.current.get(Z),V=0;se.forEach(D=>{let X=P.get(D);V=Math.max(X,V)}),M.push([Z,V])});let G=C.current;W().sort((Z,se)=>{var V,D;let X=Z.getAttribute("id"),Q=se.getAttribute("id");return((V=P.get(Q))!=null?V:0)-((D=P.get(X))!=null?D:0)}).forEach(Z=>{let se=Z.closest(pl);se?se.appendChild(Z.parentElement===se?Z:Z.closest(`${pl} > *`)):G.appendChild(Z.parentElement===G?Z:Z.closest(`${pl} > *`))}),M.sort((Z,se)=>se[1]-Z[1]).forEach(Z=>{var se;let V=(se=C.current)==null?void 0:se.querySelector(`${Co}[${jr}="${encodeURIComponent(Z[0])}"]`);V==null||V.parentElement.appendChild(V)})}function H(){let P=W().find(G=>G.getAttribute("aria-disabled")!=="true"),M=P==null?void 0:P.getAttribute(jr);E.setState("value",M||void 0)}function K(){var P,M,G,Z;if(!n.current.search||a.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let se=0;for(let V of r.current){let D=(M=(P=s.current.get(V))==null?void 0:P.value)!=null?M:"",X=(Z=(G=s.current.get(V))==null?void 0:G.keywords)!=null?Z:[],Q=R(D,X);n.current.filtered.items.set(V,Q),Q>0&&se++}for(let[V,D]of o.current)for(let X of D)if(n.current.filtered.items.get(X)>0){n.current.filtered.groups.add(V);break}n.current.filtered.count=se}function B(){var P,M,G;let Z=I();Z&&(((P=Z.parentElement)==null?void 0:P.firstChild)===Z&&((G=(M=Z.closest(Co))==null?void 0:M.querySelector(PT))==null||G.scrollIntoView({block:"nearest"})),Z.scrollIntoView({block:"nearest"}))}function I(){var P;return(P=C.current)==null?void 0:P.querySelector(`${Mh}[aria-selected="true"]`)}function W(){var P;return Array.from(((P=C.current)==null?void 0:P.querySelectorAll(Rh))||[])}function N(P){let M=W()[P];M&&E.setState("value",M.getAttribute(jr))}function U(P){var M;let G=I(),Z=W(),se=Z.findIndex(D=>D===G),V=Z[se+P];(M=a.current)!=null&&M.loop&&(V=se+P<0?Z[Z.length-1]:se+P===Z.length?Z[0]:Z[se+P]),V&&E.setState("value",V.getAttribute(jr))}function O(P){let M=I(),G=M==null?void 0:M.closest(Co),Z;for(;G&&!Z;)G=P>0?HT(G,Co):UT(G,Co),Z=G==null?void 0:G.querySelector(Rh);Z?E.setState("value",Z.getAttribute(jr)):U(P)}let j=()=>N(W().length-1),q=P=>{P.preventDefault(),P.metaKey?j():P.altKey?O(1):U(1)},J=P=>{P.preventDefault(),P.metaKey?N(0):P.altKey?O(-1):U(-1)};return h.createElement(be.div,{ref:t,tabIndex:-1,...y,"cmdk-root":"",onKeyDown:P=>{var M;(M=y.onKeyDown)==null||M.call(y,P);let G=P.nativeEvent.isComposing||P.keyCode===229;if(!(P.defaultPrevented||G))switch(P.key){case"n":case"j":{x&&P.ctrlKey&&q(P);break}case"ArrowDown":{q(P);break}case"p":case"k":{x&&P.ctrlKey&&J(P);break}case"ArrowUp":{J(P);break}case"Home":{P.preventDefault(),N(0);break}case"End":{P.preventDefault(),j();break}case"Enter":{P.preventDefault();let Z=I();if(Z){let se=new Event(hl);Z.dispatchEvent(se)}}}}},h.createElement("label",{"cmdk-label":"",htmlFor:_.inputId,id:_.labelId,style:KT},l),Ks(e,P=>h.createElement(Dh.Provider,{value:E},h.createElement(Oh.Provider,{value:_},P))))}),RT=h.forwardRef((e,t)=>{var n,r;let o=Nt(),s=h.useRef(null),i=h.useContext(Lh),a=To(),l=Fh(e),c=(r=(n=l.current)==null?void 0:n.forceMount)!=null?r:i==null?void 0:i.forceMount;sr(()=>{if(!c)return a.item(o,i==null?void 0:i.id)},[c]);let d=Bh(o,s,[e.value,e.children,s],e.keywords),p=ml(),m=Hn(T=>T.value&&T.value===d.current),f=Hn(T=>c||a.filter()===!1?!0:T.search?T.filtered.items.get(o)>0:!0);h.useEffect(()=>{let T=s.current;if(!(!T||e.disabled))return T.addEventListener(hl,v),()=>T.removeEventListener(hl,v)},[f,e.onSelect,e.disabled]);function v(){var T,E;g(),(E=(T=l.current).onSelect)==null||E.call(T,d.current)}function g(){p.setState("value",d.current,!0)}if(!f)return null;let{disabled:x,value:y,onSelect:w,forceMount:S,keywords:k,...C}=e;return h.createElement(be.div,{ref:jn(s,t),...C,id:o,"cmdk-item":"",role:"option","aria-disabled":!!x,"aria-selected":!!m,"data-disabled":!!x,"data-selected":!!m,onPointerMove:x||a.getDisablePointerSelection()?void 0:g,onClick:x?void 0:v},e.children)}),OT=h.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:o,...s}=e,i=Nt(),a=h.useRef(null),l=h.useRef(null),c=Nt(),d=To(),p=Hn(f=>o||d.filter()===!1?!0:f.search?f.filtered.groups.has(i):!0);sr(()=>d.group(i),[]),Bh(i,a,[e.value,e.heading,l]);let m=h.useMemo(()=>({id:i,forceMount:o}),[o]);return h.createElement(be.div,{ref:jn(a,t),...s,"cmdk-group":"",role:"presentation",hidden:p?void 0:!0},n&&h.createElement("div",{ref:l,"cmdk-group-heading":"","aria-hidden":!0,id:c},n),Ks(e,f=>h.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?c:void 0},h.createElement(Lh.Provider,{value:m},f))))}),DT=h.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,o=h.useRef(null),s=Hn(i=>!i.search);return!n&&!s?null:h.createElement(be.div,{ref:jn(o,t),...r,"cmdk-separator":"",role:"separator"})}),LT=h.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,o=e.value!=null,s=ml(),i=Hn(c=>c.search),a=Hn(c=>c.selectedItemId),l=To();return h.useEffect(()=>{e.value!=null&&s.setState("search",e.value)},[e.value]),h.createElement(be.input,{ref:t,...r,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":l.listId,"aria-labelledby":l.labelId,"aria-activedescendant":a,id:l.inputId,type:"text",value:o?e.value:i,onChange:c=>{o||s.setState("search",c.target.value),n==null||n(c.target.value)}})}),$T=h.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...o}=e,s=h.useRef(null),i=h.useRef(null),a=Hn(c=>c.selectedItemId),l=To();return h.useEffect(()=>{if(i.current&&s.current){let c=i.current,d=s.current,p,m=new ResizeObserver(()=>{p=requestAnimationFrame(()=>{let f=c.offsetHeight;d.style.setProperty("--cmdk-list-height",f.toFixed(1)+"px")})});return m.observe(c),()=>{cancelAnimationFrame(p),m.unobserve(c)}}},[]),h.createElement(be.div,{ref:jn(s,t),...o,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":a,"aria-label":r,id:l.listId},Ks(e,c=>h.createElement("div",{ref:jn(i,l.listInnerRef),"cmdk-list-sizer":""},c)))}),FT=h.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:o,contentClassName:s,container:i,...a}=e;return h.createElement(qa,{open:n,onOpenChange:r},h.createElement(Ga,{container:i},h.createElement(wo,{"cmdk-overlay":"",className:o}),h.createElement(bo,{"aria-label":e.label,"cmdk-dialog":"",className:s},h.createElement($h,{ref:t,...a}))))}),BT=h.forwardRef((e,t)=>Hn(n=>n.filtered.count===0)?h.createElement(be.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),zT=h.forwardRef((e,t)=>{let{progress:n,children:r,label:o="Loading...",...s}=e;return h.createElement(be.div,{ref:t,...s,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":o},Ks(e,i=>h.createElement("div",{"aria-hidden":!0},i)))}),zt=Object.assign($h,{List:$T,Item:RT,Input:LT,Group:OT,Separator:DT,Dialog:FT,Empty:BT,Loading:zT});function HT(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function UT(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function Fh(e){let t=h.useRef(e);return sr(()=>{t.current=e}),t}var sr=typeof window>"u"?h.useEffect:h.useLayoutEffect;function _r(e){let t=h.useRef();return t.current===void 0&&(t.current=e()),t}function Hn(e){let t=ml(),n=()=>e(t.snapshot());return h.useSyncExternalStore(t.subscribe,n,n)}function Bh(e,t,n,r=[]){let o=h.useRef(),s=To();return sr(()=>{var i;let a=(()=>{var c;for(let d of n){if(typeof d=="string")return d.trim();if(typeof d=="object"&&"current"in d)return d.current?(c=d.current.textContent)==null?void 0:c.trim():o.current}})(),l=r.map(c=>c.trim());s.value(e,a,l),(i=t.current)==null||i.setAttribute(jr,a),o.current=a}),o}var WT=()=>{let[e,t]=h.useState(),n=_r(()=>new Map);return sr(()=>{n.current.forEach(r=>r()),n.current=new Map},[e]),(r,o)=>{n.current.set(r,o),t({})}};function VT(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function Ks({asChild:e,children:t},n){return e&&h.isValidElement(t)?h.cloneElement(VT(t),{ref:t.ref},n(t.props.children)):n(t)}var KT={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const gl=h.forwardRef(({className:e,...t},n)=>u.jsx(zt,{ref:n,className:ne("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));gl.displayName=zt.displayName;const xl=h.forwardRef(({className:e,...t},n)=>u.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[u.jsx(ue.Search,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),u.jsx(zt.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})]}));xl.displayName=zt.Input.displayName;const vl=h.forwardRef(({className:e,...t},n)=>u.jsx(zt.List,{ref:n,className:ne("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));vl.displayName=zt.List.displayName;const wl=h.forwardRef((e,t)=>u.jsx(zt.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));wl.displayName=zt.Empty.displayName;const bl=h.forwardRef(({className:e,...t},n)=>u.jsx(zt.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}));bl.displayName=zt.Group.displayName;const qT=h.forwardRef(({className:e,...t},n)=>u.jsx(zt.Separator,{ref:n,className:ne("-mx-1 h-px bg-border",e),...t}));qT.displayName=zt.Separator.displayName;const yl=h.forwardRef(({className:e,...t},n)=>u.jsx(zt.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}));yl.displayName=zt.Item.displayName;function Sl(e,[t,n]){return Math.min(n,Math.max(t,e))}function GT(e,t){return h.useReducer((n,r)=>t[n][r]??n,e)}var Cl="ScrollArea",[zh,l1]=sn(Cl),[YT,tn]=zh(Cl),Hh=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,l]=h.useState(null),[c,d]=h.useState(null),[p,m]=h.useState(null),[f,v]=h.useState(null),[g,x]=h.useState(null),[y,w]=h.useState(0),[S,k]=h.useState(0),[C,T]=h.useState(!1),[E,_]=h.useState(!1),R=De(t,H=>l(H)),L=Ko(o);return u.jsx(YT,{scope:n,type:r,dir:L,scrollHideDelay:s,scrollArea:a,viewport:c,onViewportChange:d,content:p,onContentChange:m,scrollbarX:f,onScrollbarXChange:v,scrollbarXEnabled:C,onScrollbarXEnabledChange:T,scrollbarY:g,onScrollbarYChange:x,scrollbarYEnabled:E,onScrollbarYEnabledChange:_,onCornerWidthChange:w,onCornerHeightChange:k,children:u.jsx(be.div,{dir:L,...i,ref:R,style:{position:"relative","--radix-scroll-area-corner-width":y+"px","--radix-scroll-area-corner-height":S+"px",...e.style}})})});Hh.displayName=Cl;var Uh="ScrollAreaViewport",Wh=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=tn(Uh,n),a=h.useRef(null),l=De(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(be.div,{"data-radix-scroll-area-viewport":"",...s,ref:l,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:u.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});Wh.displayName=Uh;var Tn="ScrollAreaScrollbar",Tl=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=tn(Tn,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(XT,{...r,ref:t,forceMount:n}):o.type==="scroll"?u.jsx(JT,{...r,ref:t,forceMount:n}):o.type==="auto"?u.jsx(Vh,{...r,ref:t,forceMount:n}):o.type==="always"?u.jsx(kl,{...r,ref:t}):null});Tl.displayName=Tn;var XT=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=tn(Tn,e.__scopeScrollArea),[s,i]=h.useState(!1);return h.useEffect(()=>{const a=o.scrollArea;let l=0;if(a){const c=()=>{window.clearTimeout(l),i(!0)},d=()=>{l=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",c),a.addEventListener("pointerleave",d),()=>{window.clearTimeout(l),a.removeEventListener("pointerenter",c),a.removeEventListener("pointerleave",d)}}},[o.scrollArea,o.scrollHideDelay]),u.jsx(Ft,{present:n||s,children:u.jsx(Vh,{"data-state":s?"visible":"hidden",...r,ref:t})})}),JT=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=tn(Tn,e.__scopeScrollArea),s=e.orientation==="horizontal",i=Xs(()=>l("SCROLL_END"),100),[a,l]=GT("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return h.useEffect(()=>{if(a==="idle"){const c=window.setTimeout(()=>l("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(c)}},[a,o.scrollHideDelay,l]),h.useEffect(()=>{const c=o.viewport,d=s?"scrollLeft":"scrollTop";if(c){let p=c[d];const m=()=>{const f=c[d];p!==f&&(l("SCROLL"),i()),p=f};return c.addEventListener("scroll",m),()=>c.removeEventListener("scroll",m)}},[o.viewport,s,l,i]),u.jsx(Ft,{present:n||a!=="hidden",children:u.jsx(kl,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:ie(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:ie(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),Vh=h.forwardRef((e,t)=>{const n=tn(Tn,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=h.useState(!1),a=e.orientation==="horizontal",l=Xs(()=>{if(n.viewport){const c=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?c:d)}},10);return Pr(n.viewport,l),Pr(n.content,l),u.jsx(Ft,{present:r||s,children:u.jsx(kl,{"data-state":s?"visible":"hidden",...o,ref:t})})}),kl=h.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=tn(Tn,e.__scopeScrollArea),s=h.useRef(null),i=h.useRef(0),[a,l]=h.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),c=Xh(a.viewport,a.content),d={...r,sizes:a,onSizesChange:l,hasThumb:c>0&&c<1,onThumbChange:m=>s.current=m,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:m=>i.current=m};function p(m,f){return rk(m,i.current,a,f)}return n==="horizontal"?u.jsx(ZT,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollLeft,f=Jh(m,a,o.dir);s.current.style.transform=`translate3d(${f}px, 0, 0)`}},onWheelScroll:m=>{o.viewport&&(o.viewport.scrollLeft=m)},onDragScroll:m=>{o.viewport&&(o.viewport.scrollLeft=p(m,o.dir))}}):n==="vertical"?u.jsx(QT,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollTop,f=Jh(m,a);s.current.style.transform=`translate3d(0, ${f}px, 0)`}},onWheelScroll:m=>{o.viewport&&(o.viewport.scrollTop=m)},onDragScroll:m=>{o.viewport&&(o.viewport.scrollTop=p(m))}}):null}),ZT=h.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=tn(Tn,e.__scopeScrollArea),[i,a]=h.useState(),l=h.useRef(null),c=De(t,l,s.onScrollbarXChange);return h.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(qh,{"data-orientation":"horizontal",...o,ref:c,sizes:n,style:{bottom:0,left:s.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:s.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":Ys(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.x),onDragScroll:d=>e.onDragScroll(d.x),onWheelScroll:(d,p)=>{if(s.viewport){const m=s.viewport.scrollLeft+d.deltaX;e.onWheelScroll(m),Qh(m,p)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:l.current.clientWidth,paddingStart:Gs(i.paddingLeft),paddingEnd:Gs(i.paddingRight)}})}})}),QT=h.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=tn(Tn,e.__scopeScrollArea),[i,a]=h.useState(),l=h.useRef(null),c=De(t,l,s.onScrollbarYChange);return h.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(qh,{"data-orientation":"vertical",...o,ref:c,sizes:n,style:{top:0,right:s.dir==="ltr"?0:void 0,left:s.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":Ys(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.y),onDragScroll:d=>e.onDragScroll(d.y),onWheelScroll:(d,p)=>{if(s.viewport){const m=s.viewport.scrollTop+d.deltaY;e.onWheelScroll(m),Qh(m,p)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:l.current.clientHeight,paddingStart:Gs(i.paddingTop),paddingEnd:Gs(i.paddingBottom)}})}})}),[ek,Kh]=zh(Tn),qh=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:l,onDragScroll:c,onWheelScroll:d,onResize:p,...m}=e,f=tn(Tn,n),[v,g]=h.useState(null),x=De(t,R=>g(R)),y=h.useRef(null),w=h.useRef(""),S=f.viewport,k=r.content-r.viewport,C=mt(d),T=mt(l),E=Xs(p,10);function _(R){if(y.current){const L=R.clientX-y.current.left,H=R.clientY-y.current.top;c({x:L,y:H})}}return h.useEffect(()=>{const R=L=>{const H=L.target;(v==null?void 0:v.contains(H))&&C(L,k)};return document.addEventListener("wheel",R,{passive:!1}),()=>document.removeEventListener("wheel",R,{passive:!1})},[S,v,k,C]),h.useEffect(T,[r,T]),Pr(v,E),Pr(f.content,E),u.jsx(ek,{scope:n,scrollbar:v,hasThumb:o,onThumbChange:mt(s),onThumbPointerUp:mt(i),onThumbPositionChange:T,onThumbPointerDown:mt(a),children:u.jsx(be.div,{...m,ref:x,style:{position:"absolute",...m.style},onPointerDown:ie(e.onPointerDown,R=>{R.button===0&&(R.target.setPointerCapture(R.pointerId),y.current=v.getBoundingClientRect(),w.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",f.viewport&&(f.viewport.style.scrollBehavior="auto"),_(R))}),onPointerMove:ie(e.onPointerMove,_),onPointerUp:ie(e.onPointerUp,R=>{const L=R.target;L.hasPointerCapture(R.pointerId)&&L.releasePointerCapture(R.pointerId),document.body.style.webkitUserSelect=w.current,f.viewport&&(f.viewport.style.scrollBehavior=""),y.current=null})})})}),qs="ScrollAreaThumb",Gh=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Kh(qs,e.__scopeScrollArea);return u.jsx(Ft,{present:n||o.hasThumb,children:u.jsx(tk,{ref:t,...r})})}),tk=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=tn(qs,n),i=Kh(qs,n),{onThumbPositionChange:a}=i,l=De(t,p=>i.onThumbChange(p)),c=h.useRef(void 0),d=Xs(()=>{c.current&&(c.current(),c.current=void 0)},100);return h.useEffect(()=>{const p=s.viewport;if(p){const m=()=>{if(d(),!c.current){const f=ok(p,a);c.current=f,a()}};return a(),p.addEventListener("scroll",m),()=>p.removeEventListener("scroll",m)}},[s.viewport,d,a]),u.jsx(be.div,{"data-state":i.hasThumb?"visible":"hidden",...o,ref:l,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:ie(e.onPointerDownCapture,p=>{const f=p.target.getBoundingClientRect(),v=p.clientX-f.left,g=p.clientY-f.top;i.onThumbPointerDown({x:v,y:g})}),onPointerUp:ie(e.onPointerUp,i.onThumbPointerUp)})});Gh.displayName=qs;var El="ScrollAreaCorner",Yh=h.forwardRef((e,t)=>{const n=tn(El,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?u.jsx(nk,{...e,ref:t}):null});Yh.displayName=El;var nk=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=tn(El,n),[s,i]=h.useState(0),[a,l]=h.useState(0),c=!!(s&&a);return Pr(o.scrollbarX,()=>{var p;const d=((p=o.scrollbarX)==null?void 0:p.offsetHeight)||0;o.onCornerHeightChange(d),l(d)}),Pr(o.scrollbarY,()=>{var p;const d=((p=o.scrollbarY)==null?void 0:p.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),c?u.jsx(be.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 Gs(e){return e?parseInt(e,10):0}function Xh(e,t){const n=e/t;return isNaN(n)?0:n}function Ys(e){const t=Xh(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function rk(e,t,n,r="ltr"){const o=Ys(n),s=o/2,i=t||s,a=o-i,l=n.scrollbar.paddingStart+i,c=n.scrollbar.size-n.scrollbar.paddingEnd-a,d=n.content-n.viewport,p=r==="ltr"?[0,d]:[d*-1,0];return Zh([l,c],p)(e)}function Jh(e,t,n="ltr"){const r=Ys(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,s=t.scrollbar.size-o,i=t.content-t.viewport,a=s-r,l=n==="ltr"?[0,i]:[i*-1,0],c=Sl(e,l);return Zh([0,i],[0,a])(c)}function Zh(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 Qh(e,t){return e>0&&e<t}var ok=(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 Xs(e,t){const n=mt(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 Pr(e,t){const n=mt(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 em=Hh,sk=Wh,ik=Yh;const Il=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(em,{ref:r,className:ne("relative overflow-hidden",e),...n,children:[u.jsx(sk,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),u.jsx(tm,{}),u.jsx(ik,{})]}));Il.displayName=em.displayName;const tm=h.forwardRef(({className:e,orientation:t="vertical",...n},r)=>u.jsx(Tl,{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(Gh,{className:"relative flex-1 rounded-full bg-border"})}));tm.displayName=Tl.displayName;const Nl=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}));Nl.displayName="Input";const ak="group relative p-3 rounded-lg cursor-pointer transition-colors border text-gray-900 dark:text-slate-100",lk="bg-slate-700 border-slate-600 hover:bg-slate-600",ck="bg-slate-600 border-slate-500";function nm({thread:e,isActive:t,editingThreadId:n,editingTitle:r,onSelect:o,onStartEditing:s,onEditingTitleChange:i,onSaveEditing:a,onCancelEditing:l,onShare:c,onDelete:d,showEditTitle:p,showDeleteButton:m,formatDate:f,getDisplayThreadTitle:v,secondaryLine:g,itemClassName:x,activeItemClassName:y}){const w=n===e.threadId,S=t?`${y??ck}`:`${x??lk}`,k=C=>{C.stopPropagation(),o(e.threadId)};return u.jsxs("div",{onClick:k,className:`${ak} ${S}`,children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("div",{className:"flex-1 min-w-0",children:w?u.jsxs("div",{className:"flex items-center gap-2",onClick:C=>C.stopPropagation(),children:[u.jsx(Nl,{value:r,onChange:C=>i(C.target.value),onKeyDown:C=>{C.key==="Enter"?a(e.threadId):C.key==="Escape"&&l()},className:"h-6 text-sm",autoFocus:!0}),u.jsx(at,{variant:"ghost",size:"sm",onClick:()=>a(e.threadId),className:"h-6 w-6 p-0",children:u.jsx(ue.Check,{size:12})}),u.jsx(at,{variant:"ghost",size:"sm",onClick:l,className:"h-6 w-6 p-0",children:u.jsx(ue.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(ue.Calendar,{size:10}),u.jsx("span",{children:f(e.updatedAt||e.createdAt)})]}),g&&u.jsx("div",{className:"text-[11px] text-muted-foreground mt-1",children:g})]})}),u.jsx("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2",children:u.jsxs(vs,{children:[u.jsx(ws,{asChild:!0,children:u.jsx(at,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",children:u.jsx(ue.MoreHorizontal,{size:12})})}),u.jsxs(ao,{align:"end",sideOffset:6,className:"w-44",children:[u.jsxs(On,{onClick:C=>{C.preventDefault(),c(e.threadId)},children:[u.jsx(ue.Share2,{className:"mr-2 h-4 w-4"}),"Share thread"]}),p&&n!==e.threadId&&u.jsxs(On,{onClick:C=>{C.preventDefault(),s(e,C)},children:[u.jsx(ue.Edit3,{className:"mr-2 h-4 w-4"}),"Rename"]}),m&&d&&u.jsxs(On,{className:"text-red-400 hover:text-red-300",onClick:C=>{C.preventDefault(),d(e.threadId,C)},children:[u.jsx(ue.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 rm=25,om="thread-manager-view",uk=e=>e==="default"||e==="shared",dk=()=>{if(typeof window>"u")return null;try{const e=window.localStorage.getItem(om);if(uk(e))return e}catch{}return null};function sm({defaultView:e}={}){const[t,n]=b.useState(()=>dk()??e??"default");b.useEffect(()=>{if(!(typeof window>"u"))try{window.localStorage.setItem(om,t)}catch{}},[t]);const r=b.useCallback(o=>{n(o)},[]);return{view:t,setView:r}}const fk=[{key:"default",label:"My chats"},{key:"shared",label:"Shared with you"}];function Al({className:e="",showCreateButton:t=!0,showDeleteButton:n=!0,showEditTitle:r=!0,maxHeight:o="400px",customStyles:s={},currentThreadId:i=null,navigateToThread:a,onThreadSelect:l,onThreadCreate:c,onThreadDelete:d,view:p,defaultView:m,onViewChange:f,viewOptions:v,viewState:g,showHeader:x=!0,shareTargets:y,isLoadingShareTargets:w,shareTargetFilter:S}){const{threads:k,sharedThreads:C,currentThreadId:T,setCurrentThreadId:E,isLoading:_,isLoadingSharedThreads:R,actions:L,shareInFlight:H,shareStatus:K,clearShareStatus:B}=pr(),{createThread:I,deleteThread:W,renameThread:N,shareThread:U}=L,{loadThread:O}=Yr(),j=i??T,[q,J]=b.useState(Array.isArray(k)?k:[]),P=b.useRef(q.length>0),M=b.useRef(null),G=b.useRef(0),[Z,se]=b.useState(null),[V,D]=b.useState(""),[X,Q]=b.useState(!1),[ae,$]=b.useState(!1),[re,we]=b.useState(null),[de,xe]=b.useState(""),Ee=v&&v.length>0?v:fk,Be=sm({defaultView:m}),We=g??Be,je=p??We.view,Ve=b.useCallback(Y=>{p||We.setView(Y),f==null||f(Y)},[p,f,We]),Xe=Ee.find(Y=>Y.key===je)??Ee[0],ze=Y=>{we(Y),xe(""),$(!0)},Ge=()=>{$(!1),we(null),xe(""),B()},rt=b.useCallback(async Y=>{if(!(!re||H)&&Y.id)try{await U(re,Y.id),setTimeout(()=>Ge(),600)}catch(ge){console.error("Failed to share thread:",ge)}},[Ge,H,re,U]),nt=b.useMemo(()=>{const Y=y??[],ge=de.trim().toLowerCase();return ge?S?Y.filter(it=>S(it,ge)):Y.filter(it=>`${it.label} ${it.secondaryLabel??""}`.toLowerCase().includes(ge)):Y},[y,de,S]),et=je==="shared",xt=et?C:q,vt=et?R:_,dt=et?"No shared conversations yet":"No conversations yet",Et=Y=>{const ge=Y.sharedAt?` • ${Ze(Y.sharedAt)}`:"";return`Shared by ${Y.sharedByUserId}${ge}`},Dt=Y=>"sharedByUserId"in Y;b.useEffect(()=>{const Y=Array.isArray(k)?k:[];if(Y.length>0){P.current=!0,J(Y);return}_||(P.current=!1,J(Y))},[k,_]),b.useEffect(()=>{if(!M.current)return;const Y=M.current.querySelector("[data-radix-scroll-area-viewport]");if(!Y)return;let ge=null,it=null;return ge=requestAnimationFrame(()=>{it=requestAnimationFrame(()=>{Y.scrollTop=G.current})}),()=>{ge!==null&&cancelAnimationFrame(ge),it!==null&&cancelAnimationFrame(it)}},[q]);const $e=async Y=>{try{E(Y),await O(Y),a==null||a(Y),l==null||l(Y)}catch(ge){console.error("Failed to select thread:",ge)}},Pt=async()=>{try{Q(!0);const Y=await I();Y&&(c==null||c(Y),a==null||a(Y))}catch(Y){console.error("Failed to create thread:",Y)}finally{Q(!1)}},nn=async(Y,ge)=>{if(ge.stopPropagation(),!!confirm("Delete this thread?")){if(M.current){const it=M.current.querySelector("[data-radix-scroll-area-viewport]");it&&(G.current=it.scrollTop)}try{await W(Y),d==null||d(Y)}catch(it){console.error("Failed to delete thread:",it)}}},Me=(Y,ge)=>{ge.stopPropagation(),se(Y.threadId),D(Y.title||`Thread ${Y.threadId.slice(0,8)}`)},Ke=async Y=>{if(V.trim())try{await N(Y,V.trim()),se(null),D("")}catch(ge){console.error("Failed to update title:",ge)}},Ct=()=>{se(null),D("")},Ze=Y=>{if(!Y)return"";try{const ge=new Date(Y),Ce=new Date().getTime()-ge.getTime(),Oe=Math.floor(Ce/(1e3*60*60*24));return Oe===0?ge.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):Oe===1?"Yesterday":Oe<7?`${Oe} days ago`:ge.toLocaleDateString()}catch{return""}},pt=Y=>Y.title||`Thread ${Y.threadId.slice(0,8)}`,le=Y=>{const ge=pt(Y);return ge.length<=rm?ge:`${ge.slice(0,rm)}...`};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(at,{onClick:Pt,disabled:X||_,className:s.createButton||"px-3 py-2 gap-1",size:"sm",variant:"ghost",title:X?"Creating...":"New Chat",children:[u.jsx(ue.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(vs,{children:[u.jsx(ws,{asChild:!0,children:u.jsx(at,{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:Xe.label})}),u.jsx(ao,{align:"start",sideOffset:6,className:"w-40",children:Ee.map(Y=>u.jsxs(On,{className:"justify-between text-[12px]",onClick:ge=>{ge.preventDefault(),Ve(Y.key)},children:[u.jsx("span",{children:Y.label}),je===Y.key&&u.jsx(ue.Check,{className:"h-3 w-3"})]},Y.key))})]})]})]}),u.jsx(Il,{ref:M,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:vt?u.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-8 text-slate-400",children:[u.jsx(ue.Loader2,{className:"h-5 w-5 animate-spin"}),u.jsx("span",{className:"text-sm",children:"Loading threads…"})]}):xt.length===0?u.jsxs("div",{className:"text-center py-8 text-slate-400",children:[u.jsx(ue.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:dt})]}):xt.slice().sort((Y,ge)=>new Date(ge.updatedAt||ge.createdAt||"").getTime()-new Date(Y.updatedAt||Y.createdAt||"").getTime()).map(Y=>u.jsx(nm,{thread:Y,isActive:j===Y.threadId,editingThreadId:Z,editingTitle:V,onSelect:$e,onStartEditing:Me,onEditingTitleChange:ge=>D(ge),onSaveEditing:Ke,onCancelEditing:Ct,onShare:()=>ze(Y.threadId),onDelete:nn,showEditTitle:r,showDeleteButton:n,formatDate:Ze,getDisplayThreadTitle:le,secondaryLine:et&&Dt(Y)?Et(Y):void 0,itemClassName:s.threadItem,activeItemClassName:s.activeThread},Y.threadId))})}),u.jsx(Ya,{open:ae,onOpenChange:Y=>!Y&&Ge(),children:u.jsxs(Ds,{className:"max-w-md p-0",children:[u.jsx(Ls,{children:u.jsx($s,{children:"Share thread"})}),u.jsxs(gl,{children:[u.jsx(xl,{autoFocus:!0,value:de,onValueChange:Y=>xe(Y),placeholder:"Search for recipients..."}),u.jsxs(vl,{children:[K&&u.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-xs text-muted-foreground",children:[H&&u.jsx(ue.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(wl,{children:w?u.jsxs("span",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(ue.Loader2,{className:"h-4 w-4 animate-spin"}),"Loading recipients…"]}):"No matching recipients found"}),nt.length>0&&u.jsx(bl,{heading:"Recipients",children:nt.map(Y=>u.jsx(yl,{onSelect:()=>rt(Y),children:u.jsxs("div",{className:"flex flex-col items-start text-sm",children:[u.jsx("span",{className:"font-medium",children:Y.label}),Y.secondaryLabel&&u.jsx("span",{className:"text-xs text-muted-foreground",children:Y.secondaryLabel})]})},Y.id))})]})]})]})})]})}function pk({layout:e="sidebar",layoutSize:t="desktop",showThreads:n=!0,className:r="",customStyles:o={},...s}){const i=c=>{const d="h-full";switch(c){case"phone":return`${d} max-w-none`;case"tablet":return`${d} max-w-4xl mx-auto`;case"half-screen":return`${d} max-w-2xl`;case"desktop":default:return`${d} max-w-7xl mx-auto`}},a=c=>({"--chat-sidebar-width":c==="phone"?"100%":c==="tablet"?"280px":c==="half-screen"?"240px":"320px","--chat-message-max-width":c==="phone"?"95%":c==="tablet"?"90%":c==="half-screen"?"85%":"80%","--chat-input-height":c==="phone"?"120px":"100px"}),l=b.useCallback(c=>{var d;(d=s.onThreadChange)==null||d.call(s,c)},[s]);return e==="fullscreen"?u.jsx(Xr,{...s,onThreadChange:l,children:u.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:u.jsx(So,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?u.jsx(Xr,{...s,onThreadChange:l,children:u.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:u.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[n&&u.jsx("div",{className:`w-80 border-r flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:u.jsx(Al,{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(So,{onError:s.onError,enableFileUpload:!0})})]})})}):u.jsx(Xr,{...s,onThreadChange:l,children:u.jsxs("div",{className:`${i(t)} flex overflow-hidden ${r} ${o.container||""}`,style:a(t),children:[n&&u.jsx("div",{className:`w-80 border-r bg-gray-50 flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:u.jsx(Al,{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(So,{onError:s.onError,enableFileUpload:!0})})]})})}function hk({apiConfig:e,className:t="",onError:n}){return u.jsx(Xr,{apiConfig:e,onError:n,children:u.jsx("div",{className:`h-full ${t}`,children:u.jsx(So,{})})})}var mk="Label",im=h.forwardRef((e,t)=>u.jsx(be.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=mk;var am=im;const gk=Dr.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),lm=h.forwardRef(({className:e,...t},n)=>u.jsx(am,{ref:n,className:ne(gk(),e),...t}));lm.displayName=am.displayName;function cm(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 um=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"}),xk="VisuallyHidden",Js=h.forwardRef((e,t)=>u.jsx(be.span,{...e,ref:t,style:{...um,...e.style}}));Js.displayName=xk;var vk=Js,wk=[" ","Enter","ArrowUp","ArrowDown"],bk=[" ","Enter"],ir="Select",[Zs,Qs,yk]=Vo(ir),[Mr,c1]=sn(ir,[yk,yr]),ei=yr(),[Sk,Un]=Mr(ir),[Ck,Tk]=Mr(ir),dm=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:l,dir:c,name:d,autoComplete:p,disabled:m,required:f,form:v}=e,g=ei(t),[x,y]=h.useState(null),[w,S]=h.useState(null),[k,C]=h.useState(!1),T=Ko(c),[E,_]=_n({prop:r,defaultProp:o??!1,onChange:s,caller:ir}),[R,L]=_n({prop:i,defaultProp:a,onChange:l,caller:ir}),H=h.useRef(null),K=x?v||!!x.closest("form"):!0,[B,I]=h.useState(new Set),W=Array.from(B).map(N=>N.props.value).join(";");return u.jsx(ea,{...g,children:u.jsxs(Sk,{required:f,scope:t,trigger:x,onTriggerChange:y,valueNode:w,onValueNodeChange:S,valueNodeHasChildren:k,onValueNodeHasChildrenChange:C,contentId:Nt(),value:R,onValueChange:L,open:E,onOpenChange:_,dir:T,triggerPointerDownPosRef:H,disabled:m,children:[u.jsx(Zs.Provider,{scope:t,children:u.jsx(Ck,{scope:e.__scopeSelect,onNativeOptionAdd:h.useCallback(N=>{I(U=>new Set(U).add(N))},[]),onNativeOptionRemove:h.useCallback(N=>{I(U=>{const O=new Set(U);return O.delete(N),O})},[]),children:n})}),K?u.jsxs(Om,{"aria-hidden":!0,required:f,tabIndex:-1,name:d,autoComplete:p,value:R,onChange:N=>L(N.target.value),disabled:m,form:v,children:[R===void 0?u.jsx("option",{value:""}):null,Array.from(B)]},W):null]})})};dm.displayName=ir;var fm="SelectTrigger",pm=h.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=ei(n),i=Un(fm,n),a=i.disabled||r,l=De(t,i.onTriggerChange),c=Qs(n),d=h.useRef("touch"),[p,m,f]=Lm(g=>{const x=c().filter(S=>!S.disabled),y=x.find(S=>S.value===i.value),w=$m(x,g,y);w!==void 0&&i.onValueChange(w.value)}),v=g=>{a||(i.onOpenChange(!0),f()),g&&(i.triggerPointerDownPosRef.current={x:Math.round(g.pageX),y:Math.round(g.pageY)})};return u.jsx(ta,{asChild:!0,...s,children:u.jsx(be.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":Dm(i.value)?"":void 0,...o,ref:l,onClick:ie(o.onClick,g=>{g.currentTarget.focus(),d.current!=="mouse"&&v(g)}),onPointerDown:ie(o.onPointerDown,g=>{d.current=g.pointerType;const x=g.target;x.hasPointerCapture(g.pointerId)&&x.releasePointerCapture(g.pointerId),g.button===0&&g.ctrlKey===!1&&g.pointerType==="mouse"&&(v(g),g.preventDefault())}),onKeyDown:ie(o.onKeyDown,g=>{const x=p.current!=="";!(g.ctrlKey||g.altKey||g.metaKey)&&g.key.length===1&&m(g.key),!(x&&g.key===" ")&&wk.includes(g.key)&&(v(),g.preventDefault())})})})});pm.displayName=fm;var hm="SelectValue",mm=h.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=Un(hm,n),{onValueNodeHasChildrenChange:c}=l,d=s!==void 0,p=De(t,l.onValueNodeChange);return kt(()=>{c(d)},[c,d]),u.jsx(be.span,{...a,ref:p,style:{pointerEvents:"none"},children:Dm(l.value)?u.jsx(u.Fragment,{children:i}):s})});mm.displayName=hm;var kk="SelectIcon",gm=h.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return u.jsx(be.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});gm.displayName=kk;var Ek="SelectPortal",xm=e=>u.jsx(eo,{asChild:!0,...e});xm.displayName=Ek;var ar="SelectContent",vm=h.forwardRef((e,t)=>{const n=Un(ar,e.__scopeSelect),[r,o]=h.useState();if(kt(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?Lr.createPortal(u.jsx(wm,{scope:e.__scopeSelect,children:u.jsx(Zs.Slot,{scope:e.__scopeSelect,children:u.jsx("div",{children:e.children})})}),s):null}return u.jsx(bm,{...e,ref:t})});vm.displayName=ar;var fn=10,[wm,Wn]=Mr(ar),Ik="SelectContentImpl",Nk=Vt.createSlot("SelectContent.RemoveScroll"),bm=h.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:p,collisionBoundary:m,collisionPadding:f,sticky:v,hideWhenDetached:g,avoidCollisions:x,...y}=e,w=Un(ar,n),[S,k]=h.useState(null),[C,T]=h.useState(null),E=De(t,V=>k(V)),[_,R]=h.useState(null),[L,H]=h.useState(null),K=Qs(n),[B,I]=h.useState(!1),W=h.useRef(!1);h.useEffect(()=>{if(S)return aa(S)},[S]),$i();const N=h.useCallback(V=>{const[D,...X]=K().map($=>$.ref.current),[Q]=X.slice(-1),ae=document.activeElement;for(const $ of V)if($===ae||($==null||$.scrollIntoView({block:"nearest"}),$===D&&C&&(C.scrollTop=0),$===Q&&C&&(C.scrollTop=C.scrollHeight),$==null||$.focus(),document.activeElement!==ae))return},[K,C]),U=h.useCallback(()=>N([_,S]),[N,_,S]);h.useEffect(()=>{B&&U()},[B,U]);const{onOpenChange:O,triggerPointerDownPosRef:j}=w;h.useEffect(()=>{if(S){let V={x:0,y:0};const D=Q=>{var ae,$;V={x:Math.abs(Math.round(Q.pageX)-(((ae=j.current)==null?void 0:ae.x)??0)),y:Math.abs(Math.round(Q.pageY)-((($=j.current)==null?void 0:$.y)??0))}},X=Q=>{V.x<=10&&V.y<=10?Q.preventDefault():S.contains(Q.target)||O(!1),document.removeEventListener("pointermove",D),j.current=null};return j.current!==null&&(document.addEventListener("pointermove",D),document.addEventListener("pointerup",X,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",D),document.removeEventListener("pointerup",X,{capture:!0})}}},[S,O,j]),h.useEffect(()=>{const V=()=>O(!1);return window.addEventListener("blur",V),window.addEventListener("resize",V),()=>{window.removeEventListener("blur",V),window.removeEventListener("resize",V)}},[O]);const[q,J]=Lm(V=>{const D=K().filter(ae=>!ae.disabled),X=D.find(ae=>ae.ref.current===document.activeElement),Q=$m(D,V,X);Q&&setTimeout(()=>Q.ref.current.focus())}),P=h.useCallback((V,D,X)=>{const Q=!W.current&&!X;(w.value!==void 0&&w.value===D||Q)&&(R(V),Q&&(W.current=!0))},[w.value]),M=h.useCallback(()=>S==null?void 0:S.focus(),[S]),G=h.useCallback((V,D,X)=>{const Q=!W.current&&!X;(w.value!==void 0&&w.value===D||Q)&&H(V)},[w.value]),Z=r==="popper"?jl:ym,se=Z===jl?{side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:p,collisionBoundary:m,collisionPadding:f,sticky:v,hideWhenDetached:g,avoidCollisions:x}:{};return u.jsx(wm,{scope:n,content:S,viewport:C,onViewportChange:T,itemRefCallback:P,selectedItem:_,onItemLeave:M,itemTextRefCallback:G,focusSelectedItem:U,selectedItemText:L,position:r,isPositioned:B,searchRef:q,children:u.jsx(fs,{as:Nk,allowPinchZoom:!0,children:u.jsx(qo,{asChild:!0,trapped:w.open,onMountAutoFocus:V=>{V.preventDefault()},onUnmountAutoFocus:ie(o,V=>{var D;(D=w.trigger)==null||D.focus({preventScroll:!0}),V.preventDefault()}),children:u.jsx(gr,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:V=>V.preventDefault(),onDismiss:()=>w.onOpenChange(!1),children:u.jsx(Z,{role:"listbox",id:w.contentId,"data-state":w.open?"open":"closed",dir:w.dir,onContextMenu:V=>V.preventDefault(),...y,...se,onPlaced:()=>I(!0),ref:E,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:ie(y.onKeyDown,V=>{const D=V.ctrlKey||V.altKey||V.metaKey;if(V.key==="Tab"&&V.preventDefault(),!D&&V.key.length===1&&J(V.key),["ArrowUp","ArrowDown","Home","End"].includes(V.key)){let Q=K().filter(ae=>!ae.disabled).map(ae=>ae.ref.current);if(["ArrowUp","End"].includes(V.key)&&(Q=Q.slice().reverse()),["ArrowUp","ArrowDown"].includes(V.key)){const ae=V.target,$=Q.indexOf(ae);Q=Q.slice($+1)}setTimeout(()=>N(Q)),V.preventDefault()}})})})})})})});bm.displayName=Ik;var Ak="SelectItemAlignedPosition",ym=h.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=Un(ar,n),i=Wn(ar,n),[a,l]=h.useState(null),[c,d]=h.useState(null),p=De(t,E=>d(E)),m=Qs(n),f=h.useRef(!1),v=h.useRef(!0),{viewport:g,selectedItem:x,selectedItemText:y,focusSelectedItem:w}=i,S=h.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&c&&g&&x&&y){const E=s.trigger.getBoundingClientRect(),_=c.getBoundingClientRect(),R=s.valueNode.getBoundingClientRect(),L=y.getBoundingClientRect();if(s.dir!=="rtl"){const ae=L.left-_.left,$=R.left-ae,re=E.left-$,we=E.width+re,de=Math.max(we,_.width),xe=window.innerWidth-fn,Ee=Sl($,[fn,Math.max(fn,xe-de)]);a.style.minWidth=we+"px",a.style.left=Ee+"px"}else{const ae=_.right-L.right,$=window.innerWidth-R.right-ae,re=window.innerWidth-E.right-$,we=E.width+re,de=Math.max(we,_.width),xe=window.innerWidth-fn,Ee=Sl($,[fn,Math.max(fn,xe-de)]);a.style.minWidth=we+"px",a.style.right=Ee+"px"}const H=m(),K=window.innerHeight-fn*2,B=g.scrollHeight,I=window.getComputedStyle(c),W=parseInt(I.borderTopWidth,10),N=parseInt(I.paddingTop,10),U=parseInt(I.borderBottomWidth,10),O=parseInt(I.paddingBottom,10),j=W+N+B+O+U,q=Math.min(x.offsetHeight*5,j),J=window.getComputedStyle(g),P=parseInt(J.paddingTop,10),M=parseInt(J.paddingBottom,10),G=E.top+E.height/2-fn,Z=K-G,se=x.offsetHeight/2,V=x.offsetTop+se,D=W+N+V,X=j-D;if(D<=G){const ae=H.length>0&&x===H[H.length-1].ref.current;a.style.bottom="0px";const $=c.clientHeight-g.offsetTop-g.offsetHeight,re=Math.max(Z,se+(ae?M:0)+$+U),we=D+re;a.style.height=we+"px"}else{const ae=H.length>0&&x===H[0].ref.current;a.style.top="0px";const re=Math.max(G,W+g.offsetTop+(ae?P:0)+se)+X;a.style.height=re+"px",g.scrollTop=D-G+g.offsetTop}a.style.margin=`${fn}px 0`,a.style.minHeight=q+"px",a.style.maxHeight=K+"px",r==null||r(),requestAnimationFrame(()=>f.current=!0)}},[m,s.trigger,s.valueNode,a,c,g,x,y,s.dir,r]);kt(()=>S(),[S]);const[k,C]=h.useState();kt(()=>{c&&C(window.getComputedStyle(c).zIndex)},[c]);const T=h.useCallback(E=>{E&&v.current===!0&&(S(),w==null||w(),v.current=!1)},[S,w]);return u.jsx(_k,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:f,onScrollButtonChange:T,children:u.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:k},children:u.jsx(be.div,{...o,ref:p,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});ym.displayName=Ak;var jk="SelectPopperPosition",jl=h.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=fn,...s}=e,i=ei(n);return u.jsx(na,{...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)"}})});jl.displayName=jk;var[_k,_l]=Mr(ar,{}),Pl="SelectViewport",Sm=h.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=Wn(Pl,n),i=_l(Pl,n),a=De(t,s.onViewportChange),l=h.useRef(0);return u.jsxs(u.Fragment,{children:[u.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),u.jsx(Zs.Slot,{scope:n,children:u.jsx(be.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:ie(o.onScroll,c=>{const d=c.currentTarget,{contentWrapper:p,shouldExpandOnScrollRef:m}=i;if(m!=null&&m.current&&p){const f=Math.abs(l.current-d.scrollTop);if(f>0){const v=window.innerHeight-fn*2,g=parseFloat(p.style.minHeight),x=parseFloat(p.style.height),y=Math.max(g,x);if(y<v){const w=y+f,S=Math.min(v,w),k=w-S;p.style.height=S+"px",p.style.bottom==="0px"&&(d.scrollTop=k>0?k:0,p.style.justifyContent="flex-end")}}}l.current=d.scrollTop})})})]})});Sm.displayName=Pl;var Cm="SelectGroup",[Pk,Mk]=Mr(Cm),Rk=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Nt();return u.jsx(Pk,{scope:n,id:o,children:u.jsx(be.div,{role:"group","aria-labelledby":o,...r,ref:t})})});Rk.displayName=Cm;var Tm="SelectLabel",km=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Mk(Tm,n);return u.jsx(be.div,{id:o.id,...r,ref:t})});km.displayName=Tm;var ti="SelectItem",[Ok,Em]=Mr(ti),Im=h.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=Un(ti,n),l=Wn(ti,n),c=a.value===r,[d,p]=h.useState(s??""),[m,f]=h.useState(!1),v=De(t,w=>{var S;return(S=l.itemRefCallback)==null?void 0:S.call(l,w,r,o)}),g=Nt(),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(Ok,{scope:n,value:r,disabled:o,textId:g,isSelected:c,onItemTextChange:h.useCallback(w=>{p(S=>S||((w==null?void 0:w.textContent)??"").trim())},[]),children:u.jsx(Zs.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:u.jsx(be.div,{role:"option","aria-labelledby":g,"data-highlighted":m?"":void 0,"aria-selected":c&&m,"data-state":c?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:v,onFocus:ie(i.onFocus,()=>f(!0)),onBlur:ie(i.onBlur,()=>f(!1)),onClick:ie(i.onClick,()=>{x.current!=="mouse"&&y()}),onPointerUp:ie(i.onPointerUp,()=>{x.current==="mouse"&&y()}),onPointerDown:ie(i.onPointerDown,w=>{x.current=w.pointerType}),onPointerMove:ie(i.onPointerMove,w=>{var S;x.current=w.pointerType,o?(S=l.onItemLeave)==null||S.call(l):x.current==="mouse"&&w.currentTarget.focus({preventScroll:!0})}),onPointerLeave:ie(i.onPointerLeave,w=>{var S;w.currentTarget===document.activeElement&&((S=l.onItemLeave)==null||S.call(l))}),onKeyDown:ie(i.onKeyDown,w=>{var k;((k=l.searchRef)==null?void 0:k.current)!==""&&w.key===" "||(bk.includes(w.key)&&y(),w.key===" "&&w.preventDefault())})})})})});Im.displayName=ti;var ko="SelectItemText",Nm=h.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=Un(ko,n),a=Wn(ko,n),l=Em(ko,n),c=Tk(ko,n),[d,p]=h.useState(null),m=De(t,y=>p(y),l.onItemTextChange,y=>{var w;return(w=a.itemTextRefCallback)==null?void 0:w.call(a,y,l.value,l.disabled)}),f=d==null?void 0:d.textContent,v=h.useMemo(()=>u.jsx("option",{value:l.value,disabled:l.disabled,children:f},l.value),[l.disabled,l.value,f]),{onNativeOptionAdd:g,onNativeOptionRemove:x}=c;return kt(()=>(g(v),()=>x(v)),[g,x,v]),u.jsxs(u.Fragment,{children:[u.jsx(be.span,{id:l.textId,...s,ref:m}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?Lr.createPortal(s.children,i.valueNode):null]})});Nm.displayName=ko;var Am="SelectItemIndicator",jm=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return Em(Am,n).isSelected?u.jsx(be.span,{"aria-hidden":!0,...r,ref:t}):null});jm.displayName=Am;var Ml="SelectScrollUpButton",_m=h.forwardRef((e,t)=>{const n=Wn(Ml,e.__scopeSelect),r=_l(Ml,e.__scopeSelect),[o,s]=h.useState(!1),i=De(t,r.onScrollButtonChange);return kt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const c=l.scrollTop>0;s(c)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?u.jsx(Mm,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});_m.displayName=Ml;var Rl="SelectScrollDownButton",Pm=h.forwardRef((e,t)=>{const n=Wn(Rl,e.__scopeSelect),r=_l(Rl,e.__scopeSelect),[o,s]=h.useState(!1),i=De(t,r.onScrollButtonChange);return kt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const c=l.scrollHeight-l.clientHeight,d=Math.ceil(l.scrollTop)<c;s(d)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?u.jsx(Mm,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});Pm.displayName=Rl;var Mm=h.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=Wn("SelectScrollButton",n),i=h.useRef(null),a=Qs(n),l=h.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return h.useEffect(()=>()=>l(),[l]),kt(()=>{var d;const c=a().find(p=>p.ref.current===document.activeElement);(d=c==null?void 0:c.ref.current)==null||d.scrollIntoView({block:"nearest"})},[a]),u.jsx(be.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:ie(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:ie(o.onPointerMove,()=>{var c;(c=s.onItemLeave)==null||c.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:ie(o.onPointerLeave,()=>{l()})})}),Dk="SelectSeparator",Rm=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return u.jsx(be.div,{"aria-hidden":!0,...r,ref:t})});Rm.displayName=Dk;var Ol="SelectArrow",Lk=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=ei(n),s=Un(Ol,n),i=Wn(Ol,n);return s.open&&i.position==="popper"?u.jsx(ra,{...o,...r,ref:t}):null});Lk.displayName=Ol;var $k="SelectBubbleInput",Om=h.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=h.useRef(null),s=De(r,o),i=cm(t);return h.useEffect(()=>{const a=o.current;if(!a)return;const l=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(l,"value").set;if(i!==t&&d){const p=new Event("change",{bubbles:!0});d.call(a,t),a.dispatchEvent(p)}},[i,t]),u.jsx(be.select,{...n,style:{...um,...n.style},ref:s,defaultValue:t})});Om.displayName=$k;function Dm(e){return e===""||e===void 0}function Lm(e){const t=mt(e),n=h.useRef(""),r=h.useRef(0),o=h.useCallback(i=>{const a=n.current+i;t(a),function l(c){n.current=c,window.clearTimeout(r.current),c!==""&&(r.current=window.setTimeout(()=>l(""),1e3))}(a)},[t]),s=h.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return h.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function $m(e,t,n){const o=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=Fk(e,Math.max(s,0));o.length===1&&(i=i.filter(c=>c!==n));const l=i.find(c=>c.textValue.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function Fk(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Bk=dm,Fm=pm,zk=mm,Hk=gm,Uk=xm,Bm=vm,Wk=Sm,zm=km,Hm=Im,Vk=Nm,Kk=jm,Um=_m,Wm=Pm,Vm=Rm;const qk=Bk,Gk=zk,Km=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Fm,{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(Hk,{asChild:!0,children:u.jsx(ue.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));Km.displayName=Fm.displayName;const qm=h.forwardRef(({className:e,...t},n)=>u.jsx(Um,{ref:n,className:ne("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(ue.ChevronUp,{className:"h-4 w-4"})}));qm.displayName=Um.displayName;const Gm=h.forwardRef(({className:e,...t},n)=>u.jsx(Wm,{ref:n,className:ne("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(ue.ChevronDown,{className:"h-4 w-4"})}));Gm.displayName=Wm.displayName;const Ym=h.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>u.jsx(Uk,{children:u.jsxs(Bm,{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(qm,{}),u.jsx(Wk,{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(Gm,{})]})}));Ym.displayName=Bm.displayName;const Yk=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}));Yk.displayName=zm.displayName;const Xm=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Hm,{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(Kk,{children:u.jsx(ue.Check,{className:"h-4 w-4"})})}),u.jsx(Vk,{children:t})]}));Xm.displayName=Hm.displayName;const Xk=h.forwardRef(({className:e,...t},n)=>u.jsx(Vm,{ref:n,className:ne("-mx-1 my-1 h-px bg-muted",e),...t}));Xk.displayName=Vm.displayName;var Jk="Separator",Jm="horizontal",Zk=["horizontal","vertical"],Zm=h.forwardRef((e,t)=>{const{decorative:n,orientation:r=Jm,...o}=e,s=Qk(r)?r:Jm,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return u.jsx(be.div,{"data-orientation":s,...a,...o,ref:t})});Zm.displayName=Jk;function Qk(e){return Zk.includes(e)}var Qm=Zm;const eg=h.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>u.jsx(Qm,{ref:o,decorative:n,orientation:t,className:ne("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));eg.displayName=Qm.displayName;var ni="Switch",[eE,u1]=sn(ni),[tE,nE]=eE(ni),tg=h.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:s,required:i,disabled:a,value:l="on",onCheckedChange:c,form:d,...p}=e,[m,f]=h.useState(null),v=De(t,S=>f(S)),g=h.useRef(!1),x=m?d||!!m.closest("form"):!0,[y,w]=_n({prop:o,defaultProp:s??!1,onChange:c,caller:ni});return u.jsxs(tE,{scope:n,checked:y,disabled:a,children:[u.jsx(be.button,{type:"button",role:"switch","aria-checked":y,"aria-required":i,"data-state":sg(y),"data-disabled":a?"":void 0,disabled:a,value:l,...p,ref:v,onClick:ie(e.onClick,S=>{w(k=>!k),x&&(g.current=S.isPropagationStopped(),g.current||S.stopPropagation())})}),x&&u.jsx(og,{control:m,bubbles:!g.current,name:r,value:l,checked:y,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});tg.displayName=ni;var ng="SwitchThumb",rg=h.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=nE(ng,n);return u.jsx(be.span,{"data-state":sg(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});rg.displayName=ng;var rE="SwitchBubbleInput",og=h.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=h.useRef(null),a=De(i,s),l=cm(n),c=hd(t);return h.useEffect(()=>{const d=i.current;if(!d)return;const p=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(p,"checked").set;if(l!==n&&f){const v=new Event("click",{bubbles:r});f.call(d,n),d.dispatchEvent(v)}},[l,n,r]),u.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:a,style:{...o.style,...c,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});og.displayName=rE;function sg(e){return e?"checked":"unchecked"}var ig=tg,oE=rg;const ag=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(oE,{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")})}));ag.displayName=ig.displayName;const sE=qa,iE=JC,aE=Ga,lg=h.forwardRef(({className:e,...t},n)=>u.jsx(wo,{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}));lg.displayName=wo.displayName;const lE=Dr.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"}}),cg=h.forwardRef(({side:e="right",className:t,children:n,...r},o)=>u.jsxs(aE,{children:[u.jsx(lg,{}),u.jsxs(bo,{ref:o,className:ne(lE({side:e}),t),...r,children:[n,u.jsxs(eh,{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(ue.X,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));cg.displayName=bo.displayName;const ug=({className:e,...t})=>u.jsx("div",{className:ne("flex flex-col space-y-2 text-center sm:text-left",e),...t});ug.displayName="SheetHeader";const dg=h.forwardRef(({className:e,...t},n)=>u.jsx(rr,{ref:n,className:ne("text-lg font-semibold text-foreground",e),...t}));dg.displayName=rr.displayName;const fg=h.forwardRef(({className:e,...t},n)=>u.jsx(Os,{ref:n,className:ne("text-sm text-muted-foreground",e),...t}));fg.displayName=Os.displayName;var[ri,d1]=sn("Tooltip",[yr]),oi=yr(),pg="TooltipProvider",cE=700,Dl="tooltip.open",[uE,Ll]=ri(pg),hg=e=>{const{__scopeTooltip:t,delayDuration:n=cE,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:s}=e,i=h.useRef(!0),a=h.useRef(!1),l=h.useRef(0);return h.useEffect(()=>{const c=l.current;return()=>window.clearTimeout(c)},[]),u.jsx(uE,{scope:t,isOpenDelayedRef:i,delayDuration:n,onOpen:h.useCallback(()=>{window.clearTimeout(l.current),i.current=!1},[]),onClose:h.useCallback(()=>{window.clearTimeout(l.current),l.current=window.setTimeout(()=>i.current=!0,r)},[r]),isPointerInTransitRef:a,onPointerInTransitChange:h.useCallback(c=>{a.current=c},[]),disableHoverableContent:o,children:s})};hg.displayName=pg;var Eo="Tooltip",[dE,si]=ri(Eo),mg=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:s,disableHoverableContent:i,delayDuration:a}=e,l=Ll(Eo,e.__scopeTooltip),c=oi(t),[d,p]=h.useState(null),m=Nt(),f=h.useRef(0),v=i??l.disableHoverableContent,g=a??l.delayDuration,x=h.useRef(!1),[y,w]=_n({prop:r,defaultProp:o??!1,onChange:E=>{E?(l.onOpen(),document.dispatchEvent(new CustomEvent(Dl))):l.onClose(),s==null||s(E)},caller:Eo}),S=h.useMemo(()=>y?x.current?"delayed-open":"instant-open":"closed",[y]),k=h.useCallback(()=>{window.clearTimeout(f.current),f.current=0,x.current=!1,w(!0)},[w]),C=h.useCallback(()=>{window.clearTimeout(f.current),f.current=0,w(!1)},[w]),T=h.useCallback(()=>{window.clearTimeout(f.current),f.current=window.setTimeout(()=>{x.current=!0,w(!0),f.current=0},g)},[g,w]);return h.useEffect(()=>()=>{f.current&&(window.clearTimeout(f.current),f.current=0)},[]),u.jsx(ea,{...c,children:u.jsx(dE,{scope:t,contentId:m,open:y,stateAttribute:S,trigger:d,onTriggerChange:p,onTriggerEnter:h.useCallback(()=>{l.isOpenDelayedRef.current?T():k()},[l.isOpenDelayedRef,T,k]),onTriggerLeave:h.useCallback(()=>{v?C():(window.clearTimeout(f.current),f.current=0)},[C,v]),onOpen:k,onClose:C,disableHoverableContent:v,children:n})})};mg.displayName=Eo;var $l="TooltipTrigger",gg=h.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=si($l,n),s=Ll($l,n),i=oi(n),a=h.useRef(null),l=De(t,a,o.onTriggerChange),c=h.useRef(!1),d=h.useRef(!1),p=h.useCallback(()=>c.current=!1,[]);return h.useEffect(()=>()=>document.removeEventListener("pointerup",p),[p]),u.jsx(ta,{asChild:!0,...i,children:u.jsx(be.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:l,onPointerMove:ie(e.onPointerMove,m=>{m.pointerType!=="touch"&&!d.current&&!s.isPointerInTransitRef.current&&(o.onTriggerEnter(),d.current=!0)}),onPointerLeave:ie(e.onPointerLeave,()=>{o.onTriggerLeave(),d.current=!1}),onPointerDown:ie(e.onPointerDown,()=>{o.open&&o.onClose(),c.current=!0,document.addEventListener("pointerup",p,{once:!0})}),onFocus:ie(e.onFocus,()=>{c.current||o.onOpen()}),onBlur:ie(e.onBlur,o.onClose),onClick:ie(e.onClick,o.onClose)})})});gg.displayName=$l;var fE="TooltipPortal",[f1,pE]=ri(fE,{forceMount:void 0}),Rr="TooltipContent",xg=h.forwardRef((e,t)=>{const n=pE(Rr,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...s}=e,i=si(Rr,e.__scopeTooltip);return u.jsx(Ft,{present:r||i.open,children:i.disableHoverableContent?u.jsx(vg,{side:o,...s,ref:t}):u.jsx(hE,{side:o,...s,ref:t})})}),hE=h.forwardRef((e,t)=>{const n=si(Rr,e.__scopeTooltip),r=Ll(Rr,e.__scopeTooltip),o=h.useRef(null),s=De(t,o),[i,a]=h.useState(null),{trigger:l,onClose:c}=n,d=o.current,{onPointerInTransitChange:p}=r,m=h.useCallback(()=>{a(null),p(!1)},[p]),f=h.useCallback((v,g)=>{const x=v.currentTarget,y={x:v.clientX,y:v.clientY},w=wE(y,x.getBoundingClientRect()),S=bE(y,w),k=yE(g.getBoundingClientRect()),C=CE([...S,...k]);a(C),p(!0)},[p]);return h.useEffect(()=>()=>m(),[m]),h.useEffect(()=>{if(l&&d){const v=x=>f(x,d),g=x=>f(x,l);return l.addEventListener("pointerleave",v),d.addEventListener("pointerleave",g),()=>{l.removeEventListener("pointerleave",v),d.removeEventListener("pointerleave",g)}}},[l,d,f,m]),h.useEffect(()=>{if(i){const v=g=>{const x=g.target,y={x:g.clientX,y:g.clientY},w=(l==null?void 0:l.contains(x))||(d==null?void 0:d.contains(x)),S=!SE(y,i);w?m():S&&(m(),c())};return document.addEventListener("pointermove",v),()=>document.removeEventListener("pointermove",v)}},[l,d,i,c,m]),u.jsx(vg,{...e,ref:s})}),[mE,gE]=ri(Eo,{isInside:!1}),xE=Vt.createSlottable("TooltipContent"),vg=h.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:s,onPointerDownOutside:i,...a}=e,l=si(Rr,n),c=oi(n),{onClose:d}=l;return h.useEffect(()=>(document.addEventListener(Dl,d),()=>document.removeEventListener(Dl,d)),[d]),h.useEffect(()=>{if(l.trigger){const p=m=>{const f=m.target;f!=null&&f.contains(l.trigger)&&d()};return window.addEventListener("scroll",p,{capture:!0}),()=>window.removeEventListener("scroll",p,{capture:!0})}},[l.trigger,d]),u.jsx(gr,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:p=>p.preventDefault(),onDismiss:d,children:u.jsxs(na,{"data-state":l.stateAttribute,...c,...a,ref:t,style:{...a.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[u.jsx(xE,{children:r}),u.jsx(mE,{scope:n,isInside:!0,children:u.jsx(vk,{id:l.contentId,role:"tooltip",children:o||r})})]})})});xg.displayName=Rr;var wg="TooltipArrow",vE=h.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=oi(n);return gE(wg,n).isInside?null:u.jsx(ra,{...o,...r,ref:t})});vE.displayName=wg;function wE(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 bE(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 yE(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 SE(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const a=t[s],l=t[i],c=a.x,d=a.y,p=l.x,m=l.y;d>r!=m>r&&n<(p-c)*(r-d)/(m-d)+c&&(o=!o)}return o}function CE(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),TE(t)}function TE(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 kE=hg,EE=mg,IE=gg,bg=xg;const NE=kE,AE=EE,jE=IE,yg=h.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(bg,{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}));yg.displayName=bg.displayName;var Fl="ToastProvider",[Bl,_E,PE]=Vo("Toast"),[Sg,p1]=sn("Toast",[PE]),[ME,ii]=Sg(Fl),Cg=e=>{const{__scopeToast:t,label:n="Notification",duration:r=5e3,swipeDirection:o="right",swipeThreshold:s=50,children:i}=e,[a,l]=h.useState(null),[c,d]=h.useState(0),p=h.useRef(!1),m=h.useRef(!1);return n.trim()||console.error(`Invalid prop \`label\` supplied to \`${Fl}\`. Expected non-empty \`string\`.`),u.jsx(Bl.Provider,{scope:t,children:u.jsx(ME,{scope:t,label:n,duration:r,swipeDirection:o,swipeThreshold:s,toastCount:c,viewport:a,onViewportChange:l,onToastAdd:h.useCallback(()=>d(f=>f+1),[]),onToastRemove:h.useCallback(()=>d(f=>f-1),[]),isFocusedToastEscapeKeyDownRef:p,isClosePausedRef:m,children:i})})};Cg.displayName=Fl;var Tg="ToastViewport",RE=["F8"],zl="toast.viewportPause",Hl="toast.viewportResume",kg=h.forwardRef((e,t)=>{const{__scopeToast:n,hotkey:r=RE,label:o="Notifications ({hotkey})",...s}=e,i=ii(Tg,n),a=_E(n),l=h.useRef(null),c=h.useRef(null),d=h.useRef(null),p=h.useRef(null),m=De(t,p,i.onViewportChange),f=r.join("+").replace(/Key/g,"").replace(/Digit/g,""),v=i.toastCount>0;h.useEffect(()=>{const x=y=>{var S;r.length!==0&&r.every(k=>y[k]||y.code===k)&&((S=p.current)==null||S.focus())};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[r]),h.useEffect(()=>{const x=l.current,y=p.current;if(v&&x&&y){const w=()=>{if(!i.isClosePausedRef.current){const T=new CustomEvent(zl);y.dispatchEvent(T),i.isClosePausedRef.current=!0}},S=()=>{if(i.isClosePausedRef.current){const T=new CustomEvent(Hl);y.dispatchEvent(T),i.isClosePausedRef.current=!1}},k=T=>{!x.contains(T.relatedTarget)&&S()},C=()=>{x.contains(document.activeElement)||S()};return x.addEventListener("focusin",w),x.addEventListener("focusout",k),x.addEventListener("pointermove",w),x.addEventListener("pointerleave",C),window.addEventListener("blur",w),window.addEventListener("focus",S),()=>{x.removeEventListener("focusin",w),x.removeEventListener("focusout",k),x.removeEventListener("pointermove",w),x.removeEventListener("pointerleave",C),window.removeEventListener("blur",w),window.removeEventListener("focus",S)}}},[v,i.isClosePausedRef]);const g=h.useCallback(({tabbingDirection:x})=>{const w=a().map(S=>{const k=S.ref.current,C=[k,...qE(k)];return x==="forwards"?C:C.reverse()});return(x==="forwards"?w.reverse():w).flat()},[a]);return h.useEffect(()=>{const x=p.current;if(x){const y=w=>{var C,T,E;const S=w.altKey||w.ctrlKey||w.metaKey;if(w.key==="Tab"&&!S){const _=document.activeElement,R=w.shiftKey;if(w.target===x&&R){(C=c.current)==null||C.focus();return}const K=g({tabbingDirection:R?"backwards":"forwards"}),B=K.findIndex(I=>I===_);Vl(K.slice(B+1))?w.preventDefault():R?(T=c.current)==null||T.focus():(E=d.current)==null||E.focus()}};return x.addEventListener("keydown",y),()=>x.removeEventListener("keydown",y)}},[a,g]),u.jsxs(kw,{ref:l,role:"region","aria-label":o.replace("{hotkey}",f),tabIndex:-1,style:{pointerEvents:v?void 0:"none"},children:[v&&u.jsx(Ul,{ref:c,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"forwards"});Vl(x)}}),u.jsx(Bl.Slot,{scope:n,children:u.jsx(be.ol,{tabIndex:-1,...s,ref:m})}),v&&u.jsx(Ul,{ref:d,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"backwards"});Vl(x)}})]})});kg.displayName=Tg;var Eg="ToastFocusProxy",Ul=h.forwardRef((e,t)=>{const{__scopeToast:n,onFocusFromOutsideViewport:r,...o}=e,s=ii(Eg,n);return u.jsx(Js,{tabIndex:0,...o,ref:t,style:{position:"fixed"},onFocus:i=>{var c;const a=i.relatedTarget;!((c=s.viewport)!=null&&c.contains(a))&&r()}})});Ul.displayName=Eg;var Io="Toast",OE="toast.swipeStart",DE="toast.swipeMove",LE="toast.swipeCancel",$E="toast.swipeEnd",Ig=h.forwardRef((e,t)=>{const{forceMount:n,open:r,defaultOpen:o,onOpenChange:s,...i}=e,[a,l]=_n({prop:r,defaultProp:o??!0,onChange:s,caller:Io});return u.jsx(Ft,{present:n||a,children:u.jsx(zE,{open:a,...i,ref:t,onClose:()=>l(!1),onPause:mt(e.onPause),onResume:mt(e.onResume),onSwipeStart:ie(e.onSwipeStart,c=>{c.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:ie(e.onSwipeMove,c=>{const{x:d,y:p}=c.detail.delta;c.currentTarget.setAttribute("data-swipe","move"),c.currentTarget.style.setProperty("--radix-toast-swipe-move-x",`${d}px`),c.currentTarget.style.setProperty("--radix-toast-swipe-move-y",`${p}px`)}),onSwipeCancel:ie(e.onSwipeCancel,c=>{c.currentTarget.setAttribute("data-swipe","cancel"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),c.currentTarget.style.removeProperty("--radix-toast-swipe-end-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-end-y")}),onSwipeEnd:ie(e.onSwipeEnd,c=>{const{x:d,y:p}=c.detail.delta;c.currentTarget.setAttribute("data-swipe","end"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),c.currentTarget.style.setProperty("--radix-toast-swipe-end-x",`${d}px`),c.currentTarget.style.setProperty("--radix-toast-swipe-end-y",`${p}px`),l(!1)})})})});Ig.displayName=Io;var[FE,BE]=Sg(Io,{onClose(){}}),zE=h.forwardRef((e,t)=>{const{__scopeToast:n,type:r="foreground",duration:o,open:s,onClose:i,onEscapeKeyDown:a,onPause:l,onResume:c,onSwipeStart:d,onSwipeMove:p,onSwipeCancel:m,onSwipeEnd:f,...v}=e,g=ii(Io,n),[x,y]=h.useState(null),w=De(t,I=>y(I)),S=h.useRef(null),k=h.useRef(null),C=o||g.duration,T=h.useRef(0),E=h.useRef(C),_=h.useRef(0),{onToastAdd:R,onToastRemove:L}=g,H=mt(()=>{var W;(x==null?void 0:x.contains(document.activeElement))&&((W=g.viewport)==null||W.focus()),i()}),K=h.useCallback(I=>{!I||I===1/0||(window.clearTimeout(_.current),T.current=new Date().getTime(),_.current=window.setTimeout(H,I))},[H]);h.useEffect(()=>{const I=g.viewport;if(I){const W=()=>{K(E.current),c==null||c()},N=()=>{const U=new Date().getTime()-T.current;E.current=E.current-U,window.clearTimeout(_.current),l==null||l()};return I.addEventListener(zl,N),I.addEventListener(Hl,W),()=>{I.removeEventListener(zl,N),I.removeEventListener(Hl,W)}}},[g.viewport,C,l,c,K]),h.useEffect(()=>{s&&!g.isClosePausedRef.current&&K(C)},[s,C,g.isClosePausedRef,K]),h.useEffect(()=>(R(),()=>L()),[R,L]);const B=h.useMemo(()=>x?Rg(x):null,[x]);return g.viewport?u.jsxs(u.Fragment,{children:[B&&u.jsx(HE,{__scopeToast:n,role:"status","aria-live":r==="foreground"?"assertive":"polite",children:B}),u.jsx(FE,{scope:n,onClose:H,children:Lr.createPortal(u.jsx(Bl.ItemSlot,{scope:n,children:u.jsx(Tw,{asChild:!0,onEscapeKeyDown:ie(a,()=>{g.isFocusedToastEscapeKeyDownRef.current||H(),g.isFocusedToastEscapeKeyDownRef.current=!1}),children:u.jsx(be.li,{tabIndex:0,"data-state":s?"open":"closed","data-swipe-direction":g.swipeDirection,...v,ref:w,style:{userSelect:"none",touchAction:"none",...e.style},onKeyDown:ie(e.onKeyDown,I=>{I.key==="Escape"&&(a==null||a(I.nativeEvent),I.nativeEvent.defaultPrevented||(g.isFocusedToastEscapeKeyDownRef.current=!0,H()))}),onPointerDown:ie(e.onPointerDown,I=>{I.button===0&&(S.current={x:I.clientX,y:I.clientY})}),onPointerMove:ie(e.onPointerMove,I=>{if(!S.current)return;const W=I.clientX-S.current.x,N=I.clientY-S.current.y,U=!!k.current,O=["left","right"].includes(g.swipeDirection),j=["left","up"].includes(g.swipeDirection)?Math.min:Math.max,q=O?j(0,W):0,J=O?0:j(0,N),P=I.pointerType==="touch"?10:2,M={x:q,y:J},G={originalEvent:I,delta:M};U?(k.current=M,ai(DE,p,G,{discrete:!1})):Og(M,g.swipeDirection,P)?(k.current=M,ai(OE,d,G,{discrete:!1}),I.target.setPointerCapture(I.pointerId)):(Math.abs(W)>P||Math.abs(N)>P)&&(S.current=null)}),onPointerUp:ie(e.onPointerUp,I=>{const W=k.current,N=I.target;if(N.hasPointerCapture(I.pointerId)&&N.releasePointerCapture(I.pointerId),k.current=null,S.current=null,W){const U=I.currentTarget,O={originalEvent:I,delta:W};Og(W,g.swipeDirection,g.swipeThreshold)?ai($E,f,O,{discrete:!0}):ai(LE,m,O,{discrete:!0}),U.addEventListener("click",j=>j.preventDefault(),{once:!0})}})})})}),g.viewport)})]}):null}),HE=e=>{const{__scopeToast:t,children:n,...r}=e,o=ii(Io,t),[s,i]=h.useState(!1),[a,l]=h.useState(!1);return VE(()=>i(!0)),h.useEffect(()=>{const c=window.setTimeout(()=>l(!0),1e3);return()=>window.clearTimeout(c)},[]),a?null:u.jsx(eo,{asChild:!0,children:u.jsx(Js,{...r,children:s&&u.jsxs(u.Fragment,{children:[o.label," ",n]})})})},UE="ToastTitle",Ng=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(be.div,{...r,ref:t})});Ng.displayName=UE;var WE="ToastDescription",Ag=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(be.div,{...r,ref:t})});Ag.displayName=WE;var jg="ToastAction",_g=h.forwardRef((e,t)=>{const{altText:n,...r}=e;return n.trim()?u.jsx(Mg,{altText:n,asChild:!0,children:u.jsx(Wl,{...r,ref:t})}):(console.error(`Invalid prop \`altText\` supplied to \`${jg}\`. Expected non-empty \`string\`.`),null)});_g.displayName=jg;var Pg="ToastClose",Wl=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e,o=BE(Pg,n);return u.jsx(Mg,{asChild:!0,children:u.jsx(be.button,{type:"button",...r,ref:t,onClick:ie(e.onClick,o.onClose)})})});Wl.displayName=Pg;var Mg=h.forwardRef((e,t)=>{const{__scopeToast:n,altText:r,...o}=e;return u.jsx(be.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":r||void 0,...o,ref:t})});function Rg(e){const t=[];return Array.from(e.childNodes).forEach(r=>{if(r.nodeType===r.TEXT_NODE&&r.textContent&&t.push(r.textContent),KE(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(...Rg(r))}}),t}function ai(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?Oi(o,s):o.dispatchEvent(s)}var Og=(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 VE(e=()=>{}){const t=mt(e);kt(()=>{let n=0,r=0;return n=window.requestAnimationFrame(()=>r=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(n),window.cancelAnimationFrame(r)}},[t])}function KE(e){return e.nodeType===e.ELEMENT_NODE}function qE(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 Vl(e){const t=document.activeElement;return e.some(n=>n===t?!0:(n.focus(),document.activeElement!==t))}var GE=Cg,Dg=kg,Lg=Ig,$g=Ng,Fg=Ag,Bg=_g,zg=Wl;const YE=GE,Hg=h.forwardRef(({className:e,...t},n)=>u.jsx(Dg,{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}));Hg.displayName=Dg.displayName;const XE=Dr.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"}}),Ug=h.forwardRef(({className:e,variant:t,...n},r)=>u.jsx(Lg,{ref:r,className:ne(XE({variant:t}),e),...n}));Ug.displayName=Lg.displayName;const JE=h.forwardRef(({className:e,...t},n)=>u.jsx(Bg,{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}));JE.displayName=Bg.displayName;const Wg=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(ue.X,{className:"h-4 w-4"})}));Wg.displayName=zg.displayName;const Vg=h.forwardRef(({className:e,...t},n)=>u.jsx($g,{ref:n,className:ne("text-sm font-semibold",e),...t}));Vg.displayName=$g.displayName;const Kg=h.forwardRef(({className:e,...t},n)=>u.jsx(Fg,{ref:n,className:ne("text-sm opacity-90",e),...t}));Kg.displayName=Fg.displayName;function ZE(){const{toasts:e}=Za();return u.jsxs(YE,{children:[e.map(function({id:t,title:n,description:r,action:o,...s}){return u.jsxs(Ug,{...s,children:[u.jsxs("div",{className:"grid gap-1",children:[n&&u.jsx(Vg,{children:n}),r&&u.jsx(Kg,{children:r})]}),o,u.jsx(Wg,{})]},t)}),u.jsx(Hg,{})]})}var QE=(e,t,n,r,o,s,i,a)=>{let l=document.documentElement,c=["light","dark"];function d(f){(Array.isArray(e)?e:[e]).forEach(v=>{let g=v==="class",x=g&&s?o.map(y=>s[y]||y):o;g?(l.classList.remove(...x),l.classList.add(s&&s[f]?s[f]:f)):l.setAttribute(v,f)}),p(f)}function p(f){a&&c.includes(f)&&(l.style.colorScheme=f)}function m(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}if(r)d(r);else try{let f=localStorage.getItem(t)||n,v=i&&f==="system"?m():f;d(v)}catch{}},eI=h.createContext(void 0),tI={setTheme:e=>{},themes:[]},nI=()=>{var e;return(e=h.useContext(eI))!=null?e:tI};h.memo(({forcedTheme:e,storageKey:t,attribute:n,enableSystem:r,enableColorScheme:o,defaultTheme:s,value:i,themes:a,nonce:l,scriptProps:c})=>{let d=JSON.stringify([n,t,s,e,a,i,r,o]).slice(1,-1);return h.createElement("script",{...c,suppressHydrationWarning:!0,nonce:typeof window>"u"?l:"",dangerouslySetInnerHTML:{__html:`(${QE.toString()})(${d})`}})});var rI=e=>{switch(e){case"success":return iI;case"info":return lI;case"warning":return aI;case"error":return cI;default:return null}},oI=Array(12).fill(0),sI=({visible:e,className:t})=>b.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},b.createElement("div",{className:"sonner-spinner"},oI.map((n,r)=>b.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),iI=b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},b.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),aI=b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},b.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),lI=b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},b.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),cI=b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},b.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),uI=b.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},b.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),b.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),dI=()=>{let[e,t]=b.useState(document.hidden);return b.useEffect(()=>{let n=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),e},Kl=1,fI=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:Kl++,s=this.toasts.find(a=>a.id===o),i=e.dismissible===void 0?!0:e.dismissible;return this.dismissedToasts.has(o)&&this.dismissedToasts.delete(o),s?this.toasts=this.toasts.map(a=>a.id===o?(this.publish({...a,...e,id:o,title:n}),{...a,...e,id:o,dismissible:i,title:n}):a):this.addToast({title:n,...r,dismissible:i,id:o}),o},this.dismiss=e=>(this.dismissedToasts.add(e),e||this.toasts.forEach(t=>{this.subscribers.forEach(n=>n({id:t.id,dismiss:!0}))}),this.subscribers.forEach(t=>t({id:e,dismiss:!0})),e),this.message=(e,t)=>this.create({...t,message:e}),this.error=(e,t)=>this.create({...t,message:e,type:"error"}),this.success=(e,t)=>this.create({...t,type:"success",message:e}),this.info=(e,t)=>this.create({...t,type:"info",message:e}),this.warning=(e,t)=>this.create({...t,type:"warning",message:e}),this.loading=(e,t)=>this.create({...t,type:"loading",message:e}),this.promise=(e,t)=>{if(!t)return;let n;t.loading!==void 0&&(n=this.create({...t,promise:e,type:"loading",message:t.loading,description:typeof t.description!="function"?t.description:void 0}));let r=e instanceof Promise?e:e(),o=n!==void 0,s,i=r.then(async l=>{if(s=["resolve",l],b.isValidElement(l))o=!1,this.create({id:n,type:"default",message:l});else if(hI(l)&&!l.ok){o=!1;let c=typeof t.error=="function"?await t.error(`HTTP error! status: ${l.status}`):t.error,d=typeof t.description=="function"?await t.description(`HTTP error! status: ${l.status}`):t.description;this.create({id:n,type:"error",message:c,description:d})}else if(t.success!==void 0){o=!1;let c=typeof t.success=="function"?await t.success(l):t.success,d=typeof t.description=="function"?await t.description(l):t.description;this.create({id:n,type:"success",message:c,description:d})}}).catch(async l=>{if(s=["reject",l],t.error!==void 0){o=!1;let c=typeof t.error=="function"?await t.error(l):t.error,d=typeof t.description=="function"?await t.description(l):t.description;this.create({id:n,type:"error",message:c,description:d})}}).finally(()=>{var l;o&&(this.dismiss(n),n=void 0),(l=t.finally)==null||l.call(t)}),a=()=>new Promise((l,c)=>i.then(()=>s[0]==="reject"?c(s[1]):l(s[1])).catch(c));return typeof n!="string"&&typeof n!="number"?{unwrap:a}:Object.assign(n,{unwrap:a})},this.custom=(e,t)=>{let n=(t==null?void 0:t.id)||Kl++;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}},Ht=new fI,pI=(e,t)=>{let n=(t==null?void 0:t.id)||Kl++;return Ht.addToast({title:e,...t,id:n}),n},hI=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",mI=pI,gI=()=>Ht.toasts,xI=()=>Ht.getActiveToasts();Object.assign(mI,{success:Ht.success,info:Ht.info,warning:Ht.warning,error:Ht.error,custom:Ht.custom,message:Ht.message,promise:Ht.promise,dismiss:Ht.dismiss,loading:Ht.loading},{getHistory:gI,getToasts:xI});function vI(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))}vI(`:where(html[dir="ltr"]),:where([data-sonner-toaster][dir="ltr"]){--toast-icon-margin-start: -3px;--toast-icon-margin-end: 4px;--toast-svg-margin-start: -1px;--toast-svg-margin-end: 0px;--toast-button-margin-start: auto;--toast-button-margin-end: 0;--toast-close-button-start: 0;--toast-close-button-end: unset;--toast-close-button-transform: translate(-35%, -35%)}:where(html[dir="rtl"]),:where([data-sonner-toaster][dir="rtl"]){--toast-icon-margin-start: 4px;--toast-icon-margin-end: -3px;--toast-svg-margin-start: 0px;--toast-svg-margin-end: -1px;--toast-button-margin-start: 0;--toast-button-margin-end: auto;--toast-close-button-start: unset;--toast-close-button-end: 0;--toast-close-button-transform: translate(35%, -35%)}:where([data-sonner-toaster]){position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1: hsl(0, 0%, 99%);--gray2: hsl(0, 0%, 97.3%);--gray3: hsl(0, 0%, 95.1%);--gray4: hsl(0, 0%, 93%);--gray5: hsl(0, 0%, 90.9%);--gray6: hsl(0, 0%, 88.7%);--gray7: hsl(0, 0%, 85.8%);--gray8: hsl(0, 0%, 78%);--gray9: hsl(0, 0%, 56.1%);--gray10: hsl(0, 0%, 52.3%);--gray11: hsl(0, 0%, 43.5%);--gray12: hsl(0, 0%, 9%);--border-radius: 8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:none;z-index:999999999;transition:transform .4s ease}:where([data-sonner-toaster][data-lifted="true"]){transform:translateY(-10px)}@media (hover: none) and (pointer: coarse){:where([data-sonner-toaster][data-lifted="true"]){transform:none}}:where([data-sonner-toaster][data-x-position="right"]){right:var(--offset-right)}:where([data-sonner-toaster][data-x-position="left"]){left:var(--offset-left)}:where([data-sonner-toaster][data-x-position="center"]){left:50%;transform:translate(-50%)}:where([data-sonner-toaster][data-y-position="top"]){top:var(--offset-top)}:where([data-sonner-toaster][data-y-position="bottom"]){bottom:var(--offset-bottom)}:where([data-sonner-toast]){--y: translateY(100%);--lift-amount: calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);filter:blur(0);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:none;overflow-wrap:anywhere}:where([data-sonner-toast][data-styled="true"]){padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px #0000001a;width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}:where([data-sonner-toast]:focus-visible){box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast][data-y-position="top"]){top:0;--y: translateY(-100%);--lift: 1;--lift-amount: calc(1 * var(--gap))}:where([data-sonner-toast][data-y-position="bottom"]){bottom:0;--y: translateY(100%);--lift: -1;--lift-amount: calc(var(--lift) * var(--gap))}:where([data-sonner-toast]) :where([data-description]){font-weight:400;line-height:1.4;color:inherit}:where([data-sonner-toast]) :where([data-title]){font-weight:500;line-height:1.5;color:inherit}:where([data-sonner-toast]) :where([data-icon]){display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}:where([data-sonner-toast][data-promise="true"]) :where([data-icon])>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}:where([data-sonner-toast]) :where([data-icon])>*{flex-shrink:0}:where([data-sonner-toast]) :where([data-icon]) svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}:where([data-sonner-toast]) :where([data-content]){display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;cursor:pointer;outline:none;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}:where([data-sonner-toast]) :where([data-button]):focus-visible{box-shadow:0 0 0 2px #0006}:where([data-sonner-toast]) :where([data-button]):first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}:where([data-sonner-toast]) :where([data-cancel]){color:var(--normal-text);background:rgba(0,0,0,.08)}:where([data-sonner-toast][data-theme="dark"]) :where([data-cancel]){background:rgba(255,255,255,.3)}:where([data-sonner-toast]) :where([data-close-button]){position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast] [data-close-button]{background:var(--gray1)}:where([data-sonner-toast]) :where([data-close-button]):focus-visible{box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast]) :where([data-disabled="true"]){cursor:not-allowed}:where([data-sonner-toast]):hover :where([data-close-button]):hover{background:var(--gray2);border-color:var(--gray5)}:where([data-sonner-toast][data-swiping="true"]):before{content:"";position:absolute;left:-50%;right:-50%;height:100%;z-index:-1}:where([data-sonner-toast][data-y-position="top"][data-swiping="true"]):before{bottom:50%;transform:scaleY(3) translateY(50%)}:where([data-sonner-toast][data-y-position="bottom"][data-swiping="true"]):before{top:50%;transform:scaleY(3) translateY(-50%)}:where([data-sonner-toast][data-swiping="false"][data-removed="true"]):before{content:"";position:absolute;inset:0;transform:scaleY(2)}:where([data-sonner-toast]):after{content:"";position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}:where([data-sonner-toast][data-mounted="true"]){--y: translateY(0);opacity:1}:where([data-sonner-toast][data-expanded="false"][data-front="false"]){--scale: var(--toasts-before) * .05 + 1;--y: translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}:where([data-sonner-toast])>*{transition:opacity .4s}:where([data-sonner-toast][data-expanded="false"][data-front="false"][data-styled="true"])>*{opacity:0}:where([data-sonner-toast][data-visible="false"]){opacity:0;pointer-events:none}:where([data-sonner-toast][data-mounted="true"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}:where([data-sonner-toast][data-removed="true"][data-front="true"][data-swipe-out="false"]){--y: translateY(calc(var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="false"]){--y: translateY(40%);opacity:0;transition:transform .5s,opacity .2s}:where([data-sonner-toast][data-removed="true"][data-front="false"]):before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y, 0px)) translate(var(--swipe-amount-x, 0px));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width: 600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-theme=light]{--normal-bg: #fff;--normal-border: var(--gray4);--normal-text: var(--gray12);--success-bg: hsl(143, 85%, 96%);--success-border: hsl(145, 92%, 91%);--success-text: hsl(140, 100%, 27%);--info-bg: hsl(208, 100%, 97%);--info-border: hsl(221, 91%, 91%);--info-text: hsl(210, 92%, 45%);--warning-bg: hsl(49, 100%, 97%);--warning-border: hsl(49, 91%, 91%);--warning-text: hsl(31, 92%, 45%);--error-bg: hsl(359, 100%, 97%);--error-border: hsl(359, 100%, 94%);--error-text: hsl(360, 100%, 45%)}[data-sonner-toaster][data-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg: #000;--normal-border: hsl(0, 0%, 20%);--normal-text: var(--gray1)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg: #fff;--normal-border: var(--gray3);--normal-text: var(--gray12)}[data-sonner-toaster][data-theme=dark]{--normal-bg: #000;--normal-bg-hover: hsl(0, 0%, 12%);--normal-border: hsl(0, 0%, 20%);--normal-border-hover: hsl(0, 0%, 25%);--normal-text: var(--gray1);--success-bg: hsl(150, 100%, 6%);--success-border: hsl(147, 100%, 12%);--success-text: hsl(150, 86%, 65%);--info-bg: hsl(215, 100%, 6%);--info-border: hsl(223, 100%, 12%);--info-text: hsl(216, 87%, 65%);--warning-bg: hsl(64, 100%, 6%);--warning-border: hsl(60, 100%, 12%);--warning-text: hsl(46, 87%, 65%);--error-bg: hsl(358, 76%, 10%);--error-border: hsl(357, 89%, 16%);--error-text: hsl(358, 100%, 81%)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success],[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info],[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning],[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error],[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size: 16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:nth-child(1){animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}to{opacity:.15}}@media (prefers-reduced-motion){[data-sonner-toast],[data-sonner-toast]>*,.sonner-loading-bar{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}
130
+ `);function li(e){return e.label!==void 0}var wI=3,bI="32px",yI="16px",qg=4e3,SI=356,CI=14,TI=20,kI=200;function pn(...e){return e.filter(Boolean).join(" ")}function EI(e){let[t,n]=e.split("-"),r=[];return t&&r.push(t),n&&r.push(n),r}var II=e=>{var t,n,r,o,s,i,a,l,c,d,p;let{invert:m,toast:f,unstyled:v,interacting:g,setHeights:x,visibleToasts:y,heights:w,index:S,toasts:k,expanded:C,removeToast:T,defaultRichColors:E,closeButton:_,style:R,cancelButtonStyle:L,actionButtonStyle:H,className:K="",descriptionClassName:B="",duration:I,position:W,gap:N,loadingIcon:U,expandByDefault:O,classNames:j,icons:q,closeButtonAriaLabel:J="Close toast",pauseWhenPageIsHidden:P}=e,[M,G]=b.useState(null),[Z,se]=b.useState(null),[V,D]=b.useState(!1),[X,Q]=b.useState(!1),[ae,$]=b.useState(!1),[re,we]=b.useState(!1),[de,xe]=b.useState(!1),[Ee,Be]=b.useState(0),[We,je]=b.useState(0),Ve=b.useRef(f.duration||I||qg),Xe=b.useRef(null),ze=b.useRef(null),Ge=S===0,rt=S+1<=y,nt=f.type,et=f.dismissible!==!1,xt=f.className||"",vt=f.descriptionClassName||"",dt=b.useMemo(()=>w.findIndex(Ce=>Ce.toastId===f.id)||0,[w,f.id]),Et=b.useMemo(()=>{var Ce;return(Ce=f.closeButton)!=null?Ce:_},[f.closeButton,_]),Dt=b.useMemo(()=>f.duration||I||qg,[f.duration,I]),$e=b.useRef(0),Pt=b.useRef(0),nn=b.useRef(0),Me=b.useRef(null),[Ke,Ct]=W.split("-"),Ze=b.useMemo(()=>w.reduce((Ce,Oe,qe)=>qe>=dt?Ce:Ce+Oe.height,0),[w,dt]),pt=dI(),le=f.invert||m,Y=nt==="loading";Pt.current=b.useMemo(()=>dt*N+Ze,[dt,Ze]),b.useEffect(()=>{Ve.current=Dt},[Dt]),b.useEffect(()=>{D(!0)},[]),b.useEffect(()=>{let Ce=ze.current;if(Ce){let Oe=Ce.getBoundingClientRect().height;return je(Oe),x(qe=>[{toastId:f.id,height:Oe,position:f.position},...qe]),()=>x(qe=>qe.filter(Tt=>Tt.toastId!==f.id))}},[x,f.id]),b.useLayoutEffect(()=>{if(!V)return;let Ce=ze.current,Oe=Ce.style.height;Ce.style.height="auto";let qe=Ce.getBoundingClientRect().height;Ce.style.height=Oe,je(qe),x(Tt=>Tt.find(He=>He.toastId===f.id)?Tt.map(He=>He.toastId===f.id?{...He,height:qe}:He):[{toastId:f.id,height:qe,position:f.position},...Tt])},[V,f.title,f.description,x,f.id]);let ge=b.useCallback(()=>{Q(!0),Be(Pt.current),x(Ce=>Ce.filter(Oe=>Oe.toastId!==f.id)),setTimeout(()=>{T(f)},kI)},[f,T,x,Pt]);b.useEffect(()=>{if(f.promise&&nt==="loading"||f.duration===1/0||f.type==="loading")return;let Ce;return C||g||P&&pt?(()=>{if(nn.current<$e.current){let Oe=new Date().getTime()-$e.current;Ve.current=Ve.current-Oe}nn.current=new Date().getTime()})():Ve.current!==1/0&&($e.current=new Date().getTime(),Ce=setTimeout(()=>{var Oe;(Oe=f.onAutoClose)==null||Oe.call(f,f),ge()},Ve.current)),()=>clearTimeout(Ce)},[C,g,f,nt,P,pt,ge]),b.useEffect(()=>{f.delete&&ge()},[ge,f.delete]);function it(){var Ce,Oe,qe;return q!=null&&q.loading?b.createElement("div",{className:pn(j==null?void 0:j.loader,(Ce=f==null?void 0:f.classNames)==null?void 0:Ce.loader,"sonner-loader"),"data-visible":nt==="loading"},q.loading):U?b.createElement("div",{className:pn(j==null?void 0:j.loader,(Oe=f==null?void 0:f.classNames)==null?void 0:Oe.loader,"sonner-loader"),"data-visible":nt==="loading"},U):b.createElement(sI,{className:pn(j==null?void 0:j.loader,(qe=f==null?void 0:f.classNames)==null?void 0:qe.loader),visible:nt==="loading"})}return b.createElement("li",{tabIndex:0,ref:ze,className:pn(K,xt,j==null?void 0:j.toast,(t=f==null?void 0:f.classNames)==null?void 0:t.toast,j==null?void 0:j.default,j==null?void 0:j[nt],(n=f==null?void 0:f.classNames)==null?void 0:n[nt]),"data-sonner-toast":"","data-rich-colors":(r=f.richColors)!=null?r:E,"data-styled":!(f.jsx||f.unstyled||v),"data-mounted":V,"data-promise":!!f.promise,"data-swiped":de,"data-removed":X,"data-visible":rt,"data-y-position":Ke,"data-x-position":Ct,"data-index":S,"data-front":Ge,"data-swiping":ae,"data-dismissible":et,"data-type":nt,"data-invert":le,"data-swipe-out":re,"data-swipe-direction":Z,"data-expanded":!!(C||O&&V),style:{"--index":S,"--toasts-before":S,"--z-index":k.length-S,"--offset":`${X?Ee:Pt.current}px`,"--initial-height":O?"auto":`${We}px`,...R,...f.style},onDragEnd:()=>{$(!1),G(null),Me.current=null},onPointerDown:Ce=>{Y||!et||(Xe.current=new Date,Be(Pt.current),Ce.target.setPointerCapture(Ce.pointerId),Ce.target.tagName!=="BUTTON"&&($(!0),Me.current={x:Ce.clientX,y:Ce.clientY}))},onPointerUp:()=>{var Ce,Oe,qe,Tt;if(re||!et)return;Me.current=null;let He=Number(((Ce=ze.current)==null?void 0:Ce.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),ft=Number(((Oe=ze.current)==null?void 0:Oe.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),Fe=new Date().getTime()-((qe=Xe.current)==null?void 0:qe.getTime()),tt=M==="x"?He:ft,Ut=Math.abs(tt)/Fe;if(Math.abs(tt)>=TI||Ut>.11){Be(Pt.current),(Tt=f.onDismiss)==null||Tt.call(f,f),se(M==="x"?He>0?"right":"left":ft>0?"down":"up"),ge(),we(!0),xe(!1);return}$(!1),G(null)},onPointerMove:Ce=>{var Oe,qe,Tt,He;if(!Me.current||!et||((Oe=window.getSelection())==null?void 0:Oe.toString().length)>0)return;let ft=Ce.clientY-Me.current.y,Fe=Ce.clientX-Me.current.x,tt=(qe=e.swipeDirections)!=null?qe:EI(W);!M&&(Math.abs(Fe)>1||Math.abs(ft)>1)&&G(Math.abs(Fe)>Math.abs(ft)?"x":"y");let Ut={x:0,y:0};M==="y"?(tt.includes("top")||tt.includes("bottom"))&&(tt.includes("top")&&ft<0||tt.includes("bottom")&&ft>0)&&(Ut.y=ft):M==="x"&&(tt.includes("left")||tt.includes("right"))&&(tt.includes("left")&&Fe<0||tt.includes("right")&&Fe>0)&&(Ut.x=Fe),(Math.abs(Ut.x)>0||Math.abs(Ut.y)>0)&&xe(!0),(Tt=ze.current)==null||Tt.style.setProperty("--swipe-amount-x",`${Ut.x}px`),(He=ze.current)==null||He.style.setProperty("--swipe-amount-y",`${Ut.y}px`)}},Et&&!f.jsx?b.createElement("button",{"aria-label":J,"data-disabled":Y,"data-close-button":!0,onClick:Y||!et?()=>{}:()=>{var Ce;ge(),(Ce=f.onDismiss)==null||Ce.call(f,f)},className:pn(j==null?void 0:j.closeButton,(o=f==null?void 0:f.classNames)==null?void 0:o.closeButton)},(s=q==null?void 0:q.close)!=null?s:uI):null,f.jsx||b.isValidElement(f.title)?f.jsx?f.jsx:typeof f.title=="function"?f.title():f.title:b.createElement(b.Fragment,null,nt||f.icon||f.promise?b.createElement("div",{"data-icon":"",className:pn(j==null?void 0:j.icon,(i=f==null?void 0:f.classNames)==null?void 0:i.icon)},f.promise||f.type==="loading"&&!f.icon?f.icon||it():null,f.type!=="loading"?f.icon||(q==null?void 0:q[nt])||rI(nt):null):null,b.createElement("div",{"data-content":"",className:pn(j==null?void 0:j.content,(a=f==null?void 0:f.classNames)==null?void 0:a.content)},b.createElement("div",{"data-title":"",className:pn(j==null?void 0:j.title,(l=f==null?void 0:f.classNames)==null?void 0:l.title)},typeof f.title=="function"?f.title():f.title),f.description?b.createElement("div",{"data-description":"",className:pn(B,vt,j==null?void 0:j.description,(c=f==null?void 0:f.classNames)==null?void 0:c.description)},typeof f.description=="function"?f.description():f.description):null),b.isValidElement(f.cancel)?f.cancel:f.cancel&&li(f.cancel)?b.createElement("button",{"data-button":!0,"data-cancel":!0,style:f.cancelButtonStyle||L,onClick:Ce=>{var Oe,qe;li(f.cancel)&&et&&((qe=(Oe=f.cancel).onClick)==null||qe.call(Oe,Ce),ge())},className:pn(j==null?void 0:j.cancelButton,(d=f==null?void 0:f.classNames)==null?void 0:d.cancelButton)},f.cancel.label):null,b.isValidElement(f.action)?f.action:f.action&&li(f.action)?b.createElement("button",{"data-button":!0,"data-action":!0,style:f.actionButtonStyle||H,onClick:Ce=>{var Oe,qe;li(f.action)&&((qe=(Oe=f.action).onClick)==null||qe.call(Oe,Ce),!Ce.defaultPrevented&&ge())},className:pn(j==null?void 0:j.actionButton,(p=f==null?void 0:f.classNames)==null?void 0:p.actionButton)},f.action.label):null))};function Gg(){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 NI(e,t){let n={};return[e,t].forEach((r,o)=>{let s=o===1,i=s?"--mobile-offset":"--offset",a=s?yI:bI;function l(c){["top","right","bottom","left"].forEach(d=>{n[`${i}-${d}`]=typeof c=="number"?`${c}px`:c})}typeof r=="number"||typeof r=="string"?l(r):typeof r=="object"?["top","right","bottom","left"].forEach(c=>{r[c]===void 0?n[`${i}-${c}`]=a:n[`${i}-${c}`]=typeof r[c]=="number"?`${r[c]}px`:r[c]}):l(a)}),n}var AI=b.forwardRef(function(e,t){let{invert:n,position:r="bottom-right",hotkey:o=["altKey","KeyT"],expand:s,closeButton:i,className:a,offset:l,mobileOffset:c,theme:d="light",richColors:p,duration:m,style:f,visibleToasts:v=wI,toastOptions:g,dir:x=Gg(),gap:y=CI,loadingIcon:w,icons:S,containerAriaLabel:k="Notifications",pauseWhenPageIsHidden:C}=e,[T,E]=b.useState([]),_=b.useMemo(()=>Array.from(new Set([r].concat(T.filter(P=>P.position).map(P=>P.position)))),[T,r]),[R,L]=b.useState([]),[H,K]=b.useState(!1),[B,I]=b.useState(!1),[W,N]=b.useState(d!=="system"?d:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),U=b.useRef(null),O=o.join("+").replace(/Key/g,"").replace(/Digit/g,""),j=b.useRef(null),q=b.useRef(!1),J=b.useCallback(P=>{E(M=>{var G;return(G=M.find(Z=>Z.id===P.id))!=null&&G.delete||Ht.dismiss(P.id),M.filter(({id:Z})=>Z!==P.id)})},[]);return b.useEffect(()=>Ht.subscribe(P=>{if(P.dismiss){E(M=>M.map(G=>G.id===P.id?{...G,delete:!0}:G));return}setTimeout(()=>{No.flushSync(()=>{E(M=>{let G=M.findIndex(Z=>Z.id===P.id);return G!==-1?[...M.slice(0,G),{...M[G],...P},...M.slice(G+1)]:[P,...M]})})})}),[]),b.useEffect(()=>{if(d!=="system"){N(d);return}if(d==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?N("dark"):N("light")),typeof window>"u")return;let P=window.matchMedia("(prefers-color-scheme: dark)");try{P.addEventListener("change",({matches:M})=>{N(M?"dark":"light")})}catch{P.addListener(({matches:G})=>{try{N(G?"dark":"light")}catch(Z){console.error(Z)}})}},[d]),b.useEffect(()=>{T.length<=1&&K(!1)},[T]),b.useEffect(()=>{let P=M=>{var G,Z;o.every(se=>M[se]||M.code===se)&&(K(!0),(G=U.current)==null||G.focus()),M.code==="Escape"&&(document.activeElement===U.current||(Z=U.current)!=null&&Z.contains(document.activeElement))&&K(!1)};return document.addEventListener("keydown",P),()=>document.removeEventListener("keydown",P)},[o]),b.useEffect(()=>{if(U.current)return()=>{j.current&&(j.current.focus({preventScroll:!0}),j.current=null,q.current=!1)}},[U.current]),b.createElement("section",{ref:t,"aria-label":`${k} ${O}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},_.map((P,M)=>{var G;let[Z,se]=P.split("-");return T.length?b.createElement("ol",{key:P,dir:x==="auto"?Gg():x,tabIndex:-1,ref:U,className:a,"data-sonner-toaster":!0,"data-theme":W,"data-y-position":Z,"data-lifted":H&&T.length>1&&!s,"data-x-position":se,style:{"--front-toast-height":`${((G=R[0])==null?void 0:G.height)||0}px`,"--width":`${SI}px`,"--gap":`${y}px`,...f,...NI(l,c)},onBlur:V=>{q.current&&!V.currentTarget.contains(V.relatedTarget)&&(q.current=!1,j.current&&(j.current.focus({preventScroll:!0}),j.current=null))},onFocus:V=>{V.target instanceof HTMLElement&&V.target.dataset.dismissible==="false"||q.current||(q.current=!0,j.current=V.relatedTarget)},onMouseEnter:()=>K(!0),onMouseMove:()=>K(!0),onMouseLeave:()=>{B||K(!1)},onDragEnd:()=>K(!1),onPointerDown:V=>{V.target instanceof HTMLElement&&V.target.dataset.dismissible==="false"||I(!0)},onPointerUp:()=>I(!1)},T.filter(V=>!V.position&&M===0||V.position===P).map((V,D)=>{var X,Q;return b.createElement(II,{key:V.id,icons:S,index:D,toast:V,defaultRichColors:p,duration:(X=g==null?void 0:g.duration)!=null?X: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:B,position:P,style:g==null?void 0:g.style,unstyled:g==null?void 0:g.unstyled,classNames:g==null?void 0:g.classNames,cancelButtonStyle:g==null?void 0:g.cancelButtonStyle,actionButtonStyle:g==null?void 0:g.actionButtonStyle,removeToast:J,toasts:T.filter(ae=>ae.position==V.position),heights:R.filter(ae=>ae.position==V.position),setHeights:L,expandByDefault:s,gap:y,loadingIcon:w,expanded:H,pauseWhenPageIsHidden:C,swipeDirections:e.swipeDirections})})):null}))});const jI=({...e})=>{const{theme:t="system"}=nI();return u.jsx(AI,{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})};F.Api=jv,F.ApiClient=Av,F.ApiProvider=nu,F.ArtifactRenderer=wh,F.Badge=Lp,F.Button=at,F.Card=tl,F.CardContent=sl,F.CardDescription=ol,F.CardHeader=nl,F.CardTitle=rl,F.ChatApi=Ho,F.ChatApp=pk,F.ChatInput=$f,F.ChatInterface=So,F.ChatProviders=Xr,F.Command=gl,F.CommandEmpty=wl,F.CommandGroup=bl,F.CommandInput=xl,F.CommandItem=yl,F.CommandList=vl,F.DEFAULT_TIMEOUT_MS=Xc,F.Dialog=Ya,F.DialogContent=Ds,F.DialogHeader=Ls,F.DialogTitle=$s,F.DropdownMenu=vs,F.DropdownMenuContent=ao,F.DropdownMenuItem=On,F.DropdownMenuTrigger=ws,F.FileViewerModal=rh,F.HISTORY_TIMEOUT_MS=Jc,F.Input=Nl,F.InterruptPartRenderer=yh,F.Label=lm,F.MarkdownContent=Ar,F.MessageBody=Eh,F.MessageComponent=Vs,F.MessageList=cl,F.MessageRow=ll,F.PlotArtifact=xh,F.ResearchTaskArtifact=vh,F.SETTINGS_STORAGE_KEY=Ri,F.ScrollArea=Il,F.Select=qk,F.SelectContent=Ym,F.SelectItem=Xm,F.SelectTrigger=Km,F.SelectValue=Gk,F.Separator=eg,F.Sheet=sE,F.SheetContent=cg,F.SheetDescription=fg,F.SheetHeader=ug,F.SheetTitle=dg,F.SheetTrigger=iE,F.SimpleChat=hk,F.SimpleJsonView=il,F.Sonner=jI,F.StreamProgress=Sh,F.Switch=ag,F.Textarea=ba,F.ThinkingIndicator=Th,F.ThreadListItem=nm,F.ThreadManager=Al,F.ThreadStateProvider=Cu,F.ThreadsProvider=lu,F.TimelineColumn=ix,F.Toaster=ZE,F.ToolComponent=Ch,F.Tooltip=AE,F.TooltipContent=yg,F.TooltipProvider=NE,F.TooltipTrigger=jE,F.UserTextContent=kh,F.applySettings=lw,F.buildAttemptMaps=Ql,F.buildCheckpointIndex=tc,F.buildCheckpointPreviewMap=ex,F.chatApiClient=An,F.del=ki,F.downloadFileById=Qc,F.extractConfigFields=di,F.fileToBase64=ru,F.get=qt,F.getChatToken=Gc,F.getCurrentSettings=aw,F.getDefaultApiConfig=Au,F.getDefaultChatSettings=ju,F.getFileContent=Ii,F.getFileInfo=Pv,F.getMessageDomKey=al,F.getPreviewForMessage=ui,F.httpClient=Kt,F.hydrateHistorySnapshots=Nn,F.isEnvelope=su,F.listFiles=eu,F.loadStoredSettings=_u,F.onChatTokenChanged=Yc,F.post=zo,F.processAttachments=ou,F.put=Zc,F.readNumber=rc,F.readString=Vn,F.resolveChatBaseUrl=mn,F.resolveMessageMetadata=Jl,F.saveSettings=Pu,F.setChatToken=Bo,F.toPlainObject=cr,F.unwrap=Mt,F.useApi=Vr,F.useCheckpointIndex=nc,F.useFilePreview=Ih,F.useHasChatSession=sw,F.useMessageMetadata=Zl,F.useParsedMessageContent=Nh,F.useStream=Mi,F.useStreamingHook=Mi,F.useThreadHistoryState=wu,F.useThreadManagerViewState=sm,F.useThreadState=Yr,F.useThreadStateUpdater=Su,F.useThreads=pr,F.useThreadsState=iu,F.viewFileById=_v,Object.defineProperty(F,Symbol.toStringTag,{value:"Module"})});