teodor-new-chat-ui 4.3.457 → 4.3.458
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.esm.js +843 -843
- package/dist/index.umd.js +30 -30
- package/package.json +1 -1
package/dist/index.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(F,b){typeof exports=="object"&&typeof module<"u"?b(exports,require("react"),require("@radix-ui/react-slot"),require("class-variance-authority"),require("clsx"),require("tailwind-merge"),require("react-dom"),require("lucide-react")):typeof define=="function"&&define.amd?define(["exports","react","@radix-ui/react-slot","class-variance-authority","clsx","tailwind-merge","react-dom","lucide-react"],b):(F=typeof globalThis<"u"?globalThis:F||self,b(F.NewChatUI={},F.React,F.reactSlot,F.classVarianceAuthority,F.clsx,F.tailwindMerge,F.ReactDOM,F.LucideReact))})(this,function(F,b,Yt,zr,tx,nx,
|
|
1
|
+
(function(F,b){typeof exports=="object"&&typeof module<"u"?b(exports,require("react"),require("@radix-ui/react-slot"),require("class-variance-authority"),require("clsx"),require("tailwind-merge"),require("react-dom"),require("lucide-react")):typeof define=="function"&&define.amd?define(["exports","react","@radix-ui/react-slot","class-variance-authority","clsx","tailwind-merge","react-dom","lucide-react"],b):(F=typeof globalThis<"u"?globalThis:F||self,b(F.NewChatUI={},F.React,F.reactSlot,F.classVarianceAuthority,F.clsx,F.tailwindMerge,F.ReactDOM,F.LucideReact))})(this,function(F,b,Yt,zr,tx,nx,_o,ue){"use strict";var nN=Object.defineProperty;var rN=(F,b,Yt)=>b in F?nN(F,b,{enumerable:!0,configurable:!0,writable:!0,value:Yt}):F[b]=Yt;var Qg=(F,b,Yt)=>rN(F,typeof b!="symbol"?b+"":b,Yt);function Jl(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const p=Jl(b),Hr=Jl(_o),Zl=120;function rx(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>Zl?`${n.slice(0,Zl-3)}…`:n:""}function pi(e){return rx(e.content)||""}function ox(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=pi(o);s&&t.set(r.checkpointId,s)}}return t}function Ql(e){const t=new Map,n=[],r=new Map,o=[];for(let c=0;c<e.length;c++){const d=e[c],f=d.checkpointId,m=f??`cp-${c}`,h=d.metadata??{},v=typeof h.step=="number"?h.step:null,g=typeof h.source=="string"?h.source:null;let x=null,y=null;const w=Array.isArray(d.messages)?d.messages:[];for(const T of w)T.role==="user"&&(y||(y=T),T.id&&(x=T.id));const S=d.next&&d.next.length>0?String(d.next[0]):null,k=d.parentConfig??null,C={id:m,step:v,source:g,createdAt:d.createdAt??null,namespace:d.checkpointNs??null,parentId:d.parentId??null,next:S,parentConfig:k,userMessageId:x};if(o.push(C),f&&t.set(f,C),f&&y){const T=pi(y);T&&r.set(f,T)}n.push({id:m,messageId:x,step:v,source:g,createdAt:d.createdAt??null,next:S,parentConfig:k})}const s=new Map;for(const c of o){if(!c.userMessageId)continue;const d=s.get(c.userMessageId)??[];d.push(c),s.set(c.userMessageId,d)}for(const c of s.values()){if(!c.length)continue;c.sort((f,m)=>{const h=f.createdAt?Date.parse(f.createdAt):0;return(m.createdAt?Date.parse(m.createdAt):0)-h});const d=c.length;for(let f=0;f<c.length;f++){const m=c[f];m.attemptCount=d,m.attemptIndex=f,m.isLatestAttempt=f===0}}return{checkpoints:e,checkpointMetaByCheckpointId:t,timeline:n,messagePreviews:r,getLatest:()=>{const c=n[0];if(c)return t.get(c.id)},getCheckpoint:c=>t.get(c),getMessageAttempts:c=>{const d=[];for(const f of t.values())f.userMessageId===c&&d.push(f);return d.length?(d.sort((f,m)=>{const h=typeof f.attemptIndex=="number"?f.attemptIndex:Number.MAX_SAFE_INTEGER,v=typeof m.attemptIndex=="number"?m.attemptIndex:Number.MAX_SAFE_INTEGER;return h-v}),d):[]}}}function ec(e,t,n){if(!e)return{attemptCount:1,attemptIndex:0,attempts:[]};const r=n.getMessageAttempts(e);if(!r.length)return{attemptCount:1,attemptIndex:0,attempts:[]};let o=0;if(t){const s=r.findIndex(i=>i.id===t);s>=0&&(o=s)}return{attemptCount:r.length,attemptIndex:o,attempts:r}}function sx(e,t){return e?t.getCheckpoint(e)??null:null}function tc(e){return b.useMemo(()=>Ql(e),[e])}function Pn(e){if(!(!e||typeof e!="object"||Array.isArray(e)))return{...e}}function _n(e,t){if(e)for(const n of t){const r=e[n];if(typeof r=="string"&&r.trim())return r.trim()}}function nc(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 mi(e){const t=Pn(e);if(t)return Pn(t.configurable)??t}function Rn(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)=>ix(s,i)).filter(s=>!!s)].sort((s,i)=>rc(i.createdAt)-rc(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 ix(e,t){var S;if(!e)return null;const r=(Array.isArray((S=e.values)==null?void 0:S.messages)?e.values.messages:[]).map(k=>ax(k)).filter(k=>!!k),o=Pn(e.metadata)??{},s=mi(e.config),i=Pn(e.parent_config??e.parentConfig),a=mi(i),l=_n(s,["checkpoint_id","checkpointId"]),c=_n(s,["checkpoint_ns","checkpointNs"]),d=_n(a,["checkpoint_id","checkpointId"]),f=_n(a,["checkpoint_id","checkpointId"])??null,m=_n(a,["checkpoint_ns","checkpointNs"])??null,h=Pn(e.config),v=Array.isArray(e.tasks)?e.tasks.map(k=>({...k})):e.tasks??null,g=Array.isArray(e.next)?[...e.next]:e.next??null,x=typeof e.created_at=="string"&&e.created_at.trim()?e.created_at:typeof e.createdAt=="string"&&e.createdAt.trim()?e.createdAt:new Date(Date.now()-t).toISOString(),y={...o,step:nc(o,["step"])??0,source:_n(o,["source"])??null},w=r.map(k=>({...k,checkpointId:l??null}));return{checkpointId:l??null,checkpointNs:c??null,createdAt:x,parentId:d??null,messages:w,nextCursor:f,nextCursorNs:m,interrupt:dx(r,t),metadata:y,config:h??null,parentConfig:i??null,next:g,tasks:v}}function ax(e){var s,i,a;if(!e||typeof e!="object")return null;const t=lx(e);if(!t)return null;const n=ux(e==null?void 0:e.content);if(!n.length)return null;const r=typeof e.createdAt=="string"?e.createdAt:typeof((s=e.additional_kwargs)==null?void 0:s.created_at)=="string"?(i=e.additional_kwargs)==null?void 0:i.created_at:new Date().toISOString();return{id:typeof e.id=="string"&&e.id.trim()?e.id:`msg-${Date.now().toString(16)}-${Math.random().toString(16).slice(2)}`,role:t,name:typeof e.name=="string"?e.name:void 0,model:typeof e.model=="string"?e.model:((a=e.additional_kwargs)==null?void 0:a.model)??void 0,createdAt:r,content:n,additionalKwargs:e.additional_kwargs??void 0,responseMetadata:e.response_metadata??void 0,artifact:e.artifact??void 0,threadId:e.threadId??e.thread_id}}function lx(e){const t=typeof e.role=="string"?e.role:void 0;if(t&&cx(t))return t;const n=typeof e.type=="string"?e.type:void 0;if(!n)return null;switch(n){case"human":return"user";case"ai":return"assistant";case"tool":return"tool";case"system":return"system";default:return null}}function cx(e){return e==="assistant"||e==="user"||e==="system"||e==="tool"||e==="default_message"}function ux(e){return typeof e=="string"?[{type:"text",text:e}]:Array.isArray(e)?e.filter(t=>!!(t&&typeof t=="object"&&typeof t.type=="string")):[]}function dx(e,t){return fx(e,t)}function fx(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 rc(e){if(!e)return 0;const t=Date.parse(e);return Number.isFinite(t)?t:0}var gi={exports:{}},Ur={};/**
|
|
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 oc;function hx(){if(oc)return Ur;oc=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,
|
|
9
|
+
*/var oc;function hx(){if(oc)return Ur;oc=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,f={},m=null,h=null;c!==void 0&&(m=""+c),l.key!==void 0&&(m=""+l.key),l.ref!==void 0&&(h=l.ref);for(d in l)r.call(l,d)&&!s.hasOwnProperty(d)&&(f[d]=l[d]);if(a&&a.defaultProps)for(d in l=a.defaultProps,l)f[d]===void 0&&(f[d]=l[d]);return{$$typeof:t,type:a,key:m,ref:h,props:f,_owner:o.current}}return Ur.Fragment=n,Ur.jsx=i,Ur.jsxs=i,Ur}var Wr={};/**
|
|
10
10
|
* @license React
|
|
11
11
|
* react-jsx-runtime.development.js
|
|
12
12
|
*
|
|
@@ -14,29 +14,29 @@
|
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the MIT license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var sc;function px(){return sc||(sc=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"),
|
|
17
|
+
*/var sc;function px(){return sc||(sc=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"),f=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),h=Symbol.for("react.offscreen"),v=Symbol.iterator,g="@@iterator";function x(A){if(A===null||typeof A!="object")return null;var te=v&&A[v]||A[g];return typeof te=="function"?te:null}var y=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function w(A){{for(var te=arguments.length,fe=new Array(te>1?te-1:0),Ie=1;Ie<te;Ie++)fe[Ie-1]=arguments[Ie];S("error",A,fe)}}function S(A,te,fe){{var Ie=y.ReactDebugCurrentFrame,Ye=Ie.getStackAddendum();Ye!==""&&(te+="%s",fe=fe.concat([Ye]));var et=fe.map(function(le){return String(le)});et.unshift("Warning: "+te),Function.prototype.apply.call(console[A],console,et)}}var k=!1,C=!1,T=!1,I=!1,N=!1,R;R=Symbol.for("react.module.reference");function O(A){return!!(typeof A=="string"||typeof A=="function"||A===r||A===s||N||A===o||A===c||A===d||I||A===h||k||C||T||typeof A=="object"&&A!==null&&(A.$$typeof===m||A.$$typeof===f||A.$$typeof===i||A.$$typeof===a||A.$$typeof===l||A.$$typeof===R||A.getModuleId!==void 0))}function $(A,te,fe){var Ie=A.displayName;if(Ie)return Ie;var Ye=te.displayName||te.name||"";return Ye!==""?fe+"("+Ye+")":fe}function V(A){return A.displayName||"Context"}function U(A){if(A==null)return null;if(typeof A.tag=="number"&&w("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof A=="function")return A.displayName||A.name||null;if(typeof A=="string")return A;switch(A){case r:return"Fragment";case n:return"Portal";case s:return"Profiler";case o:return"StrictMode";case c:return"Suspense";case d:return"SuspenseList"}if(typeof A=="object")switch(A.$$typeof){case a:var te=A;return V(te)+".Consumer";case i:var fe=A;return V(fe._context)+".Provider";case l:return $(A,A.render,"ForwardRef");case f:var Ie=A.displayName||null;return Ie!==null?Ie:U(A.type)||"Memo";case m:{var Ye=A,et=Ye._payload,le=Ye._init;try{return U(le(et))}catch{return null}}}return null}var j=Object.assign,q=0,K,D,_,E,B,Y,P;function M(){}M.__reactDisabledLog=!0;function G(){{if(q===0){K=console.log,D=console.info,_=console.warn,E=console.error,B=console.group,Y=console.groupCollapsed,P=console.groupEnd;var A={configurable:!0,enumerable:!0,value:M,writable:!0};Object.defineProperties(console,{info:A,log:A,warn:A,error:A,group:A,groupCollapsed:A,groupEnd:A})}q++}}function J(){{if(q--,q===0){var A={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:j({},A,{value:K}),info:j({},A,{value:D}),warn:j({},A,{value:_}),error:j({},A,{value:E}),group:j({},A,{value:B}),groupCollapsed:j({},A,{value:Y}),groupEnd:j({},A,{value:P})})}q<0&&w("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var se=y.ReactCurrentDispatcher,W;function L(A,te,fe){{if(W===void 0)try{throw Error()}catch(Ye){var Ie=Ye.stack.trim().match(/\n( *(at )?)/);W=Ie&&Ie[1]||""}return`
|
|
18
18
|
`+W+A}}var X=!1,ee;{var Z=typeof WeakMap=="function"?WeakMap:Map;ee=new Z}function z(A,te){if(!A||X)return"";{var fe=ee.get(A);if(fe!==void 0)return fe}var Ie;X=!0;var Ye=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var et;et=se.current,se.current=null,G();try{if(te){var le=function(){throw Error()};if(Object.defineProperty(le.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(le,[])}catch(Gt){Ie=Gt}Reflect.construct(A,[],le)}else{try{le.call()}catch(Gt){Ie=Gt}A.call(le.prototype)}}else{try{throw Error()}catch(Gt){Ie=Gt}A()}}catch(Gt){if(Gt&&Ie&&typeof Gt.stack=="string"){for(var de=Gt.stack.split(`
|
|
19
19
|
`),Ce=Ie.stack.split(`
|
|
20
20
|
`),De=de.length-1,at=Ce.length-1;De>=1&&at>=0&&de[De]!==Ce[at];)at--;for(;De>=1&&at>=0;De--,at--)if(de[De]!==Ce[at]){if(De!==1||at!==1)do if(De--,at--,at<0||de[De]!==Ce[at]){var ft=`
|
|
21
|
-
`+de[De].replace(" at new "," at ");return A.displayName&&ft.includes("<anonymous>")&&(ft=ft.replace("<anonymous>",A.displayName)),typeof A=="function"&&ee.set(A,ft),ft}while(De>=1&&at>=0);break}}}finally{X=!1,se.current=et,J(),Error.prepareStackTrace=Ye}var Br=A?A.displayName||A.name:"",fr=Br?L(Br):"";return typeof A=="function"&&ee.set(A,fr),fr}function ae(A,te,fe){return z(A,!1)}function ie(A){var te=A.prototype;return!!(te&&te.isReactComponent)}function ge(A,te,fe){if(A==null)return"";if(typeof A=="function")return z(A,ie(A));if(typeof A=="string")return L(A);switch(A){case c:return L("Suspense");case d:return L("SuspenseList")}if(typeof A=="object")switch(A.$$typeof){case l:return ae(A.render);case
|
|
21
|
+
`+de[De].replace(" at new "," at ");return A.displayName&&ft.includes("<anonymous>")&&(ft=ft.replace("<anonymous>",A.displayName)),typeof A=="function"&&ee.set(A,ft),ft}while(De>=1&&at>=0);break}}}finally{X=!1,se.current=et,J(),Error.prepareStackTrace=Ye}var Br=A?A.displayName||A.name:"",fr=Br?L(Br):"";return typeof A=="function"&&ee.set(A,fr),fr}function ae(A,te,fe){return z(A,!1)}function ie(A){var te=A.prototype;return!!(te&&te.isReactComponent)}function ge(A,te,fe){if(A==null)return"";if(typeof A=="function")return z(A,ie(A));if(typeof A=="string")return L(A);switch(A){case c:return L("Suspense");case d:return L("SuspenseList")}if(typeof A=="object")switch(A.$$typeof){case l:return ae(A.render);case f:return ge(A.type,te,fe);case m:{var Ie=A,Ye=Ie._payload,et=Ie._init;try{return ge(et(Ye),te,fe)}catch{}}}return""}var we=Object.prototype.hasOwnProperty,Ae={},_e=y.ReactDebugCurrentFrame;function ke(A){if(A){var te=A._owner,fe=ge(A.type,A._source,te?te.type:null);_e.setExtraStackFrame(fe)}else _e.setExtraStackFrame(null)}function st(A,te,fe,Ie,Ye){{var et=Function.call.bind(we);for(var le in A)if(et(A,le)){var de=void 0;try{if(typeof A[le]!="function"){var Ce=Error((Ie||"React class")+": "+fe+" type `"+le+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof A[le]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw Ce.name="Invariant Violation",Ce}de=A[le](te,le,Ie,fe,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(De){de=De}de&&!(de instanceof Error)&&(ke(Ye),w("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",Ie||"React class",fe,le,typeof de),ke(null)),de instanceof Error&&!(de.message in Ae)&&(Ae[de.message]=!0,ke(Ye),w("Failed %s type: %s",fe,de.message),ke(null))}}}var bt=Array.isArray;function It(A){return bt(A)}function We(A){{var te=typeof Symbol=="function"&&Symbol.toStringTag,fe=te&&A[Symbol.toStringTag]||A.constructor.name||"Object";return fe}}function ze(A){try{return Ke(A),!1}catch{return!0}}function Ke(A){return""+A}function Fe(A){if(ze(A))return w("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",We(A)),Ke(A)}var Ue=y.ReactCurrentOwner,ut={key:!0,ref:!0,__self:!0,__source:!0},jt,it;function Pt(A){if(we.call(A,"ref")){var te=Object.getOwnPropertyDescriptor(A,"ref").get;if(te&&te.isReactWarning)return!1}return A.ref!==void 0}function yt(A){if(we.call(A,"key")){var te=Object.getOwnPropertyDescriptor(A,"key").get;if(te&&te.isReactWarning)return!1}return A.key!==void 0}function gt(A,te){typeof A.ref=="string"&&Ue.current}function Nt(A,te){{var fe=function(){jt||(jt=!0,w("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",te))};fe.isReactWarning=!0,Object.defineProperty(A,"key",{get:fe,configurable:!0})}}function St(A,te){{var fe=function(){it||(it=!0,w("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",te))};fe.isReactWarning=!0,Object.defineProperty(A,"ref",{get:fe,configurable:!0})}}var Ct=function(A,te,fe,Ie,Ye,et,le){var de={$$typeof:t,type:A,key:te,ref:fe,props:le,_owner:et};return de._store={},Object.defineProperty(de._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(de,"_self",{configurable:!1,enumerable:!1,writable:!1,value:Ie}),Object.defineProperty(de,"_source",{configurable:!1,enumerable:!1,writable:!1,value:Ye}),Object.freeze&&(Object.freeze(de.props),Object.freeze(de)),de};function zt(A,te,fe,Ie,Ye){{var et,le={},de=null,Ce=null;fe!==void 0&&(Fe(fe),de=""+fe),yt(te)&&(Fe(te.key),de=""+te.key),Pt(te)&&(Ce=te.ref,gt(te,Ye));for(et in te)we.call(te,et)&&!ut.hasOwnProperty(et)&&(le[et]=te[et]);if(A&&A.defaultProps){var De=A.defaultProps;for(et in De)le[et]===void 0&&(le[et]=De[et])}if(de||Ce){var at=typeof A=="function"?A.displayName||A.name||"Unknown":A;de&&Nt(le,at),Ce&&St(le,at)}return Ct(A,de,Ce,Ye,Ie,Ue.current,le)}}var xt=y.ReactCurrentOwner,Oe=y.ReactDebugCurrentFrame;function Ve(A){if(A){var te=A._owner,fe=ge(A.type,A._source,te?te.type:null);Oe.setExtraStackFrame(fe)}else Oe.setExtraStackFrame(null)}var Te;Te=!1;function Q(A){return typeof A=="object"&&A!==null&&A.$$typeof===t}function me(){{if(xt.current){var A=U(xt.current.type);if(A)return`
|
|
22
22
|
|
|
23
23
|
Check the render method of \``+A+"`."}return""}}function Ze(A){return""}var xe={};function Be(A){{var te=me();if(!te){var fe=typeof A=="string"?A:A.displayName||A.name;fe&&(te=`
|
|
24
24
|
|
|
25
|
-
Check the top-level render call using <`+fe+">.")}return te}}function Ge(A,te){{if(!A._store||A._store.validated||A.key!=null)return;A._store.validated=!0;var fe=Be(te);if(xe[fe])return;xe[fe]=!0;var Ie="";A&&A._owner&&A._owner!==xt.current&&(Ie=" It was passed a child from "+U(A._owner.type)+"."),Ve(A),w('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',fe,Ie),Ve(null)}}function Tt(A,te){{if(typeof A!="object")return;if(It(A))for(var fe=0;fe<A.length;fe++){var Ie=A[fe];Q(Ie)&&Ge(Ie,te)}else if(Q(A))A._store&&(A._store.validated=!0);else if(A){var Ye=x(A);if(typeof Ye=="function"&&Ye!==A.entries)for(var et=Ye.call(A),le;!(le=et.next()).done;)Q(le.value)&&Ge(le.value,te)}}}function kt(A){{var te=A.type;if(te==null||typeof te=="string")return;var fe;if(typeof te=="function")fe=te.propTypes;else if(typeof te=="object"&&(te.$$typeof===l||te.$$typeof===
|
|
25
|
+
Check the top-level render call using <`+fe+">.")}return te}}function Ge(A,te){{if(!A._store||A._store.validated||A.key!=null)return;A._store.validated=!0;var fe=Be(te);if(xe[fe])return;xe[fe]=!0;var Ie="";A&&A._owner&&A._owner!==xt.current&&(Ie=" It was passed a child from "+U(A._owner.type)+"."),Ve(A),w('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',fe,Ie),Ve(null)}}function Tt(A,te){{if(typeof A!="object")return;if(It(A))for(var fe=0;fe<A.length;fe++){var Ie=A[fe];Q(Ie)&&Ge(Ie,te)}else if(Q(A))A._store&&(A._store.validated=!0);else if(A){var Ye=x(A);if(typeof Ye=="function"&&Ye!==A.entries)for(var et=Ye.call(A),le;!(le=et.next()).done;)Q(le.value)&&Ge(le.value,te)}}}function kt(A){{var te=A.type;if(te==null||typeof te=="string")return;var fe;if(typeof te=="function")fe=te.propTypes;else if(typeof te=="object"&&(te.$$typeof===l||te.$$typeof===f))fe=te.propTypes;else return;if(fe){var Ie=U(te);st(fe,A.props,"prop",Ie,A)}else if(te.PropTypes!==void 0&&!Te){Te=!0;var Ye=U(te);w("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",Ye||"Unknown")}typeof te.getDefaultProps=="function"&&!te.getDefaultProps.isReactClassApproved&&w("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function At(A){{for(var te=Object.keys(A.props),fe=0;fe<te.length;fe++){var Ie=te[fe];if(Ie!=="children"&&Ie!=="key"){Ve(A),w("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",Ie),Ve(null);break}}A.ref!==null&&(Ve(A),w("Invalid attribute `ref` supplied to `React.Fragment`."),Ve(null))}}var Lt={};function je(A,te,fe,Ie,Ye,et){{var le=O(A);if(!le){var de="";(A===void 0||typeof A=="object"&&A!==null&&Object.keys(A).length===0)&&(de+=" 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 Ce=Ze();Ce?de+=Ce:de+=me();var De;A===null?De="null":It(A)?De="array":A!==void 0&&A.$$typeof===t?(De="<"+(U(A.type)||"Unknown")+" />",de=" Did you accidentally export a JSX literal instead of a component?"):De=typeof A,w("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",De,de)}var at=zt(A,te,fe,Ye,et);if(at==null)return at;if(le){var ft=te.children;if(ft!==void 0)if(Ie)if(It(ft)){for(var Br=0;Br<ft.length;Br++)Tt(ft[Br],A);Object.freeze&&Object.freeze(ft)}else w("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Tt(ft,A)}if(we.call(te,"key")){var fr=U(A),Gt=Object.keys(te).filter(function(tN){return tN!=="key"}),Xl=Gt.length>0?"{key: someKey, "+Gt.join(": ..., ")+": ...}":"{key: someKey}";if(!Lt[fr+Xl]){var eN=Gt.length>0?"{"+Gt.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} />`,Xl,fr,eN,fr),Lt[fr+Xl]=!0}}return A===r?At(at):kt(at),at}}function dt(A,te,fe){return je(A,te,fe,!0)}function Xe(A,te,fe){return je(A,te,fe,!1)}var ct=Xe,an=dt;Wr.Fragment=r,Wr.jsx=ct,Wr.jsxs=an}()),Wr}process.env.NODE_ENV==="production"?gi.exports=hx():gi.exports=px();var u=gi.exports;const mx=({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 ic(e,t){return function(){return e.apply(t,arguments)}}const{toString:gx}=Object.prototype,{getPrototypeOf:xi}=Object,{iterator:Ro,toStringTag:ac}=Symbol,Mo=(e=>t=>{const n=gx.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),ln=e=>(e=e.toLowerCase(),t=>Mo(t)===e),Oo=e=>t=>typeof t===e,{isArray:hr}=Array,pr=Oo("undefined");function Vr(e){return e!==null&&!pr(e)&&e.constructor!==null&&!pr(e.constructor)&&Ht(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const lc=ln("ArrayBuffer");function xx(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&lc(e.buffer),t}const vx=Oo("string"),Ht=Oo("function"),cc=Oo("number"),Kr=e=>e!==null&&typeof e=="object",bx=e=>e===!0||e===!1,Do=e=>{if(Mo(e)!=="object")return!1;const t=xi(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(ac in e)&&!(Ro in e)},wx=e=>{if(!Kr(e)||Vr(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},yx=ln("Date"),Sx=ln("File"),Cx=ln("Blob"),Tx=ln("FileList"),kx=e=>Kr(e)&&Ht(e.pipe),Ex=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||Ht(e.append)&&((t=Mo(e))==="formdata"||t==="object"&&Ht(e.toString)&&e.toString()==="[object FormData]"))},Ix=ln("URLSearchParams"),[Nx,Ax,jx,_x]=["ReadableStream","Request","Response","Headers"].map(ln),Px=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function qr(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,o;if(typeof e!="object"&&(e=[e]),hr(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{if(Vr(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 uc(e,t){if(Vr(e))return null;t=t.toLowerCase();const n=Object.keys(e);let r=n.length,o;for(;r-- >0;)if(o=n[r],t===o.toLowerCase())return o;return null}const Xn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,dc=e=>!pr(e)&&e!==Xn;function vi(){const{caseless:e,skipUndefined:t}=dc(this)&&this||{},n={},r=(o,s)=>{const i=e&&uc(n,s)||s;Do(n[i])&&Do(o)?n[i]=vi(n[i],o):Do(o)?n[i]=vi({},o):hr(o)?n[i]=o.slice():(!t||!pr(o))&&(n[i]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&qr(arguments[o],r);return n}const Rx=(e,t,n,{allOwnKeys:r}={})=>(qr(t,(o,s)=>{n&&Ht(o)?e[s]=ic(o,n):e[s]=o},{allOwnKeys:r}),e),Mx=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Ox=(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)},Dx=(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&&xi(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},Lx=(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},$x=e=>{if(!e)return null;if(hr(e))return e;let t=e.length;if(!cc(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Fx=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&xi(Uint8Array)),Bx=(e,t)=>{const r=(e&&e[Ro]).call(e);let o;for(;(o=r.next())&&!o.done;){const s=o.value;t.call(e,s[0],s[1])}},zx=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},Hx=ln("HTMLFormElement"),Ux=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),fc=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),Wx=ln("RegExp"),hc=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};qr(n,(o,s)=>{let i;(i=t(o,s,e))!==!1&&(r[s]=i||o)}),Object.defineProperties(e,r)},Vx=e=>{hc(e,(t,n)=>{if(Ht(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(Ht(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+"'")})}})},Kx=(e,t)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return hr(e)?r(e):r(String(e).split(t)),n},qx=()=>{},Gx=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function Yx(e){return!!(e&&Ht(e.append)&&e[ac]==="FormData"&&e[Ro])}const Xx=e=>{const t=new Array(10),n=(r,o)=>{if(Kr(r)){if(t.indexOf(r)>=0)return;if(Vr(r))return r;if(!("toJSON"in r)){t[o]=r;const s=hr(r)?[]:{};return qr(r,(i,a)=>{const l=n(i,o+1);!pr(l)&&(s[a]=l)}),t[o]=void 0,s}}return r};return n(e,0)},Jx=ln("AsyncFunction"),Zx=e=>e&&(Kr(e)||Ht(e))&&Ht(e.then)&&Ht(e.catch),pc=((e,t)=>e?setImmediate:t?((n,r)=>(Xn.addEventListener("message",({source:o,data:s})=>{o===Xn&&s===n&&r.length&&r.shift()()},!1),o=>{r.push(o),Xn.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",Ht(Xn.postMessage)),Qx=typeof queueMicrotask<"u"?queueMicrotask.bind(Xn):typeof process<"u"&&process.nextTick||pc,H={isArray:hr,isArrayBuffer:lc,isBuffer:Vr,isFormData:Ex,isArrayBufferView:xx,isString:vx,isNumber:cc,isBoolean:bx,isObject:Kr,isPlainObject:Do,isEmptyObject:wx,isReadableStream:Nx,isRequest:Ax,isResponse:jx,isHeaders:_x,isUndefined:pr,isDate:yx,isFile:Sx,isBlob:Cx,isRegExp:Wx,isFunction:Ht,isStream:kx,isURLSearchParams:Ix,isTypedArray:Fx,isFileList:Tx,forEach:qr,merge:vi,extend:Rx,trim:Px,stripBOM:Mx,inherits:Ox,toFlatObject:Dx,kindOf:Mo,kindOfTest:ln,endsWith:Lx,toArray:$x,forEachEntry:Bx,matchAll:zx,isHTMLForm:Hx,hasOwnProperty:fc,hasOwnProp:fc,reduceDescriptors:hc,freezeMethods:Vx,toObjectSet:Kx,toCamelCase:Ux,noop:qx,toFiniteNumber:Gx,findKey:uc,global:Xn,isContextDefined:dc,isSpecCompliantForm:Yx,toJSONObject:Xx,isAsyncFn:Jx,isThenable:Zx,setImmediate:pc,asap:Qx,isIterable:e=>e!=null&&Ht(e[Ro])};function Re(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)}H.inherits(Re,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:H.toJSONObject(this.config),code:this.code,status:this.status}}});const mc=Re.prototype,gc={};["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=>{gc[e]={value:e}}),Object.defineProperties(Re,gc),Object.defineProperty(mc,"isAxiosError",{value:!0}),Re.from=(e,t,n,r,o,s)=>{const i=Object.create(mc);H.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 Re.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 ev=null;function bi(e){return H.isPlainObject(e)||H.isArray(e)}function xc(e){return H.endsWith(e,"[]")?e.slice(0,-2):e}function vc(e,t,n){return e?e.concat(t).map(function(o,s){return o=xc(o),!n&&s?"["+o+"]":o}).join(n?".":""):t}function tv(e){return H.isArray(e)&&!e.some(bi)}const nv=H.toFlatObject(H,{},null,function(t){return/^is[A-Z]/.test(t)});function Lo(e,t,n){if(!H.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=H.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(g,x){return!H.isUndefined(x[g])});const r=n.metaTokens,o=n.visitor||d,s=n.dots,i=n.indexes,l=(n.Blob||typeof Blob<"u"&&Blob)&&H.isSpecCompliantForm(t);if(!H.isFunction(o))throw new TypeError("visitor must be a function");function c(v){if(v===null)return"";if(H.isDate(v))return v.toISOString();if(H.isBoolean(v))return v.toString();if(!l&&H.isBlob(v))throw new Re("Blob is not supported. Use a Buffer instead.");return H.isArrayBuffer(v)||H.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(H.endsWith(g,"{}"))g=r?g:g.slice(0,-2),v=JSON.stringify(v);else if(H.isArray(v)&&tv(v)||(H.isFileList(v)||H.endsWith(g,"[]"))&&(y=H.toArray(v)))return g=xc(g),y.forEach(function(S,k){!(H.isUndefined(S)||S===null)&&t.append(i===!0?vc([g],k,s):i===null?g:g+"[]",c(S))}),!1}return bi(v)?!0:(t.append(vc(x,g,s),c(v)),!1)}const h=[],m=Object.assign(nv,{defaultVisitor:d,convertValue:c,isVisitable:bi});function f(v,g){if(!H.isUndefined(v)){if(h.indexOf(v)!==-1)throw Error("Circular reference detected in "+g.join("."));h.push(v),H.forEach(v,function(y,w){(!(H.isUndefined(y)||y===null)&&o.call(t,y,H.isString(w)?w.trim():w,g,m))===!0&&f(y,g?g.concat(w):[w])}),h.pop()}}if(!H.isObject(e))throw new TypeError("data must be an object");return f(e),t}function bc(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function wi(e,t){this._pairs=[],e&&Lo(e,this,t)}const wc=wi.prototype;wc.append=function(t,n){this._pairs.push([t,n])},wc.toString=function(t){const n=t?function(r){return t.call(this,r,bc)}:bc;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function rv(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function yc(e,t,n){if(!t)return e;const r=n&&n.encode||rv;H.isFunction(n)&&(n={serialize:n});const o=n&&n.serialize;let s;if(o?s=o(t,n):s=H.isURLSearchParams(t)?t.toString():new wi(t,n).toString(r),s){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}class Sc{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){H.forEach(this.handlers,function(r){r!==null&&t(r)})}}const Cc={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},ov={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:wi,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},yi=typeof window<"u"&&typeof document<"u",Si=typeof navigator=="object"&&navigator||void 0,sv=yi&&(!Si||["ReactNative","NativeScript","NS"].indexOf(Si.product)<0),iv=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",av=yi&&window.location.href||"http://localhost",Pt={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:yi,hasStandardBrowserEnv:sv,hasStandardBrowserWebWorkerEnv:iv,navigator:Si,origin:av},Symbol.toStringTag,{value:"Module"})),...ov};function lv(e,t){return Lo(e,new Pt.classes.URLSearchParams,{visitor:function(n,r,o,s){return Pt.isNode&&H.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function cv(e){return H.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function uv(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 Tc(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&&H.isArray(o)?o.length:i,l?(H.hasOwnProp(o,i)?o[i]=[o[i],r]:o[i]=r,!a):((!o[i]||!H.isObject(o[i]))&&(o[i]=[]),t(n,r,o[i],s)&&H.isArray(o[i])&&(o[i]=uv(o[i])),!a)}if(H.isFormData(e)&&H.isFunction(e.entries)){const n={};return H.forEachEntry(e,(r,o)=>{t(cv(r),o,n,0)}),n}return null}function dv(e,t,n){if(H.isString(e))try{return(t||JSON.parse)(e),H.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const Gr={transitional:Cc,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",o=r.indexOf("application/json")>-1,s=H.isObject(t);if(s&&H.isHTMLForm(t)&&(t=new FormData(t)),H.isFormData(t))return o?JSON.stringify(Tc(t)):t;if(H.isArrayBuffer(t)||H.isBuffer(t)||H.isStream(t)||H.isFile(t)||H.isBlob(t)||H.isReadableStream(t))return t;if(H.isArrayBufferView(t))return t.buffer;if(H.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 lv(t,this.formSerializer).toString();if((a=H.isFileList(t))||r.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return Lo(a?{"files[]":t}:t,l&&new l,this.formSerializer)}}return s||o?(n.setContentType("application/json",!1),dv(t)):t}],transformResponse:[function(t){const n=this.transitional||Gr.transitional,r=n&&n.forcedJSONParsing,o=this.responseType==="json";if(H.isResponse(t)||H.isReadableStream(t))return t;if(t&&H.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"?Re.from(a,Re.ERR_BAD_RESPONSE,this,null,this.response):a}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Pt.classes.FormData,Blob:Pt.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};H.forEach(["delete","get","head","post","put","patch"],e=>{Gr.headers[e]={}});const fv=H.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"]),hv=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]&&fv[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},kc=Symbol("internals");function Yr(e){return e&&String(e).trim().toLowerCase()}function $o(e){return e===!1||e==null?e:H.isArray(e)?e.map($o):String(e)}function pv(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}const mv=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function Ci(e,t,n,r,o){if(H.isFunction(r))return r.call(this,t,n);if(o&&(t=n),!!H.isString(t)){if(H.isString(r))return t.indexOf(r)!==-1;if(H.isRegExp(r))return r.test(t)}}function gv(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function xv(e,t){const n=H.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 Ut=class{constructor(t){t&&this.set(t)}set(t,n,r){const o=this;function s(a,l,c){const d=Yr(l);if(!d)throw new Error("header name must be a non-empty string");const
|
|
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[kc]=this[kc]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=Yr(i);r[a]||(xv(o,i),r[a]=!0)}return H.isArray(t)?t.forEach(s):s(t),this}};Ut.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),H.reduceDescriptors(Ut.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),H.freezeMethods(Ut);function Ti(e,t){const n=this||Gr,r=t||n,o=Ut.from(r.headers);let s=r.data;return H.forEach(e,function(a){s=a.call(n,s,o.normalize(),t?t.status:void 0)}),o.normalize(),s}function Ec(e){return!!(e&&e.__CANCEL__)}function mr(e,t,n){Re.call(this,e??"canceled",Re.ERR_CANCELED,t,n),this.name="CanceledError"}H.inherits(mr,Re,{__CANCEL__:!0});function Ic(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new Re("Request failed with status code "+n.status,[Re.ERR_BAD_REQUEST,Re.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function vv(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function bv(e,t){e=e||10;const n=new Array(e),r=new Array(e);let o=0,s=0,i;return t=t!==void 0?t:1e3,function(l){const c=Date.now(),d=r[s];i||(i=c),n[o]=l,r[o]=c;let h=s,m=0;for(;h!==o;)m+=n[h++],h=h%e;if(o=(o+1)%e,o===s&&(s=(s+1)%e),c-i<t)return;const f=d&&c-d;return f?Math.round(m*1e3/f):void 0}}function wv(e,t){let n=0,r=1e3/t,o,s;const i=(c,d=Date.now())=>{n=d,o=null,s&&(clearTimeout(s),s=null),e(...c)};return[(...c)=>{const d=Date.now(),h=d-n;h>=r?i(c,d):(o=c,s||(s=setTimeout(()=>{s=null,i(o)},r-h)))},()=>o&&i(o)]}const Fo=(e,t,n=3)=>{let r=0;const o=bv(50,250);return wv(s=>{const i=s.loaded,a=s.lengthComputable?s.total:void 0,l=i-r,c=o(l),d=i<=a;r=i;const h={loaded:i,total:a,progress:a?i/a:void 0,bytes:l,rate:c||void 0,estimated:c&&a&&d?(a-i)/c:void 0,event:s,lengthComputable:a!=null,[t?"download":"upload"]:!0};e(h)},n)},Nc=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},Ac=e=>(...t)=>H.asap(()=>e(...t)),yv=Pt.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,Pt.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(Pt.origin),Pt.navigator&&/(msie|trident)/i.test(Pt.navigator.userAgent)):()=>!0,Sv=Pt.hasStandardBrowserEnv?{write(e,t,n,r,o,s){const i=[e+"="+encodeURIComponent(t)];H.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),H.isString(r)&&i.push("path="+r),H.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 Cv(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Tv(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function jc(e,t,n){let r=!Cv(t);return e&&(r||n==!1)?Tv(e,t):t}const _c=e=>e instanceof Ut?{...e}:e;function Jn(e,t){t=t||{};const n={};function r(c,d,h,m){return H.isPlainObject(c)&&H.isPlainObject(d)?H.merge.call({caseless:m},c,d):H.isPlainObject(d)?H.merge({},d):H.isArray(d)?d.slice():d}function o(c,d,h,m){if(H.isUndefined(d)){if(!H.isUndefined(c))return r(void 0,c,h,m)}else return r(c,d,h,m)}function s(c,d){if(!H.isUndefined(d))return r(void 0,d)}function i(c,d){if(H.isUndefined(d)){if(!H.isUndefined(c))return r(void 0,c)}else return r(void 0,d)}function a(c,d,h){if(h in t)return r(c,d);if(h in e)return r(void 0,c)}const l={url:s,method:s,data:s,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:a,headers:(c,d,h)=>o(_c(c),_c(d),h,!0)};return H.forEach(Object.keys({...e,...t}),function(d){const h=l[d]||o,m=h(e[d],t[d],d);H.isUndefined(m)&&h!==a||(n[d]=m)}),n}const Pc=e=>{const t=Jn({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=Ut.from(i),t.url=yc(jc(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&i.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),H.isFormData(n)){if(Pt.hasStandardBrowserEnv||Pt.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(H.isFunction(n.getHeaders)){const l=n.getHeaders(),c=["content-type","content-length"];Object.entries(l).forEach(([d,h])=>{c.includes(d.toLowerCase())&&i.set(d,h)})}}if(Pt.hasStandardBrowserEnv&&(r&&H.isFunction(r)&&(r=r(t)),r||r!==!1&&yv(t.url))){const l=o&&s&&Sv.read(s);l&&i.set(o,l)}return t},kv=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=Pc(e);let s=o.data;const i=Ut.from(o.headers).normalize();let{responseType:a,onUploadProgress:l,onDownloadProgress:c}=o,d,h,m,f,v;function g(){f&&f(),v&&v(),o.cancelToken&&o.cancelToken.unsubscribe(d),o.signal&&o.signal.removeEventListener("abort",d)}let x=new XMLHttpRequest;x.open(o.method.toUpperCase(),o.url,!0),x.timeout=o.timeout;function y(){if(!x)return;const S=Ut.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};Ic(function(I){n(I),g()},function(I){r(I),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 Re("Request aborted",Re.ECONNABORTED,e,x)),x=null)},x.onerror=function(k){const C=k&&k.message?k.message:"Network Error",T=new Re(C,Re.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||Cc;o.timeoutErrorMessage&&(k=o.timeoutErrorMessage),r(new Re(k,C.clarifyTimeoutError?Re.ETIMEDOUT:Re.ECONNABORTED,e,x)),x=null},s===void 0&&i.setContentType(null),"setRequestHeader"in x&&H.forEach(i.toJSON(),function(k,C){x.setRequestHeader(C,k)}),H.isUndefined(o.withCredentials)||(x.withCredentials=!!o.withCredentials),a&&a!=="json"&&(x.responseType=o.responseType),c&&([m,v]=Fo(c,!0),x.addEventListener("progress",m)),l&&x.upload&&([h,f]=Fo(l),x.upload.addEventListener("progress",h),x.upload.addEventListener("loadend",f)),(o.cancelToken||o.signal)&&(d=S=>{x&&(r(!S||S.type?new mr(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=vv(o.url);if(w&&Pt.protocols.indexOf(w)===-1){r(new Re("Unsupported protocol "+w+":",Re.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 Re?d:new mr(d instanceof Error?d.message:d))}};let i=t&&setTimeout(()=>{i=null,s(new Re(`timeout ${t} of ms exceeded`,Re.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=()=>H.asap(a),l}},Iv=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 Av(e))yield*Iv(n,t)},Av=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:n,value:r}=await t.read();if(n)break;yield r}}finally{await t.cancel()}},Rc=(e,t,n,r)=>{const o=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 h=d.byteLength;if(n){let m=s+=h;n(m)}l.enqueue(new Uint8Array(d))}catch(c){throw a(c),c}},cancel(l){return a(l),o.return()}},{highWaterMark:2})},Mc=64*1024,{isFunction:Bo}=H,jv=(({Request:e,Response:t})=>({Request:e,Response:t}))(H.global),{ReadableStream:Oc,TextEncoder:Dc}=H.global,Lc=(e,...t)=>{try{return!!e(...t)}catch{return!1}},_v=e=>{e=H.merge.call({skipUndefined:!0},jv,e);const{fetch:t,Request:n,Response:r}=e,o=t?Bo(t):typeof fetch=="function",s=Bo(n),i=Bo(r);if(!o)return!1;const a=o&&Bo(Oc),l=o&&(typeof Dc=="function"?(v=>g=>v.encode(g))(new Dc):async v=>new Uint8Array(await new n(v).arrayBuffer())),c=s&&a&&Lc(()=>{let v=!1;const g=new n(Pt.origin,{body:new Oc,method:"POST",get duplex(){return v=!0,"half"}}).headers.has("Content-Type");return v&&!g}),d=i&&a&&Lc(()=>H.isReadableStream(new r("").body)),h={stream:d&&(v=>v.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(v=>{!h[v]&&(h[v]=(g,x)=>{let y=g&&g[v];if(y)return y.call(g);throw new Re(`Response type '${v}' is not supported`,Re.ERR_NOT_SUPPORT,x)})});const m=async v=>{if(v==null)return 0;if(H.isBlob(v))return v.size;if(H.isSpecCompliantForm(v))return(await new n(Pt.origin,{method:"POST",body:v}).arrayBuffer()).byteLength;if(H.isArrayBufferView(v)||H.isArrayBuffer(v))return v.byteLength;if(H.isURLSearchParams(v)&&(v=v+""),H.isString(v))return(await l(v)).byteLength},f=async(v,g)=>{const x=H.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:I,headers:N,withCredentials:R="same-origin",fetchOptions:O}=Pc(v),$=t||fetch;I=I?(I+"").toLowerCase():"text";let V=Ev([w,S&&S.toAbortSignal()],k),U=null;const j=V&&V.unsubscribe&&(()=>{V.unsubscribe()});let q;try{if(T&&c&&x!=="get"&&x!=="head"&&(q=await f(N,y))!==0){let Y=new n(g,{method:"POST",body:y,duplex:"half"}),_;if(H.isFormData(y)&&(_=Y.headers.get("content-type"))&&N.setContentType(_),Y.body){const[M,G]=Nc(q,Fo(Ac(T)));y=Rc(Y.body,Mc,M,G)}}H.isString(R)||(R=R?"include":"omit");const K=s&&"credentials"in n.prototype,D={...O,signal:V,method:x.toUpperCase(),headers:N.normalize().toJSON(),body:y,duplex:"half",credentials:K?R:void 0};U=s&&new n(g,D);let P=await(s?$(U,O):$(g,D));const E=d&&(I==="stream"||I==="response");if(d&&(C||E&&j)){const Y={};["status","statusText","headers"].forEach(J=>{Y[J]=P[J]});const _=H.toFiniteNumber(P.headers.get("content-length")),[M,G]=C&&Nc(_,Fo(Ac(C),!0))||[];P=new r(Rc(P.body,Mc,M,()=>{G&&G(),j&&j()}),Y)}I=I||"text";let B=await h[H.findKey(h,I)||"text"](P,v);return!E&&j&&j(),await new Promise((Y,_)=>{Ic(Y,_,{data:B,headers:Ut.from(P.headers),status:P.status,statusText:P.statusText,config:v,request:U})})}catch(K){throw j&&j(),K&&K.name==="TypeError"&&/Load failed|fetch/i.test(K.message)?Object.assign(new Re("Network Error",Re.ERR_NETWORK,v,U),{cause:K.cause||K}):Re.from(K,K&&K.code,v,U)}}},Pv=new Map,$c=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=Pv;for(;a--;)l=s[a],c=d.get(l),c===void 0&&d.set(l,c=a?new Map:_v(t)),d=c;return c};$c();const ki={http:ev,xhr:kv,fetch:{get:$c}};H.forEach(ki,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Fc=e=>`- ${e}`,Rv=e=>H.isFunction(e)||e===null||e===!1,Bc={getAdapter:(e,t)=>{e=H.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,!Rv(r)&&(o=ki[(a=String(r)).toLowerCase()],o===void 0))throw new Re(`Unknown adapter '${a}'`);if(o&&(H.isFunction(o)||(o=o.get(t))))break;s[a||"#"+i]=o}if(!o){const i=Object.entries(s).map(([l,c])=>`adapter ${l} `+(c===!1?"is not supported by the environment":"is not available in the build"));let a=n?i.length>1?`since :
|
|
30
|
+
<%s key={someKey} {...props} />`,Xl,fr,eN,fr),Lt[fr+Xl]=!0}}return A===r?At(at):kt(at),at}}function dt(A,te,fe){return je(A,te,fe,!0)}function Xe(A,te,fe){return je(A,te,fe,!1)}var ct=Xe,an=dt;Wr.Fragment=r,Wr.jsx=ct,Wr.jsxs=an}()),Wr}process.env.NODE_ENV==="production"?gi.exports=hx():gi.exports=px();var u=gi.exports;const mx=({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(h=>{const v=d===h.id,g=(r==null?void 0:r.get(h.id))??null;return u.jsxs("button",{type:"button",disabled:!n,onClick:()=>n==null?void 0:n(h.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:h.label||"User input"}),u.jsxs("span",{className:"text-[9px] uppercase tracking-wide text-muted-foreground/70",children:[h.step!==null?`STEP ${h.step}`:"STEP —",h.next?` - ${h.next}`:""]}),g&&u.jsx("p",{className:"text-[10px] text-muted-foreground/80 mt-1 line-clamp-2",title:g,children:g})]})]},h.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 ic(e,t){return function(){return e.apply(t,arguments)}}const{toString:gx}=Object.prototype,{getPrototypeOf:xi}=Object,{iterator:Ro,toStringTag:ac}=Symbol,Mo=(e=>t=>{const n=gx.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),ln=e=>(e=e.toLowerCase(),t=>Mo(t)===e),Oo=e=>t=>typeof t===e,{isArray:hr}=Array,pr=Oo("undefined");function Vr(e){return e!==null&&!pr(e)&&e.constructor!==null&&!pr(e.constructor)&&Ht(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const lc=ln("ArrayBuffer");function xx(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&lc(e.buffer),t}const vx=Oo("string"),Ht=Oo("function"),cc=Oo("number"),Kr=e=>e!==null&&typeof e=="object",bx=e=>e===!0||e===!1,Do=e=>{if(Mo(e)!=="object")return!1;const t=xi(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(ac in e)&&!(Ro in e)},wx=e=>{if(!Kr(e)||Vr(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},yx=ln("Date"),Sx=ln("File"),Cx=ln("Blob"),Tx=ln("FileList"),kx=e=>Kr(e)&&Ht(e.pipe),Ex=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||Ht(e.append)&&((t=Mo(e))==="formdata"||t==="object"&&Ht(e.toString)&&e.toString()==="[object FormData]"))},Ix=ln("URLSearchParams"),[Nx,Ax,jx,Px]=["ReadableStream","Request","Response","Headers"].map(ln),_x=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function qr(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,o;if(typeof e!="object"&&(e=[e]),hr(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{if(Vr(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 uc(e,t){if(Vr(e))return null;t=t.toLowerCase();const n=Object.keys(e);let r=n.length,o;for(;r-- >0;)if(o=n[r],t===o.toLowerCase())return o;return null}const Xn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,dc=e=>!pr(e)&&e!==Xn;function vi(){const{caseless:e,skipUndefined:t}=dc(this)&&this||{},n={},r=(o,s)=>{const i=e&&uc(n,s)||s;Do(n[i])&&Do(o)?n[i]=vi(n[i],o):Do(o)?n[i]=vi({},o):hr(o)?n[i]=o.slice():(!t||!pr(o))&&(n[i]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&qr(arguments[o],r);return n}const Rx=(e,t,n,{allOwnKeys:r}={})=>(qr(t,(o,s)=>{n&&Ht(o)?e[s]=ic(o,n):e[s]=o},{allOwnKeys:r}),e),Mx=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Ox=(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)},Dx=(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&&xi(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},Lx=(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},$x=e=>{if(!e)return null;if(hr(e))return e;let t=e.length;if(!cc(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Fx=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&xi(Uint8Array)),Bx=(e,t)=>{const r=(e&&e[Ro]).call(e);let o;for(;(o=r.next())&&!o.done;){const s=o.value;t.call(e,s[0],s[1])}},zx=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},Hx=ln("HTMLFormElement"),Ux=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),fc=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),Wx=ln("RegExp"),hc=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};qr(n,(o,s)=>{let i;(i=t(o,s,e))!==!1&&(r[s]=i||o)}),Object.defineProperties(e,r)},Vx=e=>{hc(e,(t,n)=>{if(Ht(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(Ht(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+"'")})}})},Kx=(e,t)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return hr(e)?r(e):r(String(e).split(t)),n},qx=()=>{},Gx=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function Yx(e){return!!(e&&Ht(e.append)&&e[ac]==="FormData"&&e[Ro])}const Xx=e=>{const t=new Array(10),n=(r,o)=>{if(Kr(r)){if(t.indexOf(r)>=0)return;if(Vr(r))return r;if(!("toJSON"in r)){t[o]=r;const s=hr(r)?[]:{};return qr(r,(i,a)=>{const l=n(i,o+1);!pr(l)&&(s[a]=l)}),t[o]=void 0,s}}return r};return n(e,0)},Jx=ln("AsyncFunction"),Zx=e=>e&&(Kr(e)||Ht(e))&&Ht(e.then)&&Ht(e.catch),pc=((e,t)=>e?setImmediate:t?((n,r)=>(Xn.addEventListener("message",({source:o,data:s})=>{o===Xn&&s===n&&r.length&&r.shift()()},!1),o=>{r.push(o),Xn.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",Ht(Xn.postMessage)),Qx=typeof queueMicrotask<"u"?queueMicrotask.bind(Xn):typeof process<"u"&&process.nextTick||pc,H={isArray:hr,isArrayBuffer:lc,isBuffer:Vr,isFormData:Ex,isArrayBufferView:xx,isString:vx,isNumber:cc,isBoolean:bx,isObject:Kr,isPlainObject:Do,isEmptyObject:wx,isReadableStream:Nx,isRequest:Ax,isResponse:jx,isHeaders:Px,isUndefined:pr,isDate:yx,isFile:Sx,isBlob:Cx,isRegExp:Wx,isFunction:Ht,isStream:kx,isURLSearchParams:Ix,isTypedArray:Fx,isFileList:Tx,forEach:qr,merge:vi,extend:Rx,trim:_x,stripBOM:Mx,inherits:Ox,toFlatObject:Dx,kindOf:Mo,kindOfTest:ln,endsWith:Lx,toArray:$x,forEachEntry:Bx,matchAll:zx,isHTMLForm:Hx,hasOwnProperty:fc,hasOwnProp:fc,reduceDescriptors:hc,freezeMethods:Vx,toObjectSet:Kx,toCamelCase:Ux,noop:qx,toFiniteNumber:Gx,findKey:uc,global:Xn,isContextDefined:dc,isSpecCompliantForm:Yx,toJSONObject:Xx,isAsyncFn:Jx,isThenable:Zx,setImmediate:pc,asap:Qx,isIterable:e=>e!=null&&Ht(e[Ro])};function Re(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)}H.inherits(Re,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:H.toJSONObject(this.config),code:this.code,status:this.status}}});const mc=Re.prototype,gc={};["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=>{gc[e]={value:e}}),Object.defineProperties(Re,gc),Object.defineProperty(mc,"isAxiosError",{value:!0}),Re.from=(e,t,n,r,o,s)=>{const i=Object.create(mc);H.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 Re.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 ev=null;function bi(e){return H.isPlainObject(e)||H.isArray(e)}function xc(e){return H.endsWith(e,"[]")?e.slice(0,-2):e}function vc(e,t,n){return e?e.concat(t).map(function(o,s){return o=xc(o),!n&&s?"["+o+"]":o}).join(n?".":""):t}function tv(e){return H.isArray(e)&&!e.some(bi)}const nv=H.toFlatObject(H,{},null,function(t){return/^is[A-Z]/.test(t)});function Lo(e,t,n){if(!H.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=H.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(g,x){return!H.isUndefined(x[g])});const r=n.metaTokens,o=n.visitor||d,s=n.dots,i=n.indexes,l=(n.Blob||typeof Blob<"u"&&Blob)&&H.isSpecCompliantForm(t);if(!H.isFunction(o))throw new TypeError("visitor must be a function");function c(v){if(v===null)return"";if(H.isDate(v))return v.toISOString();if(H.isBoolean(v))return v.toString();if(!l&&H.isBlob(v))throw new Re("Blob is not supported. Use a Buffer instead.");return H.isArrayBuffer(v)||H.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(H.endsWith(g,"{}"))g=r?g:g.slice(0,-2),v=JSON.stringify(v);else if(H.isArray(v)&&tv(v)||(H.isFileList(v)||H.endsWith(g,"[]"))&&(y=H.toArray(v)))return g=xc(g),y.forEach(function(S,k){!(H.isUndefined(S)||S===null)&&t.append(i===!0?vc([g],k,s):i===null?g:g+"[]",c(S))}),!1}return bi(v)?!0:(t.append(vc(x,g,s),c(v)),!1)}const f=[],m=Object.assign(nv,{defaultVisitor:d,convertValue:c,isVisitable:bi});function h(v,g){if(!H.isUndefined(v)){if(f.indexOf(v)!==-1)throw Error("Circular reference detected in "+g.join("."));f.push(v),H.forEach(v,function(y,w){(!(H.isUndefined(y)||y===null)&&o.call(t,y,H.isString(w)?w.trim():w,g,m))===!0&&h(y,g?g.concat(w):[w])}),f.pop()}}if(!H.isObject(e))throw new TypeError("data must be an object");return h(e),t}function bc(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function wi(e,t){this._pairs=[],e&&Lo(e,this,t)}const wc=wi.prototype;wc.append=function(t,n){this._pairs.push([t,n])},wc.toString=function(t){const n=t?function(r){return t.call(this,r,bc)}:bc;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function rv(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function yc(e,t,n){if(!t)return e;const r=n&&n.encode||rv;H.isFunction(n)&&(n={serialize:n});const o=n&&n.serialize;let s;if(o?s=o(t,n):s=H.isURLSearchParams(t)?t.toString():new wi(t,n).toString(r),s){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}class Sc{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){H.forEach(this.handlers,function(r){r!==null&&t(r)})}}const Cc={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},ov={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:wi,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},yi=typeof window<"u"&&typeof document<"u",Si=typeof navigator=="object"&&navigator||void 0,sv=yi&&(!Si||["ReactNative","NativeScript","NS"].indexOf(Si.product)<0),iv=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",av=yi&&window.location.href||"http://localhost",_t={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:yi,hasStandardBrowserEnv:sv,hasStandardBrowserWebWorkerEnv:iv,navigator:Si,origin:av},Symbol.toStringTag,{value:"Module"})),...ov};function lv(e,t){return Lo(e,new _t.classes.URLSearchParams,{visitor:function(n,r,o,s){return _t.isNode&&H.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function cv(e){return H.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function uv(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 Tc(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&&H.isArray(o)?o.length:i,l?(H.hasOwnProp(o,i)?o[i]=[o[i],r]:o[i]=r,!a):((!o[i]||!H.isObject(o[i]))&&(o[i]=[]),t(n,r,o[i],s)&&H.isArray(o[i])&&(o[i]=uv(o[i])),!a)}if(H.isFormData(e)&&H.isFunction(e.entries)){const n={};return H.forEachEntry(e,(r,o)=>{t(cv(r),o,n,0)}),n}return null}function dv(e,t,n){if(H.isString(e))try{return(t||JSON.parse)(e),H.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const Gr={transitional:Cc,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",o=r.indexOf("application/json")>-1,s=H.isObject(t);if(s&&H.isHTMLForm(t)&&(t=new FormData(t)),H.isFormData(t))return o?JSON.stringify(Tc(t)):t;if(H.isArrayBuffer(t)||H.isBuffer(t)||H.isStream(t)||H.isFile(t)||H.isBlob(t)||H.isReadableStream(t))return t;if(H.isArrayBufferView(t))return t.buffer;if(H.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 lv(t,this.formSerializer).toString();if((a=H.isFileList(t))||r.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return Lo(a?{"files[]":t}:t,l&&new l,this.formSerializer)}}return s||o?(n.setContentType("application/json",!1),dv(t)):t}],transformResponse:[function(t){const n=this.transitional||Gr.transitional,r=n&&n.forcedJSONParsing,o=this.responseType==="json";if(H.isResponse(t)||H.isReadableStream(t))return t;if(t&&H.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"?Re.from(a,Re.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:_t.classes.FormData,Blob:_t.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};H.forEach(["delete","get","head","post","put","patch"],e=>{Gr.headers[e]={}});const fv=H.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"]),hv=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]&&fv[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},kc=Symbol("internals");function Yr(e){return e&&String(e).trim().toLowerCase()}function $o(e){return e===!1||e==null?e:H.isArray(e)?e.map($o):String(e)}function pv(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}const mv=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function Ci(e,t,n,r,o){if(H.isFunction(r))return r.call(this,t,n);if(o&&(t=n),!!H.isString(t)){if(H.isString(r))return t.indexOf(r)!==-1;if(H.isRegExp(r))return r.test(t)}}function gv(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function xv(e,t){const n=H.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 Ut=class{constructor(t){t&&this.set(t)}set(t,n,r){const o=this;function s(a,l,c){const d=Yr(l);if(!d)throw new Error("header name must be a non-empty string");const f=H.findKey(o,d);(!f||o[f]===void 0||c===!0||c===void 0&&o[f]!==!1)&&(o[f||l]=$o(a))}const i=(a,l)=>H.forEach(a,(c,d)=>s(c,d,l));if(H.isPlainObject(t)||t instanceof this.constructor)i(t,n);else if(H.isString(t)&&(t=t.trim())&&!mv(t))i(hv(t),n);else if(H.isObject(t)&&H.isIterable(t)){let a={},l,c;for(const d of t){if(!H.isArray(d))throw TypeError("Object iterator must return a key-value pair");a[c=d[0]]=(l=a[c])?H.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=Yr(t),t){const r=H.findKey(this,t);if(r){const o=this[r];if(!n)return o;if(n===!0)return pv(o);if(H.isFunction(n))return n.call(this,o,r);if(H.isRegExp(n))return n.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=Yr(t),t){const r=H.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||Ci(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let o=!1;function s(i){if(i=Yr(i),i){const a=H.findKey(r,i);a&&(!n||Ci(r,r[a],a,n))&&(delete r[a],o=!0)}}return H.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||Ci(this,this[s],s,t,!0))&&(delete this[s],o=!0)}return o}normalize(t){const n=this,r={};return H.forEach(this,(o,s)=>{const i=H.findKey(r,s);if(i){n[i]=$o(o),delete n[s];return}const a=t?gv(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 H.forEach(this,(r,o)=>{r!=null&&r!==!1&&(n[o]=t&&H.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[kc]=this[kc]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=Yr(i);r[a]||(xv(o,i),r[a]=!0)}return H.isArray(t)?t.forEach(s):s(t),this}};Ut.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),H.reduceDescriptors(Ut.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),H.freezeMethods(Ut);function Ti(e,t){const n=this||Gr,r=t||n,o=Ut.from(r.headers);let s=r.data;return H.forEach(e,function(a){s=a.call(n,s,o.normalize(),t?t.status:void 0)}),o.normalize(),s}function Ec(e){return!!(e&&e.__CANCEL__)}function mr(e,t,n){Re.call(this,e??"canceled",Re.ERR_CANCELED,t,n),this.name="CanceledError"}H.inherits(mr,Re,{__CANCEL__:!0});function Ic(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new Re("Request failed with status code "+n.status,[Re.ERR_BAD_REQUEST,Re.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function vv(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function bv(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 f=s,m=0;for(;f!==o;)m+=n[f++],f=f%e;if(o=(o+1)%e,o===s&&(s=(s+1)%e),c-i<t)return;const h=d&&c-d;return h?Math.round(m*1e3/h):void 0}}function wv(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(),f=d-n;f>=r?i(c,d):(o=c,s||(s=setTimeout(()=>{s=null,i(o)},r-f)))},()=>o&&i(o)]}const Fo=(e,t,n=3)=>{let r=0;const o=bv(50,250);return wv(s=>{const i=s.loaded,a=s.lengthComputable?s.total:void 0,l=i-r,c=o(l),d=i<=a;r=i;const f={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(f)},n)},Nc=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},Ac=e=>(...t)=>H.asap(()=>e(...t)),yv=_t.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,_t.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(_t.origin),_t.navigator&&/(msie|trident)/i.test(_t.navigator.userAgent)):()=>!0,Sv=_t.hasStandardBrowserEnv?{write(e,t,n,r,o,s){const i=[e+"="+encodeURIComponent(t)];H.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),H.isString(r)&&i.push("path="+r),H.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 Cv(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Tv(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function jc(e,t,n){let r=!Cv(t);return e&&(r||n==!1)?Tv(e,t):t}const Pc=e=>e instanceof Ut?{...e}:e;function Jn(e,t){t=t||{};const n={};function r(c,d,f,m){return H.isPlainObject(c)&&H.isPlainObject(d)?H.merge.call({caseless:m},c,d):H.isPlainObject(d)?H.merge({},d):H.isArray(d)?d.slice():d}function o(c,d,f,m){if(H.isUndefined(d)){if(!H.isUndefined(c))return r(void 0,c,f,m)}else return r(c,d,f,m)}function s(c,d){if(!H.isUndefined(d))return r(void 0,d)}function i(c,d){if(H.isUndefined(d)){if(!H.isUndefined(c))return r(void 0,c)}else return r(void 0,d)}function a(c,d,f){if(f in t)return r(c,d);if(f 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,f)=>o(Pc(c),Pc(d),f,!0)};return H.forEach(Object.keys({...e,...t}),function(d){const f=l[d]||o,m=f(e[d],t[d],d);H.isUndefined(m)&&f!==a||(n[d]=m)}),n}const _c=e=>{const t=Jn({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=Ut.from(i),t.url=yc(jc(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&i.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),H.isFormData(n)){if(_t.hasStandardBrowserEnv||_t.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(H.isFunction(n.getHeaders)){const l=n.getHeaders(),c=["content-type","content-length"];Object.entries(l).forEach(([d,f])=>{c.includes(d.toLowerCase())&&i.set(d,f)})}}if(_t.hasStandardBrowserEnv&&(r&&H.isFunction(r)&&(r=r(t)),r||r!==!1&&yv(t.url))){const l=o&&s&&Sv.read(s);l&&i.set(o,l)}return t},kv=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=_c(e);let s=o.data;const i=Ut.from(o.headers).normalize();let{responseType:a,onUploadProgress:l,onDownloadProgress:c}=o,d,f,m,h,v;function g(){h&&h(),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=Ut.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};Ic(function(I){n(I),g()},function(I){r(I),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 Re("Request aborted",Re.ECONNABORTED,e,x)),x=null)},x.onerror=function(k){const C=k&&k.message?k.message:"Network Error",T=new Re(C,Re.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||Cc;o.timeoutErrorMessage&&(k=o.timeoutErrorMessage),r(new Re(k,C.clarifyTimeoutError?Re.ETIMEDOUT:Re.ECONNABORTED,e,x)),x=null},s===void 0&&i.setContentType(null),"setRequestHeader"in x&&H.forEach(i.toJSON(),function(k,C){x.setRequestHeader(C,k)}),H.isUndefined(o.withCredentials)||(x.withCredentials=!!o.withCredentials),a&&a!=="json"&&(x.responseType=o.responseType),c&&([m,v]=Fo(c,!0),x.addEventListener("progress",m)),l&&x.upload&&([f,h]=Fo(l),x.upload.addEventListener("progress",f),x.upload.addEventListener("loadend",h)),(o.cancelToken||o.signal)&&(d=S=>{x&&(r(!S||S.type?new mr(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=vv(o.url);if(w&&_t.protocols.indexOf(w)===-1){r(new Re("Unsupported protocol "+w+":",Re.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 Re?d:new mr(d instanceof Error?d.message:d))}};let i=t&&setTimeout(()=>{i=null,s(new Re(`timeout ${t} of ms exceeded`,Re.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=()=>H.asap(a),l}},Iv=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 Av(e))yield*Iv(n,t)},Av=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:n,value:r}=await t.read();if(n)break;yield r}}finally{await t.cancel()}},Rc=(e,t,n,r)=>{const o=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 f=d.byteLength;if(n){let m=s+=f;n(m)}l.enqueue(new Uint8Array(d))}catch(c){throw a(c),c}},cancel(l){return a(l),o.return()}},{highWaterMark:2})},Mc=64*1024,{isFunction:Bo}=H,jv=(({Request:e,Response:t})=>({Request:e,Response:t}))(H.global),{ReadableStream:Oc,TextEncoder:Dc}=H.global,Lc=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Pv=e=>{e=H.merge.call({skipUndefined:!0},jv,e);const{fetch:t,Request:n,Response:r}=e,o=t?Bo(t):typeof fetch=="function",s=Bo(n),i=Bo(r);if(!o)return!1;const a=o&&Bo(Oc),l=o&&(typeof Dc=="function"?(v=>g=>v.encode(g))(new Dc):async v=>new Uint8Array(await new n(v).arrayBuffer())),c=s&&a&&Lc(()=>{let v=!1;const g=new n(_t.origin,{body:new Oc,method:"POST",get duplex(){return v=!0,"half"}}).headers.has("Content-Type");return v&&!g}),d=i&&a&&Lc(()=>H.isReadableStream(new r("").body)),f={stream:d&&(v=>v.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(v=>{!f[v]&&(f[v]=(g,x)=>{let y=g&&g[v];if(y)return y.call(g);throw new Re(`Response type '${v}' is not supported`,Re.ERR_NOT_SUPPORT,x)})});const m=async v=>{if(v==null)return 0;if(H.isBlob(v))return v.size;if(H.isSpecCompliantForm(v))return(await new n(_t.origin,{method:"POST",body:v}).arrayBuffer()).byteLength;if(H.isArrayBufferView(v)||H.isArrayBuffer(v))return v.byteLength;if(H.isURLSearchParams(v)&&(v=v+""),H.isString(v))return(await l(v)).byteLength},h=async(v,g)=>{const x=H.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:I,headers:N,withCredentials:R="same-origin",fetchOptions:O}=_c(v),$=t||fetch;I=I?(I+"").toLowerCase():"text";let V=Ev([w,S&&S.toAbortSignal()],k),U=null;const j=V&&V.unsubscribe&&(()=>{V.unsubscribe()});let q;try{if(T&&c&&x!=="get"&&x!=="head"&&(q=await h(N,y))!==0){let Y=new n(g,{method:"POST",body:y,duplex:"half"}),P;if(H.isFormData(y)&&(P=Y.headers.get("content-type"))&&N.setContentType(P),Y.body){const[M,G]=Nc(q,Fo(Ac(T)));y=Rc(Y.body,Mc,M,G)}}H.isString(R)||(R=R?"include":"omit");const K=s&&"credentials"in n.prototype,D={...O,signal:V,method:x.toUpperCase(),headers:N.normalize().toJSON(),body:y,duplex:"half",credentials:K?R:void 0};U=s&&new n(g,D);let _=await(s?$(U,O):$(g,D));const E=d&&(I==="stream"||I==="response");if(d&&(C||E&&j)){const Y={};["status","statusText","headers"].forEach(J=>{Y[J]=_[J]});const P=H.toFiniteNumber(_.headers.get("content-length")),[M,G]=C&&Nc(P,Fo(Ac(C),!0))||[];_=new r(Rc(_.body,Mc,M,()=>{G&&G(),j&&j()}),Y)}I=I||"text";let B=await f[H.findKey(f,I)||"text"](_,v);return!E&&j&&j(),await new Promise((Y,P)=>{Ic(Y,P,{data:B,headers:Ut.from(_.headers),status:_.status,statusText:_.statusText,config:v,request:U})})}catch(K){throw j&&j(),K&&K.name==="TypeError"&&/Load failed|fetch/i.test(K.message)?Object.assign(new Re("Network Error",Re.ERR_NETWORK,v,U),{cause:K.cause||K}):Re.from(K,K&&K.code,v,U)}}},_v=new Map,$c=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=_v;for(;a--;)l=s[a],c=d.get(l),c===void 0&&d.set(l,c=a?new Map:Pv(t)),d=c;return c};$c();const ki={http:ev,xhr:kv,fetch:{get:$c}};H.forEach(ki,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Fc=e=>`- ${e}`,Rv=e=>H.isFunction(e)||e===null||e===!1,Bc={getAdapter:(e,t)=>{e=H.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,!Rv(r)&&(o=ki[(a=String(r)).toLowerCase()],o===void 0))throw new Re(`Unknown adapter '${a}'`);if(o&&(H.isFunction(o)||(o=o.get(t))))break;s[a||"#"+i]=o}if(!o){const i=Object.entries(s).map(([l,c])=>`adapter ${l} `+(c===!1?"is not supported by the environment":"is not available in the build"));let a=n?i.length>1?`since :
|
|
33
33
|
`+i.map(Fc).join(`
|
|
34
34
|
`):" "+Fc(i[0]):"as no adapter specified";throw new Re("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return o},adapters:ki};function Ei(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new mr(null,e)}function zc(e){return Ei(e),e.headers=Ut.from(e.headers),e.data=Ti.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),Bc.getAdapter(e.adapter||Gr.adapter,e)(e).then(function(r){return Ei(e),r.data=Ti.call(e,e.transformResponse,r),r.headers=Ut.from(r.headers),r},function(r){return Ec(r)||(Ei(e),r&&r.response&&(r.response.data=Ti.call(e,e.transformResponse,r.response),r.response.headers=Ut.from(r.response.headers))),Promise.reject(r)})}const Hc="1.12.2",zo={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{zo[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const Uc={};zo.transitional=function(t,n,r){function o(s,i){return"[Axios v"+Hc+"] Transitional option '"+s+"'"+i+(r?". "+r:"")}return(s,i,a)=>{if(t===!1)throw new Re(o(i," has been removed"+(n?" in "+n:"")),Re.ERR_DEPRECATED);return n&&!Uc[i]&&(Uc[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}},zo.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function Mv(e,t,n){if(typeof e!="object")throw new Re("options must be an object",Re.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 Re("option "+s+" must be "+l,Re.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new Re("Unknown option "+s,Re.ERR_BAD_OPTION)}}const Ho={assertOptions:Mv,validators:zo},xn=Ho.validators;let Zn=class{constructor(t){this.defaults=t||{},this.interceptors={request:new Sc,response:new Sc}}async request(t,n){try{return await this._request(t,n)}catch(r){if(r instanceof Error){let o={};Error.captureStackTrace?Error.captureStackTrace(o):o=new Error;const s=o.stack?o.stack.replace(/^.+\n/,""):"";try{r.stack?s&&!String(r.stack).endsWith(s.replace(/^.+\n.+\n/,""))&&(r.stack+=`
|
|
35
|
-
`+s):r.stack=s}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=Jn(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:s}=n;r!==void 0&&Ho.assertOptions(r,{silentJSONParsing:xn.transitional(xn.boolean),forcedJSONParsing:xn.transitional(xn.boolean),clarifyTimeoutError:xn.transitional(xn.boolean)},!1),o!=null&&(H.isFunction(o)?n.paramsSerializer={serialize:o}:Ho.assertOptions(o,{encode:xn.function,serialize:xn.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Ho.assertOptions(n,{baseUrl:xn.spelling("baseURL"),withXsrfToken:xn.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=s&&H.merge(s.common,s[n.method]);s&&H.forEach(["delete","get","head","post","put","patch","common"],v=>{delete s[v]}),n.headers=Ut.concat(i,s);const a=[];let l=!0;this.interceptors.request.forEach(function(g){typeof g.runWhen=="function"&&g.runWhen(n)===!1||(l=l&&g.synchronous,a.unshift(g.fulfilled,g.rejected))});const c=[];this.interceptors.response.forEach(function(g){c.push(g.fulfilled,g.rejected)});let d,h=0,m;if(!l){const v=[zc.bind(this),void 0];for(v.unshift(...a),v.push(...c),m=v.length,d=Promise.resolve(n);h<m;)d=d.then(v[h++],v[h++]);return d}m=a.length;let f=n;for(;h<m;){const v=a[h++],g=a[h++];try{f=v(f)}catch(x){g.call(this,x);break}}try{d=zc.call(this,f)}catch(v){return Promise.reject(v)}for(h=0,m=c.length;h<m;)d=d.then(c[h++],c[h++]);return d}getUri(t){t=Jn(this.defaults,t);const n=jc(t.baseURL,t.url,t.allowAbsoluteUrls);return yc(n,t.params,t.paramsSerializer)}};H.forEach(["delete","get","head","options"],function(t){Zn.prototype[t]=function(n,r){return this.request(Jn(r||{},{method:t,url:n,data:(r||{}).data}))}}),H.forEach(["post","put","patch"],function(t){function n(r){return function(s,i,a){return this.request(Jn(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}Zn.prototype[t]=n(),Zn.prototype[t+"Form"]=n(!0)});let Ov=class ex{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 mr(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 ex(function(o){t=o}),cancel:t}}};function Dv(e){return function(n){return e.apply(null,n)}}function Lv(e){return H.isObject(e)&&e.isAxiosError===!0}const Ii={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(Ii).forEach(([e,t])=>{Ii[t]=e});function Wc(e){const t=new Zn(e),n=ic(Zn.prototype.request,t);return H.extend(n,Zn.prototype,t,{allOwnKeys:!0}),H.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return Wc(Jn(e,o))},n}const ht=Wc(Gr);ht.Axios=Zn,ht.CanceledError=mr,ht.CancelToken=Ov,ht.isCancel=Ec,ht.VERSION=Hc,ht.toFormData=Lo,ht.AxiosError=Re,ht.Cancel=ht.CanceledError,ht.all=function(t){return Promise.all(t)},ht.spread=Dv,ht.isAxiosError=Lv,ht.mergeConfig=Jn,ht.AxiosHeaders=Ut,ht.formToJSON=e=>Tc(H.isHTMLForm(e)?new FormData(e):e),ht.getAdapter=Bc.getAdapter,ht.HttpStatusCode=Ii,ht.default=ht;const{Axios:uN,AxiosError:dN,CanceledError:fN,isCancel:hN,CancelToken:pN,VERSION:mN,all:gN,Cancel:xN,isAxiosError:vN,spread:bN,toFormData:wN,AxiosHeaders:yN,HttpStatusCode:SN,formToJSON:CN,getAdapter:TN,mergeConfig:kN}=ht,Vc=typeof window<"u"?window.__API_BASE_URL__:void 0,Kc=Vc?vn(Vc):void 0;function vn(e){const n=(e!=null&&e.trim()?e.trim():"/api/chat").replace(/\/+$/,"");return n?n.endsWith("/chat")?n:`${n}/chat`:"/api/chat"}let Uo=null;const Ni=new Set;function qc(){return Uo}function Wo(e){Uo=e,Ni.forEach(t=>t(e))}function Gc(e){return Ni.add(e),()=>Ni.delete(e)}const Yc=3e4,Xc=9e4,Xt=ht.create({...Kc?{baseURL:Kc}:{},timeout:Yc,withCredentials:!0});Xt.interceptors.request.use(e=>(Uo&&(e.headers.Authorization=`Bearer ${Uo}`),e)),Xt.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),Wo(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 Jt(e,t){return Xt.defaults.baseURL?(await Xt.get(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}async function Vo(e,t,n){return Xt.defaults.baseURL?(await Xt.post(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function Jc(e,t,n){return Xt.defaults.baseURL?(await Xt.put(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function Ai(e,t){return Xt.defaults.baseURL?(await Xt.delete(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}function $t(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class Ko{get baseUrl(){const t=Xt.defaults.baseURL;return t?vn(String(t)):""}updateConfig(t){t.baseUrl&&(Xt.defaults.baseURL=vn(String(t.baseUrl))),t.authToken!==void 0&&Wo(t.authToken)}getAuthToken(){return qc()}setAuthToken(t){Wo(t)}onTokenChange(t){return Gc(t)}async listThreads(){const t=await Jt("/threads"),n=$t(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async listSharedThreads(){const t=await Jt("/threads/shared"),n=$t(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async createThread(t){const r=await Vo("/threads",t?{title:t}:void 0);return $t(r)}async updateThread(t,n){const r=await Jc(`/threads/${t}`,{title:n});return $t(r)}async deleteThread(t){const n=await Ai(`/threads/${t}`);return $t(n)}async shareThread(t,n){const r=await Vo(`/threads/${t}/share`,{shared_with_user_id:n});return $t(r)}async threadInfo(t){const n=await Jt(`/threads/${t}/info`);return $t(n)}async listAgents(){const t=await Jt("/agents"),n=$t(t);return(n==null?void 0:n.items)??[]}async getAgent(t){const n=await Jt(`/agents/${t}`);return $t(n)}async getAgentSchema(t){const n=await Jt(`/agents/${t}/schema`);return $t(n)}async getState(t){const n=await Jt(`/threads/${t.threadId}/state`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return $t(n)}async getStateHistory(t){const n=await Jt(`/threads/${t.threadId}/state/history`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs},timeout:Xc});return $t(n)}async cancelRun(t){const n=await Vo("/runs/cancel",{threadId:t});return $t(n)}async unshareThread(t,n){const r=await Ai(`/threads/${t}/share/${n}`);return $t(r)}}const Mn=new Ko,$v=Ko,Fv=Ko;async function ji(e,t){return await Jt(e,{responseType:"blob",onDownloadProgress:r=>{try{if(t&&r.lengthComputable){const o=r.loaded/r.total;t(o)}}catch{}},maxBodyLength:1/0})}async function Bv(e,t){const n=await ji(`/files/${e}/view`,t),r=URL.createObjectURL(n);window.open(r,"_blank"),setTimeout(()=>URL.revokeObjectURL(r),6e4)}async function _i(e,t){return await(await ji(`/files/${e}/view`,t)).text()}async function Zc(e,t){const n=await ji(`/files/${e}/download`,t),r=URL.createObjectURL(n);let o=`file_${e}`;try{const i=await Jt(`/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 zv(e){return await Jt(`/files/${e}`)}async function Qc(e,t=50,n=0){const r={limit:t,offset:n};return e&&(r.thread_id=e),await Jt("/files",{params:r})}const eu=b.createContext(null);function tu({children:e,apiConfig:t}){const n=Mn;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(eu.Provider,{value:r,children:e})}async function nu(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 ru(e=[]){const t=[],n=[];for(const r of e)try{const o=await nu(r);n.push({filename:r.name,data:o,mime_type:r.type||"application/octet-stream"})}catch{}return{contentParts:t,filesInfo:n}}function Xr(){const e=b.useContext(eu);if(!e)throw new Error("useApi must be used within ApiProvider");return e}function ou(e){return!!e&&typeof e=="object"&&e.protocolVersion==="v1"&&"data"in e}function Pi(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 Jr(e,t,n){return t<0||t>=e.length?e:[...e.slice(0,t),n,...e.slice(t+1)]}function Hv(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 su(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="assistant")return e[t].id;return null}function iu(e){return!e||!e.length?"":e.filter(t=>t.type==="text").map(t=>t.text??"").join("")}function au(e,t,n,r){const o={...n};if(r!==null&&typeof r=="number"){if(typeof o.lastSeq=="number"&&r<=o.lastSeq)return{newParts:e,newMeta:o,changed:!1};o.lastSeq=r}const s=t.filter(h=>h.type==="text").map(h=>h.text??"").join(""),i=t.filter(h=>h.type!=="text"),a=o.lastText??iu(e);let l="",c=e.slice();if(s){const h=Uv(a,s);if(h===""?l="":h===s?l=s:l=h,l){const m=c[c.length-1];if((m==null?void 0:m.type)==="text"){const f=m.text??"",v={...m,text:f+l};c=[...c.slice(0,c.length-1),v]}else c=[...c,{type:"text",text:l}];o.lastText=a+l}else o.lastText=a}i.length&&(c=[...c,...i]);const d=!!(l||i.length);return{newParts:c,newMeta:o,changed:d}}function lu(e){return e.replace(/\s+/g," ").trim()}function Uv(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=lu(e),o=lu(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 Wv(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 Jr(e,r,s)}return e}function cu(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}function Vv(e={}){const t=b.useMemo(()=>vn(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),[h,m]=b.useState(""),[f,v]=b.useState(null),[g,x]=b.useState(0),[y,w]=b.useState(!1),[S,k]=b.useState(null),C=b.useRef(null),T=b.useRef(!0),I=b.useRef(0),N=b.useRef(null),R=b.useRef(null),O=b.useRef(null),$=b.useRef(null),V=b.useRef({messageId:null,lastSeq:null,lastText:""}),U=b.useCallback(D=>{o(D)},[]),j=b.useCallback(()=>{m(""),v(null),d(null),R.current=null,O.current=null,$.current=null,k(null),V.current={messageId:null,lastSeq:null,lastText:""}},[]),q=b.useCallback(()=>{var D;console.debug("[use-chat] stop() invoked - aborting stream"),(D=C.current)==null||D.abort(),C.current=null,N.current=null,l(!1),w(!1),I.current=0,x(0)},[]),K=b.useCallback((D,P,E)=>{C.current&&(C.current.abort(),C.current=null),l(!0),d(null),e.autoAppendAssistant!==!1&&m(""),v(null),R.current=null,O.current=null,$.current=null,k(null),V.current={messageId:null,lastSeq:null,lastText:""};const B=new AbortController;C.current=B;let Y=null,_=null,M=!1;return N.current={threadId:D.threadId??null,headers:{}},(async()=>{var J,se,W,L,X,ee,Z,z,ae,ie,ge,we,Ae,Pe,ke,st,bt,It;const G=We=>{var ze;try{const Ke=JSON.parse(JSON.stringify(We));return(ze=Ke==null?void 0:Ke.payload)!=null&&ze.files_info&&Array.isArray(Ke.payload.files_info)&&(Ke.payload.files_info=Ke.payload.files_info.map(Fe=>({...Fe,data:Fe!=null&&Fe.data?`<base64 ${String(Fe.data).length} chars>`:Fe==null?void 0:Fe.data}))),Ke}catch{return We}};try{let We={};try{if(r)We={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const Ve=window.__AUTH_TOKEN__,Te=((J=window.localStorage)==null?void 0:J.getItem("authToken"))||null;let Q=null;try{const Ze=(se=window.localStorage)==null?void 0:se.getItem("chat-settings");Ze&&(Q=((W=JSON.parse(Ze))==null?void 0:W.apiKey)||null)}catch{}const me=Ve||Te||Q||null;me&&(We={Authorization:`Bearer ${me}`})}}catch{}console.debug("[use-chat] POST",t+n,G(D));let ze={};if(typeof window<"u")try{const Oe=(L=window.localStorage)==null?void 0:L.getItem("authSessionId");Oe&&(ze={"X-Session-Id":Oe})}catch{}const Ke={...We,...ze,...s.current},Fe={"Content-Type":"application/json",Accept:"text/event-stream",...Ke},Ue=await fetch(t+n,{method:"POST",headers:Fe,body:JSON.stringify(D),signal:B.signal,credentials:i});if(N.current&&(N.current.headers=Ke),!Ue.ok||!Ue.body){const Oe=await Ue.text().catch(()=>"");console.debug("[use-chat] non-OK response",Ue.status,Oe==null?void 0:Oe.slice(0,500));const Ve=`stream ${Ue.status}${Oe?": "+Oe:""}`;throw(X=E==null?void 0:E.onConnectionError)==null||X.call(E,Ve),M=!0,Y="error",_=Ve,new Error(Ve)}w(!0);const ut=Ue.body.getReader(),jt=new TextDecoder;let it="",_t=[];I.current=0,x(0);let yt=0,gt=null;const Nt=()=>{if(_t.length){const Oe=_t.join("");_t=[],T.current&&m(Ve=>Ve+Oe)}gt=null},St=()=>{typeof window<"u"&>==null&&(gt=requestAnimationFrame(Nt))};let Ct=Date.now();const zt=setInterval(()=>{var Oe;if(Date.now()-Ct>18e5){const Ve="Stream idle timeout";d(Ve),Y="error",_=Ve,B.abort(),(Oe=E==null?void 0:E.onError)==null||Oe.call(E,Ve)}},5e3),xt=1024*1024;try{const Oe=Ue.headers.get("X-Thread-Id")||Ue.headers.get("x-thread-id"),Ve=Ue.headers.get("X-Thread-Created")||Ue.headers.get("x-thread-created"),Te=Oe??null,Q=String(Ve??"").toLowerCase()==="true";for(N.current&&!N.current.threadId&&(N.current={...N.current,threadId:Te}),(ee=E==null?void 0:E.onOpen)==null||ee.call(E,{threadId:Te,created:Q});;){const{value:me,done:Ze}=await ut.read();if(Ze)break;it+=jt.decode(me,{stream:!0}),it.length>xt&&(it="",console.warn("Stream buffer reset: exceeded 1MB"));let xe;for(;(xe=it.indexOf(`
|
|
35
|
+
`+s):r.stack=s}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=Jn(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:s}=n;r!==void 0&&Ho.assertOptions(r,{silentJSONParsing:xn.transitional(xn.boolean),forcedJSONParsing:xn.transitional(xn.boolean),clarifyTimeoutError:xn.transitional(xn.boolean)},!1),o!=null&&(H.isFunction(o)?n.paramsSerializer={serialize:o}:Ho.assertOptions(o,{encode:xn.function,serialize:xn.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Ho.assertOptions(n,{baseUrl:xn.spelling("baseURL"),withXsrfToken:xn.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=s&&H.merge(s.common,s[n.method]);s&&H.forEach(["delete","get","head","post","put","patch","common"],v=>{delete s[v]}),n.headers=Ut.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,f=0,m;if(!l){const v=[zc.bind(this),void 0];for(v.unshift(...a),v.push(...c),m=v.length,d=Promise.resolve(n);f<m;)d=d.then(v[f++],v[f++]);return d}m=a.length;let h=n;for(;f<m;){const v=a[f++],g=a[f++];try{h=v(h)}catch(x){g.call(this,x);break}}try{d=zc.call(this,h)}catch(v){return Promise.reject(v)}for(f=0,m=c.length;f<m;)d=d.then(c[f++],c[f++]);return d}getUri(t){t=Jn(this.defaults,t);const n=jc(t.baseURL,t.url,t.allowAbsoluteUrls);return yc(n,t.params,t.paramsSerializer)}};H.forEach(["delete","get","head","options"],function(t){Zn.prototype[t]=function(n,r){return this.request(Jn(r||{},{method:t,url:n,data:(r||{}).data}))}}),H.forEach(["post","put","patch"],function(t){function n(r){return function(s,i,a){return this.request(Jn(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}Zn.prototype[t]=n(),Zn.prototype[t+"Form"]=n(!0)});let Ov=class ex{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 mr(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 ex(function(o){t=o}),cancel:t}}};function Dv(e){return function(n){return e.apply(null,n)}}function Lv(e){return H.isObject(e)&&e.isAxiosError===!0}const Ii={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(Ii).forEach(([e,t])=>{Ii[t]=e});function Wc(e){const t=new Zn(e),n=ic(Zn.prototype.request,t);return H.extend(n,Zn.prototype,t,{allOwnKeys:!0}),H.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return Wc(Jn(e,o))},n}const ht=Wc(Gr);ht.Axios=Zn,ht.CanceledError=mr,ht.CancelToken=Ov,ht.isCancel=Ec,ht.VERSION=Hc,ht.toFormData=Lo,ht.AxiosError=Re,ht.Cancel=ht.CanceledError,ht.all=function(t){return Promise.all(t)},ht.spread=Dv,ht.isAxiosError=Lv,ht.mergeConfig=Jn,ht.AxiosHeaders=Ut,ht.formToJSON=e=>Tc(H.isHTMLForm(e)?new FormData(e):e),ht.getAdapter=Bc.getAdapter,ht.HttpStatusCode=Ii,ht.default=ht;const{Axios:uN,AxiosError:dN,CanceledError:fN,isCancel:hN,CancelToken:pN,VERSION:mN,all:gN,Cancel:xN,isAxiosError:vN,spread:bN,toFormData:wN,AxiosHeaders:yN,HttpStatusCode:SN,formToJSON:CN,getAdapter:TN,mergeConfig:kN}=ht,Vc=typeof window<"u"?window.__API_BASE_URL__:void 0,Kc=Vc?vn(Vc):void 0;function vn(e){const n=(e!=null&&e.trim()?e.trim():"/api/chat").replace(/\/+$/,"");return n?n.endsWith("/chat")?n:`${n}/chat`:"/api/chat"}let Uo=null;const Ni=new Set;function qc(){return Uo}function Wo(e){Uo=e,Ni.forEach(t=>t(e))}function Gc(e){return Ni.add(e),()=>Ni.delete(e)}const Yc=3e4,Xc=9e4,Xt=ht.create({...Kc?{baseURL:Kc}:{},timeout:Yc,withCredentials:!0});Xt.interceptors.request.use(e=>(Uo&&(e.headers.Authorization=`Bearer ${Uo}`),e)),Xt.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),Wo(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 Jt(e,t){return Xt.defaults.baseURL?(await Xt.get(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}async function Vo(e,t,n){return Xt.defaults.baseURL?(await Xt.post(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function Jc(e,t,n){return Xt.defaults.baseURL?(await Xt.put(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function Ai(e,t){return Xt.defaults.baseURL?(await Xt.delete(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}function $t(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class Ko{get baseUrl(){const t=Xt.defaults.baseURL;return t?vn(String(t)):""}updateConfig(t){t.baseUrl&&(Xt.defaults.baseURL=vn(String(t.baseUrl))),t.authToken!==void 0&&Wo(t.authToken)}getAuthToken(){return qc()}setAuthToken(t){Wo(t)}onTokenChange(t){return Gc(t)}async listThreads(){const t=await Jt("/threads"),n=$t(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async listSharedThreads(){const t=await Jt("/threads/shared"),n=$t(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async createThread(t){const r=await Vo("/threads",t?{title:t}:void 0);return $t(r)}async updateThread(t,n){const r=await Jc(`/threads/${t}`,{title:n});return $t(r)}async deleteThread(t){const n=await Ai(`/threads/${t}`);return $t(n)}async shareThread(t,n){const r=await Vo(`/threads/${t}/share`,{shared_with_user_id:n});return $t(r)}async threadInfo(t){const n=await Jt(`/threads/${t}/info`);return $t(n)}async listAgents(){const t=await Jt("/agents"),n=$t(t);return(n==null?void 0:n.items)??[]}async getAgent(t){const n=await Jt(`/agents/${t}`);return $t(n)}async getAgentSchema(t){const n=await Jt(`/agents/${t}/schema`);return $t(n)}async getState(t){const n=await Jt(`/threads/${t.threadId}/state`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return $t(n)}async getStateHistory(t){const n=await Jt(`/threads/${t.threadId}/state/history`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs},timeout:Xc});return $t(n)}async cancelRun(t){const n=await Vo("/runs/cancel",{threadId:t});return $t(n)}async unshareThread(t,n){const r=await Ai(`/threads/${t}/share/${n}`);return $t(r)}}const Mn=new Ko,$v=Ko,Fv=Ko;async function ji(e,t){return await Jt(e,{responseType:"blob",onDownloadProgress:r=>{try{if(t&&r.lengthComputable){const o=r.loaded/r.total;t(o)}}catch{}},maxBodyLength:1/0})}async function Bv(e,t){const n=await ji(`/files/${e}/view`,t),r=URL.createObjectURL(n);window.open(r,"_blank"),setTimeout(()=>URL.revokeObjectURL(r),6e4)}async function Pi(e,t){return await(await ji(`/files/${e}/view`,t)).text()}async function Zc(e,t){const n=await ji(`/files/${e}/download`,t),r=URL.createObjectURL(n);let o=`file_${e}`;try{const i=await Jt(`/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 zv(e){return await Jt(`/files/${e}`)}async function Qc(e,t=50,n=0){const r={limit:t,offset:n};return e&&(r.thread_id=e),await Jt("/files",{params:r})}const eu=b.createContext(null);function tu({children:e,apiConfig:t}){const n=Mn;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(eu.Provider,{value:r,children:e})}async function nu(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 ru(e=[]){const t=[],n=[];for(const r of e)try{const o=await nu(r);n.push({filename:r.name,data:o,mime_type:r.type||"application/octet-stream"})}catch{}return{contentParts:t,filesInfo:n}}function Xr(){const e=b.useContext(eu);if(!e)throw new Error("useApi must be used within ApiProvider");return e}function ou(e){return!!e&&typeof e=="object"&&e.protocolVersion==="v1"&&"data"in e}function _i(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 Jr(e,t,n){return t<0||t>=e.length?e:[...e.slice(0,t),n,...e.slice(t+1)]}function Hv(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 su(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="assistant")return e[t].id;return null}function iu(e){return!e||!e.length?"":e.filter(t=>t.type==="text").map(t=>t.text??"").join("")}function au(e,t,n,r){const o={...n};if(r!==null&&typeof r=="number"){if(typeof o.lastSeq=="number"&&r<=o.lastSeq)return{newParts:e,newMeta:o,changed:!1};o.lastSeq=r}const s=t.filter(f=>f.type==="text").map(f=>f.text??"").join(""),i=t.filter(f=>f.type!=="text"),a=o.lastText??iu(e);let l="",c=e.slice();if(s){const f=Uv(a,s);if(f===""?l="":f===s?l=s:l=f,l){const m=c[c.length-1];if((m==null?void 0:m.type)==="text"){const h=m.text??"",v={...m,text:h+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 lu(e){return e.replace(/\s+/g," ").trim()}function Uv(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=lu(e),o=lu(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 Wv(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 Jr(e,r,s)}return e}function cu(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}function Vv(e={}){const t=b.useMemo(()=>vn(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),[f,m]=b.useState(""),[h,v]=b.useState(null),[g,x]=b.useState(0),[y,w]=b.useState(!1),[S,k]=b.useState(null),C=b.useRef(null),T=b.useRef(!0),I=b.useRef(0),N=b.useRef(null),R=b.useRef(null),O=b.useRef(null),$=b.useRef(null),V=b.useRef({messageId:null,lastSeq:null,lastText:""}),U=b.useCallback(D=>{o(D)},[]),j=b.useCallback(()=>{m(""),v(null),d(null),R.current=null,O.current=null,$.current=null,k(null),V.current={messageId:null,lastSeq:null,lastText:""}},[]),q=b.useCallback(()=>{var D;console.debug("[use-chat] stop() invoked - aborting stream"),(D=C.current)==null||D.abort(),C.current=null,N.current=null,l(!1),w(!1),I.current=0,x(0)},[]),K=b.useCallback((D,_,E)=>{C.current&&(C.current.abort(),C.current=null),l(!0),d(null),e.autoAppendAssistant!==!1&&m(""),v(null),R.current=null,O.current=null,$.current=null,k(null),V.current={messageId:null,lastSeq:null,lastText:""};const B=new AbortController;C.current=B;let Y=null,P=null,M=!1;return N.current={threadId:D.threadId??null,headers:{}},(async()=>{var J,se,W,L,X,ee,Z,z,ae,ie,ge,we,Ae,_e,ke,st,bt,It;const G=We=>{var ze;try{const Ke=JSON.parse(JSON.stringify(We));return(ze=Ke==null?void 0:Ke.payload)!=null&&ze.files_info&&Array.isArray(Ke.payload.files_info)&&(Ke.payload.files_info=Ke.payload.files_info.map(Fe=>({...Fe,data:Fe!=null&&Fe.data?`<base64 ${String(Fe.data).length} chars>`:Fe==null?void 0:Fe.data}))),Ke}catch{return We}};try{let We={};try{if(r)We={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const Ve=window.__AUTH_TOKEN__,Te=((J=window.localStorage)==null?void 0:J.getItem("authToken"))||null;let Q=null;try{const Ze=(se=window.localStorage)==null?void 0:se.getItem("chat-settings");Ze&&(Q=((W=JSON.parse(Ze))==null?void 0:W.apiKey)||null)}catch{}const me=Ve||Te||Q||null;me&&(We={Authorization:`Bearer ${me}`})}}catch{}console.debug("[use-chat] POST",t+n,G(D));let ze={};if(typeof window<"u")try{const Oe=(L=window.localStorage)==null?void 0:L.getItem("authSessionId");Oe&&(ze={"X-Session-Id":Oe})}catch{}const Ke={...We,...ze,...s.current},Fe={"Content-Type":"application/json",Accept:"text/event-stream",...Ke},Ue=await fetch(t+n,{method:"POST",headers:Fe,body:JSON.stringify(D),signal:B.signal,credentials:i});if(N.current&&(N.current.headers=Ke),!Ue.ok||!Ue.body){const Oe=await Ue.text().catch(()=>"");console.debug("[use-chat] non-OK response",Ue.status,Oe==null?void 0:Oe.slice(0,500));const Ve=`stream ${Ue.status}${Oe?": "+Oe:""}`;throw(X=E==null?void 0:E.onConnectionError)==null||X.call(E,Ve),M=!0,Y="error",P=Ve,new Error(Ve)}w(!0);const ut=Ue.body.getReader(),jt=new TextDecoder;let it="",Pt=[];I.current=0,x(0);let yt=0,gt=null;const Nt=()=>{if(Pt.length){const Oe=Pt.join("");Pt=[],T.current&&m(Ve=>Ve+Oe)}gt=null},St=()=>{typeof window<"u"&>==null&&(gt=requestAnimationFrame(Nt))};let Ct=Date.now();const zt=setInterval(()=>{var Oe;if(Date.now()-Ct>18e5){const Ve="Stream idle timeout";d(Ve),Y="error",P=Ve,B.abort(),(Oe=E==null?void 0:E.onError)==null||Oe.call(E,Ve)}},5e3),xt=1024*1024;try{const Oe=Ue.headers.get("X-Thread-Id")||Ue.headers.get("x-thread-id"),Ve=Ue.headers.get("X-Thread-Created")||Ue.headers.get("x-thread-created"),Te=Oe??null,Q=String(Ve??"").toLowerCase()==="true";for(N.current&&!N.current.threadId&&(N.current={...N.current,threadId:Te}),(ee=E==null?void 0:E.onOpen)==null||ee.call(E,{threadId:Te,created:Q});;){const{value:me,done:Ze}=await ut.read();if(Ze)break;it+=jt.decode(me,{stream:!0}),it.length>xt&&(it="",console.warn("Stream buffer reset: exceeded 1MB"));let xe;for(;(xe=it.indexOf(`
|
|
36
36
|
|
|
37
37
|
`))>=0;){const Be=it.slice(0,xe);it=it.slice(xe+2);const Ge=Be.split(/\r?\n/),Tt=[];for(const Xe of Ge)if(!(!Xe||Xe.startsWith(":"))&&Xe.startsWith("data:")){const ct=Xe.slice(5);Tt.push(ct.startsWith(" ")?ct.slice(1):ct)}const kt=Tt.join(`
|
|
38
|
-
`);if(!kt)continue;let At;try{At=JSON.parse(kt)}catch{console.debug("[use-chat] malformed SSE:",kt.slice(0,200));continue}const Lt=ou(At)?At.data:At;if(!Lt){console.warn("[use-chat] dropped envelope event without payload",At);continue}const je=Lt;Ct=Date.now();const dt=je.seq;if(dt!==void 0){if(dt<=yt){console.debug("[use-chat] drop duplicate/out-of-order event",{seq:dt,lastProcessedSeq:yt,type:je.type});continue}yt>0&&dt>yt+1&&((Z=E==null?void 0:E.onGap)==null||Z.call(E,{from:yt,to:dt})),yt=dt,I.current=dt,x(dt)}if(je.type==="message.start"&&je.role==="assistant"){const Xe=cu(je.model);V.current={messageId:je.id,lastSeq:dt??null,lastText:""},k({id:je.id,role:"assistant",name:Xe??void 0,model:je.model,createdAt:new Date().toISOString(),content:[]})}if(je.type==="checkpoint")R.current=je.checkpointId??null,O.current=je.checkpointNs??null,v(je.checkpointId??null);else if(je.type==="state_history"){$.current=je;try{const ct=Rn(je).latest;ct&&(R.current=ct.checkpointId??null,O.current=ct.checkpointNs??null,v(ct.checkpointId??null))}catch(Xe){console.warn("[use-chat] Failed to hydrate state_history payload",Xe)}}try{P==null||P(je)}catch(Xe){console.error("[use-chat] Error in onEvent callback:",Xe,"for event:",je.type)}if(je.type==="message.delta"){k(ct=>{const an=V.current;if(!ct||an.messageId!==ct.id)return ct;const{newParts:A,newMeta:te,changed:fe}=au(ct.content??[],je.delta,{lastSeq:an.lastSeq,lastText:an.lastText},dt??null);return fe?(V.current={...an,lastSeq:te.lastSeq??an.lastSeq,lastText:te.lastText??an.lastText},{...ct,content:A}):ct});const Xe=je.delta.filter(ct=>ct.type==="text").map(ct=>ct.text).join("");Xe&&e.autoAppendAssistant!==!1&&(_t.push(Xe),St())}else if(je.type==="heartbeat"){console.debug("[use-chat] heartbeat received");try{(z=E==null?void 0:E.onHeartbeat)==null||z.call(E,je)}catch(Xe){console.warn("[use-chat] heartbeat callback failed",Xe)}}else if(gt!==null&&cancelAnimationFrame(gt),Nt(),je.type==="checkpoint")v(je.checkpointId);else if(je.type==="error"){const Xe=je;if(d(Xe.message),Y="error",_=Xe.message,Xe.error_type==="auth_error"||Xe.code==="TOKEN_EXPIRED"||((ae=Xe.message)==null?void 0:ae.includes("token"))||((ie=Xe.message)==null?void 0:ie.includes("401"))||((ge=Xe.message)==null?void 0:ge.includes("unauthorized"))||((we=Xe.message)==null?void 0:we.includes("Unauthorized"))){console.error("[use-chat] Auth error detected:",Xe.message);try{(Ae=E==null?void 0:E.onAuthError)==null||Ae.call(E,Xe.message)}catch(an){console.warn("[use-chat] onAuthError handler failed",an)}B.abort()}}}}Nt(),Y===null&&!B.signal.aborted&&(Y="complete")}catch(Oe){if(Oe.name==="AbortError")Y=Y??"aborted";else{const Ve=Oe.message||String(Oe);Y="error",_=Ve,d(Ve),(Pe=E==null?void 0:E.onError)==null||Pe.call(E,Ve)}}finally{try{await ut.cancel()}catch{}finally{(ke=ut.releaseLock)==null||ke.call(ut)}gt!==null&&typeof window<"u"&&window.cancelAnimationFrame(gt),clearInterval(zt)}}catch(We){if(We.name==="AbortError")Y=Y??"aborted";else{const ze=We.message||String(We);Y="error",_=ze,d(ze),(st=E==null?void 0:E.onError)==null||st.call(E,ze),M||((bt=E==null?void 0:E.onConnectionError)==null||bt.call(E,ze),M=!0)}}finally{const We=I.current,ze=R.current,Ke=O.current,Fe=$.current,Ue=Y??(B.signal.aborted?"aborted":_?"error":"complete");try{(It=E==null?void 0:E.onClosed)==null||It.call(E,{reason:Ue,lastSeq:We,lastCheckpointId:ze,lastCheckpointNs:Ke,lastStateHistory:Fe,error:_})}catch(ut){console.warn("[use-chat] onClosed callback failed",ut)}l(!1),w(!1),C.current=null,I.current=0,x(0),N.current=null}})(),{close:()=>B.abort()}},[t,n,r,e.autoAppendAssistant]);return b.useEffect(()=>()=>{var D;T.current=!1,(D=C.current)==null||D.abort()},[]),{isStreaming:a,error:c,assistantText:h,assistantMessage:S,lastCheckpointId:f,lastSeq:g,connected:y,stream:K,stop:q,clear:j,setToken:U}}const Kv=["detail","message","error","description","title"];function qo(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=qo(t);if(n)return n}return null}if(typeof e=="object"){const t=e;for(const n of Kv){const r=qo(t[n]);if(r)return r}if("errors"in t){const n=qo(t.errors);if(n)return n}}return null}function qv(e){if(!e)return"Request failed";const t=e.response,n=qo(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),[h,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),I=b.useRef(new Map);b.useEffect(()=>{T.current=a},[a]);const N=b.useCallback(async()=>{d(!0),m(null);try{const P=await e.listThreads();i(P??[])}catch(P){const E=String(P);m(E),n==null||n(E)}finally{d(!1)}},[e,n]),R=b.useCallback(async()=>{x(!0),y(null);try{const P=await e.listSharedThreads();v(P??[])}catch(P){const E=String(P);y(E),n==null||n(E)}finally{x(!1)}},[e,n]);b.useEffect(()=>{N()},[N]),b.useEffect(()=>{R()},[R]),b.useEffect(()=>{r==null||r(a)},[a,r]);const O=b.useCallback(async P=>{try{const E=await e.createThread(P);return l(E.threadId),await N(),E.threadId}catch(E){const B=String(E);return n==null||n(B),null}},[e,n,N]),$=b.useCallback(async P=>{const E=s;i(Y=>Y.filter(_=>_.threadId!==P));const B=new AbortController;I.current.set(P,B);try{await e.deleteThread(P),T.current===P&&(l(null),o==null||o())}catch(Y){i(E);const _=String(Y);n==null||n(_)}finally{I.current.delete(P)}},[e,o,n,s]),V=b.useCallback(async(P,E)=>{try{await e.updateThread(P,E),await N()}catch(B){n==null||n(String(B))}},[e,n,N]),U=b.useCallback(async(P,E)=>{C(!0),S("Sharing thread…");try{await e.shareThread(P,E),await R(),S("Shared successfully")}catch(B){const Y=qv(B);throw n==null||n(Y),S(`Failed to share: ${Y}`),new Error(Y)}finally{C(!1)}},[e,n,R]),j=b.useCallback(async(P,E)=>{try{await e.unshareThread(P,E),await R()}catch(B){const Y=String(B);throw n==null||n(Y),B}},[e,n,R]),q=b.useMemo(()=>({createThread:O,deleteThread:$,renameThread:V,refreshThreads:N,refreshSharedThreads:R,shareThread:U,unshareThread:j}),[O,$,V,N,R,U,j]),K=b.useCallback(P=>{if(!(P!=null&&P.threadId))return;const E={threadId:P.threadId,title:P.title||`Thread ${P.threadId.slice(0,8)}`,createdAt:P.createdAt||new Date().toISOString(),updatedAt:P.updatedAt||new Date().toISOString(),messageCount:P.messageCount??1};i(B=>{let Y=!1;const _=B.map(M=>M.threadId===E.threadId?(Y=!0,console.debug("[useThreadsState] thread_info: updating existing thread",E.threadId),{...M,title:E.title??M.title,updatedAt:E.updatedAt??M.updatedAt,messageCount:E.messageCount??M.messageCount}):M);return Y?_:(console.debug("[useThreadsState] thread_info: adding thread to list",E.threadId),[E,...B])})},[]),D=b.useCallback(()=>S(null),[]);return{threads:s,currentThreadId:a,currentThreadIdRef:T,setCurrentThreadId:l,isLoadingThreads:c,threadsError:h,sharedThreads:f,isLoadingSharedThreads:g,actions:q,addThreadFromEvent:K,shareInFlight:k,shareStatus:w,clearShareStatus:D}}const du=b.createContext(null);function fu({children:e,initialThreadId:t=null,onError:n,onThreadChange:r}){const{api:o}=Xr(),{threads:s,currentThreadId:i,setCurrentThreadId:a,currentThreadIdRef:l,isLoadingThreads:c,threadsError:d,sharedThreads:h,isLoadingSharedThreads:m,actions:f,addThreadFromEvent:v,shareInFlight:g,shareStatus:x,clearShareStatus:y}=uu({api:o,initialThreadId:t,onError:n,onThreadChange:r}),w=b.useMemo(()=>({threads:s,currentThreadId:i,setCurrentThreadId:a,currentThreadIdRef:l,isLoading:c,error:d,sharedThreads:h,isLoadingSharedThreads:m,actions:f,shareInFlight:g,shareStatus:x,clearShareStatus:y,addThreadFromEvent:v}),[s,i,a,l,c,d,h,m,f,g,x,y,v]);return u.jsx(du.Provider,{value:w,children:e})}function gr(){const e=b.useContext(du);if(!e)throw new Error("useThreads must be used within a ThreadsProvider");return e}function Ri(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 hu(e){return!!(e&&typeof e=="object"&&(e.type==="file"||e.mimeType||e.filename||e.sourceType==="base64"))}function Zr(e){if(typeof e=="string")return e;if(e&&typeof e=="object"){if(Array.isArray(e)){const n=e.map(Zr).filter(r=>r!==void 0);if(!n.length){console.debug("[message-utils] sanitizeForDisplay - array emptied -> returning undefined",{originalLength:e.length});return}return n}if(hu(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=Zr(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 xr(e){if(typeof e=="string")return e;if(hu(e))return"";try{const t=Zr(e);return t===void 0?"":typeof t=="string"?t:JSON.stringify(t,null,2)}catch{return""}}function Gv(e){return typeof e!="string"?!1:/^[\s\n]*[-*]\s|^[\s\n]*#+\s|```|^\s*\[.*\]\(|^>\s/.test(e)}function Yv(e){const t=xr(e);return typeof e=="string"&&Gv(e)?{content:e,isMarkdown:!0}:{content:t,isMarkdown:!1}}function Qr(e){if(e==null)return e;if(typeof e=="string"){const t=e.trim();if(t.startsWith("{")||t.startsWith("[")){const n=Ri(t);if(n!==null)return Qr(n)}return e}return typeof e=="object"&&!Array.isArray(e)&&e.content!==void 0?Qr(e.content):e}function Xv(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function Mi(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 Go(e){if(e==null)return null;const t=String(e).trim();return t.length>0?t:null}function Jv(e){const t=r=>{try{const o=Zr(r);return typeof o=="string"?o:JSON.stringify(o??"")}catch{return""}},n=e.filter(r=>r.type==="text");return n.length?t(n.map(r=>r.text).join(`
|
|
39
|
-
`)):t(e)}function Zv(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function pu(e){if(e.role==="default_message")return`default:${e.content.length}`;const t=e.updatedAt??e.createdAt??"",n=Array.isArray(e.content)?e.content.map(i=>{switch(i.type){case"text":return`t:${i.text.length}`;case"image_url":return"img";case"file":return"file";case"tool_call":return"call";case"interrupt":return"interrupt";default:return"unknown"}}).join("|"):"",r="checkpointId"in e&&e.checkpointId?`cp:${e.checkpointId}`:"",o="checkpointNs"in e&&e.checkpointNs?`ns:${e.checkpointNs}`:"",s=[r,o].filter(Boolean).join("|");return`${e.id}:${t}:${n}${s?`:${s}`:""}`}function Qv(e){if(!e)return"image/png";const t=e.trim();return t?t.includes("/")?t:`image/${t}`:"image/png"}function eb(e){const t=[],n=r=>{r&&r.trim()&&t.push(r.trim())};return e&&(n(e.plotId),n(e.artifactId)),t}function tb({base64:e,url:t,formatHint:n,extras:r}){const o=typeof e=="string"&&e.length>0,s=Qv(n),i=o?`data:${s};base64,${e}`:t,a=eb(r),l=a.length?a.join(" / "):void 0,c=l?`${l} artifact`:"artifact image";return{src:i,alt:c,label:l}}function nb(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 tb({base64:t,url:n,formatHint:r,extras:{plotId:e.plotId,artifactId:e.artifactId}})}function mu(e){var n;const t=(n=e.additionalKwargs)==null?void 0:n.toolProgress;return Array.isArray(t)?t:[]}const rb={messages:[],assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,messagesStreamMeta:{},pendingInterrupt:null};function ob(e,t){var n;switch(t.type){case"reset":return{messages:Pi(((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=Pi(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=Pi(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 sb(e=[]){const[t,n]=b.useReducer(ob,{...rb,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,h)=>n({type:"seed",payload:{messages:d,...h??{}}}),prepend:d=>n({type:"prepend",payload:{messages:d}}),pushUser:(d,h)=>n({type:"user_message",payload:{message:d,editingMessageId:h}}),onEvent:l}),[l]);return{state:t,dispatch:n,...c}}function gu(e,t){var n,r,o;if(t.type==="message.start"&&t.role==="assistant"){const s=t.id,i=cu(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 ab(e,t);if(t.type==="tool.progress")return lb(e,t);if(t.type==="tool.end")return cb(e,t);if(t.type==="message.delta"){const s=e.assemblingId??su(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??{},h=d[s],m=h??{lastSeq:null,lastText:iu(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}=au(l.content,t.delta,m,f);if(!x)return e;const y={...l,content:v},w=Jr(i,a,y),S=!h||h.lastSeq!==g.lastSeq||h.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??su(e.messages);if(!s)return{...e,assemblingId:null};const i=e.messages,a=i.findIndex(l=>l.id===s&&l.role==="assistant");if(a>=0){const l=i[a];if(!((n=l.content)==null?void 0:n.some(d=>{var h;return(d==null?void 0:d.type)==="text"&&((h=d.text)==null?void 0:h.trim())}))){console.debug("[MessageReducer] pruning assistant message with no visible text",{id:l.id,contentTypes:(r=l.content)==null?void 0:r.map(h=>h==null?void 0:h.type),contentPreview:(o=l.content)==null?void 0:o.map(h=>(h==null?void 0:h.type)==="text"?String(h.text).slice(0,100):h==null?void 0:h.type)});const d=[...i.slice(0,a),...i.slice(a+1)];return{...e,assemblingId:null,messages:d}}}return e}if(t.type==="checkpoint"){const s=t.checkpointNs??e.lastCheckpointNs??null,i=Wv(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=Rn(t),i=s.interrupt,a=s.latest,l=i===null?Hv(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 Oi(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 Di(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||Mi(r).toolCallId===t)return n}return-1}function ib(e){if(e==null)return[];const t=Qr(e);if(typeof t=="string"&&t.trim())return[{type:"text",text:t}];const n=xr(t??e);return n?[{type:"text",text:n}]:[]}function bu(e,t){const n=e.additionalKwargs??{},r=Array.isArray(n.toolProgress)?[...n.toolProgress]:[],o={...n,toolProgress:[...r,t]};return{...e,additionalKwargs:o}}function ab(e,t){const n=Oi(t),r=Di(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:Jr(e.messages,r,d)}}const i=vu(s,n,o,t.args);return{...e,messages:[...e.messages,i]}}function lb(e,t){const n=Oi(t);if(!n)return e;const r=Di(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=bu(e.messages[r],o);return{...e,messages:Jr(e.messages,r,a)}}function cb(e,t){const n=Oi(t),r=xu(t);let o=e.messages,s=Di(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=ib(a),c=[...i.content,...l],d={type:t.type,content:typeof t.output=="string"?t.output:void 0,seq:t.seq??null,timestamp:new Date().toISOString()};t.artifact&&(d.artifact=t.artifact);const h=bu(i,d),m=t.artifact??i.artifact,f={...h,name:t.name??t.tool??i.name,content:c,artifact:m,additionalKwargs:{...h.additionalKwargs??{},toolStreaming:!1}};return{...e,messages:Jr(o,s,f)}}function wu({api:e,seed:t,prepend:n,onError:r,currentThreadId:o,initialThreadId:s=null,initialCheckpointId:i=null,initialCheckpointNs:a=null,autoLoadInitial:l=!0,isStreaming:c,getMessages:d}){const[h,m]=b.useState(null),v=b.useMemo(()=>Rn(h),[h]).checkpoints,g=tc(v),x=g.timeline,[y,w]=b.useState(!1),[S,k]=b.useState(null),[C,T]=b.useState(!1),[I,N]=b.useState(!1),[R,O]=b.useState(!1),[$,V]=b.useState(null),U=b.useRef(o),j=b.useRef(null),q=b.useRef(null),K=b.useRef(null),D=b.useRef(null),P=b.useRef(null),E=b.useRef(new Map);b.useEffect(()=>{U.current=o},[o]);const B=b.useCallback(async Z=>{var ae,ie;if(!Z.threadId)return;const z=Z.threadId;(ae=Z.onStart)==null||ae.call(Z),Z.setLoading(!0);try{await Z.action(z)}catch(ge){if(U.current===z){const we=String(ge);(ie=Z.handleError)==null||ie.call(Z,we),r==null||r(we)}throw ge}finally{Z.setLoading(!1)}},[r]),Y=b.useCallback(async(Z,z)=>{if(!Z)return;const ae=`${Z}:${z??"latest"}`,ie=E.current.get(ae);if(ie)return ie;const ge=B({threadId:Z,setLoading:T,onStart:()=>V(null),handleError:we=>V(we),action:async we=>{const Ae=await e.getStateHistory({threadId:we,checkpointId:z??void 0});if(U.current!==we){console.log(`[useThreadHistoryState] Thread changed during load (was ${we}, now ${U.current}), discarding stale data`);return}const{checkpoints:Pe}=Rn(Ae),ke=Pe.find(st=>st.messages&&st.messages.length>0)??(z?Pe.find(st=>st.checkpointId===z):null)??Pe[0];t((ke==null?void 0:ke.messages)??[],{checkpointId:(ke==null?void 0:ke.checkpointId)??null,checkpointNs:(ke==null?void 0:ke.checkpointNs)??null}),m(Ae),w(!!(ke!=null&&ke.nextCursor)),k((ke==null?void 0:ke.nextCursor)??null)}});E.current.set(ae,ge);try{await ge}finally{E.current.delete(ae)}return U.current===Z&&(P.current=ae),ge},[e,t,B]),_=b.useCallback(async(Z,z)=>{D.current=Z;try{await Y(Z,z)}finally{D.current===Z&&(D.current=null)}},[Y]),M=b.useCallback(Z=>{q.current=Z},[]),G=b.useCallback(Z=>{K.current=Z},[]),J=b.useCallback(Z=>{const z=Z.threadId??U.current;if(!z||U.current&&U.current!==z)return;const{checkpoints:ae}=Rn(Z);if(!ae.length)return;const ie=ae.find(we=>we.messages&&we.messages.length>0)??ae.find(we=>!!we.checkpointId)??ae[0],ge=K.current===z;!c&&!ge&&t((ie==null?void 0:ie.messages)??[],{checkpointId:(ie==null?void 0:ie.checkpointId)??null,checkpointNs:(ie==null?void 0:ie.checkpointNs)??null}),m(Z),w(!!(ie!=null&&ie.nextCursor)),k((ie==null?void 0:ie.nextCursor)??null),P.current=`${z}:latest`,q.current=null,K.current===z&&(K.current=null)},[t,c]),se=b.useCallback(async(Z,z)=>{const ae=U.current;await B({threadId:ae,setLoading:O,action:async ie=>{const ge=await e.getStateHistory({threadId:ie,checkpointId:Z,checkpointNs:z??void 0});if(U.current!==ie){console.log(`[useThreadHistoryState] Thread changed during checkpoint navigation (was ${ie}, now ${U.current}), discarding stale data`);return}const{checkpoints:we}=Rn(ge),Ae=we.find(Pe=>Pe.checkpointId===Z&&(z?Pe.checkpointNs===z:!0));if(!Ae){console.warn("[useThreadHistoryState] Requested checkpoint not found:",{checkpointId:Z,checkpointNs:z});return}m(ge),t(Ae.messages??[],{checkpointId:Ae.checkpointId??null,checkpointNs:Ae.checkpointNs??null})}}).catch(()=>{})},[e,t,B]),W=b.useCallback((Z,z)=>{t(d(),{checkpointId:Z??null,checkpointNs:z??null})},[d,t]),L=b.useCallback(async()=>{U.current&&await _(U.current)},[_]),X=b.useCallback(async()=>{const Z=U.current;!Z||!S||await B({threadId:Z,setLoading:N,action:async z=>{const ae=await e.getStateHistory({threadId:z,checkpointId:S});if(U.current!==z)return;const{checkpoints:ie}=Rn(ae);if(ie.length>0){const ge=ie[ie.length-1];n((ge==null?void 0:ge.messages)??[]),w(!!(ge!=null&&ge.nextCursor)),k((ge==null?void 0:ge.nextCursor)??null)}}}).catch(()=>{})},[e,S,r,n,B]);b.useEffect(()=>{if(!l||!o||C||c)return;if(q.current===o){q.current=null,j.current=o;return}if(K.current===o){j.current=o;return}if(D.current===o){D.current=null,j.current=o;return}if(j.current===o)return;j.current=o;let Z;console.log("[useThreadHistoryState] Loading thread with latest checkpoint");const z=`${o}:latest`;P.current!==z&&_(o,Z)},[l,o,i,a,s,C,c,_]);const ee=b.useCallback(()=>{m(null),w(!1),k(null),T(!1),N(!1),O(!1),V(null),q.current=null,K.current=null,j.current=null,P.current=null,D.current=null},[]);return{threadCheckpoints:v,threadTimeline:x,checkpointIndex:g,isLoadingThread:C,isHistoryLoading:I,isLoadingCheckpoint:R,threadStateError:$,hasMoreHistory:y,loadThread:_,navigateToCheckpoint:se,loadOlderMessages:X,setCurrentCheckpointId:W,returnToLatest:L,handleStateHistoryEvent:J,markSkipNextLoad:M,markStreamPendingThread:G,resetHistoryState:ee}}const yu=b.createContext(null),Su=b.createContext(null);function eo(){const e=b.useContext(yu);if(!e)throw new Error("useThreadState must be used within a ThreadStateProvider");return e}function Cu(){const e=b.useContext(Su);if(!e)throw new Error("useThreadStateUpdater must be used within a ThreadStateProvider");return e}function Tu({children:e,initialThreadId:t=null,initialCheckpointId:n=null,initialCheckpointNs:r=null,autoLoadInitial:o=!0,isStreaming:s,onError:i}){const{api:a}=Xr(),{currentThreadId:l}=gr(),{state:c,seed:d,prepend:h,pushUser:m,onEvent:f}=sb(),{threadCheckpoints:v,threadTimeline:g,checkpointIndex:x,isLoadingThread:y,isHistoryLoading:w,isLoadingCheckpoint:S,threadStateError:k,hasMoreHistory:C,loadThread:T,navigateToCheckpoint:I,loadOlderMessages:N,setCurrentCheckpointId:R,returnToLatest:O,handleStateHistoryEvent:$,markSkipNextLoad:V,markStreamPendingThread:U,resetHistoryState:j}=wu({api:a,seed:d,prepend:h,onError:i,currentThreadId:l,initialThreadId:t,initialCheckpointId:n,initialCheckpointNs:r,autoLoadInitial:o,isStreaming:s,getMessages:b.useCallback(()=>c.messages,[c.messages])}),[q,K]=b.useState(()=>async()=>{throw new Error("clearThread is not ready")}),[D,P]=b.useState(()=>async()=>{throw new Error("respondToInterrupt is not ready")});b.useEffect(()=>{l||(d([],{}),j())},[l,d,j]);const E=b.useCallback(G=>K(()=>G),[]),B=b.useCallback(G=>P(()=>G),[]),Y=b.useMemo(()=>({assemblingMessageId:c.assemblingId??null}),[c.assemblingId]),_=b.useMemo(()=>({threadId:l,messages:c.messages,interrupt:c.pendingInterrupt,checkpoint:{id:c.lastCheckpointId??null,namespace:c.lastCheckpointNs??null},checkpoints:v,checkpointIndex:x,timelineCheckpoints:g,metadata:Y,isLoading:y,isHistoryLoading:w,isLoadingCheckpoint:S,error:k,hasMore:C,loadOlder:N,clearState:q,navigateToCheckpoint:I,setCurrentCheckpointId:R,returnToLatest:O,loadThread:T,clearThread:q,respondToInterrupt:D,messagePreviews:x.messagePreviews,handleStateHistoryEvent:$,markSkipNextLoad:V,markStreamPendingThread:U,resetHistoryState:j,pushUser:m,onEvent:f}),[l,c,v,g,x,Y,y,w,S,k,C,N,q,I,R,O,T,D,x.messagePreviews,$,V,U,j,m,f]),M=b.useMemo(()=>({registerClearThread:E,registerRespondToInterrupt:B}),[E,B]);return u.jsx(Su.Provider,{value:M,children:u.jsx(yu.Provider,{value:_,children:e})})}function ku(e,t){if(!e)return null;const n=_n(e);if(!n)return null;const r=_n(n.configurable)??n;return Pn(r,t)??null}function ub(e){const t=ku(e,["checkpoint_id","checkpointId"]);if(!t)return null;const n=ku(e,["checkpoint_ns","checkpointNs"]);return{checkpointId:t,checkpointNs:n}}function db(e,t){const n=typeof e.step=="number"?e.step:Number.POSITIVE_INFINITY,r=typeof t.step=="number"?t.step:Number.POSITIVE_INFINITY;if(n!==r)return n-r;const o=e.createdAt?Date.parse(e.createdAt):0,s=t.createdAt?Date.parse(t.createdAt):0;return o-s}function fb(e,t){const n=[...e].sort(db);for(const r of n){if(r.messageId!==t)continue;const o=ub(r.parentConfig);if(!o)throw new Error(`Parent checkpoint info missing for message ${t}`);return o}throw new Error(`Message ${t} not found in timeline`)}const Eu=b.createContext(null),Iu=b.createContext(!1);function hb({children:e,initialThreadId:t=null,initialCheckpointId:n=null,initialCheckpointNs:r=null,autoLoadInitial:o=!0,onError:s,onAuthError:i,onThreadChange:a,onConnectionError:l,onToolEnd:c}){const{api:d,baseUrl:h}=Xr(),m=b.useMemo(()=>vn(h),[h]),{stream:f,stop:v,isStreaming:g,error:x,setToken:y}=Vv({baseUrl:m}),[w,S]=b.useState(!1);return b.useEffect(()=>{S(g)},[g]),u.jsx(fu,{initialThreadId:t,onError:s,onThreadChange:a,children:u.jsx(Tu,{initialThreadId:t,initialCheckpointId:n,initialCheckpointNs:r,autoLoadInitial:o,onError:s,isStreaming:w,children:u.jsx(Iu.Provider,{value:!0,children:u.jsx(pb,{api:d,streamApi:{stream:f,stop:v,isStreaming:g,error:x,setToken:y},onError:s,onAuthError:i,onConnectionError:l,onToolEnd:c,children:e})})})})}function pb({children:e,api:t,streamApi:n,onError:r,onAuthError:o,onConnectionError:s,onToolEnd:i}){const{stream:a,stop:l,isStreaming:c,error:d,setToken:h}=n,{setCurrentThreadId:m,currentThreadIdRef:f,addThreadFromEvent:v}=gr(),{checkpoint:g,timelineCheckpoints:x,handleStateHistoryEvent:y,markSkipNextLoad:w,markStreamPendingThread:S,resetHistoryState:k,pushUser:C,onEvent:T}=eo(),{registerClearThread:I,registerRespondToInterrupt:N}=Cu(),R=b.useCallback(D=>{v(D),f.current!==D.threadId&&((D.created??!f.current)&&w(D.threadId),S(D.threadId),m(D.threadId))},[v,w,S,m,f]),O=b.useCallback(D=>{D.type==="thread_info"?R(D):D.type==="state_history"?y(D):D.type==="tool.end"?i==null||i(D):T(D)},[R,y,T,i]),$=b.useCallback(D=>{a(D,O,{onError:P=>{console.error("[StreamingProvider] Stream error:",P),r==null||r(P)},onAuthError:P=>{console.error("[StreamingProvider] Auth error:",P),o==null||o(P)},onConnectionError:P=>{console.error("[StreamingProvider] Connection error:",P),s==null||s(P)}})},[a,O,r,o,s]),V=b.useRef(g);b.useEffect(()=>{V.current=g},[g]);const U=b.useCallback(async(D,P,E)=>{const B=f.current;if(!B)throw new Error("No active thread to handle interrupt");const Y=P?E??!0:!1,_=V.current,M={threadId:B,checkpointId:_.id??void 0,checkpointNs:_.namespace??void 0,command:{kind:"resume",value:Y}};$(M)},[f,$]);b.useEffect(()=>{N(U)},[U,N]);const j=b.useCallback(async()=>{l(),k(),m(null);try{await t.getAgent("default")}catch(D){console.warn("[StreamingProvider] Failed to refetch agent after clearing thread:",D)}},[t,k,m,l]);b.useEffect(()=>{I(j)},[j,I]);const q=b.useCallback(async(D,P)=>{let E=f.current;const B=(D==null?void 0:D.text)??"",Y=(D==null?void 0:D.attachments)??[],_=(B==null?void 0:B.trim())??"",M={...(D==null?void 0:D.payload)??{}},G=Array.isArray(M.messages)?M.messages:void 0;G&&delete M.messages;const J=!!(G&&G.length);if(!E&&!_&&Y.length===0&&!J)return;if(!E){const Pe=Math.floor(Date.now()/1e3).toString(16).padStart(8,"0"),ke=Array.from({length:4},()=>Math.floor(Math.random()*4294967295).toString(16).padStart(8,"0")).join("").slice(0,16);E=`${Pe}${ke}`,w(E),m(E)}const{contentParts:se,filesInfo:W}=await ru(Y),L=[...se];_&&L.push({type:"text",text:B});const X=P==null?void 0:P.originalMessageId,ee=!!(P!=null&&P.edit&&X),Z=!J&&L.length>0;let z=null;Z&&(z={id:ee?X:`msg-${Date.now()}`,role:"user",content:L,createdAt:new Date().toISOString()},ee?C(z,X):C(z));const ae=J?G:z?[z]:[],ie={...M,...W.length?{files_info:W}:{}};ae.length?ie.messages=ae:"messages"in ie||(ie.messages=[]);let ge=(P==null?void 0:P.checkpointId)??g.id??void 0,we=(P==null?void 0:P.checkpointNs)??g.namespace??void 0;if(ee&&X){const Pe=fb(x,X);ge=Pe.checkpointId,we=Pe.checkpointNs??void 0}const Ae={threadId:E,payload:ie,checkpointId:ge,checkpointNs:we,edit:!!(P!=null&&P.edit)};$(Ae)},[g,f,w,C,$,x]),K=b.useMemo(()=>({isStreaming:c,error:d,connectionState:c?"connected":"idle",submit:q,send:q,stop:l,setAuthToken:h}),[c,d,q,l,h]);return u.jsx(Eu.Provider,{value:K,children:e})}function Li(){const e=b.useContext(Eu);if(!e)throw new Error("useStream must be used within StreamingProvider");return e}function mb(){return b.useContext(Iu)}function Nu(e){return typeof e=="object"&&e!==null}function gb(e,t){if(Object.is(e,t))return!0;if(!Nu(e)||!Nu(t))return!1;const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const o of n)if(!Object.prototype.hasOwnProperty.call(t,o)||!Object.is(e[o],t[o]))return!1;return!0}function Au(e){const t=b.useRef(e),n=b.useRef(e);return gb(t.current,e)||(t.current=e,n.current=e),n.current}function vr({children:e,apiConfig:t,initialThreadId:n=null,initialCheckpointId:r=null,initialCheckpointNs:o=null,autoLoadInitial:s=!0,onConnectionError:i,onError:a,onAuthError:l,onThreadChange:c,onToolEnd:d}){const h=Au(t),m=to(a),f=to(l),v=to(i),g=to(c),x=to(d),y=b.useMemo(()=>({initialThreadId:n,initialCheckpointId:r,initialCheckpointNs:o,autoLoadInitial:s,onError:m,onAuthError:f,onConnectionError:v,onThreadChange:g,onToolEnd:x}),[n,r,o,s,m,f,v,g,x]);return u.jsx(tu,{apiConfig:h,children:u.jsx(hb,{...y,children:e})})}function to(e){const t=b.useRef(e);return b.useEffect(()=>{t.current=e},[e]),b.useCallback((...n)=>{const r=t.current;if(r)return r(...n)},[])}function br(e){if(!(typeof globalThis>"u"))return globalThis[e]}function xb(e){if(typeof e!="string")return;const t=e.trim();if(t)return vn(t)}function ju(){const e=[br("__API_BASE_URL__"),br("__CHAT_API_BASE_URL__"),br("__CHAT_API_URL__")];for(const t of e){const n=xb(t);if(n)return n}}function _u(){const e=[br("__API_AUTH_TOKEN__"),br("__CHAT_API_KEY__"),br("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function Pu(...e){for(const t of e)if(typeof t=="string"&&t.trim())return vn(t);return vn()}function Ru(){const e={},t=ju(),n=_u();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function Mu(){const e=Ru(),t=Mn.getAuthToken(),n=ju();return{apiBaseUrl:Pu(e.baseUrl,Mn.baseUrl,n),apiKey:t||e.apiKey||_u()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,darkMode:!1,enableSound:!1,messageHistory:100}}const $i="chat-settings";function Ou(){try{const e=localStorage.getItem($i);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function Du(e){try{const t={...e,apiBaseUrl:vn(e.apiBaseUrl)};localStorage.setItem($i,JSON.stringify(t)),t.apiKey&&Mn.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function vb(){const e=Mu(),t=Ou(),n=Mn.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:Pu(Mn.baseUrl,r,e.apiBaseUrl)}}function bb(e){Mn.updateConfig({baseUrl:e.apiBaseUrl,authToken:e.apiKey??void 0}),Du(e)}function re(...e){return nx.twMerge(tx.clsx(e))}const wb=zr.cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),Qe=p.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?Yt.Slot:"button";return u.jsx(i,{className:re(wb({variant:t,size:n,className:e})),ref:s,...o})});Qe.displayName="Button";function ce(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 Lu(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function On(...e){return t=>{let n=!1;const r=e.map(o=>{const s=Lu(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():Lu(e[o],null)}}}}function Le(...e){return p.useCallback(On(...e),e)}function yb(e,t){const n=p.createContext(t),r=s=>{const{children:i,...a}=s,l=p.useMemo(()=>a,Object.values(a));return u.jsx(n.Provider,{value:l,children:i})};r.displayName=e+"Provider";function o(s){const i=p.useContext(n);if(i)return i;if(t!==void 0)return t;throw new Error(`\`${s}\` must be used within \`${e}\``)}return[r,o]}function cn(e,t=[]){let n=[];function r(s,i){const a=p.createContext(i),l=n.length;n=[...n,i];const c=h=>{var y;const{scope:m,children:f,...v}=h,g=((y=m==null?void 0:m[e])==null?void 0:y[l])||a,x=p.useMemo(()=>v,Object.values(v));return u.jsx(g.Provider,{value:x,children:f})};c.displayName=s+"Provider";function d(h,m){var g;const f=((g=m==null?void 0:m[e])==null?void 0:g[l])||a,v=p.useContext(f);if(v)return v;if(i!==void 0)return i;throw new Error(`\`${h}\` must be used within \`${s}\``)}return[c,d]}const o=()=>{const s=n.map(i=>p.createContext(i));return function(a){const l=(a==null?void 0:a[e])||s;return p.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return o.scopeName=e,[r,Sb(o,...t)]}function Sb(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(s){const i=r.reduce((a,{useScope:l,scopeName:c})=>{const h=l(s)[`__scope${c}`];return{...a,...h}},{});return p.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var Et=globalThis!=null&&globalThis.document?p.useLayoutEffect:()=>{},Cb=p[" useInsertionEffect ".trim().toString()]||Et;function Dn({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=Tb({defaultProp:t,onChange:n}),a=e!==void 0,l=a?e:o;{const d=p.useRef(e!==void 0);p.useEffect(()=>{const h=d.current;h!==a&&console.warn(`${r} is changing from ${h?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),d.current=a},[a,r])}const c=p.useCallback(d=>{var h;if(a){const m=kb(d)?d(e):d;m!==e&&((h=i.current)==null||h.call(i,m))}else s(d)},[a,e,s,i]);return[l,c]}function Tb({defaultProp:e,onChange:t}){const[n,r]=p.useState(e),o=p.useRef(n),s=p.useRef(t);return Cb(()=>{s.current=t},[t]),p.useEffect(()=>{var i;o.current!==n&&((i=s.current)==null||i.call(s,n),o.current=n)},[n,o]),[n,r,s]}function kb(e){return typeof e=="function"}var Eb=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],ve=Eb.reduce((e,t)=>{const n=Yt.createSlot(`Primitive.${t}`),r=p.forwardRef((o,s)=>{const{asChild:i,...a}=o,l=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),u.jsx(l,{...a,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Fi(e,t){e&&Hr.flushSync(()=>e.dispatchEvent(t))}function Yo(e){const t=e+"CollectionProvider",[n,r]=cn(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=g=>{const{scope:x,children:y}=g,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=Yt.createSlot(a),c=b.forwardRef((g,x)=>{const{scope:y,children:w}=g,S=s(a,y),k=Le(x,S.collectionRef);return u.jsx(l,{ref:k,children:w})});c.displayName=a;const d=e+"CollectionItemSlot",h="data-radix-collection-item",m=Yt.createSlot(d),f=b.forwardRef((g,x)=>{const{scope:y,children:w,...S}=g,k=b.useRef(null),C=Le(x,k),T=s(d,y);return b.useEffect(()=>(T.itemMap.set(k,{ref:k,...S}),()=>void T.itemMap.delete(k))),u.jsx(m,{[h]:"",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(`[${h}]`));return Array.from(x.itemMap.values()).sort((T,I)=>S.indexOf(T.ref.current)-S.indexOf(I.ref.current))},[x.collectionRef,x.itemMap])}return[{Provider:i,Slot:c,ItemSlot:f},v,r]}var Ib=p.createContext(void 0);function Xo(e){const t=p.useContext(Ib);return e||t||"ltr"}function pt(e){const t=p.useRef(e);return p.useEffect(()=>{t.current=e}),p.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function Nb(e,t=globalThis==null?void 0:globalThis.document){const n=pt(e);p.useEffect(()=>{const r=o=>{o.key==="Escape"&&n(o)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var Ab="DismissableLayer",Bi="dismissableLayer.update",jb="dismissableLayer.pointerDownOutside",_b="dismissableLayer.focusOutside",$u,Fu=p.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),wr=p.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...l}=e,c=p.useContext(Fu),[d,h]=p.useState(null),m=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,f]=p.useState({}),v=Le(t,I=>h(I)),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=Rb(I=>{const N=I.target,R=[...c.branches].some(O=>O.contains(N));!k||R||(o==null||o(I),i==null||i(I),I.defaultPrevented||a==null||a())},m),T=Mb(I=>{const N=I.target;[...c.branches].some(O=>O.contains(N))||(s==null||s(I),i==null||i(I),I.defaultPrevented||a==null||a())},m);return Nb(I=>{w===c.layers.size-1&&(r==null||r(I),!I.defaultPrevented&&a&&(I.preventDefault(),a()))},m),p.useEffect(()=>{if(d)return n&&(c.layersWithOutsidePointerEventsDisabled.size===0&&($u=m.body.style.pointerEvents,m.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(d)),c.layers.add(d),zu(),()=>{n&&c.layersWithOutsidePointerEventsDisabled.size===1&&(m.body.style.pointerEvents=$u)}},[d,m,n,c]),p.useEffect(()=>()=>{d&&(c.layers.delete(d),c.layersWithOutsidePointerEventsDisabled.delete(d),zu())},[d,c]),p.useEffect(()=>{const I=()=>f({});return document.addEventListener(Bi,I),()=>document.removeEventListener(Bi,I)},[]),u.jsx(ve.div,{...l,ref:v,style:{pointerEvents:S?k?"auto":"none":void 0,...e.style},onFocusCapture:ce(e.onFocusCapture,T.onFocusCapture),onBlurCapture:ce(e.onBlurCapture,T.onBlurCapture),onPointerDownCapture:ce(e.onPointerDownCapture,C.onPointerDownCapture)})});wr.displayName=Ab;var Pb="DismissableLayerBranch",Bu=p.forwardRef((e,t)=>{const n=p.useContext(Fu),r=p.useRef(null),o=Le(t,r);return p.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),u.jsx(ve.div,{...e,ref:o})});Bu.displayName=Pb;function Rb(e,t=globalThis==null?void 0:globalThis.document){const n=pt(e),r=p.useRef(!1),o=p.useRef(()=>{});return p.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){Hu(jb,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 Mb(e,t=globalThis==null?void 0:globalThis.document){const n=pt(e),r=p.useRef(!1);return p.useEffect(()=>{const o=s=>{s.target&&!r.current&&Hu(_b,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 zu(){const e=new CustomEvent(Bi);document.dispatchEvent(e)}function Hu(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?Fi(o,s):o.dispatchEvent(s)}var Ob=wr,Db=Bu,zi=0;function Hi(){p.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Uu()),document.body.insertAdjacentElement("beforeend",e[1]??Uu()),zi++,()=>{zi===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),zi--}},[])}function Uu(){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 Ui="focusScope.autoFocusOnMount",Wi="focusScope.autoFocusOnUnmount",Wu={bubbles:!1,cancelable:!0},Lb="FocusScope",Jo=p.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,l]=p.useState(null),c=pt(o),d=pt(s),h=p.useRef(null),m=Le(t,g=>l(g)),f=p.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;p.useEffect(()=>{if(r){let g=function(S){if(f.paused||!a)return;const k=S.target;a.contains(k)?h.current=k:Ln(h.current,{select:!0})},x=function(S){if(f.paused||!a)return;const k=S.relatedTarget;k!==null&&(a.contains(k)||Ln(h.current,{select:!0}))},y=function(S){if(document.activeElement===document.body)for(const C of S)C.removedNodes.length>0&&Ln(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]),p.useEffect(()=>{if(a){qu.add(f);const g=document.activeElement;if(!a.contains(g)){const y=new CustomEvent(Ui,Wu);a.addEventListener(Ui,c),a.dispatchEvent(y),y.defaultPrevented||($b(Ub(Vu(a)),{select:!0}),document.activeElement===g&&Ln(a))}return()=>{a.removeEventListener(Ui,c),setTimeout(()=>{const y=new CustomEvent(Wi,Wu);a.addEventListener(Wi,d),a.dispatchEvent(y),y.defaultPrevented||Ln(g??document.body,{select:!0}),a.removeEventListener(Wi,d),qu.remove(f)},0)}}},[a,c,d,f]);const v=p.useCallback(g=>{if(!n&&!r||f.paused)return;const x=g.key==="Tab"&&!g.altKey&&!g.ctrlKey&&!g.metaKey,y=document.activeElement;if(x&&y){const w=g.currentTarget,[S,k]=Fb(w);S&&k?!g.shiftKey&&y===k?(g.preventDefault(),n&&Ln(S,{select:!0})):g.shiftKey&&y===S&&(g.preventDefault(),n&&Ln(k,{select:!0})):y===w&&g.preventDefault()}},[n,r,f.paused]);return u.jsx(ve.div,{tabIndex:-1,...i,ref:m,onKeyDown:v})});Jo.displayName=Lb;function $b(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Ln(r,{select:t}),document.activeElement!==n)return}function Fb(e){const t=Vu(e),n=Ku(t,e),r=Ku(t.reverse(),e);return[n,r]}function Vu(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 Ku(e,t){for(const n of e)if(!Bb(n,{upTo:t}))return n}function Bb(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 zb(e){return e instanceof HTMLInputElement&&"select"in e}function Ln(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&zb(e)&&t&&e.select()}}var qu=Hb();function Hb(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=Gu(e,t),e.unshift(t)},remove(t){var n;e=Gu(e,t),(n=e[0])==null||n.resume()}}}function Gu(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Ub(e){return e.filter(t=>t.tagName!=="A")}var Wb=p[" useId ".trim().toString()]||(()=>{}),Vb=0;function Rt(e){const[t,n]=p.useState(Wb());return Et(()=>{n(r=>r??String(Vb++))},[e]),t?`radix-${t}`:""}const Kb=["top","right","bottom","left"],$n=Math.min,Zt=Math.max,Zo=Math.round,Qo=Math.floor,bn=e=>({x:e,y:e}),qb={left:"right",right:"left",bottom:"top",top:"bottom"},Gb={start:"end",end:"start"};function Vi(e,t,n){return Zt(e,$n(t,n))}function Nn(e,t){return typeof e=="function"?e(t):e}function An(e){return e.split("-")[0]}function yr(e){return e.split("-")[1]}function Ki(e){return e==="x"?"y":"x"}function qi(e){return e==="y"?"height":"width"}const Yb=new Set(["top","bottom"]);function wn(e){return Yb.has(An(e))?"y":"x"}function Gi(e){return Ki(wn(e))}function Xb(e,t,n){n===void 0&&(n=!1);const r=yr(e),o=Gi(e),s=qi(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=es(i)),[i,es(i)]}function Jb(e){const t=es(e);return[Yi(e),t,Yi(t)]}function Yi(e){return e.replace(/start|end/g,t=>Gb[t])}const Yu=["left","right"],Xu=["right","left"],Zb=["top","bottom"],Qb=["bottom","top"];function ew(e,t,n){switch(e){case"top":case"bottom":return n?t?Xu:Yu:t?Yu:Xu;case"left":case"right":return t?Zb:Qb;default:return[]}}function tw(e,t,n,r){const o=yr(e);let s=ew(An(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(Yi)))),s}function es(e){return e.replace(/left|right|bottom|top/g,t=>qb[t])}function nw(e){return{top:0,right:0,bottom:0,left:0,...e}}function Ju(e){return typeof e!="number"?nw(e):{top:e,right:e,bottom:e,left:e}}function ts(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 Zu(e,t,n){let{reference:r,floating:o}=e;const s=wn(t),i=Gi(t),a=qi(i),l=An(t),c=s==="y",d=r.x+r.width/2-o.width/2,h=r.y+r.height/2-o.height/2,m=r[a]/2-o[a]/2;let f;switch(l){case"top":f={x:d,y:r.y-o.height};break;case"bottom":f={x:d,y:r.y+r.height};break;case"right":f={x:r.x+r.width,y:h};break;case"left":f={x:r.x-o.width,y:h};break;default:f={x:r.x,y:r.y}}switch(yr(t)){case"start":f[i]-=m*(n&&c?-1:1);break;case"end":f[i]+=m*(n&&c?-1:1);break}return f}const rw=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=n,a=s.filter(Boolean),l=await(i.isRTL==null?void 0:i.isRTL(t));let c=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:d,y:h}=Zu(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:h,initialPlacement:r,placement:m,strategy:o,middlewareData:f,rects:c,platform:i,elements:{reference:e,floating:t}});d=w??d,h=S??h,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:h}=Zu(c,m,l)),g=-1)}return{x:d,y:h,placement:m,strategy:o,middlewareData:f}};async function no(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:i,elements:a,strategy:l}=e,{boundary:c="clippingAncestors",rootBoundary:d="viewport",elementContext:h="floating",altBoundary:m=!1,padding:f=0}=Nn(t,e),v=Ju(f),x=a[m?h==="floating"?"reference":"floating":h],y=ts(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=h==="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=ts(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 ow=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}=Nn(e,t)||{};if(c==null)return{};const h=Ju(d),m={x:n,y:r},f=Gi(o),v=qi(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 I=T?T[S]:0;(!I||!await(i.isElement==null?void 0:i.isElement(T)))&&(I=a.floating[S]||s.floating[v]);const N=k/2-C/2,R=I/2-g[v]/2-1,O=$n(h[y],R),$=$n(h[w],R),V=O,U=I-g[v]-$,j=I/2-g[v]/2+N,q=Vi(V,j,U),K=!l.arrow&&yr(o)!=null&&j!==q&&s.reference[v]/2-(j<V?O:$)-g[v]/2<0,D=K?j<V?j-V:j-U:0;return{[f]:m[f]+D,data:{[f]:q,centerOffset:j-q-D,...K&&{alignmentOffset:D}},reset:K}}}),sw=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:s,rects:i,initialPlacement:a,platform:l,elements:c}=t,{mainAxis:d=!0,crossAxis:h=!0,fallbackPlacements:m,fallbackStrategy:f="bestFit",fallbackAxisSideDirection:v="none",flipAlignment:g=!0,...x}=Nn(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const y=An(o),w=wn(a),S=An(a)===a,k=await(l.isRTL==null?void 0:l.isRTL(c.floating)),C=m||(S||!g?[es(a)]:Jb(a)),T=v!=="none";!m&&T&&C.push(...tw(a,g,v,k));const I=[a,...C],N=await no(t,x),R=[];let O=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&R.push(N[y]),h){const j=Xb(o,i,k);R.push(N[j[0]],N[j[1]])}if(O=[...O,{placement:o,overflows:R}],!R.every(j=>j<=0)){var $,V;const j=((($=s.flip)==null?void 0:$.index)||0)+1,q=I[j];if(q&&(!(h==="alignment"?w!==wn(q):!1)||O.every(P=>wn(P.placement)===w?P.overflows[0]>0:!0)))return{data:{index:j,overflows:O},reset:{placement:q}};let K=(V=O.filter(D=>D.overflows[0]<=0).sort((D,P)=>D.overflows[1]-P.overflows[1])[0])==null?void 0:V.placement;if(!K)switch(f){case"bestFit":{var U;const D=(U=O.filter(P=>{if(T){const E=wn(P.placement);return E===w||E==="y"}return!0}).map(P=>[P.placement,P.overflows.filter(E=>E>0).reduce((E,B)=>E+B,0)]).sort((P,E)=>P[1]-E[1])[0])==null?void 0:U[0];D&&(K=D);break}case"initialPlacement":K=a;break}if(o!==K)return{reset:{placement:K}}}return{}}}};function Qu(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function ed(e){return Kb.some(t=>e[t]>=0)}const iw=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=Nn(e,t);switch(r){case"referenceHidden":{const s=await no(t,{...o,elementContext:"reference"}),i=Qu(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:ed(i)}}}case"escaped":{const s=await no(t,{...o,altBoundary:!0}),i=Qu(s,n.floating);return{data:{escapedOffsets:i,escaped:ed(i)}}}default:return{}}}}},td=new Set(["left","top"]);async function aw(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=An(n),a=yr(n),l=wn(n)==="y",c=td.has(i)?-1:1,d=s&&l?-1:1,h=Nn(t,e);let{mainAxis:m,crossAxis:f,alignmentAxis:v}=typeof h=="number"?{mainAxis:h,crossAxis:0,alignmentAxis:null}:{mainAxis:h.mainAxis||0,crossAxis:h.crossAxis||0,alignmentAxis:h.alignmentAxis};return a&&typeof v=="number"&&(f=a==="end"?v*-1:v),l?{x:f*d,y:m*c}:{x:m*c,y:f*d}}const lw=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 aw(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}}}}},cw=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}=Nn(e,t),c={x:n,y:r},d=await no(t,l),h=wn(An(o)),m=Ki(h);let f=c[m],v=c[h];if(s){const x=m==="y"?"top":"left",y=m==="y"?"bottom":"right",w=f+d[x],S=f-d[y];f=Vi(w,f,S)}if(i){const x=h==="y"?"top":"left",y=h==="y"?"bottom":"right",w=v+d[x],S=v-d[y];v=Vi(w,v,S)}const g=a.fn({...t,[m]:f,[h]:v});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[m]:s,[h]:i}}}}}},uw=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}=Nn(e,t),d={x:n,y:r},h=wn(o),m=Ki(h);let f=d[m],v=d[h];const g=Nn(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=td.has(An(o)),C=s.reference[h]-s.floating[S]+(k&&((y=i.offset)==null?void 0:y[h])||0)+(k?0:x.crossAxis),T=s.reference[h]+s.reference[S]+(k?0:((w=i.offset)==null?void 0:w[h])||0)-(k?x.crossAxis:0);v<C?v=C:v>T&&(v=T)}return{[m]:f,[h]:v}}}},dw=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}=Nn(e,t),d=await no(t,c),h=An(o),m=yr(o),f=wn(o)==="y",{width:v,height:g}=s.floating;let x,y;h==="top"||h==="bottom"?(x=h,y=m===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(y=h,x=m==="end"?"top":"bottom");const w=g-d.top-d.bottom,S=v-d.left-d.right,k=$n(g-d[x],w),C=$n(v-d[y],S),T=!t.middlewareData.shift;let I=k,N=C;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(N=S),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(I=w),T&&!m){const O=Zt(d.left,0),$=Zt(d.right,0),V=Zt(d.top,0),U=Zt(d.bottom,0);f?N=v-2*(O!==0||$!==0?O+$:Zt(d.left,d.right)):I=g-2*(V!==0||U!==0?V+U:Zt(d.top,d.bottom))}await l({...t,availableWidth:N,availableHeight:I});const R=await i.getDimensions(a.floating);return v!==R.width||g!==R.height?{reset:{rects:!0}}:{}}}};function ns(){return typeof window<"u"}function Sr(e){return nd(e)?(e.nodeName||"").toLowerCase():"#document"}function Qt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function yn(e){var t;return(t=(nd(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function nd(e){return ns()?e instanceof Node||e instanceof Qt(e).Node:!1}function un(e){return ns()?e instanceof Element||e instanceof Qt(e).Element:!1}function Sn(e){return ns()?e instanceof HTMLElement||e instanceof Qt(e).HTMLElement:!1}function rd(e){return!ns()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Qt(e).ShadowRoot}const fw=new Set(["inline","contents"]);function ro(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=dn(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!fw.has(o)}const hw=new Set(["table","td","th"]);function pw(e){return hw.has(Sr(e))}const mw=[":popover-open",":modal"];function rs(e){return mw.some(t=>{try{return e.matches(t)}catch{return!1}})}const gw=["transform","translate","scale","rotate","perspective"],xw=["transform","translate","scale","rotate","perspective","filter"],vw=["paint","layout","strict","content"];function Xi(e){const t=Ji(),n=un(e)?dn(e):e;return gw.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)||xw.some(r=>(n.willChange||"").includes(r))||vw.some(r=>(n.contain||"").includes(r))}function bw(e){let t=Fn(e);for(;Sn(t)&&!Cr(t);){if(Xi(t))return t;if(rs(t))return null;t=Fn(t)}return null}function Ji(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const ww=new Set(["html","body","#document"]);function Cr(e){return ww.has(Sr(e))}function dn(e){return Qt(e).getComputedStyle(e)}function os(e){return un(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Fn(e){if(Sr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||rd(e)&&e.host||yn(e);return rd(t)?t.host:t}function od(e){const t=Fn(e);return Cr(t)?e.ownerDocument?e.ownerDocument.body:e.body:Sn(t)&&ro(t)?t:od(t)}function oo(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=od(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Qt(o);if(s){const a=Zi(i);return t.concat(i,i.visualViewport||[],ro(o)?o:[],a&&n?oo(a):[])}return t.concat(o,oo(o,[],n))}function Zi(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function sd(e){const t=dn(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=Sn(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=Zo(n)!==s||Zo(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function Qi(e){return un(e)?e:e.contextElement}function Tr(e){const t=Qi(e);if(!Sn(t))return bn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=sd(t);let i=(s?Zo(n.width):n.width)/r,a=(s?Zo(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const yw=bn(0);function id(e){const t=Qt(e);return!Ji()||!t.visualViewport?yw:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Sw(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Qt(e)?!1:t}function Qn(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=Qi(e);let i=bn(1);t&&(r?un(r)&&(i=Tr(r)):i=Tr(e));const a=Sw(s,n,r)?id(s):bn(0);let l=(o.left+a.x)/i.x,c=(o.top+a.y)/i.y,d=o.width/i.x,h=o.height/i.y;if(s){const m=Qt(s),f=r&&un(r)?Qt(r):r;let v=m,g=Zi(v);for(;g&&r&&f!==v;){const x=Tr(g),y=g.getBoundingClientRect(),w=dn(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,h*=x.y,l+=S,c+=k,v=Qt(g),g=Zi(v)}}return ts({width:d,height:h,x:l,y:c})}function ss(e,t){const n=os(e).scrollLeft;return t?t.left+n:Qn(yn(e)).left+n}function ad(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-ss(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function Cw(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=yn(r),a=t?rs(t.floating):!1;if(r===i||a&&s)return n;let l={scrollLeft:0,scrollTop:0},c=bn(1);const d=bn(0),h=Sn(r);if((h||!h&&!s)&&((Sr(r)!=="body"||ro(i))&&(l=os(r)),Sn(r))){const f=Qn(r);c=Tr(r),d.x=f.x+r.clientLeft,d.y=f.y+r.clientTop}const m=i&&!h&&!s?ad(i,l):bn(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 Tw(e){return Array.from(e.getClientRects())}function kw(e){const t=yn(e),n=os(e),r=e.ownerDocument.body,o=Zt(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Zt(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+ss(e);const a=-n.scrollTop;return dn(r).direction==="rtl"&&(i+=Zt(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const ld=25;function Ew(e,t){const n=Qt(e),r=yn(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=Ji();(!d||d&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}const c=ss(r);if(c<=0){const d=r.ownerDocument,h=d.body,m=getComputedStyle(h),f=d.compatMode==="CSS1Compat"&&parseFloat(m.marginLeft)+parseFloat(m.marginRight)||0,v=Math.abs(r.clientWidth-h.clientWidth-f);v<=ld&&(s-=v)}else c<=ld&&(s+=c);return{width:s,height:i,x:a,y:l}}const Iw=new Set(["absolute","fixed"]);function Nw(e,t){const n=Qn(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=Sn(e)?Tr(e):bn(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 cd(e,t,n){let r;if(t==="viewport")r=Ew(e,n);else if(t==="document")r=kw(yn(e));else if(un(t))r=Nw(t,n);else{const o=id(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return ts(r)}function ud(e,t){const n=Fn(e);return n===t||!un(n)||Cr(n)?!1:dn(n).position==="fixed"||ud(n,t)}function Aw(e,t){const n=t.get(e);if(n)return n;let r=oo(e,[],!1).filter(a=>un(a)&&Sr(a)!=="body"),o=null;const s=dn(e).position==="fixed";let i=s?Fn(e):e;for(;un(i)&&!Cr(i);){const a=dn(i),l=Xi(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&Iw.has(o.position)||ro(i)&&!l&&ud(e,i))?r=r.filter(d=>d!==i):o=a,i=Fn(i)}return t.set(e,r),r}function jw(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?rs(t)?[]:Aw(t,this._c):[].concat(n),r],a=i[0],l=i.reduce((c,d)=>{const h=cd(t,d,o);return c.top=Zt(h.top,c.top),c.right=$n(h.right,c.right),c.bottom=$n(h.bottom,c.bottom),c.left=Zt(h.left,c.left),c},cd(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function _w(e){const{width:t,height:n}=sd(e);return{width:t,height:n}}function Pw(e,t,n){const r=Sn(t),o=yn(t),s=n==="fixed",i=Qn(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=bn(0);function c(){l.x=ss(o)}if(r||!r&&!s)if((Sr(t)!=="body"||ro(o))&&(a=os(t)),r){const f=Qn(t,!0,s,t);l.x=f.x+t.clientLeft,l.y=f.y+t.clientTop}else o&&c();s&&!r&&o&&c();const d=o&&!r&&!s?ad(o,a):bn(0),h=i.left+a.scrollLeft-l.x-d.x,m=i.top+a.scrollTop-l.y-d.y;return{x:h,y:m,width:i.width,height:i.height}}function ea(e){return dn(e).position==="static"}function dd(e,t){if(!Sn(e)||dn(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return yn(e)===n&&(n=n.ownerDocument.body),n}function fd(e,t){const n=Qt(e);if(rs(e))return n;if(!Sn(e)){let o=Fn(e);for(;o&&!Cr(o);){if(un(o)&&!ea(o))return o;o=Fn(o)}return n}let r=dd(e,t);for(;r&&pw(r)&&ea(r);)r=dd(r,t);return r&&Cr(r)&&ea(r)&&!Xi(r)?n:r||bw(e)||n}const Rw=async function(e){const t=this.getOffsetParent||fd,n=this.getDimensions,r=await n(e.floating);return{reference:Pw(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Mw(e){return dn(e).direction==="rtl"}const Ow={convertOffsetParentRelativeRectToViewportRelativeRect:Cw,getDocumentElement:yn,getClippingRect:jw,getOffsetParent:fd,getElementRects:Rw,getClientRects:Tw,getDimensions:_w,getScale:Tr,isElement:un,isRTL:Mw};function hd(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Dw(e,t){let n=null,r;const o=yn(e);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),s();const c=e.getBoundingClientRect(),{left:d,top:h,width:m,height:f}=c;if(a||t(),!m||!f)return;const v=Qo(h),g=Qo(o.clientWidth-(d+m)),x=Qo(o.clientHeight-(h+f)),y=Qo(d),S={rootMargin:-v+"px "+-g+"px "+-x+"px "+-y+"px",threshold:Zt(0,$n(1,l))||1};let k=!0;function C(T){const I=T[0].intersectionRatio;if(I!==l){if(!k)return i();I?i(!1,I):r=setTimeout(()=>{i(!1,1e-7)},1e3)}I===1&&!hd(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 Lw(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=Qi(e),d=o||s?[...c?oo(c):[],...oo(t)]:[];d.forEach(y=>{o&&y.addEventListener("scroll",n,{passive:!0}),s&&y.addEventListener("resize",n)});const h=c&&a?Dw(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?Qn(e):null;l&&x();function x(){const y=Qn(e);g&&!hd(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)}),h==null||h(),(y=f)==null||y.disconnect(),f=null,l&&cancelAnimationFrame(v)}}const $w=lw,Fw=cw,Bw=sw,zw=dw,Hw=iw,pd=ow,Uw=uw,Ww=(e,t,n)=>{const r=new Map,o={platform:Ow,...n},s={...o.platform,_c:r};return rw(e,t,{...o,platform:s})};var Vw=typeof document<"u",Kw=function(){},is=Vw?b.useLayoutEffect:Kw;function as(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(!as(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)&&!as(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function md(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function gd(e,t){const n=md(e);return Math.round(t*n)/n}function ta(e){const t=p.useRef(e);return is(()=>{t.current=e}),t}function qw(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:i}={},transform:a=!0,whileElementsMounted:l,open:c}=e,[d,h]=p.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[m,f]=p.useState(r);as(m,r)||f(r);const[v,g]=p.useState(null),[x,y]=p.useState(null),w=p.useCallback(P=>{P!==T.current&&(T.current=P,g(P))},[]),S=p.useCallback(P=>{P!==I.current&&(I.current=P,y(P))},[]),k=s||v,C=i||x,T=p.useRef(null),I=p.useRef(null),N=p.useRef(d),R=l!=null,O=ta(l),$=ta(o),V=ta(c),U=p.useCallback(()=>{if(!T.current||!I.current)return;const P={placement:t,strategy:n,middleware:m};$.current&&(P.platform=$.current),Ww(T.current,I.current,P).then(E=>{const B={...E,isPositioned:V.current!==!1};j.current&&!as(N.current,B)&&(N.current=B,Hr.flushSync(()=>{h(B)}))})},[m,t,n,$,V]);is(()=>{c===!1&&N.current.isPositioned&&(N.current.isPositioned=!1,h(P=>({...P,isPositioned:!1})))},[c]);const j=p.useRef(!1);is(()=>(j.current=!0,()=>{j.current=!1}),[]),is(()=>{if(k&&(T.current=k),C&&(I.current=C),k&&C){if(O.current)return O.current(k,C,U);U()}},[k,C,U,O,R]);const q=p.useMemo(()=>({reference:T,floating:I,setReference:w,setFloating:S}),[w,S]),K=p.useMemo(()=>({reference:k,floating:C}),[k,C]),D=p.useMemo(()=>{const P={position:n,left:0,top:0};if(!K.floating)return P;const E=gd(K.floating,d.x),B=gd(K.floating,d.y);return a?{...P,transform:"translate("+E+"px, "+B+"px)",...md(K.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:E,top:B}},[n,a,K.floating,d.x,d.y]);return p.useMemo(()=>({...d,update:U,refs:q,elements:K,floatingStyles:D}),[d,U,q,K,D])}const Gw=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?pd({element:r.current,padding:o}).fn(n):{}:r?pd({element:r,padding:o}).fn(n):{}}}},Yw=(e,t)=>({...$w(e),options:[e,t]}),Xw=(e,t)=>({...Fw(e),options:[e,t]}),Jw=(e,t)=>({...Uw(e),options:[e,t]}),Zw=(e,t)=>({...Bw(e),options:[e,t]}),Qw=(e,t)=>({...zw(e),options:[e,t]}),ey=(e,t)=>({...Hw(e),options:[e,t]}),ty=(e,t)=>({...Gw(e),options:[e,t]});var ny="Arrow",xd=p.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return u.jsx(ve.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"})})});xd.displayName=ny;var ry=xd;function vd(e){const[t,n]=p.useState(void 0);return Et(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const s=o[0];let i,a;if("borderBoxSize"in s){const l=s.borderBoxSize,c=Array.isArray(l)?l[0]:l;i=c.inlineSize,a=c.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var na="Popper",[bd,kr]=cn(na),[oy,wd]=bd(na),yd=e=>{const{__scopePopper:t,children:n}=e,[r,o]=p.useState(null);return u.jsx(oy,{scope:t,anchor:r,onAnchorChange:o,children:n})};yd.displayName=na;var Sd="PopperAnchor",Cd=p.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=wd(Sd,n),i=p.useRef(null),a=Le(t,i),l=p.useRef(null);return p.useEffect(()=>{const c=l.current;l.current=(r==null?void 0:r.current)||i.current,c!==l.current&&s.onAnchorChange(l.current)}),r?null:u.jsx(ve.div,{...o,ref:a})});Cd.displayName=Sd;var ra="PopperContent",[sy,iy]=bd(ra),Td=p.forwardRef((e,t)=>{var W,L,X,ee,Z,z;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:a=0,avoidCollisions:l=!0,collisionBoundary:c=[],collisionPadding:d=0,sticky:h="partial",hideWhenDetached:m=!1,updatePositionStrategy:f="optimized",onPlaced:v,...g}=e,x=wd(ra,n),[y,w]=p.useState(null),S=Le(t,ae=>w(ae)),[k,C]=p.useState(null),T=vd(k),I=(T==null?void 0:T.width)??0,N=(T==null?void 0:T.height)??0,R=r+(s!=="center"?"-"+s:""),O=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},$=Array.isArray(c)?c:[c],V=$.length>0,U={padding:O,boundary:$.filter(ly),altBoundary:V},{refs:j,floatingStyles:q,placement:K,isPositioned:D,middlewareData:P}=qw({strategy:"fixed",placement:R,whileElementsMounted:(...ae)=>Lw(...ae,{animationFrame:f==="always"}),elements:{reference:x.anchor},middleware:[Yw({mainAxis:o+N,alignmentAxis:i}),l&&Xw({mainAxis:!0,crossAxis:!1,limiter:h==="partial"?Jw():void 0,...U}),l&&Zw({...U}),Qw({...U,apply:({elements:ae,rects:ie,availableWidth:ge,availableHeight:we})=>{const{width:Ae,height:Pe}=ie.reference,ke=ae.floating.style;ke.setProperty("--radix-popper-available-width",`${ge}px`),ke.setProperty("--radix-popper-available-height",`${we}px`),ke.setProperty("--radix-popper-anchor-width",`${Ae}px`),ke.setProperty("--radix-popper-anchor-height",`${Pe}px`)}}),k&&ty({element:k,padding:a}),cy({arrowWidth:I,arrowHeight:N}),m&&ey({strategy:"referenceHidden",...U})]}),[E,B]=Id(K),Y=pt(v);Et(()=>{D&&(Y==null||Y())},[D,Y]);const _=(W=P.arrow)==null?void 0:W.x,M=(L=P.arrow)==null?void 0:L.y,G=((X=P.arrow)==null?void 0:X.centerOffset)!==0,[J,se]=p.useState();return Et(()=>{y&&se(window.getComputedStyle(y).zIndex)},[y]),u.jsx("div",{ref:j.setFloating,"data-radix-popper-content-wrapper":"",style:{...q,transform:D?q.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:J,"--radix-popper-transform-origin":[(ee=P.transformOrigin)==null?void 0:ee.x,(Z=P.transformOrigin)==null?void 0:Z.y].join(" "),...((z=P.hide)==null?void 0:z.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:u.jsx(sy,{scope:n,placedSide:E,onArrowChange:C,arrowX:_,arrowY:M,shouldHideArrow:G,children:u.jsx(ve.div,{"data-side":E,"data-align":B,...g,ref:S,style:{...g.style,animation:D?void 0:"none"}})})})});Td.displayName=ra;var kd="PopperArrow",ay={top:"bottom",right:"left",bottom:"top",left:"right"},Ed=p.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=iy(kd,r),i=ay[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(ry,{...o,ref:n,style:{...o.style,display:"block"}})})});Ed.displayName=kd;function ly(e){return e!==null}var cy=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]=Id(n),h={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?h:`${m}px`,g=`${-l}px`):c==="top"?(v=i?h:`${m}px`,g=`${r.floating.height+l}px`):c==="right"?(v=`${-l}px`,g=i?h:`${f}px`):c==="left"&&(v=`${r.floating.width+l}px`,g=i?h:`${f}px`),{data:{x:v,y:g}}}});function Id(e){const[t,n="center"]=e.split("-");return[t,n]}var oa=yd,sa=Cd,ia=Td,aa=Ed,uy="Portal",so=p.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=p.useState(!1);Et(()=>s(!0),[]);const i=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?Po.createPortal(u.jsx(ve.div,{...r,ref:t}),i):null});so.displayName=uy;function dy(e,t){return p.useReducer((n,r)=>t[n][r]??n,e)}var Wt=e=>{const{present:t,children:n}=e,r=fy(t),o=typeof n=="function"?n({present:r.isPresent}):p.Children.only(n),s=Le(r.ref,hy(o));return typeof n=="function"||r.isPresent?p.cloneElement(o,{ref:s}):null};Wt.displayName="Presence";function fy(e){const[t,n]=p.useState(),r=p.useRef(null),o=p.useRef(e),s=p.useRef("none"),i=e?"mounted":"unmounted",[a,l]=dy(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return p.useEffect(()=>{const c=ls(r.current);s.current=a==="mounted"?c:"none"},[a]),Et(()=>{const c=r.current,d=o.current;if(d!==e){const m=s.current,f=ls(c);e?l("MOUNT"):f==="none"||(c==null?void 0:c.display)==="none"?l("UNMOUNT"):l(d&&m!==f?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,l]),Et(()=>{if(t){let c;const d=t.ownerDocument.defaultView??window,h=f=>{const g=ls(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=ls(r.current))};return t.addEventListener("animationstart",m),t.addEventListener("animationcancel",h),t.addEventListener("animationend",h),()=>{d.clearTimeout(c),t.removeEventListener("animationstart",m),t.removeEventListener("animationcancel",h),t.removeEventListener("animationend",h)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:p.useCallback(c=>{r.current=c?getComputedStyle(c):null,n(c)},[])}}function ls(e){return(e==null?void 0:e.animationName)||"none"}function hy(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 la="rovingFocusGroup.onEntryFocus",py={bubbles:!1,cancelable:!0},io="RovingFocusGroup",[ca,Nd,my]=Yo(io),[gy,Ad]=cn(io,[my]),[xy,vy]=gy(io),jd=p.forwardRef((e,t)=>u.jsx(ca.Provider,{scope:e.__scopeRovingFocusGroup,children:u.jsx(ca.Slot,{scope:e.__scopeRovingFocusGroup,children:u.jsx(by,{...e,ref:t})})}));jd.displayName=io;var by=p.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:c,preventScrollOnEntryFocus:d=!1,...h}=e,m=p.useRef(null),f=Le(t,m),v=Xo(s),[g,x]=Dn({prop:i,defaultProp:a??null,onChange:l,caller:io}),[y,w]=p.useState(!1),S=pt(c),k=Nd(n),C=p.useRef(!1),[T,I]=p.useState(0);return p.useEffect(()=>{const N=m.current;if(N)return N.addEventListener(la,S),()=>N.removeEventListener(la,S)},[S]),u.jsx(xy,{scope:n,orientation:r,dir:v,loop:o,currentTabStopId:g,onItemFocus:p.useCallback(N=>x(N),[x]),onItemShiftTab:p.useCallback(()=>w(!0),[]),onFocusableItemAdd:p.useCallback(()=>I(N=>N+1),[]),onFocusableItemRemove:p.useCallback(()=>I(N=>N-1),[]),children:u.jsx(ve.div,{tabIndex:y||T===0?-1:0,"data-orientation":r,...h,ref:f,style:{outline:"none",...e.style},onMouseDown:ce(e.onMouseDown,()=>{C.current=!0}),onFocus:ce(e.onFocus,N=>{const R=!C.current;if(N.target===N.currentTarget&&R&&!y){const O=new CustomEvent(la,py);if(N.currentTarget.dispatchEvent(O),!O.defaultPrevented){const $=k().filter(K=>K.focusable),V=$.find(K=>K.active),U=$.find(K=>K.id===g),q=[V,U,...$].filter(Boolean).map(K=>K.ref.current);Rd(q,d)}}C.current=!1}),onBlur:ce(e.onBlur,()=>w(!1))})})}),_d="RovingFocusGroupItem",Pd=p.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,l=Rt(),c=s||l,d=vy(_d,n),h=d.currentTabStopId===c,m=Nd(n),{onFocusableItemAdd:f,onFocusableItemRemove:v,currentTabStopId:g}=d;return p.useEffect(()=>{if(r)return f(),()=>v()},[r,f,v]),u.jsx(ca.ItemSlot,{scope:n,id:c,focusable:r,active:o,children:u.jsx(ve.span,{tabIndex:h?0:-1,"data-orientation":d.orientation,...a,ref:t,onMouseDown:ce(e.onMouseDown,x=>{r?d.onItemFocus(c):x.preventDefault()}),onFocus:ce(e.onFocus,()=>d.onItemFocus(c)),onKeyDown:ce(e.onKeyDown,x=>{if(x.key==="Tab"&&x.shiftKey){d.onItemShiftTab();return}if(x.target!==x.currentTarget)return;const y=Sy(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?Cy(S,k+1):S.slice(k+1)}setTimeout(()=>Rd(S))}}),children:typeof i=="function"?i({isCurrentTabStop:h,hasTabStop:g!=null}):i})})});Pd.displayName=_d;var wy={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function yy(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Sy(e,t,n){const r=yy(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return wy[r]}function Rd(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function Cy(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Ty=jd,ky=Pd,Ey=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Er=new WeakMap,cs=new WeakMap,us={},ua=0,Md=function(e){return e&&(e.host||Md(e.parentNode))},Iy=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=Md(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})},Ny=function(e,t,n,r){var o=Iy(t,Array.isArray(e)?e:[e]);us[n]||(us[n]=new WeakMap);var s=us[n],i=[],a=new Set,l=new Set(o),c=function(h){!h||a.has(h)||(a.add(h),c(h.parentNode))};o.forEach(c);var d=function(h){!h||l.has(h)||Array.prototype.forEach.call(h.children,function(m){if(a.has(m))d(m);else try{var f=m.getAttribute(r),v=f!==null&&f!=="false",g=(Er.get(m)||0)+1,x=(s.get(m)||0)+1;Er.set(m,g),s.set(m,x),i.push(m),g===1&&v&&cs.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(),ua++,function(){i.forEach(function(h){var m=Er.get(h)-1,f=s.get(h)-1;Er.set(h,m),s.set(h,f),m||(cs.has(h)||h.removeAttribute(r),cs.delete(h)),f||h.removeAttribute(n)}),ua--,ua||(Er=new WeakMap,Er=new WeakMap,cs=new WeakMap,us={})}},da=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=Ey(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),Ny(r,o,n,"aria-hidden")):function(){return null}},Cn=function(){return Cn=Object.assign||function(t){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])}return t},Cn.apply(this,arguments)};function Od(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 Ay(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 ds="right-scroll-bar-position",fs="width-before-scroll-bar",jy="with-scroll-bars-hidden",_y="--removed-body-scroll-bar-size";function fa(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function Py(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 Ry=typeof window<"u"?p.useLayoutEffect:p.useEffect,Dd=new WeakMap;function My(e,t){var n=Py(null,function(r){return e.forEach(function(o){return fa(o,r)})});return Ry(function(){var r=Dd.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||fa(a,null)}),s.forEach(function(a){o.has(a)||fa(a,i)})}Dd.set(n,e)},[e]),n}function Oy(e){return e}function Dy(e,t){t===void 0&&(t=Oy);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 Ly(e){e===void 0&&(e={});var t=Dy(null);return t.options=Cn({async:!0,ssr:!1},e),t}var Ld=function(e){var t=e.sideCar,n=Od(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return p.createElement(r,Cn({},n))};Ld.isSideCarExport=!0;function $y(e,t){return e.useMedium(t),Ld}var $d=Ly(),ha=function(){},hs=p.forwardRef(function(e,t){var n=p.useRef(null),r=p.useState({onScrollCapture:ha,onWheelCapture:ha,onTouchMoveCapture:ha}),o=r[0],s=r[1],i=e.forwardProps,a=e.children,l=e.className,c=e.removeScrollBar,d=e.enabled,h=e.shards,m=e.sideCar,f=e.noRelative,v=e.noIsolation,g=e.inert,x=e.allowPinchZoom,y=e.as,w=y===void 0?"div":y,S=e.gapMode,k=Od(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=m,T=My([n,t]),I=Cn(Cn({},k),o);return p.createElement(p.Fragment,null,d&&p.createElement(C,{sideCar:$d,removeScrollBar:c,shards:h,noRelative:f,noIsolation:v,inert:g,setCallbacks:s,allowPinchZoom:!!x,lockRef:n,gapMode:S}),i?p.cloneElement(p.Children.only(a),Cn(Cn({},I),{ref:T})):p.createElement(w,Cn({},I,{className:l,ref:T}),a))});hs.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},hs.classNames={fullWidth:fs,zeroRight:ds};var Fy=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function By(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Fy();return t&&e.setAttribute("nonce",t),e}function zy(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Hy(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var Uy=function(){var e=0,t=null;return{add:function(n){e==0&&(t=By())&&(zy(t,n),Hy(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Wy=function(){var e=Uy();return function(t,n){p.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Fd=function(){var e=Wy(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},Vy={left:0,top:0,right:0,gap:0},pa=function(e){return parseInt(e||"",10)||0},Ky=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[pa(n),pa(r),pa(o)]},qy=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Vy;var t=Ky(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])}},Gy=Fd(),Ir="data-scroll-locked",Yy=function(e,t,n,r){var o=e.left,s=e.top,i=e.right,a=e.gap;return n===void 0&&(n="margin"),`
|
|
38
|
+
`);if(!kt)continue;let At;try{At=JSON.parse(kt)}catch{console.debug("[use-chat] malformed SSE:",kt.slice(0,200));continue}const Lt=ou(At)?At.data:At;if(!Lt){console.warn("[use-chat] dropped envelope event without payload",At);continue}const je=Lt;Ct=Date.now();const dt=je.seq;if(dt!==void 0){if(dt<=yt){console.debug("[use-chat] drop duplicate/out-of-order event",{seq:dt,lastProcessedSeq:yt,type:je.type});continue}yt>0&&dt>yt+1&&((Z=E==null?void 0:E.onGap)==null||Z.call(E,{from:yt,to:dt})),yt=dt,I.current=dt,x(dt)}if(je.type==="message.start"&&je.role==="assistant"){const Xe=cu(je.model);V.current={messageId:je.id,lastSeq:dt??null,lastText:""},k({id:je.id,role:"assistant",name:Xe??void 0,model:je.model,createdAt:new Date().toISOString(),content:[]})}if(je.type==="checkpoint")R.current=je.checkpointId??null,O.current=je.checkpointNs??null,v(je.checkpointId??null);else if(je.type==="state_history"){$.current=je;try{const ct=Rn(je).latest;ct&&(R.current=ct.checkpointId??null,O.current=ct.checkpointNs??null,v(ct.checkpointId??null))}catch(Xe){console.warn("[use-chat] Failed to hydrate state_history payload",Xe)}}try{_==null||_(je)}catch(Xe){console.error("[use-chat] Error in onEvent callback:",Xe,"for event:",je.type)}if(je.type==="message.delta"){k(ct=>{const an=V.current;if(!ct||an.messageId!==ct.id)return ct;const{newParts:A,newMeta:te,changed:fe}=au(ct.content??[],je.delta,{lastSeq:an.lastSeq,lastText:an.lastText},dt??null);return fe?(V.current={...an,lastSeq:te.lastSeq??an.lastSeq,lastText:te.lastText??an.lastText},{...ct,content:A}):ct});const Xe=je.delta.filter(ct=>ct.type==="text").map(ct=>ct.text).join("");Xe&&e.autoAppendAssistant!==!1&&(Pt.push(Xe),St())}else if(je.type==="heartbeat"){console.debug("[use-chat] heartbeat received");try{(z=E==null?void 0:E.onHeartbeat)==null||z.call(E,je)}catch(Xe){console.warn("[use-chat] heartbeat callback failed",Xe)}}else if(gt!==null&&cancelAnimationFrame(gt),Nt(),je.type==="checkpoint")v(je.checkpointId);else if(je.type==="error"){const Xe=je;if(d(Xe.message),Y="error",P=Xe.message,Xe.error_type==="auth_error"||Xe.code==="TOKEN_EXPIRED"||((ae=Xe.message)==null?void 0:ae.includes("token"))||((ie=Xe.message)==null?void 0:ie.includes("401"))||((ge=Xe.message)==null?void 0:ge.includes("unauthorized"))||((we=Xe.message)==null?void 0:we.includes("Unauthorized"))){console.error("[use-chat] Auth error detected:",Xe.message);try{(Ae=E==null?void 0:E.onAuthError)==null||Ae.call(E,Xe.message)}catch(an){console.warn("[use-chat] onAuthError handler failed",an)}B.abort()}}}}Nt(),Y===null&&!B.signal.aborted&&(Y="complete")}catch(Oe){if(Oe.name==="AbortError")Y=Y??"aborted";else{const Ve=Oe.message||String(Oe);Y="error",P=Ve,d(Ve),(_e=E==null?void 0:E.onError)==null||_e.call(E,Ve)}}finally{try{await ut.cancel()}catch{}finally{(ke=ut.releaseLock)==null||ke.call(ut)}gt!==null&&typeof window<"u"&&window.cancelAnimationFrame(gt),clearInterval(zt)}}catch(We){if(We.name==="AbortError")Y=Y??"aborted";else{const ze=We.message||String(We);Y="error",P=ze,d(ze),(st=E==null?void 0:E.onError)==null||st.call(E,ze),M||((bt=E==null?void 0:E.onConnectionError)==null||bt.call(E,ze),M=!0)}}finally{const We=I.current,ze=R.current,Ke=O.current,Fe=$.current,Ue=Y??(B.signal.aborted?"aborted":P?"error":"complete");try{(It=E==null?void 0:E.onClosed)==null||It.call(E,{reason:Ue,lastSeq:We,lastCheckpointId:ze,lastCheckpointNs:Ke,lastStateHistory:Fe,error:P})}catch(ut){console.warn("[use-chat] onClosed callback failed",ut)}l(!1),w(!1),C.current=null,I.current=0,x(0),N.current=null}})(),{close:()=>B.abort()}},[t,n,r,e.autoAppendAssistant]);return b.useEffect(()=>()=>{var D;T.current=!1,(D=C.current)==null||D.abort()},[]),{isStreaming:a,error:c,assistantText:f,assistantMessage:S,lastCheckpointId:h,lastSeq:g,connected:y,stream:K,stop:q,clear:j,setToken:U}}const Kv=["detail","message","error","description","title"];function qo(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=qo(t);if(n)return n}return null}if(typeof e=="object"){const t=e;for(const n of Kv){const r=qo(t[n]);if(r)return r}if("errors"in t){const n=qo(t.errors);if(n)return n}}return null}function qv(e){if(!e)return"Request failed";const t=e.response,n=qo(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),[f,m]=b.useState(null),[h,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),I=b.useRef(new Map);b.useEffect(()=>{T.current=a},[a]);const N=b.useCallback(async()=>{d(!0),m(null);try{const _=await e.listThreads();i(_??[])}catch(_){const E=String(_);m(E),n==null||n(E)}finally{d(!1)}},[e,n]),R=b.useCallback(async()=>{x(!0),y(null);try{const _=await e.listSharedThreads();v(_??[])}catch(_){const E=String(_);y(E),n==null||n(E)}finally{x(!1)}},[e,n]);b.useEffect(()=>{N()},[N]),b.useEffect(()=>{R()},[R]),b.useEffect(()=>{r==null||r(a)},[a,r]);const O=b.useCallback(async _=>{try{const E=await e.createThread(_);return l(E.threadId),await N(),E.threadId}catch(E){const B=String(E);return n==null||n(B),null}},[e,n,N]),$=b.useCallback(async _=>{const E=s;i(Y=>Y.filter(P=>P.threadId!==_));const B=new AbortController;I.current.set(_,B);try{await e.deleteThread(_),T.current===_&&(l(null),o==null||o())}catch(Y){i(E);const P=String(Y);n==null||n(P)}finally{I.current.delete(_)}},[e,o,n,s]),V=b.useCallback(async(_,E)=>{try{await e.updateThread(_,E),await N()}catch(B){n==null||n(String(B))}},[e,n,N]),U=b.useCallback(async(_,E)=>{C(!0),S("Sharing thread…");try{await e.shareThread(_,E),await R(),S("Shared successfully")}catch(B){const Y=qv(B);throw n==null||n(Y),S(`Failed to share: ${Y}`),new Error(Y)}finally{C(!1)}},[e,n,R]),j=b.useCallback(async(_,E)=>{try{await e.unshareThread(_,E),await R()}catch(B){const Y=String(B);throw n==null||n(Y),B}},[e,n,R]),q=b.useMemo(()=>({createThread:O,deleteThread:$,renameThread:V,refreshThreads:N,refreshSharedThreads:R,shareThread:U,unshareThread:j}),[O,$,V,N,R,U,j]),K=b.useCallback(_=>{if(!(_!=null&&_.threadId))return;const E={threadId:_.threadId,title:_.title||`Thread ${_.threadId.slice(0,8)}`,createdAt:_.createdAt||new Date().toISOString(),updatedAt:_.updatedAt||new Date().toISOString(),messageCount:_.messageCount??1};i(B=>{let Y=!1;const P=B.map(M=>M.threadId===E.threadId?(Y=!0,console.debug("[useThreadsState] thread_info: updating existing thread",E.threadId),{...M,title:E.title??M.title,updatedAt:E.updatedAt??M.updatedAt,messageCount:E.messageCount??M.messageCount}):M);return Y?P:(console.debug("[useThreadsState] thread_info: adding thread to list",E.threadId),[E,...B])})},[]),D=b.useCallback(()=>S(null),[]);return{threads:s,currentThreadId:a,currentThreadIdRef:T,setCurrentThreadId:l,isLoadingThreads:c,threadsError:f,sharedThreads:h,isLoadingSharedThreads:g,actions:q,addThreadFromEvent:K,shareInFlight:k,shareStatus:w,clearShareStatus:D}}const du=b.createContext(null);function fu({children:e,initialThreadId:t=null,onError:n,onThreadChange:r}){const{api:o}=Xr(),{threads:s,currentThreadId:i,setCurrentThreadId:a,currentThreadIdRef:l,isLoadingThreads:c,threadsError:d,sharedThreads:f,isLoadingSharedThreads:m,actions:h,addThreadFromEvent:v,shareInFlight:g,shareStatus:x,clearShareStatus:y}=uu({api:o,initialThreadId:t,onError:n,onThreadChange:r}),w=b.useMemo(()=>({threads:s,currentThreadId:i,setCurrentThreadId:a,currentThreadIdRef:l,isLoading:c,error:d,sharedThreads:f,isLoadingSharedThreads:m,actions:h,shareInFlight:g,shareStatus:x,clearShareStatus:y,addThreadFromEvent:v}),[s,i,a,l,c,d,f,m,h,g,x,y,v]);return u.jsx(du.Provider,{value:w,children:e})}function gr(){const e=b.useContext(du);if(!e)throw new Error("useThreads must be used within a ThreadsProvider");return e}function Ri(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 hu(e){return!!(e&&typeof e=="object"&&(e.type==="file"||e.mimeType||e.filename||e.sourceType==="base64"))}function Zr(e){if(typeof e=="string")return e;if(e&&typeof e=="object"){if(Array.isArray(e)){const n=e.map(Zr).filter(r=>r!==void 0);if(!n.length){console.debug("[message-utils] sanitizeForDisplay - array emptied -> returning undefined",{originalLength:e.length});return}return n}if(hu(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=Zr(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 xr(e){if(typeof e=="string")return e;if(hu(e))return"";try{const t=Zr(e);return t===void 0?"":typeof t=="string"?t:JSON.stringify(t,null,2)}catch{return""}}function Gv(e){return typeof e!="string"?!1:/^[\s\n]*[-*]\s|^[\s\n]*#+\s|```|^\s*\[.*\]\(|^>\s/.test(e)}function Yv(e){const t=xr(e);return typeof e=="string"&&Gv(e)?{content:e,isMarkdown:!0}:{content:t,isMarkdown:!1}}function Qr(e){if(e==null)return e;if(typeof e=="string"){const t=e.trim();if(t.startsWith("{")||t.startsWith("[")){const n=Ri(t);if(n!==null)return Qr(n)}return e}return typeof e=="object"&&!Array.isArray(e)&&e.content!==void 0?Qr(e.content):e}function Xv(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function Mi(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 Go(e){if(e==null)return null;const t=String(e).trim();return t.length>0?t:null}function Jv(e){const t=r=>{try{const o=Zr(r);return typeof o=="string"?o:JSON.stringify(o??"")}catch{return""}},n=e.filter(r=>r.type==="text");return n.length?t(n.map(r=>r.text).join(`
|
|
39
|
+
`)):t(e)}function Zv(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function pu(e){if(e.role==="default_message")return`default:${e.content.length}`;const t=e.updatedAt??e.createdAt??"",n=Array.isArray(e.content)?e.content.map(i=>{switch(i.type){case"text":return`t:${i.text.length}`;case"image_url":return"img";case"file":return"file";case"tool_call":return"call";case"interrupt":return"interrupt";default:return"unknown"}}).join("|"):"",r="checkpointId"in e&&e.checkpointId?`cp:${e.checkpointId}`:"",o="checkpointNs"in e&&e.checkpointNs?`ns:${e.checkpointNs}`:"",s=[r,o].filter(Boolean).join("|");return`${e.id}:${t}:${n}${s?`:${s}`:""}`}function Qv(e){if(!e)return"image/png";const t=e.trim();return t?t.includes("/")?t:`image/${t}`:"image/png"}function eb(e){const t=[],n=r=>{r&&r.trim()&&t.push(r.trim())};return e&&(n(e.plotId),n(e.artifactId)),t}function tb({base64:e,url:t,formatHint:n,extras:r}){const o=typeof e=="string"&&e.length>0,s=Qv(n),i=o?`data:${s};base64,${e}`:t,a=eb(r),l=a.length?a.join(" / "):void 0,c=l?`${l} artifact`:"artifact image";return{src:i,alt:c,label:l}}function nb(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 tb({base64:t,url:n,formatHint:r,extras:{plotId:e.plotId,artifactId:e.artifactId}})}function mu(e){var n;const t=(n=e.additionalKwargs)==null?void 0:n.toolProgress;return Array.isArray(t)?t:[]}const rb={messages:[],assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,messagesStreamMeta:{},pendingInterrupt:null};function ob(e,t){var n;switch(t.type){case"reset":return{messages:_i(((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=_i(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=_i(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 sb(e=[]){const[t,n]=b.useReducer(ob,{...rb,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,f)=>n({type:"seed",payload:{messages:d,...f??{}}}),prepend:d=>n({type:"prepend",payload:{messages:d}}),pushUser:(d,f)=>n({type:"user_message",payload:{message:d,editingMessageId:f}}),onEvent: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=cu(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 ab(e,t);if(t.type==="tool.progress")return lb(e,t);if(t.type==="tool.end")return cb(e,t);if(t.type==="message.delta"){const s=e.assemblingId??su(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??{},f=d[s],m=f??{lastSeq:null,lastText:iu(l.content)},h=t.seq??null;if(h!==null&&typeof h=="number"&&typeof m.lastSeq=="number"&&h<=m.lastSeq)return console.debug("[MessageReducer] skipping delta - seq <= lastSeq",{seq:h,lastSeq:m.lastSeq}),e;const{newParts:v,newMeta:g,changed:x}=au(l.content,t.delta,m,h);if(!x)return e;const y={...l,content:v},w=Jr(i,a,y),S=!f||f.lastSeq!==g.lastSeq||f.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??su(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 f;return(d==null?void 0:d.type)==="text"&&((f=d.text)==null?void 0:f.trim())}))){console.debug("[MessageReducer] pruning assistant message with no visible text",{id:l.id,contentTypes:(r=l.content)==null?void 0:r.map(f=>f==null?void 0:f.type),contentPreview:(o=l.content)==null?void 0:o.map(f=>(f==null?void 0:f.type)==="text"?String(f.text).slice(0,100):f==null?void 0:f.type)});const d=[...i.slice(0,a),...i.slice(a+1)];return{...e,assemblingId:null,messages:d}}}return e}if(t.type==="checkpoint"){const s=t.checkpointNs??e.lastCheckpointNs??null,i=Wv(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=Rn(t),i=s.interrupt,a=s.latest,l=i===null?Hv(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 Oi(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 Di(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||Mi(r).toolCallId===t)return n}return-1}function ib(e){if(e==null)return[];const t=Qr(e);if(typeof t=="string"&&t.trim())return[{type:"text",text:t}];const n=xr(t??e);return n?[{type:"text",text:n}]:[]}function bu(e,t){const n=e.additionalKwargs??{},r=Array.isArray(n.toolProgress)?[...n.toolProgress]:[],o={...n,toolProgress:[...r,t]};return{...e,additionalKwargs:o}}function ab(e,t){const n=Oi(t),r=Di(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:Jr(e.messages,r,d)}}const i=vu(s,n,o,t.args);return{...e,messages:[...e.messages,i]}}function lb(e,t){const n=Oi(t);if(!n)return e;const r=Di(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=bu(e.messages[r],o);return{...e,messages:Jr(e.messages,r,a)}}function cb(e,t){const n=Oi(t),r=xu(t);let o=e.messages,s=Di(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=ib(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 f=bu(i,d),m=t.artifact??i.artifact,h={...f,name:t.name??t.tool??i.name,content:c,artifact:m,additionalKwargs:{...f.additionalKwargs??{},toolStreaming:!1}};return{...e,messages:Jr(o,s,h)}}function wu({api:e,seed:t,prepend:n,onError:r,currentThreadId:o,initialThreadId:s=null,initialCheckpointId:i=null,initialCheckpointNs:a=null,autoLoadInitial:l=!0,isStreaming:c,getMessages:d}){const[f,m]=b.useState(null),v=b.useMemo(()=>Rn(f),[f]).checkpoints,g=tc(v),x=g.timeline,[y,w]=b.useState(!1),[S,k]=b.useState(null),[C,T]=b.useState(!1),[I,N]=b.useState(!1),[R,O]=b.useState(!1),[$,V]=b.useState(null),U=b.useRef(o),j=b.useRef(null),q=b.useRef(null),K=b.useRef(null),D=b.useRef(null),_=b.useRef(null),E=b.useRef(new Map);b.useEffect(()=>{U.current=o},[o]);const B=b.useCallback(async Z=>{var ae,ie;if(!Z.threadId)return;const z=Z.threadId;(ae=Z.onStart)==null||ae.call(Z),Z.setLoading(!0);try{await Z.action(z)}catch(ge){if(U.current===z){const we=String(ge);(ie=Z.handleError)==null||ie.call(Z,we),r==null||r(we)}throw ge}finally{Z.setLoading(!1)}},[r]),Y=b.useCallback(async(Z,z)=>{if(!Z)return;const ae=`${Z}:${z??"latest"}`,ie=E.current.get(ae);if(ie)return ie;const ge=B({threadId:Z,setLoading:T,onStart:()=>V(null),handleError:we=>V(we),action:async we=>{const Ae=await e.getStateHistory({threadId:we,checkpointId:z??void 0});if(U.current!==we){console.log(`[useThreadHistoryState] Thread changed during load (was ${we}, now ${U.current}), discarding stale data`);return}const{checkpoints:_e}=Rn(Ae),ke=_e.find(st=>st.messages&&st.messages.length>0)??(z?_e.find(st=>st.checkpointId===z):null)??_e[0];t((ke==null?void 0:ke.messages)??[],{checkpointId:(ke==null?void 0:ke.checkpointId)??null,checkpointNs:(ke==null?void 0:ke.checkpointNs)??null}),m(Ae),w(!!(ke!=null&&ke.nextCursor)),k((ke==null?void 0:ke.nextCursor)??null)}});E.current.set(ae,ge);try{await ge}finally{E.current.delete(ae)}return U.current===Z&&(_.current=ae),ge},[e,t,B]),P=b.useCallback(async(Z,z)=>{D.current=Z;try{await Y(Z,z)}finally{D.current===Z&&(D.current=null)}},[Y]),M=b.useCallback(Z=>{q.current=Z},[]),G=b.useCallback(Z=>{K.current=Z},[]),J=b.useCallback(Z=>{const z=Z.threadId??U.current;if(!z||U.current&&U.current!==z)return;const{checkpoints:ae}=Rn(Z);if(!ae.length)return;const ie=ae.find(we=>we.messages&&we.messages.length>0)??ae.find(we=>!!we.checkpointId)??ae[0],ge=K.current===z;!c&&!ge&&t((ie==null?void 0:ie.messages)??[],{checkpointId:(ie==null?void 0:ie.checkpointId)??null,checkpointNs:(ie==null?void 0:ie.checkpointNs)??null}),m(Z),w(!!(ie!=null&&ie.nextCursor)),k((ie==null?void 0:ie.nextCursor)??null),_.current=`${z}:latest`,q.current=null,K.current===z&&(K.current=null)},[t,c]),se=b.useCallback(async(Z,z)=>{const ae=U.current;await B({threadId:ae,setLoading:O,action:async ie=>{const ge=await e.getStateHistory({threadId:ie,checkpointId:Z,checkpointNs:z??void 0});if(U.current!==ie){console.log(`[useThreadHistoryState] Thread changed during checkpoint navigation (was ${ie}, now ${U.current}), discarding stale data`);return}const{checkpoints:we}=Rn(ge),Ae=we.find(_e=>_e.checkpointId===Z&&(z?_e.checkpointNs===z:!0));if(!Ae){console.warn("[useThreadHistoryState] Requested checkpoint not found:",{checkpointId:Z,checkpointNs:z});return}m(ge),t(Ae.messages??[],{checkpointId:Ae.checkpointId??null,checkpointNs:Ae.checkpointNs??null})}}).catch(()=>{})},[e,t,B]),W=b.useCallback((Z,z)=>{t(d(),{checkpointId:Z??null,checkpointNs:z??null})},[d,t]),L=b.useCallback(async()=>{U.current&&await P(U.current)},[P]),X=b.useCallback(async()=>{const Z=U.current;!Z||!S||await B({threadId:Z,setLoading:N,action:async z=>{const ae=await e.getStateHistory({threadId:z,checkpointId:S});if(U.current!==z)return;const{checkpoints:ie}=Rn(ae);if(ie.length>0){const ge=ie[ie.length-1];n((ge==null?void 0:ge.messages)??[]),w(!!(ge!=null&&ge.nextCursor)),k((ge==null?void 0:ge.nextCursor)??null)}}}).catch(()=>{})},[e,S,r,n,B]);b.useEffect(()=>{if(!l||!o||C||c)return;if(q.current===o){q.current=null,j.current=o;return}if(K.current===o){j.current=o;return}if(D.current===o){D.current=null,j.current=o;return}if(j.current===o)return;j.current=o;let Z;console.log("[useThreadHistoryState] Loading thread with latest checkpoint");const z=`${o}:latest`;_.current!==z&&P(o,Z)},[l,o,i,a,s,C,c,P]);const ee=b.useCallback(()=>{m(null),w(!1),k(null),T(!1),N(!1),O(!1),V(null),q.current=null,K.current=null,j.current=null,_.current=null,D.current=null},[]);return{threadCheckpoints:v,threadTimeline:x,checkpointIndex:g,isLoadingThread:C,isHistoryLoading:I,isLoadingCheckpoint:R,threadStateError:$,hasMoreHistory:y,loadThread:P,navigateToCheckpoint:se,loadOlderMessages:X,setCurrentCheckpointId:W,returnToLatest:L,handleStateHistoryEvent:J,markSkipNextLoad:M,markStreamPendingThread:G,resetHistoryState:ee}}const yu=b.createContext(null),Su=b.createContext(null);function eo(){const e=b.useContext(yu);if(!e)throw new Error("useThreadState must be used within a ThreadStateProvider");return e}function Cu(){const e=b.useContext(Su);if(!e)throw new Error("useThreadStateUpdater must be used within a ThreadStateProvider");return e}function Tu({children:e,initialThreadId:t=null,initialCheckpointId:n=null,initialCheckpointNs:r=null,autoLoadInitial:o=!0,isStreaming:s,onError:i}){const{api:a}=Xr(),{currentThreadId:l}=gr(),{state:c,seed:d,prepend:f,pushUser:m,onEvent:h}=sb(),{threadCheckpoints:v,threadTimeline:g,checkpointIndex:x,isLoadingThread:y,isHistoryLoading:w,isLoadingCheckpoint:S,threadStateError:k,hasMoreHistory:C,loadThread:T,navigateToCheckpoint:I,loadOlderMessages:N,setCurrentCheckpointId:R,returnToLatest:O,handleStateHistoryEvent:$,markSkipNextLoad:V,markStreamPendingThread:U,resetHistoryState:j}=wu({api:a,seed:d,prepend:f,onError:i,currentThreadId:l,initialThreadId:t,initialCheckpointId:n,initialCheckpointNs:r,autoLoadInitial:o,isStreaming:s,getMessages:b.useCallback(()=>c.messages,[c.messages])}),[q,K]=b.useState(()=>async()=>{throw new Error("clearThread is not ready")}),[D,_]=b.useState(()=>async()=>{throw new Error("respondToInterrupt is not ready")});b.useEffect(()=>{l||(d([],{}),j())},[l,d,j]);const E=b.useCallback(G=>K(()=>G),[]),B=b.useCallback(G=>_(()=>G),[]),Y=b.useMemo(()=>({assemblingMessageId:c.assemblingId??null}),[c.assemblingId]),P=b.useMemo(()=>({threadId:l,messages:c.messages,interrupt:c.pendingInterrupt,checkpoint:{id:c.lastCheckpointId??null,namespace:c.lastCheckpointNs??null},checkpoints:v,checkpointIndex:x,timelineCheckpoints:g,metadata:Y,isLoading:y,isHistoryLoading:w,isLoadingCheckpoint:S,error:k,hasMore:C,loadOlder:N,clearState:q,navigateToCheckpoint:I,setCurrentCheckpointId:R,returnToLatest:O,loadThread:T,clearThread:q,respondToInterrupt:D,messagePreviews:x.messagePreviews,handleStateHistoryEvent:$,markSkipNextLoad:V,markStreamPendingThread:U,resetHistoryState:j,pushUser:m,onEvent:h}),[l,c,v,g,x,Y,y,w,S,k,C,N,q,I,R,O,T,D,x.messagePreviews,$,V,U,j,m,h]),M=b.useMemo(()=>({registerClearThread:E,registerRespondToInterrupt:B}),[E,B]);return u.jsx(Su.Provider,{value:M,children:u.jsx(yu.Provider,{value:P,children:e})})}function ku(e,t){if(!e)return null;const n=Pn(e);if(!n)return null;const r=Pn(n.configurable)??n;return _n(r,t)??null}function ub(e){const t=ku(e,["checkpoint_id","checkpointId"]);if(!t)return null;const n=ku(e,["checkpoint_ns","checkpointNs"]);return{checkpointId:t,checkpointNs:n}}function db(e,t){const n=typeof e.step=="number"?e.step:Number.POSITIVE_INFINITY,r=typeof t.step=="number"?t.step:Number.POSITIVE_INFINITY;if(n!==r)return n-r;const o=e.createdAt?Date.parse(e.createdAt):0,s=t.createdAt?Date.parse(t.createdAt):0;return o-s}function fb(e,t){const n=[...e].sort(db);for(const r of n){if(r.messageId!==t)continue;const o=ub(r.parentConfig);if(!o)throw new Error(`Parent checkpoint info missing for message ${t}`);return o}throw new Error(`Message ${t} not found in timeline`)}const Eu=b.createContext(null),Iu=b.createContext(!1);function hb({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:f}=Xr(),m=b.useMemo(()=>vn(f),[f]),{stream:h,stop:v,isStreaming:g,error:x,setToken:y}=Vv({baseUrl:m}),[w,S]=b.useState(!1);return b.useEffect(()=>{S(g)},[g]),u.jsx(fu,{initialThreadId:t,onError:s,onThreadChange:a,children:u.jsx(Tu,{initialThreadId:t,initialCheckpointId:n,initialCheckpointNs:r,autoLoadInitial:o,onError:s,isStreaming:w,children:u.jsx(Iu.Provider,{value:!0,children:u.jsx(pb,{api:d,streamApi:{stream:h,stop:v,isStreaming:g,error:x,setToken:y},onError:s,onAuthError:i,onConnectionError:l,onToolEnd:c,children:e})})})})}function pb({children:e,api:t,streamApi:n,onError:r,onAuthError:o,onConnectionError:s,onToolEnd:i}){const{stream:a,stop:l,isStreaming:c,error:d,setToken:f}=n,{setCurrentThreadId:m,currentThreadIdRef:h,addThreadFromEvent:v}=gr(),{checkpoint:g,timelineCheckpoints:x,handleStateHistoryEvent:y,markSkipNextLoad:w,markStreamPendingThread:S,resetHistoryState:k,pushUser:C,onEvent:T}=eo(),{registerClearThread:I,registerRespondToInterrupt:N}=Cu(),R=b.useCallback(D=>{v(D),h.current!==D.threadId&&((D.created??!h.current)&&w(D.threadId),S(D.threadId),m(D.threadId))},[v,w,S,m,h]),O=b.useCallback(D=>{D.type==="thread_info"?R(D):D.type==="state_history"?y(D):D.type==="tool.end"?i==null||i(D):T(D)},[R,y,T,i]),$=b.useCallback(D=>{a(D,O,{onError:_=>{console.error("[StreamingProvider] Stream error:",_),r==null||r(_)},onAuthError:_=>{console.error("[StreamingProvider] Auth error:",_),o==null||o(_)},onConnectionError:_=>{console.error("[StreamingProvider] Connection error:",_),s==null||s(_)}})},[a,O,r,o,s]),V=b.useRef(g);b.useEffect(()=>{V.current=g},[g]);const U=b.useCallback(async(D,_,E)=>{const B=h.current;if(!B)throw new Error("No active thread to handle interrupt");const Y=_?E??!0:!1,P=V.current,M={threadId:B,checkpointId:P.id??void 0,checkpointNs:P.namespace??void 0,command:{kind:"resume",value:Y}};$(M)},[h,$]);b.useEffect(()=>{N(U)},[U,N]);const j=b.useCallback(async()=>{l(),k(),m(null);try{await t.getAgent("default")}catch(D){console.warn("[StreamingProvider] Failed to refetch agent after clearing thread:",D)}},[t,k,m,l]);b.useEffect(()=>{I(j)},[j,I]);const q=b.useCallback(async(D,_)=>{let E=h.current;const B=(D==null?void 0:D.text)??"",Y=(D==null?void 0:D.attachments)??[],P=(B==null?void 0:B.trim())??"",M={...(D==null?void 0:D.payload)??{}},G=Array.isArray(M.messages)?M.messages:void 0;G&&delete M.messages;const J=!!(G&&G.length);if(!E&&!P&&Y.length===0&&!J)return;if(!E){const _e=Math.floor(Date.now()/1e3).toString(16).padStart(8,"0"),ke=Array.from({length:4},()=>Math.floor(Math.random()*4294967295).toString(16).padStart(8,"0")).join("").slice(0,16);E=`${_e}${ke}`,w(E),m(E)}const{contentParts:se,filesInfo:W}=await ru(Y),L=[...se];P&&L.push({type:"text",text:B});const X=_==null?void 0:_.originalMessageId,ee=!!(_!=null&&_.edit&&X),Z=!J&&L.length>0;let z=null;Z&&(z={id:ee?X:`msg-${Date.now()}`,role:"user",content:L,createdAt:new Date().toISOString()},ee?C(z,X):C(z));const ae=J?G:z?[z]:[],ie={...M,...W.length?{files_info:W}:{}};ae.length?ie.messages=ae:"messages"in ie||(ie.messages=[]);let ge=(_==null?void 0:_.checkpointId)??g.id??void 0,we=(_==null?void 0:_.checkpointNs)??g.namespace??void 0;if(ee&&X){const _e=fb(x,X);ge=_e.checkpointId,we=_e.checkpointNs??void 0}const Ae={threadId:E,payload:ie,checkpointId:ge,checkpointNs:we,edit:!!(_!=null&&_.edit)};$(Ae)},[g,h,w,C,$,x]),K=b.useMemo(()=>({isStreaming:c,error:d,connectionState:c?"connected":"idle",submit:q,send:q,stop:l,setAuthToken:f}),[c,d,q,l,f]);return u.jsx(Eu.Provider,{value:K,children:e})}function Li(){const e=b.useContext(Eu);if(!e)throw new Error("useStream must be used within StreamingProvider");return e}function mb(){return b.useContext(Iu)}function Nu(e){return typeof e=="object"&&e!==null}function gb(e,t){if(Object.is(e,t))return!0;if(!Nu(e)||!Nu(t))return!1;const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const o of n)if(!Object.prototype.hasOwnProperty.call(t,o)||!Object.is(e[o],t[o]))return!1;return!0}function Au(e){const t=b.useRef(e),n=b.useRef(e);return gb(t.current,e)||(t.current=e,n.current=e),n.current}function vr({children:e,apiConfig:t,initialThreadId:n=null,initialCheckpointId:r=null,initialCheckpointNs:o=null,autoLoadInitial:s=!0,onConnectionError:i,onError:a,onAuthError:l,onThreadChange:c,onToolEnd:d}){const f=Au(t),m=to(a),h=to(l),v=to(i),g=to(c),x=to(d),y=b.useMemo(()=>({initialThreadId:n,initialCheckpointId:r,initialCheckpointNs:o,autoLoadInitial:s,onError:m,onAuthError:h,onConnectionError:v,onThreadChange:g,onToolEnd:x}),[n,r,o,s,m,h,v,g,x]);return u.jsx(tu,{apiConfig:f,children:u.jsx(hb,{...y,children:e})})}function to(e){const t=b.useRef(e);return b.useEffect(()=>{t.current=e},[e]),b.useCallback((...n)=>{const r=t.current;if(r)return r(...n)},[])}function br(e){if(!(typeof globalThis>"u"))return globalThis[e]}function xb(e){if(typeof e!="string")return;const t=e.trim();if(t)return vn(t)}function ju(){const e=[br("__API_BASE_URL__"),br("__CHAT_API_BASE_URL__"),br("__CHAT_API_URL__")];for(const t of e){const n=xb(t);if(n)return n}}function Pu(){const e=[br("__API_AUTH_TOKEN__"),br("__CHAT_API_KEY__"),br("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function _u(...e){for(const t of e)if(typeof t=="string"&&t.trim())return vn(t);return vn()}function Ru(){const e={},t=ju(),n=Pu();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function Mu(){const e=Ru(),t=Mn.getAuthToken(),n=ju();return{apiBaseUrl:_u(e.baseUrl,Mn.baseUrl,n),apiKey:t||e.apiKey||Pu()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,darkMode:!1,enableSound:!1,messageHistory:100}}const $i="chat-settings";function Ou(){try{const e=localStorage.getItem($i);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function Du(e){try{const t={...e,apiBaseUrl:vn(e.apiBaseUrl)};localStorage.setItem($i,JSON.stringify(t)),t.apiKey&&Mn.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function vb(){const e=Mu(),t=Ou(),n=Mn.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:_u(Mn.baseUrl,r,e.apiBaseUrl)}}function bb(e){Mn.updateConfig({baseUrl:e.apiBaseUrl,authToken:e.apiKey??void 0}),Du(e)}function re(...e){return nx.twMerge(tx.clsx(e))}const wb=zr.cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),Qe=p.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?Yt.Slot:"button";return u.jsx(i,{className:re(wb({variant:t,size:n,className:e})),ref:s,...o})});Qe.displayName="Button";function ce(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 Lu(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function On(...e){return t=>{let n=!1;const r=e.map(o=>{const s=Lu(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():Lu(e[o],null)}}}}function Le(...e){return p.useCallback(On(...e),e)}function yb(e,t){const n=p.createContext(t),r=s=>{const{children:i,...a}=s,l=p.useMemo(()=>a,Object.values(a));return u.jsx(n.Provider,{value:l,children:i})};r.displayName=e+"Provider";function o(s){const i=p.useContext(n);if(i)return i;if(t!==void 0)return t;throw new Error(`\`${s}\` must be used within \`${e}\``)}return[r,o]}function cn(e,t=[]){let n=[];function r(s,i){const a=p.createContext(i),l=n.length;n=[...n,i];const c=f=>{var y;const{scope:m,children:h,...v}=f,g=((y=m==null?void 0:m[e])==null?void 0:y[l])||a,x=p.useMemo(()=>v,Object.values(v));return u.jsx(g.Provider,{value:x,children:h})};c.displayName=s+"Provider";function d(f,m){var g;const h=((g=m==null?void 0:m[e])==null?void 0:g[l])||a,v=p.useContext(h);if(v)return v;if(i!==void 0)return i;throw new Error(`\`${f}\` must be used within \`${s}\``)}return[c,d]}const o=()=>{const s=n.map(i=>p.createContext(i));return function(a){const l=(a==null?void 0:a[e])||s;return p.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return o.scopeName=e,[r,Sb(o,...t)]}function Sb(...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 f=l(s)[`__scope${c}`];return{...a,...f}},{});return p.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var Et=globalThis!=null&&globalThis.document?p.useLayoutEffect:()=>{},Cb=p[" useInsertionEffect ".trim().toString()]||Et;function Dn({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=Tb({defaultProp:t,onChange:n}),a=e!==void 0,l=a?e:o;{const d=p.useRef(e!==void 0);p.useEffect(()=>{const f=d.current;f!==a&&console.warn(`${r} is changing from ${f?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),d.current=a},[a,r])}const c=p.useCallback(d=>{var f;if(a){const m=kb(d)?d(e):d;m!==e&&((f=i.current)==null||f.call(i,m))}else s(d)},[a,e,s,i]);return[l,c]}function Tb({defaultProp:e,onChange:t}){const[n,r]=p.useState(e),o=p.useRef(n),s=p.useRef(t);return Cb(()=>{s.current=t},[t]),p.useEffect(()=>{var i;o.current!==n&&((i=s.current)==null||i.call(s,n),o.current=n)},[n,o]),[n,r,s]}function kb(e){return typeof e=="function"}var Eb=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],ve=Eb.reduce((e,t)=>{const n=Yt.createSlot(`Primitive.${t}`),r=p.forwardRef((o,s)=>{const{asChild:i,...a}=o,l=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),u.jsx(l,{...a,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Fi(e,t){e&&Hr.flushSync(()=>e.dispatchEvent(t))}function Yo(e){const t=e+"CollectionProvider",[n,r]=cn(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=g=>{const{scope:x,children:y}=g,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=Yt.createSlot(a),c=b.forwardRef((g,x)=>{const{scope:y,children:w}=g,S=s(a,y),k=Le(x,S.collectionRef);return u.jsx(l,{ref:k,children:w})});c.displayName=a;const d=e+"CollectionItemSlot",f="data-radix-collection-item",m=Yt.createSlot(d),h=b.forwardRef((g,x)=>{const{scope:y,children:w,...S}=g,k=b.useRef(null),C=Le(x,k),T=s(d,y);return b.useEffect(()=>(T.itemMap.set(k,{ref:k,...S}),()=>void T.itemMap.delete(k))),u.jsx(m,{[f]:"",ref:C,children:w})});h.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(`[${f}]`));return Array.from(x.itemMap.values()).sort((T,I)=>S.indexOf(T.ref.current)-S.indexOf(I.ref.current))},[x.collectionRef,x.itemMap])}return[{Provider:i,Slot:c,ItemSlot:h},v,r]}var Ib=p.createContext(void 0);function Xo(e){const t=p.useContext(Ib);return e||t||"ltr"}function pt(e){const t=p.useRef(e);return p.useEffect(()=>{t.current=e}),p.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function Nb(e,t=globalThis==null?void 0:globalThis.document){const n=pt(e);p.useEffect(()=>{const r=o=>{o.key==="Escape"&&n(o)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var Ab="DismissableLayer",Bi="dismissableLayer.update",jb="dismissableLayer.pointerDownOutside",Pb="dismissableLayer.focusOutside",$u,Fu=p.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),wr=p.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...l}=e,c=p.useContext(Fu),[d,f]=p.useState(null),m=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,h]=p.useState({}),v=Le(t,I=>f(I)),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=Rb(I=>{const N=I.target,R=[...c.branches].some(O=>O.contains(N));!k||R||(o==null||o(I),i==null||i(I),I.defaultPrevented||a==null||a())},m),T=Mb(I=>{const N=I.target;[...c.branches].some(O=>O.contains(N))||(s==null||s(I),i==null||i(I),I.defaultPrevented||a==null||a())},m);return Nb(I=>{w===c.layers.size-1&&(r==null||r(I),!I.defaultPrevented&&a&&(I.preventDefault(),a()))},m),p.useEffect(()=>{if(d)return n&&(c.layersWithOutsidePointerEventsDisabled.size===0&&($u=m.body.style.pointerEvents,m.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(d)),c.layers.add(d),zu(),()=>{n&&c.layersWithOutsidePointerEventsDisabled.size===1&&(m.body.style.pointerEvents=$u)}},[d,m,n,c]),p.useEffect(()=>()=>{d&&(c.layers.delete(d),c.layersWithOutsidePointerEventsDisabled.delete(d),zu())},[d,c]),p.useEffect(()=>{const I=()=>h({});return document.addEventListener(Bi,I),()=>document.removeEventListener(Bi,I)},[]),u.jsx(ve.div,{...l,ref:v,style:{pointerEvents:S?k?"auto":"none":void 0,...e.style},onFocusCapture:ce(e.onFocusCapture,T.onFocusCapture),onBlurCapture:ce(e.onBlurCapture,T.onBlurCapture),onPointerDownCapture:ce(e.onPointerDownCapture,C.onPointerDownCapture)})});wr.displayName=Ab;var _b="DismissableLayerBranch",Bu=p.forwardRef((e,t)=>{const n=p.useContext(Fu),r=p.useRef(null),o=Le(t,r);return p.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),u.jsx(ve.div,{...e,ref:o})});Bu.displayName=_b;function Rb(e,t=globalThis==null?void 0:globalThis.document){const n=pt(e),r=p.useRef(!1),o=p.useRef(()=>{});return p.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){Hu(jb,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 Mb(e,t=globalThis==null?void 0:globalThis.document){const n=pt(e),r=p.useRef(!1);return p.useEffect(()=>{const o=s=>{s.target&&!r.current&&Hu(Pb,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 zu(){const e=new CustomEvent(Bi);document.dispatchEvent(e)}function Hu(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?Fi(o,s):o.dispatchEvent(s)}var Ob=wr,Db=Bu,zi=0;function Hi(){p.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Uu()),document.body.insertAdjacentElement("beforeend",e[1]??Uu()),zi++,()=>{zi===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),zi--}},[])}function Uu(){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 Ui="focusScope.autoFocusOnMount",Wi="focusScope.autoFocusOnUnmount",Wu={bubbles:!1,cancelable:!0},Lb="FocusScope",Jo=p.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,l]=p.useState(null),c=pt(o),d=pt(s),f=p.useRef(null),m=Le(t,g=>l(g)),h=p.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;p.useEffect(()=>{if(r){let g=function(S){if(h.paused||!a)return;const k=S.target;a.contains(k)?f.current=k:Ln(f.current,{select:!0})},x=function(S){if(h.paused||!a)return;const k=S.relatedTarget;k!==null&&(a.contains(k)||Ln(f.current,{select:!0}))},y=function(S){if(document.activeElement===document.body)for(const C of S)C.removedNodes.length>0&&Ln(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,h.paused]),p.useEffect(()=>{if(a){qu.add(h);const g=document.activeElement;if(!a.contains(g)){const y=new CustomEvent(Ui,Wu);a.addEventListener(Ui,c),a.dispatchEvent(y),y.defaultPrevented||($b(Ub(Vu(a)),{select:!0}),document.activeElement===g&&Ln(a))}return()=>{a.removeEventListener(Ui,c),setTimeout(()=>{const y=new CustomEvent(Wi,Wu);a.addEventListener(Wi,d),a.dispatchEvent(y),y.defaultPrevented||Ln(g??document.body,{select:!0}),a.removeEventListener(Wi,d),qu.remove(h)},0)}}},[a,c,d,h]);const v=p.useCallback(g=>{if(!n&&!r||h.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]=Fb(w);S&&k?!g.shiftKey&&y===k?(g.preventDefault(),n&&Ln(S,{select:!0})):g.shiftKey&&y===S&&(g.preventDefault(),n&&Ln(k,{select:!0})):y===w&&g.preventDefault()}},[n,r,h.paused]);return u.jsx(ve.div,{tabIndex:-1,...i,ref:m,onKeyDown:v})});Jo.displayName=Lb;function $b(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Ln(r,{select:t}),document.activeElement!==n)return}function Fb(e){const t=Vu(e),n=Ku(t,e),r=Ku(t.reverse(),e);return[n,r]}function Vu(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 Ku(e,t){for(const n of e)if(!Bb(n,{upTo:t}))return n}function Bb(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 zb(e){return e instanceof HTMLInputElement&&"select"in e}function Ln(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&zb(e)&&t&&e.select()}}var qu=Hb();function Hb(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=Gu(e,t),e.unshift(t)},remove(t){var n;e=Gu(e,t),(n=e[0])==null||n.resume()}}}function Gu(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Ub(e){return e.filter(t=>t.tagName!=="A")}var Wb=p[" useId ".trim().toString()]||(()=>{}),Vb=0;function Rt(e){const[t,n]=p.useState(Wb());return Et(()=>{n(r=>r??String(Vb++))},[e]),t?`radix-${t}`:""}const Kb=["top","right","bottom","left"],$n=Math.min,Zt=Math.max,Zo=Math.round,Qo=Math.floor,bn=e=>({x:e,y:e}),qb={left:"right",right:"left",bottom:"top",top:"bottom"},Gb={start:"end",end:"start"};function Vi(e,t,n){return Zt(e,$n(t,n))}function Nn(e,t){return typeof e=="function"?e(t):e}function An(e){return e.split("-")[0]}function yr(e){return e.split("-")[1]}function Ki(e){return e==="x"?"y":"x"}function qi(e){return e==="y"?"height":"width"}const Yb=new Set(["top","bottom"]);function wn(e){return Yb.has(An(e))?"y":"x"}function Gi(e){return Ki(wn(e))}function Xb(e,t,n){n===void 0&&(n=!1);const r=yr(e),o=Gi(e),s=qi(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=es(i)),[i,es(i)]}function Jb(e){const t=es(e);return[Yi(e),t,Yi(t)]}function Yi(e){return e.replace(/start|end/g,t=>Gb[t])}const Yu=["left","right"],Xu=["right","left"],Zb=["top","bottom"],Qb=["bottom","top"];function ew(e,t,n){switch(e){case"top":case"bottom":return n?t?Xu:Yu:t?Yu:Xu;case"left":case"right":return t?Zb:Qb;default:return[]}}function tw(e,t,n,r){const o=yr(e);let s=ew(An(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(Yi)))),s}function es(e){return e.replace(/left|right|bottom|top/g,t=>qb[t])}function nw(e){return{top:0,right:0,bottom:0,left:0,...e}}function Ju(e){return typeof e!="number"?nw(e):{top:e,right:e,bottom:e,left:e}}function ts(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 Zu(e,t,n){let{reference:r,floating:o}=e;const s=wn(t),i=Gi(t),a=qi(i),l=An(t),c=s==="y",d=r.x+r.width/2-o.width/2,f=r.y+r.height/2-o.height/2,m=r[a]/2-o[a]/2;let h;switch(l){case"top":h={x:d,y:r.y-o.height};break;case"bottom":h={x:d,y:r.y+r.height};break;case"right":h={x:r.x+r.width,y:f};break;case"left":h={x:r.x-o.width,y:f};break;default:h={x:r.x,y:r.y}}switch(yr(t)){case"start":h[i]-=m*(n&&c?-1:1);break;case"end":h[i]+=m*(n&&c?-1:1);break}return h}const rw=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:f}=Zu(c,r,l),m=r,h={},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:f,initialPlacement:r,placement:m,strategy:o,middlewareData:h,rects:c,platform:i,elements:{reference:e,floating:t}});d=w??d,f=S??f,h={...h,[x]:{...h[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:f}=Zu(c,m,l)),g=-1)}return{x:d,y:f,placement:m,strategy:o,middlewareData:h}};async function no(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:f="floating",altBoundary:m=!1,padding:h=0}=Nn(t,e),v=Ju(h),x=a[m?f==="floating"?"reference":"floating":f],y=ts(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=f==="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=ts(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 ow=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}=Nn(e,t)||{};if(c==null)return{};const f=Ju(d),m={x:n,y:r},h=Gi(o),v=qi(h),g=await i.getDimensions(c),x=h==="y",y=x?"top":"left",w=x?"bottom":"right",S=x?"clientHeight":"clientWidth",k=s.reference[v]+s.reference[h]-m[h]-s.floating[v],C=m[h]-s.reference[h],T=await(i.getOffsetParent==null?void 0:i.getOffsetParent(c));let I=T?T[S]:0;(!I||!await(i.isElement==null?void 0:i.isElement(T)))&&(I=a.floating[S]||s.floating[v]);const N=k/2-C/2,R=I/2-g[v]/2-1,O=$n(f[y],R),$=$n(f[w],R),V=O,U=I-g[v]-$,j=I/2-g[v]/2+N,q=Vi(V,j,U),K=!l.arrow&&yr(o)!=null&&j!==q&&s.reference[v]/2-(j<V?O:$)-g[v]/2<0,D=K?j<V?j-V:j-U:0;return{[h]:m[h]+D,data:{[h]:q,centerOffset:j-q-D,...K&&{alignmentOffset:D}},reset:K}}}),sw=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:f=!0,fallbackPlacements:m,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:v="none",flipAlignment:g=!0,...x}=Nn(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const y=An(o),w=wn(a),S=An(a)===a,k=await(l.isRTL==null?void 0:l.isRTL(c.floating)),C=m||(S||!g?[es(a)]:Jb(a)),T=v!=="none";!m&&T&&C.push(...tw(a,g,v,k));const I=[a,...C],N=await no(t,x),R=[];let O=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&R.push(N[y]),f){const j=Xb(o,i,k);R.push(N[j[0]],N[j[1]])}if(O=[...O,{placement:o,overflows:R}],!R.every(j=>j<=0)){var $,V;const j=((($=s.flip)==null?void 0:$.index)||0)+1,q=I[j];if(q&&(!(f==="alignment"?w!==wn(q):!1)||O.every(_=>wn(_.placement)===w?_.overflows[0]>0:!0)))return{data:{index:j,overflows:O},reset:{placement:q}};let K=(V=O.filter(D=>D.overflows[0]<=0).sort((D,_)=>D.overflows[1]-_.overflows[1])[0])==null?void 0:V.placement;if(!K)switch(h){case"bestFit":{var U;const D=(U=O.filter(_=>{if(T){const E=wn(_.placement);return E===w||E==="y"}return!0}).map(_=>[_.placement,_.overflows.filter(E=>E>0).reduce((E,B)=>E+B,0)]).sort((_,E)=>_[1]-E[1])[0])==null?void 0:U[0];D&&(K=D);break}case"initialPlacement":K=a;break}if(o!==K)return{reset:{placement:K}}}return{}}}};function Qu(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function ed(e){return Kb.some(t=>e[t]>=0)}const iw=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=Nn(e,t);switch(r){case"referenceHidden":{const s=await no(t,{...o,elementContext:"reference"}),i=Qu(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:ed(i)}}}case"escaped":{const s=await no(t,{...o,altBoundary:!0}),i=Qu(s,n.floating);return{data:{escapedOffsets:i,escaped:ed(i)}}}default:return{}}}}},td=new Set(["left","top"]);async function aw(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=An(n),a=yr(n),l=wn(n)==="y",c=td.has(i)?-1:1,d=s&&l?-1:1,f=Nn(t,e);let{mainAxis:m,crossAxis:h,alignmentAxis:v}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof v=="number"&&(h=a==="end"?v*-1:v),l?{x:h*d,y:m*c}:{x:m*c,y:h*d}}const lw=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 aw(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}}}}},cw=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}=Nn(e,t),c={x:n,y:r},d=await no(t,l),f=wn(An(o)),m=Ki(f);let h=c[m],v=c[f];if(s){const x=m==="y"?"top":"left",y=m==="y"?"bottom":"right",w=h+d[x],S=h-d[y];h=Vi(w,h,S)}if(i){const x=f==="y"?"top":"left",y=f==="y"?"bottom":"right",w=v+d[x],S=v-d[y];v=Vi(w,v,S)}const g=a.fn({...t,[m]:h,[f]:v});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[m]:s,[f]:i}}}}}},uw=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}=Nn(e,t),d={x:n,y:r},f=wn(o),m=Ki(f);let h=d[m],v=d[f];const g=Nn(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;h<k?h=k:h>C&&(h=C)}if(c){var y,w;const S=m==="y"?"width":"height",k=td.has(An(o)),C=s.reference[f]-s.floating[S]+(k&&((y=i.offset)==null?void 0:y[f])||0)+(k?0:x.crossAxis),T=s.reference[f]+s.reference[S]+(k?0:((w=i.offset)==null?void 0:w[f])||0)-(k?x.crossAxis:0);v<C?v=C:v>T&&(v=T)}return{[m]:h,[f]:v}}}},dw=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}=Nn(e,t),d=await no(t,c),f=An(o),m=yr(o),h=wn(o)==="y",{width:v,height:g}=s.floating;let x,y;f==="top"||f==="bottom"?(x=f,y=m===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(y=f,x=m==="end"?"top":"bottom");const w=g-d.top-d.bottom,S=v-d.left-d.right,k=$n(g-d[x],w),C=$n(v-d[y],S),T=!t.middlewareData.shift;let I=k,N=C;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(N=S),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(I=w),T&&!m){const O=Zt(d.left,0),$=Zt(d.right,0),V=Zt(d.top,0),U=Zt(d.bottom,0);h?N=v-2*(O!==0||$!==0?O+$:Zt(d.left,d.right)):I=g-2*(V!==0||U!==0?V+U:Zt(d.top,d.bottom))}await l({...t,availableWidth:N,availableHeight:I});const R=await i.getDimensions(a.floating);return v!==R.width||g!==R.height?{reset:{rects:!0}}:{}}}};function ns(){return typeof window<"u"}function Sr(e){return nd(e)?(e.nodeName||"").toLowerCase():"#document"}function Qt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function yn(e){var t;return(t=(nd(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function nd(e){return ns()?e instanceof Node||e instanceof Qt(e).Node:!1}function un(e){return ns()?e instanceof Element||e instanceof Qt(e).Element:!1}function Sn(e){return ns()?e instanceof HTMLElement||e instanceof Qt(e).HTMLElement:!1}function rd(e){return!ns()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Qt(e).ShadowRoot}const fw=new Set(["inline","contents"]);function ro(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=dn(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!fw.has(o)}const hw=new Set(["table","td","th"]);function pw(e){return hw.has(Sr(e))}const mw=[":popover-open",":modal"];function rs(e){return mw.some(t=>{try{return e.matches(t)}catch{return!1}})}const gw=["transform","translate","scale","rotate","perspective"],xw=["transform","translate","scale","rotate","perspective","filter"],vw=["paint","layout","strict","content"];function Xi(e){const t=Ji(),n=un(e)?dn(e):e;return gw.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)||xw.some(r=>(n.willChange||"").includes(r))||vw.some(r=>(n.contain||"").includes(r))}function bw(e){let t=Fn(e);for(;Sn(t)&&!Cr(t);){if(Xi(t))return t;if(rs(t))return null;t=Fn(t)}return null}function Ji(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const ww=new Set(["html","body","#document"]);function Cr(e){return ww.has(Sr(e))}function dn(e){return Qt(e).getComputedStyle(e)}function os(e){return un(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Fn(e){if(Sr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||rd(e)&&e.host||yn(e);return rd(t)?t.host:t}function od(e){const t=Fn(e);return Cr(t)?e.ownerDocument?e.ownerDocument.body:e.body:Sn(t)&&ro(t)?t:od(t)}function oo(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=od(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Qt(o);if(s){const a=Zi(i);return t.concat(i,i.visualViewport||[],ro(o)?o:[],a&&n?oo(a):[])}return t.concat(o,oo(o,[],n))}function Zi(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function sd(e){const t=dn(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=Sn(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=Zo(n)!==s||Zo(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function Qi(e){return un(e)?e:e.contextElement}function Tr(e){const t=Qi(e);if(!Sn(t))return bn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=sd(t);let i=(s?Zo(n.width):n.width)/r,a=(s?Zo(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const yw=bn(0);function id(e){const t=Qt(e);return!Ji()||!t.visualViewport?yw:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Sw(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Qt(e)?!1:t}function Qn(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=Qi(e);let i=bn(1);t&&(r?un(r)&&(i=Tr(r)):i=Tr(e));const a=Sw(s,n,r)?id(s):bn(0);let l=(o.left+a.x)/i.x,c=(o.top+a.y)/i.y,d=o.width/i.x,f=o.height/i.y;if(s){const m=Qt(s),h=r&&un(r)?Qt(r):r;let v=m,g=Zi(v);for(;g&&r&&h!==v;){const x=Tr(g),y=g.getBoundingClientRect(),w=dn(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,f*=x.y,l+=S,c+=k,v=Qt(g),g=Zi(v)}}return ts({width:d,height:f,x:l,y:c})}function ss(e,t){const n=os(e).scrollLeft;return t?t.left+n:Qn(yn(e)).left+n}function ad(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-ss(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function Cw(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=yn(r),a=t?rs(t.floating):!1;if(r===i||a&&s)return n;let l={scrollLeft:0,scrollTop:0},c=bn(1);const d=bn(0),f=Sn(r);if((f||!f&&!s)&&((Sr(r)!=="body"||ro(i))&&(l=os(r)),Sn(r))){const h=Qn(r);c=Tr(r),d.x=h.x+r.clientLeft,d.y=h.y+r.clientTop}const m=i&&!f&&!s?ad(i,l):bn(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 Tw(e){return Array.from(e.getClientRects())}function kw(e){const t=yn(e),n=os(e),r=e.ownerDocument.body,o=Zt(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Zt(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+ss(e);const a=-n.scrollTop;return dn(r).direction==="rtl"&&(i+=Zt(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const ld=25;function Ew(e,t){const n=Qt(e),r=yn(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=Ji();(!d||d&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}const c=ss(r);if(c<=0){const d=r.ownerDocument,f=d.body,m=getComputedStyle(f),h=d.compatMode==="CSS1Compat"&&parseFloat(m.marginLeft)+parseFloat(m.marginRight)||0,v=Math.abs(r.clientWidth-f.clientWidth-h);v<=ld&&(s-=v)}else c<=ld&&(s+=c);return{width:s,height:i,x:a,y:l}}const Iw=new Set(["absolute","fixed"]);function Nw(e,t){const n=Qn(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=Sn(e)?Tr(e):bn(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 cd(e,t,n){let r;if(t==="viewport")r=Ew(e,n);else if(t==="document")r=kw(yn(e));else if(un(t))r=Nw(t,n);else{const o=id(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return ts(r)}function ud(e,t){const n=Fn(e);return n===t||!un(n)||Cr(n)?!1:dn(n).position==="fixed"||ud(n,t)}function Aw(e,t){const n=t.get(e);if(n)return n;let r=oo(e,[],!1).filter(a=>un(a)&&Sr(a)!=="body"),o=null;const s=dn(e).position==="fixed";let i=s?Fn(e):e;for(;un(i)&&!Cr(i);){const a=dn(i),l=Xi(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&Iw.has(o.position)||ro(i)&&!l&&ud(e,i))?r=r.filter(d=>d!==i):o=a,i=Fn(i)}return t.set(e,r),r}function jw(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?rs(t)?[]:Aw(t,this._c):[].concat(n),r],a=i[0],l=i.reduce((c,d)=>{const f=cd(t,d,o);return c.top=Zt(f.top,c.top),c.right=$n(f.right,c.right),c.bottom=$n(f.bottom,c.bottom),c.left=Zt(f.left,c.left),c},cd(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function Pw(e){const{width:t,height:n}=sd(e);return{width:t,height:n}}function _w(e,t,n){const r=Sn(t),o=yn(t),s=n==="fixed",i=Qn(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=bn(0);function c(){l.x=ss(o)}if(r||!r&&!s)if((Sr(t)!=="body"||ro(o))&&(a=os(t)),r){const h=Qn(t,!0,s,t);l.x=h.x+t.clientLeft,l.y=h.y+t.clientTop}else o&&c();s&&!r&&o&&c();const d=o&&!r&&!s?ad(o,a):bn(0),f=i.left+a.scrollLeft-l.x-d.x,m=i.top+a.scrollTop-l.y-d.y;return{x:f,y:m,width:i.width,height:i.height}}function ea(e){return dn(e).position==="static"}function dd(e,t){if(!Sn(e)||dn(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return yn(e)===n&&(n=n.ownerDocument.body),n}function fd(e,t){const n=Qt(e);if(rs(e))return n;if(!Sn(e)){let o=Fn(e);for(;o&&!Cr(o);){if(un(o)&&!ea(o))return o;o=Fn(o)}return n}let r=dd(e,t);for(;r&&pw(r)&&ea(r);)r=dd(r,t);return r&&Cr(r)&&ea(r)&&!Xi(r)?n:r||bw(e)||n}const Rw=async function(e){const t=this.getOffsetParent||fd,n=this.getDimensions,r=await n(e.floating);return{reference:_w(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Mw(e){return dn(e).direction==="rtl"}const Ow={convertOffsetParentRelativeRectToViewportRelativeRect:Cw,getDocumentElement:yn,getClippingRect:jw,getOffsetParent:fd,getElementRects:Rw,getClientRects:Tw,getDimensions:Pw,getScale:Tr,isElement:un,isRTL:Mw};function hd(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Dw(e,t){let n=null,r;const o=yn(e);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),s();const c=e.getBoundingClientRect(),{left:d,top:f,width:m,height:h}=c;if(a||t(),!m||!h)return;const v=Qo(f),g=Qo(o.clientWidth-(d+m)),x=Qo(o.clientHeight-(f+h)),y=Qo(d),S={rootMargin:-v+"px "+-g+"px "+-x+"px "+-y+"px",threshold:Zt(0,$n(1,l))||1};let k=!0;function C(T){const I=T[0].intersectionRatio;if(I!==l){if(!k)return i();I?i(!1,I):r=setTimeout(()=>{i(!1,1e-7)},1e3)}I===1&&!hd(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 Lw(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=Qi(e),d=o||s?[...c?oo(c):[],...oo(t)]:[];d.forEach(y=>{o&&y.addEventListener("scroll",n,{passive:!0}),s&&y.addEventListener("resize",n)});const f=c&&a?Dw(c,n):null;let m=-1,h=null;i&&(h=new ResizeObserver(y=>{let[w]=y;w&&w.target===c&&h&&(h.unobserve(t),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var S;(S=h)==null||S.observe(t)})),n()}),c&&!l&&h.observe(c),h.observe(t));let v,g=l?Qn(e):null;l&&x();function x(){const y=Qn(e);g&&!hd(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)}),f==null||f(),(y=h)==null||y.disconnect(),h=null,l&&cancelAnimationFrame(v)}}const $w=lw,Fw=cw,Bw=sw,zw=dw,Hw=iw,pd=ow,Uw=uw,Ww=(e,t,n)=>{const r=new Map,o={platform:Ow,...n},s={...o.platform,_c:r};return rw(e,t,{...o,platform:s})};var Vw=typeof document<"u",Kw=function(){},is=Vw?b.useLayoutEffect:Kw;function as(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(!as(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)&&!as(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function md(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function gd(e,t){const n=md(e);return Math.round(t*n)/n}function ta(e){const t=p.useRef(e);return is(()=>{t.current=e}),t}function qw(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,f]=p.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[m,h]=p.useState(r);as(m,r)||h(r);const[v,g]=p.useState(null),[x,y]=p.useState(null),w=p.useCallback(_=>{_!==T.current&&(T.current=_,g(_))},[]),S=p.useCallback(_=>{_!==I.current&&(I.current=_,y(_))},[]),k=s||v,C=i||x,T=p.useRef(null),I=p.useRef(null),N=p.useRef(d),R=l!=null,O=ta(l),$=ta(o),V=ta(c),U=p.useCallback(()=>{if(!T.current||!I.current)return;const _={placement:t,strategy:n,middleware:m};$.current&&(_.platform=$.current),Ww(T.current,I.current,_).then(E=>{const B={...E,isPositioned:V.current!==!1};j.current&&!as(N.current,B)&&(N.current=B,Hr.flushSync(()=>{f(B)}))})},[m,t,n,$,V]);is(()=>{c===!1&&N.current.isPositioned&&(N.current.isPositioned=!1,f(_=>({..._,isPositioned:!1})))},[c]);const j=p.useRef(!1);is(()=>(j.current=!0,()=>{j.current=!1}),[]),is(()=>{if(k&&(T.current=k),C&&(I.current=C),k&&C){if(O.current)return O.current(k,C,U);U()}},[k,C,U,O,R]);const q=p.useMemo(()=>({reference:T,floating:I,setReference:w,setFloating:S}),[w,S]),K=p.useMemo(()=>({reference:k,floating:C}),[k,C]),D=p.useMemo(()=>{const _={position:n,left:0,top:0};if(!K.floating)return _;const E=gd(K.floating,d.x),B=gd(K.floating,d.y);return a?{..._,transform:"translate("+E+"px, "+B+"px)",...md(K.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:E,top:B}},[n,a,K.floating,d.x,d.y]);return p.useMemo(()=>({...d,update:U,refs:q,elements:K,floatingStyles:D}),[d,U,q,K,D])}const Gw=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?pd({element:r.current,padding:o}).fn(n):{}:r?pd({element:r,padding:o}).fn(n):{}}}},Yw=(e,t)=>({...$w(e),options:[e,t]}),Xw=(e,t)=>({...Fw(e),options:[e,t]}),Jw=(e,t)=>({...Uw(e),options:[e,t]}),Zw=(e,t)=>({...Bw(e),options:[e,t]}),Qw=(e,t)=>({...zw(e),options:[e,t]}),ey=(e,t)=>({...Hw(e),options:[e,t]}),ty=(e,t)=>({...Gw(e),options:[e,t]});var ny="Arrow",xd=p.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return u.jsx(ve.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"})})});xd.displayName=ny;var ry=xd;function vd(e){const[t,n]=p.useState(void 0);return Et(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const s=o[0];let i,a;if("borderBoxSize"in s){const l=s.borderBoxSize,c=Array.isArray(l)?l[0]:l;i=c.inlineSize,a=c.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var na="Popper",[bd,kr]=cn(na),[oy,wd]=bd(na),yd=e=>{const{__scopePopper:t,children:n}=e,[r,o]=p.useState(null);return u.jsx(oy,{scope:t,anchor:r,onAnchorChange:o,children:n})};yd.displayName=na;var Sd="PopperAnchor",Cd=p.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=wd(Sd,n),i=p.useRef(null),a=Le(t,i),l=p.useRef(null);return p.useEffect(()=>{const c=l.current;l.current=(r==null?void 0:r.current)||i.current,c!==l.current&&s.onAnchorChange(l.current)}),r?null:u.jsx(ve.div,{...o,ref:a})});Cd.displayName=Sd;var ra="PopperContent",[sy,iy]=bd(ra),Td=p.forwardRef((e,t)=>{var W,L,X,ee,Z,z;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:a=0,avoidCollisions:l=!0,collisionBoundary:c=[],collisionPadding:d=0,sticky:f="partial",hideWhenDetached:m=!1,updatePositionStrategy:h="optimized",onPlaced:v,...g}=e,x=wd(ra,n),[y,w]=p.useState(null),S=Le(t,ae=>w(ae)),[k,C]=p.useState(null),T=vd(k),I=(T==null?void 0:T.width)??0,N=(T==null?void 0:T.height)??0,R=r+(s!=="center"?"-"+s:""),O=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},$=Array.isArray(c)?c:[c],V=$.length>0,U={padding:O,boundary:$.filter(ly),altBoundary:V},{refs:j,floatingStyles:q,placement:K,isPositioned:D,middlewareData:_}=qw({strategy:"fixed",placement:R,whileElementsMounted:(...ae)=>Lw(...ae,{animationFrame:h==="always"}),elements:{reference:x.anchor},middleware:[Yw({mainAxis:o+N,alignmentAxis:i}),l&&Xw({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?Jw():void 0,...U}),l&&Zw({...U}),Qw({...U,apply:({elements:ae,rects:ie,availableWidth:ge,availableHeight:we})=>{const{width:Ae,height:_e}=ie.reference,ke=ae.floating.style;ke.setProperty("--radix-popper-available-width",`${ge}px`),ke.setProperty("--radix-popper-available-height",`${we}px`),ke.setProperty("--radix-popper-anchor-width",`${Ae}px`),ke.setProperty("--radix-popper-anchor-height",`${_e}px`)}}),k&&ty({element:k,padding:a}),cy({arrowWidth:I,arrowHeight:N}),m&&ey({strategy:"referenceHidden",...U})]}),[E,B]=Id(K),Y=pt(v);Et(()=>{D&&(Y==null||Y())},[D,Y]);const P=(W=_.arrow)==null?void 0:W.x,M=(L=_.arrow)==null?void 0:L.y,G=((X=_.arrow)==null?void 0:X.centerOffset)!==0,[J,se]=p.useState();return Et(()=>{y&&se(window.getComputedStyle(y).zIndex)},[y]),u.jsx("div",{ref:j.setFloating,"data-radix-popper-content-wrapper":"",style:{...q,transform:D?q.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:J,"--radix-popper-transform-origin":[(ee=_.transformOrigin)==null?void 0:ee.x,(Z=_.transformOrigin)==null?void 0:Z.y].join(" "),...((z=_.hide)==null?void 0:z.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:u.jsx(sy,{scope:n,placedSide:E,onArrowChange:C,arrowX:P,arrowY:M,shouldHideArrow:G,children:u.jsx(ve.div,{"data-side":E,"data-align":B,...g,ref:S,style:{...g.style,animation:D?void 0:"none"}})})})});Td.displayName=ra;var kd="PopperArrow",ay={top:"bottom",right:"left",bottom:"top",left:"right"},Ed=p.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=iy(kd,r),i=ay[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(ry,{...o,ref:n,style:{...o.style,display:"block"}})})});Ed.displayName=kd;function ly(e){return e!==null}var cy=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]=Id(n),f={start:"0%",center:"50%",end:"100%"}[d],m=(((y=o.arrow)==null?void 0:y.x)??0)+a/2,h=(((w=o.arrow)==null?void 0:w.y)??0)+l/2;let v="",g="";return c==="bottom"?(v=i?f:`${m}px`,g=`${-l}px`):c==="top"?(v=i?f:`${m}px`,g=`${r.floating.height+l}px`):c==="right"?(v=`${-l}px`,g=i?f:`${h}px`):c==="left"&&(v=`${r.floating.width+l}px`,g=i?f:`${h}px`),{data:{x:v,y:g}}}});function Id(e){const[t,n="center"]=e.split("-");return[t,n]}var oa=yd,sa=Cd,ia=Td,aa=Ed,uy="Portal",so=p.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=p.useState(!1);Et(()=>s(!0),[]);const i=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?_o.createPortal(u.jsx(ve.div,{...r,ref:t}),i):null});so.displayName=uy;function dy(e,t){return p.useReducer((n,r)=>t[n][r]??n,e)}var Wt=e=>{const{present:t,children:n}=e,r=fy(t),o=typeof n=="function"?n({present:r.isPresent}):p.Children.only(n),s=Le(r.ref,hy(o));return typeof n=="function"||r.isPresent?p.cloneElement(o,{ref:s}):null};Wt.displayName="Presence";function fy(e){const[t,n]=p.useState(),r=p.useRef(null),o=p.useRef(e),s=p.useRef("none"),i=e?"mounted":"unmounted",[a,l]=dy(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return p.useEffect(()=>{const c=ls(r.current);s.current=a==="mounted"?c:"none"},[a]),Et(()=>{const c=r.current,d=o.current;if(d!==e){const m=s.current,h=ls(c);e?l("MOUNT"):h==="none"||(c==null?void 0:c.display)==="none"?l("UNMOUNT"):l(d&&m!==h?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,l]),Et(()=>{if(t){let c;const d=t.ownerDocument.defaultView??window,f=h=>{const g=ls(r.current).includes(CSS.escape(h.animationName));if(h.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=h=>{h.target===t&&(s.current=ls(r.current))};return t.addEventListener("animationstart",m),t.addEventListener("animationcancel",f),t.addEventListener("animationend",f),()=>{d.clearTimeout(c),t.removeEventListener("animationstart",m),t.removeEventListener("animationcancel",f),t.removeEventListener("animationend",f)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:p.useCallback(c=>{r.current=c?getComputedStyle(c):null,n(c)},[])}}function ls(e){return(e==null?void 0:e.animationName)||"none"}function hy(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 la="rovingFocusGroup.onEntryFocus",py={bubbles:!1,cancelable:!0},io="RovingFocusGroup",[ca,Nd,my]=Yo(io),[gy,Ad]=cn(io,[my]),[xy,vy]=gy(io),jd=p.forwardRef((e,t)=>u.jsx(ca.Provider,{scope:e.__scopeRovingFocusGroup,children:u.jsx(ca.Slot,{scope:e.__scopeRovingFocusGroup,children:u.jsx(by,{...e,ref:t})})}));jd.displayName=io;var by=p.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:c,preventScrollOnEntryFocus:d=!1,...f}=e,m=p.useRef(null),h=Le(t,m),v=Xo(s),[g,x]=Dn({prop:i,defaultProp:a??null,onChange:l,caller:io}),[y,w]=p.useState(!1),S=pt(c),k=Nd(n),C=p.useRef(!1),[T,I]=p.useState(0);return p.useEffect(()=>{const N=m.current;if(N)return N.addEventListener(la,S),()=>N.removeEventListener(la,S)},[S]),u.jsx(xy,{scope:n,orientation:r,dir:v,loop:o,currentTabStopId:g,onItemFocus:p.useCallback(N=>x(N),[x]),onItemShiftTab:p.useCallback(()=>w(!0),[]),onFocusableItemAdd:p.useCallback(()=>I(N=>N+1),[]),onFocusableItemRemove:p.useCallback(()=>I(N=>N-1),[]),children:u.jsx(ve.div,{tabIndex:y||T===0?-1:0,"data-orientation":r,...f,ref:h,style:{outline:"none",...e.style},onMouseDown:ce(e.onMouseDown,()=>{C.current=!0}),onFocus:ce(e.onFocus,N=>{const R=!C.current;if(N.target===N.currentTarget&&R&&!y){const O=new CustomEvent(la,py);if(N.currentTarget.dispatchEvent(O),!O.defaultPrevented){const $=k().filter(K=>K.focusable),V=$.find(K=>K.active),U=$.find(K=>K.id===g),q=[V,U,...$].filter(Boolean).map(K=>K.ref.current);Rd(q,d)}}C.current=!1}),onBlur:ce(e.onBlur,()=>w(!1))})})}),Pd="RovingFocusGroupItem",_d=p.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,l=Rt(),c=s||l,d=vy(Pd,n),f=d.currentTabStopId===c,m=Nd(n),{onFocusableItemAdd:h,onFocusableItemRemove:v,currentTabStopId:g}=d;return p.useEffect(()=>{if(r)return h(),()=>v()},[r,h,v]),u.jsx(ca.ItemSlot,{scope:n,id:c,focusable:r,active:o,children:u.jsx(ve.span,{tabIndex:f?0:-1,"data-orientation":d.orientation,...a,ref:t,onMouseDown:ce(e.onMouseDown,x=>{r?d.onItemFocus(c):x.preventDefault()}),onFocus:ce(e.onFocus,()=>d.onItemFocus(c)),onKeyDown:ce(e.onKeyDown,x=>{if(x.key==="Tab"&&x.shiftKey){d.onItemShiftTab();return}if(x.target!==x.currentTarget)return;const y=Sy(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?Cy(S,k+1):S.slice(k+1)}setTimeout(()=>Rd(S))}}),children:typeof i=="function"?i({isCurrentTabStop:f,hasTabStop:g!=null}):i})})});_d.displayName=Pd;var wy={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function yy(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Sy(e,t,n){const r=yy(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return wy[r]}function Rd(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function Cy(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Ty=jd,ky=_d,Ey=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Er=new WeakMap,cs=new WeakMap,us={},ua=0,Md=function(e){return e&&(e.host||Md(e.parentNode))},Iy=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=Md(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})},Ny=function(e,t,n,r){var o=Iy(t,Array.isArray(e)?e:[e]);us[n]||(us[n]=new WeakMap);var s=us[n],i=[],a=new Set,l=new Set(o),c=function(f){!f||a.has(f)||(a.add(f),c(f.parentNode))};o.forEach(c);var d=function(f){!f||l.has(f)||Array.prototype.forEach.call(f.children,function(m){if(a.has(m))d(m);else try{var h=m.getAttribute(r),v=h!==null&&h!=="false",g=(Er.get(m)||0)+1,x=(s.get(m)||0)+1;Er.set(m,g),s.set(m,x),i.push(m),g===1&&v&&cs.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(),ua++,function(){i.forEach(function(f){var m=Er.get(f)-1,h=s.get(f)-1;Er.set(f,m),s.set(f,h),m||(cs.has(f)||f.removeAttribute(r),cs.delete(f)),h||f.removeAttribute(n)}),ua--,ua||(Er=new WeakMap,Er=new WeakMap,cs=new WeakMap,us={})}},da=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=Ey(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),Ny(r,o,n,"aria-hidden")):function(){return null}},Cn=function(){return Cn=Object.assign||function(t){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])}return t},Cn.apply(this,arguments)};function Od(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 Ay(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 ds="right-scroll-bar-position",fs="width-before-scroll-bar",jy="with-scroll-bars-hidden",Py="--removed-body-scroll-bar-size";function fa(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function _y(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 Ry=typeof window<"u"?p.useLayoutEffect:p.useEffect,Dd=new WeakMap;function My(e,t){var n=_y(null,function(r){return e.forEach(function(o){return fa(o,r)})});return Ry(function(){var r=Dd.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||fa(a,null)}),s.forEach(function(a){o.has(a)||fa(a,i)})}Dd.set(n,e)},[e]),n}function Oy(e){return e}function Dy(e,t){t===void 0&&(t=Oy);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 Ly(e){e===void 0&&(e={});var t=Dy(null);return t.options=Cn({async:!0,ssr:!1},e),t}var Ld=function(e){var t=e.sideCar,n=Od(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return p.createElement(r,Cn({},n))};Ld.isSideCarExport=!0;function $y(e,t){return e.useMedium(t),Ld}var $d=Ly(),ha=function(){},hs=p.forwardRef(function(e,t){var n=p.useRef(null),r=p.useState({onScrollCapture:ha,onWheelCapture:ha,onTouchMoveCapture:ha}),o=r[0],s=r[1],i=e.forwardProps,a=e.children,l=e.className,c=e.removeScrollBar,d=e.enabled,f=e.shards,m=e.sideCar,h=e.noRelative,v=e.noIsolation,g=e.inert,x=e.allowPinchZoom,y=e.as,w=y===void 0?"div":y,S=e.gapMode,k=Od(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=m,T=My([n,t]),I=Cn(Cn({},k),o);return p.createElement(p.Fragment,null,d&&p.createElement(C,{sideCar:$d,removeScrollBar:c,shards:f,noRelative:h,noIsolation:v,inert:g,setCallbacks:s,allowPinchZoom:!!x,lockRef:n,gapMode:S}),i?p.cloneElement(p.Children.only(a),Cn(Cn({},I),{ref:T})):p.createElement(w,Cn({},I,{className:l,ref:T}),a))});hs.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},hs.classNames={fullWidth:fs,zeroRight:ds};var Fy=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function By(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Fy();return t&&e.setAttribute("nonce",t),e}function zy(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Hy(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var Uy=function(){var e=0,t=null;return{add:function(n){e==0&&(t=By())&&(zy(t,n),Hy(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Wy=function(){var e=Uy();return function(t,n){p.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Fd=function(){var e=Wy(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},Vy={left:0,top:0,right:0,gap:0},pa=function(e){return parseInt(e||"",10)||0},Ky=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[pa(n),pa(r),pa(o)]},qy=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Vy;var t=Ky(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])}},Gy=Fd(),Ir="data-scroll-locked",Yy=function(e,t,n,r){var o=e.left,s=e.top,i=e.right,a=e.gap;return n===void 0&&(n="margin"),`
|
|
40
40
|
.`.concat(jy,` {
|
|
41
41
|
overflow: hidden `).concat(r,`;
|
|
42
42
|
padding-right: `).concat(a,"px ").concat(r,`;
|
|
@@ -71,28 +71,28 @@ React keys must be passed directly to JSX without using spread:
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
body[`).concat(Ir,`] {
|
|
74
|
-
`).concat(
|
|
74
|
+
`).concat(Py,": ").concat(a,`px;
|
|
75
75
|
}
|
|
76
|
-
`)},Bd=function(){var e=parseInt(document.body.getAttribute(Ir)||"0",10);return isFinite(e)?e:0},Xy=function(){p.useEffect(function(){return document.body.setAttribute(Ir,(Bd()+1).toString()),function(){var e=Bd()-1;e<=0?document.body.removeAttribute(Ir):document.body.setAttribute(Ir,e.toString())}},[])},Jy=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;Xy();var s=p.useMemo(function(){return qy(o)},[o]);return p.createElement(Gy,{styles:Yy(s,!t,o,n?"":"!important")})},ma=!1;if(typeof window<"u")try{var ps=Object.defineProperty({},"passive",{get:function(){return ma=!0,!0}});window.addEventListener("test",ps,ps),window.removeEventListener("test",ps,ps)}catch{ma=!1}var Nr=ma?{passive:!1}:!1,Zy=function(e){return e.tagName==="TEXTAREA"},zd=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!Zy(e)&&n[t]==="visible")},Qy=function(e){return zd(e,"overflowY")},e0=function(e){return zd(e,"overflowX")},Hd=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=Ud(e,r);if(o){var s=Wd(e,r),i=s[1],a=s[2];if(i>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},t0=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},n0=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},Ud=function(e,t){return e==="v"?Qy(t):e0(t)},Wd=function(e,t){return e==="v"?t0(t):n0(t)},r0=function(e,t){return e==="h"&&t==="rtl"?-1:1},o0=function(e,t,n,r,o){var s=r0(e,window.getComputedStyle(t).direction),i=s*r,a=n.target,l=t.contains(a),c=!1,d=i>0,
|
|
76
|
+
`)},Bd=function(){var e=parseInt(document.body.getAttribute(Ir)||"0",10);return isFinite(e)?e:0},Xy=function(){p.useEffect(function(){return document.body.setAttribute(Ir,(Bd()+1).toString()),function(){var e=Bd()-1;e<=0?document.body.removeAttribute(Ir):document.body.setAttribute(Ir,e.toString())}},[])},Jy=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;Xy();var s=p.useMemo(function(){return qy(o)},[o]);return p.createElement(Gy,{styles:Yy(s,!t,o,n?"":"!important")})},ma=!1;if(typeof window<"u")try{var ps=Object.defineProperty({},"passive",{get:function(){return ma=!0,!0}});window.addEventListener("test",ps,ps),window.removeEventListener("test",ps,ps)}catch{ma=!1}var Nr=ma?{passive:!1}:!1,Zy=function(e){return e.tagName==="TEXTAREA"},zd=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!Zy(e)&&n[t]==="visible")},Qy=function(e){return zd(e,"overflowY")},e0=function(e){return zd(e,"overflowX")},Hd=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=Ud(e,r);if(o){var s=Wd(e,r),i=s[1],a=s[2];if(i>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},t0=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},n0=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},Ud=function(e,t){return e==="v"?Qy(t):e0(t)},Wd=function(e,t){return e==="v"?t0(t):n0(t)},r0=function(e,t){return e==="h"&&t==="rtl"?-1:1},o0=function(e,t,n,r,o){var s=r0(e,window.getComputedStyle(t).direction),i=s*r,a=n.target,l=t.contains(a),c=!1,d=i>0,f=0,m=0;do{if(!a)break;var h=Wd(e,a),v=h[0],g=h[1],x=h[2],y=g-x-s*v;(v||y)&&Ud(e,a)&&(f+=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(f)<1||!d&&Math.abs(m)<1)&&(c=!0),c},ms=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Vd=function(e){return[e.deltaX,e.deltaY]},Kd=function(e){return e&&"current"in e?e.current:e},s0=function(e,t){return e[0]===t[0]&&e[1]===t[1]},i0=function(e){return`
|
|
77
77
|
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
78
78
|
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
79
|
-
`)},a0=0,Ar=[];function l0(e){var t=p.useRef([]),n=p.useRef([0,0]),r=p.useRef(),o=p.useState(a0++)[0],s=p.useState(Fd)[0],i=p.useRef(e);p.useEffect(function(){i.current=e},[e]),p.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var g=Ay([e.lockRef.current],(e.shards||[]).map(Kd),!0).filter(Boolean);return g.forEach(function(x){return x.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),g.forEach(function(x){return x.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var a=p.useCallback(function(g,x){if("touches"in g&&g.touches.length===2||g.type==="wheel"&&g.ctrlKey)return!i.current.allowPinchZoom;var y=ms(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,I=Math.abs(S)>Math.abs(k)?"h":"v";if("touches"in g&&I==="h"&&T.type==="range")return!1;var N=Hd(I,T);if(!N)return!0;if(N?C=I:(C=I==="v"?"h":"v",N=Hd(I,T)),!N)return!1;if(!r.current&&"changedTouches"in g&&(S||k)&&(r.current=C),!C)return!0;var R=r.current||C;return o0(R,x,g,R==="h"?S:k)},[]),l=p.useCallback(function(g){var x=g;if(!(!Ar.length||Ar[Ar.length-1]!==s)){var y="deltaY"in x?Vd(x):ms(x),w=t.current.filter(function(C){return C.name===x.type&&(C.target===x.target||x.target===C.shadowParent)&&s0(C.delta,y)})[0];if(w&&w.should){x.cancelable&&x.preventDefault();return}if(!w){var S=(i.current.shards||[]).map(Kd).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=p.useCallback(function(g,x,y,w){var S={name:g,delta:x,target:y,should:w,shadowParent:c0(y)};t.current.push(S),setTimeout(function(){t.current=t.current.filter(function(k){return k!==S})},1)},[]),d=p.useCallback(function(g){n.current=ms(g),r.current=void 0},[]),h=p.useCallback(function(g){c(g.type,Vd(g),g.target,a(g,e.lockRef.current))},[]),m=p.useCallback(function(g){c(g.type,ms(g),g.target,a(g,e.lockRef.current))},[]);p.useEffect(function(){return Ar.push(s),e.setCallbacks({onScrollCapture:h,onWheelCapture:h,onTouchMoveCapture:m}),document.addEventListener("wheel",l,Nr),document.addEventListener("touchmove",l,Nr),document.addEventListener("touchstart",d,Nr),function(){Ar=Ar.filter(function(g){return g!==s}),document.removeEventListener("wheel",l,Nr),document.removeEventListener("touchmove",l,Nr),document.removeEventListener("touchstart",d,Nr)}},[]);var f=e.removeScrollBar,v=e.inert;return p.createElement(p.Fragment,null,v?p.createElement(s,{styles:i0(o)}):null,f?p.createElement(Jy,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function c0(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const u0=$y($d,l0);var gs=p.forwardRef(function(e,t){return p.createElement(hs,Cn({},e,{ref:t,sideCar:u0}))});gs.classNames=hs.classNames;var ga=["Enter"," "],d0=["ArrowDown","PageUp","Home"],qd=["ArrowUp","PageDown","End"],f0=[...d0,...qd],h0={ltr:[...ga,"ArrowRight"],rtl:[...ga,"ArrowLeft"]},p0={ltr:["ArrowLeft"],rtl:["ArrowRight"]},ao="Menu",[lo,m0,g0]=Yo(ao),[er,Gd]=cn(ao,[g0,kr,Ad]),xs=kr(),Yd=Ad(),[x0,tr]=er(ao),[v0,co]=er(ao),Xd=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=xs(t),[l,c]=p.useState(null),d=p.useRef(!1),h=pt(s),m=Xo(o);return p.useEffect(()=>{const f=()=>{d.current=!0,document.addEventListener("pointerdown",v,{capture:!0,once:!0}),document.addEventListener("pointermove",v,{capture:!0,once:!0})},v=()=>d.current=!1;return document.addEventListener("keydown",f,{capture:!0}),()=>{document.removeEventListener("keydown",f,{capture:!0}),document.removeEventListener("pointerdown",v,{capture:!0}),document.removeEventListener("pointermove",v,{capture:!0})}},[]),u.jsx(oa,{...a,children:u.jsx(x0,{scope:t,open:n,onOpenChange:h,content:l,onContentChange:c,children:u.jsx(v0,{scope:t,onClose:p.useCallback(()=>h(!1),[h]),isUsingKeyboardRef:d,dir:m,modal:i,children:r})})})};Xd.displayName=ao;var b0="MenuAnchor",xa=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=xs(n);return u.jsx(sa,{...o,...r,ref:t})});xa.displayName=b0;var va="MenuPortal",[w0,Jd]=er(va,{forceMount:void 0}),Zd=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=tr(va,t);return u.jsx(w0,{scope:t,forceMount:n,children:u.jsx(Wt,{present:n||s.open,children:u.jsx(so,{asChild:!0,container:o,children:r})})})};Zd.displayName=va;var nn="MenuContent",[y0,ba]=er(nn),Qd=p.forwardRef((e,t)=>{const n=Jd(nn,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=tr(nn,e.__scopeMenu),i=co(nn,e.__scopeMenu);return u.jsx(lo.Provider,{scope:e.__scopeMenu,children:u.jsx(Wt,{present:r||s.open,children:u.jsx(lo.Slot,{scope:e.__scopeMenu,children:i.modal?u.jsx(S0,{...o,ref:t}):u.jsx(C0,{...o,ref:t})})})})}),S0=p.forwardRef((e,t)=>{const n=tr(nn,e.__scopeMenu),r=p.useRef(null),o=Le(t,r);return p.useEffect(()=>{const s=r.current;if(s)return da(s)},[]),u.jsx(wa,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:ce(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),C0=p.forwardRef((e,t)=>{const n=tr(nn,e.__scopeMenu);return u.jsx(wa,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),T0=Yt.createSlot("MenuContent.ScrollLock"),wa=p.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:h,onInteractOutside:m,onDismiss:f,disableOutsideScroll:v,...g}=e,x=tr(nn,n),y=co(nn,n),w=xs(n),S=Yd(n),k=m0(n),[C,T]=p.useState(null),I=p.useRef(null),N=Le(t,I,x.onContentChange),R=p.useRef(0),O=p.useRef(""),$=p.useRef(0),V=p.useRef(null),U=p.useRef("right"),j=p.useRef(0),q=v?gs:p.Fragment,K=v?{as:T0,allowPinchZoom:!0}:void 0,D=E=>{var W,L;const B=O.current+E,Y=k().filter(X=>!X.disabled),_=document.activeElement,M=(W=Y.find(X=>X.ref.current===_))==null?void 0:W.textValue,G=Y.map(X=>X.textValue),J=D0(G,B,M),se=(L=Y.find(X=>X.textValue===J))==null?void 0:L.ref.current;(function X(ee){O.current=ee,window.clearTimeout(R.current),ee!==""&&(R.current=window.setTimeout(()=>X(""),1e3))})(B),se&&setTimeout(()=>se.focus())};p.useEffect(()=>()=>window.clearTimeout(R.current),[]),Hi();const P=p.useCallback(E=>{var Y,_;return U.current===((Y=V.current)==null?void 0:Y.side)&&$0(E,(_=V.current)==null?void 0:_.area)},[]);return u.jsx(y0,{scope:n,searchRef:O,onItemEnter:p.useCallback(E=>{P(E)&&E.preventDefault()},[P]),onItemLeave:p.useCallback(E=>{var B;P(E)||((B=I.current)==null||B.focus(),T(null))},[P]),onTriggerLeave:p.useCallback(E=>{P(E)&&E.preventDefault()},[P]),pointerGraceTimerRef:$,onPointerGraceIntentChange:p.useCallback(E=>{V.current=E},[]),children:u.jsx(q,{...K,children:u.jsx(Jo,{asChild:!0,trapped:o,onMountAutoFocus:ce(s,E=>{var B;E.preventDefault(),(B=I.current)==null||B.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:u.jsx(wr,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:h,onInteractOutside:m,onDismiss:f,children:u.jsx(Ty,{asChild:!0,...S,dir:y.dir,orientation:"vertical",loop:r,currentTabStopId:C,onCurrentTabStopIdChange:T,onEntryFocus:ce(l,E=>{y.isUsingKeyboardRef.current||E.preventDefault()}),preventScrollOnEntryFocus:!0,children:u.jsx(ia,{role:"menu","aria-orientation":"vertical","data-state":xf(x.open),"data-radix-menu-content":"",dir:y.dir,...w,...g,ref:N,style:{outline:"none",...g.style},onKeyDown:ce(g.onKeyDown,E=>{const Y=E.target.closest("[data-radix-menu-content]")===E.currentTarget,_=E.ctrlKey||E.altKey||E.metaKey,M=E.key.length===1;Y&&(E.key==="Tab"&&E.preventDefault(),!_&&M&&D(E.key));const G=I.current;if(E.target!==G||!f0.includes(E.key))return;E.preventDefault();const se=k().filter(W=>!W.disabled).map(W=>W.ref.current);qd.includes(E.key)&&se.reverse(),M0(se)}),onBlur:ce(e.onBlur,E=>{E.currentTarget.contains(E.target)||(window.clearTimeout(R.current),O.current="")}),onPointerMove:ce(e.onPointerMove,fo(E=>{const B=E.target,Y=j.current!==E.clientX;if(E.currentTarget.contains(B)&&Y){const _=E.clientX>j.current?"right":"left";U.current=_,j.current=E.clientX}}))})})})})})})});Qd.displayName=nn;var k0="MenuGroup",ya=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(ve.div,{role:"group",...r,ref:t})});ya.displayName=k0;var E0="MenuLabel",ef=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(ve.div,{...r,ref:t})});ef.displayName=E0;var vs="MenuItem",tf="menu.itemSelect",bs=p.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=p.useRef(null),i=co(vs,e.__scopeMenu),a=ba(vs,e.__scopeMenu),l=Le(t,s),c=p.useRef(!1),d=()=>{const h=s.current;if(!n&&h){const m=new CustomEvent(tf,{bubbles:!0,cancelable:!0});h.addEventListener(tf,f=>r==null?void 0:r(f),{once:!0}),Fi(h,m),m.defaultPrevented?c.current=!1:i.onClose()}};return u.jsx(nf,{...o,ref:l,disabled:n,onClick:ce(e.onClick,d),onPointerDown:h=>{var m;(m=e.onPointerDown)==null||m.call(e,h),c.current=!0},onPointerUp:ce(e.onPointerUp,h=>{var m;c.current||(m=h.currentTarget)==null||m.click()}),onKeyDown:ce(e.onKeyDown,h=>{const m=a.searchRef.current!=="";n||m&&h.key===" "||ga.includes(h.key)&&(h.currentTarget.click(),h.preventDefault())})})});bs.displayName=vs;var nf=p.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=ba(vs,n),a=Yd(n),l=p.useRef(null),c=Le(t,l),[d,h]=p.useState(!1),[m,f]=p.useState("");return p.useEffect(()=>{const v=l.current;v&&f((v.textContent??"").trim())},[s.children]),u.jsx(lo.ItemSlot,{scope:n,disabled:r,textValue:o??m,children:u.jsx(ky,{asChild:!0,...a,focusable:!r,children:u.jsx(ve.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:c,onPointerMove:ce(e.onPointerMove,fo(v=>{r?i.onItemLeave(v):(i.onItemEnter(v),v.defaultPrevented||v.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:ce(e.onPointerLeave,fo(v=>i.onItemLeave(v))),onFocus:ce(e.onFocus,()=>h(!0)),onBlur:ce(e.onBlur,()=>h(!1))})})})}),I0="MenuCheckboxItem",rf=p.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return u.jsx(cf,{scope:e.__scopeMenu,checked:n,children:u.jsx(bs,{role:"menuitemcheckbox","aria-checked":ws(n)?"mixed":n,...o,ref:t,"data-state":Ca(n),onSelect:ce(o.onSelect,()=>r==null?void 0:r(ws(n)?!0:!n),{checkForDefaultPrevented:!1})})})});rf.displayName=I0;var of="MenuRadioGroup",[N0,A0]=er(of,{value:void 0,onValueChange:()=>{}}),sf=p.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=pt(r);return u.jsx(N0,{scope:e.__scopeMenu,value:n,onValueChange:s,children:u.jsx(ya,{...o,ref:t})})});sf.displayName=of;var af="MenuRadioItem",lf=p.forwardRef((e,t)=>{const{value:n,...r}=e,o=A0(af,e.__scopeMenu),s=n===o.value;return u.jsx(cf,{scope:e.__scopeMenu,checked:s,children:u.jsx(bs,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":Ca(s),onSelect:ce(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});lf.displayName=af;var Sa="MenuItemIndicator",[cf,j0]=er(Sa,{checked:!1}),uf=p.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=j0(Sa,n);return u.jsx(Wt,{present:r||ws(s.checked)||s.checked===!0,children:u.jsx(ve.span,{...o,ref:t,"data-state":Ca(s.checked)})})});uf.displayName=Sa;var _0="MenuSeparator",df=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(ve.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});df.displayName=_0;var P0="MenuArrow",ff=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=xs(n);return u.jsx(aa,{...o,...r,ref:t})});ff.displayName=P0;var R0="MenuSub",[EN,hf]=er(R0),uo="MenuSubTrigger",pf=p.forwardRef((e,t)=>{const n=tr(uo,e.__scopeMenu),r=co(uo,e.__scopeMenu),o=hf(uo,e.__scopeMenu),s=ba(uo,e.__scopeMenu),i=p.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,c={__scopeMenu:e.__scopeMenu},d=p.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return p.useEffect(()=>d,[d]),p.useEffect(()=>{const h=a.current;return()=>{window.clearTimeout(h),l(null)}},[a,l]),u.jsx(xa,{asChild:!0,...c,children:u.jsx(nf,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":xf(n.open),...e,ref:On(t,o.onTriggerChange),onClick:h=>{var m;(m=e.onClick)==null||m.call(e,h),!(e.disabled||h.defaultPrevented)&&(h.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:ce(e.onPointerMove,fo(h=>{s.onItemEnter(h),!h.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(s.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),d()},100))})),onPointerLeave:ce(e.onPointerLeave,fo(h=>{var f,v;d();const m=(f=n.content)==null?void 0:f.getBoundingClientRect();if(m){const g=(v=n.content)==null?void 0:v.dataset.side,x=g==="right",y=x?-5:5,w=m[x?"left":"right"],S=m[x?"right":"left"];s.onPointerGraceIntentChange({area:[{x:h.clientX+y,y:h.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(h),h.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:ce(e.onKeyDown,h=>{var f;const m=s.searchRef.current!=="";e.disabled||m&&h.key===" "||h0[r.dir].includes(h.key)&&(n.onOpenChange(!0),(f=n.content)==null||f.focus(),h.preventDefault())})})})});pf.displayName=uo;var mf="MenuSubContent",gf=p.forwardRef((e,t)=>{const n=Jd(nn,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=tr(nn,e.__scopeMenu),i=co(nn,e.__scopeMenu),a=hf(mf,e.__scopeMenu),l=p.useRef(null),c=Le(t,l);return u.jsx(lo.Provider,{scope:e.__scopeMenu,children:u.jsx(Wt,{present:r||s.open,children:u.jsx(lo.Slot,{scope:e.__scopeMenu,children:u.jsx(wa,{id:a.contentId,"aria-labelledby":a.triggerId,...o,ref:c,align:"start",side:i.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:d=>{var h;i.isUsingKeyboardRef.current&&((h=l.current)==null||h.focus()),d.preventDefault()},onCloseAutoFocus:d=>d.preventDefault(),onFocusOutside:ce(e.onFocusOutside,d=>{d.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:ce(e.onEscapeKeyDown,d=>{i.onClose(),d.preventDefault()}),onKeyDown:ce(e.onKeyDown,d=>{var f;const h=d.currentTarget.contains(d.target),m=p0[i.dir].includes(d.key);h&&m&&(s.onOpenChange(!1),(f=a.trigger)==null||f.focus(),d.preventDefault())})})})})})});gf.displayName=mf;function xf(e){return e?"open":"closed"}function ws(e){return e==="indeterminate"}function Ca(e){return ws(e)?"indeterminate":e?"checked":"unchecked"}function M0(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function O0(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function D0(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=O0(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 L0(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const a=t[s],l=t[i],c=a.x,d=a.y,h=l.x,m=l.y;d>r!=m>r&&n<(h-c)*(r-d)/(m-d)+c&&(o=!o)}return o}function $0(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return L0(n,t)}function fo(e){return t=>t.pointerType==="mouse"?e(t):void 0}var F0=Xd,B0=xa,z0=Zd,H0=Qd,U0=ya,W0=ef,V0=bs,K0=rf,q0=sf,G0=lf,Y0=uf,X0=df,J0=ff,Z0=pf,Q0=gf,ys="DropdownMenu",[eS,IN]=cn(ys,[Gd]),Ft=Gd(),[tS,vf]=eS(ys),bf=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,l=Ft(t),c=p.useRef(null),[d,h]=Dn({prop:o,defaultProp:s??!1,onChange:i,caller:ys});return u.jsx(tS,{scope:t,triggerId:Rt(),triggerRef:c,contentId:Rt(),open:d,onOpenChange:h,onOpenToggle:p.useCallback(()=>h(m=>!m),[h]),modal:a,children:u.jsx(F0,{...l,open:d,onOpenChange:h,dir:r,modal:a,children:n})})};bf.displayName=ys;var wf="DropdownMenuTrigger",yf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=vf(wf,n),i=Ft(n);return u.jsx(B0,{asChild:!0,...i,children:u.jsx(ve.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:On(t,s.triggerRef),onPointerDown:ce(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:ce(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});yf.displayName=wf;var nS="DropdownMenuPortal",Sf=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Ft(t);return u.jsx(z0,{...r,...n})};Sf.displayName=nS;var Cf="DropdownMenuContent",Tf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=vf(Cf,n),s=Ft(n),i=p.useRef(!1);return u.jsx(H0,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:ce(e.onCloseAutoFocus,a=>{var l;i.current||(l=o.triggerRef.current)==null||l.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:ce(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)"}})});Tf.displayName=Cf;var rS="DropdownMenuGroup",oS=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ft(n);return u.jsx(U0,{...o,...r,ref:t})});oS.displayName=rS;var sS="DropdownMenuLabel",kf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ft(n);return u.jsx(W0,{...o,...r,ref:t})});kf.displayName=sS;var iS="DropdownMenuItem",Ef=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ft(n);return u.jsx(V0,{...o,...r,ref:t})});Ef.displayName=iS;var aS="DropdownMenuCheckboxItem",If=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ft(n);return u.jsx(K0,{...o,...r,ref:t})});If.displayName=aS;var lS="DropdownMenuRadioGroup",cS=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ft(n);return u.jsx(q0,{...o,...r,ref:t})});cS.displayName=lS;var uS="DropdownMenuRadioItem",Nf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ft(n);return u.jsx(G0,{...o,...r,ref:t})});Nf.displayName=uS;var dS="DropdownMenuItemIndicator",Af=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ft(n);return u.jsx(Y0,{...o,...r,ref:t})});Af.displayName=dS;var fS="DropdownMenuSeparator",jf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ft(n);return u.jsx(X0,{...o,...r,ref:t})});jf.displayName=fS;var hS="DropdownMenuArrow",pS=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ft(n);return u.jsx(J0,{...o,...r,ref:t})});pS.displayName=hS;var mS="DropdownMenuSubTrigger",_f=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ft(n);return u.jsx(Z0,{...o,...r,ref:t})});_f.displayName=mS;var gS="DropdownMenuSubContent",Pf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ft(n);return u.jsx(Q0,{...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)"}})});Pf.displayName=gS;var xS=bf,vS=yf,bS=Sf,Rf=Tf,Mf=kf,Of=Ef,Df=If,Lf=Nf,$f=Af,Ff=jf,Bf=_f,zf=Pf;const Ss=xS,Cs=vS,wS=p.forwardRef(({className:e,inset:t,children:n,...r},o)=>u.jsxs(Bf,{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(ue.ChevronRight,{className:"ml-auto h-4 w-4"})]}));wS.displayName=Bf.displayName;const yS=p.forwardRef(({className:e,...t},n)=>u.jsx(zf,{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}));yS.displayName=zf.displayName;const ho=p.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(bS,{children:u.jsx(Rf,{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})}));ho.displayName=Rf.displayName;const Bn=p.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(Of,{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}));Bn.displayName=Of.displayName;const SS=p.forwardRef(({className:e,children:t,checked:n,...r},o)=>u.jsxs(Df,{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($f,{children:u.jsx(ue.Check,{className:"h-4 w-4"})})}),t]}));SS.displayName=Df.displayName;const CS=p.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Lf,{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($f,{children:u.jsx(ue.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));CS.displayName=Lf.displayName;const TS=p.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(Mf,{ref:r,className:re("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));TS.displayName=Mf.displayName;const kS=p.forwardRef(({className:e,...t},n)=>u.jsx(Ff,{ref:n,className:re("-mx-1 my-1 h-px bg-muted",e),...t}));kS.displayName=Ff.displayName;const Ta=p.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}));Ta.displayName="Textarea";const ES=1e4;function Hf({initialValue:e="",editingMessageId:t=null,placeholder:n="Type your message...",isStreaming:r=!1,disabled:o=!1,maxLength:s=ES,value:i,onValueChange:a,onSend:l,onCancelEdit:c,onStop:d,className:h="",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),I=b.useRef(0),N=b.useRef(null),R=b.useRef("");b.useEffect(()=>{x||(w(e??""),N.current=null,T.current&&(T.current.style.height="auto",T.current.style.height=`${T.current.scrollHeight}px`))},[e,t,x]);const[O,$]=b.useState(null),V=b.useCallback(M=>M.length>s?`Message too long (${M.length}/${s} characters)`:null,[s]),U=b.useMemo(()=>v??V,[v,V]),j=b.useCallback(M=>{const G=U(M);return $(G),g==null||g(G),R.current=M,G},[U,g]),q=b.useCallback(()=>{const M=T.current;M&&(M.style.height="auto",M.style.height=`${M.scrollHeight}px`)},[]);b.useEffect(()=>{q()},[q,S]),b.useEffect(()=>{if(!O)return;const M=(S??"").trim();R.current!==M&&j(M)},[S,O,j]);const K=b.useCallback((M,{fromUser:G})=>{x||w(M),G&&(a==null||a(M))},[x,a]),D=b.useCallback(async M=>{M&&M.preventDefault();const G=(S??"").trim();if(!G&&!f||j(G))return;const J=++I.current;N.current={id:J,shouldClear:!0},C(()=>{var se,W,L;try{const X=l(G);X&&typeof X.then=="function"?X.then(()=>{var ee,Z;((ee=N.current)==null?void 0:ee.id)===J&&N.current.shouldClear&&(x||(w(""),T.current&&(T.current.style.height="auto"),a==null||a(""))),((Z=N.current)==null?void 0:Z.id)===J&&(N.current=null)}).catch(()=>{var ee;((ee=N.current)==null?void 0:ee.id)===J&&(N.current=null)}):(((se=N.current)==null?void 0:se.id)===J&&N.current.shouldClear&&(x||(w(""),T.current&&(T.current.style.height="auto"),a==null||a(""))),((W=N.current)==null?void 0:W.id)===J&&(N.current=null))}catch{((L=N.current)==null?void 0:L.id)===J&&(N.current=null)}})},[S,l,f,x,a,j]),P=b.useCallback(M=>{const G=M.target.value;K(G,{fromUser:!0}),N.current&&(N.current.shouldClear=!1),T.current&&(T.current.style.height="auto",T.current.style.height=`${T.current.scrollHeight}px`),O&&j(G.trim())},[K,j,O]),E=b.useCallback(M=>{M.key==="Enter"&&!M.shiftKey?(M.preventDefault(),D()):M.key==="Escape"&&t&&(M.preventDefault(),c==null||c())},[D,t,c]),_=`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${t?"border-[hsl(var(--ring))] bg-[hsl(var(--card))] text-[hsl(var(--card-foreground))] dark:bg-[hsl(var(--card))] dark:text-[hsl(var(--card-foreground))]":""} ${m}`;return u.jsx("form",{onSubmit:M=>void D(M),className:`w-full ${h}`,children:u.jsxs("div",{className:"flex items-end gap-2",children:[u.jsxs("div",{className:"flex-1",children:[u.jsx(Ta,{ref:T,value:S,onChange:P,onKeyDown:E,placeholder:t?"Edit your message...":n,className:_,disabled:o,maxLength:s,rows:1,spellCheck:!1,autoCorrect:"off"}),O&&u.jsx("p",{className:"mt-1 text-xs text-destructive font-medium",children:O})]}),u.jsx("div",{children:r?u.jsx(Qe,{type:"button",onClick:()=>{d==null||d()},size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",disabled:o||!d,children:u.jsx(ue.Square,{size:16})}):u.jsx(Qe,{type:"submit",size:"icon",className:"shrink-0",title:t?"Save changes":"Send message",disabled:o||!S.trim()&&!f||k,children:u.jsx(ue.Send,{size:16})})})]})})}const IS=b.memo(Hf),Ts=0,zn=1,jr=2,Uf=4;function Wf(e){return()=>e}function NS(e){e()}function Vf(e,t){return n=>e(t(n))}function Kf(e,t){return()=>e(t)}function AS(e,t){return n=>e(t,n)}function ka(e){return e!==void 0}function jS(...e){return()=>{e.map(NS)}}function _r(){}function ks(e,t){return t(e),e}function _S(e,t){return t(e)}function rt(...e){return e}function Je(e,t){return e(zn,t)}function Me(e,t){e(Ts,t)}function Ea(e){e(jr)}function mt(e){return e(Uf)}function be(e,t){return Je(e,AS(t,Ts))}function fn(e,t){const n=e(zn,r=>{n(),t(r)});return n}function qf(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function Gf(e,t){return e===t}function ot(e=Gf){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function Ne(e){return t=>n=>{e(n)&&t(n)}}function he(e){return t=>Vf(t,e)}function Tn(e){return t=>()=>{t(e)}}function ne(e,...t){const n=PS(...t);return(r,o)=>{switch(r){case jr:Ea(e);return;case zn:return Je(e,n(o))}}}function kn(e,t){return n=>r=>{n(t=e(t,r))}}function nr(e){return t=>n=>{e>0?e--:t(n)}}function jn(e){let t=null,n;return r=>o=>{t=o,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function $e(...e){const t=new Array(e.length);let n=0,r=null;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const a=Math.pow(2,i);Je(s,l=>{const c=n;n=n|a,t[i]=l,c!==o&&n===o&&r&&(r(),r=null)})}),s=>i=>{const a=()=>{s([i].concat(t))};n===o?a():r=a}}function PS(...e){return t=>e.reduceRight(_S,t)}function RS(e){let t,n;const r=()=>t==null?void 0:t();return function(o,s){switch(o){case zn:return s?n===s?void 0:(r(),n=s,t=Je(e,s),t):(r(),_r);case jr:r(),n=null;return}}}function oe(e){let t=e;const n=He();return(r,o)=>{switch(r){case Ts:t=o;break;case zn:{o(t);break}case Uf:return t}return n(r,o)}}function Mt(e,t){return ks(oe(t),n=>be(e,n))}function He(){const e=[];return(t,n)=>{switch(t){case Ts:e.slice().forEach(r=>{r(n)});return;case jr:e.splice(0,e.length);return;case zn:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}}}function en(e){return ks(He(),t=>be(e,t))}function qe(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:MS(),singleton:n}}const MS=()=>Symbol();function OS(e){const t=new Map,n=({constructor:r,dependencies:o,id:s,singleton:i})=>{if(i&&t.has(s))return t.get(s);const a=r(o.map(l=>n(l)));return i&&t.set(s,a),a};return n(e)}function vt(...e){const t=He(),n=new Array(e.length);let r=0;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const a=Math.pow(2,i);Je(s,l=>{n[i]=l,r=r|a,r===o&&Me(t,n)})}),function(s,i){switch(s){case jr:{Ea(t);return}case zn:return r===o&&i(n),Je(t,i)}}}function Ee(e,t=Gf){return ne(e,ot(t))}function Ia(...e){return function(t,n){switch(t){case jr:return;case zn:return jS(...e.map(r=>Je(r,n)))}}}var Vt=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(Vt||{});const DS={0:"debug",3:"error",1:"log",2:"warn"},LS=()=>typeof globalThis>"u"?window:globalThis,Hn=qe(()=>{const e=oe(3);return{log:oe((t,n,r=1)=>{var o;const s=(o=LS().VIRTUOSO_LOG_LEVEL)!=null?o:mt(e);r>=s&&console[DS[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0});function rr(e,t,n){return Na(e,t,n).callbackRef}function Na(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 $S(e,t,n,r,o,s,i,a,l){const c=b.useCallback(d=>{const h=FS(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?Yf("column-gap",getComputedStyle(d).columnGap,o):Yf("row-gap",getComputedStyle(d).rowGap,o)),h!==null&&e(h)},[e,t,o,s,i,r,a]);return Na(c,n,l)}function FS(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},Vt.ERROR),d===c)continue;const h=s[s.length-1];s.length===0||h.size!==d||h.endIndex!==l-1?s.push({endIndex:l,size:d,startIndex:l}):s[s.length-1].endIndex++}return s}function Yf(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Vt.WARN),t==="normal"?0:parseInt(t??"0",10)}function Xf(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 h,m;if(t){const f=t.getBoundingClientRect(),v=c.top-f.top;m=f.height-Math.max(0,v),h=v+t.scrollTop}else{const f=i.current.ownerDocument.defaultView;m=f.innerHeight-Math.max(0,c.top),h=c.top+f.scrollY}r.current={offsetTop:h,visibleHeight:m,visibleWidth:d},e(r.current)},[e,t]),{callbackRef:s,ref:i}=Na(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 Bt=qe(()=>{const e=He(),t=He(),n=oe(0),r=He(),o=oe(0),s=He(),i=He(),a=oe(0),l=oe(0),c=oe(0),d=oe(0),h=He(),m=He(),f=oe(!1),v=oe(!1),g=oe(!1);return be(ne(e,he(({scrollTop:x})=>x)),t),be(ne(e,he(({scrollHeight:x})=>x)),i),be(t,o),{deviation:n,fixedFooterHeight:c,fixedHeaderHeight:l,footerHeight:d,headerHeight:a,horizontalDirection:v,scrollBy:m,scrollContainerState:e,scrollHeight:i,scrollingInProgress:f,scrollTo:h,scrollTop:t,skipAnimationFrameInResizeObserver:g,smoothScrollTargetReached:r,statefulScrollTop:o,viewportHeight:s}},[],{singleton:!0}),po={lvl:0};function Jf(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 tt(e){return e===po}function mo(e,t){if(!tt(e))return t===e.k?e.v:t<e.k?mo(e.l,t):mo(e.r,t)}function hn(e,t,n="k"){if(tt(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){const r=hn(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return hn(e.l,t,n)}function tn(e,t,n){return tt(e)?eh(t,n,1):t===e.k?wt(e,{k:t,v:n}):t<e.k?th(wt(e,{l:tn(e.l,t,n)})):th(wt(e,{r:tn(e.r,t,n)}))}function Pr(){return po}function Es(e,t,n){if(tt(e))return[];const r=hn(e,t)[0];return BS(ja(e,r,n))}function Aa(e,t){if(tt(e))return po;const{k:n,l:r,r:o}=e;if(t===n){if(tt(r))return o;if(tt(o))return r;{const[s,i]=Qf(r);return Is(wt(e,{k:s,l:Zf(r),v:i}))}}else return t<n?Is(wt(e,{l:Aa(r,t)})):Is(wt(e,{r:Aa(o,t)}))}function or(e){return tt(e)?[]:[...or(e.l),{k:e.k,v:e.v},...or(e.r)]}function ja(e,t,n){if(tt(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 Is(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(_a(t))return nh(wt(e,{lvl:n-1}));if(!tt(t)&&!tt(t.r))return wt(t.r,{l:wt(t,{r:t.r.l}),lvl:n,r:wt(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(_a(e))return Pa(wt(e,{lvl:n-1}));if(!tt(r)&&!tt(r.l)){const o=r.l,s=_a(o)?r.lvl-1:r.lvl;return wt(o,{l:wt(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:Pa(wt(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function wt(e,t){return eh(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 Zf(e){return tt(e.r)?e.l:Is(wt(e,{r:Zf(e.r)}))}function _a(e){return tt(e)||e.lvl>e.r.lvl}function Qf(e){return tt(e.r)?[e.k,e.v]:Qf(e.r)}function eh(e,t,n,r=po,o=po){return{k:e,l:r,lvl:n,r:o,v:t}}function th(e){return Pa(nh(e))}function nh(e){const{l:t}=e;return!tt(t)&&t.lvl===e.lvl?wt(t,{r:wt(e,{l:t.r})}):e}function Pa(e){const{lvl:t,r:n}=e;return!tt(n)&&!tt(n.r)&&n.lvl===t&&n.r.lvl===t?wt(n,{l:wt(e,{r:n.l}),lvl:t+1}):e}function BS(e){return Jf(e,({k:t,v:n})=>({index:t,value:n}))}function rh(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function go(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const Ra=qe(()=>({recalcInProgress:oe(!1)}),[],{singleton:!0});function oh(e,t,n){return e[Ns(e,t,n)]}function Ns(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 zS(e,t,n,r){const o=Ns(e,t,r),s=Ns(e,n,r,o);return e.slice(o,s+1)}function Un(e,t){return Math.round(e.getBoundingClientRect()[t])}function As(e){return!tt(e.groupOffsetTree)}function Ma({index:e},t){return t===e?0:t<e?-1:1}function HS(){return{groupIndices:[],groupOffsetTree:Pr(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Pr()}}function US(e,t){let n=tt(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),tt(e)){e=tn(e,0,s);continue}const a=Es(e,i-1,o+1);if(a.some(XS(r)))continue;let l=!1,c=!1;for(const{end:d,start:h,value:m}of a)l?(o>=h||s===m)&&(e=Aa(e,h)):(c=m!==s,l=!0),d>o&&o>=h&&m!==s&&(e=tn(e,o+1,m));c&&(e=tn(e,i,s))}return[e,n]}function WS(e){return typeof e.groupIndex<"u"}function VS({offset:e},t){return t===e?0:t<e?-1:1}function xo(e,t,n){if(t.length===0)return 0;const{index:r,offset:o,size:s}=oh(t,e,Ma),i=e-r,a=s*i+(i-1)*n+o;return a>0?a+n:a}function sh(e,t){if(!As(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function ih(e,t,n){if(WS(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=sh(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function KS(e,t,n,r=0){return r>0&&(t=Math.max(t,oh(e,r,Ma).offset)),Jf(zS(e,t,n,VS),YS)}function qS(e,[t,n,r,o]){t.length>0&&r("received item sizes",t,Vt.DEBUG);const s=e.sizeTree;let i=s,a=0;if(n.length>0&&tt(s)&&t.length===2){const m=t[0].size,f=t[1].size;i=n.reduce((v,g)=>tn(tn(v,g,m),g+1,f),i)}else[i,a]=US(i,t);if(i===s)return e;const{lastIndex:l,lastOffset:c,lastSize:d,offsetTree:h}=Oa(e.offsetTree,a,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((m,f)=>tn(m,f,xo(f,h,o)),Pr()),lastIndex:l,lastOffset:c,lastSize:d,offsetTree:h,sizeTree:i}}function GS(e){return or(e).map(({k:t,v:n},r,o)=>{const s=o[r+1];return{endIndex:s?s.k-1:1/0,size:n,startIndex:t}})}function ah(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 Oa(e,t,n,r){let o=e,s=0,i=0,a=0,l=0;if(t!==0){l=Ns(o,t-1,Ma),a=o[l].offset;const c=hn(n,t-1);s=c[0],i=c[1],o.length&&o[l].size===hn(n,t)[1]&&(l-=1),o=o.slice(0,l+1)}else o=[];for(const{start:c,value:d}of Es(n,t,1/0)){const h=c-s,m=h*i+a+h*r;o.push({index:c,offset:m,size:d}),s=c,a=m,i=d}return{lastIndex:s,lastOffset:a,lastSize:i,offsetTree:o}}function YS(e){return{index:e.index,value:e}}function XS(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 JS={offsetHeight:"height",offsetWidth:"width"},En=qe(([{log:e},{recalcInProgress:t}])=>{const n=He(),r=He(),o=Mt(r,0),s=He(),i=He(),a=oe(0),l=oe([]),c=oe(void 0),d=oe(void 0),h=oe((C,T)=>Un(C,JS[T])),m=oe(void 0),f=oe(0),v=HS(),g=Mt(ne(n,$e(l,e,f),kn(qS,v),ot()),v),x=Mt(ne(l,ot(),kn((C,T)=>({current:T,prev:C.current}),{current:[],prev:[]}),he(({prev:C})=>C)),[]);be(ne(l,Ne(C=>C.length>0),$e(g,f),he(([C,T,I])=>{const N=C.reduce((R,O,$)=>tn(R,O,xo(O,T.offsetTree,I)||$),Pr());return{...T,groupIndices:C,groupOffsetTree:N}})),g),be(ne(r,$e(g),Ne(([C,{lastIndex:T}])=>C<T),he(([C,{lastIndex:T,lastSize:I}])=>[{endIndex:T,size:I,startIndex:C}])),n),be(c,d);const y=Mt(ne(c,he(C=>C===void 0)),!0);be(ne(d,Ne(C=>C!==void 0&&tt(mt(g).sizeTree)),he(C=>[{endIndex:0,size:C,startIndex:0}])),n);const w=en(ne(n,$e(g),kn(({sizes:C},[T,I])=>({changed:I!==C,sizes:I}),{changed:!1,sizes:v}),he(C=>C.changed)));Je(ne(a,kn((C,T)=>({diff:C.prev-T,prev:T}),{diff:0,prev:0}),he(C=>C.diff)),C=>{const{groupIndices:T}=mt(g);if(C>0)Me(t,!0),Me(s,C+ah(C,T));else if(C<0){const I=mt(x);I.length>0&&(C-=ah(-C,I)),Me(i,C)}}),Je(ne(a,$e(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},Vt.ERROR)});const S=en(s);be(ne(s,$e(g),he(([C,T])=>{const I=T.groupIndices.length>0,N=[],R=T.lastSize;if(I){const O=mo(T.sizeTree,0);let $=0,V=0;for(;$<C;){const j=T.groupIndices[V],q=T.groupIndices.length===V+1?1/0:T.groupIndices[V+1]-j-1;N.push({endIndex:j,size:O,startIndex:j}),N.push({endIndex:j+1+q-1,size:R,startIndex:j+1}),V++,$+=q+1}const U=or(T.sizeTree);return $!==C&&U.shift(),U.reduce((j,{k:q,v:K})=>{let D=j.ranges;return j.prevSize!==0&&(D=[...j.ranges,{endIndex:q+C-1,size:j.prevSize,startIndex:j.prevIndex}]),{prevIndex:q+C,prevSize:K,ranges:D}},{prevIndex:C,prevSize:0,ranges:N}).ranges}return or(T.sizeTree).reduce((O,{k:$,v:V})=>({prevIndex:$+C,prevSize:V,ranges:[...O.ranges,{endIndex:$+C-1,size:O.prevSize,startIndex:O.prevIndex}]}),{prevIndex:0,prevSize:R,ranges:[]}).ranges})),n);const k=en(ne(i,$e(g,f),he(([C,{offsetTree:T},I])=>{const N=-C;return xo(N,T,I)})));return be(ne(i,$e(g,f),he(([C,T,I])=>{if(T.groupIndices.length>0){if(tt(T.sizeTree))return T;let N=Pr();const R=mt(x);let O=0,$=0,V=0;for(;O<-C;){V=R[$];const U=R[$+1]-V-1;$++,O+=U+1}if(N=or(T.sizeTree).reduce((U,{k:j,v:q})=>tn(U,Math.max(0,j+C),q),N),O!==-C){const U=mo(T.sizeTree,V);N=tn(N,0,U);const j=hn(T.sizeTree,-C+1)[1];N=tn(N,1,j)}return{...T,sizeTree:N,...Oa(T.offsetTree,0,N,I)}}else{const N=or(T.sizeTree).reduce((R,{k:O,v:$})=>tn(R,Math.max(0,O+C),$),Pr());return{...T,sizeTree:N,...Oa(T.offsetTree,0,N,I)}}})),g),{beforeUnshiftWith:S,data:m,defaultItemSize:d,firstItemIndex:a,fixedItemSize:c,gap:f,groupIndices:l,itemSize:h,listRefresh:w,shiftWith:i,shiftWithOffset:k,sizeRanges:n,sizes:g,statefulTotalCount:o,totalCount:r,trackItemSizes:y,unshiftWith:s}},rt(Hn,Ra),{singleton:!0});function ZS(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const lh=qe(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=He(),i=He(),a=en(ne(s,he(ZS)));return be(ne(a,he(l=>l.totalCount)),n),be(ne(a,he(l=>l.groupIndices)),e),be(ne(vt(o,t,r),Ne(([l,c])=>As(c)),he(([l,c,d])=>hn(c.groupOffsetTree,Math.max(l-d,0),"v")[0]),ot(),he(l=>[l])),i),{groupCounts:s,topItemsIndexes:i}},rt(En,Bt)),Wn=qe(([{log:e}])=>{const t=oe(!1),n=en(ne(t,Ne(r=>r),ot()));return Je(t,r=>{r&&mt(e)("props updated",{},Vt.DEBUG)}),{didMount:n,propsReady:t}},rt(Hn),{singleton:!0}),QS=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function ch(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!QS)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const vo=qe(([{gap:e,listRefresh:t,sizes:n,totalCount:r},{fixedFooterHeight:o,fixedHeaderHeight:s,footerHeight:i,headerHeight:a,scrollingInProgress:l,scrollTo:c,smoothScrollTargetReached:d,viewportHeight:h},{log:m}])=>{const f=He(),v=He(),g=oe(0);let x=null,y=null,w=null;function S(){x&&(x(),x=null),w&&(w(),w=null),y&&(clearTimeout(y),y=null),Me(l,!1)}return be(ne(f,$e(n,h,r,g,a,i,m),$e(e,s,o),he(([[k,C,T,I,N,R,O,$],V,U,j])=>{const q=ch(k),{align:K,behavior:D,offset:P}=q,E=I-1,B=ih(q,C,E);let Y=xo(B,C.offsetTree,V)+R;K==="end"?(Y+=U+hn(C.sizeTree,B)[1]-T+j,B===E&&(Y+=O)):K==="center"?Y+=(U+hn(C.sizeTree,B)[1]-T+j)/2:Y-=N,P&&(Y+=P);const _=M=>{S(),M?($("retrying to scroll to",{location:k},Vt.DEBUG),Me(f,k)):(Me(v,!0),$("list did not change, scroll successful",{},Vt.DEBUG))};if(S(),D==="smooth"){let M=!1;w=Je(t,G=>{M=M||G}),x=fn(d,()=>{_(M)})}else x=fn(ne(t,eC(150)),_);return y=setTimeout(()=>{S()},1200),Me(l,!0),$("scrolling from index to",{behavior:D,index:B,top:Y},Vt.DEBUG),{behavior:D,top:Y}})),c),{scrollTargetReached:v,scrollToIndex:f,topListHeight:g}},rt(En,Bt,Hn),{singleton:!0});function eC(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function Da(e,t){e==0?t():requestAnimationFrame(()=>{Da(e-1,t)})}function La(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const bo=qe(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:s},{didMount:i}])=>{const a=oe(!0),l=oe(0),c=oe(!0);return be(ne(i,$e(l),Ne(([d,h])=>!!h),Tn(!1)),a),be(ne(i,$e(l),Ne(([d,h])=>!!h),Tn(!1)),c),Je(ne(vt(t,i),$e(a,n,e,c),Ne(([[,d],h,{sizeTree:m},f,v])=>d&&(!tt(m)||ka(f))&&!h&&!v),$e(l)),([,d])=>{fn(o,()=>{Me(c,!0)}),Da(4,()=>{fn(r,()=>{Me(a,!0)}),Me(s,d)})}),{initialItemFinalLocationReached:c,initialTopMostItemIndex:l,scrolledToInitialItem:a}},rt(En,Bt,vo,Wn),{singleton:!0});function uh(e,t){return Math.abs(e-t)<1.01}const wo="up",yo="down",tC="none",nC={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},rC=0,So=qe(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=oe(!1),a=oe(!0),l=He(),c=He(),d=oe(4),h=oe(rC),m=Mt(ne(Ia(ne(Ee(o),nr(1),Tn(!0)),ne(Ee(o),nr(1),Tn(!1),qf(100))),ot()),!1),f=Mt(ne(Ia(ne(n,Tn(!0)),ne(n,Tn(!1),qf(200))),ot()),!1);be(ne(vt(Ee(o),Ee(h)),he(([w,S])=>w<=S),ot()),a),be(ne(a,jn(50)),c);const v=en(ne(vt(r,Ee(s),Ee(t),Ee(e),Ee(d)),kn((w,[{scrollHeight:S,scrollTop:k},C,T,I,N])=>{const R=k+C-S>-N,O={scrollHeight:S,scrollTop:k,viewportHeight:C};if(R){let V,U;return k>w.state.scrollTop?(V="SCROLLED_DOWN",U=w.state.scrollTop-k):(V="SIZE_DECREASED",U=w.state.scrollTop-k||w.scrollTopDelta),{atBottom:!0,atBottomBecause:V,scrollTopDelta:U,state:O}}let $;return O.scrollHeight>w.state.scrollHeight?$="SIZE_INCREASED":C<w.state.viewportHeight?$="VIEWPORT_HEIGHT_DECREASING":k<w.state.scrollTop?$="SCROLLING_UPWARDS":$="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:$,state:O}},nC),ot((w,S)=>w&&w.atBottom===S.atBottom))),g=Mt(ne(r,kn((w,{scrollHeight:S,scrollTop:k,viewportHeight:C})=>{if(uh(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}),Ne(w=>w.changed),he(w=>w.jump)),0);be(ne(v,he(w=>w.atBottom)),i),be(ne(i,jn(50)),l);const x=oe(yo);be(ne(r,he(({scrollTop:w})=>w),ot(),kn((w,S)=>mt(f)?{direction:w.direction,prevScrollTop:S}:{direction:S<w.prevScrollTop?wo:yo,prevScrollTop:S},{direction:yo,prevScrollTop:0}),he(w=>w.direction)),x),be(ne(r,jn(50),Tn(tC)),x);const y=oe(0);return be(ne(m,Ne(w=>!w),Tn(0)),y),be(ne(o,jn(100),$e(m),Ne(([w,S])=>!!S),kn(([w,S],[k])=>[S,k],[0,0]),he(([w,S])=>S-w)),y),{atBottomState:v,atBottomStateChange:l,atBottomThreshold:d,atTopStateChange:c,atTopThreshold:h,isAtBottom:i,isAtTop:a,isScrolling:m,lastJumpDueToItemResize:g,scrollDirection:x,scrollVelocity:y}},rt(Bt)),js="top",_s="bottom",dh="none";function fh(e,t,n){return typeof e=="number"?n===wo&&t===js||n===yo&&t===_s?e:0:n===wo?t===js?e.main:e.reverse:t===_s?e.main:e.reverse}function hh(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const $a=qe(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=He(),i=oe(0),a=oe(0),l=oe(0),c=Mt(ne(vt(Ee(r),Ee(o),Ee(n),Ee(s,go),Ee(l),Ee(i),Ee(t),Ee(e),Ee(a)),he(([d,h,m,[f,v],g,x,y,w,S])=>{const k=d-w,C=x+y,T=Math.max(m-k,0);let I=dh;const N=hh(S,js),R=hh(S,_s);return f-=w,f+=m+y,v+=m+y,v-=w,f>d+C-N&&(I=wo),v<d-T+h+R&&(I=yo),I!==dh?[Math.max(k-m-fh(g,js,I)-N,0),k-T-y+h+fh(g,_s,I)+R]:null}),Ne(d=>d!=null),ot(go)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:l,topListHeight:i,visibleRange:c}},rt(Bt),{singleton:!0});function oC(e,t,n){if(As(t)){const r=sh(e,t);return[{index:hn(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 Fa={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Ps(e,t,n,r,o,s){const{lastIndex:i,lastOffset:a,lastSize:l}=o;let c=0,d=0;if(e.length>0){c=e[0].offset;const g=e[e.length-1];d=g.offset+g.size}const h=n-i,m=a+h*l+(h-1)*r,f=c,v=m-d;return{bottom:d,firstItemIndex:s,items:mh(e,o,s),offsetBottom:v,offsetTop:c,top:f,topItems:mh(t,o,s),topListHeight:t.reduce((g,x)=>x.size+g,0),totalCount:n}}function ph(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=La(t,a),c=Array.from({length:a}).map((d,h)=>({data:s[h+l],index:h+l,offset:0,size:0}));return Ps(c,[],a,o,n,r)}function mh(e,t,n){if(e.length===0)return[];if(!As(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=Es(t.groupOffsetTree,r,o);let a,l=0;for(const c of e){(!a||a.end<c.index)&&(a=i.shift(),l=t.groupIndices.indexOf(a.start));let d;c.index===a.start?d={index:l,type:"group"}:d={groupIndex:l,index:c.index-(l+1)+n},s.push({...d,data:c.data,offset:c.offset,originalIndex:c.index,size:c.size})}return s}const sr=qe(([{data:e,firstItemIndex:t,gap:n,sizes:r,totalCount:o},s,{listBoundary:i,topListHeight:a,visibleRange:l},{initialTopMostItemIndex:c,scrolledToInitialItem:d},{topListHeight:h},m,{didMount:f},{recalcInProgress:v}])=>{const g=oe([]),x=oe(0),y=He();be(s.topItemsIndexes,g);const w=Mt(ne(vt(f,v,Ee(l,go),Ee(o),Ee(r),Ee(c),d,Ee(g),Ee(t),Ee(n),e),Ne(([T,I,,N,,,,,,,R])=>{const O=R&&R.length!==N;return T&&!I&&!O}),he(([,,[T,I],N,R,O,$,V,U,j,q])=>{const K=R,{offsetTree:D,sizeTree:P}=K,E=mt(x);if(N===0)return{...Fa,totalCount:N};if(T===0&&I===0)return E===0?{...Fa,totalCount:N}:ph(E,O,R,U,j,q||[]);if(tt(P))return E>0?null:Ps(oC(La(O,N),K,q),[],N,j,K,U);const B=[];if(V.length>0){const J=V[0],se=V[V.length-1];let W=0;for(const L of Es(P,J,se)){const X=L.value,ee=Math.max(L.start,J),Z=Math.min(L.end,se);for(let z=ee;z<=Z;z++)B.push({data:q==null?void 0:q[z],index:z,offset:W,size:X}),W+=X}}if(!$)return Ps([],B,N,j,K,U);const Y=V.length>0?V[V.length-1]+1:0,_=KS(D,T,I,Y);if(_.length===0)return null;const M=N-1,G=ks([],J=>{for(const se of _){const W=se.value;let L=W.offset,X=se.start;const ee=W.size;if(W.offset<T){X+=Math.floor((T-W.offset+j)/(ee+j));const z=X-se.start;L+=z*ee+z*j}X<Y&&(L+=(Y-X)*ee,X=Y);const Z=Math.min(se.end,M);for(let z=X;z<=Z&&!(L>=I);z++)J.push({data:q==null?void 0:q[z],index:z,offset:L,size:ee}),L+=ee+j}});return Ps(G,B,N,j,K,U)}),Ne(T=>T!==null),ot()),Fa);be(ne(e,Ne(ka),he(T=>T==null?void 0:T.length)),o),be(ne(w,he(T=>T.topListHeight)),h),be(h,a),be(ne(w,he(T=>[T.top,T.bottom])),i),be(ne(w,he(T=>T.items)),y);const S=en(ne(w,Ne(({items:T})=>T.length>0),$e(o,e),Ne(([{items:T},I])=>T[T.length-1].originalIndex===I-1),he(([,T,I])=>[T-1,I]),ot(go),he(([T])=>T))),k=en(ne(w,jn(200),Ne(({items:T,topItems:I})=>T.length>0&&T[0].originalIndex===I.length),he(({items:T})=>T[0].index),ot())),C=en(ne(w,Ne(({items:T})=>T.length>0),he(({items:T})=>{let I=0,N=T.length-1;for(;T[I].type==="group"&&I<N;)I++;for(;T[N].type==="group"&&N>I;)N--;return{endIndex:T[N].index,startIndex:T[I].index}}),ot(rh)));return{endReached:S,initialItemCount:x,itemsRendered:y,listState:w,rangeChanged:C,startReached:k,topItemsIndexes:g,...m}},rt(En,lh,$a,bo,vo,So,Wn,Ra),{singleton:!0}),gh=qe(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=He(),i=Mt(ne(vt(n,e,r,t,o),he(([a,l,c,d,h])=>a+l+c+d+h.offsetBottom+h.bottom)),0);return be(Ee(i),s),{totalListHeight:i,totalListHeightChanged:s}},rt(Bt,sr),{singleton:!0}),sC=qe(([{viewportHeight:e},{totalListHeight:t}])=>{const n=oe(!1),r=Mt(ne(vt(n,e,t),Ne(([o])=>o),he(([,o,s])=>Math.max(0,o-s)),jn(0),ot()),0);return{alignToBottom:n,paddingTopAddition:r}},rt(Bt,gh),{singleton:!0}),xh=qe(()=>({context:oe(null)})),iC=({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,vh=qe(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:s,scrollingInProgress:i,scrollTop:a,viewportHeight:l},{scrollToIndex:c}])=>{const d=He();return be(ne(d,$e(t,l,n,s,o,r,a),$e(e),he(([[h,m,f,v,g,x,y,w],S])=>{const{align:k,behavior:C,calculateViewLocation:T=iC,done:I,...N}=h,R=ih(h,m,v-1),O=xo(R,m.offsetTree,S)+g+x,$=O+hn(m.sizeTree,R)[1],V=w+x,U=w+f-y,j=T({itemBottom:$,itemTop:O,locationParams:{align:k,behavior:C,...N},viewportBottom:U,viewportTop:V});return j?I&&fn(ne(i,Ne(q=>!q),nr(mt(i)?1:2)),I):I&&I(),j}),Ne(h=>h!==null)),c),{scrollIntoView:d}},rt(En,Bt,vo,sr,Hn),{singleton:!0});function bh(e){return e?e==="smooth"?"smooth":"auto":!1}const aC=(e,t)=>typeof e=="function"?bh(e(t)):t&&bh(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:h},{context:m},{scrollIntoView:f}])=>{const v=oe(!1),g=He();let x=null;function y(C){Me(i,{align:"end",behavior:C,index:"LAST"})}Je(ne(vt(ne(Ee(t),nr(1)),l),$e(Ee(v),s,a,h),he(([[C,T],I,N,R,O])=>{let $=T&&R,V="auto";return $&&(V=aC(I,N||O),$=$&&!!V),{followOutputBehavior:V,shouldFollow:$,totalCount:C}}),Ne(({shouldFollow:C})=>C)),({followOutputBehavior:C,totalCount:T})=>{x&&(x(),x=null),mt(n)?requestAnimationFrame(()=>{mt(d)("following output to ",{totalCount:T},Vt.DEBUG),y(C)}):x=fn(e,()=>{mt(d)("following output to ",{totalCount:T},Vt.DEBUG),y(C),x=null})});function w(C){const T=fn(o,I=>{C&&!I.atBottom&&I.notAtBottomBecause==="SIZE_INCREASED"&&!x&&(mt(d)("scrolling to bottom due to increased size",{},Vt.DEBUG),y("auto"))});setTimeout(T,100)}Je(ne(vt(Ee(v),t,c),Ne(([C,,T])=>C&&T),kn(({value:C},[,T])=>({refreshed:C===T,value:T}),{refreshed:!1,value:0}),Ne(({refreshed:C})=>C),$e(v,t)),([,C])=>{mt(a)&&w(C!==!1)}),Je(g,()=>{w(mt(v)!==!1)}),Je(vt(Ee(v),o),([C,T])=>{C&&!T.atBottom&&T.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&y("auto")});const S=oe(null),k=He();return be(Ia(ne(Ee(r),he(C=>{var T;return(T=C==null?void 0:C.length)!=null?T:0})),ne(Ee(t))),k),Je(ne(vt(ne(k,nr(1)),l),$e(Ee(S),a,h,m),he(([[C,T],I,N,R,O])=>T&&N&&(I==null?void 0:I({context:O,totalCount:C,scrollingInProgress:R}))),Ne(C=>!!C),jn(0)),C=>{x&&(x(),x=null),mt(n)?requestAnimationFrame(()=>{mt(d)("scrolling into view",{}),Me(f,C)}):x=fn(e,()=>{mt(d)("scrolling into view",{}),Me(f,C),x=null})}),{autoscrollToBottom:g,followOutput:v,scrollIntoViewOnChange:S}},rt(En,So,vo,bo,Wn,Hn,Bt,xh,vh)),cC=qe(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(be(ne(a,$e(s),Ne(([,l])=>l!==0),$e(o,r,t,n,e),he(([[,l],c,d,h,m,f=[]])=>ph(l,c,d,h,m,f))),i),{}),rt(En,bo,sr,Wn),{singleton:!0}),uC=qe(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=oe(0);return Je(ne(e,$e(r),Ne(([,o])=>o!==0),he(([,o])=>({top:o}))),o=>{fn(ne(n,nr(1),Ne(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{Me(t,o)})})}),{initialScrollTop:r}},rt(Wn,Bt,sr),{singleton:!0}),wh=qe(([{scrollVelocity:e}])=>{const t=oe(!1),n=He(),r=oe(!1);return be(ne(e,$e(r,t,n),Ne(([o,s])=>!!s),he(([o,s,i,a])=>{const{enter:l,exit:c}=s;if(i){if(c(o,a))return!1}else if(l(o,a))return!0;return i}),ot()),t),Je(ne(vt(t,e,n),$e(r)),([[o,s,i],a])=>{o&&a&&a.change&&a.change(s,i)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},rt(So),{singleton:!0}),Ba=qe(([{scrollContainerState:e,scrollTo:t}])=>{const n=He(),r=He(),o=He(),s=oe(!1),i=oe(void 0);return be(ne(vt(n,r),he(([{scrollHeight:a,scrollTop:l,viewportHeight:c},{offsetTop:d}])=>({scrollHeight:a,scrollTop:Math.max(0,l-d),viewportHeight:c}))),e),be(ne(t,$e(r),he(([a,{offsetTop:l}])=>({...a,top:a.top+l}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},rt(Bt)),dC=qe(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:a,windowViewportRect:l}])=>{const c=He(),d=oe(void 0),h=oe(null),m=oe(null);return be(a,h),be(l,m),Je(ne(c,$e(t,r,i,h,m,n)),([f,v,g,x,y,w,S])=>{const k=GS(v.sizeTree);x&&y!==null&&w!==null&&(g=y.scrollTop-w.offsetTop),g-=S,f({ranges:k,scrollTop:g})}),be(ne(d,Ne(ka),he(fC)),o),be(ne(s,$e(d),Ne(([,f])=>f!==void 0),ot(),he(([,f])=>f.ranges)),e),{getState:c,restoreStateFrom:d}},rt(En,Bt,bo,Wn,Ba));function fC(e){return{align:"start",index:0,offset:e.scrollTop}}const hC=qe(([{topItemsIndexes:e}])=>{const t=oe(0);return be(ne(t,Ne(n=>n>=0),he(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},rt(sr));function yh(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const pC=yh(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),mC=qe(([{deviation:e,scrollBy:t,scrollingInProgress:n,scrollTop:r},{isAtBottom:o,isScrolling:s,lastJumpDueToItemResize:i,scrollDirection:a},{listState:l},{beforeUnshiftWith:c,gap:d,shiftWithOffset:h,sizes:m},{log:f},{recalcInProgress:v}])=>{const g=en(ne(l,$e(i),kn(([,y,w,S],[{bottom:k,items:C,offsetBottom:T,totalCount:I},N])=>{const R=k+T;let O=0;return w===I&&y.length>0&&C.length>0&&(C[0].originalIndex===0&&y[0].originalIndex===0||(O=R-S,O!==0&&(O+=N))),[O,C,I,R]},[0,[],0,0]),Ne(([y])=>y!==0),$e(r,a,n,o,f,v),Ne(([,y,w,S,,,k])=>!k&&!S&&y!==0&&w===wo),he(([[y],,,,,w])=>(w("Upward scrolling compensation",{amount:y},Vt.DEBUG),y))));function x(y){y>0?(Me(t,{behavior:"auto",top:-y}),Me(e,0)):(Me(e,0),Me(t,{behavior:"auto",top:-y}))}return Je(ne(g,$e(e,s)),([y,w,S])=>{S&&pC()?Me(e,w-y):x(-y)}),Je(ne(vt(Mt(s,!1),e,v),Ne(([y,w,S])=>!y&&!S&&w!==0),he(([y,w])=>w),jn(1)),x),be(ne(h,he(y=>({top:-y}))),t),Je(ne(c,$e(m,d),he(([y,{groupIndices:w,lastSize:S,sizeTree:k},C])=>{function T(I){return I*(S+C)}if(w.length===0)return T(y);{let I=0;const N=mo(k,0);let R=0,O=0;for(;R<y;){R++,I+=N;let $=w.length===O+1?1/0:w[O+1]-w[O]-1;R+$>y&&(I-=N,$=y-R+1),R+=$,I+=T($),O++}return I}})),y=>{Me(e,y),requestAnimationFrame(()=>{Me(t,{top:y}),requestAnimationFrame(()=>{Me(e,0),Me(v,!1)})})}),{deviation:e}},rt(Bt,So,sr,En,Hn,Ra)),gC=qe(([e,t,n,r,o,s,i,a,l,c,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...l,...c,...d}),rt($a,cC,Wn,wh,gh,uC,sC,Ba,vh,Hn,xh)),Sh=qe(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:r,gap:o,groupIndices:s,itemSize:i,sizeRanges:a,sizes:l,statefulTotalCount:c,totalCount:d,trackItemSizes:h},{initialItemFinalLocationReached:m,initialTopMostItemIndex:f,scrolledToInitialItem:v},g,x,y,{listState:w,topItemsIndexes:S,...k},{scrollToIndex:C},T,{topItemCount:I},{groupCounts:N},R])=>(be(k.rangeChanged,R.scrollSeekRangeChanged),be(ne(R.windowViewportRect,he(O=>O.visibleHeight)),g.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,gap:o,groupCounts:N,initialItemFinalLocationReached:m,initialTopMostItemIndex:f,scrolledToInitialItem:v,sizeRanges:a,topItemCount:I,topItemsIndexes:S,totalCount:d,...y,groupIndices:s,itemSize:i,listState:w,scrollToIndex:C,statefulTotalCount:c,trackItemSizes:h,...k,...R,...g,sizes:l,...x}),rt(En,bo,Bt,dC,lC,sr,vo,mC,hC,lh,gC));function xC(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 Rs=typeof document<"u"?b.useLayoutEffect:b.useEffect;function Ch(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&&Me(x.propsReady,!1);for(const w of r){const S=x[t.required[w]];Me(S,y[w])}for(const w of o)if(w in y){const S=x[t.optional[w]];Me(S,y[w])}x.propsReady&&Me(x.propsReady,!0)}function c(x){return s.reduce((y,w)=>(y[w]=S=>{const k=x[t.methods[w]];Me(k,S)},y),{})}function d(x){return i.reduce((y,w)=>(y[w]=RS(x[t.events[w]]),y),{})}const h=b.forwardRef((x,y)=>{const{children:w,...S}=x,[k]=b.useState(()=>ks(OS(e),I=>{l(I,S)})),[C]=b.useState(Kf(d,k));Rs(()=>{for(const I of i)I in S&&Je(C[I],S[I]);return()=>{Object.values(C).map(Ea)}},[S,C,k]),Rs(()=>{l(k,S)}),b.useImperativeHandle(y,Wf(c(k)));const T=n;return u.jsx(a.Provider,{value:k,children:n?u.jsx(T,{...xC([...r,...o,...i],S),children:w}):w})}),m=x=>{const y=b.useContext(a);return b.useCallback(w=>{Me(y[x],w)},[y,x])},f=x=>{const y=b.useContext(a)[x],w=b.useCallback(S=>Je(y,S),[y]);return b.useSyncExternalStore(w,()=>mt(y),()=>mt(y))},v=x=>{const y=b.useContext(a)[x],[w,S]=b.useState(Kf(mt,y));return Rs(()=>Je(y,k=>{k!==w&&S(Wf(k))}),[y,w]),w},g=b.version.startsWith("18")?f:v;return{Component:h,useEmitter:(x,y)=>{const w=b.useContext(a)[x];Rs(()=>Je(w,y),[y,w])},useEmitterValue:g,usePublisher:m}}const Th=b.createContext(void 0),kh=b.createContext(void 0),Eh=typeof document<"u"?b.useLayoutEffect:b.useEffect;function za(e){return"self"in e}function vC(e){return"body"in e}function Ih(e,t,n,r=_r,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(vC(x)||za(x)){const w=za(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():Po.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;za(f)?(x=Math.max(Un(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=Un(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)),uh(g,x)||m.top===y){e({scrollHeight:x,scrollTop:y,viewportHeight:g}),v&&t(!0);return}v?(a.current=m.top,l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{l.current=null,a.current=null,t(!0)},1e3)):a.current=null,s&&(m={behavior:m.behavior,left:m.top}),f.scrollTo(m)}function h(m){s&&(m={behavior:m.behavior,left:m.top}),i.current.scrollBy(m)}return{scrollByCallback:h,scrollerRef:i,scrollToCallback:d}}const Ha="-webkit-sticky",Nh="sticky",Ua=yh(()=>{if(typeof document>"u")return Nh;const e=document.createElement("div");return e.style.position=Ha,e.style.position===Ha?Ha:Nh});function Wa(e){return e}const bC=qe(()=>{const e=oe(a=>`Item ${a}`),t=oe(a=>`Group ${a}`),n=oe({}),r=oe(Wa),o=oe("div"),s=oe(_r),i=(a,l=null)=>Mt(ne(n,he(c=>c[a]),ot()),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")}}),wC=qe(([e,t])=>({...e,...t}),rt(Sh,bC)),yC=({height:e})=>u.jsx("div",{style:{height:e}}),SC={overflowAnchor:"none",position:Ua(),zIndex:1},Ah={overflowAnchor:"none"},CC={...Ah,display:"inline-block",height:"100%"},jh=b.memo(function({showTopList:e=!1}){const t=_e("listState"),n=rn("sizeRanges"),r=_e("useWindowScroll"),o=_e("customScrollParent"),s=rn("windowScrollContainerState"),i=rn("scrollContainerState"),a=o||r?s:i,l=_e("itemContent"),c=_e("context"),d=_e("groupContent"),h=_e("trackItemSizes"),m=_e("itemSize"),f=_e("log"),v=rn("gap"),g=_e("horizontalDirection"),{callbackRef:x}=$S(n,m,h,e?_r:a,f,v,o,g,_e("skipAnimationFrameInResizeObserver")),[y,w]=b.useState(0);Va("deviation",j=>{y!==j&&w(j)});const S=_e("EmptyPlaceholder"),k=_e("ScrollSeekPlaceholder")||yC,C=_e("ListComponent"),T=_e("ItemComponent"),I=_e("GroupComponent"),N=_e("computeItemKey"),R=_e("isSeeking"),O=_e("groupIndices").length>0,$=_e("alignToBottom"),V=_e("initialItemFinalLocationReached"),U=e?{}:{boxSizing:"border-box",...g?{display:"inline-block",height:"100%",marginLeft:y!==0?y:$?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:y!==0?y:$?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...V?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&S?u.jsx(S,{...Ot(S,c)}):u.jsx(C,{...Ot(C,c),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:x,style:U,children:(e?t.topItems:t.items).map(j=>{const q=j.originalIndex,K=N(q+t.firstItemIndex,j.data,c);return R?b.createElement(k,{...Ot(k,c),height:j.size,index:j.index,key:K,type:j.type||"item",...j.type==="group"?{}:{groupIndex:j.groupIndex}}):j.type==="group"?b.createElement(I,{...Ot(I,c),"data-index":q,"data-item-index":j.index,"data-known-size":j.size,key:K,style:SC},d(j.index,c)):b.createElement(T,{...Ot(T,c),...IC(T,j.data),"data-index":q,"data-item-group-index":j.groupIndex,"data-item-index":j.index,"data-known-size":j.size,key:K,style:g?CC:Ah},O?l(j.index,j.groupIndex,j.data,c):l(j.index,j.data,c))})})}),TC={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},kC={outline:"none",overflowX:"auto",position:"relative"},Ms=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),EC={position:Ua(),top:0,width:"100%",zIndex:1};function Ot(e,t){if(typeof e!="string")return{context:t}}function IC(e,t){return{item:typeof e=="string"?void 0:t}}const NC=b.memo(function(){const e=_e("HeaderComponent"),t=rn("headerHeight"),n=_e("HeaderFooterTag"),r=rr(b.useMemo(()=>s=>{t(Un(s,"height"))},[t]),!0,_e("skipAnimationFrameInResizeObserver")),o=_e("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Ot(e,o)})}):null}),AC=b.memo(function(){const e=_e("FooterComponent"),t=rn("footerHeight"),n=_e("HeaderFooterTag"),r=rr(b.useMemo(()=>s=>{t(Un(s,"height"))},[t]),!0,_e("skipAnimationFrameInResizeObserver")),o=_e("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Ot(e,o)})}):null});function _h({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"),h=t("horizontalDirection")||!1,{scrollByCallback:m,scrollerRef:f,scrollToCallback:v}=Ih(a,c,l,d,void 0,h);return e("scrollTo",v),e("scrollBy",m),u.jsx(l,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:f,style:{...h?kC:TC,...o},tabIndex:0,...i,...Ot(l,s),children:r})})}function Ph({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"),h=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 Eh(()=>{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+h}:{}},...i,...Ot(l,s),children:r})})}const jC=({children:e})=>{const t=b.useContext(Th),n=rn("viewportHeight"),r=rn("fixedItemHeight"),o=_e("alignToBottom"),s=_e("horizontalDirection"),i=b.useMemo(()=>Vf(n,l=>Un(l,s?"width":"height")),[n,s]),a=rr(i,!0,_e("skipAnimationFrameInResizeObserver"));return b.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),u.jsx("div",{"data-viewport-type":"element",ref:a,style:Ms(o),children:e})},_C=({children:e})=>{const t=b.useContext(Th),n=rn("windowViewportRect"),r=rn("fixedItemHeight"),o=_e("customScrollParent"),s=Xf(n,o,_e("skipAnimationFrameInResizeObserver")),i=_e("alignToBottom");return b.useEffect(()=>{t&&(r(t.itemHeight),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),u.jsx("div",{"data-viewport-type":"window",ref:s,style:Ms(i),children:e})},PC=({children:e})=>{const t=_e("TopItemListComponent")||"div",n=_e("headerHeight"),r={...EC,marginTop:`${n}px`},o=_e("context");return u.jsx(t,{style:r,...Ot(t,o),children:e})},RC=b.memo(function(e){const t=_e("useWindowScroll"),n=_e("topItemsIndexes").length>0,r=_e("customScrollParent"),o=_e("context");return u.jsxs(r||t?DC:OC,{...e,context:o,children:[n&&u.jsx(PC,{children:u.jsx(jh,{showTopList:!0})}),u.jsxs(r||t?_C:jC,{children:[u.jsx(NC,{}),u.jsx(jh,{}),u.jsx(AC,{})]})]})}),{Component:MC,useEmitter:Va,useEmitterValue:_e,usePublisher:rn}=Ch(wC,{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"}},RC),OC=_h({useEmitter:Va,useEmitterValue:_e,usePublisher:rn}),DC=Ph({useEmitter:Va,useEmitterValue:_e,usePublisher:rn}),LC=MC;rt(Sh,qe(()=>{const e=oe(c=>u.jsxs("td",{children:["Item $",c]})),t=oe(null),n=oe(c=>u.jsxs("td",{colSpan:1e3,children:["Group ",c]})),r=oe(null),o=oe(null),s=oe({}),i=oe(Wa),a=oe(_r),l=(c,d=null)=>Mt(ne(s,he(h=>h[c]),ot()),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")}})),Ua();const Rh={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},$C={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:Mh,floor:Os,max:Co,min:Ka,round:Oh}=Math;function Dh(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function FC(e){return{...$C,items:e}}function Ds(e,t){return e&&e.width===t.width&&e.height===t.height}function BC(e,t){return e&&e.column===t.column&&e.row===t.row}const zC=qe(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:r},{footerHeight:o,headerHeight:s,scrollBy:i,scrollContainerState:a,scrollTo:l,scrollTop:c,smoothScrollTargetReached:d,viewportHeight:h},m,f,{didMount:v,propsReady:g},{customScrollParent:x,useWindowScroll:y,windowScrollContainerState:w,windowScrollTo:S,windowViewportRect:k},C])=>{const T=oe(0),I=oe(0),N=oe(Rh),R=oe({height:0,width:0}),O=oe({height:0,width:0}),$=He(),V=He(),U=oe(0),j=oe(null),q=oe({column:0,row:0}),K=He(),D=He(),P=oe(!1),E=oe(0),B=oe(!0),Y=oe(!1),_=oe(!1);Je(ne(v,$e(E),Ne(([L,X])=>!!X)),()=>{Me(B,!1)}),Je(ne(vt(v,B,O,R,E,Y),Ne(([L,X,ee,Z,,z])=>L&&!X&&ee.height!==0&&Z.height!==0&&!z)),([,,,,L])=>{Me(Y,!0),Da(1,()=>{Me($,L)}),fn(ne(c),()=>{Me(t,[0,0]),Me(B,!0)})}),be(ne(D,Ne(L=>L!=null&&L.scrollTop>0),Tn(0)),I),Je(ne(v,$e(D),Ne(([,L])=>L!=null)),([,L])=>{L&&(Me(R,L.viewport),Me(O,L.item),Me(q,L.gap),L.scrollTop>0&&(Me(P,!0),fn(ne(c,nr(1)),X=>{Me(P,!1)}),Me(l,{top:L.scrollTop})))}),be(ne(R,he(({height:L})=>L)),h),be(ne(vt(Ee(R,Ds),Ee(O,Ds),Ee(q,(L,X)=>L&&L.column===X.column&&L.row===X.row),Ee(c)),he(([L,X,ee,Z])=>({gap:ee,item:X,scrollTop:Z,viewport:L}))),K),be(ne(vt(Ee(T),r,Ee(q,BC),Ee(O,Ds),Ee(R,Ds),Ee(j),Ee(I),Ee(P),Ee(B),Ee(E)),Ne(([,,,,,,,L])=>!L),he(([L,[X,ee],Z,z,ae,ie,ge,,we,Ae])=>{const{column:Pe,row:ke}=Z,{height:st,width:bt}=z,{width:It}=ae;if(ge===0&&(L===0||It===0))return Rh;if(bt===0){const _t=La(Ae,L),yt=_t+Math.max(ge-1,0);return FC(Dh(_t,yt,ie))}const We=Lh(It,bt,Pe);let ze,Ke;we?X===0&&ee===0&&ge>0?(ze=0,Ke=ge-1):(ze=We*Os((X+ke)/(st+ke)),Ke=We*Mh((ee+ke)/(st+ke))-1,Ke=Ka(L-1,Co(Ke,We-1)),ze=Ka(Ke,Co(0,ze))):(ze=0,Ke=-1);const Fe=Dh(ze,Ke,ie),{bottom:Ue,top:ut}=$h(ae,Z,z,Fe),jt=Mh(L/We),it=jt*st+(jt-1)*ke-Ue;return{bottom:Ue,itemHeight:st,items:Fe,itemWidth:bt,offsetBottom:it,offsetTop:ut,top:ut}})),N),be(ne(j,Ne(L=>L!==null),he(L=>L.length)),T),be(ne(vt(R,O,N,q),Ne(([L,X,{items:ee}])=>ee.length>0&&X.height!==0&&L.height!==0),he(([L,X,{items:ee},Z])=>{const{bottom:z,top:ae}=$h(L,Z,X,ee);return[ae,z]}),ot(go)),t);const M=oe(!1);be(ne(c,$e(M),he(([L,X])=>X||L!==0)),M);const G=en(ne(vt(N,T),Ne(([{items:L}])=>L.length>0),$e(M),Ne(([[L,X],ee])=>{const Z=L.items[L.items.length-1].index===X-1;return(ee||L.bottom>0&&L.itemHeight>0&&L.offsetBottom===0&&L.items.length===X)&&Z}),he(([[,L]])=>L-1),ot())),J=en(ne(Ee(N),Ne(({items:L})=>L.length>0&&L[0].index===0),Tn(0),ot())),se=en(ne(Ee(N),$e(P),Ne(([{items:L},X])=>L.length>0&&!X),he(([{items:L}])=>({endIndex:L[L.length-1].index,startIndex:L[0].index})),ot(rh),jn(0)));be(se,f.scrollSeekRangeChanged),be(ne($,$e(R,O,T,q),he(([L,X,ee,Z,z])=>{const ae=ch(L),{align:ie,behavior:ge,offset:we}=ae;let Ae=ae.index;Ae==="LAST"&&(Ae=Z-1),Ae=Co(0,Ae,Ka(Z-1,Ae));let Pe=qa(X,z,ee,Ae);return ie==="end"?Pe=Oh(Pe-X.height+ee.height):ie==="center"&&(Pe=Oh(Pe-X.height/2+ee.height/2)),we&&(Pe+=we),{behavior:ge,top:Pe}})),l);const W=Mt(ne(N,he(L=>L.offsetBottom+L.bottom)),0);return be(ne(k,he(L=>({height:L.visibleHeight,width:L.visibleWidth}))),R),{customScrollParent:x,data:j,deviation:U,footerHeight:o,gap:q,headerHeight:s,increaseViewportBy:e,initialItemCount:I,itemDimensions:O,overscan:n,restoreStateFrom:D,scrollBy:i,scrollContainerState:a,scrollHeight:V,scrollTo:l,scrollToIndex:$,scrollTop:c,smoothScrollTargetReached:d,totalCount:T,useWindowScroll:y,viewportDimensions:R,windowScrollContainerState:w,windowScrollTo:S,windowViewportRect:k,...f,gridState:N,horizontalDirection:_,initialTopMostItemIndex:E,totalListHeight:W,...m,endReached:G,propsReady:g,rangeChanged:se,startReached:J,stateChanged:K,stateRestoreInProgress:P,...C}},rt($a,Bt,So,wh,Wn,Ba,Hn));function Lh(e,t,n){return Co(1,Os((e+n)/(Os(t)+n)))}function $h(e,t,n,r){const{height:o}=n;if(o===void 0||r.length===0)return{bottom:0,top:0};const s=qa(e,t,n,r[0].index);return{bottom:qa(e,t,n,r[r.length-1].index)+o,top:s}}function qa(e,t,n,r){const o=Lh(e.width,n.width,t.column),s=Os(r/o),i=s*n.height+Co(0,s-1)*t.row;return i>0?i+t.row:i}const HC=qe(()=>{const e=oe(h=>`Item ${h}`),t=oe({}),n=oe(null),r=oe("virtuoso-grid-item"),o=oe("virtuoso-grid-list"),s=oe(Wa),i=oe("div"),a=oe(_r),l=(h,m=null)=>Mt(ne(t,he(f=>f[h]),ot()),m),c=oe(!1),d=oe(!1);return be(Ee(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")}}),UC=qe(([e,t])=>({...e,...t}),rt(zC,HC)),WC=b.memo(function(){const e=lt("gridState"),t=lt("listClassName"),n=lt("itemClassName"),r=lt("itemContent"),o=lt("computeItemKey"),s=lt("isSeeking"),i=on("scrollHeight"),a=lt("ItemComponent"),l=lt("ListComponent"),c=lt("ScrollSeekPlaceholder"),d=lt("context"),h=on("itemDimensions"),m=on("gap"),f=lt("log"),v=lt("stateRestoreInProgress"),g=on("reportReadyState"),x=rr(b.useMemo(()=>y=>{const w=y.parentElement.parentElement.scrollHeight;i(w);const S=y.firstChild;if(S){const{height:k,width:C}=S.getBoundingClientRect();h({height:k,width:C})}m({column:Bh("column-gap",getComputedStyle(y).columnGap,f),row:Bh("row-gap",getComputedStyle(y).rowGap,f)})},[i,h,m,f]),!0,!1);return Eh(()=>{e.itemHeight>0&&e.itemWidth>0&&g(!0)},[e]),v?null:u.jsx(l,{className:t,ref:x,...Ot(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,{...Ot(c,d),height:e.itemHeight,index:y.index,width:e.itemWidth},w):b.createElement(a,{...Ot(a,d),className:n,"data-index":y.index,key:w},r(y.index,y.data,d))})})}),VC=b.memo(function(){const e=lt("HeaderComponent"),t=on("headerHeight"),n=lt("headerFooterTag"),r=rr(b.useMemo(()=>s=>{t(Un(s,"height"))},[t]),!0,!1),o=lt("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Ot(e,o)})}):null}),KC=b.memo(function(){const e=lt("FooterComponent"),t=on("footerHeight"),n=lt("headerFooterTag"),r=rr(b.useMemo(()=>s=>{t(Un(s,"height"))},[t]),!0,!1),o=lt("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Ot(e,o)})}):null}),qC=({children:e})=>{const t=b.useContext(kh),n=on("itemDimensions"),r=on("viewportDimensions"),o=rr(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:Ms(!1),children:e})},GC=({children:e})=>{const t=b.useContext(kh),n=on("windowViewportRect"),r=on("itemDimensions"),o=lt("customScrollParent"),s=Xf(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:Ms(!1),children:e})},YC=b.memo(function({...e}){const t=lt("useWindowScroll"),n=lt("customScrollParent"),r=n||t?JC:XC,o=n||t?GC:qC,s=lt("context");return u.jsx(r,{...e,...Ot(r,s),children:u.jsxs(o,{children:[u.jsx(VC,{}),u.jsx(WC,{}),u.jsx(KC,{})]})})}),{useEmitter:Fh,useEmitterValue:lt,usePublisher:on}=Ch(UC,{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"}},YC),XC=_h({useEmitter:Fh,useEmitterValue:lt,usePublisher:on}),JC=Ph({useEmitter:Fh,useEmitterValue:lt,usePublisher:on});function Bh(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Vt.WARN),t==="normal"?0:parseInt(t??"0",10)}var Ls="Dialog",[zh,AN]=cn(Ls),[ZC,pn]=zh(Ls),Hh=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:i=!0}=e,a=p.useRef(null),l=p.useRef(null),[c,d]=Dn({prop:r,defaultProp:o??!1,onChange:s,caller:Ls});return u.jsx(ZC,{scope:t,triggerRef:a,contentRef:l,contentId:Rt(),titleId:Rt(),descriptionId:Rt(),open:c,onOpenChange:d,onOpenToggle:p.useCallback(()=>d(h=>!h),[d]),modal:i,children:n})};Hh.displayName=Ls;var Uh="DialogTrigger",Wh=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=pn(Uh,n),s=Le(t,o.triggerRef);return u.jsx(ve.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Xa(o.open),...r,ref:s,onClick:ce(e.onClick,o.onOpenToggle)})});Wh.displayName=Uh;var Ga="DialogPortal",[QC,Vh]=zh(Ga,{forceMount:void 0}),Kh=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=pn(Ga,t);return u.jsx(QC,{scope:t,forceMount:n,children:p.Children.map(r,i=>u.jsx(Wt,{present:n||s.open,children:u.jsx(so,{asChild:!0,container:o,children:i})}))})};Kh.displayName=Ga;var $s="DialogOverlay",qh=p.forwardRef((e,t)=>{const n=Vh($s,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=pn($s,e.__scopeDialog);return s.modal?u.jsx(Wt,{present:r||s.open,children:u.jsx(tT,{...o,ref:t})}):null});qh.displayName=$s;var eT=Yt.createSlot("DialogOverlay.RemoveScroll"),tT=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=pn($s,n);return u.jsx(gs,{as:eT,allowPinchZoom:!0,shards:[o.contentRef],children:u.jsx(ve.div,{"data-state":Xa(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),ir="DialogContent",Gh=p.forwardRef((e,t)=>{const n=Vh(ir,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=pn(ir,e.__scopeDialog);return u.jsx(Wt,{present:r||s.open,children:s.modal?u.jsx(nT,{...o,ref:t}):u.jsx(rT,{...o,ref:t})})});Gh.displayName=ir;var nT=p.forwardRef((e,t)=>{const n=pn(ir,e.__scopeDialog),r=p.useRef(null),o=Le(t,n.contentRef,r);return p.useEffect(()=>{const s=r.current;if(s)return da(s)},[]),u.jsx(Yh,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ce(e.onCloseAutoFocus,s=>{var i;s.preventDefault(),(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:ce(e.onPointerDownOutside,s=>{const i=s.detail.originalEvent,a=i.button===0&&i.ctrlKey===!0;(i.button===2||a)&&s.preventDefault()}),onFocusOutside:ce(e.onFocusOutside,s=>s.preventDefault())})}),rT=p.forwardRef((e,t)=>{const n=pn(ir,e.__scopeDialog),r=p.useRef(!1),o=p.useRef(!1);return u.jsx(Yh,{...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()}})}),Yh=p.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=pn(ir,n),l=p.useRef(null),c=Le(t,l);return Hi(),u.jsxs(u.Fragment,{children:[u.jsx(Jo,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:u.jsx(wr,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":Xa(a.open),...i,ref:c,onDismiss:()=>a.onOpenChange(!1)})}),u.jsxs(u.Fragment,{children:[u.jsx(oT,{titleId:a.titleId}),u.jsx(iT,{contentRef:l,descriptionId:a.descriptionId})]})]})}),Ya="DialogTitle",Xh=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=pn(Ya,n);return u.jsx(ve.h2,{id:o.titleId,...r,ref:t})});Xh.displayName=Ya;var Jh="DialogDescription",Zh=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=pn(Jh,n);return u.jsx(ve.p,{id:o.descriptionId,...r,ref:t})});Zh.displayName=Jh;var Qh="DialogClose",ep=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=pn(Qh,n);return u.jsx(ve.button,{type:"button",...r,ref:t,onClick:ce(e.onClick,()=>o.onOpenChange(!1))})});ep.displayName=Qh;function Xa(e){return e?"open":"closed"}var tp="DialogTitleWarning",[jN,np]=yb(tp,{contentName:ir,titleName:Ya,docsSlug:"dialog"}),oT=({titleId:e})=>{const t=np(tp),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
79
|
+
`)},a0=0,Ar=[];function l0(e){var t=p.useRef([]),n=p.useRef([0,0]),r=p.useRef(),o=p.useState(a0++)[0],s=p.useState(Fd)[0],i=p.useRef(e);p.useEffect(function(){i.current=e},[e]),p.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var g=Ay([e.lockRef.current],(e.shards||[]).map(Kd),!0).filter(Boolean);return g.forEach(function(x){return x.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),g.forEach(function(x){return x.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var a=p.useCallback(function(g,x){if("touches"in g&&g.touches.length===2||g.type==="wheel"&&g.ctrlKey)return!i.current.allowPinchZoom;var y=ms(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,I=Math.abs(S)>Math.abs(k)?"h":"v";if("touches"in g&&I==="h"&&T.type==="range")return!1;var N=Hd(I,T);if(!N)return!0;if(N?C=I:(C=I==="v"?"h":"v",N=Hd(I,T)),!N)return!1;if(!r.current&&"changedTouches"in g&&(S||k)&&(r.current=C),!C)return!0;var R=r.current||C;return o0(R,x,g,R==="h"?S:k)},[]),l=p.useCallback(function(g){var x=g;if(!(!Ar.length||Ar[Ar.length-1]!==s)){var y="deltaY"in x?Vd(x):ms(x),w=t.current.filter(function(C){return C.name===x.type&&(C.target===x.target||x.target===C.shadowParent)&&s0(C.delta,y)})[0];if(w&&w.should){x.cancelable&&x.preventDefault();return}if(!w){var S=(i.current.shards||[]).map(Kd).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=p.useCallback(function(g,x,y,w){var S={name:g,delta:x,target:y,should:w,shadowParent:c0(y)};t.current.push(S),setTimeout(function(){t.current=t.current.filter(function(k){return k!==S})},1)},[]),d=p.useCallback(function(g){n.current=ms(g),r.current=void 0},[]),f=p.useCallback(function(g){c(g.type,Vd(g),g.target,a(g,e.lockRef.current))},[]),m=p.useCallback(function(g){c(g.type,ms(g),g.target,a(g,e.lockRef.current))},[]);p.useEffect(function(){return Ar.push(s),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:m}),document.addEventListener("wheel",l,Nr),document.addEventListener("touchmove",l,Nr),document.addEventListener("touchstart",d,Nr),function(){Ar=Ar.filter(function(g){return g!==s}),document.removeEventListener("wheel",l,Nr),document.removeEventListener("touchmove",l,Nr),document.removeEventListener("touchstart",d,Nr)}},[]);var h=e.removeScrollBar,v=e.inert;return p.createElement(p.Fragment,null,v?p.createElement(s,{styles:i0(o)}):null,h?p.createElement(Jy,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function c0(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const u0=$y($d,l0);var gs=p.forwardRef(function(e,t){return p.createElement(hs,Cn({},e,{ref:t,sideCar:u0}))});gs.classNames=hs.classNames;var ga=["Enter"," "],d0=["ArrowDown","PageUp","Home"],qd=["ArrowUp","PageDown","End"],f0=[...d0,...qd],h0={ltr:[...ga,"ArrowRight"],rtl:[...ga,"ArrowLeft"]},p0={ltr:["ArrowLeft"],rtl:["ArrowRight"]},ao="Menu",[lo,m0,g0]=Yo(ao),[er,Gd]=cn(ao,[g0,kr,Ad]),xs=kr(),Yd=Ad(),[x0,tr]=er(ao),[v0,co]=er(ao),Xd=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=xs(t),[l,c]=p.useState(null),d=p.useRef(!1),f=pt(s),m=Xo(o);return p.useEffect(()=>{const h=()=>{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",h,{capture:!0}),()=>{document.removeEventListener("keydown",h,{capture:!0}),document.removeEventListener("pointerdown",v,{capture:!0}),document.removeEventListener("pointermove",v,{capture:!0})}},[]),u.jsx(oa,{...a,children:u.jsx(x0,{scope:t,open:n,onOpenChange:f,content:l,onContentChange:c,children:u.jsx(v0,{scope:t,onClose:p.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:d,dir:m,modal:i,children:r})})})};Xd.displayName=ao;var b0="MenuAnchor",xa=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=xs(n);return u.jsx(sa,{...o,...r,ref:t})});xa.displayName=b0;var va="MenuPortal",[w0,Jd]=er(va,{forceMount:void 0}),Zd=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=tr(va,t);return u.jsx(w0,{scope:t,forceMount:n,children:u.jsx(Wt,{present:n||s.open,children:u.jsx(so,{asChild:!0,container:o,children:r})})})};Zd.displayName=va;var nn="MenuContent",[y0,ba]=er(nn),Qd=p.forwardRef((e,t)=>{const n=Jd(nn,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=tr(nn,e.__scopeMenu),i=co(nn,e.__scopeMenu);return u.jsx(lo.Provider,{scope:e.__scopeMenu,children:u.jsx(Wt,{present:r||s.open,children:u.jsx(lo.Slot,{scope:e.__scopeMenu,children:i.modal?u.jsx(S0,{...o,ref:t}):u.jsx(C0,{...o,ref:t})})})})}),S0=p.forwardRef((e,t)=>{const n=tr(nn,e.__scopeMenu),r=p.useRef(null),o=Le(t,r);return p.useEffect(()=>{const s=r.current;if(s)return da(s)},[]),u.jsx(wa,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:ce(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),C0=p.forwardRef((e,t)=>{const n=tr(nn,e.__scopeMenu);return u.jsx(wa,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),T0=Yt.createSlot("MenuContent.ScrollLock"),wa=p.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:m,onDismiss:h,disableOutsideScroll:v,...g}=e,x=tr(nn,n),y=co(nn,n),w=xs(n),S=Yd(n),k=m0(n),[C,T]=p.useState(null),I=p.useRef(null),N=Le(t,I,x.onContentChange),R=p.useRef(0),O=p.useRef(""),$=p.useRef(0),V=p.useRef(null),U=p.useRef("right"),j=p.useRef(0),q=v?gs:p.Fragment,K=v?{as:T0,allowPinchZoom:!0}:void 0,D=E=>{var W,L;const B=O.current+E,Y=k().filter(X=>!X.disabled),P=document.activeElement,M=(W=Y.find(X=>X.ref.current===P))==null?void 0:W.textValue,G=Y.map(X=>X.textValue),J=D0(G,B,M),se=(L=Y.find(X=>X.textValue===J))==null?void 0:L.ref.current;(function X(ee){O.current=ee,window.clearTimeout(R.current),ee!==""&&(R.current=window.setTimeout(()=>X(""),1e3))})(B),se&&setTimeout(()=>se.focus())};p.useEffect(()=>()=>window.clearTimeout(R.current),[]),Hi();const _=p.useCallback(E=>{var Y,P;return U.current===((Y=V.current)==null?void 0:Y.side)&&$0(E,(P=V.current)==null?void 0:P.area)},[]);return u.jsx(y0,{scope:n,searchRef:O,onItemEnter:p.useCallback(E=>{_(E)&&E.preventDefault()},[_]),onItemLeave:p.useCallback(E=>{var B;_(E)||((B=I.current)==null||B.focus(),T(null))},[_]),onTriggerLeave:p.useCallback(E=>{_(E)&&E.preventDefault()},[_]),pointerGraceTimerRef:$,onPointerGraceIntentChange:p.useCallback(E=>{V.current=E},[]),children:u.jsx(q,{...K,children:u.jsx(Jo,{asChild:!0,trapped:o,onMountAutoFocus:ce(s,E=>{var B;E.preventDefault(),(B=I.current)==null||B.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:u.jsx(wr,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:m,onDismiss:h,children:u.jsx(Ty,{asChild:!0,...S,dir:y.dir,orientation:"vertical",loop:r,currentTabStopId:C,onCurrentTabStopIdChange:T,onEntryFocus:ce(l,E=>{y.isUsingKeyboardRef.current||E.preventDefault()}),preventScrollOnEntryFocus:!0,children:u.jsx(ia,{role:"menu","aria-orientation":"vertical","data-state":xf(x.open),"data-radix-menu-content":"",dir:y.dir,...w,...g,ref:N,style:{outline:"none",...g.style},onKeyDown:ce(g.onKeyDown,E=>{const Y=E.target.closest("[data-radix-menu-content]")===E.currentTarget,P=E.ctrlKey||E.altKey||E.metaKey,M=E.key.length===1;Y&&(E.key==="Tab"&&E.preventDefault(),!P&&M&&D(E.key));const G=I.current;if(E.target!==G||!f0.includes(E.key))return;E.preventDefault();const se=k().filter(W=>!W.disabled).map(W=>W.ref.current);qd.includes(E.key)&&se.reverse(),M0(se)}),onBlur:ce(e.onBlur,E=>{E.currentTarget.contains(E.target)||(window.clearTimeout(R.current),O.current="")}),onPointerMove:ce(e.onPointerMove,fo(E=>{const B=E.target,Y=j.current!==E.clientX;if(E.currentTarget.contains(B)&&Y){const P=E.clientX>j.current?"right":"left";U.current=P,j.current=E.clientX}}))})})})})})})});Qd.displayName=nn;var k0="MenuGroup",ya=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(ve.div,{role:"group",...r,ref:t})});ya.displayName=k0;var E0="MenuLabel",ef=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(ve.div,{...r,ref:t})});ef.displayName=E0;var vs="MenuItem",tf="menu.itemSelect",bs=p.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=p.useRef(null),i=co(vs,e.__scopeMenu),a=ba(vs,e.__scopeMenu),l=Le(t,s),c=p.useRef(!1),d=()=>{const f=s.current;if(!n&&f){const m=new CustomEvent(tf,{bubbles:!0,cancelable:!0});f.addEventListener(tf,h=>r==null?void 0:r(h),{once:!0}),Fi(f,m),m.defaultPrevented?c.current=!1:i.onClose()}};return u.jsx(nf,{...o,ref:l,disabled:n,onClick:ce(e.onClick,d),onPointerDown:f=>{var m;(m=e.onPointerDown)==null||m.call(e,f),c.current=!0},onPointerUp:ce(e.onPointerUp,f=>{var m;c.current||(m=f.currentTarget)==null||m.click()}),onKeyDown:ce(e.onKeyDown,f=>{const m=a.searchRef.current!=="";n||m&&f.key===" "||ga.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});bs.displayName=vs;var nf=p.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=ba(vs,n),a=Yd(n),l=p.useRef(null),c=Le(t,l),[d,f]=p.useState(!1),[m,h]=p.useState("");return p.useEffect(()=>{const v=l.current;v&&h((v.textContent??"").trim())},[s.children]),u.jsx(lo.ItemSlot,{scope:n,disabled:r,textValue:o??m,children:u.jsx(ky,{asChild:!0,...a,focusable:!r,children:u.jsx(ve.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:c,onPointerMove:ce(e.onPointerMove,fo(v=>{r?i.onItemLeave(v):(i.onItemEnter(v),v.defaultPrevented||v.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:ce(e.onPointerLeave,fo(v=>i.onItemLeave(v))),onFocus:ce(e.onFocus,()=>f(!0)),onBlur:ce(e.onBlur,()=>f(!1))})})})}),I0="MenuCheckboxItem",rf=p.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return u.jsx(cf,{scope:e.__scopeMenu,checked:n,children:u.jsx(bs,{role:"menuitemcheckbox","aria-checked":ws(n)?"mixed":n,...o,ref:t,"data-state":Ca(n),onSelect:ce(o.onSelect,()=>r==null?void 0:r(ws(n)?!0:!n),{checkForDefaultPrevented:!1})})})});rf.displayName=I0;var of="MenuRadioGroup",[N0,A0]=er(of,{value:void 0,onValueChange:()=>{}}),sf=p.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=pt(r);return u.jsx(N0,{scope:e.__scopeMenu,value:n,onValueChange:s,children:u.jsx(ya,{...o,ref:t})})});sf.displayName=of;var af="MenuRadioItem",lf=p.forwardRef((e,t)=>{const{value:n,...r}=e,o=A0(af,e.__scopeMenu),s=n===o.value;return u.jsx(cf,{scope:e.__scopeMenu,checked:s,children:u.jsx(bs,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":Ca(s),onSelect:ce(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});lf.displayName=af;var Sa="MenuItemIndicator",[cf,j0]=er(Sa,{checked:!1}),uf=p.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=j0(Sa,n);return u.jsx(Wt,{present:r||ws(s.checked)||s.checked===!0,children:u.jsx(ve.span,{...o,ref:t,"data-state":Ca(s.checked)})})});uf.displayName=Sa;var P0="MenuSeparator",df=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(ve.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});df.displayName=P0;var _0="MenuArrow",ff=p.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=xs(n);return u.jsx(aa,{...o,...r,ref:t})});ff.displayName=_0;var R0="MenuSub",[EN,hf]=er(R0),uo="MenuSubTrigger",pf=p.forwardRef((e,t)=>{const n=tr(uo,e.__scopeMenu),r=co(uo,e.__scopeMenu),o=hf(uo,e.__scopeMenu),s=ba(uo,e.__scopeMenu),i=p.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,c={__scopeMenu:e.__scopeMenu},d=p.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return p.useEffect(()=>d,[d]),p.useEffect(()=>{const f=a.current;return()=>{window.clearTimeout(f),l(null)}},[a,l]),u.jsx(xa,{asChild:!0,...c,children:u.jsx(nf,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":xf(n.open),...e,ref:On(t,o.onTriggerChange),onClick:f=>{var m;(m=e.onClick)==null||m.call(e,f),!(e.disabled||f.defaultPrevented)&&(f.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:ce(e.onPointerMove,fo(f=>{s.onItemEnter(f),!f.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(s.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),d()},100))})),onPointerLeave:ce(e.onPointerLeave,fo(f=>{var h,v;d();const m=(h=n.content)==null?void 0:h.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:f.clientX+y,y:f.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(f),f.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:ce(e.onKeyDown,f=>{var h;const m=s.searchRef.current!=="";e.disabled||m&&f.key===" "||h0[r.dir].includes(f.key)&&(n.onOpenChange(!0),(h=n.content)==null||h.focus(),f.preventDefault())})})})});pf.displayName=uo;var mf="MenuSubContent",gf=p.forwardRef((e,t)=>{const n=Jd(nn,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=tr(nn,e.__scopeMenu),i=co(nn,e.__scopeMenu),a=hf(mf,e.__scopeMenu),l=p.useRef(null),c=Le(t,l);return u.jsx(lo.Provider,{scope:e.__scopeMenu,children:u.jsx(Wt,{present:r||s.open,children:u.jsx(lo.Slot,{scope:e.__scopeMenu,children:u.jsx(wa,{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 f;i.isUsingKeyboardRef.current&&((f=l.current)==null||f.focus()),d.preventDefault()},onCloseAutoFocus:d=>d.preventDefault(),onFocusOutside:ce(e.onFocusOutside,d=>{d.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:ce(e.onEscapeKeyDown,d=>{i.onClose(),d.preventDefault()}),onKeyDown:ce(e.onKeyDown,d=>{var h;const f=d.currentTarget.contains(d.target),m=p0[i.dir].includes(d.key);f&&m&&(s.onOpenChange(!1),(h=a.trigger)==null||h.focus(),d.preventDefault())})})})})})});gf.displayName=mf;function xf(e){return e?"open":"closed"}function ws(e){return e==="indeterminate"}function Ca(e){return ws(e)?"indeterminate":e?"checked":"unchecked"}function M0(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function O0(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function D0(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=O0(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 L0(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,f=l.x,m=l.y;d>r!=m>r&&n<(f-c)*(r-d)/(m-d)+c&&(o=!o)}return o}function $0(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return L0(n,t)}function fo(e){return t=>t.pointerType==="mouse"?e(t):void 0}var F0=Xd,B0=xa,z0=Zd,H0=Qd,U0=ya,W0=ef,V0=bs,K0=rf,q0=sf,G0=lf,Y0=uf,X0=df,J0=ff,Z0=pf,Q0=gf,ys="DropdownMenu",[eS,IN]=cn(ys,[Gd]),Ft=Gd(),[tS,vf]=eS(ys),bf=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,l=Ft(t),c=p.useRef(null),[d,f]=Dn({prop:o,defaultProp:s??!1,onChange:i,caller:ys});return u.jsx(tS,{scope:t,triggerId:Rt(),triggerRef:c,contentId:Rt(),open:d,onOpenChange:f,onOpenToggle:p.useCallback(()=>f(m=>!m),[f]),modal:a,children:u.jsx(F0,{...l,open:d,onOpenChange:f,dir:r,modal:a,children:n})})};bf.displayName=ys;var wf="DropdownMenuTrigger",yf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=vf(wf,n),i=Ft(n);return u.jsx(B0,{asChild:!0,...i,children:u.jsx(ve.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:On(t,s.triggerRef),onPointerDown:ce(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:ce(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});yf.displayName=wf;var nS="DropdownMenuPortal",Sf=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Ft(t);return u.jsx(z0,{...r,...n})};Sf.displayName=nS;var Cf="DropdownMenuContent",Tf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=vf(Cf,n),s=Ft(n),i=p.useRef(!1);return u.jsx(H0,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:ce(e.onCloseAutoFocus,a=>{var l;i.current||(l=o.triggerRef.current)==null||l.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:ce(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)"}})});Tf.displayName=Cf;var rS="DropdownMenuGroup",oS=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ft(n);return u.jsx(U0,{...o,...r,ref:t})});oS.displayName=rS;var sS="DropdownMenuLabel",kf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ft(n);return u.jsx(W0,{...o,...r,ref:t})});kf.displayName=sS;var iS="DropdownMenuItem",Ef=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ft(n);return u.jsx(V0,{...o,...r,ref:t})});Ef.displayName=iS;var aS="DropdownMenuCheckboxItem",If=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ft(n);return u.jsx(K0,{...o,...r,ref:t})});If.displayName=aS;var lS="DropdownMenuRadioGroup",cS=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ft(n);return u.jsx(q0,{...o,...r,ref:t})});cS.displayName=lS;var uS="DropdownMenuRadioItem",Nf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ft(n);return u.jsx(G0,{...o,...r,ref:t})});Nf.displayName=uS;var dS="DropdownMenuItemIndicator",Af=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ft(n);return u.jsx(Y0,{...o,...r,ref:t})});Af.displayName=dS;var fS="DropdownMenuSeparator",jf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ft(n);return u.jsx(X0,{...o,...r,ref:t})});jf.displayName=fS;var hS="DropdownMenuArrow",pS=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ft(n);return u.jsx(J0,{...o,...r,ref:t})});pS.displayName=hS;var mS="DropdownMenuSubTrigger",Pf=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ft(n);return u.jsx(Z0,{...o,...r,ref:t})});Pf.displayName=mS;var gS="DropdownMenuSubContent",_f=p.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Ft(n);return u.jsx(Q0,{...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)"}})});_f.displayName=gS;var xS=bf,vS=yf,bS=Sf,Rf=Tf,Mf=kf,Of=Ef,Df=If,Lf=Nf,$f=Af,Ff=jf,Bf=Pf,zf=_f;const Ss=xS,Cs=vS,wS=p.forwardRef(({className:e,inset:t,children:n,...r},o)=>u.jsxs(Bf,{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(ue.ChevronRight,{className:"ml-auto h-4 w-4"})]}));wS.displayName=Bf.displayName;const yS=p.forwardRef(({className:e,...t},n)=>u.jsx(zf,{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}));yS.displayName=zf.displayName;const ho=p.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(bS,{children:u.jsx(Rf,{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})}));ho.displayName=Rf.displayName;const Bn=p.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(Of,{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}));Bn.displayName=Of.displayName;const SS=p.forwardRef(({className:e,children:t,checked:n,...r},o)=>u.jsxs(Df,{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($f,{children:u.jsx(ue.Check,{className:"h-4 w-4"})})}),t]}));SS.displayName=Df.displayName;const CS=p.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Lf,{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($f,{children:u.jsx(ue.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));CS.displayName=Lf.displayName;const TS=p.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(Mf,{ref:r,className:re("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));TS.displayName=Mf.displayName;const kS=p.forwardRef(({className:e,...t},n)=>u.jsx(Ff,{ref:n,className:re("-mx-1 my-1 h-px bg-muted",e),...t}));kS.displayName=Ff.displayName;const Ta=p.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}));Ta.displayName="Textarea";const ES=1e4;function Hf({initialValue:e="",editingMessageId:t=null,placeholder:n="Type your message...",isStreaming:r=!1,disabled:o=!1,maxLength:s=ES,value:i,onValueChange:a,onSend:l,onCancelEdit:c,onStop:d,className:f="",textareaClassName:m="",allowEmptySend:h=!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),I=b.useRef(0),N=b.useRef(null),R=b.useRef("");b.useEffect(()=>{x||(w(e??""),N.current=null,T.current&&(T.current.style.height="auto",T.current.style.height=`${T.current.scrollHeight}px`))},[e,t,x]);const[O,$]=b.useState(null),V=b.useCallback(M=>M.length>s?`Message too long (${M.length}/${s} characters)`:null,[s]),U=b.useMemo(()=>v??V,[v,V]),j=b.useCallback(M=>{const G=U(M);return $(G),g==null||g(G),R.current=M,G},[U,g]),q=b.useCallback(()=>{const M=T.current;M&&(M.style.height="auto",M.style.height=`${M.scrollHeight}px`)},[]);b.useEffect(()=>{q()},[q,S]),b.useEffect(()=>{if(!O)return;const M=(S??"").trim();R.current!==M&&j(M)},[S,O,j]);const K=b.useCallback((M,{fromUser:G})=>{x||w(M),G&&(a==null||a(M))},[x,a]),D=b.useCallback(async M=>{M&&M.preventDefault();const G=(S??"").trim();if(!G&&!h||j(G))return;const J=++I.current;N.current={id:J,shouldClear:!0},C(()=>{var se,W,L;try{const X=l(G);X&&typeof X.then=="function"?X.then(()=>{var ee,Z;((ee=N.current)==null?void 0:ee.id)===J&&N.current.shouldClear&&(x||(w(""),T.current&&(T.current.style.height="auto"),a==null||a(""))),((Z=N.current)==null?void 0:Z.id)===J&&(N.current=null)}).catch(()=>{var ee;((ee=N.current)==null?void 0:ee.id)===J&&(N.current=null)}):(((se=N.current)==null?void 0:se.id)===J&&N.current.shouldClear&&(x||(w(""),T.current&&(T.current.style.height="auto"),a==null||a(""))),((W=N.current)==null?void 0:W.id)===J&&(N.current=null))}catch{((L=N.current)==null?void 0:L.id)===J&&(N.current=null)}})},[S,l,h,x,a,j]),_=b.useCallback(M=>{const G=M.target.value;K(G,{fromUser:!0}),N.current&&(N.current.shouldClear=!1),T.current&&(T.current.style.height="auto",T.current.style.height=`${T.current.scrollHeight}px`),O&&j(G.trim())},[K,j,O]),E=b.useCallback(M=>{M.key==="Enter"&&!M.shiftKey?(M.preventDefault(),D()):M.key==="Escape"&&t&&(M.preventDefault(),c==null||c())},[D,t,c]),P=`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${t?"border-[hsl(var(--ring))] bg-[hsl(var(--card))] text-[hsl(var(--card-foreground))] dark:bg-[hsl(var(--card))] dark:text-[hsl(var(--card-foreground))]":""} ${m}`;return u.jsx("form",{onSubmit:M=>void D(M),className:`w-full ${f}`,children:u.jsxs("div",{className:"flex items-end gap-2",children:[u.jsxs("div",{className:"flex-1",children:[u.jsx(Ta,{ref:T,value:S,onChange:_,onKeyDown:E,placeholder:t?"Edit your message...":n,className:P,disabled:o,maxLength:s,rows:1,spellCheck:!1,autoCorrect:"off"}),O&&u.jsx("p",{className:"mt-1 text-xs text-destructive font-medium",children:O})]}),u.jsx("div",{children:r?u.jsx(Qe,{type:"button",onClick:()=>{d==null||d()},size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",disabled:o||!d,children:u.jsx(ue.Square,{size:16})}):u.jsx(Qe,{type:"submit",size:"icon",className:"shrink-0",title:t?"Save changes":"Send message",disabled:o||!S.trim()&&!h||k,children:u.jsx(ue.Send,{size:16})})})]})})}const IS=b.memo(Hf),Ts=0,zn=1,jr=2,Uf=4;function Wf(e){return()=>e}function NS(e){e()}function Vf(e,t){return n=>e(t(n))}function Kf(e,t){return()=>e(t)}function AS(e,t){return n=>e(t,n)}function ka(e){return e!==void 0}function jS(...e){return()=>{e.map(NS)}}function Pr(){}function ks(e,t){return t(e),e}function PS(e,t){return t(e)}function rt(...e){return e}function Je(e,t){return e(zn,t)}function Me(e,t){e(Ts,t)}function Ea(e){e(jr)}function mt(e){return e(Uf)}function be(e,t){return Je(e,AS(t,Ts))}function fn(e,t){const n=e(zn,r=>{n(),t(r)});return n}function qf(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function Gf(e,t){return e===t}function ot(e=Gf){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function Ne(e){return t=>n=>{e(n)&&t(n)}}function he(e){return t=>Vf(t,e)}function Tn(e){return t=>()=>{t(e)}}function ne(e,...t){const n=_S(...t);return(r,o)=>{switch(r){case jr:Ea(e);return;case zn:return Je(e,n(o))}}}function kn(e,t){return n=>r=>{n(t=e(t,r))}}function nr(e){return t=>n=>{e>0?e--:t(n)}}function jn(e){let t=null,n;return r=>o=>{t=o,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function $e(...e){const t=new Array(e.length);let n=0,r=null;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const a=Math.pow(2,i);Je(s,l=>{const c=n;n=n|a,t[i]=l,c!==o&&n===o&&r&&(r(),r=null)})}),s=>i=>{const a=()=>{s([i].concat(t))};n===o?a():r=a}}function _S(...e){return t=>e.reduceRight(PS,t)}function RS(e){let t,n;const r=()=>t==null?void 0:t();return function(o,s){switch(o){case zn:return s?n===s?void 0:(r(),n=s,t=Je(e,s),t):(r(),Pr);case jr:r(),n=null;return}}}function oe(e){let t=e;const n=He();return(r,o)=>{switch(r){case Ts:t=o;break;case zn:{o(t);break}case Uf:return t}return n(r,o)}}function Mt(e,t){return ks(oe(t),n=>be(e,n))}function He(){const e=[];return(t,n)=>{switch(t){case Ts:e.slice().forEach(r=>{r(n)});return;case jr:e.splice(0,e.length);return;case zn:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}}}function en(e){return ks(He(),t=>be(e,t))}function qe(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:MS(),singleton:n}}const MS=()=>Symbol();function OS(e){const t=new Map,n=({constructor:r,dependencies:o,id:s,singleton:i})=>{if(i&&t.has(s))return t.get(s);const a=r(o.map(l=>n(l)));return i&&t.set(s,a),a};return n(e)}function vt(...e){const t=He(),n=new Array(e.length);let r=0;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const a=Math.pow(2,i);Je(s,l=>{n[i]=l,r=r|a,r===o&&Me(t,n)})}),function(s,i){switch(s){case jr:{Ea(t);return}case zn:return r===o&&i(n),Je(t,i)}}}function Ee(e,t=Gf){return ne(e,ot(t))}function Ia(...e){return function(t,n){switch(t){case jr:return;case zn:return jS(...e.map(r=>Je(r,n)))}}}var Vt=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(Vt||{});const DS={0:"debug",3:"error",1:"log",2:"warn"},LS=()=>typeof globalThis>"u"?window:globalThis,Hn=qe(()=>{const e=oe(3);return{log:oe((t,n,r=1)=>{var o;const s=(o=LS().VIRTUOSO_LOG_LEVEL)!=null?o:mt(e);r>=s&&console[DS[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0});function rr(e,t,n){return Na(e,t,n).callbackRef}function Na(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 $S(e,t,n,r,o,s,i,a,l){const c=b.useCallback(d=>{const f=FS(d.children,t,a?"offsetWidth":"offsetHeight",o);let m=d.parentElement;for(;!m.dataset.virtuosoScroller;)m=m.parentElement;const h=m.lastElementChild.dataset.viewportType==="window";let v;h&&(v=m.ownerDocument.defaultView);const g=i?a?i.scrollLeft:i.scrollTop:h?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:h?a?v.document.documentElement.scrollWidth:v.document.documentElement.scrollHeight:a?m.scrollWidth:m.scrollHeight,y=i?a?i.offsetWidth:i.offsetHeight:h?a?v.innerWidth:v.innerHeight:a?m.offsetWidth:m.offsetHeight;r({scrollHeight:x,scrollTop:Math.max(g,0),viewportHeight:y}),s==null||s(a?Yf("column-gap",getComputedStyle(d).columnGap,o):Yf("row-gap",getComputedStyle(d).rowGap,o)),f!==null&&e(f)},[e,t,o,s,i,r,a]);return Na(c,n,l)}function FS(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},Vt.ERROR),d===c)continue;const f=s[s.length-1];s.length===0||f.size!==d||f.endIndex!==l-1?s.push({endIndex:l,size:d,startIndex:l}):s[s.length-1].endIndex++}return s}function Yf(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Vt.WARN),t==="normal"?0:parseInt(t??"0",10)}function Xf(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 f,m;if(t){const h=t.getBoundingClientRect(),v=c.top-h.top;m=h.height-Math.max(0,v),f=v+t.scrollTop}else{const h=i.current.ownerDocument.defaultView;m=h.innerHeight-Math.max(0,c.top),f=c.top+h.scrollY}r.current={offsetTop:f,visibleHeight:m,visibleWidth:d},e(r.current)},[e,t]),{callbackRef:s,ref:i}=Na(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 Bt=qe(()=>{const e=He(),t=He(),n=oe(0),r=He(),o=oe(0),s=He(),i=He(),a=oe(0),l=oe(0),c=oe(0),d=oe(0),f=He(),m=He(),h=oe(!1),v=oe(!1),g=oe(!1);return be(ne(e,he(({scrollTop:x})=>x)),t),be(ne(e,he(({scrollHeight:x})=>x)),i),be(t,o),{deviation:n,fixedFooterHeight:c,fixedHeaderHeight:l,footerHeight:d,headerHeight:a,horizontalDirection:v,scrollBy:m,scrollContainerState:e,scrollHeight:i,scrollingInProgress:h,scrollTo:f,scrollTop:t,skipAnimationFrameInResizeObserver:g,smoothScrollTargetReached:r,statefulScrollTop:o,viewportHeight:s}},[],{singleton:!0}),po={lvl:0};function Jf(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 tt(e){return e===po}function mo(e,t){if(!tt(e))return t===e.k?e.v:t<e.k?mo(e.l,t):mo(e.r,t)}function hn(e,t,n="k"){if(tt(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){const r=hn(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return hn(e.l,t,n)}function tn(e,t,n){return tt(e)?eh(t,n,1):t===e.k?wt(e,{k:t,v:n}):t<e.k?th(wt(e,{l:tn(e.l,t,n)})):th(wt(e,{r:tn(e.r,t,n)}))}function _r(){return po}function Es(e,t,n){if(tt(e))return[];const r=hn(e,t)[0];return BS(ja(e,r,n))}function Aa(e,t){if(tt(e))return po;const{k:n,l:r,r:o}=e;if(t===n){if(tt(r))return o;if(tt(o))return r;{const[s,i]=Qf(r);return Is(wt(e,{k:s,l:Zf(r),v:i}))}}else return t<n?Is(wt(e,{l:Aa(r,t)})):Is(wt(e,{r:Aa(o,t)}))}function or(e){return tt(e)?[]:[...or(e.l),{k:e.k,v:e.v},...or(e.r)]}function ja(e,t,n){if(tt(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 Is(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(Pa(t))return nh(wt(e,{lvl:n-1}));if(!tt(t)&&!tt(t.r))return wt(t.r,{l:wt(t,{r:t.r.l}),lvl:n,r:wt(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(Pa(e))return _a(wt(e,{lvl:n-1}));if(!tt(r)&&!tt(r.l)){const o=r.l,s=Pa(o)?r.lvl-1:r.lvl;return wt(o,{l:wt(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:_a(wt(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function wt(e,t){return eh(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 Zf(e){return tt(e.r)?e.l:Is(wt(e,{r:Zf(e.r)}))}function Pa(e){return tt(e)||e.lvl>e.r.lvl}function Qf(e){return tt(e.r)?[e.k,e.v]:Qf(e.r)}function eh(e,t,n,r=po,o=po){return{k:e,l:r,lvl:n,r:o,v:t}}function th(e){return _a(nh(e))}function nh(e){const{l:t}=e;return!tt(t)&&t.lvl===e.lvl?wt(t,{r:wt(e,{l:t.r})}):e}function _a(e){const{lvl:t,r:n}=e;return!tt(n)&&!tt(n.r)&&n.lvl===t&&n.r.lvl===t?wt(n,{l:wt(e,{r:n.l}),lvl:t+1}):e}function BS(e){return Jf(e,({k:t,v:n})=>({index:t,value:n}))}function rh(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function go(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const Ra=qe(()=>({recalcInProgress:oe(!1)}),[],{singleton:!0});function oh(e,t,n){return e[Ns(e,t,n)]}function Ns(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 zS(e,t,n,r){const o=Ns(e,t,r),s=Ns(e,n,r,o);return e.slice(o,s+1)}function Un(e,t){return Math.round(e.getBoundingClientRect()[t])}function As(e){return!tt(e.groupOffsetTree)}function Ma({index:e},t){return t===e?0:t<e?-1:1}function HS(){return{groupIndices:[],groupOffsetTree:_r(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:_r()}}function US(e,t){let n=tt(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),tt(e)){e=tn(e,0,s);continue}const a=Es(e,i-1,o+1);if(a.some(XS(r)))continue;let l=!1,c=!1;for(const{end:d,start:f,value:m}of a)l?(o>=f||s===m)&&(e=Aa(e,f)):(c=m!==s,l=!0),d>o&&o>=f&&m!==s&&(e=tn(e,o+1,m));c&&(e=tn(e,i,s))}return[e,n]}function WS(e){return typeof e.groupIndex<"u"}function VS({offset:e},t){return t===e?0:t<e?-1:1}function xo(e,t,n){if(t.length===0)return 0;const{index:r,offset:o,size:s}=oh(t,e,Ma),i=e-r,a=s*i+(i-1)*n+o;return a>0?a+n:a}function sh(e,t){if(!As(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function ih(e,t,n){if(WS(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=sh(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function KS(e,t,n,r=0){return r>0&&(t=Math.max(t,oh(e,r,Ma).offset)),Jf(zS(e,t,n,VS),YS)}function qS(e,[t,n,r,o]){t.length>0&&r("received item sizes",t,Vt.DEBUG);const s=e.sizeTree;let i=s,a=0;if(n.length>0&&tt(s)&&t.length===2){const m=t[0].size,h=t[1].size;i=n.reduce((v,g)=>tn(tn(v,g,m),g+1,h),i)}else[i,a]=US(i,t);if(i===s)return e;const{lastIndex:l,lastOffset:c,lastSize:d,offsetTree:f}=Oa(e.offsetTree,a,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((m,h)=>tn(m,h,xo(h,f,o)),_r()),lastIndex:l,lastOffset:c,lastSize:d,offsetTree:f,sizeTree:i}}function GS(e){return or(e).map(({k:t,v:n},r,o)=>{const s=o[r+1];return{endIndex:s?s.k-1:1/0,size:n,startIndex:t}})}function ah(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 Oa(e,t,n,r){let o=e,s=0,i=0,a=0,l=0;if(t!==0){l=Ns(o,t-1,Ma),a=o[l].offset;const c=hn(n,t-1);s=c[0],i=c[1],o.length&&o[l].size===hn(n,t)[1]&&(l-=1),o=o.slice(0,l+1)}else o=[];for(const{start:c,value:d}of Es(n,t,1/0)){const f=c-s,m=f*i+a+f*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 YS(e){return{index:e.index,value:e}}function XS(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 JS={offsetHeight:"height",offsetWidth:"width"},En=qe(([{log:e},{recalcInProgress:t}])=>{const n=He(),r=He(),o=Mt(r,0),s=He(),i=He(),a=oe(0),l=oe([]),c=oe(void 0),d=oe(void 0),f=oe((C,T)=>Un(C,JS[T])),m=oe(void 0),h=oe(0),v=HS(),g=Mt(ne(n,$e(l,e,h),kn(qS,v),ot()),v),x=Mt(ne(l,ot(),kn((C,T)=>({current:T,prev:C.current}),{current:[],prev:[]}),he(({prev:C})=>C)),[]);be(ne(l,Ne(C=>C.length>0),$e(g,h),he(([C,T,I])=>{const N=C.reduce((R,O,$)=>tn(R,O,xo(O,T.offsetTree,I)||$),_r());return{...T,groupIndices:C,groupOffsetTree:N}})),g),be(ne(r,$e(g),Ne(([C,{lastIndex:T}])=>C<T),he(([C,{lastIndex:T,lastSize:I}])=>[{endIndex:T,size:I,startIndex:C}])),n),be(c,d);const y=Mt(ne(c,he(C=>C===void 0)),!0);be(ne(d,Ne(C=>C!==void 0&&tt(mt(g).sizeTree)),he(C=>[{endIndex:0,size:C,startIndex:0}])),n);const w=en(ne(n,$e(g),kn(({sizes:C},[T,I])=>({changed:I!==C,sizes:I}),{changed:!1,sizes:v}),he(C=>C.changed)));Je(ne(a,kn((C,T)=>({diff:C.prev-T,prev:T}),{diff:0,prev:0}),he(C=>C.diff)),C=>{const{groupIndices:T}=mt(g);if(C>0)Me(t,!0),Me(s,C+ah(C,T));else if(C<0){const I=mt(x);I.length>0&&(C-=ah(-C,I)),Me(i,C)}}),Je(ne(a,$e(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},Vt.ERROR)});const S=en(s);be(ne(s,$e(g),he(([C,T])=>{const I=T.groupIndices.length>0,N=[],R=T.lastSize;if(I){const O=mo(T.sizeTree,0);let $=0,V=0;for(;$<C;){const j=T.groupIndices[V],q=T.groupIndices.length===V+1?1/0:T.groupIndices[V+1]-j-1;N.push({endIndex:j,size:O,startIndex:j}),N.push({endIndex:j+1+q-1,size:R,startIndex:j+1}),V++,$+=q+1}const U=or(T.sizeTree);return $!==C&&U.shift(),U.reduce((j,{k:q,v:K})=>{let D=j.ranges;return j.prevSize!==0&&(D=[...j.ranges,{endIndex:q+C-1,size:j.prevSize,startIndex:j.prevIndex}]),{prevIndex:q+C,prevSize:K,ranges:D}},{prevIndex:C,prevSize:0,ranges:N}).ranges}return or(T.sizeTree).reduce((O,{k:$,v:V})=>({prevIndex:$+C,prevSize:V,ranges:[...O.ranges,{endIndex:$+C-1,size:O.prevSize,startIndex:O.prevIndex}]}),{prevIndex:0,prevSize:R,ranges:[]}).ranges})),n);const k=en(ne(i,$e(g,h),he(([C,{offsetTree:T},I])=>{const N=-C;return xo(N,T,I)})));return be(ne(i,$e(g,h),he(([C,T,I])=>{if(T.groupIndices.length>0){if(tt(T.sizeTree))return T;let N=_r();const R=mt(x);let O=0,$=0,V=0;for(;O<-C;){V=R[$];const U=R[$+1]-V-1;$++,O+=U+1}if(N=or(T.sizeTree).reduce((U,{k:j,v:q})=>tn(U,Math.max(0,j+C),q),N),O!==-C){const U=mo(T.sizeTree,V);N=tn(N,0,U);const j=hn(T.sizeTree,-C+1)[1];N=tn(N,1,j)}return{...T,sizeTree:N,...Oa(T.offsetTree,0,N,I)}}else{const N=or(T.sizeTree).reduce((R,{k:O,v:$})=>tn(R,Math.max(0,O+C),$),_r());return{...T,sizeTree:N,...Oa(T.offsetTree,0,N,I)}}})),g),{beforeUnshiftWith:S,data:m,defaultItemSize:d,firstItemIndex:a,fixedItemSize:c,gap:h,groupIndices:l,itemSize:f,listRefresh:w,shiftWith:i,shiftWithOffset:k,sizeRanges:n,sizes:g,statefulTotalCount:o,totalCount:r,trackItemSizes:y,unshiftWith:s}},rt(Hn,Ra),{singleton:!0});function ZS(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const lh=qe(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=He(),i=He(),a=en(ne(s,he(ZS)));return be(ne(a,he(l=>l.totalCount)),n),be(ne(a,he(l=>l.groupIndices)),e),be(ne(vt(o,t,r),Ne(([l,c])=>As(c)),he(([l,c,d])=>hn(c.groupOffsetTree,Math.max(l-d,0),"v")[0]),ot(),he(l=>[l])),i),{groupCounts:s,topItemsIndexes:i}},rt(En,Bt)),Wn=qe(([{log:e}])=>{const t=oe(!1),n=en(ne(t,Ne(r=>r),ot()));return Je(t,r=>{r&&mt(e)("props updated",{},Vt.DEBUG)}),{didMount:n,propsReady:t}},rt(Hn),{singleton:!0}),QS=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function ch(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!QS)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const vo=qe(([{gap:e,listRefresh:t,sizes:n,totalCount:r},{fixedFooterHeight:o,fixedHeaderHeight:s,footerHeight:i,headerHeight:a,scrollingInProgress:l,scrollTo:c,smoothScrollTargetReached:d,viewportHeight:f},{log:m}])=>{const h=He(),v=He(),g=oe(0);let x=null,y=null,w=null;function S(){x&&(x(),x=null),w&&(w(),w=null),y&&(clearTimeout(y),y=null),Me(l,!1)}return be(ne(h,$e(n,f,r,g,a,i,m),$e(e,s,o),he(([[k,C,T,I,N,R,O,$],V,U,j])=>{const q=ch(k),{align:K,behavior:D,offset:_}=q,E=I-1,B=ih(q,C,E);let Y=xo(B,C.offsetTree,V)+R;K==="end"?(Y+=U+hn(C.sizeTree,B)[1]-T+j,B===E&&(Y+=O)):K==="center"?Y+=(U+hn(C.sizeTree,B)[1]-T+j)/2:Y-=N,_&&(Y+=_);const P=M=>{S(),M?($("retrying to scroll to",{location:k},Vt.DEBUG),Me(h,k)):(Me(v,!0),$("list did not change, scroll successful",{},Vt.DEBUG))};if(S(),D==="smooth"){let M=!1;w=Je(t,G=>{M=M||G}),x=fn(d,()=>{P(M)})}else x=fn(ne(t,eC(150)),P);return y=setTimeout(()=>{S()},1200),Me(l,!0),$("scrolling from index to",{behavior:D,index:B,top:Y},Vt.DEBUG),{behavior:D,top:Y}})),c),{scrollTargetReached:v,scrollToIndex:h,topListHeight:g}},rt(En,Bt,Hn),{singleton:!0});function eC(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function Da(e,t){e==0?t():requestAnimationFrame(()=>{Da(e-1,t)})}function La(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const bo=qe(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:s},{didMount:i}])=>{const a=oe(!0),l=oe(0),c=oe(!0);return be(ne(i,$e(l),Ne(([d,f])=>!!f),Tn(!1)),a),be(ne(i,$e(l),Ne(([d,f])=>!!f),Tn(!1)),c),Je(ne(vt(t,i),$e(a,n,e,c),Ne(([[,d],f,{sizeTree:m},h,v])=>d&&(!tt(m)||ka(h))&&!f&&!v),$e(l)),([,d])=>{fn(o,()=>{Me(c,!0)}),Da(4,()=>{fn(r,()=>{Me(a,!0)}),Me(s,d)})}),{initialItemFinalLocationReached:c,initialTopMostItemIndex:l,scrolledToInitialItem:a}},rt(En,Bt,vo,Wn),{singleton:!0});function uh(e,t){return Math.abs(e-t)<1.01}const wo="up",yo="down",tC="none",nC={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},rC=0,So=qe(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=oe(!1),a=oe(!0),l=He(),c=He(),d=oe(4),f=oe(rC),m=Mt(ne(Ia(ne(Ee(o),nr(1),Tn(!0)),ne(Ee(o),nr(1),Tn(!1),qf(100))),ot()),!1),h=Mt(ne(Ia(ne(n,Tn(!0)),ne(n,Tn(!1),qf(200))),ot()),!1);be(ne(vt(Ee(o),Ee(f)),he(([w,S])=>w<=S),ot()),a),be(ne(a,jn(50)),c);const v=en(ne(vt(r,Ee(s),Ee(t),Ee(e),Ee(d)),kn((w,[{scrollHeight:S,scrollTop:k},C,T,I,N])=>{const R=k+C-S>-N,O={scrollHeight:S,scrollTop:k,viewportHeight:C};if(R){let V,U;return k>w.state.scrollTop?(V="SCROLLED_DOWN",U=w.state.scrollTop-k):(V="SIZE_DECREASED",U=w.state.scrollTop-k||w.scrollTopDelta),{atBottom:!0,atBottomBecause:V,scrollTopDelta:U,state:O}}let $;return O.scrollHeight>w.state.scrollHeight?$="SIZE_INCREASED":C<w.state.viewportHeight?$="VIEWPORT_HEIGHT_DECREASING":k<w.state.scrollTop?$="SCROLLING_UPWARDS":$="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:$,state:O}},nC),ot((w,S)=>w&&w.atBottom===S.atBottom))),g=Mt(ne(r,kn((w,{scrollHeight:S,scrollTop:k,viewportHeight:C})=>{if(uh(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}),Ne(w=>w.changed),he(w=>w.jump)),0);be(ne(v,he(w=>w.atBottom)),i),be(ne(i,jn(50)),l);const x=oe(yo);be(ne(r,he(({scrollTop:w})=>w),ot(),kn((w,S)=>mt(h)?{direction:w.direction,prevScrollTop:S}:{direction:S<w.prevScrollTop?wo:yo,prevScrollTop:S},{direction:yo,prevScrollTop:0}),he(w=>w.direction)),x),be(ne(r,jn(50),Tn(tC)),x);const y=oe(0);return be(ne(m,Ne(w=>!w),Tn(0)),y),be(ne(o,jn(100),$e(m),Ne(([w,S])=>!!S),kn(([w,S],[k])=>[S,k],[0,0]),he(([w,S])=>S-w)),y),{atBottomState:v,atBottomStateChange:l,atBottomThreshold:d,atTopStateChange:c,atTopThreshold:f,isAtBottom:i,isAtTop:a,isScrolling:m,lastJumpDueToItemResize:g,scrollDirection:x,scrollVelocity:y}},rt(Bt)),js="top",Ps="bottom",dh="none";function fh(e,t,n){return typeof e=="number"?n===wo&&t===js||n===yo&&t===Ps?e:0:n===wo?t===js?e.main:e.reverse:t===Ps?e.main:e.reverse}function hh(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const $a=qe(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=He(),i=oe(0),a=oe(0),l=oe(0),c=Mt(ne(vt(Ee(r),Ee(o),Ee(n),Ee(s,go),Ee(l),Ee(i),Ee(t),Ee(e),Ee(a)),he(([d,f,m,[h,v],g,x,y,w,S])=>{const k=d-w,C=x+y,T=Math.max(m-k,0);let I=dh;const N=hh(S,js),R=hh(S,Ps);return h-=w,h+=m+y,v+=m+y,v-=w,h>d+C-N&&(I=wo),v<d-T+f+R&&(I=yo),I!==dh?[Math.max(k-m-fh(g,js,I)-N,0),k-T-y+f+fh(g,Ps,I)+R]:null}),Ne(d=>d!=null),ot(go)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:l,topListHeight:i,visibleRange:c}},rt(Bt),{singleton:!0});function oC(e,t,n){if(As(t)){const r=sh(e,t);return[{index:hn(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 Fa={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 f=n-i,m=a+f*l+(f-1)*r,h=c,v=m-d;return{bottom:d,firstItemIndex:s,items:mh(e,o,s),offsetBottom:v,offsetTop:c,top:h,topItems:mh(t,o,s),topListHeight:t.reduce((g,x)=>x.size+g,0),totalCount:n}}function ph(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=La(t,a),c=Array.from({length:a}).map((d,f)=>({data:s[f+l],index:f+l,offset:0,size:0}));return _s(c,[],a,o,n,r)}function mh(e,t,n){if(e.length===0)return[];if(!As(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=Es(t.groupOffsetTree,r,o);let a,l=0;for(const c of e){(!a||a.end<c.index)&&(a=i.shift(),l=t.groupIndices.indexOf(a.start));let d;c.index===a.start?d={index:l,type:"group"}:d={groupIndex:l,index:c.index-(l+1)+n},s.push({...d,data:c.data,offset:c.offset,originalIndex:c.index,size:c.size})}return s}const sr=qe(([{data:e,firstItemIndex:t,gap:n,sizes:r,totalCount:o},s,{listBoundary:i,topListHeight:a,visibleRange:l},{initialTopMostItemIndex:c,scrolledToInitialItem:d},{topListHeight:f},m,{didMount:h},{recalcInProgress:v}])=>{const g=oe([]),x=oe(0),y=He();be(s.topItemsIndexes,g);const w=Mt(ne(vt(h,v,Ee(l,go),Ee(o),Ee(r),Ee(c),d,Ee(g),Ee(t),Ee(n),e),Ne(([T,I,,N,,,,,,,R])=>{const O=R&&R.length!==N;return T&&!I&&!O}),he(([,,[T,I],N,R,O,$,V,U,j,q])=>{const K=R,{offsetTree:D,sizeTree:_}=K,E=mt(x);if(N===0)return{...Fa,totalCount:N};if(T===0&&I===0)return E===0?{...Fa,totalCount:N}:ph(E,O,R,U,j,q||[]);if(tt(_))return E>0?null:_s(oC(La(O,N),K,q),[],N,j,K,U);const B=[];if(V.length>0){const J=V[0],se=V[V.length-1];let W=0;for(const L of Es(_,J,se)){const X=L.value,ee=Math.max(L.start,J),Z=Math.min(L.end,se);for(let z=ee;z<=Z;z++)B.push({data:q==null?void 0:q[z],index:z,offset:W,size:X}),W+=X}}if(!$)return _s([],B,N,j,K,U);const Y=V.length>0?V[V.length-1]+1:0,P=KS(D,T,I,Y);if(P.length===0)return null;const M=N-1,G=ks([],J=>{for(const se of P){const W=se.value;let L=W.offset,X=se.start;const ee=W.size;if(W.offset<T){X+=Math.floor((T-W.offset+j)/(ee+j));const z=X-se.start;L+=z*ee+z*j}X<Y&&(L+=(Y-X)*ee,X=Y);const Z=Math.min(se.end,M);for(let z=X;z<=Z&&!(L>=I);z++)J.push({data:q==null?void 0:q[z],index:z,offset:L,size:ee}),L+=ee+j}});return _s(G,B,N,j,K,U)}),Ne(T=>T!==null),ot()),Fa);be(ne(e,Ne(ka),he(T=>T==null?void 0:T.length)),o),be(ne(w,he(T=>T.topListHeight)),f),be(f,a),be(ne(w,he(T=>[T.top,T.bottom])),i),be(ne(w,he(T=>T.items)),y);const S=en(ne(w,Ne(({items:T})=>T.length>0),$e(o,e),Ne(([{items:T},I])=>T[T.length-1].originalIndex===I-1),he(([,T,I])=>[T-1,I]),ot(go),he(([T])=>T))),k=en(ne(w,jn(200),Ne(({items:T,topItems:I})=>T.length>0&&T[0].originalIndex===I.length),he(({items:T})=>T[0].index),ot())),C=en(ne(w,Ne(({items:T})=>T.length>0),he(({items:T})=>{let I=0,N=T.length-1;for(;T[I].type==="group"&&I<N;)I++;for(;T[N].type==="group"&&N>I;)N--;return{endIndex:T[N].index,startIndex:T[I].index}}),ot(rh)));return{endReached:S,initialItemCount:x,itemsRendered:y,listState:w,rangeChanged:C,startReached:k,topItemsIndexes:g,...m}},rt(En,lh,$a,bo,vo,So,Wn,Ra),{singleton:!0}),gh=qe(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=He(),i=Mt(ne(vt(n,e,r,t,o),he(([a,l,c,d,f])=>a+l+c+d+f.offsetBottom+f.bottom)),0);return be(Ee(i),s),{totalListHeight:i,totalListHeightChanged:s}},rt(Bt,sr),{singleton:!0}),sC=qe(([{viewportHeight:e},{totalListHeight:t}])=>{const n=oe(!1),r=Mt(ne(vt(n,e,t),Ne(([o])=>o),he(([,o,s])=>Math.max(0,o-s)),jn(0),ot()),0);return{alignToBottom:n,paddingTopAddition:r}},rt(Bt,gh),{singleton:!0}),xh=qe(()=>({context:oe(null)})),iC=({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,vh=qe(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:s,scrollingInProgress:i,scrollTop:a,viewportHeight:l},{scrollToIndex:c}])=>{const d=He();return be(ne(d,$e(t,l,n,s,o,r,a),$e(e),he(([[f,m,h,v,g,x,y,w],S])=>{const{align:k,behavior:C,calculateViewLocation:T=iC,done:I,...N}=f,R=ih(f,m,v-1),O=xo(R,m.offsetTree,S)+g+x,$=O+hn(m.sizeTree,R)[1],V=w+x,U=w+h-y,j=T({itemBottom:$,itemTop:O,locationParams:{align:k,behavior:C,...N},viewportBottom:U,viewportTop:V});return j?I&&fn(ne(i,Ne(q=>!q),nr(mt(i)?1:2)),I):I&&I(),j}),Ne(f=>f!==null)),c),{scrollIntoView:d}},rt(En,Bt,vo,sr,Hn),{singleton:!0});function bh(e){return e?e==="smooth"?"smooth":"auto":!1}const aC=(e,t)=>typeof e=="function"?bh(e(t)):t&&bh(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:f},{context:m},{scrollIntoView:h}])=>{const v=oe(!1),g=He();let x=null;function y(C){Me(i,{align:"end",behavior:C,index:"LAST"})}Je(ne(vt(ne(Ee(t),nr(1)),l),$e(Ee(v),s,a,f),he(([[C,T],I,N,R,O])=>{let $=T&&R,V="auto";return $&&(V=aC(I,N||O),$=$&&!!V),{followOutputBehavior:V,shouldFollow:$,totalCount:C}}),Ne(({shouldFollow:C})=>C)),({followOutputBehavior:C,totalCount:T})=>{x&&(x(),x=null),mt(n)?requestAnimationFrame(()=>{mt(d)("following output to ",{totalCount:T},Vt.DEBUG),y(C)}):x=fn(e,()=>{mt(d)("following output to ",{totalCount:T},Vt.DEBUG),y(C),x=null})});function w(C){const T=fn(o,I=>{C&&!I.atBottom&&I.notAtBottomBecause==="SIZE_INCREASED"&&!x&&(mt(d)("scrolling to bottom due to increased size",{},Vt.DEBUG),y("auto"))});setTimeout(T,100)}Je(ne(vt(Ee(v),t,c),Ne(([C,,T])=>C&&T),kn(({value:C},[,T])=>({refreshed:C===T,value:T}),{refreshed:!1,value:0}),Ne(({refreshed:C})=>C),$e(v,t)),([,C])=>{mt(a)&&w(C!==!1)}),Je(g,()=>{w(mt(v)!==!1)}),Je(vt(Ee(v),o),([C,T])=>{C&&!T.atBottom&&T.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&y("auto")});const S=oe(null),k=He();return be(Ia(ne(Ee(r),he(C=>{var T;return(T=C==null?void 0:C.length)!=null?T:0})),ne(Ee(t))),k),Je(ne(vt(ne(k,nr(1)),l),$e(Ee(S),a,f,m),he(([[C,T],I,N,R,O])=>T&&N&&(I==null?void 0:I({context:O,totalCount:C,scrollingInProgress:R}))),Ne(C=>!!C),jn(0)),C=>{x&&(x(),x=null),mt(n)?requestAnimationFrame(()=>{mt(d)("scrolling into view",{}),Me(h,C)}):x=fn(e,()=>{mt(d)("scrolling into view",{}),Me(h,C),x=null})}),{autoscrollToBottom:g,followOutput:v,scrollIntoViewOnChange:S}},rt(En,So,vo,bo,Wn,Hn,Bt,xh,vh)),cC=qe(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(be(ne(a,$e(s),Ne(([,l])=>l!==0),$e(o,r,t,n,e),he(([[,l],c,d,f,m,h=[]])=>ph(l,c,d,f,m,h))),i),{}),rt(En,bo,sr,Wn),{singleton:!0}),uC=qe(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=oe(0);return Je(ne(e,$e(r),Ne(([,o])=>o!==0),he(([,o])=>({top:o}))),o=>{fn(ne(n,nr(1),Ne(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{Me(t,o)})})}),{initialScrollTop:r}},rt(Wn,Bt,sr),{singleton:!0}),wh=qe(([{scrollVelocity:e}])=>{const t=oe(!1),n=He(),r=oe(!1);return be(ne(e,$e(r,t,n),Ne(([o,s])=>!!s),he(([o,s,i,a])=>{const{enter:l,exit:c}=s;if(i){if(c(o,a))return!1}else if(l(o,a))return!0;return i}),ot()),t),Je(ne(vt(t,e,n),$e(r)),([[o,s,i],a])=>{o&&a&&a.change&&a.change(s,i)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},rt(So),{singleton:!0}),Ba=qe(([{scrollContainerState:e,scrollTo:t}])=>{const n=He(),r=He(),o=He(),s=oe(!1),i=oe(void 0);return be(ne(vt(n,r),he(([{scrollHeight:a,scrollTop:l,viewportHeight:c},{offsetTop:d}])=>({scrollHeight:a,scrollTop:Math.max(0,l-d),viewportHeight:c}))),e),be(ne(t,$e(r),he(([a,{offsetTop:l}])=>({...a,top:a.top+l}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},rt(Bt)),dC=qe(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:a,windowViewportRect:l}])=>{const c=He(),d=oe(void 0),f=oe(null),m=oe(null);return be(a,f),be(l,m),Je(ne(c,$e(t,r,i,f,m,n)),([h,v,g,x,y,w,S])=>{const k=GS(v.sizeTree);x&&y!==null&&w!==null&&(g=y.scrollTop-w.offsetTop),g-=S,h({ranges:k,scrollTop:g})}),be(ne(d,Ne(ka),he(fC)),o),be(ne(s,$e(d),Ne(([,h])=>h!==void 0),ot(),he(([,h])=>h.ranges)),e),{getState:c,restoreStateFrom:d}},rt(En,Bt,bo,Wn,Ba));function fC(e){return{align:"start",index:0,offset:e.scrollTop}}const hC=qe(([{topItemsIndexes:e}])=>{const t=oe(0);return be(ne(t,Ne(n=>n>=0),he(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},rt(sr));function yh(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const pC=yh(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),mC=qe(([{deviation:e,scrollBy:t,scrollingInProgress:n,scrollTop:r},{isAtBottom:o,isScrolling:s,lastJumpDueToItemResize:i,scrollDirection:a},{listState:l},{beforeUnshiftWith:c,gap:d,shiftWithOffset:f,sizes:m},{log:h},{recalcInProgress:v}])=>{const g=en(ne(l,$e(i),kn(([,y,w,S],[{bottom:k,items:C,offsetBottom:T,totalCount:I},N])=>{const R=k+T;let O=0;return w===I&&y.length>0&&C.length>0&&(C[0].originalIndex===0&&y[0].originalIndex===0||(O=R-S,O!==0&&(O+=N))),[O,C,I,R]},[0,[],0,0]),Ne(([y])=>y!==0),$e(r,a,n,o,h,v),Ne(([,y,w,S,,,k])=>!k&&!S&&y!==0&&w===wo),he(([[y],,,,,w])=>(w("Upward scrolling compensation",{amount:y},Vt.DEBUG),y))));function x(y){y>0?(Me(t,{behavior:"auto",top:-y}),Me(e,0)):(Me(e,0),Me(t,{behavior:"auto",top:-y}))}return Je(ne(g,$e(e,s)),([y,w,S])=>{S&&pC()?Me(e,w-y):x(-y)}),Je(ne(vt(Mt(s,!1),e,v),Ne(([y,w,S])=>!y&&!S&&w!==0),he(([y,w])=>w),jn(1)),x),be(ne(f,he(y=>({top:-y}))),t),Je(ne(c,$e(m,d),he(([y,{groupIndices:w,lastSize:S,sizeTree:k},C])=>{function T(I){return I*(S+C)}if(w.length===0)return T(y);{let I=0;const N=mo(k,0);let R=0,O=0;for(;R<y;){R++,I+=N;let $=w.length===O+1?1/0:w[O+1]-w[O]-1;R+$>y&&(I-=N,$=y-R+1),R+=$,I+=T($),O++}return I}})),y=>{Me(e,y),requestAnimationFrame(()=>{Me(t,{top:y}),requestAnimationFrame(()=>{Me(e,0),Me(v,!1)})})}),{deviation:e}},rt(Bt,So,sr,En,Hn,Ra)),gC=qe(([e,t,n,r,o,s,i,a,l,c,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...l,...c,...d}),rt($a,cC,Wn,wh,gh,uC,sC,Ba,vh,Hn,xh)),Sh=qe(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:r,gap:o,groupIndices:s,itemSize:i,sizeRanges:a,sizes:l,statefulTotalCount:c,totalCount:d,trackItemSizes:f},{initialItemFinalLocationReached:m,initialTopMostItemIndex:h,scrolledToInitialItem:v},g,x,y,{listState:w,topItemsIndexes:S,...k},{scrollToIndex:C},T,{topItemCount:I},{groupCounts:N},R])=>(be(k.rangeChanged,R.scrollSeekRangeChanged),be(ne(R.windowViewportRect,he(O=>O.visibleHeight)),g.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,gap:o,groupCounts:N,initialItemFinalLocationReached:m,initialTopMostItemIndex:h,scrolledToInitialItem:v,sizeRanges:a,topItemCount:I,topItemsIndexes:S,totalCount:d,...y,groupIndices:s,itemSize:i,listState:w,scrollToIndex:C,statefulTotalCount:c,trackItemSizes:f,...k,...R,...g,sizes:l,...x}),rt(En,bo,Bt,dC,lC,sr,vo,mC,hC,lh,gC));function xC(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 Rs=typeof document<"u"?b.useLayoutEffect:b.useEffect;function Ch(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&&Me(x.propsReady,!1);for(const w of r){const S=x[t.required[w]];Me(S,y[w])}for(const w of o)if(w in y){const S=x[t.optional[w]];Me(S,y[w])}x.propsReady&&Me(x.propsReady,!0)}function c(x){return s.reduce((y,w)=>(y[w]=S=>{const k=x[t.methods[w]];Me(k,S)},y),{})}function d(x){return i.reduce((y,w)=>(y[w]=RS(x[t.events[w]]),y),{})}const f=b.forwardRef((x,y)=>{const{children:w,...S}=x,[k]=b.useState(()=>ks(OS(e),I=>{l(I,S)})),[C]=b.useState(Kf(d,k));Rs(()=>{for(const I of i)I in S&&Je(C[I],S[I]);return()=>{Object.values(C).map(Ea)}},[S,C,k]),Rs(()=>{l(k,S)}),b.useImperativeHandle(y,Wf(c(k)));const T=n;return u.jsx(a.Provider,{value:k,children:n?u.jsx(T,{...xC([...r,...o,...i],S),children:w}):w})}),m=x=>{const y=b.useContext(a);return b.useCallback(w=>{Me(y[x],w)},[y,x])},h=x=>{const y=b.useContext(a)[x],w=b.useCallback(S=>Je(y,S),[y]);return b.useSyncExternalStore(w,()=>mt(y),()=>mt(y))},v=x=>{const y=b.useContext(a)[x],[w,S]=b.useState(Kf(mt,y));return Rs(()=>Je(y,k=>{k!==w&&S(Wf(k))}),[y,w]),w},g=b.version.startsWith("18")?h:v;return{Component:f,useEmitter:(x,y)=>{const w=b.useContext(a)[x];Rs(()=>Je(w,y),[y,w])},useEmitterValue:g,usePublisher:m}}const Th=b.createContext(void 0),kh=b.createContext(void 0),Eh=typeof document<"u"?b.useLayoutEffect:b.useEffect;function za(e){return"self"in e}function vC(e){return"body"in e}function Ih(e,t,n,r=Pr,o,s){const i=b.useRef(null),a=b.useRef(null),l=b.useRef(null),c=b.useCallback(m=>{let h,v,g;const x=m.target;if(vC(x)||za(x)){const w=za(x)?x:x.defaultView;g=s?w.scrollX:w.scrollY,h=s?w.document.documentElement.scrollWidth:w.document.documentElement.scrollHeight,v=s?w.innerWidth:w.innerHeight}else g=s?x.scrollLeft:x.scrollTop,h=s?x.scrollWidth:x.scrollHeight,v=s?x.offsetWidth:x.offsetHeight;const y=()=>{e({scrollHeight:h,scrollTop:Math.max(g,0),viewportHeight:v})};m.suppressFlushSync?y():_o.flushSync(y),a.current!==null&&(g===a.current||g<=0||g===h-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 h=i.current;if(!h||(s?"offsetWidth"in h&&h.offsetWidth===0:"offsetHeight"in h&&h.offsetHeight===0))return;const v=m.behavior==="smooth";let g,x,y;za(h)?(x=Math.max(Un(h.document.documentElement,s?"width":"height"),s?h.document.documentElement.scrollWidth:h.document.documentElement.scrollHeight),g=s?h.innerWidth:h.innerHeight,y=s?window.scrollX:window.scrollY):(x=h[s?"scrollWidth":"scrollHeight"],g=Un(h,s?"width":"height"),y=h[s?"scrollLeft":"scrollTop"]);const w=x-g;if(m.top=Math.ceil(Math.max(Math.min(w,m.top),0)),uh(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}),h.scrollTo(m)}function f(m){s&&(m={behavior:m.behavior,left:m.top}),i.current.scrollBy(m)}return{scrollByCallback:f,scrollerRef:i,scrollToCallback:d}}const Ha="-webkit-sticky",Nh="sticky",Ua=yh(()=>{if(typeof document>"u")return Nh;const e=document.createElement("div");return e.style.position=Ha,e.style.position===Ha?Ha:Nh});function Wa(e){return e}const bC=qe(()=>{const e=oe(a=>`Item ${a}`),t=oe(a=>`Group ${a}`),n=oe({}),r=oe(Wa),o=oe("div"),s=oe(Pr),i=(a,l=null)=>Mt(ne(n,he(c=>c[a]),ot()),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")}}),wC=qe(([e,t])=>({...e,...t}),rt(Sh,bC)),yC=({height:e})=>u.jsx("div",{style:{height:e}}),SC={overflowAnchor:"none",position:Ua(),zIndex:1},Ah={overflowAnchor:"none"},CC={...Ah,display:"inline-block",height:"100%"},jh=b.memo(function({showTopList:e=!1}){const t=Pe("listState"),n=rn("sizeRanges"),r=Pe("useWindowScroll"),o=Pe("customScrollParent"),s=rn("windowScrollContainerState"),i=rn("scrollContainerState"),a=o||r?s:i,l=Pe("itemContent"),c=Pe("context"),d=Pe("groupContent"),f=Pe("trackItemSizes"),m=Pe("itemSize"),h=Pe("log"),v=rn("gap"),g=Pe("horizontalDirection"),{callbackRef:x}=$S(n,m,f,e?Pr:a,h,v,o,g,Pe("skipAnimationFrameInResizeObserver")),[y,w]=b.useState(0);Va("deviation",j=>{y!==j&&w(j)});const S=Pe("EmptyPlaceholder"),k=Pe("ScrollSeekPlaceholder")||yC,C=Pe("ListComponent"),T=Pe("ItemComponent"),I=Pe("GroupComponent"),N=Pe("computeItemKey"),R=Pe("isSeeking"),O=Pe("groupIndices").length>0,$=Pe("alignToBottom"),V=Pe("initialItemFinalLocationReached"),U=e?{}:{boxSizing:"border-box",...g?{display:"inline-block",height:"100%",marginLeft:y!==0?y:$?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:y!==0?y:$?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...V?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&S?u.jsx(S,{...Ot(S,c)}):u.jsx(C,{...Ot(C,c),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:x,style:U,children:(e?t.topItems:t.items).map(j=>{const q=j.originalIndex,K=N(q+t.firstItemIndex,j.data,c);return R?b.createElement(k,{...Ot(k,c),height:j.size,index:j.index,key:K,type:j.type||"item",...j.type==="group"?{}:{groupIndex:j.groupIndex}}):j.type==="group"?b.createElement(I,{...Ot(I,c),"data-index":q,"data-item-index":j.index,"data-known-size":j.size,key:K,style:SC},d(j.index,c)):b.createElement(T,{...Ot(T,c),...IC(T,j.data),"data-index":q,"data-item-group-index":j.groupIndex,"data-item-index":j.index,"data-known-size":j.size,key:K,style:g?CC:Ah},O?l(j.index,j.groupIndex,j.data,c):l(j.index,j.data,c))})})}),TC={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},kC={outline:"none",overflowX:"auto",position:"relative"},Ms=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),EC={position:Ua(),top:0,width:"100%",zIndex:1};function Ot(e,t){if(typeof e!="string")return{context:t}}function IC(e,t){return{item:typeof e=="string"?void 0:t}}const NC=b.memo(function(){const e=Pe("HeaderComponent"),t=rn("headerHeight"),n=Pe("HeaderFooterTag"),r=rr(b.useMemo(()=>s=>{t(Un(s,"height"))},[t]),!0,Pe("skipAnimationFrameInResizeObserver")),o=Pe("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Ot(e,o)})}):null}),AC=b.memo(function(){const e=Pe("FooterComponent"),t=rn("footerHeight"),n=Pe("HeaderFooterTag"),r=rr(b.useMemo(()=>s=>{t(Un(s,"height"))},[t]),!0,Pe("skipAnimationFrameInResizeObserver")),o=Pe("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Ot(e,o)})}):null});function Ph({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"),f=t("horizontalDirection")||!1,{scrollByCallback:m,scrollerRef:h,scrollToCallback:v}=Ih(a,c,l,d,void 0,f);return e("scrollTo",v),e("scrollBy",m),u.jsx(l,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:h,style:{...f?kC:TC,...o},tabIndex:0,...i,...Ot(l,s),children:r})})}function _h({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"),f=t("deviation"),m=t("customScrollParent"),h=b.useRef(null),v=t("scrollerRef"),{scrollByCallback:g,scrollerRef:x,scrollToCallback:y}=Ih(a,c,l,v,m);return Eh(()=>{var w;return x.current=m||((w=h.current)==null?void 0:w.ownerDocument.defaultView),()=>{x.current=null}},[x,m]),e("windowScrollTo",y),e("scrollBy",g),u.jsx(l,{ref:h,"data-virtuoso-scroller":!0,style:{position:"relative",...o,...d!==0?{height:d+f}:{}},...i,...Ot(l,s),children:r})})}const jC=({children:e})=>{const t=b.useContext(Th),n=rn("viewportHeight"),r=rn("fixedItemHeight"),o=Pe("alignToBottom"),s=Pe("horizontalDirection"),i=b.useMemo(()=>Vf(n,l=>Un(l,s?"width":"height")),[n,s]),a=rr(i,!0,Pe("skipAnimationFrameInResizeObserver"));return b.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),u.jsx("div",{"data-viewport-type":"element",ref:a,style:Ms(o),children:e})},PC=({children:e})=>{const t=b.useContext(Th),n=rn("windowViewportRect"),r=rn("fixedItemHeight"),o=Pe("customScrollParent"),s=Xf(n,o,Pe("skipAnimationFrameInResizeObserver")),i=Pe("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:Ms(i),children:e})},_C=({children:e})=>{const t=Pe("TopItemListComponent")||"div",n=Pe("headerHeight"),r={...EC,marginTop:`${n}px`},o=Pe("context");return u.jsx(t,{style:r,...Ot(t,o),children:e})},RC=b.memo(function(e){const t=Pe("useWindowScroll"),n=Pe("topItemsIndexes").length>0,r=Pe("customScrollParent"),o=Pe("context");return u.jsxs(r||t?DC:OC,{...e,context:o,children:[n&&u.jsx(_C,{children:u.jsx(jh,{showTopList:!0})}),u.jsxs(r||t?PC:jC,{children:[u.jsx(NC,{}),u.jsx(jh,{}),u.jsx(AC,{})]})]})}),{Component:MC,useEmitter:Va,useEmitterValue:Pe,usePublisher:rn}=Ch(wC,{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"}},RC),OC=Ph({useEmitter:Va,useEmitterValue:Pe,usePublisher:rn}),DC=_h({useEmitter:Va,useEmitterValue:Pe,usePublisher:rn}),LC=MC;rt(Sh,qe(()=>{const e=oe(c=>u.jsxs("td",{children:["Item $",c]})),t=oe(null),n=oe(c=>u.jsxs("td",{colSpan:1e3,children:["Group ",c]})),r=oe(null),o=oe(null),s=oe({}),i=oe(Wa),a=oe(Pr),l=(c,d=null)=>Mt(ne(s,he(f=>f[c]),ot()),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")}})),Ua();const Rh={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},$C={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:Mh,floor:Os,max:Co,min:Ka,round:Oh}=Math;function Dh(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function FC(e){return{...$C,items:e}}function Ds(e,t){return e&&e.width===t.width&&e.height===t.height}function BC(e,t){return e&&e.column===t.column&&e.row===t.row}const zC=qe(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:r},{footerHeight:o,headerHeight:s,scrollBy:i,scrollContainerState:a,scrollTo:l,scrollTop:c,smoothScrollTargetReached:d,viewportHeight:f},m,h,{didMount:v,propsReady:g},{customScrollParent:x,useWindowScroll:y,windowScrollContainerState:w,windowScrollTo:S,windowViewportRect:k},C])=>{const T=oe(0),I=oe(0),N=oe(Rh),R=oe({height:0,width:0}),O=oe({height:0,width:0}),$=He(),V=He(),U=oe(0),j=oe(null),q=oe({column:0,row:0}),K=He(),D=He(),_=oe(!1),E=oe(0),B=oe(!0),Y=oe(!1),P=oe(!1);Je(ne(v,$e(E),Ne(([L,X])=>!!X)),()=>{Me(B,!1)}),Je(ne(vt(v,B,O,R,E,Y),Ne(([L,X,ee,Z,,z])=>L&&!X&&ee.height!==0&&Z.height!==0&&!z)),([,,,,L])=>{Me(Y,!0),Da(1,()=>{Me($,L)}),fn(ne(c),()=>{Me(t,[0,0]),Me(B,!0)})}),be(ne(D,Ne(L=>L!=null&&L.scrollTop>0),Tn(0)),I),Je(ne(v,$e(D),Ne(([,L])=>L!=null)),([,L])=>{L&&(Me(R,L.viewport),Me(O,L.item),Me(q,L.gap),L.scrollTop>0&&(Me(_,!0),fn(ne(c,nr(1)),X=>{Me(_,!1)}),Me(l,{top:L.scrollTop})))}),be(ne(R,he(({height:L})=>L)),f),be(ne(vt(Ee(R,Ds),Ee(O,Ds),Ee(q,(L,X)=>L&&L.column===X.column&&L.row===X.row),Ee(c)),he(([L,X,ee,Z])=>({gap:ee,item:X,scrollTop:Z,viewport:L}))),K),be(ne(vt(Ee(T),r,Ee(q,BC),Ee(O,Ds),Ee(R,Ds),Ee(j),Ee(I),Ee(_),Ee(B),Ee(E)),Ne(([,,,,,,,L])=>!L),he(([L,[X,ee],Z,z,ae,ie,ge,,we,Ae])=>{const{column:_e,row:ke}=Z,{height:st,width:bt}=z,{width:It}=ae;if(ge===0&&(L===0||It===0))return Rh;if(bt===0){const Pt=La(Ae,L),yt=Pt+Math.max(ge-1,0);return FC(Dh(Pt,yt,ie))}const We=Lh(It,bt,_e);let ze,Ke;we?X===0&&ee===0&&ge>0?(ze=0,Ke=ge-1):(ze=We*Os((X+ke)/(st+ke)),Ke=We*Mh((ee+ke)/(st+ke))-1,Ke=Ka(L-1,Co(Ke,We-1)),ze=Ka(Ke,Co(0,ze))):(ze=0,Ke=-1);const Fe=Dh(ze,Ke,ie),{bottom:Ue,top:ut}=$h(ae,Z,z,Fe),jt=Mh(L/We),it=jt*st+(jt-1)*ke-Ue;return{bottom:Ue,itemHeight:st,items:Fe,itemWidth:bt,offsetBottom:it,offsetTop:ut,top:ut}})),N),be(ne(j,Ne(L=>L!==null),he(L=>L.length)),T),be(ne(vt(R,O,N,q),Ne(([L,X,{items:ee}])=>ee.length>0&&X.height!==0&&L.height!==0),he(([L,X,{items:ee},Z])=>{const{bottom:z,top:ae}=$h(L,Z,X,ee);return[ae,z]}),ot(go)),t);const M=oe(!1);be(ne(c,$e(M),he(([L,X])=>X||L!==0)),M);const G=en(ne(vt(N,T),Ne(([{items:L}])=>L.length>0),$e(M),Ne(([[L,X],ee])=>{const Z=L.items[L.items.length-1].index===X-1;return(ee||L.bottom>0&&L.itemHeight>0&&L.offsetBottom===0&&L.items.length===X)&&Z}),he(([[,L]])=>L-1),ot())),J=en(ne(Ee(N),Ne(({items:L})=>L.length>0&&L[0].index===0),Tn(0),ot())),se=en(ne(Ee(N),$e(_),Ne(([{items:L},X])=>L.length>0&&!X),he(([{items:L}])=>({endIndex:L[L.length-1].index,startIndex:L[0].index})),ot(rh),jn(0)));be(se,h.scrollSeekRangeChanged),be(ne($,$e(R,O,T,q),he(([L,X,ee,Z,z])=>{const ae=ch(L),{align:ie,behavior:ge,offset:we}=ae;let Ae=ae.index;Ae==="LAST"&&(Ae=Z-1),Ae=Co(0,Ae,Ka(Z-1,Ae));let _e=qa(X,z,ee,Ae);return ie==="end"?_e=Oh(_e-X.height+ee.height):ie==="center"&&(_e=Oh(_e-X.height/2+ee.height/2)),we&&(_e+=we),{behavior:ge,top:_e}})),l);const W=Mt(ne(N,he(L=>L.offsetBottom+L.bottom)),0);return be(ne(k,he(L=>({height:L.visibleHeight,width:L.visibleWidth}))),R),{customScrollParent:x,data:j,deviation:U,footerHeight:o,gap:q,headerHeight:s,increaseViewportBy:e,initialItemCount:I,itemDimensions:O,overscan:n,restoreStateFrom:D,scrollBy:i,scrollContainerState:a,scrollHeight:V,scrollTo:l,scrollToIndex:$,scrollTop:c,smoothScrollTargetReached:d,totalCount:T,useWindowScroll:y,viewportDimensions:R,windowScrollContainerState:w,windowScrollTo:S,windowViewportRect:k,...h,gridState:N,horizontalDirection:P,initialTopMostItemIndex:E,totalListHeight:W,...m,endReached:G,propsReady:g,rangeChanged:se,startReached:J,stateChanged:K,stateRestoreInProgress:_,...C}},rt($a,Bt,So,wh,Wn,Ba,Hn));function Lh(e,t,n){return Co(1,Os((e+n)/(Os(t)+n)))}function $h(e,t,n,r){const{height:o}=n;if(o===void 0||r.length===0)return{bottom:0,top:0};const s=qa(e,t,n,r[0].index);return{bottom:qa(e,t,n,r[r.length-1].index)+o,top:s}}function qa(e,t,n,r){const o=Lh(e.width,n.width,t.column),s=Os(r/o),i=s*n.height+Co(0,s-1)*t.row;return i>0?i+t.row:i}const HC=qe(()=>{const e=oe(f=>`Item ${f}`),t=oe({}),n=oe(null),r=oe("virtuoso-grid-item"),o=oe("virtuoso-grid-list"),s=oe(Wa),i=oe("div"),a=oe(Pr),l=(f,m=null)=>Mt(ne(t,he(h=>h[f]),ot()),m),c=oe(!1),d=oe(!1);return be(Ee(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")}}),UC=qe(([e,t])=>({...e,...t}),rt(zC,HC)),WC=b.memo(function(){const e=lt("gridState"),t=lt("listClassName"),n=lt("itemClassName"),r=lt("itemContent"),o=lt("computeItemKey"),s=lt("isSeeking"),i=on("scrollHeight"),a=lt("ItemComponent"),l=lt("ListComponent"),c=lt("ScrollSeekPlaceholder"),d=lt("context"),f=on("itemDimensions"),m=on("gap"),h=lt("log"),v=lt("stateRestoreInProgress"),g=on("reportReadyState"),x=rr(b.useMemo(()=>y=>{const w=y.parentElement.parentElement.scrollHeight;i(w);const S=y.firstChild;if(S){const{height:k,width:C}=S.getBoundingClientRect();f({height:k,width:C})}m({column:Bh("column-gap",getComputedStyle(y).columnGap,h),row:Bh("row-gap",getComputedStyle(y).rowGap,h)})},[i,f,m,h]),!0,!1);return Eh(()=>{e.itemHeight>0&&e.itemWidth>0&&g(!0)},[e]),v?null:u.jsx(l,{className:t,ref:x,...Ot(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,{...Ot(c,d),height:e.itemHeight,index:y.index,width:e.itemWidth},w):b.createElement(a,{...Ot(a,d),className:n,"data-index":y.index,key:w},r(y.index,y.data,d))})})}),VC=b.memo(function(){const e=lt("HeaderComponent"),t=on("headerHeight"),n=lt("headerFooterTag"),r=rr(b.useMemo(()=>s=>{t(Un(s,"height"))},[t]),!0,!1),o=lt("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Ot(e,o)})}):null}),KC=b.memo(function(){const e=lt("FooterComponent"),t=on("footerHeight"),n=lt("headerFooterTag"),r=rr(b.useMemo(()=>s=>{t(Un(s,"height"))},[t]),!0,!1),o=lt("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Ot(e,o)})}):null}),qC=({children:e})=>{const t=b.useContext(kh),n=on("itemDimensions"),r=on("viewportDimensions"),o=rr(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:Ms(!1),children:e})},GC=({children:e})=>{const t=b.useContext(kh),n=on("windowViewportRect"),r=on("itemDimensions"),o=lt("customScrollParent"),s=Xf(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:Ms(!1),children:e})},YC=b.memo(function({...e}){const t=lt("useWindowScroll"),n=lt("customScrollParent"),r=n||t?JC:XC,o=n||t?GC:qC,s=lt("context");return u.jsx(r,{...e,...Ot(r,s),children:u.jsxs(o,{children:[u.jsx(VC,{}),u.jsx(WC,{}),u.jsx(KC,{})]})})}),{useEmitter:Fh,useEmitterValue:lt,usePublisher:on}=Ch(UC,{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"}},YC),XC=Ph({useEmitter:Fh,useEmitterValue:lt,usePublisher:on}),JC=_h({useEmitter:Fh,useEmitterValue:lt,usePublisher:on});function Bh(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Vt.WARN),t==="normal"?0:parseInt(t??"0",10)}var Ls="Dialog",[zh,AN]=cn(Ls),[ZC,pn]=zh(Ls),Hh=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:i=!0}=e,a=p.useRef(null),l=p.useRef(null),[c,d]=Dn({prop:r,defaultProp:o??!1,onChange:s,caller:Ls});return u.jsx(ZC,{scope:t,triggerRef:a,contentRef:l,contentId:Rt(),titleId:Rt(),descriptionId:Rt(),open:c,onOpenChange:d,onOpenToggle:p.useCallback(()=>d(f=>!f),[d]),modal:i,children:n})};Hh.displayName=Ls;var Uh="DialogTrigger",Wh=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=pn(Uh,n),s=Le(t,o.triggerRef);return u.jsx(ve.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Xa(o.open),...r,ref:s,onClick:ce(e.onClick,o.onOpenToggle)})});Wh.displayName=Uh;var Ga="DialogPortal",[QC,Vh]=zh(Ga,{forceMount:void 0}),Kh=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=pn(Ga,t);return u.jsx(QC,{scope:t,forceMount:n,children:p.Children.map(r,i=>u.jsx(Wt,{present:n||s.open,children:u.jsx(so,{asChild:!0,container:o,children:i})}))})};Kh.displayName=Ga;var $s="DialogOverlay",qh=p.forwardRef((e,t)=>{const n=Vh($s,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=pn($s,e.__scopeDialog);return s.modal?u.jsx(Wt,{present:r||s.open,children:u.jsx(tT,{...o,ref:t})}):null});qh.displayName=$s;var eT=Yt.createSlot("DialogOverlay.RemoveScroll"),tT=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=pn($s,n);return u.jsx(gs,{as:eT,allowPinchZoom:!0,shards:[o.contentRef],children:u.jsx(ve.div,{"data-state":Xa(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),ir="DialogContent",Gh=p.forwardRef((e,t)=>{const n=Vh(ir,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=pn(ir,e.__scopeDialog);return u.jsx(Wt,{present:r||s.open,children:s.modal?u.jsx(nT,{...o,ref:t}):u.jsx(rT,{...o,ref:t})})});Gh.displayName=ir;var nT=p.forwardRef((e,t)=>{const n=pn(ir,e.__scopeDialog),r=p.useRef(null),o=Le(t,n.contentRef,r);return p.useEffect(()=>{const s=r.current;if(s)return da(s)},[]),u.jsx(Yh,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ce(e.onCloseAutoFocus,s=>{var i;s.preventDefault(),(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:ce(e.onPointerDownOutside,s=>{const i=s.detail.originalEvent,a=i.button===0&&i.ctrlKey===!0;(i.button===2||a)&&s.preventDefault()}),onFocusOutside:ce(e.onFocusOutside,s=>s.preventDefault())})}),rT=p.forwardRef((e,t)=>{const n=pn(ir,e.__scopeDialog),r=p.useRef(!1),o=p.useRef(!1);return u.jsx(Yh,{...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()}})}),Yh=p.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=pn(ir,n),l=p.useRef(null),c=Le(t,l);return Hi(),u.jsxs(u.Fragment,{children:[u.jsx(Jo,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:u.jsx(wr,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":Xa(a.open),...i,ref:c,onDismiss:()=>a.onOpenChange(!1)})}),u.jsxs(u.Fragment,{children:[u.jsx(oT,{titleId:a.titleId}),u.jsx(iT,{contentRef:l,descriptionId:a.descriptionId})]})]})}),Ya="DialogTitle",Xh=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=pn(Ya,n);return u.jsx(ve.h2,{id:o.titleId,...r,ref:t})});Xh.displayName=Ya;var Jh="DialogDescription",Zh=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=pn(Jh,n);return u.jsx(ve.p,{id:o.descriptionId,...r,ref:t})});Zh.displayName=Jh;var Qh="DialogClose",ep=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=pn(Qh,n);return u.jsx(ve.button,{type:"button",...r,ref:t,onClick:ce(e.onClick,()=>o.onOpenChange(!1))})});ep.displayName=Qh;function Xa(e){return e?"open":"closed"}var tp="DialogTitleWarning",[jN,np]=yb(tp,{contentName:ir,titleName:Ya,docsSlug:"dialog"}),oT=({titleId:e})=>{const t=np(tp),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
80
80
|
|
|
81
81
|
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
82
82
|
|
|
83
|
-
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return p.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},sT="DialogDescriptionWarning",iT=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${np(sT).contentName}}.`;return p.useEffect(()=>{var s;const o=(s=e.current)==null?void 0:s.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},Ja=Hh,aT=Wh,Za=Kh,To=qh,ko=Gh,ar=Xh,Fs=Zh,rp=ep;const Qa=Ja,lT=Za,op=p.forwardRef(({className:e,...t},n)=>u.jsx(To,{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}));op.displayName=To.displayName;const Bs=p.forwardRef(({className:e,children:t,...n},r)=>{const o=p.useMemo(()=>{let s=!1;function i(a){p.Children.forEach(a,l=>{if(s||!p.isValidElement(l))return;const c=l.type;if(c===ar||(c==null?void 0:c.displayName)===ar.displayName||(c==null?void 0:c.name)==="DialogTitle"){s=!0;return}l.props&&l.props.children&&i(l.props.children)})}return i(t),s},[t]);return u.jsxs(lT,{children:[u.jsx(op,{}),u.jsxs(ko,{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(ar,{className:"sr-only",children:"Dialog"}),t,u.jsxs(rp,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[u.jsx(ue.X,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]})});Bs.displayName=ko.displayName;const zs=({className:e,...t})=>u.jsx("div",{className:re("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});zs.displayName="DialogHeader";const Hs=p.forwardRef(({className:e,...t},n)=>u.jsx(ar,{ref:n,className:re("text-lg font-semibold leading-none tracking-tight",e),...t}));Hs.displayName=ar.displayName;const cT=p.forwardRef(({className:e,...t},n)=>u.jsx(Fs,{ref:n,className:re("text-sm text-muted-foreground",e),...t}));cT.displayName=Fs.displayName;const uT=1,dT=1e6;let el=0;function fT(){return el=(el+1)%Number.MAX_SAFE_INTEGER,el.toString()}const tl=new Map,sp=e=>{if(tl.has(e))return;const t=setTimeout(()=>{tl.delete(e),Eo({type:"REMOVE_TOAST",toastId:e})},dT);tl.set(e,t)},hT=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,uT)};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?sp(n):e.toasts.forEach(r=>{sp(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 Eo(e){Ws=hT(Ws,e),Us.forEach(t=>{t(Ws)})}function pT({...e}){const t=fT(),n=o=>Eo({type:"UPDATE_TOAST",toast:{...o,id:t}}),r=()=>Eo({type:"DISMISS_TOAST",toastId:t});return Eo({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:o=>{o||r()}}}),{id:t,dismiss:r,update:n}}function nl(){const[e,t]=p.useState(Ws);return p.useEffect(()=>(Us.push(t),()=>{const n=Us.indexOf(t);n>-1&&Us.splice(n,1)}),[e]),{...e,toast:pT,dismiss:n=>Eo({type:"DISMISS_TOAST",toastId:n})}}function ip({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:h}=nl(),m=b.useCallback(async()=>{if(n){i(!0),d(null),l(null);try{const y=await _i(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 Zc(n),h({title:"Download started",description:`Downloading ${r}`})}catch(y){console.error("Failed to download file:",y),h({title:"Download failed",description:String(y),variant:"destructive"})}},v=async()=>{if(n)try{const y=await _i(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),h({title:"Failed to open file",description:String(y),variant:"destructive"})}},g=()=>s?u.jsxs("div",{className:"flex items-center justify-center py-12",children:[u.jsx(ue.Loader,{className:"h-8 w-8 animate-spin mr-3"}),u.jsx("span",{children:"Loading file..."})]}):c?u.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[u.jsx("div",{className:"text-red-500 mb-4",children:"⚠️"}),u.jsx("p",{className:"text-red-600 mb-4",children:c}),u.jsx(Qe,{onClick:m,variant:"outline",children:"Try Again"})]}):a?o.startsWith("image/")?u.jsx("div",{className:"flex justify-center",children:u.jsx("img",{src:`data:${o};base64,${a}`,alt:r,className:"max-w-full max-h-[70vh] object-contain rounded-lg"})}):o==="application/pdf"?u.jsx("div",{className:"w-full h-[70vh] border rounded-lg overflow-hidden",children:u.jsx("iframe",{src:`data:application/pdf;base64,${a}`,className:"w-full h-full",title:r})}):o.startsWith("text/")||o.includes("json")||o.includes("xml")?u.jsx("div",{className:"bg-gray-50 dark:bg-gray-900 rounded-lg p-4 max-h-[70vh] overflow-auto",children:u.jsx("pre",{className:"whitespace-pre-wrap font-mono text-sm",children:a})}):u.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[u.jsx(ue.FileText,{className:"h-16 w-16 text-gray-400 mb-4"}),u.jsx("p",{className:"text-lg font-medium mb-2",children:r}),u.jsxs("p",{className:"text-sm text-muted-foreground mb-4",children:[o," • ",a.length," bytes"]}),u.jsx("p",{className:"text-sm text-muted-foreground",children:"This file type cannot be previewed. Use download or external view."})]}):u.jsx("div",{className:"flex items-center justify-center py-12",children:u.jsx("p",{className:"text-muted-foreground",children:"No content to display"})}),x=()=>o.startsWith("image/")?u.jsx(ue.Image,{className:"h-5 w-5"}):u.jsx(ue.FileText,{className:"h-5 w-5"});return u.jsx(Qa,{open:e,onOpenChange:t,children:u.jsxs(Bs,{className:"max-w-4xl max-h-[90vh] overflow-hidden",children:[u.jsx(zs,{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(Hs,{className:"text-left",children:r}),u.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:[o," • Click download or external view for full access"]})]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsxs(Qe,{variant:"outline",size:"sm",onClick:v,className:"flex items-center gap-2",children:[u.jsx(ue.ExternalLink,{className:"h-4 w-4"}),"External"]}),u.jsxs(Qe,{variant:"outline",size:"sm",onClick:f,className:"flex items-center gap-2",children:[u.jsx(ue.Download,{className:"h-4 w-4"}),"Download"]})]})]})}),u.jsx("div",{className:"flex-1 overflow-hidden",children:g()})]})})}function ap(){return{async:!1,baseUrl:null,breaks:!1,extensions:null,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,hooks:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:null,sanitize:!1,sanitizer:null,silent:!1,smartypants:!1,tokenizer:null,walkTokens:null,xhtml:!1}}let lr=ap();function mT(e){lr=e}const lp=/[&<>"']/,gT=new RegExp(lp.source,"g"),cp=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,xT=new RegExp(cp.source,"g"),vT={"&":"&","<":"<",">":">",'"':""","'":"'"},up=e=>vT[e];function Dt(e,t){if(t){if(lp.test(e))return e.replace(gT,up)}else if(cp.test(e))return e.replace(xT,up);return e}const bT=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function dp(e){return e.replace(bT,(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 wT=/(^|[^\[])\^/g;function nt(e,t){e=typeof e=="string"?e:e.source,t=t||"";const n={replace:(r,o)=>(o=o.source||o,o=o.replace(wT,"$1"),e=e.replace(r,o),n),getRegex:()=>new RegExp(e,t)};return n}const yT=/[^\w:]/g,ST=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function fp(e,t,n){if(e){let r;try{r=decodeURIComponent(dp(n)).replace(yT,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}t&&!ST.test(n)&&(n=ET(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const Vs={},CT=/^[^:]+:\/*[^/]*$/,TT=/^([^:]+:)[\s\S]*$/,kT=/^([^:]+:\/*[^/]*)[\s\S]*$/;function ET(e,t){Vs[" "+e]||(CT.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(TT,"$1")+t:t.charAt(0)==="/"?n?t:e.replace(kT,"$1")+t:e+t}const Ks={exec:function(){}};function hp(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 IT(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 NT(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 pp(e,t){if(t<1)return"";let n="";for(;t>1;)t&1&&(n+=e),t>>=1,e+=e;return n+e}function mp(e,t,n,r){const o=t.href,s=t.title?Dt(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:Dt(i)}}function AT(e,t){const n=e.match(/^(\s+)(?:```)/);if(n===null)return t;const r=n[1];return t.split(`
|
|
83
|
+
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return p.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},sT="DialogDescriptionWarning",iT=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${np(sT).contentName}}.`;return p.useEffect(()=>{var s;const o=(s=e.current)==null?void 0:s.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},Ja=Hh,aT=Wh,Za=Kh,To=qh,ko=Gh,ar=Xh,Fs=Zh,rp=ep;const Qa=Ja,lT=Za,op=p.forwardRef(({className:e,...t},n)=>u.jsx(To,{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}));op.displayName=To.displayName;const Bs=p.forwardRef(({className:e,children:t,...n},r)=>{const o=p.useMemo(()=>{let s=!1;function i(a){p.Children.forEach(a,l=>{if(s||!p.isValidElement(l))return;const c=l.type;if(c===ar||(c==null?void 0:c.displayName)===ar.displayName||(c==null?void 0:c.name)==="DialogTitle"){s=!0;return}l.props&&l.props.children&&i(l.props.children)})}return i(t),s},[t]);return u.jsxs(lT,{children:[u.jsx(op,{}),u.jsxs(ko,{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(ar,{className:"sr-only",children:"Dialog"}),t,u.jsxs(rp,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[u.jsx(ue.X,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]})});Bs.displayName=ko.displayName;const zs=({className:e,...t})=>u.jsx("div",{className:re("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});zs.displayName="DialogHeader";const Hs=p.forwardRef(({className:e,...t},n)=>u.jsx(ar,{ref:n,className:re("text-lg font-semibold leading-none tracking-tight",e),...t}));Hs.displayName=ar.displayName;const cT=p.forwardRef(({className:e,...t},n)=>u.jsx(Fs,{ref:n,className:re("text-sm text-muted-foreground",e),...t}));cT.displayName=Fs.displayName;const uT=1,dT=1e6;let el=0;function fT(){return el=(el+1)%Number.MAX_SAFE_INTEGER,el.toString()}const tl=new Map,sp=e=>{if(tl.has(e))return;const t=setTimeout(()=>{tl.delete(e),Eo({type:"REMOVE_TOAST",toastId:e})},dT);tl.set(e,t)},hT=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,uT)};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?sp(n):e.toasts.forEach(r=>{sp(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 Eo(e){Ws=hT(Ws,e),Us.forEach(t=>{t(Ws)})}function pT({...e}){const t=fT(),n=o=>Eo({type:"UPDATE_TOAST",toast:{...o,id:t}}),r=()=>Eo({type:"DISMISS_TOAST",toastId:t});return Eo({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:o=>{o||r()}}}),{id:t,dismiss:r,update:n}}function nl(){const[e,t]=p.useState(Ws);return p.useEffect(()=>(Us.push(t),()=>{const n=Us.indexOf(t);n>-1&&Us.splice(n,1)}),[e]),{...e,toast:pT,dismiss:n=>Eo({type:"DISMISS_TOAST",toastId:n})}}function ip({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:f}=nl(),m=b.useCallback(async()=>{if(n){i(!0),d(null),l(null);try{const y=await Pi(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 h=async()=>{if(n)try{await Zc(n),f({title:"Download started",description:`Downloading ${r}`})}catch(y){console.error("Failed to download file:",y),f({title:"Download failed",description:String(y),variant:"destructive"})}},v=async()=>{if(n)try{const y=await Pi(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),f({title:"Failed to open file",description:String(y),variant:"destructive"})}},g=()=>s?u.jsxs("div",{className:"flex items-center justify-center py-12",children:[u.jsx(ue.Loader,{className:"h-8 w-8 animate-spin mr-3"}),u.jsx("span",{children:"Loading file..."})]}):c?u.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[u.jsx("div",{className:"text-red-500 mb-4",children:"⚠️"}),u.jsx("p",{className:"text-red-600 mb-4",children:c}),u.jsx(Qe,{onClick:m,variant:"outline",children:"Try Again"})]}):a?o.startsWith("image/")?u.jsx("div",{className:"flex justify-center",children:u.jsx("img",{src:`data:${o};base64,${a}`,alt:r,className:"max-w-full max-h-[70vh] object-contain rounded-lg"})}):o==="application/pdf"?u.jsx("div",{className:"w-full h-[70vh] border rounded-lg overflow-hidden",children:u.jsx("iframe",{src:`data:application/pdf;base64,${a}`,className:"w-full h-full",title:r})}):o.startsWith("text/")||o.includes("json")||o.includes("xml")?u.jsx("div",{className:"bg-gray-50 dark:bg-gray-900 rounded-lg p-4 max-h-[70vh] overflow-auto",children:u.jsx("pre",{className:"whitespace-pre-wrap font-mono text-sm",children:a})}):u.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[u.jsx(ue.FileText,{className:"h-16 w-16 text-gray-400 mb-4"}),u.jsx("p",{className:"text-lg font-medium mb-2",children:r}),u.jsxs("p",{className:"text-sm text-muted-foreground mb-4",children:[o," • ",a.length," bytes"]}),u.jsx("p",{className:"text-sm text-muted-foreground",children:"This file type cannot be previewed. Use download or external view."})]}):u.jsx("div",{className:"flex items-center justify-center py-12",children:u.jsx("p",{className:"text-muted-foreground",children:"No content to display"})}),x=()=>o.startsWith("image/")?u.jsx(ue.Image,{className:"h-5 w-5"}):u.jsx(ue.FileText,{className:"h-5 w-5"});return u.jsx(Qa,{open:e,onOpenChange:t,children:u.jsxs(Bs,{className:"max-w-4xl max-h-[90vh] overflow-hidden",children:[u.jsx(zs,{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(Hs,{className:"text-left",children:r}),u.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:[o," • Click download or external view for full access"]})]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsxs(Qe,{variant:"outline",size:"sm",onClick:v,className:"flex items-center gap-2",children:[u.jsx(ue.ExternalLink,{className:"h-4 w-4"}),"External"]}),u.jsxs(Qe,{variant:"outline",size:"sm",onClick:h,className:"flex items-center gap-2",children:[u.jsx(ue.Download,{className:"h-4 w-4"}),"Download"]})]})]})}),u.jsx("div",{className:"flex-1 overflow-hidden",children:g()})]})})}function ap(){return{async:!1,baseUrl:null,breaks:!1,extensions:null,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,hooks:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:null,sanitize:!1,sanitizer:null,silent:!1,smartypants:!1,tokenizer:null,walkTokens:null,xhtml:!1}}let lr=ap();function mT(e){lr=e}const lp=/[&<>"']/,gT=new RegExp(lp.source,"g"),cp=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,xT=new RegExp(cp.source,"g"),vT={"&":"&","<":"<",">":">",'"':""","'":"'"},up=e=>vT[e];function Dt(e,t){if(t){if(lp.test(e))return e.replace(gT,up)}else if(cp.test(e))return e.replace(xT,up);return e}const bT=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function dp(e){return e.replace(bT,(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 wT=/(^|[^\[])\^/g;function nt(e,t){e=typeof e=="string"?e:e.source,t=t||"";const n={replace:(r,o)=>(o=o.source||o,o=o.replace(wT,"$1"),e=e.replace(r,o),n),getRegex:()=>new RegExp(e,t)};return n}const yT=/[^\w:]/g,ST=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function fp(e,t,n){if(e){let r;try{r=decodeURIComponent(dp(n)).replace(yT,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}t&&!ST.test(n)&&(n=ET(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const Vs={},CT=/^[^:]+:\/*[^/]*$/,TT=/^([^:]+:)[\s\S]*$/,kT=/^([^:]+:\/*[^/]*)[\s\S]*$/;function ET(e,t){Vs[" "+e]||(CT.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(TT,"$1")+t:t.charAt(0)==="/"?n?t:e.replace(kT,"$1")+t:e+t}const Ks={exec:function(){}};function hp(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 IT(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 NT(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 pp(e,t){if(t<1)return"";let n="";for(;t>1;)t&1&&(n+=e),t>>=1,e+=e;return n+e}function mp(e,t,n,r){const o=t.href,s=t.title?Dt(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:Dt(i)}}function AT(e,t){const n=e.match(/^(\s+)(?:```)/);if(n===null)return t;const r=n[1];return t.split(`
|
|
84
84
|
`).map(o=>{const s=o.match(/^\s+/);if(s===null)return o;const[i]=s;return i.length>=r.length?o.slice(r.length):o}).join(`
|
|
85
85
|
`)}class rl{constructor(t){this.options=t||lr}space(t){const n=this.rules.block.newline.exec(t);if(n&&n[0].length>0)return{type:"space",raw:n[0]}}code(t){const n=this.rules.block.code.exec(t);if(n){const r=n[0].replace(/^ {1,4}/gm,"");return{type:"code",raw:n[0],codeBlockStyle:"indented",text:this.options.pedantic?r:qs(r,`
|
|
86
|
-
`)}}}fences(t){const n=this.rules.block.fences.exec(t);if(n){const r=n[0],o=AT(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,
|
|
87
|
-
`,1)[0].replace(/^\t+/,k=>" ".repeat(3*k.length)),
|
|
88
|
-
`,1)[0],this.options.pedantic?(i=2,
|
|
89
|
-
`,t=t.substring(
|
|
90
|
-
`,1)[0],
|
|
91
|
-
`+
|
|
92
|
-
`+
|
|
93
|
-
`,t=t.substring(m.length+1),d=
|
|
86
|
+
`)}}}fences(t){const n=this.rules.block.fences.exec(t);if(n){const r=n[0],o=AT(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,f,m,h,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
|
+
`,1)[0].replace(/^\t+/,k=>" ".repeat(3*k.length)),f=t.split(`
|
|
88
|
+
`,1)[0],this.options.pedantic?(i=2,h=d.trimLeft()):(i=n[2].search(/[^ ]/),i=i>4?1:i,h=d.slice(i),i+=n[1].length),l=!1,!d&&/^ *$/.test(f)&&(r+=f+`
|
|
89
|
+
`,t=t.substring(f.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)}}(?:\`\`\`|~~~)`),I=new RegExp(`^ {0,${Math.min(3,i-1)}}#`);for(;t&&(m=t.split(`
|
|
90
|
+
`,1)[0],f=m,this.options.pedantic&&(f=f.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),!(T.test(f)||I.test(f)||k.test(f)||C.test(t)));){if(f.search(/[^ ]/)>=i||!f.trim())h+=`
|
|
91
|
+
`+f.slice(i);else{if(l||d.search(/[^ ]/)>=4||T.test(d)||I.test(d)||C.test(d))break;h+=`
|
|
92
|
+
`+f}!l&&!f.trim()&&(l=!0),r+=m+`
|
|
93
|
+
`,t=t.substring(m.length+1),d=f.slice(i)}}y.loose||(c?y.loose=!0:/\n *\n *$/.test(r)&&(c=!0)),this.options.gfm&&(o=/^\[[ xX]\] /.exec(h),o&&(s=o[0]!=="[ ] ",h=h.replace(/^\[[ xX]\] +/,""))),y.items.push({type:"list_item",raw:r,task:!!o,checked:s,loose:!1,text:h}),y.raw+=r}y.items[y.items.length-1].raw=r.trimRight(),y.items[y.items.length-1].text=h.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]):Dt(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:hp(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]=hp(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:Dt(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]):Dt(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=IT(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)),mp(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 mp(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
|
|
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:Dt(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]):Dt(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=IT(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)),mp(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 mp(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 f=o[0][0]==="*"?this.rules.inline.emStrong.rDelimAst:this.rules.inline.emStrong.rDelimUnd;for(f.lastIndex=0,n=n.slice(-1*t.length+i);(o=f.exec(n))!=null;){if(a=o[1]||o[2]||o[3]||o[4]||o[5]||o[6],!a)continue;if(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 h=m.slice(2,-2);return{type:"strong",raw:m,text:h,tokens:this.lexer.inlineTokens(h)}}}}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=Dt(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=Dt(this.options.mangle?n(r[1]):r[1]),s="mailto:"+o):(o=Dt(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=Dt(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=Dt(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]):Dt(r[0]):r[0]:o=Dt(this.options.smartypants?n(r[0]):r[0]),{type:"text",raw:r[0],text:o}}}}const Se={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]+/};Se._label=/(?!\s*\])(?:\\.|[^\[\]\\])+/,Se._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,Se.def=nt(Se.def).replace("label",Se._label).replace("title",Se._title).getRegex(),Se.bullet=/(?:[*+-]|\d{1,9}[.)])/,Se.listItemStart=nt(/^( *)(bull) */).replace("bull",Se.bullet).getRegex(),Se.list=nt(Se.list).replace(/bull/g,Se.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+Se.def.source+")").getRegex(),Se._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",Se._comment=/<!--(?!-?>)[\s\S]*?(?:-->|$)/,Se.html=nt(Se.html,"i").replace("comment",Se._comment).replace("tag",Se._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Se.paragraph=nt(Se._paragraph).replace("hr",Se.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",Se._tag).getRegex(),Se.blockquote=nt(Se.blockquote).replace("paragraph",Se.paragraph).getRegex(),Se.normal={...Se},Se.gfm={...Se.normal,table:"^ *([^\\n ].*\\|.*)\\n {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"},Se.gfm.table=nt(Se.gfm.table).replace("hr",Se.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",Se._tag).getRegex(),Se.gfm.paragraph=nt(Se._paragraph).replace("hr",Se.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("table",Se.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",Se._tag).getRegex(),Se.pedantic={...Se.normal,html:nt(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Se._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:nt(Se.normal._paragraph).replace("hr",Se.hr).replace("heading",` *#{1,6} *[^
|
|
96
96
|
]`).replace("lheading",Se.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()};const pe={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])/};pe._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",pe.punctuation=nt(pe.punctuation).replace(/punctuation/g,pe._punctuation).getRegex(),pe.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g,pe.escapedEmSt=/(?:^|[^\\])(?:\\\\)*\\[*_]/g,pe._comment=nt(Se._comment).replace("(?:-->|$)","-->").getRegex(),pe.emStrong.lDelim=nt(pe.emStrong.lDelim).replace(/punct/g,pe._punctuation).getRegex(),pe.emStrong.rDelimAst=nt(pe.emStrong.rDelimAst,"g").replace(/punct/g,pe._punctuation).getRegex(),pe.emStrong.rDelimUnd=nt(pe.emStrong.rDelimUnd,"g").replace(/punct/g,pe._punctuation).getRegex(),pe._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,pe._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,pe._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])?)+(?![-_])/,pe.autolink=nt(pe.autolink).replace("scheme",pe._scheme).replace("email",pe._email).getRegex(),pe._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,pe.tag=nt(pe.tag).replace("comment",pe._comment).replace("attribute",pe._attribute).getRegex(),pe._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,pe._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/,pe._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,pe.link=nt(pe.link).replace("label",pe._label).replace("href",pe._href).replace("title",pe._title).getRegex(),pe.reflink=nt(pe.reflink).replace("label",pe._label).replace("ref",Se._label).getRegex(),pe.nolink=nt(pe.nolink).replace("ref",Se._label).getRegex(),pe.reflinkSearch=nt(pe.reflinkSearch,"g").replace("reflink",pe.reflink).replace("nolink",pe.nolink).getRegex(),pe.normal={...pe},pe.pedantic={...pe.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:nt(/^!?\[(label)\]\((.*?)\)/).replace("label",pe._label).getRegex(),reflink:nt(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",pe._label).getRegex()},pe.gfm={...pe.normal,escape:nt(pe.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.!#$%&'*+\/=?_`{\|}~-]+@)))/},pe.gfm.url=nt(pe.gfm.url,"i").replace("email",pe.gfm._extended_email).getRegex(),pe.breaks={...pe.gfm,br:nt(pe.br).replace("{2,}","*").getRegex(),text:nt(pe.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()};function jT(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 gp(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 Vn{constructor(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||lr,this.options.tokenizer=this.options.tokenizer||new rl,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:Se.normal,inline:pe.normal};this.options.pedantic?(n.block=Se.pedantic,n.inline=pe.pedantic):this.options.gfm&&(n.block=Se.gfm,this.options.breaks?n.inline=pe.breaks:n.inline=pe.gfm),this.tokenizer.rules=n}static get rules(){return{block:Se,inline:pe}}static lex(t,n){return new Vn(n).lex(t)}static lexInline(t,n){return new Vn(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+=`
|
|
@@ -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)+"["+pp("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)+"["+pp("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,gp)){t=t.substring(r.raw.length),n.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(t,gp))){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
|
|
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)+"["+pp("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)+"["+pp("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,gp)){t=t.substring(r.raw.length),n.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(t,gp))){t=t.substring(r.raw.length),n.push(r);continue}if(s=t,this.options.extensions&&this.options.extensions.startInline){let d=1/0;const f=t.slice(1);let m;this.options.extensions.startInline.forEach(function(h){m=h.call({lexer:this},f),typeof m=="number"&&m>=0&&(d=Math.min(d,m))}),d<1/0&&d>=0&&(s=t.substring(0,d+1))}if(r=this.tokenizer.inlineText(s,jT)){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 ol{constructor(t){this.options=t||lr}code(t,n,r){const o=(n||"").match(/\S*/)[0];if(this.options.highlight){const s=this.options.highlight(t,o);s!=null&&s!==t&&(r=!0,t=s)}return t=t.replace(/\n$/,"")+`
|
|
107
107
|
`,o?'<pre><code class="'+this.options.langPrefix+Dt(o)+'">'+(r?t:Dt(t,!0))+`</code></pre>
|
|
108
108
|
`:"<pre><code>"+(r?t:Dt(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=fp(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=fp(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 xp{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 vp{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 Kn{constructor(t){this.options=t||lr,this.options.renderer=this.options.renderer||new ol,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new xp,this.slugger=new vp}static parse(t,n){return new Kn(n).parse(t)}static parseInline(t,n){return new Kn(n).parseInline(t)}parse(t,n=!0){let r="",o,s,i,a,l,c,d,
|
|
127
|
-
`+(
|
|
128
|
-
Please report this to https://github.com/markedjs/marked.`,e){const o="<p>An error occurred:</p><pre>"+Dt(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 bp(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...ye.defaults,...s};const i=_T(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(NT(r),r.hooks&&(r.hooks.options=r),o){const a=r.highlight;let l;try{r.hooks&&(n=r.hooks.preprocess(n)),l=e(n,r)}catch(h){return i(h)}const c=function(h){let m;if(!h)try{r.walkTokens&&ye.walkTokens(l,r.walkTokens),m=t(l,r),r.hooks&&(m=r.hooks.postprocess(m))}catch(f){h=f}return r.highlight=a,h?i(h):o(null,m)};if(!a||a.length<3||(delete r.highlight,!l.length))return c();let d=0;ye.walkTokens(l,function(h){h.type==="code"&&(d++,setTimeout(()=>{a(h.text,h.lang,function(m,f){if(m)return c(m);f!=null&&f!==h.text&&(h.text=f,h.escaped=!0),d--,d===0&&c()})},0))}),d===0&&c();return}if(r.async)return Promise.resolve(r.hooks?r.hooks.preprocess(n):n).then(a=>e(a,r)).then(a=>r.walkTokens?Promise.all(ye.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&&ye.walkTokens(a,r.walkTokens);let l=t(a,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(a){return i(a)}}}function ye(e,t,n){return bp(Vn.lex,Kn.parse)(e,t,n)}ye.options=ye.setOptions=function(e){return ye.defaults={...ye.defaults,...e},mT(ye.defaults),ye},ye.getDefaults=ap,ye.defaults=lr,ye.use=function(...e){const t=ye.defaults.extensions||{renderers:{},childTokens:{}};e.forEach(n=>{const r={...n};if(r.async=ye.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=ye.defaults.renderer||new ol;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=ye.defaults.tokenizer||new rl;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=ye.defaults.hooks||new Gs;for(const s in n.hooks){const i=o[s];Gs.passThroughHooks.has(s)?o[s]=a=>{if(ye.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=ye.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}}ye.setOptions(r)})},ye.walkTokens=function(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(ye,r)),r.type){case"table":{for(const o of r.header)n=n.concat(ye.walkTokens(o.tokens,t));for(const o of r.rows)for(const s of o)n=n.concat(ye.walkTokens(s.tokens,t));break}case"list":{n=n.concat(ye.walkTokens(r.items,t));break}default:ye.defaults.extensions&&ye.defaults.extensions.childTokens&&ye.defaults.extensions.childTokens[r.type]?ye.defaults.extensions.childTokens[r.type].forEach(function(o){n=n.concat(ye.walkTokens(r[o],t))}):r.tokens&&(n=n.concat(ye.walkTokens(r.tokens,t)))}return n},ye.parseInline=bp(Vn.lexInline,Kn.parseInline),ye.Parser=Kn,ye.parser=Kn.parse,ye.Renderer=ol,ye.TextRenderer=xp,ye.Lexer=Vn,ye.lexer=Vn.lex,ye.Tokenizer=rl,ye.Slugger=vp,ye.Hooks=Gs,ye.parse=ye,ye.options,ye.setOptions,ye.use,ye.walkTokens,ye.parseInline,Kn.parse,Vn.lex;function Rr({content:e,className:t="",allowHtml:n=!1,style:r}){const o=b.useMemo(()=>{if(!e||typeof e!="string"||e.trim().length===0)return"";try{if(!n){const i=e.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"").replace(/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi,"").replace(/javascript:/gi,"").replace(/on\w+\s*=/gi,"");return typeof ye.parse=="function"?ye.parse(i):ye(i)}return typeof ye.parse=="function"?ye.parse(e):ye(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 wp({preview:e,idx:t}){return u.jsxs("div",{className:"space-y-2",children:[e.label&&u.jsxs("p",{className:"text-[0.65rem] uppercase tracking-wide text-muted-foreground",children:["Artifact: ",e.label]}),u.jsx("div",{className:"overflow-hidden rounded border border-border/60 bg-background/60 p-1 shadow-sm",children:u.jsx("img",{src:e.src,alt:e.alt,title:e.label,loading:"lazy",className:"h-auto max-h-[420px] w-full rounded object-contain",onLoad:()=>{},onError:n=>{console.error(`[MessageComponent] ❌ Image failed to load for artifact ${t}:`,{alt:e.alt,label:e.label,message:n.target.alt})}})})]})}const yp={completed:{label:"Completed",badgeClass:"border border-green-200 bg-green-50 text-green-700"},success:{label:"Completed",badgeClass:"border border-green-200 bg-green-50 text-green-700"},failed:{label:"Failed",badgeClass:"border border-red-200 bg-red-50 text-red-700"},error:{label:"Failed",badgeClass:"border border-red-200 bg-red-50 text-red-700"},cancelled:{label:"Cancelled",badgeClass:"border border-orange-200 bg-orange-50 text-orange-700"},cancel:{label:"Cancelled",badgeClass:"border border-orange-200 bg-orange-50 text-orange-700"},pending:{label:"Pending",badgeClass:"border border-blue-200 bg-blue-50 text-blue-700"},processing:{label:"Processing",badgeClass:"border border-yellow-200 bg-yellow-50 text-yellow-700"}},PT=e=>{if(!e)return yp.processing;const t=e.toLowerCase().trim();return yp[t]??{label:t.replace(/(^\w|\s\w)/g,n=>n.toUpperCase()),badgeClass:"border border-slate-200 bg-slate-50 text-slate-800"}},RT=e=>e?e.length>10?`${e.slice(0,8)}…`:e:"";function Sp({artifact:e}){const t=PT(e.status),n=e.task_url??e.taskUrl??"";return u.jsxs("div",{className:"rounded-lg border border-blue-200/70 bg-blue-50/40 p-4 space-y-3",children:[u.jsxs("div",{className:"flex items-start justify-between gap-3",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsx("div",{className:"flex h-7 w-7 items-center justify-center rounded-full bg-blue-600/10 text-blue-600",children:u.jsx(ue.Search,{className:"h-4 w-4"})}),u.jsxs("div",{className:"space-y-1",children:[u.jsx("p",{className:"text-xs font-semibold uppercase tracking-wide text-blue-700",children:"Research Task"}),u.jsxs("p",{className:"text-[11px] text-blue-900/80",children:["Task ID: ",u.jsx("span",{className:"font-mono",children:RT(e.task_id)})]})]})]}),t&&u.jsx("span",{className:`inline-flex items-center rounded-full px-3 py-1 text-[11px] font-semibold ${t.badgeClass}`,children:t.label})]}),e.query&&u.jsxs("div",{className:"rounded border border-blue-100 bg-white/80 px-3 py-2 text-xs text-blue-900/90",children:[u.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wide text-blue-500",children:"Query"}),u.jsx("p",{className:"line-clamp-2 text-[11px] text-blue-900",children:e.query})]}),typeof e.results=="string"&&e.results.trim()&&u.jsxs("div",{className:"rounded border border-blue-100 bg-white/80 px-3 py-2 text-sm text-blue-900/90 space-y-1",children:[u.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wide text-blue-500",children:"Results"}),u.jsx(Rr,{content:e.results,allowHtml:!1,className:"prose text-xs !prose-sm prose-blue dark:prose-invert"})]}),u.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[n?u.jsxs("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 rounded-full border border-blue-600/80 bg-blue-600/10 px-3 py-1 text-xs font-semibold text-blue-700 transition hover:bg-blue-600/20",children:[u.jsx("span",{children:"Go to task"}),u.jsx(ue.ExternalLink,{className:"h-3 w-3"})]}):u.jsx("span",{className:"text-xs text-muted-foreground",children:"Task link unavailable"}),e.createdAt&&u.jsxs("p",{className:"text-[10px] text-blue-700/70",children:["Started: ",new Date(e.createdAt).toLocaleTimeString()]})]})]})}function Cp({artifact:e,idx:t=0}){const n=b.useMemo(()=>e?(Array.isArray(e.plots)?e.plots:[]).map(o=>nb(o)).filter(o=>o!==null):[],[e]);return(e==null?void 0:e.type)==="research_task_info"?u.jsx(Sp,{artifact:{type:"research_task_info",task_id:e.task_id,task_url:e.task_url,query:e.query,status:e.status,createdAt:e.createdAt}}):n.length>0?u.jsx("div",{className:"space-y-2",children:n.map((r,o)=>u.jsx(wp,{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 sl=p.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:re("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));sl.displayName="Card";const il=p.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:re("flex flex-col space-y-1.5 p-6",e),...t}));il.displayName="CardHeader";const al=p.forwardRef(({className:e,...t},n)=>u.jsx("h3",{ref:n,className:re("text-2xl font-semibold leading-none tracking-tight",e),...t}));al.displayName="CardTitle";const ll=p.forwardRef(({className:e,...t},n)=>u.jsx("p",{ref:n,className:re("text-sm text-muted-foreground",e),...t}));ll.displayName="CardDescription";const cl=p.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:re("p-6 pt-0",e),...t}));cl.displayName="CardContent";const Tp=p.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:re("flex items-center p-6 pt-0",e),...t}));Tp.displayName="CardFooter";function kp({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=xr(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(sl,{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(il,{className:"pb-3",children:[u.jsx(al,{className:"text-blue-900 dark:text-blue-100 text-base",children:i}),u.jsx(ll,{className:"text-blue-700 dark:text-blue-300 text-sm",children:l})]}),a&&u.jsx(cl,{className:"pt-0 pb-3",children:a}),u.jsx(Tp,{className:"pt-0",children:u.jsxs("div",{className:"flex gap-2 ml-auto",children:[u.jsx(Qe,{size:"sm",variant:"outline",onClick:()=>n(e),className:"border-red-300 text-red-700 hover:bg-red-50 dark:border-red-700 dark:text-red-300 dark:hover:bg-red-950/50",disabled:r||!o,children:"Reject"}),u.jsx(Qe,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",disabled:r||!o,children:"Approve"})]})})]})}const MT="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 ul({data:e}){return Array.isArray(e)?e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?u.jsx("div",{className:MT,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:xr(e)}):u.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:xr(e)})}function Ep({message:e,isStreaming:t=!1}){const n=e.name??"tool",r=b.useMemo(()=>{const a=e.additionalKwargs??{};return Array.isArray(a.toolProgress)?[...a.toolProgress]:[]},[e]),s=r.some(a=>a.type==="tool.start"||a.type==="tool.call"||a.type==="message.start")?`Running ${n}…`:void 0;return t||r.length>0?u.jsxs("div",{className:"space-y-2",children:[u.jsxs("div",{className:"flex items-center gap-2 text-xs uppercase tracking-wide text-muted-foreground",children:[t&&u.jsx(ue.Loader,{className:"h-3 w-3 animate-spin"}),u.jsx("span",{children:s??`Running ${n}…`})]}),r.length>0&&u.jsx("div",{className:"space-y-2 text-xs text-muted-foreground",children:r.map((a,l)=>{var c;return u.jsxs("div",{className:"rounded border border-current/10 bg-muted/60 p-2 text-[11px] leading-snug",children:[u.jsxs("div",{className:"mb-1 flex items-center justify-between text-[8px] uppercase tracking-wide text-muted-foreground",children:[u.jsx("span",{children:((c=a.type)==null?void 0:c.replace(/\./g," "))??"progress"}),u.jsx("span",{children:a.idx??l+1})]}),a.content&&u.jsx("p",{className:"mt-1 text-[12px] text-foreground/90",children:a.content}),u.jsxs("div",{className:"mt-1 flex flex-wrap gap-2 text-[10px] opacity-70",children:[typeof a.factsFound=="number"&&u.jsxs("span",{children:["Facts found: ",a.factsFound]}),typeof a.isSufficient=="boolean"&&u.jsxs("span",{children:["Research ",a.isSufficient?"sufficient":"needs more data"]})]})]},`tool-progress-${n}-${l}`)})})]}):null}function Ip({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 Np({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(Rr,{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(Qe,{type:"button",variant:"ghost",size:"sm",className:"h-6 text-xs !text-[hsl(var(--chat-bubble-user-text))]",onClick:()=>n(!t),children:t?u.jsxs(u.Fragment,{children:[u.jsx(ue.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):u.jsxs(u.Fragment,{children:[u.jsx(ue.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",s," chars)"]})})]})}function Ap({message:e,viewMode:t,isStreaming:n=!1}){const o=Mi(e).name||"tool",s=e.artifact??null,i=c=>{if(c==null)return null;const d=typeof c=="string"?Ri(c)??c:c;if(d&&typeof d=="object")return u.jsx(ul,{data:d});const h=typeof d=="string"?d:(()=>{try{return xr(d)}catch{return String(d??"")}})();return u.jsx("pre",{className:"whitespace-pre-wrap break-words font-sans text-sm text-foreground/90",children:h})},a=c=>{if(c==null)return null;const{content:d,isMarkdown:h}=Yv(c);return h?u.jsx(Rr,{content:d,className:"text-current"}):i(c)},l=()=>{const c=e.content.find(m=>m.type!=="tool_call");if(!c)return u.jsx("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:u.jsxs("span",{children:["Running ",o,"…"]})});if(c.type==="text"){const f=(c.text??"").trim();if(!f)return null;const v=Qr(f);return a(v)}const d=Zr(c),h=Qr(d);return a(h)};return u.jsxs("div",{className:"space-y-2",children:[s&&u.jsx(Cp,{artifact:s,idx:0}),u.jsx(Ep,{message:e,isStreaming:n}),t==="expanded"&&u.jsx(u.Fragment,{children:l()})]})}function jp(e){const{allowFileOpen:t,currentThreadId:n}=e,{toast:r}=nl(),[o,s]=b.useState({}),[i,a]=b.useState(null),[l,c]=b.useState(!1),d=b.useCallback(()=>{c(!1),a(null)},[]),h=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";h({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 Qc(n??void 0);if(!C||!Array.isArray(C))throw new Error("Invalid file list response");const T=C.find(I=>!I||typeof I!="object"||!((I.filename??"")===(v.name??""))?!1:typeof v.size=="number"&&typeof I.size=="number"?I.size===v.size:!0);if(!(T!=null&&T.id))throw new Error(`File "${v.name}" is not yet available on the server`);if(!T.id||!T.filename)throw new Error("Invalid file data received from server");h({id:T.id,name:v.name||T.filename||`file_${T.id}`,mimeType:v.mimeType||T.mime_type||"application/octet-stream"}),(x=k.update)==null||x.call(k,{id:k.id,title:"Success",description:`Opened ${v.name}`,open:!0})}catch(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,h]);return{uploadingFiles:o,handleFileClick:m,fileViewerOpen:l,currentFileInfo:i,closeFileViewer:d}}function _p(e,t){return b.useMemo(()=>{if(t)return{contentParts:[],textContent:"",toolMeta:{},imageParts:[],fileParts:[],interruptParts:[],toolRaw:"",isToolStreaming:!1};const n=e,r=Array.isArray(n.content)?n.content:[],o=n.additionalKwargs??{};return{contentParts:r,textContent:Xv(r),toolMeta:Mi(n),imageParts:r.filter(s=>s.type==="image_url"),fileParts:r.filter(s=>s.type==="file"),interruptParts:r.filter(s=>s.type==="interrupt"),toolRaw:Jv(r),isToolStreaming:!!o.toolStreaming}},[e,t])}const OT={checkpoints:[],checkpointMetaByCheckpointId:new Map,timeline:[],messagePreviews:new Map,getLatest:()=>{},getCheckpoint:()=>{},getMessageAttempts:()=>[]},dl=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,fl=b.memo(function({message:t,index:n,isStreaming:r,streamingAssistantId:o,streamingDebounceMs:s,layoutSize:i,enableMessageEditing:a,editingMessageId:l,onEdit:c,onRegenerate:d,onCancelEdit:h,activeInterrupt:m,disableInterruptActions:f,onInterruptActionStart:v,onInterruptActionEnd:g,showToolMessages:x,checkpointIndex:y,onSelectCheckpoint:w}){const S=dl(t,n),k=t.role==="default_message",T=!!t.__syntheticStreaming,I=y??OT,N=!k&&"checkpointId"in t?t.checkpointId??null:null,{attemptCount:R,attemptIndex:O,attempts:$}=b.useMemo(()=>ec(t.id,N,I),[t.id,N,I]);return u.jsx("div",{className:"relative mb-4 last:mb-0","data-message-id":S,style:{minHeight:"60px",containIntrinsicSize:"auto 120px"},children:u.jsx(Ys,{message:t,messageIndex:n,isStreamingMessage:T||r&&o===t.id&&t.role==="assistant",streamingDebounceMs:s,isEditing:l===t.id,showActions:a,showTimestamp:!1,showAgentName:!0,layoutSize:i,onEdit:c,onRegenerate:()=>d(n),onCancelEdit:h,activeInterrupt:m,disableInterruptActions:f,onInterruptActionStart:v,onInterruptActionEnd:g,showToolMessages:x,attemptCount:R,attemptIndex:O,attemptMetas:$,onSelectCheckpoint:w})})});fl.displayName="MessageRow";function DT(e,t,n){const[r,o]=b.useState(e);return b.useEffect(()=>{if(!t){o(e);return}const s=e.map(i=>{if(i.type!=="text")return i;const a=i.text??"",l=n(a);return l===a?i:{...i,text:l}});o(s)},[e,t,n]),r}function LT({message:e,isToolMessage:t,showToolMessages:n,toolViewMode:r,isToolStreaming:o,contentParts:s,textContent:i,imageParts:a,fileParts:l,interruptParts:c,isStreamingMessage:d,enableStreamingMarkdownBuffer:h,defaultMessage:m,handleFileClick:f,uploadingFiles:v,handleInterruptApprove:g,handleInterruptReject:x,disableInterruptActions:y,messageRole:w,truncateUserMessages:S,userMessagePreviewLength:k,isUserExpanded:C,setIsUserExpanded:T,isCompactLayout:I,activeInterruptId:N,activeInterruptValue:R,iconForeground:O}){const $=b.useCallback(()=>u.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/30 rounded",children:[u.jsx(ue.Loader,{className:"h-4 w-4 text-muted-foreground"}),u.jsx("span",{className:"text-sm text-muted-foreground",children:"File upload"})]}),[]),V=h??!0,U=b.useCallback(D=>$T(D,d),[d]),j=DT(s,V&&d,U),q=b.useCallback(({part:D,i:P})=>{if(D.type==="text"){const E=D.text??"",B=E.trim(),Y=Ri(B);return Y&&w!=="tool"?u.jsx(ul,{data:Y},P):w==="user"&&S&&B.length>k?u.jsx(Np,{text:B,expanded:C,onExpandedChange:T,previewLength:k,isCompact:I},P):u.jsx(Rr,{content:E,allowHtml:!1},P)}if(D.type==="image_url"){const E=D;return u.jsx("div",{className:"my-2",children:u.jsx("img",{src:E.url,alt:E.alt??"",loading:"lazy",className:"border rounded max-h-[420px] w-auto object-contain"})},P)}if(D.type==="file"){const E=D,B=E.name||"file";return u.jsxs("a",{href:E.url,onClick:Y=>f(Y,E,P),className:`inline-flex items-center gap-2 rounded px-2 py-1 text-xs bg-gray-100 border hover:bg-gray-200
|
|
129
|
-
dark:bg-background/10 dark:border-border/30 dark:hover:bg-background/20`,children:[v[P]?u.jsx(ue.Loader,{className:"h-4 w-4 animate-spin"}):null,u.jsxs("span",{className:"truncate max-w-[180px]",children:[B,v[P]?" (processing)":""]})]},P)}if(D.type==="interrupt"){const E=D,B=Go((E==null?void 0:E.id)??(E==null?void 0:E.interrupt_id)),Y=!!(N&&B&&B===N),_=Y?R??(E==null?void 0:E.value):E==null?void 0:E.value,M=B?{...E,id:B,interrupt_id:B}:E;return u.jsx(kp,{interruptPart:M,onApprove:g,onReject:x,disabled:y,isActive:Y,payload:_},P)}return null},[N,R,y,f,g,x,I,C,w,S,v,k,T]),K=i.trim().length>0||a.length>0||l.length>0||c.length>0;if(!t&&l.length>0&&!d)return $();if(!t&&!K&&!d)return null;if(t)return n?u.jsx(Ap,{message:e,viewMode:r,isStreaming:o},e.id):null;if(!m){const D=u.jsx("div",{className:"space-y-2",children:j.map((P,E)=>u.jsx(q,{part:P,i:E},E))});return d?u.jsxs("div",{"aria-busy":"true",role:"status",children:[D,u.jsx(Ip,{className:O})]}):D}return null}function $T(e,t){if(!t||!e)return e;let n=e;return n=FT(n),n=BT(n),n}function FT(e){const t=e.match(/\[[^\]]*\]\([^)]*$/);if(t&&typeof t.index=="number")return e.slice(0,t.index);const n=e.match(/\[[^\]]*$/);return n&&typeof n.index=="number"?e.slice(0,n.index):e}function BT(e){const t=e.match(/`[^`]*$/);return t&&typeof t.index=="number"?e.slice(0,t.index):e}const zT=zr.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 Pp({className:e,variant:t,...n}){return u.jsx("div",{className:re(zT({variant:t}),e),...n})}function HT({showTimestamp:e,showAgentName:t,isToolMessage:n,iconForeground:r,agentName:o,messageIcon:s,customHeaderClass:i,customActionsClass:a,isCompactLayout:l,showActions:c,isEditing:d,messageRole:h,toolViewMode:m,toolMeta:f,onToggleToolView:v,onCopy:g,onEdit:x,onRegenerate:y,showCheckpointControls:w,attemptCount:S,attemptIndex:k,handleOlderAttemptSelect:C,handleNewerAttemptSelect:T,messageCreatedAt:I,copied:N}){return!e&&!t&&!n?null:u.jsxs("div",{className:re("flex items-center justify-between mb-2 pb-2 border-b border-current/10",l&&"mb-1 pb-1",r,i),children:[u.jsxs("div",{className:"flex items-center gap-2",children:[s,t&&o&&u.jsx("span",{className:re("font-medium",l?"text-xs":"text-sm"),children:o}),n&&u.jsxs(Pp,{variant:"outline",className:re("text-xs flex items-center gap-1 cursor-pointer select-none",r,"border border-current/40",l&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":m==="expanded",onClick:v,onKeyDown:R=>{(R.key==="Enter"||R.key===" ")&&(R.preventDefault(),v())},children:[u.jsx("span",{children:f.name??"Tool Output"}),f.toolCallId&&u.jsx("span",{className:"opacity-70",children:f.toolCallId.slice(0,8)}),m==="expanded"?u.jsx(ue.ChevronUp,{className:"h-3 w-3"}):u.jsx(ue.ChevronDown,{className:"h-3 w-3"})]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[w&&S>1&&u.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[u.jsx("button",{type:"button",className:re("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",k<S-1?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{k>=S-1||C()},"aria-label":"Older attempt (back in time)",disabled:k>=S-1,children:u.jsx(ue.ChevronLeft,{className:"h-3 w-3"})}),u.jsx("div",{className:"flex items-center gap-2",children:u.jsxs("span",{className:"whitespace-nowrap",children:[S-k," / ",S]})}),u.jsx("button",{type:"button",className:re("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",k>0?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{k<=0||T()},"aria-label":"Newer attempt (forward in time)",disabled:k<=0,children:u.jsx(ue.ChevronRight,{className:"h-3 w-3"})})]}),e&&I&&u.jsx("time",{className:re("text-xs opacity-60",r,l&&"text-xs"),dateTime:new Date(I).toISOString(),title:new Date(I).toLocaleString(),children:new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(new Date(I))}),c&&!d&&u.jsxs("div",{className:re("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",a),children:[u.jsx("div",{className:"relative",children:u.jsx(Qe,{variant:"ghost",size:"sm",onClick:g,className:re("h-6 w-6 p-0 hover:bg-foreground/10",r,l&&"h-5 w-5"),"aria-label":"Copy message",title:"Copy message",children:u.jsx(ue.Copy,{className:re(N?"text-success":r,l?"h-3 w-3":"h-4 w-4")})})}),h==="user"&&x&&u.jsx(Qe,{variant:"ghost",size:"sm",onClick:x,className:re("h-6 w-6 p-0 hover:bg-foreground/10",r,l&&"h-5 w-5"),"aria-label":"Edit message",children:u.jsx(ue.Edit,{className:re(r,l?"h-3 w-3":"h-4 w-4")})}),h==="assistant"&&y&&u.jsx(Qe,{variant:"ghost",size:"sm",onClick:y,className:re("h-6 w-6 p-0 hover:bg-foreground/10",r,l&&"h-5 w-5"),"aria-label":"Regenerate response",children:u.jsx(ue.RotateCcw,{className:re(r,l?"h-3 w-3":"h-4 w-4")})})]})]})]})}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:h=!0,customStyles:m={},streamingDebounceMs:f=300,enableStreamingMarkdownBuffer:v,onEdit:g,onRegenerate:x,onCopy:y,activeInterrupt:w,disableInterruptActions:S=!1,onInterruptActionStart:k,onInterruptActionEnd:C,attemptCount:T=1,attemptIndex:I=0,onSelectCheckpoint:N,attemptMetas:R=[]}){const[O,$]=b.useState(!1),[V,U]=b.useState("preview"),[j,q]=b.useState(!1),{currentThreadId:K}=gr(),{respondToInterrupt:D}=eo(),P=l==="phone"||l==="half-screen",E=t.role,B=E==="tool",Y=b.useMemo(()=>t.role==="default_message"?t:null,[t]),_=!!Y,M=!(r&&E!=="user"),{uploadingFiles:G,handleFileClick:J,fileViewerOpen:se,currentFileInfo:W,closeFileViewer:L}=jp({allowFileOpen:M,currentThreadId:K}),X=b.useMemo(()=>{switch(E){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))]"}},[E]),ee=_p(t,Y),{contentParts:Z,imageParts:z,fileParts:ae,interruptParts:ie,textContent:ge,toolMeta:we,toolRaw:Ae,isToolStreaming:Pe}=ee,ke=v??f!==0,st=(w==null?void 0:w.id)??(w==null?void 0:w.interrupt_id),bt=Go(st),It=w==null?void 0:w.value,We=b.useCallback(async()=>{const Te=B?Ae:ge;async function Q(me){if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function"){await navigator.clipboard.writeText(me);return}if(navigator.clipboard&&typeof navigator.clipboard.write=="function"&&typeof ClipboardItem<"u"){const Ze=new Blob([me],{type:"text/plain"});await navigator.clipboard.write([new ClipboardItem({"text/plain":Ze})]);return}throw new Error("Clipboard API not supported in this context.")}try{await Q(Te),$(!0),setTimeout(()=>$(!1),2e3),y==null||y(Te)}catch(me){console.error("Failed to copy:",me)}},[B,Ae,ge,y]),ze=b.useCallback(()=>{if(!g||!t.id)return;const Te=(B?Ae:ge)??"",Q="type"in t&&t.type==="default_message"?void 0:{checkpointId:t.checkpointId??null,checkpointNs:t.checkpointNs??null};g(t.id,Te,Q)},[g,t.id,B,Ae,ge,t]),Ke=b.useCallback(()=>{x==null||x(n)},[x,n]),Fe=b.useCallback(()=>{U(Te=>Te==="expanded"?"preview":"expanded")},[]),Ue=b.useCallback(()=>{const Q=re(P?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",X);switch(E){case"user":return u.jsx(ue.User,{className:Q});case"assistant":return u.jsx(ue.Bot,{className:Q});case"tool":return u.jsx(ue.Wrench,{className:Q});default:return u.jsx(ue.Bot,{className:Q})}},[P,X,E]),ut=b.useCallback(()=>{const Te="group relative mb-4 flex w-full";switch(E){case"user":return re(Te,"justify-end");case"assistant":case"tool":case"system":return re(Te,"justify-start");default:return Te}},[E]),jt=b.useCallback(()=>{const Te=re("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",P&&"px-3 py-2 text-sm");if(_)return re(Te,"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(E){case"user":return re(Te,"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(Te,"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(Te,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return re(Te,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return re(Te,"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")}},[P,_,E]),it=b.useCallback(async Te=>{if(S)return;const Q=Go((Te==null?void 0:Te.id)??(Te==null?void 0:Te.interrupt_id));if(!Q){console.warn("Interrupt part missing id",Te);return}try{k==null||k(),await D(Q,!0)}catch(me){console.error("Failed to approve interrupt:",me)}finally{C==null||C()}},[S,C,k,D]),_t=b.useCallback(async Te=>{if(S)return;const Q=Go((Te==null?void 0:Te.id)??(Te==null?void 0:Te.interrupt_id));if(!Q){console.warn("Interrupt part missing id",Te);return}try{k==null||k(),await D(Q,!1)}catch(me){console.error("Failed to reject interrupt:",me)}finally{C==null||C()}},[S,C,k,D]),yt=u.jsx(LT,{message:t,isToolMessage:B,showToolMessages:h,toolViewMode:V,isToolStreaming:Pe,contentParts:Z,textContent:ge,imageParts:z,fileParts:ae,interruptParts:ie,isStreamingMessage:r,defaultMessage:Y,enableStreamingMarkdownBuffer:ke,handleFileClick:J,uploadingFiles:G,handleInterruptApprove:it,handleInterruptReject:_t,disableInterruptActions:S,messageRole:E,truncateUserMessages:c,userMessagePreviewLength:d,isUserExpanded:j,setIsUserExpanded:q,isCompactLayout:P,activeInterruptId:bt,activeInterruptValue:It,iconForeground:X}),gt=b.useMemo(()=>Y?"Assistant":Zv(t),[Y,t]),Nt=Ue(),St=E==="user"&&(T??1)>1&&typeof N=="function",Ct=(R==null?void 0:R.length)??0,zt=Ct>0&&I<Ct-1?R[I+1]:void 0,xt=Ct>0&&I>0?R[I-1]:void 0,Oe=b.useCallback(()=>{!zt||!N||N(zt.id,void 0,!!zt.isLatestAttempt)},[zt,N]),Ve=b.useCallback(()=>{!xt||!N||N(xt.id,void 0,!!xt.isLatestAttempt)},[xt,N]);return B&&!h?null:_&&Y?u.jsx("div",{className:re(ut(),m.container),children:u.jsxs("div",{className:re(jt(),m.content),children:[u.jsxs("div",{className:"flex items-center gap-2 mb-2 pb-2 border-b border-current/10",children:[u.jsx(ue.Bot,{className:re("h-4 w-4",X)}),a&&u.jsx("span",{className:"font-medium text-sm",children:"Assistant"})]}),u.jsx(Rr,{content:Y.content,className:"text-current"})]})}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:re(ut(),m.container),children:u.jsxs("div",{className:re(jt(),m.content),children:[u.jsx(HT,{showTimestamp:i,showAgentName:a,isToolMessage:B,iconForeground:X,agentName:gt,messageIcon:Nt,customHeaderClass:m.header,customActionsClass:m.actions,isCompactLayout:P,showActions:s,isEditing:o,messageRole:E,toolViewMode:V,toolMeta:we,onToggleToolView:Fe,onCopy:We,onEdit:ze,onRegenerate:Ke,showCheckpointControls:St,attemptCount:T,attemptIndex:I,handleOlderAttemptSelect:Oe,handleNewerAttemptSelect:Ve,messageCreatedAt:t.createdAt,copied:O}),u.jsx("div",{className:"relative",children:yt}),B&&V==="expanded"&&(we.toolCallId||we.name)&&u.jsxs("div",{className:re("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",P&&"text-xs"),children:[we.name&&u.jsxs("div",{children:["Function: ",we.name]}),we.toolCallId&&u.jsxs("div",{children:["Call ID: ",we.toolCallId]})]}),!(i||a||B)&&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",m.actions),children:[u.jsx(Qe,{variant:"ghost",size:"sm",onClick:()=>We(),className:re("h-6 w-6 p-0 hover:bg-background/50 text-current",P&&"h-5 w-5"),children:u.jsx(ue.Copy,{className:re(O?"text-success":"text-current",P?"h-3 w-3":"h-4 w-4")})}),E==="user"&&g&&u.jsx(Qe,{variant:"ghost",size:"sm",onClick:ze,className:re("h-6 w-6 p-0 hover:bg-background/50 text-current",P&&"h-5 w-5"),children:u.jsx(ue.Edit,{className:re("text-current",P?"h-3 w-3":"h-4 w-4")})}),E==="assistant"&&x&&u.jsx(Qe,{variant:"ghost",size:"sm",onClick:Ke,className:re("h-6 w-6 p-0 hover:bg-background/50 text-current",P&&"h-5 w-5"),children:u.jsx(ue.RotateCcw,{className:re("text-current",P?"h-3 w-3":"h-4 w-4")})})]})]})}),W&&u.jsx(ip,{isOpen:se,onClose:L,fileId:W.id,fileName:W.name,mimeType:W.mimeType})]})},(e,t)=>{var l,c,d,h,m,f,v,g;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&pu(e.message)===pu(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)===((h=t.customStyles)==null?void 0:h.content)&&((m=e.customStyles)==null?void 0:m.actions)===((f=t.customStyles)==null?void 0:f.actions)&&((v=e.customStyles)==null?void 0:v.header)===((g=t.customStyles)==null?void 0:g.header);if(!o||!s)return!1;const i=mu(e.message),a=mu(t.message);return i.length===a.length});Ys.displayName="MessageComponent";const hl=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:h,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,checkpointIndex:I,activeCheckpointId:N,onSelectCheckpoint:R,createSyntheticThinkingMessage:O=!0,forceSyntheticThinking:$=!1},V)=>{const U=b.useRef(null),j=b.useRef(null),q=b.useRef(!1),K=b.useRef(!1),[D,P]=b.useState(!0),E=b.useMemo(()=>w?e.some(z=>z.role==="default_message"?!1:Array.isArray(z==null?void 0:z.content)&&z.content.some(ae=>ae&&ae.type==="interrupt"&&(ae.id??ae.interrupt_id)===w.id)):!1,[w,e]),B=b.useMemo(()=>{if(!w||E)return null;const z=w.id&&String(w.id).trim()?String(w.id).trim():"pending-interrupt";let ae;const ie=w.value;if(ie&&typeof ie=="object"&&!Array.isArray(ie)){const ge=ie.title;typeof ge=="string"&&ge.trim()&&(ae=ge.trim())}return{id:`interrupt-${z}`,role:"system",createdAt:new Date().toISOString(),content:[{type:"interrupt",id:z,value:ie,title:ae}]}},[w,E]),Y=b.useMemo(()=>B?[...e,B]:e,[e,B]),_=b.useMemo(()=>{const z=n&&Y.some(ie=>ie.id===n);return O&&(t||$)&&!z&&Y.length>0?[...Y,{id:"thinking-assistant",role:"assistant",content:[{type:"text",text:""}],createdAt:new Date().toISOString(),__syntheticStreaming:!0}]:Y},[Y,t,n,O,$]),M=b.useMemo(()=>T?_:_.filter(z=>(z==null?void 0:z.role)!=="tool"),[_,T]),G=b.useCallback(z=>{P(z),x&&x(!z),y&&y(z)},[x,y]),J=b.useMemo(()=>{if(a)return async()=>{if(!q.current){q.current=!0;try{await a()}finally{q.current=!1}}}},[a]),se=b.useMemo(()=>!v||g?!1:D?"auto":!1,[D,v,g]),W=b.useMemo(()=>{if(typeof f!="string")return null;const z=f.trim();return!z||M&&M.length>0?null:{id:"default-message",role:"default_message",content:z,createdAt:new Date().toISOString()}},[f,M]),L=["flex h-full flex-col md:flex-row",h].filter(Boolean).join(" "),X=()=>W?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:W,messageIndex:0,isStreamingMessage:!1,showActions:!1,showTimestamp:!1,showAgentName:!0,layoutSize:o,onEdit:()=>{},onRegenerate:()=>{},onCancelEdit:()=>{}})})}):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!"}),ee=M.length,Z=ee>0;return b.useEffect(()=>{var z,ae;if(ee===0){K.current=!1;return}if(!K.current)if(K.current=!0,U.current&&M.length>0){const ie=M.length-1;(ae=(z=U.current).scrollToIndex)==null||ae.call(z,{index:ie,align:"end",behavior:"auto"})}else j.current&&(j.current.scrollTop=j.current.scrollHeight)},[ee,M.length]),b.useImperativeHandle(V,()=>({scrollToLatest:()=>{var z,ae;if(U.current&&M.length>0){const ie=M.length-1;(ae=(z=U.current).scrollToIndex)==null||ae.call(z,{index:ie,align:"end",behavior:"auto"})}else j.current&&(j.current.scrollTop=j.current.scrollHeight)},scrollToTop:()=>{var z,ae;U.current&&M.length>0?(ae=(z=U.current).scrollToIndex)==null||ae.call(z,{index:0,align:"start",behavior:"auto"}):j.current&&(j.current.scrollTop=0)}}),[M]),u.jsx("div",{className:L,style:m,children:u.jsx("div",{className:"relative flex-1 min-h-0",children:Z?u.jsx(LC,{ref:z=>{U.current=z},scrollerRef:z=>{j.current=z instanceof HTMLDivElement?z:null},data:M,followOutput:se,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,startReached:()=>{J&&J()},atBottomStateChange:G,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(z,ae)=>dl(ae,z),itemContent:(z,ae)=>u.jsx(fl,{message:ae,index:z,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,checkpointIndex:I,activeCheckpointId:N,onSelectCheckpoint:R})}):X()})})});hl.displayName="MessageList";const Rp={value:""};function Mr({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,payloadExtras:h={},customStyles:m={},onMessageSent:f,onExcelUploadSuccess:v,onError:g}){const{api:x}=Xr(),{currentThreadId:y}=gr(),{threadId:w,messages:S,isHistoryLoading:k,isLoading:C,navigateToCheckpoint:T,returnToLatest:I,checkpoint:N,checkpoints:R,interrupt:O,metadata:$,checkpointIndex:V}=eo(),{isStreaming:U,error:j,connectionState:q,submit:K,stop:D}=Li(),P=w??y??null,E=(N==null?void 0:N.id)??null,B=(N==null?void 0:N.namespace)??null,Y=($==null?void 0:$.assemblingMessageId)??null,_=O,[M,G]=b.useState(!1),[J,se]=b.useState(!1);b.useEffect(()=>{_||G(!1)},[_]);const W=b.useCallback(()=>{G(!0)},[]),L=b.useCallback(()=>{G(!1)},[]),X=!!_||M,[ee,Z]=b.useState(null),[z,ae]=b.useState(""),[ie,ge]=b.useState(null),[we,Ae]=b.useState(null),[Pe,ke]=b.useState([]),[st,bt]=b.useState(0),[It,We]=b.useState(0),[ze,Ke]=b.useState(!1),[Fe,Ue]=b.useState(null),[ut,jt]=b.useState(null),[it,_t]=b.useState(!1),[yt,gt]=b.useState(null),Nt=b.useRef(!1),[St,Ct]=b.useState(()=>Rp.value),zt=b.useRef(St),xt=b.useRef(null),Oe=b.useCallback(le=>{Rp.value=le,Ct(le)},[]),[Ve,Te]=b.useState(!1),Q=b.useRef(null),me=b.useRef(null),Ze=b.useRef(null),xe=b.useCallback(()=>{me.current&&(me.current.value=""),Ze.current&&(Ze.current.value=""),bt(le=>le+1),We(le=>le+1)},[]),Be=b.useCallback(le=>{Oe(le)},[Oe]),Ge=b.useRef(!1);b.useEffect(()=>{Ge.current&&!U&&(ke([]),xe()),Ge.current=U},[U,xe]),b.useEffect(()=>{U||se(!1)},[U]),b.useEffect(()=>{$!=null&&$.assemblingMessageId&&se(!1)},[$==null?void 0:$.assemblingMessageId]);const[Tt,kt]=b.useState("desktop");b.useEffect(()=>{const le=()=>{const de=window.innerWidth;kt(de<640?"phone":de<1024?"tablet":"desktop")};return le(),window.addEventListener("resize",le),()=>window.removeEventListener("resize",le)},[]),b.useEffect(()=>{Nt.current=!1},[P]),b.useEffect(()=>{zt.current=St},[St]),b.useEffect(()=>{if(!ee){xt.current=null;return}xt.current===null&&(xt.current=zt.current),Oe(z??"")},[z,ee,Oe]),b.useEffect(()=>{(async()=>{if(!x.baseUrl){gt(null);return}try{const Ce=(await x.getAgent("default")).uiDefaultMessage||"";gt(Ce||null)}catch(de){console.warn("Failed to fetch default message:",de),gt(null)}})()},[x.baseUrl]),b.useEffect(()=>{j&&!it&&(g==null||g(j))},[j,it,g]);const At=async le=>{const de=le.trim();if(!(!de&&Pe.length===0))try{const Ce=ee?(ie==null?void 0:ie.checkpointId)??E??void 0:E??void 0,De=ee?(ie==null?void 0:ie.checkpointNs)??B??void 0:B??void 0;await K({text:de||"",attachments:Pe,payload:h},{checkpointId:Ce,checkpointNs:De,edit:!!ee,originalMessageId:ee??void 0}),f==null||f(de),se(!0),Oe(""),Ae(null),ke([]),xe(),Z(null),ae(""),ge(null)}catch(Ce){const De=(Ce==null?void 0:Ce.message)||"Failed to send message";Ae(De),g==null||g(De),se(!1)}},Lt=b.useCallback((le,de,Ce)=>{c&&(xt.current=St,Z(le),ae(de),Oe(de),Ae(null),ge({checkpointId:(Ce==null?void 0:Ce.checkpointId)??null,checkpointNs:(Ce==null?void 0:Ce.checkpointNs)??null}))},[St,c,Oe]),je=b.useCallback(()=>{Z(null),ae(""),ge(null),Ae(null),Oe(xt.current??St),xt.current=null},[St,Oe]),dt=b.useCallback((le,de,Ce)=>{Lt(le,de,Ce)},[Lt]),Xe=b.useCallback(le=>{let de=null;for(let ft=le-1;ft>=0;ft--)if(S[ft].role==="user"){de=S[ft];break}if(!de)return;const Ce=Array.isArray(de.content)?de.content:[],at=Ce.filter(ft=>(ft==null?void 0:ft.type)==="text").map(ft=>ft.text).join("")||(()=>{try{return JSON.stringify(Ce,null,2)}catch{return String(Ce)}})();at&&K({text:at,payload:h},{checkpointId:E??void 0,checkpointNs:B??void 0,edit:!0,originalMessageId:de.id})},[S,K,E,B,h]),ct=le=>{const de=Array.from(le.target.files||[]);ke(Ce=>[...Ce,...de]),le.target.value=""},an=le=>{ke(de=>{const Ce=de.filter((De,at)=>le!==at);return Ce.length===0&&xe(),Ce})},A=async le=>{const de=(le.target.files||[])[0];if(de){Ue(null),jt(null),Ke(!0);try{await K({attachments:[de],payload:h},{checkpointId:E??void 0,checkpointNs:B??void 0});const Ce=`Uploaded ${de.name} - processing through chat stream`;jt(Ce)}catch(Ce){const De=Ce instanceof Error?Ce.message:"Failed to upload Excel file";console.error("Excel upload failed",Ce),Ue(De),g==null||g(De)}finally{Ke(!1),le.target.value="",xe()}}},te=async le=>{if(y){Te(!0);try{if(!le){await I(),requestAnimationFrame(()=>{var De;(De=Q.current)==null||De.scrollToLatest()});return}const de=R.find(De=>De.checkpointId===le),Ce=(de==null?void 0:de.checkpointNs)??null;await T(le,Ce),requestAnimationFrame(()=>{var De;(De=Q.current)==null||De.scrollToTop()})}finally{Te(!1)}}},fe=b.useCallback(async(le,de,Ce)=>{await te(Ce?null:le)},[te]),Ie=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${m.container||""}`,Ye=`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||""}`,et=`relative flex-shrink-0 w-full border-t p-4 bg-transparent ${m.inputArea||""}`;return u.jsxs("div",{className:Ie,children:[!!j&&!it&&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:j}),u.jsx(Qe,{variant:"ghost",size:"sm",onClick:()=>_t(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:u.jsx(ue.X,{size:16})})]}),u.jsxs("div",{className:`relative ${Ye}`,style:r?{maxHeight:r}:void 0,children:[u.jsx(hl,{ref:Q,className:"h-full",style:{height:"100%"},messages:S,isStreaming:U,streamingAssistantId:Y,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:Tt,enableMessageEditing:c,editingMessageId:ee,onEdit:dt,onRegenerate:Xe,onCancelEdit:je,emptyMessage:yt??void 0,isNavigatingCheckpoint:Ve,activeInterrupt:_,disableInterruptActions:M,onInterruptActionStart:W,onInterruptActionEnd:L,showToolMessages:d,checkpointIndex:V,activeCheckpointId:E,onSelectCheckpoint:fe,createSyntheticThinkingMessage:!0,forceSyntheticThinking:J}),(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(ue.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(ue.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading messages…"})]}),(k||Ve)&&u.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 bg-background/80 backdrop-blur-sm text-muted-foreground",children:[u.jsx(ue.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading checkpoint…"})]})]}),u.jsxs("div",{className:et,children:[ee&&u.jsx("div",{className:"mb-3 p-3 bg-blue-50 border border-blue-200 rounded-lg",children:u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(ue.Edit3,{size:16,className:"text-blue-600"}),u.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),u.jsx(Qe,{variant:"ghost",size:"sm",onClick:je,className:"text-blue-600 hover:bg-blue-100",children:u.jsx(ue.X,{size:16})})]})}),(a||l)&&u.jsxs("div",{className:"mb-3 space-y-3",children:[a&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:me,type:"file",multiple:!0,onChange:le=>ct(le),className:"hidden"},st),Pe.length>0&&u.jsx("div",{className:"flex flex-wrap gap-2",children:Pe.map((le,de)=>u.jsxs("div",{className:"flex items-center gap-2 bg-gray-100 dark:bg-gray-800 rounded-lg px-3 py-2 text-sm text-gray-900 dark:text-gray-100",children:[u.jsx(ue.Paperclip,{size:14}),u.jsx("span",{className:"truncate max-w-[150px]",children:le.name}),u.jsx(Qe,{variant:"ghost",size:"sm",onClick:()=>an(de),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 ${le.name}`,children:u.jsx(ue.X,{size:12})})]},de))})]}),l&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:Ze,type:"file",accept:".xls,.xlsx,.xlsm",onChange:A,className:"hidden"},It),ze&&u.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(ue.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),ut&&!ze&&u.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:ut}),Fe&&!ze&&u.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:Fe})]})]}),we&&u.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:we}),u.jsxs("div",{className:"flex items-end gap-2",children:[(a||l)&&u.jsxs(Ss,{children:[u.jsx(Cs,{asChild:!0,children:u.jsx(Qe,{type:"button",size:"icon",variant:"outline",disabled:U||X,title:"More input actions",className:m.moreButton||"",children:u.jsx(ue.Plus,{size:16})})}),u.jsxs(ho,{align:"start",sideOffset:6,className:"w-52",children:[a&&u.jsxs(Bn,{onClick:()=>{var le;return(le=me.current)==null?void 0:le.click()},className:"cursor-pointer",children:[u.jsx(ue.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),l&&u.jsxs(Bn,{onClick:()=>{var le;ze||(le=Ze.current)==null||le.click()},className:`cursor-pointer ${ze?"opacity-60 pointer-events-none":""}`,children:[u.jsx(ue.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),u.jsx("div",{className:"flex-1",children:u.jsx(IS,{initialValue:z,editingMessageId:ee,value:St,onValueChange:Be,placeholder:ee?"Edit your message...":t,isStreaming:U,disabled:X,onSend:At,onCancelEdit:je,onStop:D,allowEmptySend:Pe.length>0,textareaClassName:`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${ee?"border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50":""} ${we?"border-red-400":""} ${m.textarea||""}`})})]})]})]})}var Mp=1,UT=.9,WT=.8,VT=.17,pl=.1,ml=.999,KT=.9999,qT=.99,GT=/[\\\/_+.#"@\[\(\{&]/,YT=/[\\\/_+.#"@\[\(\{&]/g,XT=/[\s-]/,Op=/[\s-]/g;function gl(e,t,n,r,o,s,i){if(s===t.length)return o===e.length?Mp:qT;var a=`${o},${s}`;if(i[a]!==void 0)return i[a];for(var l=r.charAt(s),c=n.indexOf(l,o),d=0,h,m,f,v;c>=0;)h=gl(e,t,n,r,c+1,s+1,i),h>d&&(c===o?h*=Mp:GT.test(e.charAt(c-1))?(h*=WT,f=e.slice(o,c-1).match(YT),f&&o>0&&(h*=Math.pow(ml,f.length))):XT.test(e.charAt(c-1))?(h*=UT,v=e.slice(o,c-1).match(Op),v&&o>0&&(h*=Math.pow(ml,v.length))):(h*=VT,o>0&&(h*=Math.pow(ml,c-o))),e.charAt(c)!==t.charAt(s)&&(h*=KT)),(h<pl&&n.charAt(c-1)===r.charAt(s+1)||r.charAt(s+1)===r.charAt(s)&&n.charAt(c-1)!==r.charAt(s))&&(m=gl(e,t,n,r,c+1,s+2,i),m*pl>h&&(h=m*pl)),h>d&&(d=h),c=n.indexOf(l,c+1);return i[a]=d,d}function Dp(e){return e.toLowerCase().replace(Op," ")}function JT(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,gl(e,t,Dp(e),Dp(t),0,0,{})}var Io='[cmdk-group=""]',xl='[cmdk-group-items=""]',ZT='[cmdk-group-heading=""]',Lp='[cmdk-item=""]',$p=`${Lp}:not([aria-disabled="true"])`,vl="cmdk-item-select",Or="data-value",QT=(e,t,n)=>JT(e,t,n),Fp=p.createContext(void 0),No=()=>p.useContext(Fp),Bp=p.createContext(void 0),bl=()=>p.useContext(Bp),zp=p.createContext(void 0),Hp=p.forwardRef((e,t)=>{let n=Dr(()=>{var _,M;return{search:"",value:(M=(_=e.value)!=null?_:e.defaultValue)!=null?M:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=Dr(()=>new Set),o=Dr(()=>new Map),s=Dr(()=>new Map),i=Dr(()=>new Set),a=Up(e),{label:l,children:c,value:d,onValueChange:h,filter:m,shouldFilter:f,loop:v,disablePointerSelection:g=!1,vimBindings:x=!0,...y}=e,w=Rt(),S=Rt(),k=Rt(),C=p.useRef(null),T=uk();cr(()=>{if(d!==void 0){let _=d.trim();n.current.value=_,I.emit()}},[d]),cr(()=>{T(6,U)},[]);let I=p.useMemo(()=>({subscribe:_=>(i.current.add(_),()=>i.current.delete(_)),snapshot:()=>n.current,setState:(_,M,G)=>{var J,se,W,L;if(!Object.is(n.current[_],M)){if(n.current[_]=M,_==="search")V(),O(),T(1,$);else if(_==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let X=document.getElementById(k);X?X.focus():(J=document.getElementById(w))==null||J.focus()}if(T(7,()=>{var X;n.current.selectedItemId=(X=j())==null?void 0:X.id,I.emit()}),G||T(5,U),((se=a.current)==null?void 0:se.value)!==void 0){let X=M??"";(L=(W=a.current).onValueChange)==null||L.call(W,X);return}}I.emit()}},emit:()=>{i.current.forEach(_=>_())}}),[]),N=p.useMemo(()=>({value:(_,M,G)=>{var J;M!==((J=s.current.get(_))==null?void 0:J.value)&&(s.current.set(_,{value:M,keywords:G}),n.current.filtered.items.set(_,R(M,G)),T(2,()=>{O(),I.emit()}))},item:(_,M)=>(r.current.add(_),M&&(o.current.has(M)?o.current.get(M).add(_):o.current.set(M,new Set([_]))),T(3,()=>{V(),O(),n.current.value||$(),I.emit()}),()=>{s.current.delete(_),r.current.delete(_),n.current.filtered.items.delete(_);let G=j();T(4,()=>{V(),(G==null?void 0:G.getAttribute("id"))===_&&$(),I.emit()})}),group:_=>(o.current.has(_)||o.current.set(_,new Set),()=>{s.current.delete(_),o.current.delete(_)}),filter:()=>a.current.shouldFilter,label:l||e["aria-label"],getDisablePointerSelection:()=>a.current.disablePointerSelection,listId:w,inputId:k,labelId:S,listInnerRef:C}),[]);function R(_,M){var G,J;let se=(J=(G=a.current)==null?void 0:G.filter)!=null?J:QT;return _?se(_,n.current.search,M):0}function O(){if(!n.current.search||a.current.shouldFilter===!1)return;let _=n.current.filtered.items,M=[];n.current.filtered.groups.forEach(J=>{let se=o.current.get(J),W=0;se.forEach(L=>{let X=_.get(L);W=Math.max(X,W)}),M.push([J,W])});let G=C.current;q().sort((J,se)=>{var W,L;let X=J.getAttribute("id"),ee=se.getAttribute("id");return((W=_.get(ee))!=null?W:0)-((L=_.get(X))!=null?L:0)}).forEach(J=>{let se=J.closest(xl);se?se.appendChild(J.parentElement===se?J:J.closest(`${xl} > *`)):G.appendChild(J.parentElement===G?J:J.closest(`${xl} > *`))}),M.sort((J,se)=>se[1]-J[1]).forEach(J=>{var se;let W=(se=C.current)==null?void 0:se.querySelector(`${Io}[${Or}="${encodeURIComponent(J[0])}"]`);W==null||W.parentElement.appendChild(W)})}function $(){let _=q().find(G=>G.getAttribute("aria-disabled")!=="true"),M=_==null?void 0:_.getAttribute(Or);I.setState("value",M||void 0)}function V(){var _,M,G,J;if(!n.current.search||a.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let se=0;for(let W of r.current){let L=(M=(_=s.current.get(W))==null?void 0:_.value)!=null?M:"",X=(J=(G=s.current.get(W))==null?void 0:G.keywords)!=null?J:[],ee=R(L,X);n.current.filtered.items.set(W,ee),ee>0&&se++}for(let[W,L]of o.current)for(let X of L)if(n.current.filtered.items.get(X)>0){n.current.filtered.groups.add(W);break}n.current.filtered.count=se}function U(){var _,M,G;let J=j();J&&(((_=J.parentElement)==null?void 0:_.firstChild)===J&&((G=(M=J.closest(Io))==null?void 0:M.querySelector(ZT))==null||G.scrollIntoView({block:"nearest"})),J.scrollIntoView({block:"nearest"}))}function j(){var _;return(_=C.current)==null?void 0:_.querySelector(`${Lp}[aria-selected="true"]`)}function q(){var _;return Array.from(((_=C.current)==null?void 0:_.querySelectorAll($p))||[])}function K(_){let M=q()[_];M&&I.setState("value",M.getAttribute(Or))}function D(_){var M;let G=j(),J=q(),se=J.findIndex(L=>L===G),W=J[se+_];(M=a.current)!=null&&M.loop&&(W=se+_<0?J[J.length-1]:se+_===J.length?J[0]:J[se+_]),W&&I.setState("value",W.getAttribute(Or))}function P(_){let M=j(),G=M==null?void 0:M.closest(Io),J;for(;G&&!J;)G=_>0?lk(G,Io):ck(G,Io),J=G==null?void 0:G.querySelector($p);J?I.setState("value",J.getAttribute(Or)):D(_)}let E=()=>K(q().length-1),B=_=>{_.preventDefault(),_.metaKey?E():_.altKey?P(1):D(1)},Y=_=>{_.preventDefault(),_.metaKey?K(0):_.altKey?P(-1):D(-1)};return p.createElement(ve.div,{ref:t,tabIndex:-1,...y,"cmdk-root":"",onKeyDown:_=>{var M;(M=y.onKeyDown)==null||M.call(y,_);let G=_.nativeEvent.isComposing||_.keyCode===229;if(!(_.defaultPrevented||G))switch(_.key){case"n":case"j":{x&&_.ctrlKey&&B(_);break}case"ArrowDown":{B(_);break}case"p":case"k":{x&&_.ctrlKey&&Y(_);break}case"ArrowUp":{Y(_);break}case"Home":{_.preventDefault(),K(0);break}case"End":{_.preventDefault(),E();break}case"Enter":{_.preventDefault();let J=j();if(J){let se=new Event(vl);J.dispatchEvent(se)}}}}},p.createElement("label",{"cmdk-label":"",htmlFor:N.inputId,id:N.labelId,style:fk},l),Xs(e,_=>p.createElement(Bp.Provider,{value:I},p.createElement(Fp.Provider,{value:N},_))))}),ek=p.forwardRef((e,t)=>{var n,r;let o=Rt(),s=p.useRef(null),i=p.useContext(zp),a=No(),l=Up(e),c=(r=(n=l.current)==null?void 0:n.forceMount)!=null?r:i==null?void 0:i.forceMount;cr(()=>{if(!c)return a.item(o,i==null?void 0:i.id)},[c]);let d=Wp(o,s,[e.value,e.children,s],e.keywords),h=bl(),m=qn(T=>T.value&&T.value===d.current),f=qn(T=>c||a.filter()===!1?!0:T.search?T.filtered.items.get(o)>0:!0);p.useEffect(()=>{let T=s.current;if(!(!T||e.disabled))return T.addEventListener(vl,v),()=>T.removeEventListener(vl,v)},[f,e.onSelect,e.disabled]);function v(){var T,I;g(),(I=(T=l.current).onSelect)==null||I.call(T,d.current)}function g(){h.setState("value",d.current,!0)}if(!f)return null;let{disabled:x,value:y,onSelect:w,forceMount:S,keywords:k,...C}=e;return p.createElement(ve.div,{ref:On(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)}),tk=p.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:o,...s}=e,i=Rt(),a=p.useRef(null),l=p.useRef(null),c=Rt(),d=No(),h=qn(f=>o||d.filter()===!1?!0:f.search?f.filtered.groups.has(i):!0);cr(()=>d.group(i),[]),Wp(i,a,[e.value,e.heading,l]);let m=p.useMemo(()=>({id:i,forceMount:o}),[o]);return p.createElement(ve.div,{ref:On(a,t),...s,"cmdk-group":"",role:"presentation",hidden:h?void 0:!0},n&&p.createElement("div",{ref:l,"cmdk-group-heading":"","aria-hidden":!0,id:c},n),Xs(e,f=>p.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?c:void 0},p.createElement(zp.Provider,{value:m},f))))}),nk=p.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,o=p.useRef(null),s=qn(i=>!i.search);return!n&&!s?null:p.createElement(ve.div,{ref:On(o,t),...r,"cmdk-separator":"",role:"separator"})}),rk=p.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,o=e.value!=null,s=bl(),i=qn(c=>c.search),a=qn(c=>c.selectedItemId),l=No();return p.useEffect(()=>{e.value!=null&&s.setState("search",e.value)},[e.value]),p.createElement(ve.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)}})}),ok=p.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...o}=e,s=p.useRef(null),i=p.useRef(null),a=qn(c=>c.selectedItemId),l=No();return p.useEffect(()=>{if(i.current&&s.current){let c=i.current,d=s.current,h,m=new ResizeObserver(()=>{h=requestAnimationFrame(()=>{let f=c.offsetHeight;d.style.setProperty("--cmdk-list-height",f.toFixed(1)+"px")})});return m.observe(c),()=>{cancelAnimationFrame(h),m.unobserve(c)}}},[]),p.createElement(ve.div,{ref:On(s,t),...o,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":a,"aria-label":r,id:l.listId},Xs(e,c=>p.createElement("div",{ref:On(i,l.listInnerRef),"cmdk-list-sizer":""},c)))}),sk=p.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:o,contentClassName:s,container:i,...a}=e;return p.createElement(Ja,{open:n,onOpenChange:r},p.createElement(Za,{container:i},p.createElement(To,{"cmdk-overlay":"",className:o}),p.createElement(ko,{"aria-label":e.label,"cmdk-dialog":"",className:s},p.createElement(Hp,{ref:t,...a}))))}),ik=p.forwardRef((e,t)=>qn(n=>n.filtered.count===0)?p.createElement(ve.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),ak=p.forwardRef((e,t)=>{let{progress:n,children:r,label:o="Loading...",...s}=e;return p.createElement(ve.div,{ref:t,...s,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":o},Xs(e,i=>p.createElement("div",{"aria-hidden":!0},i)))}),Kt=Object.assign(Hp,{List:ok,Item:ek,Input:rk,Group:tk,Separator:nk,Dialog:sk,Empty:ik,Loading:ak});function lk(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function ck(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function Up(e){let t=p.useRef(e);return cr(()=>{t.current=e}),t}var cr=typeof window>"u"?p.useEffect:p.useLayoutEffect;function Dr(e){let t=p.useRef();return t.current===void 0&&(t.current=e()),t}function qn(e){let t=bl(),n=()=>e(t.snapshot());return p.useSyncExternalStore(t.subscribe,n,n)}function Wp(e,t,n,r=[]){let o=p.useRef(),s=No();return cr(()=>{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(Or,a),o.current=a}),o}var uk=()=>{let[e,t]=p.useState(),n=Dr(()=>new Map);return cr(()=>{n.current.forEach(r=>r()),n.current=new Map},[e]),(r,o)=>{n.current.set(r,o),t({})}};function dk(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function Xs({asChild:e,children:t},n){return e&&p.isValidElement(t)?p.cloneElement(dk(t),{ref:t.ref},n(t.props.children)):n(t)}var fk={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const wl=p.forwardRef(({className:e,...t},n)=>u.jsx(Kt,{ref:n,className:re("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));wl.displayName=Kt.displayName;const yl=p.forwardRef(({className:e,...t},n)=>u.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[u.jsx(ue.Search,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),u.jsx(Kt.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})]}));yl.displayName=Kt.Input.displayName;const Sl=p.forwardRef(({className:e,...t},n)=>u.jsx(Kt.List,{ref:n,className:re("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));Sl.displayName=Kt.List.displayName;const Cl=p.forwardRef((e,t)=>u.jsx(Kt.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));Cl.displayName=Kt.Empty.displayName;const Tl=p.forwardRef(({className:e,...t},n)=>u.jsx(Kt.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}));Tl.displayName=Kt.Group.displayName;const hk=p.forwardRef(({className:e,...t},n)=>u.jsx(Kt.Separator,{ref:n,className:re("-mx-1 h-px bg-border",e),...t}));hk.displayName=Kt.Separator.displayName;const kl=p.forwardRef(({className:e,...t},n)=>u.jsx(Kt.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}));kl.displayName=Kt.Item.displayName;function El(e,[t,n]){return Math.min(n,Math.max(t,e))}function pk(e,t){return p.useReducer((n,r)=>t[n][r]??n,e)}var Il="ScrollArea",[Vp,_N]=cn(Il),[mk,sn]=Vp(Il),Kp=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,l]=p.useState(null),[c,d]=p.useState(null),[h,m]=p.useState(null),[f,v]=p.useState(null),[g,x]=p.useState(null),[y,w]=p.useState(0),[S,k]=p.useState(0),[C,T]=p.useState(!1),[I,N]=p.useState(!1),R=Le(t,$=>l($)),O=Xo(o);return u.jsx(mk,{scope:n,type:r,dir:O,scrollHideDelay:s,scrollArea:a,viewport:c,onViewportChange:d,content:h,onContentChange:m,scrollbarX:f,onScrollbarXChange:v,scrollbarXEnabled:C,onScrollbarXEnabledChange:T,scrollbarY:g,onScrollbarYChange:x,scrollbarYEnabled:I,onScrollbarYEnabledChange:N,onCornerWidthChange:w,onCornerHeightChange:k,children:u.jsx(ve.div,{dir:O,...i,ref:R,style:{position:"relative","--radix-scroll-area-corner-width":y+"px","--radix-scroll-area-corner-height":S+"px",...e.style}})})});Kp.displayName=Il;var qp="ScrollAreaViewport",Gp=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=sn(qp,n),a=p.useRef(null),l=Le(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(ve.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})})]})});Gp.displayName=qp;var In="ScrollAreaScrollbar",Nl=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=sn(In,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:i}=o,a=e.orientation==="horizontal";return p.useEffect(()=>(a?s(!0):i(!0),()=>{a?s(!1):i(!1)}),[a,s,i]),o.type==="hover"?u.jsx(gk,{...r,ref:t,forceMount:n}):o.type==="scroll"?u.jsx(xk,{...r,ref:t,forceMount:n}):o.type==="auto"?u.jsx(Yp,{...r,ref:t,forceMount:n}):o.type==="always"?u.jsx(Al,{...r,ref:t}):null});Nl.displayName=In;var gk=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=sn(In,e.__scopeScrollArea),[s,i]=p.useState(!1);return p.useEffect(()=>{const a=o.scrollArea;let l=0;if(a){const c=()=>{window.clearTimeout(l),i(!0)},d=()=>{l=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",c),a.addEventListener("pointerleave",d),()=>{window.clearTimeout(l),a.removeEventListener("pointerenter",c),a.removeEventListener("pointerleave",d)}}},[o.scrollArea,o.scrollHideDelay]),u.jsx(Wt,{present:n||s,children:u.jsx(Yp,{"data-state":s?"visible":"hidden",...r,ref:t})})}),xk=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=sn(In,e.__scopeScrollArea),s=e.orientation==="horizontal",i=ei(()=>l("SCROLL_END"),100),[a,l]=pk("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return p.useEffect(()=>{if(a==="idle"){const c=window.setTimeout(()=>l("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(c)}},[a,o.scrollHideDelay,l]),p.useEffect(()=>{const c=o.viewport,d=s?"scrollLeft":"scrollTop";if(c){let h=c[d];const m=()=>{const f=c[d];h!==f&&(l("SCROLL"),i()),h=f};return c.addEventListener("scroll",m),()=>c.removeEventListener("scroll",m)}},[o.viewport,s,l,i]),u.jsx(Wt,{present:n||a!=="hidden",children:u.jsx(Al,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:ce(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:ce(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),Yp=p.forwardRef((e,t)=>{const n=sn(In,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=p.useState(!1),a=e.orientation==="horizontal",l=ei(()=>{if(n.viewport){const c=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?c:d)}},10);return Lr(n.viewport,l),Lr(n.content,l),u.jsx(Wt,{present:r||s,children:u.jsx(Al,{"data-state":s?"visible":"hidden",...o,ref:t})})}),Al=p.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=sn(In,e.__scopeScrollArea),s=p.useRef(null),i=p.useRef(0),[a,l]=p.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),c=em(a.viewport,a.content),d={...r,sizes:a,onSizesChange:l,hasThumb:c>0&&c<1,onThumbChange:m=>s.current=m,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:m=>i.current=m};function h(m,f){return Ck(m,i.current,a,f)}return n==="horizontal"?u.jsx(vk,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollLeft,f=tm(m,a,o.dir);s.current.style.transform=`translate3d(${f}px, 0, 0)`}},onWheelScroll:m=>{o.viewport&&(o.viewport.scrollLeft=m)},onDragScroll:m=>{o.viewport&&(o.viewport.scrollLeft=h(m,o.dir))}}):n==="vertical"?u.jsx(bk,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollTop,f=tm(m,a);s.current.style.transform=`translate3d(0, ${f}px, 0)`}},onWheelScroll:m=>{o.viewport&&(o.viewport.scrollTop=m)},onDragScroll:m=>{o.viewport&&(o.viewport.scrollTop=h(m))}}):null}),vk=p.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=sn(In,e.__scopeScrollArea),[i,a]=p.useState(),l=p.useRef(null),c=Le(t,l,s.onScrollbarXChange);return p.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(Jp,{"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":Qs(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.x),onDragScroll:d=>e.onDragScroll(d.x),onWheelScroll:(d,h)=>{if(s.viewport){const m=s.viewport.scrollLeft+d.deltaX;e.onWheelScroll(m),rm(m,h)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:l.current.clientWidth,paddingStart:Zs(i.paddingLeft),paddingEnd:Zs(i.paddingRight)}})}})}),bk=p.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=sn(In,e.__scopeScrollArea),[i,a]=p.useState(),l=p.useRef(null),c=Le(t,l,s.onScrollbarYChange);return p.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(Jp,{"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":Qs(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.y),onDragScroll:d=>e.onDragScroll(d.y),onWheelScroll:(d,h)=>{if(s.viewport){const m=s.viewport.scrollTop+d.deltaY;e.onWheelScroll(m),rm(m,h)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:l.current.clientHeight,paddingStart:Zs(i.paddingTop),paddingEnd:Zs(i.paddingBottom)}})}})}),[wk,Xp]=Vp(In),Jp=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:l,onDragScroll:c,onWheelScroll:d,onResize:h,...m}=e,f=sn(In,n),[v,g]=p.useState(null),x=Le(t,R=>g(R)),y=p.useRef(null),w=p.useRef(""),S=f.viewport,k=r.content-r.viewport,C=pt(d),T=pt(l),I=ei(h,10);function N(R){if(y.current){const O=R.clientX-y.current.left,$=R.clientY-y.current.top;c({x:O,y:$})}}return p.useEffect(()=>{const R=O=>{const $=O.target;(v==null?void 0:v.contains($))&&C(O,k)};return document.addEventListener("wheel",R,{passive:!1}),()=>document.removeEventListener("wheel",R,{passive:!1})},[S,v,k,C]),p.useEffect(T,[r,T]),Lr(v,I),Lr(f.content,I),u.jsx(wk,{scope:n,scrollbar:v,hasThumb:o,onThumbChange:pt(s),onThumbPointerUp:pt(i),onThumbPositionChange:T,onThumbPointerDown:pt(a),children:u.jsx(ve.div,{...m,ref:x,style:{position:"absolute",...m.style},onPointerDown:ce(e.onPointerDown,R=>{R.button===0&&(R.target.setPointerCapture(R.pointerId),y.current=v.getBoundingClientRect(),w.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",f.viewport&&(f.viewport.style.scrollBehavior="auto"),N(R))}),onPointerMove:ce(e.onPointerMove,N),onPointerUp:ce(e.onPointerUp,R=>{const O=R.target;O.hasPointerCapture(R.pointerId)&&O.releasePointerCapture(R.pointerId),document.body.style.webkitUserSelect=w.current,f.viewport&&(f.viewport.style.scrollBehavior=""),y.current=null})})})}),Js="ScrollAreaThumb",Zp=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Xp(Js,e.__scopeScrollArea);return u.jsx(Wt,{present:n||o.hasThumb,children:u.jsx(yk,{ref:t,...r})})}),yk=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=sn(Js,n),i=Xp(Js,n),{onThumbPositionChange:a}=i,l=Le(t,h=>i.onThumbChange(h)),c=p.useRef(void 0),d=ei(()=>{c.current&&(c.current(),c.current=void 0)},100);return p.useEffect(()=>{const h=s.viewport;if(h){const m=()=>{if(d(),!c.current){const f=Tk(h,a);c.current=f,a()}};return a(),h.addEventListener("scroll",m),()=>h.removeEventListener("scroll",m)}},[s.viewport,d,a]),u.jsx(ve.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:ce(e.onPointerDownCapture,h=>{const f=h.target.getBoundingClientRect(),v=h.clientX-f.left,g=h.clientY-f.top;i.onThumbPointerDown({x:v,y:g})}),onPointerUp:ce(e.onPointerUp,i.onThumbPointerUp)})});Zp.displayName=Js;var jl="ScrollAreaCorner",Qp=p.forwardRef((e,t)=>{const n=sn(jl,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?u.jsx(Sk,{...e,ref:t}):null});Qp.displayName=jl;var Sk=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=sn(jl,n),[s,i]=p.useState(0),[a,l]=p.useState(0),c=!!(s&&a);return Lr(o.scrollbarX,()=>{var h;const d=((h=o.scrollbarX)==null?void 0:h.offsetHeight)||0;o.onCornerHeightChange(d),l(d)}),Lr(o.scrollbarY,()=>{var h;const d=((h=o.scrollbarY)==null?void 0:h.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),c?u.jsx(ve.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 Zs(e){return e?parseInt(e,10):0}function em(e,t){const n=e/t;return isNaN(n)?0:n}function Qs(e){const t=em(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function Ck(e,t,n,r="ltr"){const o=Qs(n),s=o/2,i=t||s,a=o-i,l=n.scrollbar.paddingStart+i,c=n.scrollbar.size-n.scrollbar.paddingEnd-a,d=n.content-n.viewport,h=r==="ltr"?[0,d]:[d*-1,0];return nm([l,c],h)(e)}function tm(e,t,n="ltr"){const r=Qs(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=El(e,l);return nm([0,i],[0,a])(c)}function nm(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 rm(e,t){return e>0&&e<t}var Tk=(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 ei(e,t){const n=pt(e),r=p.useRef(0);return p.useEffect(()=>()=>window.clearTimeout(r.current),[]),p.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function Lr(e,t){const n=pt(t);Et(()=>{let r=0;if(e){const o=new ResizeObserver(()=>{cancelAnimationFrame(r),r=window.requestAnimationFrame(n)});return o.observe(e),()=>{window.cancelAnimationFrame(r),o.unobserve(e)}}},[e,n])}var om=Kp,kk=Gp,Ek=Qp;const _l=p.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(om,{ref:r,className:re("relative overflow-hidden",e),...n,children:[u.jsx(kk,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),u.jsx(sm,{}),u.jsx(Ek,{})]}));_l.displayName=om.displayName;const sm=p.forwardRef(({className:e,orientation:t="vertical",...n},r)=>u.jsx(Nl,{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(Zp,{className:"relative flex-1 rounded-full bg-border"})}));sm.displayName=Nl.displayName;const Pl=p.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}));Pl.displayName="Input";const Ik="group relative p-3 rounded-lg cursor-pointer transition-colors border text-gray-900 dark:text-slate-100",Nk="bg-slate-700 border-slate-600 hover:bg-slate-600",Ak="bg-slate-600 border-slate-500";function im({thread:e,isActive:t,editingThreadId:n,editingTitle:r,onSelect:o,onStartEditing:s,onEditingTitleChange:i,onSaveEditing:a,onCancelEditing:l,onShare:c,onDelete:d,showEditTitle:h,showDeleteButton:m,formatDate:f,getDisplayThreadTitle:v,secondaryLine:g,itemClassName:x,activeItemClassName:y}){const w=n===e.threadId,S=t?`${y??Ak}`:`${x??Nk}`,k=C=>{C.stopPropagation(),o(e.threadId)};return u.jsxs("div",{onClick:k,className:`${Ik} ${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(Pl,{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(Qe,{variant:"ghost",size:"sm",onClick:()=>a(e.threadId),className:"h-6 w-6 p-0",children:u.jsx(ue.Check,{size:12})}),u.jsx(Qe,{variant:"ghost",size:"sm",onClick:l,className:"h-6 w-6 p-0",children:u.jsx(ue.X,{size:12})})]}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"font-medium text-sm truncate text-gray-900 dark:text-slate-100",children:v(e)}),u.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-slate-400 mt-1",children:[u.jsx(ue.Calendar,{size:10}),u.jsx("span",{children:f(e.updatedAt||e.createdAt)})]}),g&&u.jsx("div",{className:"text-[11px] text-muted-foreground mt-1",children:g})]})}),u.jsx("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2",children:u.jsxs(Ss,{children:[u.jsx(Cs,{asChild:!0,children:u.jsx(Qe,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",children:u.jsx(ue.MoreHorizontal,{size:12})})}),u.jsxs(ho,{align:"end",sideOffset:6,className:"w-44",children:[u.jsxs(Bn,{onClick:C=>{C.preventDefault(),c(e.threadId)},children:[u.jsx(ue.Share2,{className:"mr-2 h-4 w-4"}),"Share thread"]}),h&&n!==e.threadId&&u.jsxs(Bn,{onClick:C=>{C.preventDefault(),s(e,C)},children:[u.jsx(ue.Edit3,{className:"mr-2 h-4 w-4"}),"Rename"]}),m&&d&&u.jsxs(Bn,{className:"text-red-400 hover:text-red-300",onClick:C=>{C.preventDefault(),d(e.threadId,C)},children:[u.jsx(ue.Trash2,{className:"mr-2 h-4 w-4"}),"Delete"]})]})]})})]}),t&&u.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-1 h-8 bg-blue-400 rounded-r"})]})}const am=25,lm="thread-manager-view",jk=e=>e==="default"||e==="shared",_k=()=>{if(typeof window>"u")return null;try{const e=window.localStorage.getItem(lm);if(jk(e))return e}catch{}return null};function cm({defaultView:e}={}){const[t,n]=b.useState(()=>_k()??e??"default");b.useEffect(()=>{if(!(typeof window>"u"))try{window.localStorage.setItem(lm,t)}catch{}},[t]);const r=b.useCallback(o=>{n(o)},[]);return{view:t,setView:r}}const Pk=[{key:"default",label:"My chats"},{key:"shared",label:"Shared with you"}];function ti({className:e="",showCreateButton:t=!0,showDeleteButton:n=!0,showEditTitle:r=!0,maxHeight:o="400px",customStyles:s={},currentThreadId:i=null,navigateToThread:a,onThreadSelect:l,onThreadCreate:c,onThreadDelete:d,view:h,defaultView:m,onViewChange:f,viewOptions:v,viewState:g,showHeader:x=!0,shareTargets:y,isLoadingShareTargets:w,shareTargetFilter:S}){const{threads:k,sharedThreads:C,currentThreadId:T,setCurrentThreadId:I,isLoading:N,isLoadingSharedThreads:R,actions:O,shareInFlight:$,shareStatus:V,clearShareStatus:U}=gr(),{createThread:j,deleteThread:q,renameThread:K,shareThread:D}=O,{loadThread:P}=eo(),E=i??T,[B,Y]=b.useState(Array.isArray(k)?k:[]),_=b.useRef(B.length>0),M=b.useRef(null),G=b.useRef(0),[J,se]=b.useState(null),[W,L]=b.useState(""),[X,ee]=b.useState(!1),[Z,z]=b.useState(!1),[ae,ie]=b.useState(null),[ge,we]=b.useState(""),Ae=v&&v.length>0?v:Pk,Pe=cm({defaultView:m}),ke=g??Pe,st=h??ke.view,bt=b.useCallback(Q=>{h||ke.setView(Q),f==null||f(Q)},[h,f,ke]),It=Ae.find(Q=>Q.key===st)??Ae[0],We=Q=>{ie(Q),we(""),z(!0)},ze=()=>{z(!1),ie(null),we(""),U()},Ke=b.useCallback(async Q=>{if(!(!ae||$)&&Q.id)try{await D(ae,Q.id),setTimeout(()=>ze(),600)}catch(me){console.error("Failed to share thread:",me)}},[ze,$,ae,D]),Fe=b.useMemo(()=>{const Q=y??[],me=ge.trim().toLowerCase();return me?S?Q.filter(Ze=>S(Ze,me)):Q.filter(Ze=>`${Ze.label} ${Ze.secondaryLabel??""}`.toLowerCase().includes(me)):Q},[y,ge,S]),Ue=st==="shared",ut=Ue?C:B,jt=Ue?R:N,it=Ue?"No shared conversations yet":"No conversations yet",_t=Q=>{const me=Q.sharedAt?` • ${Oe(Q.sharedAt)}`:"";return`Shared by ${Q.sharedByUserId}${me}`},yt=Q=>"sharedByUserId"in Q;b.useEffect(()=>{const Q=Array.isArray(k)?k:[];if(Q.length>0){_.current=!0,Y(Q);return}N||(_.current=!1,Y(Q))},[k,N]),b.useEffect(()=>{if(!M.current)return;const Q=M.current.querySelector("[data-radix-scroll-area-viewport]");if(!Q)return;let me=null,Ze=null;return me=requestAnimationFrame(()=>{Ze=requestAnimationFrame(()=>{Q.scrollTop=G.current})}),()=>{me!==null&&cancelAnimationFrame(me),Ze!==null&&cancelAnimationFrame(Ze)}},[B]);const gt=async Q=>{try{I(Q),await P(Q),a==null||a(Q),l==null||l(Q)}catch(me){console.error("Failed to select thread:",me)}},Nt=async()=>{try{ee(!0);const Q=await j();Q&&(c==null||c(Q),a==null||a(Q))}catch(Q){console.error("Failed to create thread:",Q)}finally{ee(!1)}},St=async(Q,me)=>{if(me.stopPropagation(),!!confirm("Delete this thread?")){if(M.current){const Ze=M.current.querySelector("[data-radix-scroll-area-viewport]");Ze&&(G.current=Ze.scrollTop)}try{await q(Q),d==null||d(Q)}catch(Ze){console.error("Failed to delete thread:",Ze)}}},Ct=(Q,me)=>{me.stopPropagation(),se(Q.threadId),L(Q.title||`Thread ${Q.threadId.slice(0,8)}`)},zt=async Q=>{if(W.trim())try{await K(Q,W.trim()),se(null),L("")}catch(me){console.error("Failed to update title:",me)}},xt=()=>{se(null),L("")},Oe=Q=>{if(!Q)return"";try{const me=new Date(Q),xe=new Date().getTime()-me.getTime(),Be=Math.floor(xe/(1e3*60*60*24));return Be===0?me.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):Be===1?"Yesterday":Be<7?`${Be} days ago`:me.toLocaleDateString()}catch{return""}},Ve=Q=>Q.title||`Thread ${Q.threadId.slice(0,8)}`,Te=Q=>{const me=Ve(Q);return me.length<=am?me:`${me.slice(0,am)}...`};return u.jsxs("div",{className:`flex flex-col h-full ${e} ${s.container||""}`,children:[x&&u.jsxs("div",{className:s.header||"flex flex-col gap-2 px-1 py-0 border border-slate-200 bg-white dark:border-slate-700 dark:bg-slate-900 shadow-sm",children:[t&&u.jsx("div",{className:"flex justify-end",children:u.jsxs(Qe,{onClick:Nt,disabled:X||N,className:s.createButton||"px-3 py-2 gap-1",size:"sm",variant:"ghost",title:X?"Creating...":"New Chat",children:[u.jsx(ue.Edit3,{size:16}),u.jsx("span",{children:"New chat"})]})}),u.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-slate-700 dark:text-slate-200 uppercase tracking-wide leading-tight",children:[u.jsx("span",{children:"Current View"}),u.jsxs(Ss,{children:[u.jsx(Cs,{asChild:!0,children:u.jsx(Qe,{variant:"outline",size:"sm",className:"text-[11px] text-slate-700 dark:text-slate-200 border border-slate-300 dark:border-slate-600 bg-white dark:bg-slate-900 hover:bg-slate-50 dark:hover:bg-slate-800 px-2 py-0",children:It.label})}),u.jsx(ho,{align:"start",sideOffset:6,className:"w-40",children:Ae.map(Q=>u.jsxs(Bn,{className:"justify-between text-[12px]",onClick:me=>{me.preventDefault(),bt(Q.key)},children:[u.jsx("span",{children:Q.label}),st===Q.key&&u.jsx(ue.Check,{className:"h-3 w-3"})]},Q.key))})]})]})]}),u.jsx(_l,{ref:M,className:`flex-1 min-h-0 ${s.threadList||""}`,style:o?{maxHeight:o}:void 0,children:u.jsx("div",{className:"p-2 space-y-1 pb-4",children:jt?u.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-8 text-slate-400",children:[u.jsx(ue.Loader2,{className:"h-5 w-5 animate-spin"}),u.jsx("span",{className:"text-sm",children:"Loading threads…"})]}):ut.length===0?u.jsxs("div",{className:"text-center py-8 text-slate-400",children:[u.jsx(ue.MessageSquare,{className:"w-8 h-8 mx-auto mb-2 opacity-40 text-slate-500"}),u.jsx("p",{className:"text-sm text-slate-500",children:it})]}):ut.slice().sort((Q,me)=>new Date(me.updatedAt||me.createdAt||"").getTime()-new Date(Q.updatedAt||Q.createdAt||"").getTime()).map(Q=>u.jsx(im,{thread:Q,isActive:E===Q.threadId,editingThreadId:J,editingTitle:W,onSelect:gt,onStartEditing:Ct,onEditingTitleChange:me=>L(me),onSaveEditing:zt,onCancelEditing:xt,onShare:()=>We(Q.threadId),onDelete:St,showEditTitle:r,showDeleteButton:n,formatDate:Oe,getDisplayThreadTitle:Te,secondaryLine:Ue&&yt(Q)?_t(Q):void 0,itemClassName:s.threadItem,activeItemClassName:s.activeThread},Q.threadId))})}),u.jsx(Qa,{open:Z,onOpenChange:Q=>!Q&&ze(),children:u.jsxs(Bs,{className:"max-w-md p-0",children:[u.jsx(zs,{children:u.jsx(Hs,{children:"Share thread"})}),u.jsxs(wl,{children:[u.jsx(yl,{autoFocus:!0,value:ge,onValueChange:Q=>we(Q),placeholder:"Search for recipients..."}),u.jsxs(Sl,{children:[V&&u.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-xs text-muted-foreground",children:[$&&u.jsx(ue.Loader2,{className:"h-3 w-3 animate-spin"}),u.jsx("span",{className:V.startsWith("Failed")?"text-red-500":V.startsWith("Shared")?"text-emerald-500":"text-slate-600 dark:text-slate-400",children:V})]}),u.jsx(Cl,{children:w?u.jsxs("span",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(ue.Loader2,{className:"h-4 w-4 animate-spin"}),"Loading recipients…"]}):"No matching recipients found"}),Fe.length>0&&u.jsx(Tl,{heading:"Recipients",children:Fe.map(Q=>u.jsx(kl,{onSelect:()=>Ke(Q),children:u.jsxs("div",{className:"flex flex-col items-start text-sm",children:[u.jsx("span",{className:"font-medium",children:Q.label}),Q.secondaryLabel&&u.jsx("span",{className:"text-xs text-muted-foreground",children:Q.secondaryLabel})]})},Q.id))})]})]})]})})]})}function Rk({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(vr,{...s,onThreadChange:l,children:u.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:u.jsx(Mr,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?u.jsx(vr,{...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(ti,{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(Mr,{onError:s.onError,enableFileUpload:!0})})]})})}):u.jsx(vr,{...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(ti,{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(Mr,{onError:s.onError,enableFileUpload:!0})})]})})}function Mk({apiConfig:e,className:t="",onError:n}){return u.jsx(vr,{apiConfig:e,onError:n,children:u.jsx("div",{className:`h-full ${t}`,children:u.jsx(Mr,{})})})}function Ok({placeholder:e,onMessageSent:t}){const[n,r]=b.useState("chat");return u.jsxs("div",{className:"flex flex-col h-full",children:[u.jsxs("div",{className:"flex border-b border-gray-200 bg-gray-50",children:[u.jsx("button",{onClick:()=>r("chat"),className:`flex-1 px-3 py-2 text-sm font-medium transition-colors ${n==="chat"?"border-b-2 border-slate-800 text-slate-800 bg-white":"text-gray-600 hover:text-gray-800"}`,children:u.jsxs("div",{className:"flex items-center justify-center gap-2",children:[u.jsx(ue.MessageSquare,{size:14}),"Chat"]})}),u.jsx("button",{onClick:()=>r("threads"),className:`flex-1 px-3 py-2 text-sm font-medium transition-colors ${n==="threads"?"border-b-2 border-slate-800 text-slate-800 bg-white":"text-gray-600 hover:text-gray-800"}`,children:u.jsxs("div",{className:"flex items-center justify-center gap-2",children:[u.jsx(ue.History,{size:14}),"History"]})})]}),u.jsx("div",{className:"flex-1 min-h-0",children:n==="chat"?u.jsx(Mr,{placeholder:e??"Ask Serti AI anything...",autoFocus:!0,className:"h-full",onMessageSent:t}):u.jsx(ti,{showCreateButton:!0,className:"h-full",onThreadSelect:()=>r("chat")})})]})}function Dk({className:e="",placeholder:t,isAuthenticated:n=!0,onMessageSent:r,widgetTitle:o="Serti AI Navigator",widgetSubtitle:s="AI-Powered Assistant",...i}){const[a,l]=b.useState(!1);return n?u.jsx(vr,{...i,children:u.jsx("div",{className:`fixed bottom-6 right-6 z-[9999] transition-all duration-300 ${e}`,children:u.jsxs("div",{className:`w-96 bg-white rounded-xl shadow-2xl border border-gray-200 overflow-hidden relative ${a?"scale-75":"scale-100"}`,children:[u.jsx("div",{className:"bg-slate-800 text-white p-4 flex-shrink-0",children:u.jsxs("div",{className:"flex items-center justify-between gap-3",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsxs("div",{className:"relative h-10 w-10 rounded-full bg-gradient-to-br from-slate-500 to-slate-700 border border-white/30 flex items-center justify-center text-white text-sm font-bold",children:["S",u.jsx("span",{className:"absolute -bottom-0.5 -right-0.5 h-3 w-3 rounded-full border-2 border-slate-800 bg-emerald-400"})]}),u.jsxs("div",{className:"flex flex-col",children:[u.jsx("h3",{className:"text-lg font-semibold leading-tight",children:o}),u.jsx("p",{className:"text-xs text-white/70",children:s})]}),u.jsx("span",{className:"ml-2 inline-flex items-center justify-center rounded-full bg-red-500 px-2 py-0.5 text-[11px] font-semibold leading-none text-white",children:"1"})]}),u.jsxs("div",{className:"flex items-center gap-1",children:[u.jsx(Qe,{variant:"ghost",size:"sm",className:"text-white hover:bg-white/10 h-8 w-8 p-0",title:"Options",children:u.jsx(ue.MoreHorizontal,{size:16})}),u.jsx(Qe,{variant:"ghost",size:"sm",className:"text-white hover:bg-white/10 h-8 w-8 p-0",title:"Compose",children:u.jsx(ue.Edit3,{size:16})}),u.jsx(Qe,{variant:"ghost",size:"sm",onClick:c=>{c.stopPropagation(),l(d=>!d)},className:"text-white hover:bg-white/10 h-8 w-8 p-0",title:a?"Maximize":"Minimize",children:a?u.jsx(ue.Maximize2,{size:14}):u.jsx(ue.Minimize2,{size:14})})]})]})}),!a&&u.jsx("div",{className:"h-96 flex flex-col",children:u.jsx(Ok,{placeholder:t,onMessageSent:r})})]})})}):null}function Lk({label:e="New chat",children:t,className:n,variant:r="ghost",size:o="sm",...s}){return u.jsxs(Qe,{variant:r,size:o,className:re("gap-2 rounded-full px-3 font-semibold transition-all hover:scale-[1.01]",n),...s,children:[u.jsx(ue.Edit3,{size:16}),t??e]})}var $k="Label",um=p.forwardRef((e,t)=>u.jsx(ve.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())}}));um.displayName=$k;var dm=um;const Fk=zr.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),fm=p.forwardRef(({className:e,...t},n)=>u.jsx(dm,{ref:n,className:re(Fk(),e),...t}));fm.displayName=dm.displayName;function hm(e){const t=p.useRef({value:e,previous:e});return p.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var pm=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"}),Bk="VisuallyHidden",ni=p.forwardRef((e,t)=>u.jsx(ve.span,{...e,ref:t,style:{...pm,...e.style}}));ni.displayName=Bk;var zk=ni,Hk=[" ","Enter","ArrowUp","ArrowDown"],Uk=[" ","Enter"],ur="Select",[ri,oi,Wk]=Yo(ur),[$r,PN]=cn(ur,[Wk,kr]),si=kr(),[Vk,Gn]=$r(ur),[Kk,qk]=$r(ur),mm=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:l,dir:c,name:d,autoComplete:h,disabled:m,required:f,form:v}=e,g=si(t),[x,y]=p.useState(null),[w,S]=p.useState(null),[k,C]=p.useState(!1),T=Xo(c),[I,N]=Dn({prop:r,defaultProp:o??!1,onChange:s,caller:ur}),[R,O]=Dn({prop:i,defaultProp:a,onChange:l,caller:ur}),$=p.useRef(null),V=x?v||!!x.closest("form"):!0,[U,j]=p.useState(new Set),q=Array.from(U).map(K=>K.props.value).join(";");return u.jsx(oa,{...g,children:u.jsxs(Vk,{required:f,scope:t,trigger:x,onTriggerChange:y,valueNode:w,onValueNodeChange:S,valueNodeHasChildren:k,onValueNodeHasChildrenChange:C,contentId:Rt(),value:R,onValueChange:O,open:I,onOpenChange:N,dir:T,triggerPointerDownPosRef:$,disabled:m,children:[u.jsx(ri.Provider,{scope:t,children:u.jsx(Kk,{scope:e.__scopeSelect,onNativeOptionAdd:p.useCallback(K=>{j(D=>new Set(D).add(K))},[]),onNativeOptionRemove:p.useCallback(K=>{j(D=>{const P=new Set(D);return P.delete(K),P})},[]),children:n})}),V?u.jsxs(Fm,{"aria-hidden":!0,required:f,tabIndex:-1,name:d,autoComplete:h,value:R,onChange:K=>O(K.target.value),disabled:m,form:v,children:[R===void 0?u.jsx("option",{value:""}):null,Array.from(U)]},q):null]})})};mm.displayName=ur;var gm="SelectTrigger",xm=p.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=si(n),i=Gn(gm,n),a=i.disabled||r,l=Le(t,i.onTriggerChange),c=oi(n),d=p.useRef("touch"),[h,m,f]=zm(g=>{const x=c().filter(S=>!S.disabled),y=x.find(S=>S.value===i.value),w=Hm(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(sa,{asChild:!0,...s,children:u.jsx(ve.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":Bm(i.value)?"":void 0,...o,ref:l,onClick:ce(o.onClick,g=>{g.currentTarget.focus(),d.current!=="mouse"&&v(g)}),onPointerDown:ce(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:ce(o.onKeyDown,g=>{const x=h.current!=="";!(g.ctrlKey||g.altKey||g.metaKey)&&g.key.length===1&&m(g.key),!(x&&g.key===" ")&&Hk.includes(g.key)&&(v(),g.preventDefault())})})})});xm.displayName=gm;var vm="SelectValue",bm=p.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=Gn(vm,n),{onValueNodeHasChildrenChange:c}=l,d=s!==void 0,h=Le(t,l.onValueNodeChange);return Et(()=>{c(d)},[c,d]),u.jsx(ve.span,{...a,ref:h,style:{pointerEvents:"none"},children:Bm(l.value)?u.jsx(u.Fragment,{children:i}):s})});bm.displayName=vm;var Gk="SelectIcon",wm=p.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return u.jsx(ve.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});wm.displayName=Gk;var Yk="SelectPortal",ym=e=>u.jsx(so,{asChild:!0,...e});ym.displayName=Yk;var dr="SelectContent",Sm=p.forwardRef((e,t)=>{const n=Gn(dr,e.__scopeSelect),[r,o]=p.useState();if(Et(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?Hr.createPortal(u.jsx(Cm,{scope:e.__scopeSelect,children:u.jsx(ri.Slot,{scope:e.__scopeSelect,children:u.jsx("div",{children:e.children})})}),s):null}return u.jsx(Tm,{...e,ref:t})});Sm.displayName=dr;var mn=10,[Cm,Yn]=$r(dr),Xk="SelectContentImpl",Jk=Yt.createSlot("SelectContent.RemoveScroll"),Tm=p.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:h,collisionBoundary:m,collisionPadding:f,sticky:v,hideWhenDetached:g,avoidCollisions:x,...y}=e,w=Gn(dr,n),[S,k]=p.useState(null),[C,T]=p.useState(null),I=Le(t,W=>k(W)),[N,R]=p.useState(null),[O,$]=p.useState(null),V=oi(n),[U,j]=p.useState(!1),q=p.useRef(!1);p.useEffect(()=>{if(S)return da(S)},[S]),Hi();const K=p.useCallback(W=>{const[L,...X]=V().map(z=>z.ref.current),[ee]=X.slice(-1),Z=document.activeElement;for(const z of W)if(z===Z||(z==null||z.scrollIntoView({block:"nearest"}),z===L&&C&&(C.scrollTop=0),z===ee&&C&&(C.scrollTop=C.scrollHeight),z==null||z.focus(),document.activeElement!==Z))return},[V,C]),D=p.useCallback(()=>K([N,S]),[K,N,S]);p.useEffect(()=>{U&&D()},[U,D]);const{onOpenChange:P,triggerPointerDownPosRef:E}=w;p.useEffect(()=>{if(S){let W={x:0,y:0};const L=ee=>{var Z,z;W={x:Math.abs(Math.round(ee.pageX)-(((Z=E.current)==null?void 0:Z.x)??0)),y:Math.abs(Math.round(ee.pageY)-(((z=E.current)==null?void 0:z.y)??0))}},X=ee=>{W.x<=10&&W.y<=10?ee.preventDefault():S.contains(ee.target)||P(!1),document.removeEventListener("pointermove",L),E.current=null};return E.current!==null&&(document.addEventListener("pointermove",L),document.addEventListener("pointerup",X,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",L),document.removeEventListener("pointerup",X,{capture:!0})}}},[S,P,E]),p.useEffect(()=>{const W=()=>P(!1);return window.addEventListener("blur",W),window.addEventListener("resize",W),()=>{window.removeEventListener("blur",W),window.removeEventListener("resize",W)}},[P]);const[B,Y]=zm(W=>{const L=V().filter(Z=>!Z.disabled),X=L.find(Z=>Z.ref.current===document.activeElement),ee=Hm(L,W,X);ee&&setTimeout(()=>ee.ref.current.focus())}),_=p.useCallback((W,L,X)=>{const ee=!q.current&&!X;(w.value!==void 0&&w.value===L||ee)&&(R(W),ee&&(q.current=!0))},[w.value]),M=p.useCallback(()=>S==null?void 0:S.focus(),[S]),G=p.useCallback((W,L,X)=>{const ee=!q.current&&!X;(w.value!==void 0&&w.value===L||ee)&&$(W)},[w.value]),J=r==="popper"?Rl:km,se=J===Rl?{side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:h,collisionBoundary:m,collisionPadding:f,sticky:v,hideWhenDetached:g,avoidCollisions:x}:{};return u.jsx(Cm,{scope:n,content:S,viewport:C,onViewportChange:T,itemRefCallback:_,selectedItem:N,onItemLeave:M,itemTextRefCallback:G,focusSelectedItem:D,selectedItemText:O,position:r,isPositioned:U,searchRef:B,children:u.jsx(gs,{as:Jk,allowPinchZoom:!0,children:u.jsx(Jo,{asChild:!0,trapped:w.open,onMountAutoFocus:W=>{W.preventDefault()},onUnmountAutoFocus:ce(o,W=>{var L;(L=w.trigger)==null||L.focus({preventScroll:!0}),W.preventDefault()}),children:u.jsx(wr,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:W=>W.preventDefault(),onDismiss:()=>w.onOpenChange(!1),children:u.jsx(J,{role:"listbox",id:w.contentId,"data-state":w.open?"open":"closed",dir:w.dir,onContextMenu:W=>W.preventDefault(),...y,...se,onPlaced:()=>j(!0),ref:I,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:ce(y.onKeyDown,W=>{const L=W.ctrlKey||W.altKey||W.metaKey;if(W.key==="Tab"&&W.preventDefault(),!L&&W.key.length===1&&Y(W.key),["ArrowUp","ArrowDown","Home","End"].includes(W.key)){let ee=V().filter(Z=>!Z.disabled).map(Z=>Z.ref.current);if(["ArrowUp","End"].includes(W.key)&&(ee=ee.slice().reverse()),["ArrowUp","ArrowDown"].includes(W.key)){const Z=W.target,z=ee.indexOf(Z);ee=ee.slice(z+1)}setTimeout(()=>K(ee)),W.preventDefault()}})})})})})})});Tm.displayName=Xk;var Zk="SelectItemAlignedPosition",km=p.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=Gn(dr,n),i=Yn(dr,n),[a,l]=p.useState(null),[c,d]=p.useState(null),h=Le(t,I=>d(I)),m=oi(n),f=p.useRef(!1),v=p.useRef(!0),{viewport:g,selectedItem:x,selectedItemText:y,focusSelectedItem:w}=i,S=p.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&c&&g&&x&&y){const I=s.trigger.getBoundingClientRect(),N=c.getBoundingClientRect(),R=s.valueNode.getBoundingClientRect(),O=y.getBoundingClientRect();if(s.dir!=="rtl"){const Z=O.left-N.left,z=R.left-Z,ae=I.left-z,ie=I.width+ae,ge=Math.max(ie,N.width),we=window.innerWidth-mn,Ae=El(z,[mn,Math.max(mn,we-ge)]);a.style.minWidth=ie+"px",a.style.left=Ae+"px"}else{const Z=N.right-O.right,z=window.innerWidth-R.right-Z,ae=window.innerWidth-I.right-z,ie=I.width+ae,ge=Math.max(ie,N.width),we=window.innerWidth-mn,Ae=El(z,[mn,Math.max(mn,we-ge)]);a.style.minWidth=ie+"px",a.style.right=Ae+"px"}const $=m(),V=window.innerHeight-mn*2,U=g.scrollHeight,j=window.getComputedStyle(c),q=parseInt(j.borderTopWidth,10),K=parseInt(j.paddingTop,10),D=parseInt(j.borderBottomWidth,10),P=parseInt(j.paddingBottom,10),E=q+K+U+P+D,B=Math.min(x.offsetHeight*5,E),Y=window.getComputedStyle(g),_=parseInt(Y.paddingTop,10),M=parseInt(Y.paddingBottom,10),G=I.top+I.height/2-mn,J=V-G,se=x.offsetHeight/2,W=x.offsetTop+se,L=q+K+W,X=E-L;if(L<=G){const Z=$.length>0&&x===$[$.length-1].ref.current;a.style.bottom="0px";const z=c.clientHeight-g.offsetTop-g.offsetHeight,ae=Math.max(J,se+(Z?M:0)+z+D),ie=L+ae;a.style.height=ie+"px"}else{const Z=$.length>0&&x===$[0].ref.current;a.style.top="0px";const ae=Math.max(G,q+g.offsetTop+(Z?_:0)+se)+X;a.style.height=ae+"px",g.scrollTop=L-G+g.offsetTop}a.style.margin=`${mn}px 0`,a.style.minHeight=B+"px",a.style.maxHeight=V+"px",r==null||r(),requestAnimationFrame(()=>f.current=!0)}},[m,s.trigger,s.valueNode,a,c,g,x,y,s.dir,r]);Et(()=>S(),[S]);const[k,C]=p.useState();Et(()=>{c&&C(window.getComputedStyle(c).zIndex)},[c]);const T=p.useCallback(I=>{I&&v.current===!0&&(S(),w==null||w(),v.current=!1)},[S,w]);return u.jsx(eE,{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(ve.div,{...o,ref:h,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});km.displayName=Zk;var Qk="SelectPopperPosition",Rl=p.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=mn,...s}=e,i=si(n);return u.jsx(ia,{...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)"}})});Rl.displayName=Qk;var[eE,Ml]=$r(dr,{}),Ol="SelectViewport",Em=p.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=Yn(Ol,n),i=Ml(Ol,n),a=Le(t,s.onViewportChange),l=p.useRef(0);return u.jsxs(u.Fragment,{children:[u.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),u.jsx(ri.Slot,{scope:n,children:u.jsx(ve.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:ce(o.onScroll,c=>{const d=c.currentTarget,{contentWrapper:h,shouldExpandOnScrollRef:m}=i;if(m!=null&&m.current&&h){const f=Math.abs(l.current-d.scrollTop);if(f>0){const v=window.innerHeight-mn*2,g=parseFloat(h.style.minHeight),x=parseFloat(h.style.height),y=Math.max(g,x);if(y<v){const w=y+f,S=Math.min(v,w),k=w-S;h.style.height=S+"px",h.style.bottom==="0px"&&(d.scrollTop=k>0?k:0,h.style.justifyContent="flex-end")}}}l.current=d.scrollTop})})})]})});Em.displayName=Ol;var Im="SelectGroup",[tE,nE]=$r(Im),rE=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Rt();return u.jsx(tE,{scope:n,id:o,children:u.jsx(ve.div,{role:"group","aria-labelledby":o,...r,ref:t})})});rE.displayName=Im;var Nm="SelectLabel",Am=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=nE(Nm,n);return u.jsx(ve.div,{id:o.id,...r,ref:t})});Am.displayName=Nm;var ii="SelectItem",[oE,jm]=$r(ii),_m=p.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=Gn(ii,n),l=Yn(ii,n),c=a.value===r,[d,h]=p.useState(s??""),[m,f]=p.useState(!1),v=Le(t,w=>{var S;return(S=l.itemRefCallback)==null?void 0:S.call(l,w,r,o)}),g=Rt(),x=p.useRef("touch"),y=()=>{o||(a.onValueChange(r),a.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return u.jsx(oE,{scope:n,value:r,disabled:o,textId:g,isSelected:c,onItemTextChange:p.useCallback(w=>{h(S=>S||((w==null?void 0:w.textContent)??"").trim())},[]),children:u.jsx(ri.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:u.jsx(ve.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:ce(i.onFocus,()=>f(!0)),onBlur:ce(i.onBlur,()=>f(!1)),onClick:ce(i.onClick,()=>{x.current!=="mouse"&&y()}),onPointerUp:ce(i.onPointerUp,()=>{x.current==="mouse"&&y()}),onPointerDown:ce(i.onPointerDown,w=>{x.current=w.pointerType}),onPointerMove:ce(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:ce(i.onPointerLeave,w=>{var S;w.currentTarget===document.activeElement&&((S=l.onItemLeave)==null||S.call(l))}),onKeyDown:ce(i.onKeyDown,w=>{var k;((k=l.searchRef)==null?void 0:k.current)!==""&&w.key===" "||(Uk.includes(w.key)&&y(),w.key===" "&&w.preventDefault())})})})})});_m.displayName=ii;var Ao="SelectItemText",Pm=p.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=Gn(Ao,n),a=Yn(Ao,n),l=jm(Ao,n),c=qk(Ao,n),[d,h]=p.useState(null),m=Le(t,y=>h(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=p.useMemo(()=>u.jsx("option",{value:l.value,disabled:l.disabled,children:f},l.value),[l.disabled,l.value,f]),{onNativeOptionAdd:g,onNativeOptionRemove:x}=c;return Et(()=>(g(v),()=>x(v)),[g,x,v]),u.jsxs(u.Fragment,{children:[u.jsx(ve.span,{id:l.textId,...s,ref:m}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?Hr.createPortal(s.children,i.valueNode):null]})});Pm.displayName=Ao;var Rm="SelectItemIndicator",Mm=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return jm(Rm,n).isSelected?u.jsx(ve.span,{"aria-hidden":!0,...r,ref:t}):null});Mm.displayName=Rm;var Dl="SelectScrollUpButton",Om=p.forwardRef((e,t)=>{const n=Yn(Dl,e.__scopeSelect),r=Ml(Dl,e.__scopeSelect),[o,s]=p.useState(!1),i=Le(t,r.onScrollButtonChange);return Et(()=>{if(n.viewport&&n.isPositioned){let a=function(){const c=l.scrollTop>0;s(c)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?u.jsx(Lm,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});Om.displayName=Dl;var Ll="SelectScrollDownButton",Dm=p.forwardRef((e,t)=>{const n=Yn(Ll,e.__scopeSelect),r=Ml(Ll,e.__scopeSelect),[o,s]=p.useState(!1),i=Le(t,r.onScrollButtonChange);return Et(()=>{if(n.viewport&&n.isPositioned){let a=function(){const c=l.scrollHeight-l.clientHeight,d=Math.ceil(l.scrollTop)<c;s(d)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?u.jsx(Lm,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});Dm.displayName=Ll;var Lm=p.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=Yn("SelectScrollButton",n),i=p.useRef(null),a=oi(n),l=p.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return p.useEffect(()=>()=>l(),[l]),Et(()=>{var d;const c=a().find(h=>h.ref.current===document.activeElement);(d=c==null?void 0:c.ref.current)==null||d.scrollIntoView({block:"nearest"})},[a]),u.jsx(ve.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:ce(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:ce(o.onPointerMove,()=>{var c;(c=s.onItemLeave)==null||c.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:ce(o.onPointerLeave,()=>{l()})})}),sE="SelectSeparator",$m=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return u.jsx(ve.div,{"aria-hidden":!0,...r,ref:t})});$m.displayName=sE;var $l="SelectArrow",iE=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=si(n),s=Gn($l,n),i=Yn($l,n);return s.open&&i.position==="popper"?u.jsx(aa,{...o,...r,ref:t}):null});iE.displayName=$l;var aE="SelectBubbleInput",Fm=p.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=p.useRef(null),s=Le(r,o),i=hm(t);return p.useEffect(()=>{const a=o.current;if(!a)return;const l=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(l,"value").set;if(i!==t&&d){const h=new Event("change",{bubbles:!0});d.call(a,t),a.dispatchEvent(h)}},[i,t]),u.jsx(ve.select,{...n,style:{...pm,...n.style},ref:s,defaultValue:t})});Fm.displayName=aE;function Bm(e){return e===""||e===void 0}function zm(e){const t=pt(e),n=p.useRef(""),r=p.useRef(0),o=p.useCallback(i=>{const a=n.current+i;t(a),function l(c){n.current=c,window.clearTimeout(r.current),c!==""&&(r.current=window.setTimeout(()=>l(""),1e3))}(a)},[t]),s=p.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return p.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function Hm(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=lE(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 lE(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var cE=mm,Um=xm,uE=bm,dE=wm,fE=ym,Wm=Sm,hE=Em,Vm=Am,Km=_m,pE=Pm,mE=Mm,qm=Om,Gm=Dm,Ym=$m;const gE=cE,xE=uE,Xm=p.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Um,{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(dE,{asChild:!0,children:u.jsx(ue.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));Xm.displayName=Um.displayName;const Jm=p.forwardRef(({className:e,...t},n)=>u.jsx(qm,{ref:n,className:re("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(ue.ChevronUp,{className:"h-4 w-4"})}));Jm.displayName=qm.displayName;const Zm=p.forwardRef(({className:e,...t},n)=>u.jsx(Gm,{ref:n,className:re("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(ue.ChevronDown,{className:"h-4 w-4"})}));Zm.displayName=Gm.displayName;const Qm=p.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>u.jsx(fE,{children:u.jsxs(Wm,{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(Jm,{}),u.jsx(hE,{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(Zm,{})]})}));Qm.displayName=Wm.displayName;const vE=p.forwardRef(({className:e,...t},n)=>u.jsx(Vm,{ref:n,className:re("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));vE.displayName=Vm.displayName;const eg=p.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(mE,{children:u.jsx(ue.Check,{className:"h-4 w-4"})})}),u.jsx(pE,{children:t})]}));eg.displayName=Km.displayName;const bE=p.forwardRef(({className:e,...t},n)=>u.jsx(Ym,{ref:n,className:re("-mx-1 my-1 h-px bg-muted",e),...t}));bE.displayName=Ym.displayName;var wE="Separator",tg="horizontal",yE=["horizontal","vertical"],ng=p.forwardRef((e,t)=>{const{decorative:n,orientation:r=tg,...o}=e,s=SE(r)?r:tg,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return u.jsx(ve.div,{"data-orientation":s,...a,...o,ref:t})});ng.displayName=wE;function SE(e){return yE.includes(e)}var rg=ng;const og=p.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>u.jsx(rg,{ref:o,decorative:n,orientation:t,className:re("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));og.displayName=rg.displayName;var ai="Switch",[CE,RN]=cn(ai),[TE,kE]=CE(ai),sg=p.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:s,required:i,disabled:a,value:l="on",onCheckedChange:c,form:d,...h}=e,[m,f]=p.useState(null),v=Le(t,S=>f(S)),g=p.useRef(!1),x=m?d||!!m.closest("form"):!0,[y,w]=Dn({prop:o,defaultProp:s??!1,onChange:c,caller:ai});return u.jsxs(TE,{scope:n,checked:y,disabled:a,children:[u.jsx(ve.button,{type:"button",role:"switch","aria-checked":y,"aria-required":i,"data-state":cg(y),"data-disabled":a?"":void 0,disabled:a,value:l,...h,ref:v,onClick:ce(e.onClick,S=>{w(k=>!k),x&&(g.current=S.isPropagationStopped(),g.current||S.stopPropagation())})}),x&&u.jsx(lg,{control:m,bubbles:!g.current,name:r,value:l,checked:y,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});sg.displayName=ai;var ig="SwitchThumb",ag=p.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=kE(ig,n);return u.jsx(ve.span,{"data-state":cg(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});ag.displayName=ig;var EE="SwitchBubbleInput",lg=p.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=p.useRef(null),a=Le(i,s),l=hm(n),c=vd(t);return p.useEffect(()=>{const d=i.current;if(!d)return;const h=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(h,"checked").set;if(l!==n&&f){const v=new Event("click",{bubbles:r});f.call(d,n),d.dispatchEvent(v)}},[l,n,r]),u.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:a,style:{...o.style,...c,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});lg.displayName=EE;function cg(e){return e?"checked":"unchecked"}var ug=sg,IE=ag;const dg=p.forwardRef(({className:e,...t},n)=>u.jsx(ug,{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(IE,{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")})}));dg.displayName=ug.displayName;const NE=Ja,AE=aT,jE=Za,fg=p.forwardRef(({className:e,...t},n)=>u.jsx(To,{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}));fg.displayName=To.displayName;const _E=zr.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"}}),hg=p.forwardRef(({side:e="right",className:t,children:n,...r},o)=>u.jsxs(jE,{children:[u.jsx(fg,{}),u.jsxs(ko,{ref:o,className:re(_E({side:e}),t),...r,children:[n,u.jsxs(rp,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary",children:[u.jsx(ue.X,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));hg.displayName=ko.displayName;const pg=({className:e,...t})=>u.jsx("div",{className:re("flex flex-col space-y-2 text-center sm:text-left",e),...t});pg.displayName="SheetHeader";const mg=p.forwardRef(({className:e,...t},n)=>u.jsx(ar,{ref:n,className:re("text-lg font-semibold text-foreground",e),...t}));mg.displayName=ar.displayName;const gg=p.forwardRef(({className:e,...t},n)=>u.jsx(Fs,{ref:n,className:re("text-sm text-muted-foreground",e),...t}));gg.displayName=Fs.displayName;var[li,MN]=cn("Tooltip",[kr]),ci=kr(),xg="TooltipProvider",PE=700,Fl="tooltip.open",[RE,Bl]=li(xg),vg=e=>{const{__scopeTooltip:t,delayDuration:n=PE,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:s}=e,i=p.useRef(!0),a=p.useRef(!1),l=p.useRef(0);return p.useEffect(()=>{const c=l.current;return()=>window.clearTimeout(c)},[]),u.jsx(RE,{scope:t,isOpenDelayedRef:i,delayDuration:n,onOpen:p.useCallback(()=>{window.clearTimeout(l.current),i.current=!1},[]),onClose:p.useCallback(()=>{window.clearTimeout(l.current),l.current=window.setTimeout(()=>i.current=!0,r)},[r]),isPointerInTransitRef:a,onPointerInTransitChange:p.useCallback(c=>{a.current=c},[]),disableHoverableContent:o,children:s})};vg.displayName=xg;var jo="Tooltip",[ME,ui]=li(jo),bg=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:s,disableHoverableContent:i,delayDuration:a}=e,l=Bl(jo,e.__scopeTooltip),c=ci(t),[d,h]=p.useState(null),m=Rt(),f=p.useRef(0),v=i??l.disableHoverableContent,g=a??l.delayDuration,x=p.useRef(!1),[y,w]=Dn({prop:r,defaultProp:o??!1,onChange:I=>{I?(l.onOpen(),document.dispatchEvent(new CustomEvent(Fl))):l.onClose(),s==null||s(I)},caller:jo}),S=p.useMemo(()=>y?x.current?"delayed-open":"instant-open":"closed",[y]),k=p.useCallback(()=>{window.clearTimeout(f.current),f.current=0,x.current=!1,w(!0)},[w]),C=p.useCallback(()=>{window.clearTimeout(f.current),f.current=0,w(!1)},[w]),T=p.useCallback(()=>{window.clearTimeout(f.current),f.current=window.setTimeout(()=>{x.current=!0,w(!0),f.current=0},g)},[g,w]);return p.useEffect(()=>()=>{f.current&&(window.clearTimeout(f.current),f.current=0)},[]),u.jsx(oa,{...c,children:u.jsx(ME,{scope:t,contentId:m,open:y,stateAttribute:S,trigger:d,onTriggerChange:h,onTriggerEnter:p.useCallback(()=>{l.isOpenDelayedRef.current?T():k()},[l.isOpenDelayedRef,T,k]),onTriggerLeave:p.useCallback(()=>{v?C():(window.clearTimeout(f.current),f.current=0)},[C,v]),onOpen:k,onClose:C,disableHoverableContent:v,children:n})})};bg.displayName=jo;var zl="TooltipTrigger",wg=p.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=ui(zl,n),s=Bl(zl,n),i=ci(n),a=p.useRef(null),l=Le(t,a,o.onTriggerChange),c=p.useRef(!1),d=p.useRef(!1),h=p.useCallback(()=>c.current=!1,[]);return p.useEffect(()=>()=>document.removeEventListener("pointerup",h),[h]),u.jsx(sa,{asChild:!0,...i,children:u.jsx(ve.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:l,onPointerMove:ce(e.onPointerMove,m=>{m.pointerType!=="touch"&&!d.current&&!s.isPointerInTransitRef.current&&(o.onTriggerEnter(),d.current=!0)}),onPointerLeave:ce(e.onPointerLeave,()=>{o.onTriggerLeave(),d.current=!1}),onPointerDown:ce(e.onPointerDown,()=>{o.open&&o.onClose(),c.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:ce(e.onFocus,()=>{c.current||o.onOpen()}),onBlur:ce(e.onBlur,o.onClose),onClick:ce(e.onClick,o.onClose)})})});wg.displayName=zl;var OE="TooltipPortal",[ON,DE]=li(OE,{forceMount:void 0}),Fr="TooltipContent",yg=p.forwardRef((e,t)=>{const n=DE(Fr,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...s}=e,i=ui(Fr,e.__scopeTooltip);return u.jsx(Wt,{present:r||i.open,children:i.disableHoverableContent?u.jsx(Sg,{side:o,...s,ref:t}):u.jsx(LE,{side:o,...s,ref:t})})}),LE=p.forwardRef((e,t)=>{const n=ui(Fr,e.__scopeTooltip),r=Bl(Fr,e.__scopeTooltip),o=p.useRef(null),s=Le(t,o),[i,a]=p.useState(null),{trigger:l,onClose:c}=n,d=o.current,{onPointerInTransitChange:h}=r,m=p.useCallback(()=>{a(null),h(!1)},[h]),f=p.useCallback((v,g)=>{const x=v.currentTarget,y={x:v.clientX,y:v.clientY},w=HE(y,x.getBoundingClientRect()),S=UE(y,w),k=WE(g.getBoundingClientRect()),C=KE([...S,...k]);a(C),h(!0)},[h]);return p.useEffect(()=>()=>m(),[m]),p.useEffect(()=>{if(l&&d){const v=x=>f(x,d),g=x=>f(x,l);return l.addEventListener("pointerleave",v),d.addEventListener("pointerleave",g),()=>{l.removeEventListener("pointerleave",v),d.removeEventListener("pointerleave",g)}}},[l,d,f,m]),p.useEffect(()=>{if(i){const v=g=>{const x=g.target,y={x:g.clientX,y:g.clientY},w=(l==null?void 0:l.contains(x))||(d==null?void 0:d.contains(x)),S=!VE(y,i);w?m():S&&(m(),c())};return document.addEventListener("pointermove",v),()=>document.removeEventListener("pointermove",v)}},[l,d,i,c,m]),u.jsx(Sg,{...e,ref:s})}),[$E,FE]=li(jo,{isInside:!1}),BE=Yt.createSlottable("TooltipContent"),Sg=p.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:s,onPointerDownOutside:i,...a}=e,l=ui(Fr,n),c=ci(n),{onClose:d}=l;return p.useEffect(()=>(document.addEventListener(Fl,d),()=>document.removeEventListener(Fl,d)),[d]),p.useEffect(()=>{if(l.trigger){const h=m=>{const f=m.target;f!=null&&f.contains(l.trigger)&&d()};return window.addEventListener("scroll",h,{capture:!0}),()=>window.removeEventListener("scroll",h,{capture:!0})}},[l.trigger,d]),u.jsx(wr,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:h=>h.preventDefault(),onDismiss:d,children:u.jsxs(ia,{"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(BE,{children:r}),u.jsx($E,{scope:n,isInside:!0,children:u.jsx(zk,{id:l.contentId,role:"tooltip",children:o||r})})]})})});yg.displayName=Fr;var Cg="TooltipArrow",zE=p.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=ci(n);return FE(Cg,n).isInside?null:u.jsx(aa,{...o,...r,ref:t})});zE.displayName=Cg;function HE(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 UE(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 WE(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 VE(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const a=t[s],l=t[i],c=a.x,d=a.y,h=l.x,m=l.y;d>r!=m>r&&n<(h-c)*(r-d)/(m-d)+c&&(o=!o)}return o}function KE(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),qE(t)}function qE(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const o=e[r];for(;t.length>=2;){const s=t[t.length-1],i=t[t.length-2];if((s.x-i.x)*(o.y-i.y)>=(s.y-i.y)*(o.x-i.x))t.pop();else break}t.push(o)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const o=e[r];for(;n.length>=2;){const s=n[n.length-1],i=n[n.length-2];if((s.x-i.x)*(o.y-i.y)>=(s.y-i.y)*(o.x-i.x))n.pop();else break}n.push(o)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var GE=vg,YE=bg,XE=wg,Tg=yg;const JE=GE,ZE=YE,QE=XE,kg=p.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(Tg,{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}));kg.displayName=Tg.displayName;var Hl="ToastProvider",[Ul,eI,tI]=Yo("Toast"),[Eg,DN]=cn("Toast",[tI]),[nI,di]=Eg(Hl),Ig=e=>{const{__scopeToast:t,label:n="Notification",duration:r=5e3,swipeDirection:o="right",swipeThreshold:s=50,children:i}=e,[a,l]=p.useState(null),[c,d]=p.useState(0),h=p.useRef(!1),m=p.useRef(!1);return n.trim()||console.error(`Invalid prop \`label\` supplied to \`${Hl}\`. Expected non-empty \`string\`.`),u.jsx(Ul.Provider,{scope:t,children:u.jsx(nI,{scope:t,label:n,duration:r,swipeDirection:o,swipeThreshold:s,toastCount:c,viewport:a,onViewportChange:l,onToastAdd:p.useCallback(()=>d(f=>f+1),[]),onToastRemove:p.useCallback(()=>d(f=>f-1),[]),isFocusedToastEscapeKeyDownRef:h,isClosePausedRef:m,children:i})})};Ig.displayName=Hl;var Ng="ToastViewport",rI=["F8"],Wl="toast.viewportPause",Vl="toast.viewportResume",Ag=p.forwardRef((e,t)=>{const{__scopeToast:n,hotkey:r=rI,label:o="Notifications ({hotkey})",...s}=e,i=di(Ng,n),a=eI(n),l=p.useRef(null),c=p.useRef(null),d=p.useRef(null),h=p.useRef(null),m=Le(t,h,i.onViewportChange),f=r.join("+").replace(/Key/g,"").replace(/Digit/g,""),v=i.toastCount>0;p.useEffect(()=>{const x=y=>{var S;r.length!==0&&r.every(k=>y[k]||y.code===k)&&((S=h.current)==null||S.focus())};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[r]),p.useEffect(()=>{const x=l.current,y=h.current;if(v&&x&&y){const w=()=>{if(!i.isClosePausedRef.current){const T=new CustomEvent(Wl);y.dispatchEvent(T),i.isClosePausedRef.current=!0}},S=()=>{if(i.isClosePausedRef.current){const T=new CustomEvent(Vl);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=p.useCallback(({tabbingDirection:x})=>{const w=a().map(S=>{const k=S.ref.current,C=[k,...gI(k)];return x==="forwards"?C:C.reverse()});return(x==="forwards"?w.reverse():w).flat()},[a]);return p.useEffect(()=>{const x=h.current;if(x){const y=w=>{var C,T,I;const S=w.altKey||w.ctrlKey||w.metaKey;if(w.key==="Tab"&&!S){const N=document.activeElement,R=w.shiftKey;if(w.target===x&&R){(C=c.current)==null||C.focus();return}const V=g({tabbingDirection:R?"backwards":"forwards"}),U=V.findIndex(j=>j===N);Gl(V.slice(U+1))?w.preventDefault():R?(T=c.current)==null||T.focus():(I=d.current)==null||I.focus()}};return x.addEventListener("keydown",y),()=>x.removeEventListener("keydown",y)}},[a,g]),u.jsxs(Db,{ref:l,role:"region","aria-label":o.replace("{hotkey}",f),tabIndex:-1,style:{pointerEvents:v?void 0:"none"},children:[v&&u.jsx(Kl,{ref:c,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"forwards"});Gl(x)}}),u.jsx(Ul.Slot,{scope:n,children:u.jsx(ve.ol,{tabIndex:-1,...s,ref:m})}),v&&u.jsx(Kl,{ref:d,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"backwards"});Gl(x)}})]})});Ag.displayName=Ng;var jg="ToastFocusProxy",Kl=p.forwardRef((e,t)=>{const{__scopeToast:n,onFocusFromOutsideViewport:r,...o}=e,s=di(jg,n);return u.jsx(ni,{tabIndex:0,...o,ref:t,style:{position:"fixed"},onFocus:i=>{var c;const a=i.relatedTarget;!((c=s.viewport)!=null&&c.contains(a))&&r()}})});Kl.displayName=jg;var _o="Toast",oI="toast.swipeStart",sI="toast.swipeMove",iI="toast.swipeCancel",aI="toast.swipeEnd",_g=p.forwardRef((e,t)=>{const{forceMount:n,open:r,defaultOpen:o,onOpenChange:s,...i}=e,[a,l]=Dn({prop:r,defaultProp:o??!0,onChange:s,caller:_o});return u.jsx(Wt,{present:n||a,children:u.jsx(uI,{open:a,...i,ref:t,onClose:()=>l(!1),onPause:pt(e.onPause),onResume:pt(e.onResume),onSwipeStart:ce(e.onSwipeStart,c=>{c.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:ce(e.onSwipeMove,c=>{const{x:d,y:h}=c.detail.delta;c.currentTarget.setAttribute("data-swipe","move"),c.currentTarget.style.setProperty("--radix-toast-swipe-move-x",`${d}px`),c.currentTarget.style.setProperty("--radix-toast-swipe-move-y",`${h}px`)}),onSwipeCancel:ce(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:ce(e.onSwipeEnd,c=>{const{x:d,y:h}=c.detail.delta;c.currentTarget.setAttribute("data-swipe","end"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),c.currentTarget.style.setProperty("--radix-toast-swipe-end-x",`${d}px`),c.currentTarget.style.setProperty("--radix-toast-swipe-end-y",`${h}px`),l(!1)})})})});_g.displayName=_o;var[lI,cI]=Eg(_o,{onClose(){}}),uI=p.forwardRef((e,t)=>{const{__scopeToast:n,type:r="foreground",duration:o,open:s,onClose:i,onEscapeKeyDown:a,onPause:l,onResume:c,onSwipeStart:d,onSwipeMove:h,onSwipeCancel:m,onSwipeEnd:f,...v}=e,g=di(_o,n),[x,y]=p.useState(null),w=Le(t,j=>y(j)),S=p.useRef(null),k=p.useRef(null),C=o||g.duration,T=p.useRef(0),I=p.useRef(C),N=p.useRef(0),{onToastAdd:R,onToastRemove:O}=g,$=pt(()=>{var q;(x==null?void 0:x.contains(document.activeElement))&&((q=g.viewport)==null||q.focus()),i()}),V=p.useCallback(j=>{!j||j===1/0||(window.clearTimeout(N.current),T.current=new Date().getTime(),N.current=window.setTimeout($,j))},[$]);p.useEffect(()=>{const j=g.viewport;if(j){const q=()=>{V(I.current),c==null||c()},K=()=>{const D=new Date().getTime()-T.current;I.current=I.current-D,window.clearTimeout(N.current),l==null||l()};return j.addEventListener(Wl,K),j.addEventListener(Vl,q),()=>{j.removeEventListener(Wl,K),j.removeEventListener(Vl,q)}}},[g.viewport,C,l,c,V]),p.useEffect(()=>{s&&!g.isClosePausedRef.current&&V(C)},[s,C,g.isClosePausedRef,V]),p.useEffect(()=>(R(),()=>O()),[R,O]);const U=p.useMemo(()=>x?$g(x):null,[x]);return g.viewport?u.jsxs(u.Fragment,{children:[U&&u.jsx(dI,{__scopeToast:n,role:"status","aria-live":r==="foreground"?"assertive":"polite",children:U}),u.jsx(lI,{scope:n,onClose:$,children:Hr.createPortal(u.jsx(Ul.ItemSlot,{scope:n,children:u.jsx(Ob,{asChild:!0,onEscapeKeyDown:ce(a,()=>{g.isFocusedToastEscapeKeyDownRef.current||$(),g.isFocusedToastEscapeKeyDownRef.current=!1}),children:u.jsx(ve.li,{tabIndex:0,"data-state":s?"open":"closed","data-swipe-direction":g.swipeDirection,...v,ref:w,style:{userSelect:"none",touchAction:"none",...e.style},onKeyDown:ce(e.onKeyDown,j=>{j.key==="Escape"&&(a==null||a(j.nativeEvent),j.nativeEvent.defaultPrevented||(g.isFocusedToastEscapeKeyDownRef.current=!0,$()))}),onPointerDown:ce(e.onPointerDown,j=>{j.button===0&&(S.current={x:j.clientX,y:j.clientY})}),onPointerMove:ce(e.onPointerMove,j=>{if(!S.current)return;const q=j.clientX-S.current.x,K=j.clientY-S.current.y,D=!!k.current,P=["left","right"].includes(g.swipeDirection),E=["left","up"].includes(g.swipeDirection)?Math.min:Math.max,B=P?E(0,q):0,Y=P?0:E(0,K),_=j.pointerType==="touch"?10:2,M={x:B,y:Y},G={originalEvent:j,delta:M};D?(k.current=M,fi(sI,h,G,{discrete:!1})):Fg(M,g.swipeDirection,_)?(k.current=M,fi(oI,d,G,{discrete:!1}),j.target.setPointerCapture(j.pointerId)):(Math.abs(q)>_||Math.abs(K)>_)&&(S.current=null)}),onPointerUp:ce(e.onPointerUp,j=>{const q=k.current,K=j.target;if(K.hasPointerCapture(j.pointerId)&&K.releasePointerCapture(j.pointerId),k.current=null,S.current=null,q){const D=j.currentTarget,P={originalEvent:j,delta:q};Fg(q,g.swipeDirection,g.swipeThreshold)?fi(aI,f,P,{discrete:!0}):fi(iI,m,P,{discrete:!0}),D.addEventListener("click",E=>E.preventDefault(),{once:!0})}})})})}),g.viewport)})]}):null}),dI=e=>{const{__scopeToast:t,children:n,...r}=e,o=di(_o,t),[s,i]=p.useState(!1),[a,l]=p.useState(!1);return pI(()=>i(!0)),p.useEffect(()=>{const c=window.setTimeout(()=>l(!0),1e3);return()=>window.clearTimeout(c)},[]),a?null:u.jsx(so,{asChild:!0,children:u.jsx(ni,{...r,children:s&&u.jsxs(u.Fragment,{children:[o.label," ",n]})})})},fI="ToastTitle",Pg=p.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(ve.div,{...r,ref:t})});Pg.displayName=fI;var hI="ToastDescription",Rg=p.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(ve.div,{...r,ref:t})});Rg.displayName=hI;var Mg="ToastAction",Og=p.forwardRef((e,t)=>{const{altText:n,...r}=e;return n.trim()?u.jsx(Lg,{altText:n,asChild:!0,children:u.jsx(ql,{...r,ref:t})}):(console.error(`Invalid prop \`altText\` supplied to \`${Mg}\`. Expected non-empty \`string\`.`),null)});Og.displayName=Mg;var Dg="ToastClose",ql=p.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e,o=cI(Dg,n);return u.jsx(Lg,{asChild:!0,children:u.jsx(ve.button,{type:"button",...r,ref:t,onClick:ce(e.onClick,o.onClose)})})});ql.displayName=Dg;var Lg=p.forwardRef((e,t)=>{const{__scopeToast:n,altText:r,...o}=e;return u.jsx(ve.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":r||void 0,...o,ref:t})});function $g(e){const t=[];return Array.from(e.childNodes).forEach(r=>{if(r.nodeType===r.TEXT_NODE&&r.textContent&&t.push(r.textContent),mI(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(...$g(r))}}),t}function fi(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?Fi(o,s):o.dispatchEvent(s)}var Fg=(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 pI(e=()=>{}){const t=pt(e);Et(()=>{let n=0,r=0;return n=window.requestAnimationFrame(()=>r=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(n),window.cancelAnimationFrame(r)}},[t])}function mI(e){return e.nodeType===e.ELEMENT_NODE}function gI(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 Gl(e){const t=document.activeElement;return e.some(n=>n===t?!0:(n.focus(),document.activeElement!==t))}var xI=Ig,Bg=Ag,zg=_g,Hg=Pg,Ug=Rg,Wg=Og,Vg=ql;const vI=xI,Kg=p.forwardRef(({className:e,...t},n)=>u.jsx(Bg,{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=Bg.displayName;const bI=zr.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"}}),qg=p.forwardRef(({className:e,variant:t,...n},r)=>u.jsx(zg,{ref:r,className:re(bI({variant:t}),e),...n}));qg.displayName=zg.displayName;const wI=p.forwardRef(({className:e,...t},n)=>u.jsx(Wg,{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}));wI.displayName=Wg.displayName;const Gg=p.forwardRef(({className:e,...t},n)=>u.jsx(Vg,{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(ue.X,{className:"h-4 w-4"})}));Gg.displayName=Vg.displayName;const Yg=p.forwardRef(({className:e,...t},n)=>u.jsx(Hg,{ref:n,className:re("text-sm font-semibold",e),...t}));Yg.displayName=Hg.displayName;const Xg=p.forwardRef(({className:e,...t},n)=>u.jsx(Ug,{ref:n,className:re("text-sm opacity-90",e),...t}));Xg.displayName=Ug.displayName;function yI(){const{toasts:e}=nl();return u.jsxs(vI,{children:[e.map(function({id:t,title:n,description:r,action:o,...s}){return u.jsxs(qg,{...s,children:[u.jsxs("div",{className:"grid gap-1",children:[n&&u.jsx(Yg,{children:n}),r&&u.jsx(Xg,{children:r})]}),o,u.jsx(Gg,{})]},t)}),u.jsx(Kg,{})]})}var SI=(e,t,n,r,o,s,i,a)=>{let l=document.documentElement,c=["light","dark"];function d(f){(Array.isArray(e)?e:[e]).forEach(v=>{let g=v==="class",x=g&&s?o.map(y=>s[y]||y):o;g?(l.classList.remove(...x),l.classList.add(s&&s[f]?s[f]:f)):l.setAttribute(v,f)}),h(f)}function h(f){a&&c.includes(f)&&(l.style.colorScheme=f)}function m(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}if(r)d(r);else try{let f=localStorage.getItem(t)||n,v=i&&f==="system"?m():f;d(v)}catch{}},CI=p.createContext(void 0),TI={setTheme:e=>{},themes:[]},kI=()=>{var e;return(e=p.useContext(CI))!=null?e:TI};p.memo(({forcedTheme:e,storageKey:t,attribute:n,enableSystem:r,enableColorScheme:o,defaultTheme:s,value:i,themes:a,nonce:l,scriptProps:c})=>{let d=JSON.stringify([n,t,s,e,a,i,r,o]).slice(1,-1);return p.createElement("script",{...c,suppressHydrationWarning:!0,nonce:typeof window>"u"?l:"",dangerouslySetInnerHTML:{__html:`(${SI.toString()})(${d})`}})});var EI=e=>{switch(e){case"success":return AI;case"info":return _I;case"warning":return jI;case"error":return PI;default:return null}},II=Array(12).fill(0),NI=({visible:e,className:t})=>b.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},b.createElement("div",{className:"sonner-spinner"},II.map((n,r)=>b.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),AI=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"})),jI=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"})),_I=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"})),PI=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"})),RI=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"})),MI=()=>{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},Yl=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:Yl++,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)||Yl++;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}},qt=new OI,DI=(e,t)=>{let n=(t==null?void 0:t.id)||Yl++;return qt.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",$I=DI,FI=()=>qt.toasts,BI=()=>qt.getActiveToasts();Object.assign($I,{success:qt.success,info:qt.info,warning:qt.warning,error:qt.error,custom:qt.custom,message:qt.message,promise:qt.promise,dismiss:qt.dismiss,loading:qt.loading},{getHistory:FI,getToasts:BI});function zI(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))}zI(`: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 hi(e){return e.label!==void 0}var HI=3,UI="32px",WI="16px",Jg=4e3,VI=356,KI=14,qI=20,GI=200;function gn(...e){return e.filter(Boolean).join(" ")}function YI(e){let[t,n]=e.split("-"),r=[];return t&&r.push(t),n&&r.push(n),r}var XI=e=>{var t,n,r,o,s,i,a,l,c,d,h;let{invert:m,toast:f,unstyled:v,interacting:g,setHeights:x,visibleToasts:y,heights:w,index:S,toasts:k,expanded:C,removeToast:T,defaultRichColors:I,closeButton:N,style:R,cancelButtonStyle:O,actionButtonStyle:$,className:V="",descriptionClassName:U="",duration:j,position:q,gap:K,loadingIcon:D,expandByDefault:P,classNames:E,icons:B,closeButtonAriaLabel:Y="Close toast",pauseWhenPageIsHidden:_}=e,[M,G]=b.useState(null),[J,se]=b.useState(null),[W,L]=b.useState(!1),[X,ee]=b.useState(!1),[Z,z]=b.useState(!1),[ae,ie]=b.useState(!1),[ge,we]=b.useState(!1),[Ae,Pe]=b.useState(0),[ke,st]=b.useState(0),bt=b.useRef(f.duration||j||Jg),It=b.useRef(null),We=b.useRef(null),ze=S===0,Ke=S+1<=y,Fe=f.type,Ue=f.dismissible!==!1,ut=f.className||"",jt=f.descriptionClassName||"",it=b.useMemo(()=>w.findIndex(xe=>xe.toastId===f.id)||0,[w,f.id]),_t=b.useMemo(()=>{var xe;return(xe=f.closeButton)!=null?xe:N},[f.closeButton,N]),yt=b.useMemo(()=>f.duration||j||Jg,[f.duration,j]),gt=b.useRef(0),Nt=b.useRef(0),St=b.useRef(0),Ct=b.useRef(null),[zt,xt]=q.split("-"),Oe=b.useMemo(()=>w.reduce((xe,Be,Ge)=>Ge>=it?xe:xe+Be.height,0),[w,it]),Ve=MI(),Te=f.invert||m,Q=Fe==="loading";Nt.current=b.useMemo(()=>it*K+Oe,[it,Oe]),b.useEffect(()=>{bt.current=yt},[yt]),b.useEffect(()=>{L(!0)},[]),b.useEffect(()=>{let xe=We.current;if(xe){let Be=xe.getBoundingClientRect().height;return st(Be),x(Ge=>[{toastId:f.id,height:Be,position:f.position},...Ge]),()=>x(Ge=>Ge.filter(Tt=>Tt.toastId!==f.id))}},[x,f.id]),b.useLayoutEffect(()=>{if(!W)return;let xe=We.current,Be=xe.style.height;xe.style.height="auto";let Ge=xe.getBoundingClientRect().height;xe.style.height=Be,st(Ge),x(Tt=>Tt.find(kt=>kt.toastId===f.id)?Tt.map(kt=>kt.toastId===f.id?{...kt,height:Ge}:kt):[{toastId:f.id,height:Ge,position:f.position},...Tt])},[W,f.title,f.description,x,f.id]);let me=b.useCallback(()=>{ee(!0),Pe(Nt.current),x(xe=>xe.filter(Be=>Be.toastId!==f.id)),setTimeout(()=>{T(f)},GI)},[f,T,x,Nt]);b.useEffect(()=>{if(f.promise&&Fe==="loading"||f.duration===1/0||f.type==="loading")return;let xe;return C||g||_&&Ve?(()=>{if(St.current<gt.current){let Be=new Date().getTime()-gt.current;bt.current=bt.current-Be}St.current=new Date().getTime()})():bt.current!==1/0&&(gt.current=new Date().getTime(),xe=setTimeout(()=>{var Be;(Be=f.onAutoClose)==null||Be.call(f,f),me()},bt.current)),()=>clearTimeout(xe)},[C,g,f,Fe,_,Ve,me]),b.useEffect(()=>{f.delete&&me()},[me,f.delete]);function Ze(){var xe,Be,Ge;return B!=null&&B.loading?b.createElement("div",{className:gn(E==null?void 0:E.loader,(xe=f==null?void 0:f.classNames)==null?void 0:xe.loader,"sonner-loader"),"data-visible":Fe==="loading"},B.loading):D?b.createElement("div",{className:gn(E==null?void 0:E.loader,(Be=f==null?void 0:f.classNames)==null?void 0:Be.loader,"sonner-loader"),"data-visible":Fe==="loading"},D):b.createElement(NI,{className:gn(E==null?void 0:E.loader,(Ge=f==null?void 0:f.classNames)==null?void 0:Ge.loader),visible:Fe==="loading"})}return b.createElement("li",{tabIndex:0,ref:We,className:gn(V,ut,E==null?void 0:E.toast,(t=f==null?void 0:f.classNames)==null?void 0:t.toast,E==null?void 0:E.default,E==null?void 0:E[Fe],(n=f==null?void 0:f.classNames)==null?void 0:n[Fe]),"data-sonner-toast":"","data-rich-colors":(r=f.richColors)!=null?r:I,"data-styled":!(f.jsx||f.unstyled||v),"data-mounted":W,"data-promise":!!f.promise,"data-swiped":ge,"data-removed":X,"data-visible":Ke,"data-y-position":zt,"data-x-position":xt,"data-index":S,"data-front":ze,"data-swiping":Z,"data-dismissible":Ue,"data-type":Fe,"data-invert":Te,"data-swipe-out":ae,"data-swipe-direction":J,"data-expanded":!!(C||P&&W),style:{"--index":S,"--toasts-before":S,"--z-index":k.length-S,"--offset":`${X?Ae:Nt.current}px`,"--initial-height":P?"auto":`${ke}px`,...R,...f.style},onDragEnd:()=>{z(!1),G(null),Ct.current=null},onPointerDown:xe=>{Q||!Ue||(It.current=new Date,Pe(Nt.current),xe.target.setPointerCapture(xe.pointerId),xe.target.tagName!=="BUTTON"&&(z(!0),Ct.current={x:xe.clientX,y:xe.clientY}))},onPointerUp:()=>{var xe,Be,Ge,Tt;if(ae||!Ue)return;Ct.current=null;let kt=Number(((xe=We.current)==null?void 0:xe.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),At=Number(((Be=We.current)==null?void 0:Be.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),Lt=new Date().getTime()-((Ge=It.current)==null?void 0:Ge.getTime()),je=M==="x"?kt:At,dt=Math.abs(je)/Lt;if(Math.abs(je)>=qI||dt>.11){Pe(Nt.current),(Tt=f.onDismiss)==null||Tt.call(f,f),se(M==="x"?kt>0?"right":"left":At>0?"down":"up"),me(),ie(!0),we(!1);return}z(!1),G(null)},onPointerMove:xe=>{var Be,Ge,Tt,kt;if(!Ct.current||!Ue||((Be=window.getSelection())==null?void 0:Be.toString().length)>0)return;let At=xe.clientY-Ct.current.y,Lt=xe.clientX-Ct.current.x,je=(Ge=e.swipeDirections)!=null?Ge:YI(q);!M&&(Math.abs(Lt)>1||Math.abs(At)>1)&&G(Math.abs(Lt)>Math.abs(At)?"x":"y");let dt={x:0,y:0};M==="y"?(je.includes("top")||je.includes("bottom"))&&(je.includes("top")&&At<0||je.includes("bottom")&&At>0)&&(dt.y=At):M==="x"&&(je.includes("left")||je.includes("right"))&&(je.includes("left")&&Lt<0||je.includes("right")&&Lt>0)&&(dt.x=Lt),(Math.abs(dt.x)>0||Math.abs(dt.y)>0)&&we(!0),(Tt=We.current)==null||Tt.style.setProperty("--swipe-amount-x",`${dt.x}px`),(kt=We.current)==null||kt.style.setProperty("--swipe-amount-y",`${dt.y}px`)}},_t&&!f.jsx?b.createElement("button",{"aria-label":Y,"data-disabled":Q,"data-close-button":!0,onClick:Q||!Ue?()=>{}:()=>{var xe;me(),(xe=f.onDismiss)==null||xe.call(f,f)},className:gn(E==null?void 0:E.closeButton,(o=f==null?void 0:f.classNames)==null?void 0:o.closeButton)},(s=B==null?void 0:B.close)!=null?s:RI):null,f.jsx||b.isValidElement(f.title)?f.jsx?f.jsx:typeof f.title=="function"?f.title():f.title:b.createElement(b.Fragment,null,Fe||f.icon||f.promise?b.createElement("div",{"data-icon":"",className:gn(E==null?void 0:E.icon,(i=f==null?void 0:f.classNames)==null?void 0:i.icon)},f.promise||f.type==="loading"&&!f.icon?f.icon||Ze():null,f.type!=="loading"?f.icon||(B==null?void 0:B[Fe])||EI(Fe):null):null,b.createElement("div",{"data-content":"",className:gn(E==null?void 0:E.content,(a=f==null?void 0:f.classNames)==null?void 0:a.content)},b.createElement("div",{"data-title":"",className:gn(E==null?void 0:E.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:gn(U,jt,E==null?void 0:E.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&&hi(f.cancel)?b.createElement("button",{"data-button":!0,"data-cancel":!0,style:f.cancelButtonStyle||O,onClick:xe=>{var Be,Ge;hi(f.cancel)&&Ue&&((Ge=(Be=f.cancel).onClick)==null||Ge.call(Be,xe),me())},className:gn(E==null?void 0:E.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&&hi(f.action)?b.createElement("button",{"data-button":!0,"data-action":!0,style:f.actionButtonStyle||$,onClick:xe=>{var Be,Ge;hi(f.action)&&((Ge=(Be=f.action).onClick)==null||Ge.call(Be,xe),!xe.defaultPrevented&&me())},className:gn(E==null?void 0:E.actionButton,(h=f==null?void 0:f.classNames)==null?void 0:h.actionButton)},f.action.label):null))};function Zg(){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 JI(e,t){let n={};return[e,t].forEach((r,o)=>{let s=o===1,i=s?"--mobile-offset":"--offset",a=s?WI:UI;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 ZI=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:h,duration:m,style:f,visibleToasts:v=HI,toastOptions:g,dir:x=Zg(),gap:y=KI,loadingIcon:w,icons:S,containerAriaLabel:k="Notifications",pauseWhenPageIsHidden:C}=e,[T,I]=b.useState([]),N=b.useMemo(()=>Array.from(new Set([r].concat(T.filter(_=>_.position).map(_=>_.position)))),[T,r]),[R,O]=b.useState([]),[$,V]=b.useState(!1),[U,j]=b.useState(!1),[q,K]=b.useState(d!=="system"?d:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),D=b.useRef(null),P=o.join("+").replace(/Key/g,"").replace(/Digit/g,""),E=b.useRef(null),B=b.useRef(!1),Y=b.useCallback(_=>{I(M=>{var G;return(G=M.find(J=>J.id===_.id))!=null&&G.delete||qt.dismiss(_.id),M.filter(({id:J})=>J!==_.id)})},[]);return b.useEffect(()=>qt.subscribe(_=>{if(_.dismiss){I(M=>M.map(G=>G.id===_.id?{...G,delete:!0}:G));return}setTimeout(()=>{Po.flushSync(()=>{I(M=>{let G=M.findIndex(J=>J.id===_.id);return G!==-1?[...M.slice(0,G),{...M[G],..._},...M.slice(G+1)]:[_,...M]})})})}),[]),b.useEffect(()=>{if(d!=="system"){K(d);return}if(d==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?K("dark"):K("light")),typeof window>"u")return;let _=window.matchMedia("(prefers-color-scheme: dark)");try{_.addEventListener("change",({matches:M})=>{K(M?"dark":"light")})}catch{_.addListener(({matches:G})=>{try{K(G?"dark":"light")}catch(J){console.error(J)}})}},[d]),b.useEffect(()=>{T.length<=1&&V(!1)},[T]),b.useEffect(()=>{let _=M=>{var G,J;o.every(se=>M[se]||M.code===se)&&(V(!0),(G=D.current)==null||G.focus()),M.code==="Escape"&&(document.activeElement===D.current||(J=D.current)!=null&&J.contains(document.activeElement))&&V(!1)};return document.addEventListener("keydown",_),()=>document.removeEventListener("keydown",_)},[o]),b.useEffect(()=>{if(D.current)return()=>{E.current&&(E.current.focus({preventScroll:!0}),E.current=null,B.current=!1)}},[D.current]),b.createElement("section",{ref:t,"aria-label":`${k} ${P}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},N.map((_,M)=>{var G;let[J,se]=_.split("-");return T.length?b.createElement("ol",{key:_,dir:x==="auto"?Zg():x,tabIndex:-1,ref:D,className:a,"data-sonner-toaster":!0,"data-theme":q,"data-y-position":J,"data-lifted":$&&T.length>1&&!s,"data-x-position":se,style:{"--front-toast-height":`${((G=R[0])==null?void 0:G.height)||0}px`,"--width":`${VI}px`,"--gap":`${y}px`,...f,...JI(l,c)},onBlur:W=>{B.current&&!W.currentTarget.contains(W.relatedTarget)&&(B.current=!1,E.current&&(E.current.focus({preventScroll:!0}),E.current=null))},onFocus:W=>{W.target instanceof HTMLElement&&W.target.dataset.dismissible==="false"||B.current||(B.current=!0,E.current=W.relatedTarget)},onMouseEnter:()=>V(!0),onMouseMove:()=>V(!0),onMouseLeave:()=>{U||V(!1)},onDragEnd:()=>V(!1),onPointerDown:W=>{W.target instanceof HTMLElement&&W.target.dataset.dismissible==="false"||j(!0)},onPointerUp:()=>j(!1)},T.filter(W=>!W.position&&M===0||W.position===_).map((W,L)=>{var X,ee;return b.createElement(XI,{key:W.id,icons:S,index:L,toast:W,defaultRichColors:h,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:(ee=g==null?void 0:g.closeButton)!=null?ee:i,interacting:U,position:_,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:Y,toasts:T.filter(Z=>Z.position==W.position),heights:R.filter(Z=>Z.position==W.position),setHeights:O,expandByDefault:s,gap:y,loadingIcon:w,expanded:$,pauseWhenPageIsHidden:C,swipeDirections:e.swipeDirections})})):null}))});const QI=({...e})=>{const{theme:t="system"}=kI();return u.jsx(ZI,{theme:t,className:"toaster group",toastOptions:{classNames:{toast:"group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",description:"group-[.toast]:text-muted-foreground",actionButton:"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",cancelButton:"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground"}},...e})};F.Api=Fv,F.ApiClient=$v,F.ApiProvider=tu,F.ArtifactRenderer=Cp,F.Badge=Pp,F.Button=Qe,F.Card=sl,F.CardContent=cl,F.CardDescription=ll,F.CardHeader=il,F.CardTitle=al,F.ChatApi=Ko,F.ChatApp=Rk,F.ChatInput=Hf,F.ChatInterface=Mr,F.ChatProviders=vr,F.ChatWidget=Dk,F.Command=wl,F.CommandEmpty=Cl,F.CommandGroup=Tl,F.CommandInput=yl,F.CommandItem=kl,F.CommandList=Sl,F.DEFAULT_TIMEOUT_MS=Yc,F.Dialog=Qa,F.DialogContent=Bs,F.DialogHeader=zs,F.DialogTitle=Hs,F.DropdownMenu=Ss,F.DropdownMenuContent=ho,F.DropdownMenuItem=Bn,F.DropdownMenuTrigger=Cs,F.FileViewerModal=ip,F.HISTORY_TIMEOUT_MS=Xc,F.Input=Pl,F.InterruptPartRenderer=kp,F.Label=fm,F.MarkdownContent=Rr,F.MessageComponent=Ys,F.MessageList=hl,F.MessageRow=fl,F.NewChatButton=Lk,F.PlotArtifact=wp,F.ResearchTaskArtifact=Sp,F.SETTINGS_STORAGE_KEY=$i,F.ScrollArea=_l,F.Select=gE,F.SelectContent=Qm,F.SelectItem=eg,F.SelectTrigger=Xm,F.SelectValue=xE,F.Separator=og,F.Sheet=NE,F.SheetContent=hg,F.SheetDescription=gg,F.SheetHeader=pg,F.SheetTitle=mg,F.SheetTrigger=AE,F.SimpleChat=Mk,F.SimpleJsonView=ul,F.Sonner=QI,F.StreamProgress=Ep,F.Switch=dg,F.Textarea=Ta,F.ThinkingIndicator=Ip,F.ThreadListItem=im,F.ThreadManager=ti,F.ThreadStateProvider=Tu,F.ThreadsProvider=fu,F.TimelineColumn=mx,F.Toaster=yI,F.ToolComponent=Ap,F.Tooltip=ZE,F.TooltipContent=kg,F.TooltipProvider=JE,F.TooltipTrigger=QE,F.UserTextContent=Np,F.applySettings=bb,F.buildCheckpointIndex=Ql,F.buildCheckpointPreviewMap=ox,F.chatApiClient=Mn,F.del=Ai,F.downloadFileById=Zc,F.extractConfigFields=mi,F.fileToBase64=nu,F.get=Jt,F.getChatToken=qc,F.getCheckpointForMessage=sx,F.getCurrentSettings=vb,F.getDefaultApiConfig=Ru,F.getDefaultChatSettings=Mu,F.getFileContent=_i,F.getFileInfo=zv,F.getMessageAttemptInfo=ec,F.getMessageDomKey=dl,F.getPreviewForMessage=pi,F.httpClient=Xt,F.hydrateHistorySnapshots=Rn,F.isEnvelope=ou,F.listFiles=Qc,F.loadStoredSettings=Ou,F.onChatTokenChanged=Gc,F.post=Vo,F.processAttachments=ru,F.put=Jc,F.readNumber=nc,F.readString=Pn,F.resolveChatBaseUrl=vn,F.saveSettings=Du,F.setChatToken=Wo,F.toPlainObject=_n,F.unwrap=$t,F.useApi=Xr,F.useCheckpointIndex=tc,F.useFilePreview=jp,F.useHasChatSession=mb,F.useParsedMessageContent=_p,F.useShallowStableValue=Au,F.useStream=Li,F.useStreamingHook=Li,F.useThreadHistoryState=wu,F.useThreadManagerViewState=cm,F.useThreadState=eo,F.useThreadStateUpdater=Cu,F.useThreads=gr,F.useThreadsState=uu,F.viewFileById=Bv,Object.defineProperty(F,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=fp(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=fp(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 xp{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 vp{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 Kn{constructor(t){this.options=t||lr,this.options.renderer=this.options.renderer||new ol,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new xp,this.slugger=new vp}static parse(t,n){return new Kn(n).parse(t)}static parseInline(t,n){return new Kn(n).parseInline(t)}parse(t,n=!0){let r="",o,s,i,a,l,c,d,f,m,h,v,g,x,y,w,S,k,C,T;const I=t.length;for(o=0;o<I;o++){if(h=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[h.type]&&(T=this.options.extensions.renderers[h.type].call({parser:this},h),T!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(h.type))){r+=T||"";continue}switch(h.type){case"space":continue;case"hr":{r+=this.renderer.hr();continue}case"heading":{r+=this.renderer.heading(this.parseInline(h.tokens),h.depth,dp(this.parseInline(h.tokens,this.textRenderer)),this.slugger);continue}case"code":{r+=this.renderer.code(h.text,h.lang,h.escaped);continue}case"table":{for(f="",d="",a=h.header.length,s=0;s<a;s++)d+=this.renderer.tablecell(this.parseInline(h.header[s].tokens),{header:!0,align:h.align[s]});for(f+=this.renderer.tablerow(d),m="",a=h.rows.length,s=0;s<a;s++){for(c=h.rows[s],d="",l=c.length,i=0;i<l;i++)d+=this.renderer.tablecell(this.parseInline(c[i].tokens),{header:!1,align:h.align[i]});m+=this.renderer.tablerow(d)}r+=this.renderer.table(f,m);continue}case"blockquote":{m=this.parse(h.tokens),r+=this.renderer.blockquote(m);continue}case"list":{for(v=h.ordered,g=h.start,x=h.loose,a=h.items.length,m="",s=0;s<a;s++)w=h.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(h.text);continue}case"paragraph":{r+=this.renderer.paragraph(this.parseInline(h.tokens));continue}case"text":{for(m=h.tokens?this.parseInline(h.tokens):h.text;o+1<I&&t[o+1].type==="text";)h=t[++o],m+=`
|
|
127
|
+
`+(h.tokens?this.parseInline(h.tokens):h.text);r+=n?this.renderer.paragraph(m):m;continue}default:{const N='Token with "'+h.type+'" type was not found.';if(this.options.silent){console.error(N);return}else throw new Error(N)}}}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||lr}preprocess(t){return t}postprocess(t){return t}}Qg(Gs,"passThroughHooks",new Set(["preprocess","postprocess"]));function PT(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>"+Dt(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 bp(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...ye.defaults,...s};const i=PT(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(NT(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(f){return i(f)}const c=function(f){let m;if(!f)try{r.walkTokens&&ye.walkTokens(l,r.walkTokens),m=t(l,r),r.hooks&&(m=r.hooks.postprocess(m))}catch(h){f=h}return r.highlight=a,f?i(f):o(null,m)};if(!a||a.length<3||(delete r.highlight,!l.length))return c();let d=0;ye.walkTokens(l,function(f){f.type==="code"&&(d++,setTimeout(()=>{a(f.text,f.lang,function(m,h){if(m)return c(m);h!=null&&h!==f.text&&(f.text=h,f.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(ye.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&&ye.walkTokens(a,r.walkTokens);let l=t(a,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(a){return i(a)}}}function ye(e,t,n){return bp(Vn.lex,Kn.parse)(e,t,n)}ye.options=ye.setOptions=function(e){return ye.defaults={...ye.defaults,...e},mT(ye.defaults),ye},ye.getDefaults=ap,ye.defaults=lr,ye.use=function(...e){const t=ye.defaults.extensions||{renderers:{},childTokens:{}};e.forEach(n=>{const r={...n};if(r.async=ye.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=ye.defaults.renderer||new ol;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=ye.defaults.tokenizer||new rl;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=ye.defaults.hooks||new Gs;for(const s in n.hooks){const i=o[s];Gs.passThroughHooks.has(s)?o[s]=a=>{if(ye.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=ye.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}}ye.setOptions(r)})},ye.walkTokens=function(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(ye,r)),r.type){case"table":{for(const o of r.header)n=n.concat(ye.walkTokens(o.tokens,t));for(const o of r.rows)for(const s of o)n=n.concat(ye.walkTokens(s.tokens,t));break}case"list":{n=n.concat(ye.walkTokens(r.items,t));break}default:ye.defaults.extensions&&ye.defaults.extensions.childTokens&&ye.defaults.extensions.childTokens[r.type]?ye.defaults.extensions.childTokens[r.type].forEach(function(o){n=n.concat(ye.walkTokens(r[o],t))}):r.tokens&&(n=n.concat(ye.walkTokens(r.tokens,t)))}return n},ye.parseInline=bp(Vn.lexInline,Kn.parseInline),ye.Parser=Kn,ye.parser=Kn.parse,ye.Renderer=ol,ye.TextRenderer=xp,ye.Lexer=Vn,ye.lexer=Vn.lex,ye.Tokenizer=rl,ye.Slugger=vp,ye.Hooks=Gs,ye.parse=ye,ye.options,ye.setOptions,ye.use,ye.walkTokens,ye.parseInline,Kn.parse,Vn.lex;function Rr({content:e,className:t="",allowHtml:n=!1,style:r}){const o=b.useMemo(()=>{if(!e||typeof e!="string"||e.trim().length===0)return"";try{if(!n){const i=e.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"").replace(/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi,"").replace(/javascript:/gi,"").replace(/on\w+\s*=/gi,"");return typeof ye.parse=="function"?ye.parse(i):ye(i)}return typeof ye.parse=="function"?ye.parse(e):ye(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 wp({preview:e,idx:t}){return u.jsxs("div",{className:"space-y-2",children:[e.label&&u.jsxs("p",{className:"text-[0.65rem] uppercase tracking-wide text-muted-foreground",children:["Artifact: ",e.label]}),u.jsx("div",{className:"overflow-hidden rounded border border-border/60 bg-background/60 p-1 shadow-sm",children:u.jsx("img",{src:e.src,alt:e.alt,title:e.label,loading:"lazy",className:"h-auto max-h-[420px] w-full rounded object-contain",onLoad:()=>{},onError:n=>{console.error(`[MessageComponent] ❌ Image failed to load for artifact ${t}:`,{alt:e.alt,label:e.label,message:n.target.alt})}})})]})}const yp={completed:{label:"Completed",badgeClass:"border border-green-200 bg-green-50 text-green-700"},success:{label:"Completed",badgeClass:"border border-green-200 bg-green-50 text-green-700"},failed:{label:"Failed",badgeClass:"border border-red-200 bg-red-50 text-red-700"},error:{label:"Failed",badgeClass:"border border-red-200 bg-red-50 text-red-700"},cancelled:{label:"Cancelled",badgeClass:"border border-orange-200 bg-orange-50 text-orange-700"},cancel:{label:"Cancelled",badgeClass:"border border-orange-200 bg-orange-50 text-orange-700"},pending:{label:"Pending",badgeClass:"border border-blue-200 bg-blue-50 text-blue-700"},processing:{label:"Processing",badgeClass:"border border-yellow-200 bg-yellow-50 text-yellow-700"}},_T=e=>{if(!e)return yp.processing;const t=e.toLowerCase().trim();return yp[t]??{label:t.replace(/(^\w|\s\w)/g,n=>n.toUpperCase()),badgeClass:"border border-slate-200 bg-slate-50 text-slate-800"}},RT=e=>e?e.length>10?`${e.slice(0,8)}…`:e:"";function Sp({artifact:e}){const t=_T(e.status),n=e.task_url??e.taskUrl??"";return u.jsxs("div",{className:"rounded-lg border border-blue-200/70 bg-blue-50/40 p-4 space-y-3",children:[u.jsxs("div",{className:"flex items-start justify-between gap-3",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsx("div",{className:"flex h-7 w-7 items-center justify-center rounded-full bg-blue-600/10 text-blue-600",children:u.jsx(ue.Search,{className:"h-4 w-4"})}),u.jsxs("div",{className:"space-y-1",children:[u.jsx("p",{className:"text-xs font-semibold uppercase tracking-wide text-blue-700",children:"Research Task"}),u.jsxs("p",{className:"text-[11px] text-blue-900/80",children:["Task ID: ",u.jsx("span",{className:"font-mono",children:RT(e.task_id)})]})]})]}),t&&u.jsx("span",{className:`inline-flex items-center rounded-full px-3 py-1 text-[11px] font-semibold ${t.badgeClass}`,children:t.label})]}),e.query&&u.jsxs("div",{className:"rounded border border-blue-100 bg-white/80 px-3 py-2 text-xs text-blue-900/90",children:[u.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wide text-blue-500",children:"Query"}),u.jsx("p",{className:"line-clamp-2 text-[11px] text-blue-900",children:e.query})]}),typeof e.results=="string"&&e.results.trim()&&u.jsxs("div",{className:"rounded border border-blue-100 bg-white/80 px-3 py-2 text-sm text-blue-900/90 space-y-1",children:[u.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wide text-blue-500",children:"Results"}),u.jsx(Rr,{content:e.results,allowHtml:!1,className:"prose text-xs !prose-sm prose-blue dark:prose-invert"})]}),u.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[n?u.jsxs("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 rounded-full border border-blue-600/80 bg-blue-600/10 px-3 py-1 text-xs font-semibold text-blue-700 transition hover:bg-blue-600/20",children:[u.jsx("span",{children:"Go to task"}),u.jsx(ue.ExternalLink,{className:"h-3 w-3"})]}):u.jsx("span",{className:"text-xs text-muted-foreground",children:"Task link unavailable"}),e.createdAt&&u.jsxs("p",{className:"text-[10px] text-blue-700/70",children:["Started: ",new Date(e.createdAt).toLocaleTimeString()]})]})]})}function Cp({artifact:e,idx:t=0}){const n=b.useMemo(()=>e?(Array.isArray(e.plots)?e.plots:[]).map(o=>nb(o)).filter(o=>o!==null):[],[e]);return(e==null?void 0:e.type)==="research_task_info"?u.jsx(Sp,{artifact:{type:"research_task_info",task_id:e.task_id,task_url:e.task_url,query:e.query,status:e.status,createdAt:e.createdAt}}):n.length>0?u.jsx("div",{className:"space-y-2",children:n.map((r,o)=>u.jsx(wp,{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 sl=p.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:re("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));sl.displayName="Card";const il=p.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:re("flex flex-col space-y-1.5 p-6",e),...t}));il.displayName="CardHeader";const al=p.forwardRef(({className:e,...t},n)=>u.jsx("h3",{ref:n,className:re("text-2xl font-semibold leading-none tracking-tight",e),...t}));al.displayName="CardTitle";const ll=p.forwardRef(({className:e,...t},n)=>u.jsx("p",{ref:n,className:re("text-sm text-muted-foreground",e),...t}));ll.displayName="CardDescription";const cl=p.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:re("p-6 pt-0",e),...t}));cl.displayName="CardContent";const Tp=p.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:re("flex items-center p-6 pt-0",e),...t}));Tp.displayName="CardFooter";function kp({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=xr(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(sl,{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(il,{className:"pb-3",children:[u.jsx(al,{className:"text-blue-900 dark:text-blue-100 text-base",children:i}),u.jsx(ll,{className:"text-blue-700 dark:text-blue-300 text-sm",children:l})]}),a&&u.jsx(cl,{className:"pt-0 pb-3",children:a}),u.jsx(Tp,{className:"pt-0",children:u.jsxs("div",{className:"flex gap-2 ml-auto",children:[u.jsx(Qe,{size:"sm",variant:"outline",onClick:()=>n(e),className:"border-red-300 text-red-700 hover:bg-red-50 dark:border-red-700 dark:text-red-300 dark:hover:bg-red-950/50",disabled:r||!o,children:"Reject"}),u.jsx(Qe,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",disabled:r||!o,children:"Approve"})]})})]})}const MT="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 ul({data:e}){return Array.isArray(e)?e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?u.jsx("div",{className:MT,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:xr(e)}):u.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:xr(e)})}function Ep({message:e,isStreaming:t=!1}){const n=e.name??"tool",r=b.useMemo(()=>{const a=e.additionalKwargs??{};return Array.isArray(a.toolProgress)?[...a.toolProgress]:[]},[e]),s=r.some(a=>a.type==="tool.start"||a.type==="tool.call"||a.type==="message.start")?`Running ${n}…`:void 0;return t||r.length>0?u.jsxs("div",{className:"space-y-2",children:[u.jsxs("div",{className:"flex items-center gap-2 text-xs uppercase tracking-wide text-muted-foreground",children:[t&&u.jsx(ue.Loader,{className:"h-3 w-3 animate-spin"}),u.jsx("span",{children:s??`Running ${n}…`})]}),r.length>0&&u.jsx("div",{className:"space-y-2 text-xs text-muted-foreground",children:r.map((a,l)=>{var c;return u.jsxs("div",{className:"rounded border border-current/10 bg-muted/60 p-2 text-[11px] leading-snug",children:[u.jsxs("div",{className:"mb-1 flex items-center justify-between text-[8px] uppercase tracking-wide text-muted-foreground",children:[u.jsx("span",{children:((c=a.type)==null?void 0:c.replace(/\./g," "))??"progress"}),u.jsx("span",{children:a.idx??l+1})]}),a.content&&u.jsx("p",{className:"mt-1 text-[12px] text-foreground/90",children:a.content}),u.jsxs("div",{className:"mt-1 flex flex-wrap gap-2 text-[10px] opacity-70",children:[typeof a.factsFound=="number"&&u.jsxs("span",{children:["Facts found: ",a.factsFound]}),typeof a.isSufficient=="boolean"&&u.jsxs("span",{children:["Research ",a.isSufficient?"sufficient":"needs more data"]})]})]},`tool-progress-${n}-${l}`)})})]}):null}function Ip({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 Np({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(Rr,{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(Qe,{type:"button",variant:"ghost",size:"sm",className:"h-6 text-xs !text-[hsl(var(--chat-bubble-user-text))]",onClick:()=>n(!t),children:t?u.jsxs(u.Fragment,{children:[u.jsx(ue.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):u.jsxs(u.Fragment,{children:[u.jsx(ue.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",s," chars)"]})})]})}function Ap({message:e,viewMode:t,isStreaming:n=!1}){const o=Mi(e).name||"tool",s=e.artifact??null,i=c=>{if(c==null)return null;const d=typeof c=="string"?Ri(c)??c:c;if(d&&typeof d=="object")return u.jsx(ul,{data:d});const f=typeof d=="string"?d:(()=>{try{return xr(d)}catch{return String(d??"")}})();return u.jsx("pre",{className:"whitespace-pre-wrap break-words font-sans text-sm text-foreground/90",children:f})},a=c=>{if(c==null)return null;const{content:d,isMarkdown:f}=Yv(c);return f?u.jsx(Rr,{content:d,className:"text-current"}):i(c)},l=()=>{const c=e.content.find(m=>m.type!=="tool_call");if(!c)return u.jsx("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:u.jsxs("span",{children:["Running ",o,"…"]})});if(c.type==="text"){const h=(c.text??"").trim();if(!h)return null;const v=Qr(h);return a(v)}const d=Zr(c),f=Qr(d);return a(f)};return u.jsxs("div",{className:"space-y-2",children:[s&&u.jsx(Cp,{artifact:s,idx:0}),u.jsx(Ep,{message:e,isStreaming:n}),t==="expanded"&&u.jsx(u.Fragment,{children:l()})]})}function jp(e){const{allowFileOpen:t,currentThreadId:n}=e,{toast:r}=nl(),[o,s]=b.useState({}),[i,a]=b.useState(null),[l,c]=b.useState(!1),d=b.useCallback(()=>{c(!1),a(null)},[]),f=b.useCallback(h=>{a(h),c(!0)},[]),m=b.useCallback(async(h,v,g)=>{var x,y;if(!t){h.preventDefault();return}if(o[g]){h.preventDefault();return}try{const w=String(v.url??""),S=w.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);if(S){h.preventDefault();const k=S[1],C=v.name||`file_${k}`,T=v.mimeType||"application/octet-stream";f({id:k,name:C,mimeType:T});return}if(w.startsWith("data:")){h.preventDefault(),s(C=>({...C,[g]:!0}));const k=r({title:"Fetching file...",description:"",open:!0});try{const C=await Qc(n??void 0);if(!C||!Array.isArray(C))throw new Error("Invalid file list response");const T=C.find(I=>!I||typeof I!="object"||!((I.filename??"")===(v.name??""))?!1:typeof v.size=="number"&&typeof I.size=="number"?I.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");f({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,f]);return{uploadingFiles:o,handleFileClick:m,fileViewerOpen:l,currentFileInfo:i,closeFileViewer:d}}function Pp(e,t){return b.useMemo(()=>{if(t)return{contentParts:[],textContent:"",toolMeta:{},imageParts:[],fileParts:[],interruptParts:[],toolRaw:"",isToolStreaming:!1};const n=e,r=Array.isArray(n.content)?n.content:[],o=n.additionalKwargs??{};return{contentParts:r,textContent:Xv(r),toolMeta:Mi(n),imageParts:r.filter(s=>s.type==="image_url"),fileParts:r.filter(s=>s.type==="file"),interruptParts:r.filter(s=>s.type==="interrupt"),toolRaw:Jv(r),isToolStreaming:!!o.toolStreaming}},[e,t])}const OT={checkpoints:[],checkpointMetaByCheckpointId:new Map,timeline:[],messagePreviews:new Map,getLatest:()=>{},getCheckpoint:()=>{},getMessageAttempts:()=>[]},dl=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,fl=b.memo(function({message:t,index:n,isStreaming:r,streamingAssistantId:o,streamingDebounceMs:s,layoutSize:i,enableMessageEditing:a,editingMessageId:l,onEdit:c,onRegenerate:d,onCancelEdit:f,activeInterrupt:m,disableInterruptActions:h,onInterruptActionStart:v,onInterruptActionEnd:g,showToolMessages:x,checkpointIndex:y,onSelectCheckpoint:w}){const S=dl(t,n),k=t.role==="default_message",T=!!t.__syntheticStreaming,I=y??OT,N=!k&&"checkpointId"in t?t.checkpointId??null:null,{attemptCount:R,attemptIndex:O,attempts:$}=b.useMemo(()=>ec(t.id,N,I),[t.id,N,I]);return u.jsx("div",{className:"relative mb-4 last:mb-0","data-message-id":S,style:{minHeight:"60px",containIntrinsicSize:"auto 120px"},children:u.jsx(Ys,{message:t,messageIndex:n,isStreamingMessage:T||r&&o===t.id&&t.role==="assistant",streamingDebounceMs:s,isEditing:l===t.id,showActions:a,showTimestamp:!1,showAgentName:!0,layoutSize:i,onEdit:c,onRegenerate:()=>d(n),onCancelEdit:f,activeInterrupt:m,disableInterruptActions:h,onInterruptActionStart:v,onInterruptActionEnd:g,showToolMessages:x,attemptCount:R,attemptIndex:O,attemptMetas:$,onSelectCheckpoint:w})})});fl.displayName="MessageRow";function DT(e,t,n){const[r,o]=b.useState(e),s=b.useRef(e);return b.useEffect(()=>{if(!t){o(e),s.current=e;return}const i=e.map((a,l)=>{if(a.type!=="text")return a;const c=a.text??"",d=n(c),f=s.current[l];return d!==c&&f?f:{...a,text:d}});s.current=i,o(i)},[e,t,n]),r}function LT({message:e,isToolMessage:t,showToolMessages:n,toolViewMode:r,isToolStreaming:o,contentParts:s,textContent:i,imageParts:a,fileParts:l,interruptParts:c,isStreamingMessage:d,enableStreamingMarkdownBuffer:f,defaultMessage:m,handleFileClick:h,uploadingFiles:v,handleInterruptApprove:g,handleInterruptReject:x,disableInterruptActions:y,messageRole:w,truncateUserMessages:S,userMessagePreviewLength:k,isUserExpanded:C,setIsUserExpanded:T,isCompactLayout:I,activeInterruptId:N,activeInterruptValue:R,iconForeground:O}){const $=b.useCallback(()=>u.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/30 rounded",children:[u.jsx(ue.Loader,{className:"h-4 w-4 text-muted-foreground"}),u.jsx("span",{className:"text-sm text-muted-foreground",children:"File upload"})]}),[]),V=f??!0,U=b.useCallback(D=>$T(D,d),[d]),j=DT(s,V&&d,U),q=b.useCallback(({part:D,i:_})=>{if(D.type==="text"){const E=D.text??"",B=E.trim(),Y=Ri(B);return Y&&w!=="tool"?u.jsx(ul,{data:Y},_):w==="user"&&S&&B.length>k?u.jsx(Np,{text:B,expanded:C,onExpandedChange:T,previewLength:k,isCompact:I},_):u.jsx(Rr,{content:E,allowHtml:!1},_)}if(D.type==="image_url"){const E=D;return u.jsx("div",{className:"my-2",children:u.jsx("img",{src:E.url,alt:E.alt??"",loading:"lazy",className:"border rounded max-h-[420px] w-auto object-contain"})},_)}if(D.type==="file"){const E=D,B=E.name||"file";return u.jsxs("a",{href:E.url,onClick:Y=>h(Y,E,_),className:`inline-flex items-center gap-2 rounded px-2 py-1 text-xs bg-gray-100 border hover:bg-gray-200
|
|
129
|
+
dark:bg-background/10 dark:border-border/30 dark:hover:bg-background/20`,children:[v[_]?u.jsx(ue.Loader,{className:"h-4 w-4 animate-spin"}):null,u.jsxs("span",{className:"truncate max-w-[180px]",children:[B,v[_]?" (processing)":""]})]},_)}if(D.type==="interrupt"){const E=D,B=Go((E==null?void 0:E.id)??(E==null?void 0:E.interrupt_id)),Y=!!(N&&B&&B===N),P=Y?R??(E==null?void 0:E.value):E==null?void 0:E.value,M=B?{...E,id:B,interrupt_id:B}:E;return u.jsx(kp,{interruptPart:M,onApprove:g,onReject:x,disabled:y,isActive:Y,payload:P},_)}return null},[N,R,y,h,g,x,I,C,w,S,v,k,T]),K=i.trim().length>0||a.length>0||l.length>0||c.length>0;if(!t&&l.length>0&&!d)return $();if(!t&&!K&&!d)return null;if(t)return n?u.jsx(Ap,{message:e,viewMode:r,isStreaming:o},e.id):null;if(!m){const D=u.jsx("div",{className:"space-y-2",children:j.map((_,E)=>u.jsx(q,{part:_,i:E},E))});return d?u.jsxs("div",{"aria-busy":"true",role:"status",children:[D,u.jsx(Ip,{className:O})]}):D}return null}function $T(e,t){if(!t||!e)return e;let n=e;return n=FT(n),n=BT(n),n}function FT(e){const t=e.match(/\[[^\]]*\]\([^)]*$/);if(t&&typeof t.index=="number")return e.slice(0,t.index);const n=e.match(/\[[^\]]*$/);return n&&typeof n.index=="number"?e.slice(0,n.index):e}function BT(e){const t=e.match(/`[^`]*$/);return t&&typeof t.index=="number"?e.slice(0,t.index):e}const zT=zr.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 _p({className:e,variant:t,...n}){return u.jsx("div",{className:re(zT({variant:t}),e),...n})}function HT({showTimestamp:e,showAgentName:t,isToolMessage:n,iconForeground:r,agentName:o,messageIcon:s,customHeaderClass:i,customActionsClass:a,isCompactLayout:l,showActions:c,isEditing:d,messageRole:f,toolViewMode:m,toolMeta:h,onToggleToolView:v,onCopy:g,onEdit:x,onRegenerate:y,showCheckpointControls:w,attemptCount:S,attemptIndex:k,handleOlderAttemptSelect:C,handleNewerAttemptSelect:T,messageCreatedAt:I,copied:N}){return!e&&!t&&!n?null:u.jsxs("div",{className:re("flex items-center justify-between mb-2 pb-2 border-b border-current/10",l&&"mb-1 pb-1",r,i),children:[u.jsxs("div",{className:"flex items-center gap-2",children:[s,t&&o&&u.jsx("span",{className:re("font-medium",l?"text-xs":"text-sm"),children:o}),n&&u.jsxs(_p,{variant:"outline",className:re("text-xs flex items-center gap-1 cursor-pointer select-none",r,"border border-current/40",l&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":m==="expanded",onClick:v,onKeyDown:R=>{(R.key==="Enter"||R.key===" ")&&(R.preventDefault(),v())},children:[u.jsx("span",{children:h.name??"Tool Output"}),h.toolCallId&&u.jsx("span",{className:"opacity-70",children:h.toolCallId.slice(0,8)}),m==="expanded"?u.jsx(ue.ChevronUp,{className:"h-3 w-3"}):u.jsx(ue.ChevronDown,{className:"h-3 w-3"})]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[w&&S>1&&u.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[u.jsx("button",{type:"button",className:re("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",k<S-1?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{k>=S-1||C()},"aria-label":"Older attempt (back in time)",disabled:k>=S-1,children:u.jsx(ue.ChevronLeft,{className:"h-3 w-3"})}),u.jsx("div",{className:"flex items-center gap-2",children:u.jsxs("span",{className:"whitespace-nowrap",children:[S-k," / ",S]})}),u.jsx("button",{type:"button",className:re("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",k>0?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{k<=0||T()},"aria-label":"Newer attempt (forward in time)",disabled:k<=0,children:u.jsx(ue.ChevronRight,{className:"h-3 w-3"})})]}),e&&I&&u.jsx("time",{className:re("text-xs opacity-60",r,l&&"text-xs"),dateTime:new Date(I).toISOString(),title:new Date(I).toLocaleString(),children:new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(new Date(I))}),c&&!d&&u.jsxs("div",{className:re("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",a),children:[u.jsx("div",{className:"relative",children:u.jsx(Qe,{variant:"ghost",size:"sm",onClick:g,className:re("h-6 w-6 p-0 hover:bg-foreground/10",r,l&&"h-5 w-5"),"aria-label":"Copy message",title:"Copy message",children:u.jsx(ue.Copy,{className:re(N?"text-success":r,l?"h-3 w-3":"h-4 w-4")})})}),f==="user"&&x&&u.jsx(Qe,{variant:"ghost",size:"sm",onClick:x,className:re("h-6 w-6 p-0 hover:bg-foreground/10",r,l&&"h-5 w-5"),"aria-label":"Edit message",children:u.jsx(ue.Edit,{className:re(r,l?"h-3 w-3":"h-4 w-4")})}),f==="assistant"&&y&&u.jsx(Qe,{variant:"ghost",size:"sm",onClick:y,className:re("h-6 w-6 p-0 hover:bg-foreground/10",r,l&&"h-5 w-5"),"aria-label":"Regenerate response",children:u.jsx(ue.RotateCcw,{className:re(r,l?"h-3 w-3":"h-4 w-4")})})]})]})]})}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:f=!0,customStyles:m={},streamingDebounceMs:h=300,enableStreamingMarkdownBuffer:v,onEdit:g,onRegenerate:x,onCopy:y,activeInterrupt:w,disableInterruptActions:S=!1,onInterruptActionStart:k,onInterruptActionEnd:C,attemptCount:T=1,attemptIndex:I=0,onSelectCheckpoint:N,attemptMetas:R=[]}){const[O,$]=b.useState(!1),[V,U]=b.useState("preview"),[j,q]=b.useState(!1),{currentThreadId:K}=gr(),{respondToInterrupt:D}=eo(),_=l==="phone"||l==="half-screen",E=t.role,B=E==="tool",Y=b.useMemo(()=>t.role==="default_message"?t:null,[t]),P=!!Y,M=!(r&&E!=="user"),{uploadingFiles:G,handleFileClick:J,fileViewerOpen:se,currentFileInfo:W,closeFileViewer:L}=jp({allowFileOpen:M,currentThreadId:K}),X=b.useMemo(()=>{switch(E){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))]"}},[E]),ee=Pp(t,Y),{contentParts:Z,imageParts:z,fileParts:ae,interruptParts:ie,textContent:ge,toolMeta:we,toolRaw:Ae,isToolStreaming:_e}=ee,ke=v??h!==0,st=(w==null?void 0:w.id)??(w==null?void 0:w.interrupt_id),bt=Go(st),It=w==null?void 0:w.value,We=b.useCallback(async()=>{const Te=B?Ae:ge;async function Q(me){if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function"){await navigator.clipboard.writeText(me);return}if(navigator.clipboard&&typeof navigator.clipboard.write=="function"&&typeof ClipboardItem<"u"){const Ze=new Blob([me],{type:"text/plain"});await navigator.clipboard.write([new ClipboardItem({"text/plain":Ze})]);return}throw new Error("Clipboard API not supported in this context.")}try{await Q(Te),$(!0),setTimeout(()=>$(!1),2e3),y==null||y(Te)}catch(me){console.error("Failed to copy:",me)}},[B,Ae,ge,y]),ze=b.useCallback(()=>{if(!g||!t.id)return;const Te=(B?Ae:ge)??"",Q="type"in t&&t.type==="default_message"?void 0:{checkpointId:t.checkpointId??null,checkpointNs:t.checkpointNs??null};g(t.id,Te,Q)},[g,t.id,B,Ae,ge,t]),Ke=b.useCallback(()=>{x==null||x(n)},[x,n]),Fe=b.useCallback(()=>{U(Te=>Te==="expanded"?"preview":"expanded")},[]),Ue=b.useCallback(()=>{const Q=re(_?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",X);switch(E){case"user":return u.jsx(ue.User,{className:Q});case"assistant":return u.jsx(ue.Bot,{className:Q});case"tool":return u.jsx(ue.Wrench,{className:Q});default:return u.jsx(ue.Bot,{className:Q})}},[_,X,E]),ut=b.useCallback(()=>{const Te="group relative mb-4 flex w-full";switch(E){case"user":return re(Te,"justify-end");case"assistant":case"tool":case"system":return re(Te,"justify-start");default:return Te}},[E]),jt=b.useCallback(()=>{const Te=re("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",_&&"px-3 py-2 text-sm");if(P)return re(Te,"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(E){case"user":return re(Te,"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(Te,"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(Te,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return re(Te,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return re(Te,"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")}},[_,P,E]),it=b.useCallback(async Te=>{if(S)return;const Q=Go((Te==null?void 0:Te.id)??(Te==null?void 0:Te.interrupt_id));if(!Q){console.warn("Interrupt part missing id",Te);return}try{k==null||k(),await D(Q,!0)}catch(me){console.error("Failed to approve interrupt:",me)}finally{C==null||C()}},[S,C,k,D]),Pt=b.useCallback(async Te=>{if(S)return;const Q=Go((Te==null?void 0:Te.id)??(Te==null?void 0:Te.interrupt_id));if(!Q){console.warn("Interrupt part missing id",Te);return}try{k==null||k(),await D(Q,!1)}catch(me){console.error("Failed to reject interrupt:",me)}finally{C==null||C()}},[S,C,k,D]),yt=u.jsx(LT,{message:t,isToolMessage:B,showToolMessages:f,toolViewMode:V,isToolStreaming:_e,contentParts:Z,textContent:ge,imageParts:z,fileParts:ae,interruptParts:ie,isStreamingMessage:r,defaultMessage:Y,enableStreamingMarkdownBuffer:ke,handleFileClick:J,uploadingFiles:G,handleInterruptApprove:it,handleInterruptReject:Pt,disableInterruptActions:S,messageRole:E,truncateUserMessages:c,userMessagePreviewLength:d,isUserExpanded:j,setIsUserExpanded:q,isCompactLayout:_,activeInterruptId:bt,activeInterruptValue:It,iconForeground:X}),gt=b.useMemo(()=>Y?"Assistant":Zv(t),[Y,t]),Nt=Ue(),St=E==="user"&&(T??1)>1&&typeof N=="function",Ct=(R==null?void 0:R.length)??0,zt=Ct>0&&I<Ct-1?R[I+1]:void 0,xt=Ct>0&&I>0?R[I-1]:void 0,Oe=b.useCallback(()=>{!zt||!N||N(zt.id,void 0,!!zt.isLatestAttempt)},[zt,N]),Ve=b.useCallback(()=>{!xt||!N||N(xt.id,void 0,!!xt.isLatestAttempt)},[xt,N]);return B&&!f?null:P&&Y?u.jsx("div",{className:re(ut(),m.container),children:u.jsxs("div",{className:re(jt(),m.content),children:[u.jsxs("div",{className:"flex items-center gap-2 mb-2 pb-2 border-b border-current/10",children:[u.jsx(ue.Bot,{className:re("h-4 w-4",X)}),a&&u.jsx("span",{className:"font-medium text-sm",children:"Assistant"})]}),u.jsx(Rr,{content:Y.content,className:"text-current"})]})}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:re(ut(),m.container),children:u.jsxs("div",{className:re(jt(),m.content),children:[u.jsx(HT,{showTimestamp:i,showAgentName:a,isToolMessage:B,iconForeground:X,agentName:gt,messageIcon:Nt,customHeaderClass:m.header,customActionsClass:m.actions,isCompactLayout:_,showActions:s,isEditing:o,messageRole:E,toolViewMode:V,toolMeta:we,onToggleToolView:Fe,onCopy:We,onEdit:ze,onRegenerate:Ke,showCheckpointControls:St,attemptCount:T,attemptIndex:I,handleOlderAttemptSelect:Oe,handleNewerAttemptSelect:Ve,messageCreatedAt:t.createdAt,copied:O}),u.jsx("div",{className:"relative",children:yt}),B&&V==="expanded"&&(we.toolCallId||we.name)&&u.jsxs("div",{className:re("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",_&&"text-xs"),children:[we.name&&u.jsxs("div",{children:["Function: ",we.name]}),we.toolCallId&&u.jsxs("div",{children:["Call ID: ",we.toolCallId]})]}),!(i||a||B)&&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",m.actions),children:[u.jsx(Qe,{variant:"ghost",size:"sm",onClick:()=>We(),className:re("h-6 w-6 p-0 hover:bg-background/50 text-current",_&&"h-5 w-5"),children:u.jsx(ue.Copy,{className:re(O?"text-success":"text-current",_?"h-3 w-3":"h-4 w-4")})}),E==="user"&&g&&u.jsx(Qe,{variant:"ghost",size:"sm",onClick:ze,className:re("h-6 w-6 p-0 hover:bg-background/50 text-current",_&&"h-5 w-5"),children:u.jsx(ue.Edit,{className:re("text-current",_?"h-3 w-3":"h-4 w-4")})}),E==="assistant"&&x&&u.jsx(Qe,{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(ue.RotateCcw,{className:re("text-current",_?"h-3 w-3":"h-4 w-4")})})]})]})}),W&&u.jsx(ip,{isOpen:se,onClose:L,fileId:W.id,fileName:W.name,mimeType:W.mimeType})]})},(e,t)=>{var l,c,d,f,m,h,v,g;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&pu(e.message)===pu(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)===((f=t.customStyles)==null?void 0:f.content)&&((m=e.customStyles)==null?void 0:m.actions)===((h=t.customStyles)==null?void 0:h.actions)&&((v=e.customStyles)==null?void 0:v.header)===((g=t.customStyles)==null?void 0:g.header);if(!o||!s)return!1;const i=mu(e.message),a=mu(t.message);return i.length===a.length});Ys.displayName="MessageComponent";const hl=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:f,style:m,emptyMessage:h,followNewMessages:v=!0,isNavigatingCheckpoint:g=!1,onScrollAway:x,onAtBottom:y,activeInterrupt:w,disableInterruptActions:S=!1,onInterruptActionStart:k,onInterruptActionEnd:C,showToolMessages:T=!0,checkpointIndex:I,activeCheckpointId:N,onSelectCheckpoint:R,createSyntheticThinkingMessage:O=!0,forceSyntheticThinking:$=!1},V)=>{const U=b.useRef(null),j=b.useRef(null),q=b.useRef(!1),K=b.useRef(!1),[D,_]=b.useState(!0),E=b.useMemo(()=>w?e.some(z=>z.role==="default_message"?!1:Array.isArray(z==null?void 0:z.content)&&z.content.some(ae=>ae&&ae.type==="interrupt"&&(ae.id??ae.interrupt_id)===w.id)):!1,[w,e]),B=b.useMemo(()=>{if(!w||E)return null;const z=w.id&&String(w.id).trim()?String(w.id).trim():"pending-interrupt";let ae;const ie=w.value;if(ie&&typeof ie=="object"&&!Array.isArray(ie)){const ge=ie.title;typeof ge=="string"&&ge.trim()&&(ae=ge.trim())}return{id:`interrupt-${z}`,role:"system",createdAt:new Date().toISOString(),content:[{type:"interrupt",id:z,value:ie,title:ae}]}},[w,E]),Y=b.useMemo(()=>B?[...e,B]:e,[e,B]),P=b.useMemo(()=>{const z=n&&Y.some(ie=>ie.id===n);return O&&(t||$)&&!z&&Y.length>0?[...Y,{id:"thinking-assistant",role:"assistant",content:[{type:"text",text:""}],createdAt:new Date().toISOString(),__syntheticStreaming:!0}]:Y},[Y,t,n,O,$]),M=b.useMemo(()=>T?P:P.filter(z=>(z==null?void 0:z.role)!=="tool"),[P,T]),G=b.useCallback(z=>{_(z),x&&x(!z),y&&y(z)},[x,y]),J=b.useMemo(()=>{if(a)return async()=>{if(!q.current){q.current=!0;try{await a()}finally{q.current=!1}}}},[a]),se=b.useMemo(()=>!v||g?!1:D?"auto":!1,[D,v,g]),W=b.useMemo(()=>{if(typeof h!="string")return null;const z=h.trim();return!z||M&&M.length>0?null:{id:"default-message",role:"default_message",content:z,createdAt:new Date().toISOString()}},[h,M]),L=["flex h-full flex-col md:flex-row",f].filter(Boolean).join(" "),X=()=>W?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:W,messageIndex:0,isStreamingMessage:!1,showActions:!1,showTimestamp:!1,showAgentName:!0,layoutSize:o,onEdit:()=>{},onRegenerate:()=>{},onCancelEdit:()=>{}})})}):u.jsx("div",{className:"flex h-full items-center justify-center py-8 text-center text-muted-foreground",children:h??"No messages yet. Start a conversation!"}),ee=M.length,Z=ee>0;return b.useEffect(()=>{var z,ae;if(ee===0){K.current=!1;return}if(!K.current)if(K.current=!0,U.current&&M.length>0){const ie=M.length-1;(ae=(z=U.current).scrollToIndex)==null||ae.call(z,{index:ie,align:"end",behavior:"auto"})}else j.current&&(j.current.scrollTop=j.current.scrollHeight)},[ee,M.length]),b.useImperativeHandle(V,()=>({scrollToLatest:()=>{var z,ae;if(U.current&&M.length>0){const ie=M.length-1;(ae=(z=U.current).scrollToIndex)==null||ae.call(z,{index:ie,align:"end",behavior:"auto"})}else j.current&&(j.current.scrollTop=j.current.scrollHeight)},scrollToTop:()=>{var z,ae;U.current&&M.length>0?(ae=(z=U.current).scrollToIndex)==null||ae.call(z,{index:0,align:"start",behavior:"auto"}):j.current&&(j.current.scrollTop=0)}}),[M]),u.jsx("div",{className:L,style:m,children:u.jsx("div",{className:"relative flex-1 min-h-0",children:Z?u.jsx(LC,{ref:z=>{U.current=z},scrollerRef:z=>{j.current=z instanceof HTMLDivElement?z:null},data:M,followOutput:se,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,startReached:()=>{J&&J()},atBottomStateChange:G,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(z,ae)=>dl(ae,z),itemContent:(z,ae)=>u.jsx(fl,{message:ae,index:z,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,checkpointIndex:I,activeCheckpointId:N,onSelectCheckpoint:R})}):X()})})});hl.displayName="MessageList";const Rp={value:""};function Mr({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,payloadExtras:f={},customStyles:m={},onMessageSent:h,onExcelUploadSuccess:v,onError:g}){const{api:x}=Xr(),{currentThreadId:y}=gr(),{threadId:w,messages:S,isHistoryLoading:k,isLoading:C,navigateToCheckpoint:T,returnToLatest:I,checkpoint:N,checkpoints:R,interrupt:O,metadata:$,checkpointIndex:V}=eo(),{isStreaming:U,error:j,connectionState:q,submit:K,stop:D}=Li(),_=w??y??null,E=(N==null?void 0:N.id)??null,B=(N==null?void 0:N.namespace)??null,Y=($==null?void 0:$.assemblingMessageId)??null,P=O,[M,G]=b.useState(!1),[J,se]=b.useState(!1);b.useEffect(()=>{P||G(!1)},[P]);const W=b.useCallback(()=>{G(!0)},[]),L=b.useCallback(()=>{G(!1)},[]),X=!!P||M,[ee,Z]=b.useState(null),[z,ae]=b.useState(""),[ie,ge]=b.useState(null),[we,Ae]=b.useState(null),[_e,ke]=b.useState([]),[st,bt]=b.useState(0),[It,We]=b.useState(0),[ze,Ke]=b.useState(!1),[Fe,Ue]=b.useState(null),[ut,jt]=b.useState(null),[it,Pt]=b.useState(!1),[yt,gt]=b.useState(null),Nt=b.useRef(!1),[St,Ct]=b.useState(()=>Rp.value),zt=b.useRef(St),xt=b.useRef(null),Oe=b.useCallback(le=>{Rp.value=le,Ct(le)},[]),[Ve,Te]=b.useState(!1),Q=b.useRef(null),me=b.useRef(null),Ze=b.useRef(null),xe=b.useCallback(()=>{me.current&&(me.current.value=""),Ze.current&&(Ze.current.value=""),bt(le=>le+1),We(le=>le+1)},[]),Be=b.useCallback(le=>{Oe(le)},[Oe]),Ge=b.useRef(!1);b.useEffect(()=>{Ge.current&&!U&&(ke([]),xe()),Ge.current=U},[U,xe]),b.useEffect(()=>{U||se(!1)},[U]),b.useEffect(()=>{$!=null&&$.assemblingMessageId&&se(!1)},[$==null?void 0:$.assemblingMessageId]);const[Tt,kt]=b.useState("desktop");b.useEffect(()=>{const le=()=>{const de=window.innerWidth;kt(de<640?"phone":de<1024?"tablet":"desktop")};return le(),window.addEventListener("resize",le),()=>window.removeEventListener("resize",le)},[]),b.useEffect(()=>{Nt.current=!1},[_]),b.useEffect(()=>{zt.current=St},[St]),b.useEffect(()=>{if(!ee){xt.current=null;return}xt.current===null&&(xt.current=zt.current),Oe(z??"")},[z,ee,Oe]),b.useEffect(()=>{(async()=>{if(!x.baseUrl){gt(null);return}try{const Ce=(await x.getAgent("default")).uiDefaultMessage||"";gt(Ce||null)}catch(de){console.warn("Failed to fetch default message:",de),gt(null)}})()},[x.baseUrl]),b.useEffect(()=>{j&&!it&&(g==null||g(j))},[j,it,g]);const At=async le=>{const de=le.trim();if(!(!de&&_e.length===0))try{const Ce=ee?(ie==null?void 0:ie.checkpointId)??E??void 0:E??void 0,De=ee?(ie==null?void 0:ie.checkpointNs)??B??void 0:B??void 0;await K({text:de||"",attachments:_e,payload:f},{checkpointId:Ce,checkpointNs:De,edit:!!ee,originalMessageId:ee??void 0}),h==null||h(de),se(!0),Oe(""),Ae(null),ke([]),xe(),Z(null),ae(""),ge(null)}catch(Ce){const De=(Ce==null?void 0:Ce.message)||"Failed to send message";Ae(De),g==null||g(De),se(!1)}},Lt=b.useCallback((le,de,Ce)=>{c&&(xt.current=St,Z(le),ae(de),Oe(de),Ae(null),ge({checkpointId:(Ce==null?void 0:Ce.checkpointId)??null,checkpointNs:(Ce==null?void 0:Ce.checkpointNs)??null}))},[St,c,Oe]),je=b.useCallback(()=>{Z(null),ae(""),ge(null),Ae(null),Oe(xt.current??St),xt.current=null},[St,Oe]),dt=b.useCallback((le,de,Ce)=>{Lt(le,de,Ce)},[Lt]),Xe=b.useCallback(le=>{let de=null;for(let ft=le-1;ft>=0;ft--)if(S[ft].role==="user"){de=S[ft];break}if(!de)return;const Ce=Array.isArray(de.content)?de.content:[],at=Ce.filter(ft=>(ft==null?void 0:ft.type)==="text").map(ft=>ft.text).join("")||(()=>{try{return JSON.stringify(Ce,null,2)}catch{return String(Ce)}})();at&&K({text:at,payload:f},{checkpointId:E??void 0,checkpointNs:B??void 0,edit:!0,originalMessageId:de.id})},[S,K,E,B,f]),ct=le=>{const de=Array.from(le.target.files||[]);ke(Ce=>[...Ce,...de]),le.target.value=""},an=le=>{ke(de=>{const Ce=de.filter((De,at)=>le!==at);return Ce.length===0&&xe(),Ce})},A=async le=>{const de=(le.target.files||[])[0];if(de){Ue(null),jt(null),Ke(!0);try{await K({attachments:[de],payload:f},{checkpointId:E??void 0,checkpointNs:B??void 0});const Ce=`Uploaded ${de.name} - processing through chat stream`;jt(Ce)}catch(Ce){const De=Ce instanceof Error?Ce.message:"Failed to upload Excel file";console.error("Excel upload failed",Ce),Ue(De),g==null||g(De)}finally{Ke(!1),le.target.value="",xe()}}},te=async le=>{if(y){Te(!0);try{if(!le){await I(),requestAnimationFrame(()=>{var De;(De=Q.current)==null||De.scrollToLatest()});return}const de=R.find(De=>De.checkpointId===le),Ce=(de==null?void 0:de.checkpointNs)??null;await T(le,Ce),requestAnimationFrame(()=>{var De;(De=Q.current)==null||De.scrollToTop()})}finally{Te(!1)}}},fe=b.useCallback(async(le,de,Ce)=>{await te(Ce?null:le)},[te]),Ie=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${m.container||""}`,Ye=`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||""}`,et=`relative flex-shrink-0 w-full border-t p-4 bg-transparent ${m.inputArea||""}`;return u.jsxs("div",{className:Ie,children:[!!j&&!it&&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:j}),u.jsx(Qe,{variant:"ghost",size:"sm",onClick:()=>Pt(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:u.jsx(ue.X,{size:16})})]}),u.jsxs("div",{className:`relative ${Ye}`,style:r?{maxHeight:r}:void 0,children:[u.jsx(hl,{ref:Q,className:"h-full",style:{height:"100%"},messages:S,isStreaming:U,streamingAssistantId:Y,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:Tt,enableMessageEditing:c,editingMessageId:ee,onEdit:dt,onRegenerate:Xe,onCancelEdit:je,emptyMessage:yt??void 0,isNavigatingCheckpoint:Ve,activeInterrupt:P,disableInterruptActions:M,onInterruptActionStart:W,onInterruptActionEnd:L,showToolMessages:d,checkpointIndex:V,activeCheckpointId:E,onSelectCheckpoint:fe,createSyntheticThinkingMessage:!0,forceSyntheticThinking:J}),(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(ue.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(ue.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading messages…"})]}),(k||Ve)&&u.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 bg-background/80 backdrop-blur-sm text-muted-foreground",children:[u.jsx(ue.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading checkpoint…"})]})]}),u.jsxs("div",{className:et,children:[ee&&u.jsx("div",{className:"mb-3 p-3 bg-blue-50 border border-blue-200 rounded-lg",children:u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(ue.Edit3,{size:16,className:"text-blue-600"}),u.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),u.jsx(Qe,{variant:"ghost",size:"sm",onClick:je,className:"text-blue-600 hover:bg-blue-100",children:u.jsx(ue.X,{size:16})})]})}),(a||l)&&u.jsxs("div",{className:"mb-3 space-y-3",children:[a&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:me,type:"file",multiple:!0,onChange:le=>ct(le),className:"hidden"},st),_e.length>0&&u.jsx("div",{className:"flex flex-wrap gap-2",children:_e.map((le,de)=>u.jsxs("div",{className:"flex items-center gap-2 bg-gray-100 dark:bg-gray-800 rounded-lg px-3 py-2 text-sm text-gray-900 dark:text-gray-100",children:[u.jsx(ue.Paperclip,{size:14}),u.jsx("span",{className:"truncate max-w-[150px]",children:le.name}),u.jsx(Qe,{variant:"ghost",size:"sm",onClick:()=>an(de),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 ${le.name}`,children:u.jsx(ue.X,{size:12})})]},de))})]}),l&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:Ze,type:"file",accept:".xls,.xlsx,.xlsm",onChange:A,className:"hidden"},It),ze&&u.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(ue.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),ut&&!ze&&u.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:ut}),Fe&&!ze&&u.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:Fe})]})]}),we&&u.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:we}),u.jsxs("div",{className:"flex items-end gap-2",children:[(a||l)&&u.jsxs(Ss,{children:[u.jsx(Cs,{asChild:!0,children:u.jsx(Qe,{type:"button",size:"icon",variant:"outline",disabled:U||X,title:"More input actions",className:m.moreButton||"",children:u.jsx(ue.Plus,{size:16})})}),u.jsxs(ho,{align:"start",sideOffset:6,className:"w-52",children:[a&&u.jsxs(Bn,{onClick:()=>{var le;return(le=me.current)==null?void 0:le.click()},className:"cursor-pointer",children:[u.jsx(ue.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),l&&u.jsxs(Bn,{onClick:()=>{var le;ze||(le=Ze.current)==null||le.click()},className:`cursor-pointer ${ze?"opacity-60 pointer-events-none":""}`,children:[u.jsx(ue.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),u.jsx("div",{className:"flex-1",children:u.jsx(IS,{initialValue:z,editingMessageId:ee,value:St,onValueChange:Be,placeholder:ee?"Edit your message...":t,isStreaming:U,disabled:X,onSend:At,onCancelEdit:je,onStop:D,allowEmptySend:_e.length>0,textareaClassName:`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${ee?"border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50":""} ${we?"border-red-400":""} ${m.textarea||""}`})})]})]})]})}var Mp=1,UT=.9,WT=.8,VT=.17,pl=.1,ml=.999,KT=.9999,qT=.99,GT=/[\\\/_+.#"@\[\(\{&]/,YT=/[\\\/_+.#"@\[\(\{&]/g,XT=/[\s-]/,Op=/[\s-]/g;function gl(e,t,n,r,o,s,i){if(s===t.length)return o===e.length?Mp:qT;var a=`${o},${s}`;if(i[a]!==void 0)return i[a];for(var l=r.charAt(s),c=n.indexOf(l,o),d=0,f,m,h,v;c>=0;)f=gl(e,t,n,r,c+1,s+1,i),f>d&&(c===o?f*=Mp:GT.test(e.charAt(c-1))?(f*=WT,h=e.slice(o,c-1).match(YT),h&&o>0&&(f*=Math.pow(ml,h.length))):XT.test(e.charAt(c-1))?(f*=UT,v=e.slice(o,c-1).match(Op),v&&o>0&&(f*=Math.pow(ml,v.length))):(f*=VT,o>0&&(f*=Math.pow(ml,c-o))),e.charAt(c)!==t.charAt(s)&&(f*=KT)),(f<pl&&n.charAt(c-1)===r.charAt(s+1)||r.charAt(s+1)===r.charAt(s)&&n.charAt(c-1)!==r.charAt(s))&&(m=gl(e,t,n,r,c+1,s+2,i),m*pl>f&&(f=m*pl)),f>d&&(d=f),c=n.indexOf(l,c+1);return i[a]=d,d}function Dp(e){return e.toLowerCase().replace(Op," ")}function JT(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,gl(e,t,Dp(e),Dp(t),0,0,{})}var Io='[cmdk-group=""]',xl='[cmdk-group-items=""]',ZT='[cmdk-group-heading=""]',Lp='[cmdk-item=""]',$p=`${Lp}:not([aria-disabled="true"])`,vl="cmdk-item-select",Or="data-value",QT=(e,t,n)=>JT(e,t,n),Fp=p.createContext(void 0),No=()=>p.useContext(Fp),Bp=p.createContext(void 0),bl=()=>p.useContext(Bp),zp=p.createContext(void 0),Hp=p.forwardRef((e,t)=>{let n=Dr(()=>{var P,M;return{search:"",value:(M=(P=e.value)!=null?P:e.defaultValue)!=null?M:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=Dr(()=>new Set),o=Dr(()=>new Map),s=Dr(()=>new Map),i=Dr(()=>new Set),a=Up(e),{label:l,children:c,value:d,onValueChange:f,filter:m,shouldFilter:h,loop:v,disablePointerSelection:g=!1,vimBindings:x=!0,...y}=e,w=Rt(),S=Rt(),k=Rt(),C=p.useRef(null),T=uk();cr(()=>{if(d!==void 0){let P=d.trim();n.current.value=P,I.emit()}},[d]),cr(()=>{T(6,U)},[]);let I=p.useMemo(()=>({subscribe:P=>(i.current.add(P),()=>i.current.delete(P)),snapshot:()=>n.current,setState:(P,M,G)=>{var J,se,W,L;if(!Object.is(n.current[P],M)){if(n.current[P]=M,P==="search")V(),O(),T(1,$);else if(P==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let X=document.getElementById(k);X?X.focus():(J=document.getElementById(w))==null||J.focus()}if(T(7,()=>{var X;n.current.selectedItemId=(X=j())==null?void 0:X.id,I.emit()}),G||T(5,U),((se=a.current)==null?void 0:se.value)!==void 0){let X=M??"";(L=(W=a.current).onValueChange)==null||L.call(W,X);return}}I.emit()}},emit:()=>{i.current.forEach(P=>P())}}),[]),N=p.useMemo(()=>({value:(P,M,G)=>{var J;M!==((J=s.current.get(P))==null?void 0:J.value)&&(s.current.set(P,{value:M,keywords:G}),n.current.filtered.items.set(P,R(M,G)),T(2,()=>{O(),I.emit()}))},item:(P,M)=>(r.current.add(P),M&&(o.current.has(M)?o.current.get(M).add(P):o.current.set(M,new Set([P]))),T(3,()=>{V(),O(),n.current.value||$(),I.emit()}),()=>{s.current.delete(P),r.current.delete(P),n.current.filtered.items.delete(P);let G=j();T(4,()=>{V(),(G==null?void 0:G.getAttribute("id"))===P&&$(),I.emit()})}),group:P=>(o.current.has(P)||o.current.set(P,new Set),()=>{s.current.delete(P),o.current.delete(P)}),filter:()=>a.current.shouldFilter,label:l||e["aria-label"],getDisablePointerSelection:()=>a.current.disablePointerSelection,listId:w,inputId:k,labelId:S,listInnerRef:C}),[]);function R(P,M){var G,J;let se=(J=(G=a.current)==null?void 0:G.filter)!=null?J:QT;return P?se(P,n.current.search,M):0}function O(){if(!n.current.search||a.current.shouldFilter===!1)return;let P=n.current.filtered.items,M=[];n.current.filtered.groups.forEach(J=>{let se=o.current.get(J),W=0;se.forEach(L=>{let X=P.get(L);W=Math.max(X,W)}),M.push([J,W])});let G=C.current;q().sort((J,se)=>{var W,L;let X=J.getAttribute("id"),ee=se.getAttribute("id");return((W=P.get(ee))!=null?W:0)-((L=P.get(X))!=null?L:0)}).forEach(J=>{let se=J.closest(xl);se?se.appendChild(J.parentElement===se?J:J.closest(`${xl} > *`)):G.appendChild(J.parentElement===G?J:J.closest(`${xl} > *`))}),M.sort((J,se)=>se[1]-J[1]).forEach(J=>{var se;let W=(se=C.current)==null?void 0:se.querySelector(`${Io}[${Or}="${encodeURIComponent(J[0])}"]`);W==null||W.parentElement.appendChild(W)})}function $(){let P=q().find(G=>G.getAttribute("aria-disabled")!=="true"),M=P==null?void 0:P.getAttribute(Or);I.setState("value",M||void 0)}function V(){var P,M,G,J;if(!n.current.search||a.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let se=0;for(let W of r.current){let L=(M=(P=s.current.get(W))==null?void 0:P.value)!=null?M:"",X=(J=(G=s.current.get(W))==null?void 0:G.keywords)!=null?J:[],ee=R(L,X);n.current.filtered.items.set(W,ee),ee>0&&se++}for(let[W,L]of o.current)for(let X of L)if(n.current.filtered.items.get(X)>0){n.current.filtered.groups.add(W);break}n.current.filtered.count=se}function U(){var P,M,G;let J=j();J&&(((P=J.parentElement)==null?void 0:P.firstChild)===J&&((G=(M=J.closest(Io))==null?void 0:M.querySelector(ZT))==null||G.scrollIntoView({block:"nearest"})),J.scrollIntoView({block:"nearest"}))}function j(){var P;return(P=C.current)==null?void 0:P.querySelector(`${Lp}[aria-selected="true"]`)}function q(){var P;return Array.from(((P=C.current)==null?void 0:P.querySelectorAll($p))||[])}function K(P){let M=q()[P];M&&I.setState("value",M.getAttribute(Or))}function D(P){var M;let G=j(),J=q(),se=J.findIndex(L=>L===G),W=J[se+P];(M=a.current)!=null&&M.loop&&(W=se+P<0?J[J.length-1]:se+P===J.length?J[0]:J[se+P]),W&&I.setState("value",W.getAttribute(Or))}function _(P){let M=j(),G=M==null?void 0:M.closest(Io),J;for(;G&&!J;)G=P>0?lk(G,Io):ck(G,Io),J=G==null?void 0:G.querySelector($p);J?I.setState("value",J.getAttribute(Or)):D(P)}let E=()=>K(q().length-1),B=P=>{P.preventDefault(),P.metaKey?E():P.altKey?_(1):D(1)},Y=P=>{P.preventDefault(),P.metaKey?K(0):P.altKey?_(-1):D(-1)};return p.createElement(ve.div,{ref:t,tabIndex:-1,...y,"cmdk-root":"",onKeyDown:P=>{var M;(M=y.onKeyDown)==null||M.call(y,P);let G=P.nativeEvent.isComposing||P.keyCode===229;if(!(P.defaultPrevented||G))switch(P.key){case"n":case"j":{x&&P.ctrlKey&&B(P);break}case"ArrowDown":{B(P);break}case"p":case"k":{x&&P.ctrlKey&&Y(P);break}case"ArrowUp":{Y(P);break}case"Home":{P.preventDefault(),K(0);break}case"End":{P.preventDefault(),E();break}case"Enter":{P.preventDefault();let J=j();if(J){let se=new Event(vl);J.dispatchEvent(se)}}}}},p.createElement("label",{"cmdk-label":"",htmlFor:N.inputId,id:N.labelId,style:fk},l),Xs(e,P=>p.createElement(Bp.Provider,{value:I},p.createElement(Fp.Provider,{value:N},P))))}),ek=p.forwardRef((e,t)=>{var n,r;let o=Rt(),s=p.useRef(null),i=p.useContext(zp),a=No(),l=Up(e),c=(r=(n=l.current)==null?void 0:n.forceMount)!=null?r:i==null?void 0:i.forceMount;cr(()=>{if(!c)return a.item(o,i==null?void 0:i.id)},[c]);let d=Wp(o,s,[e.value,e.children,s],e.keywords),f=bl(),m=qn(T=>T.value&&T.value===d.current),h=qn(T=>c||a.filter()===!1?!0:T.search?T.filtered.items.get(o)>0:!0);p.useEffect(()=>{let T=s.current;if(!(!T||e.disabled))return T.addEventListener(vl,v),()=>T.removeEventListener(vl,v)},[h,e.onSelect,e.disabled]);function v(){var T,I;g(),(I=(T=l.current).onSelect)==null||I.call(T,d.current)}function g(){f.setState("value",d.current,!0)}if(!h)return null;let{disabled:x,value:y,onSelect:w,forceMount:S,keywords:k,...C}=e;return p.createElement(ve.div,{ref:On(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)}),tk=p.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:o,...s}=e,i=Rt(),a=p.useRef(null),l=p.useRef(null),c=Rt(),d=No(),f=qn(h=>o||d.filter()===!1?!0:h.search?h.filtered.groups.has(i):!0);cr(()=>d.group(i),[]),Wp(i,a,[e.value,e.heading,l]);let m=p.useMemo(()=>({id:i,forceMount:o}),[o]);return p.createElement(ve.div,{ref:On(a,t),...s,"cmdk-group":"",role:"presentation",hidden:f?void 0:!0},n&&p.createElement("div",{ref:l,"cmdk-group-heading":"","aria-hidden":!0,id:c},n),Xs(e,h=>p.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?c:void 0},p.createElement(zp.Provider,{value:m},h))))}),nk=p.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,o=p.useRef(null),s=qn(i=>!i.search);return!n&&!s?null:p.createElement(ve.div,{ref:On(o,t),...r,"cmdk-separator":"",role:"separator"})}),rk=p.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,o=e.value!=null,s=bl(),i=qn(c=>c.search),a=qn(c=>c.selectedItemId),l=No();return p.useEffect(()=>{e.value!=null&&s.setState("search",e.value)},[e.value]),p.createElement(ve.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)}})}),ok=p.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...o}=e,s=p.useRef(null),i=p.useRef(null),a=qn(c=>c.selectedItemId),l=No();return p.useEffect(()=>{if(i.current&&s.current){let c=i.current,d=s.current,f,m=new ResizeObserver(()=>{f=requestAnimationFrame(()=>{let h=c.offsetHeight;d.style.setProperty("--cmdk-list-height",h.toFixed(1)+"px")})});return m.observe(c),()=>{cancelAnimationFrame(f),m.unobserve(c)}}},[]),p.createElement(ve.div,{ref:On(s,t),...o,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":a,"aria-label":r,id:l.listId},Xs(e,c=>p.createElement("div",{ref:On(i,l.listInnerRef),"cmdk-list-sizer":""},c)))}),sk=p.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:o,contentClassName:s,container:i,...a}=e;return p.createElement(Ja,{open:n,onOpenChange:r},p.createElement(Za,{container:i},p.createElement(To,{"cmdk-overlay":"",className:o}),p.createElement(ko,{"aria-label":e.label,"cmdk-dialog":"",className:s},p.createElement(Hp,{ref:t,...a}))))}),ik=p.forwardRef((e,t)=>qn(n=>n.filtered.count===0)?p.createElement(ve.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),ak=p.forwardRef((e,t)=>{let{progress:n,children:r,label:o="Loading...",...s}=e;return p.createElement(ve.div,{ref:t,...s,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":o},Xs(e,i=>p.createElement("div",{"aria-hidden":!0},i)))}),Kt=Object.assign(Hp,{List:ok,Item:ek,Input:rk,Group:tk,Separator:nk,Dialog:sk,Empty:ik,Loading:ak});function lk(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function ck(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function Up(e){let t=p.useRef(e);return cr(()=>{t.current=e}),t}var cr=typeof window>"u"?p.useEffect:p.useLayoutEffect;function Dr(e){let t=p.useRef();return t.current===void 0&&(t.current=e()),t}function qn(e){let t=bl(),n=()=>e(t.snapshot());return p.useSyncExternalStore(t.subscribe,n,n)}function Wp(e,t,n,r=[]){let o=p.useRef(),s=No();return cr(()=>{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(Or,a),o.current=a}),o}var uk=()=>{let[e,t]=p.useState(),n=Dr(()=>new Map);return cr(()=>{n.current.forEach(r=>r()),n.current=new Map},[e]),(r,o)=>{n.current.set(r,o),t({})}};function dk(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function Xs({asChild:e,children:t},n){return e&&p.isValidElement(t)?p.cloneElement(dk(t),{ref:t.ref},n(t.props.children)):n(t)}var fk={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const wl=p.forwardRef(({className:e,...t},n)=>u.jsx(Kt,{ref:n,className:re("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));wl.displayName=Kt.displayName;const yl=p.forwardRef(({className:e,...t},n)=>u.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[u.jsx(ue.Search,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),u.jsx(Kt.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})]}));yl.displayName=Kt.Input.displayName;const Sl=p.forwardRef(({className:e,...t},n)=>u.jsx(Kt.List,{ref:n,className:re("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));Sl.displayName=Kt.List.displayName;const Cl=p.forwardRef((e,t)=>u.jsx(Kt.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));Cl.displayName=Kt.Empty.displayName;const Tl=p.forwardRef(({className:e,...t},n)=>u.jsx(Kt.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}));Tl.displayName=Kt.Group.displayName;const hk=p.forwardRef(({className:e,...t},n)=>u.jsx(Kt.Separator,{ref:n,className:re("-mx-1 h-px bg-border",e),...t}));hk.displayName=Kt.Separator.displayName;const kl=p.forwardRef(({className:e,...t},n)=>u.jsx(Kt.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}));kl.displayName=Kt.Item.displayName;function El(e,[t,n]){return Math.min(n,Math.max(t,e))}function pk(e,t){return p.useReducer((n,r)=>t[n][r]??n,e)}var Il="ScrollArea",[Vp,PN]=cn(Il),[mk,sn]=Vp(Il),Kp=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,l]=p.useState(null),[c,d]=p.useState(null),[f,m]=p.useState(null),[h,v]=p.useState(null),[g,x]=p.useState(null),[y,w]=p.useState(0),[S,k]=p.useState(0),[C,T]=p.useState(!1),[I,N]=p.useState(!1),R=Le(t,$=>l($)),O=Xo(o);return u.jsx(mk,{scope:n,type:r,dir:O,scrollHideDelay:s,scrollArea:a,viewport:c,onViewportChange:d,content:f,onContentChange:m,scrollbarX:h,onScrollbarXChange:v,scrollbarXEnabled:C,onScrollbarXEnabledChange:T,scrollbarY:g,onScrollbarYChange:x,scrollbarYEnabled:I,onScrollbarYEnabledChange:N,onCornerWidthChange:w,onCornerHeightChange:k,children:u.jsx(ve.div,{dir:O,...i,ref:R,style:{position:"relative","--radix-scroll-area-corner-width":y+"px","--radix-scroll-area-corner-height":S+"px",...e.style}})})});Kp.displayName=Il;var qp="ScrollAreaViewport",Gp=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=sn(qp,n),a=p.useRef(null),l=Le(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(ve.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})})]})});Gp.displayName=qp;var In="ScrollAreaScrollbar",Nl=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=sn(In,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:i}=o,a=e.orientation==="horizontal";return p.useEffect(()=>(a?s(!0):i(!0),()=>{a?s(!1):i(!1)}),[a,s,i]),o.type==="hover"?u.jsx(gk,{...r,ref:t,forceMount:n}):o.type==="scroll"?u.jsx(xk,{...r,ref:t,forceMount:n}):o.type==="auto"?u.jsx(Yp,{...r,ref:t,forceMount:n}):o.type==="always"?u.jsx(Al,{...r,ref:t}):null});Nl.displayName=In;var gk=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=sn(In,e.__scopeScrollArea),[s,i]=p.useState(!1);return p.useEffect(()=>{const a=o.scrollArea;let l=0;if(a){const c=()=>{window.clearTimeout(l),i(!0)},d=()=>{l=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",c),a.addEventListener("pointerleave",d),()=>{window.clearTimeout(l),a.removeEventListener("pointerenter",c),a.removeEventListener("pointerleave",d)}}},[o.scrollArea,o.scrollHideDelay]),u.jsx(Wt,{present:n||s,children:u.jsx(Yp,{"data-state":s?"visible":"hidden",...r,ref:t})})}),xk=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=sn(In,e.__scopeScrollArea),s=e.orientation==="horizontal",i=ei(()=>l("SCROLL_END"),100),[a,l]=pk("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return p.useEffect(()=>{if(a==="idle"){const c=window.setTimeout(()=>l("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(c)}},[a,o.scrollHideDelay,l]),p.useEffect(()=>{const c=o.viewport,d=s?"scrollLeft":"scrollTop";if(c){let f=c[d];const m=()=>{const h=c[d];f!==h&&(l("SCROLL"),i()),f=h};return c.addEventListener("scroll",m),()=>c.removeEventListener("scroll",m)}},[o.viewport,s,l,i]),u.jsx(Wt,{present:n||a!=="hidden",children:u.jsx(Al,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:ce(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:ce(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),Yp=p.forwardRef((e,t)=>{const n=sn(In,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=p.useState(!1),a=e.orientation==="horizontal",l=ei(()=>{if(n.viewport){const c=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?c:d)}},10);return Lr(n.viewport,l),Lr(n.content,l),u.jsx(Wt,{present:r||s,children:u.jsx(Al,{"data-state":s?"visible":"hidden",...o,ref:t})})}),Al=p.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=sn(In,e.__scopeScrollArea),s=p.useRef(null),i=p.useRef(0),[a,l]=p.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),c=em(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 f(m,h){return Ck(m,i.current,a,h)}return n==="horizontal"?u.jsx(vk,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollLeft,h=tm(m,a,o.dir);s.current.style.transform=`translate3d(${h}px, 0, 0)`}},onWheelScroll:m=>{o.viewport&&(o.viewport.scrollLeft=m)},onDragScroll:m=>{o.viewport&&(o.viewport.scrollLeft=f(m,o.dir))}}):n==="vertical"?u.jsx(bk,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollTop,h=tm(m,a);s.current.style.transform=`translate3d(0, ${h}px, 0)`}},onWheelScroll:m=>{o.viewport&&(o.viewport.scrollTop=m)},onDragScroll:m=>{o.viewport&&(o.viewport.scrollTop=f(m))}}):null}),vk=p.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=sn(In,e.__scopeScrollArea),[i,a]=p.useState(),l=p.useRef(null),c=Le(t,l,s.onScrollbarXChange);return p.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(Jp,{"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":Qs(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.x),onDragScroll:d=>e.onDragScroll(d.x),onWheelScroll:(d,f)=>{if(s.viewport){const m=s.viewport.scrollLeft+d.deltaX;e.onWheelScroll(m),rm(m,f)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:l.current.clientWidth,paddingStart:Zs(i.paddingLeft),paddingEnd:Zs(i.paddingRight)}})}})}),bk=p.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=sn(In,e.__scopeScrollArea),[i,a]=p.useState(),l=p.useRef(null),c=Le(t,l,s.onScrollbarYChange);return p.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(Jp,{"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":Qs(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.y),onDragScroll:d=>e.onDragScroll(d.y),onWheelScroll:(d,f)=>{if(s.viewport){const m=s.viewport.scrollTop+d.deltaY;e.onWheelScroll(m),rm(m,f)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:l.current.clientHeight,paddingStart:Zs(i.paddingTop),paddingEnd:Zs(i.paddingBottom)}})}})}),[wk,Xp]=Vp(In),Jp=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:l,onDragScroll:c,onWheelScroll:d,onResize:f,...m}=e,h=sn(In,n),[v,g]=p.useState(null),x=Le(t,R=>g(R)),y=p.useRef(null),w=p.useRef(""),S=h.viewport,k=r.content-r.viewport,C=pt(d),T=pt(l),I=ei(f,10);function N(R){if(y.current){const O=R.clientX-y.current.left,$=R.clientY-y.current.top;c({x:O,y:$})}}return p.useEffect(()=>{const R=O=>{const $=O.target;(v==null?void 0:v.contains($))&&C(O,k)};return document.addEventListener("wheel",R,{passive:!1}),()=>document.removeEventListener("wheel",R,{passive:!1})},[S,v,k,C]),p.useEffect(T,[r,T]),Lr(v,I),Lr(h.content,I),u.jsx(wk,{scope:n,scrollbar:v,hasThumb:o,onThumbChange:pt(s),onThumbPointerUp:pt(i),onThumbPositionChange:T,onThumbPointerDown:pt(a),children:u.jsx(ve.div,{...m,ref:x,style:{position:"absolute",...m.style},onPointerDown:ce(e.onPointerDown,R=>{R.button===0&&(R.target.setPointerCapture(R.pointerId),y.current=v.getBoundingClientRect(),w.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",h.viewport&&(h.viewport.style.scrollBehavior="auto"),N(R))}),onPointerMove:ce(e.onPointerMove,N),onPointerUp:ce(e.onPointerUp,R=>{const O=R.target;O.hasPointerCapture(R.pointerId)&&O.releasePointerCapture(R.pointerId),document.body.style.webkitUserSelect=w.current,h.viewport&&(h.viewport.style.scrollBehavior=""),y.current=null})})})}),Js="ScrollAreaThumb",Zp=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Xp(Js,e.__scopeScrollArea);return u.jsx(Wt,{present:n||o.hasThumb,children:u.jsx(yk,{ref:t,...r})})}),yk=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=sn(Js,n),i=Xp(Js,n),{onThumbPositionChange:a}=i,l=Le(t,f=>i.onThumbChange(f)),c=p.useRef(void 0),d=ei(()=>{c.current&&(c.current(),c.current=void 0)},100);return p.useEffect(()=>{const f=s.viewport;if(f){const m=()=>{if(d(),!c.current){const h=Tk(f,a);c.current=h,a()}};return a(),f.addEventListener("scroll",m),()=>f.removeEventListener("scroll",m)}},[s.viewport,d,a]),u.jsx(ve.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:ce(e.onPointerDownCapture,f=>{const h=f.target.getBoundingClientRect(),v=f.clientX-h.left,g=f.clientY-h.top;i.onThumbPointerDown({x:v,y:g})}),onPointerUp:ce(e.onPointerUp,i.onThumbPointerUp)})});Zp.displayName=Js;var jl="ScrollAreaCorner",Qp=p.forwardRef((e,t)=>{const n=sn(jl,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?u.jsx(Sk,{...e,ref:t}):null});Qp.displayName=jl;var Sk=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=sn(jl,n),[s,i]=p.useState(0),[a,l]=p.useState(0),c=!!(s&&a);return Lr(o.scrollbarX,()=>{var f;const d=((f=o.scrollbarX)==null?void 0:f.offsetHeight)||0;o.onCornerHeightChange(d),l(d)}),Lr(o.scrollbarY,()=>{var f;const d=((f=o.scrollbarY)==null?void 0:f.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),c?u.jsx(ve.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 Zs(e){return e?parseInt(e,10):0}function em(e,t){const n=e/t;return isNaN(n)?0:n}function Qs(e){const t=em(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function Ck(e,t,n,r="ltr"){const o=Qs(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,f=r==="ltr"?[0,d]:[d*-1,0];return nm([l,c],f)(e)}function tm(e,t,n="ltr"){const r=Qs(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=El(e,l);return nm([0,i],[0,a])(c)}function nm(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 rm(e,t){return e>0&&e<t}var Tk=(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 ei(e,t){const n=pt(e),r=p.useRef(0);return p.useEffect(()=>()=>window.clearTimeout(r.current),[]),p.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function Lr(e,t){const n=pt(t);Et(()=>{let r=0;if(e){const o=new ResizeObserver(()=>{cancelAnimationFrame(r),r=window.requestAnimationFrame(n)});return o.observe(e),()=>{window.cancelAnimationFrame(r),o.unobserve(e)}}},[e,n])}var om=Kp,kk=Gp,Ek=Qp;const Pl=p.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(om,{ref:r,className:re("relative overflow-hidden",e),...n,children:[u.jsx(kk,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),u.jsx(sm,{}),u.jsx(Ek,{})]}));Pl.displayName=om.displayName;const sm=p.forwardRef(({className:e,orientation:t="vertical",...n},r)=>u.jsx(Nl,{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(Zp,{className:"relative flex-1 rounded-full bg-border"})}));sm.displayName=Nl.displayName;const _l=p.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}));_l.displayName="Input";const Ik="group relative p-3 rounded-lg cursor-pointer transition-colors border text-gray-900 dark:text-slate-100",Nk="bg-slate-700 border-slate-600 hover:bg-slate-600",Ak="bg-slate-600 border-slate-500";function im({thread:e,isActive:t,editingThreadId:n,editingTitle:r,onSelect:o,onStartEditing:s,onEditingTitleChange:i,onSaveEditing:a,onCancelEditing:l,onShare:c,onDelete:d,showEditTitle:f,showDeleteButton:m,formatDate:h,getDisplayThreadTitle:v,secondaryLine:g,itemClassName:x,activeItemClassName:y}){const w=n===e.threadId,S=t?`${y??Ak}`:`${x??Nk}`,k=C=>{C.stopPropagation(),o(e.threadId)};return u.jsxs("div",{onClick:k,className:`${Ik} ${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(_l,{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(Qe,{variant:"ghost",size:"sm",onClick:()=>a(e.threadId),className:"h-6 w-6 p-0",children:u.jsx(ue.Check,{size:12})}),u.jsx(Qe,{variant:"ghost",size:"sm",onClick:l,className:"h-6 w-6 p-0",children:u.jsx(ue.X,{size:12})})]}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"font-medium text-sm truncate text-gray-900 dark:text-slate-100",children:v(e)}),u.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-slate-400 mt-1",children:[u.jsx(ue.Calendar,{size:10}),u.jsx("span",{children:h(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(Qe,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",children:u.jsx(ue.MoreHorizontal,{size:12})})}),u.jsxs(ho,{align:"end",sideOffset:6,className:"w-44",children:[u.jsxs(Bn,{onClick:C=>{C.preventDefault(),c(e.threadId)},children:[u.jsx(ue.Share2,{className:"mr-2 h-4 w-4"}),"Share thread"]}),f&&n!==e.threadId&&u.jsxs(Bn,{onClick:C=>{C.preventDefault(),s(e,C)},children:[u.jsx(ue.Edit3,{className:"mr-2 h-4 w-4"}),"Rename"]}),m&&d&&u.jsxs(Bn,{className:"text-red-400 hover:text-red-300",onClick:C=>{C.preventDefault(),d(e.threadId,C)},children:[u.jsx(ue.Trash2,{className:"mr-2 h-4 w-4"}),"Delete"]})]})]})})]}),t&&u.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-1 h-8 bg-blue-400 rounded-r"})]})}const am=25,lm="thread-manager-view",jk=e=>e==="default"||e==="shared",Pk=()=>{if(typeof window>"u")return null;try{const e=window.localStorage.getItem(lm);if(jk(e))return e}catch{}return null};function cm({defaultView:e}={}){const[t,n]=b.useState(()=>Pk()??e??"default");b.useEffect(()=>{if(!(typeof window>"u"))try{window.localStorage.setItem(lm,t)}catch{}},[t]);const r=b.useCallback(o=>{n(o)},[]);return{view:t,setView:r}}const _k=[{key:"default",label:"My chats"},{key:"shared",label:"Shared with you"}];function ti({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:f,defaultView:m,onViewChange:h,viewOptions:v,viewState:g,showHeader:x=!0,shareTargets:y,isLoadingShareTargets:w,shareTargetFilter:S}){const{threads:k,sharedThreads:C,currentThreadId:T,setCurrentThreadId:I,isLoading:N,isLoadingSharedThreads:R,actions:O,shareInFlight:$,shareStatus:V,clearShareStatus:U}=gr(),{createThread:j,deleteThread:q,renameThread:K,shareThread:D}=O,{loadThread:_}=eo(),E=i??T,[B,Y]=b.useState(Array.isArray(k)?k:[]),P=b.useRef(B.length>0),M=b.useRef(null),G=b.useRef(0),[J,se]=b.useState(null),[W,L]=b.useState(""),[X,ee]=b.useState(!1),[Z,z]=b.useState(!1),[ae,ie]=b.useState(null),[ge,we]=b.useState(""),Ae=v&&v.length>0?v:_k,_e=cm({defaultView:m}),ke=g??_e,st=f??ke.view,bt=b.useCallback(Q=>{f||ke.setView(Q),h==null||h(Q)},[f,h,ke]),It=Ae.find(Q=>Q.key===st)??Ae[0],We=Q=>{ie(Q),we(""),z(!0)},ze=()=>{z(!1),ie(null),we(""),U()},Ke=b.useCallback(async Q=>{if(!(!ae||$)&&Q.id)try{await D(ae,Q.id),setTimeout(()=>ze(),600)}catch(me){console.error("Failed to share thread:",me)}},[ze,$,ae,D]),Fe=b.useMemo(()=>{const Q=y??[],me=ge.trim().toLowerCase();return me?S?Q.filter(Ze=>S(Ze,me)):Q.filter(Ze=>`${Ze.label} ${Ze.secondaryLabel??""}`.toLowerCase().includes(me)):Q},[y,ge,S]),Ue=st==="shared",ut=Ue?C:B,jt=Ue?R:N,it=Ue?"No shared conversations yet":"No conversations yet",Pt=Q=>{const me=Q.sharedAt?` • ${Oe(Q.sharedAt)}`:"";return`Shared by ${Q.sharedByUserId}${me}`},yt=Q=>"sharedByUserId"in Q;b.useEffect(()=>{const Q=Array.isArray(k)?k:[];if(Q.length>0){P.current=!0,Y(Q);return}N||(P.current=!1,Y(Q))},[k,N]),b.useEffect(()=>{if(!M.current)return;const Q=M.current.querySelector("[data-radix-scroll-area-viewport]");if(!Q)return;let me=null,Ze=null;return me=requestAnimationFrame(()=>{Ze=requestAnimationFrame(()=>{Q.scrollTop=G.current})}),()=>{me!==null&&cancelAnimationFrame(me),Ze!==null&&cancelAnimationFrame(Ze)}},[B]);const gt=async Q=>{try{I(Q),await _(Q),a==null||a(Q),l==null||l(Q)}catch(me){console.error("Failed to select thread:",me)}},Nt=async()=>{try{ee(!0);const Q=await j();Q&&(c==null||c(Q),a==null||a(Q))}catch(Q){console.error("Failed to create thread:",Q)}finally{ee(!1)}},St=async(Q,me)=>{if(me.stopPropagation(),!!confirm("Delete this thread?")){if(M.current){const Ze=M.current.querySelector("[data-radix-scroll-area-viewport]");Ze&&(G.current=Ze.scrollTop)}try{await q(Q),d==null||d(Q)}catch(Ze){console.error("Failed to delete thread:",Ze)}}},Ct=(Q,me)=>{me.stopPropagation(),se(Q.threadId),L(Q.title||`Thread ${Q.threadId.slice(0,8)}`)},zt=async Q=>{if(W.trim())try{await K(Q,W.trim()),se(null),L("")}catch(me){console.error("Failed to update title:",me)}},xt=()=>{se(null),L("")},Oe=Q=>{if(!Q)return"";try{const me=new Date(Q),xe=new Date().getTime()-me.getTime(),Be=Math.floor(xe/(1e3*60*60*24));return Be===0?me.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):Be===1?"Yesterday":Be<7?`${Be} days ago`:me.toLocaleDateString()}catch{return""}},Ve=Q=>Q.title||`Thread ${Q.threadId.slice(0,8)}`,Te=Q=>{const me=Ve(Q);return me.length<=am?me:`${me.slice(0,am)}...`};return u.jsxs("div",{className:`flex flex-col h-full ${e} ${s.container||""}`,children:[x&&u.jsxs("div",{className:s.header||"flex flex-col gap-2 px-1 py-0 border border-slate-200 bg-white dark:border-slate-700 dark:bg-slate-900 shadow-sm",children:[t&&u.jsx("div",{className:"flex justify-end",children:u.jsxs(Qe,{onClick:Nt,disabled:X||N,className:s.createButton||"px-3 py-2 gap-1",size:"sm",variant:"ghost",title:X?"Creating...":"New Chat",children:[u.jsx(ue.Edit3,{size:16}),u.jsx("span",{children:"New chat"})]})}),u.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-slate-700 dark:text-slate-200 uppercase tracking-wide leading-tight",children:[u.jsx("span",{children:"Current View"}),u.jsxs(Ss,{children:[u.jsx(Cs,{asChild:!0,children:u.jsx(Qe,{variant:"outline",size:"sm",className:"text-[11px] text-slate-700 dark:text-slate-200 border border-slate-300 dark:border-slate-600 bg-white dark:bg-slate-900 hover:bg-slate-50 dark:hover:bg-slate-800 px-2 py-0",children:It.label})}),u.jsx(ho,{align:"start",sideOffset:6,className:"w-40",children:Ae.map(Q=>u.jsxs(Bn,{className:"justify-between text-[12px]",onClick:me=>{me.preventDefault(),bt(Q.key)},children:[u.jsx("span",{children:Q.label}),st===Q.key&&u.jsx(ue.Check,{className:"h-3 w-3"})]},Q.key))})]})]})]}),u.jsx(Pl,{ref:M,className:`flex-1 min-h-0 ${s.threadList||""}`,style:o?{maxHeight:o}:void 0,children:u.jsx("div",{className:"p-2 space-y-1 pb-4",children:jt?u.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-8 text-slate-400",children:[u.jsx(ue.Loader2,{className:"h-5 w-5 animate-spin"}),u.jsx("span",{className:"text-sm",children:"Loading threads…"})]}):ut.length===0?u.jsxs("div",{className:"text-center py-8 text-slate-400",children:[u.jsx(ue.MessageSquare,{className:"w-8 h-8 mx-auto mb-2 opacity-40 text-slate-500"}),u.jsx("p",{className:"text-sm text-slate-500",children:it})]}):ut.slice().sort((Q,me)=>new Date(me.updatedAt||me.createdAt||"").getTime()-new Date(Q.updatedAt||Q.createdAt||"").getTime()).map(Q=>u.jsx(im,{thread:Q,isActive:E===Q.threadId,editingThreadId:J,editingTitle:W,onSelect:gt,onStartEditing:Ct,onEditingTitleChange:me=>L(me),onSaveEditing:zt,onCancelEditing:xt,onShare:()=>We(Q.threadId),onDelete:St,showEditTitle:r,showDeleteButton:n,formatDate:Oe,getDisplayThreadTitle:Te,secondaryLine:Ue&&yt(Q)?Pt(Q):void 0,itemClassName:s.threadItem,activeItemClassName:s.activeThread},Q.threadId))})}),u.jsx(Qa,{open:Z,onOpenChange:Q=>!Q&&ze(),children:u.jsxs(Bs,{className:"max-w-md p-0",children:[u.jsx(zs,{children:u.jsx(Hs,{children:"Share thread"})}),u.jsxs(wl,{children:[u.jsx(yl,{autoFocus:!0,value:ge,onValueChange:Q=>we(Q),placeholder:"Search for recipients..."}),u.jsxs(Sl,{children:[V&&u.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-xs text-muted-foreground",children:[$&&u.jsx(ue.Loader2,{className:"h-3 w-3 animate-spin"}),u.jsx("span",{className:V.startsWith("Failed")?"text-red-500":V.startsWith("Shared")?"text-emerald-500":"text-slate-600 dark:text-slate-400",children:V})]}),u.jsx(Cl,{children:w?u.jsxs("span",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(ue.Loader2,{className:"h-4 w-4 animate-spin"}),"Loading recipients…"]}):"No matching recipients found"}),Fe.length>0&&u.jsx(Tl,{heading:"Recipients",children:Fe.map(Q=>u.jsx(kl,{onSelect:()=>Ke(Q),children:u.jsxs("div",{className:"flex flex-col items-start text-sm",children:[u.jsx("span",{className:"font-medium",children:Q.label}),Q.secondaryLabel&&u.jsx("span",{className:"text-xs text-muted-foreground",children:Q.secondaryLabel})]})},Q.id))})]})]})]})})]})}function Rk({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(vr,{...s,onThreadChange:l,children:u.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:u.jsx(Mr,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?u.jsx(vr,{...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(ti,{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(Mr,{onError:s.onError,enableFileUpload:!0})})]})})}):u.jsx(vr,{...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(ti,{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(Mr,{onError:s.onError,enableFileUpload:!0})})]})})}function Mk({apiConfig:e,className:t="",onError:n}){return u.jsx(vr,{apiConfig:e,onError:n,children:u.jsx("div",{className:`h-full ${t}`,children:u.jsx(Mr,{})})})}function Ok({placeholder:e,onMessageSent:t}){const[n,r]=b.useState("chat");return u.jsxs("div",{className:"flex flex-col h-full",children:[u.jsxs("div",{className:"flex border-b border-gray-200 bg-gray-50",children:[u.jsx("button",{onClick:()=>r("chat"),className:`flex-1 px-3 py-2 text-sm font-medium transition-colors ${n==="chat"?"border-b-2 border-slate-800 text-slate-800 bg-white":"text-gray-600 hover:text-gray-800"}`,children:u.jsxs("div",{className:"flex items-center justify-center gap-2",children:[u.jsx(ue.MessageSquare,{size:14}),"Chat"]})}),u.jsx("button",{onClick:()=>r("threads"),className:`flex-1 px-3 py-2 text-sm font-medium transition-colors ${n==="threads"?"border-b-2 border-slate-800 text-slate-800 bg-white":"text-gray-600 hover:text-gray-800"}`,children:u.jsxs("div",{className:"flex items-center justify-center gap-2",children:[u.jsx(ue.History,{size:14}),"History"]})})]}),u.jsx("div",{className:"flex-1 min-h-0",children:n==="chat"?u.jsx(Mr,{placeholder:e??"Ask Serti AI anything...",autoFocus:!0,className:"h-full",onMessageSent:t}):u.jsx(ti,{showCreateButton:!0,className:"h-full",onThreadSelect:()=>r("chat")})})]})}function Dk({className:e="",placeholder:t,isAuthenticated:n=!0,onMessageSent:r,widgetTitle:o="Serti AI Navigator",widgetSubtitle:s="AI-Powered Assistant",...i}){const[a,l]=b.useState(!1);return n?u.jsx(vr,{...i,children:u.jsx("div",{className:`fixed bottom-6 right-6 z-[9999] transition-all duration-300 ${e}`,children:u.jsxs("div",{className:`w-96 bg-white rounded-xl shadow-2xl border border-gray-200 overflow-hidden relative ${a?"scale-75":"scale-100"}`,children:[u.jsx("div",{className:"bg-slate-800 text-white p-4 flex-shrink-0",children:u.jsxs("div",{className:"flex items-center justify-between gap-3",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsxs("div",{className:"relative h-10 w-10 rounded-full bg-gradient-to-br from-slate-500 to-slate-700 border border-white/30 flex items-center justify-center text-white text-sm font-bold",children:["S",u.jsx("span",{className:"absolute -bottom-0.5 -right-0.5 h-3 w-3 rounded-full border-2 border-slate-800 bg-emerald-400"})]}),u.jsxs("div",{className:"flex flex-col",children:[u.jsx("h3",{className:"text-lg font-semibold leading-tight",children:o}),u.jsx("p",{className:"text-xs text-white/70",children:s})]}),u.jsx("span",{className:"ml-2 inline-flex items-center justify-center rounded-full bg-red-500 px-2 py-0.5 text-[11px] font-semibold leading-none text-white",children:"1"})]}),u.jsxs("div",{className:"flex items-center gap-1",children:[u.jsx(Qe,{variant:"ghost",size:"sm",className:"text-white hover:bg-white/10 h-8 w-8 p-0",title:"Options",children:u.jsx(ue.MoreHorizontal,{size:16})}),u.jsx(Qe,{variant:"ghost",size:"sm",className:"text-white hover:bg-white/10 h-8 w-8 p-0",title:"Compose",children:u.jsx(ue.Edit3,{size:16})}),u.jsx(Qe,{variant:"ghost",size:"sm",onClick:c=>{c.stopPropagation(),l(d=>!d)},className:"text-white hover:bg-white/10 h-8 w-8 p-0",title:a?"Maximize":"Minimize",children:a?u.jsx(ue.Maximize2,{size:14}):u.jsx(ue.Minimize2,{size:14})})]})]})}),!a&&u.jsx("div",{className:"h-96 flex flex-col",children:u.jsx(Ok,{placeholder:t,onMessageSent:r})})]})})}):null}function Lk({label:e="New chat",children:t,className:n,variant:r="ghost",size:o="sm",...s}){return u.jsxs(Qe,{variant:r,size:o,className:re("gap-2 rounded-full px-3 font-semibold transition-all hover:scale-[1.01]",n),...s,children:[u.jsx(ue.Edit3,{size:16}),t??e]})}var $k="Label",um=p.forwardRef((e,t)=>u.jsx(ve.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())}}));um.displayName=$k;var dm=um;const Fk=zr.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),fm=p.forwardRef(({className:e,...t},n)=>u.jsx(dm,{ref:n,className:re(Fk(),e),...t}));fm.displayName=dm.displayName;function hm(e){const t=p.useRef({value:e,previous:e});return p.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var pm=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"}),Bk="VisuallyHidden",ni=p.forwardRef((e,t)=>u.jsx(ve.span,{...e,ref:t,style:{...pm,...e.style}}));ni.displayName=Bk;var zk=ni,Hk=[" ","Enter","ArrowUp","ArrowDown"],Uk=[" ","Enter"],ur="Select",[ri,oi,Wk]=Yo(ur),[$r,_N]=cn(ur,[Wk,kr]),si=kr(),[Vk,Gn]=$r(ur),[Kk,qk]=$r(ur),mm=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:l,dir:c,name:d,autoComplete:f,disabled:m,required:h,form:v}=e,g=si(t),[x,y]=p.useState(null),[w,S]=p.useState(null),[k,C]=p.useState(!1),T=Xo(c),[I,N]=Dn({prop:r,defaultProp:o??!1,onChange:s,caller:ur}),[R,O]=Dn({prop:i,defaultProp:a,onChange:l,caller:ur}),$=p.useRef(null),V=x?v||!!x.closest("form"):!0,[U,j]=p.useState(new Set),q=Array.from(U).map(K=>K.props.value).join(";");return u.jsx(oa,{...g,children:u.jsxs(Vk,{required:h,scope:t,trigger:x,onTriggerChange:y,valueNode:w,onValueNodeChange:S,valueNodeHasChildren:k,onValueNodeHasChildrenChange:C,contentId:Rt(),value:R,onValueChange:O,open:I,onOpenChange:N,dir:T,triggerPointerDownPosRef:$,disabled:m,children:[u.jsx(ri.Provider,{scope:t,children:u.jsx(Kk,{scope:e.__scopeSelect,onNativeOptionAdd:p.useCallback(K=>{j(D=>new Set(D).add(K))},[]),onNativeOptionRemove:p.useCallback(K=>{j(D=>{const _=new Set(D);return _.delete(K),_})},[]),children:n})}),V?u.jsxs(Fm,{"aria-hidden":!0,required:h,tabIndex:-1,name:d,autoComplete:f,value:R,onChange:K=>O(K.target.value),disabled:m,form:v,children:[R===void 0?u.jsx("option",{value:""}):null,Array.from(U)]},q):null]})})};mm.displayName=ur;var gm="SelectTrigger",xm=p.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=si(n),i=Gn(gm,n),a=i.disabled||r,l=Le(t,i.onTriggerChange),c=oi(n),d=p.useRef("touch"),[f,m,h]=zm(g=>{const x=c().filter(S=>!S.disabled),y=x.find(S=>S.value===i.value),w=Hm(x,g,y);w!==void 0&&i.onValueChange(w.value)}),v=g=>{a||(i.onOpenChange(!0),h()),g&&(i.triggerPointerDownPosRef.current={x:Math.round(g.pageX),y:Math.round(g.pageY)})};return u.jsx(sa,{asChild:!0,...s,children:u.jsx(ve.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":Bm(i.value)?"":void 0,...o,ref:l,onClick:ce(o.onClick,g=>{g.currentTarget.focus(),d.current!=="mouse"&&v(g)}),onPointerDown:ce(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:ce(o.onKeyDown,g=>{const x=f.current!=="";!(g.ctrlKey||g.altKey||g.metaKey)&&g.key.length===1&&m(g.key),!(x&&g.key===" ")&&Hk.includes(g.key)&&(v(),g.preventDefault())})})})});xm.displayName=gm;var vm="SelectValue",bm=p.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=Gn(vm,n),{onValueNodeHasChildrenChange:c}=l,d=s!==void 0,f=Le(t,l.onValueNodeChange);return Et(()=>{c(d)},[c,d]),u.jsx(ve.span,{...a,ref:f,style:{pointerEvents:"none"},children:Bm(l.value)?u.jsx(u.Fragment,{children:i}):s})});bm.displayName=vm;var Gk="SelectIcon",wm=p.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return u.jsx(ve.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});wm.displayName=Gk;var Yk="SelectPortal",ym=e=>u.jsx(so,{asChild:!0,...e});ym.displayName=Yk;var dr="SelectContent",Sm=p.forwardRef((e,t)=>{const n=Gn(dr,e.__scopeSelect),[r,o]=p.useState();if(Et(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?Hr.createPortal(u.jsx(Cm,{scope:e.__scopeSelect,children:u.jsx(ri.Slot,{scope:e.__scopeSelect,children:u.jsx("div",{children:e.children})})}),s):null}return u.jsx(Tm,{...e,ref:t})});Sm.displayName=dr;var mn=10,[Cm,Yn]=$r(dr),Xk="SelectContentImpl",Jk=Yt.createSlot("SelectContent.RemoveScroll"),Tm=p.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:f,collisionBoundary:m,collisionPadding:h,sticky:v,hideWhenDetached:g,avoidCollisions:x,...y}=e,w=Gn(dr,n),[S,k]=p.useState(null),[C,T]=p.useState(null),I=Le(t,W=>k(W)),[N,R]=p.useState(null),[O,$]=p.useState(null),V=oi(n),[U,j]=p.useState(!1),q=p.useRef(!1);p.useEffect(()=>{if(S)return da(S)},[S]),Hi();const K=p.useCallback(W=>{const[L,...X]=V().map(z=>z.ref.current),[ee]=X.slice(-1),Z=document.activeElement;for(const z of W)if(z===Z||(z==null||z.scrollIntoView({block:"nearest"}),z===L&&C&&(C.scrollTop=0),z===ee&&C&&(C.scrollTop=C.scrollHeight),z==null||z.focus(),document.activeElement!==Z))return},[V,C]),D=p.useCallback(()=>K([N,S]),[K,N,S]);p.useEffect(()=>{U&&D()},[U,D]);const{onOpenChange:_,triggerPointerDownPosRef:E}=w;p.useEffect(()=>{if(S){let W={x:0,y:0};const L=ee=>{var Z,z;W={x:Math.abs(Math.round(ee.pageX)-(((Z=E.current)==null?void 0:Z.x)??0)),y:Math.abs(Math.round(ee.pageY)-(((z=E.current)==null?void 0:z.y)??0))}},X=ee=>{W.x<=10&&W.y<=10?ee.preventDefault():S.contains(ee.target)||_(!1),document.removeEventListener("pointermove",L),E.current=null};return E.current!==null&&(document.addEventListener("pointermove",L),document.addEventListener("pointerup",X,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",L),document.removeEventListener("pointerup",X,{capture:!0})}}},[S,_,E]),p.useEffect(()=>{const W=()=>_(!1);return window.addEventListener("blur",W),window.addEventListener("resize",W),()=>{window.removeEventListener("blur",W),window.removeEventListener("resize",W)}},[_]);const[B,Y]=zm(W=>{const L=V().filter(Z=>!Z.disabled),X=L.find(Z=>Z.ref.current===document.activeElement),ee=Hm(L,W,X);ee&&setTimeout(()=>ee.ref.current.focus())}),P=p.useCallback((W,L,X)=>{const ee=!q.current&&!X;(w.value!==void 0&&w.value===L||ee)&&(R(W),ee&&(q.current=!0))},[w.value]),M=p.useCallback(()=>S==null?void 0:S.focus(),[S]),G=p.useCallback((W,L,X)=>{const ee=!q.current&&!X;(w.value!==void 0&&w.value===L||ee)&&$(W)},[w.value]),J=r==="popper"?Rl:km,se=J===Rl?{side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:f,collisionBoundary:m,collisionPadding:h,sticky:v,hideWhenDetached:g,avoidCollisions:x}:{};return u.jsx(Cm,{scope:n,content:S,viewport:C,onViewportChange:T,itemRefCallback:P,selectedItem:N,onItemLeave:M,itemTextRefCallback:G,focusSelectedItem:D,selectedItemText:O,position:r,isPositioned:U,searchRef:B,children:u.jsx(gs,{as:Jk,allowPinchZoom:!0,children:u.jsx(Jo,{asChild:!0,trapped:w.open,onMountAutoFocus:W=>{W.preventDefault()},onUnmountAutoFocus:ce(o,W=>{var L;(L=w.trigger)==null||L.focus({preventScroll:!0}),W.preventDefault()}),children:u.jsx(wr,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:W=>W.preventDefault(),onDismiss:()=>w.onOpenChange(!1),children:u.jsx(J,{role:"listbox",id:w.contentId,"data-state":w.open?"open":"closed",dir:w.dir,onContextMenu:W=>W.preventDefault(),...y,...se,onPlaced:()=>j(!0),ref:I,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:ce(y.onKeyDown,W=>{const L=W.ctrlKey||W.altKey||W.metaKey;if(W.key==="Tab"&&W.preventDefault(),!L&&W.key.length===1&&Y(W.key),["ArrowUp","ArrowDown","Home","End"].includes(W.key)){let ee=V().filter(Z=>!Z.disabled).map(Z=>Z.ref.current);if(["ArrowUp","End"].includes(W.key)&&(ee=ee.slice().reverse()),["ArrowUp","ArrowDown"].includes(W.key)){const Z=W.target,z=ee.indexOf(Z);ee=ee.slice(z+1)}setTimeout(()=>K(ee)),W.preventDefault()}})})})})})})});Tm.displayName=Xk;var Zk="SelectItemAlignedPosition",km=p.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=Gn(dr,n),i=Yn(dr,n),[a,l]=p.useState(null),[c,d]=p.useState(null),f=Le(t,I=>d(I)),m=oi(n),h=p.useRef(!1),v=p.useRef(!0),{viewport:g,selectedItem:x,selectedItemText:y,focusSelectedItem:w}=i,S=p.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&c&&g&&x&&y){const I=s.trigger.getBoundingClientRect(),N=c.getBoundingClientRect(),R=s.valueNode.getBoundingClientRect(),O=y.getBoundingClientRect();if(s.dir!=="rtl"){const Z=O.left-N.left,z=R.left-Z,ae=I.left-z,ie=I.width+ae,ge=Math.max(ie,N.width),we=window.innerWidth-mn,Ae=El(z,[mn,Math.max(mn,we-ge)]);a.style.minWidth=ie+"px",a.style.left=Ae+"px"}else{const Z=N.right-O.right,z=window.innerWidth-R.right-Z,ae=window.innerWidth-I.right-z,ie=I.width+ae,ge=Math.max(ie,N.width),we=window.innerWidth-mn,Ae=El(z,[mn,Math.max(mn,we-ge)]);a.style.minWidth=ie+"px",a.style.right=Ae+"px"}const $=m(),V=window.innerHeight-mn*2,U=g.scrollHeight,j=window.getComputedStyle(c),q=parseInt(j.borderTopWidth,10),K=parseInt(j.paddingTop,10),D=parseInt(j.borderBottomWidth,10),_=parseInt(j.paddingBottom,10),E=q+K+U+_+D,B=Math.min(x.offsetHeight*5,E),Y=window.getComputedStyle(g),P=parseInt(Y.paddingTop,10),M=parseInt(Y.paddingBottom,10),G=I.top+I.height/2-mn,J=V-G,se=x.offsetHeight/2,W=x.offsetTop+se,L=q+K+W,X=E-L;if(L<=G){const Z=$.length>0&&x===$[$.length-1].ref.current;a.style.bottom="0px";const z=c.clientHeight-g.offsetTop-g.offsetHeight,ae=Math.max(J,se+(Z?M:0)+z+D),ie=L+ae;a.style.height=ie+"px"}else{const Z=$.length>0&&x===$[0].ref.current;a.style.top="0px";const ae=Math.max(G,q+g.offsetTop+(Z?P:0)+se)+X;a.style.height=ae+"px",g.scrollTop=L-G+g.offsetTop}a.style.margin=`${mn}px 0`,a.style.minHeight=B+"px",a.style.maxHeight=V+"px",r==null||r(),requestAnimationFrame(()=>h.current=!0)}},[m,s.trigger,s.valueNode,a,c,g,x,y,s.dir,r]);Et(()=>S(),[S]);const[k,C]=p.useState();Et(()=>{c&&C(window.getComputedStyle(c).zIndex)},[c]);const T=p.useCallback(I=>{I&&v.current===!0&&(S(),w==null||w(),v.current=!1)},[S,w]);return u.jsx(eE,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:h,onScrollButtonChange:T,children:u.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:k},children:u.jsx(ve.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});km.displayName=Zk;var Qk="SelectPopperPosition",Rl=p.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=mn,...s}=e,i=si(n);return u.jsx(ia,{...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)"}})});Rl.displayName=Qk;var[eE,Ml]=$r(dr,{}),Ol="SelectViewport",Em=p.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=Yn(Ol,n),i=Ml(Ol,n),a=Le(t,s.onViewportChange),l=p.useRef(0);return u.jsxs(u.Fragment,{children:[u.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),u.jsx(ri.Slot,{scope:n,children:u.jsx(ve.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:ce(o.onScroll,c=>{const d=c.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:m}=i;if(m!=null&&m.current&&f){const h=Math.abs(l.current-d.scrollTop);if(h>0){const v=window.innerHeight-mn*2,g=parseFloat(f.style.minHeight),x=parseFloat(f.style.height),y=Math.max(g,x);if(y<v){const w=y+h,S=Math.min(v,w),k=w-S;f.style.height=S+"px",f.style.bottom==="0px"&&(d.scrollTop=k>0?k:0,f.style.justifyContent="flex-end")}}}l.current=d.scrollTop})})})]})});Em.displayName=Ol;var Im="SelectGroup",[tE,nE]=$r(Im),rE=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Rt();return u.jsx(tE,{scope:n,id:o,children:u.jsx(ve.div,{role:"group","aria-labelledby":o,...r,ref:t})})});rE.displayName=Im;var Nm="SelectLabel",Am=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=nE(Nm,n);return u.jsx(ve.div,{id:o.id,...r,ref:t})});Am.displayName=Nm;var ii="SelectItem",[oE,jm]=$r(ii),Pm=p.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=Gn(ii,n),l=Yn(ii,n),c=a.value===r,[d,f]=p.useState(s??""),[m,h]=p.useState(!1),v=Le(t,w=>{var S;return(S=l.itemRefCallback)==null?void 0:S.call(l,w,r,o)}),g=Rt(),x=p.useRef("touch"),y=()=>{o||(a.onValueChange(r),a.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return u.jsx(oE,{scope:n,value:r,disabled:o,textId:g,isSelected:c,onItemTextChange:p.useCallback(w=>{f(S=>S||((w==null?void 0:w.textContent)??"").trim())},[]),children:u.jsx(ri.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:u.jsx(ve.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:ce(i.onFocus,()=>h(!0)),onBlur:ce(i.onBlur,()=>h(!1)),onClick:ce(i.onClick,()=>{x.current!=="mouse"&&y()}),onPointerUp:ce(i.onPointerUp,()=>{x.current==="mouse"&&y()}),onPointerDown:ce(i.onPointerDown,w=>{x.current=w.pointerType}),onPointerMove:ce(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:ce(i.onPointerLeave,w=>{var S;w.currentTarget===document.activeElement&&((S=l.onItemLeave)==null||S.call(l))}),onKeyDown:ce(i.onKeyDown,w=>{var k;((k=l.searchRef)==null?void 0:k.current)!==""&&w.key===" "||(Uk.includes(w.key)&&y(),w.key===" "&&w.preventDefault())})})})})});Pm.displayName=ii;var Ao="SelectItemText",_m=p.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=Gn(Ao,n),a=Yn(Ao,n),l=jm(Ao,n),c=qk(Ao,n),[d,f]=p.useState(null),m=Le(t,y=>f(y),l.onItemTextChange,y=>{var w;return(w=a.itemTextRefCallback)==null?void 0:w.call(a,y,l.value,l.disabled)}),h=d==null?void 0:d.textContent,v=p.useMemo(()=>u.jsx("option",{value:l.value,disabled:l.disabled,children:h},l.value),[l.disabled,l.value,h]),{onNativeOptionAdd:g,onNativeOptionRemove:x}=c;return Et(()=>(g(v),()=>x(v)),[g,x,v]),u.jsxs(u.Fragment,{children:[u.jsx(ve.span,{id:l.textId,...s,ref:m}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?Hr.createPortal(s.children,i.valueNode):null]})});_m.displayName=Ao;var Rm="SelectItemIndicator",Mm=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return jm(Rm,n).isSelected?u.jsx(ve.span,{"aria-hidden":!0,...r,ref:t}):null});Mm.displayName=Rm;var Dl="SelectScrollUpButton",Om=p.forwardRef((e,t)=>{const n=Yn(Dl,e.__scopeSelect),r=Ml(Dl,e.__scopeSelect),[o,s]=p.useState(!1),i=Le(t,r.onScrollButtonChange);return Et(()=>{if(n.viewport&&n.isPositioned){let a=function(){const c=l.scrollTop>0;s(c)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?u.jsx(Lm,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});Om.displayName=Dl;var Ll="SelectScrollDownButton",Dm=p.forwardRef((e,t)=>{const n=Yn(Ll,e.__scopeSelect),r=Ml(Ll,e.__scopeSelect),[o,s]=p.useState(!1),i=Le(t,r.onScrollButtonChange);return Et(()=>{if(n.viewport&&n.isPositioned){let a=function(){const c=l.scrollHeight-l.clientHeight,d=Math.ceil(l.scrollTop)<c;s(d)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?u.jsx(Lm,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});Dm.displayName=Ll;var Lm=p.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=Yn("SelectScrollButton",n),i=p.useRef(null),a=oi(n),l=p.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return p.useEffect(()=>()=>l(),[l]),Et(()=>{var d;const c=a().find(f=>f.ref.current===document.activeElement);(d=c==null?void 0:c.ref.current)==null||d.scrollIntoView({block:"nearest"})},[a]),u.jsx(ve.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:ce(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:ce(o.onPointerMove,()=>{var c;(c=s.onItemLeave)==null||c.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:ce(o.onPointerLeave,()=>{l()})})}),sE="SelectSeparator",$m=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return u.jsx(ve.div,{"aria-hidden":!0,...r,ref:t})});$m.displayName=sE;var $l="SelectArrow",iE=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=si(n),s=Gn($l,n),i=Yn($l,n);return s.open&&i.position==="popper"?u.jsx(aa,{...o,...r,ref:t}):null});iE.displayName=$l;var aE="SelectBubbleInput",Fm=p.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=p.useRef(null),s=Le(r,o),i=hm(t);return p.useEffect(()=>{const a=o.current;if(!a)return;const l=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(l,"value").set;if(i!==t&&d){const f=new Event("change",{bubbles:!0});d.call(a,t),a.dispatchEvent(f)}},[i,t]),u.jsx(ve.select,{...n,style:{...pm,...n.style},ref:s,defaultValue:t})});Fm.displayName=aE;function Bm(e){return e===""||e===void 0}function zm(e){const t=pt(e),n=p.useRef(""),r=p.useRef(0),o=p.useCallback(i=>{const a=n.current+i;t(a),function l(c){n.current=c,window.clearTimeout(r.current),c!==""&&(r.current=window.setTimeout(()=>l(""),1e3))}(a)},[t]),s=p.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return p.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function Hm(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=lE(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 lE(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var cE=mm,Um=xm,uE=bm,dE=wm,fE=ym,Wm=Sm,hE=Em,Vm=Am,Km=Pm,pE=_m,mE=Mm,qm=Om,Gm=Dm,Ym=$m;const gE=cE,xE=uE,Xm=p.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Um,{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(dE,{asChild:!0,children:u.jsx(ue.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));Xm.displayName=Um.displayName;const Jm=p.forwardRef(({className:e,...t},n)=>u.jsx(qm,{ref:n,className:re("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(ue.ChevronUp,{className:"h-4 w-4"})}));Jm.displayName=qm.displayName;const Zm=p.forwardRef(({className:e,...t},n)=>u.jsx(Gm,{ref:n,className:re("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(ue.ChevronDown,{className:"h-4 w-4"})}));Zm.displayName=Gm.displayName;const Qm=p.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>u.jsx(fE,{children:u.jsxs(Wm,{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(Jm,{}),u.jsx(hE,{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(Zm,{})]})}));Qm.displayName=Wm.displayName;const vE=p.forwardRef(({className:e,...t},n)=>u.jsx(Vm,{ref:n,className:re("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));vE.displayName=Vm.displayName;const eg=p.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(mE,{children:u.jsx(ue.Check,{className:"h-4 w-4"})})}),u.jsx(pE,{children:t})]}));eg.displayName=Km.displayName;const bE=p.forwardRef(({className:e,...t},n)=>u.jsx(Ym,{ref:n,className:re("-mx-1 my-1 h-px bg-muted",e),...t}));bE.displayName=Ym.displayName;var wE="Separator",tg="horizontal",yE=["horizontal","vertical"],ng=p.forwardRef((e,t)=>{const{decorative:n,orientation:r=tg,...o}=e,s=SE(r)?r:tg,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return u.jsx(ve.div,{"data-orientation":s,...a,...o,ref:t})});ng.displayName=wE;function SE(e){return yE.includes(e)}var rg=ng;const og=p.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>u.jsx(rg,{ref:o,decorative:n,orientation:t,className:re("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));og.displayName=rg.displayName;var ai="Switch",[CE,RN]=cn(ai),[TE,kE]=CE(ai),sg=p.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:s,required:i,disabled:a,value:l="on",onCheckedChange:c,form:d,...f}=e,[m,h]=p.useState(null),v=Le(t,S=>h(S)),g=p.useRef(!1),x=m?d||!!m.closest("form"):!0,[y,w]=Dn({prop:o,defaultProp:s??!1,onChange:c,caller:ai});return u.jsxs(TE,{scope:n,checked:y,disabled:a,children:[u.jsx(ve.button,{type:"button",role:"switch","aria-checked":y,"aria-required":i,"data-state":cg(y),"data-disabled":a?"":void 0,disabled:a,value:l,...f,ref:v,onClick:ce(e.onClick,S=>{w(k=>!k),x&&(g.current=S.isPropagationStopped(),g.current||S.stopPropagation())})}),x&&u.jsx(lg,{control:m,bubbles:!g.current,name:r,value:l,checked:y,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});sg.displayName=ai;var ig="SwitchThumb",ag=p.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=kE(ig,n);return u.jsx(ve.span,{"data-state":cg(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});ag.displayName=ig;var EE="SwitchBubbleInput",lg=p.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=p.useRef(null),a=Le(i,s),l=hm(n),c=vd(t);return p.useEffect(()=>{const d=i.current;if(!d)return;const f=window.HTMLInputElement.prototype,h=Object.getOwnPropertyDescriptor(f,"checked").set;if(l!==n&&h){const v=new Event("click",{bubbles:r});h.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}})});lg.displayName=EE;function cg(e){return e?"checked":"unchecked"}var ug=sg,IE=ag;const dg=p.forwardRef(({className:e,...t},n)=>u.jsx(ug,{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(IE,{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")})}));dg.displayName=ug.displayName;const NE=Ja,AE=aT,jE=Za,fg=p.forwardRef(({className:e,...t},n)=>u.jsx(To,{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}));fg.displayName=To.displayName;const PE=zr.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"}}),hg=p.forwardRef(({side:e="right",className:t,children:n,...r},o)=>u.jsxs(jE,{children:[u.jsx(fg,{}),u.jsxs(ko,{ref:o,className:re(PE({side:e}),t),...r,children:[n,u.jsxs(rp,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary",children:[u.jsx(ue.X,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));hg.displayName=ko.displayName;const pg=({className:e,...t})=>u.jsx("div",{className:re("flex flex-col space-y-2 text-center sm:text-left",e),...t});pg.displayName="SheetHeader";const mg=p.forwardRef(({className:e,...t},n)=>u.jsx(ar,{ref:n,className:re("text-lg font-semibold text-foreground",e),...t}));mg.displayName=ar.displayName;const gg=p.forwardRef(({className:e,...t},n)=>u.jsx(Fs,{ref:n,className:re("text-sm text-muted-foreground",e),...t}));gg.displayName=Fs.displayName;var[li,MN]=cn("Tooltip",[kr]),ci=kr(),xg="TooltipProvider",_E=700,Fl="tooltip.open",[RE,Bl]=li(xg),vg=e=>{const{__scopeTooltip:t,delayDuration:n=_E,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:s}=e,i=p.useRef(!0),a=p.useRef(!1),l=p.useRef(0);return p.useEffect(()=>{const c=l.current;return()=>window.clearTimeout(c)},[]),u.jsx(RE,{scope:t,isOpenDelayedRef:i,delayDuration:n,onOpen:p.useCallback(()=>{window.clearTimeout(l.current),i.current=!1},[]),onClose:p.useCallback(()=>{window.clearTimeout(l.current),l.current=window.setTimeout(()=>i.current=!0,r)},[r]),isPointerInTransitRef:a,onPointerInTransitChange:p.useCallback(c=>{a.current=c},[]),disableHoverableContent:o,children:s})};vg.displayName=xg;var jo="Tooltip",[ME,ui]=li(jo),bg=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:s,disableHoverableContent:i,delayDuration:a}=e,l=Bl(jo,e.__scopeTooltip),c=ci(t),[d,f]=p.useState(null),m=Rt(),h=p.useRef(0),v=i??l.disableHoverableContent,g=a??l.delayDuration,x=p.useRef(!1),[y,w]=Dn({prop:r,defaultProp:o??!1,onChange:I=>{I?(l.onOpen(),document.dispatchEvent(new CustomEvent(Fl))):l.onClose(),s==null||s(I)},caller:jo}),S=p.useMemo(()=>y?x.current?"delayed-open":"instant-open":"closed",[y]),k=p.useCallback(()=>{window.clearTimeout(h.current),h.current=0,x.current=!1,w(!0)},[w]),C=p.useCallback(()=>{window.clearTimeout(h.current),h.current=0,w(!1)},[w]),T=p.useCallback(()=>{window.clearTimeout(h.current),h.current=window.setTimeout(()=>{x.current=!0,w(!0),h.current=0},g)},[g,w]);return p.useEffect(()=>()=>{h.current&&(window.clearTimeout(h.current),h.current=0)},[]),u.jsx(oa,{...c,children:u.jsx(ME,{scope:t,contentId:m,open:y,stateAttribute:S,trigger:d,onTriggerChange:f,onTriggerEnter:p.useCallback(()=>{l.isOpenDelayedRef.current?T():k()},[l.isOpenDelayedRef,T,k]),onTriggerLeave:p.useCallback(()=>{v?C():(window.clearTimeout(h.current),h.current=0)},[C,v]),onOpen:k,onClose:C,disableHoverableContent:v,children:n})})};bg.displayName=jo;var zl="TooltipTrigger",wg=p.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=ui(zl,n),s=Bl(zl,n),i=ci(n),a=p.useRef(null),l=Le(t,a,o.onTriggerChange),c=p.useRef(!1),d=p.useRef(!1),f=p.useCallback(()=>c.current=!1,[]);return p.useEffect(()=>()=>document.removeEventListener("pointerup",f),[f]),u.jsx(sa,{asChild:!0,...i,children:u.jsx(ve.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:l,onPointerMove:ce(e.onPointerMove,m=>{m.pointerType!=="touch"&&!d.current&&!s.isPointerInTransitRef.current&&(o.onTriggerEnter(),d.current=!0)}),onPointerLeave:ce(e.onPointerLeave,()=>{o.onTriggerLeave(),d.current=!1}),onPointerDown:ce(e.onPointerDown,()=>{o.open&&o.onClose(),c.current=!0,document.addEventListener("pointerup",f,{once:!0})}),onFocus:ce(e.onFocus,()=>{c.current||o.onOpen()}),onBlur:ce(e.onBlur,o.onClose),onClick:ce(e.onClick,o.onClose)})})});wg.displayName=zl;var OE="TooltipPortal",[ON,DE]=li(OE,{forceMount:void 0}),Fr="TooltipContent",yg=p.forwardRef((e,t)=>{const n=DE(Fr,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...s}=e,i=ui(Fr,e.__scopeTooltip);return u.jsx(Wt,{present:r||i.open,children:i.disableHoverableContent?u.jsx(Sg,{side:o,...s,ref:t}):u.jsx(LE,{side:o,...s,ref:t})})}),LE=p.forwardRef((e,t)=>{const n=ui(Fr,e.__scopeTooltip),r=Bl(Fr,e.__scopeTooltip),o=p.useRef(null),s=Le(t,o),[i,a]=p.useState(null),{trigger:l,onClose:c}=n,d=o.current,{onPointerInTransitChange:f}=r,m=p.useCallback(()=>{a(null),f(!1)},[f]),h=p.useCallback((v,g)=>{const x=v.currentTarget,y={x:v.clientX,y:v.clientY},w=HE(y,x.getBoundingClientRect()),S=UE(y,w),k=WE(g.getBoundingClientRect()),C=KE([...S,...k]);a(C),f(!0)},[f]);return p.useEffect(()=>()=>m(),[m]),p.useEffect(()=>{if(l&&d){const v=x=>h(x,d),g=x=>h(x,l);return l.addEventListener("pointerleave",v),d.addEventListener("pointerleave",g),()=>{l.removeEventListener("pointerleave",v),d.removeEventListener("pointerleave",g)}}},[l,d,h,m]),p.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=!VE(y,i);w?m():S&&(m(),c())};return document.addEventListener("pointermove",v),()=>document.removeEventListener("pointermove",v)}},[l,d,i,c,m]),u.jsx(Sg,{...e,ref:s})}),[$E,FE]=li(jo,{isInside:!1}),BE=Yt.createSlottable("TooltipContent"),Sg=p.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:s,onPointerDownOutside:i,...a}=e,l=ui(Fr,n),c=ci(n),{onClose:d}=l;return p.useEffect(()=>(document.addEventListener(Fl,d),()=>document.removeEventListener(Fl,d)),[d]),p.useEffect(()=>{if(l.trigger){const f=m=>{const h=m.target;h!=null&&h.contains(l.trigger)&&d()};return window.addEventListener("scroll",f,{capture:!0}),()=>window.removeEventListener("scroll",f,{capture:!0})}},[l.trigger,d]),u.jsx(wr,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:f=>f.preventDefault(),onDismiss:d,children:u.jsxs(ia,{"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(BE,{children:r}),u.jsx($E,{scope:n,isInside:!0,children:u.jsx(zk,{id:l.contentId,role:"tooltip",children:o||r})})]})})});yg.displayName=Fr;var Cg="TooltipArrow",zE=p.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=ci(n);return FE(Cg,n).isInside?null:u.jsx(aa,{...o,...r,ref:t})});zE.displayName=Cg;function HE(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 UE(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 WE(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 VE(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,f=l.x,m=l.y;d>r!=m>r&&n<(f-c)*(r-d)/(m-d)+c&&(o=!o)}return o}function KE(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),qE(t)}function qE(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const o=e[r];for(;t.length>=2;){const s=t[t.length-1],i=t[t.length-2];if((s.x-i.x)*(o.y-i.y)>=(s.y-i.y)*(o.x-i.x))t.pop();else break}t.push(o)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const o=e[r];for(;n.length>=2;){const s=n[n.length-1],i=n[n.length-2];if((s.x-i.x)*(o.y-i.y)>=(s.y-i.y)*(o.x-i.x))n.pop();else break}n.push(o)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var GE=vg,YE=bg,XE=wg,Tg=yg;const JE=GE,ZE=YE,QE=XE,kg=p.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(Tg,{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}));kg.displayName=Tg.displayName;var Hl="ToastProvider",[Ul,eI,tI]=Yo("Toast"),[Eg,DN]=cn("Toast",[tI]),[nI,di]=Eg(Hl),Ig=e=>{const{__scopeToast:t,label:n="Notification",duration:r=5e3,swipeDirection:o="right",swipeThreshold:s=50,children:i}=e,[a,l]=p.useState(null),[c,d]=p.useState(0),f=p.useRef(!1),m=p.useRef(!1);return n.trim()||console.error(`Invalid prop \`label\` supplied to \`${Hl}\`. Expected non-empty \`string\`.`),u.jsx(Ul.Provider,{scope:t,children:u.jsx(nI,{scope:t,label:n,duration:r,swipeDirection:o,swipeThreshold:s,toastCount:c,viewport:a,onViewportChange:l,onToastAdd:p.useCallback(()=>d(h=>h+1),[]),onToastRemove:p.useCallback(()=>d(h=>h-1),[]),isFocusedToastEscapeKeyDownRef:f,isClosePausedRef:m,children:i})})};Ig.displayName=Hl;var Ng="ToastViewport",rI=["F8"],Wl="toast.viewportPause",Vl="toast.viewportResume",Ag=p.forwardRef((e,t)=>{const{__scopeToast:n,hotkey:r=rI,label:o="Notifications ({hotkey})",...s}=e,i=di(Ng,n),a=eI(n),l=p.useRef(null),c=p.useRef(null),d=p.useRef(null),f=p.useRef(null),m=Le(t,f,i.onViewportChange),h=r.join("+").replace(/Key/g,"").replace(/Digit/g,""),v=i.toastCount>0;p.useEffect(()=>{const x=y=>{var S;r.length!==0&&r.every(k=>y[k]||y.code===k)&&((S=f.current)==null||S.focus())};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[r]),p.useEffect(()=>{const x=l.current,y=f.current;if(v&&x&&y){const w=()=>{if(!i.isClosePausedRef.current){const T=new CustomEvent(Wl);y.dispatchEvent(T),i.isClosePausedRef.current=!0}},S=()=>{if(i.isClosePausedRef.current){const T=new CustomEvent(Vl);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=p.useCallback(({tabbingDirection:x})=>{const w=a().map(S=>{const k=S.ref.current,C=[k,...gI(k)];return x==="forwards"?C:C.reverse()});return(x==="forwards"?w.reverse():w).flat()},[a]);return p.useEffect(()=>{const x=f.current;if(x){const y=w=>{var C,T,I;const S=w.altKey||w.ctrlKey||w.metaKey;if(w.key==="Tab"&&!S){const N=document.activeElement,R=w.shiftKey;if(w.target===x&&R){(C=c.current)==null||C.focus();return}const V=g({tabbingDirection:R?"backwards":"forwards"}),U=V.findIndex(j=>j===N);Gl(V.slice(U+1))?w.preventDefault():R?(T=c.current)==null||T.focus():(I=d.current)==null||I.focus()}};return x.addEventListener("keydown",y),()=>x.removeEventListener("keydown",y)}},[a,g]),u.jsxs(Db,{ref:l,role:"region","aria-label":o.replace("{hotkey}",h),tabIndex:-1,style:{pointerEvents:v?void 0:"none"},children:[v&&u.jsx(Kl,{ref:c,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"forwards"});Gl(x)}}),u.jsx(Ul.Slot,{scope:n,children:u.jsx(ve.ol,{tabIndex:-1,...s,ref:m})}),v&&u.jsx(Kl,{ref:d,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"backwards"});Gl(x)}})]})});Ag.displayName=Ng;var jg="ToastFocusProxy",Kl=p.forwardRef((e,t)=>{const{__scopeToast:n,onFocusFromOutsideViewport:r,...o}=e,s=di(jg,n);return u.jsx(ni,{tabIndex:0,...o,ref:t,style:{position:"fixed"},onFocus:i=>{var c;const a=i.relatedTarget;!((c=s.viewport)!=null&&c.contains(a))&&r()}})});Kl.displayName=jg;var Po="Toast",oI="toast.swipeStart",sI="toast.swipeMove",iI="toast.swipeCancel",aI="toast.swipeEnd",Pg=p.forwardRef((e,t)=>{const{forceMount:n,open:r,defaultOpen:o,onOpenChange:s,...i}=e,[a,l]=Dn({prop:r,defaultProp:o??!0,onChange:s,caller:Po});return u.jsx(Wt,{present:n||a,children:u.jsx(uI,{open:a,...i,ref:t,onClose:()=>l(!1),onPause:pt(e.onPause),onResume:pt(e.onResume),onSwipeStart:ce(e.onSwipeStart,c=>{c.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:ce(e.onSwipeMove,c=>{const{x:d,y:f}=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",`${f}px`)}),onSwipeCancel:ce(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:ce(e.onSwipeEnd,c=>{const{x:d,y:f}=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",`${f}px`),l(!1)})})})});Pg.displayName=Po;var[lI,cI]=Eg(Po,{onClose(){}}),uI=p.forwardRef((e,t)=>{const{__scopeToast:n,type:r="foreground",duration:o,open:s,onClose:i,onEscapeKeyDown:a,onPause:l,onResume:c,onSwipeStart:d,onSwipeMove:f,onSwipeCancel:m,onSwipeEnd:h,...v}=e,g=di(Po,n),[x,y]=p.useState(null),w=Le(t,j=>y(j)),S=p.useRef(null),k=p.useRef(null),C=o||g.duration,T=p.useRef(0),I=p.useRef(C),N=p.useRef(0),{onToastAdd:R,onToastRemove:O}=g,$=pt(()=>{var q;(x==null?void 0:x.contains(document.activeElement))&&((q=g.viewport)==null||q.focus()),i()}),V=p.useCallback(j=>{!j||j===1/0||(window.clearTimeout(N.current),T.current=new Date().getTime(),N.current=window.setTimeout($,j))},[$]);p.useEffect(()=>{const j=g.viewport;if(j){const q=()=>{V(I.current),c==null||c()},K=()=>{const D=new Date().getTime()-T.current;I.current=I.current-D,window.clearTimeout(N.current),l==null||l()};return j.addEventListener(Wl,K),j.addEventListener(Vl,q),()=>{j.removeEventListener(Wl,K),j.removeEventListener(Vl,q)}}},[g.viewport,C,l,c,V]),p.useEffect(()=>{s&&!g.isClosePausedRef.current&&V(C)},[s,C,g.isClosePausedRef,V]),p.useEffect(()=>(R(),()=>O()),[R,O]);const U=p.useMemo(()=>x?$g(x):null,[x]);return g.viewport?u.jsxs(u.Fragment,{children:[U&&u.jsx(dI,{__scopeToast:n,role:"status","aria-live":r==="foreground"?"assertive":"polite",children:U}),u.jsx(lI,{scope:n,onClose:$,children:Hr.createPortal(u.jsx(Ul.ItemSlot,{scope:n,children:u.jsx(Ob,{asChild:!0,onEscapeKeyDown:ce(a,()=>{g.isFocusedToastEscapeKeyDownRef.current||$(),g.isFocusedToastEscapeKeyDownRef.current=!1}),children:u.jsx(ve.li,{tabIndex:0,"data-state":s?"open":"closed","data-swipe-direction":g.swipeDirection,...v,ref:w,style:{userSelect:"none",touchAction:"none",...e.style},onKeyDown:ce(e.onKeyDown,j=>{j.key==="Escape"&&(a==null||a(j.nativeEvent),j.nativeEvent.defaultPrevented||(g.isFocusedToastEscapeKeyDownRef.current=!0,$()))}),onPointerDown:ce(e.onPointerDown,j=>{j.button===0&&(S.current={x:j.clientX,y:j.clientY})}),onPointerMove:ce(e.onPointerMove,j=>{if(!S.current)return;const q=j.clientX-S.current.x,K=j.clientY-S.current.y,D=!!k.current,_=["left","right"].includes(g.swipeDirection),E=["left","up"].includes(g.swipeDirection)?Math.min:Math.max,B=_?E(0,q):0,Y=_?0:E(0,K),P=j.pointerType==="touch"?10:2,M={x:B,y:Y},G={originalEvent:j,delta:M};D?(k.current=M,fi(sI,f,G,{discrete:!1})):Fg(M,g.swipeDirection,P)?(k.current=M,fi(oI,d,G,{discrete:!1}),j.target.setPointerCapture(j.pointerId)):(Math.abs(q)>P||Math.abs(K)>P)&&(S.current=null)}),onPointerUp:ce(e.onPointerUp,j=>{const q=k.current,K=j.target;if(K.hasPointerCapture(j.pointerId)&&K.releasePointerCapture(j.pointerId),k.current=null,S.current=null,q){const D=j.currentTarget,_={originalEvent:j,delta:q};Fg(q,g.swipeDirection,g.swipeThreshold)?fi(aI,h,_,{discrete:!0}):fi(iI,m,_,{discrete:!0}),D.addEventListener("click",E=>E.preventDefault(),{once:!0})}})})})}),g.viewport)})]}):null}),dI=e=>{const{__scopeToast:t,children:n,...r}=e,o=di(Po,t),[s,i]=p.useState(!1),[a,l]=p.useState(!1);return pI(()=>i(!0)),p.useEffect(()=>{const c=window.setTimeout(()=>l(!0),1e3);return()=>window.clearTimeout(c)},[]),a?null:u.jsx(so,{asChild:!0,children:u.jsx(ni,{...r,children:s&&u.jsxs(u.Fragment,{children:[o.label," ",n]})})})},fI="ToastTitle",_g=p.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(ve.div,{...r,ref:t})});_g.displayName=fI;var hI="ToastDescription",Rg=p.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(ve.div,{...r,ref:t})});Rg.displayName=hI;var Mg="ToastAction",Og=p.forwardRef((e,t)=>{const{altText:n,...r}=e;return n.trim()?u.jsx(Lg,{altText:n,asChild:!0,children:u.jsx(ql,{...r,ref:t})}):(console.error(`Invalid prop \`altText\` supplied to \`${Mg}\`. Expected non-empty \`string\`.`),null)});Og.displayName=Mg;var Dg="ToastClose",ql=p.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e,o=cI(Dg,n);return u.jsx(Lg,{asChild:!0,children:u.jsx(ve.button,{type:"button",...r,ref:t,onClick:ce(e.onClick,o.onClose)})})});ql.displayName=Dg;var Lg=p.forwardRef((e,t)=>{const{__scopeToast:n,altText:r,...o}=e;return u.jsx(ve.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":r||void 0,...o,ref:t})});function $g(e){const t=[];return Array.from(e.childNodes).forEach(r=>{if(r.nodeType===r.TEXT_NODE&&r.textContent&&t.push(r.textContent),mI(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(...$g(r))}}),t}function fi(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?Fi(o,s):o.dispatchEvent(s)}var Fg=(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 pI(e=()=>{}){const t=pt(e);Et(()=>{let n=0,r=0;return n=window.requestAnimationFrame(()=>r=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(n),window.cancelAnimationFrame(r)}},[t])}function mI(e){return e.nodeType===e.ELEMENT_NODE}function gI(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 Gl(e){const t=document.activeElement;return e.some(n=>n===t?!0:(n.focus(),document.activeElement!==t))}var xI=Ig,Bg=Ag,zg=Pg,Hg=_g,Ug=Rg,Wg=Og,Vg=ql;const vI=xI,Kg=p.forwardRef(({className:e,...t},n)=>u.jsx(Bg,{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=Bg.displayName;const bI=zr.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"}}),qg=p.forwardRef(({className:e,variant:t,...n},r)=>u.jsx(zg,{ref:r,className:re(bI({variant:t}),e),...n}));qg.displayName=zg.displayName;const wI=p.forwardRef(({className:e,...t},n)=>u.jsx(Wg,{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}));wI.displayName=Wg.displayName;const Gg=p.forwardRef(({className:e,...t},n)=>u.jsx(Vg,{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(ue.X,{className:"h-4 w-4"})}));Gg.displayName=Vg.displayName;const Yg=p.forwardRef(({className:e,...t},n)=>u.jsx(Hg,{ref:n,className:re("text-sm font-semibold",e),...t}));Yg.displayName=Hg.displayName;const Xg=p.forwardRef(({className:e,...t},n)=>u.jsx(Ug,{ref:n,className:re("text-sm opacity-90",e),...t}));Xg.displayName=Ug.displayName;function yI(){const{toasts:e}=nl();return u.jsxs(vI,{children:[e.map(function({id:t,title:n,description:r,action:o,...s}){return u.jsxs(qg,{...s,children:[u.jsxs("div",{className:"grid gap-1",children:[n&&u.jsx(Yg,{children:n}),r&&u.jsx(Xg,{children:r})]}),o,u.jsx(Gg,{})]},t)}),u.jsx(Kg,{})]})}var SI=(e,t,n,r,o,s,i,a)=>{let l=document.documentElement,c=["light","dark"];function d(h){(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[h]?s[h]:h)):l.setAttribute(v,h)}),f(h)}function f(h){a&&c.includes(h)&&(l.style.colorScheme=h)}function m(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}if(r)d(r);else try{let h=localStorage.getItem(t)||n,v=i&&h==="system"?m():h;d(v)}catch{}},CI=p.createContext(void 0),TI={setTheme:e=>{},themes:[]},kI=()=>{var e;return(e=p.useContext(CI))!=null?e:TI};p.memo(({forcedTheme:e,storageKey:t,attribute:n,enableSystem:r,enableColorScheme:o,defaultTheme:s,value:i,themes:a,nonce:l,scriptProps:c})=>{let d=JSON.stringify([n,t,s,e,a,i,r,o]).slice(1,-1);return p.createElement("script",{...c,suppressHydrationWarning:!0,nonce:typeof window>"u"?l:"",dangerouslySetInnerHTML:{__html:`(${SI.toString()})(${d})`}})});var EI=e=>{switch(e){case"success":return AI;case"info":return PI;case"warning":return jI;case"error":return _I;default:return null}},II=Array(12).fill(0),NI=({visible:e,className:t})=>b.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},b.createElement("div",{className:"sonner-spinner"},II.map((n,r)=>b.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),AI=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"})),jI=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"})),PI=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"})),_I=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"})),RI=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"})),MI=()=>{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},Yl=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:Yl++,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)||Yl++;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}},qt=new OI,DI=(e,t)=>{let n=(t==null?void 0:t.id)||Yl++;return qt.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",$I=DI,FI=()=>qt.toasts,BI=()=>qt.getActiveToasts();Object.assign($I,{success:qt.success,info:qt.info,warning:qt.warning,error:qt.error,custom:qt.custom,message:qt.message,promise:qt.promise,dismiss:qt.dismiss,loading:qt.loading},{getHistory:FI,getToasts:BI});function zI(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))}zI(`: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 hi(e){return e.label!==void 0}var HI=3,UI="32px",WI="16px",Jg=4e3,VI=356,KI=14,qI=20,GI=200;function gn(...e){return e.filter(Boolean).join(" ")}function YI(e){let[t,n]=e.split("-"),r=[];return t&&r.push(t),n&&r.push(n),r}var XI=e=>{var t,n,r,o,s,i,a,l,c,d,f;let{invert:m,toast:h,unstyled:v,interacting:g,setHeights:x,visibleToasts:y,heights:w,index:S,toasts:k,expanded:C,removeToast:T,defaultRichColors:I,closeButton:N,style:R,cancelButtonStyle:O,actionButtonStyle:$,className:V="",descriptionClassName:U="",duration:j,position:q,gap:K,loadingIcon:D,expandByDefault:_,classNames:E,icons:B,closeButtonAriaLabel:Y="Close toast",pauseWhenPageIsHidden:P}=e,[M,G]=b.useState(null),[J,se]=b.useState(null),[W,L]=b.useState(!1),[X,ee]=b.useState(!1),[Z,z]=b.useState(!1),[ae,ie]=b.useState(!1),[ge,we]=b.useState(!1),[Ae,_e]=b.useState(0),[ke,st]=b.useState(0),bt=b.useRef(h.duration||j||Jg),It=b.useRef(null),We=b.useRef(null),ze=S===0,Ke=S+1<=y,Fe=h.type,Ue=h.dismissible!==!1,ut=h.className||"",jt=h.descriptionClassName||"",it=b.useMemo(()=>w.findIndex(xe=>xe.toastId===h.id)||0,[w,h.id]),Pt=b.useMemo(()=>{var xe;return(xe=h.closeButton)!=null?xe:N},[h.closeButton,N]),yt=b.useMemo(()=>h.duration||j||Jg,[h.duration,j]),gt=b.useRef(0),Nt=b.useRef(0),St=b.useRef(0),Ct=b.useRef(null),[zt,xt]=q.split("-"),Oe=b.useMemo(()=>w.reduce((xe,Be,Ge)=>Ge>=it?xe:xe+Be.height,0),[w,it]),Ve=MI(),Te=h.invert||m,Q=Fe==="loading";Nt.current=b.useMemo(()=>it*K+Oe,[it,Oe]),b.useEffect(()=>{bt.current=yt},[yt]),b.useEffect(()=>{L(!0)},[]),b.useEffect(()=>{let xe=We.current;if(xe){let Be=xe.getBoundingClientRect().height;return st(Be),x(Ge=>[{toastId:h.id,height:Be,position:h.position},...Ge]),()=>x(Ge=>Ge.filter(Tt=>Tt.toastId!==h.id))}},[x,h.id]),b.useLayoutEffect(()=>{if(!W)return;let xe=We.current,Be=xe.style.height;xe.style.height="auto";let Ge=xe.getBoundingClientRect().height;xe.style.height=Be,st(Ge),x(Tt=>Tt.find(kt=>kt.toastId===h.id)?Tt.map(kt=>kt.toastId===h.id?{...kt,height:Ge}:kt):[{toastId:h.id,height:Ge,position:h.position},...Tt])},[W,h.title,h.description,x,h.id]);let me=b.useCallback(()=>{ee(!0),_e(Nt.current),x(xe=>xe.filter(Be=>Be.toastId!==h.id)),setTimeout(()=>{T(h)},GI)},[h,T,x,Nt]);b.useEffect(()=>{if(h.promise&&Fe==="loading"||h.duration===1/0||h.type==="loading")return;let xe;return C||g||P&&Ve?(()=>{if(St.current<gt.current){let Be=new Date().getTime()-gt.current;bt.current=bt.current-Be}St.current=new Date().getTime()})():bt.current!==1/0&&(gt.current=new Date().getTime(),xe=setTimeout(()=>{var Be;(Be=h.onAutoClose)==null||Be.call(h,h),me()},bt.current)),()=>clearTimeout(xe)},[C,g,h,Fe,P,Ve,me]),b.useEffect(()=>{h.delete&&me()},[me,h.delete]);function Ze(){var xe,Be,Ge;return B!=null&&B.loading?b.createElement("div",{className:gn(E==null?void 0:E.loader,(xe=h==null?void 0:h.classNames)==null?void 0:xe.loader,"sonner-loader"),"data-visible":Fe==="loading"},B.loading):D?b.createElement("div",{className:gn(E==null?void 0:E.loader,(Be=h==null?void 0:h.classNames)==null?void 0:Be.loader,"sonner-loader"),"data-visible":Fe==="loading"},D):b.createElement(NI,{className:gn(E==null?void 0:E.loader,(Ge=h==null?void 0:h.classNames)==null?void 0:Ge.loader),visible:Fe==="loading"})}return b.createElement("li",{tabIndex:0,ref:We,className:gn(V,ut,E==null?void 0:E.toast,(t=h==null?void 0:h.classNames)==null?void 0:t.toast,E==null?void 0:E.default,E==null?void 0:E[Fe],(n=h==null?void 0:h.classNames)==null?void 0:n[Fe]),"data-sonner-toast":"","data-rich-colors":(r=h.richColors)!=null?r:I,"data-styled":!(h.jsx||h.unstyled||v),"data-mounted":W,"data-promise":!!h.promise,"data-swiped":ge,"data-removed":X,"data-visible":Ke,"data-y-position":zt,"data-x-position":xt,"data-index":S,"data-front":ze,"data-swiping":Z,"data-dismissible":Ue,"data-type":Fe,"data-invert":Te,"data-swipe-out":ae,"data-swipe-direction":J,"data-expanded":!!(C||_&&W),style:{"--index":S,"--toasts-before":S,"--z-index":k.length-S,"--offset":`${X?Ae:Nt.current}px`,"--initial-height":_?"auto":`${ke}px`,...R,...h.style},onDragEnd:()=>{z(!1),G(null),Ct.current=null},onPointerDown:xe=>{Q||!Ue||(It.current=new Date,_e(Nt.current),xe.target.setPointerCapture(xe.pointerId),xe.target.tagName!=="BUTTON"&&(z(!0),Ct.current={x:xe.clientX,y:xe.clientY}))},onPointerUp:()=>{var xe,Be,Ge,Tt;if(ae||!Ue)return;Ct.current=null;let kt=Number(((xe=We.current)==null?void 0:xe.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),At=Number(((Be=We.current)==null?void 0:Be.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),Lt=new Date().getTime()-((Ge=It.current)==null?void 0:Ge.getTime()),je=M==="x"?kt:At,dt=Math.abs(je)/Lt;if(Math.abs(je)>=qI||dt>.11){_e(Nt.current),(Tt=h.onDismiss)==null||Tt.call(h,h),se(M==="x"?kt>0?"right":"left":At>0?"down":"up"),me(),ie(!0),we(!1);return}z(!1),G(null)},onPointerMove:xe=>{var Be,Ge,Tt,kt;if(!Ct.current||!Ue||((Be=window.getSelection())==null?void 0:Be.toString().length)>0)return;let At=xe.clientY-Ct.current.y,Lt=xe.clientX-Ct.current.x,je=(Ge=e.swipeDirections)!=null?Ge:YI(q);!M&&(Math.abs(Lt)>1||Math.abs(At)>1)&&G(Math.abs(Lt)>Math.abs(At)?"x":"y");let dt={x:0,y:0};M==="y"?(je.includes("top")||je.includes("bottom"))&&(je.includes("top")&&At<0||je.includes("bottom")&&At>0)&&(dt.y=At):M==="x"&&(je.includes("left")||je.includes("right"))&&(je.includes("left")&&Lt<0||je.includes("right")&&Lt>0)&&(dt.x=Lt),(Math.abs(dt.x)>0||Math.abs(dt.y)>0)&&we(!0),(Tt=We.current)==null||Tt.style.setProperty("--swipe-amount-x",`${dt.x}px`),(kt=We.current)==null||kt.style.setProperty("--swipe-amount-y",`${dt.y}px`)}},Pt&&!h.jsx?b.createElement("button",{"aria-label":Y,"data-disabled":Q,"data-close-button":!0,onClick:Q||!Ue?()=>{}:()=>{var xe;me(),(xe=h.onDismiss)==null||xe.call(h,h)},className:gn(E==null?void 0:E.closeButton,(o=h==null?void 0:h.classNames)==null?void 0:o.closeButton)},(s=B==null?void 0:B.close)!=null?s:RI):null,h.jsx||b.isValidElement(h.title)?h.jsx?h.jsx:typeof h.title=="function"?h.title():h.title:b.createElement(b.Fragment,null,Fe||h.icon||h.promise?b.createElement("div",{"data-icon":"",className:gn(E==null?void 0:E.icon,(i=h==null?void 0:h.classNames)==null?void 0:i.icon)},h.promise||h.type==="loading"&&!h.icon?h.icon||Ze():null,h.type!=="loading"?h.icon||(B==null?void 0:B[Fe])||EI(Fe):null):null,b.createElement("div",{"data-content":"",className:gn(E==null?void 0:E.content,(a=h==null?void 0:h.classNames)==null?void 0:a.content)},b.createElement("div",{"data-title":"",className:gn(E==null?void 0:E.title,(l=h==null?void 0:h.classNames)==null?void 0:l.title)},typeof h.title=="function"?h.title():h.title),h.description?b.createElement("div",{"data-description":"",className:gn(U,jt,E==null?void 0:E.description,(c=h==null?void 0:h.classNames)==null?void 0:c.description)},typeof h.description=="function"?h.description():h.description):null),b.isValidElement(h.cancel)?h.cancel:h.cancel&&hi(h.cancel)?b.createElement("button",{"data-button":!0,"data-cancel":!0,style:h.cancelButtonStyle||O,onClick:xe=>{var Be,Ge;hi(h.cancel)&&Ue&&((Ge=(Be=h.cancel).onClick)==null||Ge.call(Be,xe),me())},className:gn(E==null?void 0:E.cancelButton,(d=h==null?void 0:h.classNames)==null?void 0:d.cancelButton)},h.cancel.label):null,b.isValidElement(h.action)?h.action:h.action&&hi(h.action)?b.createElement("button",{"data-button":!0,"data-action":!0,style:h.actionButtonStyle||$,onClick:xe=>{var Be,Ge;hi(h.action)&&((Ge=(Be=h.action).onClick)==null||Ge.call(Be,xe),!xe.defaultPrevented&&me())},className:gn(E==null?void 0:E.actionButton,(f=h==null?void 0:h.classNames)==null?void 0:f.actionButton)},h.action.label):null))};function Zg(){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 JI(e,t){let n={};return[e,t].forEach((r,o)=>{let s=o===1,i=s?"--mobile-offset":"--offset",a=s?WI:UI;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 ZI=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:f,duration:m,style:h,visibleToasts:v=HI,toastOptions:g,dir:x=Zg(),gap:y=KI,loadingIcon:w,icons:S,containerAriaLabel:k="Notifications",pauseWhenPageIsHidden:C}=e,[T,I]=b.useState([]),N=b.useMemo(()=>Array.from(new Set([r].concat(T.filter(P=>P.position).map(P=>P.position)))),[T,r]),[R,O]=b.useState([]),[$,V]=b.useState(!1),[U,j]=b.useState(!1),[q,K]=b.useState(d!=="system"?d:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),D=b.useRef(null),_=o.join("+").replace(/Key/g,"").replace(/Digit/g,""),E=b.useRef(null),B=b.useRef(!1),Y=b.useCallback(P=>{I(M=>{var G;return(G=M.find(J=>J.id===P.id))!=null&&G.delete||qt.dismiss(P.id),M.filter(({id:J})=>J!==P.id)})},[]);return b.useEffect(()=>qt.subscribe(P=>{if(P.dismiss){I(M=>M.map(G=>G.id===P.id?{...G,delete:!0}:G));return}setTimeout(()=>{_o.flushSync(()=>{I(M=>{let G=M.findIndex(J=>J.id===P.id);return G!==-1?[...M.slice(0,G),{...M[G],...P},...M.slice(G+1)]:[P,...M]})})})}),[]),b.useEffect(()=>{if(d!=="system"){K(d);return}if(d==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?K("dark"):K("light")),typeof window>"u")return;let P=window.matchMedia("(prefers-color-scheme: dark)");try{P.addEventListener("change",({matches:M})=>{K(M?"dark":"light")})}catch{P.addListener(({matches:G})=>{try{K(G?"dark":"light")}catch(J){console.error(J)}})}},[d]),b.useEffect(()=>{T.length<=1&&V(!1)},[T]),b.useEffect(()=>{let P=M=>{var G,J;o.every(se=>M[se]||M.code===se)&&(V(!0),(G=D.current)==null||G.focus()),M.code==="Escape"&&(document.activeElement===D.current||(J=D.current)!=null&&J.contains(document.activeElement))&&V(!1)};return document.addEventListener("keydown",P),()=>document.removeEventListener("keydown",P)},[o]),b.useEffect(()=>{if(D.current)return()=>{E.current&&(E.current.focus({preventScroll:!0}),E.current=null,B.current=!1)}},[D.current]),b.createElement("section",{ref:t,"aria-label":`${k} ${_}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},N.map((P,M)=>{var G;let[J,se]=P.split("-");return T.length?b.createElement("ol",{key:P,dir:x==="auto"?Zg():x,tabIndex:-1,ref:D,className:a,"data-sonner-toaster":!0,"data-theme":q,"data-y-position":J,"data-lifted":$&&T.length>1&&!s,"data-x-position":se,style:{"--front-toast-height":`${((G=R[0])==null?void 0:G.height)||0}px`,"--width":`${VI}px`,"--gap":`${y}px`,...h,...JI(l,c)},onBlur:W=>{B.current&&!W.currentTarget.contains(W.relatedTarget)&&(B.current=!1,E.current&&(E.current.focus({preventScroll:!0}),E.current=null))},onFocus:W=>{W.target instanceof HTMLElement&&W.target.dataset.dismissible==="false"||B.current||(B.current=!0,E.current=W.relatedTarget)},onMouseEnter:()=>V(!0),onMouseMove:()=>V(!0),onMouseLeave:()=>{U||V(!1)},onDragEnd:()=>V(!1),onPointerDown:W=>{W.target instanceof HTMLElement&&W.target.dataset.dismissible==="false"||j(!0)},onPointerUp:()=>j(!1)},T.filter(W=>!W.position&&M===0||W.position===P).map((W,L)=>{var X,ee;return b.createElement(XI,{key:W.id,icons:S,index:L,toast:W,defaultRichColors:f,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:(ee=g==null?void 0:g.closeButton)!=null?ee:i,interacting:U,position:P,style:g==null?void 0:g.style,unstyled:g==null?void 0:g.unstyled,classNames:g==null?void 0:g.classNames,cancelButtonStyle:g==null?void 0:g.cancelButtonStyle,actionButtonStyle:g==null?void 0:g.actionButtonStyle,removeToast:Y,toasts:T.filter(Z=>Z.position==W.position),heights:R.filter(Z=>Z.position==W.position),setHeights:O,expandByDefault:s,gap:y,loadingIcon:w,expanded:$,pauseWhenPageIsHidden:C,swipeDirections:e.swipeDirections})})):null}))});const QI=({...e})=>{const{theme:t="system"}=kI();return u.jsx(ZI,{theme:t,className:"toaster group",toastOptions:{classNames:{toast:"group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",description:"group-[.toast]:text-muted-foreground",actionButton:"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",cancelButton:"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground"}},...e})};F.Api=Fv,F.ApiClient=$v,F.ApiProvider=tu,F.ArtifactRenderer=Cp,F.Badge=_p,F.Button=Qe,F.Card=sl,F.CardContent=cl,F.CardDescription=ll,F.CardHeader=il,F.CardTitle=al,F.ChatApi=Ko,F.ChatApp=Rk,F.ChatInput=Hf,F.ChatInterface=Mr,F.ChatProviders=vr,F.ChatWidget=Dk,F.Command=wl,F.CommandEmpty=Cl,F.CommandGroup=Tl,F.CommandInput=yl,F.CommandItem=kl,F.CommandList=Sl,F.DEFAULT_TIMEOUT_MS=Yc,F.Dialog=Qa,F.DialogContent=Bs,F.DialogHeader=zs,F.DialogTitle=Hs,F.DropdownMenu=Ss,F.DropdownMenuContent=ho,F.DropdownMenuItem=Bn,F.DropdownMenuTrigger=Cs,F.FileViewerModal=ip,F.HISTORY_TIMEOUT_MS=Xc,F.Input=_l,F.InterruptPartRenderer=kp,F.Label=fm,F.MarkdownContent=Rr,F.MessageComponent=Ys,F.MessageList=hl,F.MessageRow=fl,F.NewChatButton=Lk,F.PlotArtifact=wp,F.ResearchTaskArtifact=Sp,F.SETTINGS_STORAGE_KEY=$i,F.ScrollArea=Pl,F.Select=gE,F.SelectContent=Qm,F.SelectItem=eg,F.SelectTrigger=Xm,F.SelectValue=xE,F.Separator=og,F.Sheet=NE,F.SheetContent=hg,F.SheetDescription=gg,F.SheetHeader=pg,F.SheetTitle=mg,F.SheetTrigger=AE,F.SimpleChat=Mk,F.SimpleJsonView=ul,F.Sonner=QI,F.StreamProgress=Ep,F.Switch=dg,F.Textarea=Ta,F.ThinkingIndicator=Ip,F.ThreadListItem=im,F.ThreadManager=ti,F.ThreadStateProvider=Tu,F.ThreadsProvider=fu,F.TimelineColumn=mx,F.Toaster=yI,F.ToolComponent=Ap,F.Tooltip=ZE,F.TooltipContent=kg,F.TooltipProvider=JE,F.TooltipTrigger=QE,F.UserTextContent=Np,F.applySettings=bb,F.buildCheckpointIndex=Ql,F.buildCheckpointPreviewMap=ox,F.chatApiClient=Mn,F.del=Ai,F.downloadFileById=Zc,F.extractConfigFields=mi,F.fileToBase64=nu,F.get=Jt,F.getChatToken=qc,F.getCheckpointForMessage=sx,F.getCurrentSettings=vb,F.getDefaultApiConfig=Ru,F.getDefaultChatSettings=Mu,F.getFileContent=Pi,F.getFileInfo=zv,F.getMessageAttemptInfo=ec,F.getMessageDomKey=dl,F.getPreviewForMessage=pi,F.httpClient=Xt,F.hydrateHistorySnapshots=Rn,F.isEnvelope=ou,F.listFiles=Qc,F.loadStoredSettings=Ou,F.onChatTokenChanged=Gc,F.post=Vo,F.processAttachments=ru,F.put=Jc,F.readNumber=nc,F.readString=_n,F.resolveChatBaseUrl=vn,F.saveSettings=Du,F.setChatToken=Wo,F.toPlainObject=Pn,F.unwrap=$t,F.useApi=Xr,F.useCheckpointIndex=tc,F.useFilePreview=jp,F.useHasChatSession=mb,F.useParsedMessageContent=Pp,F.useShallowStableValue=Au,F.useStream=Li,F.useStreamingHook=Li,F.useThreadHistoryState=wu,F.useThreadManagerViewState=cm,F.useThreadState=eo,F.useThreadStateUpdater=Cu,F.useThreads=gr,F.useThreadsState=uu,F.viewFileById=Bv,Object.defineProperty(F,Symbol.toStringTag,{value:"Module"})});
|