teodor-new-chat-ui 4.3.436 → 4.3.438
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(B,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("react-dom"),require("lucide-react")):typeof define=="function"&&define.amd?define(["exports","react","@radix-ui/react-slot","class-variance-authority","clsx","tailwind-merge","react-dom","lucide-react"],w):(B=typeof globalThis<"u"?globalThis:B||self,w(B.NewChatUI={},B.React,B.reactSlot,B.classVarianceAuthority,B.clsx,B.tailwindMerge,B.ReactDOM,B.LucideReact))})(this,function(B,w,Yt,zr,tx,nx,Po,le){"use strict";var GI=Object.defineProperty;var YI=(B,w,Yt)=>w in B?GI(B,w,{enumerable:!0,configurable:!0,writable:!0,value:Yt}):B[w]=Yt;var Qg=(B,w,Yt)=>YI(B,typeof w!="symbol"?w+"":w,Yt);function Jl(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const p=Jl(w),Hr=Jl(Po),Zl=120;function rx(e){if(!Array.isArray(e))return"";const t=e.filter(r=>!!(r&&r.type==="text")).map(r=>(r.text??"").trim()).filter(Boolean);if(!t.length)return"";const n=t.join(" ").replace(/\s+/g," ").trim();return n?n.length>Zl?`${n.slice(0,Zl-3)}…`:n:""}function pi(e){return rx(e.content)||""}function ox(e){var n;const t=new Map;for(const r of e){if(!r.checkpointId)continue;const o=(n=r.messages)==null?void 0:n.find(s=>s.role==="user");if(o){const s=pi(o);s&&t.set(r.checkpointId,s)}}return t}function Ql(e){const t=new Map,n=[],r=new Map,o=[];for(let c=0;c<e.length;c++){const d=e[c],h=d.checkpointId,m=h??`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 S=d.next&&d.next.length>0?String(d.next[0]):null,k=d.parentConfig??null,C={id:m,step:v,source:g,createdAt:d.createdAt??null,namespace:d.checkpointNs??null,parentId:d.parentId??null,next:S,parentConfig:k,userMessageId:x};if(o.push(C),h&&t.set(h,C),h&&y){const T=pi(y);T&&r.set(h,T)}n.push({id:m,messageId:x,step:v,source:g,createdAt:d.createdAt??null,next:S,parentConfig:k})}const s=new Map;for(const c of o){if(!c.userMessageId)continue;const d=s.get(c.userMessageId)??[];d.push(c),s.set(c.userMessageId,d)}for(const c of s.values()){if(!c.length)continue;c.sort((h,m)=>{const f=h.createdAt?Date.parse(h.createdAt):0;return(m.createdAt?Date.parse(m.createdAt):0)-f});const d=c.length;for(let h=0;h<c.length;h++){const m=c[h];m.attemptCount=d,m.attemptIndex=h,m.isLatestAttempt=h===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 h of t.values())h.userMessageId===c&&d.push(h);return d.length?(d.sort((h,m)=>{const f=typeof h.attemptIndex=="number"?h.attemptIndex:Number.MAX_SAFE_INTEGER,v=typeof m.attemptIndex=="number"?m.attemptIndex:Number.MAX_SAFE_INTEGER;return f-v}),d):[]}}}function ec(e,t,n){if(!e)return{attemptCount:1,attemptIndex:0,attempts:[]};const r=n.getMessageAttempts(e);if(!r.length)return{attemptCount:1,attemptIndex:0,attempts:[]};let o=0;if(t){const s=r.findIndex(i=>i.id===t);s>=0&&(o=s)}return{attemptCount:r.length,attemptIndex:o,attempts:r}}function sx(e,t){return e?t.getCheckpoint(e)??null:null}function tc(e){return w.useMemo(()=>Ql(e),[e])}function _n(e){if(!(!e||typeof e!="object"||Array.isArray(e)))return{...e}}function Pn(e,t){if(e)for(const n of t){const r=e[n];if(typeof r=="string"&&r.trim())return r.trim()}}function nc(e,t){if(!e)return null;for(const n of t){const r=e[n];if(typeof r=="number"&&Number.isFinite(r))return r}return null}function mi(e){const t=_n(e);if(t)return _n(t.configurable)??t}function Mn(e){const r=[...(Array.isArray(e==null?void 0:e.checkpoints)?(e==null?void 0:e.checkpoints)??[]:e!=null&&e.checkpoints?Object.values(e.checkpoints):[]).map((s,i)=>ix(s,i)).filter(s=>!!s)].sort((s,i)=>rc(i.createdAt)-rc(s.createdAt)),o=r[0]??null;return{threadId:(e==null?void 0:e.threadId)??"",latest:o,checkpoints:r,interrupt:(o==null?void 0:o.interrupt)??null}}function ix(e,t){var S;if(!e)return null;const r=(Array.isArray((S=e.values)==null?void 0:S.messages)?e.values.messages:[]).map(k=>ax(k)).filter(k=>!!k),o=_n(e.metadata)??{},s=mi(e.config),i=_n(e.parent_config??e.parentConfig),a=mi(i),l=Pn(s,["checkpoint_id","checkpointId"]),c=Pn(s,["checkpoint_ns","checkpointNs"]),d=Pn(a,["checkpoint_id","checkpointId"]),h=Pn(a,["checkpoint_id","checkpointId"])??null,m=Pn(a,["checkpoint_ns","checkpointNs"])??null,f=_n(e.config),v=Array.isArray(e.tasks)?e.tasks.map(k=>({...k})):e.tasks??null,g=Array.isArray(e.next)?[...e.next]:e.next??null,x=typeof e.created_at=="string"&&e.created_at.trim()?e.created_at:typeof e.createdAt=="string"&&e.createdAt.trim()?e.createdAt:new Date(Date.now()-t).toISOString(),y={...o,step:nc(o,["step"])??0,source:Pn(o,["source"])??null},b=r.map(k=>({...k,checkpointId:l??null}));return{checkpointId:l??null,checkpointNs:c??null,createdAt:x,parentId:d??null,messages:b,nextCursor:h,nextCursorNs:m,interrupt:dx(r,t),metadata:y,config:f??null,parentConfig:i??null,next:g,tasks:v}}function ax(e){var s,i,a;if(!e||typeof e!="object")return null;const t=lx(e);if(!t)return null;const n=ux(e==null?void 0:e.content);if(!n.length)return null;const r=typeof e.createdAt=="string"?e.createdAt:typeof((s=e.additional_kwargs)==null?void 0:s.created_at)=="string"?(i=e.additional_kwargs)==null?void 0:i.created_at:new Date().toISOString();return{id:typeof e.id=="string"&&e.id.trim()?e.id:`msg-${Date.now().toString(16)}-${Math.random().toString(16).slice(2)}`,role:t,name:typeof e.name=="string"?e.name:void 0,model:typeof e.model=="string"?e.model:((a=e.additional_kwargs)==null?void 0:a.model)??void 0,createdAt:r,content:n,additionalKwargs:e.additional_kwargs??void 0,responseMetadata:e.response_metadata??void 0,artifact:e.artifact??void 0,threadId:e.threadId??e.thread_id}}function lx(e){const t=typeof e.role=="string"?e.role:void 0;if(t&&cx(t))return t;const n=typeof e.type=="string"?e.type:void 0;if(!n)return null;switch(n){case"human":return"user";case"ai":return"assistant";case"tool":return"tool";case"system":return"system";default:return null}}function cx(e){return e==="assistant"||e==="user"||e==="system"||e==="tool"}function ux(e){return typeof e=="string"?[{type:"text",text:e}]:Array.isArray(e)?e.filter(t=>!!(t&&typeof t=="object"&&typeof t.type=="string")):[]}function dx(e,t){return fx(e,t)}function fx(e,t){var n;for(let r=e.length-1;r>=0;r--){const o=((n=e[r])==null?void 0:n.content)??[];for(let s=o.length-1;s>=0;s--){const i=o[s];if((i==null?void 0:i.type)==="interrupt"){const a=i;return{id:typeof a.id=="string"&&a.id.trim()?a.id:`interrupt-${t}-${r}-${s}`,value:a.value}}}}return null}function rc(e){if(!e)return 0;const t=Date.parse(e);return Number.isFinite(t)?t:0}var gi={exports:{}},Ur={};/**
|
|
1
|
+
(function(B,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("react-dom"),require("lucide-react")):typeof define=="function"&&define.amd?define(["exports","react","@radix-ui/react-slot","class-variance-authority","clsx","tailwind-merge","react-dom","lucide-react"],w):(B=typeof globalThis<"u"?globalThis:B||self,w(B.NewChatUI={},B.React,B.reactSlot,B.classVarianceAuthority,B.clsx,B.tailwindMerge,B.ReactDOM,B.LucideReact))})(this,function(B,w,Yt,zr,tx,nx,Po,le){"use strict";var GI=Object.defineProperty;var YI=(B,w,Yt)=>w in B?GI(B,w,{enumerable:!0,configurable:!0,writable:!0,value:Yt}):B[w]=Yt;var Qg=(B,w,Yt)=>YI(B,typeof w!="symbol"?w+"":w,Yt);function Jl(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const p=Jl(w),Hr=Jl(Po),Zl=120;function rx(e){if(!Array.isArray(e))return"";const t=e.filter(r=>!!(r&&r.type==="text")).map(r=>(r.text??"").trim()).filter(Boolean);if(!t.length)return"";const n=t.join(" ").replace(/\s+/g," ").trim();return n?n.length>Zl?`${n.slice(0,Zl-3)}…`:n:""}function pi(e){return rx(e.content)||""}function ox(e){var n;const t=new Map;for(const r of e){if(!r.checkpointId)continue;const o=(n=r.messages)==null?void 0:n.find(s=>s.role==="user");if(o){const s=pi(o);s&&t.set(r.checkpointId,s)}}return t}function Ql(e){const t=new Map,n=[],r=new Map,o=[];for(let c=0;c<e.length;c++){const d=e[c],h=d.checkpointId,m=h??`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 S=d.next&&d.next.length>0?String(d.next[0]):null,k=d.parentConfig??null,C={id:m,step:v,source:g,createdAt:d.createdAt??null,namespace:d.checkpointNs??null,parentId:d.parentId??null,next:S,parentConfig:k,userMessageId:x};if(o.push(C),h&&t.set(h,C),h&&y){const T=pi(y);T&&r.set(h,T)}n.push({id:m,messageId:x,step:v,source:g,createdAt:d.createdAt??null,next:S,parentConfig:k})}const s=new Map;for(const c of o){if(!c.userMessageId)continue;const d=s.get(c.userMessageId)??[];d.push(c),s.set(c.userMessageId,d)}for(const c of s.values()){if(!c.length)continue;c.sort((h,m)=>{const f=h.createdAt?Date.parse(h.createdAt):0;return(m.createdAt?Date.parse(m.createdAt):0)-f});const d=c.length;for(let h=0;h<c.length;h++){const m=c[h];m.attemptCount=d,m.attemptIndex=h,m.isLatestAttempt=h===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 h of t.values())h.userMessageId===c&&d.push(h);return d.length?(d.sort((h,m)=>{const f=typeof h.attemptIndex=="number"?h.attemptIndex:Number.MAX_SAFE_INTEGER,v=typeof m.attemptIndex=="number"?m.attemptIndex:Number.MAX_SAFE_INTEGER;return f-v}),d):[]}}}function ec(e,t,n){if(!e)return{attemptCount:1,attemptIndex:0,attempts:[]};const r=n.getMessageAttempts(e);if(!r.length)return{attemptCount:1,attemptIndex:0,attempts:[]};let o=0;if(t){const s=r.findIndex(i=>i.id===t);s>=0&&(o=s)}return{attemptCount:r.length,attemptIndex:o,attempts:r}}function sx(e,t){return e?t.getCheckpoint(e)??null:null}function tc(e){return w.useMemo(()=>Ql(e),[e])}function _n(e){if(!(!e||typeof e!="object"||Array.isArray(e)))return{...e}}function Pn(e,t){if(e)for(const n of t){const r=e[n];if(typeof r=="string"&&r.trim())return r.trim()}}function nc(e,t){if(!e)return null;for(const n of t){const r=e[n];if(typeof r=="number"&&Number.isFinite(r))return r}return null}function mi(e){const t=_n(e);if(t)return _n(t.configurable)??t}function Mn(e){const r=[...(Array.isArray(e==null?void 0:e.checkpoints)?(e==null?void 0:e.checkpoints)??[]:e!=null&&e.checkpoints?Object.values(e.checkpoints):[]).map((s,i)=>ix(s,i)).filter(s=>!!s)].sort((s,i)=>rc(i.createdAt)-rc(s.createdAt)),o=r[0]??null;return{threadId:(e==null?void 0:e.threadId)??"",latest:o,checkpoints:r,interrupt:(o==null?void 0:o.interrupt)??null}}function ix(e,t){var S;if(!e)return null;const r=(Array.isArray((S=e.values)==null?void 0:S.messages)?e.values.messages:[]).map(k=>ax(k)).filter(k=>!!k),o=_n(e.metadata)??{},s=mi(e.config),i=_n(e.parent_config??e.parentConfig),a=mi(i),l=Pn(s,["checkpoint_id","checkpointId"]),c=Pn(s,["checkpoint_ns","checkpointNs"]),d=Pn(a,["checkpoint_id","checkpointId"]),h=Pn(a,["checkpoint_id","checkpointId"])??null,m=Pn(a,["checkpoint_ns","checkpointNs"])??null,f=_n(e.config),v=Array.isArray(e.tasks)?e.tasks.map(k=>({...k})):e.tasks??null,g=Array.isArray(e.next)?[...e.next]:e.next??null,x=typeof e.created_at=="string"&&e.created_at.trim()?e.created_at:typeof e.createdAt=="string"&&e.createdAt.trim()?e.createdAt:new Date(Date.now()-t).toISOString(),y={...o,step:nc(o,["step"])??0,source:Pn(o,["source"])??null},b=r.map(k=>({...k,checkpointId:l??null}));return{checkpointId:l??null,checkpointNs:c??null,createdAt:x,parentId:d??null,messages:b,nextCursor:h,nextCursorNs:m,interrupt:dx(r,t),metadata:y,config:f??null,parentConfig:i??null,next:g,tasks:v}}function ax(e){var s,i,a;if(!e||typeof e!="object")return null;const t=lx(e);if(!t)return null;const n=ux(e==null?void 0:e.content);if(!n.length)return null;const r=typeof e.createdAt=="string"?e.createdAt:typeof((s=e.additional_kwargs)==null?void 0:s.created_at)=="string"?(i=e.additional_kwargs)==null?void 0:i.created_at:new Date().toISOString();return{id:typeof e.id=="string"&&e.id.trim()?e.id:`msg-${Date.now().toString(16)}-${Math.random().toString(16).slice(2)}`,role:t,name:typeof e.name=="string"?e.name:void 0,model:typeof e.model=="string"?e.model:((a=e.additional_kwargs)==null?void 0:a.model)??void 0,createdAt:r,content:n,additionalKwargs:e.additional_kwargs??void 0,responseMetadata:e.response_metadata??void 0,artifact:e.artifact??void 0,threadId:e.threadId??e.thread_id}}function lx(e){const t=typeof e.role=="string"?e.role:void 0;if(t&&cx(t))return t;const n=typeof e.type=="string"?e.type:void 0;if(!n)return null;switch(n){case"human":return"user";case"ai":return"assistant";case"tool":return"tool";case"system":return"system";default:return null}}function cx(e){return e==="assistant"||e==="user"||e==="system"||e==="tool"||e==="default_message"}function ux(e){return typeof e=="string"?[{type:"text",text:e}]:Array.isArray(e)?e.filter(t=>!!(t&&typeof t=="object"&&typeof t.type=="string")):[]}function dx(e,t){return fx(e,t)}function fx(e,t){var n;for(let r=e.length-1;r>=0;r--){const o=((n=e[r])==null?void 0:n.content)??[];for(let s=o.length-1;s>=0;s--){const i=o[s];if((i==null?void 0:i.type)==="interrupt"){const a=i;return{id:typeof a.id=="string"&&a.id.trim()?a.id:`interrupt-${t}-${r}-${s}`,value:a.value}}}}return null}function rc(e){if(!e)return 0;const t=Date.parse(e);return Number.isFinite(t)?t:0}var gi={exports:{}},Ur={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.min.js
|
|
4
4
|
*
|
|
@@ -36,7 +36,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
36
36
|
|
|
37
37
|
`))>=0;){const Be=at.slice(0,xe);at=at.slice(xe+2);const Xe=Be.split(/\r?\n/),kt=[];for(const Ze of Xe)if(!(!Ze||Ze.startsWith(":"))&&Ze.startsWith("data:")){const ft=Ze.slice(5);kt.push(ft.startsWith(" ")?ft.slice(1):ft)}const Et=kt.join(`
|
|
38
38
|
`);if(!Et)continue;let Nt;try{Nt=JSON.parse(Et)}catch{console.debug("[use-chat] malformed SSE:",Et.slice(0,200));continue}const Lt=ou(Nt)?Nt.data:Nt;if(!Lt){console.warn("[use-chat] dropped envelope event without payload",Nt);continue}const je=Lt;jt=Date.now();const ht=je.seq;if(ht!==void 0){if(ht<=wt){console.debug("[use-chat] drop duplicate/out-of-order event",{seq:ht,lastProcessedSeq:wt,type:je.type});continue}wt>0&&ht>wt+1&&((ue=I==null?void 0:I.onGap)==null||ue.call(I,{from:wt,to:ht})),wt=ht,E.current=ht,x(ht)}if(je.type==="message.start"&&je.role==="assistant"){const Ze=cu(je.model);V.current={messageId:je.id,lastSeq:ht??null,lastText:""},k({id:je.id,role:"assistant",name:Ze??void 0,model:je.model,createdAt:new Date().toISOString(),content:[]})}if(je.type==="checkpoint")R.current=je.checkpointId??null,L.current=je.checkpointNs??null,v(je.checkpointId??null);else if(je.type==="state_history"){z.current=je;try{const ft=Mn(je).latest;ft&&(R.current=ft.checkpointId??null,L.current=ft.checkpointNs??null,v(ft.checkpointId??null))}catch(Ze){console.warn("[use-chat] Failed to hydrate state_history payload",Ze)}}try{P==null||P(je)}catch(Ze){console.error("[use-chat] Error in onEvent callback:",Ze,"for event:",je.type)}if(je.type==="message.delta"){k(ft=>{const an=V.current;if(!ft||an.messageId!==ft.id)return ft;const{newParts:A,newMeta:Q,changed:he}=au(ft.content??[],je.delta,{lastSeq:an.lastSeq,lastText:an.lastText},ht??null);return he?(V.current={...an,lastSeq:Q.lastSeq??an.lastSeq,lastText:Q.lastText??an.lastText},{...ft,content:A}):ft});const Ze=je.delta.filter(ft=>ft.type==="text").map(ft=>ft.text).join("");Ze&&e.autoAppendAssistant!==!1&&(At.push(Ze),Tt())}else if(je.type==="heartbeat"){console.debug("[use-chat] heartbeat received");try{(F=I==null?void 0:I.onHeartbeat)==null||F.call(I,je)}catch(Ze){console.warn("[use-chat] heartbeat callback failed",Ze)}}else if(dt!==null&&cancelAnimationFrame(dt),bt(),je.type==="checkpoint")v(je.checkpointId);else if(je.type==="error"){const Ze=je;if(d(Ze.message),Y="error",_=Ze.message,Ze.error_type==="auth_error"||Ze.code==="TOKEN_EXPIRED"||((ne=Ze.message)==null?void 0:ne.includes("token"))||((de=Ze.message)==null?void 0:de.includes("401"))||((ce=Ze.message)==null?void 0:ce.includes("unauthorized"))||((ge=Ze.message)==null?void 0:ge.includes("Unauthorized"))){console.error("[use-chat] Auth error detected:",Ze.message);try{(Ce=I==null?void 0:I.onAuthError)==null||Ce.call(I,Ze.message)}catch(an){console.warn("[use-chat] onAuthError handler failed",an)}q.abort()}}}}bt(),Y===null&&!q.signal.aborted&&(Y="complete")}catch(Ee){if(Ee.name==="AbortError")Y=Y??"aborted";else{const Ke=Ee.message||String(Ee);Y="error",_=Ke,d(Ke),(Pe=I==null?void 0:I.onError)==null||Pe.call(I,Ke)}}finally{try{await mt.cancel()}catch{}finally{(De=mt.releaseLock)==null||De.call(mt)}dt!==null&&typeof window<"u"&&window.cancelAnimationFrame(dt),clearInterval(Te)}}catch(Ve){if(Ve.name==="AbortError")Y=Y??"aborted";else{const He=Ve.message||String(Ve);Y="error",_=He,d(He),(ze=I==null?void 0:I.onError)==null||ze.call(I,He),M||((rt=I==null?void 0:I.onConnectionError)==null||rt.call(I,He),M=!0)}}finally{const Ve=E.current,He=R.current,Ye=L.current,Le=z.current,Ue=Y??(q.signal.aborted?"aborted":_?"error":"complete");try{(Ct=I==null?void 0:I.onClosed)==null||Ct.call(I,{reason:Ue,lastSeq:Ve,lastCheckpointId:He,lastCheckpointNs:Ye,lastStateHistory:Le,error:_})}catch(mt){console.warn("[use-chat] onClosed callback failed",mt)}l(!1),b(!1),C.current=null,E.current=0,x(0),N.current=null}})(),{close:()=>q.abort()}},[t,n,r,e.autoAppendAssistant]);return w.useEffect(()=>()=>{var O;T.current=!1,(O=C.current)==null||O.abort()},[]),{isStreaming:a,error:c,assistantText:h,assistantMessage:S,lastCheckpointId:f,lastSeq:g,connected:y,stream:$,stop:W,clear:j,setToken:U}}const Kv=["detail","message","error","description","title"];function qo(e){if(!e)return null;if(typeof e=="string"){const t=e.trim();return t.length?t:null}if(Array.isArray(e)){for(const t of e){const n=qo(t);if(n)return n}return null}if(typeof e=="object"){const t=e;for(const n of Kv){const r=qo(t[n]);if(r)return r}if("errors"in t){const n=qo(t.errors);if(n)return n}}return null}function qv(e){if(!e)return"Request failed";const t=e.response,n=qo(t==null?void 0:t.data);if(n)return n;if(t!=null&&t.statusText)return t.statusText;if(e instanceof Error&&e.message)return e.message;if(typeof e=="string"){const r=e.trim();if(r.length)return r}return t!=null&&t.status?`Request failed with status code ${t.status}`:"Request failed"}function uu({api:e,initialThreadId:t=null,onError:n,onThreadChange:r,onCurrentThreadDeleted:o}){const[s,i]=w.useState([]),[a,l]=w.useState(t),[c,d]=w.useState(!1),[h,m]=w.useState(null),[f,v]=w.useState([]),[g,x]=w.useState(!1),[,y]=w.useState(null),[b,S]=w.useState(null),[k,C]=w.useState(!1),T=w.useRef(a),E=w.useRef(new Map);w.useEffect(()=>{T.current=a},[a]);const N=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]),R=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(()=>{N()},[N]),w.useEffect(()=>{R()},[R]),w.useEffect(()=>{r==null||r(a)},[a,r]);const L=w.useCallback(async P=>{try{const I=await e.createThread(P);return l(I.threadId),await N(),I.threadId}catch(I){const q=String(I);return n==null||n(q),null}},[e,n,N]),z=w.useCallback(async P=>{const I=s;i(Y=>Y.filter(_=>_.threadId!==P));const q=new AbortController;E.current.set(P,q);try{await e.deleteThread(P),T.current===P&&(l(null),o==null||o())}catch(Y){i(I);const _=String(Y);n==null||n(_)}finally{E.current.delete(P)}},[e,o,n,s]),V=w.useCallback(async(P,I)=>{try{await e.updateThread(P,I),await N()}catch(q){n==null||n(String(q))}},[e,n,N]),U=w.useCallback(async(P,I)=>{C(!0),S("Sharing thread…");try{await e.shareThread(P,I),await R(),S("Shared successfully")}catch(q){const Y=qv(q);throw n==null||n(Y),S(`Failed to share: ${Y}`),new Error(Y)}finally{C(!1)}},[e,n,R]),j=w.useCallback(async(P,I)=>{try{await e.unshareThread(P,I),await R()}catch(q){const Y=String(q);throw n==null||n(Y),q}},[e,n,R]),W=w.useMemo(()=>({createThread:L,deleteThread:z,renameThread:V,refreshThreads:N,refreshSharedThreads:R,shareThread:U,unshareThread:j}),[L,z,V,N,R,U,j]),$=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(q=>{let Y=!1;const _=q.map(M=>M.threadId===I.threadId?(Y=!0,console.debug("[useThreadsState] thread_info: updating existing thread",I.threadId),{...M,title:I.title??M.title,updatedAt:I.updatedAt??M.updatedAt,messageCount:I.messageCount??M.messageCount}):M);return Y?_:(console.debug("[useThreadsState] thread_info: adding thread to list",I.threadId),[I,...q])})},[]),O=w.useCallback(()=>S(null),[]);return{threads:s,currentThreadId:a,currentThreadIdRef:T,setCurrentThreadId:l,isLoadingThreads:c,threadsError:h,sharedThreads:f,isLoadingSharedThreads:g,actions:W,addThreadFromEvent:$,shareInFlight:k,shareStatus:b,clearShareStatus:O}}const du=w.createContext(null);function fu({children:e,initialThreadId:t=null,onError:n,onThreadChange:r}){const{api:o}=Xr(),{threads:s,currentThreadId:i,setCurrentThreadId:a,currentThreadIdRef:l,isLoadingThreads:c,threadsError:d,sharedThreads:h,isLoadingSharedThreads:m,actions:f,addThreadFromEvent:v,shareInFlight:g,shareStatus:x,clearShareStatus:y}=uu({api:o,initialThreadId:t,onError:n,onThreadChange:r}),b=w.useMemo(()=>({threads:s,currentThreadId:i,setCurrentThreadId:a,currentThreadIdRef:l,isLoading:c,error:d,sharedThreads:h,isLoadingSharedThreads:m,actions:f,shareInFlight:g,shareStatus:x,clearShareStatus:y,addThreadFromEvent:v}),[s,i,a,l,c,d,h,m,f,g,x,y,v]);return u.jsx(du.Provider,{value:b,children:e})}function gr(){const e=w.useContext(du);if(!e)throw new Error("useThreads must be used within a ThreadsProvider");return e}function Mi(e){const t=e==null?void 0:e.trim();if(!t||!(t.startsWith("{")||t.startsWith("[")))return null;try{return JSON.parse(t)}catch{return null}}function hu(e){return!!(e&&typeof e=="object"&&(e.type==="file"||e.mimeType||e.filename||e.sourceType==="base64"))}function Zr(e){if(typeof e=="string")return e;if(e&&typeof e=="object"){if(Array.isArray(e)){const n=e.map(Zr).filter(r=>r!==void 0);if(!n.length){console.debug("[message-utils] sanitizeForDisplay - array emptied -> returning undefined",{originalLength:e.length});return}return n}if(hu(e)){try{console.debug("[message-utils] sanitizeForDisplay - dropping file-like object",{sampleFilename:e&&(e.filename||e.name)?e.filename||e.name:void 0,keys:Object.keys(e||{})})}catch(n){console.debug("[message-utils] sanitizeForDisplay - dropped file-like (unable to inspect)",{err:String(n)})}return}const t={};for(const n of Object.keys(e)){const r=e[n];if(n==="data"&&typeof r=="string"&&r.length>100)t[n]=`[base64 ${r.length} chars omitted]`;else{const o=Zr(r);o!==void 0&&(t[n]=o)}}if(Object.keys(t).length)return t;try{console.debug("[message-utils] sanitizeForDisplay - object emptied -> returning undefined",{originalKeys:Object.keys(e||{})})}catch(n){console.debug("[message-utils] sanitizeForDisplay - object emptied -> returning undefined (inspect failed)",{err:String(n)})}return}return e}function xr(e){if(typeof e=="string")return e;if(hu(e))return"";try{const t=Zr(e);return t===void 0?"":typeof t=="string"?t:JSON.stringify(t,null,2)}catch{return""}}function Gv(e){return typeof e!="string"?!1:/^[\s\n]*[-*]\s|^[\s\n]*#+\s|```|^\s*\[.*\]\(|^>\s/.test(e)}function Yv(e){const t=xr(e);return typeof e=="string"&&Gv(e)?{content:e,isMarkdown:!0}:{content:t,isMarkdown:!1}}function Qr(e){if(e==null)return e;if(typeof e=="string"){const t=e.trim();if(t.startsWith("{")||t.startsWith("[")){const n=Mi(t);if(n!==null)return Qr(n)}return e}return typeof e=="object"&&!Array.isArray(e)&&e.content!==void 0?Qr(e.content):e}function Xv(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function Ri(e){const t=e.content.find(s=>s.type==="tool_call"),n=e.additionalKwargs??{},r=typeof(t==null?void 0:t.id)=="string"&&t.id||typeof n.toolCallId=="string"&&n.toolCallId||(e.id.startsWith("tool-")?e.id.slice(5):void 0);return{name:(typeof(t==null?void 0:t.name)=="string"&&t.name||typeof n.toolName=="string"&&n.toolName||e.name&&String(e.name))??void 0,toolCallId:r??void 0}}function Go(e){if(e==null)return null;const t=String(e).trim();return t.length>0?t:null}function Jv(e){const t=r=>{try{const o=Zr(r);return typeof o=="string"?o:JSON.stringify(o??"")}catch{return""}},n=e.filter(r=>r.type==="text");return n.length?t(n.map(r=>r.text).join(`
|
|
39
|
-
`)):t(e)}function Zv(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function pu(e){if("type"in e&&e.type==="default_message")return`default:${e.content.length}`;const t=e.updatedAt??e.createdAt??"",n=Array.isArray(e.content)?e.content.map(i=>{switch(i.type){case"text":return`t:${i.text.length}`;case"image_url":return"img";case"file":return"file";case"tool_call":return"call";case"interrupt":return"interrupt";default:return"unknown"}}).join("|"):"",r="checkpointId"in e&&e.checkpointId?`cp:${e.checkpointId}`:"",o="checkpointNs"in e&&e.checkpointNs?`ns:${e.checkpointNs}`:"",s=[r,o].filter(Boolean).join("|");return`${e.id}:${t}:${n}${s?`:${s}`:""}`}function Qv(e){if(!e)return"image/png";const t=e.trim();return t?t.includes("/")?t:`image/${t}`:"image/png"}function ew(e){const t=[],n=r=>{r&&r.trim()&&t.push(r.trim())};return e&&(n(e.plotId),n(e.artifactId)),t}function tw({base64:e,url:t,formatHint:n,extras:r}){const o=typeof e=="string"&&e.length>0,s=Qv(n),i=o?`data:${s};base64,${e}`:t,a=ew(r),l=a.length?a.join(" / "):void 0,c=l?`${l} artifact`:"artifact image";return{src:i,alt:c,label:l}}function nw(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 tw({base64:t,url:n,formatHint:r,extras:{plotId:e.plotId,artifactId:e.artifactId}})}function mu(e){var n;const t=(n=e.additionalKwargs)==null?void 0:n.toolProgress;return Array.isArray(t)?t:[]}const rw={messages:[],assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,messagesStreamMeta:{},pendingInterrupt:null};function ow(e,t){var n;switch(t.type){case"reset":return{messages:Pi(((n=t.payload)==null?void 0:n.messages)??[]),assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,pendingInterrupt:null,messagesStreamMeta:{}};case"user_message":{const{message:r,editingMessageId:o}=t.payload;if(o){const s=e.messages.findIndex(i=>i.id===o);if(s>=0){const i=e.messages.slice(0,s);return{...e,messages:[...i,r]}}}return{...e,messages:[...e.messages,r]}}case"seed":{const r=Pi(t.payload.messages),o={...e,messages:r,assemblingId:null,pendingInterrupt:t.payload.pendingInterrupt??null};return Object.prototype.hasOwnProperty.call(t.payload,"checkpointId")&&(o.lastCheckpointId=t.payload.checkpointId??null),Object.prototype.hasOwnProperty.call(t.payload,"checkpointNs")&&(o.lastCheckpointNs=t.payload.checkpointNs??null),o}case"prepend":{const r=Pi(t.payload.messages);if(!r.length)return e;const o=new Set(e.messages.map(a=>a.id)),s=r.filter(a=>!o.has(a.id));if(!s.length)return e;const i=[...s,...e.messages];return{...e,messages:i}}case"event":return gu(e,t.payload.ev);case"batch":{const{events:r}=t.payload;return r.length?r.reduce((o,s)=>gu(o,s),e):e}default:return e}}function sw(e=[]){const[t,n]=w.useReducer(ow,{...rw,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,h)=>n({type:"seed",payload:{messages:d,...h??{}}}),prepend:d=>n({type:"prepend",payload:{messages:d}}),pushUser:(d,h)=>n({type:"user_message",payload:{message:d,editingMessageId:h}}),onEvent:l}),[l]);return{state:t,dispatch:n,...c}}function gu(e,t){var n,r,o;if(t.type==="message.start"&&t.role==="assistant"){const s=t.id,i=cu(t.model);if(e.messages.some(c=>c.id===s)){const c=e.messagesStreamMeta??{},d={...c,[s]:c[s]??{lastSeq:t.seq??null,lastText:""}};return{...e,assemblingId:s,messagesStreamMeta:d}}const l={id:s,role:"assistant",name:i||void 0,model:t.model,createdAt:new Date().toISOString(),content:[]};return{...e,assemblingId:s,messages:[...e.messages,l]}}if(t.type==="tool.start")return aw(e,t);if(t.type==="tool.progress")return lw(e,t);if(t.type==="tool.end")return cw(e,t);if(t.type==="message.delta"){const s=e.assemblingId??su(e.messages);if(!s)return e;const i=e.messages,a=i.findIndex(C=>C.id===s&&C.role==="assistant");if(a===-1)return e;const l=i[a],c=e.messagesStreamMeta,d=c??{},h=d[s],m=h??{lastSeq:null,lastText:iu(l.content)},f=t.seq??null;if(f!==null&&typeof f=="number"&&typeof m.lastSeq=="number"&&f<=m.lastSeq)return console.debug("[MessageReducer] skipping delta - seq <= lastSeq",{seq:f,lastSeq:m.lastSeq}),e;const{newParts:v,newMeta:g,changed:x}=au(l.content,t.delta,m,f);if(!x)return e;const y={...l,content:v},b=Jr(i,a,y),S=!h||h.lastSeq!==g.lastSeq||h.lastText!==g.lastText,k=S?{...d,[s]:g}:c;return S?{...e,messages:b,messagesStreamMeta:k}:{...e,messages:b}}if(t.type==="message.end"){const s=e.assemblingId??su(e.messages);if(!s)return{...e,assemblingId:null};const i=e.messages,a=i.findIndex(l=>l.id===s&&l.role==="assistant");if(a>=0){const l=i[a];if(!((n=l.content)==null?void 0:n.some(d=>{var h;return(d==null?void 0:d.type)==="text"&&((h=d.text)==null?void 0:h.trim())}))){console.debug("[MessageReducer] pruning assistant message with no visible text",{id:l.id,contentTypes:(r=l.content)==null?void 0:r.map(h=>h==null?void 0:h.type),contentPreview:(o=l.content)==null?void 0:o.map(h=>(h==null?void 0:h.type)==="text"?String(h.text).slice(0,100):h==null?void 0:h.type)});const d=[...i.slice(0,a),...i.slice(a+1)];return{...e,assemblingId:null,messages:d}}}return e}if(t.type==="checkpoint"){const s=t.checkpointNs??e.lastCheckpointNs??null,i=Wv(e.messages,t.checkpointId,s);return{...e,lastCheckpointId:t.checkpointId,lastCheckpointNs:s,messages:i}}if(t.type==="error"){const s={id:`err-${Date.now()}`,role:"system",content:[{type:"text",text:`Error: ${t.message}`}],createdAt:new Date().toISOString()};return{...e,messages:[...e.messages,s]}}if(t.type==="state_history"){const s=Mn(t),i=s.interrupt,a=s.latest,l=i===null?Hv(e.messages):e.messages;return{...e,messages:l,pendingInterrupt:i,lastCheckpointId:(a==null?void 0:a.checkpointId)??e.lastCheckpointId,lastCheckpointNs:(a==null?void 0:a.checkpointNs)??e.lastCheckpointNs}}return t.type==="thread_info",e}function Oi(e){return e.call_id??e.id??null}function xu(e){return e.id??e.call_id??`tool-${Date.now()}-${Math.random().toString(16).slice(2)}`}function vu(e,t,n,r){const o=t??`call-${Date.now()}-${Math.random().toString(16).slice(2)}`;return{id:e,role:"tool",name:n??void 0,content:[{type:"tool_call",id:o,name:n??"tool",args:r??{}}],createdAt:new Date().toISOString(),additionalKwargs:{toolCallId:o,toolName:n??void 0,toolStreaming:!0,toolProgress:[]}}}function Di(e,t){if(!t)return-1;for(let n=0;n<e.length;n+=1){const r=e[n];if(r.role!=="tool")continue;const o=r.additionalKwargs??{};if(typeof o.toolCallId=="string"&&o.toolCallId===t||Ri(r).toolCallId===t)return n}return-1}function iw(e){if(e==null)return[];const t=Qr(e);if(typeof t=="string"&&t.trim())return[{type:"text",text:t}];const n=xr(t??e);return n?[{type:"text",text:n}]:[]}function wu(e,t){const n=e.additionalKwargs??{},r=Array.isArray(n.toolProgress)?[...n.toolProgress]:[],o={...n,toolProgress:[...r,t]};return{...e,additionalKwargs:o}}function aw(e,t){const n=Oi(t),r=Di(e.messages,n),o=t.name??t.tool??void 0,s=xu(t);if(r>=0){const a=e.messages[r],c={...a.additionalKwargs??{},toolStreaming:!0,toolProgress:[]},d={...a,name:o??a.name,additionalKwargs:c};return{...e,messages:Jr(e.messages,r,d)}}const i=vu(s,n,o,t.args);return{...e,messages:[...e.messages,i]}}function lw(e,t){const n=Oi(t);if(!n)return e;const r=Di(e.messages,n);if(r===-1)return e;const o={type:t.type,content:typeof t.content=="string"?t.content:void 0,seq:t.seq??null,timestamp:new Date().toISOString()},s=t.metadata;s&&(o.metadata=s);const i=t.idx;typeof i=="number"&&(o.idx=i);const a=wu(e.messages[r],o);return{...e,messages:Jr(e.messages,r,a)}}function cw(e,t){const n=Oi(t),r=xu(t);let o=e.messages,s=Di(o,n);if(s===-1){const v=t.name??t.tool??void 0;o=[...o,vu(r,n,v,{})],s=o.length-1}const i=o[s],a=t.output??t.error??null,l=iw(a),c=[...i.content,...l],d={type:t.type,content:typeof t.output=="string"?t.output:void 0,seq:t.seq??null,timestamp:new Date().toISOString()};t.artifact&&(d.artifact=t.artifact);const h=wu(i,d),m=t.artifact??i.artifact,f={...h,name:t.name??t.tool??i.name,content:c,artifact:m,additionalKwargs:{...h.additionalKwargs??{},toolStreaming:!1}};return{...e,messages:Jr(o,s,f)}}function bu({api:e,seed:t,prepend:n,onError:r,currentThreadId:o,initialThreadId:s=null,initialCheckpointId:i=null,initialCheckpointNs:a=null,autoLoadInitial:l=!0,isStreaming:c,getMessages:d}){const[h,m]=w.useState(null),v=w.useMemo(()=>Mn(h),[h]).checkpoints,g=tc(v),x=g.timeline,[y,b]=w.useState(!1),[S,k]=w.useState(null),[C,T]=w.useState(!1),[E,N]=w.useState(!1),[R,L]=w.useState(!1),[z,V]=w.useState(null),U=w.useRef(o),j=w.useRef(null),W=w.useRef(null),$=w.useRef(null),O=w.useRef(null),P=w.useRef(!1),I=w.useRef(null),q=w.useRef(new Map);w.useEffect(()=>{U.current=o},[o]);const Y=w.useCallback(async F=>{var de,ce;if(!F.threadId)return;const ne=F.threadId;(de=F.onStart)==null||de.call(F),F.setLoading(!0);try{await F.action(ne)}catch(ge){if(U.current===ne){const Ce=String(ge);(ce=F.handleError)==null||ce.call(F,Ce),r==null||r(Ce)}throw ge}finally{F.setLoading(!1)}},[r]),_=w.useCallback(async(F,ne)=>{if(!F)return;const de=`${F}:${ne??"latest"}`,ce=q.current.get(de);if(ce)return ce;const ge=Y({threadId:F,setLoading:T,onStart:()=>V(null),handleError:Ce=>V(Ce),action:async Ce=>{const Pe=await e.getStateHistory({threadId:Ce,checkpointId:ne??void 0});if(U.current!==Ce){console.log(`[useThreadHistoryState] Thread changed during load (was ${Ce}, now ${U.current}), discarding stale data`);return}const{checkpoints:De}=Mn(Pe),ze=De.find(rt=>rt.messages&&rt.messages.length>0)??(ne?De.find(rt=>rt.checkpointId===ne):null)??De[0];t((ze==null?void 0:ze.messages)??[],{checkpointId:(ze==null?void 0:ze.checkpointId)??null,checkpointNs:(ze==null?void 0:ze.checkpointNs)??null}),m(Pe),b(!!(ze!=null&&ze.nextCursor)),k((ze==null?void 0:ze.nextCursor)??null)}});q.current.set(de,ge);try{await ge}finally{q.current.delete(de)}return U.current===F&&(I.current=de),ge},[e,t,Y]),M=w.useCallback(async(F,ne)=>{O.current=F;try{await _(F,ne)}finally{O.current===F&&(O.current=null)}},[_]),G=w.useCallback(F=>{W.current=F},[]),J=w.useCallback(F=>{$.current=F},[]),oe=w.useCallback(F=>{const ne=F.threadId??U.current;if(!ne||U.current&&U.current!==ne)return;const{checkpoints:de}=Mn(F);if(!de.length)return;const ce=de.find(Ce=>Ce.messages&&Ce.messages.length>0)??de.find(Ce=>!!Ce.checkpointId)??de[0],ge=$.current===ne;!c&&!ge&&t((ce==null?void 0:ce.messages)??[],{checkpointId:(ce==null?void 0:ce.checkpointId)??null,checkpointNs:(ce==null?void 0:ce.checkpointNs)??null}),m(F),b(!!(ce!=null&&ce.nextCursor)),k((ce==null?void 0:ce.nextCursor)??null),I.current=`${ne}:latest`,W.current=null,$.current===ne&&($.current=null)},[t,c]),K=w.useCallback(async(F,ne)=>{const de=U.current;await Y({threadId:de,setLoading:L,action:async ce=>{const ge=await e.getStateHistory({threadId:ce,checkpointId:F,checkpointNs:ne??void 0});if(U.current!==ce){console.log(`[useThreadHistoryState] Thread changed during checkpoint navigation (was ${ce}, now ${U.current}), discarding stale data`);return}const{checkpoints:Ce}=Mn(ge),Pe=Ce.find(De=>De.checkpointId===F&&(ne?De.checkpointNs===ne:!0));if(!Pe){console.warn("[useThreadHistoryState] Requested checkpoint not found:",{checkpointId:F,checkpointNs:ne});return}m(ge),t(Pe.messages??[],{checkpointId:Pe.checkpointId??null,checkpointNs:Pe.checkpointNs??null})}}).catch(()=>{})},[e,t,Y]),D=w.useCallback((F,ne)=>{t(d(),{checkpointId:F??null,checkpointNs:ne??null})},[d,t]),X=w.useCallback(async()=>{U.current&&await M(U.current)},[M]),Z=w.useCallback(async()=>{const F=U.current;!F||!S||await Y({threadId:F,setLoading:N,action:async ne=>{const de=await e.getStateHistory({threadId:ne,checkpointId:S});if(U.current!==ne)return;const{checkpoints:ce}=Mn(de);if(ce.length>0){const ge=ce[ce.length-1];n((ge==null?void 0:ge.messages)??[]),b(!!(ge!=null&&ge.nextCursor)),k((ge==null?void 0:ge.nextCursor)??null)}}}).catch(()=>{})},[e,S,r,n,Y]);w.useEffect(()=>{if(!l||!o||C||c)return;if(W.current===o){W.current=null,j.current=o;return}if($.current===o){j.current=o;return}if(O.current===o){O.current=null,j.current=o;return}if(j.current===o)return;j.current=o;const F=!P.current&&!!i&&o===s;let ne;F&&i?(ne=i,P.current=!0,console.log("[useThreadHistoryState] Loading thread with checkpoint:",ne,a?`(ns: ${a})`:"")):console.log("[useThreadHistoryState] Loading thread with latest checkpoint");const de=`${o}:${ne??"latest"}`;I.current!==de&&M(o,ne)},[l,o,i,a,s,C,c,M]);const ue=w.useCallback(()=>{m(null),b(!1),k(null),T(!1),N(!1),L(!1),V(null),W.current=null,$.current=null,j.current=null,I.current=null,O.current=null},[]);return{threadCheckpoints:v,threadTimeline:x,checkpointIndex:g,isLoadingThread:C,isHistoryLoading:E,isLoadingCheckpoint:R,threadStateError:z,hasMoreHistory:y,loadThread:M,navigateToCheckpoint:K,loadOlderMessages:Z,setCurrentCheckpointId:D,returnToLatest:X,handleStateHistoryEvent:oe,markSkipNextLoad:G,markStreamPendingThread:J,resetHistoryState:ue}}const yu=w.createContext(null),Su=w.createContext(null);function eo(){const e=w.useContext(yu);if(!e)throw new Error("useThreadState must be used within a ThreadStateProvider");return e}function Cu(){const e=w.useContext(Su);if(!e)throw new Error("useThreadStateUpdater must be used within a ThreadStateProvider");return e}function Tu({children:e,initialThreadId:t=null,initialCheckpointId:n=null,initialCheckpointNs:r=null,autoLoadInitial:o=!0,isStreaming:s,onError:i}){const{api:a}=Xr(),{currentThreadId:l}=gr(),{state:c,seed:d,prepend:h,pushUser:m,onEvent:f}=sw(),{threadCheckpoints:v,threadTimeline:g,checkpointIndex:x,isLoadingThread:y,isHistoryLoading:b,isLoadingCheckpoint:S,threadStateError:k,hasMoreHistory:C,loadThread:T,navigateToCheckpoint:E,loadOlderMessages:N,setCurrentCheckpointId:R,returnToLatest:L,handleStateHistoryEvent:z,markSkipNextLoad:V,markStreamPendingThread:U,resetHistoryState:j}=bu({api:a,seed:d,prepend:h,onError:i,currentThreadId:l,initialThreadId:t,initialCheckpointId:n,initialCheckpointNs:r,autoLoadInitial:o,isStreaming:s,getMessages:w.useCallback(()=>c.messages,[c.messages])}),[W,$]=w.useState(()=>async()=>{throw new Error("clearThread is not ready")}),[O,P]=w.useState(()=>async()=>{throw new Error("respondToInterrupt is not ready")});w.useEffect(()=>{l||(d([],{}),j())},[l,d,j]);const I=w.useCallback(G=>$(()=>G),[]),q=w.useCallback(G=>P(()=>G),[]),Y=w.useMemo(()=>{const G=c.assemblingId??null;return G?{assemblingMessageId:G}:null},[c.assemblingId]),_=w.useMemo(()=>({threadId:l,messages:c.messages,interrupt:c.pendingInterrupt,checkpoint:{id:c.lastCheckpointId??null,namespace:c.lastCheckpointNs??null},checkpoints:v,checkpointIndex:x,timelineCheckpoints:g,metadata:Y,isLoading:y,isHistoryLoading:b,isLoadingCheckpoint:S,error:k,hasMore:C,loadOlder:N,clearState:W,navigateToCheckpoint:E,setCurrentCheckpointId:R,returnToLatest:L,loadThread:T,clearThread:W,respondToInterrupt:O,messagePreviews:x.messagePreviews,handleStateHistoryEvent:z,markSkipNextLoad:V,markStreamPendingThread:U,resetHistoryState:j,pushUser:m,onEvent:f}),[l,c,v,g,x,Y,y,b,S,k,C,N,W,E,R,L,T,O,x.messagePreviews,z,V,U,j,m,f]),M=w.useMemo(()=>({registerClearThread:I,registerRespondToInterrupt:q}),[I,q]);return u.jsx(Su.Provider,{value:M,children:u.jsx(yu.Provider,{value:_,children:e})})}function ku(e,t){if(!e)return null;const n=_n(e);if(!n)return null;const r=_n(n.configurable)??n;return Pn(r,t)??null}function uw(e){const t=ku(e,["checkpoint_id","checkpointId"]);if(!t)return null;const n=ku(e,["checkpoint_ns","checkpointNs"]);return{checkpointId:t,checkpointNs:n}}function dw(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 fw(e,t){const n=[...e].sort(dw);for(const r of n){if(r.messageId!==t)continue;const o=uw(r.parentConfig);if(!o)throw new Error(`Parent checkpoint info missing for message ${t}`);return o}throw new Error(`Message ${t} not found in timeline`)}const Eu=w.createContext(null),Iu=w.createContext(!1);function hw({children:e,initialThreadId:t=null,initialCheckpointId:n=null,initialCheckpointNs:r=null,autoLoadInitial:o=!0,onError:s,onAuthError:i,onThreadChange:a,onConnectionError:l,onToolEnd:c}){const{api:d,baseUrl:h}=Xr(),m=w.useMemo(()=>vn(h),[h]),{stream:f,stop:v,isStreaming:g,error:x,setToken:y}=Vv({baseUrl:m}),[b,S]=w.useState(!1);return w.useEffect(()=>{S(g)},[g]),u.jsx(fu,{initialThreadId:t,onError:s,onThreadChange:a,children:u.jsx(Tu,{initialThreadId:t,initialCheckpointId:n,initialCheckpointNs:r,autoLoadInitial:o,onError:s,isStreaming:b,children:u.jsx(Iu.Provider,{value:!0,children:u.jsx(pw,{api:d,streamApi:{stream:f,stop:v,isStreaming:g,error:x,setToken:y},onError:s,onAuthError:i,onConnectionError:l,onToolEnd:c,children:e})})})})}function pw({children:e,api:t,streamApi:n,onError:r,onAuthError:o,onConnectionError:s,onToolEnd:i}){const{stream:a,stop:l,isStreaming:c,error:d,setToken:h}=n,{setCurrentThreadId:m,currentThreadIdRef:f,addThreadFromEvent:v}=gr(),{checkpoint:g,timelineCheckpoints:x,handleStateHistoryEvent:y,markSkipNextLoad:b,markStreamPendingThread:S,resetHistoryState:k,pushUser:C,onEvent:T}=eo(),{registerClearThread:E,registerRespondToInterrupt:N}=Cu(),R=w.useCallback(O=>{v(O),f.current!==O.threadId&&((O.created??!f.current)&&b(O.threadId),S(O.threadId),m(O.threadId))},[v,b,S,m,f]),L=w.useCallback(O=>{O.type==="thread_info"?R(O):O.type==="state_history"?y(O):O.type==="tool.end"?i==null||i(O):T(O)},[R,y,T,i]),z=w.useCallback(O=>{a(O,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 U=w.useCallback(async(O,P,I)=>{const q=f.current;if(!q)throw new Error("No active thread to handle interrupt");const Y=P?I??!0:!1,_=V.current,M={threadId:q,checkpointId:_.id??void 0,checkpointNs:_.namespace??void 0,command:{kind:"resume",value:Y}};z(M)},[f,z]);w.useEffect(()=>{N(U)},[U,N]);const j=w.useCallback(async()=>{l(),k(),m(null);try{await t.getAgent("default")}catch(O){console.warn("[StreamingProvider] Failed to refetch agent after clearing thread:",O)}},[t,k,m,l]);w.useEffect(()=>{E(j)},[j,E]);const W=w.useCallback(async(O,P)=>{let I=f.current;const q=(O==null?void 0:O.text)??"",Y=(O==null?void 0:O.attachments)??[],_=(q==null?void 0:q.trim())??"",M={...(O==null?void 0:O.payload)??{}},G=Array.isArray(M.messages)?M.messages:void 0;G&&delete M.messages;const J=!!(G&&G.length);if(!I&&!_&&Y.length===0&&!J)return;if(!I){const Pe=Math.floor(Date.now()/1e3).toString(16).padStart(8,"0"),De=Array.from({length:4},()=>Math.floor(Math.random()*4294967295).toString(16).padStart(8,"0")).join("").slice(0,16);I=`${Pe}${De}`,b(I),m(I)}const{contentParts:oe,filesInfo:K}=await ru(Y),D=[...oe];_&&D.push({type:"text",text:q});const X=P==null?void 0:P.originalMessageId,Z=!!(P!=null&&P.edit&&X),ue=!J&&D.length>0;let F=null;ue&&(F={id:Z?X:`msg-${Date.now()}`,role:"user",content:D,createdAt:new Date().toISOString()},Z?C(F,X):C(F));const ne=J?G:F?[F]:[],de={...M,...K.length?{files_info:K}:{}};ne.length?de.messages=ne:"messages"in de||(de.messages=[]);let ce=(P==null?void 0:P.checkpointId)??g.id??void 0,ge=(P==null?void 0:P.checkpointNs)??g.namespace??void 0;if(Z&&X){const Pe=fw(x,X);ce=Pe.checkpointId,ge=Pe.checkpointNs??void 0}const Ce={threadId:I,payload:de,checkpointId:ce,checkpointNs:ge,edit:!!(P!=null&&P.edit)};z(Ce)},[g,f,b,C,z,x]),$=w.useMemo(()=>({isStreaming:c,error:d,connectionState:c?"connected":"idle",submit:W,send:W,stop:l,setAuthToken:h}),[c,d,W,l,h]);return u.jsx(Eu.Provider,{value:$,children:e})}function Li(){const e=w.useContext(Eu);if(!e)throw new Error("useStream must be used within StreamingProvider");return e}function mw(){return w.useContext(Iu)}function Nu(e){return typeof e=="object"&&e!==null}function gw(e,t){if(Object.is(e,t))return!0;if(!Nu(e)||!Nu(t))return!1;const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const o of n)if(!Object.prototype.hasOwnProperty.call(t,o)||!Object.is(e[o],t[o]))return!1;return!0}function Au(e){const t=w.useRef(e),n=w.useRef(e);return gw(t.current,e)||(t.current=e,n.current=e),n.current}function vr({children:e,apiConfig:t,initialThreadId:n=null,initialCheckpointId:r=null,initialCheckpointNs:o=null,autoLoadInitial:s=!0,onConnectionError:i,onError:a,onAuthError:l,onThreadChange:c,onToolEnd:d}){const h=Au(t),m=to(a),f=to(l),v=to(i),g=to(c),x=to(d),y=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(tu,{apiConfig:h,children:u.jsx(hw,{...y,children:e})})}function to(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 wr(e){if(!(typeof globalThis>"u"))return globalThis[e]}function xw(e){if(typeof e!="string")return;const t=e.trim();if(t)return vn(t)}function ju(){const e=[wr("__API_BASE_URL__"),wr("__CHAT_API_BASE_URL__"),wr("__CHAT_API_URL__")];for(const t of e){const n=xw(t);if(n)return n}}function _u(){const e=[wr("__API_AUTH_TOKEN__"),wr("__CHAT_API_KEY__"),wr("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function Pu(...e){for(const t of e)if(typeof t=="string"&&t.trim())return vn(t);return vn()}function Mu(){const e={},t=ju(),n=_u();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function Ru(){const e=Mu(),t=Rn.getAuthToken(),n=ju();return{apiBaseUrl:Pu(e.baseUrl,Rn.baseUrl,n),apiKey:t||e.apiKey||_u()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,darkMode:!1,enableSound:!1,messageHistory:100}}const $i="chat-settings";function Ou(){try{const e=localStorage.getItem($i);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function Du(e){try{const t={...e,apiBaseUrl:vn(e.apiBaseUrl)};localStorage.setItem($i,JSON.stringify(t)),t.apiKey&&Rn.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function vw(){const e=Ru(),t=Ou(),n=Rn.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:Pu(Rn.baseUrl,r,e.apiBaseUrl)}}function ww(e){Rn.updateConfig({baseUrl:e.apiBaseUrl,authToken:e.apiKey??void 0}),Du(e)}function te(...e){return nx.twMerge(tx.clsx(e))}const bw=zr.cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),tt=p.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?Yt.Slot:"button";return u.jsx(i,{className:te(bw({variant:t,size:n,className:e})),ref:s,...o})});tt.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 Lu(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function On(...e){return t=>{let n=!1;const r=e.map(o=>{const s=Lu(o,t);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let o=0;o<r.length;o++){const s=r[o];typeof s=="function"?s():Lu(e[o],null)}}}}function $e(...e){return p.useCallback(On(...e),e)}function yw(e,t){const n=p.createContext(t),r=s=>{const{children:i,...a}=s,l=p.useMemo(()=>a,Object.values(a));return u.jsx(n.Provider,{value:l,children:i})};r.displayName=e+"Provider";function o(s){const i=p.useContext(n);if(i)return i;if(t!==void 0)return t;throw new Error(`\`${s}\` must be used within \`${e}\``)}return[r,o]}function cn(e,t=[]){let n=[];function r(s,i){const a=p.createContext(i),l=n.length;n=[...n,i];const c=h=>{var y;const{scope:m,children:f,...v}=h,g=((y=m==null?void 0:m[e])==null?void 0:y[l])||a,x=p.useMemo(()=>v,Object.values(v));return u.jsx(g.Provider,{value:x,children:f})};c.displayName=s+"Provider";function d(h,m){var g;const f=((g=m==null?void 0:m[e])==null?void 0:g[l])||a,v=p.useContext(f);if(v)return v;if(i!==void 0)return i;throw new Error(`\`${h}\` must be used within \`${s}\``)}return[c,d]}const o=()=>{const s=n.map(i=>p.createContext(i));return function(a){const l=(a==null?void 0:a[e])||s;return p.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return o.scopeName=e,[r,Sw(o,...t)]}function Sw(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(s){const i=r.reduce((a,{useScope:l,scopeName:c})=>{const h=l(s)[`__scope${c}`];return{...a,...h}},{});return p.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var It=globalThis!=null&&globalThis.document?p.useLayoutEffect:()=>{},Cw=p[" useInsertionEffect ".trim().toString()]||It;function Dn({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=Tw({defaultProp:t,onChange:n}),a=e!==void 0,l=a?e:o;{const d=p.useRef(e!==void 0);p.useEffect(()=>{const h=d.current;h!==a&&console.warn(`${r} is changing from ${h?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),d.current=a},[a,r])}const c=p.useCallback(d=>{var h;if(a){const m=kw(d)?d(e):d;m!==e&&((h=i.current)==null||h.call(i,m))}else s(d)},[a,e,s,i]);return[l,c]}function Tw({defaultProp:e,onChange:t}){const[n,r]=p.useState(e),o=p.useRef(n),s=p.useRef(t);return Cw(()=>{s.current=t},[t]),p.useEffect(()=>{var i;o.current!==n&&((i=s.current)==null||i.call(s,n),o.current=n)},[n,o]),[n,r,s]}function kw(e){return typeof e=="function"}var Ew=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],ve=Ew.reduce((e,t)=>{const n=Yt.createSlot(`Primitive.${t}`),r=p.forwardRef((o,s)=>{const{asChild:i,...a}=o,l=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),u.jsx(l,{...a,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Fi(e,t){e&&Hr.flushSync(()=>e.dispatchEvent(t))}function Yo(e){const t=e+"CollectionProvider",[n,r]=cn(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=g=>{const{scope:x,children:y}=g,b=w.useRef(null),S=w.useRef(new Map).current;return u.jsx(o,{scope:x,itemMap:S,collectionRef:b,children:y})};i.displayName=t;const a=e+"CollectionSlot",l=Yt.createSlot(a),c=w.forwardRef((g,x)=>{const{scope:y,children:b}=g,S=s(a,y),k=$e(x,S.collectionRef);return u.jsx(l,{ref:k,children:b})});c.displayName=a;const d=e+"CollectionItemSlot",h="data-radix-collection-item",m=Yt.createSlot(d),f=w.forwardRef((g,x)=>{const{scope:y,children:b,...S}=g,k=w.useRef(null),C=$e(x,k),T=s(d,y);return w.useEffect(()=>(T.itemMap.set(k,{ref:k,...S}),()=>void T.itemMap.delete(k))),u.jsx(m,{[h]:"",ref:C,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 S=Array.from(b.querySelectorAll(`[${h}]`));return Array.from(x.itemMap.values()).sort((T,E)=>S.indexOf(T.ref.current)-S.indexOf(E.ref.current))},[x.collectionRef,x.itemMap])}return[{Provider:i,Slot:c,ItemSlot:f},v,r]}var Iw=p.createContext(void 0);function Xo(e){const t=p.useContext(Iw);return e||t||"ltr"}function xt(e){const t=p.useRef(e);return p.useEffect(()=>{t.current=e}),p.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function Nw(e,t=globalThis==null?void 0:globalThis.document){const n=xt(e);p.useEffect(()=>{const r=o=>{o.key==="Escape"&&n(o)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var Aw="DismissableLayer",Bi="dismissableLayer.update",jw="dismissableLayer.pointerDownOutside",_w="dismissableLayer.focusOutside",$u,Fu=p.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),br=p.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...l}=e,c=p.useContext(Fu),[d,h]=p.useState(null),m=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,f]=p.useState({}),v=$e(t,E=>h(E)),g=Array.from(c.layers),[x]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),y=g.indexOf(x),b=d?g.indexOf(d):-1,S=c.layersWithOutsidePointerEventsDisabled.size>0,k=b>=y,C=Mw(E=>{const N=E.target,R=[...c.branches].some(L=>L.contains(N));!k||R||(o==null||o(E),i==null||i(E),E.defaultPrevented||a==null||a())},m),T=Rw(E=>{const N=E.target;[...c.branches].some(L=>L.contains(N))||(s==null||s(E),i==null||i(E),E.defaultPrevented||a==null||a())},m);return Nw(E=>{b===c.layers.size-1&&(r==null||r(E),!E.defaultPrevented&&a&&(E.preventDefault(),a()))},m),p.useEffect(()=>{if(d)return n&&(c.layersWithOutsidePointerEventsDisabled.size===0&&($u=m.body.style.pointerEvents,m.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(d)),c.layers.add(d),zu(),()=>{n&&c.layersWithOutsidePointerEventsDisabled.size===1&&(m.body.style.pointerEvents=$u)}},[d,m,n,c]),p.useEffect(()=>()=>{d&&(c.layers.delete(d),c.layersWithOutsidePointerEventsDisabled.delete(d),zu())},[d,c]),p.useEffect(()=>{const E=()=>f({});return document.addEventListener(Bi,E),()=>document.removeEventListener(Bi,E)},[]),u.jsx(ve.div,{...l,ref:v,style:{pointerEvents:S?k?"auto":"none":void 0,...e.style},onFocusCapture:ae(e.onFocusCapture,T.onFocusCapture),onBlurCapture:ae(e.onBlurCapture,T.onBlurCapture),onPointerDownCapture:ae(e.onPointerDownCapture,C.onPointerDownCapture)})});br.displayName=Aw;var Pw="DismissableLayerBranch",Bu=p.forwardRef((e,t)=>{const n=p.useContext(Fu),r=p.useRef(null),o=$e(t,r);return p.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),u.jsx(ve.div,{...e,ref:o})});Bu.displayName=Pw;function Mw(e,t=globalThis==null?void 0:globalThis.document){const n=xt(e),r=p.useRef(!1),o=p.useRef(()=>{});return p.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){Hu(jw,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 Rw(e,t=globalThis==null?void 0:globalThis.document){const n=xt(e),r=p.useRef(!1);return p.useEffect(()=>{const o=s=>{s.target&&!r.current&&Hu(_w,n,{originalEvent:s},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function zu(){const e=new CustomEvent(Bi);document.dispatchEvent(e)}function Hu(e,t,n,{discrete:r}){const o=n.originalEvent.target,s=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?Fi(o,s):o.dispatchEvent(s)}var Ow=br,Dw=Bu,zi=0;function Hi(){p.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Uu()),document.body.insertAdjacentElement("beforeend",e[1]??Uu()),zi++,()=>{zi===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),zi--}},[])}function Uu(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var Ui="focusScope.autoFocusOnMount",Wi="focusScope.autoFocusOnUnmount",Wu={bubbles:!1,cancelable:!0},Lw="FocusScope",Jo=p.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,l]=p.useState(null),c=xt(o),d=xt(s),h=p.useRef(null),m=$e(t,g=>l(g)),f=p.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;p.useEffect(()=>{if(r){let g=function(S){if(f.paused||!a)return;const k=S.target;a.contains(k)?h.current=k:Ln(h.current,{select:!0})},x=function(S){if(f.paused||!a)return;const k=S.relatedTarget;k!==null&&(a.contains(k)||Ln(h.current,{select:!0}))},y=function(S){if(document.activeElement===document.body)for(const C of S)C.removedNodes.length>0&&Ln(a)};document.addEventListener("focusin",g),document.addEventListener("focusout",x);const 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]),p.useEffect(()=>{if(a){qu.add(f);const g=document.activeElement;if(!a.contains(g)){const y=new CustomEvent(Ui,Wu);a.addEventListener(Ui,c),a.dispatchEvent(y),y.defaultPrevented||($w(Uw(Vu(a)),{select:!0}),document.activeElement===g&&Ln(a))}return()=>{a.removeEventListener(Ui,c),setTimeout(()=>{const y=new CustomEvent(Wi,Wu);a.addEventListener(Wi,d),a.dispatchEvent(y),y.defaultPrevented||Ln(g??document.body,{select:!0}),a.removeEventListener(Wi,d),qu.remove(f)},0)}}},[a,c,d,f]);const v=p.useCallback(g=>{if(!n&&!r||f.paused)return;const x=g.key==="Tab"&&!g.altKey&&!g.ctrlKey&&!g.metaKey,y=document.activeElement;if(x&&y){const b=g.currentTarget,[S,k]=Fw(b);S&&k?!g.shiftKey&&y===k?(g.preventDefault(),n&&Ln(S,{select:!0})):g.shiftKey&&y===S&&(g.preventDefault(),n&&Ln(k,{select:!0})):y===b&&g.preventDefault()}},[n,r,f.paused]);return u.jsx(ve.div,{tabIndex:-1,...i,ref:m,onKeyDown:v})});Jo.displayName=Lw;function $w(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Ln(r,{select:t}),document.activeElement!==n)return}function Fw(e){const t=Vu(e),n=Ku(t,e),r=Ku(t.reverse(),e);return[n,r]}function Vu(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function Ku(e,t){for(const n of e)if(!Bw(n,{upTo:t}))return n}function Bw(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 Ln(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&zw(e)&&t&&e.select()}}var qu=Hw();function Hw(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=Gu(e,t),e.unshift(t)},remove(t){var n;e=Gu(e,t),(n=e[0])==null||n.resume()}}}function Gu(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Uw(e){return e.filter(t=>t.tagName!=="A")}var Ww=p[" useId ".trim().toString()]||(()=>{}),Vw=0;function Pt(e){const[t,n]=p.useState(Ww());return It(()=>{n(r=>r??String(Vw++))},[e]),t?`radix-${t}`:""}const Kw=["top","right","bottom","left"],$n=Math.min,Zt=Math.max,Zo=Math.round,Qo=Math.floor,wn=e=>({x:e,y:e}),qw={left:"right",right:"left",bottom:"top",top:"bottom"},Gw={start:"end",end:"start"};function Vi(e,t,n){return Zt(e,$n(t,n))}function Nn(e,t){return typeof e=="function"?e(t):e}function An(e){return e.split("-")[0]}function yr(e){return e.split("-")[1]}function Ki(e){return e==="x"?"y":"x"}function qi(e){return e==="y"?"height":"width"}const Yw=new Set(["top","bottom"]);function bn(e){return Yw.has(An(e))?"y":"x"}function Gi(e){return Ki(bn(e))}function Xw(e,t,n){n===void 0&&(n=!1);const r=yr(e),o=Gi(e),s=qi(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=es(i)),[i,es(i)]}function Jw(e){const t=es(e);return[Yi(e),t,Yi(t)]}function Yi(e){return e.replace(/start|end/g,t=>Gw[t])}const Yu=["left","right"],Xu=["right","left"],Zw=["top","bottom"],Qw=["bottom","top"];function eb(e,t,n){switch(e){case"top":case"bottom":return n?t?Xu:Yu:t?Yu:Xu;case"left":case"right":return t?Zw:Qw;default:return[]}}function tb(e,t,n,r){const o=yr(e);let s=eb(An(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(Yi)))),s}function es(e){return e.replace(/left|right|bottom|top/g,t=>qw[t])}function nb(e){return{top:0,right:0,bottom:0,left:0,...e}}function Ju(e){return typeof e!="number"?nb(e):{top:e,right:e,bottom:e,left:e}}function ts(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}function Zu(e,t,n){let{reference:r,floating:o}=e;const s=bn(t),i=Gi(t),a=qi(i),l=An(t),c=s==="y",d=r.x+r.width/2-o.width/2,h=r.y+r.height/2-o.height/2,m=r[a]/2-o[a]/2;let f;switch(l){case"top":f={x:d,y:r.y-o.height};break;case"bottom":f={x:d,y:r.y+r.height};break;case"right":f={x:r.x+r.width,y:h};break;case"left":f={x:r.x-o.width,y:h};break;default:f={x:r.x,y:r.y}}switch(yr(t)){case"start":f[i]-=m*(n&&c?-1:1);break;case"end":f[i]+=m*(n&&c?-1:1);break}return f}const rb=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=n,a=s.filter(Boolean),l=await(i.isRTL==null?void 0:i.isRTL(t));let c=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:d,y:h}=Zu(c,r,l),m=r,f={},v=0;for(let g=0;g<a.length;g++){const{name:x,fn:y}=a[g],{x:b,y:S,data:k,reset:C}=await y({x:d,y:h,initialPlacement:r,placement:m,strategy:o,middlewareData:f,rects:c,platform:i,elements:{reference:e,floating:t}});d=b??d,h=S??h,f={...f,[x]:{...f[x],...k}},C&&v<=50&&(v++,typeof C=="object"&&(C.placement&&(m=C.placement),C.rects&&(c=C.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):C.rects),{x:d,y:h}=Zu(c,m,l)),g=-1)}return{x:d,y:h,placement:m,strategy:o,middlewareData:f}};async function no(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:i,elements:a,strategy:l}=e,{boundary:c="clippingAncestors",rootBoundary:d="viewport",elementContext:h="floating",altBoundary:m=!1,padding:f=0}=Nn(t,e),v=Ju(f),x=a[m?h==="floating"?"reference":"floating":h],y=ts(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(x)))==null||n?x:x.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:c,rootBoundary:d,strategy:l})),b=h==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,S=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),k=await(s.isElement==null?void 0:s.isElement(S))?await(s.getScale==null?void 0:s.getScale(S))||{x:1,y:1}:{x:1,y:1},C=ts(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:b,offsetParent:S,strategy:l}):b);return{top:(y.top-C.top+v.top)/k.y,bottom:(C.bottom-y.bottom+v.bottom)/k.y,left:(y.left-C.left+v.left)/k.x,right:(C.right-y.right+v.right)/k.x}}const ob=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:s,platform:i,elements:a,middlewareData:l}=t,{element:c,padding:d=0}=Nn(e,t)||{};if(c==null)return{};const h=Ju(d),m={x:n,y:r},f=Gi(o),v=qi(f),g=await i.getDimensions(c),x=f==="y",y=x?"top":"left",b=x?"bottom":"right",S=x?"clientHeight":"clientWidth",k=s.reference[v]+s.reference[f]-m[f]-s.floating[v],C=m[f]-s.reference[f],T=await(i.getOffsetParent==null?void 0:i.getOffsetParent(c));let E=T?T[S]:0;(!E||!await(i.isElement==null?void 0:i.isElement(T)))&&(E=a.floating[S]||s.floating[v]);const N=k/2-C/2,R=E/2-g[v]/2-1,L=$n(h[y],R),z=$n(h[b],R),V=L,U=E-g[v]-z,j=E/2-g[v]/2+N,W=Vi(V,j,U),$=!l.arrow&&yr(o)!=null&&j!==W&&s.reference[v]/2-(j<V?L:z)-g[v]/2<0,O=$?j<V?j-V:j-U:0;return{[f]:m[f]+O,data:{[f]:W,centerOffset:j-W-O,...$&&{alignmentOffset:O}},reset:$}}}),sb=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:s,rects:i,initialPlacement:a,platform:l,elements:c}=t,{mainAxis:d=!0,crossAxis:h=!0,fallbackPlacements:m,fallbackStrategy:f="bestFit",fallbackAxisSideDirection:v="none",flipAlignment:g=!0,...x}=Nn(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const y=An(o),b=bn(a),S=An(a)===a,k=await(l.isRTL==null?void 0:l.isRTL(c.floating)),C=m||(S||!g?[es(a)]:Jw(a)),T=v!=="none";!m&&T&&C.push(...tb(a,g,v,k));const E=[a,...C],N=await no(t,x),R=[];let L=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&R.push(N[y]),h){const j=Xw(o,i,k);R.push(N[j[0]],N[j[1]])}if(L=[...L,{placement:o,overflows:R}],!R.every(j=>j<=0)){var z,V;const j=(((z=s.flip)==null?void 0:z.index)||0)+1,W=E[j];if(W&&(!(h==="alignment"?b!==bn(W):!1)||L.every(P=>bn(P.placement)===b?P.overflows[0]>0:!0)))return{data:{index:j,overflows:L},reset:{placement:W}};let $=(V=L.filter(O=>O.overflows[0]<=0).sort((O,P)=>O.overflows[1]-P.overflows[1])[0])==null?void 0:V.placement;if(!$)switch(f){case"bestFit":{var U;const O=(U=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,q)=>I+q,0)]).sort((P,I)=>P[1]-I[1])[0])==null?void 0:U[0];O&&($=O);break}case"initialPlacement":$=a;break}if(o!==$)return{reset:{placement:$}}}return{}}}};function Qu(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function ed(e){return Kw.some(t=>e[t]>=0)}const ib=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=Nn(e,t);switch(r){case"referenceHidden":{const s=await no(t,{...o,elementContext:"reference"}),i=Qu(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:ed(i)}}}case"escaped":{const s=await no(t,{...o,altBoundary:!0}),i=Qu(s,n.floating);return{data:{escapedOffsets:i,escaped:ed(i)}}}default:return{}}}}},td=new Set(["left","top"]);async function ab(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=An(n),a=yr(n),l=bn(n)==="y",c=td.has(i)?-1:1,d=s&&l?-1:1,h=Nn(t,e);let{mainAxis:m,crossAxis:f,alignmentAxis:v}=typeof h=="number"?{mainAxis:h,crossAxis:0,alignmentAxis:null}:{mainAxis:h.mainAxis||0,crossAxis:h.crossAxis||0,alignmentAxis:h.alignmentAxis};return a&&typeof v=="number"&&(f=a==="end"?v*-1:v),l?{x:f*d,y:m*c}:{x:m*c,y:f*d}}const lb=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 ab(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}}}}},cb=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}=Nn(e,t),c={x:n,y:r},d=await no(t,l),h=bn(An(o)),m=Ki(h);let f=c[m],v=c[h];if(s){const x=m==="y"?"top":"left",y=m==="y"?"bottom":"right",b=f+d[x],S=f-d[y];f=Vi(b,f,S)}if(i){const x=h==="y"?"top":"left",y=h==="y"?"bottom":"right",b=v+d[x],S=v-d[y];v=Vi(b,v,S)}const g=a.fn({...t,[m]:f,[h]:v});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[m]:s,[h]:i}}}}}},ub=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:s,middlewareData:i}=t,{offset:a=0,mainAxis:l=!0,crossAxis:c=!0}=Nn(e,t),d={x:n,y:r},h=bn(o),m=Ki(h);let f=d[m],v=d[h];const g=Nn(a,t),x=typeof g=="number"?{mainAxis:g,crossAxis:0}:{mainAxis:0,crossAxis:0,...g};if(l){const S=m==="y"?"height":"width",k=s.reference[m]-s.floating[S]+x.mainAxis,C=s.reference[m]+s.reference[S]-x.mainAxis;f<k?f=k:f>C&&(f=C)}if(c){var y,b;const S=m==="y"?"width":"height",k=td.has(An(o)),C=s.reference[h]-s.floating[S]+(k&&((y=i.offset)==null?void 0:y[h])||0)+(k?0:x.crossAxis),T=s.reference[h]+s.reference[S]+(k?0:((b=i.offset)==null?void 0:b[h])||0)-(k?x.crossAxis:0);v<C?v=C:v>T&&(v=T)}return{[m]:f,[h]:v}}}},db=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:s,platform:i,elements:a}=t,{apply:l=()=>{},...c}=Nn(e,t),d=await no(t,c),h=An(o),m=yr(o),f=bn(o)==="y",{width:v,height:g}=s.floating;let x,y;h==="top"||h==="bottom"?(x=h,y=m===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(y=h,x=m==="end"?"top":"bottom");const b=g-d.top-d.bottom,S=v-d.left-d.right,k=$n(g-d[x],b),C=$n(v-d[y],S),T=!t.middlewareData.shift;let E=k,N=C;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(N=S),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(E=b),T&&!m){const L=Zt(d.left,0),z=Zt(d.right,0),V=Zt(d.top,0),U=Zt(d.bottom,0);f?N=v-2*(L!==0||z!==0?L+z:Zt(d.left,d.right)):E=g-2*(V!==0||U!==0?V+U:Zt(d.top,d.bottom))}await l({...t,availableWidth:N,availableHeight:E});const R=await i.getDimensions(a.floating);return v!==R.width||g!==R.height?{reset:{rects:!0}}:{}}}};function ns(){return typeof window<"u"}function Sr(e){return nd(e)?(e.nodeName||"").toLowerCase():"#document"}function Qt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function yn(e){var t;return(t=(nd(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function nd(e){return ns()?e instanceof Node||e instanceof Qt(e).Node:!1}function un(e){return ns()?e instanceof Element||e instanceof Qt(e).Element:!1}function Sn(e){return ns()?e instanceof HTMLElement||e instanceof Qt(e).HTMLElement:!1}function rd(e){return!ns()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Qt(e).ShadowRoot}const fb=new Set(["inline","contents"]);function ro(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=dn(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!fb.has(o)}const hb=new Set(["table","td","th"]);function pb(e){return hb.has(Sr(e))}const mb=[":popover-open",":modal"];function rs(e){return mb.some(t=>{try{return e.matches(t)}catch{return!1}})}const gb=["transform","translate","scale","rotate","perspective"],xb=["transform","translate","scale","rotate","perspective","filter"],vb=["paint","layout","strict","content"];function Xi(e){const t=Ji(),n=un(e)?dn(e):e;return gb.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)||xb.some(r=>(n.willChange||"").includes(r))||vb.some(r=>(n.contain||"").includes(r))}function wb(e){let t=Fn(e);for(;Sn(t)&&!Cr(t);){if(Xi(t))return t;if(rs(t))return null;t=Fn(t)}return null}function Ji(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const bb=new Set(["html","body","#document"]);function Cr(e){return bb.has(Sr(e))}function dn(e){return Qt(e).getComputedStyle(e)}function os(e){return un(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Fn(e){if(Sr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||rd(e)&&e.host||yn(e);return rd(t)?t.host:t}function od(e){const t=Fn(e);return Cr(t)?e.ownerDocument?e.ownerDocument.body:e.body:Sn(t)&&ro(t)?t:od(t)}function oo(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=od(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Qt(o);if(s){const a=Zi(i);return t.concat(i,i.visualViewport||[],ro(o)?o:[],a&&n?oo(a):[])}return t.concat(o,oo(o,[],n))}function Zi(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function sd(e){const t=dn(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=Sn(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=Zo(n)!==s||Zo(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function Qi(e){return un(e)?e:e.contextElement}function Tr(e){const t=Qi(e);if(!Sn(t))return wn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=sd(t);let i=(s?Zo(n.width):n.width)/r,a=(s?Zo(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const yb=wn(0);function id(e){const t=Qt(e);return!Ji()||!t.visualViewport?yb:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Sb(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Qt(e)?!1:t}function Qn(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=Qi(e);let i=wn(1);t&&(r?un(r)&&(i=Tr(r)):i=Tr(e));const a=Sb(s,n,r)?id(s):wn(0);let l=(o.left+a.x)/i.x,c=(o.top+a.y)/i.y,d=o.width/i.x,h=o.height/i.y;if(s){const m=Qt(s),f=r&&un(r)?Qt(r):r;let v=m,g=Zi(v);for(;g&&r&&f!==v;){const x=Tr(g),y=g.getBoundingClientRect(),b=dn(g),S=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,h*=x.y,l+=S,c+=k,v=Qt(g),g=Zi(v)}}return ts({width:d,height:h,x:l,y:c})}function ss(e,t){const n=os(e).scrollLeft;return t?t.left+n:Qn(yn(e)).left+n}function ad(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-ss(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function Cb(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=yn(r),a=t?rs(t.floating):!1;if(r===i||a&&s)return n;let l={scrollLeft:0,scrollTop:0},c=wn(1);const d=wn(0),h=Sn(r);if((h||!h&&!s)&&((Sr(r)!=="body"||ro(i))&&(l=os(r)),Sn(r))){const f=Qn(r);c=Tr(r),d.x=f.x+r.clientLeft,d.y=f.y+r.clientTop}const m=i&&!h&&!s?ad(i,l):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 Tb(e){return Array.from(e.getClientRects())}function kb(e){const t=yn(e),n=os(e),r=e.ownerDocument.body,o=Zt(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Zt(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+ss(e);const a=-n.scrollTop;return dn(r).direction==="rtl"&&(i+=Zt(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const ld=25;function Eb(e,t){const n=Qt(e),r=yn(e),o=n.visualViewport;let s=r.clientWidth,i=r.clientHeight,a=0,l=0;if(o){s=o.width,i=o.height;const d=Ji();(!d||d&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}const c=ss(r);if(c<=0){const d=r.ownerDocument,h=d.body,m=getComputedStyle(h),f=d.compatMode==="CSS1Compat"&&parseFloat(m.marginLeft)+parseFloat(m.marginRight)||0,v=Math.abs(r.clientWidth-h.clientWidth-f);v<=ld&&(s-=v)}else c<=ld&&(s+=c);return{width:s,height:i,x:a,y:l}}const Ib=new Set(["absolute","fixed"]);function Nb(e,t){const n=Qn(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=Sn(e)?Tr(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 cd(e,t,n){let r;if(t==="viewport")r=Eb(e,n);else if(t==="document")r=kb(yn(e));else if(un(t))r=Nb(t,n);else{const o=id(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return ts(r)}function ud(e,t){const n=Fn(e);return n===t||!un(n)||Cr(n)?!1:dn(n).position==="fixed"||ud(n,t)}function Ab(e,t){const n=t.get(e);if(n)return n;let r=oo(e,[],!1).filter(a=>un(a)&&Sr(a)!=="body"),o=null;const s=dn(e).position==="fixed";let i=s?Fn(e):e;for(;un(i)&&!Cr(i);){const a=dn(i),l=Xi(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&Ib.has(o.position)||ro(i)&&!l&&ud(e,i))?r=r.filter(d=>d!==i):o=a,i=Fn(i)}return t.set(e,r),r}function jb(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?rs(t)?[]:Ab(t,this._c):[].concat(n),r],a=i[0],l=i.reduce((c,d)=>{const h=cd(t,d,o);return c.top=Zt(h.top,c.top),c.right=$n(h.right,c.right),c.bottom=$n(h.bottom,c.bottom),c.left=Zt(h.left,c.left),c},cd(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function _b(e){const{width:t,height:n}=sd(e);return{width:t,height:n}}function Pb(e,t,n){const r=Sn(t),o=yn(t),s=n==="fixed",i=Qn(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=wn(0);function c(){l.x=ss(o)}if(r||!r&&!s)if((Sr(t)!=="body"||ro(o))&&(a=os(t)),r){const f=Qn(t,!0,s,t);l.x=f.x+t.clientLeft,l.y=f.y+t.clientTop}else o&&c();s&&!r&&o&&c();const d=o&&!r&&!s?ad(o,a):wn(0),h=i.left+a.scrollLeft-l.x-d.x,m=i.top+a.scrollTop-l.y-d.y;return{x:h,y:m,width:i.width,height:i.height}}function ea(e){return dn(e).position==="static"}function dd(e,t){if(!Sn(e)||dn(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return yn(e)===n&&(n=n.ownerDocument.body),n}function fd(e,t){const n=Qt(e);if(rs(e))return n;if(!Sn(e)){let o=Fn(e);for(;o&&!Cr(o);){if(un(o)&&!ea(o))return o;o=Fn(o)}return n}let r=dd(e,t);for(;r&&pb(r)&&ea(r);)r=dd(r,t);return r&&Cr(r)&&ea(r)&&!Xi(r)?n:r||wb(e)||n}const Mb=async function(e){const t=this.getOffsetParent||fd,n=this.getDimensions,r=await n(e.floating);return{reference:Pb(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Rb(e){return dn(e).direction==="rtl"}const Ob={convertOffsetParentRelativeRectToViewportRelativeRect:Cb,getDocumentElement:yn,getClippingRect:jb,getOffsetParent:fd,getElementRects:Mb,getClientRects:Tb,getDimensions:_b,getScale:Tr,isElement:un,isRTL:Rb};function hd(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Db(e,t){let n=null,r;const o=yn(e);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),s();const c=e.getBoundingClientRect(),{left:d,top:h,width:m,height:f}=c;if(a||t(),!m||!f)return;const v=Qo(h),g=Qo(o.clientWidth-(d+m)),x=Qo(o.clientHeight-(h+f)),y=Qo(d),S={rootMargin:-v+"px "+-g+"px "+-x+"px "+-y+"px",threshold:Zt(0,$n(1,l))||1};let k=!0;function C(T){const E=T[0].intersectionRatio;if(E!==l){if(!k)return i();E?i(!1,E):r=setTimeout(()=>{i(!1,1e-7)},1e3)}E===1&&!hd(c,e.getBoundingClientRect())&&i(),k=!1}try{n=new IntersectionObserver(C,{...S,root:o.ownerDocument})}catch{n=new IntersectionObserver(C,S)}n.observe(e)}return i(!0),s}function Lb(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,c=Qi(e),d=o||s?[...c?oo(c):[],...oo(t)]:[];d.forEach(y=>{o&&y.addEventListener("scroll",n,{passive:!0}),s&&y.addEventListener("resize",n)});const h=c&&a?Db(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 S;(S=f)==null||S.observe(t)})),n()}),c&&!l&&f.observe(c),f.observe(t));let v,g=l?Qn(e):null;l&&x();function x(){const y=Qn(e);g&&!hd(g,y)&&n(),g=y,v=requestAnimationFrame(x)}return n(),()=>{var y;d.forEach(b=>{o&&b.removeEventListener("scroll",n),s&&b.removeEventListener("resize",n)}),h==null||h(),(y=f)==null||y.disconnect(),f=null,l&&cancelAnimationFrame(v)}}const $b=lb,Fb=cb,Bb=sb,zb=db,Hb=ib,pd=ob,Ub=ub,Wb=(e,t,n)=>{const r=new Map,o={platform:Ob,...n},s={...o.platform,_c:r};return rb(e,t,{...o,platform:s})};var Vb=typeof document<"u",Kb=function(){},is=Vb?w.useLayoutEffect:Kb;function as(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!as(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){const s=o[r];if(!(s==="_owner"&&e.$$typeof)&&!as(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function md(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function gd(e,t){const n=md(e);return Math.round(t*n)/n}function ta(e){const t=p.useRef(e);return is(()=>{t.current=e}),t}function qb(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:i}={},transform:a=!0,whileElementsMounted:l,open:c}=e,[d,h]=p.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[m,f]=p.useState(r);as(m,r)||f(r);const[v,g]=p.useState(null),[x,y]=p.useState(null),b=p.useCallback(P=>{P!==T.current&&(T.current=P,g(P))},[]),S=p.useCallback(P=>{P!==E.current&&(E.current=P,y(P))},[]),k=s||v,C=i||x,T=p.useRef(null),E=p.useRef(null),N=p.useRef(d),R=l!=null,L=ta(l),z=ta(o),V=ta(c),U=p.useCallback(()=>{if(!T.current||!E.current)return;const P={placement:t,strategy:n,middleware:m};z.current&&(P.platform=z.current),Wb(T.current,E.current,P).then(I=>{const q={...I,isPositioned:V.current!==!1};j.current&&!as(N.current,q)&&(N.current=q,Hr.flushSync(()=>{h(q)}))})},[m,t,n,z,V]);is(()=>{c===!1&&N.current.isPositioned&&(N.current.isPositioned=!1,h(P=>({...P,isPositioned:!1})))},[c]);const j=p.useRef(!1);is(()=>(j.current=!0,()=>{j.current=!1}),[]),is(()=>{if(k&&(T.current=k),C&&(E.current=C),k&&C){if(L.current)return L.current(k,C,U);U()}},[k,C,U,L,R]);const W=p.useMemo(()=>({reference:T,floating:E,setReference:b,setFloating:S}),[b,S]),$=p.useMemo(()=>({reference:k,floating:C}),[k,C]),O=p.useMemo(()=>{const P={position:n,left:0,top:0};if(!$.floating)return P;const I=gd($.floating,d.x),q=gd($.floating,d.y);return a?{...P,transform:"translate("+I+"px, "+q+"px)",...md($.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:I,top:q}},[n,a,$.floating,d.x,d.y]);return p.useMemo(()=>({...d,update:U,refs:W,elements:$,floatingStyles:O}),[d,U,W,$,O])}const Gb=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:o}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?pd({element:r.current,padding:o}).fn(n):{}:r?pd({element:r,padding:o}).fn(n):{}}}},Yb=(e,t)=>({...$b(e),options:[e,t]}),Xb=(e,t)=>({...Fb(e),options:[e,t]}),Jb=(e,t)=>({...Ub(e),options:[e,t]}),Zb=(e,t)=>({...Bb(e),options:[e,t]}),Qb=(e,t)=>({...zb(e),options:[e,t]}),ey=(e,t)=>({...Hb(e),options:[e,t]}),ty=(e,t)=>({...Gb(e),options:[e,t]});var ny="Arrow",xd=p.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return u.jsx(ve.svg,{...s,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:u.jsx("polygon",{points:"0,0 30,0 15,10"})})});xd.displayName=ny;var ry=xd;function vd(e){const[t,n]=p.useState(void 0);return It(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const s=o[0];let i,a;if("borderBoxSize"in s){const l=s.borderBoxSize,c=Array.isArray(l)?l[0]:l;i=c.inlineSize,a=c.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var na="Popper",[wd,kr]=cn(na),[oy,bd]=wd(na),yd=e=>{const{__scopePopper:t,children:n}=e,[r,o]=p.useState(null);return u.jsx(oy,{scope:t,anchor:r,onAnchorChange:o,children:n})};yd.displayName=na;var Sd="PopperAnchor",Cd=p.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=bd(Sd,n),i=p.useRef(null),a=$e(t,i),l=p.useRef(null);return p.useEffect(()=>{const c=l.current;l.current=(r==null?void 0:r.current)||i.current,c!==l.current&&s.onAnchorChange(l.current)}),r?null:u.jsx(ve.div,{...o,ref:a})});Cd.displayName=Sd;var ra="PopperContent",[sy,iy]=wd(ra),Td=p.forwardRef((e,t)=>{var K,D,X,Z,ue,F;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:a=0,avoidCollisions:l=!0,collisionBoundary:c=[],collisionPadding:d=0,sticky:h="partial",hideWhenDetached:m=!1,updatePositionStrategy:f="optimized",onPlaced:v,...g}=e,x=bd(ra,n),[y,b]=p.useState(null),S=$e(t,ne=>b(ne)),[k,C]=p.useState(null),T=vd(k),E=(T==null?void 0:T.width)??0,N=(T==null?void 0:T.height)??0,R=r+(s!=="center"?"-"+s:""),L=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},z=Array.isArray(c)?c:[c],V=z.length>0,U={padding:L,boundary:z.filter(ly),altBoundary:V},{refs:j,floatingStyles:W,placement:$,isPositioned:O,middlewareData:P}=qb({strategy:"fixed",placement:R,whileElementsMounted:(...ne)=>Lb(...ne,{animationFrame:f==="always"}),elements:{reference:x.anchor},middleware:[Yb({mainAxis:o+N,alignmentAxis:i}),l&&Xb({mainAxis:!0,crossAxis:!1,limiter:h==="partial"?Jb():void 0,...U}),l&&Zb({...U}),Qb({...U,apply:({elements:ne,rects:de,availableWidth:ce,availableHeight:ge})=>{const{width:Ce,height:Pe}=de.reference,De=ne.floating.style;De.setProperty("--radix-popper-available-width",`${ce}px`),De.setProperty("--radix-popper-available-height",`${ge}px`),De.setProperty("--radix-popper-anchor-width",`${Ce}px`),De.setProperty("--radix-popper-anchor-height",`${Pe}px`)}}),k&&ty({element:k,padding:a}),cy({arrowWidth:E,arrowHeight:N}),m&&ey({strategy:"referenceHidden",...U})]}),[I,q]=Id($),Y=xt(v);It(()=>{O&&(Y==null||Y())},[O,Y]);const _=(K=P.arrow)==null?void 0:K.x,M=(D=P.arrow)==null?void 0:D.y,G=((X=P.arrow)==null?void 0:X.centerOffset)!==0,[J,oe]=p.useState();return It(()=>{y&&oe(window.getComputedStyle(y).zIndex)},[y]),u.jsx("div",{ref:j.setFloating,"data-radix-popper-content-wrapper":"",style:{...W,transform:O?W.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:J,"--radix-popper-transform-origin":[(Z=P.transformOrigin)==null?void 0:Z.x,(ue=P.transformOrigin)==null?void 0:ue.y].join(" "),...((F=P.hide)==null?void 0:F.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:u.jsx(sy,{scope:n,placedSide:I,onArrowChange:C,arrowX:_,arrowY:M,shouldHideArrow:G,children:u.jsx(ve.div,{"data-side":I,"data-align":q,...g,ref:S,style:{...g.style,animation:O?void 0:"none"}})})})});Td.displayName=ra;var kd="PopperArrow",ay={top:"bottom",right:"left",bottom:"top",left:"right"},Ed=p.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=iy(kd,r),i=ay[s.placedSide];return u.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:u.jsx(ry,{...o,ref:n,style:{...o.style,display:"block"}})})});Ed.displayName=kd;function ly(e){return e!==null}var cy=e=>({name:"transformOrigin",options:e,fn(t){var x,y,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]=Id(n),h={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?h:`${m}px`,g=`${-l}px`):c==="top"?(v=i?h:`${m}px`,g=`${r.floating.height+l}px`):c==="right"?(v=`${-l}px`,g=i?h:`${f}px`):c==="left"&&(v=`${r.floating.width+l}px`,g=i?h:`${f}px`),{data:{x:v,y:g}}}});function Id(e){const[t,n="center"]=e.split("-");return[t,n]}var oa=yd,sa=Cd,ia=Td,aa=Ed,uy="Portal",so=p.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=p.useState(!1);It(()=>s(!0),[]);const i=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?Po.createPortal(u.jsx(ve.div,{...r,ref:t}),i):null});so.displayName=uy;function dy(e,t){return p.useReducer((n,r)=>t[n][r]??n,e)}var Wt=e=>{const{present:t,children:n}=e,r=fy(t),o=typeof n=="function"?n({present:r.isPresent}):p.Children.only(n),s=$e(r.ref,hy(o));return typeof n=="function"||r.isPresent?p.cloneElement(o,{ref:s}):null};Wt.displayName="Presence";function fy(e){const[t,n]=p.useState(),r=p.useRef(null),o=p.useRef(e),s=p.useRef("none"),i=e?"mounted":"unmounted",[a,l]=dy(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return p.useEffect(()=>{const c=ls(r.current);s.current=a==="mounted"?c:"none"},[a]),It(()=>{const c=r.current,d=o.current;if(d!==e){const m=s.current,f=ls(c);e?l("MOUNT"):f==="none"||(c==null?void 0:c.display)==="none"?l("UNMOUNT"):l(d&&m!==f?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,l]),It(()=>{if(t){let c;const d=t.ownerDocument.defaultView??window,h=f=>{const g=ls(r.current).includes(CSS.escape(f.animationName));if(f.target===t&&g&&(l("ANIMATION_END"),!o.current)){const x=t.style.animationFillMode;t.style.animationFillMode="forwards",c=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=x)})}},m=f=>{f.target===t&&(s.current=ls(r.current))};return t.addEventListener("animationstart",m),t.addEventListener("animationcancel",h),t.addEventListener("animationend",h),()=>{d.clearTimeout(c),t.removeEventListener("animationstart",m),t.removeEventListener("animationcancel",h),t.removeEventListener("animationend",h)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:p.useCallback(c=>{r.current=c?getComputedStyle(c):null,n(c)},[])}}function ls(e){return(e==null?void 0:e.animationName)||"none"}function hy(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var la="rovingFocusGroup.onEntryFocus",py={bubbles:!1,cancelable:!0},io="RovingFocusGroup",[ca,Nd,my]=Yo(io),[gy,Ad]=cn(io,[my]),[xy,vy]=gy(io),jd=p.forwardRef((e,t)=>u.jsx(ca.Provider,{scope:e.__scopeRovingFocusGroup,children:u.jsx(ca.Slot,{scope:e.__scopeRovingFocusGroup,children:u.jsx(wy,{...e,ref:t})})}));jd.displayName=io;var wy=p.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:c,preventScrollOnEntryFocus:d=!1,...h}=e,m=p.useRef(null),f=$e(t,m),v=Xo(s),[g,x]=Dn({prop:i,defaultProp:a??null,onChange:l,caller:io}),[y,b]=p.useState(!1),S=xt(c),k=Nd(n),C=p.useRef(!1),[T,E]=p.useState(0);return p.useEffect(()=>{const N=m.current;if(N)return N.addEventListener(la,S),()=>N.removeEventListener(la,S)},[S]),u.jsx(xy,{scope:n,orientation:r,dir:v,loop:o,currentTabStopId:g,onItemFocus:p.useCallback(N=>x(N),[x]),onItemShiftTab:p.useCallback(()=>b(!0),[]),onFocusableItemAdd:p.useCallback(()=>E(N=>N+1),[]),onFocusableItemRemove:p.useCallback(()=>E(N=>N-1),[]),children:u.jsx(ve.div,{tabIndex:y||T===0?-1:0,"data-orientation":r,...h,ref:f,style:{outline:"none",...e.style},onMouseDown:ae(e.onMouseDown,()=>{C.current=!0}),onFocus:ae(e.onFocus,N=>{const R=!C.current;if(N.target===N.currentTarget&&R&&!y){const L=new CustomEvent(la,py);if(N.currentTarget.dispatchEvent(L),!L.defaultPrevented){const z=k().filter($=>$.focusable),V=z.find($=>$.active),U=z.find($=>$.id===g),W=[V,U,...z].filter(Boolean).map($=>$.ref.current);Md(W,d)}}C.current=!1}),onBlur:ae(e.onBlur,()=>b(!1))})})}),_d="RovingFocusGroupItem",Pd=p.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,l=Pt(),c=s||l,d=vy(_d,n),h=d.currentTabStopId===c,m=Nd(n),{onFocusableItemAdd:f,onFocusableItemRemove:v,currentTabStopId:g}=d;return p.useEffect(()=>{if(r)return f(),()=>v()},[r,f,v]),u.jsx(ca.ItemSlot,{scope:n,id:c,focusable:r,active:o,children:u.jsx(ve.span,{tabIndex:h?0:-1,"data-orientation":d.orientation,...a,ref:t,onMouseDown:ae(e.onMouseDown,x=>{r?d.onItemFocus(c):x.preventDefault()}),onFocus:ae(e.onFocus,()=>d.onItemFocus(c)),onKeyDown:ae(e.onKeyDown,x=>{if(x.key==="Tab"&&x.shiftKey){d.onItemShiftTab();return}if(x.target!==x.currentTarget)return;const y=Sy(x,d.orientation,d.dir);if(y!==void 0){if(x.metaKey||x.ctrlKey||x.altKey||x.shiftKey)return;x.preventDefault();let S=m().filter(k=>k.focusable).map(k=>k.ref.current);if(y==="last")S.reverse();else if(y==="prev"||y==="next"){y==="prev"&&S.reverse();const k=S.indexOf(x.currentTarget);S=d.loop?Cy(S,k+1):S.slice(k+1)}setTimeout(()=>Md(S))}}),children:typeof i=="function"?i({isCurrentTabStop:h,hasTabStop:g!=null}):i})})});Pd.displayName=_d;var by={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function yy(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Sy(e,t,n){const r=yy(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return by[r]}function Md(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function Cy(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Ty=jd,ky=Pd,Ey=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Er=new WeakMap,cs=new WeakMap,us={},ua=0,Rd=function(e){return e&&(e.host||Rd(e.parentNode))},Iy=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=Rd(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},Ny=function(e,t,n,r){var o=Iy(t,Array.isArray(e)?e:[e]);us[n]||(us[n]=new WeakMap);var s=us[n],i=[],a=new Set,l=new Set(o),c=function(h){!h||a.has(h)||(a.add(h),c(h.parentNode))};o.forEach(c);var d=function(h){!h||l.has(h)||Array.prototype.forEach.call(h.children,function(m){if(a.has(m))d(m);else try{var f=m.getAttribute(r),v=f!==null&&f!=="false",g=(Er.get(m)||0)+1,x=(s.get(m)||0)+1;Er.set(m,g),s.set(m,x),i.push(m),g===1&&v&&cs.set(m,!0),x===1&&m.setAttribute(n,"true"),v||m.setAttribute(r,"true")}catch(y){console.error("aria-hidden: cannot operate on ",m,y)}})};return d(t),a.clear(),ua++,function(){i.forEach(function(h){var m=Er.get(h)-1,f=s.get(h)-1;Er.set(h,m),s.set(h,f),m||(cs.has(h)||h.removeAttribute(r),cs.delete(h)),f||h.removeAttribute(n)}),ua--,ua||(Er=new WeakMap,Er=new WeakMap,cs=new WeakMap,us={})}},da=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=Ey(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),Ny(r,o,n,"aria-hidden")):function(){return null}},Cn=function(){return Cn=Object.assign||function(t){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])}return t},Cn.apply(this,arguments)};function Od(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n}function Ay(e,t,n){if(n||arguments.length===2)for(var r=0,o=t.length,s;r<o;r++)(s||!(r in t))&&(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return e.concat(s||Array.prototype.slice.call(t))}typeof SuppressedError=="function"&&SuppressedError;var ds="right-scroll-bar-position",fs="width-before-scroll-bar",jy="with-scroll-bars-hidden",_y="--removed-body-scroll-bar-size";function fa(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function Py(e,t){var n=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 My=typeof window<"u"?p.useLayoutEffect:p.useEffect,Dd=new WeakMap;function Ry(e,t){var n=Py(null,function(r){return e.forEach(function(o){return fa(o,r)})});return My(function(){var r=Dd.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||fa(a,null)}),s.forEach(function(a){o.has(a)||fa(a,i)})}Dd.set(n,e)},[e]),n}function Oy(e){return e}function Dy(e,t){t===void 0&&(t=Oy);var n=[],r=!1,o={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(s){var i=t(s,r);return n.push(i),function(){n=n.filter(function(a){return a!==i})}},assignSyncMedium:function(s){for(r=!0;n.length;){var i=n;n=[],i.forEach(s)}n={push:function(a){return s(a)},filter:function(){return n}}},assignMedium:function(s){r=!0;var i=[];if(n.length){var a=n;n=[],a.forEach(s),i=n}var l=function(){var d=i;i=[],d.forEach(s)},c=function(){return Promise.resolve().then(l)};c(),n={push:function(d){i.push(d),c()},filter:function(d){return i=i.filter(d),n}}}};return o}function Ly(e){e===void 0&&(e={});var t=Dy(null);return t.options=Cn({async:!0,ssr:!1},e),t}var Ld=function(e){var t=e.sideCar,n=Od(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return p.createElement(r,Cn({},n))};Ld.isSideCarExport=!0;function $y(e,t){return e.useMedium(t),Ld}var $d=Ly(),ha=function(){},hs=p.forwardRef(function(e,t){var n=p.useRef(null),r=p.useState({onScrollCapture:ha,onWheelCapture:ha,onTouchMoveCapture:ha}),o=r[0],s=r[1],i=e.forwardProps,a=e.children,l=e.className,c=e.removeScrollBar,d=e.enabled,h=e.shards,m=e.sideCar,f=e.noRelative,v=e.noIsolation,g=e.inert,x=e.allowPinchZoom,y=e.as,b=y===void 0?"div":y,S=e.gapMode,k=Od(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=m,T=Ry([n,t]),E=Cn(Cn({},k),o);return p.createElement(p.Fragment,null,d&&p.createElement(C,{sideCar:$d,removeScrollBar:c,shards:h,noRelative:f,noIsolation:v,inert:g,setCallbacks:s,allowPinchZoom:!!x,lockRef:n,gapMode:S}),i?p.cloneElement(p.Children.only(a),Cn(Cn({},E),{ref:T})):p.createElement(b,Cn({},E,{className:l,ref:T}),a))});hs.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},hs.classNames={fullWidth:fs,zeroRight:ds};var Fy=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function By(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Fy();return t&&e.setAttribute("nonce",t),e}function zy(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Hy(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var Uy=function(){var e=0,t=null;return{add:function(n){e==0&&(t=By())&&(zy(t,n),Hy(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Wy=function(){var e=Uy();return function(t,n){p.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Fd=function(){var e=Wy(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},Vy={left:0,top:0,right:0,gap:0},pa=function(e){return parseInt(e||"",10)||0},Ky=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],o=t[e==="padding"?"paddingRight":"marginRight"];return[pa(n),pa(r),pa(o)]},qy=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Vy;var t=Ky(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},Gy=Fd(),Ir="data-scroll-locked",Yy=function(e,t,n,r){var o=e.left,s=e.top,i=e.right,a=e.gap;return n===void 0&&(n="margin"),`
|
|
39
|
+
`)):t(e)}function Zv(e){return e.name&&e.name.trim()?e.name:e.model&&e.model.includes("/")?e.model.split("/").pop()||null:e.model||null}function pu(e){if(e.role==="default_message")return`default:${e.content.length}`;const t=e.updatedAt??e.createdAt??"",n=Array.isArray(e.content)?e.content.map(i=>{switch(i.type){case"text":return`t:${i.text.length}`;case"image_url":return"img";case"file":return"file";case"tool_call":return"call";case"interrupt":return"interrupt";default:return"unknown"}}).join("|"):"",r="checkpointId"in e&&e.checkpointId?`cp:${e.checkpointId}`:"",o="checkpointNs"in e&&e.checkpointNs?`ns:${e.checkpointNs}`:"",s=[r,o].filter(Boolean).join("|");return`${e.id}:${t}:${n}${s?`:${s}`:""}`}function Qv(e){if(!e)return"image/png";const t=e.trim();return t?t.includes("/")?t:`image/${t}`:"image/png"}function ew(e){const t=[],n=r=>{r&&r.trim()&&t.push(r.trim())};return e&&(n(e.plotId),n(e.artifactId)),t}function tw({base64:e,url:t,formatHint:n,extras:r}){const o=typeof e=="string"&&e.length>0,s=Qv(n),i=o?`data:${s};base64,${e}`:t,a=ew(r),l=a.length?a.join(" / "):void 0,c=l?`${l} artifact`:"artifact image";return{src:i,alt:c,label:l}}function nw(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 tw({base64:t,url:n,formatHint:r,extras:{plotId:e.plotId,artifactId:e.artifactId}})}function mu(e){var n;const t=(n=e.additionalKwargs)==null?void 0:n.toolProgress;return Array.isArray(t)?t:[]}const rw={messages:[],assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,messagesStreamMeta:{},pendingInterrupt:null};function ow(e,t){var n;switch(t.type){case"reset":return{messages:Pi(((n=t.payload)==null?void 0:n.messages)??[]),assemblingId:null,lastCheckpointId:null,lastCheckpointNs:null,pendingInterrupt:null,messagesStreamMeta:{}};case"user_message":{const{message:r,editingMessageId:o}=t.payload;if(o){const s=e.messages.findIndex(i=>i.id===o);if(s>=0){const i=e.messages.slice(0,s);return{...e,messages:[...i,r]}}}return{...e,messages:[...e.messages,r]}}case"seed":{const r=Pi(t.payload.messages),o={...e,messages:r,assemblingId:null,pendingInterrupt:t.payload.pendingInterrupt??null};return Object.prototype.hasOwnProperty.call(t.payload,"checkpointId")&&(o.lastCheckpointId=t.payload.checkpointId??null),Object.prototype.hasOwnProperty.call(t.payload,"checkpointNs")&&(o.lastCheckpointNs=t.payload.checkpointNs??null),o}case"prepend":{const r=Pi(t.payload.messages);if(!r.length)return e;const o=new Set(e.messages.map(a=>a.id)),s=r.filter(a=>!o.has(a.id));if(!s.length)return e;const i=[...s,...e.messages];return{...e,messages:i}}case"event":return gu(e,t.payload.ev);case"batch":{const{events:r}=t.payload;return r.length?r.reduce((o,s)=>gu(o,s),e):e}default:return e}}function sw(e=[]){const[t,n]=w.useReducer(ow,{...rw,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,h)=>n({type:"seed",payload:{messages:d,...h??{}}}),prepend:d=>n({type:"prepend",payload:{messages:d}}),pushUser:(d,h)=>n({type:"user_message",payload:{message:d,editingMessageId:h}}),onEvent:l}),[l]);return{state:t,dispatch:n,...c}}function gu(e,t){var n,r,o;if(t.type==="message.start"&&t.role==="assistant"){const s=t.id,i=cu(t.model);if(e.messages.some(c=>c.id===s)){const c=e.messagesStreamMeta??{},d={...c,[s]:c[s]??{lastSeq:t.seq??null,lastText:""}};return{...e,assemblingId:s,messagesStreamMeta:d}}const l={id:s,role:"assistant",name:i||void 0,model:t.model,createdAt:new Date().toISOString(),content:[]};return{...e,assemblingId:s,messages:[...e.messages,l]}}if(t.type==="tool.start")return aw(e,t);if(t.type==="tool.progress")return lw(e,t);if(t.type==="tool.end")return cw(e,t);if(t.type==="message.delta"){const s=e.assemblingId??su(e.messages);if(!s)return e;const i=e.messages,a=i.findIndex(C=>C.id===s&&C.role==="assistant");if(a===-1)return e;const l=i[a],c=e.messagesStreamMeta,d=c??{},h=d[s],m=h??{lastSeq:null,lastText:iu(l.content)},f=t.seq??null;if(f!==null&&typeof f=="number"&&typeof m.lastSeq=="number"&&f<=m.lastSeq)return console.debug("[MessageReducer] skipping delta - seq <= lastSeq",{seq:f,lastSeq:m.lastSeq}),e;const{newParts:v,newMeta:g,changed:x}=au(l.content,t.delta,m,f);if(!x)return e;const y={...l,content:v},b=Jr(i,a,y),S=!h||h.lastSeq!==g.lastSeq||h.lastText!==g.lastText,k=S?{...d,[s]:g}:c;return S?{...e,messages:b,messagesStreamMeta:k}:{...e,messages:b}}if(t.type==="message.end"){const s=e.assemblingId??su(e.messages);if(!s)return{...e,assemblingId:null};const i=e.messages,a=i.findIndex(l=>l.id===s&&l.role==="assistant");if(a>=0){const l=i[a];if(!((n=l.content)==null?void 0:n.some(d=>{var h;return(d==null?void 0:d.type)==="text"&&((h=d.text)==null?void 0:h.trim())}))){console.debug("[MessageReducer] pruning assistant message with no visible text",{id:l.id,contentTypes:(r=l.content)==null?void 0:r.map(h=>h==null?void 0:h.type),contentPreview:(o=l.content)==null?void 0:o.map(h=>(h==null?void 0:h.type)==="text"?String(h.text).slice(0,100):h==null?void 0:h.type)});const d=[...i.slice(0,a),...i.slice(a+1)];return{...e,assemblingId:null,messages:d}}}return e}if(t.type==="checkpoint"){const s=t.checkpointNs??e.lastCheckpointNs??null,i=Wv(e.messages,t.checkpointId,s);return{...e,lastCheckpointId:t.checkpointId,lastCheckpointNs:s,messages:i}}if(t.type==="error"){const s={id:`err-${Date.now()}`,role:"system",content:[{type:"text",text:`Error: ${t.message}`}],createdAt:new Date().toISOString()};return{...e,messages:[...e.messages,s]}}if(t.type==="state_history"){const s=Mn(t),i=s.interrupt,a=s.latest,l=i===null?Hv(e.messages):e.messages;return{...e,messages:l,pendingInterrupt:i,lastCheckpointId:(a==null?void 0:a.checkpointId)??e.lastCheckpointId,lastCheckpointNs:(a==null?void 0:a.checkpointNs)??e.lastCheckpointNs}}return t.type==="thread_info",e}function Oi(e){return e.call_id??e.id??null}function xu(e){return e.id??e.call_id??`tool-${Date.now()}-${Math.random().toString(16).slice(2)}`}function vu(e,t,n,r){const o=t??`call-${Date.now()}-${Math.random().toString(16).slice(2)}`;return{id:e,role:"tool",name:n??void 0,content:[{type:"tool_call",id:o,name:n??"tool",args:r??{}}],createdAt:new Date().toISOString(),additionalKwargs:{toolCallId:o,toolName:n??void 0,toolStreaming:!0,toolProgress:[]}}}function Di(e,t){if(!t)return-1;for(let n=0;n<e.length;n+=1){const r=e[n];if(r.role!=="tool")continue;const o=r.additionalKwargs??{};if(typeof o.toolCallId=="string"&&o.toolCallId===t||Ri(r).toolCallId===t)return n}return-1}function iw(e){if(e==null)return[];const t=Qr(e);if(typeof t=="string"&&t.trim())return[{type:"text",text:t}];const n=xr(t??e);return n?[{type:"text",text:n}]:[]}function wu(e,t){const n=e.additionalKwargs??{},r=Array.isArray(n.toolProgress)?[...n.toolProgress]:[],o={...n,toolProgress:[...r,t]};return{...e,additionalKwargs:o}}function aw(e,t){const n=Oi(t),r=Di(e.messages,n),o=t.name??t.tool??void 0,s=xu(t);if(r>=0){const a=e.messages[r],c={...a.additionalKwargs??{},toolStreaming:!0,toolProgress:[]},d={...a,name:o??a.name,additionalKwargs:c};return{...e,messages:Jr(e.messages,r,d)}}const i=vu(s,n,o,t.args);return{...e,messages:[...e.messages,i]}}function lw(e,t){const n=Oi(t);if(!n)return e;const r=Di(e.messages,n);if(r===-1)return e;const o={type:t.type,content:typeof t.content=="string"?t.content:void 0,seq:t.seq??null,timestamp:new Date().toISOString()},s=t.metadata;s&&(o.metadata=s);const i=t.idx;typeof i=="number"&&(o.idx=i);const a=wu(e.messages[r],o);return{...e,messages:Jr(e.messages,r,a)}}function cw(e,t){const n=Oi(t),r=xu(t);let o=e.messages,s=Di(o,n);if(s===-1){const v=t.name??t.tool??void 0;o=[...o,vu(r,n,v,{})],s=o.length-1}const i=o[s],a=t.output??t.error??null,l=iw(a),c=[...i.content,...l],d={type:t.type,content:typeof t.output=="string"?t.output:void 0,seq:t.seq??null,timestamp:new Date().toISOString()};t.artifact&&(d.artifact=t.artifact);const h=wu(i,d),m=t.artifact??i.artifact,f={...h,name:t.name??t.tool??i.name,content:c,artifact:m,additionalKwargs:{...h.additionalKwargs??{},toolStreaming:!1}};return{...e,messages:Jr(o,s,f)}}function bu({api:e,seed:t,prepend:n,onError:r,currentThreadId:o,initialThreadId:s=null,initialCheckpointId:i=null,initialCheckpointNs:a=null,autoLoadInitial:l=!0,isStreaming:c,getMessages:d}){const[h,m]=w.useState(null),v=w.useMemo(()=>Mn(h),[h]).checkpoints,g=tc(v),x=g.timeline,[y,b]=w.useState(!1),[S,k]=w.useState(null),[C,T]=w.useState(!1),[E,N]=w.useState(!1),[R,L]=w.useState(!1),[z,V]=w.useState(null),U=w.useRef(o),j=w.useRef(null),W=w.useRef(null),$=w.useRef(null),O=w.useRef(null),P=w.useRef(!1),I=w.useRef(null),q=w.useRef(new Map);w.useEffect(()=>{U.current=o},[o]);const Y=w.useCallback(async F=>{var de,ce;if(!F.threadId)return;const ne=F.threadId;(de=F.onStart)==null||de.call(F),F.setLoading(!0);try{await F.action(ne)}catch(ge){if(U.current===ne){const Ce=String(ge);(ce=F.handleError)==null||ce.call(F,Ce),r==null||r(Ce)}throw ge}finally{F.setLoading(!1)}},[r]),_=w.useCallback(async(F,ne)=>{if(!F)return;const de=`${F}:${ne??"latest"}`,ce=q.current.get(de);if(ce)return ce;const ge=Y({threadId:F,setLoading:T,onStart:()=>V(null),handleError:Ce=>V(Ce),action:async Ce=>{const Pe=await e.getStateHistory({threadId:Ce,checkpointId:ne??void 0});if(U.current!==Ce){console.log(`[useThreadHistoryState] Thread changed during load (was ${Ce}, now ${U.current}), discarding stale data`);return}const{checkpoints:De}=Mn(Pe),ze=De.find(rt=>rt.messages&&rt.messages.length>0)??(ne?De.find(rt=>rt.checkpointId===ne):null)??De[0];t((ze==null?void 0:ze.messages)??[],{checkpointId:(ze==null?void 0:ze.checkpointId)??null,checkpointNs:(ze==null?void 0:ze.checkpointNs)??null}),m(Pe),b(!!(ze!=null&&ze.nextCursor)),k((ze==null?void 0:ze.nextCursor)??null)}});q.current.set(de,ge);try{await ge}finally{q.current.delete(de)}return U.current===F&&(I.current=de),ge},[e,t,Y]),M=w.useCallback(async(F,ne)=>{O.current=F;try{await _(F,ne)}finally{O.current===F&&(O.current=null)}},[_]),G=w.useCallback(F=>{W.current=F},[]),J=w.useCallback(F=>{$.current=F},[]),oe=w.useCallback(F=>{const ne=F.threadId??U.current;if(!ne||U.current&&U.current!==ne)return;const{checkpoints:de}=Mn(F);if(!de.length)return;const ce=de.find(Ce=>Ce.messages&&Ce.messages.length>0)??de.find(Ce=>!!Ce.checkpointId)??de[0],ge=$.current===ne;!c&&!ge&&t((ce==null?void 0:ce.messages)??[],{checkpointId:(ce==null?void 0:ce.checkpointId)??null,checkpointNs:(ce==null?void 0:ce.checkpointNs)??null}),m(F),b(!!(ce!=null&&ce.nextCursor)),k((ce==null?void 0:ce.nextCursor)??null),I.current=`${ne}:latest`,W.current=null,$.current===ne&&($.current=null)},[t,c]),K=w.useCallback(async(F,ne)=>{const de=U.current;await Y({threadId:de,setLoading:L,action:async ce=>{const ge=await e.getStateHistory({threadId:ce,checkpointId:F,checkpointNs:ne??void 0});if(U.current!==ce){console.log(`[useThreadHistoryState] Thread changed during checkpoint navigation (was ${ce}, now ${U.current}), discarding stale data`);return}const{checkpoints:Ce}=Mn(ge),Pe=Ce.find(De=>De.checkpointId===F&&(ne?De.checkpointNs===ne:!0));if(!Pe){console.warn("[useThreadHistoryState] Requested checkpoint not found:",{checkpointId:F,checkpointNs:ne});return}m(ge),t(Pe.messages??[],{checkpointId:Pe.checkpointId??null,checkpointNs:Pe.checkpointNs??null})}}).catch(()=>{})},[e,t,Y]),D=w.useCallback((F,ne)=>{t(d(),{checkpointId:F??null,checkpointNs:ne??null})},[d,t]),X=w.useCallback(async()=>{U.current&&await M(U.current)},[M]),Z=w.useCallback(async()=>{const F=U.current;!F||!S||await Y({threadId:F,setLoading:N,action:async ne=>{const de=await e.getStateHistory({threadId:ne,checkpointId:S});if(U.current!==ne)return;const{checkpoints:ce}=Mn(de);if(ce.length>0){const ge=ce[ce.length-1];n((ge==null?void 0:ge.messages)??[]),b(!!(ge!=null&&ge.nextCursor)),k((ge==null?void 0:ge.nextCursor)??null)}}}).catch(()=>{})},[e,S,r,n,Y]);w.useEffect(()=>{if(!l||!o||C||c)return;if(W.current===o){W.current=null,j.current=o;return}if($.current===o){j.current=o;return}if(O.current===o){O.current=null,j.current=o;return}if(j.current===o)return;j.current=o;const F=!P.current&&!!i&&o===s;let ne;F&&i?(ne=i,P.current=!0,console.log("[useThreadHistoryState] Loading thread with checkpoint:",ne,a?`(ns: ${a})`:"")):console.log("[useThreadHistoryState] Loading thread with latest checkpoint");const de=`${o}:${ne??"latest"}`;I.current!==de&&M(o,ne)},[l,o,i,a,s,C,c,M]);const ue=w.useCallback(()=>{m(null),b(!1),k(null),T(!1),N(!1),L(!1),V(null),W.current=null,$.current=null,j.current=null,I.current=null,O.current=null},[]);return{threadCheckpoints:v,threadTimeline:x,checkpointIndex:g,isLoadingThread:C,isHistoryLoading:E,isLoadingCheckpoint:R,threadStateError:z,hasMoreHistory:y,loadThread:M,navigateToCheckpoint:K,loadOlderMessages:Z,setCurrentCheckpointId:D,returnToLatest:X,handleStateHistoryEvent:oe,markSkipNextLoad:G,markStreamPendingThread:J,resetHistoryState:ue}}const yu=w.createContext(null),Su=w.createContext(null);function eo(){const e=w.useContext(yu);if(!e)throw new Error("useThreadState must be used within a ThreadStateProvider");return e}function Cu(){const e=w.useContext(Su);if(!e)throw new Error("useThreadStateUpdater must be used within a ThreadStateProvider");return e}function Tu({children:e,initialThreadId:t=null,initialCheckpointId:n=null,initialCheckpointNs:r=null,autoLoadInitial:o=!0,isStreaming:s,onError:i}){const{api:a}=Xr(),{currentThreadId:l}=gr(),{state:c,seed:d,prepend:h,pushUser:m,onEvent:f}=sw(),{threadCheckpoints:v,threadTimeline:g,checkpointIndex:x,isLoadingThread:y,isHistoryLoading:b,isLoadingCheckpoint:S,threadStateError:k,hasMoreHistory:C,loadThread:T,navigateToCheckpoint:E,loadOlderMessages:N,setCurrentCheckpointId:R,returnToLatest:L,handleStateHistoryEvent:z,markSkipNextLoad:V,markStreamPendingThread:U,resetHistoryState:j}=bu({api:a,seed:d,prepend:h,onError:i,currentThreadId:l,initialThreadId:t,initialCheckpointId:n,initialCheckpointNs:r,autoLoadInitial:o,isStreaming:s,getMessages:w.useCallback(()=>c.messages,[c.messages])}),[W,$]=w.useState(()=>async()=>{throw new Error("clearThread is not ready")}),[O,P]=w.useState(()=>async()=>{throw new Error("respondToInterrupt is not ready")});w.useEffect(()=>{l||(d([],{}),j())},[l,d,j]);const I=w.useCallback(G=>$(()=>G),[]),q=w.useCallback(G=>P(()=>G),[]),Y=w.useMemo(()=>({assemblingMessageId:c.assemblingId??null}),[c.assemblingId]),_=w.useMemo(()=>({threadId:l,messages:c.messages,interrupt:c.pendingInterrupt,checkpoint:{id:c.lastCheckpointId??null,namespace:c.lastCheckpointNs??null},checkpoints:v,checkpointIndex:x,timelineCheckpoints:g,metadata:Y,isLoading:y,isHistoryLoading:b,isLoadingCheckpoint:S,error:k,hasMore:C,loadOlder:N,clearState:W,navigateToCheckpoint:E,setCurrentCheckpointId:R,returnToLatest:L,loadThread:T,clearThread:W,respondToInterrupt:O,messagePreviews:x.messagePreviews,handleStateHistoryEvent:z,markSkipNextLoad:V,markStreamPendingThread:U,resetHistoryState:j,pushUser:m,onEvent:f}),[l,c,v,g,x,Y,y,b,S,k,C,N,W,E,R,L,T,O,x.messagePreviews,z,V,U,j,m,f]),M=w.useMemo(()=>({registerClearThread:I,registerRespondToInterrupt:q}),[I,q]);return u.jsx(Su.Provider,{value:M,children:u.jsx(yu.Provider,{value:_,children:e})})}function ku(e,t){if(!e)return null;const n=_n(e);if(!n)return null;const r=_n(n.configurable)??n;return Pn(r,t)??null}function uw(e){const t=ku(e,["checkpoint_id","checkpointId"]);if(!t)return null;const n=ku(e,["checkpoint_ns","checkpointNs"]);return{checkpointId:t,checkpointNs:n}}function dw(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 fw(e,t){const n=[...e].sort(dw);for(const r of n){if(r.messageId!==t)continue;const o=uw(r.parentConfig);if(!o)throw new Error(`Parent checkpoint info missing for message ${t}`);return o}throw new Error(`Message ${t} not found in timeline`)}const Eu=w.createContext(null),Iu=w.createContext(!1);function hw({children:e,initialThreadId:t=null,initialCheckpointId:n=null,initialCheckpointNs:r=null,autoLoadInitial:o=!0,onError:s,onAuthError:i,onThreadChange:a,onConnectionError:l,onToolEnd:c}){const{api:d,baseUrl:h}=Xr(),m=w.useMemo(()=>vn(h),[h]),{stream:f,stop:v,isStreaming:g,error:x,setToken:y}=Vv({baseUrl:m}),[b,S]=w.useState(!1);return w.useEffect(()=>{S(g)},[g]),u.jsx(fu,{initialThreadId:t,onError:s,onThreadChange:a,children:u.jsx(Tu,{initialThreadId:t,initialCheckpointId:n,initialCheckpointNs:r,autoLoadInitial:o,onError:s,isStreaming:b,children:u.jsx(Iu.Provider,{value:!0,children:u.jsx(pw,{api:d,streamApi:{stream:f,stop:v,isStreaming:g,error:x,setToken:y},onError:s,onAuthError:i,onConnectionError:l,onToolEnd:c,children:e})})})})}function pw({children:e,api:t,streamApi:n,onError:r,onAuthError:o,onConnectionError:s,onToolEnd:i}){const{stream:a,stop:l,isStreaming:c,error:d,setToken:h}=n,{setCurrentThreadId:m,currentThreadIdRef:f,addThreadFromEvent:v}=gr(),{checkpoint:g,timelineCheckpoints:x,handleStateHistoryEvent:y,markSkipNextLoad:b,markStreamPendingThread:S,resetHistoryState:k,pushUser:C,onEvent:T}=eo(),{registerClearThread:E,registerRespondToInterrupt:N}=Cu(),R=w.useCallback(O=>{v(O),f.current!==O.threadId&&((O.created??!f.current)&&b(O.threadId),S(O.threadId),m(O.threadId))},[v,b,S,m,f]),L=w.useCallback(O=>{O.type==="thread_info"?R(O):O.type==="state_history"?y(O):O.type==="tool.end"?i==null||i(O):T(O)},[R,y,T,i]),z=w.useCallback(O=>{a(O,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 U=w.useCallback(async(O,P,I)=>{const q=f.current;if(!q)throw new Error("No active thread to handle interrupt");const Y=P?I??!0:!1,_=V.current,M={threadId:q,checkpointId:_.id??void 0,checkpointNs:_.namespace??void 0,command:{kind:"resume",value:Y}};z(M)},[f,z]);w.useEffect(()=>{N(U)},[U,N]);const j=w.useCallback(async()=>{l(),k(),m(null);try{await t.getAgent("default")}catch(O){console.warn("[StreamingProvider] Failed to refetch agent after clearing thread:",O)}},[t,k,m,l]);w.useEffect(()=>{E(j)},[j,E]);const W=w.useCallback(async(O,P)=>{let I=f.current;const q=(O==null?void 0:O.text)??"",Y=(O==null?void 0:O.attachments)??[],_=(q==null?void 0:q.trim())??"",M={...(O==null?void 0:O.payload)??{}},G=Array.isArray(M.messages)?M.messages:void 0;G&&delete M.messages;const J=!!(G&&G.length);if(!I&&!_&&Y.length===0&&!J)return;if(!I){const Pe=Math.floor(Date.now()/1e3).toString(16).padStart(8,"0"),De=Array.from({length:4},()=>Math.floor(Math.random()*4294967295).toString(16).padStart(8,"0")).join("").slice(0,16);I=`${Pe}${De}`,b(I),m(I)}const{contentParts:oe,filesInfo:K}=await ru(Y),D=[...oe];_&&D.push({type:"text",text:q});const X=P==null?void 0:P.originalMessageId,Z=!!(P!=null&&P.edit&&X),ue=!J&&D.length>0;let F=null;ue&&(F={id:Z?X:`msg-${Date.now()}`,role:"user",content:D,createdAt:new Date().toISOString()},Z?C(F,X):C(F));const ne=J?G:F?[F]:[],de={...M,...K.length?{files_info:K}:{}};ne.length?de.messages=ne:"messages"in de||(de.messages=[]);let ce=(P==null?void 0:P.checkpointId)??g.id??void 0,ge=(P==null?void 0:P.checkpointNs)??g.namespace??void 0;if(Z&&X){const Pe=fw(x,X);ce=Pe.checkpointId,ge=Pe.checkpointNs??void 0}const Ce={threadId:I,payload:de,checkpointId:ce,checkpointNs:ge,edit:!!(P!=null&&P.edit)};z(Ce)},[g,f,b,C,z,x]),$=w.useMemo(()=>({isStreaming:c,error:d,connectionState:c?"connected":"idle",submit:W,send:W,stop:l,setAuthToken:h}),[c,d,W,l,h]);return u.jsx(Eu.Provider,{value:$,children:e})}function Li(){const e=w.useContext(Eu);if(!e)throw new Error("useStream must be used within StreamingProvider");return e}function mw(){return w.useContext(Iu)}function Nu(e){return typeof e=="object"&&e!==null}function gw(e,t){if(Object.is(e,t))return!0;if(!Nu(e)||!Nu(t))return!1;const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const o of n)if(!Object.prototype.hasOwnProperty.call(t,o)||!Object.is(e[o],t[o]))return!1;return!0}function Au(e){const t=w.useRef(e),n=w.useRef(e);return gw(t.current,e)||(t.current=e,n.current=e),n.current}function vr({children:e,apiConfig:t,initialThreadId:n=null,initialCheckpointId:r=null,initialCheckpointNs:o=null,autoLoadInitial:s=!0,onConnectionError:i,onError:a,onAuthError:l,onThreadChange:c,onToolEnd:d}){const h=Au(t),m=to(a),f=to(l),v=to(i),g=to(c),x=to(d),y=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(tu,{apiConfig:h,children:u.jsx(hw,{...y,children:e})})}function to(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 wr(e){if(!(typeof globalThis>"u"))return globalThis[e]}function xw(e){if(typeof e!="string")return;const t=e.trim();if(t)return vn(t)}function ju(){const e=[wr("__API_BASE_URL__"),wr("__CHAT_API_BASE_URL__"),wr("__CHAT_API_URL__")];for(const t of e){const n=xw(t);if(n)return n}}function _u(){const e=[wr("__API_AUTH_TOKEN__"),wr("__CHAT_API_KEY__"),wr("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function Pu(...e){for(const t of e)if(typeof t=="string"&&t.trim())return vn(t);return vn()}function Mu(){const e={},t=ju(),n=_u();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function Ru(){const e=Mu(),t=Rn.getAuthToken(),n=ju();return{apiBaseUrl:Pu(e.baseUrl,Rn.baseUrl,n),apiKey:t||e.apiKey||_u()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,darkMode:!1,enableSound:!1,messageHistory:100}}const $i="chat-settings";function Ou(){try{const e=localStorage.getItem($i);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function Du(e){try{const t={...e,apiBaseUrl:vn(e.apiBaseUrl)};localStorage.setItem($i,JSON.stringify(t)),t.apiKey&&Rn.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function vw(){const e=Ru(),t=Ou(),n=Rn.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:Pu(Rn.baseUrl,r,e.apiBaseUrl)}}function ww(e){Rn.updateConfig({baseUrl:e.apiBaseUrl,authToken:e.apiKey??void 0}),Du(e)}function te(...e){return nx.twMerge(tx.clsx(e))}const bw=zr.cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),tt=p.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},s)=>{const i=r?Yt.Slot:"button";return u.jsx(i,{className:te(bw({variant:t,size:n,className:e})),ref:s,...o})});tt.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 Lu(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function On(...e){return t=>{let n=!1;const r=e.map(o=>{const s=Lu(o,t);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let o=0;o<r.length;o++){const s=r[o];typeof s=="function"?s():Lu(e[o],null)}}}}function $e(...e){return p.useCallback(On(...e),e)}function yw(e,t){const n=p.createContext(t),r=s=>{const{children:i,...a}=s,l=p.useMemo(()=>a,Object.values(a));return u.jsx(n.Provider,{value:l,children:i})};r.displayName=e+"Provider";function o(s){const i=p.useContext(n);if(i)return i;if(t!==void 0)return t;throw new Error(`\`${s}\` must be used within \`${e}\``)}return[r,o]}function cn(e,t=[]){let n=[];function r(s,i){const a=p.createContext(i),l=n.length;n=[...n,i];const c=h=>{var y;const{scope:m,children:f,...v}=h,g=((y=m==null?void 0:m[e])==null?void 0:y[l])||a,x=p.useMemo(()=>v,Object.values(v));return u.jsx(g.Provider,{value:x,children:f})};c.displayName=s+"Provider";function d(h,m){var g;const f=((g=m==null?void 0:m[e])==null?void 0:g[l])||a,v=p.useContext(f);if(v)return v;if(i!==void 0)return i;throw new Error(`\`${h}\` must be used within \`${s}\``)}return[c,d]}const o=()=>{const s=n.map(i=>p.createContext(i));return function(a){const l=(a==null?void 0:a[e])||s;return p.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return o.scopeName=e,[r,Sw(o,...t)]}function Sw(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(s){const i=r.reduce((a,{useScope:l,scopeName:c})=>{const h=l(s)[`__scope${c}`];return{...a,...h}},{});return p.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var It=globalThis!=null&&globalThis.document?p.useLayoutEffect:()=>{},Cw=p[" useInsertionEffect ".trim().toString()]||It;function Dn({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,s,i]=Tw({defaultProp:t,onChange:n}),a=e!==void 0,l=a?e:o;{const d=p.useRef(e!==void 0);p.useEffect(()=>{const h=d.current;h!==a&&console.warn(`${r} is changing from ${h?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),d.current=a},[a,r])}const c=p.useCallback(d=>{var h;if(a){const m=kw(d)?d(e):d;m!==e&&((h=i.current)==null||h.call(i,m))}else s(d)},[a,e,s,i]);return[l,c]}function Tw({defaultProp:e,onChange:t}){const[n,r]=p.useState(e),o=p.useRef(n),s=p.useRef(t);return Cw(()=>{s.current=t},[t]),p.useEffect(()=>{var i;o.current!==n&&((i=s.current)==null||i.call(s,n),o.current=n)},[n,o]),[n,r,s]}function kw(e){return typeof e=="function"}var Ew=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],ve=Ew.reduce((e,t)=>{const n=Yt.createSlot(`Primitive.${t}`),r=p.forwardRef((o,s)=>{const{asChild:i,...a}=o,l=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),u.jsx(l,{...a,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Fi(e,t){e&&Hr.flushSync(()=>e.dispatchEvent(t))}function Yo(e){const t=e+"CollectionProvider",[n,r]=cn(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=g=>{const{scope:x,children:y}=g,b=w.useRef(null),S=w.useRef(new Map).current;return u.jsx(o,{scope:x,itemMap:S,collectionRef:b,children:y})};i.displayName=t;const a=e+"CollectionSlot",l=Yt.createSlot(a),c=w.forwardRef((g,x)=>{const{scope:y,children:b}=g,S=s(a,y),k=$e(x,S.collectionRef);return u.jsx(l,{ref:k,children:b})});c.displayName=a;const d=e+"CollectionItemSlot",h="data-radix-collection-item",m=Yt.createSlot(d),f=w.forwardRef((g,x)=>{const{scope:y,children:b,...S}=g,k=w.useRef(null),C=$e(x,k),T=s(d,y);return w.useEffect(()=>(T.itemMap.set(k,{ref:k,...S}),()=>void T.itemMap.delete(k))),u.jsx(m,{[h]:"",ref:C,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 S=Array.from(b.querySelectorAll(`[${h}]`));return Array.from(x.itemMap.values()).sort((T,E)=>S.indexOf(T.ref.current)-S.indexOf(E.ref.current))},[x.collectionRef,x.itemMap])}return[{Provider:i,Slot:c,ItemSlot:f},v,r]}var Iw=p.createContext(void 0);function Xo(e){const t=p.useContext(Iw);return e||t||"ltr"}function xt(e){const t=p.useRef(e);return p.useEffect(()=>{t.current=e}),p.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function Nw(e,t=globalThis==null?void 0:globalThis.document){const n=xt(e);p.useEffect(()=>{const r=o=>{o.key==="Escape"&&n(o)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var Aw="DismissableLayer",Bi="dismissableLayer.update",jw="dismissableLayer.pointerDownOutside",_w="dismissableLayer.focusOutside",$u,Fu=p.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),br=p.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...l}=e,c=p.useContext(Fu),[d,h]=p.useState(null),m=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,f]=p.useState({}),v=$e(t,E=>h(E)),g=Array.from(c.layers),[x]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),y=g.indexOf(x),b=d?g.indexOf(d):-1,S=c.layersWithOutsidePointerEventsDisabled.size>0,k=b>=y,C=Mw(E=>{const N=E.target,R=[...c.branches].some(L=>L.contains(N));!k||R||(o==null||o(E),i==null||i(E),E.defaultPrevented||a==null||a())},m),T=Rw(E=>{const N=E.target;[...c.branches].some(L=>L.contains(N))||(s==null||s(E),i==null||i(E),E.defaultPrevented||a==null||a())},m);return Nw(E=>{b===c.layers.size-1&&(r==null||r(E),!E.defaultPrevented&&a&&(E.preventDefault(),a()))},m),p.useEffect(()=>{if(d)return n&&(c.layersWithOutsidePointerEventsDisabled.size===0&&($u=m.body.style.pointerEvents,m.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(d)),c.layers.add(d),zu(),()=>{n&&c.layersWithOutsidePointerEventsDisabled.size===1&&(m.body.style.pointerEvents=$u)}},[d,m,n,c]),p.useEffect(()=>()=>{d&&(c.layers.delete(d),c.layersWithOutsidePointerEventsDisabled.delete(d),zu())},[d,c]),p.useEffect(()=>{const E=()=>f({});return document.addEventListener(Bi,E),()=>document.removeEventListener(Bi,E)},[]),u.jsx(ve.div,{...l,ref:v,style:{pointerEvents:S?k?"auto":"none":void 0,...e.style},onFocusCapture:ae(e.onFocusCapture,T.onFocusCapture),onBlurCapture:ae(e.onBlurCapture,T.onBlurCapture),onPointerDownCapture:ae(e.onPointerDownCapture,C.onPointerDownCapture)})});br.displayName=Aw;var Pw="DismissableLayerBranch",Bu=p.forwardRef((e,t)=>{const n=p.useContext(Fu),r=p.useRef(null),o=$e(t,r);return p.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),u.jsx(ve.div,{...e,ref:o})});Bu.displayName=Pw;function Mw(e,t=globalThis==null?void 0:globalThis.document){const n=xt(e),r=p.useRef(!1),o=p.useRef(()=>{});return p.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){Hu(jw,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 Rw(e,t=globalThis==null?void 0:globalThis.document){const n=xt(e),r=p.useRef(!1);return p.useEffect(()=>{const o=s=>{s.target&&!r.current&&Hu(_w,n,{originalEvent:s},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function zu(){const e=new CustomEvent(Bi);document.dispatchEvent(e)}function Hu(e,t,n,{discrete:r}){const o=n.originalEvent.target,s=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?Fi(o,s):o.dispatchEvent(s)}var Ow=br,Dw=Bu,zi=0;function Hi(){p.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Uu()),document.body.insertAdjacentElement("beforeend",e[1]??Uu()),zi++,()=>{zi===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),zi--}},[])}function Uu(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var Ui="focusScope.autoFocusOnMount",Wi="focusScope.autoFocusOnUnmount",Wu={bubbles:!1,cancelable:!0},Lw="FocusScope",Jo=p.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=e,[a,l]=p.useState(null),c=xt(o),d=xt(s),h=p.useRef(null),m=$e(t,g=>l(g)),f=p.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;p.useEffect(()=>{if(r){let g=function(S){if(f.paused||!a)return;const k=S.target;a.contains(k)?h.current=k:Ln(h.current,{select:!0})},x=function(S){if(f.paused||!a)return;const k=S.relatedTarget;k!==null&&(a.contains(k)||Ln(h.current,{select:!0}))},y=function(S){if(document.activeElement===document.body)for(const C of S)C.removedNodes.length>0&&Ln(a)};document.addEventListener("focusin",g),document.addEventListener("focusout",x);const 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]),p.useEffect(()=>{if(a){qu.add(f);const g=document.activeElement;if(!a.contains(g)){const y=new CustomEvent(Ui,Wu);a.addEventListener(Ui,c),a.dispatchEvent(y),y.defaultPrevented||($w(Uw(Vu(a)),{select:!0}),document.activeElement===g&&Ln(a))}return()=>{a.removeEventListener(Ui,c),setTimeout(()=>{const y=new CustomEvent(Wi,Wu);a.addEventListener(Wi,d),a.dispatchEvent(y),y.defaultPrevented||Ln(g??document.body,{select:!0}),a.removeEventListener(Wi,d),qu.remove(f)},0)}}},[a,c,d,f]);const v=p.useCallback(g=>{if(!n&&!r||f.paused)return;const x=g.key==="Tab"&&!g.altKey&&!g.ctrlKey&&!g.metaKey,y=document.activeElement;if(x&&y){const b=g.currentTarget,[S,k]=Fw(b);S&&k?!g.shiftKey&&y===k?(g.preventDefault(),n&&Ln(S,{select:!0})):g.shiftKey&&y===S&&(g.preventDefault(),n&&Ln(k,{select:!0})):y===b&&g.preventDefault()}},[n,r,f.paused]);return u.jsx(ve.div,{tabIndex:-1,...i,ref:m,onKeyDown:v})});Jo.displayName=Lw;function $w(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Ln(r,{select:t}),document.activeElement!==n)return}function Fw(e){const t=Vu(e),n=Ku(t,e),r=Ku(t.reverse(),e);return[n,r]}function Vu(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function Ku(e,t){for(const n of e)if(!Bw(n,{upTo:t}))return n}function Bw(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 Ln(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&zw(e)&&t&&e.select()}}var qu=Hw();function Hw(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=Gu(e,t),e.unshift(t)},remove(t){var n;e=Gu(e,t),(n=e[0])==null||n.resume()}}}function Gu(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Uw(e){return e.filter(t=>t.tagName!=="A")}var Ww=p[" useId ".trim().toString()]||(()=>{}),Vw=0;function Pt(e){const[t,n]=p.useState(Ww());return It(()=>{n(r=>r??String(Vw++))},[e]),t?`radix-${t}`:""}const Kw=["top","right","bottom","left"],$n=Math.min,Zt=Math.max,Zo=Math.round,Qo=Math.floor,wn=e=>({x:e,y:e}),qw={left:"right",right:"left",bottom:"top",top:"bottom"},Gw={start:"end",end:"start"};function Vi(e,t,n){return Zt(e,$n(t,n))}function Nn(e,t){return typeof e=="function"?e(t):e}function An(e){return e.split("-")[0]}function yr(e){return e.split("-")[1]}function Ki(e){return e==="x"?"y":"x"}function qi(e){return e==="y"?"height":"width"}const Yw=new Set(["top","bottom"]);function bn(e){return Yw.has(An(e))?"y":"x"}function Gi(e){return Ki(bn(e))}function Xw(e,t,n){n===void 0&&(n=!1);const r=yr(e),o=Gi(e),s=qi(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=es(i)),[i,es(i)]}function Jw(e){const t=es(e);return[Yi(e),t,Yi(t)]}function Yi(e){return e.replace(/start|end/g,t=>Gw[t])}const Yu=["left","right"],Xu=["right","left"],Zw=["top","bottom"],Qw=["bottom","top"];function eb(e,t,n){switch(e){case"top":case"bottom":return n?t?Xu:Yu:t?Yu:Xu;case"left":case"right":return t?Zw:Qw;default:return[]}}function tb(e,t,n,r){const o=yr(e);let s=eb(An(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(Yi)))),s}function es(e){return e.replace(/left|right|bottom|top/g,t=>qw[t])}function nb(e){return{top:0,right:0,bottom:0,left:0,...e}}function Ju(e){return typeof e!="number"?nb(e):{top:e,right:e,bottom:e,left:e}}function ts(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}function Zu(e,t,n){let{reference:r,floating:o}=e;const s=bn(t),i=Gi(t),a=qi(i),l=An(t),c=s==="y",d=r.x+r.width/2-o.width/2,h=r.y+r.height/2-o.height/2,m=r[a]/2-o[a]/2;let f;switch(l){case"top":f={x:d,y:r.y-o.height};break;case"bottom":f={x:d,y:r.y+r.height};break;case"right":f={x:r.x+r.width,y:h};break;case"left":f={x:r.x-o.width,y:h};break;default:f={x:r.x,y:r.y}}switch(yr(t)){case"start":f[i]-=m*(n&&c?-1:1);break;case"end":f[i]+=m*(n&&c?-1:1);break}return f}const rb=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=n,a=s.filter(Boolean),l=await(i.isRTL==null?void 0:i.isRTL(t));let c=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:d,y:h}=Zu(c,r,l),m=r,f={},v=0;for(let g=0;g<a.length;g++){const{name:x,fn:y}=a[g],{x:b,y:S,data:k,reset:C}=await y({x:d,y:h,initialPlacement:r,placement:m,strategy:o,middlewareData:f,rects:c,platform:i,elements:{reference:e,floating:t}});d=b??d,h=S??h,f={...f,[x]:{...f[x],...k}},C&&v<=50&&(v++,typeof C=="object"&&(C.placement&&(m=C.placement),C.rects&&(c=C.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):C.rects),{x:d,y:h}=Zu(c,m,l)),g=-1)}return{x:d,y:h,placement:m,strategy:o,middlewareData:f}};async function no(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:i,elements:a,strategy:l}=e,{boundary:c="clippingAncestors",rootBoundary:d="viewport",elementContext:h="floating",altBoundary:m=!1,padding:f=0}=Nn(t,e),v=Ju(f),x=a[m?h==="floating"?"reference":"floating":h],y=ts(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(x)))==null||n?x:x.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:c,rootBoundary:d,strategy:l})),b=h==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,S=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),k=await(s.isElement==null?void 0:s.isElement(S))?await(s.getScale==null?void 0:s.getScale(S))||{x:1,y:1}:{x:1,y:1},C=ts(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:b,offsetParent:S,strategy:l}):b);return{top:(y.top-C.top+v.top)/k.y,bottom:(C.bottom-y.bottom+v.bottom)/k.y,left:(y.left-C.left+v.left)/k.x,right:(C.right-y.right+v.right)/k.x}}const ob=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:s,platform:i,elements:a,middlewareData:l}=t,{element:c,padding:d=0}=Nn(e,t)||{};if(c==null)return{};const h=Ju(d),m={x:n,y:r},f=Gi(o),v=qi(f),g=await i.getDimensions(c),x=f==="y",y=x?"top":"left",b=x?"bottom":"right",S=x?"clientHeight":"clientWidth",k=s.reference[v]+s.reference[f]-m[f]-s.floating[v],C=m[f]-s.reference[f],T=await(i.getOffsetParent==null?void 0:i.getOffsetParent(c));let E=T?T[S]:0;(!E||!await(i.isElement==null?void 0:i.isElement(T)))&&(E=a.floating[S]||s.floating[v]);const N=k/2-C/2,R=E/2-g[v]/2-1,L=$n(h[y],R),z=$n(h[b],R),V=L,U=E-g[v]-z,j=E/2-g[v]/2+N,W=Vi(V,j,U),$=!l.arrow&&yr(o)!=null&&j!==W&&s.reference[v]/2-(j<V?L:z)-g[v]/2<0,O=$?j<V?j-V:j-U:0;return{[f]:m[f]+O,data:{[f]:W,centerOffset:j-W-O,...$&&{alignmentOffset:O}},reset:$}}}),sb=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:s,rects:i,initialPlacement:a,platform:l,elements:c}=t,{mainAxis:d=!0,crossAxis:h=!0,fallbackPlacements:m,fallbackStrategy:f="bestFit",fallbackAxisSideDirection:v="none",flipAlignment:g=!0,...x}=Nn(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const y=An(o),b=bn(a),S=An(a)===a,k=await(l.isRTL==null?void 0:l.isRTL(c.floating)),C=m||(S||!g?[es(a)]:Jw(a)),T=v!=="none";!m&&T&&C.push(...tb(a,g,v,k));const E=[a,...C],N=await no(t,x),R=[];let L=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&R.push(N[y]),h){const j=Xw(o,i,k);R.push(N[j[0]],N[j[1]])}if(L=[...L,{placement:o,overflows:R}],!R.every(j=>j<=0)){var z,V;const j=(((z=s.flip)==null?void 0:z.index)||0)+1,W=E[j];if(W&&(!(h==="alignment"?b!==bn(W):!1)||L.every(P=>bn(P.placement)===b?P.overflows[0]>0:!0)))return{data:{index:j,overflows:L},reset:{placement:W}};let $=(V=L.filter(O=>O.overflows[0]<=0).sort((O,P)=>O.overflows[1]-P.overflows[1])[0])==null?void 0:V.placement;if(!$)switch(f){case"bestFit":{var U;const O=(U=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,q)=>I+q,0)]).sort((P,I)=>P[1]-I[1])[0])==null?void 0:U[0];O&&($=O);break}case"initialPlacement":$=a;break}if(o!==$)return{reset:{placement:$}}}return{}}}};function Qu(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function ed(e){return Kw.some(t=>e[t]>=0)}const ib=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=Nn(e,t);switch(r){case"referenceHidden":{const s=await no(t,{...o,elementContext:"reference"}),i=Qu(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:ed(i)}}}case"escaped":{const s=await no(t,{...o,altBoundary:!0}),i=Qu(s,n.floating);return{data:{escapedOffsets:i,escaped:ed(i)}}}default:return{}}}}},td=new Set(["left","top"]);async function ab(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=An(n),a=yr(n),l=bn(n)==="y",c=td.has(i)?-1:1,d=s&&l?-1:1,h=Nn(t,e);let{mainAxis:m,crossAxis:f,alignmentAxis:v}=typeof h=="number"?{mainAxis:h,crossAxis:0,alignmentAxis:null}:{mainAxis:h.mainAxis||0,crossAxis:h.crossAxis||0,alignmentAxis:h.alignmentAxis};return a&&typeof v=="number"&&(f=a==="end"?v*-1:v),l?{x:f*d,y:m*c}:{x:m*c,y:f*d}}const lb=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 ab(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}}}}},cb=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}=Nn(e,t),c={x:n,y:r},d=await no(t,l),h=bn(An(o)),m=Ki(h);let f=c[m],v=c[h];if(s){const x=m==="y"?"top":"left",y=m==="y"?"bottom":"right",b=f+d[x],S=f-d[y];f=Vi(b,f,S)}if(i){const x=h==="y"?"top":"left",y=h==="y"?"bottom":"right",b=v+d[x],S=v-d[y];v=Vi(b,v,S)}const g=a.fn({...t,[m]:f,[h]:v});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[m]:s,[h]:i}}}}}},ub=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:s,middlewareData:i}=t,{offset:a=0,mainAxis:l=!0,crossAxis:c=!0}=Nn(e,t),d={x:n,y:r},h=bn(o),m=Ki(h);let f=d[m],v=d[h];const g=Nn(a,t),x=typeof g=="number"?{mainAxis:g,crossAxis:0}:{mainAxis:0,crossAxis:0,...g};if(l){const S=m==="y"?"height":"width",k=s.reference[m]-s.floating[S]+x.mainAxis,C=s.reference[m]+s.reference[S]-x.mainAxis;f<k?f=k:f>C&&(f=C)}if(c){var y,b;const S=m==="y"?"width":"height",k=td.has(An(o)),C=s.reference[h]-s.floating[S]+(k&&((y=i.offset)==null?void 0:y[h])||0)+(k?0:x.crossAxis),T=s.reference[h]+s.reference[S]+(k?0:((b=i.offset)==null?void 0:b[h])||0)-(k?x.crossAxis:0);v<C?v=C:v>T&&(v=T)}return{[m]:f,[h]:v}}}},db=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:s,platform:i,elements:a}=t,{apply:l=()=>{},...c}=Nn(e,t),d=await no(t,c),h=An(o),m=yr(o),f=bn(o)==="y",{width:v,height:g}=s.floating;let x,y;h==="top"||h==="bottom"?(x=h,y=m===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(y=h,x=m==="end"?"top":"bottom");const b=g-d.top-d.bottom,S=v-d.left-d.right,k=$n(g-d[x],b),C=$n(v-d[y],S),T=!t.middlewareData.shift;let E=k,N=C;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(N=S),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(E=b),T&&!m){const L=Zt(d.left,0),z=Zt(d.right,0),V=Zt(d.top,0),U=Zt(d.bottom,0);f?N=v-2*(L!==0||z!==0?L+z:Zt(d.left,d.right)):E=g-2*(V!==0||U!==0?V+U:Zt(d.top,d.bottom))}await l({...t,availableWidth:N,availableHeight:E});const R=await i.getDimensions(a.floating);return v!==R.width||g!==R.height?{reset:{rects:!0}}:{}}}};function ns(){return typeof window<"u"}function Sr(e){return nd(e)?(e.nodeName||"").toLowerCase():"#document"}function Qt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function yn(e){var t;return(t=(nd(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function nd(e){return ns()?e instanceof Node||e instanceof Qt(e).Node:!1}function un(e){return ns()?e instanceof Element||e instanceof Qt(e).Element:!1}function Sn(e){return ns()?e instanceof HTMLElement||e instanceof Qt(e).HTMLElement:!1}function rd(e){return!ns()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Qt(e).ShadowRoot}const fb=new Set(["inline","contents"]);function ro(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=dn(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!fb.has(o)}const hb=new Set(["table","td","th"]);function pb(e){return hb.has(Sr(e))}const mb=[":popover-open",":modal"];function rs(e){return mb.some(t=>{try{return e.matches(t)}catch{return!1}})}const gb=["transform","translate","scale","rotate","perspective"],xb=["transform","translate","scale","rotate","perspective","filter"],vb=["paint","layout","strict","content"];function Xi(e){const t=Ji(),n=un(e)?dn(e):e;return gb.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)||xb.some(r=>(n.willChange||"").includes(r))||vb.some(r=>(n.contain||"").includes(r))}function wb(e){let t=Fn(e);for(;Sn(t)&&!Cr(t);){if(Xi(t))return t;if(rs(t))return null;t=Fn(t)}return null}function Ji(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const bb=new Set(["html","body","#document"]);function Cr(e){return bb.has(Sr(e))}function dn(e){return Qt(e).getComputedStyle(e)}function os(e){return un(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Fn(e){if(Sr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||rd(e)&&e.host||yn(e);return rd(t)?t.host:t}function od(e){const t=Fn(e);return Cr(t)?e.ownerDocument?e.ownerDocument.body:e.body:Sn(t)&&ro(t)?t:od(t)}function oo(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=od(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Qt(o);if(s){const a=Zi(i);return t.concat(i,i.visualViewport||[],ro(o)?o:[],a&&n?oo(a):[])}return t.concat(o,oo(o,[],n))}function Zi(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function sd(e){const t=dn(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=Sn(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=Zo(n)!==s||Zo(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function Qi(e){return un(e)?e:e.contextElement}function Tr(e){const t=Qi(e);if(!Sn(t))return wn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=sd(t);let i=(s?Zo(n.width):n.width)/r,a=(s?Zo(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const yb=wn(0);function id(e){const t=Qt(e);return!Ji()||!t.visualViewport?yb:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Sb(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Qt(e)?!1:t}function Qn(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=Qi(e);let i=wn(1);t&&(r?un(r)&&(i=Tr(r)):i=Tr(e));const a=Sb(s,n,r)?id(s):wn(0);let l=(o.left+a.x)/i.x,c=(o.top+a.y)/i.y,d=o.width/i.x,h=o.height/i.y;if(s){const m=Qt(s),f=r&&un(r)?Qt(r):r;let v=m,g=Zi(v);for(;g&&r&&f!==v;){const x=Tr(g),y=g.getBoundingClientRect(),b=dn(g),S=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,h*=x.y,l+=S,c+=k,v=Qt(g),g=Zi(v)}}return ts({width:d,height:h,x:l,y:c})}function ss(e,t){const n=os(e).scrollLeft;return t?t.left+n:Qn(yn(e)).left+n}function ad(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-ss(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function Cb(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=yn(r),a=t?rs(t.floating):!1;if(r===i||a&&s)return n;let l={scrollLeft:0,scrollTop:0},c=wn(1);const d=wn(0),h=Sn(r);if((h||!h&&!s)&&((Sr(r)!=="body"||ro(i))&&(l=os(r)),Sn(r))){const f=Qn(r);c=Tr(r),d.x=f.x+r.clientLeft,d.y=f.y+r.clientTop}const m=i&&!h&&!s?ad(i,l):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 Tb(e){return Array.from(e.getClientRects())}function kb(e){const t=yn(e),n=os(e),r=e.ownerDocument.body,o=Zt(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Zt(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+ss(e);const a=-n.scrollTop;return dn(r).direction==="rtl"&&(i+=Zt(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const ld=25;function Eb(e,t){const n=Qt(e),r=yn(e),o=n.visualViewport;let s=r.clientWidth,i=r.clientHeight,a=0,l=0;if(o){s=o.width,i=o.height;const d=Ji();(!d||d&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}const c=ss(r);if(c<=0){const d=r.ownerDocument,h=d.body,m=getComputedStyle(h),f=d.compatMode==="CSS1Compat"&&parseFloat(m.marginLeft)+parseFloat(m.marginRight)||0,v=Math.abs(r.clientWidth-h.clientWidth-f);v<=ld&&(s-=v)}else c<=ld&&(s+=c);return{width:s,height:i,x:a,y:l}}const Ib=new Set(["absolute","fixed"]);function Nb(e,t){const n=Qn(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=Sn(e)?Tr(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 cd(e,t,n){let r;if(t==="viewport")r=Eb(e,n);else if(t==="document")r=kb(yn(e));else if(un(t))r=Nb(t,n);else{const o=id(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return ts(r)}function ud(e,t){const n=Fn(e);return n===t||!un(n)||Cr(n)?!1:dn(n).position==="fixed"||ud(n,t)}function Ab(e,t){const n=t.get(e);if(n)return n;let r=oo(e,[],!1).filter(a=>un(a)&&Sr(a)!=="body"),o=null;const s=dn(e).position==="fixed";let i=s?Fn(e):e;for(;un(i)&&!Cr(i);){const a=dn(i),l=Xi(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&Ib.has(o.position)||ro(i)&&!l&&ud(e,i))?r=r.filter(d=>d!==i):o=a,i=Fn(i)}return t.set(e,r),r}function jb(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?rs(t)?[]:Ab(t,this._c):[].concat(n),r],a=i[0],l=i.reduce((c,d)=>{const h=cd(t,d,o);return c.top=Zt(h.top,c.top),c.right=$n(h.right,c.right),c.bottom=$n(h.bottom,c.bottom),c.left=Zt(h.left,c.left),c},cd(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function _b(e){const{width:t,height:n}=sd(e);return{width:t,height:n}}function Pb(e,t,n){const r=Sn(t),o=yn(t),s=n==="fixed",i=Qn(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=wn(0);function c(){l.x=ss(o)}if(r||!r&&!s)if((Sr(t)!=="body"||ro(o))&&(a=os(t)),r){const f=Qn(t,!0,s,t);l.x=f.x+t.clientLeft,l.y=f.y+t.clientTop}else o&&c();s&&!r&&o&&c();const d=o&&!r&&!s?ad(o,a):wn(0),h=i.left+a.scrollLeft-l.x-d.x,m=i.top+a.scrollTop-l.y-d.y;return{x:h,y:m,width:i.width,height:i.height}}function ea(e){return dn(e).position==="static"}function dd(e,t){if(!Sn(e)||dn(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return yn(e)===n&&(n=n.ownerDocument.body),n}function fd(e,t){const n=Qt(e);if(rs(e))return n;if(!Sn(e)){let o=Fn(e);for(;o&&!Cr(o);){if(un(o)&&!ea(o))return o;o=Fn(o)}return n}let r=dd(e,t);for(;r&&pb(r)&&ea(r);)r=dd(r,t);return r&&Cr(r)&&ea(r)&&!Xi(r)?n:r||wb(e)||n}const Mb=async function(e){const t=this.getOffsetParent||fd,n=this.getDimensions,r=await n(e.floating);return{reference:Pb(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Rb(e){return dn(e).direction==="rtl"}const Ob={convertOffsetParentRelativeRectToViewportRelativeRect:Cb,getDocumentElement:yn,getClippingRect:jb,getOffsetParent:fd,getElementRects:Mb,getClientRects:Tb,getDimensions:_b,getScale:Tr,isElement:un,isRTL:Rb};function hd(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Db(e,t){let n=null,r;const o=yn(e);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),s();const c=e.getBoundingClientRect(),{left:d,top:h,width:m,height:f}=c;if(a||t(),!m||!f)return;const v=Qo(h),g=Qo(o.clientWidth-(d+m)),x=Qo(o.clientHeight-(h+f)),y=Qo(d),S={rootMargin:-v+"px "+-g+"px "+-x+"px "+-y+"px",threshold:Zt(0,$n(1,l))||1};let k=!0;function C(T){const E=T[0].intersectionRatio;if(E!==l){if(!k)return i();E?i(!1,E):r=setTimeout(()=>{i(!1,1e-7)},1e3)}E===1&&!hd(c,e.getBoundingClientRect())&&i(),k=!1}try{n=new IntersectionObserver(C,{...S,root:o.ownerDocument})}catch{n=new IntersectionObserver(C,S)}n.observe(e)}return i(!0),s}function Lb(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,c=Qi(e),d=o||s?[...c?oo(c):[],...oo(t)]:[];d.forEach(y=>{o&&y.addEventListener("scroll",n,{passive:!0}),s&&y.addEventListener("resize",n)});const h=c&&a?Db(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 S;(S=f)==null||S.observe(t)})),n()}),c&&!l&&f.observe(c),f.observe(t));let v,g=l?Qn(e):null;l&&x();function x(){const y=Qn(e);g&&!hd(g,y)&&n(),g=y,v=requestAnimationFrame(x)}return n(),()=>{var y;d.forEach(b=>{o&&b.removeEventListener("scroll",n),s&&b.removeEventListener("resize",n)}),h==null||h(),(y=f)==null||y.disconnect(),f=null,l&&cancelAnimationFrame(v)}}const $b=lb,Fb=cb,Bb=sb,zb=db,Hb=ib,pd=ob,Ub=ub,Wb=(e,t,n)=>{const r=new Map,o={platform:Ob,...n},s={...o.platform,_c:r};return rb(e,t,{...o,platform:s})};var Vb=typeof document<"u",Kb=function(){},is=Vb?w.useLayoutEffect:Kb;function as(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!as(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){const s=o[r];if(!(s==="_owner"&&e.$$typeof)&&!as(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function md(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function gd(e,t){const n=md(e);return Math.round(t*n)/n}function ta(e){const t=p.useRef(e);return is(()=>{t.current=e}),t}function qb(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:i}={},transform:a=!0,whileElementsMounted:l,open:c}=e,[d,h]=p.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[m,f]=p.useState(r);as(m,r)||f(r);const[v,g]=p.useState(null),[x,y]=p.useState(null),b=p.useCallback(P=>{P!==T.current&&(T.current=P,g(P))},[]),S=p.useCallback(P=>{P!==E.current&&(E.current=P,y(P))},[]),k=s||v,C=i||x,T=p.useRef(null),E=p.useRef(null),N=p.useRef(d),R=l!=null,L=ta(l),z=ta(o),V=ta(c),U=p.useCallback(()=>{if(!T.current||!E.current)return;const P={placement:t,strategy:n,middleware:m};z.current&&(P.platform=z.current),Wb(T.current,E.current,P).then(I=>{const q={...I,isPositioned:V.current!==!1};j.current&&!as(N.current,q)&&(N.current=q,Hr.flushSync(()=>{h(q)}))})},[m,t,n,z,V]);is(()=>{c===!1&&N.current.isPositioned&&(N.current.isPositioned=!1,h(P=>({...P,isPositioned:!1})))},[c]);const j=p.useRef(!1);is(()=>(j.current=!0,()=>{j.current=!1}),[]),is(()=>{if(k&&(T.current=k),C&&(E.current=C),k&&C){if(L.current)return L.current(k,C,U);U()}},[k,C,U,L,R]);const W=p.useMemo(()=>({reference:T,floating:E,setReference:b,setFloating:S}),[b,S]),$=p.useMemo(()=>({reference:k,floating:C}),[k,C]),O=p.useMemo(()=>{const P={position:n,left:0,top:0};if(!$.floating)return P;const I=gd($.floating,d.x),q=gd($.floating,d.y);return a?{...P,transform:"translate("+I+"px, "+q+"px)",...md($.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:I,top:q}},[n,a,$.floating,d.x,d.y]);return p.useMemo(()=>({...d,update:U,refs:W,elements:$,floatingStyles:O}),[d,U,W,$,O])}const Gb=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:o}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?pd({element:r.current,padding:o}).fn(n):{}:r?pd({element:r,padding:o}).fn(n):{}}}},Yb=(e,t)=>({...$b(e),options:[e,t]}),Xb=(e,t)=>({...Fb(e),options:[e,t]}),Jb=(e,t)=>({...Ub(e),options:[e,t]}),Zb=(e,t)=>({...Bb(e),options:[e,t]}),Qb=(e,t)=>({...zb(e),options:[e,t]}),ey=(e,t)=>({...Hb(e),options:[e,t]}),ty=(e,t)=>({...Gb(e),options:[e,t]});var ny="Arrow",xd=p.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return u.jsx(ve.svg,{...s,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:u.jsx("polygon",{points:"0,0 30,0 15,10"})})});xd.displayName=ny;var ry=xd;function vd(e){const[t,n]=p.useState(void 0);return It(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const s=o[0];let i,a;if("borderBoxSize"in s){const l=s.borderBoxSize,c=Array.isArray(l)?l[0]:l;i=c.inlineSize,a=c.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var na="Popper",[wd,kr]=cn(na),[oy,bd]=wd(na),yd=e=>{const{__scopePopper:t,children:n}=e,[r,o]=p.useState(null);return u.jsx(oy,{scope:t,anchor:r,onAnchorChange:o,children:n})};yd.displayName=na;var Sd="PopperAnchor",Cd=p.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=bd(Sd,n),i=p.useRef(null),a=$e(t,i),l=p.useRef(null);return p.useEffect(()=>{const c=l.current;l.current=(r==null?void 0:r.current)||i.current,c!==l.current&&s.onAnchorChange(l.current)}),r?null:u.jsx(ve.div,{...o,ref:a})});Cd.displayName=Sd;var ra="PopperContent",[sy,iy]=wd(ra),Td=p.forwardRef((e,t)=>{var K,D,X,Z,ue,F;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:a=0,avoidCollisions:l=!0,collisionBoundary:c=[],collisionPadding:d=0,sticky:h="partial",hideWhenDetached:m=!1,updatePositionStrategy:f="optimized",onPlaced:v,...g}=e,x=bd(ra,n),[y,b]=p.useState(null),S=$e(t,ne=>b(ne)),[k,C]=p.useState(null),T=vd(k),E=(T==null?void 0:T.width)??0,N=(T==null?void 0:T.height)??0,R=r+(s!=="center"?"-"+s:""),L=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},z=Array.isArray(c)?c:[c],V=z.length>0,U={padding:L,boundary:z.filter(ly),altBoundary:V},{refs:j,floatingStyles:W,placement:$,isPositioned:O,middlewareData:P}=qb({strategy:"fixed",placement:R,whileElementsMounted:(...ne)=>Lb(...ne,{animationFrame:f==="always"}),elements:{reference:x.anchor},middleware:[Yb({mainAxis:o+N,alignmentAxis:i}),l&&Xb({mainAxis:!0,crossAxis:!1,limiter:h==="partial"?Jb():void 0,...U}),l&&Zb({...U}),Qb({...U,apply:({elements:ne,rects:de,availableWidth:ce,availableHeight:ge})=>{const{width:Ce,height:Pe}=de.reference,De=ne.floating.style;De.setProperty("--radix-popper-available-width",`${ce}px`),De.setProperty("--radix-popper-available-height",`${ge}px`),De.setProperty("--radix-popper-anchor-width",`${Ce}px`),De.setProperty("--radix-popper-anchor-height",`${Pe}px`)}}),k&&ty({element:k,padding:a}),cy({arrowWidth:E,arrowHeight:N}),m&&ey({strategy:"referenceHidden",...U})]}),[I,q]=Id($),Y=xt(v);It(()=>{O&&(Y==null||Y())},[O,Y]);const _=(K=P.arrow)==null?void 0:K.x,M=(D=P.arrow)==null?void 0:D.y,G=((X=P.arrow)==null?void 0:X.centerOffset)!==0,[J,oe]=p.useState();return It(()=>{y&&oe(window.getComputedStyle(y).zIndex)},[y]),u.jsx("div",{ref:j.setFloating,"data-radix-popper-content-wrapper":"",style:{...W,transform:O?W.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:J,"--radix-popper-transform-origin":[(Z=P.transformOrigin)==null?void 0:Z.x,(ue=P.transformOrigin)==null?void 0:ue.y].join(" "),...((F=P.hide)==null?void 0:F.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:u.jsx(sy,{scope:n,placedSide:I,onArrowChange:C,arrowX:_,arrowY:M,shouldHideArrow:G,children:u.jsx(ve.div,{"data-side":I,"data-align":q,...g,ref:S,style:{...g.style,animation:O?void 0:"none"}})})})});Td.displayName=ra;var kd="PopperArrow",ay={top:"bottom",right:"left",bottom:"top",left:"right"},Ed=p.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=iy(kd,r),i=ay[s.placedSide];return u.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:u.jsx(ry,{...o,ref:n,style:{...o.style,display:"block"}})})});Ed.displayName=kd;function ly(e){return e!==null}var cy=e=>({name:"transformOrigin",options:e,fn(t){var x,y,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]=Id(n),h={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?h:`${m}px`,g=`${-l}px`):c==="top"?(v=i?h:`${m}px`,g=`${r.floating.height+l}px`):c==="right"?(v=`${-l}px`,g=i?h:`${f}px`):c==="left"&&(v=`${r.floating.width+l}px`,g=i?h:`${f}px`),{data:{x:v,y:g}}}});function Id(e){const[t,n="center"]=e.split("-");return[t,n]}var oa=yd,sa=Cd,ia=Td,aa=Ed,uy="Portal",so=p.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=p.useState(!1);It(()=>s(!0),[]);const i=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?Po.createPortal(u.jsx(ve.div,{...r,ref:t}),i):null});so.displayName=uy;function dy(e,t){return p.useReducer((n,r)=>t[n][r]??n,e)}var Wt=e=>{const{present:t,children:n}=e,r=fy(t),o=typeof n=="function"?n({present:r.isPresent}):p.Children.only(n),s=$e(r.ref,hy(o));return typeof n=="function"||r.isPresent?p.cloneElement(o,{ref:s}):null};Wt.displayName="Presence";function fy(e){const[t,n]=p.useState(),r=p.useRef(null),o=p.useRef(e),s=p.useRef("none"),i=e?"mounted":"unmounted",[a,l]=dy(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return p.useEffect(()=>{const c=ls(r.current);s.current=a==="mounted"?c:"none"},[a]),It(()=>{const c=r.current,d=o.current;if(d!==e){const m=s.current,f=ls(c);e?l("MOUNT"):f==="none"||(c==null?void 0:c.display)==="none"?l("UNMOUNT"):l(d&&m!==f?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,l]),It(()=>{if(t){let c;const d=t.ownerDocument.defaultView??window,h=f=>{const g=ls(r.current).includes(CSS.escape(f.animationName));if(f.target===t&&g&&(l("ANIMATION_END"),!o.current)){const x=t.style.animationFillMode;t.style.animationFillMode="forwards",c=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=x)})}},m=f=>{f.target===t&&(s.current=ls(r.current))};return t.addEventListener("animationstart",m),t.addEventListener("animationcancel",h),t.addEventListener("animationend",h),()=>{d.clearTimeout(c),t.removeEventListener("animationstart",m),t.removeEventListener("animationcancel",h),t.removeEventListener("animationend",h)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:p.useCallback(c=>{r.current=c?getComputedStyle(c):null,n(c)},[])}}function ls(e){return(e==null?void 0:e.animationName)||"none"}function hy(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var la="rovingFocusGroup.onEntryFocus",py={bubbles:!1,cancelable:!0},io="RovingFocusGroup",[ca,Nd,my]=Yo(io),[gy,Ad]=cn(io,[my]),[xy,vy]=gy(io),jd=p.forwardRef((e,t)=>u.jsx(ca.Provider,{scope:e.__scopeRovingFocusGroup,children:u.jsx(ca.Slot,{scope:e.__scopeRovingFocusGroup,children:u.jsx(wy,{...e,ref:t})})}));jd.displayName=io;var wy=p.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:c,preventScrollOnEntryFocus:d=!1,...h}=e,m=p.useRef(null),f=$e(t,m),v=Xo(s),[g,x]=Dn({prop:i,defaultProp:a??null,onChange:l,caller:io}),[y,b]=p.useState(!1),S=xt(c),k=Nd(n),C=p.useRef(!1),[T,E]=p.useState(0);return p.useEffect(()=>{const N=m.current;if(N)return N.addEventListener(la,S),()=>N.removeEventListener(la,S)},[S]),u.jsx(xy,{scope:n,orientation:r,dir:v,loop:o,currentTabStopId:g,onItemFocus:p.useCallback(N=>x(N),[x]),onItemShiftTab:p.useCallback(()=>b(!0),[]),onFocusableItemAdd:p.useCallback(()=>E(N=>N+1),[]),onFocusableItemRemove:p.useCallback(()=>E(N=>N-1),[]),children:u.jsx(ve.div,{tabIndex:y||T===0?-1:0,"data-orientation":r,...h,ref:f,style:{outline:"none",...e.style},onMouseDown:ae(e.onMouseDown,()=>{C.current=!0}),onFocus:ae(e.onFocus,N=>{const R=!C.current;if(N.target===N.currentTarget&&R&&!y){const L=new CustomEvent(la,py);if(N.currentTarget.dispatchEvent(L),!L.defaultPrevented){const z=k().filter($=>$.focusable),V=z.find($=>$.active),U=z.find($=>$.id===g),W=[V,U,...z].filter(Boolean).map($=>$.ref.current);Md(W,d)}}C.current=!1}),onBlur:ae(e.onBlur,()=>b(!1))})})}),_d="RovingFocusGroupItem",Pd=p.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,l=Pt(),c=s||l,d=vy(_d,n),h=d.currentTabStopId===c,m=Nd(n),{onFocusableItemAdd:f,onFocusableItemRemove:v,currentTabStopId:g}=d;return p.useEffect(()=>{if(r)return f(),()=>v()},[r,f,v]),u.jsx(ca.ItemSlot,{scope:n,id:c,focusable:r,active:o,children:u.jsx(ve.span,{tabIndex:h?0:-1,"data-orientation":d.orientation,...a,ref:t,onMouseDown:ae(e.onMouseDown,x=>{r?d.onItemFocus(c):x.preventDefault()}),onFocus:ae(e.onFocus,()=>d.onItemFocus(c)),onKeyDown:ae(e.onKeyDown,x=>{if(x.key==="Tab"&&x.shiftKey){d.onItemShiftTab();return}if(x.target!==x.currentTarget)return;const y=Sy(x,d.orientation,d.dir);if(y!==void 0){if(x.metaKey||x.ctrlKey||x.altKey||x.shiftKey)return;x.preventDefault();let S=m().filter(k=>k.focusable).map(k=>k.ref.current);if(y==="last")S.reverse();else if(y==="prev"||y==="next"){y==="prev"&&S.reverse();const k=S.indexOf(x.currentTarget);S=d.loop?Cy(S,k+1):S.slice(k+1)}setTimeout(()=>Md(S))}}),children:typeof i=="function"?i({isCurrentTabStop:h,hasTabStop:g!=null}):i})})});Pd.displayName=_d;var by={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function yy(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Sy(e,t,n){const r=yy(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return by[r]}function Md(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function Cy(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Ty=jd,ky=Pd,Ey=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Er=new WeakMap,cs=new WeakMap,us={},ua=0,Rd=function(e){return e&&(e.host||Rd(e.parentNode))},Iy=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=Rd(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},Ny=function(e,t,n,r){var o=Iy(t,Array.isArray(e)?e:[e]);us[n]||(us[n]=new WeakMap);var s=us[n],i=[],a=new Set,l=new Set(o),c=function(h){!h||a.has(h)||(a.add(h),c(h.parentNode))};o.forEach(c);var d=function(h){!h||l.has(h)||Array.prototype.forEach.call(h.children,function(m){if(a.has(m))d(m);else try{var f=m.getAttribute(r),v=f!==null&&f!=="false",g=(Er.get(m)||0)+1,x=(s.get(m)||0)+1;Er.set(m,g),s.set(m,x),i.push(m),g===1&&v&&cs.set(m,!0),x===1&&m.setAttribute(n,"true"),v||m.setAttribute(r,"true")}catch(y){console.error("aria-hidden: cannot operate on ",m,y)}})};return d(t),a.clear(),ua++,function(){i.forEach(function(h){var m=Er.get(h)-1,f=s.get(h)-1;Er.set(h,m),s.set(h,f),m||(cs.has(h)||h.removeAttribute(r),cs.delete(h)),f||h.removeAttribute(n)}),ua--,ua||(Er=new WeakMap,Er=new WeakMap,cs=new WeakMap,us={})}},da=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=Ey(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),Ny(r,o,n,"aria-hidden")):function(){return null}},Cn=function(){return Cn=Object.assign||function(t){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])}return t},Cn.apply(this,arguments)};function Od(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n}function Ay(e,t,n){if(n||arguments.length===2)for(var r=0,o=t.length,s;r<o;r++)(s||!(r in t))&&(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return e.concat(s||Array.prototype.slice.call(t))}typeof SuppressedError=="function"&&SuppressedError;var ds="right-scroll-bar-position",fs="width-before-scroll-bar",jy="with-scroll-bars-hidden",_y="--removed-body-scroll-bar-size";function fa(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function Py(e,t){var n=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 My=typeof window<"u"?p.useLayoutEffect:p.useEffect,Dd=new WeakMap;function Ry(e,t){var n=Py(null,function(r){return e.forEach(function(o){return fa(o,r)})});return My(function(){var r=Dd.get(n);if(r){var o=new Set(r),s=new Set(e),i=n.current;o.forEach(function(a){s.has(a)||fa(a,null)}),s.forEach(function(a){o.has(a)||fa(a,i)})}Dd.set(n,e)},[e]),n}function Oy(e){return e}function Dy(e,t){t===void 0&&(t=Oy);var n=[],r=!1,o={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(s){var i=t(s,r);return n.push(i),function(){n=n.filter(function(a){return a!==i})}},assignSyncMedium:function(s){for(r=!0;n.length;){var i=n;n=[],i.forEach(s)}n={push:function(a){return s(a)},filter:function(){return n}}},assignMedium:function(s){r=!0;var i=[];if(n.length){var a=n;n=[],a.forEach(s),i=n}var l=function(){var d=i;i=[],d.forEach(s)},c=function(){return Promise.resolve().then(l)};c(),n={push:function(d){i.push(d),c()},filter:function(d){return i=i.filter(d),n}}}};return o}function Ly(e){e===void 0&&(e={});var t=Dy(null);return t.options=Cn({async:!0,ssr:!1},e),t}var Ld=function(e){var t=e.sideCar,n=Od(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return p.createElement(r,Cn({},n))};Ld.isSideCarExport=!0;function $y(e,t){return e.useMedium(t),Ld}var $d=Ly(),ha=function(){},hs=p.forwardRef(function(e,t){var n=p.useRef(null),r=p.useState({onScrollCapture:ha,onWheelCapture:ha,onTouchMoveCapture:ha}),o=r[0],s=r[1],i=e.forwardProps,a=e.children,l=e.className,c=e.removeScrollBar,d=e.enabled,h=e.shards,m=e.sideCar,f=e.noRelative,v=e.noIsolation,g=e.inert,x=e.allowPinchZoom,y=e.as,b=y===void 0?"div":y,S=e.gapMode,k=Od(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=m,T=Ry([n,t]),E=Cn(Cn({},k),o);return p.createElement(p.Fragment,null,d&&p.createElement(C,{sideCar:$d,removeScrollBar:c,shards:h,noRelative:f,noIsolation:v,inert:g,setCallbacks:s,allowPinchZoom:!!x,lockRef:n,gapMode:S}),i?p.cloneElement(p.Children.only(a),Cn(Cn({},E),{ref:T})):p.createElement(b,Cn({},E,{className:l,ref:T}),a))});hs.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},hs.classNames={fullWidth:fs,zeroRight:ds};var Fy=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function By(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Fy();return t&&e.setAttribute("nonce",t),e}function zy(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Hy(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var Uy=function(){var e=0,t=null;return{add:function(n){e==0&&(t=By())&&(zy(t,n),Hy(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Wy=function(){var e=Uy();return function(t,n){p.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Fd=function(){var e=Wy(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},Vy={left:0,top:0,right:0,gap:0},pa=function(e){return parseInt(e||"",10)||0},Ky=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],o=t[e==="padding"?"paddingRight":"marginRight"];return[pa(n),pa(r),pa(o)]},qy=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Vy;var t=Ky(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},Gy=Fd(),Ir="data-scroll-locked",Yy=function(e,t,n,r){var o=e.left,s=e.top,i=e.right,a=e.gap;return n===void 0&&(n="margin"),`
|
|
40
40
|
.`.concat(jy,` {
|
|
41
41
|
overflow: hidden `).concat(r,`;
|
|
42
42
|
padding-right: `).concat(a,"px ").concat(r,`;
|
|
@@ -126,5 +126,5 @@ ${t}</tr>
|
|
|
126
126
|
`}strong(t){return`<strong>${t}</strong>`}em(t){return`<em>${t}</em>`}codespan(t){return`<code>${t}</code>`}br(){return this.options.xhtml?"<br/>":"<br>"}del(t){return`<del>${t}</del>`}link(t,n,r){if(t=hp(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=hp(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 vp{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 wp{constructor(){this.seen={}}serialize(t){return t.toLowerCase().trim().replace(/<[!\/a-z].*?>/ig,"").replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g,"").replace(/\s/g,"-")}getNextSafeSlug(t,n){let r=t,o=0;if(this.seen.hasOwnProperty(r)){o=this.seen[t];do o++,r=t+"-"+o;while(this.seen.hasOwnProperty(r))}return n||(this.seen[t]=o,this.seen[r]=0),r}slug(t,n={}){const r=this.serialize(t);return this.getNextSafeSlug(r,n.dryrun)}}class Kn{constructor(t){this.options=t||lr,this.options.renderer=this.options.renderer||new ol,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new vp,this.slugger=new wp}static parse(t,n){return new Kn(n).parse(t)}static parseInline(t,n){return new Kn(n).parseInline(t)}parse(t,n=!0){let r="",o,s,i,a,l,c,d,h,m,f,v,g,x,y,b,S,k,C,T;const E=t.length;for(o=0;o<E;o++){if(f=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[f.type]&&(T=this.options.extensions.renderers[f.type].call({parser:this},f),T!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(f.type))){r+=T||"";continue}switch(f.type){case"space":continue;case"hr":{r+=this.renderer.hr();continue}case"heading":{r+=this.renderer.heading(this.parseInline(f.tokens),f.depth,fp(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(h="",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(h+=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(h,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],S=b.checked,k=b.task,y="",b.task&&(C=this.renderer.checkbox(S),x?b.tokens.length>0&&b.tokens[0].type==="paragraph"?(b.tokens[0].text=C+" "+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=C+" "+b.tokens[0].tokens[0].text)):b.tokens.unshift({type:"text",text:C}):y+=C),y+=this.parse(b.tokens,x),m+=this.renderer.listitem(y,k,S);r+=this.renderer.list(m,v,g);continue}case"html":{r+=this.renderer.html(f.text);continue}case"paragraph":{r+=this.renderer.paragraph(this.parseInline(f.tokens));continue}case"text":{for(m=f.tokens?this.parseInline(f.tokens):f.text;o+1<E&&t[o+1].type==="text";)f=t[++o],m+=`
|
|
127
127
|
`+(f.tokens?this.parseInline(f.tokens):f.text);r+=n?this.renderer.paragraph(m):m;continue}default:{const N='Token with "'+f.type+'" type was not found.';if(this.options.silent){console.error(N);return}else throw new Error(N)}}}return r}parseInline(t,n){n=n||this.renderer;let r="",o,s,i;const a=t.length;for(o=0;o<a;o++){if(s=t[o],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[s.type]&&(i=this.options.extensions.renderers[s.type].call({parser:this},s),i!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type))){r+=i||"";continue}switch(s.type){case"escape":{r+=n.text(s.text);break}case"html":{r+=n.html(s.text);break}case"link":{r+=n.link(s.href,s.title,this.parseInline(s.tokens,n));break}case"image":{r+=n.image(s.href,s.title,s.text);break}case"strong":{r+=n.strong(this.parseInline(s.tokens,n));break}case"em":{r+=n.em(this.parseInline(s.tokens,n));break}case"codespan":{r+=n.codespan(s.text);break}case"br":{r+=n.br();break}case"del":{r+=n.del(this.parseInline(s.tokens,n));break}case"text":{r+=n.text(s.text);break}default:{const l='Token with "'+s.type+'" type was not found.';if(this.options.silent){console.error(l);return}else throw new Error(l)}}}return r}}class Gs{constructor(t){this.options=t||lr}preprocess(t){return t}postprocess(t){return t}}Qg(Gs,"passThroughHooks",new Set(["preprocess","postprocess"]));function PT(e,t,n){return r=>{if(r.message+=`
|
|
128
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 bp(e,t){return(n,r,o)=>{typeof r=="function"&&(o=r,r=null);const s={...r};r={...ye.defaults,...s};const i=PT(r.silent,r.async,o);if(typeof n>"u"||n===null)return i(new Error("marked(): input parameter is undefined or null"));if(typeof n!="string")return i(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(n)+", string expected"));if(AT(r),r.hooks&&(r.hooks.options=r),o){const a=r.highlight;let l;try{r.hooks&&(n=r.hooks.preprocess(n)),l=e(n,r)}catch(h){return i(h)}const c=function(h){let m;if(!h)try{r.walkTokens&&ye.walkTokens(l,r.walkTokens),m=t(l,r),r.hooks&&(m=r.hooks.postprocess(m))}catch(f){h=f}return r.highlight=a,h?i(h):o(null,m)};if(!a||a.length<3||(delete r.highlight,!l.length))return c();let d=0;ye.walkTokens(l,function(h){h.type==="code"&&(d++,setTimeout(()=>{a(h.text,h.lang,function(m,f){if(m)return c(m);f!=null&&f!==h.text&&(h.text=f,h.escaped=!0),d--,d===0&&c()})},0))}),d===0&&c();return}if(r.async)return Promise.resolve(r.hooks?r.hooks.preprocess(n):n).then(a=>e(a,r)).then(a=>r.walkTokens?Promise.all(ye.walkTokens(a,r.walkTokens)).then(()=>a):a).then(a=>t(a,r)).then(a=>r.hooks?r.hooks.postprocess(a):a).catch(i);try{r.hooks&&(n=r.hooks.preprocess(n));const a=e(n,r);r.walkTokens&&ye.walkTokens(a,r.walkTokens);let l=t(a,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(a){return i(a)}}}function ye(e,t,n){return bp(Vn.lex,Kn.parse)(e,t,n)}ye.options=ye.setOptions=function(e){return ye.defaults={...ye.defaults,...e},gT(ye.defaults),ye},ye.getDefaults=lp,ye.defaults=lr,ye.use=function(...e){const t=ye.defaults.extensions||{renderers:{},childTokens:{}};e.forEach(n=>{const r={...n};if(r.async=ye.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(o=>{if(!o.name)throw new Error("extension name required");if(o.renderer){const s=t.renderers[o.name];s?t.renderers[o.name]=function(...i){let a=o.renderer.apply(this,i);return a===!1&&(a=s.apply(this,i)),a}:t.renderers[o.name]=o.renderer}if(o.tokenizer){if(!o.level||o.level!=="block"&&o.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");t[o.level]?t[o.level].unshift(o.tokenizer):t[o.level]=[o.tokenizer],o.start&&(o.level==="block"?t.startBlock?t.startBlock.push(o.start):t.startBlock=[o.start]:o.level==="inline"&&(t.startInline?t.startInline.push(o.start):t.startInline=[o.start]))}o.childTokens&&(t.childTokens[o.name]=o.childTokens)}),r.extensions=t),n.renderer){const o=ye.defaults.renderer||new ol;for(const s in n.renderer){const i=o[s];o[s]=(...a)=>{let l=n.renderer[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.renderer=o}if(n.tokenizer){const o=ye.defaults.tokenizer||new rl;for(const s in n.tokenizer){const i=o[s];o[s]=(...a)=>{let l=n.tokenizer[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.tokenizer=o}if(n.hooks){const o=ye.defaults.hooks||new Gs;for(const s in n.hooks){const i=o[s];Gs.passThroughHooks.has(s)?o[s]=a=>{if(ye.defaults.async)return Promise.resolve(n.hooks[s].call(o,a)).then(c=>i.call(o,c));const l=n.hooks[s].call(o,a);return i.call(o,l)}:o[s]=(...a)=>{let l=n.hooks[s].apply(o,a);return l===!1&&(l=i.apply(o,a)),l}}r.hooks=o}if(n.walkTokens){const o=ye.defaults.walkTokens;r.walkTokens=function(s){let i=[];return i.push(n.walkTokens.call(this,s)),o&&(i=i.concat(o.call(this,s))),i}}ye.setOptions(r)})},ye.walkTokens=function(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(ye,r)),r.type){case"table":{for(const o of r.header)n=n.concat(ye.walkTokens(o.tokens,t));for(const o of r.rows)for(const s of o)n=n.concat(ye.walkTokens(s.tokens,t));break}case"list":{n=n.concat(ye.walkTokens(r.items,t));break}default:ye.defaults.extensions&&ye.defaults.extensions.childTokens&&ye.defaults.extensions.childTokens[r.type]?ye.defaults.extensions.childTokens[r.type].forEach(function(o){n=n.concat(ye.walkTokens(r[o],t))}):r.tokens&&(n=n.concat(ye.walkTokens(r.tokens,t)))}return n},ye.parseInline=bp(Vn.lexInline,Kn.parseInline),ye.Parser=Kn,ye.parser=Kn.parse,ye.Renderer=ol,ye.TextRenderer=vp,ye.Lexer=Vn,ye.lexer=Vn.lex,ye.Tokenizer=rl,ye.Slugger=wp,ye.Hooks=Gs,ye.parse=ye,ye.options,ye.setOptions,ye.use,ye.walkTokens,ye.parseInline,Kn.parse,Vn.lex;function Mr({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 ye.parse=="function"?ye.parse(i):ye(i)}return typeof ye.parse=="function"?ye.parse(e):ye(e)}catch(i){return console.error("[MarkdownContent] parse error",i),`<pre class="font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words">Error rendering markdown: ${String(i)}</pre>`}},[e,n]),s=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:te("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 yp({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 Sp({artifact:e}){const[t,n]=w.useState("bg-yellow-500/20 text-yellow-700 dark:text-yellow-300"),[r,o]=w.useState(u.jsx(le.Clock,{className:"w-4 h-4"})),[s,i]=w.useState("Processing");return w.useEffect(()=>{switch(e.status||"processing"){case"completed":n("bg-green-500/20 text-green-700 dark:text-green-300"),o(u.jsx(le.CheckCircle,{className:"w-4 h-4"})),i("Completed");break;case"failed":n("bg-red-500/20 text-red-700 dark:text-red-300"),o(u.jsx(le.ExternalLink,{className:"w-4 h-4 rotate-45"})),i("Failed");break;case"pending":n("bg-blue-500/20 text-blue-700 dark:text-blue-300"),o(u.jsx(le.Clock,{className:"w-4 h-4"})),i("Pending");break;default:n("bg-yellow-500/20 text-yellow-700 dark:text-yellow-300"),o(u.jsx(le.Clock,{className:"w-4 h-4"})),i("Processing")}},[e.status]),u.jsxs("div",{className:"rounded-lg border border-blue-200 dark:border-blue-900/50 bg-blue-50 dark:bg-blue-950/20 p-4 space-y-3",children:[u.jsxs("div",{className:"flex items-start gap-3",children:[u.jsx("div",{className:"mt-1 flex-shrink-0",children:u.jsx(le.Search,{className:"w-5 h-5 text-blue-600 dark:text-blue-400"})}),u.jsxs("div",{className:"flex-1 min-w-0",children:[u.jsx("h3",{className:"font-semibold text-blue-900 dark:text-blue-100",children:"Research Task"}),u.jsxs("p",{className:"text-sm text-blue-700 dark:text-blue-300 mt-1",children:["Task ID: ",u.jsxs("code",{className:"font-mono text-xs bg-blue-100 dark:bg-blue-900/30 px-2 py-1 rounded",children:[e.task_id.slice(0,8),"..."]})]})]})]}),u.jsxs("div",{className:`inline-flex items-center gap-2 px-3 py-1 rounded-full text-sm font-medium ${t}`,children:[r,u.jsx("span",{children:s})]}),e.query&&u.jsxs("div",{className:"text-sm text-blue-800 dark:text-blue-200 bg-white dark:bg-blue-900/30 rounded px-3 py-2",children:[u.jsx("p",{className:"font-medium text-xs text-blue-600 dark:text-blue-400 mb-1",children:"Query:"}),u.jsx("p",{className:"line-clamp-2",children:e.query})]}),typeof e.results=="string"&&e.results.trim()&&u.jsxs("div",{className:"text-sm text-blue-900 dark:text-blue-100 bg-white dark:bg-blue-900/30 rounded px-3 py-2 space-y-2",children:[u.jsx("p",{className:"font-semibold text-xs text-blue-600 dark:text-blue-400",children:"Results:"}),u.jsx(Mr,{content:e.results,allowHtml:!1,className:"prose text-xs !prose-sm prose-blue dark:prose-invert"})]}),e.progress_url&&u.jsx("div",{className:"pt-2",children:u.jsxs("a",{href:e.progress_url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white dark:bg-blue-700 dark:hover:bg-blue-600 rounded-md text-sm font-medium transition-colors",children:[u.jsx("span",{children:"Monitor Progress"}),u.jsx(le.ExternalLink,{className:"w-3.5 h-3.5"})]})}),e.createdAt&&u.jsxs("p",{className:"text-xs text-blue-600 dark:text-blue-400",children:["Started: ",new Date(e.createdAt).toLocaleTimeString()]})]})}function Cp({artifact:e,idx:t=0}){const n=w.useMemo(()=>e?(Array.isArray(e.plots)?e.plots:[]).map(o=>nw(o)).filter(o=>o!==null):[],[e]);return(e==null?void 0:e.type)==="research_task_info"?u.jsx(Sp,{artifact:{type:"research_task_info",task_id:e.task_id,progress_url:e.progress_url,query:e.query,status:e.status,createdAt:e.createdAt}}):n.length>0?u.jsx("div",{className:"space-y-2",children:n.map((r,o)=>u.jsx(yp,{preview:r,idx:o},`${t}-plot-${o}`))}):e&&typeof e=="object"?u.jsx("div",{className:"rounded-lg border border-gray-200 dark:border-gray-800 bg-gray-50 dark:bg-gray-900/20 p-4",children:u.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:["Unknown artifact type: ",u.jsx("code",{className:"font-mono",children:e.type||"unknown"})]})}):null}const sl=p.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:te("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));sl.displayName="Card";const il=p.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:te("flex flex-col space-y-1.5 p-6",e),...t}));il.displayName="CardHeader";const al=p.forwardRef(({className:e,...t},n)=>u.jsx("h3",{ref:n,className:te("text-2xl font-semibold leading-none tracking-tight",e),...t}));al.displayName="CardTitle";const ll=p.forwardRef(({className:e,...t},n)=>u.jsx("p",{ref:n,className:te("text-sm text-muted-foreground",e),...t}));ll.displayName="CardDescription";const cl=p.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:te("p-6 pt-0",e),...t}));cl.displayName="CardContent";const Tp=p.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:te("flex items-center p-6 pt-0",e),...t}));Tp.displayName="CardFooter";function kp({interruptPart:e,onApprove:t,onReject:n,disabled:r,isActive:o,payload:s}){const i=e.title??"Approve the result?";let a=null;if(s!=null)if(typeof s=="string")a=u.jsx("p",{className:"text-sm leading-relaxed text-blue-800/90 dark:text-blue-200/90 whitespace-pre-wrap",children:s});else{const c=xr(s);a=u.jsx("pre",{className:"max-h-48 overflow-auto rounded bg-blue-100/60 p-2 text-xs text-blue-900/90 dark:bg-blue-900/40 dark:text-blue-100/80",children:c})}const l=o?"Please approve or reject this action to resume the workflow.":"Waiting for approval from another participant.";return u.jsxs(sl,{className:te("border-blue-200 dark:border-blue-800 bg-blue-50/50 dark:bg-blue-950/10 transition-shadow",o?"shadow-md ring-1 ring-blue-300 dark:ring-blue-500/70":"opacity-80"),children:[u.jsxs(il,{className:"pb-3",children:[u.jsx(al,{className:"text-blue-900 dark:text-blue-100 text-base",children:i}),u.jsx(ll,{className:"text-blue-700 dark:text-blue-300 text-sm",children:l})]}),a&&u.jsx(cl,{className:"pt-0 pb-3",children:a}),u.jsx(Tp,{className:"pt-0",children:u.jsxs("div",{className:"flex gap-2 ml-auto",children:[u.jsx(tt,{size:"sm",variant:"outline",onClick:()=>n(e),className:"border-red-300 text-red-700 hover:bg-red-50 dark:border-red-700 dark:text-red-300 dark:hover:bg-red-950/50",disabled:r||!o,children:"Reject"}),u.jsx(tt,{size:"sm",onClick:()=>t(e),className:"bg-blue-600 hover:bg-blue-700 text-white",disabled:r||!o,children:"Approve"})]})})]})}const MT="prose prose-sm max-w-none break-words dark:prose-invert prose-headings:break-words prose-p:break-words prose-li:break-words prose-td:break-words prose-th:break-words prose-a:break-all prose-code:break-words prose-blockquote:break-words";function ul({data:e}){return Array.isArray(e)?e.every(n=>n===null||["string","number","boolean"].includes(typeof n))?u.jsx("div",{className:MT,children:u.jsx("ul",{className:"list-disc pl-5",children:e.map((n,r)=>u.jsx("li",{children:String(n)},r))})}):u.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:xr(e)}):u.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:xr(e)})}function Ep({message:e,isStreaming:t=!1}){const n=e.name??"tool",r=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}function Ip({message:e,viewMode:t,isStreaming:n=!1}){const o=Ri(e).name||"tool",s=l=>{if(l==null)return null;const c=typeof l=="string"?Mi(l)??l:l;if(c&&typeof c=="object")return u.jsx(ul,{data:c});const d=typeof c=="string"?c:(()=>{try{return xr(c)}catch{return String(c??"")}})();return u.jsx("pre",{className:"whitespace-pre-wrap break-words font-sans text-sm text-foreground/90",children:d})},i=l=>{if(l==null)return null;const{content:c,isMarkdown:d}=Yv(l);return d?u.jsx(Mr,{content:c,className:"text-current"}):s(l)},a=()=>{const l=e.content.find(h=>h.type!=="tool_call");if(!l)return u.jsx("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:u.jsxs("span",{children:["Running ",o,"…"]})});if(l.type==="text"){const m=(l.text??"").trim();if(!m)return null;const f=Qr(m);return i(f)}const c=Zr(l),d=Qr(c);return i(d)};return u.jsxs("div",{className:"space-y-2",children:[u.jsx(Ep,{message:e,isStreaming:n}),t==="expanded"&&a()]})}function Np({className:e}){const[t,n]=w.useState(0);return w.useEffect(()=>{const r=setInterval(()=>n(o=>(o+1)%4),500);return()=>clearInterval(r)},[]),u.jsxs("span",{"aria-live":"polite",className:te("inline-block text-xs opacity-70 ml-1",e),children:["Is thinking",".".repeat(t)]})}function Ap({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:te("text-sm text-[hsl(var(--chat-bubble-user-text))]",o&&"text-xs"),children:t?u.jsx(Mr,{content:e,allowHtml:!1}):u.jsxs("pre",{className:te("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(tt,{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 jp({message:e,isToolMessage:t,showToolMessages:n,artifactToRender:r,toolViewMode:o,isToolStreaming:s,contentParts:i,textContent:a,imageParts:l,fileParts:c,interruptParts:d,isStreamingMessage:h,defaultMessage:m,handleFileClick:f,uploadingFiles:v,handleInterruptApprove:g,handleInterruptReject:x,disableInterruptActions:y,messageRole:b,truncateUserMessages:S,userMessagePreviewLength:k,isUserExpanded:C,setIsUserExpanded:T,isCompactLayout:E,activeInterruptId:N,activeInterruptValue:R,iconForeground:L}){const z=w.useCallback(()=>u.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/30 rounded",children:[u.jsx(le.Paperclip,{className:"h-4 w-4 text-muted-foreground"}),u.jsx("span",{className:"text-sm text-muted-foreground",children:"File upload"})]}),[]),V=w.useCallback(({part:j,i:W})=>{if(j.type==="text"){const $=j.text??"",O=$.trim(),P=Mi(O);return P&&b!=="tool"?u.jsx(ul,{data:P},W):b==="user"&&S&&O.length>k?u.jsx(Ap,{text:O,expanded:C,onExpandedChange:T,previewLength:k,isCompact:E},W):u.jsx(Mr,{content:$,allowHtml:!1},W)}if(j.type==="image_url"){const $=j;return u.jsx("div",{className:"my-2",children:u.jsx("img",{src:$.url,alt:$.alt??"",loading:"lazy",className:"border rounded max-h-[420px] w-auto object-contain"})},W)}if(j.type==="file"){const $=j,O=$.name||"file";return u.jsxs("a",{href:$.url,onClick:P=>f(P.nativeEvent,$,W),className:`inline-flex items-center gap-2 rounded px-2 py-1 text-xs bg-gray-100 border hover:bg-gray-200
|
|
129
|
-
dark:bg-background/10 dark:border-border/30 dark:hover:bg-background/20`,children:[v[W]?u.jsx(le.Loader,{className:"h-4 w-4 animate-spin"}):null,u.jsxs("span",{className:"truncate max-w-[180px]",children:[O,v[W]?" (processing)":""]})]},W)}if(j.type==="interrupt"){const $=j,O=Go(($==null?void 0:$.id)??($==null?void 0:$.interrupt_id)),P=!!(N&&O&&O===N),I=P?R??($==null?void 0:$.value):$==null?void 0:$.value,q=O?{...$,id:O,interrupt_id:O}:$;return u.jsx(kp,{interruptPart:q,onApprove:g,onReject:x,disabled:y,isActive:P,payload:I},W)}return null},[f,v,g,x,b,S,k,C,E,N,R,y]),U=a.trim().length>0||l.length>0||c.length>0||d.length>0;if(!t&&c.length>0&&!h)return z();if(!t&&!U&&!h)return null;if(t)return!n&&r?null:n?u.jsx(Ip,{message:e,viewMode:o,isStreaming:s},e.id):null;if(!m){const j=u.jsx("div",{className:"space-y-2",children:i.map((W,$)=>u.jsx(V,{part:W,i:$},$))});return h?u.jsxs("div",{"aria-busy":"true",role:"status",children:[j,u.jsx(Np,{className:L})]}):j}return null}function _p(e){const{allowFileOpen:t,currentThreadId:n}=e,{toast:r}=nl(),[o,s]=w.useState({}),[i,a]=w.useState(null),[l,c]=w.useState(!1),d=w.useCallback(()=>{c(!1),a(null)},[]),h=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??""),S=b.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);if(S){f.preventDefault();const k=S[1],C=v.name||`file_${k}`,T=v.mimeType||"application/octet-stream";h({id:k,name:C,mimeType:T});return}if(b.startsWith("data:")){f.preventDefault(),s(C=>({...C,[g]:!0}));const k=r({title:"Fetching file...",description:"",open:!0});try{const C=await Qc(n??void 0);if(!C||!Array.isArray(C))throw new Error("Invalid file list response");const T=C.find(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");h({id:T.id,name:v.name||T.filename||`file_${T.id}`,mimeType:v.mimeType||T.mime_type||"application/octet-stream"}),(x=k.update)==null||x.call(k,{id:k.id,title:"Success",description:`Opened ${v.name}`,open:!0})}catch(C){console.error("Failed to fetch server file:",C);const T=C instanceof Error?C.message:"Unknown error occurred";(y=k.update)==null||y.call(k,{id:k.id,title:"Failed",description:T}),r({title:"Failed to fetch file",description:T,open:!0})}finally{s(C=>({...C,[g]:!1}))}}}catch(b){console.error("File click error:",b),s(S=>({...S,[g]:!1}))}},[t,o,r,n,h]);return{uploadingFiles:o,handleFileClick:m,fileViewerOpen:l,currentFileInfo:i,closeFileViewer:d}}function Pp(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:Xv(r),toolMeta:Ri(n),imageParts:r.filter(s=>s.type==="image_url"),fileParts:r.filter(s=>s.type==="file"),interruptParts:r.filter(s=>s.type==="interrupt"),toolRaw:Jv(r),isToolStreaming:!!o.toolStreaming}},[e,t])}const Ys=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:h=!0,showArtifactPreviews:m=!0,customStyles:f={},onEdit:v,onRegenerate:g,onCopy:x,activeInterrupt:y,disableInterruptActions:b=!1,onInterruptActionStart:S,onInterruptActionEnd:k,attemptCount:C=1,attemptIndex:T=0,onSelectCheckpoint:E,attemptMetas:N=[]}){const[R,L]=w.useState(!1),[z,V]=w.useState("preview"),[U,j]=w.useState(!1),{currentThreadId:W}=gr(),{respondToInterrupt:$}=eo(),O=l==="phone"||l==="half-screen",P=t.role,I=P==="tool",q=w.useMemo(()=>"type"in t&&t.type==="default_message"?t:null,[t]),Y=!!q,_=!(r&&P!=="user"),{uploadingFiles:M,handleFileClick:G,fileViewerOpen:J,currentFileInfo:oe,closeFileViewer:K}=_p({allowFileOpen:_,currentThreadId:W}),D=w.useMemo(()=>{switch(P){case"user":return"text-[hsl(var(--chat-bubble-user-text))]";case"assistant":return"text-[hsl(var(--chat-bubble-ai-text))]";case"tool":return"text-secondary-foreground";case"system":return"text-muted-foreground";default:return"text-[hsl(var(--chat-bubble-ai-text))]"}},[P]),X=Pp(t,q),{contentParts:Z,imageParts:ue,fileParts:F,interruptParts:ne,textContent:de,toolMeta:ce,toolRaw:ge,isToolStreaming:Ce}=X,Pe=(y==null?void 0:y.id)??(y==null?void 0:y.interrupt_id),De=Go(Pe),ze=y==null?void 0:y.value,rt=w.useMemo(()=>q||!m?null:t.artifact||null,[q,t,m]),Ct=w.useCallback(async()=>{const Te=I?ge:de;async function qe(Ee){if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function"){await navigator.clipboard.writeText(Ee);return}if(navigator.clipboard&&typeof navigator.clipboard.write=="function"&&typeof ClipboardItem<"u"){const Ke=new Blob([Ee],{type:"text/plain"});await navigator.clipboard.write([new ClipboardItem({"text/plain":Ke})]);return}throw new Error("Clipboard API not supported in this context.")}try{await qe(Te),L(!0),setTimeout(()=>L(!1),2e3),x==null||x(Te)}catch(Ee){console.error("Failed to copy:",Ee)}},[I,ge,de,x]),Ve=w.useCallback(()=>{if(!v||!t.id)return;const Te=(I?ge:de)??"",qe="type"in t&&t.type==="default_message"?void 0:{checkpointId:t.checkpointId??null,checkpointNs:t.checkpointNs??null};v(t.id,Te,qe)},[v,t.id,I,ge,de,t]),He=w.useCallback(()=>{g==null||g(n)},[g,n]),Ye=w.useCallback(()=>{const qe=te(O?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",D);switch(P){case"user":return u.jsx(le.User,{className:qe});case"assistant":return u.jsx(le.Bot,{className:qe});case"tool":return u.jsx(le.Wrench,{className:qe});default:return u.jsx(le.Bot,{className:qe})}},[O,D,P]),Le=w.useCallback(()=>{const Te="group relative mb-4 flex w-full";switch(P){case"user":return te(Te,"justify-end");case"assistant":case"tool":case"system":return te(Te,"justify-start");default:return Te}},[P]),Ue=w.useCallback(()=>{const Te=te("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",O&&"px-3 py-2 text-sm");if(Y)return te(Te,"w-full","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40 shadow-sm");switch(P){case"user":return te(Te,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-user))] text-[hsl(var(--chat-bubble-user-text))]","border border-transparent");case"assistant":return te(Te,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40");case"tool":return te(Te,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return te(Te,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return te(Te,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40")}},[O,Y,P]),mt=w.useCallback(async Te=>{if(b)return;const qe=Go((Te==null?void 0:Te.id)??(Te==null?void 0:Te.interrupt_id));if(!qe){console.warn("Interrupt part missing id",Te);return}try{S==null||S(),await $(qe,!0)}catch(Ee){console.error("Failed to approve interrupt:",Ee)}finally{k==null||k()}},[b,k,S,$]),Dt=w.useCallback(async Te=>{if(b)return;const qe=Go((Te==null?void 0:Te.id)??(Te==null?void 0:Te.interrupt_id));if(!qe){console.warn("Interrupt part missing id",Te);return}try{S==null||S(),await $(qe,!1)}catch(Ee){console.error("Failed to reject interrupt:",Ee)}finally{k==null||k()}},[b,k,S,$]),at=w.useMemo(()=>q?"Assistant":Zv(t),[q,t]),At=P==="user"&&(C??1)>1&&typeof E=="function",wt=(N==null?void 0:N.length)??0,dt=wt>0&&T<wt-1?N[T+1]:void 0,bt=wt>0&&T>0?N[T-1]:void 0,Tt=w.useCallback(()=>{!dt||!E||E(dt.id,void 0,!!dt.isLatestAttempt)},[dt,E]),jt=w.useCallback(()=>{!bt||!E||E(bt.id,void 0,!!bt.isLatestAttempt)},[bt,E]);return I&&!h&&!rt?null:Y&&q?u.jsx("div",{className:te(Le(),f.container),children:u.jsxs("div",{className:te(Ue(),f.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:te("h-4 w-4",D)}),a&&u.jsx("span",{className:"font-medium text-sm",children:"Assistant"})]}),u.jsx(Mr,{content:q.content,className:"text-current"})]})}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:te(Le(),f.container),children:u.jsxs("div",{className:te(Ue(),f.content),children:[(i||a||I)&&u.jsxs("div",{className:te("flex items-center justify-between mb-2 pb-2 border-b border-current/10",O&&"mb-1 pb-1",D,f.header),children:[u.jsxs("div",{className:"flex items-center gap-2",children:[Ye(),a&&at&&u.jsx("span",{className:te("font-medium",O?"text-xs":"text-sm"),children:at}),I&&u.jsxs(zh,{variant:"outline",className:te("text-xs flex items-center gap-1 cursor-pointer select-none",D,"border border-current/40",O&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":z==="expanded",onClick:()=>V(Te=>Te==="expanded"?"preview":"expanded"),onKeyDown:Te=>{(Te.key==="Enter"||Te.key===" ")&&(Te.preventDefault(),V(qe=>qe==="expanded"?"preview":"expanded"))},children:[u.jsx("span",{children:ce.name??"Tool Output"}),ce.toolCallId&&u.jsx("span",{className:"opacity-70",children:ce.toolCallId.slice(0,8)}),z==="expanded"?u.jsx(le.ChevronUp,{className:"h-3 w-3"}):u.jsx(le.ChevronDown,{className:"h-3 w-3"})]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[At&&C>1&&u.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[u.jsx("button",{type:"button",className:te("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",T<C-1?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{T>=C-1||Tt()},"aria-label":"Older attempt (back in time)",disabled:T>=C-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:[C-T," / ",C]})}),u.jsx("button",{type:"button",className:te("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||jt()},"aria-label":"Newer attempt (forward in time)",disabled:T<=0,children:u.jsx(le.ChevronRight,{className:"h-3 w-3"})})]}),i&&t.createdAt&&u.jsx("time",{className:te("text-xs opacity-60",D,O&&"text-xs"),dateTime:new Date(t.createdAt).toISOString(),title:new Date(t.createdAt).toLocaleString(),children:new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(new Date(t.createdAt))}),s&&!o&&u.jsxs("div",{className:te("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",f.actions),children:[u.jsx("div",{className:"relative",children:u.jsx(tt,{variant:"ghost",size:"sm",onClick:()=>Ct(),className:te("h-6 w-6 p-0 hover:bg-foreground/10",D,O&&"h-5 w-5"),"aria-label":"Copy message",title:"Copy message",children:u.jsx(le.Copy,{className:te(R?"text-success":D,O?"h-3 w-3":"h-4 w-4")})})}),P==="user"&&v&&u.jsx(tt,{variant:"ghost",size:"sm",onClick:Ve,className:te("h-6 w-6 p-0 hover:bg-foreground/10",D,O&&"h-5 w-5"),"aria-label":"Edit message",children:u.jsx(le.Edit,{className:te(D,O?"h-3 w-3":"h-4 w-4")})}),P==="assistant"&&g&&u.jsx(tt,{variant:"ghost",size:"sm",onClick:He,className:te("h-6 w-6 p-0 hover:bg-foreground/10",D,O&&"h-5 w-5"),"aria-label":"Regenerate response",children:u.jsx(le.RotateCcw,{className:te(D,O?"h-3 w-3":"h-4 w-4")})})]})]})]}),u.jsxs("div",{className:"relative",children:[u.jsx(jp,{message:t,isToolMessage:I,showToolMessages:h,artifactToRender:rt,toolViewMode:z,isToolStreaming:Ce,contentParts:Z,textContent:de,imageParts:ue,fileParts:F,interruptParts:ne,isStreamingMessage:r,defaultMessage:q,handleFileClick:G,uploadingFiles:M,handleInterruptApprove:mt,handleInterruptReject:Dt,disableInterruptActions:b,messageRole:P,truncateUserMessages:c,userMessagePreviewLength:d,isUserExpanded:U,setIsUserExpanded:j,isCompactLayout:O,activeInterruptId:De,activeInterruptValue:ze,iconForeground:D}),m&&rt&&u.jsx("div",{className:"mt-3",children:u.jsx(Cp,{artifact:rt,idx:0})})]}),I&&z==="expanded"&&(ce.toolCallId||ce.name)&&u.jsxs("div",{className:te("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",O&&"text-xs"),children:[ce.name&&u.jsxs("div",{children:["Function: ",ce.name]}),ce.toolCallId&&u.jsxs("div",{children:["Call ID: ",ce.toolCallId]})]}),!(i||a||I)&&s&&!o&&u.jsxs("div",{className:te("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",f.actions),children:[u.jsx(tt,{variant:"ghost",size:"sm",onClick:()=>Ct(),className:te("h-6 w-6 p-0 hover:bg-background/50 text-current",O&&"h-5 w-5"),children:u.jsx(le.Copy,{className:te(R?"text-success":"text-current",O?"h-3 w-3":"h-4 w-4")})}),P==="user"&&v&&u.jsx(tt,{variant:"ghost",size:"sm",onClick:Ve,className:te("h-6 w-6 p-0 hover:bg-background/50 text-current",O&&"h-5 w-5"),children:u.jsx(le.Edit,{className:te("text-current",O?"h-3 w-3":"h-4 w-4")})}),P==="assistant"&&g&&u.jsx(tt,{variant:"ghost",size:"sm",onClick:He,className:te("h-6 w-6 p-0 hover:bg-background/50 text-current",O&&"h-5 w-5"),children:u.jsx(le.RotateCcw,{className:te("text-current",O?"h-3 w-3":"h-4 w-4")})})]})]})}),oe&&u.jsx(ap,{isOpen:J,onClose:K,fileId:oe.id,fileName:oe.name,mimeType:oe.mimeType})]})},(e,t)=>{var l,c,d,h,m,f,v,g;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&pu(e.message)===pu(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateUserMessages","userMessagePreviewLength","showToolMessages"].every(x=>e[x]===t[x]),s=((l=e.customStyles)==null?void 0:l.container)===((c=t.customStyles)==null?void 0:c.container)&&((d=e.customStyles)==null?void 0:d.content)===((h=t.customStyles)==null?void 0:h.content)&&((m=e.customStyles)==null?void 0:m.actions)===((f=t.customStyles)==null?void 0:f.actions)&&((v=e.customStyles)==null?void 0:v.header)===((g=t.customStyles)==null?void 0:g.header);if(!o||!s)return!1;const i=mu(e.message),a=mu(t.message);return i.length===a.length});Ys.displayName="MessageComponent";const RT={checkpoints:[],checkpointMetaByCheckpointId:new Map,timeline:[],messagePreviews:new Map,getLatest:()=>{},getCheckpoint:()=>{},getMessageAttempts:()=>[]},dl=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,fl=w.memo(function({message:t,index:n,isStreaming:r,streamingAssistantId:o,streamingDebounceMs:s,layoutSize:i,enableMessageEditing:a,editingMessageId:l,onEdit:c,onRegenerate:d,onCancelEdit:h,activeInterrupt:m,disableInterruptActions:f,onInterruptActionStart:v,onInterruptActionEnd:g,showToolMessages:x,showArtifactPreviews:y,checkpointIndex:b,onSelectCheckpoint:S}){const k=dl(t,n),C="type"in t&&t.type==="default_message",E=!!t.__syntheticStreaming,N=b??RT,R=!C&&"checkpointId"in t?t.checkpointId??null:null,{attemptCount:L,attemptIndex:z,attempts:V}=w.useMemo(()=>ec(t.id,R,N),[t.id,R,N]);return u.jsx("div",{className:"relative mb-4 last:mb-0","data-message-id":k,style:{minHeight:"60px",containIntrinsicSize:"auto 120px"},children:u.jsx(Ys,{message:t,messageIndex:n,isStreamingMessage:E||r&&o===t.id,streamingDebounceMs:s,isEditing:l===t.id,showActions:a,showTimestamp:!1,showAgentName:!0,layoutSize:i,onEdit:c,onRegenerate:()=>d(n),onCancelEdit:h,activeInterrupt:m,disableInterruptActions:f,onInterruptActionStart:v,onInterruptActionEnd:g,showToolMessages:x,showArtifactPreviews:y,attemptCount:L,attemptIndex:z,attemptMetas:V,onSelectCheckpoint:S})})});fl.displayName="MessageRow";const hl=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:h,style:m,emptyMessage:f,followNewMessages:v=!0,isNavigatingCheckpoint:g=!1,onScrollAway:x,onAtBottom:y,activeInterrupt:b,disableInterruptActions:S=!1,onInterruptActionStart:k,onInterruptActionEnd:C,showToolMessages:T=!0,showArtifactPreviews:E=!0,checkpointIndex:N,activeCheckpointId:R,onSelectCheckpoint:L,createSyntheticThinkingMessage:z=!0},V)=>{const U=w.useRef(null),j=w.useRef(null),W=w.useRef(!1),$=w.useRef(!1),[O,P]=w.useState(!0),I=w.useMemo(()=>b?e.some(F=>"type"in F&&F.type==="default_message"?!1:Array.isArray(F==null?void 0:F.content)&&F.content.some(ne=>ne&&ne.type==="interrupt"&&(ne.id??ne.interrupt_id)===b.id)):!1,[b,e]),q=w.useMemo(()=>{if(!b||I)return null;const F=b.id&&String(b.id).trim()?String(b.id).trim():"pending-interrupt";let ne;const de=b.value;if(de&&typeof de=="object"&&!Array.isArray(de)){const ce=de.title;typeof ce=="string"&&ce.trim()&&(ne=ce.trim())}return{id:`interrupt-${F}`,role:"system",createdAt:new Date().toISOString(),content:[{type:"interrupt",id:F,value:de,title:ne}]}},[b,I]),Y=w.useMemo(()=>q?[...e,q]:e,[e,q]),_=w.useMemo(()=>!z||!t?Y:!Y.some(ne=>ne.role==="assistant")&&Y.length>0?[...Y,{id:"thinking-assistant",role:"assistant",content:[],createdAt:new Date().toISOString(),__syntheticStreaming:!0}]:Y,[Y,t,z]),M=w.useMemo(()=>T?_:_.filter(F=>(F==null?void 0:F.role)!=="tool"),[_,T]),G=w.useCallback(F=>{P(F),x&&x(!F),y&&y(F)},[x,y]),J=w.useMemo(()=>{if(a)return async()=>{if(!W.current){W.current=!0;try{await a()}finally{W.current=!1}}}},[a]),oe=w.useMemo(()=>!v||g?!1:O?"auto":!1,[O,v,g]),K=w.useMemo(()=>{if(typeof f!="string")return null;const F=f.trim();return!F||M&&M.length>0?null:{id:"default-message",role:"assistant",type:"default_message",content:F,createdAt:new Date().toISOString()}},[f,M]),D=["flex h-full flex-col md:flex-row",h].filter(Boolean).join(" "),X=()=>K?u.jsx("div",{className:"p-6 h-full overflow-y-auto",children:u.jsx("div",{className:"w-full max-w-full",children:u.jsx(Ys,{message:K,messageIndex:0,isStreamingMessage:!1,showActions:!1,showTimestamp:!1,showAgentName:!0,layoutSize:o,onEdit:()=>{},onRegenerate:()=>{},onCancelEdit:()=>{},showArtifactPreviews:E})})}):u.jsx("div",{className:"flex h-full items-center justify-center py-8 text-center text-muted-foreground",children:f??"No messages yet. Start a conversation!"}),Z=M.length,ue=Z>0;return w.useEffect(()=>{var F,ne;if(Z===0){$.current=!1;return}if(!$.current)if($.current=!0,U.current&&M.length>0){const de=M.length-1;(ne=(F=U.current).scrollToIndex)==null||ne.call(F,{index:de,align:"end",behavior:"auto"})}else j.current&&(j.current.scrollTop=j.current.scrollHeight)},[Z,M.length]),w.useImperativeHandle(V,()=>({scrollToLatest:()=>{var F,ne;if(U.current&&M.length>0){const de=M.length-1;(ne=(F=U.current).scrollToIndex)==null||ne.call(F,{index:de,align:"end",behavior:"auto"})}else j.current&&(j.current.scrollTop=j.current.scrollHeight)},scrollToTop:()=>{var F,ne;U.current&&M.length>0?(ne=(F=U.current).scrollToIndex)==null||ne.call(F,{index:0,align:"start",behavior:"auto"}):j.current&&(j.current.scrollTop=0)}}),[M]),u.jsx("div",{className:D,style:m,children:u.jsx("div",{className:"relative flex-1 min-h-0",children:ue?u.jsx(LC,{ref:F=>{U.current=F},scrollerRef:F=>{j.current=F instanceof HTMLDivElement?F:null},data:M,followOutput:oe,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,startReached:()=>{J&&J()},atBottomStateChange:G,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(F,ne)=>dl(ne,F),itemContent:(F,ne)=>u.jsx(fl,{message:ne,index:F,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onEdit:l,onRegenerate:c,onCancelEdit:d,activeInterrupt:b,disableInterruptActions:S,onInterruptActionStart:k,onInterruptActionEnd:C,showToolMessages:T,showArtifactPreviews:E,checkpointIndex:N,activeCheckpointId:R,onSelectCheckpoint:L})}):X()})})});hl.displayName="MessageList";const Mp={value:""};function Rr({className:e="",placeholder:t="Type your message...",autoFocus:n=!0,maxHeight:r=void 0,streamingDebounceMs:o=500,streamingThrottleMs:s,followNewMessages:i=!0,enableFileUpload:a=!0,enableExcelUpload:l=!1,enableMessageEditing:c=!0,showToolMessages:d=!0,showArtifactPreviews:h=!0,customStyles:m={},onMessageSent:f,onExcelUploadSuccess:v,onError:g}){const{api:x}=Xr(),{currentThreadId:y}=gr(),{threadId:b,messages:S,isHistoryLoading:k,isLoading:C,navigateToCheckpoint:T,returnToLatest:E,checkpoint:N,checkpoints:R,interrupt:L,metadata:z,checkpointIndex:V}=eo(),{isStreaming:U,error:j,connectionState:W,submit:$,stop:O}=Li(),P=b??y??null,I=(N==null?void 0:N.id)??null,q=(N==null?void 0:N.namespace)??null,[Y,_]=w.useState(null),M=(z==null?void 0:z.assemblingMessageId)??(U&&Y?Y:null),G=L,[J,oe]=w.useState(!1);w.useEffect(()=>{G||oe(!1)},[G]);const K=w.useCallback(()=>{oe(!0)},[]),D=w.useCallback(()=>{oe(!1)},[]),X=!!G||J,[Z,ue]=w.useState(null),[F,ne]=w.useState(""),[de,ce]=w.useState(null),[ge,Ce]=w.useState(null),[Pe,De]=w.useState([]),[ze,rt]=w.useState(0),[Ct,Ve]=w.useState(0),[He,Ye]=w.useState(!1),[Le,Ue]=w.useState(null),[mt,Dt]=w.useState(null),[at,At]=w.useState(!1),[wt,dt]=w.useState(null),bt=w.useRef(!1),[Tt,jt]=w.useState(()=>Mp.value),Te=w.useRef(Tt),qe=w.useRef(null),Ee=w.useCallback(ie=>{Mp.value=ie,jt(ie)},[]),[Ke,zt]=w.useState(!1),re=w.useRef(null),be=w.useRef(null),ot=w.useRef(null),xe=w.useCallback(()=>{be.current&&(be.current.value=""),ot.current&&(ot.current.value=""),rt(ie=>ie+1),Ve(ie=>ie+1)},[]),Be=w.useCallback(ie=>{Ee(ie)},[Ee]),Xe=w.useRef(!1);w.useEffect(()=>{Xe.current&&!U&&(De([]),xe()),Xe.current=U},[U,xe]),w.useEffect(()=>{U||_(null)},[U]);const[kt,Et]=w.useState("desktop");w.useEffect(()=>{const ie=()=>{const fe=window.innerWidth;Et(fe<640?"phone":fe<1024?"tablet":"desktop")};return ie(),window.addEventListener("resize",ie),()=>window.removeEventListener("resize",ie)},[]),w.useEffect(()=>{bt.current=!1},[P]),w.useEffect(()=>{Te.current=Tt},[Tt]),w.useEffect(()=>{if(!Z){qe.current=null;return}qe.current===null&&(qe.current=Te.current),Ee(F??"")},[F,Z,Ee]),w.useEffect(()=>{(async()=>{if(!x.baseUrl){dt(null);return}try{const Ne=(await x.getAgent("default")).uiDefaultMessage||"";dt(Ne||null)}catch(fe){console.warn("Failed to fetch default message:",fe),dt(null)}})()},[x.baseUrl]),w.useEffect(()=>{j&&!at&&(g==null||g(j))},[j,at,g]);const Nt=async ie=>{const fe=ie.trim();if(!fe&&Pe.length===0)return;const Ne=Z;try{const Oe=Z?(de==null?void 0:de.checkpointId)??I??void 0:I??void 0,et=Z?(de==null?void 0:de.checkpointNs)??q??void 0:q??void 0;await $({text:fe||"",attachments:Pe},{checkpointId:Oe,checkpointNs:et,edit:!!Z,originalMessageId:Z??void 0}),f==null||f(fe),Ne&&_(Ne),Ee(""),Ce(null),De([]),xe(),ue(null),ne(""),ce(null)}catch(Oe){const et=(Oe==null?void 0:Oe.message)||"Failed to send message";Ce(et),g==null||g(et)}},Lt=w.useCallback((ie,fe,Ne)=>{c&&(qe.current=Tt,ue(ie),ne(fe),Ee(fe),Ce(null),ce({checkpointId:(Ne==null?void 0:Ne.checkpointId)??null,checkpointNs:(Ne==null?void 0:Ne.checkpointNs)??null}))},[Tt,c,Ee]),je=w.useCallback(()=>{ue(null),ne(""),ce(null),Ce(null),Ee(qe.current??Tt),qe.current=null,_(null)},[Tt,Ee]),ht=w.useCallback((ie,fe,Ne)=>{Lt(ie,fe,Ne)},[Lt]),Ze=w.useCallback(ie=>{let fe=null;for(let pt=ie-1;pt>=0;pt--)if(S[pt].role==="user"){fe=S[pt];break}if(!fe)return;const Ne=Array.isArray(fe.content)?fe.content:[],et=Ne.filter(pt=>(pt==null?void 0:pt.type)==="text").map(pt=>pt.text).join("")||(()=>{try{return JSON.stringify(Ne,null,2)}catch{return String(Ne)}})();et&&$({text:et},{checkpointId:I??void 0,checkpointNs:q??void 0,edit:!0,originalMessageId:fe.id})},[S,$,I,q]),ft=ie=>{const fe=Array.from(ie.target.files||[]);De(Ne=>[...Ne,...fe]),ie.target.value=""},an=ie=>{De(fe=>{const Ne=fe.filter((Oe,et)=>ie!==et);return Ne.length===0&&xe(),Ne})},A=async ie=>{const fe=(ie.target.files||[])[0];if(fe){Ue(null),Dt(null),Ye(!0);try{await $({attachments:[fe]},{checkpointId:I??void 0,checkpointNs:q??void 0});const Ne=`Uploaded ${fe.name} - processing through chat stream`;Dt(Ne)}catch(Ne){const Oe=Ne instanceof Error?Ne.message:"Failed to upload Excel file";console.error("Excel upload failed",Ne),Ue(Oe),g==null||g(Oe)}finally{Ye(!1),ie.target.value="",xe()}}},Q=async ie=>{if(y){zt(!0);try{if(!ie){await E(),requestAnimationFrame(()=>{var Oe;(Oe=re.current)==null||Oe.scrollToLatest()});return}const fe=R.find(Oe=>Oe.checkpointId===ie),Ne=(fe==null?void 0:fe.checkpointNs)??null;await T(ie,Ne),requestAnimationFrame(()=>{var Oe;(Oe=re.current)==null||Oe.scrollToTop()})}finally{zt(!1)}}},he=w.useCallback(async(ie,fe,Ne)=>{await Q(Ne?null:ie)},[Q]),Ie=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${m.container||""}`,Je=`flex-1 min-h-0 min-w-0 max-h-full w-full overflow-hidden overscroll-contain break-words break-anywhere p-4 bg-transparent ${m.messagesArea||""}`,nt=`relative flex-shrink-0 w-full border-t p-4 bg-transparent ${m.inputArea||""}`;return u.jsxs("div",{className:Ie,children:[!!j&&!at&&u.jsxs("div",{className:"flex-shrink-0 bg-red-50 border border-red-200 text-red-800 px-4 py-2 text-sm flex items-center justify-between",children:[u.jsx("span",{children:j}),u.jsx(tt,{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 ${Je}`,style:r?{maxHeight:r}:void 0,children:[u.jsx(hl,{ref:re,className:"h-full",style:{height:"100%"},messages:S,isStreaming:U,streamingAssistantId:M,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:kt,enableMessageEditing:c,editingMessageId:Z,onEdit:ht,onRegenerate:Ze,onCancelEdit:je,emptyMessage:wt??void 0,isNavigatingCheckpoint:Ke,activeInterrupt:G,disableInterruptActions:J,onInterruptActionStart:K,onInterruptActionEnd:D,showToolMessages:d,showArtifactPreviews:h,checkpointIndex:V,activeCheckpointId:I,onSelectCheckpoint:he,createSyntheticThinkingMessage:!0}),(W==="reconnecting"||W==="connecting")&&u.jsx("div",{className:"pointer-events-none absolute top-3 right-3 z-20 rounded-full bg-muted/80 px-3 py-1 text-xs font-medium text-foreground shadow-sm backdrop-blur-sm dark:bg-muted/60",children:u.jsxs("span",{className:"flex items-center gap-2",children:[u.jsx(le.Loader2,{className:"h-3 w-3 animate-spin"}),W==="reconnecting"?"Reconnecting…":"Connecting…"]})}),W==="error"&&u.jsx("div",{className:"pointer-events-none absolute top-3 right-3 z-20 rounded-full bg-destructive/10 px-3 py-1 text-xs font-semibold text-destructive shadow-sm",children:"Connection lost"}),C&&u.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 bg-background/80 backdrop-blur-sm text-muted-foreground",children:[u.jsx(le.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading messages…"})]}),(k||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…"})]})]}),u.jsxs("div",{className:nt,children:[Z&&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(tt,{variant:"ghost",size:"sm",onClick:je,className:"text-blue-600 hover:bg-blue-100",children:u.jsx(le.X,{size:16})})]})}),(a||l)&&u.jsxs("div",{className:"mb-3 space-y-3",children:[a&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:be,type:"file",multiple:!0,onChange:ie=>ft(ie),className:"hidden"},ze),Pe.length>0&&u.jsx("div",{className:"flex flex-wrap gap-2",children:Pe.map((ie,fe)=>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:ie.name}),u.jsx(tt,{variant:"ghost",size:"sm",onClick:()=>an(fe),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 ${ie.name}`,children:u.jsx(le.X,{size:12})})]},fe))})]}),l&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:ot,type:"file",accept:".xls,.xlsx,.xlsm",onChange:A,className:"hidden"},Ct),He&&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..."]}),mt&&!He&&u.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:mt}),Le&&!He&&u.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:Le})]})]}),ge&&u.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:ge}),u.jsxs("div",{className:"flex items-end gap-2",children:[(a||l)&&u.jsxs(Ss,{children:[u.jsx(Cs,{asChild:!0,children:u.jsx(tt,{type:"button",size:"icon",variant:"outline",disabled:U||X,title:"More input actions",className:m.moreButton||"",children:u.jsx(le.Plus,{size:16})})}),u.jsxs(ho,{align:"start",sideOffset:6,className:"w-52",children:[a&&u.jsxs(Bn,{onClick:()=>{var ie;return(ie=be.current)==null?void 0:ie.click()},className:"cursor-pointer",children:[u.jsx(le.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),l&&u.jsxs(Bn,{onClick:()=>{var ie;He||(ie=ot.current)==null||ie.click()},className:`cursor-pointer ${He?"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(IS,{initialValue:F,editingMessageId:Z,value:Tt,onValueChange:Be,placeholder:Z?"Edit your message...":t,isStreaming:U,disabled:X,onSend:Nt,onCancelEdit:je,onStop:O,allowEmptySend:Pe.length>0,textareaClassName:`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${Z?"border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50":""} ${ge?"border-red-400":""} ${m.textarea||""}`})})]})]})]})}var Rp=1,OT=.9,DT=.8,LT=.17,pl=.1,ml=.999,$T=.9999,FT=.99,BT=/[\\\/_+.#"@\[\(\{&]/,zT=/[\\\/_+.#"@\[\(\{&]/g,HT=/[\s-]/,Op=/[\s-]/g;function gl(e,t,n,r,o,s,i){if(s===t.length)return o===e.length?Rp:FT;var a=`${o},${s}`;if(i[a]!==void 0)return i[a];for(var l=r.charAt(s),c=n.indexOf(l,o),d=0,h,m,f,v;c>=0;)h=gl(e,t,n,r,c+1,s+1,i),h>d&&(c===o?h*=Rp:BT.test(e.charAt(c-1))?(h*=DT,f=e.slice(o,c-1).match(zT),f&&o>0&&(h*=Math.pow(ml,f.length))):HT.test(e.charAt(c-1))?(h*=OT,v=e.slice(o,c-1).match(Op),v&&o>0&&(h*=Math.pow(ml,v.length))):(h*=LT,o>0&&(h*=Math.pow(ml,c-o))),e.charAt(c)!==t.charAt(s)&&(h*=$T)),(h<pl&&n.charAt(c-1)===r.charAt(s+1)||r.charAt(s+1)===r.charAt(s)&&n.charAt(c-1)!==r.charAt(s))&&(m=gl(e,t,n,r,c+1,s+2,i),m*pl>h&&(h=m*pl)),h>d&&(d=h),c=n.indexOf(l,c+1);return i[a]=d,d}function Dp(e){return e.toLowerCase().replace(Op," ")}function UT(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,gl(e,t,Dp(e),Dp(t),0,0,{})}var Io='[cmdk-group=""]',xl='[cmdk-group-items=""]',WT='[cmdk-group-heading=""]',Lp='[cmdk-item=""]',$p=`${Lp}:not([aria-disabled="true"])`,vl="cmdk-item-select",Or="data-value",VT=(e,t,n)=>UT(e,t,n),Fp=p.createContext(void 0),No=()=>p.useContext(Fp),Bp=p.createContext(void 0),wl=()=>p.useContext(Bp),zp=p.createContext(void 0),Hp=p.forwardRef((e,t)=>{let n=Dr(()=>{var _,M;return{search:"",value:(M=(_=e.value)!=null?_:e.defaultValue)!=null?M:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=Dr(()=>new Set),o=Dr(()=>new Map),s=Dr(()=>new Map),i=Dr(()=>new Set),a=Up(e),{label:l,children:c,value:d,onValueChange:h,filter:m,shouldFilter:f,loop:v,disablePointerSelection:g=!1,vimBindings:x=!0,...y}=e,b=Pt(),S=Pt(),k=Pt(),C=p.useRef(null),T=nk();cr(()=>{if(d!==void 0){let _=d.trim();n.current.value=_,E.emit()}},[d]),cr(()=>{T(6,U)},[]);let E=p.useMemo(()=>({subscribe:_=>(i.current.add(_),()=>i.current.delete(_)),snapshot:()=>n.current,setState:(_,M,G)=>{var J,oe,K,D;if(!Object.is(n.current[_],M)){if(n.current[_]=M,_==="search")V(),L(),T(1,z);else if(_==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let X=document.getElementById(k);X?X.focus():(J=document.getElementById(b))==null||J.focus()}if(T(7,()=>{var X;n.current.selectedItemId=(X=j())==null?void 0:X.id,E.emit()}),G||T(5,U),((oe=a.current)==null?void 0:oe.value)!==void 0){let X=M??"";(D=(K=a.current).onValueChange)==null||D.call(K,X);return}}E.emit()}},emit:()=>{i.current.forEach(_=>_())}}),[]),N=p.useMemo(()=>({value:(_,M,G)=>{var J;M!==((J=s.current.get(_))==null?void 0:J.value)&&(s.current.set(_,{value:M,keywords:G}),n.current.filtered.items.set(_,R(M,G)),T(2,()=>{L(),E.emit()}))},item:(_,M)=>(r.current.add(_),M&&(o.current.has(M)?o.current.get(M).add(_):o.current.set(M,new Set([_]))),T(3,()=>{V(),L(),n.current.value||z(),E.emit()}),()=>{s.current.delete(_),r.current.delete(_),n.current.filtered.items.delete(_);let G=j();T(4,()=>{V(),(G==null?void 0:G.getAttribute("id"))===_&&z(),E.emit()})}),group:_=>(o.current.has(_)||o.current.set(_,new Set),()=>{s.current.delete(_),o.current.delete(_)}),filter:()=>a.current.shouldFilter,label:l||e["aria-label"],getDisablePointerSelection:()=>a.current.disablePointerSelection,listId:b,inputId:k,labelId:S,listInnerRef:C}),[]);function R(_,M){var G,J;let oe=(J=(G=a.current)==null?void 0:G.filter)!=null?J:VT;return _?oe(_,n.current.search,M):0}function L(){if(!n.current.search||a.current.shouldFilter===!1)return;let _=n.current.filtered.items,M=[];n.current.filtered.groups.forEach(J=>{let oe=o.current.get(J),K=0;oe.forEach(D=>{let X=_.get(D);K=Math.max(X,K)}),M.push([J,K])});let G=C.current;W().sort((J,oe)=>{var K,D;let X=J.getAttribute("id"),Z=oe.getAttribute("id");return((K=_.get(Z))!=null?K:0)-((D=_.get(X))!=null?D:0)}).forEach(J=>{let oe=J.closest(xl);oe?oe.appendChild(J.parentElement===oe?J:J.closest(`${xl} > *`)):G.appendChild(J.parentElement===G?J:J.closest(`${xl} > *`))}),M.sort((J,oe)=>oe[1]-J[1]).forEach(J=>{var oe;let K=(oe=C.current)==null?void 0:oe.querySelector(`${Io}[${Or}="${encodeURIComponent(J[0])}"]`);K==null||K.parentElement.appendChild(K)})}function z(){let _=W().find(G=>G.getAttribute("aria-disabled")!=="true"),M=_==null?void 0:_.getAttribute(Or);E.setState("value",M||void 0)}function V(){var _,M,G,J;if(!n.current.search||a.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let oe=0;for(let K of r.current){let D=(M=(_=s.current.get(K))==null?void 0:_.value)!=null?M:"",X=(J=(G=s.current.get(K))==null?void 0:G.keywords)!=null?J:[],Z=R(D,X);n.current.filtered.items.set(K,Z),Z>0&&oe++}for(let[K,D]of o.current)for(let X of D)if(n.current.filtered.items.get(X)>0){n.current.filtered.groups.add(K);break}n.current.filtered.count=oe}function U(){var _,M,G;let J=j();J&&(((_=J.parentElement)==null?void 0:_.firstChild)===J&&((G=(M=J.closest(Io))==null?void 0:M.querySelector(WT))==null||G.scrollIntoView({block:"nearest"})),J.scrollIntoView({block:"nearest"}))}function j(){var _;return(_=C.current)==null?void 0:_.querySelector(`${Lp}[aria-selected="true"]`)}function W(){var _;return Array.from(((_=C.current)==null?void 0:_.querySelectorAll($p))||[])}function $(_){let M=W()[_];M&&E.setState("value",M.getAttribute(Or))}function O(_){var M;let G=j(),J=W(),oe=J.findIndex(D=>D===G),K=J[oe+_];(M=a.current)!=null&&M.loop&&(K=oe+_<0?J[J.length-1]:oe+_===J.length?J[0]:J[oe+_]),K&&E.setState("value",K.getAttribute(Or))}function P(_){let M=j(),G=M==null?void 0:M.closest(Io),J;for(;G&&!J;)G=_>0?ek(G,Io):tk(G,Io),J=G==null?void 0:G.querySelector($p);J?E.setState("value",J.getAttribute(Or)):O(_)}let I=()=>$(W().length-1),q=_=>{_.preventDefault(),_.metaKey?I():_.altKey?P(1):O(1)},Y=_=>{_.preventDefault(),_.metaKey?$(0):_.altKey?P(-1):O(-1)};return p.createElement(ve.div,{ref:t,tabIndex:-1,...y,"cmdk-root":"",onKeyDown:_=>{var M;(M=y.onKeyDown)==null||M.call(y,_);let G=_.nativeEvent.isComposing||_.keyCode===229;if(!(_.defaultPrevented||G))switch(_.key){case"n":case"j":{x&&_.ctrlKey&&q(_);break}case"ArrowDown":{q(_);break}case"p":case"k":{x&&_.ctrlKey&&Y(_);break}case"ArrowUp":{Y(_);break}case"Home":{_.preventDefault(),$(0);break}case"End":{_.preventDefault(),I();break}case"Enter":{_.preventDefault();let J=j();if(J){let oe=new Event(vl);J.dispatchEvent(oe)}}}}},p.createElement("label",{"cmdk-label":"",htmlFor:N.inputId,id:N.labelId,style:ok},l),Xs(e,_=>p.createElement(Bp.Provider,{value:E},p.createElement(Fp.Provider,{value:N},_))))}),KT=p.forwardRef((e,t)=>{var n,r;let o=Pt(),s=p.useRef(null),i=p.useContext(zp),a=No(),l=Up(e),c=(r=(n=l.current)==null?void 0:n.forceMount)!=null?r:i==null?void 0:i.forceMount;cr(()=>{if(!c)return a.item(o,i==null?void 0:i.id)},[c]);let d=Wp(o,s,[e.value,e.children,s],e.keywords),h=wl(),m=qn(T=>T.value&&T.value===d.current),f=qn(T=>c||a.filter()===!1?!0:T.search?T.filtered.items.get(o)>0:!0);p.useEffect(()=>{let T=s.current;if(!(!T||e.disabled))return T.addEventListener(vl,v),()=>T.removeEventListener(vl,v)},[f,e.onSelect,e.disabled]);function v(){var T,E;g(),(E=(T=l.current).onSelect)==null||E.call(T,d.current)}function g(){h.setState("value",d.current,!0)}if(!f)return null;let{disabled:x,value:y,onSelect:b,forceMount:S,keywords:k,...C}=e;return p.createElement(ve.div,{ref:On(s,t),...C,id:o,"cmdk-item":"",role:"option","aria-disabled":!!x,"aria-selected":!!m,"data-disabled":!!x,"data-selected":!!m,onPointerMove:x||a.getDisablePointerSelection()?void 0:g,onClick:x?void 0:v},e.children)}),qT=p.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:o,...s}=e,i=Pt(),a=p.useRef(null),l=p.useRef(null),c=Pt(),d=No(),h=qn(f=>o||d.filter()===!1?!0:f.search?f.filtered.groups.has(i):!0);cr(()=>d.group(i),[]),Wp(i,a,[e.value,e.heading,l]);let m=p.useMemo(()=>({id:i,forceMount:o}),[o]);return p.createElement(ve.div,{ref:On(a,t),...s,"cmdk-group":"",role:"presentation",hidden:h?void 0:!0},n&&p.createElement("div",{ref:l,"cmdk-group-heading":"","aria-hidden":!0,id:c},n),Xs(e,f=>p.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?c:void 0},p.createElement(zp.Provider,{value:m},f))))}),GT=p.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,o=p.useRef(null),s=qn(i=>!i.search);return!n&&!s?null:p.createElement(ve.div,{ref:On(o,t),...r,"cmdk-separator":"",role:"separator"})}),YT=p.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,o=e.value!=null,s=wl(),i=qn(c=>c.search),a=qn(c=>c.selectedItemId),l=No();return p.useEffect(()=>{e.value!=null&&s.setState("search",e.value)},[e.value]),p.createElement(ve.input,{ref:t,...r,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":l.listId,"aria-labelledby":l.labelId,"aria-activedescendant":a,id:l.inputId,type:"text",value:o?e.value:i,onChange:c=>{o||s.setState("search",c.target.value),n==null||n(c.target.value)}})}),XT=p.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...o}=e,s=p.useRef(null),i=p.useRef(null),a=qn(c=>c.selectedItemId),l=No();return p.useEffect(()=>{if(i.current&&s.current){let c=i.current,d=s.current,h,m=new ResizeObserver(()=>{h=requestAnimationFrame(()=>{let f=c.offsetHeight;d.style.setProperty("--cmdk-list-height",f.toFixed(1)+"px")})});return m.observe(c),()=>{cancelAnimationFrame(h),m.unobserve(c)}}},[]),p.createElement(ve.div,{ref:On(s,t),...o,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":a,"aria-label":r,id:l.listId},Xs(e,c=>p.createElement("div",{ref:On(i,l.listInnerRef),"cmdk-list-sizer":""},c)))}),JT=p.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:o,contentClassName:s,container:i,...a}=e;return p.createElement(Ja,{open:n,onOpenChange:r},p.createElement(Za,{container:i},p.createElement(To,{"cmdk-overlay":"",className:o}),p.createElement(ko,{"aria-label":e.label,"cmdk-dialog":"",className:s},p.createElement(Hp,{ref:t,...a}))))}),ZT=p.forwardRef((e,t)=>qn(n=>n.filtered.count===0)?p.createElement(ve.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),QT=p.forwardRef((e,t)=>{let{progress:n,children:r,label:o="Loading...",...s}=e;return p.createElement(ve.div,{ref:t,...s,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":o},Xs(e,i=>p.createElement("div",{"aria-hidden":!0},i)))}),Kt=Object.assign(Hp,{List:XT,Item:KT,Input:YT,Group:qT,Separator:GT,Dialog:JT,Empty:ZT,Loading:QT});function ek(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function tk(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function Up(e){let t=p.useRef(e);return cr(()=>{t.current=e}),t}var cr=typeof window>"u"?p.useEffect:p.useLayoutEffect;function Dr(e){let t=p.useRef();return t.current===void 0&&(t.current=e()),t}function qn(e){let t=wl(),n=()=>e(t.snapshot());return p.useSyncExternalStore(t.subscribe,n,n)}function Wp(e,t,n,r=[]){let o=p.useRef(),s=No();return cr(()=>{var i;let a=(()=>{var c;for(let d of n){if(typeof d=="string")return d.trim();if(typeof d=="object"&&"current"in d)return d.current?(c=d.current.textContent)==null?void 0:c.trim():o.current}})(),l=r.map(c=>c.trim());s.value(e,a,l),(i=t.current)==null||i.setAttribute(Or,a),o.current=a}),o}var nk=()=>{let[e,t]=p.useState(),n=Dr(()=>new Map);return cr(()=>{n.current.forEach(r=>r()),n.current=new Map},[e]),(r,o)=>{n.current.set(r,o),t({})}};function rk(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function Xs({asChild:e,children:t},n){return e&&p.isValidElement(t)?p.cloneElement(rk(t),{ref:t.ref},n(t.props.children)):n(t)}var ok={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const bl=p.forwardRef(({className:e,...t},n)=>u.jsx(Kt,{ref:n,className:te("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));bl.displayName=Kt.displayName;const yl=p.forwardRef(({className:e,...t},n)=>u.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[u.jsx(le.Search,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),u.jsx(Kt.Input,{ref:n,className:te("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),...t})]}));yl.displayName=Kt.Input.displayName;const Sl=p.forwardRef(({className:e,...t},n)=>u.jsx(Kt.List,{ref:n,className:te("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));Sl.displayName=Kt.List.displayName;const Cl=p.forwardRef((e,t)=>u.jsx(Kt.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));Cl.displayName=Kt.Empty.displayName;const Tl=p.forwardRef(({className:e,...t},n)=>u.jsx(Kt.Group,{ref:n,className:te("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",e),...t}));Tl.displayName=Kt.Group.displayName;const sk=p.forwardRef(({className:e,...t},n)=>u.jsx(Kt.Separator,{ref:n,className:te("-mx-1 h-px bg-border",e),...t}));sk.displayName=Kt.Separator.displayName;const kl=p.forwardRef(({className:e,...t},n)=>u.jsx(Kt.Item,{ref:n,className:te("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected='true']:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50",e),...t}));kl.displayName=Kt.Item.displayName;function El(e,[t,n]){return Math.min(n,Math.max(t,e))}function ik(e,t){return p.useReducer((n,r)=>t[n][r]??n,e)}var Il="ScrollArea",[Vp,CN]=cn(Il),[ak,sn]=Vp(Il),Kp=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,l]=p.useState(null),[c,d]=p.useState(null),[h,m]=p.useState(null),[f,v]=p.useState(null),[g,x]=p.useState(null),[y,b]=p.useState(0),[S,k]=p.useState(0),[C,T]=p.useState(!1),[E,N]=p.useState(!1),R=$e(t,z=>l(z)),L=Xo(o);return u.jsx(ak,{scope:n,type:r,dir:L,scrollHideDelay:s,scrollArea:a,viewport:c,onViewportChange:d,content:h,onContentChange:m,scrollbarX:f,onScrollbarXChange:v,scrollbarXEnabled:C,onScrollbarXEnabledChange:T,scrollbarY:g,onScrollbarYChange:x,scrollbarYEnabled:E,onScrollbarYEnabledChange:N,onCornerWidthChange:b,onCornerHeightChange:k,children:u.jsx(ve.div,{dir:L,...i,ref:R,style:{position:"relative","--radix-scroll-area-corner-width":y+"px","--radix-scroll-area-corner-height":S+"px",...e.style}})})});Kp.displayName=Il;var qp="ScrollAreaViewport",Gp=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=sn(qp,n),a=p.useRef(null),l=$e(t,a,i.onViewportChange);return u.jsxs(u.Fragment,{children:[u.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:o}),u.jsx(ve.div,{"data-radix-scroll-area-viewport":"",...s,ref:l,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:u.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});Gp.displayName=qp;var In="ScrollAreaScrollbar",Nl=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=sn(In,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:i}=o,a=e.orientation==="horizontal";return p.useEffect(()=>(a?s(!0):i(!0),()=>{a?s(!1):i(!1)}),[a,s,i]),o.type==="hover"?u.jsx(lk,{...r,ref:t,forceMount:n}):o.type==="scroll"?u.jsx(ck,{...r,ref:t,forceMount:n}):o.type==="auto"?u.jsx(Yp,{...r,ref:t,forceMount:n}):o.type==="always"?u.jsx(Al,{...r,ref:t}):null});Nl.displayName=In;var lk=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=sn(In,e.__scopeScrollArea),[s,i]=p.useState(!1);return p.useEffect(()=>{const a=o.scrollArea;let l=0;if(a){const c=()=>{window.clearTimeout(l),i(!0)},d=()=>{l=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",c),a.addEventListener("pointerleave",d),()=>{window.clearTimeout(l),a.removeEventListener("pointerenter",c),a.removeEventListener("pointerleave",d)}}},[o.scrollArea,o.scrollHideDelay]),u.jsx(Wt,{present:n||s,children:u.jsx(Yp,{"data-state":s?"visible":"hidden",...r,ref:t})})}),ck=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=sn(In,e.__scopeScrollArea),s=e.orientation==="horizontal",i=ei(()=>l("SCROLL_END"),100),[a,l]=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 p.useEffect(()=>{if(a==="idle"){const c=window.setTimeout(()=>l("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(c)}},[a,o.scrollHideDelay,l]),p.useEffect(()=>{const c=o.viewport,d=s?"scrollLeft":"scrollTop";if(c){let h=c[d];const m=()=>{const f=c[d];h!==f&&(l("SCROLL"),i()),h=f};return c.addEventListener("scroll",m),()=>c.removeEventListener("scroll",m)}},[o.viewport,s,l,i]),u.jsx(Wt,{present:n||a!=="hidden",children:u.jsx(Al,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:ae(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:ae(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),Yp=p.forwardRef((e,t)=>{const n=sn(In,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=p.useState(!1),a=e.orientation==="horizontal",l=ei(()=>{if(n.viewport){const c=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?c:d)}},10);return Lr(n.viewport,l),Lr(n.content,l),u.jsx(Wt,{present:r||s,children:u.jsx(Al,{"data-state":s?"visible":"hidden",...o,ref:t})})}),Al=p.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=sn(In,e.__scopeScrollArea),s=p.useRef(null),i=p.useRef(0),[a,l]=p.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),c=em(a.viewport,a.content),d={...r,sizes:a,onSizesChange:l,hasThumb:c>0&&c<1,onThumbChange:m=>s.current=m,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:m=>i.current=m};function h(m,f){return mk(m,i.current,a,f)}return n==="horizontal"?u.jsx(uk,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollLeft,f=tm(m,a,o.dir);s.current.style.transform=`translate3d(${f}px, 0, 0)`}},onWheelScroll:m=>{o.viewport&&(o.viewport.scrollLeft=m)},onDragScroll:m=>{o.viewport&&(o.viewport.scrollLeft=h(m,o.dir))}}):n==="vertical"?u.jsx(dk,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollTop,f=tm(m,a);s.current.style.transform=`translate3d(0, ${f}px, 0)`}},onWheelScroll:m=>{o.viewport&&(o.viewport.scrollTop=m)},onDragScroll:m=>{o.viewport&&(o.viewport.scrollTop=h(m))}}):null}),uk=p.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=sn(In,e.__scopeScrollArea),[i,a]=p.useState(),l=p.useRef(null),c=$e(t,l,s.onScrollbarXChange);return p.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(Jp,{"data-orientation":"horizontal",...o,ref:c,sizes:n,style:{bottom:0,left:s.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:s.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":Qs(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.x),onDragScroll:d=>e.onDragScroll(d.x),onWheelScroll:(d,h)=>{if(s.viewport){const m=s.viewport.scrollLeft+d.deltaX;e.onWheelScroll(m),rm(m,h)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:l.current.clientWidth,paddingStart:Zs(i.paddingLeft),paddingEnd:Zs(i.paddingRight)}})}})}),dk=p.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=sn(In,e.__scopeScrollArea),[i,a]=p.useState(),l=p.useRef(null),c=$e(t,l,s.onScrollbarYChange);return p.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(Jp,{"data-orientation":"vertical",...o,ref:c,sizes:n,style:{top:0,right:s.dir==="ltr"?0:void 0,left:s.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":Qs(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.y),onDragScroll:d=>e.onDragScroll(d.y),onWheelScroll:(d,h)=>{if(s.viewport){const m=s.viewport.scrollTop+d.deltaY;e.onWheelScroll(m),rm(m,h)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:l.current.clientHeight,paddingStart:Zs(i.paddingTop),paddingEnd:Zs(i.paddingBottom)}})}})}),[fk,Xp]=Vp(In),Jp=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:l,onDragScroll:c,onWheelScroll:d,onResize:h,...m}=e,f=sn(In,n),[v,g]=p.useState(null),x=$e(t,R=>g(R)),y=p.useRef(null),b=p.useRef(""),S=f.viewport,k=r.content-r.viewport,C=xt(d),T=xt(l),E=ei(h,10);function N(R){if(y.current){const L=R.clientX-y.current.left,z=R.clientY-y.current.top;c({x:L,y:z})}}return p.useEffect(()=>{const R=L=>{const z=L.target;(v==null?void 0:v.contains(z))&&C(L,k)};return document.addEventListener("wheel",R,{passive:!1}),()=>document.removeEventListener("wheel",R,{passive:!1})},[S,v,k,C]),p.useEffect(T,[r,T]),Lr(v,E),Lr(f.content,E),u.jsx(fk,{scope:n,scrollbar:v,hasThumb:o,onThumbChange:xt(s),onThumbPointerUp:xt(i),onThumbPositionChange:T,onThumbPointerDown:xt(a),children:u.jsx(ve.div,{...m,ref:x,style:{position:"absolute",...m.style},onPointerDown:ae(e.onPointerDown,R=>{R.button===0&&(R.target.setPointerCapture(R.pointerId),y.current=v.getBoundingClientRect(),b.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",f.viewport&&(f.viewport.style.scrollBehavior="auto"),N(R))}),onPointerMove:ae(e.onPointerMove,N),onPointerUp:ae(e.onPointerUp,R=>{const L=R.target;L.hasPointerCapture(R.pointerId)&&L.releasePointerCapture(R.pointerId),document.body.style.webkitUserSelect=b.current,f.viewport&&(f.viewport.style.scrollBehavior=""),y.current=null})})})}),Js="ScrollAreaThumb",Zp=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Xp(Js,e.__scopeScrollArea);return u.jsx(Wt,{present:n||o.hasThumb,children:u.jsx(hk,{ref:t,...r})})}),hk=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=sn(Js,n),i=Xp(Js,n),{onThumbPositionChange:a}=i,l=$e(t,h=>i.onThumbChange(h)),c=p.useRef(void 0),d=ei(()=>{c.current&&(c.current(),c.current=void 0)},100);return p.useEffect(()=>{const h=s.viewport;if(h){const m=()=>{if(d(),!c.current){const f=gk(h,a);c.current=f,a()}};return a(),h.addEventListener("scroll",m),()=>h.removeEventListener("scroll",m)}},[s.viewport,d,a]),u.jsx(ve.div,{"data-state":i.hasThumb?"visible":"hidden",...o,ref:l,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:ae(e.onPointerDownCapture,h=>{const f=h.target.getBoundingClientRect(),v=h.clientX-f.left,g=h.clientY-f.top;i.onThumbPointerDown({x:v,y:g})}),onPointerUp:ae(e.onPointerUp,i.onThumbPointerUp)})});Zp.displayName=Js;var jl="ScrollAreaCorner",Qp=p.forwardRef((e,t)=>{const n=sn(jl,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?u.jsx(pk,{...e,ref:t}):null});Qp.displayName=jl;var pk=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=sn(jl,n),[s,i]=p.useState(0),[a,l]=p.useState(0),c=!!(s&&a);return Lr(o.scrollbarX,()=>{var h;const d=((h=o.scrollbarX)==null?void 0:h.offsetHeight)||0;o.onCornerHeightChange(d),l(d)}),Lr(o.scrollbarY,()=>{var h;const d=((h=o.scrollbarY)==null?void 0:h.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),c?u.jsx(ve.div,{...r,ref:t,style:{width:s,height:a,position:"absolute",right:o.dir==="ltr"?0:void 0,left:o.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function Zs(e){return e?parseInt(e,10):0}function em(e,t){const n=e/t;return isNaN(n)?0:n}function Qs(e){const t=em(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function mk(e,t,n,r="ltr"){const o=Qs(n),s=o/2,i=t||s,a=o-i,l=n.scrollbar.paddingStart+i,c=n.scrollbar.size-n.scrollbar.paddingEnd-a,d=n.content-n.viewport,h=r==="ltr"?[0,d]:[d*-1,0];return nm([l,c],h)(e)}function tm(e,t,n="ltr"){const r=Qs(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,s=t.scrollbar.size-o,i=t.content-t.viewport,a=s-r,l=n==="ltr"?[0,i]:[i*-1,0],c=El(e,l);return nm([0,i],[0,a])(c)}function nm(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function rm(e,t){return e>0&&e<t}var gk=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return function o(){const s={left:e.scrollLeft,top:e.scrollTop},i=n.left!==s.left,a=n.top!==s.top;(i||a)&&t(),n=s,r=window.requestAnimationFrame(o)}(),()=>window.cancelAnimationFrame(r)};function ei(e,t){const n=xt(e),r=p.useRef(0);return p.useEffect(()=>()=>window.clearTimeout(r.current),[]),p.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function Lr(e,t){const n=xt(t);It(()=>{let r=0;if(e){const o=new ResizeObserver(()=>{cancelAnimationFrame(r),r=window.requestAnimationFrame(n)});return o.observe(e),()=>{window.cancelAnimationFrame(r),o.unobserve(e)}}},[e,n])}var om=Kp,xk=Gp,vk=Qp;const _l=p.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(om,{ref:r,className:te("relative overflow-hidden",e),...n,children:[u.jsx(xk,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),u.jsx(sm,{}),u.jsx(vk,{})]}));_l.displayName=om.displayName;const sm=p.forwardRef(({className:e,orientation:t="vertical",...n},r)=>u.jsx(Nl,{ref:r,orientation:t,className:te("flex touch-none select-none transition-colors",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...n,children:u.jsx(Zp,{className:"relative flex-1 rounded-full bg-border"})}));sm.displayName=Nl.displayName;const Pl=p.forwardRef(({className:e,type:t,...n},r)=>u.jsx("input",{type:t,className:te("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:r,...n}));Pl.displayName="Input";const wk="group relative p-3 rounded-lg cursor-pointer transition-colors border text-gray-900 dark:text-slate-100",bk="bg-slate-700 border-slate-600 hover:bg-slate-600",yk="bg-slate-600 border-slate-500";function im({thread:e,isActive:t,editingThreadId:n,editingTitle:r,onSelect:o,onStartEditing:s,onEditingTitleChange:i,onSaveEditing:a,onCancelEditing:l,onShare:c,onDelete:d,showEditTitle:h,showDeleteButton:m,formatDate:f,getDisplayThreadTitle:v,secondaryLine:g,itemClassName:x,activeItemClassName:y}){const b=n===e.threadId,S=t?`${y??yk}`:`${x??bk}`,k=C=>{C.stopPropagation(),o(e.threadId)};return u.jsxs("div",{onClick:k,className:`${wk} ${S}`,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:C=>C.stopPropagation(),children:[u.jsx(Pl,{value:r,onChange:C=>i(C.target.value),onKeyDown:C=>{C.key==="Enter"?a(e.threadId):C.key==="Escape"&&l()},className:"h-6 text-sm",autoFocus:!0}),u.jsx(tt,{variant:"ghost",size:"sm",onClick:()=>a(e.threadId),className:"h-6 w-6 p-0",children:u.jsx(le.Check,{size:12})}),u.jsx(tt,{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(Ss,{children:[u.jsx(Cs,{asChild:!0,children:u.jsx(tt,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",children:u.jsx(le.MoreHorizontal,{size:12})})}),u.jsxs(ho,{align:"end",sideOffset:6,className:"w-44",children:[u.jsxs(Bn,{onClick:C=>{C.preventDefault(),c(e.threadId)},children:[u.jsx(le.Share2,{className:"mr-2 h-4 w-4"}),"Share thread"]}),h&&n!==e.threadId&&u.jsxs(Bn,{onClick:C=>{C.preventDefault(),s(e,C)},children:[u.jsx(le.Edit3,{className:"mr-2 h-4 w-4"}),"Rename"]}),m&&d&&u.jsxs(Bn,{className:"text-red-400 hover:text-red-300",onClick:C=>{C.preventDefault(),d(e.threadId,C)},children:[u.jsx(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 am=25,lm="thread-manager-view",Sk=e=>e==="default"||e==="shared",Ck=()=>{if(typeof window>"u")return null;try{const e=window.localStorage.getItem(lm);if(Sk(e))return e}catch{}return null};function cm({defaultView:e}={}){const[t,n]=w.useState(()=>Ck()??e??"default");w.useEffect(()=>{if(!(typeof window>"u"))try{window.localStorage.setItem(lm,t)}catch{}},[t]);const r=w.useCallback(o=>{n(o)},[]);return{view:t,setView:r}}const Tk=[{key:"default",label:"My chats"},{key:"shared",label:"Shared with you"}];function ti({className:e="",showCreateButton:t=!0,showDeleteButton:n=!0,showEditTitle:r=!0,maxHeight:o="400px",customStyles:s={},currentThreadId:i=null,navigateToThread:a,onThreadSelect:l,onThreadCreate:c,onThreadDelete:d,view:h,defaultView:m,onViewChange:f,viewOptions:v,viewState:g,showHeader:x=!0,shareTargets:y,isLoadingShareTargets:b,shareTargetFilter:S}){const{threads:k,sharedThreads:C,currentThreadId:T,setCurrentThreadId:E,isLoading:N,isLoadingSharedThreads:R,actions:L,shareInFlight:z,shareStatus:V,clearShareStatus:U}=gr(),{createThread:j,deleteThread:W,renameThread:$,shareThread:O}=L,{loadThread:P}=eo(),I=i??T,[q,Y]=w.useState(Array.isArray(k)?k:[]),_=w.useRef(q.length>0),M=w.useRef(null),G=w.useRef(0),[J,oe]=w.useState(null),[K,D]=w.useState(""),[X,Z]=w.useState(!1),[ue,F]=w.useState(!1),[ne,de]=w.useState(null),[ce,ge]=w.useState(""),Ce=v&&v.length>0?v:Tk,Pe=cm({defaultView:m}),De=g??Pe,ze=h??De.view,rt=w.useCallback(re=>{h||De.setView(re),f==null||f(re)},[h,f,De]),Ct=Ce.find(re=>re.key===ze)??Ce[0],Ve=re=>{de(re),ge(""),F(!0)},He=()=>{F(!1),de(null),ge(""),U()},Ye=w.useCallback(async re=>{if(!(!ne||z)&&re.id)try{await O(ne,re.id),setTimeout(()=>He(),600)}catch(be){console.error("Failed to share thread:",be)}},[He,z,ne,O]),Le=w.useMemo(()=>{const re=y??[],be=ce.trim().toLowerCase();return be?S?re.filter(ot=>S(ot,be)):re.filter(ot=>`${ot.label} ${ot.secondaryLabel??""}`.toLowerCase().includes(be)):re},[y,ce,S]),Ue=ze==="shared",mt=Ue?C:q,Dt=Ue?R:N,at=Ue?"No shared conversations yet":"No conversations yet",At=re=>{const be=re.sharedAt?` • ${Ee(re.sharedAt)}`:"";return`Shared by ${re.sharedByUserId}${be}`},wt=re=>"sharedByUserId"in re;w.useEffect(()=>{const re=Array.isArray(k)?k:[];if(re.length>0){_.current=!0,Y(re);return}N||(_.current=!1,Y(re))},[k,N]),w.useEffect(()=>{if(!M.current)return;const re=M.current.querySelector("[data-radix-scroll-area-viewport]");if(!re)return;let be=null,ot=null;return be=requestAnimationFrame(()=>{ot=requestAnimationFrame(()=>{re.scrollTop=G.current})}),()=>{be!==null&&cancelAnimationFrame(be),ot!==null&&cancelAnimationFrame(ot)}},[q]);const dt=async re=>{try{E(re),await P(re),a==null||a(re),l==null||l(re)}catch(be){console.error("Failed to select thread:",be)}},bt=async()=>{try{Z(!0);const re=await j();re&&(c==null||c(re),a==null||a(re))}catch(re){console.error("Failed to create thread:",re)}finally{Z(!1)}},Tt=async(re,be)=>{if(be.stopPropagation(),!!confirm("Delete this thread?")){if(M.current){const ot=M.current.querySelector("[data-radix-scroll-area-viewport]");ot&&(G.current=ot.scrollTop)}try{await W(re),d==null||d(re)}catch(ot){console.error("Failed to delete thread:",ot)}}},jt=(re,be)=>{be.stopPropagation(),oe(re.threadId),D(re.title||`Thread ${re.threadId.slice(0,8)}`)},Te=async re=>{if(K.trim())try{await $(re,K.trim()),oe(null),D("")}catch(be){console.error("Failed to update title:",be)}},qe=()=>{oe(null),D("")},Ee=re=>{if(!re)return"";try{const be=new Date(re),xe=new Date().getTime()-be.getTime(),Be=Math.floor(xe/(1e3*60*60*24));return Be===0?be.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):Be===1?"Yesterday":Be<7?`${Be} days ago`:be.toLocaleDateString()}catch{return""}},Ke=re=>re.title||`Thread ${re.threadId.slice(0,8)}`,zt=re=>{const be=Ke(re);return be.length<=am?be:`${be.slice(0,am)}...`};return u.jsxs("div",{className:`flex flex-col h-full ${e} ${s.container||""}`,children:[x&&u.jsxs("div",{className:s.header||"flex flex-col gap-2 px-1 py-0 border border-slate-200 bg-white dark:border-slate-700 dark:bg-slate-900 shadow-sm",children:[t&&u.jsx("div",{className:"flex justify-end",children:u.jsxs(tt,{onClick:bt,disabled:X||N,className:s.createButton||"px-3 py-2 gap-1",size:"sm",variant:"ghost",title:X?"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(Ss,{children:[u.jsx(Cs,{asChild:!0,children:u.jsx(tt,{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:Ct.label})}),u.jsx(ho,{align:"start",sideOffset:6,className:"w-40",children:Ce.map(re=>u.jsxs(Bn,{className:"justify-between text-[12px]",onClick:be=>{be.preventDefault(),rt(re.key)},children:[u.jsx("span",{children:re.label}),ze===re.key&&u.jsx(le.Check,{className:"h-3 w-3"})]},re.key))})]})]})]}),u.jsx(_l,{ref:M,className:`flex-1 min-h-0 ${s.threadList||""}`,style:o?{maxHeight:o}:void 0,children:u.jsx("div",{className:"p-2 space-y-1 pb-4",children: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…"})]}):mt.length===0?u.jsxs("div",{className:"text-center py-8 text-slate-400",children:[u.jsx(le.MessageSquare,{className:"w-8 h-8 mx-auto mb-2 opacity-40 text-slate-500"}),u.jsx("p",{className:"text-sm text-slate-500",children:at})]}):mt.slice().sort((re,be)=>new Date(be.updatedAt||be.createdAt||"").getTime()-new Date(re.updatedAt||re.createdAt||"").getTime()).map(re=>u.jsx(im,{thread:re,isActive:I===re.threadId,editingThreadId:J,editingTitle:K,onSelect:dt,onStartEditing:jt,onEditingTitleChange:be=>D(be),onSaveEditing:Te,onCancelEditing:qe,onShare:()=>Ve(re.threadId),onDelete:Tt,showEditTitle:r,showDeleteButton:n,formatDate:Ee,getDisplayThreadTitle:zt,secondaryLine:Ue&&wt(re)?At(re):void 0,itemClassName:s.threadItem,activeItemClassName:s.activeThread},re.threadId))})}),u.jsx(Qa,{open:ue,onOpenChange:re=>!re&&He(),children:u.jsxs(Bs,{className:"max-w-md p-0",children:[u.jsx(zs,{children:u.jsx(Hs,{children:"Share thread"})}),u.jsxs(bl,{children:[u.jsx(yl,{autoFocus:!0,value:ce,onValueChange:re=>ge(re),placeholder:"Search for recipients..."}),u.jsxs(Sl,{children:[V&&u.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-xs text-muted-foreground",children:[z&&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(Cl,{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"}),Le.length>0&&u.jsx(Tl,{heading:"Recipients",children:Le.map(re=>u.jsx(kl,{onSelect:()=>Ye(re),children:u.jsxs("div",{className:"flex flex-col items-start text-sm",children:[u.jsx("span",{className:"font-medium",children:re.label}),re.secondaryLabel&&u.jsx("span",{className:"text-xs text-muted-foreground",children:re.secondaryLabel})]})},re.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(vr,{...s,onThreadChange:l,children:u.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:u.jsx(Rr,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?u.jsx(vr,{...s,onThreadChange:l,children:u.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:u.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[n&&u.jsx("div",{className:`w-80 border-r flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:u.jsx(ti,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),u.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:u.jsx(Rr,{onError:s.onError,enableFileUpload:!0})})]})})}):u.jsx(vr,{...s,onThreadChange:l,children:u.jsxs("div",{className:`${i(t)} flex overflow-hidden ${r} ${o.container||""}`,style:a(t),children:[n&&u.jsx("div",{className:`w-80 border-r bg-gray-50 flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:u.jsx(ti,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),u.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:u.jsx(Rr,{onError:s.onError,enableFileUpload:!0})})]})})}function Ek({apiConfig:e,className:t="",onError:n}){return u.jsx(vr,{apiConfig:e,onError:n,children:u.jsx("div",{className:`h-full ${t}`,children:u.jsx(Rr,{})})})}function Ik({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(Rr,{placeholder:e??"Ask Serti AI anything...",autoFocus:!0,className:"h-full",onMessageSent:t}):u.jsx(ti,{showCreateButton:!0,className:"h-full",onThreadSelect:()=>r("chat")})})]})}function Nk({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(vr,{...i,children:u.jsx("div",{className:`fixed bottom-6 right-6 z-[9999] transition-all duration-300 ${e}`,children:u.jsxs("div",{className:`w-96 bg-white rounded-xl shadow-2xl border border-gray-200 overflow-hidden relative ${a?"scale-75":"scale-100"}`,children:[u.jsx("div",{className:"bg-slate-800 text-white p-4 flex-shrink-0",children:u.jsxs("div",{className:"flex items-center justify-between gap-3",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsxs("div",{className:"relative h-10 w-10 rounded-full bg-gradient-to-br from-slate-500 to-slate-700 border border-white/30 flex items-center justify-center text-white text-sm font-bold",children:["S",u.jsx("span",{className:"absolute -bottom-0.5 -right-0.5 h-3 w-3 rounded-full border-2 border-slate-800 bg-emerald-400"})]}),u.jsxs("div",{className:"flex flex-col",children:[u.jsx("h3",{className:"text-lg font-semibold leading-tight",children:o}),u.jsx("p",{className:"text-xs text-white/70",children:s})]}),u.jsx("span",{className:"ml-2 inline-flex items-center justify-center rounded-full bg-red-500 px-2 py-0.5 text-[11px] font-semibold leading-none text-white",children:"1"})]}),u.jsxs("div",{className:"flex items-center gap-1",children:[u.jsx(tt,{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(tt,{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(tt,{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(Ik,{placeholder:t,onMessageSent:r})})]})})}):null}function Ak({label:e="New chat",children:t,className:n,variant:r="ghost",size:o="sm",...s}){return u.jsxs(tt,{variant:r,size:o,className:te("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",um=p.forwardRef((e,t)=>u.jsx(ve.label,{...e,ref:t,onMouseDown:n=>{var o;n.target.closest("button, input, select, textarea")||((o=e.onMouseDown)==null||o.call(e,n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));um.displayName=jk;var dm=um;const _k=zr.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),fm=p.forwardRef(({className:e,...t},n)=>u.jsx(dm,{ref:n,className:te(_k(),e),...t}));fm.displayName=dm.displayName;function hm(e){const t=p.useRef({value:e,previous:e});return p.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var pm=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),Pk="VisuallyHidden",ni=p.forwardRef((e,t)=>u.jsx(ve.span,{...e,ref:t,style:{...pm,...e.style}}));ni.displayName=Pk;var Mk=ni,Rk=[" ","Enter","ArrowUp","ArrowDown"],Ok=[" ","Enter"],ur="Select",[ri,oi,Dk]=Yo(ur),[$r,TN]=cn(ur,[Dk,kr]),si=kr(),[Lk,Gn]=$r(ur),[$k,Fk]=$r(ur),mm=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:l,dir:c,name:d,autoComplete:h,disabled:m,required:f,form:v}=e,g=si(t),[x,y]=p.useState(null),[b,S]=p.useState(null),[k,C]=p.useState(!1),T=Xo(c),[E,N]=Dn({prop:r,defaultProp:o??!1,onChange:s,caller:ur}),[R,L]=Dn({prop:i,defaultProp:a,onChange:l,caller:ur}),z=p.useRef(null),V=x?v||!!x.closest("form"):!0,[U,j]=p.useState(new Set),W=Array.from(U).map($=>$.props.value).join(";");return u.jsx(oa,{...g,children:u.jsxs(Lk,{required:f,scope:t,trigger:x,onTriggerChange:y,valueNode:b,onValueNodeChange:S,valueNodeHasChildren:k,onValueNodeHasChildrenChange:C,contentId:Pt(),value:R,onValueChange:L,open:E,onOpenChange:N,dir:T,triggerPointerDownPosRef:z,disabled:m,children:[u.jsx(ri.Provider,{scope:t,children:u.jsx($k,{scope:e.__scopeSelect,onNativeOptionAdd:p.useCallback($=>{j(O=>new Set(O).add($))},[]),onNativeOptionRemove:p.useCallback($=>{j(O=>{const P=new Set(O);return P.delete($),P})},[]),children:n})}),V?u.jsxs(Fm,{"aria-hidden":!0,required:f,tabIndex:-1,name:d,autoComplete:h,value:R,onChange:$=>L($.target.value),disabled:m,form:v,children:[R===void 0?u.jsx("option",{value:""}):null,Array.from(U)]},W):null]})})};mm.displayName=ur;var gm="SelectTrigger",xm=p.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=si(n),i=Gn(gm,n),a=i.disabled||r,l=$e(t,i.onTriggerChange),c=oi(n),d=p.useRef("touch"),[h,m,f]=zm(g=>{const x=c().filter(S=>!S.disabled),y=x.find(S=>S.value===i.value),b=Hm(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(sa,{asChild:!0,...s,children:u.jsx(ve.button,{type:"button",role:"combobox","aria-controls":i.contentId,"aria-expanded":i.open,"aria-required":i.required,"aria-autocomplete":"none",dir:i.dir,"data-state":i.open?"open":"closed",disabled:a,"data-disabled":a?"":void 0,"data-placeholder":Bm(i.value)?"":void 0,...o,ref:l,onClick: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=h.current!=="";!(g.ctrlKey||g.altKey||g.metaKey)&&g.key.length===1&&m(g.key),!(x&&g.key===" ")&&Rk.includes(g.key)&&(v(),g.preventDefault())})})})});xm.displayName=gm;var vm="SelectValue",wm=p.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=Gn(vm,n),{onValueNodeHasChildrenChange:c}=l,d=s!==void 0,h=$e(t,l.onValueNodeChange);return It(()=>{c(d)},[c,d]),u.jsx(ve.span,{...a,ref:h,style:{pointerEvents:"none"},children:Bm(l.value)?u.jsx(u.Fragment,{children:i}):s})});wm.displayName=vm;var Bk="SelectIcon",bm=p.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return u.jsx(ve.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});bm.displayName=Bk;var zk="SelectPortal",ym=e=>u.jsx(so,{asChild:!0,...e});ym.displayName=zk;var dr="SelectContent",Sm=p.forwardRef((e,t)=>{const n=Gn(dr,e.__scopeSelect),[r,o]=p.useState();if(It(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?Hr.createPortal(u.jsx(Cm,{scope:e.__scopeSelect,children:u.jsx(ri.Slot,{scope:e.__scopeSelect,children:u.jsx("div",{children:e.children})})}),s):null}return u.jsx(Tm,{...e,ref:t})});Sm.displayName=dr;var mn=10,[Cm,Yn]=$r(dr),Hk="SelectContentImpl",Uk=Yt.createSlot("SelectContent.RemoveScroll"),Tm=p.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:h,collisionBoundary:m,collisionPadding:f,sticky:v,hideWhenDetached:g,avoidCollisions:x,...y}=e,b=Gn(dr,n),[S,k]=p.useState(null),[C,T]=p.useState(null),E=$e(t,K=>k(K)),[N,R]=p.useState(null),[L,z]=p.useState(null),V=oi(n),[U,j]=p.useState(!1),W=p.useRef(!1);p.useEffect(()=>{if(S)return da(S)},[S]),Hi();const $=p.useCallback(K=>{const[D,...X]=V().map(F=>F.ref.current),[Z]=X.slice(-1),ue=document.activeElement;for(const F of K)if(F===ue||(F==null||F.scrollIntoView({block:"nearest"}),F===D&&C&&(C.scrollTop=0),F===Z&&C&&(C.scrollTop=C.scrollHeight),F==null||F.focus(),document.activeElement!==ue))return},[V,C]),O=p.useCallback(()=>$([N,S]),[$,N,S]);p.useEffect(()=>{U&&O()},[U,O]);const{onOpenChange:P,triggerPointerDownPosRef:I}=b;p.useEffect(()=>{if(S){let K={x:0,y:0};const D=Z=>{var ue,F;K={x:Math.abs(Math.round(Z.pageX)-(((ue=I.current)==null?void 0:ue.x)??0)),y:Math.abs(Math.round(Z.pageY)-(((F=I.current)==null?void 0:F.y)??0))}},X=Z=>{K.x<=10&&K.y<=10?Z.preventDefault():S.contains(Z.target)||P(!1),document.removeEventListener("pointermove",D),I.current=null};return I.current!==null&&(document.addEventListener("pointermove",D),document.addEventListener("pointerup",X,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",D),document.removeEventListener("pointerup",X,{capture:!0})}}},[S,P,I]),p.useEffect(()=>{const K=()=>P(!1);return window.addEventListener("blur",K),window.addEventListener("resize",K),()=>{window.removeEventListener("blur",K),window.removeEventListener("resize",K)}},[P]);const[q,Y]=zm(K=>{const D=V().filter(ue=>!ue.disabled),X=D.find(ue=>ue.ref.current===document.activeElement),Z=Hm(D,K,X);Z&&setTimeout(()=>Z.ref.current.focus())}),_=p.useCallback((K,D,X)=>{const Z=!W.current&&!X;(b.value!==void 0&&b.value===D||Z)&&(R(K),Z&&(W.current=!0))},[b.value]),M=p.useCallback(()=>S==null?void 0:S.focus(),[S]),G=p.useCallback((K,D,X)=>{const Z=!W.current&&!X;(b.value!==void 0&&b.value===D||Z)&&z(K)},[b.value]),J=r==="popper"?Ml:km,oe=J===Ml?{side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:h,collisionBoundary:m,collisionPadding:f,sticky:v,hideWhenDetached:g,avoidCollisions:x}:{};return u.jsx(Cm,{scope:n,content:S,viewport:C,onViewportChange:T,itemRefCallback:_,selectedItem:N,onItemLeave:M,itemTextRefCallback:G,focusSelectedItem:O,selectedItemText:L,position:r,isPositioned:U,searchRef:q,children:u.jsx(gs,{as:Uk,allowPinchZoom:!0,children:u.jsx(Jo,{asChild:!0,trapped:b.open,onMountAutoFocus:K=>{K.preventDefault()},onUnmountAutoFocus:ae(o,K=>{var D;(D=b.trigger)==null||D.focus({preventScroll:!0}),K.preventDefault()}),children:u.jsx(br,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:K=>K.preventDefault(),onDismiss:()=>b.onOpenChange(!1),children:u.jsx(J,{role:"listbox",id:b.contentId,"data-state":b.open?"open":"closed",dir:b.dir,onContextMenu:K=>K.preventDefault(),...y,...oe,onPlaced:()=>j(!0),ref:E,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:ae(y.onKeyDown,K=>{const D=K.ctrlKey||K.altKey||K.metaKey;if(K.key==="Tab"&&K.preventDefault(),!D&&K.key.length===1&&Y(K.key),["ArrowUp","ArrowDown","Home","End"].includes(K.key)){let Z=V().filter(ue=>!ue.disabled).map(ue=>ue.ref.current);if(["ArrowUp","End"].includes(K.key)&&(Z=Z.slice().reverse()),["ArrowUp","ArrowDown"].includes(K.key)){const ue=K.target,F=Z.indexOf(ue);Z=Z.slice(F+1)}setTimeout(()=>$(Z)),K.preventDefault()}})})})})})})});Tm.displayName=Hk;var Wk="SelectItemAlignedPosition",km=p.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=Gn(dr,n),i=Yn(dr,n),[a,l]=p.useState(null),[c,d]=p.useState(null),h=$e(t,E=>d(E)),m=oi(n),f=p.useRef(!1),v=p.useRef(!0),{viewport:g,selectedItem:x,selectedItemText:y,focusSelectedItem:b}=i,S=p.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&c&&g&&x&&y){const E=s.trigger.getBoundingClientRect(),N=c.getBoundingClientRect(),R=s.valueNode.getBoundingClientRect(),L=y.getBoundingClientRect();if(s.dir!=="rtl"){const ue=L.left-N.left,F=R.left-ue,ne=E.left-F,de=E.width+ne,ce=Math.max(de,N.width),ge=window.innerWidth-mn,Ce=El(F,[mn,Math.max(mn,ge-ce)]);a.style.minWidth=de+"px",a.style.left=Ce+"px"}else{const ue=N.right-L.right,F=window.innerWidth-R.right-ue,ne=window.innerWidth-E.right-F,de=E.width+ne,ce=Math.max(de,N.width),ge=window.innerWidth-mn,Ce=El(F,[mn,Math.max(mn,ge-ce)]);a.style.minWidth=de+"px",a.style.right=Ce+"px"}const z=m(),V=window.innerHeight-mn*2,U=g.scrollHeight,j=window.getComputedStyle(c),W=parseInt(j.borderTopWidth,10),$=parseInt(j.paddingTop,10),O=parseInt(j.borderBottomWidth,10),P=parseInt(j.paddingBottom,10),I=W+$+U+P+O,q=Math.min(x.offsetHeight*5,I),Y=window.getComputedStyle(g),_=parseInt(Y.paddingTop,10),M=parseInt(Y.paddingBottom,10),G=E.top+E.height/2-mn,J=V-G,oe=x.offsetHeight/2,K=x.offsetTop+oe,D=W+$+K,X=I-D;if(D<=G){const ue=z.length>0&&x===z[z.length-1].ref.current;a.style.bottom="0px";const F=c.clientHeight-g.offsetTop-g.offsetHeight,ne=Math.max(J,oe+(ue?M:0)+F+O),de=D+ne;a.style.height=de+"px"}else{const ue=z.length>0&&x===z[0].ref.current;a.style.top="0px";const ne=Math.max(G,W+g.offsetTop+(ue?_:0)+oe)+X;a.style.height=ne+"px",g.scrollTop=D-G+g.offsetTop}a.style.margin=`${mn}px 0`,a.style.minHeight=q+"px",a.style.maxHeight=V+"px",r==null||r(),requestAnimationFrame(()=>f.current=!0)}},[m,s.trigger,s.valueNode,a,c,g,x,y,s.dir,r]);It(()=>S(),[S]);const[k,C]=p.useState();It(()=>{c&&C(window.getComputedStyle(c).zIndex)},[c]);const T=p.useCallback(E=>{E&&v.current===!0&&(S(),b==null||b(),v.current=!1)},[S,b]);return u.jsx(Kk,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:f,onScrollButtonChange:T,children:u.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:k},children:u.jsx(ve.div,{...o,ref:h,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});km.displayName=Wk;var Vk="SelectPopperPosition",Ml=p.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=mn,...s}=e,i=si(n);return u.jsx(ia,{...i,...s,ref:t,align:r,collisionPadding:o,style:{boxSizing:"border-box",...s.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});Ml.displayName=Vk;var[Kk,Rl]=$r(dr,{}),Ol="SelectViewport",Em=p.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=Yn(Ol,n),i=Rl(Ol,n),a=$e(t,s.onViewportChange),l=p.useRef(0);return u.jsxs(u.Fragment,{children:[u.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),u.jsx(ri.Slot,{scope:n,children:u.jsx(ve.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:ae(o.onScroll,c=>{const d=c.currentTarget,{contentWrapper:h,shouldExpandOnScrollRef:m}=i;if(m!=null&&m.current&&h){const f=Math.abs(l.current-d.scrollTop);if(f>0){const v=window.innerHeight-mn*2,g=parseFloat(h.style.minHeight),x=parseFloat(h.style.height),y=Math.max(g,x);if(y<v){const b=y+f,S=Math.min(v,b),k=b-S;h.style.height=S+"px",h.style.bottom==="0px"&&(d.scrollTop=k>0?k:0,h.style.justifyContent="flex-end")}}}l.current=d.scrollTop})})})]})});Em.displayName=Ol;var Im="SelectGroup",[qk,Gk]=$r(Im),Yk=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Pt();return u.jsx(qk,{scope:n,id:o,children:u.jsx(ve.div,{role:"group","aria-labelledby":o,...r,ref:t})})});Yk.displayName=Im;var Nm="SelectLabel",Am=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Gk(Nm,n);return u.jsx(ve.div,{id:o.id,...r,ref:t})});Am.displayName=Nm;var ii="SelectItem",[Xk,jm]=$r(ii),_m=p.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=Gn(ii,n),l=Yn(ii,n),c=a.value===r,[d,h]=p.useState(s??""),[m,f]=p.useState(!1),v=$e(t,b=>{var S;return(S=l.itemRefCallback)==null?void 0:S.call(l,b,r,o)}),g=Pt(),x=p.useRef("touch"),y=()=>{o||(a.onValueChange(r),a.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return u.jsx(Xk,{scope:n,value:r,disabled:o,textId:g,isSelected:c,onItemTextChange:p.useCallback(b=>{h(S=>S||((b==null?void 0:b.textContent)??"").trim())},[]),children:u.jsx(ri.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:u.jsx(ve.div,{role:"option","aria-labelledby":g,"data-highlighted":m?"":void 0,"aria-selected":c&&m,"data-state":c?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:v,onFocus: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 S;x.current=b.pointerType,o?(S=l.onItemLeave)==null||S.call(l):x.current==="mouse"&&b.currentTarget.focus({preventScroll:!0})}),onPointerLeave:ae(i.onPointerLeave,b=>{var S;b.currentTarget===document.activeElement&&((S=l.onItemLeave)==null||S.call(l))}),onKeyDown:ae(i.onKeyDown,b=>{var k;((k=l.searchRef)==null?void 0:k.current)!==""&&b.key===" "||(Ok.includes(b.key)&&y(),b.key===" "&&b.preventDefault())})})})})});_m.displayName=ii;var Ao="SelectItemText",Pm=p.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=Gn(Ao,n),a=Yn(Ao,n),l=jm(Ao,n),c=Fk(Ao,n),[d,h]=p.useState(null),m=$e(t,y=>h(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=p.useMemo(()=>u.jsx("option",{value:l.value,disabled:l.disabled,children:f},l.value),[l.disabled,l.value,f]),{onNativeOptionAdd:g,onNativeOptionRemove:x}=c;return It(()=>(g(v),()=>x(v)),[g,x,v]),u.jsxs(u.Fragment,{children:[u.jsx(ve.span,{id:l.textId,...s,ref:m}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?Hr.createPortal(s.children,i.valueNode):null]})});Pm.displayName=Ao;var Mm="SelectItemIndicator",Rm=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return jm(Mm,n).isSelected?u.jsx(ve.span,{"aria-hidden":!0,...r,ref:t}):null});Rm.displayName=Mm;var Dl="SelectScrollUpButton",Om=p.forwardRef((e,t)=>{const n=Yn(Dl,e.__scopeSelect),r=Rl(Dl,e.__scopeSelect),[o,s]=p.useState(!1),i=$e(t,r.onScrollButtonChange);return It(()=>{if(n.viewport&&n.isPositioned){let a=function(){const c=l.scrollTop>0;s(c)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?u.jsx(Lm,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});Om.displayName=Dl;var Ll="SelectScrollDownButton",Dm=p.forwardRef((e,t)=>{const n=Yn(Ll,e.__scopeSelect),r=Rl(Ll,e.__scopeSelect),[o,s]=p.useState(!1),i=$e(t,r.onScrollButtonChange);return It(()=>{if(n.viewport&&n.isPositioned){let a=function(){const c=l.scrollHeight-l.clientHeight,d=Math.ceil(l.scrollTop)<c;s(d)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?u.jsx(Lm,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});Dm.displayName=Ll;var Lm=p.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=Yn("SelectScrollButton",n),i=p.useRef(null),a=oi(n),l=p.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return p.useEffect(()=>()=>l(),[l]),It(()=>{var d;const c=a().find(h=>h.ref.current===document.activeElement);(d=c==null?void 0:c.ref.current)==null||d.scrollIntoView({block:"nearest"})},[a]),u.jsx(ve.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:ae(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:ae(o.onPointerMove,()=>{var c;(c=s.onItemLeave)==null||c.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:ae(o.onPointerLeave,()=>{l()})})}),Jk="SelectSeparator",$m=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return u.jsx(ve.div,{"aria-hidden":!0,...r,ref:t})});$m.displayName=Jk;var $l="SelectArrow",Zk=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=si(n),s=Gn($l,n),i=Yn($l,n);return s.open&&i.position==="popper"?u.jsx(aa,{...o,...r,ref:t}):null});Zk.displayName=$l;var Qk="SelectBubbleInput",Fm=p.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=p.useRef(null),s=$e(r,o),i=hm(t);return p.useEffect(()=>{const a=o.current;if(!a)return;const l=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(l,"value").set;if(i!==t&&d){const h=new Event("change",{bubbles:!0});d.call(a,t),a.dispatchEvent(h)}},[i,t]),u.jsx(ve.select,{...n,style:{...pm,...n.style},ref:s,defaultValue:t})});Fm.displayName=Qk;function Bm(e){return e===""||e===void 0}function zm(e){const t=xt(e),n=p.useRef(""),r=p.useRef(0),o=p.useCallback(i=>{const a=n.current+i;t(a),function l(c){n.current=c,window.clearTimeout(r.current),c!==""&&(r.current=window.setTimeout(()=>l(""),1e3))}(a)},[t]),s=p.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return p.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function Hm(e,t,n){const o=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=eE(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 eE(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var tE=mm,Um=xm,nE=wm,rE=bm,oE=ym,Wm=Sm,sE=Em,Vm=Am,Km=_m,iE=Pm,aE=Rm,qm=Om,Gm=Dm,Ym=$m;const lE=tE,cE=nE,Xm=p.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Um,{ref:r,className:te("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(rE,{asChild:!0,children:u.jsx(le.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));Xm.displayName=Um.displayName;const Jm=p.forwardRef(({className:e,...t},n)=>u.jsx(qm,{ref:n,className:te("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(le.ChevronUp,{className:"h-4 w-4"})}));Jm.displayName=qm.displayName;const Zm=p.forwardRef(({className:e,...t},n)=>u.jsx(Gm,{ref:n,className:te("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(le.ChevronDown,{className:"h-4 w-4"})}));Zm.displayName=Gm.displayName;const Qm=p.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>u.jsx(oE,{children:u.jsxs(Wm,{ref:o,className:te("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...r,children:[u.jsx(Jm,{}),u.jsx(sE,{className:te("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),u.jsx(Zm,{})]})}));Qm.displayName=Wm.displayName;const uE=p.forwardRef(({className:e,...t},n)=>u.jsx(Vm,{ref:n,className:te("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));uE.displayName=Vm.displayName;const eg=p.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Km,{ref:r,className:te("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(aE,{children:u.jsx(le.Check,{className:"h-4 w-4"})})}),u.jsx(iE,{children:t})]}));eg.displayName=Km.displayName;const dE=p.forwardRef(({className:e,...t},n)=>u.jsx(Ym,{ref:n,className:te("-mx-1 my-1 h-px bg-muted",e),...t}));dE.displayName=Ym.displayName;var fE="Separator",tg="horizontal",hE=["horizontal","vertical"],ng=p.forwardRef((e,t)=>{const{decorative:n,orientation:r=tg,...o}=e,s=pE(r)?r:tg,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return u.jsx(ve.div,{"data-orientation":s,...a,...o,ref:t})});ng.displayName=fE;function pE(e){return hE.includes(e)}var rg=ng;const og=p.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>u.jsx(rg,{ref:o,decorative:n,orientation:t,className:te("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));og.displayName=rg.displayName;var ai="Switch",[mE,kN]=cn(ai),[gE,xE]=mE(ai),sg=p.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:s,required:i,disabled:a,value:l="on",onCheckedChange:c,form:d,...h}=e,[m,f]=p.useState(null),v=$e(t,S=>f(S)),g=p.useRef(!1),x=m?d||!!m.closest("form"):!0,[y,b]=Dn({prop:o,defaultProp:s??!1,onChange:c,caller:ai});return u.jsxs(gE,{scope:n,checked:y,disabled:a,children:[u.jsx(ve.button,{type:"button",role:"switch","aria-checked":y,"aria-required":i,"data-state":cg(y),"data-disabled":a?"":void 0,disabled:a,value:l,...h,ref:v,onClick:ae(e.onClick,S=>{b(k=>!k),x&&(g.current=S.isPropagationStopped(),g.current||S.stopPropagation())})}),x&&u.jsx(lg,{control:m,bubbles:!g.current,name:r,value:l,checked:y,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});sg.displayName=ai;var ig="SwitchThumb",ag=p.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=xE(ig,n);return u.jsx(ve.span,{"data-state":cg(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});ag.displayName=ig;var vE="SwitchBubbleInput",lg=p.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=p.useRef(null),a=$e(i,s),l=hm(n),c=vd(t);return p.useEffect(()=>{const d=i.current;if(!d)return;const h=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(h,"checked").set;if(l!==n&&f){const v=new Event("click",{bubbles:r});f.call(d,n),d.dispatchEvent(v)}},[l,n,r]),u.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:a,style:{...o.style,...c,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});lg.displayName=vE;function cg(e){return e?"checked":"unchecked"}var ug=sg,wE=ag;const dg=p.forwardRef(({className:e,...t},n)=>u.jsx(ug,{className:te("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(wE,{className:te("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));dg.displayName=ug.displayName;const bE=Ja,yE=lT,SE=Za,fg=p.forwardRef(({className:e,...t},n)=>u.jsx(To,{className:te("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t,ref:n}));fg.displayName=To.displayName;const CE=zr.cva("fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),hg=p.forwardRef(({side:e="right",className:t,children:n,...r},o)=>u.jsxs(SE,{children:[u.jsx(fg,{}),u.jsxs(ko,{ref:o,className:te(CE({side:e}),t),...r,children:[n,u.jsxs(op,{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"})]})]})]}));hg.displayName=ko.displayName;const pg=({className:e,...t})=>u.jsx("div",{className:te("flex flex-col space-y-2 text-center sm:text-left",e),...t});pg.displayName="SheetHeader";const mg=p.forwardRef(({className:e,...t},n)=>u.jsx(ar,{ref:n,className:te("text-lg font-semibold text-foreground",e),...t}));mg.displayName=ar.displayName;const gg=p.forwardRef(({className:e,...t},n)=>u.jsx(Fs,{ref:n,className:te("text-sm text-muted-foreground",e),...t}));gg.displayName=Fs.displayName;var[li,EN]=cn("Tooltip",[kr]),ci=kr(),xg="TooltipProvider",TE=700,Fl="tooltip.open",[kE,Bl]=li(xg),vg=e=>{const{__scopeTooltip:t,delayDuration:n=TE,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:s}=e,i=p.useRef(!0),a=p.useRef(!1),l=p.useRef(0);return p.useEffect(()=>{const c=l.current;return()=>window.clearTimeout(c)},[]),u.jsx(kE,{scope:t,isOpenDelayedRef:i,delayDuration:n,onOpen:p.useCallback(()=>{window.clearTimeout(l.current),i.current=!1},[]),onClose:p.useCallback(()=>{window.clearTimeout(l.current),l.current=window.setTimeout(()=>i.current=!0,r)},[r]),isPointerInTransitRef:a,onPointerInTransitChange:p.useCallback(c=>{a.current=c},[]),disableHoverableContent:o,children:s})};vg.displayName=xg;var jo="Tooltip",[EE,ui]=li(jo),wg=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:s,disableHoverableContent:i,delayDuration:a}=e,l=Bl(jo,e.__scopeTooltip),c=ci(t),[d,h]=p.useState(null),m=Pt(),f=p.useRef(0),v=i??l.disableHoverableContent,g=a??l.delayDuration,x=p.useRef(!1),[y,b]=Dn({prop:r,defaultProp:o??!1,onChange:E=>{E?(l.onOpen(),document.dispatchEvent(new CustomEvent(Fl))):l.onClose(),s==null||s(E)},caller:jo}),S=p.useMemo(()=>y?x.current?"delayed-open":"instant-open":"closed",[y]),k=p.useCallback(()=>{window.clearTimeout(f.current),f.current=0,x.current=!1,b(!0)},[b]),C=p.useCallback(()=>{window.clearTimeout(f.current),f.current=0,b(!1)},[b]),T=p.useCallback(()=>{window.clearTimeout(f.current),f.current=window.setTimeout(()=>{x.current=!0,b(!0),f.current=0},g)},[g,b]);return p.useEffect(()=>()=>{f.current&&(window.clearTimeout(f.current),f.current=0)},[]),u.jsx(oa,{...c,children:u.jsx(EE,{scope:t,contentId:m,open:y,stateAttribute:S,trigger:d,onTriggerChange:h,onTriggerEnter:p.useCallback(()=>{l.isOpenDelayedRef.current?T():k()},[l.isOpenDelayedRef,T,k]),onTriggerLeave:p.useCallback(()=>{v?C():(window.clearTimeout(f.current),f.current=0)},[C,v]),onOpen:k,onClose:C,disableHoverableContent:v,children:n})})};wg.displayName=jo;var zl="TooltipTrigger",bg=p.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=ui(zl,n),s=Bl(zl,n),i=ci(n),a=p.useRef(null),l=$e(t,a,o.onTriggerChange),c=p.useRef(!1),d=p.useRef(!1),h=p.useCallback(()=>c.current=!1,[]);return p.useEffect(()=>()=>document.removeEventListener("pointerup",h),[h]),u.jsx(sa,{asChild:!0,...i,children:u.jsx(ve.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:l,onPointerMove: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(),c.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:ae(e.onFocus,()=>{c.current||o.onOpen()}),onBlur:ae(e.onBlur,o.onClose),onClick:ae(e.onClick,o.onClose)})})});bg.displayName=zl;var IE="TooltipPortal",[IN,NE]=li(IE,{forceMount:void 0}),Fr="TooltipContent",yg=p.forwardRef((e,t)=>{const n=NE(Fr,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...s}=e,i=ui(Fr,e.__scopeTooltip);return u.jsx(Wt,{present:r||i.open,children:i.disableHoverableContent?u.jsx(Sg,{side:o,...s,ref:t}):u.jsx(AE,{side:o,...s,ref:t})})}),AE=p.forwardRef((e,t)=>{const n=ui(Fr,e.__scopeTooltip),r=Bl(Fr,e.__scopeTooltip),o=p.useRef(null),s=$e(t,o),[i,a]=p.useState(null),{trigger:l,onClose:c}=n,d=o.current,{onPointerInTransitChange:h}=r,m=p.useCallback(()=>{a(null),h(!1)},[h]),f=p.useCallback((v,g)=>{const x=v.currentTarget,y={x:v.clientX,y:v.clientY},b=RE(y,x.getBoundingClientRect()),S=OE(y,b),k=DE(g.getBoundingClientRect()),C=$E([...S,...k]);a(C),h(!0)},[h]);return p.useEffect(()=>()=>m(),[m]),p.useEffect(()=>{if(l&&d){const v=x=>f(x,d),g=x=>f(x,l);return l.addEventListener("pointerleave",v),d.addEventListener("pointerleave",g),()=>{l.removeEventListener("pointerleave",v),d.removeEventListener("pointerleave",g)}}},[l,d,f,m]),p.useEffect(()=>{if(i){const v=g=>{const x=g.target,y={x:g.clientX,y:g.clientY},b=(l==null?void 0:l.contains(x))||(d==null?void 0:d.contains(x)),S=!LE(y,i);b?m():S&&(m(),c())};return document.addEventListener("pointermove",v),()=>document.removeEventListener("pointermove",v)}},[l,d,i,c,m]),u.jsx(Sg,{...e,ref:s})}),[jE,_E]=li(jo,{isInside:!1}),PE=Yt.createSlottable("TooltipContent"),Sg=p.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:s,onPointerDownOutside:i,...a}=e,l=ui(Fr,n),c=ci(n),{onClose:d}=l;return p.useEffect(()=>(document.addEventListener(Fl,d),()=>document.removeEventListener(Fl,d)),[d]),p.useEffect(()=>{if(l.trigger){const h=m=>{const f=m.target;f!=null&&f.contains(l.trigger)&&d()};return window.addEventListener("scroll",h,{capture:!0}),()=>window.removeEventListener("scroll",h,{capture:!0})}},[l.trigger,d]),u.jsx(br,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:h=>h.preventDefault(),onDismiss:d,children:u.jsxs(ia,{"data-state":l.stateAttribute,...c,...a,ref:t,style:{...a.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[u.jsx(PE,{children:r}),u.jsx(jE,{scope:n,isInside:!0,children:u.jsx(Mk,{id:l.contentId,role:"tooltip",children:o||r})})]})})});yg.displayName=Fr;var Cg="TooltipArrow",ME=p.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=ci(n);return _E(Cg,n).isInside?null:u.jsx(aa,{...o,...r,ref:t})});ME.displayName=Cg;function RE(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 OE(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 DE(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 LE(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const a=t[s],l=t[i],c=a.x,d=a.y,h=l.x,m=l.y;d>r!=m>r&&n<(h-c)*(r-d)/(m-d)+c&&(o=!o)}return o}function $E(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),FE(t)}function FE(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 BE=vg,zE=wg,HE=bg,Tg=yg;const UE=BE,WE=zE,VE=HE,kg=p.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(Tg,{ref:r,sideOffset:t,className:te("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n}));kg.displayName=Tg.displayName;var Hl="ToastProvider",[Ul,KE,qE]=Yo("Toast"),[Eg,NN]=cn("Toast",[qE]),[GE,di]=Eg(Hl),Ig=e=>{const{__scopeToast:t,label:n="Notification",duration:r=5e3,swipeDirection:o="right",swipeThreshold:s=50,children:i}=e,[a,l]=p.useState(null),[c,d]=p.useState(0),h=p.useRef(!1),m=p.useRef(!1);return n.trim()||console.error(`Invalid prop \`label\` supplied to \`${Hl}\`. Expected non-empty \`string\`.`),u.jsx(Ul.Provider,{scope:t,children:u.jsx(GE,{scope:t,label:n,duration:r,swipeDirection:o,swipeThreshold:s,toastCount:c,viewport:a,onViewportChange:l,onToastAdd:p.useCallback(()=>d(f=>f+1),[]),onToastRemove:p.useCallback(()=>d(f=>f-1),[]),isFocusedToastEscapeKeyDownRef:h,isClosePausedRef:m,children:i})})};Ig.displayName=Hl;var Ng="ToastViewport",YE=["F8"],Wl="toast.viewportPause",Vl="toast.viewportResume",Ag=p.forwardRef((e,t)=>{const{__scopeToast:n,hotkey:r=YE,label:o="Notifications ({hotkey})",...s}=e,i=di(Ng,n),a=KE(n),l=p.useRef(null),c=p.useRef(null),d=p.useRef(null),h=p.useRef(null),m=$e(t,h,i.onViewportChange),f=r.join("+").replace(/Key/g,"").replace(/Digit/g,""),v=i.toastCount>0;p.useEffect(()=>{const x=y=>{var S;r.length!==0&&r.every(k=>y[k]||y.code===k)&&((S=h.current)==null||S.focus())};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[r]),p.useEffect(()=>{const x=l.current,y=h.current;if(v&&x&&y){const b=()=>{if(!i.isClosePausedRef.current){const T=new CustomEvent(Wl);y.dispatchEvent(T),i.isClosePausedRef.current=!0}},S=()=>{if(i.isClosePausedRef.current){const T=new CustomEvent(Vl);y.dispatchEvent(T),i.isClosePausedRef.current=!1}},k=T=>{!x.contains(T.relatedTarget)&&S()},C=()=>{x.contains(document.activeElement)||S()};return x.addEventListener("focusin",b),x.addEventListener("focusout",k),x.addEventListener("pointermove",b),x.addEventListener("pointerleave",C),window.addEventListener("blur",b),window.addEventListener("focus",S),()=>{x.removeEventListener("focusin",b),x.removeEventListener("focusout",k),x.removeEventListener("pointermove",b),x.removeEventListener("pointerleave",C),window.removeEventListener("blur",b),window.removeEventListener("focus",S)}}},[v,i.isClosePausedRef]);const g=p.useCallback(({tabbingDirection:x})=>{const b=a().map(S=>{const k=S.ref.current,C=[k,...lI(k)];return x==="forwards"?C:C.reverse()});return(x==="forwards"?b.reverse():b).flat()},[a]);return p.useEffect(()=>{const x=h.current;if(x){const y=b=>{var C,T,E;const S=b.altKey||b.ctrlKey||b.metaKey;if(b.key==="Tab"&&!S){const N=document.activeElement,R=b.shiftKey;if(b.target===x&&R){(C=c.current)==null||C.focus();return}const V=g({tabbingDirection:R?"backwards":"forwards"}),U=V.findIndex(j=>j===N);Gl(V.slice(U+1))?b.preventDefault():R?(T=c.current)==null||T.focus():(E=d.current)==null||E.focus()}};return x.addEventListener("keydown",y),()=>x.removeEventListener("keydown",y)}},[a,g]),u.jsxs(Dw,{ref:l,role:"region","aria-label":o.replace("{hotkey}",f),tabIndex:-1,style:{pointerEvents:v?void 0:"none"},children:[v&&u.jsx(Kl,{ref:c,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"forwards"});Gl(x)}}),u.jsx(Ul.Slot,{scope:n,children:u.jsx(ve.ol,{tabIndex:-1,...s,ref:m})}),v&&u.jsx(Kl,{ref:d,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"backwards"});Gl(x)}})]})});Ag.displayName=Ng;var jg="ToastFocusProxy",Kl=p.forwardRef((e,t)=>{const{__scopeToast:n,onFocusFromOutsideViewport:r,...o}=e,s=di(jg,n);return u.jsx(ni,{tabIndex:0,...o,ref:t,style:{position:"fixed"},onFocus:i=>{var c;const a=i.relatedTarget;!((c=s.viewport)!=null&&c.contains(a))&&r()}})});Kl.displayName=jg;var _o="Toast",XE="toast.swipeStart",JE="toast.swipeMove",ZE="toast.swipeCancel",QE="toast.swipeEnd",_g=p.forwardRef((e,t)=>{const{forceMount:n,open:r,defaultOpen:o,onOpenChange:s,...i}=e,[a,l]=Dn({prop:r,defaultProp:o??!0,onChange:s,caller:_o});return u.jsx(Wt,{present:n||a,children:u.jsx(nI,{open:a,...i,ref:t,onClose:()=>l(!1),onPause:xt(e.onPause),onResume:xt(e.onResume),onSwipeStart:ae(e.onSwipeStart,c=>{c.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:ae(e.onSwipeMove,c=>{const{x:d,y:h}=c.detail.delta;c.currentTarget.setAttribute("data-swipe","move"),c.currentTarget.style.setProperty("--radix-toast-swipe-move-x",`${d}px`),c.currentTarget.style.setProperty("--radix-toast-swipe-move-y",`${h}px`)}),onSwipeCancel:ae(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:ae(e.onSwipeEnd,c=>{const{x:d,y:h}=c.detail.delta;c.currentTarget.setAttribute("data-swipe","end"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),c.currentTarget.style.setProperty("--radix-toast-swipe-end-x",`${d}px`),c.currentTarget.style.setProperty("--radix-toast-swipe-end-y",`${h}px`),l(!1)})})})});_g.displayName=_o;var[eI,tI]=Eg(_o,{onClose(){}}),nI=p.forwardRef((e,t)=>{const{__scopeToast:n,type:r="foreground",duration:o,open:s,onClose:i,onEscapeKeyDown:a,onPause:l,onResume:c,onSwipeStart:d,onSwipeMove:h,onSwipeCancel:m,onSwipeEnd:f,...v}=e,g=di(_o,n),[x,y]=p.useState(null),b=$e(t,j=>y(j)),S=p.useRef(null),k=p.useRef(null),C=o||g.duration,T=p.useRef(0),E=p.useRef(C),N=p.useRef(0),{onToastAdd:R,onToastRemove:L}=g,z=xt(()=>{var W;(x==null?void 0:x.contains(document.activeElement))&&((W=g.viewport)==null||W.focus()),i()}),V=p.useCallback(j=>{!j||j===1/0||(window.clearTimeout(N.current),T.current=new Date().getTime(),N.current=window.setTimeout(z,j))},[z]);p.useEffect(()=>{const j=g.viewport;if(j){const W=()=>{V(E.current),c==null||c()},$=()=>{const O=new Date().getTime()-T.current;E.current=E.current-O,window.clearTimeout(N.current),l==null||l()};return j.addEventListener(Wl,$),j.addEventListener(Vl,W),()=>{j.removeEventListener(Wl,$),j.removeEventListener(Vl,W)}}},[g.viewport,C,l,c,V]),p.useEffect(()=>{s&&!g.isClosePausedRef.current&&V(C)},[s,C,g.isClosePausedRef,V]),p.useEffect(()=>(R(),()=>L()),[R,L]);const U=p.useMemo(()=>x?$g(x):null,[x]);return g.viewport?u.jsxs(u.Fragment,{children:[U&&u.jsx(rI,{__scopeToast:n,role:"status","aria-live":r==="foreground"?"assertive":"polite",children:U}),u.jsx(eI,{scope:n,onClose:z,children:Hr.createPortal(u.jsx(Ul.ItemSlot,{scope:n,children:u.jsx(Ow,{asChild:!0,onEscapeKeyDown:ae(a,()=>{g.isFocusedToastEscapeKeyDownRef.current||z(),g.isFocusedToastEscapeKeyDownRef.current=!1}),children:u.jsx(ve.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,j=>{j.key==="Escape"&&(a==null||a(j.nativeEvent),j.nativeEvent.defaultPrevented||(g.isFocusedToastEscapeKeyDownRef.current=!0,z()))}),onPointerDown:ae(e.onPointerDown,j=>{j.button===0&&(S.current={x:j.clientX,y:j.clientY})}),onPointerMove:ae(e.onPointerMove,j=>{if(!S.current)return;const W=j.clientX-S.current.x,$=j.clientY-S.current.y,O=!!k.current,P=["left","right"].includes(g.swipeDirection),I=["left","up"].includes(g.swipeDirection)?Math.min:Math.max,q=P?I(0,W):0,Y=P?0:I(0,$),_=j.pointerType==="touch"?10:2,M={x:q,y:Y},G={originalEvent:j,delta:M};O?(k.current=M,fi(JE,h,G,{discrete:!1})):Fg(M,g.swipeDirection,_)?(k.current=M,fi(XE,d,G,{discrete:!1}),j.target.setPointerCapture(j.pointerId)):(Math.abs(W)>_||Math.abs($)>_)&&(S.current=null)}),onPointerUp:ae(e.onPointerUp,j=>{const W=k.current,$=j.target;if($.hasPointerCapture(j.pointerId)&&$.releasePointerCapture(j.pointerId),k.current=null,S.current=null,W){const O=j.currentTarget,P={originalEvent:j,delta:W};Fg(W,g.swipeDirection,g.swipeThreshold)?fi(QE,f,P,{discrete:!0}):fi(ZE,m,P,{discrete:!0}),O.addEventListener("click",I=>I.preventDefault(),{once:!0})}})})})}),g.viewport)})]}):null}),rI=e=>{const{__scopeToast:t,children:n,...r}=e,o=di(_o,t),[s,i]=p.useState(!1),[a,l]=p.useState(!1);return iI(()=>i(!0)),p.useEffect(()=>{const c=window.setTimeout(()=>l(!0),1e3);return()=>window.clearTimeout(c)},[]),a?null:u.jsx(so,{asChild:!0,children:u.jsx(ni,{...r,children:s&&u.jsxs(u.Fragment,{children:[o.label," ",n]})})})},oI="ToastTitle",Pg=p.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(ve.div,{...r,ref:t})});Pg.displayName=oI;var sI="ToastDescription",Mg=p.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(ve.div,{...r,ref:t})});Mg.displayName=sI;var Rg="ToastAction",Og=p.forwardRef((e,t)=>{const{altText:n,...r}=e;return n.trim()?u.jsx(Lg,{altText:n,asChild:!0,children:u.jsx(ql,{...r,ref:t})}):(console.error(`Invalid prop \`altText\` supplied to \`${Rg}\`. Expected non-empty \`string\`.`),null)});Og.displayName=Rg;var Dg="ToastClose",ql=p.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e,o=tI(Dg,n);return u.jsx(Lg,{asChild:!0,children:u.jsx(ve.button,{type:"button",...r,ref:t,onClick:ae(e.onClick,o.onClose)})})});ql.displayName=Dg;var Lg=p.forwardRef((e,t)=>{const{__scopeToast:n,altText:r,...o}=e;return u.jsx(ve.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":r||void 0,...o,ref:t})});function $g(e){const t=[];return Array.from(e.childNodes).forEach(r=>{if(r.nodeType===r.TEXT_NODE&&r.textContent&&t.push(r.textContent),aI(r)){const o=r.ariaHidden||r.hidden||r.style.display==="none",s=r.dataset.radixToastAnnounceExclude==="";if(!o)if(s){const i=r.dataset.radixToastAnnounceAlt;i&&t.push(i)}else t.push(...$g(r))}}),t}function fi(e,t,n,{discrete:r}){const o=n.originalEvent.currentTarget,s=new CustomEvent(e,{bubbles:!0,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?Fi(o,s):o.dispatchEvent(s)}var Fg=(e,t,n=0)=>{const r=Math.abs(e.x),o=Math.abs(e.y),s=r>o;return t==="left"||t==="right"?s&&r>n:!s&&o>n};function iI(e=()=>{}){const t=xt(e);It(()=>{let n=0,r=0;return n=window.requestAnimationFrame(()=>r=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(n),window.cancelAnimationFrame(r)}},[t])}function aI(e){return e.nodeType===e.ELEMENT_NODE}function lI(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function Gl(e){const t=document.activeElement;return e.some(n=>n===t?!0:(n.focus(),document.activeElement!==t))}var cI=Ig,Bg=Ag,zg=_g,Hg=Pg,Ug=Mg,Wg=Og,Vg=ql;const uI=cI,Kg=p.forwardRef(({className:e,...t},n)=>u.jsx(Bg,{ref:n,className:te("fixed bottom-0 right-0 z-[100] flex max-h-screen w-full flex-col p-4 md:max-w-[420px]",e),...t}));Kg.displayName=Bg.displayName;const dI=zr.cva("group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-8 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",{variants:{variant:{default:"border bg-background text-foreground",destructive:"destructive group border-destructive bg-destructive text-destructive-foreground"}},defaultVariants:{variant:"default"}}),qg=p.forwardRef(({className:e,variant:t,...n},r)=>u.jsx(zg,{ref:r,className:te(dI({variant:t}),e),...n}));qg.displayName=zg.displayName;const fI=p.forwardRef(({className:e,...t},n)=>u.jsx(Wg,{ref:n,className:te("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}));fI.displayName=Wg.displayName;const Gg=p.forwardRef(({className:e,...t},n)=>u.jsx(Vg,{ref:n,className:te("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"})}));Gg.displayName=Vg.displayName;const Yg=p.forwardRef(({className:e,...t},n)=>u.jsx(Hg,{ref:n,className:te("text-sm font-semibold",e),...t}));Yg.displayName=Hg.displayName;const Xg=p.forwardRef(({className:e,...t},n)=>u.jsx(Ug,{ref:n,className:te("text-sm opacity-90",e),...t}));Xg.displayName=Ug.displayName;function hI(){const{toasts:e}=nl();return u.jsxs(uI,{children:[e.map(function({id:t,title:n,description:r,action:o,...s}){return u.jsxs(qg,{...s,children:[u.jsxs("div",{className:"grid gap-1",children:[n&&u.jsx(Yg,{children:n}),r&&u.jsx(Xg,{children:r})]}),o,u.jsx(Gg,{})]},t)}),u.jsx(Kg,{})]})}var pI=(e,t,n,r,o,s,i,a)=>{let l=document.documentElement,c=["light","dark"];function d(f){(Array.isArray(e)?e:[e]).forEach(v=>{let g=v==="class",x=g&&s?o.map(y=>s[y]||y):o;g?(l.classList.remove(...x),l.classList.add(s&&s[f]?s[f]:f)):l.setAttribute(v,f)}),h(f)}function h(f){a&&c.includes(f)&&(l.style.colorScheme=f)}function m(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}if(r)d(r);else try{let f=localStorage.getItem(t)||n,v=i&&f==="system"?m():f;d(v)}catch{}},mI=p.createContext(void 0),gI={setTheme:e=>{},themes:[]},xI=()=>{var e;return(e=p.useContext(mI))!=null?e:gI};p.memo(({forcedTheme:e,storageKey:t,attribute:n,enableSystem:r,enableColorScheme:o,defaultTheme:s,value:i,themes:a,nonce:l,scriptProps:c})=>{let d=JSON.stringify([n,t,s,e,a,i,r,o]).slice(1,-1);return p.createElement("script",{...c,suppressHydrationWarning:!0,nonce:typeof window>"u"?l:"",dangerouslySetInnerHTML:{__html:`(${pI.toString()})(${d})`}})});var vI=e=>{switch(e){case"success":return yI;case"info":return CI;case"warning":return SI;case"error":return TI;default:return null}},wI=Array(12).fill(0),bI=({visible:e,className:t})=>w.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},w.createElement("div",{className:"sonner-spinner"},wI.map((n,r)=>w.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),yI=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"})),SI=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"})),CI=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"})),TI=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"})),EI=()=>{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},Yl=1,II=class{constructor(){this.subscribe=e=>(this.subscribers.push(e),()=>{let t=this.subscribers.indexOf(e);this.subscribers.splice(t,1)}),this.publish=e=>{this.subscribers.forEach(t=>t(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e]},this.create=e=>{var t;let{message:n,...r}=e,o=typeof(e==null?void 0:e.id)=="number"||((t=e.id)==null?void 0:t.length)>0?e.id:Yl++,s=this.toasts.find(a=>a.id===o),i=e.dismissible===void 0?!0:e.dismissible;return this.dismissedToasts.has(o)&&this.dismissedToasts.delete(o),s?this.toasts=this.toasts.map(a=>a.id===o?(this.publish({...a,...e,id:o,title:n}),{...a,...e,id:o,dismissible:i,title:n}):a):this.addToast({title:n,...r,dismissible:i,id:o}),o},this.dismiss=e=>(this.dismissedToasts.add(e),e||this.toasts.forEach(t=>{this.subscribers.forEach(n=>n({id:t.id,dismiss:!0}))}),this.subscribers.forEach(t=>t({id:e,dismiss:!0})),e),this.message=(e,t)=>this.create({...t,message:e}),this.error=(e,t)=>this.create({...t,message:e,type:"error"}),this.success=(e,t)=>this.create({...t,type:"success",message:e}),this.info=(e,t)=>this.create({...t,type:"info",message:e}),this.warning=(e,t)=>this.create({...t,type:"warning",message:e}),this.loading=(e,t)=>this.create({...t,type:"loading",message:e}),this.promise=(e,t)=>{if(!t)return;let n;t.loading!==void 0&&(n=this.create({...t,promise:e,type:"loading",message:t.loading,description:typeof t.description!="function"?t.description:void 0}));let r=e instanceof Promise?e:e(),o=n!==void 0,s,i=r.then(async l=>{if(s=["resolve",l],w.isValidElement(l))o=!1,this.create({id:n,type:"default",message:l});else if(AI(l)&&!l.ok){o=!1;let c=typeof t.error=="function"?await t.error(`HTTP error! status: ${l.status}`):t.error,d=typeof t.description=="function"?await t.description(`HTTP error! status: ${l.status}`):t.description;this.create({id:n,type:"error",message:c,description:d})}else if(t.success!==void 0){o=!1;let c=typeof t.success=="function"?await t.success(l):t.success,d=typeof t.description=="function"?await t.description(l):t.description;this.create({id:n,type:"success",message:c,description:d})}}).catch(async l=>{if(s=["reject",l],t.error!==void 0){o=!1;let c=typeof t.error=="function"?await t.error(l):t.error,d=typeof t.description=="function"?await t.description(l):t.description;this.create({id:n,type:"error",message:c,description:d})}}).finally(()=>{var l;o&&(this.dismiss(n),n=void 0),(l=t.finally)==null||l.call(t)}),a=()=>new Promise((l,c)=>i.then(()=>s[0]==="reject"?c(s[1]):l(s[1])).catch(c));return typeof n!="string"&&typeof n!="number"?{unwrap:a}:Object.assign(n,{unwrap:a})},this.custom=(e,t)=>{let n=(t==null?void 0:t.id)||Yl++;return this.create({jsx:e(n),id:n,...t}),n},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},qt=new II,NI=(e,t)=>{let n=(t==null?void 0:t.id)||Yl++;return qt.addToast({title:e,...t,id:n}),n},AI=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",jI=NI,_I=()=>qt.toasts,PI=()=>qt.getActiveToasts();Object.assign(jI,{success:qt.success,info:qt.info,warning:qt.warning,error:qt.error,custom:qt.custom,message:qt.message,promise:qt.promise,dismiss:qt.dismiss,loading:qt.loading},{getHistory:_I,getToasts:PI});function MI(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))}MI(`: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%)}
|
|
129
|
+
dark:bg-background/10 dark:border-border/30 dark:hover:bg-background/20`,children:[v[W]?u.jsx(le.Loader,{className:"h-4 w-4 animate-spin"}):null,u.jsxs("span",{className:"truncate max-w-[180px]",children:[O,v[W]?" (processing)":""]})]},W)}if(j.type==="interrupt"){const $=j,O=Go(($==null?void 0:$.id)??($==null?void 0:$.interrupt_id)),P=!!(N&&O&&O===N),I=P?R??($==null?void 0:$.value):$==null?void 0:$.value,q=O?{...$,id:O,interrupt_id:O}:$;return u.jsx(kp,{interruptPart:q,onApprove:g,onReject:x,disabled:y,isActive:P,payload:I},W)}return null},[f,v,g,x,b,S,k,C,E,N,R,y]),U=a.trim().length>0||l.length>0||c.length>0||d.length>0;if(!t&&c.length>0&&!h)return z();if(!t&&!U&&!h)return null;if(t)return!n&&r?null:n?u.jsx(Ip,{message:e,viewMode:o,isStreaming:s},e.id):null;if(!m){const j=u.jsx("div",{className:"space-y-2",children:i.map((W,$)=>u.jsx(V,{part:W,i:$},$))});return h?u.jsxs("div",{"aria-busy":"true",role:"status",children:[j,u.jsx(Np,{className:L})]}):j}return null}function _p(e){const{allowFileOpen:t,currentThreadId:n}=e,{toast:r}=nl(),[o,s]=w.useState({}),[i,a]=w.useState(null),[l,c]=w.useState(!1),d=w.useCallback(()=>{c(!1),a(null)},[]),h=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??""),S=b.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);if(S){f.preventDefault();const k=S[1],C=v.name||`file_${k}`,T=v.mimeType||"application/octet-stream";h({id:k,name:C,mimeType:T});return}if(b.startsWith("data:")){f.preventDefault(),s(C=>({...C,[g]:!0}));const k=r({title:"Fetching file...",description:"",open:!0});try{const C=await Qc(n??void 0);if(!C||!Array.isArray(C))throw new Error("Invalid file list response");const T=C.find(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");h({id:T.id,name:v.name||T.filename||`file_${T.id}`,mimeType:v.mimeType||T.mime_type||"application/octet-stream"}),(x=k.update)==null||x.call(k,{id:k.id,title:"Success",description:`Opened ${v.name}`,open:!0})}catch(C){console.error("Failed to fetch server file:",C);const T=C instanceof Error?C.message:"Unknown error occurred";(y=k.update)==null||y.call(k,{id:k.id,title:"Failed",description:T}),r({title:"Failed to fetch file",description:T,open:!0})}finally{s(C=>({...C,[g]:!1}))}}}catch(b){console.error("File click error:",b),s(S=>({...S,[g]:!1}))}},[t,o,r,n,h]);return{uploadingFiles:o,handleFileClick:m,fileViewerOpen:l,currentFileInfo:i,closeFileViewer:d}}function Pp(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:Xv(r),toolMeta:Ri(n),imageParts:r.filter(s=>s.type==="image_url"),fileParts:r.filter(s=>s.type==="file"),interruptParts:r.filter(s=>s.type==="interrupt"),toolRaw:Jv(r),isToolStreaming:!!o.toolStreaming}},[e,t])}const Ys=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:h=!0,showArtifactPreviews:m=!0,customStyles:f={},onEdit:v,onRegenerate:g,onCopy:x,activeInterrupt:y,disableInterruptActions:b=!1,onInterruptActionStart:S,onInterruptActionEnd:k,attemptCount:C=1,attemptIndex:T=0,onSelectCheckpoint:E,attemptMetas:N=[]}){const[R,L]=w.useState(!1),[z,V]=w.useState("preview"),[U,j]=w.useState(!1),{currentThreadId:W}=gr(),{respondToInterrupt:$}=eo(),O=l==="phone"||l==="half-screen",P=t.role,I=P==="tool",q=w.useMemo(()=>t.role==="default_message"?t:null,[t]),Y=!!q,_=!(r&&P!=="user"),{uploadingFiles:M,handleFileClick:G,fileViewerOpen:J,currentFileInfo:oe,closeFileViewer:K}=_p({allowFileOpen:_,currentThreadId:W}),D=w.useMemo(()=>{switch(P){case"user":return"text-[hsl(var(--chat-bubble-user-text))]";case"assistant":return"text-[hsl(var(--chat-bubble-ai-text))]";case"tool":return"text-secondary-foreground";case"system":return"text-muted-foreground";default:return"text-[hsl(var(--chat-bubble-ai-text))]"}},[P]),X=Pp(t,q),{contentParts:Z,imageParts:ue,fileParts:F,interruptParts:ne,textContent:de,toolMeta:ce,toolRaw:ge,isToolStreaming:Ce}=X,Pe=(y==null?void 0:y.id)??(y==null?void 0:y.interrupt_id),De=Go(Pe),ze=y==null?void 0:y.value,rt=w.useMemo(()=>q||!m?null:t.artifact||null,[q,t,m]),Ct=w.useCallback(async()=>{const Te=I?ge:de;async function qe(Ee){if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function"){await navigator.clipboard.writeText(Ee);return}if(navigator.clipboard&&typeof navigator.clipboard.write=="function"&&typeof ClipboardItem<"u"){const Ke=new Blob([Ee],{type:"text/plain"});await navigator.clipboard.write([new ClipboardItem({"text/plain":Ke})]);return}throw new Error("Clipboard API not supported in this context.")}try{await qe(Te),L(!0),setTimeout(()=>L(!1),2e3),x==null||x(Te)}catch(Ee){console.error("Failed to copy:",Ee)}},[I,ge,de,x]),Ve=w.useCallback(()=>{if(!v||!t.id)return;const Te=(I?ge:de)??"",qe="type"in t&&t.type==="default_message"?void 0:{checkpointId:t.checkpointId??null,checkpointNs:t.checkpointNs??null};v(t.id,Te,qe)},[v,t.id,I,ge,de,t]),He=w.useCallback(()=>{g==null||g(n)},[g,n]),Ye=w.useCallback(()=>{const qe=te(O?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",D);switch(P){case"user":return u.jsx(le.User,{className:qe});case"assistant":return u.jsx(le.Bot,{className:qe});case"tool":return u.jsx(le.Wrench,{className:qe});default:return u.jsx(le.Bot,{className:qe})}},[O,D,P]),Le=w.useCallback(()=>{const Te="group relative mb-4 flex w-full";switch(P){case"user":return te(Te,"justify-end");case"assistant":case"tool":case"system":return te(Te,"justify-start");default:return Te}},[P]),Ue=w.useCallback(()=>{const Te=te("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",O&&"px-3 py-2 text-sm");if(Y)return te(Te,"w-full","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40 shadow-sm");switch(P){case"user":return te(Te,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-user))] text-[hsl(var(--chat-bubble-user-text))]","border border-transparent");case"assistant":return te(Te,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40");case"tool":return te(Te,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return te(Te,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return te(Te,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40")}},[O,Y,P]),mt=w.useCallback(async Te=>{if(b)return;const qe=Go((Te==null?void 0:Te.id)??(Te==null?void 0:Te.interrupt_id));if(!qe){console.warn("Interrupt part missing id",Te);return}try{S==null||S(),await $(qe,!0)}catch(Ee){console.error("Failed to approve interrupt:",Ee)}finally{k==null||k()}},[b,k,S,$]),Dt=w.useCallback(async Te=>{if(b)return;const qe=Go((Te==null?void 0:Te.id)??(Te==null?void 0:Te.interrupt_id));if(!qe){console.warn("Interrupt part missing id",Te);return}try{S==null||S(),await $(qe,!1)}catch(Ee){console.error("Failed to reject interrupt:",Ee)}finally{k==null||k()}},[b,k,S,$]),at=w.useMemo(()=>q?"Assistant":Zv(t),[q,t]),At=P==="user"&&(C??1)>1&&typeof E=="function",wt=(N==null?void 0:N.length)??0,dt=wt>0&&T<wt-1?N[T+1]:void 0,bt=wt>0&&T>0?N[T-1]:void 0,Tt=w.useCallback(()=>{!dt||!E||E(dt.id,void 0,!!dt.isLatestAttempt)},[dt,E]),jt=w.useCallback(()=>{!bt||!E||E(bt.id,void 0,!!bt.isLatestAttempt)},[bt,E]);return I&&!h&&!rt?null:Y&&q?u.jsx("div",{className:te(Le(),f.container),children:u.jsxs("div",{className:te(Ue(),f.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:te("h-4 w-4",D)}),a&&u.jsx("span",{className:"font-medium text-sm",children:"Assistant"})]}),u.jsx(Mr,{content:q.content,className:"text-current"})]})}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:te(Le(),f.container),children:u.jsxs("div",{className:te(Ue(),f.content),children:[(i||a||I)&&u.jsxs("div",{className:te("flex items-center justify-between mb-2 pb-2 border-b border-current/10",O&&"mb-1 pb-1",D,f.header),children:[u.jsxs("div",{className:"flex items-center gap-2",children:[Ye(),a&&at&&u.jsx("span",{className:te("font-medium",O?"text-xs":"text-sm"),children:at}),I&&u.jsxs(zh,{variant:"outline",className:te("text-xs flex items-center gap-1 cursor-pointer select-none",D,"border border-current/40",O&&"text-xs h-4"),role:"button",tabIndex:0,"aria-expanded":z==="expanded",onClick:()=>V(Te=>Te==="expanded"?"preview":"expanded"),onKeyDown:Te=>{(Te.key==="Enter"||Te.key===" ")&&(Te.preventDefault(),V(qe=>qe==="expanded"?"preview":"expanded"))},children:[u.jsx("span",{children:ce.name??"Tool Output"}),ce.toolCallId&&u.jsx("span",{className:"opacity-70",children:ce.toolCallId.slice(0,8)}),z==="expanded"?u.jsx(le.ChevronUp,{className:"h-3 w-3"}):u.jsx(le.ChevronDown,{className:"h-3 w-3"})]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[At&&C>1&&u.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[u.jsx("button",{type:"button",className:te("flex items-center justify-center rounded border px-1.5 py-1 transition-colors",T<C-1?"border-border text-foreground hover:bg-muted/60":"border-border text-muted-foreground cursor-not-allowed"),onClick:()=>{T>=C-1||Tt()},"aria-label":"Older attempt (back in time)",disabled:T>=C-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:[C-T," / ",C]})}),u.jsx("button",{type:"button",className:te("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||jt()},"aria-label":"Newer attempt (forward in time)",disabled:T<=0,children:u.jsx(le.ChevronRight,{className:"h-3 w-3"})})]}),i&&t.createdAt&&u.jsx("time",{className:te("text-xs opacity-60",D,O&&"text-xs"),dateTime:new Date(t.createdAt).toISOString(),title:new Date(t.createdAt).toLocaleString(),children:new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(new Date(t.createdAt))}),s&&!o&&u.jsxs("div",{className:te("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",f.actions),children:[u.jsx("div",{className:"relative",children:u.jsx(tt,{variant:"ghost",size:"sm",onClick:()=>Ct(),className:te("h-6 w-6 p-0 hover:bg-foreground/10",D,O&&"h-5 w-5"),"aria-label":"Copy message",title:"Copy message",children:u.jsx(le.Copy,{className:te(R?"text-success":D,O?"h-3 w-3":"h-4 w-4")})})}),P==="user"&&v&&u.jsx(tt,{variant:"ghost",size:"sm",onClick:Ve,className:te("h-6 w-6 p-0 hover:bg-foreground/10",D,O&&"h-5 w-5"),"aria-label":"Edit message",children:u.jsx(le.Edit,{className:te(D,O?"h-3 w-3":"h-4 w-4")})}),P==="assistant"&&g&&u.jsx(tt,{variant:"ghost",size:"sm",onClick:He,className:te("h-6 w-6 p-0 hover:bg-foreground/10",D,O&&"h-5 w-5"),"aria-label":"Regenerate response",children:u.jsx(le.RotateCcw,{className:te(D,O?"h-3 w-3":"h-4 w-4")})})]})]})]}),u.jsxs("div",{className:"relative",children:[u.jsx(jp,{message:t,isToolMessage:I,showToolMessages:h,artifactToRender:rt,toolViewMode:z,isToolStreaming:Ce,contentParts:Z,textContent:de,imageParts:ue,fileParts:F,interruptParts:ne,isStreamingMessage:r,defaultMessage:q,handleFileClick:G,uploadingFiles:M,handleInterruptApprove:mt,handleInterruptReject:Dt,disableInterruptActions:b,messageRole:P,truncateUserMessages:c,userMessagePreviewLength:d,isUserExpanded:U,setIsUserExpanded:j,isCompactLayout:O,activeInterruptId:De,activeInterruptValue:ze,iconForeground:D}),m&&rt&&u.jsx("div",{className:"mt-3",children:u.jsx(Cp,{artifact:rt,idx:0})})]}),I&&z==="expanded"&&(ce.toolCallId||ce.name)&&u.jsxs("div",{className:te("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",O&&"text-xs"),children:[ce.name&&u.jsxs("div",{children:["Function: ",ce.name]}),ce.toolCallId&&u.jsxs("div",{children:["Call ID: ",ce.toolCallId]})]}),!(i||a||I)&&s&&!o&&u.jsxs("div",{className:te("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",f.actions),children:[u.jsx(tt,{variant:"ghost",size:"sm",onClick:()=>Ct(),className:te("h-6 w-6 p-0 hover:bg-background/50 text-current",O&&"h-5 w-5"),children:u.jsx(le.Copy,{className:te(R?"text-success":"text-current",O?"h-3 w-3":"h-4 w-4")})}),P==="user"&&v&&u.jsx(tt,{variant:"ghost",size:"sm",onClick:Ve,className:te("h-6 w-6 p-0 hover:bg-background/50 text-current",O&&"h-5 w-5"),children:u.jsx(le.Edit,{className:te("text-current",O?"h-3 w-3":"h-4 w-4")})}),P==="assistant"&&g&&u.jsx(tt,{variant:"ghost",size:"sm",onClick:He,className:te("h-6 w-6 p-0 hover:bg-background/50 text-current",O&&"h-5 w-5"),children:u.jsx(le.RotateCcw,{className:te("text-current",O?"h-3 w-3":"h-4 w-4")})})]})]})}),oe&&u.jsx(ap,{isOpen:J,onClose:K,fileId:oe.id,fileName:oe.name,mimeType:oe.mimeType})]})},(e,t)=>{var l,c,d,h,m,f,v,g;if(t.isStreamingMessage||e.isStreamingMessage||!(e.message.id===t.message.id&&pu(e.message)===pu(t.message)))return!1;const o=["isEditing","showActions","layoutSize","showTimestamp","showAgentName","truncateUserMessages","userMessagePreviewLength","showToolMessages"].every(x=>e[x]===t[x]),s=((l=e.customStyles)==null?void 0:l.container)===((c=t.customStyles)==null?void 0:c.container)&&((d=e.customStyles)==null?void 0:d.content)===((h=t.customStyles)==null?void 0:h.content)&&((m=e.customStyles)==null?void 0:m.actions)===((f=t.customStyles)==null?void 0:f.actions)&&((v=e.customStyles)==null?void 0:v.header)===((g=t.customStyles)==null?void 0:g.header);if(!o||!s)return!1;const i=mu(e.message),a=mu(t.message);return i.length===a.length});Ys.displayName="MessageComponent";const RT={checkpoints:[],checkpointMetaByCheckpointId:new Map,timeline:[],messagePreviews:new Map,getLatest:()=>{},getCheckpoint:()=>{},getMessageAttempts:()=>[]},dl=(e,t)=>(e==null?void 0:e.id)??`message-${t}`,fl=w.memo(function({message:t,index:n,isStreaming:r,streamingAssistantId:o,streamingDebounceMs:s,layoutSize:i,enableMessageEditing:a,editingMessageId:l,onEdit:c,onRegenerate:d,onCancelEdit:h,activeInterrupt:m,disableInterruptActions:f,onInterruptActionStart:v,onInterruptActionEnd:g,showToolMessages:x,showArtifactPreviews:y,checkpointIndex:b,onSelectCheckpoint:S}){const k=dl(t,n),C=t.role==="default_message",E=!!t.__syntheticStreaming,N=b??RT,R=!C&&"checkpointId"in t?t.checkpointId??null:null,{attemptCount:L,attemptIndex:z,attempts:V}=w.useMemo(()=>ec(t.id,R,N),[t.id,R,N]);return u.jsx("div",{className:"relative mb-4 last:mb-0","data-message-id":k,style:{minHeight:"60px",containIntrinsicSize:"auto 120px"},children:u.jsx(Ys,{message:t,messageIndex:n,isStreamingMessage:E||r&&o===t.id,streamingDebounceMs:s,isEditing:l===t.id,showActions:a,showTimestamp:!1,showAgentName:!0,layoutSize:i,onEdit:c,onRegenerate:()=>d(n),onCancelEdit:h,activeInterrupt:m,disableInterruptActions:f,onInterruptActionStart:v,onInterruptActionEnd:g,showToolMessages:x,showArtifactPreviews:y,attemptCount:L,attemptIndex:z,attemptMetas:V,onSelectCheckpoint:S})})});fl.displayName="MessageRow";const hl=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:h,style:m,emptyMessage:f,followNewMessages:v=!0,isNavigatingCheckpoint:g=!1,onScrollAway:x,onAtBottom:y,activeInterrupt:b,disableInterruptActions:S=!1,onInterruptActionStart:k,onInterruptActionEnd:C,showToolMessages:T=!0,showArtifactPreviews:E=!0,checkpointIndex:N,activeCheckpointId:R,onSelectCheckpoint:L,createSyntheticThinkingMessage:z=!0},V)=>{const U=w.useRef(null),j=w.useRef(null),W=w.useRef(!1),$=w.useRef(!1),[O,P]=w.useState(!0),I=w.useMemo(()=>b?e.some(F=>F.role==="default_message"?!1:Array.isArray(F==null?void 0:F.content)&&F.content.some(ne=>ne&&ne.type==="interrupt"&&(ne.id??ne.interrupt_id)===b.id)):!1,[b,e]),q=w.useMemo(()=>{if(!b||I)return null;const F=b.id&&String(b.id).trim()?String(b.id).trim():"pending-interrupt";let ne;const de=b.value;if(de&&typeof de=="object"&&!Array.isArray(de)){const ce=de.title;typeof ce=="string"&&ce.trim()&&(ne=ce.trim())}return{id:`interrupt-${F}`,role:"system",createdAt:new Date().toISOString(),content:[{type:"interrupt",id:F,value:de,title:ne}]}},[b,I]),Y=w.useMemo(()=>q?[...e,q]:e,[e,q]),_=w.useMemo(()=>!z||!t?Y:!Y.some(ne=>ne.role==="assistant")&&Y.length>0?[...Y,{id:"thinking-assistant",role:"assistant",content:[],createdAt:new Date().toISOString(),__syntheticStreaming:!0}]:Y,[Y,t,z]),M=w.useMemo(()=>T?_:_.filter(F=>(F==null?void 0:F.role)!=="tool"),[_,T]),G=w.useCallback(F=>{P(F),x&&x(!F),y&&y(F)},[x,y]),J=w.useMemo(()=>{if(a)return async()=>{if(!W.current){W.current=!0;try{await a()}finally{W.current=!1}}}},[a]),oe=w.useMemo(()=>!v||g?!1:O?"auto":!1,[O,v,g]),K=w.useMemo(()=>{if(typeof f!="string")return null;const F=f.trim();return!F||M&&M.length>0?null:{id:"default-message",role:"default_message",content:F,createdAt:new Date().toISOString()}},[f,M]),D=["flex h-full flex-col md:flex-row",h].filter(Boolean).join(" "),X=()=>K?u.jsx("div",{className:"p-6 h-full overflow-y-auto",children:u.jsx("div",{className:"w-full max-w-full",children:u.jsx(Ys,{message:K,messageIndex:0,isStreamingMessage:!1,showActions:!1,showTimestamp:!1,showAgentName:!0,layoutSize:o,onEdit:()=>{},onRegenerate:()=>{},onCancelEdit:()=>{},showArtifactPreviews:E})})}):u.jsx("div",{className:"flex h-full items-center justify-center py-8 text-center text-muted-foreground",children:f??"No messages yet. Start a conversation!"}),Z=M.length,ue=Z>0;return w.useEffect(()=>{var F,ne;if(Z===0){$.current=!1;return}if(!$.current)if($.current=!0,U.current&&M.length>0){const de=M.length-1;(ne=(F=U.current).scrollToIndex)==null||ne.call(F,{index:de,align:"end",behavior:"auto"})}else j.current&&(j.current.scrollTop=j.current.scrollHeight)},[Z,M.length]),w.useImperativeHandle(V,()=>({scrollToLatest:()=>{var F,ne;if(U.current&&M.length>0){const de=M.length-1;(ne=(F=U.current).scrollToIndex)==null||ne.call(F,{index:de,align:"end",behavior:"auto"})}else j.current&&(j.current.scrollTop=j.current.scrollHeight)},scrollToTop:()=>{var F,ne;U.current&&M.length>0?(ne=(F=U.current).scrollToIndex)==null||ne.call(F,{index:0,align:"start",behavior:"auto"}):j.current&&(j.current.scrollTop=0)}}),[M]),u.jsx("div",{className:D,style:m,children:u.jsx("div",{className:"relative flex-1 min-h-0",children:ue?u.jsx(LC,{ref:F=>{U.current=F},scrollerRef:F=>{j.current=F instanceof HTMLDivElement?F:null},data:M,followOutput:oe,overscan:200,increaseViewportBy:{top:100,bottom:200},defaultItemHeight:80,atBottomThreshold:50,startReached:()=>{J&&J()},atBottomStateChange:G,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(F,ne)=>dl(ne,F),itemContent:(F,ne)=>u.jsx(fl,{message:ne,index:F,isStreaming:t,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:o,enableMessageEditing:s,editingMessageId:i,onEdit:l,onRegenerate:c,onCancelEdit:d,activeInterrupt:b,disableInterruptActions:S,onInterruptActionStart:k,onInterruptActionEnd:C,showToolMessages:T,showArtifactPreviews:E,checkpointIndex:N,activeCheckpointId:R,onSelectCheckpoint:L})}):X()})})});hl.displayName="MessageList";const Mp={value:""};function Rr({className:e="",placeholder:t="Type your message...",autoFocus:n=!0,maxHeight:r=void 0,streamingDebounceMs:o=500,streamingThrottleMs:s,followNewMessages:i=!0,enableFileUpload:a=!0,enableExcelUpload:l=!1,enableMessageEditing:c=!0,showToolMessages:d=!0,showArtifactPreviews:h=!0,customStyles:m={},onMessageSent:f,onExcelUploadSuccess:v,onError:g}){const{api:x}=Xr(),{currentThreadId:y}=gr(),{threadId:b,messages:S,isHistoryLoading:k,isLoading:C,navigateToCheckpoint:T,returnToLatest:E,checkpoint:N,checkpoints:R,interrupt:L,metadata:z,checkpointIndex:V}=eo(),{isStreaming:U,error:j,connectionState:W,submit:$,stop:O}=Li(),P=b??y??null,I=(N==null?void 0:N.id)??null,q=(N==null?void 0:N.namespace)??null,[Y,_]=w.useState(null),M=(z==null?void 0:z.assemblingMessageId)??(U&&Y?Y:null),G=L,[J,oe]=w.useState(!1);w.useEffect(()=>{G||oe(!1)},[G]);const K=w.useCallback(()=>{oe(!0)},[]),D=w.useCallback(()=>{oe(!1)},[]),X=!!G||J,[Z,ue]=w.useState(null),[F,ne]=w.useState(""),[de,ce]=w.useState(null),[ge,Ce]=w.useState(null),[Pe,De]=w.useState([]),[ze,rt]=w.useState(0),[Ct,Ve]=w.useState(0),[He,Ye]=w.useState(!1),[Le,Ue]=w.useState(null),[mt,Dt]=w.useState(null),[at,At]=w.useState(!1),[wt,dt]=w.useState(null),bt=w.useRef(!1),[Tt,jt]=w.useState(()=>Mp.value),Te=w.useRef(Tt),qe=w.useRef(null),Ee=w.useCallback(ie=>{Mp.value=ie,jt(ie)},[]),[Ke,zt]=w.useState(!1),re=w.useRef(null),be=w.useRef(null),ot=w.useRef(null),xe=w.useCallback(()=>{be.current&&(be.current.value=""),ot.current&&(ot.current.value=""),rt(ie=>ie+1),Ve(ie=>ie+1)},[]),Be=w.useCallback(ie=>{Ee(ie)},[Ee]),Xe=w.useRef(!1);w.useEffect(()=>{Xe.current&&!U&&(De([]),xe()),Xe.current=U},[U,xe]),w.useEffect(()=>{U||_(null)},[U]);const[kt,Et]=w.useState("desktop");w.useEffect(()=>{const ie=()=>{const fe=window.innerWidth;Et(fe<640?"phone":fe<1024?"tablet":"desktop")};return ie(),window.addEventListener("resize",ie),()=>window.removeEventListener("resize",ie)},[]),w.useEffect(()=>{bt.current=!1},[P]),w.useEffect(()=>{Te.current=Tt},[Tt]),w.useEffect(()=>{if(!Z){qe.current=null;return}qe.current===null&&(qe.current=Te.current),Ee(F??"")},[F,Z,Ee]),w.useEffect(()=>{(async()=>{if(!x.baseUrl){dt(null);return}try{const Ne=(await x.getAgent("default")).uiDefaultMessage||"";dt(Ne||null)}catch(fe){console.warn("Failed to fetch default message:",fe),dt(null)}})()},[x.baseUrl]),w.useEffect(()=>{j&&!at&&(g==null||g(j))},[j,at,g]);const Nt=async ie=>{const fe=ie.trim();if(!fe&&Pe.length===0)return;const Ne=Z;try{const Oe=Z?(de==null?void 0:de.checkpointId)??I??void 0:I??void 0,et=Z?(de==null?void 0:de.checkpointNs)??q??void 0:q??void 0;await $({text:fe||"",attachments:Pe},{checkpointId:Oe,checkpointNs:et,edit:!!Z,originalMessageId:Z??void 0}),f==null||f(fe),Ne&&_(Ne),Ee(""),Ce(null),De([]),xe(),ue(null),ne(""),ce(null)}catch(Oe){const et=(Oe==null?void 0:Oe.message)||"Failed to send message";Ce(et),g==null||g(et)}},Lt=w.useCallback((ie,fe,Ne)=>{c&&(qe.current=Tt,ue(ie),ne(fe),Ee(fe),Ce(null),ce({checkpointId:(Ne==null?void 0:Ne.checkpointId)??null,checkpointNs:(Ne==null?void 0:Ne.checkpointNs)??null}))},[Tt,c,Ee]),je=w.useCallback(()=>{ue(null),ne(""),ce(null),Ce(null),Ee(qe.current??Tt),qe.current=null,_(null)},[Tt,Ee]),ht=w.useCallback((ie,fe,Ne)=>{Lt(ie,fe,Ne)},[Lt]),Ze=w.useCallback(ie=>{let fe=null;for(let pt=ie-1;pt>=0;pt--)if(S[pt].role==="user"){fe=S[pt];break}if(!fe)return;const Ne=Array.isArray(fe.content)?fe.content:[],et=Ne.filter(pt=>(pt==null?void 0:pt.type)==="text").map(pt=>pt.text).join("")||(()=>{try{return JSON.stringify(Ne,null,2)}catch{return String(Ne)}})();et&&$({text:et},{checkpointId:I??void 0,checkpointNs:q??void 0,edit:!0,originalMessageId:fe.id})},[S,$,I,q]),ft=ie=>{const fe=Array.from(ie.target.files||[]);De(Ne=>[...Ne,...fe]),ie.target.value=""},an=ie=>{De(fe=>{const Ne=fe.filter((Oe,et)=>ie!==et);return Ne.length===0&&xe(),Ne})},A=async ie=>{const fe=(ie.target.files||[])[0];if(fe){Ue(null),Dt(null),Ye(!0);try{await $({attachments:[fe]},{checkpointId:I??void 0,checkpointNs:q??void 0});const Ne=`Uploaded ${fe.name} - processing through chat stream`;Dt(Ne)}catch(Ne){const Oe=Ne instanceof Error?Ne.message:"Failed to upload Excel file";console.error("Excel upload failed",Ne),Ue(Oe),g==null||g(Oe)}finally{Ye(!1),ie.target.value="",xe()}}},Q=async ie=>{if(y){zt(!0);try{if(!ie){await E(),requestAnimationFrame(()=>{var Oe;(Oe=re.current)==null||Oe.scrollToLatest()});return}const fe=R.find(Oe=>Oe.checkpointId===ie),Ne=(fe==null?void 0:fe.checkpointNs)??null;await T(ie,Ne),requestAnimationFrame(()=>{var Oe;(Oe=re.current)==null||Oe.scrollToTop()})}finally{zt(!1)}}},he=w.useCallback(async(ie,fe,Ne)=>{await Q(Ne?null:ie)},[Q]),Ie=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${m.container||""}`,Je=`flex-1 min-h-0 min-w-0 max-h-full w-full overflow-hidden overscroll-contain break-words break-anywhere p-4 bg-transparent ${m.messagesArea||""}`,nt=`relative flex-shrink-0 w-full border-t p-4 bg-transparent ${m.inputArea||""}`;return u.jsxs("div",{className:Ie,children:[!!j&&!at&&u.jsxs("div",{className:"flex-shrink-0 bg-red-50 border border-red-200 text-red-800 px-4 py-2 text-sm flex items-center justify-between",children:[u.jsx("span",{children:j}),u.jsx(tt,{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 ${Je}`,style:r?{maxHeight:r}:void 0,children:[u.jsx(hl,{ref:re,className:"h-full",style:{height:"100%"},messages:S,isStreaming:U,streamingAssistantId:M,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:kt,enableMessageEditing:c,editingMessageId:Z,onEdit:ht,onRegenerate:Ze,onCancelEdit:je,emptyMessage:wt??void 0,isNavigatingCheckpoint:Ke,activeInterrupt:G,disableInterruptActions:J,onInterruptActionStart:K,onInterruptActionEnd:D,showToolMessages:d,showArtifactPreviews:h,checkpointIndex:V,activeCheckpointId:I,onSelectCheckpoint:he,createSyntheticThinkingMessage:!0}),(W==="reconnecting"||W==="connecting")&&u.jsx("div",{className:"pointer-events-none absolute top-3 right-3 z-20 rounded-full bg-muted/80 px-3 py-1 text-xs font-medium text-foreground shadow-sm backdrop-blur-sm dark:bg-muted/60",children:u.jsxs("span",{className:"flex items-center gap-2",children:[u.jsx(le.Loader2,{className:"h-3 w-3 animate-spin"}),W==="reconnecting"?"Reconnecting…":"Connecting…"]})}),W==="error"&&u.jsx("div",{className:"pointer-events-none absolute top-3 right-3 z-20 rounded-full bg-destructive/10 px-3 py-1 text-xs font-semibold text-destructive shadow-sm",children:"Connection lost"}),C&&u.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 bg-background/80 backdrop-blur-sm text-muted-foreground",children:[u.jsx(le.Loader2,{className:"h-6 w-6 animate-spin"}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading messages…"})]}),(k||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…"})]})]}),u.jsxs("div",{className:nt,children:[Z&&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(tt,{variant:"ghost",size:"sm",onClick:je,className:"text-blue-600 hover:bg-blue-100",children:u.jsx(le.X,{size:16})})]})}),(a||l)&&u.jsxs("div",{className:"mb-3 space-y-3",children:[a&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:be,type:"file",multiple:!0,onChange:ie=>ft(ie),className:"hidden"},ze),Pe.length>0&&u.jsx("div",{className:"flex flex-wrap gap-2",children:Pe.map((ie,fe)=>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:ie.name}),u.jsx(tt,{variant:"ghost",size:"sm",onClick:()=>an(fe),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 ${ie.name}`,children:u.jsx(le.X,{size:12})})]},fe))})]}),l&&u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:ot,type:"file",accept:".xls,.xlsx,.xlsm",onChange:A,className:"hidden"},Ct),He&&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..."]}),mt&&!He&&u.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:mt}),Le&&!He&&u.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:Le})]})]}),ge&&u.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:ge}),u.jsxs("div",{className:"flex items-end gap-2",children:[(a||l)&&u.jsxs(Ss,{children:[u.jsx(Cs,{asChild:!0,children:u.jsx(tt,{type:"button",size:"icon",variant:"outline",disabled:U||X,title:"More input actions",className:m.moreButton||"",children:u.jsx(le.Plus,{size:16})})}),u.jsxs(ho,{align:"start",sideOffset:6,className:"w-52",children:[a&&u.jsxs(Bn,{onClick:()=>{var ie;return(ie=be.current)==null?void 0:ie.click()},className:"cursor-pointer",children:[u.jsx(le.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),l&&u.jsxs(Bn,{onClick:()=>{var ie;He||(ie=ot.current)==null||ie.click()},className:`cursor-pointer ${He?"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(IS,{initialValue:F,editingMessageId:Z,value:Tt,onValueChange:Be,placeholder:Z?"Edit your message...":t,isStreaming:U,disabled:X,onSend:Nt,onCancelEdit:je,onStop:O,allowEmptySend:Pe.length>0,textareaClassName:`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${Z?"border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50":""} ${ge?"border-red-400":""} ${m.textarea||""}`})})]})]})]})}var Rp=1,OT=.9,DT=.8,LT=.17,pl=.1,ml=.999,$T=.9999,FT=.99,BT=/[\\\/_+.#"@\[\(\{&]/,zT=/[\\\/_+.#"@\[\(\{&]/g,HT=/[\s-]/,Op=/[\s-]/g;function gl(e,t,n,r,o,s,i){if(s===t.length)return o===e.length?Rp:FT;var a=`${o},${s}`;if(i[a]!==void 0)return i[a];for(var l=r.charAt(s),c=n.indexOf(l,o),d=0,h,m,f,v;c>=0;)h=gl(e,t,n,r,c+1,s+1,i),h>d&&(c===o?h*=Rp:BT.test(e.charAt(c-1))?(h*=DT,f=e.slice(o,c-1).match(zT),f&&o>0&&(h*=Math.pow(ml,f.length))):HT.test(e.charAt(c-1))?(h*=OT,v=e.slice(o,c-1).match(Op),v&&o>0&&(h*=Math.pow(ml,v.length))):(h*=LT,o>0&&(h*=Math.pow(ml,c-o))),e.charAt(c)!==t.charAt(s)&&(h*=$T)),(h<pl&&n.charAt(c-1)===r.charAt(s+1)||r.charAt(s+1)===r.charAt(s)&&n.charAt(c-1)!==r.charAt(s))&&(m=gl(e,t,n,r,c+1,s+2,i),m*pl>h&&(h=m*pl)),h>d&&(d=h),c=n.indexOf(l,c+1);return i[a]=d,d}function Dp(e){return e.toLowerCase().replace(Op," ")}function UT(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,gl(e,t,Dp(e),Dp(t),0,0,{})}var Io='[cmdk-group=""]',xl='[cmdk-group-items=""]',WT='[cmdk-group-heading=""]',Lp='[cmdk-item=""]',$p=`${Lp}:not([aria-disabled="true"])`,vl="cmdk-item-select",Or="data-value",VT=(e,t,n)=>UT(e,t,n),Fp=p.createContext(void 0),No=()=>p.useContext(Fp),Bp=p.createContext(void 0),wl=()=>p.useContext(Bp),zp=p.createContext(void 0),Hp=p.forwardRef((e,t)=>{let n=Dr(()=>{var _,M;return{search:"",value:(M=(_=e.value)!=null?_:e.defaultValue)!=null?M:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=Dr(()=>new Set),o=Dr(()=>new Map),s=Dr(()=>new Map),i=Dr(()=>new Set),a=Up(e),{label:l,children:c,value:d,onValueChange:h,filter:m,shouldFilter:f,loop:v,disablePointerSelection:g=!1,vimBindings:x=!0,...y}=e,b=Pt(),S=Pt(),k=Pt(),C=p.useRef(null),T=nk();cr(()=>{if(d!==void 0){let _=d.trim();n.current.value=_,E.emit()}},[d]),cr(()=>{T(6,U)},[]);let E=p.useMemo(()=>({subscribe:_=>(i.current.add(_),()=>i.current.delete(_)),snapshot:()=>n.current,setState:(_,M,G)=>{var J,oe,K,D;if(!Object.is(n.current[_],M)){if(n.current[_]=M,_==="search")V(),L(),T(1,z);else if(_==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let X=document.getElementById(k);X?X.focus():(J=document.getElementById(b))==null||J.focus()}if(T(7,()=>{var X;n.current.selectedItemId=(X=j())==null?void 0:X.id,E.emit()}),G||T(5,U),((oe=a.current)==null?void 0:oe.value)!==void 0){let X=M??"";(D=(K=a.current).onValueChange)==null||D.call(K,X);return}}E.emit()}},emit:()=>{i.current.forEach(_=>_())}}),[]),N=p.useMemo(()=>({value:(_,M,G)=>{var J;M!==((J=s.current.get(_))==null?void 0:J.value)&&(s.current.set(_,{value:M,keywords:G}),n.current.filtered.items.set(_,R(M,G)),T(2,()=>{L(),E.emit()}))},item:(_,M)=>(r.current.add(_),M&&(o.current.has(M)?o.current.get(M).add(_):o.current.set(M,new Set([_]))),T(3,()=>{V(),L(),n.current.value||z(),E.emit()}),()=>{s.current.delete(_),r.current.delete(_),n.current.filtered.items.delete(_);let G=j();T(4,()=>{V(),(G==null?void 0:G.getAttribute("id"))===_&&z(),E.emit()})}),group:_=>(o.current.has(_)||o.current.set(_,new Set),()=>{s.current.delete(_),o.current.delete(_)}),filter:()=>a.current.shouldFilter,label:l||e["aria-label"],getDisablePointerSelection:()=>a.current.disablePointerSelection,listId:b,inputId:k,labelId:S,listInnerRef:C}),[]);function R(_,M){var G,J;let oe=(J=(G=a.current)==null?void 0:G.filter)!=null?J:VT;return _?oe(_,n.current.search,M):0}function L(){if(!n.current.search||a.current.shouldFilter===!1)return;let _=n.current.filtered.items,M=[];n.current.filtered.groups.forEach(J=>{let oe=o.current.get(J),K=0;oe.forEach(D=>{let X=_.get(D);K=Math.max(X,K)}),M.push([J,K])});let G=C.current;W().sort((J,oe)=>{var K,D;let X=J.getAttribute("id"),Z=oe.getAttribute("id");return((K=_.get(Z))!=null?K:0)-((D=_.get(X))!=null?D:0)}).forEach(J=>{let oe=J.closest(xl);oe?oe.appendChild(J.parentElement===oe?J:J.closest(`${xl} > *`)):G.appendChild(J.parentElement===G?J:J.closest(`${xl} > *`))}),M.sort((J,oe)=>oe[1]-J[1]).forEach(J=>{var oe;let K=(oe=C.current)==null?void 0:oe.querySelector(`${Io}[${Or}="${encodeURIComponent(J[0])}"]`);K==null||K.parentElement.appendChild(K)})}function z(){let _=W().find(G=>G.getAttribute("aria-disabled")!=="true"),M=_==null?void 0:_.getAttribute(Or);E.setState("value",M||void 0)}function V(){var _,M,G,J;if(!n.current.search||a.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let oe=0;for(let K of r.current){let D=(M=(_=s.current.get(K))==null?void 0:_.value)!=null?M:"",X=(J=(G=s.current.get(K))==null?void 0:G.keywords)!=null?J:[],Z=R(D,X);n.current.filtered.items.set(K,Z),Z>0&&oe++}for(let[K,D]of o.current)for(let X of D)if(n.current.filtered.items.get(X)>0){n.current.filtered.groups.add(K);break}n.current.filtered.count=oe}function U(){var _,M,G;let J=j();J&&(((_=J.parentElement)==null?void 0:_.firstChild)===J&&((G=(M=J.closest(Io))==null?void 0:M.querySelector(WT))==null||G.scrollIntoView({block:"nearest"})),J.scrollIntoView({block:"nearest"}))}function j(){var _;return(_=C.current)==null?void 0:_.querySelector(`${Lp}[aria-selected="true"]`)}function W(){var _;return Array.from(((_=C.current)==null?void 0:_.querySelectorAll($p))||[])}function $(_){let M=W()[_];M&&E.setState("value",M.getAttribute(Or))}function O(_){var M;let G=j(),J=W(),oe=J.findIndex(D=>D===G),K=J[oe+_];(M=a.current)!=null&&M.loop&&(K=oe+_<0?J[J.length-1]:oe+_===J.length?J[0]:J[oe+_]),K&&E.setState("value",K.getAttribute(Or))}function P(_){let M=j(),G=M==null?void 0:M.closest(Io),J;for(;G&&!J;)G=_>0?ek(G,Io):tk(G,Io),J=G==null?void 0:G.querySelector($p);J?E.setState("value",J.getAttribute(Or)):O(_)}let I=()=>$(W().length-1),q=_=>{_.preventDefault(),_.metaKey?I():_.altKey?P(1):O(1)},Y=_=>{_.preventDefault(),_.metaKey?$(0):_.altKey?P(-1):O(-1)};return p.createElement(ve.div,{ref:t,tabIndex:-1,...y,"cmdk-root":"",onKeyDown:_=>{var M;(M=y.onKeyDown)==null||M.call(y,_);let G=_.nativeEvent.isComposing||_.keyCode===229;if(!(_.defaultPrevented||G))switch(_.key){case"n":case"j":{x&&_.ctrlKey&&q(_);break}case"ArrowDown":{q(_);break}case"p":case"k":{x&&_.ctrlKey&&Y(_);break}case"ArrowUp":{Y(_);break}case"Home":{_.preventDefault(),$(0);break}case"End":{_.preventDefault(),I();break}case"Enter":{_.preventDefault();let J=j();if(J){let oe=new Event(vl);J.dispatchEvent(oe)}}}}},p.createElement("label",{"cmdk-label":"",htmlFor:N.inputId,id:N.labelId,style:ok},l),Xs(e,_=>p.createElement(Bp.Provider,{value:E},p.createElement(Fp.Provider,{value:N},_))))}),KT=p.forwardRef((e,t)=>{var n,r;let o=Pt(),s=p.useRef(null),i=p.useContext(zp),a=No(),l=Up(e),c=(r=(n=l.current)==null?void 0:n.forceMount)!=null?r:i==null?void 0:i.forceMount;cr(()=>{if(!c)return a.item(o,i==null?void 0:i.id)},[c]);let d=Wp(o,s,[e.value,e.children,s],e.keywords),h=wl(),m=qn(T=>T.value&&T.value===d.current),f=qn(T=>c||a.filter()===!1?!0:T.search?T.filtered.items.get(o)>0:!0);p.useEffect(()=>{let T=s.current;if(!(!T||e.disabled))return T.addEventListener(vl,v),()=>T.removeEventListener(vl,v)},[f,e.onSelect,e.disabled]);function v(){var T,E;g(),(E=(T=l.current).onSelect)==null||E.call(T,d.current)}function g(){h.setState("value",d.current,!0)}if(!f)return null;let{disabled:x,value:y,onSelect:b,forceMount:S,keywords:k,...C}=e;return p.createElement(ve.div,{ref:On(s,t),...C,id:o,"cmdk-item":"",role:"option","aria-disabled":!!x,"aria-selected":!!m,"data-disabled":!!x,"data-selected":!!m,onPointerMove:x||a.getDisablePointerSelection()?void 0:g,onClick:x?void 0:v},e.children)}),qT=p.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:o,...s}=e,i=Pt(),a=p.useRef(null),l=p.useRef(null),c=Pt(),d=No(),h=qn(f=>o||d.filter()===!1?!0:f.search?f.filtered.groups.has(i):!0);cr(()=>d.group(i),[]),Wp(i,a,[e.value,e.heading,l]);let m=p.useMemo(()=>({id:i,forceMount:o}),[o]);return p.createElement(ve.div,{ref:On(a,t),...s,"cmdk-group":"",role:"presentation",hidden:h?void 0:!0},n&&p.createElement("div",{ref:l,"cmdk-group-heading":"","aria-hidden":!0,id:c},n),Xs(e,f=>p.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?c:void 0},p.createElement(zp.Provider,{value:m},f))))}),GT=p.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,o=p.useRef(null),s=qn(i=>!i.search);return!n&&!s?null:p.createElement(ve.div,{ref:On(o,t),...r,"cmdk-separator":"",role:"separator"})}),YT=p.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,o=e.value!=null,s=wl(),i=qn(c=>c.search),a=qn(c=>c.selectedItemId),l=No();return p.useEffect(()=>{e.value!=null&&s.setState("search",e.value)},[e.value]),p.createElement(ve.input,{ref:t,...r,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":l.listId,"aria-labelledby":l.labelId,"aria-activedescendant":a,id:l.inputId,type:"text",value:o?e.value:i,onChange:c=>{o||s.setState("search",c.target.value),n==null||n(c.target.value)}})}),XT=p.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...o}=e,s=p.useRef(null),i=p.useRef(null),a=qn(c=>c.selectedItemId),l=No();return p.useEffect(()=>{if(i.current&&s.current){let c=i.current,d=s.current,h,m=new ResizeObserver(()=>{h=requestAnimationFrame(()=>{let f=c.offsetHeight;d.style.setProperty("--cmdk-list-height",f.toFixed(1)+"px")})});return m.observe(c),()=>{cancelAnimationFrame(h),m.unobserve(c)}}},[]),p.createElement(ve.div,{ref:On(s,t),...o,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":a,"aria-label":r,id:l.listId},Xs(e,c=>p.createElement("div",{ref:On(i,l.listInnerRef),"cmdk-list-sizer":""},c)))}),JT=p.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:o,contentClassName:s,container:i,...a}=e;return p.createElement(Ja,{open:n,onOpenChange:r},p.createElement(Za,{container:i},p.createElement(To,{"cmdk-overlay":"",className:o}),p.createElement(ko,{"aria-label":e.label,"cmdk-dialog":"",className:s},p.createElement(Hp,{ref:t,...a}))))}),ZT=p.forwardRef((e,t)=>qn(n=>n.filtered.count===0)?p.createElement(ve.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),QT=p.forwardRef((e,t)=>{let{progress:n,children:r,label:o="Loading...",...s}=e;return p.createElement(ve.div,{ref:t,...s,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":o},Xs(e,i=>p.createElement("div",{"aria-hidden":!0},i)))}),Kt=Object.assign(Hp,{List:XT,Item:KT,Input:YT,Group:qT,Separator:GT,Dialog:JT,Empty:ZT,Loading:QT});function ek(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function tk(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function Up(e){let t=p.useRef(e);return cr(()=>{t.current=e}),t}var cr=typeof window>"u"?p.useEffect:p.useLayoutEffect;function Dr(e){let t=p.useRef();return t.current===void 0&&(t.current=e()),t}function qn(e){let t=wl(),n=()=>e(t.snapshot());return p.useSyncExternalStore(t.subscribe,n,n)}function Wp(e,t,n,r=[]){let o=p.useRef(),s=No();return cr(()=>{var i;let a=(()=>{var c;for(let d of n){if(typeof d=="string")return d.trim();if(typeof d=="object"&&"current"in d)return d.current?(c=d.current.textContent)==null?void 0:c.trim():o.current}})(),l=r.map(c=>c.trim());s.value(e,a,l),(i=t.current)==null||i.setAttribute(Or,a),o.current=a}),o}var nk=()=>{let[e,t]=p.useState(),n=Dr(()=>new Map);return cr(()=>{n.current.forEach(r=>r()),n.current=new Map},[e]),(r,o)=>{n.current.set(r,o),t({})}};function rk(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function Xs({asChild:e,children:t},n){return e&&p.isValidElement(t)?p.cloneElement(rk(t),{ref:t.ref},n(t.props.children)):n(t)}var ok={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const bl=p.forwardRef(({className:e,...t},n)=>u.jsx(Kt,{ref:n,className:te("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));bl.displayName=Kt.displayName;const yl=p.forwardRef(({className:e,...t},n)=>u.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[u.jsx(le.Search,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),u.jsx(Kt.Input,{ref:n,className:te("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),...t})]}));yl.displayName=Kt.Input.displayName;const Sl=p.forwardRef(({className:e,...t},n)=>u.jsx(Kt.List,{ref:n,className:te("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));Sl.displayName=Kt.List.displayName;const Cl=p.forwardRef((e,t)=>u.jsx(Kt.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));Cl.displayName=Kt.Empty.displayName;const Tl=p.forwardRef(({className:e,...t},n)=>u.jsx(Kt.Group,{ref:n,className:te("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",e),...t}));Tl.displayName=Kt.Group.displayName;const sk=p.forwardRef(({className:e,...t},n)=>u.jsx(Kt.Separator,{ref:n,className:te("-mx-1 h-px bg-border",e),...t}));sk.displayName=Kt.Separator.displayName;const kl=p.forwardRef(({className:e,...t},n)=>u.jsx(Kt.Item,{ref:n,className:te("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected='true']:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50",e),...t}));kl.displayName=Kt.Item.displayName;function El(e,[t,n]){return Math.min(n,Math.max(t,e))}function ik(e,t){return p.useReducer((n,r)=>t[n][r]??n,e)}var Il="ScrollArea",[Vp,CN]=cn(Il),[ak,sn]=Vp(Il),Kp=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,l]=p.useState(null),[c,d]=p.useState(null),[h,m]=p.useState(null),[f,v]=p.useState(null),[g,x]=p.useState(null),[y,b]=p.useState(0),[S,k]=p.useState(0),[C,T]=p.useState(!1),[E,N]=p.useState(!1),R=$e(t,z=>l(z)),L=Xo(o);return u.jsx(ak,{scope:n,type:r,dir:L,scrollHideDelay:s,scrollArea:a,viewport:c,onViewportChange:d,content:h,onContentChange:m,scrollbarX:f,onScrollbarXChange:v,scrollbarXEnabled:C,onScrollbarXEnabledChange:T,scrollbarY:g,onScrollbarYChange:x,scrollbarYEnabled:E,onScrollbarYEnabledChange:N,onCornerWidthChange:b,onCornerHeightChange:k,children:u.jsx(ve.div,{dir:L,...i,ref:R,style:{position:"relative","--radix-scroll-area-corner-width":y+"px","--radix-scroll-area-corner-height":S+"px",...e.style}})})});Kp.displayName=Il;var qp="ScrollAreaViewport",Gp=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=sn(qp,n),a=p.useRef(null),l=$e(t,a,i.onViewportChange);return u.jsxs(u.Fragment,{children:[u.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:o}),u.jsx(ve.div,{"data-radix-scroll-area-viewport":"",...s,ref:l,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:u.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});Gp.displayName=qp;var In="ScrollAreaScrollbar",Nl=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=sn(In,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:i}=o,a=e.orientation==="horizontal";return p.useEffect(()=>(a?s(!0):i(!0),()=>{a?s(!1):i(!1)}),[a,s,i]),o.type==="hover"?u.jsx(lk,{...r,ref:t,forceMount:n}):o.type==="scroll"?u.jsx(ck,{...r,ref:t,forceMount:n}):o.type==="auto"?u.jsx(Yp,{...r,ref:t,forceMount:n}):o.type==="always"?u.jsx(Al,{...r,ref:t}):null});Nl.displayName=In;var lk=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=sn(In,e.__scopeScrollArea),[s,i]=p.useState(!1);return p.useEffect(()=>{const a=o.scrollArea;let l=0;if(a){const c=()=>{window.clearTimeout(l),i(!0)},d=()=>{l=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",c),a.addEventListener("pointerleave",d),()=>{window.clearTimeout(l),a.removeEventListener("pointerenter",c),a.removeEventListener("pointerleave",d)}}},[o.scrollArea,o.scrollHideDelay]),u.jsx(Wt,{present:n||s,children:u.jsx(Yp,{"data-state":s?"visible":"hidden",...r,ref:t})})}),ck=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=sn(In,e.__scopeScrollArea),s=e.orientation==="horizontal",i=ei(()=>l("SCROLL_END"),100),[a,l]=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 p.useEffect(()=>{if(a==="idle"){const c=window.setTimeout(()=>l("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(c)}},[a,o.scrollHideDelay,l]),p.useEffect(()=>{const c=o.viewport,d=s?"scrollLeft":"scrollTop";if(c){let h=c[d];const m=()=>{const f=c[d];h!==f&&(l("SCROLL"),i()),h=f};return c.addEventListener("scroll",m),()=>c.removeEventListener("scroll",m)}},[o.viewport,s,l,i]),u.jsx(Wt,{present:n||a!=="hidden",children:u.jsx(Al,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:ae(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:ae(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),Yp=p.forwardRef((e,t)=>{const n=sn(In,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=p.useState(!1),a=e.orientation==="horizontal",l=ei(()=>{if(n.viewport){const c=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?c:d)}},10);return Lr(n.viewport,l),Lr(n.content,l),u.jsx(Wt,{present:r||s,children:u.jsx(Al,{"data-state":s?"visible":"hidden",...o,ref:t})})}),Al=p.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=sn(In,e.__scopeScrollArea),s=p.useRef(null),i=p.useRef(0),[a,l]=p.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),c=em(a.viewport,a.content),d={...r,sizes:a,onSizesChange:l,hasThumb:c>0&&c<1,onThumbChange:m=>s.current=m,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:m=>i.current=m};function h(m,f){return mk(m,i.current,a,f)}return n==="horizontal"?u.jsx(uk,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollLeft,f=tm(m,a,o.dir);s.current.style.transform=`translate3d(${f}px, 0, 0)`}},onWheelScroll:m=>{o.viewport&&(o.viewport.scrollLeft=m)},onDragScroll:m=>{o.viewport&&(o.viewport.scrollLeft=h(m,o.dir))}}):n==="vertical"?u.jsx(dk,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const m=o.viewport.scrollTop,f=tm(m,a);s.current.style.transform=`translate3d(0, ${f}px, 0)`}},onWheelScroll:m=>{o.viewport&&(o.viewport.scrollTop=m)},onDragScroll:m=>{o.viewport&&(o.viewport.scrollTop=h(m))}}):null}),uk=p.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=sn(In,e.__scopeScrollArea),[i,a]=p.useState(),l=p.useRef(null),c=$e(t,l,s.onScrollbarXChange);return p.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(Jp,{"data-orientation":"horizontal",...o,ref:c,sizes:n,style:{bottom:0,left:s.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:s.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":Qs(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.x),onDragScroll:d=>e.onDragScroll(d.x),onWheelScroll:(d,h)=>{if(s.viewport){const m=s.viewport.scrollLeft+d.deltaX;e.onWheelScroll(m),rm(m,h)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:l.current.clientWidth,paddingStart:Zs(i.paddingLeft),paddingEnd:Zs(i.paddingRight)}})}})}),dk=p.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=sn(In,e.__scopeScrollArea),[i,a]=p.useState(),l=p.useRef(null),c=$e(t,l,s.onScrollbarYChange);return p.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),u.jsx(Jp,{"data-orientation":"vertical",...o,ref:c,sizes:n,style:{top:0,right:s.dir==="ltr"?0:void 0,left:s.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":Qs(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.y),onDragScroll:d=>e.onDragScroll(d.y),onWheelScroll:(d,h)=>{if(s.viewport){const m=s.viewport.scrollTop+d.deltaY;e.onWheelScroll(m),rm(m,h)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:l.current.clientHeight,paddingStart:Zs(i.paddingTop),paddingEnd:Zs(i.paddingBottom)}})}})}),[fk,Xp]=Vp(In),Jp=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:l,onDragScroll:c,onWheelScroll:d,onResize:h,...m}=e,f=sn(In,n),[v,g]=p.useState(null),x=$e(t,R=>g(R)),y=p.useRef(null),b=p.useRef(""),S=f.viewport,k=r.content-r.viewport,C=xt(d),T=xt(l),E=ei(h,10);function N(R){if(y.current){const L=R.clientX-y.current.left,z=R.clientY-y.current.top;c({x:L,y:z})}}return p.useEffect(()=>{const R=L=>{const z=L.target;(v==null?void 0:v.contains(z))&&C(L,k)};return document.addEventListener("wheel",R,{passive:!1}),()=>document.removeEventListener("wheel",R,{passive:!1})},[S,v,k,C]),p.useEffect(T,[r,T]),Lr(v,E),Lr(f.content,E),u.jsx(fk,{scope:n,scrollbar:v,hasThumb:o,onThumbChange:xt(s),onThumbPointerUp:xt(i),onThumbPositionChange:T,onThumbPointerDown:xt(a),children:u.jsx(ve.div,{...m,ref:x,style:{position:"absolute",...m.style},onPointerDown:ae(e.onPointerDown,R=>{R.button===0&&(R.target.setPointerCapture(R.pointerId),y.current=v.getBoundingClientRect(),b.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",f.viewport&&(f.viewport.style.scrollBehavior="auto"),N(R))}),onPointerMove:ae(e.onPointerMove,N),onPointerUp:ae(e.onPointerUp,R=>{const L=R.target;L.hasPointerCapture(R.pointerId)&&L.releasePointerCapture(R.pointerId),document.body.style.webkitUserSelect=b.current,f.viewport&&(f.viewport.style.scrollBehavior=""),y.current=null})})})}),Js="ScrollAreaThumb",Zp=p.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Xp(Js,e.__scopeScrollArea);return u.jsx(Wt,{present:n||o.hasThumb,children:u.jsx(hk,{ref:t,...r})})}),hk=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=sn(Js,n),i=Xp(Js,n),{onThumbPositionChange:a}=i,l=$e(t,h=>i.onThumbChange(h)),c=p.useRef(void 0),d=ei(()=>{c.current&&(c.current(),c.current=void 0)},100);return p.useEffect(()=>{const h=s.viewport;if(h){const m=()=>{if(d(),!c.current){const f=gk(h,a);c.current=f,a()}};return a(),h.addEventListener("scroll",m),()=>h.removeEventListener("scroll",m)}},[s.viewport,d,a]),u.jsx(ve.div,{"data-state":i.hasThumb?"visible":"hidden",...o,ref:l,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:ae(e.onPointerDownCapture,h=>{const f=h.target.getBoundingClientRect(),v=h.clientX-f.left,g=h.clientY-f.top;i.onThumbPointerDown({x:v,y:g})}),onPointerUp:ae(e.onPointerUp,i.onThumbPointerUp)})});Zp.displayName=Js;var jl="ScrollAreaCorner",Qp=p.forwardRef((e,t)=>{const n=sn(jl,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?u.jsx(pk,{...e,ref:t}):null});Qp.displayName=jl;var pk=p.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=sn(jl,n),[s,i]=p.useState(0),[a,l]=p.useState(0),c=!!(s&&a);return Lr(o.scrollbarX,()=>{var h;const d=((h=o.scrollbarX)==null?void 0:h.offsetHeight)||0;o.onCornerHeightChange(d),l(d)}),Lr(o.scrollbarY,()=>{var h;const d=((h=o.scrollbarY)==null?void 0:h.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),c?u.jsx(ve.div,{...r,ref:t,style:{width:s,height:a,position:"absolute",right:o.dir==="ltr"?0:void 0,left:o.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function Zs(e){return e?parseInt(e,10):0}function em(e,t){const n=e/t;return isNaN(n)?0:n}function Qs(e){const t=em(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function mk(e,t,n,r="ltr"){const o=Qs(n),s=o/2,i=t||s,a=o-i,l=n.scrollbar.paddingStart+i,c=n.scrollbar.size-n.scrollbar.paddingEnd-a,d=n.content-n.viewport,h=r==="ltr"?[0,d]:[d*-1,0];return nm([l,c],h)(e)}function tm(e,t,n="ltr"){const r=Qs(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,s=t.scrollbar.size-o,i=t.content-t.viewport,a=s-r,l=n==="ltr"?[0,i]:[i*-1,0],c=El(e,l);return nm([0,i],[0,a])(c)}function nm(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function rm(e,t){return e>0&&e<t}var gk=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return function o(){const s={left:e.scrollLeft,top:e.scrollTop},i=n.left!==s.left,a=n.top!==s.top;(i||a)&&t(),n=s,r=window.requestAnimationFrame(o)}(),()=>window.cancelAnimationFrame(r)};function ei(e,t){const n=xt(e),r=p.useRef(0);return p.useEffect(()=>()=>window.clearTimeout(r.current),[]),p.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function Lr(e,t){const n=xt(t);It(()=>{let r=0;if(e){const o=new ResizeObserver(()=>{cancelAnimationFrame(r),r=window.requestAnimationFrame(n)});return o.observe(e),()=>{window.cancelAnimationFrame(r),o.unobserve(e)}}},[e,n])}var om=Kp,xk=Gp,vk=Qp;const _l=p.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(om,{ref:r,className:te("relative overflow-hidden",e),...n,children:[u.jsx(xk,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),u.jsx(sm,{}),u.jsx(vk,{})]}));_l.displayName=om.displayName;const sm=p.forwardRef(({className:e,orientation:t="vertical",...n},r)=>u.jsx(Nl,{ref:r,orientation:t,className:te("flex touch-none select-none transition-colors",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...n,children:u.jsx(Zp,{className:"relative flex-1 rounded-full bg-border"})}));sm.displayName=Nl.displayName;const Pl=p.forwardRef(({className:e,type:t,...n},r)=>u.jsx("input",{type:t,className:te("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:r,...n}));Pl.displayName="Input";const wk="group relative p-3 rounded-lg cursor-pointer transition-colors border text-gray-900 dark:text-slate-100",bk="bg-slate-700 border-slate-600 hover:bg-slate-600",yk="bg-slate-600 border-slate-500";function im({thread:e,isActive:t,editingThreadId:n,editingTitle:r,onSelect:o,onStartEditing:s,onEditingTitleChange:i,onSaveEditing:a,onCancelEditing:l,onShare:c,onDelete:d,showEditTitle:h,showDeleteButton:m,formatDate:f,getDisplayThreadTitle:v,secondaryLine:g,itemClassName:x,activeItemClassName:y}){const b=n===e.threadId,S=t?`${y??yk}`:`${x??bk}`,k=C=>{C.stopPropagation(),o(e.threadId)};return u.jsxs("div",{onClick:k,className:`${wk} ${S}`,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:C=>C.stopPropagation(),children:[u.jsx(Pl,{value:r,onChange:C=>i(C.target.value),onKeyDown:C=>{C.key==="Enter"?a(e.threadId):C.key==="Escape"&&l()},className:"h-6 text-sm",autoFocus:!0}),u.jsx(tt,{variant:"ghost",size:"sm",onClick:()=>a(e.threadId),className:"h-6 w-6 p-0",children:u.jsx(le.Check,{size:12})}),u.jsx(tt,{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(Ss,{children:[u.jsx(Cs,{asChild:!0,children:u.jsx(tt,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",children:u.jsx(le.MoreHorizontal,{size:12})})}),u.jsxs(ho,{align:"end",sideOffset:6,className:"w-44",children:[u.jsxs(Bn,{onClick:C=>{C.preventDefault(),c(e.threadId)},children:[u.jsx(le.Share2,{className:"mr-2 h-4 w-4"}),"Share thread"]}),h&&n!==e.threadId&&u.jsxs(Bn,{onClick:C=>{C.preventDefault(),s(e,C)},children:[u.jsx(le.Edit3,{className:"mr-2 h-4 w-4"}),"Rename"]}),m&&d&&u.jsxs(Bn,{className:"text-red-400 hover:text-red-300",onClick:C=>{C.preventDefault(),d(e.threadId,C)},children:[u.jsx(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 am=25,lm="thread-manager-view",Sk=e=>e==="default"||e==="shared",Ck=()=>{if(typeof window>"u")return null;try{const e=window.localStorage.getItem(lm);if(Sk(e))return e}catch{}return null};function cm({defaultView:e}={}){const[t,n]=w.useState(()=>Ck()??e??"default");w.useEffect(()=>{if(!(typeof window>"u"))try{window.localStorage.setItem(lm,t)}catch{}},[t]);const r=w.useCallback(o=>{n(o)},[]);return{view:t,setView:r}}const Tk=[{key:"default",label:"My chats"},{key:"shared",label:"Shared with you"}];function ti({className:e="",showCreateButton:t=!0,showDeleteButton:n=!0,showEditTitle:r=!0,maxHeight:o="400px",customStyles:s={},currentThreadId:i=null,navigateToThread:a,onThreadSelect:l,onThreadCreate:c,onThreadDelete:d,view:h,defaultView:m,onViewChange:f,viewOptions:v,viewState:g,showHeader:x=!0,shareTargets:y,isLoadingShareTargets:b,shareTargetFilter:S}){const{threads:k,sharedThreads:C,currentThreadId:T,setCurrentThreadId:E,isLoading:N,isLoadingSharedThreads:R,actions:L,shareInFlight:z,shareStatus:V,clearShareStatus:U}=gr(),{createThread:j,deleteThread:W,renameThread:$,shareThread:O}=L,{loadThread:P}=eo(),I=i??T,[q,Y]=w.useState(Array.isArray(k)?k:[]),_=w.useRef(q.length>0),M=w.useRef(null),G=w.useRef(0),[J,oe]=w.useState(null),[K,D]=w.useState(""),[X,Z]=w.useState(!1),[ue,F]=w.useState(!1),[ne,de]=w.useState(null),[ce,ge]=w.useState(""),Ce=v&&v.length>0?v:Tk,Pe=cm({defaultView:m}),De=g??Pe,ze=h??De.view,rt=w.useCallback(re=>{h||De.setView(re),f==null||f(re)},[h,f,De]),Ct=Ce.find(re=>re.key===ze)??Ce[0],Ve=re=>{de(re),ge(""),F(!0)},He=()=>{F(!1),de(null),ge(""),U()},Ye=w.useCallback(async re=>{if(!(!ne||z)&&re.id)try{await O(ne,re.id),setTimeout(()=>He(),600)}catch(be){console.error("Failed to share thread:",be)}},[He,z,ne,O]),Le=w.useMemo(()=>{const re=y??[],be=ce.trim().toLowerCase();return be?S?re.filter(ot=>S(ot,be)):re.filter(ot=>`${ot.label} ${ot.secondaryLabel??""}`.toLowerCase().includes(be)):re},[y,ce,S]),Ue=ze==="shared",mt=Ue?C:q,Dt=Ue?R:N,at=Ue?"No shared conversations yet":"No conversations yet",At=re=>{const be=re.sharedAt?` • ${Ee(re.sharedAt)}`:"";return`Shared by ${re.sharedByUserId}${be}`},wt=re=>"sharedByUserId"in re;w.useEffect(()=>{const re=Array.isArray(k)?k:[];if(re.length>0){_.current=!0,Y(re);return}N||(_.current=!1,Y(re))},[k,N]),w.useEffect(()=>{if(!M.current)return;const re=M.current.querySelector("[data-radix-scroll-area-viewport]");if(!re)return;let be=null,ot=null;return be=requestAnimationFrame(()=>{ot=requestAnimationFrame(()=>{re.scrollTop=G.current})}),()=>{be!==null&&cancelAnimationFrame(be),ot!==null&&cancelAnimationFrame(ot)}},[q]);const dt=async re=>{try{E(re),await P(re),a==null||a(re),l==null||l(re)}catch(be){console.error("Failed to select thread:",be)}},bt=async()=>{try{Z(!0);const re=await j();re&&(c==null||c(re),a==null||a(re))}catch(re){console.error("Failed to create thread:",re)}finally{Z(!1)}},Tt=async(re,be)=>{if(be.stopPropagation(),!!confirm("Delete this thread?")){if(M.current){const ot=M.current.querySelector("[data-radix-scroll-area-viewport]");ot&&(G.current=ot.scrollTop)}try{await W(re),d==null||d(re)}catch(ot){console.error("Failed to delete thread:",ot)}}},jt=(re,be)=>{be.stopPropagation(),oe(re.threadId),D(re.title||`Thread ${re.threadId.slice(0,8)}`)},Te=async re=>{if(K.trim())try{await $(re,K.trim()),oe(null),D("")}catch(be){console.error("Failed to update title:",be)}},qe=()=>{oe(null),D("")},Ee=re=>{if(!re)return"";try{const be=new Date(re),xe=new Date().getTime()-be.getTime(),Be=Math.floor(xe/(1e3*60*60*24));return Be===0?be.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):Be===1?"Yesterday":Be<7?`${Be} days ago`:be.toLocaleDateString()}catch{return""}},Ke=re=>re.title||`Thread ${re.threadId.slice(0,8)}`,zt=re=>{const be=Ke(re);return be.length<=am?be:`${be.slice(0,am)}...`};return u.jsxs("div",{className:`flex flex-col h-full ${e} ${s.container||""}`,children:[x&&u.jsxs("div",{className:s.header||"flex flex-col gap-2 px-1 py-0 border border-slate-200 bg-white dark:border-slate-700 dark:bg-slate-900 shadow-sm",children:[t&&u.jsx("div",{className:"flex justify-end",children:u.jsxs(tt,{onClick:bt,disabled:X||N,className:s.createButton||"px-3 py-2 gap-1",size:"sm",variant:"ghost",title:X?"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(Ss,{children:[u.jsx(Cs,{asChild:!0,children:u.jsx(tt,{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:Ct.label})}),u.jsx(ho,{align:"start",sideOffset:6,className:"w-40",children:Ce.map(re=>u.jsxs(Bn,{className:"justify-between text-[12px]",onClick:be=>{be.preventDefault(),rt(re.key)},children:[u.jsx("span",{children:re.label}),ze===re.key&&u.jsx(le.Check,{className:"h-3 w-3"})]},re.key))})]})]})]}),u.jsx(_l,{ref:M,className:`flex-1 min-h-0 ${s.threadList||""}`,style:o?{maxHeight:o}:void 0,children:u.jsx("div",{className:"p-2 space-y-1 pb-4",children: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…"})]}):mt.length===0?u.jsxs("div",{className:"text-center py-8 text-slate-400",children:[u.jsx(le.MessageSquare,{className:"w-8 h-8 mx-auto mb-2 opacity-40 text-slate-500"}),u.jsx("p",{className:"text-sm text-slate-500",children:at})]}):mt.slice().sort((re,be)=>new Date(be.updatedAt||be.createdAt||"").getTime()-new Date(re.updatedAt||re.createdAt||"").getTime()).map(re=>u.jsx(im,{thread:re,isActive:I===re.threadId,editingThreadId:J,editingTitle:K,onSelect:dt,onStartEditing:jt,onEditingTitleChange:be=>D(be),onSaveEditing:Te,onCancelEditing:qe,onShare:()=>Ve(re.threadId),onDelete:Tt,showEditTitle:r,showDeleteButton:n,formatDate:Ee,getDisplayThreadTitle:zt,secondaryLine:Ue&&wt(re)?At(re):void 0,itemClassName:s.threadItem,activeItemClassName:s.activeThread},re.threadId))})}),u.jsx(Qa,{open:ue,onOpenChange:re=>!re&&He(),children:u.jsxs(Bs,{className:"max-w-md p-0",children:[u.jsx(zs,{children:u.jsx(Hs,{children:"Share thread"})}),u.jsxs(bl,{children:[u.jsx(yl,{autoFocus:!0,value:ce,onValueChange:re=>ge(re),placeholder:"Search for recipients..."}),u.jsxs(Sl,{children:[V&&u.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-xs text-muted-foreground",children:[z&&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(Cl,{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"}),Le.length>0&&u.jsx(Tl,{heading:"Recipients",children:Le.map(re=>u.jsx(kl,{onSelect:()=>Ye(re),children:u.jsxs("div",{className:"flex flex-col items-start text-sm",children:[u.jsx("span",{className:"font-medium",children:re.label}),re.secondaryLabel&&u.jsx("span",{className:"text-xs text-muted-foreground",children:re.secondaryLabel})]})},re.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(vr,{...s,onThreadChange:l,children:u.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:u.jsx(Rr,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?u.jsx(vr,{...s,onThreadChange:l,children:u.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:u.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[n&&u.jsx("div",{className:`w-80 border-r flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:u.jsx(ti,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),u.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:u.jsx(Rr,{onError:s.onError,enableFileUpload:!0})})]})})}):u.jsx(vr,{...s,onThreadChange:l,children:u.jsxs("div",{className:`${i(t)} flex overflow-hidden ${r} ${o.container||""}`,style:a(t),children:[n&&u.jsx("div",{className:`w-80 border-r bg-gray-50 flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:u.jsx(ti,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),u.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:u.jsx(Rr,{onError:s.onError,enableFileUpload:!0})})]})})}function Ek({apiConfig:e,className:t="",onError:n}){return u.jsx(vr,{apiConfig:e,onError:n,children:u.jsx("div",{className:`h-full ${t}`,children:u.jsx(Rr,{})})})}function Ik({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(Rr,{placeholder:e??"Ask Serti AI anything...",autoFocus:!0,className:"h-full",onMessageSent:t}):u.jsx(ti,{showCreateButton:!0,className:"h-full",onThreadSelect:()=>r("chat")})})]})}function Nk({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(vr,{...i,children:u.jsx("div",{className:`fixed bottom-6 right-6 z-[9999] transition-all duration-300 ${e}`,children:u.jsxs("div",{className:`w-96 bg-white rounded-xl shadow-2xl border border-gray-200 overflow-hidden relative ${a?"scale-75":"scale-100"}`,children:[u.jsx("div",{className:"bg-slate-800 text-white p-4 flex-shrink-0",children:u.jsxs("div",{className:"flex items-center justify-between gap-3",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsxs("div",{className:"relative h-10 w-10 rounded-full bg-gradient-to-br from-slate-500 to-slate-700 border border-white/30 flex items-center justify-center text-white text-sm font-bold",children:["S",u.jsx("span",{className:"absolute -bottom-0.5 -right-0.5 h-3 w-3 rounded-full border-2 border-slate-800 bg-emerald-400"})]}),u.jsxs("div",{className:"flex flex-col",children:[u.jsx("h3",{className:"text-lg font-semibold leading-tight",children:o}),u.jsx("p",{className:"text-xs text-white/70",children:s})]}),u.jsx("span",{className:"ml-2 inline-flex items-center justify-center rounded-full bg-red-500 px-2 py-0.5 text-[11px] font-semibold leading-none text-white",children:"1"})]}),u.jsxs("div",{className:"flex items-center gap-1",children:[u.jsx(tt,{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(tt,{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(tt,{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(Ik,{placeholder:t,onMessageSent:r})})]})})}):null}function Ak({label:e="New chat",children:t,className:n,variant:r="ghost",size:o="sm",...s}){return u.jsxs(tt,{variant:r,size:o,className:te("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",um=p.forwardRef((e,t)=>u.jsx(ve.label,{...e,ref:t,onMouseDown:n=>{var o;n.target.closest("button, input, select, textarea")||((o=e.onMouseDown)==null||o.call(e,n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));um.displayName=jk;var dm=um;const _k=zr.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),fm=p.forwardRef(({className:e,...t},n)=>u.jsx(dm,{ref:n,className:te(_k(),e),...t}));fm.displayName=dm.displayName;function hm(e){const t=p.useRef({value:e,previous:e});return p.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var pm=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),Pk="VisuallyHidden",ni=p.forwardRef((e,t)=>u.jsx(ve.span,{...e,ref:t,style:{...pm,...e.style}}));ni.displayName=Pk;var Mk=ni,Rk=[" ","Enter","ArrowUp","ArrowDown"],Ok=[" ","Enter"],ur="Select",[ri,oi,Dk]=Yo(ur),[$r,TN]=cn(ur,[Dk,kr]),si=kr(),[Lk,Gn]=$r(ur),[$k,Fk]=$r(ur),mm=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:l,dir:c,name:d,autoComplete:h,disabled:m,required:f,form:v}=e,g=si(t),[x,y]=p.useState(null),[b,S]=p.useState(null),[k,C]=p.useState(!1),T=Xo(c),[E,N]=Dn({prop:r,defaultProp:o??!1,onChange:s,caller:ur}),[R,L]=Dn({prop:i,defaultProp:a,onChange:l,caller:ur}),z=p.useRef(null),V=x?v||!!x.closest("form"):!0,[U,j]=p.useState(new Set),W=Array.from(U).map($=>$.props.value).join(";");return u.jsx(oa,{...g,children:u.jsxs(Lk,{required:f,scope:t,trigger:x,onTriggerChange:y,valueNode:b,onValueNodeChange:S,valueNodeHasChildren:k,onValueNodeHasChildrenChange:C,contentId:Pt(),value:R,onValueChange:L,open:E,onOpenChange:N,dir:T,triggerPointerDownPosRef:z,disabled:m,children:[u.jsx(ri.Provider,{scope:t,children:u.jsx($k,{scope:e.__scopeSelect,onNativeOptionAdd:p.useCallback($=>{j(O=>new Set(O).add($))},[]),onNativeOptionRemove:p.useCallback($=>{j(O=>{const P=new Set(O);return P.delete($),P})},[]),children:n})}),V?u.jsxs(Fm,{"aria-hidden":!0,required:f,tabIndex:-1,name:d,autoComplete:h,value:R,onChange:$=>L($.target.value),disabled:m,form:v,children:[R===void 0?u.jsx("option",{value:""}):null,Array.from(U)]},W):null]})})};mm.displayName=ur;var gm="SelectTrigger",xm=p.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=si(n),i=Gn(gm,n),a=i.disabled||r,l=$e(t,i.onTriggerChange),c=oi(n),d=p.useRef("touch"),[h,m,f]=zm(g=>{const x=c().filter(S=>!S.disabled),y=x.find(S=>S.value===i.value),b=Hm(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(sa,{asChild:!0,...s,children:u.jsx(ve.button,{type:"button",role:"combobox","aria-controls":i.contentId,"aria-expanded":i.open,"aria-required":i.required,"aria-autocomplete":"none",dir:i.dir,"data-state":i.open?"open":"closed",disabled:a,"data-disabled":a?"":void 0,"data-placeholder":Bm(i.value)?"":void 0,...o,ref:l,onClick: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=h.current!=="";!(g.ctrlKey||g.altKey||g.metaKey)&&g.key.length===1&&m(g.key),!(x&&g.key===" ")&&Rk.includes(g.key)&&(v(),g.preventDefault())})})})});xm.displayName=gm;var vm="SelectValue",wm=p.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=Gn(vm,n),{onValueNodeHasChildrenChange:c}=l,d=s!==void 0,h=$e(t,l.onValueNodeChange);return It(()=>{c(d)},[c,d]),u.jsx(ve.span,{...a,ref:h,style:{pointerEvents:"none"},children:Bm(l.value)?u.jsx(u.Fragment,{children:i}):s})});wm.displayName=vm;var Bk="SelectIcon",bm=p.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return u.jsx(ve.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});bm.displayName=Bk;var zk="SelectPortal",ym=e=>u.jsx(so,{asChild:!0,...e});ym.displayName=zk;var dr="SelectContent",Sm=p.forwardRef((e,t)=>{const n=Gn(dr,e.__scopeSelect),[r,o]=p.useState();if(It(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?Hr.createPortal(u.jsx(Cm,{scope:e.__scopeSelect,children:u.jsx(ri.Slot,{scope:e.__scopeSelect,children:u.jsx("div",{children:e.children})})}),s):null}return u.jsx(Tm,{...e,ref:t})});Sm.displayName=dr;var mn=10,[Cm,Yn]=$r(dr),Hk="SelectContentImpl",Uk=Yt.createSlot("SelectContent.RemoveScroll"),Tm=p.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:h,collisionBoundary:m,collisionPadding:f,sticky:v,hideWhenDetached:g,avoidCollisions:x,...y}=e,b=Gn(dr,n),[S,k]=p.useState(null),[C,T]=p.useState(null),E=$e(t,K=>k(K)),[N,R]=p.useState(null),[L,z]=p.useState(null),V=oi(n),[U,j]=p.useState(!1),W=p.useRef(!1);p.useEffect(()=>{if(S)return da(S)},[S]),Hi();const $=p.useCallback(K=>{const[D,...X]=V().map(F=>F.ref.current),[Z]=X.slice(-1),ue=document.activeElement;for(const F of K)if(F===ue||(F==null||F.scrollIntoView({block:"nearest"}),F===D&&C&&(C.scrollTop=0),F===Z&&C&&(C.scrollTop=C.scrollHeight),F==null||F.focus(),document.activeElement!==ue))return},[V,C]),O=p.useCallback(()=>$([N,S]),[$,N,S]);p.useEffect(()=>{U&&O()},[U,O]);const{onOpenChange:P,triggerPointerDownPosRef:I}=b;p.useEffect(()=>{if(S){let K={x:0,y:0};const D=Z=>{var ue,F;K={x:Math.abs(Math.round(Z.pageX)-(((ue=I.current)==null?void 0:ue.x)??0)),y:Math.abs(Math.round(Z.pageY)-(((F=I.current)==null?void 0:F.y)??0))}},X=Z=>{K.x<=10&&K.y<=10?Z.preventDefault():S.contains(Z.target)||P(!1),document.removeEventListener("pointermove",D),I.current=null};return I.current!==null&&(document.addEventListener("pointermove",D),document.addEventListener("pointerup",X,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",D),document.removeEventListener("pointerup",X,{capture:!0})}}},[S,P,I]),p.useEffect(()=>{const K=()=>P(!1);return window.addEventListener("blur",K),window.addEventListener("resize",K),()=>{window.removeEventListener("blur",K),window.removeEventListener("resize",K)}},[P]);const[q,Y]=zm(K=>{const D=V().filter(ue=>!ue.disabled),X=D.find(ue=>ue.ref.current===document.activeElement),Z=Hm(D,K,X);Z&&setTimeout(()=>Z.ref.current.focus())}),_=p.useCallback((K,D,X)=>{const Z=!W.current&&!X;(b.value!==void 0&&b.value===D||Z)&&(R(K),Z&&(W.current=!0))},[b.value]),M=p.useCallback(()=>S==null?void 0:S.focus(),[S]),G=p.useCallback((K,D,X)=>{const Z=!W.current&&!X;(b.value!==void 0&&b.value===D||Z)&&z(K)},[b.value]),J=r==="popper"?Ml:km,oe=J===Ml?{side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:h,collisionBoundary:m,collisionPadding:f,sticky:v,hideWhenDetached:g,avoidCollisions:x}:{};return u.jsx(Cm,{scope:n,content:S,viewport:C,onViewportChange:T,itemRefCallback:_,selectedItem:N,onItemLeave:M,itemTextRefCallback:G,focusSelectedItem:O,selectedItemText:L,position:r,isPositioned:U,searchRef:q,children:u.jsx(gs,{as:Uk,allowPinchZoom:!0,children:u.jsx(Jo,{asChild:!0,trapped:b.open,onMountAutoFocus:K=>{K.preventDefault()},onUnmountAutoFocus:ae(o,K=>{var D;(D=b.trigger)==null||D.focus({preventScroll:!0}),K.preventDefault()}),children:u.jsx(br,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:K=>K.preventDefault(),onDismiss:()=>b.onOpenChange(!1),children:u.jsx(J,{role:"listbox",id:b.contentId,"data-state":b.open?"open":"closed",dir:b.dir,onContextMenu:K=>K.preventDefault(),...y,...oe,onPlaced:()=>j(!0),ref:E,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:ae(y.onKeyDown,K=>{const D=K.ctrlKey||K.altKey||K.metaKey;if(K.key==="Tab"&&K.preventDefault(),!D&&K.key.length===1&&Y(K.key),["ArrowUp","ArrowDown","Home","End"].includes(K.key)){let Z=V().filter(ue=>!ue.disabled).map(ue=>ue.ref.current);if(["ArrowUp","End"].includes(K.key)&&(Z=Z.slice().reverse()),["ArrowUp","ArrowDown"].includes(K.key)){const ue=K.target,F=Z.indexOf(ue);Z=Z.slice(F+1)}setTimeout(()=>$(Z)),K.preventDefault()}})})})})})})});Tm.displayName=Hk;var Wk="SelectItemAlignedPosition",km=p.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=Gn(dr,n),i=Yn(dr,n),[a,l]=p.useState(null),[c,d]=p.useState(null),h=$e(t,E=>d(E)),m=oi(n),f=p.useRef(!1),v=p.useRef(!0),{viewport:g,selectedItem:x,selectedItemText:y,focusSelectedItem:b}=i,S=p.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&c&&g&&x&&y){const E=s.trigger.getBoundingClientRect(),N=c.getBoundingClientRect(),R=s.valueNode.getBoundingClientRect(),L=y.getBoundingClientRect();if(s.dir!=="rtl"){const ue=L.left-N.left,F=R.left-ue,ne=E.left-F,de=E.width+ne,ce=Math.max(de,N.width),ge=window.innerWidth-mn,Ce=El(F,[mn,Math.max(mn,ge-ce)]);a.style.minWidth=de+"px",a.style.left=Ce+"px"}else{const ue=N.right-L.right,F=window.innerWidth-R.right-ue,ne=window.innerWidth-E.right-F,de=E.width+ne,ce=Math.max(de,N.width),ge=window.innerWidth-mn,Ce=El(F,[mn,Math.max(mn,ge-ce)]);a.style.minWidth=de+"px",a.style.right=Ce+"px"}const z=m(),V=window.innerHeight-mn*2,U=g.scrollHeight,j=window.getComputedStyle(c),W=parseInt(j.borderTopWidth,10),$=parseInt(j.paddingTop,10),O=parseInt(j.borderBottomWidth,10),P=parseInt(j.paddingBottom,10),I=W+$+U+P+O,q=Math.min(x.offsetHeight*5,I),Y=window.getComputedStyle(g),_=parseInt(Y.paddingTop,10),M=parseInt(Y.paddingBottom,10),G=E.top+E.height/2-mn,J=V-G,oe=x.offsetHeight/2,K=x.offsetTop+oe,D=W+$+K,X=I-D;if(D<=G){const ue=z.length>0&&x===z[z.length-1].ref.current;a.style.bottom="0px";const F=c.clientHeight-g.offsetTop-g.offsetHeight,ne=Math.max(J,oe+(ue?M:0)+F+O),de=D+ne;a.style.height=de+"px"}else{const ue=z.length>0&&x===z[0].ref.current;a.style.top="0px";const ne=Math.max(G,W+g.offsetTop+(ue?_:0)+oe)+X;a.style.height=ne+"px",g.scrollTop=D-G+g.offsetTop}a.style.margin=`${mn}px 0`,a.style.minHeight=q+"px",a.style.maxHeight=V+"px",r==null||r(),requestAnimationFrame(()=>f.current=!0)}},[m,s.trigger,s.valueNode,a,c,g,x,y,s.dir,r]);It(()=>S(),[S]);const[k,C]=p.useState();It(()=>{c&&C(window.getComputedStyle(c).zIndex)},[c]);const T=p.useCallback(E=>{E&&v.current===!0&&(S(),b==null||b(),v.current=!1)},[S,b]);return u.jsx(Kk,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:f,onScrollButtonChange:T,children:u.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:k},children:u.jsx(ve.div,{...o,ref:h,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});km.displayName=Wk;var Vk="SelectPopperPosition",Ml=p.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=mn,...s}=e,i=si(n);return u.jsx(ia,{...i,...s,ref:t,align:r,collisionPadding:o,style:{boxSizing:"border-box",...s.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});Ml.displayName=Vk;var[Kk,Rl]=$r(dr,{}),Ol="SelectViewport",Em=p.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=Yn(Ol,n),i=Rl(Ol,n),a=$e(t,s.onViewportChange),l=p.useRef(0);return u.jsxs(u.Fragment,{children:[u.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),u.jsx(ri.Slot,{scope:n,children:u.jsx(ve.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:ae(o.onScroll,c=>{const d=c.currentTarget,{contentWrapper:h,shouldExpandOnScrollRef:m}=i;if(m!=null&&m.current&&h){const f=Math.abs(l.current-d.scrollTop);if(f>0){const v=window.innerHeight-mn*2,g=parseFloat(h.style.minHeight),x=parseFloat(h.style.height),y=Math.max(g,x);if(y<v){const b=y+f,S=Math.min(v,b),k=b-S;h.style.height=S+"px",h.style.bottom==="0px"&&(d.scrollTop=k>0?k:0,h.style.justifyContent="flex-end")}}}l.current=d.scrollTop})})})]})});Em.displayName=Ol;var Im="SelectGroup",[qk,Gk]=$r(Im),Yk=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Pt();return u.jsx(qk,{scope:n,id:o,children:u.jsx(ve.div,{role:"group","aria-labelledby":o,...r,ref:t})})});Yk.displayName=Im;var Nm="SelectLabel",Am=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Gk(Nm,n);return u.jsx(ve.div,{id:o.id,...r,ref:t})});Am.displayName=Nm;var ii="SelectItem",[Xk,jm]=$r(ii),_m=p.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=Gn(ii,n),l=Yn(ii,n),c=a.value===r,[d,h]=p.useState(s??""),[m,f]=p.useState(!1),v=$e(t,b=>{var S;return(S=l.itemRefCallback)==null?void 0:S.call(l,b,r,o)}),g=Pt(),x=p.useRef("touch"),y=()=>{o||(a.onValueChange(r),a.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return u.jsx(Xk,{scope:n,value:r,disabled:o,textId:g,isSelected:c,onItemTextChange:p.useCallback(b=>{h(S=>S||((b==null?void 0:b.textContent)??"").trim())},[]),children:u.jsx(ri.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:u.jsx(ve.div,{role:"option","aria-labelledby":g,"data-highlighted":m?"":void 0,"aria-selected":c&&m,"data-state":c?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:v,onFocus: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 S;x.current=b.pointerType,o?(S=l.onItemLeave)==null||S.call(l):x.current==="mouse"&&b.currentTarget.focus({preventScroll:!0})}),onPointerLeave:ae(i.onPointerLeave,b=>{var S;b.currentTarget===document.activeElement&&((S=l.onItemLeave)==null||S.call(l))}),onKeyDown:ae(i.onKeyDown,b=>{var k;((k=l.searchRef)==null?void 0:k.current)!==""&&b.key===" "||(Ok.includes(b.key)&&y(),b.key===" "&&b.preventDefault())})})})})});_m.displayName=ii;var Ao="SelectItemText",Pm=p.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=Gn(Ao,n),a=Yn(Ao,n),l=jm(Ao,n),c=Fk(Ao,n),[d,h]=p.useState(null),m=$e(t,y=>h(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=p.useMemo(()=>u.jsx("option",{value:l.value,disabled:l.disabled,children:f},l.value),[l.disabled,l.value,f]),{onNativeOptionAdd:g,onNativeOptionRemove:x}=c;return It(()=>(g(v),()=>x(v)),[g,x,v]),u.jsxs(u.Fragment,{children:[u.jsx(ve.span,{id:l.textId,...s,ref:m}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?Hr.createPortal(s.children,i.valueNode):null]})});Pm.displayName=Ao;var Mm="SelectItemIndicator",Rm=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return jm(Mm,n).isSelected?u.jsx(ve.span,{"aria-hidden":!0,...r,ref:t}):null});Rm.displayName=Mm;var Dl="SelectScrollUpButton",Om=p.forwardRef((e,t)=>{const n=Yn(Dl,e.__scopeSelect),r=Rl(Dl,e.__scopeSelect),[o,s]=p.useState(!1),i=$e(t,r.onScrollButtonChange);return It(()=>{if(n.viewport&&n.isPositioned){let a=function(){const c=l.scrollTop>0;s(c)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?u.jsx(Lm,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});Om.displayName=Dl;var Ll="SelectScrollDownButton",Dm=p.forwardRef((e,t)=>{const n=Yn(Ll,e.__scopeSelect),r=Rl(Ll,e.__scopeSelect),[o,s]=p.useState(!1),i=$e(t,r.onScrollButtonChange);return It(()=>{if(n.viewport&&n.isPositioned){let a=function(){const c=l.scrollHeight-l.clientHeight,d=Math.ceil(l.scrollTop)<c;s(d)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?u.jsx(Lm,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});Dm.displayName=Ll;var Lm=p.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=Yn("SelectScrollButton",n),i=p.useRef(null),a=oi(n),l=p.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return p.useEffect(()=>()=>l(),[l]),It(()=>{var d;const c=a().find(h=>h.ref.current===document.activeElement);(d=c==null?void 0:c.ref.current)==null||d.scrollIntoView({block:"nearest"})},[a]),u.jsx(ve.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:ae(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:ae(o.onPointerMove,()=>{var c;(c=s.onItemLeave)==null||c.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:ae(o.onPointerLeave,()=>{l()})})}),Jk="SelectSeparator",$m=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return u.jsx(ve.div,{"aria-hidden":!0,...r,ref:t})});$m.displayName=Jk;var $l="SelectArrow",Zk=p.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=si(n),s=Gn($l,n),i=Yn($l,n);return s.open&&i.position==="popper"?u.jsx(aa,{...o,...r,ref:t}):null});Zk.displayName=$l;var Qk="SelectBubbleInput",Fm=p.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=p.useRef(null),s=$e(r,o),i=hm(t);return p.useEffect(()=>{const a=o.current;if(!a)return;const l=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(l,"value").set;if(i!==t&&d){const h=new Event("change",{bubbles:!0});d.call(a,t),a.dispatchEvent(h)}},[i,t]),u.jsx(ve.select,{...n,style:{...pm,...n.style},ref:s,defaultValue:t})});Fm.displayName=Qk;function Bm(e){return e===""||e===void 0}function zm(e){const t=xt(e),n=p.useRef(""),r=p.useRef(0),o=p.useCallback(i=>{const a=n.current+i;t(a),function l(c){n.current=c,window.clearTimeout(r.current),c!==""&&(r.current=window.setTimeout(()=>l(""),1e3))}(a)},[t]),s=p.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return p.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function Hm(e,t,n){const o=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=eE(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 eE(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var tE=mm,Um=xm,nE=wm,rE=bm,oE=ym,Wm=Sm,sE=Em,Vm=Am,Km=_m,iE=Pm,aE=Rm,qm=Om,Gm=Dm,Ym=$m;const lE=tE,cE=nE,Xm=p.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Um,{ref:r,className:te("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(rE,{asChild:!0,children:u.jsx(le.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));Xm.displayName=Um.displayName;const Jm=p.forwardRef(({className:e,...t},n)=>u.jsx(qm,{ref:n,className:te("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(le.ChevronUp,{className:"h-4 w-4"})}));Jm.displayName=qm.displayName;const Zm=p.forwardRef(({className:e,...t},n)=>u.jsx(Gm,{ref:n,className:te("flex cursor-default items-center justify-center py-1",e),...t,children:u.jsx(le.ChevronDown,{className:"h-4 w-4"})}));Zm.displayName=Gm.displayName;const Qm=p.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>u.jsx(oE,{children:u.jsxs(Wm,{ref:o,className:te("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...r,children:[u.jsx(Jm,{}),u.jsx(sE,{className:te("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),u.jsx(Zm,{})]})}));Qm.displayName=Wm.displayName;const uE=p.forwardRef(({className:e,...t},n)=>u.jsx(Vm,{ref:n,className:te("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));uE.displayName=Vm.displayName;const eg=p.forwardRef(({className:e,children:t,...n},r)=>u.jsxs(Km,{ref:r,className:te("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(aE,{children:u.jsx(le.Check,{className:"h-4 w-4"})})}),u.jsx(iE,{children:t})]}));eg.displayName=Km.displayName;const dE=p.forwardRef(({className:e,...t},n)=>u.jsx(Ym,{ref:n,className:te("-mx-1 my-1 h-px bg-muted",e),...t}));dE.displayName=Ym.displayName;var fE="Separator",tg="horizontal",hE=["horizontal","vertical"],ng=p.forwardRef((e,t)=>{const{decorative:n,orientation:r=tg,...o}=e,s=pE(r)?r:tg,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return u.jsx(ve.div,{"data-orientation":s,...a,...o,ref:t})});ng.displayName=fE;function pE(e){return hE.includes(e)}var rg=ng;const og=p.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>u.jsx(rg,{ref:o,decorative:n,orientation:t,className:te("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));og.displayName=rg.displayName;var ai="Switch",[mE,kN]=cn(ai),[gE,xE]=mE(ai),sg=p.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:s,required:i,disabled:a,value:l="on",onCheckedChange:c,form:d,...h}=e,[m,f]=p.useState(null),v=$e(t,S=>f(S)),g=p.useRef(!1),x=m?d||!!m.closest("form"):!0,[y,b]=Dn({prop:o,defaultProp:s??!1,onChange:c,caller:ai});return u.jsxs(gE,{scope:n,checked:y,disabled:a,children:[u.jsx(ve.button,{type:"button",role:"switch","aria-checked":y,"aria-required":i,"data-state":cg(y),"data-disabled":a?"":void 0,disabled:a,value:l,...h,ref:v,onClick:ae(e.onClick,S=>{b(k=>!k),x&&(g.current=S.isPropagationStopped(),g.current||S.stopPropagation())})}),x&&u.jsx(lg,{control:m,bubbles:!g.current,name:r,value:l,checked:y,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});sg.displayName=ai;var ig="SwitchThumb",ag=p.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=xE(ig,n);return u.jsx(ve.span,{"data-state":cg(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});ag.displayName=ig;var vE="SwitchBubbleInput",lg=p.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=p.useRef(null),a=$e(i,s),l=hm(n),c=vd(t);return p.useEffect(()=>{const d=i.current;if(!d)return;const h=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(h,"checked").set;if(l!==n&&f){const v=new Event("click",{bubbles:r});f.call(d,n),d.dispatchEvent(v)}},[l,n,r]),u.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:a,style:{...o.style,...c,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});lg.displayName=vE;function cg(e){return e?"checked":"unchecked"}var ug=sg,wE=ag;const dg=p.forwardRef(({className:e,...t},n)=>u.jsx(ug,{className:te("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(wE,{className:te("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));dg.displayName=ug.displayName;const bE=Ja,yE=lT,SE=Za,fg=p.forwardRef(({className:e,...t},n)=>u.jsx(To,{className:te("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t,ref:n}));fg.displayName=To.displayName;const CE=zr.cva("fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),hg=p.forwardRef(({side:e="right",className:t,children:n,...r},o)=>u.jsxs(SE,{children:[u.jsx(fg,{}),u.jsxs(ko,{ref:o,className:te(CE({side:e}),t),...r,children:[n,u.jsxs(op,{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"})]})]})]}));hg.displayName=ko.displayName;const pg=({className:e,...t})=>u.jsx("div",{className:te("flex flex-col space-y-2 text-center sm:text-left",e),...t});pg.displayName="SheetHeader";const mg=p.forwardRef(({className:e,...t},n)=>u.jsx(ar,{ref:n,className:te("text-lg font-semibold text-foreground",e),...t}));mg.displayName=ar.displayName;const gg=p.forwardRef(({className:e,...t},n)=>u.jsx(Fs,{ref:n,className:te("text-sm text-muted-foreground",e),...t}));gg.displayName=Fs.displayName;var[li,EN]=cn("Tooltip",[kr]),ci=kr(),xg="TooltipProvider",TE=700,Fl="tooltip.open",[kE,Bl]=li(xg),vg=e=>{const{__scopeTooltip:t,delayDuration:n=TE,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:s}=e,i=p.useRef(!0),a=p.useRef(!1),l=p.useRef(0);return p.useEffect(()=>{const c=l.current;return()=>window.clearTimeout(c)},[]),u.jsx(kE,{scope:t,isOpenDelayedRef:i,delayDuration:n,onOpen:p.useCallback(()=>{window.clearTimeout(l.current),i.current=!1},[]),onClose:p.useCallback(()=>{window.clearTimeout(l.current),l.current=window.setTimeout(()=>i.current=!0,r)},[r]),isPointerInTransitRef:a,onPointerInTransitChange:p.useCallback(c=>{a.current=c},[]),disableHoverableContent:o,children:s})};vg.displayName=xg;var jo="Tooltip",[EE,ui]=li(jo),wg=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:s,disableHoverableContent:i,delayDuration:a}=e,l=Bl(jo,e.__scopeTooltip),c=ci(t),[d,h]=p.useState(null),m=Pt(),f=p.useRef(0),v=i??l.disableHoverableContent,g=a??l.delayDuration,x=p.useRef(!1),[y,b]=Dn({prop:r,defaultProp:o??!1,onChange:E=>{E?(l.onOpen(),document.dispatchEvent(new CustomEvent(Fl))):l.onClose(),s==null||s(E)},caller:jo}),S=p.useMemo(()=>y?x.current?"delayed-open":"instant-open":"closed",[y]),k=p.useCallback(()=>{window.clearTimeout(f.current),f.current=0,x.current=!1,b(!0)},[b]),C=p.useCallback(()=>{window.clearTimeout(f.current),f.current=0,b(!1)},[b]),T=p.useCallback(()=>{window.clearTimeout(f.current),f.current=window.setTimeout(()=>{x.current=!0,b(!0),f.current=0},g)},[g,b]);return p.useEffect(()=>()=>{f.current&&(window.clearTimeout(f.current),f.current=0)},[]),u.jsx(oa,{...c,children:u.jsx(EE,{scope:t,contentId:m,open:y,stateAttribute:S,trigger:d,onTriggerChange:h,onTriggerEnter:p.useCallback(()=>{l.isOpenDelayedRef.current?T():k()},[l.isOpenDelayedRef,T,k]),onTriggerLeave:p.useCallback(()=>{v?C():(window.clearTimeout(f.current),f.current=0)},[C,v]),onOpen:k,onClose:C,disableHoverableContent:v,children:n})})};wg.displayName=jo;var zl="TooltipTrigger",bg=p.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=ui(zl,n),s=Bl(zl,n),i=ci(n),a=p.useRef(null),l=$e(t,a,o.onTriggerChange),c=p.useRef(!1),d=p.useRef(!1),h=p.useCallback(()=>c.current=!1,[]);return p.useEffect(()=>()=>document.removeEventListener("pointerup",h),[h]),u.jsx(sa,{asChild:!0,...i,children:u.jsx(ve.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:l,onPointerMove: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(),c.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:ae(e.onFocus,()=>{c.current||o.onOpen()}),onBlur:ae(e.onBlur,o.onClose),onClick:ae(e.onClick,o.onClose)})})});bg.displayName=zl;var IE="TooltipPortal",[IN,NE]=li(IE,{forceMount:void 0}),Fr="TooltipContent",yg=p.forwardRef((e,t)=>{const n=NE(Fr,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...s}=e,i=ui(Fr,e.__scopeTooltip);return u.jsx(Wt,{present:r||i.open,children:i.disableHoverableContent?u.jsx(Sg,{side:o,...s,ref:t}):u.jsx(AE,{side:o,...s,ref:t})})}),AE=p.forwardRef((e,t)=>{const n=ui(Fr,e.__scopeTooltip),r=Bl(Fr,e.__scopeTooltip),o=p.useRef(null),s=$e(t,o),[i,a]=p.useState(null),{trigger:l,onClose:c}=n,d=o.current,{onPointerInTransitChange:h}=r,m=p.useCallback(()=>{a(null),h(!1)},[h]),f=p.useCallback((v,g)=>{const x=v.currentTarget,y={x:v.clientX,y:v.clientY},b=RE(y,x.getBoundingClientRect()),S=OE(y,b),k=DE(g.getBoundingClientRect()),C=$E([...S,...k]);a(C),h(!0)},[h]);return p.useEffect(()=>()=>m(),[m]),p.useEffect(()=>{if(l&&d){const v=x=>f(x,d),g=x=>f(x,l);return l.addEventListener("pointerleave",v),d.addEventListener("pointerleave",g),()=>{l.removeEventListener("pointerleave",v),d.removeEventListener("pointerleave",g)}}},[l,d,f,m]),p.useEffect(()=>{if(i){const v=g=>{const x=g.target,y={x:g.clientX,y:g.clientY},b=(l==null?void 0:l.contains(x))||(d==null?void 0:d.contains(x)),S=!LE(y,i);b?m():S&&(m(),c())};return document.addEventListener("pointermove",v),()=>document.removeEventListener("pointermove",v)}},[l,d,i,c,m]),u.jsx(Sg,{...e,ref:s})}),[jE,_E]=li(jo,{isInside:!1}),PE=Yt.createSlottable("TooltipContent"),Sg=p.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:s,onPointerDownOutside:i,...a}=e,l=ui(Fr,n),c=ci(n),{onClose:d}=l;return p.useEffect(()=>(document.addEventListener(Fl,d),()=>document.removeEventListener(Fl,d)),[d]),p.useEffect(()=>{if(l.trigger){const h=m=>{const f=m.target;f!=null&&f.contains(l.trigger)&&d()};return window.addEventListener("scroll",h,{capture:!0}),()=>window.removeEventListener("scroll",h,{capture:!0})}},[l.trigger,d]),u.jsx(br,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:h=>h.preventDefault(),onDismiss:d,children:u.jsxs(ia,{"data-state":l.stateAttribute,...c,...a,ref:t,style:{...a.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[u.jsx(PE,{children:r}),u.jsx(jE,{scope:n,isInside:!0,children:u.jsx(Mk,{id:l.contentId,role:"tooltip",children:o||r})})]})})});yg.displayName=Fr;var Cg="TooltipArrow",ME=p.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=ci(n);return _E(Cg,n).isInside?null:u.jsx(aa,{...o,...r,ref:t})});ME.displayName=Cg;function RE(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 OE(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 DE(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 LE(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const a=t[s],l=t[i],c=a.x,d=a.y,h=l.x,m=l.y;d>r!=m>r&&n<(h-c)*(r-d)/(m-d)+c&&(o=!o)}return o}function $E(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),FE(t)}function FE(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 BE=vg,zE=wg,HE=bg,Tg=yg;const UE=BE,WE=zE,VE=HE,kg=p.forwardRef(({className:e,sideOffset:t=4,...n},r)=>u.jsx(Tg,{ref:r,sideOffset:t,className:te("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n}));kg.displayName=Tg.displayName;var Hl="ToastProvider",[Ul,KE,qE]=Yo("Toast"),[Eg,NN]=cn("Toast",[qE]),[GE,di]=Eg(Hl),Ig=e=>{const{__scopeToast:t,label:n="Notification",duration:r=5e3,swipeDirection:o="right",swipeThreshold:s=50,children:i}=e,[a,l]=p.useState(null),[c,d]=p.useState(0),h=p.useRef(!1),m=p.useRef(!1);return n.trim()||console.error(`Invalid prop \`label\` supplied to \`${Hl}\`. Expected non-empty \`string\`.`),u.jsx(Ul.Provider,{scope:t,children:u.jsx(GE,{scope:t,label:n,duration:r,swipeDirection:o,swipeThreshold:s,toastCount:c,viewport:a,onViewportChange:l,onToastAdd:p.useCallback(()=>d(f=>f+1),[]),onToastRemove:p.useCallback(()=>d(f=>f-1),[]),isFocusedToastEscapeKeyDownRef:h,isClosePausedRef:m,children:i})})};Ig.displayName=Hl;var Ng="ToastViewport",YE=["F8"],Wl="toast.viewportPause",Vl="toast.viewportResume",Ag=p.forwardRef((e,t)=>{const{__scopeToast:n,hotkey:r=YE,label:o="Notifications ({hotkey})",...s}=e,i=di(Ng,n),a=KE(n),l=p.useRef(null),c=p.useRef(null),d=p.useRef(null),h=p.useRef(null),m=$e(t,h,i.onViewportChange),f=r.join("+").replace(/Key/g,"").replace(/Digit/g,""),v=i.toastCount>0;p.useEffect(()=>{const x=y=>{var S;r.length!==0&&r.every(k=>y[k]||y.code===k)&&((S=h.current)==null||S.focus())};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[r]),p.useEffect(()=>{const x=l.current,y=h.current;if(v&&x&&y){const b=()=>{if(!i.isClosePausedRef.current){const T=new CustomEvent(Wl);y.dispatchEvent(T),i.isClosePausedRef.current=!0}},S=()=>{if(i.isClosePausedRef.current){const T=new CustomEvent(Vl);y.dispatchEvent(T),i.isClosePausedRef.current=!1}},k=T=>{!x.contains(T.relatedTarget)&&S()},C=()=>{x.contains(document.activeElement)||S()};return x.addEventListener("focusin",b),x.addEventListener("focusout",k),x.addEventListener("pointermove",b),x.addEventListener("pointerleave",C),window.addEventListener("blur",b),window.addEventListener("focus",S),()=>{x.removeEventListener("focusin",b),x.removeEventListener("focusout",k),x.removeEventListener("pointermove",b),x.removeEventListener("pointerleave",C),window.removeEventListener("blur",b),window.removeEventListener("focus",S)}}},[v,i.isClosePausedRef]);const g=p.useCallback(({tabbingDirection:x})=>{const b=a().map(S=>{const k=S.ref.current,C=[k,...lI(k)];return x==="forwards"?C:C.reverse()});return(x==="forwards"?b.reverse():b).flat()},[a]);return p.useEffect(()=>{const x=h.current;if(x){const y=b=>{var C,T,E;const S=b.altKey||b.ctrlKey||b.metaKey;if(b.key==="Tab"&&!S){const N=document.activeElement,R=b.shiftKey;if(b.target===x&&R){(C=c.current)==null||C.focus();return}const V=g({tabbingDirection:R?"backwards":"forwards"}),U=V.findIndex(j=>j===N);Gl(V.slice(U+1))?b.preventDefault():R?(T=c.current)==null||T.focus():(E=d.current)==null||E.focus()}};return x.addEventListener("keydown",y),()=>x.removeEventListener("keydown",y)}},[a,g]),u.jsxs(Dw,{ref:l,role:"region","aria-label":o.replace("{hotkey}",f),tabIndex:-1,style:{pointerEvents:v?void 0:"none"},children:[v&&u.jsx(Kl,{ref:c,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"forwards"});Gl(x)}}),u.jsx(Ul.Slot,{scope:n,children:u.jsx(ve.ol,{tabIndex:-1,...s,ref:m})}),v&&u.jsx(Kl,{ref:d,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"backwards"});Gl(x)}})]})});Ag.displayName=Ng;var jg="ToastFocusProxy",Kl=p.forwardRef((e,t)=>{const{__scopeToast:n,onFocusFromOutsideViewport:r,...o}=e,s=di(jg,n);return u.jsx(ni,{tabIndex:0,...o,ref:t,style:{position:"fixed"},onFocus:i=>{var c;const a=i.relatedTarget;!((c=s.viewport)!=null&&c.contains(a))&&r()}})});Kl.displayName=jg;var _o="Toast",XE="toast.swipeStart",JE="toast.swipeMove",ZE="toast.swipeCancel",QE="toast.swipeEnd",_g=p.forwardRef((e,t)=>{const{forceMount:n,open:r,defaultOpen:o,onOpenChange:s,...i}=e,[a,l]=Dn({prop:r,defaultProp:o??!0,onChange:s,caller:_o});return u.jsx(Wt,{present:n||a,children:u.jsx(nI,{open:a,...i,ref:t,onClose:()=>l(!1),onPause:xt(e.onPause),onResume:xt(e.onResume),onSwipeStart:ae(e.onSwipeStart,c=>{c.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:ae(e.onSwipeMove,c=>{const{x:d,y:h}=c.detail.delta;c.currentTarget.setAttribute("data-swipe","move"),c.currentTarget.style.setProperty("--radix-toast-swipe-move-x",`${d}px`),c.currentTarget.style.setProperty("--radix-toast-swipe-move-y",`${h}px`)}),onSwipeCancel:ae(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:ae(e.onSwipeEnd,c=>{const{x:d,y:h}=c.detail.delta;c.currentTarget.setAttribute("data-swipe","end"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),c.currentTarget.style.setProperty("--radix-toast-swipe-end-x",`${d}px`),c.currentTarget.style.setProperty("--radix-toast-swipe-end-y",`${h}px`),l(!1)})})})});_g.displayName=_o;var[eI,tI]=Eg(_o,{onClose(){}}),nI=p.forwardRef((e,t)=>{const{__scopeToast:n,type:r="foreground",duration:o,open:s,onClose:i,onEscapeKeyDown:a,onPause:l,onResume:c,onSwipeStart:d,onSwipeMove:h,onSwipeCancel:m,onSwipeEnd:f,...v}=e,g=di(_o,n),[x,y]=p.useState(null),b=$e(t,j=>y(j)),S=p.useRef(null),k=p.useRef(null),C=o||g.duration,T=p.useRef(0),E=p.useRef(C),N=p.useRef(0),{onToastAdd:R,onToastRemove:L}=g,z=xt(()=>{var W;(x==null?void 0:x.contains(document.activeElement))&&((W=g.viewport)==null||W.focus()),i()}),V=p.useCallback(j=>{!j||j===1/0||(window.clearTimeout(N.current),T.current=new Date().getTime(),N.current=window.setTimeout(z,j))},[z]);p.useEffect(()=>{const j=g.viewport;if(j){const W=()=>{V(E.current),c==null||c()},$=()=>{const O=new Date().getTime()-T.current;E.current=E.current-O,window.clearTimeout(N.current),l==null||l()};return j.addEventListener(Wl,$),j.addEventListener(Vl,W),()=>{j.removeEventListener(Wl,$),j.removeEventListener(Vl,W)}}},[g.viewport,C,l,c,V]),p.useEffect(()=>{s&&!g.isClosePausedRef.current&&V(C)},[s,C,g.isClosePausedRef,V]),p.useEffect(()=>(R(),()=>L()),[R,L]);const U=p.useMemo(()=>x?$g(x):null,[x]);return g.viewport?u.jsxs(u.Fragment,{children:[U&&u.jsx(rI,{__scopeToast:n,role:"status","aria-live":r==="foreground"?"assertive":"polite",children:U}),u.jsx(eI,{scope:n,onClose:z,children:Hr.createPortal(u.jsx(Ul.ItemSlot,{scope:n,children:u.jsx(Ow,{asChild:!0,onEscapeKeyDown:ae(a,()=>{g.isFocusedToastEscapeKeyDownRef.current||z(),g.isFocusedToastEscapeKeyDownRef.current=!1}),children:u.jsx(ve.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,j=>{j.key==="Escape"&&(a==null||a(j.nativeEvent),j.nativeEvent.defaultPrevented||(g.isFocusedToastEscapeKeyDownRef.current=!0,z()))}),onPointerDown:ae(e.onPointerDown,j=>{j.button===0&&(S.current={x:j.clientX,y:j.clientY})}),onPointerMove:ae(e.onPointerMove,j=>{if(!S.current)return;const W=j.clientX-S.current.x,$=j.clientY-S.current.y,O=!!k.current,P=["left","right"].includes(g.swipeDirection),I=["left","up"].includes(g.swipeDirection)?Math.min:Math.max,q=P?I(0,W):0,Y=P?0:I(0,$),_=j.pointerType==="touch"?10:2,M={x:q,y:Y},G={originalEvent:j,delta:M};O?(k.current=M,fi(JE,h,G,{discrete:!1})):Fg(M,g.swipeDirection,_)?(k.current=M,fi(XE,d,G,{discrete:!1}),j.target.setPointerCapture(j.pointerId)):(Math.abs(W)>_||Math.abs($)>_)&&(S.current=null)}),onPointerUp:ae(e.onPointerUp,j=>{const W=k.current,$=j.target;if($.hasPointerCapture(j.pointerId)&&$.releasePointerCapture(j.pointerId),k.current=null,S.current=null,W){const O=j.currentTarget,P={originalEvent:j,delta:W};Fg(W,g.swipeDirection,g.swipeThreshold)?fi(QE,f,P,{discrete:!0}):fi(ZE,m,P,{discrete:!0}),O.addEventListener("click",I=>I.preventDefault(),{once:!0})}})})})}),g.viewport)})]}):null}),rI=e=>{const{__scopeToast:t,children:n,...r}=e,o=di(_o,t),[s,i]=p.useState(!1),[a,l]=p.useState(!1);return iI(()=>i(!0)),p.useEffect(()=>{const c=window.setTimeout(()=>l(!0),1e3);return()=>window.clearTimeout(c)},[]),a?null:u.jsx(so,{asChild:!0,children:u.jsx(ni,{...r,children:s&&u.jsxs(u.Fragment,{children:[o.label," ",n]})})})},oI="ToastTitle",Pg=p.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(ve.div,{...r,ref:t})});Pg.displayName=oI;var sI="ToastDescription",Mg=p.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return u.jsx(ve.div,{...r,ref:t})});Mg.displayName=sI;var Rg="ToastAction",Og=p.forwardRef((e,t)=>{const{altText:n,...r}=e;return n.trim()?u.jsx(Lg,{altText:n,asChild:!0,children:u.jsx(ql,{...r,ref:t})}):(console.error(`Invalid prop \`altText\` supplied to \`${Rg}\`. Expected non-empty \`string\`.`),null)});Og.displayName=Rg;var Dg="ToastClose",ql=p.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e,o=tI(Dg,n);return u.jsx(Lg,{asChild:!0,children:u.jsx(ve.button,{type:"button",...r,ref:t,onClick:ae(e.onClick,o.onClose)})})});ql.displayName=Dg;var Lg=p.forwardRef((e,t)=>{const{__scopeToast:n,altText:r,...o}=e;return u.jsx(ve.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":r||void 0,...o,ref:t})});function $g(e){const t=[];return Array.from(e.childNodes).forEach(r=>{if(r.nodeType===r.TEXT_NODE&&r.textContent&&t.push(r.textContent),aI(r)){const o=r.ariaHidden||r.hidden||r.style.display==="none",s=r.dataset.radixToastAnnounceExclude==="";if(!o)if(s){const i=r.dataset.radixToastAnnounceAlt;i&&t.push(i)}else t.push(...$g(r))}}),t}function fi(e,t,n,{discrete:r}){const o=n.originalEvent.currentTarget,s=new CustomEvent(e,{bubbles:!0,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?Fi(o,s):o.dispatchEvent(s)}var Fg=(e,t,n=0)=>{const r=Math.abs(e.x),o=Math.abs(e.y),s=r>o;return t==="left"||t==="right"?s&&r>n:!s&&o>n};function iI(e=()=>{}){const t=xt(e);It(()=>{let n=0,r=0;return n=window.requestAnimationFrame(()=>r=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(n),window.cancelAnimationFrame(r)}},[t])}function aI(e){return e.nodeType===e.ELEMENT_NODE}function lI(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function Gl(e){const t=document.activeElement;return e.some(n=>n===t?!0:(n.focus(),document.activeElement!==t))}var cI=Ig,Bg=Ag,zg=_g,Hg=Pg,Ug=Mg,Wg=Og,Vg=ql;const uI=cI,Kg=p.forwardRef(({className:e,...t},n)=>u.jsx(Bg,{ref:n,className:te("fixed bottom-0 right-0 z-[100] flex max-h-screen w-full flex-col p-4 md:max-w-[420px]",e),...t}));Kg.displayName=Bg.displayName;const dI=zr.cva("group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-8 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",{variants:{variant:{default:"border bg-background text-foreground",destructive:"destructive group border-destructive bg-destructive text-destructive-foreground"}},defaultVariants:{variant:"default"}}),qg=p.forwardRef(({className:e,variant:t,...n},r)=>u.jsx(zg,{ref:r,className:te(dI({variant:t}),e),...n}));qg.displayName=zg.displayName;const fI=p.forwardRef(({className:e,...t},n)=>u.jsx(Wg,{ref:n,className:te("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}));fI.displayName=Wg.displayName;const Gg=p.forwardRef(({className:e,...t},n)=>u.jsx(Vg,{ref:n,className:te("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"})}));Gg.displayName=Vg.displayName;const Yg=p.forwardRef(({className:e,...t},n)=>u.jsx(Hg,{ref:n,className:te("text-sm font-semibold",e),...t}));Yg.displayName=Hg.displayName;const Xg=p.forwardRef(({className:e,...t},n)=>u.jsx(Ug,{ref:n,className:te("text-sm opacity-90",e),...t}));Xg.displayName=Ug.displayName;function hI(){const{toasts:e}=nl();return u.jsxs(uI,{children:[e.map(function({id:t,title:n,description:r,action:o,...s}){return u.jsxs(qg,{...s,children:[u.jsxs("div",{className:"grid gap-1",children:[n&&u.jsx(Yg,{children:n}),r&&u.jsx(Xg,{children:r})]}),o,u.jsx(Gg,{})]},t)}),u.jsx(Kg,{})]})}var pI=(e,t,n,r,o,s,i,a)=>{let l=document.documentElement,c=["light","dark"];function d(f){(Array.isArray(e)?e:[e]).forEach(v=>{let g=v==="class",x=g&&s?o.map(y=>s[y]||y):o;g?(l.classList.remove(...x),l.classList.add(s&&s[f]?s[f]:f)):l.setAttribute(v,f)}),h(f)}function h(f){a&&c.includes(f)&&(l.style.colorScheme=f)}function m(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}if(r)d(r);else try{let f=localStorage.getItem(t)||n,v=i&&f==="system"?m():f;d(v)}catch{}},mI=p.createContext(void 0),gI={setTheme:e=>{},themes:[]},xI=()=>{var e;return(e=p.useContext(mI))!=null?e:gI};p.memo(({forcedTheme:e,storageKey:t,attribute:n,enableSystem:r,enableColorScheme:o,defaultTheme:s,value:i,themes:a,nonce:l,scriptProps:c})=>{let d=JSON.stringify([n,t,s,e,a,i,r,o]).slice(1,-1);return p.createElement("script",{...c,suppressHydrationWarning:!0,nonce:typeof window>"u"?l:"",dangerouslySetInnerHTML:{__html:`(${pI.toString()})(${d})`}})});var vI=e=>{switch(e){case"success":return yI;case"info":return CI;case"warning":return SI;case"error":return TI;default:return null}},wI=Array(12).fill(0),bI=({visible:e,className:t})=>w.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},w.createElement("div",{className:"sonner-spinner"},wI.map((n,r)=>w.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),yI=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"})),SI=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"})),CI=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"})),TI=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"})),EI=()=>{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},Yl=1,II=class{constructor(){this.subscribe=e=>(this.subscribers.push(e),()=>{let t=this.subscribers.indexOf(e);this.subscribers.splice(t,1)}),this.publish=e=>{this.subscribers.forEach(t=>t(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e]},this.create=e=>{var t;let{message:n,...r}=e,o=typeof(e==null?void 0:e.id)=="number"||((t=e.id)==null?void 0:t.length)>0?e.id:Yl++,s=this.toasts.find(a=>a.id===o),i=e.dismissible===void 0?!0:e.dismissible;return this.dismissedToasts.has(o)&&this.dismissedToasts.delete(o),s?this.toasts=this.toasts.map(a=>a.id===o?(this.publish({...a,...e,id:o,title:n}),{...a,...e,id:o,dismissible:i,title:n}):a):this.addToast({title:n,...r,dismissible:i,id:o}),o},this.dismiss=e=>(this.dismissedToasts.add(e),e||this.toasts.forEach(t=>{this.subscribers.forEach(n=>n({id:t.id,dismiss:!0}))}),this.subscribers.forEach(t=>t({id:e,dismiss:!0})),e),this.message=(e,t)=>this.create({...t,message:e}),this.error=(e,t)=>this.create({...t,message:e,type:"error"}),this.success=(e,t)=>this.create({...t,type:"success",message:e}),this.info=(e,t)=>this.create({...t,type:"info",message:e}),this.warning=(e,t)=>this.create({...t,type:"warning",message:e}),this.loading=(e,t)=>this.create({...t,type:"loading",message:e}),this.promise=(e,t)=>{if(!t)return;let n;t.loading!==void 0&&(n=this.create({...t,promise:e,type:"loading",message:t.loading,description:typeof t.description!="function"?t.description:void 0}));let r=e instanceof Promise?e:e(),o=n!==void 0,s,i=r.then(async l=>{if(s=["resolve",l],w.isValidElement(l))o=!1,this.create({id:n,type:"default",message:l});else if(AI(l)&&!l.ok){o=!1;let c=typeof t.error=="function"?await t.error(`HTTP error! status: ${l.status}`):t.error,d=typeof t.description=="function"?await t.description(`HTTP error! status: ${l.status}`):t.description;this.create({id:n,type:"error",message:c,description:d})}else if(t.success!==void 0){o=!1;let c=typeof t.success=="function"?await t.success(l):t.success,d=typeof t.description=="function"?await t.description(l):t.description;this.create({id:n,type:"success",message:c,description:d})}}).catch(async l=>{if(s=["reject",l],t.error!==void 0){o=!1;let c=typeof t.error=="function"?await t.error(l):t.error,d=typeof t.description=="function"?await t.description(l):t.description;this.create({id:n,type:"error",message:c,description:d})}}).finally(()=>{var l;o&&(this.dismiss(n),n=void 0),(l=t.finally)==null||l.call(t)}),a=()=>new Promise((l,c)=>i.then(()=>s[0]==="reject"?c(s[1]):l(s[1])).catch(c));return typeof n!="string"&&typeof n!="number"?{unwrap:a}:Object.assign(n,{unwrap:a})},this.custom=(e,t)=>{let n=(t==null?void 0:t.id)||Yl++;return this.create({jsx:e(n),id:n,...t}),n},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},qt=new II,NI=(e,t)=>{let n=(t==null?void 0:t.id)||Yl++;return qt.addToast({title:e,...t,id:n}),n},AI=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",jI=NI,_I=()=>qt.toasts,PI=()=>qt.getActiveToasts();Object.assign(jI,{success:qt.success,info:qt.info,warning:qt.warning,error:qt.error,custom:qt.custom,message:qt.message,promise:qt.promise,dismiss:qt.dismiss,loading:qt.loading},{getHistory:_I,getToasts:PI});function MI(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))}MI(`:where(html[dir="ltr"]),:where([data-sonner-toaster][dir="ltr"]){--toast-icon-margin-start: -3px;--toast-icon-margin-end: 4px;--toast-svg-margin-start: -1px;--toast-svg-margin-end: 0px;--toast-button-margin-start: auto;--toast-button-margin-end: 0;--toast-close-button-start: 0;--toast-close-button-end: unset;--toast-close-button-transform: translate(-35%, -35%)}:where(html[dir="rtl"]),:where([data-sonner-toaster][dir="rtl"]){--toast-icon-margin-start: 4px;--toast-icon-margin-end: -3px;--toast-svg-margin-start: 0px;--toast-svg-margin-end: -1px;--toast-button-margin-start: 0;--toast-button-margin-end: auto;--toast-close-button-start: unset;--toast-close-button-end: 0;--toast-close-button-transform: translate(35%, -35%)}:where([data-sonner-toaster]){position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1: hsl(0, 0%, 99%);--gray2: hsl(0, 0%, 97.3%);--gray3: hsl(0, 0%, 95.1%);--gray4: hsl(0, 0%, 93%);--gray5: hsl(0, 0%, 90.9%);--gray6: hsl(0, 0%, 88.7%);--gray7: hsl(0, 0%, 85.8%);--gray8: hsl(0, 0%, 78%);--gray9: hsl(0, 0%, 56.1%);--gray10: hsl(0, 0%, 52.3%);--gray11: hsl(0, 0%, 43.5%);--gray12: hsl(0, 0%, 9%);--border-radius: 8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:none;z-index:999999999;transition:transform .4s ease}:where([data-sonner-toaster][data-lifted="true"]){transform:translateY(-10px)}@media (hover: none) and (pointer: coarse){:where([data-sonner-toaster][data-lifted="true"]){transform:none}}:where([data-sonner-toaster][data-x-position="right"]){right:var(--offset-right)}:where([data-sonner-toaster][data-x-position="left"]){left:var(--offset-left)}:where([data-sonner-toaster][data-x-position="center"]){left:50%;transform:translate(-50%)}:where([data-sonner-toaster][data-y-position="top"]){top:var(--offset-top)}:where([data-sonner-toaster][data-y-position="bottom"]){bottom:var(--offset-bottom)}:where([data-sonner-toast]){--y: translateY(100%);--lift-amount: calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);filter:blur(0);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:none;overflow-wrap:anywhere}:where([data-sonner-toast][data-styled="true"]){padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px #0000001a;width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}:where([data-sonner-toast]:focus-visible){box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast][data-y-position="top"]){top:0;--y: translateY(-100%);--lift: 1;--lift-amount: calc(1 * var(--gap))}:where([data-sonner-toast][data-y-position="bottom"]){bottom:0;--y: translateY(100%);--lift: -1;--lift-amount: calc(var(--lift) * var(--gap))}:where([data-sonner-toast]) :where([data-description]){font-weight:400;line-height:1.4;color:inherit}:where([data-sonner-toast]) :where([data-title]){font-weight:500;line-height:1.5;color:inherit}:where([data-sonner-toast]) :where([data-icon]){display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}:where([data-sonner-toast][data-promise="true"]) :where([data-icon])>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}:where([data-sonner-toast]) :where([data-icon])>*{flex-shrink:0}:where([data-sonner-toast]) :where([data-icon]) svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}:where([data-sonner-toast]) :where([data-content]){display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;cursor:pointer;outline:none;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}:where([data-sonner-toast]) :where([data-button]):focus-visible{box-shadow:0 0 0 2px #0006}:where([data-sonner-toast]) :where([data-button]):first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}:where([data-sonner-toast]) :where([data-cancel]){color:var(--normal-text);background:rgba(0,0,0,.08)}:where([data-sonner-toast][data-theme="dark"]) :where([data-cancel]){background:rgba(255,255,255,.3)}:where([data-sonner-toast]) :where([data-close-button]){position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast] [data-close-button]{background:var(--gray1)}:where([data-sonner-toast]) :where([data-close-button]):focus-visible{box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast]) :where([data-disabled="true"]){cursor:not-allowed}:where([data-sonner-toast]):hover :where([data-close-button]):hover{background:var(--gray2);border-color:var(--gray5)}:where([data-sonner-toast][data-swiping="true"]):before{content:"";position:absolute;left:-50%;right:-50%;height:100%;z-index:-1}:where([data-sonner-toast][data-y-position="top"][data-swiping="true"]):before{bottom:50%;transform:scaleY(3) translateY(50%)}:where([data-sonner-toast][data-y-position="bottom"][data-swiping="true"]):before{top:50%;transform:scaleY(3) translateY(-50%)}:where([data-sonner-toast][data-swiping="false"][data-removed="true"]):before{content:"";position:absolute;inset:0;transform:scaleY(2)}:where([data-sonner-toast]):after{content:"";position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}:where([data-sonner-toast][data-mounted="true"]){--y: translateY(0);opacity:1}:where([data-sonner-toast][data-expanded="false"][data-front="false"]){--scale: var(--toasts-before) * .05 + 1;--y: translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}:where([data-sonner-toast])>*{transition:opacity .4s}:where([data-sonner-toast][data-expanded="false"][data-front="false"][data-styled="true"])>*{opacity:0}:where([data-sonner-toast][data-visible="false"]){opacity:0;pointer-events:none}:where([data-sonner-toast][data-mounted="true"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}:where([data-sonner-toast][data-removed="true"][data-front="true"][data-swipe-out="false"]){--y: translateY(calc(var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="false"]){--y: translateY(40%);opacity:0;transition:transform .5s,opacity .2s}:where([data-sonner-toast][data-removed="true"][data-front="false"]):before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y, 0px)) translate(var(--swipe-amount-x, 0px));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width: 600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-theme=light]{--normal-bg: #fff;--normal-border: var(--gray4);--normal-text: var(--gray12);--success-bg: hsl(143, 85%, 96%);--success-border: hsl(145, 92%, 91%);--success-text: hsl(140, 100%, 27%);--info-bg: hsl(208, 100%, 97%);--info-border: hsl(221, 91%, 91%);--info-text: hsl(210, 92%, 45%);--warning-bg: hsl(49, 100%, 97%);--warning-border: hsl(49, 91%, 91%);--warning-text: hsl(31, 92%, 45%);--error-bg: hsl(359, 100%, 97%);--error-border: hsl(359, 100%, 94%);--error-text: hsl(360, 100%, 45%)}[data-sonner-toaster][data-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg: #000;--normal-border: hsl(0, 0%, 20%);--normal-text: var(--gray1)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg: #fff;--normal-border: var(--gray3);--normal-text: var(--gray12)}[data-sonner-toaster][data-theme=dark]{--normal-bg: #000;--normal-bg-hover: hsl(0, 0%, 12%);--normal-border: hsl(0, 0%, 20%);--normal-border-hover: hsl(0, 0%, 25%);--normal-text: var(--gray1);--success-bg: hsl(150, 100%, 6%);--success-border: hsl(147, 100%, 12%);--success-text: hsl(150, 86%, 65%);--info-bg: hsl(215, 100%, 6%);--info-border: hsl(223, 100%, 12%);--info-text: hsl(216, 87%, 65%);--warning-bg: hsl(64, 100%, 6%);--warning-border: hsl(60, 100%, 12%);--warning-text: hsl(46, 87%, 65%);--error-bg: hsl(358, 76%, 10%);--error-border: hsl(357, 89%, 16%);--error-text: hsl(358, 100%, 81%)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success],[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info],[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning],[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error],[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size: 16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:nth-child(1){animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}to{opacity:.15}}@media (prefers-reduced-motion){[data-sonner-toast],[data-sonner-toast]>*,.sonner-loading-bar{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}
|
|
130
130
|
`);function hi(e){return e.label!==void 0}var RI=3,OI="32px",DI="16px",Jg=4e3,LI=356,$I=14,FI=20,BI=200;function gn(...e){return e.filter(Boolean).join(" ")}function zI(e){let[t,n]=e.split("-"),r=[];return t&&r.push(t),n&&r.push(n),r}var HI=e=>{var t,n,r,o,s,i,a,l,c,d,h;let{invert:m,toast:f,unstyled:v,interacting:g,setHeights:x,visibleToasts:y,heights:b,index:S,toasts:k,expanded:C,removeToast:T,defaultRichColors:E,closeButton:N,style:R,cancelButtonStyle:L,actionButtonStyle:z,className:V="",descriptionClassName:U="",duration:j,position:W,gap:$,loadingIcon:O,expandByDefault:P,classNames:I,icons:q,closeButtonAriaLabel:Y="Close toast",pauseWhenPageIsHidden:_}=e,[M,G]=w.useState(null),[J,oe]=w.useState(null),[K,D]=w.useState(!1),[X,Z]=w.useState(!1),[ue,F]=w.useState(!1),[ne,de]=w.useState(!1),[ce,ge]=w.useState(!1),[Ce,Pe]=w.useState(0),[De,ze]=w.useState(0),rt=w.useRef(f.duration||j||Jg),Ct=w.useRef(null),Ve=w.useRef(null),He=S===0,Ye=S+1<=y,Le=f.type,Ue=f.dismissible!==!1,mt=f.className||"",Dt=f.descriptionClassName||"",at=w.useMemo(()=>b.findIndex(xe=>xe.toastId===f.id)||0,[b,f.id]),At=w.useMemo(()=>{var xe;return(xe=f.closeButton)!=null?xe:N},[f.closeButton,N]),wt=w.useMemo(()=>f.duration||j||Jg,[f.duration,j]),dt=w.useRef(0),bt=w.useRef(0),Tt=w.useRef(0),jt=w.useRef(null),[Te,qe]=W.split("-"),Ee=w.useMemo(()=>b.reduce((xe,Be,Xe)=>Xe>=at?xe:xe+Be.height,0),[b,at]),Ke=EI(),zt=f.invert||m,re=Le==="loading";bt.current=w.useMemo(()=>at*$+Ee,[at,Ee]),w.useEffect(()=>{rt.current=wt},[wt]),w.useEffect(()=>{D(!0)},[]),w.useEffect(()=>{let xe=Ve.current;if(xe){let Be=xe.getBoundingClientRect().height;return ze(Be),x(Xe=>[{toastId:f.id,height:Be,position:f.position},...Xe]),()=>x(Xe=>Xe.filter(kt=>kt.toastId!==f.id))}},[x,f.id]),w.useLayoutEffect(()=>{if(!K)return;let xe=Ve.current,Be=xe.style.height;xe.style.height="auto";let Xe=xe.getBoundingClientRect().height;xe.style.height=Be,ze(Xe),x(kt=>kt.find(Et=>Et.toastId===f.id)?kt.map(Et=>Et.toastId===f.id?{...Et,height:Xe}:Et):[{toastId:f.id,height:Xe,position:f.position},...kt])},[K,f.title,f.description,x,f.id]);let be=w.useCallback(()=>{Z(!0),Pe(bt.current),x(xe=>xe.filter(Be=>Be.toastId!==f.id)),setTimeout(()=>{T(f)},BI)},[f,T,x,bt]);w.useEffect(()=>{if(f.promise&&Le==="loading"||f.duration===1/0||f.type==="loading")return;let xe;return C||g||_&&Ke?(()=>{if(Tt.current<dt.current){let Be=new Date().getTime()-dt.current;rt.current=rt.current-Be}Tt.current=new Date().getTime()})():rt.current!==1/0&&(dt.current=new Date().getTime(),xe=setTimeout(()=>{var Be;(Be=f.onAutoClose)==null||Be.call(f,f),be()},rt.current)),()=>clearTimeout(xe)},[C,g,f,Le,_,Ke,be]),w.useEffect(()=>{f.delete&&be()},[be,f.delete]);function ot(){var xe,Be,Xe;return q!=null&&q.loading?w.createElement("div",{className:gn(I==null?void 0:I.loader,(xe=f==null?void 0:f.classNames)==null?void 0:xe.loader,"sonner-loader"),"data-visible":Le==="loading"},q.loading):O?w.createElement("div",{className:gn(I==null?void 0:I.loader,(Be=f==null?void 0:f.classNames)==null?void 0:Be.loader,"sonner-loader"),"data-visible":Le==="loading"},O):w.createElement(bI,{className:gn(I==null?void 0:I.loader,(Xe=f==null?void 0:f.classNames)==null?void 0:Xe.loader),visible:Le==="loading"})}return w.createElement("li",{tabIndex:0,ref:Ve,className:gn(V,mt,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[Le],(n=f==null?void 0:f.classNames)==null?void 0:n[Le]),"data-sonner-toast":"","data-rich-colors":(r=f.richColors)!=null?r:E,"data-styled":!(f.jsx||f.unstyled||v),"data-mounted":K,"data-promise":!!f.promise,"data-swiped":ce,"data-removed":X,"data-visible":Ye,"data-y-position":Te,"data-x-position":qe,"data-index":S,"data-front":He,"data-swiping":ue,"data-dismissible":Ue,"data-type":Le,"data-invert":zt,"data-swipe-out":ne,"data-swipe-direction":J,"data-expanded":!!(C||P&&K),style:{"--index":S,"--toasts-before":S,"--z-index":k.length-S,"--offset":`${X?Ce:bt.current}px`,"--initial-height":P?"auto":`${De}px`,...R,...f.style},onDragEnd:()=>{F(!1),G(null),jt.current=null},onPointerDown:xe=>{re||!Ue||(Ct.current=new Date,Pe(bt.current),xe.target.setPointerCapture(xe.pointerId),xe.target.tagName!=="BUTTON"&&(F(!0),jt.current={x:xe.clientX,y:xe.clientY}))},onPointerUp:()=>{var xe,Be,Xe,kt;if(ne||!Ue)return;jt.current=null;let Et=Number(((xe=Ve.current)==null?void 0:xe.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),Nt=Number(((Be=Ve.current)==null?void 0:Be.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),Lt=new Date().getTime()-((Xe=Ct.current)==null?void 0:Xe.getTime()),je=M==="x"?Et:Nt,ht=Math.abs(je)/Lt;if(Math.abs(je)>=FI||ht>.11){Pe(bt.current),(kt=f.onDismiss)==null||kt.call(f,f),oe(M==="x"?Et>0?"right":"left":Nt>0?"down":"up"),be(),de(!0),ge(!1);return}F(!1),G(null)},onPointerMove:xe=>{var Be,Xe,kt,Et;if(!jt.current||!Ue||((Be=window.getSelection())==null?void 0:Be.toString().length)>0)return;let Nt=xe.clientY-jt.current.y,Lt=xe.clientX-jt.current.x,je=(Xe=e.swipeDirections)!=null?Xe:zI(W);!M&&(Math.abs(Lt)>1||Math.abs(Nt)>1)&&G(Math.abs(Lt)>Math.abs(Nt)?"x":"y");let ht={x:0,y:0};M==="y"?(je.includes("top")||je.includes("bottom"))&&(je.includes("top")&&Nt<0||je.includes("bottom")&&Nt>0)&&(ht.y=Nt):M==="x"&&(je.includes("left")||je.includes("right"))&&(je.includes("left")&&Lt<0||je.includes("right")&&Lt>0)&&(ht.x=Lt),(Math.abs(ht.x)>0||Math.abs(ht.y)>0)&&ge(!0),(kt=Ve.current)==null||kt.style.setProperty("--swipe-amount-x",`${ht.x}px`),(Et=Ve.current)==null||Et.style.setProperty("--swipe-amount-y",`${ht.y}px`)}},At&&!f.jsx?w.createElement("button",{"aria-label":Y,"data-disabled":re,"data-close-button":!0,onClick:re||!Ue?()=>{}:()=>{var xe;be(),(xe=f.onDismiss)==null||xe.call(f,f)},className:gn(I==null?void 0:I.closeButton,(o=f==null?void 0:f.classNames)==null?void 0:o.closeButton)},(s=q==null?void 0:q.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,Le||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||ot():null,f.type!=="loading"?f.icon||(q==null?void 0:q[Le])||vI(Le):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(U,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&&hi(f.cancel)?w.createElement("button",{"data-button":!0,"data-cancel":!0,style:f.cancelButtonStyle||L,onClick:xe=>{var Be,Xe;hi(f.cancel)&&Ue&&((Xe=(Be=f.cancel).onClick)==null||Xe.call(Be,xe),be())},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&&hi(f.action)?w.createElement("button",{"data-button":!0,"data-action":!0,style:f.actionButtonStyle||z,onClick:xe=>{var Be,Xe;hi(f.action)&&((Xe=(Be=f.action).onClick)==null||Xe.call(Be,xe),!xe.defaultPrevented&&be())},className:gn(I==null?void 0:I.actionButton,(h=f==null?void 0:f.classNames)==null?void 0:h.actionButton)},f.action.label):null))};function Zg(){if(typeof window>"u"||typeof document>"u")return"ltr";let e=document.documentElement.getAttribute("dir");return e==="auto"||!e?window.getComputedStyle(document.documentElement).direction:e}function UI(e,t){let n={};return[e,t].forEach((r,o)=>{let s=o===1,i=s?"--mobile-offset":"--offset",a=s?DI:OI;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 WI=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:h,duration:m,style:f,visibleToasts:v=RI,toastOptions:g,dir:x=Zg(),gap:y=$I,loadingIcon:b,icons:S,containerAriaLabel:k="Notifications",pauseWhenPageIsHidden:C}=e,[T,E]=w.useState([]),N=w.useMemo(()=>Array.from(new Set([r].concat(T.filter(_=>_.position).map(_=>_.position)))),[T,r]),[R,L]=w.useState([]),[z,V]=w.useState(!1),[U,j]=w.useState(!1),[W,$]=w.useState(d!=="system"?d:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),O=w.useRef(null),P=o.join("+").replace(/Key/g,"").replace(/Digit/g,""),I=w.useRef(null),q=w.useRef(!1),Y=w.useCallback(_=>{E(M=>{var G;return(G=M.find(J=>J.id===_.id))!=null&&G.delete||qt.dismiss(_.id),M.filter(({id:J})=>J!==_.id)})},[]);return w.useEffect(()=>qt.subscribe(_=>{if(_.dismiss){E(M=>M.map(G=>G.id===_.id?{...G,delete:!0}:G));return}setTimeout(()=>{Po.flushSync(()=>{E(M=>{let G=M.findIndex(J=>J.id===_.id);return G!==-1?[...M.slice(0,G),{...M[G],..._},...M.slice(G+1)]:[_,...M]})})})}),[]),w.useEffect(()=>{if(d!=="system"){$(d);return}if(d==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?$("dark"):$("light")),typeof window>"u")return;let _=window.matchMedia("(prefers-color-scheme: dark)");try{_.addEventListener("change",({matches:M})=>{$(M?"dark":"light")})}catch{_.addListener(({matches:G})=>{try{$(G?"dark":"light")}catch(J){console.error(J)}})}},[d]),w.useEffect(()=>{T.length<=1&&V(!1)},[T]),w.useEffect(()=>{let _=M=>{var G,J;o.every(oe=>M[oe]||M.code===oe)&&(V(!0),(G=O.current)==null||G.focus()),M.code==="Escape"&&(document.activeElement===O.current||(J=O.current)!=null&&J.contains(document.activeElement))&&V(!1)};return document.addEventListener("keydown",_),()=>document.removeEventListener("keydown",_)},[o]),w.useEffect(()=>{if(O.current)return()=>{I.current&&(I.current.focus({preventScroll:!0}),I.current=null,q.current=!1)}},[O.current]),w.createElement("section",{ref:t,"aria-label":`${k} ${P}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},N.map((_,M)=>{var G;let[J,oe]=_.split("-");return T.length?w.createElement("ol",{key:_,dir:x==="auto"?Zg():x,tabIndex:-1,ref:O,className:a,"data-sonner-toaster":!0,"data-theme":W,"data-y-position":J,"data-lifted":z&&T.length>1&&!s,"data-x-position":oe,style:{"--front-toast-height":`${((G=R[0])==null?void 0:G.height)||0}px`,"--width":`${LI}px`,"--gap":`${y}px`,...f,...UI(l,c)},onBlur:K=>{q.current&&!K.currentTarget.contains(K.relatedTarget)&&(q.current=!1,I.current&&(I.current.focus({preventScroll:!0}),I.current=null))},onFocus:K=>{K.target instanceof HTMLElement&&K.target.dataset.dismissible==="false"||q.current||(q.current=!0,I.current=K.relatedTarget)},onMouseEnter:()=>V(!0),onMouseMove:()=>V(!0),onMouseLeave:()=>{U||V(!1)},onDragEnd:()=>V(!1),onPointerDown:K=>{K.target instanceof HTMLElement&&K.target.dataset.dismissible==="false"||j(!0)},onPointerUp:()=>j(!1)},T.filter(K=>!K.position&&M===0||K.position===_).map((K,D)=>{var X,Z;return w.createElement(HI,{key:K.id,icons:S,index:D,toast:K,defaultRichColors:h,duration:(X=g==null?void 0:g.duration)!=null?X:m,className:g==null?void 0:g.className,descriptionClassName:g==null?void 0:g.descriptionClassName,invert:n,visibleToasts:v,closeButton:(Z=g==null?void 0:g.closeButton)!=null?Z:i,interacting:U,position:_,style:g==null?void 0:g.style,unstyled:g==null?void 0:g.unstyled,classNames:g==null?void 0:g.classNames,cancelButtonStyle:g==null?void 0:g.cancelButtonStyle,actionButtonStyle:g==null?void 0:g.actionButtonStyle,removeToast:Y,toasts:T.filter(ue=>ue.position==K.position),heights:R.filter(ue=>ue.position==K.position),setHeights:L,expandByDefault:s,gap:y,loadingIcon:b,expanded:z,pauseWhenPageIsHidden:C,swipeDirections:e.swipeDirections})})):null}))});const VI=({...e})=>{const{theme:t="system"}=xI();return u.jsx(WI,{theme:t,className:"toaster group",toastOptions:{classNames:{toast:"group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",description:"group-[.toast]:text-muted-foreground",actionButton:"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",cancelButton:"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground"}},...e})};B.Api=Fv,B.ApiClient=$v,B.ApiProvider=tu,B.ArtifactRenderer=Cp,B.Badge=zh,B.Button=tt,B.Card=sl,B.CardContent=cl,B.CardDescription=ll,B.CardHeader=il,B.CardTitle=al,B.ChatApi=Ko,B.ChatApp=kk,B.ChatInput=Hf,B.ChatInterface=Rr,B.ChatProviders=vr,B.ChatWidget=Nk,B.Command=bl,B.CommandEmpty=Cl,B.CommandGroup=Tl,B.CommandInput=yl,B.CommandItem=kl,B.CommandList=Sl,B.DEFAULT_TIMEOUT_MS=Yc,B.Dialog=Qa,B.DialogContent=Bs,B.DialogHeader=zs,B.DialogTitle=Hs,B.DropdownMenu=Ss,B.DropdownMenuContent=ho,B.DropdownMenuItem=Bn,B.DropdownMenuTrigger=Cs,B.FileViewerModal=ap,B.HISTORY_TIMEOUT_MS=Xc,B.Input=Pl,B.InterruptPartRenderer=kp,B.Label=fm,B.MarkdownContent=Mr,B.MessageBody=jp,B.MessageComponent=Ys,B.MessageList=hl,B.MessageRow=fl,B.NewChatButton=Ak,B.PlotArtifact=yp,B.ResearchTaskArtifact=Sp,B.SETTINGS_STORAGE_KEY=$i,B.ScrollArea=_l,B.Select=lE,B.SelectContent=Qm,B.SelectItem=eg,B.SelectTrigger=Xm,B.SelectValue=cE,B.Separator=og,B.Sheet=bE,B.SheetContent=hg,B.SheetDescription=gg,B.SheetHeader=pg,B.SheetTitle=mg,B.SheetTrigger=yE,B.SimpleChat=Ek,B.SimpleJsonView=ul,B.Sonner=VI,B.StreamProgress=Ep,B.Switch=dg,B.Textarea=Ta,B.ThinkingIndicator=Np,B.ThreadListItem=im,B.ThreadManager=ti,B.ThreadStateProvider=Tu,B.ThreadsProvider=fu,B.TimelineColumn=mx,B.Toaster=hI,B.ToolComponent=Ip,B.Tooltip=WE,B.TooltipContent=kg,B.TooltipProvider=UE,B.TooltipTrigger=VE,B.UserTextContent=Ap,B.applySettings=ww,B.buildCheckpointIndex=Ql,B.buildCheckpointPreviewMap=ox,B.chatApiClient=Rn,B.del=Ai,B.downloadFileById=Zc,B.extractConfigFields=mi,B.fileToBase64=nu,B.get=Jt,B.getChatToken=qc,B.getCheckpointForMessage=sx,B.getCurrentSettings=vw,B.getDefaultApiConfig=Mu,B.getDefaultChatSettings=Ru,B.getFileContent=_i,B.getFileInfo=zv,B.getMessageAttemptInfo=ec,B.getMessageDomKey=dl,B.getPreviewForMessage=pi,B.httpClient=Xt,B.hydrateHistorySnapshots=Mn,B.isEnvelope=ou,B.listFiles=Qc,B.loadStoredSettings=Ou,B.onChatTokenChanged=Gc,B.post=Vo,B.processAttachments=ru,B.put=Jc,B.readNumber=nc,B.readString=Pn,B.resolveChatBaseUrl=vn,B.saveSettings=Du,B.setChatToken=Wo,B.toPlainObject=_n,B.unwrap=$t,B.useApi=Xr,B.useCheckpointIndex=tc,B.useFilePreview=_p,B.useHasChatSession=mw,B.useParsedMessageContent=Pp,B.useShallowStableValue=Au,B.useStream=Li,B.useStreamingHook=Li,B.useThreadHistoryState=bu,B.useThreadManagerViewState=cm,B.useThreadState=eo,B.useThreadStateUpdater=Cu,B.useThreads=gr,B.useThreadsState=uu,B.viewFileById=Bv,Object.defineProperty(B,Symbol.toStringTag,{value:"Module"})});
|