@sciol/xyzen 1.9.77-beta.dbae374 → 1.9.77-beta.f9561ad

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/xyzen.es.js CHANGED
@@ -7878,7 +7878,12 @@ function wJn(t, e) {
7878
7878
  t.messages[n].attachments || (t.messages[n].attachments = []);
7879
7879
  const i = t.messages[n].attachments || [], o = e.files.filter(
7880
7880
  (l) => !i.some((u) => u.id === l.id)
7881
- );
7881
+ ).map((l) => ({
7882
+ ...l,
7883
+ // Normalize to stable API download path — presigned URLs from the
7884
+ // streaming event expire after 1 hour and break cached images.
7885
+ download_url: `/xyzen/api/v1/files/${l.id}/download`
7886
+ }));
7882
7887
  t.messages[n].attachments = [
7883
7888
  ...i,
7884
7889
  ...o
package/dist/xyzen.umd.js CHANGED
@@ -106,7 +106,7 @@ border-radius:50%;animation:spin .8s linear infinite;margin:0 auto}
106
106
  `)){if(o.startsWith(":"))continue;const l=o.indexOf(":");if(l===-1)continue;const u=o.slice(0,l),d=o.slice(l+1).trimStart();switch(u){case"id":i.id=d;break;case"event":i.event=d;break;case"data":i.data=i.data?`${i.data}
107
107
  ${d}`:d;break}}(i.data!==void 0||i.event!==void 0)&&(yield{event:i,remaining:e})}yield{event:{},remaining:e}}class hOn{connections=new Map;retryTimeouts=new Map;constructor(){setTimeout(()=>{try{Ed().visibility.onVisible(()=>{this._retryAllPending()})}catch{typeof document<"u"&&document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"&&this._retryAllPending()})}},0)}_retryAllPending(){for(const[e,n]of this.retryTimeouts){clearTimeout(n),this.retryTimeouts.delete(e);const r=this.connections.get(e);r&&(r.retryCount=0,r.controller=new AbortController,this._startStream(r))}}get baseUrl(){const e=Ed().env.backendUrl;return(!e||e==="")&&typeof window<"u"?`${window.location.protocol}//${window.location.host}`:e}connect(e,n){this.disconnect(e);const r=new AbortController,i={topicId:e,controller:r,lastEventId:null,retryCount:0,callbacks:n};this.connections.set(e,i),this._startStream(i)}disconnect(e){const n=this.connections.get(e);n&&(n.controller.abort(),this.connections.delete(e));const r=this.retryTimeouts.get(e);r&&(clearTimeout(r),this.retryTimeouts.delete(e))}disconnectAll(){for(const e of[...this.connections.keys()])this.disconnect(e)}getOpenTopicIds(){return[...this.connections.keys()]}hasConnection(e){return this.connections.has(e)}updateCallbacks(e,n){const r=this.connections.get(e);return r?(r.callbacks=n,!0):!1}async _startStream(e){const{topicId:n,controller:r,callbacks:i}=e,o=Eo.getToken();if(!o){i.onStatusChange({connected:!1,error:"Authentication required"});return}const l={Authorization:`Bearer ${o}`,Accept:"text/event-stream"};e.lastEventId&&(l["Last-Event-ID"]=e.lastEventId);const u=`${this.baseUrl}/xyzen/api/v1/topics/${n}/events`;try{const d=Ed().streamingFetch,p=await d(u,{headers:l,signal:r.signal});if(!p.ok){if(p.status===401){Eo.removeToken(),i.onStatusChange({connected:!1,error:"Authentication failed"}),l5n();return}throw new Error(`SSE HTTP ${p.status}`)}if(!p.body)throw new Error("SSE response has no body");e.retryCount=0,i.onStatusChange({connected:!0});const m=p.body.getReader(),g=new TextDecoder;let h="";for(;;){const{done:f,value:b}=await m.read();if(f)break;h+=g.decode(b,{stream:!0});let y=h;for(const{event:v,remaining:_}of gOn(h))if(y=_,v.data!==void 0){v.id&&(e.lastEventId=v.id);try{const w=JSON.parse(v.data),x=v.event||w.type||"message";i.onMessageEvent({type:x,data:w.data!==void 0?w.data:w})}catch{console.warn("SSE: failed to parse event data",v.data)}}h=y}this._handleDisconnect(e)}catch(d){if(r.signal.aborted)return;console.error(`SSE error for topic ${n}:`,d),this._handleDisconnect(e)}}_handleDisconnect(e){const{topicId:n,callbacks:r}=e;if(this.connections.get(n)!==e)return;if(r.onStatusChange({connected:!1}),e.retryCount>=dOn){r.onStatusChange({connected:!1,error:"Connection closed. Please refresh the page."}),this.connections.delete(n);return}const i=Math.min(pOn*Math.pow(2,e.retryCount),mOn);e.retryCount++,e.controller=new AbortController;const o=setTimeout(()=>{this.retryTimeouts.delete(n),this.connections.get(n)===e&&this._startStream(e)},i);this.retryTimeouts.set(n,o)}}const Qb=new hOn;class fOn{async createTopic(e){return on.post("/xyzen/api/v1/topics/",e)}async updateTopic(e,n){return on.put(`/xyzen/api/v1/topics/${e}`,n)}async deleteTopic(e){return on.delete(`/xyzen/api/v1/topics/${e}`)}async getMessages(e,n){const r=new URLSearchParams;n?.before&&r.set("before",n.before),n?.limit&&r.set("limit",String(n.limit));const i=r.toString();return on.get(`/xyzen/api/v1/topics/${e}/messages${i?`?${i}`:""}`)}async getMessageNav(e){return on.get(`/xyzen/api/v1/topics/${e}/message-nav`)}async getTokenStats(e){return on.get(`/xyzen/api/v1/topics/${e}/token-stats`)}async compactTopic(e,n){return on.post(`/xyzen/api/v1/topics/${e}/compact`,n?{up_to_message_id:n}:{})}async sendMessage(e,n){return on.post(`/xyzen/api/v1/topics/${e}/messages`,n)}async abort(e){return on.post(`/xyzen/api/v1/topics/${e}/abort`)}async regenerate(e){return on.post(`/xyzen/api/v1/topics/${e}/regenerate`)}async answerQuestion(e,n){return on.post(`/xyzen/api/v1/topics/${e}/question-response`,n)}}const dg=new fOn,ix=787,qv="Asia/Shanghai",zxe=576,Uxe=640,SN="app.chatConfig.defaultTitle",sot="/workspace";class AOn{getProviderDisplayName(e){return{openai:"OpenAI",azure_openai:"Azure OpenAI",google:"Google",google_vertex:"Google Vertex AI"}[e]||e}async getProviderTemplates(){const e=await on.get("/xyzen/api/v1/providers/templates",{auth:!1});return Object.entries(e).map(([n,r])=>({type:n,display_name:this.getProviderDisplayName(n),models:r}))}async getSupportedModels(){return on.get("/xyzen/api/v1/providers/models",{auth:!1})}async getAvailableModels(){return on.get("/xyzen/api/v1/providers/available-models")}async getTierModels(){return on.get("/xyzen/api/v1/providers/tier-models")}async getDefaultModelConfig(){return on.get("/xyzen/api/v1/providers/default-model",{auth:!1})}async getMyProviders(){return on.get("/xyzen/api/v1/providers/me")}async getSystemProviders(){return on.get("/xyzen/api/v1/providers/system")}async createProvider(e){return on.post("/xyzen/api/v1/providers/",e)}async getProvider(e){return on.get(`/xyzen/api/v1/providers/${e}`)}async updateProvider(e,n){return on.patch(`/xyzen/api/v1/providers/${e}`,n)}async deleteProvider(e){return on.delete(`/xyzen/api/v1/providers/${e}`)}}const N7=new AOn;class bOn{defaultModelConfig=null;defaultModelConfigPromise=null;async getDefaultModelConfig(){return this.defaultModelConfig?this.defaultModelConfig:this.defaultModelConfigPromise?this.defaultModelConfigPromise:(this.defaultModelConfigPromise=N7.getDefaultModelConfig().then(e=>(this.defaultModelConfig=e,this.defaultModelConfigPromise=null,e)).catch(e=>{throw console.error("Failed to fetch default model config:",e),this.defaultModelConfigPromise=null,e}),this.defaultModelConfigPromise)}async getDefaultSystemProviderId(e){try{const n=await this.getDefaultModelConfig();return e.find(i=>i.provider_type===n.provider_type&&i.is_system)?.id||null}catch(n){return console.error("Failed to get default system provider:",n),null}}async getDefaultModelName(){try{return(await this.getDefaultModelConfig()).key}catch(e){return console.error("Failed to get default model name:",e),null}}async getDefaultProviderAndModel(e){try{const n=await this.getDefaultModelConfig(),r={openai:"openai",azure:"azure_openai",google:"google",vertex_ai:"google_vertex","vertex_ai-language-models":"google_vertex"};let i=e.find(o=>o.provider_type===n.provider_type);if(!i&&n.litellm_provider){const o=r[n.litellm_provider];o&&(i=e.find(l=>l.provider_type===o))}return i?{providerId:i.id,model:n.key}:(console.error("No matching provider found for default model"),{providerId:null,model:null})}catch(n){return console.error("Failed to get default provider and model:",n),{providerId:null,model:null}}}clearCache(){this.defaultModelConfig=null,this.defaultModelConfigPromise=null}}const lot=new bOn,A1=new Map,NP=new Set,yOn=5e3,vOn=100;function cot(t){Qb.disconnect(t);const e=A1.get(t);e&&(clearTimeout(e),A1.delete(t))}function _On(t,e,n){const{reconcileChannelFromBackend:r,getAgentNameById:i,waitForChannelConnection:o}=n;return{setActiveChatChannel:l=>t({activeChatChannel:l}),fetchChatHistory:async()=>{const{setLoading:l}=e();l("chatHistory",!0);try{const u=await Np.getSessions(),d=e().channels,p={...d},m=Object.entries(d).filter(([,h])=>h.responding).map(([h,f])=>`${h.slice(0,8)}(msgs=${f.messages.length})`);m.length>0&&console.warn("[fetchChatHistory] DANGER: overwriting channels while responding:",m.join(", "));const g=u.flatMap(h=>h.topics?.map(f=>(p[f.id]?p[f.id]={...p[f.id],sessionId:h.id,title:f.name,agentId:h.agent_id}:p[f.id]={id:f.id,sessionId:h.id,title:f.name,messages:[],agentId:h.agent_id,provider_id:h.provider_id,model:h.model,model_tier:h.model_tier,knowledge_set_id:h.knowledge_set_id,sandbox_backend:h.sandbox_backend,connected:!1,error:null},{id:f.id,sessionId:h.id,title:f.name,updatedAt:f.updated_at,assistantTitle:i(h.agent_id),lastMessage:"",isPinned:f.is_pinned??!1}))||[]);t(h=>{h.chatHistory=g,h.chatHistoryLoading=!1;for(const[f,b]of Object.entries(p)){const y=h.channels[f];if(!y)h.channels[f]=b;else{if(y.responding)continue;y.sessionId=b.sessionId,y.title=b.title,y.agentId=b.agentId,b.provider_id!==void 0&&(y.provider_id=b.provider_id),b.model!==void 0&&(y.model=b.model),b.model_tier!==void 0&&(y.model_tier=b.model_tier),b.knowledge_set_id!==void 0&&(y.knowledge_set_id=b.knowledge_set_id),b.sandbox_backend!==void 0&&(y.sandbox_backend=b.sandbox_backend)}}})}catch(u){console.error("ChatSlice: Failed to fetch chat history:",u),t({chatHistoryLoading:!1})}finally{e().setLoading("chatHistory",!1)}},togglePinChat:l=>{const u=e().chatHistory.find(p=>p.id===l);if(!u)return;const d=!u.isPinned;t(p=>{const m=p.chatHistory.find(g=>g.id===l);m&&(m.isPinned=d)}),dg.updateTopic(l,{is_pinned:d}).catch(p=>{console.error("Failed to persist pin state:",p),t(m=>{const g=m.chatHistory.find(h=>h.id===l);g&&(g.isPinned=!d)})})},activateChannel:async l=>{const{channels:u,activeChatChannel:d,connectToChannel:p}=e();if(console.debug(`[activateChannel] topic=${l.slice(0,8)} current=${d?.slice(0,8)} connected=${u[l]?.connected} msgs=${u[l]?.messages.length} responding=${u[l]?.responding}`),l===d&&u[l]?.connected){console.debug("[activateChannel] SKIP (already active & connected)");return}const m=u[l];m?.agentId&&t(h=>{h.activeTopicByAgent[m.agentId]=l});let g=u[l];if(!g)try{const h=await Np.getSessionByTopic(l),f=h.topics.find(E=>E.id===l),b=h.id,y=f?.name??null,v=h.agent_id,_=h.provider_id,w=h.model,x=h.model_tier,k=h.knowledge_set_id,C=h.sandbox_backend;if(y)g={id:l,sessionId:b,title:y,messages:[],agentId:v,provider_id:_,model:w,model_tier:x,knowledge_set_id:k,sandbox_backend:C,connected:!1,error:null},t(E=>{E.channels[l]=g});else{console.error(`Topic ${l} not found in any session, refetching history...`),await e().fetchChatHistory();const E=e().channels;if(E[l])g=E[l];else{console.error(`Topic ${l} still not found after refetch.`);return}}}catch(h){console.error("Failed to find session for topic:",h);return}if(g){if(t({activeChatChannel:l}),Qb.hasConnection(l))console.debug("[activateChannel] hasLiveWs, skipping reconcile");else{const f=g.messages.some(b=>b.status==="pending"||b.status==="streaming"||b.status==="thinking");console.debug(`[activateChannel] noLiveWs, msgs=${g.messages.length} stale=${f} → ${g.messages.length===0||f?"RECONCILE":"SKIP"}`),(g.messages.length===0||f)&&await r(l)}p(g.sessionId,g.id),await o(l,{logFailure:!0})}},activateChannelForAgent:async l=>{const u=`activate:${l}`;if(!NP.has(u)){NP.add(u);try{try{const d=await Np.getSessionByAgent(l);if(d.topics&&d.topics.length>0){const p=d.topics[0],m={id:p.id,sessionId:d.id,title:p.name,messages:[],agentId:d.agent_id,provider_id:d.provider_id,model:d.model,model_tier:d.model_tier,knowledge_set_id:d.knowledge_set_id,sandbox_backend:d.sandbox_backend,connected:!1,error:null};t(g=>{const h=g.channels[p.id];g.channels[p.id]=not(h,m)}),await e().activateChannel(p.id)}else{const p=await dg.createTopic({name:to.t(SN),session_id:d.id}),m={id:p.id,sessionId:d.id,title:p.name,messages:[],agentId:d.agent_id,provider_id:d.provider_id,model:d.model,model_tier:d.model_tier,knowledge_set_id:d.knowledge_set_id,sandbox_backend:d.sandbox_backend,connected:!1,error:null};t(g=>{g.channels[p.id]=m}),await e().activateChannel(p.id)}}catch(d){d instanceof cg&&d.status===404?await e().createDefaultChannel(l):(console.error("Failed to activate channel for agent:",d),await e().createDefaultChannel(l))}}finally{NP.delete(u)}}},createDefaultChannel:async l=>{const u=l||e().rootAgentId;if(!u){console.error("createDefaultChannel: no agentId and rootAgentId not loaded");return}const d=`create:${u}`;if(!NP.has(d)){NP.add(d);try{const p=u;let m;try{m=await Np.getSessionByAgent(p)}catch(y){if(y instanceof cg&&y.status===404)m=null;else throw y}if(m){if(!m.provider_id||!m.model){console.log(" - Existing session missing provider/model, updating with defaults...");try{const x=e().agents.find(E=>E.id===m.agent_id);let k=m.provider_id,C=m.model;if(x?.provider_id&&x?.model)k=x.provider_id,C=x.model;else{const E=await N7.getMyProviders(),S=await lot.getDefaultProviderAndModel(E);k=k||S.providerId||void 0,C=C||S.model||void 0}k&&C&&(await Np.updateSession(m.id,{provider_id:k,model:C}),m.provider_id=k,m.model=C,console.log(` - Updated session with provider (${k}) and model (${C})`))}catch(w){console.warn(" - Failed to update session with defaults:",w)}}const y=await dg.createTopic({name:to.t(SN),session_id:m.id}),v={id:y.id,sessionId:m.id,title:y.name,messages:[],agentId:m.agent_id,provider_id:m.provider_id,model:m.model,model_tier:m.model_tier,knowledge_set_id:m.knowledge_set_id,sandbox_backend:m.sandbox_backend,connected:!1,error:null},_={id:y.id,sessionId:m.id,title:y.name,updatedAt:y.updated_at,assistantTitle:i(m.agent_id),lastMessage:"",isPinned:!1};t(w=>{w.channels[y.id]=v,w.chatHistory.unshift(_),w.activeChatChannel=y.id,w.activeTabIndex=1}),e().connectToChannel(m.id,y.id);return}const g=e().resolveAgent(u),h={name:"New Session",agent_id:u};g?.mcp_servers?.length&&(h.mcp_server_ids=g.mcp_servers.map(y=>y.id));let f=[];try{f=await N7.getMyProviders()}catch(y){console.error("Failed to fetch providers:",y)}try{if(g?.provider_id&&g?.model)h.provider_id=g.provider_id,h.model=g.model;else{const{providerId:y,model:v}=await lot.getDefaultProviderAndModel(f);y&&v&&(h.provider_id=y,h.model=v)}}catch(y){console.error("Error getting provider/model:",y)}const b=await Np.createSession(h);if(b.topics&&b.topics.length>0){const y=b.topics[0],v={id:y.id,sessionId:b.id,title:y.name,messages:[],agentId:b.agent_id,provider_id:b.provider_id,model:b.model,model_tier:b.model_tier,connected:!1,error:null},_={id:y.id,sessionId:b.id,title:y.name,updatedAt:y.updated_at,assistantTitle:i(b.agent_id),lastMessage:"",isPinned:!1};t(w=>{w.channels[y.id]=v,w.chatHistory.unshift(_),w.activeChatChannel=y.id,w.activeTabIndex=1}),e().connectToChannel(b.id,y.id)}else{const y=await dg.createTopic({name:to.t(SN),session_id:b.id}),v={id:y.id,sessionId:b.id,title:y.name,messages:[],agentId:b.agent_id,provider_id:b.provider_id,model:b.model,model_tier:b.model_tier,connected:!1,error:null},_={id:y.id,sessionId:b.id,title:y.name,updatedAt:y.updated_at,assistantTitle:i(b.agent_id),lastMessage:"",isPinned:!1};t(w=>{w.channels[y.id]=v,w.chatHistory.unshift(_),w.activeChatChannel=y.id,w.activeTabIndex=1}),e().connectToChannel(b.id,y.id)}}catch(p){console.error("Failed to create channel:",p)}finally{NP.delete(d)}}},updateTopicName:async(l,u)=>{try{await dg.updateTopic(l,{name:u}),t(d=>{d.channels[l]&&(d.channels[l].title=u);const p=d.chatHistory.find(m=>m.id===l);p&&(p.title=u)}),console.log(`Topic ${l} name updated to: ${u}`)}catch(d){throw console.error("Failed to update topic name:",d),d}},deleteTopic:async l=>{try{await dg.deleteTopic(l),cot(l);const u=e().chatHistory,p=u.find(h=>h.id===l)?.sessionId,m=e().activeChatChannel===l,g=m?u.find(h=>h.id!==l&&h.sessionId===p)?.id??null:null;t(h=>{delete h.channels[l],h.chatHistory=h.chatHistory.filter(f=>f.id!==l),m&&(h.activeChatChannel=g)}),m&&g&&e().activateChannel(g),console.log(`Topic ${l} deleted`)}catch(u){throw console.error("Failed to delete topic:",u),u}},clearSessionTopics:async l=>{try{const u=e().channels;for(const[p,m]of Object.entries(u))m.sessionId===l&&cot(p);await Np.clearSessionTopics(l);const d=e().activeChatChannel;d&&u[d]?.sessionId===l&&t({activeChatChannel:null}),await e().fetchChatHistory(),console.log(`Session ${l} topics cleared`)}catch(u){console.error("Failed to clear session topics:",u)}},updateSessionConfig:async(l,u)=>{try{const d=await Np.updateSession(l,u);t(p=>{for(const m of Object.values(p.channels))m.sessionId===l&&(m.provider_id=d.provider_id,m.model=d.model,m.model_tier=d.model_tier,m.knowledge_set_id=d.knowledge_set_id,m.sandbox_backend=d.sandbox_backend)})}catch(d){console.error("Failed to update session config:",d),e().showNotification("Error","Failed to update session configuration","error")}},ensureChannelForTopic:async(l,u,d)=>{const{channels:p}=e();if(!p[l]){let m;try{m=await Np.getSessionByAgent(d)}catch{}const g={id:l,sessionId:u,title:"",messages:[],agentId:d,provider_id:m?.provider_id,model:m?.model,model_tier:m?.model_tier,knowledge_set_id:m?.knowledge_set_id,sandbox_backend:m?.sandbox_backend,connected:!1,error:null};t(h=>{const f=h.channels[l];h.channels[l]=not(f,g)})}await e().activateChannel(l)},updateSessionProviderAndModel:async(l,u,d)=>{try{await Np.updateSession(l,{provider_id:u,model:d}),t(p=>{const m=p.activeChatChannel;m&&p.channels[m]?.sessionId===l&&(p.channels[m].provider_id=u,p.channels[m].model=d),Object.keys(p.channels).forEach(g=>{p.channels[g].sessionId===l&&(p.channels[g].provider_id=u,p.channels[g].model=d)})})}catch(p){console.error("Failed to update session provider and model:",p),e().showNotification("Error","Failed to update model selection","error")}}}}class wOn{constructor(e){this.mutateChannel=e}buffer=[];rafId=null;pushStreaming(e,n,r){this.buffer.push({type:"streaming",id:e,content:n,execution_id:r}),this.scheduleFlush()}pushThinking(e,n){this.buffer.push({type:"thinking",id:e,content:n}),this.scheduleFlush()}flushSync(){this.buffer.length!==0&&(this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null),this.flush())}destroy(){this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null),this.buffer=[]}get hasPending(){return this.buffer.length>0}scheduleFlush(){this.rafId===null&&(this.rafId=requestAnimationFrame(()=>this.flush()))}flush(){if(this.rafId=null,this.buffer.length===0)return;const e=this.buffer;this.buffer=[],this.mutateChannel(n=>{for(const r of e)r.type==="streaming"?this.applyStreamingChunk(n,r):this.applyThinkingChunk(n,r);jxe(n)})}applyStreamingChunk(e,n){const r=ax(e,n.id,n.execution_id);if(r===-1){e.messages.push({id:n.id,streamId:n.id,clientId:EN(),role:"assistant",content:n.content,created_at:new Date().toISOString(),status:"streaming"});return}const i=e.messages[r];if(i.streamId=n.id,i.status="streaming",i.agentExecution&&i.agentExecution.phases.length>0){const o=i.agentExecution;let l=o.currentNode?o.phases.findLast(d=>d.nodeId===o.currentNode):null;l||(l=o.phases.findLast(d=>d.status==="running")),l||(l=o.phases[o.phases.length-1]);const u=l.streamedContent||"";u.length>100&&n.content.length>u.length&&n.content.startsWith(u.slice(0,100))?l.streamedContent=n.content:l.streamedContent=u+n.content}else{const o=i.content;e.messages[r].content=o+n.content}}applyThinkingChunk(e,n){let r=e.messages.findIndex(i=>i.id===n.id);if(r===-1&&(r=e.messages.findLastIndex(i=>i.status==="thinking"&&i.agentExecution?.status==="running")),r!==-1){const i=e.messages[r].thinkingContent??"";e.messages[r].thinkingContent=i+n.content}}}function xOn(t,e){if(t.responding=!0,ax(t,e)!==-1)return;CN(t)===-1&&t.messages.push({id:e,streamId:e,clientId:EN(),role:"assistant",content:"",created_at:new Date().toISOString(),status:"pending",isNewMessage:!0})}function kOn(t,e){t.responding=!0;let n=ax(t,e.stream_id,e.execution_id);if(n===-1&&(n=CN(t)),n!==-1){const r=t.messages[n];r.id=e.stream_id,r.streamId=e.stream_id,r.status="streaming",r.content||(r.content="");return}t.messages.push({id:e.stream_id,streamId:e.stream_id,clientId:EN(),role:"assistant",content:"",isNewMessage:!0,created_at:new Date().toISOString(),status:"streaming"})}function EOn(t,e){let n=ax(t,e.stream_id,e.execution_id);if(n===-1){const r=t.messages.map((i,o)=>i.status==="streaming"?o:-1).filter(i=>i!==-1);n=r.length===1?r[0]:-1}if(n!==-1){const r=t.messages[n];if(!r.content&&r.agentExecution&&r.agentExecution.phases.length>0){const i=r.agentExecution.phases.map(o=>o.streamedContent||"").filter(Boolean).join(`
108
108
 
109
- `);i&&(r.content=i)}r.agentExecution?.status==="running"||ate(r,{status:"completed",onlyIfRunning:!0}),r.created_at=e.created_at||new Date().toISOString(),console.debug("[ChatSlice] streaming_end: finalized message at index",n)}else console.warn("[ChatSlice] streaming_end: no message found to finalize")}function COn(t,e){t.messages.some(n=>n.id===e.id)||t.messages.push({...e,status:e.status||"completed",isNewMessage:!0})}function SOn(t,e){let n=ax(t,e.stream_id);if(n===-1)for(let r=t.messages.length-1;r>=0;r--){const i=t.messages[r];if(i.role==="assistant"&&i.error&&!Jit(i.id)){n=r;break}}if(n!==-1){if(t.messages.findIndex((l,u)=>u!==n&&l.id===e.db_id)!==-1){t.messages.splice(n,1);return}const i=t.messages[n];i.dbId=e.db_id,i.id=e.db_id,i.created_at=e.created_at,i.status==="waiting_for_user"||i.userQuestion?.status==="pending"||ate(i,{status:"completed",onlyIfRunning:!0})}}function IOn(t,e){t.responding=!0;const n=CN(t);if(n!==-1){const i=t.messages[n];i.id=e.stream_id,i.status="thinking",i.thinkingContent="",i.content=i.content||"";return}const r=D7(t);if(r!==-1){const i=t.messages[r];i.status="thinking",i.thinkingContent=i.thinkingContent??"";return}t.messages.push({id:e.stream_id,clientId:`thinking-${Date.now()}`,role:"assistant",content:"",isNewMessage:!0,created_at:new Date().toISOString(),status:"thinking",thinkingContent:""})}function Kgo(t,e){}function TOn(t,e){t.responding=!0;const{context:n}=e;let r=-1;n.stream_id&&(r=ax(t,n.stream_id)),r===-1&&(r=CN(t));const i={agentId:n.agent_id,agentName:n.agent_name,agentType:n.agent_type,executionId:n.execution_id,status:"running",startedAt:n.started_at,phases:[],subagents:[]};if(r!==-1){const o=t.messages[r];t.messages[r]={...o,id:`agent-${n.execution_id}`,streamId:n.stream_id||o.streamId,status:"pending",agentExecution:i}}else t.messages.push({id:`agent-${n.execution_id}`,streamId:n.stream_id,clientId:EN(),role:"assistant",content:"",created_at:new Date().toISOString(),status:"pending",isNewMessage:!0,agentExecution:i})}function BOn(t,e){t.responding=!1;const{context:n}=e,r=t.messages.findIndex(i=>i.agentExecution?.executionId===n.execution_id);if(r!==-1){const i=t.messages[r];i.agentExecution?ate(i,{status:e.status==="completed"?"completed":e.status==="cancelled"?"cancelled":"failed",durationMs:e.duration_ms}):Qxe(i)}}function DOn(t,e){t.responding=!1;const{context:n}=e,r=t.messages.findIndex(i=>i.agentExecution?.executionId===n.execution_id);if(r!==-1){const i=t.messages[r],o=i.agentExecution;o?(o.error={type:e.error_type,message:e.error_message,recoverable:e.recoverable,nodeId:e.node_id},ate(i,{status:"failed"})):Qxe(i)}}function NOn(t,e){const{context:n}=e,r=t.messages.findIndex(i=>i.agentExecution?.executionId===n.execution_id);if(r!==-1){const i=t.messages[r].agentExecution;if(i){const o=i.phases.find(p=>p.status==="running");o&&(o.status="completed",o.endedAt=Date.now(),o.startedAt&&(o.durationMs=Date.now()-o.startedAt));const l=sOn(e.node_id),u=i.phases.filter(p=>p.nodeId===e.node_id).length,d=u>0?`${e.node_id}__${u}`:e.node_id;i.phases.push({id:d,nodeId:e.node_id,name:l,componentKey:e.component_key,status:"running",startedAt:Date.now(),nodes:[],streamedContent:""}),i.currentPhase=l,i.currentNode=e.node_id}}}function ROn(t,e){const{context:n}=e,r=t.messages.findIndex(i=>i.agentExecution?.executionId===n.execution_id);if(r!==-1){const i=t.messages[r].agentExecution;if(i){const o=i.phases.findLast(l=>l.nodeId===e.node_id&&l.status==="running");o&&(o.status=e.status==="completed"?"completed":e.status==="skipped"?"skipped":"failed",o.endedAt=Date.now(),o.durationMs=e.duration_ms,o.outputSummary=e.output_summary)}}}function LOn(t,e){const{context:n}=e,r=t.messages.findIndex(i=>i.agentExecution&&(i.agentExecution.executionId===n.parent_execution_id||i.agentExecution.executionId===n.execution_id));if(r!==-1){const i=t.messages[r].agentExecution;i&&i.subagents.push({id:e.subagent_id,name:e.subagent_name,type:e.subagent_type,status:"running",depth:n.depth,executionPath:n.execution_path,startedAt:n.started_at})}}function MOn(t,e){const n=t.messages.findIndex(r=>r.agentExecution?.subagents?.some(i=>i.id===e.subagent_id));if(n!==-1){const r=t.messages[n].agentExecution;if(r){const i=r.subagents.find(o=>o.id===e.subagent_id);i&&(i.status=e.status==="completed"?"completed":"failed",i.endedAt=Date.now(),i.durationMs=e.duration_ms,i.outputSummary=e.output_summary)}}}function POn(t,e){const{context:n}=e,r=t.messages.findIndex(i=>i.agentExecution?.executionId===n.execution_id);if(r!==-1){const i=t.messages[r].agentExecution;i&&(i.progressPercent=e.progress_percent,i.progressMessage=e.message)}}function OOn(t,e){t.responding=!1;const n=e.error_code?{code:e.error_code,category:e.error_category||e.error_code.split(".")[0],message:e.error,recoverable:e.recoverable??!1,detail:e.detail,errorRef:e.error_ref,occurredAt:e.occurred_at}:{code:"system.internal_error",category:"system",message:e.error||"An error occurred",recoverable:!1};let r=ax(t,e.stream_id);r===-1&&(r=CN(t)),r===-1&&(r=lOn(t)),r===-1&&(r=D7(t)),r!==-1?t.messages[r]={...t.messages[r],status:"failed",error:n}:t.messages.push({id:e.stream_id,streamId:e.stream_id,clientId:EN(),role:"assistant",content:"",created_at:new Date().toISOString(),status:"failed",isNewMessage:!0,error:n}),console.error("Chat error:",e.error_code||e.error)}function FOn(t,e){console.warn("Insufficient balance:",e),t.responding=!1;let n=ax(t,e.stream_id);return n===-1&&(n=CN(t)),n!==-1&&(t.messages[n]={...t.messages[n],content:"",status:"failed",error:{code:"billing.insufficient_balance",category:"billing",message:e.message||"Insufficient balance. Please recharge to continue.",recoverable:!1}}),{isOpen:!0,title:"积分用尽",message:"您的积分已用尽。目前产品处于内测阶段,欢迎填写问卷参与内测,获取更多使用额度。",type:"warning",actionLabel:"填写问卷",actionUrl:"https://sii-czxy.feishu.cn/share/base/form/shrcnYu8Y3GNgI7M14En1xJ7rMb"}}function QOn(t,e){console.warn("Parallel chat limit reached:",e),t.responding=!1;const n=CN(t);return n!==-1&&t.messages.splice(n,1),{isOpen:!0,title:"并行会话已达上限",message:`您已达到并行会话上限(${e.current??"?"}/${e.limit??"?"})。请等待其他会话完成后重试。`,type:"warning"}}function $On(t,e,n){console.log("Stream aborted:",e);const r=n.get(t.id);r&&(clearTimeout(r),n.delete(t.id)),t.responding=!1,t.aborting=!1,$xe(t)}function jOn(t,e){t.responding=!0;const n=t.messages.findIndex(l=>l.status==="pending"&&!l.agentExecution);n!==-1&&t.messages.splice(n,1);const r={id:e.id,name:e.name,description:e.description,arguments:e.arguments,status:e.status,timestamp:new Date(e.timestamp*1e3).toISOString()};let i=D7(t);if(i===-1&&e.stream_id&&(i=ax(t,e.stream_id)),i!==-1){const l=t.messages[i].agentExecution;if(l){let u=l.currentNode?l.phases.findLast(d=>d.nodeId===l.currentNode):null;if(u||(u=l.phases.findLast(d=>d.status==="running")),!u&&l.phases.length>0&&(u=l.phases[l.phases.length-1]),u){u.toolCalls||(u.toolCalls=[]);const d=u.streamedContent?.length??0;r.contentOffset=d,u.toolCalls.push(r),console.log(`ChatSlice: Added tool call ${e.name} to phase ${u.id}`);return}}}const o=`tool-call-${e.id}`;t.messages.push({id:o,streamId:e.stream_id,clientId:EN(),role:"assistant",content:"",created_at:new Date().toISOString(),status:"streaming",isNewMessage:!0,toolCalls:[r]}),console.log(`ChatSlice: Created new tool call message with tool ${e.name}`)}function zOn(t,e){const n=D7(t);if(n!==-1){const r=t.messages[n].agentExecution;if(r){for(const i of r.phases)if(i.toolCalls){const o=i.toolCalls.find(l=>l.id===e.toolCallId);if(o){o.status=e.status,e.result!=null&&(o.result=e.result),e.error&&(o.error=e.error),e.duration_ms!==void 0&&(o.duration_ms=e.duration_ms);break}}}}t.messages.forEach(r=>{r.toolCalls&&r.toolCalls.forEach(i=>{i.id===e.toolCallId&&(i.status=e.status,e.result!=null&&(i.result=e.result),e.error&&(i.error=e.error),e.duration_ms!==void 0&&(i.duration_ms=e.duration_ms))})})}function UOn(t,e,n){t.title=e.name;const r=n.find(i=>i.id===e.id);r&&(r.title=e.name,r.updatedAt=e.updated_at)}function qOn(t,e){const n=rot(t,"citations");n!==-1?(t.messages[n].citations=e.citations,console.log(`Attached ${e.citations.length} citations to message ${t.messages[n].id}`)):console.warn("[Citation Debug] Could not find assistant message to attach citations")}function GOn(t,e){const n=rot(t,"attachments");if(n!==-1){t.messages[n].attachments||(t.messages[n].attachments=[]);const i=t.messages[n].attachments||[],o=e.files.filter(l=>!i.some(u=>u.id===l.id));t.messages[n].attachments=[...i,...o]}}function HOn(t,e){t.contextUsage={estimatedTokens:e.estimated_tokens,maxTokens:e.max_tokens,usagePercent:e.usage_percent,nearLimit:e.near_limit,critical:e.critical}}function WOn(t){return{questionId:t.question_id,question:t.question,options:t.options?.map(e=>({id:e.id,label:e.label,description:e.description,markdown:e.markdown})),multiSelect:t.multi_select??!1,allowTextInput:t.allow_text_input,timeoutSeconds:t.timeout_seconds,threadId:t.thread_id,status:"pending",askedAt:Date.now()}}function YOn(t,e){let n=ax(t,e.stream_id);if(n===-1&&(n=D7(t)),n===-1){for(let o=t.messages.length-1;o>=0;o--)if(t.messages[o].role==="assistant"){n=o;break}}if(n===-1){console.warn("[questionHandlers] No target message found for ask_user_question event");return}const r=t.messages[n],i=WOn(e);r.agentExecution&&r.agentExecution.phases.length>0&&(i.afterPhaseIndex=r.agentExecution.phases.length-1),r.userQuestion&&r.userQuestion.status!=="pending"&&(r.answeredQuestions||(r.answeredQuestions=[]),r.answeredQuestions.push(r.userQuestion)),r.status="waiting_for_user",r.userQuestion=i,t.responding=!0}const R7=new Map;function VOn(t,e,n){const{updateDerivedStatus:r,closeIdleNonPrimaryConnection:i}=n;return{connectToChannel:(o,l)=>{console.debug(`[connectToChannel] topic=${l.slice(0,8)} hasExistingSSE=${Qb.hasConnection(l)} msgs=${e().channels[l]?.messages.length}`),R7.get(l)?.destroy();const u=new wOn(m=>{t(g=>{const h=g.channels[l];h&&m(h)})});R7.set(l,u);const d=m=>{const g=m;if(g.type==="streaming_chunk"){u.pushStreaming(g.data.stream_id,g.data.content,g.data.execution_id);return}if(g.type==="thinking_chunk"){u.pushThinking(g.data.stream_id,g.data.content);return}const h=u.hasPending;u.flushSync();const f=e().channels[l]?.responding;console.groupCollapsed(`[ChatEvent] ${g.type} | topic=${l.slice(0,8)} | responding=${f}`),t(y=>{const v=y.channels[l];if(v){switch(console.debug(`msgs=${v.messages.length}`,`| latestAssist=${(()=>{const _=[...v.messages].reverse().find(w=>w.role==="assistant");return _?`id=${_.id.slice(0,12)} status=${_.status} agentExec=${_.agentExecution?.status}`:"none"})()}`),g.type){case"processing":case"loading":{xOn(v,g.data.stream_id);break}case"streaming_start":{kOn(v,g.data);break}case"streaming_end":{EOn(v,g.data);break}case"message":{const _=g.data,w=_.client_id;if(w){const x=v.messages.findIndex(k=>k.clientId===w);if(x!==-1){const k=v.messages[x];v.messages[x]={...k,..._,id:_.id,status:_.status||"completed",isNewMessage:!1};break}}COn(v,_);break}case"search_citations":{qOn(v,g.data);break}case"generated_files":{GOn(v,g.data);break}case"message_saved":{SOn(v,g.data);break}case"message_ack":{const{message_id:_,client_id:w}=g.data;if(w){const x=v.messages.findIndex(k=>k.clientId===w);if(x!==-1){const k=v.messages[x];k.id=_,k.status==="sending"&&(k.status="completed")}}break}case"tool_call_request":{jOn(v,g.data);break}case"tool_call_response":{zOn(v,g.data);break}case"error":{OOn(v,g.data);break}case"insufficient_balance":{const _=FOn(v,g.data);_&&(y.notification={..._,onAction:()=>window.open(_.actionUrl,"_blank")});break}case"parallel_chat_limit":{const _=QOn(v,g.data);y.notification=_;break}case"stream_aborted":{$On(v,g.data,A1);break}case"thinking_start":{IOn(v,g.data);break}case"thinking_end":{g.data;break}case"topic_updated":{UOn(v,g.data,y.chatHistory);break}case"agent_start":{TOn(v,g.data);break}case"agent_end":{BOn(v,g.data);break}case"agent_error":{DOn(v,g.data);break}case"node_start":{NOn(v,g.data);break}case"node_end":{ROn(v,g.data);break}case"subagent_start":{LOn(v,g.data);break}case"subagent_end":{MOn(v,g.data);break}case"progress_update":{POn(v,g.data);break}case"ask_user_question":{YOn(v,g.data);break}case"token_usage":{const{total_tokens:_}=g.data;v.tokenUsage=_;break}case"context_usage":{HOn(v,g.data);break}}jxe(v)}});const b=e().channels[l]?.responding;if(f!==b&&console.debug(`responding changed: ${f} → ${b}`,`| hadPendingChunks: ${h}`),console.groupEnd(),g.type==="topic_updated"&&e().renameTab(g.data.id,g.data.name),g.type==="agent_end"){const y=e().channels[l];y?.sessionId&&!y.sandbox_backend&&Np.getSessionByTopic(l).then(v=>{v.sandbox_backend&&t(_=>{const w=_.channels[l];w&&!w.sandbox_backend&&(w.sandbox_backend=v.sandbox_backend)})}).catch(()=>{})}r(),i(l)};if(Qb.hasConnection(l)){Qb.updateCallbacks(l,{onMessageEvent:d,onStatusChange:m=>{t(g=>{const h=g.channels[l];h&&(h.connected=m.connected,h.error=m.error??null)})}}),t(m=>{m.channels[l]&&(m.channels[l].connected=!0,m.channels[l].error=null)});return}const p=Qb.getOpenTopicIds();for(const m of p){if(m===l)continue;e().channels[m]?.responding||Qb.disconnect(m)}t(m=>{Object.entries(m.channels).forEach(([g,h])=>{Qb.hasConnection(g)||(h.connected=!1)}),m.channels[l]&&(m.channels[l].error=null)}),Qb.connect(l,{onMessageEvent:d,onStatusChange:m=>{t(g=>{const h=g.channels[l];h&&(h.connected=m.connected,h.error=m.error??null)})}}),t(m=>{m.channels[l]&&(m.channels[l].connected=!0,m.channels[l].error=null)})},disconnectFromChannel:()=>{for(const[,o]of R7)o.destroy();R7.clear();for(const[o,l]of A1)clearTimeout(l),A1.delete(o);Qb.disconnectAll()},abortGeneration:o=>{dg.abort(o).catch(p=>{console.error("Failed to send abort signal:",p)});const l=A1.get(o);l&&(clearTimeout(l),A1.delete(o));const u=R7.get(o);u&&u.destroy(),t(p=>{const m=p.channels[o];m&&(m.aborting=!0,$xe(m))}),r();const d=setTimeout(()=>{A1.delete(o),e().channels[o]?.aborting&&(console.warn("Abort timeout: Backend did not respond, resetting state"),t(g=>{const h=g.channels[o];h&&(h.aborting=!1,h.responding=!1,$xe(h))}),r())},1e4);A1.set(o,d)},respondToQuestion:(o,l,u)=>{dg.answerQuestion(o,{question_id:l,selected_options:u.selectedOptions,text:u.text||""}).catch(d=>{console.error("Failed to send question response:",d)}),t(d=>{const p=d.channels[o];if(!p)return;const m=p.messages.find(h=>h.userQuestion?.questionId===l||h.answeredQuestions?.some(f=>f.questionId===l));if(!m)return;const g=m.userQuestion?.questionId===l?m.userQuestion:m.answeredQuestions?.find(h=>h.questionId===l);g&&(g.status="answered",g.selectedOptions=u.selectedOptions,g.userText=u.text,m.status="pending")}),r()},confirmToolCall:(o,l)=>{console.warn("confirmToolCall: not implemented in SSE mode"),t(u=>{u.channels[o]&&u.channels[o].messages.forEach(d=>{d.toolCalls&&d.toolCalls.forEach(p=>{p.id===l&&p.status==="waiting_confirmation"&&(p.status="executing")})})})},cancelToolCall:(o,l)=>{console.warn("cancelToolCall: not implemented in SSE mode"),t(u=>{u.channels[o]&&u.channels[o].messages.forEach(d=>{d.toolCalls&&d.toolCalls.forEach(p=>{p.id===l&&p.status==="waiting_confirmation"&&(p.status="failed",p.error="用户取消执行")})})})}}}const KOn=["image/jpeg","image/jpg","image/png","image/gif","image/webp","application/pdf","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.openxmlformats-officedocument.presentationml.presentation","application/json","application/xml","application/x-yaml","text/plain","text/markdown","text/csv","text/html","text/xml","text/yaml","text/x-yaml","audio/mpeg","audio/wav","audio/wave","audio/x-wav",".csv",".docx",".htm",".html",".json",".md",".pdf",".pptx",".txt",".xlsx",".xml",".yaml",".yml"],ZOn=[".csv",".docx",".htm",".html",".json",".md",".pdf",".pptx",".txt",".xlsx",".xml",".yaml",".yml"];class XOn{appendUploadFields(e,n){e.append("file",n.file),e.append("scope",n.scope),n.category&&e.append("category",n.category),n.parentId&&e.append("parent_id",n.parentId),n.knowledgeSetId&&e.append("knowledge_set_id",n.knowledgeSetId),n.purpose&&e.append("purpose",n.purpose)}getUploadError(e){if(e.status===429)return new Error("Too many requests. Please wait a moment and try again.");try{const n=JSON.parse(e.responseText);if(typeof n.detail=="string"&&n.detail.trim())return new Error(n.detail)}catch{}return new Error(`Upload failed: ${e.statusText||`HTTP ${e.status}`}`)}uploadWithXhr(e,n){const r=new FormData;this.appendUploadFields(r,e);const i=new XMLHttpRequest,o=on.baseUrl;return{promise:new Promise((u,d)=>{i.upload.addEventListener("progress",m=>{if(n&&m.lengthComputable){const g=Math.round(m.loaded*100/m.total);n({loaded:m.loaded,total:m.total,percentage:g})}}),i.addEventListener("load",()=>{i.status>=200&&i.status<300?u(JSON.parse(i.responseText)):d(this.getUploadError(i))}),i.addEventListener("error",()=>{d(new Error("Upload failed"))}),i.addEventListener("abort",()=>{d(new Error("Upload cancelled"))}),i.open("POST",`${o}/xyzen/api/v1/files/upload`);const p=Eo.getToken();p&&i.setRequestHeader("Authorization",`Bearer ${p}`),i.send(r)}),abort:()=>i.abort()}}isAllowedType(e,n){return n.endsWith("/*")?e.type.startsWith(n.slice(0,-1)):n.startsWith(".")?e.name.toLowerCase().endsWith(n.toLowerCase()):e.type===n}uploadFileWithProgress(e,n="private",r,i,o,l){return this.uploadWithXhr({file:e,scope:n,category:r,parentId:i,knowledgeSetId:o},l)}async uploadFile(e,n="private",r,i,o,l){return this.uploadWithXhr({file:e,scope:n,category:r,parentId:i,knowledgeSetId:o},l).promise}async uploadChatAttachment(e,n="private",r,i,o,l){return this.uploadWithXhr({file:e,scope:n,category:r,parentId:i,knowledgeSetId:o,purpose:"chat_attachment"},l).promise}async getFile(e){return on.get(`/xyzen/api/v1/files/${e}`)}async listFiles(e){const n=new URLSearchParams;e&&(e.scope&&n.append("scope",e.scope),e.category&&n.append("category",e.category),e.include_deleted&&n.append("include_deleted","true"),e.limit&&n.append("limit",e.limit.toString()),e.offset&&n.append("offset",e.offset.toString()),e.parent_id&&n.append("parent_id",e.parent_id),e.filter_by_parent&&n.append("filter_by_parent","true"),e.is_dir!==void 0&&n.append("is_dir",e.is_dir.toString()),e.knowledge_set_id&&n.append("knowledge_set_id",e.knowledge_set_id));const r=n.toString()?"?"+n.toString():"";return on.get(`/xyzen/api/v1/files/${r}`)}async getFileUrl(e,n=3600){return on.get(`/xyzen/api/v1/files/${e}/url`,{params:{expires_in:n}})}async updateFile(e,n){return on.patch(`/xyzen/api/v1/files/${e}`,n)}async confirmFiles(e,n){await Promise.all(e.map(r=>this.updateFile(r,{message_id:n,status:"confirmed"})))}async deleteFile(e,n=!1){return on.delete(`/xyzen/api/v1/files/${e}`,void 0,{params:{hard_delete:n}})}async restoreFile(e){return on.post(`/xyzen/api/v1/files/${e}/restore`)}async getStorageStats(){return on.get("/xyzen/api/v1/files/stats/summary")}async getChatUploadCapabilities(){return on.get("/xyzen/api/v1/files/chat-upload-capabilities")}async emptyTrash(){return on.post("/xyzen/api/v1/files/empty-trash")}async bulkDeleteFiles(e){return on.delete("/xyzen/api/v1/files/bulk",e)}async updateFileContent(e,n,r){const i=new Blob([n],{type:r||"text/plain"}),o=new FormData;return o.append("file",i,"content"),on.put(`/xyzen/api/v1/files/${e}/content`,o)}async downloadRaw(e,n){return on.raw(`/xyzen/api/v1/files/${e}/download`,{signal:n?.signal})}validateFile(e,n={}){const{maxSize:r=100*1024*1024,allowedTypes:i=KOn}=n;return e.size>r?{valid:!1,reason:"file_too_large",maxSize:r,actualSize:e.size,error:`File size exceeds ${(r/(1024*1024)).toFixed(0)}MB limit`}:i.length>0&&!i.some(l=>this.isAllowedType(e,l))?{valid:!1,reason:"unsupported_type",fileType:e.type||"unknown",error:`File type ${e.type||"unknown"} is not supported`}:{valid:!0}}getFileCategory(e){if(e.type.startsWith("image/"))return"images";if(e.type.startsWith("audio/"))return"audio";const n=e.name.toLowerCase();return e.type.includes("pdf")||e.type.includes("text")||e.type.includes("document")||e.type.includes("sheet")||e.type.includes("presentation")||e.type.includes("json")||e.type.includes("xml")||e.type.includes("yaml")||ZOn.some(r=>n.endsWith(r))?"documents":"others"}getAttachmentAccessHint(e,n){const r=n||this.getFileCategory({name:e.name,type:e.type});return r==="images"||r==="audio"?"view":"read"}generateThumbnail(e){return new Promise((n,r)=>{if(!e.type.startsWith("image/")){r(new Error("File is not an image"));return}const i=160,o=URL.createObjectURL(e),l=new Image;l.onload=()=>{URL.revokeObjectURL(o);let u=l.width,d=l.height;u>d?u>i&&(d=Math.round(d*i/u),u=i):d>i&&(u=Math.round(u*i/d),d=i);const p=document.createElement("canvas");p.width=u,p.height=d;const m=p.getContext("2d");if(!m){r(new Error("Failed to get canvas context"));return}m.drawImage(l,0,0,u,d);const g=p.toDataURL("image/jpeg",.8);n(g)},l.onerror=()=>{URL.revokeObjectURL(o),r(new Error("Failed to load image"))},l.src=o})}}const ys=new XOn;class JOn{async editMessage(e,n){return on.patch(`/xyzen/api/v1/messages/${e}`,n)}async deleteMessage(e){return on.delete(`/xyzen/api/v1/messages/${e}`)}}const uot=new JOn;function eFn(t,e,n){const{updateDerivedStatus:r,waitForChannelConnection:i}=n;return{sendMessage:async o=>{const{activeChatChannel:l,uploadedFiles:u,clearFiles:d,isUploading:p,channels:m,connectToChannel:g,showNotification:h}=e();if(!l)return;if(p){console.warn("Cannot send message while files are uploading");return}const f=m[l];if(!f)return;if(f.responding){console.warn("Cannot send message while assistant is responding");return}Qb.hasConnection(l)||(g(f.sessionId,f.id),await i(l));const b=e().channels[l];if(!b?.connected){h("Connection not ready","Please wait for chat connection and try again.","warning");return}const y=EN(),v=u.filter(k=>k.status==="completed"&&k.uploadedId),_=v.map(k=>({id:k.uploadedId,name:k.file.name,type:k.file.type,size:k.file.size,category:ys.getFileCategory(k.file)}));t(k=>{const C=k.channels[l];C&&(C.responding=!0,C.messages.push({id:y,clientId:y,role:"user",content:o,created_at:new Date().toISOString(),status:"sending",isNewMessage:!0,..._.length>0?{attachments:_}:{}}))}),r();const w={message:o,client_id:y};v.length>0&&(w.file_ids=v.map(k=>k.uploadedId));const x=b;x?.knowledgeContext&&(w.context=x.knowledgeContext);try{await dg.sendMessage(l,w)}catch(k){console.error("Failed to send message via REST:",k),t(E=>{const S=E.channels[l];if(S){S.responding=!1;const I=S.messages.find(B=>B.clientId===y);I&&(I.status="failed")}}),r();const C=k instanceof Error&&"detail"in k?k.detail:void 0;if(C&&typeof C=="object"&&C.type==="parallel_chat_limit"){const E=C.data;e().showNotification(to.t("app.chat.parallelLimitTitle","Parallel chat limit reached"),to.t("app.chat.parallelLimitMessage","You have reached the parallel chat limit ({{current}}/{{limit}}). Please wait for other chats to finish.",{current:E?.current??"?",limit:E?.limit??"?"}),"warning")}else C&&typeof C=="object"&&C.error_code==="INSUFFICIENT_BALANCE"&&e().showNotification(to.t("app.chat.insufficientBalance","Insufficient balance"),to.t("app.chat.insufficientBalanceMessage","Your photon balance is insufficient. Please top up to continue."),"warning");return}d(!1)},startEditMessage:(o,l,u)=>{t({editingMessageId:o,editingContent:l,editingMode:u})},cancelEditMessage:()=>{t({editingMessageId:null,editingContent:"",editingMode:null})},submitEditMessage:async()=>{const{editingMessageId:o,editingContent:l,editingMode:u,activeChatChannel:d,channels:p}=e();if(!o||!d||!u)return;const m=p[d];if(!m)return;if(!m.messages.some(f=>f.id===o)){console.error("Message not found in active channel, skipping edit"),e().cancelEditMessage();return}const h=u==="edit_and_regenerate";try{const f=await uot.editMessage(o,{content:l,truncate_and_regenerate:h});t(b=>{const y=b.channels[d];if(!y)return;const v=y.messages.findIndex(_=>_.id===o);v!==-1&&(y.messages[v].content=f.message.content,y.messages[v].created_at=f.message.created_at,h&&(y.messages=y.messages.slice(0,v+1),y.responding=!1),b.editingMessageId=null,b.editingContent="",b.editingMode=null)}),f.regenerate&&e().triggerRegeneration()}catch(f){console.error("Failed to edit message:",f),e().showNotification("Error",to.t("app.message.editFailed"),"error")}},triggerRegeneration:()=>{const{activeChatChannel:o}=e();if(o){if(!Qb.hasConnection(o)){console.warn("[triggerRegeneration] No SSE connection, skipping");return}t(l=>{const u=l.channels[o];u&&(u.responding=!0)}),dg.regenerate(o).catch(l=>{console.error("Failed to trigger regeneration:",l),t(u=>{const d=u.channels[o];d&&(d.responding=!1)}),r()})}},deleteMessage:async o=>{const{activeChatChannel:l,channels:u}=e();if(!l)return;const d=u[l];if(!d)return;if(!Jit(o)){const g=d.messages.find(h=>h.id===o)?.status==="streaming"?to.t("app.message.deleteStillStreaming"):to.t("app.message.deleteNotSaved");console.error(`Cannot delete message: ${g} (id: ${o.slice(0,20)}...)`),e().showNotification(to.t("app.message.cannotDelete"),g,"warning");return}if(!d.messages.some(m=>m.id===o)){console.error("Message not found in active channel, skipping delete");return}try{await uot.deleteMessage(o),t(m=>{const g=m.channels[l];g&&(g.messages=g.messages.filter(h=>h.id!==o))})}catch(m){console.error("Failed to delete message:",m),e().showNotification("Error",to.t("app.message.deleteFailed"),"error")}},retryMessage:o=>{const{activeChatChannel:l,channels:u,sendMessage:d}=e();if(!l)return;const p=u[l];if(!p)return;const m=p.messages.find(h=>h.id===o);if(!m||m.status!=="failed")return;const g=m.content;t(h=>{const f=h.channels[l];f&&(f.messages=f.messages.filter(b=>b.id!==o))}),d(g)}}}const ite=50,tFn=(t,e)=>{const n=d=>d&&e().resolveAgent(d)?.name||"通用助理",r=async(d,p)=>{const m=Date.now();for(;Date.now()-m<=yOn;){const g=e().channels[d];if(g?.connected)return!0;if(g?.error)return p?.logFailure&&console.warn(`Connection failed for topic ${d}: ${g.error}`),!1;await new Promise(h=>{setTimeout(h,vOn)})}return p?.logFailure&&console.warn(`Connection timeout for topic ${d}`),!1},i=()=>{const d=e().respondingChannelIds;t(p=>{const m=new Set,g=new Set,h={};for(const b of Object.values(p.channels)){const y=oOn(b);(y==="running"||y==="stopping")&&(m.add(b.id),b.agentId&&g.add(b.agentId)),y==="running"&&b.agentId&&(h[b.agentId]=(h[b.agentId]||0)+1)}p.respondingChannelIds=m,p.runningAgentIds=g,p.activeTopicCountByAgent=h;const f=p.activeChatChannel;if(f){const b=d.has(f),y=m.has(f);b!==y&&console.debug(`[updateDerivedStatus] active channel ${f}: respondingChannelIds ${b} → ${y}`,`| channel.responding: ${p.channels[f]?.responding}`)}})},u={reconcileChannelFromBackend:async d=>{const{setLoading:p}=e(),m=`topicMessages-${d}`,g=e().channels[d];if(g?.responding){console.debug(`[reconcile] SKIP — channel is responding, topic=${d.slice(0,8)} msgs=${g.messages.length}`);return}console.groupCollapsed(`[reconcile] topic=${d.slice(0,8)} responding=${g?.responding} msgs=${g?.messages.length}`),console.debug(new Error().stack?.split(`
109
+ `);i&&(r.content=i)}r.agentExecution?.status==="running"||ate(r,{status:"completed",onlyIfRunning:!0}),r.created_at=e.created_at||new Date().toISOString(),console.debug("[ChatSlice] streaming_end: finalized message at index",n)}else console.warn("[ChatSlice] streaming_end: no message found to finalize")}function COn(t,e){t.messages.some(n=>n.id===e.id)||t.messages.push({...e,status:e.status||"completed",isNewMessage:!0})}function SOn(t,e){let n=ax(t,e.stream_id);if(n===-1)for(let r=t.messages.length-1;r>=0;r--){const i=t.messages[r];if(i.role==="assistant"&&i.error&&!Jit(i.id)){n=r;break}}if(n!==-1){if(t.messages.findIndex((l,u)=>u!==n&&l.id===e.db_id)!==-1){t.messages.splice(n,1);return}const i=t.messages[n];i.dbId=e.db_id,i.id=e.db_id,i.created_at=e.created_at,i.status==="waiting_for_user"||i.userQuestion?.status==="pending"||ate(i,{status:"completed",onlyIfRunning:!0})}}function IOn(t,e){t.responding=!0;const n=CN(t);if(n!==-1){const i=t.messages[n];i.id=e.stream_id,i.status="thinking",i.thinkingContent="",i.content=i.content||"";return}const r=D7(t);if(r!==-1){const i=t.messages[r];i.status="thinking",i.thinkingContent=i.thinkingContent??"";return}t.messages.push({id:e.stream_id,clientId:`thinking-${Date.now()}`,role:"assistant",content:"",isNewMessage:!0,created_at:new Date().toISOString(),status:"thinking",thinkingContent:""})}function Kgo(t,e){}function TOn(t,e){t.responding=!0;const{context:n}=e;let r=-1;n.stream_id&&(r=ax(t,n.stream_id)),r===-1&&(r=CN(t));const i={agentId:n.agent_id,agentName:n.agent_name,agentType:n.agent_type,executionId:n.execution_id,status:"running",startedAt:n.started_at,phases:[],subagents:[]};if(r!==-1){const o=t.messages[r];t.messages[r]={...o,id:`agent-${n.execution_id}`,streamId:n.stream_id||o.streamId,status:"pending",agentExecution:i}}else t.messages.push({id:`agent-${n.execution_id}`,streamId:n.stream_id,clientId:EN(),role:"assistant",content:"",created_at:new Date().toISOString(),status:"pending",isNewMessage:!0,agentExecution:i})}function BOn(t,e){t.responding=!1;const{context:n}=e,r=t.messages.findIndex(i=>i.agentExecution?.executionId===n.execution_id);if(r!==-1){const i=t.messages[r];i.agentExecution?ate(i,{status:e.status==="completed"?"completed":e.status==="cancelled"?"cancelled":"failed",durationMs:e.duration_ms}):Qxe(i)}}function DOn(t,e){t.responding=!1;const{context:n}=e,r=t.messages.findIndex(i=>i.agentExecution?.executionId===n.execution_id);if(r!==-1){const i=t.messages[r],o=i.agentExecution;o?(o.error={type:e.error_type,message:e.error_message,recoverable:e.recoverable,nodeId:e.node_id},ate(i,{status:"failed"})):Qxe(i)}}function NOn(t,e){const{context:n}=e,r=t.messages.findIndex(i=>i.agentExecution?.executionId===n.execution_id);if(r!==-1){const i=t.messages[r].agentExecution;if(i){const o=i.phases.find(p=>p.status==="running");o&&(o.status="completed",o.endedAt=Date.now(),o.startedAt&&(o.durationMs=Date.now()-o.startedAt));const l=sOn(e.node_id),u=i.phases.filter(p=>p.nodeId===e.node_id).length,d=u>0?`${e.node_id}__${u}`:e.node_id;i.phases.push({id:d,nodeId:e.node_id,name:l,componentKey:e.component_key,status:"running",startedAt:Date.now(),nodes:[],streamedContent:""}),i.currentPhase=l,i.currentNode=e.node_id}}}function ROn(t,e){const{context:n}=e,r=t.messages.findIndex(i=>i.agentExecution?.executionId===n.execution_id);if(r!==-1){const i=t.messages[r].agentExecution;if(i){const o=i.phases.findLast(l=>l.nodeId===e.node_id&&l.status==="running");o&&(o.status=e.status==="completed"?"completed":e.status==="skipped"?"skipped":"failed",o.endedAt=Date.now(),o.durationMs=e.duration_ms,o.outputSummary=e.output_summary)}}}function LOn(t,e){const{context:n}=e,r=t.messages.findIndex(i=>i.agentExecution&&(i.agentExecution.executionId===n.parent_execution_id||i.agentExecution.executionId===n.execution_id));if(r!==-1){const i=t.messages[r].agentExecution;i&&i.subagents.push({id:e.subagent_id,name:e.subagent_name,type:e.subagent_type,status:"running",depth:n.depth,executionPath:n.execution_path,startedAt:n.started_at})}}function MOn(t,e){const n=t.messages.findIndex(r=>r.agentExecution?.subagents?.some(i=>i.id===e.subagent_id));if(n!==-1){const r=t.messages[n].agentExecution;if(r){const i=r.subagents.find(o=>o.id===e.subagent_id);i&&(i.status=e.status==="completed"?"completed":"failed",i.endedAt=Date.now(),i.durationMs=e.duration_ms,i.outputSummary=e.output_summary)}}}function POn(t,e){const{context:n}=e,r=t.messages.findIndex(i=>i.agentExecution?.executionId===n.execution_id);if(r!==-1){const i=t.messages[r].agentExecution;i&&(i.progressPercent=e.progress_percent,i.progressMessage=e.message)}}function OOn(t,e){t.responding=!1;const n=e.error_code?{code:e.error_code,category:e.error_category||e.error_code.split(".")[0],message:e.error,recoverable:e.recoverable??!1,detail:e.detail,errorRef:e.error_ref,occurredAt:e.occurred_at}:{code:"system.internal_error",category:"system",message:e.error||"An error occurred",recoverable:!1};let r=ax(t,e.stream_id);r===-1&&(r=CN(t)),r===-1&&(r=lOn(t)),r===-1&&(r=D7(t)),r!==-1?t.messages[r]={...t.messages[r],status:"failed",error:n}:t.messages.push({id:e.stream_id,streamId:e.stream_id,clientId:EN(),role:"assistant",content:"",created_at:new Date().toISOString(),status:"failed",isNewMessage:!0,error:n}),console.error("Chat error:",e.error_code||e.error)}function FOn(t,e){console.warn("Insufficient balance:",e),t.responding=!1;let n=ax(t,e.stream_id);return n===-1&&(n=CN(t)),n!==-1&&(t.messages[n]={...t.messages[n],content:"",status:"failed",error:{code:"billing.insufficient_balance",category:"billing",message:e.message||"Insufficient balance. Please recharge to continue.",recoverable:!1}}),{isOpen:!0,title:"积分用尽",message:"您的积分已用尽。目前产品处于内测阶段,欢迎填写问卷参与内测,获取更多使用额度。",type:"warning",actionLabel:"填写问卷",actionUrl:"https://sii-czxy.feishu.cn/share/base/form/shrcnYu8Y3GNgI7M14En1xJ7rMb"}}function QOn(t,e){console.warn("Parallel chat limit reached:",e),t.responding=!1;const n=CN(t);return n!==-1&&t.messages.splice(n,1),{isOpen:!0,title:"并行会话已达上限",message:`您已达到并行会话上限(${e.current??"?"}/${e.limit??"?"})。请等待其他会话完成后重试。`,type:"warning"}}function $On(t,e,n){console.log("Stream aborted:",e);const r=n.get(t.id);r&&(clearTimeout(r),n.delete(t.id)),t.responding=!1,t.aborting=!1,$xe(t)}function jOn(t,e){t.responding=!0;const n=t.messages.findIndex(l=>l.status==="pending"&&!l.agentExecution);n!==-1&&t.messages.splice(n,1);const r={id:e.id,name:e.name,description:e.description,arguments:e.arguments,status:e.status,timestamp:new Date(e.timestamp*1e3).toISOString()};let i=D7(t);if(i===-1&&e.stream_id&&(i=ax(t,e.stream_id)),i!==-1){const l=t.messages[i].agentExecution;if(l){let u=l.currentNode?l.phases.findLast(d=>d.nodeId===l.currentNode):null;if(u||(u=l.phases.findLast(d=>d.status==="running")),!u&&l.phases.length>0&&(u=l.phases[l.phases.length-1]),u){u.toolCalls||(u.toolCalls=[]);const d=u.streamedContent?.length??0;r.contentOffset=d,u.toolCalls.push(r),console.log(`ChatSlice: Added tool call ${e.name} to phase ${u.id}`);return}}}const o=`tool-call-${e.id}`;t.messages.push({id:o,streamId:e.stream_id,clientId:EN(),role:"assistant",content:"",created_at:new Date().toISOString(),status:"streaming",isNewMessage:!0,toolCalls:[r]}),console.log(`ChatSlice: Created new tool call message with tool ${e.name}`)}function zOn(t,e){const n=D7(t);if(n!==-1){const r=t.messages[n].agentExecution;if(r){for(const i of r.phases)if(i.toolCalls){const o=i.toolCalls.find(l=>l.id===e.toolCallId);if(o){o.status=e.status,e.result!=null&&(o.result=e.result),e.error&&(o.error=e.error),e.duration_ms!==void 0&&(o.duration_ms=e.duration_ms);break}}}}t.messages.forEach(r=>{r.toolCalls&&r.toolCalls.forEach(i=>{i.id===e.toolCallId&&(i.status=e.status,e.result!=null&&(i.result=e.result),e.error&&(i.error=e.error),e.duration_ms!==void 0&&(i.duration_ms=e.duration_ms))})})}function UOn(t,e,n){t.title=e.name;const r=n.find(i=>i.id===e.id);r&&(r.title=e.name,r.updatedAt=e.updated_at)}function qOn(t,e){const n=rot(t,"citations");n!==-1?(t.messages[n].citations=e.citations,console.log(`Attached ${e.citations.length} citations to message ${t.messages[n].id}`)):console.warn("[Citation Debug] Could not find assistant message to attach citations")}function GOn(t,e){const n=rot(t,"attachments");if(n!==-1){t.messages[n].attachments||(t.messages[n].attachments=[]);const i=t.messages[n].attachments||[],o=e.files.filter(l=>!i.some(u=>u.id===l.id)).map(l=>({...l,download_url:`/xyzen/api/v1/files/${l.id}/download`}));t.messages[n].attachments=[...i,...o]}}function HOn(t,e){t.contextUsage={estimatedTokens:e.estimated_tokens,maxTokens:e.max_tokens,usagePercent:e.usage_percent,nearLimit:e.near_limit,critical:e.critical}}function WOn(t){return{questionId:t.question_id,question:t.question,options:t.options?.map(e=>({id:e.id,label:e.label,description:e.description,markdown:e.markdown})),multiSelect:t.multi_select??!1,allowTextInput:t.allow_text_input,timeoutSeconds:t.timeout_seconds,threadId:t.thread_id,status:"pending",askedAt:Date.now()}}function YOn(t,e){let n=ax(t,e.stream_id);if(n===-1&&(n=D7(t)),n===-1){for(let o=t.messages.length-1;o>=0;o--)if(t.messages[o].role==="assistant"){n=o;break}}if(n===-1){console.warn("[questionHandlers] No target message found for ask_user_question event");return}const r=t.messages[n],i=WOn(e);r.agentExecution&&r.agentExecution.phases.length>0&&(i.afterPhaseIndex=r.agentExecution.phases.length-1),r.userQuestion&&r.userQuestion.status!=="pending"&&(r.answeredQuestions||(r.answeredQuestions=[]),r.answeredQuestions.push(r.userQuestion)),r.status="waiting_for_user",r.userQuestion=i,t.responding=!0}const R7=new Map;function VOn(t,e,n){const{updateDerivedStatus:r,closeIdleNonPrimaryConnection:i}=n;return{connectToChannel:(o,l)=>{console.debug(`[connectToChannel] topic=${l.slice(0,8)} hasExistingSSE=${Qb.hasConnection(l)} msgs=${e().channels[l]?.messages.length}`),R7.get(l)?.destroy();const u=new wOn(m=>{t(g=>{const h=g.channels[l];h&&m(h)})});R7.set(l,u);const d=m=>{const g=m;if(g.type==="streaming_chunk"){u.pushStreaming(g.data.stream_id,g.data.content,g.data.execution_id);return}if(g.type==="thinking_chunk"){u.pushThinking(g.data.stream_id,g.data.content);return}const h=u.hasPending;u.flushSync();const f=e().channels[l]?.responding;console.groupCollapsed(`[ChatEvent] ${g.type} | topic=${l.slice(0,8)} | responding=${f}`),t(y=>{const v=y.channels[l];if(v){switch(console.debug(`msgs=${v.messages.length}`,`| latestAssist=${(()=>{const _=[...v.messages].reverse().find(w=>w.role==="assistant");return _?`id=${_.id.slice(0,12)} status=${_.status} agentExec=${_.agentExecution?.status}`:"none"})()}`),g.type){case"processing":case"loading":{xOn(v,g.data.stream_id);break}case"streaming_start":{kOn(v,g.data);break}case"streaming_end":{EOn(v,g.data);break}case"message":{const _=g.data,w=_.client_id;if(w){const x=v.messages.findIndex(k=>k.clientId===w);if(x!==-1){const k=v.messages[x];v.messages[x]={...k,..._,id:_.id,status:_.status||"completed",isNewMessage:!1};break}}COn(v,_);break}case"search_citations":{qOn(v,g.data);break}case"generated_files":{GOn(v,g.data);break}case"message_saved":{SOn(v,g.data);break}case"message_ack":{const{message_id:_,client_id:w}=g.data;if(w){const x=v.messages.findIndex(k=>k.clientId===w);if(x!==-1){const k=v.messages[x];k.id=_,k.status==="sending"&&(k.status="completed")}}break}case"tool_call_request":{jOn(v,g.data);break}case"tool_call_response":{zOn(v,g.data);break}case"error":{OOn(v,g.data);break}case"insufficient_balance":{const _=FOn(v,g.data);_&&(y.notification={..._,onAction:()=>window.open(_.actionUrl,"_blank")});break}case"parallel_chat_limit":{const _=QOn(v,g.data);y.notification=_;break}case"stream_aborted":{$On(v,g.data,A1);break}case"thinking_start":{IOn(v,g.data);break}case"thinking_end":{g.data;break}case"topic_updated":{UOn(v,g.data,y.chatHistory);break}case"agent_start":{TOn(v,g.data);break}case"agent_end":{BOn(v,g.data);break}case"agent_error":{DOn(v,g.data);break}case"node_start":{NOn(v,g.data);break}case"node_end":{ROn(v,g.data);break}case"subagent_start":{LOn(v,g.data);break}case"subagent_end":{MOn(v,g.data);break}case"progress_update":{POn(v,g.data);break}case"ask_user_question":{YOn(v,g.data);break}case"token_usage":{const{total_tokens:_}=g.data;v.tokenUsage=_;break}case"context_usage":{HOn(v,g.data);break}}jxe(v)}});const b=e().channels[l]?.responding;if(f!==b&&console.debug(`responding changed: ${f} → ${b}`,`| hadPendingChunks: ${h}`),console.groupEnd(),g.type==="topic_updated"&&e().renameTab(g.data.id,g.data.name),g.type==="agent_end"){const y=e().channels[l];y?.sessionId&&!y.sandbox_backend&&Np.getSessionByTopic(l).then(v=>{v.sandbox_backend&&t(_=>{const w=_.channels[l];w&&!w.sandbox_backend&&(w.sandbox_backend=v.sandbox_backend)})}).catch(()=>{})}r(),i(l)};if(Qb.hasConnection(l)){Qb.updateCallbacks(l,{onMessageEvent:d,onStatusChange:m=>{t(g=>{const h=g.channels[l];h&&(h.connected=m.connected,h.error=m.error??null)})}}),t(m=>{m.channels[l]&&(m.channels[l].connected=!0,m.channels[l].error=null)});return}const p=Qb.getOpenTopicIds();for(const m of p){if(m===l)continue;e().channels[m]?.responding||Qb.disconnect(m)}t(m=>{Object.entries(m.channels).forEach(([g,h])=>{Qb.hasConnection(g)||(h.connected=!1)}),m.channels[l]&&(m.channels[l].error=null)}),Qb.connect(l,{onMessageEvent:d,onStatusChange:m=>{t(g=>{const h=g.channels[l];h&&(h.connected=m.connected,h.error=m.error??null)})}}),t(m=>{m.channels[l]&&(m.channels[l].connected=!0,m.channels[l].error=null)})},disconnectFromChannel:()=>{for(const[,o]of R7)o.destroy();R7.clear();for(const[o,l]of A1)clearTimeout(l),A1.delete(o);Qb.disconnectAll()},abortGeneration:o=>{dg.abort(o).catch(p=>{console.error("Failed to send abort signal:",p)});const l=A1.get(o);l&&(clearTimeout(l),A1.delete(o));const u=R7.get(o);u&&u.destroy(),t(p=>{const m=p.channels[o];m&&(m.aborting=!0,$xe(m))}),r();const d=setTimeout(()=>{A1.delete(o),e().channels[o]?.aborting&&(console.warn("Abort timeout: Backend did not respond, resetting state"),t(g=>{const h=g.channels[o];h&&(h.aborting=!1,h.responding=!1,$xe(h))}),r())},1e4);A1.set(o,d)},respondToQuestion:(o,l,u)=>{dg.answerQuestion(o,{question_id:l,selected_options:u.selectedOptions,text:u.text||""}).catch(d=>{console.error("Failed to send question response:",d)}),t(d=>{const p=d.channels[o];if(!p)return;const m=p.messages.find(h=>h.userQuestion?.questionId===l||h.answeredQuestions?.some(f=>f.questionId===l));if(!m)return;const g=m.userQuestion?.questionId===l?m.userQuestion:m.answeredQuestions?.find(h=>h.questionId===l);g&&(g.status="answered",g.selectedOptions=u.selectedOptions,g.userText=u.text,m.status="pending")}),r()},confirmToolCall:(o,l)=>{console.warn("confirmToolCall: not implemented in SSE mode"),t(u=>{u.channels[o]&&u.channels[o].messages.forEach(d=>{d.toolCalls&&d.toolCalls.forEach(p=>{p.id===l&&p.status==="waiting_confirmation"&&(p.status="executing")})})})},cancelToolCall:(o,l)=>{console.warn("cancelToolCall: not implemented in SSE mode"),t(u=>{u.channels[o]&&u.channels[o].messages.forEach(d=>{d.toolCalls&&d.toolCalls.forEach(p=>{p.id===l&&p.status==="waiting_confirmation"&&(p.status="failed",p.error="用户取消执行")})})})}}}const KOn=["image/jpeg","image/jpg","image/png","image/gif","image/webp","application/pdf","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.openxmlformats-officedocument.presentationml.presentation","application/json","application/xml","application/x-yaml","text/plain","text/markdown","text/csv","text/html","text/xml","text/yaml","text/x-yaml","audio/mpeg","audio/wav","audio/wave","audio/x-wav",".csv",".docx",".htm",".html",".json",".md",".pdf",".pptx",".txt",".xlsx",".xml",".yaml",".yml"],ZOn=[".csv",".docx",".htm",".html",".json",".md",".pdf",".pptx",".txt",".xlsx",".xml",".yaml",".yml"];class XOn{appendUploadFields(e,n){e.append("file",n.file),e.append("scope",n.scope),n.category&&e.append("category",n.category),n.parentId&&e.append("parent_id",n.parentId),n.knowledgeSetId&&e.append("knowledge_set_id",n.knowledgeSetId),n.purpose&&e.append("purpose",n.purpose)}getUploadError(e){if(e.status===429)return new Error("Too many requests. Please wait a moment and try again.");try{const n=JSON.parse(e.responseText);if(typeof n.detail=="string"&&n.detail.trim())return new Error(n.detail)}catch{}return new Error(`Upload failed: ${e.statusText||`HTTP ${e.status}`}`)}uploadWithXhr(e,n){const r=new FormData;this.appendUploadFields(r,e);const i=new XMLHttpRequest,o=on.baseUrl;return{promise:new Promise((u,d)=>{i.upload.addEventListener("progress",m=>{if(n&&m.lengthComputable){const g=Math.round(m.loaded*100/m.total);n({loaded:m.loaded,total:m.total,percentage:g})}}),i.addEventListener("load",()=>{i.status>=200&&i.status<300?u(JSON.parse(i.responseText)):d(this.getUploadError(i))}),i.addEventListener("error",()=>{d(new Error("Upload failed"))}),i.addEventListener("abort",()=>{d(new Error("Upload cancelled"))}),i.open("POST",`${o}/xyzen/api/v1/files/upload`);const p=Eo.getToken();p&&i.setRequestHeader("Authorization",`Bearer ${p}`),i.send(r)}),abort:()=>i.abort()}}isAllowedType(e,n){return n.endsWith("/*")?e.type.startsWith(n.slice(0,-1)):n.startsWith(".")?e.name.toLowerCase().endsWith(n.toLowerCase()):e.type===n}uploadFileWithProgress(e,n="private",r,i,o,l){return this.uploadWithXhr({file:e,scope:n,category:r,parentId:i,knowledgeSetId:o},l)}async uploadFile(e,n="private",r,i,o,l){return this.uploadWithXhr({file:e,scope:n,category:r,parentId:i,knowledgeSetId:o},l).promise}async uploadChatAttachment(e,n="private",r,i,o,l){return this.uploadWithXhr({file:e,scope:n,category:r,parentId:i,knowledgeSetId:o,purpose:"chat_attachment"},l).promise}async getFile(e){return on.get(`/xyzen/api/v1/files/${e}`)}async listFiles(e){const n=new URLSearchParams;e&&(e.scope&&n.append("scope",e.scope),e.category&&n.append("category",e.category),e.include_deleted&&n.append("include_deleted","true"),e.limit&&n.append("limit",e.limit.toString()),e.offset&&n.append("offset",e.offset.toString()),e.parent_id&&n.append("parent_id",e.parent_id),e.filter_by_parent&&n.append("filter_by_parent","true"),e.is_dir!==void 0&&n.append("is_dir",e.is_dir.toString()),e.knowledge_set_id&&n.append("knowledge_set_id",e.knowledge_set_id));const r=n.toString()?"?"+n.toString():"";return on.get(`/xyzen/api/v1/files/${r}`)}async getFileUrl(e,n=3600){return on.get(`/xyzen/api/v1/files/${e}/url`,{params:{expires_in:n}})}async updateFile(e,n){return on.patch(`/xyzen/api/v1/files/${e}`,n)}async confirmFiles(e,n){await Promise.all(e.map(r=>this.updateFile(r,{message_id:n,status:"confirmed"})))}async deleteFile(e,n=!1){return on.delete(`/xyzen/api/v1/files/${e}`,void 0,{params:{hard_delete:n}})}async restoreFile(e){return on.post(`/xyzen/api/v1/files/${e}/restore`)}async getStorageStats(){return on.get("/xyzen/api/v1/files/stats/summary")}async getChatUploadCapabilities(){return on.get("/xyzen/api/v1/files/chat-upload-capabilities")}async emptyTrash(){return on.post("/xyzen/api/v1/files/empty-trash")}async bulkDeleteFiles(e){return on.delete("/xyzen/api/v1/files/bulk",e)}async updateFileContent(e,n,r){const i=new Blob([n],{type:r||"text/plain"}),o=new FormData;return o.append("file",i,"content"),on.put(`/xyzen/api/v1/files/${e}/content`,o)}async downloadRaw(e,n){return on.raw(`/xyzen/api/v1/files/${e}/download`,{signal:n?.signal})}validateFile(e,n={}){const{maxSize:r=100*1024*1024,allowedTypes:i=KOn}=n;return e.size>r?{valid:!1,reason:"file_too_large",maxSize:r,actualSize:e.size,error:`File size exceeds ${(r/(1024*1024)).toFixed(0)}MB limit`}:i.length>0&&!i.some(l=>this.isAllowedType(e,l))?{valid:!1,reason:"unsupported_type",fileType:e.type||"unknown",error:`File type ${e.type||"unknown"} is not supported`}:{valid:!0}}getFileCategory(e){if(e.type.startsWith("image/"))return"images";if(e.type.startsWith("audio/"))return"audio";const n=e.name.toLowerCase();return e.type.includes("pdf")||e.type.includes("text")||e.type.includes("document")||e.type.includes("sheet")||e.type.includes("presentation")||e.type.includes("json")||e.type.includes("xml")||e.type.includes("yaml")||ZOn.some(r=>n.endsWith(r))?"documents":"others"}getAttachmentAccessHint(e,n){const r=n||this.getFileCategory({name:e.name,type:e.type});return r==="images"||r==="audio"?"view":"read"}generateThumbnail(e){return new Promise((n,r)=>{if(!e.type.startsWith("image/")){r(new Error("File is not an image"));return}const i=160,o=URL.createObjectURL(e),l=new Image;l.onload=()=>{URL.revokeObjectURL(o);let u=l.width,d=l.height;u>d?u>i&&(d=Math.round(d*i/u),u=i):d>i&&(u=Math.round(u*i/d),d=i);const p=document.createElement("canvas");p.width=u,p.height=d;const m=p.getContext("2d");if(!m){r(new Error("Failed to get canvas context"));return}m.drawImage(l,0,0,u,d);const g=p.toDataURL("image/jpeg",.8);n(g)},l.onerror=()=>{URL.revokeObjectURL(o),r(new Error("Failed to load image"))},l.src=o})}}const ys=new XOn;class JOn{async editMessage(e,n){return on.patch(`/xyzen/api/v1/messages/${e}`,n)}async deleteMessage(e){return on.delete(`/xyzen/api/v1/messages/${e}`)}}const uot=new JOn;function eFn(t,e,n){const{updateDerivedStatus:r,waitForChannelConnection:i}=n;return{sendMessage:async o=>{const{activeChatChannel:l,uploadedFiles:u,clearFiles:d,isUploading:p,channels:m,connectToChannel:g,showNotification:h}=e();if(!l)return;if(p){console.warn("Cannot send message while files are uploading");return}const f=m[l];if(!f)return;if(f.responding){console.warn("Cannot send message while assistant is responding");return}Qb.hasConnection(l)||(g(f.sessionId,f.id),await i(l));const b=e().channels[l];if(!b?.connected){h("Connection not ready","Please wait for chat connection and try again.","warning");return}const y=EN(),v=u.filter(k=>k.status==="completed"&&k.uploadedId),_=v.map(k=>({id:k.uploadedId,name:k.file.name,type:k.file.type,size:k.file.size,category:ys.getFileCategory(k.file)}));t(k=>{const C=k.channels[l];C&&(C.responding=!0,C.messages.push({id:y,clientId:y,role:"user",content:o,created_at:new Date().toISOString(),status:"sending",isNewMessage:!0,..._.length>0?{attachments:_}:{}}))}),r();const w={message:o,client_id:y};v.length>0&&(w.file_ids=v.map(k=>k.uploadedId));const x=b;x?.knowledgeContext&&(w.context=x.knowledgeContext);try{await dg.sendMessage(l,w)}catch(k){console.error("Failed to send message via REST:",k),t(E=>{const S=E.channels[l];if(S){S.responding=!1;const I=S.messages.find(B=>B.clientId===y);I&&(I.status="failed")}}),r();const C=k instanceof Error&&"detail"in k?k.detail:void 0;if(C&&typeof C=="object"&&C.type==="parallel_chat_limit"){const E=C.data;e().showNotification(to.t("app.chat.parallelLimitTitle","Parallel chat limit reached"),to.t("app.chat.parallelLimitMessage","You have reached the parallel chat limit ({{current}}/{{limit}}). Please wait for other chats to finish.",{current:E?.current??"?",limit:E?.limit??"?"}),"warning")}else C&&typeof C=="object"&&C.error_code==="INSUFFICIENT_BALANCE"&&e().showNotification(to.t("app.chat.insufficientBalance","Insufficient balance"),to.t("app.chat.insufficientBalanceMessage","Your photon balance is insufficient. Please top up to continue."),"warning");return}d(!1)},startEditMessage:(o,l,u)=>{t({editingMessageId:o,editingContent:l,editingMode:u})},cancelEditMessage:()=>{t({editingMessageId:null,editingContent:"",editingMode:null})},submitEditMessage:async()=>{const{editingMessageId:o,editingContent:l,editingMode:u,activeChatChannel:d,channels:p}=e();if(!o||!d||!u)return;const m=p[d];if(!m)return;if(!m.messages.some(f=>f.id===o)){console.error("Message not found in active channel, skipping edit"),e().cancelEditMessage();return}const h=u==="edit_and_regenerate";try{const f=await uot.editMessage(o,{content:l,truncate_and_regenerate:h});t(b=>{const y=b.channels[d];if(!y)return;const v=y.messages.findIndex(_=>_.id===o);v!==-1&&(y.messages[v].content=f.message.content,y.messages[v].created_at=f.message.created_at,h&&(y.messages=y.messages.slice(0,v+1),y.responding=!1),b.editingMessageId=null,b.editingContent="",b.editingMode=null)}),f.regenerate&&e().triggerRegeneration()}catch(f){console.error("Failed to edit message:",f),e().showNotification("Error",to.t("app.message.editFailed"),"error")}},triggerRegeneration:()=>{const{activeChatChannel:o}=e();if(o){if(!Qb.hasConnection(o)){console.warn("[triggerRegeneration] No SSE connection, skipping");return}t(l=>{const u=l.channels[o];u&&(u.responding=!0)}),dg.regenerate(o).catch(l=>{console.error("Failed to trigger regeneration:",l),t(u=>{const d=u.channels[o];d&&(d.responding=!1)}),r()})}},deleteMessage:async o=>{const{activeChatChannel:l,channels:u}=e();if(!l)return;const d=u[l];if(!d)return;if(!Jit(o)){const g=d.messages.find(h=>h.id===o)?.status==="streaming"?to.t("app.message.deleteStillStreaming"):to.t("app.message.deleteNotSaved");console.error(`Cannot delete message: ${g} (id: ${o.slice(0,20)}...)`),e().showNotification(to.t("app.message.cannotDelete"),g,"warning");return}if(!d.messages.some(m=>m.id===o)){console.error("Message not found in active channel, skipping delete");return}try{await uot.deleteMessage(o),t(m=>{const g=m.channels[l];g&&(g.messages=g.messages.filter(h=>h.id!==o))})}catch(m){console.error("Failed to delete message:",m),e().showNotification("Error",to.t("app.message.deleteFailed"),"error")}},retryMessage:o=>{const{activeChatChannel:l,channels:u,sendMessage:d}=e();if(!l)return;const p=u[l];if(!p)return;const m=p.messages.find(h=>h.id===o);if(!m||m.status!=="failed")return;const g=m.content;t(h=>{const f=h.channels[l];f&&(f.messages=f.messages.filter(b=>b.id!==o))}),d(g)}}}const ite=50,tFn=(t,e)=>{const n=d=>d&&e().resolveAgent(d)?.name||"通用助理",r=async(d,p)=>{const m=Date.now();for(;Date.now()-m<=yOn;){const g=e().channels[d];if(g?.connected)return!0;if(g?.error)return p?.logFailure&&console.warn(`Connection failed for topic ${d}: ${g.error}`),!1;await new Promise(h=>{setTimeout(h,vOn)})}return p?.logFailure&&console.warn(`Connection timeout for topic ${d}`),!1},i=()=>{const d=e().respondingChannelIds;t(p=>{const m=new Set,g=new Set,h={};for(const b of Object.values(p.channels)){const y=oOn(b);(y==="running"||y==="stopping")&&(m.add(b.id),b.agentId&&g.add(b.agentId)),y==="running"&&b.agentId&&(h[b.agentId]=(h[b.agentId]||0)+1)}p.respondingChannelIds=m,p.runningAgentIds=g,p.activeTopicCountByAgent=h;const f=p.activeChatChannel;if(f){const b=d.has(f),y=m.has(f);b!==y&&console.debug(`[updateDerivedStatus] active channel ${f}: respondingChannelIds ${b} → ${y}`,`| channel.responding: ${p.channels[f]?.responding}`)}})},u={reconcileChannelFromBackend:async d=>{const{setLoading:p}=e(),m=`topicMessages-${d}`,g=e().channels[d];if(g?.responding){console.debug(`[reconcile] SKIP — channel is responding, topic=${d.slice(0,8)} msgs=${g.messages.length}`);return}console.groupCollapsed(`[reconcile] topic=${d.slice(0,8)} responding=${g?.responding} msgs=${g?.messages.length}`),console.debug(new Error().stack?.split(`
110
110
  `).slice(1,5).join(" <- ")),p(m,!0);try{const[h,f]=await Promise.all([dg.getMessages(d,{limit:ite}),dg.getTokenStats(d).catch(()=>null)]),b=Mxe(h);t(y=>{const v=y.channels[d];if(v){const _=new Set(b.map(E=>E.id)),w=v.messages.filter(E=>_.has(E.id)||E.dbId&&_.has(E.dbId)?!1:!!(E.status==="pending"||E.status==="streaming"||E.status==="thinking"||E.agentExecution)),x=new Set,k=[];for(const E of w){let S=-1;if(E.role==="assistant"){for(let I=b.length-1;I>=0;I--)if(b[I].role==="assistant"&&!x.has(I)){S=I;break}}if(S!==-1){const I=b[S];I.streamId=E.streamId,I.status=E.status,I.agentExecution=E.agentExecution,I.thinkingContent=E.thinkingContent,x.add(S)}else k.push(E)}const C=[...b,...k];console.debug(`[reconcile] OVERWRITE topic=${d.slice(0,8)} oldMsgs=${v.messages.length} dbMsgs=${b.length} preserved=${w.length} merged=${w.length-k.length} new=${k.length} responding=${v.responding}`),v.messages=C,v.hasOlderMessages=h.length>=ite,f?.total_tokens!=null&&(v.tokenUsage=f.total_tokens),jxe(v)}}),i()}catch(h){console.error("Failed to reconcile topic messages:",h)}finally{console.groupEnd(),p(m,!1)}},updateDerivedStatus:i,closeIdleNonPrimaryConnection:d=>{setTimeout(()=>{e().channels[d]?.responding||e().activeChatChannel===d||Qb.disconnect(d)},0)},getAgentNameById:n,waitForChannelConnection:r};return{activeChatChannel:null,activeTopicByAgent:{},chatHistory:[],chatHistoryLoading:!0,channels:{},respondingChannelIds:new Set,runningAgentIds:new Set,activeTopicCountByAgent:{},notification:null,editingMessageId:null,editingContent:"",editingMode:null,setKnowledgeContext:(d,p)=>{t(m=>{m.channels[d]&&(m.channels[d].knowledgeContext=p||void 0)})},showNotification:(d,p,m="info",g,h)=>{t(f=>{f.notification={isOpen:!0,title:d,message:p,type:m,actionLabel:g,onAction:h}})},closeNotification:()=>{t({notification:null})},loadOlderMessages:async d=>{const p=e().channels[d];if(!p||p.loadingOlderMessages||!p.hasOlderMessages)return;const m=p.messages.find(g=>g.id);if(m?.id){t(g=>{const h=g.channels[d];h&&(h.loadingOlderMessages=!0)});try{const g=await dg.getMessages(d,{before:m.id,limit:ite}),h=Mxe(g);t(f=>{const b=f.channels[d];if(b){const y=new Set(b.messages.map(_=>_.id)),v=h.filter(_=>!y.has(_.id));b.messages=[...v,...b.messages],b.hasOlderMessages=g.length>=ite,b.loadingOlderMessages=!1}})}catch(g){console.error("Failed to load older messages:",g),t(h=>{const f=h.channels[d];f&&(f.loadingOlderMessages=!1)})}}},..._On(t,e,u),...eFn(t,e,u),...VOn(t,e,u)}},nFn={maxSize:10*1024*1024,maxFiles:5,maxTotalSize:20*1024*1024,allowedTypes:["image/jpeg","image/jpg","image/png","image/gif","image/webp","application/pdf","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.openxmlformats-officedocument.presentationml.presentation","application/json","application/xml","application/x-yaml","text/plain","text/markdown","text/csv","text/html","text/xml","text/yaml","text/x-yaml","audio/mpeg","audio/wav","audio/wave","audio/x-wav",".csv",".docx",".htm",".html",".json",".md",".pdf",".pptx",".txt",".xlsx",".xml",".yaml",".yml"],autoUpload:!0};function IN(t){return(t/(1024*1024)).toFixed(1)}function dot(t){const e=t.slice(0,3).map(r=>r.name).join(", "),n=t.length>3?to.t("app.input.moreFilesSuffix",{count:t.length-3}):"";return e+n}function pot(t,e){switch(e.reason){case"file_too_large":return to.t("app.input.fileTooLargeDetail",{name:t.name,maxSize:IN(e.maxSize??t.size),actualSize:IN(e.actualSize??t.size)});case"unsupported_type":return to.t("app.input.unsupportedFileTypeDetail",{name:t.name});default:return e.error||t.name}}const rFn=(t,e)=>({uploadedFiles:[],isUploading:!1,uploadError:null,fileUploadOptions:{...nFn},validateFiles:n=>{const r=e(),i=r.fileUploadOptions,o=r.uploadedFiles,l=[];o.length+n.length>(i.maxFiles||5)&&l.push(`Maximum ${i.maxFiles} files allowed. You have ${o.length} files and are trying to add ${n.length} more.`);for(const m of n){const g=ys.validateFile(m,{maxSize:i.maxSize,allowedTypes:i.allowedTypes});g.valid||l.push(pot(m,g))}const u=r.getTotalSize(),d=n.reduce((m,g)=>m+g.size,0),p=u+d;return p>(i.maxTotalSize||20*1024*1024)&&l.push(to.t("app.input.totalSizeExceededMessage",{maxSize:IN(i.maxTotalSize||20*1024*1024),actualSize:IN(p)})),{valid:l.length===0,errors:l.length>0?l:void 0,error:l.length>0?l.join("; "):void 0}},addFiles:async n=>{const r=e(),i=r.fileUploadOptions,o=r.uploadedFiles,l=[],u=[],d=[];for(const C of n){const E=ys.validateFile(C,{maxSize:i.maxSize,allowedTypes:i.allowedTypes});E.valid?l.push(C):(u.push({file:C,validation:E}),d.push(pot(C,E)))}const p=u.filter(({validation:C})=>C.reason==="file_too_large").map(({file:C})=>C);p.length>0&&e().showNotification(to.t("app.input.fileTooLargeTitle"),to.t("app.input.fileTooLargeMessage",{files:dot(p),maxSize:IN(i.maxSize||10*1024*1024)}),"warning");const m=u.filter(({validation:C})=>C.reason==="unsupported_type").map(({file:C})=>C);m.length>0&&e().showNotification(to.t("app.input.unsupportedFilesTitle"),to.t("app.input.unsupportedFilesMessage",{files:dot(m)}),"warning");const g=Math.max(0,(i.maxFiles||5)-o.length);if(g===0){const C=to.t("app.dragDrop.maxReached");t({uploadError:C}),e().showNotification(to.t("app.input.fileLimitTitle"),C,"warning");return}const h=l.slice(0,g);l.slice(g).length>0&&e().showNotification(to.t("app.input.fileLimitTitle"),to.t("app.input.fileLimitMessage",{count:g}),"warning");const b=i.maxTotalSize||20*1024*1024,y=r.getTotalSize(),v=y+h.reduce((C,E)=>C+E.size,0);let _=y;const w=[],x=[];for(const C of h){if(_+C.size>b){x.push(C);continue}w.push(C),_+=C.size}if(x.length>0){const C=to.t("app.input.totalSizeExceededMessage",{maxSize:IN(b),actualSize:IN(v)});t({uploadError:C}),e().showNotification(to.t("app.input.totalSizeExceededTitle"),C,"warning")}if(w.length===0){d.length>0&&t({uploadError:d.join("; ")});return}const k=w.map(C=>({id:`${Date.now()}-${Math.random().toString(36).slice(2,9)}`,file:C,name:C.name,size:C.size,type:C.type,category:ys.getFileCategory(C),status:"pending",progress:0,createdAt:new Date}));if(t(C=>({uploadedFiles:[...C.uploadedFiles,...k],uploadError:d.length>0?d.join("; "):null})),r.fileUploadOptions.autoUpload)for(const C of k)await r.uploadFile(C.file)},uploadFile:async n=>{const i=e().uploadedFiles.find(o=>o.file===n);if(!i)return null;try{if(t(p=>({uploadedFiles:p.uploadedFiles.map(m=>m.id===i.id?{...m,status:"uploading",progress:0}:m),isUploading:!0})),n.type.startsWith("image/"))try{const p=await ys.generateThumbnail(n);t(m=>({uploadedFiles:m.uploadedFiles.map(g=>g.id===i.id?{...g,thumbnailUrl:p}:g)}))}catch(p){console.warn("Failed to generate thumbnail:",p)}const o=e().activeChatChannel,u=(o?e().channels[o]:null)?.knowledge_set_id??null,d=await ys.uploadChatAttachment(n,"private",i.category,null,u,p=>{t(m=>({uploadedFiles:m.uploadedFiles.map(g=>g.id===i.id?{...g,progress:p.percentage}:g)}))});return t(p=>({uploadedFiles:p.uploadedFiles.map(m=>m.id===i.id?{...m,status:"completed",progress:100,uploadedId:d.id,downloadUrl:d.download_url}:m),isUploading:p.uploadedFiles.some(m=>m.id!==i.id&&m.status==="uploading")})),d.id}catch(o){const l=o instanceof Error?o.message:"Upload failed";return t(u=>({uploadedFiles:u.uploadedFiles.map(d=>d.id===i.id?{...d,status:"error",error:l}:d),isUploading:u.uploadedFiles.some(d=>d.id!==i.id&&d.status==="uploading"),uploadError:l})),null}},removeFile:n=>{const i=e().uploadedFiles.find(o=>o.id===n);i?.uploadedId&&ys.deleteFile(i.uploadedId,!1).catch(o=>{console.error("Failed to delete file from server:",o)}),t(o=>({uploadedFiles:o.uploadedFiles.filter(l=>l.id!==n)}))},clearFiles:(n=!1)=>{const r=e();if(n){const i=r.uploadedFiles.filter(o=>o.uploadedId).map(o=>o.uploadedId);i.length>0&&ys.bulkDeleteFiles(i).catch(o=>{console.error("Failed to delete files from server:",o)})}t({uploadedFiles:[],isUploading:!1,uploadError:null})},confirmFilesForMessage:async n=>{const i=e().uploadedFiles.filter(o=>o.uploadedId&&o.status==="completed").map(o=>o.uploadedId);if(i.length>0)try{await ys.confirmFiles(i,n),t({uploadedFiles:[]})}catch(o){throw console.error("Failed to confirm files:",o),o}},cancelUpload:n=>{t(r=>({uploadedFiles:r.uploadedFiles.map(i=>i.id===n?{...i,status:"error",error:"Cancelled"}:i)}))},retryUpload:async n=>{const r=e(),i=r.uploadedFiles.find(o=>o.id===n);i&&await r.uploadFile(i.file)},updateFileUploadOptions:n=>{t(r=>({fileUploadOptions:{...r.fileUploadOptions,...n}}))},getTotalSize:()=>e().uploadedFiles.reduce((r,i)=>r+i.size,0),canAddMoreFiles:()=>{const n=e();return n.uploadedFiles.length<(n.fileUploadOptions.maxFiles||5)}});class aFn{async createFolder(e){return on.post("/xyzen/api/v1/folders/",e)}async listFolders(e=null,n=!1,r){return on.get("/xyzen/api/v1/folders/",{params:{parent_id:e??void 0,include_deleted:n||void 0,knowledge_set_id:r}})}async getTree(e,n){return on.get("/xyzen/api/v1/folders/tree",{params:{knowledge_set_id:e,only_deleted:n||void 0}})}async getFolder(e){return on.get(`/xyzen/api/v1/folders/${e}`)}async getFolderPath(e){return on.get(`/xyzen/api/v1/folders/${e}/path`)}async updateFolder(e,n){return on.patch(`/xyzen/api/v1/folders/${e}`,n)}async deleteFolder(e,n=!1){return on.delete(`/xyzen/api/v1/folders/${e}`,void 0,{params:{hard_delete:n}})}}const uf=new aFn,iFn=(t,e)=>({knowledgeActiveTab:"home",knowledgeFolderId:null,knowledgeSetId:null,knowledgeTreeItems:[],knowledgeTreeLoading:!1,knowledgeTreeSignal:0,trashTreeItems:[],trashTreeLoading:!1,navigateKnowledge:(n,r=null)=>{t(i=>{i.knowledgeActiveTab=n,i.knowledgeSetId=n==="knowledge"?r??null:null,i.knowledgeFolderId=null})},setKnowledgeFolderId:n=>{t(r=>{r.knowledgeFolderId=n})},fetchKnowledgeTree:async()=>{const{knowledgeActiveTab:n,knowledgeSetId:r}=e();if(n==="trash"){t(i=>{i.trashTreeLoading=!0});try{const i=await uf.getTree(void 0,!0);t(o=>{o.trashTreeItems=i,o.trashTreeLoading=!1})}catch(i){console.error("Failed to fetch trash tree",i),t(o=>{o.trashTreeLoading=!1})}return}if(!(n!=="all"&&n!=="knowledge"&&n!=="images"&&n!=="documents")){if(n==="knowledge"&&!r){t(i=>{i.knowledgeTreeItems=[],i.knowledgeTreeLoading=!1});return}t(i=>{i.knowledgeTreeLoading=!0});try{const i=n==="knowledge"?r??void 0:void 0,o=await uf.getTree(i);t(l=>{l.knowledgeTreeItems=o,l.knowledgeTreeLoading=!1})}catch(i){console.error("Failed to fetch knowledge tree",i),t(o=>{o.knowledgeTreeLoading=!1})}}},refreshKnowledge:()=>{t(n=>{n.knowledgeTreeSignal+=1})},removeTreeItems:n=>{t(r=>{const i=new Set(n);r.knowledgeActiveTab==="trash"?r.trashTreeItems=r.trashTreeItems.filter(o=>!i.has(o.id)):r.knowledgeTreeItems=r.knowledgeTreeItems.filter(o=>!i.has(o.id))})},renameTreeItem:(n,r)=>{t(i=>{const l=(i.knowledgeActiveTab==="trash"?i.trashTreeItems:i.knowledgeTreeItems).find(u=>u.id===n);l&&(l.name=r)})}}),oFn=(t,e)=>({loadingStates:{},setLoading:(n,r)=>{t(i=>{r?i.loadingStates[n]=!0:delete i.loadingStates[n]})},getLoading:n=>e().loadingStates[n]||!1,clearAllLoading:()=>{t(n=>{n.loadingStates={}})}}),BA={MCP_SERVERS:"mcpServers",MCP_SERVER_CREATE:"mcpServerCreate",MCP_SERVER_UPDATE:"mcpServerUpdate",MCP_SERVER_DELETE:"mcpServerDelete"},b1={async getMcpServers(){return on.get("/xyzen/api/v1/mcps")},async createMcpServer(t){return on.post("/xyzen/api/v1/mcps",t)},async updateMcpServer(t,e){return on.patch(`/xyzen/api/v1/mcps/${t}`,e)},async deleteMcpServer(t){return on.delete(`/xyzen/api/v1/mcps/${t}`)},async refreshMcpServers(){return on.post("/xyzen/api/v1/mcps/refresh")},async activateSmitheryServer(t,e){return on.post("/xyzen/api/v1/mcps/smithery/activate",{qualifiedName:t,profile:e})},async getBuiltinMcpServers(){try{return await on.get("/xyzen/api/v1/mcps/discover")}catch(t){return console.warn("Error discovering builtin MCP servers:",t),[]}},async getBuiltinSearchServers(){try{return await on.get("/xyzen/api/v1/mcps/search-servers/discover")}catch(t){return console.warn("Error discovering builtin search servers:",t),[]}},async getSearchServers(){return on.get("/xyzen/api/v1/mcps")},async getSessionSearchEngine(t){try{return await on.get(`/xyzen/api/v1/sessions/${t}/search-engine`)}catch(e){if(e instanceof Error&&"status"in e&&e.status===404)return null;throw e}},async setSessionSearchEngine(t,e){return on.put(`/xyzen/api/v1/sessions/${t}/search-engine`,{mcp_server_id:e})},async removeSessionSearchEngine(t){return on.delete(`/xyzen/api/v1/sessions/${t}/search-engine`)},async testTool(t,e,n){return on.post(`/xyzen/api/v1/mcps/${t}/tools/${e}/test`,{parameters:n})}};function sFn(t){if("data"in t&&"source"in t&&t.source==="official")return t;const e=t,n={name:e.name,module_name:e.module_name,mount_path:e.mount_path,description:e.description,is_builtin:!0,requires_auth:e.requires_auth||!1,is_default:e.is_default,banner:e.banner};return{id:e.module_name,name:e.name,description:e.description,source:"official",cover:e.banner,data:n}}function lFn(t){return Array.isArray(t)?t.filter(e=>e&&typeof e=="object").map(e=>sFn(e)):(console.warn("convertBuiltinServers: input is not an array",t),[])}const cFn=(t,e)=>({mcpServers:[],builtinMcpServers:[],lastFetchTime:0,isEditMcpServerModalOpen:!1,editingMcpServer:null,openEditMcpServerModal:n=>{t({isEditMcpServerModalOpen:!0,editingMcpServer:n})},closeEditMcpServerModal:()=>{t({isEditMcpServerModalOpen:!1,editingMcpServer:null})},fetchMcpServers:async()=>{const{setLoading:n}=e(),r=Date.now(),{lastFetchTime:i}=e();if(r-i<5e3){console.log("McpSlice: 使用缓存的MCP服务器数据");return}n(BA.MCP_SERVERS,!0);try{console.log("McpSlice: Starting to fetch MCP servers...");const o=await b1.getMcpServers();console.log(`McpSlice: Loaded ${o.length} MCP servers`),t({mcpServers:o,lastFetchTime:r})}catch(o){console.error("Failed to fetch MCP servers:",o)}finally{n(BA.MCP_SERVERS,!1)}},fetchBuiltinMcpServers:async()=>{try{const n=await b1.getBuiltinMcpServers(),r=lFn(n),{mcpServers:i,backendUrl:o}=e(),l=i.map(d=>d.url),u=r.filter(d=>{const p=d.data.mount_path.endsWith("/")?d.data.mount_path:`${d.data.mount_path}/`,m=`${o}${p}`;return!l.includes(m)});t({builtinMcpServers:u})}catch(n){console.error("Failed to fetch builtin MCP servers:",n),t({builtinMcpServers:[]})}},refreshMcpServers:async()=>{const{setLoading:n}=e();n(BA.MCP_SERVERS,!0);try{await b1.refreshMcpServers(),setTimeout(()=>{e().fetchMcpServers()},1e3)}catch(r){console.error("Failed to refresh MCP servers:",r)}finally{setTimeout(()=>n(BA.MCP_SERVERS,!1),1500)}},addMcpServer:async n=>{const{setLoading:r}=e();r(BA.MCP_SERVER_CREATE,!0);try{const i=await b1.createMcpServer(n);t(o=>{o.mcpServers.push(i)}),e().closeAddMcpServerModal()}catch(i){throw console.error("Failed to add MCP server:",i),i}finally{r(BA.MCP_SERVER_CREATE,!1)}},quickAddBuiltinServer:async n=>{const{backendUrl:r,token:i,setLoading:o}=e();o(BA.MCP_SERVER_CREATE,!0);try{const l=n.data.mount_path.endsWith("/")?n.data.mount_path:`${n.data.mount_path}/`,u={name:n.name,description:n.description,url:`${r}${l}`,token:i||""},d=await b1.createMcpServer(u);return t(p=>{p.mcpServers.push(d),p.builtinMcpServers=p.builtinMcpServers.filter(m=>m.data.module_name!==n.data.module_name)}),e().closeAddMcpServerModal(),d}catch(l){throw console.error("Failed to add builtin MCP server:",l),l}finally{o(BA.MCP_SERVER_CREATE,!1)}},activateSmitheryServer:async(n,r)=>{const{setLoading:i}=e();i(BA.MCP_SERVER_CREATE,!0);try{const o=await b1.activateSmitheryServer(n,r);t(l=>{l.mcpServers.push(o)}),e().closeAddMcpServerModal()}catch(o){throw console.error("Failed to activate Smithery MCP server:",o),o}finally{i(BA.MCP_SERVER_CREATE,!1)}},editMcpServer:async(n,r)=>{const{setLoading:i}=e();i(BA.MCP_SERVER_UPDATE,!0);try{const o=await b1.updateMcpServer(n,r);t(l=>{const u=l.mcpServers.findIndex(d=>d.id===n);u!==-1&&(l.mcpServers[u]=o)})}catch(o){throw console.error("Failed to edit MCP server:",o),o}finally{i(BA.MCP_SERVER_UPDATE,!1)}},removeMcpServer:async n=>{const{setLoading:r}=e();r(BA.MCP_SERVER_DELETE,!0);try{await b1.deleteMcpServer(n),t(i=>{i.mcpServers=i.mcpServers.filter(o=>o.id!==n)})}catch(i){throw console.error("Failed to remove MCP server:",i),i}finally{r(BA.MCP_SERVER_DELETE,!1)}},updateMcpServerInList:n=>{t(r=>{const i=r.mcpServers.findIndex(o=>o.id===n.id);i!==-1?r.mcpServers[i]=n:r.mcpServers.push(n)})}}),uFn=(t,e)=>({toolTestModal:{isOpen:!1},toolExecutionHistory:[],openToolTestModal:(n,r,i)=>{t(o=>{o.toolTestModal={isOpen:!0,server:n,toolName:r,toolDescription:i}})},closeToolTestModal:()=>{t(n=>{n.toolTestModal={isOpen:!1}})},addToolExecution:n=>{t(r=>{const i={...n,id:`${Date.now()}-${Math.random().toString(36).substr(2,9)}`,timestamp:new Date};r.toolExecutionHistory.unshift(i),r.toolExecutionHistory.length>100&&(r.toolExecutionHistory=r.toolExecutionHistory.slice(0,100))})},clearToolExecutionHistory:()=>{t(n=>{n.toolExecutionHistory=[]})},getToolExecutionHistory:(n,r)=>{const{toolExecutionHistory:i}=e();return!n&&!r?i:i.filter(o=>{const l=!n||o.serverId===n,u=!r||o.toolName===r;return l&&u})}}),dFn=t=>({notificationEnabled:!1,novuAppIdentifier:"",novuApiUrl:"",novuWsUrl:"",pushPermission:typeof Notification<"u"&&typeof Notification.permission=="string"?Notification.permission:"default",pushSubscribed:!1,setNotificationConfig:(e,n,r,i)=>{t(o=>{o.notificationEnabled=e,o.novuAppIdentifier=n,o.novuApiUrl=r,o.novuWsUrl=i})},setPushPermission:e=>{t(n=>{n.pushPermission=e})},setPushSubscribed:e=>{t(n=>{n.pushSubscribed=e})}});class qxe{static STORAGE_KEY="xyzen_provider_preferences";static getPreferences(){try{const e=localStorage.getItem(this.STORAGE_KEY);if(e){const n=JSON.parse(e);return{defaultProviderId:n.defaultProviderId||null,lastUsedProviders:n.lastUsedProviders||{}}}}catch(e){console.warn("Failed to load provider preferences:",e)}return{defaultProviderId:null,lastUsedProviders:{}}}static savePreferences(e){try{localStorage.setItem(this.STORAGE_KEY,JSON.stringify(e))}catch(n){console.error("Failed to save provider preferences:",n)}}static setDefaultProvider(e){const n=this.getPreferences();n.defaultProviderId=e,this.savePreferences(n)}static getDefaultProviderId(){return this.getPreferences().defaultProviderId}static getDefaultProvider(e){const n=this.getDefaultProviderId();return n&&e.find(r=>r.id===n)||null}static setLastUsedProviderForAgent(e,n){const r=this.getPreferences();r.lastUsedProviders[e]=n,this.savePreferences(r)}static getLastUsedProviderForAgent(e){return this.getPreferences().lastUsedProviders[e]||null}static clearPreferences(){try{localStorage.removeItem(this.STORAGE_KEY)}catch(e){console.error("Failed to clear provider preferences:",e)}}static migrateFromDatabaseDefault(e){if(!this.getPreferences().defaultProviderId){const r=e.find(i=>i.is_default&&!i.is_system);r&&(console.info("Migrating database default provider to local preferences:",r.name),this.setDefaultProvider(r.id))}}}function pFn(t,e){if(t?.provider_id){const o=e.find(l=>l.id===t.provider_id);if(o)return o}const n=qxe.getDefaultProvider(e);if(n&&!n.is_system)return n;const r=e.find(o=>o.is_system);return r||e.filter(o=>!o.is_system)[0]||null}const mFn=(t,e)=>({userDefaultProviderId:null,initializeProviderPreferences:()=>{const n=qxe.getDefaultProviderId();t({userDefaultProviderId:n})},setUserDefaultProvider:n=>{qxe.setDefaultProvider(n),t({userDefaultProviderId:n})},getUserDefaultProvider:n=>{const{userDefaultProviderId:r}=e();return r&&n.find(i=>i.id===r)||null},resolveProviderForAgent:(n,r)=>pFn(n,r),llmProviders:[],llmProvidersLoading:!1,providerTemplates:[],templatesLoading:!1,availableModels:{},availableModelsLoading:!1,fetchProviderTemplates:async()=>{console.warn("[DEPRECATED] fetchProviderTemplates is deprecated. Use useProviderTemplates() hook instead.")},fetchMyProviders:async()=>{console.warn("[DEPRECATED] fetchMyProviders is deprecated. Use useMyProviders() hook instead."),e().initializeProviderPreferences()},fetchAvailableModels:async()=>{console.warn("[DEPRECATED] fetchAvailableModels is deprecated. Use useAvailableModels() hook instead.")},addProvider:async()=>{throw console.warn("[DEPRECATED] addProvider is deprecated. Use useCreateProvider().mutateAsync instead."),new Error("addProvider is deprecated. Use useCreateProvider().mutateAsync instead.")},updateProvider:async()=>{throw console.warn("[DEPRECATED] updateProvider is deprecated. Use useUpdateProvider().mutateAsync instead."),new Error("updateProvider is deprecated. Use useUpdateProvider().mutateAsync instead.")},removeProvider:async()=>{throw console.warn("[DEPRECATED] removeProvider is deprecated. Use useDeleteProvider().mutateAsync instead."),new Error("removeProvider is deprecated. Use useDeleteProvider().mutateAsync instead.")}});class gFn{async listRunners(){return on.get("/xyzen/api/v1/runners/")}async createRunnerToken(e){return on.post("/xyzen/api/v1/runners/token",{name:e})}async updateRunner(e,n){return on.patch(`/xyzen/api/v1/runners/${e}`,n)}async deleteRunner(e){return on.delete(`/xyzen/api/v1/runners/${e}`)}}const ote=new gFn;class hFn{ws=null;handlers=new Map;reconnectTimer=null;reconnectDelay=1e3;maxReconnectDelay=3e4;intentionalClose=!1;connect(){if(this.ws?.readyState===WebSocket.OPEN)return;const e=Eo.getToken();if(!e)return;const n=Ed().env.backendUrl;if(!n)return;const r=`${n.replace(/^http(s?):\/\//,"ws$1://")}/xyzen/ws/v1/user/events?token=${encodeURIComponent(e)}`;this.intentionalClose=!1;try{this.ws=new WebSocket(r)}catch{this.scheduleReconnect();return}this.ws.onopen=()=>{this.reconnectDelay=1e3},this.ws.onmessage=i=>{try{const o=JSON.parse(i.data);if(o.type==="pong")return;const l=this.handlers.get(o.type);if(l)for(const u of l)u(o)}catch{}},this.ws.onclose=()=>{this.ws=null,this.intentionalClose||this.scheduleReconnect()},this.ws.onerror=()=>{}}disconnect(){this.intentionalClose=!0,this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.ws&&(this.ws.close(),this.ws=null)}on(e,n){let r=this.handlers.get(e);return r||(r=new Set,this.handlers.set(e,r)),r.add(n),()=>{r.delete(n),r.size===0&&this.handlers.delete(e)}}scheduleReconnect(){this.reconnectTimer||(this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.reconnectDelay=Math.min(this.reconnectDelay*2,this.maxReconnectDelay),this.connect()},this.reconnectDelay))}}const RP=new hFn,fFn=t=>({runners:[],runnersLoading:!1,fetchRunners:async()=>{t({runnersLoading:!0});try{const e=await ote.listRunners();t({runners:e,runnersLoading:!1})}catch{t({runnersLoading:!1})}},createRunnerToken:async e=>{try{const n=await ote.createRunnerToken(e);return t(r=>{r.runners.unshift(n.runner)}),{token:n.token,connect_command:n.connect_command}}catch{return null}},deleteRunner:async e=>{try{await ote.deleteRunner(e),t(n=>{n.runners=n.runners.filter(r=>r.id!==e)})}catch{}},updateRunner:async(e,n)=>{try{const r=await ote.updateRunner(e,n);t(i=>{const o=i.runners.findIndex(l=>l.id===e);o>=0&&(i.runners[o]=r)})}catch{}},connectRunnerEvents:()=>{RP.connect();const e=RP.on("runner_status",n=>{const{runner_id:r,is_online:i}=n.data;t(o=>{const l=o.runners.find(u=>u.id===r);l&&(l.is_online=i)})});return()=>{e(),RP.disconnect()}}}),AFn=t=>({isTerminalOpen:!1,activeSessionId:null,terminalSessions:{},pendingCommand:"",pendingArgs:[],pendingRunnerId:null,openTerminal:(e="",n=[],r)=>{t(i=>{i.isTerminalOpen=!0,i.pendingCommand=e,i.pendingArgs=n,i.pendingRunnerId=r??null})},closeTerminalModal:()=>{t(e=>{e.isTerminalOpen=!1})},addSession:e=>{t(n=>{n.terminalSessions[e.id]=e,n.activeSessionId=e.id})},updateSession:(e,n)=>{t(r=>{const i=r.terminalSessions[e];i&&Object.assign(i,n)})},removeSession:e=>{t(n=>{if(delete n.terminalSessions[e],n.activeSessionId===e){const r=Object.keys(n.terminalSessions);n.activeSessionId=r.length>0?r[0]:null}})},setActiveSession:e=>{t({activeSessionId:e})}}),mot={Sidebar:"sidebar"},bFn=t=>({backendUrl:Ed().env.backendUrl,isXyzenOpen:!1,panelWidth:Uxe,activeTabIndex:0,activePanel:"chat",theme:Ed().storage.getItem("theme")||"system",layoutStyle:Ed().storage.getItem("layoutStyle")||Ed().env.layoutStyle||mot.Sidebar,inputPosition:Ed().storage.getItem("inputPosition")||"bottom",isMcpListModalOpen:!1,isLlmProvidersModalOpen:!1,isAddMcpServerModalOpen:!1,isAddLlmProviderModalOpen:!1,isSettingsModalOpen:!1,activeSettingsCategory:"account",activeUiSetting:"theme",selectedProviderId:null,pendingInput:"",spatialSidebarCollapsed:!1,capsuleOpen:!1,capsuleActiveTab:"knowledge",showOfficialRecommendations:Ed().storage.getItem("officialRecommendationsDismissed")!=="true",mobileCeoOverlay:!0,mobilePage:0,pendingFocusAgentId:null,highlightMessageId:null,dockMinimized:!1,openTabsByAgent:{},toggleXyzen:()=>t(e=>({isXyzenOpen:!e.isXyzenOpen})),openXyzen:()=>t({isXyzenOpen:!0}),closeXyzen:()=>t({isXyzenOpen:!1}),setPanelWidth:e=>t({panelWidth:e}),setTabIndex:e=>t({activeTabIndex:e}),setActivePanel:e=>t({activePanel:e}),setTheme:e=>{Ed().storage.setItem("theme",e),t({theme:e})},setLayoutStyle:e=>{Ed().storage.setItem("layoutStyle",e),t({layoutStyle:e})},setInputPosition:e=>{Ed().storage.setItem("inputPosition",e),t({inputPosition:e})},setBackendUrl:e=>{Ed().env.backendUrl=e,t({backendUrl:e})},openMcpListModal:()=>t({isMcpListModalOpen:!0}),closeMcpListModal:()=>t({isMcpListModalOpen:!1}),openLlmProvidersModal:()=>t({isLlmProvidersModalOpen:!0}),closeLlmProvidersModal:()=>t({isLlmProvidersModalOpen:!1}),openAddMcpServerModal:()=>t({isAddMcpServerModalOpen:!0}),closeAddMcpServerModal:()=>t({isAddMcpServerModalOpen:!1}),openAddLlmProviderModal:()=>t({isAddLlmProviderModalOpen:!0}),closeAddLlmProviderModal:()=>t({isAddLlmProviderModalOpen:!1}),openSettingsModal:(e="account")=>t({isSettingsModalOpen:!0,activeSettingsCategory:e}),closeSettingsModal:()=>t({isSettingsModalOpen:!1,selectedProviderId:null}),setActiveSettingsCategory:e=>t({activeSettingsCategory:e}),setActiveUiSetting:e=>t({activeUiSetting:e}),setSelectedProvider:e=>t({selectedProviderId:e}),setPendingInput:e=>t({pendingInput:e}),submitInput:()=>t(()=>({isXyzenOpen:!0,activeTabIndex:1,activePanel:"chat"})),setSpatialSidebarCollapsed:e=>t({spatialSidebarCollapsed:e}),setCapsuleOpen:e=>t({capsuleOpen:e}),setCapsuleActiveTab:e=>t({capsuleActiveTab:e}),setShowOfficialRecommendations:e=>{Ed().storage.setItem("officialRecommendationsDismissed",e?"false":"true"),t({showOfficialRecommendations:e})},setMobileCeoOverlay:e=>t({mobileCeoOverlay:e}),setMobilePage:e=>t({mobilePage:e}),requestFocusAgent:e=>t({pendingFocusAgentId:e}),highlightMessage:e=>t({highlightMessageId:e}),openTab:(e,n)=>t(r=>{const i=r.openTabsByAgent[e]??[];i.some(o=>o.id===n.id)||(r.openTabsByAgent[e]=[...i,n])}),closeTab:(e,n)=>t(r=>{const i=r.openTabsByAgent[e];i&&(r.openTabsByAgent[e]=i.filter(o=>o.id!==n))}),setOpenTabs:(e,n)=>t(r=>{r.openTabsByAgent[e]=n}),setDockMinimized:e=>t({dockMinimized:e}),renameTab:(e,n)=>t(r=>{for(const i of Object.values(r.openTabsByAgent)){const o=i.find(l=>l.id===e);if(o){o.name=n;break}}})});class yFn{async redeemCode(e){return on.post("/xyzen/api/v1/redemption/redeem",{code:e})}async getUserWallet(){return on.get("/xyzen/api/v1/redemption/wallet")}async getRedemptionHistory(e=100,n=0){return on.get("/xyzen/api/v1/redemption/history",{params:{limit:e,offset:n}})}async getDailyTokenStats(e,n,r){return on.get("/xyzen/api/v1/redemption/admin/stats/daily-tokens",{auth:!1,headers:{"X-Admin-Secret":e},params:{date:n,tz:r}})}async getTopUsersByConsumption(e,n=20){return on.get("/xyzen/api/v1/redemption/admin/stats/top-users",{auth:!1,headers:{"X-Admin-Secret":e},params:{limit:n}})}async getConsumeRecords(e,n,r,i,o=1e4,l=0){return on.get("/xyzen/api/v1/redemption/admin/stats/consume-records",{auth:!1,headers:{"X-Admin-Secret":e},params:{start_date:n,end_date:r,tz:i,limit:o,offset:l}})}async getAllConsumeRecords(e,n,r,i,o=1e4){const l=[];let u=0;for(;;){const d=await this.getConsumeRecords(e,n,r,i,o,u);if(l.push(...d),d.length<o)break;u+=o}return l}async getUserActivityStats(e,n,r,i){return on.get("/xyzen/api/v1/redemption/admin/stats/user-activity",{auth:!1,headers:{"X-Admin-Secret":e},params:{start_date:n,end_date:r,tz:i}})}async adminListCodes(e,n=50){return on.get("/xyzen/api/v1/redemption/admin/codes",{auth:!1,headers:{"X-Admin-Secret":e},params:{limit:n}})}async adminCreateCode(e,n){return on.post("/xyzen/api/v1/redemption/admin/codes",n,{auth:!1,headers:{"X-Admin-Secret":e}})}async adminDeactivateCode(e,n){return on.post(`/xyzen/api/v1/redemption/admin/codes/${n}/deactivate`,void 0,{auth:!1,headers:{"X-Admin-Secret":e}})}async getConsumptionHeatmap(e,n,r,i,o,l,u){return on.get("/xyzen/api/v1/redemption/admin/stats/consumption-heatmap",{auth:!1,headers:{"X-Admin-Secret":e},params:{year:n,tz:r,model_tier:i,model_name:o,provider:l,tool_name:u}})}async getUserConsumptionHeatmap(e,n,r,i,o,l,u){return on.get("/xyzen/api/v1/redemption/admin/stats/user-consumption-heatmap",{auth:!1,headers:{"X-Admin-Secret":e},params:{year:n,tz:r,model_tier:i,model_name:o,provider:l,tool_name:u}})}async getConsumptionTopUsers(e,n,r,i,o,l,u=20,d,p,m,g){return on.get("/xyzen/api/v1/redemption/admin/stats/consumption-top-users",{auth:!1,headers:{"X-Admin-Secret":e},params:{year:n,tz:r,date:i,model_tier:o,model_name:l,limit:u,search:d,provider:p,include_tiers:m||void 0,tool_name:g}})}async getRedemptionHeatmap(e,n,r){return on.get("/xyzen/api/v1/redemption/admin/stats/redemption-heatmap",{auth:!1,headers:{"X-Admin-Secret":e},params:{year:n,tz:r}})}async getRedemptionRankings(e,n,r,i,o=20,l){return on.get("/xyzen/api/v1/redemption/admin/stats/redemption-rankings",{auth:!1,headers:{"X-Admin-Secret":e},params:{year:n,tz:r,date:i,limit:o,search:l}})}async getNewUsersHeatmap(e,n,r){return on.get("/xyzen/api/v1/redemption/admin/stats/new-users-heatmap",{auth:!1,headers:{"X-Admin-Secret":e},params:{year:n,tz:r}})}async getFilterOptions(e,n,r,i){return on.get("/xyzen/api/v1/redemption/admin/stats/filter-options",{auth:!1,headers:{"X-Admin-Secret":e},params:{year:n,tz:r,provider:i}})}async getModelOptions(e){return on.get("/xyzen/api/v1/redemption/admin/stats/model-options",{auth:!1,headers:{"X-Admin-Secret":e}})}async getCreditSources(e){return on.get("/xyzen/api/v1/redemption/admin/stats/credit-sources",{auth:!1,headers:{"X-Admin-Secret":e}})}async getCreditHeatmap(e,n,r,i,o){return on.get("/xyzen/api/v1/redemption/admin/stats/credit-heatmap",{auth:!1,headers:{"X-Admin-Secret":e},params:{year:n,tz:r,source:i,tier:o}})}async getCreditRankings(e,n,r,i,o,l,u=20,d){return on.get("/xyzen/api/v1/redemption/admin/stats/credit-rankings",{auth:!1,headers:{"X-Admin-Secret":e},params:{year:n,tz:r,source:i,tier:o,date:l,limit:u,search:d}})}}const DA=new yFn,vFn=t=>({walletBalance:null,walletLoading:!1,fetchWallet:async()=>{t({walletLoading:!0});try{const e=await DA.getUserWallet();t({walletBalance:{free:e.free_balance,paid:e.paid_balance,earned:e.earned_balance,total:e.virtual_balance},walletLoading:!1})}catch{t({walletLoading:!1})}},connectWalletEvents:()=>{RP.connect();const e=RP.on("credit_updated",n=>{const r=n.data;t({walletBalance:{free:r.free_balance??0,paid:r.paid_balance??0,earned:r.earned_balance??0,total:r.virtual_balance??0}})});return()=>{e(),RP.disconnect()}},_handleCreditUpdated:e=>{t({walletBalance:{free:e.free_balance??0,paid:e.paid_balance??0,earned:e.earned_balance??0,total:e.virtual_balance??0}})}});let Gxe=null;function _Fn(t){Gxe=t}function ste(){if(!Gxe)throw new Error("toolbarActions not initialized — call initToolbarActions() at app startup");return Gxe()}async function wFn(t,e){try{await ste()(t,{model_tier:e,provider_id:null,model:null})}catch(n){console.error("Failed to update session tier:",n)}}async function xFn(t,e,n,r){try{await ste()(t,{model_tier:e,provider_id:n,model:r})}catch(i){console.error("Failed to update session tier model:",i)}}async function kFn(t,e){try{await ste()(t,{sandbox_backend:e})}catch(n){console.error("Failed to update session sandbox backend:",n)}}async function EFn(t,e){try{await ste()(t,{knowledge_set_id:e})}catch(n){console.error("Failed to update session knowledge set:",n)}}i5n(W5n),on.configure({getToken:()=>Eo.getToken(),onUnauthorized:()=>{Promise.resolve().then(()=>m5n).then(t=>t.logout()).catch(()=>{})}}),N5n();let CFn;const SFn={getItem:()=>null,setItem:()=>{},removeItem:()=>{}},Un=O5n()(Yit(U5n((...t)=>({...bFn(...t),...tFn(...t),...K5n(...t),...cFn(...t),...uFn(...t),...mFn(...t),...Z5n(...t),...oFn(...t),...rFn(...t),...iFn(...t),...dFn(...t),...fFn(...t),...AFn(...t),...vFn(...t)})),{name:"xyzen-storage",storage:Wit(()=>CFn??(typeof localStorage<"u"?localStorage:SFn)),partialize:t=>({isXyzenOpen:t.isXyzenOpen,panelWidth:t.panelWidth,activePanel:t.activePanel,theme:t.theme,token:t.token,user:t.user,backendUrl:t.backendUrl,activeChatChannel:t.activeChatChannel,spatialSidebarCollapsed:t.spatialSidebarCollapsed,capsuleOpen:t.capsuleOpen,capsuleActiveTab:t.capsuleActiveTab,mobileCeoOverlay:t.mobileCeoOverlay,mobilePage:t.mobilePage,openTabsByAgent:t.openTabsByAgent,terminalSessions:t.terminalSessions}),onRehydrateStorage:()=>t=>{if(!t)return;const e=t.terminalSessions;if(e)for(const n of Object.keys(e)){const r=e[n];(r.status==="connected"||r.status==="connecting"||r.status==="reconnecting")&&(r.status="detached")}}}));if(p5n(Un),_Fn(()=>Un.getState().updateSessionConfig),typeof window<"u"){const t=new Map;Un.subscribe(e=>{const n=e.activeChatChannel;if(!n)return;const r=e.channels[n];if(!r)return;const i=t.get(n)??0,o=r.messages.length;i>0&&o<i&&console.error(`[DIAGNOSTIC] MESSAGE COUNT DROP: ${n.slice(0,8)} ${i} → ${o}`,`| responding=${r.responding}`,`| latestAssist=${(()=>{const l=[...r.messages].reverse().find(u=>u.role==="assistant");return l?`id=${l.id.slice(0,12)} agentExec=${l.agentExecution?.status}`:"none"})()}`,new Error("trace").stack),t.set(n,o)})}function IFn(t){return Un.getState().status!=="succeeded"&&localStorage.getItem("platform")==="bohrium"?(t("provider_bohrium"),!0):!1}async function Hxe(){try{const t=await Eo.getAuthStatus();if(!t.is_configured||!t.provider)throw new Error("Authentication is not configured");const e=await Eo.getAuthConfig(),n=t.provider,r=`${window.location.origin}${window.location.pathname}`;let i=null;if(n==="casdoor"){const o=Math.random().toString(36).substring(7);sessionStorage.setItem("auth_state",o),i=xN(n,e,r,o)}else i=xN(n,e,r);if(i)window.location.href=i;else throw new Error(`Unsupported auth provider: ${n}`)}catch(t){throw console.error("Failed to initiate OAuth login:",t),t}}function TFn(t){const e=Un(M=>M.setBackendUrl),[n,r]=T.useState(!1),[i,o]=T.useState(!1),[l,u]=T.useState(!1),[d,p]=T.useState(),m=T.useRef(!1),g=T.useRef(null);T.useEffect(()=>{e(t),!m.current&&(m.current=!0,Cit().then(()=>{IFn(M=>g.current?.(M))}))},[t,e]);const h=T.useCallback(async M=>{const N=Math.random().toString(36).substring(7);sessionStorage.setItem("auth_state",N);const D=`${window.location.origin}${window.location.pathname}`;let P=null;try{const O=await Eo.getOAuthUrl(M,D,N);O.url&&(P=O.url)}catch{}if(!P)try{const O=await Eo.getAuthConfig();P=xN("casdoor",O,D,N,M)}catch{}if(P){u(!0);try{const O=await h5n(P);await rx(O.access_token,O.user_info)}catch(O){const F=O.message;if(F!=="OAuth popup was closed")if(F==="Popup blocked by browser"){window.location.href=P;return}else console.error("Failed to initiate provider login:",O),o(!1),r(!0)}finally{u(!1)}}},[]);g.current=h;const f=T.useCallback(async()=>{try{const[M,N]=await Promise.all([Eo.getAuthStatus(),Eo.getAuthConfig(),Dit()]),D=N?.provider??M?.provider;if(D==="casdoor"){N?.turnstile_site_key&&p(N.turnstile_site_key),o(!0);return}if(D&&D!=="bohr_app"){const P=xN(D,N,`${window.location.origin}${window.location.pathname}`);if(P){window.location.href=P;return}}}catch{}r(!0)},[]),b=T.useCallback(()=>{Cit()},[]),y=T.useCallback(()=>{o(!1)},[]),v=T.useCallback(async(M,N)=>Eo.sendVerificationCode(M,N),[]),_=T.useCallback(async(M,N)=>{await _xe(M,N,"email")},[]),w=T.useCallback(async(M,N,D,P)=>{await wxe(M,N,D,P)},[]),x=T.useCallback(async(M,N)=>{await vit(M,N)},[]),k=T.useCallback(async M=>{await Eo.sendResetCode(M)},[]),C=T.useCallback(async(M,N,D)=>{await wit(M,N,D)},[]),E=T.useCallback(async M=>Eo.sendPhoneVerificationCode(M),[]),S=T.useCallback(async M=>Eo.checkPhoneExists(M),[]),I=T.useCallback(async(M,N)=>{await _xe(M,N,"phone")},[]),B=T.useCallback(async(M,N)=>{await _it(M,N)},[]),R=T.useCallback(async(M,N,D,P)=>{await wxe("",N,D,P,"phone",M)},[]),L=T.useCallback(()=>{r(!1),o(!1)},[]);return{state:{showAuthScreen:n,showLoginPage:i,oauthLoading:l,turnstileSiteKey:d},handlers:{handleRetry:b,handleShowAuthScreen:f,handleSelectProvider:h,handleLoginBack:y,handleSendCode:v,handleCodeLogin:_,handleSignup:w,handlePasswordLogin:x,handleSendResetCode:k,handleResetPassword:C,handleSendPhoneCode:E,handleCheckPhone:S,handlePhoneCodeLogin:I,handlePhonePasswordLogin:B,handlePhoneSignup:R},resetAuthScreens:L}}var TN=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(t){return this.listeners.add(t),this.onSubscribe(),()=>{this.listeners.delete(t),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},BFn=class extends TN{#e;#t;#r;constructor(){super(),this.#r=t=>{if(typeof window<"u"&&window.addEventListener){const e=()=>t();return window.addEventListener("visibilitychange",e,!1),()=>{window.removeEventListener("visibilitychange",e)}}}}onSubscribe(){this.#t||this.setEventListener(this.#r)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(t){this.#r=t,this.#t?.(),this.#t=t(e=>{typeof e=="boolean"?this.setFocused(e):this.onFocus()})}setFocused(t){this.#e!==t&&(this.#e=t,this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(e=>{e(t)})}isFocused(){return typeof this.#e=="boolean"?this.#e:globalThis.document?.visibilityState!=="hidden"}},Wxe=new BFn,DFn={setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t),setInterval:(t,e)=>setInterval(t,e),clearInterval:t=>clearInterval(t)},NFn=class{#e=DFn;#t=!1;setTimeoutProvider(t){process.env.NODE_ENV!=="production"&&this.#t&&t!==this.#e&&console.error("[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.",{previous:this.#e,provider:t}),this.#e=t,process.env.NODE_ENV!=="production"&&(this.#t=!1)}setTimeout(t,e){return process.env.NODE_ENV!=="production"&&(this.#t=!0),this.#e.setTimeout(t,e)}clearTimeout(t){this.#e.clearTimeout(t)}setInterval(t,e){return process.env.NODE_ENV!=="production"&&(this.#t=!0),this.#e.setInterval(t,e)}clearInterval(t){this.#e.clearInterval(t)}},BN=new NFn;function RFn(t){setTimeout(t,0)}var LFn=typeof window>"u"||"Deno"in globalThis;function eh(){}function MFn(t,e){return typeof t=="function"?t(e):t}function Yxe(t){return typeof t=="number"&&t>=0&&t!==1/0}function got(t,e){return Math.max(t+(e||0)-Date.now(),0)}function eI(t,e){return typeof t=="function"?t(e):t}function ey(t,e){return typeof t=="function"?t(e):t}function hot(t,e){const{type:n="all",exact:r,fetchStatus:i,predicate:o,queryKey:l,stale:u}=t;if(l){if(r){if(e.queryHash!==Vxe(l,e.options))return!1}else if(!L7(e.queryKey,l))return!1}if(n!=="all"){const d=e.isActive();if(n==="active"&&!d||n==="inactive"&&d)return!1}return!(typeof u=="boolean"&&e.isStale()!==u||i&&i!==e.state.fetchStatus||o&&!o(e))}function fot(t,e){const{exact:n,status:r,predicate:i,mutationKey:o}=t;if(o){if(!e.options.mutationKey)return!1;if(n){if(DN(e.options.mutationKey)!==DN(o))return!1}else if(!L7(e.options.mutationKey,o))return!1}return!(r&&e.state.status!==r||i&&!i(e))}function Vxe(t,e){return(e?.queryKeyHashFn||DN)(t)}function DN(t){return JSON.stringify(t,(e,n)=>Kxe(n)?Object.keys(n).sort().reduce((r,i)=>(r[i]=n[i],r),{}):n)}function L7(t,e){return t===e?!0:typeof t!=typeof e?!1:t&&e&&typeof t=="object"&&typeof e=="object"?Object.keys(e).every(n=>L7(t[n],e[n])):!1}var PFn=Object.prototype.hasOwnProperty;function lte(t,e,n=0){if(t===e)return t;if(n>500)return e;const r=Aot(t)&&Aot(e);if(!r&&!(Kxe(t)&&Kxe(e)))return e;const o=(r?t:Object.keys(t)).length,l=r?e:Object.keys(e),u=l.length,d=r?new Array(u):{};let p=0;for(let m=0;m<u;m++){const g=r?m:l[m],h=t[g],f=e[g];if(h===f){d[g]=h,(r?m<o:PFn.call(t,g))&&p++;continue}if(h===null||f===null||typeof h!="object"||typeof f!="object"){d[g]=f;continue}const b=lte(h,f,n+1);d[g]=b,b===h&&p++}return o===u&&p===o?t:d}function M7(t,e){if(!e||Object.keys(t).length!==Object.keys(e).length)return!1;for(const n in t)if(t[n]!==e[n])return!1;return!0}function Aot(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function Kxe(t){if(!bot(t))return!1;const e=t.constructor;if(e===void 0)return!0;const n=e.prototype;return!(!bot(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}function bot(t){return Object.prototype.toString.call(t)==="[object Object]"}function OFn(t){return new Promise(e=>{BN.setTimeout(e,t)})}function Zxe(t,e,n){if(typeof n.structuralSharing=="function")return n.structuralSharing(t,e);if(n.structuralSharing!==!1){if(process.env.NODE_ENV!=="production")try{return lte(t,e)}catch(r){throw console.error(`Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${n.queryHash}]: ${r}`),r}return lte(t,e)}return e}function FFn(t,e,n=0){const r=[...t,e];return n&&r.length>n?r.slice(1):r}function QFn(t,e,n=0){const r=[e,...t];return n&&r.length>n?r.slice(0,-1):r}var cte=Symbol();function yot(t,e){return process.env.NODE_ENV!=="production"&&t.queryFn===cte&&console.error(`Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${t.queryHash}'`),!t.queryFn&&e?.initialPromise?()=>e.initialPromise:!t.queryFn||t.queryFn===cte?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function Xxe(t,e){return typeof t=="function"?t(...e):!!t}function $Fn(t,e,n){let r=!1,i;return Object.defineProperty(t,"signal",{enumerable:!0,get:()=>(i??=e(),r||(r=!0,i.aborted?n():i.addEventListener("abort",n,{once:!0})),i)}),t}var P7=(()=>{let t=()=>LFn;return{isServer(){return t()},setIsServer(e){t=e}}})();function Jxe(){let t,e;const n=new Promise((i,o)=>{t=i,e=o});n.status="pending",n.catch(()=>{});function r(i){Object.assign(n,i),delete n.resolve,delete n.reject}return n.resolve=i=>{r({status:"fulfilled",value:i}),t(i)},n.reject=i=>{r({status:"rejected",reason:i}),e(i)},n}var jFn=RFn;function zFn(){let t=[],e=0,n=u=>{u()},r=u=>{u()},i=jFn;const o=u=>{e?t.push(u):i(()=>{n(u)})},l=()=>{const u=t;t=[],u.length&&i(()=>{r(()=>{u.forEach(d=>{n(d)})})})};return{batch:u=>{let d;e++;try{d=u()}finally{e--,e||l()}return d},batchCalls:u=>(...d)=>{o(()=>{u(...d)})},schedule:o,setNotifyFunction:u=>{n=u},setBatchNotifyFunction:u=>{r=u},setScheduler:u=>{i=u}}}var rd=zFn(),UFn=class extends TN{#e=!0;#t;#r;constructor(){super(),this.#r=t=>{if(typeof window<"u"&&window.addEventListener){const e=()=>t(!0),n=()=>t(!1);return window.addEventListener("online",e,!1),window.addEventListener("offline",n,!1),()=>{window.removeEventListener("online",e),window.removeEventListener("offline",n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#r)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(t){this.#r=t,this.#t?.(),this.#t=t(this.setOnline.bind(this))}setOnline(t){this.#e!==t&&(this.#e=t,this.listeners.forEach(n=>{n(t)}))}isOnline(){return this.#e}},ute=new UFn;function qFn(t){return Math.min(1e3*2**t,3e4)}function vot(t){return(t??"online")==="online"?ute.isOnline():!0}var eke=class extends Error{constructor(t){super("CancelledError"),this.revert=t?.revert,this.silent=t?.silent}};function _ot(t){let e=!1,n=0,r;const i=Jxe(),o=()=>i.status!=="pending",l=y=>{if(!o()){const v=new eke(y);h(v),t.onCancel?.(v)}},u=()=>{e=!0},d=()=>{e=!1},p=()=>Wxe.isFocused()&&(t.networkMode==="always"||ute.isOnline())&&t.canRun(),m=()=>vot(t.networkMode)&&t.canRun(),g=y=>{o()||(r?.(),i.resolve(y))},h=y=>{o()||(r?.(),i.reject(y))},f=()=>new Promise(y=>{r=v=>{(o()||p())&&y(v)},t.onPause?.()}).then(()=>{r=void 0,o()||t.onContinue?.()}),b=()=>{if(o())return;let y;const v=n===0?t.initialPromise:void 0;try{y=v??t.fn()}catch(_){y=Promise.reject(_)}Promise.resolve(y).then(g).catch(_=>{if(o())return;const w=t.retry??(P7.isServer()?0:3),x=t.retryDelay??qFn,k=typeof x=="function"?x(n,_):x,C=w===!0||typeof w=="number"&&n<w||typeof w=="function"&&w(n,_);if(e||!C){h(_);return}n++,t.onFail?.(n,_),OFn(k).then(()=>p()?void 0:f()).then(()=>{e?h(_):b()})})};return{promise:i,status:()=>i.status,cancel:l,continue:()=>(r?.(),i),cancelRetry:u,continueRetry:d,canStart:m,start:()=>(m()?b():f().then(b),i)}}var wot=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Yxe(this.gcTime)&&(this.#e=BN.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(P7.isServer()?1/0:300*1e3))}clearGcTimeout(){this.#e&&(BN.clearTimeout(this.#e),this.#e=void 0)}},GFn=class extends wot{#e;#t;#r;#n;#a;#o;#i;constructor(t){super(),this.#i=!1,this.#o=t.defaultOptions,this.setOptions(t.options),this.observers=[],this.#n=t.client,this.#r=this.#n.getQueryCache(),this.queryKey=t.queryKey,this.queryHash=t.queryHash,this.#e=Eot(this.options),this.state=t.state??this.#e,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#a?.promise}setOptions(t){if(this.options={...this.#o,...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const e=Eot(this.options);e.data!==void 0&&(this.setState(kot(e.data,e.dataUpdatedAt)),this.#e=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#r.remove(this)}setData(t,e){const n=Zxe(this.state.data,t,this.options);return this.#l({data:n,type:"success",dataUpdatedAt:e?.updatedAt,manual:e?.manual}),n}setState(t,e){this.#l({type:"setState",state:t,setStateOptions:e})}cancel(t){const e=this.#a?.promise;return this.#a?.cancel(t),e?e.then(eh).catch(eh):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#e}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(t=>ey(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===cte||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>eI(t.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?!0:t==="static"?!1:this.state.isInvalidated?!0:!got(this.state.dataUpdatedAt,t)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#a?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#a?.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),this.#r.notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(e=>e!==t),this.observers.length||(this.#a&&(this.#i||this.#s()?this.#a.cancel({revert:!0}):this.#a.cancelRetry()),this.scheduleGc()),this.#r.notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}#s(){return this.state.fetchStatus==="paused"&&this.state.status==="pending"}invalidate(){this.state.isInvalidated||this.#l({type:"invalidate"})}async fetch(t,e){if(this.state.fetchStatus!=="idle"&&this.#a?.status()!=="rejected"){if(this.state.data!==void 0&&e?.cancelRefetch)this.cancel({silent:!0});else if(this.#a)return this.#a.continueRetry(),this.#a.promise}if(t&&this.setOptions(t),!this.options.queryFn){const u=this.observers.find(d=>d.options.queryFn);u&&this.setOptions(u.options)}process.env.NODE_ENV!=="production"&&(Array.isArray(this.options.queryKey)||console.error("As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']"));const n=new AbortController,r=u=>{Object.defineProperty(u,"signal",{enumerable:!0,get:()=>(this.#i=!0,n.signal)})},i=()=>{const u=yot(this.options,e),p=(()=>{const m={client:this.#n,queryKey:this.queryKey,meta:this.meta};return r(m),m})();return this.#i=!1,this.options.persister?this.options.persister(u,p,this):u(p)},l=(()=>{const u={fetchOptions:e,options:this.options,queryKey:this.queryKey,client:this.#n,state:this.state,fetchFn:i};return r(u),u})();this.options.behavior?.onFetch(l,this),this.#t=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==l.fetchOptions?.meta)&&this.#l({type:"fetch",meta:l.fetchOptions?.meta}),this.#a=_ot({initialPromise:e?.initialPromise,fn:l.fetchFn,onCancel:u=>{u instanceof eke&&u.revert&&this.setState({...this.#t,fetchStatus:"idle"}),n.abort()},onFail:(u,d)=>{this.#l({type:"failed",failureCount:u,error:d})},onPause:()=>{this.#l({type:"pause"})},onContinue:()=>{this.#l({type:"continue"})},retry:l.options.retry,retryDelay:l.options.retryDelay,networkMode:l.options.networkMode,canRun:()=>!0});try{const u=await this.#a.start();if(u===void 0)throw process.env.NODE_ENV!=="production"&&console.error(`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`),new Error(`${this.queryHash} data is undefined`);return this.setData(u),this.#r.config.onSuccess?.(u,this),this.#r.config.onSettled?.(u,this.state.error,this),u}catch(u){if(u instanceof eke){if(u.silent)return this.#a.promise;if(u.revert){if(this.state.data===void 0)throw u;return this.state.data}}throw this.#l({type:"error",error:u}),this.#r.config.onError?.(u,this),this.#r.config.onSettled?.(this.state.data,u,this),u}finally{this.scheduleGc()}}#l(t){const e=n=>{switch(t.type){case"failed":return{...n,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...n,fetchStatus:"paused"};case"continue":return{...n,fetchStatus:"fetching"};case"fetch":return{...n,...xot(n.data,this.options),fetchMeta:t.meta??null};case"success":const r={...n,...kot(t.data,t.dataUpdatedAt),dataUpdateCount:n.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return this.#t=t.manual?r:void 0,r;case"error":const i=t.error;return{...n,error:i,errorUpdateCount:n.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:n.fetchFailureCount+1,fetchFailureReason:i,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...n,isInvalidated:!0};case"setState":return{...n,...t.state}}};this.state=e(this.state),rd.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),this.#r.notify({query:this,type:"updated",action:t})})}};function xot(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:vot(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function kot(t,e){return{data:t,dataUpdatedAt:e??Date.now(),error:null,isInvalidated:!1,status:"success"}}function Eot(t){const e=typeof t.initialData=="function"?t.initialData():t.initialData,n=e!==void 0,r=n?typeof t.initialDataUpdatedAt=="function"?t.initialDataUpdatedAt():t.initialDataUpdatedAt:0;return{data:e,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var dte=class extends TN{constructor(t,e){super(),this.options=e,this.#e=t,this.#s=null,this.#i=Jxe(),this.bindMethods(),this.setOptions(e)}#e;#t=void 0;#r=void 0;#n=void 0;#a;#o;#i;#s;#l;#c;#p;#u;#m;#h;#g=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),Cot(this.#t,this.options)?this.#d():this.updateResult(),this.#b())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return tke(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return tke(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#k(),this.#x(),this.#t.removeObserver(this)}setOptions(t){const e=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof ey(this.options.enabled,this.#t)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#v(),this.#t.setOptions(this.options),e._defaulted&&!M7(this.options,e)&&this.#e.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#t,observer:this});const r=this.hasListeners();r&&Sot(this.#t,n,this.options,e)&&this.#d(),this.updateResult(),r&&(this.#t!==n||ey(this.options.enabled,this.#t)!==ey(e.enabled,this.#t)||eI(this.options.staleTime,this.#t)!==eI(e.staleTime,this.#t))&&this.#f();const i=this.#A();r&&(this.#t!==n||ey(this.options.enabled,this.#t)!==ey(e.enabled,this.#t)||i!==this.#h)&&this.#y(i)}getOptimisticResult(t){const e=this.#e.getQueryCache().build(this.#e,t),n=this.createResult(e,t);return WFn(this,n)&&(this.#n=n,this.#o=this.options,this.#a=this.#t.state),n}getCurrentResult(){return this.#n}trackResult(t,e){return new Proxy(t,{get:(n,r)=>(this.trackProp(r),e?.(r),r==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&this.#i.status==="pending"&&this.#i.reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(n,r))})}trackProp(t){this.#g.add(t)}getCurrentQuery(){return this.#t}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const e=this.#e.defaultQueryOptions(t),n=this.#e.getQueryCache().build(this.#e,e);return n.fetch().then(()=>this.createResult(n,e))}fetch(t){return this.#d({...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#n))}#d(t){this.#v();let e=this.#t.fetch(this.options,t);return t?.throwOnError||(e=e.catch(eh)),e}#f(){this.#k();const t=eI(this.options.staleTime,this.#t);if(P7.isServer()||this.#n.isStale||!Yxe(t))return;const n=got(this.#n.dataUpdatedAt,t)+1;this.#u=BN.setTimeout(()=>{this.#n.isStale||this.updateResult()},n)}#A(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#y(t){this.#x(),this.#h=t,!(P7.isServer()||ey(this.options.enabled,this.#t)===!1||!Yxe(this.#h)||this.#h===0)&&(this.#m=BN.setInterval(()=>{(this.options.refetchIntervalInBackground||Wxe.isFocused())&&this.#d()},this.#h))}#b(){this.#f(),this.#y(this.#A())}#k(){this.#u&&(BN.clearTimeout(this.#u),this.#u=void 0)}#x(){this.#m&&(BN.clearInterval(this.#m),this.#m=void 0)}createResult(t,e){const n=this.#t,r=this.options,i=this.#n,o=this.#a,l=this.#o,d=t!==n?t.state:this.#r,{state:p}=t;let m={...p},g=!1,h;if(e._optimisticResults){const I=this.hasListeners(),B=!I&&Cot(t,e),R=I&&Sot(t,n,e,r);(B||R)&&(m={...m,...xot(p.data,t.options)}),e._optimisticResults==="isRestoring"&&(m.fetchStatus="idle")}let{error:f,errorUpdatedAt:b,status:y}=m;h=m.data;let v=!1;if(e.placeholderData!==void 0&&h===void 0&&y==="pending"){let I;i?.isPlaceholderData&&e.placeholderData===l?.placeholderData?(I=i.data,v=!0):I=typeof e.placeholderData=="function"?e.placeholderData(this.#p?.state.data,this.#p):e.placeholderData,I!==void 0&&(y="success",h=Zxe(i?.data,I,e),g=!0)}if(e.select&&h!==void 0&&!v)if(i&&h===o?.data&&e.select===this.#l)h=this.#c;else try{this.#l=e.select,h=e.select(h),h=Zxe(i?.data,h,e),this.#c=h,this.#s=null}catch(I){this.#s=I}this.#s&&(f=this.#s,h=this.#c,b=Date.now(),y="error");const _=m.fetchStatus==="fetching",w=y==="pending",x=y==="error",k=w&&_,C=h!==void 0,S={status:y,fetchStatus:m.fetchStatus,isPending:w,isSuccess:y==="success",isError:x,isInitialLoading:k,isLoading:k,data:h,dataUpdatedAt:m.dataUpdatedAt,error:f,errorUpdatedAt:b,failureCount:m.fetchFailureCount,failureReason:m.fetchFailureReason,errorUpdateCount:m.errorUpdateCount,isFetched:t.isFetched(),isFetchedAfterMount:m.dataUpdateCount>d.dataUpdateCount||m.errorUpdateCount>d.errorUpdateCount,isFetching:_,isRefetching:_&&!w,isLoadingError:x&&!C,isPaused:m.fetchStatus==="paused",isPlaceholderData:g,isRefetchError:x&&C,isStale:nke(t,e),refetch:this.refetch,promise:this.#i,isEnabled:ey(e.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const I=S.data!==void 0,B=S.status==="error"&&!I,R=N=>{B?N.reject(S.error):I&&N.resolve(S.data)},L=()=>{const N=this.#i=S.promise=Jxe();R(N)},M=this.#i;switch(M.status){case"pending":t.queryHash===n.queryHash&&R(M);break;case"fulfilled":(B||S.data!==M.value)&&L();break;case"rejected":(!B||S.error!==M.reason)&&L();break}}return S}updateResult(){const t=this.#n,e=this.createResult(this.#t,this.options);if(this.#a=this.#t.state,this.#o=this.options,this.#a.data!==void 0&&(this.#p=this.#t),M7(e,t))return;this.#n=e;const n=()=>{if(!t)return!0;const{notifyOnChangeProps:r}=this.options,i=typeof r=="function"?r():r;if(i==="all"||!i&&!this.#g.size)return!0;const o=new Set(i??this.#g);return this.options.throwOnError&&o.add("error"),Object.keys(this.#n).some(l=>{const u=l;return this.#n[u]!==t[u]&&o.has(u)})};this.#C({listeners:n()})}#v(){const t=this.#e.getQueryCache().build(this.#e,this.options);if(t===this.#t)return;const e=this.#t;this.#t=t,this.#r=t.state,this.hasListeners()&&(e?.removeObserver(this),t.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#b()}#C(t){rd.batch(()=>{t.listeners&&this.listeners.forEach(e=>{e(this.#n)}),this.#e.getQueryCache().notify({query:this.#t,type:"observerResultsUpdated"})})}};function HFn(t,e){return ey(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&e.retryOnMount===!1)}function Cot(t,e){return HFn(t,e)||t.state.data!==void 0&&tke(t,e,e.refetchOnMount)}function tke(t,e,n){if(ey(e.enabled,t)!==!1&&eI(e.staleTime,t)!=="static"){const r=typeof n=="function"?n(t):n;return r==="always"||r!==!1&&nke(t,e)}return!1}function Sot(t,e,n,r){return(t!==e||ey(r.enabled,t)===!1)&&(!n.suspense||t.state.status!=="error")&&nke(t,n)}function nke(t,e){return ey(e.enabled,t)!==!1&&t.isStaleByTime(eI(e.staleTime,t))}function WFn(t,e){return!M7(t.getCurrentResult(),e)}function pte(t){return{onFetch:(e,n)=>{const r=e.options,i=e.fetchOptions?.meta?.fetchMore?.direction,o=e.state.data?.pages||[],l=e.state.data?.pageParams||[];let u={pages:[],pageParams:[]},d=0;const p=async()=>{let m=!1;const g=b=>{$Fn(b,()=>e.signal,()=>m=!0)},h=yot(e.options,e.fetchOptions),f=async(b,y,v)=>{if(m)return Promise.reject();if(y==null&&b.pages.length)return Promise.resolve(b);const w=(()=>{const E={client:e.client,queryKey:e.queryKey,pageParam:y,direction:v?"backward":"forward",meta:e.options.meta};return g(E),E})(),x=await h(w),{maxPages:k}=e.options,C=v?QFn:FFn;return{pages:C(b.pages,x,k),pageParams:C(b.pageParams,y,k)}};if(i&&o.length){const b=i==="backward",y=b?Iot:rke,v={pages:o,pageParams:l},_=y(r,v);u=await f(v,_,b)}else{const b=t??o.length;do{const y=d===0?l[0]??r.initialPageParam:rke(r,u);if(d>0&&y==null)break;u=await f(u,y),d++}while(d<b)}return u};e.options.persister?e.fetchFn=()=>e.options.persister?.(p,{client:e.client,queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},n):e.fetchFn=p}}}function rke(t,{pages:e,pageParams:n}){const r=e.length-1;return e.length>0?t.getNextPageParam(e[r],e,n[r],n):void 0}function Iot(t,{pages:e,pageParams:n}){return e.length>0?t.getPreviousPageParam?.(e[0],e,n[0],n):void 0}function YFn(t,e){return e?rke(t,e)!=null:!1}function VFn(t,e){return!e||!t.getPreviousPageParam?!1:Iot(t,e)!=null}var KFn=class extends dte{constructor(t,e){super(t,e)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(t){super.setOptions({...t,behavior:pte()})}getOptimisticResult(t){return t.behavior=pte(),super.getOptimisticResult(t)}fetchNextPage(t){return this.fetch({...t,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(t){return this.fetch({...t,meta:{fetchMore:{direction:"backward"}}})}createResult(t,e){const{state:n}=t,r=super.createResult(t,e),{isFetching:i,isRefetching:o,isError:l,isRefetchError:u}=r,d=n.fetchMeta?.fetchMore?.direction,p=l&&d==="forward",m=i&&d==="forward",g=l&&d==="backward",h=i&&d==="backward";return{...r,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:YFn(e,n.data),hasPreviousPage:VFn(e,n.data),isFetchNextPageError:p,isFetchingNextPage:m,isFetchPreviousPageError:g,isFetchingPreviousPage:h,isRefetchError:u&&!p&&!g,isRefetching:o&&!m&&!h}}},ZFn=class extends wot{#e;#t;#r;#n;constructor(t){super(),this.#e=t.client,this.mutationId=t.mutationId,this.#r=t.mutationCache,this.#t=[],this.state=t.state||Tot(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){this.#t.includes(t)||(this.#t.push(t),this.clearGcTimeout(),this.#r.notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){this.#t=this.#t.filter(e=>e!==t),this.scheduleGc(),this.#r.notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){this.#t.length||(this.state.status==="pending"?this.scheduleGc():this.#r.remove(this))}continue(){return this.#n?.continue()??this.execute(this.state.variables)}async execute(t){const e=()=>{this.#a({type:"continue"})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#n=_ot({fn:()=>this.options.mutationFn?this.options.mutationFn(t,n):Promise.reject(new Error("No mutationFn found")),onFail:(o,l)=>{this.#a({type:"failed",failureCount:o,error:l})},onPause:()=>{this.#a({type:"pause"})},onContinue:e,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#r.canRun(this)});const r=this.state.status==="pending",i=!this.#n.canStart();try{if(r)e();else{this.#a({type:"pending",variables:t,isPaused:i}),this.#r.config.onMutate&&await this.#r.config.onMutate(t,this,n);const l=await this.options.onMutate?.(t,n);l!==this.state.context&&this.#a({type:"pending",context:l,variables:t,isPaused:i})}const o=await this.#n.start();return await this.#r.config.onSuccess?.(o,t,this.state.context,this,n),await this.options.onSuccess?.(o,t,this.state.context,n),await this.#r.config.onSettled?.(o,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(o,null,t,this.state.context,n),this.#a({type:"success",data:o}),o}catch(o){try{await this.#r.config.onError?.(o,t,this.state.context,this,n)}catch(l){Promise.reject(l)}try{await this.options.onError?.(o,t,this.state.context,n)}catch(l){Promise.reject(l)}try{await this.#r.config.onSettled?.(void 0,o,this.state.variables,this.state.context,this,n)}catch(l){Promise.reject(l)}try{await this.options.onSettled?.(void 0,o,t,this.state.context,n)}catch(l){Promise.reject(l)}throw this.#a({type:"error",error:o}),o}finally{this.#r.runNext(this)}}#a(t){const e=n=>{switch(t.type){case"failed":return{...n,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...n,isPaused:!0};case"continue":return{...n,isPaused:!1};case"pending":return{...n,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...n,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...n,data:void 0,error:t.error,failureCount:n.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=e(this.state),rd.batch(()=>{this.#t.forEach(n=>{n.onMutationUpdate(t)}),this.#r.notify({mutation:this,type:"updated",action:t})})}};function Tot(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var XFn=class extends TN{constructor(t={}){super(),this.config=t,this.#e=new Set,this.#t=new Map,this.#r=0}#e;#t;#r;build(t,e,n){const r=new ZFn({client:t,mutationCache:this,mutationId:++this.#r,options:t.defaultMutationOptions(e),state:n});return this.add(r),r}add(t){this.#e.add(t);const e=mte(t);if(typeof e=="string"){const n=this.#t.get(e);n?n.push(t):this.#t.set(e,[t])}this.notify({type:"added",mutation:t})}remove(t){if(this.#e.delete(t)){const e=mte(t);if(typeof e=="string"){const n=this.#t.get(e);if(n)if(n.length>1){const r=n.indexOf(t);r!==-1&&n.splice(r,1)}else n[0]===t&&this.#t.delete(e)}}this.notify({type:"removed",mutation:t})}canRun(t){const e=mte(t);if(typeof e=="string"){const r=this.#t.get(e)?.find(i=>i.state.status==="pending");return!r||r===t}else return!0}runNext(t){const e=mte(t);return typeof e=="string"?this.#t.get(e)?.find(r=>r!==t&&r.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){rd.batch(()=>{this.#e.forEach(t=>{this.notify({type:"removed",mutation:t})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(t){const e={exact:!0,...t};return this.getAll().find(n=>fot(e,n))}findAll(t={}){return this.getAll().filter(e=>fot(t,e))}notify(t){rd.batch(()=>{this.listeners.forEach(e=>{e(t)})})}resumePausedMutations(){const t=this.getAll().filter(e=>e.state.isPaused);return rd.batch(()=>Promise.all(t.map(e=>e.continue().catch(eh))))}};function mte(t){return t.options.scope?.id}var JFn=class extends TN{#e;#t=void 0;#r;#n;constructor(e,n){super(),this.#e=e,this.setOptions(n),this.bindMethods(),this.#a()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){const n=this.options;this.options=this.#e.defaultMutationOptions(e),M7(this.options,n)||this.#e.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#r,observer:this}),n?.mutationKey&&this.options.mutationKey&&DN(n.mutationKey)!==DN(this.options.mutationKey)?this.reset():this.#r?.state.status==="pending"&&this.#r.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#r?.removeObserver(this)}onMutationUpdate(e){this.#a(),this.#o(e)}getCurrentResult(){return this.#t}reset(){this.#r?.removeObserver(this),this.#r=void 0,this.#a(),this.#o()}mutate(e,n){return this.#n=n,this.#r?.removeObserver(this),this.#r=this.#e.getMutationCache().build(this.#e,this.options),this.#r.addObserver(this),this.#r.execute(e)}#a(){const e=this.#r?.state??Tot();this.#t={...e,isPending:e.status==="pending",isSuccess:e.status==="success",isError:e.status==="error",isIdle:e.status==="idle",mutate:this.mutate,reset:this.reset}}#o(e){rd.batch(()=>{if(this.#n&&this.hasListeners()){const n=this.#t.variables,r=this.#t.context,i={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type==="success"){try{this.#n.onSuccess?.(e.data,n,r,i)}catch(o){Promise.reject(o)}try{this.#n.onSettled?.(e.data,null,n,r,i)}catch(o){Promise.reject(o)}}else if(e?.type==="error"){try{this.#n.onError?.(e.error,n,r,i)}catch(o){Promise.reject(o)}try{this.#n.onSettled?.(void 0,e.error,n,r,i)}catch(o){Promise.reject(o)}}}this.listeners.forEach(n=>{n(this.#t)})})}};function Bot(t,e){const n=new Set(e);return t.filter(r=>!n.has(r))}function e8n(t,e,n){const r=t.slice(0);return r[e]=n,r}var t8n=class extends TN{#e;#t;#r;#n;#a;#o;#i;#s;#l;#c=[];constructor(t,e,n){super(),this.#e=t,this.#n=n,this.#r=[],this.#a=[],this.#t=[],this.setQueries(e)}onSubscribe(){this.listeners.size===1&&this.#a.forEach(t=>{t.subscribe(e=>{this.#h(t,e)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#a.forEach(t=>{t.destroy()})}setQueries(t,e){if(this.#r=t,this.#n=e,process.env.NODE_ENV!=="production"){const n=t.map(r=>this.#e.defaultQueryOptions(r).queryHash);new Set(n).size!==n.length&&console.warn("[QueriesObserver]: Duplicate Queries found. This might result in unexpected behavior.")}rd.batch(()=>{const n=this.#a,r=this.#m(this.#r);r.forEach(m=>m.observer.setOptions(m.defaultedQueryOptions));const i=r.map(m=>m.observer),o=i.map(m=>m.getCurrentResult()),l=n.length!==i.length,u=i.some((m,g)=>m!==n[g]),d=l||u,p=d?!0:o.some((m,g)=>{const h=this.#t[g];return!h||!M7(m,h)});!d&&!p||(d&&(this.#c=r,this.#a=i),this.#t=o,this.hasListeners()&&(d&&(Bot(n,i).forEach(m=>{m.destroy()}),Bot(i,n).forEach(m=>{m.subscribe(g=>{this.#h(m,g)})})),this.#g()))})}getCurrentResult(){return this.#t}getQueries(){return this.#a.map(t=>t.getCurrentQuery())}getObservers(){return this.#a}getOptimisticResult(t,e){const n=this.#m(t),r=n.map(o=>o.observer.getOptimisticResult(o.defaultedQueryOptions)),i=n.map(o=>o.defaultedQueryOptions.queryHash);return[r,o=>this.#u(o??r,e,i),()=>this.#p(r,n)]}#p(t,e){return e.map((n,r)=>{const i=t[r];return n.defaultedQueryOptions.notifyOnChangeProps?i:n.observer.trackResult(i,o=>{e.forEach(l=>{l.observer.trackProp(o)})})})}#u(t,e,n){if(e){const r=this.#l,i=n!==void 0&&r!==void 0&&(r.length!==n.length||n.some((o,l)=>o!==r[l]));return(!this.#o||this.#t!==this.#s||i||e!==this.#i)&&(this.#i=e,this.#s=this.#t,n!==void 0&&(this.#l=n),this.#o=lte(this.#o,e(t))),this.#o}return t}#m(t){const e=new Map;this.#a.forEach(r=>{const i=r.options.queryHash;if(!i)return;const o=e.get(i);o?o.push(r):e.set(i,[r])});const n=[];return t.forEach(r=>{const i=this.#e.defaultQueryOptions(r),l=e.get(i.queryHash)?.shift()??new dte(this.#e,i);n.push({defaultedQueryOptions:i,observer:l})}),n}#h(t,e){const n=this.#a.indexOf(t);n!==-1&&(this.#t=e8n(this.#t,n,e),this.#g())}#g(){if(this.hasListeners()){const t=this.#o,e=this.#p(this.#t,this.#c),n=this.#u(e,this.#n?.combine);t!==n&&rd.batch(()=>{this.listeners.forEach(r=>{r(this.#t)})})}}},n8n=class extends TN{constructor(t={}){super(),this.config=t,this.#e=new Map}#e;build(t,e,n){const r=e.queryKey,i=e.queryHash??Vxe(r,e);let o=this.get(i);return o||(o=new GFn({client:t,queryKey:r,queryHash:i,options:t.defaultQueryOptions(e),state:n,defaultOptions:t.getQueryDefaults(r)}),this.add(o)),o}add(t){this.#e.has(t.queryHash)||(this.#e.set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const e=this.#e.get(t.queryHash);e&&(t.destroy(),e===t&&this.#e.delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){rd.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return this.#e.get(t)}getAll(){return[...this.#e.values()]}find(t){const e={exact:!0,...t};return this.getAll().find(n=>hot(e,n))}findAll(t={}){const e=this.getAll();return Object.keys(t).length>0?e.filter(n=>hot(t,n)):e}notify(t){rd.batch(()=>{this.listeners.forEach(e=>{e(t)})})}onFocus(){rd.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){rd.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},r8n=class{#e;#t;#r;#n;#a;#o;#i;#s;constructor(t={}){this.#e=t.queryCache||new n8n,this.#t=t.mutationCache||new XFn,this.#r=t.defaultOptions||{},this.#n=new Map,this.#a=new Map,this.#o=0}mount(){this.#o++,this.#o===1&&(this.#i=Wxe.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=ute.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#o--,this.#o===0&&(this.#i?.(),this.#i=void 0,this.#s?.(),this.#s=void 0)}isFetching(t){return this.#e.findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return this.#t.findAll({...t,status:"pending"}).length}getQueryData(t){const e=this.defaultQueryOptions({queryKey:t});return this.#e.get(e.queryHash)?.state.data}ensureQueryData(t){const e=this.defaultQueryOptions(t),n=this.#e.build(this,e),r=n.state.data;return r===void 0?this.fetchQuery(t):(t.revalidateIfStale&&n.isStaleByTime(eI(e.staleTime,n))&&this.prefetchQuery(e),Promise.resolve(r))}getQueriesData(t){return this.#e.findAll(t).map(({queryKey:e,state:n})=>{const r=n.data;return[e,r]})}setQueryData(t,e,n){const r=this.defaultQueryOptions({queryKey:t}),o=this.#e.get(r.queryHash)?.state.data,l=MFn(e,o);if(l!==void 0)return this.#e.build(this,r).setData(l,{...n,manual:!0})}setQueriesData(t,e,n){return rd.batch(()=>this.#e.findAll(t).map(({queryKey:r})=>[r,this.setQueryData(r,e,n)]))}getQueryState(t){const e=this.defaultQueryOptions({queryKey:t});return this.#e.get(e.queryHash)?.state}removeQueries(t){const e=this.#e;rd.batch(()=>{e.findAll(t).forEach(n=>{e.remove(n)})})}resetQueries(t,e){const n=this.#e;return rd.batch(()=>(n.findAll(t).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){const n={revert:!0,...e},r=rd.batch(()=>this.#e.findAll(t).map(i=>i.cancel(n)));return Promise.all(r).then(eh).catch(eh)}invalidateQueries(t,e={}){return rd.batch(()=>(this.#e.findAll(t).forEach(n=>{n.invalidate()}),t?.refetchType==="none"?Promise.resolve():this.refetchQueries({...t,type:t?.refetchType??t?.type??"active"},e)))}refetchQueries(t,e={}){const n={...e,cancelRefetch:e.cancelRefetch??!0},r=rd.batch(()=>this.#e.findAll(t).filter(i=>!i.isDisabled()&&!i.isStatic()).map(i=>{let o=i.fetch(void 0,n);return n.throwOnError||(o=o.catch(eh)),i.state.fetchStatus==="paused"?Promise.resolve():o}));return Promise.all(r).then(eh)}fetchQuery(t){const e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);const n=this.#e.build(this,e);return n.isStaleByTime(eI(e.staleTime,n))?n.fetch(e):Promise.resolve(n.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(eh).catch(eh)}fetchInfiniteQuery(t){return t.behavior=pte(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(eh).catch(eh)}ensureInfiniteQueryData(t){return t.behavior=pte(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return ute.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#r}setDefaultOptions(t){this.#r=t}setQueryDefaults(t,e){this.#n.set(DN(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){const e=[...this.#n.values()],n={};return e.forEach(r=>{L7(t,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(t,e){this.#a.set(DN(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){const e=[...this.#a.values()],n={};return e.forEach(r=>{L7(t,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(t){if(t._defaulted)return t;const e={...this.#r.queries,...this.getQueryDefaults(t.queryKey),...t,_defaulted:!0};return e.queryHash||(e.queryHash=Vxe(e.queryKey,e)),e.refetchOnReconnect===void 0&&(e.refetchOnReconnect=e.networkMode!=="always"),e.throwOnError===void 0&&(e.throwOnError=!!e.suspense),!e.networkMode&&e.persister&&(e.networkMode="offlineFirst"),e.queryFn===cte&&(e.enabled=!1),e}defaultMutationOptions(t){return t?._defaulted?t:{...this.#r.mutations,...t?.mutationKey&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},Dot=ee.createContext(void 0),Tc=t=>{const e=ee.useContext(Dot);if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},O7=({client:t,children:e})=>(ee.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),A.jsx(Dot.Provider,{value:t,children:e})),Not=ee.createContext(!1),Rot=()=>ee.useContext(Not);Not.Provider;function a8n(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var i8n=ee.createContext(a8n()),Lot=()=>ee.useContext(i8n),Mot=(t,e,n)=>{const r=n?.state.error&&typeof t.throwOnError=="function"?Xxe(t.throwOnError,[n.state.error,n]):t.throwOnError;(t.suspense||t.experimental_prefetchInRender||r)&&(e.isReset()||(t.retryOnMount=!1))},Pot=t=>{ee.useEffect(()=>{t.clearReset()},[t])},Oot=({result:t,errorResetBoundary:e,throwOnError:n,query:r,suspense:i})=>t.isError&&!e.isReset()&&!t.isFetching&&r&&(i&&t.data===void 0||Xxe(n,[t.error,r])),Fot=t=>{if(t.suspense){const n=i=>i==="static"?i:Math.max(i??1e3,1e3),r=t.staleTime;t.staleTime=typeof r=="function"?(...i)=>n(r(...i)):n(r),typeof t.gcTime=="number"&&(t.gcTime=Math.max(t.gcTime,1e3))}},o8n=(t,e)=>t.isLoading&&t.isFetching&&!e,ake=(t,e)=>t?.suspense&&e.isPending,ike=(t,e,n)=>e.fetchOptimistic(t).catch(()=>{n.clearReset()});function s8n({queries:t,...e},n){const r=Tc(),i=Rot(),o=Lot(),l=ee.useMemo(()=>t.map(y=>{const v=r.defaultQueryOptions(y);return v._optimisticResults=i?"isRestoring":"optimistic",v}),[t,r,i]);l.forEach(y=>{Fot(y);const v=r.getQueryCache().get(y.queryHash);Mot(y,o,v)}),Pot(o);const[u]=ee.useState(()=>new t8n(r,l,e)),[d,p,m]=u.getOptimisticResult(l,e.combine),g=!i&&e.subscribed!==!1;ee.useSyncExternalStore(ee.useCallback(y=>g?u.subscribe(rd.batchCalls(y)):eh,[u,g]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),ee.useEffect(()=>{u.setQueries(l,e)},[l,e,u]);const f=d.some((y,v)=>ake(l[v],y))?d.flatMap((y,v)=>{const _=l[v];if(_&&ake(_,y)){const w=new dte(r,_);return ike(_,w,o)}return[]}):[];if(f.length>0)throw Promise.all(f);const b=d.find((y,v)=>{const _=l[v];return _&&Oot({result:y,errorResetBoundary:o,throwOnError:_.throwOnError,query:r.getQueryCache().get(_.queryHash),suspense:_.suspense})});if(b?.error)throw b.error;return p(m())}function Qot(t,e,n){if(process.env.NODE_ENV!=="production"&&(typeof t!="object"||Array.isArray(t)))throw new Error('Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object');const r=Rot(),i=Lot(),o=Tc(),l=o.defaultQueryOptions(t);o.getDefaultOptions().queries?._experimental_beforeQuery?.(l);const u=o.getQueryCache().get(l.queryHash);process.env.NODE_ENV!=="production"&&(l.queryFn||console.error(`[${l.queryHash}]: No queryFn was passed as an option, and no default queryFn was found. The queryFn parameter is only optional when using a default queryFn. More info here: https://tanstack.com/query/latest/docs/framework/react/guides/default-query-function`)),l._optimisticResults=r?"isRestoring":"optimistic",Fot(l),Mot(l,i,u),Pot(i);const d=!o.getQueryCache().get(l.queryHash),[p]=ee.useState(()=>new e(o,l)),m=p.getOptimisticResult(l),g=!r&&t.subscribed!==!1;if(ee.useSyncExternalStore(ee.useCallback(h=>{const f=g?p.subscribe(rd.batchCalls(h)):eh;return p.updateResult(),f},[p,g]),()=>p.getCurrentResult(),()=>p.getCurrentResult()),ee.useEffect(()=>{p.setOptions(l)},[l,p]),ake(l,m))throw ike(l,p,i);if(Oot({result:m,errorResetBoundary:i,throwOnError:l.throwOnError,query:u,suspense:l.suspense}))throw m.error;return o.getDefaultOptions().queries?._experimental_afterQuery?.(l,m),l.experimental_prefetchInRender&&!P7.isServer()&&o8n(m,r)&&(d?ike(l,p,i):u?.promise)?.catch(eh).finally(()=>{p.updateResult()}),l.notifyOnChangeProps?m:p.trackResult(m)}function Ns(t,e){return Qot(t,dte)}function NA(t,e){const n=Tc(),[r]=ee.useState(()=>new JFn(n,t));ee.useEffect(()=>{r.setOptions(t)},[r,t]);const i=ee.useSyncExternalStore(ee.useCallback(l=>r.subscribe(rd.batchCalls(l)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),o=ee.useCallback((l,u)=>{r.mutate(l,u).catch(eh)},[r]);if(i.error&&Xxe(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:o,mutateAsync:i.mutate}}function $ot(t,e){return Qot(t,KFn)}class l8n{async getActiveCampaigns(){return on.get("/xyzen/api/v1/gifts/active")}async claimGift(e){return on.post(`/xyzen/api/v1/gifts/${e}/claim`)}}const jot=new l8n,c8n=!1,u8n=!0;console.log("=== Environment Debug ==="),console.log("MODE:","production"),console.log("isDevelopment:",c8n),console.log("isProduction:",u8n),console.log("VITE_XYZEN_BACKEND_URL:","https://xyzen.cc");const NN="https://xyzen.cc";console.log("Final DEFAULT_BACKEND_URL:",NN);const d8n=typeof localStorage<"u"&&localStorage.getItem("layoutStyle")?localStorage.getItem("layoutStyle"):"sidebar";console.log("Final DEFAULT_LAYOUT_STYLE:",d8n);function oke(){return typeof window<"u"&&"__TAURI__"in window}async function ske(t,e){const{invoke:n}=await Promise.resolve().then(()=>_Zn);return n(t,e)}async function p8n(t,e,n){return ske("runner_start",{token:t,url:e,workDir:n})}async function m8n(){return ske("runner_stop")}async function g8n(){return ske("runner_status")}function h8n(){return A.jsx("div",{"data-tauri-drag-region":!0,className:"fixed top-0 left-0 right-0 h-2 z-[100] select-none backdrop-blur-xl backdrop-saturate-150",style:{WebkitMaskImage:"linear-gradient(to bottom, black 0%, transparent 100%)",maskImage:"linear-gradient(to bottom, black 0%, transparent 100%)",background:"linear-gradient(to bottom, rgba(128,128,128,0.2) 0%, transparent 100%)"}})}const f8n=Object.freeze({billing:!1,admin:!1,checkIn:!1,subscription:!1,developerReward:!1}),A8n=Object.freeze({billing:!0,admin:!0,checkIn:!0,subscription:!0,developerReward:!0}),lke=Object.freeze({edition:"ce",isEE:!1,features:f8n}),b8n=Object.freeze({edition:"ee",isEE:!0,features:A8n});let LP=lke,zot=!1;async function y8n(){if(zot)return LP;try{const[t,e]=await Promise.all([Wee.getEdition(),Wee.getFeatures().catch(()=>null)]),n=t.edition==="ee"?b8n:lke;if(e){const r={...n.features,developerReward:n.features.developerReward&&e.developer_reward};LP=Object.freeze({...n,features:Object.freeze(r)})}else LP=n}catch{LP=lke}return zot=!0,LP}function RA(t){return LP.features[t]}const gte=()=>{const[t,e]=T.useState("system"),n=Un(l=>l.setTheme),r=T.useCallback(l=>{const u=window.document.documentElement,d=l==="dark"||l==="system"&&window.matchMedia("(prefers-color-scheme: dark)").matches,p=document.createElement("style");p.innerHTML="*, *::before, *::after { transition: none !important; }",document.head.appendChild(p),u.classList.toggle("dark",d),localStorage.setItem("theme",l);const m=d?"#000000":"#ffffff";document.querySelectorAll('meta[name="theme-color"]').forEach(g=>{g.content=m}),setTimeout(()=>{document.head.contains(p)&&document.head.removeChild(p)},50)},[]);return T.useEffect(()=>{const u=localStorage.getItem("theme")||"system";e(u),r(u)},[r]),T.useEffect(()=>{const l=window.matchMedia("(prefers-color-scheme: dark)"),u=()=>{t==="system"&&r("system")};return l.addEventListener("change",u),()=>l.removeEventListener("change",u)},[t,r]),{theme:t,cycleTheme:()=>{const l=["light","dark","system"],u=l.indexOf(t),d=l[(u+1)%l.length];e(d),r(d)},setTheme:l=>{e(l),r(l),n(l)}}};function v8n(t){if(typeof document>"u")return;let e=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css",e.appendChild(n),n.styleSheet?n.styleSheet.cssText=t:n.appendChild(document.createTextNode(t))}const _8n=t=>{switch(t){case"success":return k8n;case"info":return C8n;case"warning":return E8n;case"error":return S8n;default:return null}},w8n=Array(12).fill(0),x8n=({visible:t,className:e})=>T.createElement("div",{className:["sonner-loading-wrapper",e].filter(Boolean).join(" "),"data-visible":t},T.createElement("div",{className:"sonner-spinner"},w8n.map((n,r)=>T.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),k8n=T.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},T.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),E8n=T.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},T.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),C8n=T.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},T.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),S8n=T.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},T.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),I8n=T.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},T.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),T.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),T8n=()=>{const[t,e]=T.useState(document.hidden);return T.useEffect(()=>{const n=()=>{e(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),t};let cke=1;class B8n{constructor(){this.subscribe=e=>(this.subscribers.push(e),()=>{const n=this.subscribers.indexOf(e);this.subscribers.splice(n,1)}),this.publish=e=>{this.subscribers.forEach(n=>n(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e]},this.create=e=>{var n;const{message:r,...i}=e,o=typeof e?.id=="number"||((n=e.id)==null?void 0:n.length)>0?e.id:cke++,l=this.toasts.find(d=>d.id===o),u=e.dismissible===void 0?!0:e.dismissible;return this.dismissedToasts.has(o)&&this.dismissedToasts.delete(o),l?this.toasts=this.toasts.map(d=>d.id===o?(this.publish({...d,...e,id:o,title:r}),{...d,...e,id:o,dismissible:u,title:r}):d):this.addToast({title:r,...i,dismissible:u,id:o}),o},this.dismiss=e=>(e?(this.dismissedToasts.add(e),requestAnimationFrame(()=>this.subscribers.forEach(n=>n({id:e,dismiss:!0})))):this.toasts.forEach(n=>{this.subscribers.forEach(r=>r({id:n.id,dismiss:!0}))}),e),this.message=(e,n)=>this.create({...n,message:e}),this.error=(e,n)=>this.create({...n,message:e,type:"error"}),this.success=(e,n)=>this.create({...n,type:"success",message:e}),this.info=(e,n)=>this.create({...n,type:"info",message:e}),this.warning=(e,n)=>this.create({...n,type:"warning",message:e}),this.loading=(e,n)=>this.create({...n,type:"loading",message:e}),this.promise=(e,n)=>{if(!n)return;let r;n.loading!==void 0&&(r=this.create({...n,promise:e,type:"loading",message:n.loading,description:typeof n.description!="function"?n.description:void 0}));const i=Promise.resolve(e instanceof Function?e():e);let o=r!==void 0,l;const u=i.then(async p=>{if(l=["resolve",p],T.isValidElement(p))o=!1,this.create({id:r,type:"default",message:p});else if(N8n(p)&&!p.ok){o=!1;const g=typeof n.error=="function"?await n.error(`HTTP error! status: ${p.status}`):n.error,h=typeof n.description=="function"?await n.description(`HTTP error! status: ${p.status}`):n.description,b=typeof g=="object"&&!T.isValidElement(g)?g:{message:g};this.create({id:r,type:"error",description:h,...b})}else if(p instanceof Error){o=!1;const g=typeof n.error=="function"?await n.error(p):n.error,h=typeof n.description=="function"?await n.description(p):n.description,b=typeof g=="object"&&!T.isValidElement(g)?g:{message:g};this.create({id:r,type:"error",description:h,...b})}else if(n.success!==void 0){o=!1;const g=typeof n.success=="function"?await n.success(p):n.success,h=typeof n.description=="function"?await n.description(p):n.description,b=typeof g=="object"&&!T.isValidElement(g)?g:{message:g};this.create({id:r,type:"success",description:h,...b})}}).catch(async p=>{if(l=["reject",p],n.error!==void 0){o=!1;const m=typeof n.error=="function"?await n.error(p):n.error,g=typeof n.description=="function"?await n.description(p):n.description,f=typeof m=="object"&&!T.isValidElement(m)?m:{message:m};this.create({id:r,type:"error",description:g,...f})}}).finally(()=>{o&&(this.dismiss(r),r=void 0),n.finally==null||n.finally.call(n)}),d=()=>new Promise((p,m)=>u.then(()=>l[0]==="reject"?m(l[1]):p(l[1])).catch(m));return typeof r!="string"&&typeof r!="number"?{unwrap:d}:Object.assign(r,{unwrap:d})},this.custom=(e,n)=>{const r=n?.id||cke++;return this.create({jsx:e(r),id:r,...n}),r},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}}const LA=new B8n,D8n=(t,e)=>{const n=e?.id||cke++;return LA.addToast({title:t,...e,id:n}),n},N8n=t=>t&&typeof t=="object"&&"ok"in t&&typeof t.ok=="boolean"&&"status"in t&&typeof t.status=="number",R8n=D8n,L8n=()=>LA.toasts,M8n=()=>LA.getActiveToasts(),Gr=Object.assign(R8n,{success:LA.success,info:LA.info,warning:LA.warning,error:LA.error,custom:LA.custom,message:LA.message,promise:LA.promise,dismiss:LA.dismiss,loading:LA.loading},{getHistory:L8n,getToasts:M8n});v8n("[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);background:var(--normal-bg);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}");function hte(t){return t.label!==void 0}const P8n=3,O8n="24px",F8n="16px",Uot=4e3,Q8n=356,$8n=14,j8n=45,z8n=200;function ox(...t){return t.filter(Boolean).join(" ")}function U8n(t){const[e,n]=t.split("-"),r=[];return e&&r.push(e),n&&r.push(n),r}const q8n=t=>{var e,n,r,i,o,l,u,d,p;const{invert:m,toast:g,unstyled:h,interacting:f,setHeights:b,visibleToasts:y,heights:v,index:_,toasts:w,expanded:x,removeToast:k,defaultRichColors:C,closeButton:E,style:S,cancelButtonStyle:I,actionButtonStyle:B,className:R="",descriptionClassName:L="",duration:M,position:N,gap:D,expandByDefault:P,classNames:O,icons:F,closeButtonAriaLabel:$="Close toast"}=t,[j,Q]=T.useState(null),[z,U]=T.useState(null),[H,te]=T.useState(!1),[V,re]=T.useState(!1),[ie,X]=T.useState(!1),[W,q]=T.useState(!1),[Y,Z]=T.useState(!1),[ae,de]=T.useState(0),[se,ce]=T.useState(0),ge=T.useRef(g.duration||M||Uot),_e=T.useRef(null),Ce=T.useRef(null),He=_===0,Le=_+1<=y,lt=g.type,pt=g.dismissible!==!1,wt=g.className||"",Lt=g.descriptionClassName||"",Je=T.useMemo(()=>v.findIndex(fe=>fe.toastId===g.id)||0,[v,g.id]),bt=T.useMemo(()=>{var fe;return(fe=g.closeButton)!=null?fe:E},[g.closeButton,E]),Ne=T.useMemo(()=>g.duration||M||Uot,[g.duration,M]),at=T.useRef(0),$t=T.useRef(0),me=T.useRef(0),Xe=T.useRef(null),[oe,Re]=N.split("-"),ye=T.useMemo(()=>v.reduce((fe,xe,dt)=>dt>=Je?fe:fe+xe.height,0),[v,Je]),Qe=T8n(),we=g.invert||m,it=lt==="loading";$t.current=T.useMemo(()=>Je*D+ye,[Je,ye]),T.useEffect(()=>{ge.current=Ne},[Ne]),T.useEffect(()=>{te(!0)},[]),T.useEffect(()=>{const fe=Ce.current;if(fe){const xe=fe.getBoundingClientRect().height;return ce(xe),b(dt=>[{toastId:g.id,height:xe,position:g.position},...dt]),()=>b(dt=>dt.filter(et=>et.toastId!==g.id))}},[b,g.id]),T.useLayoutEffect(()=>{if(!H)return;const fe=Ce.current,xe=fe.style.height;fe.style.height="auto";const dt=fe.getBoundingClientRect().height;fe.style.height=xe,ce(dt),b(et=>et.find(rn=>rn.toastId===g.id)?et.map(rn=>rn.toastId===g.id?{...rn,height:dt}:rn):[{toastId:g.id,height:dt,position:g.position},...et])},[H,g.title,g.description,b,g.id,g.jsx,g.action,g.cancel]);const yt=T.useCallback(()=>{re(!0),de($t.current),b(fe=>fe.filter(xe=>xe.toastId!==g.id)),setTimeout(()=>{k(g)},z8n)},[g,k,b,$t]);T.useEffect(()=>{if(g.promise&&lt==="loading"||g.duration===1/0||g.type==="loading")return;let fe;return x||f||Qe?(()=>{if(me.current<at.current){const et=new Date().getTime()-at.current;ge.current=ge.current-et}me.current=new Date().getTime()})():ge.current!==1/0&&(at.current=new Date().getTime(),fe=setTimeout(()=>{g.onAutoClose==null||g.onAutoClose.call(g,g),yt()},ge.current)),()=>clearTimeout(fe)},[x,f,g,lt,Qe,yt]),T.useEffect(()=>{g.delete&&(yt(),g.onDismiss==null||g.onDismiss.call(g,g))},[yt,g.delete]);function ue(){var fe;if(F?.loading){var xe;return T.createElement("div",{className:ox(O?.loader,g==null||(xe=g.classNames)==null?void 0:xe.loader,"sonner-loader"),"data-visible":lt==="loading"},F.loading)}return T.createElement(x8n,{className:ox(O?.loader,g==null||(fe=g.classNames)==null?void 0:fe.loader),visible:lt==="loading"})}const tt=g.icon||F?.[lt]||_8n(lt);var st,De;return T.createElement("li",{tabIndex:0,ref:Ce,className:ox(R,wt,O?.toast,g==null||(e=g.classNames)==null?void 0:e.toast,O?.default,O?.[lt],g==null||(n=g.classNames)==null?void 0:n[lt]),"data-sonner-toast":"","data-rich-colors":(st=g.richColors)!=null?st:C,"data-styled":!(g.jsx||g.unstyled||h),"data-mounted":H,"data-promise":!!g.promise,"data-swiped":Y,"data-removed":V,"data-visible":Le,"data-y-position":oe,"data-x-position":Re,"data-index":_,"data-front":He,"data-swiping":ie,"data-dismissible":pt,"data-type":lt,"data-invert":we,"data-swipe-out":W,"data-swipe-direction":z,"data-expanded":!!(x||P&&H),"data-testid":g.testId,style:{"--index":_,"--toasts-before":_,"--z-index":w.length-_,"--offset":`${V?ae:$t.current}px`,"--initial-height":P?"auto":`${se}px`,...S,...g.style},onDragEnd:()=>{X(!1),Q(null),Xe.current=null},onPointerDown:fe=>{fe.button!==2&&(it||!pt||(_e.current=new Date,de($t.current),fe.target.setPointerCapture(fe.pointerId),fe.target.tagName!=="BUTTON"&&(X(!0),Xe.current={x:fe.clientX,y:fe.clientY})))},onPointerUp:()=>{var fe,xe,dt;if(W||!pt)return;Xe.current=null;const et=Number(((fe=Ce.current)==null?void 0:fe.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),Yt=Number(((xe=Ce.current)==null?void 0:xe.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),rn=new Date().getTime()-((dt=_e.current)==null?void 0:dt.getTime()),an=j==="x"?et:Yt,Xt=Math.abs(an)/rn;if(Math.abs(an)>=j8n||Xt>.11){de($t.current),g.onDismiss==null||g.onDismiss.call(g,g),U(j==="x"?et>0?"right":"left":Yt>0?"down":"up"),yt(),q(!0);return}else{var Nt,Bt;(Nt=Ce.current)==null||Nt.style.setProperty("--swipe-amount-x","0px"),(Bt=Ce.current)==null||Bt.style.setProperty("--swipe-amount-y","0px")}Z(!1),X(!1),Q(null)},onPointerMove:fe=>{var xe,dt,et;if(!Xe.current||!pt||((xe=window.getSelection())==null?void 0:xe.toString().length)>0)return;const rn=fe.clientY-Xe.current.y,an=fe.clientX-Xe.current.x;var Xt;const Nt=(Xt=t.swipeDirections)!=null?Xt:U8n(N);!j&&(Math.abs(an)>1||Math.abs(rn)>1)&&Q(Math.abs(an)>Math.abs(rn)?"x":"y");let Bt={x:0,y:0};const nt=gn=>1/(1.5+Math.abs(gn)/20);if(j==="y"){if(Nt.includes("top")||Nt.includes("bottom"))if(Nt.includes("top")&&rn<0||Nt.includes("bottom")&&rn>0)Bt.y=rn;else{const gn=rn*nt(rn);Bt.y=Math.abs(gn)<Math.abs(rn)?gn:rn}}else if(j==="x"&&(Nt.includes("left")||Nt.includes("right")))if(Nt.includes("left")&&an<0||Nt.includes("right")&&an>0)Bt.x=an;else{const gn=an*nt(an);Bt.x=Math.abs(gn)<Math.abs(an)?gn:an}(Math.abs(Bt.x)>0||Math.abs(Bt.y)>0)&&Z(!0),(dt=Ce.current)==null||dt.style.setProperty("--swipe-amount-x",`${Bt.x}px`),(et=Ce.current)==null||et.style.setProperty("--swipe-amount-y",`${Bt.y}px`)}},bt&&!g.jsx&&lt!=="loading"?T.createElement("button",{"aria-label":$,"data-disabled":it,"data-close-button":!0,onClick:it||!pt?()=>{}:()=>{yt(),g.onDismiss==null||g.onDismiss.call(g,g)},className:ox(O?.closeButton,g==null||(r=g.classNames)==null?void 0:r.closeButton)},(De=F?.close)!=null?De:I8n):null,(lt||g.icon||g.promise)&&g.icon!==null&&(F?.[lt]!==null||g.icon)?T.createElement("div",{"data-icon":"",className:ox(O?.icon,g==null||(i=g.classNames)==null?void 0:i.icon)},g.promise||g.type==="loading"&&!g.icon?g.icon||ue():null,g.type!=="loading"?tt:null):null,T.createElement("div",{"data-content":"",className:ox(O?.content,g==null||(o=g.classNames)==null?void 0:o.content)},T.createElement("div",{"data-title":"",className:ox(O?.title,g==null||(l=g.classNames)==null?void 0:l.title)},g.jsx?g.jsx:typeof g.title=="function"?g.title():g.title),g.description?T.createElement("div",{"data-description":"",className:ox(L,Lt,O?.description,g==null||(u=g.classNames)==null?void 0:u.description)},typeof g.description=="function"?g.description():g.description):null),T.isValidElement(g.cancel)?g.cancel:g.cancel&&hte(g.cancel)?T.createElement("button",{"data-button":!0,"data-cancel":!0,style:g.cancelButtonStyle||I,onClick:fe=>{hte(g.cancel)&&pt&&(g.cancel.onClick==null||g.cancel.onClick.call(g.cancel,fe),yt())},className:ox(O?.cancelButton,g==null||(d=g.classNames)==null?void 0:d.cancelButton)},g.cancel.label):null,T.isValidElement(g.action)?g.action:g.action&&hte(g.action)?T.createElement("button",{"data-button":!0,"data-action":!0,style:g.actionButtonStyle||B,onClick:fe=>{hte(g.action)&&(g.action.onClick==null||g.action.onClick.call(g.action,fe),!fe.defaultPrevented&&yt())},className:ox(O?.actionButton,g==null||(p=g.classNames)==null?void 0:p.actionButton)},g.action.label):null)};function qot(){if(typeof window>"u"||typeof document>"u")return"ltr";const t=document.documentElement.getAttribute("dir");return t==="auto"||!t?window.getComputedStyle(document.documentElement).direction:t}function G8n(t,e){const n={};return[t,e].forEach((r,i)=>{const o=i===1,l=o?"--mobile-offset":"--offset",u=o?F8n:O8n;function d(p){["top","right","bottom","left"].forEach(m=>{n[`${l}-${m}`]=typeof p=="number"?`${p}px`:p})}typeof r=="number"||typeof r=="string"?d(r):typeof r=="object"?["top","right","bottom","left"].forEach(p=>{r[p]===void 0?n[`${l}-${p}`]=u:n[`${l}-${p}`]=typeof r[p]=="number"?`${r[p]}px`:r[p]}):d(u)}),n}const H8n=T.forwardRef(function(e,n){const{id:r,invert:i,position:o="bottom-right",hotkey:l=["altKey","KeyT"],expand:u,closeButton:d,className:p,offset:m,mobileOffset:g,theme:h="light",richColors:f,duration:b,style:y,visibleToasts:v=P8n,toastOptions:_,dir:w=qot(),gap:x=$8n,icons:k,containerAriaLabel:C="Notifications"}=e,[E,S]=T.useState([]),I=T.useMemo(()=>r?E.filter(H=>H.toasterId===r):E.filter(H=>!H.toasterId),[E,r]),B=T.useMemo(()=>Array.from(new Set([o].concat(I.filter(H=>H.position).map(H=>H.position)))),[I,o]),[R,L]=T.useState([]),[M,N]=T.useState(!1),[D,P]=T.useState(!1),[O,F]=T.useState(h!=="system"?h:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),$=T.useRef(null),j=l.join("+").replace(/Key/g,"").replace(/Digit/g,""),Q=T.useRef(null),z=T.useRef(!1),U=T.useCallback(H=>{S(te=>{var V;return(V=te.find(re=>re.id===H.id))!=null&&V.delete||LA.dismiss(H.id),te.filter(({id:re})=>re!==H.id)})},[]);return T.useEffect(()=>LA.subscribe(H=>{if(H.dismiss){requestAnimationFrame(()=>{S(te=>te.map(V=>V.id===H.id?{...V,delete:!0}:V))});return}setTimeout(()=>{Qi.flushSync(()=>{S(te=>{const V=te.findIndex(re=>re.id===H.id);return V!==-1?[...te.slice(0,V),{...te[V],...H},...te.slice(V+1)]:[H,...te]})})})}),[E]),T.useEffect(()=>{if(h!=="system"){F(h);return}if(h==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?F("dark"):F("light")),typeof window>"u")return;const H=window.matchMedia("(prefers-color-scheme: dark)");try{H.addEventListener("change",({matches:te})=>{F(te?"dark":"light")})}catch{H.addListener(({matches:V})=>{try{F(V?"dark":"light")}catch(re){console.error(re)}})}},[h]),T.useEffect(()=>{E.length<=1&&N(!1)},[E]),T.useEffect(()=>{const H=te=>{var V;if(l.every(X=>te[X]||te.code===X)){var ie;N(!0),(ie=$.current)==null||ie.focus()}te.code==="Escape"&&(document.activeElement===$.current||(V=$.current)!=null&&V.contains(document.activeElement))&&N(!1)};return document.addEventListener("keydown",H),()=>document.removeEventListener("keydown",H)},[l]),T.useEffect(()=>{if($.current)return()=>{Q.current&&(Q.current.focus({preventScroll:!0}),Q.current=null,z.current=!1)}},[$.current]),T.createElement("section",{ref:n,"aria-label":`${C} ${j}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},B.map((H,te)=>{var V;const[re,ie]=H.split("-");return I.length?T.createElement("ol",{key:H,dir:w==="auto"?qot():w,tabIndex:-1,ref:$,className:p,"data-sonner-toaster":!0,"data-sonner-theme":O,"data-y-position":re,"data-x-position":ie,style:{"--front-toast-height":`${((V=R[0])==null?void 0:V.height)||0}px`,"--width":`${Q8n}px`,"--gap":`${x}px`,...y,...G8n(m,g)},onBlur:X=>{z.current&&!X.currentTarget.contains(X.relatedTarget)&&(z.current=!1,Q.current&&(Q.current.focus({preventScroll:!0}),Q.current=null))},onFocus:X=>{X.target instanceof HTMLElement&&X.target.dataset.dismissible==="false"||z.current||(z.current=!0,Q.current=X.relatedTarget)},onMouseEnter:()=>N(!0),onMouseMove:()=>N(!0),onMouseLeave:()=>{D||N(!1)},onDragEnd:()=>N(!1),onPointerDown:X=>{X.target instanceof HTMLElement&&X.target.dataset.dismissible==="false"||P(!0)},onPointerUp:()=>P(!1)},I.filter(X=>!X.position&&te===0||X.position===H).map((X,W)=>{var q,Y;return T.createElement(q8n,{key:X.id,icons:k,index:W,toast:X,defaultRichColors:f,duration:(q=_?.duration)!=null?q:b,className:_?.className,descriptionClassName:_?.descriptionClassName,invert:i,visibleToasts:v,closeButton:(Y=_?.closeButton)!=null?Y:d,interacting:D,position:H,style:_?.style,unstyled:_?.unstyled,classNames:_?.classNames,cancelButtonStyle:_?.cancelButtonStyle,actionButtonStyle:_?.actionButtonStyle,closeButtonAriaLabel:_?.closeButtonAriaLabel,removeToast:U,toasts:I.filter(Z=>Z.position==X.position),heights:R.filter(Z=>Z.position==X.position),setHeights:L,expandByDefault:u,gap:x,expanded:M,swipeDirections:e.swipeDirections})})):null}))});function W8n(){return{needRefresh:[!1,()=>{}],offlineReady:[!1,()=>{}],updateServiceWorker:async()=>{}}}const Got=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim();const Y8n=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const V8n=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase());const Hot=t=>{const e=V8n(t);return e.charAt(0).toUpperCase()+e.slice(1)};var K8n={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const Z8n=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0;return!1};const X8n=T.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i="",children:o,iconNode:l,...u},d)=>T.createElement("svg",{ref:d,...K8n,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:Got("lucide",i),...!o&&!Z8n(u)&&{"aria-hidden":"true"},...u},[...l.map(([p,m])=>T.createElement(p,m)),...Array.isArray(o)?o:[o]]));const Yr=(t,e)=>{const n=T.forwardRef(({className:r,...i},o)=>T.createElement(X8n,{ref:o,iconNode:e,className:Got(`lucide-${Y8n(Hot(t))}`,`lucide-${t}`,r),...i}));return n.displayName=Hot(t),n};const uke=Yr("archive",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]]);const sx=Yr("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);const MP=Yr("arrow-right",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);const Wot=Yr("audio-lines",[["path",{d:"M2 10v3",key:"1fnikh"}],["path",{d:"M6 6v11",key:"11sgs0"}],["path",{d:"M10 3v18",key:"yhl04a"}],["path",{d:"M14 8v7",key:"3a1oy3"}],["path",{d:"M18 5v13",key:"123xd1"}],["path",{d:"M22 10v3",key:"154ddg"}]]);const J8n=Yr("bold",[["path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8",key:"mg9rjx"}]]);const e6n=Yr("book-open",[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]]);const PP=Yr("bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]);const t6n=Yr("braces",[["path",{d:"M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1",key:"ezmyqa"}],["path",{d:"M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1",key:"e1hn23"}]]);const fte=Yr("brain",[["path",{d:"M12 18V5",key:"adv99a"}],["path",{d:"M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4",key:"1e3is1"}],["path",{d:"M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5",key:"1gqd8o"}],["path",{d:"M17.997 5.125a4 4 0 0 1 2.526 5.77",key:"iwvgf7"}],["path",{d:"M18 18a4 4 0 0 0 2-7.464",key:"efp6ie"}],["path",{d:"M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517",key:"1gq6am"}],["path",{d:"M6 18a4 4 0 0 1-2-7.464",key:"k1g0md"}],["path",{d:"M6.003 5.125a4 4 0 0 0-2.526 5.77",key:"q97ue3"}]]);const n6n=Yr("check-check",[["path",{d:"M18 6 7 17l-5-5",key:"116fxf"}],["path",{d:"m22 10-7.5 7.5L13 16",key:"ke71qq"}]]);const th=Yr("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);const df=Yr("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);const dke=Yr("chevron-left",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);const tI=Yr("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);const Ate=Yr("chevron-up",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);const r6n=Yr("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);const Yot=Yr("circle-stop",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]]);const a6n=Yr("circle-x",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);const i6n=Yr("circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);const o6n=Yr("clipboard-copy",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2",key:"4jdomd"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v4",key:"3hqy98"}],["path",{d:"M21 14H11",key:"1bme5i"}],["path",{d:"m15 10-4 4 4 4",key:"5dvupr"}]]);const s6n=Yr("cloud-off",[["path",{d:"M10.94 5.274A7 7 0 0 1 15.71 10h1.79a4.5 4.5 0 0 1 4.222 6.057",key:"1uxyv8"}],["path",{d:"M18.796 18.81A4.5 4.5 0 0 1 17.5 19H9A7 7 0 0 1 5.79 5.78",key:"99tcn7"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);const pke=Yr("code-xml",[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]]);const l6n=Yr("coins",[["path",{d:"M13.744 17.736a6 6 0 1 1-7.48-7.48",key:"bq4yh3"}],["path",{d:"M15 6h1v4",key:"11y1tn"}],["path",{d:"m6.134 14.768.866-.5 2 3.464",key:"17snzx"}],["circle",{cx:"16",cy:"8",r:"6",key:"14bfc9"}]]);const c6n=Yr("columns-3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]]);const u6n=Yr("compass",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z",key:"9ktpf1"}]]);const mke=Yr("copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);const d6n=Yr("cpu",[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]]);const gke=Yr("credit-card",[["rect",{width:"20",height:"14",x:"2",y:"5",rx:"2",key:"ynyp8z"}],["line",{x1:"2",x2:"22",y1:"10",y2:"10",key:"1b3vmo"}]]);const y1=Yr("crown",[["path",{d:"M11.562 3.266a.5.5 0 0 1 .876 0L15.39 8.87a1 1 0 0 0 1.516.294L21.183 5.5a.5.5 0 0 1 .798.519l-2.834 10.246a1 1 0 0 1-.956.734H5.81a1 1 0 0 1-.957-.734L2.02 6.02a.5.5 0 0 1 .798-.519l4.276 3.664a1 1 0 0 0 1.516-.294z",key:"1vdc57"}],["path",{d:"M5 21h14",key:"11awu3"}]]);const v1=Yr("download",[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]]);const Vot=Yr("external-link",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);const Kot=Yr("eye-off",[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);const Zot=Yr("eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);const p6n=Yr("file-code",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}]]);const hke=Yr("file-up",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M12 12v6",key:"3ahymv"}],["path",{d:"m15 15-3-3-3 3",key:"15xj92"}]]);const Xot=Yr("film",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7 3v18",key:"bbkbws"}],["path",{d:"M3 7.5h4",key:"zfgn84"}],["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 16.5h4",key:"1230mu"}],["path",{d:"M17 3v18",key:"in4fa5"}],["path",{d:"M17 7.5h4",key:"myr1c1"}],["path",{d:"M17 16.5h4",key:"go4c1d"}]]);const Jot=Yr("folder-open",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]);const fke=Yr("folder",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);const bte=Yr("gem",[["path",{d:"M10.5 3 8 9l4 13 4-13-2.5-6",key:"b3dvk1"}],["path",{d:"M17 3a2 2 0 0 1 1.6.8l3 4a2 2 0 0 1 .013 2.382l-7.99 10.986a2 2 0 0 1-3.247 0l-7.99-10.986A2 2 0 0 1 2.4 7.8l2.998-3.997A2 2 0 0 1 7 3z",key:"7w4byz"}],["path",{d:"M2 9h20",key:"16fsjt"}]]);const est=Yr("gift",[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M20 11v8a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-8",key:"1sqzm4"}],["path",{d:"M7.5 7a1 1 0 0 1 0-5A4.8 8 0 0 1 12 7a4.8 8 0 0 1 4.5-5 1 1 0 0 1 0 5",key:"kc0143"}],["rect",{x:"3",y:"7",width:"18",height:"4",rx:"1",key:"1hberx"}]]);const tst=Yr("github",[["path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4",key:"tonef"}],["path",{d:"M9 18c-4.51 2-5-2-7-2",key:"9comsn"}]]);const Ake=Yr("globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);const m6n=Yr("heading-1",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"m17 12 3-2v8",key:"1hhhft"}]]);const g6n=Yr("heading-2",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1",key:"9jr5yi"}]]);const h6n=Yr("heading-3",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2",key:"68ncm8"}],["path",{d:"M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2",key:"1ejuhz"}]]);const f6n=Yr("heading-4",[["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17 10v3a1 1 0 0 0 1 1h3",key:"tj5zdr"}],["path",{d:"M21 10v8",key:"1kdml4"}],["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}]]);const A6n=Yr("heading-5",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17 13v-3h4",key:"1nvgqp"}],["path",{d:"M17 17.7c.4.2.8.3 1.3.3 1.5 0 2.7-1.1 2.7-2.5S19.8 13 18.3 13H17",key:"2nebdn"}]]);const b6n=Yr("heading-6",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["circle",{cx:"19",cy:"16",r:"2",key:"15mx69"}],["path",{d:"M20 10c-2 2-3 3.5-3 6",key:"f35dl0"}]]);const OP=Yr("image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]);const y6n=Yr("inbox",[["polyline",{points:"22 12 16 12 14 15 10 15 8 12 2 12",key:"o97t9d"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}]]);const F7=Yr("info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]);const v6n=Yr("italic",[["line",{x1:"19",x2:"10",y1:"4",y2:"4",key:"15jd3p"}],["line",{x1:"14",x2:"5",y1:"20",y2:"20",key:"bu0au3"}],["line",{x1:"15",x2:"9",y1:"4",y2:"20",key:"uljnxc"}]]);const FP=Yr("link",[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]]);const nst=Yr("list-ordered",[["path",{d:"M11 5h10",key:"1cz7ny"}],["path",{d:"M11 12h10",key:"1438ji"}],["path",{d:"M11 19h10",key:"11t30w"}],["path",{d:"M4 4h1v5",key:"10yrso"}],["path",{d:"M4 9h2",key:"r1h2o0"}],["path",{d:"M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02",key:"xtkcd5"}]]);const rst=Yr("list",[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]]);const nh=Yr("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);const bke=Yr("log-in",[["path",{d:"m10 17 5-5-5-5",key:"1bsop3"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}]]);const ast=Yr("mail-open",[["path",{d:"M21.2 8.4c.5.38.8.97.8 1.6v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V10a2 2 0 0 1 .8-1.6l8-6a2 2 0 0 1 2.4 0l8 6Z",key:"1jhwl8"}],["path",{d:"m22 10-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 10",key:"1qfld7"}]]);const yte=Yr("mail",[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}]]);const _6n=Yr("message-square-plus",[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}],["path",{d:"M12 8v6",key:"1ib9pf"}],["path",{d:"M9 11h6",key:"1fldmi"}]]);const yke=Yr("message-square",[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]]);const ist=Yr("minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);const w6n=Yr("monitor",[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]]);const x6n=Yr("octagon-x",[["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"M2.586 16.726A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2h6.624a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586z",key:"2d38gg"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);const k6n=Yr("panel-right-close",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m8 9 3 3-3 3",key:"12hl5m"}]]);const Q7=Yr("phone",[["path",{d:"M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384",key:"9njp5v"}]]);const E6n=Yr("pilcrow",[["path",{d:"M13 4v16",key:"8vvj80"}],["path",{d:"M17 4v16",key:"7dpous"}],["path",{d:"M19 4H9.5a4.5 4.5 0 0 0 0 9H13",key:"sh4n9v"}]]);const ost=Yr("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);const C6n=Yr("quote",[["path",{d:"M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"rib7q0"}],["path",{d:"M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"1ymkrd"}]]);const S6n=Yr("redo-2",[["path",{d:"m15 14 5-5-5-5",key:"12vg1m"}],["path",{d:"M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13",key:"6uklza"}]]);const sst=Yr("refresh-cw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);const I6n=Yr("scale",[["path",{d:"M12 3v18",key:"108xh3"}],["path",{d:"m19 8 3 8a5 5 0 0 1-6 0zV7",key:"zcdpyk"}],["path",{d:"M3 7h1a17 17 0 0 0 8-2 17 17 0 0 0 8 2h1",key:"1yorad"}],["path",{d:"m5 8 3 8a5 5 0 0 1-6 0zV7",key:"eua70x"}],["path",{d:"M7 21h10",key:"1b0cd5"}]]);const T6n=Yr("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]);const B6n=Yr("share-2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]]);const D6n=Yr("shield-alert",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]]);const vte=Yr("shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]);const N6n=Yr("smartphone",[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]]);const lx=Yr("sparkles",[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]]);const R6n=Yr("square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);const L6n=Yr("strikethrough",[["path",{d:"M16 4H9a3 3 0 0 0-2.83 4",key:"43sutm"}],["path",{d:"M14 12a4 4 0 0 1 0 8H6",key:"nlfj13"}],["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}]]);const M6n=Yr("terminal",[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]]);const P6n=Yr("text-align-start",[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 19H3",key:"z6ezky"}]]);const _te=Yr("trash-2",[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]]);const vke=Yr("triangle-alert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);const lst=Yr("undo-2",[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]);const O6n=Yr("unlink",[["path",{d:"m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71",key:"yqzxt4"}],["path",{d:"m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71",key:"4qinb0"}],["line",{x1:"8",x2:"8",y1:"2",y2:"5",key:"1041cp"}],["line",{x1:"2",x2:"5",y1:"8",y2:"8",key:"14m1p5"}],["line",{x1:"16",x2:"16",y1:"19",y2:"22",key:"rzdirn"}],["line",{x1:"19",x2:"22",y1:"16",y2:"16",key:"ox905f"}]]);const wte=Yr("user",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);const xte=Yr("users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]]);const F6n=Yr("video",[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]]);const Q6n=Yr("wallet",[["path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1",key:"18etb6"}],["path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4",key:"xoc0q4"}]]);const _1=Yr("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);const kte=Yr("zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]);function $6n({title:t,description:e,actionLabel:n,cancelLabel:r,onAction:i,onCancel:o}){return A.jsxs("div",{className:"flex w-[360px] flex-col gap-3 rounded-lg border border-neutral-200/60 bg-white p-4 shadow-lg dark:border-neutral-800/60 dark:bg-neutral-900",children:[A.jsxs("div",{className:"flex items-start gap-3",children:[A.jsx("div",{className:"mt-0.5 shrink-0 rounded-full bg-indigo-500/10 p-1.5",children:A.jsx(sst,{className:"size-4 text-indigo-500"})}),A.jsxs("div",{className:"min-w-0",children:[A.jsx("p",{className:"text-[13px] font-semibold text-neutral-900 dark:text-neutral-100",children:t}),A.jsx("p",{className:"mt-0.5 text-xs text-neutral-500 dark:text-neutral-400",children:e})]})]}),A.jsxs("div",{className:"flex flex-col gap-1.5",children:[A.jsx("button",{onClick:i,className:"w-full rounded-lg bg-indigo-500 px-3 py-2 text-[13px] font-semibold text-white transition-colors hover:bg-indigo-600 active:bg-indigo-700",children:n}),A.jsx("button",{onClick:o,className:"w-full rounded-lg bg-neutral-100/80 px-3 py-2 text-[13px] text-neutral-600 transition-colors hover:bg-neutral-200/80 dark:bg-white/[0.06] dark:text-neutral-400 dark:hover:bg-white/[0.1]",children:r})]})]})}function j6n(){const{t}=Cn(),e=T.useRef(null),n=T.useRef(null),{needRefresh:[r],updateServiceWorker:i}=W8n();T.useEffect(()=>()=>{n.current?.(),n.current=null},[]);const o=T.useCallback(()=>{i()},[i]);T.useEffect(()=>{if(!r){e.current!=null&&(Gr.dismiss(e.current),e.current=null);return}e.current=Gr.custom(l=>$6n({title:t("app.pwa.updateAvailableTitle","New version available"),description:t("app.pwa.updateAvailableDescription","A new version of Xyzen is ready. Refresh to update."),actionLabel:t("app.pwa.updateAction","Refresh"),cancelLabel:t("app.pwa.updateDismiss","Dismiss"),onAction:o,onCancel:()=>{Gr.dismiss(l),e.current=null}}),{duration:1/0})},[r,o,t])}function z6n(){const t=Xg(),e=(t.isAuthenticated||!!t.token)&&RA("billing"),n=Un(i=>i.fetchWallet),r=Un(i=>i.connectWalletEvents);T.useEffect(()=>e?(n(),r()):void 0,[e,n,r])}const U6n=({...t})=>A.jsx(H8n,{theme:"system",className:"toaster group",richColors:!0,icons:{success:A.jsx(r6n,{className:"size-4"}),info:A.jsx(F7,{className:"size-4"}),warning:A.jsx(vke,{className:"size-4"}),error:A.jsx(x6n,{className:"size-4"}),loading:A.jsx(nh,{className:"size-4 animate-spin"})},style:{"--normal-bg":"var(--popover)","--normal-text":"var(--popover-foreground)","--normal-border":"var(--border)","--border-radius":"var(--radius)"},...t}),$7=T.createContext({});function nI(t){const e=T.useRef(null);return e.current===null&&(e.current=t()),e.current}const Ete=typeof window<"u"?T.useLayoutEffect:T.useEffect,Cte=T.createContext(null);function _ke(t,e){t.indexOf(e)===-1&&t.push(e)}function QP(t,e){const n=t.indexOf(e);n>-1&&t.splice(n,1)}const cx=(t,e,n)=>n>e?e:n<t?t:n;function wke(t,e){return e?`${t}. For more information and steps for solving, visit https://motion.dev/troubleshooting/${e}`:t}let $P=()=>{},Gv=()=>{};typeof process<"u"&&process.env?.NODE_ENV!=="production"&&($P=(t,e,n)=>{!t&&typeof console<"u"&&console.warn(wke(e,n))},Gv=(t,e,n)=>{if(!t)throw new Error(wke(e,n))});const rI={},cst=t=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t);function ust(t){return typeof t=="object"&&t!==null}const dst=t=>/^0[^.\s]+$/u.test(t);function pst(t){let e;return()=>(e===void 0&&(e=t()),e)}const ty=t=>t,q6n=(t,e)=>n=>e(t(n)),j7=(...t)=>t.reduce(q6n),jP=(t,e,n)=>{const r=e-t;return r===0?1:(n-t)/r};class xke{constructor(){this.subscriptions=[]}add(e){return _ke(this.subscriptions,e),()=>QP(this.subscriptions,e)}notify(e,n,r){const i=this.subscriptions.length;if(i)if(i===1)this.subscriptions[0](e,n,r);else for(let o=0;o<i;o++){const l=this.subscriptions[o];l&&l(e,n,r)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const pf=t=>t*1e3,ny=t=>t/1e3;function mst(t,e){return e?t*(1e3/e):0}const gst=new Set;function kke(t,e,n){t||gst.has(e)||(console.warn(wke(e,n)),gst.add(e))}const G6n=(t,e,n)=>{const r=e-t;return((n-t)%r+r)%r+t},hst=(t,e,n)=>(((1-3*n+3*e)*t+(3*n-6*e))*t+3*e)*t,H6n=1e-7,W6n=12;function Y6n(t,e,n,r,i){let o,l,u=0;do l=e+(n-e)/2,o=hst(l,r,i)-t,o>0?n=l:e=l;while(Math.abs(o)>H6n&&++u<W6n);return l}function z7(t,e,n,r){if(t===e&&n===r)return ty;const i=o=>Y6n(o,0,1,t,n);return o=>o===0||o===1?o:hst(i(o),e,r)}const fst=t=>e=>e<=.5?t(2*e)/2:(2-t(2*(1-e)))/2,Ast=t=>e=>1-t(1-e),bst=z7(.33,1.53,.69,.99),Eke=Ast(bst),yst=fst(Eke),vst=t=>t>=1?1:(t*=2)<1?.5*Eke(t):.5*(2-Math.pow(2,-10*(t-1))),Cke=t=>1-Math.sin(Math.acos(t)),_st=Ast(Cke),wst=fst(Cke),V6n=z7(.42,0,1,1),Ske=z7(0,0,.58,1),xst=z7(.42,0,.58,1),kst=t=>Array.isArray(t)&&typeof t[0]!="number";function Est(t,e){return kst(t)?t[G6n(0,t.length,e)]:t}const Cst=t=>Array.isArray(t)&&typeof t[0]=="number",Sst={linear:ty,easeIn:V6n,easeInOut:xst,easeOut:Ske,circIn:Cke,circInOut:wst,circOut:_st,backIn:Eke,backInOut:yst,backOut:bst,anticipate:vst},K6n=t=>typeof t=="string",Ist=t=>{if(Cst(t)){Gv(t.length===4,"Cubic bezier arrays must contain four numerical values.","cubic-bezier-length");const[e,n,r,i]=t;return z7(e,n,r,i)}else if(K6n(t))return Gv(Sst[t]!==void 0,`Invalid easing type '${t}'`,"invalid-easing-type"),Sst[t];return t},Ste=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function Z6n(t,e){let n=new Set,r=new Set,i=!1,o=!1;const l=new WeakSet;let u={delta:0,timestamp:0,isProcessing:!1};function d(m){l.has(m)&&(p.schedule(m),t()),m(u)}const p={schedule:(m,g=!1,h=!1)=>{const b=h&&i?n:r;return g&&l.add(m),b.add(m),m},cancel:m=>{r.delete(m),l.delete(m)},process:m=>{if(u=m,i){o=!0;return}i=!0;const g=n;n=r,r=g,n.forEach(d),n.clear(),i=!1,o&&(o=!1,p.process(m))}};return p}const X6n=40;function Tst(t,e){let n=!1,r=!0;const i={delta:0,timestamp:0,isProcessing:!1},o=()=>n=!0,l=Ste.reduce((x,k)=>(x[k]=Z6n(o),x),{}),{setup:u,read:d,resolveKeyframes:p,preUpdate:m,update:g,preRender:h,render:f,postRender:b}=l,y=()=>{const x=rI.useManualTiming,k=x?i.timestamp:performance.now();n=!1,x||(i.delta=r?1e3/60:Math.max(Math.min(k-i.timestamp,X6n),1)),i.timestamp=k,i.isProcessing=!0,u.process(i),d.process(i),p.process(i),m.process(i),g.process(i),h.process(i),f.process(i),b.process(i),i.isProcessing=!1,n&&e&&(r=!1,t(y))},v=()=>{n=!0,r=!0,i.isProcessing||t(y)};return{schedule:Ste.reduce((x,k)=>{const C=l[k];return x[k]=(E,S=!1,I=!1)=>(n||v(),C.schedule(E,S,I)),x},{}),cancel:x=>{for(let k=0;k<Ste.length;k++)l[Ste[k]].cancel(x)},state:i,steps:l}}const{schedule:Nl,cancel:w1,state:pg,steps:Ike}=Tst(typeof requestAnimationFrame<"u"?requestAnimationFrame:ty,!0);let Ite;function J6n(){Ite=void 0}const mf={now:()=>(Ite===void 0&&mf.set(pg.isProcessing||rI.useManualTiming?pg.timestamp:performance.now()),Ite),set:t=>{Ite=t,queueMicrotask(J6n)}},Bst=t=>e=>typeof e=="string"&&e.startsWith(t),Dst=Bst("--"),e9n=Bst("var(--"),Tke=t=>e9n(t)?t9n.test(t.split("/*")[0].trim()):!1,t9n=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function Nst(t){return typeof t!="string"?!1:t.split("/*")[0].includes("var(--")}const zP={test:t=>typeof t=="number",parse:parseFloat,transform:t=>t},U7={...zP,transform:t=>cx(0,1,t)},Tte={...zP,default:1},q7=t=>Math.round(t*1e5)/1e5,Bke=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function n9n(t){return t==null}const r9n=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,Dke=(t,e)=>n=>!!(typeof n=="string"&&r9n.test(n)&&n.startsWith(t)||e&&!n9n(n)&&Object.prototype.hasOwnProperty.call(n,e)),Rst=(t,e,n)=>r=>{if(typeof r!="string")return r;const[i,o,l,u]=r.match(Bke);return{[t]:parseFloat(i),[e]:parseFloat(o),[n]:parseFloat(l),alpha:u!==void 0?parseFloat(u):1}},a9n=t=>cx(0,255,t),Nke={...zP,transform:t=>Math.round(a9n(t))},RN={test:Dke("rgb","red"),parse:Rst("red","green","blue"),transform:({red:t,green:e,blue:n,alpha:r=1})=>"rgba("+Nke.transform(t)+", "+Nke.transform(e)+", "+Nke.transform(n)+", "+q7(U7.transform(r))+")"};function i9n(t){let e="",n="",r="",i="";return t.length>5?(e=t.substring(1,3),n=t.substring(3,5),r=t.substring(5,7),i=t.substring(7,9)):(e=t.substring(1,2),n=t.substring(2,3),r=t.substring(3,4),i=t.substring(4,5),e+=e,n+=n,r+=r,i+=i),{red:parseInt(e,16),green:parseInt(n,16),blue:parseInt(r,16),alpha:i?parseInt(i,16)/255:1}}const Rke={test:Dke("#"),parse:i9n,transform:RN.transform},G7=t=>({test:e=>typeof e=="string"&&e.endsWith(t)&&e.split(" ").length===1,parse:parseFloat,transform:e=>`${e}${t}`}),aI=G7("deg"),ux=G7("%"),Ja=G7("px"),o9n=G7("vh"),s9n=G7("vw"),Lst={...ux,parse:t=>ux.parse(t)/100,transform:t=>ux.transform(t*100)},UP={test:Dke("hsl","hue"),parse:Rst("hue","saturation","lightness"),transform:({hue:t,saturation:e,lightness:n,alpha:r=1})=>"hsla("+Math.round(t)+", "+ux.transform(q7(e))+", "+ux.transform(q7(n))+", "+q7(U7.transform(r))+")"},ep={test:t=>RN.test(t)||Rke.test(t)||UP.test(t),parse:t=>RN.test(t)?RN.parse(t):UP.test(t)?UP.parse(t):Rke.parse(t),transform:t=>typeof t=="string"?t:t.hasOwnProperty("red")?RN.transform(t):UP.transform(t),getAnimatableNone:t=>{const e=ep.parse(t);return e.alpha=0,ep.transform(e)}},l9n=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function c9n(t){return isNaN(t)&&typeof t=="string"&&(t.match(Bke)?.length||0)+(t.match(l9n)?.length||0)>0}const Mst="number",Pst="color",u9n="var",d9n="var(",Ost="${}",p9n=/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 qP(t){const e=t.toString(),n=[],r={color:[],number:[],var:[]},i=[];let o=0;const u=e.replace(p9n,d=>(ep.test(d)?(r.color.push(o),i.push(Pst),n.push(ep.parse(d))):d.startsWith(d9n)?(r.var.push(o),i.push(u9n),n.push(d)):(r.number.push(o),i.push(Mst),n.push(parseFloat(d))),++o,Ost)).split(Ost);return{values:n,split:u,indexes:r,types:i}}function m9n(t){return qP(t).values}function Fst({split:t,types:e}){const n=t.length;return r=>{let i="";for(let o=0;o<n;o++)if(i+=t[o],r[o]!==void 0){const l=e[o];l===Mst?i+=q7(r[o]):l===Pst?i+=ep.transform(r[o]):i+=r[o]}return i}}function g9n(t){return Fst(qP(t))}const h9n=t=>typeof t=="number"?0:ep.test(t)?ep.getAnimatableNone(t):t,f9n=(t,e)=>typeof t=="number"?e?.trim().endsWith("/")?t:0:h9n(t);function A9n(t){const e=qP(t);return Fst(e)(e.values.map((r,i)=>f9n(r,e.split[i])))}const Hv={test:c9n,parse:m9n,createTransformer:g9n,getAnimatableNone:A9n};function Lke(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+(e-t)*6*n:n<1/2?e:n<2/3?t+(e-t)*(2/3-n)*6:t}function b9n({hue:t,saturation:e,lightness:n,alpha:r}){t/=360,e/=100,n/=100;let i=0,o=0,l=0;if(!e)i=o=l=n;else{const u=n<.5?n*(1+e):n+e-n*e,d=2*n-u;i=Lke(d,u,t+1/3),o=Lke(d,u,t),l=Lke(d,u,t-1/3)}return{red:Math.round(i*255),green:Math.round(o*255),blue:Math.round(l*255),alpha:r}}function Bte(t,e){return n=>n>0?e:t}const Bc=(t,e,n)=>t+(e-t)*n,Mke=(t,e,n)=>{const r=t*t,i=n*(e*e-r)+r;return i<0?0:Math.sqrt(i)},y9n=[Rke,RN,UP],v9n=t=>y9n.find(e=>e.test(t));function Qst(t){const e=v9n(t);if($P(!!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===UP&&(n=b9n(n)),n}const $st=(t,e)=>{const n=Qst(t),r=Qst(e);if(!n||!r)return Bte(t,e);const i={...n};return o=>(i.red=Mke(n.red,r.red,o),i.green=Mke(n.green,r.green,o),i.blue=Mke(n.blue,r.blue,o),i.alpha=Bc(n.alpha,r.alpha,o),RN.transform(i))},Pke=new Set(["none","hidden"]);function _9n(t,e){return Pke.has(t)?n=>n<=0?t:e:n=>n>=1?e:t}function w9n(t,e){return n=>Bc(t,e,n)}function Oke(t){return typeof t=="number"?w9n:typeof t=="string"?Tke(t)?Bte:ep.test(t)?$st:E9n:Array.isArray(t)?jst:typeof t=="object"?ep.test(t)?$st:x9n:Bte}function jst(t,e){const n=[...t],r=n.length,i=t.map((o,l)=>Oke(o)(o,e[l]));return o=>{for(let l=0;l<r;l++)n[l]=i[l](o);return n}}function x9n(t,e){const n={...t,...e},r={};for(const i in n)t[i]!==void 0&&e[i]!==void 0&&(r[i]=Oke(t[i])(t[i],e[i]));return i=>{for(const o in r)n[o]=r[o](i);return n}}function k9n(t,e){const n=[],r={color:0,var:0,number:0};for(let i=0;i<e.values.length;i++){const o=e.types[i],l=t.indexes[o][r[o]],u=t.values[l]??0;n[i]=u,r[o]++}return n}const E9n=(t,e)=>{const n=Hv.createTransformer(e),r=qP(t),i=qP(e);return r.indexes.var.length===i.indexes.var.length&&r.indexes.color.length===i.indexes.color.length&&r.indexes.number.length>=i.indexes.number.length?Pke.has(t)&&!i.values.length||Pke.has(e)&&!r.values.length?_9n(t,e):j7(jst(k9n(r,i),i.values),n):($P(!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"),Bte(t,e))};function zst(t,e,n){return typeof t=="number"&&typeof e=="number"&&typeof n=="number"?Bc(t,e,n):Oke(t)(t,e)}const C9n=t=>{const e=({timestamp:n})=>t(n);return{start:(n=!0)=>Nl.update(e,n),stop:()=>w1(e),now:()=>pg.isProcessing?pg.timestamp:mf.now()}},Ust=(t,e,n=10)=>{let r="";const i=Math.max(Math.round(e/n),2);for(let o=0;o<i;o++)r+=Math.round(t(o/(i-1))*1e4)/1e4+", ";return`linear(${r.substring(0,r.length-2)})`},Dte=2e4;function Fke(t){let e=0;const n=50;let r=t.next(e);for(;!r.done&&e<Dte;)e+=n,r=t.next(e);return e>=Dte?1/0:e}function qst(t,e=100,n){const r=n({...t,keyframes:[0,e]}),i=Math.min(Fke(r),Dte);return{type:"keyframes",ease:o=>r.next(i*o).value/e,duration:ny(i)}}const Ru={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};function Qke(t,e){return t*Math.sqrt(1-e*e)}const S9n=12;function I9n(t,e,n){let r=n;for(let i=1;i<S9n;i++)r=r-t(r)/e(r);return r}const $ke=.001;function T9n({duration:t=Ru.duration,bounce:e=Ru.bounce,velocity:n=Ru.velocity,mass:r=Ru.mass}){let i,o;$P(t<=pf(Ru.maxDuration),"Spring duration must be 10 seconds or less","spring-duration-limit");let l=1-e;l=cx(Ru.minDamping,Ru.maxDamping,l),t=cx(Ru.minDuration,Ru.maxDuration,ny(t)),l<1?(i=p=>{const m=p*l,g=m*t,h=m-n,f=Qke(p,l),b=Math.exp(-g);return $ke-h/f*b},o=p=>{const g=p*l*t,h=g*n+n,f=Math.pow(l,2)*Math.pow(p,2)*t,b=Math.exp(-g),y=Qke(Math.pow(p,2),l);return(-i(p)+$ke>0?-1:1)*((h-f)*b)/y}):(i=p=>{const m=Math.exp(-p*t),g=(p-n)*t+1;return-$ke+m*g},o=p=>{const m=Math.exp(-p*t),g=(n-p)*(t*t);return m*g});const u=5/t,d=I9n(i,o,u);if(t=pf(t),isNaN(d))return{stiffness:Ru.stiffness,damping:Ru.damping,duration:t};{const p=Math.pow(d,2)*r;return{stiffness:p,damping:l*2*Math.sqrt(r*p),duration:t}}}const B9n=["duration","bounce"],D9n=["stiffness","damping","mass"];function Gst(t,e){return e.some(n=>t[n]!==void 0)}function N9n(t){let e={velocity:Ru.velocity,stiffness:Ru.stiffness,damping:Ru.damping,mass:Ru.mass,isResolvedFromDuration:!1,...t};if(!Gst(t,D9n)&&Gst(t,B9n))if(e.velocity=0,t.visualDuration){const n=t.visualDuration,r=2*Math.PI/(n*1.2),i=r*r,o=2*cx(.05,1,1-(t.bounce||0))*Math.sqrt(i);e={...e,mass:Ru.mass,stiffness:i,damping:o}}else{const n=T9n({...t,velocity:0});e={...e,...n,mass:Ru.mass},e.isResolvedFromDuration=!0}return e}function H7(t=Ru.visualDuration,e=Ru.bounce){const n=typeof t!="object"?{visualDuration:t,keyframes:[0,1],bounce:e}:t;let{restSpeed:r,restDelta:i}=n;const o=n.keyframes[0],l=n.keyframes[n.keyframes.length-1],u={done:!1,value:o},{stiffness:d,damping:p,mass:m,duration:g,velocity:h,isResolvedFromDuration:f}=N9n({...n,velocity:-ny(n.velocity||0)}),b=h||0,y=p/(2*Math.sqrt(d*m)),v=l-o,_=ny(Math.sqrt(d/m)),w=Math.abs(v)<5;r||(r=w?Ru.restSpeed.granular:Ru.restSpeed.default),i||(i=w?Ru.restDelta.granular:Ru.restDelta.default);let x,k,C,E,S,I;if(y<1)C=Qke(_,y),E=(b+y*_*v)/C,x=R=>{const L=Math.exp(-y*_*R);return l-L*(E*Math.sin(C*R)+v*Math.cos(C*R))},S=y*_*E+v*C,I=y*_*v-E*C,k=R=>Math.exp(-y*_*R)*(S*Math.sin(C*R)+I*Math.cos(C*R));else if(y===1){x=L=>l-Math.exp(-_*L)*(v+(b+_*v)*L);const R=b+_*v;k=L=>Math.exp(-_*L)*(_*R*L-b)}else{const R=_*Math.sqrt(y*y-1);x=D=>{const P=Math.exp(-y*_*D),O=Math.min(R*D,300);return l-P*((b+y*_*v)*Math.sinh(O)+R*v*Math.cosh(O))/R};const L=(b+y*_*v)/R,M=y*_*L-v*R,N=y*_*v-L*R;k=D=>{const P=Math.exp(-y*_*D),O=Math.min(R*D,300);return P*(M*Math.sinh(O)+N*Math.cosh(O))}}const B={calculatedDuration:f&&g||null,velocity:R=>pf(k(R)),next:R=>{if(!f&&y<1){const M=Math.exp(-y*_*R),N=Math.sin(C*R),D=Math.cos(C*R),P=l-M*(E*N+v*D),O=pf(M*(S*N+I*D));return u.done=Math.abs(O)<=r&&Math.abs(l-P)<=i,u.value=u.done?l:P,u}const L=x(R);if(f)u.done=R>=g;else{const M=pf(k(R));u.done=Math.abs(M)<=r&&Math.abs(l-L)<=i}return u.value=u.done?l:L,u},toString:()=>{const R=Math.min(Fke(B),Dte),L=Ust(M=>B.next(R*M).value,R,30);return R+"ms "+L},toTransition:()=>{}};return B}H7.applyToOptions=t=>{const e=qst(t,100,H7);return t.ease=e.ease,t.duration=pf(e.duration),t.type="keyframes",t};const R9n=5;function Hst(t,e,n){const r=Math.max(e-R9n,0);return mst(n-t(r),e-r)}function jke({keyframes:t,velocity:e=0,power:n=.8,timeConstant:r=325,bounceDamping:i=10,bounceStiffness:o=500,modifyTarget:l,min:u,max:d,restDelta:p=.5,restSpeed:m}){const g=t[0],h={done:!1,value:g},f=I=>u!==void 0&&I<u||d!==void 0&&I>d,b=I=>u===void 0?d:d===void 0||Math.abs(u-I)<Math.abs(d-I)?u:d;let y=n*e;const v=g+y,_=l===void 0?v:l(v);_!==v&&(y=_-g);const w=I=>-y*Math.exp(-I/r),x=I=>_+w(I),k=I=>{const B=w(I),R=x(I);h.done=Math.abs(B)<=p,h.value=h.done?_:R};let C,E;const S=I=>{f(h.value)&&(C=I,E=H7({keyframes:[h.value,b(h.value)],velocity:Hst(x,I,h.value),damping:i,stiffness:o,restDelta:p,restSpeed:m}))};return S(0),{calculatedDuration:null,next:I=>{let B=!1;return!E&&C===void 0&&(B=!0,k(I),S(I)),C!==void 0&&I>=C?E.next(I-C):(!B&&k(I),h)}}}function L9n(t,e,n){const r=[],i=n||rI.mix||zst,o=t.length-1;for(let l=0;l<o;l++){let u=i(t[l],t[l+1]);if(e){const d=Array.isArray(e)?e[l]||ty:e;u=j7(d,u)}r.push(u)}return r}function Wst(t,e,{clamp:n=!0,ease:r,mixer:i}={}){const o=t.length;if(Gv(o===e.length,"Both input and output ranges must be the same length","range-length"),o===1)return()=>e[0];if(o===2&&e[0]===e[1])return()=>e[1];const l=t[0]===t[1];t[0]>t[o-1]&&(t=[...t].reverse(),e=[...e].reverse());const u=L9n(e,r,i),d=u.length,p=m=>{if(l&&m<t[0])return e[0];let g=0;if(d>1)for(;g<t.length-2&&!(m<t[g+1]);g++);const h=jP(t[g],t[g+1],m);return u[g](h)};return n?m=>p(cx(t[0],t[o-1],m)):p}function Yst(t,e){const n=t[t.length-1];for(let r=1;r<=e;r++){const i=jP(0,e,r);t.push(Bc(n,1,i))}}function Vst(t){const e=[0];return Yst(e,t.length-1),e}function M9n(t,e){return t.map(n=>n*e)}function P9n(t,e){return t.map(()=>e||xst).splice(0,t.length-1)}function GP({duration:t=300,keyframes:e,times:n,ease:r="easeInOut"}){const i=kst(r)?r.map(Ist):Ist(r),o={done:!1,value:e[0]},l=M9n(n&&n.length===e.length?n:Vst(e),t),u=Wst(l,e,{ease:Array.isArray(i)?i:P9n(e,i)});return{calculatedDuration:t,next:d=>(o.value=u(d),o.done=d>=t,o)}}const O9n=t=>t!==null;function Nte(t,{repeat:e,repeatType:n="loop"},r,i=1){const o=t.filter(O9n),u=i<0||e&&n!=="loop"&&e%2===1?0:o.length-1;return!u||r===void 0?o[u]:r}const F9n={decay:jke,inertia:jke,tween:GP,keyframes:GP,spring:H7};function Kst(t){typeof t.type=="string"&&(t.type=F9n[t.type])}class zke{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)}}const Q9n=t=>t/100;class W7 extends zke{constructor(e){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.delayState={done:!1,value:void 0},this.stop=()=>{const{motionValue:n}=this.options;n&&n.updatedAt!==mf.now()&&this.tick(mf.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;Kst(e);const{type:n=GP,repeat:r=0,repeatDelay:i=0,repeatType:o,velocity:l=0}=e;let{keyframes:u}=e;const d=n||GP;process.env.NODE_ENV!=="production"&&d!==GP&&Gv(u.length<=2,`Only two keyframes currently supported with spring and inertia animations. Trying to animate ${u}`,"spring-two-frames"),d!==GP&&typeof u[0]!="number"&&(this.mixKeyframes=j7(Q9n,zst(u[0],u[1])),u=[0,100]);const p=d({...e,keyframes:u});o==="mirror"&&(this.mirroredGenerator=d({...e,keyframes:[...u].reverse(),velocity:-l})),p.calculatedDuration===null&&(p.calculatedDuration=Fke(p));const{calculatedDuration:m}=p;this.calculatedDuration=m,this.resolvedDuration=m+i,this.totalDuration=this.resolvedDuration*(r+1)-i,this.generator=p}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:r,totalDuration:i,mixKeyframes:o,mirroredGenerator:l,resolvedDuration:u,calculatedDuration:d}=this;if(this.startTime===null)return r.next(0);const{delay:p=0,keyframes:m,repeat:g,repeatType:h,repeatDelay:f,type:b,onUpdate:y,finalKeyframe:v}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,e):this.speed<0&&(this.startTime=Math.min(e-i/this.speed,this.startTime)),n?this.currentTime=e:this.updateTime(e);const _=this.currentTime-p*(this.playbackSpeed>=0?1:-1),w=this.playbackSpeed>=0?_<0:_>i;this.currentTime=Math.max(_,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=i);let x=this.currentTime,k=r;if(g){const I=Math.min(this.currentTime,i)/u;let B=Math.floor(I),R=I%1;!R&&I>=1&&(R=1),R===1&&B--,B=Math.min(B,g+1),B%2&&(h==="reverse"?(R=1-R,f&&(R-=f/u)):h==="mirror"&&(k=l)),x=cx(0,1,R)*u}let C;w?(this.delayState.value=m[0],C=this.delayState):C=k.next(x),o&&!w&&(C.value=o(C.value));let{done:E}=C;!w&&d!==null&&(E=this.playbackSpeed>=0?this.currentTime>=i:this.currentTime<=0);const S=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&E);return S&&b!==jke&&(C.value=Nte(m,this.options,v,this.speed)),y&&y(C.value),S&&this.finish(),C}then(e,n){return this.finished.then(e,n)}get duration(){return ny(this.calculatedDuration)}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+ny(e)}get time(){return ny(this.currentTime)}set time(e){e=pf(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?this.driver.start(!1):(this.startTime=0,this.state="paused",this.holdTime=e,this.tick(e))}getGeneratorVelocity(){const e=this.currentTime;if(e<=0)return this.options.velocity||0;if(this.generator.velocity)return this.generator.velocity(e);const n=this.generator.next(e).value;return Hst(r=>this.generator.next(r).value,e,n)}get speed(){return this.playbackSpeed}set speed(e){const n=this.playbackSpeed!==e;n&&this.driver&&this.updateTime(mf.now()),this.playbackSpeed=e,n&&this.driver&&(this.time=ny(this.currentTime))}play(){if(this.isStopped)return;const{driver:e=C9n,startTime:n}=this.options;this.driver||(this.driver=e(i=>this.tick(i))),this.options.onPlay?.();const r=this.driver.now();this.state==="finished"?(this.updateFinished(),this.startTime=r):this.holdTime!==null?this.startTime=r-this.holdTime:this.startTime||(this.startTime=n??r),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(mf.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 $9n(t){for(let e=1;e<t.length;e++)t[e]??(t[e]=t[e-1])}const LN=t=>t*180/Math.PI,Uke=t=>{const e=LN(Math.atan2(t[1],t[0]));return qke(e)},j9n={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:t=>(Math.abs(t[0])+Math.abs(t[3]))/2,rotate:Uke,rotateZ:Uke,skewX:t=>LN(Math.atan(t[1])),skewY:t=>LN(Math.atan(t[2])),skew:t=>(Math.abs(t[1])+Math.abs(t[2]))/2},qke=t=>(t=t%360,t<0&&(t+=360),t),Zst=Uke,Xst=t=>Math.sqrt(t[0]*t[0]+t[1]*t[1]),Jst=t=>Math.sqrt(t[4]*t[4]+t[5]*t[5]),z9n={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:Xst,scaleY:Jst,scale:t=>(Xst(t)+Jst(t))/2,rotateX:t=>qke(LN(Math.atan2(t[6],t[5]))),rotateY:t=>qke(LN(Math.atan2(-t[2],t[0]))),rotateZ:Zst,rotate:Zst,skewX:t=>LN(Math.atan(t[4])),skewY:t=>LN(Math.atan(t[1])),skew:t=>(Math.abs(t[1])+Math.abs(t[4]))/2};function Gke(t){return t.includes("scale")?1:0}function Hke(t,e){if(!t||t==="none")return Gke(e);const n=t.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let r,i;if(n)r=z9n,i=n;else{const u=t.match(/^matrix\(([-\d.e\s,]+)\)$/u);r=j9n,i=u}if(!i)return Gke(e);const o=r[e],l=i[1].split(",").map(q9n);return typeof o=="function"?o(l):l[o]}const U9n=(t,e)=>{const{transform:n="none"}=getComputedStyle(t);return Hke(n,e)};function q9n(t){return parseFloat(t.trim())}const HP=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],WP=new Set(HP),elt=t=>t===zP||t===Ja,G9n=new Set(["x","y","z"]),H9n=HP.filter(t=>!G9n.has(t));function W9n(t){const e=[];return H9n.forEach(n=>{const r=t.getValue(n);r!==void 0&&(e.push([n,r.get()]),r.set(n.startsWith("scale")?1:0))}),e}const iI={width:({x:t},{paddingLeft:e="0",paddingRight:n="0",boxSizing:r})=>{const i=t.max-t.min;return r==="border-box"?i:i-parseFloat(e)-parseFloat(n)},height:({y:t},{paddingTop:e="0",paddingBottom:n="0",boxSizing:r})=>{const i=t.max-t.min;return r==="border-box"?i:i-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})=>Hke(e,"x"),y:(t,{transform:e})=>Hke(e,"y")};iI.translateX=iI.x,iI.translateY=iI.y;const MN=new Set;let Wke=!1,Yke=!1,Vke=!1;function tlt(){if(Yke){const t=Array.from(MN).filter(r=>r.needsMeasurement),e=new Set(t.map(r=>r.element)),n=new Map;e.forEach(r=>{const i=W9n(r);i.length&&(n.set(r,i),r.render())}),t.forEach(r=>r.measureInitialState()),e.forEach(r=>{r.render();const i=n.get(r);i&&i.forEach(([o,l])=>{r.getValue(o)?.set(l)})}),t.forEach(r=>r.measureEndState()),t.forEach(r=>{r.suspendedScrollY!==void 0&&window.scrollTo(0,r.suspendedScrollY)})}Yke=!1,Wke=!1,MN.forEach(t=>t.complete(Vke)),MN.clear()}function nlt(){MN.forEach(t=>{t.readKeyframes(),t.needsMeasurement&&(Yke=!0)})}function Y9n(){Vke=!0,nlt(),tlt(),Vke=!1}class Kke{constructor(e,n,r,i,o,l=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...e],this.onComplete=n,this.name=r,this.motionValue=i,this.element=o,this.isAsync=l}scheduleResolve(){this.state="scheduled",this.isAsync?(MN.add(this),Wke||(Wke=!0,Nl.read(nlt),Nl.resolveKeyframes(tlt))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:e,name:n,element:r,motionValue:i}=this;if(e[0]===null){const o=i?.get(),l=e[e.length-1];if(o!==void 0)e[0]=o;else if(r&&n){const u=r.readValue(n,l);u!=null&&(e[0]=u)}e[0]===void 0&&(e[0]=l),i&&o===void 0&&i.set(e[0])}$9n(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),MN.delete(this)}cancel(){this.state==="scheduled"&&(MN.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const V9n=t=>t.startsWith("--");function rlt(t,e,n){V9n(e)?t.style.setProperty(e,n):t.style[e]=n}const K9n={};function alt(t,e){const n=pst(t);return()=>K9n[e]??n()}const Z9n=alt(()=>window.ScrollTimeline!==void 0,"scrollTimeline"),ilt=alt(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),Y7=([t,e,n,r])=>`cubic-bezier(${t}, ${e}, ${n}, ${r})`,olt={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:Y7([0,.65,.55,1]),circOut:Y7([.55,0,1,.45]),backIn:Y7([.31,.01,.66,-.59]),backOut:Y7([.33,1.53,.69,.99])};function slt(t,e){if(t)return typeof t=="function"?ilt()?Ust(t,e):"ease-out":Cst(t)?Y7(t):Array.isArray(t)?t.map(n=>slt(n,e)||olt.easeOut):olt[t]}function X9n(t,e,n,{delay:r=0,duration:i=300,repeat:o=0,repeatType:l="loop",ease:u="easeOut",times:d}={},p=void 0){const m={[e]:n};d&&(m.offset=d);const g=slt(u,i);Array.isArray(g)&&(m.easing=g);const h={delay:r,duration:i,easing:Array.isArray(g)?"linear":g,fill:"both",iterations:o+1,direction:l==="reverse"?"alternate":"normal"};return p&&(h.pseudoElement=p),t.animate(m,h)}function Zke(t){return typeof t=="function"&&"applyToOptions"in t}function J9n({type:t,...e}){return Zke(t)&&ilt()?t.applyToOptions(e):(e.duration??(e.duration=300),e.ease??(e.ease="easeOut"),e)}class llt extends zke{constructor(e){if(super(),this.finishedTime=null,this.isStopped=!1,this.manualStartTime=null,!e)return;const{element:n,name:r,keyframes:i,pseudoElement:o,allowFlatten:l=!1,finalKeyframe:u,onComplete:d}=e;this.isPseudoElement=!!o,this.allowFlatten=l,this.options=e,Gv(typeof e.type!="string",`Mini animate() doesn't support "type" as a string.`,"mini-spring");const p=J9n(e);this.animation=X9n(n,r,i,p,o),p.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!o){const m=Nte(i,this.options,u,this.speed);this.updateMotionValue&&this.updateMotionValue(m),rlt(n,r,m),this.animation.cancel()}d?.(),this.notifyFinished()}}play(){this.isStopped||(this.manualStartTime=null,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(){const e=this.options?.element;!this.isPseudoElement&&e?.isConnected&&this.animation.commitStyles?.()}get duration(){const e=this.animation.effect?.getComputedTiming?.().duration||0;return ny(Number(e))}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+ny(e)}get time(){return ny(Number(this.animation.currentTime)||0)}set time(e){const n=this.finishedTime!==null;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=pf(e),n&&this.animation.pause()}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 this.manualStartTime??Number(this.animation.startTime)}set startTime(e){this.manualStartTime=this.animation.startTime=e}attachTimeline({timeline:e,rangeStart:n,rangeEnd:r,observe:i}){return this.allowFlatten&&this.animation.effect?.updateTiming({easing:"linear"}),this.animation.onfinish=null,e&&Z9n()?(this.animation.timeline=e,n&&(this.animation.rangeStart=n),r&&(this.animation.rangeEnd=r),ty):i(this)}}const clt={anticipate:vst,backInOut:yst,circInOut:wst};function eQn(t){return t in clt}function tQn(t){typeof t.ease=="string"&&eQn(t.ease)&&(t.ease=clt[t.ease])}const Xke=10;class nQn extends llt{constructor(e){tQn(e),Kst(e),super(e),e.startTime!==void 0&&e.autoplay!==!1&&(this.startTime=e.startTime),this.options=e}updateMotionValue(e){const{motionValue:n,onUpdate:r,onComplete:i,element:o,...l}=this.options;if(!n)return;if(e!==void 0){n.set(e);return}const u=new W7({...l,autoplay:!1}),d=Math.max(Xke,mf.now()-this.startTime),p=cx(0,Xke,d-Xke),m=u.sample(d).value,{name:g}=this.options;o&&g&&rlt(o,g,m),n.setWithVelocity(u.sample(Math.max(0,d-p)).value,m,p),u.stop()}}const ult=(t,e)=>e==="zIndex"?!1:!!(typeof t=="number"||Array.isArray(t)||typeof t=="string"&&(Hv.test(t)||t==="0")&&!t.startsWith("url("));function rQn(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 aQn(t,e,n,r){const i=t[0];if(i===null)return!1;if(e==="display"||e==="visibility")return!0;const o=t[t.length-1],l=ult(i,e),u=ult(o,e);return $P(l===u,`You are trying to animate ${e} from "${i}" to "${o}". "${l?o:i}" is not an animatable value.`,"value-not-animatable"),!l||!u?!1:rQn(t)||(n==="spring"||Zke(n))&&r}function Jke(t){t.duration=0,t.type="keyframes"}const dlt=new Set(["opacity","clipPath","filter","transform"]),iQn=/^(?:oklch|oklab|lab|lch|color|color-mix|light-dark)\(/;function oQn(t){for(let e=0;e<t.length;e++)if(typeof t[e]=="string"&&iQn.test(t[e]))return!0;return!1}const sQn=new Set(["color","backgroundColor","outlineColor","fill","stroke","borderColor","borderTopColor","borderRightColor","borderBottomColor","borderLeftColor"]),lQn=pst(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function cQn(t){const{motionValue:e,name:n,repeatDelay:r,repeatType:i,damping:o,type:l,keyframes:u}=t;if(!(e?.owner?.current instanceof HTMLElement))return!1;const{onUpdate:p,transformTemplate:m}=e.owner.getProps();return lQn()&&n&&(dlt.has(n)||sQn.has(n)&&oQn(u))&&(n!=="transform"||!m)&&!p&&!r&&i!=="mirror"&&o!==0&&l!=="inertia"}const uQn=40;class dQn extends zke{constructor({autoplay:e=!0,delay:n=0,type:r="keyframes",repeat:i=0,repeatDelay:o=0,repeatType:l="loop",keyframes:u,name:d,motionValue:p,element:m,...g}){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=mf.now();const h={autoplay:e,delay:n,type:r,repeat:i,repeatDelay:o,repeatType:l,name:d,motionValue:p,element:m,...g},f=m?.KeyframeResolver||Kke;this.keyframeResolver=new f(u,(b,y,v)=>this.onKeyframesResolved(b,y,h,!v),d,p,m),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(e,n,r,i){this.keyframeResolver=void 0;const{name:o,type:l,velocity:u,delay:d,isHandoff:p,onUpdate:m}=r;this.resolvedAt=mf.now();let g=!0;aQn(e,o,l,u)||(g=!1,(rI.instantAnimations||!d)&&m?.(Nte(e,r,n)),e[0]=e[e.length-1],Jke(r),r.repeat=0);const f={startTime:i?this.resolvedAt?this.resolvedAt-this.createdAt>uQn?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...r,keyframes:e},b=g&&!p&&cQn(f),y=f.motionValue?.owner?.current;let v;if(b)try{v=new nQn({...f,element:y})}catch{v=new W7(f)}else v=new W7(f);v.finished.then(()=>{this.notifyFinished()}).catch(ty),this.pendingTimeline&&(this.stopTimeline=v.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=v}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(),Y9n()),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()}}class pQn{constructor(e){this.stop=()=>this.runAll("stop"),this.animations=e.filter(Boolean)}get finished(){return Promise.all(this.animations.map(e=>e.finished))}getAll(e){return this.animations[0][e]}setAll(e,n){for(let r=0;r<this.animations.length;r++)this.animations[r][e]=n}attachTimeline(e){const n=this.animations.map(r=>r.attachTimeline(e));return()=>{n.forEach((r,i)=>{r&&r(),this.animations[i].stop()})}}get time(){return this.getAll("time")}set time(e){this.setAll("time",e)}get speed(){return this.getAll("speed")}set speed(e){this.setAll("speed",e)}get state(){return this.getAll("state")}get startTime(){return this.getAll("startTime")}get duration(){return plt(this.animations,"duration")}get iterationDuration(){return plt(this.animations,"iterationDuration")}runAll(e){this.animations.forEach(n=>n[e]())}play(){this.runAll("play")}pause(){this.runAll("pause")}cancel(){this.runAll("cancel")}complete(){this.runAll("complete")}}function plt(t,e){let n=0;for(let r=0;r<t.length;r++){const i=t[r][e];i!==null&&i>n&&(n=i)}return n}class mQn extends pQn{then(e,n){return this.finished.finally(e).then(()=>{})}}function mlt(t,e,n,r=0,i=1){const o=Array.from(t).sort((p,m)=>p.sortNodePosition(m)).indexOf(e),l=t.size,u=(l-1)*r;return typeof n=="function"?n(o,l):i===1?o*r:u-o*r}const gQn=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function hQn(t){const e=gQn.exec(t);if(!e)return[,];const[,n,r,i]=e;return[`--${n??r}`,i]}const fQn=4;function glt(t,e,n=1){Gv(n<=fQn,`Max CSS variable fallback depth detected in property "${t}". This may indicate a circular fallback dependency.`,"max-css-var-depth");const[r,i]=hQn(t);if(!r)return;const o=window.getComputedStyle(e).getPropertyValue(r);if(o){const l=o.trim();return cst(l)?parseFloat(l):l}return Tke(i)?glt(i,e,n+1):i}const AQn={type:"spring",stiffness:500,damping:25,restSpeed:10},bQn=t=>({type:"spring",stiffness:550,damping:t===0?2*Math.sqrt(550):30,restSpeed:10}),yQn={type:"keyframes",duration:.8},vQn={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},_Qn=(t,{keyframes:e})=>e.length>2?yQn:WP.has(t)?t.startsWith("scale")?bQn(e[1]):AQn:vQn;function hlt(t,e){if(t?.inherit&&e){const{inherit:n,...r}=t;return{...e,...r}}return t}function eEe(t,e){const n=t?.[e]??t?.default??t;return n!==t?hlt(n,t):n}const wQn=new Set(["when","delay","delayChildren","staggerChildren","staggerDirection","repeat","repeatType","repeatDelay","from","elapsed"]);function xQn(t){for(const e in t)if(!wQn.has(e))return!0;return!1}const tEe=(t,e,n,r={},i,o)=>l=>{const u=eEe(r,t)||{},d=u.delay||r.delay||0;let{elapsed:p=0}=r;p=p-pf(d);const m={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:e.getVelocity(),...u,delay:-p,onUpdate:h=>{e.set(h),u.onUpdate&&u.onUpdate(h)},onComplete:()=>{l(),u.onComplete&&u.onComplete()},name:t,motionValue:e,element:o?void 0:i};xQn(u)||Object.assign(m,_Qn(t,m)),m.duration&&(m.duration=pf(m.duration)),m.repeatDelay&&(m.repeatDelay=pf(m.repeatDelay)),m.from!==void 0&&(m.keyframes[0]=m.from);let g=!1;if((m.type===!1||m.duration===0&&!m.repeatDelay)&&(Jke(m),m.delay===0&&(g=!0)),(rI.instantAnimations||rI.skipAnimations||i?.shouldSkipAnimations)&&(g=!0,Jke(m),m.delay=0),m.allowFlatten=!u.type&&!u.ease,g&&!o&&e.get()!==void 0){const h=Nte(m.keyframes,u);if(h!==void 0){Nl.update(()=>{m.onUpdate(h),m.onComplete()});return}}return u.isSync?new W7(m):new dQn(m)};function flt(t){const e=[{},{}];return t?.values.forEach((n,r)=>{e[0][r]=n.get(),e[1][r]=n.getVelocity()}),e}function nEe(t,e,n,r){if(typeof e=="function"){const[i,o]=flt(r);e=e(n!==void 0?n:t.custom,i,o)}if(typeof e=="string"&&(e=t.variants&&t.variants[e]),typeof e=="function"){const[i,o]=flt(r);e=e(n!==void 0?n:t.custom,i,o)}return e}function PN(t,e,n){const r=t.getProps();return nEe(r,e,n!==void 0?n:r.custom,t)}const Alt=new Set(["width","height","top","left","right","bottom",...HP]),blt=30,kQn=t=>!isNaN(parseFloat(t)),V7={current:void 0};class EQn{constructor(e,n={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=r=>{const i=mf.now();if(this.updatedAt!==i&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(r),this.current!==this.prev&&(this.events.change?.notify(this.current),this.dependents))for(const o of this.dependents)o.dirty()},this.hasAnimated=!1,this.setCurrent(e),this.owner=n.owner}setCurrent(e){this.current=e,this.updatedAt=mf.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=kQn(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return process.env.NODE_ENV!=="production"&&kke(!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 xke);const r=this.events[e].add(n);return e==="change"?()=>{r(),Nl.read(()=>{this.events.change.getSize()||this.stop()})}:r}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,r){this.set(n),this.prev=void 0,this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt-r}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 V7.current&&V7.current.push(this),this.current}getPrevious(){return this.prev}getVelocity(){const e=mf.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>blt)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,blt);return mst(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 oI(t,e){return new EQn(t,e)}const rEe=t=>Array.isArray(t);function CQn(t,e,n){t.hasValue(e)?t.getValue(e).set(n):t.addValue(e,oI(n))}function SQn(t){return rEe(t)?t[t.length-1]||0:t}function IQn(t,e){const n=PN(t,e);let{transitionEnd:r={},transition:i={},...o}=n||{};o={...o,...r};for(const l in o){const u=SQn(o[l]);CQn(t,l,u)}}const Cd=t=>!!(t&&t.getVelocity);function TQn(t){return!!(Cd(t)&&t.add)}function aEe(t,e){const n=t.getValue("willChange");if(TQn(n))return n.add(e);if(!n&&rI.WillChange){const r=new rI.WillChange("auto");t.addValue("willChange",r),r.add(e)}}function iEe(t){return t.replace(/([A-Z])/g,e=>`-${e.toLowerCase()}`)}const ylt="data-"+iEe("framerAppearId");function vlt(t){return t.props[ylt]}function BQn({protectedKeys:t,needsAnimating:e},n){const r=t.hasOwnProperty(n)&&e[n]!==!0;return e[n]=!1,r}function oEe(t,e,{delay:n=0,transitionOverride:r,type:i}={}){let{transition:o,transitionEnd:l,...u}=e;const d=t.getDefaultTransition();o=o?hlt(o,d):d;const p=o?.reduceMotion;r&&(o=r);const m=[],g=i&&t.animationState&&t.animationState.getState()[i];for(const h in u){const f=t.getValue(h,t.latestValues[h]??null),b=u[h];if(b===void 0||g&&BQn(g,h))continue;const y={delay:n,...eEe(o||{},h)},v=f.get();if(v!==void 0&&!f.isAnimating()&&!Array.isArray(b)&&b===v&&!y.velocity){Nl.update(()=>f.set(b));continue}let _=!1;if(window.MotionHandoffAnimation){const k=vlt(t);if(k){const C=window.MotionHandoffAnimation(k,h,Nl);C!==null&&(y.startTime=C,_=!0)}}aEe(t,h);const w=p??t.shouldReduceMotion;f.start(tEe(h,f,b,w&&Alt.has(h)?{type:!1}:y,t,_));const x=f.animation;x&&m.push(x)}if(l){const h=()=>Nl.update(()=>{l&&IQn(t,l)});m.length?Promise.all(m).then(h):h()}return m}function sEe(t,e,n={}){const r=PN(t,e,n.type==="exit"?t.presenceContext?.custom:void 0);let{transition:i=t.getDefaultTransition()||{}}=r||{};n.transitionOverride&&(i=n.transitionOverride);const o=r?()=>Promise.all(oEe(t,r,n)):()=>Promise.resolve(),l=t.variantChildren&&t.variantChildren.size?(d=0)=>{const{delayChildren:p=0,staggerChildren:m,staggerDirection:g}=i;return DQn(t,e,d,p,m,g,n)}:()=>Promise.resolve(),{when:u}=i;if(u){const[d,p]=u==="beforeChildren"?[o,l]:[l,o];return d().then(()=>p())}else return Promise.all([o(),l(n.delay)])}function DQn(t,e,n=0,r=0,i=0,o=1,l){const u=[];for(const d of t.variantChildren)d.notify("AnimationStart",e),u.push(sEe(d,e,{...l,delay:n+(typeof r=="function"?0:r)+mlt(t.variantChildren,d,r,i,o)}).then(()=>d.notify("AnimationComplete",e)));return Promise.all(u)}function NQn(t,e,n={}){t.notify("AnimationStart",e);let r;if(Array.isArray(e)){const i=e.map(o=>sEe(t,o,n));r=Promise.all(i)}else if(typeof e=="string")r=sEe(t,e,n);else{const i=typeof e=="function"?PN(t,e,n.custom):e;r=Promise.all(oEe(t,i,n))}return r.then(()=>{t.notify("AnimationComplete",e)})}const RQn={test:t=>t==="auto",parse:t=>t},_lt=t=>e=>e.test(t),wlt=[zP,Ja,ux,aI,s9n,o9n,RQn],xlt=t=>wlt.find(_lt(t));function LQn(t){return typeof t=="number"?t===0:t!==null?t==="none"||t==="0"||dst(t):!0}const MQn=new Set(["brightness","contrast","saturate","opacity"]);function PQn(t){const[e,n]=t.slice(0,-1).split("(");if(e==="drop-shadow")return t;const[r]=n.match(Bke)||[];if(!r)return t;const i=n.replace(r,"");let o=MQn.has(e)?1:0;return r!==n&&(o*=100),e+"("+o+i+")"}const OQn=/\b([a-z-]*)\(.*?\)/gu,lEe={...Hv,getAnimatableNone:t=>{const e=t.match(OQn);return e?e.map(PQn).join(" "):t}},cEe={...Hv,getAnimatableNone:t=>{const e=Hv.parse(t);return Hv.createTransformer(t)(e.map(r=>typeof r=="number"?0:typeof r=="object"?{...r,alpha:1}:r))}},klt={...zP,transform:Math.round},uEe={borderWidth:Ja,borderTopWidth:Ja,borderRightWidth:Ja,borderBottomWidth:Ja,borderLeftWidth:Ja,borderRadius:Ja,borderTopLeftRadius:Ja,borderTopRightRadius:Ja,borderBottomRightRadius:Ja,borderBottomLeftRadius:Ja,width:Ja,maxWidth:Ja,height:Ja,maxHeight:Ja,top:Ja,right:Ja,bottom:Ja,left:Ja,inset:Ja,insetBlock:Ja,insetBlockStart:Ja,insetBlockEnd:Ja,insetInline:Ja,insetInlineStart:Ja,insetInlineEnd:Ja,padding:Ja,paddingTop:Ja,paddingRight:Ja,paddingBottom:Ja,paddingLeft:Ja,paddingBlock:Ja,paddingBlockStart:Ja,paddingBlockEnd:Ja,paddingInline:Ja,paddingInlineStart:Ja,paddingInlineEnd:Ja,margin:Ja,marginTop:Ja,marginRight:Ja,marginBottom:Ja,marginLeft:Ja,marginBlock:Ja,marginBlockStart:Ja,marginBlockEnd:Ja,marginInline:Ja,marginInlineStart:Ja,marginInlineEnd:Ja,fontSize:Ja,backgroundPositionX:Ja,backgroundPositionY:Ja,...{rotate:aI,rotateX:aI,rotateY:aI,rotateZ:aI,scale:Tte,scaleX:Tte,scaleY:Tte,scaleZ:Tte,skew:aI,skewX:aI,skewY:aI,distance:Ja,translateX:Ja,translateY:Ja,translateZ:Ja,x:Ja,y:Ja,z:Ja,perspective:Ja,transformPerspective:Ja,opacity:U7,originX:Lst,originY:Lst,originZ:Ja},zIndex:klt,fillOpacity:U7,strokeOpacity:U7,numOctaves:klt},FQn={...uEe,color:ep,backgroundColor:ep,outlineColor:ep,fill:ep,stroke:ep,borderColor:ep,borderTopColor:ep,borderRightColor:ep,borderBottomColor:ep,borderLeftColor:ep,filter:lEe,WebkitFilter:lEe,mask:cEe,WebkitMask:cEe},Elt=t=>FQn[t],QQn=new Set([lEe,cEe]);function Clt(t,e){let n=Elt(t);return QQn.has(n)||(n=Hv),n.getAnimatableNone?n.getAnimatableNone(e):void 0}const $Qn=new Set(["auto","none","0"]);function jQn(t,e,n){let r=0,i;for(;r<t.length&&!i;){const o=t[r];typeof o=="string"&&!$Qn.has(o)&&qP(o).values.length&&(i=t[r]),r++}if(i&&n)for(const o of e)t[o]=Clt(n,i)}class zQn extends Kke{constructor(e,n,r,i,o){super(e,n,r,i,o,!0)}readKeyframes(){const{unresolvedKeyframes:e,element:n,name:r}=this;if(!n||!n.current)return;super.readKeyframes();for(let m=0;m<e.length;m++){let g=e[m];if(typeof g=="string"&&(g=g.trim(),Tke(g))){const h=glt(g,n.current);h!==void 0&&(e[m]=h),m===e.length-1&&(this.finalKeyframe=g)}}if(this.resolveNoneKeyframes(),!Alt.has(r)||e.length!==2)return;const[i,o]=e,l=xlt(i),u=xlt(o),d=Nst(i),p=Nst(o);if(d!==p&&iI[r]){this.needsMeasurement=!0;return}if(l!==u)if(elt(l)&&elt(u))for(let m=0;m<e.length;m++){const g=e[m];typeof g=="string"&&(e[m]=parseFloat(g))}else iI[r]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:e,name:n}=this,r=[];for(let i=0;i<e.length;i++)(e[i]===null||LQn(e[i]))&&r.push(i);r.length&&jQn(e,r,n)}measureInitialState(){const{element:e,unresolvedKeyframes:n,name:r}=this;if(!e||!e.current)return;r==="height"&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=iI[r](e.measureViewportBox(),window.getComputedStyle(e.current)),n[0]=this.measuredOrigin;const i=n[n.length-1];i!==void 0&&e.getValue(r,i).jump(i,!1)}measureEndState(){const{element:e,name:n,unresolvedKeyframes:r}=this;if(!e||!e.current)return;const i=e.getValue(n);i&&i.jump(this.measuredOrigin,!1);const o=r.length-1,l=r[o];r[o]=iI[n](e.measureViewportBox(),window.getComputedStyle(e.current)),l!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=l),this.removedTransforms?.length&&this.removedTransforms.forEach(([u,d])=>{e.getValue(u).set(d)}),this.resolveNoneKeyframes()}}function Rte(t,e,n){if(t==null)return[];if(t instanceof EventTarget)return[t];if(typeof t=="string"){let r=document;e&&(r=e.current);const i=n?.[t]??r.querySelectorAll(t);return i?Array.from(i):[]}return Array.from(t).filter(r=>r!=null)}const Slt=(t,e)=>e&&typeof t=="number"?e.transform(t):t;function Lte(t){return ust(t)&&"offsetHeight"in t&&!("ownerSVGElement"in t)}const{schedule:dEe}=Tst(queueMicrotask,!1),Wv={x:!1,y:!1};function Ilt(){return Wv.x||Wv.y}function UQn(t){return t==="x"||t==="y"?Wv[t]?null:(Wv[t]=!0,()=>{Wv[t]=!1}):Wv.x||Wv.y?null:(Wv.x=Wv.y=!0,()=>{Wv.x=Wv.y=!1})}function Tlt(t,e){const n=Rte(t),r=new AbortController,i={passive:!0,...e,signal:r.signal};return[n,i,()=>r.abort()]}function qQn(t){return!(t.pointerType==="touch"||Ilt())}function GQn(t,e,n={}){const[r,i,o]=Tlt(t,n);return r.forEach(l=>{let u=!1,d=!1,p;const m=()=>{l.removeEventListener("pointerleave",b)},g=v=>{p&&(p(v),p=void 0),m()},h=v=>{u=!1,window.removeEventListener("pointerup",h),window.removeEventListener("pointercancel",h),d&&(d=!1,g(v))},f=()=>{u=!0,window.addEventListener("pointerup",h,i),window.addEventListener("pointercancel",h,i)},b=v=>{if(v.pointerType!=="touch"){if(u){d=!0;return}g(v)}},y=v=>{if(!qQn(v))return;d=!1;const _=e(l,v);typeof _=="function"&&(p=_,l.addEventListener("pointerleave",b,i))};l.addEventListener("pointerenter",y,i),l.addEventListener("pointerdown",f,i)}),o}const Blt=(t,e)=>e?t===e?!0:Blt(t,e.parentElement):!1,pEe=t=>t.pointerType==="mouse"?typeof t.button!="number"||t.button<=0:t.isPrimary!==!1,HQn=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function WQn(t){return HQn.has(t.tagName)||t.isContentEditable===!0}const YQn=new Set(["INPUT","SELECT","TEXTAREA"]);function VQn(t){return YQn.has(t.tagName)||t.isContentEditable===!0}const Mte=new WeakSet;function Dlt(t){return e=>{e.key==="Enter"&&t(e)}}function mEe(t,e){t.dispatchEvent(new PointerEvent("pointer"+e,{isPrimary:!0,bubbles:!0}))}const KQn=(t,e)=>{const n=t.currentTarget;if(!n)return;const r=Dlt(()=>{if(Mte.has(n))return;mEe(n,"down");const i=Dlt(()=>{mEe(n,"up")}),o=()=>mEe(n,"cancel");n.addEventListener("keyup",i,e),n.addEventListener("blur",o,e)});n.addEventListener("keydown",r,e),n.addEventListener("blur",()=>n.removeEventListener("keydown",r),e)};function Nlt(t){return pEe(t)&&!Ilt()}const Rlt=new WeakSet;function ZQn(t,e,n={}){const[r,i,o]=Tlt(t,n),l=u=>{const d=u.currentTarget;if(!Nlt(u)||Rlt.has(u))return;Mte.add(d),n.stopPropagation&&Rlt.add(u);const p=e(d,u),m=(f,b)=>{window.removeEventListener("pointerup",g),window.removeEventListener("pointercancel",h),Mte.has(d)&&Mte.delete(d),Nlt(f)&&typeof p=="function"&&p(f,{success:b})},g=f=>{m(f,d===window||d===document||n.useGlobalTarget||Blt(d,f.target))},h=f=>{m(f,!1)};window.addEventListener("pointerup",g,i),window.addEventListener("pointercancel",h,i)};return r.forEach(u=>{(n.useGlobalTarget?window:u).addEventListener("pointerdown",l,i),Lte(u)&&(u.addEventListener("focus",p=>KQn(p,i)),!WQn(u)&&!u.hasAttribute("tabindex")&&(u.tabIndex=0))}),o}function Pte(t){return ust(t)&&"ownerSVGElement"in t}const Ote=new WeakMap;let Fte;const Llt=(t,e,n)=>(r,i)=>i&&i[0]?i[0][t+"Size"]:Pte(r)&&"getBBox"in r?r.getBBox()[e]:r[n],XQn=Llt("inline","width","offsetWidth"),JQn=Llt("block","height","offsetHeight");function e$n({target:t,borderBoxSize:e}){Ote.get(t)?.forEach(n=>{n(t,{get width(){return XQn(t,e)},get height(){return JQn(t,e)}})})}function t$n(t){t.forEach(e$n)}function n$n(){typeof ResizeObserver>"u"||(Fte=new ResizeObserver(t$n))}function r$n(t,e){Fte||n$n();const n=Rte(t);return n.forEach(r=>{let i=Ote.get(r);i||(i=new Set,Ote.set(r,i)),i.add(e),Fte?.observe(r)}),()=>{n.forEach(r=>{const i=Ote.get(r);i?.delete(e),i?.size||Fte?.unobserve(r)})}}const Qte=new Set;let YP;function a$n(){YP=()=>{const t={get width(){return window.innerWidth},get height(){return window.innerHeight}};Qte.forEach(e=>e(t))},window.addEventListener("resize",YP)}function i$n(t){return Qte.add(t),YP||a$n(),()=>{Qte.delete(t),!Qte.size&&typeof YP=="function"&&(window.removeEventListener("resize",YP),YP=void 0)}}function Mlt(t,e){return typeof t=="function"?i$n(t):r$n(t,e)}function Plt(t){return Pte(t)&&t.tagName==="svg"}function o$n(...t){const e=!Array.isArray(t[0]),n=e?0:-1,r=t[0+n],i=t[1+n],o=t[2+n],l=t[3+n],u=Wst(i,o,l);return e?u(r):u}function s$n(t,e,n={}){const r=t.get();let i=null,o=r,l;const u=typeof r=="string"?r.replace(/[\d.-]/g,""):void 0,d=()=>{i&&(i.stop(),i=null),t.animation=void 0},p=()=>{const g=Olt(t.get()),h=Olt(o);if(g===h){d();return}const f=i?i.getGeneratorVelocity():t.getVelocity();d(),i=new W7({keyframes:[g,h],velocity:f,type:"spring",restDelta:.001,restSpeed:.01,...n,onUpdate:l})},m=()=>{p(),t.animation=i??void 0,t.events.animationStart?.notify(),i?.then(()=>{t.animation=void 0,t.events.animationComplete?.notify()})};if(t.attach((g,h)=>{o=g,l=f=>h(gEe(f,u)),Nl.postRender(m)},d),Cd(e)){let g=n.skipInitialAnimation===!0;const h=e.on("change",b=>{g?(g=!1,t.jump(gEe(b,u),!1)):t.set(gEe(b,u))}),f=t.on("destroy",h);return()=>{h(),f()}}return d}function gEe(t,e){return e?t+e:t}function Olt(t){return typeof t=="number"?t:parseFloat(t)}const l$n=[...wlt,ep,Hv],c$n=t=>l$n.find(_lt(t)),Flt=()=>({translate:0,scale:1,origin:0,originPoint:0}),VP=()=>({x:Flt(),y:Flt()}),Qlt=()=>({min:0,max:0}),tp=()=>({x:Qlt(),y:Qlt()}),K7=new WeakMap;function $te(t){return t!==null&&typeof t=="object"&&typeof t.start=="function"}function Z7(t){return typeof t=="string"||Array.isArray(t)}const hEe=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],fEe=["initial",...hEe];function jte(t){return $te(t.animate)||fEe.some(e=>Z7(t[e]))}function $lt(t){return!!(jte(t)||t.variants)}function u$n(t,e,n){for(const r in e){const i=e[r],o=n[r];if(Cd(i))t.addValue(r,i);else if(Cd(o))t.addValue(r,oI(i,{owner:t}));else if(o!==i)if(t.hasValue(r)){const l=t.getValue(r);l.liveStyle===!0?l.jump(i):l.hasAnimated||l.set(i)}else{const l=t.getStaticValue(r);t.addValue(r,oI(l!==void 0?l:i,{owner:t}))}}for(const r in n)e[r]===void 0&&t.removeValue(r);return e}const AEe={current:null},jlt={current:!1},d$n=typeof window<"u";function p$n(){if(jlt.current=!0,!!d$n)if(window.matchMedia){const t=window.matchMedia("(prefers-reduced-motion)"),e=()=>AEe.current=t.matches;t.addEventListener("change",e),e()}else AEe.current=!1}const zlt=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];let zte={};function Ult(t){zte=t}function m$n(){return zte}class qlt{scrapeMotionValuesFromProps(e,n,r){return{}}constructor({parent:e,props:n,presenceContext:r,reducedMotionConfig:i,skipAnimations:o,blockInitialAnimation:l,visualState:u},d={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.shouldSkipAnimations=!1,this.values=new Map,this.KeyframeResolver=Kke,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.hasBeenMounted=!1,this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify("Update",this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{const f=mf.now();this.renderScheduledAt<f&&(this.renderScheduledAt=f,Nl.render(this.render,!1,!0))};const{latestValues:p,renderState:m}=u;this.latestValues=p,this.baseTarget={...p},this.initialValues=n.initial?{...p}:{},this.renderState=m,this.parent=e,this.props=n,this.presenceContext=r,this.depth=e?e.depth+1:0,this.reducedMotionConfig=i,this.skipAnimationsConfig=o,this.options=d,this.blockInitialAnimation=!!l,this.isControllingVariants=jte(n),this.isVariantNode=$lt(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(e&&e.current);const{willChange:g,...h}=this.scrapeMotionValuesFromProps(n,{},this);for(const f in h){const b=h[f];p[f]!==void 0&&Cd(b)&&b.set(p[f])}}mount(e){if(this.hasBeenMounted)for(const n in this.initialValues)this.values.get(n)?.jump(this.initialValues[n]),this.latestValues[n]=this.initialValues[n];this.current=e,K7.set(e,this),this.projection&&!this.projection.instance&&this.projection.mount(e),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((n,r)=>this.bindToMotionValue(r,n)),this.reducedMotionConfig==="never"?this.shouldReduceMotion=!1:this.reducedMotionConfig==="always"?this.shouldReduceMotion=!0:(jlt.current||p$n(),this.shouldReduceMotion=AEe.current),process.env.NODE_ENV!=="production"&&kke(this.shouldReduceMotion!==!0,"You have Reduced Motion enabled on your device. Animations may not appear as expected.","reduced-motion-disabled"),this.shouldSkipAnimations=this.skipAnimationsConfig??!1,this.parent?.addChild(this),this.update(this.props,this.presenceContext),this.hasBeenMounted=!0}unmount(){this.projection&&this.projection.unmount(),w1(this.notifyUpdate),w1(this.render),this.valueSubscriptions.forEach(e=>e()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent?.removeChild(this);for(const e in this.events)this.events[e].clear();for(const e in this.features){const n=this.features[e];n&&(n.unmount(),n.isMounted=!1)}this.current=null}addChild(e){this.children.add(e),this.enteringChildren??(this.enteringChildren=new Set),this.enteringChildren.add(e)}removeChild(e){this.children.delete(e),this.enteringChildren&&this.enteringChildren.delete(e)}bindToMotionValue(e,n){if(this.valueSubscriptions.has(e)&&this.valueSubscriptions.get(e)(),n.accelerate&&dlt.has(e)&&this.current instanceof HTMLElement){const{factory:l,keyframes:u,times:d,ease:p,duration:m}=n.accelerate,g=new llt({element:this.current,name:e,keyframes:u,times:d,ease:p,duration:pf(m)}),h=l(g);this.valueSubscriptions.set(e,()=>{h(),g.cancel()});return}const r=WP.has(e);r&&this.onBindTransform&&this.onBindTransform();const i=n.on("change",l=>{this.latestValues[e]=l,this.props.onUpdate&&Nl.preRender(this.notifyUpdate),r&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});let o;typeof window<"u"&&window.MotionCheckAppearSync&&(o=window.MotionCheckAppearSync(this,e,n)),this.valueSubscriptions.set(e,()=>{i(),o&&o(),n.owner&&n.stop()})}sortNodePosition(e){return!this.current||!this.sortInstanceNodePosition||this.type!==e.type?0:this.sortInstanceNodePosition(this.current,e.current)}updateFeatures(){let e="animation";for(e in zte){const n=zte[e];if(!n)continue;const{isEnabled:r,Feature:i}=n;if(!this.features[e]&&i&&r(this.props)&&(this.features[e]=new i(this)),this.features[e]){const o=this.features[e];o.isMounted?o.update():(o.mount(),o.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):tp()}getStaticValue(e){return this.latestValues[e]}setStaticValue(e,n){this.latestValues[e]=n}update(e,n){(e.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=e,this.prevPresenceContext=this.presenceContext,this.presenceContext=n;for(let r=0;r<zlt.length;r++){const i=zlt[r];this.propEventSubscriptions[i]&&(this.propEventSubscriptions[i](),delete this.propEventSubscriptions[i]);const o="on"+i,l=e[o];l&&(this.propEventSubscriptions[i]=this.on(i,l))}this.prevMotionValues=u$n(this,this.scrapeMotionValuesFromProps(e,this.prevProps||{},this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(e){return this.props.variants?this.props.variants[e]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(e){const n=this.getClosestVariantNode();if(n)return n.variantChildren&&n.variantChildren.add(e),()=>n.variantChildren.delete(e)}addValue(e,n){const r=this.values.get(e);n!==r&&(r&&this.removeValue(e),this.bindToMotionValue(e,n),this.values.set(e,n),this.latestValues[e]=n.get())}removeValue(e){this.values.delete(e);const n=this.valueSubscriptions.get(e);n&&(n(),this.valueSubscriptions.delete(e)),delete this.latestValues[e],this.removeValueFromRenderState(e,this.renderState)}hasValue(e){return this.values.has(e)}getValue(e,n){if(this.props.values&&this.props.values[e])return this.props.values[e];let r=this.values.get(e);return r===void 0&&n!==void 0&&(r=oI(n===null?void 0:n,{owner:this}),this.addValue(e,r)),r}readValue(e,n){let r=this.latestValues[e]!==void 0||!this.current?this.latestValues[e]:this.getBaseTargetFromProps(this.props,e)??this.readValueFromInstance(this.current,e,this.options);return r!=null&&(typeof r=="string"&&(cst(r)||dst(r))?r=parseFloat(r):!c$n(r)&&Hv.test(n)&&(r=Clt(e,n)),this.setBaseTarget(e,Cd(r)?r.get():r)),Cd(r)?r.get():r}setBaseTarget(e,n){this.baseTarget[e]=n}getBaseTarget(e){const{initial:n}=this.props;let r;if(typeof n=="string"||typeof n=="object"){const o=nEe(this.props,n,this.presenceContext?.custom);o&&(r=o[e])}if(n&&r!==void 0)return r;const i=this.getBaseTargetFromProps(this.props,e);return i!==void 0&&!Cd(i)?i:this.initialValues[e]!==void 0&&r===void 0?void 0:this.baseTarget[e]}on(e,n){return this.events[e]||(this.events[e]=new xke),this.events[e].add(n)}notify(e,...n){this.events[e]&&this.events[e].notify(...n)}scheduleRenderMicrotask(){dEe.render(this.render)}}class Glt extends qlt{constructor(){super(...arguments),this.KeyframeResolver=zQn}sortInstanceNodePosition(e,n){return e.compareDocumentPosition(n)&2?1:-1}getBaseTargetFromProps(e,n){const r=e.style;return r?r[n]:void 0}removeValueFromRenderState(e,{vars:n,style:r}){delete n[e],delete r[e]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:e}=this.props;Cd(e)&&(this.childSubscription=e.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}class sI{constructor(e){this.isMounted=!1,this.node=e}update(){}}function Hlt({top:t,left:e,right:n,bottom:r}){return{x:{min:e,max:n},y:{min:t,max:r}}}function g$n({x:t,y:e}){return{top:e.min,right:t.max,bottom:e.max,left:t.min}}function h$n(t,e){if(!e)return t;const n=e({x:t.left,y:t.top}),r=e({x:t.right,y:t.bottom});return{top:n.y,left:n.x,bottom:r.y,right:r.x}}function bEe(t){return t===void 0||t===1}function yEe({scale:t,scaleX:e,scaleY:n}){return!bEe(t)||!bEe(e)||!bEe(n)}function ON(t){return yEe(t)||Wlt(t)||t.z||t.rotate||t.rotateX||t.rotateY||t.skewX||t.skewY}function Wlt(t){return Ylt(t.x)||Ylt(t.y)}function Ylt(t){return t&&t!=="0%"}function Ute(t,e,n){const r=t-n,i=e*r;return n+i}function Vlt(t,e,n,r,i){return i!==void 0&&(t=Ute(t,i,r)),Ute(t,n,r)+e}function vEe(t,e=0,n=1,r,i){t.min=Vlt(t.min,e,n,r,i),t.max=Vlt(t.max,e,n,r,i)}function Klt(t,{x:e,y:n}){vEe(t.x,e.translate,e.scale,e.originPoint),vEe(t.y,n.translate,n.scale,n.originPoint)}const Zlt=.999999999999,Xlt=1.0000000000001;function f$n(t,e,n,r=!1){const i=n.length;if(!i)return;e.x=e.y=1;let o,l;for(let u=0;u<i;u++){o=n[u],l=o.projectionDelta;const{visualElement:d}=o.options;d&&d.props.style&&d.props.style.display==="contents"||(r&&o.options.layoutScroll&&o.scroll&&o!==o.root&&(dx(t.x,-o.scroll.offset.x),dx(t.y,-o.scroll.offset.y)),l&&(e.x*=l.x.scale,e.y*=l.y.scale,Klt(t,l)),r&&ON(o.latestValues)&&qte(t,o.latestValues,o.layout?.layoutBox))}e.x<Xlt&&e.x>Zlt&&(e.x=1),e.y<Xlt&&e.y>Zlt&&(e.y=1)}function dx(t,e){t.min+=e,t.max+=e}function Jlt(t,e,n,r,i=.5){const o=Bc(t.min,t.max,i);vEe(t,e,n,o,r)}function ect(t,e){return typeof t=="string"?parseFloat(t)/100*(e.max-e.min):t}function qte(t,e,n){const r=n??t;Jlt(t.x,ect(e.x,r.x),e.scaleX,e.scale,e.originX),Jlt(t.y,ect(e.y,r.y),e.scaleY,e.scale,e.originY)}function tct(t,e){return Hlt(h$n(t.getBoundingClientRect(),e))}function A$n(t,e,n){const r=tct(t,n),{scroll:i}=e;return i&&(dx(r.x,i.offset.x),dx(r.y,i.offset.y)),r}const b$n={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},y$n=HP.length;function v$n(t,e,n){let r="",i=!0;for(let o=0;o<y$n;o++){const l=HP[o],u=t[l];if(u===void 0)continue;let d=!0;if(typeof u=="number")d=u===(l.startsWith("scale")?1:0);else{const p=parseFloat(u);d=l.startsWith("scale")?p===1:p===0}if(!d||n){const p=Slt(u,uEe[l]);if(!d){i=!1;const m=b$n[l]||l;r+=`${m}(${p}) `}n&&(e[l]=p)}}return r=r.trim(),n?r=n(e,i?"":r):i&&(r="none"),r}function _Ee(t,e,n){const{style:r,vars:i,transformOrigin:o}=t;let l=!1,u=!1;for(const d in e){const p=e[d];if(WP.has(d)){l=!0;continue}else if(Dst(d)){i[d]=p;continue}else{const m=Slt(p,uEe[d]);d.startsWith("origin")?(u=!0,o[d]=m):r[d]=m}}if(e.transform||(l||n?r.transform=v$n(e,t.transform,n):r.transform&&(r.transform="none")),u){const{originX:d="50%",originY:p="50%",originZ:m=0}=o;r.transformOrigin=`${d} ${p} ${m}`}}function nct(t,{style:e,vars:n},r,i){const o=t.style;let l;for(l in e)o[l]=e[l];i?.applyProjectionStyles(o,r);for(l in n)o.setProperty(l,n[l])}function rct(t,e){return e.max===e.min?0:t/(e.max-e.min)*100}const X7={correct:(t,e)=>{if(!e.target)return t;if(typeof t=="string")if(Ja.test(t))t=parseFloat(t);else return t;const n=rct(t,e.target.x),r=rct(t,e.target.y);return`${n}% ${r}%`}},_$n={correct:(t,{treeScale:e,projectionDelta:n})=>{const r=t,i=Hv.parse(t);if(i.length>5)return r;const o=Hv.createTransformer(t),l=typeof i[0]!="number"?1:0,u=n.x.scale*e.x,d=n.y.scale*e.y;i[0+l]/=u,i[1+l]/=d;const p=Bc(u,d,.5);return typeof i[2+l]=="number"&&(i[2+l]/=p),typeof i[3+l]=="number"&&(i[3+l]/=p),o(i)}},wEe={borderRadius:{...X7,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:X7,borderTopRightRadius:X7,borderBottomLeftRadius:X7,borderBottomRightRadius:X7,boxShadow:_$n};function act(t,{layout:e,layoutId:n}){return WP.has(t)||t.startsWith("origin")||(e||n!==void 0)&&(!!wEe[t]||t==="opacity")}function xEe(t,e,n){const r=t.style,i=e?.style,o={};if(!r)return o;for(const l in r)(Cd(r[l])||i&&Cd(i[l])||act(l,t)||n?.getValue(l)?.liveStyle!==void 0)&&(o[l]=r[l]);return o}function w$n(t){return window.getComputedStyle(t)}class ict extends Glt{constructor(){super(...arguments),this.type="html",this.renderInstance=nct}readValueFromInstance(e,n){if(WP.has(n))return this.projection?.isProjecting?Gke(n):U9n(e,n);{const r=w$n(e),i=(Dst(n)?r.getPropertyValue(n):r[n])||0;return typeof i=="string"?i.trim():i}}measureInstanceViewportBox(e,{transformPagePoint:n}){return tct(e,n)}build(e,n,r){_Ee(e,n,r.transformTemplate)}scrapeMotionValuesFromProps(e,n,r){return xEe(e,n,r)}}function x$n(t,e){return t in e}class k$n extends qlt{constructor(){super(...arguments),this.type="object"}readValueFromInstance(e,n){if(x$n(n,e)){const r=e[n];if(typeof r=="string"||typeof r=="number")return r}}getBaseTargetFromProps(){}removeValueFromRenderState(e,n){delete n.output[e]}measureInstanceViewportBox(){return tp()}build(e,n){Object.assign(e.output,n)}renderInstance(e,{output:n}){Object.assign(e,n)}sortInstanceNodePosition(){return 0}}const E$n={offset:"stroke-dashoffset",array:"stroke-dasharray"},C$n={offset:"strokeDashoffset",array:"strokeDasharray"};function S$n(t,e,n=1,r=0,i=!0){t.pathLength=1;const o=i?E$n:C$n;t[o.offset]=`${-r}`,t[o.array]=`${e} ${n}`}const I$n=["offsetDistance","offsetPath","offsetRotate","offsetAnchor"];function oct(t,{attrX:e,attrY:n,attrScale:r,pathLength:i,pathSpacing:o=1,pathOffset:l=0,...u},d,p,m){if(_Ee(t,u,p),d){t.style.viewBox&&(t.attrs.viewBox=t.style.viewBox);return}t.attrs=t.style,t.style={};const{attrs:g,style:h}=t;g.transform&&(h.transform=g.transform,delete g.transform),(h.transform||g.transformOrigin)&&(h.transformOrigin=g.transformOrigin??"50% 50%",delete g.transformOrigin),h.transform&&(h.transformBox=m?.transformBox??"fill-box",delete g.transformBox);for(const f of I$n)g[f]!==void 0&&(h[f]=g[f],delete g[f]);e!==void 0&&(g.x=e),n!==void 0&&(g.y=n),r!==void 0&&(g.scale=r),i!==void 0&&S$n(g,i,o,l,!1)}const sct=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues","viewBox","gradientTransform","pathLength","startOffset","textLength","lengthAdjust"]),lct=t=>typeof t=="string"&&t.toLowerCase()==="svg";function T$n(t,e,n,r){nct(t,e,void 0,r);for(const i in e.attrs)t.setAttribute(sct.has(i)?i:iEe(i),e.attrs[i])}function cct(t,e,n){const r=xEe(t,e,n);for(const i in t)if(Cd(t[i])||Cd(e[i])){const o=HP.indexOf(i)!==-1?"attr"+i.charAt(0).toUpperCase()+i.substring(1):i;r[o]=t[i]}return r}class uct extends Glt{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=tp}getBaseTargetFromProps(e,n){return e[n]}readValueFromInstance(e,n){if(WP.has(n)){const r=Elt(n);return r&&r.default||0}return n=sct.has(n)?n:iEe(n),e.getAttribute(n)}scrapeMotionValuesFromProps(e,n,r){return cct(e,n,r)}build(e,n,r){oct(e,n,this.isSVGTag,r.transformTemplate,r.style)}renderInstance(e,n,r,i){T$n(e,n,r,i)}mount(e){this.isSVGTag=lct(e.tagName),super.mount(e)}}const B$n=fEe.length;function dct(t){if(!t)return;if(!t.isControllingVariants){const n=t.parent?dct(t.parent)||{}:{};return t.props.initial!==void 0&&(n.initial=t.props.initial),n}const e={};for(let n=0;n<B$n;n++){const r=fEe[n],i=t.props[r];(Z7(i)||i===!1)&&(e[r]=i)}return e}function pct(t,e){if(!Array.isArray(e))return!1;const n=e.length;if(n!==t.length)return!1;for(let r=0;r<n;r++)if(e[r]!==t[r])return!1;return!0}const D$n=[...hEe].reverse(),N$n=hEe.length;function R$n(t){return e=>Promise.all(e.map(({animation:n,options:r})=>NQn(t,n,r)))}function L$n(t){let e=R$n(t),n=mct(),r=!0,i=!1;const o=p=>(m,g)=>{const h=PN(t,g,p==="exit"?t.presenceContext?.custom:void 0);if(h){const{transition:f,transitionEnd:b,...y}=h;m={...m,...y,...b}}return m};function l(p){e=p(t)}function u(p){const{props:m}=t,g=dct(t.parent)||{},h=[],f=new Set;let b={},y=1/0;for(let _=0;_<N$n;_++){const w=D$n[_],x=n[w],k=m[w]!==void 0?m[w]:g[w],C=Z7(k),E=w===p?x.isActive:null;E===!1&&(y=_);let S=k===g[w]&&k!==m[w]&&C;if(S&&(r||i)&&t.manuallyAnimateOnMount&&(S=!1),x.protectedKeys={...b},!x.isActive&&E===null||!k&&!x.prevProp||$te(k)||typeof k=="boolean")continue;if(w==="exit"&&x.isActive&&E!==!0){x.prevResolvedValues&&(b={...b,...x.prevResolvedValues});continue}const I=M$n(x.prevProp,k);let B=I||w===p&&x.isActive&&!S&&C||_>y&&C,R=!1;const L=Array.isArray(k)?k:[k];let M=L.reduce(o(w),{});E===!1&&(M={});const{prevResolvedValues:N={}}=x,D={...N,...M},P=$=>{B=!0,f.has($)&&(R=!0,f.delete($)),x.needsAnimating[$]=!0;const j=t.getValue($);j&&(j.liveStyle=!1)};for(const $ in D){const j=M[$],Q=N[$];if(b.hasOwnProperty($))continue;let z=!1;rEe(j)&&rEe(Q)?z=!pct(j,Q):z=j!==Q,z?j!=null?P($):f.add($):j!==void 0&&f.has($)?P($):x.protectedKeys[$]=!0}x.prevProp=k,x.prevResolvedValues=M,x.isActive&&(b={...b,...M}),(r||i)&&t.blockInitialAnimation&&(B=!1);const O=S&&I;B&&(!O||R)&&h.push(...L.map($=>{const j={type:w};if(typeof $=="string"&&(r||i)&&!O&&t.manuallyAnimateOnMount&&t.parent){const{parent:Q}=t,z=PN(Q,$);if(Q.enteringChildren&&z){const{delayChildren:U}=z.transition||{};j.delay=mlt(Q.enteringChildren,t,U)}}return{animation:$,options:j}}))}if(f.size){const _={};if(typeof m.initial!="boolean"){const w=PN(t,Array.isArray(m.initial)?m.initial[0]:m.initial);w&&w.transition&&(_.transition=w.transition)}f.forEach(w=>{const x=t.getBaseTarget(w),k=t.getValue(w);k&&(k.liveStyle=!0),_[w]=x??null}),h.push({animation:_})}let v=!!h.length;return r&&(m.initial===!1||m.initial===m.animate)&&!t.manuallyAnimateOnMount&&(v=!1),r=!1,i=!1,v?e(h):Promise.resolve()}function d(p,m){if(n[p].isActive===m)return Promise.resolve();t.variantChildren?.forEach(h=>h.animationState?.setActive(p,m)),n[p].isActive=m;const g=u(p);for(const h in n)n[h].protectedKeys={};return g}return{animateChanges:u,setActive:d,setAnimateFunction:l,getState:()=>n,reset:()=>{n=mct(),i=!0}}}function M$n(t,e){return typeof e=="string"?e!==t:Array.isArray(e)?!pct(e,t):!1}function FN(t=!1){return{isActive:t,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function mct(){return{animate:FN(!0),whileInView:FN(),whileHover:FN(),whileTap:FN(),whileDrag:FN(),whileFocus:FN(),exit:FN()}}function kEe(t,e){t.min=e.min,t.max=e.max}function Yv(t,e){kEe(t.x,e.x),kEe(t.y,e.y)}function gct(t,e){t.translate=e.translate,t.scale=e.scale,t.originPoint=e.originPoint,t.origin=e.origin}const hct=1e-4,P$n=1-hct,O$n=1+hct,fct=.01,F$n=0-fct,Q$n=0+fct;function gf(t){return t.max-t.min}function $$n(t,e,n){return Math.abs(t-e)<=n}function Act(t,e,n,r=.5){t.origin=r,t.originPoint=Bc(e.min,e.max,t.origin),t.scale=gf(n)/gf(e),t.translate=Bc(n.min,n.max,t.origin)-t.originPoint,(t.scale>=P$n&&t.scale<=O$n||isNaN(t.scale))&&(t.scale=1),(t.translate>=F$n&&t.translate<=Q$n||isNaN(t.translate))&&(t.translate=0)}function J7(t,e,n,r){Act(t.x,e.x,n.x,r?r.originX:void 0),Act(t.y,e.y,n.y,r?r.originY:void 0)}function bct(t,e,n,r=0){const i=r?Bc(n.min,n.max,r):n.min;t.min=i+e.min,t.max=t.min+gf(e)}function j$n(t,e,n,r){bct(t.x,e.x,n.x,r?.x),bct(t.y,e.y,n.y,r?.y)}function yct(t,e,n,r=0){const i=r?Bc(n.min,n.max,r):n.min;t.min=e.min-i,t.max=t.min+gf(e)}function Gte(t,e,n,r){yct(t.x,e.x,n.x,r?.x),yct(t.y,e.y,n.y,r?.y)}function vct(t,e,n,r,i){return t-=e,t=Ute(t,1/n,r),i!==void 0&&(t=Ute(t,1/i,r)),t}function z$n(t,e=0,n=1,r=.5,i,o=t,l=t){if(ux.test(e)&&(e=parseFloat(e),e=Bc(l.min,l.max,e/100)-l.min),typeof e!="number")return;let u=Bc(o.min,o.max,r);t===o&&(u-=e),t.min=vct(t.min,e,n,u,i),t.max=vct(t.max,e,n,u,i)}function _ct(t,e,[n,r,i],o,l){z$n(t,e[n],e[r],e[i],e.scale,o,l)}const U$n=["x","scaleX","originX"],q$n=["y","scaleY","originY"];function wct(t,e,n,r){_ct(t.x,e,U$n,n?n.x:void 0,r?r.x:void 0),_ct(t.y,e,q$n,n?n.y:void 0,r?r.y:void 0)}function xct(t){return t.translate===0&&t.scale===1}function kct(t){return xct(t.x)&&xct(t.y)}function Ect(t,e){return t.min===e.min&&t.max===e.max}function G$n(t,e){return Ect(t.x,e.x)&&Ect(t.y,e.y)}function Cct(t,e){return Math.round(t.min)===Math.round(e.min)&&Math.round(t.max)===Math.round(e.max)}function Sct(t,e){return Cct(t.x,e.x)&&Cct(t.y,e.y)}function Ict(t){return gf(t.x)/gf(t.y)}function Tct(t,e){return t.translate===e.translate&&t.scale===e.scale&&t.originPoint===e.originPoint}function px(t){return[t("x"),t("y")]}function H$n(t,e,n){let r="";const i=t.x.translate/e.x,o=t.y.translate/e.y,l=n?.z||0;if((i||o||l)&&(r=`translate3d(${i}px, ${o}px, ${l}px) `),(e.x!==1||e.y!==1)&&(r+=`scale(${1/e.x}, ${1/e.y}) `),n){const{transformPerspective:p,rotate:m,rotateX:g,rotateY:h,skewX:f,skewY:b}=n;p&&(r=`perspective(${p}px) ${r}`),m&&(r+=`rotate(${m}deg) `),g&&(r+=`rotateX(${g}deg) `),h&&(r+=`rotateY(${h}deg) `),f&&(r+=`skewX(${f}deg) `),b&&(r+=`skewY(${b}deg) `)}const u=t.x.scale*e.x,d=t.y.scale*e.y;return(u!==1||d!==1)&&(r+=`scale(${u}, ${d})`),r||"none"}const Bct=["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"],W$n=Bct.length,Dct=t=>typeof t=="string"?parseFloat(t):t,Nct=t=>typeof t=="number"||Ja.test(t);function Y$n(t,e,n,r,i,o){i?(t.opacity=Bc(0,n.opacity??1,V$n(r)),t.opacityExit=Bc(e.opacity??1,0,K$n(r))):o&&(t.opacity=Bc(e.opacity??1,n.opacity??1,r));for(let l=0;l<W$n;l++){const u=Bct[l];let d=Rct(e,u),p=Rct(n,u);if(d===void 0&&p===void 0)continue;d||(d=0),p||(p=0),d===0||p===0||Nct(d)===Nct(p)?(t[u]=Math.max(Bc(Dct(d),Dct(p),r),0),(ux.test(p)||ux.test(d))&&(t[u]+="%")):t[u]=p}(e.rotate||n.rotate)&&(t.rotate=Bc(e.rotate||0,n.rotate||0,r))}function Rct(t,e){return t[e]!==void 0?t[e]:t.borderRadius}const V$n=Lct(0,.5,_st),K$n=Lct(.5,.95,ty);function Lct(t,e,n){return r=>r<t?0:r>e?1:n(jP(t,e,r))}function Mct(t,e,n){const r=Cd(t)?t:oI(t);return r.start(tEe("",r,e,n)),r.animation}function ez(t,e,n,r={passive:!0}){return t.addEventListener(e,n,r),()=>t.removeEventListener(e,n)}const Z$n=(t,e)=>t.depth-e.depth;class X$n{constructor(){this.children=[],this.isDirty=!1}add(e){_ke(this.children,e),this.isDirty=!0}remove(e){QP(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(Z$n),this.isDirty=!1,this.children.forEach(e)}}function J$n(t,e){const n=mf.now(),r=({timestamp:i})=>{const o=i-n;o>=e&&(w1(r),t(o-e))};return Nl.setup(r,!0),()=>w1(r)}function Hte(t){return Cd(t)?t.get():t}class ejn{constructor(){this.members=[]}add(e){_ke(this.members,e);for(let n=this.members.length-1;n>=0;n--){const r=this.members[n];if(r===e||r===this.lead||r===this.prevLead)continue;const i=r.instance;(!i||i.isConnected===!1)&&!r.snapshot&&(QP(this.members,r),r.unmount())}e.scheduleRender()}remove(e){if(QP(this.members,e),e===this.prevLead&&(this.prevLead=void 0),e===this.lead){const n=this.members[this.members.length-1];n&&this.promote(n)}}relegate(e){for(let n=this.members.indexOf(e)-1;n>=0;n--){const r=this.members[n];if(r.isPresent!==!1&&r.instance?.isConnected!==!1)return this.promote(r),!0}return!1}promote(e,n){const r=this.lead;if(e!==r&&(this.prevLead=r,this.lead=e,e.show(),r)){r.updateSnapshot(),e.scheduleRender();const{layoutDependency:i}=r.options,{layoutDependency:o}=e.options;(i===void 0||i!==o)&&(e.resumeFrom=r,n&&(r.preserveOpacity=!0),r.snapshot&&(e.snapshot=r.snapshot,e.snapshot.latestValues=r.animationValues||r.latestValues),e.root?.isUpdating&&(e.isLayoutDirty=!0)),e.options.crossfade===!1&&r.hide()}}exitAnimationComplete(){this.members.forEach(e=>{e.options.onExitComplete?.(),e.resumingFrom?.options.onExitComplete?.()})}scheduleRender(){this.members.forEach(e=>e.instance&&e.scheduleRender(!1))}removeLeadSnapshot(){this.lead?.snapshot&&(this.lead.snapshot=void 0)}}const Wte={hasAnimatedSinceResize:!0,hasEverUpdated:!1},EEe=["","X","Y","Z"],tjn=1e3;let njn=0;function CEe(t,e,n,r){const{latestValues:i}=e;i[t]&&(n[t]=i[t],e.setStaticValue(t,0),r&&(r[t]=0))}function Pct(t){if(t.hasCheckedOptimisedAppear=!0,t.root===t)return;const{visualElement:e}=t.options;if(!e)return;const n=vlt(e);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:i,layoutId:o}=t.options;window.MotionCancelOptimisedAnimation(n,"transform",Nl,!(i||o))}const{parent:r}=t;r&&!r.hasCheckedOptimisedAppear&&Pct(r)}function Oct({attachResizeListener:t,defaultParent:e,measureScroll:n,checkIsScrollRoot:r,resetTransform:i}){return class{constructor(l={},u=e?.()){this.id=njn++,this.animationId=0,this.animationCommitId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.layoutVersion=0,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,this.nodes.forEach(ijn),this.nodes.forEach(djn),this.nodes.forEach(pjn),this.nodes.forEach(ojn)},this.resolvedRelativeTargetAt=0,this.linkedParentVersion=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=l,this.root=u?u.root||u:this,this.path=u?[...u.path,u]:[],this.parent=u,this.depth=u?u.depth+1:0;for(let d=0;d<this.path.length;d++)this.path[d].shouldResetTransform=!0;this.root===this&&(this.nodes=new X$n)}addEventListener(l,u){return this.eventHandlers.has(l)||this.eventHandlers.set(l,new xke),this.eventHandlers.get(l).add(u)}notifyListeners(l,...u){const d=this.eventHandlers.get(l);d&&d.notify(...u)}hasListeners(l){return this.eventHandlers.has(l)}mount(l){if(this.instance)return;this.isSVG=Pte(l)&&!Plt(l),this.instance=l;const{layoutId:u,layout:d,visualElement:p}=this.options;if(p&&!p.current&&p.mount(l),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(d||u)&&(this.isLayoutDirty=!0),t){let m,g=0;const h=()=>this.root.updateBlockedByResize=!1;Nl.read(()=>{g=window.innerWidth}),t(l,()=>{const f=window.innerWidth;f!==g&&(g=f,this.root.updateBlockedByResize=!0,m&&m(),m=J$n(h,250),Wte.hasAnimatedSinceResize&&(Wte.hasAnimatedSinceResize=!1,this.nodes.forEach($ct)))})}u&&this.root.registerSharedNode(u,this),this.options.animate!==!1&&p&&(u||d)&&this.addEventListener("didUpdate",({delta:m,hasLayoutChanged:g,hasRelativeLayoutChanged:h,layout:f})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const b=this.options.transition||p.getDefaultTransition()||Ajn,{onLayoutAnimationStart:y,onLayoutAnimationComplete:v}=p.getProps(),_=!this.targetLayout||!Sct(this.targetLayout,f),w=!g&&h;if(this.options.layoutRoot||this.resumeFrom||w||g&&(_||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const x={...eEe(b,"layout"),onPlay:y,onComplete:v};(p.shouldReduceMotion||this.options.layoutRoot)&&(x.delay=0,x.type=!1),this.startAnimation(x),this.setAnimationOrigin(m,w)}else g||$ct(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=f})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const l=this.getStack();l&&l.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),w1(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(mjn),this.animationId++)}getTransformTemplate(){const{visualElement:l}=this.options;return l&&l.getProps().transformTemplate}willUpdate(l=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&Pct(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let m=0;m<this.path.length;m++){const g=this.path[m];g.shouldResetTransform=!0,(typeof g.latestValues.x=="string"||typeof g.latestValues.y=="string")&&(g.isLayoutDirty=!0),g.updateScroll("snapshot"),g.options.layoutRoot&&g.willUpdate(!1)}const{layoutId:u,layout:d}=this.options;if(u===void 0&&!d)return;const p=this.getTransformTemplate();this.prevTransformTemplateValue=p?p(this.latestValues,""):void 0,this.updateSnapshot(),l&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){const d=this.updateBlockedByResize;this.unblockUpdate(),this.updateBlockedByResize=!1,this.clearAllSnapshots(),d&&this.nodes.forEach(ljn),this.nodes.forEach(Fct);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(Qct);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(cjn),this.nodes.forEach(ujn),this.nodes.forEach(rjn),this.nodes.forEach(ajn)):this.nodes.forEach(Qct),this.clearAllSnapshots();const u=mf.now();pg.delta=cx(0,1e3/60,u-pg.timestamp),pg.timestamp=u,pg.isProcessing=!0,Ike.update.process(pg),Ike.preRender.process(pg),Ike.render.process(pg),pg.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,dEe.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(sjn),this.sharedNodes.forEach(gjn)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,Nl.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){Nl.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!gf(this.snapshot.measuredBox.x)&&!gf(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let d=0;d<this.path.length;d++)this.path[d].updateScroll();const l=this.layout;this.layout=this.measure(!1),this.layoutVersion++,this.layoutCorrected||(this.layoutCorrected=tp()),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);const{visualElement:u}=this.options;u&&u.notify("LayoutMeasure",this.layout.layoutBox,l?l.layoutBox:void 0)}updateScroll(l="measure"){let u=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===l&&(u=!1),u&&this.instance){const d=r(this.instance);this.scroll={animationId:this.root.animationId,phase:l,isRoot:d,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:d}}}resetTransform(){if(!i)return;const l=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,u=this.projectionDelta&&!kct(this.projectionDelta),d=this.getTransformTemplate(),p=d?d(this.latestValues,""):void 0,m=p!==this.prevTransformTemplateValue;l&&this.instance&&(u||ON(this.latestValues)||m)&&(i(this.instance,p),this.shouldResetTransform=!1,this.scheduleRender())}measure(l=!0){const u=this.measurePageBox();let d=this.removeElementScroll(u);return l&&(d=this.removeTransform(d)),bjn(d),{animationId:this.root.animationId,measuredBox:u,layoutBox:d,latestValues:{},source:this.id}}measurePageBox(){const{visualElement:l}=this.options;if(!l)return tp();const u=l.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(yjn))){const{scroll:p}=this.root;p&&(dx(u.x,p.offset.x),dx(u.y,p.offset.y))}return u}removeElementScroll(l){const u=tp();if(Yv(u,l),this.scroll?.wasRoot)return u;for(let d=0;d<this.path.length;d++){const p=this.path[d],{scroll:m,options:g}=p;p!==this.root&&m&&g.layoutScroll&&(m.wasRoot&&Yv(u,l),dx(u.x,m.offset.x),dx(u.y,m.offset.y))}return u}applyTransform(l,u=!1,d){const p=d||tp();Yv(p,l);for(let m=0;m<this.path.length;m++){const g=this.path[m];!u&&g.options.layoutScroll&&g.scroll&&g!==g.root&&(dx(p.x,-g.scroll.offset.x),dx(p.y,-g.scroll.offset.y)),ON(g.latestValues)&&qte(p,g.latestValues,g.layout?.layoutBox)}return ON(this.latestValues)&&qte(p,this.latestValues,this.layout?.layoutBox),p}removeTransform(l){const u=tp();Yv(u,l);for(let d=0;d<this.path.length;d++){const p=this.path[d];if(!ON(p.latestValues))continue;let m;p.instance&&(yEe(p.latestValues)&&p.updateSnapshot(),m=tp(),Yv(m,p.measurePageBox())),wct(u,p.latestValues,p.snapshot?.layoutBox,m)}return ON(this.latestValues)&&wct(u,this.latestValues),u}setTargetDelta(l){this.targetDelta=l,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(l){this.options={...this.options,...l,crossfade:l.crossfade!==void 0?l.crossfade:!0}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==pg.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(l=!1){const u=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=u.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=u.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=u.isSharedProjectionDirty);const d=!!this.resumingFrom||this!==u;if(!(l||d&&this.isSharedProjectionDirty||this.isProjectionDirty||this.parent?.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:m,layoutId:g}=this.options;if(!this.layout||!(m||g))return;this.resolvedRelativeTargetAt=pg.timestamp;const h=this.getClosestProjectingParent();h&&this.linkedParentVersion!==h.layoutVersion&&!h.options.layoutRoot&&this.removeRelativeTarget(),!this.targetDelta&&!this.relativeTarget&&(this.options.layoutAnchor!==!1&&h&&h.layout?this.createRelativeTarget(h,this.layout.layoutBox,h.layout.layoutBox):this.removeRelativeTarget()),!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=tp(),this.targetWithTransforms=tp()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),j$n(this.target,this.relativeTarget,this.relativeParent.target,this.options.layoutAnchor||void 0)):this.targetDelta?(this.resumingFrom?this.applyTransform(this.layout.layoutBox,!1,this.target):Yv(this.target,this.layout.layoutBox),Klt(this.target,this.targetDelta)):Yv(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget&&(this.attemptToResolveRelativeTarget=!1,this.options.layoutAnchor!==!1&&h&&!!h.resumingFrom==!!this.resumingFrom&&!h.options.layoutScroll&&h.target&&this.animationProgress!==1?this.createRelativeTarget(h,this.target,h.target):this.relativeParent=this.relativeTarget=void 0))}getClosestProjectingParent(){if(!(!this.parent||yEe(this.parent.latestValues)||Wlt(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}createRelativeTarget(l,u,d){this.relativeParent=l,this.linkedParentVersion=l.layoutVersion,this.forceRelativeParentToResolveTarget(),this.relativeTarget=tp(),this.relativeTargetOrigin=tp(),Gte(this.relativeTargetOrigin,u,d,this.options.layoutAnchor||void 0),Yv(this.relativeTarget,this.relativeTargetOrigin)}removeRelativeTarget(){this.relativeParent=this.relativeTarget=void 0}calcProjection(){const l=this.getLead(),u=!!this.resumingFrom||this!==l;let d=!0;if((this.isProjectionDirty||this.parent?.isProjectionDirty)&&(d=!1),u&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(d=!1),this.resolvedRelativeTargetAt===pg.timestamp&&(d=!1),d)return;const{layout:p,layoutId:m}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(p||m))return;Yv(this.layoutCorrected,this.layout.layoutBox);const g=this.treeScale.x,h=this.treeScale.y;f$n(this.layoutCorrected,this.treeScale,this.path,u),l.layout&&!l.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(l.target=l.layout.layoutBox,l.targetWithTransforms=tp());const{target:f}=l;if(!f){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(gct(this.prevProjectionDelta.x,this.projectionDelta.x),gct(this.prevProjectionDelta.y,this.projectionDelta.y)),J7(this.projectionDelta,this.layoutCorrected,f,this.latestValues),(this.treeScale.x!==g||this.treeScale.y!==h||!Tct(this.projectionDelta.x,this.prevProjectionDelta.x)||!Tct(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",f))}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(l=!0){if(this.options.visualElement?.scheduleRender(),l){const u=this.getStack();u&&u.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=VP(),this.projectionDelta=VP(),this.projectionDeltaWithTransform=VP()}setAnimationOrigin(l,u=!1){const d=this.snapshot,p=d?d.latestValues:{},m={...this.latestValues},g=VP();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!u;const h=tp(),f=d?d.source:void 0,b=this.layout?this.layout.source:void 0,y=f!==b,v=this.getStack(),_=!v||v.members.length<=1,w=!!(y&&!_&&this.options.crossfade===!0&&!this.path.some(fjn));this.animationProgress=0;let x;this.mixTargetDelta=k=>{const C=k/1e3;jct(g.x,l.x,C),jct(g.y,l.y,C),this.setTargetDelta(g),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(Gte(h,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0),hjn(this.relativeTarget,this.relativeTargetOrigin,h,C),x&&G$n(this.relativeTarget,x)&&(this.isProjectionDirty=!1),x||(x=tp()),Yv(x,this.relativeTarget)),y&&(this.animationValues=m,Y$n(m,p,this.latestValues,C,w,_)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=C},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(l){this.notifyListeners("animationStart"),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&(w1(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=Nl.update(()=>{Wte.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=oI(0)),this.motionValue.jump(0,!1),this.currentAnimation=Mct(this.motionValue,[0,1e3],{...l,velocity:0,isSync:!0,onUpdate:u=>{this.mixTargetDelta(u),l.onUpdate&&l.onUpdate(u)},onStop:()=>{},onComplete:()=>{l.onComplete&&l.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);const l=this.getStack();l&&l.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(tjn),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const l=this.getLead();let{targetWithTransforms:u,target:d,layout:p,latestValues:m}=l;if(!(!u||!d||!p)){if(this!==l&&this.layout&&p&&Hct(this.options.animationType,this.layout.layoutBox,p.layoutBox)){d=this.target||tp();const g=gf(this.layout.layoutBox.x);d.x.min=l.target.x.min,d.x.max=d.x.min+g;const h=gf(this.layout.layoutBox.y);d.y.min=l.target.y.min,d.y.max=d.y.min+h}Yv(u,d),qte(u,m),J7(this.projectionDeltaWithTransform,this.layoutCorrected,u,m)}}registerSharedNode(l,u){this.sharedNodes.has(l)||this.sharedNodes.set(l,new ejn),this.sharedNodes.get(l).add(u);const p=u.options.initialPromotionConfig;u.promote({transition:p?p.transition:void 0,preserveFollowOpacity:p&&p.shouldPreserveFollowOpacity?p.shouldPreserveFollowOpacity(u):void 0})}isLead(){const l=this.getStack();return l?l.lead===this:!0}getLead(){const{layoutId:l}=this.options;return l?this.getStack()?.lead||this:this}getPrevLead(){const{layoutId:l}=this.options;return l?this.getStack()?.prevLead:void 0}getStack(){const{layoutId:l}=this.options;if(l)return this.root.sharedNodes.get(l)}promote({needsReset:l,transition:u,preserveFollowOpacity:d}={}){const p=this.getStack();p&&p.promote(this,d),l&&(this.projectionDelta=void 0,this.needsReset=!0),u&&this.setOptions({transition:u})}relegate(){const l=this.getStack();return l?l.relegate(this):!1}resetSkewAndRotation(){const{visualElement:l}=this.options;if(!l)return;let u=!1;const{latestValues:d}=l;if((d.z||d.rotate||d.rotateX||d.rotateY||d.rotateZ||d.skewX||d.skewY)&&(u=!0),!u)return;const p={};d.z&&CEe("z",l,p,this.animationValues);for(let m=0;m<EEe.length;m++)CEe(`rotate${EEe[m]}`,l,p,this.animationValues),CEe(`skew${EEe[m]}`,l,p,this.animationValues);l.render();for(const m in p)l.setStaticValue(m,p[m]),this.animationValues&&(this.animationValues[m]=p[m]);l.scheduleRender()}applyProjectionStyles(l,u){if(!this.instance||this.isSVG)return;if(!this.isVisible){l.visibility="hidden";return}const d=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,l.visibility="",l.opacity="",l.pointerEvents=Hte(u?.pointerEvents)||"",l.transform=d?d(this.latestValues,""):"none";return}const p=this.getLead();if(!this.projectionDelta||!this.layout||!p.target){this.options.layoutId&&(l.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,l.pointerEvents=Hte(u?.pointerEvents)||""),this.hasProjected&&!ON(this.latestValues)&&(l.transform=d?d({},""):"none",this.hasProjected=!1);return}l.visibility="";const m=p.animationValues||p.latestValues;this.applyTransformsToTarget();let g=H$n(this.projectionDeltaWithTransform,this.treeScale,m);d&&(g=d(m,g)),l.transform=g;const{x:h,y:f}=this.projectionDelta;l.transformOrigin=`${h.origin*100}% ${f.origin*100}% 0`,p.animationValues?l.opacity=p===this?m.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:m.opacityExit:l.opacity=p===this?m.opacity!==void 0?m.opacity:"":m.opacityExit!==void 0?m.opacityExit:0;for(const b in wEe){if(m[b]===void 0)continue;const{correct:y,applyTo:v,isCSSVariable:_}=wEe[b],w=g==="none"?m[b]:y(m[b],p);if(v){const x=v.length;for(let k=0;k<x;k++)l[v[k]]=w}else _?this.options.visualElement.renderState.vars[b]=w:l[b]=w}this.options.layoutId&&(l.pointerEvents=p===this?Hte(u?.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(l=>l.currentAnimation?.stop()),this.root.nodes.forEach(Fct),this.root.sharedNodes.clear()}}}function rjn(t){t.updateLayout()}function ajn(t){const e=t.resumeFrom?.snapshot||t.snapshot;if(t.isLead()&&t.layout&&e&&t.hasListeners("didUpdate")){const{layoutBox:n,measuredBox:r}=t.layout,{animationType:i}=t.options,o=e.source!==t.layout.source;if(i==="size")px(m=>{const g=o?e.measuredBox[m]:e.layoutBox[m],h=gf(g);g.min=n[m].min,g.max=g.min+h});else if(i==="x"||i==="y"){const m=i==="x"?"y":"x";kEe(o?e.measuredBox[m]:e.layoutBox[m],n[m])}else Hct(i,e.layoutBox,n)&&px(m=>{const g=o?e.measuredBox[m]:e.layoutBox[m],h=gf(n[m]);g.max=g.min+h,t.relativeTarget&&!t.currentAnimation&&(t.isProjectionDirty=!0,t.relativeTarget[m].max=t.relativeTarget[m].min+h)});const l=VP();J7(l,n,e.layoutBox);const u=VP();o?J7(u,t.applyTransform(r,!0),e.measuredBox):J7(u,n,e.layoutBox);const d=!kct(l);let p=!1;if(!t.resumeFrom){const m=t.getClosestProjectingParent();if(m&&!m.resumeFrom){const{snapshot:g,layout:h}=m;if(g&&h){const f=t.options.layoutAnchor||void 0,b=tp();Gte(b,e.layoutBox,g.layoutBox,f);const y=tp();Gte(y,n,h.layoutBox,f),Sct(b,y)||(p=!0),m.options.layoutRoot&&(t.relativeTarget=y,t.relativeTargetOrigin=b,t.relativeParent=m)}}}t.notifyListeners("didUpdate",{layout:n,snapshot:e,delta:u,layoutDelta:l,hasLayoutChanged:d,hasRelativeLayoutChanged:p})}else if(t.isLead()){const{onExitComplete:n}=t.options;n&&n()}t.options.transition=void 0}function ijn(t){t.parent&&(t.isProjecting()||(t.isProjectionDirty=t.parent.isProjectionDirty),t.isSharedProjectionDirty||(t.isSharedProjectionDirty=!!(t.isProjectionDirty||t.parent.isProjectionDirty||t.parent.isSharedProjectionDirty)),t.isTransformDirty||(t.isTransformDirty=t.parent.isTransformDirty))}function ojn(t){t.isProjectionDirty=t.isSharedProjectionDirty=t.isTransformDirty=!1}function sjn(t){t.clearSnapshot()}function Fct(t){t.clearMeasurements()}function ljn(t){t.isLayoutDirty=!0,t.updateLayout()}function Qct(t){t.isLayoutDirty=!1}function cjn(t){t.isAnimationBlocked&&t.layout&&!t.isLayoutDirty&&(t.snapshot=t.layout,t.isLayoutDirty=!0)}function ujn(t){const{visualElement:e}=t.options;e&&e.getProps().onBeforeLayoutMeasure&&e.notify("BeforeLayoutMeasure"),t.resetTransform()}function $ct(t){t.finishAnimation(),t.targetDelta=t.relativeTarget=t.target=void 0,t.isProjectionDirty=!0}function djn(t){t.resolveTargetDelta()}function pjn(t){t.calcProjection()}function mjn(t){t.resetSkewAndRotation()}function gjn(t){t.removeLeadSnapshot()}function jct(t,e,n){t.translate=Bc(e.translate,0,n),t.scale=Bc(e.scale,1,n),t.origin=e.origin,t.originPoint=e.originPoint}function zct(t,e,n,r){t.min=Bc(e.min,n.min,r),t.max=Bc(e.max,n.max,r)}function hjn(t,e,n,r){zct(t.x,e.x,n.x,r),zct(t.y,e.y,n.y,r)}function fjn(t){return t.animationValues&&t.animationValues.opacityExit!==void 0}const Ajn={duration:.45,ease:[.4,0,.1,1]},Uct=t=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(t),qct=Uct("applewebkit/")&&!Uct("chrome/")?Math.round:ty;function Gct(t){t.min=qct(t.min),t.max=qct(t.max)}function bjn(t){Gct(t.x),Gct(t.y)}function Hct(t,e,n){return t==="position"||t==="preserve-aspect"&&!$$n(Ict(e),Ict(n),.2)}function yjn(t){return t!==t.root&&t.scroll?.wasRoot}const vjn=Oct({attachResizeListener:(t,e)=>ez(t,"resize",e),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body?.scrollLeft||0,y:document.documentElement.scrollTop||document.body?.scrollTop||0}),checkIsScrollRoot:()=>!0}),_jn=t=>!t.isLayoutDirty&&t.willUpdate(!1);function Wct(){const t=new Set,e=new WeakMap,n=()=>t.forEach(_jn);return{add:r=>{t.add(r),e.set(r,r.addEventListener("willUpdate",n))},remove:r=>{t.delete(r);const i=e.get(r);i&&(i(),e.delete(r)),n()},dirty:n}}const SEe={current:void 0},Yct=Oct({measureScroll:t=>({x:t.scrollLeft,y:t.scrollTop}),defaultParent:()=>{if(!SEe.current){const t=new vjn({});t.mount(window),t.setOptions({layoutScroll:!0}),SEe.current=t}return SEe.current},resetTransform:(t,e)=>{t.style.transform=e!==void 0?e:"none"},checkIsScrollRoot:t=>window.getComputedStyle(t).position==="fixed"}),tz=T.createContext({transformPagePoint:t=>t,isStatic:!1,reducedMotion:"never"});function Vct(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function wjn(...t){return e=>{let n=!1;const r=t.map(i=>{const o=Vct(i,e);return!n&&typeof o=="function"&&(n=!0),o});if(n)return()=>{for(let i=0;i<r.length;i++){const o=r[i];typeof o=="function"?o():Vct(t[i],null)}}}}function xjn(...t){return ee.useCallback(wjn(...t),t)}class kjn extends ee.Component{getSnapshotBeforeUpdate(e){const n=this.props.childRef.current;if(Lte(n)&&e.isPresent&&!this.props.isPresent&&this.props.pop!==!1){const r=n.offsetParent,i=Lte(r)&&r.offsetWidth||0,o=Lte(r)&&r.offsetHeight||0,l=getComputedStyle(n),u=this.props.sizeRef.current;u.height=parseFloat(l.height),u.width=parseFloat(l.width),u.top=n.offsetTop,u.left=n.offsetLeft,u.right=i-u.width-u.left,u.bottom=o-u.height-u.top}return null}componentDidUpdate(){}render(){return this.props.children}}function Ejn({children:t,isPresent:e,anchorX:n,anchorY:r,root:i,pop:o}){const l=T.useId(),u=T.useRef(null),d=T.useRef({width:0,height:0,top:0,left:0,right:0,bottom:0}),{nonce:p}=T.useContext(tz),m=t.props?.ref??t?.ref,g=xjn(u,m);return T.useInsertionEffect(()=>{const{width:h,height:f,top:b,left:y,right:v,bottom:_}=d.current;if(e||o===!1||!u.current||!h||!f)return;const w=n==="left"?`left: ${y}`:`right: ${v}`,x=r==="bottom"?`bottom: ${_}`:`top: ${b}`;u.current.dataset.motionPopId=l;const k=document.createElement("style");p&&(k.nonce=p);const C=i??document.head;return C.appendChild(k),k.sheet&&k.sheet.insertRule(`
111
111
  [data-motion-pop-id="${l}"] {
112
112
  position: absolute !important;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sciol/xyzen",
3
3
  "type": "module",
4
- "version": "1.9.77-beta.dbae374",
4
+ "version": "1.9.77-beta.f9561ad",
5
5
  "description": "A modern, lightweight, and extensible chat component for React.",
6
6
  "author": "Haohui <harveyque@outlook.com>",
7
7
  "license": "Apache-2.0",