tia-chatbot 1.1.7 → 1.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/tia-widget.iife.js
CHANGED
|
@@ -342,7 +342,7 @@ class StreamProcessor extends AudioWorkletProcessor {
|
|
|
342
342
|
}
|
|
343
343
|
|
|
344
344
|
registerProcessor('stream_processor', StreamProcessor);
|
|
345
|
-
`,aS=new Blob([oS],{type:"application/javascript"}),lS=URL.createObjectURL(aS),uS=lS,Up=class{constructor({sampleRate:e=24e3,onStop:n}={}){this.scriptSrc=uS,this.onStop=n,this.sampleRate=e,this.context=null,this.stream=null,this.analyser=null,this.trackSampleOffsets={},this.interruptedTrackIds={}}async connect(){this.context=new AudioContext({sampleRate:this.sampleRate}),this.context.state==="suspended"&&await this.context.resume();try{await this.context.audioWorklet.addModule(this.scriptSrc)}catch(n){throw console.error(n),new Error(`Could not add audioWorklet module: ${this.scriptSrc}`)}let e=this.context.createAnalyser();return e.fftSize=8192,e.smoothingTimeConstant=.1,this.analyser=e,!0}getFrequencies(e="frequency",n=-100,i=-30){if(!this.analyser)throw new Error("Not connected, please call .connect() first");return wu.getFrequencies(this.analyser,this.sampleRate,null,e,n,i)}_start(){let e=new AudioWorkletNode(this.context,"stream_processor");return e.connect(this.context.destination),e.port.onmessage=n=>{let{event:i}=n.data;if(i==="stop")this.onStop?.(),e.disconnect(),this.stream=null;else if(i==="offset"){let{requestId:o,trackId:a,offset:u}=n.data,c=u/this.sampleRate;this.trackSampleOffsets[o]={trackId:a,offset:u,currentTime:c}}},this.analyser.disconnect(),e.connect(this.analyser),this.stream=e,!0}add16BitPCM(e,n="default"){if(typeof n!="string")throw new Error("trackId must be a string");if(this.interruptedTrackIds[n])return;this.stream||this._start();let i;if(e instanceof Int16Array)i=e;else if(e instanceof ArrayBuffer)i=new Int16Array(e);else throw new Error("argument must be Int16Array or ArrayBuffer");return this.stream.port.postMessage({event:"write",buffer:i,trackId:n}),i}async getTrackSampleOffset(e=!1){if(!this.stream)return null;let n=crypto.randomUUID();this.stream.port.postMessage({event:e?"interrupt":"offset",requestId:n});let i;for(;!i;)i=this.trackSampleOffsets[n],await new Promise(a=>setTimeout(()=>a(),1));let{trackId:o}=i;return e&&o&&(this.interruptedTrackIds[o]=!0),i}async interrupt(){return this.getTrackSampleOffset(!0)}};globalThis.WavStreamPlayer=Up;var Vp=ye({key:"ThreadIdToResume",default:void 0}),cS=ye({key:"ResumeThreadErrorState",default:void 0}),Pp=ye({key:"ChatProfile",default:void 0}),Bp=ye({key:"SessionId",default:Pl()}),xu=Do({key:"SessionIdSelector",get:({get:t})=>t(Bp),set:({set:t},e)=>t(Bp,e instanceof Hh?Pl():e)}),Tu=ye({key:"Session",dangerouslyAllowMutability:!0,default:void 0}),Eu=ye({key:"Actions",default:[]}),Au=ye({key:"Messages",dangerouslyAllowMutability:!0,default:[]}),fS=ye({key:"Commands",default:[]}),Fp=ye({key:"TokenCount",default:0}),bu=ye({key:"Loading",default:!1}),Su=ye({key:"AskUser",default:void 0}),dS=ye({key:"WavRecorder",dangerouslyAllowMutability:!0,default:new jp}),hS=ye({key:"WavStreamPlayer",dangerouslyAllowMutability:!0,default:new Up}),pS=ye({key:"AudioConnection",default:"off"}),gS=ye({key:"isAiSpeaking",default:!1}),Qp=ye({key:"CallFn",default:void 0}),qo=ye({key:"ChatSettings",default:[]}),Yp=Do({key:"ChatSettingsValue/Default",get:({get:t})=>{let e=t(qo),n=(i,o)=>(Array.isArray(i)&&i.forEach(a=>{a&&(Array.isArray(a?.inputs)&&a.inputs.length>0?n(a.inputs,o):a?.id!==void 0&&(o[a.id]=a.initial))}),o);return n(e,{})}}),Wo=ye({key:"ChatSettingsValue",default:Yp}),Nu=ye({key:"DisplayElements",default:[]}),Du=ye({key:"TasklistElements",default:[]}),Iu=ye({key:"FirstUserInteraction",default:void 0}),mS=ye({key:"User",default:void 0}),yS=ye({key:"ChainlitConfig",default:void 0}),vS=ye({key:"AuthConfig",default:void 0}),MS=ye({key:"ThreadHistory",default:{threads:void 0,currentThreadId:void 0,timeGroupedThreads:void 0,pageInfo:void 0},effects:[({setSelf:t,onSet:e})=>{e((n,i)=>{let o=n?.timeGroupedThreads;n?.threads&&!ei.isEqual(n.threads,i?.timeGroupedThreads)&&(o=$1(n.threads)),t({...n,timeGroupedThreads:o})})}]}),qp=ye({key:"SideView",default:void 0}),Cu=ye({key:"CurrentThreadId",default:void 0}),wS=t=>({setSelf:e,onSet:n})=>{let i=localStorage.getItem(t);if(i!=null)try{e(JSON.parse(i))}catch(o){console.error(`Error parsing localStorage value for key "${t}":`,o)}n((o,a,u)=>{u?localStorage.removeItem(t):localStorage.setItem(t,JSON.stringify(o))})},xS=ye({key:"Mcp",default:[],effects:[wS("mcp_storage_key")]}),TS=()=>{let t=It(bu),e=It(Nu),n=It(Du),i=It(Eu),o=It(Tu),a=It(Su),u=It(Qp),c=It(qo),d=It(Wo),h=It(Yp),p=o?.socket.connected&&!o?.error,m=!p||t||a?.spec.type==="file"||a?.spec.type==="action"||a?.spec.type==="element";return{actions:i,askUser:a,callFn:u,chatSettingsDefaultValue:h,chatSettingsInputs:c,chatSettingsValue:d,connected:p,disabled:m,elements:e,error:o?.error,loading:t,tasklists:n}},Di=(t,e)=>_o(t,e.id)?ku(t,e.id,e):"parentId"in e&&e.parentId?_p(t,e.parentId,e):"indent"in e&&e.indent&&e.indent>0?Wp(t,e.indent,e):[...t,e],Wp=(t,e,n,i=0)=>{let o=[...t];if(o.length===0)return[...o,n];{let a=o.length-1,u=o[a];return u.steps=u.steps||[],i+1===e?(u.steps=[...u.steps,n],o[a]={...u},o):(u.steps=Wp(u.steps,e,n,i+1),o[a]={...u},o)}},_p=(t,e,n)=>{let i=[...t];for(let o=0;o<i.length;o++){let a=i[o];ei.isEqual(a.id,e)?(a.steps=a.steps?[...a.steps,n]:[n],i[o]={...a}):_o(i,e)&&a.steps&&(a.steps=_p(a.steps,e,n),i[o]={...a})}return i},Kp=(t,e)=>{for(let n of t){if(ei.isEqual(n.id,e))return n;if(n.steps&&n.steps.length>0){let i=Kp(n.steps,e);if(i)return i}}},_o=(t,e)=>Kp(t,e)!==void 0,ku=(t,e,n)=>{let i=[...t];for(let o=0;o<i.length;o++){let a=i[o];ei.isEqual(a.id,e)?i[o]={steps:a.steps,...n}:_o(i,e)&&a.steps&&(a.steps=ku(a.steps,e,n),i[o]={...a})}return i},Hp=(t,e)=>{let n=[...t];for(let i=0;i<n.length;i++){let o=n[i];o.id===e?n=[...n.slice(0,i),...n.slice(i+1)]:_o(n,e)&&o.steps&&(o.steps=Hp(o.steps,e),n[i]={...o})}return n},Jp=(t,e,n,i,o)=>{let a=[...t];for(let u=0;u<a.length;u++){let c=a[u];ei.isEqual(c.id,e)?("content"in c&&c.content!==void 0?i?c.content=n:c.content+=n:o?"input"in c&&c.input!==void 0&&(i?c.input=n:c.input+=n):"output"in c&&c.output!==void 0&&(i?c.output=n:c.output+=n),a[u]={...c}):c.steps&&(c.steps=Jp(c.steps,e,n,i,o),a[u]={...c})}return a},Ko=()=>{let[t,e]=bi(vS),[n,i]=bi(mS),o=ht(MS);return{authConfig:t,setAuthConfig:e,user:n,setUser:i,setThreadHistory:o}},ES=async(t,e)=>(await t.get(e))?.json(),AS=t=>{let e=new Xp("","webapp");return Object.assign(e,t),e};function Ho(t,{...e}={}){let n=x.useContext(Jo),{setUser:i}=Ko(),o=x.useMemo(()=>([u])=>{e.onErrorRetry||(e.onErrorRetry=(...d)=>{let[h]=d;if(h.status===401){i(null);return}return Zb.defaultValue.onErrorRetry(...d)});let c=AS(n);return c.on401=c.onError=void 0,ES(c,u)},[n]),a=x.useMemo(()=>t?[t]:null,[t]);return Xb(a,o,e)}var bS=()=>{let{authConfig:t,setAuthConfig:e}=Ko(),{data:n,isLoading:i}=Ho(t?null:"/auth/config");return x.useEffect(()=>{n&&e(n)},[n,e]),{authConfig:t,isLoading:i}},SS=()=>{let t=x.useContext(Jo),{setUser:e,setThreadHistory:n}=Ko();return{logout:async(i=!1)=>{await t.logout(),e(void 0),n(void 0),i&&window.location.reload()}}},NS=()=>{let{user:t,setUser:e}=Ko(),{data:n,error:i,mutate:o}=Ho("/user");return x.useEffect(()=>{n&&e(n)},[n,e]),x.useEffect(()=>{i&&e(null)},[i]),{user:t,setUserFromAPI:o}},Gp=()=>{let{authConfig:t}=bS(),{logout:e}=SS(),{user:n,setUserFromAPI:i}=NS(),o=!!t&&(!t.requireLogin||n!==void 0);return t&&!t.requireLogin?{data:t,user:null,isReady:o,isAuthenticated:!0,logout:()=>Promise.resolve(),setUserFromAPI:()=>Promise.resolve()}:{data:t,user:n,isReady:o,isAuthenticated:!!n,logout:e,setUserFromAPI:i}},Zp=class extends Error{constructor(e,n,i){super(e),this.status=n,this.detail=i}toString(){return this.detail?`${this.message}: ${this.detail}`:this.message}},DS=class{constructor(e,n,i,o,a){this.httpEndpoint=e,this.type=n,this.additionalQueryParams=i,this.on401=o,this.onError=a}buildEndpoint(e){let n=`${this.httpEndpoint}${e}`;this.httpEndpoint.endsWith("/")&&(n=`${this.httpEndpoint.slice(0,-1)}${e}`);let i=new URL(n);if(this.additionalQueryParams){let o=new URLSearchParams(this.additionalQueryParams),a=i.search?"&":"?";i.search=i.search+`${a}${o.toString()}`}return i.toString()}async getDetailFromErrorResponse(e){try{return(await e.json())?.detail}catch(n){console.error("Unable to parse error response",n)}}handleRequestError(e){e instanceof Zp&&(e.status===401&&this.on401&&this.on401(),this.onError&&this.onError(e)),console.error(e)}async fetch(e,n,i,o,a={}){try{let u;i instanceof FormData?u=i:(a["Content-Type"]="application/json",u=i?JSON.stringify(i):null);let c=await fetch(this.buildEndpoint(n),{method:e,credentials:"include",headers:a,signal:o,body:u});if(!c.ok){let d=await this.getDetailFromErrorResponse(c);throw new Zp(c.statusText,c.status,d)}return c}catch(u){throw this.handleRequestError(u),u}}async get(e){return await this.fetch("GET",e)}async post(e,n,i){return await this.fetch("POST",e,n,i)}async put(e,n){return await this.fetch("PUT",e,n)}async patch(e,n){return await this.fetch("PATCH",e,n)}async delete(e,n){return await this.fetch("DELETE",e,n)}},Xp=class extends DS{async headerAuth(e){return e?(await this.fetch("POST","/auth/header",void 0,void 0,{Authorization:`Bearer ${e}`})).json():(await this.post("/auth/header",{})).json()}async jwtAuth(e){return(await this.fetch("POST","/auth/jwt",void 0,void 0,{Authorization:`Bearer ${e}`})).json()}async stickyCookie(e){return(await this.fetch("POST","/set-session-cookie",{session_id:e})).json()}async passwordAuth(e){return(await this.post("/login",e)).json()}async getUser(){return(await this.get("/user")).json()}async logout(){return(await this.post("/logout",{})).json()}async setFeedback(e,n){return(await this.put("/feedback",{feedback:e,sessionId:n})).json()}async deleteFeedback(e){return(await this.delete("/feedback",{feedbackId:e})).json()}async listThreads(e,n){return(await this.post("/project/threads",{pagination:e,filter:n})).json()}async renameThread(e,n){return(await this.put("/project/thread",{threadId:e,name:n})).json()}async deleteThread(e){return(await this.delete("/project/thread",{threadId:e})).json()}uploadFile(e,n,i,o){let a=new XMLHttpRequest;a.withCredentials=!0;let u=new Promise((c,d)=>{let h=new FormData;h.append("file",e);let p=o?`&ask_parent_id=${o}`:"";a.open("POST",this.buildEndpoint(`/project/file?session_id=${i}${p}`),!0),a.upload.onprogress=function(m){if(m.lengthComputable){let w=m.loaded/m.total*100;n(w)}},a.onload=function(){if(a.status===200){let w=JSON.parse(a.responseText);c(w);return}let m=a.getResponseHeader("Content-Type");if(m&&m.includes("application/json")){let w=JSON.parse(a.responseText);d(w.detail)}else d("Upload failed")},a.onerror=function(){d("Upload error")},a.send(h)});return{xhr:a,promise:u}}async callAction(e,n){return(await this.post("/project/action",{sessionId:n,action:e})).json()}async updateElement(e,n){return(await this.put("/project/element",{sessionId:n,element:e})).json()}async deleteElement(e,n){return(await this.delete("/project/element",{sessionId:n,element:e})).json()}async connectStdioMCP(e,n,i){return(await this.post("/mcp",{sessionId:e,name:n,fullCommand:i,clientType:"stdio"})).json()}async connectSseMCP(e,n,i,o){return(await this.post("/mcp",{sessionId:e,name:n,url:i,...o?{headers:o}:{},clientType:"sse"})).json()}async connectStreamableHttpMCP(e,n,i,o){return(await this.post("/mcp",{sessionId:e,name:n,url:i,...o?{headers:o}:{},clientType:"streamable-http"})).json()}async disconnectMcp(e,n){return(await this.delete("/mcp",{sessionId:e,name:n})).json()}getElementUrl(e,n){let i=`?session_id=${n}`;return this.buildEndpoint(`/project/file/${e}${i}`)}getLogoEndpoint(e,n){return n||this.buildEndpoint(`/logo?theme=${e}`)}getOAuthEndpoint(e){return this.buildEndpoint(`/auth/oauth/${e}`)}async shareThread(e,n){return(await this.put("/project/thread/share",{threadId:e,isShared:n})).json()}},Jo=x.createContext(new Xp("http://localhost:8000","webapp")),$p=()=>{let t=x.useContext(Jo),e=It(Tu),n=It(Su),i=It(xu),o=Io(qo),a=Io(xu),u=Io(Wo),c=ht(Iu),d=ht(bu),h=ht(Au),p=ht(Nu),m=ht(Du),w=ht(Eu),y=ht(Fp),b=ht(Vp),S=ht(qp),P=ht(Cu),R=x.useCallback(()=>{e?.socket.emit("clear_session"),e?.socket.disconnect(),b(void 0),a(),c(void 0),h([]),p([]),m([]),w([]),y(0),o(),u(),S(void 0),P(void 0)},[e]),L=x.useCallback((ue,Fe=[])=>{ue.id||(ue.id=Pl()),ue.createdAt||(ue.createdAt=new Date().toISOString()),h(Ee=>Di(Ee,ue)),e?.socket.emit("client_message",{message:ue,fileReferences:Fe})},[e?.socket]),k=x.useCallback(ue=>{e?.socket.emit("edit_message",{message:ue})},[e?.socket]),Z=x.useCallback(ue=>{e?.socket.emit("window_message",ue)},[e?.socket]),B=x.useCallback(()=>{e?.socket.emit("audio_start")},[e?.socket]),J=x.useCallback((ue,Fe,Ee,we)=>{e?.socket.emit("audio_chunk",{isStart:ue,mimeType:Fe,elapsedTime:Ee,data:we})},[e?.socket]),G=x.useCallback(()=>{e?.socket.emit("audio_end")},[e?.socket]),K=x.useCallback(ue=>{n&&(n.parentId&&(ue.parentId=n.parentId),h(Fe=>Di(Fe,ue)),n.callback(ue))},[n]),Me=x.useCallback(ue=>{e?.socket.emit("chat_settings_change",ue)},[e?.socket]),fe=x.useCallback(()=>{h(ue=>ue.map(Fe=>(Fe.streaming=!1,Fe))),d(!1),e?.socket.emit("stop")},[e?.socket]);return{uploadFile:x.useCallback((ue,Fe,Ee)=>t.uploadFile(ue,Fe,i,Ee),[i]),clear:R,replyMessage:K,sendMessage:L,editMessage:k,windowMessage:Z,startAudioStream:B,sendAudioChunk:J,endAudioStream:G,stopTask:fe,setIdToResume:b,updateChatSettings:Me}},IS=()=>{let t=It(Au),e=It(Iu);return{threadId:It(Cu),messages:t,firstInteraction:e}},eg=()=>{let t=x.useContext(Jo),e=It(xu),[n,i]=bi(Tu),o=ht(gS),a=ht(pS),u=Io(Wo),c=ht(Wo),d=ht(Iu),h=ht(bu),p=ht(xS),m=It(hS),w=It(dS),y=ht(Au),b=ht(Su),S=ht(Qp),P=ht(fS),R=ht(qp),L=ht(Nu),k=ht(Du),Z=ht(Eu),B=ht(qo),J=ht(Fp),[G,K]=bi(Pp),Me=It(Vp),fe=ht(cS),[ue,Fe]=bi(Cu);x.useEffect(()=>{n?.socket&&(n.socket.auth.threadId=ue||"")},[ue]);let Ee=x.useCallback(async({transports:$e,userEnv:Te})=>{let{protocol:Re,host:he,pathname:ae}=new URL(t.httpEndpoint),pe=`${Re}//${he}`,I=ae&&ae!=="/"?`${ae}/ws/socket.io`:"/ws/socket.io";try{await t.stickyCookie(e)}catch(N){console.error(`Failed to set sticky session cookie: ${N}`)}let j=Qo(pe,{path:I,withCredentials:!0,transports:$e,auth:{clientType:t.type,sessionId:e,threadId:Me||"",userEnv:JSON.stringify(Te),chatProfile:G?encodeURIComponent(G):""}});i(N=>(N?.socket?.removeAllListeners(),N?.socket?.close(),{socket:j})),j.on("connect",()=>{j.emit("connection_successful"),i(N=>({...N,error:!1})),p(N=>N.map(V=>{let Q;return V.clientType==="sse"?Q=t.connectSseMCP(e,V.name,V.url):V.clientType==="streamable-http"?Q=t.connectStreamableHttpMCP(e,V.name,V.url,V.headers||{}):Q=t.connectStdioMCP(e,V.name,V.command),Q.then(async({success:$,mcp:X})=>{p(xe=>xe.map(Le=>Le.name===X.name?{...Le,status:$?"connected":"failed",tools:X?X.tools:Le.tools}:Le))}).catch(()=>{p($=>$.map(X=>X.name===V.name?{...X,status:"failed"}:X))}),{...V,status:"connecting"}}))}),j.on("connect_error",N=>{i(V=>({...V,error:!0}))}),j.on("task_start",()=>{h(!0)}),j.on("task_end",()=>{h(!1)}),j.on("reload",()=>{j.emit("clear_session"),window.location.reload()}),j.on("audio_connection",async N=>{if(N==="on"){let V=!0,Q=Date.now(),$="pcm16";await w.begin(),await m.connect(),await w.record(async X=>{let xe=Date.now()-Q;j.emit("audio_chunk",{isStart:V,mimeType:$,elapsedTime:xe,data:X.mono}),V=!1}),m.onStop=()=>o(!1)}else await w.end(),await m.interrupt();a(N)}),j.on("audio_chunk",N=>{m.add16BitPCM(N.data,N.track),o(!0)}),j.on("audio_interrupt",()=>{m.interrupt()}),j.on("resume_thread",N=>{let V=!!N?.metadata?.viewer_read_only;!V&&Me&&N.id!==Me&&(window.location.href=`/thread/${N.id}`),!V&&Me&&Fe(N.id);let Q=[];for(let X of N.steps)Q=Di(Q,X);N.metadata?.chat_profile&&K(N.metadata?.chat_profile),N.metadata?.chat_settings&&c(N.metadata?.chat_settings),y(Q);let $=N.elements||[];k($.filter(X=>X.type==="tasklist")),L($.filter(X=>["avatar","tasklist"].indexOf(X.type)===-1))}),j.on("resume_thread_error",N=>{fe(N)}),j.on("new_message",N=>{y(V=>Di(V,N))}),j.on("first_interaction",N=>{d(N.interaction),Fe(N.thread_id)}),j.on("update_message",N=>{y(V=>ku(V,N.id,N))}),j.on("delete_message",N=>{y(V=>Hp(V,N.id))}),j.on("stream_start",N=>{y(V=>Di(V,N))}),j.on("stream_token",({id:N,token:V,isSequence:Q,isInput:$})=>{y(X=>Jp(X,N,V,Q,$))}),j.on("ask",({msg:N,spec:V},Q)=>{b({spec:V,callback:Q,parentId:N.parentId}),y($=>Di($,N)),h(!1)}),j.on("ask_timeout",()=>{b(void 0),h(!1)}),j.on("clear_ask",()=>{b(void 0)}),j.on("call_fn",({name:N,args:V},Q)=>{S({name:N,args:V,callback:Q})}),j.on("clear_call_fn",()=>{S(void 0)}),j.on("call_fn_timeout",()=>{S(void 0)}),j.on("chat_settings",N=>{B(N),u()}),j.on("set_commands",N=>{P(N)}),j.on("set_sidebar_title",N=>{R(V=>V?.title===N?V:{title:N,elements:V?.elements||[]})}),j.on("set_sidebar_elements",({elements:N,key:V})=>{N.length?(N.forEach(Q=>{!Q.url&&Q.chainlitKey&&(Q.url=t.getElementUrl(Q.chainlitKey,e))}),R(Q=>Q?.key===V?Q:{title:Q?.title||"",elements:N,key:V})):R(void 0)}),j.on("element",N=>{!N.url&&N.chainlitKey&&(N.url=t.getElementUrl(N.chainlitKey,e)),N.type==="tasklist"?k(V=>{let Q=V.findIndex($=>$.id===N.id);return Q===-1?[...V,N]:[...V.slice(0,Q),N,...V.slice(Q+1)]}):L(V=>{let Q=V.findIndex($=>$.id===N.id);return Q===-1?[...V,N]:[...V.slice(0,Q),N,...V.slice(Q+1)]})}),j.on("remove_element",N=>{L(V=>V.filter(Q=>Q.id!==N.id)),k(V=>V.filter(Q=>Q.id!==N.id))}),j.on("action",N=>{Z(V=>[...V,N])}),j.on("remove_action",N=>{Z(V=>{let Q=V.findIndex($=>$.id===N.id);return Q===-1?V:[...V.slice(0,Q),...V.slice(Q+1)]})}),j.on("token_usage",N=>{J(V=>V+N)}),j.on("window_message",N=>{window.parent&&window.parent.postMessage(N,"*")}),j.on("toast",N=>{if(!N.message){console.warn("No message received for toast.");return}switch(N.type){case"info":Ni.info(N.message);break;case"error":Ni.error(N.message);break;case"success":Ni.success(N.message);break;case"warning":Ni.warning(N.message);break;default:Ni(N.message);break}})},[i,e,Me,G]),we=x.useCallback(ei.debounce(Ee,200),[Ee]),nt=x.useCallback(()=>{n?.socket&&(n.socket.removeAllListeners(),n.socket.close())},[n]);return{connect:we,disconnect:nt,session:n,sessionId:e,chatProfile:G,idToResume:Me,setChatProfile:K}},tg=()=>{let[t,e]=bi(yS),{isAuthenticated:n}=Gp(),i=It(Pp),o=navigator.language||"en-US",a=x.useRef(i),u=n?`/project/settings?language=${o}${i?`&chat_profile=${encodeURIComponent(i)}`:""}`:null,c=n&&!t,{data:d,error:h,isLoading:p}=Ho(c?u:null);return x.useEffect(()=>{d&&e(d)},[d,e]),x.useEffect(()=>{a.current!==i&&(e(void 0),a.current=i)},[i,e]),{config:t,error:h,isLoading:p,language:o}};const CS="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='utf-8'?%3e%3c!--%20Uploaded%20to:%20SVG%20Repo,%20www.svgrepo.com,%20Generator:%20SVG%20Repo%20Mixer%20Tools%20--%3e%3csvg%20width='800px'%20height='800px'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M12%2022C17.5228%2022%2022%2017.5228%2022%2012C22%206.47715%2017.5228%202%2012%202C6.47715%202%202%206.47715%202%2012C2%2013.5997%202.37562%2015.1116%203.04346%2016.4525C3.22094%2016.8088%203.28001%2017.2161%203.17712%2017.6006L2.58151%2019.8267C2.32295%2020.793%203.20701%2021.677%204.17335%2021.4185L6.39939%2020.8229C6.78393%2020.72%207.19121%2020.7791%207.54753%2020.9565C8.88837%2021.6244%2010.4003%2022%2012%2022Z'%20fill='%23262D7B'/%3e%3c/svg%3e",zu=x.createContext({});function Lu(t){const e=x.useRef(null);return e.current===null&&(e.current=t()),e.current}const Ou=typeof window<"u",ng=Ou?x.useLayoutEffect:x.useEffect,Go=x.createContext(null);function Ru(t,e){t.indexOf(e)===-1&&t.push(e)}function ju(t,e){const n=t.indexOf(e);n>-1&&t.splice(n,1)}const gr=(t,e,n)=>n>e?e:n<t?t:n;function Uu(t,e){return e?`${t}. For more information and steps for solving, visit https://motion.dev/troubleshooting/${e}`:t}var kS={env:{}};let Ii=()=>{},mr=()=>{};kS.env.NODE_ENV!=="production"&&(Ii=(t,e,n)=>{!t&&typeof console<"u"&&console.warn(Uu(e,n))},mr=(t,e,n)=>{if(!t)throw new Error(Uu(e,n))});const yr={},rg=t=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t);function ig(t){return typeof t=="object"&&t!==null}const sg=t=>/^0[^.\s]+$/u.test(t);function Vu(t){let e;return()=>(e===void 0&&(e=t()),e)}const Ln=t=>t,zS=(t,e)=>n=>e(t(n)),Ts=(...t)=>t.reduce(zS),Es=(t,e,n)=>{const i=e-t;return i===0?1:(n-t)/i};class Pu{constructor(){this.subscriptions=[]}add(e){return Ru(this.subscriptions,e),()=>ju(this.subscriptions,e)}notify(e,n,i){const o=this.subscriptions.length;if(o)if(o===1)this.subscriptions[0](e,n,i);else for(let a=0;a<o;a++){const u=this.subscriptions[a];u&&u(e,n,i)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const Jn=t=>t*1e3,On=t=>t/1e3;function og(t,e){return e?t*(1e3/e):0}const ag=new Set;function Bu(t,e,n){t||ag.has(e)||(console.warn(Uu(e,n)),ag.add(e))}const lg=(t,e,n)=>(((1-3*n+3*e)*t+(3*n-6*e))*t+3*e)*t,LS=1e-7,OS=12;function RS(t,e,n,i,o){let a,u,c=0;do u=e+(n-e)/2,a=lg(u,i,o)-t,a>0?n=u:e=u;while(Math.abs(a)>LS&&++c<OS);return u}function As(t,e,n,i){if(t===e&&n===i)return Ln;const o=a=>RS(a,0,1,t,n);return a=>a===0||a===1?a:lg(o(a),e,i)}const ug=t=>e=>e<=.5?t(2*e)/2:(2-t(2*(1-e)))/2,cg=t=>e=>1-t(1-e),fg=As(.33,1.53,.69,.99),Fu=cg(fg),dg=ug(Fu),hg=t=>(t*=2)<1?.5*Fu(t):.5*(2-Math.pow(2,-10*(t-1))),Qu=t=>1-Math.sin(Math.acos(t)),pg=cg(Qu),gg=ug(Qu),jS=As(.42,0,1,1),US=As(0,0,.58,1),mg=As(.42,0,.58,1),VS=t=>Array.isArray(t)&&typeof t[0]!="number",yg=t=>Array.isArray(t)&&typeof t[0]=="number",vg={linear:Ln,easeIn:jS,easeInOut:mg,easeOut:US,circIn:Qu,circInOut:gg,circOut:pg,backIn:Fu,backInOut:dg,backOut:fg,anticipate:hg},PS=t=>typeof t=="string",Mg=t=>{if(yg(t)){mr(t.length===4,"Cubic bezier arrays must contain four numerical values.","cubic-bezier-length");const[e,n,i,o]=t;return As(e,n,i,o)}else if(PS(t))return mr(vg[t]!==void 0,`Invalid easing type '${t}'`,"invalid-easing-type"),vg[t];return t},Zo=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function BS(t,e){let n=new Set,i=new Set,o=!1,a=!1;const u=new WeakSet;let c={delta:0,timestamp:0,isProcessing:!1};function d(p){u.has(p)&&(h.schedule(p),t()),p(c)}const h={schedule:(p,m=!1,w=!1)=>{const b=w&&o?n:i;return m&&u.add(p),b.has(p)||b.add(p),p},cancel:p=>{i.delete(p),u.delete(p)},process:p=>{if(c=p,o){a=!0;return}o=!0,[n,i]=[i,n],n.forEach(d),n.clear(),o=!1,a&&(a=!1,h.process(p))}};return h}const FS=40;function wg(t,e){let n=!1,i=!0;const o={delta:0,timestamp:0,isProcessing:!1},a=()=>n=!0,u=Zo.reduce((k,Z)=>(k[Z]=BS(a),k),{}),{setup:c,read:d,resolveKeyframes:h,preUpdate:p,update:m,preRender:w,render:y,postRender:b}=u,S=()=>{const k=yr.useManualTiming?o.timestamp:performance.now();n=!1,yr.useManualTiming||(o.delta=i?1e3/60:Math.max(Math.min(k-o.timestamp,FS),1)),o.timestamp=k,o.isProcessing=!0,c.process(o),d.process(o),h.process(o),p.process(o),m.process(o),w.process(o),y.process(o),b.process(o),o.isProcessing=!1,n&&e&&(i=!1,t(S))},P=()=>{n=!0,i=!0,o.isProcessing||t(S)};return{schedule:Zo.reduce((k,Z)=>{const B=u[Z];return k[Z]=(J,G=!1,K=!1)=>(n||P(),B.schedule(J,G,K)),k},{}),cancel:k=>{for(let Z=0;Z<Zo.length;Z++)u[Zo[Z]].cancel(k)},state:o,steps:u}}const{schedule:Et,cancel:zr,state:Jt,steps:Yu}=wg(typeof requestAnimationFrame<"u"?requestAnimationFrame:Ln,!0);let Xo;function QS(){Xo=void 0}const hn={now:()=>(Xo===void 0&&hn.set(Jt.isProcessing||yr.useManualTiming?Jt.timestamp:performance.now()),Xo),set:t=>{Xo=t,queueMicrotask(QS)}},xg=t=>e=>typeof e=="string"&&e.startsWith(t),qu=xg("--"),YS=xg("var(--"),Wu=t=>YS(t)?qS.test(t.split("/*")[0].trim()):!1,qS=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu,Ci={test:t=>typeof t=="number",parse:parseFloat,transform:t=>t},bs={...Ci,transform:t=>gr(0,1,t)},$o={...Ci,default:1},Ss=t=>Math.round(t*1e5)/1e5,_u=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function WS(t){return t==null}const _S=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,Ku=(t,e)=>n=>!!(typeof n=="string"&&_S.test(n)&&n.startsWith(t)||e&&!WS(n)&&Object.prototype.hasOwnProperty.call(n,e)),Tg=(t,e,n)=>i=>{if(typeof i!="string")return i;const[o,a,u,c]=i.match(_u);return{[t]:parseFloat(o),[e]:parseFloat(a),[n]:parseFloat(u),alpha:c!==void 0?parseFloat(c):1}},KS=t=>gr(0,255,t),Hu={...Ci,transform:t=>Math.round(KS(t))},ni={test:Ku("rgb","red"),parse:Tg("red","green","blue"),transform:({red:t,green:e,blue:n,alpha:i=1})=>"rgba("+Hu.transform(t)+", "+Hu.transform(e)+", "+Hu.transform(n)+", "+Ss(bs.transform(i))+")"};function HS(t){let e="",n="",i="",o="";return t.length>5?(e=t.substring(1,3),n=t.substring(3,5),i=t.substring(5,7),o=t.substring(7,9)):(e=t.substring(1,2),n=t.substring(2,3),i=t.substring(3,4),o=t.substring(4,5),e+=e,n+=n,i+=i,o+=o),{red:parseInt(e,16),green:parseInt(n,16),blue:parseInt(i,16),alpha:o?parseInt(o,16)/255:1}}const Ju={test:Ku("#"),parse:HS,transform:ni.transform},Ns=t=>({test:e=>typeof e=="string"&&e.endsWith(t)&&e.split(" ").length===1,parse:parseFloat,transform:e=>`${e}${t}`}),Lr=Ns("deg"),ar=Ns("%"),Ie=Ns("px"),JS=Ns("vh"),GS=Ns("vw"),Eg={...ar,parse:t=>ar.parse(t)/100,transform:t=>ar.transform(t*100)},ki={test:Ku("hsl","hue"),parse:Tg("hue","saturation","lightness"),transform:({hue:t,saturation:e,lightness:n,alpha:i=1})=>"hsla("+Math.round(t)+", "+ar.transform(Ss(e))+", "+ar.transform(Ss(n))+", "+Ss(bs.transform(i))+")"},Bt={test:t=>ni.test(t)||Ju.test(t)||ki.test(t),parse:t=>ni.test(t)?ni.parse(t):ki.test(t)?ki.parse(t):Ju.parse(t),transform:t=>typeof t=="string"?t:t.hasOwnProperty("red")?ni.transform(t):ki.transform(t),getAnimatableNone:t=>{const e=Bt.parse(t);return e.alpha=0,Bt.transform(e)}},ZS=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function XS(t){return isNaN(t)&&typeof t=="string"&&(t.match(_u)?.length||0)+(t.match(ZS)?.length||0)>0}const Ag="number",bg="color",$S="var",eN="var(",Sg="${}",tN=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function Ds(t){const e=t.toString(),n=[],i={color:[],number:[],var:[]},o=[];let a=0;const c=e.replace(tN,d=>(Bt.test(d)?(i.color.push(a),o.push(bg),n.push(Bt.parse(d))):d.startsWith(eN)?(i.var.push(a),o.push($S),n.push(d)):(i.number.push(a),o.push(Ag),n.push(parseFloat(d))),++a,Sg)).split(Sg);return{values:n,split:c,indexes:i,types:o}}function Ng(t){return Ds(t).values}function Dg(t){const{split:e,types:n}=Ds(t),i=e.length;return o=>{let a="";for(let u=0;u<i;u++)if(a+=e[u],o[u]!==void 0){const c=n[u];c===Ag?a+=Ss(o[u]):c===bg?a+=Bt.transform(o[u]):a+=o[u]}return a}}const nN=t=>typeof t=="number"?0:Bt.test(t)?Bt.getAnimatableNone(t):t;function rN(t){const e=Ng(t);return Dg(t)(e.map(nN))}const Or={test:XS,parse:Ng,createTransformer:Dg,getAnimatableNone:rN};function Gu(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<.16666666666666666?t+(e-t)*6*n:n<.5?e:n<.6666666666666666?t+(e-t)*(.6666666666666666-n)*6:t}function iN({hue:t,saturation:e,lightness:n,alpha:i}){t/=360,e/=100,n/=100;let o=0,a=0,u=0;if(!e)o=a=u=n;else{const c=n<.5?n*(1+e):n+e-n*e,d=2*n-c;o=Gu(d,c,t+.3333333333333333),a=Gu(d,c,t),u=Gu(d,c,t-.3333333333333333)}return{red:Math.round(o*255),green:Math.round(a*255),blue:Math.round(u*255),alpha:i}}function ea(t,e){return n=>n>0?e:t}const bt=(t,e,n)=>t+(e-t)*n,Zu=(t,e,n)=>{const i=t*t,o=n*(e*e-i)+i;return o<0?0:Math.sqrt(o)},sN=[Ju,ni,ki],oN=t=>sN.find(e=>e.test(t));function Ig(t){const e=oN(t);if(Ii(!!e,`'${t}' is not an animatable color. Use the equivalent color code instead.`,"color-not-animatable"),!e)return!1;let n=e.parse(t);return e===ki&&(n=iN(n)),n}const Cg=(t,e)=>{const n=Ig(t),i=Ig(e);if(!n||!i)return ea(t,e);const o={...n};return a=>(o.red=Zu(n.red,i.red,a),o.green=Zu(n.green,i.green,a),o.blue=Zu(n.blue,i.blue,a),o.alpha=bt(n.alpha,i.alpha,a),ni.transform(o))},Xu=new Set(["none","hidden"]);function aN(t,e){return Xu.has(t)?n=>n<=0?t:e:n=>n>=1?e:t}function lN(t,e){return n=>bt(t,e,n)}function $u(t){return typeof t=="number"?lN:typeof t=="string"?Wu(t)?ea:Bt.test(t)?Cg:fN:Array.isArray(t)?kg:typeof t=="object"?Bt.test(t)?Cg:uN:ea}function kg(t,e){const n=[...t],i=n.length,o=t.map((a,u)=>$u(a)(a,e[u]));return a=>{for(let u=0;u<i;u++)n[u]=o[u](a);return n}}function uN(t,e){const n={...t,...e},i={};for(const o in n)t[o]!==void 0&&e[o]!==void 0&&(i[o]=$u(t[o])(t[o],e[o]));return o=>{for(const a in i)n[a]=i[a](o);return n}}function cN(t,e){const n=[],i={color:0,var:0,number:0};for(let o=0;o<e.values.length;o++){const a=e.types[o],u=t.indexes[a][i[a]],c=t.values[u]??0;n[o]=c,i[a]++}return n}const fN=(t,e)=>{const n=Or.createTransformer(e),i=Ds(t),o=Ds(e);return i.indexes.var.length===o.indexes.var.length&&i.indexes.color.length===o.indexes.color.length&&i.indexes.number.length>=o.indexes.number.length?Xu.has(t)&&!o.values.length||Xu.has(e)&&!i.values.length?aN(t,e):Ts(kg(cN(i,o),o.values),n):(Ii(!0,`Complex values '${t}' and '${e}' too different to mix. Ensure all colors are of the same type, and that each contains the same quantity of number and color values. Falling back to instant transition.`,"complex-values-different"),ea(t,e))};function zg(t,e,n){return typeof t=="number"&&typeof e=="number"&&typeof n=="number"?bt(t,e,n):$u(t)(t,e)}const dN=t=>{const e=({timestamp:n})=>t(n);return{start:(n=!0)=>Et.update(e,n),stop:()=>zr(e),now:()=>Jt.isProcessing?Jt.timestamp:hn.now()}},Lg=(t,e,n=10)=>{let i="";const o=Math.max(Math.round(e/n),2);for(let a=0;a<o;a++)i+=Math.round(t(a/(o-1))*1e4)/1e4+", ";return`linear(${i.substring(0,i.length-2)})`},ta=2e4;function ec(t){let e=0;const n=50;let i=t.next(e);for(;!i.done&&e<ta;)e+=n,i=t.next(e);return e>=ta?1/0:e}function hN(t,e=100,n){const i=n({...t,keyframes:[0,e]}),o=Math.min(ec(i),ta);return{type:"keyframes",ease:a=>i.next(o*a).value/e,duration:On(o)}}const pN=5;function Og(t,e,n){const i=Math.max(e-pN,0);return og(n-t(i),e-i)}const St={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1},tc=.001;function gN({duration:t=St.duration,bounce:e=St.bounce,velocity:n=St.velocity,mass:i=St.mass}){let o,a;Ii(t<=Jn(St.maxDuration),"Spring duration must be 10 seconds or less","spring-duration-limit");let u=1-e;u=gr(St.minDamping,St.maxDamping,u),t=gr(St.minDuration,St.maxDuration,On(t)),u<1?(o=h=>{const p=h*u,m=p*t,w=p-n,y=nc(h,u),b=Math.exp(-m);return tc-w/y*b},a=h=>{const m=h*u*t,w=m*n+n,y=Math.pow(u,2)*Math.pow(h,2)*t,b=Math.exp(-m),S=nc(Math.pow(h,2),u);return(-o(h)+tc>0?-1:1)*((w-y)*b)/S}):(o=h=>{const p=Math.exp(-h*t),m=(h-n)*t+1;return-tc+p*m},a=h=>{const p=Math.exp(-h*t),m=(n-h)*(t*t);return p*m});const c=5/t,d=yN(o,a,c);if(t=Jn(t),isNaN(d))return{stiffness:St.stiffness,damping:St.damping,duration:t};{const h=Math.pow(d,2)*i;return{stiffness:h,damping:u*2*Math.sqrt(i*h),duration:t}}}const mN=12;function yN(t,e,n){let i=n;for(let o=1;o<mN;o++)i=i-t(i)/e(i);return i}function nc(t,e){return t*Math.sqrt(1-e*e)}const vN=["duration","bounce"],MN=["stiffness","damping","mass"];function Rg(t,e){return e.some(n=>t[n]!==void 0)}function wN(t){let e={velocity:St.velocity,stiffness:St.stiffness,damping:St.damping,mass:St.mass,isResolvedFromDuration:!1,...t};if(!Rg(t,MN)&&Rg(t,vN))if(t.visualDuration){const n=t.visualDuration,i=2*Math.PI/(n*1.2),o=i*i,a=2*gr(.05,1,1-(t.bounce||0))*Math.sqrt(o);e={...e,mass:St.mass,stiffness:o,damping:a}}else{const n=gN(t);e={...e,...n,mass:St.mass},e.isResolvedFromDuration=!0}return e}function na(t=St.visualDuration,e=St.bounce){const n=typeof t!="object"?{visualDuration:t,keyframes:[0,1],bounce:e}:t;let{restSpeed:i,restDelta:o}=n;const a=n.keyframes[0],u=n.keyframes[n.keyframes.length-1],c={done:!1,value:a},{stiffness:d,damping:h,mass:p,duration:m,velocity:w,isResolvedFromDuration:y}=wN({...n,velocity:-On(n.velocity||0)}),b=w||0,S=h/(2*Math.sqrt(d*p)),P=u-a,R=On(Math.sqrt(d/p)),L=Math.abs(P)<5;i||(i=L?St.restSpeed.granular:St.restSpeed.default),o||(o=L?St.restDelta.granular:St.restDelta.default);let k;if(S<1){const B=nc(R,S);k=J=>{const G=Math.exp(-S*R*J);return u-G*((b+S*R*P)/B*Math.sin(B*J)+P*Math.cos(B*J))}}else if(S===1)k=B=>u-Math.exp(-R*B)*(P+(b+R*P)*B);else{const B=R*Math.sqrt(S*S-1);k=J=>{const G=Math.exp(-S*R*J),K=Math.min(B*J,300);return u-G*((b+S*R*P)*Math.sinh(K)+B*P*Math.cosh(K))/B}}const Z={calculatedDuration:y&&m||null,next:B=>{const J=k(B);if(y)c.done=B>=m;else{let G=B===0?b:0;S<1&&(G=B===0?Jn(b):Og(k,B,J));const K=Math.abs(G)<=i,Me=Math.abs(u-J)<=o;c.done=K&&Me}return c.value=c.done?u:J,c},toString:()=>{const B=Math.min(ec(Z),ta),J=Lg(G=>Z.next(B*G).value,B,30);return B+"ms "+J},toTransition:()=>{}};return Z}na.applyToOptions=t=>{const e=hN(t,100,na);return t.ease=e.ease,t.duration=Jn(e.duration),t.type="keyframes",t};function rc({keyframes:t,velocity:e=0,power:n=.8,timeConstant:i=325,bounceDamping:o=10,bounceStiffness:a=500,modifyTarget:u,min:c,max:d,restDelta:h=.5,restSpeed:p}){const m=t[0],w={done:!1,value:m},y=K=>c!==void 0&&K<c||d!==void 0&&K>d,b=K=>c===void 0?d:d===void 0||Math.abs(c-K)<Math.abs(d-K)?c:d;let S=n*e;const P=m+S,R=u===void 0?P:u(P);R!==P&&(S=R-m);const L=K=>-S*Math.exp(-K/i),k=K=>R+L(K),Z=K=>{const Me=L(K),fe=k(K);w.done=Math.abs(Me)<=h,w.value=w.done?R:fe};let B,J;const G=K=>{y(w.value)&&(B=K,J=na({keyframes:[w.value,b(w.value)],velocity:Og(k,K,w.value),damping:o,stiffness:a,restDelta:h,restSpeed:p}))};return G(0),{calculatedDuration:null,next:K=>{let Me=!1;return!J&&B===void 0&&(Me=!0,Z(K),G(K)),B!==void 0&&K>=B?J.next(K-B):(!Me&&Z(K),w)}}}function xN(t,e,n){const i=[],o=n||yr.mix||zg,a=t.length-1;for(let u=0;u<a;u++){let c=o(t[u],t[u+1]);if(e){const d=Array.isArray(e)?e[u]||Ln:e;c=Ts(d,c)}i.push(c)}return i}function TN(t,e,{clamp:n=!0,ease:i,mixer:o}={}){const a=t.length;if(mr(a===e.length,"Both input and output ranges must be the same length","range-length"),a===1)return()=>e[0];if(a===2&&e[0]===e[1])return()=>e[1];const u=t[0]===t[1];t[0]>t[a-1]&&(t=[...t].reverse(),e=[...e].reverse());const c=xN(e,i,o),d=c.length,h=p=>{if(u&&p<t[0])return e[0];let m=0;if(d>1)for(;m<t.length-2&&!(p<t[m+1]);m++);const w=Es(t[m],t[m+1],p);return c[m](w)};return n?p=>h(gr(t[0],t[a-1],p)):h}function EN(t,e){const n=t[t.length-1];for(let i=1;i<=e;i++){const o=Es(0,e,i);t.push(bt(n,1,o))}}function AN(t){const e=[0];return EN(e,t.length-1),e}function bN(t,e){return t.map(n=>n*e)}function SN(t,e){return t.map(()=>e||mg).splice(0,t.length-1)}function zi({duration:t=300,keyframes:e,times:n,ease:i="easeInOut"}){const o=VS(i)?i.map(Mg):Mg(i),a={done:!1,value:e[0]},u=bN(n&&n.length===e.length?n:AN(e),t),c=TN(u,e,{ease:Array.isArray(o)?o:SN(e,o)});return{calculatedDuration:t,next:d=>(a.value=c(d),a.done=d>=t,a)}}const NN=t=>t!==null;function ic(t,{repeat:e,repeatType:n="loop"},i,o=1){const a=t.filter(NN),c=o<0||e&&n!=="loop"&&e%2===1?0:a.length-1;return!c||i===void 0?a[c]:i}const DN={decay:rc,inertia:rc,tween:zi,keyframes:zi,spring:na};function jg(t){typeof t.type=="string"&&(t.type=DN[t.type])}class sc{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(e=>{this.resolve=e})}notifyFinished(){this.resolve()}then(e,n){return this.finished.then(e,n)}}var IN={env:{}};const CN=t=>t/100;class oc extends sc{constructor(e){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.stop=()=>{const{motionValue:n}=this.options;n&&n.updatedAt!==hn.now()&&this.tick(hn.now()),this.isStopped=!0,this.state!=="idle"&&(this.teardown(),this.options.onStop?.())},this.options=e,this.initAnimation(),this.play(),e.autoplay===!1&&this.pause()}initAnimation(){const{options:e}=this;jg(e);const{type:n=zi,repeat:i=0,repeatDelay:o=0,repeatType:a,velocity:u=0}=e;let{keyframes:c}=e;const d=n||zi;IN.env.NODE_ENV!=="production"&&d!==zi&&mr(c.length<=2,`Only two keyframes currently supported with spring and inertia animations. Trying to animate ${c}`,"spring-two-frames"),d!==zi&&typeof c[0]!="number"&&(this.mixKeyframes=Ts(CN,zg(c[0],c[1])),c=[0,100]);const h=d({...e,keyframes:c});a==="mirror"&&(this.mirroredGenerator=d({...e,keyframes:[...c].reverse(),velocity:-u})),h.calculatedDuration===null&&(h.calculatedDuration=ec(h));const{calculatedDuration:p}=h;this.calculatedDuration=p,this.resolvedDuration=p+o,this.totalDuration=this.resolvedDuration*(i+1)-o,this.generator=h}updateTime(e){const n=Math.round(e-this.startTime)*this.playbackSpeed;this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=n}tick(e,n=!1){const{generator:i,totalDuration:o,mixKeyframes:a,mirroredGenerator:u,resolvedDuration:c,calculatedDuration:d}=this;if(this.startTime===null)return i.next(0);const{delay:h=0,keyframes:p,repeat:m,repeatType:w,repeatDelay:y,type:b,onUpdate:S,finalKeyframe:P}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,e):this.speed<0&&(this.startTime=Math.min(e-o/this.speed,this.startTime)),n?this.currentTime=e:this.updateTime(e);const R=this.currentTime-h*(this.playbackSpeed>=0?1:-1),L=this.playbackSpeed>=0?R<0:R>o;this.currentTime=Math.max(R,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=o);let k=this.currentTime,Z=i;if(m){const K=Math.min(this.currentTime,o)/c;let Me=Math.floor(K),fe=K%1;!fe&&K>=1&&(fe=1),fe===1&&Me--,Me=Math.min(Me,m+1),!!(Me%2)&&(w==="reverse"?(fe=1-fe,y&&(fe-=y/c)):w==="mirror"&&(Z=u)),k=gr(0,1,fe)*c}const B=L?{done:!1,value:p[0]}:Z.next(k);a&&(B.value=a(B.value));let{done:J}=B;!L&&d!==null&&(J=this.playbackSpeed>=0?this.currentTime>=o:this.currentTime<=0);const G=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&J);return G&&b!==rc&&(B.value=ic(p,this.options,P,this.speed)),S&&S(B.value),G&&this.finish(),B}then(e,n){return this.finished.then(e,n)}get duration(){return On(this.calculatedDuration)}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+On(e)}get time(){return On(this.currentTime)}set time(e){e=Jn(e),this.currentTime=e,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=e:this.driver&&(this.startTime=this.driver.now()-e/this.playbackSpeed),this.driver?.start(!1)}get speed(){return this.playbackSpeed}set speed(e){this.updateTime(hn.now());const n=this.playbackSpeed!==e;this.playbackSpeed=e,n&&(this.time=On(this.currentTime))}play(){if(this.isStopped)return;const{driver:e=dN,startTime:n}=this.options;this.driver||(this.driver=e(o=>this.tick(o))),this.options.onPlay?.();const i=this.driver.now();this.state==="finished"?(this.updateFinished(),this.startTime=i):this.holdTime!==null?this.startTime=i-this.holdTime:this.startTime||(this.startTime=n??i),this.state==="finished"&&this.speed<0&&(this.startTime+=this.calculatedDuration),this.holdTime=null,this.state="running",this.driver.start()}pause(){this.state="paused",this.updateTime(hn.now()),this.holdTime=this.currentTime}complete(){this.state!=="running"&&this.play(),this.state="finished",this.holdTime=null}finish(){this.notifyFinished(),this.teardown(),this.state="finished",this.options.onComplete?.()}cancel(){this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),this.options.onCancel?.()}teardown(){this.state="idle",this.stopDriver(),this.startTime=this.holdTime=null}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(e){return this.startTime=0,this.tick(e,!0)}attachTimeline(e){return this.options.allowFlatten&&(this.options.type="keyframes",this.options.ease="linear",this.initAnimation()),this.driver?.stop(),e.observe(this)}}function kN(t){for(let e=1;e<t.length;e++)t[e]??(t[e]=t[e-1])}const ri=t=>t*180/Math.PI,ac=t=>{const e=ri(Math.atan2(t[1],t[0]));return lc(e)},zN={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:t=>(Math.abs(t[0])+Math.abs(t[3]))/2,rotate:ac,rotateZ:ac,skewX:t=>ri(Math.atan(t[1])),skewY:t=>ri(Math.atan(t[2])),skew:t=>(Math.abs(t[1])+Math.abs(t[2]))/2},lc=t=>(t=t%360,t<0&&(t+=360),t),Ug=ac,Vg=t=>Math.sqrt(t[0]*t[0]+t[1]*t[1]),Pg=t=>Math.sqrt(t[4]*t[4]+t[5]*t[5]),LN={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:Vg,scaleY:Pg,scale:t=>(Vg(t)+Pg(t))/2,rotateX:t=>lc(ri(Math.atan2(t[6],t[5]))),rotateY:t=>lc(ri(Math.atan2(-t[2],t[0]))),rotateZ:Ug,rotate:Ug,skewX:t=>ri(Math.atan(t[4])),skewY:t=>ri(Math.atan(t[1])),skew:t=>(Math.abs(t[1])+Math.abs(t[4]))/2};function uc(t){return t.includes("scale")?1:0}function cc(t,e){if(!t||t==="none")return uc(e);const n=t.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let i,o;if(n)i=LN,o=n;else{const c=t.match(/^matrix\(([-\d.e\s,]+)\)$/u);i=zN,o=c}if(!o)return uc(e);const a=i[e],u=o[1].split(",").map(RN);return typeof a=="function"?a(u):u[a]}const ON=(t,e)=>{const{transform:n="none"}=getComputedStyle(t);return cc(n,e)};function RN(t){return parseFloat(t.trim())}const Li=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],Oi=new Set(Li),Bg=t=>t===Ci||t===Ie,jN=new Set(["x","y","z"]),UN=Li.filter(t=>!jN.has(t));function VN(t){const e=[];return UN.forEach(n=>{const i=t.getValue(n);i!==void 0&&(e.push([n,i.get()]),i.set(n.startsWith("scale")?1:0))}),e}const ii={width:({x:t},{paddingLeft:e="0",paddingRight:n="0"})=>t.max-t.min-parseFloat(e)-parseFloat(n),height:({y:t},{paddingTop:e="0",paddingBottom:n="0"})=>t.max-t.min-parseFloat(e)-parseFloat(n),top:(t,{top:e})=>parseFloat(e),left:(t,{left:e})=>parseFloat(e),bottom:({y:t},{top:e})=>parseFloat(e)+(t.max-t.min),right:({x:t},{left:e})=>parseFloat(e)+(t.max-t.min),x:(t,{transform:e})=>cc(e,"x"),y:(t,{transform:e})=>cc(e,"y")};ii.translateX=ii.x,ii.translateY=ii.y;const si=new Set;let fc=!1,dc=!1,hc=!1;function Fg(){if(dc){const t=Array.from(si).filter(i=>i.needsMeasurement),e=new Set(t.map(i=>i.element)),n=new Map;e.forEach(i=>{const o=VN(i);o.length&&(n.set(i,o),i.render())}),t.forEach(i=>i.measureInitialState()),e.forEach(i=>{i.render();const o=n.get(i);o&&o.forEach(([a,u])=>{i.getValue(a)?.set(u)})}),t.forEach(i=>i.measureEndState()),t.forEach(i=>{i.suspendedScrollY!==void 0&&window.scrollTo(0,i.suspendedScrollY)})}dc=!1,fc=!1,si.forEach(t=>t.complete(hc)),si.clear()}function Qg(){si.forEach(t=>{t.readKeyframes(),t.needsMeasurement&&(dc=!0)})}function PN(){hc=!0,Qg(),Fg(),hc=!1}class pc{constructor(e,n,i,o,a,u=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...e],this.onComplete=n,this.name=i,this.motionValue=o,this.element=a,this.isAsync=u}scheduleResolve(){this.state="scheduled",this.isAsync?(si.add(this),fc||(fc=!0,Et.read(Qg),Et.resolveKeyframes(Fg))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:e,name:n,element:i,motionValue:o}=this;if(e[0]===null){const a=o?.get(),u=e[e.length-1];if(a!==void 0)e[0]=a;else if(i&&n){const c=i.readValue(n,u);c!=null&&(e[0]=c)}e[0]===void 0&&(e[0]=u),o&&a===void 0&&o.set(e[0])}kN(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),si.delete(this)}cancel(){this.state==="scheduled"&&(si.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const BN=t=>t.startsWith("--");function FN(t,e,n){BN(e)?t.style.setProperty(e,n):t.style[e]=n}const QN=Vu(()=>window.ScrollTimeline!==void 0),YN={};function qN(t,e){const n=Vu(t);return()=>YN[e]??n()}const Yg=qN(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),Is=([t,e,n,i])=>`cubic-bezier(${t}, ${e}, ${n}, ${i})`,qg={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:Is([0,.65,.55,1]),circOut:Is([.55,0,1,.45]),backIn:Is([.31,.01,.66,-.59]),backOut:Is([.33,1.53,.69,.99])};function Wg(t,e){if(t)return typeof t=="function"?Yg()?Lg(t,e):"ease-out":yg(t)?Is(t):Array.isArray(t)?t.map(n=>Wg(n,e)||qg.easeOut):qg[t]}function WN(t,e,n,{delay:i=0,duration:o=300,repeat:a=0,repeatType:u="loop",ease:c="easeOut",times:d}={},h=void 0){const p={[e]:n};d&&(p.offset=d);const m=Wg(c,o);Array.isArray(m)&&(p.easing=m);const w={delay:i,duration:o,easing:Array.isArray(m)?"linear":m,fill:"both",iterations:a+1,direction:u==="reverse"?"alternate":"normal"};return h&&(w.pseudoElement=h),t.animate(p,w)}function _g(t){return typeof t=="function"&&"applyToOptions"in t}function _N({type:t,...e}){return _g(t)&&Yg()?t.applyToOptions(e):(e.duration??(e.duration=300),e.ease??(e.ease="easeOut"),e)}class KN extends sc{constructor(e){if(super(),this.finishedTime=null,this.isStopped=!1,!e)return;const{element:n,name:i,keyframes:o,pseudoElement:a,allowFlatten:u=!1,finalKeyframe:c,onComplete:d}=e;this.isPseudoElement=!!a,this.allowFlatten=u,this.options=e,mr(typeof e.type!="string",`Mini animate() doesn't support "type" as a string.`,"mini-spring");const h=_N(e);this.animation=WN(n,i,o,h,a),h.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!a){const p=ic(o,this.options,c,this.speed);this.updateMotionValue?this.updateMotionValue(p):FN(n,i,p),this.animation.cancel()}d?.(),this.notifyFinished()}}play(){this.isStopped||(this.animation.play(),this.state==="finished"&&this.updateFinished())}pause(){this.animation.pause()}complete(){this.animation.finish?.()}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;const{state:e}=this;e==="idle"||e==="finished"||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){this.isPseudoElement||this.animation.commitStyles?.()}get duration(){const e=this.animation.effect?.getComputedTiming?.().duration||0;return On(Number(e))}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+On(e)}get time(){return On(Number(this.animation.currentTime)||0)}set time(e){this.finishedTime=null,this.animation.currentTime=Jn(e)}get speed(){return this.animation.playbackRate}set speed(e){e<0&&(this.finishedTime=null),this.animation.playbackRate=e}get state(){return this.finishedTime!==null?"finished":this.animation.playState}get startTime(){return Number(this.animation.startTime)}set startTime(e){this.animation.startTime=e}attachTimeline({timeline:e,observe:n}){return this.allowFlatten&&this.animation.effect?.updateTiming({easing:"linear"}),this.animation.onfinish=null,e&&QN()?(this.animation.timeline=e,Ln):n(this)}}const Kg={anticipate:hg,backInOut:dg,circInOut:gg};function HN(t){return t in Kg}function JN(t){typeof t.ease=="string"&&HN(t.ease)&&(t.ease=Kg[t.ease])}const Hg=10;class GN extends KN{constructor(e){JN(e),jg(e),super(e),e.startTime&&(this.startTime=e.startTime),this.options=e}updateMotionValue(e){const{motionValue:n,onUpdate:i,onComplete:o,element:a,...u}=this.options;if(!n)return;if(e!==void 0){n.set(e);return}const c=new oc({...u,autoplay:!1}),d=Jn(this.finishedTime??this.time);n.setWithVelocity(c.sample(d-Hg).value,c.sample(d).value,Hg),c.stop()}}const Jg=(t,e)=>e==="zIndex"?!1:!!(typeof t=="number"||Array.isArray(t)||typeof t=="string"&&(Or.test(t)||t==="0")&&!t.startsWith("url("));function ZN(t){const e=t[0];if(t.length===1)return!0;for(let n=0;n<t.length;n++)if(t[n]!==e)return!0}function XN(t,e,n,i){const o=t[0];if(o===null)return!1;if(e==="display"||e==="visibility")return!0;const a=t[t.length-1],u=Jg(o,e),c=Jg(a,e);return Ii(u===c,`You are trying to animate ${e} from "${o}" to "${a}". "${u?a:o}" is not an animatable value.`,"value-not-animatable"),!u||!c?!1:ZN(t)||(n==="spring"||_g(n))&&i}function gc(t){t.duration=0,t.type="keyframes"}const $N=new Set(["opacity","clipPath","filter","transform"]),eD=Vu(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function tD(t){const{motionValue:e,name:n,repeatDelay:i,repeatType:o,damping:a,type:u}=t;if(!(e?.owner?.current instanceof HTMLElement))return!1;const{onUpdate:d,transformTemplate:h}=e.owner.getProps();return eD()&&n&&$N.has(n)&&(n!=="transform"||!h)&&!d&&!i&&o!=="mirror"&&a!==0&&u!=="inertia"}const nD=40;class rD extends sc{constructor({autoplay:e=!0,delay:n=0,type:i="keyframes",repeat:o=0,repeatDelay:a=0,repeatType:u="loop",keyframes:c,name:d,motionValue:h,element:p,...m}){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=hn.now();const w={autoplay:e,delay:n,type:i,repeat:o,repeatDelay:a,repeatType:u,name:d,motionValue:h,element:p,...m},y=p?.KeyframeResolver||pc;this.keyframeResolver=new y(c,(b,S,P)=>this.onKeyframesResolved(b,S,w,!P),d,h,p),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(e,n,i,o){this.keyframeResolver=void 0;const{name:a,type:u,velocity:c,delay:d,isHandoff:h,onUpdate:p}=i;this.resolvedAt=hn.now(),XN(e,a,u,c)||((yr.instantAnimations||!d)&&p?.(ic(e,i,n)),e[0]=e[e.length-1],gc(i),i.repeat=0);const w={startTime:o?this.resolvedAt?this.resolvedAt-this.createdAt>nD?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...i,keyframes:e},y=!h&&tD(w)?new GN({...w,element:w.motionValue.owner.current}):new oc(w);y.finished.then(()=>this.notifyFinished()).catch(Ln),this.pendingTimeline&&(this.stopTimeline=y.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=y}get finished(){return this._animation?this.animation.finished:this._finished}then(e,n){return this.finished.finally(e).then(()=>{})}get animation(){return this._animation||(this.keyframeResolver?.resume(),PN()),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(e){this.animation.time=e}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(e){this.animation.speed=e}get startTime(){return this.animation.startTime}attachTimeline(e){return this._animation?this.stopTimeline=this.animation.attachTimeline(e):this.pendingTimeline=e,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){this._animation&&this.animation.cancel(),this.keyframeResolver?.cancel()}}const iD=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function sD(t){const e=iD.exec(t);if(!e)return[,];const[,n,i,o]=e;return[`--${n??i}`,o]}const oD=4;function Gg(t,e,n=1){mr(n<=oD,`Max CSS variable fallback depth detected in property "${t}". This may indicate a circular fallback dependency.`,"max-css-var-depth");const[i,o]=sD(t);if(!i)return;const a=window.getComputedStyle(e).getPropertyValue(i);if(a){const u=a.trim();return rg(u)?parseFloat(u):u}return Wu(o)?Gg(o,e,n+1):o}function mc(t,e){return t?.[e]??t?.default??t}const Zg=new Set(["width","height","top","left","right","bottom",...Li]),aD={test:t=>t==="auto",parse:t=>t},Xg=t=>e=>e.test(t),$g=[Ci,Ie,ar,Lr,GS,JS,aD],em=t=>$g.find(Xg(t));function lD(t){return typeof t=="number"?t===0:t!==null?t==="none"||t==="0"||sg(t):!0}const uD=new Set(["brightness","contrast","saturate","opacity"]);function cD(t){const[e,n]=t.slice(0,-1).split("(");if(e==="drop-shadow")return t;const[i]=n.match(_u)||[];if(!i)return t;const o=n.replace(i,"");let a=uD.has(e)?1:0;return i!==n&&(a*=100),e+"("+a+o+")"}const fD=/\b([a-z-]*)\(.*?\)/gu,yc={...Or,getAnimatableNone:t=>{const e=t.match(fD);return e?e.map(cD).join(" "):t}},tm={...Ci,transform:Math.round},vc={borderWidth:Ie,borderTopWidth:Ie,borderRightWidth:Ie,borderBottomWidth:Ie,borderLeftWidth:Ie,borderRadius:Ie,radius:Ie,borderTopLeftRadius:Ie,borderTopRightRadius:Ie,borderBottomRightRadius:Ie,borderBottomLeftRadius:Ie,width:Ie,maxWidth:Ie,height:Ie,maxHeight:Ie,top:Ie,right:Ie,bottom:Ie,left:Ie,padding:Ie,paddingTop:Ie,paddingRight:Ie,paddingBottom:Ie,paddingLeft:Ie,margin:Ie,marginTop:Ie,marginRight:Ie,marginBottom:Ie,marginLeft:Ie,backgroundPositionX:Ie,backgroundPositionY:Ie,...{rotate:Lr,rotateX:Lr,rotateY:Lr,rotateZ:Lr,scale:$o,scaleX:$o,scaleY:$o,scaleZ:$o,skew:Lr,skewX:Lr,skewY:Lr,distance:Ie,translateX:Ie,translateY:Ie,translateZ:Ie,x:Ie,y:Ie,z:Ie,perspective:Ie,transformPerspective:Ie,opacity:bs,originX:Eg,originY:Eg,originZ:Ie},zIndex:tm,fillOpacity:bs,strokeOpacity:bs,numOctaves:tm},dD={...vc,color:Bt,backgroundColor:Bt,outlineColor:Bt,fill:Bt,stroke:Bt,borderColor:Bt,borderTopColor:Bt,borderRightColor:Bt,borderBottomColor:Bt,borderLeftColor:Bt,filter:yc,WebkitFilter:yc},nm=t=>dD[t];function rm(t,e){let n=nm(t);return n!==yc&&(n=Or),n.getAnimatableNone?n.getAnimatableNone(e):void 0}const hD=new Set(["auto","none","0"]);function pD(t,e,n){let i=0,o;for(;i<t.length&&!o;){const a=t[i];typeof a=="string"&&!hD.has(a)&&Ds(a).values.length&&(o=t[i]),i++}if(o&&n)for(const a of e)t[a]=rm(n,o)}class gD extends pc{constructor(e,n,i,o,a){super(e,n,i,o,a,!0)}readKeyframes(){const{unresolvedKeyframes:e,element:n,name:i}=this;if(!n||!n.current)return;super.readKeyframes();for(let d=0;d<e.length;d++){let h=e[d];if(typeof h=="string"&&(h=h.trim(),Wu(h))){const p=Gg(h,n.current);p!==void 0&&(e[d]=p),d===e.length-1&&(this.finalKeyframe=h)}}if(this.resolveNoneKeyframes(),!Zg.has(i)||e.length!==2)return;const[o,a]=e,u=em(o),c=em(a);if(u!==c)if(Bg(u)&&Bg(c))for(let d=0;d<e.length;d++){const h=e[d];typeof h=="string"&&(e[d]=parseFloat(h))}else ii[i]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:e,name:n}=this,i=[];for(let o=0;o<e.length;o++)(e[o]===null||lD(e[o]))&&i.push(o);i.length&&pD(e,i,n)}measureInitialState(){const{element:e,unresolvedKeyframes:n,name:i}=this;if(!e||!e.current)return;i==="height"&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=ii[i](e.measureViewportBox(),window.getComputedStyle(e.current)),n[0]=this.measuredOrigin;const o=n[n.length-1];o!==void 0&&e.getValue(i,o).jump(o,!1)}measureEndState(){const{element:e,name:n,unresolvedKeyframes:i}=this;if(!e||!e.current)return;const o=e.getValue(n);o&&o.jump(this.measuredOrigin,!1);const a=i.length-1,u=i[a];i[a]=ii[n](e.measureViewportBox(),window.getComputedStyle(e.current)),u!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=u),this.removedTransforms?.length&&this.removedTransforms.forEach(([c,d])=>{e.getValue(c).set(d)}),this.resolveNoneKeyframes()}}function mD(t,e,n){if(t instanceof EventTarget)return[t];if(typeof t=="string"){let i=document;const o=n?.[t]??i.querySelectorAll(t);return o?Array.from(o):[]}return Array.from(t)}const im=(t,e)=>e&&typeof t=="number"?e.transform(t):t;function sm(t){return ig(t)&&"offsetHeight"in t}var yD={env:{}};const om=30,vD=t=>!isNaN(parseFloat(t));class MD{constructor(e,n={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=i=>{const o=hn.now();if(this.updatedAt!==o&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(i),this.current!==this.prev&&(this.events.change?.notify(this.current),this.dependents))for(const a of this.dependents)a.dirty()},this.hasAnimated=!1,this.setCurrent(e),this.owner=n.owner}setCurrent(e){this.current=e,this.updatedAt=hn.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=vD(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return yD.env.NODE_ENV!=="production"&&Bu(!1,'value.onChange(callback) is deprecated. Switch to value.on("change", callback).'),this.on("change",e)}on(e,n){this.events[e]||(this.events[e]=new Pu);const i=this.events[e].add(n);return e==="change"?()=>{i(),Et.read(()=>{this.events.change.getSize()||this.stop()})}:i}clearListeners(){for(const e in this.events)this.events[e].clear()}attach(e,n){this.passiveEffect=e,this.stopPassiveEffect=n}set(e){this.passiveEffect?this.passiveEffect(e,this.updateAndNotify):this.updateAndNotify(e)}setWithVelocity(e,n,i){this.set(n),this.prev=void 0,this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt-i}jump(e,n=!0){this.updateAndNotify(e),this.prev=e,this.prevUpdatedAt=this.prevFrameValue=void 0,n&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){this.events.change?.notify(this.current)}addDependent(e){this.dependents||(this.dependents=new Set),this.dependents.add(e)}removeDependent(e){this.dependents&&this.dependents.delete(e)}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const e=hn.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>om)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,om);return og(parseFloat(this.current)-parseFloat(this.prevFrameValue),n)}start(e){return this.stop(),new Promise(n=>{this.hasAnimated=!0,this.animation=e(n),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.dependents?.clear(),this.events.destroy?.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function Ri(t,e){return new MD(t,e)}const{schedule:Mc}=wg(queueMicrotask,!1),Gn={x:!1,y:!1};function am(){return Gn.x||Gn.y}function wD(t){return t==="x"||t==="y"?Gn[t]?null:(Gn[t]=!0,()=>{Gn[t]=!1}):Gn.x||Gn.y?null:(Gn.x=Gn.y=!0,()=>{Gn.x=Gn.y=!1})}function lm(t,e){const n=mD(t),i=new AbortController,o={passive:!0,...e,signal:i.signal};return[n,o,()=>i.abort()]}function um(t){return!(t.pointerType==="touch"||am())}function xD(t,e,n={}){const[i,o,a]=lm(t,n),u=c=>{if(!um(c))return;const{target:d}=c,h=e(d,c);if(typeof h!="function"||!d)return;const p=m=>{um(m)&&(h(m),d.removeEventListener("pointerleave",p))};d.addEventListener("pointerleave",p,o)};return i.forEach(c=>{c.addEventListener("pointerenter",u,o)}),a}const cm=(t,e)=>e?t===e?!0:cm(t,e.parentElement):!1,wc=t=>t.pointerType==="mouse"?typeof t.button!="number"||t.button<=0:t.isPrimary!==!1,TD=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function ED(t){return TD.has(t.tagName)||t.tabIndex!==-1}const ra=new WeakSet;function fm(t){return e=>{e.key==="Enter"&&t(e)}}function xc(t,e){t.dispatchEvent(new PointerEvent("pointer"+e,{isPrimary:!0,bubbles:!0}))}const AD=(t,e)=>{const n=t.currentTarget;if(!n)return;const i=fm(()=>{if(ra.has(n))return;xc(n,"down");const o=fm(()=>{xc(n,"up")}),a=()=>xc(n,"cancel");n.addEventListener("keyup",o,e),n.addEventListener("blur",a,e)});n.addEventListener("keydown",i,e),n.addEventListener("blur",()=>n.removeEventListener("keydown",i),e)};function dm(t){return wc(t)&&!am()}function bD(t,e,n={}){const[i,o,a]=lm(t,n),u=c=>{const d=c.currentTarget;if(!dm(c))return;ra.add(d);const h=e(d,c),p=(y,b)=>{window.removeEventListener("pointerup",m),window.removeEventListener("pointercancel",w),ra.has(d)&&ra.delete(d),dm(y)&&typeof h=="function"&&h(y,{success:b})},m=y=>{p(y,d===window||d===document||n.useGlobalTarget||cm(d,y.target))},w=y=>{p(y,!1)};window.addEventListener("pointerup",m,o),window.addEventListener("pointercancel",w,o)};return i.forEach(c=>{(n.useGlobalTarget?window:c).addEventListener("pointerdown",u,o),sm(c)&&(c.addEventListener("focus",h=>AD(h,o)),!ED(c)&&!c.hasAttribute("tabindex")&&(c.tabIndex=0))}),a}function hm(t){return ig(t)&&"ownerSVGElement"in t}function SD(t){return hm(t)&&t.tagName==="svg"}const nn=t=>!!(t&&t.getVelocity),ND=[...$g,Bt,Or],DD=t=>ND.find(Xg(t)),Tc=x.createContext({transformPagePoint:t=>t,isStatic:!1,reducedMotion:"never"});function pm(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function ID(...t){return e=>{let n=!1;const i=t.map(o=>{const a=pm(o,e);return!n&&typeof a=="function"&&(n=!0),a});if(n)return()=>{for(let o=0;o<i.length;o++){const a=i[o];typeof a=="function"?a():pm(t[o],null)}}}}function CD(...t){return eo.useCallback(ID(...t),t)}class kD extends eo.Component{getSnapshotBeforeUpdate(e){const n=this.props.childRef.current;if(n&&e.isPresent&&!this.props.isPresent){const i=n.offsetParent,o=sm(i)&&i.offsetWidth||0,a=this.props.sizeRef.current;a.height=n.offsetHeight||0,a.width=n.offsetWidth||0,a.top=n.offsetTop,a.left=n.offsetLeft,a.right=o-a.width-a.left}return null}componentDidUpdate(){}render(){return this.props.children}}function zD({children:t,isPresent:e,anchorX:n,root:i}){const o=x.useId(),a=x.useRef(null),u=x.useRef({width:0,height:0,top:0,left:0,right:0}),{nonce:c}=x.useContext(Tc),d=CD(a,t?.ref);return x.useInsertionEffect(()=>{const{width:h,height:p,top:m,left:w,right:y}=u.current;if(e||!a.current||!h||!p)return;const b=n==="left"?`left: ${w}`:`right: ${y}`;a.current.dataset.motionPopId=o;const S=document.createElement("style");c&&(S.nonce=c);const P=i??document.head;return P.appendChild(S),S.sheet&&S.sheet.insertRule(`
|
|
345
|
+
`,aS=new Blob([oS],{type:"application/javascript"}),lS=URL.createObjectURL(aS),uS=lS,Up=class{constructor({sampleRate:e=24e3,onStop:n}={}){this.scriptSrc=uS,this.onStop=n,this.sampleRate=e,this.context=null,this.stream=null,this.analyser=null,this.trackSampleOffsets={},this.interruptedTrackIds={}}async connect(){this.context=new AudioContext({sampleRate:this.sampleRate}),this.context.state==="suspended"&&await this.context.resume();try{await this.context.audioWorklet.addModule(this.scriptSrc)}catch(n){throw console.error(n),new Error(`Could not add audioWorklet module: ${this.scriptSrc}`)}let e=this.context.createAnalyser();return e.fftSize=8192,e.smoothingTimeConstant=.1,this.analyser=e,!0}getFrequencies(e="frequency",n=-100,i=-30){if(!this.analyser)throw new Error("Not connected, please call .connect() first");return wu.getFrequencies(this.analyser,this.sampleRate,null,e,n,i)}_start(){let e=new AudioWorkletNode(this.context,"stream_processor");return e.connect(this.context.destination),e.port.onmessage=n=>{let{event:i}=n.data;if(i==="stop")this.onStop?.(),e.disconnect(),this.stream=null;else if(i==="offset"){let{requestId:o,trackId:a,offset:u}=n.data,c=u/this.sampleRate;this.trackSampleOffsets[o]={trackId:a,offset:u,currentTime:c}}},this.analyser.disconnect(),e.connect(this.analyser),this.stream=e,!0}add16BitPCM(e,n="default"){if(typeof n!="string")throw new Error("trackId must be a string");if(this.interruptedTrackIds[n])return;this.stream||this._start();let i;if(e instanceof Int16Array)i=e;else if(e instanceof ArrayBuffer)i=new Int16Array(e);else throw new Error("argument must be Int16Array or ArrayBuffer");return this.stream.port.postMessage({event:"write",buffer:i,trackId:n}),i}async getTrackSampleOffset(e=!1){if(!this.stream)return null;let n=crypto.randomUUID();this.stream.port.postMessage({event:e?"interrupt":"offset",requestId:n});let i;for(;!i;)i=this.trackSampleOffsets[n],await new Promise(a=>setTimeout(()=>a(),1));let{trackId:o}=i;return e&&o&&(this.interruptedTrackIds[o]=!0),i}async interrupt(){return this.getTrackSampleOffset(!0)}};globalThis.WavStreamPlayer=Up;var Vp=ye({key:"ThreadIdToResume",default:void 0}),cS=ye({key:"ResumeThreadErrorState",default:void 0}),Pp=ye({key:"ChatProfile",default:void 0}),Bp=ye({key:"SessionId",default:Pl()}),xu=Do({key:"SessionIdSelector",get:({get:t})=>t(Bp),set:({set:t},e)=>t(Bp,e instanceof Hh?Pl():e)}),Tu=ye({key:"Session",dangerouslyAllowMutability:!0,default:void 0}),Eu=ye({key:"Actions",default:[]}),Au=ye({key:"Messages",dangerouslyAllowMutability:!0,default:[]}),fS=ye({key:"Commands",default:[]}),Fp=ye({key:"TokenCount",default:0}),bu=ye({key:"Loading",default:!1}),Su=ye({key:"AskUser",default:void 0}),dS=ye({key:"WavRecorder",dangerouslyAllowMutability:!0,default:new jp}),hS=ye({key:"WavStreamPlayer",dangerouslyAllowMutability:!0,default:new Up}),pS=ye({key:"AudioConnection",default:"off"}),gS=ye({key:"isAiSpeaking",default:!1}),Qp=ye({key:"CallFn",default:void 0}),qo=ye({key:"ChatSettings",default:[]}),Yp=Do({key:"ChatSettingsValue/Default",get:({get:t})=>{let e=t(qo),n=(i,o)=>(Array.isArray(i)&&i.forEach(a=>{a&&(Array.isArray(a?.inputs)&&a.inputs.length>0?n(a.inputs,o):a?.id!==void 0&&(o[a.id]=a.initial))}),o);return n(e,{})}}),Wo=ye({key:"ChatSettingsValue",default:Yp}),Nu=ye({key:"DisplayElements",default:[]}),Du=ye({key:"TasklistElements",default:[]}),Iu=ye({key:"FirstUserInteraction",default:void 0}),mS=ye({key:"User",default:void 0}),yS=ye({key:"ChainlitConfig",default:void 0}),vS=ye({key:"AuthConfig",default:void 0}),MS=ye({key:"ThreadHistory",default:{threads:void 0,currentThreadId:void 0,timeGroupedThreads:void 0,pageInfo:void 0},effects:[({setSelf:t,onSet:e})=>{e((n,i)=>{let o=n?.timeGroupedThreads;n?.threads&&!ei.isEqual(n.threads,i?.timeGroupedThreads)&&(o=$1(n.threads)),t({...n,timeGroupedThreads:o})})}]}),qp=ye({key:"SideView",default:void 0}),Cu=ye({key:"CurrentThreadId",default:void 0}),wS=t=>({setSelf:e,onSet:n})=>{let i=localStorage.getItem(t);if(i!=null)try{e(JSON.parse(i))}catch(o){console.error(`Error parsing localStorage value for key "${t}":`,o)}n((o,a,u)=>{u?localStorage.removeItem(t):localStorage.setItem(t,JSON.stringify(o))})},xS=ye({key:"Mcp",default:[],effects:[wS("mcp_storage_key")]}),TS=()=>{let t=It(bu),e=It(Nu),n=It(Du),i=It(Eu),o=It(Tu),a=It(Su),u=It(Qp),c=It(qo),d=It(Wo),h=It(Yp),p=o?.socket.connected&&!o?.error,m=!p||t||a?.spec.type==="file"||a?.spec.type==="action"||a?.spec.type==="element";return{actions:i,askUser:a,callFn:u,chatSettingsDefaultValue:h,chatSettingsInputs:c,chatSettingsValue:d,connected:p,disabled:m,elements:e,error:o?.error,loading:t,tasklists:n}},Di=(t,e)=>_o(t,e.id)?ku(t,e.id,e):"parentId"in e&&e.parentId?_p(t,e.parentId,e):"indent"in e&&e.indent&&e.indent>0?Wp(t,e.indent,e):[...t,e],Wp=(t,e,n,i=0)=>{let o=[...t];if(o.length===0)return[...o,n];{let a=o.length-1,u=o[a];return u.steps=u.steps||[],i+1===e?(u.steps=[...u.steps,n],o[a]={...u},o):(u.steps=Wp(u.steps,e,n,i+1),o[a]={...u},o)}},_p=(t,e,n)=>{let i=[...t];for(let o=0;o<i.length;o++){let a=i[o];ei.isEqual(a.id,e)?(a.steps=a.steps?[...a.steps,n]:[n],i[o]={...a}):_o(i,e)&&a.steps&&(a.steps=_p(a.steps,e,n),i[o]={...a})}return i},Kp=(t,e)=>{for(let n of t){if(ei.isEqual(n.id,e))return n;if(n.steps&&n.steps.length>0){let i=Kp(n.steps,e);if(i)return i}}},_o=(t,e)=>Kp(t,e)!==void 0,ku=(t,e,n)=>{let i=[...t];for(let o=0;o<i.length;o++){let a=i[o];ei.isEqual(a.id,e)?i[o]={steps:a.steps,...n}:_o(i,e)&&a.steps&&(a.steps=ku(a.steps,e,n),i[o]={...a})}return i},Hp=(t,e)=>{let n=[...t];for(let i=0;i<n.length;i++){let o=n[i];o.id===e?n=[...n.slice(0,i),...n.slice(i+1)]:_o(n,e)&&o.steps&&(o.steps=Hp(o.steps,e),n[i]={...o})}return n},Jp=(t,e,n,i,o)=>{let a=[...t];for(let u=0;u<a.length;u++){let c=a[u];ei.isEqual(c.id,e)?("content"in c&&c.content!==void 0?i?c.content=n:c.content+=n:o?"input"in c&&c.input!==void 0&&(i?c.input=n:c.input+=n):"output"in c&&c.output!==void 0&&(i?c.output=n:c.output+=n),a[u]={...c}):c.steps&&(c.steps=Jp(c.steps,e,n,i,o),a[u]={...c})}return a},Ko=()=>{let[t,e]=bi(vS),[n,i]=bi(mS),o=ht(MS);return{authConfig:t,setAuthConfig:e,user:n,setUser:i,setThreadHistory:o}},ES=async(t,e)=>(await t.get(e))?.json(),AS=t=>{let e=new Xp("","webapp");return Object.assign(e,t),e};function Ho(t,{...e}={}){let n=x.useContext(Jo),{setUser:i}=Ko(),o=x.useMemo(()=>([u])=>{e.onErrorRetry||(e.onErrorRetry=(...d)=>{let[h]=d;if(h.status===401){i(null);return}return Zb.defaultValue.onErrorRetry(...d)});let c=AS(n);return c.on401=c.onError=void 0,ES(c,u)},[n]),a=x.useMemo(()=>t?[t]:null,[t]);return Xb(a,o,e)}var bS=()=>{let{authConfig:t,setAuthConfig:e}=Ko(),{data:n,isLoading:i}=Ho(t?null:"/auth/config");return x.useEffect(()=>{n&&e(n)},[n,e]),{authConfig:t,isLoading:i}},SS=()=>{let t=x.useContext(Jo),{setUser:e,setThreadHistory:n}=Ko();return{logout:async(i=!1)=>{await t.logout(),e(void 0),n(void 0),i&&window.location.reload()}}},NS=()=>{let{user:t,setUser:e}=Ko(),{data:n,error:i,mutate:o}=Ho("/user");return x.useEffect(()=>{n&&e(n)},[n,e]),x.useEffect(()=>{i&&e(null)},[i]),{user:t,setUserFromAPI:o}},Gp=()=>{let{authConfig:t}=bS(),{logout:e}=SS(),{user:n,setUserFromAPI:i}=NS(),o=!!t&&(!t.requireLogin||n!==void 0);return t&&!t.requireLogin?{data:t,user:null,isReady:o,isAuthenticated:!0,logout:()=>Promise.resolve(),setUserFromAPI:()=>Promise.resolve()}:{data:t,user:n,isReady:o,isAuthenticated:!!n,logout:e,setUserFromAPI:i}},Zp=class extends Error{constructor(e,n,i){super(e),this.status=n,this.detail=i}toString(){return this.detail?`${this.message}: ${this.detail}`:this.message}},DS=class{constructor(e,n,i,o,a){this.httpEndpoint=e,this.type=n,this.additionalQueryParams=i,this.on401=o,this.onError=a}buildEndpoint(e){let n=`${this.httpEndpoint}${e}`;this.httpEndpoint.endsWith("/")&&(n=`${this.httpEndpoint.slice(0,-1)}${e}`);let i=new URL(n);if(this.additionalQueryParams){let o=new URLSearchParams(this.additionalQueryParams),a=i.search?"&":"?";i.search=i.search+`${a}${o.toString()}`}return i.toString()}async getDetailFromErrorResponse(e){try{return(await e.json())?.detail}catch(n){console.error("Unable to parse error response",n)}}handleRequestError(e){e instanceof Zp&&(e.status===401&&this.on401&&this.on401(),this.onError&&this.onError(e)),console.error(e)}async fetch(e,n,i,o,a={}){try{let u;i instanceof FormData?u=i:(a["Content-Type"]="application/json",u=i?JSON.stringify(i):null);let c=await fetch(this.buildEndpoint(n),{method:e,credentials:"include",headers:a,signal:o,body:u});if(!c.ok){let d=await this.getDetailFromErrorResponse(c);throw new Zp(c.statusText,c.status,d)}return c}catch(u){throw this.handleRequestError(u),u}}async get(e){return await this.fetch("GET",e)}async post(e,n,i){return await this.fetch("POST",e,n,i)}async put(e,n){return await this.fetch("PUT",e,n)}async patch(e,n){return await this.fetch("PATCH",e,n)}async delete(e,n){return await this.fetch("DELETE",e,n)}},Xp=class extends DS{async headerAuth(e){return e?(await this.fetch("POST","/auth/header",void 0,void 0,{Authorization:`Bearer ${e}`})).json():(await this.post("/auth/header",{})).json()}async jwtAuth(e){return(await this.fetch("POST","/auth/jwt",void 0,void 0,{Authorization:`Bearer ${e}`})).json()}async stickyCookie(e){return(await this.fetch("POST","/set-session-cookie",{session_id:e})).json()}async passwordAuth(e){return(await this.post("/login",e)).json()}async getUser(){return(await this.get("/user")).json()}async logout(){return(await this.post("/logout",{})).json()}async setFeedback(e,n){return(await this.put("/feedback",{feedback:e,sessionId:n})).json()}async deleteFeedback(e){return(await this.delete("/feedback",{feedbackId:e})).json()}async listThreads(e,n){return(await this.post("/project/threads",{pagination:e,filter:n})).json()}async renameThread(e,n){return(await this.put("/project/thread",{threadId:e,name:n})).json()}async deleteThread(e){return(await this.delete("/project/thread",{threadId:e})).json()}uploadFile(e,n,i,o){let a=new XMLHttpRequest;a.withCredentials=!0;let u=new Promise((c,d)=>{let h=new FormData;h.append("file",e);let p=o?`&ask_parent_id=${o}`:"";a.open("POST",this.buildEndpoint(`/project/file?session_id=${i}${p}`),!0),a.upload.onprogress=function(m){if(m.lengthComputable){let w=m.loaded/m.total*100;n(w)}},a.onload=function(){if(a.status===200){let w=JSON.parse(a.responseText);c(w);return}let m=a.getResponseHeader("Content-Type");if(m&&m.includes("application/json")){let w=JSON.parse(a.responseText);d(w.detail)}else d("Upload failed")},a.onerror=function(){d("Upload error")},a.send(h)});return{xhr:a,promise:u}}async callAction(e,n){return(await this.post("/project/action",{sessionId:n,action:e})).json()}async updateElement(e,n){return(await this.put("/project/element",{sessionId:n,element:e})).json()}async deleteElement(e,n){return(await this.delete("/project/element",{sessionId:n,element:e})).json()}async connectStdioMCP(e,n,i){return(await this.post("/mcp",{sessionId:e,name:n,fullCommand:i,clientType:"stdio"})).json()}async connectSseMCP(e,n,i,o){return(await this.post("/mcp",{sessionId:e,name:n,url:i,...o?{headers:o}:{},clientType:"sse"})).json()}async connectStreamableHttpMCP(e,n,i,o){return(await this.post("/mcp",{sessionId:e,name:n,url:i,...o?{headers:o}:{},clientType:"streamable-http"})).json()}async disconnectMcp(e,n){return(await this.delete("/mcp",{sessionId:e,name:n})).json()}getElementUrl(e,n){let i=`?session_id=${n}`;return this.buildEndpoint(`/project/file/${e}${i}`)}getLogoEndpoint(e,n){return n||this.buildEndpoint(`/logo?theme=${e}`)}getOAuthEndpoint(e){return this.buildEndpoint(`/auth/oauth/${e}`)}async shareThread(e,n){return(await this.put("/project/thread/share",{threadId:e,isShared:n})).json()}},Jo=x.createContext(new Xp("https://v2.tia.ascenthr.ai","webapp")),$p=()=>{let t=x.useContext(Jo),e=It(Tu),n=It(Su),i=It(xu),o=Io(qo),a=Io(xu),u=Io(Wo),c=ht(Iu),d=ht(bu),h=ht(Au),p=ht(Nu),m=ht(Du),w=ht(Eu),y=ht(Fp),b=ht(Vp),S=ht(qp),P=ht(Cu),R=x.useCallback(()=>{e?.socket.emit("clear_session"),e?.socket.disconnect(),b(void 0),a(),c(void 0),h([]),p([]),m([]),w([]),y(0),o(),u(),S(void 0),P(void 0)},[e]),L=x.useCallback((ue,Fe=[])=>{ue.id||(ue.id=Pl()),ue.createdAt||(ue.createdAt=new Date().toISOString()),h(Ee=>Di(Ee,ue)),e?.socket.emit("client_message",{message:ue,fileReferences:Fe})},[e?.socket]),k=x.useCallback(ue=>{e?.socket.emit("edit_message",{message:ue})},[e?.socket]),Z=x.useCallback(ue=>{e?.socket.emit("window_message",ue)},[e?.socket]),B=x.useCallback(()=>{e?.socket.emit("audio_start")},[e?.socket]),J=x.useCallback((ue,Fe,Ee,we)=>{e?.socket.emit("audio_chunk",{isStart:ue,mimeType:Fe,elapsedTime:Ee,data:we})},[e?.socket]),G=x.useCallback(()=>{e?.socket.emit("audio_end")},[e?.socket]),K=x.useCallback(ue=>{n&&(n.parentId&&(ue.parentId=n.parentId),h(Fe=>Di(Fe,ue)),n.callback(ue))},[n]),Me=x.useCallback(ue=>{e?.socket.emit("chat_settings_change",ue)},[e?.socket]),fe=x.useCallback(()=>{h(ue=>ue.map(Fe=>(Fe.streaming=!1,Fe))),d(!1),e?.socket.emit("stop")},[e?.socket]);return{uploadFile:x.useCallback((ue,Fe,Ee)=>t.uploadFile(ue,Fe,i,Ee),[i]),clear:R,replyMessage:K,sendMessage:L,editMessage:k,windowMessage:Z,startAudioStream:B,sendAudioChunk:J,endAudioStream:G,stopTask:fe,setIdToResume:b,updateChatSettings:Me}},IS=()=>{let t=It(Au),e=It(Iu);return{threadId:It(Cu),messages:t,firstInteraction:e}},eg=()=>{let t=x.useContext(Jo),e=It(xu),[n,i]=bi(Tu),o=ht(gS),a=ht(pS),u=Io(Wo),c=ht(Wo),d=ht(Iu),h=ht(bu),p=ht(xS),m=It(hS),w=It(dS),y=ht(Au),b=ht(Su),S=ht(Qp),P=ht(fS),R=ht(qp),L=ht(Nu),k=ht(Du),Z=ht(Eu),B=ht(qo),J=ht(Fp),[G,K]=bi(Pp),Me=It(Vp),fe=ht(cS),[ue,Fe]=bi(Cu);x.useEffect(()=>{n?.socket&&(n.socket.auth.threadId=ue||"")},[ue]);let Ee=x.useCallback(async({transports:$e,userEnv:Te})=>{let{protocol:Re,host:he,pathname:ae}=new URL(t.httpEndpoint),pe=`${Re}//${he}`,I=ae&&ae!=="/"?`${ae}/ws/socket.io`:"/ws/socket.io";try{await t.stickyCookie(e)}catch(N){console.error(`Failed to set sticky session cookie: ${N}`)}let j=Qo(pe,{path:I,withCredentials:!0,transports:$e,auth:{clientType:t.type,sessionId:e,threadId:Me||"",userEnv:JSON.stringify(Te),chatProfile:G?encodeURIComponent(G):""}});i(N=>(N?.socket?.removeAllListeners(),N?.socket?.close(),{socket:j})),j.on("connect",()=>{j.emit("connection_successful"),i(N=>({...N,error:!1})),p(N=>N.map(V=>{let Q;return V.clientType==="sse"?Q=t.connectSseMCP(e,V.name,V.url):V.clientType==="streamable-http"?Q=t.connectStreamableHttpMCP(e,V.name,V.url,V.headers||{}):Q=t.connectStdioMCP(e,V.name,V.command),Q.then(async({success:$,mcp:X})=>{p(xe=>xe.map(Le=>Le.name===X.name?{...Le,status:$?"connected":"failed",tools:X?X.tools:Le.tools}:Le))}).catch(()=>{p($=>$.map(X=>X.name===V.name?{...X,status:"failed"}:X))}),{...V,status:"connecting"}}))}),j.on("connect_error",N=>{i(V=>({...V,error:!0}))}),j.on("task_start",()=>{h(!0)}),j.on("task_end",()=>{h(!1)}),j.on("reload",()=>{j.emit("clear_session"),window.location.reload()}),j.on("audio_connection",async N=>{if(N==="on"){let V=!0,Q=Date.now(),$="pcm16";await w.begin(),await m.connect(),await w.record(async X=>{let xe=Date.now()-Q;j.emit("audio_chunk",{isStart:V,mimeType:$,elapsedTime:xe,data:X.mono}),V=!1}),m.onStop=()=>o(!1)}else await w.end(),await m.interrupt();a(N)}),j.on("audio_chunk",N=>{m.add16BitPCM(N.data,N.track),o(!0)}),j.on("audio_interrupt",()=>{m.interrupt()}),j.on("resume_thread",N=>{let V=!!N?.metadata?.viewer_read_only;!V&&Me&&N.id!==Me&&(window.location.href=`/thread/${N.id}`),!V&&Me&&Fe(N.id);let Q=[];for(let X of N.steps)Q=Di(Q,X);N.metadata?.chat_profile&&K(N.metadata?.chat_profile),N.metadata?.chat_settings&&c(N.metadata?.chat_settings),y(Q);let $=N.elements||[];k($.filter(X=>X.type==="tasklist")),L($.filter(X=>["avatar","tasklist"].indexOf(X.type)===-1))}),j.on("resume_thread_error",N=>{fe(N)}),j.on("new_message",N=>{y(V=>Di(V,N))}),j.on("first_interaction",N=>{d(N.interaction),Fe(N.thread_id)}),j.on("update_message",N=>{y(V=>ku(V,N.id,N))}),j.on("delete_message",N=>{y(V=>Hp(V,N.id))}),j.on("stream_start",N=>{y(V=>Di(V,N))}),j.on("stream_token",({id:N,token:V,isSequence:Q,isInput:$})=>{y(X=>Jp(X,N,V,Q,$))}),j.on("ask",({msg:N,spec:V},Q)=>{b({spec:V,callback:Q,parentId:N.parentId}),y($=>Di($,N)),h(!1)}),j.on("ask_timeout",()=>{b(void 0),h(!1)}),j.on("clear_ask",()=>{b(void 0)}),j.on("call_fn",({name:N,args:V},Q)=>{S({name:N,args:V,callback:Q})}),j.on("clear_call_fn",()=>{S(void 0)}),j.on("call_fn_timeout",()=>{S(void 0)}),j.on("chat_settings",N=>{B(N),u()}),j.on("set_commands",N=>{P(N)}),j.on("set_sidebar_title",N=>{R(V=>V?.title===N?V:{title:N,elements:V?.elements||[]})}),j.on("set_sidebar_elements",({elements:N,key:V})=>{N.length?(N.forEach(Q=>{!Q.url&&Q.chainlitKey&&(Q.url=t.getElementUrl(Q.chainlitKey,e))}),R(Q=>Q?.key===V?Q:{title:Q?.title||"",elements:N,key:V})):R(void 0)}),j.on("element",N=>{!N.url&&N.chainlitKey&&(N.url=t.getElementUrl(N.chainlitKey,e)),N.type==="tasklist"?k(V=>{let Q=V.findIndex($=>$.id===N.id);return Q===-1?[...V,N]:[...V.slice(0,Q),N,...V.slice(Q+1)]}):L(V=>{let Q=V.findIndex($=>$.id===N.id);return Q===-1?[...V,N]:[...V.slice(0,Q),N,...V.slice(Q+1)]})}),j.on("remove_element",N=>{L(V=>V.filter(Q=>Q.id!==N.id)),k(V=>V.filter(Q=>Q.id!==N.id))}),j.on("action",N=>{Z(V=>[...V,N])}),j.on("remove_action",N=>{Z(V=>{let Q=V.findIndex($=>$.id===N.id);return Q===-1?V:[...V.slice(0,Q),...V.slice(Q+1)]})}),j.on("token_usage",N=>{J(V=>V+N)}),j.on("window_message",N=>{window.parent&&window.parent.postMessage(N,"*")}),j.on("toast",N=>{if(!N.message){console.warn("No message received for toast.");return}switch(N.type){case"info":Ni.info(N.message);break;case"error":Ni.error(N.message);break;case"success":Ni.success(N.message);break;case"warning":Ni.warning(N.message);break;default:Ni(N.message);break}})},[i,e,Me,G]),we=x.useCallback(ei.debounce(Ee,200),[Ee]),nt=x.useCallback(()=>{n?.socket&&(n.socket.removeAllListeners(),n.socket.close())},[n]);return{connect:we,disconnect:nt,session:n,sessionId:e,chatProfile:G,idToResume:Me,setChatProfile:K}},tg=()=>{let[t,e]=bi(yS),{isAuthenticated:n}=Gp(),i=It(Pp),o=navigator.language||"en-US",a=x.useRef(i),u=n?`/project/settings?language=${o}${i?`&chat_profile=${encodeURIComponent(i)}`:""}`:null,c=n&&!t,{data:d,error:h,isLoading:p}=Ho(c?u:null);return x.useEffect(()=>{d&&e(d)},[d,e]),x.useEffect(()=>{a.current!==i&&(e(void 0),a.current=i)},[i,e]),{config:t,error:h,isLoading:p,language:o}};const CS="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='utf-8'?%3e%3c!--%20Uploaded%20to:%20SVG%20Repo,%20www.svgrepo.com,%20Generator:%20SVG%20Repo%20Mixer%20Tools%20--%3e%3csvg%20width='800px'%20height='800px'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M12%2022C17.5228%2022%2022%2017.5228%2022%2012C22%206.47715%2017.5228%202%2012%202C6.47715%202%202%206.47715%202%2012C2%2013.5997%202.37562%2015.1116%203.04346%2016.4525C3.22094%2016.8088%203.28001%2017.2161%203.17712%2017.6006L2.58151%2019.8267C2.32295%2020.793%203.20701%2021.677%204.17335%2021.4185L6.39939%2020.8229C6.78393%2020.72%207.19121%2020.7791%207.54753%2020.9565C8.88837%2021.6244%2010.4003%2022%2012%2022Z'%20fill='%23262D7B'/%3e%3c/svg%3e",zu=x.createContext({});function Lu(t){const e=x.useRef(null);return e.current===null&&(e.current=t()),e.current}const Ou=typeof window<"u",ng=Ou?x.useLayoutEffect:x.useEffect,Go=x.createContext(null);function Ru(t,e){t.indexOf(e)===-1&&t.push(e)}function ju(t,e){const n=t.indexOf(e);n>-1&&t.splice(n,1)}const gr=(t,e,n)=>n>e?e:n<t?t:n;function Uu(t,e){return e?`${t}. For more information and steps for solving, visit https://motion.dev/troubleshooting/${e}`:t}var kS={env:{}};let Ii=()=>{},mr=()=>{};kS.env.NODE_ENV!=="production"&&(Ii=(t,e,n)=>{!t&&typeof console<"u"&&console.warn(Uu(e,n))},mr=(t,e,n)=>{if(!t)throw new Error(Uu(e,n))});const yr={},rg=t=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t);function ig(t){return typeof t=="object"&&t!==null}const sg=t=>/^0[^.\s]+$/u.test(t);function Vu(t){let e;return()=>(e===void 0&&(e=t()),e)}const Ln=t=>t,zS=(t,e)=>n=>e(t(n)),Ts=(...t)=>t.reduce(zS),Es=(t,e,n)=>{const i=e-t;return i===0?1:(n-t)/i};class Pu{constructor(){this.subscriptions=[]}add(e){return Ru(this.subscriptions,e),()=>ju(this.subscriptions,e)}notify(e,n,i){const o=this.subscriptions.length;if(o)if(o===1)this.subscriptions[0](e,n,i);else for(let a=0;a<o;a++){const u=this.subscriptions[a];u&&u(e,n,i)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const Jn=t=>t*1e3,On=t=>t/1e3;function og(t,e){return e?t*(1e3/e):0}const ag=new Set;function Bu(t,e,n){t||ag.has(e)||(console.warn(Uu(e,n)),ag.add(e))}const lg=(t,e,n)=>(((1-3*n+3*e)*t+(3*n-6*e))*t+3*e)*t,LS=1e-7,OS=12;function RS(t,e,n,i,o){let a,u,c=0;do u=e+(n-e)/2,a=lg(u,i,o)-t,a>0?n=u:e=u;while(Math.abs(a)>LS&&++c<OS);return u}function As(t,e,n,i){if(t===e&&n===i)return Ln;const o=a=>RS(a,0,1,t,n);return a=>a===0||a===1?a:lg(o(a),e,i)}const ug=t=>e=>e<=.5?t(2*e)/2:(2-t(2*(1-e)))/2,cg=t=>e=>1-t(1-e),fg=As(.33,1.53,.69,.99),Fu=cg(fg),dg=ug(Fu),hg=t=>(t*=2)<1?.5*Fu(t):.5*(2-Math.pow(2,-10*(t-1))),Qu=t=>1-Math.sin(Math.acos(t)),pg=cg(Qu),gg=ug(Qu),jS=As(.42,0,1,1),US=As(0,0,.58,1),mg=As(.42,0,.58,1),VS=t=>Array.isArray(t)&&typeof t[0]!="number",yg=t=>Array.isArray(t)&&typeof t[0]=="number",vg={linear:Ln,easeIn:jS,easeInOut:mg,easeOut:US,circIn:Qu,circInOut:gg,circOut:pg,backIn:Fu,backInOut:dg,backOut:fg,anticipate:hg},PS=t=>typeof t=="string",Mg=t=>{if(yg(t)){mr(t.length===4,"Cubic bezier arrays must contain four numerical values.","cubic-bezier-length");const[e,n,i,o]=t;return As(e,n,i,o)}else if(PS(t))return mr(vg[t]!==void 0,`Invalid easing type '${t}'`,"invalid-easing-type"),vg[t];return t},Zo=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function BS(t,e){let n=new Set,i=new Set,o=!1,a=!1;const u=new WeakSet;let c={delta:0,timestamp:0,isProcessing:!1};function d(p){u.has(p)&&(h.schedule(p),t()),p(c)}const h={schedule:(p,m=!1,w=!1)=>{const b=w&&o?n:i;return m&&u.add(p),b.has(p)||b.add(p),p},cancel:p=>{i.delete(p),u.delete(p)},process:p=>{if(c=p,o){a=!0;return}o=!0,[n,i]=[i,n],n.forEach(d),n.clear(),o=!1,a&&(a=!1,h.process(p))}};return h}const FS=40;function wg(t,e){let n=!1,i=!0;const o={delta:0,timestamp:0,isProcessing:!1},a=()=>n=!0,u=Zo.reduce((k,Z)=>(k[Z]=BS(a),k),{}),{setup:c,read:d,resolveKeyframes:h,preUpdate:p,update:m,preRender:w,render:y,postRender:b}=u,S=()=>{const k=yr.useManualTiming?o.timestamp:performance.now();n=!1,yr.useManualTiming||(o.delta=i?1e3/60:Math.max(Math.min(k-o.timestamp,FS),1)),o.timestamp=k,o.isProcessing=!0,c.process(o),d.process(o),h.process(o),p.process(o),m.process(o),w.process(o),y.process(o),b.process(o),o.isProcessing=!1,n&&e&&(i=!1,t(S))},P=()=>{n=!0,i=!0,o.isProcessing||t(S)};return{schedule:Zo.reduce((k,Z)=>{const B=u[Z];return k[Z]=(J,G=!1,K=!1)=>(n||P(),B.schedule(J,G,K)),k},{}),cancel:k=>{for(let Z=0;Z<Zo.length;Z++)u[Zo[Z]].cancel(k)},state:o,steps:u}}const{schedule:Et,cancel:zr,state:Jt,steps:Yu}=wg(typeof requestAnimationFrame<"u"?requestAnimationFrame:Ln,!0);let Xo;function QS(){Xo=void 0}const hn={now:()=>(Xo===void 0&&hn.set(Jt.isProcessing||yr.useManualTiming?Jt.timestamp:performance.now()),Xo),set:t=>{Xo=t,queueMicrotask(QS)}},xg=t=>e=>typeof e=="string"&&e.startsWith(t),qu=xg("--"),YS=xg("var(--"),Wu=t=>YS(t)?qS.test(t.split("/*")[0].trim()):!1,qS=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu,Ci={test:t=>typeof t=="number",parse:parseFloat,transform:t=>t},bs={...Ci,transform:t=>gr(0,1,t)},$o={...Ci,default:1},Ss=t=>Math.round(t*1e5)/1e5,_u=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function WS(t){return t==null}const _S=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,Ku=(t,e)=>n=>!!(typeof n=="string"&&_S.test(n)&&n.startsWith(t)||e&&!WS(n)&&Object.prototype.hasOwnProperty.call(n,e)),Tg=(t,e,n)=>i=>{if(typeof i!="string")return i;const[o,a,u,c]=i.match(_u);return{[t]:parseFloat(o),[e]:parseFloat(a),[n]:parseFloat(u),alpha:c!==void 0?parseFloat(c):1}},KS=t=>gr(0,255,t),Hu={...Ci,transform:t=>Math.round(KS(t))},ni={test:Ku("rgb","red"),parse:Tg("red","green","blue"),transform:({red:t,green:e,blue:n,alpha:i=1})=>"rgba("+Hu.transform(t)+", "+Hu.transform(e)+", "+Hu.transform(n)+", "+Ss(bs.transform(i))+")"};function HS(t){let e="",n="",i="",o="";return t.length>5?(e=t.substring(1,3),n=t.substring(3,5),i=t.substring(5,7),o=t.substring(7,9)):(e=t.substring(1,2),n=t.substring(2,3),i=t.substring(3,4),o=t.substring(4,5),e+=e,n+=n,i+=i,o+=o),{red:parseInt(e,16),green:parseInt(n,16),blue:parseInt(i,16),alpha:o?parseInt(o,16)/255:1}}const Ju={test:Ku("#"),parse:HS,transform:ni.transform},Ns=t=>({test:e=>typeof e=="string"&&e.endsWith(t)&&e.split(" ").length===1,parse:parseFloat,transform:e=>`${e}${t}`}),Lr=Ns("deg"),ar=Ns("%"),Ie=Ns("px"),JS=Ns("vh"),GS=Ns("vw"),Eg={...ar,parse:t=>ar.parse(t)/100,transform:t=>ar.transform(t*100)},ki={test:Ku("hsl","hue"),parse:Tg("hue","saturation","lightness"),transform:({hue:t,saturation:e,lightness:n,alpha:i=1})=>"hsla("+Math.round(t)+", "+ar.transform(Ss(e))+", "+ar.transform(Ss(n))+", "+Ss(bs.transform(i))+")"},Bt={test:t=>ni.test(t)||Ju.test(t)||ki.test(t),parse:t=>ni.test(t)?ni.parse(t):ki.test(t)?ki.parse(t):Ju.parse(t),transform:t=>typeof t=="string"?t:t.hasOwnProperty("red")?ni.transform(t):ki.transform(t),getAnimatableNone:t=>{const e=Bt.parse(t);return e.alpha=0,Bt.transform(e)}},ZS=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function XS(t){return isNaN(t)&&typeof t=="string"&&(t.match(_u)?.length||0)+(t.match(ZS)?.length||0)>0}const Ag="number",bg="color",$S="var",eN="var(",Sg="${}",tN=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function Ds(t){const e=t.toString(),n=[],i={color:[],number:[],var:[]},o=[];let a=0;const c=e.replace(tN,d=>(Bt.test(d)?(i.color.push(a),o.push(bg),n.push(Bt.parse(d))):d.startsWith(eN)?(i.var.push(a),o.push($S),n.push(d)):(i.number.push(a),o.push(Ag),n.push(parseFloat(d))),++a,Sg)).split(Sg);return{values:n,split:c,indexes:i,types:o}}function Ng(t){return Ds(t).values}function Dg(t){const{split:e,types:n}=Ds(t),i=e.length;return o=>{let a="";for(let u=0;u<i;u++)if(a+=e[u],o[u]!==void 0){const c=n[u];c===Ag?a+=Ss(o[u]):c===bg?a+=Bt.transform(o[u]):a+=o[u]}return a}}const nN=t=>typeof t=="number"?0:Bt.test(t)?Bt.getAnimatableNone(t):t;function rN(t){const e=Ng(t);return Dg(t)(e.map(nN))}const Or={test:XS,parse:Ng,createTransformer:Dg,getAnimatableNone:rN};function Gu(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<.16666666666666666?t+(e-t)*6*n:n<.5?e:n<.6666666666666666?t+(e-t)*(.6666666666666666-n)*6:t}function iN({hue:t,saturation:e,lightness:n,alpha:i}){t/=360,e/=100,n/=100;let o=0,a=0,u=0;if(!e)o=a=u=n;else{const c=n<.5?n*(1+e):n+e-n*e,d=2*n-c;o=Gu(d,c,t+.3333333333333333),a=Gu(d,c,t),u=Gu(d,c,t-.3333333333333333)}return{red:Math.round(o*255),green:Math.round(a*255),blue:Math.round(u*255),alpha:i}}function ea(t,e){return n=>n>0?e:t}const bt=(t,e,n)=>t+(e-t)*n,Zu=(t,e,n)=>{const i=t*t,o=n*(e*e-i)+i;return o<0?0:Math.sqrt(o)},sN=[Ju,ni,ki],oN=t=>sN.find(e=>e.test(t));function Ig(t){const e=oN(t);if(Ii(!!e,`'${t}' is not an animatable color. Use the equivalent color code instead.`,"color-not-animatable"),!e)return!1;let n=e.parse(t);return e===ki&&(n=iN(n)),n}const Cg=(t,e)=>{const n=Ig(t),i=Ig(e);if(!n||!i)return ea(t,e);const o={...n};return a=>(o.red=Zu(n.red,i.red,a),o.green=Zu(n.green,i.green,a),o.blue=Zu(n.blue,i.blue,a),o.alpha=bt(n.alpha,i.alpha,a),ni.transform(o))},Xu=new Set(["none","hidden"]);function aN(t,e){return Xu.has(t)?n=>n<=0?t:e:n=>n>=1?e:t}function lN(t,e){return n=>bt(t,e,n)}function $u(t){return typeof t=="number"?lN:typeof t=="string"?Wu(t)?ea:Bt.test(t)?Cg:fN:Array.isArray(t)?kg:typeof t=="object"?Bt.test(t)?Cg:uN:ea}function kg(t,e){const n=[...t],i=n.length,o=t.map((a,u)=>$u(a)(a,e[u]));return a=>{for(let u=0;u<i;u++)n[u]=o[u](a);return n}}function uN(t,e){const n={...t,...e},i={};for(const o in n)t[o]!==void 0&&e[o]!==void 0&&(i[o]=$u(t[o])(t[o],e[o]));return o=>{for(const a in i)n[a]=i[a](o);return n}}function cN(t,e){const n=[],i={color:0,var:0,number:0};for(let o=0;o<e.values.length;o++){const a=e.types[o],u=t.indexes[a][i[a]],c=t.values[u]??0;n[o]=c,i[a]++}return n}const fN=(t,e)=>{const n=Or.createTransformer(e),i=Ds(t),o=Ds(e);return i.indexes.var.length===o.indexes.var.length&&i.indexes.color.length===o.indexes.color.length&&i.indexes.number.length>=o.indexes.number.length?Xu.has(t)&&!o.values.length||Xu.has(e)&&!i.values.length?aN(t,e):Ts(kg(cN(i,o),o.values),n):(Ii(!0,`Complex values '${t}' and '${e}' too different to mix. Ensure all colors are of the same type, and that each contains the same quantity of number and color values. Falling back to instant transition.`,"complex-values-different"),ea(t,e))};function zg(t,e,n){return typeof t=="number"&&typeof e=="number"&&typeof n=="number"?bt(t,e,n):$u(t)(t,e)}const dN=t=>{const e=({timestamp:n})=>t(n);return{start:(n=!0)=>Et.update(e,n),stop:()=>zr(e),now:()=>Jt.isProcessing?Jt.timestamp:hn.now()}},Lg=(t,e,n=10)=>{let i="";const o=Math.max(Math.round(e/n),2);for(let a=0;a<o;a++)i+=Math.round(t(a/(o-1))*1e4)/1e4+", ";return`linear(${i.substring(0,i.length-2)})`},ta=2e4;function ec(t){let e=0;const n=50;let i=t.next(e);for(;!i.done&&e<ta;)e+=n,i=t.next(e);return e>=ta?1/0:e}function hN(t,e=100,n){const i=n({...t,keyframes:[0,e]}),o=Math.min(ec(i),ta);return{type:"keyframes",ease:a=>i.next(o*a).value/e,duration:On(o)}}const pN=5;function Og(t,e,n){const i=Math.max(e-pN,0);return og(n-t(i),e-i)}const St={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1},tc=.001;function gN({duration:t=St.duration,bounce:e=St.bounce,velocity:n=St.velocity,mass:i=St.mass}){let o,a;Ii(t<=Jn(St.maxDuration),"Spring duration must be 10 seconds or less","spring-duration-limit");let u=1-e;u=gr(St.minDamping,St.maxDamping,u),t=gr(St.minDuration,St.maxDuration,On(t)),u<1?(o=h=>{const p=h*u,m=p*t,w=p-n,y=nc(h,u),b=Math.exp(-m);return tc-w/y*b},a=h=>{const m=h*u*t,w=m*n+n,y=Math.pow(u,2)*Math.pow(h,2)*t,b=Math.exp(-m),S=nc(Math.pow(h,2),u);return(-o(h)+tc>0?-1:1)*((w-y)*b)/S}):(o=h=>{const p=Math.exp(-h*t),m=(h-n)*t+1;return-tc+p*m},a=h=>{const p=Math.exp(-h*t),m=(n-h)*(t*t);return p*m});const c=5/t,d=yN(o,a,c);if(t=Jn(t),isNaN(d))return{stiffness:St.stiffness,damping:St.damping,duration:t};{const h=Math.pow(d,2)*i;return{stiffness:h,damping:u*2*Math.sqrt(i*h),duration:t}}}const mN=12;function yN(t,e,n){let i=n;for(let o=1;o<mN;o++)i=i-t(i)/e(i);return i}function nc(t,e){return t*Math.sqrt(1-e*e)}const vN=["duration","bounce"],MN=["stiffness","damping","mass"];function Rg(t,e){return e.some(n=>t[n]!==void 0)}function wN(t){let e={velocity:St.velocity,stiffness:St.stiffness,damping:St.damping,mass:St.mass,isResolvedFromDuration:!1,...t};if(!Rg(t,MN)&&Rg(t,vN))if(t.visualDuration){const n=t.visualDuration,i=2*Math.PI/(n*1.2),o=i*i,a=2*gr(.05,1,1-(t.bounce||0))*Math.sqrt(o);e={...e,mass:St.mass,stiffness:o,damping:a}}else{const n=gN(t);e={...e,...n,mass:St.mass},e.isResolvedFromDuration=!0}return e}function na(t=St.visualDuration,e=St.bounce){const n=typeof t!="object"?{visualDuration:t,keyframes:[0,1],bounce:e}:t;let{restSpeed:i,restDelta:o}=n;const a=n.keyframes[0],u=n.keyframes[n.keyframes.length-1],c={done:!1,value:a},{stiffness:d,damping:h,mass:p,duration:m,velocity:w,isResolvedFromDuration:y}=wN({...n,velocity:-On(n.velocity||0)}),b=w||0,S=h/(2*Math.sqrt(d*p)),P=u-a,R=On(Math.sqrt(d/p)),L=Math.abs(P)<5;i||(i=L?St.restSpeed.granular:St.restSpeed.default),o||(o=L?St.restDelta.granular:St.restDelta.default);let k;if(S<1){const B=nc(R,S);k=J=>{const G=Math.exp(-S*R*J);return u-G*((b+S*R*P)/B*Math.sin(B*J)+P*Math.cos(B*J))}}else if(S===1)k=B=>u-Math.exp(-R*B)*(P+(b+R*P)*B);else{const B=R*Math.sqrt(S*S-1);k=J=>{const G=Math.exp(-S*R*J),K=Math.min(B*J,300);return u-G*((b+S*R*P)*Math.sinh(K)+B*P*Math.cosh(K))/B}}const Z={calculatedDuration:y&&m||null,next:B=>{const J=k(B);if(y)c.done=B>=m;else{let G=B===0?b:0;S<1&&(G=B===0?Jn(b):Og(k,B,J));const K=Math.abs(G)<=i,Me=Math.abs(u-J)<=o;c.done=K&&Me}return c.value=c.done?u:J,c},toString:()=>{const B=Math.min(ec(Z),ta),J=Lg(G=>Z.next(B*G).value,B,30);return B+"ms "+J},toTransition:()=>{}};return Z}na.applyToOptions=t=>{const e=hN(t,100,na);return t.ease=e.ease,t.duration=Jn(e.duration),t.type="keyframes",t};function rc({keyframes:t,velocity:e=0,power:n=.8,timeConstant:i=325,bounceDamping:o=10,bounceStiffness:a=500,modifyTarget:u,min:c,max:d,restDelta:h=.5,restSpeed:p}){const m=t[0],w={done:!1,value:m},y=K=>c!==void 0&&K<c||d!==void 0&&K>d,b=K=>c===void 0?d:d===void 0||Math.abs(c-K)<Math.abs(d-K)?c:d;let S=n*e;const P=m+S,R=u===void 0?P:u(P);R!==P&&(S=R-m);const L=K=>-S*Math.exp(-K/i),k=K=>R+L(K),Z=K=>{const Me=L(K),fe=k(K);w.done=Math.abs(Me)<=h,w.value=w.done?R:fe};let B,J;const G=K=>{y(w.value)&&(B=K,J=na({keyframes:[w.value,b(w.value)],velocity:Og(k,K,w.value),damping:o,stiffness:a,restDelta:h,restSpeed:p}))};return G(0),{calculatedDuration:null,next:K=>{let Me=!1;return!J&&B===void 0&&(Me=!0,Z(K),G(K)),B!==void 0&&K>=B?J.next(K-B):(!Me&&Z(K),w)}}}function xN(t,e,n){const i=[],o=n||yr.mix||zg,a=t.length-1;for(let u=0;u<a;u++){let c=o(t[u],t[u+1]);if(e){const d=Array.isArray(e)?e[u]||Ln:e;c=Ts(d,c)}i.push(c)}return i}function TN(t,e,{clamp:n=!0,ease:i,mixer:o}={}){const a=t.length;if(mr(a===e.length,"Both input and output ranges must be the same length","range-length"),a===1)return()=>e[0];if(a===2&&e[0]===e[1])return()=>e[1];const u=t[0]===t[1];t[0]>t[a-1]&&(t=[...t].reverse(),e=[...e].reverse());const c=xN(e,i,o),d=c.length,h=p=>{if(u&&p<t[0])return e[0];let m=0;if(d>1)for(;m<t.length-2&&!(p<t[m+1]);m++);const w=Es(t[m],t[m+1],p);return c[m](w)};return n?p=>h(gr(t[0],t[a-1],p)):h}function EN(t,e){const n=t[t.length-1];for(let i=1;i<=e;i++){const o=Es(0,e,i);t.push(bt(n,1,o))}}function AN(t){const e=[0];return EN(e,t.length-1),e}function bN(t,e){return t.map(n=>n*e)}function SN(t,e){return t.map(()=>e||mg).splice(0,t.length-1)}function zi({duration:t=300,keyframes:e,times:n,ease:i="easeInOut"}){const o=VS(i)?i.map(Mg):Mg(i),a={done:!1,value:e[0]},u=bN(n&&n.length===e.length?n:AN(e),t),c=TN(u,e,{ease:Array.isArray(o)?o:SN(e,o)});return{calculatedDuration:t,next:d=>(a.value=c(d),a.done=d>=t,a)}}const NN=t=>t!==null;function ic(t,{repeat:e,repeatType:n="loop"},i,o=1){const a=t.filter(NN),c=o<0||e&&n!=="loop"&&e%2===1?0:a.length-1;return!c||i===void 0?a[c]:i}const DN={decay:rc,inertia:rc,tween:zi,keyframes:zi,spring:na};function jg(t){typeof t.type=="string"&&(t.type=DN[t.type])}class sc{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(e=>{this.resolve=e})}notifyFinished(){this.resolve()}then(e,n){return this.finished.then(e,n)}}var IN={env:{}};const CN=t=>t/100;class oc extends sc{constructor(e){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.stop=()=>{const{motionValue:n}=this.options;n&&n.updatedAt!==hn.now()&&this.tick(hn.now()),this.isStopped=!0,this.state!=="idle"&&(this.teardown(),this.options.onStop?.())},this.options=e,this.initAnimation(),this.play(),e.autoplay===!1&&this.pause()}initAnimation(){const{options:e}=this;jg(e);const{type:n=zi,repeat:i=0,repeatDelay:o=0,repeatType:a,velocity:u=0}=e;let{keyframes:c}=e;const d=n||zi;IN.env.NODE_ENV!=="production"&&d!==zi&&mr(c.length<=2,`Only two keyframes currently supported with spring and inertia animations. Trying to animate ${c}`,"spring-two-frames"),d!==zi&&typeof c[0]!="number"&&(this.mixKeyframes=Ts(CN,zg(c[0],c[1])),c=[0,100]);const h=d({...e,keyframes:c});a==="mirror"&&(this.mirroredGenerator=d({...e,keyframes:[...c].reverse(),velocity:-u})),h.calculatedDuration===null&&(h.calculatedDuration=ec(h));const{calculatedDuration:p}=h;this.calculatedDuration=p,this.resolvedDuration=p+o,this.totalDuration=this.resolvedDuration*(i+1)-o,this.generator=h}updateTime(e){const n=Math.round(e-this.startTime)*this.playbackSpeed;this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=n}tick(e,n=!1){const{generator:i,totalDuration:o,mixKeyframes:a,mirroredGenerator:u,resolvedDuration:c,calculatedDuration:d}=this;if(this.startTime===null)return i.next(0);const{delay:h=0,keyframes:p,repeat:m,repeatType:w,repeatDelay:y,type:b,onUpdate:S,finalKeyframe:P}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,e):this.speed<0&&(this.startTime=Math.min(e-o/this.speed,this.startTime)),n?this.currentTime=e:this.updateTime(e);const R=this.currentTime-h*(this.playbackSpeed>=0?1:-1),L=this.playbackSpeed>=0?R<0:R>o;this.currentTime=Math.max(R,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=o);let k=this.currentTime,Z=i;if(m){const K=Math.min(this.currentTime,o)/c;let Me=Math.floor(K),fe=K%1;!fe&&K>=1&&(fe=1),fe===1&&Me--,Me=Math.min(Me,m+1),!!(Me%2)&&(w==="reverse"?(fe=1-fe,y&&(fe-=y/c)):w==="mirror"&&(Z=u)),k=gr(0,1,fe)*c}const B=L?{done:!1,value:p[0]}:Z.next(k);a&&(B.value=a(B.value));let{done:J}=B;!L&&d!==null&&(J=this.playbackSpeed>=0?this.currentTime>=o:this.currentTime<=0);const G=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&J);return G&&b!==rc&&(B.value=ic(p,this.options,P,this.speed)),S&&S(B.value),G&&this.finish(),B}then(e,n){return this.finished.then(e,n)}get duration(){return On(this.calculatedDuration)}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+On(e)}get time(){return On(this.currentTime)}set time(e){e=Jn(e),this.currentTime=e,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=e:this.driver&&(this.startTime=this.driver.now()-e/this.playbackSpeed),this.driver?.start(!1)}get speed(){return this.playbackSpeed}set speed(e){this.updateTime(hn.now());const n=this.playbackSpeed!==e;this.playbackSpeed=e,n&&(this.time=On(this.currentTime))}play(){if(this.isStopped)return;const{driver:e=dN,startTime:n}=this.options;this.driver||(this.driver=e(o=>this.tick(o))),this.options.onPlay?.();const i=this.driver.now();this.state==="finished"?(this.updateFinished(),this.startTime=i):this.holdTime!==null?this.startTime=i-this.holdTime:this.startTime||(this.startTime=n??i),this.state==="finished"&&this.speed<0&&(this.startTime+=this.calculatedDuration),this.holdTime=null,this.state="running",this.driver.start()}pause(){this.state="paused",this.updateTime(hn.now()),this.holdTime=this.currentTime}complete(){this.state!=="running"&&this.play(),this.state="finished",this.holdTime=null}finish(){this.notifyFinished(),this.teardown(),this.state="finished",this.options.onComplete?.()}cancel(){this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),this.options.onCancel?.()}teardown(){this.state="idle",this.stopDriver(),this.startTime=this.holdTime=null}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(e){return this.startTime=0,this.tick(e,!0)}attachTimeline(e){return this.options.allowFlatten&&(this.options.type="keyframes",this.options.ease="linear",this.initAnimation()),this.driver?.stop(),e.observe(this)}}function kN(t){for(let e=1;e<t.length;e++)t[e]??(t[e]=t[e-1])}const ri=t=>t*180/Math.PI,ac=t=>{const e=ri(Math.atan2(t[1],t[0]));return lc(e)},zN={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:t=>(Math.abs(t[0])+Math.abs(t[3]))/2,rotate:ac,rotateZ:ac,skewX:t=>ri(Math.atan(t[1])),skewY:t=>ri(Math.atan(t[2])),skew:t=>(Math.abs(t[1])+Math.abs(t[2]))/2},lc=t=>(t=t%360,t<0&&(t+=360),t),Ug=ac,Vg=t=>Math.sqrt(t[0]*t[0]+t[1]*t[1]),Pg=t=>Math.sqrt(t[4]*t[4]+t[5]*t[5]),LN={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:Vg,scaleY:Pg,scale:t=>(Vg(t)+Pg(t))/2,rotateX:t=>lc(ri(Math.atan2(t[6],t[5]))),rotateY:t=>lc(ri(Math.atan2(-t[2],t[0]))),rotateZ:Ug,rotate:Ug,skewX:t=>ri(Math.atan(t[4])),skewY:t=>ri(Math.atan(t[1])),skew:t=>(Math.abs(t[1])+Math.abs(t[4]))/2};function uc(t){return t.includes("scale")?1:0}function cc(t,e){if(!t||t==="none")return uc(e);const n=t.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let i,o;if(n)i=LN,o=n;else{const c=t.match(/^matrix\(([-\d.e\s,]+)\)$/u);i=zN,o=c}if(!o)return uc(e);const a=i[e],u=o[1].split(",").map(RN);return typeof a=="function"?a(u):u[a]}const ON=(t,e)=>{const{transform:n="none"}=getComputedStyle(t);return cc(n,e)};function RN(t){return parseFloat(t.trim())}const Li=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],Oi=new Set(Li),Bg=t=>t===Ci||t===Ie,jN=new Set(["x","y","z"]),UN=Li.filter(t=>!jN.has(t));function VN(t){const e=[];return UN.forEach(n=>{const i=t.getValue(n);i!==void 0&&(e.push([n,i.get()]),i.set(n.startsWith("scale")?1:0))}),e}const ii={width:({x:t},{paddingLeft:e="0",paddingRight:n="0"})=>t.max-t.min-parseFloat(e)-parseFloat(n),height:({y:t},{paddingTop:e="0",paddingBottom:n="0"})=>t.max-t.min-parseFloat(e)-parseFloat(n),top:(t,{top:e})=>parseFloat(e),left:(t,{left:e})=>parseFloat(e),bottom:({y:t},{top:e})=>parseFloat(e)+(t.max-t.min),right:({x:t},{left:e})=>parseFloat(e)+(t.max-t.min),x:(t,{transform:e})=>cc(e,"x"),y:(t,{transform:e})=>cc(e,"y")};ii.translateX=ii.x,ii.translateY=ii.y;const si=new Set;let fc=!1,dc=!1,hc=!1;function Fg(){if(dc){const t=Array.from(si).filter(i=>i.needsMeasurement),e=new Set(t.map(i=>i.element)),n=new Map;e.forEach(i=>{const o=VN(i);o.length&&(n.set(i,o),i.render())}),t.forEach(i=>i.measureInitialState()),e.forEach(i=>{i.render();const o=n.get(i);o&&o.forEach(([a,u])=>{i.getValue(a)?.set(u)})}),t.forEach(i=>i.measureEndState()),t.forEach(i=>{i.suspendedScrollY!==void 0&&window.scrollTo(0,i.suspendedScrollY)})}dc=!1,fc=!1,si.forEach(t=>t.complete(hc)),si.clear()}function Qg(){si.forEach(t=>{t.readKeyframes(),t.needsMeasurement&&(dc=!0)})}function PN(){hc=!0,Qg(),Fg(),hc=!1}class pc{constructor(e,n,i,o,a,u=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...e],this.onComplete=n,this.name=i,this.motionValue=o,this.element=a,this.isAsync=u}scheduleResolve(){this.state="scheduled",this.isAsync?(si.add(this),fc||(fc=!0,Et.read(Qg),Et.resolveKeyframes(Fg))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:e,name:n,element:i,motionValue:o}=this;if(e[0]===null){const a=o?.get(),u=e[e.length-1];if(a!==void 0)e[0]=a;else if(i&&n){const c=i.readValue(n,u);c!=null&&(e[0]=c)}e[0]===void 0&&(e[0]=u),o&&a===void 0&&o.set(e[0])}kN(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),si.delete(this)}cancel(){this.state==="scheduled"&&(si.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const BN=t=>t.startsWith("--");function FN(t,e,n){BN(e)?t.style.setProperty(e,n):t.style[e]=n}const QN=Vu(()=>window.ScrollTimeline!==void 0),YN={};function qN(t,e){const n=Vu(t);return()=>YN[e]??n()}const Yg=qN(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),Is=([t,e,n,i])=>`cubic-bezier(${t}, ${e}, ${n}, ${i})`,qg={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:Is([0,.65,.55,1]),circOut:Is([.55,0,1,.45]),backIn:Is([.31,.01,.66,-.59]),backOut:Is([.33,1.53,.69,.99])};function Wg(t,e){if(t)return typeof t=="function"?Yg()?Lg(t,e):"ease-out":yg(t)?Is(t):Array.isArray(t)?t.map(n=>Wg(n,e)||qg.easeOut):qg[t]}function WN(t,e,n,{delay:i=0,duration:o=300,repeat:a=0,repeatType:u="loop",ease:c="easeOut",times:d}={},h=void 0){const p={[e]:n};d&&(p.offset=d);const m=Wg(c,o);Array.isArray(m)&&(p.easing=m);const w={delay:i,duration:o,easing:Array.isArray(m)?"linear":m,fill:"both",iterations:a+1,direction:u==="reverse"?"alternate":"normal"};return h&&(w.pseudoElement=h),t.animate(p,w)}function _g(t){return typeof t=="function"&&"applyToOptions"in t}function _N({type:t,...e}){return _g(t)&&Yg()?t.applyToOptions(e):(e.duration??(e.duration=300),e.ease??(e.ease="easeOut"),e)}class KN extends sc{constructor(e){if(super(),this.finishedTime=null,this.isStopped=!1,!e)return;const{element:n,name:i,keyframes:o,pseudoElement:a,allowFlatten:u=!1,finalKeyframe:c,onComplete:d}=e;this.isPseudoElement=!!a,this.allowFlatten=u,this.options=e,mr(typeof e.type!="string",`Mini animate() doesn't support "type" as a string.`,"mini-spring");const h=_N(e);this.animation=WN(n,i,o,h,a),h.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!a){const p=ic(o,this.options,c,this.speed);this.updateMotionValue?this.updateMotionValue(p):FN(n,i,p),this.animation.cancel()}d?.(),this.notifyFinished()}}play(){this.isStopped||(this.animation.play(),this.state==="finished"&&this.updateFinished())}pause(){this.animation.pause()}complete(){this.animation.finish?.()}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;const{state:e}=this;e==="idle"||e==="finished"||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){this.isPseudoElement||this.animation.commitStyles?.()}get duration(){const e=this.animation.effect?.getComputedTiming?.().duration||0;return On(Number(e))}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+On(e)}get time(){return On(Number(this.animation.currentTime)||0)}set time(e){this.finishedTime=null,this.animation.currentTime=Jn(e)}get speed(){return this.animation.playbackRate}set speed(e){e<0&&(this.finishedTime=null),this.animation.playbackRate=e}get state(){return this.finishedTime!==null?"finished":this.animation.playState}get startTime(){return Number(this.animation.startTime)}set startTime(e){this.animation.startTime=e}attachTimeline({timeline:e,observe:n}){return this.allowFlatten&&this.animation.effect?.updateTiming({easing:"linear"}),this.animation.onfinish=null,e&&QN()?(this.animation.timeline=e,Ln):n(this)}}const Kg={anticipate:hg,backInOut:dg,circInOut:gg};function HN(t){return t in Kg}function JN(t){typeof t.ease=="string"&&HN(t.ease)&&(t.ease=Kg[t.ease])}const Hg=10;class GN extends KN{constructor(e){JN(e),jg(e),super(e),e.startTime&&(this.startTime=e.startTime),this.options=e}updateMotionValue(e){const{motionValue:n,onUpdate:i,onComplete:o,element:a,...u}=this.options;if(!n)return;if(e!==void 0){n.set(e);return}const c=new oc({...u,autoplay:!1}),d=Jn(this.finishedTime??this.time);n.setWithVelocity(c.sample(d-Hg).value,c.sample(d).value,Hg),c.stop()}}const Jg=(t,e)=>e==="zIndex"?!1:!!(typeof t=="number"||Array.isArray(t)||typeof t=="string"&&(Or.test(t)||t==="0")&&!t.startsWith("url("));function ZN(t){const e=t[0];if(t.length===1)return!0;for(let n=0;n<t.length;n++)if(t[n]!==e)return!0}function XN(t,e,n,i){const o=t[0];if(o===null)return!1;if(e==="display"||e==="visibility")return!0;const a=t[t.length-1],u=Jg(o,e),c=Jg(a,e);return Ii(u===c,`You are trying to animate ${e} from "${o}" to "${a}". "${u?a:o}" is not an animatable value.`,"value-not-animatable"),!u||!c?!1:ZN(t)||(n==="spring"||_g(n))&&i}function gc(t){t.duration=0,t.type="keyframes"}const $N=new Set(["opacity","clipPath","filter","transform"]),eD=Vu(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function tD(t){const{motionValue:e,name:n,repeatDelay:i,repeatType:o,damping:a,type:u}=t;if(!(e?.owner?.current instanceof HTMLElement))return!1;const{onUpdate:d,transformTemplate:h}=e.owner.getProps();return eD()&&n&&$N.has(n)&&(n!=="transform"||!h)&&!d&&!i&&o!=="mirror"&&a!==0&&u!=="inertia"}const nD=40;class rD extends sc{constructor({autoplay:e=!0,delay:n=0,type:i="keyframes",repeat:o=0,repeatDelay:a=0,repeatType:u="loop",keyframes:c,name:d,motionValue:h,element:p,...m}){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=hn.now();const w={autoplay:e,delay:n,type:i,repeat:o,repeatDelay:a,repeatType:u,name:d,motionValue:h,element:p,...m},y=p?.KeyframeResolver||pc;this.keyframeResolver=new y(c,(b,S,P)=>this.onKeyframesResolved(b,S,w,!P),d,h,p),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(e,n,i,o){this.keyframeResolver=void 0;const{name:a,type:u,velocity:c,delay:d,isHandoff:h,onUpdate:p}=i;this.resolvedAt=hn.now(),XN(e,a,u,c)||((yr.instantAnimations||!d)&&p?.(ic(e,i,n)),e[0]=e[e.length-1],gc(i),i.repeat=0);const w={startTime:o?this.resolvedAt?this.resolvedAt-this.createdAt>nD?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...i,keyframes:e},y=!h&&tD(w)?new GN({...w,element:w.motionValue.owner.current}):new oc(w);y.finished.then(()=>this.notifyFinished()).catch(Ln),this.pendingTimeline&&(this.stopTimeline=y.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=y}get finished(){return this._animation?this.animation.finished:this._finished}then(e,n){return this.finished.finally(e).then(()=>{})}get animation(){return this._animation||(this.keyframeResolver?.resume(),PN()),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(e){this.animation.time=e}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(e){this.animation.speed=e}get startTime(){return this.animation.startTime}attachTimeline(e){return this._animation?this.stopTimeline=this.animation.attachTimeline(e):this.pendingTimeline=e,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){this._animation&&this.animation.cancel(),this.keyframeResolver?.cancel()}}const iD=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function sD(t){const e=iD.exec(t);if(!e)return[,];const[,n,i,o]=e;return[`--${n??i}`,o]}const oD=4;function Gg(t,e,n=1){mr(n<=oD,`Max CSS variable fallback depth detected in property "${t}". This may indicate a circular fallback dependency.`,"max-css-var-depth");const[i,o]=sD(t);if(!i)return;const a=window.getComputedStyle(e).getPropertyValue(i);if(a){const u=a.trim();return rg(u)?parseFloat(u):u}return Wu(o)?Gg(o,e,n+1):o}function mc(t,e){return t?.[e]??t?.default??t}const Zg=new Set(["width","height","top","left","right","bottom",...Li]),aD={test:t=>t==="auto",parse:t=>t},Xg=t=>e=>e.test(t),$g=[Ci,Ie,ar,Lr,GS,JS,aD],em=t=>$g.find(Xg(t));function lD(t){return typeof t=="number"?t===0:t!==null?t==="none"||t==="0"||sg(t):!0}const uD=new Set(["brightness","contrast","saturate","opacity"]);function cD(t){const[e,n]=t.slice(0,-1).split("(");if(e==="drop-shadow")return t;const[i]=n.match(_u)||[];if(!i)return t;const o=n.replace(i,"");let a=uD.has(e)?1:0;return i!==n&&(a*=100),e+"("+a+o+")"}const fD=/\b([a-z-]*)\(.*?\)/gu,yc={...Or,getAnimatableNone:t=>{const e=t.match(fD);return e?e.map(cD).join(" "):t}},tm={...Ci,transform:Math.round},vc={borderWidth:Ie,borderTopWidth:Ie,borderRightWidth:Ie,borderBottomWidth:Ie,borderLeftWidth:Ie,borderRadius:Ie,radius:Ie,borderTopLeftRadius:Ie,borderTopRightRadius:Ie,borderBottomRightRadius:Ie,borderBottomLeftRadius:Ie,width:Ie,maxWidth:Ie,height:Ie,maxHeight:Ie,top:Ie,right:Ie,bottom:Ie,left:Ie,padding:Ie,paddingTop:Ie,paddingRight:Ie,paddingBottom:Ie,paddingLeft:Ie,margin:Ie,marginTop:Ie,marginRight:Ie,marginBottom:Ie,marginLeft:Ie,backgroundPositionX:Ie,backgroundPositionY:Ie,...{rotate:Lr,rotateX:Lr,rotateY:Lr,rotateZ:Lr,scale:$o,scaleX:$o,scaleY:$o,scaleZ:$o,skew:Lr,skewX:Lr,skewY:Lr,distance:Ie,translateX:Ie,translateY:Ie,translateZ:Ie,x:Ie,y:Ie,z:Ie,perspective:Ie,transformPerspective:Ie,opacity:bs,originX:Eg,originY:Eg,originZ:Ie},zIndex:tm,fillOpacity:bs,strokeOpacity:bs,numOctaves:tm},dD={...vc,color:Bt,backgroundColor:Bt,outlineColor:Bt,fill:Bt,stroke:Bt,borderColor:Bt,borderTopColor:Bt,borderRightColor:Bt,borderBottomColor:Bt,borderLeftColor:Bt,filter:yc,WebkitFilter:yc},nm=t=>dD[t];function rm(t,e){let n=nm(t);return n!==yc&&(n=Or),n.getAnimatableNone?n.getAnimatableNone(e):void 0}const hD=new Set(["auto","none","0"]);function pD(t,e,n){let i=0,o;for(;i<t.length&&!o;){const a=t[i];typeof a=="string"&&!hD.has(a)&&Ds(a).values.length&&(o=t[i]),i++}if(o&&n)for(const a of e)t[a]=rm(n,o)}class gD extends pc{constructor(e,n,i,o,a){super(e,n,i,o,a,!0)}readKeyframes(){const{unresolvedKeyframes:e,element:n,name:i}=this;if(!n||!n.current)return;super.readKeyframes();for(let d=0;d<e.length;d++){let h=e[d];if(typeof h=="string"&&(h=h.trim(),Wu(h))){const p=Gg(h,n.current);p!==void 0&&(e[d]=p),d===e.length-1&&(this.finalKeyframe=h)}}if(this.resolveNoneKeyframes(),!Zg.has(i)||e.length!==2)return;const[o,a]=e,u=em(o),c=em(a);if(u!==c)if(Bg(u)&&Bg(c))for(let d=0;d<e.length;d++){const h=e[d];typeof h=="string"&&(e[d]=parseFloat(h))}else ii[i]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:e,name:n}=this,i=[];for(let o=0;o<e.length;o++)(e[o]===null||lD(e[o]))&&i.push(o);i.length&&pD(e,i,n)}measureInitialState(){const{element:e,unresolvedKeyframes:n,name:i}=this;if(!e||!e.current)return;i==="height"&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=ii[i](e.measureViewportBox(),window.getComputedStyle(e.current)),n[0]=this.measuredOrigin;const o=n[n.length-1];o!==void 0&&e.getValue(i,o).jump(o,!1)}measureEndState(){const{element:e,name:n,unresolvedKeyframes:i}=this;if(!e||!e.current)return;const o=e.getValue(n);o&&o.jump(this.measuredOrigin,!1);const a=i.length-1,u=i[a];i[a]=ii[n](e.measureViewportBox(),window.getComputedStyle(e.current)),u!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=u),this.removedTransforms?.length&&this.removedTransforms.forEach(([c,d])=>{e.getValue(c).set(d)}),this.resolveNoneKeyframes()}}function mD(t,e,n){if(t instanceof EventTarget)return[t];if(typeof t=="string"){let i=document;const o=n?.[t]??i.querySelectorAll(t);return o?Array.from(o):[]}return Array.from(t)}const im=(t,e)=>e&&typeof t=="number"?e.transform(t):t;function sm(t){return ig(t)&&"offsetHeight"in t}var yD={env:{}};const om=30,vD=t=>!isNaN(parseFloat(t));class MD{constructor(e,n={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=i=>{const o=hn.now();if(this.updatedAt!==o&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(i),this.current!==this.prev&&(this.events.change?.notify(this.current),this.dependents))for(const a of this.dependents)a.dirty()},this.hasAnimated=!1,this.setCurrent(e),this.owner=n.owner}setCurrent(e){this.current=e,this.updatedAt=hn.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=vD(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return yD.env.NODE_ENV!=="production"&&Bu(!1,'value.onChange(callback) is deprecated. Switch to value.on("change", callback).'),this.on("change",e)}on(e,n){this.events[e]||(this.events[e]=new Pu);const i=this.events[e].add(n);return e==="change"?()=>{i(),Et.read(()=>{this.events.change.getSize()||this.stop()})}:i}clearListeners(){for(const e in this.events)this.events[e].clear()}attach(e,n){this.passiveEffect=e,this.stopPassiveEffect=n}set(e){this.passiveEffect?this.passiveEffect(e,this.updateAndNotify):this.updateAndNotify(e)}setWithVelocity(e,n,i){this.set(n),this.prev=void 0,this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt-i}jump(e,n=!0){this.updateAndNotify(e),this.prev=e,this.prevUpdatedAt=this.prevFrameValue=void 0,n&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){this.events.change?.notify(this.current)}addDependent(e){this.dependents||(this.dependents=new Set),this.dependents.add(e)}removeDependent(e){this.dependents&&this.dependents.delete(e)}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const e=hn.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>om)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,om);return og(parseFloat(this.current)-parseFloat(this.prevFrameValue),n)}start(e){return this.stop(),new Promise(n=>{this.hasAnimated=!0,this.animation=e(n),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.dependents?.clear(),this.events.destroy?.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function Ri(t,e){return new MD(t,e)}const{schedule:Mc}=wg(queueMicrotask,!1),Gn={x:!1,y:!1};function am(){return Gn.x||Gn.y}function wD(t){return t==="x"||t==="y"?Gn[t]?null:(Gn[t]=!0,()=>{Gn[t]=!1}):Gn.x||Gn.y?null:(Gn.x=Gn.y=!0,()=>{Gn.x=Gn.y=!1})}function lm(t,e){const n=mD(t),i=new AbortController,o={passive:!0,...e,signal:i.signal};return[n,o,()=>i.abort()]}function um(t){return!(t.pointerType==="touch"||am())}function xD(t,e,n={}){const[i,o,a]=lm(t,n),u=c=>{if(!um(c))return;const{target:d}=c,h=e(d,c);if(typeof h!="function"||!d)return;const p=m=>{um(m)&&(h(m),d.removeEventListener("pointerleave",p))};d.addEventListener("pointerleave",p,o)};return i.forEach(c=>{c.addEventListener("pointerenter",u,o)}),a}const cm=(t,e)=>e?t===e?!0:cm(t,e.parentElement):!1,wc=t=>t.pointerType==="mouse"?typeof t.button!="number"||t.button<=0:t.isPrimary!==!1,TD=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function ED(t){return TD.has(t.tagName)||t.tabIndex!==-1}const ra=new WeakSet;function fm(t){return e=>{e.key==="Enter"&&t(e)}}function xc(t,e){t.dispatchEvent(new PointerEvent("pointer"+e,{isPrimary:!0,bubbles:!0}))}const AD=(t,e)=>{const n=t.currentTarget;if(!n)return;const i=fm(()=>{if(ra.has(n))return;xc(n,"down");const o=fm(()=>{xc(n,"up")}),a=()=>xc(n,"cancel");n.addEventListener("keyup",o,e),n.addEventListener("blur",a,e)});n.addEventListener("keydown",i,e),n.addEventListener("blur",()=>n.removeEventListener("keydown",i),e)};function dm(t){return wc(t)&&!am()}function bD(t,e,n={}){const[i,o,a]=lm(t,n),u=c=>{const d=c.currentTarget;if(!dm(c))return;ra.add(d);const h=e(d,c),p=(y,b)=>{window.removeEventListener("pointerup",m),window.removeEventListener("pointercancel",w),ra.has(d)&&ra.delete(d),dm(y)&&typeof h=="function"&&h(y,{success:b})},m=y=>{p(y,d===window||d===document||n.useGlobalTarget||cm(d,y.target))},w=y=>{p(y,!1)};window.addEventListener("pointerup",m,o),window.addEventListener("pointercancel",w,o)};return i.forEach(c=>{(n.useGlobalTarget?window:c).addEventListener("pointerdown",u,o),sm(c)&&(c.addEventListener("focus",h=>AD(h,o)),!ED(c)&&!c.hasAttribute("tabindex")&&(c.tabIndex=0))}),a}function hm(t){return ig(t)&&"ownerSVGElement"in t}function SD(t){return hm(t)&&t.tagName==="svg"}const nn=t=>!!(t&&t.getVelocity),ND=[...$g,Bt,Or],DD=t=>ND.find(Xg(t)),Tc=x.createContext({transformPagePoint:t=>t,isStatic:!1,reducedMotion:"never"});function pm(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function ID(...t){return e=>{let n=!1;const i=t.map(o=>{const a=pm(o,e);return!n&&typeof a=="function"&&(n=!0),a});if(n)return()=>{for(let o=0;o<i.length;o++){const a=i[o];typeof a=="function"?a():pm(t[o],null)}}}}function CD(...t){return eo.useCallback(ID(...t),t)}class kD extends eo.Component{getSnapshotBeforeUpdate(e){const n=this.props.childRef.current;if(n&&e.isPresent&&!this.props.isPresent){const i=n.offsetParent,o=sm(i)&&i.offsetWidth||0,a=this.props.sizeRef.current;a.height=n.offsetHeight||0,a.width=n.offsetWidth||0,a.top=n.offsetTop,a.left=n.offsetLeft,a.right=o-a.width-a.left}return null}componentDidUpdate(){}render(){return this.props.children}}function zD({children:t,isPresent:e,anchorX:n,root:i}){const o=x.useId(),a=x.useRef(null),u=x.useRef({width:0,height:0,top:0,left:0,right:0}),{nonce:c}=x.useContext(Tc),d=CD(a,t?.ref);return x.useInsertionEffect(()=>{const{width:h,height:p,top:m,left:w,right:y}=u.current;if(e||!a.current||!h||!p)return;const b=n==="left"?`left: ${w}`:`right: ${y}`;a.current.dataset.motionPopId=o;const S=document.createElement("style");c&&(S.nonce=c);const P=i??document.head;return P.appendChild(S),S.sheet&&S.sheet.insertRule(`
|
|
346
346
|
[data-motion-pop-id="${o}"] {
|
|
347
347
|
position: absolute !important;
|
|
348
348
|
width: ${h}px !important;
|