teodor-new-chat-ui 4.3.507 → 4.3.509
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/features/messaging/components/message/ToolComponent.d.ts +3 -1
- package/dist/features/messaging/components/message/renderers/MessageContent.d.ts +2 -1
- package/dist/features/messaging/components/message/renderers/MessageHeader.d.ts +4 -1
- package/dist/index.esm.js +4672 -4663
- package/dist/index.umd.js +39 -39
- package/package.json +1 -1
package/dist/index.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(z,w){typeof exports=="object"&&typeof module<"u"?w(exports,require("react"),require("@radix-ui/react-slot"),require("class-variance-authority"),require("clsx"),require("tailwind-merge"),require("lucide-react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","@radix-ui/react-slot","class-variance-authority","clsx","tailwind-merge","lucide-react","react-dom"],w):(z=typeof globalThis<"u"?globalThis:z||self,w(z.NewChatUI={},z.React,z.reactSlot,z.classVarianceAuthority,z.clsx,z.tailwindMerge,z.LucideReact,z.ReactDOM))})(this,function(z,w,qt,Kr,wx,bx,le,Lo){"use strict";var mN=Object.defineProperty;var gN=(z,w,qt)=>w in z?mN(z,w,{enumerable:!0,configurable:!0,writable:!0,value:qt}):z[w]=qt;var xx=(z,w,qt)=>gN(z,typeof w!="symbol"?w+"":w,qt);var gx;var yi=typeof document<"u"?document.currentScript:null;function ic(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const h=ic(w),qr=ic(Lo),ac=120;function yx(e){if(!Array.isArray(e))return"";const t=e.filter(r=>!!(r&&r.type==="text")).map(r=>(r.text??"").trim()).filter(Boolean);if(!t.length)return"";const n=t.join(" ").replace(/\s+/g," ").trim();return n?n.length>ac?`${n.slice(0,ac-3)}…`:n:""}function Si(e){return yx(e.content)||""}function Sx(e){var n;const t=new Map;for(const r of e){if(!r.checkpointId)continue;const o=(n=r.messages)==null?void 0:n.find(s=>s.role==="user");if(o){const s=Si(o);s&&t.set(r.checkpointId,s)}}return t}function lc(e){const t=new Map,n=[],r=new Map,o=[];for(let c=0;c<e.length;c++){const d=e[c],p=d.checkpointId,m=p??`cp-${c}`,f=d.metadata??{},v=typeof f.step=="number"?f.step:null,g=typeof f.source=="string"?f.source:null;let x=null,y=null;const b=Array.isArray(d.messages)?d.messages:[];for(const T of b)T.role==="user"&&(y||(y=T),T.id&&(x=T.id));const C=d.next&&d.next.length>0?String(d.next[0]):null,k=d.parentConfig??null,S={id:m,step:v,source:g,createdAt:d.createdAt??null,namespace:d.checkpointNs??null,parentId:d.parentId??null,next:C,parentConfig:k,userMessageId:x};if(o.push(S),p&&t.set(p,S),p&&y){const T=Si(y);T&&r.set(p,T)}n.push({id:m,messageId:x,step:v,source:g,createdAt:d.createdAt??null,next:C,parentConfig:k})}const s=new Map;for(const c of o){if(!c.userMessageId)continue;const d=s.get(c.userMessageId)??[];d.push(c),s.set(c.userMessageId,d)}for(const c of s.values()){if(!c.length)continue;c.sort((p,m)=>{const f=p.createdAt?Date.parse(p.createdAt):0;return(m.createdAt?Date.parse(m.createdAt):0)-f});const d=c.length;for(let p=0;p<c.length;p++){const m=c[p];m.attemptCount=d,m.attemptIndex=p,m.isLatestAttempt=p===0}}return{checkpoints:e,checkpointMetaByCheckpointId:t,timeline:n,messagePreviews:r,getLatest:()=>{const c=n[0];if(c)return t.get(c.id)},getCheckpoint:c=>t.get(c),getMessageAttempts:c=>{const d=[];for(const p of t.values())p.userMessageId===c&&d.push(p);return d.length?(d.sort((p,m)=>{const f=typeof p.attemptIndex=="number"?p.attemptIndex:Number.MAX_SAFE_INTEGER,v=typeof m.attemptIndex=="number"?m.attemptIndex:Number.MAX_SAFE_INTEGER;return f-v}),d):[]}}}function cc(e,t,n){if(!e)return{attemptCount:1,attemptIndex:0,attempts:[]};const r=n.getMessageAttempts(e);if(!r.length)return{attemptCount:1,attemptIndex:0,attempts:[]};let o=0;if(t){const s=r.findIndex(i=>i.id===t);s>=0&&(o=s)}return{attemptCount:r.length,attemptIndex:o,attempts:r}}function Cx(e,t){return e?t.getCheckpoint(e)??null:null}function uc(e){return w.useMemo(()=>lc(e),[e])}function _n(e){if(!(!e||typeof e!="object"||Array.isArray(e)))return{...e}}function Rn(e,t){if(e)for(const n of t){const r=e[n];if(typeof r=="string"&&r.trim())return r.trim()}}function dc(e,t){if(!e)return null;for(const n of t){const r=e[n];if(typeof r=="number"&&Number.isFinite(r))return r}return null}function Ci(e){const t=_n(e);if(t)return _n(t.configurable)??t}const Tx={},xr=typeof{url:typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:yi&&yi.tagName.toUpperCase()==="SCRIPT"&&yi.src||new URL("index.umd.js",document.baseURI).href}<"u"?Tx:void 0,Gr=!(((gx=xr==null?void 0:xr.VITE_DEBUG_HISTORY_INTERRUPTS)==null?void 0:gx.toLowerCase())==="false"||(xr==null?void 0:xr.VITE_DEBUG_HISTORY_INTERRUPTS)==="0");function Yn(e){const r=[...(Array.isArray(e==null?void 0:e.checkpoints)?(e==null?void 0:e.checkpoints)??[]:e!=null&&e.checkpoints?Object.values(e.checkpoints):[]).map((s,i)=>kx(s,i)).filter(s=>!!s)].sort((s,i)=>fc(i.createdAt)-fc(s.createdAt)),o=r[0]??null;return{threadId:(e==null?void 0:e.threadId)??"",latest:o,checkpoints:r,interrupt:(o==null?void 0:o.interrupt)??null}}function kx(e,t){var S,T;if(!e)return null;const r=(Array.isArray((S=e.values)==null?void 0:S.messages)?e.values.messages:[]).map(E=>Ex(E)).filter(E=>!!E),o=_n(e.metadata)??{},s=Ci(e.config),i=_n(e.parent_config??e.parentConfig),a=Ci(i),l=Rn(s,["checkpoint_id","checkpointId"]),c=Rn(s,["checkpoint_ns","checkpointNs"]),d=Rn(a,["checkpoint_id","checkpointId"]),p=Rn(a,["checkpoint_id","checkpointId"])??null,m=Rn(a,["checkpoint_ns","checkpointNs"])??null,f=_n(e.config),v=Array.isArray(e.tasks)?e.tasks.map(E=>({...E})):e.tasks??null,g=Array.isArray(e.next)?[...e.next]:e.next??null,x=typeof e.created_at=="string"&&e.created_at.trim()?e.created_at:typeof e.createdAt=="string"&&e.createdAt.trim()?e.createdAt:new Date(Date.now()-t).toISOString(),y={...o,step:dc(o,["step"])??0,source:Rn(o,["source"])??null},b=r.map(E=>({...E,checkpointId:l??null})),C=(T=e.values)==null?void 0:T.interrupts,k=Array.isArray(e.interrupts)?e.interrupts:Array.isArray(C)?C:[];return{checkpointId:l??null,checkpointNs:c??null,createdAt:x,parentId:d??null,messages:b,nextCursor:p,nextCursorNs:m,interrupt:Px(r,k,t,l??null,c??null),metadata:y,config:f??null,parentConfig:i??null,next:g,tasks:v}}function Ex(e){var s,i,a;if(!e||typeof e!="object")return null;const t=Ix(e);if(!t)return null;const n=Ax(e==null?void 0:e.content);if(!n.length)return null;const r=typeof e.createdAt=="string"?e.createdAt:typeof((s=e.additional_kwargs)==null?void 0:s.created_at)=="string"?(i=e.additional_kwargs)==null?void 0:i.created_at:new Date().toISOString();return{id:typeof e.id=="string"&&e.id.trim()?e.id:`msg-${Date.now().toString(16)}-${Math.random().toString(16).slice(2)}`,role:t,name:typeof e.name=="string"?e.name:void 0,model:typeof e.model=="string"?e.model:((a=e.additional_kwargs)==null?void 0:a.model)??void 0,createdAt:r,content:n,additionalKwargs:e.additional_kwargs??void 0,responseMetadata:e.response_metadata??void 0,artifact:e.artifact??void 0,threadId:e.threadId??e.thread_id}}function Ix(e){const t=typeof e.role=="string"?e.role:void 0;if(t&&Nx(t))return t;const n=typeof e.type=="string"?e.type:void 0;if(!n)return null;switch(n){case"human":return"user";case"ai":return"assistant";case"tool":return"tool";case"system":return"system";default:return null}}function Nx(e){return e==="assistant"||e==="user"||e==="system"||e==="tool"||e==="default_message"}function Ax(e){return typeof e=="string"?[{type:"text",text:e}]:Array.isArray(e)?e.filter(t=>!!(t&&typeof t=="object"&&typeof t.type=="string")):[]}function Px(e,t,n,r,o){const s=t.length,i=jx(e,n);if(Gr&&console.debug("[historyUtils] deriveInterruptFromSnapshot",{checkpointId:r,checkpointNs:o,fallbackIndex:n,messageCount:e.length,rawInterruptCount:s,messageInterrupt:i,rawInterrupts:t.slice(Math.max(0,s-3))}),i)return Gr&&console.debug("[historyUtils] interrupt found in messages",i),i;for(let a=s-1;a>=0;a-=1){const l=t[a];if(!l||typeof l!="object"){Gr&&console.debug("[historyUtils] skipping invalid raw interrupt entry",{entry:l,index:a});continue}const c=l,d=c.value??l;if(d==null){Gr&&console.debug("[historyUtils] skipping raw interrupt without value",{entry:l,index:a});continue}const m={id:typeof c.id=="string"&&c.id.trim()?c.id:`interrupt-${r??n}-${a}`,value:d};return Gr&&console.debug("[historyUtils] interrupt derived from raw entry",m),m}return null}function jx(e,t){var n;for(let r=e.length-1;r>=0;r--){const o=((n=e[r])==null?void 0:n.content)??[];for(let s=o.length-1;s>=0;s--){const i=o[s];if((i==null?void 0:i.type)==="interrupt"){const a=i;return{id:typeof a.id=="string"&&a.id.trim()?a.id:`interrupt-${t}-${r}-${s}`,value:a.value}}}}return null}function fc(e){if(!e)return 0;const t=Date.parse(e);return Number.isFinite(t)?t:0}var Ti={exports:{}},Yr={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.min.js
|
|
4
4
|
*
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var pc;function _x(){if(pc)return Yr;pc=1;var e=w,t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,o=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function i(a,c
|
|
9
|
+
*/var pc;function _x(){if(pc)return Yr;pc=1;var e=w,t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,o=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function i(a,l,c){var d,p={},m=null,f=null;c!==void 0&&(m=""+c),l.key!==void 0&&(m=""+l.key),l.ref!==void 0&&(f=l.ref);for(d in l)r.call(l,d)&&!s.hasOwnProperty(d)&&(p[d]=l[d]);if(a&&a.defaultProps)for(d in l=a.defaultProps,l)p[d]===void 0&&(p[d]=l[d]);return{$$typeof:t,type:a,key:m,ref:f,props:p,_owner:o.current}}return Yr.Fragment=n,Yr.jsx=i,Yr.jsxs=i,Yr}var Xr={};/**
|
|
10
10
|
* @license React
|
|
11
11
|
* react-jsx-runtime.development.js
|
|
12
12
|
*
|
|
@@ -14,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 hc;function Rx(){return hc||(hc=1,process.env.NODE_ENV!=="production"&&function(){var e=w,t=Symbol.for("react.element"),n=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),a=Symbol.for("react.context"),
|
|
18
|
-
`+
|
|
19
|
-
`),Ft=
|
|
20
|
-
`),
|
|
21
|
-
`+
|
|
17
|
+
*/var hc;function Rx(){return hc||(hc=1,process.env.NODE_ENV!=="production"&&function(){var e=w,t=Symbol.for("react.element"),n=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),a=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),p=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),f=Symbol.for("react.offscreen"),v=Symbol.iterator,g="@@iterator";function x(N){if(N===null||typeof N!="object")return null;var X=v&&N[v]||N[g];return typeof X=="function"?X:null}var y=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function b(N){{for(var X=arguments.length,re=new Array(X>1?X-1:0),fe=1;fe<X;fe++)re[fe-1]=arguments[fe];C("error",N,re)}}function C(N,X,re){{var fe=y.ReactDebugCurrentFrame,De=fe.getStackAddendum();De!==""&&(X+="%s",re=re.concat([De]));var Le=re.map(function(We){return String(We)});Le.unshift("Warning: "+X),Function.prototype.apply.call(console[N],console,Le)}}var k=!1,S=!1,T=!1,E=!1,A=!1,P;P=Symbol.for("react.module.reference");function $(N){return!!(typeof N=="string"||typeof N=="function"||N===r||N===s||A||N===o||N===c||N===d||E||N===f||k||S||T||typeof N=="object"&&N!==null&&(N.$$typeof===m||N.$$typeof===p||N.$$typeof===i||N.$$typeof===a||N.$$typeof===l||N.$$typeof===P||N.getModuleId!==void 0))}function L(N,X,re){var fe=N.displayName;if(fe)return fe;var De=X.displayName||X.name||"";return De!==""?re+"("+De+")":re}function H(N){return N.displayName||"Context"}function Y(N){if(N==null)return null;if(typeof N.tag=="number"&&b("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof N=="function")return N.displayName||N.name||null;if(typeof N=="string")return N;switch(N){case r:return"Fragment";case n:return"Portal";case s:return"Profiler";case o:return"StrictMode";case c:return"Suspense";case d:return"SuspenseList"}if(typeof N=="object")switch(N.$$typeof){case a:var X=N;return H(X)+".Consumer";case i:var re=N;return H(re._context)+".Provider";case l:return L(N,N.render,"ForwardRef");case p:var fe=N.displayName||null;return fe!==null?fe:Y(N.type)||"Memo";case m:{var De=N,Le=De._payload,We=De._init;try{return Y(We(Le))}catch{return null}}}return null}var _=Object.assign,V=0,G,W,D,I,U,Z,R;function q(){}q.__reactDisabledLog=!0;function j(){{if(V===0){G=console.log,W=console.info,D=console.warn,I=console.error,U=console.group,Z=console.groupCollapsed,R=console.groupEnd;var N={configurable:!0,enumerable:!0,value:q,writable:!0};Object.defineProperties(console,{info:N,log:N,warn:N,error:N,group:N,groupCollapsed:N,groupEnd:N})}V++}}function B(){{if(V--,V===0){var N={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:_({},N,{value:G}),info:_({},N,{value:W}),warn:_({},N,{value:D}),error:_({},N,{value:I}),group:_({},N,{value:U}),groupCollapsed:_({},N,{value:Z}),groupEnd:_({},N,{value:R})})}V<0&&b("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var Q=y.ReactCurrentDispatcher,M;function O(N,X,re){{if(M===void 0)try{throw Error()}catch(De){var fe=De.stack.trim().match(/\n( *(at )?)/);M=fe&&fe[1]||""}return`
|
|
18
|
+
`+M+N}}var F=!1,J;{var oe=typeof WeakMap=="function"?WeakMap:Map;J=new oe}function ae(N,X){if(!N||F)return"";{var re=J.get(N);if(re!==void 0)return re}var fe;F=!0;var De=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var Le;Le=Q.current,Q.current=null,j();try{if(X){var We=function(){throw Error()};if(Object.defineProperty(We.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(We,[])}catch(Kt){fe=Kt}Reflect.construct(N,[],We)}else{try{We.call()}catch(Kt){fe=Kt}N.call(We.prototype)}}else{try{throw Error()}catch(Kt){fe=Kt}N()}}catch(Kt){if(Kt&&fe&&typeof Kt.stack=="string"){for(var Be=Kt.stack.split(`
|
|
19
|
+
`),Ft=fe.stack.split(`
|
|
20
|
+
`),gt=Be.length-1,bt=Ft.length-1;gt>=1&&bt>=0&&Be[gt]!==Ft[bt];)bt--;for(;gt>=1&&bt>=0;gt--,bt--)if(Be[gt]!==Ft[bt]){if(gt!==1||bt!==1)do if(gt--,bt--,bt<0||Be[gt]!==Ft[bt]){var an=`
|
|
21
|
+
`+Be[gt].replace(" at new "," at ");return N.displayName&&an.includes("<anonymous>")&&(an=an.replace("<anonymous>",N.displayName)),typeof N=="function"&&J.set(N,an),an}while(gt>=1&&bt>=0);break}}}finally{F=!1,Q.current=Le,B(),Error.prepareStackTrace=De}var Vr=N?N.displayName||N.name:"",gr=Vr?O(Vr):"";return typeof N=="function"&&J.set(N,gr),gr}function Se(N,X,re){return ae(N,!1)}function we(N){var X=N.prototype;return!!(X&&X.isReactComponent)}function Re(N,X,re){if(N==null)return"";if(typeof N=="function")return ae(N,we(N));if(typeof N=="string")return O(N);switch(N){case c:return O("Suspense");case d:return O("SuspenseList")}if(typeof N=="object")switch(N.$$typeof){case l:return Se(N.render);case p:return Re(N.type,X,re);case m:{var fe=N,De=fe._payload,Le=fe._init;try{return Re(Le(De),X,re)}catch{}}}return""}var $e=Object.prototype.hasOwnProperty,Fe={},Ge=y.ReactDebugCurrentFrame;function Je(N){if(N){var X=N._owner,re=Re(N.type,N._source,X?X.type:null);Ge.setExtraStackFrame(re)}else Ge.setExtraStackFrame(null)}function vt(N,X,re,fe,De){{var Le=Function.call.bind($e);for(var We in N)if(Le(N,We)){var Be=void 0;try{if(typeof N[We]!="function"){var Ft=Error((fe||"React class")+": "+re+" type `"+We+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof N[We]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw Ft.name="Invariant Violation",Ft}Be=N[We](X,We,fe,re,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(gt){Be=gt}Be&&!(Be instanceof Error)&&(Je(De),b("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",fe||"React class",re,We,typeof Be),Je(null)),Be instanceof Error&&!(Be.message in Fe)&&(Fe[Be.message]=!0,Je(De),b("Failed %s type: %s",re,Be.message),Je(null))}}}var ct=Array.isArray;function tt(N){return ct(N)}function Oe(N){{var X=typeof Symbol=="function"&&Symbol.toStringTag,re=X&&N[Symbol.toStringTag]||N.constructor.name||"Object";return re}}function Ve(N){try{return He(N),!1}catch{return!0}}function He(N){return""+N}function Te(N){if(Ve(N))return b("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Oe(N)),He(N)}var Ae=y.ReactCurrentOwner,ut={key:!0,ref:!0,__self:!0,__source:!0},dt,it;function At(N){if($e.call(N,"ref")){var X=Object.getOwnPropertyDescriptor(N,"ref").get;if(X&&X.isReactWarning)return!1}return N.ref!==void 0}function St(N){if($e.call(N,"key")){var X=Object.getOwnPropertyDescriptor(N,"key").get;if(X&&X.isReactWarning)return!1}return N.key!==void 0}function ft(N,X){typeof N.ref=="string"&&Ae.current}function Ct(N,X){{var re=function(){dt||(dt=!0,b("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",X))};re.isReactWarning=!0,Object.defineProperty(N,"key",{get:re,configurable:!0})}}function Tt(N,X){{var re=function(){it||(it=!0,b("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",X))};re.isReactWarning=!0,Object.defineProperty(N,"ref",{get:re,configurable:!0})}}var It=function(N,X,re,fe,De,Le,We){var Be={$$typeof:t,type:N,key:X,ref:re,props:We,_owner:Le};return Be._store={},Object.defineProperty(Be._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(Be,"_self",{configurable:!1,enumerable:!1,writable:!1,value:fe}),Object.defineProperty(Be,"_source",{configurable:!1,enumerable:!1,writable:!1,value:De}),Object.freeze&&(Object.freeze(Be.props),Object.freeze(Be)),Be};function en(N,X,re,fe,De){{var Le,We={},Be=null,Ft=null;re!==void 0&&(Te(re),Be=""+re),St(X)&&(Te(X.key),Be=""+X.key),At(X)&&(Ft=X.ref,ft(X,De));for(Le in X)$e.call(X,Le)&&!ut.hasOwnProperty(Le)&&(We[Le]=X[Le]);if(N&&N.defaultProps){var gt=N.defaultProps;for(Le in gt)We[Le]===void 0&&(We[Le]=gt[Le])}if(Be||Ft){var bt=typeof N=="function"?N.displayName||N.name||"Unknown":N;Be&&Ct(We,bt),Ft&&Tt(We,bt)}return It(N,Be,Ft,De,fe,Ae.current,We)}}var kt=y.ReactCurrentOwner,Ie=y.ReactDebugCurrentFrame;function Ke(N){if(N){var X=N._owner,re=Re(N.type,N._source,X?X.type:null);Ie.setExtraStackFrame(re)}else Ie.setExtraStackFrame(null)}var Nt;Nt=!1;function te(N){return typeof N=="object"&&N!==null&&N.$$typeof===t}function xe(){{if(kt.current){var N=Y(kt.current.type);if(N)return`
|
|
22
22
|
|
|
23
|
-
Check the render method of \``+N+"`."}return""}}function
|
|
23
|
+
Check the render method of \``+N+"`."}return""}}function nt(N){return""}var me={};function Ne(N){{var X=xe();if(!X){var re=typeof N=="string"?N:N.displayName||N.name;re&&(X=`
|
|
24
24
|
|
|
25
|
-
Check the top-level render call using <`+re+">.")}return X}}function
|
|
25
|
+
Check the top-level render call using <`+re+">.")}return X}}function Ue(N,X){{if(!N._store||N._store.validated||N.key!=null)return;N._store.validated=!0;var re=Ne(X);if(me[re])return;me[re]=!0;var fe="";N&&N._owner&&N._owner!==kt.current&&(fe=" It was passed a child from "+Y(N._owner.type)+"."),Ke(N),b('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',re,fe),Ke(null)}}function at(N,X){{if(typeof N!="object")return;if(tt(N))for(var re=0;re<N.length;re++){var fe=N[re];te(fe)&&Ue(fe,X)}else if(te(N))N._store&&(N._store.validated=!0);else if(N){var De=x(N);if(typeof De=="function"&&De!==N.entries)for(var Le=De.call(N),We;!(We=Le.next()).done;)te(We.value)&&Ue(We.value,X)}}}function rt(N){{var X=N.type;if(X==null||typeof X=="string")return;var re;if(typeof X=="function")re=X.propTypes;else if(typeof X=="object"&&(X.$$typeof===l||X.$$typeof===p))re=X.propTypes;else return;if(re){var fe=Y(X);vt(re,N.props,"prop",fe,N)}else if(X.PropTypes!==void 0&&!Nt){Nt=!0;var De=Y(X);b("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",De||"Unknown")}typeof X.getDefaultProps=="function"&&!X.getDefaultProps.isReactClassApproved&&b("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function wt(N){{for(var X=Object.keys(N.props),re=0;re<X.length;re++){var fe=X[re];if(fe!=="children"&&fe!=="key"){Ke(N),b("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",fe),Ke(null);break}}N.ref!==null&&(Ke(N),b("Invalid attribute `ref` supplied to `React.Fragment`."),Ke(null))}}var Pt={};function de(N,X,re,fe,De,Le){{var We=$(N);if(!We){var Be="";(N===void 0||typeof N=="object"&&N!==null&&Object.keys(N).length===0)&&(Be+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var Ft=nt();Ft?Be+=Ft:Be+=xe();var gt;N===null?gt="null":tt(N)?gt="array":N!==void 0&&N.$$typeof===t?(gt="<"+(Y(N.type)||"Unknown")+" />",Be=" Did you accidentally export a JSX literal instead of a component?"):gt=typeof N,b("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",gt,Be)}var bt=en(N,X,re,De,Le);if(bt==null)return bt;if(We){var an=X.children;if(an!==void 0)if(fe)if(tt(an)){for(var Vr=0;Vr<an.length;Vr++)at(an[Vr],N);Object.freeze&&Object.freeze(an)}else b("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else at(an,N)}if($e.call(X,"key")){var gr=Y(N),Kt=Object.keys(X).filter(function(hN){return hN!=="key"}),sc=Kt.length>0?"{key: someKey, "+Kt.join(": ..., ")+": ...}":"{key: someKey}";if(!Pt[gr+sc]){var pN=Kt.length>0?"{"+Kt.join(": ..., ")+": ...}":"{}";b(`A props object containing a "key" prop is being spread into JSX:
|
|
26
26
|
let props = %s;
|
|
27
27
|
<%s {...props} />
|
|
28
28
|
React keys must be passed directly to JSX without using spread:
|
|
29
29
|
let props = %s;
|
|
30
|
-
<%s key={someKey} {...props} />`,sc,gr,pN,gr),$t[gr+sc]=!0}}return N===r?Nt(bt):nt(bt),bt}}function ut(N,X,re){return Ee(N,X,re,!0)}function Ge(N,X,re){return Ee(N,X,re,!1)}var at=Ge,sn=ut;Xr.Fragment=r,Xr.jsx=at,Xr.jsxs=sn}()),Xr}process.env.NODE_ENV==="production"?Ti.exports=_x():Ti.exports=Rx();var u=Ti.exports;const Mx=({timelineEntries:e,activeCheckpointId:t,onSelectCheckpoint:n,messagePreviews:r,className:o,onHoverStart:s,onHoverEnd:i})=>{const a=e??[],c=a.length>0,l=w.useMemo(()=>c?[...a].reverse():[],[a,c]),d=t??(a.length?a[a.length-1].id:null);if(!c)return null;const m=["w-32 flex-shrink-0 flex-col border-r border-border/40 pr-2 flex bg-white text-gray-900 dark:bg-slate-900 dark:text-slate-100",o].filter(Boolean).join(" ");return u.jsxs("div",{className:m,onMouseEnter:s,onMouseLeave:i,children:[u.jsxs("div",{className:"relative flex-1 overflow-y-auto pt-4 pb-2 pr-1",children:[u.jsx("div",{className:"absolute left-0 right-0 top-1 px-2 pb-3 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:u.jsx("span",{children:"Timeline"})}),u.jsx("div",{className:"pointer-events-none absolute left-3 top-0 bottom-0 w-px bg-border/40"}),u.jsx("div",{className:"flex flex-col gap-3 pt-6 pr-2",children:l.map(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 mc(e,t){return function(){return e.apply(t,arguments)}}const{toString:Ox}=Object.prototype,{getPrototypeOf:ki}=Object,{iterator:$o,toStringTag:gc}=Symbol,Fo=(e=>t=>{const n=Ox.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),ln=e=>(e=e.toLowerCase(),t=>Fo(t)===e),Bo=e=>t=>typeof t===e,{isArray:vr}=Array,wr=Bo("undefined");function Jr(e){return e!==null&&!wr(e)&&e.constructor!==null&&!wr(e.constructor)&&Bt(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const xc=ln("ArrayBuffer");function Dx(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&xc(e.buffer),t}const Lx=Bo("string"),Bt=Bo("function"),vc=Bo("number"),Zr=e=>e!==null&&typeof e=="object",$x=e=>e===!0||e===!1,zo=e=>{if(Fo(e)!=="object")return!1;const t=ki(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(gc in e)&&!($o in e)},Fx=e=>{if(!Zr(e)||Jr(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},Bx=ln("Date"),zx=ln("File"),Hx=ln("Blob"),Ux=ln("FileList"),Wx=e=>Zr(e)&&Bt(e.pipe),Vx=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||Bt(e.append)&&((t=Fo(e))==="formdata"||t==="object"&&Bt(e.toString)&&e.toString()==="[object FormData]"))},Kx=ln("URLSearchParams"),[qx,Gx,Yx,Xx]=["ReadableStream","Request","Response","Headers"].map(ln),Jx=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Qr(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,o;if(typeof e!="object"&&(e=[e]),vr(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{if(Jr(e))return;const s=n?Object.getOwnPropertyNames(e):Object.keys(e),i=s.length;let a;for(r=0;r<i;r++)a=s[r],t.call(null,e[a],a,e)}}function wc(e,t){if(Jr(e))return null;t=t.toLowerCase();const n=Object.keys(e);let r=n.length,o;for(;r-- >0;)if(o=n[r],t===o.toLowerCase())return o;return null}const Xn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,bc=e=>!wr(e)&&e!==Xn;function Ei(){const{caseless:e,skipUndefined:t}=bc(this)&&this||{},n={},r=(o,s)=>{const i=e&&wc(n,s)||s;zo(n[i])&&zo(o)?n[i]=Ei(n[i],o):zo(o)?n[i]=Ei({},o):vr(o)?n[i]=o.slice():(!t||!wr(o))&&(n[i]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&Qr(arguments[o],r);return n}const Zx=(e,t,n,{allOwnKeys:r}={})=>(Qr(t,(o,s)=>{n&&Bt(o)?e[s]=mc(o,n):e[s]=o},{allOwnKeys:r}),e),Qx=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),ev=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},tv=(e,t,n,r)=>{let o,s,i;const a={};if(t=t||{},e==null)return t;do{for(o=Object.getOwnPropertyNames(e),s=o.length;s-- >0;)i=o[s],(!r||r(i,e,t))&&!a[i]&&(t[i]=e[i],a[i]=!0);e=n!==!1&&ki(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},nv=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return r!==-1&&r===n},rv=e=>{if(!e)return null;if(vr(e))return e;let t=e.length;if(!vc(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},ov=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&ki(Uint8Array)),sv=(e,t)=>{const r=(e&&e[$o]).call(e);let o;for(;(o=r.next())&&!o.done;){const s=o.value;t.call(e,s[0],s[1])}},iv=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},av=ln("HTMLFormElement"),lv=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),yc=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),cv=ln("RegExp"),Sc=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};Qr(n,(o,s)=>{let i;(i=t(o,s,e))!==!1&&(r[s]=i||o)}),Object.defineProperties(e,r)},uv=e=>{Sc(e,(t,n)=>{if(Bt(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(Bt(r)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},dv=(e,t)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return vr(e)?r(e):r(String(e).split(t)),n},fv=()=>{},pv=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function hv(e){return!!(e&&Bt(e.append)&&e[gc]==="FormData"&&e[$o])}const mv=e=>{const t=new Array(10),n=(r,o)=>{if(Zr(r)){if(t.indexOf(r)>=0)return;if(Jr(r))return r;if(!("toJSON"in r)){t[o]=r;const s=vr(r)?[]:{};return Qr(r,(i,a)=>{const c=n(i,o+1);!wr(c)&&(s[a]=c)}),t[o]=void 0,s}}return r};return n(e,0)},gv=ln("AsyncFunction"),xv=e=>e&&(Zr(e)||Bt(e))&&Bt(e.then)&&Bt(e.catch),Cc=((e,t)=>e?setImmediate:t?((n,r)=>(Xn.addEventListener("message",({source:o,data:s})=>{o===Xn&&s===n&&r.length&&r.shift()()},!1),o=>{r.push(o),Xn.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",Bt(Xn.postMessage)),vv=typeof queueMicrotask<"u"?queueMicrotask.bind(Xn):typeof process<"u"&&process.nextTick||Cc,q={isArray:vr,isArrayBuffer:xc,isBuffer:Jr,isFormData:Vx,isArrayBufferView:Dx,isString:Lx,isNumber:vc,isBoolean:$x,isObject:Zr,isPlainObject:zo,isEmptyObject:Fx,isReadableStream:qx,isRequest:Gx,isResponse:Yx,isHeaders:Xx,isUndefined:wr,isDate:Bx,isFile:zx,isBlob:Hx,isRegExp:cv,isFunction:Bt,isStream:Wx,isURLSearchParams:Kx,isTypedArray:ov,isFileList:Ux,forEach:Qr,merge:Ei,extend:Zx,trim:Jx,stripBOM:Qx,inherits:ev,toFlatObject:tv,kindOf:Fo,kindOfTest:ln,endsWith:nv,toArray:rv,forEachEntry:sv,matchAll:iv,isHTMLForm:av,hasOwnProperty:yc,hasOwnProp:yc,reduceDescriptors:Sc,freezeMethods:uv,toObjectSet:dv,toCamelCase:lv,noop:fv,toFiniteNumber:pv,findKey:wc,global:Xn,isContextDefined:bc,isSpecCompliantForm:hv,toJSONObject:mv,isAsyncFn:gv,isThenable:xv,setImmediate:Cc,asap:vv,isIterable:e=>e!=null&&Bt(e[$o])};function Ie(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)}q.inherits(Ie,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:q.toJSONObject(this.config),code:this.code,status:this.status}}});const Tc=Ie.prototype,kc={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{kc[e]={value:e}}),Object.defineProperties(Ie,kc),Object.defineProperty(Tc,"isAxiosError",{value:!0}),Ie.from=(e,t,n,r,o,s)=>{const i=Object.create(Tc);q.toFlatObject(e,i,function(d){return d!==Error.prototype},l=>l!=="isAxiosError");const a=e&&e.message?e.message:"Error",c=t==null&&e?e.code:t;return Ie.call(i,a,c,n,r,o),e&&i.cause==null&&Object.defineProperty(i,"cause",{value:e,configurable:!0}),i.name=e&&e.name||"Error",s&&Object.assign(i,s),i};const wv=null;function Ii(e){return q.isPlainObject(e)||q.isArray(e)}function Ec(e){return q.endsWith(e,"[]")?e.slice(0,-2):e}function Ic(e,t,n){return e?e.concat(t).map(function(o,s){return o=Ec(o),!n&&s?"["+o+"]":o}).join(n?".":""):t}function bv(e){return q.isArray(e)&&!e.some(Ii)}const yv=q.toFlatObject(q,{},null,function(t){return/^is[A-Z]/.test(t)});function Ho(e,t,n){if(!q.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=q.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(g,x){return!q.isUndefined(x[g])});const r=n.metaTokens,o=n.visitor||d,s=n.dots,i=n.indexes,c=(n.Blob||typeof Blob<"u"&&Blob)&&q.isSpecCompliantForm(t);if(!q.isFunction(o))throw new TypeError("visitor must be a function");function l(v){if(v===null)return"";if(q.isDate(v))return v.toISOString();if(q.isBoolean(v))return v.toString();if(!c&&q.isBlob(v))throw new Ie("Blob is not supported. Use a Buffer instead.");return q.isArrayBuffer(v)||q.isTypedArray(v)?c&&typeof Blob=="function"?new Blob([v]):Buffer.from(v):v}function d(v,g,x){let y=v;if(v&&!x&&typeof v=="object"){if(q.endsWith(g,"{}"))g=r?g:g.slice(0,-2),v=JSON.stringify(v);else if(q.isArray(v)&&bv(v)||(q.isFileList(v)||q.endsWith(g,"[]"))&&(y=q.toArray(v)))return g=Ec(g),y.forEach(function(C,k){!(q.isUndefined(C)||C===null)&&t.append(i===!0?Ic([g],k,s):i===null?g:g+"[]",l(C))}),!1}return Ii(v)?!0:(t.append(Ic(x,g,s),l(v)),!1)}const p=[],m=Object.assign(yv,{defaultVisitor:d,convertValue:l,isVisitable:Ii});function f(v,g){if(!q.isUndefined(v)){if(p.indexOf(v)!==-1)throw Error("Circular reference detected in "+g.join("."));p.push(v),q.forEach(v,function(y,b){(!(q.isUndefined(y)||y===null)&&o.call(t,y,q.isString(b)?b.trim():b,g,m))===!0&&f(y,g?g.concat(b):[b])}),p.pop()}}if(!q.isObject(e))throw new TypeError("data must be an object");return f(e),t}function Nc(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function Ni(e,t){this._pairs=[],e&&Ho(e,this,t)}const Ac=Ni.prototype;Ac.append=function(t,n){this._pairs.push([t,n])},Ac.toString=function(t){const n=t?function(r){return t.call(this,r,Nc)}:Nc;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function Sv(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Pc(e,t,n){if(!t)return e;const r=n&&n.encode||Sv;q.isFunction(n)&&(n={serialize:n});const o=n&&n.serialize;let s;if(o?s=o(t,n):s=q.isURLSearchParams(t)?t.toString():new Ni(t,n).toString(r),s){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}class jc{constructor(){this.handlers=[]}use(t,n,r){return this.handlers.push({fulfilled:t,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){q.forEach(this.handlers,function(r){r!==null&&t(r)})}}const _c={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Cv={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:Ni,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},Ai=typeof window<"u"&&typeof document<"u",Pi=typeof navigator=="object"&&navigator||void 0,Tv=Ai&&(!Pi||["ReactNative","NativeScript","NS"].indexOf(Pi.product)<0),kv=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Ev=Ai&&window.location.href||"http://localhost",Pt={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Ai,hasStandardBrowserEnv:Tv,hasStandardBrowserWebWorkerEnv:kv,navigator:Pi,origin:Ev},Symbol.toStringTag,{value:"Module"})),...Cv};function Iv(e,t){return Ho(e,new Pt.classes.URLSearchParams,{visitor:function(n,r,o,s){return Pt.isNode&&q.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function Nv(e){return q.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function Av(e){const t={},n=Object.keys(e);let r;const o=n.length;let s;for(r=0;r<o;r++)s=n[r],t[s]=e[s];return t}function Rc(e){function t(n,r,o,s){let i=n[s++];if(i==="__proto__")return!0;const a=Number.isFinite(+i),c=s>=n.length;return i=!i&&q.isArray(o)?o.length:i,c?(q.hasOwnProp(o,i)?o[i]=[o[i],r]:o[i]=r,!a):((!o[i]||!q.isObject(o[i]))&&(o[i]=[]),t(n,r,o[i],s)&&q.isArray(o[i])&&(o[i]=Av(o[i])),!a)}if(q.isFormData(e)&&q.isFunction(e.entries)){const n={};return q.forEachEntry(e,(r,o)=>{t(Nv(r),o,n,0)}),n}return null}function Pv(e,t,n){if(q.isString(e))try{return(t||JSON.parse)(e),q.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const eo={transitional:_c,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",o=r.indexOf("application/json")>-1,s=q.isObject(t);if(s&&q.isHTMLForm(t)&&(t=new FormData(t)),q.isFormData(t))return o?JSON.stringify(Rc(t)):t;if(q.isArrayBuffer(t)||q.isBuffer(t)||q.isStream(t)||q.isFile(t)||q.isBlob(t)||q.isReadableStream(t))return t;if(q.isArrayBufferView(t))return t.buffer;if(q.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let a;if(s){if(r.indexOf("application/x-www-form-urlencoded")>-1)return Iv(t,this.formSerializer).toString();if((a=q.isFileList(t))||r.indexOf("multipart/form-data")>-1){const c=this.env&&this.env.FormData;return Ho(a?{"files[]":t}:t,c&&new c,this.formSerializer)}}return s||o?(n.setContentType("application/json",!1),Pv(t)):t}],transformResponse:[function(t){const n=this.transitional||eo.transitional,r=n&&n.forcedJSONParsing,o=this.responseType==="json";if(q.isResponse(t)||q.isReadableStream(t))return t;if(t&&q.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"?Ie.from(a,Ie.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}}};q.forEach(["delete","get","head","post","put","patch"],e=>{eo.headers[e]={}});const jv=q.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),_v=e=>{const t={};let n,r,o;return e&&e.split(`
|
|
31
|
-
`).forEach(function(i){o=i.indexOf(":"),n=i.substring(0,o).trim().toLowerCase(),r=i.substring(o+1).trim(),!(!n||t[n]&&jv[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},Mc=Symbol("internals");function to(e){return e&&String(e).trim().toLowerCase()}function Uo(e){return e===!1||e==null?e:
|
|
32
|
-
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const r=new this(t);return n.forEach(o=>r.set(o)),r}static accessor(t){const r=(this[Mc]=this[Mc]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=to(i);r[a]||(Dv(o,i),r[a]=!0)}return q.isArray(t)?t.forEach(s):s(t),this}};zt.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),q.reduceDescriptors(zt.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),q.freezeMethods(zt);function _i(e,t){const n=this||eo,r=t||n,o=zt.from(r.headers);let s=r.data;return q.forEach(e,function(a){s=a.call(n,s,o.normalize(),t?t.status:void 0)}),o.normalize(),s}function Oc(e){return!!(e&&e.__CANCEL__)}function br(e,t,n){Ie.call(this,e??"canceled",Ie.ERR_CANCELED,t,n),this.name="CanceledError"}q.inherits(br,Ie,{__CANCEL__:!0});function Dc(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new Ie("Request failed with status code "+n.status,[Ie.ERR_BAD_REQUEST,Ie.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function Lv(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function $v(e,t){e=e||10;const n=new Array(e),r=new Array(e);let o=0,s=0,i;return t=t!==void 0?t:1e3,function(c){const l=Date.now(),d=r[s];i||(i=l),n[o]=c,r[o]=l;let p=s,m=0;for(;p!==o;)m+=n[p++],p=p%e;if(o=(o+1)%e,o===s&&(s=(s+1)%e),l-i<t)return;const f=d&&l-d;return f?Math.round(m*1e3/f):void 0}}function Fv(e,t){let n=0,r=1e3/t,o,s;const i=(l,d=Date.now())=>{n=d,o=null,s&&(clearTimeout(s),s=null),e(...l)};return[(...l)=>{const d=Date.now(),p=d-n;p>=r?i(l,d):(o=l,s||(s=setTimeout(()=>{s=null,i(o)},r-p)))},()=>o&&i(o)]}const Wo=(e,t,n=3)=>{let r=0;const o=$v(50,250);return Fv(s=>{const i=s.loaded,a=s.lengthComputable?s.total:void 0,c=i-r,l=o(c),d=i<=a;r=i;const p={loaded:i,total:a,progress:a?i/a:void 0,bytes:c,rate:l||void 0,estimated:l&&a&&d?(a-i)/l:void 0,event:s,lengthComputable:a!=null,[t?"download":"upload"]:!0};e(p)},n)},Lc=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},$c=e=>(...t)=>q.asap(()=>e(...t)),Bv=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,zv=Pt.hasStandardBrowserEnv?{write(e,t,n,r,o,s){const i=[e+"="+encodeURIComponent(t)];q.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),q.isString(r)&&i.push("path="+r),q.isString(o)&&i.push("domain="+o),s===!0&&i.push("secure"),document.cookie=i.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function Hv(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Uv(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function Fc(e,t,n){let r=!Hv(t);return e&&(r||n==!1)?Uv(e,t):t}const Bc=e=>e instanceof zt?{...e}:e;function Jn(e,t){t=t||{};const n={};function r(l,d,p,m){return q.isPlainObject(l)&&q.isPlainObject(d)?q.merge.call({caseless:m},l,d):q.isPlainObject(d)?q.merge({},d):q.isArray(d)?d.slice():d}function o(l,d,p,m){if(q.isUndefined(d)){if(!q.isUndefined(l))return r(void 0,l,p,m)}else return r(l,d,p,m)}function s(l,d){if(!q.isUndefined(d))return r(void 0,d)}function i(l,d){if(q.isUndefined(d)){if(!q.isUndefined(l))return r(void 0,l)}else return r(void 0,d)}function a(l,d,p){if(p in t)return r(l,d);if(p in e)return r(void 0,l)}const c={url:s,method:s,data:s,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:a,headers:(l,d,p)=>o(Bc(l),Bc(d),p,!0)};return q.forEach(Object.keys({...e,...t}),function(d){const p=c[d]||o,m=p(e[d],t[d],d);q.isUndefined(m)&&p!==a||(n[d]=m)}),n}const zc=e=>{const t=Jn({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=zt.from(i),t.url=Pc(Fc(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&i.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),q.isFormData(n)){if(Pt.hasStandardBrowserEnv||Pt.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(q.isFunction(n.getHeaders)){const c=n.getHeaders(),l=["content-type","content-length"];Object.entries(c).forEach(([d,p])=>{l.includes(d.toLowerCase())&&i.set(d,p)})}}if(Pt.hasStandardBrowserEnv&&(r&&q.isFunction(r)&&(r=r(t)),r||r!==!1&&Bv(t.url))){const c=o&&s&&zv.read(s);c&&i.set(o,c)}return t},Wv=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=zc(e);let s=o.data;const i=zt.from(o.headers).normalize();let{responseType:a,onUploadProgress:c,onDownloadProgress:l}=o,d,p,m,f,v;function g(){f&&f(),v&&v(),o.cancelToken&&o.cancelToken.unsubscribe(d),o.signal&&o.signal.removeEventListener("abort",d)}let x=new XMLHttpRequest;x.open(o.method.toUpperCase(),o.url,!0),x.timeout=o.timeout;function y(){if(!x)return;const C=zt.from("getAllResponseHeaders"in x&&x.getAllResponseHeaders()),S={data:!a||a==="text"||a==="json"?x.responseText:x.response,status:x.status,statusText:x.statusText,headers:C,config:e,request:x};Dc(function(E){n(E),g()},function(E){r(E),g()},S),x=null}"onloadend"in x?x.onloadend=y:x.onreadystatechange=function(){!x||x.readyState!==4||x.status===0&&!(x.responseURL&&x.responseURL.indexOf("file:")===0)||setTimeout(y)},x.onabort=function(){x&&(r(new Ie("Request aborted",Ie.ECONNABORTED,e,x)),x=null)},x.onerror=function(k){const S=k&&k.message?k.message:"Network Error",T=new Ie(S,Ie.ERR_NETWORK,e,x);T.event=k||null,r(T),x=null},x.ontimeout=function(){let k=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const S=o.transitional||_c;o.timeoutErrorMessage&&(k=o.timeoutErrorMessage),r(new Ie(k,S.clarifyTimeoutError?Ie.ETIMEDOUT:Ie.ECONNABORTED,e,x)),x=null},s===void 0&&i.setContentType(null),"setRequestHeader"in x&&q.forEach(i.toJSON(),function(k,S){x.setRequestHeader(S,k)}),q.isUndefined(o.withCredentials)||(x.withCredentials=!!o.withCredentials),a&&a!=="json"&&(x.responseType=o.responseType),l&&([m,v]=Wo(l,!0),x.addEventListener("progress",m)),c&&x.upload&&([p,f]=Wo(c),x.upload.addEventListener("progress",p),x.upload.addEventListener("loadend",f)),(o.cancelToken||o.signal)&&(d=C=>{x&&(r(!C||C.type?new br(null,e,x):C),x.abort(),x=null)},o.cancelToken&&o.cancelToken.subscribe(d),o.signal&&(o.signal.aborted?d():o.signal.addEventListener("abort",d)));const b=Lv(o.url);if(b&&Pt.protocols.indexOf(b)===-1){r(new Ie("Unsupported protocol "+b+":",Ie.ERR_BAD_REQUEST,e));return}x.send(s||null)})},Vv=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let r=new AbortController,o;const s=function(l){if(!o){o=!0,a();const d=l instanceof Error?l:this.reason;r.abort(d instanceof Ie?d:new br(d instanceof Error?d.message:d))}};let i=t&&setTimeout(()=>{i=null,s(new Ie(`timeout ${t} of ms exceeded`,Ie.ETIMEDOUT))},t);const a=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(l=>{l.unsubscribe?l.unsubscribe(s):l.removeEventListener("abort",s)}),e=null)};e.forEach(l=>l.addEventListener("abort",s));const{signal:c}=r;return c.unsubscribe=()=>q.asap(a),c}},Kv=function*(e,t){let n=e.byteLength;if(n<t){yield e;return}let r=0,o;for(;r<n;)o=r+t,yield e.slice(r,o),r=o},qv=async function*(e,t){for await(const n of Gv(e))yield*Kv(n,t)},Gv=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:n,value:r}=await t.read();if(n)break;yield r}}finally{await t.cancel()}},Hc=(e,t,n,r)=>{const o=qv(e,t);let s=0,i,a=c=>{i||(i=!0,r&&r(c))};return new ReadableStream({async pull(c){try{const{done:l,value:d}=await o.next();if(l){a(),c.close();return}let p=d.byteLength;if(n){let m=s+=p;n(m)}c.enqueue(new Uint8Array(d))}catch(l){throw a(l),l}},cancel(c){return a(c),o.return()}},{highWaterMark:2})},Uc=64*1024,{isFunction:Vo}=q,Yv=(({Request:e,Response:t})=>({Request:e,Response:t}))(q.global),{ReadableStream:Wc,TextEncoder:Vc}=q.global,Kc=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Xv=e=>{e=q.merge.call({skipUndefined:!0},Yv,e);const{fetch:t,Request:n,Response:r}=e,o=t?Vo(t):typeof fetch=="function",s=Vo(n),i=Vo(r);if(!o)return!1;const a=o&&Vo(Wc),c=o&&(typeof Vc=="function"?(v=>g=>v.encode(g))(new Vc):async v=>new Uint8Array(await new n(v).arrayBuffer())),l=s&&a&&Kc(()=>{let v=!1;const g=new n(Pt.origin,{body:new Wc,method:"POST",get duplex(){return v=!0,"half"}}).headers.has("Content-Type");return v&&!g}),d=i&&a&&Kc(()=>q.isReadableStream(new r("").body)),p={stream:d&&(v=>v.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(v=>{!p[v]&&(p[v]=(g,x)=>{let y=g&&g[v];if(y)return y.call(g);throw new Ie(`Response type '${v}' is not supported`,Ie.ERR_NOT_SUPPORT,x)})});const m=async v=>{if(v==null)return 0;if(q.isBlob(v))return v.size;if(q.isSpecCompliantForm(v))return(await new n(Pt.origin,{method:"POST",body:v}).arrayBuffer()).byteLength;if(q.isArrayBufferView(v)||q.isArrayBuffer(v))return v.byteLength;if(q.isURLSearchParams(v)&&(v=v+""),q.isString(v))return(await c(v)).byteLength},f=async(v,g)=>{const x=q.toFiniteNumber(v.getContentLength());return x??m(g)};return async v=>{let{url:g,method:x,data:y,signal:b,cancelToken:C,timeout:k,onDownloadProgress:S,onUploadProgress:T,responseType:E,headers:A,withCredentials:j="same-origin",fetchOptions:L}=zc(v),H=t||fetch;E=E?(E+"").toLowerCase():"text";let V=Vv([b,C&&C.toAbortSignal()],k),J=null;const R=V&&V.unsubscribe&&(()=>{V.unsubscribe()});let G;try{if(T&&l&&x!=="get"&&x!=="head"&&(G=await f(A,y))!==0){let Z=new n(g,{method:"POST",body:y,duplex:"half"}),M;if(q.isFormData(y)&&(M=Z.headers.get("content-type"))&&A.setContentType(M),Z.body){const[Y,_]=Lc(G,Wo($c(T)));y=Hc(Z.body,Uc,Y,_)}}q.isString(j)||(j=j?"include":"omit");const K=s&&"credentials"in n.prototype,$={...L,signal:V,method:x.toUpperCase(),headers:A.normalize().toJSON(),body:y,duplex:"half",credentials:K?j:void 0};J=s&&new n(g,$);let P=await(s?H(J,L):H(g,$));const I=d&&(E==="stream"||E==="response");if(d&&(S||I&&R)){const Z={};["status","statusText","headers"].forEach(z=>{Z[z]=P[z]});const M=q.toFiniteNumber(P.headers.get("content-length")),[Y,_]=S&&Lc(M,Wo($c(S),!0))||[];P=new r(Hc(P.body,Uc,Y,()=>{_&&_(),R&&R()}),Z)}E=E||"text";let U=await p[q.findKey(p,E)||"text"](P,v);return!I&&R&&R(),await new Promise((Z,M)=>{Dc(Z,M,{data:U,headers:zt.from(P.headers),status:P.status,statusText:P.statusText,config:v,request:J})})}catch(K){throw R&&R(),K&&K.name==="TypeError"&&/Load failed|fetch/i.test(K.message)?Object.assign(new Ie("Network Error",Ie.ERR_NETWORK,v,J),{cause:K.cause||K}):Ie.from(K,K&&K.code,v,J)}}},Jv=new Map,qc=e=>{let t=e?e.env:{};const{fetch:n,Request:r,Response:o}=t,s=[r,o,n];let i=s.length,a=i,c,l,d=Jv;for(;a--;)c=s[a],l=d.get(c),l===void 0&&d.set(c,l=a?new Map:Xv(t)),d=l;return l};qc();const Ri={http:wv,xhr:Wv,fetch:{get:qc}};q.forEach(Ri,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Gc=e=>`- ${e}`,Zv=e=>q.isFunction(e)||e===null||e===!1,Yc={getAdapter:(e,t)=>{e=q.isArray(e)?e:[e];const{length:n}=e;let r,o;const s={};for(let i=0;i<n;i++){r=e[i];let a;if(o=r,!Zv(r)&&(o=Ri[(a=String(r)).toLowerCase()],o===void 0))throw new Ie(`Unknown adapter '${a}'`);if(o&&(q.isFunction(o)||(o=o.get(t))))break;s[a||"#"+i]=o}if(!o){const i=Object.entries(s).map(([c,l])=>`adapter ${c} `+(l===!1?"is not supported by the environment":"is not available in the build"));let a=n?i.length>1?`since :
|
|
30
|
+
<%s key={someKey} {...props} />`,sc,gr,pN,gr),Pt[gr+sc]=!0}}return N===r?wt(bt):rt(bt),bt}}function Pe(N,X,re){return de(N,X,re,!0)}function Me(N,X,re){return de(N,X,re,!1)}var Ze=Me,sn=Pe;Xr.Fragment=r,Xr.jsx=Ze,Xr.jsxs=sn}()),Xr}process.env.NODE_ENV==="production"?Ti.exports=_x():Ti.exports=Rx();var u=Ti.exports;const Mx=({timelineEntries:e,activeCheckpointId:t,onSelectCheckpoint:n,messagePreviews:r,className:o,onHoverStart:s,onHoverEnd:i})=>{const a=e??[],l=a.length>0,c=w.useMemo(()=>l?[...a].reverse():[],[a,l]),d=t??(a.length?a[a.length-1].id:null);if(!l)return null;const m=["w-32 flex-shrink-0 flex-col border-r border-border/40 pr-2 flex bg-white text-gray-900 dark:bg-slate-900 dark:text-slate-100",o].filter(Boolean).join(" ");return u.jsxs("div",{className:m,onMouseEnter:s,onMouseLeave:i,children:[u.jsxs("div",{className:"relative flex-1 overflow-y-auto pt-4 pb-2 pr-1",children:[u.jsx("div",{className:"absolute left-0 right-0 top-1 px-2 pb-3 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:u.jsx("span",{children:"Timeline"})}),u.jsx("div",{className:"pointer-events-none absolute left-3 top-0 bottom-0 w-px bg-border/40"}),u.jsx("div",{className:"flex flex-col gap-3 pt-6 pr-2",children:c.map(f=>{const v=d===f.id,g=(r==null?void 0:r.get(f.id))??null;return u.jsxs("button",{type:"button",disabled:!n,onClick:()=>n==null?void 0:n(f.id),className:`relative flex items-start gap-2 text-left text-[11px] transition ${v?"text-primary":"text-muted-foreground"} ${n?"hover:text-foreground":"cursor-default opacity-70"}`,children:[u.jsx("span",{className:`mt-1 inline-flex h-3 w-3 items-center justify-center rounded-full border ${v?"border-primary bg-primary/10 text-primary":"border-border bg-background"}`,children:u.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${v?"bg-primary":"bg-border"}`})}),u.jsxs("span",{className:"flex-1",children:[u.jsx("span",{className:"block font-medium leading-tight",children:f.label||"User input"}),u.jsxs("span",{className:"text-[9px] uppercase tracking-wide text-muted-foreground/70",children:[f.step!==null?`STEP ${f.step}`:"STEP —",f.next?` - ${f.next}`:""]}),g&&u.jsx("p",{className:"text-[10px] text-muted-foreground/80 mt-1 line-clamp-2",title:g,children:g})]})]},f.id)})})]}),n&&u.jsx("button",{type:"button",onClick:()=>n==null?void 0:n(null),className:"mt-auto mb-3 rounded-md border border-border/70 px-2 py-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground transition hover:border-foreground/60 hover:text-foreground",children:"Latest"})]})};function mc(e,t){return function(){return e.apply(t,arguments)}}const{toString:Ox}=Object.prototype,{getPrototypeOf:ki}=Object,{iterator:$o,toStringTag:gc}=Symbol,Fo=(e=>t=>{const n=Ox.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),ln=e=>(e=e.toLowerCase(),t=>Fo(t)===e),Bo=e=>t=>typeof t===e,{isArray:vr}=Array,wr=Bo("undefined");function Jr(e){return e!==null&&!wr(e)&&e.constructor!==null&&!wr(e.constructor)&&Bt(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const xc=ln("ArrayBuffer");function Dx(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&xc(e.buffer),t}const Lx=Bo("string"),Bt=Bo("function"),vc=Bo("number"),Zr=e=>e!==null&&typeof e=="object",$x=e=>e===!0||e===!1,zo=e=>{if(Fo(e)!=="object")return!1;const t=ki(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(gc in e)&&!($o in e)},Fx=e=>{if(!Zr(e)||Jr(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},Bx=ln("Date"),zx=ln("File"),Hx=ln("Blob"),Ux=ln("FileList"),Wx=e=>Zr(e)&&Bt(e.pipe),Vx=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||Bt(e.append)&&((t=Fo(e))==="formdata"||t==="object"&&Bt(e.toString)&&e.toString()==="[object FormData]"))},Kx=ln("URLSearchParams"),[qx,Gx,Yx,Xx]=["ReadableStream","Request","Response","Headers"].map(ln),Jx=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Qr(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,o;if(typeof e!="object"&&(e=[e]),vr(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{if(Jr(e))return;const s=n?Object.getOwnPropertyNames(e):Object.keys(e),i=s.length;let a;for(r=0;r<i;r++)a=s[r],t.call(null,e[a],a,e)}}function wc(e,t){if(Jr(e))return null;t=t.toLowerCase();const n=Object.keys(e);let r=n.length,o;for(;r-- >0;)if(o=n[r],t===o.toLowerCase())return o;return null}const Xn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,bc=e=>!wr(e)&&e!==Xn;function Ei(){const{caseless:e,skipUndefined:t}=bc(this)&&this||{},n={},r=(o,s)=>{const i=e&&wc(n,s)||s;zo(n[i])&&zo(o)?n[i]=Ei(n[i],o):zo(o)?n[i]=Ei({},o):vr(o)?n[i]=o.slice():(!t||!wr(o))&&(n[i]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&Qr(arguments[o],r);return n}const Zx=(e,t,n,{allOwnKeys:r}={})=>(Qr(t,(o,s)=>{n&&Bt(o)?e[s]=mc(o,n):e[s]=o},{allOwnKeys:r}),e),Qx=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),ev=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},tv=(e,t,n,r)=>{let o,s,i;const a={};if(t=t||{},e==null)return t;do{for(o=Object.getOwnPropertyNames(e),s=o.length;s-- >0;)i=o[s],(!r||r(i,e,t))&&!a[i]&&(t[i]=e[i],a[i]=!0);e=n!==!1&&ki(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},nv=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return r!==-1&&r===n},rv=e=>{if(!e)return null;if(vr(e))return e;let t=e.length;if(!vc(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},ov=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&ki(Uint8Array)),sv=(e,t)=>{const r=(e&&e[$o]).call(e);let o;for(;(o=r.next())&&!o.done;){const s=o.value;t.call(e,s[0],s[1])}},iv=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},av=ln("HTMLFormElement"),lv=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),yc=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),cv=ln("RegExp"),Sc=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};Qr(n,(o,s)=>{let i;(i=t(o,s,e))!==!1&&(r[s]=i||o)}),Object.defineProperties(e,r)},uv=e=>{Sc(e,(t,n)=>{if(Bt(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(Bt(r)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},dv=(e,t)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return vr(e)?r(e):r(String(e).split(t)),n},fv=()=>{},pv=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function hv(e){return!!(e&&Bt(e.append)&&e[gc]==="FormData"&&e[$o])}const mv=e=>{const t=new Array(10),n=(r,o)=>{if(Zr(r)){if(t.indexOf(r)>=0)return;if(Jr(r))return r;if(!("toJSON"in r)){t[o]=r;const s=vr(r)?[]:{};return Qr(r,(i,a)=>{const l=n(i,o+1);!wr(l)&&(s[a]=l)}),t[o]=void 0,s}}return r};return n(e,0)},gv=ln("AsyncFunction"),xv=e=>e&&(Zr(e)||Bt(e))&&Bt(e.then)&&Bt(e.catch),Cc=((e,t)=>e?setImmediate:t?((n,r)=>(Xn.addEventListener("message",({source:o,data:s})=>{o===Xn&&s===n&&r.length&&r.shift()()},!1),o=>{r.push(o),Xn.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",Bt(Xn.postMessage)),vv=typeof queueMicrotask<"u"?queueMicrotask.bind(Xn):typeof process<"u"&&process.nextTick||Cc,K={isArray:vr,isArrayBuffer:xc,isBuffer:Jr,isFormData:Vx,isArrayBufferView:Dx,isString:Lx,isNumber:vc,isBoolean:$x,isObject:Zr,isPlainObject:zo,isEmptyObject:Fx,isReadableStream:qx,isRequest:Gx,isResponse:Yx,isHeaders:Xx,isUndefined:wr,isDate:Bx,isFile:zx,isBlob:Hx,isRegExp:cv,isFunction:Bt,isStream:Wx,isURLSearchParams:Kx,isTypedArray:ov,isFileList:Ux,forEach:Qr,merge:Ei,extend:Zx,trim:Jx,stripBOM:Qx,inherits:ev,toFlatObject:tv,kindOf:Fo,kindOfTest:ln,endsWith:nv,toArray:rv,forEachEntry:sv,matchAll:iv,isHTMLForm:av,hasOwnProperty:yc,hasOwnProp:yc,reduceDescriptors:Sc,freezeMethods:uv,toObjectSet:dv,toCamelCase:lv,noop:fv,toFiniteNumber:pv,findKey:wc,global:Xn,isContextDefined:bc,isSpecCompliantForm:hv,toJSONObject:mv,isAsyncFn:gv,isThenable:xv,setImmediate:Cc,asap:vv,isIterable:e=>e!=null&&Bt(e[$o])};function ke(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)}K.inherits(ke,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:K.toJSONObject(this.config),code:this.code,status:this.status}}});const Tc=ke.prototype,kc={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{kc[e]={value:e}}),Object.defineProperties(ke,kc),Object.defineProperty(Tc,"isAxiosError",{value:!0}),ke.from=(e,t,n,r,o,s)=>{const i=Object.create(Tc);K.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 ke.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 wv=null;function Ii(e){return K.isPlainObject(e)||K.isArray(e)}function Ec(e){return K.endsWith(e,"[]")?e.slice(0,-2):e}function Ic(e,t,n){return e?e.concat(t).map(function(o,s){return o=Ec(o),!n&&s?"["+o+"]":o}).join(n?".":""):t}function bv(e){return K.isArray(e)&&!e.some(Ii)}const yv=K.toFlatObject(K,{},null,function(t){return/^is[A-Z]/.test(t)});function Ho(e,t,n){if(!K.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=K.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(g,x){return!K.isUndefined(x[g])});const r=n.metaTokens,o=n.visitor||d,s=n.dots,i=n.indexes,l=(n.Blob||typeof Blob<"u"&&Blob)&&K.isSpecCompliantForm(t);if(!K.isFunction(o))throw new TypeError("visitor must be a function");function c(v){if(v===null)return"";if(K.isDate(v))return v.toISOString();if(K.isBoolean(v))return v.toString();if(!l&&K.isBlob(v))throw new ke("Blob is not supported. Use a Buffer instead.");return K.isArrayBuffer(v)||K.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(K.endsWith(g,"{}"))g=r?g:g.slice(0,-2),v=JSON.stringify(v);else if(K.isArray(v)&&bv(v)||(K.isFileList(v)||K.endsWith(g,"[]"))&&(y=K.toArray(v)))return g=Ec(g),y.forEach(function(C,k){!(K.isUndefined(C)||C===null)&&t.append(i===!0?Ic([g],k,s):i===null?g:g+"[]",c(C))}),!1}return Ii(v)?!0:(t.append(Ic(x,g,s),c(v)),!1)}const p=[],m=Object.assign(yv,{defaultVisitor:d,convertValue:c,isVisitable:Ii});function f(v,g){if(!K.isUndefined(v)){if(p.indexOf(v)!==-1)throw Error("Circular reference detected in "+g.join("."));p.push(v),K.forEach(v,function(y,b){(!(K.isUndefined(y)||y===null)&&o.call(t,y,K.isString(b)?b.trim():b,g,m))===!0&&f(y,g?g.concat(b):[b])}),p.pop()}}if(!K.isObject(e))throw new TypeError("data must be an object");return f(e),t}function Nc(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function Ni(e,t){this._pairs=[],e&&Ho(e,this,t)}const Ac=Ni.prototype;Ac.append=function(t,n){this._pairs.push([t,n])},Ac.toString=function(t){const n=t?function(r){return t.call(this,r,Nc)}:Nc;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function Sv(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Pc(e,t,n){if(!t)return e;const r=n&&n.encode||Sv;K.isFunction(n)&&(n={serialize:n});const o=n&&n.serialize;let s;if(o?s=o(t,n):s=K.isURLSearchParams(t)?t.toString():new Ni(t,n).toString(r),s){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}class jc{constructor(){this.handlers=[]}use(t,n,r){return this.handlers.push({fulfilled:t,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){K.forEach(this.handlers,function(r){r!==null&&t(r)})}}const _c={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Cv={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:Ni,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},Ai=typeof window<"u"&&typeof document<"u",Pi=typeof navigator=="object"&&navigator||void 0,Tv=Ai&&(!Pi||["ReactNative","NativeScript","NS"].indexOf(Pi.product)<0),kv=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Ev=Ai&&window.location.href||"http://localhost",jt={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Ai,hasStandardBrowserEnv:Tv,hasStandardBrowserWebWorkerEnv:kv,navigator:Pi,origin:Ev},Symbol.toStringTag,{value:"Module"})),...Cv};function Iv(e,t){return Ho(e,new jt.classes.URLSearchParams,{visitor:function(n,r,o,s){return jt.isNode&&K.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function Nv(e){return K.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function Av(e){const t={},n=Object.keys(e);let r;const o=n.length;let s;for(r=0;r<o;r++)s=n[r],t[s]=e[s];return t}function Rc(e){function t(n,r,o,s){let i=n[s++];if(i==="__proto__")return!0;const a=Number.isFinite(+i),l=s>=n.length;return i=!i&&K.isArray(o)?o.length:i,l?(K.hasOwnProp(o,i)?o[i]=[o[i],r]:o[i]=r,!a):((!o[i]||!K.isObject(o[i]))&&(o[i]=[]),t(n,r,o[i],s)&&K.isArray(o[i])&&(o[i]=Av(o[i])),!a)}if(K.isFormData(e)&&K.isFunction(e.entries)){const n={};return K.forEachEntry(e,(r,o)=>{t(Nv(r),o,n,0)}),n}return null}function Pv(e,t,n){if(K.isString(e))try{return(t||JSON.parse)(e),K.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const eo={transitional:_c,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",o=r.indexOf("application/json")>-1,s=K.isObject(t);if(s&&K.isHTMLForm(t)&&(t=new FormData(t)),K.isFormData(t))return o?JSON.stringify(Rc(t)):t;if(K.isArrayBuffer(t)||K.isBuffer(t)||K.isStream(t)||K.isFile(t)||K.isBlob(t)||K.isReadableStream(t))return t;if(K.isArrayBufferView(t))return t.buffer;if(K.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let a;if(s){if(r.indexOf("application/x-www-form-urlencoded")>-1)return Iv(t,this.formSerializer).toString();if((a=K.isFileList(t))||r.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return Ho(a?{"files[]":t}:t,l&&new l,this.formSerializer)}}return s||o?(n.setContentType("application/json",!1),Pv(t)):t}],transformResponse:[function(t){const n=this.transitional||eo.transitional,r=n&&n.forcedJSONParsing,o=this.responseType==="json";if(K.isResponse(t)||K.isReadableStream(t))return t;if(t&&K.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"?ke.from(a,ke.ERR_BAD_RESPONSE,this,null,this.response):a}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:jt.classes.FormData,Blob:jt.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};K.forEach(["delete","get","head","post","put","patch"],e=>{eo.headers[e]={}});const jv=K.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),_v=e=>{const t={};let n,r,o;return e&&e.split(`
|
|
31
|
+
`).forEach(function(i){o=i.indexOf(":"),n=i.substring(0,o).trim().toLowerCase(),r=i.substring(o+1).trim(),!(!n||t[n]&&jv[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},Mc=Symbol("internals");function to(e){return e&&String(e).trim().toLowerCase()}function Uo(e){return e===!1||e==null?e:K.isArray(e)?e.map(Uo):String(e)}function Rv(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}const Mv=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function ji(e,t,n,r,o){if(K.isFunction(r))return r.call(this,t,n);if(o&&(t=n),!!K.isString(t)){if(K.isString(r))return t.indexOf(r)!==-1;if(K.isRegExp(r))return r.test(t)}}function Ov(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function Dv(e,t){const n=K.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{value:function(o,s,i){return this[r].call(this,t,o,s,i)},configurable:!0})})}let zt=class{constructor(t){t&&this.set(t)}set(t,n,r){const o=this;function s(a,l,c){const d=to(l);if(!d)throw new Error("header name must be a non-empty string");const p=K.findKey(o,d);(!p||o[p]===void 0||c===!0||c===void 0&&o[p]!==!1)&&(o[p||l]=Uo(a))}const i=(a,l)=>K.forEach(a,(c,d)=>s(c,d,l));if(K.isPlainObject(t)||t instanceof this.constructor)i(t,n);else if(K.isString(t)&&(t=t.trim())&&!Mv(t))i(_v(t),n);else if(K.isObject(t)&&K.isIterable(t)){let a={},l,c;for(const d of t){if(!K.isArray(d))throw TypeError("Object iterator must return a key-value pair");a[c=d[0]]=(l=a[c])?K.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=to(t),t){const r=K.findKey(this,t);if(r){const o=this[r];if(!n)return o;if(n===!0)return Rv(o);if(K.isFunction(n))return n.call(this,o,r);if(K.isRegExp(n))return n.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=to(t),t){const r=K.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||ji(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let o=!1;function s(i){if(i=to(i),i){const a=K.findKey(r,i);a&&(!n||ji(r,r[a],a,n))&&(delete r[a],o=!0)}}return K.isArray(t)?t.forEach(s):s(t),o}clear(t){const n=Object.keys(this);let r=n.length,o=!1;for(;r--;){const s=n[r];(!t||ji(this,this[s],s,t,!0))&&(delete this[s],o=!0)}return o}normalize(t){const n=this,r={};return K.forEach(this,(o,s)=>{const i=K.findKey(r,s);if(i){n[i]=Uo(o),delete n[s];return}const a=t?Ov(s):String(s).trim();a!==s&&delete n[s],n[a]=Uo(o),r[a]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return K.forEach(this,(r,o)=>{r!=null&&r!==!1&&(n[o]=t&&K.isArray(r)?r.join(", "):r)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,n])=>t+": "+n).join(`
|
|
32
|
+
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const r=new this(t);return n.forEach(o=>r.set(o)),r}static accessor(t){const r=(this[Mc]=this[Mc]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=to(i);r[a]||(Dv(o,i),r[a]=!0)}return K.isArray(t)?t.forEach(s):s(t),this}};zt.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),K.reduceDescriptors(zt.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),K.freezeMethods(zt);function _i(e,t){const n=this||eo,r=t||n,o=zt.from(r.headers);let s=r.data;return K.forEach(e,function(a){s=a.call(n,s,o.normalize(),t?t.status:void 0)}),o.normalize(),s}function Oc(e){return!!(e&&e.__CANCEL__)}function br(e,t,n){ke.call(this,e??"canceled",ke.ERR_CANCELED,t,n),this.name="CanceledError"}K.inherits(br,ke,{__CANCEL__:!0});function Dc(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new ke("Request failed with status code "+n.status,[ke.ERR_BAD_REQUEST,ke.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function Lv(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function $v(e,t){e=e||10;const n=new Array(e),r=new Array(e);let o=0,s=0,i;return t=t!==void 0?t:1e3,function(l){const c=Date.now(),d=r[s];i||(i=c),n[o]=l,r[o]=c;let p=s,m=0;for(;p!==o;)m+=n[p++],p=p%e;if(o=(o+1)%e,o===s&&(s=(s+1)%e),c-i<t)return;const f=d&&c-d;return f?Math.round(m*1e3/f):void 0}}function Fv(e,t){let n=0,r=1e3/t,o,s;const i=(c,d=Date.now())=>{n=d,o=null,s&&(clearTimeout(s),s=null),e(...c)};return[(...c)=>{const d=Date.now(),p=d-n;p>=r?i(c,d):(o=c,s||(s=setTimeout(()=>{s=null,i(o)},r-p)))},()=>o&&i(o)]}const Wo=(e,t,n=3)=>{let r=0;const o=$v(50,250);return Fv(s=>{const i=s.loaded,a=s.lengthComputable?s.total:void 0,l=i-r,c=o(l),d=i<=a;r=i;const p={loaded:i,total:a,progress:a?i/a:void 0,bytes:l,rate:c||void 0,estimated:c&&a&&d?(a-i)/c:void 0,event:s,lengthComputable:a!=null,[t?"download":"upload"]:!0};e(p)},n)},Lc=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},$c=e=>(...t)=>K.asap(()=>e(...t)),Bv=jt.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,jt.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(jt.origin),jt.navigator&&/(msie|trident)/i.test(jt.navigator.userAgent)):()=>!0,zv=jt.hasStandardBrowserEnv?{write(e,t,n,r,o,s){const i=[e+"="+encodeURIComponent(t)];K.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),K.isString(r)&&i.push("path="+r),K.isString(o)&&i.push("domain="+o),s===!0&&i.push("secure"),document.cookie=i.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function Hv(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Uv(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function Fc(e,t,n){let r=!Hv(t);return e&&(r||n==!1)?Uv(e,t):t}const Bc=e=>e instanceof zt?{...e}:e;function Jn(e,t){t=t||{};const n={};function r(c,d,p,m){return K.isPlainObject(c)&&K.isPlainObject(d)?K.merge.call({caseless:m},c,d):K.isPlainObject(d)?K.merge({},d):K.isArray(d)?d.slice():d}function o(c,d,p,m){if(K.isUndefined(d)){if(!K.isUndefined(c))return r(void 0,c,p,m)}else return r(c,d,p,m)}function s(c,d){if(!K.isUndefined(d))return r(void 0,d)}function i(c,d){if(K.isUndefined(d)){if(!K.isUndefined(c))return r(void 0,c)}else return r(void 0,d)}function a(c,d,p){if(p in t)return r(c,d);if(p in e)return r(void 0,c)}const l={url:s,method:s,data:s,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:a,headers:(c,d,p)=>o(Bc(c),Bc(d),p,!0)};return K.forEach(Object.keys({...e,...t}),function(d){const p=l[d]||o,m=p(e[d],t[d],d);K.isUndefined(m)&&p!==a||(n[d]=m)}),n}const zc=e=>{const t=Jn({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=t;if(t.headers=i=zt.from(i),t.url=Pc(Fc(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&i.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),K.isFormData(n)){if(jt.hasStandardBrowserEnv||jt.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(K.isFunction(n.getHeaders)){const l=n.getHeaders(),c=["content-type","content-length"];Object.entries(l).forEach(([d,p])=>{c.includes(d.toLowerCase())&&i.set(d,p)})}}if(jt.hasStandardBrowserEnv&&(r&&K.isFunction(r)&&(r=r(t)),r||r!==!1&&Bv(t.url))){const l=o&&s&&zv.read(s);l&&i.set(o,l)}return t},Wv=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=zc(e);let s=o.data;const i=zt.from(o.headers).normalize();let{responseType:a,onUploadProgress:l,onDownloadProgress:c}=o,d,p,m,f,v;function g(){f&&f(),v&&v(),o.cancelToken&&o.cancelToken.unsubscribe(d),o.signal&&o.signal.removeEventListener("abort",d)}let x=new XMLHttpRequest;x.open(o.method.toUpperCase(),o.url,!0),x.timeout=o.timeout;function y(){if(!x)return;const C=zt.from("getAllResponseHeaders"in x&&x.getAllResponseHeaders()),S={data:!a||a==="text"||a==="json"?x.responseText:x.response,status:x.status,statusText:x.statusText,headers:C,config:e,request:x};Dc(function(E){n(E),g()},function(E){r(E),g()},S),x=null}"onloadend"in x?x.onloadend=y:x.onreadystatechange=function(){!x||x.readyState!==4||x.status===0&&!(x.responseURL&&x.responseURL.indexOf("file:")===0)||setTimeout(y)},x.onabort=function(){x&&(r(new ke("Request aborted",ke.ECONNABORTED,e,x)),x=null)},x.onerror=function(k){const S=k&&k.message?k.message:"Network Error",T=new ke(S,ke.ERR_NETWORK,e,x);T.event=k||null,r(T),x=null},x.ontimeout=function(){let k=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const S=o.transitional||_c;o.timeoutErrorMessage&&(k=o.timeoutErrorMessage),r(new ke(k,S.clarifyTimeoutError?ke.ETIMEDOUT:ke.ECONNABORTED,e,x)),x=null},s===void 0&&i.setContentType(null),"setRequestHeader"in x&&K.forEach(i.toJSON(),function(k,S){x.setRequestHeader(S,k)}),K.isUndefined(o.withCredentials)||(x.withCredentials=!!o.withCredentials),a&&a!=="json"&&(x.responseType=o.responseType),c&&([m,v]=Wo(c,!0),x.addEventListener("progress",m)),l&&x.upload&&([p,f]=Wo(l),x.upload.addEventListener("progress",p),x.upload.addEventListener("loadend",f)),(o.cancelToken||o.signal)&&(d=C=>{x&&(r(!C||C.type?new br(null,e,x):C),x.abort(),x=null)},o.cancelToken&&o.cancelToken.subscribe(d),o.signal&&(o.signal.aborted?d():o.signal.addEventListener("abort",d)));const b=Lv(o.url);if(b&&jt.protocols.indexOf(b)===-1){r(new ke("Unsupported protocol "+b+":",ke.ERR_BAD_REQUEST,e));return}x.send(s||null)})},Vv=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let r=new AbortController,o;const s=function(c){if(!o){o=!0,a();const d=c instanceof Error?c:this.reason;r.abort(d instanceof ke?d:new br(d instanceof Error?d.message:d))}};let i=t&&setTimeout(()=>{i=null,s(new ke(`timeout ${t} of ms exceeded`,ke.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=()=>K.asap(a),l}},Kv=function*(e,t){let n=e.byteLength;if(n<t){yield e;return}let r=0,o;for(;r<n;)o=r+t,yield e.slice(r,o),r=o},qv=async function*(e,t){for await(const n of Gv(e))yield*Kv(n,t)},Gv=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:n,value:r}=await t.read();if(n)break;yield r}}finally{await t.cancel()}},Hc=(e,t,n,r)=>{const o=qv(e,t);let s=0,i,a=l=>{i||(i=!0,r&&r(l))};return new ReadableStream({async pull(l){try{const{done:c,value:d}=await o.next();if(c){a(),l.close();return}let p=d.byteLength;if(n){let m=s+=p;n(m)}l.enqueue(new Uint8Array(d))}catch(c){throw a(c),c}},cancel(l){return a(l),o.return()}},{highWaterMark:2})},Uc=64*1024,{isFunction:Vo}=K,Yv=(({Request:e,Response:t})=>({Request:e,Response:t}))(K.global),{ReadableStream:Wc,TextEncoder:Vc}=K.global,Kc=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Xv=e=>{e=K.merge.call({skipUndefined:!0},Yv,e);const{fetch:t,Request:n,Response:r}=e,o=t?Vo(t):typeof fetch=="function",s=Vo(n),i=Vo(r);if(!o)return!1;const a=o&&Vo(Wc),l=o&&(typeof Vc=="function"?(v=>g=>v.encode(g))(new Vc):async v=>new Uint8Array(await new n(v).arrayBuffer())),c=s&&a&&Kc(()=>{let v=!1;const g=new n(jt.origin,{body:new Wc,method:"POST",get duplex(){return v=!0,"half"}}).headers.has("Content-Type");return v&&!g}),d=i&&a&&Kc(()=>K.isReadableStream(new r("").body)),p={stream:d&&(v=>v.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(v=>{!p[v]&&(p[v]=(g,x)=>{let y=g&&g[v];if(y)return y.call(g);throw new ke(`Response type '${v}' is not supported`,ke.ERR_NOT_SUPPORT,x)})});const m=async v=>{if(v==null)return 0;if(K.isBlob(v))return v.size;if(K.isSpecCompliantForm(v))return(await new n(jt.origin,{method:"POST",body:v}).arrayBuffer()).byteLength;if(K.isArrayBufferView(v)||K.isArrayBuffer(v))return v.byteLength;if(K.isURLSearchParams(v)&&(v=v+""),K.isString(v))return(await l(v)).byteLength},f=async(v,g)=>{const x=K.toFiniteNumber(v.getContentLength());return x??m(g)};return async v=>{let{url:g,method:x,data:y,signal:b,cancelToken:C,timeout:k,onDownloadProgress:S,onUploadProgress:T,responseType:E,headers:A,withCredentials:P="same-origin",fetchOptions:$}=zc(v),L=t||fetch;E=E?(E+"").toLowerCase():"text";let H=Vv([b,C&&C.toAbortSignal()],k),Y=null;const _=H&&H.unsubscribe&&(()=>{H.unsubscribe()});let V;try{if(T&&c&&x!=="get"&&x!=="head"&&(V=await f(A,y))!==0){let Z=new n(g,{method:"POST",body:y,duplex:"half"}),R;if(K.isFormData(y)&&(R=Z.headers.get("content-type"))&&A.setContentType(R),Z.body){const[q,j]=Lc(V,Wo($c(T)));y=Hc(Z.body,Uc,q,j)}}K.isString(P)||(P=P?"include":"omit");const G=s&&"credentials"in n.prototype,W={...$,signal:H,method:x.toUpperCase(),headers:A.normalize().toJSON(),body:y,duplex:"half",credentials:G?P:void 0};Y=s&&new n(g,W);let D=await(s?L(Y,$):L(g,W));const I=d&&(E==="stream"||E==="response");if(d&&(S||I&&_)){const Z={};["status","statusText","headers"].forEach(B=>{Z[B]=D[B]});const R=K.toFiniteNumber(D.headers.get("content-length")),[q,j]=S&&Lc(R,Wo($c(S),!0))||[];D=new r(Hc(D.body,Uc,q,()=>{j&&j(),_&&_()}),Z)}E=E||"text";let U=await p[K.findKey(p,E)||"text"](D,v);return!I&&_&&_(),await new Promise((Z,R)=>{Dc(Z,R,{data:U,headers:zt.from(D.headers),status:D.status,statusText:D.statusText,config:v,request:Y})})}catch(G){throw _&&_(),G&&G.name==="TypeError"&&/Load failed|fetch/i.test(G.message)?Object.assign(new ke("Network Error",ke.ERR_NETWORK,v,Y),{cause:G.cause||G}):ke.from(G,G&&G.code,v,Y)}}},Jv=new Map,qc=e=>{let t=e?e.env:{};const{fetch:n,Request:r,Response:o}=t,s=[r,o,n];let i=s.length,a=i,l,c,d=Jv;for(;a--;)l=s[a],c=d.get(l),c===void 0&&d.set(l,c=a?new Map:Xv(t)),d=c;return c};qc();const Ri={http:wv,xhr:Wv,fetch:{get:qc}};K.forEach(Ri,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Gc=e=>`- ${e}`,Zv=e=>K.isFunction(e)||e===null||e===!1,Yc={getAdapter:(e,t)=>{e=K.isArray(e)?e:[e];const{length:n}=e;let r,o;const s={};for(let i=0;i<n;i++){r=e[i];let a;if(o=r,!Zv(r)&&(o=Ri[(a=String(r)).toLowerCase()],o===void 0))throw new ke(`Unknown adapter '${a}'`);if(o&&(K.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(Gc).join(`
|
|
34
|
-
`):" "+Gc(i[0]):"as no adapter specified";throw new
|
|
35
|
-
`+s):r.stack=s}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=Jn(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:s}=n;r!==void 0&&qo.assertOptions(r,{silentJSONParsing:xn.transitional(xn.boolean),forcedJSONParsing:xn.transitional(xn.boolean),clarifyTimeoutError:xn.transitional(xn.boolean)},!1),o!=null&&(q.isFunction(o)?n.paramsSerializer={serialize:o}:qo.assertOptions(o,{encode:xn.function,serialize:xn.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),qo.assertOptions(n,{baseUrl:xn.spelling("baseURL"),withXsrfToken:xn.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=s&&q.merge(s.common,s[n.method]);s&&q.forEach(["delete","get","head","post","put","patch","common"],v=>{delete s[v]}),n.headers=zt.concat(i,s);const a=[];let c=!0;this.interceptors.request.forEach(function(g){typeof g.runWhen=="function"&&g.runWhen(n)===!1||(c=c&&g.synchronous,a.unshift(g.fulfilled,g.rejected))});const l=[];this.interceptors.response.forEach(function(g){l.push(g.fulfilled,g.rejected)});let d,p=0,m;if(!c){const v=[Xc.bind(this),void 0];for(v.unshift(...a),v.push(...l),m=v.length,d=Promise.resolve(n);p<m;)d=d.then(v[p++],v[p++]);return d}m=a.length;let f=n;for(;p<m;){const v=a[p++],g=a[p++];try{f=v(f)}catch(x){g.call(this,x);break}}try{d=Xc.call(this,f)}catch(v){return Promise.reject(v)}for(p=0,m=l.length;p<m;)d=d.then(l[p++],l[p++]);return d}getUri(t){t=Jn(this.defaults,t);const n=Fc(t.baseURL,t.url,t.allowAbsoluteUrls);return Pc(n,t.params,t.paramsSerializer)}};q.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}))}}),q.forEach(["post","put","patch"],function(t){function n(r){return function(s,i,a){return this.request(Jn(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}Zn.prototype[t]=n(),Zn.prototype[t+"Form"]=n(!0)});let ew=class vx{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(s){n=s});const r=this;this.promise.then(o=>{if(!r._listeners)return;let s=r._listeners.length;for(;s-- >0;)r._listeners[s](o);r._listeners=null}),this.promise.then=o=>{let s;const i=new Promise(a=>{r.subscribe(a),s=a}).then(o);return i.cancel=function(){r.unsubscribe(s)},i},t(function(s,i,a){r.reason||(r.reason=new br(s,i,a),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const t=new AbortController,n=r=>{t.abort(r)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new vx(function(o){t=o}),cancel:t}}};function tw(e){return function(n){return e.apply(null,n)}}function nw(e){return q.isObject(e)&&e.isAxiosError===!0}const Oi={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Oi).forEach(([e,t])=>{Oi[t]=e});function Qc(e){const t=new Zn(e),n=mc(Zn.prototype.request,t);return q.extend(n,Zn.prototype,t,{allOwnKeys:!0}),q.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return Qc(Jn(e,o))},n}const ft=Qc(eo);ft.Axios=Zn,ft.CanceledError=br,ft.CancelToken=ew,ft.isCancel=Oc,ft.VERSION=Jc,ft.toFormData=Ho,ft.AxiosError=Ie,ft.Cancel=ft.CanceledError,ft.all=function(t){return Promise.all(t)},ft.spread=tw,ft.isAxiosError=nw,ft.mergeConfig=Jn,ft.AxiosHeaders=zt,ft.formToJSON=e=>Rc(q.isHTMLForm(e)?new FormData(e):e),ft.getAdapter=Yc.getAdapter,ft.HttpStatusCode=Oi,ft.default=ft;const{Axios:TN,AxiosError:kN,CanceledError:EN,isCancel:eu,CancelToken:IN,VERSION:NN,all:AN,Cancel:PN,isAxiosError:jN,spread:_N,toFormData:RN,AxiosHeaders:MN,HttpStatusCode:ON,formToJSON:DN,getAdapter:LN,mergeConfig:$N}=ft,tu=typeof window<"u"?window.__API_BASE_URL__:void 0,nu=tu?vn(tu):void 0;function vn(e){const n=(e!=null&&e.trim()?e.trim():"/api/chat").replace(/\/+$/,"");return n?n.endsWith("/chat")?n:`${n}/chat`:"/api/chat"}let Go=null;const Di=new Set;function ru(){return Go}function Yo(e){Go=e,Di.forEach(t=>t(e))}function ou(e){return Di.add(e),()=>Di.delete(e)}const su=3e4,iu=9e4,Gt=ft.create({...nu?{baseURL:nu}:{},timeout:su,withCredentials:!0});Gt.interceptors.request.use(e=>(Go&&(e.headers.Authorization=`Bearer ${Go}`),e)),Gt.interceptors.response.use(e=>{if(typeof window<"u"&&(e!=null&&e.data))try{const t=e.data,n=t.data||{},r=typeof t.token=="string"&&t.token||typeof n.token=="string"&&n.token||null,o=typeof t.expires_at=="number"&&t.expires_at||typeof n.expires_at=="number"&&n.expires_at||typeof t.expiresAt=="number"&&t.expiresAt||typeof n.expiresAt=="number"&&n.expiresAt||null;r&&(localStorage.setItem("authToken",r),Yo(r)),o&&localStorage.setItem("authTokenExpiresAt",o.toString()),(r||o)&&window.dispatchEvent(new CustomEvent("smartorg:chat-token-updated",{detail:{token:r,expiresAt:o}}))}catch(t){console.warn("[chat-api] Error storing token:",t)}return e},e=>Promise.reject(e));async function Yt(e,t){return Gt.defaults.baseURL?(await Gt.get(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}async function Xo(e,t,n){return Gt.defaults.baseURL?(await Gt.post(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function au(e,t,n){return Gt.defaults.baseURL?(await Gt.put(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function Li(e,t){return Gt.defaults.baseURL?(await Gt.delete(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}function Ot(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class Jo{get baseUrl(){const t=Gt.defaults.baseURL;return t?vn(String(t)):""}updateConfig(t){t.baseUrl&&(Gt.defaults.baseURL=vn(String(t.baseUrl))),t.authToken!==void 0&&Yo(t.authToken)}getAuthToken(){return ru()}setAuthToken(t){Yo(t)}onTokenChange(t){return ou(t)}async listThreads(){const t=await Yt("/threads"),n=Ot(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async listSharedThreads(){const t=await Yt("/threads/shared"),n=Ot(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async createThread(t){const r=await Xo("/threads",t?{title:t}:void 0);return Ot(r)}async updateThread(t,n){const r=await au(`/threads/${t}`,{title:n});return Ot(r)}async deleteThread(t){const n=await Li(`/threads/${t}`);return Ot(n)}async shareThread(t,n){const r=await Xo(`/threads/${t}/share`,{shared_with_user_id:n});return Ot(r)}async threadInfo(t){const n=await Yt(`/threads/${t}/info`);return Ot(n)}async listAgents(){const t=await Yt("/agents"),n=Ot(t);return(n==null?void 0:n.items)??[]}async getAgent(t){const n=await Yt(`/agents/${t}`);return Ot(n)}async getAgentSchema(t){const n=await Yt(`/agents/${t}/schema`);return Ot(n)}async getState(t){const n=await Yt(`/threads/${t.threadId}/state`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return Ot(n)}async getStateHistory(t){const n=await Yt(`/threads/${t.threadId}/state/history`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs},timeout:iu,signal:t.signal});return Ot(n)}async cancelRun(t){const n=await Xo("/runs/cancel",{threadId:t});return Ot(n)}async unshareThread(t,n){const r=await Li(`/threads/${t}/share/${n}`);return Ot(r)}}const Nn=new Jo,rw=Jo,ow=Jo;async function $i(e,t){return await Yt(e,{responseType:"blob",onDownloadProgress:r=>{try{if(t&&r.lengthComputable){const o=r.loaded/r.total;t(o)}}catch{}},maxBodyLength:1/0})}async function sw(e,t){const n=await $i(`/files/${e}/view`,t),r=URL.createObjectURL(n);window.open(r,"_blank"),setTimeout(()=>URL.revokeObjectURL(r),6e4)}async function Fi(e,t){return await(await $i(`/files/${e}/view`,t)).text()}async function lu(e,t){const n=await $i(`/files/${e}/download`,t),r=URL.createObjectURL(n);let o=`file_${e}`;try{const i=await Yt(`/files/${e}`);o=(i==null?void 0:i.filename)??o}catch{}const s=document.createElement("a");s.href=r,s.download=o,document.body.appendChild(s),s.click(),s.remove(),setTimeout(()=>URL.revokeObjectURL(r),6e4)}async function iw(e){return await Yt(`/files/${e}`)}async function cu(e,t=50,n=0){const r={limit:t,offset:n};return e&&(r.thread_id=e),await Yt("/files",{params:r})}const uu=w.createContext(null);function du({children:e,apiConfig:t}){const n=Nn;if(t){const o=n.baseUrl,s=n.getAuthToken();t.baseUrl&&t.baseUrl!==o&&n.updateConfig({baseUrl:t.baseUrl}),t.apiKey!==void 0&&t.apiKey!==s&&n.updateConfig({authToken:t.apiKey})}const r={token:n.getAuthToken(),setToken:o=>n.setAuthToken(o),api:n,baseUrl:n.baseUrl};return u.jsx(uu.Provider,{value:r,children:e})}async function fu(e){return await new Promise((t,n)=>{const r=new FileReader;r.onload=()=>{try{const o=r.result,s=new Uint8Array(o);let i="";const a=s.byteLength;for(let c=0;c<a;c++)i+=String.fromCharCode(s[c]);t(btoa(i))}catch(o){n(o)}},r.onerror=o=>n(o),r.readAsArrayBuffer(e)})}async function pu(e=[]){const t=[],n=[];for(const r of e)try{const o=await fu(r);n.push({filename:r.name,data:o,mime_type:r.type||"application/octet-stream"})}catch{}return{contentParts:t,filesInfo:n}}function no(){const e=w.useContext(uu);if(!e)throw new Error("useApi must be used within ApiProvider");return e}function hu(e){return!!e&&typeof e=="object"&&"data"in e}function Bi(e){return e.filter(t=>{var i;if(t.role!=="assistant")return!0;const n=(t.content??[]).some(a=>{var c;return a&&a.type==="text"&&((c=a.text)==null?void 0:c.trim())}),r=(t.content??[]).some(a=>a&&a.type==="image_url"),o=(i=t.artifact)==null?void 0:i.plots,s=Array.isArray(o)&&o.length>0;return!!(n||r||s)})}function ro(e,t,n){return t<0||t>=e.length?e:[...e.slice(0,t),n,...e.slice(t+1)]}function aw(e){let t=!1;const n=e.map(r=>{const o=(r.content??[]).filter(s=>s.type!=="interrupt");return o.length!==r.content.length?(t=!0,{...r,content:o}):r});return t?n:e}function mu(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="assistant")return e[t].id;return null}function gu(e){return!e||!e.length?"":e.filter(t=>t.type==="text").map(t=>t.text??"").join("")}function xu(e,t,n,r){const o={...n};if(r!==null&&typeof r=="number"){if(typeof o.lastSeq=="number"&&r<=o.lastSeq)return{newParts:e,newMeta:o,changed:!1};o.lastSeq=r}const s=t.filter(p=>p.type==="text").map(p=>p.text??"").join(""),i=t.filter(p=>p.type!=="text"),a=o.lastText??gu(e);let c="",l=e.slice();if(s){const p=lw(a,s);if(p===""?c="":p===s?c=s:c=p,c){const m=l[l.length-1];if((m==null?void 0:m.type)==="text"){const f=m.text??"",v={...m,text:f+c};l=[...l.slice(0,l.length-1),v]}else l=[...l,{type:"text",text:c}];o.lastText=a+c}else o.lastText=a}i.length&&(l=[...l,...i]);const d=!!(c||i.length);return{newParts:l,newMeta:o,changed:d}}function vu(e){return e.replace(/\s+/g," ").trim()}function lw(e,t){if(!t)return"";if(!e)return t;if(e===t)return"";const n=Math.min(e.length,t.length);for(let i=n;i>0;i--)if(e.slice(-i)===t.slice(0,i))return t.slice(i);const r=vu(e),o=vu(t);if(r===o)return"";const s=Math.min(r.length,o.length);for(let i=s;i>0;i--)if(r.slice(-i)===o.slice(0,i))return t;return t}function cw(e,t,n){for(let r=e.length-1;r>=0;r--)if(e[r].role==="assistant"){const s={...e[r],checkpointId:t,checkpointNs:n??void 0};return ro(e,r,s)}return e}function wu(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}function uw(e={}){const t=w.useMemo(()=>vn(e.baseUrl),[e.baseUrl]),n=e.streamPath??"/runs/stream",[r,o]=w.useState(e.token??null),s=w.useRef(e.headers??{}),i=e.credentials??"include",[a,c]=w.useState(!1),[l,d]=w.useState(null),[p,m]=w.useState(""),[f,v]=w.useState(null),[g,x]=w.useState(0),[y,b]=w.useState(!1),[C,k]=w.useState(null),S=w.useRef(null),T=w.useRef(!0),E=w.useRef(0),A=w.useRef(null),j=w.useRef(null),L=w.useRef(null),H=w.useRef(null),V=w.useRef({messageId:null,lastSeq:null,lastText:""}),J=w.useCallback($=>{o($)},[]),R=w.useCallback(()=>{m(""),v(null),d(null),j.current=null,L.current=null,H.current=null,k(null),V.current={messageId:null,lastSeq:null,lastText:""}},[]),G=w.useCallback(()=>{var U;console.debug("[use-chat] stop() invoked - aborting stream");const $=(U=A.current)==null?void 0:U.threadId,P=()=>{var Z;(Z=S.current)==null||Z.abort(),S.current=null,A.current=null,c(!1),b(!1),E.current=0,x(0)};($?Nn.cancelRun($).catch(Z=>{console.warn("[use-chat] cancel run failed:",Z)}):Promise.resolve()).finally(P)},[]),K=w.useCallback(($,P,I)=>{S.current&&(S.current.abort(),S.current=null),c(!0),d(null),e.autoAppendAssistant!==!1&&m(""),v(null),j.current=null,L.current=null,H.current=null,k(null),V.current={messageId:null,lastSeq:null,lastText:""};const U=new AbortController;S.current=U;let Z=null,M=null,Y=!1;return A.current={threadId:$.threadId??null,headers:{}},(async()=>{var z,W,O,D,B,Q,oe,ie,Ce,ve,Re,We,De,qe,ze,xt,lt,et;const _=Le=>{var Ve;try{const $e=JSON.parse(JSON.stringify(Le));return(Ve=$e==null?void 0:$e.payload)!=null&&Ve.files_info&&Array.isArray($e.payload.files_info)&&($e.payload.files_info=$e.payload.files_info.map(ke=>({...ke,data:ke!=null&&ke.data?`<base64 ${String(ke.data).length} chars>`:ke==null?void 0:ke.data}))),$e}catch{return Le}};try{let Le={};try{if(r)Le={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const He=window.__AUTH_TOKEN__,Ct=((z=window.localStorage)==null?void 0:z.getItem("authToken"))||null;let ee=null;try{const tt=(W=window.localStorage)==null?void 0:W.getItem("chat-settings");tt&&(ee=((O=JSON.parse(tt))==null?void 0:O.apiKey)||null)}catch{}const fe=He||Ct||ee||null;fe&&(Le={Authorization:`Bearer ${fe}`})}}catch{}console.debug("[use-chat] POST",t+n,_($));let Ve={};if(typeof window<"u")try{const Pe=(D=window.localStorage)==null?void 0:D.getItem("authSessionId");Pe&&(Ve={"X-Session-Id":Pe})}catch{}const $e={...Le,...Ve,...s.current},ke={"Content-Type":"application/json",Accept:"text/event-stream",...$e},Ae=await fetch(t+n,{method:"POST",headers:ke,body:JSON.stringify($),signal:U.signal,credentials:i});if(A.current&&(A.current.headers=$e),!Ae.ok||!Ae.body){const Pe=await Ae.text().catch(()=>"");console.debug("[use-chat] non-OK response",Ae.status,Pe==null?void 0:Pe.slice(0,500));const He=`stream ${Ae.status}${Pe?": "+Pe:""}`;throw(B=I==null?void 0:I.onConnectionError)==null||B.call(I,He),Y=!0,Z="error",M=He,new Error(He)}b(!0);const ct=Ae.body.getReader(),kt=new TextDecoder;let st="",Et=[];E.current=0,x(0);let vt=0,dt=null;const St=()=>{if(Et.length){const Pe=Et.join("");Et=[],T.current&&m(He=>He+Pe)}dt=null},wt=()=>{typeof window<"u"&&dt==null&&(dt=requestAnimationFrame(St))};let At=Date.now();const on=setInterval(()=>{var Pe;if(Date.now()-At>18e5){const He="Stream idle timeout";d(He),Z="error",M=He,U.abort(),(Pe=I==null?void 0:I.onError)==null||Pe.call(I,He)}},5e3),It=1024*1024;try{const Pe=Ae.headers.get("X-Thread-Id")||Ae.headers.get("x-thread-id"),He=Ae.headers.get("X-Thread-Created")||Ae.headers.get("x-thread-created"),Ct=Pe??null,ee=String(He??"").toLowerCase()==="true";for(A.current&&!A.current.threadId&&(A.current={...A.current,threadId:Ct}),(Q=I==null?void 0:I.onOpen)==null||Q.call(I,{threadId:Ct,created:ee});;){const{value:fe,done:tt}=await ct.read();if(tt)break;st+=kt.decode(fe,{stream:!0}),st.length>It&&(st="",console.warn("Stream buffer reset: exceeded 1MB"));let ge;for(;(ge=st.indexOf(`
|
|
34
|
+
`):" "+Gc(i[0]):"as no adapter specified";throw new ke("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return o},adapters:Ri};function Mi(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new br(null,e)}function Xc(e){return Mi(e),e.headers=zt.from(e.headers),e.data=_i.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),Yc.getAdapter(e.adapter||eo.adapter,e)(e).then(function(r){return Mi(e),r.data=_i.call(e,e.transformResponse,r),r.headers=zt.from(r.headers),r},function(r){return Oc(r)||(Mi(e),r&&r.response&&(r.response.data=_i.call(e,e.transformResponse,r.response),r.response.headers=zt.from(r.response.headers))),Promise.reject(r)})}const Jc="1.12.2",Ko={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Ko[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const Zc={};Ko.transitional=function(t,n,r){function o(s,i){return"[Axios v"+Jc+"] Transitional option '"+s+"'"+i+(r?". "+r:"")}return(s,i,a)=>{if(t===!1)throw new ke(o(i," has been removed"+(n?" in "+n:"")),ke.ERR_DEPRECATED);return n&&!Zc[i]&&(Zc[i]=!0,console.warn(o(i," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(s,i,a):!0}},Ko.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function Qv(e,t,n){if(typeof e!="object")throw new ke("options must be an object",ke.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 ke("option "+s+" must be "+l,ke.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new ke("Unknown option "+s,ke.ERR_BAD_OPTION)}}const qo={assertOptions:Qv,validators:Ko},xn=qo.validators;let Zn=class{constructor(t){this.defaults=t||{},this.interceptors={request:new jc,response:new jc}}async request(t,n){try{return await this._request(t,n)}catch(r){if(r instanceof Error){let o={};Error.captureStackTrace?Error.captureStackTrace(o):o=new Error;const s=o.stack?o.stack.replace(/^.+\n/,""):"";try{r.stack?s&&!String(r.stack).endsWith(s.replace(/^.+\n.+\n/,""))&&(r.stack+=`
|
|
35
|
+
`+s):r.stack=s}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=Jn(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:s}=n;r!==void 0&&qo.assertOptions(r,{silentJSONParsing:xn.transitional(xn.boolean),forcedJSONParsing:xn.transitional(xn.boolean),clarifyTimeoutError:xn.transitional(xn.boolean)},!1),o!=null&&(K.isFunction(o)?n.paramsSerializer={serialize:o}:qo.assertOptions(o,{encode:xn.function,serialize:xn.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),qo.assertOptions(n,{baseUrl:xn.spelling("baseURL"),withXsrfToken:xn.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=s&&K.merge(s.common,s[n.method]);s&&K.forEach(["delete","get","head","post","put","patch","common"],v=>{delete s[v]}),n.headers=zt.concat(i,s);const a=[];let l=!0;this.interceptors.request.forEach(function(g){typeof g.runWhen=="function"&&g.runWhen(n)===!1||(l=l&&g.synchronous,a.unshift(g.fulfilled,g.rejected))});const c=[];this.interceptors.response.forEach(function(g){c.push(g.fulfilled,g.rejected)});let d,p=0,m;if(!l){const v=[Xc.bind(this),void 0];for(v.unshift(...a),v.push(...c),m=v.length,d=Promise.resolve(n);p<m;)d=d.then(v[p++],v[p++]);return d}m=a.length;let f=n;for(;p<m;){const v=a[p++],g=a[p++];try{f=v(f)}catch(x){g.call(this,x);break}}try{d=Xc.call(this,f)}catch(v){return Promise.reject(v)}for(p=0,m=c.length;p<m;)d=d.then(c[p++],c[p++]);return d}getUri(t){t=Jn(this.defaults,t);const n=Fc(t.baseURL,t.url,t.allowAbsoluteUrls);return Pc(n,t.params,t.paramsSerializer)}};K.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}))}}),K.forEach(["post","put","patch"],function(t){function n(r){return function(s,i,a){return this.request(Jn(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}Zn.prototype[t]=n(),Zn.prototype[t+"Form"]=n(!0)});let ew=class vx{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(s){n=s});const r=this;this.promise.then(o=>{if(!r._listeners)return;let s=r._listeners.length;for(;s-- >0;)r._listeners[s](o);r._listeners=null}),this.promise.then=o=>{let s;const i=new Promise(a=>{r.subscribe(a),s=a}).then(o);return i.cancel=function(){r.unsubscribe(s)},i},t(function(s,i,a){r.reason||(r.reason=new br(s,i,a),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const t=new AbortController,n=r=>{t.abort(r)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new vx(function(o){t=o}),cancel:t}}};function tw(e){return function(n){return e.apply(null,n)}}function nw(e){return K.isObject(e)&&e.isAxiosError===!0}const Oi={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Oi).forEach(([e,t])=>{Oi[t]=e});function Qc(e){const t=new Zn(e),n=mc(Zn.prototype.request,t);return K.extend(n,Zn.prototype,t,{allOwnKeys:!0}),K.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return Qc(Jn(e,o))},n}const pt=Qc(eo);pt.Axios=Zn,pt.CanceledError=br,pt.CancelToken=ew,pt.isCancel=Oc,pt.VERSION=Jc,pt.toFormData=Ho,pt.AxiosError=ke,pt.Cancel=pt.CanceledError,pt.all=function(t){return Promise.all(t)},pt.spread=tw,pt.isAxiosError=nw,pt.mergeConfig=Jn,pt.AxiosHeaders=zt,pt.formToJSON=e=>Rc(K.isHTMLForm(e)?new FormData(e):e),pt.getAdapter=Yc.getAdapter,pt.HttpStatusCode=Oi,pt.default=pt;const{Axios:TN,AxiosError:kN,CanceledError:EN,isCancel:eu,CancelToken:IN,VERSION:NN,all:AN,Cancel:PN,isAxiosError:jN,spread:_N,toFormData:RN,AxiosHeaders:MN,HttpStatusCode:ON,formToJSON:DN,getAdapter:LN,mergeConfig:$N}=pt,tu=typeof window<"u"?window.__API_BASE_URL__:void 0,nu=tu?vn(tu):void 0;function vn(e){const n=(e!=null&&e.trim()?e.trim():"/api/chat").replace(/\/+$/,"");return n?n.endsWith("/chat")?n:`${n}/chat`:"/api/chat"}let Go=null;const Di=new Set;function ru(){return Go}function Yo(e){Go=e,Di.forEach(t=>t(e))}function ou(e){return Di.add(e),()=>Di.delete(e)}const su=3e4,iu=9e4,Gt=pt.create({...nu?{baseURL:nu}:{},timeout:su,withCredentials:!0});Gt.interceptors.request.use(e=>(Go&&(e.headers.Authorization=`Bearer ${Go}`),e)),Gt.interceptors.response.use(e=>{if(typeof window<"u"&&(e!=null&&e.data))try{const t=e.data,n=t.data||{},r=typeof t.token=="string"&&t.token||typeof n.token=="string"&&n.token||null,o=typeof t.expires_at=="number"&&t.expires_at||typeof n.expires_at=="number"&&n.expires_at||typeof t.expiresAt=="number"&&t.expiresAt||typeof n.expiresAt=="number"&&n.expiresAt||null;r&&(localStorage.setItem("authToken",r),Yo(r)),o&&localStorage.setItem("authTokenExpiresAt",o.toString()),(r||o)&&window.dispatchEvent(new CustomEvent("smartorg:chat-token-updated",{detail:{token:r,expiresAt:o}}))}catch(t){console.warn("[chat-api] Error storing token:",t)}return e},e=>Promise.reject(e));async function Yt(e,t){return Gt.defaults.baseURL?(await Gt.get(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}async function Xo(e,t,n){return Gt.defaults.baseURL?(await Gt.post(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function au(e,t,n){return Gt.defaults.baseURL?(await Gt.put(e,t,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function Li(e,t){return Gt.defaults.baseURL?(await Gt.delete(e,t)).data:Promise.reject(new Error("API base URL is not configured"))}function Dt(e){return e&&typeof e=="object"&&"data"in e?e.data:e}class Jo{get baseUrl(){const t=Gt.defaults.baseURL;return t?vn(String(t)):""}updateConfig(t){t.baseUrl&&(Gt.defaults.baseURL=vn(String(t.baseUrl))),t.authToken!==void 0&&Yo(t.authToken)}getAuthToken(){return ru()}setAuthToken(t){Yo(t)}onTokenChange(t){return ou(t)}async listThreads(){const t=await Yt("/threads"),n=Dt(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async listSharedThreads(){const t=await Yt("/threads/shared"),n=Dt(t);return(n==null?void 0:n.items)??(t==null?void 0:t.items)??[]}async createThread(t){const r=await Xo("/threads",t?{title:t}:void 0);return Dt(r)}async updateThread(t,n){const r=await au(`/threads/${t}`,{title:n});return Dt(r)}async deleteThread(t){const n=await Li(`/threads/${t}`);return Dt(n)}async shareThread(t,n){const r=await Xo(`/threads/${t}/share`,{shared_with_user_id:n});return Dt(r)}async threadInfo(t){const n=await Yt(`/threads/${t}/info`);return Dt(n)}async listAgents(){const t=await Yt("/agents"),n=Dt(t);return(n==null?void 0:n.items)??[]}async getAgent(t){const n=await Yt(`/agents/${t}`);return Dt(n)}async getAgentSchema(t){const n=await Yt(`/agents/${t}/schema`);return Dt(n)}async getState(t){const n=await Yt(`/threads/${t.threadId}/state`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs}});return Dt(n)}async getStateHistory(t){const n=await Yt(`/threads/${t.threadId}/state/history`,{params:{thread_id:t.threadId,checkpoint_id:t.checkpointId,checkpoint_ns:t.checkpointNs},timeout:iu,signal:t.signal});return Dt(n)}async cancelRun(t){const n=await Xo("/runs/cancel",{threadId:t});return Dt(n)}async unshareThread(t,n){const r=await Li(`/threads/${t}/share/${n}`);return Dt(r)}}const Nn=new Jo,rw=Jo,ow=Jo;async function $i(e,t){return await Yt(e,{responseType:"blob",onDownloadProgress:r=>{try{if(t&&r.lengthComputable){const o=r.loaded/r.total;t(o)}}catch{}},maxBodyLength:1/0})}async function sw(e,t){const n=await $i(`/files/${e}/view`,t),r=URL.createObjectURL(n);window.open(r,"_blank"),setTimeout(()=>URL.revokeObjectURL(r),6e4)}async function Fi(e,t){return await(await $i(`/files/${e}/view`,t)).text()}async function lu(e,t){const n=await $i(`/files/${e}/download`,t),r=URL.createObjectURL(n);let o=`file_${e}`;try{const i=await Yt(`/files/${e}`);o=(i==null?void 0:i.filename)??o}catch{}const s=document.createElement("a");s.href=r,s.download=o,document.body.appendChild(s),s.click(),s.remove(),setTimeout(()=>URL.revokeObjectURL(r),6e4)}async function iw(e){return await Yt(`/files/${e}`)}async function cu(e,t=50,n=0){const r={limit:t,offset:n};return e&&(r.thread_id=e),await Yt("/files",{params:r})}const uu=w.createContext(null);function du({children:e,apiConfig:t}){const n=Nn;if(t){const o=n.baseUrl,s=n.getAuthToken();t.baseUrl&&t.baseUrl!==o&&n.updateConfig({baseUrl:t.baseUrl}),t.apiKey!==void 0&&t.apiKey!==s&&n.updateConfig({authToken:t.apiKey})}const r={token:n.getAuthToken(),setToken:o=>n.setAuthToken(o),api:n,baseUrl:n.baseUrl};return u.jsx(uu.Provider,{value:r,children:e})}async function fu(e){return await new Promise((t,n)=>{const r=new FileReader;r.onload=()=>{try{const o=r.result,s=new Uint8Array(o);let i="";const a=s.byteLength;for(let 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 pu(e=[]){const t=[],n=[];for(const r of e)try{const o=await fu(r);n.push({filename:r.name,data:o,mime_type:r.type||"application/octet-stream"})}catch{}return{contentParts:t,filesInfo:n}}function no(){const e=w.useContext(uu);if(!e)throw new Error("useApi must be used within ApiProvider");return e}function hu(e){return!!e&&typeof e=="object"&&"data"in e}function Bi(e){return e.filter(t=>{var i;if(t.role!=="assistant")return!0;const n=(t.content??[]).some(a=>{var 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 ro(e,t,n){return t<0||t>=e.length?e:[...e.slice(0,t),n,...e.slice(t+1)]}function aw(e){let t=!1;const n=e.map(r=>{const o=(r.content??[]).filter(s=>s.type!=="interrupt");return o.length!==r.content.length?(t=!0,{...r,content:o}):r});return t?n:e}function mu(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="assistant")return e[t].id;return null}function gu(e){return!e||!e.length?"":e.filter(t=>t.type==="text").map(t=>t.text??"").join("")}function xu(e,t,n,r){const o={...n};if(r!==null&&typeof r=="number"){if(typeof o.lastSeq=="number"&&r<=o.lastSeq)return{newParts:e,newMeta:o,changed:!1};o.lastSeq=r}const s=t.filter(p=>p.type==="text").map(p=>p.text??"").join(""),i=t.filter(p=>p.type!=="text"),a=o.lastText??gu(e);let l="",c=e.slice();if(s){const p=lw(a,s);if(p===""?l="":p===s?l=s:l=p,l){const m=c[c.length-1];if((m==null?void 0:m.type)==="text"){const f=m.text??"",v={...m,text:f+l};c=[...c.slice(0,c.length-1),v]}else c=[...c,{type:"text",text:l}];o.lastText=a+l}else o.lastText=a}i.length&&(c=[...c,...i]);const d=!!(l||i.length);return{newParts:c,newMeta:o,changed:d}}function vu(e){return e.replace(/\s+/g," ").trim()}function lw(e,t){if(!t)return"";if(!e)return t;if(e===t)return"";const n=Math.min(e.length,t.length);for(let i=n;i>0;i--)if(e.slice(-i)===t.slice(0,i))return t.slice(i);const r=vu(e),o=vu(t);if(r===o)return"";const s=Math.min(r.length,o.length);for(let i=s;i>0;i--)if(r.slice(-i)===o.slice(0,i))return t;return t}function cw(e,t,n){for(let r=e.length-1;r>=0;r--)if(e[r].role==="assistant"){const s={...e[r],checkpointId:t,checkpointNs:n??void 0};return ro(e,r,s)}return e}function wu(e){if(!e)return null;const t=e.split("/");return t[t.length-1]||null}function uw(e={}){const t=w.useMemo(()=>vn(e.baseUrl),[e.baseUrl]),n=e.streamPath??"/runs/stream",[r,o]=w.useState(e.token??null),s=w.useRef(e.headers??{}),i=e.credentials??"include",[a,l]=w.useState(!1),[c,d]=w.useState(null),[p,m]=w.useState(""),[f,v]=w.useState(null),[g,x]=w.useState(0),[y,b]=w.useState(!1),[C,k]=w.useState(null),S=w.useRef(null),T=w.useRef(!0),E=w.useRef(0),A=w.useRef(null),P=w.useRef(null),$=w.useRef(null),L=w.useRef(null),H=w.useRef({messageId:null,lastSeq:null,lastText:""}),Y=w.useCallback(W=>{o(W)},[]),_=w.useCallback(()=>{m(""),v(null),d(null),P.current=null,$.current=null,L.current=null,k(null),H.current={messageId:null,lastSeq:null,lastText:""}},[]),V=w.useCallback(()=>{var U;console.debug("[use-chat] stop() invoked - aborting stream");const W=(U=A.current)==null?void 0:U.threadId,D=()=>{var Z;(Z=S.current)==null||Z.abort(),S.current=null,A.current=null,l(!1),b(!1),E.current=0,x(0)};(W?Nn.cancelRun(W).catch(Z=>{console.warn("[use-chat] cancel run failed:",Z)}):Promise.resolve()).finally(D)},[]),G=w.useCallback((W,D,I)=>{S.current&&(S.current.abort(),S.current=null),l(!0),d(null),e.autoAppendAssistant!==!1&&m(""),v(null),P.current=null,$.current=null,L.current=null,k(null),H.current={messageId:null,lastSeq:null,lastText:""};const U=new AbortController;S.current=U;let Z=null,R=null,q=!1;return A.current={threadId:W.threadId??null,headers:{}},(async()=>{var B,Q,M,O,F,J,oe,ae,Se,we,Re,$e,Fe,Ge,Je,vt,ct,tt;const j=Oe=>{var Ve;try{const He=JSON.parse(JSON.stringify(Oe));return(Ve=He==null?void 0:He.payload)!=null&&Ve.files_info&&Array.isArray(He.payload.files_info)&&(He.payload.files_info=He.payload.files_info.map(Te=>({...Te,data:Te!=null&&Te.data?`<base64 ${String(Te.data).length} chars>`:Te==null?void 0:Te.data}))),He}catch{return Oe}};try{let Oe={};try{if(r)Oe={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const Ke=window.__AUTH_TOKEN__,Nt=((B=window.localStorage)==null?void 0:B.getItem("authToken"))||null;let te=null;try{const nt=(Q=window.localStorage)==null?void 0:Q.getItem("chat-settings");nt&&(te=((M=JSON.parse(nt))==null?void 0:M.apiKey)||null)}catch{}const xe=Ke||Nt||te||null;xe&&(Oe={Authorization:`Bearer ${xe}`})}}catch{}console.debug("[use-chat] POST",t+n,j(W));let Ve={};if(typeof window<"u")try{const Ie=(O=window.localStorage)==null?void 0:O.getItem("authSessionId");Ie&&(Ve={"X-Session-Id":Ie})}catch{}const He={...Oe,...Ve,...s.current},Te={"Content-Type":"application/json",Accept:"text/event-stream",...He},Ae=await fetch(t+n,{method:"POST",headers:Te,body:JSON.stringify(W),signal:U.signal,credentials:i});if(A.current&&(A.current.headers=He),!Ae.ok||!Ae.body){const Ie=await Ae.text().catch(()=>"");console.debug("[use-chat] non-OK response",Ae.status,Ie==null?void 0:Ie.slice(0,500));const Ke=`stream ${Ae.status}${Ie?": "+Ie:""}`;throw(F=I==null?void 0:I.onConnectionError)==null||F.call(I,Ke),q=!0,Z="error",R=Ke,new Error(Ke)}b(!0);const ut=Ae.body.getReader(),dt=new TextDecoder;let it="",At=[];E.current=0,x(0);let St=0,ft=null;const Ct=()=>{if(At.length){const Ie=At.join("");At=[],T.current&&m(Ke=>Ke+Ie)}ft=null},Tt=()=>{typeof window<"u"&&ft==null&&(ft=requestAnimationFrame(Ct))};let It=Date.now();const en=setInterval(()=>{var Ie;if(Date.now()-It>18e5){const Ke="Stream idle timeout";d(Ke),Z="error",R=Ke,U.abort(),(Ie=I==null?void 0:I.onError)==null||Ie.call(I,Ke)}},5e3),kt=1024*1024;try{const Ie=Ae.headers.get("X-Thread-Id")||Ae.headers.get("x-thread-id"),Ke=Ae.headers.get("X-Thread-Created")||Ae.headers.get("x-thread-created"),Nt=Ie??null,te=String(Ke??"").toLowerCase()==="true";for(A.current&&!A.current.threadId&&(A.current={...A.current,threadId:Nt}),(J=I==null?void 0:I.onOpen)==null||J.call(I,{threadId:Nt,created:te});;){const{value:xe,done:nt}=await ut.read();if(nt)break;it+=dt.decode(xe,{stream:!0}),it.length>kt&&(it="",console.warn("Stream buffer reset: exceeded 1MB"));let me;for(;(me=it.indexOf(`
|
|
36
36
|
|
|
37
|
-
`))>=0;){const
|
|
38
|
-
`);if(!nt)continue;let Nt;try{Nt=JSON.parse(nt)}catch{console.debug("[use-chat] malformed SSE:",nt.slice(0,200));continue}const $t=hu(Nt)?Nt.data:Nt;if(!$t){console.warn("[use-chat] dropped envelope event without payload",Nt);continue}const Ee=$t;At=Date.now();const ut=Ee.seq;if(ut!==void 0){if(ut<=vt){console.debug("[use-chat] drop duplicate/out-of-order event",{seq:ut,lastProcessedSeq:vt,type:Ee.type});continue}vt>0&&ut>vt+1&&((oe=I==null?void 0:I.onGap)==null||oe.call(I,{from:vt,to:ut})),vt=ut,E.current=ut,x(ut)}if(Ee.type==="message.start"&&Ee.role==="assistant"){const Ge=wu(Ee.model);V.current={messageId:Ee.id,lastSeq:ut??null,lastText:""},k({id:Ee.id,role:"assistant",name:Ge??void 0,model:Ee.model,createdAt:new Date().toISOString(),content:[]})}if(Ee.type==="checkpoint")j.current=Ee.checkpointId??null,L.current=Ee.checkpointNs??null,v(Ee.checkpointId??null);else if(Ee.type==="state_history"){H.current=Ee;try{const at=Yn(Ee).latest;at&&(j.current=at.checkpointId??null,L.current=at.checkpointNs??null,v(at.checkpointId??null))}catch(Ge){console.warn("[use-chat] Failed to hydrate state_history payload",Ge)}}try{P==null||P(Ee)}catch(Ge){console.error("[use-chat] Error in onEvent callback:",Ge,"for event:",Ee.type)}if(Ee.type==="message.delta"){k(at=>{const sn=V.current;if(!at||sn.messageId!==at.id)return at;const{newParts:N,newMeta:X,changed:re}=xu(at.content??[],Ee.delta,{lastSeq:sn.lastSeq,lastText:sn.lastText},ut??null);return re?(V.current={...sn,lastSeq:X.lastSeq??sn.lastSeq,lastText:X.lastText??sn.lastText},{...at,content:N}):at});const Ge=Ee.delta.filter(at=>at.type==="text").map(at=>at.text).join("");Ge&&e.autoAppendAssistant!==!1&&(Et.push(Ge),wt())}else if(Ee.type==="heartbeat"){console.debug("[use-chat] heartbeat received");try{(ie=I==null?void 0:I.onHeartbeat)==null||ie.call(I,Ee)}catch(Ge){console.warn("[use-chat] heartbeat callback failed",Ge)}}else if(dt!==null&&cancelAnimationFrame(dt),St(),Ee.type==="checkpoint")v(Ee.checkpointId);else if(Ee.type==="error"){const Ge=Ee;if(d(Ge.message),Z="error",M=Ge.message,Ge.error_type==="auth_error"||Ge.code==="TOKEN_EXPIRED"||((Ce=Ge.message)==null?void 0:Ce.includes("token"))||((ve=Ge.message)==null?void 0:ve.includes("401"))||((Re=Ge.message)==null?void 0:Re.includes("unauthorized"))||((We=Ge.message)==null?void 0:We.includes("Unauthorized"))){console.error("[use-chat] Auth error detected:",Ge.message);try{(De=I==null?void 0:I.onAuthError)==null||De.call(I,Ge.message)}catch(sn){console.warn("[use-chat] onAuthError handler failed",sn)}U.abort()}}}}St(),Z===null&&!U.signal.aborted&&(Z="complete")}catch(Pe){if(Pe.name==="AbortError")Z=Z??"aborted";else{const He=Pe.message||String(Pe);Z="error",M=He,d(He),(qe=I==null?void 0:I.onError)==null||qe.call(I,He)}}finally{try{await ct.cancel()}catch{}finally{(ze=ct.releaseLock)==null||ze.call(ct)}dt!==null&&typeof window<"u"&&window.cancelAnimationFrame(dt),clearInterval(on)}}catch(Le){if(Le.name==="AbortError")Z=Z??"aborted";else{const Ve=Le.message||String(Le);Z="error",M=Ve,d(Ve),(xt=I==null?void 0:I.onError)==null||xt.call(I,Ve),Y||((lt=I==null?void 0:I.onConnectionError)==null||lt.call(I,Ve),Y=!0)}}finally{const Le=E.current,Ve=j.current,$e=L.current,ke=H.current,Ae=Z??(U.signal.aborted?"aborted":M?"error":"complete");try{(et=I==null?void 0:I.onClosed)==null||et.call(I,{reason:Ae,lastSeq:Le,lastCheckpointId:Ve,lastCheckpointNs:$e,lastStateHistory:ke,error:M})}catch(ct){console.warn("[use-chat] onClosed callback failed",ct)}c(!1),b(!1),S.current=null,E.current=0,x(0),A.current=null}})(),{close:()=>U.abort()}},[t,n,r,e.autoAppendAssistant]);return w.useEffect(()=>()=>{var $;T.current=!1,($=S.current)==null||$.abort()},[]),{isStreaming:a,error:l,assistantText:p,assistantMessage:C,lastCheckpointId:f,lastSeq:g,connected:y,stream:K,stop:G,clear:R,setToken:J}}const dw=["detail","message","error","description","title"];function Zo(e){if(!e)return null;if(typeof e=="string"){const t=e.trim();return t.length?t:null}if(Array.isArray(e)){for(const t of e){const n=Zo(t);if(n)return n}return null}if(typeof e=="object"){const t=e;for(const n of dw){const r=Zo(t[n]);if(r)return r}if("errors"in t){const n=Zo(t.errors);if(n)return n}}return null}function fw(e){if(!e)return"Request failed";const t=e.response,n=Zo(t==null?void 0:t.data);if(n)return n;if(t!=null&&t.statusText)return t.statusText;if(e instanceof Error&&e.message)return e.message;if(typeof e=="string"){const r=e.trim();if(r.length)return r}return t!=null&&t.status?`Request failed with status code ${t.status}`:"Request failed"}function bu({api:e,initialThreadId:t=null,onError:n,onThreadChange:r,onCurrentThreadDeleted:o}){const[s,i]=w.useState([]),[a,c]=w.useState(t),[l,d]=w.useState(!1),[p,m]=w.useState(null),[f,v]=w.useState([]),[g,x]=w.useState(!1),[,y]=w.useState(null),[b,C]=w.useState(null),[k,S]=w.useState(!1),T=w.useRef(a),E=w.useRef(new Map);w.useEffect(()=>{T.current=a},[a]);const A=w.useCallback(async()=>{d(!0),m(null);try{const P=await e.listThreads();i(P??[])}catch(P){const I=String(P);m(I),n==null||n(I)}finally{d(!1)}},[e,n]),j=w.useCallback(async()=>{x(!0),y(null);try{const P=await e.listSharedThreads();v(P??[])}catch(P){const I=String(P);y(I),n==null||n(I)}finally{x(!1)}},[e,n]);w.useEffect(()=>{A()},[A]),w.useEffect(()=>{j()},[j]),w.useEffect(()=>{r==null||r(a)},[a,r]);const L=w.useCallback(async P=>{try{const I=await e.createThread(P);return c(I.threadId),await A(),I.threadId}catch(I){const U=String(I);return n==null||n(U),null}},[e,n,A]),H=w.useCallback(async P=>{const I=s;i(Z=>Z.filter(M=>M.threadId!==P));const U=new AbortController;E.current.set(P,U);try{await e.deleteThread(P),T.current===P&&(c(null),o==null||o())}catch(Z){i(I);const M=String(Z);n==null||n(M)}finally{E.current.delete(P)}},[e,o,n,s]),V=w.useCallback(async(P,I)=>{try{await e.updateThread(P,I),await A()}catch(U){n==null||n(String(U))}},[e,n,A]),J=w.useCallback(async(P,I)=>{S(!0),C("Sharing thread…");try{await e.shareThread(P,I),await j(),C("Shared successfully")}catch(U){const Z=fw(U);throw n==null||n(Z),C(`Failed to share: ${Z}`),new Error(Z)}finally{S(!1)}},[e,n,j]),R=w.useCallback(async(P,I)=>{try{await e.unshareThread(P,I),await j()}catch(U){const Z=String(U);throw n==null||n(Z),U}},[e,n,j]),G=w.useMemo(()=>({createThread:L,deleteThread:H,renameThread:V,refreshThreads:A,refreshSharedThreads:j,shareThread:J,unshareThread:R}),[L,H,V,A,j,J,R]),K=w.useCallback(P=>{if(!(P!=null&&P.threadId))return;const I={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(U=>{let Z=!1;const M=U.map(Y=>Y.threadId===I.threadId?(Z=!0,console.debug("[useThreadsState] thread_info: updating existing thread",I.threadId),{...Y,title:I.title??Y.title,updatedAt:I.updatedAt??Y.updatedAt,messageCount:I.messageCount??Y.messageCount}):Y);return Z?M:(console.debug("[useThreadsState] thread_info: adding thread to list",I.threadId),[I,...U])})},[]),$=w.useCallback(()=>C(null),[]);return{threads:s,currentThreadId:a,currentThreadIdRef:T,setCurrentThreadId:c,isLoadingThreads:l,threadsError:p,sharedThreads:f,isLoadingSharedThreads:g,actions:G,addThreadFromEvent:K,shareInFlight:k,shareStatus:b,clearShareStatus:$}}const yu=w.createContext(null);function Su({children:e,initialThreadId:t=null,onError:n,onThreadChange:r}){const{api:o}=no(),{threads:s,currentThreadId:i,setCurrentThreadId:a,currentThreadIdRef:c,isLoadingThreads:l,threadsError:d,sharedThreads:p,isLoadingSharedThreads:m,actions:f,addThreadFromEvent:v,shareInFlight:g,shareStatus:x,clearShareStatus:y}=bu({api:o,initialThreadId:t,onError:n,onThreadChange:r}),b=w.useMemo(()=>({threads:s,currentThreadId:i,setCurrentThreadId:a,currentThreadIdRef:c,isLoading:l,error:d,sharedThreads:p,isLoadingSharedThreads:m,actions:f,shareInFlight:g,shareStatus:x,clearShareStatus:y,addThreadFromEvent:v}),[s,i,a,c,l,d,p,m,f,g,x,y,v]);return u.jsx(yu.Provider,{value:b,children:e})}function yr(){const e=w.useContext(yu);if(!e)throw new Error("useThreads must be used within a ThreadsProvider");return e}function Qn(e){const t=e==null?void 0:e.trim();if(!t||!(t.startsWith("{")||t.startsWith("[")))return null;try{return JSON.parse(t)}catch{const n=pw(t);if(n)try{return JSON.parse(n)}catch{return null}return null}}function pw(e){let t=!1,n="";for(const o of e){if(o==="\\"){n+=o,t=!t;continue}if(o==="'"&&!t){n+='"';continue}n+=o,t=!1}return n.replace(/\bTrue\b/g,"true").replace(/\bFalse\b/g,"false").replace(/\bNone\b/g,"null")}function zi(e){return!!(e&&typeof e=="object"&&(e.type==="file"||e.mimeType||e.filename||e.sourceType==="base64"))}function Sr(e){if(typeof e=="string")return e;if(e&&typeof e=="object"){if(Array.isArray(e)){const n=e.map(Sr).filter(r=>r!==void 0);if(!n.length){console.debug("[message-utils] sanitizeForDisplay - array emptied -> returning undefined",{originalLength:e.length});return}return n}if(zi(e)){try{console.debug("[message-utils] sanitizeForDisplay - dropping file-like object",{sampleFilename:e&&(e.filename||e.name)?e.filename||e.name:void 0,keys:Object.keys(e||{})})}catch(n){console.debug("[message-utils] sanitizeForDisplay - dropped file-like (unable to inspect)",{err:String(n)})}return}const t={};for(const n of Object.keys(e)){const r=e[n];if(n==="data"&&typeof r=="string"&&r.length>100)t[n]=`[base64 ${r.length} chars omitted]`;else{const o=Sr(r);o!==void 0&&(t[n]=o)}}if(Object.keys(t).length)return t;try{console.debug("[message-utils] sanitizeForDisplay - object emptied -> returning undefined",{originalKeys:Object.keys(e||{})})}catch(n){console.debug("[message-utils] sanitizeForDisplay - object emptied -> returning undefined (inspect failed)",{err:String(n)})}return}return e}function er(e){if(typeof e=="string")return e;if(zi(e))return"";try{const t=Sr(e);return t===void 0?"":typeof t=="string"?t:JSON.stringify(t,null,2)}catch{return""}}function Cu(e){return typeof e!="string"?!1:/^[\s\n]*[-*]\s|^[\s\n]*#+\s|```|^\s*\[.*\]\(|^>\s/.test(e)}function Tu(e){const t=er(e);return typeof e=="string"&&Cu(e)?{content:e,isMarkdown:!0}:{content:t,isMarkdown:!1}}function tr(e){if(e==null)return e;if(typeof e=="string"){const t=e.trim();if(t.startsWith("{")||t.startsWith("[")){const n=Qn(t);if(n!==null)return tr(n)}return e}return typeof e=="object"&&!Array.isArray(e)&&e.content!==void 0?tr(e.content):e}function ku(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function Qo(e){const t=e.content.find(s=>s.type==="tool_call"),n=e.additionalKwargs??{},r=typeof(t==null?void 0:t.id)=="string"&&t.id||typeof n.toolCallId=="string"&&n.toolCallId||(e.id.startsWith("tool-")?e.id.slice(5):void 0);return{name:(typeof(t==null?void 0:t.name)=="string"&&t.name||typeof n.toolName=="string"&&n.toolName||e.name&&String(e.name))??void 0,toolCallId:r??void 0}}function Hi(e){if(e==null)return null;const t=String(e).trim();return t.length>0?t:null}function Eu(e){const t=r=>{try{const o=Sr(r);return typeof o=="string"?o:JSON.stringify(o??"")}catch{return""}},n=e.filter(r=>r.type==="text");return n.length?t(n.map(r=>r.text).join(`
|
|
39
|
-
`)):t(e)}function Iu(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function Ui(e){if(e.role==="default_message")return`default:${e.content.length}`;const t=e.updatedAt??e.createdAt??"",n=Array.isArray(e.content)?e.content.map(i=>{switch(i.type){case"text":return`t:${i.text.length}`;case"image_url":return"img";case"file":return"file";case"tool_call":return"call";case"interrupt":return"interrupt";default:return"unknown"}}).join("|"):"",r="checkpointId"in e&&e.checkpointId?`cp:${e.checkpointId}`:"",o="checkpointNs"in e&&e.checkpointNs?`ns:${e.checkpointNs}`:"",s=[r,o].filter(Boolean).join("|");return`${e.id}:${t}:${n}${s?`:${s}`:""}`}function Nu(e){if(!e)return"image/png";const t=e.trim();return t?t.includes("/")?t:`image/${t}`:"image/png"}function Au(e){const t=[],n=r=>{r&&r.trim()&&t.push(r.trim())};return e&&(n(e.plotId),n(e.artifactId)),t}function Pu({base64:e,url:t,formatHint:n,extras:r}){const o=typeof e=="string"&&e.length>0,s=Nu(n),i=o?`data:${s};base64,${e}`:t,a=Au(r),c=a.length?a.join(" / "):void 0,l=c?`${c} artifact`:"artifact image";return{src:i,alt:l,label:c}}function ju(e){var o,s;const t=((o=e.content_base64)==null?void 0:o.trim())||void 0,n=((s=e.url)==null?void 0:s.trim())||void 0,r=e.format||e.mimeType||e.mime_type;return Pu({base64:t,url:n,formatHint:r,extras:{plotId:e.plotId,artifactId:e.artifactId}})}function Wi(e){var n;const t=(n=e.additionalKwargs)==null?void 0:n.toolProgress;return Array.isArray(t)?t:[]}function Cr(e){if(e==null)return e;if(typeof e=="string"){const t=e.trim(),n=Qn(t);return n!==null?Cr(n):t}if(Array.isArray(e))return e.map(t=>Cr(t));if(typeof e=="object"){const t=e.value;if(t!==void 0)return Cr(t)}return e}function _u(e){const t=Cr(e.value);return t===e.value?e:{...e,value:t}}const hw={messages:[],assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,messagesStreamMeta:{},pendingInterrupt:null};function mw(e,t){var n;switch(t.type){case"reset":return{messages:Bi(((n=t.payload)==null?void 0:n.messages)??[]),assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,pendingInterrupt:null,messagesStreamMeta:{}};case"user_message":{const{message:r,editingMessageId:o}=t.payload;if(o){const s=e.messages.findIndex(i=>i.id===o);if(s>=0){const i=e.messages.slice(0,s);return{...e,messages:[...i,r]}}}return{...e,messages:[...e.messages,r]}}case"seed":{const r=Bi(t.payload.messages),o={...e,messages:r,assemblingId:null,pendingInterrupt:t.payload.pendingInterrupt??null};return Object.prototype.hasOwnProperty.call(t.payload,"checkpointId")&&(o.lastCheckpointId=t.payload.checkpointId??null),Object.prototype.hasOwnProperty.call(t.payload,"checkpointNs")&&(o.lastCheckpointNs=t.payload.checkpointNs??null),o}case"prepend":{const r=Bi(t.payload.messages);if(!r.length)return e;const o=new Set(e.messages.map(a=>a.id)),s=r.filter(a=>!o.has(a.id));if(!s.length)return e;const i=[...s,...e.messages];return{...e,messages:i}}case"event":return Ru(e,t.payload.ev);case"batch":{const{events:r}=t.payload;return r.length?r.reduce((o,s)=>Ru(o,s),e):e}default:return e}}function gw(e=[]){const[t,n]=w.useReducer(mw,{...hw,messages:e}),r=w.useRef([]),o=w.useRef(null),s=w.useRef(null),i=w.useCallback(()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),o.current=null,s.current=null;const d=r.current;d.length&&(r.current=[],n({type:"batch",payload:{events:d}}))},[]),a=w.useCallback(()=>{typeof window<"u"&&typeof window.requestAnimationFrame=="function"?o.current===null&&(o.current=window.requestAnimationFrame(()=>i())):s.current===null&&(s.current=setTimeout(i,8))},[i]),c=w.useCallback(d=>{r.current.push(d),a()},[a]);w.useEffect(()=>()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),r.current=[]},[]);const l=w.useMemo(()=>({reset:d=>n({type:"reset",payload:{messages:d}}),seed:(d,p)=>n({type:"seed",payload:{messages:d,...p??{}}}),prepend:d=>n({type:"prepend",payload:{messages:d}}),pushUser:(d,p)=>n({type:"user_message",payload:{message:d,editingMessageId:p}}),onEvent:c}),[c]);return{state:t,dispatch:n,...l}}function Ru(e,t){var n,r,o;if(t.type==="message.start"&&t.role==="assistant"){const s=t.id,i=wu(t.model);if(e.messages.some(l=>l.id===s)){const l=e.messagesStreamMeta??{},d={...l,[s]:l[s]??{lastSeq:t.seq??null,lastText:""}};return{...e,assemblingId:s,messagesStreamMeta:d}}const c={id:s,role:"assistant",name:i||void 0,model:t.model,createdAt:new Date().toISOString(),content:[]};return{...e,assemblingId:s,messages:[...e.messages,c]}}if(t.type==="tool.start")return vw(e,t);if(t.type==="tool.progress")return ww(e,t);if(t.type==="tool.end")return bw(e,t);if(t.type==="message.delta"){const s=e.assemblingId??mu(e.messages);if(!s)return e;const i=e.messages,a=i.findIndex(S=>S.id===s&&S.role==="assistant");if(a===-1)return e;const c=i[a],l=e.messagesStreamMeta,d=l??{},p=d[s],m=p??{lastSeq:null,lastText:gu(c.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}=xu(c.content,t.delta,m,f);if(!x)return e;const y={...c,content:v},b=ro(i,a,y),C=!p||p.lastSeq!==g.lastSeq||p.lastText!==g.lastText,k=C?{...d,[s]:g}:l;return C?{...e,messages:b,messagesStreamMeta:k}:{...e,messages:b}}if(t.type==="message.end"){const s=e.assemblingId??mu(e.messages);if(!s)return{...e,assemblingId:null};const i=e.messages,a=i.findIndex(c=>c.id===s&&c.role==="assistant");if(a>=0){const c=i[a];if(!((n=c.content)==null?void 0:n.some(d=>{var p;return(d==null?void 0:d.type)==="text"&&((p=d.text)==null?void 0:p.trim())}))){console.debug("[MessageReducer] pruning assistant message with no visible text",{id:c.id,contentTypes:(r=c.content)==null?void 0:r.map(p=>p==null?void 0:p.type),contentPreview:(o=c.content)==null?void 0:o.map(p=>(p==null?void 0:p.type)==="text"?String(p.text).slice(0,100):p==null?void 0:p.type)});const d=[...i.slice(0,a),...i.slice(a+1)];return{...e,assemblingId:null,messages:d}}}return e}if(t.type==="checkpoint"){const s=t.checkpointNs??e.lastCheckpointNs??null,i=cw(e.messages,t.checkpointId,s);return{...e,lastCheckpointId:t.checkpointId,lastCheckpointNs:s,messages:i}}if(t.type==="error"){const s={id:`err-${Date.now()}`,role:"system",content:[{type:"text",text:`Error: ${t.message}`}],createdAt:new Date().toISOString()};return{...e,messages:[...e.messages,s]}}if(t.type==="state_history"){const s=Yn(t),i=s.interrupt,a=s.latest,c=i===null?aw(e.messages):e.messages;return{...e,messages:c,pendingInterrupt:i,lastCheckpointId:(a==null?void 0:a.checkpointId)??e.lastCheckpointId,lastCheckpointNs:(a==null?void 0:a.checkpointNs)??e.lastCheckpointNs}}return t.type==="thread_info",e}function Vi(e){return e.call_id??e.id??null}function Mu(e){return e.id??e.call_id??`tool-${Date.now()}-${Math.random().toString(16).slice(2)}`}function Ou(e,t,n,r){const o=t??`call-${Date.now()}-${Math.random().toString(16).slice(2)}`;return{id:e,role:"tool",name:n??void 0,content:[{type:"tool_call",id:o,name:n??"tool",args:r??{}}],createdAt:new Date().toISOString(),additionalKwargs:{toolCallId:o,toolName:n??void 0,toolStreaming:!0,toolProgress:[]}}}function Ki(e,t){if(!t)return-1;for(let n=0;n<e.length;n+=1){const r=e[n];if(r.role!=="tool")continue;const o=r.additionalKwargs??{};if(typeof o.toolCallId=="string"&&o.toolCallId===t||Qo(r).toolCallId===t)return n}return-1}function xw(e){if(e==null)return[];const t=tr(e);if(typeof t=="string"&&t.trim())return[{type:"text",text:t}];const n=er(t??e);return n?[{type:"text",text:n}]:[]}function Du(e,t){const n=e.additionalKwargs??{},r=Array.isArray(n.toolProgress)?[...n.toolProgress]:[],o={...n,toolProgress:[...r,t]};return{...e,additionalKwargs:o}}function vw(e,t){const n=Vi(t),r=Ki(e.messages,n),o=t.name??t.tool??void 0,s=Mu(t);if(r>=0){const a=e.messages[r],l={...a.additionalKwargs??{},toolStreaming:!0,toolProgress:[]},d={...a,name:o??a.name,additionalKwargs:l};return{...e,messages:ro(e.messages,r,d)}}const i=Ou(s,n,o,t.args);return{...e,messages:[...e.messages,i]}}function ww(e,t){const n=Vi(t);if(!n)return e;const r=Ki(e.messages,n);if(r===-1)return e;const o={type:t.type,content:typeof t.content=="string"?t.content:void 0,seq:t.seq??null,timestamp:new Date().toISOString()},s=t.metadata;s&&(o.metadata=s);const i=t.idx;typeof i=="number"&&(o.idx=i);const a=Du(e.messages[r],o);return{...e,messages:ro(e.messages,r,a)}}function bw(e,t){const n=Vi(t),r=Mu(t);let o=e.messages,s=Ki(o,n);if(s===-1){const v=t.name??t.tool??void 0;o=[...o,Ou(r,n,v,{})],s=o.length-1}const i=o[s],a=t.output??t.error??null,c=xw(a),l=[...i.content,...c],d={type:t.type,content:typeof t.output=="string"?t.output:void 0,seq:t.seq??null,timestamp:new Date().toISOString()};t.artifact&&(d.artifact=t.artifact);const p=Du(i,d),m=t.artifact??i.artifact,f={...p,name:t.name??t.tool??i.name,content:l,artifact:m,additionalKwargs:{...p.additionalKwargs??{},toolStreaming:!1}};return{...e,messages:ro(o,s,f)}}function Lu({api:e,seed:t,onError:n,currentThreadId:r,initialThreadId:o=null,initialCheckpointId:s=null,initialCheckpointNs:i=null,autoLoadInitial:a=!0,isStreaming:c,getMessages:l}){const[d,p]=w.useState(null),f=w.useMemo(()=>Yn(d),[d]).checkpoints,v=uc(f),g=v.timeline,[x,y]=w.useState(!1),[b,C]=w.useState(!1),[k,S]=w.useState(null),T=w.useRef(r),E=w.useRef(null),A=w.useRef(null),j=w.useRef(null),L=w.useRef(null),H=w.useRef(null),V=w.useRef(new Map),J=w.useRef(null);w.useEffect(()=>{T.current=r},[r]);const R=w.useCallback(async _=>{var W,O;if(!_.threadId)return;const z=_.threadId;(W=_.onStart)==null||W.call(_),_.setLoading(!0);try{await _.action(z)}catch(D){if(!eu(D)&&T.current===z){const Q=String(D);(O=_.handleError)==null||O.call(_,Q),n==null||n(Q)}throw D}finally{_.setLoading(!1)}},[n]),G=w.useCallback(async(_,z)=>{var Q;if(!_)return;const W=`${_}:${z??"latest"}`,O=V.current.get(W);if(O)return O;(Q=J.current)==null||Q.abort();const D=new AbortController;J.current=D;const B=R({threadId:_,setLoading:y,onStart:()=>S(null),handleError:oe=>S(oe),action:async oe=>{const ie=await e.getStateHistory({threadId:oe,checkpointId:z??void 0,signal:D.signal});if(T.current!==oe){console.log(`[useThreadHistoryState] Thread changed during load (was ${oe}, now ${T.current}), discarding stale data`);return}const{checkpoints:Ce}=Yn(ie),ve=Ce.find(Re=>Re.messages&&Re.messages.length>0)??(z?Ce.find(Re=>Re.checkpointId===z):null)??Ce[0];t((ve==null?void 0:ve.messages)??[],{checkpointId:(ve==null?void 0:ve.checkpointId)??null,checkpointNs:(ve==null?void 0:ve.checkpointNs)??null,pendingInterrupt:(ve==null?void 0:ve.interrupt)??null}),p(ie)}});V.current.set(W,B);try{await B}finally{V.current.delete(W),J.current===D&&(J.current=null)}return T.current===_&&(H.current=W),B},[e,t,R]),K=w.useCallback(async(_,z)=>{L.current=_;try{await G(_,z)}catch(W){if(!eu(W))throw W}finally{L.current===_&&(L.current=null)}},[G]),$=w.useCallback(_=>{A.current=_},[]),P=w.useCallback(_=>{j.current=_},[]),I=w.useCallback(_=>{const z=_.threadId??T.current;if(!z||T.current&&T.current!==z)return;const{checkpoints:W}=Yn(_);if(!W.length)return;const O=W.find(B=>B.messages&&B.messages.length>0)??W.find(B=>!!B.checkpointId)??W[0],D=j.current===z;!c&&!D&&t((O==null?void 0:O.messages)??[],{checkpointId:(O==null?void 0:O.checkpointId)??null,checkpointNs:(O==null?void 0:O.checkpointNs)??null,pendingInterrupt:(O==null?void 0:O.interrupt)??null}),p(_),H.current=`${z}:latest`,A.current=null,j.current===z&&(j.current=null)},[t,c]),U=w.useCallback(async(_,z)=>{const W=T.current;await R({threadId:W,setLoading:C,action:async O=>{const D=await e.getStateHistory({threadId:O,checkpointId:_,checkpointNs:z??void 0});if(T.current!==O)return;const{checkpoints:B}=Yn(D),Q=B.find(oe=>oe.checkpointId===_&&(z?oe.checkpointNs===z:!0));if(!Q){console.warn("[useThreadHistoryState] Requested checkpoint not found:",{checkpointId:_,checkpointNs:z});return}p(D),t(Q.messages??[],{checkpointId:Q.checkpointId??null,checkpointNs:Q.checkpointNs??null})}}).catch(()=>{})},[e,t,R]),Z=w.useCallback((_,z)=>{t(l(),{checkpointId:_??null,checkpointNs:z??null})},[l,t]),M=w.useCallback(async()=>{T.current&&await K(T.current)},[K]);w.useEffect(()=>{if(!a||!r||x||c)return;if(A.current===r){A.current=null,E.current=r;return}if(j.current===r){E.current=r;return}if(L.current===r){L.current=null,E.current=r;return}if(E.current===r)return;E.current=r;let _;const z=`${r}:latest`;H.current!==z&&K(r,_)},[a,r,s,i,o,x,c,K]);const Y=w.useCallback(()=>{p(null),y(!1),C(!1),S(null),A.current=null,j.current=null,E.current=null,H.current=null,L.current=null},[]);return{threadCheckpoints:f,threadTimeline:g,checkpointIndex:v,isLoadingThread:x,isLoadingCheckpoint:b,threadStateError:k,loadThread:K,navigateToCheckpoint:U,setCurrentCheckpointId:Z,returnToLatest:M,handleStateHistoryEvent:I,markSkipNextLoad:$,markStreamPendingThread:P,resetHistoryState:Y}}const $u=w.createContext(null),Fu=w.createContext(null);function oo(){const e=w.useContext($u);if(!e)throw new Error("useThreadState must be used within a ThreadStateProvider");return e}function Bu(){const e=w.useContext(Fu);if(!e)throw new Error("useThreadStateUpdater must be used within a ThreadStateProvider");return e}function zu({children:e,initialThreadId:t=null,initialCheckpointId:n=null,initialCheckpointNs:r=null,autoLoadInitial:o=!0,isStreaming:s,onError:i}){const{api:a}=no(),{currentThreadId:c}=yr(),{state:l,seed:d,pushUser:p,onEvent:m}=gw(),{threadCheckpoints:f,threadTimeline:v,checkpointIndex:g,isLoadingThread:x,isLoadingCheckpoint:y,threadStateError:b,loadThread:C,navigateToCheckpoint:k,setCurrentCheckpointId:S,returnToLatest:T,handleStateHistoryEvent:E,markSkipNextLoad:A,markStreamPendingThread:j,resetHistoryState:L}=Lu({api:a,seed:d,onError:i,currentThreadId:c,initialThreadId:t,initialCheckpointId:n,initialCheckpointNs:r,autoLoadInitial:o,isStreaming:s,getMessages:w.useCallback(()=>l.messages,[l.messages])}),[H,V]=w.useState(()=>async()=>{throw new Error("clearThread is not ready")}),[J,R]=w.useState(()=>async()=>{throw new Error("respondToInterrupt is not ready")});w.useEffect(()=>{c||(d([],{}),L())},[c,d,L]);const G=w.useCallback(U=>V(()=>U),[]),K=w.useCallback(U=>R(()=>U),[]),$=w.useMemo(()=>({assemblingMessageId:l.assemblingId??null}),[l.assemblingId]),P=w.useMemo(()=>({threadId:c,messages:l.messages,interrupt:l.pendingInterrupt,checkpoint:{id:l.lastCheckpointId??null,namespace:l.lastCheckpointNs??null},checkpoints:f,checkpointIndex:g,timelineCheckpoints:v,metadata:$,isLoading:x,isLoadingCheckpoint:y,error:b,clearState:H,navigateToCheckpoint:k,setCurrentCheckpointId:S,returnToLatest:T,loadThread:C,clearThread:H,respondToInterrupt:J,messagePreviews:g.messagePreviews,handleStateHistoryEvent:E,markSkipNextLoad:A,markStreamPendingThread:j,resetHistoryState:L,pushUser:p,onEvent:m}),[c,l,f,v,g,$,x,y,b,H,k,S,T,C,J,g.messagePreviews,E,A,j,L,p,m]),I=w.useMemo(()=>({registerClearThread:G,registerRespondToInterrupt:K}),[G,K]);return u.jsx(Fu.Provider,{value:I,children:u.jsx($u.Provider,{value:P,children:e})})}function Hu(e,t){if(!e)return null;const n=_n(e);if(!n)return null;const r=_n(n.configurable)??n;return Rn(r,t)??null}function yw(e){const t=Hu(e,["checkpoint_id","checkpointId"]);if(!t)return null;const n=Hu(e,["checkpoint_ns","checkpointNs"]);return{checkpointId:t,checkpointNs:n}}function Sw(e,t){const n=typeof e.step=="number"?e.step:Number.POSITIVE_INFINITY,r=typeof t.step=="number"?t.step:Number.POSITIVE_INFINITY;if(n!==r)return n-r;const o=e.createdAt?Date.parse(e.createdAt):0,s=t.createdAt?Date.parse(t.createdAt):0;return o-s}function Cw(e,t){const n=[...e].sort(Sw);for(const r of n){if(r.messageId!==t)continue;const o=yw(r.parentConfig);if(!o)throw new Error(`Parent checkpoint info missing for message ${t}`);return o}throw new Error(`Message ${t} not found in timeline`)}const Uu=w.createContext(null),Wu=w.createContext(!1);function Tw({children:e,initialThreadId:t=null,initialCheckpointId:n=null,initialCheckpointNs:r=null,autoLoadInitial:o=!0,onError:s,onAuthError:i,onThreadChange:a,onConnectionError:c,onToolEnd:l}){const{api:d,baseUrl:p}=no(),m=w.useMemo(()=>vn(p),[p]),{stream:f,stop:v,isStreaming:g,error:x,setToken:y}=uw({baseUrl:m}),[b,C]=w.useState(!1);return w.useEffect(()=>{C(g)},[g]),u.jsx(Su,{initialThreadId:t,onError:s,onThreadChange:a,children:u.jsx(zu,{initialThreadId:t,initialCheckpointId:n,initialCheckpointNs:r,autoLoadInitial:o,onError:s,isStreaming:b,children:u.jsx(Wu.Provider,{value:!0,children:u.jsx(kw,{api:d,streamApi:{stream:f,stop:v,isStreaming:g,error:x,setToken:y},onError:s,onAuthError:i,onConnectionError:c,onToolEnd:l,children:e})})})})}function kw({children:e,api:t,streamApi:n,onError:r,onAuthError:o,onConnectionError:s,onToolEnd:i}){const{stream:a,stop:c,isStreaming:l,error:d,setToken:p}=n,{setCurrentThreadId:m,currentThreadIdRef:f,addThreadFromEvent:v}=yr(),{checkpoint:g,timelineCheckpoints:x,handleStateHistoryEvent:y,markSkipNextLoad:b,markStreamPendingThread:C,resetHistoryState:k,pushUser:S,onEvent:T}=oo(),{registerClearThread:E,registerRespondToInterrupt:A}=Bu(),j=w.useCallback($=>{v($),f.current!==$.threadId&&(($.created??!f.current)&&b($.threadId),C($.threadId),m($.threadId))},[v,b,C,m,f]),L=w.useCallback($=>{$.type==="thread_info"?j($):$.type==="state_history"?y($):$.type==="tool.end"?i==null||i($):T($)},[j,y,T,i]),H=w.useCallback($=>{a($,L,{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,L,r,o,s]),V=w.useRef(g);w.useEffect(()=>{V.current=g},[g]);const J=w.useCallback(async($,P,I)=>{const U=f.current;if(!U)throw new Error("No active thread to handle interrupt");const Z=$?P??!0:!1,M=V.current,Y={threadId:U,checkpointId:M.id??void 0,checkpointNs:M.namespace??void 0,command:{kind:"resume",value:Z},payload:I==null?void 0:I.payload,config:I==null?void 0:I.config,nodeFilter:I==null?void 0:I.nodeFilter,branchLabel:I==null?void 0:I.branchLabel,active_agent:I==null?void 0:I.active_agent,timelineCheckpoints:I==null?void 0:I.timelineCheckpoints};H(Y)},[f,H]);w.useEffect(()=>{A(J)},[J,A]);const R=w.useCallback(async()=>{c(),k(),m(null)},[k,m,c]);w.useEffect(()=>{E(R)},[R,E]);const G=w.useCallback(async($,P)=>{let I=f.current;const U=($==null?void 0:$.text)??"",Z=($==null?void 0:$.attachments)??[],M=(U==null?void 0:U.trim())??"",Y={...($==null?void 0:$.payload)??{}},_=Array.isArray(Y.messages)?Y.messages:void 0;_&&delete Y.messages;const z=!!(_&&_.length);if(!I&&!M&&Z.length===0&&!z)return;if(!I){const qe=Math.floor(Date.now()/1e3).toString(16).padStart(8,"0"),ze=Array.from({length:4},()=>Math.floor(Math.random()*4294967295).toString(16).padStart(8,"0")).join("").slice(0,16);I=`${qe}${ze}`,b(I),m(I)}const{contentParts:W,filesInfo:O}=await pu(Z),D=[...W];M&&D.push({type:"text",text:U});const B=P==null?void 0:P.originalMessageId,Q=!!(P!=null&&P.edit&&B),oe=!z&&D.length>0;let ie=null;oe&&(ie={id:Q?B:`msg-${Date.now()}`,role:"user",content:D,createdAt:new Date().toISOString()},Q?S(ie,B):S(ie));const Ce=z?_:ie?[ie]:[],ve={...Y,...O.length?{files_info:O}:{}};Ce.length?ve.messages=Ce:"messages"in ve||(ve.messages=[]);let Re=(P==null?void 0:P.checkpointId)??g.id??void 0,We=(P==null?void 0:P.checkpointNs)??g.namespace??void 0;if(Q&&B){const qe=Cw(x,B);Re=qe.checkpointId,We=qe.checkpointNs??void 0}const De={threadId:I,payload:ve,checkpointId:Re,checkpointNs:We,edit:!!(P!=null&&P.edit)};H(De)},[g,f,b,S,H,x]),K=w.useMemo(()=>({isStreaming:l,error:d,connectionState:l?"connected":"idle",submit:G,send:G,stop:c,setAuthToken:p}),[l,d,G,c,p]);return u.jsx(Uu.Provider,{value:K,children:e})}function qi(){const e=w.useContext(Uu);if(!e)throw new Error("useStream must be used within StreamingProvider");return e}function Ew(){return w.useContext(Wu)}function Vu(e){return typeof e=="object"&&e!==null}function Iw(e,t){if(Object.is(e,t))return!0;if(!Vu(e)||!Vu(t))return!1;const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const o of n)if(!Object.prototype.hasOwnProperty.call(t,o)||!Object.is(e[o],t[o]))return!1;return!0}function Ku(e){const t=w.useRef(e),n=w.useRef(e);return Iw(t.current,e)||(t.current=e,n.current=e),n.current}function Tr({children:e,apiConfig:t,initialThreadId:n=null,initialCheckpointId:r=null,initialCheckpointNs:o=null,autoLoadInitial:s=!0,onConnectionError:i,onError:a,onAuthError:c,onThreadChange:l,onToolEnd:d}){const p=Ku(t),m=so(a),f=so(c),v=so(i),g=so(l),x=so(d),y=w.useMemo(()=>({initialThreadId:n,initialCheckpointId:r,initialCheckpointNs:o,autoLoadInitial:s,onError:m,onAuthError:f,onConnectionError:v,onThreadChange:g,onToolEnd:x}),[n,r,o,s,m,f,v,g,x]);return u.jsx(du,{apiConfig:p,children:u.jsx(Tw,{...y,children:e})})}function so(e){const t=w.useRef(e);return w.useEffect(()=>{t.current=e},[e]),w.useCallback((...n)=>{const r=t.current;if(r)return r(...n)},[])}function kr(e){if(!(typeof globalThis>"u"))return globalThis[e]}function Nw(e){if(typeof e!="string")return;const t=e.trim();if(t)return vn(t)}function qu(){const e=[kr("__API_BASE_URL__"),kr("__CHAT_API_BASE_URL__"),kr("__CHAT_API_URL__")];for(const t of e){const n=Nw(t);if(n)return n}}function Gu(){const e=[kr("__API_AUTH_TOKEN__"),kr("__CHAT_API_KEY__"),kr("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function Yu(...e){for(const t of e)if(typeof t=="string"&&t.trim())return vn(t);return vn()}function Xu(){const e={},t=qu(),n=Gu();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function Ju(){const e=Xu(),t=Nn.getAuthToken(),n=qu();return{apiBaseUrl:Yu(e.baseUrl,Nn.baseUrl,n),apiKey:t||e.apiKey||Gu()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,darkMode:!1,enableSound:!1,messageHistory:100}}const Gi="chat-settings";function Zu(){try{const e=localStorage.getItem(Gi);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function Qu(e){try{const t={...e,apiBaseUrl:vn(e.apiBaseUrl)};localStorage.setItem(Gi,JSON.stringify(t)),t.apiKey&&Nn.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function Aw(){const e=Ju(),t=Zu(),n=Nn.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:Yu(Nn.baseUrl,r,e.apiBaseUrl)}}function Pw(e){Nn.updateConfig({baseUrl:e.apiBaseUrl,authToken:e.apiKey??void 0}),Qu(e)}function ne(...e){return bx.twMerge(wx.clsx(e))}const jw=Kr.cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),Ye=h.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?qt.Slot:"button";return u.jsx(i,{className:ne(jw({variant:t,size:n,className:e})),ref:s,...o})});Ye.displayName="Button";function ae(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}function ed(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Mn(...e){return t=>{let n=!1;const r=e.map(o=>{const s=ed(o,t);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let o=0;o<r.length;o++){const s=r[o];typeof s=="function"?s():ed(e[o],null)}}}}function je(...e){return h.useCallback(Mn(...e),e)}function _w(e,t){const n=h.createContext(t),r=s=>{const{children:i,...a}=s,c=h.useMemo(()=>a,Object.values(a));return u.jsx(n.Provider,{value:c,children:i})};r.displayName=e+"Provider";function o(s){const i=h.useContext(n);if(i)return i;if(t!==void 0)return t;throw new Error(`\`${s}\` must be used within \`${e}\``)}return[r,o]}function cn(e,t=[]){let n=[];function r(s,i){const a=h.createContext(i),c=n.length;n=[...n,i];const l=p=>{var y;const{scope:m,children:f,...v}=p,g=((y=m==null?void 0:m[e])==null?void 0:y[c])||a,x=h.useMemo(()=>v,Object.values(v));return u.jsx(g.Provider,{value:x,children:f})};l.displayName=s+"Provider";function d(p,m){var g;const f=((g=m==null?void 0:m[e])==null?void 0:g[c])||a,v=h.useContext(f);if(v)return v;if(i!==void 0)return i;throw new Error(`\`${p}\` must be used within \`${s}\``)}return[l,d]}const o=()=>{const s=n.map(i=>h.createContext(i));return function(a){const c=(a==null?void 0:a[e])||s;return h.useMemo(()=>({[`__scope${e}`]:{...a,[e]:c}}),[a,c])}};return o.scopeName=e,[r,Rw(o,...t)]}function Rw(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(s){const i=r.reduce((a,{useScope:c,scopeName:l})=>{const p=c(s)[`__scope${l}`];return{...a,...p}},{});return h.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var Tt=globalThis!=null&&globalThis.document?h.useLayoutEffect:()=>{},Mw=h[" useInsertionEffect ".trim().toString()]||Tt;function On({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=Ow({defaultProp:t,onChange:n}),a=e!==void 0,c=a?e:o;{const d=h.useRef(e!==void 0);h.useEffect(()=>{const p=d.current;p!==a&&console.warn(`${r} is changing from ${p?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),d.current=a},[a,r])}const l=h.useCallback(d=>{var p;if(a){const m=Dw(d)?d(e):d;m!==e&&((p=i.current)==null||p.call(i,m))}else s(d)},[a,e,s,i]);return[c,l]}function Ow({defaultProp:e,onChange:t}){const[n,r]=h.useState(e),o=h.useRef(n),s=h.useRef(t);return Mw(()=>{s.current=t},[t]),h.useEffect(()=>{var i;o.current!==n&&((i=s.current)==null||i.call(s,n),o.current=n)},[n,o]),[n,r,s]}function Dw(e){return typeof e=="function"}var Lw=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],he=Lw.reduce((e,t)=>{const n=qt.createSlot(`Primitive.${t}`),r=h.forwardRef((o,s)=>{const{asChild:i,...a}=o,c=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),u.jsx(c,{...a,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Yi(e,t){e&&qr.flushSync(()=>e.dispatchEvent(t))}function es(e){const t=e+"CollectionProvider",[n,r]=cn(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=g=>{const{scope:x,children:y}=g,b=w.useRef(null),C=w.useRef(new Map).current;return u.jsx(o,{scope:x,itemMap:C,collectionRef:b,children:y})};i.displayName=t;const a=e+"CollectionSlot",c=qt.createSlot(a),l=w.forwardRef((g,x)=>{const{scope:y,children:b}=g,C=s(a,y),k=je(x,C.collectionRef);return u.jsx(c,{ref:k,children:b})});l.displayName=a;const d=e+"CollectionItemSlot",p="data-radix-collection-item",m=qt.createSlot(d),f=w.forwardRef((g,x)=>{const{scope:y,children:b,...C}=g,k=w.useRef(null),S=je(x,k),T=s(d,y);return w.useEffect(()=>(T.itemMap.set(k,{ref:k,...C}),()=>void T.itemMap.delete(k))),u.jsx(m,{[p]:"",ref:S,children:b})});f.displayName=d;function v(g){const x=s(e+"CollectionConsumer",g);return w.useCallback(()=>{const b=x.collectionRef.current;if(!b)return[];const C=Array.from(b.querySelectorAll(`[${p}]`));return Array.from(x.itemMap.values()).sort((T,E)=>C.indexOf(T.ref.current)-C.indexOf(E.ref.current))},[x.collectionRef,x.itemMap])}return[{Provider:i,Slot:l,ItemSlot:f},v,r]}var $w=h.createContext(void 0);function ts(e){const t=h.useContext($w);return e||t||"ltr"}function pt(e){const t=h.useRef(e);return h.useEffect(()=>{t.current=e}),h.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function Fw(e,t=globalThis==null?void 0:globalThis.document){const n=pt(e);h.useEffect(()=>{const r=o=>{o.key==="Escape"&&n(o)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var Bw="DismissableLayer",Xi="dismissableLayer.update",zw="dismissableLayer.pointerDownOutside",Hw="dismissableLayer.focusOutside",td,nd=h.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Er=h.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...c}=e,l=h.useContext(nd),[d,p]=h.useState(null),m=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,f]=h.useState({}),v=je(t,E=>p(E)),g=Array.from(l.layers),[x]=[...l.layersWithOutsidePointerEventsDisabled].slice(-1),y=g.indexOf(x),b=d?g.indexOf(d):-1,C=l.layersWithOutsidePointerEventsDisabled.size>0,k=b>=y,S=Ww(E=>{const A=E.target,j=[...l.branches].some(L=>L.contains(A));!k||j||(o==null||o(E),i==null||i(E),E.defaultPrevented||a==null||a())},m),T=Vw(E=>{const A=E.target;[...l.branches].some(L=>L.contains(A))||(s==null||s(E),i==null||i(E),E.defaultPrevented||a==null||a())},m);return Fw(E=>{b===l.layers.size-1&&(r==null||r(E),!E.defaultPrevented&&a&&(E.preventDefault(),a()))},m),h.useEffect(()=>{if(d)return n&&(l.layersWithOutsidePointerEventsDisabled.size===0&&(td=m.body.style.pointerEvents,m.body.style.pointerEvents="none"),l.layersWithOutsidePointerEventsDisabled.add(d)),l.layers.add(d),od(),()=>{n&&l.layersWithOutsidePointerEventsDisabled.size===1&&(m.body.style.pointerEvents=td)}},[d,m,n,l]),h.useEffect(()=>()=>{d&&(l.layers.delete(d),l.layersWithOutsidePointerEventsDisabled.delete(d),od())},[d,l]),h.useEffect(()=>{const E=()=>f({});return document.addEventListener(Xi,E),()=>document.removeEventListener(Xi,E)},[]),u.jsx(he.div,{...c,ref:v,style:{pointerEvents:C?k?"auto":"none":void 0,...e.style},onFocusCapture:ae(e.onFocusCapture,T.onFocusCapture),onBlurCapture:ae(e.onBlurCapture,T.onBlurCapture),onPointerDownCapture:ae(e.onPointerDownCapture,S.onPointerDownCapture)})});Er.displayName=Bw;var Uw="DismissableLayerBranch",rd=h.forwardRef((e,t)=>{const n=h.useContext(nd),r=h.useRef(null),o=je(t,r);return h.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),u.jsx(he.div,{...e,ref:o})});rd.displayName=Uw;function Ww(e,t=globalThis==null?void 0:globalThis.document){const n=pt(e),r=h.useRef(!1),o=h.useRef(()=>{});return h.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let c=function(){sd(zw,n,l,{discrete:!0})};const l={originalEvent:a};a.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=c,t.addEventListener("click",o.current,{once:!0})):c()}else t.removeEventListener("click",o.current);r.current=!1},i=window.setTimeout(()=>{t.addEventListener("pointerdown",s)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",s),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function Vw(e,t=globalThis==null?void 0:globalThis.document){const n=pt(e),r=h.useRef(!1);return h.useEffect(()=>{const o=s=>{s.target&&!r.current&&sd(Hw,n,{originalEvent:s},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function od(){const e=new CustomEvent(Xi);document.dispatchEvent(e)}function sd(e,t,n,{discrete:r}){const o=n.originalEvent.target,s=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?Yi(o,s):o.dispatchEvent(s)}var Kw=Er,qw=rd,Ji=0;function Zi(){h.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??id()),document.body.insertAdjacentElement("beforeend",e[1]??id()),Ji++,()=>{Ji===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Ji--}},[])}function id(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var Qi="focusScope.autoFocusOnMount",ea="focusScope.autoFocusOnUnmount",ad={bubbles:!1,cancelable:!0},Gw="FocusScope",ns=h.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,c]=h.useState(null),l=pt(o),d=pt(s),p=h.useRef(null),m=je(t,g=>c(g)),f=h.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;h.useEffect(()=>{if(r){let g=function(C){if(f.paused||!a)return;const k=C.target;a.contains(k)?p.current=k:Dn(p.current,{select:!0})},x=function(C){if(f.paused||!a)return;const k=C.relatedTarget;k!==null&&(a.contains(k)||Dn(p.current,{select:!0}))},y=function(C){if(document.activeElement===document.body)for(const S of C)S.removedNodes.length>0&&Dn(a)};document.addEventListener("focusin",g),document.addEventListener("focusout",x);const b=new MutationObserver(y);return a&&b.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",g),document.removeEventListener("focusout",x),b.disconnect()}}},[r,a,f.paused]),h.useEffect(()=>{if(a){ud.add(f);const g=document.activeElement;if(!a.contains(g)){const y=new CustomEvent(Qi,ad);a.addEventListener(Qi,l),a.dispatchEvent(y),y.defaultPrevented||(Yw(eb(ld(a)),{select:!0}),document.activeElement===g&&Dn(a))}return()=>{a.removeEventListener(Qi,l),setTimeout(()=>{const y=new CustomEvent(ea,ad);a.addEventListener(ea,d),a.dispatchEvent(y),y.defaultPrevented||Dn(g??document.body,{select:!0}),a.removeEventListener(ea,d),ud.remove(f)},0)}}},[a,l,d,f]);const v=h.useCallback(g=>{if(!n&&!r||f.paused)return;const x=g.key==="Tab"&&!g.altKey&&!g.ctrlKey&&!g.metaKey,y=document.activeElement;if(x&&y){const b=g.currentTarget,[C,k]=Xw(b);C&&k?!g.shiftKey&&y===k?(g.preventDefault(),n&&Dn(C,{select:!0})):g.shiftKey&&y===C&&(g.preventDefault(),n&&Dn(k,{select:!0})):y===b&&g.preventDefault()}},[n,r,f.paused]);return u.jsx(he.div,{tabIndex:-1,...i,ref:m,onKeyDown:v})});ns.displayName=Gw;function Yw(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Dn(r,{select:t}),document.activeElement!==n)return}function Xw(e){const t=ld(e),n=cd(t,e),r=cd(t.reverse(),e);return[n,r]}function ld(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function cd(e,t){for(const n of e)if(!Jw(n,{upTo:t}))return n}function Jw(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function Zw(e){return e instanceof HTMLInputElement&&"select"in e}function Dn(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Zw(e)&&t&&e.select()}}var ud=Qw();function Qw(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=dd(e,t),e.unshift(t)},remove(t){var n;e=dd(e,t),(n=e[0])==null||n.resume()}}}function dd(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function eb(e){return e.filter(t=>t.tagName!=="A")}var tb=h[" useId ".trim().toString()]||(()=>{}),nb=0;function jt(e){const[t,n]=h.useState(tb());return Tt(()=>{n(r=>r??String(nb++))},[e]),t?`radix-${t}`:""}const rb=["top","right","bottom","left"],Ln=Math.min,Xt=Math.max,rs=Math.round,os=Math.floor,wn=e=>({x:e,y:e}),ob={left:"right",right:"left",bottom:"top",top:"bottom"},sb={start:"end",end:"start"};function ta(e,t,n){return Xt(e,Ln(t,n))}function An(e,t){return typeof e=="function"?e(t):e}function Pn(e){return e.split("-")[0]}function Ir(e){return e.split("-")[1]}function na(e){return e==="x"?"y":"x"}function ra(e){return e==="y"?"height":"width"}const ib=new Set(["top","bottom"]);function bn(e){return ib.has(Pn(e))?"y":"x"}function oa(e){return na(bn(e))}function ab(e,t,n){n===void 0&&(n=!1);const r=Ir(e),o=oa(e),s=ra(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=ss(i)),[i,ss(i)]}function lb(e){const t=ss(e);return[sa(e),t,sa(t)]}function sa(e){return e.replace(/start|end/g,t=>sb[t])}const fd=["left","right"],pd=["right","left"],cb=["top","bottom"],ub=["bottom","top"];function db(e,t,n){switch(e){case"top":case"bottom":return n?t?pd:fd:t?fd:pd;case"left":case"right":return t?cb:ub;default:return[]}}function fb(e,t,n,r){const o=Ir(e);let s=db(Pn(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(sa)))),s}function ss(e){return e.replace(/left|right|bottom|top/g,t=>ob[t])}function pb(e){return{top:0,right:0,bottom:0,left:0,...e}}function hd(e){return typeof e!="number"?pb(e):{top:e,right:e,bottom:e,left:e}}function is(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}function md(e,t,n){let{reference:r,floating:o}=e;const s=bn(t),i=oa(t),a=ra(i),c=Pn(t),l=s==="y",d=r.x+r.width/2-o.width/2,p=r.y+r.height/2-o.height/2,m=r[a]/2-o[a]/2;let f;switch(c){case"top":f={x:d,y:r.y-o.height};break;case"bottom":f={x:d,y:r.y+r.height};break;case"right":f={x:r.x+r.width,y:p};break;case"left":f={x:r.x-o.width,y:p};break;default:f={x:r.x,y:r.y}}switch(Ir(t)){case"start":f[i]-=m*(n&&l?-1:1);break;case"end":f[i]+=m*(n&&l?-1:1);break}return f}const hb=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=n,a=s.filter(Boolean),c=await(i.isRTL==null?void 0:i.isRTL(t));let l=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:d,y:p}=md(l,r,c),m=r,f={},v=0;for(let g=0;g<a.length;g++){const{name:x,fn:y}=a[g],{x:b,y:C,data:k,reset:S}=await y({x:d,y:p,initialPlacement:r,placement:m,strategy:o,middlewareData:f,rects:l,platform:i,elements:{reference:e,floating:t}});d=b??d,p=C??p,f={...f,[x]:{...f[x],...k}},S&&v<=50&&(v++,typeof S=="object"&&(S.placement&&(m=S.placement),S.rects&&(l=S.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):S.rects),{x:d,y:p}=md(l,m,c)),g=-1)}return{x:d,y:p,placement:m,strategy:o,middlewareData:f}};async function io(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:i,elements:a,strategy:c}=e,{boundary:l="clippingAncestors",rootBoundary:d="viewport",elementContext:p="floating",altBoundary:m=!1,padding:f=0}=An(t,e),v=hd(f),x=a[m?p==="floating"?"reference":"floating":p],y=is(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(x)))==null||n?x:x.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:l,rootBoundary:d,strategy:c})),b=p==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,C=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),k=await(s.isElement==null?void 0:s.isElement(C))?await(s.getScale==null?void 0:s.getScale(C))||{x:1,y:1}:{x:1,y:1},S=is(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:b,offsetParent:C,strategy:c}):b);return{top:(y.top-S.top+v.top)/k.y,bottom:(S.bottom-y.bottom+v.bottom)/k.y,left:(y.left-S.left+v.left)/k.x,right:(S.right-y.right+v.right)/k.x}}const mb=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:s,platform:i,elements:a,middlewareData:c}=t,{element:l,padding:d=0}=An(e,t)||{};if(l==null)return{};const p=hd(d),m={x:n,y:r},f=oa(o),v=ra(f),g=await i.getDimensions(l),x=f==="y",y=x?"top":"left",b=x?"bottom":"right",C=x?"clientHeight":"clientWidth",k=s.reference[v]+s.reference[f]-m[f]-s.floating[v],S=m[f]-s.reference[f],T=await(i.getOffsetParent==null?void 0:i.getOffsetParent(l));let E=T?T[C]:0;(!E||!await(i.isElement==null?void 0:i.isElement(T)))&&(E=a.floating[C]||s.floating[v]);const A=k/2-S/2,j=E/2-g[v]/2-1,L=Ln(p[y],j),H=Ln(p[b],j),V=L,J=E-g[v]-H,R=E/2-g[v]/2+A,G=ta(V,R,J),K=!c.arrow&&Ir(o)!=null&&R!==G&&s.reference[v]/2-(R<V?L:H)-g[v]/2<0,$=K?R<V?R-V:R-J:0;return{[f]:m[f]+$,data:{[f]:G,centerOffset:R-G-$,...K&&{alignmentOffset:$}},reset:K}}}),gb=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:s,rects:i,initialPlacement:a,platform:c,elements:l}=t,{mainAxis:d=!0,crossAxis:p=!0,fallbackPlacements:m,fallbackStrategy:f="bestFit",fallbackAxisSideDirection:v="none",flipAlignment:g=!0,...x}=An(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const y=Pn(o),b=bn(a),C=Pn(a)===a,k=await(c.isRTL==null?void 0:c.isRTL(l.floating)),S=m||(C||!g?[ss(a)]:lb(a)),T=v!=="none";!m&&T&&S.push(...fb(a,g,v,k));const E=[a,...S],A=await io(t,x),j=[];let L=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&j.push(A[y]),p){const R=ab(o,i,k);j.push(A[R[0]],A[R[1]])}if(L=[...L,{placement:o,overflows:j}],!j.every(R=>R<=0)){var H,V;const R=(((H=s.flip)==null?void 0:H.index)||0)+1,G=E[R];if(G&&(!(p==="alignment"?b!==bn(G):!1)||L.every(P=>bn(P.placement)===b?P.overflows[0]>0:!0)))return{data:{index:R,overflows:L},reset:{placement:G}};let K=(V=L.filter($=>$.overflows[0]<=0).sort(($,P)=>$.overflows[1]-P.overflows[1])[0])==null?void 0:V.placement;if(!K)switch(f){case"bestFit":{var J;const $=(J=L.filter(P=>{if(T){const I=bn(P.placement);return I===b||I==="y"}return!0}).map(P=>[P.placement,P.overflows.filter(I=>I>0).reduce((I,U)=>I+U,0)]).sort((P,I)=>P[1]-I[1])[0])==null?void 0:J[0];$&&(K=$);break}case"initialPlacement":K=a;break}if(o!==K)return{reset:{placement:K}}}return{}}}};function gd(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function xd(e){return rb.some(t=>e[t]>=0)}const xb=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=An(e,t);switch(r){case"referenceHidden":{const s=await io(t,{...o,elementContext:"reference"}),i=gd(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:xd(i)}}}case"escaped":{const s=await io(t,{...o,altBoundary:!0}),i=gd(s,n.floating);return{data:{escapedOffsets:i,escaped:xd(i)}}}default:return{}}}}},vd=new Set(["left","top"]);async function vb(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=Pn(n),a=Ir(n),c=bn(n)==="y",l=vd.has(i)?-1:1,d=s&&c?-1:1,p=An(t,e);let{mainAxis:m,crossAxis:f,alignmentAxis:v}=typeof p=="number"?{mainAxis:p,crossAxis:0,alignmentAxis:null}:{mainAxis:p.mainAxis||0,crossAxis:p.crossAxis||0,alignmentAxis:p.alignmentAxis};return a&&typeof v=="number"&&(f=a==="end"?v*-1:v),c?{x:f*d,y:m*l}:{x:m*l,y:f*d}}const wb=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:s,placement:i,middlewareData:a}=t,c=await vb(t,e);return i===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:o+c.x,y:s+c.y,data:{...c,placement:i}}}}},bb=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o}=t,{mainAxis:s=!0,crossAxis:i=!1,limiter:a={fn:x=>{let{x:y,y:b}=x;return{x:y,y:b}}},...c}=An(e,t),l={x:n,y:r},d=await io(t,c),p=bn(Pn(o)),m=na(p);let f=l[m],v=l[p];if(s){const x=m==="y"?"top":"left",y=m==="y"?"bottom":"right",b=f+d[x],C=f-d[y];f=ta(b,f,C)}if(i){const x=p==="y"?"top":"left",y=p==="y"?"bottom":"right",b=v+d[x],C=v-d[y];v=ta(b,v,C)}const g=a.fn({...t,[m]:f,[p]:v});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[m]:s,[p]:i}}}}}},yb=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:s,middlewareData:i}=t,{offset:a=0,mainAxis:c=!0,crossAxis:l=!0}=An(e,t),d={x:n,y:r},p=bn(o),m=na(p);let f=d[m],v=d[p];const g=An(a,t),x=typeof g=="number"?{mainAxis:g,crossAxis:0}:{mainAxis:0,crossAxis:0,...g};if(c){const C=m==="y"?"height":"width",k=s.reference[m]-s.floating[C]+x.mainAxis,S=s.reference[m]+s.reference[C]-x.mainAxis;f<k?f=k:f>S&&(f=S)}if(l){var y,b;const C=m==="y"?"width":"height",k=vd.has(Pn(o)),S=s.reference[p]-s.floating[C]+(k&&((y=i.offset)==null?void 0:y[p])||0)+(k?0:x.crossAxis),T=s.reference[p]+s.reference[C]+(k?0:((b=i.offset)==null?void 0:b[p])||0)-(k?x.crossAxis:0);v<S?v=S:v>T&&(v=T)}return{[m]:f,[p]:v}}}},Sb=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:s,platform:i,elements:a}=t,{apply:c=()=>{},...l}=An(e,t),d=await io(t,l),p=Pn(o),m=Ir(o),f=bn(o)==="y",{width:v,height:g}=s.floating;let x,y;p==="top"||p==="bottom"?(x=p,y=m===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(y=p,x=m==="end"?"top":"bottom");const b=g-d.top-d.bottom,C=v-d.left-d.right,k=Ln(g-d[x],b),S=Ln(v-d[y],C),T=!t.middlewareData.shift;let E=k,A=S;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(A=C),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(E=b),T&&!m){const L=Xt(d.left,0),H=Xt(d.right,0),V=Xt(d.top,0),J=Xt(d.bottom,0);f?A=v-2*(L!==0||H!==0?L+H:Xt(d.left,d.right)):E=g-2*(V!==0||J!==0?V+J:Xt(d.top,d.bottom))}await c({...t,availableWidth:A,availableHeight:E});const j=await i.getDimensions(a.floating);return v!==j.width||g!==j.height?{reset:{rects:!0}}:{}}}};function as(){return typeof window<"u"}function Nr(e){return wd(e)?(e.nodeName||"").toLowerCase():"#document"}function Jt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function yn(e){var t;return(t=(wd(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function wd(e){return as()?e instanceof Node||e instanceof Jt(e).Node:!1}function un(e){return as()?e instanceof Element||e instanceof Jt(e).Element:!1}function Sn(e){return as()?e instanceof HTMLElement||e instanceof Jt(e).HTMLElement:!1}function bd(e){return!as()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Jt(e).ShadowRoot}const Cb=new Set(["inline","contents"]);function ao(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=dn(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!Cb.has(o)}const Tb=new Set(["table","td","th"]);function kb(e){return Tb.has(Nr(e))}const Eb=[":popover-open",":modal"];function ls(e){return Eb.some(t=>{try{return e.matches(t)}catch{return!1}})}const Ib=["transform","translate","scale","rotate","perspective"],Nb=["transform","translate","scale","rotate","perspective","filter"],Ab=["paint","layout","strict","content"];function ia(e){const t=aa(),n=un(e)?dn(e):e;return Ib.some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||Nb.some(r=>(n.willChange||"").includes(r))||Ab.some(r=>(n.contain||"").includes(r))}function Pb(e){let t=$n(e);for(;Sn(t)&&!Ar(t);){if(ia(t))return t;if(ls(t))return null;t=$n(t)}return null}function aa(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const jb=new Set(["html","body","#document"]);function Ar(e){return jb.has(Nr(e))}function dn(e){return Jt(e).getComputedStyle(e)}function cs(e){return un(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function $n(e){if(Nr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||bd(e)&&e.host||yn(e);return bd(t)?t.host:t}function yd(e){const t=$n(e);return Ar(t)?e.ownerDocument?e.ownerDocument.body:e.body:Sn(t)&&ao(t)?t:yd(t)}function lo(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=yd(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Jt(o);if(s){const a=la(i);return t.concat(i,i.visualViewport||[],ao(o)?o:[],a&&n?lo(a):[])}return t.concat(o,lo(o,[],n))}function la(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Sd(e){const t=dn(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=Sn(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=rs(n)!==s||rs(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function ca(e){return un(e)?e:e.contextElement}function Pr(e){const t=ca(e);if(!Sn(t))return wn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=Sd(t);let i=(s?rs(n.width):n.width)/r,a=(s?rs(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const _b=wn(0);function Cd(e){const t=Jt(e);return!aa()||!t.visualViewport?_b:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Rb(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Jt(e)?!1:t}function nr(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=ca(e);let i=wn(1);t&&(r?un(r)&&(i=Pr(r)):i=Pr(e));const a=Rb(s,n,r)?Cd(s):wn(0);let c=(o.left+a.x)/i.x,l=(o.top+a.y)/i.y,d=o.width/i.x,p=o.height/i.y;if(s){const m=Jt(s),f=r&&un(r)?Jt(r):r;let v=m,g=la(v);for(;g&&r&&f!==v;){const x=Pr(g),y=g.getBoundingClientRect(),b=dn(g),C=y.left+(g.clientLeft+parseFloat(b.paddingLeft))*x.x,k=y.top+(g.clientTop+parseFloat(b.paddingTop))*x.y;c*=x.x,l*=x.y,d*=x.x,p*=x.y,c+=C,l+=k,v=Jt(g),g=la(v)}}return is({width:d,height:p,x:c,y:l})}function us(e,t){const n=cs(e).scrollLeft;return t?t.left+n:nr(yn(e)).left+n}function Td(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-us(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function Mb(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=yn(r),a=t?ls(t.floating):!1;if(r===i||a&&s)return n;let c={scrollLeft:0,scrollTop:0},l=wn(1);const d=wn(0),p=Sn(r);if((p||!p&&!s)&&((Nr(r)!=="body"||ao(i))&&(c=cs(r)),Sn(r))){const f=nr(r);l=Pr(r),d.x=f.x+r.clientLeft,d.y=f.y+r.clientTop}const m=i&&!p&&!s?Td(i,c):wn(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+d.x+m.x,y:n.y*l.y-c.scrollTop*l.y+d.y+m.y}}function Ob(e){return Array.from(e.getClientRects())}function Db(e){const t=yn(e),n=cs(e),r=e.ownerDocument.body,o=Xt(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Xt(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+us(e);const a=-n.scrollTop;return dn(r).direction==="rtl"&&(i+=Xt(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const kd=25;function Lb(e,t){const n=Jt(e),r=yn(e),o=n.visualViewport;let s=r.clientWidth,i=r.clientHeight,a=0,c=0;if(o){s=o.width,i=o.height;const d=aa();(!d||d&&t==="fixed")&&(a=o.offsetLeft,c=o.offsetTop)}const l=us(r);if(l<=0){const d=r.ownerDocument,p=d.body,m=getComputedStyle(p),f=d.compatMode==="CSS1Compat"&&parseFloat(m.marginLeft)+parseFloat(m.marginRight)||0,v=Math.abs(r.clientWidth-p.clientWidth-f);v<=kd&&(s-=v)}else l<=kd&&(s+=l);return{width:s,height:i,x:a,y:c}}const $b=new Set(["absolute","fixed"]);function Fb(e,t){const n=nr(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=Sn(e)?Pr(e):wn(1),i=e.clientWidth*s.x,a=e.clientHeight*s.y,c=o*s.x,l=r*s.y;return{width:i,height:a,x:c,y:l}}function Ed(e,t,n){let r;if(t==="viewport")r=Lb(e,n);else if(t==="document")r=Db(yn(e));else if(un(t))r=Fb(t,n);else{const o=Cd(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return is(r)}function Id(e,t){const n=$n(e);return n===t||!un(n)||Ar(n)?!1:dn(n).position==="fixed"||Id(n,t)}function Bb(e,t){const n=t.get(e);if(n)return n;let r=lo(e,[],!1).filter(a=>un(a)&&Nr(a)!=="body"),o=null;const s=dn(e).position==="fixed";let i=s?$n(e):e;for(;un(i)&&!Ar(i);){const a=dn(i),c=ia(i);!c&&a.position==="fixed"&&(o=null),(s?!c&&!o:!c&&a.position==="static"&&!!o&&$b.has(o.position)||ao(i)&&!c&&Id(e,i))?r=r.filter(d=>d!==i):o=a,i=$n(i)}return t.set(e,r),r}function zb(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?ls(t)?[]:Bb(t,this._c):[].concat(n),r],a=i[0],c=i.reduce((l,d)=>{const p=Ed(t,d,o);return l.top=Xt(p.top,l.top),l.right=Ln(p.right,l.right),l.bottom=Ln(p.bottom,l.bottom),l.left=Xt(p.left,l.left),l},Ed(t,a,o));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function Hb(e){const{width:t,height:n}=Sd(e);return{width:t,height:n}}function Ub(e,t,n){const r=Sn(t),o=yn(t),s=n==="fixed",i=nr(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const c=wn(0);function l(){c.x=us(o)}if(r||!r&&!s)if((Nr(t)!=="body"||ao(o))&&(a=cs(t)),r){const f=nr(t,!0,s,t);c.x=f.x+t.clientLeft,c.y=f.y+t.clientTop}else o&&l();s&&!r&&o&&l();const d=o&&!r&&!s?Td(o,a):wn(0),p=i.left+a.scrollLeft-c.x-d.x,m=i.top+a.scrollTop-c.y-d.y;return{x:p,y:m,width:i.width,height:i.height}}function ua(e){return dn(e).position==="static"}function Nd(e,t){if(!Sn(e)||dn(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return yn(e)===n&&(n=n.ownerDocument.body),n}function Ad(e,t){const n=Jt(e);if(ls(e))return n;if(!Sn(e)){let o=$n(e);for(;o&&!Ar(o);){if(un(o)&&!ua(o))return o;o=$n(o)}return n}let r=Nd(e,t);for(;r&&kb(r)&&ua(r);)r=Nd(r,t);return r&&Ar(r)&&ua(r)&&!ia(r)?n:r||Pb(e)||n}const Wb=async function(e){const t=this.getOffsetParent||Ad,n=this.getDimensions,r=await n(e.floating);return{reference:Ub(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Vb(e){return dn(e).direction==="rtl"}const Kb={convertOffsetParentRelativeRectToViewportRelativeRect:Mb,getDocumentElement:yn,getClippingRect:zb,getOffsetParent:Ad,getElementRects:Wb,getClientRects:Ob,getDimensions:Hb,getScale:Pr,isElement:un,isRTL:Vb};function Pd(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function qb(e,t){let n=null,r;const o=yn(e);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,c){a===void 0&&(a=!1),c===void 0&&(c=1),s();const l=e.getBoundingClientRect(),{left:d,top:p,width:m,height:f}=l;if(a||t(),!m||!f)return;const v=os(p),g=os(o.clientWidth-(d+m)),x=os(o.clientHeight-(p+f)),y=os(d),C={rootMargin:-v+"px "+-g+"px "+-x+"px "+-y+"px",threshold:Xt(0,Ln(1,c))||1};let k=!0;function S(T){const E=T[0].intersectionRatio;if(E!==c){if(!k)return i();E?i(!1,E):r=setTimeout(()=>{i(!1,1e-7)},1e3)}E===1&&!Pd(l,e.getBoundingClientRect())&&i(),k=!1}try{n=new IntersectionObserver(S,{...C,root:o.ownerDocument})}catch{n=new IntersectionObserver(S,C)}n.observe(e)}return i(!0),s}function Gb(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:c=!1}=r,l=ca(e),d=o||s?[...l?lo(l):[],...lo(t)]:[];d.forEach(y=>{o&&y.addEventListener("scroll",n,{passive:!0}),s&&y.addEventListener("resize",n)});const p=l&&a?qb(l,n):null;let m=-1,f=null;i&&(f=new ResizeObserver(y=>{let[b]=y;b&&b.target===l&&f&&(f.unobserve(t),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var C;(C=f)==null||C.observe(t)})),n()}),l&&!c&&f.observe(l),f.observe(t));let v,g=c?nr(e):null;c&&x();function x(){const y=nr(e);g&&!Pd(g,y)&&n(),g=y,v=requestAnimationFrame(x)}return n(),()=>{var y;d.forEach(b=>{o&&b.removeEventListener("scroll",n),s&&b.removeEventListener("resize",n)}),p==null||p(),(y=f)==null||y.disconnect(),f=null,c&&cancelAnimationFrame(v)}}const Yb=wb,Xb=bb,Jb=gb,Zb=Sb,Qb=xb,jd=mb,ey=yb,ty=(e,t,n)=>{const r=new Map,o={platform:Kb,...n},s={...o.platform,_c:r};return hb(e,t,{...o,platform:s})};var ny=typeof document<"u",ry=function(){},ds=ny?w.useLayoutEffect:ry;function fs(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!fs(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){const s=o[r];if(!(s==="_owner"&&e.$$typeof)&&!fs(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function _d(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Rd(e,t){const n=_d(e);return Math.round(t*n)/n}function da(e){const t=h.useRef(e);return ds(()=>{t.current=e}),t}function oy(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:i}={},transform:a=!0,whileElementsMounted:c,open:l}=e,[d,p]=h.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[m,f]=h.useState(r);fs(m,r)||f(r);const[v,g]=h.useState(null),[x,y]=h.useState(null),b=h.useCallback(P=>{P!==T.current&&(T.current=P,g(P))},[]),C=h.useCallback(P=>{P!==E.current&&(E.current=P,y(P))},[]),k=s||v,S=i||x,T=h.useRef(null),E=h.useRef(null),A=h.useRef(d),j=c!=null,L=da(c),H=da(o),V=da(l),J=h.useCallback(()=>{if(!T.current||!E.current)return;const P={placement:t,strategy:n,middleware:m};H.current&&(P.platform=H.current),ty(T.current,E.current,P).then(I=>{const U={...I,isPositioned:V.current!==!1};R.current&&!fs(A.current,U)&&(A.current=U,qr.flushSync(()=>{p(U)}))})},[m,t,n,H,V]);ds(()=>{l===!1&&A.current.isPositioned&&(A.current.isPositioned=!1,p(P=>({...P,isPositioned:!1})))},[l]);const R=h.useRef(!1);ds(()=>(R.current=!0,()=>{R.current=!1}),[]),ds(()=>{if(k&&(T.current=k),S&&(E.current=S),k&&S){if(L.current)return L.current(k,S,J);J()}},[k,S,J,L,j]);const G=h.useMemo(()=>({reference:T,floating:E,setReference:b,setFloating:C}),[b,C]),K=h.useMemo(()=>({reference:k,floating:S}),[k,S]),$=h.useMemo(()=>{const P={position:n,left:0,top:0};if(!K.floating)return P;const I=Rd(K.floating,d.x),U=Rd(K.floating,d.y);return a?{...P,transform:"translate("+I+"px, "+U+"px)",..._d(K.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:I,top:U}},[n,a,K.floating,d.x,d.y]);return h.useMemo(()=>({...d,update:J,refs:G,elements:K,floatingStyles:$}),[d,J,G,K,$])}const sy=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:o}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?jd({element:r.current,padding:o}).fn(n):{}:r?jd({element:r,padding:o}).fn(n):{}}}},iy=(e,t)=>({...Yb(e),options:[e,t]}),ay=(e,t)=>({...Xb(e),options:[e,t]}),ly=(e,t)=>({...ey(e),options:[e,t]}),cy=(e,t)=>({...Jb(e),options:[e,t]}),uy=(e,t)=>({...Zb(e),options:[e,t]}),dy=(e,t)=>({...Qb(e),options:[e,t]}),fy=(e,t)=>({...sy(e),options:[e,t]});var py="Arrow",Md=h.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return u.jsx(he.svg,{...s,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:u.jsx("polygon",{points:"0,0 30,0 15,10"})})});Md.displayName=py;var hy=Md;function Od(e){const[t,n]=h.useState(void 0);return Tt(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const s=o[0];let i,a;if("borderBoxSize"in s){const c=s.borderBoxSize,l=Array.isArray(c)?c[0]:c;i=l.inlineSize,a=l.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var fa="Popper",[Dd,jr]=cn(fa),[my,Ld]=Dd(fa),$d=e=>{const{__scopePopper:t,children:n}=e,[r,o]=h.useState(null);return u.jsx(my,{scope:t,anchor:r,onAnchorChange:o,children:n})};$d.displayName=fa;var Fd="PopperAnchor",Bd=h.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=Ld(Fd,n),i=h.useRef(null),a=je(t,i),c=h.useRef(null);return h.useEffect(()=>{const l=c.current;c.current=(r==null?void 0:r.current)||i.current,l!==c.current&&s.onAnchorChange(c.current)}),r?null:u.jsx(he.div,{...o,ref:a})});Bd.displayName=Fd;var pa="PopperContent",[gy,xy]=Dd(pa),zd=h.forwardRef((e,t)=>{var O,D,B,Q,oe,ie;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:a=0,avoidCollisions:c=!0,collisionBoundary:l=[],collisionPadding:d=0,sticky:p="partial",hideWhenDetached:m=!1,updatePositionStrategy:f="optimized",onPlaced:v,...g}=e,x=Ld(pa,n),[y,b]=h.useState(null),C=je(t,Ce=>b(Ce)),[k,S]=h.useState(null),T=Od(k),E=(T==null?void 0:T.width)??0,A=(T==null?void 0:T.height)??0,j=r+(s!=="center"?"-"+s:""),L=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},H=Array.isArray(l)?l:[l],V=H.length>0,J={padding:L,boundary:H.filter(wy),altBoundary:V},{refs:R,floatingStyles:G,placement:K,isPositioned:$,middlewareData:P}=oy({strategy:"fixed",placement:j,whileElementsMounted:(...Ce)=>Gb(...Ce,{animationFrame:f==="always"}),elements:{reference:x.anchor},middleware:[iy({mainAxis:o+A,alignmentAxis:i}),c&&ay({mainAxis:!0,crossAxis:!1,limiter:p==="partial"?ly():void 0,...J}),c&&cy({...J}),uy({...J,apply:({elements:Ce,rects:ve,availableWidth:Re,availableHeight:We})=>{const{width:De,height:qe}=ve.reference,ze=Ce.floating.style;ze.setProperty("--radix-popper-available-width",`${Re}px`),ze.setProperty("--radix-popper-available-height",`${We}px`),ze.setProperty("--radix-popper-anchor-width",`${De}px`),ze.setProperty("--radix-popper-anchor-height",`${qe}px`)}}),k&&fy({element:k,padding:a}),by({arrowWidth:E,arrowHeight:A}),m&&dy({strategy:"referenceHidden",...J})]}),[I,U]=Wd(K),Z=pt(v);Tt(()=>{$&&(Z==null||Z())},[$,Z]);const M=(O=P.arrow)==null?void 0:O.x,Y=(D=P.arrow)==null?void 0:D.y,_=((B=P.arrow)==null?void 0:B.centerOffset)!==0,[z,W]=h.useState();return Tt(()=>{y&&W(window.getComputedStyle(y).zIndex)},[y]),u.jsx("div",{ref:R.setFloating,"data-radix-popper-content-wrapper":"",style:{...G,transform:$?G.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:z,"--radix-popper-transform-origin":[(Q=P.transformOrigin)==null?void 0:Q.x,(oe=P.transformOrigin)==null?void 0:oe.y].join(" "),...((ie=P.hide)==null?void 0:ie.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:u.jsx(gy,{scope:n,placedSide:I,onArrowChange:S,arrowX:M,arrowY:Y,shouldHideArrow:_,children:u.jsx(he.div,{"data-side":I,"data-align":U,...g,ref:C,style:{...g.style,animation:$?void 0:"none"}})})})});zd.displayName=pa;var Hd="PopperArrow",vy={top:"bottom",right:"left",bottom:"top",left:"right"},Ud=h.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=xy(Hd,r),i=vy[s.placedSide];return u.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:u.jsx(hy,{...o,ref:n,style:{...o.style,display:"block"}})})});Ud.displayName=Hd;function wy(e){return e!==null}var by=e=>({name:"transformOrigin",options:e,fn(t){var x,y,b;const{placement:n,rects:r,middlewareData:o}=t,i=((x=o.arrow)==null?void 0:x.centerOffset)!==0,a=i?0:e.arrowWidth,c=i?0:e.arrowHeight,[l,d]=Wd(n),p={start:"0%",center:"50%",end:"100%"}[d],m=(((y=o.arrow)==null?void 0:y.x)??0)+a/2,f=(((b=o.arrow)==null?void 0:b.y)??0)+c/2;let v="",g="";return l==="bottom"?(v=i?p:`${m}px`,g=`${-c}px`):l==="top"?(v=i?p:`${m}px`,g=`${r.floating.height+c}px`):l==="right"?(v=`${-c}px`,g=i?p:`${f}px`):l==="left"&&(v=`${r.floating.width+c}px`,g=i?p:`${f}px`),{data:{x:v,y:g}}}});function Wd(e){const[t,n="center"]=e.split("-");return[t,n]}var ha=$d,ma=Bd,ga=zd,xa=Ud,yy="Portal",co=h.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=h.useState(!1);Tt(()=>s(!0),[]);const i=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?Lo.createPortal(u.jsx(he.div,{...r,ref:t}),i):null});co.displayName=yy;function Sy(e,t){return h.useReducer((n,r)=>t[n][r]??n,e)}var Ht=e=>{const{present:t,children:n}=e,r=Cy(t),o=typeof n=="function"?n({present:r.isPresent}):h.Children.only(n),s=je(r.ref,Ty(o));return typeof n=="function"||r.isPresent?h.cloneElement(o,{ref:s}):null};Ht.displayName="Presence";function Cy(e){const[t,n]=h.useState(),r=h.useRef(null),o=h.useRef(e),s=h.useRef("none"),i=e?"mounted":"unmounted",[a,c]=Sy(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return h.useEffect(()=>{const l=ps(r.current);s.current=a==="mounted"?l:"none"},[a]),Tt(()=>{const l=r.current,d=o.current;if(d!==e){const m=s.current,f=ps(l);e?c("MOUNT"):f==="none"||(l==null?void 0:l.display)==="none"?c("UNMOUNT"):c(d&&m!==f?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,c]),Tt(()=>{if(t){let l;const d=t.ownerDocument.defaultView??window,p=f=>{const g=ps(r.current).includes(CSS.escape(f.animationName));if(f.target===t&&g&&(c("ANIMATION_END"),!o.current)){const x=t.style.animationFillMode;t.style.animationFillMode="forwards",l=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=x)})}},m=f=>{f.target===t&&(s.current=ps(r.current))};return t.addEventListener("animationstart",m),t.addEventListener("animationcancel",p),t.addEventListener("animationend",p),()=>{d.clearTimeout(l),t.removeEventListener("animationstart",m),t.removeEventListener("animationcancel",p),t.removeEventListener("animationend",p)}}else c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:h.useCallback(l=>{r.current=l?getComputedStyle(l):null,n(l)},[])}}function ps(e){return(e==null?void 0:e.animationName)||"none"}function Ty(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var va="rovingFocusGroup.onEntryFocus",ky={bubbles:!1,cancelable:!0},uo="RovingFocusGroup",[wa,Vd,Ey]=es(uo),[Iy,Kd]=cn(uo,[Ey]),[Ny,Ay]=Iy(uo),qd=h.forwardRef((e,t)=>u.jsx(wa.Provider,{scope:e.__scopeRovingFocusGroup,children:u.jsx(wa.Slot,{scope:e.__scopeRovingFocusGroup,children:u.jsx(Py,{...e,ref:t})})}));qd.displayName=uo;var Py=h.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:c,onEntryFocus:l,preventScrollOnEntryFocus:d=!1,...p}=e,m=h.useRef(null),f=je(t,m),v=ts(s),[g,x]=On({prop:i,defaultProp:a??null,onChange:c,caller:uo}),[y,b]=h.useState(!1),C=pt(l),k=Vd(n),S=h.useRef(!1),[T,E]=h.useState(0);return h.useEffect(()=>{const A=m.current;if(A)return A.addEventListener(va,C),()=>A.removeEventListener(va,C)},[C]),u.jsx(Ny,{scope:n,orientation:r,dir:v,loop:o,currentTabStopId:g,onItemFocus:h.useCallback(A=>x(A),[x]),onItemShiftTab:h.useCallback(()=>b(!0),[]),onFocusableItemAdd:h.useCallback(()=>E(A=>A+1),[]),onFocusableItemRemove:h.useCallback(()=>E(A=>A-1),[]),children:u.jsx(he.div,{tabIndex:y||T===0?-1:0,"data-orientation":r,...p,ref:f,style:{outline:"none",...e.style},onMouseDown:ae(e.onMouseDown,()=>{S.current=!0}),onFocus:ae(e.onFocus,A=>{const j=!S.current;if(A.target===A.currentTarget&&j&&!y){const L=new CustomEvent(va,ky);if(A.currentTarget.dispatchEvent(L),!L.defaultPrevented){const H=k().filter(K=>K.focusable),V=H.find(K=>K.active),J=H.find(K=>K.id===g),G=[V,J,...H].filter(Boolean).map(K=>K.ref.current);Xd(G,d)}}S.current=!1}),onBlur:ae(e.onBlur,()=>b(!1))})})}),Gd="RovingFocusGroupItem",Yd=h.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,c=jt(),l=s||c,d=Ay(Gd,n),p=d.currentTabStopId===l,m=Vd(n),{onFocusableItemAdd:f,onFocusableItemRemove:v,currentTabStopId:g}=d;return h.useEffect(()=>{if(r)return f(),()=>v()},[r,f,v]),u.jsx(wa.ItemSlot,{scope:n,id:l,focusable:r,active:o,children:u.jsx(he.span,{tabIndex:p?0:-1,"data-orientation":d.orientation,...a,ref:t,onMouseDown:ae(e.onMouseDown,x=>{r?d.onItemFocus(l):x.preventDefault()}),onFocus:ae(e.onFocus,()=>d.onItemFocus(l)),onKeyDown:ae(e.onKeyDown,x=>{if(x.key==="Tab"&&x.shiftKey){d.onItemShiftTab();return}if(x.target!==x.currentTarget)return;const y=Ry(x,d.orientation,d.dir);if(y!==void 0){if(x.metaKey||x.ctrlKey||x.altKey||x.shiftKey)return;x.preventDefault();let C=m().filter(k=>k.focusable).map(k=>k.ref.current);if(y==="last")C.reverse();else if(y==="prev"||y==="next"){y==="prev"&&C.reverse();const k=C.indexOf(x.currentTarget);C=d.loop?My(C,k+1):C.slice(k+1)}setTimeout(()=>Xd(C))}}),children:typeof i=="function"?i({isCurrentTabStop:p,hasTabStop:g!=null}):i})})});Yd.displayName=Gd;var jy={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function _y(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Ry(e,t,n){const r=_y(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return jy[r]}function Xd(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function My(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Oy=qd,Dy=Yd,Ly=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},_r=new WeakMap,hs=new WeakMap,ms={},ba=0,Jd=function(e){return e&&(e.host||Jd(e.parentNode))},$y=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=Jd(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},Fy=function(e,t,n,r){var o=$y(t,Array.isArray(e)?e:[e]);ms[n]||(ms[n]=new WeakMap);var s=ms[n],i=[],a=new Set,c=new Set(o),l=function(p){!p||a.has(p)||(a.add(p),l(p.parentNode))};o.forEach(l);var d=function(p){!p||c.has(p)||Array.prototype.forEach.call(p.children,function(m){if(a.has(m))d(m);else try{var f=m.getAttribute(r),v=f!==null&&f!=="false",g=(_r.get(m)||0)+1,x=(s.get(m)||0)+1;_r.set(m,g),s.set(m,x),i.push(m),g===1&&v&&hs.set(m,!0),x===1&&m.setAttribute(n,"true"),v||m.setAttribute(r,"true")}catch(y){console.error("aria-hidden: cannot operate on ",m,y)}})};return d(t),a.clear(),ba++,function(){i.forEach(function(p){var m=_r.get(p)-1,f=s.get(p)-1;_r.set(p,m),s.set(p,f),m||(hs.has(p)||p.removeAttribute(r),hs.delete(p)),f||p.removeAttribute(n)}),ba--,ba||(_r=new WeakMap,_r=new WeakMap,hs=new WeakMap,ms={})}},ya=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=Ly(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),Fy(r,o,n,"aria-hidden")):function(){return null}},Cn=function(){return Cn=Object.assign||function(t){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])}return t},Cn.apply(this,arguments)};function Zd(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n}function By(e,t,n){if(n||arguments.length===2)for(var r=0,o=t.length,s;r<o;r++)(s||!(r in t))&&(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return e.concat(s||Array.prototype.slice.call(t))}typeof SuppressedError=="function"&&SuppressedError;var gs="right-scroll-bar-position",xs="width-before-scroll-bar",zy="with-scroll-bars-hidden",Hy="--removed-body-scroll-bar-size";function Sa(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function Uy(e,t){var n=w.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var o=n.value;o!==r&&(n.value=r,n.callback(r,o))}}}})[0];return n.callback=t,n.facade}var Wy=typeof window<"u"?h.useLayoutEffect:h.useEffect,Qd=new WeakMap;function Vy(e,t){var n=Uy(null,function(r){return e.forEach(function(o){return Sa(o,r)})});return Wy(function(){var r=Qd.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||Sa(a,null)}),s.forEach(function(a){o.has(a)||Sa(a,i)})}Qd.set(n,e)},[e]),n}function Ky(e){return e}function qy(e,t){t===void 0&&(t=Ky);var n=[],r=!1,o={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(s){var i=t(s,r);return n.push(i),function(){n=n.filter(function(a){return a!==i})}},assignSyncMedium:function(s){for(r=!0;n.length;){var i=n;n=[],i.forEach(s)}n={push:function(a){return s(a)},filter:function(){return n}}},assignMedium:function(s){r=!0;var i=[];if(n.length){var a=n;n=[],a.forEach(s),i=n}var c=function(){var d=i;i=[],d.forEach(s)},l=function(){return Promise.resolve().then(c)};l(),n={push:function(d){i.push(d),l()},filter:function(d){return i=i.filter(d),n}}}};return o}function Gy(e){e===void 0&&(e={});var t=qy(null);return t.options=Cn({async:!0,ssr:!1},e),t}var ef=function(e){var t=e.sideCar,n=Zd(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return h.createElement(r,Cn({},n))};ef.isSideCarExport=!0;function Yy(e,t){return e.useMedium(t),ef}var tf=Gy(),Ca=function(){},vs=h.forwardRef(function(e,t){var n=h.useRef(null),r=h.useState({onScrollCapture:Ca,onWheelCapture:Ca,onTouchMoveCapture:Ca}),o=r[0],s=r[1],i=e.forwardProps,a=e.children,c=e.className,l=e.removeScrollBar,d=e.enabled,p=e.shards,m=e.sideCar,f=e.noRelative,v=e.noIsolation,g=e.inert,x=e.allowPinchZoom,y=e.as,b=y===void 0?"div":y,C=e.gapMode,k=Zd(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),S=m,T=Vy([n,t]),E=Cn(Cn({},k),o);return h.createElement(h.Fragment,null,d&&h.createElement(S,{sideCar:tf,removeScrollBar:l,shards:p,noRelative:f,noIsolation:v,inert:g,setCallbacks:s,allowPinchZoom:!!x,lockRef:n,gapMode:C}),i?h.cloneElement(h.Children.only(a),Cn(Cn({},E),{ref:T})):h.createElement(b,Cn({},E,{className:c,ref:T}),a))});vs.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},vs.classNames={fullWidth:xs,zeroRight:gs};var Xy=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Jy(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Xy();return t&&e.setAttribute("nonce",t),e}function Zy(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Qy(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var e0=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Jy())&&(Zy(t,n),Qy(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},t0=function(){var e=e0();return function(t,n){h.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},nf=function(){var e=t0(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},n0={left:0,top:0,right:0,gap:0},Ta=function(e){return parseInt(e||"",10)||0},r0=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],o=t[e==="padding"?"paddingRight":"marginRight"];return[Ta(n),Ta(r),Ta(o)]},o0=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return n0;var t=r0(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},s0=nf(),Rr="data-scroll-locked",i0=function(e,t,n,r){var o=e.left,s=e.top,i=e.right,a=e.gap;return n===void 0&&(n="margin"),`
|
|
37
|
+
`))>=0;){const Ne=it.slice(0,me);it=it.slice(me+2);const Ue=Ne.split(/\r?\n/),at=[];for(const Me of Ue)if(!(!Me||Me.startsWith(":"))&&Me.startsWith("data:")){const Ze=Me.slice(5);at.push(Ze.startsWith(" ")?Ze.slice(1):Ze)}const rt=at.join(`
|
|
38
|
+
`);if(!rt)continue;let wt;try{wt=JSON.parse(rt)}catch{console.debug("[use-chat] malformed SSE:",rt.slice(0,200));continue}const Pt=hu(wt)?wt.data:wt;if(!Pt){console.warn("[use-chat] dropped envelope event without payload",wt);continue}const de=Pt;It=Date.now();const Pe=de.seq;if(Pe!==void 0){if(Pe<=St){console.debug("[use-chat] drop duplicate/out-of-order event",{seq:Pe,lastProcessedSeq:St,type:de.type});continue}St>0&&Pe>St+1&&((oe=I==null?void 0:I.onGap)==null||oe.call(I,{from:St,to:Pe})),St=Pe,E.current=Pe,x(Pe)}if(de.type==="message.start"&&de.role==="assistant"){const Me=wu(de.model);H.current={messageId:de.id,lastSeq:Pe??null,lastText:""},k({id:de.id,role:"assistant",name:Me??void 0,model:de.model,createdAt:new Date().toISOString(),content:[]})}if(de.type==="checkpoint")P.current=de.checkpointId??null,$.current=de.checkpointNs??null,v(de.checkpointId??null);else if(de.type==="state_history"){L.current=de;try{const Ze=Yn(de).latest;Ze&&(P.current=Ze.checkpointId??null,$.current=Ze.checkpointNs??null,v(Ze.checkpointId??null))}catch(Me){console.warn("[use-chat] Failed to hydrate state_history payload",Me)}}try{D==null||D(de)}catch(Me){console.error("[use-chat] Error in onEvent callback:",Me,"for event:",de.type)}if(de.type==="message.delta"){k(Ze=>{const sn=H.current;if(!Ze||sn.messageId!==Ze.id)return Ze;const{newParts:N,newMeta:X,changed:re}=xu(Ze.content??[],de.delta,{lastSeq:sn.lastSeq,lastText:sn.lastText},Pe??null);return re?(H.current={...sn,lastSeq:X.lastSeq??sn.lastSeq,lastText:X.lastText??sn.lastText},{...Ze,content:N}):Ze});const Me=de.delta.filter(Ze=>Ze.type==="text").map(Ze=>Ze.text).join("");Me&&e.autoAppendAssistant!==!1&&(At.push(Me),Tt())}else if(de.type==="heartbeat"){console.debug("[use-chat] heartbeat received");try{(ae=I==null?void 0:I.onHeartbeat)==null||ae.call(I,de)}catch(Me){console.warn("[use-chat] heartbeat callback failed",Me)}}else if(ft!==null&&cancelAnimationFrame(ft),Ct(),de.type==="checkpoint")v(de.checkpointId);else if(de.type==="error"){const Me=de;if(d(Me.message),Z="error",R=Me.message,Me.error_type==="auth_error"||Me.code==="TOKEN_EXPIRED"||((Se=Me.message)==null?void 0:Se.includes("token"))||((we=Me.message)==null?void 0:we.includes("401"))||((Re=Me.message)==null?void 0:Re.includes("unauthorized"))||(($e=Me.message)==null?void 0:$e.includes("Unauthorized"))){console.error("[use-chat] Auth error detected:",Me.message);try{(Fe=I==null?void 0:I.onAuthError)==null||Fe.call(I,Me.message)}catch(sn){console.warn("[use-chat] onAuthError handler failed",sn)}U.abort()}}}}Ct(),Z===null&&!U.signal.aborted&&(Z="complete")}catch(Ie){if(Ie.name==="AbortError")Z=Z??"aborted";else{const Ke=Ie.message||String(Ie);Z="error",R=Ke,d(Ke),(Ge=I==null?void 0:I.onError)==null||Ge.call(I,Ke)}}finally{try{await ut.cancel()}catch{}finally{(Je=ut.releaseLock)==null||Je.call(ut)}ft!==null&&typeof window<"u"&&window.cancelAnimationFrame(ft),clearInterval(en)}}catch(Oe){if(Oe.name==="AbortError")Z=Z??"aborted";else{const Ve=Oe.message||String(Oe);Z="error",R=Ve,d(Ve),(vt=I==null?void 0:I.onError)==null||vt.call(I,Ve),q||((ct=I==null?void 0:I.onConnectionError)==null||ct.call(I,Ve),q=!0)}}finally{const Oe=E.current,Ve=P.current,He=$.current,Te=L.current,Ae=Z??(U.signal.aborted?"aborted":R?"error":"complete");try{(tt=I==null?void 0:I.onClosed)==null||tt.call(I,{reason:Ae,lastSeq:Oe,lastCheckpointId:Ve,lastCheckpointNs:He,lastStateHistory:Te,error:R})}catch(ut){console.warn("[use-chat] onClosed callback failed",ut)}l(!1),b(!1),S.current=null,E.current=0,x(0),A.current=null}})(),{close:()=>U.abort()}},[t,n,r,e.autoAppendAssistant]);return w.useEffect(()=>()=>{var W;T.current=!1,(W=S.current)==null||W.abort()},[]),{isStreaming:a,error:c,assistantText:p,assistantMessage:C,lastCheckpointId:f,lastSeq:g,connected:y,stream:G,stop:V,clear:_,setToken:Y}}const dw=["detail","message","error","description","title"];function Zo(e){if(!e)return null;if(typeof e=="string"){const t=e.trim();return t.length?t:null}if(Array.isArray(e)){for(const t of e){const n=Zo(t);if(n)return n}return null}if(typeof e=="object"){const t=e;for(const n of dw){const r=Zo(t[n]);if(r)return r}if("errors"in t){const n=Zo(t.errors);if(n)return n}}return null}function fw(e){if(!e)return"Request failed";const t=e.response,n=Zo(t==null?void 0:t.data);if(n)return n;if(t!=null&&t.statusText)return t.statusText;if(e instanceof Error&&e.message)return e.message;if(typeof e=="string"){const r=e.trim();if(r.length)return r}return t!=null&&t.status?`Request failed with status code ${t.status}`:"Request failed"}function bu({api:e,initialThreadId:t=null,onError:n,onThreadChange:r,onCurrentThreadDeleted:o}){const[s,i]=w.useState([]),[a,l]=w.useState(t),[c,d]=w.useState(!1),[p,m]=w.useState(null),[f,v]=w.useState([]),[g,x]=w.useState(!1),[,y]=w.useState(null),[b,C]=w.useState(null),[k,S]=w.useState(!1),T=w.useRef(a),E=w.useRef(new Map);w.useEffect(()=>{T.current=a},[a]);const A=w.useCallback(async()=>{d(!0),m(null);try{const D=await e.listThreads();i(D??[])}catch(D){const I=String(D);m(I),n==null||n(I)}finally{d(!1)}},[e,n]),P=w.useCallback(async()=>{x(!0),y(null);try{const D=await e.listSharedThreads();v(D??[])}catch(D){const I=String(D);y(I),n==null||n(I)}finally{x(!1)}},[e,n]);w.useEffect(()=>{A()},[A]),w.useEffect(()=>{P()},[P]),w.useEffect(()=>{r==null||r(a)},[a,r]);const $=w.useCallback(async D=>{try{const I=await e.createThread(D);return l(I.threadId),await A(),I.threadId}catch(I){const U=String(I);return n==null||n(U),null}},[e,n,A]),L=w.useCallback(async D=>{const I=s;i(Z=>Z.filter(R=>R.threadId!==D));const U=new AbortController;E.current.set(D,U);try{await e.deleteThread(D),T.current===D&&(l(null),o==null||o())}catch(Z){i(I);const R=String(Z);n==null||n(R)}finally{E.current.delete(D)}},[e,o,n,s]),H=w.useCallback(async(D,I)=>{try{await e.updateThread(D,I),await A()}catch(U){n==null||n(String(U))}},[e,n,A]),Y=w.useCallback(async(D,I)=>{S(!0),C("Sharing thread…");try{await e.shareThread(D,I),await P(),C("Shared successfully")}catch(U){const Z=fw(U);throw n==null||n(Z),C(`Failed to share: ${Z}`),new Error(Z)}finally{S(!1)}},[e,n,P]),_=w.useCallback(async(D,I)=>{try{await e.unshareThread(D,I),await P()}catch(U){const Z=String(U);throw n==null||n(Z),U}},[e,n,P]),V=w.useMemo(()=>({createThread:$,deleteThread:L,renameThread:H,refreshThreads:A,refreshSharedThreads:P,shareThread:Y,unshareThread:_}),[$,L,H,A,P,Y,_]),G=w.useCallback(D=>{if(!(D!=null&&D.threadId))return;const I={threadId:D.threadId,title:D.title||`Thread ${D.threadId.slice(0,8)}`,createdAt:D.createdAt||new Date().toISOString(),updatedAt:D.updatedAt||new Date().toISOString(),messageCount:D.messageCount??1};i(U=>{let Z=!1;const R=U.map(q=>q.threadId===I.threadId?(Z=!0,console.debug("[useThreadsState] thread_info: updating existing thread",I.threadId),{...q,title:I.title??q.title,updatedAt:I.updatedAt??q.updatedAt,messageCount:I.messageCount??q.messageCount}):q);return Z?R:(console.debug("[useThreadsState] thread_info: adding thread to list",I.threadId),[I,...U])})},[]),W=w.useCallback(()=>C(null),[]);return{threads:s,currentThreadId:a,currentThreadIdRef:T,setCurrentThreadId:l,isLoadingThreads:c,threadsError:p,sharedThreads:f,isLoadingSharedThreads:g,actions:V,addThreadFromEvent:G,shareInFlight:k,shareStatus:b,clearShareStatus:W}}const yu=w.createContext(null);function Su({children:e,initialThreadId:t=null,onError:n,onThreadChange:r}){const{api:o}=no(),{threads:s,currentThreadId:i,setCurrentThreadId:a,currentThreadIdRef:l,isLoadingThreads:c,threadsError:d,sharedThreads:p,isLoadingSharedThreads:m,actions:f,addThreadFromEvent:v,shareInFlight:g,shareStatus:x,clearShareStatus:y}=bu({api:o,initialThreadId:t,onError:n,onThreadChange:r}),b=w.useMemo(()=>({threads:s,currentThreadId:i,setCurrentThreadId:a,currentThreadIdRef:l,isLoading:c,error:d,sharedThreads:p,isLoadingSharedThreads:m,actions:f,shareInFlight:g,shareStatus:x,clearShareStatus:y,addThreadFromEvent:v}),[s,i,a,l,c,d,p,m,f,g,x,y,v]);return u.jsx(yu.Provider,{value:b,children:e})}function yr(){const e=w.useContext(yu);if(!e)throw new Error("useThreads must be used within a ThreadsProvider");return e}function Qn(e){const t=e==null?void 0:e.trim();if(!t||!(t.startsWith("{")||t.startsWith("[")))return null;try{return JSON.parse(t)}catch{const n=pw(t);if(n)try{return JSON.parse(n)}catch{return null}return null}}function pw(e){let t=!1,n="";for(const o of e){if(o==="\\"){n+=o,t=!t;continue}if(o==="'"&&!t){n+='"';continue}n+=o,t=!1}return n.replace(/\bTrue\b/g,"true").replace(/\bFalse\b/g,"false").replace(/\bNone\b/g,"null")}function zi(e){return!!(e&&typeof e=="object"&&(e.type==="file"||e.mimeType||e.filename||e.sourceType==="base64"))}function Sr(e){if(typeof e=="string")return e;if(e&&typeof e=="object"){if(Array.isArray(e)){const n=e.map(Sr).filter(r=>r!==void 0);if(!n.length){console.debug("[message-utils] sanitizeForDisplay - array emptied -> returning undefined",{originalLength:e.length});return}return n}if(zi(e)){try{console.debug("[message-utils] sanitizeForDisplay - dropping file-like object",{sampleFilename:e&&(e.filename||e.name)?e.filename||e.name:void 0,keys:Object.keys(e||{})})}catch(n){console.debug("[message-utils] sanitizeForDisplay - dropped file-like (unable to inspect)",{err:String(n)})}return}const t={};for(const n of Object.keys(e)){const r=e[n];if(n==="data"&&typeof r=="string"&&r.length>100)t[n]=`[base64 ${r.length} chars omitted]`;else{const o=Sr(r);o!==void 0&&(t[n]=o)}}if(Object.keys(t).length)return t;try{console.debug("[message-utils] sanitizeForDisplay - object emptied -> returning undefined",{originalKeys:Object.keys(e||{})})}catch(n){console.debug("[message-utils] sanitizeForDisplay - object emptied -> returning undefined (inspect failed)",{err:String(n)})}return}return e}function er(e){if(typeof e=="string")return e;if(zi(e))return"";try{const t=Sr(e);return t===void 0?"":typeof t=="string"?t:JSON.stringify(t,null,2)}catch{return""}}function Cu(e){return typeof e!="string"?!1:/^[\s\n]*[-*]\s|^[\s\n]*#+\s|```|^\s*\[.*\]\(|^>\s/.test(e)}function Tu(e){const t=er(e);return typeof e=="string"&&Cu(e)?{content:e,isMarkdown:!0}:{content:t,isMarkdown:!1}}function tr(e){if(e==null)return e;if(typeof e=="string"){const t=e.trim();if(t.startsWith("{")||t.startsWith("[")){const n=Qn(t);if(n!==null)return tr(n)}return e}return typeof e=="object"&&!Array.isArray(e)&&e.content!==void 0?tr(e.content):e}function ku(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function Qo(e){const t=e.content.find(s=>s.type==="tool_call"),n=e.additionalKwargs??{},r=typeof(t==null?void 0:t.id)=="string"&&t.id||typeof n.toolCallId=="string"&&n.toolCallId||(e.id.startsWith("tool-")?e.id.slice(5):void 0);return{name:(typeof(t==null?void 0:t.name)=="string"&&t.name||typeof n.toolName=="string"&&n.toolName||e.name&&String(e.name))??void 0,toolCallId:r??void 0}}function Hi(e){if(e==null)return null;const t=String(e).trim();return t.length>0?t:null}function Eu(e){const t=r=>{try{const o=Sr(r);return typeof o=="string"?o:JSON.stringify(o??"")}catch{return""}},n=e.filter(r=>r.type==="text");return n.length?t(n.map(r=>r.text).join(`
|
|
39
|
+
`)):t(e)}function Iu(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function Ui(e){if(e.role==="default_message")return`default:${e.content.length}`;const t=e.updatedAt??e.createdAt??"",n=Array.isArray(e.content)?e.content.map(i=>{switch(i.type){case"text":return`t:${i.text.length}`;case"image_url":return"img";case"file":return"file";case"tool_call":return"call";case"interrupt":return"interrupt";default:return"unknown"}}).join("|"):"",r="checkpointId"in e&&e.checkpointId?`cp:${e.checkpointId}`:"",o="checkpointNs"in e&&e.checkpointNs?`ns:${e.checkpointNs}`:"",s=[r,o].filter(Boolean).join("|");return`${e.id}:${t}:${n}${s?`:${s}`:""}`}function Nu(e){if(!e)return"image/png";const t=e.trim();return t?t.includes("/")?t:`image/${t}`:"image/png"}function Au(e){const t=[],n=r=>{r&&r.trim()&&t.push(r.trim())};return e&&(n(e.plotId),n(e.artifactId)),t}function Pu({base64:e,url:t,formatHint:n,extras:r}){const o=typeof e=="string"&&e.length>0,s=Nu(n),i=o?`data:${s};base64,${e}`:t,a=Au(r),l=a.length?a.join(" / "):void 0,c=l?`${l} artifact`:"artifact image";return{src:i,alt:c,label:l}}function ju(e){var o,s;const t=((o=e.content_base64)==null?void 0:o.trim())||void 0,n=((s=e.url)==null?void 0:s.trim())||void 0,r=e.format||e.mimeType||e.mime_type;return Pu({base64:t,url:n,formatHint:r,extras:{plotId:e.plotId,artifactId:e.artifactId}})}function Wi(e){var n;const t=(n=e.additionalKwargs)==null?void 0:n.toolProgress;return Array.isArray(t)?t:[]}function Cr(e){if(e==null)return e;if(typeof e=="string"){const t=e.trim(),n=Qn(t);return n!==null?Cr(n):t}if(Array.isArray(e))return e.map(t=>Cr(t));if(typeof e=="object"){const t=e.value;if(t!==void 0)return Cr(t)}return e}function _u(e){const t=Cr(e.value);return t===e.value?e:{...e,value:t}}const hw={messages:[],assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,messagesStreamMeta:{},pendingInterrupt:null};function mw(e,t){var n;switch(t.type){case"reset":return{messages:Bi(((n=t.payload)==null?void 0:n.messages)??[]),assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,pendingInterrupt:null,messagesStreamMeta:{}};case"user_message":{const{message:r,editingMessageId:o}=t.payload;if(o){const s=e.messages.findIndex(i=>i.id===o);if(s>=0){const i=e.messages.slice(0,s);return{...e,messages:[...i,r]}}}return{...e,messages:[...e.messages,r]}}case"seed":{const r=Bi(t.payload.messages),o={...e,messages:r,assemblingId:null,pendingInterrupt:t.payload.pendingInterrupt??null};return Object.prototype.hasOwnProperty.call(t.payload,"checkpointId")&&(o.lastCheckpointId=t.payload.checkpointId??null),Object.prototype.hasOwnProperty.call(t.payload,"checkpointNs")&&(o.lastCheckpointNs=t.payload.checkpointNs??null),o}case"prepend":{const r=Bi(t.payload.messages);if(!r.length)return e;const o=new Set(e.messages.map(a=>a.id)),s=r.filter(a=>!o.has(a.id));if(!s.length)return e;const i=[...s,...e.messages];return{...e,messages:i}}case"event":return Ru(e,t.payload.ev);case"batch":{const{events:r}=t.payload;return r.length?r.reduce((o,s)=>Ru(o,s),e):e}default:return e}}function gw(e=[]){const[t,n]=w.useReducer(mw,{...hw,messages:e}),r=w.useRef([]),o=w.useRef(null),s=w.useRef(null),i=w.useCallback(()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),o.current=null,s.current=null;const d=r.current;d.length&&(r.current=[],n({type:"batch",payload:{events:d}}))},[]),a=w.useCallback(()=>{typeof window<"u"&&typeof window.requestAnimationFrame=="function"?o.current===null&&(o.current=window.requestAnimationFrame(()=>i())):s.current===null&&(s.current=setTimeout(i,8))},[i]),l=w.useCallback(d=>{r.current.push(d),a()},[a]);w.useEffect(()=>()=>{o.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(o.current),s.current!==null&&clearTimeout(s.current),r.current=[]},[]);const c=w.useMemo(()=>({reset:d=>n({type:"reset",payload:{messages:d}}),seed:(d,p)=>n({type:"seed",payload:{messages:d,...p??{}}}),prepend:d=>n({type:"prepend",payload:{messages:d}}),pushUser:(d,p)=>n({type:"user_message",payload:{message:d,editingMessageId:p}}),onEvent:l}),[l]);return{state:t,dispatch:n,...c}}function Ru(e,t){var n,r,o;if(t.type==="message.start"&&t.role==="assistant"){const s=t.id,i=wu(t.model);if(e.messages.some(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 vw(e,t);if(t.type==="tool.progress")return ww(e,t);if(t.type==="tool.end")return bw(e,t);if(t.type==="message.delta"){const s=e.assemblingId??mu(e.messages);if(!s)return e;const i=e.messages,a=i.findIndex(S=>S.id===s&&S.role==="assistant");if(a===-1)return e;const l=i[a],c=e.messagesStreamMeta,d=c??{},p=d[s],m=p??{lastSeq:null,lastText:gu(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}=xu(l.content,t.delta,m,f);if(!x)return e;const y={...l,content:v},b=ro(i,a,y),C=!p||p.lastSeq!==g.lastSeq||p.lastText!==g.lastText,k=C?{...d,[s]:g}:c;return C?{...e,messages:b,messagesStreamMeta:k}:{...e,messages:b}}if(t.type==="message.end"){const s=e.assemblingId??mu(e.messages);if(!s)return{...e,assemblingId:null};const i=e.messages,a=i.findIndex(l=>l.id===s&&l.role==="assistant");if(a>=0){const l=i[a];if(!((n=l.content)==null?void 0:n.some(d=>{var p;return(d==null?void 0:d.type)==="text"&&((p=d.text)==null?void 0:p.trim())}))){console.debug("[MessageReducer] pruning assistant message with no visible text",{id:l.id,contentTypes:(r=l.content)==null?void 0:r.map(p=>p==null?void 0:p.type),contentPreview:(o=l.content)==null?void 0:o.map(p=>(p==null?void 0:p.type)==="text"?String(p.text).slice(0,100):p==null?void 0:p.type)});const d=[...i.slice(0,a),...i.slice(a+1)];return{...e,assemblingId:null,messages:d}}}return e}if(t.type==="checkpoint"){const s=t.checkpointNs??e.lastCheckpointNs??null,i=cw(e.messages,t.checkpointId,s);return{...e,lastCheckpointId:t.checkpointId,lastCheckpointNs:s,messages:i}}if(t.type==="error"){const s={id:`err-${Date.now()}`,role:"system",content:[{type:"text",text:`Error: ${t.message}`}],createdAt:new Date().toISOString()};return{...e,messages:[...e.messages,s]}}if(t.type==="state_history"){const s=Yn(t),i=s.interrupt,a=s.latest,l=i===null?aw(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 Vi(e){return e.call_id??e.id??null}function Mu(e){return e.id??e.call_id??`tool-${Date.now()}-${Math.random().toString(16).slice(2)}`}function Ou(e,t,n,r){const o=t??`call-${Date.now()}-${Math.random().toString(16).slice(2)}`;return{id:e,role:"tool",name:n??void 0,content:[{type:"tool_call",id:o,name:n??"tool",args:r??{}}],createdAt:new Date().toISOString(),additionalKwargs:{toolCallId:o,toolName:n??void 0,toolStreaming:!0,toolProgress:[]}}}function Ki(e,t){if(!t)return-1;for(let n=0;n<e.length;n+=1){const r=e[n];if(r.role!=="tool")continue;const o=r.additionalKwargs??{};if(typeof o.toolCallId=="string"&&o.toolCallId===t||Qo(r).toolCallId===t)return n}return-1}function xw(e){if(e==null)return[];const t=tr(e);if(typeof t=="string"&&t.trim())return[{type:"text",text:t}];const n=er(t??e);return n?[{type:"text",text:n}]:[]}function Du(e,t){const n=e.additionalKwargs??{},r=Array.isArray(n.toolProgress)?[...n.toolProgress]:[],o={...n,toolProgress:[...r,t]};return{...e,additionalKwargs:o}}function vw(e,t){const n=Vi(t),r=Ki(e.messages,n),o=t.name??t.tool??void 0,s=Mu(t);if(r>=0){const a=e.messages[r],c={...a.additionalKwargs??{},toolStreaming:!0,toolProgress:[]},d={...a,name:o??a.name,additionalKwargs:c};return{...e,messages:ro(e.messages,r,d)}}const i=Ou(s,n,o,t.args);return{...e,messages:[...e.messages,i]}}function ww(e,t){const n=Vi(t);if(!n)return e;const r=Ki(e.messages,n);if(r===-1)return e;const o={type:t.type,content:typeof t.content=="string"?t.content:void 0,seq:t.seq??null,timestamp:new Date().toISOString()},s=t.metadata;s&&(o.metadata=s);const i=t.idx;typeof i=="number"&&(o.idx=i);const a=Du(e.messages[r],o);return{...e,messages:ro(e.messages,r,a)}}function bw(e,t){const n=Vi(t),r=Mu(t);let o=e.messages,s=Ki(o,n);if(s===-1){const v=t.name??t.tool??void 0;o=[...o,Ou(r,n,v,{})],s=o.length-1}const i=o[s],a=t.output??t.error??null,l=xw(a),c=[...i.content,...l],d={type:t.type,content:typeof t.output=="string"?t.output:void 0,seq:t.seq??null,timestamp:new Date().toISOString()};t.artifact&&(d.artifact=t.artifact);const p=Du(i,d),m=t.artifact??i.artifact,f={...p,name:t.name??t.tool??i.name,content:c,artifact:m,additionalKwargs:{...p.additionalKwargs??{},toolStreaming:!1}};return{...e,messages:ro(o,s,f)}}function Lu({api:e,seed:t,onError:n,currentThreadId:r,initialThreadId:o=null,initialCheckpointId:s=null,initialCheckpointNs:i=null,autoLoadInitial:a=!0,isStreaming:l,getMessages:c}){const[d,p]=w.useState(null),f=w.useMemo(()=>Yn(d),[d]).checkpoints,v=uc(f),g=v.timeline,[x,y]=w.useState(!1),[b,C]=w.useState(!1),[k,S]=w.useState(null),T=w.useRef(r),E=w.useRef(null),A=w.useRef(null),P=w.useRef(null),$=w.useRef(null),L=w.useRef(null),H=w.useRef(new Map),Y=w.useRef(null);w.useEffect(()=>{T.current=r},[r]);const _=w.useCallback(async j=>{var Q,M;if(!j.threadId)return;const B=j.threadId;(Q=j.onStart)==null||Q.call(j),j.setLoading(!0);try{await j.action(B)}catch(O){if(!eu(O)&&T.current===B){const J=String(O);(M=j.handleError)==null||M.call(j,J),n==null||n(J)}throw O}finally{j.setLoading(!1)}},[n]),V=w.useCallback(async(j,B)=>{var J;if(!j)return;const Q=`${j}:${B??"latest"}`,M=H.current.get(Q);if(M)return M;(J=Y.current)==null||J.abort();const O=new AbortController;Y.current=O;const F=_({threadId:j,setLoading:y,onStart:()=>S(null),handleError:oe=>S(oe),action:async oe=>{const ae=await e.getStateHistory({threadId:oe,checkpointId:B??void 0,signal:O.signal});if(T.current!==oe){console.log(`[useThreadHistoryState] Thread changed during load (was ${oe}, now ${T.current}), discarding stale data`);return}const{checkpoints:Se}=Yn(ae),we=Se.find(Re=>Re.messages&&Re.messages.length>0)??(B?Se.find(Re=>Re.checkpointId===B):null)??Se[0];t((we==null?void 0:we.messages)??[],{checkpointId:(we==null?void 0:we.checkpointId)??null,checkpointNs:(we==null?void 0:we.checkpointNs)??null,pendingInterrupt:(we==null?void 0:we.interrupt)??null}),p(ae)}});H.current.set(Q,F);try{await F}finally{H.current.delete(Q),Y.current===O&&(Y.current=null)}return T.current===j&&(L.current=Q),F},[e,t,_]),G=w.useCallback(async(j,B)=>{$.current=j;try{await V(j,B)}catch(Q){if(!eu(Q))throw Q}finally{$.current===j&&($.current=null)}},[V]),W=w.useCallback(j=>{A.current=j},[]),D=w.useCallback(j=>{P.current=j},[]),I=w.useCallback(j=>{const B=j.threadId??T.current;if(!B||T.current&&T.current!==B)return;const{checkpoints:Q}=Yn(j);if(!Q.length)return;const M=Q.find(F=>F.messages&&F.messages.length>0)??Q.find(F=>!!F.checkpointId)??Q[0],O=P.current===B;!l&&!O&&t((M==null?void 0:M.messages)??[],{checkpointId:(M==null?void 0:M.checkpointId)??null,checkpointNs:(M==null?void 0:M.checkpointNs)??null,pendingInterrupt:(M==null?void 0:M.interrupt)??null}),p(j),L.current=`${B}:latest`,A.current=null,P.current===B&&(P.current=null)},[t,l]),U=w.useCallback(async(j,B)=>{const Q=T.current;await _({threadId:Q,setLoading:C,action:async M=>{const O=await e.getStateHistory({threadId:M,checkpointId:j,checkpointNs:B??void 0});if(T.current!==M)return;const{checkpoints:F}=Yn(O),J=F.find(oe=>oe.checkpointId===j&&(B?oe.checkpointNs===B:!0));if(!J){console.warn("[useThreadHistoryState] Requested checkpoint not found:",{checkpointId:j,checkpointNs:B});return}p(O),t(J.messages??[],{checkpointId:J.checkpointId??null,checkpointNs:J.checkpointNs??null})}}).catch(()=>{})},[e,t,_]),Z=w.useCallback((j,B)=>{t(c(),{checkpointId:j??null,checkpointNs:B??null})},[c,t]),R=w.useCallback(async()=>{T.current&&await G(T.current)},[G]);w.useEffect(()=>{if(!a||!r||x||l)return;if(A.current===r){A.current=null,E.current=r;return}if(P.current===r){E.current=r;return}if($.current===r){$.current=null,E.current=r;return}if(E.current===r)return;E.current=r;let j;const B=`${r}:latest`;L.current!==B&&G(r,j)},[a,r,s,i,o,x,l,G]);const q=w.useCallback(()=>{p(null),y(!1),C(!1),S(null),A.current=null,P.current=null,E.current=null,L.current=null,$.current=null},[]);return{threadCheckpoints:f,threadTimeline:g,checkpointIndex:v,isLoadingThread:x,isLoadingCheckpoint:b,threadStateError:k,loadThread:G,navigateToCheckpoint:U,setCurrentCheckpointId:Z,returnToLatest:R,handleStateHistoryEvent:I,markSkipNextLoad:W,markStreamPendingThread:D,resetHistoryState:q}}const $u=w.createContext(null),Fu=w.createContext(null);function oo(){const e=w.useContext($u);if(!e)throw new Error("useThreadState must be used within a ThreadStateProvider");return e}function Bu(){const e=w.useContext(Fu);if(!e)throw new Error("useThreadStateUpdater must be used within a ThreadStateProvider");return e}function zu({children:e,initialThreadId:t=null,initialCheckpointId:n=null,initialCheckpointNs:r=null,autoLoadInitial:o=!0,isStreaming:s,onError:i}){const{api:a}=no(),{currentThreadId:l}=yr(),{state:c,seed:d,pushUser:p,onEvent:m}=gw(),{threadCheckpoints:f,threadTimeline:v,checkpointIndex:g,isLoadingThread:x,isLoadingCheckpoint:y,threadStateError:b,loadThread:C,navigateToCheckpoint:k,setCurrentCheckpointId:S,returnToLatest:T,handleStateHistoryEvent:E,markSkipNextLoad:A,markStreamPendingThread:P,resetHistoryState:$}=Lu({api:a,seed:d,onError:i,currentThreadId:l,initialThreadId:t,initialCheckpointId:n,initialCheckpointNs:r,autoLoadInitial:o,isStreaming:s,getMessages:w.useCallback(()=>c.messages,[c.messages])}),[L,H]=w.useState(()=>async()=>{throw new Error("clearThread is not ready")}),[Y,_]=w.useState(()=>async()=>{throw new Error("respondToInterrupt is not ready")});w.useEffect(()=>{l||(d([],{}),$())},[l,d,$]);const V=w.useCallback(U=>H(()=>U),[]),G=w.useCallback(U=>_(()=>U),[]),W=w.useMemo(()=>({assemblingMessageId:c.assemblingId??null}),[c.assemblingId]),D=w.useMemo(()=>({threadId:l,messages:c.messages,interrupt:c.pendingInterrupt,checkpoint:{id:c.lastCheckpointId??null,namespace:c.lastCheckpointNs??null},checkpoints:f,checkpointIndex:g,timelineCheckpoints:v,metadata:W,isLoading:x,isLoadingCheckpoint:y,error:b,clearState:L,navigateToCheckpoint:k,setCurrentCheckpointId:S,returnToLatest:T,loadThread:C,clearThread:L,respondToInterrupt:Y,messagePreviews:g.messagePreviews,handleStateHistoryEvent:E,markSkipNextLoad:A,markStreamPendingThread:P,resetHistoryState:$,pushUser:p,onEvent:m}),[l,c,f,v,g,W,x,y,b,L,k,S,T,C,Y,g.messagePreviews,E,A,P,$,p,m]),I=w.useMemo(()=>({registerClearThread:V,registerRespondToInterrupt:G}),[V,G]);return u.jsx(Fu.Provider,{value:I,children:u.jsx($u.Provider,{value:D,children:e})})}function Hu(e,t){if(!e)return null;const n=_n(e);if(!n)return null;const r=_n(n.configurable)??n;return Rn(r,t)??null}function yw(e){const t=Hu(e,["checkpoint_id","checkpointId"]);if(!t)return null;const n=Hu(e,["checkpoint_ns","checkpointNs"]);return{checkpointId:t,checkpointNs:n}}function Sw(e,t){const n=typeof e.step=="number"?e.step:Number.POSITIVE_INFINITY,r=typeof t.step=="number"?t.step:Number.POSITIVE_INFINITY;if(n!==r)return n-r;const o=e.createdAt?Date.parse(e.createdAt):0,s=t.createdAt?Date.parse(t.createdAt):0;return o-s}function Cw(e,t){const n=[...e].sort(Sw);for(const r of n){if(r.messageId!==t)continue;const o=yw(r.parentConfig);if(!o)throw new Error(`Parent checkpoint info missing for message ${t}`);return o}throw new Error(`Message ${t} not found in timeline`)}const Uu=w.createContext(null),Wu=w.createContext(!1);function Tw({children:e,initialThreadId:t=null,initialCheckpointId:n=null,initialCheckpointNs:r=null,autoLoadInitial:o=!0,onError:s,onAuthError:i,onThreadChange:a,onConnectionError:l,onToolEnd:c}){const{api:d,baseUrl:p}=no(),m=w.useMemo(()=>vn(p),[p]),{stream:f,stop:v,isStreaming:g,error:x,setToken:y}=uw({baseUrl:m}),[b,C]=w.useState(!1);return w.useEffect(()=>{C(g)},[g]),u.jsx(Su,{initialThreadId:t,onError:s,onThreadChange:a,children:u.jsx(zu,{initialThreadId:t,initialCheckpointId:n,initialCheckpointNs:r,autoLoadInitial:o,onError:s,isStreaming:b,children:u.jsx(Wu.Provider,{value:!0,children:u.jsx(kw,{api:d,streamApi:{stream:f,stop:v,isStreaming:g,error:x,setToken:y},onError:s,onAuthError:i,onConnectionError:l,onToolEnd:c,children:e})})})})}function kw({children:e,api:t,streamApi:n,onError:r,onAuthError:o,onConnectionError:s,onToolEnd:i}){const{stream:a,stop:l,isStreaming:c,error:d,setToken:p}=n,{setCurrentThreadId:m,currentThreadIdRef:f,addThreadFromEvent:v}=yr(),{checkpoint:g,timelineCheckpoints:x,handleStateHistoryEvent:y,markSkipNextLoad:b,markStreamPendingThread:C,resetHistoryState:k,pushUser:S,onEvent:T}=oo(),{registerClearThread:E,registerRespondToInterrupt:A}=Bu(),P=w.useCallback(W=>{v(W),f.current!==W.threadId&&((W.created??!f.current)&&b(W.threadId),C(W.threadId),m(W.threadId))},[v,b,C,m,f]),$=w.useCallback(W=>{W.type==="thread_info"?P(W):W.type==="state_history"?y(W):W.type==="tool.end"?i==null||i(W):T(W)},[P,y,T,i]),L=w.useCallback(W=>{a(W,$,{onError:D=>{console.error("[StreamingProvider] Stream error:",D),r==null||r(D)},onAuthError:D=>{console.error("[StreamingProvider] Auth error:",D),o==null||o(D)},onConnectionError:D=>{console.error("[StreamingProvider] Connection error:",D),s==null||s(D)}})},[a,$,r,o,s]),H=w.useRef(g);w.useEffect(()=>{H.current=g},[g]);const Y=w.useCallback(async(W,D,I)=>{const U=f.current;if(!U)throw new Error("No active thread to handle interrupt");const Z=W?D??!0:!1,R=H.current,q={threadId:U,checkpointId:R.id??void 0,checkpointNs:R.namespace??void 0,command:{kind:"resume",value:Z},payload:I==null?void 0:I.payload,config:I==null?void 0:I.config,nodeFilter:I==null?void 0:I.nodeFilter,branchLabel:I==null?void 0:I.branchLabel,active_agent:I==null?void 0:I.active_agent,timelineCheckpoints:I==null?void 0:I.timelineCheckpoints};L(q)},[f,L]);w.useEffect(()=>{A(Y)},[Y,A]);const _=w.useCallback(async()=>{l(),k(),m(null)},[k,m,l]);w.useEffect(()=>{E(_)},[_,E]);const V=w.useCallback(async(W,D)=>{let I=f.current;const U=(W==null?void 0:W.text)??"",Z=(W==null?void 0:W.attachments)??[],R=(U==null?void 0:U.trim())??"",q={...(W==null?void 0:W.payload)??{}},j=Array.isArray(q.messages)?q.messages:void 0;j&&delete q.messages;const B=!!(j&&j.length);if(!I&&!R&&Z.length===0&&!B)return;if(!I){const Ge=Math.floor(Date.now()/1e3).toString(16).padStart(8,"0"),Je=Array.from({length:4},()=>Math.floor(Math.random()*4294967295).toString(16).padStart(8,"0")).join("").slice(0,16);I=`${Ge}${Je}`,b(I),m(I)}const{contentParts:Q,filesInfo:M}=await pu(Z),O=[...Q];R&&O.push({type:"text",text:U});const F=D==null?void 0:D.originalMessageId,J=!!(D!=null&&D.edit&&F),oe=!B&&O.length>0;let ae=null;oe&&(ae={id:J?F:`msg-${Date.now()}`,role:"user",content:O,createdAt:new Date().toISOString()},J?S(ae,F):S(ae));const Se=B?j:ae?[ae]:[],we={...q,...M.length?{files_info:M}:{}};Se.length?we.messages=Se:"messages"in we||(we.messages=[]);let Re=(D==null?void 0:D.checkpointId)??g.id??void 0,$e=(D==null?void 0:D.checkpointNs)??g.namespace??void 0;if(J&&F){const Ge=Cw(x,F);Re=Ge.checkpointId,$e=Ge.checkpointNs??void 0}const Fe={threadId:I,payload:we,checkpointId:Re,checkpointNs:$e,edit:!!(D!=null&&D.edit)};L(Fe)},[g,f,b,S,L,x]),G=w.useMemo(()=>({isStreaming:c,error:d,connectionState:c?"connected":"idle",submit:V,send:V,stop:l,setAuthToken:p}),[c,d,V,l,p]);return u.jsx(Uu.Provider,{value:G,children:e})}function qi(){const e=w.useContext(Uu);if(!e)throw new Error("useStream must be used within StreamingProvider");return e}function Ew(){return w.useContext(Wu)}function Vu(e){return typeof e=="object"&&e!==null}function Iw(e,t){if(Object.is(e,t))return!0;if(!Vu(e)||!Vu(t))return!1;const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const o of n)if(!Object.prototype.hasOwnProperty.call(t,o)||!Object.is(e[o],t[o]))return!1;return!0}function Ku(e){const t=w.useRef(e),n=w.useRef(e);return Iw(t.current,e)||(t.current=e,n.current=e),n.current}function Tr({children:e,apiConfig:t,initialThreadId:n=null,initialCheckpointId:r=null,initialCheckpointNs:o=null,autoLoadInitial:s=!0,onConnectionError:i,onError:a,onAuthError:l,onThreadChange:c,onToolEnd:d}){const p=Ku(t),m=so(a),f=so(l),v=so(i),g=so(c),x=so(d),y=w.useMemo(()=>({initialThreadId:n,initialCheckpointId:r,initialCheckpointNs:o,autoLoadInitial:s,onError:m,onAuthError:f,onConnectionError:v,onThreadChange:g,onToolEnd:x}),[n,r,o,s,m,f,v,g,x]);return u.jsx(du,{apiConfig:p,children:u.jsx(Tw,{...y,children:e})})}function so(e){const t=w.useRef(e);return w.useEffect(()=>{t.current=e},[e]),w.useCallback((...n)=>{const r=t.current;if(r)return r(...n)},[])}function kr(e){if(!(typeof globalThis>"u"))return globalThis[e]}function Nw(e){if(typeof e!="string")return;const t=e.trim();if(t)return vn(t)}function qu(){const e=[kr("__API_BASE_URL__"),kr("__CHAT_API_BASE_URL__"),kr("__CHAT_API_URL__")];for(const t of e){const n=Nw(t);if(n)return n}}function Gu(){const e=[kr("__API_AUTH_TOKEN__"),kr("__CHAT_API_KEY__"),kr("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function Yu(...e){for(const t of e)if(typeof t=="string"&&t.trim())return vn(t);return vn()}function Xu(){const e={},t=qu(),n=Gu();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function Ju(){const e=Xu(),t=Nn.getAuthToken(),n=qu();return{apiBaseUrl:Yu(e.baseUrl,Nn.baseUrl,n),apiKey:t||e.apiKey||Gu()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,darkMode:!1,enableSound:!1,messageHistory:100}}const Gi="chat-settings";function Zu(){try{const e=localStorage.getItem(Gi);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function Qu(e){try{const t={...e,apiBaseUrl:vn(e.apiBaseUrl)};localStorage.setItem(Gi,JSON.stringify(t)),t.apiKey&&Nn.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function Aw(){const e=Ju(),t=Zu(),n=Nn.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:Yu(Nn.baseUrl,r,e.apiBaseUrl)}}function Pw(e){Nn.updateConfig({baseUrl:e.apiBaseUrl,authToken:e.apiKey??void 0}),Qu(e)}function ne(...e){return bx.twMerge(wx.clsx(e))}const jw=Kr.cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),Ye=h.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?qt.Slot:"button";return u.jsx(i,{className:ne(jw({variant:t,size:n,className:e})),ref:s,...o})});Ye.displayName="Button";function ie(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}function ed(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Mn(...e){return t=>{let n=!1;const r=e.map(o=>{const s=ed(o,t);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let o=0;o<r.length;o++){const s=r[o];typeof s=="function"?s():ed(e[o],null)}}}}function je(...e){return h.useCallback(Mn(...e),e)}function _w(e,t){const n=h.createContext(t),r=s=>{const{children:i,...a}=s,l=h.useMemo(()=>a,Object.values(a));return u.jsx(n.Provider,{value:l,children:i})};r.displayName=e+"Provider";function o(s){const i=h.useContext(n);if(i)return i;if(t!==void 0)return t;throw new Error(`\`${s}\` must be used within \`${e}\``)}return[r,o]}function cn(e,t=[]){let n=[];function r(s,i){const a=h.createContext(i),l=n.length;n=[...n,i];const c=p=>{var y;const{scope:m,children:f,...v}=p,g=((y=m==null?void 0:m[e])==null?void 0:y[l])||a,x=h.useMemo(()=>v,Object.values(v));return u.jsx(g.Provider,{value:x,children:f})};c.displayName=s+"Provider";function d(p,m){var g;const f=((g=m==null?void 0:m[e])==null?void 0:g[l])||a,v=h.useContext(f);if(v)return v;if(i!==void 0)return i;throw new Error(`\`${p}\` must be used within \`${s}\``)}return[c,d]}const o=()=>{const s=n.map(i=>h.createContext(i));return function(a){const l=(a==null?void 0:a[e])||s;return h.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return o.scopeName=e,[r,Rw(o,...t)]}function Rw(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(s){const i=r.reduce((a,{useScope:l,scopeName:c})=>{const p=l(s)[`__scope${c}`];return{...a,...p}},{});return h.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var Et=globalThis!=null&&globalThis.document?h.useLayoutEffect:()=>{},Mw=h[" useInsertionEffect ".trim().toString()]||Et;function On({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=Ow({defaultProp:t,onChange:n}),a=e!==void 0,l=a?e:o;{const d=h.useRef(e!==void 0);h.useEffect(()=>{const p=d.current;p!==a&&console.warn(`${r} is changing from ${p?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),d.current=a},[a,r])}const c=h.useCallback(d=>{var p;if(a){const m=Dw(d)?d(e):d;m!==e&&((p=i.current)==null||p.call(i,m))}else s(d)},[a,e,s,i]);return[l,c]}function Ow({defaultProp:e,onChange:t}){const[n,r]=h.useState(e),o=h.useRef(n),s=h.useRef(t);return Mw(()=>{s.current=t},[t]),h.useEffect(()=>{var i;o.current!==n&&((i=s.current)==null||i.call(s,n),o.current=n)},[n,o]),[n,r,s]}function Dw(e){return typeof e=="function"}var Lw=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],pe=Lw.reduce((e,t)=>{const n=qt.createSlot(`Primitive.${t}`),r=h.forwardRef((o,s)=>{const{asChild:i,...a}=o,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 Yi(e,t){e&&qr.flushSync(()=>e.dispatchEvent(t))}function es(e){const t=e+"CollectionProvider",[n,r]=cn(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=g=>{const{scope:x,children:y}=g,b=w.useRef(null),C=w.useRef(new Map).current;return u.jsx(o,{scope:x,itemMap:C,collectionRef:b,children:y})};i.displayName=t;const a=e+"CollectionSlot",l=qt.createSlot(a),c=w.forwardRef((g,x)=>{const{scope:y,children:b}=g,C=s(a,y),k=je(x,C.collectionRef);return u.jsx(l,{ref:k,children:b})});c.displayName=a;const d=e+"CollectionItemSlot",p="data-radix-collection-item",m=qt.createSlot(d),f=w.forwardRef((g,x)=>{const{scope:y,children:b,...C}=g,k=w.useRef(null),S=je(x,k),T=s(d,y);return w.useEffect(()=>(T.itemMap.set(k,{ref:k,...C}),()=>void T.itemMap.delete(k))),u.jsx(m,{[p]:"",ref:S,children:b})});f.displayName=d;function v(g){const x=s(e+"CollectionConsumer",g);return w.useCallback(()=>{const b=x.collectionRef.current;if(!b)return[];const C=Array.from(b.querySelectorAll(`[${p}]`));return Array.from(x.itemMap.values()).sort((T,E)=>C.indexOf(T.ref.current)-C.indexOf(E.ref.current))},[x.collectionRef,x.itemMap])}return[{Provider:i,Slot:c,ItemSlot:f},v,r]}var $w=h.createContext(void 0);function ts(e){const t=h.useContext($w);return e||t||"ltr"}function ht(e){const t=h.useRef(e);return h.useEffect(()=>{t.current=e}),h.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function Fw(e,t=globalThis==null?void 0:globalThis.document){const n=ht(e);h.useEffect(()=>{const r=o=>{o.key==="Escape"&&n(o)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var Bw="DismissableLayer",Xi="dismissableLayer.update",zw="dismissableLayer.pointerDownOutside",Hw="dismissableLayer.focusOutside",td,nd=h.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Er=h.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...l}=e,c=h.useContext(nd),[d,p]=h.useState(null),m=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,f]=h.useState({}),v=je(t,E=>p(E)),g=Array.from(c.layers),[x]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),y=g.indexOf(x),b=d?g.indexOf(d):-1,C=c.layersWithOutsidePointerEventsDisabled.size>0,k=b>=y,S=Ww(E=>{const A=E.target,P=[...c.branches].some($=>$.contains(A));!k||P||(o==null||o(E),i==null||i(E),E.defaultPrevented||a==null||a())},m),T=Vw(E=>{const A=E.target;[...c.branches].some($=>$.contains(A))||(s==null||s(E),i==null||i(E),E.defaultPrevented||a==null||a())},m);return Fw(E=>{b===c.layers.size-1&&(r==null||r(E),!E.defaultPrevented&&a&&(E.preventDefault(),a()))},m),h.useEffect(()=>{if(d)return n&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(td=m.body.style.pointerEvents,m.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(d)),c.layers.add(d),od(),()=>{n&&c.layersWithOutsidePointerEventsDisabled.size===1&&(m.body.style.pointerEvents=td)}},[d,m,n,c]),h.useEffect(()=>()=>{d&&(c.layers.delete(d),c.layersWithOutsidePointerEventsDisabled.delete(d),od())},[d,c]),h.useEffect(()=>{const E=()=>f({});return document.addEventListener(Xi,E),()=>document.removeEventListener(Xi,E)},[]),u.jsx(pe.div,{...l,ref:v,style:{pointerEvents:C?k?"auto":"none":void 0,...e.style},onFocusCapture:ie(e.onFocusCapture,T.onFocusCapture),onBlurCapture:ie(e.onBlurCapture,T.onBlurCapture),onPointerDownCapture:ie(e.onPointerDownCapture,S.onPointerDownCapture)})});Er.displayName=Bw;var Uw="DismissableLayerBranch",rd=h.forwardRef((e,t)=>{const n=h.useContext(nd),r=h.useRef(null),o=je(t,r);return h.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),u.jsx(pe.div,{...e,ref:o})});rd.displayName=Uw;function Ww(e,t=globalThis==null?void 0:globalThis.document){const n=ht(e),r=h.useRef(!1),o=h.useRef(()=>{});return h.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){sd(zw,n,c,{discrete:!0})};const c={originalEvent:a};a.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=l,t.addEventListener("click",o.current,{once:!0})):l()}else t.removeEventListener("click",o.current);r.current=!1},i=window.setTimeout(()=>{t.addEventListener("pointerdown",s)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",s),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function Vw(e,t=globalThis==null?void 0:globalThis.document){const n=ht(e),r=h.useRef(!1);return h.useEffect(()=>{const o=s=>{s.target&&!r.current&&sd(Hw,n,{originalEvent:s},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function od(){const e=new CustomEvent(Xi);document.dispatchEvent(e)}function sd(e,t,n,{discrete:r}){const o=n.originalEvent.target,s=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?Yi(o,s):o.dispatchEvent(s)}var Kw=Er,qw=rd,Ji=0;function Zi(){h.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??id()),document.body.insertAdjacentElement("beforeend",e[1]??id()),Ji++,()=>{Ji===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Ji--}},[])}function id(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var Qi="focusScope.autoFocusOnMount",ea="focusScope.autoFocusOnUnmount",ad={bubbles:!1,cancelable:!0},Gw="FocusScope",ns=h.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,l]=h.useState(null),c=ht(o),d=ht(s),p=h.useRef(null),m=je(t,g=>l(g)),f=h.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;h.useEffect(()=>{if(r){let g=function(C){if(f.paused||!a)return;const k=C.target;a.contains(k)?p.current=k:Dn(p.current,{select:!0})},x=function(C){if(f.paused||!a)return;const k=C.relatedTarget;k!==null&&(a.contains(k)||Dn(p.current,{select:!0}))},y=function(C){if(document.activeElement===document.body)for(const S of C)S.removedNodes.length>0&&Dn(a)};document.addEventListener("focusin",g),document.addEventListener("focusout",x);const b=new MutationObserver(y);return a&&b.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",g),document.removeEventListener("focusout",x),b.disconnect()}}},[r,a,f.paused]),h.useEffect(()=>{if(a){ud.add(f);const g=document.activeElement;if(!a.contains(g)){const y=new CustomEvent(Qi,ad);a.addEventListener(Qi,c),a.dispatchEvent(y),y.defaultPrevented||(Yw(eb(ld(a)),{select:!0}),document.activeElement===g&&Dn(a))}return()=>{a.removeEventListener(Qi,c),setTimeout(()=>{const y=new CustomEvent(ea,ad);a.addEventListener(ea,d),a.dispatchEvent(y),y.defaultPrevented||Dn(g??document.body,{select:!0}),a.removeEventListener(ea,d),ud.remove(f)},0)}}},[a,c,d,f]);const v=h.useCallback(g=>{if(!n&&!r||f.paused)return;const x=g.key==="Tab"&&!g.altKey&&!g.ctrlKey&&!g.metaKey,y=document.activeElement;if(x&&y){const b=g.currentTarget,[C,k]=Xw(b);C&&k?!g.shiftKey&&y===k?(g.preventDefault(),n&&Dn(C,{select:!0})):g.shiftKey&&y===C&&(g.preventDefault(),n&&Dn(k,{select:!0})):y===b&&g.preventDefault()}},[n,r,f.paused]);return u.jsx(pe.div,{tabIndex:-1,...i,ref:m,onKeyDown:v})});ns.displayName=Gw;function Yw(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Dn(r,{select:t}),document.activeElement!==n)return}function Xw(e){const t=ld(e),n=cd(t,e),r=cd(t.reverse(),e);return[n,r]}function ld(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function cd(e,t){for(const n of e)if(!Jw(n,{upTo:t}))return n}function Jw(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function Zw(e){return e instanceof HTMLInputElement&&"select"in e}function Dn(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Zw(e)&&t&&e.select()}}var ud=Qw();function Qw(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=dd(e,t),e.unshift(t)},remove(t){var n;e=dd(e,t),(n=e[0])==null||n.resume()}}}function dd(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function eb(e){return e.filter(t=>t.tagName!=="A")}var tb=h[" useId ".trim().toString()]||(()=>{}),nb=0;function _t(e){const[t,n]=h.useState(tb());return Et(()=>{n(r=>r??String(nb++))},[e]),t?`radix-${t}`:""}const rb=["top","right","bottom","left"],Ln=Math.min,Xt=Math.max,rs=Math.round,os=Math.floor,wn=e=>({x:e,y:e}),ob={left:"right",right:"left",bottom:"top",top:"bottom"},sb={start:"end",end:"start"};function ta(e,t,n){return Xt(e,Ln(t,n))}function An(e,t){return typeof e=="function"?e(t):e}function Pn(e){return e.split("-")[0]}function Ir(e){return e.split("-")[1]}function na(e){return e==="x"?"y":"x"}function ra(e){return e==="y"?"height":"width"}const ib=new Set(["top","bottom"]);function bn(e){return ib.has(Pn(e))?"y":"x"}function oa(e){return na(bn(e))}function ab(e,t,n){n===void 0&&(n=!1);const r=Ir(e),o=oa(e),s=ra(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=ss(i)),[i,ss(i)]}function lb(e){const t=ss(e);return[sa(e),t,sa(t)]}function sa(e){return e.replace(/start|end/g,t=>sb[t])}const fd=["left","right"],pd=["right","left"],cb=["top","bottom"],ub=["bottom","top"];function db(e,t,n){switch(e){case"top":case"bottom":return n?t?pd:fd:t?fd:pd;case"left":case"right":return t?cb:ub;default:return[]}}function fb(e,t,n,r){const o=Ir(e);let s=db(Pn(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(sa)))),s}function ss(e){return e.replace(/left|right|bottom|top/g,t=>ob[t])}function pb(e){return{top:0,right:0,bottom:0,left:0,...e}}function hd(e){return typeof e!="number"?pb(e):{top:e,right:e,bottom:e,left:e}}function is(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}function md(e,t,n){let{reference:r,floating:o}=e;const s=bn(t),i=oa(t),a=ra(i),l=Pn(t),c=s==="y",d=r.x+r.width/2-o.width/2,p=r.y+r.height/2-o.height/2,m=r[a]/2-o[a]/2;let f;switch(l){case"top":f={x:d,y:r.y-o.height};break;case"bottom":f={x:d,y:r.y+r.height};break;case"right":f={x:r.x+r.width,y:p};break;case"left":f={x:r.x-o.width,y:p};break;default:f={x:r.x,y:r.y}}switch(Ir(t)){case"start":f[i]-=m*(n&&c?-1:1);break;case"end":f[i]+=m*(n&&c?-1:1);break}return f}const hb=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=n,a=s.filter(Boolean),l=await(i.isRTL==null?void 0:i.isRTL(t));let c=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:d,y:p}=md(c,r,l),m=r,f={},v=0;for(let g=0;g<a.length;g++){const{name:x,fn:y}=a[g],{x:b,y:C,data:k,reset:S}=await y({x:d,y:p,initialPlacement:r,placement:m,strategy:o,middlewareData:f,rects:c,platform:i,elements:{reference:e,floating:t}});d=b??d,p=C??p,f={...f,[x]:{...f[x],...k}},S&&v<=50&&(v++,typeof S=="object"&&(S.placement&&(m=S.placement),S.rects&&(c=S.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):S.rects),{x:d,y:p}=md(c,m,l)),g=-1)}return{x:d,y:p,placement:m,strategy:o,middlewareData:f}};async function io(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:i,elements:a,strategy:l}=e,{boundary:c="clippingAncestors",rootBoundary:d="viewport",elementContext:p="floating",altBoundary:m=!1,padding:f=0}=An(t,e),v=hd(f),x=a[m?p==="floating"?"reference":"floating":p],y=is(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(x)))==null||n?x:x.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:c,rootBoundary:d,strategy:l})),b=p==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,C=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),k=await(s.isElement==null?void 0:s.isElement(C))?await(s.getScale==null?void 0:s.getScale(C))||{x:1,y:1}:{x:1,y:1},S=is(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:b,offsetParent:C,strategy:l}):b);return{top:(y.top-S.top+v.top)/k.y,bottom:(S.bottom-y.bottom+v.bottom)/k.y,left:(y.left-S.left+v.left)/k.x,right:(S.right-y.right+v.right)/k.x}}const mb=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:s,platform:i,elements:a,middlewareData:l}=t,{element:c,padding:d=0}=An(e,t)||{};if(c==null)return{};const p=hd(d),m={x:n,y:r},f=oa(o),v=ra(f),g=await i.getDimensions(c),x=f==="y",y=x?"top":"left",b=x?"bottom":"right",C=x?"clientHeight":"clientWidth",k=s.reference[v]+s.reference[f]-m[f]-s.floating[v],S=m[f]-s.reference[f],T=await(i.getOffsetParent==null?void 0:i.getOffsetParent(c));let E=T?T[C]:0;(!E||!await(i.isElement==null?void 0:i.isElement(T)))&&(E=a.floating[C]||s.floating[v]);const A=k/2-S/2,P=E/2-g[v]/2-1,$=Ln(p[y],P),L=Ln(p[b],P),H=$,Y=E-g[v]-L,_=E/2-g[v]/2+A,V=ta(H,_,Y),G=!l.arrow&&Ir(o)!=null&&_!==V&&s.reference[v]/2-(_<H?$:L)-g[v]/2<0,W=G?_<H?_-H:_-Y:0;return{[f]:m[f]+W,data:{[f]:V,centerOffset:_-V-W,...G&&{alignmentOffset:W}},reset:G}}}),gb=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:s,rects:i,initialPlacement:a,platform:l,elements:c}=t,{mainAxis:d=!0,crossAxis:p=!0,fallbackPlacements:m,fallbackStrategy:f="bestFit",fallbackAxisSideDirection:v="none",flipAlignment:g=!0,...x}=An(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const y=Pn(o),b=bn(a),C=Pn(a)===a,k=await(l.isRTL==null?void 0:l.isRTL(c.floating)),S=m||(C||!g?[ss(a)]:lb(a)),T=v!=="none";!m&&T&&S.push(...fb(a,g,v,k));const E=[a,...S],A=await io(t,x),P=[];let $=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&P.push(A[y]),p){const _=ab(o,i,k);P.push(A[_[0]],A[_[1]])}if($=[...$,{placement:o,overflows:P}],!P.every(_=>_<=0)){var L,H;const _=(((L=s.flip)==null?void 0:L.index)||0)+1,V=E[_];if(V&&(!(p==="alignment"?b!==bn(V):!1)||$.every(D=>bn(D.placement)===b?D.overflows[0]>0:!0)))return{data:{index:_,overflows:$},reset:{placement:V}};let G=(H=$.filter(W=>W.overflows[0]<=0).sort((W,D)=>W.overflows[1]-D.overflows[1])[0])==null?void 0:H.placement;if(!G)switch(f){case"bestFit":{var Y;const W=(Y=$.filter(D=>{if(T){const I=bn(D.placement);return I===b||I==="y"}return!0}).map(D=>[D.placement,D.overflows.filter(I=>I>0).reduce((I,U)=>I+U,0)]).sort((D,I)=>D[1]-I[1])[0])==null?void 0:Y[0];W&&(G=W);break}case"initialPlacement":G=a;break}if(o!==G)return{reset:{placement:G}}}return{}}}};function gd(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function xd(e){return rb.some(t=>e[t]>=0)}const xb=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=An(e,t);switch(r){case"referenceHidden":{const s=await io(t,{...o,elementContext:"reference"}),i=gd(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:xd(i)}}}case"escaped":{const s=await io(t,{...o,altBoundary:!0}),i=gd(s,n.floating);return{data:{escapedOffsets:i,escaped:xd(i)}}}default:return{}}}}},vd=new Set(["left","top"]);async function vb(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=Pn(n),a=Ir(n),l=bn(n)==="y",c=vd.has(i)?-1:1,d=s&&l?-1:1,p=An(t,e);let{mainAxis:m,crossAxis:f,alignmentAxis:v}=typeof p=="number"?{mainAxis:p,crossAxis:0,alignmentAxis:null}:{mainAxis:p.mainAxis||0,crossAxis:p.crossAxis||0,alignmentAxis:p.alignmentAxis};return a&&typeof v=="number"&&(f=a==="end"?v*-1:v),l?{x:f*d,y:m*c}:{x:m*c,y:f*d}}const wb=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:s,placement:i,middlewareData:a}=t,l=await vb(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}}}}},bb=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o}=t,{mainAxis:s=!0,crossAxis:i=!1,limiter:a={fn:x=>{let{x:y,y:b}=x;return{x:y,y:b}}},...l}=An(e,t),c={x:n,y:r},d=await io(t,l),p=bn(Pn(o)),m=na(p);let f=c[m],v=c[p];if(s){const x=m==="y"?"top":"left",y=m==="y"?"bottom":"right",b=f+d[x],C=f-d[y];f=ta(b,f,C)}if(i){const x=p==="y"?"top":"left",y=p==="y"?"bottom":"right",b=v+d[x],C=v-d[y];v=ta(b,v,C)}const g=a.fn({...t,[m]:f,[p]:v});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[m]:s,[p]:i}}}}}},yb=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:s,middlewareData:i}=t,{offset:a=0,mainAxis:l=!0,crossAxis:c=!0}=An(e,t),d={x:n,y:r},p=bn(o),m=na(p);let f=d[m],v=d[p];const g=An(a,t),x=typeof g=="number"?{mainAxis:g,crossAxis:0}:{mainAxis:0,crossAxis:0,...g};if(l){const C=m==="y"?"height":"width",k=s.reference[m]-s.floating[C]+x.mainAxis,S=s.reference[m]+s.reference[C]-x.mainAxis;f<k?f=k:f>S&&(f=S)}if(c){var y,b;const C=m==="y"?"width":"height",k=vd.has(Pn(o)),S=s.reference[p]-s.floating[C]+(k&&((y=i.offset)==null?void 0:y[p])||0)+(k?0:x.crossAxis),T=s.reference[p]+s.reference[C]+(k?0:((b=i.offset)==null?void 0:b[p])||0)-(k?x.crossAxis:0);v<S?v=S:v>T&&(v=T)}return{[m]:f,[p]:v}}}},Sb=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:s,platform:i,elements:a}=t,{apply:l=()=>{},...c}=An(e,t),d=await io(t,c),p=Pn(o),m=Ir(o),f=bn(o)==="y",{width:v,height:g}=s.floating;let x,y;p==="top"||p==="bottom"?(x=p,y=m===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(y=p,x=m==="end"?"top":"bottom");const b=g-d.top-d.bottom,C=v-d.left-d.right,k=Ln(g-d[x],b),S=Ln(v-d[y],C),T=!t.middlewareData.shift;let E=k,A=S;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(A=C),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(E=b),T&&!m){const $=Xt(d.left,0),L=Xt(d.right,0),H=Xt(d.top,0),Y=Xt(d.bottom,0);f?A=v-2*($!==0||L!==0?$+L:Xt(d.left,d.right)):E=g-2*(H!==0||Y!==0?H+Y:Xt(d.top,d.bottom))}await l({...t,availableWidth:A,availableHeight:E});const P=await i.getDimensions(a.floating);return v!==P.width||g!==P.height?{reset:{rects:!0}}:{}}}};function as(){return typeof window<"u"}function Nr(e){return wd(e)?(e.nodeName||"").toLowerCase():"#document"}function Jt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function yn(e){var t;return(t=(wd(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function wd(e){return as()?e instanceof Node||e instanceof Jt(e).Node:!1}function un(e){return as()?e instanceof Element||e instanceof Jt(e).Element:!1}function Sn(e){return as()?e instanceof HTMLElement||e instanceof Jt(e).HTMLElement:!1}function bd(e){return!as()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Jt(e).ShadowRoot}const Cb=new Set(["inline","contents"]);function ao(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=dn(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!Cb.has(o)}const Tb=new Set(["table","td","th"]);function kb(e){return Tb.has(Nr(e))}const Eb=[":popover-open",":modal"];function ls(e){return Eb.some(t=>{try{return e.matches(t)}catch{return!1}})}const Ib=["transform","translate","scale","rotate","perspective"],Nb=["transform","translate","scale","rotate","perspective","filter"],Ab=["paint","layout","strict","content"];function ia(e){const t=aa(),n=un(e)?dn(e):e;return Ib.some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||Nb.some(r=>(n.willChange||"").includes(r))||Ab.some(r=>(n.contain||"").includes(r))}function Pb(e){let t=$n(e);for(;Sn(t)&&!Ar(t);){if(ia(t))return t;if(ls(t))return null;t=$n(t)}return null}function aa(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const jb=new Set(["html","body","#document"]);function Ar(e){return jb.has(Nr(e))}function dn(e){return Jt(e).getComputedStyle(e)}function cs(e){return un(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function $n(e){if(Nr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||bd(e)&&e.host||yn(e);return bd(t)?t.host:t}function yd(e){const t=$n(e);return Ar(t)?e.ownerDocument?e.ownerDocument.body:e.body:Sn(t)&&ao(t)?t:yd(t)}function lo(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=yd(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Jt(o);if(s){const a=la(i);return t.concat(i,i.visualViewport||[],ao(o)?o:[],a&&n?lo(a):[])}return t.concat(o,lo(o,[],n))}function la(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Sd(e){const t=dn(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=Sn(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=rs(n)!==s||rs(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function ca(e){return un(e)?e:e.contextElement}function Pr(e){const t=ca(e);if(!Sn(t))return wn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=Sd(t);let i=(s?rs(n.width):n.width)/r,a=(s?rs(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const _b=wn(0);function Cd(e){const t=Jt(e);return!aa()||!t.visualViewport?_b:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Rb(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Jt(e)?!1:t}function nr(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=ca(e);let i=wn(1);t&&(r?un(r)&&(i=Pr(r)):i=Pr(e));const a=Rb(s,n,r)?Cd(s):wn(0);let l=(o.left+a.x)/i.x,c=(o.top+a.y)/i.y,d=o.width/i.x,p=o.height/i.y;if(s){const m=Jt(s),f=r&&un(r)?Jt(r):r;let v=m,g=la(v);for(;g&&r&&f!==v;){const x=Pr(g),y=g.getBoundingClientRect(),b=dn(g),C=y.left+(g.clientLeft+parseFloat(b.paddingLeft))*x.x,k=y.top+(g.clientTop+parseFloat(b.paddingTop))*x.y;l*=x.x,c*=x.y,d*=x.x,p*=x.y,l+=C,c+=k,v=Jt(g),g=la(v)}}return is({width:d,height:p,x:l,y:c})}function us(e,t){const n=cs(e).scrollLeft;return t?t.left+n:nr(yn(e)).left+n}function Td(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-us(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function Mb(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=yn(r),a=t?ls(t.floating):!1;if(r===i||a&&s)return n;let l={scrollLeft:0,scrollTop:0},c=wn(1);const d=wn(0),p=Sn(r);if((p||!p&&!s)&&((Nr(r)!=="body"||ao(i))&&(l=cs(r)),Sn(r))){const f=nr(r);c=Pr(r),d.x=f.x+r.clientLeft,d.y=f.y+r.clientTop}const m=i&&!p&&!s?Td(i,l):wn(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 Ob(e){return Array.from(e.getClientRects())}function Db(e){const t=yn(e),n=cs(e),r=e.ownerDocument.body,o=Xt(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Xt(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+us(e);const a=-n.scrollTop;return dn(r).direction==="rtl"&&(i+=Xt(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const kd=25;function Lb(e,t){const n=Jt(e),r=yn(e),o=n.visualViewport;let s=r.clientWidth,i=r.clientHeight,a=0,l=0;if(o){s=o.width,i=o.height;const d=aa();(!d||d&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}const c=us(r);if(c<=0){const d=r.ownerDocument,p=d.body,m=getComputedStyle(p),f=d.compatMode==="CSS1Compat"&&parseFloat(m.marginLeft)+parseFloat(m.marginRight)||0,v=Math.abs(r.clientWidth-p.clientWidth-f);v<=kd&&(s-=v)}else c<=kd&&(s+=c);return{width:s,height:i,x:a,y:l}}const $b=new Set(["absolute","fixed"]);function Fb(e,t){const n=nr(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=Sn(e)?Pr(e):wn(1),i=e.clientWidth*s.x,a=e.clientHeight*s.y,l=o*s.x,c=r*s.y;return{width:i,height:a,x:l,y:c}}function Ed(e,t,n){let r;if(t==="viewport")r=Lb(e,n);else if(t==="document")r=Db(yn(e));else if(un(t))r=Fb(t,n);else{const o=Cd(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return is(r)}function Id(e,t){const n=$n(e);return n===t||!un(n)||Ar(n)?!1:dn(n).position==="fixed"||Id(n,t)}function Bb(e,t){const n=t.get(e);if(n)return n;let r=lo(e,[],!1).filter(a=>un(a)&&Nr(a)!=="body"),o=null;const s=dn(e).position==="fixed";let i=s?$n(e):e;for(;un(i)&&!Ar(i);){const a=dn(i),l=ia(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&$b.has(o.position)||ao(i)&&!l&&Id(e,i))?r=r.filter(d=>d!==i):o=a,i=$n(i)}return t.set(e,r),r}function zb(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?ls(t)?[]:Bb(t,this._c):[].concat(n),r],a=i[0],l=i.reduce((c,d)=>{const p=Ed(t,d,o);return c.top=Xt(p.top,c.top),c.right=Ln(p.right,c.right),c.bottom=Ln(p.bottom,c.bottom),c.left=Xt(p.left,c.left),c},Ed(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function Hb(e){const{width:t,height:n}=Sd(e);return{width:t,height:n}}function Ub(e,t,n){const r=Sn(t),o=yn(t),s=n==="fixed",i=nr(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=wn(0);function c(){l.x=us(o)}if(r||!r&&!s)if((Nr(t)!=="body"||ao(o))&&(a=cs(t)),r){const f=nr(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?Td(o,a):wn(0),p=i.left+a.scrollLeft-l.x-d.x,m=i.top+a.scrollTop-l.y-d.y;return{x:p,y:m,width:i.width,height:i.height}}function ua(e){return dn(e).position==="static"}function Nd(e,t){if(!Sn(e)||dn(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return yn(e)===n&&(n=n.ownerDocument.body),n}function Ad(e,t){const n=Jt(e);if(ls(e))return n;if(!Sn(e)){let o=$n(e);for(;o&&!Ar(o);){if(un(o)&&!ua(o))return o;o=$n(o)}return n}let r=Nd(e,t);for(;r&&kb(r)&&ua(r);)r=Nd(r,t);return r&&Ar(r)&&ua(r)&&!ia(r)?n:r||Pb(e)||n}const Wb=async function(e){const t=this.getOffsetParent||Ad,n=this.getDimensions,r=await n(e.floating);return{reference:Ub(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Vb(e){return dn(e).direction==="rtl"}const Kb={convertOffsetParentRelativeRectToViewportRelativeRect:Mb,getDocumentElement:yn,getClippingRect:zb,getOffsetParent:Ad,getElementRects:Wb,getClientRects:Ob,getDimensions:Hb,getScale:Pr,isElement:un,isRTL:Vb};function Pd(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function qb(e,t){let n=null,r;const o=yn(e);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),s();const c=e.getBoundingClientRect(),{left:d,top:p,width:m,height:f}=c;if(a||t(),!m||!f)return;const v=os(p),g=os(o.clientWidth-(d+m)),x=os(o.clientHeight-(p+f)),y=os(d),C={rootMargin:-v+"px "+-g+"px "+-x+"px "+-y+"px",threshold:Xt(0,Ln(1,l))||1};let k=!0;function S(T){const E=T[0].intersectionRatio;if(E!==l){if(!k)return i();E?i(!1,E):r=setTimeout(()=>{i(!1,1e-7)},1e3)}E===1&&!Pd(c,e.getBoundingClientRect())&&i(),k=!1}try{n=new IntersectionObserver(S,{...C,root:o.ownerDocument})}catch{n=new IntersectionObserver(S,C)}n.observe(e)}return i(!0),s}function Gb(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,c=ca(e),d=o||s?[...c?lo(c):[],...lo(t)]:[];d.forEach(y=>{o&&y.addEventListener("scroll",n,{passive:!0}),s&&y.addEventListener("resize",n)});const p=c&&a?qb(c,n):null;let m=-1,f=null;i&&(f=new ResizeObserver(y=>{let[b]=y;b&&b.target===c&&f&&(f.unobserve(t),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var C;(C=f)==null||C.observe(t)})),n()}),c&&!l&&f.observe(c),f.observe(t));let v,g=l?nr(e):null;l&&x();function x(){const y=nr(e);g&&!Pd(g,y)&&n(),g=y,v=requestAnimationFrame(x)}return n(),()=>{var y;d.forEach(b=>{o&&b.removeEventListener("scroll",n),s&&b.removeEventListener("resize",n)}),p==null||p(),(y=f)==null||y.disconnect(),f=null,l&&cancelAnimationFrame(v)}}const Yb=wb,Xb=bb,Jb=gb,Zb=Sb,Qb=xb,jd=mb,ey=yb,ty=(e,t,n)=>{const r=new Map,o={platform:Kb,...n},s={...o.platform,_c:r};return hb(e,t,{...o,platform:s})};var ny=typeof document<"u",ry=function(){},ds=ny?w.useLayoutEffect:ry;function fs(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!fs(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){const s=o[r];if(!(s==="_owner"&&e.$$typeof)&&!fs(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function _d(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Rd(e,t){const n=_d(e);return Math.round(t*n)/n}function da(e){const t=h.useRef(e);return ds(()=>{t.current=e}),t}function oy(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:i}={},transform:a=!0,whileElementsMounted:l,open:c}=e,[d,p]=h.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[m,f]=h.useState(r);fs(m,r)||f(r);const[v,g]=h.useState(null),[x,y]=h.useState(null),b=h.useCallback(D=>{D!==T.current&&(T.current=D,g(D))},[]),C=h.useCallback(D=>{D!==E.current&&(E.current=D,y(D))},[]),k=s||v,S=i||x,T=h.useRef(null),E=h.useRef(null),A=h.useRef(d),P=l!=null,$=da(l),L=da(o),H=da(c),Y=h.useCallback(()=>{if(!T.current||!E.current)return;const D={placement:t,strategy:n,middleware:m};L.current&&(D.platform=L.current),ty(T.current,E.current,D).then(I=>{const U={...I,isPositioned:H.current!==!1};_.current&&!fs(A.current,U)&&(A.current=U,qr.flushSync(()=>{p(U)}))})},[m,t,n,L,H]);ds(()=>{c===!1&&A.current.isPositioned&&(A.current.isPositioned=!1,p(D=>({...D,isPositioned:!1})))},[c]);const _=h.useRef(!1);ds(()=>(_.current=!0,()=>{_.current=!1}),[]),ds(()=>{if(k&&(T.current=k),S&&(E.current=S),k&&S){if($.current)return $.current(k,S,Y);Y()}},[k,S,Y,$,P]);const V=h.useMemo(()=>({reference:T,floating:E,setReference:b,setFloating:C}),[b,C]),G=h.useMemo(()=>({reference:k,floating:S}),[k,S]),W=h.useMemo(()=>{const D={position:n,left:0,top:0};if(!G.floating)return D;const I=Rd(G.floating,d.x),U=Rd(G.floating,d.y);return a?{...D,transform:"translate("+I+"px, "+U+"px)",..._d(G.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:I,top:U}},[n,a,G.floating,d.x,d.y]);return h.useMemo(()=>({...d,update:Y,refs:V,elements:G,floatingStyles:W}),[d,Y,V,G,W])}const sy=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:o}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?jd({element:r.current,padding:o}).fn(n):{}:r?jd({element:r,padding:o}).fn(n):{}}}},iy=(e,t)=>({...Yb(e),options:[e,t]}),ay=(e,t)=>({...Xb(e),options:[e,t]}),ly=(e,t)=>({...ey(e),options:[e,t]}),cy=(e,t)=>({...Jb(e),options:[e,t]}),uy=(e,t)=>({...Zb(e),options:[e,t]}),dy=(e,t)=>({...Qb(e),options:[e,t]}),fy=(e,t)=>({...sy(e),options:[e,t]});var py="Arrow",Md=h.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return u.jsx(pe.svg,{...s,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:u.jsx("polygon",{points:"0,0 30,0 15,10"})})});Md.displayName=py;var hy=Md;function Od(e){const[t,n]=h.useState(void 0);return 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 fa="Popper",[Dd,jr]=cn(fa),[my,Ld]=Dd(fa),$d=e=>{const{__scopePopper:t,children:n}=e,[r,o]=h.useState(null);return u.jsx(my,{scope:t,anchor:r,onAnchorChange:o,children:n})};$d.displayName=fa;var Fd="PopperAnchor",Bd=h.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=Ld(Fd,n),i=h.useRef(null),a=je(t,i),l=h.useRef(null);return h.useEffect(()=>{const c=l.current;l.current=(r==null?void 0:r.current)||i.current,c!==l.current&&s.onAnchorChange(l.current)}),r?null:u.jsx(pe.div,{...o,ref:a})});Bd.displayName=Fd;var pa="PopperContent",[gy,xy]=Dd(pa),zd=h.forwardRef((e,t)=>{var M,O,F,J,oe,ae;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:a=0,avoidCollisions:l=!0,collisionBoundary:c=[],collisionPadding:d=0,sticky:p="partial",hideWhenDetached:m=!1,updatePositionStrategy:f="optimized",onPlaced:v,...g}=e,x=Ld(pa,n),[y,b]=h.useState(null),C=je(t,Se=>b(Se)),[k,S]=h.useState(null),T=Od(k),E=(T==null?void 0:T.width)??0,A=(T==null?void 0:T.height)??0,P=r+(s!=="center"?"-"+s:""),$=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},L=Array.isArray(c)?c:[c],H=L.length>0,Y={padding:$,boundary:L.filter(wy),altBoundary:H},{refs:_,floatingStyles:V,placement:G,isPositioned:W,middlewareData:D}=oy({strategy:"fixed",placement:P,whileElementsMounted:(...Se)=>Gb(...Se,{animationFrame:f==="always"}),elements:{reference:x.anchor},middleware:[iy({mainAxis:o+A,alignmentAxis:i}),l&&ay({mainAxis:!0,crossAxis:!1,limiter:p==="partial"?ly():void 0,...Y}),l&&cy({...Y}),uy({...Y,apply:({elements:Se,rects:we,availableWidth:Re,availableHeight:$e})=>{const{width:Fe,height:Ge}=we.reference,Je=Se.floating.style;Je.setProperty("--radix-popper-available-width",`${Re}px`),Je.setProperty("--radix-popper-available-height",`${$e}px`),Je.setProperty("--radix-popper-anchor-width",`${Fe}px`),Je.setProperty("--radix-popper-anchor-height",`${Ge}px`)}}),k&&fy({element:k,padding:a}),by({arrowWidth:E,arrowHeight:A}),m&&dy({strategy:"referenceHidden",...Y})]}),[I,U]=Wd(G),Z=ht(v);Et(()=>{W&&(Z==null||Z())},[W,Z]);const R=(M=D.arrow)==null?void 0:M.x,q=(O=D.arrow)==null?void 0:O.y,j=((F=D.arrow)==null?void 0:F.centerOffset)!==0,[B,Q]=h.useState();return Et(()=>{y&&Q(window.getComputedStyle(y).zIndex)},[y]),u.jsx("div",{ref:_.setFloating,"data-radix-popper-content-wrapper":"",style:{...V,transform:W?V.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:B,"--radix-popper-transform-origin":[(J=D.transformOrigin)==null?void 0:J.x,(oe=D.transformOrigin)==null?void 0:oe.y].join(" "),...((ae=D.hide)==null?void 0:ae.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:u.jsx(gy,{scope:n,placedSide:I,onArrowChange:S,arrowX:R,arrowY:q,shouldHideArrow:j,children:u.jsx(pe.div,{"data-side":I,"data-align":U,...g,ref:C,style:{...g.style,animation:W?void 0:"none"}})})})});zd.displayName=pa;var Hd="PopperArrow",vy={top:"bottom",right:"left",bottom:"top",left:"right"},Ud=h.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=xy(Hd,r),i=vy[s.placedSide];return u.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:u.jsx(hy,{...o,ref:n,style:{...o.style,display:"block"}})})});Ud.displayName=Hd;function wy(e){return e!==null}var by=e=>({name:"transformOrigin",options:e,fn(t){var x,y,b;const{placement:n,rects:r,middlewareData:o}=t,i=((x=o.arrow)==null?void 0:x.centerOffset)!==0,a=i?0:e.arrowWidth,l=i?0:e.arrowHeight,[c,d]=Wd(n),p={start:"0%",center:"50%",end:"100%"}[d],m=(((y=o.arrow)==null?void 0:y.x)??0)+a/2,f=(((b=o.arrow)==null?void 0:b.y)??0)+l/2;let v="",g="";return c==="bottom"?(v=i?p:`${m}px`,g=`${-l}px`):c==="top"?(v=i?p:`${m}px`,g=`${r.floating.height+l}px`):c==="right"?(v=`${-l}px`,g=i?p:`${f}px`):c==="left"&&(v=`${r.floating.width+l}px`,g=i?p:`${f}px`),{data:{x:v,y:g}}}});function Wd(e){const[t,n="center"]=e.split("-");return[t,n]}var ha=$d,ma=Bd,ga=zd,xa=Ud,yy="Portal",co=h.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=h.useState(!1);Et(()=>s(!0),[]);const i=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?Lo.createPortal(u.jsx(pe.div,{...r,ref:t}),i):null});co.displayName=yy;function Sy(e,t){return h.useReducer((n,r)=>t[n][r]??n,e)}var Ht=e=>{const{present:t,children:n}=e,r=Cy(t),o=typeof n=="function"?n({present:r.isPresent}):h.Children.only(n),s=je(r.ref,Ty(o));return typeof n=="function"||r.isPresent?h.cloneElement(o,{ref:s}):null};Ht.displayName="Presence";function Cy(e){const[t,n]=h.useState(),r=h.useRef(null),o=h.useRef(e),s=h.useRef("none"),i=e?"mounted":"unmounted",[a,l]=Sy(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return h.useEffect(()=>{const c=ps(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=ps(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,p=f=>{const g=ps(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=ps(r.current))};return t.addEventListener("animationstart",m),t.addEventListener("animationcancel",p),t.addEventListener("animationend",p),()=>{d.clearTimeout(c),t.removeEventListener("animationstart",m),t.removeEventListener("animationcancel",p),t.removeEventListener("animationend",p)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:h.useCallback(c=>{r.current=c?getComputedStyle(c):null,n(c)},[])}}function ps(e){return(e==null?void 0:e.animationName)||"none"}function Ty(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var va="rovingFocusGroup.onEntryFocus",ky={bubbles:!1,cancelable:!0},uo="RovingFocusGroup",[wa,Vd,Ey]=es(uo),[Iy,Kd]=cn(uo,[Ey]),[Ny,Ay]=Iy(uo),qd=h.forwardRef((e,t)=>u.jsx(wa.Provider,{scope:e.__scopeRovingFocusGroup,children:u.jsx(wa.Slot,{scope:e.__scopeRovingFocusGroup,children:u.jsx(Py,{...e,ref:t})})}));qd.displayName=uo;var Py=h.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:c,preventScrollOnEntryFocus:d=!1,...p}=e,m=h.useRef(null),f=je(t,m),v=ts(s),[g,x]=On({prop:i,defaultProp:a??null,onChange:l,caller:uo}),[y,b]=h.useState(!1),C=ht(c),k=Vd(n),S=h.useRef(!1),[T,E]=h.useState(0);return h.useEffect(()=>{const A=m.current;if(A)return A.addEventListener(va,C),()=>A.removeEventListener(va,C)},[C]),u.jsx(Ny,{scope:n,orientation:r,dir:v,loop:o,currentTabStopId:g,onItemFocus:h.useCallback(A=>x(A),[x]),onItemShiftTab:h.useCallback(()=>b(!0),[]),onFocusableItemAdd:h.useCallback(()=>E(A=>A+1),[]),onFocusableItemRemove:h.useCallback(()=>E(A=>A-1),[]),children:u.jsx(pe.div,{tabIndex:y||T===0?-1:0,"data-orientation":r,...p,ref:f,style:{outline:"none",...e.style},onMouseDown:ie(e.onMouseDown,()=>{S.current=!0}),onFocus:ie(e.onFocus,A=>{const P=!S.current;if(A.target===A.currentTarget&&P&&!y){const $=new CustomEvent(va,ky);if(A.currentTarget.dispatchEvent($),!$.defaultPrevented){const L=k().filter(G=>G.focusable),H=L.find(G=>G.active),Y=L.find(G=>G.id===g),V=[H,Y,...L].filter(Boolean).map(G=>G.ref.current);Xd(V,d)}}S.current=!1}),onBlur:ie(e.onBlur,()=>b(!1))})})}),Gd="RovingFocusGroupItem",Yd=h.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,l=_t(),c=s||l,d=Ay(Gd,n),p=d.currentTabStopId===c,m=Vd(n),{onFocusableItemAdd:f,onFocusableItemRemove:v,currentTabStopId:g}=d;return h.useEffect(()=>{if(r)return f(),()=>v()},[r,f,v]),u.jsx(wa.ItemSlot,{scope:n,id:c,focusable:r,active:o,children:u.jsx(pe.span,{tabIndex:p?0:-1,"data-orientation":d.orientation,...a,ref:t,onMouseDown:ie(e.onMouseDown,x=>{r?d.onItemFocus(c):x.preventDefault()}),onFocus:ie(e.onFocus,()=>d.onItemFocus(c)),onKeyDown:ie(e.onKeyDown,x=>{if(x.key==="Tab"&&x.shiftKey){d.onItemShiftTab();return}if(x.target!==x.currentTarget)return;const y=Ry(x,d.orientation,d.dir);if(y!==void 0){if(x.metaKey||x.ctrlKey||x.altKey||x.shiftKey)return;x.preventDefault();let C=m().filter(k=>k.focusable).map(k=>k.ref.current);if(y==="last")C.reverse();else if(y==="prev"||y==="next"){y==="prev"&&C.reverse();const k=C.indexOf(x.currentTarget);C=d.loop?My(C,k+1):C.slice(k+1)}setTimeout(()=>Xd(C))}}),children:typeof i=="function"?i({isCurrentTabStop:p,hasTabStop:g!=null}):i})})});Yd.displayName=Gd;var jy={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function _y(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Ry(e,t,n){const r=_y(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return jy[r]}function Xd(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function My(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Oy=qd,Dy=Yd,Ly=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},_r=new WeakMap,hs=new WeakMap,ms={},ba=0,Jd=function(e){return e&&(e.host||Jd(e.parentNode))},$y=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=Jd(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},Fy=function(e,t,n,r){var o=$y(t,Array.isArray(e)?e:[e]);ms[n]||(ms[n]=new WeakMap);var s=ms[n],i=[],a=new Set,l=new Set(o),c=function(p){!p||a.has(p)||(a.add(p),c(p.parentNode))};o.forEach(c);var d=function(p){!p||l.has(p)||Array.prototype.forEach.call(p.children,function(m){if(a.has(m))d(m);else try{var f=m.getAttribute(r),v=f!==null&&f!=="false",g=(_r.get(m)||0)+1,x=(s.get(m)||0)+1;_r.set(m,g),s.set(m,x),i.push(m),g===1&&v&&hs.set(m,!0),x===1&&m.setAttribute(n,"true"),v||m.setAttribute(r,"true")}catch(y){console.error("aria-hidden: cannot operate on ",m,y)}})};return d(t),a.clear(),ba++,function(){i.forEach(function(p){var m=_r.get(p)-1,f=s.get(p)-1;_r.set(p,m),s.set(p,f),m||(hs.has(p)||p.removeAttribute(r),hs.delete(p)),f||p.removeAttribute(n)}),ba--,ba||(_r=new WeakMap,_r=new WeakMap,hs=new WeakMap,ms={})}},ya=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=Ly(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),Fy(r,o,n,"aria-hidden")):function(){return null}},Cn=function(){return Cn=Object.assign||function(t){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])}return t},Cn.apply(this,arguments)};function Zd(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n}function By(e,t,n){if(n||arguments.length===2)for(var r=0,o=t.length,s;r<o;r++)(s||!(r in t))&&(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return e.concat(s||Array.prototype.slice.call(t))}typeof SuppressedError=="function"&&SuppressedError;var gs="right-scroll-bar-position",xs="width-before-scroll-bar",zy="with-scroll-bars-hidden",Hy="--removed-body-scroll-bar-size";function Sa(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function Uy(e,t){var n=w.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var o=n.value;o!==r&&(n.value=r,n.callback(r,o))}}}})[0];return n.callback=t,n.facade}var Wy=typeof window<"u"?h.useLayoutEffect:h.useEffect,Qd=new WeakMap;function Vy(e,t){var n=Uy(null,function(r){return e.forEach(function(o){return Sa(o,r)})});return Wy(function(){var r=Qd.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||Sa(a,null)}),s.forEach(function(a){o.has(a)||Sa(a,i)})}Qd.set(n,e)},[e]),n}function Ky(e){return e}function qy(e,t){t===void 0&&(t=Ky);var n=[],r=!1,o={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(s){var i=t(s,r);return n.push(i),function(){n=n.filter(function(a){return a!==i})}},assignSyncMedium:function(s){for(r=!0;n.length;){var i=n;n=[],i.forEach(s)}n={push:function(a){return s(a)},filter:function(){return n}}},assignMedium:function(s){r=!0;var i=[];if(n.length){var a=n;n=[],a.forEach(s),i=n}var 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 Gy(e){e===void 0&&(e={});var t=qy(null);return t.options=Cn({async:!0,ssr:!1},e),t}var ef=function(e){var t=e.sideCar,n=Zd(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return h.createElement(r,Cn({},n))};ef.isSideCarExport=!0;function Yy(e,t){return e.useMedium(t),ef}var tf=Gy(),Ca=function(){},vs=h.forwardRef(function(e,t){var n=h.useRef(null),r=h.useState({onScrollCapture:Ca,onWheelCapture:Ca,onTouchMoveCapture:Ca}),o=r[0],s=r[1],i=e.forwardProps,a=e.children,l=e.className,c=e.removeScrollBar,d=e.enabled,p=e.shards,m=e.sideCar,f=e.noRelative,v=e.noIsolation,g=e.inert,x=e.allowPinchZoom,y=e.as,b=y===void 0?"div":y,C=e.gapMode,k=Zd(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),S=m,T=Vy([n,t]),E=Cn(Cn({},k),o);return h.createElement(h.Fragment,null,d&&h.createElement(S,{sideCar:tf,removeScrollBar:c,shards:p,noRelative:f,noIsolation:v,inert:g,setCallbacks:s,allowPinchZoom:!!x,lockRef:n,gapMode:C}),i?h.cloneElement(h.Children.only(a),Cn(Cn({},E),{ref:T})):h.createElement(b,Cn({},E,{className:l,ref:T}),a))});vs.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},vs.classNames={fullWidth:xs,zeroRight:gs};var Xy=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Jy(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Xy();return t&&e.setAttribute("nonce",t),e}function Zy(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Qy(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var e0=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Jy())&&(Zy(t,n),Qy(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},t0=function(){var e=e0();return function(t,n){h.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},nf=function(){var e=t0(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},n0={left:0,top:0,right:0,gap:0},Ta=function(e){return parseInt(e||"",10)||0},r0=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],o=t[e==="padding"?"paddingRight":"marginRight"];return[Ta(n),Ta(r),Ta(o)]},o0=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return n0;var t=r0(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},s0=nf(),Rr="data-scroll-locked",i0=function(e,t,n,r){var o=e.left,s=e.top,i=e.right,a=e.gap;return n===void 0&&(n="margin"),`
|
|
40
40
|
.`.concat(zy,` {
|
|
41
41
|
overflow: hidden `).concat(r,`;
|
|
42
42
|
padding-right: `).concat(a,"px ").concat(r,`;
|
|
@@ -73,39 +73,39 @@ React keys must be passed directly to JSX without using spread:
|
|
|
73
73
|
body[`).concat(Rr,`] {
|
|
74
74
|
`).concat(Hy,": ").concat(a,`px;
|
|
75
75
|
}
|
|
76
|
-
`)},rf=function(){var e=parseInt(document.body.getAttribute(Rr)||"0",10);return isFinite(e)?e:0},a0=function(){h.useEffect(function(){return document.body.setAttribute(Rr,(rf()+1).toString()),function(){var e=rf()-1;e<=0?document.body.removeAttribute(Rr):document.body.setAttribute(Rr,e.toString())}},[])},l0=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;a0();var s=h.useMemo(function(){return o0(o)},[o]);return h.createElement(s0,{styles:i0(s,!t,o,n?"":"!important")})},ka=!1;if(typeof window<"u")try{var ws=Object.defineProperty({},"passive",{get:function(){return ka=!0,!0}});window.addEventListener("test",ws,ws),window.removeEventListener("test",ws,ws)}catch{ka=!1}var Mr=ka?{passive:!1}:!1,c0=function(e){return e.tagName==="TEXTAREA"},of=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!c0(e)&&n[t]==="visible")},u0=function(e){return of(e,"overflowY")},d0=function(e){return of(e,"overflowX")},sf=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=af(e,r);if(o){var s=lf(e,r),i=s[1],a=s[2];if(i>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},f0=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},p0=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},af=function(e,t){return e==="v"?u0(t):d0(t)},lf=function(e,t){return e==="v"?f0(t):p0(t)},h0=function(e,t){return e==="h"&&t==="rtl"?-1:1},m0=function(e,t,n,r,o){var s=h0(e,window.getComputedStyle(t).direction),i=s*r,a=n.target,
|
|
76
|
+
`)},rf=function(){var e=parseInt(document.body.getAttribute(Rr)||"0",10);return isFinite(e)?e:0},a0=function(){h.useEffect(function(){return document.body.setAttribute(Rr,(rf()+1).toString()),function(){var e=rf()-1;e<=0?document.body.removeAttribute(Rr):document.body.setAttribute(Rr,e.toString())}},[])},l0=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;a0();var s=h.useMemo(function(){return o0(o)},[o]);return h.createElement(s0,{styles:i0(s,!t,o,n?"":"!important")})},ka=!1;if(typeof window<"u")try{var ws=Object.defineProperty({},"passive",{get:function(){return ka=!0,!0}});window.addEventListener("test",ws,ws),window.removeEventListener("test",ws,ws)}catch{ka=!1}var Mr=ka?{passive:!1}:!1,c0=function(e){return e.tagName==="TEXTAREA"},of=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!c0(e)&&n[t]==="visible")},u0=function(e){return of(e,"overflowY")},d0=function(e){return of(e,"overflowX")},sf=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=af(e,r);if(o){var s=lf(e,r),i=s[1],a=s[2];if(i>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},f0=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},p0=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},af=function(e,t){return e==="v"?u0(t):d0(t)},lf=function(e,t){return e==="v"?f0(t):p0(t)},h0=function(e,t){return e==="h"&&t==="rtl"?-1:1},m0=function(e,t,n,r,o){var s=h0(e,window.getComputedStyle(t).direction),i=s*r,a=n.target,l=t.contains(a),c=!1,d=i>0,p=0,m=0;do{if(!a)break;var f=lf(e,a),v=f[0],g=f[1],x=f[2],y=g-x-s*v;(v||y)&&af(e,a)&&(p+=y,m+=v);var b=a.parentNode;a=b&&b.nodeType===Node.DOCUMENT_FRAGMENT_NODE?b.host:b}while(!l&&a!==document.body||l&&(t.contains(a)||t===a));return(d&&Math.abs(p)<1||!d&&Math.abs(m)<1)&&(c=!0),c},bs=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},cf=function(e){return[e.deltaX,e.deltaY]},uf=function(e){return e&&"current"in e?e.current:e},g0=function(e,t){return e[0]===t[0]&&e[1]===t[1]},x0=function(e){return`
|
|
77
77
|
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
78
78
|
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
79
|
-
`)},v0=0,Or=[];function w0(e){var t=h.useRef([]),n=h.useRef([0,0]),r=h.useRef(),o=h.useState(v0++)[0],s=h.useState(nf)[0],i=h.useRef(e);h.useEffect(function(){i.current=e},[e]),h.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var g=By([e.lockRef.current],(e.shards||[]).map(uf),!0).filter(Boolean);return g.forEach(function(x){return x.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),g.forEach(function(x){return x.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var a=h.useCallback(function(g,x){if("touches"in g&&g.touches.length===2||g.type==="wheel"&&g.ctrlKey)return!i.current.allowPinchZoom;var y=bs(g),b=n.current,C="deltaX"in g?g.deltaX:b[0]-y[0],k="deltaY"in g?g.deltaY:b[1]-y[1],S,T=g.target,E=Math.abs(C)>Math.abs(k)?"h":"v";if("touches"in g&&E==="h"&&T.type==="range")return!1;var A=sf(E,T);if(!A)return!0;if(A?S=E:(S=E==="v"?"h":"v",A=sf(E,T)),!A)return!1;if(!r.current&&"changedTouches"in g&&(C||k)&&(r.current=S),!S)return!0;var j=r.current||S;return m0(j,x,g,j==="h"?C:k)},[]),c=h.useCallback(function(g){var x=g;if(!(!Or.length||Or[Or.length-1]!==s)){var y="deltaY"in x?cf(x):bs(x),b=t.current.filter(function(S){return S.name===x.type&&(S.target===x.target||x.target===S.shadowParent)&&g0(S.delta,y)})[0];if(b&&b.should){x.cancelable&&x.preventDefault();return}if(!b){var C=(i.current.shards||[]).map(uf).filter(Boolean).filter(function(S){return S.contains(x.target)}),k=C.length>0?a(x,C[0]):!i.current.noIsolation;k&&x.cancelable&&x.preventDefault()}}},[]),l=h.useCallback(function(g,x,y,b){var C={name:g,delta:x,target:y,should:b,shadowParent:b0(y)};t.current.push(C),setTimeout(function(){t.current=t.current.filter(function(k){return k!==C})},1)},[]),d=h.useCallback(function(g){n.current=bs(g),r.current=void 0},[]),p=h.useCallback(function(g){l(g.type,cf(g),g.target,a(g,e.lockRef.current))},[]),m=h.useCallback(function(g){l(g.type,bs(g),g.target,a(g,e.lockRef.current))},[]);h.useEffect(function(){return Or.push(s),e.setCallbacks({onScrollCapture:p,onWheelCapture:p,onTouchMoveCapture:m}),document.addEventListener("wheel",c,Mr),document.addEventListener("touchmove",c,Mr),document.addEventListener("touchstart",d,Mr),function(){Or=Or.filter(function(g){return g!==s}),document.removeEventListener("wheel",c,Mr),document.removeEventListener("touchmove",c,Mr),document.removeEventListener("touchstart",d,Mr)}},[]);var f=e.removeScrollBar,v=e.inert;return h.createElement(h.Fragment,null,v?h.createElement(s,{styles:x0(o)}):null,f?h.createElement(l0,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function b0(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const y0=Yy(tf,w0);var ys=h.forwardRef(function(e,t){return h.createElement(vs,Cn({},e,{ref:t,sideCar:y0}))});ys.classNames=vs.classNames;var Ea=["Enter"," "],S0=["ArrowDown","PageUp","Home"],df=["ArrowUp","PageDown","End"],C0=[...S0,...df],T0={ltr:[...Ea,"ArrowRight"],rtl:[...Ea,"ArrowLeft"]},k0={ltr:["ArrowLeft"],rtl:["ArrowRight"]},fo="Menu",[po,E0,I0]=es(fo),[rr,ff]=cn(fo,[I0,jr,Kd]),Ss=jr(),pf=Kd(),[N0,or]=rr(fo),[A0,ho]=rr(fo),hf=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=Ss(t),[c,l]=h.useState(null),d=h.useRef(!1),p=pt(s),m=ts(o);return h.useEffect(()=>{const f=()=>{d.current=!0,document.addEventListener("pointerdown",v,{capture:!0,once:!0}),document.addEventListener("pointermove",v,{capture:!0,once:!0})},v=()=>d.current=!1;return document.addEventListener("keydown",f,{capture:!0}),()=>{document.removeEventListener("keydown",f,{capture:!0}),document.removeEventListener("pointerdown",v,{capture:!0}),document.removeEventListener("pointermove",v,{capture:!0})}},[]),u.jsx(ha,{...a,children:u.jsx(N0,{scope:t,open:n,onOpenChange:p,content:c,onContentChange:l,children:u.jsx(A0,{scope:t,onClose:h.useCallback(()=>p(!1),[p]),isUsingKeyboardRef:d,dir:m,modal:i,children:r})})})};hf.displayName=fo;var P0="MenuAnchor",Ia=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=Ss(n);return u.jsx(ma,{...o,...r,ref:t})});Ia.displayName=P0;var Na="MenuPortal",[j0,mf]=rr(Na,{forceMount:void 0}),gf=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=or(Na,t);return u.jsx(j0,{scope:t,forceMount:n,children:u.jsx(Ht,{present:n||s.open,children:u.jsx(co,{asChild:!0,container:o,children:r})})})};gf.displayName=Na;var en="MenuContent",[_0,Aa]=rr(en),xf=h.forwardRef((e,t)=>{const n=mf(en,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=or(en,e.__scopeMenu),i=ho(en,e.__scopeMenu);return u.jsx(po.Provider,{scope:e.__scopeMenu,children:u.jsx(Ht,{present:r||s.open,children:u.jsx(po.Slot,{scope:e.__scopeMenu,children:i.modal?u.jsx(R0,{...o,ref:t}):u.jsx(M0,{...o,ref:t})})})})}),R0=h.forwardRef((e,t)=>{const n=or(en,e.__scopeMenu),r=h.useRef(null),o=je(t,r);return h.useEffect(()=>{const s=r.current;if(s)return ya(s)},[]),u.jsx(Pa,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:ae(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),M0=h.forwardRef((e,t)=>{const n=or(en,e.__scopeMenu);return u.jsx(Pa,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),O0=qt.createSlot("MenuContent.ScrollLock"),Pa=h.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEntryFocus:c,onEscapeKeyDown:l,onPointerDownOutside:d,onFocusOutside:p,onInteractOutside:m,onDismiss:f,disableOutsideScroll:v,...g}=e,x=or(en,n),y=ho(en,n),b=Ss(n),C=pf(n),k=E0(n),[S,T]=h.useState(null),E=h.useRef(null),A=je(t,E,x.onContentChange),j=h.useRef(0),L=h.useRef(""),H=h.useRef(0),V=h.useRef(null),J=h.useRef("right"),R=h.useRef(0),G=v?ys:h.Fragment,K=v?{as:O0,allowPinchZoom:!0}:void 0,$=I=>{var O,D;const U=L.current+I,Z=k().filter(B=>!B.disabled),M=document.activeElement,Y=(O=Z.find(B=>B.ref.current===M))==null?void 0:O.textValue,_=Z.map(B=>B.textValue),z=q0(_,U,Y),W=(D=Z.find(B=>B.textValue===z))==null?void 0:D.ref.current;(function B(Q){L.current=Q,window.clearTimeout(j.current),Q!==""&&(j.current=window.setTimeout(()=>B(""),1e3))})(U),W&&setTimeout(()=>W.focus())};h.useEffect(()=>()=>window.clearTimeout(j.current),[]),Zi();const P=h.useCallback(I=>{var Z,M;return J.current===((Z=V.current)==null?void 0:Z.side)&&Y0(I,(M=V.current)==null?void 0:M.area)},[]);return u.jsx(_0,{scope:n,searchRef:L,onItemEnter:h.useCallback(I=>{P(I)&&I.preventDefault()},[P]),onItemLeave:h.useCallback(I=>{var U;P(I)||((U=E.current)==null||U.focus(),T(null))},[P]),onTriggerLeave:h.useCallback(I=>{P(I)&&I.preventDefault()},[P]),pointerGraceTimerRef:H,onPointerGraceIntentChange:h.useCallback(I=>{V.current=I},[]),children:u.jsx(G,{...K,children:u.jsx(ns,{asChild:!0,trapped:o,onMountAutoFocus:ae(s,I=>{var U;I.preventDefault(),(U=E.current)==null||U.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:u.jsx(Er,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:l,onPointerDownOutside:d,onFocusOutside:p,onInteractOutside:m,onDismiss:f,children:u.jsx(Oy,{asChild:!0,...C,dir:y.dir,orientation:"vertical",loop:r,currentTabStopId:S,onCurrentTabStopIdChange:T,onEntryFocus:ae(c,I=>{y.isUsingKeyboardRef.current||I.preventDefault()}),preventScrollOnEntryFocus:!0,children:u.jsx(ga,{role:"menu","aria-orientation":"vertical","data-state":Mf(x.open),"data-radix-menu-content":"",dir:y.dir,...b,...g,ref:A,style:{outline:"none",...g.style},onKeyDown:ae(g.onKeyDown,I=>{const Z=I.target.closest("[data-radix-menu-content]")===I.currentTarget,M=I.ctrlKey||I.altKey||I.metaKey,Y=I.key.length===1;Z&&(I.key==="Tab"&&I.preventDefault(),!M&&Y&&$(I.key));const _=E.current;if(I.target!==_||!C0.includes(I.key))return;I.preventDefault();const W=k().filter(O=>!O.disabled).map(O=>O.ref.current);df.includes(I.key)&&W.reverse(),V0(W)}),onBlur:ae(e.onBlur,I=>{I.currentTarget.contains(I.target)||(window.clearTimeout(j.current),L.current="")}),onPointerMove:ae(e.onPointerMove,go(I=>{const U=I.target,Z=R.current!==I.clientX;if(I.currentTarget.contains(U)&&Z){const M=I.clientX>R.current?"right":"left";J.current=M,R.current=I.clientX}}))})})})})})})});xf.displayName=en;var D0="MenuGroup",ja=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(he.div,{role:"group",...r,ref:t})});ja.displayName=D0;var L0="MenuLabel",vf=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(he.div,{...r,ref:t})});vf.displayName=L0;var Cs="MenuItem",wf="menu.itemSelect",Ts=h.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=h.useRef(null),i=ho(Cs,e.__scopeMenu),a=Aa(Cs,e.__scopeMenu),c=je(t,s),l=h.useRef(!1),d=()=>{const p=s.current;if(!n&&p){const m=new CustomEvent(wf,{bubbles:!0,cancelable:!0});p.addEventListener(wf,f=>r==null?void 0:r(f),{once:!0}),Yi(p,m),m.defaultPrevented?l.current=!1:i.onClose()}};return u.jsx(bf,{...o,ref:c,disabled:n,onClick:ae(e.onClick,d),onPointerDown:p=>{var m;(m=e.onPointerDown)==null||m.call(e,p),l.current=!0},onPointerUp:ae(e.onPointerUp,p=>{var m;l.current||(m=p.currentTarget)==null||m.click()}),onKeyDown:ae(e.onKeyDown,p=>{const m=a.searchRef.current!=="";n||m&&p.key===" "||Ea.includes(p.key)&&(p.currentTarget.click(),p.preventDefault())})})});Ts.displayName=Cs;var bf=h.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=Aa(Cs,n),a=pf(n),c=h.useRef(null),l=je(t,c),[d,p]=h.useState(!1),[m,f]=h.useState("");return h.useEffect(()=>{const v=c.current;v&&f((v.textContent??"").trim())},[s.children]),u.jsx(po.ItemSlot,{scope:n,disabled:r,textValue:o??m,children:u.jsx(Dy,{asChild:!0,...a,focusable:!r,children:u.jsx(he.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:l,onPointerMove:ae(e.onPointerMove,go(v=>{r?i.onItemLeave(v):(i.onItemEnter(v),v.defaultPrevented||v.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:ae(e.onPointerLeave,go(v=>i.onItemLeave(v))),onFocus:ae(e.onFocus,()=>p(!0)),onBlur:ae(e.onBlur,()=>p(!1))})})})}),$0="MenuCheckboxItem",yf=h.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return u.jsx(Ef,{scope:e.__scopeMenu,checked:n,children:u.jsx(Ts,{role:"menuitemcheckbox","aria-checked":ks(n)?"mixed":n,...o,ref:t,"data-state":Ra(n),onSelect:ae(o.onSelect,()=>r==null?void 0:r(ks(n)?!0:!n),{checkForDefaultPrevented:!1})})})});yf.displayName=$0;var Sf="MenuRadioGroup",[F0,B0]=rr(Sf,{value:void 0,onValueChange:()=>{}}),Cf=h.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=pt(r);return u.jsx(F0,{scope:e.__scopeMenu,value:n,onValueChange:s,children:u.jsx(ja,{...o,ref:t})})});Cf.displayName=Sf;var Tf="MenuRadioItem",kf=h.forwardRef((e,t)=>{const{value:n,...r}=e,o=B0(Tf,e.__scopeMenu),s=n===o.value;return u.jsx(Ef,{scope:e.__scopeMenu,checked:s,children:u.jsx(Ts,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":Ra(s),onSelect:ae(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});kf.displayName=Tf;var _a="MenuItemIndicator",[Ef,z0]=rr(_a,{checked:!1}),If=h.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=z0(_a,n);return u.jsx(Ht,{present:r||ks(s.checked)||s.checked===!0,children:u.jsx(he.span,{...o,ref:t,"data-state":Ra(s.checked)})})});If.displayName=_a;var H0="MenuSeparator",Nf=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(he.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});Nf.displayName=H0;var U0="MenuArrow",Af=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=Ss(n);return u.jsx(xa,{...o,...r,ref:t})});Af.displayName=U0;var W0="MenuSub",[FN,Pf]=rr(W0),mo="MenuSubTrigger",jf=h.forwardRef((e,t)=>{const n=or(mo,e.__scopeMenu),r=ho(mo,e.__scopeMenu),o=Pf(mo,e.__scopeMenu),s=Aa(mo,e.__scopeMenu),i=h.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:c}=s,l={__scopeMenu:e.__scopeMenu},d=h.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return h.useEffect(()=>d,[d]),h.useEffect(()=>{const p=a.current;return()=>{window.clearTimeout(p),c(null)}},[a,c]),u.jsx(Ia,{asChild:!0,...l,children:u.jsx(bf,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":Mf(n.open),...e,ref:Mn(t,o.onTriggerChange),onClick:p=>{var m;(m=e.onClick)==null||m.call(e,p),!(e.disabled||p.defaultPrevented)&&(p.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:ae(e.onPointerMove,go(p=>{s.onItemEnter(p),!p.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(s.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),d()},100))})),onPointerLeave:ae(e.onPointerLeave,go(p=>{var f,v;d();const m=(f=n.content)==null?void 0:f.getBoundingClientRect();if(m){const g=(v=n.content)==null?void 0:v.dataset.side,x=g==="right",y=x?-5:5,b=m[x?"left":"right"],C=m[x?"right":"left"];s.onPointerGraceIntentChange({area:[{x:p.clientX+y,y:p.clientY},{x:b,y:m.top},{x:C,y:m.top},{x:C,y:m.bottom},{x:b,y:m.bottom}],side:g}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(p),p.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:ae(e.onKeyDown,p=>{var f;const m=s.searchRef.current!=="";e.disabled||m&&p.key===" "||T0[r.dir].includes(p.key)&&(n.onOpenChange(!0),(f=n.content)==null||f.focus(),p.preventDefault())})})})});jf.displayName=mo;var _f="MenuSubContent",Rf=h.forwardRef((e,t)=>{const n=mf(en,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=or(en,e.__scopeMenu),i=ho(en,e.__scopeMenu),a=Pf(_f,e.__scopeMenu),c=h.useRef(null),l=je(t,c);return u.jsx(po.Provider,{scope:e.__scopeMenu,children:u.jsx(Ht,{present:r||s.open,children:u.jsx(po.Slot,{scope:e.__scopeMenu,children:u.jsx(Pa,{id:a.contentId,"aria-labelledby":a.triggerId,...o,ref:l,align:"start",side:i.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:d=>{var p;i.isUsingKeyboardRef.current&&((p=c.current)==null||p.focus()),d.preventDefault()},onCloseAutoFocus:d=>d.preventDefault(),onFocusOutside:ae(e.onFocusOutside,d=>{d.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:ae(e.onEscapeKeyDown,d=>{i.onClose(),d.preventDefault()}),onKeyDown:ae(e.onKeyDown,d=>{var f;const p=d.currentTarget.contains(d.target),m=k0[i.dir].includes(d.key);p&&m&&(s.onOpenChange(!1),(f=a.trigger)==null||f.focus(),d.preventDefault())})})})})})});Rf.displayName=_f;function Mf(e){return e?"open":"closed"}function ks(e){return e==="indeterminate"}function Ra(e){return ks(e)?"indeterminate":e?"checked":"unchecked"}function V0(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function K0(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function q0(e,t,n){const o=t.length>1&&Array.from(t).every(l=>l===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=K0(e,Math.max(s,0));o.length===1&&(i=i.filter(l=>l!==n));const c=i.find(l=>l.toLowerCase().startsWith(o.toLowerCase()));return c!==n?c:void 0}function G0(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const a=t[s],c=t[i],l=a.x,d=a.y,p=c.x,m=c.y;d>r!=m>r&&n<(p-l)*(r-d)/(m-d)+l&&(o=!o)}return o}function Y0(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return G0(n,t)}function go(e){return t=>t.pointerType==="mouse"?e(t):void 0}var X0=hf,J0=Ia,Z0=gf,Q0=xf,eS=ja,tS=vf,nS=Ts,rS=yf,oS=Cf,sS=kf,iS=If,aS=Nf,lS=Af,cS=jf,uS=Rf,Es="DropdownMenu",[dS,BN]=cn(Es,[ff]),Dt=ff(),[fS,Of]=dS(Es),Df=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,c=Dt(t),l=h.useRef(null),[d,p]=On({prop:o,defaultProp:s??!1,onChange:i,caller:Es});return u.jsx(fS,{scope:t,triggerId:jt(),triggerRef:l,contentId:jt(),open:d,onOpenChange:p,onOpenToggle:h.useCallback(()=>p(m=>!m),[p]),modal:a,children:u.jsx(X0,{...c,open:d,onOpenChange:p,dir:r,modal:a,children:n})})};Df.displayName=Es;var Lf="DropdownMenuTrigger",$f=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=Of(Lf,n),i=Dt(n);return u.jsx(J0,{asChild:!0,...i,children:u.jsx(he.button,{type:"button",id:s.triggerId,"aria-haspopup":"menu","aria-expanded":s.open,"aria-controls":s.open?s.contentId:void 0,"data-state":s.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...o,ref:Mn(t,s.triggerRef),onPointerDown:ae(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:ae(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});$f.displayName=Lf;var pS="DropdownMenuPortal",Ff=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Dt(t);return u.jsx(Z0,{...r,...n})};Ff.displayName=pS;var Bf="DropdownMenuContent",zf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Of(Bf,n),s=Dt(n),i=h.useRef(!1);return u.jsx(Q0,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:ae(e.onCloseAutoFocus,a=>{var c;i.current||(c=o.triggerRef.current)==null||c.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:ae(e.onInteractOutside,a=>{const c=a.detail.originalEvent,l=c.button===0&&c.ctrlKey===!0,d=c.button===2||l;(!o.modal||d)&&(i.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});zf.displayName=Bf;var hS="DropdownMenuGroup",mS=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(eS,{...o,...r,ref:t})});mS.displayName=hS;var gS="DropdownMenuLabel",Hf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(tS,{...o,...r,ref:t})});Hf.displayName=gS;var xS="DropdownMenuItem",Uf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(nS,{...o,...r,ref:t})});Uf.displayName=xS;var vS="DropdownMenuCheckboxItem",Wf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(rS,{...o,...r,ref:t})});Wf.displayName=vS;var wS="DropdownMenuRadioGroup",bS=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(oS,{...o,...r,ref:t})});bS.displayName=wS;var yS="DropdownMenuRadioItem",Vf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(sS,{...o,...r,ref:t})});Vf.displayName=yS;var SS="DropdownMenuItemIndicator",Kf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(iS,{...o,...r,ref:t})});Kf.displayName=SS;var CS="DropdownMenuSeparator",qf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(aS,{...o,...r,ref:t})});qf.displayName=CS;var TS="DropdownMenuArrow",kS=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(lS,{...o,...r,ref:t})});kS.displayName=TS;var ES="DropdownMenuSubTrigger",Gf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(cS,{...o,...r,ref:t})});Gf.displayName=ES;var IS="DropdownMenuSubContent",Yf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Dt(n);return u.jsx(uS,{...o,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Yf.displayName=IS;var NS=Df,AS=$f,PS=Ff,Xf=zf,Jf=Hf,Zf=Uf,Qf=Wf,ep=Vf,tp=Kf,np=qf,rp=Gf,op=Yf;const Is=NS,Ns=AS,jS=h.forwardRef(({className:e,inset:t,children:n,...r},o)=>u.jsxs(rp,{ref:o,className:ne("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",t&&"pl-8",e),...r,children:[n,u.jsx(le.ChevronRight,{className:"ml-auto h-4 w-4"})]}));jS.displayName=rp.displayName;const _S=h.forwardRef(({className:e,...t},n)=>u.jsx(op,{ref:n,className:ne("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...t}));_S.displayName=op.displayName;const xo=h.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(PS,{children:u.jsx(Xf,{ref:r,sideOffset:t,className:ne("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n})}));xo.displayName=Xf.displayName;const Fn=h.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(Zf,{ref:r,className:ne("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...n}));Fn.displayName=Zf.displayName;const RS=h.forwardRef(({className:e,children:t,checked:n,...r},o)=>u.jsxs(Qf,{ref:o,className:ne("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:n,...r,children:[u.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx(tp,{children:u.jsx(le.Check,{className:"h-4 w-4"})})}),t]}));RS.displayName=Qf.displayName;const MS=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(ep,{ref:r,className:ne("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[u.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx(tp,{children:u.jsx(le.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));MS.displayName=ep.displayName;const OS=h.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(Jf,{ref:r,className:ne("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));OS.displayName=Jf.displayName;const DS=h.forwardRef(({className:e,...t},n)=>u.jsx(np,{ref:n,className:ne("-mx-1 my-1 h-px bg-muted",e),...t}));DS.displayName=np.displayName;const Ma=h.forwardRef(({className:e,...t},n)=>u.jsx("textarea",{className:ne("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),ref:n,...t}));Ma.displayName="Textarea";const LS=1e4;function sp({initialValue:e="",editingMessageId:t=null,placeholder:n="Type your message...",isStreaming:r=!1,disabled:o=!1,maxLength:s=LS,value:i,onValueChange:a,onSend:c,onCancelEdit:l,onStop:d,className:p="",textareaClassName:m="",allowEmptySend:f=!1,sendButtonClassName:v,validate:g,onValidationError:x}){const y=i!==void 0,[b,C]=w.useState(e),k=(y?i:b)??"",[S,T]=w.useTransition(),E=w.useRef(null),A=w.useRef(0),j=w.useRef(null),L=w.useRef("");w.useEffect(()=>{y||(C(e??""),j.current=null,E.current&&(E.current.style.height="auto",E.current.style.height=`${E.current.scrollHeight}px`))},[e,t,y]);const[H,V]=w.useState(null),J=w.useCallback(_=>_.length>s?`Message too long (${_.length}/${s} characters)`:null,[s]),R=w.useMemo(()=>g??J,[g,J]),G=w.useCallback(_=>{const z=R(_);return V(z),x==null||x(z),L.current=_,z},[R,x]),K=w.useCallback(()=>{const _=E.current;_&&(_.style.height="auto",_.style.height=`${_.scrollHeight}px`)},[]);w.useEffect(()=>{K()},[K,k]),w.useEffect(()=>{if(!H)return;const _=(k??"").trim();L.current!==_&&G(_)},[k,H,G]);const $=w.useCallback((_,{fromUser:z})=>{y||C(_),z&&(a==null||a(_))},[y,a]),P=w.useCallback(async _=>{_&&_.preventDefault();const z=(k??"").trim();if(!z&&!f||G(z))return;const W=++A.current;j.current={id:W,shouldClear:!0},T(()=>{var O,D,B;try{const Q=c(z);Q&&typeof Q.then=="function"?Q.then(()=>{var oe,ie;((oe=j.current)==null?void 0:oe.id)===W&&j.current.shouldClear&&(y||(C(""),E.current&&(E.current.style.height="auto"),a==null||a(""))),((ie=j.current)==null?void 0:ie.id)===W&&(j.current=null)}).catch(()=>{var oe;((oe=j.current)==null?void 0:oe.id)===W&&(j.current=null)}):(((O=j.current)==null?void 0:O.id)===W&&j.current.shouldClear&&(y||(C(""),E.current&&(E.current.style.height="auto"),a==null||a(""))),((D=j.current)==null?void 0:D.id)===W&&(j.current=null))}catch{((B=j.current)==null?void 0:B.id)===W&&(j.current=null)}})},[k,c,f,y,a,G]),I=w.useCallback(_=>{const z=_.target.value;$(z,{fromUser:!0}),j.current&&(j.current.shouldClear=!1),E.current&&(E.current.style.height="auto",E.current.style.height=`${E.current.scrollHeight}px`),H&&G(z.trim())},[$,G,H]),U=w.useCallback(_=>{_.key==="Enter"&&!_.shiftKey?(_.preventDefault(),P()):_.key==="Escape"&&t&&(_.preventDefault(),l==null||l())},[P,t,l]),Y=`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:_=>void P(_),className:`w-full ${p}`,children:u.jsxs("div",{className:"flex items-end gap-2",children:[u.jsxs("div",{className:"flex-1",children:[u.jsx(Ma,{ref:E,value:k,onChange:I,onKeyDown:U,placeholder:t?"Edit your message...":n,className:Y,disabled:o,maxLength:s,rows:1,spellCheck:!1,autoCorrect:"off"}),H&&u.jsx("p",{className:"mt-1 text-xs text-destructive font-medium",children:H})]}),u.jsx("div",{children:r?u.jsx(Ye,{type:"button",onClick:()=>{d==null||d()},size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",disabled:o||!d,children:u.jsx(le.Square,{size:16})}):u.jsx(Ye,{type:"submit",size:"icon",className:`shrink-0 ${v??""}`,title:t?"Save changes":"Send message",disabled:o||!k.trim()&&!f||S,children:u.jsx(le.Send,{size:16})})})]})})}const $S=w.memo(sp);function ip({composerValue:e,onComposerChange:t,onSend:n,onCancelEdit:r,onStop:o,editingMessageId:s=null,editingInitialValue:i="",placeholder:a="Type your message...",isStreaming:c=!1,disabled:l=!1,textareaClassName:d="",customStyles:p={},enableFileUpload:m=!1,enableExcelUpload:f=!1,onExcelUpload:v,onError:g,allowEmptySend:x=!1,inputError:y=null}){const[b,C]=w.useState([]),k=w.useRef(null),S=w.useRef(null),[T,E]=w.useState(0),[A,j]=w.useState(0),[L,H]=w.useState(!1),[V,J]=w.useState(null),[R,G]=w.useState(null),K=w.useCallback(()=>{k.current&&(k.current.value=""),S.current&&(S.current.value=""),E(_=>_+1),j(_=>_+1)},[]),$=w.useCallback(_=>{C(z=>[...z,..._])},[]),P=w.useCallback(_=>{const z=Array.from(_.target.files||[]);$(z),_.target.value=""},[$]),I=w.useCallback(_=>{C(z=>{const W=z.filter((O,D)=>D!==_);return W.length===0&&K(),W})},[K]),U=w.useCallback(async _=>{const z=(_.target.files||[])[0];if(z&&(J(null),G(null),!!v)){H(!0);try{await v(z),J(`Uploaded ${z.name} - processing through chat stream`)}catch(W){const O=W instanceof Error?W.message:"Failed to upload Excel file";G(O),g==null||g(O)}finally{H(!1),_.target.value="",K()}}},[v,g,K]),Z=w.useMemo(()=>x||b.length>0,[x,b]),M=w.useCallback(async _=>{const W=await n(_,b);return b.length>0&&(C([]),K()),W},[n,K,b]),Y=`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${s?"border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50":""} ${y?"border-red-400":""} ${p.textarea||""} ${d}`;return u.jsxs(u.Fragment,{children:[(m||f)&&u.jsxs("div",{className:"mb-3 space-y-3",children:[m&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:k,type:"file",multiple:!0,onChange:P,className:"hidden"},T),b.length>0&&u.jsx("div",{className:"flex flex-wrap gap-2",children:b.map((_,z)=>u.jsxs("div",{className:"flex items-center gap-2 bg-gray-100 dark:bg-gray-800 rounded-lg px-3 py-2 text-sm text-gray-900 dark:text-gray-100",children:[u.jsx(le.Paperclip,{size:14}),u.jsx("span",{className:"truncate max-w-[150px]",children:_.name}),u.jsx(Ye,{variant:"ghost",size:"sm",onClick:()=>I(z),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 ${_.name}`,children:u.jsx(le.X,{size:12})})]},z))})]}),f&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:S,type:"file",accept:".xls,.xlsx,.xlsm",onChange:U,className:"hidden"},A),L&&u.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(le.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),V&&!L&&u.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:V}),R&&!L&&u.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:R})]})]}),u.jsxs("div",{className:"flex items-end gap-2",children:[(m||f)&&u.jsxs(Is,{children:[u.jsx(Ns,{asChild:!0,children:u.jsx(Ye,{type:"button",size:"icon",variant:"outline",disabled:c||l,title:"More input actions",className:p.moreButton||"",children:u.jsx(le.Plus,{size:16})})}),u.jsxs(xo,{align:"start",sideOffset:6,className:"w-52",children:[m&&u.jsxs(Fn,{onClick:()=>{var _;return(_=k.current)==null?void 0:_.click()},className:"cursor-pointer",children:[u.jsx(le.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),f&&u.jsxs(Fn,{onClick:()=>{var _;L||(_=S.current)==null||_.click()},className:`cursor-pointer ${L?"opacity-60 pointer-events-none":""}`,children:[u.jsx(le.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),u.jsx("div",{className:"flex-1",children:u.jsx($S,{initialValue:i,editingMessageId:s,value:e,onValueChange:t,placeholder:s?"Edit your message...":a,isStreaming:c,disabled:l,onSend:M,onCancelEdit:r,onStop:o,allowEmptySend:Z,textareaClassName:Y,sendButtonClassName:p.sendButton})})]})]})}const FS=w.memo(ip),As=0,Bn=1,Dr=2,ap=4;function lp(e){return()=>e}function BS(e){e()}function cp(e,t){return n=>e(t(n))}function up(e,t){return()=>e(t)}function zS(e,t){return n=>e(t,n)}function Oa(e){return e!==void 0}function HS(...e){return()=>{e.map(BS)}}function Lr(){}function Ps(e,t){return t(e),e}function US(e,t){return t(e)}function rt(...e){return e}function Xe(e,t){return e(Bn,t)}function Ne(e,t){e(As,t)}function Da(e){e(Dr)}function ht(e){return e(ap)}function me(e,t){return Xe(e,zS(t,As))}function fn(e,t){const n=e(Bn,r=>{n(),t(r)});return n}function dp(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function fp(e,t){return e===t}function ot(e=fp){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function Se(e){return t=>n=>{e(n)&&t(n)}}function ce(e){return t=>cp(t,e)}function Tn(e){return t=>()=>{t(e)}}function te(e,...t){const n=WS(...t);return(r,o)=>{switch(r){case Dr:Da(e);return;case Bn:return Xe(e,n(o))}}}function kn(e,t){return n=>r=>{n(t=e(t,r))}}function sr(e){return t=>n=>{e>0?e--:t(n)}}function jn(e){let t=null,n;return r=>o=>{t=o,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function _e(...e){const t=new Array(e.length);let n=0,r=null;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const a=Math.pow(2,i);Xe(s,c=>{const l=n;n=n|a,t[i]=c,l!==o&&n===o&&r&&(r(),r=null)})}),s=>i=>{const a=()=>{s([i].concat(t))};n===o?a():r=a}}function WS(...e){return t=>e.reduceRight(US,t)}function VS(e){let t,n;const r=()=>t==null?void 0:t();return function(o,s){switch(o){case Bn:return s?n===s?void 0:(r(),n=s,t=Xe(e,s),t):(r(),Lr);case Dr:r(),n=null;return}}}function se(e){let t=e;const n=Be();return(r,o)=>{switch(r){case As:t=o;break;case Bn:{o(t);break}case ap:return t}return n(r,o)}}function _t(e,t){return Ps(se(t),n=>me(e,n))}function Be(){const e=[];return(t,n)=>{switch(t){case As:e.slice().forEach(r=>{r(n)});return;case Dr:e.splice(0,e.length);return;case Bn:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}}}function Zt(e){return Ps(Be(),t=>me(e,t))}function Ke(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:KS(),singleton:n}}const KS=()=>Symbol();function qS(e){const t=new Map,n=({constructor:r,dependencies:o,id:s,singleton:i})=>{if(i&&t.has(s))return t.get(s);const a=r(o.map(c=>n(c)));return i&&t.set(s,a),a};return n(e)}function gt(...e){const t=Be(),n=new Array(e.length);let r=0;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const a=Math.pow(2,i);Xe(s,c=>{n[i]=c,r=r|a,r===o&&Ne(t,n)})}),function(s,i){switch(s){case Dr:{Da(t);return}case Bn:return r===o&&i(n),Xe(t,i)}}}function be(e,t=fp){return te(e,ot(t))}function La(...e){return function(t,n){switch(t){case Dr:return;case Bn:return HS(...e.map(r=>Xe(r,n)))}}}var Ut=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(Ut||{});const GS={0:"debug",3:"error",1:"log",2:"warn"},YS=()=>typeof globalThis>"u"?window:globalThis,zn=Ke(()=>{const e=se(3);return{log:se((t,n,r=1)=>{var o;const s=(o=YS().VIRTUOSO_LOG_LEVEL)!=null?o:ht(e);r>=s&&console[GS[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0});function ir(e,t,n){return $a(e,t,n).callbackRef}function $a(e,t,n){const r=w.useRef(null);let o=i=>{};const s=w.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(i=>{const a=()=>{const c=i[0].target;c.offsetParent!==null&&e(c)};n?a():requestAnimationFrame(a)}):null,[e,n]);return o=i=>{i&&t?(s==null||s.observe(i),r.current=i):(r.current&&(s==null||s.unobserve(r.current)),r.current=null)},{callbackRef:o,ref:r}}function XS(e,t,n,r,o,s,i,a,c){const l=w.useCallback(d=>{const p=JS(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?pp("column-gap",getComputedStyle(d).columnGap,o):pp("row-gap",getComputedStyle(d).rowGap,o)),p!==null&&e(p)},[e,t,o,s,i,r,a]);return $a(l,n,c)}function JS(e,t,n,r){const o=e.length;if(o===0)return null;const s=[];for(let i=0;i<o;i++){const a=e.item(i);if(a.dataset.index===void 0)continue;const c=parseInt(a.dataset.index),l=parseFloat(a.dataset.knownSize),d=t(a,n);if(d===0&&r("Zero-sized element, this should not happen",{child:a},Ut.ERROR),d===l)continue;const p=s[s.length-1];s.length===0||p.size!==d||p.endIndex!==c-1?s.push({endIndex:c,size:d,startIndex:c}):s[s.length-1].endIndex++}return s}function pp(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Ut.WARN),t==="normal"?0:parseInt(t??"0",10)}function hp(e,t,n){const r=w.useRef(null),o=w.useCallback(c=>{if(!(c!=null&&c.offsetParent))return;const l=c.getBoundingClientRect(),d=l.width;let p,m;if(t){const f=t.getBoundingClientRect(),v=l.top-f.top;m=f.height-Math.max(0,v),p=v+t.scrollTop}else{const f=i.current.ownerDocument.defaultView;m=f.innerHeight-Math.max(0,l.top),p=l.top+f.scrollY}r.current={offsetTop:p,visibleHeight:m,visibleWidth:d},e(r.current)},[e,t]),{callbackRef:s,ref:i}=$a(o,!0,n),a=w.useCallback(()=>{o(i.current)},[o,i]);return w.useEffect(()=>{var c;if(t){t.addEventListener("scroll",a);const l=new ResizeObserver(()=>{requestAnimationFrame(a)});return l.observe(t),()=>{t.removeEventListener("scroll",a),l.unobserve(t)}}else{const l=(c=i.current)==null?void 0:c.ownerDocument.defaultView;return l==null||l.addEventListener("scroll",a),l==null||l.addEventListener("resize",a),()=>{l==null||l.removeEventListener("scroll",a),l==null||l.removeEventListener("resize",a)}}},[a,t,i]),s}const Lt=Ke(()=>{const e=Be(),t=Be(),n=se(0),r=Be(),o=se(0),s=Be(),i=Be(),a=se(0),c=se(0),l=se(0),d=se(0),p=Be(),m=Be(),f=se(!1),v=se(!1),g=se(!1);return me(te(e,ce(({scrollTop:x})=>x)),t),me(te(e,ce(({scrollHeight:x})=>x)),i),me(t,o),{deviation:n,fixedFooterHeight:l,fixedHeaderHeight:c,footerHeight:d,headerHeight:a,horizontalDirection:v,scrollBy:m,scrollContainerState:e,scrollHeight:i,scrollingInProgress:f,scrollTo:p,scrollTop:t,skipAnimationFrameInResizeObserver:g,smoothScrollTargetReached:r,statefulScrollTop:o,viewportHeight:s}},[],{singleton:!0}),vo={lvl:0};function mp(e,t){const n=e.length;if(n===0)return[];let{index:r,value:o}=t(e[0]);const s=[];for(let i=1;i<n;i++){const{index:a,value:c}=t(e[i]);s.push({end:a-1,start:r,value:o}),r=a,o=c}return s.push({end:1/0,start:r,value:o}),s}function Ze(e){return e===vo}function wo(e,t){if(!Ze(e))return t===e.k?e.v:t<e.k?wo(e.l,t):wo(e.r,t)}function pn(e,t,n="k"){if(Ze(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){const r=pn(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return pn(e.l,t,n)}function Qt(e,t,n){return Ze(e)?vp(t,n,1):t===e.k?yt(e,{k:t,v:n}):t<e.k?wp(yt(e,{l:Qt(e.l,t,n)})):wp(yt(e,{r:Qt(e.r,t,n)}))}function $r(){return vo}function js(e,t,n){if(Ze(e))return[];const r=pn(e,t)[0];return ZS(Ba(e,r,n))}function Fa(e,t){if(Ze(e))return vo;const{k:n,l:r,r:o}=e;if(t===n){if(Ze(r))return o;if(Ze(o))return r;{const[s,i]=xp(r);return _s(yt(e,{k:s,l:gp(r),v:i}))}}else return t<n?_s(yt(e,{l:Fa(r,t)})):_s(yt(e,{r:Fa(o,t)}))}function ar(e){return Ze(e)?[]:[...ar(e.l),{k:e.k,v:e.v},...ar(e.r)]}function Ba(e,t,n){if(Ze(e))return[];const{k:r,l:o,r:s,v:i}=e;let a=[];return r>t&&(a=a.concat(Ba(o,t,n))),r>=t&&r<=n&&a.push({k:r,v:i}),r<=n&&(a=a.concat(Ba(s,t,n))),a}function _s(e){const{l:t,lvl:n,r}=e;if(r.lvl>=n-1&&t.lvl>=n-1)return e;if(n>r.lvl+1){if(za(t))return bp(yt(e,{lvl:n-1}));if(!Ze(t)&&!Ze(t.r))return yt(t.r,{l:yt(t,{r:t.r.l}),lvl:n,r:yt(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(za(e))return Ha(yt(e,{lvl:n-1}));if(!Ze(r)&&!Ze(r.l)){const o=r.l,s=za(o)?r.lvl-1:r.lvl;return yt(o,{l:yt(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:Ha(yt(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function yt(e,t){return vp(t.k!==void 0?t.k:e.k,t.v!==void 0?t.v:e.v,t.lvl!==void 0?t.lvl:e.lvl,t.l!==void 0?t.l:e.l,t.r!==void 0?t.r:e.r)}function gp(e){return Ze(e.r)?e.l:_s(yt(e,{r:gp(e.r)}))}function za(e){return Ze(e)||e.lvl>e.r.lvl}function xp(e){return Ze(e.r)?[e.k,e.v]:xp(e.r)}function vp(e,t,n,r=vo,o=vo){return{k:e,l:r,lvl:n,r:o,v:t}}function wp(e){return Ha(bp(e))}function bp(e){const{l:t}=e;return!Ze(t)&&t.lvl===e.lvl?yt(t,{r:yt(e,{l:t.r})}):e}function Ha(e){const{lvl:t,r:n}=e;return!Ze(n)&&!Ze(n.r)&&n.lvl===t&&n.r.lvl===t?yt(n,{l:yt(e,{r:n.l}),lvl:t+1}):e}function ZS(e){return mp(e,({k:t,v:n})=>({index:t,value:n}))}function yp(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function bo(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const Ua=Ke(()=>({recalcInProgress:se(!1)}),[],{singleton:!0});function Sp(e,t,n){return e[Rs(e,t,n)]}function Rs(e,t,n,r=0){let o=e.length-1;for(;r<=o;){const s=Math.floor((r+o)/2),i=e[s],a=n(i,t);if(a===0)return s;if(a===-1){if(o-r<2)return s-1;o=s-1}else{if(o===r)return s;r=s+1}}throw new Error(`Failed binary finding record in array - ${e.join(",")}, searched for ${t}`)}function QS(e,t,n,r){const o=Rs(e,t,r),s=Rs(e,n,r,o);return e.slice(o,s+1)}function Hn(e,t){return Math.round(e.getBoundingClientRect()[t])}function Ms(e){return!Ze(e.groupOffsetTree)}function Wa({index:e},t){return t===e?0:t<e?-1:1}function eC(){return{groupIndices:[],groupOffsetTree:$r(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:$r()}}function tC(e,t){let n=Ze(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),Ze(e)){e=Qt(e,0,s);continue}const a=js(e,i-1,o+1);if(a.some(lC(r)))continue;let c=!1,l=!1;for(const{end:d,start:p,value:m}of a)c?(o>=p||s===m)&&(e=Fa(e,p)):(l=m!==s,c=!0),d>o&&o>=p&&m!==s&&(e=Qt(e,o+1,m));l&&(e=Qt(e,i,s))}return[e,n]}function nC(e){return typeof e.groupIndex<"u"}function rC({offset:e},t){return t===e?0:t<e?-1:1}function yo(e,t,n){if(t.length===0)return 0;const{index:r,offset:o,size:s}=Sp(t,e,Wa),i=e-r,a=s*i+(i-1)*n+o;return a>0?a+n:a}function Cp(e,t){if(!Ms(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function Tp(e,t,n){if(nC(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=Cp(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function oC(e,t,n,r=0){return r>0&&(t=Math.max(t,Sp(e,r,Wa).offset)),mp(QS(e,t,n,rC),aC)}function sC(e,[t,n,r,o]){t.length>0&&r("received item sizes",t,Ut.DEBUG);const s=e.sizeTree;let i=s,a=0;if(n.length>0&&Ze(s)&&t.length===2){const m=t[0].size,f=t[1].size;i=n.reduce((v,g)=>Qt(Qt(v,g,m),g+1,f),i)}else[i,a]=tC(i,t);if(i===s)return e;const{lastIndex:c,lastOffset:l,lastSize:d,offsetTree:p}=Va(e.offsetTree,a,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((m,f)=>Qt(m,f,yo(f,p,o)),$r()),lastIndex:c,lastOffset:l,lastSize:d,offsetTree:p,sizeTree:i}}function iC(e){return ar(e).map(({k:t,v:n},r,o)=>{const s=o[r+1];return{endIndex:s?s.k-1:1/0,size:n,startIndex:t}})}function kp(e,t){let n=0,r=0;for(;n<e;)n+=t[r+1]-t[r]-1,r++;return r-(n===e?0:1)}function Va(e,t,n,r){let o=e,s=0,i=0,a=0,c=0;if(t!==0){c=Rs(o,t-1,Wa),a=o[c].offset;const l=pn(n,t-1);s=l[0],i=l[1],o.length&&o[c].size===pn(n,t)[1]&&(c-=1),o=o.slice(0,c+1)}else o=[];for(const{start:l,value:d}of js(n,t,1/0)){const p=l-s,m=p*i+a+p*r;o.push({index:l,offset:m,size:d}),s=l,a=m,i=d}return{lastIndex:s,lastOffset:a,lastSize:i,offsetTree:o}}function aC(e){return{index:e.index,value:e}}function lC(e){const{endIndex:t,size:n,startIndex:r}=e;return o=>o.start===r&&(o.end===t||o.end===1/0)&&o.value===n}const cC={offsetHeight:"height",offsetWidth:"width"},En=Ke(([{log:e},{recalcInProgress:t}])=>{const n=Be(),r=Be(),o=_t(r,0),s=Be(),i=Be(),a=se(0),c=se([]),l=se(void 0),d=se(void 0),p=se((S,T)=>Hn(S,cC[T])),m=se(void 0),f=se(0),v=eC(),g=_t(te(n,_e(c,e,f),kn(sC,v),ot()),v),x=_t(te(c,ot(),kn((S,T)=>({current:T,prev:S.current}),{current:[],prev:[]}),ce(({prev:S})=>S)),[]);me(te(c,Se(S=>S.length>0),_e(g,f),ce(([S,T,E])=>{const A=S.reduce((j,L,H)=>Qt(j,L,yo(L,T.offsetTree,E)||H),$r());return{...T,groupIndices:S,groupOffsetTree:A}})),g),me(te(r,_e(g),Se(([S,{lastIndex:T}])=>S<T),ce(([S,{lastIndex:T,lastSize:E}])=>[{endIndex:T,size:E,startIndex:S}])),n),me(l,d);const y=_t(te(l,ce(S=>S===void 0)),!0);me(te(d,Se(S=>S!==void 0&&Ze(ht(g).sizeTree)),ce(S=>[{endIndex:0,size:S,startIndex:0}])),n);const b=Zt(te(n,_e(g),kn(({sizes:S},[T,E])=>({changed:E!==S,sizes:E}),{changed:!1,sizes:v}),ce(S=>S.changed)));Xe(te(a,kn((S,T)=>({diff:S.prev-T,prev:T}),{diff:0,prev:0}),ce(S=>S.diff)),S=>{const{groupIndices:T}=ht(g);if(S>0)Ne(t,!0),Ne(s,S+kp(S,T));else if(S<0){const E=ht(x);E.length>0&&(S-=kp(-S,E)),Ne(i,S)}}),Xe(te(a,_e(e)),([S,T])=>{S<0&&T("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:a},Ut.ERROR)});const C=Zt(s);me(te(s,_e(g),ce(([S,T])=>{const E=T.groupIndices.length>0,A=[],j=T.lastSize;if(E){const L=wo(T.sizeTree,0);let H=0,V=0;for(;H<S;){const R=T.groupIndices[V],G=T.groupIndices.length===V+1?1/0:T.groupIndices[V+1]-R-1;A.push({endIndex:R,size:L,startIndex:R}),A.push({endIndex:R+1+G-1,size:j,startIndex:R+1}),V++,H+=G+1}const J=ar(T.sizeTree);return H!==S&&J.shift(),J.reduce((R,{k:G,v:K})=>{let $=R.ranges;return R.prevSize!==0&&($=[...R.ranges,{endIndex:G+S-1,size:R.prevSize,startIndex:R.prevIndex}]),{prevIndex:G+S,prevSize:K,ranges:$}},{prevIndex:S,prevSize:0,ranges:A}).ranges}return ar(T.sizeTree).reduce((L,{k:H,v:V})=>({prevIndex:H+S,prevSize:V,ranges:[...L.ranges,{endIndex:H+S-1,size:L.prevSize,startIndex:L.prevIndex}]}),{prevIndex:0,prevSize:j,ranges:[]}).ranges})),n);const k=Zt(te(i,_e(g,f),ce(([S,{offsetTree:T},E])=>{const A=-S;return yo(A,T,E)})));return me(te(i,_e(g,f),ce(([S,T,E])=>{if(T.groupIndices.length>0){if(Ze(T.sizeTree))return T;let A=$r();const j=ht(x);let L=0,H=0,V=0;for(;L<-S;){V=j[H];const J=j[H+1]-V-1;H++,L+=J+1}if(A=ar(T.sizeTree).reduce((J,{k:R,v:G})=>Qt(J,Math.max(0,R+S),G),A),L!==-S){const J=wo(T.sizeTree,V);A=Qt(A,0,J);const R=pn(T.sizeTree,-S+1)[1];A=Qt(A,1,R)}return{...T,sizeTree:A,...Va(T.offsetTree,0,A,E)}}else{const A=ar(T.sizeTree).reduce((j,{k:L,v:H})=>Qt(j,Math.max(0,L+S),H),$r());return{...T,sizeTree:A,...Va(T.offsetTree,0,A,E)}}})),g),{beforeUnshiftWith:C,data:m,defaultItemSize:d,firstItemIndex:a,fixedItemSize:l,gap:f,groupIndices:c,itemSize:p,listRefresh:b,shiftWith:i,shiftWithOffset:k,sizeRanges:n,sizes:g,statefulTotalCount:o,totalCount:r,trackItemSizes:y,unshiftWith:s}},rt(zn,Ua),{singleton:!0});function uC(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const Ep=Ke(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=Be(),i=Be(),a=Zt(te(s,ce(uC)));return me(te(a,ce(c=>c.totalCount)),n),me(te(a,ce(c=>c.groupIndices)),e),me(te(gt(o,t,r),Se(([c,l])=>Ms(l)),ce(([c,l,d])=>pn(l.groupOffsetTree,Math.max(c-d,0),"v")[0]),ot(),ce(c=>[c])),i),{groupCounts:s,topItemsIndexes:i}},rt(En,Lt)),Un=Ke(([{log:e}])=>{const t=se(!1),n=Zt(te(t,Se(r=>r),ot()));return Xe(t,r=>{r&&ht(e)("props updated",{},Ut.DEBUG)}),{didMount:n,propsReady:t}},rt(zn),{singleton:!0}),dC=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function Ip(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!dC)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const So=Ke(([{gap:e,listRefresh:t,sizes:n,totalCount:r},{fixedFooterHeight:o,fixedHeaderHeight:s,footerHeight:i,headerHeight:a,scrollingInProgress:c,scrollTo:l,smoothScrollTargetReached:d,viewportHeight:p},{log:m}])=>{const f=Be(),v=Be(),g=se(0);let x=null,y=null,b=null;function C(){x&&(x(),x=null),b&&(b(),b=null),y&&(clearTimeout(y),y=null),Ne(c,!1)}return me(te(f,_e(n,p,r,g,a,i,m),_e(e,s,o),ce(([[k,S,T,E,A,j,L,H],V,J,R])=>{const G=Ip(k),{align:K,behavior:$,offset:P}=G,I=E-1,U=Tp(G,S,I);let Z=yo(U,S.offsetTree,V)+j;K==="end"?(Z+=J+pn(S.sizeTree,U)[1]-T+R,U===I&&(Z+=L)):K==="center"?Z+=(J+pn(S.sizeTree,U)[1]-T+R)/2:Z-=A,P&&(Z+=P);const M=Y=>{C(),Y?(H("retrying to scroll to",{location:k},Ut.DEBUG),Ne(f,k)):(Ne(v,!0),H("list did not change, scroll successful",{},Ut.DEBUG))};if(C(),$==="smooth"){let Y=!1;b=Xe(t,_=>{Y=Y||_}),x=fn(d,()=>{M(Y)})}else x=fn(te(t,fC(150)),M);return y=setTimeout(()=>{C()},1200),Ne(c,!0),H("scrolling from index to",{behavior:$,index:U,top:Z},Ut.DEBUG),{behavior:$,top:Z}})),l),{scrollTargetReached:v,scrollToIndex:f,topListHeight:g}},rt(En,Lt,zn),{singleton:!0});function fC(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function Ka(e,t){e==0?t():requestAnimationFrame(()=>{Ka(e-1,t)})}function qa(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const Co=Ke(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:s},{didMount:i}])=>{const a=se(!0),c=se(0),l=se(!0);return me(te(i,_e(c),Se(([d,p])=>!!p),Tn(!1)),a),me(te(i,_e(c),Se(([d,p])=>!!p),Tn(!1)),l),Xe(te(gt(t,i),_e(a,n,e,l),Se(([[,d],p,{sizeTree:m},f,v])=>d&&(!Ze(m)||Oa(f))&&!p&&!v),_e(c)),([,d])=>{fn(o,()=>{Ne(l,!0)}),Ka(4,()=>{fn(r,()=>{Ne(a,!0)}),Ne(s,d)})}),{initialItemFinalLocationReached:l,initialTopMostItemIndex:c,scrolledToInitialItem:a}},rt(En,Lt,So,Un),{singleton:!0});function Np(e,t){return Math.abs(e-t)<1.01}const To="up",ko="down",pC="none",hC={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},mC=0,Eo=Ke(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=se(!1),a=se(!0),c=Be(),l=Be(),d=se(4),p=se(mC),m=_t(te(La(te(be(o),sr(1),Tn(!0)),te(be(o),sr(1),Tn(!1),dp(100))),ot()),!1),f=_t(te(La(te(n,Tn(!0)),te(n,Tn(!1),dp(200))),ot()),!1);me(te(gt(be(o),be(p)),ce(([b,C])=>b<=C),ot()),a),me(te(a,jn(50)),l);const v=Zt(te(gt(r,be(s),be(t),be(e),be(d)),kn((b,[{scrollHeight:C,scrollTop:k},S,T,E,A])=>{const j=k+S-C>-A,L={scrollHeight:C,scrollTop:k,viewportHeight:S};if(j){let V,J;return k>b.state.scrollTop?(V="SCROLLED_DOWN",J=b.state.scrollTop-k):(V="SIZE_DECREASED",J=b.state.scrollTop-k||b.scrollTopDelta),{atBottom:!0,atBottomBecause:V,scrollTopDelta:J,state:L}}let H;return L.scrollHeight>b.state.scrollHeight?H="SIZE_INCREASED":S<b.state.viewportHeight?H="VIEWPORT_HEIGHT_DECREASING":k<b.state.scrollTop?H="SCROLLING_UPWARDS":H="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:H,state:L}},hC),ot((b,C)=>b&&b.atBottom===C.atBottom))),g=_t(te(r,kn((b,{scrollHeight:C,scrollTop:k,viewportHeight:S})=>{if(Np(b.scrollHeight,C))return{changed:!1,jump:0,scrollHeight:C,scrollTop:k};{const T=C-(k+S)<1;return b.scrollTop!==k&&T?{changed:!0,jump:b.scrollTop-k,scrollHeight:C,scrollTop:k}:{changed:!0,jump:0,scrollHeight:C,scrollTop:k}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),Se(b=>b.changed),ce(b=>b.jump)),0);me(te(v,ce(b=>b.atBottom)),i),me(te(i,jn(50)),c);const x=se(ko);me(te(r,ce(({scrollTop:b})=>b),ot(),kn((b,C)=>ht(f)?{direction:b.direction,prevScrollTop:C}:{direction:C<b.prevScrollTop?To:ko,prevScrollTop:C},{direction:ko,prevScrollTop:0}),ce(b=>b.direction)),x),me(te(r,jn(50),Tn(pC)),x);const y=se(0);return me(te(m,Se(b=>!b),Tn(0)),y),me(te(o,jn(100),_e(m),Se(([b,C])=>!!C),kn(([b,C],[k])=>[C,k],[0,0]),ce(([b,C])=>C-b)),y),{atBottomState:v,atBottomStateChange:c,atBottomThreshold:d,atTopStateChange:l,atTopThreshold:p,isAtBottom:i,isAtTop:a,isScrolling:m,lastJumpDueToItemResize:g,scrollDirection:x,scrollVelocity:y}},rt(Lt)),Os="top",Ds="bottom",Ap="none";function Pp(e,t,n){return typeof e=="number"?n===To&&t===Os||n===ko&&t===Ds?e:0:n===To?t===Os?e.main:e.reverse:t===Ds?e.main:e.reverse}function jp(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const Ga=Ke(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=Be(),i=se(0),a=se(0),c=se(0),l=_t(te(gt(be(r),be(o),be(n),be(s,bo),be(c),be(i),be(t),be(e),be(a)),ce(([d,p,m,[f,v],g,x,y,b,C])=>{const k=d-b,S=x+y,T=Math.max(m-k,0);let E=Ap;const A=jp(C,Os),j=jp(C,Ds);return f-=b,f+=m+y,v+=m+y,v-=b,f>d+S-A&&(E=To),v<d-T+p+j&&(E=ko),E!==Ap?[Math.max(k-m-Pp(g,Os,E)-A,0),k-T-y+p+Pp(g,Ds,E)+j]:null}),Se(d=>d!=null),ot(bo)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:c,topListHeight:i,visibleRange:l}},rt(Lt),{singleton:!0});function gC(e,t,n){if(Ms(t)){const r=Cp(e,t);return[{index:pn(t.groupOffsetTree,r)[0],offset:0,size:0},{data:n==null?void 0:n[0],index:r,offset:0,size:0}]}return[{data:n==null?void 0:n[0],index:e,offset:0,size:0}]}const Ya={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Ls(e,t,n,r,o,s){const{lastIndex:i,lastOffset:a,lastSize:c}=o;let l=0,d=0;if(e.length>0){l=e[0].offset;const g=e[e.length-1];d=g.offset+g.size}const p=n-i,m=a+p*c+(p-1)*r,f=l,v=m-d;return{bottom:d,firstItemIndex:s,items:Rp(e,o,s),offsetBottom:v,offsetTop:l,top:f,topItems:Rp(t,o,s),topListHeight:t.reduce((g,x)=>x.size+g,0),totalCount:n}}function _p(e,t,n,r,o,s){let i=0;if(n.groupIndices.length>0)for(const d of n.groupIndices){if(d-i>=e)break;i++}const a=e+i,c=qa(t,a),l=Array.from({length:a}).map((d,p)=>({data:s[p+c],index:p+c,offset:0,size:0}));return Ls(l,[],a,o,n,r)}function Rp(e,t,n){if(e.length===0)return[];if(!Ms(t))return e.map(l=>({...l,index:l.index+n,originalIndex:l.index}));const r=e[0].index,o=e[e.length-1].index,s=[],i=js(t.groupOffsetTree,r,o);let a,c=0;for(const l of e){(!a||a.end<l.index)&&(a=i.shift(),c=t.groupIndices.indexOf(a.start));let d;l.index===a.start?d={index:c,type:"group"}:d={groupIndex:c,index:l.index-(c+1)+n},s.push({...d,data:l.data,offset:l.offset,originalIndex:l.index,size:l.size})}return s}const lr=Ke(([{data:e,firstItemIndex:t,gap:n,sizes:r,totalCount:o},s,{listBoundary:i,topListHeight:a,visibleRange:c},{initialTopMostItemIndex:l,scrolledToInitialItem:d},{topListHeight:p},m,{didMount:f},{recalcInProgress:v}])=>{const g=se([]),x=se(0),y=Be();me(s.topItemsIndexes,g);const b=_t(te(gt(f,v,be(c,bo),be(o),be(r),be(l),d,be(g),be(t),be(n),e),Se(([T,E,,A,,,,,,,j])=>{const L=j&&j.length!==A;return T&&!E&&!L}),ce(([,,[T,E],A,j,L,H,V,J,R,G])=>{const K=j,{offsetTree:$,sizeTree:P}=K,I=ht(x);if(A===0)return{...Ya,totalCount:A};if(T===0&&E===0)return I===0?{...Ya,totalCount:A}:_p(I,L,j,J,R,G||[]);if(Ze(P))return I>0?null:Ls(gC(qa(L,A),K,G),[],A,R,K,J);const U=[];if(V.length>0){const z=V[0],W=V[V.length-1];let O=0;for(const D of js(P,z,W)){const B=D.value,Q=Math.max(D.start,z),oe=Math.min(D.end,W);for(let ie=Q;ie<=oe;ie++)U.push({data:G==null?void 0:G[ie],index:ie,offset:O,size:B}),O+=B}}if(!H)return Ls([],U,A,R,K,J);const Z=V.length>0?V[V.length-1]+1:0,M=oC($,T,E,Z);if(M.length===0)return null;const Y=A-1,_=Ps([],z=>{for(const W of M){const O=W.value;let D=O.offset,B=W.start;const Q=O.size;if(O.offset<T){B+=Math.floor((T-O.offset+R)/(Q+R));const ie=B-W.start;D+=ie*Q+ie*R}B<Z&&(D+=(Z-B)*Q,B=Z);const oe=Math.min(W.end,Y);for(let ie=B;ie<=oe&&!(D>=E);ie++)z.push({data:G==null?void 0:G[ie],index:ie,offset:D,size:Q}),D+=Q+R}});return Ls(_,U,A,R,K,J)}),Se(T=>T!==null),ot()),Ya);me(te(e,Se(Oa),ce(T=>T==null?void 0:T.length)),o),me(te(b,ce(T=>T.topListHeight)),p),me(p,a),me(te(b,ce(T=>[T.top,T.bottom])),i),me(te(b,ce(T=>T.items)),y);const C=Zt(te(b,Se(({items:T})=>T.length>0),_e(o,e),Se(([{items:T},E])=>T[T.length-1].originalIndex===E-1),ce(([,T,E])=>[T-1,E]),ot(bo),ce(([T])=>T))),k=Zt(te(b,jn(200),Se(({items:T,topItems:E})=>T.length>0&&T[0].originalIndex===E.length),ce(({items:T})=>T[0].index),ot())),S=Zt(te(b,Se(({items:T})=>T.length>0),ce(({items:T})=>{let E=0,A=T.length-1;for(;T[E].type==="group"&&E<A;)E++;for(;T[A].type==="group"&&A>E;)A--;return{endIndex:T[A].index,startIndex:T[E].index}}),ot(yp)));return{endReached:C,initialItemCount:x,itemsRendered:y,listState:b,rangeChanged:S,startReached:k,topItemsIndexes:g,...m}},rt(En,Ep,Ga,Co,So,Eo,Un,Ua),{singleton:!0}),Mp=Ke(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=Be(),i=_t(te(gt(n,e,r,t,o),ce(([a,c,l,d,p])=>a+c+l+d+p.offsetBottom+p.bottom)),0);return me(be(i),s),{totalListHeight:i,totalListHeightChanged:s}},rt(Lt,lr),{singleton:!0}),xC=Ke(([{viewportHeight:e},{totalListHeight:t}])=>{const n=se(!1),r=_t(te(gt(n,e,t),Se(([o])=>o),ce(([,o,s])=>Math.max(0,o-s)),jn(0),ot()),0);return{alignToBottom:n,paddingTopAddition:r}},rt(Lt,Mp),{singleton:!0}),Op=Ke(()=>({context:se(null)})),vC=({itemBottom:e,itemTop:t,locationParams:{align:n,behavior:r,...o},viewportBottom:s,viewportTop:i})=>t<i?{...o,align:n??"start",behavior:r}:e>s?{...o,align:n??"end",behavior:r}:null,Dp=Ke(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:s,scrollingInProgress:i,scrollTop:a,viewportHeight:c},{scrollToIndex:l}])=>{const d=Be();return me(te(d,_e(t,c,n,s,o,r,a),_e(e),ce(([[p,m,f,v,g,x,y,b],C])=>{const{align:k,behavior:S,calculateViewLocation:T=vC,done:E,...A}=p,j=Tp(p,m,v-1),L=yo(j,m.offsetTree,C)+g+x,H=L+pn(m.sizeTree,j)[1],V=b+x,J=b+f-y,R=T({itemBottom:H,itemTop:L,locationParams:{align:k,behavior:S,...A},viewportBottom:J,viewportTop:V});return R?E&&fn(te(i,Se(G=>!G),sr(ht(i)?1:2)),E):E&&E(),R}),Se(p=>p!==null)),l),{scrollIntoView:d}},rt(En,Lt,So,lr,zn),{singleton:!0});function Lp(e){return e?e==="smooth"?"smooth":"auto":!1}const wC=(e,t)=>typeof e=="function"?Lp(e(t)):t&&Lp(e),bC=Ke(([{listRefresh:e,totalCount:t,fixedItemSize:n,data:r},{atBottomState:o,isAtBottom:s},{scrollToIndex:i},{scrolledToInitialItem:a},{didMount:c,propsReady:l},{log:d},{scrollingInProgress:p},{context:m},{scrollIntoView:f}])=>{const v=se(!1),g=Be();let x=null;function y(S){Ne(i,{align:"end",behavior:S,index:"LAST"})}Xe(te(gt(te(be(t),sr(1)),c),_e(be(v),s,a,p),ce(([[S,T],E,A,j,L])=>{let H=T&&j,V="auto";return H&&(V=wC(E,A||L),H=H&&!!V),{followOutputBehavior:V,shouldFollow:H,totalCount:S}}),Se(({shouldFollow:S})=>S)),({followOutputBehavior:S,totalCount:T})=>{x&&(x(),x=null),ht(n)?requestAnimationFrame(()=>{ht(d)("following output to ",{totalCount:T},Ut.DEBUG),y(S)}):x=fn(e,()=>{ht(d)("following output to ",{totalCount:T},Ut.DEBUG),y(S),x=null})});function b(S){const T=fn(o,E=>{S&&!E.atBottom&&E.notAtBottomBecause==="SIZE_INCREASED"&&!x&&(ht(d)("scrolling to bottom due to increased size",{},Ut.DEBUG),y("auto"))});setTimeout(T,100)}Xe(te(gt(be(v),t,l),Se(([S,,T])=>S&&T),kn(({value:S},[,T])=>({refreshed:S===T,value:T}),{refreshed:!1,value:0}),Se(({refreshed:S})=>S),_e(v,t)),([,S])=>{ht(a)&&b(S!==!1)}),Xe(g,()=>{b(ht(v)!==!1)}),Xe(gt(be(v),o),([S,T])=>{S&&!T.atBottom&&T.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&y("auto")});const C=se(null),k=Be();return me(La(te(be(r),ce(S=>{var T;return(T=S==null?void 0:S.length)!=null?T:0})),te(be(t))),k),Xe(te(gt(te(k,sr(1)),c),_e(be(C),a,p,m),ce(([[S,T],E,A,j,L])=>T&&A&&(E==null?void 0:E({context:L,totalCount:S,scrollingInProgress:j}))),Se(S=>!!S),jn(0)),S=>{x&&(x(),x=null),ht(n)?requestAnimationFrame(()=>{ht(d)("scrolling into view",{}),Ne(f,S)}):x=fn(e,()=>{ht(d)("scrolling into view",{}),Ne(f,S),x=null})}),{autoscrollToBottom:g,followOutput:v,scrollIntoViewOnChange:C}},rt(En,Eo,So,Co,Un,zn,Lt,Op,Dp)),yC=Ke(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(me(te(a,_e(s),Se(([,c])=>c!==0),_e(o,r,t,n,e),ce(([[,c],l,d,p,m,f=[]])=>_p(c,l,d,p,m,f))),i),{}),rt(En,Co,lr,Un),{singleton:!0}),SC=Ke(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=se(0);return Xe(te(e,_e(r),Se(([,o])=>o!==0),ce(([,o])=>({top:o}))),o=>{fn(te(n,sr(1),Se(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{Ne(t,o)})})}),{initialScrollTop:r}},rt(Un,Lt,lr),{singleton:!0}),$p=Ke(([{scrollVelocity:e}])=>{const t=se(!1),n=Be(),r=se(!1);return me(te(e,_e(r,t,n),Se(([o,s])=>!!s),ce(([o,s,i,a])=>{const{enter:c,exit:l}=s;if(i){if(l(o,a))return!1}else if(c(o,a))return!0;return i}),ot()),t),Xe(te(gt(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(Eo),{singleton:!0}),Xa=Ke(([{scrollContainerState:e,scrollTo:t}])=>{const n=Be(),r=Be(),o=Be(),s=se(!1),i=se(void 0);return me(te(gt(n,r),ce(([{scrollHeight:a,scrollTop:c,viewportHeight:l},{offsetTop:d}])=>({scrollHeight:a,scrollTop:Math.max(0,c-d),viewportHeight:l}))),e),me(te(t,_e(r),ce(([a,{offsetTop:c}])=>({...a,top:a.top+c}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},rt(Lt)),CC=Ke(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:a,windowViewportRect:c}])=>{const l=Be(),d=se(void 0),p=se(null),m=se(null);return me(a,p),me(c,m),Xe(te(l,_e(t,r,i,p,m,n)),([f,v,g,x,y,b,C])=>{const k=iC(v.sizeTree);x&&y!==null&&b!==null&&(g=y.scrollTop-b.offsetTop),g-=C,f({ranges:k,scrollTop:g})}),me(te(d,Se(Oa),ce(TC)),o),me(te(s,_e(d),Se(([,f])=>f!==void 0),ot(),ce(([,f])=>f.ranges)),e),{getState:l,restoreStateFrom:d}},rt(En,Lt,Co,Un,Xa));function TC(e){return{align:"start",index:0,offset:e.scrollTop}}const kC=Ke(([{topItemsIndexes:e}])=>{const t=se(0);return me(te(t,Se(n=>n>=0),ce(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},rt(lr));function Fp(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const EC=Fp(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),IC=Ke(([{deviation:e,scrollBy:t,scrollingInProgress:n,scrollTop:r},{isAtBottom:o,isScrolling:s,lastJumpDueToItemResize:i,scrollDirection:a},{listState:c},{beforeUnshiftWith:l,gap:d,shiftWithOffset:p,sizes:m},{log:f},{recalcInProgress:v}])=>{const g=Zt(te(c,_e(i),kn(([,y,b,C],[{bottom:k,items:S,offsetBottom:T,totalCount:E},A])=>{const j=k+T;let L=0;return b===E&&y.length>0&&S.length>0&&(S[0].originalIndex===0&&y[0].originalIndex===0||(L=j-C,L!==0&&(L+=A))),[L,S,E,j]},[0,[],0,0]),Se(([y])=>y!==0),_e(r,a,n,o,f,v),Se(([,y,b,C,,,k])=>!k&&!C&&y!==0&&b===To),ce(([[y],,,,,b])=>(b("Upward scrolling compensation",{amount:y},Ut.DEBUG),y))));function x(y){y>0?(Ne(t,{behavior:"auto",top:-y}),Ne(e,0)):(Ne(e,0),Ne(t,{behavior:"auto",top:-y}))}return Xe(te(g,_e(e,s)),([y,b,C])=>{C&&EC()?Ne(e,b-y):x(-y)}),Xe(te(gt(_t(s,!1),e,v),Se(([y,b,C])=>!y&&!C&&b!==0),ce(([y,b])=>b),jn(1)),x),me(te(p,ce(y=>({top:-y}))),t),Xe(te(l,_e(m,d),ce(([y,{groupIndices:b,lastSize:C,sizeTree:k},S])=>{function T(E){return E*(C+S)}if(b.length===0)return T(y);{let E=0;const A=wo(k,0);let j=0,L=0;for(;j<y;){j++,E+=A;let H=b.length===L+1?1/0:b[L+1]-b[L]-1;j+H>y&&(E-=A,H=y-j+1),j+=H,E+=T(H),L++}return E}})),y=>{Ne(e,y),requestAnimationFrame(()=>{Ne(t,{top:y}),requestAnimationFrame(()=>{Ne(e,0),Ne(v,!1)})})}),{deviation:e}},rt(Lt,Eo,lr,En,zn,Ua)),NC=Ke(([e,t,n,r,o,s,i,a,c,l,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...c,...l,...d}),rt(Ga,yC,Un,$p,Mp,SC,xC,Xa,Dp,zn,Op)),Bp=Ke(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:r,gap:o,groupIndices:s,itemSize:i,sizeRanges:a,sizes:c,statefulTotalCount:l,totalCount:d,trackItemSizes:p},{initialItemFinalLocationReached:m,initialTopMostItemIndex:f,scrolledToInitialItem:v},g,x,y,{listState:b,topItemsIndexes:C,...k},{scrollToIndex:S},T,{topItemCount:E},{groupCounts:A},j])=>(me(k.rangeChanged,j.scrollSeekRangeChanged),me(te(j.windowViewportRect,ce(L=>L.visibleHeight)),g.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,gap:o,groupCounts:A,initialItemFinalLocationReached:m,initialTopMostItemIndex:f,scrolledToInitialItem:v,sizeRanges:a,topItemCount:E,topItemsIndexes:C,totalCount:d,...y,groupIndices:s,itemSize:i,listState:b,scrollToIndex:S,statefulTotalCount:l,trackItemSizes:p,...k,...j,...g,sizes:c,...x}),rt(En,Co,Lt,CC,bC,lr,So,IC,kC,Ep,NC));function AC(e,t){const n={},r={};let o=0;const s=e.length;for(;o<s;)r[e[o]]=1,o+=1;for(const i in t)Object.hasOwn(r,i)||(n[i]=t[i]);return n}const $s=typeof document<"u"?w.useLayoutEffect:w.useEffect;function zp(e,t,n){const r=Object.keys(t.required||{}),o=Object.keys(t.optional||{}),s=Object.keys(t.methods||{}),i=Object.keys(t.events||{}),a=w.createContext({});function c(x,y){x.propsReady&&Ne(x.propsReady,!1);for(const b of r){const C=x[t.required[b]];Ne(C,y[b])}for(const b of o)if(b in y){const C=x[t.optional[b]];Ne(C,y[b])}x.propsReady&&Ne(x.propsReady,!0)}function l(x){return s.reduce((y,b)=>(y[b]=C=>{const k=x[t.methods[b]];Ne(k,C)},y),{})}function d(x){return i.reduce((y,b)=>(y[b]=VS(x[t.events[b]]),y),{})}const p=w.forwardRef((x,y)=>{const{children:b,...C}=x,[k]=w.useState(()=>Ps(qS(e),E=>{c(E,C)})),[S]=w.useState(up(d,k));$s(()=>{for(const E of i)E in C&&Xe(S[E],C[E]);return()=>{Object.values(S).map(Da)}},[C,S,k]),$s(()=>{c(k,C)}),w.useImperativeHandle(y,lp(l(k)));const T=n;return u.jsx(a.Provider,{value:k,children:n?u.jsx(T,{...AC([...r,...o,...i],C),children:b}):b})}),m=x=>{const y=w.useContext(a);return w.useCallback(b=>{Ne(y[x],b)},[y,x])},f=x=>{const y=w.useContext(a)[x],b=w.useCallback(C=>Xe(y,C),[y]);return w.useSyncExternalStore(b,()=>ht(y),()=>ht(y))},v=x=>{const y=w.useContext(a)[x],[b,C]=w.useState(up(ht,y));return $s(()=>Xe(y,k=>{k!==b&&C(lp(k))}),[y,b]),b},g=w.version.startsWith("18")?f:v;return{Component:p,useEmitter:(x,y)=>{const b=w.useContext(a)[x];$s(()=>Xe(b,y),[y,b])},useEmitterValue:g,usePublisher:m}}const Hp=w.createContext(void 0),Up=w.createContext(void 0),Wp=typeof document<"u"?w.useLayoutEffect:w.useEffect;function Ja(e){return"self"in e}function PC(e){return"body"in e}function Vp(e,t,n,r=Lr,o,s){const i=w.useRef(null),a=w.useRef(null),c=w.useRef(null),l=w.useCallback(m=>{let f,v,g;const x=m.target;if(PC(x)||Ja(x)){const b=Ja(x)?x:x.defaultView;g=s?b.scrollX:b.scrollY,f=s?b.document.documentElement.scrollWidth:b.document.documentElement.scrollHeight,v=s?b.innerWidth:b.innerHeight}else g=s?x.scrollLeft:x.scrollTop,f=s?x.scrollWidth:x.scrollHeight,v=s?x.offsetWidth:x.offsetHeight;const y=()=>{e({scrollHeight:f,scrollTop:Math.max(g,0),viewportHeight:v})};m.suppressFlushSync?y():Lo.flushSync(y),a.current!==null&&(g===a.current||g<=0||g===f-v)&&(a.current=null,t(!0),c.current&&(clearTimeout(c.current),c.current=null))},[e,t,s]);w.useEffect(()=>{const m=o||i.current;return r(o||i.current),l({suppressFlushSync:!0,target:m}),m.addEventListener("scroll",l,{passive:!0}),()=>{r(null),m.removeEventListener("scroll",l)}},[i,l,n,r,o]);function d(m){const 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;Ja(f)?(x=Math.max(Hn(f.document.documentElement,s?"width":"height"),s?f.document.documentElement.scrollWidth:f.document.documentElement.scrollHeight),g=s?f.innerWidth:f.innerHeight,y=s?window.scrollX:window.scrollY):(x=f[s?"scrollWidth":"scrollHeight"],g=Hn(f,s?"width":"height"),y=f[s?"scrollLeft":"scrollTop"]);const b=x-g;if(m.top=Math.ceil(Math.max(Math.min(b,m.top),0)),Np(g,x)||m.top===y){e({scrollHeight:x,scrollTop:y,viewportHeight:g}),v&&t(!0);return}v?(a.current=m.top,c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{c.current=null,a.current=null,t(!0)},1e3)):a.current=null,s&&(m={behavior:m.behavior,left:m.top}),f.scrollTo(m)}function p(m){s&&(m={behavior:m.behavior,left:m.top}),i.current.scrollBy(m)}return{scrollByCallback:p,scrollerRef:i,scrollToCallback:d}}const Za="-webkit-sticky",Kp="sticky",Qa=Fp(()=>{if(typeof document>"u")return Kp;const e=document.createElement("div");return e.style.position=Za,e.style.position===Za?Za:Kp});function el(e){return e}const jC=Ke(()=>{const e=se(a=>`Item ${a}`),t=se(a=>`Group ${a}`),n=se({}),r=se(el),o=se("div"),s=se(Lr),i=(a,c=null)=>_t(te(n,ce(l=>l[a]),ot()),c);return{components:n,computeItemKey:r,EmptyPlaceholder:i("EmptyPlaceholder"),FooterComponent:i("Footer"),GroupComponent:i("Group","div"),groupContent:t,HeaderComponent:i("Header"),HeaderFooterTag:o,ItemComponent:i("Item","div"),itemContent:e,ListComponent:i("List","div"),ScrollerComponent:i("Scroller","div"),scrollerRef:s,ScrollSeekPlaceholder:i("ScrollSeekPlaceholder"),TopItemListComponent:i("TopItemList")}}),_C=Ke(([e,t])=>({...e,...t}),rt(Bp,jC)),RC=({height:e})=>u.jsx("div",{style:{height:e}}),MC={overflowAnchor:"none",position:Qa(),zIndex:1},qp={overflowAnchor:"none"},OC={...qp,display:"inline-block",height:"100%"},Gp=w.memo(function({showTopList:e=!1}){const t=Te("listState"),n=tn("sizeRanges"),r=Te("useWindowScroll"),o=Te("customScrollParent"),s=tn("windowScrollContainerState"),i=tn("scrollContainerState"),a=o||r?s:i,c=Te("itemContent"),l=Te("context"),d=Te("groupContent"),p=Te("trackItemSizes"),m=Te("itemSize"),f=Te("log"),v=tn("gap"),g=Te("horizontalDirection"),{callbackRef:x}=XS(n,m,p,e?Lr:a,f,v,o,g,Te("skipAnimationFrameInResizeObserver")),[y,b]=w.useState(0);tl("deviation",R=>{y!==R&&b(R)});const C=Te("EmptyPlaceholder"),k=Te("ScrollSeekPlaceholder")||RC,S=Te("ListComponent"),T=Te("ItemComponent"),E=Te("GroupComponent"),A=Te("computeItemKey"),j=Te("isSeeking"),L=Te("groupIndices").length>0,H=Te("alignToBottom"),V=Te("initialItemFinalLocationReached"),J=e?{}:{boxSizing:"border-box",...g?{display:"inline-block",height:"100%",marginLeft:y!==0?y:H?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:y!==0?y:H?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...V?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&C?u.jsx(C,{...Rt(C,l)}):u.jsx(S,{...Rt(S,l),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:x,style:J,children:(e?t.topItems:t.items).map(R=>{const G=R.originalIndex,K=A(G+t.firstItemIndex,R.data,l);return j?w.createElement(k,{...Rt(k,l),height:R.size,index:R.index,key:K,type:R.type||"item",...R.type==="group"?{}:{groupIndex:R.groupIndex}}):R.type==="group"?w.createElement(E,{...Rt(E,l),"data-index":G,"data-item-index":R.index,"data-known-size":R.size,key:K,style:MC},d(R.index,l)):w.createElement(T,{...Rt(T,l),...FC(T,R.data),"data-index":G,"data-item-group-index":R.groupIndex,"data-item-index":R.index,"data-known-size":R.size,key:K,style:g?OC:qp},L?c(R.index,R.groupIndex,R.data,l):c(R.index,R.data,l))})})}),DC={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},LC={outline:"none",overflowX:"auto",position:"relative"},Fs=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),$C={position:Qa(),top:0,width:"100%",zIndex:1};function Rt(e,t){if(typeof e!="string")return{context:t}}function FC(e,t){return{item:typeof e=="string"?void 0:t}}const BC=w.memo(function(){const e=Te("HeaderComponent"),t=tn("headerHeight"),n=Te("HeaderFooterTag"),r=ir(w.useMemo(()=>s=>{t(Hn(s,"height"))},[t]),!0,Te("skipAnimationFrameInResizeObserver")),o=Te("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Rt(e,o)})}):null}),zC=w.memo(function(){const e=Te("FooterComponent"),t=tn("footerHeight"),n=Te("HeaderFooterTag"),r=ir(w.useMemo(()=>s=>{t(Hn(s,"height"))},[t]),!0,Te("skipAnimationFrameInResizeObserver")),o=Te("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Rt(e,o)})}):null});function Yp({useEmitter:e,useEmitterValue:t,usePublisher:n}){return w.memo(function({children:r,style:o,context:s,...i}){const a=n("scrollContainerState"),c=t("ScrollerComponent"),l=n("smoothScrollTargetReached"),d=t("scrollerRef"),p=t("horizontalDirection")||!1,{scrollByCallback:m,scrollerRef:f,scrollToCallback:v}=Vp(a,l,c,d,void 0,p);return e("scrollTo",v),e("scrollBy",m),u.jsx(c,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:f,style:{...p?LC:DC,...o},tabIndex:0,...i,...Rt(c,s),children:r})})}function Xp({useEmitter:e,useEmitterValue:t,usePublisher:n}){return w.memo(function({children:r,style:o,context:s,...i}){const a=n("windowScrollContainerState"),c=t("ScrollerComponent"),l=n("smoothScrollTargetReached"),d=t("totalListHeight"),p=t("deviation"),m=t("customScrollParent"),f=w.useRef(null),v=t("scrollerRef"),{scrollByCallback:g,scrollerRef:x,scrollToCallback:y}=Vp(a,l,c,v,m);return Wp(()=>{var b;return x.current=m||((b=f.current)==null?void 0:b.ownerDocument.defaultView),()=>{x.current=null}},[x,m]),e("windowScrollTo",y),e("scrollBy",g),u.jsx(c,{ref:f,"data-virtuoso-scroller":!0,style:{position:"relative",...o,...d!==0?{height:d+p}:{}},...i,...Rt(c,s),children:r})})}const HC=({children:e})=>{const t=w.useContext(Hp),n=tn("viewportHeight"),r=tn("fixedItemHeight"),o=Te("alignToBottom"),s=Te("horizontalDirection"),i=w.useMemo(()=>cp(n,c=>Hn(c,s?"width":"height")),[n,s]),a=ir(i,!0,Te("skipAnimationFrameInResizeObserver"));return w.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),u.jsx("div",{"data-viewport-type":"element",ref:a,style:Fs(o),children:e})},UC=({children:e})=>{const t=w.useContext(Hp),n=tn("windowViewportRect"),r=tn("fixedItemHeight"),o=Te("customScrollParent"),s=hp(n,o,Te("skipAnimationFrameInResizeObserver")),i=Te("alignToBottom");return w.useEffect(()=>{t&&(r(t.itemHeight),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),u.jsx("div",{"data-viewport-type":"window",ref:s,style:Fs(i),children:e})},WC=({children:e})=>{const t=Te("TopItemListComponent")||"div",n=Te("headerHeight"),r={...$C,marginTop:`${n}px`},o=Te("context");return u.jsx(t,{style:r,...Rt(t,o),children:e})},VC=w.memo(function(e){const t=Te("useWindowScroll"),n=Te("topItemsIndexes").length>0,r=Te("customScrollParent"),o=Te("context");return u.jsxs(r||t?GC:qC,{...e,context:o,children:[n&&u.jsx(WC,{children:u.jsx(Gp,{showTopList:!0})}),u.jsxs(r||t?UC:HC,{children:[u.jsx(BC,{}),u.jsx(Gp,{}),u.jsx(zC,{})]})]})}),{Component:KC,useEmitter:tl,useEmitterValue:Te,usePublisher:tn}=zp(_C,{required:{},optional:{restoreStateFrom:"restoreStateFrom",context:"context",followOutput:"followOutput",scrollIntoViewOnChange:"scrollIntoViewOnChange",itemContent:"itemContent",groupContent:"groupContent",overscan:"overscan",increaseViewportBy:"increaseViewportBy",totalCount:"totalCount",groupCounts:"groupCounts",topItemCount:"topItemCount",firstItemIndex:"firstItemIndex",initialTopMostItemIndex:"initialTopMostItemIndex",components:"components",atBottomThreshold:"atBottomThreshold",atTopThreshold:"atTopThreshold",computeItemKey:"computeItemKey",defaultItemHeight:"defaultItemHeight",fixedItemHeight:"fixedItemHeight",itemSize:"itemSize",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"HeaderFooterTag",data:"data",initialItemCount:"initialItemCount",initialScrollTop:"initialScrollTop",alignToBottom:"alignToBottom",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",horizontalDirection:"horizontalDirection",skipAnimationFrameInResizeObserver:"skipAnimationFrameInResizeObserver"},methods:{scrollToIndex:"scrollToIndex",scrollIntoView:"scrollIntoView",scrollTo:"scrollTo",scrollBy:"scrollBy",autoscrollToBottom:"autoscrollToBottom",getState:"getState"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",totalListHeightChanged:"totalListHeightChanged",itemsRendered:"itemsRendered",groupIndices:"groupIndices"}},VC),qC=Yp({useEmitter:tl,useEmitterValue:Te,usePublisher:tn}),GC=Xp({useEmitter:tl,useEmitterValue:Te,usePublisher:tn}),YC=KC;rt(Bp,Ke(()=>{const e=se(l=>u.jsxs("td",{children:["Item $",l]})),t=se(null),n=se(l=>u.jsxs("td",{colSpan:1e3,children:["Group ",l]})),r=se(null),o=se(null),s=se({}),i=se(el),a=se(Lr),c=(l,d=null)=>_t(te(s,ce(p=>p[l]),ot()),d);return{components:s,computeItemKey:i,context:t,EmptyPlaceholder:c("EmptyPlaceholder"),FillerRow:c("FillerRow"),fixedFooterContent:o,fixedHeaderContent:r,itemContent:e,groupContent:n,ScrollerComponent:c("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:c("ScrollSeekPlaceholder"),TableBodyComponent:c("TableBody","tbody"),TableComponent:c("Table","table"),TableFooterComponent:c("TableFoot","tfoot"),TableHeadComponent:c("TableHead","thead"),TableRowComponent:c("TableRow","tr"),GroupComponent:c("Group","tr")}})),Qa();const Jp={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},XC={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:Zp,floor:Bs,max:Io,min:nl,round:Qp}=Math;function eh(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function JC(e){return{...XC,items:e}}function zs(e,t){return e&&e.width===t.width&&e.height===t.height}function ZC(e,t){return e&&e.column===t.column&&e.row===t.row}const QC=Ke(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:r},{footerHeight:o,headerHeight:s,scrollBy:i,scrollContainerState:a,scrollTo:c,scrollTop:l,smoothScrollTargetReached:d,viewportHeight:p},m,f,{didMount:v,propsReady:g},{customScrollParent:x,useWindowScroll:y,windowScrollContainerState:b,windowScrollTo:C,windowViewportRect:k},S])=>{const T=se(0),E=se(0),A=se(Jp),j=se({height:0,width:0}),L=se({height:0,width:0}),H=Be(),V=Be(),J=se(0),R=se(null),G=se({column:0,row:0}),K=Be(),$=Be(),P=se(!1),I=se(0),U=se(!0),Z=se(!1),M=se(!1);Xe(te(v,_e(I),Se(([D,B])=>!!B)),()=>{Ne(U,!1)}),Xe(te(gt(v,U,L,j,I,Z),Se(([D,B,Q,oe,,ie])=>D&&!B&&Q.height!==0&&oe.height!==0&&!ie)),([,,,,D])=>{Ne(Z,!0),Ka(1,()=>{Ne(H,D)}),fn(te(l),()=>{Ne(t,[0,0]),Ne(U,!0)})}),me(te($,Se(D=>D!=null&&D.scrollTop>0),Tn(0)),E),Xe(te(v,_e($),Se(([,D])=>D!=null)),([,D])=>{D&&(Ne(j,D.viewport),Ne(L,D.item),Ne(G,D.gap),D.scrollTop>0&&(Ne(P,!0),fn(te(l,sr(1)),B=>{Ne(P,!1)}),Ne(c,{top:D.scrollTop})))}),me(te(j,ce(({height:D})=>D)),p),me(te(gt(be(j,zs),be(L,zs),be(G,(D,B)=>D&&D.column===B.column&&D.row===B.row),be(l)),ce(([D,B,Q,oe])=>({gap:Q,item:B,scrollTop:oe,viewport:D}))),K),me(te(gt(be(T),r,be(G,ZC),be(L,zs),be(j,zs),be(R),be(E),be(P),be(U),be(I)),Se(([,,,,,,,D])=>!D),ce(([D,[B,Q],oe,ie,Ce,ve,Re,,We,De])=>{const{column:qe,row:ze}=oe,{height:xt,width:lt}=ie,{width:et}=Ce;if(Re===0&&(D===0||et===0))return Jp;if(lt===0){const Et=qa(De,D),vt=Et+Math.max(Re-1,0);return JC(eh(Et,vt,ve))}const Le=th(et,lt,qe);let Ve,$e;We?B===0&&Q===0&&Re>0?(Ve=0,$e=Re-1):(Ve=Le*Bs((B+ze)/(xt+ze)),$e=Le*Zp((Q+ze)/(xt+ze))-1,$e=nl(D-1,Io($e,Le-1)),Ve=nl($e,Io(0,Ve))):(Ve=0,$e=-1);const ke=eh(Ve,$e,ve),{bottom:Ae,top:ct}=nh(Ce,oe,ie,ke),kt=Zp(D/Le),st=kt*xt+(kt-1)*ze-Ae;return{bottom:Ae,itemHeight:xt,items:ke,itemWidth:lt,offsetBottom:st,offsetTop:ct,top:ct}})),A),me(te(R,Se(D=>D!==null),ce(D=>D.length)),T),me(te(gt(j,L,A,G),Se(([D,B,{items:Q}])=>Q.length>0&&B.height!==0&&D.height!==0),ce(([D,B,{items:Q},oe])=>{const{bottom:ie,top:Ce}=nh(D,oe,B,Q);return[Ce,ie]}),ot(bo)),t);const Y=se(!1);me(te(l,_e(Y),ce(([D,B])=>B||D!==0)),Y);const _=Zt(te(gt(A,T),Se(([{items:D}])=>D.length>0),_e(Y),Se(([[D,B],Q])=>{const oe=D.items[D.items.length-1].index===B-1;return(Q||D.bottom>0&&D.itemHeight>0&&D.offsetBottom===0&&D.items.length===B)&&oe}),ce(([[,D]])=>D-1),ot())),z=Zt(te(be(A),Se(({items:D})=>D.length>0&&D[0].index===0),Tn(0),ot())),W=Zt(te(be(A),_e(P),Se(([{items:D},B])=>D.length>0&&!B),ce(([{items:D}])=>({endIndex:D[D.length-1].index,startIndex:D[0].index})),ot(yp),jn(0)));me(W,f.scrollSeekRangeChanged),me(te(H,_e(j,L,T,G),ce(([D,B,Q,oe,ie])=>{const Ce=Ip(D),{align:ve,behavior:Re,offset:We}=Ce;let De=Ce.index;De==="LAST"&&(De=oe-1),De=Io(0,De,nl(oe-1,De));let qe=rl(B,ie,Q,De);return ve==="end"?qe=Qp(qe-B.height+Q.height):ve==="center"&&(qe=Qp(qe-B.height/2+Q.height/2)),We&&(qe+=We),{behavior:Re,top:qe}})),c);const O=_t(te(A,ce(D=>D.offsetBottom+D.bottom)),0);return me(te(k,ce(D=>({height:D.visibleHeight,width:D.visibleWidth}))),j),{customScrollParent:x,data:R,deviation:J,footerHeight:o,gap:G,headerHeight:s,increaseViewportBy:e,initialItemCount:E,itemDimensions:L,overscan:n,restoreStateFrom:$,scrollBy:i,scrollContainerState:a,scrollHeight:V,scrollTo:c,scrollToIndex:H,scrollTop:l,smoothScrollTargetReached:d,totalCount:T,useWindowScroll:y,viewportDimensions:j,windowScrollContainerState:b,windowScrollTo:C,windowViewportRect:k,...f,gridState:A,horizontalDirection:M,initialTopMostItemIndex:I,totalListHeight:O,...m,endReached:_,propsReady:g,rangeChanged:W,startReached:z,stateChanged:K,stateRestoreInProgress:P,...S}},rt(Ga,Lt,Eo,$p,Un,Xa,zn));function th(e,t,n){return Io(1,Bs((e+n)/(Bs(t)+n)))}function nh(e,t,n,r){const{height:o}=n;if(o===void 0||r.length===0)return{bottom:0,top:0};const s=rl(e,t,n,r[0].index);return{bottom:rl(e,t,n,r[r.length-1].index)+o,top:s}}function rl(e,t,n,r){const o=th(e.width,n.width,t.column),s=Bs(r/o),i=s*n.height+Io(0,s-1)*t.row;return i>0?i+t.row:i}const eT=Ke(()=>{const e=se(p=>`Item ${p}`),t=se({}),n=se(null),r=se("virtuoso-grid-item"),o=se("virtuoso-grid-list"),s=se(el),i=se("div"),a=se(Lr),c=(p,m=null)=>_t(te(t,ce(f=>f[p]),ot()),m),l=se(!1),d=se(!1);return me(be(d),l),{components:t,computeItemKey:s,context:n,FooterComponent:c("Footer"),HeaderComponent:c("Header"),headerFooterTag:i,itemClassName:r,ItemComponent:c("Item","div"),itemContent:e,listClassName:o,ListComponent:c("List","div"),readyStateChanged:l,reportReadyState:d,ScrollerComponent:c("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:c("ScrollSeekPlaceholder","div")}}),tT=Ke(([e,t])=>({...e,...t}),rt(QC,eT)),nT=w.memo(function(){const e=it("gridState"),t=it("listClassName"),n=it("itemClassName"),r=it("itemContent"),o=it("computeItemKey"),s=it("isSeeking"),i=nn("scrollHeight"),a=it("ItemComponent"),c=it("ListComponent"),l=it("ScrollSeekPlaceholder"),d=it("context"),p=nn("itemDimensions"),m=nn("gap"),f=it("log"),v=it("stateRestoreInProgress"),g=nn("reportReadyState"),x=ir(w.useMemo(()=>y=>{const b=y.parentElement.parentElement.scrollHeight;i(b);const C=y.firstChild;if(C){const{height:k,width:S}=C.getBoundingClientRect();p({height:k,width:S})}m({column:oh("column-gap",getComputedStyle(y).columnGap,f),row:oh("row-gap",getComputedStyle(y).rowGap,f)})},[i,p,m,f]),!0,!1);return Wp(()=>{e.itemHeight>0&&e.itemWidth>0&&g(!0)},[e]),v?null:u.jsx(c,{className:t,ref:x,...Rt(c,d),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(y=>{const b=o(y.index,y.data,d);return s?u.jsx(l,{...Rt(l,d),height:e.itemHeight,index:y.index,width:e.itemWidth},b):w.createElement(a,{...Rt(a,d),className:n,"data-index":y.index,key:b},r(y.index,y.data,d))})})}),rT=w.memo(function(){const e=it("HeaderComponent"),t=nn("headerHeight"),n=it("headerFooterTag"),r=ir(w.useMemo(()=>s=>{t(Hn(s,"height"))},[t]),!0,!1),o=it("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Rt(e,o)})}):null}),oT=w.memo(function(){const e=it("FooterComponent"),t=nn("footerHeight"),n=it("headerFooterTag"),r=ir(w.useMemo(()=>s=>{t(Hn(s,"height"))},[t]),!0,!1),o=it("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Rt(e,o)})}):null}),sT=({children:e})=>{const t=w.useContext(Up),n=nn("itemDimensions"),r=nn("viewportDimensions"),o=ir(w.useMemo(()=>s=>{r(s.getBoundingClientRect())},[r]),!0,!1);return w.useEffect(()=>{t&&(r({height:t.viewportHeight,width:t.viewportWidth}),n({height:t.itemHeight,width:t.itemWidth}))},[t,r,n]),u.jsx("div",{ref:o,style:Fs(!1),children:e})},iT=({children:e})=>{const t=w.useContext(Up),n=nn("windowViewportRect"),r=nn("itemDimensions"),o=it("customScrollParent"),s=hp(n,o,!1);return w.useEffect(()=>{t&&(r({height:t.itemHeight,width:t.itemWidth}),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:t.viewportWidth}))},[t,n,r]),u.jsx("div",{ref:s,style:Fs(!1),children:e})},aT=w.memo(function({...e}){const t=it("useWindowScroll"),n=it("customScrollParent"),r=n||t?cT:lT,o=n||t?iT:sT,s=it("context");return u.jsx(r,{...e,...Rt(r,s),children:u.jsxs(o,{children:[u.jsx(rT,{}),u.jsx(nT,{}),u.jsx(oT,{})]})})}),{useEmitter:rh,useEmitterValue:it,usePublisher:nn}=zp(tT,{optional:{context:"context",totalCount:"totalCount",overscan:"overscan",itemContent:"itemContent",components:"components",computeItemKey:"computeItemKey",data:"data",initialItemCount:"initialItemCount",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"headerFooterTag",listClassName:"listClassName",itemClassName:"itemClassName",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",restoreStateFrom:"restoreStateFrom",initialTopMostItemIndex:"initialTopMostItemIndex",increaseViewportBy:"increaseViewportBy"},methods:{scrollTo:"scrollTo",scrollBy:"scrollBy",scrollToIndex:"scrollToIndex"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",stateChanged:"stateChanged",readyStateChanged:"readyStateChanged"}},aT),lT=Yp({useEmitter:rh,useEmitterValue:it,usePublisher:nn}),cT=Xp({useEmitter:rh,useEmitterValue:it,usePublisher:nn});function oh(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Ut.WARN),t==="normal"?0:parseInt(t??"0",10)}var Hs="Dialog",[sh,HN]=cn(Hs),[uT,hn]=sh(Hs),ih=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:i=!0}=e,a=h.useRef(null),c=h.useRef(null),[l,d]=On({prop:r,defaultProp:o??!1,onChange:s,caller:Hs});return u.jsx(uT,{scope:t,triggerRef:a,contentRef:c,contentId:jt(),titleId:jt(),descriptionId:jt(),open:l,onOpenChange:d,onOpenToggle:h.useCallback(()=>d(p=>!p),[d]),modal:i,children:n})};ih.displayName=Hs;var ah="DialogTrigger",lh=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=hn(ah,n),s=je(t,o.triggerRef);return u.jsx(he.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":il(o.open),...r,ref:s,onClick:ae(e.onClick,o.onOpenToggle)})});lh.displayName=ah;var ol="DialogPortal",[dT,ch]=sh(ol,{forceMount:void 0}),uh=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=hn(ol,t);return u.jsx(dT,{scope:t,forceMount:n,children:h.Children.map(r,i=>u.jsx(Ht,{present:n||s.open,children:u.jsx(co,{asChild:!0,container:o,children:i})}))})};uh.displayName=ol;var Us="DialogOverlay",dh=h.forwardRef((e,t)=>{const n=ch(Us,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=hn(Us,e.__scopeDialog);return s.modal?u.jsx(Ht,{present:r||s.open,children:u.jsx(pT,{...o,ref:t})}):null});dh.displayName=Us;var fT=qt.createSlot("DialogOverlay.RemoveScroll"),pT=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=hn(Us,n);return u.jsx(ys,{as:fT,allowPinchZoom:!0,shards:[o.contentRef],children:u.jsx(he.div,{"data-state":il(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),cr="DialogContent",fh=h.forwardRef((e,t)=>{const n=ch(cr,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=hn(cr,e.__scopeDialog);return u.jsx(Ht,{present:r||s.open,children:s.modal?u.jsx(hT,{...o,ref:t}):u.jsx(mT,{...o,ref:t})})});fh.displayName=cr;var hT=h.forwardRef((e,t)=>{const n=hn(cr,e.__scopeDialog),r=h.useRef(null),o=je(t,n.contentRef,r);return h.useEffect(()=>{const s=r.current;if(s)return ya(s)},[]),u.jsx(ph,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ae(e.onCloseAutoFocus,s=>{var i;s.preventDefault(),(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:ae(e.onPointerDownOutside,s=>{const i=s.detail.originalEvent,a=i.button===0&&i.ctrlKey===!0;(i.button===2||a)&&s.preventDefault()}),onFocusOutside:ae(e.onFocusOutside,s=>s.preventDefault())})}),mT=h.forwardRef((e,t)=>{const n=hn(cr,e.__scopeDialog),r=h.useRef(!1),o=h.useRef(!1);return u.jsx(ph,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var i,a;(i=e.onCloseAutoFocus)==null||i.call(e,s),s.defaultPrevented||(r.current||(a=n.triggerRef.current)==null||a.focus(),s.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:s=>{var c,l;(c=e.onInteractOutside)==null||c.call(e,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const i=s.target;((l=n.triggerRef.current)==null?void 0:l.contains(i))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&o.current&&s.preventDefault()}})}),ph=h.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=hn(cr,n),c=h.useRef(null),l=je(t,c);return Zi(),u.jsxs(u.Fragment,{children:[u.jsx(ns,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:u.jsx(Er,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":il(a.open),...i,ref:l,onDismiss:()=>a.onOpenChange(!1)})}),u.jsxs(u.Fragment,{children:[u.jsx(gT,{titleId:a.titleId}),u.jsx(vT,{contentRef:c,descriptionId:a.descriptionId})]})]})}),sl="DialogTitle",hh=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=hn(sl,n);return u.jsx(he.h2,{id:o.titleId,...r,ref:t})});hh.displayName=sl;var mh="DialogDescription",gh=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=hn(mh,n);return u.jsx(he.p,{id:o.descriptionId,...r,ref:t})});gh.displayName=mh;var xh="DialogClose",vh=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=hn(xh,n);return u.jsx(he.button,{type:"button",...r,ref:t,onClick:ae(e.onClick,()=>o.onOpenChange(!1))})});vh.displayName=xh;function il(e){return e?"open":"closed"}var wh="DialogTitleWarning",[UN,bh]=_w(wh,{contentName:cr,titleName:sl,docsSlug:"dialog"}),gT=({titleId:e})=>{const t=bh(wh),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
79
|
+
`)},v0=0,Or=[];function w0(e){var t=h.useRef([]),n=h.useRef([0,0]),r=h.useRef(),o=h.useState(v0++)[0],s=h.useState(nf)[0],i=h.useRef(e);h.useEffect(function(){i.current=e},[e]),h.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var g=By([e.lockRef.current],(e.shards||[]).map(uf),!0).filter(Boolean);return g.forEach(function(x){return x.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),g.forEach(function(x){return x.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var a=h.useCallback(function(g,x){if("touches"in g&&g.touches.length===2||g.type==="wheel"&&g.ctrlKey)return!i.current.allowPinchZoom;var y=bs(g),b=n.current,C="deltaX"in g?g.deltaX:b[0]-y[0],k="deltaY"in g?g.deltaY:b[1]-y[1],S,T=g.target,E=Math.abs(C)>Math.abs(k)?"h":"v";if("touches"in g&&E==="h"&&T.type==="range")return!1;var A=sf(E,T);if(!A)return!0;if(A?S=E:(S=E==="v"?"h":"v",A=sf(E,T)),!A)return!1;if(!r.current&&"changedTouches"in g&&(C||k)&&(r.current=S),!S)return!0;var P=r.current||S;return m0(P,x,g,P==="h"?C:k)},[]),l=h.useCallback(function(g){var x=g;if(!(!Or.length||Or[Or.length-1]!==s)){var y="deltaY"in x?cf(x):bs(x),b=t.current.filter(function(S){return S.name===x.type&&(S.target===x.target||x.target===S.shadowParent)&&g0(S.delta,y)})[0];if(b&&b.should){x.cancelable&&x.preventDefault();return}if(!b){var C=(i.current.shards||[]).map(uf).filter(Boolean).filter(function(S){return S.contains(x.target)}),k=C.length>0?a(x,C[0]):!i.current.noIsolation;k&&x.cancelable&&x.preventDefault()}}},[]),c=h.useCallback(function(g,x,y,b){var C={name:g,delta:x,target:y,should:b,shadowParent:b0(y)};t.current.push(C),setTimeout(function(){t.current=t.current.filter(function(k){return k!==C})},1)},[]),d=h.useCallback(function(g){n.current=bs(g),r.current=void 0},[]),p=h.useCallback(function(g){c(g.type,cf(g),g.target,a(g,e.lockRef.current))},[]),m=h.useCallback(function(g){c(g.type,bs(g),g.target,a(g,e.lockRef.current))},[]);h.useEffect(function(){return Or.push(s),e.setCallbacks({onScrollCapture:p,onWheelCapture:p,onTouchMoveCapture:m}),document.addEventListener("wheel",l,Mr),document.addEventListener("touchmove",l,Mr),document.addEventListener("touchstart",d,Mr),function(){Or=Or.filter(function(g){return g!==s}),document.removeEventListener("wheel",l,Mr),document.removeEventListener("touchmove",l,Mr),document.removeEventListener("touchstart",d,Mr)}},[]);var f=e.removeScrollBar,v=e.inert;return h.createElement(h.Fragment,null,v?h.createElement(s,{styles:x0(o)}):null,f?h.createElement(l0,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function b0(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const y0=Yy(tf,w0);var ys=h.forwardRef(function(e,t){return h.createElement(vs,Cn({},e,{ref:t,sideCar:y0}))});ys.classNames=vs.classNames;var Ea=["Enter"," "],S0=["ArrowDown","PageUp","Home"],df=["ArrowUp","PageDown","End"],C0=[...S0,...df],T0={ltr:[...Ea,"ArrowRight"],rtl:[...Ea,"ArrowLeft"]},k0={ltr:["ArrowLeft"],rtl:["ArrowRight"]},fo="Menu",[po,E0,I0]=es(fo),[rr,ff]=cn(fo,[I0,jr,Kd]),Ss=jr(),pf=Kd(),[N0,or]=rr(fo),[A0,ho]=rr(fo),hf=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=Ss(t),[l,c]=h.useState(null),d=h.useRef(!1),p=ht(s),m=ts(o);return h.useEffect(()=>{const f=()=>{d.current=!0,document.addEventListener("pointerdown",v,{capture:!0,once:!0}),document.addEventListener("pointermove",v,{capture:!0,once:!0})},v=()=>d.current=!1;return document.addEventListener("keydown",f,{capture:!0}),()=>{document.removeEventListener("keydown",f,{capture:!0}),document.removeEventListener("pointerdown",v,{capture:!0}),document.removeEventListener("pointermove",v,{capture:!0})}},[]),u.jsx(ha,{...a,children:u.jsx(N0,{scope:t,open:n,onOpenChange:p,content:l,onContentChange:c,children:u.jsx(A0,{scope:t,onClose:h.useCallback(()=>p(!1),[p]),isUsingKeyboardRef:d,dir:m,modal:i,children:r})})})};hf.displayName=fo;var P0="MenuAnchor",Ia=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=Ss(n);return u.jsx(ma,{...o,...r,ref:t})});Ia.displayName=P0;var Na="MenuPortal",[j0,mf]=rr(Na,{forceMount:void 0}),gf=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=or(Na,t);return u.jsx(j0,{scope:t,forceMount:n,children:u.jsx(Ht,{present:n||s.open,children:u.jsx(co,{asChild:!0,container:o,children:r})})})};gf.displayName=Na;var tn="MenuContent",[_0,Aa]=rr(tn),xf=h.forwardRef((e,t)=>{const n=mf(tn,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=or(tn,e.__scopeMenu),i=ho(tn,e.__scopeMenu);return u.jsx(po.Provider,{scope:e.__scopeMenu,children:u.jsx(Ht,{present:r||s.open,children:u.jsx(po.Slot,{scope:e.__scopeMenu,children:i.modal?u.jsx(R0,{...o,ref:t}):u.jsx(M0,{...o,ref:t})})})})}),R0=h.forwardRef((e,t)=>{const n=or(tn,e.__scopeMenu),r=h.useRef(null),o=je(t,r);return h.useEffect(()=>{const s=r.current;if(s)return ya(s)},[]),u.jsx(Pa,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:ie(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),M0=h.forwardRef((e,t)=>{const n=or(tn,e.__scopeMenu);return u.jsx(Pa,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),O0=qt.createSlot("MenuContent.ScrollLock"),Pa=h.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:p,onInteractOutside:m,onDismiss:f,disableOutsideScroll:v,...g}=e,x=or(tn,n),y=ho(tn,n),b=Ss(n),C=pf(n),k=E0(n),[S,T]=h.useState(null),E=h.useRef(null),A=je(t,E,x.onContentChange),P=h.useRef(0),$=h.useRef(""),L=h.useRef(0),H=h.useRef(null),Y=h.useRef("right"),_=h.useRef(0),V=v?ys:h.Fragment,G=v?{as:O0,allowPinchZoom:!0}:void 0,W=I=>{var M,O;const U=$.current+I,Z=k().filter(F=>!F.disabled),R=document.activeElement,q=(M=Z.find(F=>F.ref.current===R))==null?void 0:M.textValue,j=Z.map(F=>F.textValue),B=q0(j,U,q),Q=(O=Z.find(F=>F.textValue===B))==null?void 0:O.ref.current;(function F(J){$.current=J,window.clearTimeout(P.current),J!==""&&(P.current=window.setTimeout(()=>F(""),1e3))})(U),Q&&setTimeout(()=>Q.focus())};h.useEffect(()=>()=>window.clearTimeout(P.current),[]),Zi();const D=h.useCallback(I=>{var Z,R;return Y.current===((Z=H.current)==null?void 0:Z.side)&&Y0(I,(R=H.current)==null?void 0:R.area)},[]);return u.jsx(_0,{scope:n,searchRef:$,onItemEnter:h.useCallback(I=>{D(I)&&I.preventDefault()},[D]),onItemLeave:h.useCallback(I=>{var U;D(I)||((U=E.current)==null||U.focus(),T(null))},[D]),onTriggerLeave:h.useCallback(I=>{D(I)&&I.preventDefault()},[D]),pointerGraceTimerRef:L,onPointerGraceIntentChange:h.useCallback(I=>{H.current=I},[]),children:u.jsx(V,{...G,children:u.jsx(ns,{asChild:!0,trapped:o,onMountAutoFocus:ie(s,I=>{var U;I.preventDefault(),(U=E.current)==null||U.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:u.jsx(Er,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:p,onInteractOutside:m,onDismiss:f,children:u.jsx(Oy,{asChild:!0,...C,dir:y.dir,orientation:"vertical",loop:r,currentTabStopId:S,onCurrentTabStopIdChange:T,onEntryFocus:ie(l,I=>{y.isUsingKeyboardRef.current||I.preventDefault()}),preventScrollOnEntryFocus:!0,children:u.jsx(ga,{role:"menu","aria-orientation":"vertical","data-state":Mf(x.open),"data-radix-menu-content":"",dir:y.dir,...b,...g,ref:A,style:{outline:"none",...g.style},onKeyDown:ie(g.onKeyDown,I=>{const Z=I.target.closest("[data-radix-menu-content]")===I.currentTarget,R=I.ctrlKey||I.altKey||I.metaKey,q=I.key.length===1;Z&&(I.key==="Tab"&&I.preventDefault(),!R&&q&&W(I.key));const j=E.current;if(I.target!==j||!C0.includes(I.key))return;I.preventDefault();const Q=k().filter(M=>!M.disabled).map(M=>M.ref.current);df.includes(I.key)&&Q.reverse(),V0(Q)}),onBlur:ie(e.onBlur,I=>{I.currentTarget.contains(I.target)||(window.clearTimeout(P.current),$.current="")}),onPointerMove:ie(e.onPointerMove,go(I=>{const U=I.target,Z=_.current!==I.clientX;if(I.currentTarget.contains(U)&&Z){const R=I.clientX>_.current?"right":"left";Y.current=R,_.current=I.clientX}}))})})})})})})});xf.displayName=tn;var D0="MenuGroup",ja=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(pe.div,{role:"group",...r,ref:t})});ja.displayName=D0;var L0="MenuLabel",vf=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(pe.div,{...r,ref:t})});vf.displayName=L0;var Cs="MenuItem",wf="menu.itemSelect",Ts=h.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=h.useRef(null),i=ho(Cs,e.__scopeMenu),a=Aa(Cs,e.__scopeMenu),l=je(t,s),c=h.useRef(!1),d=()=>{const p=s.current;if(!n&&p){const m=new CustomEvent(wf,{bubbles:!0,cancelable:!0});p.addEventListener(wf,f=>r==null?void 0:r(f),{once:!0}),Yi(p,m),m.defaultPrevented?c.current=!1:i.onClose()}};return u.jsx(bf,{...o,ref:l,disabled:n,onClick:ie(e.onClick,d),onPointerDown:p=>{var m;(m=e.onPointerDown)==null||m.call(e,p),c.current=!0},onPointerUp:ie(e.onPointerUp,p=>{var m;c.current||(m=p.currentTarget)==null||m.click()}),onKeyDown:ie(e.onKeyDown,p=>{const m=a.searchRef.current!=="";n||m&&p.key===" "||Ea.includes(p.key)&&(p.currentTarget.click(),p.preventDefault())})})});Ts.displayName=Cs;var bf=h.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=Aa(Cs,n),a=pf(n),l=h.useRef(null),c=je(t,l),[d,p]=h.useState(!1),[m,f]=h.useState("");return h.useEffect(()=>{const v=l.current;v&&f((v.textContent??"").trim())},[s.children]),u.jsx(po.ItemSlot,{scope:n,disabled:r,textValue:o??m,children:u.jsx(Dy,{asChild:!0,...a,focusable:!r,children:u.jsx(pe.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:c,onPointerMove:ie(e.onPointerMove,go(v=>{r?i.onItemLeave(v):(i.onItemEnter(v),v.defaultPrevented||v.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:ie(e.onPointerLeave,go(v=>i.onItemLeave(v))),onFocus:ie(e.onFocus,()=>p(!0)),onBlur:ie(e.onBlur,()=>p(!1))})})})}),$0="MenuCheckboxItem",yf=h.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return u.jsx(Ef,{scope:e.__scopeMenu,checked:n,children:u.jsx(Ts,{role:"menuitemcheckbox","aria-checked":ks(n)?"mixed":n,...o,ref:t,"data-state":Ra(n),onSelect:ie(o.onSelect,()=>r==null?void 0:r(ks(n)?!0:!n),{checkForDefaultPrevented:!1})})})});yf.displayName=$0;var Sf="MenuRadioGroup",[F0,B0]=rr(Sf,{value:void 0,onValueChange:()=>{}}),Cf=h.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=ht(r);return u.jsx(F0,{scope:e.__scopeMenu,value:n,onValueChange:s,children:u.jsx(ja,{...o,ref:t})})});Cf.displayName=Sf;var Tf="MenuRadioItem",kf=h.forwardRef((e,t)=>{const{value:n,...r}=e,o=B0(Tf,e.__scopeMenu),s=n===o.value;return u.jsx(Ef,{scope:e.__scopeMenu,checked:s,children:u.jsx(Ts,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":Ra(s),onSelect:ie(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});kf.displayName=Tf;var _a="MenuItemIndicator",[Ef,z0]=rr(_a,{checked:!1}),If=h.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=z0(_a,n);return u.jsx(Ht,{present:r||ks(s.checked)||s.checked===!0,children:u.jsx(pe.span,{...o,ref:t,"data-state":Ra(s.checked)})})});If.displayName=_a;var H0="MenuSeparator",Nf=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(pe.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});Nf.displayName=H0;var U0="MenuArrow",Af=h.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=Ss(n);return u.jsx(xa,{...o,...r,ref:t})});Af.displayName=U0;var W0="MenuSub",[FN,Pf]=rr(W0),mo="MenuSubTrigger",jf=h.forwardRef((e,t)=>{const n=or(mo,e.__scopeMenu),r=ho(mo,e.__scopeMenu),o=Pf(mo,e.__scopeMenu),s=Aa(mo,e.__scopeMenu),i=h.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,c={__scopeMenu:e.__scopeMenu},d=h.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return h.useEffect(()=>d,[d]),h.useEffect(()=>{const p=a.current;return()=>{window.clearTimeout(p),l(null)}},[a,l]),u.jsx(Ia,{asChild:!0,...c,children:u.jsx(bf,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":Mf(n.open),...e,ref:Mn(t,o.onTriggerChange),onClick:p=>{var m;(m=e.onClick)==null||m.call(e,p),!(e.disabled||p.defaultPrevented)&&(p.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:ie(e.onPointerMove,go(p=>{s.onItemEnter(p),!p.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(s.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),d()},100))})),onPointerLeave:ie(e.onPointerLeave,go(p=>{var f,v;d();const m=(f=n.content)==null?void 0:f.getBoundingClientRect();if(m){const g=(v=n.content)==null?void 0:v.dataset.side,x=g==="right",y=x?-5:5,b=m[x?"left":"right"],C=m[x?"right":"left"];s.onPointerGraceIntentChange({area:[{x:p.clientX+y,y:p.clientY},{x:b,y:m.top},{x:C,y:m.top},{x:C,y:m.bottom},{x:b,y:m.bottom}],side:g}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(p),p.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:ie(e.onKeyDown,p=>{var f;const m=s.searchRef.current!=="";e.disabled||m&&p.key===" "||T0[r.dir].includes(p.key)&&(n.onOpenChange(!0),(f=n.content)==null||f.focus(),p.preventDefault())})})})});jf.displayName=mo;var _f="MenuSubContent",Rf=h.forwardRef((e,t)=>{const n=mf(tn,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=or(tn,e.__scopeMenu),i=ho(tn,e.__scopeMenu),a=Pf(_f,e.__scopeMenu),l=h.useRef(null),c=je(t,l);return u.jsx(po.Provider,{scope:e.__scopeMenu,children:u.jsx(Ht,{present:r||s.open,children:u.jsx(po.Slot,{scope:e.__scopeMenu,children:u.jsx(Pa,{id:a.contentId,"aria-labelledby":a.triggerId,...o,ref:c,align:"start",side:i.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:d=>{var p;i.isUsingKeyboardRef.current&&((p=l.current)==null||p.focus()),d.preventDefault()},onCloseAutoFocus:d=>d.preventDefault(),onFocusOutside:ie(e.onFocusOutside,d=>{d.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:ie(e.onEscapeKeyDown,d=>{i.onClose(),d.preventDefault()}),onKeyDown:ie(e.onKeyDown,d=>{var f;const p=d.currentTarget.contains(d.target),m=k0[i.dir].includes(d.key);p&&m&&(s.onOpenChange(!1),(f=a.trigger)==null||f.focus(),d.preventDefault())})})})})})});Rf.displayName=_f;function Mf(e){return e?"open":"closed"}function ks(e){return e==="indeterminate"}function Ra(e){return ks(e)?"indeterminate":e?"checked":"unchecked"}function V0(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function K0(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function q0(e,t,n){const o=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=K0(e,Math.max(s,0));o.length===1&&(i=i.filter(c=>c!==n));const l=i.find(c=>c.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function G0(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const a=t[s],l=t[i],c=a.x,d=a.y,p=l.x,m=l.y;d>r!=m>r&&n<(p-c)*(r-d)/(m-d)+c&&(o=!o)}return o}function Y0(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return G0(n,t)}function go(e){return t=>t.pointerType==="mouse"?e(t):void 0}var X0=hf,J0=Ia,Z0=gf,Q0=xf,eS=ja,tS=vf,nS=Ts,rS=yf,oS=Cf,sS=kf,iS=If,aS=Nf,lS=Af,cS=jf,uS=Rf,Es="DropdownMenu",[dS,BN]=cn(Es,[ff]),Lt=ff(),[fS,Of]=dS(Es),Df=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,l=Lt(t),c=h.useRef(null),[d,p]=On({prop:o,defaultProp:s??!1,onChange:i,caller:Es});return u.jsx(fS,{scope:t,triggerId:_t(),triggerRef:c,contentId:_t(),open:d,onOpenChange:p,onOpenToggle:h.useCallback(()=>p(m=>!m),[p]),modal:a,children:u.jsx(X0,{...l,open:d,onOpenChange:p,dir:r,modal:a,children:n})})};Df.displayName=Es;var Lf="DropdownMenuTrigger",$f=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=Of(Lf,n),i=Lt(n);return u.jsx(J0,{asChild:!0,...i,children:u.jsx(pe.button,{type:"button",id:s.triggerId,"aria-haspopup":"menu","aria-expanded":s.open,"aria-controls":s.open?s.contentId:void 0,"data-state":s.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...o,ref:Mn(t,s.triggerRef),onPointerDown:ie(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:ie(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});$f.displayName=Lf;var pS="DropdownMenuPortal",Ff=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Lt(t);return u.jsx(Z0,{...r,...n})};Ff.displayName=pS;var Bf="DropdownMenuContent",zf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Of(Bf,n),s=Lt(n),i=h.useRef(!1);return u.jsx(Q0,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:ie(e.onCloseAutoFocus,a=>{var l;i.current||(l=o.triggerRef.current)==null||l.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:ie(e.onInteractOutside,a=>{const l=a.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0,d=l.button===2||c;(!o.modal||d)&&(i.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});zf.displayName=Bf;var hS="DropdownMenuGroup",mS=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Lt(n);return u.jsx(eS,{...o,...r,ref:t})});mS.displayName=hS;var gS="DropdownMenuLabel",Hf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Lt(n);return u.jsx(tS,{...o,...r,ref:t})});Hf.displayName=gS;var xS="DropdownMenuItem",Uf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Lt(n);return u.jsx(nS,{...o,...r,ref:t})});Uf.displayName=xS;var vS="DropdownMenuCheckboxItem",Wf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Lt(n);return u.jsx(rS,{...o,...r,ref:t})});Wf.displayName=vS;var wS="DropdownMenuRadioGroup",bS=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Lt(n);return u.jsx(oS,{...o,...r,ref:t})});bS.displayName=wS;var yS="DropdownMenuRadioItem",Vf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Lt(n);return u.jsx(sS,{...o,...r,ref:t})});Vf.displayName=yS;var SS="DropdownMenuItemIndicator",Kf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Lt(n);return u.jsx(iS,{...o,...r,ref:t})});Kf.displayName=SS;var CS="DropdownMenuSeparator",qf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Lt(n);return u.jsx(aS,{...o,...r,ref:t})});qf.displayName=CS;var TS="DropdownMenuArrow",kS=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Lt(n);return u.jsx(lS,{...o,...r,ref:t})});kS.displayName=TS;var ES="DropdownMenuSubTrigger",Gf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Lt(n);return u.jsx(cS,{...o,...r,ref:t})});Gf.displayName=ES;var IS="DropdownMenuSubContent",Yf=h.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Lt(n);return u.jsx(uS,{...o,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Yf.displayName=IS;var NS=Df,AS=$f,PS=Ff,Xf=zf,Jf=Hf,Zf=Uf,Qf=Wf,ep=Vf,tp=Kf,np=qf,rp=Gf,op=Yf;const Is=NS,Ns=AS,jS=h.forwardRef(({className:e,inset:t,children:n,...r},o)=>u.jsxs(rp,{ref:o,className:ne("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",t&&"pl-8",e),...r,children:[n,u.jsx(le.ChevronRight,{className:"ml-auto h-4 w-4"})]}));jS.displayName=rp.displayName;const _S=h.forwardRef(({className:e,...t},n)=>u.jsx(op,{ref:n,className:ne("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...t}));_S.displayName=op.displayName;const xo=h.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(PS,{children:u.jsx(Xf,{ref:r,sideOffset:t,className:ne("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n})}));xo.displayName=Xf.displayName;const Fn=h.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(Zf,{ref:r,className:ne("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...n}));Fn.displayName=Zf.displayName;const RS=h.forwardRef(({className:e,children:t,checked:n,...r},o)=>u.jsxs(Qf,{ref:o,className:ne("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:n,...r,children:[u.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx(tp,{children:u.jsx(le.Check,{className:"h-4 w-4"})})}),t]}));RS.displayName=Qf.displayName;const MS=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(ep,{ref:r,className:ne("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[u.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx(tp,{children:u.jsx(le.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));MS.displayName=ep.displayName;const OS=h.forwardRef(({className:e,inset:t,...n},r)=>u.jsx(Jf,{ref:r,className:ne("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));OS.displayName=Jf.displayName;const DS=h.forwardRef(({className:e,...t},n)=>u.jsx(np,{ref:n,className:ne("-mx-1 my-1 h-px bg-muted",e),...t}));DS.displayName=np.displayName;const Ma=h.forwardRef(({className:e,...t},n)=>u.jsx("textarea",{className:ne("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),ref:n,...t}));Ma.displayName="Textarea";const LS=1e4;function sp({initialValue:e="",editingMessageId:t=null,placeholder:n="Type your message...",isStreaming:r=!1,disabled:o=!1,maxLength:s=LS,value:i,onValueChange:a,onSend:l,onCancelEdit:c,onStop:d,className:p="",textareaClassName:m="",allowEmptySend:f=!1,sendButtonClassName:v,validate:g,onValidationError:x}){const y=i!==void 0,[b,C]=w.useState(e),k=(y?i:b)??"",[S,T]=w.useTransition(),E=w.useRef(null),A=w.useRef(0),P=w.useRef(null),$=w.useRef("");w.useEffect(()=>{y||(C(e??""),P.current=null,E.current&&(E.current.style.height="auto",E.current.style.height=`${E.current.scrollHeight}px`))},[e,t,y]);const[L,H]=w.useState(null),Y=w.useCallback(j=>j.length>s?`Message too long (${j.length}/${s} characters)`:null,[s]),_=w.useMemo(()=>g??Y,[g,Y]),V=w.useCallback(j=>{const B=_(j);return H(B),x==null||x(B),$.current=j,B},[_,x]),G=w.useCallback(()=>{const j=E.current;j&&(j.style.height="auto",j.style.height=`${j.scrollHeight}px`)},[]);w.useEffect(()=>{G()},[G,k]),w.useEffect(()=>{if(!L)return;const j=(k??"").trim();$.current!==j&&V(j)},[k,L,V]);const W=w.useCallback((j,{fromUser:B})=>{y||C(j),B&&(a==null||a(j))},[y,a]),D=w.useCallback(async j=>{j&&j.preventDefault();const B=(k??"").trim();if(!B&&!f||V(B))return;const Q=++A.current;P.current={id:Q,shouldClear:!0},T(()=>{var M,O,F;try{const J=l(B);J&&typeof J.then=="function"?J.then(()=>{var oe,ae;((oe=P.current)==null?void 0:oe.id)===Q&&P.current.shouldClear&&(y||(C(""),E.current&&(E.current.style.height="auto"),a==null||a(""))),((ae=P.current)==null?void 0:ae.id)===Q&&(P.current=null)}).catch(()=>{var oe;((oe=P.current)==null?void 0:oe.id)===Q&&(P.current=null)}):(((M=P.current)==null?void 0:M.id)===Q&&P.current.shouldClear&&(y||(C(""),E.current&&(E.current.style.height="auto"),a==null||a(""))),((O=P.current)==null?void 0:O.id)===Q&&(P.current=null))}catch{((F=P.current)==null?void 0:F.id)===Q&&(P.current=null)}})},[k,l,f,y,a,V]),I=w.useCallback(j=>{const B=j.target.value;W(B,{fromUser:!0}),P.current&&(P.current.shouldClear=!1),E.current&&(E.current.style.height="auto",E.current.style.height=`${E.current.scrollHeight}px`),L&&V(B.trim())},[W,V,L]),U=w.useCallback(j=>{j.key==="Enter"&&!j.shiftKey?(j.preventDefault(),D()):j.key==="Escape"&&t&&(j.preventDefault(),c==null||c())},[D,t,c]),q=`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:j=>void D(j),className:`w-full ${p}`,children:u.jsxs("div",{className:"flex items-end gap-2",children:[u.jsxs("div",{className:"flex-1",children:[u.jsx(Ma,{ref:E,value:k,onChange:I,onKeyDown:U,placeholder:t?"Edit your message...":n,className:q,disabled:o,maxLength:s,rows:1,spellCheck:!1,autoCorrect:"off"}),L&&u.jsx("p",{className:"mt-1 text-xs text-destructive font-medium",children:L})]}),u.jsx("div",{children:r?u.jsx(Ye,{type:"button",onClick:()=>{d==null||d()},size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",disabled:o||!d,children:u.jsx(le.Square,{size:16})}):u.jsx(Ye,{type:"submit",size:"icon",className:`shrink-0 ${v??""}`,title:t?"Save changes":"Send message",disabled:o||!k.trim()&&!f||S,children:u.jsx(le.Send,{size:16})})})]})})}const $S=w.memo(sp);function ip({composerValue:e,onComposerChange:t,onSend:n,onCancelEdit:r,onStop:o,editingMessageId:s=null,editingInitialValue:i="",placeholder:a="Type your message...",isStreaming:l=!1,disabled:c=!1,textareaClassName:d="",customStyles:p={},enableFileUpload:m=!1,enableExcelUpload:f=!1,onExcelUpload:v,onError:g,allowEmptySend:x=!1,inputError:y=null}){const[b,C]=w.useState([]),k=w.useRef(null),S=w.useRef(null),[T,E]=w.useState(0),[A,P]=w.useState(0),[$,L]=w.useState(!1),[H,Y]=w.useState(null),[_,V]=w.useState(null),G=w.useCallback(()=>{k.current&&(k.current.value=""),S.current&&(S.current.value=""),E(j=>j+1),P(j=>j+1)},[]),W=w.useCallback(j=>{C(B=>[...B,...j])},[]),D=w.useCallback(j=>{const B=Array.from(j.target.files||[]);W(B),j.target.value=""},[W]),I=w.useCallback(j=>{C(B=>{const Q=B.filter((M,O)=>O!==j);return Q.length===0&&G(),Q})},[G]),U=w.useCallback(async j=>{const B=(j.target.files||[])[0];if(B&&(Y(null),V(null),!!v)){L(!0);try{await v(B),Y(`Uploaded ${B.name} - processing through chat stream`)}catch(Q){const M=Q instanceof Error?Q.message:"Failed to upload Excel file";V(M),g==null||g(M)}finally{L(!1),j.target.value="",G()}}},[v,g,G]),Z=w.useMemo(()=>x||b.length>0,[x,b]),R=w.useCallback(async j=>{const Q=await n(j,b);return b.length>0&&(C([]),G()),Q},[n,G,b]),q=`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${s?"border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50":""} ${y?"border-red-400":""} ${p.textarea||""} ${d}`;return u.jsxs(u.Fragment,{children:[(m||f)&&u.jsxs("div",{className:"mb-3 space-y-3",children:[m&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:k,type:"file",multiple:!0,onChange:D,className:"hidden"},T),b.length>0&&u.jsx("div",{className:"flex flex-wrap gap-2",children:b.map((j,B)=>u.jsxs("div",{className:"flex items-center gap-2 bg-gray-100 dark:bg-gray-800 rounded-lg px-3 py-2 text-sm text-gray-900 dark:text-gray-100",children:[u.jsx(le.Paperclip,{size:14}),u.jsx("span",{className:"truncate max-w-[150px]",children:j.name}),u.jsx(Ye,{variant:"ghost",size:"sm",onClick:()=>I(B),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 ${j.name}`,children:u.jsx(le.X,{size:12})})]},B))})]}),f&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:S,type:"file",accept:".xls,.xlsx,.xlsm",onChange:U,className:"hidden"},A),$&&u.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(le.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),H&&!$&&u.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:H}),_&&!$&&u.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:_})]})]}),u.jsxs("div",{className:"flex items-end gap-2",children:[(m||f)&&u.jsxs(Is,{children:[u.jsx(Ns,{asChild:!0,children:u.jsx(Ye,{type:"button",size:"icon",variant:"outline",disabled:l||c,title:"More input actions",className:p.moreButton||"",children:u.jsx(le.Plus,{size:16})})}),u.jsxs(xo,{align:"start",sideOffset:6,className:"w-52",children:[m&&u.jsxs(Fn,{onClick:()=>{var j;return(j=k.current)==null?void 0:j.click()},className:"cursor-pointer",children:[u.jsx(le.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),f&&u.jsxs(Fn,{onClick:()=>{var j;$||(j=S.current)==null||j.click()},className:`cursor-pointer ${$?"opacity-60 pointer-events-none":""}`,children:[u.jsx(le.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),u.jsx("div",{className:"flex-1",children:u.jsx($S,{initialValue:i,editingMessageId:s,value:e,onValueChange:t,placeholder:s?"Edit your message...":a,isStreaming:l,disabled:c,onSend:R,onCancelEdit:r,onStop:o,allowEmptySend:Z,textareaClassName:q,sendButtonClassName:p.sendButton})})]})]})}const FS=w.memo(ip),As=0,Bn=1,Dr=2,ap=4;function lp(e){return()=>e}function BS(e){e()}function cp(e,t){return n=>e(t(n))}function up(e,t){return()=>e(t)}function zS(e,t){return n=>e(t,n)}function Oa(e){return e!==void 0}function HS(...e){return()=>{e.map(BS)}}function Lr(){}function Ps(e,t){return t(e),e}function US(e,t){return t(e)}function ot(...e){return e}function Xe(e,t){return e(Bn,t)}function Ee(e,t){e(As,t)}function Da(e){e(Dr)}function mt(e){return e(ap)}function he(e,t){return Xe(e,zS(t,As))}function fn(e,t){const n=e(Bn,r=>{n(),t(r)});return n}function dp(e){let t,n;return r=>o=>{t=o,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function fp(e,t){return e===t}function st(e=fp){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function ye(e){return t=>n=>{e(n)&&t(n)}}function ce(e){return t=>cp(t,e)}function Tn(e){return t=>()=>{t(e)}}function ee(e,...t){const n=WS(...t);return(r,o)=>{switch(r){case Dr:Da(e);return;case Bn:return Xe(e,n(o))}}}function kn(e,t){return n=>r=>{n(t=e(t,r))}}function sr(e){return t=>n=>{e>0?e--:t(n)}}function jn(e){let t=null,n;return r=>o=>{t=o,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function _e(...e){const t=new Array(e.length);let n=0,r=null;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const a=Math.pow(2,i);Xe(s,l=>{const c=n;n=n|a,t[i]=l,c!==o&&n===o&&r&&(r(),r=null)})}),s=>i=>{const a=()=>{s([i].concat(t))};n===o?a():r=a}}function WS(...e){return t=>e.reduceRight(US,t)}function VS(e){let t,n;const r=()=>t==null?void 0:t();return function(o,s){switch(o){case Bn:return s?n===s?void 0:(r(),n=s,t=Xe(e,s),t):(r(),Lr);case Dr:r(),n=null;return}}}function se(e){let t=e;const n=ze();return(r,o)=>{switch(r){case As:t=o;break;case Bn:{o(t);break}case ap:return t}return n(r,o)}}function Rt(e,t){return Ps(se(t),n=>he(e,n))}function ze(){const e=[];return(t,n)=>{switch(t){case As:e.slice().forEach(r=>{r(n)});return;case Dr:e.splice(0,e.length);return;case Bn:return e.push(n),()=>{const r=e.indexOf(n);r>-1&&e.splice(r,1)}}}}function Zt(e){return Ps(ze(),t=>he(e,t))}function qe(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:KS(),singleton:n}}const KS=()=>Symbol();function qS(e){const t=new Map,n=({constructor:r,dependencies:o,id:s,singleton:i})=>{if(i&&t.has(s))return t.get(s);const a=r(o.map(l=>n(l)));return i&&t.set(s,a),a};return n(e)}function xt(...e){const t=ze(),n=new Array(e.length);let r=0;const o=Math.pow(2,e.length)-1;return e.forEach((s,i)=>{const a=Math.pow(2,i);Xe(s,l=>{n[i]=l,r=r|a,r===o&&Ee(t,n)})}),function(s,i){switch(s){case Dr:{Da(t);return}case Bn:return r===o&&i(n),Xe(t,i)}}}function be(e,t=fp){return ee(e,st(t))}function La(...e){return function(t,n){switch(t){case Dr:return;case Bn:return HS(...e.map(r=>Xe(r,n)))}}}var Ut=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(Ut||{});const GS={0:"debug",3:"error",1:"log",2:"warn"},YS=()=>typeof globalThis>"u"?window:globalThis,zn=qe(()=>{const e=se(3);return{log:se((t,n,r=1)=>{var o;const s=(o=YS().VIRTUOSO_LOG_LEVEL)!=null?o:mt(e);r>=s&&console[GS[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0});function ir(e,t,n){return $a(e,t,n).callbackRef}function $a(e,t,n){const r=w.useRef(null);let o=i=>{};const s=w.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(i=>{const a=()=>{const 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 XS(e,t,n,r,o,s,i,a,l){const c=w.useCallback(d=>{const p=JS(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?pp("column-gap",getComputedStyle(d).columnGap,o):pp("row-gap",getComputedStyle(d).rowGap,o)),p!==null&&e(p)},[e,t,o,s,i,r,a]);return $a(c,n,l)}function JS(e,t,n,r){const o=e.length;if(o===0)return null;const s=[];for(let i=0;i<o;i++){const a=e.item(i);if(a.dataset.index===void 0)continue;const 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},Ut.ERROR),d===c)continue;const p=s[s.length-1];s.length===0||p.size!==d||p.endIndex!==l-1?s.push({endIndex:l,size:d,startIndex:l}):s[s.length-1].endIndex++}return s}function pp(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Ut.WARN),t==="normal"?0:parseInt(t??"0",10)}function hp(e,t,n){const r=w.useRef(null),o=w.useCallback(l=>{if(!(l!=null&&l.offsetParent))return;const c=l.getBoundingClientRect(),d=c.width;let p,m;if(t){const f=t.getBoundingClientRect(),v=c.top-f.top;m=f.height-Math.max(0,v),p=v+t.scrollTop}else{const f=i.current.ownerDocument.defaultView;m=f.innerHeight-Math.max(0,c.top),p=c.top+f.scrollY}r.current={offsetTop:p,visibleHeight:m,visibleWidth:d},e(r.current)},[e,t]),{callbackRef:s,ref:i}=$a(o,!0,n),a=w.useCallback(()=>{o(i.current)},[o,i]);return w.useEffect(()=>{var l;if(t){t.addEventListener("scroll",a);const c=new ResizeObserver(()=>{requestAnimationFrame(a)});return c.observe(t),()=>{t.removeEventListener("scroll",a),c.unobserve(t)}}else{const c=(l=i.current)==null?void 0:l.ownerDocument.defaultView;return c==null||c.addEventListener("scroll",a),c==null||c.addEventListener("resize",a),()=>{c==null||c.removeEventListener("scroll",a),c==null||c.removeEventListener("resize",a)}}},[a,t,i]),s}const $t=qe(()=>{const e=ze(),t=ze(),n=se(0),r=ze(),o=se(0),s=ze(),i=ze(),a=se(0),l=se(0),c=se(0),d=se(0),p=ze(),m=ze(),f=se(!1),v=se(!1),g=se(!1);return he(ee(e,ce(({scrollTop:x})=>x)),t),he(ee(e,ce(({scrollHeight:x})=>x)),i),he(t,o),{deviation:n,fixedFooterHeight:c,fixedHeaderHeight:l,footerHeight:d,headerHeight:a,horizontalDirection:v,scrollBy:m,scrollContainerState:e,scrollHeight:i,scrollingInProgress:f,scrollTo:p,scrollTop:t,skipAnimationFrameInResizeObserver:g,smoothScrollTargetReached:r,statefulScrollTop:o,viewportHeight:s}},[],{singleton:!0}),vo={lvl:0};function mp(e,t){const n=e.length;if(n===0)return[];let{index:r,value:o}=t(e[0]);const s=[];for(let i=1;i<n;i++){const{index:a,value: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 Qe(e){return e===vo}function wo(e,t){if(!Qe(e))return t===e.k?e.v:t<e.k?wo(e.l,t):wo(e.r,t)}function pn(e,t,n="k"){if(Qe(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){const r=pn(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return pn(e.l,t,n)}function Qt(e,t,n){return Qe(e)?vp(t,n,1):t===e.k?yt(e,{k:t,v:n}):t<e.k?wp(yt(e,{l:Qt(e.l,t,n)})):wp(yt(e,{r:Qt(e.r,t,n)}))}function $r(){return vo}function js(e,t,n){if(Qe(e))return[];const r=pn(e,t)[0];return ZS(Ba(e,r,n))}function Fa(e,t){if(Qe(e))return vo;const{k:n,l:r,r:o}=e;if(t===n){if(Qe(r))return o;if(Qe(o))return r;{const[s,i]=xp(r);return _s(yt(e,{k:s,l:gp(r),v:i}))}}else return t<n?_s(yt(e,{l:Fa(r,t)})):_s(yt(e,{r:Fa(o,t)}))}function ar(e){return Qe(e)?[]:[...ar(e.l),{k:e.k,v:e.v},...ar(e.r)]}function Ba(e,t,n){if(Qe(e))return[];const{k:r,l:o,r:s,v:i}=e;let a=[];return r>t&&(a=a.concat(Ba(o,t,n))),r>=t&&r<=n&&a.push({k:r,v:i}),r<=n&&(a=a.concat(Ba(s,t,n))),a}function _s(e){const{l:t,lvl:n,r}=e;if(r.lvl>=n-1&&t.lvl>=n-1)return e;if(n>r.lvl+1){if(za(t))return bp(yt(e,{lvl:n-1}));if(!Qe(t)&&!Qe(t.r))return yt(t.r,{l:yt(t,{r:t.r.l}),lvl:n,r:yt(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(za(e))return Ha(yt(e,{lvl:n-1}));if(!Qe(r)&&!Qe(r.l)){const o=r.l,s=za(o)?r.lvl-1:r.lvl;return yt(o,{l:yt(e,{lvl:n-1,r:o.l}),lvl:o.lvl+1,r:Ha(yt(r,{l:o.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function yt(e,t){return vp(t.k!==void 0?t.k:e.k,t.v!==void 0?t.v:e.v,t.lvl!==void 0?t.lvl:e.lvl,t.l!==void 0?t.l:e.l,t.r!==void 0?t.r:e.r)}function gp(e){return Qe(e.r)?e.l:_s(yt(e,{r:gp(e.r)}))}function za(e){return Qe(e)||e.lvl>e.r.lvl}function xp(e){return Qe(e.r)?[e.k,e.v]:xp(e.r)}function vp(e,t,n,r=vo,o=vo){return{k:e,l:r,lvl:n,r:o,v:t}}function wp(e){return Ha(bp(e))}function bp(e){const{l:t}=e;return!Qe(t)&&t.lvl===e.lvl?yt(t,{r:yt(e,{l:t.r})}):e}function Ha(e){const{lvl:t,r:n}=e;return!Qe(n)&&!Qe(n.r)&&n.lvl===t&&n.r.lvl===t?yt(n,{l:yt(e,{r:n.l}),lvl:t+1}):e}function ZS(e){return mp(e,({k:t,v:n})=>({index:t,value:n}))}function yp(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function bo(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const Ua=qe(()=>({recalcInProgress:se(!1)}),[],{singleton:!0});function Sp(e,t,n){return e[Rs(e,t,n)]}function Rs(e,t,n,r=0){let o=e.length-1;for(;r<=o;){const s=Math.floor((r+o)/2),i=e[s],a=n(i,t);if(a===0)return s;if(a===-1){if(o-r<2)return s-1;o=s-1}else{if(o===r)return s;r=s+1}}throw new Error(`Failed binary finding record in array - ${e.join(",")}, searched for ${t}`)}function QS(e,t,n,r){const o=Rs(e,t,r),s=Rs(e,n,r,o);return e.slice(o,s+1)}function Hn(e,t){return Math.round(e.getBoundingClientRect()[t])}function Ms(e){return!Qe(e.groupOffsetTree)}function Wa({index:e},t){return t===e?0:t<e?-1:1}function eC(){return{groupIndices:[],groupOffsetTree:$r(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:$r()}}function tC(e,t){let n=Qe(e)?0:1/0;for(const r of t){const{endIndex:o,size:s,startIndex:i}=r;if(n=Math.min(n,i),Qe(e)){e=Qt(e,0,s);continue}const a=js(e,i-1,o+1);if(a.some(lC(r)))continue;let l=!1,c=!1;for(const{end:d,start:p,value:m}of a)l?(o>=p||s===m)&&(e=Fa(e,p)):(c=m!==s,l=!0),d>o&&o>=p&&m!==s&&(e=Qt(e,o+1,m));c&&(e=Qt(e,i,s))}return[e,n]}function nC(e){return typeof e.groupIndex<"u"}function rC({offset:e},t){return t===e?0:t<e?-1:1}function yo(e,t,n){if(t.length===0)return 0;const{index:r,offset:o,size:s}=Sp(t,e,Wa),i=e-r,a=s*i+(i-1)*n+o;return a>0?a+n:a}function Cp(e,t){if(!Ms(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function Tp(e,t,n){if(nC(e))return t.groupIndices[e.groupIndex]+1;{const r=e.index==="LAST"?n:e.index;let o=Cp(r,t);return o=Math.max(0,o,Math.min(n,o)),o}}function oC(e,t,n,r=0){return r>0&&(t=Math.max(t,Sp(e,r,Wa).offset)),mp(QS(e,t,n,rC),aC)}function sC(e,[t,n,r,o]){t.length>0&&r("received item sizes",t,Ut.DEBUG);const s=e.sizeTree;let i=s,a=0;if(n.length>0&&Qe(s)&&t.length===2){const m=t[0].size,f=t[1].size;i=n.reduce((v,g)=>Qt(Qt(v,g,m),g+1,f),i)}else[i,a]=tC(i,t);if(i===s)return e;const{lastIndex:l,lastOffset:c,lastSize:d,offsetTree:p}=Va(e.offsetTree,a,i,o);return{groupIndices:n,groupOffsetTree:n.reduce((m,f)=>Qt(m,f,yo(f,p,o)),$r()),lastIndex:l,lastOffset:c,lastSize:d,offsetTree:p,sizeTree:i}}function iC(e){return ar(e).map(({k:t,v:n},r,o)=>{const s=o[r+1];return{endIndex:s?s.k-1:1/0,size:n,startIndex:t}})}function kp(e,t){let n=0,r=0;for(;n<e;)n+=t[r+1]-t[r]-1,r++;return r-(n===e?0:1)}function Va(e,t,n,r){let o=e,s=0,i=0,a=0,l=0;if(t!==0){l=Rs(o,t-1,Wa),a=o[l].offset;const c=pn(n,t-1);s=c[0],i=c[1],o.length&&o[l].size===pn(n,t)[1]&&(l-=1),o=o.slice(0,l+1)}else o=[];for(const{start:c,value:d}of js(n,t,1/0)){const p=c-s,m=p*i+a+p*r;o.push({index:c,offset:m,size:d}),s=c,a=m,i=d}return{lastIndex:s,lastOffset:a,lastSize:i,offsetTree:o}}function aC(e){return{index:e.index,value:e}}function lC(e){const{endIndex:t,size:n,startIndex:r}=e;return o=>o.start===r&&(o.end===t||o.end===1/0)&&o.value===n}const cC={offsetHeight:"height",offsetWidth:"width"},En=qe(([{log:e},{recalcInProgress:t}])=>{const n=ze(),r=ze(),o=Rt(r,0),s=ze(),i=ze(),a=se(0),l=se([]),c=se(void 0),d=se(void 0),p=se((S,T)=>Hn(S,cC[T])),m=se(void 0),f=se(0),v=eC(),g=Rt(ee(n,_e(l,e,f),kn(sC,v),st()),v),x=Rt(ee(l,st(),kn((S,T)=>({current:T,prev:S.current}),{current:[],prev:[]}),ce(({prev:S})=>S)),[]);he(ee(l,ye(S=>S.length>0),_e(g,f),ce(([S,T,E])=>{const A=S.reduce((P,$,L)=>Qt(P,$,yo($,T.offsetTree,E)||L),$r());return{...T,groupIndices:S,groupOffsetTree:A}})),g),he(ee(r,_e(g),ye(([S,{lastIndex:T}])=>S<T),ce(([S,{lastIndex:T,lastSize:E}])=>[{endIndex:T,size:E,startIndex:S}])),n),he(c,d);const y=Rt(ee(c,ce(S=>S===void 0)),!0);he(ee(d,ye(S=>S!==void 0&&Qe(mt(g).sizeTree)),ce(S=>[{endIndex:0,size:S,startIndex:0}])),n);const b=Zt(ee(n,_e(g),kn(({sizes:S},[T,E])=>({changed:E!==S,sizes:E}),{changed:!1,sizes:v}),ce(S=>S.changed)));Xe(ee(a,kn((S,T)=>({diff:S.prev-T,prev:T}),{diff:0,prev:0}),ce(S=>S.diff)),S=>{const{groupIndices:T}=mt(g);if(S>0)Ee(t,!0),Ee(s,S+kp(S,T));else if(S<0){const E=mt(x);E.length>0&&(S-=kp(-S,E)),Ee(i,S)}}),Xe(ee(a,_e(e)),([S,T])=>{S<0&&T("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:a},Ut.ERROR)});const C=Zt(s);he(ee(s,_e(g),ce(([S,T])=>{const E=T.groupIndices.length>0,A=[],P=T.lastSize;if(E){const $=wo(T.sizeTree,0);let L=0,H=0;for(;L<S;){const _=T.groupIndices[H],V=T.groupIndices.length===H+1?1/0:T.groupIndices[H+1]-_-1;A.push({endIndex:_,size:$,startIndex:_}),A.push({endIndex:_+1+V-1,size:P,startIndex:_+1}),H++,L+=V+1}const Y=ar(T.sizeTree);return L!==S&&Y.shift(),Y.reduce((_,{k:V,v:G})=>{let W=_.ranges;return _.prevSize!==0&&(W=[..._.ranges,{endIndex:V+S-1,size:_.prevSize,startIndex:_.prevIndex}]),{prevIndex:V+S,prevSize:G,ranges:W}},{prevIndex:S,prevSize:0,ranges:A}).ranges}return ar(T.sizeTree).reduce(($,{k:L,v:H})=>({prevIndex:L+S,prevSize:H,ranges:[...$.ranges,{endIndex:L+S-1,size:$.prevSize,startIndex:$.prevIndex}]}),{prevIndex:0,prevSize:P,ranges:[]}).ranges})),n);const k=Zt(ee(i,_e(g,f),ce(([S,{offsetTree:T},E])=>{const A=-S;return yo(A,T,E)})));return he(ee(i,_e(g,f),ce(([S,T,E])=>{if(T.groupIndices.length>0){if(Qe(T.sizeTree))return T;let A=$r();const P=mt(x);let $=0,L=0,H=0;for(;$<-S;){H=P[L];const Y=P[L+1]-H-1;L++,$+=Y+1}if(A=ar(T.sizeTree).reduce((Y,{k:_,v:V})=>Qt(Y,Math.max(0,_+S),V),A),$!==-S){const Y=wo(T.sizeTree,H);A=Qt(A,0,Y);const _=pn(T.sizeTree,-S+1)[1];A=Qt(A,1,_)}return{...T,sizeTree:A,...Va(T.offsetTree,0,A,E)}}else{const A=ar(T.sizeTree).reduce((P,{k:$,v:L})=>Qt(P,Math.max(0,$+S),L),$r());return{...T,sizeTree:A,...Va(T.offsetTree,0,A,E)}}})),g),{beforeUnshiftWith:C,data:m,defaultItemSize:d,firstItemIndex:a,fixedItemSize:c,gap:f,groupIndices:l,itemSize:p,listRefresh:b,shiftWith:i,shiftWithOffset:k,sizeRanges:n,sizes:g,statefulTotalCount:o,totalCount:r,trackItemSizes:y,unshiftWith:s}},ot(zn,Ua),{singleton:!0});function uC(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const Ep=qe(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:o}])=>{const s=ze(),i=ze(),a=Zt(ee(s,ce(uC)));return he(ee(a,ce(l=>l.totalCount)),n),he(ee(a,ce(l=>l.groupIndices)),e),he(ee(xt(o,t,r),ye(([l,c])=>Ms(c)),ce(([l,c,d])=>pn(c.groupOffsetTree,Math.max(l-d,0),"v")[0]),st(),ce(l=>[l])),i),{groupCounts:s,topItemsIndexes:i}},ot(En,$t)),Un=qe(([{log:e}])=>{const t=se(!1),n=Zt(ee(t,ye(r=>r),st()));return Xe(t,r=>{r&&mt(e)("props updated",{},Ut.DEBUG)}),{didMount:n,propsReady:t}},ot(zn),{singleton:!0}),dC=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function Ip(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!dC)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const So=qe(([{gap:e,listRefresh:t,sizes:n,totalCount:r},{fixedFooterHeight:o,fixedHeaderHeight:s,footerHeight:i,headerHeight:a,scrollingInProgress:l,scrollTo:c,smoothScrollTargetReached:d,viewportHeight:p},{log:m}])=>{const f=ze(),v=ze(),g=se(0);let x=null,y=null,b=null;function C(){x&&(x(),x=null),b&&(b(),b=null),y&&(clearTimeout(y),y=null),Ee(l,!1)}return he(ee(f,_e(n,p,r,g,a,i,m),_e(e,s,o),ce(([[k,S,T,E,A,P,$,L],H,Y,_])=>{const V=Ip(k),{align:G,behavior:W,offset:D}=V,I=E-1,U=Tp(V,S,I);let Z=yo(U,S.offsetTree,H)+P;G==="end"?(Z+=Y+pn(S.sizeTree,U)[1]-T+_,U===I&&(Z+=$)):G==="center"?Z+=(Y+pn(S.sizeTree,U)[1]-T+_)/2:Z-=A,D&&(Z+=D);const R=q=>{C(),q?(L("retrying to scroll to",{location:k},Ut.DEBUG),Ee(f,k)):(Ee(v,!0),L("list did not change, scroll successful",{},Ut.DEBUG))};if(C(),W==="smooth"){let q=!1;b=Xe(t,j=>{q=q||j}),x=fn(d,()=>{R(q)})}else x=fn(ee(t,fC(150)),R);return y=setTimeout(()=>{C()},1200),Ee(l,!0),L("scrolling from index to",{behavior:W,index:U,top:Z},Ut.DEBUG),{behavior:W,top:Z}})),c),{scrollTargetReached:v,scrollToIndex:f,topListHeight:g}},ot(En,$t,zn),{singleton:!0});function fC(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return r=>{r&&(t(!0),clearTimeout(n))}}}function Ka(e,t){e==0?t():requestAnimationFrame(()=>{Ka(e-1,t)})}function qa(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const Co=qe(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:o,scrollToIndex:s},{didMount:i}])=>{const a=se(!0),l=se(0),c=se(!0);return he(ee(i,_e(l),ye(([d,p])=>!!p),Tn(!1)),a),he(ee(i,_e(l),ye(([d,p])=>!!p),Tn(!1)),c),Xe(ee(xt(t,i),_e(a,n,e,c),ye(([[,d],p,{sizeTree:m},f,v])=>d&&(!Qe(m)||Oa(f))&&!p&&!v),_e(l)),([,d])=>{fn(o,()=>{Ee(c,!0)}),Ka(4,()=>{fn(r,()=>{Ee(a,!0)}),Ee(s,d)})}),{initialItemFinalLocationReached:c,initialTopMostItemIndex:l,scrolledToInitialItem:a}},ot(En,$t,So,Un),{singleton:!0});function Np(e,t){return Math.abs(e-t)<1.01}const To="up",ko="down",pC="none",hC={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},mC=0,Eo=qe(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:o,viewportHeight:s}])=>{const i=se(!1),a=se(!0),l=ze(),c=ze(),d=se(4),p=se(mC),m=Rt(ee(La(ee(be(o),sr(1),Tn(!0)),ee(be(o),sr(1),Tn(!1),dp(100))),st()),!1),f=Rt(ee(La(ee(n,Tn(!0)),ee(n,Tn(!1),dp(200))),st()),!1);he(ee(xt(be(o),be(p)),ce(([b,C])=>b<=C),st()),a),he(ee(a,jn(50)),c);const v=Zt(ee(xt(r,be(s),be(t),be(e),be(d)),kn((b,[{scrollHeight:C,scrollTop:k},S,T,E,A])=>{const P=k+S-C>-A,$={scrollHeight:C,scrollTop:k,viewportHeight:S};if(P){let H,Y;return k>b.state.scrollTop?(H="SCROLLED_DOWN",Y=b.state.scrollTop-k):(H="SIZE_DECREASED",Y=b.state.scrollTop-k||b.scrollTopDelta),{atBottom:!0,atBottomBecause:H,scrollTopDelta:Y,state:$}}let L;return $.scrollHeight>b.state.scrollHeight?L="SIZE_INCREASED":S<b.state.viewportHeight?L="VIEWPORT_HEIGHT_DECREASING":k<b.state.scrollTop?L="SCROLLING_UPWARDS":L="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:L,state:$}},hC),st((b,C)=>b&&b.atBottom===C.atBottom))),g=Rt(ee(r,kn((b,{scrollHeight:C,scrollTop:k,viewportHeight:S})=>{if(Np(b.scrollHeight,C))return{changed:!1,jump:0,scrollHeight:C,scrollTop:k};{const T=C-(k+S)<1;return b.scrollTop!==k&&T?{changed:!0,jump:b.scrollTop-k,scrollHeight:C,scrollTop:k}:{changed:!0,jump:0,scrollHeight:C,scrollTop:k}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),ye(b=>b.changed),ce(b=>b.jump)),0);he(ee(v,ce(b=>b.atBottom)),i),he(ee(i,jn(50)),l);const x=se(ko);he(ee(r,ce(({scrollTop:b})=>b),st(),kn((b,C)=>mt(f)?{direction:b.direction,prevScrollTop:C}:{direction:C<b.prevScrollTop?To:ko,prevScrollTop:C},{direction:ko,prevScrollTop:0}),ce(b=>b.direction)),x),he(ee(r,jn(50),Tn(pC)),x);const y=se(0);return he(ee(m,ye(b=>!b),Tn(0)),y),he(ee(o,jn(100),_e(m),ye(([b,C])=>!!C),kn(([b,C],[k])=>[C,k],[0,0]),ce(([b,C])=>C-b)),y),{atBottomState:v,atBottomStateChange:l,atBottomThreshold:d,atTopStateChange:c,atTopThreshold:p,isAtBottom:i,isAtTop:a,isScrolling:m,lastJumpDueToItemResize:g,scrollDirection:x,scrollVelocity:y}},ot($t)),Os="top",Ds="bottom",Ap="none";function Pp(e,t,n){return typeof e=="number"?n===To&&t===Os||n===ko&&t===Ds?e:0:n===To?t===Os?e.main:e.reverse:t===Ds?e.main:e.reverse}function jp(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const Ga=qe(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:o}])=>{const s=ze(),i=se(0),a=se(0),l=se(0),c=Rt(ee(xt(be(r),be(o),be(n),be(s,bo),be(l),be(i),be(t),be(e),be(a)),ce(([d,p,m,[f,v],g,x,y,b,C])=>{const k=d-b,S=x+y,T=Math.max(m-k,0);let E=Ap;const A=jp(C,Os),P=jp(C,Ds);return f-=b,f+=m+y,v+=m+y,v-=b,f>d+S-A&&(E=To),v<d-T+p+P&&(E=ko),E!==Ap?[Math.max(k-m-Pp(g,Os,E)-A,0),k-T-y+p+Pp(g,Ds,E)+P]:null}),ye(d=>d!=null),st(bo)),[0,0]);return{increaseViewportBy:a,listBoundary:s,overscan:l,topListHeight:i,visibleRange:c}},ot($t),{singleton:!0});function gC(e,t,n){if(Ms(t)){const r=Cp(e,t);return[{index:pn(t.groupOffsetTree,r)[0],offset:0,size:0},{data:n==null?void 0:n[0],index:r,offset:0,size:0}]}return[{data:n==null?void 0:n[0],index:e,offset:0,size:0}]}const Ya={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Ls(e,t,n,r,o,s){const{lastIndex:i,lastOffset:a,lastSize:l}=o;let c=0,d=0;if(e.length>0){c=e[0].offset;const g=e[e.length-1];d=g.offset+g.size}const p=n-i,m=a+p*l+(p-1)*r,f=c,v=m-d;return{bottom:d,firstItemIndex:s,items:Rp(e,o,s),offsetBottom:v,offsetTop:c,top:f,topItems:Rp(t,o,s),topListHeight:t.reduce((g,x)=>x.size+g,0),totalCount:n}}function _p(e,t,n,r,o,s){let i=0;if(n.groupIndices.length>0)for(const d of n.groupIndices){if(d-i>=e)break;i++}const a=e+i,l=qa(t,a),c=Array.from({length:a}).map((d,p)=>({data:s[p+l],index:p+l,offset:0,size:0}));return Ls(c,[],a,o,n,r)}function Rp(e,t,n){if(e.length===0)return[];if(!Ms(t))return e.map(c=>({...c,index:c.index+n,originalIndex:c.index}));const r=e[0].index,o=e[e.length-1].index,s=[],i=js(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 lr=qe(([{data:e,firstItemIndex:t,gap:n,sizes:r,totalCount:o},s,{listBoundary:i,topListHeight:a,visibleRange:l},{initialTopMostItemIndex:c,scrolledToInitialItem:d},{topListHeight:p},m,{didMount:f},{recalcInProgress:v}])=>{const g=se([]),x=se(0),y=ze();he(s.topItemsIndexes,g);const b=Rt(ee(xt(f,v,be(l,bo),be(o),be(r),be(c),d,be(g),be(t),be(n),e),ye(([T,E,,A,,,,,,,P])=>{const $=P&&P.length!==A;return T&&!E&&!$}),ce(([,,[T,E],A,P,$,L,H,Y,_,V])=>{const G=P,{offsetTree:W,sizeTree:D}=G,I=mt(x);if(A===0)return{...Ya,totalCount:A};if(T===0&&E===0)return I===0?{...Ya,totalCount:A}:_p(I,$,P,Y,_,V||[]);if(Qe(D))return I>0?null:Ls(gC(qa($,A),G,V),[],A,_,G,Y);const U=[];if(H.length>0){const B=H[0],Q=H[H.length-1];let M=0;for(const O of js(D,B,Q)){const F=O.value,J=Math.max(O.start,B),oe=Math.min(O.end,Q);for(let ae=J;ae<=oe;ae++)U.push({data:V==null?void 0:V[ae],index:ae,offset:M,size:F}),M+=F}}if(!L)return Ls([],U,A,_,G,Y);const Z=H.length>0?H[H.length-1]+1:0,R=oC(W,T,E,Z);if(R.length===0)return null;const q=A-1,j=Ps([],B=>{for(const Q of R){const M=Q.value;let O=M.offset,F=Q.start;const J=M.size;if(M.offset<T){F+=Math.floor((T-M.offset+_)/(J+_));const ae=F-Q.start;O+=ae*J+ae*_}F<Z&&(O+=(Z-F)*J,F=Z);const oe=Math.min(Q.end,q);for(let ae=F;ae<=oe&&!(O>=E);ae++)B.push({data:V==null?void 0:V[ae],index:ae,offset:O,size:J}),O+=J+_}});return Ls(j,U,A,_,G,Y)}),ye(T=>T!==null),st()),Ya);he(ee(e,ye(Oa),ce(T=>T==null?void 0:T.length)),o),he(ee(b,ce(T=>T.topListHeight)),p),he(p,a),he(ee(b,ce(T=>[T.top,T.bottom])),i),he(ee(b,ce(T=>T.items)),y);const C=Zt(ee(b,ye(({items:T})=>T.length>0),_e(o,e),ye(([{items:T},E])=>T[T.length-1].originalIndex===E-1),ce(([,T,E])=>[T-1,E]),st(bo),ce(([T])=>T))),k=Zt(ee(b,jn(200),ye(({items:T,topItems:E})=>T.length>0&&T[0].originalIndex===E.length),ce(({items:T})=>T[0].index),st())),S=Zt(ee(b,ye(({items:T})=>T.length>0),ce(({items:T})=>{let E=0,A=T.length-1;for(;T[E].type==="group"&&E<A;)E++;for(;T[A].type==="group"&&A>E;)A--;return{endIndex:T[A].index,startIndex:T[E].index}}),st(yp)));return{endReached:C,initialItemCount:x,itemsRendered:y,listState:b,rangeChanged:S,startReached:k,topItemsIndexes:g,...m}},ot(En,Ep,Ga,Co,So,Eo,Un,Ua),{singleton:!0}),Mp=qe(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:o}])=>{const s=ze(),i=Rt(ee(xt(n,e,r,t,o),ce(([a,l,c,d,p])=>a+l+c+d+p.offsetBottom+p.bottom)),0);return he(be(i),s),{totalListHeight:i,totalListHeightChanged:s}},ot($t,lr),{singleton:!0}),xC=qe(([{viewportHeight:e},{totalListHeight:t}])=>{const n=se(!1),r=Rt(ee(xt(n,e,t),ye(([o])=>o),ce(([,o,s])=>Math.max(0,o-s)),jn(0),st()),0);return{alignToBottom:n,paddingTopAddition:r}},ot($t,Mp),{singleton:!0}),Op=qe(()=>({context:se(null)})),vC=({itemBottom:e,itemTop:t,locationParams:{align:n,behavior:r,...o},viewportBottom:s,viewportTop:i})=>t<i?{...o,align:n??"start",behavior:r}:e>s?{...o,align:n??"end",behavior:r}:null,Dp=qe(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:o,headerHeight:s,scrollingInProgress:i,scrollTop:a,viewportHeight:l},{scrollToIndex:c}])=>{const d=ze();return he(ee(d,_e(t,l,n,s,o,r,a),_e(e),ce(([[p,m,f,v,g,x,y,b],C])=>{const{align:k,behavior:S,calculateViewLocation:T=vC,done:E,...A}=p,P=Tp(p,m,v-1),$=yo(P,m.offsetTree,C)+g+x,L=$+pn(m.sizeTree,P)[1],H=b+x,Y=b+f-y,_=T({itemBottom:L,itemTop:$,locationParams:{align:k,behavior:S,...A},viewportBottom:Y,viewportTop:H});return _?E&&fn(ee(i,ye(V=>!V),sr(mt(i)?1:2)),E):E&&E(),_}),ye(p=>p!==null)),c),{scrollIntoView:d}},ot(En,$t,So,lr,zn),{singleton:!0});function Lp(e){return e?e==="smooth"?"smooth":"auto":!1}const wC=(e,t)=>typeof e=="function"?Lp(e(t)):t&&Lp(e),bC=qe(([{listRefresh:e,totalCount:t,fixedItemSize:n,data:r},{atBottomState:o,isAtBottom:s},{scrollToIndex:i},{scrolledToInitialItem:a},{didMount:l,propsReady:c},{log:d},{scrollingInProgress:p},{context:m},{scrollIntoView:f}])=>{const v=se(!1),g=ze();let x=null;function y(S){Ee(i,{align:"end",behavior:S,index:"LAST"})}Xe(ee(xt(ee(be(t),sr(1)),l),_e(be(v),s,a,p),ce(([[S,T],E,A,P,$])=>{let L=T&&P,H="auto";return L&&(H=wC(E,A||$),L=L&&!!H),{followOutputBehavior:H,shouldFollow:L,totalCount:S}}),ye(({shouldFollow:S})=>S)),({followOutputBehavior:S,totalCount:T})=>{x&&(x(),x=null),mt(n)?requestAnimationFrame(()=>{mt(d)("following output to ",{totalCount:T},Ut.DEBUG),y(S)}):x=fn(e,()=>{mt(d)("following output to ",{totalCount:T},Ut.DEBUG),y(S),x=null})});function b(S){const T=fn(o,E=>{S&&!E.atBottom&&E.notAtBottomBecause==="SIZE_INCREASED"&&!x&&(mt(d)("scrolling to bottom due to increased size",{},Ut.DEBUG),y("auto"))});setTimeout(T,100)}Xe(ee(xt(be(v),t,c),ye(([S,,T])=>S&&T),kn(({value:S},[,T])=>({refreshed:S===T,value:T}),{refreshed:!1,value:0}),ye(({refreshed:S})=>S),_e(v,t)),([,S])=>{mt(a)&&b(S!==!1)}),Xe(g,()=>{b(mt(v)!==!1)}),Xe(xt(be(v),o),([S,T])=>{S&&!T.atBottom&&T.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&y("auto")});const C=se(null),k=ze();return he(La(ee(be(r),ce(S=>{var T;return(T=S==null?void 0:S.length)!=null?T:0})),ee(be(t))),k),Xe(ee(xt(ee(k,sr(1)),l),_e(be(C),a,p,m),ce(([[S,T],E,A,P,$])=>T&&A&&(E==null?void 0:E({context:$,totalCount:S,scrollingInProgress:P}))),ye(S=>!!S),jn(0)),S=>{x&&(x(),x=null),mt(n)?requestAnimationFrame(()=>{mt(d)("scrolling into view",{}),Ee(f,S)}):x=fn(e,()=>{mt(d)("scrolling into view",{}),Ee(f,S),x=null})}),{autoscrollToBottom:g,followOutput:v,scrollIntoViewOnChange:C}},ot(En,Eo,So,Co,Un,zn,$t,Op,Dp)),yC=qe(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:o},{initialItemCount:s,listState:i},{didMount:a}])=>(he(ee(a,_e(s),ye(([,l])=>l!==0),_e(o,r,t,n,e),ce(([[,l],c,d,p,m,f=[]])=>_p(l,c,d,p,m,f))),i),{}),ot(En,Co,lr,Un),{singleton:!0}),SC=qe(([{didMount:e},{scrollTo:t},{listState:n}])=>{const r=se(0);return Xe(ee(e,_e(r),ye(([,o])=>o!==0),ce(([,o])=>({top:o}))),o=>{fn(ee(n,sr(1),ye(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{Ee(t,o)})})}),{initialScrollTop:r}},ot(Un,$t,lr),{singleton:!0}),$p=qe(([{scrollVelocity:e}])=>{const t=se(!1),n=ze(),r=se(!1);return he(ee(e,_e(r,t,n),ye(([o,s])=>!!s),ce(([o,s,i,a])=>{const{enter:l,exit:c}=s;if(i){if(c(o,a))return!1}else if(l(o,a))return!0;return i}),st()),t),Xe(ee(xt(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}},ot(Eo),{singleton:!0}),Xa=qe(([{scrollContainerState:e,scrollTo:t}])=>{const n=ze(),r=ze(),o=ze(),s=se(!1),i=se(void 0);return he(ee(xt(n,r),ce(([{scrollHeight:a,scrollTop:l,viewportHeight:c},{offsetTop:d}])=>({scrollHeight:a,scrollTop:Math.max(0,l-d),viewportHeight:c}))),e),he(ee(t,_e(r),ce(([a,{offsetTop:l}])=>({...a,top:a.top+l}))),o),{customScrollParent:i,useWindowScroll:s,windowScrollContainerState:n,windowScrollTo:o,windowViewportRect:r}},ot($t)),CC=qe(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:o},{didMount:s},{useWindowScroll:i,windowScrollContainerState:a,windowViewportRect:l}])=>{const c=ze(),d=se(void 0),p=se(null),m=se(null);return he(a,p),he(l,m),Xe(ee(c,_e(t,r,i,p,m,n)),([f,v,g,x,y,b,C])=>{const k=iC(v.sizeTree);x&&y!==null&&b!==null&&(g=y.scrollTop-b.offsetTop),g-=C,f({ranges:k,scrollTop:g})}),he(ee(d,ye(Oa),ce(TC)),o),he(ee(s,_e(d),ye(([,f])=>f!==void 0),st(),ce(([,f])=>f.ranges)),e),{getState:c,restoreStateFrom:d}},ot(En,$t,Co,Un,Xa));function TC(e){return{align:"start",index:0,offset:e.scrollTop}}const kC=qe(([{topItemsIndexes:e}])=>{const t=se(0);return he(ee(t,ye(n=>n>=0),ce(n=>Array.from({length:n}).map((r,o)=>o))),e),{topItemCount:t}},ot(lr));function Fp(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const EC=Fp(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),IC=qe(([{deviation:e,scrollBy:t,scrollingInProgress:n,scrollTop:r},{isAtBottom:o,isScrolling:s,lastJumpDueToItemResize:i,scrollDirection:a},{listState:l},{beforeUnshiftWith:c,gap:d,shiftWithOffset:p,sizes:m},{log:f},{recalcInProgress:v}])=>{const g=Zt(ee(l,_e(i),kn(([,y,b,C],[{bottom:k,items:S,offsetBottom:T,totalCount:E},A])=>{const P=k+T;let $=0;return b===E&&y.length>0&&S.length>0&&(S[0].originalIndex===0&&y[0].originalIndex===0||($=P-C,$!==0&&($+=A))),[$,S,E,P]},[0,[],0,0]),ye(([y])=>y!==0),_e(r,a,n,o,f,v),ye(([,y,b,C,,,k])=>!k&&!C&&y!==0&&b===To),ce(([[y],,,,,b])=>(b("Upward scrolling compensation",{amount:y},Ut.DEBUG),y))));function x(y){y>0?(Ee(t,{behavior:"auto",top:-y}),Ee(e,0)):(Ee(e,0),Ee(t,{behavior:"auto",top:-y}))}return Xe(ee(g,_e(e,s)),([y,b,C])=>{C&&EC()?Ee(e,b-y):x(-y)}),Xe(ee(xt(Rt(s,!1),e,v),ye(([y,b,C])=>!y&&!C&&b!==0),ce(([y,b])=>b),jn(1)),x),he(ee(p,ce(y=>({top:-y}))),t),Xe(ee(c,_e(m,d),ce(([y,{groupIndices:b,lastSize:C,sizeTree:k},S])=>{function T(E){return E*(C+S)}if(b.length===0)return T(y);{let E=0;const A=wo(k,0);let P=0,$=0;for(;P<y;){P++,E+=A;let L=b.length===$+1?1/0:b[$+1]-b[$]-1;P+L>y&&(E-=A,L=y-P+1),P+=L,E+=T(L),$++}return E}})),y=>{Ee(e,y),requestAnimationFrame(()=>{Ee(t,{top:y}),requestAnimationFrame(()=>{Ee(e,0),Ee(v,!1)})})}),{deviation:e}},ot($t,Eo,lr,En,zn,Ua)),NC=qe(([e,t,n,r,o,s,i,a,l,c,d])=>({...e,...t,...n,...r,...o,...s,...i,...a,...l,...c,...d}),ot(Ga,yC,Un,$p,Mp,SC,xC,Xa,Dp,zn,Op)),Bp=qe(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:r,gap:o,groupIndices:s,itemSize:i,sizeRanges:a,sizes:l,statefulTotalCount:c,totalCount:d,trackItemSizes:p},{initialItemFinalLocationReached:m,initialTopMostItemIndex:f,scrolledToInitialItem:v},g,x,y,{listState:b,topItemsIndexes:C,...k},{scrollToIndex:S},T,{topItemCount:E},{groupCounts:A},P])=>(he(k.rangeChanged,P.scrollSeekRangeChanged),he(ee(P.windowViewportRect,ce($=>$.visibleHeight)),g.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,gap:o,groupCounts:A,initialItemFinalLocationReached:m,initialTopMostItemIndex:f,scrolledToInitialItem:v,sizeRanges:a,topItemCount:E,topItemsIndexes:C,totalCount:d,...y,groupIndices:s,itemSize:i,listState:b,scrollToIndex:S,statefulTotalCount:c,trackItemSizes:p,...k,...P,...g,sizes:l,...x}),ot(En,Co,$t,CC,bC,lr,So,IC,kC,Ep,NC));function AC(e,t){const n={},r={};let o=0;const s=e.length;for(;o<s;)r[e[o]]=1,o+=1;for(const i in t)Object.hasOwn(r,i)||(n[i]=t[i]);return n}const $s=typeof document<"u"?w.useLayoutEffect:w.useEffect;function zp(e,t,n){const r=Object.keys(t.required||{}),o=Object.keys(t.optional||{}),s=Object.keys(t.methods||{}),i=Object.keys(t.events||{}),a=w.createContext({});function l(x,y){x.propsReady&&Ee(x.propsReady,!1);for(const b of r){const C=x[t.required[b]];Ee(C,y[b])}for(const b of o)if(b in y){const C=x[t.optional[b]];Ee(C,y[b])}x.propsReady&&Ee(x.propsReady,!0)}function c(x){return s.reduce((y,b)=>(y[b]=C=>{const k=x[t.methods[b]];Ee(k,C)},y),{})}function d(x){return i.reduce((y,b)=>(y[b]=VS(x[t.events[b]]),y),{})}const p=w.forwardRef((x,y)=>{const{children:b,...C}=x,[k]=w.useState(()=>Ps(qS(e),E=>{l(E,C)})),[S]=w.useState(up(d,k));$s(()=>{for(const E of i)E in C&&Xe(S[E],C[E]);return()=>{Object.values(S).map(Da)}},[C,S,k]),$s(()=>{l(k,C)}),w.useImperativeHandle(y,lp(c(k)));const T=n;return u.jsx(a.Provider,{value:k,children:n?u.jsx(T,{...AC([...r,...o,...i],C),children:b}):b})}),m=x=>{const y=w.useContext(a);return w.useCallback(b=>{Ee(y[x],b)},[y,x])},f=x=>{const y=w.useContext(a)[x],b=w.useCallback(C=>Xe(y,C),[y]);return w.useSyncExternalStore(b,()=>mt(y),()=>mt(y))},v=x=>{const y=w.useContext(a)[x],[b,C]=w.useState(up(mt,y));return $s(()=>Xe(y,k=>{k!==b&&C(lp(k))}),[y,b]),b},g=w.version.startsWith("18")?f:v;return{Component:p,useEmitter:(x,y)=>{const b=w.useContext(a)[x];$s(()=>Xe(b,y),[y,b])},useEmitterValue:g,usePublisher:m}}const Hp=w.createContext(void 0),Up=w.createContext(void 0),Wp=typeof document<"u"?w.useLayoutEffect:w.useEffect;function Ja(e){return"self"in e}function PC(e){return"body"in e}function Vp(e,t,n,r=Lr,o,s){const i=w.useRef(null),a=w.useRef(null),l=w.useRef(null),c=w.useCallback(m=>{let f,v,g;const x=m.target;if(PC(x)||Ja(x)){const b=Ja(x)?x:x.defaultView;g=s?b.scrollX:b.scrollY,f=s?b.document.documentElement.scrollWidth:b.document.documentElement.scrollHeight,v=s?b.innerWidth:b.innerHeight}else g=s?x.scrollLeft:x.scrollTop,f=s?x.scrollWidth:x.scrollHeight,v=s?x.offsetWidth:x.offsetHeight;const y=()=>{e({scrollHeight:f,scrollTop:Math.max(g,0),viewportHeight:v})};m.suppressFlushSync?y():Lo.flushSync(y),a.current!==null&&(g===a.current||g<=0||g===f-v)&&(a.current=null,t(!0),l.current&&(clearTimeout(l.current),l.current=null))},[e,t,s]);w.useEffect(()=>{const m=o||i.current;return r(o||i.current),c({suppressFlushSync:!0,target:m}),m.addEventListener("scroll",c,{passive:!0}),()=>{r(null),m.removeEventListener("scroll",c)}},[i,c,n,r,o]);function d(m){const f=i.current;if(!f||(s?"offsetWidth"in f&&f.offsetWidth===0:"offsetHeight"in f&&f.offsetHeight===0))return;const v=m.behavior==="smooth";let g,x,y;Ja(f)?(x=Math.max(Hn(f.document.documentElement,s?"width":"height"),s?f.document.documentElement.scrollWidth:f.document.documentElement.scrollHeight),g=s?f.innerWidth:f.innerHeight,y=s?window.scrollX:window.scrollY):(x=f[s?"scrollWidth":"scrollHeight"],g=Hn(f,s?"width":"height"),y=f[s?"scrollLeft":"scrollTop"]);const b=x-g;if(m.top=Math.ceil(Math.max(Math.min(b,m.top),0)),Np(g,x)||m.top===y){e({scrollHeight:x,scrollTop:y,viewportHeight:g}),v&&t(!0);return}v?(a.current=m.top,l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{l.current=null,a.current=null,t(!0)},1e3)):a.current=null,s&&(m={behavior:m.behavior,left:m.top}),f.scrollTo(m)}function p(m){s&&(m={behavior:m.behavior,left:m.top}),i.current.scrollBy(m)}return{scrollByCallback:p,scrollerRef:i,scrollToCallback:d}}const Za="-webkit-sticky",Kp="sticky",Qa=Fp(()=>{if(typeof document>"u")return Kp;const e=document.createElement("div");return e.style.position=Za,e.style.position===Za?Za:Kp});function el(e){return e}const jC=qe(()=>{const e=se(a=>`Item ${a}`),t=se(a=>`Group ${a}`),n=se({}),r=se(el),o=se("div"),s=se(Lr),i=(a,l=null)=>Rt(ee(n,ce(c=>c[a]),st()),l);return{components:n,computeItemKey:r,EmptyPlaceholder:i("EmptyPlaceholder"),FooterComponent:i("Footer"),GroupComponent:i("Group","div"),groupContent:t,HeaderComponent:i("Header"),HeaderFooterTag:o,ItemComponent:i("Item","div"),itemContent:e,ListComponent:i("List","div"),ScrollerComponent:i("Scroller","div"),scrollerRef:s,ScrollSeekPlaceholder:i("ScrollSeekPlaceholder"),TopItemListComponent:i("TopItemList")}}),_C=qe(([e,t])=>({...e,...t}),ot(Bp,jC)),RC=({height:e})=>u.jsx("div",{style:{height:e}}),MC={overflowAnchor:"none",position:Qa(),zIndex:1},qp={overflowAnchor:"none"},OC={...qp,display:"inline-block",height:"100%"},Gp=w.memo(function({showTopList:e=!1}){const t=Ce("listState"),n=nn("sizeRanges"),r=Ce("useWindowScroll"),o=Ce("customScrollParent"),s=nn("windowScrollContainerState"),i=nn("scrollContainerState"),a=o||r?s:i,l=Ce("itemContent"),c=Ce("context"),d=Ce("groupContent"),p=Ce("trackItemSizes"),m=Ce("itemSize"),f=Ce("log"),v=nn("gap"),g=Ce("horizontalDirection"),{callbackRef:x}=XS(n,m,p,e?Lr:a,f,v,o,g,Ce("skipAnimationFrameInResizeObserver")),[y,b]=w.useState(0);tl("deviation",_=>{y!==_&&b(_)});const C=Ce("EmptyPlaceholder"),k=Ce("ScrollSeekPlaceholder")||RC,S=Ce("ListComponent"),T=Ce("ItemComponent"),E=Ce("GroupComponent"),A=Ce("computeItemKey"),P=Ce("isSeeking"),$=Ce("groupIndices").length>0,L=Ce("alignToBottom"),H=Ce("initialItemFinalLocationReached"),Y=e?{}:{boxSizing:"border-box",...g?{display:"inline-block",height:"100%",marginLeft:y!==0?y:L?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:y!==0?y:L?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...H?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&C?u.jsx(C,{...Mt(C,c)}):u.jsx(S,{...Mt(S,c),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:x,style:Y,children:(e?t.topItems:t.items).map(_=>{const V=_.originalIndex,G=A(V+t.firstItemIndex,_.data,c);return P?w.createElement(k,{...Mt(k,c),height:_.size,index:_.index,key:G,type:_.type||"item",..._.type==="group"?{}:{groupIndex:_.groupIndex}}):_.type==="group"?w.createElement(E,{...Mt(E,c),"data-index":V,"data-item-index":_.index,"data-known-size":_.size,key:G,style:MC},d(_.index,c)):w.createElement(T,{...Mt(T,c),...FC(T,_.data),"data-index":V,"data-item-group-index":_.groupIndex,"data-item-index":_.index,"data-known-size":_.size,key:G,style:g?OC:qp},$?l(_.index,_.groupIndex,_.data,c):l(_.index,_.data,c))})})}),DC={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},LC={outline:"none",overflowX:"auto",position:"relative"},Fs=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),$C={position:Qa(),top:0,width:"100%",zIndex:1};function Mt(e,t){if(typeof e!="string")return{context:t}}function FC(e,t){return{item:typeof e=="string"?void 0:t}}const BC=w.memo(function(){const e=Ce("HeaderComponent"),t=nn("headerHeight"),n=Ce("HeaderFooterTag"),r=ir(w.useMemo(()=>s=>{t(Hn(s,"height"))},[t]),!0,Ce("skipAnimationFrameInResizeObserver")),o=Ce("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Mt(e,o)})}):null}),zC=w.memo(function(){const e=Ce("FooterComponent"),t=nn("footerHeight"),n=Ce("HeaderFooterTag"),r=ir(w.useMemo(()=>s=>{t(Hn(s,"height"))},[t]),!0,Ce("skipAnimationFrameInResizeObserver")),o=Ce("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Mt(e,o)})}):null});function Yp({useEmitter:e,useEmitterValue:t,usePublisher:n}){return w.memo(function({children:r,style:o,context:s,...i}){const a=n("scrollContainerState"),l=t("ScrollerComponent"),c=n("smoothScrollTargetReached"),d=t("scrollerRef"),p=t("horizontalDirection")||!1,{scrollByCallback:m,scrollerRef:f,scrollToCallback:v}=Vp(a,c,l,d,void 0,p);return e("scrollTo",v),e("scrollBy",m),u.jsx(l,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:f,style:{...p?LC:DC,...o},tabIndex:0,...i,...Mt(l,s),children:r})})}function Xp({useEmitter:e,useEmitterValue:t,usePublisher:n}){return w.memo(function({children:r,style:o,context:s,...i}){const a=n("windowScrollContainerState"),l=t("ScrollerComponent"),c=n("smoothScrollTargetReached"),d=t("totalListHeight"),p=t("deviation"),m=t("customScrollParent"),f=w.useRef(null),v=t("scrollerRef"),{scrollByCallback:g,scrollerRef:x,scrollToCallback:y}=Vp(a,c,l,v,m);return Wp(()=>{var b;return x.current=m||((b=f.current)==null?void 0:b.ownerDocument.defaultView),()=>{x.current=null}},[x,m]),e("windowScrollTo",y),e("scrollBy",g),u.jsx(l,{ref:f,"data-virtuoso-scroller":!0,style:{position:"relative",...o,...d!==0?{height:d+p}:{}},...i,...Mt(l,s),children:r})})}const HC=({children:e})=>{const t=w.useContext(Hp),n=nn("viewportHeight"),r=nn("fixedItemHeight"),o=Ce("alignToBottom"),s=Ce("horizontalDirection"),i=w.useMemo(()=>cp(n,l=>Hn(l,s?"width":"height")),[n,s]),a=ir(i,!0,Ce("skipAnimationFrameInResizeObserver"));return w.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),u.jsx("div",{"data-viewport-type":"element",ref:a,style:Fs(o),children:e})},UC=({children:e})=>{const t=w.useContext(Hp),n=nn("windowViewportRect"),r=nn("fixedItemHeight"),o=Ce("customScrollParent"),s=hp(n,o,Ce("skipAnimationFrameInResizeObserver")),i=Ce("alignToBottom");return w.useEffect(()=>{t&&(r(t.itemHeight),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),u.jsx("div",{"data-viewport-type":"window",ref:s,style:Fs(i),children:e})},WC=({children:e})=>{const t=Ce("TopItemListComponent")||"div",n=Ce("headerHeight"),r={...$C,marginTop:`${n}px`},o=Ce("context");return u.jsx(t,{style:r,...Mt(t,o),children:e})},VC=w.memo(function(e){const t=Ce("useWindowScroll"),n=Ce("topItemsIndexes").length>0,r=Ce("customScrollParent"),o=Ce("context");return u.jsxs(r||t?GC:qC,{...e,context:o,children:[n&&u.jsx(WC,{children:u.jsx(Gp,{showTopList:!0})}),u.jsxs(r||t?UC:HC,{children:[u.jsx(BC,{}),u.jsx(Gp,{}),u.jsx(zC,{})]})]})}),{Component:KC,useEmitter:tl,useEmitterValue:Ce,usePublisher:nn}=zp(_C,{required:{},optional:{restoreStateFrom:"restoreStateFrom",context:"context",followOutput:"followOutput",scrollIntoViewOnChange:"scrollIntoViewOnChange",itemContent:"itemContent",groupContent:"groupContent",overscan:"overscan",increaseViewportBy:"increaseViewportBy",totalCount:"totalCount",groupCounts:"groupCounts",topItemCount:"topItemCount",firstItemIndex:"firstItemIndex",initialTopMostItemIndex:"initialTopMostItemIndex",components:"components",atBottomThreshold:"atBottomThreshold",atTopThreshold:"atTopThreshold",computeItemKey:"computeItemKey",defaultItemHeight:"defaultItemHeight",fixedItemHeight:"fixedItemHeight",itemSize:"itemSize",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"HeaderFooterTag",data:"data",initialItemCount:"initialItemCount",initialScrollTop:"initialScrollTop",alignToBottom:"alignToBottom",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",horizontalDirection:"horizontalDirection",skipAnimationFrameInResizeObserver:"skipAnimationFrameInResizeObserver"},methods:{scrollToIndex:"scrollToIndex",scrollIntoView:"scrollIntoView",scrollTo:"scrollTo",scrollBy:"scrollBy",autoscrollToBottom:"autoscrollToBottom",getState:"getState"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",totalListHeightChanged:"totalListHeightChanged",itemsRendered:"itemsRendered",groupIndices:"groupIndices"}},VC),qC=Yp({useEmitter:tl,useEmitterValue:Ce,usePublisher:nn}),GC=Xp({useEmitter:tl,useEmitterValue:Ce,usePublisher:nn}),YC=KC;ot(Bp,qe(()=>{const e=se(c=>u.jsxs("td",{children:["Item $",c]})),t=se(null),n=se(c=>u.jsxs("td",{colSpan:1e3,children:["Group ",c]})),r=se(null),o=se(null),s=se({}),i=se(el),a=se(Lr),l=(c,d=null)=>Rt(ee(s,ce(p=>p[c]),st()),d);return{components:s,computeItemKey:i,context:t,EmptyPlaceholder:l("EmptyPlaceholder"),FillerRow:l("FillerRow"),fixedFooterContent:o,fixedHeaderContent:r,itemContent:e,groupContent:n,ScrollerComponent:l("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder"),TableBodyComponent:l("TableBody","tbody"),TableComponent:l("Table","table"),TableFooterComponent:l("TableFoot","tfoot"),TableHeadComponent:l("TableHead","thead"),TableRowComponent:l("TableRow","tr"),GroupComponent:l("Group","tr")}})),Qa();const Jp={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},XC={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:Zp,floor:Bs,max:Io,min:nl,round:Qp}=Math;function eh(e,t,n){return Array.from({length:t-e+1}).map((r,o)=>({data:n===null?null:n[o+e],index:o+e}))}function JC(e){return{...XC,items:e}}function zs(e,t){return e&&e.width===t.width&&e.height===t.height}function ZC(e,t){return e&&e.column===t.column&&e.row===t.row}const QC=qe(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:r},{footerHeight:o,headerHeight:s,scrollBy:i,scrollContainerState:a,scrollTo:l,scrollTop:c,smoothScrollTargetReached:d,viewportHeight:p},m,f,{didMount:v,propsReady:g},{customScrollParent:x,useWindowScroll:y,windowScrollContainerState:b,windowScrollTo:C,windowViewportRect:k},S])=>{const T=se(0),E=se(0),A=se(Jp),P=se({height:0,width:0}),$=se({height:0,width:0}),L=ze(),H=ze(),Y=se(0),_=se(null),V=se({column:0,row:0}),G=ze(),W=ze(),D=se(!1),I=se(0),U=se(!0),Z=se(!1),R=se(!1);Xe(ee(v,_e(I),ye(([O,F])=>!!F)),()=>{Ee(U,!1)}),Xe(ee(xt(v,U,$,P,I,Z),ye(([O,F,J,oe,,ae])=>O&&!F&&J.height!==0&&oe.height!==0&&!ae)),([,,,,O])=>{Ee(Z,!0),Ka(1,()=>{Ee(L,O)}),fn(ee(c),()=>{Ee(t,[0,0]),Ee(U,!0)})}),he(ee(W,ye(O=>O!=null&&O.scrollTop>0),Tn(0)),E),Xe(ee(v,_e(W),ye(([,O])=>O!=null)),([,O])=>{O&&(Ee(P,O.viewport),Ee($,O.item),Ee(V,O.gap),O.scrollTop>0&&(Ee(D,!0),fn(ee(c,sr(1)),F=>{Ee(D,!1)}),Ee(l,{top:O.scrollTop})))}),he(ee(P,ce(({height:O})=>O)),p),he(ee(xt(be(P,zs),be($,zs),be(V,(O,F)=>O&&O.column===F.column&&O.row===F.row),be(c)),ce(([O,F,J,oe])=>({gap:J,item:F,scrollTop:oe,viewport:O}))),G),he(ee(xt(be(T),r,be(V,ZC),be($,zs),be(P,zs),be(_),be(E),be(D),be(U),be(I)),ye(([,,,,,,,O])=>!O),ce(([O,[F,J],oe,ae,Se,we,Re,,$e,Fe])=>{const{column:Ge,row:Je}=oe,{height:vt,width:ct}=ae,{width:tt}=Se;if(Re===0&&(O===0||tt===0))return Jp;if(ct===0){const At=qa(Fe,O),St=At+Math.max(Re-1,0);return JC(eh(At,St,we))}const Oe=th(tt,ct,Ge);let Ve,He;$e?F===0&&J===0&&Re>0?(Ve=0,He=Re-1):(Ve=Oe*Bs((F+Je)/(vt+Je)),He=Oe*Zp((J+Je)/(vt+Je))-1,He=nl(O-1,Io(He,Oe-1)),Ve=nl(He,Io(0,Ve))):(Ve=0,He=-1);const Te=eh(Ve,He,we),{bottom:Ae,top:ut}=nh(Se,oe,ae,Te),dt=Zp(O/Oe),it=dt*vt+(dt-1)*Je-Ae;return{bottom:Ae,itemHeight:vt,items:Te,itemWidth:ct,offsetBottom:it,offsetTop:ut,top:ut}})),A),he(ee(_,ye(O=>O!==null),ce(O=>O.length)),T),he(ee(xt(P,$,A,V),ye(([O,F,{items:J}])=>J.length>0&&F.height!==0&&O.height!==0),ce(([O,F,{items:J},oe])=>{const{bottom:ae,top:Se}=nh(O,oe,F,J);return[Se,ae]}),st(bo)),t);const q=se(!1);he(ee(c,_e(q),ce(([O,F])=>F||O!==0)),q);const j=Zt(ee(xt(A,T),ye(([{items:O}])=>O.length>0),_e(q),ye(([[O,F],J])=>{const oe=O.items[O.items.length-1].index===F-1;return(J||O.bottom>0&&O.itemHeight>0&&O.offsetBottom===0&&O.items.length===F)&&oe}),ce(([[,O]])=>O-1),st())),B=Zt(ee(be(A),ye(({items:O})=>O.length>0&&O[0].index===0),Tn(0),st())),Q=Zt(ee(be(A),_e(D),ye(([{items:O},F])=>O.length>0&&!F),ce(([{items:O}])=>({endIndex:O[O.length-1].index,startIndex:O[0].index})),st(yp),jn(0)));he(Q,f.scrollSeekRangeChanged),he(ee(L,_e(P,$,T,V),ce(([O,F,J,oe,ae])=>{const Se=Ip(O),{align:we,behavior:Re,offset:$e}=Se;let Fe=Se.index;Fe==="LAST"&&(Fe=oe-1),Fe=Io(0,Fe,nl(oe-1,Fe));let Ge=rl(F,ae,J,Fe);return we==="end"?Ge=Qp(Ge-F.height+J.height):we==="center"&&(Ge=Qp(Ge-F.height/2+J.height/2)),$e&&(Ge+=$e),{behavior:Re,top:Ge}})),l);const M=Rt(ee(A,ce(O=>O.offsetBottom+O.bottom)),0);return he(ee(k,ce(O=>({height:O.visibleHeight,width:O.visibleWidth}))),P),{customScrollParent:x,data:_,deviation:Y,footerHeight:o,gap:V,headerHeight:s,increaseViewportBy:e,initialItemCount:E,itemDimensions:$,overscan:n,restoreStateFrom:W,scrollBy:i,scrollContainerState:a,scrollHeight:H,scrollTo:l,scrollToIndex:L,scrollTop:c,smoothScrollTargetReached:d,totalCount:T,useWindowScroll:y,viewportDimensions:P,windowScrollContainerState:b,windowScrollTo:C,windowViewportRect:k,...f,gridState:A,horizontalDirection:R,initialTopMostItemIndex:I,totalListHeight:M,...m,endReached:j,propsReady:g,rangeChanged:Q,startReached:B,stateChanged:G,stateRestoreInProgress:D,...S}},ot(Ga,$t,Eo,$p,Un,Xa,zn));function th(e,t,n){return Io(1,Bs((e+n)/(Bs(t)+n)))}function nh(e,t,n,r){const{height:o}=n;if(o===void 0||r.length===0)return{bottom:0,top:0};const s=rl(e,t,n,r[0].index);return{bottom:rl(e,t,n,r[r.length-1].index)+o,top:s}}function rl(e,t,n,r){const o=th(e.width,n.width,t.column),s=Bs(r/o),i=s*n.height+Io(0,s-1)*t.row;return i>0?i+t.row:i}const eT=qe(()=>{const e=se(p=>`Item ${p}`),t=se({}),n=se(null),r=se("virtuoso-grid-item"),o=se("virtuoso-grid-list"),s=se(el),i=se("div"),a=se(Lr),l=(p,m=null)=>Rt(ee(t,ce(f=>f[p]),st()),m),c=se(!1),d=se(!1);return he(be(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")}}),tT=qe(([e,t])=>({...e,...t}),ot(QC,eT)),nT=w.memo(function(){const e=lt("gridState"),t=lt("listClassName"),n=lt("itemClassName"),r=lt("itemContent"),o=lt("computeItemKey"),s=lt("isSeeking"),i=rn("scrollHeight"),a=lt("ItemComponent"),l=lt("ListComponent"),c=lt("ScrollSeekPlaceholder"),d=lt("context"),p=rn("itemDimensions"),m=rn("gap"),f=lt("log"),v=lt("stateRestoreInProgress"),g=rn("reportReadyState"),x=ir(w.useMemo(()=>y=>{const b=y.parentElement.parentElement.scrollHeight;i(b);const C=y.firstChild;if(C){const{height:k,width:S}=C.getBoundingClientRect();p({height:k,width:S})}m({column:oh("column-gap",getComputedStyle(y).columnGap,f),row:oh("row-gap",getComputedStyle(y).rowGap,f)})},[i,p,m,f]),!0,!1);return Wp(()=>{e.itemHeight>0&&e.itemWidth>0&&g(!0)},[e]),v?null:u.jsx(l,{className:t,ref:x,...Mt(l,d),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(y=>{const b=o(y.index,y.data,d);return s?u.jsx(c,{...Mt(c,d),height:e.itemHeight,index:y.index,width:e.itemWidth},b):w.createElement(a,{...Mt(a,d),className:n,"data-index":y.index,key:b},r(y.index,y.data,d))})})}),rT=w.memo(function(){const e=lt("HeaderComponent"),t=rn("headerHeight"),n=lt("headerFooterTag"),r=ir(w.useMemo(()=>s=>{t(Hn(s,"height"))},[t]),!0,!1),o=lt("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Mt(e,o)})}):null}),oT=w.memo(function(){const e=lt("FooterComponent"),t=rn("footerHeight"),n=lt("headerFooterTag"),r=ir(w.useMemo(()=>s=>{t(Hn(s,"height"))},[t]),!0,!1),o=lt("context");return e?u.jsx(n,{ref:r,children:u.jsx(e,{...Mt(e,o)})}):null}),sT=({children:e})=>{const t=w.useContext(Up),n=rn("itemDimensions"),r=rn("viewportDimensions"),o=ir(w.useMemo(()=>s=>{r(s.getBoundingClientRect())},[r]),!0,!1);return w.useEffect(()=>{t&&(r({height:t.viewportHeight,width:t.viewportWidth}),n({height:t.itemHeight,width:t.itemWidth}))},[t,r,n]),u.jsx("div",{ref:o,style:Fs(!1),children:e})},iT=({children:e})=>{const t=w.useContext(Up),n=rn("windowViewportRect"),r=rn("itemDimensions"),o=lt("customScrollParent"),s=hp(n,o,!1);return w.useEffect(()=>{t&&(r({height:t.itemHeight,width:t.itemWidth}),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:t.viewportWidth}))},[t,n,r]),u.jsx("div",{ref:s,style:Fs(!1),children:e})},aT=w.memo(function({...e}){const t=lt("useWindowScroll"),n=lt("customScrollParent"),r=n||t?cT:lT,o=n||t?iT:sT,s=lt("context");return u.jsx(r,{...e,...Mt(r,s),children:u.jsxs(o,{children:[u.jsx(rT,{}),u.jsx(nT,{}),u.jsx(oT,{})]})})}),{useEmitter:rh,useEmitterValue:lt,usePublisher:rn}=zp(tT,{optional:{context:"context",totalCount:"totalCount",overscan:"overscan",itemContent:"itemContent",components:"components",computeItemKey:"computeItemKey",data:"data",initialItemCount:"initialItemCount",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"headerFooterTag",listClassName:"listClassName",itemClassName:"itemClassName",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",restoreStateFrom:"restoreStateFrom",initialTopMostItemIndex:"initialTopMostItemIndex",increaseViewportBy:"increaseViewportBy"},methods:{scrollTo:"scrollTo",scrollBy:"scrollBy",scrollToIndex:"scrollToIndex"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",stateChanged:"stateChanged",readyStateChanged:"readyStateChanged"}},aT),lT=Yp({useEmitter:rh,useEmitterValue:lt,usePublisher:rn}),cT=Xp({useEmitter:rh,useEmitterValue:lt,usePublisher:rn});function oh(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Ut.WARN),t==="normal"?0:parseInt(t??"0",10)}var Hs="Dialog",[sh,HN]=cn(Hs),[uT,hn]=sh(Hs),ih=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:i=!0}=e,a=h.useRef(null),l=h.useRef(null),[c,d]=On({prop:r,defaultProp:o??!1,onChange:s,caller:Hs});return u.jsx(uT,{scope:t,triggerRef:a,contentRef:l,contentId:_t(),titleId:_t(),descriptionId:_t(),open:c,onOpenChange:d,onOpenToggle:h.useCallback(()=>d(p=>!p),[d]),modal:i,children:n})};ih.displayName=Hs;var ah="DialogTrigger",lh=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=hn(ah,n),s=je(t,o.triggerRef);return u.jsx(pe.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":il(o.open),...r,ref:s,onClick:ie(e.onClick,o.onOpenToggle)})});lh.displayName=ah;var ol="DialogPortal",[dT,ch]=sh(ol,{forceMount:void 0}),uh=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,s=hn(ol,t);return u.jsx(dT,{scope:t,forceMount:n,children:h.Children.map(r,i=>u.jsx(Ht,{present:n||s.open,children:u.jsx(co,{asChild:!0,container:o,children:i})}))})};uh.displayName=ol;var Us="DialogOverlay",dh=h.forwardRef((e,t)=>{const n=ch(Us,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=hn(Us,e.__scopeDialog);return s.modal?u.jsx(Ht,{present:r||s.open,children:u.jsx(pT,{...o,ref:t})}):null});dh.displayName=Us;var fT=qt.createSlot("DialogOverlay.RemoveScroll"),pT=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=hn(Us,n);return u.jsx(ys,{as:fT,allowPinchZoom:!0,shards:[o.contentRef],children:u.jsx(pe.div,{"data-state":il(o.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),cr="DialogContent",fh=h.forwardRef((e,t)=>{const n=ch(cr,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,s=hn(cr,e.__scopeDialog);return u.jsx(Ht,{present:r||s.open,children:s.modal?u.jsx(hT,{...o,ref:t}):u.jsx(mT,{...o,ref:t})})});fh.displayName=cr;var hT=h.forwardRef((e,t)=>{const n=hn(cr,e.__scopeDialog),r=h.useRef(null),o=je(t,n.contentRef,r);return h.useEffect(()=>{const s=r.current;if(s)return ya(s)},[]),u.jsx(ph,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ie(e.onCloseAutoFocus,s=>{var i;s.preventDefault(),(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:ie(e.onPointerDownOutside,s=>{const i=s.detail.originalEvent,a=i.button===0&&i.ctrlKey===!0;(i.button===2||a)&&s.preventDefault()}),onFocusOutside:ie(e.onFocusOutside,s=>s.preventDefault())})}),mT=h.forwardRef((e,t)=>{const n=hn(cr,e.__scopeDialog),r=h.useRef(!1),o=h.useRef(!1);return u.jsx(ph,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var i,a;(i=e.onCloseAutoFocus)==null||i.call(e,s),s.defaultPrevented||(r.current||(a=n.triggerRef.current)==null||a.focus(),s.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:s=>{var 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()}})}),ph=h.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=e,a=hn(cr,n),l=h.useRef(null),c=je(t,l);return Zi(),u.jsxs(u.Fragment,{children:[u.jsx(ns,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:u.jsx(Er,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":il(a.open),...i,ref:c,onDismiss:()=>a.onOpenChange(!1)})}),u.jsxs(u.Fragment,{children:[u.jsx(gT,{titleId:a.titleId}),u.jsx(vT,{contentRef:l,descriptionId:a.descriptionId})]})]})}),sl="DialogTitle",hh=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=hn(sl,n);return u.jsx(pe.h2,{id:o.titleId,...r,ref:t})});hh.displayName=sl;var mh="DialogDescription",gh=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=hn(mh,n);return u.jsx(pe.p,{id:o.descriptionId,...r,ref:t})});gh.displayName=mh;var xh="DialogClose",vh=h.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=hn(xh,n);return u.jsx(pe.button,{type:"button",...r,ref:t,onClick:ie(e.onClick,()=>o.onOpenChange(!1))})});vh.displayName=xh;function il(e){return e?"open":"closed"}var wh="DialogTitleWarning",[UN,bh]=_w(wh,{contentName:cr,titleName:sl,docsSlug:"dialog"}),gT=({titleId:e})=>{const t=bh(wh),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
80
80
|
|
|
81
81
|
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
82
82
|
|
|
83
|
-
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return h.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},xT="DialogDescriptionWarning",vT=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${bh(xT).contentName}}.`;return h.useEffect(()=>{var s;const o=(s=e.current)==null?void 0:s.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},al=ih,wT=lh,ll=uh,No=dh,Ao=fh,ur=hh,Ws=gh,yh=vh;const cl=al,bT=ll,Sh=h.forwardRef(({className:e,...t},n)=>u.jsx(No,{ref:n,className:ne("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));Sh.displayName=No.displayName;const Vs=h.forwardRef(({className:e,children:t,...n},r)=>{const o=h.useMemo(()=>{let s=!1;function i(a){h.Children.forEach(a,c=>{if(s||!h.isValidElement(c))return;const l=c.type;if(l===ur||(l==null?void 0:l.displayName)===ur.displayName||(l==null?void 0:l.name)==="DialogTitle"){s=!0;return}c.props&&c.props.children&&i(c.props.children)})}return i(t),s},[t]);return u.jsxs(bT,{children:[u.jsx(Sh,{}),u.jsxs(Ao,{ref:r,className:ne("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...n,children:[!o&&u.jsx(ur,{className:"sr-only",children:"Dialog"}),t,u.jsxs(yh,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[u.jsx(le.X,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]})});Vs.displayName=Ao.displayName;const Ks=({className:e,...t})=>u.jsx("div",{className:ne("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});Ks.displayName="DialogHeader";const qs=h.forwardRef(({className:e,...t},n)=>u.jsx(ur,{ref:n,className:ne("text-lg font-semibold leading-none tracking-tight",e),...t}));qs.displayName=ur.displayName;const yT=h.forwardRef(({className:e,...t},n)=>u.jsx(Ws,{ref:n,className:ne("text-sm text-muted-foreground",e),...t}));yT.displayName=Ws.displayName;const ST=1,CT=1e6;let ul=0;function TT(){return ul=(ul+1)%Number.MAX_SAFE_INTEGER,ul.toString()}const dl=new Map,Ch=e=>{if(dl.has(e))return;const t=setTimeout(()=>{dl.delete(e),Po({type:"REMOVE_TOAST",toastId:e})},CT);dl.set(e,t)},kT=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,ST)};case"UPDATE_TOAST":return{...e,toasts:e.toasts.map(n=>n.id===t.toast.id?{...n,...t.toast}:n)};case"DISMISS_TOAST":{const{toastId:n}=t;return n?Ch(n):e.toasts.forEach(r=>{Ch(r.id)}),{...e,toasts:e.toasts.map(r=>r.id===n||n===void 0?{...r,open:!1}:r)}}case"REMOVE_TOAST":return t.toastId===void 0?{...e,toasts:[]}:{...e,toasts:e.toasts.filter(n=>n.id!==t.toastId)}}},Gs=[];let Ys={toasts:[]};function Po(e){Ys=kT(Ys,e),Gs.forEach(t=>{t(Ys)})}function ET({...e}){const t=TT(),n=o=>Po({type:"UPDATE_TOAST",toast:{...o,id:t}}),r=()=>Po({type:"DISMISS_TOAST",toastId:t});return Po({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:o=>{o||r()}}}),{id:t,dismiss:r,update:n}}function fl(){const[e,t]=h.useState(Ys);return h.useEffect(()=>(Gs.push(t),()=>{const n=Gs.indexOf(t);n>-1&&Gs.splice(n,1)}),[e]),{...e,toast:ET,dismiss:n=>Po({type:"DISMISS_TOAST",toastId:n})}}function Th({isOpen:e,onClose:t,fileId:n,fileName:r,mimeType:o}){const[s,i]=w.useState(!1),[a,c]=w.useState(null),[l,d]=w.useState(null),{toast:p}=fl(),m=w.useCallback(async()=>{if(n){i(!0),d(null),c(null);try{const y=await Fi(n);c(y)}catch(y){console.error("Failed to load file:",y),d(y instanceof Error?y.message:"Failed to load file")}finally{i(!1)}}},[n]);w.useEffect(()=>{e&&n&&m()},[e,n,m]);const f=async()=>{if(n)try{await lu(n),p({title:"Download started",description:`Downloading ${r}`})}catch(y){console.error("Failed to download file:",y),p({title:"Download failed",description:String(y),variant:"destructive"})}},v=async()=>{if(n)try{const y=await Fi(n),b=new Blob([y],{type:o}),C=URL.createObjectURL(b);window.open(C,"_blank"),URL.revokeObjectURL(C)}catch(y){console.error("Failed to open file externally:",y),p({title:"Failed to open file",description:String(y),variant:"destructive"})}},g=()=>s?u.jsxs("div",{className:"flex items-center justify-center py-12",children:[u.jsx(le.Loader,{className:"h-8 w-8 animate-spin mr-3"}),u.jsx("span",{children:"Loading file..."})]}):l?u.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[u.jsx("div",{className:"text-red-500 mb-4",children:"⚠️"}),u.jsx("p",{className:"text-red-600 mb-4",children:l}),u.jsx(Ye,{onClick:m,variant:"outline",children:"Try Again"})]}):a?o.startsWith("image/")?u.jsx("div",{className:"flex justify-center",children:u.jsx("img",{src:`data:${o};base64,${a}`,alt:r,className:"max-w-full max-h-[70vh] object-contain rounded-lg"})}):o==="application/pdf"?u.jsx("div",{className:"w-full h-[70vh] border rounded-lg overflow-hidden",children:u.jsx("iframe",{src:`data:application/pdf;base64,${a}`,className:"w-full h-full",title:r})}):o.startsWith("text/")||o.includes("json")||o.includes("xml")?u.jsx("div",{className:"bg-gray-50 dark:bg-gray-900 rounded-lg p-4 max-h-[70vh] overflow-auto",children:u.jsx("pre",{className:"whitespace-pre-wrap font-mono text-sm",children:a})}):u.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[u.jsx(le.FileText,{className:"h-16 w-16 text-gray-400 mb-4"}),u.jsx("p",{className:"text-lg font-medium mb-2",children:r}),u.jsxs("p",{className:"text-sm text-muted-foreground mb-4",children:[o," • ",a.length," bytes"]}),u.jsx("p",{className:"text-sm text-muted-foreground",children:"This file type cannot be previewed. Use download or external view."})]}):u.jsx("div",{className:"flex items-center justify-center py-12",children:u.jsx("p",{className:"text-muted-foreground",children:"No content to display"})}),x=()=>o.startsWith("image/")?u.jsx(le.Image,{className:"h-5 w-5"}):u.jsx(le.FileText,{className:"h-5 w-5"});return u.jsx(cl,{open:e,onOpenChange:t,children:u.jsxs(Vs,{className:"max-w-4xl max-h-[90vh] overflow-hidden",children:[u.jsx(Ks,{children:u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[x(),u.jsxs("div",{children:[u.jsx(qs,{className:"text-left",children:r}),u.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:[o," • Click download or external view for full access"]})]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsxs(Ye,{variant:"outline",size:"sm",onClick:v,className:"flex items-center gap-2",children:[u.jsx(le.ExternalLink,{className:"h-4 w-4"}),"External"]}),u.jsxs(Ye,{variant:"outline",size:"sm",onClick:f,className:"flex items-center gap-2",children:[u.jsx(le.Download,{className:"h-4 w-4"}),"Download"]})]})]})}),u.jsx("div",{className:"flex-1 overflow-hidden",children:g()})]})})}function kh(){return{async:!1,baseUrl:null,breaks:!1,extensions:null,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,hooks:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:null,sanitize:!1,sanitizer:null,silent:!1,smartypants:!1,tokenizer:null,walkTokens:null,xhtml:!1}}let dr=kh();function IT(e){dr=e}const Eh=/[&<>"']/,NT=new RegExp(Eh.source,"g"),Ih=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,AT=new RegExp(Ih.source,"g"),PT={"&":"&","<":"<",">":">",'"':""","'":"'"},Nh=e=>PT[e];function Mt(e,t){if(t){if(Eh.test(e))return e.replace(NT,Nh)}else if(Ih.test(e))return e.replace(AT,Nh);return e}const jT=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function Ah(e){return e.replace(jT,(t,n)=>(n=n.toLowerCase(),n==="colon"?":":n.charAt(0)==="#"?n.charAt(1)==="x"?String.fromCharCode(parseInt(n.substring(2),16)):String.fromCharCode(+n.substring(1)):""))}const _T=/(^|[^\[])\^/g;function Qe(e,t){e=typeof e=="string"?e:e.source,t=t||"";const n={replace:(r,o)=>(o=o.source||o,o=o.replace(_T,"$1"),e=e.replace(r,o),n),getRegex:()=>new RegExp(e,t)};return n}const RT=/[^\w:]/g,MT=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function Ph(e,t,n){if(e){let r;try{r=decodeURIComponent(Ah(n)).replace(RT,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}t&&!MT.test(n)&&(n=$T(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const Xs={},OT=/^[^:]+:\/*[^/]*$/,DT=/^([^:]+:)[\s\S]*$/,LT=/^([^:]+:\/*[^/]*)[\s\S]*$/;function $T(e,t){Xs[" "+e]||(OT.test(e)?Xs[" "+e]=e+"/":Xs[" "+e]=Zs(e,"/",!0)),e=Xs[" "+e];const n=e.indexOf(":")===-1;return t.substring(0,2)==="//"?n?t:e.replace(DT,"$1")+t:t.charAt(0)==="/"?n?t:e.replace(LT,"$1")+t:e+t}const Js={exec:function(){}};function jh(e,t){const n=e.replace(/\|/g,(s,i,a)=>{let c=!1,l=i;for(;--l>=0&&a[l]==="\\";)c=!c;return c?"|":" |"}),r=n.split(/ \|/);let o=0;if(r[0].trim()||r.shift(),r.length>0&&!r[r.length-1].trim()&&r.pop(),r.length>t)r.splice(t);else for(;r.length<t;)r.push("");for(;o<r.length;o++)r[o]=r[o].trim().replace(/\\\|/g,"|");return r}function Zs(e,t,n){const r=e.length;if(r===0)return"";let o=0;for(;o<r;){const s=e.charAt(r-o-1);if(s===t&&!n)o++;else if(s!==t&&n)o++;else break}return e.slice(0,r-o)}function FT(e,t){if(e.indexOf(t[1])===-1)return-1;const n=e.length;let r=0,o=0;for(;o<n;o++)if(e[o]==="\\")o++;else if(e[o]===t[0])r++;else if(e[o]===t[1]&&(r--,r<0))return o;return-1}function BT(e){e&&e.sanitize&&!e.silent&&console.warn("marked(): sanitize and sanitizer parameters are deprecated since version 0.7.0, should not be used and will be removed in the future. Read more here: https://marked.js.org/#/USING_ADVANCED.md#options")}function _h(e,t){if(t<1)return"";let n="";for(;t>1;)t&1&&(n+=e),t>>=1,e+=e;return n+e}function Rh(e,t,n,r){const o=t.href,s=t.title?Mt(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:Mt(i)}}function zT(e,t){const n=e.match(/^(\s+)(?:```)/);if(n===null)return t;const r=n[1];return t.split(`
|
|
83
|
+
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return h.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},xT="DialogDescriptionWarning",vT=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${bh(xT).contentName}}.`;return h.useEffect(()=>{var s;const o=(s=e.current)==null?void 0:s.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},al=ih,wT=lh,ll=uh,No=dh,Ao=fh,ur=hh,Ws=gh,yh=vh;const cl=al,bT=ll,Sh=h.forwardRef(({className:e,...t},n)=>u.jsx(No,{ref:n,className:ne("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));Sh.displayName=No.displayName;const Vs=h.forwardRef(({className:e,children:t,...n},r)=>{const o=h.useMemo(()=>{let s=!1;function i(a){h.Children.forEach(a,l=>{if(s||!h.isValidElement(l))return;const c=l.type;if(c===ur||(c==null?void 0:c.displayName)===ur.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(bT,{children:[u.jsx(Sh,{}),u.jsxs(Ao,{ref:r,className:ne("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...n,children:[!o&&u.jsx(ur,{className:"sr-only",children:"Dialog"}),t,u.jsxs(yh,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[u.jsx(le.X,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]})});Vs.displayName=Ao.displayName;const Ks=({className:e,...t})=>u.jsx("div",{className:ne("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});Ks.displayName="DialogHeader";const qs=h.forwardRef(({className:e,...t},n)=>u.jsx(ur,{ref:n,className:ne("text-lg font-semibold leading-none tracking-tight",e),...t}));qs.displayName=ur.displayName;const yT=h.forwardRef(({className:e,...t},n)=>u.jsx(Ws,{ref:n,className:ne("text-sm text-muted-foreground",e),...t}));yT.displayName=Ws.displayName;const ST=1,CT=1e6;let ul=0;function TT(){return ul=(ul+1)%Number.MAX_SAFE_INTEGER,ul.toString()}const dl=new Map,Ch=e=>{if(dl.has(e))return;const t=setTimeout(()=>{dl.delete(e),Po({type:"REMOVE_TOAST",toastId:e})},CT);dl.set(e,t)},kT=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,ST)};case"UPDATE_TOAST":return{...e,toasts:e.toasts.map(n=>n.id===t.toast.id?{...n,...t.toast}:n)};case"DISMISS_TOAST":{const{toastId:n}=t;return n?Ch(n):e.toasts.forEach(r=>{Ch(r.id)}),{...e,toasts:e.toasts.map(r=>r.id===n||n===void 0?{...r,open:!1}:r)}}case"REMOVE_TOAST":return t.toastId===void 0?{...e,toasts:[]}:{...e,toasts:e.toasts.filter(n=>n.id!==t.toastId)}}},Gs=[];let Ys={toasts:[]};function Po(e){Ys=kT(Ys,e),Gs.forEach(t=>{t(Ys)})}function ET({...e}){const t=TT(),n=o=>Po({type:"UPDATE_TOAST",toast:{...o,id:t}}),r=()=>Po({type:"DISMISS_TOAST",toastId:t});return Po({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:o=>{o||r()}}}),{id:t,dismiss:r,update:n}}function fl(){const[e,t]=h.useState(Ys);return h.useEffect(()=>(Gs.push(t),()=>{const n=Gs.indexOf(t);n>-1&&Gs.splice(n,1)}),[e]),{...e,toast:ET,dismiss:n=>Po({type:"DISMISS_TOAST",toastId:n})}}function Th({isOpen:e,onClose:t,fileId:n,fileName:r,mimeType:o}){const[s,i]=w.useState(!1),[a,l]=w.useState(null),[c,d]=w.useState(null),{toast:p}=fl(),m=w.useCallback(async()=>{if(n){i(!0),d(null),l(null);try{const y=await Fi(n);l(y)}catch(y){console.error("Failed to load file:",y),d(y instanceof Error?y.message:"Failed to load file")}finally{i(!1)}}},[n]);w.useEffect(()=>{e&&n&&m()},[e,n,m]);const f=async()=>{if(n)try{await lu(n),p({title:"Download started",description:`Downloading ${r}`})}catch(y){console.error("Failed to download file:",y),p({title:"Download failed",description:String(y),variant:"destructive"})}},v=async()=>{if(n)try{const y=await Fi(n),b=new Blob([y],{type:o}),C=URL.createObjectURL(b);window.open(C,"_blank"),URL.revokeObjectURL(C)}catch(y){console.error("Failed to open file externally:",y),p({title:"Failed to open file",description:String(y),variant:"destructive"})}},g=()=>s?u.jsxs("div",{className:"flex items-center justify-center py-12",children:[u.jsx(le.Loader,{className:"h-8 w-8 animate-spin mr-3"}),u.jsx("span",{children:"Loading file..."})]}):c?u.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[u.jsx("div",{className:"text-red-500 mb-4",children:"⚠️"}),u.jsx("p",{className:"text-red-600 mb-4",children:c}),u.jsx(Ye,{onClick:m,variant:"outline",children:"Try Again"})]}):a?o.startsWith("image/")?u.jsx("div",{className:"flex justify-center",children:u.jsx("img",{src:`data:${o};base64,${a}`,alt:r,className:"max-w-full max-h-[70vh] object-contain rounded-lg"})}):o==="application/pdf"?u.jsx("div",{className:"w-full h-[70vh] border rounded-lg overflow-hidden",children:u.jsx("iframe",{src:`data:application/pdf;base64,${a}`,className:"w-full h-full",title:r})}):o.startsWith("text/")||o.includes("json")||o.includes("xml")?u.jsx("div",{className:"bg-gray-50 dark:bg-gray-900 rounded-lg p-4 max-h-[70vh] overflow-auto",children:u.jsx("pre",{className:"whitespace-pre-wrap font-mono text-sm",children:a})}):u.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[u.jsx(le.FileText,{className:"h-16 w-16 text-gray-400 mb-4"}),u.jsx("p",{className:"text-lg font-medium mb-2",children:r}),u.jsxs("p",{className:"text-sm text-muted-foreground mb-4",children:[o," • ",a.length," bytes"]}),u.jsx("p",{className:"text-sm text-muted-foreground",children:"This file type cannot be previewed. Use download or external view."})]}):u.jsx("div",{className:"flex items-center justify-center py-12",children:u.jsx("p",{className:"text-muted-foreground",children:"No content to display"})}),x=()=>o.startsWith("image/")?u.jsx(le.Image,{className:"h-5 w-5"}):u.jsx(le.FileText,{className:"h-5 w-5"});return u.jsx(cl,{open:e,onOpenChange:t,children:u.jsxs(Vs,{className:"max-w-4xl max-h-[90vh] overflow-hidden",children:[u.jsx(Ks,{children:u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[x(),u.jsxs("div",{children:[u.jsx(qs,{className:"text-left",children:r}),u.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:[o," • Click download or external view for full access"]})]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsxs(Ye,{variant:"outline",size:"sm",onClick:v,className:"flex items-center gap-2",children:[u.jsx(le.ExternalLink,{className:"h-4 w-4"}),"External"]}),u.jsxs(Ye,{variant:"outline",size:"sm",onClick:f,className:"flex items-center gap-2",children:[u.jsx(le.Download,{className:"h-4 w-4"}),"Download"]})]})]})}),u.jsx("div",{className:"flex-1 overflow-hidden",children:g()})]})})}function kh(){return{async:!1,baseUrl:null,breaks:!1,extensions:null,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,hooks:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:null,sanitize:!1,sanitizer:null,silent:!1,smartypants:!1,tokenizer:null,walkTokens:null,xhtml:!1}}let dr=kh();function IT(e){dr=e}const Eh=/[&<>"']/,NT=new RegExp(Eh.source,"g"),Ih=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,AT=new RegExp(Ih.source,"g"),PT={"&":"&","<":"<",">":">",'"':""","'":"'"},Nh=e=>PT[e];function Ot(e,t){if(t){if(Eh.test(e))return e.replace(NT,Nh)}else if(Ih.test(e))return e.replace(AT,Nh);return e}const jT=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function Ah(e){return e.replace(jT,(t,n)=>(n=n.toLowerCase(),n==="colon"?":":n.charAt(0)==="#"?n.charAt(1)==="x"?String.fromCharCode(parseInt(n.substring(2),16)):String.fromCharCode(+n.substring(1)):""))}const _T=/(^|[^\[])\^/g;function et(e,t){e=typeof e=="string"?e:e.source,t=t||"";const n={replace:(r,o)=>(o=o.source||o,o=o.replace(_T,"$1"),e=e.replace(r,o),n),getRegex:()=>new RegExp(e,t)};return n}const RT=/[^\w:]/g,MT=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function Ph(e,t,n){if(e){let r;try{r=decodeURIComponent(Ah(n)).replace(RT,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}t&&!MT.test(n)&&(n=$T(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const Xs={},OT=/^[^:]+:\/*[^/]*$/,DT=/^([^:]+:)[\s\S]*$/,LT=/^([^:]+:\/*[^/]*)[\s\S]*$/;function $T(e,t){Xs[" "+e]||(OT.test(e)?Xs[" "+e]=e+"/":Xs[" "+e]=Zs(e,"/",!0)),e=Xs[" "+e];const n=e.indexOf(":")===-1;return t.substring(0,2)==="//"?n?t:e.replace(DT,"$1")+t:t.charAt(0)==="/"?n?t:e.replace(LT,"$1")+t:e+t}const Js={exec:function(){}};function jh(e,t){const n=e.replace(/\|/g,(s,i,a)=>{let 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 Zs(e,t,n){const r=e.length;if(r===0)return"";let o=0;for(;o<r;){const s=e.charAt(r-o-1);if(s===t&&!n)o++;else if(s!==t&&n)o++;else break}return e.slice(0,r-o)}function FT(e,t){if(e.indexOf(t[1])===-1)return-1;const n=e.length;let r=0,o=0;for(;o<n;o++)if(e[o]==="\\")o++;else if(e[o]===t[0])r++;else if(e[o]===t[1]&&(r--,r<0))return o;return-1}function BT(e){e&&e.sanitize&&!e.silent&&console.warn("marked(): sanitize and sanitizer parameters are deprecated since version 0.7.0, should not be used and will be removed in the future. Read more here: https://marked.js.org/#/USING_ADVANCED.md#options")}function _h(e,t){if(t<1)return"";let n="";for(;t>1;)t&1&&(n+=e),t>>=1,e+=e;return n+e}function Rh(e,t,n,r){const o=t.href,s=t.title?Ot(t.title):null,i=e[1].replace(/\\([\[\]])/g,"$1");if(e[0].charAt(0)!=="!"){r.state.inLink=!0;const a={type:"link",raw:n,href:o,title:s,text:i,tokens:r.inlineTokens(i)};return r.state.inLink=!1,a}return{type:"image",raw:n,href:o,title:s,text:Ot(i)}}function zT(e,t){const n=e.match(/^(\s+)(?:```)/);if(n===null)return t;const r=n[1];return t.split(`
|
|
84
84
|
`).map(o=>{const s=o.match(/^\s+/);if(s===null)return o;const[i]=s;return i.length>=r.length?o.slice(r.length):o}).join(`
|
|
85
85
|
`)}class pl{constructor(t){this.options=t||dr}space(t){const n=this.rules.block.newline.exec(t);if(n&&n[0].length>0)return{type:"space",raw:n[0]}}code(t){const n=this.rules.block.code.exec(t);if(n){const r=n[0].replace(/^ {1,4}/gm,"");return{type:"code",raw:n[0],codeBlockStyle:"indented",text:this.options.pedantic?r:Zs(r,`
|
|
86
|
-
`)}}}fences(t){const n=this.rules.block.fences.exec(t);if(n){const r=n[0],o=zT(r,n[3]||"");return{type:"code",raw:r,lang:n[2]?n[2].trim().replace(this.rules.inline._escapes,"$1"):n[2],text:o}}}heading(t){const n=this.rules.block.heading.exec(t);if(n){let r=n[2].trim();if(/#$/.test(r)){const o=Zs(r,"#");(this.options.pedantic||!o||/ $/.test(o))&&(r=o.trim())}return{type:"heading",raw:n[0],depth:n[1].length,text:r,tokens:this.lexer.inline(r)}}}hr(t){const n=this.rules.block.hr.exec(t);if(n)return{type:"hr",raw:n[0]}}blockquote(t){const n=this.rules.block.blockquote.exec(t);if(n){const r=n[0].replace(/^ *>[ \t]?/gm,""),o=this.lexer.state.top;this.lexer.state.top=!0;const s=this.lexer.blockTokens(r);return this.lexer.state.top=o,{type:"blockquote",raw:n[0],tokens:s,text:r}}}list(t){let n=this.rules.block.list.exec(t);if(n){let r,o,s,i,a,c,
|
|
86
|
+
`)}}}fences(t){const n=this.rules.block.fences.exec(t);if(n){const r=n[0],o=zT(r,n[3]||"");return{type:"code",raw:r,lang:n[2]?n[2].trim().replace(this.rules.inline._escapes,"$1"):n[2],text:o}}}heading(t){const n=this.rules.block.heading.exec(t);if(n){let r=n[2].trim();if(/#$/.test(r)){const o=Zs(r,"#");(this.options.pedantic||!o||/ $/.test(o))&&(r=o.trim())}return{type:"heading",raw:n[0],depth:n[1].length,text:r,tokens:this.lexer.inline(r)}}}hr(t){const n=this.rules.block.hr.exec(t);if(n)return{type:"hr",raw:n[0]}}blockquote(t){const n=this.rules.block.blockquote.exec(t);if(n){const r=n[0].replace(/^ *>[ \t]?/gm,""),o=this.lexer.state.top;this.lexer.state.top=!0;const s=this.lexer.blockTokens(r);return this.lexer.state.top=o,{type:"blockquote",raw:n[0],tokens:s,text:r}}}list(t){let n=this.rules.block.list.exec(t);if(n){let r,o,s,i,a,l,c,d,p,m,f,v,g=n[1].trim();const x=g.length>1,y={type:"list",raw:"",ordered:x,start:x?+g.slice(0,-1):"",loose:!1,items:[]};g=x?`\\d{1,9}\\${g.slice(-1)}`:`\\${g}`,this.options.pedantic&&(g=x?g:"[*+-]");const b=new RegExp(`^( {0,3}${g})((?:[ ][^\\n]*)?(?:\\n|$))`);for(;t&&(v=!1,!(!(n=b.exec(t))||this.rules.block.hr.test(t)));){if(r=n[0],t=t.substring(r.length),d=n[2].split(`
|
|
87
87
|
`,1)[0].replace(/^\t+/,k=>" ".repeat(3*k.length)),p=t.split(`
|
|
88
|
-
`,1)[0],this.options.pedantic?(i=2,f=d.trimLeft()):(i=n[2].search(/[^ ]/),i=i>4?1:i,f=d.slice(i),i+=n[1].length),
|
|
88
|
+
`,1)[0],this.options.pedantic?(i=2,f=d.trimLeft()):(i=n[2].search(/[^ ]/),i=i>4?1:i,f=d.slice(i),i+=n[1].length),l=!1,!d&&/^ *$/.test(p)&&(r+=p+`
|
|
89
89
|
`,t=t.substring(p.length+1),v=!0),!v){const k=new RegExp(`^ {0,${Math.min(3,i-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),S=new RegExp(`^ {0,${Math.min(3,i-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),T=new RegExp(`^ {0,${Math.min(3,i-1)}}(?:\`\`\`|~~~)`),E=new RegExp(`^ {0,${Math.min(3,i-1)}}#`);for(;t&&(m=t.split(`
|
|
90
90
|
`,1)[0],p=m,this.options.pedantic&&(p=p.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),!(T.test(p)||E.test(p)||k.test(p)||S.test(t)));){if(p.search(/[^ ]/)>=i||!p.trim())f+=`
|
|
91
|
-
`+p.slice(i);else{if(
|
|
92
|
-
`+p}!
|
|
93
|
-
`,t=t.substring(m.length+1),d=p.slice(i)}}y.loose||(
|
|
94
|
-
`):[]};if(r.header.length===r.align.length){r.raw=n[0];let o=r.align.length,s,i,a,
|
|
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:
|
|
96
|
-
]`).replace("lheading",
|
|
97
|
-
`),this.blockTokens(t,this.tokens);let n;for(;n=this.inlineQueue.shift();)this.inlineTokens(n.src,n.tokens);return this.tokens}blockTokens(t,n=[]){this.options.pedantic?t=t.replace(/\t/g," ").replace(/^ +$/gm,""):t=t.replace(/^( *)(\t+)/gm,(a,c
|
|
91
|
+
`+p.slice(i);else{if(l||d.search(/[^ ]/)>=4||T.test(d)||E.test(d)||S.test(d))break;f+=`
|
|
92
|
+
`+p}!l&&!p.trim()&&(l=!0),r+=m+`
|
|
93
|
+
`,t=t.substring(m.length+1),d=p.slice(i)}}y.loose||(c?y.loose=!0:/\n *\n *$/.test(r)&&(c=!0)),this.options.gfm&&(o=/^\[[ xX]\] /.exec(f),o&&(s=o[0]!=="[ ] ",f=f.replace(/^\[[ xX]\] +/,""))),y.items.push({type:"list_item",raw:r,task:!!o,checked:s,loose:!1,text:f}),y.raw+=r}y.items[y.items.length-1].raw=r.trimRight(),y.items[y.items.length-1].text=f.trimRight(),y.raw=y.raw.trimRight();const C=y.items.length;for(a=0;a<C;a++)if(this.lexer.state.top=!1,y.items[a].tokens=this.lexer.blockTokens(y.items[a].text,[]),!y.loose){const k=y.items[a].tokens.filter(T=>T.type==="space"),S=k.length>0&&k.some(T=>/\n.*\n/.test(T.raw));y.loose=S}if(y.loose)for(a=0;a<C;a++)y.items[a].loose=!0;return y}}html(t){const n=this.rules.block.html.exec(t);if(n){const r={type:"html",raw:n[0],pre:!this.options.sanitizer&&(n[1]==="pre"||n[1]==="script"||n[1]==="style"),text:n[0]};if(this.options.sanitize){const o=this.options.sanitizer?this.options.sanitizer(n[0]):Ot(n[0]);r.type="paragraph",r.text=o,r.tokens=this.lexer.inline(o)}return r}}def(t){const n=this.rules.block.def.exec(t);if(n){const r=n[1].toLowerCase().replace(/\s+/g," "),o=n[2]?n[2].replace(/^<(.*)>$/,"$1").replace(this.rules.inline._escapes,"$1"):"",s=n[3]?n[3].substring(1,n[3].length-1).replace(this.rules.inline._escapes,"$1"):n[3];return{type:"def",tag:r,raw:n[0],href:o,title:s}}}table(t){const n=this.rules.block.table.exec(t);if(n){const r={type:"table",header:jh(n[1]).map(o=>({text:o})),align:n[2].replace(/^ *|\| *$/g,"").split(/ *\| */),rows:n[3]&&n[3].trim()?n[3].replace(/\n[ \t]*$/,"").split(`
|
|
94
|
+
`):[]};if(r.header.length===r.align.length){r.raw=n[0];let o=r.align.length,s,i,a,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]=jh(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:Ot(n[1])}}tag(t){const n=this.rules.inline.tag.exec(t);if(n)return!this.lexer.state.inLink&&/^<a /i.test(n[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&/^<\/a>/i.test(n[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(n[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(n[0])&&(this.lexer.state.inRawBlock=!1),{type:this.options.sanitize?"text":"html",raw:n[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(n[0]):Ot(n[0]):n[0]}}link(t){const n=this.rules.inline.link.exec(t);if(n){const r=n[2].trim();if(!this.options.pedantic&&/^</.test(r)){if(!/>$/.test(r))return;const i=Zs(r.slice(0,-1),"\\");if((r.length-i.length)%2===0)return}else{const i=FT(n[2],"()");if(i>-1){const 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)),Rh(n,{href:o&&o.replace(this.rules.inline._escapes,"$1"),title:s&&s.replace(this.rules.inline._escapes,"$1")},n[0],this.lexer)}}reflink(t,n){let r;if((r=this.rules.inline.reflink.exec(t))||(r=this.rules.inline.nolink.exec(t))){let o=(r[2]||r[1]).replace(/\s+/g," ");if(o=n[o.toLowerCase()],!o){const s=r[0].charAt(0);return{type:"text",raw:s,text:s}}return Rh(r,o,r[0],this.lexer)}}emStrong(t,n,r=""){let o=this.rules.inline.emStrong.lDelim.exec(t);if(!o||o[3]&&r.match(/[\p{L}\p{N}]/u))return;const s=o[1]||o[2]||"";if(!s||s&&(r===""||this.rules.inline.punctuation.exec(r))){const i=o[0].length-1;let a,l,c=i,d=0;const p=o[0][0]==="*"?this.rules.inline.emStrong.rDelimAst:this.rules.inline.emStrong.rDelimUnd;for(p.lastIndex=0,n=n.slice(-1*t.length+i);(o=p.exec(n))!=null;){if(a=o[1]||o[2]||o[3]||o[4]||o[5]||o[6],!a)continue;if(l=a.length,o[3]||o[4]){c+=l;continue}else if((o[5]||o[6])&&i%3&&!((i+l)%3)){d+=l;continue}if(c-=l,c>0)continue;l=Math.min(l,l+c+d);const m=t.slice(0,i+o.index+(o[0].length-a.length)+l);if(Math.min(i,l)%2){const v=m.slice(1,-1);return{type:"em",raw:m,text:v,tokens:this.lexer.inlineTokens(v)}}const f=m.slice(2,-2);return{type:"strong",raw:m,text:f,tokens:this.lexer.inlineTokens(f)}}}}codespan(t){const n=this.rules.inline.code.exec(t);if(n){let r=n[2].replace(/\n/g," ");const o=/[^ ]/.test(r),s=/^ /.test(r)&&/ $/.test(r);return o&&s&&(r=r.substring(1,r.length-1)),r=Ot(r,!0),{type:"codespan",raw:n[0],text:r}}}br(t){const n=this.rules.inline.br.exec(t);if(n)return{type:"br",raw:n[0]}}del(t){const n=this.rules.inline.del.exec(t);if(n)return{type:"del",raw:n[0],text:n[2],tokens:this.lexer.inlineTokens(n[2])}}autolink(t,n){const r=this.rules.inline.autolink.exec(t);if(r){let o,s;return r[2]==="@"?(o=Ot(this.options.mangle?n(r[1]):r[1]),s="mailto:"+o):(o=Ot(r[1]),s=o),{type:"link",raw:r[0],text:o,href:s,tokens:[{type:"text",raw:o,text:o}]}}}url(t,n){let r;if(r=this.rules.inline.url.exec(t)){let o,s;if(r[2]==="@")o=Ot(this.options.mangle?n(r[0]):r[0]),s="mailto:"+o;else{let i;do i=r[0],r[0]=this.rules.inline._backpedal.exec(r[0])[0];while(i!==r[0]);o=Ot(r[0]),r[1]==="www."?s="http://"+r[0]:s=r[0]}return{type:"link",raw:r[0],text:o,href:s,tokens:[{type:"text",raw:o,text:o}]}}}inlineText(t,n){const r=this.rules.inline.text.exec(t);if(r){let o;return this.lexer.state.inRawBlock?o=this.options.sanitize?this.options.sanitizer?this.options.sanitizer(r[0]):Ot(r[0]):r[0]:o=Ot(this.options.smartypants?n(r[0]):r[0]),{type:"text",raw:r[0],text:o}}}}const ve={newline:/^(?: *(?:\n|$))+/,code:/^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,fences:/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,hr:/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,blockquote:/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,list:/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/,html:"^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n *)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$))",def:/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/,table:Js,lheading:/^((?:.|\n(?!\n))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,text:/^[^\n]+/};ve._label=/(?!\s*\])(?:\\.|[^\[\]\\])+/,ve._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,ve.def=et(ve.def).replace("label",ve._label).replace("title",ve._title).getRegex(),ve.bullet=/(?:[*+-]|\d{1,9}[.)])/,ve.listItemStart=et(/^( *)(bull) */).replace("bull",ve.bullet).getRegex(),ve.list=et(ve.list).replace(/bull/g,ve.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+ve.def.source+")").getRegex(),ve._tag="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",ve._comment=/<!--(?!-?>)[\s\S]*?(?:-->|$)/,ve.html=et(ve.html,"i").replace("comment",ve._comment).replace("tag",ve._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),ve.paragraph=et(ve._paragraph).replace("hr",ve.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",ve._tag).getRegex(),ve.blockquote=et(ve.blockquote).replace("paragraph",ve.paragraph).getRegex(),ve.normal={...ve},ve.gfm={...ve.normal,table:"^ *([^\\n ].*\\|.*)\\n {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"},ve.gfm.table=et(ve.gfm.table).replace("hr",ve.hr).replace("heading"," {0,3}#{1,6} ").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",ve._tag).getRegex(),ve.gfm.paragraph=et(ve._paragraph).replace("hr",ve.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("table",ve.gfm.table).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",ve._tag).getRegex(),ve.pedantic={...ve.normal,html:et(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",ve._comment).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Js,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:et(ve.normal._paragraph).replace("hr",ve.hr).replace("heading",` *#{1,6} *[^
|
|
96
|
+
]`).replace("lheading",ve.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()};const ue={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:Js,tag:"^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>",link:/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/,reflink:/^!?\[(label)\]\[(ref)\]/,nolink:/^!?\[(ref)\](?:\[\])?/,reflinkSearch:"reflink|nolink(?!\\()",emStrong:{lDelim:/^(?:\*+(?:([punct_])|[^\s*]))|^_+(?:([punct*])|([^\s_]))/,rDelimAst:/^(?:[^_*\\]|\\.)*?\_\_(?:[^_*\\]|\\.)*?\*(?:[^_*\\]|\\.)*?(?=\_\_)|(?:[^*\\]|\\.)+(?=[^*])|[punct_](\*+)(?=[\s]|$)|(?:[^punct*_\s\\]|\\.)(\*+)(?=[punct_\s]|$)|[punct_\s](\*+)(?=[^punct*_\s])|[\s](\*+)(?=[punct_])|[punct_](\*+)(?=[punct_])|(?:[^punct*_\s\\]|\\.)(\*+)(?=[^punct*_\s])/,rDelimUnd:/^(?:[^_*\\]|\\.)*?\*\*(?:[^_*\\]|\\.)*?\_(?:[^_*\\]|\\.)*?(?=\*\*)|(?:[^_\\]|\\.)+(?=[^_])|[punct*](\_+)(?=[\s]|$)|(?:[^punct*_\s\\]|\\.)(\_+)(?=[punct*\s]|$)|[punct*\s](\_+)(?=[^punct*_\s])|[\s](\_+)(?=[punct*])|[punct*](\_+)(?=[punct*])/},code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,br:/^( {2,}|\\)\n(?!\s*$)/,del:Js,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,punctuation:/^([\spunctuation])/};ue._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",ue.punctuation=et(ue.punctuation).replace(/punctuation/g,ue._punctuation).getRegex(),ue.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g,ue.escapedEmSt=/(?:^|[^\\])(?:\\\\)*\\[*_]/g,ue._comment=et(ve._comment).replace("(?:-->|$)","-->").getRegex(),ue.emStrong.lDelim=et(ue.emStrong.lDelim).replace(/punct/g,ue._punctuation).getRegex(),ue.emStrong.rDelimAst=et(ue.emStrong.rDelimAst,"g").replace(/punct/g,ue._punctuation).getRegex(),ue.emStrong.rDelimUnd=et(ue.emStrong.rDelimUnd,"g").replace(/punct/g,ue._punctuation).getRegex(),ue._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,ue._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,ue._email=/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/,ue.autolink=et(ue.autolink).replace("scheme",ue._scheme).replace("email",ue._email).getRegex(),ue._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,ue.tag=et(ue.tag).replace("comment",ue._comment).replace("attribute",ue._attribute).getRegex(),ue._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,ue._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/,ue._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,ue.link=et(ue.link).replace("label",ue._label).replace("href",ue._href).replace("title",ue._title).getRegex(),ue.reflink=et(ue.reflink).replace("label",ue._label).replace("ref",ve._label).getRegex(),ue.nolink=et(ue.nolink).replace("ref",ve._label).getRegex(),ue.reflinkSearch=et(ue.reflinkSearch,"g").replace("reflink",ue.reflink).replace("nolink",ue.nolink).getRegex(),ue.normal={...ue},ue.pedantic={...ue.normal,strong:{start:/^__|\*\*/,middle:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,endAst:/\*\*(?!\*)/g,endUnd:/__(?!_)/g},em:{start:/^_|\*/,middle:/^()\*(?=\S)([\s\S]*?\S)\*(?!\*)|^_(?=\S)([\s\S]*?\S)_(?!_)/,endAst:/\*(?!\*)/g,endUnd:/_(?!_)/g},link:et(/^!?\[(label)\]\((.*?)\)/).replace("label",ue._label).getRegex(),reflink:et(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",ue._label).getRegex()},ue.gfm={...ue.normal,escape:et(ue.escape).replace("])","~|])").getRegex(),_extended_email:/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,url:/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},ue.gfm.url=et(ue.gfm.url,"i").replace("email",ue.gfm._extended_email).getRegex(),ue.breaks={...ue.gfm,br:et(ue.br).replace("{2,}","*").getRegex(),text:et(ue.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()};function HT(e){return e.replace(/---/g,"—").replace(/--/g,"–").replace(/(^|[-\u2014/(\[{"\s])'/g,"$1‘").replace(/'/g,"’").replace(/(^|[-\u2014/(\[{\u2018\s])"/g,"$1“").replace(/"/g,"”").replace(/\.{3}/g,"…")}function Mh(e){let t="",n,r;const o=e.length;for(n=0;n<o;n++)r=e.charCodeAt(n),Math.random()>.5&&(r="x"+r.toString(16)),t+="&#"+r+";";return t}class Wn{constructor(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||dr,this.options.tokenizer=this.options.tokenizer||new pl,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};const n={block:ve.normal,inline:ue.normal};this.options.pedantic?(n.block=ve.pedantic,n.inline=ue.pedantic):this.options.gfm&&(n.block=ve.gfm,this.options.breaks?n.inline=ue.breaks:n.inline=ue.gfm),this.tokenizer.rules=n}static get rules(){return{block:ve,inline:ue}}static lex(t,n){return new Wn(n).lex(t)}static lexInline(t,n){return new Wn(n).inlineTokens(t)}lex(t){t=t.replace(/\r\n|\r/g,`
|
|
97
|
+
`),this.blockTokens(t,this.tokens);let n;for(;n=this.inlineQueue.shift();)this.inlineTokens(n.src,n.tokens);return this.tokens}blockTokens(t,n=[]){this.options.pedantic?t=t.replace(/\t/g," ").replace(/^ +$/gm,""):t=t.replace(/^( *)(\t+)/gm,(a,l,c)=>l+" ".repeat(c.length));let r,o,s,i;for(;t;)if(!(this.options.extensions&&this.options.extensions.block&&this.options.extensions.block.some(a=>(r=a.call({lexer:this},t,n))?(t=t.substring(r.raw.length),n.push(r),!0):!1))){if(r=this.tokenizer.space(t)){t=t.substring(r.raw.length),r.raw.length===1&&n.length>0?n[n.length-1].raw+=`
|
|
98
98
|
`:n.push(r);continue}if(r=this.tokenizer.code(t)){t=t.substring(r.raw.length),o=n[n.length-1],o&&(o.type==="paragraph"||o.type==="text")?(o.raw+=`
|
|
99
99
|
`+r.raw,o.text+=`
|
|
100
100
|
`+r.text,this.inlineQueue[this.inlineQueue.length-1].src=o.text):n.push(r);continue}if(r=this.tokenizer.fences(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.heading(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.hr(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.blockquote(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.list(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.html(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.def(t)){t=t.substring(r.raw.length),o=n[n.length-1],o&&(o.type==="paragraph"||o.type==="text")?(o.raw+=`
|
|
101
101
|
`+r.raw,o.text+=`
|
|
102
|
-
`+r.raw,this.inlineQueue[this.inlineQueue.length-1].src=o.text):this.tokens.links[r.tag]||(this.tokens.links[r.tag]={href:r.href,title:r.title});continue}if(r=this.tokenizer.table(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.lheading(t)){t=t.substring(r.raw.length),n.push(r);continue}if(s=t,this.options.extensions&&this.options.extensions.startBlock){let a=1/0;const
|
|
102
|
+
`+r.raw,this.inlineQueue[this.inlineQueue.length-1].src=o.text):this.tokens.links[r.tag]||(this.tokens.links[r.tag]={href:r.href,title:r.title});continue}if(r=this.tokenizer.table(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.lheading(t)){t=t.substring(r.raw.length),n.push(r);continue}if(s=t,this.options.extensions&&this.options.extensions.startBlock){let a=1/0;const l=t.slice(1);let c;this.options.extensions.startBlock.forEach(function(d){c=d.call({lexer:this},l),typeof c=="number"&&c>=0&&(a=Math.min(a,c))}),a<1/0&&a>=0&&(s=t.substring(0,a+1))}if(this.state.top&&(r=this.tokenizer.paragraph(s))){o=n[n.length-1],i&&o.type==="paragraph"?(o.raw+=`
|
|
103
103
|
`+r.raw,o.text+=`
|
|
104
104
|
`+r.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=o.text):n.push(r),i=s.length!==t.length,t=t.substring(r.raw.length);continue}if(r=this.tokenizer.text(t)){t=t.substring(r.raw.length),o=n[n.length-1],o&&o.type==="text"?(o.raw+=`
|
|
105
105
|
`+r.raw,o.text+=`
|
|
106
|
-
`+r.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=o.text):n.push(r);continue}if(t){const a="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(a);break}else throw new Error(a)}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}inlineTokens(t,n=[]){let r,o,s,i=t,a,c
|
|
107
|
-
`,o?'<pre><code class="'+this.options.langPrefix+
|
|
108
|
-
`:"<pre><code>"+(r?t:
|
|
106
|
+
`+r.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=o.text):n.push(r);continue}if(t){const a="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(a);break}else throw new Error(a)}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}inlineTokens(t,n=[]){let r,o,s,i=t,a,l,c;if(this.tokens.links){const d=Object.keys(this.tokens.links);if(d.length>0)for(;(a=this.tokenizer.rules.inline.reflinkSearch.exec(i))!=null;)d.includes(a[0].slice(a[0].lastIndexOf("[")+1,-1))&&(i=i.slice(0,a.index)+"["+_h("a",a[0].length-2)+"]"+i.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(a=this.tokenizer.rules.inline.blockSkip.exec(i))!=null;)i=i.slice(0,a.index)+"["+_h("a",a[0].length-2)+"]"+i.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;(a=this.tokenizer.rules.inline.escapedEmSt.exec(i))!=null;)i=i.slice(0,a.index+a[0].length-2)+"++"+i.slice(this.tokenizer.rules.inline.escapedEmSt.lastIndex),this.tokenizer.rules.inline.escapedEmSt.lastIndex--;for(;t;)if(l||(c=""),l=!1,!(this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some(d=>(r=d.call({lexer:this},t,n))?(t=t.substring(r.raw.length),n.push(r),!0):!1))){if(r=this.tokenizer.escape(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.tag(t)){t=t.substring(r.raw.length),o=n[n.length-1],o&&r.type==="text"&&o.type==="text"?(o.raw+=r.raw,o.text+=r.text):n.push(r);continue}if(r=this.tokenizer.link(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(r.raw.length),o=n[n.length-1],o&&r.type==="text"&&o.type==="text"?(o.raw+=r.raw,o.text+=r.text):n.push(r);continue}if(r=this.tokenizer.emStrong(t,i,c)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.codespan(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.br(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.del(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.autolink(t,Mh)){t=t.substring(r.raw.length),n.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(t,Mh))){t=t.substring(r.raw.length),n.push(r);continue}if(s=t,this.options.extensions&&this.options.extensions.startInline){let d=1/0;const p=t.slice(1);let m;this.options.extensions.startInline.forEach(function(f){m=f.call({lexer:this},p),typeof m=="number"&&m>=0&&(d=Math.min(d,m))}),d<1/0&&d>=0&&(s=t.substring(0,d+1))}if(r=this.tokenizer.inlineText(s,HT)){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 hl{constructor(t){this.options=t||dr}code(t,n,r){const o=(n||"").match(/\S*/)[0];if(this.options.highlight){const s=this.options.highlight(t,o);s!=null&&s!==t&&(r=!0,t=s)}return t=t.replace(/\n$/,"")+`
|
|
107
|
+
`,o?'<pre><code class="'+this.options.langPrefix+Ot(o)+'">'+(r?t:Ot(t,!0))+`</code></pre>
|
|
108
|
+
`:"<pre><code>"+(r?t:Ot(t,!0))+`</code></pre>
|
|
109
109
|
`}blockquote(t){return`<blockquote>
|
|
110
110
|
${t}</blockquote>
|
|
111
111
|
`}html(t){return t}heading(t,n,r,o){if(this.options.headerIds){const s=this.options.headerPrefix+o.slug(r);return`<h${n} id="${s}">${t}</h${n}>
|
|
@@ -123,9 +123,9 @@ ${t}</blockquote>
|
|
|
123
123
|
`}tablerow(t){return`<tr>
|
|
124
124
|
${t}</tr>
|
|
125
125
|
`}tablecell(t,n){const r=n.header?"th":"td";return(n.align?`<${r} align="${n.align}">`:`<${r}>`)+t+`</${r}>
|
|
126
|
-
`}strong(t){return`<strong>${t}</strong>`}em(t){return`<em>${t}</em>`}codespan(t){return`<code>${t}</code>`}br(){return this.options.xhtml?"<br/>":"<br>"}del(t){return`<del>${t}</del>`}link(t,n,r){if(t=Ph(this.options.sanitize,this.options.baseUrl,t),t===null)return r;let o='<a href="'+t+'"';return n&&(o+=' title="'+n+'"'),o+=">"+r+"</a>",o}image(t,n,r){if(t=Ph(this.options.sanitize,this.options.baseUrl,t),t===null)return r;let o=`<img src="${t}" alt="${r}"`;return n&&(o+=` title="${n}"`),o+=this.options.xhtml?"/>":">",o}text(t){return t}}class Oh{strong(t){return t}em(t){return t}codespan(t){return t}del(t){return t}html(t){return t}text(t){return t}link(t,n,r){return""+r}image(t,n,r){return""+r}br(){return""}}class Dh{constructor(){this.seen={}}serialize(t){return t.toLowerCase().trim().replace(/<[!\/a-z].*?>/ig,"").replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g,"").replace(/\s/g,"-")}getNextSafeSlug(t,n){let r=t,o=0;if(this.seen.hasOwnProperty(r)){o=this.seen[t];do o++,r=t+"-"+o;while(this.seen.hasOwnProperty(r))}return n||(this.seen[t]=o,this.seen[r]=0),r}slug(t,n={}){const r=this.serialize(t);return this.getNextSafeSlug(r,n.dryrun)}}class Vn{constructor(t){this.options=t||dr,this.options.renderer=this.options.renderer||new hl,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new Oh,this.slugger=new Dh}static parse(t,n){return new Vn(n).parse(t)}static parseInline(t,n){return new Vn(n).parseInline(t)}parse(t,n=!0){let r="",o,s,i,a,c,
|
|
127
|
-
`+(f.tokens?this.parseInline(f.tokens):f.text);r+=n?this.renderer.paragraph(m):m;continue}default:{const A='Token with "'+f.type+'" type was not found.';if(this.options.silent){console.error(A);return}else throw new Error(A)}}}return r}parseInline(t,n){n=n||this.renderer;let r="",o,s,i;const a=t.length;for(o=0;o<a;o++){if(s=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[s.type]&&(i=this.options.extensions.renderers[s.type].call({parser:this},s),i!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type))){r+=i||"";continue}switch(s.type){case"escape":{r+=n.text(s.text);break}case"html":{r+=n.html(s.text);break}case"link":{r+=n.link(s.href,s.title,this.parseInline(s.tokens,n));break}case"image":{r+=n.image(s.href,s.title,s.text);break}case"strong":{r+=n.strong(this.parseInline(s.tokens,n));break}case"em":{r+=n.em(this.parseInline(s.tokens,n));break}case"codespan":{r+=n.codespan(s.text);break}case"br":{r+=n.br();break}case"del":{r+=n.del(this.parseInline(s.tokens,n));break}case"text":{r+=n.text(s.text);break}default:{const
|
|
128
|
-
Please report this to https://github.com/markedjs/marked.`,e){const o="<p>An error occurred:</p><pre>"+Mt(r.message+"",!0)+"</pre>";if(t)return Promise.resolve(o);if(n){n(null,o);return}return o}if(t)return Promise.reject(r);if(n){n(r);return}throw r}}function Lh(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...xe.defaults,...s};const i=UT(r.silent,r.async,o);if(typeof n>"u"||n===null)return i(new Error("marked(): input parameter is undefined or null"));if(typeof n!="string")return i(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(n)+", string expected"));if(BT(r),r.hooks&&(r.hooks.options=r),o){const a=r.highlight;let c;try{r.hooks&&(n=r.hooks.preprocess(n)),c=e(n,r)}catch(p){return i(p)}const l=function(p){let m;if(!p)try{r.walkTokens&&xe.walkTokens(c,r.walkTokens),m=t(c,r),r.hooks&&(m=r.hooks.postprocess(m))}catch(f){p=f}return r.highlight=a,p?i(p):o(null,m)};if(!a||a.length<3||(delete r.highlight,!c.length))return l();let d=0;xe.walkTokens(c,function(p){p.type==="code"&&(d++,setTimeout(()=>{a(p.text,p.lang,function(m,f){if(m)return l(m);f!=null&&f!==p.text&&(p.text=f,p.escaped=!0),d--,d===0&&l()})},0))}),d===0&&l();return}if(r.async)return Promise.resolve(r.hooks?r.hooks.preprocess(n):n).then(a=>e(a,r)).then(a=>r.walkTokens?Promise.all(xe.walkTokens(a,r.walkTokens)).then(()=>a):a).then(a=>t(a,r)).then(a=>r.hooks?r.hooks.postprocess(a):a).catch(i);try{r.hooks&&(n=r.hooks.preprocess(n));const a=e(n,r);r.walkTokens&&xe.walkTokens(a,r.walkTokens);let c=t(a,r);return r.hooks&&(c=r.hooks.postprocess(c)),c}catch(a){return i(a)}}}function xe(e,t,n){return Lh(Wn.lex,Vn.parse)(e,t,n)}xe.options=xe.setOptions=function(e){return xe.defaults={...xe.defaults,...e},IT(xe.defaults),xe},xe.getDefaults=kh,xe.defaults=dr,xe.use=function(...e){const t=xe.defaults.extensions||{renderers:{},childTokens:{}};e.forEach(n=>{const r={...n};if(r.async=xe.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(o=>{if(!o.name)throw new Error("extension name required");if(o.renderer){const s=t.renderers[o.name];s?t.renderers[o.name]=function(...i){let a=o.renderer.apply(this,i);return a===!1&&(a=s.apply(this,i)),a}:t.renderers[o.name]=o.renderer}if(o.tokenizer){if(!o.level||o.level!=="block"&&o.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");t[o.level]?t[o.level].unshift(o.tokenizer):t[o.level]=[o.tokenizer],o.start&&(o.level==="block"?t.startBlock?t.startBlock.push(o.start):t.startBlock=[o.start]:o.level==="inline"&&(t.startInline?t.startInline.push(o.start):t.startInline=[o.start]))}o.childTokens&&(t.childTokens[o.name]=o.childTokens)}),r.extensions=t),n.renderer){const o=xe.defaults.renderer||new hl;for(const s in n.renderer){const i=o[s];o[s]=(...a)=>{let c=n.renderer[s].apply(o,a);return c===!1&&(c=i.apply(o,a)),c}}r.renderer=o}if(n.tokenizer){const o=xe.defaults.tokenizer||new pl;for(const s in n.tokenizer){const i=o[s];o[s]=(...a)=>{let c=n.tokenizer[s].apply(o,a);return c===!1&&(c=i.apply(o,a)),c}}r.tokenizer=o}if(n.hooks){const o=xe.defaults.hooks||new Qs;for(const s in n.hooks){const i=o[s];Qs.passThroughHooks.has(s)?o[s]=a=>{if(xe.defaults.async)return Promise.resolve(n.hooks[s].call(o,a)).then(l=>i.call(o,l));const c=n.hooks[s].call(o,a);return i.call(o,c)}:o[s]=(...a)=>{let c=n.hooks[s].apply(o,a);return c===!1&&(c=i.apply(o,a)),c}}r.hooks=o}if(n.walkTokens){const o=xe.defaults.walkTokens;r.walkTokens=function(s){let i=[];return i.push(n.walkTokens.call(this,s)),o&&(i=i.concat(o.call(this,s))),i}}xe.setOptions(r)})},xe.walkTokens=function(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(xe,r)),r.type){case"table":{for(const o of r.header)n=n.concat(xe.walkTokens(o.tokens,t));for(const o of r.rows)for(const s of o)n=n.concat(xe.walkTokens(s.tokens,t));break}case"list":{n=n.concat(xe.walkTokens(r.items,t));break}default:xe.defaults.extensions&&xe.defaults.extensions.childTokens&&xe.defaults.extensions.childTokens[r.type]?xe.defaults.extensions.childTokens[r.type].forEach(function(o){n=n.concat(xe.walkTokens(r[o],t))}):r.tokens&&(n=n.concat(xe.walkTokens(r.tokens,t)))}return n},xe.parseInline=Lh(Wn.lexInline,Vn.parseInline),xe.Parser=Vn,xe.parser=Vn.parse,xe.Renderer=hl,xe.TextRenderer=Oh,xe.Lexer=Wn,xe.lexer=Wn.lex,xe.Tokenizer=pl,xe.Slugger=Dh,xe.Hooks=Qs,xe.parse=xe,xe.options,xe.setOptions,xe.use,xe.walkTokens,xe.parseInline,Vn.parse,Wn.lex;function fr({content:e,className:t="",allowHtml:n=!1,style:r}){const o=w.useMemo(()=>{if(!e||typeof e!="string"||e.trim().length===0)return"";try{if(!n){const i=e.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"").replace(/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi,"").replace(/javascript:/gi,"").replace(/on\w+\s*=/gi,"");return typeof xe.parse=="function"?xe.parse(i):xe(i)}return typeof xe.parse=="function"?xe.parse(e):xe(e)}catch(i){return console.error("[MarkdownContent] parse error",i),`<pre class="font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words">Error rendering markdown: ${String(i)}</pre>`}},[e,n]),s=w.useMemo(()=>{const i={color:"currentColor",...r};if(r&&r.color){const a=r.color;return{...i,"--tw-prose-body":a,"--tw-prose-headings":a,"--tw-prose-links":a,"--tw-prose-bold":a,"--tw-prose-counters":a,"--tw-prose-bullets":a,"--tw-prose-hr":a,"--tw-prose-quotes":a,"--tw-prose-quote-borders":a,"--tw-prose-captions":a,"--tw-prose-code":a,"--tw-prose-pre-code":a,"--tw-prose-pre-bg":"inherit","--tw-prose-th-borders":a,"--tw-prose-td-borders":a}}return i},[r]);return u.jsx("div",{className:ne("markdown prose prose-sm max-w-none break-words","dark:prose-invert","text-current","prose-headings:text-current prose-p:text-current prose-li:text-current prose-a:text-current prose-strong:text-current","prose-em:text-current prose-blockquote:text-current prose-table:text-current prose-td:text-current prose-th:text-current","prose-pre:font-mono prose-pre:text-xs prose-pre:bg-background/50 prose-pre:border prose-pre:rounded prose-pre:p-3 prose-pre:whitespace-pre prose-pre:overflow-x-auto","prose-code:font-mono prose-code:text-sm prose-code:bg-background/50 prose-code:px-1.5 prose-code:py-0.5 prose-code:rounded prose-code:text-current",t),style:s,dangerouslySetInnerHTML:{__html:o}})}function $h({preview:e,idx:t}){return u.jsxs("div",{className:"space-y-2",children:[e.label&&u.jsxs("p",{className:"text-[0.65rem] uppercase tracking-wide text-muted-foreground",children:["Artifact: ",e.label]}),u.jsx("div",{className:"overflow-hidden rounded border border-border/60 bg-background/60 p-1 shadow-sm",children:u.jsx("img",{src:e.src,alt:e.alt,title:e.label,loading:"lazy",className:"h-auto max-h-[420px] w-full rounded object-contain",onLoad:()=>{},onError:n=>{console.error(`[MessageComponent] ❌ Image failed to load for artifact ${t}:`,{alt:e.alt,label:e.label,message:n.target.alt})}})})]})}function Fh({artifact:e,idx:t=0}){const n=w.useMemo(()=>e?(Array.isArray(e.plots)?e.plots:[]).map(o=>ju(o)).filter(o=>o!==null):[],[e]);return n.length>0?u.jsx("div",{className:"space-y-2",children:n.map((r,o)=>u.jsx($h,{preview:r,idx:o},`${t}-plot-${o}`))}):e&&typeof e=="object"?u.jsx("div",{className:"rounded-lg border border-gray-200 dark:border-gray-800 bg-gray-50 dark:bg-gray-900/20 p-4",children:u.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:["Unknown artifact type: ",u.jsx("code",{className:"font-mono",children:e.type||"unknown"})]})}):null}const WT="prose prose-sm max-w-none break-words dark:prose-invert prose-headings:break-words prose-p:break-words prose-li:break-words prose-td:break-words prose-th:break-words prose-a:break-all prose-code:break-words prose-blockquote:break-words";function ei({data:e}){return Array.isArray(e)?e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?u.jsx("div",{className:WT,children:u.jsx("ul",{className:"list-disc pl-5",children:e.map((n,r)=>u.jsx("li",{children:String(n)},r))})}):u.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:er(e)}):u.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:er(e)})}function Bh({message:e,isStreaming:t=!1}){const n=e.name??"tool",r=w.useMemo(()=>{const a=e.additionalKwargs??{};return Array.isArray(a.toolProgress)?[...a.toolProgress]:[]},[e]),s=r.some(a=>a.type==="tool.start"||a.type==="tool.call"||a.type==="message.start")?`Running ${n}…`:void 0;return t||r.length>0?u.jsxs("div",{className:"space-y-2",children:[u.jsxs("div",{className:"flex items-center gap-2 text-xs uppercase tracking-wide text-muted-foreground",children:[t&&u.jsx(le.Loader,{className:"h-3 w-3 animate-spin"}),u.jsx("span",{children:s??`Running ${n}…`})]}),r.length>0&&u.jsx("div",{className:"space-y-2 text-xs text-muted-foreground",children:r.map((a,c)=>{var l;return u.jsxs("div",{className:"rounded border border-current/10 bg-muted/60 p-2 text-[11px] leading-snug",children:[u.jsxs("div",{className:"mb-1 flex items-center justify-between text-[8px] uppercase tracking-wide text-muted-foreground",children:[u.jsx("span",{children:((l=a.type)==null?void 0:l.replace(/\./g," "))??"progress"}),u.jsx("span",{children:a.idx??c+1})]}),a.content&&u.jsx("p",{className:"mt-1 text-[12px] text-foreground/90",children:a.content}),u.jsxs("div",{className:"mt-1 flex flex-wrap gap-2 text-[10px] opacity-70",children:[typeof a.factsFound=="number"&&u.jsxs("span",{children:["Facts found: ",a.factsFound]}),typeof a.isSufficient=="boolean"&&u.jsxs("span",{children:["Research ",a.isSufficient?"sufficient":"needs more data"]})]})]},`tool-progress-${n}-${c}`)})})]}):null}const ml=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:ne("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));ml.displayName="Card";const gl=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:ne("flex flex-col space-y-1.5 p-6",e),...t}));gl.displayName="CardHeader";const xl=h.forwardRef(({className:e,...t},n)=>u.jsx("h3",{ref:n,className:ne("text-2xl font-semibold leading-none tracking-tight",e),...t}));xl.displayName="CardTitle";const vl=h.forwardRef(({className:e,...t},n)=>u.jsx("p",{ref:n,className:ne("text-sm text-muted-foreground",e),...t}));vl.displayName="CardDescription";const ti=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:ne("p-6 pt-0",e),...t}));ti.displayName="CardContent";const zh=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:ne("flex items-center p-6 pt-0",e),...t}));zh.displayName="CardFooter";const VT=e=>!!e&&typeof e=="object"&&e.type==="user_choice"&&typeof e.question=="string"&&Array.isArray(e.alternatives);function wl({interruptPart:e,onApprove:t,onReject:n,onSelectAlternative:r,disabled:o,isActive:s,payload:i}){const a=VT(i)?i:null,c=(a==null?void 0:a.question)??e.title??"Approve the result?",l=a?s?"Select one of the alternatives to continue.":"Waiting for approval from another participant.":s?"Please approve or reject this action to resume the workflow.":"Waiting for approval from another participant.";let d=null;if(!a&&i!==void 0&&i!==null)if(typeof i=="string")d=u.jsx("p",{className:"text-sm leading-relaxed text-blue-800/90 dark:text-blue-200/90 whitespace-pre-wrap",children:i});else{const p=er(i);d=u.jsx("pre",{className:"max-h-48 overflow-auto rounded bg-blue-100/60 p-2 text-xs text-blue-900/90 dark:bg-blue-900/40 dark:text-blue-100/80",children:p})}return u.jsxs(ml,{className:ne("border-blue-200 dark:border-blue-800 bg-blue-50/50 dark:bg-blue-950/10 transition-shadow",s?"shadow-md ring-1 ring-blue-300 dark:ring-blue-500/70":"opacity-80"),children:[u.jsxs(gl,{className:"pb-3",children:[u.jsx(xl,{className:"text-blue-900 dark:text-blue-100 text-base",children:c}),u.jsx(vl,{className:"text-blue-700 dark:text-blue-300 text-sm",children:l})]}),a?u.jsx(ti,{className:"pt-0 pb-3",children:u.jsx("div",{className:"space-y-2",children:a.alternatives.map(p=>u.jsx(Ye,{size:"sm",variant:"outline",onClick:()=>r==null?void 0:r(e,p),className:"w-full justify-start text-left",disabled:o||!s,children:u.jsxs("div",{className:"flex flex-col items-start gap-1",children:[u.jsx("span",{className:"font-semibold",children:p.label}),p.description?u.jsx("span",{className:"text-xs text-muted-foreground leading-snug",children:p.description}):null]})},p.id))})}):d&&u.jsx(ti,{className:"pt-0 pb-3",children:d}),!a&&u.jsx(zh,{className:"pt-0",children:u.jsxs("div",{className:"flex gap-2 ml-auto",children:[u.jsx(Ye,{size:"sm",variant:"outline",onClick:()=>n(e),className:"border-red-300 text-red-700 hover:bg-red-50 dark:border-red-700 dark:text-red-300 dark:hover:bg-red-950/50",disabled:o||!s,children:"Reject"}),u.jsx(Ye,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",disabled:o||!s,children:"Approve"})]})})]})}function Hh({className:e}){const t=w.useRef(null);return w.useEffect(()=>{let n=0;const r=()=>{if(n=(n+1)%4,t.current){const s=".".repeat(n);t.current.textContent=`Is thinking${s}`}};r();const o=setInterval(r,500);return()=>clearInterval(o)},[]),u.jsx("span",{ref:t,"aria-live":"polite",className:ne("inline-block text-xs opacity-70 ml-1",e),children:"Is thinking"})}function Uh({text:e,expanded:t,onExpandedChange:n,previewLength:r,isCompact:o}){const s=Math.max(e.length-r,0),i=e.substring(0,r);return u.jsxs("div",{className:"flex flex-col gap-1",children:[u.jsx("div",{className:ne("text-sm text-[hsl(var(--chat-bubble-user-text))]",o&&"text-xs"),children:t?u.jsx(fr,{content:e,allowHtml:!1}):u.jsxs("pre",{className:ne("font-sans whitespace-pre-wrap break-words bg-transparent p-0 m-0 text-[hsl(var(--chat-bubble-user-text))]",o&&"text-xs"),children:[i,"..."]})}),u.jsx(Ye,{type:"button",variant:"ghost",size:"sm",className:"h-6 text-xs !text-[hsl(var(--chat-bubble-user-text))]",onClick:()=>n(!t),children:t?u.jsxs(u.Fragment,{children:[u.jsx(le.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):u.jsxs(u.Fragment,{children:[u.jsx(le.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",s," chars)"]})})]})}function Wh(e){const{allowFileOpen:t,currentThreadId:n}=e,{toast:r}=fl(),[o,s]=w.useState({}),[i,a]=w.useState(null),[c,l]=w.useState(!1),d=w.useCallback(()=>{l(!1),a(null)},[]),p=w.useCallback(f=>{a(f),l(!0)},[]),m=w.useCallback(async(f,v,g)=>{var x,y;if(!t){f.preventDefault();return}if(o[g]){f.preventDefault();return}try{const b=String(v.url??""),C=b.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);if(C){f.preventDefault();const k=C[1],S=v.name||`file_${k}`,T=v.mimeType||"application/octet-stream";p({id:k,name:S,mimeType:T});return}if(b.startsWith("data:")){f.preventDefault(),s(S=>({...S,[g]:!0}));const k=r({title:"Fetching file...",description:"",open:!0});try{const S=await cu(n??void 0);if(!S||!Array.isArray(S))throw new Error("Invalid file list response");const T=S.find(E=>!E||typeof E!="object"||!((E.filename??"")===(v.name??""))?!1:typeof v.size=="number"&&typeof E.size=="number"?E.size===v.size:!0);if(!(T!=null&&T.id))throw new Error(`File "${v.name}" is not yet available on the server`);if(!T.id||!T.filename)throw new Error("Invalid file data received from server");p({id:T.id,name:v.name||T.filename||`file_${T.id}`,mimeType:v.mimeType||T.mime_type||"application/octet-stream"}),(x=k.update)==null||x.call(k,{id:k.id,title:"Success",description:`Opened ${v.name}`,open:!0})}catch(S){console.error("Failed to fetch server file:",S);const T=S instanceof Error?S.message:"Unknown error occurred";(y=k.update)==null||y.call(k,{id:k.id,title:"Failed",description:T}),r({title:"Failed to fetch file",description:T,open:!0})}finally{s(S=>({...S,[g]:!1}))}}}catch(b){console.error("File click error:",b),s(C=>({...C,[g]:!1}))}},[t,o,r,n,p]);return{uploadingFiles:o,handleFileClick:m,fileViewerOpen:c,currentFileInfo:i,closeFileViewer:d}}function Vh(e,t){return w.useMemo(()=>{if(t)return{contentParts:[],textContent:"",toolMeta:{},imageParts:[],fileParts:[],interruptParts:[],toolRaw:"",isToolStreaming:!1};const n=e,r=Array.isArray(n.content)?n.content:[],o=n.additionalKwargs??{};return{contentParts:r,textContent:ku(r),toolMeta:Qo(n),imageParts:r.filter(s=>s.type==="image_url"),fileParts:r.filter(s=>s.type==="file"),interruptParts:r.filter(s=>s.type==="interrupt"),toolRaw:Eu(r),isToolStreaming:!!o.toolStreaming}},[e,t])}const Kh="data:";function KT(e){if(!e)return[];const t=[],n=e.split(/\r?\n/);for(const r of n){const o=r.trim();if(!o||!o.startsWith(Kh))continue;const s=o.slice(Kh.length).trim();if(!s||s.toLowerCase()==="[done]")continue;const i=Qn(s);i&&typeof i=="object"&&t.push(i)}return t}function qT(e){for(let t=e.length-1;t>=0;t-=1){const n=e[t];if(n&&typeof n=="object"&&n.type==="tool.end")return n}return null}function GT(e){return w.useMemo(()=>{const t=e.content.filter(l=>l.type==="text");if(!t.length)return null;let r=t.flatMap(l=>KT(l.text??""));if(!r.length){const l=t.map(p=>p.text??"").join(`
|
|
129
|
-
`),d=Qn(
|
|
130
|
-
dark:bg-background/10 dark:border-border/30 dark:hover:bg-background/20`,children:[g[O]?u.jsx(le.Loader,{className:"h-4 w-4 animate-spin"}):null,u.jsxs("span",{className:"truncate max-w-[180px]",children:[B,g[O]?" (processing)":""]})]},O)}return null},[v,S,C,x,y,g,b,m,k]),z=i.trim().length>0||a.length>0||c.length>0||Y.length>0;if(!t&&c.length>0&&!d)return R();if(!t&&!z&&!d)return null;if(t){if(!n)return null;if(J&&l){const W=l.value,O=!V,D=j??(()=>{}),B=L??(()=>{});return u.jsx(wl,{interruptPart:l,payload:W,onApprove:D,onReject:B,onSelectAlternative:H,disabled:V,isActive:O})}return u.jsx(qh,{message:e,expandable:r,isStreaming:o,toolRenderers:E,toolArtifactRenderers:A},e.id)}if(!f){const W=u.jsx("div",{className:"space-y-2",children:Y.map((O,D)=>m&&QT(O)?U?u.jsx("div",{className:"space-y-2",children:U},`streaming-md-${D}`):null:u.jsx(_,{part:O,i:D},D))});return d?u.jsxs("div",{"aria-busy":"true",role:"status",children:[W,u.jsx(Hh,{className:T})]}):W}return null}function Gh(e){return e?!(jo(e,/```/g)||jo(e,/`/g)||jo(e,/\*\*/g)||jo(e,/__/g)||jo(e,/~~/g)||/[^\\]\[[^\]]*$/.test(e)||/\[[^\]]*\]\([^)]*$/.test(e)):!0}function jo(e,t){const n=e.match(t);return((n==null?void 0:n.length)??0)%2!==0}function ZT(e){if(!e)return 0;for(let t=e.length;t>=0;t-=1)if(Gh(e.slice(0,t)))return t;return 0}function QT(e){return e.type==="text"&&!!e.__streamingMarkdownAggregate}const ek=Kr.cva("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function Yh({className:e,variant:t,...n}){return u.jsx("div",{className:ne(ek({variant:t}),e),...n})}function tk({showTimestamp:e,showAgentName:t,isToolMessage:n,isInterruptMessage:r=!1,iconForeground:o,agentName:s,messageIcon:i,customHeaderClass:a,customActionsClass:c,isCompactLayout:l,showActions:d,isEditing:p,messageRole:m,toolMeta:f,onCopy:v,onEdit:g,onRegenerate:x,showCheckpointControls:y,attemptCount:b,attemptIndex:C,handleOlderAttemptSelect:k,handleNewerAttemptSelect:S,messageCreatedAt:T,copied:E}){return!e&&!t&&!n&&!r?null:u.jsxs("div",{className:ne("flex items-center justify-between mb-2 pb-2 border-b border-current/10",l&&"mb-1 pb-1",o,a),children:[u.jsxs("div",{className:"flex items-center gap-2",children:[i,t&&s&&u.jsx("span",{className:ne("font-medium",l?"text-xs":"text-sm"),children:s}),n&&!r&&u.jsxs(Yh,{variant:"outline",className:ne("text-xs flex items-center gap-1",o,"border border-current/40",l&&"text-xs h-4"),children:[u.jsx("span",{children:f.name??"Tool Output"}),f.toolCallId&&u.jsx("span",{className:"opacity-70",children:f.toolCallId.slice(0,8)})]}),r&&u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:f.name??"Interrupt"})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[y&&b>1&&u.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[u.jsx("button",{type:"button",className:ne("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",C<b-1?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{C>=b-1||k()},"aria-label":"Older attempt (back in time)",disabled:C>=b-1,children:u.jsx(le.ChevronLeft,{className:"h-3 w-3"})}),u.jsx("div",{className:"flex items-center gap-2",children:u.jsxs("span",{className:"whitespace-nowrap",children:[b-C," / ",b]})}),u.jsx("button",{type:"button",className:ne("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",C>0?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{C<=0||S()},"aria-label":"Newer attempt (forward in time)",disabled:C<=0,children:u.jsx(le.ChevronRight,{className:"h-3 w-3"})})]}),e&&T&&u.jsx("time",{className:ne("text-xs opacity-60",o,l&&"text-xs"),dateTime:new Date(T).toISOString(),title:new Date(T).toLocaleString(),children:new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(new Date(T))}),d&&!p&&u.jsxs("div",{className:ne("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",c),children:[u.jsx("div",{className:"relative",children:u.jsx(Ye,{variant:"ghost",size:"sm",onClick:v,className:ne("h-6 w-6 p-0 hover:bg-foreground/10",o,l&&"h-5 w-5"),"aria-label":"Copy message",title:"Copy message",children:u.jsx(le.Copy,{className:ne(E?"text-success":o,l?"h-3 w-3":"h-4 w-4")})})}),m==="user"&&g&&u.jsx(Ye,{variant:"ghost",size:"sm",onClick:g,className:ne("h-6 w-6 p-0 hover:bg-foreground/10",o,l&&"h-5 w-5"),"aria-label":"Edit message",children:u.jsx(le.Edit,{className:ne(o,l?"h-3 w-3":"h-4 w-4")})}),m==="assistant"&&x&&u.jsx(Ye,{variant:"ghost",size:"sm",onClick:x,className:ne("h-6 w-6 p-0 hover:bg-foreground/10",o,l&&"h-5 w-5"),"aria-label":"Regenerate response",children:u.jsx(le.RotateCcw,{className:ne(o,l?"h-3 w-3":"h-4 w-4")})})]})]})]})}const ni=w.memo(function({message:t,messageIndex:n,isStreamingMessage:r=!1,isEditing:o=!1,showActions:s=!0,showTimestamp:i=!0,showAgentName:a=!0,layoutSize:c="desktop",truncateUserMessages:l=!0,userMessagePreviewLength:d=500,showToolMessages:p=!0,toolRenderers:m,toolArtifactRenderers:f,getToolExpandable:v,customStyles:g={},streamingDebounceMs:x=300,renderStreamingMarkdown:y=!1,enableStreamingMarkdownBuffer:b,onEdit:C,onRegenerate:k,onCopy:S,getInterruptOptions:T,attemptCount:E=1,attemptIndex:A=0,onSelectCheckpoint:j,attemptMetas:L=[]}){const[H,V]=w.useState(!1),[J,R]=w.useState(!1),{currentThreadId:G}=yr(),{respondToInterrupt:K}=oo(),[$,P]=w.useState(!1),I=c==="phone"||c==="half-screen",U=t.role,Z=U==="interrupt",M=U==="tool"||Z,_=!(t.role==="default_message")&&t.expandable!==void 0?t.expandable!==!1:!0,z=w.useMemo(()=>!v||t.role!=="tool"?!1:v(t),[v,t.id,t.role]),W=w.useMemo(()=>t.role==="default_message"?t:null,[t]),O=!!W,D=!(r&&U!=="user"),{uploadingFiles:B,handleFileClick:Q,fileViewerOpen:oe,currentFileInfo:ie,closeFileViewer:Ce}=Wh({allowFileOpen:D,currentThreadId:G}),ve=w.useMemo(()=>{switch(U){case"user":return"text-[hsl(var(--chat-bubble-user-text))]";case"assistant":return"text-[hsl(var(--chat-bubble-ai-text))]";case"interrupt":return"text-[hsl(var(--chat-bubble-ai-text))]";case"tool":return"text-secondary-foreground";case"system":return"text-muted-foreground";default:return"text-[hsl(var(--chat-bubble-ai-text))]"}},[U]),Re=Vh(t,W),{contentParts:We,imageParts:De,fileParts:qe,textContent:ze,toolMeta:xt,toolRaw:lt,isToolStreaming:et,interruptParts:Le}=Re,Ve=b??x!==0,$e=w.useMemo(()=>Le.length?Le[0]:null,[Le]),ke=w.useCallback(async()=>{const pe=M?lt:ze;async function ye(Je){if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function"){await navigator.clipboard.writeText(Je);return}if(navigator.clipboard&&typeof navigator.clipboard.write=="function"&&typeof ClipboardItem<"u"){const nt=new Blob([Je],{type:"text/plain"});await navigator.clipboard.write([new ClipboardItem({"text/plain":nt})]);return}throw new Error("Clipboard API not supported in this context.")}try{await ye(pe),V(!0),setTimeout(()=>V(!1),2e3),S==null||S(pe)}catch(Je){console.error("Failed to copy:",Je)}},[M,lt,ze,S]),Ae=w.useCallback(async(pe,ye)=>{if(!$e)return;if(!Hi($e.id)){console.warn("Interrupt part missing id",$e);return}P(!0);try{const nt=T==null?void 0:T(t);await K(pe,ye,nt)}catch(nt){console.error("Failed to respond to interrupt:",nt)}finally{P(!1)}},[$e,K]),ct=w.useCallback(()=>Ae(!0),[Ae]),kt=w.useCallback(()=>Ae(!1),[Ae]),st=w.useCallback((pe,ye)=>{if(!ye)return;const Je={alternativeId:ye.id??ye.label??void 0,alternativeLabel:ye.label};Ae(!0,Je)},[Ae]),Et=w.useCallback(()=>{if(!C||!t.id)return;const pe=(M?lt:ze)??"",ye="type"in t&&t.type==="default_message"?void 0:{checkpointId:t.checkpointId??null,checkpointNs:t.checkpointNs??null};C(t.id,pe,ye)},[C,M,lt,ze,t]),vt=w.useCallback(()=>{k==null||k(n)},[k,n]),dt=w.useCallback(()=>{const ye=ne(I?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",ve);switch(U){case"user":return u.jsx(le.User,{className:ye});case"assistant":return u.jsx(le.Bot,{className:ye});case"tool":return u.jsx(le.Wrench,{className:ye});case"interrupt":return u.jsx(le.Bot,{className:ye});default:return u.jsx(le.Bot,{className:ye})}},[I,ve,U]),St=w.useCallback(()=>{const pe="group relative mb-4 flex w-full";switch(U){case"user":return ne(pe,"justify-end");case"assistant":case"tool":case"system":case"interrupt":return ne(pe,"justify-start");default:return pe}},[U]),wt=w.useCallback(()=>{const pe=ne("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",I&&"px-3 py-2 text-sm");if(O)return ne(pe,"w-full","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40 shadow-sm");switch(U){case"user":return ne(pe,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-user))] text-[hsl(var(--chat-bubble-user-text))]","border border-transparent");case"assistant":return ne(pe,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40");case"tool":case"interrupt":return ne(pe,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return ne(pe,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return ne(pe,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40")}},[I,O,U]),At=(p||Z)&&_,on=u.jsx(JT,{message:t,isToolMessage:M,showToolMessages:At,toolExpandable:z,isToolStreaming:et,contentParts:We,textContent:ze,imageParts:De,fileParts:qe,isStreamingMessage:r,defaultMessage:W,enableStreamingMarkdownBuffer:Ve,renderStreamingMarkdown:y,handleFileClick:Q,uploadingFiles:B,messageRole:U,truncateUserMessages:l,userMessagePreviewLength:d,isUserExpanded:J,setIsUserExpanded:R,isCompactLayout:I,iconForeground:ve,toolRenderers:m,toolArtifactRenderers:f,interruptPart:$e,handleInterruptApprove:ct,handleInterruptReject:kt,handleInterruptAlternative:st,disableInterruptActions:$,isInterruptMessage:Z}),It=w.useMemo(()=>W?"Assistant":Iu(t),[W,t]),Pe=dt(),He=U==="user"&&(E??1)>1&&typeof j=="function",Ct=(L==null?void 0:L.length)??0,ee=Ct>0&&A<Ct-1?L[A+1]:void 0,fe=Ct>0&&A>0?L[A-1]:void 0,tt=w.useCallback(()=>{!ee||!j||j(ee.id,void 0,!!ee.isLatestAttempt)},[ee,j]),ge=w.useCallback(()=>{!fe||!j||j(fe.id,void 0,!!fe.isLatestAttempt)},[fe,j]);return M&&!p?null:O&&W?u.jsx("div",{className:ne(St(),g.container),children:u.jsxs("div",{className:ne(wt(),g.content),children:[u.jsxs("div",{className:"flex items-center gap-2 mb-2 pb-2 border-b border-current/10",children:[u.jsx(le.Bot,{className:ne("h-4 w-4",ve)}),a&&u.jsx("span",{className:"font-medium text-sm",children:"Assistant"})]}),u.jsx(fr,{content:W.content,className:"text-current"})]})}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:ne(St(),g.container),children:u.jsxs("div",{className:ne(wt(),g.content),children:[u.jsx(tk,{showTimestamp:i,showAgentName:a,isToolMessage:M,iconForeground:ve,agentName:It,messageIcon:Pe,customHeaderClass:g.header,customActionsClass:g.actions,isCompactLayout:I,showActions:s,isEditing:o,messageRole:U,isInterruptMessage:Z,toolMeta:xt,onCopy:ke,onEdit:Et,onRegenerate:vt,showCheckpointControls:He,attemptCount:E,attemptIndex:A,handleOlderAttemptSelect:tt,handleNewerAttemptSelect:ge,messageCreatedAt:t.createdAt,copied:H}),u.jsx("div",{className:"relative",children:on}),!(i||a||M)&&s&&!o&&u.jsxs("div",{className:ne("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",g.actions),children:[u.jsx(Ye,{variant:"ghost",size:"sm",onClick:()=>ke(),className:ne("h-6 w-6 p-0 hover:bg-background/50 text-current",I&&"h-5 w-5"),children:u.jsx(le.Copy,{className:ne(H?"text-success":"text-current",I?"h-3 w-3":"h-4 w-4")})}),U==="user"&&C&&u.jsx(Ye,{variant:"ghost",size:"sm",onClick:Et,className:ne("h-6 w-6 p-0 hover:bg-background/50 text-current",I&&"h-5 w-5"),children:u.jsx(le.Edit,{className:ne("text-current",I?"h-3 w-3":"h-4 w-4")})}),U==="assistant"&&k&&u.jsx(Ye,{variant:"ghost",size:"sm",onClick:vt,className:ne("h-6 w-6 p-0 hover:bg-background/50 text-current",I&&"h-5 w-5"),children:u.jsx(le.RotateCcw,{className:ne("text-current",I?"h-3 w-3":"h-4 w-4")})})]})]})}),ie&&u.jsx(Th,{isOpen:oe,onClose:Ce,fileId:ie.id,fileName:ie.name,mimeType:ie.mimeType})]})},(e,t)=>{var c,l,d,p,m,f,v,g;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&Ui(e.message)===Ui(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateUserMessages","userMessagePreviewLength","showToolMessages","toolRenderers","toolArtifactRenderers"].every(x=>e[x]===t[x]),s=((c=e.customStyles)==null?void 0:c.container)===((l=t.customStyles)==null?void 0:l.container)&&((d=e.customStyles)==null?void 0:d.content)===((p=t.customStyles)==null?void 0:p.content)&&((m=e.customStyles)==null?void 0:m.actions)===((f=t.customStyles)==null?void 0:f.actions)&&((v=e.customStyles)==null?void 0:v.header)===((g=t.customStyles)==null?void 0:g.header);if(!o||!s)return!1;const i=Wi(e.message),a=Wi(t.message);return i.length===a.length});ni.displayName="MessageComponent";const Sl=w.forwardRef(({messages:e,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onStartReached:a,onEdit:c,onRegenerate:l,onCancelEdit:d,className:p,style:m,emptyMessage:f,followNewMessages:v=!0,isNavigatingCheckpoint:g=!1,onScrollAway:x,onAtBottom:y,showToolMessages:b=!0,toolRenderers:C,toolArtifactRenderers:k,checkpointIndex:S,activeCheckpointId:T,onSelectCheckpoint:E,createSyntheticThinkingMessage:A=!0,forceSyntheticThinking:j=!1,getMessageCustomStyles:L,getToolExpandable:H,getInterruptOptions:V},J)=>{const R=w.useRef(null),G=w.useRef(null),K=w.useRef(!1),$=w.useRef(!1),P=e,I=w.useMemo(()=>{const B=n&&P.some(oe=>oe.id===n);return A&&(t||j)&&!B&&P.length>0?[...P,{id:"thinking-assistant",role:"assistant",content:[{type:"text",text:""}],createdAt:new Date().toISOString(),__syntheticStreaming:!0}]:P},[P,t,n,A,j]),U=w.useMemo(()=>b?I:I.filter(B=>(B==null?void 0:B.role)!=="tool"),[I,b]),Z=w.useCallback(B=>{x&&x(!B),y&&y(B)},[x,y]),M=w.useMemo(()=>{if(a)return async()=>{if(!K.current){K.current=!0;try{await a()}finally{K.current=!1}}}},[a]),Y=w.useMemo(()=>!v||g?!1:"auto",[v,g]),_=w.useMemo(()=>{if(typeof f!="string")return null;const B=f.trim();return!B||U&&U.length>0?null:{id:"default-message",role:"default_message",content:B,createdAt:new Date().toISOString()}},[f,U]),z=["flex h-full flex-col md:flex-row",p].filter(Boolean).join(" "),W=()=>{if(_){const B=L==null?void 0:L(_);return u.jsx("div",{className:"p-6 h-full overflow-y-auto",children:u.jsx("div",{className:"w-full max-w-full",children:u.jsx(ni,{message:_,messageIndex:0,isStreamingMessage:!1,showActions:!1,showTimestamp:!1,showAgentName:!0,layoutSize:o,onEdit:()=>{},onRegenerate:()=>{},onCancelEdit:()=>{},customStyles:B,getInterruptOptions:V})})})}return u.jsx("div",{className:"flex h-full items-center justify-center py-8 text-center text-muted-foreground",children:f??"No messages yet. Start a conversation!"})},O=U.length,D=O>0;return w.useEffect(()=>{var B,Q;if(O===0){$.current=!1;return}if(!$.current)if($.current=!0,R.current&&U.length>0){const oe=U.length-1;(Q=(B=R.current).scrollToIndex)==null||Q.call(B,{index:oe,align:"end",behavior:"auto"})}else G.current&&(G.current.scrollTop=G.current.scrollHeight)},[O,U.length]),w.useImperativeHandle(J,()=>({scrollToLatest:()=>{var B,Q;if(R.current&&U.length>0){const oe=U.length-1;(Q=(B=R.current).scrollToIndex)==null||Q.call(B,{index:oe,align:"end",behavior:"auto"})}else G.current&&(G.current.scrollTop=G.current.scrollHeight)},scrollToTop:()=>{var B,Q;R.current&&U.length>0?(Q=(B=R.current).scrollToIndex)==null||Q.call(B,{index:0,align:"start",behavior:"auto"}):G.current&&(G.current.scrollTop=0)}}),[U]),u.jsx("div",{className:z,style:m,children:u.jsx("div",{className:"relative flex-1 min-h-0",children:D?u.jsx(YC,{ref:B=>{R.current=B},scrollerRef:B=>{G.current=B instanceof HTMLDivElement?B:null},data:U,followOutput:Y,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,startReached:()=>{M&&M()},atBottomStateChange:Z,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(B,Q)=>bl(Q,B),itemContent:(B,Q)=>u.jsx(yl,{message:Q,index:B,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onEdit:c,onRegenerate:l,onCancelEdit:d,showToolMessages:b,toolRenderers:C,toolArtifactRenderers:k,checkpointIndex:S,activeCheckpointId:T,onSelectCheckpoint:E,getMessageCustomStyles:L,getToolExpandable:H,getInterruptOptions:V})}):W()})})});Sl.displayName="MessageList";const Xh={value:""};function Fr({className:e="",placeholder:t="Type your message...",autoFocus:n=!0,maxHeight:r=void 0,streamingDebounceMs:o=500,streamingThrottleMs:s,followNewMessages:i=!0,enableFileUpload:a=!0,enableExcelUpload:c=!1,enableMessageEditing:l=!0,showToolMessages:d=!0,toolRenderers:p,toolArtifactRenderers:m,payloadExtras:f={},customStyles:v={},messageCustomStyles:g,onMessageSent:x,onExcelUploadSuccess:y,onError:b,defaultMessage:C}){const{api:k}=no(),S=k.baseUrl,{currentThreadId:T}=yr(),{threadId:E,messages:A,isLoading:j,navigateToCheckpoint:L,returnToLatest:H,checkpoint:V,checkpoints:J,interrupt:R,metadata:G,checkpointIndex:K,respondToInterrupt:$}=oo(),{isStreaming:P,error:I,connectionState:U,submit:Z,stop:M}=qi(),Y=E??T??null,_=(V==null?void 0:V.id)??null,z=(V==null?void 0:V.namespace)??null,W=(G==null?void 0:G.assemblingMessageId)??null,O=R,D=O?Hi(O.id):null,B=D!==null?{type:"interrupt",id:D}:null,[Q,oe]=w.useState(!1),[ie,Ce]=w.useState(!1);w.useEffect(()=>{O||oe(!1)},[O]);const ve=w.useCallback(()=>{oe(!0)},[]),Re=w.useCallback(()=>{oe(!1)},[]),We=w.useCallback(N=>{},[]),De=w.useCallback(async(N,X,re)=>{try{ve(),await $(N,X,re)}catch(de){console.error("Failed to respond to interrupt:",de)}finally{Re()}},[Re,ve,$]),qe=w.useCallback(()=>De(!0),[De]),ze=w.useCallback(()=>De(!1),[De]),xt=w.useCallback((N,X)=>De(!0,X),[De]),lt=!!O||Q,[et,Le]=w.useState(null),[Ve,$e]=w.useState(""),[ke,Ae]=w.useState(null),[ct,kt]=w.useState(null),[st,Et]=w.useState(!1),[vt,dt]=w.useState(null),St=w.useRef(!1),[wt,At]=w.useState(()=>Xh.value),on=w.useRef(wt),It=w.useRef(null),Pe=w.useCallback(N=>{Xh.value=N,At(N)},[]),[He,Ct]=w.useState(!1),ee=w.useRef(null),fe=w.useCallback(N=>{Pe(N)},[Pe]);w.useEffect(()=>{P||Ce(!1)},[P]),w.useEffect(()=>{G!=null&&G.assemblingMessageId&&Ce(!1)},[G==null?void 0:G.assemblingMessageId]);const[tt,ge]=w.useState("desktop");w.useEffect(()=>{const N=()=>{const X=window.innerWidth;ge(X<640?"phone":X<1024?"tablet":"desktop")};return N(),window.addEventListener("resize",N),()=>window.removeEventListener("resize",N)},[]),w.useEffect(()=>{St.current=!1},[Y]),w.useEffect(()=>{on.current=wt},[wt]),w.useEffect(()=>{if(!et){It.current=null;return}It.current===null&&(It.current=on.current),Pe(Ve??"")},[Ve,et,Pe]),w.useEffect(()=>{if(C!==void 0){dt(C);return}(async()=>{if(!S){dt(null);return}try{const re=(await k.getAgent("default")).uiDefaultMessage||"";dt(re||null)}catch(X){console.warn("Failed to fetch default message:",X),dt(null)}})()},[k,S,C]),w.useEffect(()=>{I&&!st&&(b==null||b(I))},[I,st,b]);const pe=async(N,X)=>{const re=N.trim();if(!(!re&&X.length===0))try{const de=et?(ke==null?void 0:ke.checkpointId)??_??void 0:_??void 0,Me=et?(ke==null?void 0:ke.checkpointNs)??z??void 0:z??void 0;await Z({text:re||"",attachments:X,payload:f},{checkpointId:de,checkpointNs:Me,edit:!!et,originalMessageId:et??void 0}),x==null||x(re),Ce(!0),Pe(""),kt(null),Le(null),$e(""),Ae(null)}catch(de){const Me=(de==null?void 0:de.message)||"Failed to send message";kt(Me),b==null||b(Me),Ce(!1)}},ye=w.useCallback(async N=>{await Z({attachments:[N],payload:f},{checkpointId:_??void 0,checkpointNs:z??void 0}),y==null||y({file:N})},[_,z,f,y,Z]),Je=w.useCallback((N,X,re)=>{l&&(It.current=wt,Le(N),$e(X),Pe(X),kt(null),Ae({checkpointId:(re==null?void 0:re.checkpointId)??null,checkpointNs:(re==null?void 0:re.checkpointNs)??null}))},[wt,l,Pe]),nt=w.useCallback(()=>{Le(null),$e(""),Ae(null),kt(null),Pe(It.current??wt),It.current=null},[wt,Pe]),Nt=w.useCallback((N,X,re)=>{Je(N,X,re)},[Je]),$t=w.useCallback(N=>{let X=null;for(let Oe=N-1;Oe>=0;Oe--)if(A[Oe].role==="user"){X=A[Oe];break}if(!X)return;const re=Array.isArray(X.content)?X.content:[],Me=re.filter(Oe=>(Oe==null?void 0:Oe.type)==="text").map(Oe=>Oe.text).join("")||(()=>{try{return JSON.stringify(re,null,2)}catch{return String(re)}})();Me&&Z({text:Me,payload:f},{checkpointId:_??void 0,checkpointNs:z??void 0,edit:!0,originalMessageId:X.id})},[A,Z,_,z,f]),Ee=w.useCallback(async N=>{if(T){Ct(!0);try{if(!N){await H(),requestAnimationFrame(()=>{var de;(de=ee.current)==null||de.scrollToLatest()});return}const X=J.find(de=>de.checkpointId===N),re=(X==null?void 0:X.checkpointNs)??null;await L(N,re),requestAnimationFrame(()=>{var de;(de=ee.current)==null||de.scrollToTop()})}finally{Ct(!1)}}},[J,T,ee,L,H]),ut=w.useCallback(async(N,X,re)=>{await Ee(re?null:N)},[Ee]),Ge=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${v.container||""}`,at=`flex-1 min-h-0 min-w-0 max-h-full w-full overflow-hidden overscroll-contain break-words break-anywhere p-4 ${O?"pb-32":""} bg-transparent ${v.messagesArea||""}`,sn=`relative flex-shrink-0 w-full border-t p-4 bg-transparent ${v.inputArea||""}`;return u.jsxs("div",{className:Ge,children:[!!I&&!st&&u.jsxs("div",{className:"flex-shrink-0 bg-red-50 border border-red-200 text-red-800 px-4 py-2 text-sm flex items-center justify-between",children:[u.jsx("span",{children:I}),u.jsx(Ye,{variant:"ghost",size:"sm",onClick:()=>Et(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:u.jsx(le.X,{size:16})})]}),u.jsxs("div",{className:`relative ${at}`,style:r?{maxHeight:r}:void 0,children:[u.jsx(Sl,{ref:ee,className:"h-full",style:{height:"100%"},messages:A,isStreaming:P,streamingAssistantId:W,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:tt,enableMessageEditing:l,editingMessageId:et,onEdit:Nt,onRegenerate:$t,onCancelEdit:nt,emptyMessage:vt??void 0,isNavigatingCheckpoint:He,showToolMessages:d,toolRenderers:p,toolArtifactRenderers:m,checkpointIndex:K,activeCheckpointId:_,onSelectCheckpoint:ut,createSyntheticThinkingMessage:!0,forceSyntheticThinking:ie,getMessageCustomStyles:g,getInterruptOptions:We}),(U==="reconnecting"||U==="connecting")&&u.jsx("div",{className:"pointer-events-none absolute top-3 right-3 z-20 rounded-full bg-muted/80 px-3 py-1 text-xs font-medium text-foreground shadow-sm backdrop-blur-sm dark:bg-muted/60",children:u.jsxs("span",{className:"flex items-center gap-2",children:[u.jsx(le.Loader2,{className:"h-3 w-3 animate-spin"}),U==="reconnecting"?"Reconnecting…":"Connecting…"]})}),U==="error"&&u.jsx("div",{className:"pointer-events-none absolute top-3 right-3 z-20 rounded-full bg-destructive/10 px-3 py-1 text-xs font-semibold text-destructive shadow-sm",children:"Connection lost"}),j&&u.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 bg-background/80 backdrop-blur-sm text-muted-foreground",children:[u.jsx(le.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading messages…"})]}),He&&u.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 bg-background/80 backdrop-blur-sm text-muted-foreground",children:[u.jsx(le.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading checkpoint…"})]}),O&&B&&u.jsx("div",{className:"pointer-events-auto absolute inset-x-0 bottom-6 z-30 flex justify-center px-4",children:u.jsx("div",{className:"w-full max-w-3xl",children:u.jsx(wl,{interruptPart:B,onApprove:qe,onReject:ze,onSelectAlternative:xt,disabled:Q,isActive:!0,payload:O.value})})})]}),u.jsxs("div",{className:sn,children:[et&&u.jsx("div",{className:"mb-3 p-3 bg-blue-50 border border-blue-200 rounded-lg",children:u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(le.Edit3,{size:16,className:"text-blue-600"}),u.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),u.jsx(Ye,{variant:"ghost",size:"sm",onClick:nt,className:"text-blue-600 hover:bg-blue-100",children:u.jsx(le.X,{size:16})})]})}),ct&&u.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:ct}),u.jsx(FS,{composerValue:wt,onComposerChange:fe,onSend:pe,onCancelEdit:nt,onStop:M,editingMessageId:et,editingInitialValue:Ve,placeholder:et?"Edit your message...":t,isStreaming:P,disabled:lt,enableFileUpload:a,enableExcelUpload:c,onExcelUpload:ye,onError:b,customStyles:v,textareaClassName:v.textarea||"",allowEmptySend:!1,inputError:ct})]})]})}var Jh=1,nk=.9,rk=.8,ok=.17,Cl=.1,Tl=.999,sk=.9999,ik=.99,ak=/[\\\/_+.#"@\[\(\{&]/,lk=/[\\\/_+.#"@\[\(\{&]/g,ck=/[\s-]/,Zh=/[\s-]/g;function kl(e,t,n,r,o,s,i){if(s===t.length)return o===e.length?Jh:ik;var a=`${o},${s}`;if(i[a]!==void 0)return i[a];for(var c=r.charAt(s),l=n.indexOf(c,o),d=0,p,m,f,v;l>=0;)p=kl(e,t,n,r,l+1,s+1,i),p>d&&(l===o?p*=Jh:ak.test(e.charAt(l-1))?(p*=rk,f=e.slice(o,l-1).match(lk),f&&o>0&&(p*=Math.pow(Tl,f.length))):ck.test(e.charAt(l-1))?(p*=nk,v=e.slice(o,l-1).match(Zh),v&&o>0&&(p*=Math.pow(Tl,v.length))):(p*=ok,o>0&&(p*=Math.pow(Tl,l-o))),e.charAt(l)!==t.charAt(s)&&(p*=sk)),(p<Cl&&n.charAt(l-1)===r.charAt(s+1)||r.charAt(s+1)===r.charAt(s)&&n.charAt(l-1)!==r.charAt(s))&&(m=kl(e,t,n,r,l+1,s+2,i),m*Cl>p&&(p=m*Cl)),p>d&&(d=p),l=n.indexOf(c,l+1);return i[a]=d,d}function Qh(e){return e.toLowerCase().replace(Zh," ")}function uk(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,kl(e,t,Qh(e),Qh(t),0,0,{})}var _o='[cmdk-group=""]',El='[cmdk-group-items=""]',dk='[cmdk-group-heading=""]',em='[cmdk-item=""]',tm=`${em}:not([aria-disabled="true"])`,Il="cmdk-item-select",Br="data-value",fk=(e,t,n)=>uk(e,t,n),nm=h.createContext(void 0),Ro=()=>h.useContext(nm),rm=h.createContext(void 0),Nl=()=>h.useContext(rm),om=h.createContext(void 0),sm=h.forwardRef((e,t)=>{let n=zr(()=>{var M,Y;return{search:"",value:(Y=(M=e.value)!=null?M:e.defaultValue)!=null?Y:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=zr(()=>new Set),o=zr(()=>new Map),s=zr(()=>new Map),i=zr(()=>new Set),a=im(e),{label:c,children:l,value:d,onValueChange:p,filter:m,shouldFilter:f,loop:v,disablePointerSelection:g=!1,vimBindings:x=!0,...y}=e,b=jt(),C=jt(),k=jt(),S=h.useRef(null),T=Ck();pr(()=>{if(d!==void 0){let M=d.trim();n.current.value=M,E.emit()}},[d]),pr(()=>{T(6,J)},[]);let E=h.useMemo(()=>({subscribe:M=>(i.current.add(M),()=>i.current.delete(M)),snapshot:()=>n.current,setState:(M,Y,_)=>{var z,W,O,D;if(!Object.is(n.current[M],Y)){if(n.current[M]=Y,M==="search")V(),L(),T(1,H);else if(M==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let B=document.getElementById(k);B?B.focus():(z=document.getElementById(b))==null||z.focus()}if(T(7,()=>{var B;n.current.selectedItemId=(B=R())==null?void 0:B.id,E.emit()}),_||T(5,J),((W=a.current)==null?void 0:W.value)!==void 0){let B=Y??"";(D=(O=a.current).onValueChange)==null||D.call(O,B);return}}E.emit()}},emit:()=>{i.current.forEach(M=>M())}}),[]),A=h.useMemo(()=>({value:(M,Y,_)=>{var z;Y!==((z=s.current.get(M))==null?void 0:z.value)&&(s.current.set(M,{value:Y,keywords:_}),n.current.filtered.items.set(M,j(Y,_)),T(2,()=>{L(),E.emit()}))},item:(M,Y)=>(r.current.add(M),Y&&(o.current.has(Y)?o.current.get(Y).add(M):o.current.set(Y,new Set([M]))),T(3,()=>{V(),L(),n.current.value||H(),E.emit()}),()=>{s.current.delete(M),r.current.delete(M),n.current.filtered.items.delete(M);let _=R();T(4,()=>{V(),(_==null?void 0:_.getAttribute("id"))===M&&H(),E.emit()})}),group:M=>(o.current.has(M)||o.current.set(M,new Set),()=>{s.current.delete(M),o.current.delete(M)}),filter:()=>a.current.shouldFilter,label:c||e["aria-label"],getDisablePointerSelection:()=>a.current.disablePointerSelection,listId:b,inputId:k,labelId:C,listInnerRef:S}),[]);function j(M,Y){var _,z;let W=(z=(_=a.current)==null?void 0:_.filter)!=null?z:fk;return M?W(M,n.current.search,Y):0}function L(){if(!n.current.search||a.current.shouldFilter===!1)return;let M=n.current.filtered.items,Y=[];n.current.filtered.groups.forEach(z=>{let W=o.current.get(z),O=0;W.forEach(D=>{let B=M.get(D);O=Math.max(B,O)}),Y.push([z,O])});let _=S.current;G().sort((z,W)=>{var O,D;let B=z.getAttribute("id"),Q=W.getAttribute("id");return((O=M.get(Q))!=null?O:0)-((D=M.get(B))!=null?D:0)}).forEach(z=>{let W=z.closest(El);W?W.appendChild(z.parentElement===W?z:z.closest(`${El} > *`)):_.appendChild(z.parentElement===_?z:z.closest(`${El} > *`))}),Y.sort((z,W)=>W[1]-z[1]).forEach(z=>{var W;let O=(W=S.current)==null?void 0:W.querySelector(`${_o}[${Br}="${encodeURIComponent(z[0])}"]`);O==null||O.parentElement.appendChild(O)})}function H(){let M=G().find(_=>_.getAttribute("aria-disabled")!=="true"),Y=M==null?void 0:M.getAttribute(Br);E.setState("value",Y||void 0)}function V(){var M,Y,_,z;if(!n.current.search||a.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let W=0;for(let O of r.current){let D=(Y=(M=s.current.get(O))==null?void 0:M.value)!=null?Y:"",B=(z=(_=s.current.get(O))==null?void 0:_.keywords)!=null?z:[],Q=j(D,B);n.current.filtered.items.set(O,Q),Q>0&&W++}for(let[O,D]of o.current)for(let B of D)if(n.current.filtered.items.get(B)>0){n.current.filtered.groups.add(O);break}n.current.filtered.count=W}function J(){var M,Y,_;let z=R();z&&(((M=z.parentElement)==null?void 0:M.firstChild)===z&&((_=(Y=z.closest(_o))==null?void 0:Y.querySelector(dk))==null||_.scrollIntoView({block:"nearest"})),z.scrollIntoView({block:"nearest"}))}function R(){var M;return(M=S.current)==null?void 0:M.querySelector(`${em}[aria-selected="true"]`)}function G(){var M;return Array.from(((M=S.current)==null?void 0:M.querySelectorAll(tm))||[])}function K(M){let Y=G()[M];Y&&E.setState("value",Y.getAttribute(Br))}function $(M){var Y;let _=R(),z=G(),W=z.findIndex(D=>D===_),O=z[W+M];(Y=a.current)!=null&&Y.loop&&(O=W+M<0?z[z.length-1]:W+M===z.length?z[0]:z[W+M]),O&&E.setState("value",O.getAttribute(Br))}function P(M){let Y=R(),_=Y==null?void 0:Y.closest(_o),z;for(;_&&!z;)_=M>0?yk(_,_o):Sk(_,_o),z=_==null?void 0:_.querySelector(tm);z?E.setState("value",z.getAttribute(Br)):$(M)}let I=()=>K(G().length-1),U=M=>{M.preventDefault(),M.metaKey?I():M.altKey?P(1):$(1)},Z=M=>{M.preventDefault(),M.metaKey?K(0):M.altKey?P(-1):$(-1)};return h.createElement(he.div,{ref:t,tabIndex:-1,...y,"cmdk-root":"",onKeyDown:M=>{var Y;(Y=y.onKeyDown)==null||Y.call(y,M);let _=M.nativeEvent.isComposing||M.keyCode===229;if(!(M.defaultPrevented||_))switch(M.key){case"n":case"j":{x&&M.ctrlKey&&U(M);break}case"ArrowDown":{U(M);break}case"p":case"k":{x&&M.ctrlKey&&Z(M);break}case"ArrowUp":{Z(M);break}case"Home":{M.preventDefault(),K(0);break}case"End":{M.preventDefault(),I();break}case"Enter":{M.preventDefault();let z=R();if(z){let W=new Event(Il);z.dispatchEvent(W)}}}}},h.createElement("label",{"cmdk-label":"",htmlFor:A.inputId,id:A.labelId,style:kk},c),ri(e,M=>h.createElement(rm.Provider,{value:E},h.createElement(nm.Provider,{value:A},M))))}),pk=h.forwardRef((e,t)=>{var n,r;let o=jt(),s=h.useRef(null),i=h.useContext(om),a=Ro(),c=im(e),l=(r=(n=c.current)==null?void 0:n.forceMount)!=null?r:i==null?void 0:i.forceMount;pr(()=>{if(!l)return a.item(o,i==null?void 0:i.id)},[l]);let d=am(o,s,[e.value,e.children,s],e.keywords),p=Nl(),m=Kn(T=>T.value&&T.value===d.current),f=Kn(T=>l||a.filter()===!1?!0:T.search?T.filtered.items.get(o)>0:!0);h.useEffect(()=>{let T=s.current;if(!(!T||e.disabled))return T.addEventListener(Il,v),()=>T.removeEventListener(Il,v)},[f,e.onSelect,e.disabled]);function v(){var T,E;g(),(E=(T=c.current).onSelect)==null||E.call(T,d.current)}function g(){p.setState("value",d.current,!0)}if(!f)return null;let{disabled:x,value:y,onSelect:b,forceMount:C,keywords:k,...S}=e;return h.createElement(he.div,{ref:Mn(s,t),...S,id:o,"cmdk-item":"",role:"option","aria-disabled":!!x,"aria-selected":!!m,"data-disabled":!!x,"data-selected":!!m,onPointerMove:x||a.getDisablePointerSelection()?void 0:g,onClick:x?void 0:v},e.children)}),hk=h.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:o,...s}=e,i=jt(),a=h.useRef(null),c=h.useRef(null),l=jt(),d=Ro(),p=Kn(f=>o||d.filter()===!1?!0:f.search?f.filtered.groups.has(i):!0);pr(()=>d.group(i),[]),am(i,a,[e.value,e.heading,c]);let m=h.useMemo(()=>({id:i,forceMount:o}),[o]);return h.createElement(he.div,{ref:Mn(a,t),...s,"cmdk-group":"",role:"presentation",hidden:p?void 0:!0},n&&h.createElement("div",{ref:c,"cmdk-group-heading":"","aria-hidden":!0,id:l},n),ri(e,f=>h.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?l:void 0},h.createElement(om.Provider,{value:m},f))))}),mk=h.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,o=h.useRef(null),s=Kn(i=>!i.search);return!n&&!s?null:h.createElement(he.div,{ref:Mn(o,t),...r,"cmdk-separator":"",role:"separator"})}),gk=h.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,o=e.value!=null,s=Nl(),i=Kn(l=>l.search),a=Kn(l=>l.selectedItemId),c=Ro();return h.useEffect(()=>{e.value!=null&&s.setState("search",e.value)},[e.value]),h.createElement(he.input,{ref:t,...r,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":c.listId,"aria-labelledby":c.labelId,"aria-activedescendant":a,id:c.inputId,type:"text",value:o?e.value:i,onChange:l=>{o||s.setState("search",l.target.value),n==null||n(l.target.value)}})}),xk=h.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...o}=e,s=h.useRef(null),i=h.useRef(null),a=Kn(l=>l.selectedItemId),c=Ro();return h.useEffect(()=>{if(i.current&&s.current){let l=i.current,d=s.current,p,m=new ResizeObserver(()=>{p=requestAnimationFrame(()=>{let f=l.offsetHeight;d.style.setProperty("--cmdk-list-height",f.toFixed(1)+"px")})});return m.observe(l),()=>{cancelAnimationFrame(p),m.unobserve(l)}}},[]),h.createElement(he.div,{ref:Mn(s,t),...o,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":a,"aria-label":r,id:c.listId},ri(e,l=>h.createElement("div",{ref:Mn(i,c.listInnerRef),"cmdk-list-sizer":""},l)))}),vk=h.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:o,contentClassName:s,container:i,...a}=e;return h.createElement(al,{open:n,onOpenChange:r},h.createElement(ll,{container:i},h.createElement(No,{"cmdk-overlay":"",className:o}),h.createElement(Ao,{"aria-label":e.label,"cmdk-dialog":"",className:s},h.createElement(sm,{ref:t,...a}))))}),wk=h.forwardRef((e,t)=>Kn(n=>n.filtered.count===0)?h.createElement(he.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),bk=h.forwardRef((e,t)=>{let{progress:n,children:r,label:o="Loading...",...s}=e;return h.createElement(he.div,{ref:t,...s,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":o},ri(e,i=>h.createElement("div",{"aria-hidden":!0},i)))}),Wt=Object.assign(sm,{List:xk,Item:pk,Input:gk,Group:hk,Separator:mk,Dialog:vk,Empty:wk,Loading:bk});function yk(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function Sk(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function im(e){let t=h.useRef(e);return pr(()=>{t.current=e}),t}var pr=typeof window>"u"?h.useEffect:h.useLayoutEffect;function zr(e){let t=h.useRef();return t.current===void 0&&(t.current=e()),t}function Kn(e){let t=Nl(),n=()=>e(t.snapshot());return h.useSyncExternalStore(t.subscribe,n,n)}function am(e,t,n,r=[]){let o=h.useRef(),s=Ro();return pr(()=>{var i;let a=(()=>{var l;for(let d of n){if(typeof d=="string")return d.trim();if(typeof d=="object"&&"current"in d)return d.current?(l=d.current.textContent)==null?void 0:l.trim():o.current}})(),c=r.map(l=>l.trim());s.value(e,a,c),(i=t.current)==null||i.setAttribute(Br,a),o.current=a}),o}var Ck=()=>{let[e,t]=h.useState(),n=zr(()=>new Map);return pr(()=>{n.current.forEach(r=>r()),n.current=new Map},[e]),(r,o)=>{n.current.set(r,o),t({})}};function Tk(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function ri({asChild:e,children:t},n){return e&&h.isValidElement(t)?h.cloneElement(Tk(t),{ref:t.ref},n(t.props.children)):n(t)}var kk={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const Al=h.forwardRef(({className:e,...t},n)=>u.jsx(Wt,{ref:n,className:ne("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));Al.displayName=Wt.displayName;const Pl=h.forwardRef(({className:e,...t},n)=>u.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[u.jsx(le.Search,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),u.jsx(Wt.Input,{ref:n,className:ne("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),...t})]}));Pl.displayName=Wt.Input.displayName;const jl=h.forwardRef(({className:e,...t},n)=>u.jsx(Wt.List,{ref:n,className:ne("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));jl.displayName=Wt.List.displayName;const _l=h.forwardRef((e,t)=>u.jsx(Wt.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));_l.displayName=Wt.Empty.displayName;const Rl=h.forwardRef(({className:e,...t},n)=>u.jsx(Wt.Group,{ref:n,className:ne("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",e),...t}));Rl.displayName=Wt.Group.displayName;const Ek=h.forwardRef(({className:e,...t},n)=>u.jsx(Wt.Separator,{ref:n,className:ne("-mx-1 h-px bg-border",e),...t}));Ek.displayName=Wt.Separator.displayName;const Ml=h.forwardRef(({className:e,...t},n)=>u.jsx(Wt.Item,{ref:n,className:ne("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected='true']:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50",e),...t}));Ml.displayName=Wt.Item.displayName;function Ol(e,[t,n]){return Math.min(n,Math.max(t,e))}function Ik(e,t){return h.useReducer((n,r)=>t[n][r]??n,e)}var Dl="ScrollArea",[lm,WN]=cn(Dl),[Nk,rn]=lm(Dl),cm=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,c]=h.useState(null),[l,d]=h.useState(null),[p,m]=h.useState(null),[f,v]=h.useState(null),[g,x]=h.useState(null),[y,b]=h.useState(0),[C,k]=h.useState(0),[S,T]=h.useState(!1),[E,A]=h.useState(!1),j=je(t,H=>c(H)),L=ts(o);return u.jsx(Nk,{scope:n,type:r,dir:L,scrollHideDelay:s,scrollArea:a,viewport:l,onViewportChange:d,content:p,onContentChange:m,scrollbarX:f,onScrollbarXChange:v,scrollbarXEnabled:S,onScrollbarXEnabledChange:T,scrollbarY:g,onScrollbarYChange:x,scrollbarYEnabled:E,onScrollbarYEnabledChange:A,onCornerWidthChange:b,onCornerHeightChange:k,children:u.jsx(he.div,{dir:L,...i,ref:j,style:{position:"relative","--radix-scroll-area-corner-width":y+"px","--radix-scroll-area-corner-height":C+"px",...e.style}})})});cm.displayName=Dl;var um="ScrollAreaViewport",dm=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=rn(um,n),a=h.useRef(null),c=je(t,a,i.onViewportChange);return u.jsxs(u.Fragment,{children:[u.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:o}),u.jsx(he.div,{"data-radix-scroll-area-viewport":"",...s,ref:c,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:u.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});dm.displayName=um;var In="ScrollAreaScrollbar",Ll=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=rn(In,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:i}=o,a=e.orientation==="horizontal";return h.useEffect(()=>(a?s(!0):i(!0),()=>{a?s(!1):i(!1)}),[a,s,i]),o.type==="hover"?u.jsx(Ak,{...r,ref:t,forceMount:n}):o.type==="scroll"?u.jsx(Pk,{...r,ref:t,forceMount:n}):o.type==="auto"?u.jsx(fm,{...r,ref:t,forceMount:n}):o.type==="always"?u.jsx($l,{...r,ref:t}):null});Ll.displayName=In;var Ak=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=rn(In,e.__scopeScrollArea),[s,i]=h.useState(!1);return h.useEffect(()=>{const a=o.scrollArea;let c=0;if(a){const l=()=>{window.clearTimeout(c),i(!0)},d=()=>{c=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",l),a.addEventListener("pointerleave",d),()=>{window.clearTimeout(c),a.removeEventListener("pointerenter",l),a.removeEventListener("pointerleave",d)}}},[o.scrollArea,o.scrollHideDelay]),u.jsx(Ht,{present:n||s,children:u.jsx(fm,{"data-state":s?"visible":"hidden",...r,ref:t})})}),Pk=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=rn(In,e.__scopeScrollArea),s=e.orientation==="horizontal",i=ai(()=>c("SCROLL_END"),100),[a,c]=Ik("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return h.useEffect(()=>{if(a==="idle"){const l=window.setTimeout(()=>c("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(l)}},[a,o.scrollHideDelay,c]),h.useEffect(()=>{const l=o.viewport,d=s?"scrollLeft":"scrollTop";if(l){let p=l[d];const m=()=>{const f=l[d];p!==f&&(c("SCROLL"),i()),p=f};return l.addEventListener("scroll",m),()=>l.removeEventListener("scroll",m)}},[o.viewport,s,c,i]),u.jsx(Ht,{present:n||a!=="hidden",children:u.jsx($l,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:ae(e.onPointerEnter,()=>c("POINTER_ENTER")),onPointerLeave:ae(e.onPointerLeave,()=>c("POINTER_LEAVE"))})})}),fm=h.forwardRef((e,t)=>{const n=rn(In,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=h.useState(!1),a=e.orientation==="horizontal",c=ai(()=>{if(n.viewport){const l=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?l:d)}},10);return Hr(n.viewport,c),Hr(n.content,c),u.jsx(Ht,{present:r||s,children:u.jsx($l,{"data-state":s?"visible":"hidden",...o,ref:t})})}),$l=h.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=rn(In,e.__scopeScrollArea),s=h.useRef(null),i=h.useRef(0),[a,c]=h.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),l=xm(a.viewport,a.content),d={...r,sizes:a,onSizesChange:c,hasThumb:l>0&&l<1,onThumbChange:m=>s.current=m,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:m=>i.current=m};function p(m,f){return Dk(m,i.current,a,f)}return n==="horizontal"?u.jsx(jk,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollLeft,f=vm(m,a,o.dir);s.current.style.transform=`translate3d(${f}px, 0, 0)`}},onWheelScroll:m=>{o.viewport&&(o.viewport.scrollLeft=m)},onDragScroll:m=>{o.viewport&&(o.viewport.scrollLeft=p(m,o.dir))}}):n==="vertical"?u.jsx(_k,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollTop,f=vm(m,a);s.current.style.transform=`translate3d(0, ${f}px, 0)`}},onWheelScroll:m=>{o.viewport&&(o.viewport.scrollTop=m)},onDragScroll:m=>{o.viewport&&(o.viewport.scrollTop=p(m))}}):null}),jk=h.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=rn(In,e.__scopeScrollArea),[i,a]=h.useState(),c=h.useRef(null),l=je(t,c,s.onScrollbarXChange);return h.useEffect(()=>{c.current&&a(getComputedStyle(c.current))},[c]),u.jsx(hm,{"data-orientation":"horizontal",...o,ref:l,sizes:n,style:{bottom:0,left:s.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:s.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":ii(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.x),onDragScroll:d=>e.onDragScroll(d.x),onWheelScroll:(d,p)=>{if(s.viewport){const m=s.viewport.scrollLeft+d.deltaX;e.onWheelScroll(m),bm(m,p)&&d.preventDefault()}},onResize:()=>{c.current&&s.viewport&&i&&r({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:si(i.paddingLeft),paddingEnd:si(i.paddingRight)}})}})}),_k=h.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=rn(In,e.__scopeScrollArea),[i,a]=h.useState(),c=h.useRef(null),l=je(t,c,s.onScrollbarYChange);return h.useEffect(()=>{c.current&&a(getComputedStyle(c.current))},[c]),u.jsx(hm,{"data-orientation":"vertical",...o,ref:l,sizes:n,style:{top:0,right:s.dir==="ltr"?0:void 0,left:s.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":ii(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.y),onDragScroll:d=>e.onDragScroll(d.y),onWheelScroll:(d,p)=>{if(s.viewport){const m=s.viewport.scrollTop+d.deltaY;e.onWheelScroll(m),bm(m,p)&&d.preventDefault()}},onResize:()=>{c.current&&s.viewport&&i&&r({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:si(i.paddingTop),paddingEnd:si(i.paddingBottom)}})}})}),[Rk,pm]=lm(In),hm=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:c,onDragScroll:l,onWheelScroll:d,onResize:p,...m}=e,f=rn(In,n),[v,g]=h.useState(null),x=je(t,j=>g(j)),y=h.useRef(null),b=h.useRef(""),C=f.viewport,k=r.content-r.viewport,S=pt(d),T=pt(c),E=ai(p,10);function A(j){if(y.current){const L=j.clientX-y.current.left,H=j.clientY-y.current.top;l({x:L,y:H})}}return h.useEffect(()=>{const j=L=>{const H=L.target;(v==null?void 0:v.contains(H))&&S(L,k)};return document.addEventListener("wheel",j,{passive:!1}),()=>document.removeEventListener("wheel",j,{passive:!1})},[C,v,k,S]),h.useEffect(T,[r,T]),Hr(v,E),Hr(f.content,E),u.jsx(Rk,{scope:n,scrollbar:v,hasThumb:o,onThumbChange:pt(s),onThumbPointerUp:pt(i),onThumbPositionChange:T,onThumbPointerDown:pt(a),children:u.jsx(he.div,{...m,ref:x,style:{position:"absolute",...m.style},onPointerDown:ae(e.onPointerDown,j=>{j.button===0&&(j.target.setPointerCapture(j.pointerId),y.current=v.getBoundingClientRect(),b.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",f.viewport&&(f.viewport.style.scrollBehavior="auto"),A(j))}),onPointerMove:ae(e.onPointerMove,A),onPointerUp:ae(e.onPointerUp,j=>{const L=j.target;L.hasPointerCapture(j.pointerId)&&L.releasePointerCapture(j.pointerId),document.body.style.webkitUserSelect=b.current,f.viewport&&(f.viewport.style.scrollBehavior=""),y.current=null})})})}),oi="ScrollAreaThumb",mm=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=pm(oi,e.__scopeScrollArea);return u.jsx(Ht,{present:n||o.hasThumb,children:u.jsx(Mk,{ref:t,...r})})}),Mk=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=rn(oi,n),i=pm(oi,n),{onThumbPositionChange:a}=i,c=je(t,p=>i.onThumbChange(p)),l=h.useRef(void 0),d=ai(()=>{l.current&&(l.current(),l.current=void 0)},100);return h.useEffect(()=>{const p=s.viewport;if(p){const m=()=>{if(d(),!l.current){const f=Lk(p,a);l.current=f,a()}};return a(),p.addEventListener("scroll",m),()=>p.removeEventListener("scroll",m)}},[s.viewport,d,a]),u.jsx(he.div,{"data-state":i.hasThumb?"visible":"hidden",...o,ref:c,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:ae(e.onPointerDownCapture,p=>{const f=p.target.getBoundingClientRect(),v=p.clientX-f.left,g=p.clientY-f.top;i.onThumbPointerDown({x:v,y:g})}),onPointerUp:ae(e.onPointerUp,i.onThumbPointerUp)})});mm.displayName=oi;var Fl="ScrollAreaCorner",gm=h.forwardRef((e,t)=>{const n=rn(Fl,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?u.jsx(Ok,{...e,ref:t}):null});gm.displayName=Fl;var Ok=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=rn(Fl,n),[s,i]=h.useState(0),[a,c]=h.useState(0),l=!!(s&&a);return Hr(o.scrollbarX,()=>{var p;const d=((p=o.scrollbarX)==null?void 0:p.offsetHeight)||0;o.onCornerHeightChange(d),c(d)}),Hr(o.scrollbarY,()=>{var p;const d=((p=o.scrollbarY)==null?void 0:p.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),l?u.jsx(he.div,{...r,ref:t,style:{width:s,height:a,position:"absolute",right:o.dir==="ltr"?0:void 0,left:o.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function si(e){return e?parseInt(e,10):0}function xm(e,t){const n=e/t;return isNaN(n)?0:n}function ii(e){const t=xm(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function Dk(e,t,n,r="ltr"){const o=ii(n),s=o/2,i=t||s,a=o-i,c=n.scrollbar.paddingStart+i,l=n.scrollbar.size-n.scrollbar.paddingEnd-a,d=n.content-n.viewport,p=r==="ltr"?[0,d]:[d*-1,0];return wm([c,l],p)(e)}function vm(e,t,n="ltr"){const r=ii(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,s=t.scrollbar.size-o,i=t.content-t.viewport,a=s-r,c=n==="ltr"?[0,i]:[i*-1,0],l=Ol(e,c);return wm([0,i],[0,a])(l)}function wm(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function bm(e,t){return e>0&&e<t}var Lk=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return function o(){const s={left:e.scrollLeft,top:e.scrollTop},i=n.left!==s.left,a=n.top!==s.top;(i||a)&&t(),n=s,r=window.requestAnimationFrame(o)}(),()=>window.cancelAnimationFrame(r)};function ai(e,t){const n=pt(e),r=h.useRef(0);return h.useEffect(()=>()=>window.clearTimeout(r.current),[]),h.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function Hr(e,t){const n=pt(t);Tt(()=>{let r=0;if(e){const o=new ResizeObserver(()=>{cancelAnimationFrame(r),r=window.requestAnimationFrame(n)});return o.observe(e),()=>{window.cancelAnimationFrame(r),o.unobserve(e)}}},[e,n])}var ym=cm,$k=dm,Fk=gm;const Bl=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(ym,{ref:r,className:ne("relative overflow-hidden",e),...n,children:[u.jsx($k,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),u.jsx(Sm,{}),u.jsx(Fk,{})]}));Bl.displayName=ym.displayName;const Sm=h.forwardRef(({className:e,orientation:t="vertical",...n},r)=>u.jsx(Ll,{ref:r,orientation:t,className:ne("flex touch-none select-none transition-colors",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...n,children:u.jsx(mm,{className:"relative flex-1 rounded-full bg-border"})}));Sm.displayName=Ll.displayName;const zl=h.forwardRef(({className:e,type:t,...n},r)=>u.jsx("input",{type:t,className:ne("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:r,...n}));zl.displayName="Input";const Bk="group relative p-3 rounded-lg cursor-pointer transition-colors border text-gray-900 dark:text-slate-100",zk="bg-slate-700 border-slate-600 hover:bg-slate-600",Hk="bg-slate-600 border-slate-500";function Cm({thread:e,isActive:t,editingThreadId:n,editingTitle:r,onSelect:o,onStartEditing:s,onEditingTitleChange:i,onSaveEditing:a,onCancelEditing:c,onShare:l,onDelete:d,showEditTitle:p,showDeleteButton:m,formatDate:f,getDisplayThreadTitle:v,secondaryLine:g,itemClassName:x,activeItemClassName:y}){const b=n===e.threadId,C=t?`${y??Hk}`:`${x??zk}`,k=S=>{S.stopPropagation(),o(e.threadId)};return u.jsxs("div",{onClick:k,className:`${Bk} ${C}`,children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("div",{className:"flex-1 min-w-0",children:b?u.jsxs("div",{className:"flex items-center gap-2",onClick:S=>S.stopPropagation(),children:[u.jsx(zl,{value:r,onChange:S=>i(S.target.value),onKeyDown:S=>{S.key==="Enter"?a(e.threadId):S.key==="Escape"&&c()},className:"h-6 text-sm",autoFocus:!0}),u.jsx(Ye,{variant:"ghost",size:"sm",onClick:()=>a(e.threadId),className:"h-6 w-6 p-0",children:u.jsx(le.Check,{size:12})}),u.jsx(Ye,{variant:"ghost",size:"sm",onClick:c,className:"h-6 w-6 p-0",children:u.jsx(le.X,{size:12})})]}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"font-medium text-sm truncate text-gray-900 dark:text-slate-100",children:v(e)}),u.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-slate-400 mt-1",children:[u.jsx(le.Calendar,{size:10}),u.jsx("span",{children: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(Is,{children:[u.jsx(Ns,{asChild:!0,children:u.jsx(Ye,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",children:u.jsx(le.MoreHorizontal,{size:12})})}),u.jsxs(xo,{align:"end",sideOffset:6,className:"w-44",children:[u.jsxs(Fn,{onClick:S=>{S.preventDefault(),l(e.threadId)},children:[u.jsx(le.Share2,{className:"mr-2 h-4 w-4"}),"Share thread"]}),p&&n!==e.threadId&&u.jsxs(Fn,{onClick:S=>{S.preventDefault(),s(e,S)},children:[u.jsx(le.Edit3,{className:"mr-2 h-4 w-4"}),"Rename"]}),m&&d&&u.jsxs(Fn,{className:"text-red-400 hover:text-red-300",onClick:S=>{S.preventDefault(),d(e.threadId,S)},children:[u.jsx(le.Trash2,{className:"mr-2 h-4 w-4"}),"Delete"]})]})]})})]}),t&&u.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-1 h-8 bg-blue-400 rounded-r"})]})}const Tm=25,km="thread-manager-view",Uk=e=>e==="default"||e==="shared",Wk=()=>{if(typeof window>"u")return null;try{const e=window.localStorage.getItem(km);if(Uk(e))return e}catch{}return null};function Em({defaultView:e}={}){const[t,n]=w.useState(()=>Wk()??e??"default");w.useEffect(()=>{if(!(typeof window>"u"))try{window.localStorage.setItem(km,t)}catch{}},[t]);const r=w.useCallback(o=>{n(o)},[]);return{view:t,setView:r}}const Vk=[{key:"default",label:"My chats"},{key:"shared",label:"Shared with you"}];function li({className:e="",showCreateButton:t=!0,showDeleteButton:n=!0,showEditTitle:r=!0,maxHeight:o="400px",customStyles:s={},currentThreadId:i=null,navigateToThread:a,onThreadSelect:c,onThreadCreate:l,onThreadDelete:d,view:p,defaultView:m,onViewChange:f,viewOptions:v,viewState:g,showHeader:x=!0,shareTargets:y,isLoadingShareTargets:b,shareTargetFilter:C}){const{threads:k,sharedThreads:S,currentThreadId:T,setCurrentThreadId:E,isLoading:A,isLoadingSharedThreads:j,actions:L,shareInFlight:H,shareStatus:V,clearShareStatus:J}=yr(),{createThread:R,deleteThread:G,renameThread:K,shareThread:$}=L,{loadThread:P}=oo(),I=i??T,[U,Z]=w.useState(Array.isArray(k)?k:[]),M=w.useRef(U.length>0),Y=w.useRef(null),_=w.useRef(0),[z,W]=w.useState(null),[O,D]=w.useState(""),[B,Q]=w.useState(!1),[oe,ie]=w.useState(!1),[Ce,ve]=w.useState(null),[Re,We]=w.useState(""),De=v&&v.length>0?v:Vk,qe=Em({defaultView:m}),ze=g??qe,xt=p??ze.view,lt=w.useCallback(ee=>{p||ze.setView(ee),f==null||f(ee)},[p,f,ze]),et=De.find(ee=>ee.key===xt)??De[0],Le=ee=>{ve(ee),We(""),ie(!0)},Ve=()=>{ie(!1),ve(null),We(""),J()},$e=w.useCallback(async ee=>{if(!(!Ce||H)&&ee.id)try{await $(Ce,ee.id),setTimeout(()=>Ve(),600)}catch(fe){console.error("Failed to share thread:",fe)}},[Ve,H,Ce,$]),ke=w.useMemo(()=>{const ee=y??[],fe=Re.trim().toLowerCase();return fe?C?ee.filter(tt=>C(tt,fe)):ee.filter(tt=>`${tt.label} ${tt.secondaryLabel??""}`.toLowerCase().includes(fe)):ee},[y,Re,C]),Ae=xt==="shared",ct=Ae?S:U,kt=Ae?j:A,st=Ae?"No shared conversations yet":"No conversations yet",Et=ee=>{const fe=ee.sharedAt?` • ${Pe(ee.sharedAt)}`:"";return`Shared by ${ee.sharedByUserId}${fe}`},vt=ee=>"sharedByUserId"in ee;w.useEffect(()=>{const ee=Array.isArray(k)?k:[];if(ee.length>0){M.current=!0,Z(ee);return}A||(M.current=!1,Z(ee))},[k,A]),w.useEffect(()=>{if(!Y.current)return;const ee=Y.current.querySelector("[data-radix-scroll-area-viewport]");if(!ee)return;let fe=null,tt=null;return fe=requestAnimationFrame(()=>{tt=requestAnimationFrame(()=>{ee.scrollTop=_.current})}),()=>{fe!==null&&cancelAnimationFrame(fe),tt!==null&&cancelAnimationFrame(tt)}},[U]);const dt=async ee=>{try{E(ee),await P(ee),a==null||a(ee),c==null||c(ee)}catch(fe){console.error("Failed to select thread:",fe)}},St=async()=>{try{Q(!0);const ee=await R();ee&&(l==null||l(ee),a==null||a(ee))}catch(ee){console.error("Failed to create thread:",ee)}finally{Q(!1)}},wt=async(ee,fe)=>{if(fe.stopPropagation(),!!confirm("Delete this thread?")){if(Y.current){const tt=Y.current.querySelector("[data-radix-scroll-area-viewport]");tt&&(_.current=tt.scrollTop)}try{await G(ee),d==null||d(ee)}catch(tt){console.error("Failed to delete thread:",tt)}}},At=(ee,fe)=>{fe.stopPropagation(),W(ee.threadId),D(ee.title||`Thread ${ee.threadId.slice(0,8)}`)},on=async ee=>{if(O.trim())try{await K(ee,O.trim()),W(null),D("")}catch(fe){console.error("Failed to update title:",fe)}},It=()=>{W(null),D("")},Pe=ee=>{if(!ee)return"";try{const fe=new Date(ee),ge=new Date().getTime()-fe.getTime(),pe=Math.floor(ge/(1e3*60*60*24));return pe===0?fe.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):pe===1?"Yesterday":pe<7?`${pe} days ago`:fe.toLocaleDateString()}catch{return""}},He=ee=>ee.title||`Thread ${ee.threadId.slice(0,8)}`,Ct=ee=>{const fe=He(ee);return fe.length<=Tm?fe:`${fe.slice(0,Tm)}...`};return u.jsxs("div",{className:`flex flex-col h-full ${e} ${s.container||""}`,children:[x&&u.jsxs("div",{className:s.header||"flex flex-col gap-2 px-1 py-0 border border-slate-200 bg-white dark:border-slate-700 dark:bg-slate-900 shadow-sm",children:[t&&u.jsx("div",{className:"flex justify-end",children:u.jsxs(Ye,{onClick:St,disabled:B||A,className:s.createButton||"px-3 py-2 gap-1",size:"sm",variant:"ghost",title:B?"Creating...":"New Chat",children:[u.jsx(le.Edit3,{size:16}),u.jsx("span",{children:"New chat"})]})}),u.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-slate-700 dark:text-slate-200 uppercase tracking-wide leading-tight",children:[u.jsx("span",{children:"Current View"}),u.jsxs(Is,{children:[u.jsx(Ns,{asChild:!0,children:u.jsx(Ye,{variant:"outline",size:"sm",className:"text-[11px] text-slate-700 dark:text-slate-200 border border-slate-300 dark:border-slate-600 bg-white dark:bg-slate-900 hover:bg-slate-50 dark:hover:bg-slate-800 px-2 py-0",children:et.label})}),u.jsx(xo,{align:"start",sideOffset:6,className:"w-40",children:De.map(ee=>u.jsxs(Fn,{className:"justify-between text-[12px]",onClick:fe=>{fe.preventDefault(),lt(ee.key)},children:[u.jsx("span",{children:ee.label}),xt===ee.key&&u.jsx(le.Check,{className:"h-3 w-3"})]},ee.key))})]})]})]}),u.jsx(Bl,{ref:Y,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:kt?u.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-8 text-slate-400",children:[u.jsx(le.Loader2,{className:"h-5 w-5 animate-spin"}),u.jsx("span",{className:"text-sm",children:"Loading threads…"})]}):ct.length===0?u.jsxs("div",{className:"text-center py-8 text-slate-400",children:[u.jsx(le.MessageSquare,{className:"w-8 h-8 mx-auto mb-2 opacity-40 text-slate-500"}),u.jsx("p",{className:"text-sm text-slate-500",children:st})]}):ct.slice().sort((ee,fe)=>new Date(fe.updatedAt||fe.createdAt||"").getTime()-new Date(ee.updatedAt||ee.createdAt||"").getTime()).map(ee=>u.jsx(Cm,{thread:ee,isActive:I===ee.threadId,editingThreadId:z,editingTitle:O,onSelect:dt,onStartEditing:At,onEditingTitleChange:fe=>D(fe),onSaveEditing:on,onCancelEditing:It,onShare:()=>Le(ee.threadId),onDelete:wt,showEditTitle:r,showDeleteButton:n,formatDate:Pe,getDisplayThreadTitle:Ct,secondaryLine:Ae&&vt(ee)?Et(ee):void 0,itemClassName:s.threadItem,activeItemClassName:s.activeThread},ee.threadId))})}),u.jsx(cl,{open:oe,onOpenChange:ee=>!ee&&Ve(),children:u.jsxs(Vs,{className:"max-w-md p-0",children:[u.jsx(Ks,{children:u.jsx(qs,{children:"Share thread"})}),u.jsxs(Al,{children:[u.jsx(Pl,{autoFocus:!0,value:Re,onValueChange:ee=>We(ee),placeholder:"Search for recipients..."}),u.jsxs(jl,{children:[V&&u.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-xs text-muted-foreground",children:[H&&u.jsx(le.Loader2,{className:"h-3 w-3 animate-spin"}),u.jsx("span",{className:V.startsWith("Failed")?"text-red-500":V.startsWith("Shared")?"text-emerald-500":"text-slate-600 dark:text-slate-400",children:V})]}),u.jsx(_l,{children:b?u.jsxs("span",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(le.Loader2,{className:"h-4 w-4 animate-spin"}),"Loading recipients…"]}):"No matching recipients found"}),ke.length>0&&u.jsx(Rl,{heading:"Recipients",children:ke.map(ee=>u.jsx(Ml,{onSelect:()=>$e(ee),children:u.jsxs("div",{className:"flex flex-col items-start text-sm",children:[u.jsx("span",{className:"font-medium",children:ee.label}),ee.secondaryLabel&&u.jsx("span",{className:"text-xs text-muted-foreground",children:ee.secondaryLabel})]})},ee.id))})]})]})]})})]})}function Kk({layout:e="sidebar",layoutSize:t="desktop",showThreads:n=!0,className:r="",customStyles:o={},...s}){const i=l=>{const d="h-full";switch(l){case"phone":return`${d} max-w-none`;case"tablet":return`${d} max-w-4xl mx-auto`;case"half-screen":return`${d} max-w-2xl`;case"desktop":default:return`${d} max-w-7xl mx-auto`}},a=l=>({"--chat-sidebar-width":l==="phone"?"100%":l==="tablet"?"280px":l==="half-screen"?"240px":"320px","--chat-message-max-width":l==="phone"?"95%":l==="tablet"?"90%":l==="half-screen"?"85%":"80%","--chat-input-height":l==="phone"?"120px":"100px"}),c=w.useCallback(l=>{var d;(d=s.onThreadChange)==null||d.call(s,l)},[s]);return e==="fullscreen"?u.jsx(Tr,{...s,onThreadChange:c,children:u.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:u.jsx(Fr,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?u.jsx(Tr,{...s,onThreadChange:c,children:u.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:u.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[n&&u.jsx("div",{className:`w-80 border-r flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:u.jsx(li,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),u.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:u.jsx(Fr,{onError:s.onError,enableFileUpload:!0})})]})})}):u.jsx(Tr,{...s,onThreadChange:c,children:u.jsxs("div",{className:`${i(t)} flex overflow-hidden ${r} ${o.container||""}`,style:a(t),children:[n&&u.jsx("div",{className:`w-80 border-r bg-gray-50 flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:u.jsx(li,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),u.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:u.jsx(Fr,{onError:s.onError,enableFileUpload:!0})})]})})}function qk({apiConfig:e,className:t="",onError:n}){return u.jsx(Tr,{apiConfig:e,onError:n,children:u.jsx("div",{className:`h-full ${t}`,children:u.jsx(Fr,{})})})}function Gk({placeholder:e,onMessageSent:t}){const[n,r]=w.useState("chat");return u.jsxs("div",{className:"flex flex-col h-full",children:[u.jsxs("div",{className:"flex border-b border-gray-200 bg-gray-50",children:[u.jsx("button",{onClick:()=>r("chat"),className:`flex-1 px-3 py-2 text-sm font-medium transition-colors ${n==="chat"?"border-b-2 border-slate-800 text-slate-800 bg-white":"text-gray-600 hover:text-gray-800"}`,children:u.jsxs("div",{className:"flex items-center justify-center gap-2",children:[u.jsx(le.MessageSquare,{size:14}),"Chat"]})}),u.jsx("button",{onClick:()=>r("threads"),className:`flex-1 px-3 py-2 text-sm font-medium transition-colors ${n==="threads"?"border-b-2 border-slate-800 text-slate-800 bg-white":"text-gray-600 hover:text-gray-800"}`,children:u.jsxs("div",{className:"flex items-center justify-center gap-2",children:[u.jsx(le.History,{size:14}),"History"]})})]}),u.jsx("div",{className:"flex-1 min-h-0",children:n==="chat"?u.jsx(Fr,{placeholder:e??"Ask Serti AI anything...",autoFocus:!0,className:"h-full",onMessageSent:t}):u.jsx(li,{showCreateButton:!0,className:"h-full",onThreadSelect:()=>r("chat")})})]})}function Yk({className:e="",placeholder:t,isAuthenticated:n=!0,onMessageSent:r,widgetTitle:o="Serti AI Navigator",widgetSubtitle:s="AI-Powered Assistant",...i}){const[a,c]=w.useState(!1);return n?u.jsx(Tr,{...i,children:u.jsx("div",{className:`fixed bottom-6 right-6 z-[9999] transition-all duration-300 ${e}`,children:u.jsxs("div",{className:`w-96 bg-white rounded-xl shadow-2xl border border-gray-200 overflow-hidden relative ${a?"scale-75":"scale-100"}`,children:[u.jsx("div",{className:"bg-slate-800 text-white p-4 flex-shrink-0",children:u.jsxs("div",{className:"flex items-center justify-between gap-3",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsxs("div",{className:"relative h-10 w-10 rounded-full bg-gradient-to-br from-slate-500 to-slate-700 border border-white/30 flex items-center justify-center text-white text-sm font-bold",children:["S",u.jsx("span",{className:"absolute -bottom-0.5 -right-0.5 h-3 w-3 rounded-full border-2 border-slate-800 bg-emerald-400"})]}),u.jsxs("div",{className:"flex flex-col",children:[u.jsx("h3",{className:"text-lg font-semibold leading-tight",children:o}),u.jsx("p",{className:"text-xs text-white/70",children:s})]}),u.jsx("span",{className:"ml-2 inline-flex items-center justify-center rounded-full bg-red-500 px-2 py-0.5 text-[11px] font-semibold leading-none text-white",children:"1"})]}),u.jsxs("div",{className:"flex items-center gap-1",children:[u.jsx(Ye,{variant:"ghost",size:"sm",className:"text-white hover:bg-white/10 h-8 w-8 p-0",title:"Options",children:u.jsx(le.MoreHorizontal,{size:16})}),u.jsx(Ye,{variant:"ghost",size:"sm",className:"text-white hover:bg-white/10 h-8 w-8 p-0",title:"Compose",children:u.jsx(le.Edit3,{size:16})}),u.jsx(Ye,{variant:"ghost",size:"sm",onClick:l=>{l.stopPropagation(),c(d=>!d)},className:"text-white hover:bg-white/10 h-8 w-8 p-0",title:a?"Maximize":"Minimize",children:a?u.jsx(le.Maximize2,{size:14}):u.jsx(le.Minimize2,{size:14})})]})]})}),!a&&u.jsx("div",{className:"h-96 flex flex-col",children:u.jsx(Gk,{placeholder:t,onMessageSent:r})})]})})}):null}function Xk({label:e="New chat",children:t,className:n,variant:r="ghost",size:o="sm",...s}){return u.jsxs(Ye,{variant:r,size:o,className:ne("gap-2 rounded-full px-3 font-semibold transition-all hover:scale-[1.01]",n),...s,children:[u.jsx(le.Edit3,{size:16}),t??e]})}var Jk="Label",Im=h.forwardRef((e,t)=>u.jsx(he.label,{...e,ref:t,onMouseDown:n=>{var o;n.target.closest("button, input, select, textarea")||((o=e.onMouseDown)==null||o.call(e,n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));Im.displayName=Jk;var Nm=Im;const Zk=Kr.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Am=h.forwardRef(({className:e,...t},n)=>u.jsx(Nm,{ref:n,className:ne(Zk(),e),...t}));Am.displayName=Nm.displayName;function Pm(e){const t=h.useRef({value:e,previous:e});return h.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var jm=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),Qk="VisuallyHidden",ci=h.forwardRef((e,t)=>u.jsx(he.span,{...e,ref:t,style:{...jm,...e.style}}));ci.displayName=Qk;var eE=ci,tE=[" ","Enter","ArrowUp","ArrowDown"],nE=[" ","Enter"],hr="Select",[ui,di,rE]=es(hr),[Ur,VN]=cn(hr,[rE,jr]),fi=jr(),[oE,qn]=Ur(hr),[sE,iE]=Ur(hr),_m=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:c,dir:l,name:d,autoComplete:p,disabled:m,required:f,form:v}=e,g=fi(t),[x,y]=h.useState(null),[b,C]=h.useState(null),[k,S]=h.useState(!1),T=ts(l),[E,A]=On({prop:r,defaultProp:o??!1,onChange:s,caller:hr}),[j,L]=On({prop:i,defaultProp:a,onChange:c,caller:hr}),H=h.useRef(null),V=x?v||!!x.closest("form"):!0,[J,R]=h.useState(new Set),G=Array.from(J).map(K=>K.props.value).join(";");return u.jsx(ha,{...g,children:u.jsxs(oE,{required:f,scope:t,trigger:x,onTriggerChange:y,valueNode:b,onValueNodeChange:C,valueNodeHasChildren:k,onValueNodeHasChildrenChange:S,contentId:jt(),value:j,onValueChange:L,open:E,onOpenChange:A,dir:T,triggerPointerDownPosRef:H,disabled:m,children:[u.jsx(ui.Provider,{scope:t,children:u.jsx(sE,{scope:e.__scopeSelect,onNativeOptionAdd:h.useCallback(K=>{R($=>new Set($).add(K))},[]),onNativeOptionRemove:h.useCallback(K=>{R($=>{const P=new Set($);return P.delete(K),P})},[]),children:n})}),V?u.jsxs(ng,{"aria-hidden":!0,required:f,tabIndex:-1,name:d,autoComplete:p,value:j,onChange:K=>L(K.target.value),disabled:m,form:v,children:[j===void 0?u.jsx("option",{value:""}):null,Array.from(J)]},G):null]})})};_m.displayName=hr;var Rm="SelectTrigger",Mm=h.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=fi(n),i=qn(Rm,n),a=i.disabled||r,c=je(t,i.onTriggerChange),l=di(n),d=h.useRef("touch"),[p,m,f]=og(g=>{const x=l().filter(C=>!C.disabled),y=x.find(C=>C.value===i.value),b=sg(x,g,y);b!==void 0&&i.onValueChange(b.value)}),v=g=>{a||(i.onOpenChange(!0),f()),g&&(i.triggerPointerDownPosRef.current={x:Math.round(g.pageX),y:Math.round(g.pageY)})};return u.jsx(ma,{asChild:!0,...s,children:u.jsx(he.button,{type:"button",role:"combobox","aria-controls":i.contentId,"aria-expanded":i.open,"aria-required":i.required,"aria-autocomplete":"none",dir:i.dir,"data-state":i.open?"open":"closed",disabled:a,"data-disabled":a?"":void 0,"data-placeholder":rg(i.value)?"":void 0,...o,ref:c,onClick:ae(o.onClick,g=>{g.currentTarget.focus(),d.current!=="mouse"&&v(g)}),onPointerDown:ae(o.onPointerDown,g=>{d.current=g.pointerType;const x=g.target;x.hasPointerCapture(g.pointerId)&&x.releasePointerCapture(g.pointerId),g.button===0&&g.ctrlKey===!1&&g.pointerType==="mouse"&&(v(g),g.preventDefault())}),onKeyDown:ae(o.onKeyDown,g=>{const x=p.current!=="";!(g.ctrlKey||g.altKey||g.metaKey)&&g.key.length===1&&m(g.key),!(x&&g.key===" ")&&tE.includes(g.key)&&(v(),g.preventDefault())})})})});Mm.displayName=Rm;var Om="SelectValue",Dm=h.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,c=qn(Om,n),{onValueNodeHasChildrenChange:l}=c,d=s!==void 0,p=je(t,c.onValueNodeChange);return Tt(()=>{l(d)},[l,d]),u.jsx(he.span,{...a,ref:p,style:{pointerEvents:"none"},children:rg(c.value)?u.jsx(u.Fragment,{children:i}):s})});Dm.displayName=Om;var aE="SelectIcon",Lm=h.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return u.jsx(he.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});Lm.displayName=aE;var lE="SelectPortal",$m=e=>u.jsx(co,{asChild:!0,...e});$m.displayName=lE;var mr="SelectContent",Fm=h.forwardRef((e,t)=>{const n=qn(mr,e.__scopeSelect),[r,o]=h.useState();if(Tt(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?qr.createPortal(u.jsx(Bm,{scope:e.__scopeSelect,children:u.jsx(ui.Slot,{scope:e.__scopeSelect,children:u.jsx("div",{children:e.children})})}),s):null}return u.jsx(zm,{...e,ref:t})});Fm.displayName=mr;var mn=10,[Bm,Gn]=Ur(mr),cE="SelectContentImpl",uE=qt.createSlot("SelectContent.RemoveScroll"),zm=h.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:a,sideOffset:c,align:l,alignOffset:d,arrowPadding:p,collisionBoundary:m,collisionPadding:f,sticky:v,hideWhenDetached:g,avoidCollisions:x,...y}=e,b=qn(mr,n),[C,k]=h.useState(null),[S,T]=h.useState(null),E=je(t,O=>k(O)),[A,j]=h.useState(null),[L,H]=h.useState(null),V=di(n),[J,R]=h.useState(!1),G=h.useRef(!1);h.useEffect(()=>{if(C)return ya(C)},[C]),Zi();const K=h.useCallback(O=>{const[D,...B]=V().map(ie=>ie.ref.current),[Q]=B.slice(-1),oe=document.activeElement;for(const ie of O)if(ie===oe||(ie==null||ie.scrollIntoView({block:"nearest"}),ie===D&&S&&(S.scrollTop=0),ie===Q&&S&&(S.scrollTop=S.scrollHeight),ie==null||ie.focus(),document.activeElement!==oe))return},[V,S]),$=h.useCallback(()=>K([A,C]),[K,A,C]);h.useEffect(()=>{J&&$()},[J,$]);const{onOpenChange:P,triggerPointerDownPosRef:I}=b;h.useEffect(()=>{if(C){let O={x:0,y:0};const D=Q=>{var oe,ie;O={x:Math.abs(Math.round(Q.pageX)-(((oe=I.current)==null?void 0:oe.x)??0)),y:Math.abs(Math.round(Q.pageY)-(((ie=I.current)==null?void 0:ie.y)??0))}},B=Q=>{O.x<=10&&O.y<=10?Q.preventDefault():C.contains(Q.target)||P(!1),document.removeEventListener("pointermove",D),I.current=null};return I.current!==null&&(document.addEventListener("pointermove",D),document.addEventListener("pointerup",B,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",D),document.removeEventListener("pointerup",B,{capture:!0})}}},[C,P,I]),h.useEffect(()=>{const O=()=>P(!1);return window.addEventListener("blur",O),window.addEventListener("resize",O),()=>{window.removeEventListener("blur",O),window.removeEventListener("resize",O)}},[P]);const[U,Z]=og(O=>{const D=V().filter(oe=>!oe.disabled),B=D.find(oe=>oe.ref.current===document.activeElement),Q=sg(D,O,B);Q&&setTimeout(()=>Q.ref.current.focus())}),M=h.useCallback((O,D,B)=>{const Q=!G.current&&!B;(b.value!==void 0&&b.value===D||Q)&&(j(O),Q&&(G.current=!0))},[b.value]),Y=h.useCallback(()=>C==null?void 0:C.focus(),[C]),_=h.useCallback((O,D,B)=>{const Q=!G.current&&!B;(b.value!==void 0&&b.value===D||Q)&&H(O)},[b.value]),z=r==="popper"?Hl:Hm,W=z===Hl?{side:a,sideOffset:c,align:l,alignOffset:d,arrowPadding:p,collisionBoundary:m,collisionPadding:f,sticky:v,hideWhenDetached:g,avoidCollisions:x}:{};return u.jsx(Bm,{scope:n,content:C,viewport:S,onViewportChange:T,itemRefCallback:M,selectedItem:A,onItemLeave:Y,itemTextRefCallback:_,focusSelectedItem:$,selectedItemText:L,position:r,isPositioned:J,searchRef:U,children:u.jsx(ys,{as:uE,allowPinchZoom:!0,children:u.jsx(ns,{asChild:!0,trapped:b.open,onMountAutoFocus:O=>{O.preventDefault()},onUnmountAutoFocus:ae(o,O=>{var D;(D=b.trigger)==null||D.focus({preventScroll:!0}),O.preventDefault()}),children:u.jsx(Er,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:O=>O.preventDefault(),onDismiss:()=>b.onOpenChange(!1),children:u.jsx(z,{role:"listbox",id:b.contentId,"data-state":b.open?"open":"closed",dir:b.dir,onContextMenu:O=>O.preventDefault(),...y,...W,onPlaced:()=>R(!0),ref:E,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:ae(y.onKeyDown,O=>{const D=O.ctrlKey||O.altKey||O.metaKey;if(O.key==="Tab"&&O.preventDefault(),!D&&O.key.length===1&&Z(O.key),["ArrowUp","ArrowDown","Home","End"].includes(O.key)){let Q=V().filter(oe=>!oe.disabled).map(oe=>oe.ref.current);if(["ArrowUp","End"].includes(O.key)&&(Q=Q.slice().reverse()),["ArrowUp","ArrowDown"].includes(O.key)){const oe=O.target,ie=Q.indexOf(oe);Q=Q.slice(ie+1)}setTimeout(()=>K(Q)),O.preventDefault()}})})})})})})});zm.displayName=cE;var dE="SelectItemAlignedPosition",Hm=h.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=qn(mr,n),i=Gn(mr,n),[a,c]=h.useState(null),[l,d]=h.useState(null),p=je(t,E=>d(E)),m=di(n),f=h.useRef(!1),v=h.useRef(!0),{viewport:g,selectedItem:x,selectedItemText:y,focusSelectedItem:b}=i,C=h.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&l&&g&&x&&y){const E=s.trigger.getBoundingClientRect(),A=l.getBoundingClientRect(),j=s.valueNode.getBoundingClientRect(),L=y.getBoundingClientRect();if(s.dir!=="rtl"){const oe=L.left-A.left,ie=j.left-oe,Ce=E.left-ie,ve=E.width+Ce,Re=Math.max(ve,A.width),We=window.innerWidth-mn,De=Ol(ie,[mn,Math.max(mn,We-Re)]);a.style.minWidth=ve+"px",a.style.left=De+"px"}else{const oe=A.right-L.right,ie=window.innerWidth-j.right-oe,Ce=window.innerWidth-E.right-ie,ve=E.width+Ce,Re=Math.max(ve,A.width),We=window.innerWidth-mn,De=Ol(ie,[mn,Math.max(mn,We-Re)]);a.style.minWidth=ve+"px",a.style.right=De+"px"}const H=m(),V=window.innerHeight-mn*2,J=g.scrollHeight,R=window.getComputedStyle(l),G=parseInt(R.borderTopWidth,10),K=parseInt(R.paddingTop,10),$=parseInt(R.borderBottomWidth,10),P=parseInt(R.paddingBottom,10),I=G+K+J+P+$,U=Math.min(x.offsetHeight*5,I),Z=window.getComputedStyle(g),M=parseInt(Z.paddingTop,10),Y=parseInt(Z.paddingBottom,10),_=E.top+E.height/2-mn,z=V-_,W=x.offsetHeight/2,O=x.offsetTop+W,D=G+K+O,B=I-D;if(D<=_){const oe=H.length>0&&x===H[H.length-1].ref.current;a.style.bottom="0px";const ie=l.clientHeight-g.offsetTop-g.offsetHeight,Ce=Math.max(z,W+(oe?Y:0)+ie+$),ve=D+Ce;a.style.height=ve+"px"}else{const oe=H.length>0&&x===H[0].ref.current;a.style.top="0px";const Ce=Math.max(_,G+g.offsetTop+(oe?M:0)+W)+B;a.style.height=Ce+"px",g.scrollTop=D-_+g.offsetTop}a.style.margin=`${mn}px 0`,a.style.minHeight=U+"px",a.style.maxHeight=V+"px",r==null||r(),requestAnimationFrame(()=>f.current=!0)}},[m,s.trigger,s.valueNode,a,l,g,x,y,s.dir,r]);Tt(()=>C(),[C]);const[k,S]=h.useState();Tt(()=>{l&&S(window.getComputedStyle(l).zIndex)},[l]);const T=h.useCallback(E=>{E&&v.current===!0&&(C(),b==null||b(),v.current=!1)},[C,b]);return u.jsx(pE,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:f,onScrollButtonChange:T,children:u.jsx("div",{ref:c,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:k},children:u.jsx(he.div,{...o,ref:p,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Hm.displayName=dE;var fE="SelectPopperPosition",Hl=h.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=mn,...s}=e,i=fi(n);return u.jsx(ga,{...i,...s,ref:t,align:r,collisionPadding:o,style:{boxSizing:"border-box",...s.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});Hl.displayName=fE;var[pE,Ul]=Ur(mr,{}),Wl="SelectViewport",Um=h.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=Gn(Wl,n),i=Ul(Wl,n),a=je(t,s.onViewportChange),c=h.useRef(0);return u.jsxs(u.Fragment,{children:[u.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),u.jsx(ui.Slot,{scope:n,children:u.jsx(he.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:ae(o.onScroll,l=>{const d=l.currentTarget,{contentWrapper:p,shouldExpandOnScrollRef:m}=i;if(m!=null&&m.current&&p){const f=Math.abs(c.current-d.scrollTop);if(f>0){const v=window.innerHeight-mn*2,g=parseFloat(p.style.minHeight),x=parseFloat(p.style.height),y=Math.max(g,x);if(y<v){const b=y+f,C=Math.min(v,b),k=b-C;p.style.height=C+"px",p.style.bottom==="0px"&&(d.scrollTop=k>0?k:0,p.style.justifyContent="flex-end")}}}c.current=d.scrollTop})})})]})});Um.displayName=Wl;var Wm="SelectGroup",[hE,mE]=Ur(Wm),gE=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=jt();return u.jsx(hE,{scope:n,id:o,children:u.jsx(he.div,{role:"group","aria-labelledby":o,...r,ref:t})})});gE.displayName=Wm;var Vm="SelectLabel",Km=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=mE(Vm,n);return u.jsx(he.div,{id:o.id,...r,ref:t})});Km.displayName=Vm;var pi="SelectItem",[xE,qm]=Ur(pi),Gm=h.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=qn(pi,n),c=Gn(pi,n),l=a.value===r,[d,p]=h.useState(s??""),[m,f]=h.useState(!1),v=je(t,b=>{var C;return(C=c.itemRefCallback)==null?void 0:C.call(c,b,r,o)}),g=jt(),x=h.useRef("touch"),y=()=>{o||(a.onValueChange(r),a.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return u.jsx(xE,{scope:n,value:r,disabled:o,textId:g,isSelected:l,onItemTextChange:h.useCallback(b=>{p(C=>C||((b==null?void 0:b.textContent)??"").trim())},[]),children:u.jsx(ui.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:u.jsx(he.div,{role:"option","aria-labelledby":g,"data-highlighted":m?"":void 0,"aria-selected":l&&m,"data-state":l?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:v,onFocus:ae(i.onFocus,()=>f(!0)),onBlur:ae(i.onBlur,()=>f(!1)),onClick:ae(i.onClick,()=>{x.current!=="mouse"&&y()}),onPointerUp:ae(i.onPointerUp,()=>{x.current==="mouse"&&y()}),onPointerDown:ae(i.onPointerDown,b=>{x.current=b.pointerType}),onPointerMove:ae(i.onPointerMove,b=>{var C;x.current=b.pointerType,o?(C=c.onItemLeave)==null||C.call(c):x.current==="mouse"&&b.currentTarget.focus({preventScroll:!0})}),onPointerLeave:ae(i.onPointerLeave,b=>{var C;b.currentTarget===document.activeElement&&((C=c.onItemLeave)==null||C.call(c))}),onKeyDown:ae(i.onKeyDown,b=>{var k;((k=c.searchRef)==null?void 0:k.current)!==""&&b.key===" "||(nE.includes(b.key)&&y(),b.key===" "&&b.preventDefault())})})})})});Gm.displayName=pi;var Mo="SelectItemText",Ym=h.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=qn(Mo,n),a=Gn(Mo,n),c=qm(Mo,n),l=iE(Mo,n),[d,p]=h.useState(null),m=je(t,y=>p(y),c.onItemTextChange,y=>{var b;return(b=a.itemTextRefCallback)==null?void 0:b.call(a,y,c.value,c.disabled)}),f=d==null?void 0:d.textContent,v=h.useMemo(()=>u.jsx("option",{value:c.value,disabled:c.disabled,children:f},c.value),[c.disabled,c.value,f]),{onNativeOptionAdd:g,onNativeOptionRemove:x}=l;return Tt(()=>(g(v),()=>x(v)),[g,x,v]),u.jsxs(u.Fragment,{children:[u.jsx(he.span,{id:c.textId,...s,ref:m}),c.isSelected&&i.valueNode&&!i.valueNodeHasChildren?qr.createPortal(s.children,i.valueNode):null]})});Ym.displayName=Mo;var Xm="SelectItemIndicator",Jm=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return qm(Xm,n).isSelected?u.jsx(he.span,{"aria-hidden":!0,...r,ref:t}):null});Jm.displayName=Xm;var Vl="SelectScrollUpButton",Zm=h.forwardRef((e,t)=>{const n=Gn(Vl,e.__scopeSelect),r=Ul(Vl,e.__scopeSelect),[o,s]=h.useState(!1),i=je(t,r.onScrollButtonChange);return Tt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const l=c.scrollTop>0;s(l)};const c=n.viewport;return a(),c.addEventListener("scroll",a),()=>c.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?u.jsx(eg,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:c}=n;a&&c&&(a.scrollTop=a.scrollTop-c.offsetHeight)}}):null});Zm.displayName=Vl;var Kl="SelectScrollDownButton",Qm=h.forwardRef((e,t)=>{const n=Gn(Kl,e.__scopeSelect),r=Ul(Kl,e.__scopeSelect),[o,s]=h.useState(!1),i=je(t,r.onScrollButtonChange);return Tt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const l=c.scrollHeight-c.clientHeight,d=Math.ceil(c.scrollTop)<l;s(d)};const c=n.viewport;return a(),c.addEventListener("scroll",a),()=>c.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?u.jsx(eg,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:c}=n;a&&c&&(a.scrollTop=a.scrollTop+c.offsetHeight)}}):null});Qm.displayName=Kl;var eg=h.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=Gn("SelectScrollButton",n),i=h.useRef(null),a=di(n),c=h.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return h.useEffect(()=>()=>c(),[c]),Tt(()=>{var d;const l=a().find(p=>p.ref.current===document.activeElement);(d=l==null?void 0:l.ref.current)==null||d.scrollIntoView({block:"nearest"})},[a]),u.jsx(he.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:ae(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:ae(o.onPointerMove,()=>{var l;(l=s.onItemLeave)==null||l.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:ae(o.onPointerLeave,()=>{c()})})}),vE="SelectSeparator",tg=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return u.jsx(he.div,{"aria-hidden":!0,...r,ref:t})});tg.displayName=vE;var ql="SelectArrow",wE=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=fi(n),s=qn(ql,n),i=Gn(ql,n);return s.open&&i.position==="popper"?u.jsx(xa,{...o,...r,ref:t}):null});wE.displayName=ql;var bE="SelectBubbleInput",ng=h.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=h.useRef(null),s=je(r,o),i=Pm(t);return h.useEffect(()=>{const a=o.current;if(!a)return;const c=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(c,"value").set;if(i!==t&&d){const p=new Event("change",{bubbles:!0});d.call(a,t),a.dispatchEvent(p)}},[i,t]),u.jsx(he.select,{...n,style:{...jm,...n.style},ref:s,defaultValue:t})});ng.displayName=bE;function rg(e){return e===""||e===void 0}function og(e){const t=pt(e),n=h.useRef(""),r=h.useRef(0),o=h.useCallback(i=>{const a=n.current+i;t(a),function c(l){n.current=l,window.clearTimeout(r.current),l!==""&&(r.current=window.setTimeout(()=>c(""),1e3))}(a)},[t]),s=h.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return h.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function sg(e,t,n){const o=t.length>1&&Array.from(t).every(l=>l===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=yE(e,Math.max(s,0));o.length===1&&(i=i.filter(l=>l!==n));const c=i.find(l=>l.textValue.toLowerCase().startsWith(o.toLowerCase()));return c!==n?c:void 0}function yE(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var SE=_m,ig=Mm,CE=Dm,TE=Lm,kE=$m,ag=Fm,EE=Um,lg=Km,cg=Gm,IE=Ym,NE=Jm,ug=Zm,dg=Qm,fg=tg;const AE=SE,PE=CE,pg=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(ig,{ref:r,className:ne("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[t,u.jsx(TE,{asChild:!0,children:u.jsx(le.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));pg.displayName=ig.displayName;const hg=h.forwardRef(({className:e,...t},n)=>u.jsx(ug,{ref:n,className:ne("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(le.ChevronUp,{className:"h-4 w-4"})}));hg.displayName=ug.displayName;const mg=h.forwardRef(({className:e,...t},n)=>u.jsx(dg,{ref:n,className:ne("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(le.ChevronDown,{className:"h-4 w-4"})}));mg.displayName=dg.displayName;const gg=h.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>u.jsx(kE,{children:u.jsxs(ag,{ref:o,className:ne("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...r,children:[u.jsx(hg,{}),u.jsx(EE,{className:ne("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),u.jsx(mg,{})]})}));gg.displayName=ag.displayName;const jE=h.forwardRef(({className:e,...t},n)=>u.jsx(lg,{ref:n,className:ne("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));jE.displayName=lg.displayName;const xg=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(cg,{ref:r,className:ne("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[u.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx(NE,{children:u.jsx(le.Check,{className:"h-4 w-4"})})}),u.jsx(IE,{children:t})]}));xg.displayName=cg.displayName;const _E=h.forwardRef(({className:e,...t},n)=>u.jsx(fg,{ref:n,className:ne("-mx-1 my-1 h-px bg-muted",e),...t}));_E.displayName=fg.displayName;var RE="Separator",vg="horizontal",ME=["horizontal","vertical"],wg=h.forwardRef((e,t)=>{const{decorative:n,orientation:r=vg,...o}=e,s=OE(r)?r:vg,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return u.jsx(he.div,{"data-orientation":s,...a,...o,ref:t})});wg.displayName=RE;function OE(e){return ME.includes(e)}var bg=wg;const yg=h.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>u.jsx(bg,{ref:o,decorative:n,orientation:t,className:ne("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));yg.displayName=bg.displayName;var hi="Switch",[DE,KN]=cn(hi),[LE,$E]=DE(hi),Sg=h.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:s,required:i,disabled:a,value:c="on",onCheckedChange:l,form:d,...p}=e,[m,f]=h.useState(null),v=je(t,C=>f(C)),g=h.useRef(!1),x=m?d||!!m.closest("form"):!0,[y,b]=On({prop:o,defaultProp:s??!1,onChange:l,caller:hi});return u.jsxs(LE,{scope:n,checked:y,disabled:a,children:[u.jsx(he.button,{type:"button",role:"switch","aria-checked":y,"aria-required":i,"data-state":Eg(y),"data-disabled":a?"":void 0,disabled:a,value:c,...p,ref:v,onClick:ae(e.onClick,C=>{b(k=>!k),x&&(g.current=C.isPropagationStopped(),g.current||C.stopPropagation())})}),x&&u.jsx(kg,{control:m,bubbles:!g.current,name:r,value:c,checked:y,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});Sg.displayName=hi;var Cg="SwitchThumb",Tg=h.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=$E(Cg,n);return u.jsx(he.span,{"data-state":Eg(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});Tg.displayName=Cg;var FE="SwitchBubbleInput",kg=h.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=h.useRef(null),a=je(i,s),c=Pm(n),l=Od(t);return h.useEffect(()=>{const d=i.current;if(!d)return;const p=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(p,"checked").set;if(c!==n&&f){const v=new Event("click",{bubbles:r});f.call(d,n),d.dispatchEvent(v)}},[c,n,r]),u.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:a,style:{...o.style,...l,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});kg.displayName=FE;function Eg(e){return e?"checked":"unchecked"}var Ig=Sg,BE=Tg;const Ng=h.forwardRef(({className:e,...t},n)=>u.jsx(Ig,{className:ne("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...t,ref:n,children:u.jsx(BE,{className:ne("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));Ng.displayName=Ig.displayName;const zE=al,HE=wT,UE=ll,Ag=h.forwardRef(({className:e,...t},n)=>u.jsx(No,{className:ne("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t,ref:n}));Ag.displayName=No.displayName;const WE=Kr.cva("fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),Pg=h.forwardRef(({side:e="right",className:t,children:n,...r},o)=>u.jsxs(UE,{children:[u.jsx(Ag,{}),u.jsxs(Ao,{ref:o,className:ne(WE({side:e}),t),...r,children:[n,u.jsxs(yh,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary",children:[u.jsx(le.X,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Pg.displayName=Ao.displayName;const jg=({className:e,...t})=>u.jsx("div",{className:ne("flex flex-col space-y-2 text-center sm:text-left",e),...t});jg.displayName="SheetHeader";const _g=h.forwardRef(({className:e,...t},n)=>u.jsx(ur,{ref:n,className:ne("text-lg font-semibold text-foreground",e),...t}));_g.displayName=ur.displayName;const Rg=h.forwardRef(({className:e,...t},n)=>u.jsx(Ws,{ref:n,className:ne("text-sm text-muted-foreground",e),...t}));Rg.displayName=Ws.displayName;var[mi,qN]=cn("Tooltip",[jr]),gi=jr(),Mg="TooltipProvider",VE=700,Gl="tooltip.open",[KE,Yl]=mi(Mg),Og=e=>{const{__scopeTooltip:t,delayDuration:n=VE,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:s}=e,i=h.useRef(!0),a=h.useRef(!1),c=h.useRef(0);return h.useEffect(()=>{const l=c.current;return()=>window.clearTimeout(l)},[]),u.jsx(KE,{scope:t,isOpenDelayedRef:i,delayDuration:n,onOpen:h.useCallback(()=>{window.clearTimeout(c.current),i.current=!1},[]),onClose:h.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>i.current=!0,r)},[r]),isPointerInTransitRef:a,onPointerInTransitChange:h.useCallback(l=>{a.current=l},[]),disableHoverableContent:o,children:s})};Og.displayName=Mg;var Oo="Tooltip",[qE,xi]=mi(Oo),Dg=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:s,disableHoverableContent:i,delayDuration:a}=e,c=Yl(Oo,e.__scopeTooltip),l=gi(t),[d,p]=h.useState(null),m=jt(),f=h.useRef(0),v=i??c.disableHoverableContent,g=a??c.delayDuration,x=h.useRef(!1),[y,b]=On({prop:r,defaultProp:o??!1,onChange:E=>{E?(c.onOpen(),document.dispatchEvent(new CustomEvent(Gl))):c.onClose(),s==null||s(E)},caller:Oo}),C=h.useMemo(()=>y?x.current?"delayed-open":"instant-open":"closed",[y]),k=h.useCallback(()=>{window.clearTimeout(f.current),f.current=0,x.current=!1,b(!0)},[b]),S=h.useCallback(()=>{window.clearTimeout(f.current),f.current=0,b(!1)},[b]),T=h.useCallback(()=>{window.clearTimeout(f.current),f.current=window.setTimeout(()=>{x.current=!0,b(!0),f.current=0},g)},[g,b]);return h.useEffect(()=>()=>{f.current&&(window.clearTimeout(f.current),f.current=0)},[]),u.jsx(ha,{...l,children:u.jsx(qE,{scope:t,contentId:m,open:y,stateAttribute:C,trigger:d,onTriggerChange:p,onTriggerEnter:h.useCallback(()=>{c.isOpenDelayedRef.current?T():k()},[c.isOpenDelayedRef,T,k]),onTriggerLeave:h.useCallback(()=>{v?S():(window.clearTimeout(f.current),f.current=0)},[S,v]),onOpen:k,onClose:S,disableHoverableContent:v,children:n})})};Dg.displayName=Oo;var Xl="TooltipTrigger",Lg=h.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=xi(Xl,n),s=Yl(Xl,n),i=gi(n),a=h.useRef(null),c=je(t,a,o.onTriggerChange),l=h.useRef(!1),d=h.useRef(!1),p=h.useCallback(()=>l.current=!1,[]);return h.useEffect(()=>()=>document.removeEventListener("pointerup",p),[p]),u.jsx(ma,{asChild:!0,...i,children:u.jsx(he.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:c,onPointerMove:ae(e.onPointerMove,m=>{m.pointerType!=="touch"&&!d.current&&!s.isPointerInTransitRef.current&&(o.onTriggerEnter(),d.current=!0)}),onPointerLeave:ae(e.onPointerLeave,()=>{o.onTriggerLeave(),d.current=!1}),onPointerDown:ae(e.onPointerDown,()=>{o.open&&o.onClose(),l.current=!0,document.addEventListener("pointerup",p,{once:!0})}),onFocus:ae(e.onFocus,()=>{l.current||o.onOpen()}),onBlur:ae(e.onBlur,o.onClose),onClick:ae(e.onClick,o.onClose)})})});Lg.displayName=Xl;var GE="TooltipPortal",[GN,YE]=mi(GE,{forceMount:void 0}),Wr="TooltipContent",$g=h.forwardRef((e,t)=>{const n=YE(Wr,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...s}=e,i=xi(Wr,e.__scopeTooltip);return u.jsx(Ht,{present:r||i.open,children:i.disableHoverableContent?u.jsx(Fg,{side:o,...s,ref:t}):u.jsx(XE,{side:o,...s,ref:t})})}),XE=h.forwardRef((e,t)=>{const n=xi(Wr,e.__scopeTooltip),r=Yl(Wr,e.__scopeTooltip),o=h.useRef(null),s=je(t,o),[i,a]=h.useState(null),{trigger:c,onClose:l}=n,d=o.current,{onPointerInTransitChange:p}=r,m=h.useCallback(()=>{a(null),p(!1)},[p]),f=h.useCallback((v,g)=>{const x=v.currentTarget,y={x:v.clientX,y:v.clientY},b=tI(y,x.getBoundingClientRect()),C=nI(y,b),k=rI(g.getBoundingClientRect()),S=sI([...C,...k]);a(S),p(!0)},[p]);return h.useEffect(()=>()=>m(),[m]),h.useEffect(()=>{if(c&&d){const v=x=>f(x,d),g=x=>f(x,c);return c.addEventListener("pointerleave",v),d.addEventListener("pointerleave",g),()=>{c.removeEventListener("pointerleave",v),d.removeEventListener("pointerleave",g)}}},[c,d,f,m]),h.useEffect(()=>{if(i){const v=g=>{const x=g.target,y={x:g.clientX,y:g.clientY},b=(c==null?void 0:c.contains(x))||(d==null?void 0:d.contains(x)),C=!oI(y,i);b?m():C&&(m(),l())};return document.addEventListener("pointermove",v),()=>document.removeEventListener("pointermove",v)}},[c,d,i,l,m]),u.jsx(Fg,{...e,ref:s})}),[JE,ZE]=mi(Oo,{isInside:!1}),QE=qt.createSlottable("TooltipContent"),Fg=h.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:s,onPointerDownOutside:i,...a}=e,c=xi(Wr,n),l=gi(n),{onClose:d}=c;return h.useEffect(()=>(document.addEventListener(Gl,d),()=>document.removeEventListener(Gl,d)),[d]),h.useEffect(()=>{if(c.trigger){const p=m=>{const f=m.target;f!=null&&f.contains(c.trigger)&&d()};return window.addEventListener("scroll",p,{capture:!0}),()=>window.removeEventListener("scroll",p,{capture:!0})}},[c.trigger,d]),u.jsx(Er,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:p=>p.preventDefault(),onDismiss:d,children:u.jsxs(ga,{"data-state":c.stateAttribute,...l,...a,ref:t,style:{...a.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[u.jsx(QE,{children:r}),u.jsx(JE,{scope:n,isInside:!0,children:u.jsx(eE,{id:c.contentId,role:"tooltip",children:o||r})})]})})});$g.displayName=Wr;var Bg="TooltipArrow",eI=h.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=gi(n);return ZE(Bg,n).isInside?null:u.jsx(xa,{...o,...r,ref:t})});eI.displayName=Bg;function tI(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),o=Math.abs(t.right-e.x),s=Math.abs(t.left-e.x);switch(Math.min(n,r,o,s)){case s:return"left";case o:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function nI(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function rI(e){const{top:t,right:n,bottom:r,left:o}=e;return[{x:o,y:t},{x:n,y:t},{x:n,y:r},{x:o,y:r}]}function oI(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const a=t[s],c=t[i],l=a.x,d=a.y,p=c.x,m=c.y;d>r!=m>r&&n<(p-l)*(r-d)/(m-d)+l&&(o=!o)}return o}function sI(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),iI(t)}function iI(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const o=e[r];for(;t.length>=2;){const s=t[t.length-1],i=t[t.length-2];if((s.x-i.x)*(o.y-i.y)>=(s.y-i.y)*(o.x-i.x))t.pop();else break}t.push(o)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const o=e[r];for(;n.length>=2;){const s=n[n.length-1],i=n[n.length-2];if((s.x-i.x)*(o.y-i.y)>=(s.y-i.y)*(o.x-i.x))n.pop();else break}n.push(o)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var aI=Og,lI=Dg,cI=Lg,zg=$g;const uI=aI,dI=lI,fI=cI,Hg=h.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(zg,{ref:r,sideOffset:t,className:ne("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n}));Hg.displayName=zg.displayName;var Jl="ToastProvider",[Zl,pI,hI]=es("Toast"),[Ug,YN]=cn("Toast",[hI]),[mI,vi]=Ug(Jl),Wg=e=>{const{__scopeToast:t,label:n="Notification",duration:r=5e3,swipeDirection:o="right",swipeThreshold:s=50,children:i}=e,[a,c]=h.useState(null),[l,d]=h.useState(0),p=h.useRef(!1),m=h.useRef(!1);return n.trim()||console.error(`Invalid prop \`label\` supplied to \`${Jl}\`. Expected non-empty \`string\`.`),u.jsx(Zl.Provider,{scope:t,children:u.jsx(mI,{scope:t,label:n,duration:r,swipeDirection:o,swipeThreshold:s,toastCount:l,viewport:a,onViewportChange:c,onToastAdd:h.useCallback(()=>d(f=>f+1),[]),onToastRemove:h.useCallback(()=>d(f=>f-1),[]),isFocusedToastEscapeKeyDownRef:p,isClosePausedRef:m,children:i})})};Wg.displayName=Jl;var Vg="ToastViewport",gI=["F8"],Ql="toast.viewportPause",ec="toast.viewportResume",Kg=h.forwardRef((e,t)=>{const{__scopeToast:n,hotkey:r=gI,label:o="Notifications ({hotkey})",...s}=e,i=vi(Vg,n),a=pI(n),c=h.useRef(null),l=h.useRef(null),d=h.useRef(null),p=h.useRef(null),m=je(t,p,i.onViewportChange),f=r.join("+").replace(/Key/g,"").replace(/Digit/g,""),v=i.toastCount>0;h.useEffect(()=>{const x=y=>{var C;r.length!==0&&r.every(k=>y[k]||y.code===k)&&((C=p.current)==null||C.focus())};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[r]),h.useEffect(()=>{const x=c.current,y=p.current;if(v&&x&&y){const b=()=>{if(!i.isClosePausedRef.current){const T=new CustomEvent(Ql);y.dispatchEvent(T),i.isClosePausedRef.current=!0}},C=()=>{if(i.isClosePausedRef.current){const T=new CustomEvent(ec);y.dispatchEvent(T),i.isClosePausedRef.current=!1}},k=T=>{!x.contains(T.relatedTarget)&&C()},S=()=>{x.contains(document.activeElement)||C()};return x.addEventListener("focusin",b),x.addEventListener("focusout",k),x.addEventListener("pointermove",b),x.addEventListener("pointerleave",S),window.addEventListener("blur",b),window.addEventListener("focus",C),()=>{x.removeEventListener("focusin",b),x.removeEventListener("focusout",k),x.removeEventListener("pointermove",b),x.removeEventListener("pointerleave",S),window.removeEventListener("blur",b),window.removeEventListener("focus",C)}}},[v,i.isClosePausedRef]);const g=h.useCallback(({tabbingDirection:x})=>{const b=a().map(C=>{const k=C.ref.current,S=[k,...AI(k)];return x==="forwards"?S:S.reverse()});return(x==="forwards"?b.reverse():b).flat()},[a]);return h.useEffect(()=>{const x=p.current;if(x){const y=b=>{var S,T,E;const C=b.altKey||b.ctrlKey||b.metaKey;if(b.key==="Tab"&&!C){const A=document.activeElement,j=b.shiftKey;if(b.target===x&&j){(S=l.current)==null||S.focus();return}const V=g({tabbingDirection:j?"backwards":"forwards"}),J=V.findIndex(R=>R===A);rc(V.slice(J+1))?b.preventDefault():j?(T=l.current)==null||T.focus():(E=d.current)==null||E.focus()}};return x.addEventListener("keydown",y),()=>x.removeEventListener("keydown",y)}},[a,g]),u.jsxs(qw,{ref:c,role:"region","aria-label":o.replace("{hotkey}",f),tabIndex:-1,style:{pointerEvents:v?void 0:"none"},children:[v&&u.jsx(tc,{ref:l,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"forwards"});rc(x)}}),u.jsx(Zl.Slot,{scope:n,children:u.jsx(he.ol,{tabIndex:-1,...s,ref:m})}),v&&u.jsx(tc,{ref:d,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"backwards"});rc(x)}})]})});Kg.displayName=Vg;var qg="ToastFocusProxy",tc=h.forwardRef((e,t)=>{const{__scopeToast:n,onFocusFromOutsideViewport:r,...o}=e,s=vi(qg,n);return u.jsx(ci,{tabIndex:0,...o,ref:t,style:{position:"fixed"},onFocus:i=>{var l;const a=i.relatedTarget;!((l=s.viewport)!=null&&l.contains(a))&&r()}})});tc.displayName=qg;var Do="Toast",xI="toast.swipeStart",vI="toast.swipeMove",wI="toast.swipeCancel",bI="toast.swipeEnd",Gg=h.forwardRef((e,t)=>{const{forceMount:n,open:r,defaultOpen:o,onOpenChange:s,...i}=e,[a,c]=On({prop:r,defaultProp:o??!0,onChange:s,caller:Do});return u.jsx(Ht,{present:n||a,children:u.jsx(CI,{open:a,...i,ref:t,onClose:()=>c(!1),onPause:pt(e.onPause),onResume:pt(e.onResume),onSwipeStart:ae(e.onSwipeStart,l=>{l.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:ae(e.onSwipeMove,l=>{const{x:d,y:p}=l.detail.delta;l.currentTarget.setAttribute("data-swipe","move"),l.currentTarget.style.setProperty("--radix-toast-swipe-move-x",`${d}px`),l.currentTarget.style.setProperty("--radix-toast-swipe-move-y",`${p}px`)}),onSwipeCancel:ae(e.onSwipeCancel,l=>{l.currentTarget.setAttribute("data-swipe","cancel"),l.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),l.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),l.currentTarget.style.removeProperty("--radix-toast-swipe-end-x"),l.currentTarget.style.removeProperty("--radix-toast-swipe-end-y")}),onSwipeEnd:ae(e.onSwipeEnd,l=>{const{x:d,y:p}=l.detail.delta;l.currentTarget.setAttribute("data-swipe","end"),l.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),l.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),l.currentTarget.style.setProperty("--radix-toast-swipe-end-x",`${d}px`),l.currentTarget.style.setProperty("--radix-toast-swipe-end-y",`${p}px`),c(!1)})})})});Gg.displayName=Do;var[yI,SI]=Ug(Do,{onClose(){}}),CI=h.forwardRef((e,t)=>{const{__scopeToast:n,type:r="foreground",duration:o,open:s,onClose:i,onEscapeKeyDown:a,onPause:c,onResume:l,onSwipeStart:d,onSwipeMove:p,onSwipeCancel:m,onSwipeEnd:f,...v}=e,g=vi(Do,n),[x,y]=h.useState(null),b=je(t,R=>y(R)),C=h.useRef(null),k=h.useRef(null),S=o||g.duration,T=h.useRef(0),E=h.useRef(S),A=h.useRef(0),{onToastAdd:j,onToastRemove:L}=g,H=pt(()=>{var G;(x==null?void 0:x.contains(document.activeElement))&&((G=g.viewport)==null||G.focus()),i()}),V=h.useCallback(R=>{!R||R===1/0||(window.clearTimeout(A.current),T.current=new Date().getTime(),A.current=window.setTimeout(H,R))},[H]);h.useEffect(()=>{const R=g.viewport;if(R){const G=()=>{V(E.current),l==null||l()},K=()=>{const $=new Date().getTime()-T.current;E.current=E.current-$,window.clearTimeout(A.current),c==null||c()};return R.addEventListener(Ql,K),R.addEventListener(ec,G),()=>{R.removeEventListener(Ql,K),R.removeEventListener(ec,G)}}},[g.viewport,S,c,l,V]),h.useEffect(()=>{s&&!g.isClosePausedRef.current&&V(S)},[s,S,g.isClosePausedRef,V]),h.useEffect(()=>(j(),()=>L()),[j,L]);const J=h.useMemo(()=>x?tx(x):null,[x]);return g.viewport?u.jsxs(u.Fragment,{children:[J&&u.jsx(TI,{__scopeToast:n,role:"status","aria-live":r==="foreground"?"assertive":"polite",children:J}),u.jsx(yI,{scope:n,onClose:H,children:qr.createPortal(u.jsx(Zl.ItemSlot,{scope:n,children:u.jsx(Kw,{asChild:!0,onEscapeKeyDown:ae(a,()=>{g.isFocusedToastEscapeKeyDownRef.current||H(),g.isFocusedToastEscapeKeyDownRef.current=!1}),children:u.jsx(he.li,{tabIndex:0,"data-state":s?"open":"closed","data-swipe-direction":g.swipeDirection,...v,ref:b,style:{userSelect:"none",touchAction:"none",...e.style},onKeyDown:ae(e.onKeyDown,R=>{R.key==="Escape"&&(a==null||a(R.nativeEvent),R.nativeEvent.defaultPrevented||(g.isFocusedToastEscapeKeyDownRef.current=!0,H()))}),onPointerDown:ae(e.onPointerDown,R=>{R.button===0&&(C.current={x:R.clientX,y:R.clientY})}),onPointerMove:ae(e.onPointerMove,R=>{if(!C.current)return;const G=R.clientX-C.current.x,K=R.clientY-C.current.y,$=!!k.current,P=["left","right"].includes(g.swipeDirection),I=["left","up"].includes(g.swipeDirection)?Math.min:Math.max,U=P?I(0,G):0,Z=P?0:I(0,K),M=R.pointerType==="touch"?10:2,Y={x:U,y:Z},_={originalEvent:R,delta:Y};$?(k.current=Y,wi(vI,p,_,{discrete:!1})):nx(Y,g.swipeDirection,M)?(k.current=Y,wi(xI,d,_,{discrete:!1}),R.target.setPointerCapture(R.pointerId)):(Math.abs(G)>M||Math.abs(K)>M)&&(C.current=null)}),onPointerUp:ae(e.onPointerUp,R=>{const G=k.current,K=R.target;if(K.hasPointerCapture(R.pointerId)&&K.releasePointerCapture(R.pointerId),k.current=null,C.current=null,G){const $=R.currentTarget,P={originalEvent:R,delta:G};nx(G,g.swipeDirection,g.swipeThreshold)?wi(bI,f,P,{discrete:!0}):wi(wI,m,P,{discrete:!0}),$.addEventListener("click",I=>I.preventDefault(),{once:!0})}})})})}),g.viewport)})]}):null}),TI=e=>{const{__scopeToast:t,children:n,...r}=e,o=vi(Do,t),[s,i]=h.useState(!1),[a,c]=h.useState(!1);return II(()=>i(!0)),h.useEffect(()=>{const l=window.setTimeout(()=>c(!0),1e3);return()=>window.clearTimeout(l)},[]),a?null:u.jsx(co,{asChild:!0,children:u.jsx(ci,{...r,children:s&&u.jsxs(u.Fragment,{children:[o.label," ",n]})})})},kI="ToastTitle",Yg=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(he.div,{...r,ref:t})});Yg.displayName=kI;var EI="ToastDescription",Xg=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(he.div,{...r,ref:t})});Xg.displayName=EI;var Jg="ToastAction",Zg=h.forwardRef((e,t)=>{const{altText:n,...r}=e;return n.trim()?u.jsx(ex,{altText:n,asChild:!0,children:u.jsx(nc,{...r,ref:t})}):(console.error(`Invalid prop \`altText\` supplied to \`${Jg}\`. Expected non-empty \`string\`.`),null)});Zg.displayName=Jg;var Qg="ToastClose",nc=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e,o=SI(Qg,n);return u.jsx(ex,{asChild:!0,children:u.jsx(he.button,{type:"button",...r,ref:t,onClick:ae(e.onClick,o.onClose)})})});nc.displayName=Qg;var ex=h.forwardRef((e,t)=>{const{__scopeToast:n,altText:r,...o}=e;return u.jsx(he.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":r||void 0,...o,ref:t})});function tx(e){const t=[];return Array.from(e.childNodes).forEach(r=>{if(r.nodeType===r.TEXT_NODE&&r.textContent&&t.push(r.textContent),NI(r)){const o=r.ariaHidden||r.hidden||r.style.display==="none",s=r.dataset.radixToastAnnounceExclude==="";if(!o)if(s){const i=r.dataset.radixToastAnnounceAlt;i&&t.push(i)}else t.push(...tx(r))}}),t}function wi(e,t,n,{discrete:r}){const o=n.originalEvent.currentTarget,s=new CustomEvent(e,{bubbles:!0,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?Yi(o,s):o.dispatchEvent(s)}var nx=(e,t,n=0)=>{const r=Math.abs(e.x),o=Math.abs(e.y),s=r>o;return t==="left"||t==="right"?s&&r>n:!s&&o>n};function II(e=()=>{}){const t=pt(e);Tt(()=>{let n=0,r=0;return n=window.requestAnimationFrame(()=>r=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(n),window.cancelAnimationFrame(r)}},[t])}function NI(e){return e.nodeType===e.ELEMENT_NODE}function AI(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function rc(e){const t=document.activeElement;return e.some(n=>n===t?!0:(n.focus(),document.activeElement!==t))}var PI=Wg,rx=Kg,ox=Gg,sx=Yg,ix=Xg,ax=Zg,lx=nc;const jI=PI,cx=h.forwardRef(({className:e,...t},n)=>u.jsx(rx,{ref:n,className:ne("fixed bottom-0 right-0 z-[100] flex max-h-screen w-full flex-col p-4 md:max-w-[420px]",e),...t}));cx.displayName=rx.displayName;const _I=Kr.cva("group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-8 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",{variants:{variant:{default:"border bg-background text-foreground",destructive:"destructive group border-destructive bg-destructive text-destructive-foreground"}},defaultVariants:{variant:"default"}}),ux=h.forwardRef(({className:e,variant:t,...n},r)=>u.jsx(ox,{ref:r,className:ne(_I({variant:t}),e),...n}));ux.displayName=ox.displayName;const RI=h.forwardRef(({className:e,...t},n)=>u.jsx(ax,{ref:n,className:ne("inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors hover:bg-secondary focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive",e),...t}));RI.displayName=ax.displayName;const dx=h.forwardRef(({className:e,...t},n)=>u.jsx(lx,{ref:n,className:ne("absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-2 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",e),"toast-close":"",...t,children:u.jsx(le.X,{className:"h-4 w-4"})}));dx.displayName=lx.displayName;const fx=h.forwardRef(({className:e,...t},n)=>u.jsx(sx,{ref:n,className:ne("text-sm font-semibold",e),...t}));fx.displayName=sx.displayName;const px=h.forwardRef(({className:e,...t},n)=>u.jsx(ix,{ref:n,className:ne("text-sm opacity-90",e),...t}));px.displayName=ix.displayName;function MI(){const{toasts:e}=fl();return u.jsxs(jI,{children:[e.map(function({id:t,title:n,description:r,action:o,...s}){return u.jsxs(ux,{...s,children:[u.jsxs("div",{className:"grid gap-1",children:[n&&u.jsx(fx,{children:n}),r&&u.jsx(px,{children:r})]}),o,u.jsx(dx,{})]},t)}),u.jsx(cx,{})]})}var OI=(e,t,n,r,o,s,i,a)=>{let c=document.documentElement,l=["light","dark"];function d(f){(Array.isArray(e)?e:[e]).forEach(v=>{let g=v==="class",x=g&&s?o.map(y=>s[y]||y):o;g?(c.classList.remove(...x),c.classList.add(s&&s[f]?s[f]:f)):c.setAttribute(v,f)}),p(f)}function p(f){a&&l.includes(f)&&(c.style.colorScheme=f)}function m(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}if(r)d(r);else try{let f=localStorage.getItem(t)||n,v=i&&f==="system"?m():f;d(v)}catch{}},DI=h.createContext(void 0),LI={setTheme:e=>{},themes:[]},$I=()=>{var e;return(e=h.useContext(DI))!=null?e:LI};h.memo(({forcedTheme:e,storageKey:t,attribute:n,enableSystem:r,enableColorScheme:o,defaultTheme:s,value:i,themes:a,nonce:c,scriptProps:l})=>{let d=JSON.stringify([n,t,s,e,a,i,r,o]).slice(1,-1);return h.createElement("script",{...l,suppressHydrationWarning:!0,nonce:typeof window>"u"?c:"",dangerouslySetInnerHTML:{__html:`(${OI.toString()})(${d})`}})});var FI=e=>{switch(e){case"success":return HI;case"info":return WI;case"warning":return UI;case"error":return VI;default:return null}},BI=Array(12).fill(0),zI=({visible:e,className:t})=>w.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},w.createElement("div",{className:"sonner-spinner"},BI.map((n,r)=>w.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),HI=w.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},w.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),UI=w.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},w.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),WI=w.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},w.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),VI=w.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},w.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),KI=w.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},w.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),w.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),qI=()=>{let[e,t]=w.useState(document.hidden);return w.useEffect(()=>{let n=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),e},oc=1,GI=class{constructor(){this.subscribe=e=>(this.subscribers.push(e),()=>{let t=this.subscribers.indexOf(e);this.subscribers.splice(t,1)}),this.publish=e=>{this.subscribers.forEach(t=>t(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e]},this.create=e=>{var t;let{message:n,...r}=e,o=typeof(e==null?void 0:e.id)=="number"||((t=e.id)==null?void 0:t.length)>0?e.id:oc++,s=this.toasts.find(a=>a.id===o),i=e.dismissible===void 0?!0:e.dismissible;return this.dismissedToasts.has(o)&&this.dismissedToasts.delete(o),s?this.toasts=this.toasts.map(a=>a.id===o?(this.publish({...a,...e,id:o,title:n}),{...a,...e,id:o,dismissible:i,title:n}):a):this.addToast({title:n,...r,dismissible:i,id:o}),o},this.dismiss=e=>(this.dismissedToasts.add(e),e||this.toasts.forEach(t=>{this.subscribers.forEach(n=>n({id:t.id,dismiss:!0}))}),this.subscribers.forEach(t=>t({id:e,dismiss:!0})),e),this.message=(e,t)=>this.create({...t,message:e}),this.error=(e,t)=>this.create({...t,message:e,type:"error"}),this.success=(e,t)=>this.create({...t,type:"success",message:e}),this.info=(e,t)=>this.create({...t,type:"info",message:e}),this.warning=(e,t)=>this.create({...t,type:"warning",message:e}),this.loading=(e,t)=>this.create({...t,type:"loading",message:e}),this.promise=(e,t)=>{if(!t)return;let n;t.loading!==void 0&&(n=this.create({...t,promise:e,type:"loading",message:t.loading,description:typeof t.description!="function"?t.description:void 0}));let r=e instanceof Promise?e:e(),o=n!==void 0,s,i=r.then(async c=>{if(s=["resolve",c],w.isValidElement(c))o=!1,this.create({id:n,type:"default",message:c});else if(XI(c)&&!c.ok){o=!1;let l=typeof t.error=="function"?await t.error(`HTTP error! status: ${c.status}`):t.error,d=typeof t.description=="function"?await t.description(`HTTP error! status: ${c.status}`):t.description;this.create({id:n,type:"error",message:l,description:d})}else if(t.success!==void 0){o=!1;let l=typeof t.success=="function"?await t.success(c):t.success,d=typeof t.description=="function"?await t.description(c):t.description;this.create({id:n,type:"success",message:l,description:d})}}).catch(async c=>{if(s=["reject",c],t.error!==void 0){o=!1;let l=typeof t.error=="function"?await t.error(c):t.error,d=typeof t.description=="function"?await t.description(c):t.description;this.create({id:n,type:"error",message:l,description:d})}}).finally(()=>{var c;o&&(this.dismiss(n),n=void 0),(c=t.finally)==null||c.call(t)}),a=()=>new Promise((c,l)=>i.then(()=>s[0]==="reject"?l(s[1]):c(s[1])).catch(l));return typeof n!="string"&&typeof n!="number"?{unwrap:a}:Object.assign(n,{unwrap:a})},this.custom=(e,t)=>{let n=(t==null?void 0:t.id)||oc++;return this.create({jsx:e(n),id:n,...t}),n},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},Vt=new GI,YI=(e,t)=>{let n=(t==null?void 0:t.id)||oc++;return Vt.addToast({title:e,...t,id:n}),n},XI=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",JI=YI,ZI=()=>Vt.toasts,QI=()=>Vt.getActiveToasts();Object.assign(JI,{success:Vt.success,info:Vt.info,warning:Vt.warning,error:Vt.error,custom:Vt.custom,message:Vt.message,promise:Vt.promise,dismiss:Vt.dismiss,loading:Vt.loading},{getHistory:ZI,getToasts:QI});function eN(e,{insertAt:t}={}){if(typeof document>"u")return;let n=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",t==="top"&&n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r),r.styleSheet?r.styleSheet.cssText=e:r.appendChild(document.createTextNode(e))}eN(`:where(html[dir="ltr"]),:where([data-sonner-toaster][dir="ltr"]){--toast-icon-margin-start: -3px;--toast-icon-margin-end: 4px;--toast-svg-margin-start: -1px;--toast-svg-margin-end: 0px;--toast-button-margin-start: auto;--toast-button-margin-end: 0;--toast-close-button-start: 0;--toast-close-button-end: unset;--toast-close-button-transform: translate(-35%, -35%)}:where(html[dir="rtl"]),:where([data-sonner-toaster][dir="rtl"]){--toast-icon-margin-start: 4px;--toast-icon-margin-end: -3px;--toast-svg-margin-start: 0px;--toast-svg-margin-end: -1px;--toast-button-margin-start: 0;--toast-button-margin-end: auto;--toast-close-button-start: unset;--toast-close-button-end: 0;--toast-close-button-transform: translate(35%, -35%)}:where([data-sonner-toaster]){position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1: hsl(0, 0%, 99%);--gray2: hsl(0, 0%, 97.3%);--gray3: hsl(0, 0%, 95.1%);--gray4: hsl(0, 0%, 93%);--gray5: hsl(0, 0%, 90.9%);--gray6: hsl(0, 0%, 88.7%);--gray7: hsl(0, 0%, 85.8%);--gray8: hsl(0, 0%, 78%);--gray9: hsl(0, 0%, 56.1%);--gray10: hsl(0, 0%, 52.3%);--gray11: hsl(0, 0%, 43.5%);--gray12: hsl(0, 0%, 9%);--border-radius: 8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:none;z-index:999999999;transition:transform .4s ease}:where([data-sonner-toaster][data-lifted="true"]){transform:translateY(-10px)}@media (hover: none) and (pointer: coarse){:where([data-sonner-toaster][data-lifted="true"]){transform:none}}:where([data-sonner-toaster][data-x-position="right"]){right:var(--offset-right)}:where([data-sonner-toaster][data-x-position="left"]){left:var(--offset-left)}:where([data-sonner-toaster][data-x-position="center"]){left:50%;transform:translate(-50%)}:where([data-sonner-toaster][data-y-position="top"]){top:var(--offset-top)}:where([data-sonner-toaster][data-y-position="bottom"]){bottom:var(--offset-bottom)}:where([data-sonner-toast]){--y: translateY(100%);--lift-amount: calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);filter:blur(0);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:none;overflow-wrap:anywhere}:where([data-sonner-toast][data-styled="true"]){padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px #0000001a;width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}:where([data-sonner-toast]:focus-visible){box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast][data-y-position="top"]){top:0;--y: translateY(-100%);--lift: 1;--lift-amount: calc(1 * var(--gap))}:where([data-sonner-toast][data-y-position="bottom"]){bottom:0;--y: translateY(100%);--lift: -1;--lift-amount: calc(var(--lift) * var(--gap))}:where([data-sonner-toast]) :where([data-description]){font-weight:400;line-height:1.4;color:inherit}:where([data-sonner-toast]) :where([data-title]){font-weight:500;line-height:1.5;color:inherit}:where([data-sonner-toast]) :where([data-icon]){display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}:where([data-sonner-toast][data-promise="true"]) :where([data-icon])>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}:where([data-sonner-toast]) :where([data-icon])>*{flex-shrink:0}:where([data-sonner-toast]) :where([data-icon]) svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}:where([data-sonner-toast]) :where([data-content]){display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;cursor:pointer;outline:none;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}:where([data-sonner-toast]) :where([data-button]):focus-visible{box-shadow:0 0 0 2px #0006}:where([data-sonner-toast]) :where([data-button]):first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}:where([data-sonner-toast]) :where([data-cancel]){color:var(--normal-text);background:rgba(0,0,0,.08)}:where([data-sonner-toast][data-theme="dark"]) :where([data-cancel]){background:rgba(255,255,255,.3)}:where([data-sonner-toast]) :where([data-close-button]){position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast] [data-close-button]{background:var(--gray1)}:where([data-sonner-toast]) :where([data-close-button]):focus-visible{box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast]) :where([data-disabled="true"]){cursor:not-allowed}:where([data-sonner-toast]):hover :where([data-close-button]):hover{background:var(--gray2);border-color:var(--gray5)}:where([data-sonner-toast][data-swiping="true"]):before{content:"";position:absolute;left:-50%;right:-50%;height:100%;z-index:-1}:where([data-sonner-toast][data-y-position="top"][data-swiping="true"]):before{bottom:50%;transform:scaleY(3) translateY(50%)}:where([data-sonner-toast][data-y-position="bottom"][data-swiping="true"]):before{top:50%;transform:scaleY(3) translateY(-50%)}:where([data-sonner-toast][data-swiping="false"][data-removed="true"]):before{content:"";position:absolute;inset:0;transform:scaleY(2)}:where([data-sonner-toast]):after{content:"";position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}:where([data-sonner-toast][data-mounted="true"]){--y: translateY(0);opacity:1}:where([data-sonner-toast][data-expanded="false"][data-front="false"]){--scale: var(--toasts-before) * .05 + 1;--y: translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}:where([data-sonner-toast])>*{transition:opacity .4s}:where([data-sonner-toast][data-expanded="false"][data-front="false"][data-styled="true"])>*{opacity:0}:where([data-sonner-toast][data-visible="false"]){opacity:0;pointer-events:none}:where([data-sonner-toast][data-mounted="true"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}:where([data-sonner-toast][data-removed="true"][data-front="true"][data-swipe-out="false"]){--y: translateY(calc(var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="false"]){--y: translateY(40%);opacity:0;transition:transform .5s,opacity .2s}:where([data-sonner-toast][data-removed="true"][data-front="false"]):before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y, 0px)) translate(var(--swipe-amount-x, 0px));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width: 600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-theme=light]{--normal-bg: #fff;--normal-border: var(--gray4);--normal-text: var(--gray12);--success-bg: hsl(143, 85%, 96%);--success-border: hsl(145, 92%, 91%);--success-text: hsl(140, 100%, 27%);--info-bg: hsl(208, 100%, 97%);--info-border: hsl(221, 91%, 91%);--info-text: hsl(210, 92%, 45%);--warning-bg: hsl(49, 100%, 97%);--warning-border: hsl(49, 91%, 91%);--warning-text: hsl(31, 92%, 45%);--error-bg: hsl(359, 100%, 97%);--error-border: hsl(359, 100%, 94%);--error-text: hsl(360, 100%, 45%)}[data-sonner-toaster][data-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg: #000;--normal-border: hsl(0, 0%, 20%);--normal-text: var(--gray1)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg: #fff;--normal-border: var(--gray3);--normal-text: var(--gray12)}[data-sonner-toaster][data-theme=dark]{--normal-bg: #000;--normal-bg-hover: hsl(0, 0%, 12%);--normal-border: hsl(0, 0%, 20%);--normal-border-hover: hsl(0, 0%, 25%);--normal-text: var(--gray1);--success-bg: hsl(150, 100%, 6%);--success-border: hsl(147, 100%, 12%);--success-text: hsl(150, 86%, 65%);--info-bg: hsl(215, 100%, 6%);--info-border: hsl(223, 100%, 12%);--info-text: hsl(216, 87%, 65%);--warning-bg: hsl(64, 100%, 6%);--warning-border: hsl(60, 100%, 12%);--warning-text: hsl(46, 87%, 65%);--error-bg: hsl(358, 76%, 10%);--error-border: hsl(357, 89%, 16%);--error-text: hsl(358, 100%, 81%)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success],[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info],[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning],[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error],[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size: 16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:nth-child(1){animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}to{opacity:.15}}@media (prefers-reduced-motion){[data-sonner-toast],[data-sonner-toast]>*,.sonner-loading-bar{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}
|
|
131
|
-
`);function bi(e){return e.label!==void 0}var tN=3,nN="32px",rN="16px",hx=4e3,oN=356,sN=14,iN=20,aN=200;function gn(...e){return e.filter(Boolean).join(" ")}function lN(e){let[t,n]=e.split("-"),r=[];return t&&r.push(t),n&&r.push(n),r}var cN=e=>{var t,n,r,o,s,i,a,c,l,d,p;let{invert:m,toast:f,unstyled:v,interacting:g,setHeights:x,visibleToasts:y,heights:b,index:C,toasts:k,expanded:S,removeToast:T,defaultRichColors:E,closeButton:A,style:j,cancelButtonStyle:L,actionButtonStyle:H,className:V="",descriptionClassName:J="",duration:R,position:G,gap:K,loadingIcon:$,expandByDefault:P,classNames:I,icons:U,closeButtonAriaLabel:Z="Close toast",pauseWhenPageIsHidden:M}=e,[Y,_]=w.useState(null),[z,W]=w.useState(null),[O,D]=w.useState(!1),[B,Q]=w.useState(!1),[oe,ie]=w.useState(!1),[Ce,ve]=w.useState(!1),[Re,We]=w.useState(!1),[De,qe]=w.useState(0),[ze,xt]=w.useState(0),lt=w.useRef(f.duration||R||hx),et=w.useRef(null),Le=w.useRef(null),Ve=C===0,$e=C+1<=y,ke=f.type,Ae=f.dismissible!==!1,ct=f.className||"",kt=f.descriptionClassName||"",st=w.useMemo(()=>b.findIndex(ge=>ge.toastId===f.id)||0,[b,f.id]),Et=w.useMemo(()=>{var ge;return(ge=f.closeButton)!=null?ge:A},[f.closeButton,A]),vt=w.useMemo(()=>f.duration||R||hx,[f.duration,R]),dt=w.useRef(0),St=w.useRef(0),wt=w.useRef(0),At=w.useRef(null),[on,It]=G.split("-"),Pe=w.useMemo(()=>b.reduce((ge,pe,ye)=>ye>=st?ge:ge+pe.height,0),[b,st]),He=qI(),Ct=f.invert||m,ee=ke==="loading";St.current=w.useMemo(()=>st*K+Pe,[st,Pe]),w.useEffect(()=>{lt.current=vt},[vt]),w.useEffect(()=>{D(!0)},[]),w.useEffect(()=>{let ge=Le.current;if(ge){let pe=ge.getBoundingClientRect().height;return xt(pe),x(ye=>[{toastId:f.id,height:pe,position:f.position},...ye]),()=>x(ye=>ye.filter(Je=>Je.toastId!==f.id))}},[x,f.id]),w.useLayoutEffect(()=>{if(!O)return;let ge=Le.current,pe=ge.style.height;ge.style.height="auto";let ye=ge.getBoundingClientRect().height;ge.style.height=pe,xt(ye),x(Je=>Je.find(nt=>nt.toastId===f.id)?Je.map(nt=>nt.toastId===f.id?{...nt,height:ye}:nt):[{toastId:f.id,height:ye,position:f.position},...Je])},[O,f.title,f.description,x,f.id]);let fe=w.useCallback(()=>{Q(!0),qe(St.current),x(ge=>ge.filter(pe=>pe.toastId!==f.id)),setTimeout(()=>{T(f)},aN)},[f,T,x,St]);w.useEffect(()=>{if(f.promise&&ke==="loading"||f.duration===1/0||f.type==="loading")return;let ge;return S||g||M&&He?(()=>{if(wt.current<dt.current){let pe=new Date().getTime()-dt.current;lt.current=lt.current-pe}wt.current=new Date().getTime()})():lt.current!==1/0&&(dt.current=new Date().getTime(),ge=setTimeout(()=>{var pe;(pe=f.onAutoClose)==null||pe.call(f,f),fe()},lt.current)),()=>clearTimeout(ge)},[S,g,f,ke,M,He,fe]),w.useEffect(()=>{f.delete&&fe()},[fe,f.delete]);function tt(){var ge,pe,ye;return U!=null&&U.loading?w.createElement("div",{className:gn(I==null?void 0:I.loader,(ge=f==null?void 0:f.classNames)==null?void 0:ge.loader,"sonner-loader"),"data-visible":ke==="loading"},U.loading):$?w.createElement("div",{className:gn(I==null?void 0:I.loader,(pe=f==null?void 0:f.classNames)==null?void 0:pe.loader,"sonner-loader"),"data-visible":ke==="loading"},$):w.createElement(zI,{className:gn(I==null?void 0:I.loader,(ye=f==null?void 0:f.classNames)==null?void 0:ye.loader),visible:ke==="loading"})}return w.createElement("li",{tabIndex:0,ref:Le,className:gn(V,ct,I==null?void 0:I.toast,(t=f==null?void 0:f.classNames)==null?void 0:t.toast,I==null?void 0:I.default,I==null?void 0:I[ke],(n=f==null?void 0:f.classNames)==null?void 0:n[ke]),"data-sonner-toast":"","data-rich-colors":(r=f.richColors)!=null?r:E,"data-styled":!(f.jsx||f.unstyled||v),"data-mounted":O,"data-promise":!!f.promise,"data-swiped":Re,"data-removed":B,"data-visible":$e,"data-y-position":on,"data-x-position":It,"data-index":C,"data-front":Ve,"data-swiping":oe,"data-dismissible":Ae,"data-type":ke,"data-invert":Ct,"data-swipe-out":Ce,"data-swipe-direction":z,"data-expanded":!!(S||P&&O),style:{"--index":C,"--toasts-before":C,"--z-index":k.length-C,"--offset":`${B?De:St.current}px`,"--initial-height":P?"auto":`${ze}px`,...j,...f.style},onDragEnd:()=>{ie(!1),_(null),At.current=null},onPointerDown:ge=>{ee||!Ae||(et.current=new Date,qe(St.current),ge.target.setPointerCapture(ge.pointerId),ge.target.tagName!=="BUTTON"&&(ie(!0),At.current={x:ge.clientX,y:ge.clientY}))},onPointerUp:()=>{var ge,pe,ye,Je;if(Ce||!Ae)return;At.current=null;let nt=Number(((ge=Le.current)==null?void 0:ge.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),Nt=Number(((pe=Le.current)==null?void 0:pe.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),$t=new Date().getTime()-((ye=et.current)==null?void 0:ye.getTime()),Ee=Y==="x"?nt:Nt,ut=Math.abs(Ee)/$t;if(Math.abs(Ee)>=iN||ut>.11){qe(St.current),(Je=f.onDismiss)==null||Je.call(f,f),W(Y==="x"?nt>0?"right":"left":Nt>0?"down":"up"),fe(),ve(!0),We(!1);return}ie(!1),_(null)},onPointerMove:ge=>{var pe,ye,Je,nt;if(!At.current||!Ae||((pe=window.getSelection())==null?void 0:pe.toString().length)>0)return;let Nt=ge.clientY-At.current.y,$t=ge.clientX-At.current.x,Ee=(ye=e.swipeDirections)!=null?ye:lN(G);!Y&&(Math.abs($t)>1||Math.abs(Nt)>1)&&_(Math.abs($t)>Math.abs(Nt)?"x":"y");let ut={x:0,y:0};Y==="y"?(Ee.includes("top")||Ee.includes("bottom"))&&(Ee.includes("top")&&Nt<0||Ee.includes("bottom")&&Nt>0)&&(ut.y=Nt):Y==="x"&&(Ee.includes("left")||Ee.includes("right"))&&(Ee.includes("left")&&$t<0||Ee.includes("right")&&$t>0)&&(ut.x=$t),(Math.abs(ut.x)>0||Math.abs(ut.y)>0)&&We(!0),(Je=Le.current)==null||Je.style.setProperty("--swipe-amount-x",`${ut.x}px`),(nt=Le.current)==null||nt.style.setProperty("--swipe-amount-y",`${ut.y}px`)}},Et&&!f.jsx?w.createElement("button",{"aria-label":Z,"data-disabled":ee,"data-close-button":!0,onClick:ee||!Ae?()=>{}:()=>{var ge;fe(),(ge=f.onDismiss)==null||ge.call(f,f)},className:gn(I==null?void 0:I.closeButton,(o=f==null?void 0:f.classNames)==null?void 0:o.closeButton)},(s=U==null?void 0:U.close)!=null?s:KI):null,f.jsx||w.isValidElement(f.title)?f.jsx?f.jsx:typeof f.title=="function"?f.title():f.title:w.createElement(w.Fragment,null,ke||f.icon||f.promise?w.createElement("div",{"data-icon":"",className:gn(I==null?void 0:I.icon,(i=f==null?void 0:f.classNames)==null?void 0:i.icon)},f.promise||f.type==="loading"&&!f.icon?f.icon||tt():null,f.type!=="loading"?f.icon||(U==null?void 0:U[ke])||FI(ke):null):null,w.createElement("div",{"data-content":"",className:gn(I==null?void 0:I.content,(a=f==null?void 0:f.classNames)==null?void 0:a.content)},w.createElement("div",{"data-title":"",className:gn(I==null?void 0:I.title,(c=f==null?void 0:f.classNames)==null?void 0:c.title)},typeof f.title=="function"?f.title():f.title),f.description?w.createElement("div",{"data-description":"",className:gn(J,kt,I==null?void 0:I.description,(l=f==null?void 0:f.classNames)==null?void 0:l.description)},typeof f.description=="function"?f.description():f.description):null),w.isValidElement(f.cancel)?f.cancel:f.cancel&&bi(f.cancel)?w.createElement("button",{"data-button":!0,"data-cancel":!0,style:f.cancelButtonStyle||L,onClick:ge=>{var pe,ye;bi(f.cancel)&&Ae&&((ye=(pe=f.cancel).onClick)==null||ye.call(pe,ge),fe())},className:gn(I==null?void 0:I.cancelButton,(d=f==null?void 0:f.classNames)==null?void 0:d.cancelButton)},f.cancel.label):null,w.isValidElement(f.action)?f.action:f.action&&bi(f.action)?w.createElement("button",{"data-button":!0,"data-action":!0,style:f.actionButtonStyle||H,onClick:ge=>{var pe,ye;bi(f.action)&&((ye=(pe=f.action).onClick)==null||ye.call(pe,ge),!ge.defaultPrevented&&fe())},className:gn(I==null?void 0:I.actionButton,(p=f==null?void 0:f.classNames)==null?void 0:p.actionButton)},f.action.label):null))};function mx(){if(typeof window>"u"||typeof document>"u")return"ltr";let e=document.documentElement.getAttribute("dir");return e==="auto"||!e?window.getComputedStyle(document.documentElement).direction:e}function uN(e,t){let n={};return[e,t].forEach((r,o)=>{let s=o===1,i=s?"--mobile-offset":"--offset",a=s?rN:nN;function c(l){["top","right","bottom","left"].forEach(d=>{n[`${i}-${d}`]=typeof l=="number"?`${l}px`:l})}typeof r=="number"||typeof r=="string"?c(r):typeof r=="object"?["top","right","bottom","left"].forEach(l=>{r[l]===void 0?n[`${i}-${l}`]=a:n[`${i}-${l}`]=typeof r[l]=="number"?`${r[l]}px`:r[l]}):c(a)}),n}var dN=w.forwardRef(function(e,t){let{invert:n,position:r="bottom-right",hotkey:o=["altKey","KeyT"],expand:s,closeButton:i,className:a,offset:c,mobileOffset:l,theme:d="light",richColors:p,duration:m,style:f,visibleToasts:v=tN,toastOptions:g,dir:x=mx(),gap:y=sN,loadingIcon:b,icons:C,containerAriaLabel:k="Notifications",pauseWhenPageIsHidden:S}=e,[T,E]=w.useState([]),A=w.useMemo(()=>Array.from(new Set([r].concat(T.filter(M=>M.position).map(M=>M.position)))),[T,r]),[j,L]=w.useState([]),[H,V]=w.useState(!1),[J,R]=w.useState(!1),[G,K]=w.useState(d!=="system"?d:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),$=w.useRef(null),P=o.join("+").replace(/Key/g,"").replace(/Digit/g,""),I=w.useRef(null),U=w.useRef(!1),Z=w.useCallback(M=>{E(Y=>{var _;return(_=Y.find(z=>z.id===M.id))!=null&&_.delete||Vt.dismiss(M.id),Y.filter(({id:z})=>z!==M.id)})},[]);return w.useEffect(()=>Vt.subscribe(M=>{if(M.dismiss){E(Y=>Y.map(_=>_.id===M.id?{..._,delete:!0}:_));return}setTimeout(()=>{Lo.flushSync(()=>{E(Y=>{let _=Y.findIndex(z=>z.id===M.id);return _!==-1?[...Y.slice(0,_),{...Y[_],...M},...Y.slice(_+1)]:[M,...Y]})})})}),[]),w.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 M=window.matchMedia("(prefers-color-scheme: dark)");try{M.addEventListener("change",({matches:Y})=>{K(Y?"dark":"light")})}catch{M.addListener(({matches:_})=>{try{K(_?"dark":"light")}catch(z){console.error(z)}})}},[d]),w.useEffect(()=>{T.length<=1&&V(!1)},[T]),w.useEffect(()=>{let M=Y=>{var _,z;o.every(W=>Y[W]||Y.code===W)&&(V(!0),(_=$.current)==null||_.focus()),Y.code==="Escape"&&(document.activeElement===$.current||(z=$.current)!=null&&z.contains(document.activeElement))&&V(!1)};return document.addEventListener("keydown",M),()=>document.removeEventListener("keydown",M)},[o]),w.useEffect(()=>{if($.current)return()=>{I.current&&(I.current.focus({preventScroll:!0}),I.current=null,U.current=!1)}},[$.current]),w.createElement("section",{ref:t,"aria-label":`${k} ${P}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},A.map((M,Y)=>{var _;let[z,W]=M.split("-");return T.length?w.createElement("ol",{key:M,dir:x==="auto"?mx():x,tabIndex:-1,ref:$,className:a,"data-sonner-toaster":!0,"data-theme":G,"data-y-position":z,"data-lifted":H&&T.length>1&&!s,"data-x-position":W,style:{"--front-toast-height":`${((_=j[0])==null?void 0:_.height)||0}px`,"--width":`${oN}px`,"--gap":`${y}px`,...f,...uN(c,l)},onBlur:O=>{U.current&&!O.currentTarget.contains(O.relatedTarget)&&(U.current=!1,I.current&&(I.current.focus({preventScroll:!0}),I.current=null))},onFocus:O=>{O.target instanceof HTMLElement&&O.target.dataset.dismissible==="false"||U.current||(U.current=!0,I.current=O.relatedTarget)},onMouseEnter:()=>V(!0),onMouseMove:()=>V(!0),onMouseLeave:()=>{J||V(!1)},onDragEnd:()=>V(!1),onPointerDown:O=>{O.target instanceof HTMLElement&&O.target.dataset.dismissible==="false"||R(!0)},onPointerUp:()=>R(!1)},T.filter(O=>!O.position&&Y===0||O.position===M).map((O,D)=>{var B,Q;return w.createElement(cN,{key:O.id,icons:C,index:D,toast:O,defaultRichColors:p,duration:(B=g==null?void 0:g.duration)!=null?B:m,className:g==null?void 0:g.className,descriptionClassName:g==null?void 0:g.descriptionClassName,invert:n,visibleToasts:v,closeButton:(Q=g==null?void 0:g.closeButton)!=null?Q:i,interacting:J,position:M,style:g==null?void 0:g.style,unstyled:g==null?void 0:g.unstyled,classNames:g==null?void 0:g.classNames,cancelButtonStyle:g==null?void 0:g.cancelButtonStyle,actionButtonStyle:g==null?void 0:g.actionButtonStyle,removeToast:Z,toasts:T.filter(oe=>oe.position==O.position),heights:j.filter(oe=>oe.position==O.position),setHeights:L,expandByDefault:s,gap:y,loadingIcon:b,expanded:H,pauseWhenPageIsHidden:S,swipeDirections:e.swipeDirections})})):null}))});const fN=({...e})=>{const{theme:t="system"}=$I();return u.jsx(dN,{theme:t,className:"toaster group",toastOptions:{classNames:{toast:"group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",description:"group-[.toast]:text-muted-foreground",actionButton:"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",cancelButton:"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground"}},...e})};F.Api=ow,F.ApiClient=rw,F.ApiProvider=du,F.ArtifactRenderer=Fh,F.Badge=Yh,F.Button=Ye,F.Card=ml,F.CardContent=ti,F.CardDescription=vl,F.CardHeader=gl,F.CardTitle=xl,F.ChatApi=Jo,F.ChatApp=Kk,F.ChatInput=sp,F.ChatInputRow=ip,F.ChatInterface=Fr,F.ChatProviders=Tr,F.ChatWidget=Yk,F.Command=Al,F.CommandEmpty=_l,F.CommandGroup=Rl,F.CommandInput=Pl,F.CommandItem=Ml,F.CommandList=jl,F.DEFAULT_TIMEOUT_MS=su,F.Dialog=cl,F.DialogContent=Vs,F.DialogHeader=Ks,F.DialogTitle=qs,F.DropdownMenu=Is,F.DropdownMenuContent=xo,F.DropdownMenuItem=Fn,F.DropdownMenuTrigger=Ns,F.FileViewerModal=Th,F.HISTORY_TIMEOUT_MS=iu,F.Input=zl,F.InterruptPartRenderer=wl,F.Label=Am,F.MarkdownContent=fr,F.MessageComponent=ni,F.MessageList=Sl,F.MessageRow=yl,F.NewChatButton=Xk,F.PlotArtifact=$h,F.SETTINGS_STORAGE_KEY=Gi,F.ScrollArea=Bl,F.Select=AE,F.SelectContent=gg,F.SelectItem=xg,F.SelectTrigger=pg,F.SelectValue=PE,F.Separator=yg,F.Sheet=zE,F.SheetContent=Pg,F.SheetDescription=Rg,F.SheetHeader=jg,F.SheetTitle=_g,F.SheetTrigger=HE,F.SimpleChat=qk,F.SimpleJsonView=ei,F.Sonner=fN,F.StreamProgress=Bh,F.Switch=Ng,F.Textarea=Ma,F.ThinkingIndicator=Hh,F.ThreadListItem=Cm,F.ThreadManager=li,F.ThreadStateProvider=zu,F.ThreadsProvider=Su,F.TimelineColumn=Mx,F.Toaster=MI,F.ToolComponent=qh,F.Tooltip=dI,F.TooltipContent=Hg,F.TooltipProvider=uI,F.TooltipTrigger=fI,F.UserTextContent=Uh,F.applySettings=Pw,F.buildCheckpointIndex=lc,F.buildCheckpointPreviewMap=Sx,F.buildLabelParts=Au,F.chatApiClient=Nn,F.collectText=ku,F.createArtifactPreviewFromPlot=ju,F.createArtifactPreviewFromSource=Pu,F.del=Li,F.downloadFileById=lu,F.extractConfigFields=Ci,F.extractToolContent=tr,F.extractToolMeta=Qo,F.fileToBase64=fu,F.formatToolOutput=Tu,F.get=Yt,F.getAgentNameFromMessage=Iu,F.getChatToken=ru,F.getCheckpointForMessage=Cx,F.getCurrentSettings=Aw,F.getDefaultApiConfig=Xu,F.getDefaultChatSettings=Ju,F.getFileContent=Fi,F.getFileInfo=iw,F.getMessageAttemptInfo=cc,F.getMessageDomKey=bl,F.getPreviewForMessage=Si,F.getToolProgress=Wi,F.httpClient=Gt,F.hydrateHistorySnapshots=Yn,F.isEnvelope=hu,F.isFileLike=zi,F.listFiles=cu,F.loadStoredSettings=Zu,F.looksLikeMarkdown=Cu,F.messageSignature=Ui,F.normalizeInterruptId=Hi,F.normalizeMimeType=Nu,F.normalizeToolPayload=_u,F.normalizeToolPayloadValue=Cr,F.onChatTokenChanged=ou,F.parseJsonSafe=Qn,F.post=Xo,F.pretty=er,F.processAttachments=pu,F.put=au,F.readNumber=dc,F.readString=Rn,F.resolveChatBaseUrl=vn,F.sanitizeForDisplay=Sr,F.saveSettings=Qu,F.setChatToken=Yo,F.stringifyTool=Eu,F.toPlainObject=_n,F.unwrap=Ot,F.useApi=no,F.useCheckpointIndex=uc,F.useFilePreview=Wh,F.useHasChatSession=Ew,F.useParsedMessageContent=Vh,F.useShallowStableValue=Ku,F.useStream=qi,F.useStreamingHook=qi,F.useThreadHistoryState=Lu,F.useThreadManagerViewState=Em,F.useThreadState=oo,F.useThreadStateUpdater=Bu,F.useThreads=yr,F.useThreadsState=bu,F.viewFileById=sw,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=Ph(this.options.sanitize,this.options.baseUrl,t),t===null)return r;let o='<a href="'+t+'"';return n&&(o+=' title="'+n+'"'),o+=">"+r+"</a>",o}image(t,n,r){if(t=Ph(this.options.sanitize,this.options.baseUrl,t),t===null)return r;let o=`<img src="${t}" alt="${r}"`;return n&&(o+=` title="${n}"`),o+=this.options.xhtml?"/>":">",o}text(t){return t}}class Oh{strong(t){return t}em(t){return t}codespan(t){return t}del(t){return t}html(t){return t}text(t){return t}link(t,n,r){return""+r}image(t,n,r){return""+r}br(){return""}}class Dh{constructor(){this.seen={}}serialize(t){return t.toLowerCase().trim().replace(/<[!\/a-z].*?>/ig,"").replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g,"").replace(/\s/g,"-")}getNextSafeSlug(t,n){let r=t,o=0;if(this.seen.hasOwnProperty(r)){o=this.seen[t];do o++,r=t+"-"+o;while(this.seen.hasOwnProperty(r))}return n||(this.seen[t]=o,this.seen[r]=0),r}slug(t,n={}){const r=this.serialize(t);return this.getNextSafeSlug(r,n.dryrun)}}class Vn{constructor(t){this.options=t||dr,this.options.renderer=this.options.renderer||new hl,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new Oh,this.slugger=new Dh}static parse(t,n){return new Vn(n).parse(t)}static parseInline(t,n){return new Vn(n).parseInline(t)}parse(t,n=!0){let r="",o,s,i,a,l,c,d,p,m,f,v,g,x,y,b,C,k,S,T;const E=t.length;for(o=0;o<E;o++){if(f=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[f.type]&&(T=this.options.extensions.renderers[f.type].call({parser:this},f),T!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(f.type))){r+=T||"";continue}switch(f.type){case"space":continue;case"hr":{r+=this.renderer.hr();continue}case"heading":{r+=this.renderer.heading(this.parseInline(f.tokens),f.depth,Ah(this.parseInline(f.tokens,this.textRenderer)),this.slugger);continue}case"code":{r+=this.renderer.code(f.text,f.lang,f.escaped);continue}case"table":{for(p="",d="",a=f.header.length,s=0;s<a;s++)d+=this.renderer.tablecell(this.parseInline(f.header[s].tokens),{header:!0,align:f.align[s]});for(p+=this.renderer.tablerow(d),m="",a=f.rows.length,s=0;s<a;s++){for(c=f.rows[s],d="",l=c.length,i=0;i<l;i++)d+=this.renderer.tablecell(this.parseInline(c[i].tokens),{header:!1,align:f.align[i]});m+=this.renderer.tablerow(d)}r+=this.renderer.table(p,m);continue}case"blockquote":{m=this.parse(f.tokens),r+=this.renderer.blockquote(m);continue}case"list":{for(v=f.ordered,g=f.start,x=f.loose,a=f.items.length,m="",s=0;s<a;s++)b=f.items[s],C=b.checked,k=b.task,y="",b.task&&(S=this.renderer.checkbox(C),x?b.tokens.length>0&&b.tokens[0].type==="paragraph"?(b.tokens[0].text=S+" "+b.tokens[0].text,b.tokens[0].tokens&&b.tokens[0].tokens.length>0&&b.tokens[0].tokens[0].type==="text"&&(b.tokens[0].tokens[0].text=S+" "+b.tokens[0].tokens[0].text)):b.tokens.unshift({type:"text",text:S}):y+=S),y+=this.parse(b.tokens,x),m+=this.renderer.listitem(y,k,C);r+=this.renderer.list(m,v,g);continue}case"html":{r+=this.renderer.html(f.text);continue}case"paragraph":{r+=this.renderer.paragraph(this.parseInline(f.tokens));continue}case"text":{for(m=f.tokens?this.parseInline(f.tokens):f.text;o+1<E&&t[o+1].type==="text";)f=t[++o],m+=`
|
|
127
|
+
`+(f.tokens?this.parseInline(f.tokens):f.text);r+=n?this.renderer.paragraph(m):m;continue}default:{const A='Token with "'+f.type+'" type was not found.';if(this.options.silent){console.error(A);return}else throw new Error(A)}}}return r}parseInline(t,n){n=n||this.renderer;let r="",o,s,i;const a=t.length;for(o=0;o<a;o++){if(s=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[s.type]&&(i=this.options.extensions.renderers[s.type].call({parser:this},s),i!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type))){r+=i||"";continue}switch(s.type){case"escape":{r+=n.text(s.text);break}case"html":{r+=n.html(s.text);break}case"link":{r+=n.link(s.href,s.title,this.parseInline(s.tokens,n));break}case"image":{r+=n.image(s.href,s.title,s.text);break}case"strong":{r+=n.strong(this.parseInline(s.tokens,n));break}case"em":{r+=n.em(this.parseInline(s.tokens,n));break}case"codespan":{r+=n.codespan(s.text);break}case"br":{r+=n.br();break}case"del":{r+=n.del(this.parseInline(s.tokens,n));break}case"text":{r+=n.text(s.text);break}default:{const l='Token with "'+s.type+'" type was not found.';if(this.options.silent){console.error(l);return}else throw new Error(l)}}}return r}}class Qs{constructor(t){this.options=t||dr}preprocess(t){return t}postprocess(t){return t}}xx(Qs,"passThroughHooks",new Set(["preprocess","postprocess"]));function UT(e,t,n){return r=>{if(r.message+=`
|
|
128
|
+
Please report this to https://github.com/markedjs/marked.`,e){const o="<p>An error occurred:</p><pre>"+Ot(r.message+"",!0)+"</pre>";if(t)return Promise.resolve(o);if(n){n(null,o);return}return o}if(t)return Promise.reject(r);if(n){n(r);return}throw r}}function Lh(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...ge.defaults,...s};const i=UT(r.silent,r.async,o);if(typeof n>"u"||n===null)return i(new Error("marked(): input parameter is undefined or null"));if(typeof n!="string")return i(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(n)+", string expected"));if(BT(r),r.hooks&&(r.hooks.options=r),o){const a=r.highlight;let l;try{r.hooks&&(n=r.hooks.preprocess(n)),l=e(n,r)}catch(p){return i(p)}const c=function(p){let m;if(!p)try{r.walkTokens&&ge.walkTokens(l,r.walkTokens),m=t(l,r),r.hooks&&(m=r.hooks.postprocess(m))}catch(f){p=f}return r.highlight=a,p?i(p):o(null,m)};if(!a||a.length<3||(delete r.highlight,!l.length))return c();let d=0;ge.walkTokens(l,function(p){p.type==="code"&&(d++,setTimeout(()=>{a(p.text,p.lang,function(m,f){if(m)return c(m);f!=null&&f!==p.text&&(p.text=f,p.escaped=!0),d--,d===0&&c()})},0))}),d===0&&c();return}if(r.async)return Promise.resolve(r.hooks?r.hooks.preprocess(n):n).then(a=>e(a,r)).then(a=>r.walkTokens?Promise.all(ge.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&&ge.walkTokens(a,r.walkTokens);let l=t(a,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(a){return i(a)}}}function ge(e,t,n){return Lh(Wn.lex,Vn.parse)(e,t,n)}ge.options=ge.setOptions=function(e){return ge.defaults={...ge.defaults,...e},IT(ge.defaults),ge},ge.getDefaults=kh,ge.defaults=dr,ge.use=function(...e){const t=ge.defaults.extensions||{renderers:{},childTokens:{}};e.forEach(n=>{const r={...n};if(r.async=ge.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=ge.defaults.renderer||new hl;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=ge.defaults.tokenizer||new pl;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=ge.defaults.hooks||new Qs;for(const s in n.hooks){const i=o[s];Qs.passThroughHooks.has(s)?o[s]=a=>{if(ge.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=ge.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}}ge.setOptions(r)})},ge.walkTokens=function(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(ge,r)),r.type){case"table":{for(const o of r.header)n=n.concat(ge.walkTokens(o.tokens,t));for(const o of r.rows)for(const s of o)n=n.concat(ge.walkTokens(s.tokens,t));break}case"list":{n=n.concat(ge.walkTokens(r.items,t));break}default:ge.defaults.extensions&&ge.defaults.extensions.childTokens&&ge.defaults.extensions.childTokens[r.type]?ge.defaults.extensions.childTokens[r.type].forEach(function(o){n=n.concat(ge.walkTokens(r[o],t))}):r.tokens&&(n=n.concat(ge.walkTokens(r.tokens,t)))}return n},ge.parseInline=Lh(Wn.lexInline,Vn.parseInline),ge.Parser=Vn,ge.parser=Vn.parse,ge.Renderer=hl,ge.TextRenderer=Oh,ge.Lexer=Wn,ge.lexer=Wn.lex,ge.Tokenizer=pl,ge.Slugger=Dh,ge.Hooks=Qs,ge.parse=ge,ge.options,ge.setOptions,ge.use,ge.walkTokens,ge.parseInline,Vn.parse,Wn.lex;function fr({content:e,className:t="",allowHtml:n=!1,style:r}){const o=w.useMemo(()=>{if(!e||typeof e!="string"||e.trim().length===0)return"";try{if(!n){const i=e.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"").replace(/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi,"").replace(/javascript:/gi,"").replace(/on\w+\s*=/gi,"");return typeof ge.parse=="function"?ge.parse(i):ge(i)}return typeof ge.parse=="function"?ge.parse(e):ge(e)}catch(i){return console.error("[MarkdownContent] parse error",i),`<pre class="font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words">Error rendering markdown: ${String(i)}</pre>`}},[e,n]),s=w.useMemo(()=>{const i={color:"currentColor",...r};if(r&&r.color){const a=r.color;return{...i,"--tw-prose-body":a,"--tw-prose-headings":a,"--tw-prose-links":a,"--tw-prose-bold":a,"--tw-prose-counters":a,"--tw-prose-bullets":a,"--tw-prose-hr":a,"--tw-prose-quotes":a,"--tw-prose-quote-borders":a,"--tw-prose-captions":a,"--tw-prose-code":a,"--tw-prose-pre-code":a,"--tw-prose-pre-bg":"inherit","--tw-prose-th-borders":a,"--tw-prose-td-borders":a}}return i},[r]);return u.jsx("div",{className:ne("markdown prose prose-sm max-w-none break-words","dark:prose-invert","text-current","prose-headings:text-current prose-p:text-current prose-li:text-current prose-a:text-current prose-strong:text-current","prose-em:text-current prose-blockquote:text-current prose-table:text-current prose-td:text-current prose-th:text-current","prose-pre:font-mono prose-pre:text-xs prose-pre:bg-background/50 prose-pre:border prose-pre:rounded prose-pre:p-3 prose-pre:whitespace-pre prose-pre:overflow-x-auto","prose-code:font-mono prose-code:text-sm prose-code:bg-background/50 prose-code:px-1.5 prose-code:py-0.5 prose-code:rounded prose-code:text-current",t),style:s,dangerouslySetInnerHTML:{__html:o}})}function $h({preview:e,idx:t}){return u.jsxs("div",{className:"space-y-2",children:[e.label&&u.jsxs("p",{className:"text-[0.65rem] uppercase tracking-wide text-muted-foreground",children:["Artifact: ",e.label]}),u.jsx("div",{className:"overflow-hidden rounded border border-border/60 bg-background/60 p-1 shadow-sm",children:u.jsx("img",{src:e.src,alt:e.alt,title:e.label,loading:"lazy",className:"h-auto max-h-[420px] w-full rounded object-contain",onLoad:()=>{},onError:n=>{console.error(`[MessageComponent] ❌ Image failed to load for artifact ${t}:`,{alt:e.alt,label:e.label,message:n.target.alt})}})})]})}function Fh({artifact:e,idx:t=0}){const n=w.useMemo(()=>e?(Array.isArray(e.plots)?e.plots:[]).map(o=>ju(o)).filter(o=>o!==null):[],[e]);return n.length>0?u.jsx("div",{className:"space-y-2",children:n.map((r,o)=>u.jsx($h,{preview:r,idx:o},`${t}-plot-${o}`))}):e&&typeof e=="object"?u.jsx("div",{className:"rounded-lg border border-gray-200 dark:border-gray-800 bg-gray-50 dark:bg-gray-900/20 p-4",children:u.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:["Unknown artifact type: ",u.jsx("code",{className:"font-mono",children:e.type||"unknown"})]})}):null}const WT="prose prose-sm max-w-none break-words dark:prose-invert prose-headings:break-words prose-p:break-words prose-li:break-words prose-td:break-words prose-th:break-words prose-a:break-all prose-code:break-words prose-blockquote:break-words";function ei({data:e}){return Array.isArray(e)?e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?u.jsx("div",{className:WT,children:u.jsx("ul",{className:"list-disc pl-5",children:e.map((n,r)=>u.jsx("li",{children:String(n)},r))})}):u.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:er(e)}):u.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:er(e)})}function Bh({message:e,isStreaming:t=!1}){const n=e.name??"tool",r=w.useMemo(()=>{const a=e.additionalKwargs??{};return Array.isArray(a.toolProgress)?[...a.toolProgress]:[]},[e]),s=r.some(a=>a.type==="tool.start"||a.type==="tool.call"||a.type==="message.start")?`Running ${n}…`:void 0;return t||r.length>0?u.jsxs("div",{className:"space-y-2",children:[u.jsxs("div",{className:"flex items-center gap-2 text-xs uppercase tracking-wide text-muted-foreground",children:[t&&u.jsx(le.Loader,{className:"h-3 w-3 animate-spin"}),u.jsx("span",{children:s??`Running ${n}…`})]}),r.length>0&&u.jsx("div",{className:"space-y-2 text-xs text-muted-foreground",children:r.map((a,l)=>{var c;return u.jsxs("div",{className:"rounded border border-current/10 bg-muted/60 p-2 text-[11px] leading-snug",children:[u.jsxs("div",{className:"mb-1 flex items-center justify-between text-[8px] uppercase tracking-wide text-muted-foreground",children:[u.jsx("span",{children:((c=a.type)==null?void 0:c.replace(/\./g," "))??"progress"}),u.jsx("span",{children:a.idx??l+1})]}),a.content&&u.jsx("p",{className:"mt-1 text-[12px] text-foreground/90",children:a.content}),u.jsxs("div",{className:"mt-1 flex flex-wrap gap-2 text-[10px] opacity-70",children:[typeof a.factsFound=="number"&&u.jsxs("span",{children:["Facts found: ",a.factsFound]}),typeof a.isSufficient=="boolean"&&u.jsxs("span",{children:["Research ",a.isSufficient?"sufficient":"needs more data"]})]})]},`tool-progress-${n}-${l}`)})})]}):null}const ml=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:ne("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));ml.displayName="Card";const gl=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:ne("flex flex-col space-y-1.5 p-6",e),...t}));gl.displayName="CardHeader";const xl=h.forwardRef(({className:e,...t},n)=>u.jsx("h3",{ref:n,className:ne("text-2xl font-semibold leading-none tracking-tight",e),...t}));xl.displayName="CardTitle";const vl=h.forwardRef(({className:e,...t},n)=>u.jsx("p",{ref:n,className:ne("text-sm text-muted-foreground",e),...t}));vl.displayName="CardDescription";const ti=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:ne("p-6 pt-0",e),...t}));ti.displayName="CardContent";const zh=h.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:ne("flex items-center p-6 pt-0",e),...t}));zh.displayName="CardFooter";const VT=e=>!!e&&typeof e=="object"&&e.type==="user_choice"&&typeof e.question=="string"&&Array.isArray(e.alternatives);function wl({interruptPart:e,onApprove:t,onReject:n,onSelectAlternative:r,disabled:o,isActive:s,payload:i}){const a=VT(i)?i:null,l=(a==null?void 0:a.question)??e.title??"Approve the result?",c=a?s?"Select one of the alternatives to continue.":"Waiting for approval from another participant.":s?"Please approve or reject this action to resume the workflow.":"Waiting for approval from another participant.";let d=null;if(!a&&i!==void 0&&i!==null)if(typeof i=="string")d=u.jsx("p",{className:"text-sm leading-relaxed text-blue-800/90 dark:text-blue-200/90 whitespace-pre-wrap",children:i});else{const p=er(i);d=u.jsx("pre",{className:"max-h-48 overflow-auto rounded bg-blue-100/60 p-2 text-xs text-blue-900/90 dark:bg-blue-900/40 dark:text-blue-100/80",children:p})}return u.jsxs(ml,{className:ne("border-blue-200 dark:border-blue-800 bg-blue-50/50 dark:bg-blue-950/10 transition-shadow",s?"shadow-md ring-1 ring-blue-300 dark:ring-blue-500/70":"opacity-80"),children:[u.jsxs(gl,{className:"pb-3",children:[u.jsx(xl,{className:"text-blue-900 dark:text-blue-100 text-base",children:l}),u.jsx(vl,{className:"text-blue-700 dark:text-blue-300 text-sm",children:c})]}),a?u.jsx(ti,{className:"pt-0 pb-3",children:u.jsx("div",{className:"space-y-2",children:a.alternatives.map(p=>u.jsx(Ye,{size:"sm",variant:"outline",onClick:()=>r==null?void 0:r(e,p),className:"w-full justify-start text-left",disabled:o||!s,children:u.jsxs("div",{className:"flex flex-col items-start gap-1",children:[u.jsx("span",{className:"font-semibold",children:p.label}),p.description?u.jsx("span",{className:"text-xs text-muted-foreground leading-snug",children:p.description}):null]})},p.id))})}):d&&u.jsx(ti,{className:"pt-0 pb-3",children:d}),!a&&u.jsx(zh,{className:"pt-0",children:u.jsxs("div",{className:"flex gap-2 ml-auto",children:[u.jsx(Ye,{size:"sm",variant:"outline",onClick:()=>n(e),className:"border-red-300 text-red-700 hover:bg-red-50 dark:border-red-700 dark:text-red-300 dark:hover:bg-red-950/50",disabled:o||!s,children:"Reject"}),u.jsx(Ye,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",disabled:o||!s,children:"Approve"})]})})]})}function Hh({className:e}){const t=w.useRef(null);return w.useEffect(()=>{let n=0;const r=()=>{if(n=(n+1)%4,t.current){const s=".".repeat(n);t.current.textContent=`Is thinking${s}`}};r();const o=setInterval(r,500);return()=>clearInterval(o)},[]),u.jsx("span",{ref:t,"aria-live":"polite",className:ne("inline-block text-xs opacity-70 ml-1",e),children:"Is thinking"})}function Uh({text:e,expanded:t,onExpandedChange:n,previewLength:r,isCompact:o}){const s=Math.max(e.length-r,0),i=e.substring(0,r);return u.jsxs("div",{className:"flex flex-col gap-1",children:[u.jsx("div",{className:ne("text-sm text-[hsl(var(--chat-bubble-user-text))]",o&&"text-xs"),children:t?u.jsx(fr,{content:e,allowHtml:!1}):u.jsxs("pre",{className:ne("font-sans whitespace-pre-wrap break-words bg-transparent p-0 m-0 text-[hsl(var(--chat-bubble-user-text))]",o&&"text-xs"),children:[i,"..."]})}),u.jsx(Ye,{type:"button",variant:"ghost",size:"sm",className:"h-6 text-xs !text-[hsl(var(--chat-bubble-user-text))]",onClick:()=>n(!t),children:t?u.jsxs(u.Fragment,{children:[u.jsx(le.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):u.jsxs(u.Fragment,{children:[u.jsx(le.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",s," chars)"]})})]})}function Wh(e){const{allowFileOpen:t,currentThreadId:n}=e,{toast:r}=fl(),[o,s]=w.useState({}),[i,a]=w.useState(null),[l,c]=w.useState(!1),d=w.useCallback(()=>{c(!1),a(null)},[]),p=w.useCallback(f=>{a(f),c(!0)},[]),m=w.useCallback(async(f,v,g)=>{var x,y;if(!t){f.preventDefault();return}if(o[g]){f.preventDefault();return}try{const b=String(v.url??""),C=b.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);if(C){f.preventDefault();const k=C[1],S=v.name||`file_${k}`,T=v.mimeType||"application/octet-stream";p({id:k,name:S,mimeType:T});return}if(b.startsWith("data:")){f.preventDefault(),s(S=>({...S,[g]:!0}));const k=r({title:"Fetching file...",description:"",open:!0});try{const S=await cu(n??void 0);if(!S||!Array.isArray(S))throw new Error("Invalid file list response");const T=S.find(E=>!E||typeof E!="object"||!((E.filename??"")===(v.name??""))?!1:typeof v.size=="number"&&typeof E.size=="number"?E.size===v.size:!0);if(!(T!=null&&T.id))throw new Error(`File "${v.name}" is not yet available on the server`);if(!T.id||!T.filename)throw new Error("Invalid file data received from server");p({id:T.id,name:v.name||T.filename||`file_${T.id}`,mimeType:v.mimeType||T.mime_type||"application/octet-stream"}),(x=k.update)==null||x.call(k,{id:k.id,title:"Success",description:`Opened ${v.name}`,open:!0})}catch(S){console.error("Failed to fetch server file:",S);const T=S instanceof Error?S.message:"Unknown error occurred";(y=k.update)==null||y.call(k,{id:k.id,title:"Failed",description:T}),r({title:"Failed to fetch file",description:T,open:!0})}finally{s(S=>({...S,[g]:!1}))}}}catch(b){console.error("File click error:",b),s(C=>({...C,[g]:!1}))}},[t,o,r,n,p]);return{uploadingFiles:o,handleFileClick:m,fileViewerOpen:l,currentFileInfo:i,closeFileViewer:d}}function Vh(e,t){return w.useMemo(()=>{if(t)return{contentParts:[],textContent:"",toolMeta:{},imageParts:[],fileParts:[],interruptParts:[],toolRaw:"",isToolStreaming:!1};const n=e,r=Array.isArray(n.content)?n.content:[],o=n.additionalKwargs??{};return{contentParts:r,textContent:ku(r),toolMeta:Qo(n),imageParts:r.filter(s=>s.type==="image_url"),fileParts:r.filter(s=>s.type==="file"),interruptParts:r.filter(s=>s.type==="interrupt"),toolRaw:Eu(r),isToolStreaming:!!o.toolStreaming}},[e,t])}const Kh="data:";function KT(e){if(!e)return[];const t=[],n=e.split(/\r?\n/);for(const r of n){const o=r.trim();if(!o||!o.startsWith(Kh))continue;const s=o.slice(Kh.length).trim();if(!s||s.toLowerCase()==="[done]")continue;const i=Qn(s);i&&typeof i=="object"&&t.push(i)}return t}function qT(e){for(let t=e.length-1;t>=0;t-=1){const n=e[t];if(n&&typeof n=="object"&&n.type==="tool.end")return n}return null}function GT(e){return w.useMemo(()=>{const t=e.content.filter(c=>c.type==="text");if(!t.length)return null;let r=t.flatMap(c=>KT(c.text??""));if(!r.length){const c=t.map(p=>p.text??"").join(`
|
|
129
|
+
`),d=Qn(c);d&&typeof d=="object"&&(r=[d])}if(!r.length)return null;const s=qT(r)??r[r.length-1];if(!s)return null;const i=s.output??s.payload??s,a=Cr(i),l=tr(a);return l&&typeof l=="object"&&!Array.isArray(l)?{kind:"dict",value:l,data:l,event:s}:{kind:"generic",value:l,event:s}},[e])}function qh({message:e,viewMode:t,isStreaming:n=!1,toolRenderers:r,toolArtifactRenderers:o,expandable:s=!1}){var $;const i=Qo(e),a=e.artifact??null,l=GT(e),d=(l?_u(l):null)??l,p=e.content.find(L=>L.type!=="tool_call"),m=L=>{if(L==null)return null;const H=typeof L=="string"?Qn(L)??L:L;if(H&&typeof H=="object")return u.jsx(ei,{data:H});const Y=typeof H=="string"?H:(()=>{try{return er(H)}catch{return String(H??"")}})();return u.jsx("pre",{className:"whitespace-pre-wrap break-words font-sans text-sm text-foreground/90",children:Y})},f=L=>{if(L==null)return null;const{content:H,isMarkdown:Y}=Tu(L);return Y?u.jsx(fr,{content:H,className:"text-current"}):m(L)},v=L=>u.jsxs("div",{className:"space-y-2 rounded-2xl border border-muted-foreground/30 bg-white/80 p-4 shadow-sm shadow-slate-900/10",children:[u.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-[0.4em] text-muted-foreground",children:"Structured dictionary"}),u.jsx(ei,{data:L})]}),g=()=>{if((d==null?void 0:d.kind)==="generic")return f(d.value);if(!p)return null;if(p.type==="text"){const _=(p.text??"").trim();if(!_)return null;const V=tr(_);return f(V)}const L=Sr(p),H=tr(L);return f(H)},x=()=>(d==null?void 0:d.kind)==="dict"?v(d.data):g(),b=(()=>{if(!r)return;if(i.name){const H=r[i.name];if(H)return H}const L=(d==null?void 0:d.kind)??(l==null?void 0:l.kind);if(L){const H=r[L];if(H)return H}return r.default})(),C=(b==null?void 0:b({message:e,toolMeta:i,toolPayload:d,viewMode:t,isStreaming:n}))??null,S=(($=(()=>{if(!o)return;const L=a==null?void 0:a.type;if(typeof L=="string"){const H=o[L];if(H)return H}return o.default})())==null?void 0:$({artifact:a,message:e,toolPayload:d,isStreaming:n}))??null,T=x(),E=s&&t==="preview",A=!s||t==="expanded",P=C??(s?null:T);return u.jsxs("div",{className:"space-y-2",children:[a&&(S??u.jsx(Fh,{artifact:a,idx:0})),u.jsx(Bh,{message:e,isStreaming:n}),E?T:null,A?P:null]})}const YT={checkpoints:[],checkpointMetaByCheckpointId:new Map,timeline:[],messagePreviews:new Map,getLatest:()=>{},getCheckpoint:()=>{},getMessageAttempts:()=>[]},bl=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,yl=w.memo(function({message:t,index:n,isStreaming:r,streamingAssistantId:o,streamingDebounceMs:s,layoutSize:i,enableMessageEditing:a,editingMessageId:l,onEdit:c,onRegenerate:d,onCancelEdit:p,showToolMessages:m,checkpointIndex:f,onSelectCheckpoint:v,getMessageCustomStyles:g,getInterruptOptions:x,toolRenderers:y,toolArtifactRenderers:b,getToolExpandable:C}){const k=bl(t,n),S=t.role==="default_message",E=!!t.__syntheticStreaming,A=f??YT,P=!S&&"checkpointId"in t?t.checkpointId??null:null,{attemptCount:$,attemptIndex:L,attempts:H}=w.useMemo(()=>cc(t.id,P,A),[t.id,P,A]),Y=g==null?void 0:g(t);return u.jsx("div",{className:"relative mb-4 last:mb-0","data-message-id":k,style:{minHeight:"60px",containIntrinsicSize:"auto 120px"},children:u.jsx(ni,{message:t,messageIndex:n,isStreamingMessage:E||r&&o===t.id&&t.role==="assistant",streamingDebounceMs:s,isEditing:l===t.id,showActions:a,showTimestamp:!1,showAgentName:!0,layoutSize:i,onEdit:c,onRegenerate:()=>d(n),onCancelEdit:p,getInterruptOptions:x,showToolMessages:m,attemptCount:$,attemptIndex:L,attemptMetas:H,onSelectCheckpoint:v,customStyles:Y,toolRenderers:y,toolArtifactRenderers:b,getToolExpandable:C})})});yl.displayName="MessageRow";function XT(e,t,n){const[r,o]=w.useState(e),s=w.useRef([]);return w.useEffect(()=>{if(!t){o(e),s.current=e.map(a=>a.type==="text"?a.text??"":void 0);return}const i=e.map((a,l)=>{if(a.type!=="text")return s.current[l]=void 0,a;const c=a.text??"",d=s.current[l];return n(c)?(s.current[l]=c,a):{...a,text:d??""}});o(i)},[e,t,n]),r}function JT({message:e,isToolMessage:t,showToolMessages:n,toolViewMode:r,toolExpandable:o,isToolStreaming:s,contentParts:i,textContent:a,imageParts:l,fileParts:c,interruptPart:d,isStreamingMessage:p,enableStreamingMarkdownBuffer:m,renderStreamingMarkdown:f,defaultMessage:v,handleFileClick:g,uploadingFiles:x,messageRole:y,truncateUserMessages:b,userMessagePreviewLength:C,isUserExpanded:k,setIsUserExpanded:S,isCompactLayout:T,iconForeground:E,toolRenderers:A,toolArtifactRenderers:P,handleInterruptApprove:$,handleInterruptReject:L,handleInterruptAlternative:H,disableInterruptActions:Y,isInterruptMessage:_}){const V=w.useCallback(()=>u.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/30 rounded",children:[u.jsx(le.Loader,{className:"h-4 w-4 text-muted-foreground"}),u.jsx("span",{className:"text-sm text-muted-foreground",children:"File upload"})]}),[]),W=XT(i,(m??!0)&&p,Gh),D=w.useMemo(()=>W.filter(M=>M.type==="text"),[W]),I=w.useMemo(()=>D.map(M=>M.text??"").join(""),[D]),U=w.useMemo(()=>{if(!f)return null;const M=ZT(I);return{stablePart:I.slice(0,M),tailPart:I.slice(M)}},[I,f]),Z=w.useMemo(()=>{if(!U)return null;const{stablePart:M,tailPart:O}=U;return!M&&!O?null:u.jsxs("div",{className:"space-y-2",children:[M?u.jsx(fr,{content:M,allowHtml:!1}):null,O?u.jsx(fr,{content:O,allowHtml:!1}):null]})},[U]),R=w.useMemo(()=>{if(!f)return W;const M=[];let O=!1;for(const F of W){if(F.type==="text"){O||(M.push({type:"text",text:"",__streamingMarkdownAggregate:!0}),O=!0);continue}M.push(F)}return M},[W,f]),j=(f?R:W).filter(M=>M.type!=="interrupt"),B=w.useCallback(({part:M,i:O})=>{if(M.type==="text"){if(f)return null;const F=M.text??"",J=F.trim(),oe=Qn(J);return oe&&y!=="tool"?u.jsx(ei,{data:oe},O):y==="user"&&b&&J.length>C?u.jsx(Uh,{text:J,expanded:k,onExpandedChange:S,previewLength:C,isCompact:T},O):u.jsx(fr,{content:F,allowHtml:!1},O)}if(M.type==="image_url"){const F=M;return u.jsx("div",{className:"my-2",children:u.jsx("img",{src:F.url,alt:F.alt??"",loading:"lazy",className:"border rounded max-h-[420px] w-auto object-contain"})},O)}if(M.type==="file"){const F=M,J=F.name||"file";return u.jsxs("a",{href:F.url,onClick:oe=>g(oe,F,O),className:`inline-flex items-center gap-2 rounded px-2 py-1 text-xs bg-gray-100 border hover:bg-gray-200
|
|
130
|
+
dark:bg-background/10 dark:border-border/30 dark:hover:bg-background/20`,children:[x[O]?u.jsx(le.Loader,{className:"h-4 w-4 animate-spin"}):null,u.jsxs("span",{className:"truncate max-w-[180px]",children:[J,x[O]?" (processing)":""]})]},O)}return null},[g,T,k,y,b,x,C,f,S]),Q=a.trim().length>0||l.length>0||c.length>0||j.length>0;if(!t&&c.length>0&&!p)return V();if(!t&&!Q&&!p)return null;if(t){if(!n)return null;if(_&&d){const M=d.value,O=!Y,F=$??(()=>{}),J=L??(()=>{});return u.jsx(wl,{interruptPart:d,payload:M,onApprove:F,onReject:J,onSelectAlternative:H,disabled:Y,isActive:O})}return u.jsx(qh,{message:e,viewMode:r,expandable:o,isStreaming:s,toolRenderers:A,toolArtifactRenderers:P},e.id)}if(!v){const M=u.jsx("div",{className:"space-y-2",children:j.map((O,F)=>f&&QT(O)?Z?u.jsx("div",{className:"space-y-2",children:Z},`streaming-md-${F}`):null:u.jsx(B,{part:O,i:F},F))});return p?u.jsxs("div",{"aria-busy":"true",role:"status",children:[M,u.jsx(Hh,{className:E})]}):M}return null}function Gh(e){return e?!(jo(e,/```/g)||jo(e,/`/g)||jo(e,/\*\*/g)||jo(e,/__/g)||jo(e,/~~/g)||/[^\\]\[[^\]]*$/.test(e)||/\[[^\]]*\]\([^)]*$/.test(e)):!0}function jo(e,t){const n=e.match(t);return((n==null?void 0:n.length)??0)%2!==0}function ZT(e){if(!e)return 0;for(let t=e.length;t>=0;t-=1)if(Gh(e.slice(0,t)))return t;return 0}function QT(e){return e.type==="text"&&!!e.__streamingMarkdownAggregate}const ek=Kr.cva("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function Yh({className:e,variant:t,...n}){return u.jsx("div",{className:ne(ek({variant:t}),e),...n})}function tk({showTimestamp:e,showAgentName:t,isToolMessage:n,isInterruptMessage:r=!1,iconForeground:o,agentName:s,messageIcon:i,customHeaderClass:a,customActionsClass:l,isCompactLayout:c,showActions:d,isEditing:p,messageRole:m,toolViewMode:f,toolExpandable:v=!1,toolMeta:g,onToggleToolView:x,onCopy:y,onEdit:b,onRegenerate:C,showCheckpointControls:k,attemptCount:S,attemptIndex:T,handleOlderAttemptSelect:E,handleNewerAttemptSelect:A,messageCreatedAt:P,copied:$}){return!e&&!t&&!n&&!r?null:u.jsxs("div",{className:ne("flex items-center justify-between mb-2 pb-2 border-b border-current/10",c&&"mb-1 pb-1",o,a),children:[u.jsxs("div",{className:"flex items-center gap-2",children:[i,t&&s&&u.jsx("span",{className:ne("font-medium",c?"text-xs":"text-sm"),children:s}),n&&!r&&u.jsxs(Yh,{variant:"outline",className:ne("text-xs flex items-center gap-1",o,"border border-current/40",c&&"text-xs h-4",v&&"cursor-pointer select-none"),role:v?"button":void 0,tabIndex:v?0:void 0,"aria-expanded":v?f==="expanded":void 0,onClick:v?x:void 0,onKeyDown:L=>{v&&(L.key==="Enter"||L.key===" ")&&(L.preventDefault(),x())},children:[u.jsx("span",{children:g.name??"Tool Output"}),g.toolCallId&&u.jsx("span",{className:"opacity-70",children:g.toolCallId.slice(0,8)}),v&&(f==="expanded"?u.jsx(le.ChevronUp,{className:"h-3 w-3"}):u.jsx(le.ChevronDown,{className:"h-3 w-3"}))]}),r&&u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:g.name??"Interrupt"})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[k&&S>1&&u.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[u.jsx("button",{type:"button",className:ne("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",T<S-1?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{T>=S-1||E()},"aria-label":"Older attempt (back in time)",disabled:T>=S-1,children:u.jsx(le.ChevronLeft,{className:"h-3 w-3"})}),u.jsx("div",{className:"flex items-center gap-2",children:u.jsxs("span",{className:"whitespace-nowrap",children:[S-T," / ",S]})}),u.jsx("button",{type:"button",className:ne("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",T>0?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{T<=0||A()},"aria-label":"Newer attempt (forward in time)",disabled:T<=0,children:u.jsx(le.ChevronRight,{className:"h-3 w-3"})})]}),e&&P&&u.jsx("time",{className:ne("text-xs opacity-60",o,c&&"text-xs"),dateTime:new Date(P).toISOString(),title:new Date(P).toLocaleString(),children:new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(new Date(P))}),d&&!p&&u.jsxs("div",{className:ne("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",l),children:[u.jsx("div",{className:"relative",children:u.jsx(Ye,{variant:"ghost",size:"sm",onClick:y,className:ne("h-6 w-6 p-0 hover:bg-foreground/10",o,c&&"h-5 w-5"),"aria-label":"Copy message",title:"Copy message",children:u.jsx(le.Copy,{className:ne($?"text-success":o,c?"h-3 w-3":"h-4 w-4")})})}),m==="user"&&b&&u.jsx(Ye,{variant:"ghost",size:"sm",onClick:b,className:ne("h-6 w-6 p-0 hover:bg-foreground/10",o,c&&"h-5 w-5"),"aria-label":"Edit message",children:u.jsx(le.Edit,{className:ne(o,c?"h-3 w-3":"h-4 w-4")})}),m==="assistant"&&C&&u.jsx(Ye,{variant:"ghost",size:"sm",onClick:C,className:ne("h-6 w-6 p-0 hover:bg-foreground/10",o,c&&"h-5 w-5"),"aria-label":"Regenerate response",children:u.jsx(le.RotateCcw,{className:ne(o,c?"h-3 w-3":"h-4 w-4")})})]})]})]})}const ni=w.memo(function({message:t,messageIndex:n,isStreamingMessage:r=!1,isEditing:o=!1,showActions:s=!0,showTimestamp:i=!0,showAgentName:a=!0,layoutSize:l="desktop",truncateUserMessages:c=!0,userMessagePreviewLength:d=500,showToolMessages:p=!0,toolRenderers:m,toolArtifactRenderers:f,getToolExpandable:v,customStyles:g={},streamingDebounceMs:x=300,renderStreamingMarkdown:y=!1,enableStreamingMarkdownBuffer:b,onEdit:C,onRegenerate:k,onCopy:S,getInterruptOptions:T,attemptCount:E=1,attemptIndex:A=0,onSelectCheckpoint:P,attemptMetas:$=[]}){const[L,H]=w.useState(!1),[Y,_]=w.useState(!1),{currentThreadId:V}=yr(),{respondToInterrupt:G}=oo(),[W,D]=w.useState(!1),I=l==="phone"||l==="half-screen",U=t.role,Z=U==="interrupt",R=U==="tool"||Z,j=!(t.role==="default_message")&&t.expandable!==void 0?t.expandable!==!1:!0,B=w.useMemo(()=>!v||t.role!=="tool"?!1:v(t),[v,t.id,t.role]),[Q,M]=w.useState(B?"preview":"expanded");w.useEffect(()=>{M(B?"preview":"expanded")},[B,t.id]);const O=w.useMemo(()=>t.role==="default_message"?t:null,[t]),F=!!O,J=!(r&&U!=="user"),{uploadingFiles:oe,handleFileClick:ae,fileViewerOpen:Se,currentFileInfo:we,closeFileViewer:Re}=Wh({allowFileOpen:J,currentThreadId:V}),$e=w.useMemo(()=>{switch(U){case"user":return"text-[hsl(var(--chat-bubble-user-text))]";case"assistant":return"text-[hsl(var(--chat-bubble-ai-text))]";case"interrupt":return"text-[hsl(var(--chat-bubble-ai-text))]";case"tool":return"text-secondary-foreground";case"system":return"text-muted-foreground";default:return"text-[hsl(var(--chat-bubble-ai-text))]"}},[U]),Fe=Vh(t,O),{contentParts:Ge,imageParts:Je,fileParts:vt,textContent:ct,toolMeta:tt,toolRaw:Oe,isToolStreaming:Ve,interruptParts:He}=Fe,Te=b??x!==0,Ae=w.useMemo(()=>He.length?He[0]:null,[He]),ut=w.useCallback(async()=>{const de=R?Oe:ct;async function Pe(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 Pe(de),H(!0),setTimeout(()=>H(!1),2e3),S==null||S(de)}catch(Me){console.error("Failed to copy:",Me)}},[R,Oe,ct,S]),dt=w.useCallback(async(de,Pe)=>{if(!Ae)return;if(!Hi(Ae.id)){console.warn("Interrupt part missing id",Ae);return}D(!0);try{const Ze=T==null?void 0:T(t);await G(de,Pe,Ze)}catch(Ze){console.error("Failed to respond to interrupt:",Ze)}finally{D(!1)}},[Ae,G]),it=w.useCallback(()=>dt(!0),[dt]),At=w.useCallback(()=>dt(!1),[dt]),St=w.useCallback((de,Pe)=>{if(!Pe)return;const Me={alternativeId:Pe.id??Pe.label??void 0,alternativeLabel:Pe.label};dt(!0,Me)},[dt]),ft=w.useCallback(()=>{if(!C||!t.id)return;const de=(R?Oe:ct)??"",Pe="type"in t&&t.type==="default_message"?void 0:{checkpointId:t.checkpointId??null,checkpointNs:t.checkpointNs??null};C(t.id,de,Pe)},[C,R,Oe,ct,t]),Ct=w.useCallback(()=>{k==null||k(n)},[k,n]),Tt=w.useCallback(()=>{const Pe=ne(I?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",$e);switch(U){case"user":return u.jsx(le.User,{className:Pe});case"assistant":return u.jsx(le.Bot,{className:Pe});case"tool":return u.jsx(le.Wrench,{className:Pe});case"interrupt":return u.jsx(le.Bot,{className:Pe});default:return u.jsx(le.Bot,{className:Pe})}},[I,$e,U]),It=w.useCallback(()=>{const de="group relative mb-4 flex w-full";switch(U){case"user":return ne(de,"justify-end");case"assistant":case"tool":case"system":case"interrupt":return ne(de,"justify-start");default:return de}},[U]),en=w.useCallback(()=>{const de=ne("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",I&&"px-3 py-2 text-sm");if(F)return ne(de,"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(U){case"user":return ne(de,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-user))] text-[hsl(var(--chat-bubble-user-text))]","border border-transparent");case"assistant":return ne(de,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40");case"tool":case"interrupt":return ne(de,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return ne(de,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return ne(de,"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")}},[I,F,U]),kt=B&&!Z&&j,Ie=w.useCallback(()=>{kt&&M(de=>de==="expanded"?"preview":"expanded")},[kt]),Nt=Z?"expanded":Q,te=(p||Z)&&j,xe=u.jsx(JT,{message:t,isToolMessage:R,showToolMessages:te,toolViewMode:Nt,toolExpandable:B,isToolStreaming:Ve,contentParts:Ge,textContent:ct,imageParts:Je,fileParts:vt,isStreamingMessage:r,defaultMessage:O,enableStreamingMarkdownBuffer:Te,renderStreamingMarkdown:y,handleFileClick:ae,uploadingFiles:oe,messageRole:U,truncateUserMessages:c,userMessagePreviewLength:d,isUserExpanded:Y,setIsUserExpanded:_,isCompactLayout:I,iconForeground:$e,toolRenderers:m,toolArtifactRenderers:f,interruptPart:Ae,handleInterruptApprove:it,handleInterruptReject:At,handleInterruptAlternative:St,disableInterruptActions:W,isInterruptMessage:Z}),nt=w.useMemo(()=>O?"Assistant":Iu(t),[O,t]),me=Tt(),Ne=U==="user"&&(E??1)>1&&typeof P=="function",Ue=($==null?void 0:$.length)??0,at=Ue>0&&A<Ue-1?$[A+1]:void 0,rt=Ue>0&&A>0?$[A-1]:void 0,wt=w.useCallback(()=>{!at||!P||P(at.id,void 0,!!at.isLatestAttempt)},[at,P]),Pt=w.useCallback(()=>{!rt||!P||P(rt.id,void 0,!!rt.isLatestAttempt)},[rt,P]);return R&&!p?null:F&&O?u.jsx("div",{className:ne(It(),g.container),children:u.jsxs("div",{className:ne(en(),g.content),children:[u.jsxs("div",{className:"flex items-center gap-2 mb-2 pb-2 border-b border-current/10",children:[u.jsx(le.Bot,{className:ne("h-4 w-4",$e)}),a&&u.jsx("span",{className:"font-medium text-sm",children:"Assistant"})]}),u.jsx(fr,{content:O.content,className:"text-current"})]})}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:ne(It(),g.container),children:u.jsxs("div",{className:ne(en(),g.content),children:[u.jsx(tk,{showTimestamp:i,showAgentName:a,isToolMessage:R,iconForeground:$e,agentName:nt,messageIcon:me,customHeaderClass:g.header,customActionsClass:g.actions,isCompactLayout:I,showActions:s,isEditing:o,messageRole:U,toolViewMode:Nt,toolExpandable:B,isInterruptMessage:Z,toolMeta:tt,onToggleToolView:Ie,onCopy:ut,onEdit:ft,onRegenerate:Ct,showCheckpointControls:Ne,attemptCount:E,attemptIndex:A,handleOlderAttemptSelect:wt,handleNewerAttemptSelect:Pt,messageCreatedAt:t.createdAt,copied:L}),u.jsx("div",{className:"relative",children:xe}),!(i||a||R)&&s&&!o&&u.jsxs("div",{className:ne("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",g.actions),children:[u.jsx(Ye,{variant:"ghost",size:"sm",onClick:()=>ut(),className:ne("h-6 w-6 p-0 hover:bg-background/50 text-current",I&&"h-5 w-5"),children:u.jsx(le.Copy,{className:ne(L?"text-success":"text-current",I?"h-3 w-3":"h-4 w-4")})}),U==="user"&&C&&u.jsx(Ye,{variant:"ghost",size:"sm",onClick:ft,className:ne("h-6 w-6 p-0 hover:bg-background/50 text-current",I&&"h-5 w-5"),children:u.jsx(le.Edit,{className:ne("text-current",I?"h-3 w-3":"h-4 w-4")})}),U==="assistant"&&k&&u.jsx(Ye,{variant:"ghost",size:"sm",onClick:Ct,className:ne("h-6 w-6 p-0 hover:bg-background/50 text-current",I&&"h-5 w-5"),children:u.jsx(le.RotateCcw,{className:ne("text-current",I?"h-3 w-3":"h-4 w-4")})})]})]})}),we&&u.jsx(Th,{isOpen:Se,onClose:Re,fileId:we.id,fileName:we.name,mimeType:we.mimeType})]})},(e,t)=>{var l,c,d,p,m,f,v,g;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&Ui(e.message)===Ui(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateUserMessages","userMessagePreviewLength","showToolMessages","toolRenderers","toolArtifactRenderers"].every(x=>e[x]===t[x]),s=((l=e.customStyles)==null?void 0:l.container)===((c=t.customStyles)==null?void 0:c.container)&&((d=e.customStyles)==null?void 0:d.content)===((p=t.customStyles)==null?void 0:p.content)&&((m=e.customStyles)==null?void 0:m.actions)===((f=t.customStyles)==null?void 0:f.actions)&&((v=e.customStyles)==null?void 0:v.header)===((g=t.customStyles)==null?void 0:g.header);if(!o||!s)return!1;const i=Wi(e.message),a=Wi(t.message);return i.length===a.length});ni.displayName="MessageComponent";const Sl=w.forwardRef(({messages:e,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onStartReached:a,onEdit:l,onRegenerate:c,onCancelEdit:d,className:p,style:m,emptyMessage:f,followNewMessages:v=!0,isNavigatingCheckpoint:g=!1,onScrollAway:x,onAtBottom:y,showToolMessages:b=!0,toolRenderers:C,toolArtifactRenderers:k,checkpointIndex:S,activeCheckpointId:T,onSelectCheckpoint:E,createSyntheticThinkingMessage:A=!0,forceSyntheticThinking:P=!1,getMessageCustomStyles:$,getToolExpandable:L,getInterruptOptions:H},Y)=>{const _=w.useRef(null),V=w.useRef(null),G=w.useRef(!1),W=w.useRef(!1),D=e,I=w.useMemo(()=>{const F=n&&D.some(oe=>oe.id===n);return A&&(t||P)&&!F&&D.length>0?[...D,{id:"thinking-assistant",role:"assistant",content:[{type:"text",text:""}],createdAt:new Date().toISOString(),__syntheticStreaming:!0}]:D},[D,t,n,A,P]),U=w.useMemo(()=>b?I:I.filter(F=>(F==null?void 0:F.role)!=="tool"),[I,b]),Z=w.useCallback(F=>{x&&x(!F),y&&y(F)},[x,y]),R=w.useMemo(()=>{if(a)return async()=>{if(!G.current){G.current=!0;try{await a()}finally{G.current=!1}}}},[a]),q=w.useMemo(()=>!v||g?!1:"auto",[v,g]),j=w.useMemo(()=>{if(typeof f!="string")return null;const F=f.trim();return!F||U&&U.length>0?null:{id:"default-message",role:"default_message",content:F,createdAt:new Date().toISOString()}},[f,U]),B=["flex h-full flex-col md:flex-row",p].filter(Boolean).join(" "),Q=()=>{if(j){const F=$==null?void 0:$(j);return u.jsx("div",{className:"p-6 h-full overflow-y-auto",children:u.jsx("div",{className:"w-full max-w-full",children:u.jsx(ni,{message:j,messageIndex:0,isStreamingMessage:!1,showActions:!1,showTimestamp:!1,showAgentName:!0,layoutSize:o,onEdit:()=>{},onRegenerate:()=>{},onCancelEdit:()=>{},customStyles:F,getInterruptOptions:H})})})}return u.jsx("div",{className:"flex h-full items-center justify-center py-8 text-center text-muted-foreground",children:f??"No messages yet. Start a conversation!"})},M=U.length,O=M>0;return w.useEffect(()=>{var F,J;if(M===0){W.current=!1;return}if(!W.current)if(W.current=!0,_.current&&U.length>0){const oe=U.length-1;(J=(F=_.current).scrollToIndex)==null||J.call(F,{index:oe,align:"end",behavior:"auto"})}else V.current&&(V.current.scrollTop=V.current.scrollHeight)},[M,U.length]),w.useImperativeHandle(Y,()=>({scrollToLatest:()=>{var F,J;if(_.current&&U.length>0){const oe=U.length-1;(J=(F=_.current).scrollToIndex)==null||J.call(F,{index:oe,align:"end",behavior:"auto"})}else V.current&&(V.current.scrollTop=V.current.scrollHeight)},scrollToTop:()=>{var F,J;_.current&&U.length>0?(J=(F=_.current).scrollToIndex)==null||J.call(F,{index:0,align:"start",behavior:"auto"}):V.current&&(V.current.scrollTop=0)}}),[U]),u.jsx("div",{className:B,style:m,children:u.jsx("div",{className:"relative flex-1 min-h-0",children:O?u.jsx(YC,{ref:F=>{_.current=F},scrollerRef:F=>{V.current=F instanceof HTMLDivElement?F:null},data:U,followOutput:q,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,startReached:()=>{R&&R()},atBottomStateChange:Z,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(F,J)=>bl(J,F),itemContent:(F,J)=>u.jsx(yl,{message:J,index:F,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onEdit:l,onRegenerate:c,onCancelEdit:d,showToolMessages:b,toolRenderers:C,toolArtifactRenderers:k,checkpointIndex:S,activeCheckpointId:T,onSelectCheckpoint:E,getMessageCustomStyles:$,getToolExpandable:L,getInterruptOptions:H})}):Q()})})});Sl.displayName="MessageList";const Xh={value:""};function Fr({className:e="",placeholder:t="Type your message...",autoFocus:n=!0,maxHeight:r=void 0,streamingDebounceMs:o=500,streamingThrottleMs:s,followNewMessages:i=!0,enableFileUpload:a=!0,enableExcelUpload:l=!1,enableMessageEditing:c=!0,showToolMessages:d=!0,toolRenderers:p,toolArtifactRenderers:m,payloadExtras:f={},customStyles:v={},messageCustomStyles:g,onMessageSent:x,onExcelUploadSuccess:y,onError:b,defaultMessage:C}){const{api:k}=no(),S=k.baseUrl,{currentThreadId:T}=yr(),{threadId:E,messages:A,isLoading:P,navigateToCheckpoint:$,returnToLatest:L,checkpoint:H,checkpoints:Y,interrupt:_,metadata:V,checkpointIndex:G,respondToInterrupt:W}=oo(),{isStreaming:D,error:I,connectionState:U,submit:Z,stop:R}=qi(),q=E??T??null,j=(H==null?void 0:H.id)??null,B=(H==null?void 0:H.namespace)??null,Q=(V==null?void 0:V.assemblingMessageId)??null,M=_,O=M?Hi(M.id):null,F=O!==null?{type:"interrupt",id:O}:null,[J,oe]=w.useState(!1),[ae,Se]=w.useState(!1);w.useEffect(()=>{M||oe(!1)},[M]);const we=w.useCallback(()=>{oe(!0)},[]),Re=w.useCallback(()=>{oe(!1)},[]),$e=w.useCallback(N=>{},[]),Fe=w.useCallback(async(N,X,re)=>{try{we(),await W(N,X,re)}catch(fe){console.error("Failed to respond to interrupt:",fe)}finally{Re()}},[Re,we,W]),Ge=w.useCallback(()=>Fe(!0),[Fe]),Je=w.useCallback(()=>Fe(!1),[Fe]),vt=w.useCallback((N,X)=>Fe(!0,X),[Fe]),ct=!!M||J,[tt,Oe]=w.useState(null),[Ve,He]=w.useState(""),[Te,Ae]=w.useState(null),[ut,dt]=w.useState(null),[it,At]=w.useState(!1),[St,ft]=w.useState(null),Ct=w.useRef(!1),[Tt,It]=w.useState(()=>Xh.value),en=w.useRef(Tt),kt=w.useRef(null),Ie=w.useCallback(N=>{Xh.value=N,It(N)},[]),[Ke,Nt]=w.useState(!1),te=w.useRef(null),xe=w.useCallback(N=>{Ie(N)},[Ie]);w.useEffect(()=>{D||Se(!1)},[D]),w.useEffect(()=>{V!=null&&V.assemblingMessageId&&Se(!1)},[V==null?void 0:V.assemblingMessageId]);const[nt,me]=w.useState("desktop");w.useEffect(()=>{const N=()=>{const X=window.innerWidth;me(X<640?"phone":X<1024?"tablet":"desktop")};return N(),window.addEventListener("resize",N),()=>window.removeEventListener("resize",N)},[]),w.useEffect(()=>{Ct.current=!1},[q]),w.useEffect(()=>{en.current=Tt},[Tt]),w.useEffect(()=>{if(!tt){kt.current=null;return}kt.current===null&&(kt.current=en.current),Ie(Ve??"")},[Ve,tt,Ie]),w.useEffect(()=>{if(C!==void 0){ft(C);return}(async()=>{if(!S){ft(null);return}try{const re=(await k.getAgent("default")).uiDefaultMessage||"";ft(re||null)}catch(X){console.warn("Failed to fetch default message:",X),ft(null)}})()},[k,S,C]),w.useEffect(()=>{I&&!it&&(b==null||b(I))},[I,it,b]);const Ne=async(N,X)=>{const re=N.trim();if(!(!re&&X.length===0))try{const fe=tt?(Te==null?void 0:Te.checkpointId)??j??void 0:j??void 0,De=tt?(Te==null?void 0:Te.checkpointNs)??B??void 0:B??void 0;await Z({text:re||"",attachments:X,payload:f},{checkpointId:fe,checkpointNs:De,edit:!!tt,originalMessageId:tt??void 0}),x==null||x(re),Se(!0),Ie(""),dt(null),Oe(null),He(""),Ae(null)}catch(fe){const De=(fe==null?void 0:fe.message)||"Failed to send message";dt(De),b==null||b(De),Se(!1)}},Ue=w.useCallback(async N=>{await Z({attachments:[N],payload:f},{checkpointId:j??void 0,checkpointNs:B??void 0}),y==null||y({file:N})},[j,B,f,y,Z]),at=w.useCallback((N,X,re)=>{c&&(kt.current=Tt,Oe(N),He(X),Ie(X),dt(null),Ae({checkpointId:(re==null?void 0:re.checkpointId)??null,checkpointNs:(re==null?void 0:re.checkpointNs)??null}))},[Tt,c,Ie]),rt=w.useCallback(()=>{Oe(null),He(""),Ae(null),dt(null),Ie(kt.current??Tt),kt.current=null},[Tt,Ie]),wt=w.useCallback((N,X,re)=>{at(N,X,re)},[at]),Pt=w.useCallback(N=>{let X=null;for(let Le=N-1;Le>=0;Le--)if(A[Le].role==="user"){X=A[Le];break}if(!X)return;const re=Array.isArray(X.content)?X.content:[],De=re.filter(Le=>(Le==null?void 0:Le.type)==="text").map(Le=>Le.text).join("")||(()=>{try{return JSON.stringify(re,null,2)}catch{return String(re)}})();De&&Z({text:De,payload:f},{checkpointId:j??void 0,checkpointNs:B??void 0,edit:!0,originalMessageId:X.id})},[A,Z,j,B,f]),de=w.useCallback(async N=>{if(T){Nt(!0);try{if(!N){await L(),requestAnimationFrame(()=>{var fe;(fe=te.current)==null||fe.scrollToLatest()});return}const X=Y.find(fe=>fe.checkpointId===N),re=(X==null?void 0:X.checkpointNs)??null;await $(N,re),requestAnimationFrame(()=>{var fe;(fe=te.current)==null||fe.scrollToTop()})}finally{Nt(!1)}}},[Y,T,te,$,L]),Pe=w.useCallback(async(N,X,re)=>{await de(re?null:N)},[de]),Me=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${v.container||""}`,Ze=`flex-1 min-h-0 min-w-0 max-h-full w-full overflow-hidden overscroll-contain break-words break-anywhere p-4 ${M?"pb-32":""} bg-transparent ${v.messagesArea||""}`,sn=`relative flex-shrink-0 w-full border-t p-4 bg-transparent ${v.inputArea||""}`;return u.jsxs("div",{className:Me,children:[!!I&&!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:I}),u.jsx(Ye,{variant:"ghost",size:"sm",onClick:()=>At(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:u.jsx(le.X,{size:16})})]}),u.jsxs("div",{className:`relative ${Ze}`,style:r?{maxHeight:r}:void 0,children:[u.jsx(Sl,{ref:te,className:"h-full",style:{height:"100%"},messages:A,isStreaming:D,streamingAssistantId:Q,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:nt,enableMessageEditing:c,editingMessageId:tt,onEdit:wt,onRegenerate:Pt,onCancelEdit:rt,emptyMessage:St??void 0,isNavigatingCheckpoint:Ke,showToolMessages:d,toolRenderers:p,toolArtifactRenderers:m,checkpointIndex:G,activeCheckpointId:j,onSelectCheckpoint:Pe,createSyntheticThinkingMessage:!0,forceSyntheticThinking:ae,getMessageCustomStyles:g,getInterruptOptions:$e}),(U==="reconnecting"||U==="connecting")&&u.jsx("div",{className:"pointer-events-none absolute top-3 right-3 z-20 rounded-full bg-muted/80 px-3 py-1 text-xs font-medium text-foreground shadow-sm backdrop-blur-sm dark:bg-muted/60",children:u.jsxs("span",{className:"flex items-center gap-2",children:[u.jsx(le.Loader2,{className:"h-3 w-3 animate-spin"}),U==="reconnecting"?"Reconnecting…":"Connecting…"]})}),U==="error"&&u.jsx("div",{className:"pointer-events-none absolute top-3 right-3 z-20 rounded-full bg-destructive/10 px-3 py-1 text-xs font-semibold text-destructive shadow-sm",children:"Connection lost"}),P&&u.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 bg-background/80 backdrop-blur-sm text-muted-foreground",children:[u.jsx(le.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading messages…"})]}),Ke&&u.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 bg-background/80 backdrop-blur-sm text-muted-foreground",children:[u.jsx(le.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading checkpoint…"})]}),M&&F&&u.jsx("div",{className:"pointer-events-auto absolute inset-x-0 bottom-6 z-30 flex justify-center px-4",children:u.jsx("div",{className:"w-full max-w-3xl",children:u.jsx(wl,{interruptPart:F,onApprove:Ge,onReject:Je,onSelectAlternative:vt,disabled:J,isActive:!0,payload:M.value})})})]}),u.jsxs("div",{className:sn,children:[tt&&u.jsx("div",{className:"mb-3 p-3 bg-blue-50 border border-blue-200 rounded-lg",children:u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(le.Edit3,{size:16,className:"text-blue-600"}),u.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),u.jsx(Ye,{variant:"ghost",size:"sm",onClick:rt,className:"text-blue-600 hover:bg-blue-100",children:u.jsx(le.X,{size:16})})]})}),ut&&u.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:ut}),u.jsx(FS,{composerValue:Tt,onComposerChange:xe,onSend:Ne,onCancelEdit:rt,onStop:R,editingMessageId:tt,editingInitialValue:Ve,placeholder:tt?"Edit your message...":t,isStreaming:D,disabled:ct,enableFileUpload:a,enableExcelUpload:l,onExcelUpload:Ue,onError:b,customStyles:v,textareaClassName:v.textarea||"",allowEmptySend:!1,inputError:ut})]})]})}var Jh=1,nk=.9,rk=.8,ok=.17,Cl=.1,Tl=.999,sk=.9999,ik=.99,ak=/[\\\/_+.#"@\[\(\{&]/,lk=/[\\\/_+.#"@\[\(\{&]/g,ck=/[\s-]/,Zh=/[\s-]/g;function kl(e,t,n,r,o,s,i){if(s===t.length)return o===e.length?Jh:ik;var a=`${o},${s}`;if(i[a]!==void 0)return i[a];for(var l=r.charAt(s),c=n.indexOf(l,o),d=0,p,m,f,v;c>=0;)p=kl(e,t,n,r,c+1,s+1,i),p>d&&(c===o?p*=Jh:ak.test(e.charAt(c-1))?(p*=rk,f=e.slice(o,c-1).match(lk),f&&o>0&&(p*=Math.pow(Tl,f.length))):ck.test(e.charAt(c-1))?(p*=nk,v=e.slice(o,c-1).match(Zh),v&&o>0&&(p*=Math.pow(Tl,v.length))):(p*=ok,o>0&&(p*=Math.pow(Tl,c-o))),e.charAt(c)!==t.charAt(s)&&(p*=sk)),(p<Cl&&n.charAt(c-1)===r.charAt(s+1)||r.charAt(s+1)===r.charAt(s)&&n.charAt(c-1)!==r.charAt(s))&&(m=kl(e,t,n,r,c+1,s+2,i),m*Cl>p&&(p=m*Cl)),p>d&&(d=p),c=n.indexOf(l,c+1);return i[a]=d,d}function Qh(e){return e.toLowerCase().replace(Zh," ")}function uk(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,kl(e,t,Qh(e),Qh(t),0,0,{})}var _o='[cmdk-group=""]',El='[cmdk-group-items=""]',dk='[cmdk-group-heading=""]',em='[cmdk-item=""]',tm=`${em}:not([aria-disabled="true"])`,Il="cmdk-item-select",Br="data-value",fk=(e,t,n)=>uk(e,t,n),nm=h.createContext(void 0),Ro=()=>h.useContext(nm),rm=h.createContext(void 0),Nl=()=>h.useContext(rm),om=h.createContext(void 0),sm=h.forwardRef((e,t)=>{let n=zr(()=>{var R,q;return{search:"",value:(q=(R=e.value)!=null?R:e.defaultValue)!=null?q:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=zr(()=>new Set),o=zr(()=>new Map),s=zr(()=>new Map),i=zr(()=>new Set),a=im(e),{label:l,children:c,value:d,onValueChange:p,filter:m,shouldFilter:f,loop:v,disablePointerSelection:g=!1,vimBindings:x=!0,...y}=e,b=_t(),C=_t(),k=_t(),S=h.useRef(null),T=Ck();pr(()=>{if(d!==void 0){let R=d.trim();n.current.value=R,E.emit()}},[d]),pr(()=>{T(6,Y)},[]);let E=h.useMemo(()=>({subscribe:R=>(i.current.add(R),()=>i.current.delete(R)),snapshot:()=>n.current,setState:(R,q,j)=>{var B,Q,M,O;if(!Object.is(n.current[R],q)){if(n.current[R]=q,R==="search")H(),$(),T(1,L);else if(R==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let F=document.getElementById(k);F?F.focus():(B=document.getElementById(b))==null||B.focus()}if(T(7,()=>{var F;n.current.selectedItemId=(F=_())==null?void 0:F.id,E.emit()}),j||T(5,Y),((Q=a.current)==null?void 0:Q.value)!==void 0){let F=q??"";(O=(M=a.current).onValueChange)==null||O.call(M,F);return}}E.emit()}},emit:()=>{i.current.forEach(R=>R())}}),[]),A=h.useMemo(()=>({value:(R,q,j)=>{var B;q!==((B=s.current.get(R))==null?void 0:B.value)&&(s.current.set(R,{value:q,keywords:j}),n.current.filtered.items.set(R,P(q,j)),T(2,()=>{$(),E.emit()}))},item:(R,q)=>(r.current.add(R),q&&(o.current.has(q)?o.current.get(q).add(R):o.current.set(q,new Set([R]))),T(3,()=>{H(),$(),n.current.value||L(),E.emit()}),()=>{s.current.delete(R),r.current.delete(R),n.current.filtered.items.delete(R);let j=_();T(4,()=>{H(),(j==null?void 0:j.getAttribute("id"))===R&&L(),E.emit()})}),group:R=>(o.current.has(R)||o.current.set(R,new Set),()=>{s.current.delete(R),o.current.delete(R)}),filter:()=>a.current.shouldFilter,label:l||e["aria-label"],getDisablePointerSelection:()=>a.current.disablePointerSelection,listId:b,inputId:k,labelId:C,listInnerRef:S}),[]);function P(R,q){var j,B;let Q=(B=(j=a.current)==null?void 0:j.filter)!=null?B:fk;return R?Q(R,n.current.search,q):0}function $(){if(!n.current.search||a.current.shouldFilter===!1)return;let R=n.current.filtered.items,q=[];n.current.filtered.groups.forEach(B=>{let Q=o.current.get(B),M=0;Q.forEach(O=>{let F=R.get(O);M=Math.max(F,M)}),q.push([B,M])});let j=S.current;V().sort((B,Q)=>{var M,O;let F=B.getAttribute("id"),J=Q.getAttribute("id");return((M=R.get(J))!=null?M:0)-((O=R.get(F))!=null?O:0)}).forEach(B=>{let Q=B.closest(El);Q?Q.appendChild(B.parentElement===Q?B:B.closest(`${El} > *`)):j.appendChild(B.parentElement===j?B:B.closest(`${El} > *`))}),q.sort((B,Q)=>Q[1]-B[1]).forEach(B=>{var Q;let M=(Q=S.current)==null?void 0:Q.querySelector(`${_o}[${Br}="${encodeURIComponent(B[0])}"]`);M==null||M.parentElement.appendChild(M)})}function L(){let R=V().find(j=>j.getAttribute("aria-disabled")!=="true"),q=R==null?void 0:R.getAttribute(Br);E.setState("value",q||void 0)}function H(){var R,q,j,B;if(!n.current.search||a.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let Q=0;for(let M of r.current){let O=(q=(R=s.current.get(M))==null?void 0:R.value)!=null?q:"",F=(B=(j=s.current.get(M))==null?void 0:j.keywords)!=null?B:[],J=P(O,F);n.current.filtered.items.set(M,J),J>0&&Q++}for(let[M,O]of o.current)for(let F of O)if(n.current.filtered.items.get(F)>0){n.current.filtered.groups.add(M);break}n.current.filtered.count=Q}function Y(){var R,q,j;let B=_();B&&(((R=B.parentElement)==null?void 0:R.firstChild)===B&&((j=(q=B.closest(_o))==null?void 0:q.querySelector(dk))==null||j.scrollIntoView({block:"nearest"})),B.scrollIntoView({block:"nearest"}))}function _(){var R;return(R=S.current)==null?void 0:R.querySelector(`${em}[aria-selected="true"]`)}function V(){var R;return Array.from(((R=S.current)==null?void 0:R.querySelectorAll(tm))||[])}function G(R){let q=V()[R];q&&E.setState("value",q.getAttribute(Br))}function W(R){var q;let j=_(),B=V(),Q=B.findIndex(O=>O===j),M=B[Q+R];(q=a.current)!=null&&q.loop&&(M=Q+R<0?B[B.length-1]:Q+R===B.length?B[0]:B[Q+R]),M&&E.setState("value",M.getAttribute(Br))}function D(R){let q=_(),j=q==null?void 0:q.closest(_o),B;for(;j&&!B;)j=R>0?yk(j,_o):Sk(j,_o),B=j==null?void 0:j.querySelector(tm);B?E.setState("value",B.getAttribute(Br)):W(R)}let I=()=>G(V().length-1),U=R=>{R.preventDefault(),R.metaKey?I():R.altKey?D(1):W(1)},Z=R=>{R.preventDefault(),R.metaKey?G(0):R.altKey?D(-1):W(-1)};return h.createElement(pe.div,{ref:t,tabIndex:-1,...y,"cmdk-root":"",onKeyDown:R=>{var q;(q=y.onKeyDown)==null||q.call(y,R);let j=R.nativeEvent.isComposing||R.keyCode===229;if(!(R.defaultPrevented||j))switch(R.key){case"n":case"j":{x&&R.ctrlKey&&U(R);break}case"ArrowDown":{U(R);break}case"p":case"k":{x&&R.ctrlKey&&Z(R);break}case"ArrowUp":{Z(R);break}case"Home":{R.preventDefault(),G(0);break}case"End":{R.preventDefault(),I();break}case"Enter":{R.preventDefault();let B=_();if(B){let Q=new Event(Il);B.dispatchEvent(Q)}}}}},h.createElement("label",{"cmdk-label":"",htmlFor:A.inputId,id:A.labelId,style:kk},l),ri(e,R=>h.createElement(rm.Provider,{value:E},h.createElement(nm.Provider,{value:A},R))))}),pk=h.forwardRef((e,t)=>{var n,r;let o=_t(),s=h.useRef(null),i=h.useContext(om),a=Ro(),l=im(e),c=(r=(n=l.current)==null?void 0:n.forceMount)!=null?r:i==null?void 0:i.forceMount;pr(()=>{if(!c)return a.item(o,i==null?void 0:i.id)},[c]);let d=am(o,s,[e.value,e.children,s],e.keywords),p=Nl(),m=Kn(T=>T.value&&T.value===d.current),f=Kn(T=>c||a.filter()===!1?!0:T.search?T.filtered.items.get(o)>0:!0);h.useEffect(()=>{let T=s.current;if(!(!T||e.disabled))return T.addEventListener(Il,v),()=>T.removeEventListener(Il,v)},[f,e.onSelect,e.disabled]);function v(){var T,E;g(),(E=(T=l.current).onSelect)==null||E.call(T,d.current)}function g(){p.setState("value",d.current,!0)}if(!f)return null;let{disabled:x,value:y,onSelect:b,forceMount:C,keywords:k,...S}=e;return h.createElement(pe.div,{ref:Mn(s,t),...S,id:o,"cmdk-item":"",role:"option","aria-disabled":!!x,"aria-selected":!!m,"data-disabled":!!x,"data-selected":!!m,onPointerMove:x||a.getDisablePointerSelection()?void 0:g,onClick:x?void 0:v},e.children)}),hk=h.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:o,...s}=e,i=_t(),a=h.useRef(null),l=h.useRef(null),c=_t(),d=Ro(),p=Kn(f=>o||d.filter()===!1?!0:f.search?f.filtered.groups.has(i):!0);pr(()=>d.group(i),[]),am(i,a,[e.value,e.heading,l]);let m=h.useMemo(()=>({id:i,forceMount:o}),[o]);return h.createElement(pe.div,{ref:Mn(a,t),...s,"cmdk-group":"",role:"presentation",hidden:p?void 0:!0},n&&h.createElement("div",{ref:l,"cmdk-group-heading":"","aria-hidden":!0,id:c},n),ri(e,f=>h.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?c:void 0},h.createElement(om.Provider,{value:m},f))))}),mk=h.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,o=h.useRef(null),s=Kn(i=>!i.search);return!n&&!s?null:h.createElement(pe.div,{ref:Mn(o,t),...r,"cmdk-separator":"",role:"separator"})}),gk=h.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,o=e.value!=null,s=Nl(),i=Kn(c=>c.search),a=Kn(c=>c.selectedItemId),l=Ro();return h.useEffect(()=>{e.value!=null&&s.setState("search",e.value)},[e.value]),h.createElement(pe.input,{ref:t,...r,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":l.listId,"aria-labelledby":l.labelId,"aria-activedescendant":a,id:l.inputId,type:"text",value:o?e.value:i,onChange:c=>{o||s.setState("search",c.target.value),n==null||n(c.target.value)}})}),xk=h.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...o}=e,s=h.useRef(null),i=h.useRef(null),a=Kn(c=>c.selectedItemId),l=Ro();return h.useEffect(()=>{if(i.current&&s.current){let c=i.current,d=s.current,p,m=new ResizeObserver(()=>{p=requestAnimationFrame(()=>{let f=c.offsetHeight;d.style.setProperty("--cmdk-list-height",f.toFixed(1)+"px")})});return m.observe(c),()=>{cancelAnimationFrame(p),m.unobserve(c)}}},[]),h.createElement(pe.div,{ref:Mn(s,t),...o,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":a,"aria-label":r,id:l.listId},ri(e,c=>h.createElement("div",{ref:Mn(i,l.listInnerRef),"cmdk-list-sizer":""},c)))}),vk=h.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:o,contentClassName:s,container:i,...a}=e;return h.createElement(al,{open:n,onOpenChange:r},h.createElement(ll,{container:i},h.createElement(No,{"cmdk-overlay":"",className:o}),h.createElement(Ao,{"aria-label":e.label,"cmdk-dialog":"",className:s},h.createElement(sm,{ref:t,...a}))))}),wk=h.forwardRef((e,t)=>Kn(n=>n.filtered.count===0)?h.createElement(pe.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),bk=h.forwardRef((e,t)=>{let{progress:n,children:r,label:o="Loading...",...s}=e;return h.createElement(pe.div,{ref:t,...s,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":o},ri(e,i=>h.createElement("div",{"aria-hidden":!0},i)))}),Wt=Object.assign(sm,{List:xk,Item:pk,Input:gk,Group:hk,Separator:mk,Dialog:vk,Empty:wk,Loading:bk});function yk(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function Sk(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function im(e){let t=h.useRef(e);return pr(()=>{t.current=e}),t}var pr=typeof window>"u"?h.useEffect:h.useLayoutEffect;function zr(e){let t=h.useRef();return t.current===void 0&&(t.current=e()),t}function Kn(e){let t=Nl(),n=()=>e(t.snapshot());return h.useSyncExternalStore(t.subscribe,n,n)}function am(e,t,n,r=[]){let o=h.useRef(),s=Ro();return pr(()=>{var i;let a=(()=>{var c;for(let d of n){if(typeof d=="string")return d.trim();if(typeof d=="object"&&"current"in d)return d.current?(c=d.current.textContent)==null?void 0:c.trim():o.current}})(),l=r.map(c=>c.trim());s.value(e,a,l),(i=t.current)==null||i.setAttribute(Br,a),o.current=a}),o}var Ck=()=>{let[e,t]=h.useState(),n=zr(()=>new Map);return pr(()=>{n.current.forEach(r=>r()),n.current=new Map},[e]),(r,o)=>{n.current.set(r,o),t({})}};function Tk(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function ri({asChild:e,children:t},n){return e&&h.isValidElement(t)?h.cloneElement(Tk(t),{ref:t.ref},n(t.props.children)):n(t)}var kk={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const Al=h.forwardRef(({className:e,...t},n)=>u.jsx(Wt,{ref:n,className:ne("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));Al.displayName=Wt.displayName;const Pl=h.forwardRef(({className:e,...t},n)=>u.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[u.jsx(le.Search,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),u.jsx(Wt.Input,{ref:n,className:ne("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),...t})]}));Pl.displayName=Wt.Input.displayName;const jl=h.forwardRef(({className:e,...t},n)=>u.jsx(Wt.List,{ref:n,className:ne("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));jl.displayName=Wt.List.displayName;const _l=h.forwardRef((e,t)=>u.jsx(Wt.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));_l.displayName=Wt.Empty.displayName;const Rl=h.forwardRef(({className:e,...t},n)=>u.jsx(Wt.Group,{ref:n,className:ne("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",e),...t}));Rl.displayName=Wt.Group.displayName;const Ek=h.forwardRef(({className:e,...t},n)=>u.jsx(Wt.Separator,{ref:n,className:ne("-mx-1 h-px bg-border",e),...t}));Ek.displayName=Wt.Separator.displayName;const Ml=h.forwardRef(({className:e,...t},n)=>u.jsx(Wt.Item,{ref:n,className:ne("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected='true']:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50",e),...t}));Ml.displayName=Wt.Item.displayName;function Ol(e,[t,n]){return Math.min(n,Math.max(t,e))}function Ik(e,t){return h.useReducer((n,r)=>t[n][r]??n,e)}var Dl="ScrollArea",[lm,WN]=cn(Dl),[Nk,on]=lm(Dl),cm=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,l]=h.useState(null),[c,d]=h.useState(null),[p,m]=h.useState(null),[f,v]=h.useState(null),[g,x]=h.useState(null),[y,b]=h.useState(0),[C,k]=h.useState(0),[S,T]=h.useState(!1),[E,A]=h.useState(!1),P=je(t,L=>l(L)),$=ts(o);return u.jsx(Nk,{scope:n,type:r,dir:$,scrollHideDelay:s,scrollArea:a,viewport:c,onViewportChange:d,content:p,onContentChange:m,scrollbarX:f,onScrollbarXChange:v,scrollbarXEnabled:S,onScrollbarXEnabledChange:T,scrollbarY:g,onScrollbarYChange:x,scrollbarYEnabled:E,onScrollbarYEnabledChange:A,onCornerWidthChange:b,onCornerHeightChange:k,children:u.jsx(pe.div,{dir:$,...i,ref:P,style:{position:"relative","--radix-scroll-area-corner-width":y+"px","--radix-scroll-area-corner-height":C+"px",...e.style}})})});cm.displayName=Dl;var um="ScrollAreaViewport",dm=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=on(um,n),a=h.useRef(null),l=je(t,a,i.onViewportChange);return u.jsxs(u.Fragment,{children:[u.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:o}),u.jsx(pe.div,{"data-radix-scroll-area-viewport":"",...s,ref: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})})]})});dm.displayName=um;var In="ScrollAreaScrollbar",Ll=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=on(In,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:i}=o,a=e.orientation==="horizontal";return h.useEffect(()=>(a?s(!0):i(!0),()=>{a?s(!1):i(!1)}),[a,s,i]),o.type==="hover"?u.jsx(Ak,{...r,ref:t,forceMount:n}):o.type==="scroll"?u.jsx(Pk,{...r,ref:t,forceMount:n}):o.type==="auto"?u.jsx(fm,{...r,ref:t,forceMount:n}):o.type==="always"?u.jsx($l,{...r,ref:t}):null});Ll.displayName=In;var Ak=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=on(In,e.__scopeScrollArea),[s,i]=h.useState(!1);return h.useEffect(()=>{const a=o.scrollArea;let l=0;if(a){const c=()=>{window.clearTimeout(l),i(!0)},d=()=>{l=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",c),a.addEventListener("pointerleave",d),()=>{window.clearTimeout(l),a.removeEventListener("pointerenter",c),a.removeEventListener("pointerleave",d)}}},[o.scrollArea,o.scrollHideDelay]),u.jsx(Ht,{present:n||s,children:u.jsx(fm,{"data-state":s?"visible":"hidden",...r,ref:t})})}),Pk=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=on(In,e.__scopeScrollArea),s=e.orientation==="horizontal",i=ai(()=>l("SCROLL_END"),100),[a,l]=Ik("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return h.useEffect(()=>{if(a==="idle"){const c=window.setTimeout(()=>l("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(c)}},[a,o.scrollHideDelay,l]),h.useEffect(()=>{const c=o.viewport,d=s?"scrollLeft":"scrollTop";if(c){let p=c[d];const m=()=>{const f=c[d];p!==f&&(l("SCROLL"),i()),p=f};return c.addEventListener("scroll",m),()=>c.removeEventListener("scroll",m)}},[o.viewport,s,l,i]),u.jsx(Ht,{present:n||a!=="hidden",children:u.jsx($l,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:ie(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:ie(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),fm=h.forwardRef((e,t)=>{const n=on(In,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=h.useState(!1),a=e.orientation==="horizontal",l=ai(()=>{if(n.viewport){const c=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?c:d)}},10);return Hr(n.viewport,l),Hr(n.content,l),u.jsx(Ht,{present:r||s,children:u.jsx($l,{"data-state":s?"visible":"hidden",...o,ref:t})})}),$l=h.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=on(In,e.__scopeScrollArea),s=h.useRef(null),i=h.useRef(0),[a,l]=h.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),c=xm(a.viewport,a.content),d={...r,sizes:a,onSizesChange:l,hasThumb:c>0&&c<1,onThumbChange:m=>s.current=m,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:m=>i.current=m};function p(m,f){return Dk(m,i.current,a,f)}return n==="horizontal"?u.jsx(jk,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollLeft,f=vm(m,a,o.dir);s.current.style.transform=`translate3d(${f}px, 0, 0)`}},onWheelScroll:m=>{o.viewport&&(o.viewport.scrollLeft=m)},onDragScroll:m=>{o.viewport&&(o.viewport.scrollLeft=p(m,o.dir))}}):n==="vertical"?u.jsx(_k,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollTop,f=vm(m,a);s.current.style.transform=`translate3d(0, ${f}px, 0)`}},onWheelScroll:m=>{o.viewport&&(o.viewport.scrollTop=m)},onDragScroll:m=>{o.viewport&&(o.viewport.scrollTop=p(m))}}):null}),jk=h.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=on(In,e.__scopeScrollArea),[i,a]=h.useState(),l=h.useRef(null),c=je(t,l,s.onScrollbarXChange);return h.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(hm,{"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":ii(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.x),onDragScroll:d=>e.onDragScroll(d.x),onWheelScroll:(d,p)=>{if(s.viewport){const m=s.viewport.scrollLeft+d.deltaX;e.onWheelScroll(m),bm(m,p)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:l.current.clientWidth,paddingStart:si(i.paddingLeft),paddingEnd:si(i.paddingRight)}})}})}),_k=h.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=on(In,e.__scopeScrollArea),[i,a]=h.useState(),l=h.useRef(null),c=je(t,l,s.onScrollbarYChange);return h.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(hm,{"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":ii(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.y),onDragScroll:d=>e.onDragScroll(d.y),onWheelScroll:(d,p)=>{if(s.viewport){const m=s.viewport.scrollTop+d.deltaY;e.onWheelScroll(m),bm(m,p)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:l.current.clientHeight,paddingStart:si(i.paddingTop),paddingEnd:si(i.paddingBottom)}})}})}),[Rk,pm]=lm(In),hm=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:l,onDragScroll:c,onWheelScroll:d,onResize:p,...m}=e,f=on(In,n),[v,g]=h.useState(null),x=je(t,P=>g(P)),y=h.useRef(null),b=h.useRef(""),C=f.viewport,k=r.content-r.viewport,S=ht(d),T=ht(l),E=ai(p,10);function A(P){if(y.current){const $=P.clientX-y.current.left,L=P.clientY-y.current.top;c({x:$,y:L})}}return h.useEffect(()=>{const P=$=>{const L=$.target;(v==null?void 0:v.contains(L))&&S($,k)};return document.addEventListener("wheel",P,{passive:!1}),()=>document.removeEventListener("wheel",P,{passive:!1})},[C,v,k,S]),h.useEffect(T,[r,T]),Hr(v,E),Hr(f.content,E),u.jsx(Rk,{scope:n,scrollbar:v,hasThumb:o,onThumbChange:ht(s),onThumbPointerUp:ht(i),onThumbPositionChange:T,onThumbPointerDown:ht(a),children:u.jsx(pe.div,{...m,ref:x,style:{position:"absolute",...m.style},onPointerDown:ie(e.onPointerDown,P=>{P.button===0&&(P.target.setPointerCapture(P.pointerId),y.current=v.getBoundingClientRect(),b.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",f.viewport&&(f.viewport.style.scrollBehavior="auto"),A(P))}),onPointerMove:ie(e.onPointerMove,A),onPointerUp:ie(e.onPointerUp,P=>{const $=P.target;$.hasPointerCapture(P.pointerId)&&$.releasePointerCapture(P.pointerId),document.body.style.webkitUserSelect=b.current,f.viewport&&(f.viewport.style.scrollBehavior=""),y.current=null})})})}),oi="ScrollAreaThumb",mm=h.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=pm(oi,e.__scopeScrollArea);return u.jsx(Ht,{present:n||o.hasThumb,children:u.jsx(Mk,{ref:t,...r})})}),Mk=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=on(oi,n),i=pm(oi,n),{onThumbPositionChange:a}=i,l=je(t,p=>i.onThumbChange(p)),c=h.useRef(void 0),d=ai(()=>{c.current&&(c.current(),c.current=void 0)},100);return h.useEffect(()=>{const p=s.viewport;if(p){const m=()=>{if(d(),!c.current){const f=Lk(p,a);c.current=f,a()}};return a(),p.addEventListener("scroll",m),()=>p.removeEventListener("scroll",m)}},[s.viewport,d,a]),u.jsx(pe.div,{"data-state":i.hasThumb?"visible":"hidden",...o,ref:l,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:ie(e.onPointerDownCapture,p=>{const f=p.target.getBoundingClientRect(),v=p.clientX-f.left,g=p.clientY-f.top;i.onThumbPointerDown({x:v,y:g})}),onPointerUp:ie(e.onPointerUp,i.onThumbPointerUp)})});mm.displayName=oi;var Fl="ScrollAreaCorner",gm=h.forwardRef((e,t)=>{const n=on(Fl,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?u.jsx(Ok,{...e,ref:t}):null});gm.displayName=Fl;var Ok=h.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=on(Fl,n),[s,i]=h.useState(0),[a,l]=h.useState(0),c=!!(s&&a);return Hr(o.scrollbarX,()=>{var p;const d=((p=o.scrollbarX)==null?void 0:p.offsetHeight)||0;o.onCornerHeightChange(d),l(d)}),Hr(o.scrollbarY,()=>{var p;const d=((p=o.scrollbarY)==null?void 0:p.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),c?u.jsx(pe.div,{...r,ref:t,style:{width:s,height:a,position:"absolute",right:o.dir==="ltr"?0:void 0,left:o.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function si(e){return e?parseInt(e,10):0}function xm(e,t){const n=e/t;return isNaN(n)?0:n}function ii(e){const t=xm(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function Dk(e,t,n,r="ltr"){const o=ii(n),s=o/2,i=t||s,a=o-i,l=n.scrollbar.paddingStart+i,c=n.scrollbar.size-n.scrollbar.paddingEnd-a,d=n.content-n.viewport,p=r==="ltr"?[0,d]:[d*-1,0];return wm([l,c],p)(e)}function vm(e,t,n="ltr"){const r=ii(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,s=t.scrollbar.size-o,i=t.content-t.viewport,a=s-r,l=n==="ltr"?[0,i]:[i*-1,0],c=Ol(e,l);return wm([0,i],[0,a])(c)}function wm(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function bm(e,t){return e>0&&e<t}var Lk=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return function o(){const s={left:e.scrollLeft,top:e.scrollTop},i=n.left!==s.left,a=n.top!==s.top;(i||a)&&t(),n=s,r=window.requestAnimationFrame(o)}(),()=>window.cancelAnimationFrame(r)};function ai(e,t){const n=ht(e),r=h.useRef(0);return h.useEffect(()=>()=>window.clearTimeout(r.current),[]),h.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function Hr(e,t){const n=ht(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 ym=cm,$k=dm,Fk=gm;const Bl=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(ym,{ref:r,className:ne("relative overflow-hidden",e),...n,children:[u.jsx($k,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),u.jsx(Sm,{}),u.jsx(Fk,{})]}));Bl.displayName=ym.displayName;const Sm=h.forwardRef(({className:e,orientation:t="vertical",...n},r)=>u.jsx(Ll,{ref:r,orientation:t,className:ne("flex touch-none select-none transition-colors",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...n,children:u.jsx(mm,{className:"relative flex-1 rounded-full bg-border"})}));Sm.displayName=Ll.displayName;const zl=h.forwardRef(({className:e,type:t,...n},r)=>u.jsx("input",{type:t,className:ne("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:r,...n}));zl.displayName="Input";const Bk="group relative p-3 rounded-lg cursor-pointer transition-colors border text-gray-900 dark:text-slate-100",zk="bg-slate-700 border-slate-600 hover:bg-slate-600",Hk="bg-slate-600 border-slate-500";function Cm({thread:e,isActive:t,editingThreadId:n,editingTitle:r,onSelect:o,onStartEditing:s,onEditingTitleChange:i,onSaveEditing:a,onCancelEditing:l,onShare:c,onDelete:d,showEditTitle:p,showDeleteButton:m,formatDate:f,getDisplayThreadTitle:v,secondaryLine:g,itemClassName:x,activeItemClassName:y}){const b=n===e.threadId,C=t?`${y??Hk}`:`${x??zk}`,k=S=>{S.stopPropagation(),o(e.threadId)};return u.jsxs("div",{onClick:k,className:`${Bk} ${C}`,children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("div",{className:"flex-1 min-w-0",children:b?u.jsxs("div",{className:"flex items-center gap-2",onClick:S=>S.stopPropagation(),children:[u.jsx(zl,{value:r,onChange:S=>i(S.target.value),onKeyDown:S=>{S.key==="Enter"?a(e.threadId):S.key==="Escape"&&l()},className:"h-6 text-sm",autoFocus:!0}),u.jsx(Ye,{variant:"ghost",size:"sm",onClick:()=>a(e.threadId),className:"h-6 w-6 p-0",children:u.jsx(le.Check,{size:12})}),u.jsx(Ye,{variant:"ghost",size:"sm",onClick:l,className:"h-6 w-6 p-0",children:u.jsx(le.X,{size:12})})]}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"font-medium text-sm truncate text-gray-900 dark:text-slate-100",children:v(e)}),u.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-slate-400 mt-1",children:[u.jsx(le.Calendar,{size:10}),u.jsx("span",{children:f(e.updatedAt||e.createdAt)})]}),g&&u.jsx("div",{className:"text-[11px] text-muted-foreground mt-1",children:g})]})}),u.jsx("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2",children:u.jsxs(Is,{children:[u.jsx(Ns,{asChild:!0,children:u.jsx(Ye,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",children:u.jsx(le.MoreHorizontal,{size:12})})}),u.jsxs(xo,{align:"end",sideOffset:6,className:"w-44",children:[u.jsxs(Fn,{onClick:S=>{S.preventDefault(),c(e.threadId)},children:[u.jsx(le.Share2,{className:"mr-2 h-4 w-4"}),"Share thread"]}),p&&n!==e.threadId&&u.jsxs(Fn,{onClick:S=>{S.preventDefault(),s(e,S)},children:[u.jsx(le.Edit3,{className:"mr-2 h-4 w-4"}),"Rename"]}),m&&d&&u.jsxs(Fn,{className:"text-red-400 hover:text-red-300",onClick:S=>{S.preventDefault(),d(e.threadId,S)},children:[u.jsx(le.Trash2,{className:"mr-2 h-4 w-4"}),"Delete"]})]})]})})]}),t&&u.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-1 h-8 bg-blue-400 rounded-r"})]})}const Tm=25,km="thread-manager-view",Uk=e=>e==="default"||e==="shared",Wk=()=>{if(typeof window>"u")return null;try{const e=window.localStorage.getItem(km);if(Uk(e))return e}catch{}return null};function Em({defaultView:e}={}){const[t,n]=w.useState(()=>Wk()??e??"default");w.useEffect(()=>{if(!(typeof window>"u"))try{window.localStorage.setItem(km,t)}catch{}},[t]);const r=w.useCallback(o=>{n(o)},[]);return{view:t,setView:r}}const Vk=[{key:"default",label:"My chats"},{key:"shared",label:"Shared with you"}];function li({className:e="",showCreateButton:t=!0,showDeleteButton:n=!0,showEditTitle:r=!0,maxHeight:o="400px",customStyles:s={},currentThreadId:i=null,navigateToThread:a,onThreadSelect:l,onThreadCreate:c,onThreadDelete:d,view:p,defaultView:m,onViewChange:f,viewOptions:v,viewState:g,showHeader:x=!0,shareTargets:y,isLoadingShareTargets:b,shareTargetFilter:C}){const{threads:k,sharedThreads:S,currentThreadId:T,setCurrentThreadId:E,isLoading:A,isLoadingSharedThreads:P,actions:$,shareInFlight:L,shareStatus:H,clearShareStatus:Y}=yr(),{createThread:_,deleteThread:V,renameThread:G,shareThread:W}=$,{loadThread:D}=oo(),I=i??T,[U,Z]=w.useState(Array.isArray(k)?k:[]),R=w.useRef(U.length>0),q=w.useRef(null),j=w.useRef(0),[B,Q]=w.useState(null),[M,O]=w.useState(""),[F,J]=w.useState(!1),[oe,ae]=w.useState(!1),[Se,we]=w.useState(null),[Re,$e]=w.useState(""),Fe=v&&v.length>0?v:Vk,Ge=Em({defaultView:m}),Je=g??Ge,vt=p??Je.view,ct=w.useCallback(te=>{p||Je.setView(te),f==null||f(te)},[p,f,Je]),tt=Fe.find(te=>te.key===vt)??Fe[0],Oe=te=>{we(te),$e(""),ae(!0)},Ve=()=>{ae(!1),we(null),$e(""),Y()},He=w.useCallback(async te=>{if(!(!Se||L)&&te.id)try{await W(Se,te.id),setTimeout(()=>Ve(),600)}catch(xe){console.error("Failed to share thread:",xe)}},[Ve,L,Se,W]),Te=w.useMemo(()=>{const te=y??[],xe=Re.trim().toLowerCase();return xe?C?te.filter(nt=>C(nt,xe)):te.filter(nt=>`${nt.label} ${nt.secondaryLabel??""}`.toLowerCase().includes(xe)):te},[y,Re,C]),Ae=vt==="shared",ut=Ae?S:U,dt=Ae?P:A,it=Ae?"No shared conversations yet":"No conversations yet",At=te=>{const xe=te.sharedAt?` • ${Ie(te.sharedAt)}`:"";return`Shared by ${te.sharedByUserId}${xe}`},St=te=>"sharedByUserId"in te;w.useEffect(()=>{const te=Array.isArray(k)?k:[];if(te.length>0){R.current=!0,Z(te);return}A||(R.current=!1,Z(te))},[k,A]),w.useEffect(()=>{if(!q.current)return;const te=q.current.querySelector("[data-radix-scroll-area-viewport]");if(!te)return;let xe=null,nt=null;return xe=requestAnimationFrame(()=>{nt=requestAnimationFrame(()=>{te.scrollTop=j.current})}),()=>{xe!==null&&cancelAnimationFrame(xe),nt!==null&&cancelAnimationFrame(nt)}},[U]);const ft=async te=>{try{E(te),await D(te),a==null||a(te),l==null||l(te)}catch(xe){console.error("Failed to select thread:",xe)}},Ct=async()=>{try{J(!0);const te=await _();te&&(c==null||c(te),a==null||a(te))}catch(te){console.error("Failed to create thread:",te)}finally{J(!1)}},Tt=async(te,xe)=>{if(xe.stopPropagation(),!!confirm("Delete this thread?")){if(q.current){const nt=q.current.querySelector("[data-radix-scroll-area-viewport]");nt&&(j.current=nt.scrollTop)}try{await V(te),d==null||d(te)}catch(nt){console.error("Failed to delete thread:",nt)}}},It=(te,xe)=>{xe.stopPropagation(),Q(te.threadId),O(te.title||`Thread ${te.threadId.slice(0,8)}`)},en=async te=>{if(M.trim())try{await G(te,M.trim()),Q(null),O("")}catch(xe){console.error("Failed to update title:",xe)}},kt=()=>{Q(null),O("")},Ie=te=>{if(!te)return"";try{const xe=new Date(te),me=new Date().getTime()-xe.getTime(),Ne=Math.floor(me/(1e3*60*60*24));return Ne===0?xe.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):Ne===1?"Yesterday":Ne<7?`${Ne} days ago`:xe.toLocaleDateString()}catch{return""}},Ke=te=>te.title||`Thread ${te.threadId.slice(0,8)}`,Nt=te=>{const xe=Ke(te);return xe.length<=Tm?xe:`${xe.slice(0,Tm)}...`};return u.jsxs("div",{className:`flex flex-col h-full ${e} ${s.container||""}`,children:[x&&u.jsxs("div",{className:s.header||"flex flex-col gap-2 px-1 py-0 border border-slate-200 bg-white dark:border-slate-700 dark:bg-slate-900 shadow-sm",children:[t&&u.jsx("div",{className:"flex justify-end",children:u.jsxs(Ye,{onClick:Ct,disabled:F||A,className:s.createButton||"px-3 py-2 gap-1",size:"sm",variant:"ghost",title:F?"Creating...":"New Chat",children:[u.jsx(le.Edit3,{size:16}),u.jsx("span",{children:"New chat"})]})}),u.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-slate-700 dark:text-slate-200 uppercase tracking-wide leading-tight",children:[u.jsx("span",{children:"Current View"}),u.jsxs(Is,{children:[u.jsx(Ns,{asChild:!0,children:u.jsx(Ye,{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:tt.label})}),u.jsx(xo,{align:"start",sideOffset:6,className:"w-40",children:Fe.map(te=>u.jsxs(Fn,{className:"justify-between text-[12px]",onClick:xe=>{xe.preventDefault(),ct(te.key)},children:[u.jsx("span",{children:te.label}),vt===te.key&&u.jsx(le.Check,{className:"h-3 w-3"})]},te.key))})]})]})]}),u.jsx(Bl,{ref:q,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:dt?u.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-8 text-slate-400",children:[u.jsx(le.Loader2,{className:"h-5 w-5 animate-spin"}),u.jsx("span",{className:"text-sm",children:"Loading threads…"})]}):ut.length===0?u.jsxs("div",{className:"text-center py-8 text-slate-400",children:[u.jsx(le.MessageSquare,{className:"w-8 h-8 mx-auto mb-2 opacity-40 text-slate-500"}),u.jsx("p",{className:"text-sm text-slate-500",children:it})]}):ut.slice().sort((te,xe)=>new Date(xe.updatedAt||xe.createdAt||"").getTime()-new Date(te.updatedAt||te.createdAt||"").getTime()).map(te=>u.jsx(Cm,{thread:te,isActive:I===te.threadId,editingThreadId:B,editingTitle:M,onSelect:ft,onStartEditing:It,onEditingTitleChange:xe=>O(xe),onSaveEditing:en,onCancelEditing:kt,onShare:()=>Oe(te.threadId),onDelete:Tt,showEditTitle:r,showDeleteButton:n,formatDate:Ie,getDisplayThreadTitle:Nt,secondaryLine:Ae&&St(te)?At(te):void 0,itemClassName:s.threadItem,activeItemClassName:s.activeThread},te.threadId))})}),u.jsx(cl,{open:oe,onOpenChange:te=>!te&&Ve(),children:u.jsxs(Vs,{className:"max-w-md p-0",children:[u.jsx(Ks,{children:u.jsx(qs,{children:"Share thread"})}),u.jsxs(Al,{children:[u.jsx(Pl,{autoFocus:!0,value:Re,onValueChange:te=>$e(te),placeholder:"Search for recipients..."}),u.jsxs(jl,{children:[H&&u.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-xs text-muted-foreground",children:[L&&u.jsx(le.Loader2,{className:"h-3 w-3 animate-spin"}),u.jsx("span",{className:H.startsWith("Failed")?"text-red-500":H.startsWith("Shared")?"text-emerald-500":"text-slate-600 dark:text-slate-400",children:H})]}),u.jsx(_l,{children:b?u.jsxs("span",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(le.Loader2,{className:"h-4 w-4 animate-spin"}),"Loading recipients…"]}):"No matching recipients found"}),Te.length>0&&u.jsx(Rl,{heading:"Recipients",children:Te.map(te=>u.jsx(Ml,{onSelect:()=>He(te),children:u.jsxs("div",{className:"flex flex-col items-start text-sm",children:[u.jsx("span",{className:"font-medium",children:te.label}),te.secondaryLabel&&u.jsx("span",{className:"text-xs text-muted-foreground",children:te.secondaryLabel})]})},te.id))})]})]})]})})]})}function Kk({layout:e="sidebar",layoutSize:t="desktop",showThreads:n=!0,className:r="",customStyles:o={},...s}){const i=c=>{const d="h-full";switch(c){case"phone":return`${d} max-w-none`;case"tablet":return`${d} max-w-4xl mx-auto`;case"half-screen":return`${d} max-w-2xl`;case"desktop":default:return`${d} max-w-7xl mx-auto`}},a=c=>({"--chat-sidebar-width":c==="phone"?"100%":c==="tablet"?"280px":c==="half-screen"?"240px":"320px","--chat-message-max-width":c==="phone"?"95%":c==="tablet"?"90%":c==="half-screen"?"85%":"80%","--chat-input-height":c==="phone"?"120px":"100px"}),l=w.useCallback(c=>{var d;(d=s.onThreadChange)==null||d.call(s,c)},[s]);return e==="fullscreen"?u.jsx(Tr,{...s,onThreadChange:l,children:u.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:u.jsx(Fr,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?u.jsx(Tr,{...s,onThreadChange: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(li,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),u.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:u.jsx(Fr,{onError:s.onError,enableFileUpload:!0})})]})})}):u.jsx(Tr,{...s,onThreadChange: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(li,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),u.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:u.jsx(Fr,{onError:s.onError,enableFileUpload:!0})})]})})}function qk({apiConfig:e,className:t="",onError:n}){return u.jsx(Tr,{apiConfig:e,onError:n,children:u.jsx("div",{className:`h-full ${t}`,children:u.jsx(Fr,{})})})}function Gk({placeholder:e,onMessageSent:t}){const[n,r]=w.useState("chat");return u.jsxs("div",{className:"flex flex-col h-full",children:[u.jsxs("div",{className:"flex border-b border-gray-200 bg-gray-50",children:[u.jsx("button",{onClick:()=>r("chat"),className:`flex-1 px-3 py-2 text-sm font-medium transition-colors ${n==="chat"?"border-b-2 border-slate-800 text-slate-800 bg-white":"text-gray-600 hover:text-gray-800"}`,children:u.jsxs("div",{className:"flex items-center justify-center gap-2",children:[u.jsx(le.MessageSquare,{size:14}),"Chat"]})}),u.jsx("button",{onClick:()=>r("threads"),className:`flex-1 px-3 py-2 text-sm font-medium transition-colors ${n==="threads"?"border-b-2 border-slate-800 text-slate-800 bg-white":"text-gray-600 hover:text-gray-800"}`,children:u.jsxs("div",{className:"flex items-center justify-center gap-2",children:[u.jsx(le.History,{size:14}),"History"]})})]}),u.jsx("div",{className:"flex-1 min-h-0",children:n==="chat"?u.jsx(Fr,{placeholder:e??"Ask Serti AI anything...",autoFocus:!0,className:"h-full",onMessageSent:t}):u.jsx(li,{showCreateButton:!0,className:"h-full",onThreadSelect:()=>r("chat")})})]})}function Yk({className:e="",placeholder:t,isAuthenticated:n=!0,onMessageSent:r,widgetTitle:o="Serti AI Navigator",widgetSubtitle:s="AI-Powered Assistant",...i}){const[a,l]=w.useState(!1);return n?u.jsx(Tr,{...i,children:u.jsx("div",{className:`fixed bottom-6 right-6 z-[9999] transition-all duration-300 ${e}`,children:u.jsxs("div",{className:`w-96 bg-white rounded-xl shadow-2xl border border-gray-200 overflow-hidden relative ${a?"scale-75":"scale-100"}`,children:[u.jsx("div",{className:"bg-slate-800 text-white p-4 flex-shrink-0",children:u.jsxs("div",{className:"flex items-center justify-between gap-3",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsxs("div",{className:"relative h-10 w-10 rounded-full bg-gradient-to-br from-slate-500 to-slate-700 border border-white/30 flex items-center justify-center text-white text-sm font-bold",children:["S",u.jsx("span",{className:"absolute -bottom-0.5 -right-0.5 h-3 w-3 rounded-full border-2 border-slate-800 bg-emerald-400"})]}),u.jsxs("div",{className:"flex flex-col",children:[u.jsx("h3",{className:"text-lg font-semibold leading-tight",children:o}),u.jsx("p",{className:"text-xs text-white/70",children:s})]}),u.jsx("span",{className:"ml-2 inline-flex items-center justify-center rounded-full bg-red-500 px-2 py-0.5 text-[11px] font-semibold leading-none text-white",children:"1"})]}),u.jsxs("div",{className:"flex items-center gap-1",children:[u.jsx(Ye,{variant:"ghost",size:"sm",className:"text-white hover:bg-white/10 h-8 w-8 p-0",title:"Options",children:u.jsx(le.MoreHorizontal,{size:16})}),u.jsx(Ye,{variant:"ghost",size:"sm",className:"text-white hover:bg-white/10 h-8 w-8 p-0",title:"Compose",children:u.jsx(le.Edit3,{size:16})}),u.jsx(Ye,{variant:"ghost",size:"sm",onClick:c=>{c.stopPropagation(),l(d=>!d)},className:"text-white hover:bg-white/10 h-8 w-8 p-0",title:a?"Maximize":"Minimize",children:a?u.jsx(le.Maximize2,{size:14}):u.jsx(le.Minimize2,{size:14})})]})]})}),!a&&u.jsx("div",{className:"h-96 flex flex-col",children:u.jsx(Gk,{placeholder:t,onMessageSent:r})})]})})}):null}function Xk({label:e="New chat",children:t,className:n,variant:r="ghost",size:o="sm",...s}){return u.jsxs(Ye,{variant:r,size:o,className:ne("gap-2 rounded-full px-3 font-semibold transition-all hover:scale-[1.01]",n),...s,children:[u.jsx(le.Edit3,{size:16}),t??e]})}var Jk="Label",Im=h.forwardRef((e,t)=>u.jsx(pe.label,{...e,ref:t,onMouseDown:n=>{var o;n.target.closest("button, input, select, textarea")||((o=e.onMouseDown)==null||o.call(e,n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));Im.displayName=Jk;var Nm=Im;const Zk=Kr.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Am=h.forwardRef(({className:e,...t},n)=>u.jsx(Nm,{ref:n,className:ne(Zk(),e),...t}));Am.displayName=Nm.displayName;function Pm(e){const t=h.useRef({value:e,previous:e});return h.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var jm=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),Qk="VisuallyHidden",ci=h.forwardRef((e,t)=>u.jsx(pe.span,{...e,ref:t,style:{...jm,...e.style}}));ci.displayName=Qk;var eE=ci,tE=[" ","Enter","ArrowUp","ArrowDown"],nE=[" ","Enter"],hr="Select",[ui,di,rE]=es(hr),[Ur,VN]=cn(hr,[rE,jr]),fi=jr(),[oE,qn]=Ur(hr),[sE,iE]=Ur(hr),_m=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:l,dir:c,name:d,autoComplete:p,disabled:m,required:f,form:v}=e,g=fi(t),[x,y]=h.useState(null),[b,C]=h.useState(null),[k,S]=h.useState(!1),T=ts(c),[E,A]=On({prop:r,defaultProp:o??!1,onChange:s,caller:hr}),[P,$]=On({prop:i,defaultProp:a,onChange:l,caller:hr}),L=h.useRef(null),H=x?v||!!x.closest("form"):!0,[Y,_]=h.useState(new Set),V=Array.from(Y).map(G=>G.props.value).join(";");return u.jsx(ha,{...g,children:u.jsxs(oE,{required:f,scope:t,trigger:x,onTriggerChange:y,valueNode:b,onValueNodeChange:C,valueNodeHasChildren:k,onValueNodeHasChildrenChange:S,contentId:_t(),value:P,onValueChange:$,open:E,onOpenChange:A,dir:T,triggerPointerDownPosRef:L,disabled:m,children:[u.jsx(ui.Provider,{scope:t,children:u.jsx(sE,{scope:e.__scopeSelect,onNativeOptionAdd:h.useCallback(G=>{_(W=>new Set(W).add(G))},[]),onNativeOptionRemove:h.useCallback(G=>{_(W=>{const D=new Set(W);return D.delete(G),D})},[]),children:n})}),H?u.jsxs(ng,{"aria-hidden":!0,required:f,tabIndex:-1,name:d,autoComplete:p,value:P,onChange:G=>$(G.target.value),disabled:m,form:v,children:[P===void 0?u.jsx("option",{value:""}):null,Array.from(Y)]},V):null]})})};_m.displayName=hr;var Rm="SelectTrigger",Mm=h.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=fi(n),i=qn(Rm,n),a=i.disabled||r,l=je(t,i.onTriggerChange),c=di(n),d=h.useRef("touch"),[p,m,f]=og(g=>{const x=c().filter(C=>!C.disabled),y=x.find(C=>C.value===i.value),b=sg(x,g,y);b!==void 0&&i.onValueChange(b.value)}),v=g=>{a||(i.onOpenChange(!0),f()),g&&(i.triggerPointerDownPosRef.current={x:Math.round(g.pageX),y:Math.round(g.pageY)})};return u.jsx(ma,{asChild:!0,...s,children:u.jsx(pe.button,{type:"button",role:"combobox","aria-controls":i.contentId,"aria-expanded":i.open,"aria-required":i.required,"aria-autocomplete":"none",dir:i.dir,"data-state":i.open?"open":"closed",disabled:a,"data-disabled":a?"":void 0,"data-placeholder":rg(i.value)?"":void 0,...o,ref:l,onClick:ie(o.onClick,g=>{g.currentTarget.focus(),d.current!=="mouse"&&v(g)}),onPointerDown:ie(o.onPointerDown,g=>{d.current=g.pointerType;const x=g.target;x.hasPointerCapture(g.pointerId)&&x.releasePointerCapture(g.pointerId),g.button===0&&g.ctrlKey===!1&&g.pointerType==="mouse"&&(v(g),g.preventDefault())}),onKeyDown:ie(o.onKeyDown,g=>{const x=p.current!=="";!(g.ctrlKey||g.altKey||g.metaKey)&&g.key.length===1&&m(g.key),!(x&&g.key===" ")&&tE.includes(g.key)&&(v(),g.preventDefault())})})})});Mm.displayName=Rm;var Om="SelectValue",Dm=h.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=qn(Om,n),{onValueNodeHasChildrenChange:c}=l,d=s!==void 0,p=je(t,l.onValueNodeChange);return Et(()=>{c(d)},[c,d]),u.jsx(pe.span,{...a,ref:p,style:{pointerEvents:"none"},children:rg(l.value)?u.jsx(u.Fragment,{children:i}):s})});Dm.displayName=Om;var aE="SelectIcon",Lm=h.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return u.jsx(pe.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});Lm.displayName=aE;var lE="SelectPortal",$m=e=>u.jsx(co,{asChild:!0,...e});$m.displayName=lE;var mr="SelectContent",Fm=h.forwardRef((e,t)=>{const n=qn(mr,e.__scopeSelect),[r,o]=h.useState();if(Et(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?qr.createPortal(u.jsx(Bm,{scope:e.__scopeSelect,children:u.jsx(ui.Slot,{scope:e.__scopeSelect,children:u.jsx("div",{children:e.children})})}),s):null}return u.jsx(zm,{...e,ref:t})});Fm.displayName=mr;var mn=10,[Bm,Gn]=Ur(mr),cE="SelectContentImpl",uE=qt.createSlot("SelectContent.RemoveScroll"),zm=h.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:p,collisionBoundary:m,collisionPadding:f,sticky:v,hideWhenDetached:g,avoidCollisions:x,...y}=e,b=qn(mr,n),[C,k]=h.useState(null),[S,T]=h.useState(null),E=je(t,M=>k(M)),[A,P]=h.useState(null),[$,L]=h.useState(null),H=di(n),[Y,_]=h.useState(!1),V=h.useRef(!1);h.useEffect(()=>{if(C)return ya(C)},[C]),Zi();const G=h.useCallback(M=>{const[O,...F]=H().map(ae=>ae.ref.current),[J]=F.slice(-1),oe=document.activeElement;for(const ae of M)if(ae===oe||(ae==null||ae.scrollIntoView({block:"nearest"}),ae===O&&S&&(S.scrollTop=0),ae===J&&S&&(S.scrollTop=S.scrollHeight),ae==null||ae.focus(),document.activeElement!==oe))return},[H,S]),W=h.useCallback(()=>G([A,C]),[G,A,C]);h.useEffect(()=>{Y&&W()},[Y,W]);const{onOpenChange:D,triggerPointerDownPosRef:I}=b;h.useEffect(()=>{if(C){let M={x:0,y:0};const O=J=>{var oe,ae;M={x:Math.abs(Math.round(J.pageX)-(((oe=I.current)==null?void 0:oe.x)??0)),y:Math.abs(Math.round(J.pageY)-(((ae=I.current)==null?void 0:ae.y)??0))}},F=J=>{M.x<=10&&M.y<=10?J.preventDefault():C.contains(J.target)||D(!1),document.removeEventListener("pointermove",O),I.current=null};return I.current!==null&&(document.addEventListener("pointermove",O),document.addEventListener("pointerup",F,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",O),document.removeEventListener("pointerup",F,{capture:!0})}}},[C,D,I]),h.useEffect(()=>{const M=()=>D(!1);return window.addEventListener("blur",M),window.addEventListener("resize",M),()=>{window.removeEventListener("blur",M),window.removeEventListener("resize",M)}},[D]);const[U,Z]=og(M=>{const O=H().filter(oe=>!oe.disabled),F=O.find(oe=>oe.ref.current===document.activeElement),J=sg(O,M,F);J&&setTimeout(()=>J.ref.current.focus())}),R=h.useCallback((M,O,F)=>{const J=!V.current&&!F;(b.value!==void 0&&b.value===O||J)&&(P(M),J&&(V.current=!0))},[b.value]),q=h.useCallback(()=>C==null?void 0:C.focus(),[C]),j=h.useCallback((M,O,F)=>{const J=!V.current&&!F;(b.value!==void 0&&b.value===O||J)&&L(M)},[b.value]),B=r==="popper"?Hl:Hm,Q=B===Hl?{side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:p,collisionBoundary:m,collisionPadding:f,sticky:v,hideWhenDetached:g,avoidCollisions:x}:{};return u.jsx(Bm,{scope:n,content:C,viewport:S,onViewportChange:T,itemRefCallback:R,selectedItem:A,onItemLeave:q,itemTextRefCallback:j,focusSelectedItem:W,selectedItemText:$,position:r,isPositioned:Y,searchRef:U,children:u.jsx(ys,{as:uE,allowPinchZoom:!0,children:u.jsx(ns,{asChild:!0,trapped:b.open,onMountAutoFocus:M=>{M.preventDefault()},onUnmountAutoFocus:ie(o,M=>{var O;(O=b.trigger)==null||O.focus({preventScroll:!0}),M.preventDefault()}),children:u.jsx(Er,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:M=>M.preventDefault(),onDismiss:()=>b.onOpenChange(!1),children:u.jsx(B,{role:"listbox",id:b.contentId,"data-state":b.open?"open":"closed",dir:b.dir,onContextMenu:M=>M.preventDefault(),...y,...Q,onPlaced:()=>_(!0),ref:E,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:ie(y.onKeyDown,M=>{const O=M.ctrlKey||M.altKey||M.metaKey;if(M.key==="Tab"&&M.preventDefault(),!O&&M.key.length===1&&Z(M.key),["ArrowUp","ArrowDown","Home","End"].includes(M.key)){let J=H().filter(oe=>!oe.disabled).map(oe=>oe.ref.current);if(["ArrowUp","End"].includes(M.key)&&(J=J.slice().reverse()),["ArrowUp","ArrowDown"].includes(M.key)){const oe=M.target,ae=J.indexOf(oe);J=J.slice(ae+1)}setTimeout(()=>G(J)),M.preventDefault()}})})})})})})});zm.displayName=cE;var dE="SelectItemAlignedPosition",Hm=h.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=qn(mr,n),i=Gn(mr,n),[a,l]=h.useState(null),[c,d]=h.useState(null),p=je(t,E=>d(E)),m=di(n),f=h.useRef(!1),v=h.useRef(!0),{viewport:g,selectedItem:x,selectedItemText:y,focusSelectedItem:b}=i,C=h.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&c&&g&&x&&y){const E=s.trigger.getBoundingClientRect(),A=c.getBoundingClientRect(),P=s.valueNode.getBoundingClientRect(),$=y.getBoundingClientRect();if(s.dir!=="rtl"){const oe=$.left-A.left,ae=P.left-oe,Se=E.left-ae,we=E.width+Se,Re=Math.max(we,A.width),$e=window.innerWidth-mn,Fe=Ol(ae,[mn,Math.max(mn,$e-Re)]);a.style.minWidth=we+"px",a.style.left=Fe+"px"}else{const oe=A.right-$.right,ae=window.innerWidth-P.right-oe,Se=window.innerWidth-E.right-ae,we=E.width+Se,Re=Math.max(we,A.width),$e=window.innerWidth-mn,Fe=Ol(ae,[mn,Math.max(mn,$e-Re)]);a.style.minWidth=we+"px",a.style.right=Fe+"px"}const L=m(),H=window.innerHeight-mn*2,Y=g.scrollHeight,_=window.getComputedStyle(c),V=parseInt(_.borderTopWidth,10),G=parseInt(_.paddingTop,10),W=parseInt(_.borderBottomWidth,10),D=parseInt(_.paddingBottom,10),I=V+G+Y+D+W,U=Math.min(x.offsetHeight*5,I),Z=window.getComputedStyle(g),R=parseInt(Z.paddingTop,10),q=parseInt(Z.paddingBottom,10),j=E.top+E.height/2-mn,B=H-j,Q=x.offsetHeight/2,M=x.offsetTop+Q,O=V+G+M,F=I-O;if(O<=j){const oe=L.length>0&&x===L[L.length-1].ref.current;a.style.bottom="0px";const ae=c.clientHeight-g.offsetTop-g.offsetHeight,Se=Math.max(B,Q+(oe?q:0)+ae+W),we=O+Se;a.style.height=we+"px"}else{const oe=L.length>0&&x===L[0].ref.current;a.style.top="0px";const Se=Math.max(j,V+g.offsetTop+(oe?R:0)+Q)+F;a.style.height=Se+"px",g.scrollTop=O-j+g.offsetTop}a.style.margin=`${mn}px 0`,a.style.minHeight=U+"px",a.style.maxHeight=H+"px",r==null||r(),requestAnimationFrame(()=>f.current=!0)}},[m,s.trigger,s.valueNode,a,c,g,x,y,s.dir,r]);Et(()=>C(),[C]);const[k,S]=h.useState();Et(()=>{c&&S(window.getComputedStyle(c).zIndex)},[c]);const T=h.useCallback(E=>{E&&v.current===!0&&(C(),b==null||b(),v.current=!1)},[C,b]);return u.jsx(pE,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:f,onScrollButtonChange:T,children:u.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:k},children:u.jsx(pe.div,{...o,ref:p,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Hm.displayName=dE;var fE="SelectPopperPosition",Hl=h.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=mn,...s}=e,i=fi(n);return u.jsx(ga,{...i,...s,ref:t,align:r,collisionPadding:o,style:{boxSizing:"border-box",...s.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});Hl.displayName=fE;var[pE,Ul]=Ur(mr,{}),Wl="SelectViewport",Um=h.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=Gn(Wl,n),i=Ul(Wl,n),a=je(t,s.onViewportChange),l=h.useRef(0);return u.jsxs(u.Fragment,{children:[u.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),u.jsx(ui.Slot,{scope:n,children:u.jsx(pe.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:ie(o.onScroll,c=>{const d=c.currentTarget,{contentWrapper:p,shouldExpandOnScrollRef:m}=i;if(m!=null&&m.current&&p){const f=Math.abs(l.current-d.scrollTop);if(f>0){const v=window.innerHeight-mn*2,g=parseFloat(p.style.minHeight),x=parseFloat(p.style.height),y=Math.max(g,x);if(y<v){const b=y+f,C=Math.min(v,b),k=b-C;p.style.height=C+"px",p.style.bottom==="0px"&&(d.scrollTop=k>0?k:0,p.style.justifyContent="flex-end")}}}l.current=d.scrollTop})})})]})});Um.displayName=Wl;var Wm="SelectGroup",[hE,mE]=Ur(Wm),gE=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=_t();return u.jsx(hE,{scope:n,id:o,children:u.jsx(pe.div,{role:"group","aria-labelledby":o,...r,ref:t})})});gE.displayName=Wm;var Vm="SelectLabel",Km=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=mE(Vm,n);return u.jsx(pe.div,{id:o.id,...r,ref:t})});Km.displayName=Vm;var pi="SelectItem",[xE,qm]=Ur(pi),Gm=h.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=qn(pi,n),l=Gn(pi,n),c=a.value===r,[d,p]=h.useState(s??""),[m,f]=h.useState(!1),v=je(t,b=>{var C;return(C=l.itemRefCallback)==null?void 0:C.call(l,b,r,o)}),g=_t(),x=h.useRef("touch"),y=()=>{o||(a.onValueChange(r),a.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return u.jsx(xE,{scope:n,value:r,disabled:o,textId:g,isSelected:c,onItemTextChange:h.useCallback(b=>{p(C=>C||((b==null?void 0:b.textContent)??"").trim())},[]),children:u.jsx(ui.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:u.jsx(pe.div,{role:"option","aria-labelledby":g,"data-highlighted":m?"":void 0,"aria-selected":c&&m,"data-state":c?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:v,onFocus:ie(i.onFocus,()=>f(!0)),onBlur:ie(i.onBlur,()=>f(!1)),onClick:ie(i.onClick,()=>{x.current!=="mouse"&&y()}),onPointerUp:ie(i.onPointerUp,()=>{x.current==="mouse"&&y()}),onPointerDown:ie(i.onPointerDown,b=>{x.current=b.pointerType}),onPointerMove:ie(i.onPointerMove,b=>{var C;x.current=b.pointerType,o?(C=l.onItemLeave)==null||C.call(l):x.current==="mouse"&&b.currentTarget.focus({preventScroll:!0})}),onPointerLeave:ie(i.onPointerLeave,b=>{var C;b.currentTarget===document.activeElement&&((C=l.onItemLeave)==null||C.call(l))}),onKeyDown:ie(i.onKeyDown,b=>{var k;((k=l.searchRef)==null?void 0:k.current)!==""&&b.key===" "||(nE.includes(b.key)&&y(),b.key===" "&&b.preventDefault())})})})})});Gm.displayName=pi;var Mo="SelectItemText",Ym=h.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=qn(Mo,n),a=Gn(Mo,n),l=qm(Mo,n),c=iE(Mo,n),[d,p]=h.useState(null),m=je(t,y=>p(y),l.onItemTextChange,y=>{var b;return(b=a.itemTextRefCallback)==null?void 0:b.call(a,y,l.value,l.disabled)}),f=d==null?void 0:d.textContent,v=h.useMemo(()=>u.jsx("option",{value:l.value,disabled:l.disabled,children:f},l.value),[l.disabled,l.value,f]),{onNativeOptionAdd:g,onNativeOptionRemove:x}=c;return Et(()=>(g(v),()=>x(v)),[g,x,v]),u.jsxs(u.Fragment,{children:[u.jsx(pe.span,{id:l.textId,...s,ref:m}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?qr.createPortal(s.children,i.valueNode):null]})});Ym.displayName=Mo;var Xm="SelectItemIndicator",Jm=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return qm(Xm,n).isSelected?u.jsx(pe.span,{"aria-hidden":!0,...r,ref:t}):null});Jm.displayName=Xm;var Vl="SelectScrollUpButton",Zm=h.forwardRef((e,t)=>{const n=Gn(Vl,e.__scopeSelect),r=Ul(Vl,e.__scopeSelect),[o,s]=h.useState(!1),i=je(t,r.onScrollButtonChange);return 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(eg,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});Zm.displayName=Vl;var Kl="SelectScrollDownButton",Qm=h.forwardRef((e,t)=>{const n=Gn(Kl,e.__scopeSelect),r=Ul(Kl,e.__scopeSelect),[o,s]=h.useState(!1),i=je(t,r.onScrollButtonChange);return 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(eg,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});Qm.displayName=Kl;var eg=h.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=Gn("SelectScrollButton",n),i=h.useRef(null),a=di(n),l=h.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return h.useEffect(()=>()=>l(),[l]),Et(()=>{var d;const c=a().find(p=>p.ref.current===document.activeElement);(d=c==null?void 0:c.ref.current)==null||d.scrollIntoView({block:"nearest"})},[a]),u.jsx(pe.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:ie(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:ie(o.onPointerMove,()=>{var c;(c=s.onItemLeave)==null||c.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:ie(o.onPointerLeave,()=>{l()})})}),vE="SelectSeparator",tg=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return u.jsx(pe.div,{"aria-hidden":!0,...r,ref:t})});tg.displayName=vE;var ql="SelectArrow",wE=h.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=fi(n),s=qn(ql,n),i=Gn(ql,n);return s.open&&i.position==="popper"?u.jsx(xa,{...o,...r,ref:t}):null});wE.displayName=ql;var bE="SelectBubbleInput",ng=h.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=h.useRef(null),s=je(r,o),i=Pm(t);return h.useEffect(()=>{const a=o.current;if(!a)return;const l=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(l,"value").set;if(i!==t&&d){const p=new Event("change",{bubbles:!0});d.call(a,t),a.dispatchEvent(p)}},[i,t]),u.jsx(pe.select,{...n,style:{...jm,...n.style},ref:s,defaultValue:t})});ng.displayName=bE;function rg(e){return e===""||e===void 0}function og(e){const t=ht(e),n=h.useRef(""),r=h.useRef(0),o=h.useCallback(i=>{const a=n.current+i;t(a),function l(c){n.current=c,window.clearTimeout(r.current),c!==""&&(r.current=window.setTimeout(()=>l(""),1e3))}(a)},[t]),s=h.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return h.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function sg(e,t,n){const o=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=yE(e,Math.max(s,0));o.length===1&&(i=i.filter(c=>c!==n));const l=i.find(c=>c.textValue.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function yE(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var SE=_m,ig=Mm,CE=Dm,TE=Lm,kE=$m,ag=Fm,EE=Um,lg=Km,cg=Gm,IE=Ym,NE=Jm,ug=Zm,dg=Qm,fg=tg;const AE=SE,PE=CE,pg=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(ig,{ref:r,className:ne("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[t,u.jsx(TE,{asChild:!0,children:u.jsx(le.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));pg.displayName=ig.displayName;const hg=h.forwardRef(({className:e,...t},n)=>u.jsx(ug,{ref:n,className:ne("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(le.ChevronUp,{className:"h-4 w-4"})}));hg.displayName=ug.displayName;const mg=h.forwardRef(({className:e,...t},n)=>u.jsx(dg,{ref:n,className:ne("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(le.ChevronDown,{className:"h-4 w-4"})}));mg.displayName=dg.displayName;const gg=h.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>u.jsx(kE,{children:u.jsxs(ag,{ref:o,className:ne("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...r,children:[u.jsx(hg,{}),u.jsx(EE,{className:ne("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),u.jsx(mg,{})]})}));gg.displayName=ag.displayName;const jE=h.forwardRef(({className:e,...t},n)=>u.jsx(lg,{ref:n,className:ne("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));jE.displayName=lg.displayName;const xg=h.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(cg,{ref:r,className:ne("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[u.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:u.jsx(NE,{children:u.jsx(le.Check,{className:"h-4 w-4"})})}),u.jsx(IE,{children:t})]}));xg.displayName=cg.displayName;const _E=h.forwardRef(({className:e,...t},n)=>u.jsx(fg,{ref:n,className:ne("-mx-1 my-1 h-px bg-muted",e),...t}));_E.displayName=fg.displayName;var RE="Separator",vg="horizontal",ME=["horizontal","vertical"],wg=h.forwardRef((e,t)=>{const{decorative:n,orientation:r=vg,...o}=e,s=OE(r)?r:vg,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return u.jsx(pe.div,{"data-orientation":s,...a,...o,ref:t})});wg.displayName=RE;function OE(e){return ME.includes(e)}var bg=wg;const yg=h.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>u.jsx(bg,{ref:o,decorative:n,orientation:t,className:ne("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));yg.displayName=bg.displayName;var hi="Switch",[DE,KN]=cn(hi),[LE,$E]=DE(hi),Sg=h.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:s,required:i,disabled:a,value:l="on",onCheckedChange:c,form:d,...p}=e,[m,f]=h.useState(null),v=je(t,C=>f(C)),g=h.useRef(!1),x=m?d||!!m.closest("form"):!0,[y,b]=On({prop:o,defaultProp:s??!1,onChange:c,caller:hi});return u.jsxs(LE,{scope:n,checked:y,disabled:a,children:[u.jsx(pe.button,{type:"button",role:"switch","aria-checked":y,"aria-required":i,"data-state":Eg(y),"data-disabled":a?"":void 0,disabled:a,value:l,...p,ref:v,onClick:ie(e.onClick,C=>{b(k=>!k),x&&(g.current=C.isPropagationStopped(),g.current||C.stopPropagation())})}),x&&u.jsx(kg,{control:m,bubbles:!g.current,name:r,value:l,checked:y,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});Sg.displayName=hi;var Cg="SwitchThumb",Tg=h.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=$E(Cg,n);return u.jsx(pe.span,{"data-state":Eg(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});Tg.displayName=Cg;var FE="SwitchBubbleInput",kg=h.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=h.useRef(null),a=je(i,s),l=Pm(n),c=Od(t);return h.useEffect(()=>{const d=i.current;if(!d)return;const p=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(p,"checked").set;if(l!==n&&f){const v=new Event("click",{bubbles:r});f.call(d,n),d.dispatchEvent(v)}},[l,n,r]),u.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:a,style:{...o.style,...c,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});kg.displayName=FE;function Eg(e){return e?"checked":"unchecked"}var Ig=Sg,BE=Tg;const Ng=h.forwardRef(({className:e,...t},n)=>u.jsx(Ig,{className:ne("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...t,ref:n,children:u.jsx(BE,{className:ne("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));Ng.displayName=Ig.displayName;const zE=al,HE=wT,UE=ll,Ag=h.forwardRef(({className:e,...t},n)=>u.jsx(No,{className:ne("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t,ref:n}));Ag.displayName=No.displayName;const WE=Kr.cva("fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),Pg=h.forwardRef(({side:e="right",className:t,children:n,...r},o)=>u.jsxs(UE,{children:[u.jsx(Ag,{}),u.jsxs(Ao,{ref:o,className:ne(WE({side:e}),t),...r,children:[n,u.jsxs(yh,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary",children:[u.jsx(le.X,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Pg.displayName=Ao.displayName;const jg=({className:e,...t})=>u.jsx("div",{className:ne("flex flex-col space-y-2 text-center sm:text-left",e),...t});jg.displayName="SheetHeader";const _g=h.forwardRef(({className:e,...t},n)=>u.jsx(ur,{ref:n,className:ne("text-lg font-semibold text-foreground",e),...t}));_g.displayName=ur.displayName;const Rg=h.forwardRef(({className:e,...t},n)=>u.jsx(Ws,{ref:n,className:ne("text-sm text-muted-foreground",e),...t}));Rg.displayName=Ws.displayName;var[mi,qN]=cn("Tooltip",[jr]),gi=jr(),Mg="TooltipProvider",VE=700,Gl="tooltip.open",[KE,Yl]=mi(Mg),Og=e=>{const{__scopeTooltip:t,delayDuration:n=VE,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:s}=e,i=h.useRef(!0),a=h.useRef(!1),l=h.useRef(0);return h.useEffect(()=>{const c=l.current;return()=>window.clearTimeout(c)},[]),u.jsx(KE,{scope:t,isOpenDelayedRef:i,delayDuration:n,onOpen:h.useCallback(()=>{window.clearTimeout(l.current),i.current=!1},[]),onClose:h.useCallback(()=>{window.clearTimeout(l.current),l.current=window.setTimeout(()=>i.current=!0,r)},[r]),isPointerInTransitRef:a,onPointerInTransitChange:h.useCallback(c=>{a.current=c},[]),disableHoverableContent:o,children:s})};Og.displayName=Mg;var Oo="Tooltip",[qE,xi]=mi(Oo),Dg=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:s,disableHoverableContent:i,delayDuration:a}=e,l=Yl(Oo,e.__scopeTooltip),c=gi(t),[d,p]=h.useState(null),m=_t(),f=h.useRef(0),v=i??l.disableHoverableContent,g=a??l.delayDuration,x=h.useRef(!1),[y,b]=On({prop:r,defaultProp:o??!1,onChange:E=>{E?(l.onOpen(),document.dispatchEvent(new CustomEvent(Gl))):l.onClose(),s==null||s(E)},caller:Oo}),C=h.useMemo(()=>y?x.current?"delayed-open":"instant-open":"closed",[y]),k=h.useCallback(()=>{window.clearTimeout(f.current),f.current=0,x.current=!1,b(!0)},[b]),S=h.useCallback(()=>{window.clearTimeout(f.current),f.current=0,b(!1)},[b]),T=h.useCallback(()=>{window.clearTimeout(f.current),f.current=window.setTimeout(()=>{x.current=!0,b(!0),f.current=0},g)},[g,b]);return h.useEffect(()=>()=>{f.current&&(window.clearTimeout(f.current),f.current=0)},[]),u.jsx(ha,{...c,children:u.jsx(qE,{scope:t,contentId:m,open:y,stateAttribute:C,trigger:d,onTriggerChange:p,onTriggerEnter:h.useCallback(()=>{l.isOpenDelayedRef.current?T():k()},[l.isOpenDelayedRef,T,k]),onTriggerLeave:h.useCallback(()=>{v?S():(window.clearTimeout(f.current),f.current=0)},[S,v]),onOpen:k,onClose:S,disableHoverableContent:v,children:n})})};Dg.displayName=Oo;var Xl="TooltipTrigger",Lg=h.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=xi(Xl,n),s=Yl(Xl,n),i=gi(n),a=h.useRef(null),l=je(t,a,o.onTriggerChange),c=h.useRef(!1),d=h.useRef(!1),p=h.useCallback(()=>c.current=!1,[]);return h.useEffect(()=>()=>document.removeEventListener("pointerup",p),[p]),u.jsx(ma,{asChild:!0,...i,children:u.jsx(pe.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:l,onPointerMove:ie(e.onPointerMove,m=>{m.pointerType!=="touch"&&!d.current&&!s.isPointerInTransitRef.current&&(o.onTriggerEnter(),d.current=!0)}),onPointerLeave:ie(e.onPointerLeave,()=>{o.onTriggerLeave(),d.current=!1}),onPointerDown:ie(e.onPointerDown,()=>{o.open&&o.onClose(),c.current=!0,document.addEventListener("pointerup",p,{once:!0})}),onFocus:ie(e.onFocus,()=>{c.current||o.onOpen()}),onBlur:ie(e.onBlur,o.onClose),onClick:ie(e.onClick,o.onClose)})})});Lg.displayName=Xl;var GE="TooltipPortal",[GN,YE]=mi(GE,{forceMount:void 0}),Wr="TooltipContent",$g=h.forwardRef((e,t)=>{const n=YE(Wr,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...s}=e,i=xi(Wr,e.__scopeTooltip);return u.jsx(Ht,{present:r||i.open,children:i.disableHoverableContent?u.jsx(Fg,{side:o,...s,ref:t}):u.jsx(XE,{side:o,...s,ref:t})})}),XE=h.forwardRef((e,t)=>{const n=xi(Wr,e.__scopeTooltip),r=Yl(Wr,e.__scopeTooltip),o=h.useRef(null),s=je(t,o),[i,a]=h.useState(null),{trigger:l,onClose:c}=n,d=o.current,{onPointerInTransitChange:p}=r,m=h.useCallback(()=>{a(null),p(!1)},[p]),f=h.useCallback((v,g)=>{const x=v.currentTarget,y={x:v.clientX,y:v.clientY},b=tI(y,x.getBoundingClientRect()),C=nI(y,b),k=rI(g.getBoundingClientRect()),S=sI([...C,...k]);a(S),p(!0)},[p]);return h.useEffect(()=>()=>m(),[m]),h.useEffect(()=>{if(l&&d){const v=x=>f(x,d),g=x=>f(x,l);return l.addEventListener("pointerleave",v),d.addEventListener("pointerleave",g),()=>{l.removeEventListener("pointerleave",v),d.removeEventListener("pointerleave",g)}}},[l,d,f,m]),h.useEffect(()=>{if(i){const v=g=>{const x=g.target,y={x:g.clientX,y:g.clientY},b=(l==null?void 0:l.contains(x))||(d==null?void 0:d.contains(x)),C=!oI(y,i);b?m():C&&(m(),c())};return document.addEventListener("pointermove",v),()=>document.removeEventListener("pointermove",v)}},[l,d,i,c,m]),u.jsx(Fg,{...e,ref:s})}),[JE,ZE]=mi(Oo,{isInside:!1}),QE=qt.createSlottable("TooltipContent"),Fg=h.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:s,onPointerDownOutside:i,...a}=e,l=xi(Wr,n),c=gi(n),{onClose:d}=l;return h.useEffect(()=>(document.addEventListener(Gl,d),()=>document.removeEventListener(Gl,d)),[d]),h.useEffect(()=>{if(l.trigger){const p=m=>{const f=m.target;f!=null&&f.contains(l.trigger)&&d()};return window.addEventListener("scroll",p,{capture:!0}),()=>window.removeEventListener("scroll",p,{capture:!0})}},[l.trigger,d]),u.jsx(Er,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:p=>p.preventDefault(),onDismiss:d,children:u.jsxs(ga,{"data-state":l.stateAttribute,...c,...a,ref:t,style:{...a.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[u.jsx(QE,{children:r}),u.jsx(JE,{scope:n,isInside:!0,children:u.jsx(eE,{id:l.contentId,role:"tooltip",children:o||r})})]})})});$g.displayName=Wr;var Bg="TooltipArrow",eI=h.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=gi(n);return ZE(Bg,n).isInside?null:u.jsx(xa,{...o,...r,ref:t})});eI.displayName=Bg;function tI(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),o=Math.abs(t.right-e.x),s=Math.abs(t.left-e.x);switch(Math.min(n,r,o,s)){case s:return"left";case o:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function nI(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function rI(e){const{top:t,right:n,bottom:r,left:o}=e;return[{x:o,y:t},{x:n,y:t},{x:n,y:r},{x:o,y:r}]}function oI(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const a=t[s],l=t[i],c=a.x,d=a.y,p=l.x,m=l.y;d>r!=m>r&&n<(p-c)*(r-d)/(m-d)+c&&(o=!o)}return o}function sI(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),iI(t)}function iI(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const o=e[r];for(;t.length>=2;){const s=t[t.length-1],i=t[t.length-2];if((s.x-i.x)*(o.y-i.y)>=(s.y-i.y)*(o.x-i.x))t.pop();else break}t.push(o)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const o=e[r];for(;n.length>=2;){const s=n[n.length-1],i=n[n.length-2];if((s.x-i.x)*(o.y-i.y)>=(s.y-i.y)*(o.x-i.x))n.pop();else break}n.push(o)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var aI=Og,lI=Dg,cI=Lg,zg=$g;const uI=aI,dI=lI,fI=cI,Hg=h.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(zg,{ref:r,sideOffset:t,className:ne("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n}));Hg.displayName=zg.displayName;var Jl="ToastProvider",[Zl,pI,hI]=es("Toast"),[Ug,YN]=cn("Toast",[hI]),[mI,vi]=Ug(Jl),Wg=e=>{const{__scopeToast:t,label:n="Notification",duration:r=5e3,swipeDirection:o="right",swipeThreshold:s=50,children:i}=e,[a,l]=h.useState(null),[c,d]=h.useState(0),p=h.useRef(!1),m=h.useRef(!1);return n.trim()||console.error(`Invalid prop \`label\` supplied to \`${Jl}\`. Expected non-empty \`string\`.`),u.jsx(Zl.Provider,{scope:t,children:u.jsx(mI,{scope:t,label:n,duration:r,swipeDirection:o,swipeThreshold:s,toastCount:c,viewport:a,onViewportChange:l,onToastAdd:h.useCallback(()=>d(f=>f+1),[]),onToastRemove:h.useCallback(()=>d(f=>f-1),[]),isFocusedToastEscapeKeyDownRef:p,isClosePausedRef:m,children:i})})};Wg.displayName=Jl;var Vg="ToastViewport",gI=["F8"],Ql="toast.viewportPause",ec="toast.viewportResume",Kg=h.forwardRef((e,t)=>{const{__scopeToast:n,hotkey:r=gI,label:o="Notifications ({hotkey})",...s}=e,i=vi(Vg,n),a=pI(n),l=h.useRef(null),c=h.useRef(null),d=h.useRef(null),p=h.useRef(null),m=je(t,p,i.onViewportChange),f=r.join("+").replace(/Key/g,"").replace(/Digit/g,""),v=i.toastCount>0;h.useEffect(()=>{const x=y=>{var C;r.length!==0&&r.every(k=>y[k]||y.code===k)&&((C=p.current)==null||C.focus())};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[r]),h.useEffect(()=>{const x=l.current,y=p.current;if(v&&x&&y){const b=()=>{if(!i.isClosePausedRef.current){const T=new CustomEvent(Ql);y.dispatchEvent(T),i.isClosePausedRef.current=!0}},C=()=>{if(i.isClosePausedRef.current){const T=new CustomEvent(ec);y.dispatchEvent(T),i.isClosePausedRef.current=!1}},k=T=>{!x.contains(T.relatedTarget)&&C()},S=()=>{x.contains(document.activeElement)||C()};return x.addEventListener("focusin",b),x.addEventListener("focusout",k),x.addEventListener("pointermove",b),x.addEventListener("pointerleave",S),window.addEventListener("blur",b),window.addEventListener("focus",C),()=>{x.removeEventListener("focusin",b),x.removeEventListener("focusout",k),x.removeEventListener("pointermove",b),x.removeEventListener("pointerleave",S),window.removeEventListener("blur",b),window.removeEventListener("focus",C)}}},[v,i.isClosePausedRef]);const g=h.useCallback(({tabbingDirection:x})=>{const b=a().map(C=>{const k=C.ref.current,S=[k,...AI(k)];return x==="forwards"?S:S.reverse()});return(x==="forwards"?b.reverse():b).flat()},[a]);return h.useEffect(()=>{const x=p.current;if(x){const y=b=>{var S,T,E;const C=b.altKey||b.ctrlKey||b.metaKey;if(b.key==="Tab"&&!C){const A=document.activeElement,P=b.shiftKey;if(b.target===x&&P){(S=c.current)==null||S.focus();return}const H=g({tabbingDirection:P?"backwards":"forwards"}),Y=H.findIndex(_=>_===A);rc(H.slice(Y+1))?b.preventDefault():P?(T=c.current)==null||T.focus():(E=d.current)==null||E.focus()}};return x.addEventListener("keydown",y),()=>x.removeEventListener("keydown",y)}},[a,g]),u.jsxs(qw,{ref:l,role:"region","aria-label":o.replace("{hotkey}",f),tabIndex:-1,style:{pointerEvents:v?void 0:"none"},children:[v&&u.jsx(tc,{ref:c,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"forwards"});rc(x)}}),u.jsx(Zl.Slot,{scope:n,children:u.jsx(pe.ol,{tabIndex:-1,...s,ref:m})}),v&&u.jsx(tc,{ref:d,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"backwards"});rc(x)}})]})});Kg.displayName=Vg;var qg="ToastFocusProxy",tc=h.forwardRef((e,t)=>{const{__scopeToast:n,onFocusFromOutsideViewport:r,...o}=e,s=vi(qg,n);return u.jsx(ci,{tabIndex:0,...o,ref:t,style:{position:"fixed"},onFocus:i=>{var c;const a=i.relatedTarget;!((c=s.viewport)!=null&&c.contains(a))&&r()}})});tc.displayName=qg;var Do="Toast",xI="toast.swipeStart",vI="toast.swipeMove",wI="toast.swipeCancel",bI="toast.swipeEnd",Gg=h.forwardRef((e,t)=>{const{forceMount:n,open:r,defaultOpen:o,onOpenChange:s,...i}=e,[a,l]=On({prop:r,defaultProp:o??!0,onChange:s,caller:Do});return u.jsx(Ht,{present:n||a,children:u.jsx(CI,{open:a,...i,ref:t,onClose:()=>l(!1),onPause:ht(e.onPause),onResume:ht(e.onResume),onSwipeStart:ie(e.onSwipeStart,c=>{c.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:ie(e.onSwipeMove,c=>{const{x:d,y:p}=c.detail.delta;c.currentTarget.setAttribute("data-swipe","move"),c.currentTarget.style.setProperty("--radix-toast-swipe-move-x",`${d}px`),c.currentTarget.style.setProperty("--radix-toast-swipe-move-y",`${p}px`)}),onSwipeCancel:ie(e.onSwipeCancel,c=>{c.currentTarget.setAttribute("data-swipe","cancel"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),c.currentTarget.style.removeProperty("--radix-toast-swipe-end-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-end-y")}),onSwipeEnd:ie(e.onSwipeEnd,c=>{const{x:d,y:p}=c.detail.delta;c.currentTarget.setAttribute("data-swipe","end"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),c.currentTarget.style.setProperty("--radix-toast-swipe-end-x",`${d}px`),c.currentTarget.style.setProperty("--radix-toast-swipe-end-y",`${p}px`),l(!1)})})})});Gg.displayName=Do;var[yI,SI]=Ug(Do,{onClose(){}}),CI=h.forwardRef((e,t)=>{const{__scopeToast:n,type:r="foreground",duration:o,open:s,onClose:i,onEscapeKeyDown:a,onPause:l,onResume:c,onSwipeStart:d,onSwipeMove:p,onSwipeCancel:m,onSwipeEnd:f,...v}=e,g=vi(Do,n),[x,y]=h.useState(null),b=je(t,_=>y(_)),C=h.useRef(null),k=h.useRef(null),S=o||g.duration,T=h.useRef(0),E=h.useRef(S),A=h.useRef(0),{onToastAdd:P,onToastRemove:$}=g,L=ht(()=>{var V;(x==null?void 0:x.contains(document.activeElement))&&((V=g.viewport)==null||V.focus()),i()}),H=h.useCallback(_=>{!_||_===1/0||(window.clearTimeout(A.current),T.current=new Date().getTime(),A.current=window.setTimeout(L,_))},[L]);h.useEffect(()=>{const _=g.viewport;if(_){const V=()=>{H(E.current),c==null||c()},G=()=>{const W=new Date().getTime()-T.current;E.current=E.current-W,window.clearTimeout(A.current),l==null||l()};return _.addEventListener(Ql,G),_.addEventListener(ec,V),()=>{_.removeEventListener(Ql,G),_.removeEventListener(ec,V)}}},[g.viewport,S,l,c,H]),h.useEffect(()=>{s&&!g.isClosePausedRef.current&&H(S)},[s,S,g.isClosePausedRef,H]),h.useEffect(()=>(P(),()=>$()),[P,$]);const Y=h.useMemo(()=>x?tx(x):null,[x]);return g.viewport?u.jsxs(u.Fragment,{children:[Y&&u.jsx(TI,{__scopeToast:n,role:"status","aria-live":r==="foreground"?"assertive":"polite",children:Y}),u.jsx(yI,{scope:n,onClose:L,children:qr.createPortal(u.jsx(Zl.ItemSlot,{scope:n,children:u.jsx(Kw,{asChild:!0,onEscapeKeyDown:ie(a,()=>{g.isFocusedToastEscapeKeyDownRef.current||L(),g.isFocusedToastEscapeKeyDownRef.current=!1}),children:u.jsx(pe.li,{tabIndex:0,"data-state":s?"open":"closed","data-swipe-direction":g.swipeDirection,...v,ref:b,style:{userSelect:"none",touchAction:"none",...e.style},onKeyDown:ie(e.onKeyDown,_=>{_.key==="Escape"&&(a==null||a(_.nativeEvent),_.nativeEvent.defaultPrevented||(g.isFocusedToastEscapeKeyDownRef.current=!0,L()))}),onPointerDown:ie(e.onPointerDown,_=>{_.button===0&&(C.current={x:_.clientX,y:_.clientY})}),onPointerMove:ie(e.onPointerMove,_=>{if(!C.current)return;const V=_.clientX-C.current.x,G=_.clientY-C.current.y,W=!!k.current,D=["left","right"].includes(g.swipeDirection),I=["left","up"].includes(g.swipeDirection)?Math.min:Math.max,U=D?I(0,V):0,Z=D?0:I(0,G),R=_.pointerType==="touch"?10:2,q={x:U,y:Z},j={originalEvent:_,delta:q};W?(k.current=q,wi(vI,p,j,{discrete:!1})):nx(q,g.swipeDirection,R)?(k.current=q,wi(xI,d,j,{discrete:!1}),_.target.setPointerCapture(_.pointerId)):(Math.abs(V)>R||Math.abs(G)>R)&&(C.current=null)}),onPointerUp:ie(e.onPointerUp,_=>{const V=k.current,G=_.target;if(G.hasPointerCapture(_.pointerId)&&G.releasePointerCapture(_.pointerId),k.current=null,C.current=null,V){const W=_.currentTarget,D={originalEvent:_,delta:V};nx(V,g.swipeDirection,g.swipeThreshold)?wi(bI,f,D,{discrete:!0}):wi(wI,m,D,{discrete:!0}),W.addEventListener("click",I=>I.preventDefault(),{once:!0})}})})})}),g.viewport)})]}):null}),TI=e=>{const{__scopeToast:t,children:n,...r}=e,o=vi(Do,t),[s,i]=h.useState(!1),[a,l]=h.useState(!1);return II(()=>i(!0)),h.useEffect(()=>{const c=window.setTimeout(()=>l(!0),1e3);return()=>window.clearTimeout(c)},[]),a?null:u.jsx(co,{asChild:!0,children:u.jsx(ci,{...r,children:s&&u.jsxs(u.Fragment,{children:[o.label," ",n]})})})},kI="ToastTitle",Yg=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(pe.div,{...r,ref:t})});Yg.displayName=kI;var EI="ToastDescription",Xg=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(pe.div,{...r,ref:t})});Xg.displayName=EI;var Jg="ToastAction",Zg=h.forwardRef((e,t)=>{const{altText:n,...r}=e;return n.trim()?u.jsx(ex,{altText:n,asChild:!0,children:u.jsx(nc,{...r,ref:t})}):(console.error(`Invalid prop \`altText\` supplied to \`${Jg}\`. Expected non-empty \`string\`.`),null)});Zg.displayName=Jg;var Qg="ToastClose",nc=h.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e,o=SI(Qg,n);return u.jsx(ex,{asChild:!0,children:u.jsx(pe.button,{type:"button",...r,ref:t,onClick:ie(e.onClick,o.onClose)})})});nc.displayName=Qg;var ex=h.forwardRef((e,t)=>{const{__scopeToast:n,altText:r,...o}=e;return u.jsx(pe.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":r||void 0,...o,ref:t})});function tx(e){const t=[];return Array.from(e.childNodes).forEach(r=>{if(r.nodeType===r.TEXT_NODE&&r.textContent&&t.push(r.textContent),NI(r)){const o=r.ariaHidden||r.hidden||r.style.display==="none",s=r.dataset.radixToastAnnounceExclude==="";if(!o)if(s){const i=r.dataset.radixToastAnnounceAlt;i&&t.push(i)}else t.push(...tx(r))}}),t}function wi(e,t,n,{discrete:r}){const o=n.originalEvent.currentTarget,s=new CustomEvent(e,{bubbles:!0,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?Yi(o,s):o.dispatchEvent(s)}var nx=(e,t,n=0)=>{const r=Math.abs(e.x),o=Math.abs(e.y),s=r>o;return t==="left"||t==="right"?s&&r>n:!s&&o>n};function II(e=()=>{}){const t=ht(e);Et(()=>{let n=0,r=0;return n=window.requestAnimationFrame(()=>r=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(n),window.cancelAnimationFrame(r)}},[t])}function NI(e){return e.nodeType===e.ELEMENT_NODE}function AI(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function rc(e){const t=document.activeElement;return e.some(n=>n===t?!0:(n.focus(),document.activeElement!==t))}var PI=Wg,rx=Kg,ox=Gg,sx=Yg,ix=Xg,ax=Zg,lx=nc;const jI=PI,cx=h.forwardRef(({className:e,...t},n)=>u.jsx(rx,{ref:n,className:ne("fixed bottom-0 right-0 z-[100] flex max-h-screen w-full flex-col p-4 md:max-w-[420px]",e),...t}));cx.displayName=rx.displayName;const _I=Kr.cva("group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-8 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",{variants:{variant:{default:"border bg-background text-foreground",destructive:"destructive group border-destructive bg-destructive text-destructive-foreground"}},defaultVariants:{variant:"default"}}),ux=h.forwardRef(({className:e,variant:t,...n},r)=>u.jsx(ox,{ref:r,className:ne(_I({variant:t}),e),...n}));ux.displayName=ox.displayName;const RI=h.forwardRef(({className:e,...t},n)=>u.jsx(ax,{ref:n,className:ne("inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors hover:bg-secondary focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive",e),...t}));RI.displayName=ax.displayName;const dx=h.forwardRef(({className:e,...t},n)=>u.jsx(lx,{ref:n,className:ne("absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-2 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",e),"toast-close":"",...t,children:u.jsx(le.X,{className:"h-4 w-4"})}));dx.displayName=lx.displayName;const fx=h.forwardRef(({className:e,...t},n)=>u.jsx(sx,{ref:n,className:ne("text-sm font-semibold",e),...t}));fx.displayName=sx.displayName;const px=h.forwardRef(({className:e,...t},n)=>u.jsx(ix,{ref:n,className:ne("text-sm opacity-90",e),...t}));px.displayName=ix.displayName;function MI(){const{toasts:e}=fl();return u.jsxs(jI,{children:[e.map(function({id:t,title:n,description:r,action:o,...s}){return u.jsxs(ux,{...s,children:[u.jsxs("div",{className:"grid gap-1",children:[n&&u.jsx(fx,{children:n}),r&&u.jsx(px,{children:r})]}),o,u.jsx(dx,{})]},t)}),u.jsx(cx,{})]})}var OI=(e,t,n,r,o,s,i,a)=>{let l=document.documentElement,c=["light","dark"];function d(f){(Array.isArray(e)?e:[e]).forEach(v=>{let g=v==="class",x=g&&s?o.map(y=>s[y]||y):o;g?(l.classList.remove(...x),l.classList.add(s&&s[f]?s[f]:f)):l.setAttribute(v,f)}),p(f)}function p(f){a&&c.includes(f)&&(l.style.colorScheme=f)}function m(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}if(r)d(r);else try{let f=localStorage.getItem(t)||n,v=i&&f==="system"?m():f;d(v)}catch{}},DI=h.createContext(void 0),LI={setTheme:e=>{},themes:[]},$I=()=>{var e;return(e=h.useContext(DI))!=null?e:LI};h.memo(({forcedTheme:e,storageKey:t,attribute:n,enableSystem:r,enableColorScheme:o,defaultTheme:s,value:i,themes:a,nonce:l,scriptProps:c})=>{let d=JSON.stringify([n,t,s,e,a,i,r,o]).slice(1,-1);return h.createElement("script",{...c,suppressHydrationWarning:!0,nonce:typeof window>"u"?l:"",dangerouslySetInnerHTML:{__html:`(${OI.toString()})(${d})`}})});var FI=e=>{switch(e){case"success":return HI;case"info":return WI;case"warning":return UI;case"error":return VI;default:return null}},BI=Array(12).fill(0),zI=({visible:e,className:t})=>w.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},w.createElement("div",{className:"sonner-spinner"},BI.map((n,r)=>w.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),HI=w.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},w.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),UI=w.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},w.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),WI=w.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},w.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),VI=w.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},w.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),KI=w.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},w.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),w.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),qI=()=>{let[e,t]=w.useState(document.hidden);return w.useEffect(()=>{let n=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),e},oc=1,GI=class{constructor(){this.subscribe=e=>(this.subscribers.push(e),()=>{let t=this.subscribers.indexOf(e);this.subscribers.splice(t,1)}),this.publish=e=>{this.subscribers.forEach(t=>t(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e]},this.create=e=>{var t;let{message:n,...r}=e,o=typeof(e==null?void 0:e.id)=="number"||((t=e.id)==null?void 0:t.length)>0?e.id:oc++,s=this.toasts.find(a=>a.id===o),i=e.dismissible===void 0?!0:e.dismissible;return this.dismissedToasts.has(o)&&this.dismissedToasts.delete(o),s?this.toasts=this.toasts.map(a=>a.id===o?(this.publish({...a,...e,id:o,title:n}),{...a,...e,id:o,dismissible:i,title:n}):a):this.addToast({title:n,...r,dismissible:i,id:o}),o},this.dismiss=e=>(this.dismissedToasts.add(e),e||this.toasts.forEach(t=>{this.subscribers.forEach(n=>n({id:t.id,dismiss:!0}))}),this.subscribers.forEach(t=>t({id:e,dismiss:!0})),e),this.message=(e,t)=>this.create({...t,message:e}),this.error=(e,t)=>this.create({...t,message:e,type:"error"}),this.success=(e,t)=>this.create({...t,type:"success",message:e}),this.info=(e,t)=>this.create({...t,type:"info",message:e}),this.warning=(e,t)=>this.create({...t,type:"warning",message:e}),this.loading=(e,t)=>this.create({...t,type:"loading",message:e}),this.promise=(e,t)=>{if(!t)return;let n;t.loading!==void 0&&(n=this.create({...t,promise:e,type:"loading",message:t.loading,description:typeof t.description!="function"?t.description:void 0}));let r=e instanceof Promise?e:e(),o=n!==void 0,s,i=r.then(async l=>{if(s=["resolve",l],w.isValidElement(l))o=!1,this.create({id:n,type:"default",message:l});else if(XI(l)&&!l.ok){o=!1;let c=typeof t.error=="function"?await t.error(`HTTP error! status: ${l.status}`):t.error,d=typeof t.description=="function"?await t.description(`HTTP error! status: ${l.status}`):t.description;this.create({id:n,type:"error",message:c,description:d})}else if(t.success!==void 0){o=!1;let c=typeof t.success=="function"?await t.success(l):t.success,d=typeof t.description=="function"?await t.description(l):t.description;this.create({id:n,type:"success",message:c,description:d})}}).catch(async l=>{if(s=["reject",l],t.error!==void 0){o=!1;let c=typeof t.error=="function"?await t.error(l):t.error,d=typeof t.description=="function"?await t.description(l):t.description;this.create({id:n,type:"error",message:c,description:d})}}).finally(()=>{var l;o&&(this.dismiss(n),n=void 0),(l=t.finally)==null||l.call(t)}),a=()=>new Promise((l,c)=>i.then(()=>s[0]==="reject"?c(s[1]):l(s[1])).catch(c));return typeof n!="string"&&typeof n!="number"?{unwrap:a}:Object.assign(n,{unwrap:a})},this.custom=(e,t)=>{let n=(t==null?void 0:t.id)||oc++;return this.create({jsx:e(n),id:n,...t}),n},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},Vt=new GI,YI=(e,t)=>{let n=(t==null?void 0:t.id)||oc++;return Vt.addToast({title:e,...t,id:n}),n},XI=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",JI=YI,ZI=()=>Vt.toasts,QI=()=>Vt.getActiveToasts();Object.assign(JI,{success:Vt.success,info:Vt.info,warning:Vt.warning,error:Vt.error,custom:Vt.custom,message:Vt.message,promise:Vt.promise,dismiss:Vt.dismiss,loading:Vt.loading},{getHistory:ZI,getToasts:QI});function eN(e,{insertAt:t}={}){if(typeof document>"u")return;let n=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",t==="top"&&n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r),r.styleSheet?r.styleSheet.cssText=e:r.appendChild(document.createTextNode(e))}eN(`:where(html[dir="ltr"]),:where([data-sonner-toaster][dir="ltr"]){--toast-icon-margin-start: -3px;--toast-icon-margin-end: 4px;--toast-svg-margin-start: -1px;--toast-svg-margin-end: 0px;--toast-button-margin-start: auto;--toast-button-margin-end: 0;--toast-close-button-start: 0;--toast-close-button-end: unset;--toast-close-button-transform: translate(-35%, -35%)}:where(html[dir="rtl"]),:where([data-sonner-toaster][dir="rtl"]){--toast-icon-margin-start: 4px;--toast-icon-margin-end: -3px;--toast-svg-margin-start: 0px;--toast-svg-margin-end: -1px;--toast-button-margin-start: 0;--toast-button-margin-end: auto;--toast-close-button-start: unset;--toast-close-button-end: 0;--toast-close-button-transform: translate(35%, -35%)}:where([data-sonner-toaster]){position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1: hsl(0, 0%, 99%);--gray2: hsl(0, 0%, 97.3%);--gray3: hsl(0, 0%, 95.1%);--gray4: hsl(0, 0%, 93%);--gray5: hsl(0, 0%, 90.9%);--gray6: hsl(0, 0%, 88.7%);--gray7: hsl(0, 0%, 85.8%);--gray8: hsl(0, 0%, 78%);--gray9: hsl(0, 0%, 56.1%);--gray10: hsl(0, 0%, 52.3%);--gray11: hsl(0, 0%, 43.5%);--gray12: hsl(0, 0%, 9%);--border-radius: 8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:none;z-index:999999999;transition:transform .4s ease}:where([data-sonner-toaster][data-lifted="true"]){transform:translateY(-10px)}@media (hover: none) and (pointer: coarse){:where([data-sonner-toaster][data-lifted="true"]){transform:none}}:where([data-sonner-toaster][data-x-position="right"]){right:var(--offset-right)}:where([data-sonner-toaster][data-x-position="left"]){left:var(--offset-left)}:where([data-sonner-toaster][data-x-position="center"]){left:50%;transform:translate(-50%)}:where([data-sonner-toaster][data-y-position="top"]){top:var(--offset-top)}:where([data-sonner-toaster][data-y-position="bottom"]){bottom:var(--offset-bottom)}:where([data-sonner-toast]){--y: translateY(100%);--lift-amount: calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);filter:blur(0);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:none;overflow-wrap:anywhere}:where([data-sonner-toast][data-styled="true"]){padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px #0000001a;width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}:where([data-sonner-toast]:focus-visible){box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast][data-y-position="top"]){top:0;--y: translateY(-100%);--lift: 1;--lift-amount: calc(1 * var(--gap))}:where([data-sonner-toast][data-y-position="bottom"]){bottom:0;--y: translateY(100%);--lift: -1;--lift-amount: calc(var(--lift) * var(--gap))}:where([data-sonner-toast]) :where([data-description]){font-weight:400;line-height:1.4;color:inherit}:where([data-sonner-toast]) :where([data-title]){font-weight:500;line-height:1.5;color:inherit}:where([data-sonner-toast]) :where([data-icon]){display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}:where([data-sonner-toast][data-promise="true"]) :where([data-icon])>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}:where([data-sonner-toast]) :where([data-icon])>*{flex-shrink:0}:where([data-sonner-toast]) :where([data-icon]) svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}:where([data-sonner-toast]) :where([data-content]){display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;cursor:pointer;outline:none;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}:where([data-sonner-toast]) :where([data-button]):focus-visible{box-shadow:0 0 0 2px #0006}:where([data-sonner-toast]) :where([data-button]):first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}:where([data-sonner-toast]) :where([data-cancel]){color:var(--normal-text);background:rgba(0,0,0,.08)}:where([data-sonner-toast][data-theme="dark"]) :where([data-cancel]){background:rgba(255,255,255,.3)}:where([data-sonner-toast]) :where([data-close-button]){position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast] [data-close-button]{background:var(--gray1)}:where([data-sonner-toast]) :where([data-close-button]):focus-visible{box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast]) :where([data-disabled="true"]){cursor:not-allowed}:where([data-sonner-toast]):hover :where([data-close-button]):hover{background:var(--gray2);border-color:var(--gray5)}:where([data-sonner-toast][data-swiping="true"]):before{content:"";position:absolute;left:-50%;right:-50%;height:100%;z-index:-1}:where([data-sonner-toast][data-y-position="top"][data-swiping="true"]):before{bottom:50%;transform:scaleY(3) translateY(50%)}:where([data-sonner-toast][data-y-position="bottom"][data-swiping="true"]):before{top:50%;transform:scaleY(3) translateY(-50%)}:where([data-sonner-toast][data-swiping="false"][data-removed="true"]):before{content:"";position:absolute;inset:0;transform:scaleY(2)}:where([data-sonner-toast]):after{content:"";position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}:where([data-sonner-toast][data-mounted="true"]){--y: translateY(0);opacity:1}:where([data-sonner-toast][data-expanded="false"][data-front="false"]){--scale: var(--toasts-before) * .05 + 1;--y: translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}:where([data-sonner-toast])>*{transition:opacity .4s}:where([data-sonner-toast][data-expanded="false"][data-front="false"][data-styled="true"])>*{opacity:0}:where([data-sonner-toast][data-visible="false"]){opacity:0;pointer-events:none}:where([data-sonner-toast][data-mounted="true"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}:where([data-sonner-toast][data-removed="true"][data-front="true"][data-swipe-out="false"]){--y: translateY(calc(var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="false"]){--y: translateY(40%);opacity:0;transition:transform .5s,opacity .2s}:where([data-sonner-toast][data-removed="true"][data-front="false"]):before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y, 0px)) translate(var(--swipe-amount-x, 0px));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width: 600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-theme=light]{--normal-bg: #fff;--normal-border: var(--gray4);--normal-text: var(--gray12);--success-bg: hsl(143, 85%, 96%);--success-border: hsl(145, 92%, 91%);--success-text: hsl(140, 100%, 27%);--info-bg: hsl(208, 100%, 97%);--info-border: hsl(221, 91%, 91%);--info-text: hsl(210, 92%, 45%);--warning-bg: hsl(49, 100%, 97%);--warning-border: hsl(49, 91%, 91%);--warning-text: hsl(31, 92%, 45%);--error-bg: hsl(359, 100%, 97%);--error-border: hsl(359, 100%, 94%);--error-text: hsl(360, 100%, 45%)}[data-sonner-toaster][data-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg: #000;--normal-border: hsl(0, 0%, 20%);--normal-text: var(--gray1)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg: #fff;--normal-border: var(--gray3);--normal-text: var(--gray12)}[data-sonner-toaster][data-theme=dark]{--normal-bg: #000;--normal-bg-hover: hsl(0, 0%, 12%);--normal-border: hsl(0, 0%, 20%);--normal-border-hover: hsl(0, 0%, 25%);--normal-text: var(--gray1);--success-bg: hsl(150, 100%, 6%);--success-border: hsl(147, 100%, 12%);--success-text: hsl(150, 86%, 65%);--info-bg: hsl(215, 100%, 6%);--info-border: hsl(223, 100%, 12%);--info-text: hsl(216, 87%, 65%);--warning-bg: hsl(64, 100%, 6%);--warning-border: hsl(60, 100%, 12%);--warning-text: hsl(46, 87%, 65%);--error-bg: hsl(358, 76%, 10%);--error-border: hsl(357, 89%, 16%);--error-text: hsl(358, 100%, 81%)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success],[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info],[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning],[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error],[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size: 16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:nth-child(1){animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}to{opacity:.15}}@media (prefers-reduced-motion){[data-sonner-toast],[data-sonner-toast]>*,.sonner-loading-bar{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}
|
|
131
|
+
`);function bi(e){return e.label!==void 0}var tN=3,nN="32px",rN="16px",hx=4e3,oN=356,sN=14,iN=20,aN=200;function gn(...e){return e.filter(Boolean).join(" ")}function lN(e){let[t,n]=e.split("-"),r=[];return t&&r.push(t),n&&r.push(n),r}var cN=e=>{var t,n,r,o,s,i,a,l,c,d,p;let{invert:m,toast:f,unstyled:v,interacting:g,setHeights:x,visibleToasts:y,heights:b,index:C,toasts:k,expanded:S,removeToast:T,defaultRichColors:E,closeButton:A,style:P,cancelButtonStyle:$,actionButtonStyle:L,className:H="",descriptionClassName:Y="",duration:_,position:V,gap:G,loadingIcon:W,expandByDefault:D,classNames:I,icons:U,closeButtonAriaLabel:Z="Close toast",pauseWhenPageIsHidden:R}=e,[q,j]=w.useState(null),[B,Q]=w.useState(null),[M,O]=w.useState(!1),[F,J]=w.useState(!1),[oe,ae]=w.useState(!1),[Se,we]=w.useState(!1),[Re,$e]=w.useState(!1),[Fe,Ge]=w.useState(0),[Je,vt]=w.useState(0),ct=w.useRef(f.duration||_||hx),tt=w.useRef(null),Oe=w.useRef(null),Ve=C===0,He=C+1<=y,Te=f.type,Ae=f.dismissible!==!1,ut=f.className||"",dt=f.descriptionClassName||"",it=w.useMemo(()=>b.findIndex(me=>me.toastId===f.id)||0,[b,f.id]),At=w.useMemo(()=>{var me;return(me=f.closeButton)!=null?me:A},[f.closeButton,A]),St=w.useMemo(()=>f.duration||_||hx,[f.duration,_]),ft=w.useRef(0),Ct=w.useRef(0),Tt=w.useRef(0),It=w.useRef(null),[en,kt]=V.split("-"),Ie=w.useMemo(()=>b.reduce((me,Ne,Ue)=>Ue>=it?me:me+Ne.height,0),[b,it]),Ke=qI(),Nt=f.invert||m,te=Te==="loading";Ct.current=w.useMemo(()=>it*G+Ie,[it,Ie]),w.useEffect(()=>{ct.current=St},[St]),w.useEffect(()=>{O(!0)},[]),w.useEffect(()=>{let me=Oe.current;if(me){let Ne=me.getBoundingClientRect().height;return vt(Ne),x(Ue=>[{toastId:f.id,height:Ne,position:f.position},...Ue]),()=>x(Ue=>Ue.filter(at=>at.toastId!==f.id))}},[x,f.id]),w.useLayoutEffect(()=>{if(!M)return;let me=Oe.current,Ne=me.style.height;me.style.height="auto";let Ue=me.getBoundingClientRect().height;me.style.height=Ne,vt(Ue),x(at=>at.find(rt=>rt.toastId===f.id)?at.map(rt=>rt.toastId===f.id?{...rt,height:Ue}:rt):[{toastId:f.id,height:Ue,position:f.position},...at])},[M,f.title,f.description,x,f.id]);let xe=w.useCallback(()=>{J(!0),Ge(Ct.current),x(me=>me.filter(Ne=>Ne.toastId!==f.id)),setTimeout(()=>{T(f)},aN)},[f,T,x,Ct]);w.useEffect(()=>{if(f.promise&&Te==="loading"||f.duration===1/0||f.type==="loading")return;let me;return S||g||R&&Ke?(()=>{if(Tt.current<ft.current){let Ne=new Date().getTime()-ft.current;ct.current=ct.current-Ne}Tt.current=new Date().getTime()})():ct.current!==1/0&&(ft.current=new Date().getTime(),me=setTimeout(()=>{var Ne;(Ne=f.onAutoClose)==null||Ne.call(f,f),xe()},ct.current)),()=>clearTimeout(me)},[S,g,f,Te,R,Ke,xe]),w.useEffect(()=>{f.delete&&xe()},[xe,f.delete]);function nt(){var me,Ne,Ue;return U!=null&&U.loading?w.createElement("div",{className:gn(I==null?void 0:I.loader,(me=f==null?void 0:f.classNames)==null?void 0:me.loader,"sonner-loader"),"data-visible":Te==="loading"},U.loading):W?w.createElement("div",{className:gn(I==null?void 0:I.loader,(Ne=f==null?void 0:f.classNames)==null?void 0:Ne.loader,"sonner-loader"),"data-visible":Te==="loading"},W):w.createElement(zI,{className:gn(I==null?void 0:I.loader,(Ue=f==null?void 0:f.classNames)==null?void 0:Ue.loader),visible:Te==="loading"})}return w.createElement("li",{tabIndex:0,ref:Oe,className:gn(H,ut,I==null?void 0:I.toast,(t=f==null?void 0:f.classNames)==null?void 0:t.toast,I==null?void 0:I.default,I==null?void 0:I[Te],(n=f==null?void 0:f.classNames)==null?void 0:n[Te]),"data-sonner-toast":"","data-rich-colors":(r=f.richColors)!=null?r:E,"data-styled":!(f.jsx||f.unstyled||v),"data-mounted":M,"data-promise":!!f.promise,"data-swiped":Re,"data-removed":F,"data-visible":He,"data-y-position":en,"data-x-position":kt,"data-index":C,"data-front":Ve,"data-swiping":oe,"data-dismissible":Ae,"data-type":Te,"data-invert":Nt,"data-swipe-out":Se,"data-swipe-direction":B,"data-expanded":!!(S||D&&M),style:{"--index":C,"--toasts-before":C,"--z-index":k.length-C,"--offset":`${F?Fe:Ct.current}px`,"--initial-height":D?"auto":`${Je}px`,...P,...f.style},onDragEnd:()=>{ae(!1),j(null),It.current=null},onPointerDown:me=>{te||!Ae||(tt.current=new Date,Ge(Ct.current),me.target.setPointerCapture(me.pointerId),me.target.tagName!=="BUTTON"&&(ae(!0),It.current={x:me.clientX,y:me.clientY}))},onPointerUp:()=>{var me,Ne,Ue,at;if(Se||!Ae)return;It.current=null;let rt=Number(((me=Oe.current)==null?void 0:me.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),wt=Number(((Ne=Oe.current)==null?void 0:Ne.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),Pt=new Date().getTime()-((Ue=tt.current)==null?void 0:Ue.getTime()),de=q==="x"?rt:wt,Pe=Math.abs(de)/Pt;if(Math.abs(de)>=iN||Pe>.11){Ge(Ct.current),(at=f.onDismiss)==null||at.call(f,f),Q(q==="x"?rt>0?"right":"left":wt>0?"down":"up"),xe(),we(!0),$e(!1);return}ae(!1),j(null)},onPointerMove:me=>{var Ne,Ue,at,rt;if(!It.current||!Ae||((Ne=window.getSelection())==null?void 0:Ne.toString().length)>0)return;let wt=me.clientY-It.current.y,Pt=me.clientX-It.current.x,de=(Ue=e.swipeDirections)!=null?Ue:lN(V);!q&&(Math.abs(Pt)>1||Math.abs(wt)>1)&&j(Math.abs(Pt)>Math.abs(wt)?"x":"y");let Pe={x:0,y:0};q==="y"?(de.includes("top")||de.includes("bottom"))&&(de.includes("top")&&wt<0||de.includes("bottom")&&wt>0)&&(Pe.y=wt):q==="x"&&(de.includes("left")||de.includes("right"))&&(de.includes("left")&&Pt<0||de.includes("right")&&Pt>0)&&(Pe.x=Pt),(Math.abs(Pe.x)>0||Math.abs(Pe.y)>0)&&$e(!0),(at=Oe.current)==null||at.style.setProperty("--swipe-amount-x",`${Pe.x}px`),(rt=Oe.current)==null||rt.style.setProperty("--swipe-amount-y",`${Pe.y}px`)}},At&&!f.jsx?w.createElement("button",{"aria-label":Z,"data-disabled":te,"data-close-button":!0,onClick:te||!Ae?()=>{}:()=>{var me;xe(),(me=f.onDismiss)==null||me.call(f,f)},className:gn(I==null?void 0:I.closeButton,(o=f==null?void 0:f.classNames)==null?void 0:o.closeButton)},(s=U==null?void 0:U.close)!=null?s:KI):null,f.jsx||w.isValidElement(f.title)?f.jsx?f.jsx:typeof f.title=="function"?f.title():f.title:w.createElement(w.Fragment,null,Te||f.icon||f.promise?w.createElement("div",{"data-icon":"",className:gn(I==null?void 0:I.icon,(i=f==null?void 0:f.classNames)==null?void 0:i.icon)},f.promise||f.type==="loading"&&!f.icon?f.icon||nt():null,f.type!=="loading"?f.icon||(U==null?void 0:U[Te])||FI(Te):null):null,w.createElement("div",{"data-content":"",className:gn(I==null?void 0:I.content,(a=f==null?void 0:f.classNames)==null?void 0:a.content)},w.createElement("div",{"data-title":"",className:gn(I==null?void 0:I.title,(l=f==null?void 0:f.classNames)==null?void 0:l.title)},typeof f.title=="function"?f.title():f.title),f.description?w.createElement("div",{"data-description":"",className:gn(Y,dt,I==null?void 0:I.description,(c=f==null?void 0:f.classNames)==null?void 0:c.description)},typeof f.description=="function"?f.description():f.description):null),w.isValidElement(f.cancel)?f.cancel:f.cancel&&bi(f.cancel)?w.createElement("button",{"data-button":!0,"data-cancel":!0,style:f.cancelButtonStyle||$,onClick:me=>{var Ne,Ue;bi(f.cancel)&&Ae&&((Ue=(Ne=f.cancel).onClick)==null||Ue.call(Ne,me),xe())},className:gn(I==null?void 0:I.cancelButton,(d=f==null?void 0:f.classNames)==null?void 0:d.cancelButton)},f.cancel.label):null,w.isValidElement(f.action)?f.action:f.action&&bi(f.action)?w.createElement("button",{"data-button":!0,"data-action":!0,style:f.actionButtonStyle||L,onClick:me=>{var Ne,Ue;bi(f.action)&&((Ue=(Ne=f.action).onClick)==null||Ue.call(Ne,me),!me.defaultPrevented&&xe())},className:gn(I==null?void 0:I.actionButton,(p=f==null?void 0:f.classNames)==null?void 0:p.actionButton)},f.action.label):null))};function mx(){if(typeof window>"u"||typeof document>"u")return"ltr";let e=document.documentElement.getAttribute("dir");return e==="auto"||!e?window.getComputedStyle(document.documentElement).direction:e}function uN(e,t){let n={};return[e,t].forEach((r,o)=>{let s=o===1,i=s?"--mobile-offset":"--offset",a=s?rN:nN;function l(c){["top","right","bottom","left"].forEach(d=>{n[`${i}-${d}`]=typeof c=="number"?`${c}px`:c})}typeof r=="number"||typeof r=="string"?l(r):typeof r=="object"?["top","right","bottom","left"].forEach(c=>{r[c]===void 0?n[`${i}-${c}`]=a:n[`${i}-${c}`]=typeof r[c]=="number"?`${r[c]}px`:r[c]}):l(a)}),n}var dN=w.forwardRef(function(e,t){let{invert:n,position:r="bottom-right",hotkey:o=["altKey","KeyT"],expand:s,closeButton:i,className:a,offset:l,mobileOffset:c,theme:d="light",richColors:p,duration:m,style:f,visibleToasts:v=tN,toastOptions:g,dir:x=mx(),gap:y=sN,loadingIcon:b,icons:C,containerAriaLabel:k="Notifications",pauseWhenPageIsHidden:S}=e,[T,E]=w.useState([]),A=w.useMemo(()=>Array.from(new Set([r].concat(T.filter(R=>R.position).map(R=>R.position)))),[T,r]),[P,$]=w.useState([]),[L,H]=w.useState(!1),[Y,_]=w.useState(!1),[V,G]=w.useState(d!=="system"?d:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),W=w.useRef(null),D=o.join("+").replace(/Key/g,"").replace(/Digit/g,""),I=w.useRef(null),U=w.useRef(!1),Z=w.useCallback(R=>{E(q=>{var j;return(j=q.find(B=>B.id===R.id))!=null&&j.delete||Vt.dismiss(R.id),q.filter(({id:B})=>B!==R.id)})},[]);return w.useEffect(()=>Vt.subscribe(R=>{if(R.dismiss){E(q=>q.map(j=>j.id===R.id?{...j,delete:!0}:j));return}setTimeout(()=>{Lo.flushSync(()=>{E(q=>{let j=q.findIndex(B=>B.id===R.id);return j!==-1?[...q.slice(0,j),{...q[j],...R},...q.slice(j+1)]:[R,...q]})})})}),[]),w.useEffect(()=>{if(d!=="system"){G(d);return}if(d==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?G("dark"):G("light")),typeof window>"u")return;let R=window.matchMedia("(prefers-color-scheme: dark)");try{R.addEventListener("change",({matches:q})=>{G(q?"dark":"light")})}catch{R.addListener(({matches:j})=>{try{G(j?"dark":"light")}catch(B){console.error(B)}})}},[d]),w.useEffect(()=>{T.length<=1&&H(!1)},[T]),w.useEffect(()=>{let R=q=>{var j,B;o.every(Q=>q[Q]||q.code===Q)&&(H(!0),(j=W.current)==null||j.focus()),q.code==="Escape"&&(document.activeElement===W.current||(B=W.current)!=null&&B.contains(document.activeElement))&&H(!1)};return document.addEventListener("keydown",R),()=>document.removeEventListener("keydown",R)},[o]),w.useEffect(()=>{if(W.current)return()=>{I.current&&(I.current.focus({preventScroll:!0}),I.current=null,U.current=!1)}},[W.current]),w.createElement("section",{ref:t,"aria-label":`${k} ${D}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},A.map((R,q)=>{var j;let[B,Q]=R.split("-");return T.length?w.createElement("ol",{key:R,dir:x==="auto"?mx():x,tabIndex:-1,ref:W,className:a,"data-sonner-toaster":!0,"data-theme":V,"data-y-position":B,"data-lifted":L&&T.length>1&&!s,"data-x-position":Q,style:{"--front-toast-height":`${((j=P[0])==null?void 0:j.height)||0}px`,"--width":`${oN}px`,"--gap":`${y}px`,...f,...uN(l,c)},onBlur:M=>{U.current&&!M.currentTarget.contains(M.relatedTarget)&&(U.current=!1,I.current&&(I.current.focus({preventScroll:!0}),I.current=null))},onFocus:M=>{M.target instanceof HTMLElement&&M.target.dataset.dismissible==="false"||U.current||(U.current=!0,I.current=M.relatedTarget)},onMouseEnter:()=>H(!0),onMouseMove:()=>H(!0),onMouseLeave:()=>{Y||H(!1)},onDragEnd:()=>H(!1),onPointerDown:M=>{M.target instanceof HTMLElement&&M.target.dataset.dismissible==="false"||_(!0)},onPointerUp:()=>_(!1)},T.filter(M=>!M.position&&q===0||M.position===R).map((M,O)=>{var F,J;return w.createElement(cN,{key:M.id,icons:C,index:O,toast:M,defaultRichColors:p,duration:(F=g==null?void 0:g.duration)!=null?F:m,className:g==null?void 0:g.className,descriptionClassName:g==null?void 0:g.descriptionClassName,invert:n,visibleToasts:v,closeButton:(J=g==null?void 0:g.closeButton)!=null?J:i,interacting:Y,position:R,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:Z,toasts:T.filter(oe=>oe.position==M.position),heights:P.filter(oe=>oe.position==M.position),setHeights:$,expandByDefault:s,gap:y,loadingIcon:b,expanded:L,pauseWhenPageIsHidden:S,swipeDirections:e.swipeDirections})})):null}))});const fN=({...e})=>{const{theme:t="system"}=$I();return u.jsx(dN,{theme:t,className:"toaster group",toastOptions:{classNames:{toast:"group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",description:"group-[.toast]:text-muted-foreground",actionButton:"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",cancelButton:"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground"}},...e})};z.Api=ow,z.ApiClient=rw,z.ApiProvider=du,z.ArtifactRenderer=Fh,z.Badge=Yh,z.Button=Ye,z.Card=ml,z.CardContent=ti,z.CardDescription=vl,z.CardHeader=gl,z.CardTitle=xl,z.ChatApi=Jo,z.ChatApp=Kk,z.ChatInput=sp,z.ChatInputRow=ip,z.ChatInterface=Fr,z.ChatProviders=Tr,z.ChatWidget=Yk,z.Command=Al,z.CommandEmpty=_l,z.CommandGroup=Rl,z.CommandInput=Pl,z.CommandItem=Ml,z.CommandList=jl,z.DEFAULT_TIMEOUT_MS=su,z.Dialog=cl,z.DialogContent=Vs,z.DialogHeader=Ks,z.DialogTitle=qs,z.DropdownMenu=Is,z.DropdownMenuContent=xo,z.DropdownMenuItem=Fn,z.DropdownMenuTrigger=Ns,z.FileViewerModal=Th,z.HISTORY_TIMEOUT_MS=iu,z.Input=zl,z.InterruptPartRenderer=wl,z.Label=Am,z.MarkdownContent=fr,z.MessageComponent=ni,z.MessageList=Sl,z.MessageRow=yl,z.NewChatButton=Xk,z.PlotArtifact=$h,z.SETTINGS_STORAGE_KEY=Gi,z.ScrollArea=Bl,z.Select=AE,z.SelectContent=gg,z.SelectItem=xg,z.SelectTrigger=pg,z.SelectValue=PE,z.Separator=yg,z.Sheet=zE,z.SheetContent=Pg,z.SheetDescription=Rg,z.SheetHeader=jg,z.SheetTitle=_g,z.SheetTrigger=HE,z.SimpleChat=qk,z.SimpleJsonView=ei,z.Sonner=fN,z.StreamProgress=Bh,z.Switch=Ng,z.Textarea=Ma,z.ThinkingIndicator=Hh,z.ThreadListItem=Cm,z.ThreadManager=li,z.ThreadStateProvider=zu,z.ThreadsProvider=Su,z.TimelineColumn=Mx,z.Toaster=MI,z.ToolComponent=qh,z.Tooltip=dI,z.TooltipContent=Hg,z.TooltipProvider=uI,z.TooltipTrigger=fI,z.UserTextContent=Uh,z.applySettings=Pw,z.buildCheckpointIndex=lc,z.buildCheckpointPreviewMap=Sx,z.buildLabelParts=Au,z.chatApiClient=Nn,z.collectText=ku,z.createArtifactPreviewFromPlot=ju,z.createArtifactPreviewFromSource=Pu,z.del=Li,z.downloadFileById=lu,z.extractConfigFields=Ci,z.extractToolContent=tr,z.extractToolMeta=Qo,z.fileToBase64=fu,z.formatToolOutput=Tu,z.get=Yt,z.getAgentNameFromMessage=Iu,z.getChatToken=ru,z.getCheckpointForMessage=Cx,z.getCurrentSettings=Aw,z.getDefaultApiConfig=Xu,z.getDefaultChatSettings=Ju,z.getFileContent=Fi,z.getFileInfo=iw,z.getMessageAttemptInfo=cc,z.getMessageDomKey=bl,z.getPreviewForMessage=Si,z.getToolProgress=Wi,z.httpClient=Gt,z.hydrateHistorySnapshots=Yn,z.isEnvelope=hu,z.isFileLike=zi,z.listFiles=cu,z.loadStoredSettings=Zu,z.looksLikeMarkdown=Cu,z.messageSignature=Ui,z.normalizeInterruptId=Hi,z.normalizeMimeType=Nu,z.normalizeToolPayload=_u,z.normalizeToolPayloadValue=Cr,z.onChatTokenChanged=ou,z.parseJsonSafe=Qn,z.post=Xo,z.pretty=er,z.processAttachments=pu,z.put=au,z.readNumber=dc,z.readString=Rn,z.resolveChatBaseUrl=vn,z.sanitizeForDisplay=Sr,z.saveSettings=Qu,z.setChatToken=Yo,z.stringifyTool=Eu,z.toPlainObject=_n,z.unwrap=Dt,z.useApi=no,z.useCheckpointIndex=uc,z.useFilePreview=Wh,z.useHasChatSession=Ew,z.useParsedMessageContent=Vh,z.useShallowStableValue=Ku,z.useStream=qi,z.useStreamingHook=qi,z.useThreadHistoryState=Lu,z.useThreadManagerViewState=Em,z.useThreadState=oo,z.useThreadStateUpdater=Bu,z.useThreads=yr,z.useThreadsState=bu,z.viewFileById=sw,Object.defineProperty(z,Symbol.toStringTag,{value:"Module"})});
|