teodor-new-chat-ui 4.3.404 → 4.3.406
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/features/core/contexts/index.d.ts +1 -0
- package/dist/features/core/contexts/providers/index.d.ts +1 -0
- package/dist/index.esm.js +1161 -1155
- package/dist/index.umd.js +32 -32
- package/package.json +17 -15
package/dist/index.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(K,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):(K=typeof globalThis<"u"?globalThis:K||self,b(K.NewChatUI={},K.React,K.reactSlot,K.classVarianceAuthority,K.clsx,K.tailwindMerge,K.ReactDOM,K.LucideReact))})(this,function(K,b,Vt,Or,Rg,Og,To,fe){"use strict";var II=Object.defineProperty;var NI=(K,b,Vt)=>b in K?II(K,b,{enumerable:!0,configurable:!0,writable:!0,value:Vt}):K[b]=Vt;var Pg=(K,b,Vt)=>NI(K,typeof b!="symbol"?b+"":b,Vt);function ql(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const h=ql(b),Dr=ql(To);function Gl(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 Yl(e,t){return b.useMemo(()=>Gl(e,t),[e,t])}function Xl(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 Jl=120;function Dg(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>Jl?`${n.slice(0,Jl-3)}…`:n:""}function ci(e){return Dg(e.content)||""}function Lg(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=ci(o);s&&t.set(r.checkpointId,s)}}return t}function Zl(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=ci(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}=Xl(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 Ql(e){return b.useMemo(()=>Zl(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 ec(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 ui(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)=>$g(s,i)).filter(s=>!!s)].sort((s,i)=>tc(i.createdAt)-tc(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 $g(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=ui(e.config),i=cr(e.parent_config??e.parentConfig),a=ui(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:ec(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:Fg(r,t),metadata:y,config:f??null,parentConfig:i??null,next:g,tasks:v}}function Fg(e,t){return Bg(e,t)}function Bg(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 tc(e){if(!e)return 0;const t=Date.parse(e);return Number.isFinite(t)?t:0}var di={exports:{}},Lr={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.min.js
|
|
4
4
|
*
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var
|
|
9
|
+
*/var nc;function zg(){if(nc)return Lr;nc=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 Lr.Fragment=n,Lr.jsx=i,Lr.jsxs=i,Lr}var $r={};/**
|
|
10
10
|
* @license React
|
|
11
11
|
* react-jsx-runtime.development.js
|
|
12
12
|
*
|
|
@@ -14,7 +14,7 @@
|
|
|
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
|
|
17
|
+
*/var rc;function Hg(){return rc||(rc=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(I){if(I===null||typeof I!="object")return null;var ne=v&&I[v]||I[g];return typeof ne=="function"?ne:null}var y=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function w(I){{for(var ne=arguments.length,pe=new Array(ne>1?ne-1:0),je=1;je<ne;je++)pe[je-1]=arguments[je];S("error",I,pe)}}function S(I,ne,pe){{var je=y.ReactDebugCurrentFrame,ue=je.getStackAddendum();ue!==""&&(ne+="%s",pe=pe.concat([ue]));var be=pe.map(function(he){return String(he)});be.unshift("Warning: "+ne),Function.prototype.apply.call(console[I],console,be)}}var k=!1,C=!1,T=!1,E=!1,A=!1,O;O=Symbol.for("react.module.reference");function F(I){return!!(typeof I=="string"||typeof I=="function"||I===r||I===s||A||I===o||I===c||I===d||E||I===f||k||C||T||typeof I=="object"&&I!==null&&(I.$$typeof===m||I.$$typeof===p||I.$$typeof===i||I.$$typeof===a||I.$$typeof===l||I.$$typeof===O||I.getModuleId!==void 0))}function U(I,ne,pe){var je=I.displayName;if(je)return je;var ue=ne.displayName||ne.name||"";return ue!==""?pe+"("+ue+")":pe}function W(I){return I.displayName||"Context"}function z(I){if(I==null)return null;if(typeof I.tag=="number"&&w("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof I=="function")return I.displayName||I.name||null;if(typeof I=="string")return I;switch(I){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 I=="object")switch(I.$$typeof){case a:var ne=I;return W(ne)+".Consumer";case i:var pe=I;return W(pe._context)+".Provider";case l:return U(I,I.render,"ForwardRef");case p:var je=I.displayName||null;return je!==null?je:z(I.type)||"Memo";case m:{var ue=I,be=ue._payload,he=ue._init;try{return z(he(be))}catch{return null}}}return null}var N=Object.assign,q=0,M,Q,$,_,V,J,j;function R(){}R.__reactDisabledLog=!0;function G(){{if(q===0){M=console.log,Q=console.info,$=console.warn,_=console.error,V=console.group,J=console.groupCollapsed,j=console.groupEnd;var I={configurable:!0,enumerable:!0,value:R,writable:!0};Object.defineProperties(console,{info:I,log:I,warn:I,error:I,group:I,groupCollapsed:I,groupEnd:I})}q++}}function Y(){{if(q--,q===0){var I={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:N({},I,{value:M}),info:N({},I,{value:Q}),warn:N({},I,{value:$}),error:N({},I,{value:_}),group:N({},I,{value:V}),groupCollapsed:N({},I,{value:J}),groupEnd:N({},I,{value:j})})}q<0&&w("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var ie=y.ReactCurrentDispatcher,H;function D(I,ne,pe){{if(H===void 0)try{throw Error()}catch(ue){var je=ue.stack.trim().match(/\n( *(at )?)/);H=je&&je[1]||""}return`
|
|
18
18
|
`+H+I}}var X=!1,Z;{var ce=typeof WeakMap=="function"?WeakMap:Map;Z=new ce}function L(I,ne){if(!I||X)return"";{var pe=Z.get(I);if(pe!==void 0)return pe}var je;X=!0;var ue=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var be;be=ie.current,ie.current=null,G();try{if(ne){var he=function(){throw Error()};if(Object.defineProperty(he.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(he,[])}catch(Wt){je=Wt}Reflect.construct(I,[],he)}else{try{he.call()}catch(Wt){je=Wt}I.call(he.prototype)}}else{try{throw Error()}catch(Wt){je=Wt}I()}}catch(Wt){if(Wt&&je&&typeof Wt.stack=="string"){for(var Ee=Wt.stack.split(`
|
|
19
19
|
`),Tt=je.stack.split(`
|
|
20
20
|
`),et=Ee.length-1,kt=Tt.length-1;et>=1&&kt>=0&&Ee[et]!==Tt[kt];)kt--;for(;et>=1&&kt>=0;et--,kt--)if(Ee[et]!==Tt[kt]){if(et!==1||kt!==1)do if(et--,kt--,kt<0||Ee[et]!==Tt[kt]){var rn=`
|
|
@@ -22,22 +22,22 @@
|
|
|
22
22
|
|
|
23
23
|
Check the render method of \``+I+"`."}return""}}function ve(I){return""}var ae={};function Ie(I){{var ne=te();if(!ne){var pe=typeof I=="string"?I:I.displayName||I.name;pe&&(ne=`
|
|
24
24
|
|
|
25
|
-
Check the top-level render call using <`+pe+">.")}return ne}}function Te(I,ne){{if(!I._store||I._store.validated||I.key!=null)return;I._store.validated=!0;var pe=Ie(ne);if(ae[pe])return;ae[pe]=!0;var je="";I&&I._owner&&I._owner!==St.current&&(je=" It was passed a child from "+z(I._owner.type)+"."),Ye(I),w('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',pe,je),Ye(null)}}function st(I,ne){{if(typeof I!="object")return;if(Ge(I))for(var pe=0;pe<I.length;pe++){var je=I[pe];P(je)&&Te(je,ne)}else if(P(I))I._store&&(I._store.validated=!0);else if(I){var ue=x(I);if(typeof ue=="function"&&ue!==I.entries)for(var be=ue.call(I),he;!(he=be.next()).done;)P(he.value)&&Te(he.value,ne)}}}function Ue(I){{var ne=I.type;if(ne==null||typeof ne=="string")return;var pe;if(typeof ne=="function")pe=ne.propTypes;else if(typeof ne=="object"&&(ne.$$typeof===l||ne.$$typeof===p))pe=ne.propTypes;else return;if(pe){var je=z(ne);Ae(pe,I.props,"prop",je,I)}else if(ne.PropTypes!==void 0&&!gt){gt=!0;var ue=z(ne);w("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",ue||"Unknown")}typeof ne.getDefaultProps=="function"&&!ne.getDefaultProps.isReactClassApproved&&w("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function lt(I){{for(var ne=Object.keys(I.props),pe=0;pe<ne.length;pe++){var je=ne[pe];if(je!=="children"&&je!=="key"){Ye(I),w("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",je),Ye(null);break}}I.ref!==null&&(Ye(I),w("Invalid attribute `ref` supplied to `React.Fragment`."),Ye(null))}}var Ut={};function Mt(I,ne,pe,je,ue,be){{var he=F(I);if(!he){var Ee="";(I===void 0||typeof I=="object"&&I!==null&&Object.keys(I).length===0)&&(Ee+=" 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 Tt=ve();Tt?Ee+=Tt:Ee+=te();var et;I===null?et="null":Ge(I)?et="array":I!==void 0&&I.$$typeof===t?(et="<"+(z(I.type)||"Unknown")+" />",Ee=" Did you accidentally export a JSX literal instead of a component?"):et=typeof I,w("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",et,Ee)}var kt=Be(I,ne,pe,ue,be);if(kt==null)return kt;if(he){var rn=ne.children;if(rn!==void 0)if(je)if(Ge(rn)){for(var Rr=0;Rr<rn.length;Rr++)st(rn[Rr],I);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 st(rn,I)}if(we.call(ne,"key")){var lr=z(I),Wt=Object.keys(ne).filter(function(
|
|
25
|
+
Check the top-level render call using <`+pe+">.")}return ne}}function Te(I,ne){{if(!I._store||I._store.validated||I.key!=null)return;I._store.validated=!0;var pe=Ie(ne);if(ae[pe])return;ae[pe]=!0;var je="";I&&I._owner&&I._owner!==St.current&&(je=" It was passed a child from "+z(I._owner.type)+"."),Ye(I),w('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',pe,je),Ye(null)}}function st(I,ne){{if(typeof I!="object")return;if(Ge(I))for(var pe=0;pe<I.length;pe++){var je=I[pe];P(je)&&Te(je,ne)}else if(P(I))I._store&&(I._store.validated=!0);else if(I){var ue=x(I);if(typeof ue=="function"&&ue!==I.entries)for(var be=ue.call(I),he;!(he=be.next()).done;)P(he.value)&&Te(he.value,ne)}}}function Ue(I){{var ne=I.type;if(ne==null||typeof ne=="string")return;var pe;if(typeof ne=="function")pe=ne.propTypes;else if(typeof ne=="object"&&(ne.$$typeof===l||ne.$$typeof===p))pe=ne.propTypes;else return;if(pe){var je=z(ne);Ae(pe,I.props,"prop",je,I)}else if(ne.PropTypes!==void 0&&!gt){gt=!0;var ue=z(ne);w("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",ue||"Unknown")}typeof ne.getDefaultProps=="function"&&!ne.getDefaultProps.isReactClassApproved&&w("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function lt(I){{for(var ne=Object.keys(I.props),pe=0;pe<ne.length;pe++){var je=ne[pe];if(je!=="children"&&je!=="key"){Ye(I),w("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",je),Ye(null);break}}I.ref!==null&&(Ye(I),w("Invalid attribute `ref` supplied to `React.Fragment`."),Ye(null))}}var Ut={};function Mt(I,ne,pe,je,ue,be){{var he=F(I);if(!he){var Ee="";(I===void 0||typeof I=="object"&&I!==null&&Object.keys(I).length===0)&&(Ee+=" 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 Tt=ve();Tt?Ee+=Tt:Ee+=te();var et;I===null?et="null":Ge(I)?et="array":I!==void 0&&I.$$typeof===t?(et="<"+(z(I.type)||"Unknown")+" />",Ee=" Did you accidentally export a JSX literal instead of a component?"):et=typeof I,w("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",et,Ee)}var kt=Be(I,ne,pe,ue,be);if(kt==null)return kt;if(he){var rn=ne.children;if(rn!==void 0)if(je)if(Ge(rn)){for(var Rr=0;Rr<rn.length;Rr++)st(rn[Rr],I);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 st(rn,I)}if(we.call(ne,"key")){var lr=z(I),Wt=Object.keys(ne).filter(function(EI){return EI!=="key"}),Kl=Wt.length>0?"{key: someKey, "+Wt.join(": ..., ")+": ...}":"{key: someKey}";if(!Ut[lr+Kl]){var kI=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} />`,Vl,lr,CI,lr),Ut[lr+Vl]=!0}}return I===r?lt(kt):Ue(kt),kt}}function nn(I,ne,pe){return Mt(I,ne,pe,!0)}function Ul(I,ne,pe){return Mt(I,ne,pe,!1)}var Wl=Ul,ii=nn;$r.Fragment=r,$r.jsx=Wl,$r.jsxs=ii}()),$r}process.env.NODE_ENV==="production"?ci.exports=zg():ci.exports=Hg();var u=ci.exports;const Ug=({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 rc(e,t){return function(){return e.apply(t,arguments)}}const{toString:Wg}=Object.prototype,{getPrototypeOf:ui}=Object,{iterator:ko,toStringTag:oc}=Symbol,Eo=(e=>t=>{const n=Wg.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),on=e=>(e=e.toLowerCase(),t=>Eo(t)===e),Io=e=>t=>typeof t===e,{isArray:ur}=Array,dr=Io("undefined");function Fr(e){return e!==null&&!dr(e)&&e.constructor!==null&&!dr(e.constructor)&&Lt(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const sc=on("ArrayBuffer");function Vg(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&sc(e.buffer),t}const Kg=Io("string"),Lt=Io("function"),ic=Io("number"),Br=e=>e!==null&&typeof e=="object",qg=e=>e===!0||e===!1,No=e=>{if(Eo(e)!=="object")return!1;const t=ui(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(oc in e)&&!(ko in e)},Gg=e=>{if(!Br(e)||Fr(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},Yg=on("Date"),Xg=on("File"),Jg=on("Blob"),Zg=on("FileList"),Qg=e=>Br(e)&&Lt(e.pipe),ex=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||Lt(e.append)&&((t=Eo(e))==="formdata"||t==="object"&&Lt(e.toString)&&e.toString()==="[object FormData]"))},tx=on("URLSearchParams"),[nx,rx,ox,sx]=["ReadableStream","Request","Response","Headers"].map(on),ix=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function zr(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(Fr(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 ac(e,t){if(Fr(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,lc=e=>!dr(e)&&e!==Kn;function di(){const{caseless:e,skipUndefined:t}=lc(this)&&this||{},n={},r=(o,s)=>{const i=e&&ac(n,s)||s;No(n[i])&&No(o)?n[i]=di(n[i],o):No(o)?n[i]=di({},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]&&zr(arguments[o],r);return n}const ax=(e,t,n,{allOwnKeys:r}={})=>(zr(t,(o,s)=>{n&&Lt(o)?e[s]=rc(o,n):e[s]=o},{allOwnKeys:r}),e),lx=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),cx=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},ux=(e,t,n,r)=>{let o,s,i;const a={};if(t=t||{},e==null)return t;do{for(o=Object.getOwnPropertyNames(e),s=o.length;s-- >0;)i=o[s],(!r||r(i,e,t))&&!a[i]&&(t[i]=e[i],a[i]=!0);e=n!==!1&&ui(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},dx=(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},fx=e=>{if(!e)return null;if(ur(e))return e;let t=e.length;if(!ic(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},px=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&ui(Uint8Array)),hx=(e,t)=>{const r=(e&&e[ko]).call(e);let o;for(;(o=r.next())&&!o.done;){const s=o.value;t.call(e,s[0],s[1])}},mx=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},gx=on("HTMLFormElement"),xx=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),cc=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),vx=on("RegExp"),uc=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};zr(n,(o,s)=>{let i;(i=t(o,s,e))!==!1&&(r[s]=i||o)}),Object.defineProperties(e,r)},wx=e=>{uc(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+"'")})}})},bx=(e,t)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return ur(e)?r(e):r(String(e).split(t)),n},yx=()=>{},Sx=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function Cx(e){return!!(e&&Lt(e.append)&&e[oc]==="FormData"&&e[ko])}const Tx=e=>{const t=new Array(10),n=(r,o)=>{if(Br(r)){if(t.indexOf(r)>=0)return;if(Fr(r))return r;if(!("toJSON"in r)){t[o]=r;const s=ur(r)?[]:{};return zr(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)},kx=on("AsyncFunction"),Ex=e=>e&&(Br(e)||Lt(e))&&Lt(e.then)&&Lt(e.catch),dc=((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)),Ix=typeof queueMicrotask<"u"?queueMicrotask.bind(Kn):typeof process<"u"&&process.nextTick||dc,B={isArray:ur,isArrayBuffer:sc,isBuffer:Fr,isFormData:ex,isArrayBufferView:Vg,isString:Kg,isNumber:ic,isBoolean:qg,isObject:Br,isPlainObject:No,isEmptyObject:Gg,isReadableStream:nx,isRequest:rx,isResponse:ox,isHeaders:sx,isUndefined:dr,isDate:Yg,isFile:Xg,isBlob:Jg,isRegExp:vx,isFunction:Lt,isStream:Qg,isURLSearchParams:tx,isTypedArray:px,isFileList:Zg,forEach:zr,merge:di,extend:ax,trim:ix,stripBOM:lx,inherits:cx,toFlatObject:ux,kindOf:Eo,kindOfTest:on,endsWith:dx,toArray:fx,forEachEntry:hx,matchAll:mx,isHTMLForm:gx,hasOwnProperty:cc,hasOwnProp:cc,reduceDescriptors:uc,freezeMethods:wx,toObjectSet:bx,toCamelCase:xx,noop:yx,toFiniteNumber:Sx,findKey:ac,global:Kn,isContextDefined:lc,isSpecCompliantForm:Cx,toJSONObject:Tx,isAsyncFn:kx,isThenable:Ex,setImmediate:dc,asap:Ix,isIterable:e=>e!=null&&Lt(e[ko])};function Le(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)}B.inherits(Le,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:B.toJSONObject(this.config),code:this.code,status:this.status}}});const fc=Le.prototype,pc={};["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=>{pc[e]={value:e}}),Object.defineProperties(Le,pc),Object.defineProperty(fc,"isAxiosError",{value:!0}),Le.from=(e,t,n,r,o,s)=>{const i=Object.create(fc);B.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 Le.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 Nx=null;function fi(e){return B.isPlainObject(e)||B.isArray(e)}function hc(e){return B.endsWith(e,"[]")?e.slice(0,-2):e}function mc(e,t,n){return e?e.concat(t).map(function(o,s){return o=hc(o),!n&&s?"["+o+"]":o}).join(n?".":""):t}function Ax(e){return B.isArray(e)&&!e.some(fi)}const _x=B.toFlatObject(B,{},null,function(t){return/^is[A-Z]/.test(t)});function Ao(e,t,n){if(!B.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=B.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(g,x){return!B.isUndefined(x[g])});const r=n.metaTokens,o=n.visitor||d,s=n.dots,i=n.indexes,l=(n.Blob||typeof Blob<"u"&&Blob)&&B.isSpecCompliantForm(t);if(!B.isFunction(o))throw new TypeError("visitor must be a function");function c(v){if(v===null)return"";if(B.isDate(v))return v.toISOString();if(B.isBoolean(v))return v.toString();if(!l&&B.isBlob(v))throw new Le("Blob is not supported. Use a Buffer instead.");return B.isArrayBuffer(v)||B.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(B.endsWith(g,"{}"))g=r?g:g.slice(0,-2),v=JSON.stringify(v);else if(B.isArray(v)&&Ax(v)||(B.isFileList(v)||B.endsWith(g,"[]"))&&(y=B.toArray(v)))return g=hc(g),y.forEach(function(S,k){!(B.isUndefined(S)||S===null)&&t.append(i===!0?mc([g],k,s):i===null?g:g+"[]",c(S))}),!1}return fi(v)?!0:(t.append(mc(x,g,s),c(v)),!1)}const p=[],m=Object.assign(_x,{defaultVisitor:d,convertValue:c,isVisitable:fi});function f(v,g){if(!B.isUndefined(v)){if(p.indexOf(v)!==-1)throw Error("Circular reference detected in "+g.join("."));p.push(v),B.forEach(v,function(y,w){(!(B.isUndefined(y)||y===null)&&o.call(t,y,B.isString(w)?w.trim():w,g,m))===!0&&f(y,g?g.concat(w):[w])}),p.pop()}}if(!B.isObject(e))throw new TypeError("data must be an object");return f(e),t}function gc(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function pi(e,t){this._pairs=[],e&&Ao(e,this,t)}const xc=pi.prototype;xc.append=function(t,n){this._pairs.push([t,n])},xc.toString=function(t){const n=t?function(r){return t.call(this,r,gc)}:gc;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function jx(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function vc(e,t,n){if(!t)return e;const r=n&&n.encode||jx;B.isFunction(n)&&(n={serialize:n});const o=n&&n.serialize;let s;if(o?s=o(t,n):s=B.isURLSearchParams(t)?t.toString():new pi(t,n).toString(r),s){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}class wc{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){B.forEach(this.handlers,function(r){r!==null&&t(r)})}}const bc={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Px={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:pi,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},hi=typeof window<"u"&&typeof document<"u",mi=typeof navigator=="object"&&navigator||void 0,Mx=hi&&(!mi||["ReactNative","NativeScript","NS"].indexOf(mi.product)<0),Rx=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Ox=hi&&window.location.href||"http://localhost",Nt={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:hi,hasStandardBrowserEnv:Mx,hasStandardBrowserWebWorkerEnv:Rx,navigator:mi,origin:Ox},Symbol.toStringTag,{value:"Module"})),...Px};function Dx(e,t){return Ao(e,new Nt.classes.URLSearchParams,{visitor:function(n,r,o,s){return Nt.isNode&&B.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function Lx(e){return B.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function $x(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 yc(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&&B.isArray(o)?o.length:i,l?(B.hasOwnProp(o,i)?o[i]=[o[i],r]:o[i]=r,!a):((!o[i]||!B.isObject(o[i]))&&(o[i]=[]),t(n,r,o[i],s)&&B.isArray(o[i])&&(o[i]=$x(o[i])),!a)}if(B.isFormData(e)&&B.isFunction(e.entries)){const n={};return B.forEachEntry(e,(r,o)=>{t(Lx(r),o,n,0)}),n}return null}function Fx(e,t,n){if(B.isString(e))try{return(t||JSON.parse)(e),B.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const Hr={transitional:bc,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",o=r.indexOf("application/json")>-1,s=B.isObject(t);if(s&&B.isHTMLForm(t)&&(t=new FormData(t)),B.isFormData(t))return o?JSON.stringify(yc(t)):t;if(B.isArrayBuffer(t)||B.isBuffer(t)||B.isStream(t)||B.isFile(t)||B.isBlob(t)||B.isReadableStream(t))return t;if(B.isArrayBufferView(t))return t.buffer;if(B.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 Dx(t,this.formSerializer).toString();if((a=B.isFileList(t))||r.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return Ao(a?{"files[]":t}:t,l&&new l,this.formSerializer)}}return s||o?(n.setContentType("application/json",!1),Fx(t)):t}],transformResponse:[function(t){const n=this.transitional||Hr.transitional,r=n&&n.forcedJSONParsing,o=this.responseType==="json";if(B.isResponse(t)||B.isReadableStream(t))return t;if(t&&B.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"?Le.from(a,Le.ERR_BAD_RESPONSE,this,null,this.response):a}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Nt.classes.FormData,Blob:Nt.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};B.forEach(["delete","get","head","post","put","patch"],e=>{Hr.headers[e]={}});const Bx=B.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"]),zx=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]&&Bx[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},
|
|
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[Sc]=this[Sc]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=Ur(i);r[a]||(Vx(o,i),r[a]=!0)}return B.isArray(t)?t.forEach(s):s(t),this}};$t.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),B.reduceDescriptors($t.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),B.freezeMethods($t);function xi(e,t){const n=this||Hr,r=t||n,o=$t.from(r.headers);let s=r.data;return B.forEach(e,function(a){s=a.call(n,s,o.normalize(),t?t.status:void 0)}),o.normalize(),s}function Cc(e){return!!(e&&e.__CANCEL__)}function fr(e,t,n){Le.call(this,e??"canceled",Le.ERR_CANCELED,t,n),this.name="CanceledError"}B.inherits(fr,Le,{__CANCEL__:!0});function Tc(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new Le("Request failed with status code "+n.status,[Le.ERR_BAD_REQUEST,Le.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function Kx(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function qx(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 Gx(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 jo=(e,t,n=3)=>{let r=0;const o=qx(50,250);return Gx(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)},kc=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},Ec=e=>(...t)=>B.asap(()=>e(...t)),Yx=Nt.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,Nt.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(Nt.origin),Nt.navigator&&/(msie|trident)/i.test(Nt.navigator.userAgent)):()=>!0,Xx=Nt.hasStandardBrowserEnv?{write(e,t,n,r,o,s){const i=[e+"="+encodeURIComponent(t)];B.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),B.isString(r)&&i.push("path="+r),B.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 Jx(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Zx(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function Ic(e,t,n){let r=!Jx(t);return e&&(r||n==!1)?Zx(e,t):t}const Nc=e=>e instanceof $t?{...e}:e;function qn(e,t){t=t||{};const n={};function r(c,d,p,m){return B.isPlainObject(c)&&B.isPlainObject(d)?B.merge.call({caseless:m},c,d):B.isPlainObject(d)?B.merge({},d):B.isArray(d)?d.slice():d}function o(c,d,p,m){if(B.isUndefined(d)){if(!B.isUndefined(c))return r(void 0,c,p,m)}else return r(c,d,p,m)}function s(c,d){if(!B.isUndefined(d))return r(void 0,d)}function i(c,d){if(B.isUndefined(d)){if(!B.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(Nc(c),Nc(d),p,!0)};return B.forEach(Object.keys({...e,...t}),function(d){const p=l[d]||o,m=p(e[d],t[d],d);B.isUndefined(m)&&p!==a||(n[d]=m)}),n}const Ac=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=vc(Ic(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&i.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),B.isFormData(n)){if(Nt.hasStandardBrowserEnv||Nt.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(B.isFunction(n.getHeaders)){const l=n.getHeaders(),c=["content-type","content-length"];Object.entries(l).forEach(([d,p])=>{c.includes(d.toLowerCase())&&i.set(d,p)})}}if(Nt.hasStandardBrowserEnv&&(r&&B.isFunction(r)&&(r=r(t)),r||r!==!1&&Yx(t.url))){const l=o&&s&&Xx.read(s);l&&i.set(o,l)}return t},Qx=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=Ac(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};Tc(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 Le("Request aborted",Le.ECONNABORTED,e,x)),x=null)},x.onerror=function(k){const C=k&&k.message?k.message:"Network Error",T=new Le(C,Le.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||bc;o.timeoutErrorMessage&&(k=o.timeoutErrorMessage),r(new Le(k,C.clarifyTimeoutError?Le.ETIMEDOUT:Le.ECONNABORTED,e,x)),x=null},s===void 0&&i.setContentType(null),"setRequestHeader"in x&&B.forEach(i.toJSON(),function(k,C){x.setRequestHeader(C,k)}),B.isUndefined(o.withCredentials)||(x.withCredentials=!!o.withCredentials),a&&a!=="json"&&(x.responseType=o.responseType),c&&([m,v]=jo(c,!0),x.addEventListener("progress",m)),l&&x.upload&&([p,f]=jo(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=Kx(o.url);if(w&&Nt.protocols.indexOf(w)===-1){r(new Le("Unsupported protocol "+w+":",Le.ERR_BAD_REQUEST,e));return}x.send(s||null)})},ev=(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 Le?d:new fr(d instanceof Error?d.message:d))}};let i=t&&setTimeout(()=>{i=null,s(new Le(`timeout ${t} of ms exceeded`,Le.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=()=>B.asap(a),l}},tv=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},nv=async function*(e,t){for await(const n of rv(e))yield*tv(n,t)},rv=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:n,value:r}=await t.read();if(n)break;yield r}}finally{await t.cancel()}},_c=(e,t,n,r)=>{const o=nv(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})},jc=64*1024,{isFunction:Po}=B,ov=(({Request:e,Response:t})=>({Request:e,Response:t}))(B.global),{ReadableStream:Pc,TextEncoder:Mc}=B.global,Rc=(e,...t)=>{try{return!!e(...t)}catch{return!1}},sv=e=>{e=B.merge.call({skipUndefined:!0},ov,e);const{fetch:t,Request:n,Response:r}=e,o=t?Po(t):typeof fetch=="function",s=Po(n),i=Po(r);if(!o)return!1;const a=o&&Po(Pc),l=o&&(typeof Mc=="function"?(v=>g=>v.encode(g))(new Mc):async v=>new Uint8Array(await new n(v).arrayBuffer())),c=s&&a&&Rc(()=>{let v=!1;const g=new n(Nt.origin,{body:new Pc,method:"POST",get duplex(){return v=!0,"half"}}).headers.has("Content-Type");return v&&!g}),d=i&&a&&Rc(()=>B.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 Le(`Response type '${v}' is not supported`,Le.ERR_NOT_SUPPORT,x)})});const m=async v=>{if(v==null)return 0;if(B.isBlob(v))return v.size;if(B.isSpecCompliantForm(v))return(await new n(Nt.origin,{method:"POST",body:v}).arrayBuffer()).byteLength;if(B.isArrayBufferView(v)||B.isArrayBuffer(v))return v.byteLength;if(B.isURLSearchParams(v)&&(v=v+""),B.isString(v))return(await l(v)).byteLength},f=async(v,g)=>{const x=B.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:A,withCredentials:O="same-origin",fetchOptions:F}=Ac(v),U=t||fetch;E=E?(E+"").toLowerCase():"text";let W=ev([w,S&&S.toAbortSignal()],k),z=null;const N=W&&W.unsubscribe&&(()=>{W.unsubscribe()});let K;try{if(T&&c&&x!=="get"&&x!=="head"&&(K=await f(A,y))!==0){let J=new n(g,{method:"POST",body:y,duplex:"half"}),j;if(B.isFormData(y)&&(j=J.headers.get("content-type"))&&A.setContentType(j),J.body){const[R,G]=kc(K,jo(Ec(T)));y=_c(J.body,jc,R,G)}}B.isString(O)||(O=O?"include":"omit");const M=s&&"credentials"in n.prototype,Q={...F,signal:W,method:x.toUpperCase(),headers:A.normalize().toJSON(),body:y,duplex:"half",credentials:M?O:void 0};z=s&&new n(g,Q);let $=await(s?U(z,F):U(g,Q));const _=d&&(E==="stream"||E==="response");if(d&&(C||_&&N)){const J={};["status","statusText","headers"].forEach(Y=>{J[Y]=$[Y]});const j=B.toFiniteNumber($.headers.get("content-length")),[R,G]=C&&kc(j,jo(Ec(C),!0))||[];$=new r(_c($.body,jc,R,()=>{G&&G(),N&&N()}),J)}E=E||"text";let V=await p[B.findKey(p,E)||"text"]($,v);return!_&&N&&N(),await new Promise((J,j)=>{Tc(J,j,{data:V,headers:$t.from($.headers),status:$.status,statusText:$.statusText,config:v,request:z})})}catch(M){throw N&&N(),M&&M.name==="TypeError"&&/Load failed|fetch/i.test(M.message)?Object.assign(new Le("Network Error",Le.ERR_NETWORK,v,z),{cause:M.cause||M}):Le.from(M,M&&M.code,v,z)}}},iv=new Map,Oc=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=iv;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};Oc();const vi={http:Nx,xhr:Qx,fetch:{get:Oc}};B.forEach(vi,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Dc=e=>`- ${e}`,av=e=>B.isFunction(e)||e===null||e===!1,Lc={getAdapter:(e,t)=>{e=B.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,!av(r)&&(o=vi[(a=String(r)).toLowerCase()],o===void 0))throw new Le(`Unknown adapter '${a}'`);if(o&&(B.isFunction(o)||(o=o.get(t))))break;s[a||"#"+i]=o}if(!o){const i=Object.entries(s).map(([l,c])=>`adapter ${l} `+(c===!1?"is not supported by the environment":"is not available in the build"));let a=n?i.length>1?`since :
|
|
33
|
-
`+i.map(
|
|
34
|
-
`):" "+
|
|
35
|
-
`+s):r.stack=s}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=qn(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:s}=n;r!==void 0&&Ro.assertOptions(r,{silentJSONParsing:hn.transitional(hn.boolean),forcedJSONParsing:hn.transitional(hn.boolean),clarifyTimeoutError:hn.transitional(hn.boolean)},!1),o!=null&&(B.isFunction(o)?n.paramsSerializer={serialize:o}:Ro.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),Ro.assertOptions(n,{baseUrl:hn.spelling("baseURL"),withXsrfToken:hn.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=s&&B.merge(s.common,s[n.method]);s&&B.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=[$c.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=$c.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=Ic(t.baseURL,t.url,t.allowAbsoluteUrls);return vc(n,t.params,t.paramsSerializer)}};B.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}))}}),B.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 cv=class Mg{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 Mg(function(o){t=o}),cancel:t}}};function uv(e){return function(n){return e.apply(null,n)}}function dv(e){return B.isObject(e)&&e.isAxiosError===!0}const bi={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(bi).forEach(([e,t])=>{bi[t]=e});function zc(e){const t=new Gn(e),n=rc(Gn.prototype.request,t);return B.extend(n,Gn.prototype,t,{allOwnKeys:!0}),B.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return zc(qn(e,o))},n}const vt=zc(Hr);vt.Axios=Gn,vt.CanceledError=fr,vt.CancelToken=cv,vt.isCancel=Cc,vt.VERSION=Fc,vt.toFormData=Ao,vt.AxiosError=Le,vt.Cancel=vt.CanceledError,vt.all=function(t){return Promise.all(t)},vt.spread=uv,vt.isAxiosError=dv,vt.mergeConfig=qn,vt.AxiosHeaders=$t,vt.formToJSON=e=>yc(B.isHTMLForm(e)?new FormData(e):e),vt.getAdapter=Lc.getAdapter,vt.HttpStatusCode=bi,vt.default=vt;const{Axios:MI,AxiosError:RI,CanceledError:OI,isCancel:DI,CancelToken:LI,VERSION:$I,all:FI,Cancel:BI,isAxiosError:zI,spread:HI,toFormData:UI,AxiosHeaders:WI,HttpStatusCode:VI,formToJSON:KI,getAdapter:qI,mergeConfig:GI}=vt,Hc=typeof window<"u"?window.__API_BASE_URL__:void 0,Uc=Hc?mn(Hc):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 Oo=null;const yi=new Set;function Wc(){return Oo}function Do(e){Oo=e,yi.forEach(t=>t(e))}function Vc(e){return yi.add(e),()=>yi.delete(e)}const Kc=3e4,qc=9e4,Kt=vt.create({...Uc?{baseURL:Uc}:{},timeout:Kc,withCredentials:!0});Kt.interceptors.request.use(e=>(Oo&&(e.headers.Authorization=`Bearer ${Oo}`),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),Do(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 Lo(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 Gc(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 Si(e,t){return Kt.defaults.baseURL?(await Kt.delete(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}function Rt(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class $o{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&&Do(t.authToken)}getAuthToken(){return Wc()}setAuthToken(t){Do(t)}onTokenChange(t){return Vc(t)}async listThreads(){const t=await qt("/threads"),n=Rt(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async listSharedThreads(){const t=await qt("/threads/shared"),n=Rt(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async createThread(t){const r=await Lo("/threads",t?{title:t}:void 0);return Rt(r)}async updateThread(t,n){const r=await Gc(`/threads/${t}`,{title:n});return Rt(r)}async deleteThread(t){const n=await Si(`/threads/${t}`);return Rt(n)}async shareThread(t,n){const r=await Lo(`/threads/${t}/share`,{shared_with_user_id:n});return Rt(r)}async threadInfo(t){const n=await qt(`/threads/${t}/info`);return Rt(n)}async listAgents(){const t=await qt("/agents"),n=Rt(t);return(n==null?void 0:n.items)??[]}async getAgent(t){const n=await qt(`/agents/${t}`);return Rt(n)}async getAgentSchema(t){const n=await qt(`/agents/${t}/schema`);return Rt(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 Rt(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:qc});return Rt(n)}async cancelRun(t){const n=await Lo("/runs/cancel",{threadId:t});return Rt(n)}async unshareThread(t,n){const r=await Si(`/threads/${t}/share/${n}`);return Rt(r)}}const An=new $o,fv=$o,pv=$o;async function Ci(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 hv(e,t){const n=await Ci(`/files/${e}/view`,t),r=URL.createObjectURL(n);window.open(r,"_blank"),setTimeout(()=>URL.revokeObjectURL(r),6e4)}async function Ti(e,t){return await(await Ci(`/files/${e}/view`,t)).text()}async function Yc(e,t){const n=await Ci(`/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 mv(e){return await qt(`/files/${e}`)}async function Xc(e,t=50,n=0){const r={limit:t,offset:n};return e&&(r.thread_id=e),await qt("/files",{params:r})}function ki(){const e=b.useContext(iu);if(!e)throw new Error("useApi must be used within ApiProvider");return e}async function Jc(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 Zc(e=[]){const t=[],n=[];for(const r of e)try{const o=await Jc(r);n.push({filename:r.name,data:o,mime_type:r.type||"application/octet-stream"})}catch{}return{contentParts:t,filesInfo:n}}function pr(e){if(!(typeof globalThis>"u"))return globalThis[e]}function gv(e){if(typeof e!="string")return;const t=e.trim();if(t)return mn(t)}function Qc(){const e=[pr("__API_BASE_URL__"),pr("__CHAT_API_BASE_URL__"),pr("__CHAT_API_URL__")];for(const t of e){const n=gv(t);if(n)return n}}function eu(){const e=[pr("__API_AUTH_TOKEN__"),pr("__CHAT_API_KEY__"),pr("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function tu(...e){for(const t of e)if(typeof t=="string"&&t.trim())return mn(t);return mn()}function nu(){const e={},t=Qc(),n=eu();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function ru(){const e=nu(),t=An.getAuthToken(),n=Qc();return{apiBaseUrl:tu(e.baseUrl,An.baseUrl,n),apiKey:t||e.apiKey||eu()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,darkMode:!1,enableSound:!1,messageHistory:100}}const Ei="chat-settings";function ou(){try{const e=localStorage.getItem(Ei);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function su(e){try{const t={...e,apiBaseUrl:mn(e.apiBaseUrl)};localStorage.setItem(Ei,JSON.stringify(t)),t.apiKey&&An.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function xv(){const e=ru(),t=ou(),n=An.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:tu(An.baseUrl,r,e.apiBaseUrl)}}function vv(e){An.updateConfig({baseUrl:e.apiBaseUrl,authToken:e.apiKey??void 0}),su(e)}const iu=b.createContext(null);function au({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(iu.Provider,{value:r,children:e})}function lu({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=Zl(v),x=g.timeline,[y,w]=b.useState(!1),[S,k]=b.useState(null),[C,T]=b.useState(!1),[E,A]=b.useState(!1),[O,F]=b.useState(!1),[U,W]=b.useState(null),z=b.useRef(o),N=b.useRef(null),K=b.useRef(null),M=b.useRef(null),Q=b.useRef(null),$=b.useRef(!1),_=b.useRef(null),V=b.useRef(new Map);b.useEffect(()=>{z.current=o},[o]);const J=b.useCallback(async L=>{var xe,de;if(!L.threadId)return;const oe=L.threadId;(xe=L.onStart)==null||xe.call(L),L.setLoading(!0);try{await L.action(oe)}catch(we){if(z.current===oe){const Me=String(we);(de=L.handleError)==null||de.call(L,Me),r==null||r(Me)}throw we}finally{L.setLoading(!1)}},[r]),j=b.useCallback(async(L,oe)=>{if(!L)return;const xe=`${L}:${oe??"latest"}`,de=V.current.get(xe);if(de)return de;const we=J({threadId:L,setLoading:T,onStart:()=>W(null),handleError:Me=>W(Me),action:async Me=>{const He=await e.getStateHistory({threadId:Me,checkpointId:oe??void 0});if(z.current!==Me){console.log(`[useThreadHistoryState] Thread changed during load (was ${Me}, now ${z.current}), discarding stale data`);return}const{checkpoints:$e}=Nn(He),Ae=$e.find(Fe=>Fe.messages&&Fe.messages.length>0)??(oe?$e.find(Fe=>Fe.checkpointId===oe):null)??$e[0];t((Ae==null?void 0:Ae.messages)??[],{checkpointId:(Ae==null?void 0:Ae.checkpointId)??null,checkpointNs:(Ae==null?void 0:Ae.checkpointNs)??null}),m(He),w(!!(Ae!=null&&Ae.nextCursor)),k((Ae==null?void 0:Ae.nextCursor)??null)}});V.current.set(xe,we);try{await we}finally{V.current.delete(xe)}return z.current===L&&(_.current=xe),we},[e,t,J]),R=b.useCallback(async(L,oe)=>{Q.current=L;try{await j(L,oe)}finally{Q.current===L&&(Q.current=null)}},[j]),G=b.useCallback(L=>{K.current=L},[]),Y=b.useCallback(L=>{M.current=L},[]),ie=b.useCallback(L=>{const oe=L.threadId??z.current;if(!oe||z.current&&z.current!==oe)return;const{checkpoints:xe}=Nn(L);if(!xe.length)return;const de=xe.find(we=>we.messages&&we.messages.length>0)??xe.find(we=>!!we.checkpointId)??xe[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(L),w(!!(de!=null&&de.nextCursor)),k((de==null?void 0:de.nextCursor)??null),_.current=`${oe}:latest`,K.current=null,M.current=null},[t]),H=b.useCallback(async(L,oe)=>{const xe=z.current;await J({threadId:xe,setLoading:F,action:async de=>{const we=await e.getStateHistory({threadId:de,checkpointId:L,checkpointNs:oe??void 0});if(z.current!==de){console.log(`[useThreadHistoryState] Thread changed during checkpoint navigation (was ${de}, now ${z.current}), discarding stale data`);return}const{checkpoints:Me}=Nn(we),He=Me.find($e=>$e.checkpointId===L&&(oe?$e.checkpointNs===oe:!0));if(!He){console.warn("[useThreadHistoryState] Requested checkpoint not found:",{checkpointId:L,checkpointNs:oe});return}m(we),t(He.messages??[],{checkpointId:He.checkpointId??null,checkpointNs:He.checkpointNs??null})}}).catch(()=>{})},[e,t,J]),D=b.useCallback((L,oe)=>{t(d(),{checkpointId:L??null,checkpointNs:oe??null})},[d,t]),X=b.useCallback(async()=>{z.current&&await R(z.current)},[R]),Z=b.useCallback(async()=>{const L=z.current;!L||!S||await J({threadId:L,setLoading:A,action:async oe=>{const xe=await e.getStateHistory({threadId:oe,checkpointId:S});if(z.current!==oe)return;const{checkpoints:de}=Nn(xe);if(de.length>0){const we=de[de.length-1];n((we==null?void 0:we.messages)??[]),w(!!(we!=null&&we.nextCursor)),k((we==null?void 0:we.nextCursor)??null)}}}).catch(()=>{})},[e,S,r,n,J]);b.useEffect(()=>{if(!l||!o||C||c)return;if(K.current===o){K.current=null,N.current=o;return}if(M.current===o){N.current=o;return}if(Q.current===o){Q.current=null,N.current=o;return}if(N.current===o)return;N.current=o;const L=!$.current&&!!i&&o===s;let oe;L&&i?(oe=i,$.current=!0,console.log("[useThreadHistoryState] Loading thread with checkpoint:",oe,a?`(ns: ${a})`:"")):console.log("[useThreadHistoryState] Loading thread with latest checkpoint");const xe=`${o}:${oe??"latest"}`;_.current!==xe&&R(o,oe)},[l,o,i,a,s,C,c,R]);const ce=b.useCallback(()=>{m(null),w(!1),k(null),T(!1),A(!1),F(!1),W(null),K.current=null,M.current=null,N.current=null,_.current=null,Q.current=null},[]);return{threadCheckpoints:v,threadTimeline:x,checkpointIndex:g,isLoadingThread:C,isHistoryLoading:E,isLoadingCheckpoint:O,threadStateError:U,hasMoreHistory:y,loadThread:R,navigateToCheckpoint:H,loadOlderMessages:Z,setCurrentCheckpointId:D,returnToLatest:X,handleStateHistoryEvent:ie,markSkipNextLoad:G,markStreamPendingThread:Y,resetHistoryState:ce}}const wv=["detail","message","error","description","title"];function Fo(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=Fo(t);if(n)return n}return null}if(typeof e=="object"){const t=e;for(const n of wv){const r=Fo(t[n]);if(r)return r}if("errors"in t){const n=Fo(t.errors);if(n)return n}}return null}function bv(e){if(!e)return"Request failed";const t=e.response,n=Fo(t==null?void 0:t.data);if(n)return n;if(t!=null&&t.statusText)return t.statusText;if(e instanceof Error&&e.message)return e.message;if(typeof e=="string"){const r=e.trim();if(r.length)return r}return t!=null&&t.status?`Request failed with status code ${t.status}`:"Request failed"}function cu({api:e,initialThreadId:t=null,onError:n,onThreadChange:r,onCurrentThreadDeleted:o}){const[s,i]=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 A=b.useCallback(async()=>{d(!0),m(null);try{const $=await e.listThreads();i($??[])}catch($){const _=String($);m(_),n==null||n(_)}finally{d(!1)}},[e,n]),O=b.useCallback(async()=>{x(!0),y(null);try{const $=await e.listSharedThreads();v($??[])}catch($){const _=String($);y(_),n==null||n(_)}finally{x(!1)}},[e,n]);b.useEffect(()=>{A()},[A]),b.useEffect(()=>{O()},[O]),b.useEffect(()=>{r==null||r(a)},[a,r]);const F=b.useCallback(async $=>{try{const _=await e.createThread($);return l(_.threadId),await A(),_.threadId}catch(_){const V=String(_);return n==null||n(V),null}},[e,n,A]),U=b.useCallback(async $=>{const _=s;i(J=>J.filter(j=>j.threadId!==$));const V=new AbortController;E.current.set($,V);try{await e.deleteThread($),T.current===$&&(l(null),o==null||o())}catch(J){i(_);const j=String(J);n==null||n(j)}finally{E.current.delete($)}},[e,o,n,s]),W=b.useCallback(async($,_)=>{try{await e.updateThread($,_),await A()}catch(V){n==null||n(String(V))}},[e,n,A]),z=b.useCallback(async($,_)=>{C(!0),S("Sharing thread…");try{await e.shareThread($,_),await O(),S("Shared successfully")}catch(V){const J=bv(V);throw n==null||n(J),S(`Failed to share: ${J}`),new Error(J)}finally{C(!1)}},[e,n,O]),N=b.useCallback(async($,_)=>{try{await e.unshareThread($,_),await O()}catch(V){const J=String(V);throw n==null||n(J),V}},[e,n,O]),K=b.useMemo(()=>({createThread:F,deleteThread:U,renameThread:W,refreshThreads:A,refreshSharedThreads:O,shareThread:z,unshareThread:N}),[F,U,W,A,O,z,N]),M=b.useCallback($=>{if(!($!=null&&$.threadId))return;const _={threadId:$.threadId,title:$.title||`Thread ${$.threadId.slice(0,8)}`,createdAt:$.createdAt||new Date().toISOString(),updatedAt:$.updatedAt||new Date().toISOString(),messageCount:$.messageCount??1};i(V=>{let J=!1;const j=V.map(R=>R.threadId===_.threadId?(J=!0,console.debug("[useThreadsState] thread_info: updating existing thread",_.threadId),{...R,title:_.title??R.title,updatedAt:_.updatedAt??R.updatedAt,messageCount:_.messageCount??R.messageCount}):R);return J?j:(console.debug("[useThreadsState] thread_info: adding thread to list",_.threadId),[_,...V])})},[]),Q=b.useCallback(()=>S(null),[]);return{threads:s,currentThreadId:a,currentThreadIdRef:T,setCurrentThreadId:l,isLoadingThreads:c,threadsError:p,sharedThreads:f,isLoadingSharedThreads:g,actions:K,addThreadFromEvent:M,shareInFlight:k,shareStatus:w,clearShareStatus:Q}}function Ii(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 uu(e){return!!(e&&typeof e=="object"&&(e.type==="file"||e.mimeType||e.filename||e.sourceType==="base64"))}function Wr(e){if(typeof e=="string")return e;if(e&&typeof e=="object"){if(Array.isArray(e)){const n=e.map(Wr).filter(r=>r!==void 0);if(!n.length){console.debug("[message-utils] sanitizeForDisplay - array emptied -> returning undefined",{originalLength:e.length});return}return n}if(uu(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=Wr(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(uu(e))return"";try{const t=Wr(e);return t===void 0?"":typeof t=="string"?t:JSON.stringify(t,null,2)}catch{return""}}function yv(e){return typeof e!="string"?!1:/^[\s\n]*[-*]\s|^[\s\n]*#+\s|```|^\s*\[.*\]\(|^>\s/.test(e)}function Sv(e){const t=hr(e);return typeof e=="string"&&yv(e)?{content:e,isMarkdown:!0}:{content:t,isMarkdown:!1}}function Vr(e){if(e==null)return e;if(typeof e=="string"){const t=e.trim();if(t.startsWith("{")||t.startsWith("[")){const n=Ii(t);if(n!==null)return Vr(n)}return e}return typeof e=="object"&&!Array.isArray(e)&&e.content!==void 0?Vr(e.content):e}function Cv(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function Ni(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 Bo(e){if(e==null)return null;const t=String(e).trim();return t.length>0?t:null}function Tv(e){const t=r=>{try{const o=Wr(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(`
|
|
36
|
-
`)):t(e)}function kv(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function du(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 Ev(e){if(!e)return"image/png";const t=e.trim();return t?t.includes("/")?t:`image/${t}`:"image/png"}function Iv(e){const t=[],n=r=>{r&&r.trim()&&t.push(r.trim())};return e&&(n(e.plotId),n(e.artifactId)),t}function Nv({base64:e,url:t,formatHint:n,extras:r}){const o=typeof e=="string"&&e.length>0,s=Ev(n),i=o?`data:${s};base64,${e}`:t,a=Iv(r),l=a.length?a.join(" / "):void 0,c=l?`${l} artifact`:"artifact image";return{src:i,alt:c,label:l}}function Av(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 Nv({base64:t,url:n,formatHint:r,extras:{plotId:e.plotId,artifactId:e.artifactId}})}function Ai(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 Kr(e,t,n){return t<0||t>=e.length?e:[...e.slice(0,t),n,...e.slice(t+1)]}function _v(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 jv(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=Pv(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 Pv(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 Mv(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 Kr(e,r,s)}return e}function Rv(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}const Ov={messages:[],assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,messagesStreamMeta:{},pendingInterrupt:null};function Dv(e,t){var n;switch(t.type){case"reset":return{messages:Ai(((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=Ai(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=Ai(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 Lv(e=[]){const[t,n]=b.useReducer(Dv,{...Ov,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=Rv(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 Fv(e,t);if(t.type==="tool.progress")return Bv(e,t);if(t.type==="tool.end")return zv(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}=jv(l.content,t.delta,m,f);if(!x)return e;const y={...l,content:v},w=Kr(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=Mv(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?_v(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 ji(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||Ni(r).toolCallId===t)return n}return-1}function $v(e){if(e==null)return[];const t=Vr(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 Fv(e,t){const n=_i(t),r=ji(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:Kr(e.messages,r,d)}}const i=xu(s,n,o,t.args);return{...e,messages:[...e.messages,i]}}function Bv(e,t){const n=_i(t);if(!n)return e;const r=ji(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:Kr(e.messages,r,a)}}function zv(e,t){const n=_i(t),r=gu(t);let o=e.messages,s=ji(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=$v(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:Kr(o,s,f)}}function Hv(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),A=b.useRef(null),O=b.useRef(null),F=b.useCallback(N=>{o(N)},[]),U=b.useCallback(()=>{m(""),v(null),d(null),E.current=null,A.current=null,O.current=null},[]),W=b.useCallback(()=>{var N;console.debug("[use-chat] stop() invoked - aborting stream"),(N=S.current)==null||N.abort(),S.current=null,T.current=null,l(!1),w(!1),C.current=0,x(0)},[]),z=b.useCallback((N,K,M)=>{S.current&&(S.current.abort(),S.current=null),l(!0),d(null),e.autoAppendAssistant!==!1&&m(""),v(null),E.current=null,A.current=null,O.current=null;const Q=new AbortController;S.current=Q;let $=null,_=null,V=!1;return T.current={threadId:N.threadId??null,headers:{}},(async()=>{var j,R,G,Y,ie,H,D,X,Z,ce,L,oe,xe,de,we,Me,He,$e;const J=Ae=>{var Fe;try{const Ge=JSON.parse(JSON.stringify(Ae));return(Fe=Ge==null?void 0:Ge.payload)!=null&&Fe.files_info&&Array.isArray(Ge.payload.files_info)&&(Ge.payload.files_info=Ge.payload.files_info.map(Ke=>({...Ke,data:Ke!=null&&Ke.data?`<base64 ${String(Ke.data).length} chars>`:Ke==null?void 0:Ke.data}))),Ge}catch{return Ae}};try{let Ae={};try{if(r)Ae={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const Be=window.__AUTH_TOKEN__,St=((j=window.localStorage)==null?void 0:j.getItem("authToken"))||null;let xt=null;try{const gt=(R=window.localStorage)==null?void 0:R.getItem("chat-settings");gt&&(xt=((G=JSON.parse(gt))==null?void 0:G.apiKey)||null)}catch{}const Ye=Be||St||xt||null;Ye&&(Ae={Authorization:`Bearer ${Ye}`})}}catch{}console.debug("[use-chat] POST",t+n,J(N));let Fe={};if(typeof window<"u")try{const De=(Y=window.localStorage)==null?void 0:Y.getItem("authSessionId");De&&(Fe={"X-Session-Id":De})}catch{}const Ge={...Ae,...Fe,...s.current},Ke={"Content-Type":"application/json",Accept:"text/event-stream",...Ge},Xe=await fetch(t+n,{method:"POST",headers:Ke,body:JSON.stringify(N),signal:Q.signal,credentials:i});if(T.current&&(T.current.headers=Ge),!Xe.ok||!Xe.body){const De=await Xe.text().catch(()=>"");console.debug("[use-chat] non-OK response",Xe.status,De==null?void 0:De.slice(0,500));const Be=`stream ${Xe.status}${De?": "+De:""}`;throw(ie=M==null?void 0:M.onConnectionError)==null||ie.call(M,Be),V=!0,$="error",_=Be,new Error(Be)}w(!0);const tt=Xe.body.getReader(),nt=new TextDecoder;let Ze="",pt=[];C.current=0,x(0);let ht=0,Se=null;const Re=()=>{if(pt.length){const De=pt.join("");pt=[],k.current&&m(Be=>Be+De)}Se=null},mt=()=>{typeof window<"u"&&Se==null&&(Se=requestAnimationFrame(Re))};let ot=Date.now();const qe=setInterval(()=>{var De;if(Date.now()-ot>18e5){const Be="Stream idle timeout";d(Be),$="error",_=Be,Q.abort(),(De=M==null?void 0:M.onError)==null||De.call(M,Be)}},5e3),yt=1024*1024;try{const De=Xe.headers.get("X-Thread-Id")||Xe.headers.get("x-thread-id"),Be=Xe.headers.get("X-Thread-Created")||Xe.headers.get("x-thread-created"),St=De??null,xt=String(Be??"").toLowerCase()==="true";for(T.current&&!T.current.threadId&&(T.current={...T.current,threadId:St}),(H=M==null?void 0:M.onOpen)==null||H.call(M,{threadId:St,created:xt});;){const{value:Ye,done:gt}=await tt.read();if(gt)break;Ze+=nt.decode(Ye,{stream:!0}),Ze.length>yt&&(Ze="",console.warn("Stream buffer reset: exceeded 1MB"));let P;for(;(P=Ze.indexOf(`
|
|
30
|
+
<%s key={someKey} {...props} />`,Kl,lr,kI,lr),Ut[lr+Kl]=!0}}return I===r?lt(kt):Ue(kt),kt}}function nn(I,ne,pe){return Mt(I,ne,pe,!0)}function Wl(I,ne,pe){return Mt(I,ne,pe,!1)}var Vl=Wl,li=nn;$r.Fragment=r,$r.jsx=Vl,$r.jsxs=li}()),$r}process.env.NODE_ENV==="production"?di.exports=zg():di.exports=Hg();var u=di.exports;const Ug=({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 oc(e,t){return function(){return e.apply(t,arguments)}}const{toString:Wg}=Object.prototype,{getPrototypeOf:fi}=Object,{iterator:ko,toStringTag:sc}=Symbol,Eo=(e=>t=>{const n=Wg.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),on=e=>(e=e.toLowerCase(),t=>Eo(t)===e),Io=e=>t=>typeof t===e,{isArray:ur}=Array,dr=Io("undefined");function Fr(e){return e!==null&&!dr(e)&&e.constructor!==null&&!dr(e.constructor)&&Lt(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const ic=on("ArrayBuffer");function Vg(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&ic(e.buffer),t}const Kg=Io("string"),Lt=Io("function"),ac=Io("number"),Br=e=>e!==null&&typeof e=="object",qg=e=>e===!0||e===!1,No=e=>{if(Eo(e)!=="object")return!1;const t=fi(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(sc in e)&&!(ko in e)},Gg=e=>{if(!Br(e)||Fr(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},Yg=on("Date"),Xg=on("File"),Jg=on("Blob"),Zg=on("FileList"),Qg=e=>Br(e)&&Lt(e.pipe),ex=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||Lt(e.append)&&((t=Eo(e))==="formdata"||t==="object"&&Lt(e.toString)&&e.toString()==="[object FormData]"))},tx=on("URLSearchParams"),[nx,rx,ox,sx]=["ReadableStream","Request","Response","Headers"].map(on),ix=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function zr(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(Fr(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 lc(e,t){if(Fr(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,cc=e=>!dr(e)&&e!==Kn;function pi(){const{caseless:e,skipUndefined:t}=cc(this)&&this||{},n={},r=(o,s)=>{const i=e&&lc(n,s)||s;No(n[i])&&No(o)?n[i]=pi(n[i],o):No(o)?n[i]=pi({},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]&&zr(arguments[o],r);return n}const ax=(e,t,n,{allOwnKeys:r}={})=>(zr(t,(o,s)=>{n&&Lt(o)?e[s]=oc(o,n):e[s]=o},{allOwnKeys:r}),e),lx=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),cx=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},ux=(e,t,n,r)=>{let o,s,i;const a={};if(t=t||{},e==null)return t;do{for(o=Object.getOwnPropertyNames(e),s=o.length;s-- >0;)i=o[s],(!r||r(i,e,t))&&!a[i]&&(t[i]=e[i],a[i]=!0);e=n!==!1&&fi(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},dx=(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},fx=e=>{if(!e)return null;if(ur(e))return e;let t=e.length;if(!ac(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},px=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&fi(Uint8Array)),hx=(e,t)=>{const r=(e&&e[ko]).call(e);let o;for(;(o=r.next())&&!o.done;){const s=o.value;t.call(e,s[0],s[1])}},mx=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},gx=on("HTMLFormElement"),xx=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),uc=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),vx=on("RegExp"),dc=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};zr(n,(o,s)=>{let i;(i=t(o,s,e))!==!1&&(r[s]=i||o)}),Object.defineProperties(e,r)},wx=e=>{dc(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+"'")})}})},bx=(e,t)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return ur(e)?r(e):r(String(e).split(t)),n},yx=()=>{},Sx=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function Cx(e){return!!(e&&Lt(e.append)&&e[sc]==="FormData"&&e[ko])}const Tx=e=>{const t=new Array(10),n=(r,o)=>{if(Br(r)){if(t.indexOf(r)>=0)return;if(Fr(r))return r;if(!("toJSON"in r)){t[o]=r;const s=ur(r)?[]:{};return zr(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)},kx=on("AsyncFunction"),Ex=e=>e&&(Br(e)||Lt(e))&&Lt(e.then)&&Lt(e.catch),fc=((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)),Ix=typeof queueMicrotask<"u"?queueMicrotask.bind(Kn):typeof process<"u"&&process.nextTick||fc,B={isArray:ur,isArrayBuffer:ic,isBuffer:Fr,isFormData:ex,isArrayBufferView:Vg,isString:Kg,isNumber:ac,isBoolean:qg,isObject:Br,isPlainObject:No,isEmptyObject:Gg,isReadableStream:nx,isRequest:rx,isResponse:ox,isHeaders:sx,isUndefined:dr,isDate:Yg,isFile:Xg,isBlob:Jg,isRegExp:vx,isFunction:Lt,isStream:Qg,isURLSearchParams:tx,isTypedArray:px,isFileList:Zg,forEach:zr,merge:pi,extend:ax,trim:ix,stripBOM:lx,inherits:cx,toFlatObject:ux,kindOf:Eo,kindOfTest:on,endsWith:dx,toArray:fx,forEachEntry:hx,matchAll:mx,isHTMLForm:gx,hasOwnProperty:uc,hasOwnProp:uc,reduceDescriptors:dc,freezeMethods:wx,toObjectSet:bx,toCamelCase:xx,noop:yx,toFiniteNumber:Sx,findKey:lc,global:Kn,isContextDefined:cc,isSpecCompliantForm:Cx,toJSONObject:Tx,isAsyncFn:kx,isThenable:Ex,setImmediate:fc,asap:Ix,isIterable:e=>e!=null&&Lt(e[ko])};function Le(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)}B.inherits(Le,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:B.toJSONObject(this.config),code:this.code,status:this.status}}});const pc=Le.prototype,hc={};["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=>{hc[e]={value:e}}),Object.defineProperties(Le,hc),Object.defineProperty(pc,"isAxiosError",{value:!0}),Le.from=(e,t,n,r,o,s)=>{const i=Object.create(pc);B.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 Le.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 Nx=null;function hi(e){return B.isPlainObject(e)||B.isArray(e)}function mc(e){return B.endsWith(e,"[]")?e.slice(0,-2):e}function gc(e,t,n){return e?e.concat(t).map(function(o,s){return o=mc(o),!n&&s?"["+o+"]":o}).join(n?".":""):t}function Ax(e){return B.isArray(e)&&!e.some(hi)}const _x=B.toFlatObject(B,{},null,function(t){return/^is[A-Z]/.test(t)});function Ao(e,t,n){if(!B.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=B.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(g,x){return!B.isUndefined(x[g])});const r=n.metaTokens,o=n.visitor||d,s=n.dots,i=n.indexes,l=(n.Blob||typeof Blob<"u"&&Blob)&&B.isSpecCompliantForm(t);if(!B.isFunction(o))throw new TypeError("visitor must be a function");function c(v){if(v===null)return"";if(B.isDate(v))return v.toISOString();if(B.isBoolean(v))return v.toString();if(!l&&B.isBlob(v))throw new Le("Blob is not supported. Use a Buffer instead.");return B.isArrayBuffer(v)||B.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(B.endsWith(g,"{}"))g=r?g:g.slice(0,-2),v=JSON.stringify(v);else if(B.isArray(v)&&Ax(v)||(B.isFileList(v)||B.endsWith(g,"[]"))&&(y=B.toArray(v)))return g=mc(g),y.forEach(function(S,k){!(B.isUndefined(S)||S===null)&&t.append(i===!0?gc([g],k,s):i===null?g:g+"[]",c(S))}),!1}return hi(v)?!0:(t.append(gc(x,g,s),c(v)),!1)}const p=[],m=Object.assign(_x,{defaultVisitor:d,convertValue:c,isVisitable:hi});function f(v,g){if(!B.isUndefined(v)){if(p.indexOf(v)!==-1)throw Error("Circular reference detected in "+g.join("."));p.push(v),B.forEach(v,function(y,w){(!(B.isUndefined(y)||y===null)&&o.call(t,y,B.isString(w)?w.trim():w,g,m))===!0&&f(y,g?g.concat(w):[w])}),p.pop()}}if(!B.isObject(e))throw new TypeError("data must be an object");return f(e),t}function xc(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function mi(e,t){this._pairs=[],e&&Ao(e,this,t)}const vc=mi.prototype;vc.append=function(t,n){this._pairs.push([t,n])},vc.toString=function(t){const n=t?function(r){return t.call(this,r,xc)}:xc;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function jx(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function wc(e,t,n){if(!t)return e;const r=n&&n.encode||jx;B.isFunction(n)&&(n={serialize:n});const o=n&&n.serialize;let s;if(o?s=o(t,n):s=B.isURLSearchParams(t)?t.toString():new mi(t,n).toString(r),s){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}class bc{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){B.forEach(this.handlers,function(r){r!==null&&t(r)})}}const yc={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Px={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:mi,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},gi=typeof window<"u"&&typeof document<"u",xi=typeof navigator=="object"&&navigator||void 0,Mx=gi&&(!xi||["ReactNative","NativeScript","NS"].indexOf(xi.product)<0),Rx=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Ox=gi&&window.location.href||"http://localhost",Nt={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:gi,hasStandardBrowserEnv:Mx,hasStandardBrowserWebWorkerEnv:Rx,navigator:xi,origin:Ox},Symbol.toStringTag,{value:"Module"})),...Px};function Dx(e,t){return Ao(e,new Nt.classes.URLSearchParams,{visitor:function(n,r,o,s){return Nt.isNode&&B.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function Lx(e){return B.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function $x(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 Sc(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&&B.isArray(o)?o.length:i,l?(B.hasOwnProp(o,i)?o[i]=[o[i],r]:o[i]=r,!a):((!o[i]||!B.isObject(o[i]))&&(o[i]=[]),t(n,r,o[i],s)&&B.isArray(o[i])&&(o[i]=$x(o[i])),!a)}if(B.isFormData(e)&&B.isFunction(e.entries)){const n={};return B.forEachEntry(e,(r,o)=>{t(Lx(r),o,n,0)}),n}return null}function Fx(e,t,n){if(B.isString(e))try{return(t||JSON.parse)(e),B.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const Hr={transitional:yc,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",o=r.indexOf("application/json")>-1,s=B.isObject(t);if(s&&B.isHTMLForm(t)&&(t=new FormData(t)),B.isFormData(t))return o?JSON.stringify(Sc(t)):t;if(B.isArrayBuffer(t)||B.isBuffer(t)||B.isStream(t)||B.isFile(t)||B.isBlob(t)||B.isReadableStream(t))return t;if(B.isArrayBufferView(t))return t.buffer;if(B.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 Dx(t,this.formSerializer).toString();if((a=B.isFileList(t))||r.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return Ao(a?{"files[]":t}:t,l&&new l,this.formSerializer)}}return s||o?(n.setContentType("application/json",!1),Fx(t)):t}],transformResponse:[function(t){const n=this.transitional||Hr.transitional,r=n&&n.forcedJSONParsing,o=this.responseType==="json";if(B.isResponse(t)||B.isReadableStream(t))return t;if(t&&B.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"?Le.from(a,Le.ERR_BAD_RESPONSE,this,null,this.response):a}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Nt.classes.FormData,Blob:Nt.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};B.forEach(["delete","get","head","post","put","patch"],e=>{Hr.headers[e]={}});const Bx=B.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"]),zx=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]&&Bx[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},Cc=Symbol("internals");function Ur(e){return e&&String(e).trim().toLowerCase()}function _o(e){return e===!1||e==null?e:B.isArray(e)?e.map(_o):String(e)}function Hx(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 Ux=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function vi(e,t,n,r,o){if(B.isFunction(r))return r.call(this,t,n);if(o&&(t=n),!!B.isString(t)){if(B.isString(r))return t.indexOf(r)!==-1;if(B.isRegExp(r))return r.test(t)}}function Wx(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function Vx(e,t){const n=B.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=Ur(l);if(!d)throw new Error("header name must be a non-empty string");const p=B.findKey(o,d);(!p||o[p]===void 0||c===!0||c===void 0&&o[p]!==!1)&&(o[p||l]=_o(a))}const i=(a,l)=>B.forEach(a,(c,d)=>s(c,d,l));if(B.isPlainObject(t)||t instanceof this.constructor)i(t,n);else if(B.isString(t)&&(t=t.trim())&&!Ux(t))i(zx(t),n);else if(B.isObject(t)&&B.isIterable(t)){let a={},l,c;for(const d of t){if(!B.isArray(d))throw TypeError("Object iterator must return a key-value pair");a[c=d[0]]=(l=a[c])?B.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=Ur(t),t){const r=B.findKey(this,t);if(r){const o=this[r];if(!n)return o;if(n===!0)return Hx(o);if(B.isFunction(n))return n.call(this,o,r);if(B.isRegExp(n))return n.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=Ur(t),t){const r=B.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||vi(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let o=!1;function s(i){if(i=Ur(i),i){const a=B.findKey(r,i);a&&(!n||vi(r,r[a],a,n))&&(delete r[a],o=!0)}}return B.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||vi(this,this[s],s,t,!0))&&(delete this[s],o=!0)}return o}normalize(t){const n=this,r={};return B.forEach(this,(o,s)=>{const i=B.findKey(r,s);if(i){n[i]=_o(o),delete n[s];return}const a=t?Wx(s):String(s).trim();a!==s&&delete n[s],n[a]=_o(o),r[a]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return B.forEach(this,(r,o)=>{r!=null&&r!==!1&&(n[o]=t&&B.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[Cc]=this[Cc]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=Ur(i);r[a]||(Vx(o,i),r[a]=!0)}return B.isArray(t)?t.forEach(s):s(t),this}};$t.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),B.reduceDescriptors($t.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),B.freezeMethods($t);function wi(e,t){const n=this||Hr,r=t||n,o=$t.from(r.headers);let s=r.data;return B.forEach(e,function(a){s=a.call(n,s,o.normalize(),t?t.status:void 0)}),o.normalize(),s}function Tc(e){return!!(e&&e.__CANCEL__)}function fr(e,t,n){Le.call(this,e??"canceled",Le.ERR_CANCELED,t,n),this.name="CanceledError"}B.inherits(fr,Le,{__CANCEL__:!0});function kc(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new Le("Request failed with status code "+n.status,[Le.ERR_BAD_REQUEST,Le.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function Kx(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function qx(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 Gx(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 jo=(e,t,n=3)=>{let r=0;const o=qx(50,250);return Gx(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)},Ec=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},Ic=e=>(...t)=>B.asap(()=>e(...t)),Yx=Nt.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,Nt.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(Nt.origin),Nt.navigator&&/(msie|trident)/i.test(Nt.navigator.userAgent)):()=>!0,Xx=Nt.hasStandardBrowserEnv?{write(e,t,n,r,o,s){const i=[e+"="+encodeURIComponent(t)];B.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),B.isString(r)&&i.push("path="+r),B.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 Jx(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Zx(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function Nc(e,t,n){let r=!Jx(t);return e&&(r||n==!1)?Zx(e,t):t}const Ac=e=>e instanceof $t?{...e}:e;function qn(e,t){t=t||{};const n={};function r(c,d,p,m){return B.isPlainObject(c)&&B.isPlainObject(d)?B.merge.call({caseless:m},c,d):B.isPlainObject(d)?B.merge({},d):B.isArray(d)?d.slice():d}function o(c,d,p,m){if(B.isUndefined(d)){if(!B.isUndefined(c))return r(void 0,c,p,m)}else return r(c,d,p,m)}function s(c,d){if(!B.isUndefined(d))return r(void 0,d)}function i(c,d){if(B.isUndefined(d)){if(!B.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(Ac(c),Ac(d),p,!0)};return B.forEach(Object.keys({...e,...t}),function(d){const p=l[d]||o,m=p(e[d],t[d],d);B.isUndefined(m)&&p!==a||(n[d]=m)}),n}const _c=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=wc(Nc(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&i.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),B.isFormData(n)){if(Nt.hasStandardBrowserEnv||Nt.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(B.isFunction(n.getHeaders)){const l=n.getHeaders(),c=["content-type","content-length"];Object.entries(l).forEach(([d,p])=>{c.includes(d.toLowerCase())&&i.set(d,p)})}}if(Nt.hasStandardBrowserEnv&&(r&&B.isFunction(r)&&(r=r(t)),r||r!==!1&&Yx(t.url))){const l=o&&s&&Xx.read(s);l&&i.set(o,l)}return t},Qx=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=_c(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};kc(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 Le("Request aborted",Le.ECONNABORTED,e,x)),x=null)},x.onerror=function(k){const C=k&&k.message?k.message:"Network Error",T=new Le(C,Le.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||yc;o.timeoutErrorMessage&&(k=o.timeoutErrorMessage),r(new Le(k,C.clarifyTimeoutError?Le.ETIMEDOUT:Le.ECONNABORTED,e,x)),x=null},s===void 0&&i.setContentType(null),"setRequestHeader"in x&&B.forEach(i.toJSON(),function(k,C){x.setRequestHeader(C,k)}),B.isUndefined(o.withCredentials)||(x.withCredentials=!!o.withCredentials),a&&a!=="json"&&(x.responseType=o.responseType),c&&([m,v]=jo(c,!0),x.addEventListener("progress",m)),l&&x.upload&&([p,f]=jo(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=Kx(o.url);if(w&&Nt.protocols.indexOf(w)===-1){r(new Le("Unsupported protocol "+w+":",Le.ERR_BAD_REQUEST,e));return}x.send(s||null)})},ev=(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 Le?d:new fr(d instanceof Error?d.message:d))}};let i=t&&setTimeout(()=>{i=null,s(new Le(`timeout ${t} of ms exceeded`,Le.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=()=>B.asap(a),l}},tv=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},nv=async function*(e,t){for await(const n of rv(e))yield*tv(n,t)},rv=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()}},jc=(e,t,n,r)=>{const o=nv(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})},Pc=64*1024,{isFunction:Po}=B,ov=(({Request:e,Response:t})=>({Request:e,Response:t}))(B.global),{ReadableStream:Mc,TextEncoder:Rc}=B.global,Oc=(e,...t)=>{try{return!!e(...t)}catch{return!1}},sv=e=>{e=B.merge.call({skipUndefined:!0},ov,e);const{fetch:t,Request:n,Response:r}=e,o=t?Po(t):typeof fetch=="function",s=Po(n),i=Po(r);if(!o)return!1;const a=o&&Po(Mc),l=o&&(typeof Rc=="function"?(v=>g=>v.encode(g))(new Rc):async v=>new Uint8Array(await new n(v).arrayBuffer())),c=s&&a&&Oc(()=>{let v=!1;const g=new n(Nt.origin,{body:new Mc,method:"POST",get duplex(){return v=!0,"half"}}).headers.has("Content-Type");return v&&!g}),d=i&&a&&Oc(()=>B.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 Le(`Response type '${v}' is not supported`,Le.ERR_NOT_SUPPORT,x)})});const m=async v=>{if(v==null)return 0;if(B.isBlob(v))return v.size;if(B.isSpecCompliantForm(v))return(await new n(Nt.origin,{method:"POST",body:v}).arrayBuffer()).byteLength;if(B.isArrayBufferView(v)||B.isArrayBuffer(v))return v.byteLength;if(B.isURLSearchParams(v)&&(v=v+""),B.isString(v))return(await l(v)).byteLength},f=async(v,g)=>{const x=B.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:A,withCredentials:O="same-origin",fetchOptions:F}=_c(v),U=t||fetch;E=E?(E+"").toLowerCase():"text";let W=ev([w,S&&S.toAbortSignal()],k),z=null;const N=W&&W.unsubscribe&&(()=>{W.unsubscribe()});let q;try{if(T&&c&&x!=="get"&&x!=="head"&&(q=await f(A,y))!==0){let J=new n(g,{method:"POST",body:y,duplex:"half"}),j;if(B.isFormData(y)&&(j=J.headers.get("content-type"))&&A.setContentType(j),J.body){const[R,G]=Ec(q,jo(Ic(T)));y=jc(J.body,Pc,R,G)}}B.isString(O)||(O=O?"include":"omit");const M=s&&"credentials"in n.prototype,Q={...F,signal:W,method:x.toUpperCase(),headers:A.normalize().toJSON(),body:y,duplex:"half",credentials:M?O:void 0};z=s&&new n(g,Q);let $=await(s?U(z,F):U(g,Q));const _=d&&(E==="stream"||E==="response");if(d&&(C||_&&N)){const J={};["status","statusText","headers"].forEach(Y=>{J[Y]=$[Y]});const j=B.toFiniteNumber($.headers.get("content-length")),[R,G]=C&&Ec(j,jo(Ic(C),!0))||[];$=new r(jc($.body,Pc,R,()=>{G&&G(),N&&N()}),J)}E=E||"text";let V=await p[B.findKey(p,E)||"text"]($,v);return!_&&N&&N(),await new Promise((J,j)=>{kc(J,j,{data:V,headers:$t.from($.headers),status:$.status,statusText:$.statusText,config:v,request:z})})}catch(M){throw N&&N(),M&&M.name==="TypeError"&&/Load failed|fetch/i.test(M.message)?Object.assign(new Le("Network Error",Le.ERR_NETWORK,v,z),{cause:M.cause||M}):Le.from(M,M&&M.code,v,z)}}},iv=new Map,Dc=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=iv;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};Dc();const bi={http:Nx,xhr:Qx,fetch:{get:Dc}};B.forEach(bi,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Lc=e=>`- ${e}`,av=e=>B.isFunction(e)||e===null||e===!1,$c={getAdapter:(e,t)=>{e=B.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,!av(r)&&(o=bi[(a=String(r)).toLowerCase()],o===void 0))throw new Le(`Unknown adapter '${a}'`);if(o&&(B.isFunction(o)||(o=o.get(t))))break;s[a||"#"+i]=o}if(!o){const i=Object.entries(s).map(([l,c])=>`adapter ${l} `+(c===!1?"is not supported by the environment":"is not available in the build"));let a=n?i.length>1?`since :
|
|
33
|
+
`+i.map(Lc).join(`
|
|
34
|
+
`):" "+Lc(i[0]):"as no adapter specified";throw new Le("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return o},adapters:bi};function yi(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new fr(null,e)}function Fc(e){return yi(e),e.headers=$t.from(e.headers),e.data=wi.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),$c.getAdapter(e.adapter||Hr.adapter,e)(e).then(function(r){return yi(e),r.data=wi.call(e,e.transformResponse,r),r.headers=$t.from(r.headers),r},function(r){return Tc(r)||(yi(e),r&&r.response&&(r.response.data=wi.call(e,e.transformResponse,r.response),r.response.headers=$t.from(r.response.headers))),Promise.reject(r)})}const Bc="1.12.2",Mo={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Mo[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const zc={};Mo.transitional=function(t,n,r){function o(s,i){return"[Axios v"+Bc+"] Transitional option '"+s+"'"+i+(r?". "+r:"")}return(s,i,a)=>{if(t===!1)throw new Le(o(i," has been removed"+(n?" in "+n:"")),Le.ERR_DEPRECATED);return n&&!zc[i]&&(zc[i]=!0,console.warn(o(i," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(s,i,a):!0}},Mo.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function lv(e,t,n){if(typeof e!="object")throw new Le("options must be an object",Le.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 Le("option "+s+" must be "+l,Le.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new Le("Unknown option "+s,Le.ERR_BAD_OPTION)}}const Ro={assertOptions:lv,validators:Mo},hn=Ro.validators;let Gn=class{constructor(t){this.defaults=t||{},this.interceptors={request:new bc,response:new bc}}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&&Ro.assertOptions(r,{silentJSONParsing:hn.transitional(hn.boolean),forcedJSONParsing:hn.transitional(hn.boolean),clarifyTimeoutError:hn.transitional(hn.boolean)},!1),o!=null&&(B.isFunction(o)?n.paramsSerializer={serialize:o}:Ro.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),Ro.assertOptions(n,{baseUrl:hn.spelling("baseURL"),withXsrfToken:hn.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=s&&B.merge(s.common,s[n.method]);s&&B.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=[Fc.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=Fc.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=Nc(t.baseURL,t.url,t.allowAbsoluteUrls);return wc(n,t.params,t.paramsSerializer)}};B.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}))}}),B.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 cv=class Mg{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 Mg(function(o){t=o}),cancel:t}}};function uv(e){return function(n){return e.apply(null,n)}}function dv(e){return B.isObject(e)&&e.isAxiosError===!0}const Si={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(Si).forEach(([e,t])=>{Si[t]=e});function Hc(e){const t=new Gn(e),n=oc(Gn.prototype.request,t);return B.extend(n,Gn.prototype,t,{allOwnKeys:!0}),B.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return Hc(qn(e,o))},n}const vt=Hc(Hr);vt.Axios=Gn,vt.CanceledError=fr,vt.CancelToken=cv,vt.isCancel=Tc,vt.VERSION=Bc,vt.toFormData=Ao,vt.AxiosError=Le,vt.Cancel=vt.CanceledError,vt.all=function(t){return Promise.all(t)},vt.spread=uv,vt.isAxiosError=dv,vt.mergeConfig=qn,vt.AxiosHeaders=$t,vt.formToJSON=e=>Sc(B.isHTMLForm(e)?new FormData(e):e),vt.getAdapter=$c.getAdapter,vt.HttpStatusCode=Si,vt.default=vt;const{Axios:OI,AxiosError:DI,CanceledError:LI,isCancel:$I,CancelToken:FI,VERSION:BI,all:zI,Cancel:HI,isAxiosError:UI,spread:WI,toFormData:VI,AxiosHeaders:KI,HttpStatusCode:qI,formToJSON:GI,getAdapter:YI,mergeConfig:XI}=vt,Uc=typeof window<"u"?window.__API_BASE_URL__:void 0,Wc=Uc?mn(Uc):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 Oo=null;const Ci=new Set;function Vc(){return Oo}function Do(e){Oo=e,Ci.forEach(t=>t(e))}function Kc(e){return Ci.add(e),()=>Ci.delete(e)}const qc=3e4,Gc=9e4,Kt=vt.create({...Wc?{baseURL:Wc}:{},timeout:qc,withCredentials:!0});Kt.interceptors.request.use(e=>(Oo&&(e.headers.Authorization=`Bearer ${Oo}`),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),Do(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 Lo(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 Yc(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 Ti(e,t){return Kt.defaults.baseURL?(await Kt.delete(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}function Rt(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class $o{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&&Do(t.authToken)}getAuthToken(){return Vc()}setAuthToken(t){Do(t)}onTokenChange(t){return Kc(t)}async listThreads(){const t=await qt("/threads"),n=Rt(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async listSharedThreads(){const t=await qt("/threads/shared"),n=Rt(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async createThread(t){const r=await Lo("/threads",t?{title:t}:void 0);return Rt(r)}async updateThread(t,n){const r=await Yc(`/threads/${t}`,{title:n});return Rt(r)}async deleteThread(t){const n=await Ti(`/threads/${t}`);return Rt(n)}async shareThread(t,n){const r=await Lo(`/threads/${t}/share`,{shared_with_user_id:n});return Rt(r)}async threadInfo(t){const n=await qt(`/threads/${t}/info`);return Rt(n)}async listAgents(){const t=await qt("/agents"),n=Rt(t);return(n==null?void 0:n.items)??[]}async getAgent(t){const n=await qt(`/agents/${t}`);return Rt(n)}async getAgentSchema(t){const n=await qt(`/agents/${t}/schema`);return Rt(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 Rt(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:Gc});return Rt(n)}async cancelRun(t){const n=await Lo("/runs/cancel",{threadId:t});return Rt(n)}async unshareThread(t,n){const r=await Ti(`/threads/${t}/share/${n}`);return Rt(r)}}const An=new $o,fv=$o,pv=$o;async function ki(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 hv(e,t){const n=await ki(`/files/${e}/view`,t),r=URL.createObjectURL(n);window.open(r,"_blank"),setTimeout(()=>URL.revokeObjectURL(r),6e4)}async function Ei(e,t){return await(await ki(`/files/${e}/view`,t)).text()}async function Xc(e,t){const n=await ki(`/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 mv(e){return await qt(`/files/${e}`)}async function Jc(e,t=50,n=0){const r={limit:t,offset:n};return e&&(r.thread_id=e),await qt("/files",{params:r})}function Ii(){const e=b.useContext(au);if(!e)throw new Error("useApi must be used within ApiProvider");return e}async function Zc(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 Qc(e=[]){const t=[],n=[];for(const r of e)try{const o=await Zc(r);n.push({filename:r.name,data:o,mime_type:r.type||"application/octet-stream"})}catch{}return{contentParts:t,filesInfo:n}}function pr(e){if(!(typeof globalThis>"u"))return globalThis[e]}function gv(e){if(typeof e!="string")return;const t=e.trim();if(t)return mn(t)}function eu(){const e=[pr("__API_BASE_URL__"),pr("__CHAT_API_BASE_URL__"),pr("__CHAT_API_URL__")];for(const t of e){const n=gv(t);if(n)return n}}function tu(){const e=[pr("__API_AUTH_TOKEN__"),pr("__CHAT_API_KEY__"),pr("__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 ru(){const e={},t=eu(),n=tu();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function ou(){const e=ru(),t=An.getAuthToken(),n=eu();return{apiBaseUrl:nu(e.baseUrl,An.baseUrl,n),apiKey:t||e.apiKey||tu()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,darkMode:!1,enableSound:!1,messageHistory:100}}const Ni="chat-settings";function su(){try{const e=localStorage.getItem(Ni);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function iu(e){try{const t={...e,apiBaseUrl:mn(e.apiBaseUrl)};localStorage.setItem(Ni,JSON.stringify(t)),t.apiKey&&An.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function xv(){const e=ou(),t=su(),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 vv(e){An.updateConfig({baseUrl:e.apiBaseUrl,authToken:e.apiKey??void 0}),iu(e)}const au=b.createContext(null);function lu({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(au.Provider,{value:r,children:e})}function cu({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=Ql(v),x=g.timeline,[y,w]=b.useState(!1),[S,k]=b.useState(null),[C,T]=b.useState(!1),[E,A]=b.useState(!1),[O,F]=b.useState(!1),[U,W]=b.useState(null),z=b.useRef(o),N=b.useRef(null),q=b.useRef(null),M=b.useRef(null),Q=b.useRef(null),$=b.useRef(!1),_=b.useRef(null),V=b.useRef(new Map);b.useEffect(()=>{z.current=o},[o]);const J=b.useCallback(async L=>{var xe,de;if(!L.threadId)return;const oe=L.threadId;(xe=L.onStart)==null||xe.call(L),L.setLoading(!0);try{await L.action(oe)}catch(we){if(z.current===oe){const Me=String(we);(de=L.handleError)==null||de.call(L,Me),r==null||r(Me)}throw we}finally{L.setLoading(!1)}},[r]),j=b.useCallback(async(L,oe)=>{if(!L)return;const xe=`${L}:${oe??"latest"}`,de=V.current.get(xe);if(de)return de;const we=J({threadId:L,setLoading:T,onStart:()=>W(null),handleError:Me=>W(Me),action:async Me=>{const He=await e.getStateHistory({threadId:Me,checkpointId:oe??void 0});if(z.current!==Me){console.log(`[useThreadHistoryState] Thread changed during load (was ${Me}, now ${z.current}), discarding stale data`);return}const{checkpoints:$e}=Nn(He),Ae=$e.find(Fe=>Fe.messages&&Fe.messages.length>0)??(oe?$e.find(Fe=>Fe.checkpointId===oe):null)??$e[0];t((Ae==null?void 0:Ae.messages)??[],{checkpointId:(Ae==null?void 0:Ae.checkpointId)??null,checkpointNs:(Ae==null?void 0:Ae.checkpointNs)??null}),m(He),w(!!(Ae!=null&&Ae.nextCursor)),k((Ae==null?void 0:Ae.nextCursor)??null)}});V.current.set(xe,we);try{await we}finally{V.current.delete(xe)}return z.current===L&&(_.current=xe),we},[e,t,J]),R=b.useCallback(async(L,oe)=>{Q.current=L;try{await j(L,oe)}finally{Q.current===L&&(Q.current=null)}},[j]),G=b.useCallback(L=>{q.current=L},[]),Y=b.useCallback(L=>{M.current=L},[]),ie=b.useCallback(L=>{const oe=L.threadId??z.current;if(!oe||z.current&&z.current!==oe)return;const{checkpoints:xe}=Nn(L);if(!xe.length)return;const de=xe.find(we=>we.messages&&we.messages.length>0)??xe.find(we=>!!we.checkpointId)??xe[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(L),w(!!(de!=null&&de.nextCursor)),k((de==null?void 0:de.nextCursor)??null),_.current=`${oe}:latest`,q.current=null,M.current=null},[t]),H=b.useCallback(async(L,oe)=>{const xe=z.current;await J({threadId:xe,setLoading:F,action:async de=>{const we=await e.getStateHistory({threadId:de,checkpointId:L,checkpointNs:oe??void 0});if(z.current!==de){console.log(`[useThreadHistoryState] Thread changed during checkpoint navigation (was ${de}, now ${z.current}), discarding stale data`);return}const{checkpoints:Me}=Nn(we),He=Me.find($e=>$e.checkpointId===L&&(oe?$e.checkpointNs===oe:!0));if(!He){console.warn("[useThreadHistoryState] Requested checkpoint not found:",{checkpointId:L,checkpointNs:oe});return}m(we),t(He.messages??[],{checkpointId:He.checkpointId??null,checkpointNs:He.checkpointNs??null})}}).catch(()=>{})},[e,t,J]),D=b.useCallback((L,oe)=>{t(d(),{checkpointId:L??null,checkpointNs:oe??null})},[d,t]),X=b.useCallback(async()=>{z.current&&await R(z.current)},[R]),Z=b.useCallback(async()=>{const L=z.current;!L||!S||await J({threadId:L,setLoading:A,action:async oe=>{const xe=await e.getStateHistory({threadId:oe,checkpointId:S});if(z.current!==oe)return;const{checkpoints:de}=Nn(xe);if(de.length>0){const we=de[de.length-1];n((we==null?void 0:we.messages)??[]),w(!!(we!=null&&we.nextCursor)),k((we==null?void 0:we.nextCursor)??null)}}}).catch(()=>{})},[e,S,r,n,J]);b.useEffect(()=>{if(!l||!o||C||c)return;if(q.current===o){q.current=null,N.current=o;return}if(M.current===o){N.current=o;return}if(Q.current===o){Q.current=null,N.current=o;return}if(N.current===o)return;N.current=o;const L=!$.current&&!!i&&o===s;let oe;L&&i?(oe=i,$.current=!0,console.log("[useThreadHistoryState] Loading thread with checkpoint:",oe,a?`(ns: ${a})`:"")):console.log("[useThreadHistoryState] Loading thread with latest checkpoint");const xe=`${o}:${oe??"latest"}`;_.current!==xe&&R(o,oe)},[l,o,i,a,s,C,c,R]);const ce=b.useCallback(()=>{m(null),w(!1),k(null),T(!1),A(!1),F(!1),W(null),q.current=null,M.current=null,N.current=null,_.current=null,Q.current=null},[]);return{threadCheckpoints:v,threadTimeline:x,checkpointIndex:g,isLoadingThread:C,isHistoryLoading:E,isLoadingCheckpoint:O,threadStateError:U,hasMoreHistory:y,loadThread:R,navigateToCheckpoint:H,loadOlderMessages:Z,setCurrentCheckpointId:D,returnToLatest:X,handleStateHistoryEvent:ie,markSkipNextLoad:G,markStreamPendingThread:Y,resetHistoryState:ce}}const wv=["detail","message","error","description","title"];function Fo(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=Fo(t);if(n)return n}return null}if(typeof e=="object"){const t=e;for(const n of wv){const r=Fo(t[n]);if(r)return r}if("errors"in t){const n=Fo(t.errors);if(n)return n}}return null}function bv(e){if(!e)return"Request failed";const t=e.response,n=Fo(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 uu({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 A=b.useCallback(async()=>{d(!0),m(null);try{const $=await e.listThreads();i($??[])}catch($){const _=String($);m(_),n==null||n(_)}finally{d(!1)}},[e,n]),O=b.useCallback(async()=>{x(!0),y(null);try{const $=await e.listSharedThreads();v($??[])}catch($){const _=String($);y(_),n==null||n(_)}finally{x(!1)}},[e,n]);b.useEffect(()=>{A()},[A]),b.useEffect(()=>{O()},[O]),b.useEffect(()=>{r==null||r(a)},[a,r]);const F=b.useCallback(async $=>{try{const _=await e.createThread($);return l(_.threadId),await A(),_.threadId}catch(_){const V=String(_);return n==null||n(V),null}},[e,n,A]),U=b.useCallback(async $=>{const _=s;i(J=>J.filter(j=>j.threadId!==$));const V=new AbortController;E.current.set($,V);try{await e.deleteThread($),T.current===$&&(l(null),o==null||o())}catch(J){i(_);const j=String(J);n==null||n(j)}finally{E.current.delete($)}},[e,o,n,s]),W=b.useCallback(async($,_)=>{try{await e.updateThread($,_),await A()}catch(V){n==null||n(String(V))}},[e,n,A]),z=b.useCallback(async($,_)=>{C(!0),S("Sharing thread…");try{await e.shareThread($,_),await O(),S("Shared successfully")}catch(V){const J=bv(V);throw n==null||n(J),S(`Failed to share: ${J}`),new Error(J)}finally{C(!1)}},[e,n,O]),N=b.useCallback(async($,_)=>{try{await e.unshareThread($,_),await O()}catch(V){const J=String(V);throw n==null||n(J),V}},[e,n,O]),q=b.useMemo(()=>({createThread:F,deleteThread:U,renameThread:W,refreshThreads:A,refreshSharedThreads:O,shareThread:z,unshareThread:N}),[F,U,W,A,O,z,N]),M=b.useCallback($=>{if(!($!=null&&$.threadId))return;const _={threadId:$.threadId,title:$.title||`Thread ${$.threadId.slice(0,8)}`,createdAt:$.createdAt||new Date().toISOString(),updatedAt:$.updatedAt||new Date().toISOString(),messageCount:$.messageCount??1};i(V=>{let J=!1;const j=V.map(R=>R.threadId===_.threadId?(J=!0,console.debug("[useThreadsState] thread_info: updating existing thread",_.threadId),{...R,title:_.title??R.title,updatedAt:_.updatedAt??R.updatedAt,messageCount:_.messageCount??R.messageCount}):R);return J?j:(console.debug("[useThreadsState] thread_info: adding thread to list",_.threadId),[_,...V])})},[]),Q=b.useCallback(()=>S(null),[]);return{threads:s,currentThreadId:a,currentThreadIdRef:T,setCurrentThreadId:l,isLoadingThreads:c,threadsError:p,sharedThreads:f,isLoadingSharedThreads:g,actions:q,addThreadFromEvent:M,shareInFlight:k,shareStatus:w,clearShareStatus:Q}}function Ai(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 du(e){return!!(e&&typeof e=="object"&&(e.type==="file"||e.mimeType||e.filename||e.sourceType==="base64"))}function Wr(e){if(typeof e=="string")return e;if(e&&typeof e=="object"){if(Array.isArray(e)){const n=e.map(Wr).filter(r=>r!==void 0);if(!n.length){console.debug("[message-utils] sanitizeForDisplay - array emptied -> returning undefined",{originalLength:e.length});return}return n}if(du(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=Wr(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(du(e))return"";try{const t=Wr(e);return t===void 0?"":typeof t=="string"?t:JSON.stringify(t,null,2)}catch{return""}}function yv(e){return typeof e!="string"?!1:/^[\s\n]*[-*]\s|^[\s\n]*#+\s|```|^\s*\[.*\]\(|^>\s/.test(e)}function Sv(e){const t=hr(e);return typeof e=="string"&&yv(e)?{content:e,isMarkdown:!0}:{content:t,isMarkdown:!1}}function Vr(e){if(e==null)return e;if(typeof e=="string"){const t=e.trim();if(t.startsWith("{")||t.startsWith("[")){const n=Ai(t);if(n!==null)return Vr(n)}return e}return typeof e=="object"&&!Array.isArray(e)&&e.content!==void 0?Vr(e.content):e}function Cv(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function _i(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 Bo(e){if(e==null)return null;const t=String(e).trim();return t.length>0?t:null}function Tv(e){const t=r=>{try{const o=Wr(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(`
|
|
36
|
+
`)):t(e)}function kv(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function fu(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 Ev(e){if(!e)return"image/png";const t=e.trim();return t?t.includes("/")?t:`image/${t}`:"image/png"}function Iv(e){const t=[],n=r=>{r&&r.trim()&&t.push(r.trim())};return e&&(n(e.plotId),n(e.artifactId)),t}function Nv({base64:e,url:t,formatHint:n,extras:r}){const o=typeof e=="string"&&e.length>0,s=Ev(n),i=o?`data:${s};base64,${e}`:t,a=Iv(r),l=a.length?a.join(" / "):void 0,c=l?`${l} artifact`:"artifact image";return{src:i,alt:c,label:l}}function Av(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 Nv({base64:t,url:n,formatHint:r,extras:{plotId:e.plotId,artifactId:e.artifactId}})}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 Kr(e,t,n){return t<0||t>=e.length?e:[...e.slice(0,t),n,...e.slice(t+1)]}function _v(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 pu(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="assistant")return e[t].id;return null}function hu(e){return!e||!e.length?"":e.filter(t=>t.type==="text").map(t=>t.text??"").join("")}function jv(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??hu(e);let l="",c=e.slice();if(s){const p=Pv(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 mu(e){return e.replace(/\s+/g," ").trim()}function Pv(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=mu(e),o=mu(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 Mv(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 Kr(e,r,s)}return e}function Rv(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}const Ov={messages:[],assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,messagesStreamMeta:{},pendingInterrupt:null};function Dv(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 gu(e,t.payload.ev);case"batch":{const{events:r}=t.payload;return r.length?r.reduce((o,s)=>gu(o,s),e):e}default:return e}}function Lv(e=[]){const[t,n]=b.useReducer(Dv,{...Ov,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 gu(e,t){var n,r,o;if(t.type==="message.start"&&t.role==="assistant"){const s=t.id,i=Rv(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 Fv(e,t);if(t.type==="tool.progress")return Bv(e,t);if(t.type==="tool.end")return zv(e,t);if(t.type==="message.delta"){const s=e.assemblingId??pu(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:hu(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}=jv(l.content,t.delta,m,f);if(!x)return e;const y={...l,content:v},w=Kr(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??pu(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=Mv(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?_v(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 Pi(e){return e.call_id??e.id??null}function xu(e){return e.id??e.call_id??`tool-${Date.now()}-${Math.random().toString(16).slice(2)}`}function vu(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 Mi(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||_i(r).toolCallId===t)return n}return-1}function $v(e){if(e==null)return[];const t=Vr(e);if(typeof t=="string"&&t.trim())return[{type:"text",text:t}];const n=hr(t??e);return n?[{type:"text",text:n}]:[]}function wu(e,t){const n=e.additionalKwargs??{},r=Array.isArray(n.toolProgress)?[...n.toolProgress]:[],o={...n,toolProgress:[...r,t]};return{...e,additionalKwargs:o}}function Fv(e,t){const n=Pi(t),r=Mi(e.messages,n),o=t.name??t.tool??void 0,s=xu(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:Kr(e.messages,r,d)}}const i=vu(s,n,o,t.args);return{...e,messages:[...e.messages,i]}}function Bv(e,t){const n=Pi(t);if(!n)return e;const r=Mi(e.messages,n);if(r===-1)return e;const o={type:t.type,content:typeof t.content=="string"?t.content:void 0,seq:t.seq??null,timestamp:new Date().toISOString()},s=t.metadata;s&&(o.metadata=s);const i=t.idx;typeof i=="number"&&(o.idx=i);const a=wu(e.messages[r],o);return{...e,messages:Kr(e.messages,r,a)}}function zv(e,t){const n=Pi(t),r=xu(t);let o=e.messages,s=Mi(o,n);if(s===-1){const v=t.name??t.tool??void 0;o=[...o,vu(r,n,v,{})],s=o.length-1}const i=o[s],a=t.output??t.error??null,l=$v(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=wu(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:Kr(o,s,f)}}function Hv(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),A=b.useRef(null),O=b.useRef(null),F=b.useCallback(N=>{o(N)},[]),U=b.useCallback(()=>{m(""),v(null),d(null),E.current=null,A.current=null,O.current=null},[]),W=b.useCallback(()=>{var N;console.debug("[use-chat] stop() invoked - aborting stream"),(N=S.current)==null||N.abort(),S.current=null,T.current=null,l(!1),w(!1),C.current=0,x(0)},[]),z=b.useCallback((N,q,M)=>{S.current&&(S.current.abort(),S.current=null),l(!0),d(null),e.autoAppendAssistant!==!1&&m(""),v(null),E.current=null,A.current=null,O.current=null;const Q=new AbortController;S.current=Q;let $=null,_=null,V=!1;return T.current={threadId:N.threadId??null,headers:{}},(async()=>{var j,R,G,Y,ie,H,D,X,Z,ce,L,oe,xe,de,we,Me,He,$e;const J=Ae=>{var Fe;try{const Ge=JSON.parse(JSON.stringify(Ae));return(Fe=Ge==null?void 0:Ge.payload)!=null&&Fe.files_info&&Array.isArray(Ge.payload.files_info)&&(Ge.payload.files_info=Ge.payload.files_info.map(Ke=>({...Ke,data:Ke!=null&&Ke.data?`<base64 ${String(Ke.data).length} chars>`:Ke==null?void 0:Ke.data}))),Ge}catch{return Ae}};try{let Ae={};try{if(r)Ae={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const Be=window.__AUTH_TOKEN__,St=((j=window.localStorage)==null?void 0:j.getItem("authToken"))||null;let xt=null;try{const gt=(R=window.localStorage)==null?void 0:R.getItem("chat-settings");gt&&(xt=((G=JSON.parse(gt))==null?void 0:G.apiKey)||null)}catch{}const Ye=Be||St||xt||null;Ye&&(Ae={Authorization:`Bearer ${Ye}`})}}catch{}console.debug("[use-chat] POST",t+n,J(N));let Fe={};if(typeof window<"u")try{const De=(Y=window.localStorage)==null?void 0:Y.getItem("authSessionId");De&&(Fe={"X-Session-Id":De})}catch{}const Ge={...Ae,...Fe,...s.current},Ke={"Content-Type":"application/json",Accept:"text/event-stream",...Ge},Xe=await fetch(t+n,{method:"POST",headers:Ke,body:JSON.stringify(N),signal:Q.signal,credentials:i});if(T.current&&(T.current.headers=Ge),!Xe.ok||!Xe.body){const De=await Xe.text().catch(()=>"");console.debug("[use-chat] non-OK response",Xe.status,De==null?void 0:De.slice(0,500));const Be=`stream ${Xe.status}${De?": "+De:""}`;throw(ie=M==null?void 0:M.onConnectionError)==null||ie.call(M,Be),V=!0,$="error",_=Be,new Error(Be)}w(!0);const tt=Xe.body.getReader(),nt=new TextDecoder;let Ze="",pt=[];C.current=0,x(0);let ht=0,Se=null;const Re=()=>{if(pt.length){const De=pt.join("");pt=[],k.current&&m(Be=>Be+De)}Se=null},mt=()=>{typeof window<"u"&&Se==null&&(Se=requestAnimationFrame(Re))};let ot=Date.now();const qe=setInterval(()=>{var De;if(Date.now()-ot>18e5){const Be="Stream idle timeout";d(Be),$="error",_=Be,Q.abort(),(De=M==null?void 0:M.onError)==null||De.call(M,Be)}},5e3),yt=1024*1024;try{const De=Xe.headers.get("X-Thread-Id")||Xe.headers.get("x-thread-id"),Be=Xe.headers.get("X-Thread-Created")||Xe.headers.get("x-thread-created"),St=De??null,xt=String(Be??"").toLowerCase()==="true";for(T.current&&!T.current.threadId&&(T.current={...T.current,threadId:St}),(H=M==null?void 0:M.onOpen)==null||H.call(M,{threadId:St,created:xt});;){const{value:Ye,done:gt}=await tt.read();if(gt)break;Ze+=nt.decode(Ye,{stream:!0}),Ze.length>yt&&(Ze="",console.warn("Stream buffer reset: exceeded 1MB"));let P;for(;(P=Ze.indexOf(`
|
|
37
37
|
|
|
38
|
-
`))>=0;){const te=Ze.slice(0,P);Ze=Ze.slice(P+2);const ve=Wv(te);if(!ve)continue;let ae;try{ae=JSON.parse(ve)}catch{console.debug("[use-chat] malformed SSE:",ve.slice(0,200));continue}const Ie=Uv(ae)?ae.data:ae;if(!Ie){console.warn("[use-chat] dropped envelope event without payload",ae);continue}const Te=Ie;ot=Date.now();const st=Te.seq;if(st!==void 0){if(st<=ht){console.debug("[use-chat] drop duplicate/out-of-order event",{seq:st,lastProcessedSeq:ht,type:Te.type});continue}ht>0&&st>ht+1&&((D=M==null?void 0:M.onGap)==null||D.call(M,{from:ht,to:st})),ht=st,C.current=st,x(st)}if(Te.type==="checkpoint")E.current=Te.checkpointId??null,A.current=Te.checkpointNs??null,v(Te.checkpointId??null);else if(Te.type==="state_history"){O.current=Te;try{const lt=Nn(Te).latest;lt&&(E.current=lt.checkpointId??null,A.current=lt.checkpointNs??null,v(lt.checkpointId??null))}catch(Ue){console.warn("[use-chat] Failed to hydrate state_history payload",Ue)}}try{
|
|
39
|
-
`)}const wu=b.createContext(null),bu=b.createContext(null),yu=b.createContext(null);b.createContext(!1);function Vv({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}=ki(),m=b.useMemo(()=>mn(p),[p]),{state:f,seed:v,prepend:g,pushUser:x,onEvent:y}=Lv(),{threads:w,currentThreadId:S,setCurrentThreadId:k,currentThreadIdRef:C,isLoadingThreads:T,threadsError:E,sharedThreads:A,isLoadingSharedThreads:O,actions:F,addThreadFromEvent:U,shareInFlight:W,shareStatus:z,clearShareStatus:N}=cu({api:d,initialThreadId:t,onError:s,onThreadChange:a,onCurrentThreadDeleted:()=>v([],{})}),[K,M]=b.useState(!1),Q=b.useCallback(()=>f.messages,[f.messages]),{threadCheckpoints:$,threadTimeline:_,checkpointIndex:V,isLoadingThread:J,isHistoryLoading:j,isLoadingCheckpoint:R,threadStateError:G,hasMoreHistory:Y,loadThread:ie,navigateToCheckpoint:H,loadOlderMessages:D,setCurrentCheckpointId:X,returnToLatest:Z,handleStateHistoryEvent:ce,markSkipNextLoad:L,markStreamPendingThread:oe,resetHistoryState:xe}=lu({api:d,seed:v,prepend:g,onError:s,currentThreadId:S,initialThreadId:t,initialCheckpointId:n,initialCheckpointNs:r,autoLoadInitial:o,isStreaming:K,getMessages:Q}),de=b.useCallback(Se=>{console.log("[StreamingProvider] 🎯 Received thread_info:",Se.threadId),U(Se),C.current!==Se.threadId&&((Se.created??!C.current)&&L(Se.threadId),oe(Se.threadId),console.log("[StreamingProvider] thread_info: marking to skip auto-load for new thread"),k(Se.threadId))},[U,L,oe]),we=b.useCallback(Se=>{Se.type==="thread_info"?de(Se):Se.type==="state_history"?ce(Se):Se.type==="tool.end"?c==null||c(Se):y(Se)},[de,ce,c,y]),{stream:Me,stop:He,isStreaming:$e,error:Ae,setToken:Fe}=Hv({baseUrl:m}),Ge=b.useCallback(Se=>{Me(Se,we,{onError:Re=>{console.error("[StreamingProvider] Stream error:",Re),s==null||s(Re)},onAuthError:Re=>{console.error("[StreamingProvider] Auth error:",Re),i==null||i(Re)},onConnectionError:Re=>{console.error("[StreamingProvider] Connection error:",Re),l==null||l(Re)}})},[Me,we,s,i,l]);b.useEffect(()=>{M($e)},[$e]);const Ke=b.useCallback(async()=>{v([],{}),k(null),He(),xe();try{await d.getAgent("default")}catch(Se){console.warn("[StreamingProvider] Failed to refetch agent after clearing thread:",Se)}},[v,He,d,xe]),Xe=b.useCallback(async(Se,Re,mt)=>{const ot=C.current;if(!ot)throw new Error("No active thread to handle interrupt");const qe=Re?mt??!0:!1;try{const yt={threadId:ot,checkpointId:f.lastCheckpointId??void 0,checkpointNs:f.lastCheckpointNs??void 0,command:{kind:"resume",value:qe}};Ge(yt)}catch(yt){throw console.error(`[StreamingProvider] Failed to handle interrupt ${Se}:`,yt),yt}},[f.lastCheckpointId,f.lastCheckpointNs,Ge]),tt=b.useCallback(async(Se,Re)=>{let mt=C.current;const ot=(Se==null?void 0:Se.text)??"",qe=(Se==null?void 0:Se.attachments)??[],yt=(ot==null?void 0:ot.trim())??"",De={...(Se==null?void 0:Se.payload)??{}},Be=Array.isArray(De.messages)?De.messages:void 0;Be&&delete De.messages;const St=!!(Be&&Be.length);if(!mt&&!yt&&qe.length===0&&!St)return;if(!mt){const Ue=Math.floor(Date.now()/1e3).toString(16).padStart(8,"0"),lt=Array.from({length:4},()=>Math.floor(Math.random()*4294967295).toString(16).padStart(8,"0")).join("").slice(0,16);mt=`${Ue}${lt}`,L(mt),k(mt)}const{contentParts:xt,filesInfo:Ye}=await Zc(qe),gt=[...xt];yt&>.push({type:"text",text:ot});const P=Re==null?void 0:Re.originalMessageId,te=!!(Re!=null&&Re.edit&&P),ve=!St&>.length>0;let ae=null;ve&&(ae={id:te?P:`msg-${Date.now()}`,role:"user",content:gt,createdAt:new Date().toISOString()},te?x(ae,P):x(ae));const Ie=St?Be:ae?[ae]:[],Te={...De,...Ye.length?{files_info:Ye}:{}};Ie.length?Te.messages=Ie:"messages"in Te||(Te.messages=[]);const st={threadId:mt,payload:Te,checkpointId:(Re==null?void 0:Re.checkpointId)??f.lastCheckpointId??void 0,checkpointNs:(Re==null?void 0:Re.checkpointNs)??f.lastCheckpointNs??void 0,edit:!!(Re!=null&&Re.edit),timelineCheckpoints:_};Ge(st)},[d,x,f,Ge,_]),nt=b.useMemo(()=>({threads:w,currentThreadId:S,setCurrentThreadId:k,isLoading:T,error:E,sharedThreads:A,isLoadingSharedThreads:O,actions:F,shareInFlight:W,shareStatus:z,clearShareStatus:N}),[w,S,k,T,E,A,O,F,W,z,N]),Ze=b.useMemo(()=>{const Se=f.assemblingId??null;return Se?{assemblingMessageId:Se}:null},[f.assemblingId]),pt=b.useMemo(()=>({threadId:S,messages:f.messages,interrupt:null,checkpoint:{id:f.lastCheckpointId??null,namespace:f.lastCheckpointNs??null},checkpoints:$,checkpointIndex:V,timelineCheckpoints:_,metadata:Ze,isLoading:J,isHistoryLoading:j,isLoadingCheckpoint:R,error:G,hasMore:Y,loadOlder:D,clearState:Ke,navigateToCheckpoint:H,setCurrentCheckpointId:X,returnToLatest:Z,loadThread:ie,clearThread:Ke,respondToInterrupt:Xe,messagePreviews:V.messagePreviews}),[S,f,$,_,V,J,j,R,G,Y,D,Ke,H,X,Z,ie,Xe,Ze]),ht=b.useMemo(()=>({isStreaming:$e,error:Ae,connectionState:$e?"connected":"idle",submit:tt,send:tt,stop:He,setAuthToken:Fe}),[$e,Ae,tt,He,Fe]);return u.jsx(wu.Provider,{value:nt,children:u.jsx(bu.Provider,{value:pt,children:u.jsx(yu.Provider,{value:ht,children:e})})})}function Pi(){const e=b.useContext(wu);if(!e)throw new Error("useThreads must be used within StreamingProvider");return e}function Mi(){const e=b.useContext(bu);if(!e)throw new Error("useThreadState must be used within StreamingProvider");return e}function Su(){const e=b.useContext(yu);if(!e)throw new Error("useStream must be used within StreamingProvider");return e}function zo({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(au,{apiConfig:t,children:u.jsx(Vv,{initialThreadId:n,initialCheckpointId:r,initialCheckpointNs:o,autoLoadInitial:s,onError:a,onAuthError:l,onConnectionError:i,onThreadChange:c,onToolEnd:d,children:e})})}function re(...e){return Og.twMerge(Rg.clsx(e))}const Kv=Or.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"}}),ct=h.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?Vt.Slot:"button";return u.jsx(i,{className:re(Kv({variant:t,size:n,className:e})),ref:s,...o})});ct.displayName="Button";var Cu=1,qv=.9,Gv=.8,Yv=.17,Ri=.1,Oi=.999,Xv=.9999,Jv=.99,Zv=/[\\\/_+.#"@\[\(\{&]/,Qv=/[\\\/_+.#"@\[\(\{&]/g,ew=/[\s-]/,Tu=/[\s-]/g;function Di(e,t,n,r,o,s,i){if(s===t.length)return o===e.length?Cu:Jv;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=Di(e,t,n,r,c+1,s+1,i),p>d&&(c===o?p*=Cu:Zv.test(e.charAt(c-1))?(p*=Gv,f=e.slice(o,c-1).match(Qv),f&&o>0&&(p*=Math.pow(Oi,f.length))):ew.test(e.charAt(c-1))?(p*=qv,v=e.slice(o,c-1).match(Tu),v&&o>0&&(p*=Math.pow(Oi,v.length))):(p*=Yv,o>0&&(p*=Math.pow(Oi,c-o))),e.charAt(c)!==t.charAt(s)&&(p*=Xv)),(p<Ri&&n.charAt(c-1)===r.charAt(s+1)||r.charAt(s+1)===r.charAt(s)&&n.charAt(c-1)!==r.charAt(s))&&(m=Di(e,t,n,r,c+1,s+2,i),m*Ri>p&&(p=m*Ri)),p>d&&(d=p),c=n.indexOf(l,c+1);return i[a]=d,d}function ku(e){return e.toLowerCase().replace(Tu," ")}function tw(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,Di(e,t,ku(e),ku(t),0,0,{})}function le(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 Eu(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function _n(...e){return t=>{let n=!1;const r=e.map(o=>{const s=Eu(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():Eu(e[o],null)}}}}function We(...e){return h.useCallback(_n(...e),e)}function nw(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,rw(o,...t)]}function rw(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(s){const i=r.reduce((a,{useScope: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 It=globalThis!=null&&globalThis.document?h.useLayoutEffect:()=>{},ow=h[" useId ".trim().toString()]||(()=>{}),sw=0;function At(e){const[t,n]=h.useState(ow());return It(()=>{n(r=>r??String(sw++))},[e]),t?`radix-${t}`:""}var iw=h[" useInsertionEffect ".trim().toString()]||It;function jn({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=aw({defaultProp:t,onChange:n}),a=e!==void 0,l=a?e:o;{const d=h.useRef(e!==void 0);h.useEffect(()=>{const 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=lw(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 aw({defaultProp:e,onChange:t}){const[n,r]=h.useState(e),o=h.useRef(n),s=h.useRef(t);return iw(()=>{s.current=t},[t]),h.useEffect(()=>{var i;o.current!==n&&((i=s.current)==null||i.call(s,n),o.current=n)},[n,o]),[n,r,s]}function lw(e){return typeof e=="function"}var cw=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],ye=cw.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 Li(e,t){e&&Dr.flushSync(()=>e.dispatchEvent(t))}function wt(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 uw(e,t=globalThis==null?void 0:globalThis.document){const n=wt(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 dw="DismissableLayer",$i="dismissableLayer.update",fw="dismissableLayer.pointerDownOutside",pw="dismissableLayer.focusOutside",Iu,Nu=h.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),mr=h.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...l}=e,c=h.useContext(Nu),[d,p]=h.useState(null),m=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,f]=h.useState({}),v=We(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=mw(E=>{const A=E.target,O=[...c.branches].some(F=>F.contains(A));!k||O||(o==null||o(E),i==null||i(E),E.defaultPrevented||a==null||a())},m),T=gw(E=>{const A=E.target;[...c.branches].some(F=>F.contains(A))||(s==null||s(E),i==null||i(E),E.defaultPrevented||a==null||a())},m);return uw(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&&(Iu=m.body.style.pointerEvents,m.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(d)),c.layers.add(d),_u(),()=>{n&&c.layersWithOutsidePointerEventsDisabled.size===1&&(m.body.style.pointerEvents=Iu)}},[d,m,n,c]),h.useEffect(()=>()=>{d&&(c.layers.delete(d),c.layersWithOutsidePointerEventsDisabled.delete(d),_u())},[d,c]),h.useEffect(()=>{const E=()=>f({});return document.addEventListener($i,E),()=>document.removeEventListener($i,E)},[]),u.jsx(ye.div,{...l,ref:v,style:{pointerEvents:S?k?"auto":"none":void 0,...e.style},onFocusCapture:le(e.onFocusCapture,T.onFocusCapture),onBlurCapture:le(e.onBlurCapture,T.onBlurCapture),onPointerDownCapture:le(e.onPointerDownCapture,C.onPointerDownCapture)})});mr.displayName=dw;var hw="DismissableLayerBranch",Au=h.forwardRef((e,t)=>{const n=h.useContext(Nu),r=h.useRef(null),o=We(t,r);return h.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),u.jsx(ye.div,{...e,ref:o})});Au.displayName=hw;function mw(e,t=globalThis==null?void 0:globalThis.document){const n=wt(e),r=h.useRef(!1),o=h.useRef(()=>{});return h.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){ju(fw,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 gw(e,t=globalThis==null?void 0:globalThis.document){const n=wt(e),r=h.useRef(!1);return h.useEffect(()=>{const o=s=>{s.target&&!r.current&&ju(pw,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 _u(){const e=new CustomEvent($i);document.dispatchEvent(e)}function ju(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?Li(o,s):o.dispatchEvent(s)}var xw=mr,vw=Au,Fi="focusScope.autoFocusOnMount",Bi="focusScope.autoFocusOnUnmount",Pu={bubbles:!1,cancelable:!0},ww="FocusScope",Ho=h.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,l]=h.useState(null),c=wt(o),d=wt(s),p=h.useRef(null),m=We(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){Ou.add(f);const g=document.activeElement;if(!a.contains(g)){const y=new CustomEvent(Fi,Pu);a.addEventListener(Fi,c),a.dispatchEvent(y),y.defaultPrevented||(bw(kw(Mu(a)),{select:!0}),document.activeElement===g&&Pn(a))}return()=>{a.removeEventListener(Fi,c),setTimeout(()=>{const y=new CustomEvent(Bi,Pu);a.addEventListener(Bi,d),a.dispatchEvent(y),y.defaultPrevented||Pn(g??document.body,{select:!0}),a.removeEventListener(Bi,d),Ou.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]=yw(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(ye.div,{tabIndex:-1,...i,ref:m,onKeyDown:v})});Ho.displayName=ww;function bw(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Pn(r,{select:t}),document.activeElement!==n)return}function yw(e){const t=Mu(e),n=Ru(t,e),r=Ru(t.reverse(),e);return[n,r]}function Mu(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 Ru(e,t){for(const n of e)if(!Sw(n,{upTo:t}))return n}function Sw(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 Cw(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&&Cw(e)&&t&&e.select()}}var Ou=Tw();function Tw(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=Du(e,t),e.unshift(t)},remove(t){var n;e=Du(e,t),(n=e[0])==null||n.resume()}}}function Du(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function kw(e){return e.filter(t=>t.tagName!=="A")}var Ew="Portal",qr=h.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=h.useState(!1);It(()=>s(!0),[]);const i=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?To.createPortal(u.jsx(ye.div,{...r,ref:t}),i):null});qr.displayName=Ew;function Iw(e,t){return h.useReducer((n,r)=>t[n][r]??n,e)}var Ft=e=>{const{present:t,children:n}=e,r=Nw(t),o=typeof n=="function"?n({present:r.isPresent}):h.Children.only(n),s=We(r.ref,Aw(o));return typeof n=="function"||r.isPresent?h.cloneElement(o,{ref:s}):null};Ft.displayName="Presence";function Nw(e){const[t,n]=h.useState(),r=h.useRef(null),o=h.useRef(e),s=h.useRef("none"),i=e?"mounted":"unmounted",[a,l]=Iw(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return h.useEffect(()=>{const c=Uo(r.current);s.current=a==="mounted"?c:"none"},[a]),It(()=>{const c=r.current,d=o.current;if(d!==e){const m=s.current,f=Uo(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]),It(()=>{if(t){let c;const d=t.ownerDocument.defaultView??window,p=f=>{const g=Uo(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=Uo(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 Uo(e){return(e==null?void 0:e.animationName)||"none"}function Aw(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 zi=0;function Hi(){h.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Lu()),document.body.insertAdjacentElement("beforeend",e[1]??Lu()),zi++,()=>{zi===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),zi--}},[])}function Lu(){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 gn=function(){return gn=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},gn.apply(this,arguments)};function $u(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 _w(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 Wo="right-scroll-bar-position",Vo="width-before-scroll-bar",jw="with-scroll-bars-hidden",Pw="--removed-body-scroll-bar-size";function Ui(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function Mw(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 Rw=typeof window<"u"?h.useLayoutEffect:h.useEffect,Fu=new WeakMap;function Ow(e,t){var n=Mw(null,function(r){return e.forEach(function(o){return Ui(o,r)})});return Rw(function(){var r=Fu.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||Ui(a,null)}),s.forEach(function(a){o.has(a)||Ui(a,i)})}Fu.set(n,e)},[e]),n}function Dw(e){return e}function Lw(e,t){t===void 0&&(t=Dw);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 $w(e){e===void 0&&(e={});var t=Lw(null);return t.options=gn({async:!0,ssr:!1},e),t}var Bu=function(e){var t=e.sideCar,n=$u(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,gn({},n))};Bu.isSideCarExport=!0;function Fw(e,t){return e.useMedium(t),Bu}var zu=$w(),Wi=function(){},Ko=h.forwardRef(function(e,t){var n=h.useRef(null),r=h.useState({onScrollCapture:Wi,onWheelCapture:Wi,onTouchMoveCapture:Wi}),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=$u(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=m,T=Ow([n,t]),E=gn(gn({},k),o);return h.createElement(h.Fragment,null,d&&h.createElement(C,{sideCar:zu,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),gn(gn({},E),{ref:T})):h.createElement(w,gn({},E,{className:l,ref:T}),a))});Ko.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},Ko.classNames={fullWidth:Vo,zeroRight:Wo};var Bw=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function zw(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Bw();return t&&e.setAttribute("nonce",t),e}function Hw(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Uw(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var Ww=function(){var e=0,t=null;return{add:function(n){e==0&&(t=zw())&&(Hw(t,n),Uw(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Vw=function(){var e=Ww();return function(t,n){h.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Hu=function(){var e=Vw(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},Kw={left:0,top:0,right:0,gap:0},Vi=function(e){return parseInt(e||"",10)||0},qw=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[Vi(n),Vi(r),Vi(o)]},Gw=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Kw;var t=qw(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])}},Yw=Hu(),gr="data-scroll-locked",Xw=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(
|
|
38
|
+
`))>=0;){const te=Ze.slice(0,P);Ze=Ze.slice(P+2);const ve=Wv(te);if(!ve)continue;let ae;try{ae=JSON.parse(ve)}catch{console.debug("[use-chat] malformed SSE:",ve.slice(0,200));continue}const Ie=Uv(ae)?ae.data:ae;if(!Ie){console.warn("[use-chat] dropped envelope event without payload",ae);continue}const Te=Ie;ot=Date.now();const st=Te.seq;if(st!==void 0){if(st<=ht){console.debug("[use-chat] drop duplicate/out-of-order event",{seq:st,lastProcessedSeq:ht,type:Te.type});continue}ht>0&&st>ht+1&&((D=M==null?void 0:M.onGap)==null||D.call(M,{from:ht,to:st})),ht=st,C.current=st,x(st)}if(Te.type==="checkpoint")E.current=Te.checkpointId??null,A.current=Te.checkpointNs??null,v(Te.checkpointId??null);else if(Te.type==="state_history"){O.current=Te;try{const lt=Nn(Te).latest;lt&&(E.current=lt.checkpointId??null,A.current=lt.checkpointNs??null,v(lt.checkpointId??null))}catch(Ue){console.warn("[use-chat] Failed to hydrate state_history payload",Ue)}}try{q==null||q(Te)}catch(Ue){console.error("[use-chat] Error in onEvent callback:",Ue,"for event:",Te.type)}if(Te.type==="message.delta"){const Ue=Te.delta.filter(lt=>lt.type==="text").map(lt=>lt.text).join("");Ue&&e.autoAppendAssistant!==!1&&(pt.push(Ue),mt())}else if(Te.type==="heartbeat"){console.debug("[use-chat] heartbeat received");try{(X=M==null?void 0:M.onHeartbeat)==null||X.call(M,Te)}catch(Ue){console.warn("[use-chat] heartbeat callback failed",Ue)}}else if(Se!==null&&cancelAnimationFrame(Se),Re(),Te.type==="checkpoint")v(Te.checkpointId);else if(Te.type==="error"){const Ue=Te;if(d(Ue.message),$="error",_=Ue.message,Ue.error_type==="auth_error"||Ue.code==="TOKEN_EXPIRED"||((Z=Ue.message)==null?void 0:Z.includes("token"))||((ce=Ue.message)==null?void 0:ce.includes("401"))||((L=Ue.message)==null?void 0:L.includes("unauthorized"))||((oe=Ue.message)==null?void 0:oe.includes("Unauthorized"))){console.error("[use-chat] Auth error detected:",Ue.message);try{(xe=M==null?void 0:M.onAuthError)==null||xe.call(M,Ue.message)}catch(Ut){console.warn("[use-chat] onAuthError handler failed",Ut)}Q.abort()}}}}Re(),$===null&&!Q.signal.aborted&&($="complete")}catch(De){if(De.name==="AbortError")$=$??"aborted";else{const Be=De.message||String(De);$="error",_=Be,d(Be),(de=M==null?void 0:M.onError)==null||de.call(M,Be)}}finally{try{await tt.cancel()}catch{}finally{(we=tt.releaseLock)==null||we.call(tt)}Se!==null&&typeof window<"u"&&window.cancelAnimationFrame(Se),clearInterval(qe)}}catch(Ae){if(Ae.name==="AbortError")$=$??"aborted";else{const Fe=Ae.message||String(Ae);$="error",_=Fe,d(Fe),(Me=M==null?void 0:M.onError)==null||Me.call(M,Fe),V||((He=M==null?void 0:M.onConnectionError)==null||He.call(M,Fe),V=!0)}}finally{const Ae=C.current,Fe=E.current,Ge=A.current,Ke=O.current,Xe=$??(Q.signal.aborted?"aborted":_?"error":"complete");try{($e=M==null?void 0:M.onClosed)==null||$e.call(M,{reason:Xe,lastSeq:Ae,lastCheckpointId:Fe,lastCheckpointNs:Ge,lastStateHistory:Ke,error:_})}catch(tt){console.warn("[use-chat] onClosed callback failed",tt)}l(!1),w(!1),S.current=null,C.current=0,x(0),T.current=null}})(),{close:()=>Q.abort()}},[t,n,r,e.autoAppendAssistant]);return b.useEffect(()=>()=>{var N;k.current=!1,(N=S.current)==null||N.abort()},[]),{isStreaming:a,error:c,assistantText:p,lastCheckpointId:f,lastSeq:g,connected:y,stream:z,stop:W,clear:U,setToken:F}}function Uv(e){return!!e&&typeof e=="object"&&e.protocolVersion==="v1"&&"data"in e}function Wv(e){const t=e.split(/\r?\n/),n=[];for(const r of t)if(r&&!r.startsWith(":")&&r.startsWith("data:")){const o=r.slice(5);n.push(o.startsWith(" ")?o.slice(1):o)}return n.length===0?null:n.join(`
|
|
39
|
+
`)}const bu=b.createContext(null),yu=b.createContext(null),Su=b.createContext(null),Vv=b.createContext(!1);function Kv({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}=Ii(),m=b.useMemo(()=>mn(p),[p]),{state:f,seed:v,prepend:g,pushUser:x,onEvent:y}=Lv(),{threads:w,currentThreadId:S,setCurrentThreadId:k,currentThreadIdRef:C,isLoadingThreads:T,threadsError:E,sharedThreads:A,isLoadingSharedThreads:O,actions:F,addThreadFromEvent:U,shareInFlight:W,shareStatus:z,clearShareStatus:N}=uu({api:d,initialThreadId:t,onError:s,onThreadChange:a,onCurrentThreadDeleted:()=>v([],{})}),[q,M]=b.useState(!1),Q=b.useCallback(()=>f.messages,[f.messages]),{threadCheckpoints:$,threadTimeline:_,checkpointIndex:V,isLoadingThread:J,isHistoryLoading:j,isLoadingCheckpoint:R,threadStateError:G,hasMoreHistory:Y,loadThread:ie,navigateToCheckpoint:H,loadOlderMessages:D,setCurrentCheckpointId:X,returnToLatest:Z,handleStateHistoryEvent:ce,markSkipNextLoad:L,markStreamPendingThread:oe,resetHistoryState:xe}=cu({api:d,seed:v,prepend:g,onError:s,currentThreadId:S,initialThreadId:t,initialCheckpointId:n,initialCheckpointNs:r,autoLoadInitial:o,isStreaming:q,getMessages:Q}),de=b.useCallback(Se=>{console.log("[StreamingProvider] 🎯 Received thread_info:",Se.threadId),U(Se),C.current!==Se.threadId&&((Se.created??!C.current)&&L(Se.threadId),oe(Se.threadId),console.log("[StreamingProvider] thread_info: marking to skip auto-load for new thread"),k(Se.threadId))},[U,L,oe]),we=b.useCallback(Se=>{Se.type==="thread_info"?de(Se):Se.type==="state_history"?ce(Se):Se.type==="tool.end"?c==null||c(Se):y(Se)},[de,ce,c,y]),{stream:Me,stop:He,isStreaming:$e,error:Ae,setToken:Fe}=Hv({baseUrl:m}),Ge=b.useCallback(Se=>{Me(Se,we,{onError:Re=>{console.error("[StreamingProvider] Stream error:",Re),s==null||s(Re)},onAuthError:Re=>{console.error("[StreamingProvider] Auth error:",Re),i==null||i(Re)},onConnectionError:Re=>{console.error("[StreamingProvider] Connection error:",Re),l==null||l(Re)}})},[Me,we,s,i,l]);b.useEffect(()=>{M($e)},[$e]);const Ke=b.useCallback(async()=>{v([],{}),k(null),He(),xe();try{await d.getAgent("default")}catch(Se){console.warn("[StreamingProvider] Failed to refetch agent after clearing thread:",Se)}},[v,He,d,xe]),Xe=b.useCallback(async(Se,Re,mt)=>{const ot=C.current;if(!ot)throw new Error("No active thread to handle interrupt");const qe=Re?mt??!0:!1;try{const yt={threadId:ot,checkpointId:f.lastCheckpointId??void 0,checkpointNs:f.lastCheckpointNs??void 0,command:{kind:"resume",value:qe}};Ge(yt)}catch(yt){throw console.error(`[StreamingProvider] Failed to handle interrupt ${Se}:`,yt),yt}},[f.lastCheckpointId,f.lastCheckpointNs,Ge]),tt=b.useCallback(async(Se,Re)=>{let mt=C.current;const ot=(Se==null?void 0:Se.text)??"",qe=(Se==null?void 0:Se.attachments)??[],yt=(ot==null?void 0:ot.trim())??"",De={...(Se==null?void 0:Se.payload)??{}},Be=Array.isArray(De.messages)?De.messages:void 0;Be&&delete De.messages;const St=!!(Be&&Be.length);if(!mt&&!yt&&qe.length===0&&!St)return;if(!mt){const Ue=Math.floor(Date.now()/1e3).toString(16).padStart(8,"0"),lt=Array.from({length:4},()=>Math.floor(Math.random()*4294967295).toString(16).padStart(8,"0")).join("").slice(0,16);mt=`${Ue}${lt}`,L(mt),k(mt)}const{contentParts:xt,filesInfo:Ye}=await Qc(qe),gt=[...xt];yt&>.push({type:"text",text:ot});const P=Re==null?void 0:Re.originalMessageId,te=!!(Re!=null&&Re.edit&&P),ve=!St&>.length>0;let ae=null;ve&&(ae={id:te?P:`msg-${Date.now()}`,role:"user",content:gt,createdAt:new Date().toISOString()},te?x(ae,P):x(ae));const Ie=St?Be:ae?[ae]:[],Te={...De,...Ye.length?{files_info:Ye}:{}};Ie.length?Te.messages=Ie:"messages"in Te||(Te.messages=[]);const st={threadId:mt,payload:Te,checkpointId:(Re==null?void 0:Re.checkpointId)??f.lastCheckpointId??void 0,checkpointNs:(Re==null?void 0:Re.checkpointNs)??f.lastCheckpointNs??void 0,edit:!!(Re!=null&&Re.edit),timelineCheckpoints:_};Ge(st)},[d,x,f,Ge,_]),nt=b.useMemo(()=>({threads:w,currentThreadId:S,setCurrentThreadId:k,isLoading:T,error:E,sharedThreads:A,isLoadingSharedThreads:O,actions:F,shareInFlight:W,shareStatus:z,clearShareStatus:N}),[w,S,k,T,E,A,O,F,W,z,N]),Ze=b.useMemo(()=>{const Se=f.assemblingId??null;return Se?{assemblingMessageId:Se}:null},[f.assemblingId]),pt=b.useMemo(()=>({threadId:S,messages:f.messages,interrupt:null,checkpoint:{id:f.lastCheckpointId??null,namespace:f.lastCheckpointNs??null},checkpoints:$,checkpointIndex:V,timelineCheckpoints:_,metadata:Ze,isLoading:J,isHistoryLoading:j,isLoadingCheckpoint:R,error:G,hasMore:Y,loadOlder:D,clearState:Ke,navigateToCheckpoint:H,setCurrentCheckpointId:X,returnToLatest:Z,loadThread:ie,clearThread:Ke,respondToInterrupt:Xe,messagePreviews:V.messagePreviews}),[S,f,$,_,V,J,j,R,G,Y,D,Ke,H,X,Z,ie,Xe,Ze]),ht=b.useMemo(()=>({isStreaming:$e,error:Ae,connectionState:$e?"connected":"idle",submit:tt,send:tt,stop:He,setAuthToken:Fe}),[$e,Ae,tt,He,Fe]);return u.jsx(bu.Provider,{value:nt,children:u.jsx(yu.Provider,{value:pt,children:u.jsx(Su.Provider,{value:ht,children:e})})})}function qv(){return b.useContext(Vv)}function zo(){const e=b.useContext(bu);if(!e)throw new Error("useThreads must be used within StreamingProvider");return e}function Ho(){const e=b.useContext(yu);if(!e)throw new Error("useThreadState must be used within StreamingProvider");return e}function Ri(){const e=b.useContext(Su);if(!e)throw new Error("useStream must be used within StreamingProvider");return e}function Uo({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(lu,{apiConfig:t,children:u.jsx(Kv,{initialThreadId:n,initialCheckpointId:r,initialCheckpointNs:o,autoLoadInitial:s,onError:a,onAuthError:l,onConnectionError:i,onThreadChange:c,onToolEnd:d,children:e})})}function re(...e){return Og.twMerge(Rg.clsx(e))}const Gv=Or.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"}}),ct=h.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?Vt.Slot:"button";return u.jsx(i,{className:re(Gv({variant:t,size:n,className:e})),ref:s,...o})});ct.displayName="Button";var Cu=1,Yv=.9,Xv=.8,Jv=.17,Oi=.1,Di=.999,Zv=.9999,Qv=.99,ew=/[\\\/_+.#"@\[\(\{&]/,tw=/[\\\/_+.#"@\[\(\{&]/g,nw=/[\s-]/,Tu=/[\s-]/g;function Li(e,t,n,r,o,s,i){if(s===t.length)return o===e.length?Cu:Qv;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=Li(e,t,n,r,c+1,s+1,i),p>d&&(c===o?p*=Cu:ew.test(e.charAt(c-1))?(p*=Xv,f=e.slice(o,c-1).match(tw),f&&o>0&&(p*=Math.pow(Di,f.length))):nw.test(e.charAt(c-1))?(p*=Yv,v=e.slice(o,c-1).match(Tu),v&&o>0&&(p*=Math.pow(Di,v.length))):(p*=Jv,o>0&&(p*=Math.pow(Di,c-o))),e.charAt(c)!==t.charAt(s)&&(p*=Zv)),(p<Oi&&n.charAt(c-1)===r.charAt(s+1)||r.charAt(s+1)===r.charAt(s)&&n.charAt(c-1)!==r.charAt(s))&&(m=Li(e,t,n,r,c+1,s+2,i),m*Oi>p&&(p=m*Oi)),p>d&&(d=p),c=n.indexOf(l,c+1);return i[a]=d,d}function ku(e){return e.toLowerCase().replace(Tu," ")}function rw(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,Li(e,t,ku(e),ku(t),0,0,{})}function le(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 Eu(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function _n(...e){return t=>{let n=!1;const r=e.map(o=>{const s=Eu(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():Eu(e[o],null)}}}}function We(...e){return h.useCallback(_n(...e),e)}function ow(e,t){const n=h.createContext(t),r=s=>{const{children:i,...a}=s,l=h.useMemo(()=>a,Object.values(a));return 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,sw(o,...t)]}function sw(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(s){const i=r.reduce((a,{useScope:l,scopeName: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 It=globalThis!=null&&globalThis.document?h.useLayoutEffect:()=>{},iw=h[" useId ".trim().toString()]||(()=>{}),aw=0;function At(e){const[t,n]=h.useState(iw());return It(()=>{n(r=>r??String(aw++))},[e]),t?`radix-${t}`:""}var lw=h[" useInsertionEffect ".trim().toString()]||It;function jn({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=cw({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=uw(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 cw({defaultProp:e,onChange:t}){const[n,r]=h.useState(e),o=h.useRef(n),s=h.useRef(t);return lw(()=>{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 uw(e){return typeof e=="function"}var dw=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],ye=dw.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 $i(e,t){e&&Dr.flushSync(()=>e.dispatchEvent(t))}function wt(e){const t=h.useRef(e);return h.useEffect(()=>{t.current=e}),h.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function fw(e,t=globalThis==null?void 0:globalThis.document){const n=wt(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 pw="DismissableLayer",Fi="dismissableLayer.update",hw="dismissableLayer.pointerDownOutside",mw="dismissableLayer.focusOutside",Iu,Nu=h.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),mr=h.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...l}=e,c=h.useContext(Nu),[d,p]=h.useState(null),m=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,f]=h.useState({}),v=We(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=xw(E=>{const A=E.target,O=[...c.branches].some(F=>F.contains(A));!k||O||(o==null||o(E),i==null||i(E),E.defaultPrevented||a==null||a())},m),T=vw(E=>{const A=E.target;[...c.branches].some(F=>F.contains(A))||(s==null||s(E),i==null||i(E),E.defaultPrevented||a==null||a())},m);return fw(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&&(Iu=m.body.style.pointerEvents,m.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(d)),c.layers.add(d),_u(),()=>{n&&c.layersWithOutsidePointerEventsDisabled.size===1&&(m.body.style.pointerEvents=Iu)}},[d,m,n,c]),h.useEffect(()=>()=>{d&&(c.layers.delete(d),c.layersWithOutsidePointerEventsDisabled.delete(d),_u())},[d,c]),h.useEffect(()=>{const E=()=>f({});return document.addEventListener(Fi,E),()=>document.removeEventListener(Fi,E)},[]),u.jsx(ye.div,{...l,ref:v,style:{pointerEvents:S?k?"auto":"none":void 0,...e.style},onFocusCapture:le(e.onFocusCapture,T.onFocusCapture),onBlurCapture:le(e.onBlurCapture,T.onBlurCapture),onPointerDownCapture:le(e.onPointerDownCapture,C.onPointerDownCapture)})});mr.displayName=pw;var gw="DismissableLayerBranch",Au=h.forwardRef((e,t)=>{const n=h.useContext(Nu),r=h.useRef(null),o=We(t,r);return h.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),u.jsx(ye.div,{...e,ref:o})});Au.displayName=gw;function xw(e,t=globalThis==null?void 0:globalThis.document){const n=wt(e),r=h.useRef(!1),o=h.useRef(()=>{});return h.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){ju(hw,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 vw(e,t=globalThis==null?void 0:globalThis.document){const n=wt(e),r=h.useRef(!1);return h.useEffect(()=>{const o=s=>{s.target&&!r.current&&ju(mw,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 _u(){const e=new CustomEvent(Fi);document.dispatchEvent(e)}function ju(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?$i(o,s):o.dispatchEvent(s)}var ww=mr,bw=Au,Bi="focusScope.autoFocusOnMount",zi="focusScope.autoFocusOnUnmount",Pu={bubbles:!1,cancelable:!0},yw="FocusScope",Wo=h.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,l]=h.useState(null),c=wt(o),d=wt(s),p=h.useRef(null),m=We(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){Ou.add(f);const g=document.activeElement;if(!a.contains(g)){const y=new CustomEvent(Bi,Pu);a.addEventListener(Bi,c),a.dispatchEvent(y),y.defaultPrevented||(Sw(Iw(Mu(a)),{select:!0}),document.activeElement===g&&Pn(a))}return()=>{a.removeEventListener(Bi,c),setTimeout(()=>{const y=new CustomEvent(zi,Pu);a.addEventListener(zi,d),a.dispatchEvent(y),y.defaultPrevented||Pn(g??document.body,{select:!0}),a.removeEventListener(zi,d),Ou.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]=Cw(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(ye.div,{tabIndex:-1,...i,ref:m,onKeyDown:v})});Wo.displayName=yw;function Sw(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Pn(r,{select:t}),document.activeElement!==n)return}function Cw(e){const t=Mu(e),n=Ru(t,e),r=Ru(t.reverse(),e);return[n,r]}function Mu(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 Ru(e,t){for(const n of e)if(!Tw(n,{upTo:t}))return n}function Tw(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 kw(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&&kw(e)&&t&&e.select()}}var Ou=Ew();function Ew(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=Du(e,t),e.unshift(t)},remove(t){var n;e=Du(e,t),(n=e[0])==null||n.resume()}}}function Du(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Iw(e){return e.filter(t=>t.tagName!=="A")}var Nw="Portal",qr=h.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=h.useState(!1);It(()=>s(!0),[]);const i=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?To.createPortal(u.jsx(ye.div,{...r,ref:t}),i):null});qr.displayName=Nw;function Aw(e,t){return h.useReducer((n,r)=>t[n][r]??n,e)}var Ft=e=>{const{present:t,children:n}=e,r=_w(t),o=typeof n=="function"?n({present:r.isPresent}):h.Children.only(n),s=We(r.ref,jw(o));return typeof n=="function"||r.isPresent?h.cloneElement(o,{ref:s}):null};Ft.displayName="Presence";function _w(e){const[t,n]=h.useState(),r=h.useRef(null),o=h.useRef(e),s=h.useRef("none"),i=e?"mounted":"unmounted",[a,l]=Aw(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return h.useEffect(()=>{const c=Vo(r.current);s.current=a==="mounted"?c:"none"},[a]),It(()=>{const c=r.current,d=o.current;if(d!==e){const m=s.current,f=Vo(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]),It(()=>{if(t){let c;const d=t.ownerDocument.defaultView??window,p=f=>{const g=Vo(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=Vo(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 Vo(e){return(e==null?void 0:e.animationName)||"none"}function jw(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 Hi=0;function Ui(){h.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Lu()),document.body.insertAdjacentElement("beforeend",e[1]??Lu()),Hi++,()=>{Hi===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Hi--}},[])}function Lu(){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 gn=function(){return gn=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},gn.apply(this,arguments)};function $u(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 Pw(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 Ko="right-scroll-bar-position",qo="width-before-scroll-bar",Mw="with-scroll-bars-hidden",Rw="--removed-body-scroll-bar-size";function Wi(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function Ow(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 Dw=typeof window<"u"?h.useLayoutEffect:h.useEffect,Fu=new WeakMap;function Lw(e,t){var n=Ow(null,function(r){return e.forEach(function(o){return Wi(o,r)})});return Dw(function(){var r=Fu.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||Wi(a,null)}),s.forEach(function(a){o.has(a)||Wi(a,i)})}Fu.set(n,e)},[e]),n}function $w(e){return e}function Fw(e,t){t===void 0&&(t=$w);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 Bw(e){e===void 0&&(e={});var t=Fw(null);return t.options=gn({async:!0,ssr:!1},e),t}var Bu=function(e){var t=e.sideCar,n=$u(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,gn({},n))};Bu.isSideCarExport=!0;function zw(e,t){return e.useMedium(t),Bu}var zu=Bw(),Vi=function(){},Go=h.forwardRef(function(e,t){var n=h.useRef(null),r=h.useState({onScrollCapture:Vi,onWheelCapture:Vi,onTouchMoveCapture:Vi}),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=$u(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=m,T=Lw([n,t]),E=gn(gn({},k),o);return h.createElement(h.Fragment,null,d&&h.createElement(C,{sideCar:zu,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),gn(gn({},E),{ref:T})):h.createElement(w,gn({},E,{className:l,ref:T}),a))});Go.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},Go.classNames={fullWidth:qo,zeroRight:Ko};var Hw=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Uw(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Hw();return t&&e.setAttribute("nonce",t),e}function Ww(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Vw(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var Kw=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Uw())&&(Ww(t,n),Vw(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},qw=function(){var e=Kw();return function(t,n){h.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Hu=function(){var e=qw(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},Gw={left:0,top:0,right:0,gap:0},Ki=function(e){return parseInt(e||"",10)||0},Yw=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[Ki(n),Ki(r),Ki(o)]},Xw=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Gw;var t=Yw(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])}},Jw=Hu(),gr="data-scroll-locked",Zw=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(Mw,` {
|
|
41
41
|
overflow: hidden `).concat(r,`;
|
|
42
42
|
padding-right: `).concat(a,"px ").concat(r,`;
|
|
43
43
|
}
|
|
@@ -54,36 +54,36 @@ React keys must be passed directly to JSX without using spread:
|
|
|
54
54
|
`),n==="padding"&&"padding-right: ".concat(a,"px ").concat(r,";")].filter(Boolean).join(""),`
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
.`).concat(
|
|
57
|
+
.`).concat(Ko,` {
|
|
58
58
|
right: `).concat(a,"px ").concat(r,`;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
.`).concat(
|
|
61
|
+
.`).concat(qo,` {
|
|
62
62
|
margin-right: `).concat(a,"px ").concat(r,`;
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
.`).concat(
|
|
65
|
+
.`).concat(Ko," .").concat(Ko,` {
|
|
66
66
|
right: 0 `).concat(r,`;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
.`).concat(
|
|
69
|
+
.`).concat(qo," .").concat(qo,` {
|
|
70
70
|
margin-right: 0 `).concat(r,`;
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
body[`).concat(gr,`] {
|
|
74
|
-
`).concat(
|
|
74
|
+
`).concat(Rw,": ").concat(a,`px;
|
|
75
75
|
}
|
|
76
|
-
`)},Uu=function(){var e=parseInt(document.body.getAttribute(gr)||"0",10);return isFinite(e)?e:0},
|
|
76
|
+
`)},Uu=function(){var e=parseInt(document.body.getAttribute(gr)||"0",10);return isFinite(e)?e:0},Qw=function(){h.useEffect(function(){return document.body.setAttribute(gr,(Uu()+1).toString()),function(){var e=Uu()-1;e<=0?document.body.removeAttribute(gr):document.body.setAttribute(gr,e.toString())}},[])},eb=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;Qw();var s=h.useMemo(function(){return Xw(o)},[o]);return h.createElement(Jw,{styles:Zw(s,!t,o,n?"":"!important")})},qi=!1;if(typeof window<"u")try{var Yo=Object.defineProperty({},"passive",{get:function(){return qi=!0,!0}});window.addEventListener("test",Yo,Yo),window.removeEventListener("test",Yo,Yo)}catch{qi=!1}var xr=qi?{passive:!1}:!1,tb=function(e){return e.tagName==="TEXTAREA"},Wu=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!tb(e)&&n[t]==="visible")},nb=function(e){return Wu(e,"overflowY")},rb=function(e){return Wu(e,"overflowX")},Vu=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=Ku(e,r);if(o){var s=qu(e,r),i=s[1],a=s[2];if(i>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},ob=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},sb=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},Ku=function(e,t){return e==="v"?nb(t):rb(t)},qu=function(e,t){return e==="v"?ob(t):sb(t)},ib=function(e,t){return e==="h"&&t==="rtl"?-1:1},ab=function(e,t,n,r,o){var s=ib(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=qu(e,a),v=f[0],g=f[1],x=f[2],y=g-x-s*v;(v||y)&&Ku(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},Xo=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Gu=function(e){return[e.deltaX,e.deltaY]},Yu=function(e){return e&&"current"in e?e.current:e},lb=function(e,t){return e[0]===t[0]&&e[1]===t[1]},cb=function(e){return`
|
|
77
77
|
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
78
78
|
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
79
|
-
`)},
|
|
79
|
+
`)},ub=0,vr=[];function db(e){var t=h.useRef([]),n=h.useRef([0,0]),r=h.useRef(),o=h.useState(ub++)[0],s=h.useState(Hu)[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=Pw([e.lockRef.current],(e.shards||[]).map(Yu),!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=Xo(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 A=Vu(E,T);if(!A)return!0;if(A?C=E:(C=E==="v"?"h":"v",A=Vu(E,T)),!A)return!1;if(!r.current&&"changedTouches"in g&&(S||k)&&(r.current=C),!C)return!0;var O=r.current||C;return ab(O,x,g,O==="h"?S:k)},[]),l=h.useCallback(function(g){var x=g;if(!(!vr.length||vr[vr.length-1]!==s)){var y="deltaY"in x?Gu(x):Xo(x),w=t.current.filter(function(C){return C.name===x.type&&(C.target===x.target||x.target===C.shadowParent)&&lb(C.delta,y)})[0];if(w&&w.should){x.cancelable&&x.preventDefault();return}if(!w){var S=(i.current.shards||[]).map(Yu).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:fb(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=Xo(g),r.current=void 0},[]),p=h.useCallback(function(g){c(g.type,Gu(g),g.target,a(g,e.lockRef.current))},[]),m=h.useCallback(function(g){c(g.type,Xo(g),g.target,a(g,e.lockRef.current))},[]);h.useEffect(function(){return vr.push(s),e.setCallbacks({onScrollCapture:p,onWheelCapture:p,onTouchMoveCapture:m}),document.addEventListener("wheel",l,xr),document.addEventListener("touchmove",l,xr),document.addEventListener("touchstart",d,xr),function(){vr=vr.filter(function(g){return g!==s}),document.removeEventListener("wheel",l,xr),document.removeEventListener("touchmove",l,xr),document.removeEventListener("touchstart",d,xr)}},[]);var f=e.removeScrollBar,v=e.inert;return h.createElement(h.Fragment,null,v?h.createElement(s,{styles:cb(o)}):null,f?h.createElement(eb,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function fb(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const pb=zw(zu,db);var Jo=h.forwardRef(function(e,t){return h.createElement(Go,gn({},e,{ref:t,sideCar:pb}))});Jo.classNames=Go.classNames;var hb=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},wr=new WeakMap,Zo=new WeakMap,Qo={},Gi=0,Xu=function(e){return e&&(e.host||Xu(e.parentNode))},mb=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=Xu(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})},gb=function(e,t,n,r){var o=mb(t,Array.isArray(e)?e:[e]);Qo[n]||(Qo[n]=new WeakMap);var s=Qo[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=(wr.get(m)||0)+1,x=(s.get(m)||0)+1;wr.set(m,g),s.set(m,x),i.push(m),g===1&&v&&Zo.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(),Gi++,function(){i.forEach(function(p){var m=wr.get(p)-1,f=s.get(p)-1;wr.set(p,m),s.set(p,f),m||(Zo.has(p)||p.removeAttribute(r),Zo.delete(p)),f||p.removeAttribute(n)}),Gi--,Gi||(wr=new WeakMap,wr=new WeakMap,Zo=new WeakMap,Qo={})}},Yi=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=hb(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),gb(r,o,n,"aria-hidden")):function(){return null}},es="Dialog",[Ju,JI]=sn(es),[xb,an]=Ju(es),Zu=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]=jn({prop:r,defaultProp:o??!1,onChange:s,caller:es});return u.jsx(xb,{scope:t,triggerRef:a,contentRef:l,contentId:At(),titleId:At(),descriptionId:At(),open:c,onOpenChange:d,onOpenToggle:h.useCallback(()=>d(p=>!p),[d]),modal:i,children:n})};Zu.displayName=es;var Qu="DialogTrigger",ed=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=an(Qu,n),s=We(t,o.triggerRef);return u.jsx(ye.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Zi(o.open),...r,ref:s,onClick:le(e.onClick,o.onOpenToggle)})});ed.displayName=Qu;var Xi="DialogPortal",[vb,td]=Ju(Xi,{forceMount:void 0}),nd=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=an(Xi,t);return u.jsx(vb,{scope:t,forceMount:n,children:h.Children.map(r,i=>u.jsx(Ft,{present:n||s.open,children:u.jsx(qr,{asChild:!0,container:o,children:i})}))})};nd.displayName=Xi;var ts="DialogOverlay",rd=h.forwardRef((e,t)=>{const n=td(ts,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=an(ts,e.__scopeDialog);return s.modal?u.jsx(Ft,{present:r||s.open,children:u.jsx(bb,{...o,ref:t})}):null});rd.displayName=ts;var wb=Vt.createSlot("DialogOverlay.RemoveScroll"),bb=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=an(ts,n);return u.jsx(Jo,{as:wb,allowPinchZoom:!0,shards:[o.contentRef],children:u.jsx(ye.div,{"data-state":Zi(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),Yn="DialogContent",od=h.forwardRef((e,t)=>{const n=td(Yn,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=an(Yn,e.__scopeDialog);return u.jsx(Ft,{present:r||s.open,children:s.modal?u.jsx(yb,{...o,ref:t}):u.jsx(Sb,{...o,ref:t})})});od.displayName=Yn;var yb=h.forwardRef((e,t)=>{const n=an(Yn,e.__scopeDialog),r=h.useRef(null),o=We(t,n.contentRef,r);return h.useEffect(()=>{const s=r.current;if(s)return Yi(s)},[]),u.jsx(sd,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:le(e.onCloseAutoFocus,s=>{var i;s.preventDefault(),(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:le(e.onPointerDownOutside,s=>{const i=s.detail.originalEvent,a=i.button===0&&i.ctrlKey===!0;(i.button===2||a)&&s.preventDefault()}),onFocusOutside:le(e.onFocusOutside,s=>s.preventDefault())})}),Sb=h.forwardRef((e,t)=>{const n=an(Yn,e.__scopeDialog),r=h.useRef(!1),o=h.useRef(!1);return u.jsx(sd,{...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()}})}),sd=h.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=an(Yn,n),l=h.useRef(null),c=We(t,l);return Ui(),u.jsxs(u.Fragment,{children:[u.jsx(Wo,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:u.jsx(mr,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":Zi(a.open),...i,ref:c,onDismiss:()=>a.onOpenChange(!1)})}),u.jsxs(u.Fragment,{children:[u.jsx(Cb,{titleId:a.titleId}),u.jsx(kb,{contentRef:l,descriptionId:a.descriptionId})]})]})}),Ji="DialogTitle",id=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=an(Ji,n);return u.jsx(ye.h2,{id:o.titleId,...r,ref:t})});id.displayName=Ji;var ad="DialogDescription",ld=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=an(ad,n);return u.jsx(ye.p,{id:o.descriptionId,...r,ref:t})});ld.displayName=ad;var cd="DialogClose",ud=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=an(cd,n);return u.jsx(ye.button,{type:"button",...r,ref:t,onClick:le(e.onClick,()=>o.onOpenChange(!1))})});ud.displayName=cd;function Zi(e){return e?"open":"closed"}var dd="DialogTitleWarning",[ZI,fd]=ow(dd,{contentName:Yn,titleName:Ji,docsSlug:"dialog"}),Cb=({titleId:e})=>{const t=fd(dd),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},Sb="DialogDescriptionWarning",Cb=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${fd(Sb).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},Zi=Zu,Tb=ed,Qi=nd,Gr=rd,Yr=od,Xn=id,es=ld,pd=ud,Xr='[cmdk-group=""]',ea='[cmdk-group-items=""]',kb='[cmdk-group-heading=""]',hd='[cmdk-item=""]',md=`${hd}:not([aria-disabled="true"])`,ta="cmdk-item-select",br="data-value",Eb=(e,t,n)=>tw(e,t,n),gd=h.createContext(void 0),Jr=()=>h.useContext(gd),xd=h.createContext(void 0),na=()=>h.useContext(xd),vd=h.createContext(void 0),wd=h.forwardRef((e,t)=>{let n=yr(()=>{var j,R;return{search:"",value:(R=(j=e.value)!=null?j:e.defaultValue)!=null?R:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=yr(()=>new Set),o=yr(()=>new Map),s=yr(()=>new Map),i=yr(()=>new Set),a=bd(e),{label:l,children:c,value:d,onValueChange:p,filter:m,shouldFilter:f,loop:v,disablePointerSelection:g=!1,vimBindings:x=!0,...y}=e,w=At(),S=At(),k=At(),C=h.useRef(null),T=Lb();Jn(()=>{if(d!==void 0){let j=d.trim();n.current.value=j,E.emit()}},[d]),Jn(()=>{T(6,z)},[]);let E=h.useMemo(()=>({subscribe:j=>(i.current.add(j),()=>i.current.delete(j)),snapshot:()=>n.current,setState:(j,R,G)=>{var Y,ie,H,D;if(!Object.is(n.current[j],R)){if(n.current[j]=R,j==="search")W(),F(),T(1,U);else if(j==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let X=document.getElementById(k);X?X.focus():(Y=document.getElementById(w))==null||Y.focus()}if(T(7,()=>{var X;n.current.selectedItemId=(X=N())==null?void 0:X.id,E.emit()}),G||T(5,z),((ie=a.current)==null?void 0:ie.value)!==void 0){let X=R??"";(D=(H=a.current).onValueChange)==null||D.call(H,X);return}}E.emit()}},emit:()=>{i.current.forEach(j=>j())}}),[]),A=h.useMemo(()=>({value:(j,R,G)=>{var Y;R!==((Y=s.current.get(j))==null?void 0:Y.value)&&(s.current.set(j,{value:R,keywords:G}),n.current.filtered.items.set(j,O(R,G)),T(2,()=>{F(),E.emit()}))},item:(j,R)=>(r.current.add(j),R&&(o.current.has(R)?o.current.get(R).add(j):o.current.set(R,new Set([j]))),T(3,()=>{W(),F(),n.current.value||U(),E.emit()}),()=>{s.current.delete(j),r.current.delete(j),n.current.filtered.items.delete(j);let G=N();T(4,()=>{W(),(G==null?void 0:G.getAttribute("id"))===j&&U(),E.emit()})}),group:j=>(o.current.has(j)||o.current.set(j,new Set),()=>{s.current.delete(j),o.current.delete(j)}),filter:()=>a.current.shouldFilter,label:l||e["aria-label"],getDisablePointerSelection:()=>a.current.disablePointerSelection,listId:w,inputId:k,labelId:S,listInnerRef:C}),[]);function O(j,R){var G,Y;let ie=(Y=(G=a.current)==null?void 0:G.filter)!=null?Y:Eb;return j?ie(j,n.current.search,R):0}function F(){if(!n.current.search||a.current.shouldFilter===!1)return;let j=n.current.filtered.items,R=[];n.current.filtered.groups.forEach(Y=>{let ie=o.current.get(Y),H=0;ie.forEach(D=>{let X=j.get(D);H=Math.max(X,H)}),R.push([Y,H])});let G=C.current;K().sort((Y,ie)=>{var H,D;let X=Y.getAttribute("id"),Z=ie.getAttribute("id");return((H=j.get(Z))!=null?H:0)-((D=j.get(X))!=null?D:0)}).forEach(Y=>{let ie=Y.closest(ea);ie?ie.appendChild(Y.parentElement===ie?Y:Y.closest(`${ea} > *`)):G.appendChild(Y.parentElement===G?Y:Y.closest(`${ea} > *`))}),R.sort((Y,ie)=>ie[1]-Y[1]).forEach(Y=>{var ie;let H=(ie=C.current)==null?void 0:ie.querySelector(`${Xr}[${br}="${encodeURIComponent(Y[0])}"]`);H==null||H.parentElement.appendChild(H)})}function U(){let j=K().find(G=>G.getAttribute("aria-disabled")!=="true"),R=j==null?void 0:j.getAttribute(br);E.setState("value",R||void 0)}function W(){var j,R,G,Y;if(!n.current.search||a.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let ie=0;for(let H of r.current){let D=(R=(j=s.current.get(H))==null?void 0:j.value)!=null?R:"",X=(Y=(G=s.current.get(H))==null?void 0:G.keywords)!=null?Y:[],Z=O(D,X);n.current.filtered.items.set(H,Z),Z>0&&ie++}for(let[H,D]of o.current)for(let X of D)if(n.current.filtered.items.get(X)>0){n.current.filtered.groups.add(H);break}n.current.filtered.count=ie}function z(){var j,R,G;let Y=N();Y&&(((j=Y.parentElement)==null?void 0:j.firstChild)===Y&&((G=(R=Y.closest(Xr))==null?void 0:R.querySelector(kb))==null||G.scrollIntoView({block:"nearest"})),Y.scrollIntoView({block:"nearest"}))}function N(){var j;return(j=C.current)==null?void 0:j.querySelector(`${hd}[aria-selected="true"]`)}function K(){var j;return Array.from(((j=C.current)==null?void 0:j.querySelectorAll(md))||[])}function M(j){let R=K()[j];R&&E.setState("value",R.getAttribute(br))}function Q(j){var R;let G=N(),Y=K(),ie=Y.findIndex(D=>D===G),H=Y[ie+j];(R=a.current)!=null&&R.loop&&(H=ie+j<0?Y[Y.length-1]:ie+j===Y.length?Y[0]:Y[ie+j]),H&&E.setState("value",H.getAttribute(br))}function $(j){let R=N(),G=R==null?void 0:R.closest(Xr),Y;for(;G&&!Y;)G=j>0?Ob(G,Xr):Db(G,Xr),Y=G==null?void 0:G.querySelector(md);Y?E.setState("value",Y.getAttribute(br)):Q(j)}let _=()=>M(K().length-1),V=j=>{j.preventDefault(),j.metaKey?_():j.altKey?$(1):Q(1)},J=j=>{j.preventDefault(),j.metaKey?M(0):j.altKey?$(-1):Q(-1)};return h.createElement(ye.div,{ref:t,tabIndex:-1,...y,"cmdk-root":"",onKeyDown:j=>{var R;(R=y.onKeyDown)==null||R.call(y,j);let G=j.nativeEvent.isComposing||j.keyCode===229;if(!(j.defaultPrevented||G))switch(j.key){case"n":case"j":{x&&j.ctrlKey&&V(j);break}case"ArrowDown":{V(j);break}case"p":case"k":{x&&j.ctrlKey&&J(j);break}case"ArrowUp":{J(j);break}case"Home":{j.preventDefault(),M(0);break}case"End":{j.preventDefault(),_();break}case"Enter":{j.preventDefault();let Y=N();if(Y){let ie=new Event(ta);Y.dispatchEvent(ie)}}}}},h.createElement("label",{"cmdk-label":"",htmlFor:A.inputId,id:A.labelId,style:Fb},l),ts(e,j=>h.createElement(xd.Provider,{value:E},h.createElement(gd.Provider,{value:A},j))))}),Ib=h.forwardRef((e,t)=>{var n,r;let o=At(),s=h.useRef(null),i=h.useContext(vd),a=Jr(),l=bd(e),c=(r=(n=l.current)==null?void 0:n.forceMount)!=null?r:i==null?void 0:i.forceMount;Jn(()=>{if(!c)return a.item(o,i==null?void 0:i.id)},[c]);let d=yd(o,s,[e.value,e.children,s],e.keywords),p=na(),m=Mn(T=>T.value&&T.value===d.current),f=Mn(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(ta,v),()=>T.removeEventListener(ta,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(ye.div,{ref:_n(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)}),Nb=h.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:o,...s}=e,i=At(),a=h.useRef(null),l=h.useRef(null),c=At(),d=Jr(),p=Mn(f=>o||d.filter()===!1?!0:f.search?f.filtered.groups.has(i):!0);Jn(()=>d.group(i),[]),yd(i,a,[e.value,e.heading,l]);let m=h.useMemo(()=>({id:i,forceMount:o}),[o]);return h.createElement(ye.div,{ref:_n(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),ts(e,f=>h.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?c:void 0},h.createElement(vd.Provider,{value:m},f))))}),Ab=h.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,o=h.useRef(null),s=Mn(i=>!i.search);return!n&&!s?null:h.createElement(ye.div,{ref:_n(o,t),...r,"cmdk-separator":"",role:"separator"})}),_b=h.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,o=e.value!=null,s=na(),i=Mn(c=>c.search),a=Mn(c=>c.selectedItemId),l=Jr();return h.useEffect(()=>{e.value!=null&&s.setState("search",e.value)},[e.value]),h.createElement(ye.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)}})}),jb=h.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...o}=e,s=h.useRef(null),i=h.useRef(null),a=Mn(c=>c.selectedItemId),l=Jr();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(ye.div,{ref:_n(s,t),...o,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":a,"aria-label":r,id:l.listId},ts(e,c=>h.createElement("div",{ref:_n(i,l.listInnerRef),"cmdk-list-sizer":""},c)))}),Pb=h.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:o,contentClassName:s,container:i,...a}=e;return h.createElement(Zi,{open:n,onOpenChange:r},h.createElement(Qi,{container:i},h.createElement(Gr,{"cmdk-overlay":"",className:o}),h.createElement(Yr,{"aria-label":e.label,"cmdk-dialog":"",className:s},h.createElement(wd,{ref:t,...a}))))}),Mb=h.forwardRef((e,t)=>Mn(n=>n.filtered.count===0)?h.createElement(ye.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),Rb=h.forwardRef((e,t)=>{let{progress:n,children:r,label:o="Loading...",...s}=e;return h.createElement(ye.div,{ref:t,...s,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":o},ts(e,i=>h.createElement("div",{"aria-hidden":!0},i)))}),Bt=Object.assign(wd,{List:jb,Item:Ib,Input:_b,Group:Nb,Separator:Ab,Dialog:Pb,Empty:Mb,Loading:Rb});function Ob(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function Db(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function bd(e){let t=h.useRef(e);return Jn(()=>{t.current=e}),t}var Jn=typeof window>"u"?h.useEffect:h.useLayoutEffect;function yr(e){let t=h.useRef();return t.current===void 0&&(t.current=e()),t}function Mn(e){let t=na(),n=()=>e(t.snapshot());return h.useSyncExternalStore(t.subscribe,n,n)}function yd(e,t,n,r=[]){let o=h.useRef(),s=Jr();return Jn(()=>{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(br,a),o.current=a}),o}var Lb=()=>{let[e,t]=h.useState(),n=yr(()=>new Map);return Jn(()=>{n.current.forEach(r=>r()),n.current=new Map},[e]),(r,o)=>{n.current.set(r,o),t({})}};function $b(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function ts({asChild:e,children:t},n){return e&&h.isValidElement(t)?h.cloneElement($b(t),{ref:t.ref},n(t.props.children)):n(t)}var Fb={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const ra=Zi,Bb=Qi,Sd=h.forwardRef(({className:e,...t},n)=>u.jsx(Gr,{ref:n,className:re("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}));Sd.displayName=Gr.displayName;const ns=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===Xn||(c==null?void 0:c.displayName)===Xn.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(Bb,{children:[u.jsx(Sd,{}),u.jsxs(Yr,{ref:r,className:re("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(Xn,{className:"sr-only",children:"Dialog"}),t,u.jsxs(pd,{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(fe.X,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]})});ns.displayName=Yr.displayName;const rs=({className:e,...t})=>u.jsx("div",{className:re("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});rs.displayName="DialogHeader";const os=h.forwardRef(({className:e,...t},n)=>u.jsx(Xn,{ref:n,className:re("text-lg font-semibold leading-none tracking-tight",e),...t}));os.displayName=Xn.displayName;const zb=h.forwardRef(({className:e,...t},n)=>u.jsx(es,{ref:n,className:re("text-sm text-muted-foreground",e),...t}));zb.displayName=es.displayName;const oa=h.forwardRef(({className:e,...t},n)=>u.jsx(Bt,{ref:n,className:re("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));oa.displayName=Bt.displayName;const sa=h.forwardRef(({className:e,...t},n)=>u.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[u.jsx(fe.Search,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),u.jsx(Bt.Input,{ref:n,className:re("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})]}));sa.displayName=Bt.Input.displayName;const ia=h.forwardRef(({className:e,...t},n)=>u.jsx(Bt.List,{ref:n,className:re("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));ia.displayName=Bt.List.displayName;const aa=h.forwardRef((e,t)=>u.jsx(Bt.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));aa.displayName=Bt.Empty.displayName;const la=h.forwardRef(({className:e,...t},n)=>u.jsx(Bt.Group,{ref:n,className:re("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}));la.displayName=Bt.Group.displayName;const Hb=h.forwardRef(({className:e,...t},n)=>u.jsx(Bt.Separator,{ref:n,className:re("-mx-1 h-px bg-border",e),...t}));Hb.displayName=Bt.Separator.displayName;const ca=h.forwardRef(({className:e,...t},n)=>u.jsx(Bt.Item,{ref:n,className:re("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}));ca.displayName=Bt.Item.displayName;function ss(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=We(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=We(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 Ub=h.createContext(void 0);function is(e){const t=h.useContext(Ub);return e||t||"ltr"}const Wb=["top","right","bottom","left"],Rn=Math.min,Gt=Math.max,as=Math.round,ls=Math.floor,xn=e=>({x:e,y:e}),Vb={left:"right",right:"left",bottom:"top",top:"bottom"},Kb={start:"end",end:"start"};function ua(e,t,n){return Gt(e,Rn(t,n))}function kn(e,t){return typeof e=="function"?e(t):e}function En(e){return e.split("-")[0]}function Sr(e){return e.split("-")[1]}function da(e){return e==="x"?"y":"x"}function fa(e){return e==="y"?"height":"width"}const qb=new Set(["top","bottom"]);function vn(e){return qb.has(En(e))?"y":"x"}function pa(e){return da(vn(e))}function Gb(e,t,n){n===void 0&&(n=!1);const r=Sr(e),o=pa(e),s=fa(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=cs(i)),[i,cs(i)]}function Yb(e){const t=cs(e);return[ha(e),t,ha(t)]}function ha(e){return e.replace(/start|end/g,t=>Kb[t])}const Cd=["left","right"],Td=["right","left"],Xb=["top","bottom"],Jb=["bottom","top"];function Zb(e,t,n){switch(e){case"top":case"bottom":return n?t?Td:Cd:t?Cd:Td;case"left":case"right":return t?Xb:Jb;default:return[]}}function Qb(e,t,n,r){const o=Sr(e);let s=Zb(En(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(ha)))),s}function cs(e){return e.replace(/left|right|bottom|top/g,t=>Vb[t])}function ey(e){return{top:0,right:0,bottom:0,left:0,...e}}function kd(e){return typeof e!="number"?ey(e):{top:e,right:e,bottom:e,left:e}}function us(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}function Ed(e,t,n){let{reference:r,floating:o}=e;const s=vn(t),i=pa(t),a=fa(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(Sr(t)){case"start":f[i]-=m*(n&&c?-1:1);break;case"end":f[i]+=m*(n&&c?-1:1);break}return f}const ty=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}=Ed(c,r,l),m=r,f={},v=0;for(let g=0;g<a.length;g++){const{name:x,fn:y}=a[g],{x: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}=Ed(c,m,l)),g=-1)}return{x:d,y:p,placement:m,strategy:o,middlewareData:f}};async function Zr(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=kd(f),x=a[m?p==="floating"?"reference":"floating":p],y=us(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=us(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 ny=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=kd(d),m={x:n,y:r},f=pa(o),v=fa(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 A=k/2-C/2,O=E/2-g[v]/2-1,F=Rn(p[y],O),U=Rn(p[w],O),W=F,z=E-g[v]-U,N=E/2-g[v]/2+A,K=ua(W,N,z),M=!l.arrow&&Sr(o)!=null&&N!==K&&s.reference[v]/2-(N<W?F:U)-g[v]/2<0,Q=M?N<W?N-W:N-z:0;return{[f]:m[f]+Q,data:{[f]:K,centerOffset:N-K-Q,...M&&{alignmentOffset:Q}},reset:M}}}),ry=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=vn(a),S=En(a)===a,k=await(l.isRTL==null?void 0:l.isRTL(c.floating)),C=m||(S||!g?[cs(a)]:Yb(a)),T=v!=="none";!m&&T&&C.push(...Qb(a,g,v,k));const E=[a,...C],A=await Zr(t,x),O=[];let F=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&O.push(A[y]),p){const N=Gb(o,i,k);O.push(A[N[0]],A[N[1]])}if(F=[...F,{placement:o,overflows:O}],!O.every(N=>N<=0)){var U,W;const N=(((U=s.flip)==null?void 0:U.index)||0)+1,K=E[N];if(K&&(!(p==="alignment"?w!==vn(K):!1)||F.every($=>vn($.placement)===w?$.overflows[0]>0:!0)))return{data:{index:N,overflows:F},reset:{placement:K}};let M=(W=F.filter(Q=>Q.overflows[0]<=0).sort((Q,$)=>Q.overflows[1]-$.overflows[1])[0])==null?void 0:W.placement;if(!M)switch(f){case"bestFit":{var z;const Q=(z=F.filter($=>{if(T){const _=vn($.placement);return _===w||_==="y"}return!0}).map($=>[$.placement,$.overflows.filter(_=>_>0).reduce((_,V)=>_+V,0)]).sort(($,_)=>$[1]-_[1])[0])==null?void 0:z[0];Q&&(M=Q);break}case"initialPlacement":M=a;break}if(o!==M)return{reset:{placement:M}}}return{}}}};function Id(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Nd(e){return Wb.some(t=>e[t]>=0)}const oy=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 Zr(t,{...o,elementContext:"reference"}),i=Id(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:Nd(i)}}}case"escaped":{const s=await Zr(t,{...o,altBoundary:!0}),i=Id(s,n.floating);return{data:{escapedOffsets:i,escaped:Nd(i)}}}default:return{}}}}},Ad=new Set(["left","top"]);async function sy(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=Sr(n),l=vn(n)==="y",c=Ad.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 iy=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 sy(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}}}}},ay=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 Zr(t,l),p=vn(En(o)),m=da(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=ua(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=ua(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}}}}}},ly=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=vn(o),m=da(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=Ad.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}}}},cy=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 Zr(t,c),p=En(o),m=Sr(o),f=vn(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=Rn(g-d[x],w),C=Rn(v-d[y],S),T=!t.middlewareData.shift;let E=k,A=C;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(A=S),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(E=w),T&&!m){const F=Gt(d.left,0),U=Gt(d.right,0),W=Gt(d.top,0),z=Gt(d.bottom,0);f?A=v-2*(F!==0||U!==0?F+U:Gt(d.left,d.right)):E=g-2*(W!==0||z!==0?W+z:Gt(d.top,d.bottom))}await l({...t,availableWidth:A,availableHeight:E});const O=await i.getDimensions(a.floating);return v!==O.width||g!==O.height?{reset:{rects:!0}}:{}}}};function ds(){return typeof window<"u"}function Cr(e){return _d(e)?(e.nodeName||"").toLowerCase():"#document"}function Yt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function wn(e){var t;return(t=(_d(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function _d(e){return ds()?e instanceof Node||e instanceof Yt(e).Node:!1}function ln(e){return ds()?e instanceof Element||e instanceof Yt(e).Element:!1}function bn(e){return ds()?e instanceof HTMLElement||e instanceof Yt(e).HTMLElement:!1}function jd(e){return!ds()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Yt(e).ShadowRoot}const uy=new Set(["inline","contents"]);function Qr(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=cn(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!uy.has(o)}const dy=new Set(["table","td","th"]);function fy(e){return dy.has(Cr(e))}const py=[":popover-open",":modal"];function fs(e){return py.some(t=>{try{return e.matches(t)}catch{return!1}})}const hy=["transform","translate","scale","rotate","perspective"],my=["transform","translate","scale","rotate","perspective","filter"],gy=["paint","layout","strict","content"];function ma(e){const t=ga(),n=ln(e)?cn(e):e;return hy.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)||my.some(r=>(n.willChange||"").includes(r))||gy.some(r=>(n.contain||"").includes(r))}function xy(e){let t=On(e);for(;bn(t)&&!Tr(t);){if(ma(t))return t;if(fs(t))return null;t=On(t)}return null}function ga(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const vy=new Set(["html","body","#document"]);function Tr(e){return vy.has(Cr(e))}function cn(e){return Yt(e).getComputedStyle(e)}function ps(e){return ln(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function On(e){if(Cr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||jd(e)&&e.host||wn(e);return jd(t)?t.host:t}function Pd(e){const t=On(e);return Tr(t)?e.ownerDocument?e.ownerDocument.body:e.body:bn(t)&&Qr(t)?t:Pd(t)}function eo(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=Pd(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Yt(o);if(s){const a=xa(i);return t.concat(i,i.visualViewport||[],Qr(o)?o:[],a&&n?eo(a):[])}return t.concat(o,eo(o,[],n))}function xa(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Md(e){const t=cn(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=bn(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=as(n)!==s||as(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function va(e){return ln(e)?e:e.contextElement}function kr(e){const t=va(e);if(!bn(t))return xn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=Md(t);let i=(s?as(n.width):n.width)/r,a=(s?as(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const wy=xn(0);function Rd(e){const t=Yt(e);return!ga()||!t.visualViewport?wy:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function by(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Yt(e)?!1:t}function Zn(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=va(e);let i=xn(1);t&&(r?ln(r)&&(i=kr(r)):i=kr(e));const a=by(s,n,r)?Rd(s):xn(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&&ln(r)?Yt(r):r;let v=m,g=xa(v);for(;g&&r&&f!==v;){const x=kr(g),y=g.getBoundingClientRect(),w=cn(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=xa(v)}}return us({width:d,height:p,x:l,y:c})}function hs(e,t){const n=ps(e).scrollLeft;return t?t.left+n:Zn(wn(e)).left+n}function Od(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-hs(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function yy(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=wn(r),a=t?fs(t.floating):!1;if(r===i||a&&s)return n;let l={scrollLeft:0,scrollTop:0},c=xn(1);const d=xn(0),p=bn(r);if((p||!p&&!s)&&((Cr(r)!=="body"||Qr(i))&&(l=ps(r)),bn(r))){const f=Zn(r);c=kr(r),d.x=f.x+r.clientLeft,d.y=f.y+r.clientTop}const m=i&&!p&&!s?Od(i,l):xn(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 Sy(e){return Array.from(e.getClientRects())}function Cy(e){const t=wn(e),n=ps(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+hs(e);const a=-n.scrollTop;return cn(r).direction==="rtl"&&(i+=Gt(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const Dd=25;function Ty(e,t){const n=Yt(e),r=wn(e),o=n.visualViewport;let s=r.clientWidth,i=r.clientHeight,a=0,l=0;if(o){s=o.width,i=o.height;const d=ga();(!d||d&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}const c=hs(r);if(c<=0){const d=r.ownerDocument,p=d.body,m=getComputedStyle(p),f=d.compatMode==="CSS1Compat"&&parseFloat(m.marginLeft)+parseFloat(m.marginRight)||0,v=Math.abs(r.clientWidth-p.clientWidth-f);v<=Dd&&(s-=v)}else c<=Dd&&(s+=c);return{width:s,height:i,x:a,y:l}}const ky=new Set(["absolute","fixed"]);function Ey(e,t){const n=Zn(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=bn(e)?kr(e):xn(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 Ld(e,t,n){let r;if(t==="viewport")r=Ty(e,n);else if(t==="document")r=Cy(wn(e));else if(ln(t))r=Ey(t,n);else{const o=Rd(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return us(r)}function $d(e,t){const n=On(e);return n===t||!ln(n)||Tr(n)?!1:cn(n).position==="fixed"||$d(n,t)}function Iy(e,t){const n=t.get(e);if(n)return n;let r=eo(e,[],!1).filter(a=>ln(a)&&Cr(a)!=="body"),o=null;const s=cn(e).position==="fixed";let i=s?On(e):e;for(;ln(i)&&!Tr(i);){const a=cn(i),l=ma(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&ky.has(o.position)||Qr(i)&&!l&&$d(e,i))?r=r.filter(d=>d!==i):o=a,i=On(i)}return t.set(e,r),r}function Ny(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?fs(t)?[]:Iy(t,this._c):[].concat(n),r],a=i[0],l=i.reduce((c,d)=>{const p=Ld(t,d,o);return c.top=Gt(p.top,c.top),c.right=Rn(p.right,c.right),c.bottom=Rn(p.bottom,c.bottom),c.left=Gt(p.left,c.left),c},Ld(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function Ay(e){const{width:t,height:n}=Md(e);return{width:t,height:n}}function _y(e,t,n){const r=bn(t),o=wn(t),s=n==="fixed",i=Zn(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=xn(0);function c(){l.x=hs(o)}if(r||!r&&!s)if((Cr(t)!=="body"||Qr(o))&&(a=ps(t)),r){const f=Zn(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?Od(o,a):xn(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 wa(e){return cn(e).position==="static"}function Fd(e,t){if(!bn(e)||cn(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return wn(e)===n&&(n=n.ownerDocument.body),n}function Bd(e,t){const n=Yt(e);if(fs(e))return n;if(!bn(e)){let o=On(e);for(;o&&!Tr(o);){if(ln(o)&&!wa(o))return o;o=On(o)}return n}let r=Fd(e,t);for(;r&&fy(r)&&wa(r);)r=Fd(r,t);return r&&Tr(r)&&wa(r)&&!ma(r)?n:r||xy(e)||n}const jy=async function(e){const t=this.getOffsetParent||Bd,n=this.getDimensions,r=await n(e.floating);return{reference:_y(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Py(e){return cn(e).direction==="rtl"}const My={convertOffsetParentRelativeRectToViewportRelativeRect:yy,getDocumentElement:wn,getClippingRect:Ny,getOffsetParent:Bd,getElementRects:jy,getClientRects:Sy,getDimensions:Ay,getScale:kr,isElement:ln,isRTL:Py};function zd(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Ry(e,t){let n=null,r;const o=wn(e);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),s();const c=e.getBoundingClientRect(),{left:d,top:p,width:m,height:f}=c;if(a||t(),!m||!f)return;const v=ls(p),g=ls(o.clientWidth-(d+m)),x=ls(o.clientHeight-(p+f)),y=ls(d),S={rootMargin:-v+"px "+-g+"px "+-x+"px "+-y+"px",threshold:Gt(0,Rn(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&&!zd(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 Oy(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=va(e),d=o||s?[...c?eo(c):[],...eo(t)]:[];d.forEach(y=>{o&&y.addEventListener("scroll",n,{passive:!0}),s&&y.addEventListener("resize",n)});const p=c&&a?Ry(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?Zn(e):null;l&&x();function x(){const y=Zn(e);g&&!zd(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 Dy=iy,Ly=ay,$y=ry,Fy=cy,By=oy,Hd=ny,zy=ly,Hy=(e,t,n)=>{const r=new Map,o={platform:My,...n},s={...o.platform,_c:r};return ty(e,t,{...o,platform:s})};var Uy=typeof document<"u",Wy=function(){},ms=Uy?b.useLayoutEffect:Wy;function gs(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(!gs(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)&&!gs(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function Ud(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Wd(e,t){const n=Ud(e);return Math.round(t*n)/n}function ba(e){const t=h.useRef(e);return ms(()=>{t.current=e}),t}function Vy(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);gs(m,r)||f(r);const[v,g]=h.useState(null),[x,y]=h.useState(null),w=h.useCallback($=>{$!==T.current&&(T.current=$,g($))},[]),S=h.useCallback($=>{$!==E.current&&(E.current=$,y($))},[]),k=s||v,C=i||x,T=h.useRef(null),E=h.useRef(null),A=h.useRef(d),O=l!=null,F=ba(l),U=ba(o),W=ba(c),z=h.useCallback(()=>{if(!T.current||!E.current)return;const $={placement:t,strategy:n,middleware:m};U.current&&($.platform=U.current),Hy(T.current,E.current,$).then(_=>{const V={..._,isPositioned:W.current!==!1};N.current&&!gs(A.current,V)&&(A.current=V,Dr.flushSync(()=>{p(V)}))})},[m,t,n,U,W]);ms(()=>{c===!1&&A.current.isPositioned&&(A.current.isPositioned=!1,p($=>({...$,isPositioned:!1})))},[c]);const N=h.useRef(!1);ms(()=>(N.current=!0,()=>{N.current=!1}),[]),ms(()=>{if(k&&(T.current=k),C&&(E.current=C),k&&C){if(F.current)return F.current(k,C,z);z()}},[k,C,z,F,O]);const K=h.useMemo(()=>({reference:T,floating:E,setReference:w,setFloating:S}),[w,S]),M=h.useMemo(()=>({reference:k,floating:C}),[k,C]),Q=h.useMemo(()=>{const $={position:n,left:0,top:0};if(!M.floating)return $;const _=Wd(M.floating,d.x),V=Wd(M.floating,d.y);return a?{...$,transform:"translate("+_+"px, "+V+"px)",...Ud(M.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:_,top:V}},[n,a,M.floating,d.x,d.y]);return h.useMemo(()=>({...d,update:z,refs:K,elements:M,floatingStyles:Q}),[d,z,K,M,Q])}const Ky=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?Hd({element:r.current,padding:o}).fn(n):{}:r?Hd({element:r,padding:o}).fn(n):{}}}},qy=(e,t)=>({...Dy(e),options:[e,t]}),Gy=(e,t)=>({...Ly(e),options:[e,t]}),Yy=(e,t)=>({...zy(e),options:[e,t]}),Xy=(e,t)=>({...$y(e),options:[e,t]}),Jy=(e,t)=>({...Fy(e),options:[e,t]}),Zy=(e,t)=>({...By(e),options:[e,t]}),Qy=(e,t)=>({...Ky(e),options:[e,t]});var e0="Arrow",Vd=h.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return u.jsx(ye.svg,{...s,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:u.jsx("polygon",{points:"0,0 30,0 15,10"})})});Vd.displayName=e0;var t0=Vd;function Kd(e){const[t,n]=h.useState(void 0);return It(()=>{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 ya="Popper",[qd,Er]=sn(ya),[n0,Gd]=qd(ya),Yd=e=>{const{__scopePopper:t,children:n}=e,[r,o]=h.useState(null);return u.jsx(n0,{scope:t,anchor:r,onAnchorChange:o,children:n})};Yd.displayName=ya;var Xd="PopperAnchor",Jd=h.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=Gd(Xd,n),i=h.useRef(null),a=We(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(ye.div,{...o,ref:a})});Jd.displayName=Xd;var Sa="PopperContent",[r0,o0]=qd(Sa),Zd=h.forwardRef((e,t)=>{var H,D,X,Z,ce,L;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(Sa,n),[y,w]=h.useState(null),S=We(t,oe=>w(oe)),[k,C]=h.useState(null),T=Kd(k),E=(T==null?void 0:T.width)??0,A=(T==null?void 0:T.height)??0,O=r+(s!=="center"?"-"+s:""),F=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},U=Array.isArray(c)?c:[c],W=U.length>0,z={padding:F,boundary:U.filter(i0),altBoundary:W},{refs:N,floatingStyles:K,placement:M,isPositioned:Q,middlewareData:$}=Vy({strategy:"fixed",placement:O,whileElementsMounted:(...oe)=>Oy(...oe,{animationFrame:f==="always"}),elements:{reference:x.anchor},middleware:[qy({mainAxis:o+A,alignmentAxis:i}),l&&Gy({mainAxis:!0,crossAxis:!1,limiter:p==="partial"?Yy():void 0,...z}),l&&Xy({...z}),Jy({...z,apply:({elements:oe,rects:xe,availableWidth:de,availableHeight:we})=>{const{width:Me,height:He}=xe.reference,$e=oe.floating.style;$e.setProperty("--radix-popper-available-width",`${de}px`),$e.setProperty("--radix-popper-available-height",`${we}px`),$e.setProperty("--radix-popper-anchor-width",`${Me}px`),$e.setProperty("--radix-popper-anchor-height",`${He}px`)}}),k&&Qy({element:k,padding:a}),a0({arrowWidth:E,arrowHeight:A}),m&&Zy({strategy:"referenceHidden",...z})]}),[_,V]=tf(M),J=wt(v);It(()=>{Q&&(J==null||J())},[Q,J]);const j=(H=$.arrow)==null?void 0:H.x,R=(D=$.arrow)==null?void 0:D.y,G=((X=$.arrow)==null?void 0:X.centerOffset)!==0,[Y,ie]=h.useState();return It(()=>{y&&ie(window.getComputedStyle(y).zIndex)},[y]),u.jsx("div",{ref:N.setFloating,"data-radix-popper-content-wrapper":"",style:{...K,transform:Q?K.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Y,"--radix-popper-transform-origin":[(Z=$.transformOrigin)==null?void 0:Z.x,(ce=$.transformOrigin)==null?void 0:ce.y].join(" "),...((L=$.hide)==null?void 0:L.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:u.jsx(r0,{scope:n,placedSide:_,onArrowChange:C,arrowX:j,arrowY:R,shouldHideArrow:G,children:u.jsx(ye.div,{"data-side":_,"data-align":V,...g,ref:S,style:{...g.style,animation:Q?void 0:"none"}})})})});Zd.displayName=Sa;var Qd="PopperArrow",s0={top:"bottom",right:"left",bottom:"top",left:"right"},ef=h.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=o0(Qd,r),i=s0[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(t0,{...o,ref:n,style:{...o.style,display:"block"}})})});ef.displayName=Qd;function i0(e){return e!==null}var a0=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]=tf(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 tf(e){const[t,n="center"]=e.split("-");return[t,n]}var Ca=Yd,Ta=Jd,ka=Zd,Ea=ef,Ia="rovingFocusGroup.onEntryFocus",l0={bubbles:!1,cancelable:!0},to="RovingFocusGroup",[Na,nf,c0]=ss(to),[u0,rf]=sn(to,[c0]),[d0,f0]=u0(to),of=h.forwardRef((e,t)=>u.jsx(Na.Provider,{scope:e.__scopeRovingFocusGroup,children:u.jsx(Na.Slot,{scope:e.__scopeRovingFocusGroup,children:u.jsx(p0,{...e,ref:t})})}));of.displayName=to;var p0=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=We(t,m),v=is(s),[g,x]=jn({prop:i,defaultProp:a??null,onChange:l,caller:to}),[y,w]=h.useState(!1),S=wt(c),k=nf(n),C=h.useRef(!1),[T,E]=h.useState(0);return h.useEffect(()=>{const A=m.current;if(A)return A.addEventListener(Ia,S),()=>A.removeEventListener(Ia,S)},[S]),u.jsx(d0,{scope:n,orientation:r,dir:v,loop:o,currentTabStopId:g,onItemFocus:h.useCallback(A=>x(A),[x]),onItemShiftTab:h.useCallback(()=>w(!0),[]),onFocusableItemAdd:h.useCallback(()=>E(A=>A+1),[]),onFocusableItemRemove:h.useCallback(()=>E(A=>A-1),[]),children:u.jsx(ye.div,{tabIndex:y||T===0?-1:0,"data-orientation":r,...p,ref:f,style:{outline:"none",...e.style},onMouseDown:le(e.onMouseDown,()=>{C.current=!0}),onFocus:le(e.onFocus,A=>{const O=!C.current;if(A.target===A.currentTarget&&O&&!y){const F=new CustomEvent(Ia,l0);if(A.currentTarget.dispatchEvent(F),!F.defaultPrevented){const U=k().filter(M=>M.focusable),W=U.find(M=>M.active),z=U.find(M=>M.id===g),K=[W,z,...U].filter(Boolean).map(M=>M.ref.current);lf(K,d)}}C.current=!1}),onBlur:le(e.onBlur,()=>w(!1))})})}),sf="RovingFocusGroupItem",af=h.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,l=At(),c=s||l,d=f0(sf,n),p=d.currentTabStopId===c,m=nf(n),{onFocusableItemAdd:f,onFocusableItemRemove:v,currentTabStopId:g}=d;return h.useEffect(()=>{if(r)return f(),()=>v()},[r,f,v]),u.jsx(Na.ItemSlot,{scope:n,id:c,focusable:r,active:o,children:u.jsx(ye.span,{tabIndex:p?0:-1,"data-orientation":d.orientation,...a,ref:t,onMouseDown:le(e.onMouseDown,x=>{r?d.onItemFocus(c):x.preventDefault()}),onFocus:le(e.onFocus,()=>d.onItemFocus(c)),onKeyDown:le(e.onKeyDown,x=>{if(x.key==="Tab"&&x.shiftKey){d.onItemShiftTab();return}if(x.target!==x.currentTarget)return;const y=g0(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?x0(S,k+1):S.slice(k+1)}setTimeout(()=>lf(S))}}),children:typeof i=="function"?i({isCurrentTabStop:p,hasTabStop:g!=null}):i})})});af.displayName=sf;var h0={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function m0(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function g0(e,t,n){const r=m0(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return h0[r]}function lf(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function x0(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var v0=of,w0=af,Aa=["Enter"," "],b0=["ArrowDown","PageUp","Home"],cf=["ArrowUp","PageDown","End"],y0=[...b0,...cf],S0={ltr:[...Aa,"ArrowRight"],rtl:[...Aa,"ArrowLeft"]},C0={ltr:["ArrowLeft"],rtl:["ArrowRight"]},no="Menu",[ro,T0,k0]=ss(no),[Qn,uf]=sn(no,[k0,Er,rf]),xs=Er(),df=rf(),[E0,er]=Qn(no),[I0,oo]=Qn(no),ff=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=xs(t),[l,c]=h.useState(null),d=h.useRef(!1),p=wt(s),m=is(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(Ca,{...a,children:u.jsx(E0,{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})})})};ff.displayName=no;var N0="MenuAnchor",_a=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=xs(n);return u.jsx(Ta,{...o,...r,ref:t})});_a.displayName=N0;var ja="MenuPortal",[A0,pf]=Qn(ja,{forceMount:void 0}),hf=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=er(ja,t);return u.jsx(A0,{scope:t,forceMount:n,children:u.jsx(Ft,{present:n||s.open,children:u.jsx(qr,{asChild:!0,container:o,children:r})})})};hf.displayName=ja;var Zt="MenuContent",[_0,Pa]=Qn(Zt),mf=h.forwardRef((e,t)=>{const n=pf(Zt,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=er(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(j0,{...o,ref:t}):u.jsx(P0,{...o,ref:t})})})})}),j0=h.forwardRef((e,t)=>{const n=er(Zt,e.__scopeMenu),r=h.useRef(null),o=We(t,r);return h.useEffect(()=>{const s=r.current;if(s)return Gi(s)},[]),u.jsx(Ma,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:le(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),P0=h.forwardRef((e,t)=>{const n=er(Zt,e.__scopeMenu);return u.jsx(Ma,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),M0=Vt.createSlot("MenuContent.ScrollLock"),Ma=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=er(Zt,n),y=oo(Zt,n),w=xs(n),S=df(n),k=T0(n),[C,T]=h.useState(null),E=h.useRef(null),A=We(t,E,x.onContentChange),O=h.useRef(0),F=h.useRef(""),U=h.useRef(0),W=h.useRef(null),z=h.useRef("right"),N=h.useRef(0),K=v?Yo:h.Fragment,M=v?{as:M0,allowPinchZoom:!0}:void 0,Q=_=>{var H,D;const V=F.current+_,J=k().filter(X=>!X.disabled),j=document.activeElement,R=(H=J.find(X=>X.ref.current===j))==null?void 0:H.textValue,G=J.map(X=>X.textValue),Y=V0(G,V,R),ie=(D=J.find(X=>X.textValue===Y))==null?void 0:D.ref.current;(function X(Z){F.current=Z,window.clearTimeout(O.current),Z!==""&&(O.current=window.setTimeout(()=>X(""),1e3))})(V),ie&&setTimeout(()=>ie.focus())};h.useEffect(()=>()=>window.clearTimeout(O.current),[]),Hi();const $=h.useCallback(_=>{var J,j;return z.current===((J=W.current)==null?void 0:J.side)&&q0(_,(j=W.current)==null?void 0:j.area)},[]);return u.jsx(_0,{scope:n,searchRef:F,onItemEnter:h.useCallback(_=>{$(_)&&_.preventDefault()},[$]),onItemLeave:h.useCallback(_=>{var V;$(_)||((V=E.current)==null||V.focus(),T(null))},[$]),onTriggerLeave:h.useCallback(_=>{$(_)&&_.preventDefault()},[$]),pointerGraceTimerRef:U,onPointerGraceIntentChange:h.useCallback(_=>{W.current=_},[]),children:u.jsx(K,{...M,children:u.jsx(Ho,{asChild:!0,trapped:o,onMountAutoFocus:le(s,_=>{var V;_.preventDefault(),(V=E.current)==null||V.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:u.jsx(mr,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:p,onInteractOutside:m,onDismiss:f,children:u.jsx(v0,{asChild:!0,...S,dir:y.dir,orientation:"vertical",loop:r,currentTabStopId:C,onCurrentTabStopIdChange:T,onEntryFocus:le(l,_=>{y.isUsingKeyboardRef.current||_.preventDefault()}),preventScrollOnEntryFocus:!0,children:u.jsx(ka,{role:"menu","aria-orientation":"vertical","data-state":Pf(x.open),"data-radix-menu-content":"",dir:y.dir,...w,...g,ref:A,style:{outline:"none",...g.style},onKeyDown:le(g.onKeyDown,_=>{const J=_.target.closest("[data-radix-menu-content]")===_.currentTarget,j=_.ctrlKey||_.altKey||_.metaKey,R=_.key.length===1;J&&(_.key==="Tab"&&_.preventDefault(),!j&&R&&Q(_.key));const G=E.current;if(_.target!==G||!y0.includes(_.key))return;_.preventDefault();const ie=k().filter(H=>!H.disabled).map(H=>H.ref.current);cf.includes(_.key)&&ie.reverse(),U0(ie)}),onBlur:le(e.onBlur,_=>{_.currentTarget.contains(_.target)||(window.clearTimeout(O.current),F.current="")}),onPointerMove:le(e.onPointerMove,io(_=>{const V=_.target,J=N.current!==_.clientX;if(_.currentTarget.contains(V)&&J){const j=_.clientX>N.current?"right":"left";z.current=j,N.current=_.clientX}}))})})})})})})});mf.displayName=Zt;var R0="MenuGroup",Ra=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(ye.div,{role:"group",...r,ref:t})});Ra.displayName=R0;var O0="MenuLabel",gf=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(ye.div,{...r,ref:t})});gf.displayName=O0;var vs="MenuItem",xf="menu.itemSelect",ws=h.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=h.useRef(null),i=oo(vs,e.__scopeMenu),a=Pa(vs,e.__scopeMenu),l=We(t,s),c=h.useRef(!1),d=()=>{const p=s.current;if(!n&&p){const m=new CustomEvent(xf,{bubbles:!0,cancelable:!0});p.addEventListener(xf,f=>r==null?void 0:r(f),{once:!0}),Li(p,m),m.defaultPrevented?c.current=!1:i.onClose()}};return u.jsx(vf,{...o,ref:l,disabled:n,onClick:le(e.onClick,d),onPointerDown:p=>{var m;(m=e.onPointerDown)==null||m.call(e,p),c.current=!0},onPointerUp:le(e.onPointerUp,p=>{var m;c.current||(m=p.currentTarget)==null||m.click()}),onKeyDown:le(e.onKeyDown,p=>{const m=a.searchRef.current!=="";n||m&&p.key===" "||Aa.includes(p.key)&&(p.currentTarget.click(),p.preventDefault())})})});ws.displayName=vs;var vf=h.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=Pa(vs,n),a=df(n),l=h.useRef(null),c=We(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(w0,{asChild:!0,...a,focusable:!r,children:u.jsx(ye.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:c,onPointerMove:le(e.onPointerMove,io(v=>{r?i.onItemLeave(v):(i.onItemEnter(v),v.defaultPrevented||v.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:le(e.onPointerLeave,io(v=>i.onItemLeave(v))),onFocus:le(e.onFocus,()=>p(!0)),onBlur:le(e.onBlur,()=>p(!1))})})})}),D0="MenuCheckboxItem",wf=h.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return u.jsx(Tf,{scope:e.__scopeMenu,checked:n,children:u.jsx(ws,{role:"menuitemcheckbox","aria-checked":bs(n)?"mixed":n,...o,ref:t,"data-state":Da(n),onSelect:le(o.onSelect,()=>r==null?void 0:r(bs(n)?!0:!n),{checkForDefaultPrevented:!1})})})});wf.displayName=D0;var bf="MenuRadioGroup",[L0,$0]=Qn(bf,{value:void 0,onValueChange:()=>{}}),yf=h.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=wt(r);return u.jsx(L0,{scope:e.__scopeMenu,value:n,onValueChange:s,children:u.jsx(Ra,{...o,ref:t})})});yf.displayName=bf;var Sf="MenuRadioItem",Cf=h.forwardRef((e,t)=>{const{value:n,...r}=e,o=$0(Sf,e.__scopeMenu),s=n===o.value;return u.jsx(Tf,{scope:e.__scopeMenu,checked:s,children:u.jsx(ws,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":Da(s),onSelect:le(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});Cf.displayName=Sf;var Oa="MenuItemIndicator",[Tf,F0]=Qn(Oa,{checked:!1}),kf=h.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=F0(Oa,n);return u.jsx(Ft,{present:r||bs(s.checked)||s.checked===!0,children:u.jsx(ye.span,{...o,ref:t,"data-state":Da(s.checked)})})});kf.displayName=Oa;var B0="MenuSeparator",Ef=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(ye.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});Ef.displayName=B0;var z0="MenuArrow",If=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=xs(n);return u.jsx(Ea,{...o,...r,ref:t})});If.displayName=z0;var H0="MenuSub",[JI,Nf]=Qn(H0),so="MenuSubTrigger",Af=h.forwardRef((e,t)=>{const n=er(so,e.__scopeMenu),r=oo(so,e.__scopeMenu),o=Nf(so,e.__scopeMenu),s=Pa(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(_a,{asChild:!0,...c,children:u.jsx(vf,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":Pf(n.open),...e,ref:_n(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:le(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:le(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:le(e.onKeyDown,p=>{var f;const m=s.searchRef.current!=="";e.disabled||m&&p.key===" "||S0[r.dir].includes(p.key)&&(n.onOpenChange(!0),(f=n.content)==null||f.focus(),p.preventDefault())})})})});Af.displayName=so;var _f="MenuSubContent",jf=h.forwardRef((e,t)=>{const n=pf(Zt,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=er(Zt,e.__scopeMenu),i=oo(Zt,e.__scopeMenu),a=Nf(_f,e.__scopeMenu),l=h.useRef(null),c=We(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(Ma,{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:le(e.onFocusOutside,d=>{d.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:le(e.onEscapeKeyDown,d=>{i.onClose(),d.preventDefault()}),onKeyDown:le(e.onKeyDown,d=>{var f;const p=d.currentTarget.contains(d.target),m=C0[i.dir].includes(d.key);p&&m&&(s.onOpenChange(!1),(f=a.trigger)==null||f.focus(),d.preventDefault())})})})})})});jf.displayName=_f;function Pf(e){return e?"open":"closed"}function bs(e){return e==="indeterminate"}function Da(e){return bs(e)?"indeterminate":e?"checked":"unchecked"}function U0(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function W0(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function V0(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=W0(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 q0(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 G0=ff,Y0=_a,X0=hf,J0=mf,Z0=Ra,Q0=gf,eS=ws,tS=wf,nS=yf,rS=Cf,oS=kf,sS=Ef,iS=If,aS=Af,lS=jf,ys="DropdownMenu",[cS,ZI]=sn(ys,[uf]),Ot=uf(),[uS,Mf]=cS(ys),Rf=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,l=Ot(t),c=h.useRef(null),[d,p]=jn({prop:o,defaultProp:s??!1,onChange:i,caller:ys});return u.jsx(uS,{scope:t,triggerId:At(),triggerRef:c,contentId:At(),open:d,onOpenChange:p,onOpenToggle:h.useCallback(()=>p(m=>!m),[p]),modal:a,children:u.jsx(G0,{...l,open:d,onOpenChange:p,dir:r,modal:a,children:n})})};Rf.displayName=ys;var Of="DropdownMenuTrigger",Df=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=Mf(Of,n),i=Ot(n);return u.jsx(Y0,{asChild:!0,...i,children:u.jsx(ye.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:_n(t,s.triggerRef),onPointerDown:le(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:le(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});Df.displayName=Of;var dS="DropdownMenuPortal",Lf=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Ot(t);return u.jsx(X0,{...r,...n})};Lf.displayName=dS;var $f="DropdownMenuContent",Ff=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Mf($f,n),s=Ot(n),i=h.useRef(!1);return u.jsx(J0,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:le(e.onCloseAutoFocus,a=>{var l;i.current||(l=o.triggerRef.current)==null||l.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:le(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)"}})});Ff.displayName=$f;var fS="DropdownMenuGroup",pS=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(Z0,{...o,...r,ref:t})});pS.displayName=fS;var hS="DropdownMenuLabel",Bf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(Q0,{...o,...r,ref:t})});Bf.displayName=hS;var mS="DropdownMenuItem",zf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(eS,{...o,...r,ref:t})});zf.displayName=mS;var gS="DropdownMenuCheckboxItem",Hf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(tS,{...o,...r,ref:t})});Hf.displayName=gS;var xS="DropdownMenuRadioGroup",vS=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(nS,{...o,...r,ref:t})});vS.displayName=xS;var wS="DropdownMenuRadioItem",Uf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(rS,{...o,...r,ref:t})});Uf.displayName=wS;var bS="DropdownMenuItemIndicator",Wf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(oS,{...o,...r,ref:t})});Wf.displayName=bS;var yS="DropdownMenuSeparator",Vf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(sS,{...o,...r,ref:t})});Vf.displayName=yS;var SS="DropdownMenuArrow",CS=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(iS,{...o,...r,ref:t})});CS.displayName=SS;var TS="DropdownMenuSubTrigger",Kf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(aS,{...o,...r,ref:t})});Kf.displayName=TS;var kS="DropdownMenuSubContent",qf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(lS,{...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)"}})});qf.displayName=kS;var ES=Rf,IS=Df,NS=Lf,Gf=Ff,Yf=Bf,Xf=zf,Jf=Hf,Zf=Uf,Qf=Wf,ep=Vf,tp=Kf,np=qf;const Ss=ES,Cs=IS,AS=h.forwardRef(({className:e,inset:t,children:n,...r},o)=>u.jsxs(tp,{ref:o,className:re("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(fe.ChevronRight,{className:"ml-auto h-4 w-4"})]}));AS.displayName=tp.displayName;const _S=h.forwardRef(({className:e,...t},n)=>u.jsx(np,{ref:n,className:re("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...t}));_S.displayName=np.displayName;const ao=h.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(NS,{children:u.jsx(Gf,{ref:r,sideOffset:t,className:re("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=Gf.displayName;const Dn=h.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(Xf,{ref:r,className:re("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}));Dn.displayName=Xf.displayName;const jS=h.forwardRef(({className:e,children:t,checked:n,...r},o)=>u.jsxs(Jf,{ref:o,className:re("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(Qf,{children:u.jsx(fe.Check,{className:"h-4 w-4"})})}),t]}));jS.displayName=Jf.displayName;const PS=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Zf,{ref:r,className:re("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(Qf,{children:u.jsx(fe.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));PS.displayName=Zf.displayName;const MS=h.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(Yf,{ref:r,className:re("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));MS.displayName=Yf.displayName;const RS=h.forwardRef(({className:e,...t},n)=>u.jsx(ep,{ref:n,className:re("-mx-1 my-1 h-px bg-muted",e),...t}));RS.displayName=ep.displayName;function La(e,[t,n]){return Math.min(n,Math.max(t,e))}function OS(e,t){return h.useReducer((n,r)=>t[n][r]??n,e)}var $a="ScrollArea",[rp,QI]=sn($a),[DS,Qt]=rp($a),op=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,A]=h.useState(!1),O=We(t,U=>l(U)),F=is(o);return u.jsx(DS,{scope:n,type:r,dir:F,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:A,onCornerWidthChange:w,onCornerHeightChange:k,children:u.jsx(ye.div,{dir:F,...i,ref:O,style:{position:"relative","--radix-scroll-area-corner-width":y+"px","--radix-scroll-area-corner-height":S+"px",...e.style}})})});op.displayName=$a;var sp="ScrollAreaViewport",ip=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=Qt(sp,n),a=h.useRef(null),l=We(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(ye.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})})]})});ip.displayName=sp;var yn="ScrollAreaScrollbar",Fa=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Qt(yn,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(LS,{...r,ref:t,forceMount:n}):o.type==="scroll"?u.jsx($S,{...r,ref:t,forceMount:n}):o.type==="auto"?u.jsx(ap,{...r,ref:t,forceMount:n}):o.type==="always"?u.jsx(Ba,{...r,ref:t}):null});Fa.displayName=yn;var LS=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Qt(yn,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(ap,{"data-state":s?"visible":"hidden",...r,ref:t})})}),$S=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Qt(yn,e.__scopeScrollArea),s=e.orientation==="horizontal",i=Is(()=>l("SCROLL_END"),100),[a,l]=OS("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(Ba,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:le(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:le(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),ap=h.forwardRef((e,t)=>{const n=Qt(yn,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=h.useState(!1),a=e.orientation==="horizontal",l=Is(()=>{if(n.viewport){const c=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?c:d)}},10);return Ir(n.viewport,l),Ir(n.content,l),u.jsx(Ft,{present:r||s,children:u.jsx(Ba,{"data-state":s?"visible":"hidden",...o,ref:t})})}),Ba=h.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=Qt(yn,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=fp(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 WS(m,i.current,a,f)}return n==="horizontal"?u.jsx(FS,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollLeft,f=pp(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(BS,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollTop,f=pp(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}),FS=h.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=Qt(yn,e.__scopeScrollArea),[i,a]=h.useState(),l=h.useRef(null),c=We(t,l,s.onScrollbarXChange);return h.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(cp,{"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":Es(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),mp(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:ks(i.paddingLeft),paddingEnd:ks(i.paddingRight)}})}})}),BS=h.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=Qt(yn,e.__scopeScrollArea),[i,a]=h.useState(),l=h.useRef(null),c=We(t,l,s.onScrollbarYChange);return h.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(cp,{"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":Es(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),mp(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:ks(i.paddingTop),paddingEnd:ks(i.paddingBottom)}})}})}),[zS,lp]=rp(yn),cp=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=Qt(yn,n),[v,g]=h.useState(null),x=We(t,O=>g(O)),y=h.useRef(null),w=h.useRef(""),S=f.viewport,k=r.content-r.viewport,C=wt(d),T=wt(l),E=Is(p,10);function A(O){if(y.current){const F=O.clientX-y.current.left,U=O.clientY-y.current.top;c({x:F,y:U})}}return h.useEffect(()=>{const O=F=>{const U=F.target;(v==null?void 0:v.contains(U))&&C(F,k)};return document.addEventListener("wheel",O,{passive:!1}),()=>document.removeEventListener("wheel",O,{passive:!1})},[S,v,k,C]),h.useEffect(T,[r,T]),Ir(v,E),Ir(f.content,E),u.jsx(zS,{scope:n,scrollbar:v,hasThumb:o,onThumbChange:wt(s),onThumbPointerUp:wt(i),onThumbPositionChange:T,onThumbPointerDown:wt(a),children:u.jsx(ye.div,{...m,ref:x,style:{position:"absolute",...m.style},onPointerDown:le(e.onPointerDown,O=>{O.button===0&&(O.target.setPointerCapture(O.pointerId),y.current=v.getBoundingClientRect(),w.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",f.viewport&&(f.viewport.style.scrollBehavior="auto"),A(O))}),onPointerMove:le(e.onPointerMove,A),onPointerUp:le(e.onPointerUp,O=>{const F=O.target;F.hasPointerCapture(O.pointerId)&&F.releasePointerCapture(O.pointerId),document.body.style.webkitUserSelect=w.current,f.viewport&&(f.viewport.style.scrollBehavior=""),y.current=null})})})}),Ts="ScrollAreaThumb",up=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=lp(Ts,e.__scopeScrollArea);return u.jsx(Ft,{present:n||o.hasThumb,children:u.jsx(HS,{ref:t,...r})})}),HS=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=Qt(Ts,n),i=lp(Ts,n),{onThumbPositionChange:a}=i,l=We(t,p=>i.onThumbChange(p)),c=h.useRef(void 0),d=Is(()=>{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=VS(p,a);c.current=f,a()}};return a(),p.addEventListener("scroll",m),()=>p.removeEventListener("scroll",m)}},[s.viewport,d,a]),u.jsx(ye.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:le(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:le(e.onPointerUp,i.onThumbPointerUp)})});up.displayName=Ts;var za="ScrollAreaCorner",dp=h.forwardRef((e,t)=>{const n=Qt(za,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?u.jsx(US,{...e,ref:t}):null});dp.displayName=za;var US=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=Qt(za,n),[s,i]=h.useState(0),[a,l]=h.useState(0),c=!!(s&&a);return Ir(o.scrollbarX,()=>{var p;const d=((p=o.scrollbarX)==null?void 0:p.offsetHeight)||0;o.onCornerHeightChange(d),l(d)}),Ir(o.scrollbarY,()=>{var p;const d=((p=o.scrollbarY)==null?void 0:p.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),c?u.jsx(ye.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 ks(e){return e?parseInt(e,10):0}function fp(e,t){const n=e/t;return isNaN(n)?0:n}function Es(e){const t=fp(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function WS(e,t,n,r="ltr"){const o=Es(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 hp([l,c],p)(e)}function pp(e,t,n="ltr"){const r=Es(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=La(e,l);return hp([0,i],[0,a])(c)}function hp(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 mp(e,t){return e>0&&e<t}var VS=(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 Is(e,t){const n=wt(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 Ir(e,t){const n=wt(t);It(()=>{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 gp=op,KS=ip,qS=dp;const Ha=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(gp,{ref:r,className:re("relative overflow-hidden",e),...n,children:[u.jsx(KS,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),u.jsx(xp,{}),u.jsx(qS,{})]}));Ha.displayName=gp.displayName;const xp=h.forwardRef(({className:e,orientation:t="vertical",...n},r)=>u.jsx(Fa,{ref:r,orientation:t,className:re("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(up,{className:"relative flex-1 rounded-full bg-border"})}));xp.displayName=Fa.displayName;const Ua=h.forwardRef(({className:e,type:t,...n},r)=>u.jsx("input",{type:t,className:re("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}));Ua.displayName="Input";const GS="group relative p-3 rounded-lg cursor-pointer transition-colors border text-gray-900 dark:text-slate-100",YS="bg-slate-700 border-slate-600 hover:bg-slate-600",XS="bg-slate-600 border-slate-500";function JS({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??XS}`:`${x??YS}`,k=C=>{C.stopPropagation(),o(e.threadId)};return u.jsxs("div",{onClick:k,className:`${GS} ${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(Ua,{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(ct,{variant:"ghost",size:"sm",onClick:()=>a(e.threadId),className:"h-6 w-6 p-0",children:u.jsx(fe.Check,{size:12})}),u.jsx(ct,{variant:"ghost",size:"sm",onClick:l,className:"h-6 w-6 p-0",children:u.jsx(fe.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(fe.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(Ss,{children:[u.jsx(Cs,{asChild:!0,children:u.jsx(ct,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",children:u.jsx(fe.MoreHorizontal,{size:12})})}),u.jsxs(ao,{align:"end",sideOffset:6,className:"w-44",children:[u.jsxs(Dn,{onClick:C=>{C.preventDefault(),c(e.threadId)},children:[u.jsx(fe.Share2,{className:"mr-2 h-4 w-4"}),"Share thread"]}),p&&n!==e.threadId&&u.jsxs(Dn,{onClick:C=>{C.preventDefault(),s(e,C)},children:[u.jsx(fe.Edit3,{className:"mr-2 h-4 w-4"}),"Rename"]}),m&&d&&u.jsxs(Dn,{className:"text-red-400 hover:text-red-300",onClick:C=>{C.preventDefault(),d(e.threadId,C)},children:[u.jsx(fe.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 vp=25,wp="thread-manager-view",ZS=e=>e==="default"||e==="shared",QS=()=>{if(typeof window>"u")return null;try{const e=window.localStorage.getItem(wp);if(ZS(e))return e}catch{}return null};function bp({defaultView:e}={}){const[t,n]=b.useState(()=>QS()??e??"default");b.useEffect(()=>{if(!(typeof window>"u"))try{window.localStorage.setItem(wp,t)}catch{}},[t]);const r=b.useCallback(o=>{n(o)},[]);return{view:t,setView:r}}const eC=[{key:"default",label:"My chats"},{key:"shared",label:"Shared with you"}];function Wa({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:A,isLoadingSharedThreads:O,actions:F,shareInFlight:U,shareStatus:W,clearShareStatus:z}=Pi(),{createThread:N,deleteThread:K,renameThread:M,shareThread:Q}=F,{loadThread:$}=Mi(),_=i??T,[V,J]=b.useState(Array.isArray(k)?k:[]),j=b.useRef(V.length>0),R=b.useRef(null),G=b.useRef(0),[Y,ie]=b.useState(null),[H,D]=b.useState(""),[X,Z]=b.useState(!1),[ce,L]=b.useState(!1),[oe,xe]=b.useState(null),[de,we]=b.useState(""),Me=v&&v.length>0?v:eC,He=bp({defaultView:m}),$e=g??He,Ae=p??$e.view,Fe=b.useCallback(P=>{p||$e.setView(P),f==null||f(P)},[p,f,$e]),Ge=Me.find(P=>P.key===Ae)??Me[0],Ke=P=>{xe(P),we(""),L(!0)},Xe=()=>{L(!1),xe(null),we(""),z()},tt=b.useCallback(async P=>{if(!(!oe||U)&&P.id)try{await Q(oe,P.id),setTimeout(()=>Xe(),600)}catch(te){console.error("Failed to share thread:",te)}},[Xe,U,oe,Q]),nt=b.useMemo(()=>{const P=y??[],te=de.trim().toLowerCase();return te?S?P.filter(ve=>S(ve,te)):P.filter(ve=>`${ve.label} ${ve.secondaryLabel??""}`.toLowerCase().includes(te)):P},[y,de,S]),Ze=Ae==="shared",pt=Ze?C:V,ht=Ze?O:A,Se=Ze?"No shared conversations yet":"No conversations yet",Re=P=>{const te=P.sharedAt?` • ${xt(P.sharedAt)}`:"";return`Shared by ${P.sharedByUserId}${te}`},mt=P=>"sharedByUserId"in P;b.useEffect(()=>{const P=Array.isArray(k)?k:[];if(P.length>0){j.current=!0,J(P);return}A||(j.current=!1,J(P))},[k,A]),b.useEffect(()=>{if(!R.current)return;const P=R.current.querySelector("[data-radix-scroll-area-viewport]");if(!P)return;let te=null,ve=null;return te=requestAnimationFrame(()=>{ve=requestAnimationFrame(()=>{P.scrollTop=G.current})}),()=>{te!==null&&cancelAnimationFrame(te),ve!==null&&cancelAnimationFrame(ve)}},[V]);const ot=async P=>{try{E(P),await $(P),a==null||a(P),l==null||l(P)}catch(te){console.error("Failed to select thread:",te)}},qe=async()=>{try{Z(!0);const P=await N();P&&(c==null||c(P),a==null||a(P))}catch(P){console.error("Failed to create thread:",P)}finally{Z(!1)}},yt=async(P,te)=>{if(te.stopPropagation(),!!confirm("Delete this thread?")){if(R.current){const ve=R.current.querySelector("[data-radix-scroll-area-viewport]");ve&&(G.current=ve.scrollTop)}try{await K(P),d==null||d(P)}catch(ve){console.error("Failed to delete thread:",ve)}}},De=(P,te)=>{te.stopPropagation(),ie(P.threadId),D(P.title||`Thread ${P.threadId.slice(0,8)}`)},Be=async P=>{if(H.trim())try{await M(P,H.trim()),ie(null),D("")}catch(te){console.error("Failed to update title:",te)}},St=()=>{ie(null),D("")},xt=P=>{if(!P)return"";try{const te=new Date(P),ae=new Date().getTime()-te.getTime(),Ie=Math.floor(ae/(1e3*60*60*24));return Ie===0?te.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):Ie===1?"Yesterday":Ie<7?`${Ie} days ago`:te.toLocaleDateString()}catch{return""}},Ye=P=>P.title||`Thread ${P.threadId.slice(0,8)}`,gt=P=>{const te=Ye(P);return te.length<=vp?te:`${te.slice(0,vp)}...`};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(ct,{onClick:qe,disabled:X||A,className:s.createButton||"px-3 py-2 gap-1",size:"sm",variant:"ghost",title:X?"Creating...":"New Chat",children:[u.jsx(fe.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(Ss,{children:[u.jsx(Cs,{asChild:!0,children:u.jsx(ct,{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:Ge.label})}),u.jsx(ao,{align:"start",sideOffset:6,className:"w-40",children:Me.map(P=>u.jsxs(Dn,{className:"justify-between text-[12px]",onClick:te=>{te.preventDefault(),Fe(P.key)},children:[u.jsx("span",{children:P.label}),Ae===P.key&&u.jsx(fe.Check,{className:"h-3 w-3"})]},P.key))})]})]})]}),u.jsx(Ha,{ref:R,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:ht?u.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-8 text-slate-400",children:[u.jsx(fe.Loader2,{className:"h-5 w-5 animate-spin"}),u.jsx("span",{className:"text-sm",children:"Loading threads…"})]}):pt.length===0?u.jsxs("div",{className:"text-center py-8 text-slate-400",children:[u.jsx(fe.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:Se})]}):pt.slice().sort((P,te)=>new Date(te.updatedAt||te.createdAt||"").getTime()-new Date(P.updatedAt||P.createdAt||"").getTime()).map(P=>u.jsx(JS,{thread:P,isActive:_===P.threadId,editingThreadId:Y,editingTitle:H,onSelect:ot,onStartEditing:De,onEditingTitleChange:te=>D(te),onSaveEditing:Be,onCancelEditing:St,onShare:()=>Ke(P.threadId),onDelete:yt,showEditTitle:r,showDeleteButton:n,formatDate:xt,getDisplayThreadTitle:gt,secondaryLine:Ze&&mt(P)?Re(P):void 0,itemClassName:s.threadItem,activeItemClassName:s.activeThread},P.threadId))})}),u.jsx(ra,{open:ce,onOpenChange:P=>!P&&Xe(),children:u.jsxs(ns,{className:"max-w-md p-0",children:[u.jsx(rs,{children:u.jsx(os,{children:"Share thread"})}),u.jsxs(oa,{children:[u.jsx(sa,{autoFocus:!0,value:de,onValueChange:P=>we(P),placeholder:"Search for recipients..."}),u.jsxs(ia,{children:[W&&u.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-xs text-muted-foreground",children:[U&&u.jsx(fe.Loader2,{className:"h-3 w-3 animate-spin"}),u.jsx("span",{className:W.startsWith("Failed")?"text-red-500":W.startsWith("Shared")?"text-emerald-500":"text-slate-600 dark:text-slate-400",children:W})]}),u.jsx(aa,{children:w?u.jsxs("span",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(fe.Loader2,{className:"h-4 w-4 animate-spin"}),"Loading recipients…"]}):"No matching recipients found"}),nt.length>0&&u.jsx(la,{heading:"Recipients",children:nt.map(P=>u.jsx(ca,{onSelect:()=>tt(P),children:u.jsxs("div",{className:"flex flex-col items-start text-sm",children:[u.jsx("span",{className:"font-medium",children:P.label}),P.secondaryLabel&&u.jsx("span",{className:"text-xs text-muted-foreground",children:P.secondaryLabel})]})},P.id))})]})]})]})})]})}const Va=h.forwardRef(({className:e,...t},n)=>u.jsx("textarea",{className:re("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}));Va.displayName="Textarea";const tC=1e4;function yp({initialValue:e="",editingMessageId:t=null,placeholder:n="Type your message...",isStreaming:r=!1,disabled:o=!1,maxLength:s=tC,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),A=b.useRef(null),O=b.useRef("");b.useEffect(()=>{x||(w(e??""),A.current=null,T.current&&(T.current.style.height="auto",T.current.style.height=`${T.current.scrollHeight}px`))},[e,t,x]);const[F,U]=b.useState(null),W=b.useCallback(R=>R.length>s?`Message too long (${R.length}/${s} characters)`:null,[s]),z=b.useMemo(()=>v??W,[v,W]),N=b.useCallback(R=>{const G=z(R);return U(G),g==null||g(G),O.current=R,G},[z,g]),K=b.useCallback(()=>{const R=T.current;R&&(R.style.height="auto",R.style.height=`${R.scrollHeight}px`)},[]);b.useEffect(()=>{K()},[K,S]),b.useEffect(()=>{if(!F)return;const R=(S??"").trim();O.current!==R&&N(R)},[S,F,N]);const M=b.useCallback((R,{fromUser:G})=>{x||w(R),G&&(a==null||a(R))},[x,a]),Q=b.useCallback(async R=>{R&&R.preventDefault();const G=(S??"").trim();if(!G&&!f||N(G))return;const Y=++E.current;A.current={id:Y,shouldClear:!0},C(()=>{var ie,H,D;try{const X=l(G);X&&typeof X.then=="function"?X.then(()=>{var Z,ce;((Z=A.current)==null?void 0:Z.id)===Y&&A.current.shouldClear&&(x||(w(""),T.current&&(T.current.style.height="auto"),a==null||a(""))),((ce=A.current)==null?void 0:ce.id)===Y&&(A.current=null)}).catch(()=>{var Z;((Z=A.current)==null?void 0:Z.id)===Y&&(A.current=null)}):(((ie=A.current)==null?void 0:ie.id)===Y&&A.current.shouldClear&&(x||(w(""),T.current&&(T.current.style.height="auto"),a==null||a(""))),((H=A.current)==null?void 0:H.id)===Y&&(A.current=null))}catch{((D=A.current)==null?void 0:D.id)===Y&&(A.current=null)}})},[S,l,f,x,a,N]),$=b.useCallback(R=>{const G=R.target.value;M(G,{fromUser:!0}),A.current&&(A.current.shouldClear=!1),T.current&&(T.current.style.height="auto",T.current.style.height=`${T.current.scrollHeight}px`),F&&N(G.trim())},[M,N,F]),_=b.useCallback(R=>{R.key==="Enter"&&!R.shiftKey?(R.preventDefault(),Q()):R.key==="Escape"&&t&&(R.preventDefault(),c==null||c())},[Q,t,c]),j=`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${t?"border-[hsl(var(--ring))] bg-[hsl(var(--card))] text-[hsl(var(--card-foreground))] dark:bg-[hsl(var(--card))] dark:text-[hsl(var(--card-foreground))]":""} ${m}`;return u.jsx("form",{onSubmit:R=>void Q(R),className:`w-full ${p}`,children:u.jsxs("div",{className:"flex items-end gap-2",children:[u.jsxs("div",{className:"flex-1",children:[u.jsx(Va,{ref:T,value:S,onChange:$,onKeyDown:_,placeholder:t?"Edit your message...":n,className:j,disabled:o,maxLength:s,rows:1,spellCheck:!1,autoCorrect:"off"}),F&&u.jsx("p",{className:"mt-1 text-xs text-destructive font-medium",children:F})]}),u.jsx("div",{children:r?u.jsx(ct,{type:"button",onClick:()=>{d==null||d()},size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",disabled:o||!d,children:u.jsx(fe.Square,{size:16})}):u.jsx(ct,{type:"submit",size:"icon",className:"shrink-0",title:t?"Save changes":"Send message",disabled:o||!S.trim()&&!f||k,children:u.jsx(fe.Send,{size:16})})})]})})}const nC=b.memo(yp),Ns=0,Ln=1,Nr=2,Sp=4;function Cp(e){return()=>e}function rC(e){e()}function Tp(e,t){return n=>e(t(n))}function kp(e,t){return()=>e(t)}function oC(e,t){return n=>e(t,n)}function Ka(e){return e!==void 0}function sC(...e){return()=>{e.map(rC)}}function Ar(){}function As(e,t){return t(e),e}function iC(e,t){return t(e)}function ut(...e){return e}function rt(e,t){return e(Ln,t)}function ze(e,t){e(Ns,t)}function qa(e){e(Nr)}function bt(e){return e(Sp)}function Ce(e,t){return rt(e,oC(t,Ns))}function un(e,t){const n=e(Ln,r=>{n(),t(r)});return n}function Ep(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function Ip(e,t){return e===t}function dt(e=Ip){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function Pe(e){return t=>n=>{e(n)&&t(n)}}function me(e){return t=>Tp(t,e)}function Sn(e){return t=>()=>{t(e)}}function ee(e,...t){const n=aC(...t);return(r,o)=>{switch(r){case Nr:qa(e);return;case Ln:return rt(e,n(o))}}}function Cn(e,t){return n=>r=>{n(t=e(t,r))}}function tr(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 Ve(...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);rt(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 aC(...e){return t=>e.reduceRight(iC,t)}function lC(e){let t,n;const r=()=>t==null?void 0:t();return function(o,s){switch(o){case Ln:return s?n===s?void 0:(r(),n=s,t=rt(e,s),t):(r(),Ar);case Nr:r(),n=null;return}}}function se(e){let t=e;const n=Je();return(r,o)=>{switch(r){case Ns:t=o;break;case Ln:{o(t);break}case Sp:return t}return n(r,o)}}function _t(e,t){return As(se(t),n=>Ce(e,n))}function Je(){const e=[];return(t,n)=>{switch(t){case Ns:e.slice().forEach(r=>{r(n)});return;case Nr:e.splice(0,e.length);return;case Ln:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}}}function Xt(e){return As(Je(),t=>Ce(e,t))}function Qe(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:cC(),singleton:n}}const cC=()=>Symbol();function uC(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 Ct(...e){const t=Je(),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);rt(s,l=>{n[i]=l,r=r|a,r===o&&ze(t,n)})}),function(s,i){switch(s){case Nr:{qa(t);return}case Ln:return r===o&&i(n),rt(t,i)}}}function _e(e,t=Ip){return ee(e,dt(t))}function Ga(...e){return function(t,n){switch(t){case Nr:return;case Ln:return sC(...e.map(r=>rt(r,n)))}}}var zt=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(zt||{});const dC={0:"debug",3:"error",1:"log",2:"warn"},fC=()=>typeof globalThis>"u"?window:globalThis,$n=Qe(()=>{const e=se(3);return{log:se((t,n,r=1)=>{var o;const s=(o=fC().VIRTUOSO_LOG_LEVEL)!=null?o:bt(e);r>=s&&console[dC[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0});function nr(e,t,n){return Ya(e,t,n).callbackRef}function Ya(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 pC(e,t,n,r,o,s,i,a,l){const c=b.useCallback(d=>{const p=hC(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?Np("column-gap",getComputedStyle(d).columnGap,o):Np("row-gap",getComputedStyle(d).rowGap,o)),p!==null&&e(p)},[e,t,o,s,i,r,a]);return Ya(c,n,l)}function hC(e,t,n,r){const o=e.length;if(o===0)return null;const s=[];for(let i=0;i<o;i++){const a=e.item(i);if(a.dataset.index===void 0)continue;const l=parseInt(a.dataset.index),c=parseFloat(a.dataset.knownSize),d=t(a,n);if(d===0&&r("Zero-sized element, this should not happen",{child:a},zt.ERROR),d===c)continue;const 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 Np(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,zt.WARN),t==="normal"?0:parseInt(t??"0",10)}function Ap(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}=Ya(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 Dt=Qe(()=>{const e=Je(),t=Je(),n=se(0),r=Je(),o=se(0),s=Je(),i=Je(),a=se(0),l=se(0),c=se(0),d=se(0),p=Je(),m=Je(),f=se(!1),v=se(!1),g=se(!1);return Ce(ee(e,me(({scrollTop:x})=>x)),t),Ce(ee(e,me(({scrollHeight:x})=>x)),i),Ce(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 _p(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 it(e){return e===lo}function co(e,t){if(!it(e))return t===e.k?e.v:t<e.k?co(e.l,t):co(e.r,t)}function dn(e,t,n="k"){if(it(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){const r=dn(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return dn(e.l,t,n)}function Jt(e,t,n){return it(e)?Mp(t,n,1):t===e.k?Et(e,{k:t,v:n}):t<e.k?Rp(Et(e,{l:Jt(e.l,t,n)})):Rp(Et(e,{r:Jt(e.r,t,n)}))}function _r(){return lo}function _s(e,t,n){if(it(e))return[];const r=dn(e,t)[0];return mC(Ja(e,r,n))}function Xa(e,t){if(it(e))return lo;const{k:n,l:r,r:o}=e;if(t===n){if(it(r))return o;if(it(o))return r;{const[s,i]=Pp(r);return js(Et(e,{k:s,l:jp(r),v:i}))}}else return t<n?js(Et(e,{l:Xa(r,t)})):js(Et(e,{r:Xa(o,t)}))}function rr(e){return it(e)?[]:[...rr(e.l),{k:e.k,v:e.v},...rr(e.r)]}function Ja(e,t,n){if(it(e))return[];const{k:r,l:o,r:s,v:i}=e;let a=[];return r>t&&(a=a.concat(Ja(o,t,n))),r>=t&&r<=n&&a.push({k:r,v:i}),r<=n&&(a=a.concat(Ja(s,t,n))),a}function js(e){const{l:t,lvl:n,r}=e;if(r.lvl>=n-1&&t.lvl>=n-1)return e;if(n>r.lvl+1){if(Za(t))return Op(Et(e,{lvl:n-1}));if(!it(t)&&!it(t.r))return Et(t.r,{l:Et(t,{r:t.r.l}),lvl:n,r:Et(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(Za(e))return Qa(Et(e,{lvl:n-1}));if(!it(r)&&!it(r.l)){const o=r.l,s=Za(o)?r.lvl-1:r.lvl;return Et(o,{l:Et(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:Qa(Et(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function Et(e,t){return Mp(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 jp(e){return it(e.r)?e.l:js(Et(e,{r:jp(e.r)}))}function Za(e){return it(e)||e.lvl>e.r.lvl}function Pp(e){return it(e.r)?[e.k,e.v]:Pp(e.r)}function Mp(e,t,n,r=lo,o=lo){return{k:e,l:r,lvl:n,r:o,v:t}}function Rp(e){return Qa(Op(e))}function Op(e){const{l:t}=e;return!it(t)&&t.lvl===e.lvl?Et(t,{r:Et(e,{l:t.r})}):e}function Qa(e){const{lvl:t,r:n}=e;return!it(n)&&!it(n.r)&&n.lvl===t&&n.r.lvl===t?Et(n,{l:Et(e,{r:n.l}),lvl:t+1}):e}function mC(e){return _p(e,({k:t,v:n})=>({index:t,value:n}))}function Dp(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 el=Qe(()=>({recalcInProgress:se(!1)}),[],{singleton:!0});function Lp(e,t,n){return e[Ps(e,t,n)]}function Ps(e,t,n,r=0){let o=e.length-1;for(;r<=o;){const s=Math.floor((r+o)/2),i=e[s],a=n(i,t);if(a===0)return s;if(a===-1){if(o-r<2)return s-1;o=s-1}else{if(o===r)return s;r=s+1}}throw new Error(`Failed binary finding record in array - ${e.join(",")}, searched for ${t}`)}function gC(e,t,n,r){const o=Ps(e,t,r),s=Ps(e,n,r,o);return e.slice(o,s+1)}function Fn(e,t){return Math.round(e.getBoundingClientRect()[t])}function Ms(e){return!it(e.groupOffsetTree)}function tl({index:e},t){return t===e?0:t<e?-1:1}function xC(){return{groupIndices:[],groupOffsetTree:_r(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:_r()}}function vC(e,t){let n=it(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),it(e)){e=Jt(e,0,s);continue}const a=_s(e,i-1,o+1);if(a.some(kC(r)))continue;let l=!1,c=!1;for(const{end:d,start:p,value:m}of a)l?(o>=p||s===m)&&(e=Xa(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 wC(e){return typeof e.groupIndex<"u"}function bC({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}=Lp(t,e,tl),i=e-r,a=s*i+(i-1)*n+o;return a>0?a+n:a}function $p(e,t){if(!Ms(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function Fp(e,t,n){if(wC(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=$p(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function yC(e,t,n,r=0){return r>0&&(t=Math.max(t,Lp(e,r,tl).offset)),_p(gC(e,t,n,bC),TC)}function SC(e,[t,n,r,o]){t.length>0&&r("received item sizes",t,zt.DEBUG);const s=e.sizeTree;let i=s,a=0;if(n.length>0&&it(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]=vC(i,t);if(i===s)return e;const{lastIndex:l,lastOffset:c,lastSize:d,offsetTree:p}=nl(e.offsetTree,a,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((m,f)=>Jt(m,f,fo(f,p,o)),_r()),lastIndex:l,lastOffset:c,lastSize:d,offsetTree:p,sizeTree:i}}function CC(e){return rr(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 Bp(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 nl(e,t,n,r){let o=e,s=0,i=0,a=0,l=0;if(t!==0){l=Ps(o,t-1,tl),a=o[l].offset;const c=dn(n,t-1);s=c[0],i=c[1],o.length&&o[l].size===dn(n,t)[1]&&(l-=1),o=o.slice(0,l+1)}else o=[];for(const{start:c,value:d}of _s(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 TC(e){return{index:e.index,value:e}}function kC(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 EC={offsetHeight:"height",offsetWidth:"width"},Tn=Qe(([{log:e},{recalcInProgress:t}])=>{const n=Je(),r=Je(),o=_t(r,0),s=Je(),i=Je(),a=se(0),l=se([]),c=se(void 0),d=se(void 0),p=se((C,T)=>Fn(C,EC[T])),m=se(void 0),f=se(0),v=xC(),g=_t(ee(n,Ve(l,e,f),Cn(SC,v),dt()),v),x=_t(ee(l,dt(),Cn((C,T)=>({current:T,prev:C.current}),{current:[],prev:[]}),me(({prev:C})=>C)),[]);Ce(ee(l,Pe(C=>C.length>0),Ve(g,f),me(([C,T,E])=>{const A=C.reduce((O,F,U)=>Jt(O,F,fo(F,T.offsetTree,E)||U),_r());return{...T,groupIndices:C,groupOffsetTree:A}})),g),Ce(ee(r,Ve(g),Pe(([C,{lastIndex:T}])=>C<T),me(([C,{lastIndex:T,lastSize:E}])=>[{endIndex:T,size:E,startIndex:C}])),n),Ce(c,d);const y=_t(ee(c,me(C=>C===void 0)),!0);Ce(ee(d,Pe(C=>C!==void 0&&it(bt(g).sizeTree)),me(C=>[{endIndex:0,size:C,startIndex:0}])),n);const w=Xt(ee(n,Ve(g),Cn(({sizes:C},[T,E])=>({changed:E!==C,sizes:E}),{changed:!1,sizes:v}),me(C=>C.changed)));rt(ee(a,Cn((C,T)=>({diff:C.prev-T,prev:T}),{diff:0,prev:0}),me(C=>C.diff)),C=>{const{groupIndices:T}=bt(g);if(C>0)ze(t,!0),ze(s,C+Bp(C,T));else if(C<0){const E=bt(x);E.length>0&&(C-=Bp(-C,E)),ze(i,C)}}),rt(ee(a,Ve(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},zt.ERROR)});const S=Xt(s);Ce(ee(s,Ve(g),me(([C,T])=>{const E=T.groupIndices.length>0,A=[],O=T.lastSize;if(E){const F=co(T.sizeTree,0);let U=0,W=0;for(;U<C;){const N=T.groupIndices[W],K=T.groupIndices.length===W+1?1/0:T.groupIndices[W+1]-N-1;A.push({endIndex:N,size:F,startIndex:N}),A.push({endIndex:N+1+K-1,size:O,startIndex:N+1}),W++,U+=K+1}const z=rr(T.sizeTree);return U!==C&&z.shift(),z.reduce((N,{k:K,v:M})=>{let Q=N.ranges;return N.prevSize!==0&&(Q=[...N.ranges,{endIndex:K+C-1,size:N.prevSize,startIndex:N.prevIndex}]),{prevIndex:K+C,prevSize:M,ranges:Q}},{prevIndex:C,prevSize:0,ranges:A}).ranges}return rr(T.sizeTree).reduce((F,{k:U,v:W})=>({prevIndex:U+C,prevSize:W,ranges:[...F.ranges,{endIndex:U+C-1,size:F.prevSize,startIndex:F.prevIndex}]}),{prevIndex:0,prevSize:O,ranges:[]}).ranges})),n);const k=Xt(ee(i,Ve(g,f),me(([C,{offsetTree:T},E])=>{const A=-C;return fo(A,T,E)})));return Ce(ee(i,Ve(g,f),me(([C,T,E])=>{if(T.groupIndices.length>0){if(it(T.sizeTree))return T;let A=_r();const O=bt(x);let F=0,U=0,W=0;for(;F<-C;){W=O[U];const z=O[U+1]-W-1;U++,F+=z+1}if(A=rr(T.sizeTree).reduce((z,{k:N,v:K})=>Jt(z,Math.max(0,N+C),K),A),F!==-C){const z=co(T.sizeTree,W);A=Jt(A,0,z);const N=dn(T.sizeTree,-C+1)[1];A=Jt(A,1,N)}return{...T,sizeTree:A,...nl(T.offsetTree,0,A,E)}}else{const A=rr(T.sizeTree).reduce((O,{k:F,v:U})=>Jt(O,Math.max(0,F+C),U),_r());return{...T,sizeTree:A,...nl(T.offsetTree,0,A,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}},ut($n,el),{singleton:!0});function IC(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const zp=Qe(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=Je(),i=Je(),a=Xt(ee(s,me(IC)));return Ce(ee(a,me(l=>l.totalCount)),n),Ce(ee(a,me(l=>l.groupIndices)),e),Ce(ee(Ct(o,t,r),Pe(([l,c])=>Ms(c)),me(([l,c,d])=>dn(c.groupOffsetTree,Math.max(l-d,0),"v")[0]),dt(),me(l=>[l])),i),{groupCounts:s,topItemsIndexes:i}},ut(Tn,Dt)),Bn=Qe(([{log:e}])=>{const t=se(!1),n=Xt(ee(t,Pe(r=>r),dt()));return rt(t,r=>{r&&bt(e)("props updated",{},zt.DEBUG)}),{didMount:n,propsReady:t}},ut($n),{singleton:!0}),NC=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function Hp(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!NC)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const po=Qe(([{gap:e,listRefresh:t,sizes:n,totalCount:r},{fixedFooterHeight:o,fixedHeaderHeight:s,footerHeight:i,headerHeight:a,scrollingInProgress:l,scrollTo:c,smoothScrollTargetReached:d,viewportHeight:p},{log:m}])=>{const f=Je(),v=Je(),g=se(0);let x=null,y=null,w=null;function S(){x&&(x(),x=null),w&&(w(),w=null),y&&(clearTimeout(y),y=null),ze(l,!1)}return Ce(ee(f,Ve(n,p,r,g,a,i,m),Ve(e,s,o),me(([[k,C,T,E,A,O,F,U],W,z,N])=>{const K=Hp(k),{align:M,behavior:Q,offset:$}=K,_=E-1,V=Fp(K,C,_);let J=fo(V,C.offsetTree,W)+O;M==="end"?(J+=z+dn(C.sizeTree,V)[1]-T+N,V===_&&(J+=F)):M==="center"?J+=(z+dn(C.sizeTree,V)[1]-T+N)/2:J-=A,$&&(J+=$);const j=R=>{S(),R?(U("retrying to scroll to",{location:k},zt.DEBUG),ze(f,k)):(ze(v,!0),U("list did not change, scroll successful",{},zt.DEBUG))};if(S(),Q==="smooth"){let R=!1;w=rt(t,G=>{R=R||G}),x=un(d,()=>{j(R)})}else x=un(ee(t,AC(150)),j);return y=setTimeout(()=>{S()},1200),ze(l,!0),U("scrolling from index to",{behavior:Q,index:V,top:J},zt.DEBUG),{behavior:Q,top:J}})),c),{scrollTargetReached:v,scrollToIndex:f,topListHeight:g}},ut(Tn,Dt,$n),{singleton:!0});function AC(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function rl(e,t){e==0?t():requestAnimationFrame(()=>{rl(e-1,t)})}function ol(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const ho=Qe(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:s},{didMount:i}])=>{const a=se(!0),l=se(0),c=se(!0);return Ce(ee(i,Ve(l),Pe(([d,p])=>!!p),Sn(!1)),a),Ce(ee(i,Ve(l),Pe(([d,p])=>!!p),Sn(!1)),c),rt(ee(Ct(t,i),Ve(a,n,e,c),Pe(([[,d],p,{sizeTree:m},f,v])=>d&&(!it(m)||Ka(f))&&!p&&!v),Ve(l)),([,d])=>{un(o,()=>{ze(c,!0)}),rl(4,()=>{un(r,()=>{ze(a,!0)}),ze(s,d)})}),{initialItemFinalLocationReached:c,initialTopMostItemIndex:l,scrolledToInitialItem:a}},ut(Tn,Dt,po,Bn),{singleton:!0});function Up(e,t){return Math.abs(e-t)<1.01}const mo="up",go="down",_C="none",jC={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},PC=0,xo=Qe(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=se(!1),a=se(!0),l=Je(),c=Je(),d=se(4),p=se(PC),m=_t(ee(Ga(ee(_e(o),tr(1),Sn(!0)),ee(_e(o),tr(1),Sn(!1),Ep(100))),dt()),!1),f=_t(ee(Ga(ee(n,Sn(!0)),ee(n,Sn(!1),Ep(200))),dt()),!1);Ce(ee(Ct(_e(o),_e(p)),me(([w,S])=>w<=S),dt()),a),Ce(ee(a,In(50)),c);const v=Xt(ee(Ct(r,_e(s),_e(t),_e(e),_e(d)),Cn((w,[{scrollHeight:S,scrollTop:k},C,T,E,A])=>{const O=k+C-S>-A,F={scrollHeight:S,scrollTop:k,viewportHeight:C};if(O){let W,z;return k>w.state.scrollTop?(W="SCROLLED_DOWN",z=w.state.scrollTop-k):(W="SIZE_DECREASED",z=w.state.scrollTop-k||w.scrollTopDelta),{atBottom:!0,atBottomBecause:W,scrollTopDelta:z,state:F}}let U;return F.scrollHeight>w.state.scrollHeight?U="SIZE_INCREASED":C<w.state.viewportHeight?U="VIEWPORT_HEIGHT_DECREASING":k<w.state.scrollTop?U="SCROLLING_UPWARDS":U="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:U,state:F}},jC),dt((w,S)=>w&&w.atBottom===S.atBottom))),g=_t(ee(r,Cn((w,{scrollHeight:S,scrollTop:k,viewportHeight:C})=>{if(Up(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}),Pe(w=>w.changed),me(w=>w.jump)),0);Ce(ee(v,me(w=>w.atBottom)),i),Ce(ee(i,In(50)),l);const x=se(go);Ce(ee(r,me(({scrollTop:w})=>w),dt(),Cn((w,S)=>bt(f)?{direction:w.direction,prevScrollTop:S}:{direction:S<w.prevScrollTop?mo:go,prevScrollTop:S},{direction:go,prevScrollTop:0}),me(w=>w.direction)),x),Ce(ee(r,In(50),Sn(_C)),x);const y=se(0);return Ce(ee(m,Pe(w=>!w),Sn(0)),y),Ce(ee(o,In(100),Ve(m),Pe(([w,S])=>!!S),Cn(([w,S],[k])=>[S,k],[0,0]),me(([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}},ut(Dt)),Rs="top",Os="bottom",Wp="none";function Vp(e,t,n){return typeof e=="number"?n===mo&&t===Rs||n===go&&t===Os?e:0:n===mo?t===Rs?e.main:e.reverse:t===Os?e.main:e.reverse}function Kp(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const sl=Qe(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=Je(),i=se(0),a=se(0),l=se(0),c=_t(ee(Ct(_e(r),_e(o),_e(n),_e(s,uo),_e(l),_e(i),_e(t),_e(e),_e(a)),me(([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=Wp;const A=Kp(S,Rs),O=Kp(S,Os);return f-=w,f+=m+y,v+=m+y,v-=w,f>d+C-A&&(E=mo),v<d-T+p+O&&(E=go),E!==Wp?[Math.max(k-m-Vp(g,Rs,E)-A,0),k-T-y+p+Vp(g,Os,E)+O]:null}),Pe(d=>d!=null),dt(uo)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:l,topListHeight:i,visibleRange:c}},ut(Dt),{singleton:!0});function MC(e,t,n){if(Ms(t)){const r=$p(e,t);return[{index:dn(t.groupOffsetTree,r)[0],offset:0,size:0},{data:n==null?void 0:n[0],index:r,offset:0,size:0}]}return[{data:n==null?void 0:n[0],index:e,offset:0,size:0}]}const il={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Ds(e,t,n,r,o,s){const{lastIndex:i,lastOffset:a,lastSize:l}=o;let 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:Gp(e,o,s),offsetBottom:v,offsetTop:c,top:f,topItems:Gp(t,o,s),topListHeight:t.reduce((g,x)=>x.size+g,0),totalCount:n}}function qp(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=ol(t,a),c=Array.from({length:a}).map((d,p)=>({data:s[p+l],index:p+l,offset:0,size:0}));return Ds(c,[],a,o,n,r)}function Gp(e,t,n){if(e.length===0)return[];if(!Ms(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=_s(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 or=Qe(([{data:e,firstItemIndex:t,gap:n,sizes:r,totalCount:o},s,{listBoundary:i,topListHeight:a,visibleRange:l},{initialTopMostItemIndex:c,scrolledToInitialItem:d},{topListHeight:p},m,{didMount:f},{recalcInProgress:v}])=>{const g=se([]),x=se(0),y=Je();Ce(s.topItemsIndexes,g);const w=_t(ee(Ct(f,v,_e(l,uo),_e(o),_e(r),_e(c),d,_e(g),_e(t),_e(n),e),Pe(([T,E,,A,,,,,,,O])=>{const F=O&&O.length!==A;return T&&!E&&!F}),me(([,,[T,E],A,O,F,U,W,z,N,K])=>{const M=O,{offsetTree:Q,sizeTree:$}=M,_=bt(x);if(A===0)return{...il,totalCount:A};if(T===0&&E===0)return _===0?{...il,totalCount:A}:qp(_,F,O,z,N,K||[]);if(it($))return _>0?null:Ds(MC(ol(F,A),M,K),[],A,N,M,z);const V=[];if(W.length>0){const Y=W[0],ie=W[W.length-1];let H=0;for(const D of _s($,Y,ie)){const X=D.value,Z=Math.max(D.start,Y),ce=Math.min(D.end,ie);for(let L=Z;L<=ce;L++)V.push({data:K==null?void 0:K[L],index:L,offset:H,size:X}),H+=X}}if(!U)return Ds([],V,A,N,M,z);const J=W.length>0?W[W.length-1]+1:0,j=yC(Q,T,E,J);if(j.length===0)return null;const R=A-1,G=As([],Y=>{for(const ie of j){const H=ie.value;let D=H.offset,X=ie.start;const Z=H.size;if(H.offset<T){X+=Math.floor((T-H.offset+N)/(Z+N));const L=X-ie.start;D+=L*Z+L*N}X<J&&(D+=(J-X)*Z,X=J);const ce=Math.min(ie.end,R);for(let L=X;L<=ce&&!(D>=E);L++)Y.push({data:K==null?void 0:K[L],index:L,offset:D,size:Z}),D+=Z+N}});return Ds(G,V,A,N,M,z)}),Pe(T=>T!==null),dt()),il);Ce(ee(e,Pe(Ka),me(T=>T==null?void 0:T.length)),o),Ce(ee(w,me(T=>T.topListHeight)),p),Ce(p,a),Ce(ee(w,me(T=>[T.top,T.bottom])),i),Ce(ee(w,me(T=>T.items)),y);const S=Xt(ee(w,Pe(({items:T})=>T.length>0),Ve(o,e),Pe(([{items:T},E])=>T[T.length-1].originalIndex===E-1),me(([,T,E])=>[T-1,E]),dt(uo),me(([T])=>T))),k=Xt(ee(w,In(200),Pe(({items:T,topItems:E})=>T.length>0&&T[0].originalIndex===E.length),me(({items:T})=>T[0].index),dt())),C=Xt(ee(w,Pe(({items:T})=>T.length>0),me(({items:T})=>{let E=0,A=T.length-1;for(;T[E].type==="group"&&E<A;)E++;for(;T[A].type==="group"&&A>E;)A--;return{endIndex:T[A].index,startIndex:T[E].index}}),dt(Dp)));return{endReached:S,initialItemCount:x,itemsRendered:y,listState:w,rangeChanged:C,startReached:k,topItemsIndexes:g,...m}},ut(Tn,zp,sl,ho,po,xo,Bn,el),{singleton:!0}),Yp=Qe(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=Je(),i=_t(ee(Ct(n,e,r,t,o),me(([a,l,c,d,p])=>a+l+c+d+p.offsetBottom+p.bottom)),0);return Ce(_e(i),s),{totalListHeight:i,totalListHeightChanged:s}},ut(Dt,or),{singleton:!0}),RC=Qe(([{viewportHeight:e},{totalListHeight:t}])=>{const n=se(!1),r=_t(ee(Ct(n,e,t),Pe(([o])=>o),me(([,o,s])=>Math.max(0,o-s)),In(0),dt()),0);return{alignToBottom:n,paddingTopAddition:r}},ut(Dt,Yp),{singleton:!0}),Xp=Qe(()=>({context:se(null)})),OC=({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,Jp=Qe(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:s,scrollingInProgress:i,scrollTop:a,viewportHeight:l},{scrollToIndex:c}])=>{const d=Je();return Ce(ee(d,Ve(t,l,n,s,o,r,a),Ve(e),me(([[p,m,f,v,g,x,y,w],S])=>{const{align:k,behavior:C,calculateViewLocation:T=OC,done:E,...A}=p,O=Fp(p,m,v-1),F=fo(O,m.offsetTree,S)+g+x,U=F+dn(m.sizeTree,O)[1],W=w+x,z=w+f-y,N=T({itemBottom:U,itemTop:F,locationParams:{align:k,behavior:C,...A},viewportBottom:z,viewportTop:W});return N?E&&un(ee(i,Pe(K=>!K),tr(bt(i)?1:2)),E):E&&E(),N}),Pe(p=>p!==null)),c),{scrollIntoView:d}},ut(Tn,Dt,po,or,$n),{singleton:!0});function Zp(e){return e?e==="smooth"?"smooth":"auto":!1}const DC=(e,t)=>typeof e=="function"?Zp(e(t)):t&&Zp(e),LC=Qe(([{listRefresh:e,totalCount:t,fixedItemSize:n,data:r},{atBottomState:o,isAtBottom:s},{scrollToIndex:i},{scrolledToInitialItem:a},{didMount:l,propsReady:c},{log:d},{scrollingInProgress:p},{context:m},{scrollIntoView:f}])=>{const v=se(!1),g=Je();let x=null;function y(C){ze(i,{align:"end",behavior:C,index:"LAST"})}rt(ee(Ct(ee(_e(t),tr(1)),l),Ve(_e(v),s,a,p),me(([[C,T],E,A,O,F])=>{let U=T&&O,W="auto";return U&&(W=DC(E,A||F),U=U&&!!W),{followOutputBehavior:W,shouldFollow:U,totalCount:C}}),Pe(({shouldFollow:C})=>C)),({followOutputBehavior:C,totalCount:T})=>{x&&(x(),x=null),bt(n)?requestAnimationFrame(()=>{bt(d)("following output to ",{totalCount:T},zt.DEBUG),y(C)}):x=un(e,()=>{bt(d)("following output to ",{totalCount:T},zt.DEBUG),y(C),x=null})});function w(C){const T=un(o,E=>{C&&!E.atBottom&&E.notAtBottomBecause==="SIZE_INCREASED"&&!x&&(bt(d)("scrolling to bottom due to increased size",{},zt.DEBUG),y("auto"))});setTimeout(T,100)}rt(ee(Ct(_e(v),t,c),Pe(([C,,T])=>C&&T),Cn(({value:C},[,T])=>({refreshed:C===T,value:T}),{refreshed:!1,value:0}),Pe(({refreshed:C})=>C),Ve(v,t)),([,C])=>{bt(a)&&w(C!==!1)}),rt(g,()=>{w(bt(v)!==!1)}),rt(Ct(_e(v),o),([C,T])=>{C&&!T.atBottom&&T.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&y("auto")});const S=se(null),k=Je();return Ce(Ga(ee(_e(r),me(C=>{var T;return(T=C==null?void 0:C.length)!=null?T:0})),ee(_e(t))),k),rt(ee(Ct(ee(k,tr(1)),l),Ve(_e(S),a,p,m),me(([[C,T],E,A,O,F])=>T&&A&&(E==null?void 0:E({context:F,totalCount:C,scrollingInProgress:O}))),Pe(C=>!!C),In(0)),C=>{x&&(x(),x=null),bt(n)?requestAnimationFrame(()=>{bt(d)("scrolling into view",{}),ze(f,C)}):x=un(e,()=>{bt(d)("scrolling into view",{}),ze(f,C),x=null})}),{autoscrollToBottom:g,followOutput:v,scrollIntoViewOnChange:S}},ut(Tn,xo,po,ho,Bn,$n,Dt,Xp,Jp)),$C=Qe(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(Ce(ee(a,Ve(s),Pe(([,l])=>l!==0),Ve(o,r,t,n,e),me(([[,l],c,d,p,m,f=[]])=>qp(l,c,d,p,m,f))),i),{}),ut(Tn,ho,or,Bn),{singleton:!0}),FC=Qe(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=se(0);return rt(ee(e,Ve(r),Pe(([,o])=>o!==0),me(([,o])=>({top:o}))),o=>{un(ee(n,tr(1),Pe(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{ze(t,o)})})}),{initialScrollTop:r}},ut(Bn,Dt,or),{singleton:!0}),Qp=Qe(([{scrollVelocity:e}])=>{const t=se(!1),n=Je(),r=se(!1);return Ce(ee(e,Ve(r,t,n),Pe(([o,s])=>!!s),me(([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}),dt()),t),rt(ee(Ct(t,e,n),Ve(r)),([[o,s,i],a])=>{o&&a&&a.change&&a.change(s,i)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},ut(xo),{singleton:!0}),al=Qe(([{scrollContainerState:e,scrollTo:t}])=>{const n=Je(),r=Je(),o=Je(),s=se(!1),i=se(void 0);return Ce(ee(Ct(n,r),me(([{scrollHeight:a,scrollTop:l,viewportHeight:c},{offsetTop:d}])=>({scrollHeight:a,scrollTop:Math.max(0,l-d),viewportHeight:c}))),e),Ce(ee(t,Ve(r),me(([a,{offsetTop:l}])=>({...a,top:a.top+l}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},ut(Dt)),BC=Qe(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:a,windowViewportRect:l}])=>{const c=Je(),d=se(void 0),p=se(null),m=se(null);return Ce(a,p),Ce(l,m),rt(ee(c,Ve(t,r,i,p,m,n)),([f,v,g,x,y,w,S])=>{const k=CC(v.sizeTree);x&&y!==null&&w!==null&&(g=y.scrollTop-w.offsetTop),g-=S,f({ranges:k,scrollTop:g})}),Ce(ee(d,Pe(Ka),me(zC)),o),Ce(ee(s,Ve(d),Pe(([,f])=>f!==void 0),dt(),me(([,f])=>f.ranges)),e),{getState:c,restoreStateFrom:d}},ut(Tn,Dt,ho,Bn,al));function zC(e){return{align:"start",index:0,offset:e.scrollTop}}const HC=Qe(([{topItemsIndexes:e}])=>{const t=se(0);return Ce(ee(t,Pe(n=>n>=0),me(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},ut(or));function eh(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const UC=eh(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),WC=Qe(([{deviation:e,scrollBy:t,scrollingInProgress:n,scrollTop:r},{isAtBottom:o,isScrolling:s,lastJumpDueToItemResize:i,scrollDirection:a},{listState:l},{beforeUnshiftWith:c,gap:d,shiftWithOffset:p,sizes:m},{log:f},{recalcInProgress:v}])=>{const g=Xt(ee(l,Ve(i),Cn(([,y,w,S],[{bottom:k,items:C,offsetBottom:T,totalCount:E},A])=>{const O=k+T;let F=0;return w===E&&y.length>0&&C.length>0&&(C[0].originalIndex===0&&y[0].originalIndex===0||(F=O-S,F!==0&&(F+=A))),[F,C,E,O]},[0,[],0,0]),Pe(([y])=>y!==0),Ve(r,a,n,o,f,v),Pe(([,y,w,S,,,k])=>!k&&!S&&y!==0&&w===mo),me(([[y],,,,,w])=>(w("Upward scrolling compensation",{amount:y},zt.DEBUG),y))));function x(y){y>0?(ze(t,{behavior:"auto",top:-y}),ze(e,0)):(ze(e,0),ze(t,{behavior:"auto",top:-y}))}return rt(ee(g,Ve(e,s)),([y,w,S])=>{S&&UC()?ze(e,w-y):x(-y)}),rt(ee(Ct(_t(s,!1),e,v),Pe(([y,w,S])=>!y&&!S&&w!==0),me(([y,w])=>w),In(1)),x),Ce(ee(p,me(y=>({top:-y}))),t),rt(ee(c,Ve(m,d),me(([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 A=co(k,0);let O=0,F=0;for(;O<y;){O++,E+=A;let U=w.length===F+1?1/0:w[F+1]-w[F]-1;O+U>y&&(E-=A,U=y-O+1),O+=U,E+=T(U),F++}return E}})),y=>{ze(e,y),requestAnimationFrame(()=>{ze(t,{top:y}),requestAnimationFrame(()=>{ze(e,0),ze(v,!1)})})}),{deviation:e}},ut(Dt,xo,or,Tn,$n,el)),VC=Qe(([e,t,n,r,o,s,i,a,l,c,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...l,...c,...d}),ut(sl,$C,Bn,Qp,Yp,FC,RC,al,Jp,$n,Xp)),th=Qe(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:r,gap:o,groupIndices:s,itemSize:i,sizeRanges:a,sizes:l,statefulTotalCount:c,totalCount:d,trackItemSizes:p},{initialItemFinalLocationReached:m,initialTopMostItemIndex:f,scrolledToInitialItem:v},g,x,y,{listState:w,topItemsIndexes:S,...k},{scrollToIndex:C},T,{topItemCount:E},{groupCounts:A},O])=>(Ce(k.rangeChanged,O.scrollSeekRangeChanged),Ce(ee(O.windowViewportRect,me(F=>F.visibleHeight)),g.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,gap:o,groupCounts:A,initialItemFinalLocationReached:m,initialTopMostItemIndex:f,scrolledToInitialItem:v,sizeRanges:a,topItemCount:E,topItemsIndexes:S,totalCount:d,...y,groupIndices:s,itemSize:i,listState:w,scrollToIndex:C,statefulTotalCount:c,trackItemSizes:p,...k,...O,...g,sizes:l,...x}),ut(Tn,ho,Dt,BC,LC,or,po,WC,HC,zp,VC));function KC(e,t){const n={},r={};let o=0;const s=e.length;for(;o<s;)r[e[o]]=1,o+=1;for(const i in t)Object.hasOwn(r,i)||(n[i]=t[i]);return n}const Ls=typeof document<"u"?b.useLayoutEffect:b.useEffect;function nh(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&&ze(x.propsReady,!1);for(const w of r){const S=x[t.required[w]];ze(S,y[w])}for(const w of o)if(w in y){const S=x[t.optional[w]];ze(S,y[w])}x.propsReady&&ze(x.propsReady,!0)}function c(x){return s.reduce((y,w)=>(y[w]=S=>{const k=x[t.methods[w]];ze(k,S)},y),{})}function d(x){return i.reduce((y,w)=>(y[w]=lC(x[t.events[w]]),y),{})}const p=b.forwardRef((x,y)=>{const{children:w,...S}=x,[k]=b.useState(()=>As(uC(e),E=>{l(E,S)})),[C]=b.useState(kp(d,k));Ls(()=>{for(const E of i)E in S&&rt(C[E],S[E]);return()=>{Object.values(C).map(qa)}},[S,C,k]),Ls(()=>{l(k,S)}),b.useImperativeHandle(y,Cp(c(k)));const T=n;return u.jsx(a.Provider,{value:k,children:n?u.jsx(T,{...KC([...r,...o,...i],S),children:w}):w})}),m=x=>{const y=b.useContext(a);return b.useCallback(w=>{ze(y[x],w)},[y,x])},f=x=>{const y=b.useContext(a)[x],w=b.useCallback(S=>rt(y,S),[y]);return b.useSyncExternalStore(w,()=>bt(y),()=>bt(y))},v=x=>{const y=b.useContext(a)[x],[w,S]=b.useState(kp(bt,y));return Ls(()=>rt(y,k=>{k!==w&&S(Cp(k))}),[y,w]),w},g=b.version.startsWith("18")?f:v;return{Component:p,useEmitter:(x,y)=>{const w=b.useContext(a)[x];Ls(()=>rt(w,y),[y,w])},useEmitterValue:g,usePublisher:m}}const rh=b.createContext(void 0),oh=b.createContext(void 0),sh=typeof document<"u"?b.useLayoutEffect:b.useEffect;function ll(e){return"self"in e}function qC(e){return"body"in e}function ih(e,t,n,r=Ar,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(qC(x)||ll(x)){const w=ll(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():To.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;ll(f)?(x=Math.max(Fn(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=Fn(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)),Up(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 cl="-webkit-sticky",ah="sticky",ul=eh(()=>{if(typeof document>"u")return ah;const e=document.createElement("div");return e.style.position=cl,e.style.position===cl?cl:ah});function dl(e){return e}const GC=Qe(()=>{const e=se(a=>`Item ${a}`),t=se(a=>`Group ${a}`),n=se({}),r=se(dl),o=se("div"),s=se(Ar),i=(a,l=null)=>_t(ee(n,me(c=>c[a]),dt()),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")}}),YC=Qe(([e,t])=>({...e,...t}),ut(th,GC)),XC=({height:e})=>u.jsx("div",{style:{height:e}}),JC={overflowAnchor:"none",position:ul(),zIndex:1},lh={overflowAnchor:"none"},ZC={...lh,display:"inline-block",height:"100%"},ch=b.memo(function({showTopList:e=!1}){const t=Oe("listState"),n=en("sizeRanges"),r=Oe("useWindowScroll"),o=Oe("customScrollParent"),s=en("windowScrollContainerState"),i=en("scrollContainerState"),a=o||r?s:i,l=Oe("itemContent"),c=Oe("context"),d=Oe("groupContent"),p=Oe("trackItemSizes"),m=Oe("itemSize"),f=Oe("log"),v=en("gap"),g=Oe("horizontalDirection"),{callbackRef:x}=pC(n,m,p,e?Ar:a,f,v,o,g,Oe("skipAnimationFrameInResizeObserver")),[y,w]=b.useState(0);fl("deviation",N=>{y!==N&&w(N)});const S=Oe("EmptyPlaceholder"),k=Oe("ScrollSeekPlaceholder")||XC,C=Oe("ListComponent"),T=Oe("ItemComponent"),E=Oe("GroupComponent"),A=Oe("computeItemKey"),O=Oe("isSeeking"),F=Oe("groupIndices").length>0,U=Oe("alignToBottom"),W=Oe("initialItemFinalLocationReached"),z=e?{}:{boxSizing:"border-box",...g?{display:"inline-block",height:"100%",marginLeft:y!==0?y:U?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:y!==0?y:U?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...W?{}:{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:z,children:(e?t.topItems:t.items).map(N=>{const K=N.originalIndex,M=A(K+t.firstItemIndex,N.data,c);return O?b.createElement(k,{...jt(k,c),height:N.size,index:N.index,key:M,type:N.type||"item",...N.type==="group"?{}:{groupIndex:N.groupIndex}}):N.type==="group"?b.createElement(E,{...jt(E,c),"data-index":K,"data-item-index":N.index,"data-known-size":N.size,key:M,style:JC},d(N.index,c)):b.createElement(T,{...jt(T,c),...nT(T,N.data),"data-index":K,"data-item-group-index":N.groupIndex,"data-item-index":N.index,"data-known-size":N.size,key:M,style:g?ZC:lh},F?l(N.index,N.groupIndex,N.data,c):l(N.index,N.data,c))})})}),QC={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},eT={outline:"none",overflowX:"auto",position:"relative"},$s=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),tT={position:ul(),top:0,width:"100%",zIndex:1};function jt(e,t){if(typeof e!="string")return{context:t}}function nT(e,t){return{item:typeof e=="string"?void 0:t}}const rT=b.memo(function(){const e=Oe("HeaderComponent"),t=en("headerHeight"),n=Oe("HeaderFooterTag"),r=nr(b.useMemo(()=>s=>{t(Fn(s,"height"))},[t]),!0,Oe("skipAnimationFrameInResizeObserver")),o=Oe("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...jt(e,o)})}):null}),oT=b.memo(function(){const e=Oe("FooterComponent"),t=en("footerHeight"),n=Oe("HeaderFooterTag"),r=nr(b.useMemo(()=>s=>{t(Fn(s,"height"))},[t]),!0,Oe("skipAnimationFrameInResizeObserver")),o=Oe("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...jt(e,o)})}):null});function uh({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}=ih(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?eT:QC,...o},tabIndex:0,...i,...jt(l,s),children:r})})}function dh({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}=ih(a,c,l,v,m);return sh(()=>{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 sT=({children:e})=>{const t=b.useContext(rh),n=en("viewportHeight"),r=en("fixedItemHeight"),o=Oe("alignToBottom"),s=Oe("horizontalDirection"),i=b.useMemo(()=>Tp(n,l=>Fn(l,s?"width":"height")),[n,s]),a=nr(i,!0,Oe("skipAnimationFrameInResizeObserver"));return b.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),u.jsx("div",{"data-viewport-type":"element",ref:a,style:$s(o),children:e})},iT=({children:e})=>{const t=b.useContext(rh),n=en("windowViewportRect"),r=en("fixedItemHeight"),o=Oe("customScrollParent"),s=Ap(n,o,Oe("skipAnimationFrameInResizeObserver")),i=Oe("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:$s(i),children:e})},aT=({children:e})=>{const t=Oe("TopItemListComponent")||"div",n=Oe("headerHeight"),r={...tT,marginTop:`${n}px`},o=Oe("context");return u.jsx(t,{style:r,...jt(t,o),children:e})},lT=b.memo(function(e){const t=Oe("useWindowScroll"),n=Oe("topItemsIndexes").length>0,r=Oe("customScrollParent"),o=Oe("context");return u.jsxs(r||t?dT:uT,{...e,context:o,children:[n&&u.jsx(aT,{children:u.jsx(ch,{showTopList:!0})}),u.jsxs(r||t?iT:sT,{children:[u.jsx(rT,{}),u.jsx(ch,{}),u.jsx(oT,{})]})]})}),{Component:cT,useEmitter:fl,useEmitterValue:Oe,usePublisher:en}=nh(YC,{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"}},lT),uT=uh({useEmitter:fl,useEmitterValue:Oe,usePublisher:en}),dT=dh({useEmitter:fl,useEmitterValue:Oe,usePublisher:en}),fT=cT;ut(th,Qe(()=>{const e=se(c=>u.jsxs("td",{children:["Item $",c]})),t=se(null),n=se(c=>u.jsxs("td",{colSpan:1e3,children:["Group ",c]})),r=se(null),o=se(null),s=se({}),i=se(dl),a=se(Ar),l=(c,d=null)=>_t(ee(s,me(p=>p[c]),dt()),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")}})),ul();const fh={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},pT={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:ph,floor:Fs,max:vo,min:pl,round:hh}=Math;function mh(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function hT(e){return{...pT,items:e}}function Bs(e,t){return e&&e.width===t.width&&e.height===t.height}function mT(e,t){return e&&e.column===t.column&&e.row===t.row}const gT=Qe(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:r},{footerHeight:o,headerHeight:s,scrollBy:i,scrollContainerState:a,scrollTo:l,scrollTop:c,smoothScrollTargetReached:d,viewportHeight:p},m,f,{didMount:v,propsReady:g},{customScrollParent:x,useWindowScroll:y,windowScrollContainerState:w,windowScrollTo:S,windowViewportRect:k},C])=>{const T=se(0),E=se(0),A=se(fh),O=se({height:0,width:0}),F=se({height:0,width:0}),U=Je(),W=Je(),z=se(0),N=se(null),K=se({column:0,row:0}),M=Je(),Q=Je(),$=se(!1),_=se(0),V=se(!0),J=se(!1),j=se(!1);rt(ee(v,Ve(_),Pe(([D,X])=>!!X)),()=>{ze(V,!1)}),rt(ee(Ct(v,V,F,O,_,J),Pe(([D,X,Z,ce,,L])=>D&&!X&&Z.height!==0&&ce.height!==0&&!L)),([,,,,D])=>{ze(J,!0),rl(1,()=>{ze(U,D)}),un(ee(c),()=>{ze(t,[0,0]),ze(V,!0)})}),Ce(ee(Q,Pe(D=>D!=null&&D.scrollTop>0),Sn(0)),E),rt(ee(v,Ve(Q),Pe(([,D])=>D!=null)),([,D])=>{D&&(ze(O,D.viewport),ze(F,D.item),ze(K,D.gap),D.scrollTop>0&&(ze($,!0),un(ee(c,tr(1)),X=>{ze($,!1)}),ze(l,{top:D.scrollTop})))}),Ce(ee(O,me(({height:D})=>D)),p),Ce(ee(Ct(_e(O,Bs),_e(F,Bs),_e(K,(D,X)=>D&&D.column===X.column&&D.row===X.row),_e(c)),me(([D,X,Z,ce])=>({gap:Z,item:X,scrollTop:ce,viewport:D}))),M),Ce(ee(Ct(_e(T),r,_e(K,mT),_e(F,Bs),_e(O,Bs),_e(N),_e(E),_e($),_e(V),_e(_)),Pe(([,,,,,,,D])=>!D),me(([D,[X,Z],ce,L,oe,xe,de,,we,Me])=>{const{column:He,row:$e}=ce,{height:Ae,width:Fe}=L,{width:Ge}=oe;if(de===0&&(D===0||Ge===0))return fh;if(Fe===0){const Re=ol(Me,D),mt=Re+Math.max(de-1,0);return hT(mh(Re,mt,xe))}const Ke=gh(Ge,Fe,He);let Xe,tt;we?X===0&&Z===0&&de>0?(Xe=0,tt=de-1):(Xe=Ke*Fs((X+$e)/(Ae+$e)),tt=Ke*ph((Z+$e)/(Ae+$e))-1,tt=pl(D-1,vo(tt,Ke-1)),Xe=pl(tt,vo(0,Xe))):(Xe=0,tt=-1);const nt=mh(Xe,tt,xe),{bottom:Ze,top:pt}=xh(oe,ce,L,nt),ht=ph(D/Ke),Se=ht*Ae+(ht-1)*$e-Ze;return{bottom:Ze,itemHeight:Ae,items:nt,itemWidth:Fe,offsetBottom:Se,offsetTop:pt,top:pt}})),A),Ce(ee(N,Pe(D=>D!==null),me(D=>D.length)),T),Ce(ee(Ct(O,F,A,K),Pe(([D,X,{items:Z}])=>Z.length>0&&X.height!==0&&D.height!==0),me(([D,X,{items:Z},ce])=>{const{bottom:L,top:oe}=xh(D,ce,X,Z);return[oe,L]}),dt(uo)),t);const R=se(!1);Ce(ee(c,Ve(R),me(([D,X])=>X||D!==0)),R);const G=Xt(ee(Ct(A,T),Pe(([{items:D}])=>D.length>0),Ve(R),Pe(([[D,X],Z])=>{const ce=D.items[D.items.length-1].index===X-1;return(Z||D.bottom>0&&D.itemHeight>0&&D.offsetBottom===0&&D.items.length===X)&&ce}),me(([[,D]])=>D-1),dt())),Y=Xt(ee(_e(A),Pe(({items:D})=>D.length>0&&D[0].index===0),Sn(0),dt())),ie=Xt(ee(_e(A),Ve($),Pe(([{items:D},X])=>D.length>0&&!X),me(([{items:D}])=>({endIndex:D[D.length-1].index,startIndex:D[0].index})),dt(Dp),In(0)));Ce(ie,f.scrollSeekRangeChanged),Ce(ee(U,Ve(O,F,T,K),me(([D,X,Z,ce,L])=>{const oe=Hp(D),{align:xe,behavior:de,offset:we}=oe;let Me=oe.index;Me==="LAST"&&(Me=ce-1),Me=vo(0,Me,pl(ce-1,Me));let He=hl(X,L,Z,Me);return xe==="end"?He=hh(He-X.height+Z.height):xe==="center"&&(He=hh(He-X.height/2+Z.height/2)),we&&(He+=we),{behavior:de,top:He}})),l);const H=_t(ee(A,me(D=>D.offsetBottom+D.bottom)),0);return Ce(ee(k,me(D=>({height:D.visibleHeight,width:D.visibleWidth}))),O),{customScrollParent:x,data:N,deviation:z,footerHeight:o,gap:K,headerHeight:s,increaseViewportBy:e,initialItemCount:E,itemDimensions:F,overscan:n,restoreStateFrom:Q,scrollBy:i,scrollContainerState:a,scrollHeight:W,scrollTo:l,scrollToIndex:U,scrollTop:c,smoothScrollTargetReached:d,totalCount:T,useWindowScroll:y,viewportDimensions:O,windowScrollContainerState:w,windowScrollTo:S,windowViewportRect:k,...f,gridState:A,horizontalDirection:j,initialTopMostItemIndex:_,totalListHeight:H,...m,endReached:G,propsReady:g,rangeChanged:ie,startReached:Y,stateChanged:M,stateRestoreInProgress:$,...C}},ut(sl,Dt,xo,Qp,Bn,al,$n));function gh(e,t,n){return vo(1,Fs((e+n)/(Fs(t)+n)))}function xh(e,t,n,r){const{height:o}=n;if(o===void 0||r.length===0)return{bottom:0,top:0};const s=hl(e,t,n,r[0].index);return{bottom:hl(e,t,n,r[r.length-1].index)+o,top:s}}function hl(e,t,n,r){const o=gh(e.width,n.width,t.column),s=Fs(r/o),i=s*n.height+vo(0,s-1)*t.row;return i>0?i+t.row:i}const xT=Qe(()=>{const e=se(p=>`Item ${p}`),t=se({}),n=se(null),r=se("virtuoso-grid-item"),o=se("virtuoso-grid-list"),s=se(dl),i=se("div"),a=se(Ar),l=(p,m=null)=>_t(ee(t,me(f=>f[p]),dt()),m),c=se(!1),d=se(!1);return Ce(_e(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")}}),vT=Qe(([e,t])=>({...e,...t}),ut(gT,xT)),wT=b.memo(function(){const e=ft("gridState"),t=ft("listClassName"),n=ft("itemClassName"),r=ft("itemContent"),o=ft("computeItemKey"),s=ft("isSeeking"),i=tn("scrollHeight"),a=ft("ItemComponent"),l=ft("ListComponent"),c=ft("ScrollSeekPlaceholder"),d=ft("context"),p=tn("itemDimensions"),m=tn("gap"),f=ft("log"),v=ft("stateRestoreInProgress"),g=tn("reportReadyState"),x=nr(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:wh("column-gap",getComputedStyle(y).columnGap,f),row:wh("row-gap",getComputedStyle(y).rowGap,f)})},[i,p,m,f]),!0,!1);return sh(()=>{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))})})}),bT=b.memo(function(){const e=ft("HeaderComponent"),t=tn("headerHeight"),n=ft("headerFooterTag"),r=nr(b.useMemo(()=>s=>{t(Fn(s,"height"))},[t]),!0,!1),o=ft("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...jt(e,o)})}):null}),yT=b.memo(function(){const e=ft("FooterComponent"),t=tn("footerHeight"),n=ft("headerFooterTag"),r=nr(b.useMemo(()=>s=>{t(Fn(s,"height"))},[t]),!0,!1),o=ft("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...jt(e,o)})}):null}),ST=({children:e})=>{const t=b.useContext(oh),n=tn("itemDimensions"),r=tn("viewportDimensions"),o=nr(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:$s(!1),children:e})},CT=({children:e})=>{const t=b.useContext(oh),n=tn("windowViewportRect"),r=tn("itemDimensions"),o=ft("customScrollParent"),s=Ap(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:$s(!1),children:e})},TT=b.memo(function({...e}){const t=ft("useWindowScroll"),n=ft("customScrollParent"),r=n||t?ET:kT,o=n||t?CT:ST,s=ft("context");return u.jsx(r,{...e,...jt(r,s),children:u.jsxs(o,{children:[u.jsx(bT,{}),u.jsx(wT,{}),u.jsx(yT,{})]})})}),{useEmitter:vh,useEmitterValue:ft,usePublisher:tn}=nh(vT,{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"}},TT),kT=uh({useEmitter:vh,useEmitterValue:ft,usePublisher:tn}),ET=dh({useEmitter:vh,useEmitterValue:ft,usePublisher:tn});function wh(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,zt.WARN),t==="normal"?0:parseInt(t??"0",10)}const IT=Or.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 bh({className:e,variant:t,...n}){return u.jsx("div",{className:re(IT({variant:t}),e),...n})}const NT=1,AT=1e6;let ml=0;function _T(){return ml=(ml+1)%Number.MAX_SAFE_INTEGER,ml.toString()}const gl=new Map,yh=e=>{if(gl.has(e))return;const t=setTimeout(()=>{gl.delete(e),wo({type:"REMOVE_TOAST",toastId:e})},AT);gl.set(e,t)},jT=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,NT)};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?yh(n):e.toasts.forEach(r=>{yh(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)}}},zs=[];let Hs={toasts:[]};function wo(e){Hs=jT(Hs,e),zs.forEach(t=>{t(Hs)})}function PT({...e}){const t=_T(),n=o=>wo({type:"UPDATE_TOAST",toast:{...o,id:t}}),r=()=>wo({type:"DISMISS_TOAST",toastId:t});return wo({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:o=>{o||r()}}}),{id:t,dismiss:r,update:n}}function xl(){const[e,t]=h.useState(Hs);return h.useEffect(()=>(zs.push(t),()=>{const n=zs.indexOf(t);n>-1&&zs.splice(n,1)}),[e]),{...e,toast:PT,dismiss:n=>wo({type:"DISMISS_TOAST",toastId:n})}}function Sh({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}=xl(),m=b.useCallback(async()=>{if(n){i(!0),d(null),l(null);try{const y=await Ti(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 Yc(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 Ti(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(fe.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(ct,{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(fe.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(fe.Image,{className:"h-5 w-5"}):u.jsx(fe.FileText,{className:"h-5 w-5"});return u.jsx(ra,{open:e,onOpenChange:t,children:u.jsxs(ns,{className:"max-w-4xl max-h-[90vh] overflow-hidden",children:[u.jsx(rs,{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(os,{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(ct,{variant:"outline",size:"sm",onClick:v,className:"flex items-center gap-2",children:[u.jsx(fe.ExternalLink,{className:"h-4 w-4"}),"External"]}),u.jsxs(ct,{variant:"outline",size:"sm",onClick:f,className:"flex items-center gap-2",children:[u.jsx(fe.Download,{className:"h-4 w-4"}),"Download"]})]})]})}),u.jsx("div",{className:"flex-1 overflow-hidden",children:g()})]})})}function Ch(){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 sr=Ch();function MT(e){sr=e}const Th=/[&<>"']/,RT=new RegExp(Th.source,"g"),kh=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,OT=new RegExp(kh.source,"g"),DT={"&":"&","<":"<",">":">",'"':""","'":"'"},Eh=e=>DT[e];function Pt(e,t){if(t){if(Th.test(e))return e.replace(RT,Eh)}else if(kh.test(e))return e.replace(OT,Eh);return e}const LT=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function Ih(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 $T=/(^|[^\[])\^/g;function at(e,t){e=typeof e=="string"?e:e.source,t=t||"";const n={replace:(r,o)=>(o=o.source||o,o=o.replace($T,"$1"),e=e.replace(r,o),n),getRegex:()=>new RegExp(e,t)};return n}const FT=/[^\w:]/g,BT=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function Nh(e,t,n){if(e){let r;try{r=decodeURIComponent(Ih(n)).replace(FT,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}t&&!BT.test(n)&&(n=WT(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const Us={},zT=/^[^:]+:\/*[^/]*$/,HT=/^([^:]+:)[\s\S]*$/,UT=/^([^:]+:\/*[^/]*)[\s\S]*$/;function WT(e,t){Us[" "+e]||(zT.test(e)?Us[" "+e]=e+"/":Us[" "+e]=Vs(e,"/",!0)),e=Us[" "+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(UT,"$1")+t:e+t}const Ws={exec:function(){}};function Ah(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 Vs(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 VT(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 KT(e){e&&e.sanitize&&!e.silent&&console.warn("marked(): sanitize and sanitizer parameters are deprecated since version 0.7.0, should not be used and will be removed in the future. Read more here: https://marked.js.org/#/USING_ADVANCED.md#options")}function _h(e,t){if(t<1)return"";let n="";for(;t>1;)t&1&&(n+=e),t>>=1,e+=e;return n+e}function jh(e,t,n,r){const o=t.href,s=t.title?Pt(t.title):null,i=e[1].replace(/\\([\[\]])/g,"$1");if(e[0].charAt(0)!=="!"){r.state.inLink=!0;const a={type:"link",raw:n,href:o,title:s,text:i,tokens:r.inlineTokens(i)};return r.state.inLink=!1,a}return{type:"image",raw:n,href:o,title:s,text:Pt(i)}}function qT(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},Tb="DialogDescriptionWarning",kb=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${fd(Tb).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},Qi=Zu,Eb=ed,ea=nd,Gr=rd,Yr=od,Xn=id,ns=ld,pd=ud,Xr='[cmdk-group=""]',ta='[cmdk-group-items=""]',Ib='[cmdk-group-heading=""]',hd='[cmdk-item=""]',md=`${hd}:not([aria-disabled="true"])`,na="cmdk-item-select",br="data-value",Nb=(e,t,n)=>rw(e,t,n),gd=h.createContext(void 0),Jr=()=>h.useContext(gd),xd=h.createContext(void 0),ra=()=>h.useContext(xd),vd=h.createContext(void 0),wd=h.forwardRef((e,t)=>{let n=yr(()=>{var j,R;return{search:"",value:(R=(j=e.value)!=null?j:e.defaultValue)!=null?R:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=yr(()=>new Set),o=yr(()=>new Map),s=yr(()=>new Map),i=yr(()=>new Set),a=bd(e),{label:l,children:c,value:d,onValueChange:p,filter:m,shouldFilter:f,loop:v,disablePointerSelection:g=!1,vimBindings:x=!0,...y}=e,w=At(),S=At(),k=At(),C=h.useRef(null),T=Fb();Jn(()=>{if(d!==void 0){let j=d.trim();n.current.value=j,E.emit()}},[d]),Jn(()=>{T(6,z)},[]);let E=h.useMemo(()=>({subscribe:j=>(i.current.add(j),()=>i.current.delete(j)),snapshot:()=>n.current,setState:(j,R,G)=>{var Y,ie,H,D;if(!Object.is(n.current[j],R)){if(n.current[j]=R,j==="search")W(),F(),T(1,U);else if(j==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let X=document.getElementById(k);X?X.focus():(Y=document.getElementById(w))==null||Y.focus()}if(T(7,()=>{var X;n.current.selectedItemId=(X=N())==null?void 0:X.id,E.emit()}),G||T(5,z),((ie=a.current)==null?void 0:ie.value)!==void 0){let X=R??"";(D=(H=a.current).onValueChange)==null||D.call(H,X);return}}E.emit()}},emit:()=>{i.current.forEach(j=>j())}}),[]),A=h.useMemo(()=>({value:(j,R,G)=>{var Y;R!==((Y=s.current.get(j))==null?void 0:Y.value)&&(s.current.set(j,{value:R,keywords:G}),n.current.filtered.items.set(j,O(R,G)),T(2,()=>{F(),E.emit()}))},item:(j,R)=>(r.current.add(j),R&&(o.current.has(R)?o.current.get(R).add(j):o.current.set(R,new Set([j]))),T(3,()=>{W(),F(),n.current.value||U(),E.emit()}),()=>{s.current.delete(j),r.current.delete(j),n.current.filtered.items.delete(j);let G=N();T(4,()=>{W(),(G==null?void 0:G.getAttribute("id"))===j&&U(),E.emit()})}),group:j=>(o.current.has(j)||o.current.set(j,new Set),()=>{s.current.delete(j),o.current.delete(j)}),filter:()=>a.current.shouldFilter,label:l||e["aria-label"],getDisablePointerSelection:()=>a.current.disablePointerSelection,listId:w,inputId:k,labelId:S,listInnerRef:C}),[]);function O(j,R){var G,Y;let ie=(Y=(G=a.current)==null?void 0:G.filter)!=null?Y:Nb;return j?ie(j,n.current.search,R):0}function F(){if(!n.current.search||a.current.shouldFilter===!1)return;let j=n.current.filtered.items,R=[];n.current.filtered.groups.forEach(Y=>{let ie=o.current.get(Y),H=0;ie.forEach(D=>{let X=j.get(D);H=Math.max(X,H)}),R.push([Y,H])});let G=C.current;q().sort((Y,ie)=>{var H,D;let X=Y.getAttribute("id"),Z=ie.getAttribute("id");return((H=j.get(Z))!=null?H:0)-((D=j.get(X))!=null?D:0)}).forEach(Y=>{let ie=Y.closest(ta);ie?ie.appendChild(Y.parentElement===ie?Y:Y.closest(`${ta} > *`)):G.appendChild(Y.parentElement===G?Y:Y.closest(`${ta} > *`))}),R.sort((Y,ie)=>ie[1]-Y[1]).forEach(Y=>{var ie;let H=(ie=C.current)==null?void 0:ie.querySelector(`${Xr}[${br}="${encodeURIComponent(Y[0])}"]`);H==null||H.parentElement.appendChild(H)})}function U(){let j=q().find(G=>G.getAttribute("aria-disabled")!=="true"),R=j==null?void 0:j.getAttribute(br);E.setState("value",R||void 0)}function W(){var j,R,G,Y;if(!n.current.search||a.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let ie=0;for(let H of r.current){let D=(R=(j=s.current.get(H))==null?void 0:j.value)!=null?R:"",X=(Y=(G=s.current.get(H))==null?void 0:G.keywords)!=null?Y:[],Z=O(D,X);n.current.filtered.items.set(H,Z),Z>0&&ie++}for(let[H,D]of o.current)for(let X of D)if(n.current.filtered.items.get(X)>0){n.current.filtered.groups.add(H);break}n.current.filtered.count=ie}function z(){var j,R,G;let Y=N();Y&&(((j=Y.parentElement)==null?void 0:j.firstChild)===Y&&((G=(R=Y.closest(Xr))==null?void 0:R.querySelector(Ib))==null||G.scrollIntoView({block:"nearest"})),Y.scrollIntoView({block:"nearest"}))}function N(){var j;return(j=C.current)==null?void 0:j.querySelector(`${hd}[aria-selected="true"]`)}function q(){var j;return Array.from(((j=C.current)==null?void 0:j.querySelectorAll(md))||[])}function M(j){let R=q()[j];R&&E.setState("value",R.getAttribute(br))}function Q(j){var R;let G=N(),Y=q(),ie=Y.findIndex(D=>D===G),H=Y[ie+j];(R=a.current)!=null&&R.loop&&(H=ie+j<0?Y[Y.length-1]:ie+j===Y.length?Y[0]:Y[ie+j]),H&&E.setState("value",H.getAttribute(br))}function $(j){let R=N(),G=R==null?void 0:R.closest(Xr),Y;for(;G&&!Y;)G=j>0?Lb(G,Xr):$b(G,Xr),Y=G==null?void 0:G.querySelector(md);Y?E.setState("value",Y.getAttribute(br)):Q(j)}let _=()=>M(q().length-1),V=j=>{j.preventDefault(),j.metaKey?_():j.altKey?$(1):Q(1)},J=j=>{j.preventDefault(),j.metaKey?M(0):j.altKey?$(-1):Q(-1)};return h.createElement(ye.div,{ref:t,tabIndex:-1,...y,"cmdk-root":"",onKeyDown:j=>{var R;(R=y.onKeyDown)==null||R.call(y,j);let G=j.nativeEvent.isComposing||j.keyCode===229;if(!(j.defaultPrevented||G))switch(j.key){case"n":case"j":{x&&j.ctrlKey&&V(j);break}case"ArrowDown":{V(j);break}case"p":case"k":{x&&j.ctrlKey&&J(j);break}case"ArrowUp":{J(j);break}case"Home":{j.preventDefault(),M(0);break}case"End":{j.preventDefault(),_();break}case"Enter":{j.preventDefault();let Y=N();if(Y){let ie=new Event(na);Y.dispatchEvent(ie)}}}}},h.createElement("label",{"cmdk-label":"",htmlFor:A.inputId,id:A.labelId,style:zb},l),rs(e,j=>h.createElement(xd.Provider,{value:E},h.createElement(gd.Provider,{value:A},j))))}),Ab=h.forwardRef((e,t)=>{var n,r;let o=At(),s=h.useRef(null),i=h.useContext(vd),a=Jr(),l=bd(e),c=(r=(n=l.current)==null?void 0:n.forceMount)!=null?r:i==null?void 0:i.forceMount;Jn(()=>{if(!c)return a.item(o,i==null?void 0:i.id)},[c]);let d=yd(o,s,[e.value,e.children,s],e.keywords),p=ra(),m=Mn(T=>T.value&&T.value===d.current),f=Mn(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(na,v),()=>T.removeEventListener(na,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(ye.div,{ref:_n(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)}),_b=h.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:o,...s}=e,i=At(),a=h.useRef(null),l=h.useRef(null),c=At(),d=Jr(),p=Mn(f=>o||d.filter()===!1?!0:f.search?f.filtered.groups.has(i):!0);Jn(()=>d.group(i),[]),yd(i,a,[e.value,e.heading,l]);let m=h.useMemo(()=>({id:i,forceMount:o}),[o]);return h.createElement(ye.div,{ref:_n(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),rs(e,f=>h.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?c:void 0},h.createElement(vd.Provider,{value:m},f))))}),jb=h.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,o=h.useRef(null),s=Mn(i=>!i.search);return!n&&!s?null:h.createElement(ye.div,{ref:_n(o,t),...r,"cmdk-separator":"",role:"separator"})}),Pb=h.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,o=e.value!=null,s=ra(),i=Mn(c=>c.search),a=Mn(c=>c.selectedItemId),l=Jr();return h.useEffect(()=>{e.value!=null&&s.setState("search",e.value)},[e.value]),h.createElement(ye.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)}})}),Mb=h.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...o}=e,s=h.useRef(null),i=h.useRef(null),a=Mn(c=>c.selectedItemId),l=Jr();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(ye.div,{ref:_n(s,t),...o,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":a,"aria-label":r,id:l.listId},rs(e,c=>h.createElement("div",{ref:_n(i,l.listInnerRef),"cmdk-list-sizer":""},c)))}),Rb=h.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:o,contentClassName:s,container:i,...a}=e;return h.createElement(Qi,{open:n,onOpenChange:r},h.createElement(ea,{container:i},h.createElement(Gr,{"cmdk-overlay":"",className:o}),h.createElement(Yr,{"aria-label":e.label,"cmdk-dialog":"",className:s},h.createElement(wd,{ref:t,...a}))))}),Ob=h.forwardRef((e,t)=>Mn(n=>n.filtered.count===0)?h.createElement(ye.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),Db=h.forwardRef((e,t)=>{let{progress:n,children:r,label:o="Loading...",...s}=e;return h.createElement(ye.div,{ref:t,...s,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":o},rs(e,i=>h.createElement("div",{"aria-hidden":!0},i)))}),Bt=Object.assign(wd,{List:Mb,Item:Ab,Input:Pb,Group:_b,Separator:jb,Dialog:Rb,Empty:Ob,Loading:Db});function Lb(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function $b(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function bd(e){let t=h.useRef(e);return Jn(()=>{t.current=e}),t}var Jn=typeof window>"u"?h.useEffect:h.useLayoutEffect;function yr(e){let t=h.useRef();return t.current===void 0&&(t.current=e()),t}function Mn(e){let t=ra(),n=()=>e(t.snapshot());return h.useSyncExternalStore(t.subscribe,n,n)}function yd(e,t,n,r=[]){let o=h.useRef(),s=Jr();return Jn(()=>{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(br,a),o.current=a}),o}var Fb=()=>{let[e,t]=h.useState(),n=yr(()=>new Map);return Jn(()=>{n.current.forEach(r=>r()),n.current=new Map},[e]),(r,o)=>{n.current.set(r,o),t({})}};function Bb(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function rs({asChild:e,children:t},n){return e&&h.isValidElement(t)?h.cloneElement(Bb(t),{ref:t.ref},n(t.props.children)):n(t)}var zb={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const oa=Qi,Hb=ea,Sd=h.forwardRef(({className:e,...t},n)=>u.jsx(Gr,{ref:n,className:re("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}));Sd.displayName=Gr.displayName;const os=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===Xn||(c==null?void 0:c.displayName)===Xn.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(Hb,{children:[u.jsx(Sd,{}),u.jsxs(Yr,{ref:r,className:re("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(Xn,{className:"sr-only",children:"Dialog"}),t,u.jsxs(pd,{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(fe.X,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]})});os.displayName=Yr.displayName;const ss=({className:e,...t})=>u.jsx("div",{className:re("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});ss.displayName="DialogHeader";const is=h.forwardRef(({className:e,...t},n)=>u.jsx(Xn,{ref:n,className:re("text-lg font-semibold leading-none tracking-tight",e),...t}));is.displayName=Xn.displayName;const Ub=h.forwardRef(({className:e,...t},n)=>u.jsx(ns,{ref:n,className:re("text-sm text-muted-foreground",e),...t}));Ub.displayName=ns.displayName;const sa=h.forwardRef(({className:e,...t},n)=>u.jsx(Bt,{ref:n,className:re("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));sa.displayName=Bt.displayName;const ia=h.forwardRef(({className:e,...t},n)=>u.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[u.jsx(fe.Search,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),u.jsx(Bt.Input,{ref:n,className:re("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})]}));ia.displayName=Bt.Input.displayName;const aa=h.forwardRef(({className:e,...t},n)=>u.jsx(Bt.List,{ref:n,className:re("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));aa.displayName=Bt.List.displayName;const la=h.forwardRef((e,t)=>u.jsx(Bt.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));la.displayName=Bt.Empty.displayName;const ca=h.forwardRef(({className:e,...t},n)=>u.jsx(Bt.Group,{ref:n,className:re("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}));ca.displayName=Bt.Group.displayName;const Wb=h.forwardRef(({className:e,...t},n)=>u.jsx(Bt.Separator,{ref:n,className:re("-mx-1 h-px bg-border",e),...t}));Wb.displayName=Bt.Separator.displayName;const ua=h.forwardRef(({className:e,...t},n)=>u.jsx(Bt.Item,{ref:n,className:re("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}));ua.displayName=Bt.Item.displayName;function as(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=We(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=We(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 Vb=h.createContext(void 0);function ls(e){const t=h.useContext(Vb);return e||t||"ltr"}const Kb=["top","right","bottom","left"],Rn=Math.min,Gt=Math.max,cs=Math.round,us=Math.floor,xn=e=>({x:e,y:e}),qb={left:"right",right:"left",bottom:"top",top:"bottom"},Gb={start:"end",end:"start"};function da(e,t,n){return Gt(e,Rn(t,n))}function kn(e,t){return typeof e=="function"?e(t):e}function En(e){return e.split("-")[0]}function Sr(e){return e.split("-")[1]}function fa(e){return e==="x"?"y":"x"}function pa(e){return e==="y"?"height":"width"}const Yb=new Set(["top","bottom"]);function vn(e){return Yb.has(En(e))?"y":"x"}function ha(e){return fa(vn(e))}function Xb(e,t,n){n===void 0&&(n=!1);const r=Sr(e),o=ha(e),s=pa(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=ds(i)),[i,ds(i)]}function Jb(e){const t=ds(e);return[ma(e),t,ma(t)]}function ma(e){return e.replace(/start|end/g,t=>Gb[t])}const Cd=["left","right"],Td=["right","left"],Zb=["top","bottom"],Qb=["bottom","top"];function ey(e,t,n){switch(e){case"top":case"bottom":return n?t?Td:Cd:t?Cd:Td;case"left":case"right":return t?Zb:Qb;default:return[]}}function ty(e,t,n,r){const o=Sr(e);let s=ey(En(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(ma)))),s}function ds(e){return e.replace(/left|right|bottom|top/g,t=>qb[t])}function ny(e){return{top:0,right:0,bottom:0,left:0,...e}}function kd(e){return typeof e!="number"?ny(e):{top:e,right:e,bottom:e,left:e}}function fs(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}function Ed(e,t,n){let{reference:r,floating:o}=e;const s=vn(t),i=ha(t),a=pa(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(Sr(t)){case"start":f[i]-=m*(n&&c?-1:1);break;case"end":f[i]+=m*(n&&c?-1:1);break}return f}const ry=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}=Ed(c,r,l),m=r,f={},v=0;for(let g=0;g<a.length;g++){const{name:x,fn:y}=a[g],{x: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}=Ed(c,m,l)),g=-1)}return{x:d,y:p,placement:m,strategy:o,middlewareData:f}};async function Zr(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=kd(f),x=a[m?p==="floating"?"reference":"floating":p],y=fs(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=fs(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 oy=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=kd(d),m={x:n,y:r},f=ha(o),v=pa(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 A=k/2-C/2,O=E/2-g[v]/2-1,F=Rn(p[y],O),U=Rn(p[w],O),W=F,z=E-g[v]-U,N=E/2-g[v]/2+A,q=da(W,N,z),M=!l.arrow&&Sr(o)!=null&&N!==q&&s.reference[v]/2-(N<W?F:U)-g[v]/2<0,Q=M?N<W?N-W:N-z:0;return{[f]:m[f]+Q,data:{[f]:q,centerOffset:N-q-Q,...M&&{alignmentOffset:Q}},reset:M}}}),sy=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=vn(a),S=En(a)===a,k=await(l.isRTL==null?void 0:l.isRTL(c.floating)),C=m||(S||!g?[ds(a)]:Jb(a)),T=v!=="none";!m&&T&&C.push(...ty(a,g,v,k));const E=[a,...C],A=await Zr(t,x),O=[];let F=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&O.push(A[y]),p){const N=Xb(o,i,k);O.push(A[N[0]],A[N[1]])}if(F=[...F,{placement:o,overflows:O}],!O.every(N=>N<=0)){var U,W;const N=(((U=s.flip)==null?void 0:U.index)||0)+1,q=E[N];if(q&&(!(p==="alignment"?w!==vn(q):!1)||F.every($=>vn($.placement)===w?$.overflows[0]>0:!0)))return{data:{index:N,overflows:F},reset:{placement:q}};let M=(W=F.filter(Q=>Q.overflows[0]<=0).sort((Q,$)=>Q.overflows[1]-$.overflows[1])[0])==null?void 0:W.placement;if(!M)switch(f){case"bestFit":{var z;const Q=(z=F.filter($=>{if(T){const _=vn($.placement);return _===w||_==="y"}return!0}).map($=>[$.placement,$.overflows.filter(_=>_>0).reduce((_,V)=>_+V,0)]).sort(($,_)=>$[1]-_[1])[0])==null?void 0:z[0];Q&&(M=Q);break}case"initialPlacement":M=a;break}if(o!==M)return{reset:{placement:M}}}return{}}}};function Id(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Nd(e){return Kb.some(t=>e[t]>=0)}const iy=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 Zr(t,{...o,elementContext:"reference"}),i=Id(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:Nd(i)}}}case"escaped":{const s=await Zr(t,{...o,altBoundary:!0}),i=Id(s,n.floating);return{data:{escapedOffsets:i,escaped:Nd(i)}}}default:return{}}}}},Ad=new Set(["left","top"]);async function ay(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=Sr(n),l=vn(n)==="y",c=Ad.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 ly=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 ay(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}}}}},cy=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 Zr(t,l),p=vn(En(o)),m=fa(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=da(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=da(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}}}}}},uy=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=vn(o),m=fa(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=Ad.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}}}},dy=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 Zr(t,c),p=En(o),m=Sr(o),f=vn(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=Rn(g-d[x],w),C=Rn(v-d[y],S),T=!t.middlewareData.shift;let E=k,A=C;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(A=S),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(E=w),T&&!m){const F=Gt(d.left,0),U=Gt(d.right,0),W=Gt(d.top,0),z=Gt(d.bottom,0);f?A=v-2*(F!==0||U!==0?F+U:Gt(d.left,d.right)):E=g-2*(W!==0||z!==0?W+z:Gt(d.top,d.bottom))}await l({...t,availableWidth:A,availableHeight:E});const O=await i.getDimensions(a.floating);return v!==O.width||g!==O.height?{reset:{rects:!0}}:{}}}};function ps(){return typeof window<"u"}function Cr(e){return _d(e)?(e.nodeName||"").toLowerCase():"#document"}function Yt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function wn(e){var t;return(t=(_d(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function _d(e){return ps()?e instanceof Node||e instanceof Yt(e).Node:!1}function ln(e){return ps()?e instanceof Element||e instanceof Yt(e).Element:!1}function bn(e){return ps()?e instanceof HTMLElement||e instanceof Yt(e).HTMLElement:!1}function jd(e){return!ps()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Yt(e).ShadowRoot}const fy=new Set(["inline","contents"]);function Qr(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=cn(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!fy.has(o)}const py=new Set(["table","td","th"]);function hy(e){return py.has(Cr(e))}const my=[":popover-open",":modal"];function hs(e){return my.some(t=>{try{return e.matches(t)}catch{return!1}})}const gy=["transform","translate","scale","rotate","perspective"],xy=["transform","translate","scale","rotate","perspective","filter"],vy=["paint","layout","strict","content"];function ga(e){const t=xa(),n=ln(e)?cn(e):e;return gy.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)||xy.some(r=>(n.willChange||"").includes(r))||vy.some(r=>(n.contain||"").includes(r))}function wy(e){let t=On(e);for(;bn(t)&&!Tr(t);){if(ga(t))return t;if(hs(t))return null;t=On(t)}return null}function xa(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const by=new Set(["html","body","#document"]);function Tr(e){return by.has(Cr(e))}function cn(e){return Yt(e).getComputedStyle(e)}function ms(e){return ln(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function On(e){if(Cr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||jd(e)&&e.host||wn(e);return jd(t)?t.host:t}function Pd(e){const t=On(e);return Tr(t)?e.ownerDocument?e.ownerDocument.body:e.body:bn(t)&&Qr(t)?t:Pd(t)}function eo(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=Pd(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Yt(o);if(s){const a=va(i);return t.concat(i,i.visualViewport||[],Qr(o)?o:[],a&&n?eo(a):[])}return t.concat(o,eo(o,[],n))}function va(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Md(e){const t=cn(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=bn(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=cs(n)!==s||cs(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function wa(e){return ln(e)?e:e.contextElement}function kr(e){const t=wa(e);if(!bn(t))return xn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=Md(t);let i=(s?cs(n.width):n.width)/r,a=(s?cs(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const yy=xn(0);function Rd(e){const t=Yt(e);return!xa()||!t.visualViewport?yy:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Sy(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Yt(e)?!1:t}function Zn(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=wa(e);let i=xn(1);t&&(r?ln(r)&&(i=kr(r)):i=kr(e));const a=Sy(s,n,r)?Rd(s):xn(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&&ln(r)?Yt(r):r;let v=m,g=va(v);for(;g&&r&&f!==v;){const x=kr(g),y=g.getBoundingClientRect(),w=cn(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=va(v)}}return fs({width:d,height:p,x:l,y:c})}function gs(e,t){const n=ms(e).scrollLeft;return t?t.left+n:Zn(wn(e)).left+n}function Od(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-gs(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function Cy(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=wn(r),a=t?hs(t.floating):!1;if(r===i||a&&s)return n;let l={scrollLeft:0,scrollTop:0},c=xn(1);const d=xn(0),p=bn(r);if((p||!p&&!s)&&((Cr(r)!=="body"||Qr(i))&&(l=ms(r)),bn(r))){const f=Zn(r);c=kr(r),d.x=f.x+r.clientLeft,d.y=f.y+r.clientTop}const m=i&&!p&&!s?Od(i,l):xn(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 Ty(e){return Array.from(e.getClientRects())}function ky(e){const t=wn(e),n=ms(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+gs(e);const a=-n.scrollTop;return cn(r).direction==="rtl"&&(i+=Gt(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const Dd=25;function Ey(e,t){const n=Yt(e),r=wn(e),o=n.visualViewport;let s=r.clientWidth,i=r.clientHeight,a=0,l=0;if(o){s=o.width,i=o.height;const d=xa();(!d||d&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}const c=gs(r);if(c<=0){const d=r.ownerDocument,p=d.body,m=getComputedStyle(p),f=d.compatMode==="CSS1Compat"&&parseFloat(m.marginLeft)+parseFloat(m.marginRight)||0,v=Math.abs(r.clientWidth-p.clientWidth-f);v<=Dd&&(s-=v)}else c<=Dd&&(s+=c);return{width:s,height:i,x:a,y:l}}const Iy=new Set(["absolute","fixed"]);function Ny(e,t){const n=Zn(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=bn(e)?kr(e):xn(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 Ld(e,t,n){let r;if(t==="viewport")r=Ey(e,n);else if(t==="document")r=ky(wn(e));else if(ln(t))r=Ny(t,n);else{const o=Rd(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return fs(r)}function $d(e,t){const n=On(e);return n===t||!ln(n)||Tr(n)?!1:cn(n).position==="fixed"||$d(n,t)}function Ay(e,t){const n=t.get(e);if(n)return n;let r=eo(e,[],!1).filter(a=>ln(a)&&Cr(a)!=="body"),o=null;const s=cn(e).position==="fixed";let i=s?On(e):e;for(;ln(i)&&!Tr(i);){const a=cn(i),l=ga(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&Iy.has(o.position)||Qr(i)&&!l&&$d(e,i))?r=r.filter(d=>d!==i):o=a,i=On(i)}return t.set(e,r),r}function _y(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?hs(t)?[]:Ay(t,this._c):[].concat(n),r],a=i[0],l=i.reduce((c,d)=>{const p=Ld(t,d,o);return c.top=Gt(p.top,c.top),c.right=Rn(p.right,c.right),c.bottom=Rn(p.bottom,c.bottom),c.left=Gt(p.left,c.left),c},Ld(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function jy(e){const{width:t,height:n}=Md(e);return{width:t,height:n}}function Py(e,t,n){const r=bn(t),o=wn(t),s=n==="fixed",i=Zn(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=xn(0);function c(){l.x=gs(o)}if(r||!r&&!s)if((Cr(t)!=="body"||Qr(o))&&(a=ms(t)),r){const f=Zn(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?Od(o,a):xn(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 ba(e){return cn(e).position==="static"}function Fd(e,t){if(!bn(e)||cn(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return wn(e)===n&&(n=n.ownerDocument.body),n}function Bd(e,t){const n=Yt(e);if(hs(e))return n;if(!bn(e)){let o=On(e);for(;o&&!Tr(o);){if(ln(o)&&!ba(o))return o;o=On(o)}return n}let r=Fd(e,t);for(;r&&hy(r)&&ba(r);)r=Fd(r,t);return r&&Tr(r)&&ba(r)&&!ga(r)?n:r||wy(e)||n}const My=async function(e){const t=this.getOffsetParent||Bd,n=this.getDimensions,r=await n(e.floating);return{reference:Py(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Ry(e){return cn(e).direction==="rtl"}const Oy={convertOffsetParentRelativeRectToViewportRelativeRect:Cy,getDocumentElement:wn,getClippingRect:_y,getOffsetParent:Bd,getElementRects:My,getClientRects:Ty,getDimensions:jy,getScale:kr,isElement:ln,isRTL:Ry};function zd(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Dy(e,t){let n=null,r;const o=wn(e);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),s();const c=e.getBoundingClientRect(),{left:d,top:p,width:m,height:f}=c;if(a||t(),!m||!f)return;const v=us(p),g=us(o.clientWidth-(d+m)),x=us(o.clientHeight-(p+f)),y=us(d),S={rootMargin:-v+"px "+-g+"px "+-x+"px "+-y+"px",threshold:Gt(0,Rn(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&&!zd(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 Ly(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=wa(e),d=o||s?[...c?eo(c):[],...eo(t)]:[];d.forEach(y=>{o&&y.addEventListener("scroll",n,{passive:!0}),s&&y.addEventListener("resize",n)});const p=c&&a?Dy(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?Zn(e):null;l&&x();function x(){const y=Zn(e);g&&!zd(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 $y=ly,Fy=cy,By=sy,zy=dy,Hy=iy,Hd=oy,Uy=uy,Wy=(e,t,n)=>{const r=new Map,o={platform:Oy,...n},s={...o.platform,_c:r};return ry(e,t,{...o,platform:s})};var Vy=typeof document<"u",Ky=function(){},xs=Vy?b.useLayoutEffect:Ky;function vs(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(!vs(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)&&!vs(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function Ud(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Wd(e,t){const n=Ud(e);return Math.round(t*n)/n}function ya(e){const t=h.useRef(e);return xs(()=>{t.current=e}),t}function qy(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);vs(m,r)||f(r);const[v,g]=h.useState(null),[x,y]=h.useState(null),w=h.useCallback($=>{$!==T.current&&(T.current=$,g($))},[]),S=h.useCallback($=>{$!==E.current&&(E.current=$,y($))},[]),k=s||v,C=i||x,T=h.useRef(null),E=h.useRef(null),A=h.useRef(d),O=l!=null,F=ya(l),U=ya(o),W=ya(c),z=h.useCallback(()=>{if(!T.current||!E.current)return;const $={placement:t,strategy:n,middleware:m};U.current&&($.platform=U.current),Wy(T.current,E.current,$).then(_=>{const V={..._,isPositioned:W.current!==!1};N.current&&!vs(A.current,V)&&(A.current=V,Dr.flushSync(()=>{p(V)}))})},[m,t,n,U,W]);xs(()=>{c===!1&&A.current.isPositioned&&(A.current.isPositioned=!1,p($=>({...$,isPositioned:!1})))},[c]);const N=h.useRef(!1);xs(()=>(N.current=!0,()=>{N.current=!1}),[]),xs(()=>{if(k&&(T.current=k),C&&(E.current=C),k&&C){if(F.current)return F.current(k,C,z);z()}},[k,C,z,F,O]);const q=h.useMemo(()=>({reference:T,floating:E,setReference:w,setFloating:S}),[w,S]),M=h.useMemo(()=>({reference:k,floating:C}),[k,C]),Q=h.useMemo(()=>{const $={position:n,left:0,top:0};if(!M.floating)return $;const _=Wd(M.floating,d.x),V=Wd(M.floating,d.y);return a?{...$,transform:"translate("+_+"px, "+V+"px)",...Ud(M.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:_,top:V}},[n,a,M.floating,d.x,d.y]);return h.useMemo(()=>({...d,update:z,refs:q,elements:M,floatingStyles:Q}),[d,z,q,M,Q])}const Gy=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?Hd({element:r.current,padding:o}).fn(n):{}:r?Hd({element:r,padding:o}).fn(n):{}}}},Yy=(e,t)=>({...$y(e),options:[e,t]}),Xy=(e,t)=>({...Fy(e),options:[e,t]}),Jy=(e,t)=>({...Uy(e),options:[e,t]}),Zy=(e,t)=>({...By(e),options:[e,t]}),Qy=(e,t)=>({...zy(e),options:[e,t]}),e0=(e,t)=>({...Hy(e),options:[e,t]}),t0=(e,t)=>({...Gy(e),options:[e,t]});var n0="Arrow",Vd=h.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return u.jsx(ye.svg,{...s,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:u.jsx("polygon",{points:"0,0 30,0 15,10"})})});Vd.displayName=n0;var r0=Vd;function Kd(e){const[t,n]=h.useState(void 0);return It(()=>{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 Sa="Popper",[qd,Er]=sn(Sa),[o0,Gd]=qd(Sa),Yd=e=>{const{__scopePopper:t,children:n}=e,[r,o]=h.useState(null);return u.jsx(o0,{scope:t,anchor:r,onAnchorChange:o,children:n})};Yd.displayName=Sa;var Xd="PopperAnchor",Jd=h.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=Gd(Xd,n),i=h.useRef(null),a=We(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(ye.div,{...o,ref:a})});Jd.displayName=Xd;var Ca="PopperContent",[s0,i0]=qd(Ca),Zd=h.forwardRef((e,t)=>{var H,D,X,Z,ce,L;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(Ca,n),[y,w]=h.useState(null),S=We(t,oe=>w(oe)),[k,C]=h.useState(null),T=Kd(k),E=(T==null?void 0:T.width)??0,A=(T==null?void 0:T.height)??0,O=r+(s!=="center"?"-"+s:""),F=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},U=Array.isArray(c)?c:[c],W=U.length>0,z={padding:F,boundary:U.filter(l0),altBoundary:W},{refs:N,floatingStyles:q,placement:M,isPositioned:Q,middlewareData:$}=qy({strategy:"fixed",placement:O,whileElementsMounted:(...oe)=>Ly(...oe,{animationFrame:f==="always"}),elements:{reference:x.anchor},middleware:[Yy({mainAxis:o+A,alignmentAxis:i}),l&&Xy({mainAxis:!0,crossAxis:!1,limiter:p==="partial"?Jy():void 0,...z}),l&&Zy({...z}),Qy({...z,apply:({elements:oe,rects:xe,availableWidth:de,availableHeight:we})=>{const{width:Me,height:He}=xe.reference,$e=oe.floating.style;$e.setProperty("--radix-popper-available-width",`${de}px`),$e.setProperty("--radix-popper-available-height",`${we}px`),$e.setProperty("--radix-popper-anchor-width",`${Me}px`),$e.setProperty("--radix-popper-anchor-height",`${He}px`)}}),k&&t0({element:k,padding:a}),c0({arrowWidth:E,arrowHeight:A}),m&&e0({strategy:"referenceHidden",...z})]}),[_,V]=tf(M),J=wt(v);It(()=>{Q&&(J==null||J())},[Q,J]);const j=(H=$.arrow)==null?void 0:H.x,R=(D=$.arrow)==null?void 0:D.y,G=((X=$.arrow)==null?void 0:X.centerOffset)!==0,[Y,ie]=h.useState();return It(()=>{y&&ie(window.getComputedStyle(y).zIndex)},[y]),u.jsx("div",{ref:N.setFloating,"data-radix-popper-content-wrapper":"",style:{...q,transform:Q?q.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Y,"--radix-popper-transform-origin":[(Z=$.transformOrigin)==null?void 0:Z.x,(ce=$.transformOrigin)==null?void 0:ce.y].join(" "),...((L=$.hide)==null?void 0:L.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:u.jsx(s0,{scope:n,placedSide:_,onArrowChange:C,arrowX:j,arrowY:R,shouldHideArrow:G,children:u.jsx(ye.div,{"data-side":_,"data-align":V,...g,ref:S,style:{...g.style,animation:Q?void 0:"none"}})})})});Zd.displayName=Ca;var Qd="PopperArrow",a0={top:"bottom",right:"left",bottom:"top",left:"right"},ef=h.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=i0(Qd,r),i=a0[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(r0,{...o,ref:n,style:{...o.style,display:"block"}})})});ef.displayName=Qd;function l0(e){return e!==null}var c0=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]=tf(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 tf(e){const[t,n="center"]=e.split("-");return[t,n]}var Ta=Yd,ka=Jd,Ea=Zd,Ia=ef,Na="rovingFocusGroup.onEntryFocus",u0={bubbles:!1,cancelable:!0},to="RovingFocusGroup",[Aa,nf,d0]=as(to),[f0,rf]=sn(to,[d0]),[p0,h0]=f0(to),of=h.forwardRef((e,t)=>u.jsx(Aa.Provider,{scope:e.__scopeRovingFocusGroup,children:u.jsx(Aa.Slot,{scope:e.__scopeRovingFocusGroup,children:u.jsx(m0,{...e,ref:t})})}));of.displayName=to;var m0=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=We(t,m),v=ls(s),[g,x]=jn({prop:i,defaultProp:a??null,onChange:l,caller:to}),[y,w]=h.useState(!1),S=wt(c),k=nf(n),C=h.useRef(!1),[T,E]=h.useState(0);return h.useEffect(()=>{const A=m.current;if(A)return A.addEventListener(Na,S),()=>A.removeEventListener(Na,S)},[S]),u.jsx(p0,{scope:n,orientation:r,dir:v,loop:o,currentTabStopId:g,onItemFocus:h.useCallback(A=>x(A),[x]),onItemShiftTab:h.useCallback(()=>w(!0),[]),onFocusableItemAdd:h.useCallback(()=>E(A=>A+1),[]),onFocusableItemRemove:h.useCallback(()=>E(A=>A-1),[]),children:u.jsx(ye.div,{tabIndex:y||T===0?-1:0,"data-orientation":r,...p,ref:f,style:{outline:"none",...e.style},onMouseDown:le(e.onMouseDown,()=>{C.current=!0}),onFocus:le(e.onFocus,A=>{const O=!C.current;if(A.target===A.currentTarget&&O&&!y){const F=new CustomEvent(Na,u0);if(A.currentTarget.dispatchEvent(F),!F.defaultPrevented){const U=k().filter(M=>M.focusable),W=U.find(M=>M.active),z=U.find(M=>M.id===g),q=[W,z,...U].filter(Boolean).map(M=>M.ref.current);lf(q,d)}}C.current=!1}),onBlur:le(e.onBlur,()=>w(!1))})})}),sf="RovingFocusGroupItem",af=h.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,l=At(),c=s||l,d=h0(sf,n),p=d.currentTabStopId===c,m=nf(n),{onFocusableItemAdd:f,onFocusableItemRemove:v,currentTabStopId:g}=d;return h.useEffect(()=>{if(r)return f(),()=>v()},[r,f,v]),u.jsx(Aa.ItemSlot,{scope:n,id:c,focusable:r,active:o,children:u.jsx(ye.span,{tabIndex:p?0:-1,"data-orientation":d.orientation,...a,ref:t,onMouseDown:le(e.onMouseDown,x=>{r?d.onItemFocus(c):x.preventDefault()}),onFocus:le(e.onFocus,()=>d.onItemFocus(c)),onKeyDown:le(e.onKeyDown,x=>{if(x.key==="Tab"&&x.shiftKey){d.onItemShiftTab();return}if(x.target!==x.currentTarget)return;const y=v0(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?w0(S,k+1):S.slice(k+1)}setTimeout(()=>lf(S))}}),children:typeof i=="function"?i({isCurrentTabStop:p,hasTabStop:g!=null}):i})})});af.displayName=sf;var g0={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function x0(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function v0(e,t,n){const r=x0(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return g0[r]}function lf(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function w0(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var b0=of,y0=af,_a=["Enter"," "],S0=["ArrowDown","PageUp","Home"],cf=["ArrowUp","PageDown","End"],C0=[...S0,...cf],T0={ltr:[..._a,"ArrowRight"],rtl:[..._a,"ArrowLeft"]},k0={ltr:["ArrowLeft"],rtl:["ArrowRight"]},no="Menu",[ro,E0,I0]=as(no),[Qn,uf]=sn(no,[I0,Er,rf]),ws=Er(),df=rf(),[N0,er]=Qn(no),[A0,oo]=Qn(no),ff=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=ws(t),[l,c]=h.useState(null),d=h.useRef(!1),p=wt(s),m=ls(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(Ta,{...a,children:u.jsx(N0,{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})})})};ff.displayName=no;var _0="MenuAnchor",ja=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=ws(n);return u.jsx(ka,{...o,...r,ref:t})});ja.displayName=_0;var Pa="MenuPortal",[j0,pf]=Qn(Pa,{forceMount:void 0}),hf=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=er(Pa,t);return u.jsx(j0,{scope:t,forceMount:n,children:u.jsx(Ft,{present:n||s.open,children:u.jsx(qr,{asChild:!0,container:o,children:r})})})};hf.displayName=Pa;var Zt="MenuContent",[P0,Ma]=Qn(Zt),mf=h.forwardRef((e,t)=>{const n=pf(Zt,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=er(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(M0,{...o,ref:t}):u.jsx(R0,{...o,ref:t})})})})}),M0=h.forwardRef((e,t)=>{const n=er(Zt,e.__scopeMenu),r=h.useRef(null),o=We(t,r);return h.useEffect(()=>{const s=r.current;if(s)return Yi(s)},[]),u.jsx(Ra,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:le(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),R0=h.forwardRef((e,t)=>{const n=er(Zt,e.__scopeMenu);return u.jsx(Ra,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),O0=Vt.createSlot("MenuContent.ScrollLock"),Ra=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=er(Zt,n),y=oo(Zt,n),w=ws(n),S=df(n),k=E0(n),[C,T]=h.useState(null),E=h.useRef(null),A=We(t,E,x.onContentChange),O=h.useRef(0),F=h.useRef(""),U=h.useRef(0),W=h.useRef(null),z=h.useRef("right"),N=h.useRef(0),q=v?Jo:h.Fragment,M=v?{as:O0,allowPinchZoom:!0}:void 0,Q=_=>{var H,D;const V=F.current+_,J=k().filter(X=>!X.disabled),j=document.activeElement,R=(H=J.find(X=>X.ref.current===j))==null?void 0:H.textValue,G=J.map(X=>X.textValue),Y=q0(G,V,R),ie=(D=J.find(X=>X.textValue===Y))==null?void 0:D.ref.current;(function X(Z){F.current=Z,window.clearTimeout(O.current),Z!==""&&(O.current=window.setTimeout(()=>X(""),1e3))})(V),ie&&setTimeout(()=>ie.focus())};h.useEffect(()=>()=>window.clearTimeout(O.current),[]),Ui();const $=h.useCallback(_=>{var J,j;return z.current===((J=W.current)==null?void 0:J.side)&&Y0(_,(j=W.current)==null?void 0:j.area)},[]);return u.jsx(P0,{scope:n,searchRef:F,onItemEnter:h.useCallback(_=>{$(_)&&_.preventDefault()},[$]),onItemLeave:h.useCallback(_=>{var V;$(_)||((V=E.current)==null||V.focus(),T(null))},[$]),onTriggerLeave:h.useCallback(_=>{$(_)&&_.preventDefault()},[$]),pointerGraceTimerRef:U,onPointerGraceIntentChange:h.useCallback(_=>{W.current=_},[]),children:u.jsx(q,{...M,children:u.jsx(Wo,{asChild:!0,trapped:o,onMountAutoFocus:le(s,_=>{var V;_.preventDefault(),(V=E.current)==null||V.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:u.jsx(mr,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:p,onInteractOutside:m,onDismiss:f,children:u.jsx(b0,{asChild:!0,...S,dir:y.dir,orientation:"vertical",loop:r,currentTabStopId:C,onCurrentTabStopIdChange:T,onEntryFocus:le(l,_=>{y.isUsingKeyboardRef.current||_.preventDefault()}),preventScrollOnEntryFocus:!0,children:u.jsx(Ea,{role:"menu","aria-orientation":"vertical","data-state":Pf(x.open),"data-radix-menu-content":"",dir:y.dir,...w,...g,ref:A,style:{outline:"none",...g.style},onKeyDown:le(g.onKeyDown,_=>{const J=_.target.closest("[data-radix-menu-content]")===_.currentTarget,j=_.ctrlKey||_.altKey||_.metaKey,R=_.key.length===1;J&&(_.key==="Tab"&&_.preventDefault(),!j&&R&&Q(_.key));const G=E.current;if(_.target!==G||!C0.includes(_.key))return;_.preventDefault();const ie=k().filter(H=>!H.disabled).map(H=>H.ref.current);cf.includes(_.key)&&ie.reverse(),V0(ie)}),onBlur:le(e.onBlur,_=>{_.currentTarget.contains(_.target)||(window.clearTimeout(O.current),F.current="")}),onPointerMove:le(e.onPointerMove,io(_=>{const V=_.target,J=N.current!==_.clientX;if(_.currentTarget.contains(V)&&J){const j=_.clientX>N.current?"right":"left";z.current=j,N.current=_.clientX}}))})})})})})})});mf.displayName=Zt;var D0="MenuGroup",Oa=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(ye.div,{role:"group",...r,ref:t})});Oa.displayName=D0;var L0="MenuLabel",gf=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(ye.div,{...r,ref:t})});gf.displayName=L0;var bs="MenuItem",xf="menu.itemSelect",ys=h.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=h.useRef(null),i=oo(bs,e.__scopeMenu),a=Ma(bs,e.__scopeMenu),l=We(t,s),c=h.useRef(!1),d=()=>{const p=s.current;if(!n&&p){const m=new CustomEvent(xf,{bubbles:!0,cancelable:!0});p.addEventListener(xf,f=>r==null?void 0:r(f),{once:!0}),$i(p,m),m.defaultPrevented?c.current=!1:i.onClose()}};return u.jsx(vf,{...o,ref:l,disabled:n,onClick:le(e.onClick,d),onPointerDown:p=>{var m;(m=e.onPointerDown)==null||m.call(e,p),c.current=!0},onPointerUp:le(e.onPointerUp,p=>{var m;c.current||(m=p.currentTarget)==null||m.click()}),onKeyDown:le(e.onKeyDown,p=>{const m=a.searchRef.current!=="";n||m&&p.key===" "||_a.includes(p.key)&&(p.currentTarget.click(),p.preventDefault())})})});ys.displayName=bs;var vf=h.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=Ma(bs,n),a=df(n),l=h.useRef(null),c=We(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(y0,{asChild:!0,...a,focusable:!r,children:u.jsx(ye.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:c,onPointerMove:le(e.onPointerMove,io(v=>{r?i.onItemLeave(v):(i.onItemEnter(v),v.defaultPrevented||v.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:le(e.onPointerLeave,io(v=>i.onItemLeave(v))),onFocus:le(e.onFocus,()=>p(!0)),onBlur:le(e.onBlur,()=>p(!1))})})})}),$0="MenuCheckboxItem",wf=h.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return u.jsx(Tf,{scope:e.__scopeMenu,checked:n,children:u.jsx(ys,{role:"menuitemcheckbox","aria-checked":Ss(n)?"mixed":n,...o,ref:t,"data-state":La(n),onSelect:le(o.onSelect,()=>r==null?void 0:r(Ss(n)?!0:!n),{checkForDefaultPrevented:!1})})})});wf.displayName=$0;var bf="MenuRadioGroup",[F0,B0]=Qn(bf,{value:void 0,onValueChange:()=>{}}),yf=h.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=wt(r);return u.jsx(F0,{scope:e.__scopeMenu,value:n,onValueChange:s,children:u.jsx(Oa,{...o,ref:t})})});yf.displayName=bf;var Sf="MenuRadioItem",Cf=h.forwardRef((e,t)=>{const{value:n,...r}=e,o=B0(Sf,e.__scopeMenu),s=n===o.value;return u.jsx(Tf,{scope:e.__scopeMenu,checked:s,children:u.jsx(ys,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":La(s),onSelect:le(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});Cf.displayName=Sf;var Da="MenuItemIndicator",[Tf,z0]=Qn(Da,{checked:!1}),kf=h.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=z0(Da,n);return u.jsx(Ft,{present:r||Ss(s.checked)||s.checked===!0,children:u.jsx(ye.span,{...o,ref:t,"data-state":La(s.checked)})})});kf.displayName=Da;var H0="MenuSeparator",Ef=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(ye.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});Ef.displayName=H0;var U0="MenuArrow",If=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=ws(n);return u.jsx(Ia,{...o,...r,ref:t})});If.displayName=U0;var W0="MenuSub",[QI,Nf]=Qn(W0),so="MenuSubTrigger",Af=h.forwardRef((e,t)=>{const n=er(so,e.__scopeMenu),r=oo(so,e.__scopeMenu),o=Nf(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(ja,{asChild:!0,...c,children:u.jsx(vf,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":Pf(n.open),...e,ref:_n(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:le(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:le(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:le(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())})})})});Af.displayName=so;var _f="MenuSubContent",jf=h.forwardRef((e,t)=>{const n=pf(Zt,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=er(Zt,e.__scopeMenu),i=oo(Zt,e.__scopeMenu),a=Nf(_f,e.__scopeMenu),l=h.useRef(null),c=We(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(Ra,{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:le(e.onFocusOutside,d=>{d.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:le(e.onEscapeKeyDown,d=>{i.onClose(),d.preventDefault()}),onKeyDown:le(e.onKeyDown,d=>{var f;const p=d.currentTarget.contains(d.target),m=k0[i.dir].includes(d.key);p&&m&&(s.onOpenChange(!1),(f=a.trigger)==null||f.focus(),d.preventDefault())})})})})})});jf.displayName=_f;function Pf(e){return e?"open":"closed"}function Ss(e){return e==="indeterminate"}function La(e){return Ss(e)?"indeterminate":e?"checked":"unchecked"}function V0(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function K0(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function q0(e,t,n){const o=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=K0(e,Math.max(s,0));o.length===1&&(i=i.filter(c=>c!==n));const l=i.find(c=>c.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function G0(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const a=t[s],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 Y0(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return G0(n,t)}function io(e){return t=>t.pointerType==="mouse"?e(t):void 0}var X0=ff,J0=ja,Z0=hf,Q0=mf,eS=Oa,tS=gf,nS=ys,rS=wf,oS=yf,sS=Cf,iS=kf,aS=Ef,lS=If,cS=Af,uS=jf,Cs="DropdownMenu",[dS,e1]=sn(Cs,[uf]),Ot=uf(),[fS,Mf]=dS(Cs),Rf=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,l=Ot(t),c=h.useRef(null),[d,p]=jn({prop:o,defaultProp:s??!1,onChange:i,caller:Cs});return u.jsx(fS,{scope:t,triggerId:At(),triggerRef:c,contentId:At(),open:d,onOpenChange:p,onOpenToggle:h.useCallback(()=>p(m=>!m),[p]),modal:a,children:u.jsx(X0,{...l,open:d,onOpenChange:p,dir:r,modal:a,children:n})})};Rf.displayName=Cs;var Of="DropdownMenuTrigger",Df=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=Mf(Of,n),i=Ot(n);return u.jsx(J0,{asChild:!0,...i,children:u.jsx(ye.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:_n(t,s.triggerRef),onPointerDown:le(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:le(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});Df.displayName=Of;var pS="DropdownMenuPortal",Lf=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Ot(t);return u.jsx(Z0,{...r,...n})};Lf.displayName=pS;var $f="DropdownMenuContent",Ff=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Mf($f,n),s=Ot(n),i=h.useRef(!1);return u.jsx(Q0,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:le(e.onCloseAutoFocus,a=>{var l;i.current||(l=o.triggerRef.current)==null||l.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:le(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)"}})});Ff.displayName=$f;var hS="DropdownMenuGroup",mS=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(eS,{...o,...r,ref:t})});mS.displayName=hS;var gS="DropdownMenuLabel",Bf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(tS,{...o,...r,ref:t})});Bf.displayName=gS;var xS="DropdownMenuItem",zf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(nS,{...o,...r,ref:t})});zf.displayName=xS;var vS="DropdownMenuCheckboxItem",Hf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(rS,{...o,...r,ref:t})});Hf.displayName=vS;var wS="DropdownMenuRadioGroup",bS=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(oS,{...o,...r,ref:t})});bS.displayName=wS;var yS="DropdownMenuRadioItem",Uf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(sS,{...o,...r,ref:t})});Uf.displayName=yS;var SS="DropdownMenuItemIndicator",Wf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(iS,{...o,...r,ref:t})});Wf.displayName=SS;var CS="DropdownMenuSeparator",Vf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(aS,{...o,...r,ref:t})});Vf.displayName=CS;var TS="DropdownMenuArrow",kS=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(lS,{...o,...r,ref:t})});kS.displayName=TS;var ES="DropdownMenuSubTrigger",Kf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(cS,{...o,...r,ref:t})});Kf.displayName=ES;var IS="DropdownMenuSubContent",qf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ot(n);return u.jsx(uS,{...o,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});qf.displayName=IS;var NS=Rf,AS=Df,_S=Lf,Gf=Ff,Yf=Bf,Xf=zf,Jf=Hf,Zf=Uf,Qf=Wf,ep=Vf,tp=Kf,np=qf;const Ts=NS,ks=AS,jS=h.forwardRef(({className:e,inset:t,children:n,...r},o)=>u.jsxs(tp,{ref:o,className:re("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(fe.ChevronRight,{className:"ml-auto h-4 w-4"})]}));jS.displayName=tp.displayName;const PS=h.forwardRef(({className:e,...t},n)=>u.jsx(np,{ref:n,className:re("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}));PS.displayName=np.displayName;const ao=h.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(_S,{children:u.jsx(Gf,{ref:r,sideOffset:t,className:re("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=Gf.displayName;const Dn=h.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(Xf,{ref:r,className:re("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}));Dn.displayName=Xf.displayName;const MS=h.forwardRef(({className:e,children:t,checked:n,...r},o)=>u.jsxs(Jf,{ref:o,className:re("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(Qf,{children:u.jsx(fe.Check,{className:"h-4 w-4"})})}),t]}));MS.displayName=Jf.displayName;const RS=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Zf,{ref:r,className:re("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(Qf,{children:u.jsx(fe.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));RS.displayName=Zf.displayName;const OS=h.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(Yf,{ref:r,className:re("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));OS.displayName=Yf.displayName;const DS=h.forwardRef(({className:e,...t},n)=>u.jsx(ep,{ref:n,className:re("-mx-1 my-1 h-px bg-muted",e),...t}));DS.displayName=ep.displayName;function $a(e,[t,n]){return Math.min(n,Math.max(t,e))}function LS(e,t){return h.useReducer((n,r)=>t[n][r]??n,e)}var Fa="ScrollArea",[rp,t1]=sn(Fa),[$S,Qt]=rp(Fa),op=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,A]=h.useState(!1),O=We(t,U=>l(U)),F=ls(o);return u.jsx($S,{scope:n,type:r,dir:F,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:A,onCornerWidthChange:w,onCornerHeightChange:k,children:u.jsx(ye.div,{dir:F,...i,ref:O,style:{position:"relative","--radix-scroll-area-corner-width":y+"px","--radix-scroll-area-corner-height":S+"px",...e.style}})})});op.displayName=Fa;var sp="ScrollAreaViewport",ip=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=Qt(sp,n),a=h.useRef(null),l=We(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(ye.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})})]})});ip.displayName=sp;var yn="ScrollAreaScrollbar",Ba=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Qt(yn,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(FS,{...r,ref:t,forceMount:n}):o.type==="scroll"?u.jsx(BS,{...r,ref:t,forceMount:n}):o.type==="auto"?u.jsx(ap,{...r,ref:t,forceMount:n}):o.type==="always"?u.jsx(za,{...r,ref:t}):null});Ba.displayName=yn;var FS=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Qt(yn,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(ap,{"data-state":s?"visible":"hidden",...r,ref:t})})}),BS=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Qt(yn,e.__scopeScrollArea),s=e.orientation==="horizontal",i=As(()=>l("SCROLL_END"),100),[a,l]=LS("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(za,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:le(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:le(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),ap=h.forwardRef((e,t)=>{const n=Qt(yn,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=h.useState(!1),a=e.orientation==="horizontal",l=As(()=>{if(n.viewport){const c=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?c:d)}},10);return Ir(n.viewport,l),Ir(n.content,l),u.jsx(Ft,{present:r||s,children:u.jsx(za,{"data-state":s?"visible":"hidden",...o,ref:t})})}),za=h.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=Qt(yn,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=fp(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 KS(m,i.current,a,f)}return n==="horizontal"?u.jsx(zS,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollLeft,f=pp(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(HS,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollTop,f=pp(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}),zS=h.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=Qt(yn,e.__scopeScrollArea),[i,a]=h.useState(),l=h.useRef(null),c=We(t,l,s.onScrollbarXChange);return h.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(cp,{"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":Ns(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),mp(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:Is(i.paddingLeft),paddingEnd:Is(i.paddingRight)}})}})}),HS=h.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=Qt(yn,e.__scopeScrollArea),[i,a]=h.useState(),l=h.useRef(null),c=We(t,l,s.onScrollbarYChange);return h.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(cp,{"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":Ns(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),mp(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:Is(i.paddingTop),paddingEnd:Is(i.paddingBottom)}})}})}),[US,lp]=rp(yn),cp=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=Qt(yn,n),[v,g]=h.useState(null),x=We(t,O=>g(O)),y=h.useRef(null),w=h.useRef(""),S=f.viewport,k=r.content-r.viewport,C=wt(d),T=wt(l),E=As(p,10);function A(O){if(y.current){const F=O.clientX-y.current.left,U=O.clientY-y.current.top;c({x:F,y:U})}}return h.useEffect(()=>{const O=F=>{const U=F.target;(v==null?void 0:v.contains(U))&&C(F,k)};return document.addEventListener("wheel",O,{passive:!1}),()=>document.removeEventListener("wheel",O,{passive:!1})},[S,v,k,C]),h.useEffect(T,[r,T]),Ir(v,E),Ir(f.content,E),u.jsx(US,{scope:n,scrollbar:v,hasThumb:o,onThumbChange:wt(s),onThumbPointerUp:wt(i),onThumbPositionChange:T,onThumbPointerDown:wt(a),children:u.jsx(ye.div,{...m,ref:x,style:{position:"absolute",...m.style},onPointerDown:le(e.onPointerDown,O=>{O.button===0&&(O.target.setPointerCapture(O.pointerId),y.current=v.getBoundingClientRect(),w.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",f.viewport&&(f.viewport.style.scrollBehavior="auto"),A(O))}),onPointerMove:le(e.onPointerMove,A),onPointerUp:le(e.onPointerUp,O=>{const F=O.target;F.hasPointerCapture(O.pointerId)&&F.releasePointerCapture(O.pointerId),document.body.style.webkitUserSelect=w.current,f.viewport&&(f.viewport.style.scrollBehavior=""),y.current=null})})})}),Es="ScrollAreaThumb",up=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=lp(Es,e.__scopeScrollArea);return u.jsx(Ft,{present:n||o.hasThumb,children:u.jsx(WS,{ref:t,...r})})}),WS=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=Qt(Es,n),i=lp(Es,n),{onThumbPositionChange:a}=i,l=We(t,p=>i.onThumbChange(p)),c=h.useRef(void 0),d=As(()=>{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=qS(p,a);c.current=f,a()}};return a(),p.addEventListener("scroll",m),()=>p.removeEventListener("scroll",m)}},[s.viewport,d,a]),u.jsx(ye.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:le(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:le(e.onPointerUp,i.onThumbPointerUp)})});up.displayName=Es;var Ha="ScrollAreaCorner",dp=h.forwardRef((e,t)=>{const n=Qt(Ha,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?u.jsx(VS,{...e,ref:t}):null});dp.displayName=Ha;var VS=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=Qt(Ha,n),[s,i]=h.useState(0),[a,l]=h.useState(0),c=!!(s&&a);return Ir(o.scrollbarX,()=>{var p;const d=((p=o.scrollbarX)==null?void 0:p.offsetHeight)||0;o.onCornerHeightChange(d),l(d)}),Ir(o.scrollbarY,()=>{var p;const d=((p=o.scrollbarY)==null?void 0:p.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),c?u.jsx(ye.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 Is(e){return e?parseInt(e,10):0}function fp(e,t){const n=e/t;return isNaN(n)?0:n}function Ns(e){const t=fp(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function KS(e,t,n,r="ltr"){const o=Ns(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 hp([l,c],p)(e)}function pp(e,t,n="ltr"){const r=Ns(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=$a(e,l);return hp([0,i],[0,a])(c)}function hp(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 mp(e,t){return e>0&&e<t}var qS=(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 As(e,t){const n=wt(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 Ir(e,t){const n=wt(t);It(()=>{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 gp=op,GS=ip,YS=dp;const Ua=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(gp,{ref:r,className:re("relative overflow-hidden",e),...n,children:[u.jsx(GS,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),u.jsx(xp,{}),u.jsx(YS,{})]}));Ua.displayName=gp.displayName;const xp=h.forwardRef(({className:e,orientation:t="vertical",...n},r)=>u.jsx(Ba,{ref:r,orientation:t,className:re("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(up,{className:"relative flex-1 rounded-full bg-border"})}));xp.displayName=Ba.displayName;const Wa=h.forwardRef(({className:e,type:t,...n},r)=>u.jsx("input",{type:t,className:re("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}));Wa.displayName="Input";const XS="group relative p-3 rounded-lg cursor-pointer transition-colors border text-gray-900 dark:text-slate-100",JS="bg-slate-700 border-slate-600 hover:bg-slate-600",ZS="bg-slate-600 border-slate-500";function QS({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??ZS}`:`${x??JS}`,k=C=>{C.stopPropagation(),o(e.threadId)};return u.jsxs("div",{onClick:k,className:`${XS} ${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(Wa,{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(ct,{variant:"ghost",size:"sm",onClick:()=>a(e.threadId),className:"h-6 w-6 p-0",children:u.jsx(fe.Check,{size:12})}),u.jsx(ct,{variant:"ghost",size:"sm",onClick:l,className:"h-6 w-6 p-0",children:u.jsx(fe.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(fe.Calendar,{size:10}),u.jsx("span",{children:f(e.updatedAt||e.createdAt)})]}),g&&u.jsx("div",{className:"text-[11px] text-muted-foreground mt-1",children:g})]})}),u.jsx("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2",children:u.jsxs(Ts,{children:[u.jsx(ks,{asChild:!0,children:u.jsx(ct,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",children:u.jsx(fe.MoreHorizontal,{size:12})})}),u.jsxs(ao,{align:"end",sideOffset:6,className:"w-44",children:[u.jsxs(Dn,{onClick:C=>{C.preventDefault(),c(e.threadId)},children:[u.jsx(fe.Share2,{className:"mr-2 h-4 w-4"}),"Share thread"]}),p&&n!==e.threadId&&u.jsxs(Dn,{onClick:C=>{C.preventDefault(),s(e,C)},children:[u.jsx(fe.Edit3,{className:"mr-2 h-4 w-4"}),"Rename"]}),m&&d&&u.jsxs(Dn,{className:"text-red-400 hover:text-red-300",onClick:C=>{C.preventDefault(),d(e.threadId,C)},children:[u.jsx(fe.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 vp=25,wp="thread-manager-view",eC=e=>e==="default"||e==="shared",tC=()=>{if(typeof window>"u")return null;try{const e=window.localStorage.getItem(wp);if(eC(e))return e}catch{}return null};function bp({defaultView:e}={}){const[t,n]=b.useState(()=>tC()??e??"default");b.useEffect(()=>{if(!(typeof window>"u"))try{window.localStorage.setItem(wp,t)}catch{}},[t]);const r=b.useCallback(o=>{n(o)},[]);return{view:t,setView:r}}const nC=[{key:"default",label:"My chats"},{key:"shared",label:"Shared with you"}];function Va({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:A,isLoadingSharedThreads:O,actions:F,shareInFlight:U,shareStatus:W,clearShareStatus:z}=zo(),{createThread:N,deleteThread:q,renameThread:M,shareThread:Q}=F,{loadThread:$}=Ho(),_=i??T,[V,J]=b.useState(Array.isArray(k)?k:[]),j=b.useRef(V.length>0),R=b.useRef(null),G=b.useRef(0),[Y,ie]=b.useState(null),[H,D]=b.useState(""),[X,Z]=b.useState(!1),[ce,L]=b.useState(!1),[oe,xe]=b.useState(null),[de,we]=b.useState(""),Me=v&&v.length>0?v:nC,He=bp({defaultView:m}),$e=g??He,Ae=p??$e.view,Fe=b.useCallback(P=>{p||$e.setView(P),f==null||f(P)},[p,f,$e]),Ge=Me.find(P=>P.key===Ae)??Me[0],Ke=P=>{xe(P),we(""),L(!0)},Xe=()=>{L(!1),xe(null),we(""),z()},tt=b.useCallback(async P=>{if(!(!oe||U)&&P.id)try{await Q(oe,P.id),setTimeout(()=>Xe(),600)}catch(te){console.error("Failed to share thread:",te)}},[Xe,U,oe,Q]),nt=b.useMemo(()=>{const P=y??[],te=de.trim().toLowerCase();return te?S?P.filter(ve=>S(ve,te)):P.filter(ve=>`${ve.label} ${ve.secondaryLabel??""}`.toLowerCase().includes(te)):P},[y,de,S]),Ze=Ae==="shared",pt=Ze?C:V,ht=Ze?O:A,Se=Ze?"No shared conversations yet":"No conversations yet",Re=P=>{const te=P.sharedAt?` • ${xt(P.sharedAt)}`:"";return`Shared by ${P.sharedByUserId}${te}`},mt=P=>"sharedByUserId"in P;b.useEffect(()=>{const P=Array.isArray(k)?k:[];if(P.length>0){j.current=!0,J(P);return}A||(j.current=!1,J(P))},[k,A]),b.useEffect(()=>{if(!R.current)return;const P=R.current.querySelector("[data-radix-scroll-area-viewport]");if(!P)return;let te=null,ve=null;return te=requestAnimationFrame(()=>{ve=requestAnimationFrame(()=>{P.scrollTop=G.current})}),()=>{te!==null&&cancelAnimationFrame(te),ve!==null&&cancelAnimationFrame(ve)}},[V]);const ot=async P=>{try{E(P),await $(P),a==null||a(P),l==null||l(P)}catch(te){console.error("Failed to select thread:",te)}},qe=async()=>{try{Z(!0);const P=await N();P&&(c==null||c(P),a==null||a(P))}catch(P){console.error("Failed to create thread:",P)}finally{Z(!1)}},yt=async(P,te)=>{if(te.stopPropagation(),!!confirm("Delete this thread?")){if(R.current){const ve=R.current.querySelector("[data-radix-scroll-area-viewport]");ve&&(G.current=ve.scrollTop)}try{await q(P),d==null||d(P)}catch(ve){console.error("Failed to delete thread:",ve)}}},De=(P,te)=>{te.stopPropagation(),ie(P.threadId),D(P.title||`Thread ${P.threadId.slice(0,8)}`)},Be=async P=>{if(H.trim())try{await M(P,H.trim()),ie(null),D("")}catch(te){console.error("Failed to update title:",te)}},St=()=>{ie(null),D("")},xt=P=>{if(!P)return"";try{const te=new Date(P),ae=new Date().getTime()-te.getTime(),Ie=Math.floor(ae/(1e3*60*60*24));return Ie===0?te.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):Ie===1?"Yesterday":Ie<7?`${Ie} days ago`:te.toLocaleDateString()}catch{return""}},Ye=P=>P.title||`Thread ${P.threadId.slice(0,8)}`,gt=P=>{const te=Ye(P);return te.length<=vp?te:`${te.slice(0,vp)}...`};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(ct,{onClick:qe,disabled:X||A,className:s.createButton||"px-3 py-2 gap-1",size:"sm",variant:"ghost",title:X?"Creating...":"New Chat",children:[u.jsx(fe.Edit3,{size:16}),u.jsx("span",{children:"New chat"})]})}),u.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-slate-700 dark:text-slate-200 uppercase tracking-wide leading-tight",children:[u.jsx("span",{children:"Current View"}),u.jsxs(Ts,{children:[u.jsx(ks,{asChild:!0,children:u.jsx(ct,{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:Ge.label})}),u.jsx(ao,{align:"start",sideOffset:6,className:"w-40",children:Me.map(P=>u.jsxs(Dn,{className:"justify-between text-[12px]",onClick:te=>{te.preventDefault(),Fe(P.key)},children:[u.jsx("span",{children:P.label}),Ae===P.key&&u.jsx(fe.Check,{className:"h-3 w-3"})]},P.key))})]})]})]}),u.jsx(Ua,{ref:R,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:ht?u.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-8 text-slate-400",children:[u.jsx(fe.Loader2,{className:"h-5 w-5 animate-spin"}),u.jsx("span",{className:"text-sm",children:"Loading threads…"})]}):pt.length===0?u.jsxs("div",{className:"text-center py-8 text-slate-400",children:[u.jsx(fe.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:Se})]}):pt.slice().sort((P,te)=>new Date(te.updatedAt||te.createdAt||"").getTime()-new Date(P.updatedAt||P.createdAt||"").getTime()).map(P=>u.jsx(QS,{thread:P,isActive:_===P.threadId,editingThreadId:Y,editingTitle:H,onSelect:ot,onStartEditing:De,onEditingTitleChange:te=>D(te),onSaveEditing:Be,onCancelEditing:St,onShare:()=>Ke(P.threadId),onDelete:yt,showEditTitle:r,showDeleteButton:n,formatDate:xt,getDisplayThreadTitle:gt,secondaryLine:Ze&&mt(P)?Re(P):void 0,itemClassName:s.threadItem,activeItemClassName:s.activeThread},P.threadId))})}),u.jsx(oa,{open:ce,onOpenChange:P=>!P&&Xe(),children:u.jsxs(os,{className:"max-w-md p-0",children:[u.jsx(ss,{children:u.jsx(is,{children:"Share thread"})}),u.jsxs(sa,{children:[u.jsx(ia,{autoFocus:!0,value:de,onValueChange:P=>we(P),placeholder:"Search for recipients..."}),u.jsxs(aa,{children:[W&&u.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-xs text-muted-foreground",children:[U&&u.jsx(fe.Loader2,{className:"h-3 w-3 animate-spin"}),u.jsx("span",{className:W.startsWith("Failed")?"text-red-500":W.startsWith("Shared")?"text-emerald-500":"text-slate-600 dark:text-slate-400",children:W})]}),u.jsx(la,{children:w?u.jsxs("span",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(fe.Loader2,{className:"h-4 w-4 animate-spin"}),"Loading recipients…"]}):"No matching recipients found"}),nt.length>0&&u.jsx(ca,{heading:"Recipients",children:nt.map(P=>u.jsx(ua,{onSelect:()=>tt(P),children:u.jsxs("div",{className:"flex flex-col items-start text-sm",children:[u.jsx("span",{className:"font-medium",children:P.label}),P.secondaryLabel&&u.jsx("span",{className:"text-xs text-muted-foreground",children:P.secondaryLabel})]})},P.id))})]})]})]})})]})}const Ka=h.forwardRef(({className:e,...t},n)=>u.jsx("textarea",{className:re("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),ref:n,...t}));Ka.displayName="Textarea";const rC=1e4;function yp({initialValue:e="",editingMessageId:t=null,placeholder:n="Type your message...",isStreaming:r=!1,disabled:o=!1,maxLength:s=rC,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),A=b.useRef(null),O=b.useRef("");b.useEffect(()=>{x||(w(e??""),A.current=null,T.current&&(T.current.style.height="auto",T.current.style.height=`${T.current.scrollHeight}px`))},[e,t,x]);const[F,U]=b.useState(null),W=b.useCallback(R=>R.length>s?`Message too long (${R.length}/${s} characters)`:null,[s]),z=b.useMemo(()=>v??W,[v,W]),N=b.useCallback(R=>{const G=z(R);return U(G),g==null||g(G),O.current=R,G},[z,g]),q=b.useCallback(()=>{const R=T.current;R&&(R.style.height="auto",R.style.height=`${R.scrollHeight}px`)},[]);b.useEffect(()=>{q()},[q,S]),b.useEffect(()=>{if(!F)return;const R=(S??"").trim();O.current!==R&&N(R)},[S,F,N]);const M=b.useCallback((R,{fromUser:G})=>{x||w(R),G&&(a==null||a(R))},[x,a]),Q=b.useCallback(async R=>{R&&R.preventDefault();const G=(S??"").trim();if(!G&&!f||N(G))return;const Y=++E.current;A.current={id:Y,shouldClear:!0},C(()=>{var ie,H,D;try{const X=l(G);X&&typeof X.then=="function"?X.then(()=>{var Z,ce;((Z=A.current)==null?void 0:Z.id)===Y&&A.current.shouldClear&&(x||(w(""),T.current&&(T.current.style.height="auto"),a==null||a(""))),((ce=A.current)==null?void 0:ce.id)===Y&&(A.current=null)}).catch(()=>{var Z;((Z=A.current)==null?void 0:Z.id)===Y&&(A.current=null)}):(((ie=A.current)==null?void 0:ie.id)===Y&&A.current.shouldClear&&(x||(w(""),T.current&&(T.current.style.height="auto"),a==null||a(""))),((H=A.current)==null?void 0:H.id)===Y&&(A.current=null))}catch{((D=A.current)==null?void 0:D.id)===Y&&(A.current=null)}})},[S,l,f,x,a,N]),$=b.useCallback(R=>{const G=R.target.value;M(G,{fromUser:!0}),A.current&&(A.current.shouldClear=!1),T.current&&(T.current.style.height="auto",T.current.style.height=`${T.current.scrollHeight}px`),F&&N(G.trim())},[M,N,F]),_=b.useCallback(R=>{R.key==="Enter"&&!R.shiftKey?(R.preventDefault(),Q()):R.key==="Escape"&&t&&(R.preventDefault(),c==null||c())},[Q,t,c]),j=`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${t?"border-[hsl(var(--ring))] bg-[hsl(var(--card))] text-[hsl(var(--card-foreground))] dark:bg-[hsl(var(--card))] dark:text-[hsl(var(--card-foreground))]":""} ${m}`;return u.jsx("form",{onSubmit:R=>void Q(R),className:`w-full ${p}`,children:u.jsxs("div",{className:"flex items-end gap-2",children:[u.jsxs("div",{className:"flex-1",children:[u.jsx(Ka,{ref:T,value:S,onChange:$,onKeyDown:_,placeholder:t?"Edit your message...":n,className:j,disabled:o,maxLength:s,rows:1,spellCheck:!1,autoCorrect:"off"}),F&&u.jsx("p",{className:"mt-1 text-xs text-destructive font-medium",children:F})]}),u.jsx("div",{children:r?u.jsx(ct,{type:"button",onClick:()=>{d==null||d()},size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",disabled:o||!d,children:u.jsx(fe.Square,{size:16})}):u.jsx(ct,{type:"submit",size:"icon",className:"shrink-0",title:t?"Save changes":"Send message",disabled:o||!S.trim()&&!f||k,children:u.jsx(fe.Send,{size:16})})})]})})}const oC=b.memo(yp),_s=0,Ln=1,Nr=2,Sp=4;function Cp(e){return()=>e}function sC(e){e()}function Tp(e,t){return n=>e(t(n))}function kp(e,t){return()=>e(t)}function iC(e,t){return n=>e(t,n)}function qa(e){return e!==void 0}function aC(...e){return()=>{e.map(sC)}}function Ar(){}function js(e,t){return t(e),e}function lC(e,t){return t(e)}function ut(...e){return e}function rt(e,t){return e(Ln,t)}function ze(e,t){e(_s,t)}function Ga(e){e(Nr)}function bt(e){return e(Sp)}function Ce(e,t){return rt(e,iC(t,_s))}function un(e,t){const n=e(Ln,r=>{n(),t(r)});return n}function Ep(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function Ip(e,t){return e===t}function dt(e=Ip){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function Pe(e){return t=>n=>{e(n)&&t(n)}}function me(e){return t=>Tp(t,e)}function Sn(e){return t=>()=>{t(e)}}function ee(e,...t){const n=cC(...t);return(r,o)=>{switch(r){case Nr:Ga(e);return;case Ln:return rt(e,n(o))}}}function Cn(e,t){return n=>r=>{n(t=e(t,r))}}function tr(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 Ve(...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);rt(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 cC(...e){return t=>e.reduceRight(lC,t)}function uC(e){let t,n;const r=()=>t==null?void 0:t();return function(o,s){switch(o){case Ln:return s?n===s?void 0:(r(),n=s,t=rt(e,s),t):(r(),Ar);case Nr:r(),n=null;return}}}function se(e){let t=e;const n=Je();return(r,o)=>{switch(r){case _s:t=o;break;case Ln:{o(t);break}case Sp:return t}return n(r,o)}}function _t(e,t){return js(se(t),n=>Ce(e,n))}function Je(){const e=[];return(t,n)=>{switch(t){case _s:e.slice().forEach(r=>{r(n)});return;case Nr:e.splice(0,e.length);return;case Ln:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}}}function Xt(e){return js(Je(),t=>Ce(e,t))}function Qe(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:dC(),singleton:n}}const dC=()=>Symbol();function fC(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 Ct(...e){const t=Je(),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);rt(s,l=>{n[i]=l,r=r|a,r===o&&ze(t,n)})}),function(s,i){switch(s){case Nr:{Ga(t);return}case Ln:return r===o&&i(n),rt(t,i)}}}function _e(e,t=Ip){return ee(e,dt(t))}function Ya(...e){return function(t,n){switch(t){case Nr:return;case Ln:return aC(...e.map(r=>rt(r,n)))}}}var zt=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(zt||{});const pC={0:"debug",3:"error",1:"log",2:"warn"},hC=()=>typeof globalThis>"u"?window:globalThis,$n=Qe(()=>{const e=se(3);return{log:se((t,n,r=1)=>{var o;const s=(o=hC().VIRTUOSO_LOG_LEVEL)!=null?o:bt(e);r>=s&&console[pC[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0});function nr(e,t,n){return Xa(e,t,n).callbackRef}function Xa(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 mC(e,t,n,r,o,s,i,a,l){const c=b.useCallback(d=>{const p=gC(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?Np("column-gap",getComputedStyle(d).columnGap,o):Np("row-gap",getComputedStyle(d).rowGap,o)),p!==null&&e(p)},[e,t,o,s,i,r,a]);return Xa(c,n,l)}function gC(e,t,n,r){const o=e.length;if(o===0)return null;const s=[];for(let i=0;i<o;i++){const a=e.item(i);if(a.dataset.index===void 0)continue;const l=parseInt(a.dataset.index),c=parseFloat(a.dataset.knownSize),d=t(a,n);if(d===0&&r("Zero-sized element, this should not happen",{child:a},zt.ERROR),d===c)continue;const 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 Np(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,zt.WARN),t==="normal"?0:parseInt(t??"0",10)}function Ap(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}=Xa(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 Dt=Qe(()=>{const e=Je(),t=Je(),n=se(0),r=Je(),o=se(0),s=Je(),i=Je(),a=se(0),l=se(0),c=se(0),d=se(0),p=Je(),m=Je(),f=se(!1),v=se(!1),g=se(!1);return Ce(ee(e,me(({scrollTop:x})=>x)),t),Ce(ee(e,me(({scrollHeight:x})=>x)),i),Ce(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 _p(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 it(e){return e===lo}function co(e,t){if(!it(e))return t===e.k?e.v:t<e.k?co(e.l,t):co(e.r,t)}function dn(e,t,n="k"){if(it(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){const r=dn(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return dn(e.l,t,n)}function Jt(e,t,n){return it(e)?Mp(t,n,1):t===e.k?Et(e,{k:t,v:n}):t<e.k?Rp(Et(e,{l:Jt(e.l,t,n)})):Rp(Et(e,{r:Jt(e.r,t,n)}))}function _r(){return lo}function Ps(e,t,n){if(it(e))return[];const r=dn(e,t)[0];return xC(Za(e,r,n))}function Ja(e,t){if(it(e))return lo;const{k:n,l:r,r:o}=e;if(t===n){if(it(r))return o;if(it(o))return r;{const[s,i]=Pp(r);return Ms(Et(e,{k:s,l:jp(r),v:i}))}}else return t<n?Ms(Et(e,{l:Ja(r,t)})):Ms(Et(e,{r:Ja(o,t)}))}function rr(e){return it(e)?[]:[...rr(e.l),{k:e.k,v:e.v},...rr(e.r)]}function Za(e,t,n){if(it(e))return[];const{k:r,l:o,r:s,v:i}=e;let a=[];return r>t&&(a=a.concat(Za(o,t,n))),r>=t&&r<=n&&a.push({k:r,v:i}),r<=n&&(a=a.concat(Za(s,t,n))),a}function Ms(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(Qa(t))return Op(Et(e,{lvl:n-1}));if(!it(t)&&!it(t.r))return Et(t.r,{l:Et(t,{r:t.r.l}),lvl:n,r:Et(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(Qa(e))return el(Et(e,{lvl:n-1}));if(!it(r)&&!it(r.l)){const o=r.l,s=Qa(o)?r.lvl-1:r.lvl;return Et(o,{l:Et(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:el(Et(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function Et(e,t){return Mp(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 jp(e){return it(e.r)?e.l:Ms(Et(e,{r:jp(e.r)}))}function Qa(e){return it(e)||e.lvl>e.r.lvl}function Pp(e){return it(e.r)?[e.k,e.v]:Pp(e.r)}function Mp(e,t,n,r=lo,o=lo){return{k:e,l:r,lvl:n,r:o,v:t}}function Rp(e){return el(Op(e))}function Op(e){const{l:t}=e;return!it(t)&&t.lvl===e.lvl?Et(t,{r:Et(e,{l:t.r})}):e}function el(e){const{lvl:t,r:n}=e;return!it(n)&&!it(n.r)&&n.lvl===t&&n.r.lvl===t?Et(n,{l:Et(e,{r:n.l}),lvl:t+1}):e}function xC(e){return _p(e,({k:t,v:n})=>({index:t,value:n}))}function Dp(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 tl=Qe(()=>({recalcInProgress:se(!1)}),[],{singleton:!0});function Lp(e,t,n){return e[Rs(e,t,n)]}function Rs(e,t,n,r=0){let o=e.length-1;for(;r<=o;){const s=Math.floor((r+o)/2),i=e[s],a=n(i,t);if(a===0)return s;if(a===-1){if(o-r<2)return s-1;o=s-1}else{if(o===r)return s;r=s+1}}throw new Error(`Failed binary finding record in array - ${e.join(",")}, searched for ${t}`)}function vC(e,t,n,r){const o=Rs(e,t,r),s=Rs(e,n,r,o);return e.slice(o,s+1)}function Fn(e,t){return Math.round(e.getBoundingClientRect()[t])}function Os(e){return!it(e.groupOffsetTree)}function nl({index:e},t){return t===e?0:t<e?-1:1}function wC(){return{groupIndices:[],groupOffsetTree:_r(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:_r()}}function bC(e,t){let n=it(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),it(e)){e=Jt(e,0,s);continue}const a=Ps(e,i-1,o+1);if(a.some(IC(r)))continue;let l=!1,c=!1;for(const{end:d,start:p,value:m}of a)l?(o>=p||s===m)&&(e=Ja(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 yC(e){return typeof e.groupIndex<"u"}function SC({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}=Lp(t,e,nl),i=e-r,a=s*i+(i-1)*n+o;return a>0?a+n:a}function $p(e,t){if(!Os(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function Fp(e,t,n){if(yC(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=$p(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function CC(e,t,n,r=0){return r>0&&(t=Math.max(t,Lp(e,r,nl).offset)),_p(vC(e,t,n,SC),EC)}function TC(e,[t,n,r,o]){t.length>0&&r("received item sizes",t,zt.DEBUG);const s=e.sizeTree;let i=s,a=0;if(n.length>0&&it(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]=bC(i,t);if(i===s)return e;const{lastIndex:l,lastOffset:c,lastSize:d,offsetTree:p}=rl(e.offsetTree,a,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((m,f)=>Jt(m,f,fo(f,p,o)),_r()),lastIndex:l,lastOffset:c,lastSize:d,offsetTree:p,sizeTree:i}}function kC(e){return rr(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 Bp(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 rl(e,t,n,r){let o=e,s=0,i=0,a=0,l=0;if(t!==0){l=Rs(o,t-1,nl),a=o[l].offset;const c=dn(n,t-1);s=c[0],i=c[1],o.length&&o[l].size===dn(n,t)[1]&&(l-=1),o=o.slice(0,l+1)}else o=[];for(const{start:c,value:d}of Ps(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 EC(e){return{index:e.index,value:e}}function IC(e){const{endIndex:t,size:n,startIndex:r}=e;return o=>o.start===r&&(o.end===t||o.end===1/0)&&o.value===n}const NC={offsetHeight:"height",offsetWidth:"width"},Tn=Qe(([{log:e},{recalcInProgress:t}])=>{const n=Je(),r=Je(),o=_t(r,0),s=Je(),i=Je(),a=se(0),l=se([]),c=se(void 0),d=se(void 0),p=se((C,T)=>Fn(C,NC[T])),m=se(void 0),f=se(0),v=wC(),g=_t(ee(n,Ve(l,e,f),Cn(TC,v),dt()),v),x=_t(ee(l,dt(),Cn((C,T)=>({current:T,prev:C.current}),{current:[],prev:[]}),me(({prev:C})=>C)),[]);Ce(ee(l,Pe(C=>C.length>0),Ve(g,f),me(([C,T,E])=>{const A=C.reduce((O,F,U)=>Jt(O,F,fo(F,T.offsetTree,E)||U),_r());return{...T,groupIndices:C,groupOffsetTree:A}})),g),Ce(ee(r,Ve(g),Pe(([C,{lastIndex:T}])=>C<T),me(([C,{lastIndex:T,lastSize:E}])=>[{endIndex:T,size:E,startIndex:C}])),n),Ce(c,d);const y=_t(ee(c,me(C=>C===void 0)),!0);Ce(ee(d,Pe(C=>C!==void 0&&it(bt(g).sizeTree)),me(C=>[{endIndex:0,size:C,startIndex:0}])),n);const w=Xt(ee(n,Ve(g),Cn(({sizes:C},[T,E])=>({changed:E!==C,sizes:E}),{changed:!1,sizes:v}),me(C=>C.changed)));rt(ee(a,Cn((C,T)=>({diff:C.prev-T,prev:T}),{diff:0,prev:0}),me(C=>C.diff)),C=>{const{groupIndices:T}=bt(g);if(C>0)ze(t,!0),ze(s,C+Bp(C,T));else if(C<0){const E=bt(x);E.length>0&&(C-=Bp(-C,E)),ze(i,C)}}),rt(ee(a,Ve(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},zt.ERROR)});const S=Xt(s);Ce(ee(s,Ve(g),me(([C,T])=>{const E=T.groupIndices.length>0,A=[],O=T.lastSize;if(E){const F=co(T.sizeTree,0);let U=0,W=0;for(;U<C;){const N=T.groupIndices[W],q=T.groupIndices.length===W+1?1/0:T.groupIndices[W+1]-N-1;A.push({endIndex:N,size:F,startIndex:N}),A.push({endIndex:N+1+q-1,size:O,startIndex:N+1}),W++,U+=q+1}const z=rr(T.sizeTree);return U!==C&&z.shift(),z.reduce((N,{k:q,v:M})=>{let Q=N.ranges;return N.prevSize!==0&&(Q=[...N.ranges,{endIndex:q+C-1,size:N.prevSize,startIndex:N.prevIndex}]),{prevIndex:q+C,prevSize:M,ranges:Q}},{prevIndex:C,prevSize:0,ranges:A}).ranges}return rr(T.sizeTree).reduce((F,{k:U,v:W})=>({prevIndex:U+C,prevSize:W,ranges:[...F.ranges,{endIndex:U+C-1,size:F.prevSize,startIndex:F.prevIndex}]}),{prevIndex:0,prevSize:O,ranges:[]}).ranges})),n);const k=Xt(ee(i,Ve(g,f),me(([C,{offsetTree:T},E])=>{const A=-C;return fo(A,T,E)})));return Ce(ee(i,Ve(g,f),me(([C,T,E])=>{if(T.groupIndices.length>0){if(it(T.sizeTree))return T;let A=_r();const O=bt(x);let F=0,U=0,W=0;for(;F<-C;){W=O[U];const z=O[U+1]-W-1;U++,F+=z+1}if(A=rr(T.sizeTree).reduce((z,{k:N,v:q})=>Jt(z,Math.max(0,N+C),q),A),F!==-C){const z=co(T.sizeTree,W);A=Jt(A,0,z);const N=dn(T.sizeTree,-C+1)[1];A=Jt(A,1,N)}return{...T,sizeTree:A,...rl(T.offsetTree,0,A,E)}}else{const A=rr(T.sizeTree).reduce((O,{k:F,v:U})=>Jt(O,Math.max(0,F+C),U),_r());return{...T,sizeTree:A,...rl(T.offsetTree,0,A,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}},ut($n,tl),{singleton:!0});function AC(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const zp=Qe(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=Je(),i=Je(),a=Xt(ee(s,me(AC)));return Ce(ee(a,me(l=>l.totalCount)),n),Ce(ee(a,me(l=>l.groupIndices)),e),Ce(ee(Ct(o,t,r),Pe(([l,c])=>Os(c)),me(([l,c,d])=>dn(c.groupOffsetTree,Math.max(l-d,0),"v")[0]),dt(),me(l=>[l])),i),{groupCounts:s,topItemsIndexes:i}},ut(Tn,Dt)),Bn=Qe(([{log:e}])=>{const t=se(!1),n=Xt(ee(t,Pe(r=>r),dt()));return rt(t,r=>{r&&bt(e)("props updated",{},zt.DEBUG)}),{didMount:n,propsReady:t}},ut($n),{singleton:!0}),_C=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function Hp(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!_C)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const po=Qe(([{gap:e,listRefresh:t,sizes:n,totalCount:r},{fixedFooterHeight:o,fixedHeaderHeight:s,footerHeight:i,headerHeight:a,scrollingInProgress:l,scrollTo:c,smoothScrollTargetReached:d,viewportHeight:p},{log:m}])=>{const f=Je(),v=Je(),g=se(0);let x=null,y=null,w=null;function S(){x&&(x(),x=null),w&&(w(),w=null),y&&(clearTimeout(y),y=null),ze(l,!1)}return Ce(ee(f,Ve(n,p,r,g,a,i,m),Ve(e,s,o),me(([[k,C,T,E,A,O,F,U],W,z,N])=>{const q=Hp(k),{align:M,behavior:Q,offset:$}=q,_=E-1,V=Fp(q,C,_);let J=fo(V,C.offsetTree,W)+O;M==="end"?(J+=z+dn(C.sizeTree,V)[1]-T+N,V===_&&(J+=F)):M==="center"?J+=(z+dn(C.sizeTree,V)[1]-T+N)/2:J-=A,$&&(J+=$);const j=R=>{S(),R?(U("retrying to scroll to",{location:k},zt.DEBUG),ze(f,k)):(ze(v,!0),U("list did not change, scroll successful",{},zt.DEBUG))};if(S(),Q==="smooth"){let R=!1;w=rt(t,G=>{R=R||G}),x=un(d,()=>{j(R)})}else x=un(ee(t,jC(150)),j);return y=setTimeout(()=>{S()},1200),ze(l,!0),U("scrolling from index to",{behavior:Q,index:V,top:J},zt.DEBUG),{behavior:Q,top:J}})),c),{scrollTargetReached:v,scrollToIndex:f,topListHeight:g}},ut(Tn,Dt,$n),{singleton:!0});function jC(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function ol(e,t){e==0?t():requestAnimationFrame(()=>{ol(e-1,t)})}function sl(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const ho=Qe(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:s},{didMount:i}])=>{const a=se(!0),l=se(0),c=se(!0);return Ce(ee(i,Ve(l),Pe(([d,p])=>!!p),Sn(!1)),a),Ce(ee(i,Ve(l),Pe(([d,p])=>!!p),Sn(!1)),c),rt(ee(Ct(t,i),Ve(a,n,e,c),Pe(([[,d],p,{sizeTree:m},f,v])=>d&&(!it(m)||qa(f))&&!p&&!v),Ve(l)),([,d])=>{un(o,()=>{ze(c,!0)}),ol(4,()=>{un(r,()=>{ze(a,!0)}),ze(s,d)})}),{initialItemFinalLocationReached:c,initialTopMostItemIndex:l,scrolledToInitialItem:a}},ut(Tn,Dt,po,Bn),{singleton:!0});function Up(e,t){return Math.abs(e-t)<1.01}const mo="up",go="down",PC="none",MC={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},RC=0,xo=Qe(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=se(!1),a=se(!0),l=Je(),c=Je(),d=se(4),p=se(RC),m=_t(ee(Ya(ee(_e(o),tr(1),Sn(!0)),ee(_e(o),tr(1),Sn(!1),Ep(100))),dt()),!1),f=_t(ee(Ya(ee(n,Sn(!0)),ee(n,Sn(!1),Ep(200))),dt()),!1);Ce(ee(Ct(_e(o),_e(p)),me(([w,S])=>w<=S),dt()),a),Ce(ee(a,In(50)),c);const v=Xt(ee(Ct(r,_e(s),_e(t),_e(e),_e(d)),Cn((w,[{scrollHeight:S,scrollTop:k},C,T,E,A])=>{const O=k+C-S>-A,F={scrollHeight:S,scrollTop:k,viewportHeight:C};if(O){let W,z;return k>w.state.scrollTop?(W="SCROLLED_DOWN",z=w.state.scrollTop-k):(W="SIZE_DECREASED",z=w.state.scrollTop-k||w.scrollTopDelta),{atBottom:!0,atBottomBecause:W,scrollTopDelta:z,state:F}}let U;return F.scrollHeight>w.state.scrollHeight?U="SIZE_INCREASED":C<w.state.viewportHeight?U="VIEWPORT_HEIGHT_DECREASING":k<w.state.scrollTop?U="SCROLLING_UPWARDS":U="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:U,state:F}},MC),dt((w,S)=>w&&w.atBottom===S.atBottom))),g=_t(ee(r,Cn((w,{scrollHeight:S,scrollTop:k,viewportHeight:C})=>{if(Up(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}),Pe(w=>w.changed),me(w=>w.jump)),0);Ce(ee(v,me(w=>w.atBottom)),i),Ce(ee(i,In(50)),l);const x=se(go);Ce(ee(r,me(({scrollTop:w})=>w),dt(),Cn((w,S)=>bt(f)?{direction:w.direction,prevScrollTop:S}:{direction:S<w.prevScrollTop?mo:go,prevScrollTop:S},{direction:go,prevScrollTop:0}),me(w=>w.direction)),x),Ce(ee(r,In(50),Sn(PC)),x);const y=se(0);return Ce(ee(m,Pe(w=>!w),Sn(0)),y),Ce(ee(o,In(100),Ve(m),Pe(([w,S])=>!!S),Cn(([w,S],[k])=>[S,k],[0,0]),me(([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}},ut(Dt)),Ds="top",Ls="bottom",Wp="none";function Vp(e,t,n){return typeof e=="number"?n===mo&&t===Ds||n===go&&t===Ls?e:0:n===mo?t===Ds?e.main:e.reverse:t===Ls?e.main:e.reverse}function Kp(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const il=Qe(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=Je(),i=se(0),a=se(0),l=se(0),c=_t(ee(Ct(_e(r),_e(o),_e(n),_e(s,uo),_e(l),_e(i),_e(t),_e(e),_e(a)),me(([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=Wp;const A=Kp(S,Ds),O=Kp(S,Ls);return f-=w,f+=m+y,v+=m+y,v-=w,f>d+C-A&&(E=mo),v<d-T+p+O&&(E=go),E!==Wp?[Math.max(k-m-Vp(g,Ds,E)-A,0),k-T-y+p+Vp(g,Ls,E)+O]:null}),Pe(d=>d!=null),dt(uo)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:l,topListHeight:i,visibleRange:c}},ut(Dt),{singleton:!0});function OC(e,t,n){if(Os(t)){const r=$p(e,t);return[{index:dn(t.groupOffsetTree,r)[0],offset:0,size:0},{data:n==null?void 0:n[0],index:r,offset:0,size:0}]}return[{data:n==null?void 0:n[0],index:e,offset:0,size:0}]}const al={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function $s(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:Gp(e,o,s),offsetBottom:v,offsetTop:c,top:f,topItems:Gp(t,o,s),topListHeight:t.reduce((g,x)=>x.size+g,0),totalCount:n}}function qp(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=sl(t,a),c=Array.from({length:a}).map((d,p)=>({data:s[p+l],index:p+l,offset:0,size:0}));return $s(c,[],a,o,n,r)}function Gp(e,t,n){if(e.length===0)return[];if(!Os(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=Ps(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 or=Qe(([{data:e,firstItemIndex:t,gap:n,sizes:r,totalCount:o},s,{listBoundary:i,topListHeight:a,visibleRange:l},{initialTopMostItemIndex:c,scrolledToInitialItem:d},{topListHeight:p},m,{didMount:f},{recalcInProgress:v}])=>{const g=se([]),x=se(0),y=Je();Ce(s.topItemsIndexes,g);const w=_t(ee(Ct(f,v,_e(l,uo),_e(o),_e(r),_e(c),d,_e(g),_e(t),_e(n),e),Pe(([T,E,,A,,,,,,,O])=>{const F=O&&O.length!==A;return T&&!E&&!F}),me(([,,[T,E],A,O,F,U,W,z,N,q])=>{const M=O,{offsetTree:Q,sizeTree:$}=M,_=bt(x);if(A===0)return{...al,totalCount:A};if(T===0&&E===0)return _===0?{...al,totalCount:A}:qp(_,F,O,z,N,q||[]);if(it($))return _>0?null:$s(OC(sl(F,A),M,q),[],A,N,M,z);const V=[];if(W.length>0){const Y=W[0],ie=W[W.length-1];let H=0;for(const D of Ps($,Y,ie)){const X=D.value,Z=Math.max(D.start,Y),ce=Math.min(D.end,ie);for(let L=Z;L<=ce;L++)V.push({data:q==null?void 0:q[L],index:L,offset:H,size:X}),H+=X}}if(!U)return $s([],V,A,N,M,z);const J=W.length>0?W[W.length-1]+1:0,j=CC(Q,T,E,J);if(j.length===0)return null;const R=A-1,G=js([],Y=>{for(const ie of j){const H=ie.value;let D=H.offset,X=ie.start;const Z=H.size;if(H.offset<T){X+=Math.floor((T-H.offset+N)/(Z+N));const L=X-ie.start;D+=L*Z+L*N}X<J&&(D+=(J-X)*Z,X=J);const ce=Math.min(ie.end,R);for(let L=X;L<=ce&&!(D>=E);L++)Y.push({data:q==null?void 0:q[L],index:L,offset:D,size:Z}),D+=Z+N}});return $s(G,V,A,N,M,z)}),Pe(T=>T!==null),dt()),al);Ce(ee(e,Pe(qa),me(T=>T==null?void 0:T.length)),o),Ce(ee(w,me(T=>T.topListHeight)),p),Ce(p,a),Ce(ee(w,me(T=>[T.top,T.bottom])),i),Ce(ee(w,me(T=>T.items)),y);const S=Xt(ee(w,Pe(({items:T})=>T.length>0),Ve(o,e),Pe(([{items:T},E])=>T[T.length-1].originalIndex===E-1),me(([,T,E])=>[T-1,E]),dt(uo),me(([T])=>T))),k=Xt(ee(w,In(200),Pe(({items:T,topItems:E})=>T.length>0&&T[0].originalIndex===E.length),me(({items:T})=>T[0].index),dt())),C=Xt(ee(w,Pe(({items:T})=>T.length>0),me(({items:T})=>{let E=0,A=T.length-1;for(;T[E].type==="group"&&E<A;)E++;for(;T[A].type==="group"&&A>E;)A--;return{endIndex:T[A].index,startIndex:T[E].index}}),dt(Dp)));return{endReached:S,initialItemCount:x,itemsRendered:y,listState:w,rangeChanged:C,startReached:k,topItemsIndexes:g,...m}},ut(Tn,zp,il,ho,po,xo,Bn,tl),{singleton:!0}),Yp=Qe(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=Je(),i=_t(ee(Ct(n,e,r,t,o),me(([a,l,c,d,p])=>a+l+c+d+p.offsetBottom+p.bottom)),0);return Ce(_e(i),s),{totalListHeight:i,totalListHeightChanged:s}},ut(Dt,or),{singleton:!0}),DC=Qe(([{viewportHeight:e},{totalListHeight:t}])=>{const n=se(!1),r=_t(ee(Ct(n,e,t),Pe(([o])=>o),me(([,o,s])=>Math.max(0,o-s)),In(0),dt()),0);return{alignToBottom:n,paddingTopAddition:r}},ut(Dt,Yp),{singleton:!0}),Xp=Qe(()=>({context:se(null)})),LC=({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,Jp=Qe(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:s,scrollingInProgress:i,scrollTop:a,viewportHeight:l},{scrollToIndex:c}])=>{const d=Je();return Ce(ee(d,Ve(t,l,n,s,o,r,a),Ve(e),me(([[p,m,f,v,g,x,y,w],S])=>{const{align:k,behavior:C,calculateViewLocation:T=LC,done:E,...A}=p,O=Fp(p,m,v-1),F=fo(O,m.offsetTree,S)+g+x,U=F+dn(m.sizeTree,O)[1],W=w+x,z=w+f-y,N=T({itemBottom:U,itemTop:F,locationParams:{align:k,behavior:C,...A},viewportBottom:z,viewportTop:W});return N?E&&un(ee(i,Pe(q=>!q),tr(bt(i)?1:2)),E):E&&E(),N}),Pe(p=>p!==null)),c),{scrollIntoView:d}},ut(Tn,Dt,po,or,$n),{singleton:!0});function Zp(e){return e?e==="smooth"?"smooth":"auto":!1}const $C=(e,t)=>typeof e=="function"?Zp(e(t)):t&&Zp(e),FC=Qe(([{listRefresh:e,totalCount:t,fixedItemSize:n,data:r},{atBottomState:o,isAtBottom:s},{scrollToIndex:i},{scrolledToInitialItem:a},{didMount:l,propsReady:c},{log:d},{scrollingInProgress:p},{context:m},{scrollIntoView:f}])=>{const v=se(!1),g=Je();let x=null;function y(C){ze(i,{align:"end",behavior:C,index:"LAST"})}rt(ee(Ct(ee(_e(t),tr(1)),l),Ve(_e(v),s,a,p),me(([[C,T],E,A,O,F])=>{let U=T&&O,W="auto";return U&&(W=$C(E,A||F),U=U&&!!W),{followOutputBehavior:W,shouldFollow:U,totalCount:C}}),Pe(({shouldFollow:C})=>C)),({followOutputBehavior:C,totalCount:T})=>{x&&(x(),x=null),bt(n)?requestAnimationFrame(()=>{bt(d)("following output to ",{totalCount:T},zt.DEBUG),y(C)}):x=un(e,()=>{bt(d)("following output to ",{totalCount:T},zt.DEBUG),y(C),x=null})});function w(C){const T=un(o,E=>{C&&!E.atBottom&&E.notAtBottomBecause==="SIZE_INCREASED"&&!x&&(bt(d)("scrolling to bottom due to increased size",{},zt.DEBUG),y("auto"))});setTimeout(T,100)}rt(ee(Ct(_e(v),t,c),Pe(([C,,T])=>C&&T),Cn(({value:C},[,T])=>({refreshed:C===T,value:T}),{refreshed:!1,value:0}),Pe(({refreshed:C})=>C),Ve(v,t)),([,C])=>{bt(a)&&w(C!==!1)}),rt(g,()=>{w(bt(v)!==!1)}),rt(Ct(_e(v),o),([C,T])=>{C&&!T.atBottom&&T.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&y("auto")});const S=se(null),k=Je();return Ce(Ya(ee(_e(r),me(C=>{var T;return(T=C==null?void 0:C.length)!=null?T:0})),ee(_e(t))),k),rt(ee(Ct(ee(k,tr(1)),l),Ve(_e(S),a,p,m),me(([[C,T],E,A,O,F])=>T&&A&&(E==null?void 0:E({context:F,totalCount:C,scrollingInProgress:O}))),Pe(C=>!!C),In(0)),C=>{x&&(x(),x=null),bt(n)?requestAnimationFrame(()=>{bt(d)("scrolling into view",{}),ze(f,C)}):x=un(e,()=>{bt(d)("scrolling into view",{}),ze(f,C),x=null})}),{autoscrollToBottom:g,followOutput:v,scrollIntoViewOnChange:S}},ut(Tn,xo,po,ho,Bn,$n,Dt,Xp,Jp)),BC=Qe(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(Ce(ee(a,Ve(s),Pe(([,l])=>l!==0),Ve(o,r,t,n,e),me(([[,l],c,d,p,m,f=[]])=>qp(l,c,d,p,m,f))),i),{}),ut(Tn,ho,or,Bn),{singleton:!0}),zC=Qe(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=se(0);return rt(ee(e,Ve(r),Pe(([,o])=>o!==0),me(([,o])=>({top:o}))),o=>{un(ee(n,tr(1),Pe(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{ze(t,o)})})}),{initialScrollTop:r}},ut(Bn,Dt,or),{singleton:!0}),Qp=Qe(([{scrollVelocity:e}])=>{const t=se(!1),n=Je(),r=se(!1);return Ce(ee(e,Ve(r,t,n),Pe(([o,s])=>!!s),me(([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}),dt()),t),rt(ee(Ct(t,e,n),Ve(r)),([[o,s,i],a])=>{o&&a&&a.change&&a.change(s,i)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},ut(xo),{singleton:!0}),ll=Qe(([{scrollContainerState:e,scrollTo:t}])=>{const n=Je(),r=Je(),o=Je(),s=se(!1),i=se(void 0);return Ce(ee(Ct(n,r),me(([{scrollHeight:a,scrollTop:l,viewportHeight:c},{offsetTop:d}])=>({scrollHeight:a,scrollTop:Math.max(0,l-d),viewportHeight:c}))),e),Ce(ee(t,Ve(r),me(([a,{offsetTop:l}])=>({...a,top:a.top+l}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},ut(Dt)),HC=Qe(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:a,windowViewportRect:l}])=>{const c=Je(),d=se(void 0),p=se(null),m=se(null);return Ce(a,p),Ce(l,m),rt(ee(c,Ve(t,r,i,p,m,n)),([f,v,g,x,y,w,S])=>{const k=kC(v.sizeTree);x&&y!==null&&w!==null&&(g=y.scrollTop-w.offsetTop),g-=S,f({ranges:k,scrollTop:g})}),Ce(ee(d,Pe(qa),me(UC)),o),Ce(ee(s,Ve(d),Pe(([,f])=>f!==void 0),dt(),me(([,f])=>f.ranges)),e),{getState:c,restoreStateFrom:d}},ut(Tn,Dt,ho,Bn,ll));function UC(e){return{align:"start",index:0,offset:e.scrollTop}}const WC=Qe(([{topItemsIndexes:e}])=>{const t=se(0);return Ce(ee(t,Pe(n=>n>=0),me(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},ut(or));function eh(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const VC=eh(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),KC=Qe(([{deviation:e,scrollBy:t,scrollingInProgress:n,scrollTop:r},{isAtBottom:o,isScrolling:s,lastJumpDueToItemResize:i,scrollDirection:a},{listState:l},{beforeUnshiftWith:c,gap:d,shiftWithOffset:p,sizes:m},{log:f},{recalcInProgress:v}])=>{const g=Xt(ee(l,Ve(i),Cn(([,y,w,S],[{bottom:k,items:C,offsetBottom:T,totalCount:E},A])=>{const O=k+T;let F=0;return w===E&&y.length>0&&C.length>0&&(C[0].originalIndex===0&&y[0].originalIndex===0||(F=O-S,F!==0&&(F+=A))),[F,C,E,O]},[0,[],0,0]),Pe(([y])=>y!==0),Ve(r,a,n,o,f,v),Pe(([,y,w,S,,,k])=>!k&&!S&&y!==0&&w===mo),me(([[y],,,,,w])=>(w("Upward scrolling compensation",{amount:y},zt.DEBUG),y))));function x(y){y>0?(ze(t,{behavior:"auto",top:-y}),ze(e,0)):(ze(e,0),ze(t,{behavior:"auto",top:-y}))}return rt(ee(g,Ve(e,s)),([y,w,S])=>{S&&VC()?ze(e,w-y):x(-y)}),rt(ee(Ct(_t(s,!1),e,v),Pe(([y,w,S])=>!y&&!S&&w!==0),me(([y,w])=>w),In(1)),x),Ce(ee(p,me(y=>({top:-y}))),t),rt(ee(c,Ve(m,d),me(([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 A=co(k,0);let O=0,F=0;for(;O<y;){O++,E+=A;let U=w.length===F+1?1/0:w[F+1]-w[F]-1;O+U>y&&(E-=A,U=y-O+1),O+=U,E+=T(U),F++}return E}})),y=>{ze(e,y),requestAnimationFrame(()=>{ze(t,{top:y}),requestAnimationFrame(()=>{ze(e,0),ze(v,!1)})})}),{deviation:e}},ut(Dt,xo,or,Tn,$n,tl)),qC=Qe(([e,t,n,r,o,s,i,a,l,c,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...l,...c,...d}),ut(il,BC,Bn,Qp,Yp,zC,DC,ll,Jp,$n,Xp)),th=Qe(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:r,gap:o,groupIndices:s,itemSize:i,sizeRanges:a,sizes:l,statefulTotalCount:c,totalCount:d,trackItemSizes:p},{initialItemFinalLocationReached:m,initialTopMostItemIndex:f,scrolledToInitialItem:v},g,x,y,{listState:w,topItemsIndexes:S,...k},{scrollToIndex:C},T,{topItemCount:E},{groupCounts:A},O])=>(Ce(k.rangeChanged,O.scrollSeekRangeChanged),Ce(ee(O.windowViewportRect,me(F=>F.visibleHeight)),g.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,gap:o,groupCounts:A,initialItemFinalLocationReached:m,initialTopMostItemIndex:f,scrolledToInitialItem:v,sizeRanges:a,topItemCount:E,topItemsIndexes:S,totalCount:d,...y,groupIndices:s,itemSize:i,listState:w,scrollToIndex:C,statefulTotalCount:c,trackItemSizes:p,...k,...O,...g,sizes:l,...x}),ut(Tn,ho,Dt,HC,FC,or,po,KC,WC,zp,qC));function GC(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 Fs=typeof document<"u"?b.useLayoutEffect:b.useEffect;function nh(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&&ze(x.propsReady,!1);for(const w of r){const S=x[t.required[w]];ze(S,y[w])}for(const w of o)if(w in y){const S=x[t.optional[w]];ze(S,y[w])}x.propsReady&&ze(x.propsReady,!0)}function c(x){return s.reduce((y,w)=>(y[w]=S=>{const k=x[t.methods[w]];ze(k,S)},y),{})}function d(x){return i.reduce((y,w)=>(y[w]=uC(x[t.events[w]]),y),{})}const p=b.forwardRef((x,y)=>{const{children:w,...S}=x,[k]=b.useState(()=>js(fC(e),E=>{l(E,S)})),[C]=b.useState(kp(d,k));Fs(()=>{for(const E of i)E in S&&rt(C[E],S[E]);return()=>{Object.values(C).map(Ga)}},[S,C,k]),Fs(()=>{l(k,S)}),b.useImperativeHandle(y,Cp(c(k)));const T=n;return u.jsx(a.Provider,{value:k,children:n?u.jsx(T,{...GC([...r,...o,...i],S),children:w}):w})}),m=x=>{const y=b.useContext(a);return b.useCallback(w=>{ze(y[x],w)},[y,x])},f=x=>{const y=b.useContext(a)[x],w=b.useCallback(S=>rt(y,S),[y]);return b.useSyncExternalStore(w,()=>bt(y),()=>bt(y))},v=x=>{const y=b.useContext(a)[x],[w,S]=b.useState(kp(bt,y));return Fs(()=>rt(y,k=>{k!==w&&S(Cp(k))}),[y,w]),w},g=b.version.startsWith("18")?f:v;return{Component:p,useEmitter:(x,y)=>{const w=b.useContext(a)[x];Fs(()=>rt(w,y),[y,w])},useEmitterValue:g,usePublisher:m}}const rh=b.createContext(void 0),oh=b.createContext(void 0),sh=typeof document<"u"?b.useLayoutEffect:b.useEffect;function cl(e){return"self"in e}function YC(e){return"body"in e}function ih(e,t,n,r=Ar,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(YC(x)||cl(x)){const w=cl(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():To.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;cl(f)?(x=Math.max(Fn(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=Fn(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)),Up(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 ul="-webkit-sticky",ah="sticky",dl=eh(()=>{if(typeof document>"u")return ah;const e=document.createElement("div");return e.style.position=ul,e.style.position===ul?ul:ah});function fl(e){return e}const XC=Qe(()=>{const e=se(a=>`Item ${a}`),t=se(a=>`Group ${a}`),n=se({}),r=se(fl),o=se("div"),s=se(Ar),i=(a,l=null)=>_t(ee(n,me(c=>c[a]),dt()),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")}}),JC=Qe(([e,t])=>({...e,...t}),ut(th,XC)),ZC=({height:e})=>u.jsx("div",{style:{height:e}}),QC={overflowAnchor:"none",position:dl(),zIndex:1},lh={overflowAnchor:"none"},eT={...lh,display:"inline-block",height:"100%"},ch=b.memo(function({showTopList:e=!1}){const t=Oe("listState"),n=en("sizeRanges"),r=Oe("useWindowScroll"),o=Oe("customScrollParent"),s=en("windowScrollContainerState"),i=en("scrollContainerState"),a=o||r?s:i,l=Oe("itemContent"),c=Oe("context"),d=Oe("groupContent"),p=Oe("trackItemSizes"),m=Oe("itemSize"),f=Oe("log"),v=en("gap"),g=Oe("horizontalDirection"),{callbackRef:x}=mC(n,m,p,e?Ar:a,f,v,o,g,Oe("skipAnimationFrameInResizeObserver")),[y,w]=b.useState(0);pl("deviation",N=>{y!==N&&w(N)});const S=Oe("EmptyPlaceholder"),k=Oe("ScrollSeekPlaceholder")||ZC,C=Oe("ListComponent"),T=Oe("ItemComponent"),E=Oe("GroupComponent"),A=Oe("computeItemKey"),O=Oe("isSeeking"),F=Oe("groupIndices").length>0,U=Oe("alignToBottom"),W=Oe("initialItemFinalLocationReached"),z=e?{}:{boxSizing:"border-box",...g?{display:"inline-block",height:"100%",marginLeft:y!==0?y:U?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:y!==0?y:U?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...W?{}:{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:z,children:(e?t.topItems:t.items).map(N=>{const q=N.originalIndex,M=A(q+t.firstItemIndex,N.data,c);return O?b.createElement(k,{...jt(k,c),height:N.size,index:N.index,key:M,type:N.type||"item",...N.type==="group"?{}:{groupIndex:N.groupIndex}}):N.type==="group"?b.createElement(E,{...jt(E,c),"data-index":q,"data-item-index":N.index,"data-known-size":N.size,key:M,style:QC},d(N.index,c)):b.createElement(T,{...jt(T,c),...oT(T,N.data),"data-index":q,"data-item-group-index":N.groupIndex,"data-item-index":N.index,"data-known-size":N.size,key:M,style:g?eT:lh},F?l(N.index,N.groupIndex,N.data,c):l(N.index,N.data,c))})})}),tT={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},nT={outline:"none",overflowX:"auto",position:"relative"},Bs=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),rT={position:dl(),top:0,width:"100%",zIndex:1};function jt(e,t){if(typeof e!="string")return{context:t}}function oT(e,t){return{item:typeof e=="string"?void 0:t}}const sT=b.memo(function(){const e=Oe("HeaderComponent"),t=en("headerHeight"),n=Oe("HeaderFooterTag"),r=nr(b.useMemo(()=>s=>{t(Fn(s,"height"))},[t]),!0,Oe("skipAnimationFrameInResizeObserver")),o=Oe("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...jt(e,o)})}):null}),iT=b.memo(function(){const e=Oe("FooterComponent"),t=en("footerHeight"),n=Oe("HeaderFooterTag"),r=nr(b.useMemo(()=>s=>{t(Fn(s,"height"))},[t]),!0,Oe("skipAnimationFrameInResizeObserver")),o=Oe("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...jt(e,o)})}):null});function uh({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}=ih(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?nT:tT,...o},tabIndex:0,...i,...jt(l,s),children:r})})}function dh({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}=ih(a,c,l,v,m);return sh(()=>{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 aT=({children:e})=>{const t=b.useContext(rh),n=en("viewportHeight"),r=en("fixedItemHeight"),o=Oe("alignToBottom"),s=Oe("horizontalDirection"),i=b.useMemo(()=>Tp(n,l=>Fn(l,s?"width":"height")),[n,s]),a=nr(i,!0,Oe("skipAnimationFrameInResizeObserver"));return b.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),u.jsx("div",{"data-viewport-type":"element",ref:a,style:Bs(o),children:e})},lT=({children:e})=>{const t=b.useContext(rh),n=en("windowViewportRect"),r=en("fixedItemHeight"),o=Oe("customScrollParent"),s=Ap(n,o,Oe("skipAnimationFrameInResizeObserver")),i=Oe("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:Bs(i),children:e})},cT=({children:e})=>{const t=Oe("TopItemListComponent")||"div",n=Oe("headerHeight"),r={...rT,marginTop:`${n}px`},o=Oe("context");return u.jsx(t,{style:r,...jt(t,o),children:e})},uT=b.memo(function(e){const t=Oe("useWindowScroll"),n=Oe("topItemsIndexes").length>0,r=Oe("customScrollParent"),o=Oe("context");return u.jsxs(r||t?pT:fT,{...e,context:o,children:[n&&u.jsx(cT,{children:u.jsx(ch,{showTopList:!0})}),u.jsxs(r||t?lT:aT,{children:[u.jsx(sT,{}),u.jsx(ch,{}),u.jsx(iT,{})]})]})}),{Component:dT,useEmitter:pl,useEmitterValue:Oe,usePublisher:en}=nh(JC,{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"}},uT),fT=uh({useEmitter:pl,useEmitterValue:Oe,usePublisher:en}),pT=dh({useEmitter:pl,useEmitterValue:Oe,usePublisher:en}),hT=dT;ut(th,Qe(()=>{const e=se(c=>u.jsxs("td",{children:["Item $",c]})),t=se(null),n=se(c=>u.jsxs("td",{colSpan:1e3,children:["Group ",c]})),r=se(null),o=se(null),s=se({}),i=se(fl),a=se(Ar),l=(c,d=null)=>_t(ee(s,me(p=>p[c]),dt()),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")}})),dl();const fh={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},mT={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:ph,floor:zs,max:vo,min:hl,round:hh}=Math;function mh(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function gT(e){return{...mT,items:e}}function Hs(e,t){return e&&e.width===t.width&&e.height===t.height}function xT(e,t){return e&&e.column===t.column&&e.row===t.row}const vT=Qe(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:r},{footerHeight:o,headerHeight:s,scrollBy:i,scrollContainerState:a,scrollTo:l,scrollTop:c,smoothScrollTargetReached:d,viewportHeight:p},m,f,{didMount:v,propsReady:g},{customScrollParent:x,useWindowScroll:y,windowScrollContainerState:w,windowScrollTo:S,windowViewportRect:k},C])=>{const T=se(0),E=se(0),A=se(fh),O=se({height:0,width:0}),F=se({height:0,width:0}),U=Je(),W=Je(),z=se(0),N=se(null),q=se({column:0,row:0}),M=Je(),Q=Je(),$=se(!1),_=se(0),V=se(!0),J=se(!1),j=se(!1);rt(ee(v,Ve(_),Pe(([D,X])=>!!X)),()=>{ze(V,!1)}),rt(ee(Ct(v,V,F,O,_,J),Pe(([D,X,Z,ce,,L])=>D&&!X&&Z.height!==0&&ce.height!==0&&!L)),([,,,,D])=>{ze(J,!0),ol(1,()=>{ze(U,D)}),un(ee(c),()=>{ze(t,[0,0]),ze(V,!0)})}),Ce(ee(Q,Pe(D=>D!=null&&D.scrollTop>0),Sn(0)),E),rt(ee(v,Ve(Q),Pe(([,D])=>D!=null)),([,D])=>{D&&(ze(O,D.viewport),ze(F,D.item),ze(q,D.gap),D.scrollTop>0&&(ze($,!0),un(ee(c,tr(1)),X=>{ze($,!1)}),ze(l,{top:D.scrollTop})))}),Ce(ee(O,me(({height:D})=>D)),p),Ce(ee(Ct(_e(O,Hs),_e(F,Hs),_e(q,(D,X)=>D&&D.column===X.column&&D.row===X.row),_e(c)),me(([D,X,Z,ce])=>({gap:Z,item:X,scrollTop:ce,viewport:D}))),M),Ce(ee(Ct(_e(T),r,_e(q,xT),_e(F,Hs),_e(O,Hs),_e(N),_e(E),_e($),_e(V),_e(_)),Pe(([,,,,,,,D])=>!D),me(([D,[X,Z],ce,L,oe,xe,de,,we,Me])=>{const{column:He,row:$e}=ce,{height:Ae,width:Fe}=L,{width:Ge}=oe;if(de===0&&(D===0||Ge===0))return fh;if(Fe===0){const Re=sl(Me,D),mt=Re+Math.max(de-1,0);return gT(mh(Re,mt,xe))}const Ke=gh(Ge,Fe,He);let Xe,tt;we?X===0&&Z===0&&de>0?(Xe=0,tt=de-1):(Xe=Ke*zs((X+$e)/(Ae+$e)),tt=Ke*ph((Z+$e)/(Ae+$e))-1,tt=hl(D-1,vo(tt,Ke-1)),Xe=hl(tt,vo(0,Xe))):(Xe=0,tt=-1);const nt=mh(Xe,tt,xe),{bottom:Ze,top:pt}=xh(oe,ce,L,nt),ht=ph(D/Ke),Se=ht*Ae+(ht-1)*$e-Ze;return{bottom:Ze,itemHeight:Ae,items:nt,itemWidth:Fe,offsetBottom:Se,offsetTop:pt,top:pt}})),A),Ce(ee(N,Pe(D=>D!==null),me(D=>D.length)),T),Ce(ee(Ct(O,F,A,q),Pe(([D,X,{items:Z}])=>Z.length>0&&X.height!==0&&D.height!==0),me(([D,X,{items:Z},ce])=>{const{bottom:L,top:oe}=xh(D,ce,X,Z);return[oe,L]}),dt(uo)),t);const R=se(!1);Ce(ee(c,Ve(R),me(([D,X])=>X||D!==0)),R);const G=Xt(ee(Ct(A,T),Pe(([{items:D}])=>D.length>0),Ve(R),Pe(([[D,X],Z])=>{const ce=D.items[D.items.length-1].index===X-1;return(Z||D.bottom>0&&D.itemHeight>0&&D.offsetBottom===0&&D.items.length===X)&&ce}),me(([[,D]])=>D-1),dt())),Y=Xt(ee(_e(A),Pe(({items:D})=>D.length>0&&D[0].index===0),Sn(0),dt())),ie=Xt(ee(_e(A),Ve($),Pe(([{items:D},X])=>D.length>0&&!X),me(([{items:D}])=>({endIndex:D[D.length-1].index,startIndex:D[0].index})),dt(Dp),In(0)));Ce(ie,f.scrollSeekRangeChanged),Ce(ee(U,Ve(O,F,T,q),me(([D,X,Z,ce,L])=>{const oe=Hp(D),{align:xe,behavior:de,offset:we}=oe;let Me=oe.index;Me==="LAST"&&(Me=ce-1),Me=vo(0,Me,hl(ce-1,Me));let He=ml(X,L,Z,Me);return xe==="end"?He=hh(He-X.height+Z.height):xe==="center"&&(He=hh(He-X.height/2+Z.height/2)),we&&(He+=we),{behavior:de,top:He}})),l);const H=_t(ee(A,me(D=>D.offsetBottom+D.bottom)),0);return Ce(ee(k,me(D=>({height:D.visibleHeight,width:D.visibleWidth}))),O),{customScrollParent:x,data:N,deviation:z,footerHeight:o,gap:q,headerHeight:s,increaseViewportBy:e,initialItemCount:E,itemDimensions:F,overscan:n,restoreStateFrom:Q,scrollBy:i,scrollContainerState:a,scrollHeight:W,scrollTo:l,scrollToIndex:U,scrollTop:c,smoothScrollTargetReached:d,totalCount:T,useWindowScroll:y,viewportDimensions:O,windowScrollContainerState:w,windowScrollTo:S,windowViewportRect:k,...f,gridState:A,horizontalDirection:j,initialTopMostItemIndex:_,totalListHeight:H,...m,endReached:G,propsReady:g,rangeChanged:ie,startReached:Y,stateChanged:M,stateRestoreInProgress:$,...C}},ut(il,Dt,xo,Qp,Bn,ll,$n));function gh(e,t,n){return vo(1,zs((e+n)/(zs(t)+n)))}function xh(e,t,n,r){const{height:o}=n;if(o===void 0||r.length===0)return{bottom:0,top:0};const s=ml(e,t,n,r[0].index);return{bottom:ml(e,t,n,r[r.length-1].index)+o,top:s}}function ml(e,t,n,r){const o=gh(e.width,n.width,t.column),s=zs(r/o),i=s*n.height+vo(0,s-1)*t.row;return i>0?i+t.row:i}const wT=Qe(()=>{const e=se(p=>`Item ${p}`),t=se({}),n=se(null),r=se("virtuoso-grid-item"),o=se("virtuoso-grid-list"),s=se(fl),i=se("div"),a=se(Ar),l=(p,m=null)=>_t(ee(t,me(f=>f[p]),dt()),m),c=se(!1),d=se(!1);return Ce(_e(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")}}),bT=Qe(([e,t])=>({...e,...t}),ut(vT,wT)),yT=b.memo(function(){const e=ft("gridState"),t=ft("listClassName"),n=ft("itemClassName"),r=ft("itemContent"),o=ft("computeItemKey"),s=ft("isSeeking"),i=tn("scrollHeight"),a=ft("ItemComponent"),l=ft("ListComponent"),c=ft("ScrollSeekPlaceholder"),d=ft("context"),p=tn("itemDimensions"),m=tn("gap"),f=ft("log"),v=ft("stateRestoreInProgress"),g=tn("reportReadyState"),x=nr(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:wh("column-gap",getComputedStyle(y).columnGap,f),row:wh("row-gap",getComputedStyle(y).rowGap,f)})},[i,p,m,f]),!0,!1);return sh(()=>{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))})})}),ST=b.memo(function(){const e=ft("HeaderComponent"),t=tn("headerHeight"),n=ft("headerFooterTag"),r=nr(b.useMemo(()=>s=>{t(Fn(s,"height"))},[t]),!0,!1),o=ft("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...jt(e,o)})}):null}),CT=b.memo(function(){const e=ft("FooterComponent"),t=tn("footerHeight"),n=ft("headerFooterTag"),r=nr(b.useMemo(()=>s=>{t(Fn(s,"height"))},[t]),!0,!1),o=ft("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...jt(e,o)})}):null}),TT=({children:e})=>{const t=b.useContext(oh),n=tn("itemDimensions"),r=tn("viewportDimensions"),o=nr(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:Bs(!1),children:e})},kT=({children:e})=>{const t=b.useContext(oh),n=tn("windowViewportRect"),r=tn("itemDimensions"),o=ft("customScrollParent"),s=Ap(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:Bs(!1),children:e})},ET=b.memo(function({...e}){const t=ft("useWindowScroll"),n=ft("customScrollParent"),r=n||t?NT:IT,o=n||t?kT:TT,s=ft("context");return u.jsx(r,{...e,...jt(r,s),children:u.jsxs(o,{children:[u.jsx(ST,{}),u.jsx(yT,{}),u.jsx(CT,{})]})})}),{useEmitter:vh,useEmitterValue:ft,usePublisher:tn}=nh(bT,{optional:{context:"context",totalCount:"totalCount",overscan:"overscan",itemContent:"itemContent",components:"components",computeItemKey:"computeItemKey",data:"data",initialItemCount:"initialItemCount",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"headerFooterTag",listClassName:"listClassName",itemClassName:"itemClassName",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",restoreStateFrom:"restoreStateFrom",initialTopMostItemIndex:"initialTopMostItemIndex",increaseViewportBy:"increaseViewportBy"},methods:{scrollTo:"scrollTo",scrollBy:"scrollBy",scrollToIndex:"scrollToIndex"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",stateChanged:"stateChanged",readyStateChanged:"readyStateChanged"}},ET),IT=uh({useEmitter:vh,useEmitterValue:ft,usePublisher:tn}),NT=dh({useEmitter:vh,useEmitterValue:ft,usePublisher:tn});function wh(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,zt.WARN),t==="normal"?0:parseInt(t??"0",10)}const AT=Or.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 bh({className:e,variant:t,...n}){return u.jsx("div",{className:re(AT({variant:t}),e),...n})}const _T=1,jT=1e6;let gl=0;function PT(){return gl=(gl+1)%Number.MAX_SAFE_INTEGER,gl.toString()}const xl=new Map,yh=e=>{if(xl.has(e))return;const t=setTimeout(()=>{xl.delete(e),wo({type:"REMOVE_TOAST",toastId:e})},jT);xl.set(e,t)},MT=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,_T)};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?yh(n):e.toasts.forEach(r=>{yh(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)}}},Us=[];let Ws={toasts:[]};function wo(e){Ws=MT(Ws,e),Us.forEach(t=>{t(Ws)})}function RT({...e}){const t=PT(),n=o=>wo({type:"UPDATE_TOAST",toast:{...o,id:t}}),r=()=>wo({type:"DISMISS_TOAST",toastId:t});return wo({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:o=>{o||r()}}}),{id:t,dismiss:r,update:n}}function vl(){const[e,t]=h.useState(Ws);return h.useEffect(()=>(Us.push(t),()=>{const n=Us.indexOf(t);n>-1&&Us.splice(n,1)}),[e]),{...e,toast:RT,dismiss:n=>wo({type:"DISMISS_TOAST",toastId:n})}}function Sh({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}=vl(),m=b.useCallback(async()=>{if(n){i(!0),d(null),l(null);try{const y=await Ei(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 Xc(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 Ei(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(fe.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(ct,{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(fe.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(fe.Image,{className:"h-5 w-5"}):u.jsx(fe.FileText,{className:"h-5 w-5"});return u.jsx(oa,{open:e,onOpenChange:t,children:u.jsxs(os,{className:"max-w-4xl max-h-[90vh] overflow-hidden",children:[u.jsx(ss,{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(is,{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(ct,{variant:"outline",size:"sm",onClick:v,className:"flex items-center gap-2",children:[u.jsx(fe.ExternalLink,{className:"h-4 w-4"}),"External"]}),u.jsxs(ct,{variant:"outline",size:"sm",onClick:f,className:"flex items-center gap-2",children:[u.jsx(fe.Download,{className:"h-4 w-4"}),"Download"]})]})]})}),u.jsx("div",{className:"flex-1 overflow-hidden",children:g()})]})})}function Ch(){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 sr=Ch();function OT(e){sr=e}const Th=/[&<>"']/,DT=new RegExp(Th.source,"g"),kh=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,LT=new RegExp(kh.source,"g"),$T={"&":"&","<":"<",">":">",'"':""","'":"'"},Eh=e=>$T[e];function Pt(e,t){if(t){if(Th.test(e))return e.replace(DT,Eh)}else if(kh.test(e))return e.replace(LT,Eh);return e}const FT=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function Ih(e){return e.replace(FT,(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 BT=/(^|[^\[])\^/g;function at(e,t){e=typeof e=="string"?e:e.source,t=t||"";const n={replace:(r,o)=>(o=o.source||o,o=o.replace(BT,"$1"),e=e.replace(r,o),n),getRegex:()=>new RegExp(e,t)};return n}const zT=/[^\w:]/g,HT=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function Nh(e,t,n){if(e){let r;try{r=decodeURIComponent(Ih(n)).replace(zT,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}t&&!HT.test(n)&&(n=KT(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const Vs={},UT=/^[^:]+:\/*[^/]*$/,WT=/^([^:]+:)[\s\S]*$/,VT=/^([^:]+:\/*[^/]*)[\s\S]*$/;function KT(e,t){Vs[" "+e]||(UT.test(e)?Vs[" "+e]=e+"/":Vs[" "+e]=qs(e,"/",!0)),e=Vs[" "+e];const n=e.indexOf(":")===-1;return t.substring(0,2)==="//"?n?t:e.replace(WT,"$1")+t:t.charAt(0)==="/"?n?t:e.replace(VT,"$1")+t:e+t}const Ks={exec:function(){}};function Ah(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 qs(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 qT(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 GT(e){e&&e.sanitize&&!e.silent&&console.warn("marked(): sanitize and sanitizer parameters are deprecated since version 0.7.0, should not be used and will be removed in the future. Read more here: https://marked.js.org/#/USING_ADVANCED.md#options")}function _h(e,t){if(t<1)return"";let n="";for(;t>1;)t&1&&(n+=e),t>>=1,e+=e;return n+e}function jh(e,t,n,r){const o=t.href,s=t.title?Pt(t.title):null,i=e[1].replace(/\\([\[\]])/g,"$1");if(e[0].charAt(0)!=="!"){r.state.inLink=!0;const a={type:"link",raw:n,href:o,title:s,text:i,tokens:r.inlineTokens(i)};return r.state.inLink=!1,a}return{type:"image",raw:n,href:o,title:s,text:Pt(i)}}function YT(e,t){const n=e.match(/^(\s+)(?:```)/);if(n===null)return t;const r=n[1];return t.split(`
|
|
84
84
|
`).map(o=>{const s=o.match(/^\s+/);if(s===null)return o;const[i]=s;return i.length>=r.length?o.slice(r.length):o}).join(`
|
|
85
|
-
`)}class
|
|
86
|
-
`)}}}fences(t){const n=this.rules.block.fences.exec(t);if(n){const r=n[0],o=
|
|
85
|
+
`)}class wl{constructor(t){this.options=t||sr}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:qs(r,`
|
|
86
|
+
`)}}}fences(t){const n=this.rules.block.fences.exec(t);if(n){const r=n[0],o=YT(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=qs(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]):Pt(n[0]);r.type="paragraph",r.text=o,r.tokens=this.lexer.inline(o)}return r}}def(t){const n=this.rules.block.def.exec(t);if(n){const r=n[1].toLowerCase().replace(/\s+/g," "),o=n[2]?n[2].replace(/^<(.*)>$/,"$1").replace(this.rules.inline._escapes,"$1"):"",s=n[3]?n[3].substring(1,n[3].length-1).replace(this.rules.inline._escapes,"$1"):n[3];return{type:"def",tag:r,raw:n[0],href:o,title:s}}}table(t){const n=this.rules.block.table.exec(t);if(n){const r={type:"table",header:Ah(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]=Ah(r.rows[s],r.header.length).map(c=>({text:c}));for(o=r.header.length,i=0;i<o;i++)r.header[i].tokens=this.lexer.inline(r.header[i].text);for(o=r.rows.length,i=0;i<o;i++)for(l=r.rows[i],a=0;a<l.length;a++)l[a].tokens=this.lexer.inline(l[a].text);return r}}}lheading(t){const n=this.rules.block.lheading.exec(t);if(n)return{type:"heading",raw:n[0],depth:n[2].charAt(0)==="="?1:2,text:n[1],tokens:this.lexer.inline(n[1])}}paragraph(t){const n=this.rules.block.paragraph.exec(t);if(n){const r=n[1].charAt(n[1].length-1)===`
|
|
95
|
-
`?n[1].slice(0,-1):n[1];return{type:"paragraph",raw:n[0],text:r,tokens:this.lexer.inline(r)}}}text(t){const n=this.rules.block.text.exec(t);if(n)return{type:"text",raw:n[0],text:n[0],tokens:this.lexer.inline(n[0])}}escape(t){const n=this.rules.inline.escape.exec(t);if(n)return{type:"escape",raw:n[0],text:Pt(n[1])}}tag(t){const n=this.rules.inline.tag.exec(t);if(n)return!this.lexer.state.inLink&&/^<a /i.test(n[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&/^<\/a>/i.test(n[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(n[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(n[0])&&(this.lexer.state.inRawBlock=!1),{type:this.options.sanitize?"text":"html",raw:n[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(n[0]):Pt(n[0]):n[0]}}link(t){const n=this.rules.inline.link.exec(t);if(n){const r=n[2].trim();if(!this.options.pedantic&&/^</.test(r)){if(!/>$/.test(r))return;const i=
|
|
96
|
-
]`).replace("lheading",Ne.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()};const ge={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:
|
|
95
|
+
`?n[1].slice(0,-1):n[1];return{type:"paragraph",raw:n[0],text:r,tokens:this.lexer.inline(r)}}}text(t){const n=this.rules.block.text.exec(t);if(n)return{type:"text",raw:n[0],text:n[0],tokens:this.lexer.inline(n[0])}}escape(t){const n=this.rules.inline.escape.exec(t);if(n)return{type:"escape",raw:n[0],text:Pt(n[1])}}tag(t){const n=this.rules.inline.tag.exec(t);if(n)return!this.lexer.state.inLink&&/^<a /i.test(n[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&/^<\/a>/i.test(n[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(n[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(n[0])&&(this.lexer.state.inRawBlock=!1),{type:this.options.sanitize?"text":"html",raw:n[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(n[0]):Pt(n[0]):n[0]}}link(t){const n=this.rules.inline.link.exec(t);if(n){const r=n[2].trim();if(!this.options.pedantic&&/^</.test(r)){if(!/>$/.test(r))return;const i=qs(r.slice(0,-1),"\\");if((r.length-i.length)%2===0)return}else{const i=qT(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)),jh(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 jh(r,o,r[0],this.lexer)}}emStrong(t,n,r=""){let o=this.rules.inline.emStrong.lDelim.exec(t);if(!o||o[3]&&r.match(/[\p{L}\p{N}]/u))return;const s=o[1]||o[2]||"";if(!s||s&&(r===""||this.rules.inline.punctuation.exec(r))){const i=o[0].length-1;let a,l,c=i,d=0;const p=o[0][0]==="*"?this.rules.inline.emStrong.rDelimAst:this.rules.inline.emStrong.rDelimUnd;for(p.lastIndex=0,n=n.slice(-1*t.length+i);(o=p.exec(n))!=null;){if(a=o[1]||o[2]||o[3]||o[4]||o[5]||o[6],!a)continue;if(l=a.length,o[3]||o[4]){c+=l;continue}else if((o[5]||o[6])&&i%3&&!((i+l)%3)){d+=l;continue}if(c-=l,c>0)continue;l=Math.min(l,l+c+d);const m=t.slice(0,i+o.index+(o[0].length-a.length)+l);if(Math.min(i,l)%2){const v=m.slice(1,-1);return{type:"em",raw:m,text:v,tokens:this.lexer.inlineTokens(v)}}const f=m.slice(2,-2);return{type:"strong",raw:m,text:f,tokens:this.lexer.inlineTokens(f)}}}}codespan(t){const n=this.rules.inline.code.exec(t);if(n){let r=n[2].replace(/\n/g," ");const o=/[^ ]/.test(r),s=/^ /.test(r)&&/ $/.test(r);return o&&s&&(r=r.substring(1,r.length-1)),r=Pt(r,!0),{type:"codespan",raw:n[0],text:r}}}br(t){const n=this.rules.inline.br.exec(t);if(n)return{type:"br",raw:n[0]}}del(t){const n=this.rules.inline.del.exec(t);if(n)return{type:"del",raw:n[0],text:n[2],tokens:this.lexer.inlineTokens(n[2])}}autolink(t,n){const r=this.rules.inline.autolink.exec(t);if(r){let o,s;return r[2]==="@"?(o=Pt(this.options.mangle?n(r[1]):r[1]),s="mailto:"+o):(o=Pt(r[1]),s=o),{type:"link",raw:r[0],text:o,href:s,tokens:[{type:"text",raw:o,text:o}]}}}url(t,n){let r;if(r=this.rules.inline.url.exec(t)){let o,s;if(r[2]==="@")o=Pt(this.options.mangle?n(r[0]):r[0]),s="mailto:"+o;else{let i;do i=r[0],r[0]=this.rules.inline._backpedal.exec(r[0])[0];while(i!==r[0]);o=Pt(r[0]),r[1]==="www."?s="http://"+r[0]:s=r[0]}return{type:"link",raw:r[0],text:o,href:s,tokens:[{type:"text",raw:o,text:o}]}}}inlineText(t,n){const r=this.rules.inline.text.exec(t);if(r){let o;return this.lexer.state.inRawBlock?o=this.options.sanitize?this.options.sanitizer?this.options.sanitizer(r[0]):Pt(r[0]):r[0]:o=Pt(this.options.smartypants?n(r[0]):r[0]),{type:"text",raw:r[0],text:o}}}}const Ne={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:Ks,lheading:/^((?:.|\n(?!\n))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,text:/^[^\n]+/};Ne._label=/(?!\s*\])(?:\\.|[^\[\]\\])+/,Ne._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,Ne.def=at(Ne.def).replace("label",Ne._label).replace("title",Ne._title).getRegex(),Ne.bullet=/(?:[*+-]|\d{1,9}[.)])/,Ne.listItemStart=at(/^( *)(bull) */).replace("bull",Ne.bullet).getRegex(),Ne.list=at(Ne.list).replace(/bull/g,Ne.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+Ne.def.source+")").getRegex(),Ne._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",Ne._comment=/<!--(?!-?>)[\s\S]*?(?:-->|$)/,Ne.html=at(Ne.html,"i").replace("comment",Ne._comment).replace("tag",Ne._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Ne.paragraph=at(Ne._paragraph).replace("hr",Ne.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",Ne._tag).getRegex(),Ne.blockquote=at(Ne.blockquote).replace("paragraph",Ne.paragraph).getRegex(),Ne.normal={...Ne},Ne.gfm={...Ne.normal,table:"^ *([^\\n ].*\\|.*)\\n {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"},Ne.gfm.table=at(Ne.gfm.table).replace("hr",Ne.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",Ne._tag).getRegex(),Ne.gfm.paragraph=at(Ne._paragraph).replace("hr",Ne.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("table",Ne.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",Ne._tag).getRegex(),Ne.pedantic={...Ne.normal,html:at(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Ne._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:Ks,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:at(Ne.normal._paragraph).replace("hr",Ne.hr).replace("heading",` *#{1,6} *[^
|
|
96
|
+
]`).replace("lheading",Ne.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()};const ge={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:Ks,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:Ks,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,punctuation:/^([\spunctuation])/};ge._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",ge.punctuation=at(ge.punctuation).replace(/punctuation/g,ge._punctuation).getRegex(),ge.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g,ge.escapedEmSt=/(?:^|[^\\])(?:\\\\)*\\[*_]/g,ge._comment=at(Ne._comment).replace("(?:-->|$)","-->").getRegex(),ge.emStrong.lDelim=at(ge.emStrong.lDelim).replace(/punct/g,ge._punctuation).getRegex(),ge.emStrong.rDelimAst=at(ge.emStrong.rDelimAst,"g").replace(/punct/g,ge._punctuation).getRegex(),ge.emStrong.rDelimUnd=at(ge.emStrong.rDelimUnd,"g").replace(/punct/g,ge._punctuation).getRegex(),ge._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,ge._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,ge._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])?)+(?![-_])/,ge.autolink=at(ge.autolink).replace("scheme",ge._scheme).replace("email",ge._email).getRegex(),ge._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,ge.tag=at(ge.tag).replace("comment",ge._comment).replace("attribute",ge._attribute).getRegex(),ge._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,ge._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/,ge._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,ge.link=at(ge.link).replace("label",ge._label).replace("href",ge._href).replace("title",ge._title).getRegex(),ge.reflink=at(ge.reflink).replace("label",ge._label).replace("ref",Ne._label).getRegex(),ge.nolink=at(ge.nolink).replace("ref",Ne._label).getRegex(),ge.reflinkSearch=at(ge.reflinkSearch,"g").replace("reflink",ge.reflink).replace("nolink",ge.nolink).getRegex(),ge.normal={...ge},ge.pedantic={...ge.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:at(/^!?\[(label)\]\((.*?)\)/).replace("label",ge._label).getRegex(),reflink:at(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",ge._label).getRegex()},ge.gfm={...ge.normal,escape:at(ge.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.!#$%&'*+\/=?_`{\|}~-]+@)))/},ge.gfm.url=at(ge.gfm.url,"i").replace("email",ge.gfm._extended_email).getRegex(),ge.breaks={...ge.gfm,br:at(ge.br).replace("{2,}","*").getRegex(),text:at(ge.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()};function XT(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 zn{constructor(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||sr,this.options.tokenizer=this.options.tokenizer||new wl,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:Ne.normal,inline:ge.normal};this.options.pedantic?(n.block=Ne.pedantic,n.inline=ge.pedantic):this.options.gfm&&(n.block=Ne.gfm,this.options.breaks?n.inline=ge.breaks:n.inline=ge.gfm),this.tokenizer.rules=n}static get rules(){return{block:Ne,inline:ge}}static lex(t,n){return new zn(n).lex(t)}static lexInline(t,n){return new zn(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)+"["+_h("a",a[0].length-2)+"]"+i.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(a=this.tokenizer.rules.inline.blockSkip.exec(i))!=null;)i=i.slice(0,a.index)+"["+_h("a",a[0].length-2)+"]"+i.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;(a=this.tokenizer.rules.inline.escapedEmSt.exec(i))!=null;)i=i.slice(0,a.index+a[0].length-2)+"++"+i.slice(this.tokenizer.rules.inline.escapedEmSt.lastIndex),this.tokenizer.rules.inline.escapedEmSt.lastIndex--;for(;t;)if(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,
|
|
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)+"["+_h("a",a[0].length-2)+"]"+i.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(a=this.tokenizer.rules.inline.blockSkip.exec(i))!=null;)i=i.slice(0,a.index)+"["+_h("a",a[0].length-2)+"]"+i.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;(a=this.tokenizer.rules.inline.escapedEmSt.exec(i))!=null;)i=i.slice(0,a.index+a[0].length-2)+"++"+i.slice(this.tokenizer.rules.inline.escapedEmSt.lastIndex),this.tokenizer.rules.inline.escapedEmSt.lastIndex--;for(;t;)if(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,XT)){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 bl{constructor(t){this.options=t||sr}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+Pt(o)+'">'+(r?t:Pt(t,!0))+`</code></pre>
|
|
108
108
|
`:"<pre><code>"+(r?t:Pt(t,!0))+`</code></pre>
|
|
109
109
|
`}blockquote(t){return`<blockquote>
|
|
@@ -123,8 +123,8 @@ ${t}</blockquote>
|
|
|
123
123
|
`}tablerow(t){return`<tr>
|
|
124
124
|
${t}</tr>
|
|
125
125
|
`}tablecell(t,n){const r=n.header?"th":"td";return(n.align?`<${r} align="${n.align}">`:`<${r}>`)+t+`</${r}>
|
|
126
|
-
`}strong(t){return`<strong>${t}</strong>`}em(t){return`<em>${t}</em>`}codespan(t){return`<code>${t}</code>`}br(){return this.options.xhtml?"<br/>":"<br>"}del(t){return`<del>${t}</del>`}link(t,n,r){if(t=Nh(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=Nh(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 Mh{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 Rh{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 Hn{constructor(t){this.options=t||sr,this.options.renderer=this.options.renderer||new
|
|
127
|
-
`+(f.tokens?this.parseInline(f.tokens):f.text);r+=n?this.renderer.paragraph(m):m;continue}default:{const A='Token with "'+f.type+'" type was not found.';if(this.options.silent){console.error(A);return}else throw new Error(A)}}}return r}parseInline(t,n){n=n||this.renderer;let r="",o,s,i;const a=t.length;for(o=0;o<a;o++){if(s=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[s.type]&&(i=this.options.extensions.renderers[s.type].call({parser:this},s),i!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type))){r+=i||"";continue}switch(s.type){case"escape":{r+=n.text(s.text);break}case"html":{r+=n.html(s.text);break}case"link":{r+=n.link(s.href,s.title,this.parseInline(s.tokens,n));break}case"image":{r+=n.image(s.href,s.title,s.text);break}case"strong":{r+=n.strong(this.parseInline(s.tokens,n));break}case"em":{r+=n.em(this.parseInline(s.tokens,n));break}case"codespan":{r+=n.codespan(s.text);break}case"br":{r+=n.br();break}case"del":{r+=n.del(this.parseInline(s.tokens,n));break}case"text":{r+=n.text(s.text);break}default:{const l='Token with "'+s.type+'" type was not found.';if(this.options.silent){console.error(l);return}else throw new Error(l)}}}return r}}class
|
|
128
|
-
Please report this to https://github.com/markedjs/marked.`,e){const o="<p>An error occurred:</p><pre>"+Pt(r.message+"",!0)+"</pre>";if(t)return Promise.resolve(o);if(n){n(null,o);return}return o}if(t)return Promise.reject(r);if(n){n(r);return}throw r}}function Oh(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...ke.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(KT(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&&ke.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;ke.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(ke.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&&ke.walkTokens(a,r.walkTokens);let l=t(a,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(a){return i(a)}}}function ke(e,t,n){return Oh(zn.lex,Hn.parse)(e,t,n)}ke.options=ke.setOptions=function(e){return ke.defaults={...ke.defaults,...e},MT(ke.defaults),ke},ke.getDefaults=Ch,ke.defaults=sr,ke.use=function(...e){const t=ke.defaults.extensions||{renderers:{},childTokens:{}};e.forEach(n=>{const r={...n};if(r.async=ke.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=ke.defaults.renderer||new wl;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=ke.defaults.tokenizer||new vl;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=ke.defaults.hooks||new Ks;for(const s in n.hooks){const i=o[s];Ks.passThroughHooks.has(s)?o[s]=a=>{if(ke.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=ke.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}}ke.setOptions(r)})},ke.walkTokens=function(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(ke,r)),r.type){case"table":{for(const o of r.header)n=n.concat(ke.walkTokens(o.tokens,t));for(const o of r.rows)for(const s of o)n=n.concat(ke.walkTokens(s.tokens,t));break}case"list":{n=n.concat(ke.walkTokens(r.items,t));break}default:ke.defaults.extensions&&ke.defaults.extensions.childTokens&&ke.defaults.extensions.childTokens[r.type]?ke.defaults.extensions.childTokens[r.type].forEach(function(o){n=n.concat(ke.walkTokens(r[o],t))}):r.tokens&&(n=n.concat(ke.walkTokens(r.tokens,t)))}return n},ke.parseInline=Oh(zn.lexInline,Hn.parseInline),ke.Parser=Hn,ke.parser=Hn.parse,ke.Renderer=wl,ke.TextRenderer=Mh,ke.Lexer=zn,ke.lexer=zn.lex,ke.Tokenizer=vl,ke.Slugger=Rh,ke.Hooks=Ks,ke.parse=ke,ke.options,ke.setOptions,ke.use,ke.walkTokens,ke.parseInline,Hn.parse,zn.lex;function jr({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 ke.parse=="function"?ke.parse(i):ke(i)}return typeof ke.parse=="function"?ke.parse(e):ke(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:re("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 XT({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 JT({artifact:e}){const[t,n]=b.useState("bg-yellow-500/20 text-yellow-700 dark:text-yellow-300"),[r,o]=b.useState(u.jsx(fe.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(fe.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(fe.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(fe.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(fe.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(fe.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(jr,{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(fe.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 ZT({artifact:e,idx:t=0}){const n=b.useMemo(()=>e?(Array.isArray(e.plots)?e.plots:[]).map(o=>Av(o)).filter(o=>o!==null):[],[e]);return(e==null?void 0:e.type)==="research_task_info"?u.jsx(JT,{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(XT,{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 bl=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:re("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));bl.displayName="Card";const yl=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:re("flex flex-col space-y-1.5 p-6",e),...t}));yl.displayName="CardHeader";const Sl=h.forwardRef(({className:e,...t},n)=>u.jsx("h3",{ref:n,className:re("text-2xl font-semibold leading-none tracking-tight",e),...t}));Sl.displayName="CardTitle";const Cl=h.forwardRef(({className:e,...t},n)=>u.jsx("p",{ref:n,className:re("text-sm text-muted-foreground",e),...t}));Cl.displayName="CardDescription";const Tl=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:re("p-6 pt-0",e),...t}));Tl.displayName="CardContent";const Dh=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:re("flex items-center p-6 pt-0",e),...t}));Dh.displayName="CardFooter";function QT({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(bl,{className:re("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(yl,{className:"pb-3",children:[u.jsx(Sl,{className:"text-blue-900 dark:text-blue-100 text-base",children:i}),u.jsx(Cl,{className:"text-blue-700 dark:text-blue-300 text-sm",children:l})]}),a&&u.jsx(Tl,{className:"pt-0 pb-3",children:a}),u.jsx(Dh,{className:"pt-0",children:u.jsxs("div",{className:"flex gap-2 ml-auto",children:[u.jsx(ct,{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(ct,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",disabled:r||!o,children:"Approve"})]})})]})}const ek="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 Lh({data:e}){return Array.isArray(e)?e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?u.jsx("div",{className:ek,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 tk({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(fe.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 nk({message:e,viewMode:t,isStreaming:n=!1}){const o=Ni(e).name||"tool",s=l=>{if(l==null)return null;const c=typeof l=="string"?Ii(l)??l:l;if(c&&typeof c=="object")return u.jsx(Lh,{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}=Sv(l);return d?u.jsx(jr,{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=Vr(m);return i(f)}const c=Wr(l),d=Vr(c);return i(d)};return u.jsxs("div",{className:"space-y-2",children:[u.jsx(tk,{message:e,isStreaming:n}),t==="expanded"&&a()]})}function rk(e){const{allowFileOpen:t,currentThreadId:n}=e,{toast:r}=xl(),[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 Xc(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 ok({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:re("text-sm text-[hsl(var(--chat-bubble-user-text))]",o&&"text-xs"),children:t?u.jsx(jr,{content:e,allowHtml:!1}):u.jsxs("pre",{className:re("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(ct,{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(fe.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):u.jsxs(u.Fragment,{children:[u.jsx(fe.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",s," chars)"]})})]})}function sk({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:re("inline-block text-xs opacity-70 ml-1",e),children:["Is thinking",".".repeat(t)]})}function $h(e){var n;const t=(n=e.additionalKwargs)==null?void 0:n.toolProgress;return Array.isArray(t)?t:[]}const qs=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:A,defaultCheckpointId:O=null,messageParentCheckpointId:F=null}){const[U,W]=b.useState(!1),[z,N]=b.useState("preview"),[K,M]=b.useState(!1),{currentThreadId:Q}=Pi(),{respondToInterrupt:$}=Mi(),_=l==="phone"||l==="half-screen",V=t.role,J=V==="tool",j=b.useMemo(()=>"type"in t&&t.type==="default_message"?t:null,[t]),R=!!j,G=!(r&&V!=="user"),{uploadingFiles:Y,handleFileClick:ie,fileViewerOpen:H,currentFileInfo:D,closeFileViewer:X}=rk({allowFileOpen:G,currentThreadId:Q}),Z=b.useMemo(()=>{switch(V){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))]"}},[V]),ce=b.useMemo(()=>{if(j)return"";const P=t.content;return Array.isArray(P)?Cv(P):""},[j,t]),L=b.useMemo(()=>{if(j)return{};const P=t.content;return Array.isArray(P)?Ni(t):{}},[j,t]),oe=b.useMemo(()=>J?!!(t.additionalKwargs??{}).toolStreaming:!1,[J,t]),xe=b.useMemo(()=>{if(j)return[];const P=t.content;return Array.isArray(P)?P.filter(te=>te.type==="image_url"):[]},[j,t]),de=b.useMemo(()=>{if(j)return[];const P=t.content;return Array.isArray(P)?P.filter(te=>te.type==="file"):[]},[j,t]),we=b.useMemo(()=>{if(j)return[];const P=t.content;return Array.isArray(P)?P.filter(te=>te.type==="interrupt"):[]},[j,t]),Me=(w==null?void 0:w.id)??(w==null?void 0:w.interrupt_id),He=Bo(Me),$e=w==null?void 0:w.value,Ae=b.useMemo(()=>{if(j)return"";const P=t.content;return Array.isArray(P)?Tv(P):""},[j,t]),Fe=b.useMemo(()=>j||!m?null:t.artifact||null,[j,t,m]),Ge=b.useCallback(async()=>{const P=J?Ae:ce;async function te(ve){if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function"){await navigator.clipboard.writeText(ve);return}if(navigator.clipboard&&typeof navigator.clipboard.write=="function"&&typeof ClipboardItem<"u"){const ae=new Blob([ve],{type:"text/plain"});await navigator.clipboard.write([new ClipboardItem({"text/plain":ae})]);return}throw new Error("Clipboard API not supported in this context.")}try{await te(P),W(!0),setTimeout(()=>W(!1),2e3),y==null||y(P)}catch(ve){console.error("Failed to copy:",ve)}},[J,Ae,ce,y]),Ke=b.useCallback(()=>{if(!v||!t.id)return;const P=(J?Ae:ce)??"",te="type"in t&&t.type==="default_message"?void 0:{checkpointId:t.checkpointId??null,checkpointNs:t.checkpointNs??null};v(t.id,P,te)},[v,t.id,J,Ae,ce,t]),Xe=b.useCallback(()=>{g==null||g(n)},[g,n]),tt=b.useCallback(()=>{const te=re(_?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",Z);switch(V){case"user":return u.jsx(fe.User,{className:te});case"assistant":return u.jsx(fe.Bot,{className:te});case"tool":return u.jsx(fe.Wrench,{className:te});default:return u.jsx(fe.Bot,{className:te})}},[_,Z,V]),nt=b.useCallback(()=>{const P="group relative mb-4 flex w-full";switch(V){case"user":return re(P,"justify-end");case"assistant":case"tool":case"system":return re(P,"justify-start");default:return P}},[V]),Ze=b.useCallback(()=>{const P=re("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",_&&"px-3 py-2 text-sm");if(R)return re(P,"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(V){case"user":return re(P,"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 re(P,"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 re(P,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return re(P,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return re(P,"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")}},[_,R,V]),pt=b.useCallback(async P=>{if(S)return;const te=Bo((P==null?void 0:P.id)??(P==null?void 0:P.interrupt_id));if(!te){console.warn("Interrupt part missing id",P);return}try{k==null||k(),await $(te,!0)}catch(ve){console.error("Failed to approve interrupt:",ve)}finally{C==null||C()}},[S,C,k,$]),ht=b.useCallback(async P=>{if(S)return;const te=Bo((P==null?void 0:P.id)??(P==null?void 0:P.interrupt_id));if(!te){console.warn("Interrupt part missing id",P);return}try{k==null||k(),await $(te,!1)}catch(ve){console.error("Failed to reject interrupt:",ve)}finally{C==null||C()}},[S,C,k,$]),Se=b.useCallback(({part:P,i:te})=>{if(P.type==="text"){const ve=P.text??"",ae=ve.trim(),Ie=Ii(ae);return Ie&&V!=="tool"?u.jsx(Lh,{data:Ie},te):V==="user"&&c&&ae.length>d?u.jsx(ok,{text:ae,expanded:K,onExpandedChange:M,previewLength:d,isCompact:_},te):u.jsx(jr,{content:ve,allowHtml:!1},te)}if(P.type==="image_url"){const ve=P;return u.jsx("div",{className:"my-2",children:u.jsx("img",{src:ve.url,alt:ve.alt??"",loading:"lazy",className:"border rounded max-h-[420px] w-auto object-contain"})},te)}if(P.type==="file"){const ve=P,ae=ve.name||"file";return u.jsxs("a",{href:ve.url,onClick:Ie=>ie(Ie.nativeEvent,ve,te),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:[Y[te]?u.jsx(fe.Loader,{className:"h-4 w-4 animate-spin"}):null,u.jsxs("span",{className:"truncate max-w-[180px]",children:[ae,Y[te]?" (processing)":""]})]},te)}if(P.type==="interrupt"){const ve=P,ae=Bo((ve==null?void 0:ve.id)??(ve==null?void 0:ve.interrupt_id)),Ie=!!(He&&ae&&ae===He),Te=Ie?$e??(ve==null?void 0:ve.value):ve==null?void 0:ve.value,st=ae?{...ve,id:ae,interrupt_id:ae}:ve;return u.jsx(QT,{interruptPart:st,onApprove:pt,onReject:ht,disabled:S,isActive:Ie,payload:Te},te)}return null},[ie,Y,pt,ht,V,c,d,K,_,He,$e,w,S,we]),Re=b.useCallback(()=>u.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/30 rounded",children:[u.jsx(fe.Paperclip,{className:"h-4 w-4 text-muted-foreground"}),u.jsx("span",{className:"text-sm text-muted-foreground",children:"File upload"})]}),[]),mt=b.useCallback(()=>{const P=ce.trim().length>0||xe.length>0||de.length>0||we.length>0;if(!J&&de.length>0&&!r)return Re();if(!J&&!P&&!r)return null;if(J)return!p&&Fe?null:p?u.jsx(nk,{message:t,viewMode:z,isStreaming:oe},t.id):null;if(!J&&!j){const te=t,ve=u.jsx("div",{className:"space-y-2",children:te.content.map((ae,Ie)=>u.jsx(Se,{part:ae,i:Ie},Ie))});return r?u.jsxs("div",{"aria-busy":"true",role:"status",children:[ve,u.jsx(sk,{className:Z})]}):ve}},[ce,xe.length,de.length,we.length,r,J,z,p,Fe,Re,Z]),ot=b.useMemo(()=>j?"Assistant":kv(t),[j,t]),qe=b.useMemo(()=>j?[]:Array.isArray(T)?T:[],[T,j]),yt=b.useMemo(()=>{var P;return qe.length?O&&qe.some(te=>te.id===O)?O:((P=qe[0])==null?void 0:P.id)??null:null},[O,qe]),Be=b.useMemo(()=>!qe.length||!E?null:qe.some(P=>P.id===E)?E:null,[E,qe])??yt,St=V==="user"&&qe.length>0&&typeof A=="function",xt=b.useCallback((P,te=!1)=>{if(!A)return;const ve=(P==null?void 0:P.id)??null,ae=(P==null?void 0:P.parentId)??F??null;A(ve,ae,te)},[F,A]),Ye=b.useMemo(()=>Be?qe.findIndex(P=>P.id===Be):-1,[Be,qe]),gt=b.useMemo(()=>Ye<0?null:qe[Ye]??null,[Ye,qe]);return J&&!p&&!Fe?null:R&&j?u.jsx("div",{className:re(nt(),f.container),children:u.jsxs("div",{className:re(Ze(),f.content),children:[u.jsxs("div",{className:"flex items-center gap-2 mb-2 pb-2 border-b border-current/10",children:[u.jsx(fe.Bot,{className:re("h-4 w-4",Z)}),a&&u.jsx("span",{className:"font-medium text-sm",children:"Assistant"})]}),u.jsx(jr,{content:j.content,className:"text-current"})]})}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:re(nt(),f.container),children:u.jsxs("div",{className:re(Ze(),f.content),children:[(i||a||J)&&u.jsxs("div",{className:re("flex items-center justify-between mb-2 pb-2 border-b border-current/10",_&&"mb-1 pb-1",Z,f.header),children:[u.jsxs("div",{className:"flex items-center gap-2",children:[tt(),a&&ot&&u.jsx("span",{className:re("font-medium",_?"text-xs":"text-sm"),children:ot}),J&&u.jsxs(bh,{variant:"outline",className:re("text-xs flex items-center gap-1 cursor-pointer select-none",Z,"border border-current/40",_&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":z==="expanded",onClick:()=>N(P=>P==="expanded"?"preview":"expanded"),onKeyDown:P=>{(P.key==="Enter"||P.key===" ")&&(P.preventDefault(),N(te=>te==="expanded"?"preview":"expanded"))},children:[u.jsx("span",{children:L.name??"Tool Output"}),L.toolCallId&&u.jsx("span",{className:"opacity-70",children:L.toolCallId.slice(0,8)}),z==="expanded"?u.jsx(fe.ChevronUp,{className:"h-3 w-3"}):u.jsx(fe.ChevronDown,{className:"h-3 w-3"})]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[St&>&&Ye>=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:re("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",Ye<qe.length-1?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{if(Ye>=qe.length-1)return;const P=qe[Ye+1];P&&xt(P)},"aria-label":"Older checkpoint (back in time)",disabled:Ye>=qe.length-1,children:u.jsx(fe.ChevronLeft,{className:"h-3 w-3"})}),u.jsx("div",{className:"flex items-center gap-2",children:u.jsxs("span",{className:"whitespace-nowrap",children:[qe.length-Ye," / ",qe.length]})}),u.jsx("button",{type:"button",className:re("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",Ye>0?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{if(!(Ye<=0))if(Ye===1)xt(null,!0);else{const P=qe[Ye-1];P&&xt(P,!1)}},"aria-label":"Newer checkpoint (forward in time)",disabled:Ye<=0,children:u.jsx(fe.ChevronRight,{className:"h-3 w-3"})})]})}),i&&t.createdAt&&u.jsx("time",{className:re("text-xs opacity-60",Z,_&&"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:re("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",f.actions),children:[u.jsx("div",{className:"relative",children:u.jsx(ct,{variant:"ghost",size:"sm",onClick:()=>Ge(),className:re("h-6 w-6 p-0 hover:bg-foreground/10",Z,_&&"h-5 w-5"),"aria-label":"Copy message",title:"Copy message",children:u.jsx(fe.Copy,{className:re(U?"text-success":Z,_?"h-3 w-3":"h-4 w-4")})})}),V==="user"&&v&&u.jsx(ct,{variant:"ghost",size:"sm",onClick:Ke,className:re("h-6 w-6 p-0 hover:bg-foreground/10",Z,_&&"h-5 w-5"),"aria-label":"Edit message",children:u.jsx(fe.Edit,{className:re(Z,_?"h-3 w-3":"h-4 w-4")})}),V==="assistant"&&g&&u.jsx(ct,{variant:"ghost",size:"sm",onClick:Xe,className:re("h-6 w-6 p-0 hover:bg-foreground/10",Z,_&&"h-5 w-5"),"aria-label":"Regenerate response",children:u.jsx(fe.RotateCcw,{className:re(Z,_?"h-3 w-3":"h-4 w-4")})})]})]})]}),u.jsxs("div",{className:"relative",children:[mt(),m&&Fe&&u.jsx("div",{className:"mt-3",children:u.jsx(ZT,{artifact:Fe,idx:0})})]}),J&&z==="expanded"&&(L.toolCallId||L.name)&&u.jsxs("div",{className:re("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",_&&"text-xs"),children:[L.name&&u.jsxs("div",{children:["Function: ",L.name]}),L.toolCallId&&u.jsxs("div",{children:["Call ID: ",L.toolCallId]})]}),!(i||a||J)&&s&&!o&&u.jsxs("div",{className:re("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",f.actions),children:[u.jsx(ct,{variant:"ghost",size:"sm",onClick:()=>Ge(),className:re("h-6 w-6 p-0 hover:bg-background/50 text-current",_&&"h-5 w-5"),children:u.jsx(fe.Copy,{className:re(U?"text-success":"text-current",_?"h-3 w-3":"h-4 w-4")})}),V==="user"&&v&&u.jsx(ct,{variant:"ghost",size:"sm",onClick:Ke,className:re("h-6 w-6 p-0 hover:bg-background/50 text-current",_&&"h-5 w-5"),children:u.jsx(fe.Edit,{className:re("text-current",_?"h-3 w-3":"h-4 w-4")})}),V==="assistant"&&g&&u.jsx(ct,{variant:"ghost",size:"sm",onClick:Xe,className:re("h-6 w-6 p-0 hover:bg-background/50 text-current",_&&"h-5 w-5"),children:u.jsx(fe.RotateCcw,{className:re("text-current",_?"h-3 w-3":"h-4 w-4")})})]})]})}),D&&u.jsx(Sh,{isOpen:H,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&&du(e.message)===du(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=$h(e.message),a=$h(t.message);return i.length===a.length});qs.displayName="MessageComponent";const Fh=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,Bh=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=Fh(t,n),T="type"in t&&t.type==="default_message",A=!!t.__syntheticStreaming,{checkpointCandidates:O,defaultCheckpointId:F}=Gl(t,w??{checkpoints:[],checkpointMetaById:new Map,checkpointIndexByKey:new Map,attemptMetaById:new Map,userMessageIdToAttempts:new Map,timeline:[],messagePreviews:new Map,getLatest:()=>{},getCheckpoint:()=>{},getAttempts:()=>[]}),U=t&&!T?t.additionalKwargs??{}:{},W=t&&!T?t.responseMetadata??{}:{},z=(()=>{if(typeof U.parentCheckpointId=="string")return U.parentCheckpointId;if(typeof W.parentCheckpointId=="string")return W.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(qs,{message:t,messageIndex:n,isStreamingMessage:A||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:O,activeCheckpointId:S??null,onSelectCheckpoint:k,defaultCheckpointId:F,messageParentCheckpointId:z})})});Bh.displayName="MessageRow";const kl=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:A,activeCheckpointId:O,onSelectCheckpoint:F,createSyntheticThinkingMessage:U=!0},W)=>{const z=b.useRef(null),N=b.useRef(null),K=b.useRef(!1),M=b.useRef(!1),[Q,$]=b.useState(!0),_=b.useMemo(()=>w?e.some(L=>"type"in L&&L.type==="default_message"?!1:Array.isArray(L==null?void 0:L.content)&&L.content.some(oe=>oe&&oe.type==="interrupt"&&(oe.id??oe.interrupt_id)===w.id)):!1,[w,e]),V=b.useMemo(()=>{if(!w||_)return null;const L=w.id&&String(w.id).trim()?String(w.id).trim():"pending-interrupt";let oe;const xe=w.value;if(xe&&typeof xe=="object"&&!Array.isArray(xe)){const de=xe.title;typeof de=="string"&&de.trim()&&(oe=de.trim())}return{id:`interrupt-${L}`,role:"system",createdAt:new Date().toISOString(),content:[{type:"interrupt",id:L,value:xe,title:oe}]}},[w,_]),J=b.useMemo(()=>V?[...e,V]:e,[e,V]),j=b.useMemo(()=>!U||!t?J:!J.some(oe=>oe.role==="assistant")&&J.length>0?[...J,{id:"thinking-assistant",role:"assistant",content:[],createdAt:new Date().toISOString(),__syntheticStreaming:!0}]:J,[J,t,U]),R=b.useMemo(()=>T?j:j.filter(L=>(L==null?void 0:L.role)!=="tool"),[j,T]),G=b.useCallback(L=>{$(L),x&&x(!L),y&&y(L)},[x,y]),Y=b.useMemo(()=>{if(a)return async()=>{if(!K.current){K.current=!0;try{await a()}finally{K.current=!1}}}},[a]),ie=b.useMemo(()=>!v||g?!1:Q?"auto":!1,[Q,v,g]),H=b.useMemo(()=>{if(typeof f!="string")return null;const L=f.trim();return L?{id:"default-message",role:"assistant",type:"default_message",content:L,createdAt:new Date().toISOString()}:null},[f]),D=["flex h-full flex-col md:flex-row",p].filter(Boolean).join(" "),X=()=>H?u.jsx("div",{className:"p-6 h-full overflow-y-auto",children:u.jsx("div",{className:"w-full max-w-full",children:u.jsx(qs,{message:H,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!"}),Z=R.length,ce=Z>0;return b.useEffect(()=>{var L,oe;if(Z===0){M.current=!1;return}if(!M.current)if(M.current=!0,z.current&&R.length>0){const xe=R.length-1;(oe=(L=z.current).scrollToIndex)==null||oe.call(L,{index:xe,align:"end",behavior:"auto"})}else N.current&&(N.current.scrollTop=N.current.scrollHeight)},[Z,R.length]),b.useImperativeHandle(W,()=>({scrollToLatest:()=>{var L,oe;if(z.current&&R.length>0){const xe=R.length-1;(oe=(L=z.current).scrollToIndex)==null||oe.call(L,{index:xe,align:"end",behavior:"auto"})}else N.current&&(N.current.scrollTop=N.current.scrollHeight)},scrollToTop:()=>{var L,oe;z.current&&R.length>0?(oe=(L=z.current).scrollToIndex)==null||oe.call(L,{index:0,align:"start",behavior:"auto"}):N.current&&(N.current.scrollTop=0)}}),[R]),u.jsx("div",{className:D,style:m,children:u.jsx("div",{className:"relative flex-1 min-h-0",children:ce?u.jsx(fT,{ref:L=>{z.current=L},scrollerRef:L=>{N.current=L instanceof HTMLDivElement?L:null},data:R,followOutput:ie,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,startReached:()=>{Y&&Y()},atBottomStateChange:G,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(L,oe)=>Fh(oe,L),itemContent:(L,oe)=>u.jsx(Bh,{message:oe,index:L,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:A,activeCheckpointId:O,onSelectCheckpoint:F})}):X()})})});kl.displayName="MessageList";const zh={value:""};function bo({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}=ki(),{currentThreadId:y}=Pi(),{threadId:w,messages:S,isHistoryLoading:k,isLoading:C,navigateToCheckpoint:T,returnToLatest:E,checkpoint:A,checkpoints:O,interrupt:F,metadata:U,checkpointIndex:W}=Mi(),{isStreaming:z,error:N,connectionState:K,submit:M,stop:Q}=Su(),$=w??y??null,_=(A==null?void 0:A.id)??null,V=(A==null?void 0:A.namespace)??null,J=(U==null?void 0:U.assemblingMessageId)??null,j=F,[R,G]=b.useState(!1);b.useEffect(()=>{j||G(!1)},[j]);const Y=b.useCallback(()=>{G(!0)},[]),ie=b.useCallback(()=>{G(!1)},[]),H=!!j||R,[D,X]=b.useState(null),[Z,ce]=b.useState(""),[L,oe]=b.useState(null),[xe,de]=b.useState(null),[we,Me]=b.useState([]),[He,$e]=b.useState(0),[Ae,Fe]=b.useState(0),[Ge,Ke]=b.useState(!1),[Xe,tt]=b.useState(null),[nt,Ze]=b.useState(null),[pt,ht]=b.useState(!1),[Se,Re]=b.useState(null),mt=b.useRef(!1),[ot,qe]=b.useState(()=>zh.value),yt=b.useRef(ot),De=b.useRef(null),Be=b.useCallback(ue=>{zh.value=ue,qe(ue)},[]),[St,xt]=b.useState(!1),Ye=b.useRef(null),gt=b.useRef(null),P=b.useRef(null),te=b.useCallback(()=>{gt.current&&(gt.current.value=""),P.current&&(P.current.value=""),$e(ue=>ue+1),Fe(ue=>ue+1)},[]),ve=b.useCallback(ue=>{Be(ue)},[Be]),ae=b.useRef(!1);b.useEffect(()=>{ae.current&&!z&&(Me([]),te()),ae.current=z},[z,te]);const[Ie,Te]=b.useState("desktop");b.useEffect(()=>{const ue=()=>{const be=window.innerWidth;Te(be<640?"phone":be<1024?"tablet":"desktop")};return ue(),window.addEventListener("resize",ue),()=>window.removeEventListener("resize",ue)},[]),b.useEffect(()=>{mt.current=!1},[$]),b.useEffect(()=>{yt.current=ot},[ot]),b.useEffect(()=>{if(!D){De.current=null;return}De.current===null&&(De.current=yt.current),Be(Z??"")},[Z,D,Be]),b.useEffect(()=>{(async()=>{if(!x.baseUrl){Re(null);return}try{const he=(await x.getAgent("default")).uiDefaultMessage||"";Re(he||null)}catch(be){console.warn("Failed to fetch default message:",be),Re(null)}})()},[x.baseUrl]),b.useEffect(()=>{N&&!pt&&(g==null||g(N))},[N,pt,g]);const st=async ue=>{const be=ue.trim();if(!(!be&&we.length===0))try{const he=D?(L==null?void 0:L.checkpointId)??_??void 0:_??void 0,Ee=D?(L==null?void 0:L.checkpointNs)??V??void 0:V??void 0;await M({text:be||"",attachments:we},{checkpointId:he,checkpointNs:Ee,edit:!!D,originalMessageId:D??void 0}),f==null||f(be),Be(""),de(null),Me([]),te(),X(null),ce(""),oe(null)}catch(he){const Ee=(he==null?void 0:he.message)||"Failed to send message";de(Ee),g==null||g(Ee)}},Ue=b.useCallback((ue,be,he)=>{c&&(De.current=ot,X(ue),ce(be),Be(be),de(null),oe({checkpointId:(he==null?void 0:he.checkpointId)??null,checkpointNs:(he==null?void 0:he.checkpointNs)??null}))},[ot,c,Be]),lt=b.useCallback(()=>{X(null),ce(""),oe(null),de(null),Be(De.current??ot),De.current=null},[ot,Be]),Ut=b.useCallback((ue,be,he)=>{Ue(ue,be,he)},[Ue]),Mt=b.useCallback(ue=>{let be=null;for(let et=ue-1;et>=0;et--)if(S[et].role==="user"){be=S[et];break}if(!be)return;const he=Array.isArray(be.content)?be.content:[],Tt=he.filter(et=>(et==null?void 0:et.type)==="text").map(et=>et.text).join("")||(()=>{try{return JSON.stringify(he,null,2)}catch{return String(he)}})();Tt&&M({text:Tt},{checkpointId:_??void 0,checkpointNs:V??void 0,edit:!0,originalMessageId:be.id})},[S,M,_,V]),nn=ue=>{const be=Array.from(ue.target.files||[]);Me(he=>[...he,...be]),ue.target.value=""},Ul=ue=>{Me(be=>{const he=be.filter((Ee,Tt)=>ue!==Tt);return he.length===0&&te(),he})},Wl=async ue=>{const be=(ue.target.files||[])[0];if(be){tt(null),Ze(null),Ke(!0);try{await M({attachments:[be]},{checkpointId:_??void 0,checkpointNs:V??void 0});const he=`Uploaded ${be.name} - processing through chat stream`;Ze(he)}catch(he){const Ee=he instanceof Error?he.message:"Failed to upload Excel file";console.error("Excel upload failed",he),tt(Ee),g==null||g(Ee)}finally{Ke(!1),ue.target.value="",te()}}},ii=async ue=>{if(y){xt(!0);try{if(!ue){await E(),requestAnimationFrame(()=>{var Ee;(Ee=Ye.current)==null||Ee.scrollToLatest()});return}const be=O.find(Ee=>Ee.checkpointId===ue),he=(be==null?void 0:be.checkpointNs)??null;await T(ue,he),requestAnimationFrame(()=>{var Ee;(Ee=Ye.current)==null||Ee.scrollToTop()})}finally{xt(!1)}}},I=b.useCallback(async(ue,be,he)=>{await ii(he?null:ue)},[ii]),ne=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${m.container||""}`,pe=`flex-1 min-h-0 min-w-0 max-h-full w-full overflow-hidden overscroll-contain break-words break-anywhere p-4 bg-transparent ${m.messagesArea||""}`,je=`relative flex-shrink-0 w-full border-t p-4 bg-transparent ${m.inputArea||""}`;return u.jsxs("div",{className:ne,children:[!!N&&!pt&&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:N}),u.jsx(ct,{variant:"ghost",size:"sm",onClick:()=>ht(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:u.jsx(fe.X,{size:16})})]}),u.jsxs("div",{className:`relative ${pe}`,style:r?{maxHeight:r}:void 0,children:[u.jsx(kl,{ref:Ye,className:"h-full",style:{height:"100%"},messages:S,isStreaming:z,streamingAssistantId:J,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:Ie,enableMessageEditing:c,editingMessageId:D,onEdit:Ut,onRegenerate:Mt,onCancelEdit:lt,emptyMessage:Se??void 0,isNavigatingCheckpoint:St,activeInterrupt:j,disableInterruptActions:R,onInterruptActionStart:Y,onInterruptActionEnd:ie,showToolMessages:d,showArtifactPreviews:p,checkpointIndex:W,activeCheckpointId:_,onSelectCheckpoint:I,createSyntheticThinkingMessage:!0}),(K==="reconnecting"||K==="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(fe.Loader2,{className:"h-3 w-3 animate-spin"}),K==="reconnecting"?"Reconnecting…":"Connecting…"]})}),K==="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(fe.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading messages…"})]}),(k||St)&&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(fe.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:je,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(fe.Edit3,{size:16,className:"text-blue-600"}),u.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),u.jsx(ct,{variant:"ghost",size:"sm",onClick:lt,className:"text-blue-600 hover:bg-blue-100",children:u.jsx(fe.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:gt,type:"file",multiple:!0,onChange:ue=>nn(ue),className:"hidden"},He),we.length>0&&u.jsx("div",{className:"flex flex-wrap gap-2",children:we.map((ue,be)=>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(fe.Paperclip,{size:14}),u.jsx("span",{className:"truncate max-w-[150px]",children:ue.name}),u.jsx(ct,{variant:"ghost",size:"sm",onClick:()=>Ul(be),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 ${ue.name}`,children:u.jsx(fe.X,{size:12})})]},be))})]}),l&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:P,type:"file",accept:".xls,.xlsx,.xlsm",onChange:Wl,className:"hidden"},Ae),Ge&&u.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(fe.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),nt&&!Ge&&u.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:nt}),Xe&&!Ge&&u.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:Xe})]})]}),xe&&u.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:xe}),u.jsxs("div",{className:"flex items-end gap-2",children:[(a||l)&&u.jsxs(Ss,{children:[u.jsx(Cs,{asChild:!0,children:u.jsx(ct,{type:"button",size:"icon",variant:"outline",disabled:z||H,title:"More input actions",className:m.moreButton||"",children:u.jsx(fe.Plus,{size:16})})}),u.jsxs(ao,{align:"start",sideOffset:6,className:"w-52",children:[a&&u.jsxs(Dn,{onClick:()=>{var ue;return(ue=gt.current)==null?void 0:ue.click()},className:"cursor-pointer",children:[u.jsx(fe.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),l&&u.jsxs(Dn,{onClick:()=>{var ue;Ge||(ue=P.current)==null||ue.click()},className:`cursor-pointer ${Ge?"opacity-60 pointer-events-none":""}`,children:[u.jsx(fe.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),u.jsx("div",{className:"flex-1",children:u.jsx(nC,{initialValue:Z,editingMessageId:D,value:ot,onValueChange:ve,placeholder:D?"Edit your message...":t,isStreaming:z,disabled:H,onSend:st,onCancelEdit:lt,onStop:Q,allowEmptySend:we.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":""} ${xe?"border-red-400":""} ${m.textarea||""}`})})]})]})]})}function Hh({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(zo,{...s,onThreadChange:l,children:u.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:u.jsx(bo,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?u.jsx(zo,{...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(Wa,{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(bo,{onError:s.onError,enableFileUpload:!0})})]})})}):u.jsx(zo,{...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(Wa,{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(bo,{onError:s.onError,enableFileUpload:!0})})]})})}function ik({apiConfig:e,className:t="",onError:n}){return u.jsx(zo,{apiConfig:e,onError:n,children:u.jsx("div",{className:`h-full ${t}`,children:u.jsx(bo,{})})})}var ak="Label",Uh=h.forwardRef((e,t)=>u.jsx(ye.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())}}));Uh.displayName=ak;var Wh=Uh;const lk=Or.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Vh=h.forwardRef(({className:e,...t},n)=>u.jsx(Wh,{ref:n,className:re(lk(),e),...t}));Vh.displayName=Wh.displayName;function Kh(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 qh=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"}),ck="VisuallyHidden",Gs=h.forwardRef((e,t)=>u.jsx(ye.span,{...e,ref:t,style:{...qh,...e.style}}));Gs.displayName=ck;var uk=Gs,dk=[" ","Enter","ArrowUp","ArrowDown"],fk=[" ","Enter"],ir="Select",[Ys,Xs,pk]=ss(ir),[Pr,t1]=sn(ir,[pk,Er]),Js=Er(),[hk,Un]=Pr(ir),[mk,gk]=Pr(ir),Gh=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=Js(t),[x,y]=h.useState(null),[w,S]=h.useState(null),[k,C]=h.useState(!1),T=is(c),[E,A]=jn({prop:r,defaultProp:o??!1,onChange:s,caller:ir}),[O,F]=jn({prop:i,defaultProp:a,onChange:l,caller:ir}),U=h.useRef(null),W=x?v||!!x.closest("form"):!0,[z,N]=h.useState(new Set),K=Array.from(z).map(M=>M.props.value).join(";");return u.jsx(Ca,{...g,children:u.jsxs(hk,{required:f,scope:t,trigger:x,onTriggerChange:y,valueNode:w,onValueNodeChange:S,valueNodeHasChildren:k,onValueNodeHasChildrenChange:C,contentId:At(),value:O,onValueChange:F,open:E,onOpenChange:A,dir:T,triggerPointerDownPosRef:U,disabled:m,children:[u.jsx(Ys.Provider,{scope:t,children:u.jsx(mk,{scope:e.__scopeSelect,onNativeOptionAdd:h.useCallback(M=>{N(Q=>new Set(Q).add(M))},[]),onNativeOptionRemove:h.useCallback(M=>{N(Q=>{const $=new Set(Q);return $.delete(M),$})},[]),children:n})}),W?u.jsxs(vm,{"aria-hidden":!0,required:f,tabIndex:-1,name:d,autoComplete:p,value:O,onChange:M=>F(M.target.value),disabled:m,form:v,children:[O===void 0?u.jsx("option",{value:""}):null,Array.from(z)]},K):null]})})};Gh.displayName=ir;var Yh="SelectTrigger",Xh=h.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=Js(n),i=Un(Yh,n),a=i.disabled||r,l=We(t,i.onTriggerChange),c=Xs(n),d=h.useRef("touch"),[p,m,f]=bm(g=>{const x=c().filter(S=>!S.disabled),y=x.find(S=>S.value===i.value),w=ym(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(ye.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":wm(i.value)?"":void 0,...o,ref:l,onClick:le(o.onClick,g=>{g.currentTarget.focus(),d.current!=="mouse"&&v(g)}),onPointerDown:le(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:le(o.onKeyDown,g=>{const x=p.current!=="";!(g.ctrlKey||g.altKey||g.metaKey)&&g.key.length===1&&m(g.key),!(x&&g.key===" ")&&dk.includes(g.key)&&(v(),g.preventDefault())})})})});Xh.displayName=Yh;var Jh="SelectValue",Zh=h.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=Un(Jh,n),{onValueNodeHasChildrenChange:c}=l,d=s!==void 0,p=We(t,l.onValueNodeChange);return It(()=>{c(d)},[c,d]),u.jsx(ye.span,{...a,ref:p,style:{pointerEvents:"none"},children:wm(l.value)?u.jsx(u.Fragment,{children:i}):s})});Zh.displayName=Jh;var xk="SelectIcon",Qh=h.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return u.jsx(ye.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});Qh.displayName=xk;var vk="SelectPortal",em=e=>u.jsx(qr,{asChild:!0,...e});em.displayName=vk;var ar="SelectContent",tm=h.forwardRef((e,t)=>{const n=Un(ar,e.__scopeSelect),[r,o]=h.useState();if(It(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?Dr.createPortal(u.jsx(nm,{scope:e.__scopeSelect,children:u.jsx(Ys.Slot,{scope:e.__scopeSelect,children:u.jsx("div",{children:e.children})})}),s):null}return u.jsx(rm,{...e,ref:t})});tm.displayName=ar;var fn=10,[nm,Wn]=Pr(ar),wk="SelectContentImpl",bk=Vt.createSlot("SelectContent.RemoveScroll"),rm=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=We(t,H=>k(H)),[A,O]=h.useState(null),[F,U]=h.useState(null),W=Xs(n),[z,N]=h.useState(!1),K=h.useRef(!1);h.useEffect(()=>{if(S)return Gi(S)},[S]),Hi();const M=h.useCallback(H=>{const[D,...X]=W().map(L=>L.ref.current),[Z]=X.slice(-1),ce=document.activeElement;for(const L of H)if(L===ce||(L==null||L.scrollIntoView({block:"nearest"}),L===D&&C&&(C.scrollTop=0),L===Z&&C&&(C.scrollTop=C.scrollHeight),L==null||L.focus(),document.activeElement!==ce))return},[W,C]),Q=h.useCallback(()=>M([A,S]),[M,A,S]);h.useEffect(()=>{z&&Q()},[z,Q]);const{onOpenChange:$,triggerPointerDownPosRef:_}=w;h.useEffect(()=>{if(S){let H={x:0,y:0};const D=Z=>{var ce,L;H={x:Math.abs(Math.round(Z.pageX)-(((ce=_.current)==null?void 0:ce.x)??0)),y:Math.abs(Math.round(Z.pageY)-(((L=_.current)==null?void 0:L.y)??0))}},X=Z=>{H.x<=10&&H.y<=10?Z.preventDefault():S.contains(Z.target)||$(!1),document.removeEventListener("pointermove",D),_.current=null};return _.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,$,_]),h.useEffect(()=>{const H=()=>$(!1);return window.addEventListener("blur",H),window.addEventListener("resize",H),()=>{window.removeEventListener("blur",H),window.removeEventListener("resize",H)}},[$]);const[V,J]=bm(H=>{const D=W().filter(ce=>!ce.disabled),X=D.find(ce=>ce.ref.current===document.activeElement),Z=ym(D,H,X);Z&&setTimeout(()=>Z.ref.current.focus())}),j=h.useCallback((H,D,X)=>{const Z=!K.current&&!X;(w.value!==void 0&&w.value===D||Z)&&(O(H),Z&&(K.current=!0))},[w.value]),R=h.useCallback(()=>S==null?void 0:S.focus(),[S]),G=h.useCallback((H,D,X)=>{const Z=!K.current&&!X;(w.value!==void 0&&w.value===D||Z)&&U(H)},[w.value]),Y=r==="popper"?El:om,ie=Y===El?{side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:p,collisionBoundary:m,collisionPadding:f,sticky:v,hideWhenDetached:g,avoidCollisions:x}:{};return u.jsx(nm,{scope:n,content:S,viewport:C,onViewportChange:T,itemRefCallback:j,selectedItem:A,onItemLeave:R,itemTextRefCallback:G,focusSelectedItem:Q,selectedItemText:F,position:r,isPositioned:z,searchRef:V,children:u.jsx(Yo,{as:bk,allowPinchZoom:!0,children:u.jsx(Ho,{asChild:!0,trapped:w.open,onMountAutoFocus:H=>{H.preventDefault()},onUnmountAutoFocus:le(o,H=>{var D;(D=w.trigger)==null||D.focus({preventScroll:!0}),H.preventDefault()}),children:u.jsx(mr,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:H=>H.preventDefault(),onDismiss:()=>w.onOpenChange(!1),children:u.jsx(Y,{role:"listbox",id:w.contentId,"data-state":w.open?"open":"closed",dir:w.dir,onContextMenu:H=>H.preventDefault(),...y,...ie,onPlaced:()=>N(!0),ref:E,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:le(y.onKeyDown,H=>{const D=H.ctrlKey||H.altKey||H.metaKey;if(H.key==="Tab"&&H.preventDefault(),!D&&H.key.length===1&&J(H.key),["ArrowUp","ArrowDown","Home","End"].includes(H.key)){let Z=W().filter(ce=>!ce.disabled).map(ce=>ce.ref.current);if(["ArrowUp","End"].includes(H.key)&&(Z=Z.slice().reverse()),["ArrowUp","ArrowDown"].includes(H.key)){const ce=H.target,L=Z.indexOf(ce);Z=Z.slice(L+1)}setTimeout(()=>M(Z)),H.preventDefault()}})})})})})})});rm.displayName=wk;var yk="SelectItemAlignedPosition",om=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=We(t,E=>d(E)),m=Xs(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(),A=c.getBoundingClientRect(),O=s.valueNode.getBoundingClientRect(),F=y.getBoundingClientRect();if(s.dir!=="rtl"){const ce=F.left-A.left,L=O.left-ce,oe=E.left-L,xe=E.width+oe,de=Math.max(xe,A.width),we=window.innerWidth-fn,Me=La(L,[fn,Math.max(fn,we-de)]);a.style.minWidth=xe+"px",a.style.left=Me+"px"}else{const ce=A.right-F.right,L=window.innerWidth-O.right-ce,oe=window.innerWidth-E.right-L,xe=E.width+oe,de=Math.max(xe,A.width),we=window.innerWidth-fn,Me=La(L,[fn,Math.max(fn,we-de)]);a.style.minWidth=xe+"px",a.style.right=Me+"px"}const U=m(),W=window.innerHeight-fn*2,z=g.scrollHeight,N=window.getComputedStyle(c),K=parseInt(N.borderTopWidth,10),M=parseInt(N.paddingTop,10),Q=parseInt(N.borderBottomWidth,10),$=parseInt(N.paddingBottom,10),_=K+M+z+$+Q,V=Math.min(x.offsetHeight*5,_),J=window.getComputedStyle(g),j=parseInt(J.paddingTop,10),R=parseInt(J.paddingBottom,10),G=E.top+E.height/2-fn,Y=W-G,ie=x.offsetHeight/2,H=x.offsetTop+ie,D=K+M+H,X=_-D;if(D<=G){const ce=U.length>0&&x===U[U.length-1].ref.current;a.style.bottom="0px";const L=c.clientHeight-g.offsetTop-g.offsetHeight,oe=Math.max(Y,ie+(ce?R:0)+L+Q),xe=D+oe;a.style.height=xe+"px"}else{const ce=U.length>0&&x===U[0].ref.current;a.style.top="0px";const oe=Math.max(G,K+g.offsetTop+(ce?j:0)+ie)+X;a.style.height=oe+"px",g.scrollTop=D-G+g.offsetTop}a.style.margin=`${fn}px 0`,a.style.minHeight=V+"px",a.style.maxHeight=W+"px",r==null||r(),requestAnimationFrame(()=>f.current=!0)}},[m,s.trigger,s.valueNode,a,c,g,x,y,s.dir,r]);It(()=>S(),[S]);const[k,C]=h.useState();It(()=>{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(Ck,{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(ye.div,{...o,ref:p,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});om.displayName=yk;var Sk="SelectPopperPosition",El=h.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=fn,...s}=e,i=Js(n);return u.jsx(ka,{...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)"}})});El.displayName=Sk;var[Ck,Il]=Pr(ar,{}),Nl="SelectViewport",sm=h.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=Wn(Nl,n),i=Il(Nl,n),a=We(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(Ys.Slot,{scope:n,children:u.jsx(ye.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:le(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=Nl;var im="SelectGroup",[Tk,kk]=Pr(im),Ek=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=At();return u.jsx(Tk,{scope:n,id:o,children:u.jsx(ye.div,{role:"group","aria-labelledby":o,...r,ref:t})})});Ek.displayName=im;var am="SelectLabel",lm=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=kk(am,n);return u.jsx(ye.div,{id:o.id,...r,ref:t})});lm.displayName=am;var Zs="SelectItem",[Ik,cm]=Pr(Zs),um=h.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=Un(Zs,n),l=Wn(Zs,n),c=a.value===r,[d,p]=h.useState(s??""),[m,f]=h.useState(!1),v=We(t,w=>{var S;return(S=l.itemRefCallback)==null?void 0:S.call(l,w,r,o)}),g=At(),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(Ik,{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(Ys.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:u.jsx(ye.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:le(i.onFocus,()=>f(!0)),onBlur:le(i.onBlur,()=>f(!1)),onClick:le(i.onClick,()=>{x.current!=="mouse"&&y()}),onPointerUp:le(i.onPointerUp,()=>{x.current==="mouse"&&y()}),onPointerDown:le(i.onPointerDown,w=>{x.current=w.pointerType}),onPointerMove:le(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:le(i.onPointerLeave,w=>{var S;w.currentTarget===document.activeElement&&((S=l.onItemLeave)==null||S.call(l))}),onKeyDown:le(i.onKeyDown,w=>{var k;((k=l.searchRef)==null?void 0:k.current)!==""&&w.key===" "||(fk.includes(w.key)&&y(),w.key===" "&&w.preventDefault())})})})})});um.displayName=Zs;var yo="SelectItemText",dm=h.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=Un(yo,n),a=Wn(yo,n),l=cm(yo,n),c=gk(yo,n),[d,p]=h.useState(null),m=We(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 It(()=>(g(v),()=>x(v)),[g,x,v]),u.jsxs(u.Fragment,{children:[u.jsx(ye.span,{id:l.textId,...s,ref:m}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?Dr.createPortal(s.children,i.valueNode):null]})});dm.displayName=yo;var fm="SelectItemIndicator",pm=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return cm(fm,n).isSelected?u.jsx(ye.span,{"aria-hidden":!0,...r,ref:t}):null});pm.displayName=fm;var Al="SelectScrollUpButton",hm=h.forwardRef((e,t)=>{const n=Wn(Al,e.__scopeSelect),r=Il(Al,e.__scopeSelect),[o,s]=h.useState(!1),i=We(t,r.onScrollButtonChange);return It(()=>{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(gm,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});hm.displayName=Al;var _l="SelectScrollDownButton",mm=h.forwardRef((e,t)=>{const n=Wn(_l,e.__scopeSelect),r=Il(_l,e.__scopeSelect),[o,s]=h.useState(!1),i=We(t,r.onScrollButtonChange);return It(()=>{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(gm,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});mm.displayName=_l;var gm=h.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=Wn("SelectScrollButton",n),i=h.useRef(null),a=Xs(n),l=h.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return h.useEffect(()=>()=>l(),[l]),It(()=>{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(ye.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:le(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:le(o.onPointerMove,()=>{var c;(c=s.onItemLeave)==null||c.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:le(o.onPointerLeave,()=>{l()})})}),Nk="SelectSeparator",xm=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return u.jsx(ye.div,{"aria-hidden":!0,...r,ref:t})});xm.displayName=Nk;var jl="SelectArrow",Ak=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Js(n),s=Un(jl,n),i=Wn(jl,n);return s.open&&i.position==="popper"?u.jsx(Ea,{...o,...r,ref:t}):null});Ak.displayName=jl;var _k="SelectBubbleInput",vm=h.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=h.useRef(null),s=We(r,o),i=Kh(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(ye.select,{...n,style:{...qh,...n.style},ref:s,defaultValue:t})});vm.displayName=_k;function wm(e){return e===""||e===void 0}function bm(e){const t=wt(e),n=h.useRef(""),r=h.useRef(0),o=h.useCallback(i=>{const a=n.current+i;t(a),function l(c){n.current=c,window.clearTimeout(r.current),c!==""&&(r.current=window.setTimeout(()=>l(""),1e3))}(a)},[t]),s=h.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return h.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function ym(e,t,n){const o=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=jk(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 jk(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Pk=Gh,Sm=Xh,Mk=Zh,Rk=Qh,Ok=em,Cm=tm,Dk=sm,Tm=lm,km=um,Lk=dm,$k=pm,Em=hm,Im=mm,Nm=xm;const Fk=Pk,Bk=Mk,Am=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Sm,{ref:r,className:re("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(Rk,{asChild:!0,children:u.jsx(fe.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));Am.displayName=Sm.displayName;const _m=h.forwardRef(({className:e,...t},n)=>u.jsx(Em,{ref:n,className:re("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(fe.ChevronUp,{className:"h-4 w-4"})}));_m.displayName=Em.displayName;const jm=h.forwardRef(({className:e,...t},n)=>u.jsx(Im,{ref:n,className:re("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(fe.ChevronDown,{className:"h-4 w-4"})}));jm.displayName=Im.displayName;const Pm=h.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>u.jsx(Ok,{children:u.jsxs(Cm,{ref:o,className:re("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(_m,{}),u.jsx(Dk,{className:re("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),u.jsx(jm,{})]})}));Pm.displayName=Cm.displayName;const zk=h.forwardRef(({className:e,...t},n)=>u.jsx(Tm,{ref:n,className:re("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));zk.displayName=Tm.displayName;const Mm=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(km,{ref:r,className:re("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($k,{children:u.jsx(fe.Check,{className:"h-4 w-4"})})}),u.jsx(Lk,{children:t})]}));Mm.displayName=km.displayName;const Hk=h.forwardRef(({className:e,...t},n)=>u.jsx(Nm,{ref:n,className:re("-mx-1 my-1 h-px bg-muted",e),...t}));Hk.displayName=Nm.displayName;var Uk="Separator",Rm="horizontal",Wk=["horizontal","vertical"],Om=h.forwardRef((e,t)=>{const{decorative:n,orientation:r=Rm,...o}=e,s=Vk(r)?r:Rm,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return u.jsx(ye.div,{"data-orientation":s,...a,...o,ref:t})});Om.displayName=Uk;function Vk(e){return Wk.includes(e)}var Dm=Om;const Lm=h.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>u.jsx(Dm,{ref:o,decorative:n,orientation:t,className:re("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));Lm.displayName=Dm.displayName;var Qs="Switch",[Kk,n1]=sn(Qs),[qk,Gk]=Kk(Qs),$m=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=We(t,S=>f(S)),g=h.useRef(!1),x=m?d||!!m.closest("form"):!0,[y,w]=jn({prop:o,defaultProp:s??!1,onChange:c,caller:Qs});return u.jsxs(qk,{scope:n,checked:y,disabled:a,children:[u.jsx(ye.button,{type:"button",role:"switch","aria-checked":y,"aria-required":i,"data-state":Hm(y),"data-disabled":a?"":void 0,disabled:a,value:l,...p,ref:v,onClick:le(e.onClick,S=>{w(k=>!k),x&&(g.current=S.isPropagationStopped(),g.current||S.stopPropagation())})}),x&&u.jsx(zm,{control:m,bubbles:!g.current,name:r,value:l,checked:y,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});$m.displayName=Qs;var Fm="SwitchThumb",Bm=h.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=Gk(Fm,n);return u.jsx(ye.span,{"data-state":Hm(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});Bm.displayName=Fm;var Yk="SwitchBubbleInput",zm=h.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=h.useRef(null),a=We(i,s),l=Kh(n),c=Kd(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}})});zm.displayName=Yk;function Hm(e){return e?"checked":"unchecked"}var Um=$m,Xk=Bm;const Wm=h.forwardRef(({className:e,...t},n)=>u.jsx(Um,{className:re("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(Xk,{className:re("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")})}));Wm.displayName=Um.displayName;const Jk=Zi,Zk=Tb,Qk=Qi,Vm=h.forwardRef(({className:e,...t},n)=>u.jsx(Gr,{className:re("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}));Vm.displayName=Gr.displayName;const eE=Or.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"}}),Km=h.forwardRef(({side:e="right",className:t,children:n,...r},o)=>u.jsxs(Qk,{children:[u.jsx(Vm,{}),u.jsxs(Yr,{ref:o,className:re(eE({side:e}),t),...r,children:[n,u.jsxs(pd,{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(fe.X,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Km.displayName=Yr.displayName;const qm=({className:e,...t})=>u.jsx("div",{className:re("flex flex-col space-y-2 text-center sm:text-left",e),...t});qm.displayName="SheetHeader";const Gm=h.forwardRef(({className:e,...t},n)=>u.jsx(Xn,{ref:n,className:re("text-lg font-semibold text-foreground",e),...t}));Gm.displayName=Xn.displayName;const Ym=h.forwardRef(({className:e,...t},n)=>u.jsx(es,{ref:n,className:re("text-sm text-muted-foreground",e),...t}));Ym.displayName=es.displayName;var[ei,r1]=sn("Tooltip",[Er]),ti=Er(),Xm="TooltipProvider",tE=700,Pl="tooltip.open",[nE,Ml]=ei(Xm),Jm=e=>{const{__scopeTooltip:t,delayDuration:n=tE,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(nE,{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})};Jm.displayName=Xm;var So="Tooltip",[rE,ni]=ei(So),Zm=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:s,disableHoverableContent:i,delayDuration:a}=e,l=Ml(So,e.__scopeTooltip),c=ti(t),[d,p]=h.useState(null),m=At(),f=h.useRef(0),v=i??l.disableHoverableContent,g=a??l.delayDuration,x=h.useRef(!1),[y,w]=jn({prop:r,defaultProp:o??!1,onChange:E=>{E?(l.onOpen(),document.dispatchEvent(new CustomEvent(Pl))):l.onClose(),s==null||s(E)},caller:So}),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(Ca,{...c,children:u.jsx(rE,{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})})};Zm.displayName=So;var Rl="TooltipTrigger",Qm=h.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=ni(Rl,n),s=Ml(Rl,n),i=ti(n),a=h.useRef(null),l=We(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(ye.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:l,onPointerMove:le(e.onPointerMove,m=>{m.pointerType!=="touch"&&!d.current&&!s.isPointerInTransitRef.current&&(o.onTriggerEnter(),d.current=!0)}),onPointerLeave:le(e.onPointerLeave,()=>{o.onTriggerLeave(),d.current=!1}),onPointerDown:le(e.onPointerDown,()=>{o.open&&o.onClose(),c.current=!0,document.addEventListener("pointerup",p,{once:!0})}),onFocus:le(e.onFocus,()=>{c.current||o.onOpen()}),onBlur:le(e.onBlur,o.onClose),onClick:le(e.onClick,o.onClose)})})});Qm.displayName=Rl;var oE="TooltipPortal",[o1,sE]=ei(oE,{forceMount:void 0}),Mr="TooltipContent",eg=h.forwardRef((e,t)=>{const n=sE(Mr,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...s}=e,i=ni(Mr,e.__scopeTooltip);return u.jsx(Ft,{present:r||i.open,children:i.disableHoverableContent?u.jsx(tg,{side:o,...s,ref:t}):u.jsx(iE,{side:o,...s,ref:t})})}),iE=h.forwardRef((e,t)=>{const n=ni(Mr,e.__scopeTooltip),r=Ml(Mr,e.__scopeTooltip),o=h.useRef(null),s=We(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=dE(y,x.getBoundingClientRect()),S=fE(y,w),k=pE(g.getBoundingClientRect()),C=mE([...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=!hE(y,i);w?m():S&&(m(),c())};return document.addEventListener("pointermove",v),()=>document.removeEventListener("pointermove",v)}},[l,d,i,c,m]),u.jsx(tg,{...e,ref:s})}),[aE,lE]=ei(So,{isInside:!1}),cE=Vt.createSlottable("TooltipContent"),tg=h.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:s,onPointerDownOutside:i,...a}=e,l=ni(Mr,n),c=ti(n),{onClose:d}=l;return h.useEffect(()=>(document.addEventListener(Pl,d),()=>document.removeEventListener(Pl,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(mr,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:p=>p.preventDefault(),onDismiss:d,children:u.jsxs(ka,{"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(cE,{children:r}),u.jsx(aE,{scope:n,isInside:!0,children:u.jsx(uk,{id:l.contentId,role:"tooltip",children:o||r})})]})})});eg.displayName=Mr;var ng="TooltipArrow",uE=h.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=ti(n);return lE(ng,n).isInside?null:u.jsx(Ea,{...o,...r,ref:t})});uE.displayName=ng;function dE(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 fE(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 pE(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 hE(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 mE(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),gE(t)}function gE(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 xE=Jm,vE=Zm,wE=Qm,rg=eg;const bE=xE,yE=vE,SE=wE,og=h.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(rg,{ref:r,sideOffset:t,className:re("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}));og.displayName=rg.displayName;var Ol="ToastProvider",[Dl,CE,TE]=ss("Toast"),[sg,s1]=sn("Toast",[TE]),[kE,ri]=sg(Ol),ig=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 \`${Ol}\`. Expected non-empty \`string\`.`),u.jsx(Dl.Provider,{scope:t,children:u.jsx(kE,{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})})};ig.displayName=Ol;var ag="ToastViewport",EE=["F8"],Ll="toast.viewportPause",$l="toast.viewportResume",lg=h.forwardRef((e,t)=>{const{__scopeToast:n,hotkey:r=EE,label:o="Notifications ({hotkey})",...s}=e,i=ri(ag,n),a=CE(n),l=h.useRef(null),c=h.useRef(null),d=h.useRef(null),p=h.useRef(null),m=We(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(Ll);y.dispatchEvent(T),i.isClosePausedRef.current=!0}},S=()=>{if(i.isClosePausedRef.current){const T=new CustomEvent($l);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,...FE(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 A=document.activeElement,O=w.shiftKey;if(w.target===x&&O){(C=c.current)==null||C.focus();return}const W=g({tabbingDirection:O?"backwards":"forwards"}),z=W.findIndex(N=>N===A);zl(W.slice(z+1))?w.preventDefault():O?(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(vw,{ref:l,role:"region","aria-label":o.replace("{hotkey}",f),tabIndex:-1,style:{pointerEvents:v?void 0:"none"},children:[v&&u.jsx(Fl,{ref:c,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"forwards"});zl(x)}}),u.jsx(Dl.Slot,{scope:n,children:u.jsx(ye.ol,{tabIndex:-1,...s,ref:m})}),v&&u.jsx(Fl,{ref:d,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"backwards"});zl(x)}})]})});lg.displayName=ag;var cg="ToastFocusProxy",Fl=h.forwardRef((e,t)=>{const{__scopeToast:n,onFocusFromOutsideViewport:r,...o}=e,s=ri(cg,n);return u.jsx(Gs,{tabIndex:0,...o,ref:t,style:{position:"fixed"},onFocus:i=>{var c;const a=i.relatedTarget;!((c=s.viewport)!=null&&c.contains(a))&&r()}})});Fl.displayName=cg;var Co="Toast",IE="toast.swipeStart",NE="toast.swipeMove",AE="toast.swipeCancel",_E="toast.swipeEnd",ug=h.forwardRef((e,t)=>{const{forceMount:n,open:r,defaultOpen:o,onOpenChange:s,...i}=e,[a,l]=jn({prop:r,defaultProp:o??!0,onChange:s,caller:Co});return u.jsx(Ft,{present:n||a,children:u.jsx(ME,{open:a,...i,ref:t,onClose:()=>l(!1),onPause:wt(e.onPause),onResume:wt(e.onResume),onSwipeStart:le(e.onSwipeStart,c=>{c.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:le(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:le(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:le(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)})})})});ug.displayName=Co;var[jE,PE]=sg(Co,{onClose(){}}),ME=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=ri(Co,n),[x,y]=h.useState(null),w=We(t,N=>y(N)),S=h.useRef(null),k=h.useRef(null),C=o||g.duration,T=h.useRef(0),E=h.useRef(C),A=h.useRef(0),{onToastAdd:O,onToastRemove:F}=g,U=wt(()=>{var K;(x==null?void 0:x.contains(document.activeElement))&&((K=g.viewport)==null||K.focus()),i()}),W=h.useCallback(N=>{!N||N===1/0||(window.clearTimeout(A.current),T.current=new Date().getTime(),A.current=window.setTimeout(U,N))},[U]);h.useEffect(()=>{const N=g.viewport;if(N){const K=()=>{W(E.current),c==null||c()},M=()=>{const Q=new Date().getTime()-T.current;E.current=E.current-Q,window.clearTimeout(A.current),l==null||l()};return N.addEventListener(Ll,M),N.addEventListener($l,K),()=>{N.removeEventListener(Ll,M),N.removeEventListener($l,K)}}},[g.viewport,C,l,c,W]),h.useEffect(()=>{s&&!g.isClosePausedRef.current&&W(C)},[s,C,g.isClosePausedRef,W]),h.useEffect(()=>(O(),()=>F()),[O,F]);const z=h.useMemo(()=>x?xg(x):null,[x]);return g.viewport?u.jsxs(u.Fragment,{children:[z&&u.jsx(RE,{__scopeToast:n,role:"status","aria-live":r==="foreground"?"assertive":"polite",children:z}),u.jsx(jE,{scope:n,onClose:U,children:Dr.createPortal(u.jsx(Dl.ItemSlot,{scope:n,children:u.jsx(xw,{asChild:!0,onEscapeKeyDown:le(a,()=>{g.isFocusedToastEscapeKeyDownRef.current||U(),g.isFocusedToastEscapeKeyDownRef.current=!1}),children:u.jsx(ye.li,{tabIndex:0,"data-state":s?"open":"closed","data-swipe-direction":g.swipeDirection,...v,ref:w,style:{userSelect:"none",touchAction:"none",...e.style},onKeyDown:le(e.onKeyDown,N=>{N.key==="Escape"&&(a==null||a(N.nativeEvent),N.nativeEvent.defaultPrevented||(g.isFocusedToastEscapeKeyDownRef.current=!0,U()))}),onPointerDown:le(e.onPointerDown,N=>{N.button===0&&(S.current={x:N.clientX,y:N.clientY})}),onPointerMove:le(e.onPointerMove,N=>{if(!S.current)return;const K=N.clientX-S.current.x,M=N.clientY-S.current.y,Q=!!k.current,$=["left","right"].includes(g.swipeDirection),_=["left","up"].includes(g.swipeDirection)?Math.min:Math.max,V=$?_(0,K):0,J=$?0:_(0,M),j=N.pointerType==="touch"?10:2,R={x:V,y:J},G={originalEvent:N,delta:R};Q?(k.current=R,oi(NE,p,G,{discrete:!1})):vg(R,g.swipeDirection,j)?(k.current=R,oi(IE,d,G,{discrete:!1}),N.target.setPointerCapture(N.pointerId)):(Math.abs(K)>j||Math.abs(M)>j)&&(S.current=null)}),onPointerUp:le(e.onPointerUp,N=>{const K=k.current,M=N.target;if(M.hasPointerCapture(N.pointerId)&&M.releasePointerCapture(N.pointerId),k.current=null,S.current=null,K){const Q=N.currentTarget,$={originalEvent:N,delta:K};vg(K,g.swipeDirection,g.swipeThreshold)?oi(_E,f,$,{discrete:!0}):oi(AE,m,$,{discrete:!0}),Q.addEventListener("click",_=>_.preventDefault(),{once:!0})}})})})}),g.viewport)})]}):null}),RE=e=>{const{__scopeToast:t,children:n,...r}=e,o=ri(Co,t),[s,i]=h.useState(!1),[a,l]=h.useState(!1);return LE(()=>i(!0)),h.useEffect(()=>{const c=window.setTimeout(()=>l(!0),1e3);return()=>window.clearTimeout(c)},[]),a?null:u.jsx(qr,{asChild:!0,children:u.jsx(Gs,{...r,children:s&&u.jsxs(u.Fragment,{children:[o.label," ",n]})})})},OE="ToastTitle",dg=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(ye.div,{...r,ref:t})});dg.displayName=OE;var DE="ToastDescription",fg=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(ye.div,{...r,ref:t})});fg.displayName=DE;var pg="ToastAction",hg=h.forwardRef((e,t)=>{const{altText:n,...r}=e;return n.trim()?u.jsx(gg,{altText:n,asChild:!0,children:u.jsx(Bl,{...r,ref:t})}):(console.error(`Invalid prop \`altText\` supplied to \`${pg}\`. Expected non-empty \`string\`.`),null)});hg.displayName=pg;var mg="ToastClose",Bl=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e,o=PE(mg,n);return u.jsx(gg,{asChild:!0,children:u.jsx(ye.button,{type:"button",...r,ref:t,onClick:le(e.onClick,o.onClose)})})});Bl.displayName=mg;var gg=h.forwardRef((e,t)=>{const{__scopeToast:n,altText:r,...o}=e;return u.jsx(ye.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":r||void 0,...o,ref:t})});function xg(e){const t=[];return Array.from(e.childNodes).forEach(r=>{if(r.nodeType===r.TEXT_NODE&&r.textContent&&t.push(r.textContent),$E(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(...xg(r))}}),t}function oi(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?Li(o,s):o.dispatchEvent(s)}var vg=(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 LE(e=()=>{}){const t=wt(e);It(()=>{let n=0,r=0;return n=window.requestAnimationFrame(()=>r=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(n),window.cancelAnimationFrame(r)}},[t])}function $E(e){return e.nodeType===e.ELEMENT_NODE}function FE(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 zl(e){const t=document.activeElement;return e.some(n=>n===t?!0:(n.focus(),document.activeElement!==t))}var BE=ig,wg=lg,bg=ug,yg=dg,Sg=fg,Cg=hg,Tg=Bl;const zE=BE,kg=h.forwardRef(({className:e,...t},n)=>u.jsx(wg,{ref:n,className:re("fixed bottom-0 right-0 z-[100] flex max-h-screen w-full flex-col p-4 md:max-w-[420px]",e),...t}));kg.displayName=wg.displayName;const HE=Or.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"}}),Eg=h.forwardRef(({className:e,variant:t,...n},r)=>u.jsx(bg,{ref:r,className:re(HE({variant:t}),e),...n}));Eg.displayName=bg.displayName;const UE=h.forwardRef(({className:e,...t},n)=>u.jsx(Cg,{ref:n,className:re("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}));UE.displayName=Cg.displayName;const Ig=h.forwardRef(({className:e,...t},n)=>u.jsx(Tg,{ref:n,className:re("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(fe.X,{className:"h-4 w-4"})}));Ig.displayName=Tg.displayName;const Ng=h.forwardRef(({className:e,...t},n)=>u.jsx(yg,{ref:n,className:re("text-sm font-semibold",e),...t}));Ng.displayName=yg.displayName;const Ag=h.forwardRef(({className:e,...t},n)=>u.jsx(Sg,{ref:n,className:re("text-sm opacity-90",e),...t}));Ag.displayName=Sg.displayName;function WE(){const{toasts:e}=xl();return u.jsxs(zE,{children:[e.map(function({id:t,title:n,description:r,action:o,...s}){return u.jsxs(Eg,{...s,children:[u.jsxs("div",{className:"grid gap-1",children:[n&&u.jsx(Ng,{children:n}),r&&u.jsx(Ag,{children:r})]}),o,u.jsx(Ig,{})]},t)}),u.jsx(kg,{})]})}var VE=(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{}},KE=h.createContext(void 0),qE={setTheme:e=>{},themes:[]},GE=()=>{var e;return(e=h.useContext(KE))!=null?e:qE};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:`(${VE.toString()})(${d})`}})});var YE=e=>{switch(e){case"success":return ZE;case"info":return eI;case"warning":return QE;case"error":return tI;default:return null}},XE=Array(12).fill(0),JE=({visible:e,className:t})=>b.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},b.createElement("div",{className:"sonner-spinner"},XE.map((n,r)=>b.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),ZE=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"})),QE=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"})),eI=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"})),tI=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"})),nI=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"})),rI=()=>{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},Hl=1,oI=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:Hl++,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(iI(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)||Hl++;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 oI,sI=(e,t)=>{let n=(t==null?void 0:t.id)||Hl++;return Ht.addToast({title:e,...t,id:n}),n},iI=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",aI=sI,lI=()=>Ht.toasts,cI=()=>Ht.getActiveToasts();Object.assign(aI,{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:lI,getToasts:cI});function uI(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))}uI(`: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 si(e){return e.label!==void 0}var dI=3,fI="32px",pI="16px",_g=4e3,hI=356,mI=14,gI=20,xI=200;function pn(...e){return e.filter(Boolean).join(" ")}function vI(e){let[t,n]=e.split("-"),r=[];return t&&r.push(t),n&&r.push(n),r}var wI=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:A,style:O,cancelButtonStyle:F,actionButtonStyle:U,className:W="",descriptionClassName:z="",duration:N,position:K,gap:M,loadingIcon:Q,expandByDefault:$,classNames:_,icons:V,closeButtonAriaLabel:J="Close toast",pauseWhenPageIsHidden:j}=e,[R,G]=b.useState(null),[Y,ie]=b.useState(null),[H,D]=b.useState(!1),[X,Z]=b.useState(!1),[ce,L]=b.useState(!1),[oe,xe]=b.useState(!1),[de,we]=b.useState(!1),[Me,He]=b.useState(0),[$e,Ae]=b.useState(0),Fe=b.useRef(f.duration||N||_g),Ge=b.useRef(null),Ke=b.useRef(null),Xe=S===0,tt=S+1<=y,nt=f.type,Ze=f.dismissible!==!1,pt=f.className||"",ht=f.descriptionClassName||"",Se=b.useMemo(()=>w.findIndex(ae=>ae.toastId===f.id)||0,[w,f.id]),Re=b.useMemo(()=>{var ae;return(ae=f.closeButton)!=null?ae:A},[f.closeButton,A]),mt=b.useMemo(()=>f.duration||N||_g,[f.duration,N]),ot=b.useRef(0),qe=b.useRef(0),yt=b.useRef(0),De=b.useRef(null),[Be,St]=K.split("-"),xt=b.useMemo(()=>w.reduce((ae,Ie,Te)=>Te>=Se?ae:ae+Ie.height,0),[w,Se]),Ye=rI(),gt=f.invert||m,P=nt==="loading";qe.current=b.useMemo(()=>Se*M+xt,[Se,xt]),b.useEffect(()=>{Fe.current=mt},[mt]),b.useEffect(()=>{D(!0)},[]),b.useEffect(()=>{let ae=Ke.current;if(ae){let Ie=ae.getBoundingClientRect().height;return Ae(Ie),x(Te=>[{toastId:f.id,height:Ie,position:f.position},...Te]),()=>x(Te=>Te.filter(st=>st.toastId!==f.id))}},[x,f.id]),b.useLayoutEffect(()=>{if(!H)return;let ae=Ke.current,Ie=ae.style.height;ae.style.height="auto";let Te=ae.getBoundingClientRect().height;ae.style.height=Ie,Ae(Te),x(st=>st.find(Ue=>Ue.toastId===f.id)?st.map(Ue=>Ue.toastId===f.id?{...Ue,height:Te}:Ue):[{toastId:f.id,height:Te,position:f.position},...st])},[H,f.title,f.description,x,f.id]);let te=b.useCallback(()=>{Z(!0),He(qe.current),x(ae=>ae.filter(Ie=>Ie.toastId!==f.id)),setTimeout(()=>{T(f)},xI)},[f,T,x,qe]);b.useEffect(()=>{if(f.promise&&nt==="loading"||f.duration===1/0||f.type==="loading")return;let ae;return C||g||j&&Ye?(()=>{if(yt.current<ot.current){let Ie=new Date().getTime()-ot.current;Fe.current=Fe.current-Ie}yt.current=new Date().getTime()})():Fe.current!==1/0&&(ot.current=new Date().getTime(),ae=setTimeout(()=>{var Ie;(Ie=f.onAutoClose)==null||Ie.call(f,f),te()},Fe.current)),()=>clearTimeout(ae)},[C,g,f,nt,j,Ye,te]),b.useEffect(()=>{f.delete&&te()},[te,f.delete]);function ve(){var ae,Ie,Te;return V!=null&&V.loading?b.createElement("div",{className:pn(_==null?void 0:_.loader,(ae=f==null?void 0:f.classNames)==null?void 0:ae.loader,"sonner-loader"),"data-visible":nt==="loading"},V.loading):Q?b.createElement("div",{className:pn(_==null?void 0:_.loader,(Ie=f==null?void 0:f.classNames)==null?void 0:Ie.loader,"sonner-loader"),"data-visible":nt==="loading"},Q):b.createElement(JE,{className:pn(_==null?void 0:_.loader,(Te=f==null?void 0:f.classNames)==null?void 0:Te.loader),visible:nt==="loading"})}return b.createElement("li",{tabIndex:0,ref:Ke,className:pn(W,pt,_==null?void 0:_.toast,(t=f==null?void 0:f.classNames)==null?void 0:t.toast,_==null?void 0:_.default,_==null?void 0:_[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":H,"data-promise":!!f.promise,"data-swiped":de,"data-removed":X,"data-visible":tt,"data-y-position":Be,"data-x-position":St,"data-index":S,"data-front":Xe,"data-swiping":ce,"data-dismissible":Ze,"data-type":nt,"data-invert":gt,"data-swipe-out":oe,"data-swipe-direction":Y,"data-expanded":!!(C||$&&H),style:{"--index":S,"--toasts-before":S,"--z-index":k.length-S,"--offset":`${X?Me:qe.current}px`,"--initial-height":$?"auto":`${$e}px`,...O,...f.style},onDragEnd:()=>{L(!1),G(null),De.current=null},onPointerDown:ae=>{P||!Ze||(Ge.current=new Date,He(qe.current),ae.target.setPointerCapture(ae.pointerId),ae.target.tagName!=="BUTTON"&&(L(!0),De.current={x:ae.clientX,y:ae.clientY}))},onPointerUp:()=>{var ae,Ie,Te,st;if(oe||!Ze)return;De.current=null;let Ue=Number(((ae=Ke.current)==null?void 0:ae.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),lt=Number(((Ie=Ke.current)==null?void 0:Ie.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),Ut=new Date().getTime()-((Te=Ge.current)==null?void 0:Te.getTime()),Mt=R==="x"?Ue:lt,nn=Math.abs(Mt)/Ut;if(Math.abs(Mt)>=gI||nn>.11){He(qe.current),(st=f.onDismiss)==null||st.call(f,f),ie(R==="x"?Ue>0?"right":"left":lt>0?"down":"up"),te(),xe(!0),we(!1);return}L(!1),G(null)},onPointerMove:ae=>{var Ie,Te,st,Ue;if(!De.current||!Ze||((Ie=window.getSelection())==null?void 0:Ie.toString().length)>0)return;let lt=ae.clientY-De.current.y,Ut=ae.clientX-De.current.x,Mt=(Te=e.swipeDirections)!=null?Te:vI(K);!R&&(Math.abs(Ut)>1||Math.abs(lt)>1)&&G(Math.abs(Ut)>Math.abs(lt)?"x":"y");let nn={x:0,y:0};R==="y"?(Mt.includes("top")||Mt.includes("bottom"))&&(Mt.includes("top")&<<0||Mt.includes("bottom")&<>0)&&(nn.y=lt):R==="x"&&(Mt.includes("left")||Mt.includes("right"))&&(Mt.includes("left")&&Ut<0||Mt.includes("right")&&Ut>0)&&(nn.x=Ut),(Math.abs(nn.x)>0||Math.abs(nn.y)>0)&&we(!0),(st=Ke.current)==null||st.style.setProperty("--swipe-amount-x",`${nn.x}px`),(Ue=Ke.current)==null||Ue.style.setProperty("--swipe-amount-y",`${nn.y}px`)}},Re&&!f.jsx?b.createElement("button",{"aria-label":J,"data-disabled":P,"data-close-button":!0,onClick:P||!Ze?()=>{}:()=>{var ae;te(),(ae=f.onDismiss)==null||ae.call(f,f)},className:pn(_==null?void 0:_.closeButton,(o=f==null?void 0:f.classNames)==null?void 0:o.closeButton)},(s=V==null?void 0:V.close)!=null?s:nI):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(_==null?void 0:_.icon,(i=f==null?void 0:f.classNames)==null?void 0:i.icon)},f.promise||f.type==="loading"&&!f.icon?f.icon||ve():null,f.type!=="loading"?f.icon||(V==null?void 0:V[nt])||YE(nt):null):null,b.createElement("div",{"data-content":"",className:pn(_==null?void 0:_.content,(a=f==null?void 0:f.classNames)==null?void 0:a.content)},b.createElement("div",{"data-title":"",className:pn(_==null?void 0:_.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(z,ht,_==null?void 0:_.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&&si(f.cancel)?b.createElement("button",{"data-button":!0,"data-cancel":!0,style:f.cancelButtonStyle||F,onClick:ae=>{var Ie,Te;si(f.cancel)&&Ze&&((Te=(Ie=f.cancel).onClick)==null||Te.call(Ie,ae),te())},className:pn(_==null?void 0:_.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&&si(f.action)?b.createElement("button",{"data-button":!0,"data-action":!0,style:f.actionButtonStyle||U,onClick:ae=>{var Ie,Te;si(f.action)&&((Te=(Ie=f.action).onClick)==null||Te.call(Ie,ae),!ae.defaultPrevented&&te())},className:pn(_==null?void 0:_.actionButton,(p=f==null?void 0:f.classNames)==null?void 0:p.actionButton)},f.action.label):null))};function jg(){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 bI(e,t){let n={};return[e,t].forEach((r,o)=>{let s=o===1,i=s?"--mobile-offset":"--offset",a=s?pI:fI;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 yI=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=dI,toastOptions:g,dir:x=jg(),gap:y=mI,loadingIcon:w,icons:S,containerAriaLabel:k="Notifications",pauseWhenPageIsHidden:C}=e,[T,E]=b.useState([]),A=b.useMemo(()=>Array.from(new Set([r].concat(T.filter(j=>j.position).map(j=>j.position)))),[T,r]),[O,F]=b.useState([]),[U,W]=b.useState(!1),[z,N]=b.useState(!1),[K,M]=b.useState(d!=="system"?d:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),Q=b.useRef(null),$=o.join("+").replace(/Key/g,"").replace(/Digit/g,""),_=b.useRef(null),V=b.useRef(!1),J=b.useCallback(j=>{E(R=>{var G;return(G=R.find(Y=>Y.id===j.id))!=null&&G.delete||Ht.dismiss(j.id),R.filter(({id:Y})=>Y!==j.id)})},[]);return b.useEffect(()=>Ht.subscribe(j=>{if(j.dismiss){E(R=>R.map(G=>G.id===j.id?{...G,delete:!0}:G));return}setTimeout(()=>{To.flushSync(()=>{E(R=>{let G=R.findIndex(Y=>Y.id===j.id);return G!==-1?[...R.slice(0,G),{...R[G],...j},...R.slice(G+1)]:[j,...R]})})})}),[]),b.useEffect(()=>{if(d!=="system"){M(d);return}if(d==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?M("dark"):M("light")),typeof window>"u")return;let j=window.matchMedia("(prefers-color-scheme: dark)");try{j.addEventListener("change",({matches:R})=>{M(R?"dark":"light")})}catch{j.addListener(({matches:G})=>{try{M(G?"dark":"light")}catch(Y){console.error(Y)}})}},[d]),b.useEffect(()=>{T.length<=1&&W(!1)},[T]),b.useEffect(()=>{let j=R=>{var G,Y;o.every(ie=>R[ie]||R.code===ie)&&(W(!0),(G=Q.current)==null||G.focus()),R.code==="Escape"&&(document.activeElement===Q.current||(Y=Q.current)!=null&&Y.contains(document.activeElement))&&W(!1)};return document.addEventListener("keydown",j),()=>document.removeEventListener("keydown",j)},[o]),b.useEffect(()=>{if(Q.current)return()=>{_.current&&(_.current.focus({preventScroll:!0}),_.current=null,V.current=!1)}},[Q.current]),b.createElement("section",{ref:t,"aria-label":`${k} ${$}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},A.map((j,R)=>{var G;let[Y,ie]=j.split("-");return T.length?b.createElement("ol",{key:j,dir:x==="auto"?jg():x,tabIndex:-1,ref:Q,className:a,"data-sonner-toaster":!0,"data-theme":K,"data-y-position":Y,"data-lifted":U&&T.length>1&&!s,"data-x-position":ie,style:{"--front-toast-height":`${((G=O[0])==null?void 0:G.height)||0}px`,"--width":`${hI}px`,"--gap":`${y}px`,...f,...bI(l,c)},onBlur:H=>{V.current&&!H.currentTarget.contains(H.relatedTarget)&&(V.current=!1,_.current&&(_.current.focus({preventScroll:!0}),_.current=null))},onFocus:H=>{H.target instanceof HTMLElement&&H.target.dataset.dismissible==="false"||V.current||(V.current=!0,_.current=H.relatedTarget)},onMouseEnter:()=>W(!0),onMouseMove:()=>W(!0),onMouseLeave:()=>{z||W(!1)},onDragEnd:()=>W(!1),onPointerDown:H=>{H.target instanceof HTMLElement&&H.target.dataset.dismissible==="false"||N(!0)},onPointerUp:()=>N(!1)},T.filter(H=>!H.position&&R===0||H.position===j).map((H,D)=>{var X,Z;return b.createElement(wI,{key:H.id,icons:S,index:D,toast:H,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:(Z=g==null?void 0:g.closeButton)!=null?Z:i,interacting:z,position:j,style:g==null?void 0:g.style,unstyled:g==null?void 0:g.unstyled,classNames:g==null?void 0:g.classNames,cancelButtonStyle:g==null?void 0:g.cancelButtonStyle,actionButtonStyle:g==null?void 0:g.actionButtonStyle,removeToast:J,toasts:T.filter(ce=>ce.position==H.position),heights:O.filter(ce=>ce.position==H.position),setHeights:F,expandByDefault:s,gap:y,loadingIcon:w,expanded:U,pauseWhenPageIsHidden:C,swipeDirections:e.swipeDirections})})):null}))});const SI=({...e})=>{const{theme:t="system"}=GE();return u.jsx(yI,{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})};q.Api=pv,q.ApiClient=fv,q.ApiProvider=au,q.Badge=bh,q.Button=ct,q.Card=bl,q.CardContent=Tl,q.CardDescription=Cl,q.CardHeader=yl,q.CardTitle=Sl,q.ChatApi=$o,q.ChatApp=Hh,q.ChatInput=yp,q.ChatInterface=bo,q.Command=oa,q.CommandEmpty=aa,q.CommandGroup=la,q.CommandInput=sa,q.CommandItem=ca,q.CommandList=ia,q.DEFAULT_TIMEOUT_MS=Kc,q.Dialog=ra,q.DialogContent=ns,q.DialogHeader=rs,q.DialogTitle=os,q.DropdownMenu=Ss,q.DropdownMenuContent=ao,q.DropdownMenuItem=Dn,q.DropdownMenuTrigger=Cs,q.FileViewerModal=Sh,q.HISTORY_TIMEOUT_MS=qc,q.Input=Ua,q.Label=Vh,q.MarkdownContent=jr,q.MessageComponent=qs,q.MessageList=kl,q.SETTINGS_STORAGE_KEY=Ei,q.ScrollArea=Ha,q.Select=Fk,q.SelectContent=Pm,q.SelectItem=Mm,q.SelectTrigger=Am,q.SelectValue=Bk,q.Separator=Lm,q.Sheet=Jk,q.SheetContent=Km,q.SheetDescription=Ym,q.SheetHeader=qm,q.SheetTitle=Gm,q.SheetTrigger=Zk,q.SimpleChat=ik,q.Sonner=SI,q.Switch=Wm,q.Textarea=Va,q.ThreadManager=Wa,q.TimelineColumn=Ug,q.Toaster=WE,q.Tooltip=yE,q.TooltipContent=og,q.TooltipProvider=bE,q.TooltipTrigger=SE,q.applySettings=vv,q.buildAttemptMaps=Yl,q.buildCheckpointIndex=Jl,q.buildCheckpointPreviewMap=Lg,q.chatApiClient=An,q.default=Hh,q.del=Si,q.downloadFileById=Yc,q.extractConfigFields=li,q.fileToBase64=Jc,q.get=qt,q.getChatToken=Wc,q.getCurrentSettings=xv,q.getDefaultApiConfig=nu,q.getDefaultChatSettings=ru,q.getFileContent=Ti,q.getFileInfo=mv,q.getPreviewForMessage=ai,q.httpClient=Kt,q.hydrateHistorySnapshots=Nn,q.listFiles=Xc,q.loadStoredSettings=ou,q.onChatTokenChanged=Vc,q.post=Lo,q.processAttachments=Zc,q.put=Gc,q.readNumber=Ql,q.readString=Vn,q.resolveChatBaseUrl=mn,q.resolveMessageMetadata=ql,q.saveSettings=su,q.setChatToken=Do,q.toPlainObject=cr,q.unwrap=Rt,q.useApi=ki,q.useCheckpointIndex=Zl,q.useMessageMetadata=Gl,q.useStreamingHook=Su,q.useThreadHistoryState=lu,q.useThreadManagerViewState=bp,q.useThreadsState=cu,q.viewFileById=hv,Object.defineProperties(q,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
126
|
+
`}strong(t){return`<strong>${t}</strong>`}em(t){return`<em>${t}</em>`}codespan(t){return`<code>${t}</code>`}br(){return this.options.xhtml?"<br/>":"<br>"}del(t){return`<del>${t}</del>`}link(t,n,r){if(t=Nh(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=Nh(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 Mh{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 Rh{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 Hn{constructor(t){this.options=t||sr,this.options.renderer=this.options.renderer||new bl,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new Mh,this.slugger=new Rh}static parse(t,n){return new Hn(n).parse(t)}static parseInline(t,n){return new Hn(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,Ih(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 A='Token with "'+f.type+'" type was not found.';if(this.options.silent){console.error(A);return}else throw new Error(A)}}}return r}parseInline(t,n){n=n||this.renderer;let r="",o,s,i;const a=t.length;for(o=0;o<a;o++){if(s=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[s.type]&&(i=this.options.extensions.renderers[s.type].call({parser:this},s),i!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type))){r+=i||"";continue}switch(s.type){case"escape":{r+=n.text(s.text);break}case"html":{r+=n.html(s.text);break}case"link":{r+=n.link(s.href,s.title,this.parseInline(s.tokens,n));break}case"image":{r+=n.image(s.href,s.title,s.text);break}case"strong":{r+=n.strong(this.parseInline(s.tokens,n));break}case"em":{r+=n.em(this.parseInline(s.tokens,n));break}case"codespan":{r+=n.codespan(s.text);break}case"br":{r+=n.br();break}case"del":{r+=n.del(this.parseInline(s.tokens,n));break}case"text":{r+=n.text(s.text);break}default:{const l='Token with "'+s.type+'" type was not found.';if(this.options.silent){console.error(l);return}else throw new Error(l)}}}return r}}class Gs{constructor(t){this.options=t||sr}preprocess(t){return t}postprocess(t){return t}}Pg(Gs,"passThroughHooks",new Set(["preprocess","postprocess"]));function JT(e,t,n){return r=>{if(r.message+=`
|
|
128
|
+
Please report this to https://github.com/markedjs/marked.`,e){const o="<p>An error occurred:</p><pre>"+Pt(r.message+"",!0)+"</pre>";if(t)return Promise.resolve(o);if(n){n(null,o);return}return o}if(t)return Promise.reject(r);if(n){n(r);return}throw r}}function Oh(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...ke.defaults,...s};const i=JT(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(GT(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&&ke.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;ke.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(ke.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&&ke.walkTokens(a,r.walkTokens);let l=t(a,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(a){return i(a)}}}function ke(e,t,n){return Oh(zn.lex,Hn.parse)(e,t,n)}ke.options=ke.setOptions=function(e){return ke.defaults={...ke.defaults,...e},OT(ke.defaults),ke},ke.getDefaults=Ch,ke.defaults=sr,ke.use=function(...e){const t=ke.defaults.extensions||{renderers:{},childTokens:{}};e.forEach(n=>{const r={...n};if(r.async=ke.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=ke.defaults.renderer||new bl;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=ke.defaults.tokenizer||new wl;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=ke.defaults.hooks||new Gs;for(const s in n.hooks){const i=o[s];Gs.passThroughHooks.has(s)?o[s]=a=>{if(ke.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=ke.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}}ke.setOptions(r)})},ke.walkTokens=function(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(ke,r)),r.type){case"table":{for(const o of r.header)n=n.concat(ke.walkTokens(o.tokens,t));for(const o of r.rows)for(const s of o)n=n.concat(ke.walkTokens(s.tokens,t));break}case"list":{n=n.concat(ke.walkTokens(r.items,t));break}default:ke.defaults.extensions&&ke.defaults.extensions.childTokens&&ke.defaults.extensions.childTokens[r.type]?ke.defaults.extensions.childTokens[r.type].forEach(function(o){n=n.concat(ke.walkTokens(r[o],t))}):r.tokens&&(n=n.concat(ke.walkTokens(r.tokens,t)))}return n},ke.parseInline=Oh(zn.lexInline,Hn.parseInline),ke.Parser=Hn,ke.parser=Hn.parse,ke.Renderer=bl,ke.TextRenderer=Mh,ke.Lexer=zn,ke.lexer=zn.lex,ke.Tokenizer=wl,ke.Slugger=Rh,ke.Hooks=Gs,ke.parse=ke,ke.options,ke.setOptions,ke.use,ke.walkTokens,ke.parseInline,Hn.parse,zn.lex;function jr({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 ke.parse=="function"?ke.parse(i):ke(i)}return typeof ke.parse=="function"?ke.parse(e):ke(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:re("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 ZT({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 QT({artifact:e}){const[t,n]=b.useState("bg-yellow-500/20 text-yellow-700 dark:text-yellow-300"),[r,o]=b.useState(u.jsx(fe.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(fe.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(fe.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(fe.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(fe.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(fe.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(jr,{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(fe.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 ek({artifact:e,idx:t=0}){const n=b.useMemo(()=>e?(Array.isArray(e.plots)?e.plots:[]).map(o=>Av(o)).filter(o=>o!==null):[],[e]);return(e==null?void 0:e.type)==="research_task_info"?u.jsx(QT,{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(ZT,{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 yl=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:re("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));yl.displayName="Card";const Sl=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:re("flex flex-col space-y-1.5 p-6",e),...t}));Sl.displayName="CardHeader";const Cl=h.forwardRef(({className:e,...t},n)=>u.jsx("h3",{ref:n,className:re("text-2xl font-semibold leading-none tracking-tight",e),...t}));Cl.displayName="CardTitle";const Tl=h.forwardRef(({className:e,...t},n)=>u.jsx("p",{ref:n,className:re("text-sm text-muted-foreground",e),...t}));Tl.displayName="CardDescription";const kl=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:re("p-6 pt-0",e),...t}));kl.displayName="CardContent";const Dh=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:re("flex items-center p-6 pt-0",e),...t}));Dh.displayName="CardFooter";function tk({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(yl,{className:re("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(Sl,{className:"pb-3",children:[u.jsx(Cl,{className:"text-blue-900 dark:text-blue-100 text-base",children:i}),u.jsx(Tl,{className:"text-blue-700 dark:text-blue-300 text-sm",children:l})]}),a&&u.jsx(kl,{className:"pt-0 pb-3",children:a}),u.jsx(Dh,{className:"pt-0",children:u.jsxs("div",{className:"flex gap-2 ml-auto",children:[u.jsx(ct,{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(ct,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",disabled:r||!o,children:"Approve"})]})})]})}const nk="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 Lh({data:e}){return Array.isArray(e)?e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?u.jsx("div",{className:nk,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 rk({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(fe.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 ok({message:e,viewMode:t,isStreaming:n=!1}){const o=_i(e).name||"tool",s=l=>{if(l==null)return null;const c=typeof l=="string"?Ai(l)??l:l;if(c&&typeof c=="object")return u.jsx(Lh,{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}=Sv(l);return d?u.jsx(jr,{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=Vr(m);return i(f)}const c=Wr(l),d=Vr(c);return i(d)};return u.jsxs("div",{className:"space-y-2",children:[u.jsx(rk,{message:e,isStreaming:n}),t==="expanded"&&a()]})}function sk(e){const{allowFileOpen:t,currentThreadId:n}=e,{toast:r}=vl(),[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 Jc(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 ik({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:re("text-sm text-[hsl(var(--chat-bubble-user-text))]",o&&"text-xs"),children:t?u.jsx(jr,{content:e,allowHtml:!1}):u.jsxs("pre",{className:re("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(ct,{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(fe.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):u.jsxs(u.Fragment,{children:[u.jsx(fe.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",s," chars)"]})})]})}function ak({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:re("inline-block text-xs opacity-70 ml-1",e),children:["Is thinking",".".repeat(t)]})}function $h(e){var n;const t=(n=e.additionalKwargs)==null?void 0:n.toolProgress;return Array.isArray(t)?t:[]}const Ys=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:A,defaultCheckpointId:O=null,messageParentCheckpointId:F=null}){const[U,W]=b.useState(!1),[z,N]=b.useState("preview"),[q,M]=b.useState(!1),{currentThreadId:Q}=zo(),{respondToInterrupt:$}=Ho(),_=l==="phone"||l==="half-screen",V=t.role,J=V==="tool",j=b.useMemo(()=>"type"in t&&t.type==="default_message"?t:null,[t]),R=!!j,G=!(r&&V!=="user"),{uploadingFiles:Y,handleFileClick:ie,fileViewerOpen:H,currentFileInfo:D,closeFileViewer:X}=sk({allowFileOpen:G,currentThreadId:Q}),Z=b.useMemo(()=>{switch(V){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))]"}},[V]),ce=b.useMemo(()=>{if(j)return"";const P=t.content;return Array.isArray(P)?Cv(P):""},[j,t]),L=b.useMemo(()=>{if(j)return{};const P=t.content;return Array.isArray(P)?_i(t):{}},[j,t]),oe=b.useMemo(()=>J?!!(t.additionalKwargs??{}).toolStreaming:!1,[J,t]),xe=b.useMemo(()=>{if(j)return[];const P=t.content;return Array.isArray(P)?P.filter(te=>te.type==="image_url"):[]},[j,t]),de=b.useMemo(()=>{if(j)return[];const P=t.content;return Array.isArray(P)?P.filter(te=>te.type==="file"):[]},[j,t]),we=b.useMemo(()=>{if(j)return[];const P=t.content;return Array.isArray(P)?P.filter(te=>te.type==="interrupt"):[]},[j,t]),Me=(w==null?void 0:w.id)??(w==null?void 0:w.interrupt_id),He=Bo(Me),$e=w==null?void 0:w.value,Ae=b.useMemo(()=>{if(j)return"";const P=t.content;return Array.isArray(P)?Tv(P):""},[j,t]),Fe=b.useMemo(()=>j||!m?null:t.artifact||null,[j,t,m]),Ge=b.useCallback(async()=>{const P=J?Ae:ce;async function te(ve){if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function"){await navigator.clipboard.writeText(ve);return}if(navigator.clipboard&&typeof navigator.clipboard.write=="function"&&typeof ClipboardItem<"u"){const ae=new Blob([ve],{type:"text/plain"});await navigator.clipboard.write([new ClipboardItem({"text/plain":ae})]);return}throw new Error("Clipboard API not supported in this context.")}try{await te(P),W(!0),setTimeout(()=>W(!1),2e3),y==null||y(P)}catch(ve){console.error("Failed to copy:",ve)}},[J,Ae,ce,y]),Ke=b.useCallback(()=>{if(!v||!t.id)return;const P=(J?Ae:ce)??"",te="type"in t&&t.type==="default_message"?void 0:{checkpointId:t.checkpointId??null,checkpointNs:t.checkpointNs??null};v(t.id,P,te)},[v,t.id,J,Ae,ce,t]),Xe=b.useCallback(()=>{g==null||g(n)},[g,n]),tt=b.useCallback(()=>{const te=re(_?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",Z);switch(V){case"user":return u.jsx(fe.User,{className:te});case"assistant":return u.jsx(fe.Bot,{className:te});case"tool":return u.jsx(fe.Wrench,{className:te});default:return u.jsx(fe.Bot,{className:te})}},[_,Z,V]),nt=b.useCallback(()=>{const P="group relative mb-4 flex w-full";switch(V){case"user":return re(P,"justify-end");case"assistant":case"tool":case"system":return re(P,"justify-start");default:return P}},[V]),Ze=b.useCallback(()=>{const P=re("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",_&&"px-3 py-2 text-sm");if(R)return re(P,"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(V){case"user":return re(P,"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 re(P,"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 re(P,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return re(P,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return re(P,"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")}},[_,R,V]),pt=b.useCallback(async P=>{if(S)return;const te=Bo((P==null?void 0:P.id)??(P==null?void 0:P.interrupt_id));if(!te){console.warn("Interrupt part missing id",P);return}try{k==null||k(),await $(te,!0)}catch(ve){console.error("Failed to approve interrupt:",ve)}finally{C==null||C()}},[S,C,k,$]),ht=b.useCallback(async P=>{if(S)return;const te=Bo((P==null?void 0:P.id)??(P==null?void 0:P.interrupt_id));if(!te){console.warn("Interrupt part missing id",P);return}try{k==null||k(),await $(te,!1)}catch(ve){console.error("Failed to reject interrupt:",ve)}finally{C==null||C()}},[S,C,k,$]),Se=b.useCallback(({part:P,i:te})=>{if(P.type==="text"){const ve=P.text??"",ae=ve.trim(),Ie=Ai(ae);return Ie&&V!=="tool"?u.jsx(Lh,{data:Ie},te):V==="user"&&c&&ae.length>d?u.jsx(ik,{text:ae,expanded:q,onExpandedChange:M,previewLength:d,isCompact:_},te):u.jsx(jr,{content:ve,allowHtml:!1},te)}if(P.type==="image_url"){const ve=P;return u.jsx("div",{className:"my-2",children:u.jsx("img",{src:ve.url,alt:ve.alt??"",loading:"lazy",className:"border rounded max-h-[420px] w-auto object-contain"})},te)}if(P.type==="file"){const ve=P,ae=ve.name||"file";return u.jsxs("a",{href:ve.url,onClick:Ie=>ie(Ie.nativeEvent,ve,te),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:[Y[te]?u.jsx(fe.Loader,{className:"h-4 w-4 animate-spin"}):null,u.jsxs("span",{className:"truncate max-w-[180px]",children:[ae,Y[te]?" (processing)":""]})]},te)}if(P.type==="interrupt"){const ve=P,ae=Bo((ve==null?void 0:ve.id)??(ve==null?void 0:ve.interrupt_id)),Ie=!!(He&&ae&&ae===He),Te=Ie?$e??(ve==null?void 0:ve.value):ve==null?void 0:ve.value,st=ae?{...ve,id:ae,interrupt_id:ae}:ve;return u.jsx(tk,{interruptPart:st,onApprove:pt,onReject:ht,disabled:S,isActive:Ie,payload:Te},te)}return null},[ie,Y,pt,ht,V,c,d,q,_,He,$e,w,S,we]),Re=b.useCallback(()=>u.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/30 rounded",children:[u.jsx(fe.Paperclip,{className:"h-4 w-4 text-muted-foreground"}),u.jsx("span",{className:"text-sm text-muted-foreground",children:"File upload"})]}),[]),mt=b.useCallback(()=>{const P=ce.trim().length>0||xe.length>0||de.length>0||we.length>0;if(!J&&de.length>0&&!r)return Re();if(!J&&!P&&!r)return null;if(J)return!p&&Fe?null:p?u.jsx(ok,{message:t,viewMode:z,isStreaming:oe},t.id):null;if(!J&&!j){const te=t,ve=u.jsx("div",{className:"space-y-2",children:te.content.map((ae,Ie)=>u.jsx(Se,{part:ae,i:Ie},Ie))});return r?u.jsxs("div",{"aria-busy":"true",role:"status",children:[ve,u.jsx(ak,{className:Z})]}):ve}},[ce,xe.length,de.length,we.length,r,J,z,p,Fe,Re,Z]),ot=b.useMemo(()=>j?"Assistant":kv(t),[j,t]),qe=b.useMemo(()=>j?[]:Array.isArray(T)?T:[],[T,j]),yt=b.useMemo(()=>{var P;return qe.length?O&&qe.some(te=>te.id===O)?O:((P=qe[0])==null?void 0:P.id)??null:null},[O,qe]),Be=b.useMemo(()=>!qe.length||!E?null:qe.some(P=>P.id===E)?E:null,[E,qe])??yt,St=V==="user"&&qe.length>0&&typeof A=="function",xt=b.useCallback((P,te=!1)=>{if(!A)return;const ve=(P==null?void 0:P.id)??null,ae=(P==null?void 0:P.parentId)??F??null;A(ve,ae,te)},[F,A]),Ye=b.useMemo(()=>Be?qe.findIndex(P=>P.id===Be):-1,[Be,qe]),gt=b.useMemo(()=>Ye<0?null:qe[Ye]??null,[Ye,qe]);return J&&!p&&!Fe?null:R&&j?u.jsx("div",{className:re(nt(),f.container),children:u.jsxs("div",{className:re(Ze(),f.content),children:[u.jsxs("div",{className:"flex items-center gap-2 mb-2 pb-2 border-b border-current/10",children:[u.jsx(fe.Bot,{className:re("h-4 w-4",Z)}),a&&u.jsx("span",{className:"font-medium text-sm",children:"Assistant"})]}),u.jsx(jr,{content:j.content,className:"text-current"})]})}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:re(nt(),f.container),children:u.jsxs("div",{className:re(Ze(),f.content),children:[(i||a||J)&&u.jsxs("div",{className:re("flex items-center justify-between mb-2 pb-2 border-b border-current/10",_&&"mb-1 pb-1",Z,f.header),children:[u.jsxs("div",{className:"flex items-center gap-2",children:[tt(),a&&ot&&u.jsx("span",{className:re("font-medium",_?"text-xs":"text-sm"),children:ot}),J&&u.jsxs(bh,{variant:"outline",className:re("text-xs flex items-center gap-1 cursor-pointer select-none",Z,"border border-current/40",_&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":z==="expanded",onClick:()=>N(P=>P==="expanded"?"preview":"expanded"),onKeyDown:P=>{(P.key==="Enter"||P.key===" ")&&(P.preventDefault(),N(te=>te==="expanded"?"preview":"expanded"))},children:[u.jsx("span",{children:L.name??"Tool Output"}),L.toolCallId&&u.jsx("span",{className:"opacity-70",children:L.toolCallId.slice(0,8)}),z==="expanded"?u.jsx(fe.ChevronUp,{className:"h-3 w-3"}):u.jsx(fe.ChevronDown,{className:"h-3 w-3"})]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[St&>&&Ye>=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:re("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",Ye<qe.length-1?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{if(Ye>=qe.length-1)return;const P=qe[Ye+1];P&&xt(P)},"aria-label":"Older checkpoint (back in time)",disabled:Ye>=qe.length-1,children:u.jsx(fe.ChevronLeft,{className:"h-3 w-3"})}),u.jsx("div",{className:"flex items-center gap-2",children:u.jsxs("span",{className:"whitespace-nowrap",children:[qe.length-Ye," / ",qe.length]})}),u.jsx("button",{type:"button",className:re("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",Ye>0?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{if(!(Ye<=0))if(Ye===1)xt(null,!0);else{const P=qe[Ye-1];P&&xt(P,!1)}},"aria-label":"Newer checkpoint (forward in time)",disabled:Ye<=0,children:u.jsx(fe.ChevronRight,{className:"h-3 w-3"})})]})}),i&&t.createdAt&&u.jsx("time",{className:re("text-xs opacity-60",Z,_&&"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:re("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",f.actions),children:[u.jsx("div",{className:"relative",children:u.jsx(ct,{variant:"ghost",size:"sm",onClick:()=>Ge(),className:re("h-6 w-6 p-0 hover:bg-foreground/10",Z,_&&"h-5 w-5"),"aria-label":"Copy message",title:"Copy message",children:u.jsx(fe.Copy,{className:re(U?"text-success":Z,_?"h-3 w-3":"h-4 w-4")})})}),V==="user"&&v&&u.jsx(ct,{variant:"ghost",size:"sm",onClick:Ke,className:re("h-6 w-6 p-0 hover:bg-foreground/10",Z,_&&"h-5 w-5"),"aria-label":"Edit message",children:u.jsx(fe.Edit,{className:re(Z,_?"h-3 w-3":"h-4 w-4")})}),V==="assistant"&&g&&u.jsx(ct,{variant:"ghost",size:"sm",onClick:Xe,className:re("h-6 w-6 p-0 hover:bg-foreground/10",Z,_&&"h-5 w-5"),"aria-label":"Regenerate response",children:u.jsx(fe.RotateCcw,{className:re(Z,_?"h-3 w-3":"h-4 w-4")})})]})]})]}),u.jsxs("div",{className:"relative",children:[mt(),m&&Fe&&u.jsx("div",{className:"mt-3",children:u.jsx(ek,{artifact:Fe,idx:0})})]}),J&&z==="expanded"&&(L.toolCallId||L.name)&&u.jsxs("div",{className:re("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",_&&"text-xs"),children:[L.name&&u.jsxs("div",{children:["Function: ",L.name]}),L.toolCallId&&u.jsxs("div",{children:["Call ID: ",L.toolCallId]})]}),!(i||a||J)&&s&&!o&&u.jsxs("div",{className:re("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",f.actions),children:[u.jsx(ct,{variant:"ghost",size:"sm",onClick:()=>Ge(),className:re("h-6 w-6 p-0 hover:bg-background/50 text-current",_&&"h-5 w-5"),children:u.jsx(fe.Copy,{className:re(U?"text-success":"text-current",_?"h-3 w-3":"h-4 w-4")})}),V==="user"&&v&&u.jsx(ct,{variant:"ghost",size:"sm",onClick:Ke,className:re("h-6 w-6 p-0 hover:bg-background/50 text-current",_&&"h-5 w-5"),children:u.jsx(fe.Edit,{className:re("text-current",_?"h-3 w-3":"h-4 w-4")})}),V==="assistant"&&g&&u.jsx(ct,{variant:"ghost",size:"sm",onClick:Xe,className:re("h-6 w-6 p-0 hover:bg-background/50 text-current",_&&"h-5 w-5"),children:u.jsx(fe.RotateCcw,{className:re("text-current",_?"h-3 w-3":"h-4 w-4")})})]})]})}),D&&u.jsx(Sh,{isOpen:H,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&&fu(e.message)===fu(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=$h(e.message),a=$h(t.message);return i.length===a.length});Ys.displayName="MessageComponent";const Fh=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,Bh=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=Fh(t,n),T="type"in t&&t.type==="default_message",A=!!t.__syntheticStreaming,{checkpointCandidates:O,defaultCheckpointId:F}=Yl(t,w??{checkpoints:[],checkpointMetaById:new Map,checkpointIndexByKey:new Map,attemptMetaById:new Map,userMessageIdToAttempts:new Map,timeline:[],messagePreviews:new Map,getLatest:()=>{},getCheckpoint:()=>{},getAttempts:()=>[]}),U=t&&!T?t.additionalKwargs??{}:{},W=t&&!T?t.responseMetadata??{}:{},z=(()=>{if(typeof U.parentCheckpointId=="string")return U.parentCheckpointId;if(typeof W.parentCheckpointId=="string")return W.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(Ys,{message:t,messageIndex:n,isStreamingMessage:A||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:O,activeCheckpointId:S??null,onSelectCheckpoint:k,defaultCheckpointId:F,messageParentCheckpointId:z})})});Bh.displayName="MessageRow";const El=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:A,activeCheckpointId:O,onSelectCheckpoint:F,createSyntheticThinkingMessage:U=!0},W)=>{const z=b.useRef(null),N=b.useRef(null),q=b.useRef(!1),M=b.useRef(!1),[Q,$]=b.useState(!0),_=b.useMemo(()=>w?e.some(L=>"type"in L&&L.type==="default_message"?!1:Array.isArray(L==null?void 0:L.content)&&L.content.some(oe=>oe&&oe.type==="interrupt"&&(oe.id??oe.interrupt_id)===w.id)):!1,[w,e]),V=b.useMemo(()=>{if(!w||_)return null;const L=w.id&&String(w.id).trim()?String(w.id).trim():"pending-interrupt";let oe;const xe=w.value;if(xe&&typeof xe=="object"&&!Array.isArray(xe)){const de=xe.title;typeof de=="string"&&de.trim()&&(oe=de.trim())}return{id:`interrupt-${L}`,role:"system",createdAt:new Date().toISOString(),content:[{type:"interrupt",id:L,value:xe,title:oe}]}},[w,_]),J=b.useMemo(()=>V?[...e,V]:e,[e,V]),j=b.useMemo(()=>!U||!t?J:!J.some(oe=>oe.role==="assistant")&&J.length>0?[...J,{id:"thinking-assistant",role:"assistant",content:[],createdAt:new Date().toISOString(),__syntheticStreaming:!0}]:J,[J,t,U]),R=b.useMemo(()=>T?j:j.filter(L=>(L==null?void 0:L.role)!=="tool"),[j,T]),G=b.useCallback(L=>{$(L),x&&x(!L),y&&y(L)},[x,y]),Y=b.useMemo(()=>{if(a)return async()=>{if(!q.current){q.current=!0;try{await a()}finally{q.current=!1}}}},[a]),ie=b.useMemo(()=>!v||g?!1:Q?"auto":!1,[Q,v,g]),H=b.useMemo(()=>{if(typeof f!="string")return null;const L=f.trim();return L?{id:"default-message",role:"assistant",type:"default_message",content:L,createdAt:new Date().toISOString()}:null},[f]),D=["flex h-full flex-col md:flex-row",p].filter(Boolean).join(" "),X=()=>H?u.jsx("div",{className:"p-6 h-full overflow-y-auto",children:u.jsx("div",{className:"w-full max-w-full",children:u.jsx(Ys,{message:H,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!"}),Z=R.length,ce=Z>0;return b.useEffect(()=>{var L,oe;if(Z===0){M.current=!1;return}if(!M.current)if(M.current=!0,z.current&&R.length>0){const xe=R.length-1;(oe=(L=z.current).scrollToIndex)==null||oe.call(L,{index:xe,align:"end",behavior:"auto"})}else N.current&&(N.current.scrollTop=N.current.scrollHeight)},[Z,R.length]),b.useImperativeHandle(W,()=>({scrollToLatest:()=>{var L,oe;if(z.current&&R.length>0){const xe=R.length-1;(oe=(L=z.current).scrollToIndex)==null||oe.call(L,{index:xe,align:"end",behavior:"auto"})}else N.current&&(N.current.scrollTop=N.current.scrollHeight)},scrollToTop:()=>{var L,oe;z.current&&R.length>0?(oe=(L=z.current).scrollToIndex)==null||oe.call(L,{index:0,align:"start",behavior:"auto"}):N.current&&(N.current.scrollTop=0)}}),[R]),u.jsx("div",{className:D,style:m,children:u.jsx("div",{className:"relative flex-1 min-h-0",children:ce?u.jsx(hT,{ref:L=>{z.current=L},scrollerRef:L=>{N.current=L instanceof HTMLDivElement?L:null},data:R,followOutput:ie,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,startReached:()=>{Y&&Y()},atBottomStateChange:G,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(L,oe)=>Fh(oe,L),itemContent:(L,oe)=>u.jsx(Bh,{message:oe,index:L,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:A,activeCheckpointId:O,onSelectCheckpoint:F})}):X()})})});El.displayName="MessageList";const zh={value:""};function bo({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}=Ii(),{currentThreadId:y}=zo(),{threadId:w,messages:S,isHistoryLoading:k,isLoading:C,navigateToCheckpoint:T,returnToLatest:E,checkpoint:A,checkpoints:O,interrupt:F,metadata:U,checkpointIndex:W}=Ho(),{isStreaming:z,error:N,connectionState:q,submit:M,stop:Q}=Ri(),$=w??y??null,_=(A==null?void 0:A.id)??null,V=(A==null?void 0:A.namespace)??null,J=(U==null?void 0:U.assemblingMessageId)??null,j=F,[R,G]=b.useState(!1);b.useEffect(()=>{j||G(!1)},[j]);const Y=b.useCallback(()=>{G(!0)},[]),ie=b.useCallback(()=>{G(!1)},[]),H=!!j||R,[D,X]=b.useState(null),[Z,ce]=b.useState(""),[L,oe]=b.useState(null),[xe,de]=b.useState(null),[we,Me]=b.useState([]),[He,$e]=b.useState(0),[Ae,Fe]=b.useState(0),[Ge,Ke]=b.useState(!1),[Xe,tt]=b.useState(null),[nt,Ze]=b.useState(null),[pt,ht]=b.useState(!1),[Se,Re]=b.useState(null),mt=b.useRef(!1),[ot,qe]=b.useState(()=>zh.value),yt=b.useRef(ot),De=b.useRef(null),Be=b.useCallback(ue=>{zh.value=ue,qe(ue)},[]),[St,xt]=b.useState(!1),Ye=b.useRef(null),gt=b.useRef(null),P=b.useRef(null),te=b.useCallback(()=>{gt.current&&(gt.current.value=""),P.current&&(P.current.value=""),$e(ue=>ue+1),Fe(ue=>ue+1)},[]),ve=b.useCallback(ue=>{Be(ue)},[Be]),ae=b.useRef(!1);b.useEffect(()=>{ae.current&&!z&&(Me([]),te()),ae.current=z},[z,te]);const[Ie,Te]=b.useState("desktop");b.useEffect(()=>{const ue=()=>{const be=window.innerWidth;Te(be<640?"phone":be<1024?"tablet":"desktop")};return ue(),window.addEventListener("resize",ue),()=>window.removeEventListener("resize",ue)},[]),b.useEffect(()=>{mt.current=!1},[$]),b.useEffect(()=>{yt.current=ot},[ot]),b.useEffect(()=>{if(!D){De.current=null;return}De.current===null&&(De.current=yt.current),Be(Z??"")},[Z,D,Be]),b.useEffect(()=>{(async()=>{if(!x.baseUrl){Re(null);return}try{const he=(await x.getAgent("default")).uiDefaultMessage||"";Re(he||null)}catch(be){console.warn("Failed to fetch default message:",be),Re(null)}})()},[x.baseUrl]),b.useEffect(()=>{N&&!pt&&(g==null||g(N))},[N,pt,g]);const st=async ue=>{const be=ue.trim();if(!(!be&&we.length===0))try{const he=D?(L==null?void 0:L.checkpointId)??_??void 0:_??void 0,Ee=D?(L==null?void 0:L.checkpointNs)??V??void 0:V??void 0;await M({text:be||"",attachments:we},{checkpointId:he,checkpointNs:Ee,edit:!!D,originalMessageId:D??void 0}),f==null||f(be),Be(""),de(null),Me([]),te(),X(null),ce(""),oe(null)}catch(he){const Ee=(he==null?void 0:he.message)||"Failed to send message";de(Ee),g==null||g(Ee)}},Ue=b.useCallback((ue,be,he)=>{c&&(De.current=ot,X(ue),ce(be),Be(be),de(null),oe({checkpointId:(he==null?void 0:he.checkpointId)??null,checkpointNs:(he==null?void 0:he.checkpointNs)??null}))},[ot,c,Be]),lt=b.useCallback(()=>{X(null),ce(""),oe(null),de(null),Be(De.current??ot),De.current=null},[ot,Be]),Ut=b.useCallback((ue,be,he)=>{Ue(ue,be,he)},[Ue]),Mt=b.useCallback(ue=>{let be=null;for(let et=ue-1;et>=0;et--)if(S[et].role==="user"){be=S[et];break}if(!be)return;const he=Array.isArray(be.content)?be.content:[],Tt=he.filter(et=>(et==null?void 0:et.type)==="text").map(et=>et.text).join("")||(()=>{try{return JSON.stringify(he,null,2)}catch{return String(he)}})();Tt&&M({text:Tt},{checkpointId:_??void 0,checkpointNs:V??void 0,edit:!0,originalMessageId:be.id})},[S,M,_,V]),nn=ue=>{const be=Array.from(ue.target.files||[]);Me(he=>[...he,...be]),ue.target.value=""},Wl=ue=>{Me(be=>{const he=be.filter((Ee,Tt)=>ue!==Tt);return he.length===0&&te(),he})},Vl=async ue=>{const be=(ue.target.files||[])[0];if(be){tt(null),Ze(null),Ke(!0);try{await M({attachments:[be]},{checkpointId:_??void 0,checkpointNs:V??void 0});const he=`Uploaded ${be.name} - processing through chat stream`;Ze(he)}catch(he){const Ee=he instanceof Error?he.message:"Failed to upload Excel file";console.error("Excel upload failed",he),tt(Ee),g==null||g(Ee)}finally{Ke(!1),ue.target.value="",te()}}},li=async ue=>{if(y){xt(!0);try{if(!ue){await E(),requestAnimationFrame(()=>{var Ee;(Ee=Ye.current)==null||Ee.scrollToLatest()});return}const be=O.find(Ee=>Ee.checkpointId===ue),he=(be==null?void 0:be.checkpointNs)??null;await T(ue,he),requestAnimationFrame(()=>{var Ee;(Ee=Ye.current)==null||Ee.scrollToTop()})}finally{xt(!1)}}},I=b.useCallback(async(ue,be,he)=>{await li(he?null:ue)},[li]),ne=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${m.container||""}`,pe=`flex-1 min-h-0 min-w-0 max-h-full w-full overflow-hidden overscroll-contain break-words break-anywhere p-4 bg-transparent ${m.messagesArea||""}`,je=`relative flex-shrink-0 w-full border-t p-4 bg-transparent ${m.inputArea||""}`;return u.jsxs("div",{className:ne,children:[!!N&&!pt&&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:N}),u.jsx(ct,{variant:"ghost",size:"sm",onClick:()=>ht(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:u.jsx(fe.X,{size:16})})]}),u.jsxs("div",{className:`relative ${pe}`,style:r?{maxHeight:r}:void 0,children:[u.jsx(El,{ref:Ye,className:"h-full",style:{height:"100%"},messages:S,isStreaming:z,streamingAssistantId:J,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:Ie,enableMessageEditing:c,editingMessageId:D,onEdit:Ut,onRegenerate:Mt,onCancelEdit:lt,emptyMessage:Se??void 0,isNavigatingCheckpoint:St,activeInterrupt:j,disableInterruptActions:R,onInterruptActionStart:Y,onInterruptActionEnd:ie,showToolMessages:d,showArtifactPreviews:p,checkpointIndex:W,activeCheckpointId:_,onSelectCheckpoint:I,createSyntheticThinkingMessage:!0}),(q==="reconnecting"||q==="connecting")&&u.jsx("div",{className:"pointer-events-none absolute top-3 right-3 z-20 rounded-full bg-muted/80 px-3 py-1 text-xs font-medium text-foreground shadow-sm backdrop-blur-sm dark:bg-muted/60",children:u.jsxs("span",{className:"flex items-center gap-2",children:[u.jsx(fe.Loader2,{className:"h-3 w-3 animate-spin"}),q==="reconnecting"?"Reconnecting…":"Connecting…"]})}),q==="error"&&u.jsx("div",{className:"pointer-events-none absolute top-3 right-3 z-20 rounded-full bg-destructive/10 px-3 py-1 text-xs font-semibold text-destructive shadow-sm",children:"Connection lost"}),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(fe.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading messages…"})]}),(k||St)&&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(fe.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:je,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(fe.Edit3,{size:16,className:"text-blue-600"}),u.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),u.jsx(ct,{variant:"ghost",size:"sm",onClick:lt,className:"text-blue-600 hover:bg-blue-100",children:u.jsx(fe.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:gt,type:"file",multiple:!0,onChange:ue=>nn(ue),className:"hidden"},He),we.length>0&&u.jsx("div",{className:"flex flex-wrap gap-2",children:we.map((ue,be)=>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(fe.Paperclip,{size:14}),u.jsx("span",{className:"truncate max-w-[150px]",children:ue.name}),u.jsx(ct,{variant:"ghost",size:"sm",onClick:()=>Wl(be),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 ${ue.name}`,children:u.jsx(fe.X,{size:12})})]},be))})]}),l&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:P,type:"file",accept:".xls,.xlsx,.xlsm",onChange:Vl,className:"hidden"},Ae),Ge&&u.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(fe.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),nt&&!Ge&&u.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:nt}),Xe&&!Ge&&u.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:Xe})]})]}),xe&&u.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:xe}),u.jsxs("div",{className:"flex items-end gap-2",children:[(a||l)&&u.jsxs(Ts,{children:[u.jsx(ks,{asChild:!0,children:u.jsx(ct,{type:"button",size:"icon",variant:"outline",disabled:z||H,title:"More input actions",className:m.moreButton||"",children:u.jsx(fe.Plus,{size:16})})}),u.jsxs(ao,{align:"start",sideOffset:6,className:"w-52",children:[a&&u.jsxs(Dn,{onClick:()=>{var ue;return(ue=gt.current)==null?void 0:ue.click()},className:"cursor-pointer",children:[u.jsx(fe.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),l&&u.jsxs(Dn,{onClick:()=>{var ue;Ge||(ue=P.current)==null||ue.click()},className:`cursor-pointer ${Ge?"opacity-60 pointer-events-none":""}`,children:[u.jsx(fe.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),u.jsx("div",{className:"flex-1",children:u.jsx(oC,{initialValue:Z,editingMessageId:D,value:ot,onValueChange:ve,placeholder:D?"Edit your message...":t,isStreaming:z,disabled:H,onSend:st,onCancelEdit:lt,onStop:Q,allowEmptySend:we.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":""} ${xe?"border-red-400":""} ${m.textarea||""}`})})]})]})]})}function Hh({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(Uo,{...s,onThreadChange:l,children:u.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:u.jsx(bo,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?u.jsx(Uo,{...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(Va,{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(bo,{onError:s.onError,enableFileUpload:!0})})]})})}):u.jsx(Uo,{...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(Va,{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(bo,{onError:s.onError,enableFileUpload:!0})})]})})}function lk({apiConfig:e,className:t="",onError:n}){return u.jsx(Uo,{apiConfig:e,onError:n,children:u.jsx("div",{className:`h-full ${t}`,children:u.jsx(bo,{})})})}var ck="Label",Uh=h.forwardRef((e,t)=>u.jsx(ye.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())}}));Uh.displayName=ck;var Wh=Uh;const uk=Or.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Vh=h.forwardRef(({className:e,...t},n)=>u.jsx(Wh,{ref:n,className:re(uk(),e),...t}));Vh.displayName=Wh.displayName;function Kh(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 qh=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"}),dk="VisuallyHidden",Xs=h.forwardRef((e,t)=>u.jsx(ye.span,{...e,ref:t,style:{...qh,...e.style}}));Xs.displayName=dk;var fk=Xs,pk=[" ","Enter","ArrowUp","ArrowDown"],hk=[" ","Enter"],ir="Select",[Js,Zs,mk]=as(ir),[Pr,r1]=sn(ir,[mk,Er]),Qs=Er(),[gk,Un]=Pr(ir),[xk,vk]=Pr(ir),Gh=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=Qs(t),[x,y]=h.useState(null),[w,S]=h.useState(null),[k,C]=h.useState(!1),T=ls(c),[E,A]=jn({prop:r,defaultProp:o??!1,onChange:s,caller:ir}),[O,F]=jn({prop:i,defaultProp:a,onChange:l,caller:ir}),U=h.useRef(null),W=x?v||!!x.closest("form"):!0,[z,N]=h.useState(new Set),q=Array.from(z).map(M=>M.props.value).join(";");return u.jsx(Ta,{...g,children:u.jsxs(gk,{required:f,scope:t,trigger:x,onTriggerChange:y,valueNode:w,onValueNodeChange:S,valueNodeHasChildren:k,onValueNodeHasChildrenChange:C,contentId:At(),value:O,onValueChange:F,open:E,onOpenChange:A,dir:T,triggerPointerDownPosRef:U,disabled:m,children:[u.jsx(Js.Provider,{scope:t,children:u.jsx(xk,{scope:e.__scopeSelect,onNativeOptionAdd:h.useCallback(M=>{N(Q=>new Set(Q).add(M))},[]),onNativeOptionRemove:h.useCallback(M=>{N(Q=>{const $=new Set(Q);return $.delete(M),$})},[]),children:n})}),W?u.jsxs(vm,{"aria-hidden":!0,required:f,tabIndex:-1,name:d,autoComplete:p,value:O,onChange:M=>F(M.target.value),disabled:m,form:v,children:[O===void 0?u.jsx("option",{value:""}):null,Array.from(z)]},q):null]})})};Gh.displayName=ir;var Yh="SelectTrigger",Xh=h.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=Qs(n),i=Un(Yh,n),a=i.disabled||r,l=We(t,i.onTriggerChange),c=Zs(n),d=h.useRef("touch"),[p,m,f]=bm(g=>{const x=c().filter(S=>!S.disabled),y=x.find(S=>S.value===i.value),w=ym(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(ka,{asChild:!0,...s,children:u.jsx(ye.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":wm(i.value)?"":void 0,...o,ref:l,onClick:le(o.onClick,g=>{g.currentTarget.focus(),d.current!=="mouse"&&v(g)}),onPointerDown:le(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:le(o.onKeyDown,g=>{const x=p.current!=="";!(g.ctrlKey||g.altKey||g.metaKey)&&g.key.length===1&&m(g.key),!(x&&g.key===" ")&&pk.includes(g.key)&&(v(),g.preventDefault())})})})});Xh.displayName=Yh;var Jh="SelectValue",Zh=h.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=Un(Jh,n),{onValueNodeHasChildrenChange:c}=l,d=s!==void 0,p=We(t,l.onValueNodeChange);return It(()=>{c(d)},[c,d]),u.jsx(ye.span,{...a,ref:p,style:{pointerEvents:"none"},children:wm(l.value)?u.jsx(u.Fragment,{children:i}):s})});Zh.displayName=Jh;var wk="SelectIcon",Qh=h.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return u.jsx(ye.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});Qh.displayName=wk;var bk="SelectPortal",em=e=>u.jsx(qr,{asChild:!0,...e});em.displayName=bk;var ar="SelectContent",tm=h.forwardRef((e,t)=>{const n=Un(ar,e.__scopeSelect),[r,o]=h.useState();if(It(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?Dr.createPortal(u.jsx(nm,{scope:e.__scopeSelect,children:u.jsx(Js.Slot,{scope:e.__scopeSelect,children:u.jsx("div",{children:e.children})})}),s):null}return u.jsx(rm,{...e,ref:t})});tm.displayName=ar;var fn=10,[nm,Wn]=Pr(ar),yk="SelectContentImpl",Sk=Vt.createSlot("SelectContent.RemoveScroll"),rm=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=We(t,H=>k(H)),[A,O]=h.useState(null),[F,U]=h.useState(null),W=Zs(n),[z,N]=h.useState(!1),q=h.useRef(!1);h.useEffect(()=>{if(S)return Yi(S)},[S]),Ui();const M=h.useCallback(H=>{const[D,...X]=W().map(L=>L.ref.current),[Z]=X.slice(-1),ce=document.activeElement;for(const L of H)if(L===ce||(L==null||L.scrollIntoView({block:"nearest"}),L===D&&C&&(C.scrollTop=0),L===Z&&C&&(C.scrollTop=C.scrollHeight),L==null||L.focus(),document.activeElement!==ce))return},[W,C]),Q=h.useCallback(()=>M([A,S]),[M,A,S]);h.useEffect(()=>{z&&Q()},[z,Q]);const{onOpenChange:$,triggerPointerDownPosRef:_}=w;h.useEffect(()=>{if(S){let H={x:0,y:0};const D=Z=>{var ce,L;H={x:Math.abs(Math.round(Z.pageX)-(((ce=_.current)==null?void 0:ce.x)??0)),y:Math.abs(Math.round(Z.pageY)-(((L=_.current)==null?void 0:L.y)??0))}},X=Z=>{H.x<=10&&H.y<=10?Z.preventDefault():S.contains(Z.target)||$(!1),document.removeEventListener("pointermove",D),_.current=null};return _.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,$,_]),h.useEffect(()=>{const H=()=>$(!1);return window.addEventListener("blur",H),window.addEventListener("resize",H),()=>{window.removeEventListener("blur",H),window.removeEventListener("resize",H)}},[$]);const[V,J]=bm(H=>{const D=W().filter(ce=>!ce.disabled),X=D.find(ce=>ce.ref.current===document.activeElement),Z=ym(D,H,X);Z&&setTimeout(()=>Z.ref.current.focus())}),j=h.useCallback((H,D,X)=>{const Z=!q.current&&!X;(w.value!==void 0&&w.value===D||Z)&&(O(H),Z&&(q.current=!0))},[w.value]),R=h.useCallback(()=>S==null?void 0:S.focus(),[S]),G=h.useCallback((H,D,X)=>{const Z=!q.current&&!X;(w.value!==void 0&&w.value===D||Z)&&U(H)},[w.value]),Y=r==="popper"?Il:om,ie=Y===Il?{side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:p,collisionBoundary:m,collisionPadding:f,sticky:v,hideWhenDetached:g,avoidCollisions:x}:{};return u.jsx(nm,{scope:n,content:S,viewport:C,onViewportChange:T,itemRefCallback:j,selectedItem:A,onItemLeave:R,itemTextRefCallback:G,focusSelectedItem:Q,selectedItemText:F,position:r,isPositioned:z,searchRef:V,children:u.jsx(Jo,{as:Sk,allowPinchZoom:!0,children:u.jsx(Wo,{asChild:!0,trapped:w.open,onMountAutoFocus:H=>{H.preventDefault()},onUnmountAutoFocus:le(o,H=>{var D;(D=w.trigger)==null||D.focus({preventScroll:!0}),H.preventDefault()}),children:u.jsx(mr,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:H=>H.preventDefault(),onDismiss:()=>w.onOpenChange(!1),children:u.jsx(Y,{role:"listbox",id:w.contentId,"data-state":w.open?"open":"closed",dir:w.dir,onContextMenu:H=>H.preventDefault(),...y,...ie,onPlaced:()=>N(!0),ref:E,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:le(y.onKeyDown,H=>{const D=H.ctrlKey||H.altKey||H.metaKey;if(H.key==="Tab"&&H.preventDefault(),!D&&H.key.length===1&&J(H.key),["ArrowUp","ArrowDown","Home","End"].includes(H.key)){let Z=W().filter(ce=>!ce.disabled).map(ce=>ce.ref.current);if(["ArrowUp","End"].includes(H.key)&&(Z=Z.slice().reverse()),["ArrowUp","ArrowDown"].includes(H.key)){const ce=H.target,L=Z.indexOf(ce);Z=Z.slice(L+1)}setTimeout(()=>M(Z)),H.preventDefault()}})})})})})})});rm.displayName=yk;var Ck="SelectItemAlignedPosition",om=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=We(t,E=>d(E)),m=Zs(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(),A=c.getBoundingClientRect(),O=s.valueNode.getBoundingClientRect(),F=y.getBoundingClientRect();if(s.dir!=="rtl"){const ce=F.left-A.left,L=O.left-ce,oe=E.left-L,xe=E.width+oe,de=Math.max(xe,A.width),we=window.innerWidth-fn,Me=$a(L,[fn,Math.max(fn,we-de)]);a.style.minWidth=xe+"px",a.style.left=Me+"px"}else{const ce=A.right-F.right,L=window.innerWidth-O.right-ce,oe=window.innerWidth-E.right-L,xe=E.width+oe,de=Math.max(xe,A.width),we=window.innerWidth-fn,Me=$a(L,[fn,Math.max(fn,we-de)]);a.style.minWidth=xe+"px",a.style.right=Me+"px"}const U=m(),W=window.innerHeight-fn*2,z=g.scrollHeight,N=window.getComputedStyle(c),q=parseInt(N.borderTopWidth,10),M=parseInt(N.paddingTop,10),Q=parseInt(N.borderBottomWidth,10),$=parseInt(N.paddingBottom,10),_=q+M+z+$+Q,V=Math.min(x.offsetHeight*5,_),J=window.getComputedStyle(g),j=parseInt(J.paddingTop,10),R=parseInt(J.paddingBottom,10),G=E.top+E.height/2-fn,Y=W-G,ie=x.offsetHeight/2,H=x.offsetTop+ie,D=q+M+H,X=_-D;if(D<=G){const ce=U.length>0&&x===U[U.length-1].ref.current;a.style.bottom="0px";const L=c.clientHeight-g.offsetTop-g.offsetHeight,oe=Math.max(Y,ie+(ce?R:0)+L+Q),xe=D+oe;a.style.height=xe+"px"}else{const ce=U.length>0&&x===U[0].ref.current;a.style.top="0px";const oe=Math.max(G,q+g.offsetTop+(ce?j:0)+ie)+X;a.style.height=oe+"px",g.scrollTop=D-G+g.offsetTop}a.style.margin=`${fn}px 0`,a.style.minHeight=V+"px",a.style.maxHeight=W+"px",r==null||r(),requestAnimationFrame(()=>f.current=!0)}},[m,s.trigger,s.valueNode,a,c,g,x,y,s.dir,r]);It(()=>S(),[S]);const[k,C]=h.useState();It(()=>{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(kk,{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(ye.div,{...o,ref:p,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});om.displayName=Ck;var Tk="SelectPopperPosition",Il=h.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=fn,...s}=e,i=Qs(n);return u.jsx(Ea,{...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)"}})});Il.displayName=Tk;var[kk,Nl]=Pr(ar,{}),Al="SelectViewport",sm=h.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=Wn(Al,n),i=Nl(Al,n),a=We(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(Js.Slot,{scope:n,children:u.jsx(ye.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:le(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=Al;var im="SelectGroup",[Ek,Ik]=Pr(im),Nk=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=At();return u.jsx(Ek,{scope:n,id:o,children:u.jsx(ye.div,{role:"group","aria-labelledby":o,...r,ref:t})})});Nk.displayName=im;var am="SelectLabel",lm=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Ik(am,n);return u.jsx(ye.div,{id:o.id,...r,ref:t})});lm.displayName=am;var ei="SelectItem",[Ak,cm]=Pr(ei),um=h.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=Un(ei,n),l=Wn(ei,n),c=a.value===r,[d,p]=h.useState(s??""),[m,f]=h.useState(!1),v=We(t,w=>{var S;return(S=l.itemRefCallback)==null?void 0:S.call(l,w,r,o)}),g=At(),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(Ak,{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(Js.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:u.jsx(ye.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:le(i.onFocus,()=>f(!0)),onBlur:le(i.onBlur,()=>f(!1)),onClick:le(i.onClick,()=>{x.current!=="mouse"&&y()}),onPointerUp:le(i.onPointerUp,()=>{x.current==="mouse"&&y()}),onPointerDown:le(i.onPointerDown,w=>{x.current=w.pointerType}),onPointerMove:le(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:le(i.onPointerLeave,w=>{var S;w.currentTarget===document.activeElement&&((S=l.onItemLeave)==null||S.call(l))}),onKeyDown:le(i.onKeyDown,w=>{var k;((k=l.searchRef)==null?void 0:k.current)!==""&&w.key===" "||(hk.includes(w.key)&&y(),w.key===" "&&w.preventDefault())})})})})});um.displayName=ei;var yo="SelectItemText",dm=h.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=Un(yo,n),a=Wn(yo,n),l=cm(yo,n),c=vk(yo,n),[d,p]=h.useState(null),m=We(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 It(()=>(g(v),()=>x(v)),[g,x,v]),u.jsxs(u.Fragment,{children:[u.jsx(ye.span,{id:l.textId,...s,ref:m}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?Dr.createPortal(s.children,i.valueNode):null]})});dm.displayName=yo;var fm="SelectItemIndicator",pm=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return cm(fm,n).isSelected?u.jsx(ye.span,{"aria-hidden":!0,...r,ref:t}):null});pm.displayName=fm;var _l="SelectScrollUpButton",hm=h.forwardRef((e,t)=>{const n=Wn(_l,e.__scopeSelect),r=Nl(_l,e.__scopeSelect),[o,s]=h.useState(!1),i=We(t,r.onScrollButtonChange);return It(()=>{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(gm,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});hm.displayName=_l;var jl="SelectScrollDownButton",mm=h.forwardRef((e,t)=>{const n=Wn(jl,e.__scopeSelect),r=Nl(jl,e.__scopeSelect),[o,s]=h.useState(!1),i=We(t,r.onScrollButtonChange);return It(()=>{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(gm,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});mm.displayName=jl;var gm=h.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=Wn("SelectScrollButton",n),i=h.useRef(null),a=Zs(n),l=h.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return h.useEffect(()=>()=>l(),[l]),It(()=>{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(ye.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:le(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:le(o.onPointerMove,()=>{var c;(c=s.onItemLeave)==null||c.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:le(o.onPointerLeave,()=>{l()})})}),_k="SelectSeparator",xm=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return u.jsx(ye.div,{"aria-hidden":!0,...r,ref:t})});xm.displayName=_k;var Pl="SelectArrow",jk=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Qs(n),s=Un(Pl,n),i=Wn(Pl,n);return s.open&&i.position==="popper"?u.jsx(Ia,{...o,...r,ref:t}):null});jk.displayName=Pl;var Pk="SelectBubbleInput",vm=h.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=h.useRef(null),s=We(r,o),i=Kh(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(ye.select,{...n,style:{...qh,...n.style},ref:s,defaultValue:t})});vm.displayName=Pk;function wm(e){return e===""||e===void 0}function bm(e){const t=wt(e),n=h.useRef(""),r=h.useRef(0),o=h.useCallback(i=>{const a=n.current+i;t(a),function l(c){n.current=c,window.clearTimeout(r.current),c!==""&&(r.current=window.setTimeout(()=>l(""),1e3))}(a)},[t]),s=h.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return h.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function ym(e,t,n){const o=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=Mk(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 Mk(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Rk=Gh,Sm=Xh,Ok=Zh,Dk=Qh,Lk=em,Cm=tm,$k=sm,Tm=lm,km=um,Fk=dm,Bk=pm,Em=hm,Im=mm,Nm=xm;const zk=Rk,Hk=Ok,Am=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Sm,{ref:r,className:re("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(Dk,{asChild:!0,children:u.jsx(fe.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));Am.displayName=Sm.displayName;const _m=h.forwardRef(({className:e,...t},n)=>u.jsx(Em,{ref:n,className:re("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(fe.ChevronUp,{className:"h-4 w-4"})}));_m.displayName=Em.displayName;const jm=h.forwardRef(({className:e,...t},n)=>u.jsx(Im,{ref:n,className:re("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(fe.ChevronDown,{className:"h-4 w-4"})}));jm.displayName=Im.displayName;const Pm=h.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>u.jsx(Lk,{children:u.jsxs(Cm,{ref:o,className:re("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(_m,{}),u.jsx($k,{className:re("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),u.jsx(jm,{})]})}));Pm.displayName=Cm.displayName;const Uk=h.forwardRef(({className:e,...t},n)=>u.jsx(Tm,{ref:n,className:re("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));Uk.displayName=Tm.displayName;const Mm=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(km,{ref:r,className:re("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(Bk,{children:u.jsx(fe.Check,{className:"h-4 w-4"})})}),u.jsx(Fk,{children:t})]}));Mm.displayName=km.displayName;const Wk=h.forwardRef(({className:e,...t},n)=>u.jsx(Nm,{ref:n,className:re("-mx-1 my-1 h-px bg-muted",e),...t}));Wk.displayName=Nm.displayName;var Vk="Separator",Rm="horizontal",Kk=["horizontal","vertical"],Om=h.forwardRef((e,t)=>{const{decorative:n,orientation:r=Rm,...o}=e,s=qk(r)?r:Rm,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return u.jsx(ye.div,{"data-orientation":s,...a,...o,ref:t})});Om.displayName=Vk;function qk(e){return Kk.includes(e)}var Dm=Om;const Lm=h.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>u.jsx(Dm,{ref:o,decorative:n,orientation:t,className:re("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));Lm.displayName=Dm.displayName;var ti="Switch",[Gk,o1]=sn(ti),[Yk,Xk]=Gk(ti),$m=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=We(t,S=>f(S)),g=h.useRef(!1),x=m?d||!!m.closest("form"):!0,[y,w]=jn({prop:o,defaultProp:s??!1,onChange:c,caller:ti});return u.jsxs(Yk,{scope:n,checked:y,disabled:a,children:[u.jsx(ye.button,{type:"button",role:"switch","aria-checked":y,"aria-required":i,"data-state":Hm(y),"data-disabled":a?"":void 0,disabled:a,value:l,...p,ref:v,onClick:le(e.onClick,S=>{w(k=>!k),x&&(g.current=S.isPropagationStopped(),g.current||S.stopPropagation())})}),x&&u.jsx(zm,{control:m,bubbles:!g.current,name:r,value:l,checked:y,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});$m.displayName=ti;var Fm="SwitchThumb",Bm=h.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=Xk(Fm,n);return u.jsx(ye.span,{"data-state":Hm(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});Bm.displayName=Fm;var Jk="SwitchBubbleInput",zm=h.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=h.useRef(null),a=We(i,s),l=Kh(n),c=Kd(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}})});zm.displayName=Jk;function Hm(e){return e?"checked":"unchecked"}var Um=$m,Zk=Bm;const Wm=h.forwardRef(({className:e,...t},n)=>u.jsx(Um,{className:re("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(Zk,{className:re("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")})}));Wm.displayName=Um.displayName;const Qk=Qi,eE=Eb,tE=ea,Vm=h.forwardRef(({className:e,...t},n)=>u.jsx(Gr,{className:re("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}));Vm.displayName=Gr.displayName;const nE=Or.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"}}),Km=h.forwardRef(({side:e="right",className:t,children:n,...r},o)=>u.jsxs(tE,{children:[u.jsx(Vm,{}),u.jsxs(Yr,{ref:o,className:re(nE({side:e}),t),...r,children:[n,u.jsxs(pd,{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(fe.X,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Km.displayName=Yr.displayName;const qm=({className:e,...t})=>u.jsx("div",{className:re("flex flex-col space-y-2 text-center sm:text-left",e),...t});qm.displayName="SheetHeader";const Gm=h.forwardRef(({className:e,...t},n)=>u.jsx(Xn,{ref:n,className:re("text-lg font-semibold text-foreground",e),...t}));Gm.displayName=Xn.displayName;const Ym=h.forwardRef(({className:e,...t},n)=>u.jsx(ns,{ref:n,className:re("text-sm text-muted-foreground",e),...t}));Ym.displayName=ns.displayName;var[ni,s1]=sn("Tooltip",[Er]),ri=Er(),Xm="TooltipProvider",rE=700,Ml="tooltip.open",[oE,Rl]=ni(Xm),Jm=e=>{const{__scopeTooltip:t,delayDuration:n=rE,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(oE,{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})};Jm.displayName=Xm;var So="Tooltip",[sE,oi]=ni(So),Zm=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:s,disableHoverableContent:i,delayDuration:a}=e,l=Rl(So,e.__scopeTooltip),c=ri(t),[d,p]=h.useState(null),m=At(),f=h.useRef(0),v=i??l.disableHoverableContent,g=a??l.delayDuration,x=h.useRef(!1),[y,w]=jn({prop:r,defaultProp:o??!1,onChange:E=>{E?(l.onOpen(),document.dispatchEvent(new CustomEvent(Ml))):l.onClose(),s==null||s(E)},caller:So}),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(Ta,{...c,children:u.jsx(sE,{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})})};Zm.displayName=So;var Ol="TooltipTrigger",Qm=h.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=oi(Ol,n),s=Rl(Ol,n),i=ri(n),a=h.useRef(null),l=We(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(ka,{asChild:!0,...i,children:u.jsx(ye.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:l,onPointerMove:le(e.onPointerMove,m=>{m.pointerType!=="touch"&&!d.current&&!s.isPointerInTransitRef.current&&(o.onTriggerEnter(),d.current=!0)}),onPointerLeave:le(e.onPointerLeave,()=>{o.onTriggerLeave(),d.current=!1}),onPointerDown:le(e.onPointerDown,()=>{o.open&&o.onClose(),c.current=!0,document.addEventListener("pointerup",p,{once:!0})}),onFocus:le(e.onFocus,()=>{c.current||o.onOpen()}),onBlur:le(e.onBlur,o.onClose),onClick:le(e.onClick,o.onClose)})})});Qm.displayName=Ol;var iE="TooltipPortal",[i1,aE]=ni(iE,{forceMount:void 0}),Mr="TooltipContent",eg=h.forwardRef((e,t)=>{const n=aE(Mr,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...s}=e,i=oi(Mr,e.__scopeTooltip);return u.jsx(Ft,{present:r||i.open,children:i.disableHoverableContent?u.jsx(tg,{side:o,...s,ref:t}):u.jsx(lE,{side:o,...s,ref:t})})}),lE=h.forwardRef((e,t)=>{const n=oi(Mr,e.__scopeTooltip),r=Rl(Mr,e.__scopeTooltip),o=h.useRef(null),s=We(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=pE(y,x.getBoundingClientRect()),S=hE(y,w),k=mE(g.getBoundingClientRect()),C=xE([...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=!gE(y,i);w?m():S&&(m(),c())};return document.addEventListener("pointermove",v),()=>document.removeEventListener("pointermove",v)}},[l,d,i,c,m]),u.jsx(tg,{...e,ref:s})}),[cE,uE]=ni(So,{isInside:!1}),dE=Vt.createSlottable("TooltipContent"),tg=h.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:s,onPointerDownOutside:i,...a}=e,l=oi(Mr,n),c=ri(n),{onClose:d}=l;return h.useEffect(()=>(document.addEventListener(Ml,d),()=>document.removeEventListener(Ml,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(mr,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:p=>p.preventDefault(),onDismiss:d,children:u.jsxs(Ea,{"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(dE,{children:r}),u.jsx(cE,{scope:n,isInside:!0,children:u.jsx(fk,{id:l.contentId,role:"tooltip",children:o||r})})]})})});eg.displayName=Mr;var ng="TooltipArrow",fE=h.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=ri(n);return uE(ng,n).isInside?null:u.jsx(Ia,{...o,...r,ref:t})});fE.displayName=ng;function pE(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 hE(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 mE(e){const{top:t,right:n,bottom:r,left:o}=e;return[{x:o,y:t},{x:n,y:t},{x:n,y:r},{x:o,y:r}]}function gE(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const a=t[s],l=t[i],c=a.x,d=a.y,p=l.x,m=l.y;d>r!=m>r&&n<(p-c)*(r-d)/(m-d)+c&&(o=!o)}return o}function xE(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),vE(t)}function vE(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 wE=Jm,bE=Zm,yE=Qm,rg=eg;const SE=wE,CE=bE,TE=yE,og=h.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(rg,{ref:r,sideOffset:t,className:re("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}));og.displayName=rg.displayName;var Dl="ToastProvider",[Ll,kE,EE]=as("Toast"),[sg,a1]=sn("Toast",[EE]),[IE,si]=sg(Dl),ig=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 \`${Dl}\`. Expected non-empty \`string\`.`),u.jsx(Ll.Provider,{scope:t,children:u.jsx(IE,{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})})};ig.displayName=Dl;var ag="ToastViewport",NE=["F8"],$l="toast.viewportPause",Fl="toast.viewportResume",lg=h.forwardRef((e,t)=>{const{__scopeToast:n,hotkey:r=NE,label:o="Notifications ({hotkey})",...s}=e,i=si(ag,n),a=kE(n),l=h.useRef(null),c=h.useRef(null),d=h.useRef(null),p=h.useRef(null),m=We(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($l);y.dispatchEvent(T),i.isClosePausedRef.current=!0}},S=()=>{if(i.isClosePausedRef.current){const T=new CustomEvent(Fl);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,...zE(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 A=document.activeElement,O=w.shiftKey;if(w.target===x&&O){(C=c.current)==null||C.focus();return}const W=g({tabbingDirection:O?"backwards":"forwards"}),z=W.findIndex(N=>N===A);Hl(W.slice(z+1))?w.preventDefault():O?(T=c.current)==null||T.focus():(E=d.current)==null||E.focus()}};return x.addEventListener("keydown",y),()=>x.removeEventListener("keydown",y)}},[a,g]),u.jsxs(bw,{ref:l,role:"region","aria-label":o.replace("{hotkey}",f),tabIndex:-1,style:{pointerEvents:v?void 0:"none"},children:[v&&u.jsx(Bl,{ref:c,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"forwards"});Hl(x)}}),u.jsx(Ll.Slot,{scope:n,children:u.jsx(ye.ol,{tabIndex:-1,...s,ref:m})}),v&&u.jsx(Bl,{ref:d,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"backwards"});Hl(x)}})]})});lg.displayName=ag;var cg="ToastFocusProxy",Bl=h.forwardRef((e,t)=>{const{__scopeToast:n,onFocusFromOutsideViewport:r,...o}=e,s=si(cg,n);return u.jsx(Xs,{tabIndex:0,...o,ref:t,style:{position:"fixed"},onFocus:i=>{var c;const a=i.relatedTarget;!((c=s.viewport)!=null&&c.contains(a))&&r()}})});Bl.displayName=cg;var Co="Toast",AE="toast.swipeStart",_E="toast.swipeMove",jE="toast.swipeCancel",PE="toast.swipeEnd",ug=h.forwardRef((e,t)=>{const{forceMount:n,open:r,defaultOpen:o,onOpenChange:s,...i}=e,[a,l]=jn({prop:r,defaultProp:o??!0,onChange:s,caller:Co});return u.jsx(Ft,{present:n||a,children:u.jsx(OE,{open:a,...i,ref:t,onClose:()=>l(!1),onPause:wt(e.onPause),onResume:wt(e.onResume),onSwipeStart:le(e.onSwipeStart,c=>{c.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:le(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:le(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:le(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)})})})});ug.displayName=Co;var[ME,RE]=sg(Co,{onClose(){}}),OE=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=si(Co,n),[x,y]=h.useState(null),w=We(t,N=>y(N)),S=h.useRef(null),k=h.useRef(null),C=o||g.duration,T=h.useRef(0),E=h.useRef(C),A=h.useRef(0),{onToastAdd:O,onToastRemove:F}=g,U=wt(()=>{var q;(x==null?void 0:x.contains(document.activeElement))&&((q=g.viewport)==null||q.focus()),i()}),W=h.useCallback(N=>{!N||N===1/0||(window.clearTimeout(A.current),T.current=new Date().getTime(),A.current=window.setTimeout(U,N))},[U]);h.useEffect(()=>{const N=g.viewport;if(N){const q=()=>{W(E.current),c==null||c()},M=()=>{const Q=new Date().getTime()-T.current;E.current=E.current-Q,window.clearTimeout(A.current),l==null||l()};return N.addEventListener($l,M),N.addEventListener(Fl,q),()=>{N.removeEventListener($l,M),N.removeEventListener(Fl,q)}}},[g.viewport,C,l,c,W]),h.useEffect(()=>{s&&!g.isClosePausedRef.current&&W(C)},[s,C,g.isClosePausedRef,W]),h.useEffect(()=>(O(),()=>F()),[O,F]);const z=h.useMemo(()=>x?xg(x):null,[x]);return g.viewport?u.jsxs(u.Fragment,{children:[z&&u.jsx(DE,{__scopeToast:n,role:"status","aria-live":r==="foreground"?"assertive":"polite",children:z}),u.jsx(ME,{scope:n,onClose:U,children:Dr.createPortal(u.jsx(Ll.ItemSlot,{scope:n,children:u.jsx(ww,{asChild:!0,onEscapeKeyDown:le(a,()=>{g.isFocusedToastEscapeKeyDownRef.current||U(),g.isFocusedToastEscapeKeyDownRef.current=!1}),children:u.jsx(ye.li,{tabIndex:0,"data-state":s?"open":"closed","data-swipe-direction":g.swipeDirection,...v,ref:w,style:{userSelect:"none",touchAction:"none",...e.style},onKeyDown:le(e.onKeyDown,N=>{N.key==="Escape"&&(a==null||a(N.nativeEvent),N.nativeEvent.defaultPrevented||(g.isFocusedToastEscapeKeyDownRef.current=!0,U()))}),onPointerDown:le(e.onPointerDown,N=>{N.button===0&&(S.current={x:N.clientX,y:N.clientY})}),onPointerMove:le(e.onPointerMove,N=>{if(!S.current)return;const q=N.clientX-S.current.x,M=N.clientY-S.current.y,Q=!!k.current,$=["left","right"].includes(g.swipeDirection),_=["left","up"].includes(g.swipeDirection)?Math.min:Math.max,V=$?_(0,q):0,J=$?0:_(0,M),j=N.pointerType==="touch"?10:2,R={x:V,y:J},G={originalEvent:N,delta:R};Q?(k.current=R,ii(_E,p,G,{discrete:!1})):vg(R,g.swipeDirection,j)?(k.current=R,ii(AE,d,G,{discrete:!1}),N.target.setPointerCapture(N.pointerId)):(Math.abs(q)>j||Math.abs(M)>j)&&(S.current=null)}),onPointerUp:le(e.onPointerUp,N=>{const q=k.current,M=N.target;if(M.hasPointerCapture(N.pointerId)&&M.releasePointerCapture(N.pointerId),k.current=null,S.current=null,q){const Q=N.currentTarget,$={originalEvent:N,delta:q};vg(q,g.swipeDirection,g.swipeThreshold)?ii(PE,f,$,{discrete:!0}):ii(jE,m,$,{discrete:!0}),Q.addEventListener("click",_=>_.preventDefault(),{once:!0})}})})})}),g.viewport)})]}):null}),DE=e=>{const{__scopeToast:t,children:n,...r}=e,o=si(Co,t),[s,i]=h.useState(!1),[a,l]=h.useState(!1);return FE(()=>i(!0)),h.useEffect(()=>{const c=window.setTimeout(()=>l(!0),1e3);return()=>window.clearTimeout(c)},[]),a?null:u.jsx(qr,{asChild:!0,children:u.jsx(Xs,{...r,children:s&&u.jsxs(u.Fragment,{children:[o.label," ",n]})})})},LE="ToastTitle",dg=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(ye.div,{...r,ref:t})});dg.displayName=LE;var $E="ToastDescription",fg=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(ye.div,{...r,ref:t})});fg.displayName=$E;var pg="ToastAction",hg=h.forwardRef((e,t)=>{const{altText:n,...r}=e;return n.trim()?u.jsx(gg,{altText:n,asChild:!0,children:u.jsx(zl,{...r,ref:t})}):(console.error(`Invalid prop \`altText\` supplied to \`${pg}\`. Expected non-empty \`string\`.`),null)});hg.displayName=pg;var mg="ToastClose",zl=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e,o=RE(mg,n);return u.jsx(gg,{asChild:!0,children:u.jsx(ye.button,{type:"button",...r,ref:t,onClick:le(e.onClick,o.onClose)})})});zl.displayName=mg;var gg=h.forwardRef((e,t)=>{const{__scopeToast:n,altText:r,...o}=e;return u.jsx(ye.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":r||void 0,...o,ref:t})});function xg(e){const t=[];return Array.from(e.childNodes).forEach(r=>{if(r.nodeType===r.TEXT_NODE&&r.textContent&&t.push(r.textContent),BE(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(...xg(r))}}),t}function ii(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?$i(o,s):o.dispatchEvent(s)}var vg=(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 FE(e=()=>{}){const t=wt(e);It(()=>{let n=0,r=0;return n=window.requestAnimationFrame(()=>r=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(n),window.cancelAnimationFrame(r)}},[t])}function BE(e){return e.nodeType===e.ELEMENT_NODE}function zE(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 Hl(e){const t=document.activeElement;return e.some(n=>n===t?!0:(n.focus(),document.activeElement!==t))}var HE=ig,wg=lg,bg=ug,yg=dg,Sg=fg,Cg=hg,Tg=zl;const UE=HE,kg=h.forwardRef(({className:e,...t},n)=>u.jsx(wg,{ref:n,className:re("fixed bottom-0 right-0 z-[100] flex max-h-screen w-full flex-col p-4 md:max-w-[420px]",e),...t}));kg.displayName=wg.displayName;const WE=Or.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"}}),Eg=h.forwardRef(({className:e,variant:t,...n},r)=>u.jsx(bg,{ref:r,className:re(WE({variant:t}),e),...n}));Eg.displayName=bg.displayName;const VE=h.forwardRef(({className:e,...t},n)=>u.jsx(Cg,{ref:n,className:re("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}));VE.displayName=Cg.displayName;const Ig=h.forwardRef(({className:e,...t},n)=>u.jsx(Tg,{ref:n,className:re("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(fe.X,{className:"h-4 w-4"})}));Ig.displayName=Tg.displayName;const Ng=h.forwardRef(({className:e,...t},n)=>u.jsx(yg,{ref:n,className:re("text-sm font-semibold",e),...t}));Ng.displayName=yg.displayName;const Ag=h.forwardRef(({className:e,...t},n)=>u.jsx(Sg,{ref:n,className:re("text-sm opacity-90",e),...t}));Ag.displayName=Sg.displayName;function KE(){const{toasts:e}=vl();return u.jsxs(UE,{children:[e.map(function({id:t,title:n,description:r,action:o,...s}){return u.jsxs(Eg,{...s,children:[u.jsxs("div",{className:"grid gap-1",children:[n&&u.jsx(Ng,{children:n}),r&&u.jsx(Ag,{children:r})]}),o,u.jsx(Ig,{})]},t)}),u.jsx(kg,{})]})}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{}},GE=h.createContext(void 0),YE={setTheme:e=>{},themes:[]},XE=()=>{var e;return(e=h.useContext(GE))!=null?e:YE};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 JE=e=>{switch(e){case"success":return eI;case"info":return nI;case"warning":return tI;case"error":return rI;default:return null}},ZE=Array(12).fill(0),QE=({visible:e,className:t})=>b.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},b.createElement("div",{className:"sonner-spinner"},ZE.map((n,r)=>b.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),eI=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"})),tI=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"})),nI=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"})),rI=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"})),oI=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"})),sI=()=>{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},Ul=1,iI=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:Ul++,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(lI(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)||Ul++;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 iI,aI=(e,t)=>{let n=(t==null?void 0:t.id)||Ul++;return Ht.addToast({title:e,...t,id:n}),n},lI=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",cI=aI,uI=()=>Ht.toasts,dI=()=>Ht.getActiveToasts();Object.assign(cI,{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:uI,getToasts:dI});function fI(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))}fI(`: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 ai(e){return e.label!==void 0}var pI=3,hI="32px",mI="16px",_g=4e3,gI=356,xI=14,vI=20,wI=200;function pn(...e){return e.filter(Boolean).join(" ")}function bI(e){let[t,n]=e.split("-"),r=[];return t&&r.push(t),n&&r.push(n),r}var yI=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:A,style:O,cancelButtonStyle:F,actionButtonStyle:U,className:W="",descriptionClassName:z="",duration:N,position:q,gap:M,loadingIcon:Q,expandByDefault:$,classNames:_,icons:V,closeButtonAriaLabel:J="Close toast",pauseWhenPageIsHidden:j}=e,[R,G]=b.useState(null),[Y,ie]=b.useState(null),[H,D]=b.useState(!1),[X,Z]=b.useState(!1),[ce,L]=b.useState(!1),[oe,xe]=b.useState(!1),[de,we]=b.useState(!1),[Me,He]=b.useState(0),[$e,Ae]=b.useState(0),Fe=b.useRef(f.duration||N||_g),Ge=b.useRef(null),Ke=b.useRef(null),Xe=S===0,tt=S+1<=y,nt=f.type,Ze=f.dismissible!==!1,pt=f.className||"",ht=f.descriptionClassName||"",Se=b.useMemo(()=>w.findIndex(ae=>ae.toastId===f.id)||0,[w,f.id]),Re=b.useMemo(()=>{var ae;return(ae=f.closeButton)!=null?ae:A},[f.closeButton,A]),mt=b.useMemo(()=>f.duration||N||_g,[f.duration,N]),ot=b.useRef(0),qe=b.useRef(0),yt=b.useRef(0),De=b.useRef(null),[Be,St]=q.split("-"),xt=b.useMemo(()=>w.reduce((ae,Ie,Te)=>Te>=Se?ae:ae+Ie.height,0),[w,Se]),Ye=sI(),gt=f.invert||m,P=nt==="loading";qe.current=b.useMemo(()=>Se*M+xt,[Se,xt]),b.useEffect(()=>{Fe.current=mt},[mt]),b.useEffect(()=>{D(!0)},[]),b.useEffect(()=>{let ae=Ke.current;if(ae){let Ie=ae.getBoundingClientRect().height;return Ae(Ie),x(Te=>[{toastId:f.id,height:Ie,position:f.position},...Te]),()=>x(Te=>Te.filter(st=>st.toastId!==f.id))}},[x,f.id]),b.useLayoutEffect(()=>{if(!H)return;let ae=Ke.current,Ie=ae.style.height;ae.style.height="auto";let Te=ae.getBoundingClientRect().height;ae.style.height=Ie,Ae(Te),x(st=>st.find(Ue=>Ue.toastId===f.id)?st.map(Ue=>Ue.toastId===f.id?{...Ue,height:Te}:Ue):[{toastId:f.id,height:Te,position:f.position},...st])},[H,f.title,f.description,x,f.id]);let te=b.useCallback(()=>{Z(!0),He(qe.current),x(ae=>ae.filter(Ie=>Ie.toastId!==f.id)),setTimeout(()=>{T(f)},wI)},[f,T,x,qe]);b.useEffect(()=>{if(f.promise&&nt==="loading"||f.duration===1/0||f.type==="loading")return;let ae;return C||g||j&&Ye?(()=>{if(yt.current<ot.current){let Ie=new Date().getTime()-ot.current;Fe.current=Fe.current-Ie}yt.current=new Date().getTime()})():Fe.current!==1/0&&(ot.current=new Date().getTime(),ae=setTimeout(()=>{var Ie;(Ie=f.onAutoClose)==null||Ie.call(f,f),te()},Fe.current)),()=>clearTimeout(ae)},[C,g,f,nt,j,Ye,te]),b.useEffect(()=>{f.delete&&te()},[te,f.delete]);function ve(){var ae,Ie,Te;return V!=null&&V.loading?b.createElement("div",{className:pn(_==null?void 0:_.loader,(ae=f==null?void 0:f.classNames)==null?void 0:ae.loader,"sonner-loader"),"data-visible":nt==="loading"},V.loading):Q?b.createElement("div",{className:pn(_==null?void 0:_.loader,(Ie=f==null?void 0:f.classNames)==null?void 0:Ie.loader,"sonner-loader"),"data-visible":nt==="loading"},Q):b.createElement(QE,{className:pn(_==null?void 0:_.loader,(Te=f==null?void 0:f.classNames)==null?void 0:Te.loader),visible:nt==="loading"})}return b.createElement("li",{tabIndex:0,ref:Ke,className:pn(W,pt,_==null?void 0:_.toast,(t=f==null?void 0:f.classNames)==null?void 0:t.toast,_==null?void 0:_.default,_==null?void 0:_[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":H,"data-promise":!!f.promise,"data-swiped":de,"data-removed":X,"data-visible":tt,"data-y-position":Be,"data-x-position":St,"data-index":S,"data-front":Xe,"data-swiping":ce,"data-dismissible":Ze,"data-type":nt,"data-invert":gt,"data-swipe-out":oe,"data-swipe-direction":Y,"data-expanded":!!(C||$&&H),style:{"--index":S,"--toasts-before":S,"--z-index":k.length-S,"--offset":`${X?Me:qe.current}px`,"--initial-height":$?"auto":`${$e}px`,...O,...f.style},onDragEnd:()=>{L(!1),G(null),De.current=null},onPointerDown:ae=>{P||!Ze||(Ge.current=new Date,He(qe.current),ae.target.setPointerCapture(ae.pointerId),ae.target.tagName!=="BUTTON"&&(L(!0),De.current={x:ae.clientX,y:ae.clientY}))},onPointerUp:()=>{var ae,Ie,Te,st;if(oe||!Ze)return;De.current=null;let Ue=Number(((ae=Ke.current)==null?void 0:ae.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),lt=Number(((Ie=Ke.current)==null?void 0:Ie.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),Ut=new Date().getTime()-((Te=Ge.current)==null?void 0:Te.getTime()),Mt=R==="x"?Ue:lt,nn=Math.abs(Mt)/Ut;if(Math.abs(Mt)>=vI||nn>.11){He(qe.current),(st=f.onDismiss)==null||st.call(f,f),ie(R==="x"?Ue>0?"right":"left":lt>0?"down":"up"),te(),xe(!0),we(!1);return}L(!1),G(null)},onPointerMove:ae=>{var Ie,Te,st,Ue;if(!De.current||!Ze||((Ie=window.getSelection())==null?void 0:Ie.toString().length)>0)return;let lt=ae.clientY-De.current.y,Ut=ae.clientX-De.current.x,Mt=(Te=e.swipeDirections)!=null?Te:bI(q);!R&&(Math.abs(Ut)>1||Math.abs(lt)>1)&&G(Math.abs(Ut)>Math.abs(lt)?"x":"y");let nn={x:0,y:0};R==="y"?(Mt.includes("top")||Mt.includes("bottom"))&&(Mt.includes("top")&<<0||Mt.includes("bottom")&<>0)&&(nn.y=lt):R==="x"&&(Mt.includes("left")||Mt.includes("right"))&&(Mt.includes("left")&&Ut<0||Mt.includes("right")&&Ut>0)&&(nn.x=Ut),(Math.abs(nn.x)>0||Math.abs(nn.y)>0)&&we(!0),(st=Ke.current)==null||st.style.setProperty("--swipe-amount-x",`${nn.x}px`),(Ue=Ke.current)==null||Ue.style.setProperty("--swipe-amount-y",`${nn.y}px`)}},Re&&!f.jsx?b.createElement("button",{"aria-label":J,"data-disabled":P,"data-close-button":!0,onClick:P||!Ze?()=>{}:()=>{var ae;te(),(ae=f.onDismiss)==null||ae.call(f,f)},className:pn(_==null?void 0:_.closeButton,(o=f==null?void 0:f.classNames)==null?void 0:o.closeButton)},(s=V==null?void 0:V.close)!=null?s:oI):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(_==null?void 0:_.icon,(i=f==null?void 0:f.classNames)==null?void 0:i.icon)},f.promise||f.type==="loading"&&!f.icon?f.icon||ve():null,f.type!=="loading"?f.icon||(V==null?void 0:V[nt])||JE(nt):null):null,b.createElement("div",{"data-content":"",className:pn(_==null?void 0:_.content,(a=f==null?void 0:f.classNames)==null?void 0:a.content)},b.createElement("div",{"data-title":"",className:pn(_==null?void 0:_.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(z,ht,_==null?void 0:_.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&&ai(f.cancel)?b.createElement("button",{"data-button":!0,"data-cancel":!0,style:f.cancelButtonStyle||F,onClick:ae=>{var Ie,Te;ai(f.cancel)&&Ze&&((Te=(Ie=f.cancel).onClick)==null||Te.call(Ie,ae),te())},className:pn(_==null?void 0:_.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&&ai(f.action)?b.createElement("button",{"data-button":!0,"data-action":!0,style:f.actionButtonStyle||U,onClick:ae=>{var Ie,Te;ai(f.action)&&((Te=(Ie=f.action).onClick)==null||Te.call(Ie,ae),!ae.defaultPrevented&&te())},className:pn(_==null?void 0:_.actionButton,(p=f==null?void 0:f.classNames)==null?void 0:p.actionButton)},f.action.label):null))};function jg(){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 SI(e,t){let n={};return[e,t].forEach((r,o)=>{let s=o===1,i=s?"--mobile-offset":"--offset",a=s?mI:hI;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 CI=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=pI,toastOptions:g,dir:x=jg(),gap:y=xI,loadingIcon:w,icons:S,containerAriaLabel:k="Notifications",pauseWhenPageIsHidden:C}=e,[T,E]=b.useState([]),A=b.useMemo(()=>Array.from(new Set([r].concat(T.filter(j=>j.position).map(j=>j.position)))),[T,r]),[O,F]=b.useState([]),[U,W]=b.useState(!1),[z,N]=b.useState(!1),[q,M]=b.useState(d!=="system"?d:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),Q=b.useRef(null),$=o.join("+").replace(/Key/g,"").replace(/Digit/g,""),_=b.useRef(null),V=b.useRef(!1),J=b.useCallback(j=>{E(R=>{var G;return(G=R.find(Y=>Y.id===j.id))!=null&&G.delete||Ht.dismiss(j.id),R.filter(({id:Y})=>Y!==j.id)})},[]);return b.useEffect(()=>Ht.subscribe(j=>{if(j.dismiss){E(R=>R.map(G=>G.id===j.id?{...G,delete:!0}:G));return}setTimeout(()=>{To.flushSync(()=>{E(R=>{let G=R.findIndex(Y=>Y.id===j.id);return G!==-1?[...R.slice(0,G),{...R[G],...j},...R.slice(G+1)]:[j,...R]})})})}),[]),b.useEffect(()=>{if(d!=="system"){M(d);return}if(d==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?M("dark"):M("light")),typeof window>"u")return;let j=window.matchMedia("(prefers-color-scheme: dark)");try{j.addEventListener("change",({matches:R})=>{M(R?"dark":"light")})}catch{j.addListener(({matches:G})=>{try{M(G?"dark":"light")}catch(Y){console.error(Y)}})}},[d]),b.useEffect(()=>{T.length<=1&&W(!1)},[T]),b.useEffect(()=>{let j=R=>{var G,Y;o.every(ie=>R[ie]||R.code===ie)&&(W(!0),(G=Q.current)==null||G.focus()),R.code==="Escape"&&(document.activeElement===Q.current||(Y=Q.current)!=null&&Y.contains(document.activeElement))&&W(!1)};return document.addEventListener("keydown",j),()=>document.removeEventListener("keydown",j)},[o]),b.useEffect(()=>{if(Q.current)return()=>{_.current&&(_.current.focus({preventScroll:!0}),_.current=null,V.current=!1)}},[Q.current]),b.createElement("section",{ref:t,"aria-label":`${k} ${$}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},A.map((j,R)=>{var G;let[Y,ie]=j.split("-");return T.length?b.createElement("ol",{key:j,dir:x==="auto"?jg():x,tabIndex:-1,ref:Q,className:a,"data-sonner-toaster":!0,"data-theme":q,"data-y-position":Y,"data-lifted":U&&T.length>1&&!s,"data-x-position":ie,style:{"--front-toast-height":`${((G=O[0])==null?void 0:G.height)||0}px`,"--width":`${gI}px`,"--gap":`${y}px`,...f,...SI(l,c)},onBlur:H=>{V.current&&!H.currentTarget.contains(H.relatedTarget)&&(V.current=!1,_.current&&(_.current.focus({preventScroll:!0}),_.current=null))},onFocus:H=>{H.target instanceof HTMLElement&&H.target.dataset.dismissible==="false"||V.current||(V.current=!0,_.current=H.relatedTarget)},onMouseEnter:()=>W(!0),onMouseMove:()=>W(!0),onMouseLeave:()=>{z||W(!1)},onDragEnd:()=>W(!1),onPointerDown:H=>{H.target instanceof HTMLElement&&H.target.dataset.dismissible==="false"||N(!0)},onPointerUp:()=>N(!1)},T.filter(H=>!H.position&&R===0||H.position===j).map((H,D)=>{var X,Z;return b.createElement(yI,{key:H.id,icons:S,index:D,toast:H,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:(Z=g==null?void 0:g.closeButton)!=null?Z:i,interacting:z,position:j,style:g==null?void 0:g.style,unstyled:g==null?void 0:g.unstyled,classNames:g==null?void 0:g.classNames,cancelButtonStyle:g==null?void 0:g.cancelButtonStyle,actionButtonStyle:g==null?void 0:g.actionButtonStyle,removeToast:J,toasts:T.filter(ce=>ce.position==H.position),heights:O.filter(ce=>ce.position==H.position),setHeights:F,expandByDefault:s,gap:y,loadingIcon:w,expanded:U,pauseWhenPageIsHidden:C,swipeDirections:e.swipeDirections})})):null}))});const TI=({...e})=>{const{theme:t="system"}=XE();return u.jsx(CI,{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})};K.Api=pv,K.ApiClient=fv,K.ApiProvider=lu,K.Badge=bh,K.Button=ct,K.Card=yl,K.CardContent=kl,K.CardDescription=Tl,K.CardHeader=Sl,K.CardTitle=Cl,K.ChatApi=$o,K.ChatApp=Hh,K.ChatInput=yp,K.ChatInterface=bo,K.Command=sa,K.CommandEmpty=la,K.CommandGroup=ca,K.CommandInput=ia,K.CommandItem=ua,K.CommandList=aa,K.DEFAULT_TIMEOUT_MS=qc,K.Dialog=oa,K.DialogContent=os,K.DialogHeader=ss,K.DialogTitle=is,K.DropdownMenu=Ts,K.DropdownMenuContent=ao,K.DropdownMenuItem=Dn,K.DropdownMenuTrigger=ks,K.FileViewerModal=Sh,K.HISTORY_TIMEOUT_MS=Gc,K.Input=Wa,K.Label=Vh,K.MarkdownContent=jr,K.MessageComponent=Ys,K.MessageList=El,K.SETTINGS_STORAGE_KEY=Ni,K.ScrollArea=Ua,K.Select=zk,K.SelectContent=Pm,K.SelectItem=Mm,K.SelectTrigger=Am,K.SelectValue=Hk,K.Separator=Lm,K.Sheet=Qk,K.SheetContent=Km,K.SheetDescription=Ym,K.SheetHeader=qm,K.SheetTitle=Gm,K.SheetTrigger=eE,K.SimpleChat=lk,K.Sonner=TI,K.Switch=Wm,K.Textarea=Ka,K.ThreadManager=Va,K.TimelineColumn=Ug,K.Toaster=KE,K.Tooltip=CE,K.TooltipContent=og,K.TooltipProvider=SE,K.TooltipTrigger=TE,K.applySettings=vv,K.buildAttemptMaps=Xl,K.buildCheckpointIndex=Zl,K.buildCheckpointPreviewMap=Lg,K.chatApiClient=An,K.default=Hh,K.del=Ti,K.downloadFileById=Xc,K.extractConfigFields=ui,K.fileToBase64=Zc,K.get=qt,K.getChatToken=Vc,K.getCurrentSettings=xv,K.getDefaultApiConfig=ru,K.getDefaultChatSettings=ou,K.getFileContent=Ei,K.getFileInfo=mv,K.getPreviewForMessage=ci,K.httpClient=Kt,K.hydrateHistorySnapshots=Nn,K.listFiles=Jc,K.loadStoredSettings=su,K.onChatTokenChanged=Kc,K.post=Lo,K.processAttachments=Qc,K.put=Yc,K.readNumber=ec,K.readString=Vn,K.resolveChatBaseUrl=mn,K.resolveMessageMetadata=Gl,K.saveSettings=iu,K.setChatToken=Do,K.toPlainObject=cr,K.unwrap=Rt,K.useApi=Ii,K.useCheckpointIndex=Ql,K.useHasChatSession=qv,K.useMessageMetadata=Yl,K.useStream=Ri,K.useStreamingHook=Ri,K.useThreadHistoryState=cu,K.useThreadManagerViewState=bp,K.useThreadState=Ho,K.useThreads=zo,K.useThreadsState=uu,K.viewFileById=hv,Object.defineProperties(K,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|