teodor-new-chat-ui 4.3.436 → 4.3.437
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.
|
@@ -52,7 +52,7 @@ export interface ThreadStateContextValue {
|
|
|
52
52
|
namespace: string | null;
|
|
53
53
|
};
|
|
54
54
|
checkpoints: HydratedCheckpointSnapshot[];
|
|
55
|
-
metadata: ThreadStateMetadata
|
|
55
|
+
metadata: ThreadStateMetadata;
|
|
56
56
|
isLoading: boolean;
|
|
57
57
|
isHistoryLoading: boolean;
|
|
58
58
|
error: string | null;
|
|
@@ -38,7 +38,7 @@ export interface ThreadStateContextValue {
|
|
|
38
38
|
checkpoints: HydratedCheckpointSnapshot[];
|
|
39
39
|
checkpointIndex: CheckpointIndex;
|
|
40
40
|
timelineCheckpoints: TimelineCheckpoint[];
|
|
41
|
-
metadata: ThreadStateMetadata
|
|
41
|
+
metadata: ThreadStateMetadata;
|
|
42
42
|
isLoading: boolean;
|
|
43
43
|
isHistoryLoading: boolean;
|
|
44
44
|
isLoadingCheckpoint: boolean;
|
package/dist/index.esm.js
CHANGED
|
@@ -4382,10 +4382,7 @@ function Iw({
|
|
|
4382
4382
|
), K = me(
|
|
4383
4383
|
(q) => j(() => q),
|
|
4384
4384
|
[]
|
|
4385
|
-
), G = Ze(() => {
|
|
4386
|
-
const q = c.assemblingId ?? null;
|
|
4387
|
-
return q ? { assemblingMessageId: q } : null;
|
|
4388
|
-
}, [c.assemblingId]), A = Ze(
|
|
4385
|
+
), G = Ze(() => ({ assemblingMessageId: c.assemblingId ?? null }), [c.assemblingId]), A = Ze(
|
|
4389
4386
|
() => ({
|
|
4390
4387
|
threadId: l,
|
|
4391
4388
|
messages: c.messages,
|
package/dist/index.umd.js
CHANGED
|
@@ -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("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(()=>({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,`;
|
package/package.json
CHANGED