@arcteninc/core 0.0.154 → 0.0.156
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +10 -10
- package/dist/index.mjs +2319 -2348
- package/dist/lib/useAgent.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
To fix: Run "arcten-extract-types ." and ensure "${u}" is used in ArctenAgent/useAgent.`),null}return r.add(i.meta.name),{name:i.meta.name,description:i.meta.description,jsonSchema:i.meta.parameters}}).filter(o=>o!==null)}const $l={password:[/^password$/i,/^pwd$/i,/^pass$/i,/^newPassword$/i,/^oldPassword$/i,/^currentPassword$/i,/^confirmPassword$/i,/.*password.*/i],email:[/^email$/i,/^emailAddress$/i,/^mail$/i,/.*email.*/i],phone:[/^phone$/i,/^phoneNumber$/i,/^mobile$/i,/^cell$/i,/^cellPhone$/i,/^telephone$/i,/.*phone.*/i,/.*mobile.*/i],pin:[/^pin$/i,/^pinCode$/i,/^securityPin$/i,/^accessPin$/i,/.*pin$/i],ssn:[/^ssn$/i,/^socialSecurityNumber$/i,/^social$/i,/.*ssn.*/i,/.*social.*/i],creditCard:[/^creditCard$/i,/^cardNumber$/i,/^card$/i,/^ccNumber$/i,/^creditCardNumber$/i,/.*card.*/i,/^cvv$/i,/^cvc$/i,/^cvn$/i,/^securityCode$/i],text:[]};function jn(e){for(const[t,n]of Object.entries($l))if(t!=="text"){for(const s of n)if(s.test(e))return t}return null}function Fl(e,t){return{password:{title:"Password Required",description:"Please enter your password to continue",placeholder:"Enter password..."},email:{title:"Email Required",description:"Please enter your email address",placeholder:"Enter email address..."},phone:{title:"Phone Number Required",description:"Please enter your phone number",placeholder:"Enter phone number..."},pin:{title:"PIN Required",description:"Please enter your PIN",placeholder:"Enter PIN..."},ssn:{title:"Social Security Number Required",description:"Please enter your Social Security Number",placeholder:"XXX-XX-XXXX"},creditCard:{title:"Credit Card Required",description:"Please enter your credit card information",placeholder:"XXXX XXXX XXXX XXXX"},text:{title:"Secure Input Required",description:`Please enter your ${t}`,placeholder:`Enter ${t}...`}}[e]}function Bl(e,t,n){return t.length>0}function Ul(e,t,n,s={}){const r=[];return Object.keys(s).forEach(i=>{const a=i in n,l=n[i];if(!a){const f=s[i];if(f!=null&&f!=="")return}const u=zl(s[i]),d={name:i,type:_l(l||jn(i)||"text"),label:jo(i),placeholder:Xl(i,l),required:!0,value:u};d.type==="password"&&(d.validation=f=>f.length<8?"Password must be at least 8 characters":null),r.push(d)}),r.sort((i,a)=>{const l=i.name in n,u=a.name in n;return l===u?0:l?1:-1}),{shouldUseForm:Bl(e,t),fields:r,title:Wl(e),description:ql(e,r.length)}}function zl(e){if(e!=null){if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return String(e)}}function _l(e){switch(e){case"password":return"password";case"email":return"email";case"phone":return"phone";case"pin":return"pin";case"ssn":return"ssn";case"creditCard":return"creditCard";default:return"text"}}function jo(e){return e.replace(/([A-Z])/g," $1").replace(/_/g," ").trim().toLowerCase().split(" ").map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" ")}function Xl(e,t){return t?Fl(t,e).placeholder:`Enter ${jo(e).toLowerCase()}...`}function Wl(e){return e.replace(/([A-Z])/g," $1").trim().toLowerCase().split(" ").map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" ")}function ql(e,t){const n=e.toLowerCase();return t<=2?`Please provide the required information to ${n}.`:`Please fill out the form below to ${n}. Required fields are marked with *.`}function An(e){if(typeof e=="string")try{const t=JSON.parse(e);return An(t)}catch{return e}if(Array.isArray(e))return e.map(An);if(e&&typeof e=="object"){const t={};for(const[n,s]of Object.entries(e))t[n]=An(s);return t}return e}function Kl(e,t){if(!t||Object.keys(t).length===0)return e;const n={...e};return Object.keys(t).forEach(s=>{s in n&&delete n[s]}),n}function Gl(e){if(typeof e=="string"){try{const t=JSON.parse(e);if(t&&typeof t=="object"&&!Array.isArray(t))return An(t)}catch{}return{}}return e&&typeof e=="object"&&!Array.isArray(e)?An(e):{}}const ns="__secureOutput",ss="[hidden for privacy]";function Yl(e,t){if(!e||e.length===0)return t;const n=new Map;t.forEach(o=>{const i=o[Le]||o.name;i&&n.set(i,o)});const s=new Map(e.map(o=>[o.name,o])),r=[];return e.forEach(o=>{const i=n.get(o.name);if(!i){console.log(`[useAgent] Skipping server-only tool: ${o.name}`);return}if(!o.isEnabled&&!o.isOverridable){console.log(`[useAgent] Blocking non-overridable disabled tool: ${o.name}`);return}if(!o.isEnabled&&o.isOverridable&&i){console.log(`[useAgent] Allowing overridable disabled tool with local implementation: ${o.name}`),r.push(i);return}o.isEnabled&&i&&r.push(i)}),t.forEach(o=>{const i=o[Le]||o.name;i&&!s.has(i)&&(console.log(`[useAgent] Allowing client-only tool (forward compatible): ${i}`),r.push(o))}),r}function Hl(e){if(typeof globalThis.structuredClone=="function")return globalThis.structuredClone(e);try{return JSON.parse(JSON.stringify(e))}catch(t){return console.warn("[useAgent] Failed to clone value for redaction:",t),e}}function Jl(e){return e.replace(/\[(\w+)\]/g,".$1").split(".").map(t=>t.trim()).filter(Boolean)}function Zl(e,t){if(t.length===0)return e;if(!e||typeof e!="object")return;let n=e;for(const s of t){if(!n||typeof n!="object")return;n=n[s]}return n}function Ql(e,t,n){if(!e||typeof e!="object"||t.length===0)return!1;let s=e;for(let o=0;o<t.length-1;o++){if(!s||typeof s!="object")return!1;const i=s,a=t[o];if(a===void 0)return!1;const l=i[a];if(l==null||typeof l!="object")return!1;s=l}if(!s)return!1;const r=t[t.length-1];return!r||!(r in s)?!1:(s[r]=n,!0)}function Xs(e){return e==null?!1:typeof e=="string"?e.trim().length>0:Array.isArray(e)?e.length>0:typeof e=="object"?Object.keys(e).length>0:!0}function Po(e,t=""){const n={};return e&&typeof e=="object"?Object.entries(e).forEach(([s,r])=>{const o=t?`${t}.${s}`:s;n[o]=Xs(r),r&&typeof r=="object"&&Object.assign(n,Po(r,o))}):t&&(n[t]=Xs(e)),n}function ec(e){if(e===void 0||e===!1)return;if(e===!0)return{strategy:"full",fields:[],placeholder:ss,includeFieldStatus:!1,preserve:[]};if(Array.isArray(e))return{strategy:"fields",fields:e,placeholder:ss,includeFieldStatus:!1,preserve:[]};const t=e.strategy??(e.fields&&e.fields.length>0?"fields":"full");return{strategy:t,fields:t==="fields"?e.fields??[]:[],placeholder:e.placeholder??ss,includeFieldStatus:e.includeFieldStatus??!1,preserve:e.preserve??[]}}function tc(e){if(!e)return{};const t={};for(const[n,s]of Object.entries(e)){const r=ec(s);r&&(t[n]=r)}return t}function Ao(e,t,n){const s=n.placeholder,r={tool:e,redacted:!0,strategy:n.strategy,placeholder:s};if(n.strategy==="full"){n.includeFieldStatus&&typeof t=="object"&&t!==null&&(r.fieldStatus=Po(t)),r.redactedFields=["*"];let l={};return n.preserve.length>0&&t&&typeof t=="object"&&n.preserve.forEach(u=>{u in t&&(l[u]=t[u])}),l[ns]=r,l}if(n.fields.includes("*"))return Ao(e,t,{...n,strategy:"full",fields:[]});if(typeof t!="object"||t===null)return{value:s,[ns]:{...r,redactedFields:n.fields}};const o=Hl(t),i=[],a={};return n.fields.forEach(l=>{const u=Jl(l);if(u.length===0)return;const d=Zl(o,u),f=Xs(d);a[l]=f,Ql(o,u,s)&&i.push(l)}),r.redactedFields=i,n.includeFieldStatus&&(r.fieldStatus=a),o[ns]=r,o}function Eo({apiBaseUrl:e="https://api.arcten.com",tokenEndpoint:t="/api/arcten/token",clientToken:n,skipTokenFetch:s=!1,user:r,tools:o=[],safeTools:i=[],safeToolNames:a,toolMetadata:l,sensitiveParams:u,sensitiveOutputs:d,autoDetectSensitive:f=!1,autoFormGeneration:m=!1,formMode:p="auto",systemPrompt:S="",agentId:v,agentName:C,projectId:b,enableRemoteConfig:M,remoteConfigUrl:E,initialMessages:$=[],conversationId:R,state:I,onStateChange:N,allowStateEdits:P=!0,onToolCall:O,onFinish:A,sources:k,ragConfig:F,ragFilters:V,secureInputHandler:B}={}){const W=e.replace(/\/+$/,""),[H,G]=h.useState(null),[ie,ye]=h.useState(!1),[Ge,xt]=h.useState(null),nt=h.useMemo(()=>{const g=k||[],y=H?.config?.sources||[];return[...new Set([...g,...y])]},[k,H]),Y=h.useMemo(()=>F!==void 0?F:V?{enabled:!0,filters:V}:nt&&nt.length>0?{enabled:!0,organizationId:nt[0],autoExecute:!0,filters:void 0}:{enabled:!1},[nt,F,V]),Ot=h.useMemo(()=>M===!1?!1:!!b,[b,M]);h.useEffect(()=>{if(!Ot||!oe.current)return;(async()=>{ye(!0),xt(null);try{const x=`${E||W.replace("/chat","").replace(/\/$/,"")}/convex/api/query`,w=await fetch(x,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${oe.current}`},body:JSON.stringify({path:"agents:getConfigForClient",args:{projectId:b,agentName:C,agentId:v},format:"json"})});if(!w.ok){if(w.status===404){console.warn("[useAgent] Remote config endpoint not found (404), using local tools only"),G(null);return}const D=await w.text().catch(()=>"Unknown error");throw new Error(`Failed to fetch remote config: ${w.status} ${D}`)}const j=await w.json();G(j?.value||null),console.log("[useAgent] Remote config loaded successfully:",j?.value)}catch(y){console.error("[useAgent] Failed to fetch remote config:",y);const x=y instanceof Error?y:new Error(String(y));xt(x),G(null)}finally{ye(!1)}})()},[Ot,b,C,v,W,E]);const Me=h.useMemo(()=>{const g={};if(u)for(const[y,x]of Object.entries(u))if(g[y]={},Array.isArray(x))for(const w of x){const j=jn(w);g[y][w]=j||"text"}else for(const[w,j]of Object.entries(x))g[y][w]=j;if(l){for(const[y,x]of Object.entries(l))if(x&&typeof x=="object"&&"sensitiveParams"in x){g[y]||(g[y]={});const w=x.sensitiveParams;if(Array.isArray(w))for(const j of w){const D=jn(j);g[y][j]=D||"text"}else if(w&&typeof w=="object")for(const[j,D]of Object.entries(w))g[y][j]=D}}return g},[u,l,f]),bt=h.useMemo(()=>tc(d),[d]),Pe=h.useCallback((g,y)=>{const x=bt[g];if(!x)return y;try{return Ao(g,y,x)}catch(w){return console.error(`[useAgent] Failed to redact output for ${g}:`,w),{value:ss,[ns]:{tool:g,redacted:!0,error:String(w)}}}},[bt]),[Be,fn]=h.useState(n||null),oe=h.useRef(n||null),[hn,vt]=h.useState(null),[mn,_n]=h.useState(null),Ue=h.useRef(null),[wt,St]=h.useState([]),[Re,pn]=h.useState(R||(typeof window<"u"?crypto.randomUUID():null)),[bs,Lt]=h.useState(!1),[Xn,Tt]=h.useState(new Set),[lt,vs]=h.useState(new Map),[Wn,Ye]=h.useState(new Map),[ws,qn]=h.useState(new Map),[$t,gn]=h.useState(new Map),le=I!==void 0,[yn,ze]=h.useState({}),Te=h.useRef({}),He=le?I||{}:yn;le&&I?Te.current=I:le||(Te.current=yn);const[_e,Ft]=h.useState(!1),[Ct,jt]=h.useState(null),xn=h.useRef(!1),De=h.useCallback(async(g,y=3)=>{if(!Re||!oe.current)return;const x=async()=>{const j=`${W.replace("/chat","").replace(/\/$/,"")}/convex/api/mutation`,D=await fetch(j,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${oe.current}`},body:JSON.stringify({path:"conversations:mergeStateByChatId",args:{chatId:Re,updates:g},format:"json"})});if(!D.ok){if(D.status===404){console.warn("[useAgent] Convex API endpoint not available (404), state changes will not be persisted");return}const L=await D.text().catch(()=>"Unknown error");throw new Error(`Failed to sync conversation state: ${D.status} ${L}`)}};for(let w=0;w<y;w++)try{await x(),jt(null);return}catch(j){if(w===y-1){const L=j instanceof Error?j:new Error(String(j));throw jt(L),console.error("Failed to sync state to Convex after retries:",j),L}await new Promise(L=>setTimeout(L,Math.pow(2,w)*100))}},[Re,W,oe]),Pt=h.useMemo(()=>function(){return Te.current},[]),xe=h.useMemo(()=>async function(y){const x={...Te.current,...y};Te.current=x,le||ze(x),N&&N(x);try{await De(y)}catch(w){throw w}},[De,N,le]);h.useEffect(()=>{le&&I&&(Te.current=I)},[le,I]);const Kn=h.useCallback(g=>B?B.showSecureModal(g):new Promise(y=>{vs(x=>new Map(x).set(g.id,g)),Ye(x=>new Map(x).set(g.id,y))}),[B]),Bt=h.useCallback((g,y)=>{if(B)return;const x=Wn.get(g);x&&(x(y),vs(w=>{const j=new Map(w);return j.delete(g),j}),Ye(w=>{const j=new Map(w);return j.delete(g),j}))},[Wn,B]),st=h.useCallback(g=>B?B.showSecureForm(g):new Promise(y=>{qn(x=>new Map(x).set(g.id,g)),gn(x=>new Map(x).set(g.id,y))}),[B]),Qr=h.useCallback((g,y)=>{if(B)return;const x=$t.get(g);x&&(x(y),qn(w=>{const j=new Map(w);return j.delete(g),j}),gn(w=>{const j=new Map(w);return j.delete(g),j}))},[$t,B]),bn=h.useCallback((g,y)=>{const x=Me[g]||{},w=Object.keys(x).length>0;if(f){const j=Object.keys(y).filter(D=>jn(D)!==null);return w||j.length>0}return w},[Me,f]),vn=h.useCallback((g,y)=>{const w={...Me[g]||{}};if(f){for(const D of Object.keys(y))if(!(D in w)){const L=jn(D);L&&(w[D]=L)}}const j=Object.entries(w).filter(([D])=>Object.prototype.hasOwnProperty.call(y,D));return j.length>0?Object.fromEntries(j):w},[Me,f]),Je=h.useMemo(()=>Y?.enabled?async function(y,x=20,w){const j={...Y.filters,...w};if(k&&k.length>1){const L=k.map(K=>fetch(`${W}/search`,{method:"POST",headers:{"Content-Type":"application/json",...oe.current?{Authorization:`Bearer ${oe.current}`}:{}},body:JSON.stringify({q:y,k:Math.min(x,100),organizationId:K,...Object.keys(j).length>0?{filters:j}:{}})}).then(re=>re.ok?re.json():null)),ae=await Promise.all(L),Q=[];for(const K of ae)K?.candidates&&Q.push(...K.candidates);Q.sort((K,re)=>{const et=K.scores?.rerank||K.scores?.dense||0;return(re.scores?.rerank||re.scores?.dense||0)-et});const ve=Q.slice(0,x).map((K,re)=>{const et=K.citation||K.url;return{rank:re+1,doc_id:K.doc_id,block_id:K.block_id,url:K.url,citation:et,title:K.title||"Untitled",snippet:K.snippet,score:K.scores?.rerank||K.scores?.dense||0,metadata:{site:K.metadata?.site,lang:K.metadata?.lang,contentType:K.metadata?.content_type}}});return{success:!0,query:y,total:Q.length,results:ve,summary:`Found ${Q.length} relevant results across ${k.length} source(s) for "${y}". Top result: ${ve[0]?.title||"N/A"}`}}const D=Y.organizationId&&Y.organizationId!=="default"?Y.organizationId:k&&k.length>0?k[0]:void 0;try{const L={q:y,k:Math.min(x,100)};D&&(L.organizationId=D),Object.keys(j).length>0&&(L.filters=j);const ae={"Content-Type":"application/json"};oe.current&&(ae.Authorization=`Bearer ${oe.current}`);const Q=await fetch(`${W}/search`,{method:"POST",headers:ae,body:JSON.stringify(L)});if(!Q.ok){const re=await Q.text();return{success:!1,error:`Search failed: ${Q.status} ${re}`}}const ve=await Q.json(),K=ve.candidates.map((re,et)=>{const Tn=re.citation||re.url;return{rank:et+1,doc_id:re.doc_id,block_id:re.block_id,url:re.url,citation:Tn,title:re.title||"Untitled",snippet:re.snippet,score:re.scores?.rerank||re.scores?.dense||0,metadata:{site:re.metadata?.site,lang:re.metadata?.lang,contentType:re.metadata?.content_type}}});return{success:!0,query:ve.query,total:ve.total,results:K,summary:`Found ${ve.total} relevant results for "${y}". Top result: ${K[0]?.title||"N/A"}`}}catch(L){return{success:!1,error:L instanceof Error?L.message:"Unknown error occurred"}}}:null,[Y,W,oe]),ct=h.useMemo(()=>Y?.enabled?async function(y,x){const w=Y.organizationId&&Y.organizationId!=="default"?Y.organizationId:k&&k.length>0?k[0]:void 0;try{const j={"Content-Type":"application/json"};oe.current&&(j.Authorization=`Bearer ${oe.current}`);const D=await fetch(`${W}/fetch`,{method:"POST",headers:j,body:JSON.stringify({doc_id:y,block_ids:x,...w?{organizationId:w}:{}})});if(!D.ok){const ae=await D.text();return{success:!1,error:`Fetch failed: ${D.status} ${ae}`}}const L=await D.json();return{success:!0,blocks:L.blocks||[],fullContent:L.fullContent||"",pageUrl:L.pageUrl||"",pageTitle:L.pageTitle||"",summary:`Fetched ${L.blocks?.length||0} blocks from ${L.pageTitle||y}`}}catch(j){return{success:!1,error:j instanceof Error?j.message:"Unknown error occurred"}}}:null,[Y,W,oe]),Ut=h.useMemo(()=>{if(H&&H.config?.tools){const g=Yl(H.config.tools,o);return console.log("[useAgent] Merged remote config:",{remoteToolCount:H.config.tools.length,localToolCount:o.length,mergedToolCount:g.length}),g}return o},[H,o]),Xe=H?.enableStateTools??!0,Ze=H?.enableRagTools??Y?.enabled??!1,Gn=h.useMemo(()=>{const g=[...Ut,...i];return Xe&&(g.push(Pt),(!le||P)&&g.push(xe)),Ze&&(Je&&g.push(Je),ct&&g.push(ct)),g},[Ut,i,Pt,xe,Je,ct,Xe,Ze,le,P]),Yn=h.useMemo(()=>[...Ut,...i],[Ut,i]),rt=h.useMemo(()=>pr(Yn,l),[Yn,l]),At=h.useMemo(()=>{const g=new Map,y=new Map(rt.map(x=>[x.name,x]));return g.set("getState",Pt),(!le||P)&&g.set("setState",xe),Y?.enabled&&(Je&&g.set("searchDocs",Je),ct&&g.set("fetchDocContent",ct)),Gn.forEach(x=>{if(x===Pt||x===xe||x===Je||x===ct)return;const w=x[Le];if(w){const D=y.get(w);if(D){g.set(D.name,x);return}}const j=rt.find(D=>D.name===x.name);j&&g.set(j.name,x)}),g},[Gn,rt,Pt,xe,Je,ct,Y,le,P]),wn=h.useMemo(()=>new Set(rt.map(g=>g.name)),[rt]),Hn=h.useMemo(()=>{const g=[];Xe&&(g.push({name:"getState",description:"Get the current agent state. Returns IDs, workflow state, checklists, and other persistent data.",jsonSchema:{type:"object",properties:{},required:[]}}),(!le||P)&&g.push({name:"setState",description:"Update the agent state. Store IDs, workflow state, checklists, context, and other data that must persist across conversations. Merges with existing state.",jsonSchema:{type:"object",properties:{updates:{type:"object",description:"Partial state updates to merge with existing state"}},required:["updates"]}}));const y=[];Ze&&y.push({name:"searchDocs",description:"Search documentation using semantic search. Returns relevant results with snippets and scores. Use this first to find relevant documentation. Default returns 20 results - use higher k values (30-50) when you need to find many sources.",jsonSchema:{type:"object",properties:{query:{type:"string",description:"The search query (user's question or keywords)"},k:{type:"number",description:"Number of results to return (default: 20, max: 100). Use 20-30 for comprehensive searches, or higher (50-100) when you need to find all relevant sources.",default:20},filters:{type:"object",description:"Optional filters to scope the search",properties:{site:{type:"string"},lang:{type:"string"},tags:{type:"array",items:{type:"string"}},docIds:{type:"array",items:{type:"string"}},pageIds:{type:"array",items:{type:"string"}}}}},required:["query"]}},{name:"fetchDocContent",description:"Fetch full content of documentation blocks after searching. Use this AFTER searchDocs when you find relevant results (scores > 0.3) to get complete text. Automatically fetches nearby blocks (5 chunks before/after each requested block) for context. You can pass multiple block_ids to fetch comprehensive content from multiple blocks/pages.",jsonSchema:{type:"object",properties:{doc_id:{type:"string",description:"The doc_id from searchDocs results"},block_ids:{type:"array",items:{type:"string"},description:"Array of block_ids from searchDocs results. You can pass multiple block_ids to fetch comprehensive content."}},required:["doc_id","block_ids"]}});const x=[];return H?.config?.workflows&&H.config.workflows.forEach(w=>{const j={},D=[];w.parameters&&w.parameters.forEach(L=>{j[L.name]={type:L.type||"string",description:L.description},L.required&&D.push(L.name)}),x.push({name:`workflow_${w.name.replace(/\s+/g,"_").toLowerCase()}`,description:w.description||`Execute the "${w.name}" workflow. ${w.contentPlaintext?.slice(0,200)||""}`,jsonSchema:{type:"object",properties:j,required:D},_workflow:w})}),[...rt,...g,...y,...x]},[rt,Xe,Ze,le,P,H]),ut=h.useMemo(()=>Hn.filter(g=>g.name==="getState"?Xe:g.name==="setState"?Xe&&(!le||P):g.name==="searchDocs"||g.name==="fetchDocContent"?Ze:g.name.startsWith("workflow_")?!0:wn.has(g.name)),[Hn,wn,Xe,Ze,le,P]),zt=h.useMemo(()=>{const g=new Set;return Xe&&(g.add("getState"),g.add("setState")),Ze&&Y?.autoExecute!==!1&&(g.add("searchDocs"),g.add("fetchDocContent")),H?.config?.tools?H.config.tools.forEach(y=>{y.isEnabled&&!y.requiresApproval&&g.add(y.name)}):(i.forEach(y=>{for(const[x,w]of At.entries())if(w===y){g.add(x);break}}),a&&Array.isArray(a)&&a.forEach(y=>{typeof y=="string"&&g.add(y)})),H?.config?.workflows&&H.config.workflows.forEach(y=>{const x=`workflow_${y.name.replace(/\s+/g,"_").toLowerCase()}`;y.requiresApproval||g.add(x)}),g},[H,i,a,At,Xe,Ze,Y]);h.useEffect(()=>s||n?void 0:((async()=>{try{const y=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:r})});if(!y.ok)throw new Error("Failed to fetch token");const x=await y.json();fn(x.clientToken),oe.current=x.clientToken,_n(x.expiresAt),vt(null)}catch(y){console.error("[useAgent] Token fetch failed:",y),vt(y instanceof Error?y.message:"Failed to fetch token")}})(),()=>{Ue.current&&clearTimeout(Ue.current)}),[t,JSON.stringify(r),s,n]),h.useEffect(()=>{if(!mn||s||n)return;Ue.current&&clearTimeout(Ue.current);const g=Math.floor(Date.now()/1e3),y=mn-g,w=Math.max(0,y-5);return Ue.current=setTimeout(async()=>{try{const j=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:r})});if(!j.ok)throw new Error("Failed to refresh token");const D=await j.json();fn(D.clientToken),oe.current=D.clientToken,_n(D.expiresAt),vt(null)}catch(j){console.error("[useAgent] Token refresh failed:",j),vt(j instanceof Error?j.message:"Failed to refresh token")}},w*1e3),()=>{Ue.current&&clearTimeout(Ue.current)}},[mn,t,JSON.stringify(r),s,n]);const Ss=async(g,y={})=>{const x=y.headers?new Headers(y.headers):new Headers;x.delete("user-agent"),x.delete("User-Agent"),console.log("[useAgent] Making request to:",g),console.log("[useAgent] Method:",y.method||"GET"),console.log("[useAgent] Has Authorization header:",x.has("Authorization")),console.log("[useAgent] Client token available:",!!oe.current);try{const w=await fetch(g,{...y,headers:x});if(!w.ok){console.error("[useAgent] Request failed:",w.status,w.statusText);const j=await w.text().catch(()=>"Unable to read error response");console.error("[useAgent] Error response:",j)}return w}catch(w){throw console.error("[useAgent] Fetch error:",w),w}},_t=h.useRef(!1),Sn=h.useRef(null),T=h.useRef(!1),_=h.useRef("ready"),X=`${W}/chat`;console.log("[useAgent] Chat API URL:",X);const{messages:q,sendMessage:Z,status:J,error:ke,stop:se,addToolResult:be,setMessages:z}=El.useChat({id:Re||void 0,messages:$,transport:new ni.DefaultChatTransport({api:X,fetch:Ss,headers:()=>{const g={};return oe.current?(g.Authorization=`Bearer ${oe.current}`,console.log("[useAgent] Adding Authorization header with token")):console.warn("[useAgent] No client token available - request may fail"),g},body:()=>{console.log("[ArctenAgent] body() agentName =",C);const g=ut.map(w=>({name:w.name,description:w.description,inputSchema:w.jsonSchema})),y=g.filter(w=>w.name==="getState"||w.name==="setState").map(w=>w.name),x=g.filter(w=>w.name==="searchDocs"||w.name==="fetchDocContent").map(w=>w.name);return y.length>0&&console.log("[useAgent] State tools included in tools list sent to AI SDK:",y),x.length>0?console.log("[useAgent] RAG tools included in tools list sent to AI SDK:",x):Y?.enabled&&console.warn("[useAgent] RAG is enabled but no RAG tools found in tools list!"),{tools:g,...v&&{agentId:v},...C&&{agentName:C},state:Te.current,...V&&{ragFilters:V}}}}),sendAutomaticallyWhen:g=>{const y=g.messages,x=y[y.length-1];if(_.current==="submitted"||_.current==="streaming")return!1;if(_t.current)return _t.current=!1,!1;if(x?.role==="user"||T.current)return!1;let w=!1;if(y.forEach(j=>{j.role==="assistant"&&j.parts?.forEach(D=>{D.type?.startsWith("tool-")&&D.state==="input-available"&&(w=!0)})}),w)return!1;if(x?.role==="assistant"&&x.id){if(Sn.current===x.id)return!1;if(ni.lastAssistantMessageIsCompleteWithToolCalls(g))return Sn.current=x.id,!0}return!1}});h.useEffect(()=>{_.current=J},[J]);const fe=Z,te=h.useCallback(g=>(_t.current=!0,Sn.current=null,T.current=!1,fe(g)),[fe]);h.useEffect(()=>{let g=!1;q.forEach(y=>{y.role==="assistant"&&y.parts.forEach(x=>{x.type?.startsWith("tool-")&&x.state==="input-available"&&(g=!0)})}),!g&&T.current&&(T.current=!1)},[q]);const he=h.useCallback((g,y,x)=>{const w=Pe(g,x);be({toolCallId:y,tool:g,output:w})},[be,Pe]);h.useEffect(()=>{q.forEach(g=>{g.role==="assistant"&&g.parts.forEach(y=>{if(!y.type?.startsWith("tool-")||y.state!=="input-available")return;const x=y.type.replace("tool-",""),w=y.toolCallId;if(Xn.has(w))return;Tt(D=>new Set(D).add(w));const j=Gl(y.input);if(bn(x,j)){const D=vn(x,j),L=Object.entries(D).filter(([K])=>j[K]!==void 0),ae=L.length>0?Object.fromEntries(L):D,Q=Object.keys(j),ve=Kl(j,ae);(async()=>{try{const K=Ul(x,Q,ae,j),re={id:`${w}-form`,toolName:x,toolCallId:w,title:K.title,description:K.description,fields:K.fields},et=await st(re);if(et===null){he(x,w,"User cancelled secure input");return}const Tn={...ve,...et},Ts=At.get(x);if(!Ts)throw new Error(`Tool ${x} not found`);let Cs;const js=ut.find(ei=>ei.name===x);if(js&&js.jsonSchema?.properties){const bl=Object.keys(js.jsonSchema.properties).map(vl=>Tn[vl]);Cs=await Ts(...bl)}else Cs=await Ts(...Object.values(Tn));he(x,w,Cs)}catch(K){console.error(`[useAgent] Error executing tool with secure input ${x}:`,K),he(x,w,`Error: ${K}`)}})();return}if(x.startsWith("workflow_")&&zt.has(x)){(async()=>{try{const L=ut.find(Q=>Q.name===x)?._workflow;if(!L)throw new Error(`Workflow metadata not found for ${x}`);let ae;if(L.webhook?.url){let Q=j;if(L.webhook.bodyTemplate){let K=L.webhook.bodyTemplate;Object.entries(j).forEach(([re,et])=>{K=K.replace(new RegExp(`\\{\\{${re}\\}\\}`,"g"),String(et))}),Q=JSON.parse(K)}const ve=await fetch(L.webhook.url,{method:L.webhook.method||"POST",headers:{"Content-Type":"application/json",...L.webhook.headers||{}},body:JSON.stringify(Q)});if(ve.ok)ae={success:!0,data:await ve.json().catch(()=>({success:!0}))};else{const K=await ve.text();ae={success:!1,error:`Webhook failed: ${ve.status} ${K}`}}}else ae={success:!0,message:`Workflow "${L.name}" acknowledged. Follow the workflow instructions to proceed.`,instructions:L.contentPlaintext};he(x,w,ae)}catch(D){console.error(`[useAgent] Error executing workflow ${x}:`,D),he(x,w,`Error: ${D}`)}})();return}if(zt.has(x)&&!bn(x,j)){const D=At.get(x);D?(async()=>{try{const L=ut.find(Q=>Q.name===x);let ae;if(L&&L.jsonSchema?.properties){const ve=Object.keys(L.jsonSchema.properties).map(K=>j[K]);ae=await D(...ve)}else if(x==="getState")ae=D();else if(x==="setState"){const Q=j.updates||j;ae=await D(Q)}else ae=await D(...Object.values(j));he(x,w,ae)}catch(L){console.error(`[useAgent] Error executing tool ${x}:`,L),he(x,w,`Error: ${L}`)}})():console.warn(`[useAgent] Tool ${x} not found in toolsMap`)}else x.startsWith("workflow_")&&O?(T.current=!0,O({toolCall:{toolCallId:w,toolName:x,args:j}})):O&&(T.current=!0,O({toolCall:{toolCallId:w,toolName:x,args:j}}))})})},[q,zt,At,O,he,Xn,xe,ut,bn,vn,Kn]),h.useEffect(()=>{if(J==="ready"&&q.length>0&&A){const g=q[q.length-1];g&&g.role==="assistant"&&A({message:g,messages:q,isAbort:!1,isDisconnect:!1,isError:!!ke})}},[J,q,ke,A]);async function me(){if(!(!r?.id||!Be)){Lt(!0);try{const y=await(await fetch(`${W}/conversations`,{headers:{Authorization:`Bearer ${Be}`}})).json();St(y.conversations||[])}catch(g){console.error("Failed to fetch conversations:",g)}finally{Lt(!1)}}}h.useEffect(()=>{r?.id&&Be&&me()},[JSON.stringify(r),Be,W]),h.useEffect(()=>{if(!Re||!oe.current)return;(async()=>{Ft(!0),jt(null);try{const y=await fetch(`${W.replace("/chat","")}/convex/api/query`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${oe.current}`},body:JSON.stringify({path:"conversations:getStateByChatId",args:{chatId:Re},format:"json"})});if(!y.ok){const j=await y.text().catch(()=>"Unknown error");throw new Error(`Failed to fetch conversation state: ${y.status} ${j}`)}const w=(await y.json())?.value||{};Te.current=w,le||ze(w),N&&N(w),xn.current=!0}catch(y){console.error("Failed to fetch state:",y);const x=y instanceof Error?y:new Error(String(y));jt(x),xn.current||(Te.current={},le?N&&N({}):(ze({}),N&&N({})),xn.current=!0)}finally{Ft(!1)}})()},[Re,W,le,N]);async function Qe(g){pn(g),Lt(!0);try{const y=await fetch(`${W}/conversations/${g}/messages`,{headers:{Authorization:`Bearer ${oe.current}`}});if(!y.ok)throw new Error(`Failed to fetch messages: ${y.statusText}`);const w=(await y.json()).messages||[];z(w)}catch(y){console.error("Failed to load conversation messages:",y)}finally{Lt(!1)}}async function we(g){if(Be)try{await fetch(`${W}/conversations/${g}`,{method:"DELETE",headers:{Authorization:`Bearer ${Be}`}}),St(wt.filter(y=>y._id!==g)),g===Re&&Ae()}catch(y){console.error("Failed to delete conversation:",y)}}function Ae(){const g=crypto.randomUUID();pn(g),z([]),Tt(new Set),Te.current={},le?N&&N({}):(ze({}),N&&N({})),xn.current=!1}function Ve(g){const y=g.tool||"unknown-tool",x=Pe(y,g.output);be({toolCallId:g.toolCallId,tool:y,output:x})}async function yl(g,y,x){if(!y.startsWith("workflow_"))throw new Error(`${y} is not a workflow tool`);try{const j=ut.find(L=>L.name===y)?._workflow;if(!j)throw new Error(`Workflow metadata not found for ${y}`);let D;if(j.webhook?.url){let L=x;if(j.webhook.bodyTemplate){let Q=j.webhook.bodyTemplate;Object.entries(x).forEach(([ve,K])=>{Q=Q.replace(new RegExp(`\\{\\{${ve}\\}\\}`,"g"),String(K))}),L=JSON.parse(Q)}const ae=await fetch(j.webhook.url,{method:j.webhook.method||"POST",headers:{"Content-Type":"application/json",...j.webhook.headers||{}},body:JSON.stringify(L)});if(ae.ok)D={success:!0,data:await ae.json().catch(()=>({success:!0}))};else{const Q=await ae.text();D={success:!1,error:`Webhook failed: ${ae.status} ${Q}`}}}else D={success:!0,message:`Workflow "${j.name}" acknowledged. Follow the workflow instructions to proceed.`,instructions:j.contentPlaintext};return Ve({toolCallId:g,tool:y,output:D}),D}catch(w){const j={success:!1,error:String(w)};throw Ve({toolCallId:g,tool:y,output:j}),w}}async function xl(g){const y={...Te.current,...g};Te.current=y,le||ze(y),N&&N(y);try{await De(g)}catch(x){throw x}}return{id:Re,messages:q,status:J,error:ke,sendMessage:te,stop:se,addToolOutput:Ve,executeWorkflowTool:yl,setMessages:z,conversations:wt,loadConversation:Qe,deleteConversation:we,startNewConversation:Ae,isLoadingConversations:bs,clientToken:Be,tokenError:hn,state:He,setState:xl,isStateLoading:_e,stateError:Ct,pendingSecureInputs:Array.from(lt.values()),completeSecureInput:Bt,pendingSecureForms:Array.from(ws.values()),completeSecureForm:Qr,safeToolNames:zt}}function ne(...e){return kl.twMerge(Ml.clsx(e))}const Mt=Co.cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive active:scale-95",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9","icon-sm":"size-8","icon-lg":"size-10"}},defaultVariants:{variant:"default",size:"default"}}),je=qe.forwardRef(({className:e,variant:t,size:n,asChild:s=!1,...r},o)=>{const i=s?To.Slot:"button";return c.jsx(i,{ref:o,"data-slot":"button",className:ne(Mt({variant:t,size:n,className:e})),...r})});je.displayName="Button";const nc=Co.cva("inline-flex items-center justify-center rounded-full border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",destructive:"border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground"}},defaultVariants:{variant:"default"}});function Ps({className:e,variant:t,asChild:n=!1,...s}){const r=n?To.Slot:"span";return c.jsx(r,{"data-slot":"badge",className:ne(nc({variant:t}),e),...s})}const sc=({textAreaRef:e,triggerAutoSize:t,maxHeight:n=Number.MAX_SAFE_INTEGER,minHeight:s=0})=>{const[r,o]=qe.useState(!0);qe.useEffect(()=>{const a=e.current;if(a){r&&(a.style.minHeight=`${s+6}px`,n>s&&(a.style.maxHeight=`${n}px`),o(!1)),a.style.height=`${s+6}px`;const l=a.scrollHeight;l>n?a.style.height=`${n}px`:a.style.height=`${l+6}px`}},[e.current,t])},Mo=qe.forwardRef(({maxHeight:e=Number.MAX_SAFE_INTEGER,minHeight:t=52,className:n,onChange:s,value:r,...o},i)=>{const a=qe.useRef(null),[l,u]=qe.useState("");return sc({textAreaRef:a,triggerAutoSize:l,maxHeight:e,minHeight:t}),h.useImperativeHandle(i,()=>({textArea:a.current,focus:()=>a?.current?.focus(),maxHeight:e,minHeight:t})),qe.useEffect(()=>{u(r)},[o?.defaultValue,r]),c.jsx("textarea",{...o,value:r,ref:a,className:ne("flex w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",n),onChange:d=>{u(d.target.value),s?.(d)}})});Mo.displayName="AutosizeTextarea";function rc({delayDuration:e=0,...t}){return c.jsx(Ht.Provider,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function dt({...e}){return c.jsx(rc,{children:c.jsx(Ht.Root,{"data-slot":"tooltip",...e})})}function ft({...e}){return c.jsx(Ht.Trigger,{"data-slot":"tooltip-trigger",...e})}function ht({className:e,sideOffset:t=0,children:n,...s}){return c.jsx(Ht.Portal,{children:c.jsxs(Ht.Content,{"data-slot":"tooltip-content",sideOffset:t,className:ne("bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",e),...s,children:[n,c.jsx(Ht.Arrow,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}function ri({className:e,...t}){return c.jsx("kbd",{"data-slot":"kbd",className:ne("bg-muted text-muted-foreground pointer-events-none inline-flex h-5 w-fit min-w-5 items-center justify-center gap-1 rounded-sm px-1 font-sans text-xs font-medium select-none","[&_svg:not([class*='size-'])]:size-3","[[data-slot=tooltip-content]_&]:bg-background/20 [[data-slot=tooltip-content]_&]:text-background dark:[[data-slot=tooltip-content]_&]:bg-background/10",e),...t})}const gr=h.createContext({});function yr(e){const t=h.useRef(null);return t.current===null&&(t.current=e()),t.current}const xr=typeof window<"u",ko=xr?h.useLayoutEffect:h.useEffect,ps=h.createContext(null);function br(e,t){e.indexOf(t)===-1&&e.push(t)}function vr(e,t){const n=e.indexOf(t);n>-1&&e.splice(n,1)}const it=(e,t,n)=>n>t?t:n<e?e:n;function Ws(e,t){return t?`${e}. For more information and steps for solving, visit https://motion.dev/troubleshooting/${t}`:e}let en=()=>{},ot=()=>{};process.env.NODE_ENV!=="production"&&(en=(e,t,n)=>{!e&&typeof console<"u"&&console.warn(Ws(t,n))},ot=(e,t,n)=>{if(!e)throw new Error(Ws(t,n))});const at={},No=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e);function Ro(e){return typeof e=="object"&&e!==null}const Do=e=>/^0[^.\s]+$/u.test(e);function wr(e){let t;return()=>(t===void 0&&(t=e()),t)}const Fe=e=>e,ic=(e,t)=>n=>t(e(n)),Fn=(...e)=>e.reduce(ic),Dn=(e,t,n)=>{const s=t-e;return s===0?1:(n-e)/s};class Sr{constructor(){this.subscriptions=[]}add(t){return br(this.subscriptions,t),()=>vr(this.subscriptions,t)}notify(t,n,s){const r=this.subscriptions.length;if(r)if(r===1)this.subscriptions[0](t,n,s);else for(let o=0;o<r;o++){const i=this.subscriptions[o];i&&i(t,n,s)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const Ke=e=>e*1e3,$e=e=>e/1e3;function Vo(e,t){return t?e*(1e3/t):0}const ii=new Set;function Tr(e,t,n){e||ii.has(t)||(console.warn(Ws(t,n)),ii.add(t))}const Io=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,oc=1e-7,ac=12;function lc(e,t,n,s,r){let o,i,a=0;do i=t+(n-t)/2,o=Io(i,s,r)-e,o>0?n=i:t=i;while(Math.abs(o)>oc&&++a<ac);return i}function Bn(e,t,n,s){if(e===t&&n===s)return Fe;const r=o=>lc(o,0,1,e,n);return o=>o===0||o===1?o:Io(r(o),t,s)}const Oo=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,Lo=e=>t=>1-e(1-t),$o=Bn(.33,1.53,.69,.99),Cr=Lo($o),Fo=Oo(Cr),Bo=e=>(e*=2)<1?.5*Cr(e):.5*(2-Math.pow(2,-10*(e-1))),jr=e=>1-Math.sin(Math.acos(e)),Uo=Lo(jr),zo=Oo(jr),cc=Bn(.42,0,1,1),uc=Bn(0,0,.58,1),_o=Bn(.42,0,.58,1),dc=e=>Array.isArray(e)&&typeof e[0]!="number",Xo=e=>Array.isArray(e)&&typeof e[0]=="number",oi={linear:Fe,easeIn:cc,easeInOut:_o,easeOut:uc,circIn:jr,circInOut:zo,circOut:Uo,backIn:Cr,backInOut:Fo,backOut:$o,anticipate:Bo},fc=e=>typeof e=="string",ai=e=>{if(Xo(e)){ot(e.length===4,"Cubic bezier arrays must contain four numerical values.","cubic-bezier-length");const[t,n,s,r]=e;return Bn(t,n,s,r)}else if(fc(e))return ot(oi[e]!==void 0,`Invalid easing type '${e}'`,"invalid-easing-type"),oi[e];return e},Jn=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function hc(e,t){let n=new Set,s=new Set,r=!1,o=!1;const i=new WeakSet;let a={delta:0,timestamp:0,isProcessing:!1};function l(d){i.has(d)&&(u.schedule(d),e()),d(a)}const u={schedule:(d,f=!1,m=!1)=>{const S=m&&r?n:s;return f&&i.add(d),S.has(d)||S.add(d),d},cancel:d=>{s.delete(d),i.delete(d)},process:d=>{if(a=d,r){o=!0;return}r=!0,[n,s]=[s,n],n.forEach(l),n.clear(),r=!1,o&&(o=!1,u.process(d))}};return u}const mc=40;function Wo(e,t){let n=!1,s=!0;const r={delta:0,timestamp:0,isProcessing:!1},o=()=>n=!0,i=Jn.reduce((E,$)=>(E[$]=hc(o),E),{}),{setup:a,read:l,resolveKeyframes:u,preUpdate:d,update:f,preRender:m,render:p,postRender:S}=i,v=()=>{const E=at.useManualTiming?r.timestamp:performance.now();n=!1,at.useManualTiming||(r.delta=s?1e3/60:Math.max(Math.min(E-r.timestamp,mc),1)),r.timestamp=E,r.isProcessing=!0,a.process(r),l.process(r),u.process(r),d.process(r),f.process(r),m.process(r),p.process(r),S.process(r),r.isProcessing=!1,n&&t&&(s=!1,e(v))},C=()=>{n=!0,s=!0,r.isProcessing||e(v)};return{schedule:Jn.reduce((E,$)=>{const R=i[$];return E[$]=(I,N=!1,P=!1)=>(n||C(),R.schedule(I,N,P)),E},{}),cancel:E=>{for(let $=0;$<Jn.length;$++)i[Jn[$]].cancel(E)},state:r,steps:i}}const{schedule:ce,cancel:pt,state:Se,steps:As}=Wo(typeof requestAnimationFrame<"u"?requestAnimationFrame:Fe,!0);let rs;function pc(){rs=void 0}const Ne={now:()=>(rs===void 0&&Ne.set(Se.isProcessing||at.useManualTiming?Se.timestamp:performance.now()),rs),set:e=>{rs=e,queueMicrotask(pc)}},qo=e=>t=>typeof t=="string"&&t.startsWith(e),Pr=qo("--"),gc=qo("var(--"),Ar=e=>gc(e)?yc.test(e.split("/*")[0].trim()):!1,yc=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu,tn={test:e=>typeof e=="number",parse:parseFloat,transform:e=>e},Vn={...tn,transform:e=>it(0,1,e)},Zn={...tn,default:1},En=e=>Math.round(e*1e5)/1e5,Er=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function xc(e){return e==null}const bc=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,Mr=(e,t)=>n=>!!(typeof n=="string"&&bc.test(n)&&n.startsWith(e)||t&&!xc(n)&&Object.prototype.hasOwnProperty.call(n,t)),Ko=(e,t,n)=>s=>{if(typeof s!="string")return s;const[r,o,i,a]=s.match(Er);return{[e]:parseFloat(r),[t]:parseFloat(o),[n]:parseFloat(i),alpha:a!==void 0?parseFloat(a):1}},vc=e=>it(0,255,e),Es={...tn,transform:e=>Math.round(vc(e))},Nt={test:Mr("rgb","red"),parse:Ko("red","green","blue"),transform:({red:e,green:t,blue:n,alpha:s=1})=>"rgba("+Es.transform(e)+", "+Es.transform(t)+", "+Es.transform(n)+", "+En(Vn.transform(s))+")"};function wc(e){let t="",n="",s="",r="";return e.length>5?(t=e.substring(1,3),n=e.substring(3,5),s=e.substring(5,7),r=e.substring(7,9)):(t=e.substring(1,2),n=e.substring(2,3),s=e.substring(3,4),r=e.substring(4,5),t+=t,n+=n,s+=s,r+=r),{red:parseInt(t,16),green:parseInt(n,16),blue:parseInt(s,16),alpha:r?parseInt(r,16)/255:1}}const qs={test:Mr("#"),parse:wc,transform:Nt.transform},Un=e=>({test:t=>typeof t=="string"&&t.endsWith(e)&&t.split(" ").length===1,parse:parseFloat,transform:t=>`${t}${e}`}),mt=Un("deg"),tt=Un("%"),U=Un("px"),Sc=Un("vh"),Tc=Un("vw"),li={...tt,parse:e=>tt.parse(e)/100,transform:e=>tt.transform(e*100)},Xt={test:Mr("hsl","hue"),parse:Ko("hue","saturation","lightness"),transform:({hue:e,saturation:t,lightness:n,alpha:s=1})=>"hsla("+Math.round(e)+", "+tt.transform(En(t))+", "+tt.transform(En(n))+", "+En(Vn.transform(s))+")"},ge={test:e=>Nt.test(e)||qs.test(e)||Xt.test(e),parse:e=>Nt.test(e)?Nt.parse(e):Xt.test(e)?Xt.parse(e):qs.parse(e),transform:e=>typeof e=="string"?e:e.hasOwnProperty("red")?Nt.transform(e):Xt.transform(e),getAnimatableNone:e=>{const t=ge.parse(e);return t.alpha=0,ge.transform(t)}},Cc=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function jc(e){return isNaN(e)&&typeof e=="string"&&(e.match(Er)?.length||0)+(e.match(Cc)?.length||0)>0}const Go="number",Yo="color",Pc="var",Ac="var(",ci="${}",Ec=/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 In(e){const t=e.toString(),n=[],s={color:[],number:[],var:[]},r=[];let o=0;const a=t.replace(Ec,l=>(ge.test(l)?(s.color.push(o),r.push(Yo),n.push(ge.parse(l))):l.startsWith(Ac)?(s.var.push(o),r.push(Pc),n.push(l)):(s.number.push(o),r.push(Go),n.push(parseFloat(l))),++o,ci)).split(ci);return{values:n,split:a,indexes:s,types:r}}function Ho(e){return In(e).values}function Jo(e){const{split:t,types:n}=In(e),s=t.length;return r=>{let o="";for(let i=0;i<s;i++)if(o+=t[i],r[i]!==void 0){const a=n[i];a===Go?o+=En(r[i]):a===Yo?o+=ge.transform(r[i]):o+=r[i]}return o}}const Mc=e=>typeof e=="number"?0:ge.test(e)?ge.getAnimatableNone(e):e;function kc(e){const t=Ho(e);return Jo(e)(t.map(Mc))}const gt={test:jc,parse:Ho,createTransformer:Jo,getAnimatableNone:kc};function Ms(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e}function Nc({hue:e,saturation:t,lightness:n,alpha:s}){e/=360,t/=100,n/=100;let r=0,o=0,i=0;if(!t)r=o=i=n;else{const a=n<.5?n*(1+t):n+t-n*t,l=2*n-a;r=Ms(l,a,e+1/3),o=Ms(l,a,e),i=Ms(l,a,e-1/3)}return{red:Math.round(r*255),green:Math.round(o*255),blue:Math.round(i*255),alpha:s}}function cs(e,t){return n=>n>0?t:e}const de=(e,t,n)=>e+(t-e)*n,ks=(e,t,n)=>{const s=e*e,r=n*(t*t-s)+s;return r<0?0:Math.sqrt(r)},Rc=[qs,Nt,Xt],Dc=e=>Rc.find(t=>t.test(e));function ui(e){const t=Dc(e);if(en(!!t,`'${e}' is not an animatable color. Use the equivalent color code instead.`,"color-not-animatable"),!t)return!1;let n=t.parse(e);return t===Xt&&(n=Nc(n)),n}const di=(e,t)=>{const n=ui(e),s=ui(t);if(!n||!s)return cs(e,t);const r={...n};return o=>(r.red=ks(n.red,s.red,o),r.green=ks(n.green,s.green,o),r.blue=ks(n.blue,s.blue,o),r.alpha=de(n.alpha,s.alpha,o),Nt.transform(r))},Ks=new Set(["none","hidden"]);function Vc(e,t){return Ks.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function Ic(e,t){return n=>de(e,t,n)}function kr(e){return typeof e=="number"?Ic:typeof e=="string"?Ar(e)?cs:ge.test(e)?di:$c:Array.isArray(e)?Zo:typeof e=="object"?ge.test(e)?di:Oc:cs}function Zo(e,t){const n=[...e],s=n.length,r=e.map((o,i)=>kr(o)(o,t[i]));return o=>{for(let i=0;i<s;i++)n[i]=r[i](o);return n}}function Oc(e,t){const n={...e,...t},s={};for(const r in n)e[r]!==void 0&&t[r]!==void 0&&(s[r]=kr(e[r])(e[r],t[r]));return r=>{for(const o in s)n[o]=s[o](r);return n}}function Lc(e,t){const n=[],s={color:0,var:0,number:0};for(let r=0;r<t.values.length;r++){const o=t.types[r],i=e.indexes[o][s[o]],a=e.values[i]??0;n[r]=a,s[o]++}return n}const $c=(e,t)=>{const n=gt.createTransformer(t),s=In(e),r=In(t);return s.indexes.var.length===r.indexes.var.length&&s.indexes.color.length===r.indexes.color.length&&s.indexes.number.length>=r.indexes.number.length?Ks.has(e)&&!r.values.length||Ks.has(t)&&!s.values.length?Vc(e,t):Fn(Zo(Lc(s,r),r.values),n):(en(!0,`Complex values '${e}' and '${t}' 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"),cs(e,t))};function Qo(e,t,n){return typeof e=="number"&&typeof t=="number"&&typeof n=="number"?de(e,t,n):kr(e)(e,t)}const Fc=e=>{const t=({timestamp:n})=>e(n);return{start:(n=!0)=>ce.update(t,n),stop:()=>pt(t),now:()=>Se.isProcessing?Se.timestamp:Ne.now()}},ea=(e,t,n=10)=>{let s="";const r=Math.max(Math.round(t/n),2);for(let o=0;o<r;o++)s+=Math.round(e(o/(r-1))*1e4)/1e4+", ";return`linear(${s.substring(0,s.length-2)})`},us=2e4;function Nr(e){let t=0;const n=50;let s=e.next(t);for(;!s.done&&t<us;)t+=n,s=e.next(t);return t>=us?1/0:t}function Bc(e,t=100,n){const s=n({...e,keyframes:[0,t]}),r=Math.min(Nr(s),us);return{type:"keyframes",ease:o=>s.next(r*o).value/t,duration:$e(r)}}const Uc=5;function ta(e,t,n){const s=Math.max(t-Uc,0);return Vo(n-e(s),t-s)}const ue={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},Ns=.001;function zc({duration:e=ue.duration,bounce:t=ue.bounce,velocity:n=ue.velocity,mass:s=ue.mass}){let r,o;en(e<=Ke(ue.maxDuration),"Spring duration must be 10 seconds or less","spring-duration-limit");let i=1-t;i=it(ue.minDamping,ue.maxDamping,i),e=it(ue.minDuration,ue.maxDuration,$e(e)),i<1?(r=u=>{const d=u*i,f=d*e,m=d-n,p=Gs(u,i),S=Math.exp(-f);return Ns-m/p*S},o=u=>{const f=u*i*e,m=f*n+n,p=Math.pow(i,2)*Math.pow(u,2)*e,S=Math.exp(-f),v=Gs(Math.pow(u,2),i);return(-r(u)+Ns>0?-1:1)*((m-p)*S)/v}):(r=u=>{const d=Math.exp(-u*e),f=(u-n)*e+1;return-Ns+d*f},o=u=>{const d=Math.exp(-u*e),f=(n-u)*(e*e);return d*f});const a=5/e,l=Xc(r,o,a);if(e=Ke(e),isNaN(l))return{stiffness:ue.stiffness,damping:ue.damping,duration:e};{const u=Math.pow(l,2)*s;return{stiffness:u,damping:i*2*Math.sqrt(s*u),duration:e}}}const _c=12;function Xc(e,t,n){let s=n;for(let r=1;r<_c;r++)s=s-e(s)/t(s);return s}function Gs(e,t){return e*Math.sqrt(1-t*t)}const Wc=["duration","bounce"],qc=["stiffness","damping","mass"];function fi(e,t){return t.some(n=>e[n]!==void 0)}function Kc(e){let t={velocity:ue.velocity,stiffness:ue.stiffness,damping:ue.damping,mass:ue.mass,isResolvedFromDuration:!1,...e};if(!fi(e,qc)&&fi(e,Wc))if(e.visualDuration){const n=e.visualDuration,s=2*Math.PI/(n*1.2),r=s*s,o=2*it(.05,1,1-(e.bounce||0))*Math.sqrt(r);t={...t,mass:ue.mass,stiffness:r,damping:o}}else{const n=zc(e);t={...t,...n,mass:ue.mass},t.isResolvedFromDuration=!0}return t}function ds(e=ue.visualDuration,t=ue.bounce){const n=typeof e!="object"?{visualDuration:e,keyframes:[0,1],bounce:t}:e;let{restSpeed:s,restDelta:r}=n;const o=n.keyframes[0],i=n.keyframes[n.keyframes.length-1],a={done:!1,value:o},{stiffness:l,damping:u,mass:d,duration:f,velocity:m,isResolvedFromDuration:p}=Kc({...n,velocity:-$e(n.velocity||0)}),S=m||0,v=u/(2*Math.sqrt(l*d)),C=i-o,b=$e(Math.sqrt(l/d)),M=Math.abs(C)<5;s||(s=M?ue.restSpeed.granular:ue.restSpeed.default),r||(r=M?ue.restDelta.granular:ue.restDelta.default);let E;if(v<1){const R=Gs(b,v);E=I=>{const N=Math.exp(-v*b*I);return i-N*((S+v*b*C)/R*Math.sin(R*I)+C*Math.cos(R*I))}}else if(v===1)E=R=>i-Math.exp(-b*R)*(C+(S+b*C)*R);else{const R=b*Math.sqrt(v*v-1);E=I=>{const N=Math.exp(-v*b*I),P=Math.min(R*I,300);return i-N*((S+v*b*C)*Math.sinh(P)+R*C*Math.cosh(P))/R}}const $={calculatedDuration:p&&f||null,next:R=>{const I=E(R);if(p)a.done=R>=f;else{let N=R===0?S:0;v<1&&(N=R===0?Ke(S):ta(E,R,I));const P=Math.abs(N)<=s,O=Math.abs(i-I)<=r;a.done=P&&O}return a.value=a.done?i:I,a},toString:()=>{const R=Math.min(Nr($),us),I=ea(N=>$.next(R*N).value,R,30);return R+"ms "+I},toTransition:()=>{}};return $}ds.applyToOptions=e=>{const t=Bc(e,100,ds);return e.ease=t.ease,e.duration=Ke(t.duration),e.type="keyframes",e};function Ys({keyframes:e,velocity:t=0,power:n=.8,timeConstant:s=325,bounceDamping:r=10,bounceStiffness:o=500,modifyTarget:i,min:a,max:l,restDelta:u=.5,restSpeed:d}){const f=e[0],m={done:!1,value:f},p=P=>a!==void 0&&P<a||l!==void 0&&P>l,S=P=>a===void 0?l:l===void 0||Math.abs(a-P)<Math.abs(l-P)?a:l;let v=n*t;const C=f+v,b=i===void 0?C:i(C);b!==C&&(v=b-f);const M=P=>-v*Math.exp(-P/s),E=P=>b+M(P),$=P=>{const O=M(P),A=E(P);m.done=Math.abs(O)<=u,m.value=m.done?b:A};let R,I;const N=P=>{p(m.value)&&(R=P,I=ds({keyframes:[m.value,S(m.value)],velocity:ta(E,P,m.value),damping:r,stiffness:o,restDelta:u,restSpeed:d}))};return N(0),{calculatedDuration:null,next:P=>{let O=!1;return!I&&R===void 0&&(O=!0,$(P),N(P)),R!==void 0&&P>=R?I.next(P-R):(!O&&$(P),m)}}}function Gc(e,t,n){const s=[],r=n||at.mix||Qo,o=e.length-1;for(let i=0;i<o;i++){let a=r(e[i],e[i+1]);if(t){const l=Array.isArray(t)?t[i]||Fe:t;a=Fn(l,a)}s.push(a)}return s}function Yc(e,t,{clamp:n=!0,ease:s,mixer:r}={}){const o=e.length;if(ot(o===t.length,"Both input and output ranges must be the same length","range-length"),o===1)return()=>t[0];if(o===2&&t[0]===t[1])return()=>t[1];const i=e[0]===e[1];e[0]>e[o-1]&&(e=[...e].reverse(),t=[...t].reverse());const a=Gc(t,s,r),l=a.length,u=d=>{if(i&&d<e[0])return t[0];let f=0;if(l>1)for(;f<e.length-2&&!(d<e[f+1]);f++);const m=Dn(e[f],e[f+1],d);return a[f](m)};return n?d=>u(it(e[0],e[o-1],d)):u}function Hc(e,t){const n=e[e.length-1];for(let s=1;s<=t;s++){const r=Dn(0,t,s);e.push(de(n,1,r))}}function Jc(e){const t=[0];return Hc(t,e.length-1),t}function Zc(e,t){return e.map(n=>n*t)}function Qc(e,t){return e.map(()=>t||_o).splice(0,e.length-1)}function Wt({duration:e=300,keyframes:t,times:n,ease:s="easeInOut"}){const r=dc(s)?s.map(ai):ai(s),o={done:!1,value:t[0]},i=Zc(n&&n.length===t.length?n:Jc(t),e),a=Yc(i,t,{ease:Array.isArray(r)?r:Qc(t,r)});return{calculatedDuration:e,next:l=>(o.value=a(l),o.done=l>=e,o)}}const eu=e=>e!==null;function Rr(e,{repeat:t,repeatType:n="loop"},s,r=1){const o=e.filter(eu),a=r<0||t&&n!=="loop"&&t%2===1?0:o.length-1;return!a||s===void 0?o[a]:s}const tu={decay:Ys,inertia:Ys,tween:Wt,keyframes:Wt,spring:ds};function na(e){typeof e.type=="string"&&(e.type=tu[e.type])}class Dr{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(t=>{this.resolve=t})}notifyFinished(){this.resolve()}then(t,n){return this.finished.then(t,n)}}const nu=e=>e/100;class Vr extends Dr{constructor(t){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.stop=()=>{const{motionValue:n}=this.options;n&&n.updatedAt!==Ne.now()&&this.tick(Ne.now()),this.isStopped=!0,this.state!=="idle"&&(this.teardown(),this.options.onStop?.())},this.options=t,this.initAnimation(),this.play(),t.autoplay===!1&&this.pause()}initAnimation(){const{options:t}=this;na(t);const{type:n=Wt,repeat:s=0,repeatDelay:r=0,repeatType:o,velocity:i=0}=t;let{keyframes:a}=t;const l=n||Wt;process.env.NODE_ENV!=="production"&&l!==Wt&&ot(a.length<=2,`Only two keyframes currently supported with spring and inertia animations. Trying to animate ${a}`,"spring-two-frames"),l!==Wt&&typeof a[0]!="number"&&(this.mixKeyframes=Fn(nu,Qo(a[0],a[1])),a=[0,100]);const u=l({...t,keyframes:a});o==="mirror"&&(this.mirroredGenerator=l({...t,keyframes:[...a].reverse(),velocity:-i})),u.calculatedDuration===null&&(u.calculatedDuration=Nr(u));const{calculatedDuration:d}=u;this.calculatedDuration=d,this.resolvedDuration=d+r,this.totalDuration=this.resolvedDuration*(s+1)-r,this.generator=u}updateTime(t){const n=Math.round(t-this.startTime)*this.playbackSpeed;this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=n}tick(t,n=!1){const{generator:s,totalDuration:r,mixKeyframes:o,mirroredGenerator:i,resolvedDuration:a,calculatedDuration:l}=this;if(this.startTime===null)return s.next(0);const{delay:u=0,keyframes:d,repeat:f,repeatType:m,repeatDelay:p,type:S,onUpdate:v,finalKeyframe:C}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,t):this.speed<0&&(this.startTime=Math.min(t-r/this.speed,this.startTime)),n?this.currentTime=t:this.updateTime(t);const b=this.currentTime-u*(this.playbackSpeed>=0?1:-1),M=this.playbackSpeed>=0?b<0:b>r;this.currentTime=Math.max(b,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=r);let E=this.currentTime,$=s;if(f){const P=Math.min(this.currentTime,r)/a;let O=Math.floor(P),A=P%1;!A&&P>=1&&(A=1),A===1&&O--,O=Math.min(O,f+1),!!(O%2)&&(m==="reverse"?(A=1-A,p&&(A-=p/a)):m==="mirror"&&($=i)),E=it(0,1,A)*a}const R=M?{done:!1,value:d[0]}:$.next(E);o&&(R.value=o(R.value));let{done:I}=R;!M&&l!==null&&(I=this.playbackSpeed>=0?this.currentTime>=r:this.currentTime<=0);const N=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&I);return N&&S!==Ys&&(R.value=Rr(d,this.options,C,this.speed)),v&&v(R.value),N&&this.finish(),R}then(t,n){return this.finished.then(t,n)}get duration(){return $e(this.calculatedDuration)}get iterationDuration(){const{delay:t=0}=this.options||{};return this.duration+$e(t)}get time(){return $e(this.currentTime)}set time(t){t=Ke(t),this.currentTime=t,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=t:this.driver&&(this.startTime=this.driver.now()-t/this.playbackSpeed),this.driver?.start(!1)}get speed(){return this.playbackSpeed}set speed(t){this.updateTime(Ne.now());const n=this.playbackSpeed!==t;this.playbackSpeed=t,n&&(this.time=$e(this.currentTime))}play(){if(this.isStopped)return;const{driver:t=Fc,startTime:n}=this.options;this.driver||(this.driver=t(r=>this.tick(r))),this.options.onPlay?.();const s=this.driver.now();this.state==="finished"?(this.updateFinished(),this.startTime=s):this.holdTime!==null?this.startTime=s-this.holdTime:this.startTime||(this.startTime=n??s),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(Ne.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(t){return this.startTime=0,this.tick(t,!0)}attachTimeline(t){return this.options.allowFlatten&&(this.options.type="keyframes",this.options.ease="linear",this.initAnimation()),this.driver?.stop(),t.observe(this)}}function su(e){for(let t=1;t<e.length;t++)e[t]??(e[t]=e[t-1])}const Rt=e=>e*180/Math.PI,Hs=e=>{const t=Rt(Math.atan2(e[1],e[0]));return Js(t)},ru={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:Hs,rotateZ:Hs,skewX:e=>Rt(Math.atan(e[1])),skewY:e=>Rt(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},Js=e=>(e=e%360,e<0&&(e+=360),e),hi=Hs,mi=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),pi=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),iu={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:mi,scaleY:pi,scale:e=>(mi(e)+pi(e))/2,rotateX:e=>Js(Rt(Math.atan2(e[6],e[5]))),rotateY:e=>Js(Rt(Math.atan2(-e[2],e[0]))),rotateZ:hi,rotate:hi,skewX:e=>Rt(Math.atan(e[4])),skewY:e=>Rt(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function Zs(e){return e.includes("scale")?1:0}function Qs(e,t){if(!e||e==="none")return Zs(t);const n=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let s,r;if(n)s=iu,r=n;else{const a=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);s=ru,r=a}if(!r)return Zs(t);const o=s[t],i=r[1].split(",").map(au);return typeof o=="function"?o(i):i[o]}const ou=(e,t)=>{const{transform:n="none"}=getComputedStyle(e);return Qs(n,t)};function au(e){return parseFloat(e.trim())}const nn=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],sn=new Set(nn),gi=e=>e===tn||e===U,lu=new Set(["x","y","z"]),cu=nn.filter(e=>!lu.has(e));function uu(e){const t=[];return cu.forEach(n=>{const s=e.getValue(n);s!==void 0&&(t.push([n,s.get()]),s.set(n.startsWith("scale")?1:0))}),t}const Dt={width:({x:e},{paddingLeft:t="0",paddingRight:n="0"})=>e.max-e.min-parseFloat(t)-parseFloat(n),height:({y:e},{paddingTop:t="0",paddingBottom:n="0"})=>e.max-e.min-parseFloat(t)-parseFloat(n),top:(e,{top:t})=>parseFloat(t),left:(e,{left:t})=>parseFloat(t),bottom:({y:e},{top:t})=>parseFloat(t)+(e.max-e.min),right:({x:e},{left:t})=>parseFloat(t)+(e.max-e.min),x:(e,{transform:t})=>Qs(t,"x"),y:(e,{transform:t})=>Qs(t,"y")};Dt.translateX=Dt.x;Dt.translateY=Dt.y;const Vt=new Set;let er=!1,tr=!1,nr=!1;function sa(){if(tr){const e=Array.from(Vt).filter(s=>s.needsMeasurement),t=new Set(e.map(s=>s.element)),n=new Map;t.forEach(s=>{const r=uu(s);r.length&&(n.set(s,r),s.render())}),e.forEach(s=>s.measureInitialState()),t.forEach(s=>{s.render();const r=n.get(s);r&&r.forEach(([o,i])=>{s.getValue(o)?.set(i)})}),e.forEach(s=>s.measureEndState()),e.forEach(s=>{s.suspendedScrollY!==void 0&&window.scrollTo(0,s.suspendedScrollY)})}tr=!1,er=!1,Vt.forEach(e=>e.complete(nr)),Vt.clear()}function ra(){Vt.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(tr=!0)})}function du(){nr=!0,ra(),sa(),nr=!1}class Ir{constructor(t,n,s,r,o,i=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...t],this.onComplete=n,this.name=s,this.motionValue=r,this.element=o,this.isAsync=i}scheduleResolve(){this.state="scheduled",this.isAsync?(Vt.add(this),er||(er=!0,ce.read(ra),ce.resolveKeyframes(sa))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:t,name:n,element:s,motionValue:r}=this;if(t[0]===null){const o=r?.get(),i=t[t.length-1];if(o!==void 0)t[0]=o;else if(s&&n){const a=s.readValue(n,i);a!=null&&(t[0]=a)}t[0]===void 0&&(t[0]=i),r&&o===void 0&&r.set(t[0])}su(t)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(t=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,t),Vt.delete(this)}cancel(){this.state==="scheduled"&&(Vt.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const fu=e=>e.startsWith("--");function hu(e,t,n){fu(t)?e.style.setProperty(t,n):e.style[t]=n}const mu=wr(()=>window.ScrollTimeline!==void 0),pu={};function gu(e,t){const n=wr(e);return()=>pu[t]??n()}const ia=gu(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),Pn=([e,t,n,s])=>`cubic-bezier(${e}, ${t}, ${n}, ${s})`,yi={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:Pn([0,.65,.55,1]),circOut:Pn([.55,0,1,.45]),backIn:Pn([.31,.01,.66,-.59]),backOut:Pn([.33,1.53,.69,.99])};function oa(e,t){if(e)return typeof e=="function"?ia()?ea(e,t):"ease-out":Xo(e)?Pn(e):Array.isArray(e)?e.map(n=>oa(n,t)||yi.easeOut):yi[e]}function yu(e,t,n,{delay:s=0,duration:r=300,repeat:o=0,repeatType:i="loop",ease:a="easeOut",times:l}={},u=void 0){const d={[t]:n};l&&(d.offset=l);const f=oa(a,r);Array.isArray(f)&&(d.easing=f);const m={delay:s,duration:r,easing:Array.isArray(f)?"linear":f,fill:"both",iterations:o+1,direction:i==="reverse"?"alternate":"normal"};return u&&(m.pseudoElement=u),e.animate(d,m)}function aa(e){return typeof e=="function"&&"applyToOptions"in e}function xu({type:e,...t}){return aa(e)&&ia()?e.applyToOptions(t):(t.duration??(t.duration=300),t.ease??(t.ease="easeOut"),t)}class bu extends Dr{constructor(t){if(super(),this.finishedTime=null,this.isStopped=!1,!t)return;const{element:n,name:s,keyframes:r,pseudoElement:o,allowFlatten:i=!1,finalKeyframe:a,onComplete:l}=t;this.isPseudoElement=!!o,this.allowFlatten=i,this.options=t,ot(typeof t.type!="string",`Mini animate() doesn't support "type" as a string.`,"mini-spring");const u=xu(t);this.animation=yu(n,s,r,u,o),u.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!o){const d=Rr(r,this.options,a,this.speed);this.updateMotionValue?this.updateMotionValue(d):hu(n,s,d),this.animation.cancel()}l?.(),this.notifyFinished()}}play(){this.isStopped||(this.animation.play(),this.state==="finished"&&this.updateFinished())}pause(){this.animation.pause()}complete(){this.animation.finish?.()}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;const{state:t}=this;t==="idle"||t==="finished"||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){this.isPseudoElement||this.animation.commitStyles?.()}get duration(){const t=this.animation.effect?.getComputedTiming?.().duration||0;return $e(Number(t))}get iterationDuration(){const{delay:t=0}=this.options||{};return this.duration+$e(t)}get time(){return $e(Number(this.animation.currentTime)||0)}set time(t){this.finishedTime=null,this.animation.currentTime=Ke(t)}get speed(){return this.animation.playbackRate}set speed(t){t<0&&(this.finishedTime=null),this.animation.playbackRate=t}get state(){return this.finishedTime!==null?"finished":this.animation.playState}get startTime(){return Number(this.animation.startTime)}set startTime(t){this.animation.startTime=t}attachTimeline({timeline:t,observe:n}){return this.allowFlatten&&this.animation.effect?.updateTiming({easing:"linear"}),this.animation.onfinish=null,t&&mu()?(this.animation.timeline=t,Fe):n(this)}}const la={anticipate:Bo,backInOut:Fo,circInOut:zo};function vu(e){return e in la}function wu(e){typeof e.ease=="string"&&vu(e.ease)&&(e.ease=la[e.ease])}const xi=10;class Su extends bu{constructor(t){wu(t),na(t),super(t),t.startTime&&(this.startTime=t.startTime),this.options=t}updateMotionValue(t){const{motionValue:n,onUpdate:s,onComplete:r,element:o,...i}=this.options;if(!n)return;if(t!==void 0){n.set(t);return}const a=new Vr({...i,autoplay:!1}),l=Ke(this.finishedTime??this.time);n.setWithVelocity(a.sample(l-xi).value,a.sample(l).value,xi),a.stop()}}const bi=(e,t)=>t==="zIndex"?!1:!!(typeof e=="number"||Array.isArray(e)||typeof e=="string"&&(gt.test(e)||e==="0")&&!e.startsWith("url("));function Tu(e){const t=e[0];if(e.length===1)return!0;for(let n=0;n<e.length;n++)if(e[n]!==t)return!0}function Cu(e,t,n,s){const r=e[0];if(r===null)return!1;if(t==="display"||t==="visibility")return!0;const o=e[e.length-1],i=bi(r,t),a=bi(o,t);return en(i===a,`You are trying to animate ${t} from "${r}" to "${o}". "${i?o:r}" is not an animatable value.`,"value-not-animatable"),!i||!a?!1:Tu(e)||(n==="spring"||aa(n))&&s}function sr(e){e.duration=0,e.type="keyframes"}const ju=new Set(["opacity","clipPath","filter","transform"]),Pu=wr(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function Au(e){const{motionValue:t,name:n,repeatDelay:s,repeatType:r,damping:o,type:i}=e;if(!(t?.owner?.current instanceof HTMLElement))return!1;const{onUpdate:l,transformTemplate:u}=t.owner.getProps();return Pu()&&n&&ju.has(n)&&(n!=="transform"||!u)&&!l&&!s&&r!=="mirror"&&o!==0&&i!=="inertia"}const Eu=40;class Mu extends Dr{constructor({autoplay:t=!0,delay:n=0,type:s="keyframes",repeat:r=0,repeatDelay:o=0,repeatType:i="loop",keyframes:a,name:l,motionValue:u,element:d,...f}){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=Ne.now();const m={autoplay:t,delay:n,type:s,repeat:r,repeatDelay:o,repeatType:i,name:l,motionValue:u,element:d,...f},p=d?.KeyframeResolver||Ir;this.keyframeResolver=new p(a,(S,v,C)=>this.onKeyframesResolved(S,v,m,!C),l,u,d),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(t,n,s,r){this.keyframeResolver=void 0;const{name:o,type:i,velocity:a,delay:l,isHandoff:u,onUpdate:d}=s;this.resolvedAt=Ne.now(),Cu(t,o,i,a)||((at.instantAnimations||!l)&&d?.(Rr(t,s,n)),t[0]=t[t.length-1],sr(s),s.repeat=0);const m={startTime:r?this.resolvedAt?this.resolvedAt-this.createdAt>Eu?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...s,keyframes:t},p=!u&&Au(m)?new Su({...m,element:m.motionValue.owner.current}):new Vr(m);p.finished.then(()=>this.notifyFinished()).catch(Fe),this.pendingTimeline&&(this.stopTimeline=p.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=p}get finished(){return this._animation?this.animation.finished:this._finished}then(t,n){return this.finished.finally(t).then(()=>{})}get animation(){return this._animation||(this.keyframeResolver?.resume(),du()),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(t){this.animation.time=t}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(t){this.animation.speed=t}get startTime(){return this.animation.startTime}attachTimeline(t){return this._animation?this.stopTimeline=this.animation.attachTimeline(t):this.pendingTimeline=t,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){this._animation&&this.animation.cancel(),this.keyframeResolver?.cancel()}}const ku=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function Nu(e){const t=ku.exec(e);if(!t)return[,];const[,n,s,r]=t;return[`--${n??s}`,r]}const Ru=4;function ca(e,t,n=1){ot(n<=Ru,`Max CSS variable fallback depth detected in property "${e}". This may indicate a circular fallback dependency.`,"max-css-var-depth");const[s,r]=Nu(e);if(!s)return;const o=window.getComputedStyle(t).getPropertyValue(s);if(o){const i=o.trim();return No(i)?parseFloat(i):i}return Ar(r)?ca(r,t,n+1):r}function Or(e,t){return e?.[t]??e?.default??e}const ua=new Set(["width","height","top","left","right","bottom",...nn]),Du={test:e=>e==="auto",parse:e=>e},da=e=>t=>t.test(e),fa=[tn,U,tt,mt,Tc,Sc,Du],vi=e=>fa.find(da(e));function Vu(e){return typeof e=="number"?e===0:e!==null?e==="none"||e==="0"||Do(e):!0}const Iu=new Set(["brightness","contrast","saturate","opacity"]);function Ou(e){const[t,n]=e.slice(0,-1).split("(");if(t==="drop-shadow")return e;const[s]=n.match(Er)||[];if(!s)return e;const r=n.replace(s,"");let o=Iu.has(t)?1:0;return s!==n&&(o*=100),t+"("+o+r+")"}const Lu=/\b([a-z-]*)\(.*?\)/gu,rr={...gt,getAnimatableNone:e=>{const t=e.match(Lu);return t?t.map(Ou).join(" "):e}},wi={...tn,transform:Math.round},$u={rotate:mt,rotateX:mt,rotateY:mt,rotateZ:mt,scale:Zn,scaleX:Zn,scaleY:Zn,scaleZ:Zn,skew:mt,skewX:mt,skewY:mt,distance:U,translateX:U,translateY:U,translateZ:U,x:U,y:U,z:U,perspective:U,transformPerspective:U,opacity:Vn,originX:li,originY:li,originZ:U},Lr={borderWidth:U,borderTopWidth:U,borderRightWidth:U,borderBottomWidth:U,borderLeftWidth:U,borderRadius:U,radius:U,borderTopLeftRadius:U,borderTopRightRadius:U,borderBottomRightRadius:U,borderBottomLeftRadius:U,width:U,maxWidth:U,height:U,maxHeight:U,top:U,right:U,bottom:U,left:U,padding:U,paddingTop:U,paddingRight:U,paddingBottom:U,paddingLeft:U,margin:U,marginTop:U,marginRight:U,marginBottom:U,marginLeft:U,backgroundPositionX:U,backgroundPositionY:U,...$u,zIndex:wi,fillOpacity:Vn,strokeOpacity:Vn,numOctaves:wi},Fu={...Lr,color:ge,backgroundColor:ge,outlineColor:ge,fill:ge,stroke:ge,borderColor:ge,borderTopColor:ge,borderRightColor:ge,borderBottomColor:ge,borderLeftColor:ge,filter:rr,WebkitFilter:rr},ha=e=>Fu[e];function ma(e,t){let n=ha(e);return n!==rr&&(n=gt),n.getAnimatableNone?n.getAnimatableNone(t):void 0}const Bu=new Set(["auto","none","0"]);function Uu(e,t,n){let s=0,r;for(;s<e.length&&!r;){const o=e[s];typeof o=="string"&&!Bu.has(o)&&In(o).values.length&&(r=e[s]),s++}if(r&&n)for(const o of t)e[o]=ma(n,r)}class zu extends Ir{constructor(t,n,s,r,o){super(t,n,s,r,o,!0)}readKeyframes(){const{unresolvedKeyframes:t,element:n,name:s}=this;if(!n||!n.current)return;super.readKeyframes();for(let l=0;l<t.length;l++){let u=t[l];if(typeof u=="string"&&(u=u.trim(),Ar(u))){const d=ca(u,n.current);d!==void 0&&(t[l]=d),l===t.length-1&&(this.finalKeyframe=u)}}if(this.resolveNoneKeyframes(),!ua.has(s)||t.length!==2)return;const[r,o]=t,i=vi(r),a=vi(o);if(i!==a)if(gi(i)&&gi(a))for(let l=0;l<t.length;l++){const u=t[l];typeof u=="string"&&(t[l]=parseFloat(u))}else Dt[s]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:t,name:n}=this,s=[];for(let r=0;r<t.length;r++)(t[r]===null||Vu(t[r]))&&s.push(r);s.length&&Uu(t,s,n)}measureInitialState(){const{element:t,unresolvedKeyframes:n,name:s}=this;if(!t||!t.current)return;s==="height"&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=Dt[s](t.measureViewportBox(),window.getComputedStyle(t.current)),n[0]=this.measuredOrigin;const r=n[n.length-1];r!==void 0&&t.getValue(s,r).jump(r,!1)}measureEndState(){const{element:t,name:n,unresolvedKeyframes:s}=this;if(!t||!t.current)return;const r=t.getValue(n);r&&r.jump(this.measuredOrigin,!1);const o=s.length-1,i=s[o];s[o]=Dt[n](t.measureViewportBox(),window.getComputedStyle(t.current)),i!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=i),this.removedTransforms?.length&&this.removedTransforms.forEach(([a,l])=>{t.getValue(a).set(l)}),this.resolveNoneKeyframes()}}function _u(e,t,n){if(e instanceof EventTarget)return[e];if(typeof e=="string"){let s=document;const r=n?.[e]??s.querySelectorAll(e);return r?Array.from(r):[]}return Array.from(e)}const pa=(e,t)=>t&&typeof e=="number"?t.transform(e):e;function ga(e){return Ro(e)&&"offsetHeight"in e}const Si=30,Xu=e=>!isNaN(parseFloat(e));class Wu{constructor(t,n={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=s=>{const r=Ne.now();if(this.updatedAt!==r&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(s),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(t),this.owner=n.owner}setCurrent(t){this.current=t,this.updatedAt=Ne.now(),this.canTrackVelocity===null&&t!==void 0&&(this.canTrackVelocity=Xu(this.current))}setPrevFrameValue(t=this.current){this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt}onChange(t){return process.env.NODE_ENV!=="production"&&Tr(!1,'value.onChange(callback) is deprecated. Switch to value.on("change", callback).'),this.on("change",t)}on(t,n){this.events[t]||(this.events[t]=new Sr);const s=this.events[t].add(n);return t==="change"?()=>{s(),ce.read(()=>{this.events.change.getSize()||this.stop()})}:s}clearListeners(){for(const t in this.events)this.events[t].clear()}attach(t,n){this.passiveEffect=t,this.stopPassiveEffect=n}set(t){this.passiveEffect?this.passiveEffect(t,this.updateAndNotify):this.updateAndNotify(t)}setWithVelocity(t,n,s){this.set(n),this.prev=void 0,this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt-s}jump(t,n=!0){this.updateAndNotify(t),this.prev=t,this.prevUpdatedAt=this.prevFrameValue=void 0,n&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){this.events.change?.notify(this.current)}addDependent(t){this.dependents||(this.dependents=new Set),this.dependents.add(t)}removeDependent(t){this.dependents&&this.dependents.delete(t)}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const t=Ne.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||t-this.updatedAt>Si)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,Si);return Vo(parseFloat(this.current)-parseFloat(this.prevFrameValue),n)}start(t){return this.stop(),new Promise(n=>{this.hasAnimated=!0,this.animation=t(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 Zt(e,t){return new Wu(e,t)}const{schedule:$r}=Wo(queueMicrotask,!1),We={x:!1,y:!1};function ya(){return We.x||We.y}function qu(e){return e==="x"||e==="y"?We[e]?null:(We[e]=!0,()=>{We[e]=!1}):We.x||We.y?null:(We.x=We.y=!0,()=>{We.x=We.y=!1})}function xa(e,t){const n=_u(e),s=new AbortController,r={passive:!0,...t,signal:s.signal};return[n,r,()=>s.abort()]}function Ti(e){return!(e.pointerType==="touch"||ya())}function Ku(e,t,n={}){const[s,r,o]=xa(e,n),i=a=>{if(!Ti(a))return;const{target:l}=a,u=t(l,a);if(typeof u!="function"||!l)return;const d=f=>{Ti(f)&&(u(f),l.removeEventListener("pointerleave",d))};l.addEventListener("pointerleave",d,r)};return s.forEach(a=>{a.addEventListener("pointerenter",i,r)}),o}const ba=(e,t)=>t?e===t?!0:ba(e,t.parentElement):!1,Fr=e=>e.pointerType==="mouse"?typeof e.button!="number"||e.button<=0:e.isPrimary!==!1,Gu=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function Yu(e){return Gu.has(e.tagName)||e.tabIndex!==-1}const is=new WeakSet;function Ci(e){return t=>{t.key==="Enter"&&e(t)}}function Rs(e,t){e.dispatchEvent(new PointerEvent("pointer"+t,{isPrimary:!0,bubbles:!0}))}const Hu=(e,t)=>{const n=e.currentTarget;if(!n)return;const s=Ci(()=>{if(is.has(n))return;Rs(n,"down");const r=Ci(()=>{Rs(n,"up")}),o=()=>Rs(n,"cancel");n.addEventListener("keyup",r,t),n.addEventListener("blur",o,t)});n.addEventListener("keydown",s,t),n.addEventListener("blur",()=>n.removeEventListener("keydown",s),t)};function ji(e){return Fr(e)&&!ya()}function Ju(e,t,n={}){const[s,r,o]=xa(e,n),i=a=>{const l=a.currentTarget;if(!ji(a))return;is.add(l);const u=t(l,a),d=(p,S)=>{window.removeEventListener("pointerup",f),window.removeEventListener("pointercancel",m),is.has(l)&&is.delete(l),ji(p)&&typeof u=="function"&&u(p,{success:S})},f=p=>{d(p,l===window||l===document||n.useGlobalTarget||ba(l,p.target))},m=p=>{d(p,!1)};window.addEventListener("pointerup",f,r),window.addEventListener("pointercancel",m,r)};return s.forEach(a=>{(n.useGlobalTarget?window:a).addEventListener("pointerdown",i,r),ga(a)&&(a.addEventListener("focus",u=>Hu(u,r)),!Yu(a)&&!a.hasAttribute("tabindex")&&(a.tabIndex=0))}),o}function va(e){return Ro(e)&&"ownerSVGElement"in e}function Zu(e){return va(e)&&e.tagName==="svg"}const Ce=e=>!!(e&&e.getVelocity),Qu=[...fa,ge,gt],ed=e=>Qu.find(da(e)),Br=h.createContext({transformPagePoint:e=>e,isStatic:!1,reducedMotion:"never"});function Pi(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function td(...e){return t=>{let n=!1;const s=e.map(r=>{const o=Pi(r,t);return!n&&typeof o=="function"&&(n=!0),o});if(n)return()=>{for(let r=0;r<s.length;r++){const o=s[r];typeof o=="function"?o():Pi(e[r],null)}}}}function nd(...e){return qe.useCallback(td(...e),e)}class sd extends qe.Component{getSnapshotBeforeUpdate(t){const n=this.props.childRef.current;if(n&&t.isPresent&&!this.props.isPresent){const s=n.offsetParent,r=ga(s)&&s.offsetWidth||0,o=this.props.sizeRef.current;o.height=n.offsetHeight||0,o.width=n.offsetWidth||0,o.top=n.offsetTop,o.left=n.offsetLeft,o.right=r-o.width-o.left}return null}componentDidUpdate(){}render(){return this.props.children}}function rd({children:e,isPresent:t,anchorX:n,root:s}){const r=h.useId(),o=h.useRef(null),i=h.useRef({width:0,height:0,top:0,left:0,right:0}),{nonce:a}=h.useContext(Br),l=nd(o,e?.ref);return h.useInsertionEffect(()=>{const{width:u,height:d,top:f,left:m,right:p}=i.current;if(t||!o.current||!u||!d)return;const S=n==="left"?`left: ${m}`:`right: ${p}`;o.current.dataset.motionPopId=r;const v=document.createElement("style");a&&(v.nonce=a);const C=s??document.head;return C.appendChild(v),v.sheet&&v.sheet.insertRule(`
|
|
1
|
+
"use strict";var xl=Object.create;var ei=Object.defineProperty;var bl=Object.getOwnPropertyDescriptor;var vl=Object.getOwnPropertyNames;var wl=Object.getPrototypeOf,Sl=Object.prototype.hasOwnProperty;var Tl=(e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of vl(t))!Sl.call(e,r)&&r!==n&&ei(e,r,{get:()=>t[r],enumerable:!(s=bl(t,r))||s.enumerable});return e};var Cl=(e,t,n)=>(n=e!=null?xl(wl(e)):{},Tl(t||!e||!e.__esModule?ei(n,"default",{value:e,enumerable:!0}):n,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react/jsx-runtime"),f=require("react"),ee=require("lucide-react"),jl=require("@ai-sdk/react"),ti=require("ai"),So=require("@radix-ui/react-slot"),To=require("class-variance-authority"),Pl=require("clsx"),Al=require("tailwind-merge"),Ml=require("@radix-ui/react-tooltip"),ni=require("@radix-ui/react-use-controllable-state"),El=require("@radix-ui/react-collapsible"),kl=require("react-dom"),Nl=require("@radix-ui/react-dialog"),Rl=require("./server.cjs");function ps(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const s=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,s.get?s:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const We=ps(f),Kt=ps(Ml),mr=ps(El),Dt=ps(Nl),$e=Symbol.for("@arcteninc/core:originalName");function Dl(e,t){return e[$e]=t,e}function Vl(e,t,n,s){if(typeof e!="function")return null;const r=e[$e];if(r){const a=t[r];if(a&&!n.has(a.name))return{fn:e,meta:a}}const o=e.name;let i;if(o&&(i=t[o],i&&!n.has(i.name)))return e[$e]=i.name,{fn:e,meta:i};if(s&&s.length>0){for(const a of s)if(!n.has(a)&&(i=t[a],i))return e[$e]=i.name,{fn:e,meta:i}}else if(i=Object.values(t).find(l=>!n.has(l.name)),i)return e[$e]=i.name,{fn:e,meta:i};return null}function pr(e,t){if(!t)return[];let n,s;if("functions"in t&&typeof t.functions=="object"){const o=t;n=o.functions,s=o.toolOrder}else n=t,s=void 0;const r=new Set;return e.map(o=>{const i=Vl(o,n,r,s);if(!i){const a=o.name,u=o[$e]||a||"unnamed";return typeof process<"u"&&(process.env.NODE_ENV==="development"||process.env.NODE_ENV!=="production")&&typeof console<"u"&&console.warn&&console.warn(`⚠️ [@arcteninc/core] No metadata found for tool "${u}". This tool will be excluded.
|
|
2
|
+
To fix: Run "arcten-extract-types ." and ensure "${u}" is used in ArctenAgent/useAgent.`),null}return r.add(i.meta.name),{name:i.meta.name,description:i.meta.description,jsonSchema:i.meta.parameters}}).filter(o=>o!==null)}const Il={password:[/^password$/i,/^pwd$/i,/^pass$/i,/^newPassword$/i,/^oldPassword$/i,/^currentPassword$/i,/^confirmPassword$/i,/.*password.*/i],email:[/^email$/i,/^emailAddress$/i,/^mail$/i,/.*email.*/i],phone:[/^phone$/i,/^phoneNumber$/i,/^mobile$/i,/^cell$/i,/^cellPhone$/i,/^telephone$/i,/.*phone.*/i,/.*mobile.*/i],pin:[/^pin$/i,/^pinCode$/i,/^securityPin$/i,/^accessPin$/i,/.*pin$/i],ssn:[/^ssn$/i,/^socialSecurityNumber$/i,/^social$/i,/.*ssn.*/i,/.*social.*/i],creditCard:[/^creditCard$/i,/^cardNumber$/i,/^card$/i,/^ccNumber$/i,/^creditCardNumber$/i,/.*card.*/i,/^cvv$/i,/^cvc$/i,/^cvn$/i,/^securityCode$/i],text:[]};function Sn(e){for(const[t,n]of Object.entries(Il))if(t!=="text"){for(const s of n)if(s.test(e))return t}return null}function Ol(e,t){return{password:{title:"Password Required",description:"Please enter your password to continue",placeholder:"Enter password..."},email:{title:"Email Required",description:"Please enter your email address",placeholder:"Enter email address..."},phone:{title:"Phone Number Required",description:"Please enter your phone number",placeholder:"Enter phone number..."},pin:{title:"PIN Required",description:"Please enter your PIN",placeholder:"Enter PIN..."},ssn:{title:"Social Security Number Required",description:"Please enter your Social Security Number",placeholder:"XXX-XX-XXXX"},creditCard:{title:"Credit Card Required",description:"Please enter your credit card information",placeholder:"XXXX XXXX XXXX XXXX"},text:{title:"Secure Input Required",description:`Please enter your ${t}`,placeholder:`Enter ${t}...`}}[e]}function Ll(e,t,n){return t.length>0}function $l(e,t,n,s={}){const r=[];return Object.keys(s).forEach(i=>{const a=i in n,l=n[i];if(!a){const h=s[i];if(h!=null&&h!=="")return}const u=Fl(s[i]),d={name:i,type:Bl(l||Sn(i)||"text"),label:Co(i),placeholder:Ul(i,l),required:!0,value:u};d.type==="password"&&(d.validation=h=>h.length<8?"Password must be at least 8 characters":null),r.push(d)}),r.sort((i,a)=>{const l=i.name in n,u=a.name in n;return l===u?0:l?1:-1}),{shouldUseForm:Ll(e,t),fields:r,title:zl(e),description:_l(e,r.length)}}function Fl(e){if(e!=null){if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return String(e)}}function Bl(e){switch(e){case"password":return"password";case"email":return"email";case"phone":return"phone";case"pin":return"pin";case"ssn":return"ssn";case"creditCard":return"creditCard";default:return"text"}}function Co(e){return e.replace(/([A-Z])/g," $1").replace(/_/g," ").trim().toLowerCase().split(" ").map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" ")}function Ul(e,t){return t?Ol(t,e).placeholder:`Enter ${Co(e).toLowerCase()}...`}function zl(e){return e.replace(/([A-Z])/g," $1").trim().toLowerCase().split(" ").map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" ")}function _l(e,t){const n=e.toLowerCase();return t<=2?`Please provide the required information to ${n}.`:`Please fill out the form below to ${n}. Required fields are marked with *.`}function Cn(e){if(typeof e=="string")try{const t=JSON.parse(e);return Cn(t)}catch{return e}if(Array.isArray(e))return e.map(Cn);if(e&&typeof e=="object"){const t={};for(const[n,s]of Object.entries(e))t[n]=Cn(s);return t}return e}function Xl(e,t){if(!t||Object.keys(t).length===0)return e;const n={...e};return Object.keys(t).forEach(s=>{s in n&&delete n[s]}),n}function Wl(e){if(typeof e=="string"){try{const t=JSON.parse(e);if(t&&typeof t=="object"&&!Array.isArray(t))return Cn(t)}catch{}return{}}return e&&typeof e=="object"&&!Array.isArray(e)?Cn(e):{}}const ss="__secureOutput",rs="[hidden for privacy]";function ql(e,t){if(!e||e.length===0)return t;const n=new Map;t.forEach(o=>{const i=o[$e]||o.name;i&&n.set(i,o)});const s=new Map(e.map(o=>[o.name,o])),r=[];return e.forEach(o=>{const i=n.get(o.name);if(!i){console.log(`[useAgent] Skipping server-only tool: ${o.name}`);return}if(!o.isEnabled&&!o.isOverridable){console.log(`[useAgent] Blocking non-overridable disabled tool: ${o.name}`);return}if(!o.isEnabled&&o.isOverridable&&i){console.log(`[useAgent] Allowing overridable disabled tool with local implementation: ${o.name}`),r.push(i);return}o.isEnabled&&i&&r.push(i)}),t.forEach(o=>{const i=o[$e]||o.name;i&&!s.has(i)&&(console.log(`[useAgent] Allowing client-only tool (forward compatible): ${i}`),r.push(o))}),r}function Kl(e){if(typeof globalThis.structuredClone=="function")return globalThis.structuredClone(e);try{return JSON.parse(JSON.stringify(e))}catch(t){return console.warn("[useAgent] Failed to clone value for redaction:",t),e}}function Gl(e){return e.replace(/\[(\w+)\]/g,".$1").split(".").map(t=>t.trim()).filter(Boolean)}function Yl(e,t){if(t.length===0)return e;if(!e||typeof e!="object")return;let n=e;for(const s of t){if(!n||typeof n!="object")return;n=n[s]}return n}function Hl(e,t,n){if(!e||typeof e!="object"||t.length===0)return!1;let s=e;for(let o=0;o<t.length-1;o++){if(!s||typeof s!="object")return!1;const i=s,a=t[o];if(a===void 0)return!1;const l=i[a];if(l==null||typeof l!="object")return!1;s=l}if(!s)return!1;const r=t[t.length-1];return!r||!(r in s)?!1:(s[r]=n,!0)}function Xs(e){return e==null?!1:typeof e=="string"?e.trim().length>0:Array.isArray(e)?e.length>0:typeof e=="object"?Object.keys(e).length>0:!0}function jo(e,t=""){const n={};return e&&typeof e=="object"?Object.entries(e).forEach(([s,r])=>{const o=t?`${t}.${s}`:s;n[o]=Xs(r),r&&typeof r=="object"&&Object.assign(n,jo(r,o))}):t&&(n[t]=Xs(e)),n}function Jl(e){if(e===void 0||e===!1)return;if(e===!0)return{strategy:"full",fields:[],placeholder:rs,includeFieldStatus:!1,preserve:[]};if(Array.isArray(e))return{strategy:"fields",fields:e,placeholder:rs,includeFieldStatus:!1,preserve:[]};const t=e.strategy??(e.fields&&e.fields.length>0?"fields":"full");return{strategy:t,fields:t==="fields"?e.fields??[]:[],placeholder:e.placeholder??rs,includeFieldStatus:e.includeFieldStatus??!1,preserve:e.preserve??[]}}function Zl(e){if(!e)return{};const t={};for(const[n,s]of Object.entries(e)){const r=Jl(s);r&&(t[n]=r)}return t}function Po(e,t,n){const s=n.placeholder,r={tool:e,redacted:!0,strategy:n.strategy,placeholder:s};if(n.strategy==="full"){n.includeFieldStatus&&typeof t=="object"&&t!==null&&(r.fieldStatus=jo(t)),r.redactedFields=["*"];let l={};return n.preserve.length>0&&t&&typeof t=="object"&&n.preserve.forEach(u=>{u in t&&(l[u]=t[u])}),l[ss]=r,l}if(n.fields.includes("*"))return Po(e,t,{...n,strategy:"full",fields:[]});if(typeof t!="object"||t===null)return{value:s,[ss]:{...r,redactedFields:n.fields}};const o=Kl(t),i=[],a={};return n.fields.forEach(l=>{const u=Gl(l);if(u.length===0)return;const d=Yl(o,u),h=Xs(d);a[l]=h,Hl(o,u,s)&&i.push(l)}),r.redactedFields=i,n.includeFieldStatus&&(r.fieldStatus=a),o[ss]=r,o}function Ao({apiBaseUrl:e="https://api.arcten.com",tokenEndpoint:t="/api/arcten/token",clientToken:n,skipTokenFetch:s=!1,user:r,tools:o=[],safeTools:i=[],safeToolNames:a,toolMetadata:l,sensitiveParams:u,sensitiveOutputs:d,autoDetectSensitive:h=!1,autoFormGeneration:m=!1,formMode:p="auto",systemPrompt:T="",agentId:v,agentName:C,projectId:b,enableRemoteConfig:E,remoteConfigUrl:M,initialMessages:$=[],conversationId:R,state:I,onStateChange:N,allowStateEdits:j=!0,onToolCall:O,onFinish:A,sources:k,ragConfig:F,ragFilters:D,secureInputHandler:B}={}){const X=e.replace(/\/+$/,""),[Y,K]=f.useState(null),[ie,ge]=f.useState(!1),[Ke,bt]=f.useState(null),tt=f.useMemo(()=>{const g=k||[],y=Y?.config?.sources||[];return[...new Set([...g,...y])]},[k,Y]),G=f.useMemo(()=>F!==void 0?F:D?{enabled:!0,filters:D}:tt&&tt.length>0?{enabled:!0,organizationId:tt[0],autoExecute:!0,filters:void 0}:{enabled:!1},[tt,F,D]),Vt=f.useMemo(()=>E===!1?!1:!!b,[b,E]);f.useEffect(()=>{if(!Vt||!oe.current)return;(async()=>{ge(!0),bt(null);try{const x=`${M||X.replace("/chat","").replace(/\/$/,"")}/convex/api/query`,w=await fetch(x,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${oe.current}`},body:JSON.stringify({path:"agents:getConfigForClient",args:{projectId:b,agentName:C,agentId:v},format:"json"})});if(!w.ok){if(w.status===404){console.warn("[useAgent] Remote config endpoint not found (404), using local tools only"),K(null);return}const V=await w.text().catch(()=>"Unknown error");throw new Error(`Failed to fetch remote config: ${w.status} ${V}`)}const P=await w.json();K(P?.value||null),console.log("[useAgent] Remote config loaded successfully:",P?.value)}catch(y){console.error("[useAgent] Failed to fetch remote config:",y);const x=y instanceof Error?y:new Error(String(y));bt(x),K(null)}finally{ge(!1)}})()},[Vt,b,C,v,X,M]);const Me=f.useMemo(()=>{const g={};if(u)for(const[y,x]of Object.entries(u))if(g[y]={},Array.isArray(x))for(const w of x){const P=Sn(w);g[y][w]=P||"text"}else for(const[w,P]of Object.entries(x))g[y][w]=P;if(l){for(const[y,x]of Object.entries(l))if(x&&typeof x=="object"&&"sensitiveParams"in x){g[y]||(g[y]={});const w=x.sensitiveParams;if(Array.isArray(w))for(const P of w){const V=Sn(P);g[y][P]=V||"text"}else if(w&&typeof w=="object")for(const[P,V]of Object.entries(w))g[y][P]=V}}return g},[u,l,h]),vt=f.useMemo(()=>Zl(d),[d]),Ce=f.useCallback((g,y)=>{const x=vt[g];if(!x)return y;try{return Po(g,y,x)}catch(w){return console.error(`[useAgent] Failed to redact output for ${g}:`,w),{value:rs,[ss]:{tool:g,redacted:!0,error:String(w)}}}},[vt]),[Ue,cn]=f.useState(n||null),oe=f.useRef(n||null),[un,wt]=f.useState(null),[dn,Bn]=f.useState(null),ze=f.useRef(null),[St,Tt]=f.useState([]),[Re,hn]=f.useState(R||(typeof window<"u"?crypto.randomUUID():null)),[vs,It]=f.useState(!1),fn=f.useRef(new Set),[Ot,nt]=f.useState(new Map),[ws,Un]=f.useState(new Map),[st,zn]=f.useState(new Map),[_n,Lt]=f.useState(new Map),ce=I!==void 0,[$t,ct]=f.useState({}),ye=f.useRef({}),mn=ce?I||{}:$t;ce&&I?ye.current=I:ce||(ye.current=$t);const[Ge,Ve]=f.useState(!1),[pn,Ye]=f.useState(null),Ct=f.useRef(!1),Xn=f.useCallback(async(g,y=3)=>{if(!Re||!oe.current)return;const x=async()=>{const P=`${X.replace("/chat","").replace(/\/$/,"")}/convex/api/mutation`,V=await fetch(P,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${oe.current}`},body:JSON.stringify({path:"conversations:mergeStateByChatId",args:{chatId:Re,updates:g},format:"json"})});if(!V.ok){if(V.status===404){console.warn("[useAgent] Convex API endpoint not available (404), state changes will not be persisted");return}const L=await V.text().catch(()=>"Unknown error");throw new Error(`Failed to sync conversation state: ${V.status} ${L}`)}};for(let w=0;w<y;w++)try{await x(),Ye(null);return}catch(P){if(w===y-1){const L=P instanceof Error?P:new Error(String(P));throw Ye(L),console.error("Failed to sync state to Convex after retries:",P),L}await new Promise(L=>setTimeout(L,Math.pow(2,w)*100))}},[Re,X,oe]),je=f.useMemo(()=>function(){return ye.current},[]),ut=f.useMemo(()=>async function(y){const x={...ye.current,...y};ye.current=x,ce||ct(x),N&&N(x);try{await Xn(y)}catch(w){throw w}},[Xn,N,ce]);f.useEffect(()=>{ce&&I&&(ye.current=I)},[ce,I]);const De=f.useCallback(g=>B?B.showSecureModal(g):new Promise(y=>{nt(x=>new Map(x).set(g.id,g)),Un(x=>new Map(x).set(g.id,y))}),[B]),Wn=f.useCallback((g,y)=>{if(B)return;const x=ws.get(g);x&&(x(y),nt(w=>{const P=new Map(w);return P.delete(g),P}),Un(w=>{const P=new Map(w);return P.delete(g),P}))},[ws,B]),Ft=f.useCallback(g=>B?B.showSecureForm(g):new Promise(y=>{zn(x=>new Map(x).set(g.id,g)),Lt(x=>new Map(x).set(g.id,y))}),[B]),rt=f.useCallback((g,y)=>{if(B)return;const x=_n.get(g);x&&(x(y),zn(w=>{const P=new Map(w);return P.delete(g),P}),Lt(w=>{const P=new Map(w);return P.delete(g),P}))},[_n,B]),qn=f.useCallback((g,y)=>{const x=Me[g]||{},w=Object.keys(x).length>0;if(h){const P=Object.keys(y).filter(V=>Sn(V)!==null);return w||P.length>0}return w},[Me,h]),Kn=f.useCallback((g,y)=>{const w={...Me[g]||{}};if(h){for(const V of Object.keys(y))if(!(V in w)){const L=Sn(V);L&&(w[V]=L)}}const P=Object.entries(w).filter(([V])=>Object.prototype.hasOwnProperty.call(y,V));return P.length>0?Object.fromEntries(P):w},[Me,h]),He=f.useMemo(()=>G?.enabled?async function(y,x=20,w){const P={...G.filters,...w};if(k&&k.length>1){const L=k.map(q=>fetch(`${X}/search`,{method:"POST",headers:{"Content-Type":"application/json",...oe.current?{Authorization:`Bearer ${oe.current}`}:{}},body:JSON.stringify({q:y,k:Math.min(x,100),organizationId:q,...Object.keys(P).length>0?{filters:P}:{}})}).then(re=>re.ok?re.json():null)),ae=await Promise.all(L),Q=[];for(const q of ae)q?.candidates&&Q.push(...q.candidates);Q.sort((q,re)=>{const Qe=q.scores?.rerank||q.scores?.dense||0;return(re.scores?.rerank||re.scores?.dense||0)-Qe});const xe=Q.slice(0,x).map((q,re)=>{const Qe=q.citation||q.url;return{rank:re+1,doc_id:q.doc_id,block_id:q.block_id,url:q.url,citation:Qe,title:q.title||"Untitled",snippet:q.snippet,score:q.scores?.rerank||q.scores?.dense||0,metadata:{site:q.metadata?.site,lang:q.metadata?.lang,contentType:q.metadata?.content_type}}});return{success:!0,query:y,total:Q.length,results:xe,summary:`Found ${Q.length} relevant results across ${k.length} source(s) for "${y}". Top result: ${xe[0]?.title||"N/A"}`}}const V=G.organizationId&&G.organizationId!=="default"?G.organizationId:k&&k.length>0?k[0]:void 0;try{const L={q:y,k:Math.min(x,100)};V&&(L.organizationId=V),Object.keys(P).length>0&&(L.filters=P);const ae={"Content-Type":"application/json"};oe.current&&(ae.Authorization=`Bearer ${oe.current}`);const Q=await fetch(`${X}/search`,{method:"POST",headers:ae,body:JSON.stringify(L)});if(!Q.ok){const re=await Q.text();return{success:!1,error:`Search failed: ${Q.status} ${re}`}}const xe=await Q.json(),q=xe.candidates.map((re,Qe)=>{const vn=re.citation||re.url;return{rank:Qe+1,doc_id:re.doc_id,block_id:re.block_id,url:re.url,citation:vn,title:re.title||"Untitled",snippet:re.snippet,score:re.scores?.rerank||re.scores?.dense||0,metadata:{site:re.metadata?.site,lang:re.metadata?.lang,contentType:re.metadata?.content_type}}});return{success:!0,query:xe.query,total:xe.total,results:q,summary:`Found ${xe.total} relevant results for "${y}". Top result: ${q[0]?.title||"N/A"}`}}catch(L){return{success:!1,error:L instanceof Error?L.message:"Unknown error occurred"}}}:null,[G,X,oe]),Je=f.useMemo(()=>G?.enabled?async function(y,x){const w=G.organizationId&&G.organizationId!=="default"?G.organizationId:k&&k.length>0?k[0]:void 0;try{const P={"Content-Type":"application/json"};oe.current&&(P.Authorization=`Bearer ${oe.current}`);const V=await fetch(`${X}/fetch`,{method:"POST",headers:P,body:JSON.stringify({doc_id:y,block_ids:x,...w?{organizationId:w}:{}})});if(!V.ok){const ae=await V.text();return{success:!1,error:`Fetch failed: ${V.status} ${ae}`}}const L=await V.json();return{success:!0,blocks:L.blocks||[],fullContent:L.fullContent||"",pageUrl:L.pageUrl||"",pageTitle:L.pageTitle||"",summary:`Fetched ${L.blocks?.length||0} blocks from ${L.pageTitle||y}`}}catch(P){return{success:!1,error:P instanceof Error?P.message:"Unknown error occurred"}}}:null,[G,X,oe]),gn=f.useMemo(()=>{if(Y&&Y.config?.tools){const g=ql(Y.config.tools,o);return console.log("[useAgent] Merged remote config:",{remoteToolCount:Y.config.tools.length,localToolCount:o.length,mergedToolCount:g.length}),g}return o},[Y,o]),_e=Y?.enableStateTools??!0,Ze=Y?.enableRagTools??G?.enabled??!1,Gn=f.useMemo(()=>{const g=[...gn,...i];return _e&&(g.push(je),(!ce||j)&&g.push(ut)),Ze&&(He&&g.push(He),Je&&g.push(Je)),g},[gn,i,je,ut,He,Je,_e,Ze,ce,j]),Yn=f.useMemo(()=>[...gn,...i],[gn,i]),it=f.useMemo(()=>pr(Yn,l),[Yn,l]),jt=f.useMemo(()=>{const g=new Map,y=new Map(it.map(x=>[x.name,x]));return g.set("getState",je),(!ce||j)&&g.set("setState",ut),G?.enabled&&(He&&g.set("searchDocs",He),Je&&g.set("fetchDocContent",Je)),Gn.forEach(x=>{if(x===je||x===ut||x===He||x===Je)return;const w=x[$e];if(w){const V=y.get(w);if(V){g.set(V.name,x);return}}const P=it.find(V=>V.name===x.name);P&&g.set(P.name,x)}),g},[Gn,it,je,ut,He,Je,G,ce,j]),Hn=f.useMemo(()=>new Set(it.map(g=>g.name)),[it]),yn=f.useMemo(()=>{const g=[];_e&&(g.push({name:"getState",description:"Get the current agent state. Returns IDs, workflow state, checklists, and other persistent data.",jsonSchema:{type:"object",properties:{},required:[]}}),(!ce||j)&&g.push({name:"setState",description:"Update the agent state. Store IDs, workflow state, checklists, context, and other data that must persist across conversations. Merges with existing state.",jsonSchema:{type:"object",properties:{updates:{type:"object",description:"Partial state updates to merge with existing state"}},required:["updates"]}}));const y=[];Ze&&y.push({name:"searchDocs",description:"Search documentation using semantic search. Returns relevant results with snippets and scores. Use this first to find relevant documentation. Default returns 20 results - use higher k values (30-50) when you need to find many sources.",jsonSchema:{type:"object",properties:{query:{type:"string",description:"The search query (user's question or keywords)"},k:{type:"number",description:"Number of results to return (default: 20, max: 100). Use 20-30 for comprehensive searches, or higher (50-100) when you need to find all relevant sources.",default:20},filters:{type:"object",description:"Optional filters to scope the search",properties:{site:{type:"string"},lang:{type:"string"},tags:{type:"array",items:{type:"string"}},docIds:{type:"array",items:{type:"string"}},pageIds:{type:"array",items:{type:"string"}}}}},required:["query"]}},{name:"fetchDocContent",description:"Fetch full content of documentation blocks after searching. Use this AFTER searchDocs when you find relevant results (scores > 0.3) to get complete text. Automatically fetches nearby blocks (5 chunks before/after each requested block) for context. You can pass multiple block_ids to fetch comprehensive content from multiple blocks/pages.",jsonSchema:{type:"object",properties:{doc_id:{type:"string",description:"The doc_id from searchDocs results"},block_ids:{type:"array",items:{type:"string"},description:"Array of block_ids from searchDocs results. You can pass multiple block_ids to fetch comprehensive content."}},required:["doc_id","block_ids"]}});const x=[];return Y?.config?.workflows&&Y.config.workflows.forEach(w=>{const P={},V=[];w.parameters&&w.parameters.forEach(L=>{P[L.name]={type:L.type||"string",description:L.description},L.required&&V.push(L.name)}),x.push({name:`workflow_${w.name.replace(/\s+/g,"_").toLowerCase()}`,description:w.description||`Execute the "${w.name}" workflow. ${w.contentPlaintext?.slice(0,200)||""}`,jsonSchema:{type:"object",properties:P,required:V},_workflow:w})}),[...it,...g,...y,...x]},[it,_e,Ze,ce,j,Y]),dt=f.useMemo(()=>yn.filter(g=>g.name==="getState"?_e:g.name==="setState"?_e&&(!ce||j):g.name==="searchDocs"||g.name==="fetchDocContent"?Ze:g.name.startsWith("workflow_")?!0:Hn.has(g.name)),[yn,Hn,_e,Ze,ce,j]),Bt=f.useMemo(()=>{const g=new Set;return _e&&(g.add("getState"),g.add("setState")),Ze&&G?.autoExecute!==!1&&(g.add("searchDocs"),g.add("fetchDocContent")),Y?.config?.tools?Y.config.tools.forEach(y=>{y.isEnabled&&!y.requiresApproval&&g.add(y.name)}):(i.forEach(y=>{for(const[x,w]of jt.entries())if(w===y){g.add(x);break}}),a&&Array.isArray(a)&&a.forEach(y=>{typeof y=="string"&&g.add(y)})),Y?.config?.workflows&&Y.config.workflows.forEach(y=>{const x=`workflow_${y.name.replace(/\s+/g,"_").toLowerCase()}`;y.requiresApproval||g.add(x)}),g},[Y,i,a,jt,_e,Ze,G]);f.useEffect(()=>s||n?void 0:((async()=>{try{const y=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:r})});if(!y.ok)throw new Error("Failed to fetch token");const x=await y.json();cn(x.clientToken),oe.current=x.clientToken,Bn(x.expiresAt),wt(null)}catch(y){console.error("[useAgent] Token fetch failed:",y),wt(y instanceof Error?y.message:"Failed to fetch token")}})(),()=>{ze.current&&clearTimeout(ze.current)}),[t,JSON.stringify(r),s,n]),f.useEffect(()=>{if(!dn||s||n)return;ze.current&&clearTimeout(ze.current);const g=Math.floor(Date.now()/1e3),y=dn-g,w=Math.max(0,y-5);return ze.current=setTimeout(async()=>{try{const P=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:r})});if(!P.ok)throw new Error("Failed to refresh token");const V=await P.json();cn(V.clientToken),oe.current=V.clientToken,Bn(V.expiresAt),wt(null)}catch(P){console.error("[useAgent] Token refresh failed:",P),wt(P instanceof Error?P.message:"Failed to refresh token")}},w*1e3),()=>{ze.current&&clearTimeout(ze.current)}},[dn,t,JSON.stringify(r),s,n]);const Ss=async(g,y={})=>{const x=y.headers?new Headers(y.headers):new Headers;x.delete("user-agent"),x.delete("User-Agent"),console.log("[useAgent] Making request to:",g),console.log("[useAgent] Method:",y.method||"GET"),console.log("[useAgent] Has Authorization header:",x.has("Authorization")),console.log("[useAgent] Client token available:",!!oe.current);try{const w=await fetch(g,{...y,headers:x});if(!w.ok){console.error("[useAgent] Request failed:",w.status,w.statusText);const P=await w.text().catch(()=>"Unable to read error response");console.error("[useAgent] Error response:",P)}return w}catch(w){throw console.error("[useAgent] Fetch error:",w),w}},xn=f.useRef(0),bn=f.useRef(-1),Jn=`${X}/chat`;console.log("[useAgent] Chat API URL:",Jn);const{messages:S,sendMessage:W,status:_,error:J,stop:H,addToolResult:Z,setMessages:Ee}=jl.useChat({id:Re||void 0,messages:$,transport:new ti.DefaultChatTransport({api:Jn,fetch:Ss,headers:()=>{const g={};return oe.current?(g.Authorization=`Bearer ${oe.current}`,console.log("[useAgent] Adding Authorization header with token")):console.warn("[useAgent] No client token available - request may fail"),g},body:()=>{console.log("[ArctenAgent] body() agentName =",C);const g=dt.map(w=>({name:w.name,description:w.description,inputSchema:w.jsonSchema})),y=g.filter(w=>w.name==="getState"||w.name==="setState").map(w=>w.name),x=g.filter(w=>w.name==="searchDocs"||w.name==="fetchDocContent").map(w=>w.name);return y.length>0&&console.log("[useAgent] State tools included in tools list sent to AI SDK:",y),x.length>0?console.log("[useAgent] RAG tools included in tools list sent to AI SDK:",x):G?.enabled&&console.warn("[useAgent] RAG is enabled but no RAG tools found in tools list!"),{tools:g,...v&&{agentId:v},...C&&{agentName:C},state:ye.current,...D&&{ragFilters:D}}}}),sendAutomaticallyWhen:g=>{const y=g.messages;if(y[y.length-1]?.role==="user"||bn.current===xn.current)return!1;const w=ti.lastAssistantMessageIsCompleteWithToolCalls(g);return w&&(bn.current=xn.current),w}}),se=W,we=f.useCallback(g=>(xn.current+=1,se(g)),[se]),U=f.useCallback((g,y,x)=>{const w=Ce(g,x);Z({toolCallId:y,tool:g,output:w})},[Z,Ce]);f.useEffect(()=>{S.forEach(g=>{g.role==="assistant"&&g.parts.forEach(y=>{if(!y.type?.startsWith("tool-")||y.state!=="input-available")return;const x=y.type.replace("tool-",""),w=y.toolCallId;if(fn.current.has(w))return;fn.current.add(w);const P=Wl(y.input);if(qn(x,P)){const V=Kn(x,P),L=Object.entries(V).filter(([q])=>P[q]!==void 0),ae=L.length>0?Object.fromEntries(L):V,Q=Object.keys(P),xe=Xl(P,ae);(async()=>{try{const q=$l(x,Q,ae,P),re={id:`${w}-form`,toolName:x,toolCallId:w,title:q.title,description:q.description,fields:q.fields},Qe=await Ft(re);if(Qe===null){U(x,w,"User cancelled secure input");return}const vn={...xe,...Qe},Ts=jt.get(x);if(!Ts)throw new Error(`Tool ${x} not found`);let Cs;const js=dt.find(Qr=>Qr.name===x);if(js&&js.jsonSchema?.properties){const gl=Object.keys(js.jsonSchema.properties).map(yl=>vn[yl]);Cs=await Ts(...gl)}else Cs=await Ts(...Object.values(vn));U(x,w,Cs)}catch(q){console.error(`[useAgent] Error executing tool with secure input ${x}:`,q),U(x,w,`Error: ${q}`)}})();return}if(x.startsWith("workflow_")&&Bt.has(x)){(async()=>{try{const L=dt.find(Q=>Q.name===x)?._workflow;if(!L)throw new Error(`Workflow metadata not found for ${x}`);let ae;if(L.webhook?.url){let Q=P;if(L.webhook.bodyTemplate){let q=L.webhook.bodyTemplate;Object.entries(P).forEach(([re,Qe])=>{q=q.replace(new RegExp(`\\{\\{${re}\\}\\}`,"g"),String(Qe))}),Q=JSON.parse(q)}const xe=await fetch(L.webhook.url,{method:L.webhook.method||"POST",headers:{"Content-Type":"application/json",...L.webhook.headers||{}},body:JSON.stringify(Q)});if(xe.ok)ae={success:!0,data:await xe.json().catch(()=>({success:!0}))};else{const q=await xe.text();ae={success:!1,error:`Webhook failed: ${xe.status} ${q}`}}}else ae={success:!0,message:`Workflow "${L.name}" acknowledged. Follow the workflow instructions to proceed.`,instructions:L.contentPlaintext};U(x,w,ae)}catch(V){console.error(`[useAgent] Error executing workflow ${x}:`,V),U(x,w,`Error: ${V}`)}})();return}if(Bt.has(x)&&!qn(x,P)){const V=jt.get(x);V?(async()=>{try{const L=dt.find(Q=>Q.name===x);let ae;if(L&&L.jsonSchema?.properties){const xe=Object.keys(L.jsonSchema.properties).map(q=>P[q]);ae=await V(...xe)}else if(x==="getState")ae=V();else if(x==="setState"){const Q=P.updates||P;ae=await V(Q)}else ae=await V(...Object.values(P));U(x,w,ae)}catch(L){console.error(`[useAgent] Error executing tool ${x}:`,L),U(x,w,`Error: ${L}`)}})():console.warn(`[useAgent] Tool ${x} not found in toolsMap`)}else x.startsWith("workflow_")&&O?O({toolCall:{toolCallId:w,toolName:x,args:P}}):O&&O({toolCall:{toolCallId:w,toolName:x,args:P}})})})},[S,Bt,jt,O,U,ut,dt,qn,Kn,De]),f.useEffect(()=>{if(_==="ready"&&S.length>0&&A){const g=S[S.length-1];g&&g.role==="assistant"&&A({message:g,messages:S,isAbort:!1,isDisconnect:!1,isError:!!J})}},[_,S,J,A]);async function fe(){if(!(!r?.id||!Ue)){It(!0);try{const y=await(await fetch(`${X}/conversations`,{headers:{Authorization:`Bearer ${Ue}`}})).json();Tt(y.conversations||[])}catch(g){console.error("Failed to fetch conversations:",g)}finally{It(!1)}}}f.useEffect(()=>{r?.id&&Ue&&fe()},[JSON.stringify(r),Ue,X]),f.useEffect(()=>{if(!Re||!oe.current)return;(async()=>{Ve(!0),Ye(null);try{const y=await fetch(`${X.replace("/chat","")}/convex/api/query`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${oe.current}`},body:JSON.stringify({path:"conversations:getStateByChatId",args:{chatId:Re},format:"json"})});if(!y.ok){const P=await y.text().catch(()=>"Unknown error");throw new Error(`Failed to fetch conversation state: ${y.status} ${P}`)}const w=(await y.json())?.value||{};ye.current=w,ce||ct(w),N&&N(w),Ct.current=!0}catch(y){console.error("Failed to fetch state:",y);const x=y instanceof Error?y:new Error(String(y));Ye(x),Ct.current||(ye.current={},ce?N&&N({}):(ct({}),N&&N({})),Ct.current=!0)}finally{Ve(!1)}})()},[Re,X,ce,N]);async function te(g){hn(g),It(!0);try{const y=await fetch(`${X}/conversations/${g}/messages`,{headers:{Authorization:`Bearer ${oe.current}`}});if(!y.ok)throw new Error(`Failed to fetch messages: ${y.statusText}`);const w=(await y.json()).messages||[];Ee(w)}catch(y){console.error("Failed to load conversation messages:",y)}finally{It(!1)}}async function Pe(g){if(Ue)try{await fetch(`${X}/conversations/${g}`,{method:"DELETE",headers:{Authorization:`Bearer ${Ue}`}}),Tt(St.filter(y=>y._id!==g)),g===Re&&he()}catch(y){console.error("Failed to delete conversation:",y)}}function he(){const g=crypto.randomUUID();hn(g),Ee([]),fn.current=new Set,ye.current={},ce?N&&N({}):(ct({}),N&&N({})),Ct.current=!1}function Ie(g){const y=g.tool||"unknown-tool",x=Ce(y,g.output);Z({toolCallId:g.toolCallId,tool:y,output:x})}async function be(g,y,x){if(!y.startsWith("workflow_"))throw new Error(`${y} is not a workflow tool`);try{const P=dt.find(L=>L.name===y)?._workflow;if(!P)throw new Error(`Workflow metadata not found for ${y}`);let V;if(P.webhook?.url){let L=x;if(P.webhook.bodyTemplate){let Q=P.webhook.bodyTemplate;Object.entries(x).forEach(([xe,q])=>{Q=Q.replace(new RegExp(`\\{\\{${xe}\\}\\}`,"g"),String(q))}),L=JSON.parse(Q)}const ae=await fetch(P.webhook.url,{method:P.webhook.method||"POST",headers:{"Content-Type":"application/json",...P.webhook.headers||{}},body:JSON.stringify(L)});if(ae.ok)V={success:!0,data:await ae.json().catch(()=>({success:!0}))};else{const Q=await ae.text();V={success:!1,error:`Webhook failed: ${ae.status} ${Q}`}}}else V={success:!0,message:`Workflow "${P.name}" acknowledged. Follow the workflow instructions to proceed.`,instructions:P.contentPlaintext};return Ie({toolCallId:g,tool:y,output:V}),V}catch(w){const P={success:!1,error:String(w)};throw Ie({toolCallId:g,tool:y,output:P}),w}}async function ke(g){const y={...ye.current,...g};ye.current=y,ce||ct(y),N&&N(y);try{await Xn(g)}catch(x){throw x}}return{id:Re,messages:S,status:_,error:J,sendMessage:we,stop:H,addToolOutput:Ie,executeWorkflowTool:be,setMessages:Ee,conversations:St,loadConversation:te,deleteConversation:Pe,startNewConversation:he,isLoadingConversations:vs,clientToken:Ue,tokenError:un,state:mn,setState:ke,isStateLoading:Ge,stateError:pn,pendingSecureInputs:Array.from(Ot.values()),completeSecureInput:Wn,pendingSecureForms:Array.from(st.values()),completeSecureForm:rt,safeToolNames:Bt}}function ne(...e){return Al.twMerge(Pl.clsx(e))}const At=To.cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive active:scale-95",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9","icon-sm":"size-8","icon-lg":"size-10"}},defaultVariants:{variant:"default",size:"default"}}),Te=We.forwardRef(({className:e,variant:t,size:n,asChild:s=!1,...r},o)=>{const i=s?So.Slot:"button";return c.jsx(i,{ref:o,"data-slot":"button",className:ne(At({variant:t,size:n,className:e})),...r})});Te.displayName="Button";const Ql=To.cva("inline-flex items-center justify-center rounded-full border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",destructive:"border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground"}},defaultVariants:{variant:"default"}});function Ps({className:e,variant:t,asChild:n=!1,...s}){const r=n?So.Slot:"span";return c.jsx(r,{"data-slot":"badge",className:ne(Ql({variant:t}),e),...s})}const ec=({textAreaRef:e,triggerAutoSize:t,maxHeight:n=Number.MAX_SAFE_INTEGER,minHeight:s=0})=>{const[r,o]=We.useState(!0);We.useEffect(()=>{const a=e.current;if(a){r&&(a.style.minHeight=`${s+6}px`,n>s&&(a.style.maxHeight=`${n}px`),o(!1)),a.style.height=`${s+6}px`;const l=a.scrollHeight;l>n?a.style.height=`${n}px`:a.style.height=`${l+6}px`}},[e.current,t])},Mo=We.forwardRef(({maxHeight:e=Number.MAX_SAFE_INTEGER,minHeight:t=52,className:n,onChange:s,value:r,...o},i)=>{const a=We.useRef(null),[l,u]=We.useState("");return ec({textAreaRef:a,triggerAutoSize:l,maxHeight:e,minHeight:t}),f.useImperativeHandle(i,()=>({textArea:a.current,focus:()=>a?.current?.focus(),maxHeight:e,minHeight:t})),We.useEffect(()=>{u(r)},[o?.defaultValue,r]),c.jsx("textarea",{...o,value:r,ref:a,className:ne("flex w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",n),onChange:d=>{u(d.target.value),s?.(d)}})});Mo.displayName="AutosizeTextarea";function tc({delayDuration:e=0,...t}){return c.jsx(Kt.Provider,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function ht({...e}){return c.jsx(tc,{children:c.jsx(Kt.Root,{"data-slot":"tooltip",...e})})}function ft({...e}){return c.jsx(Kt.Trigger,{"data-slot":"tooltip-trigger",...e})}function mt({className:e,sideOffset:t=0,children:n,...s}){return c.jsx(Kt.Portal,{children:c.jsxs(Kt.Content,{"data-slot":"tooltip-content",sideOffset:t,className:ne("bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",e),...s,children:[n,c.jsx(Kt.Arrow,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}function si({className:e,...t}){return c.jsx("kbd",{"data-slot":"kbd",className:ne("bg-muted text-muted-foreground pointer-events-none inline-flex h-5 w-fit min-w-5 items-center justify-center gap-1 rounded-sm px-1 font-sans text-xs font-medium select-none","[&_svg:not([class*='size-'])]:size-3","[[data-slot=tooltip-content]_&]:bg-background/20 [[data-slot=tooltip-content]_&]:text-background dark:[[data-slot=tooltip-content]_&]:bg-background/10",e),...t})}const gr=f.createContext({});function yr(e){const t=f.useRef(null);return t.current===null&&(t.current=e()),t.current}const xr=typeof window<"u",Eo=xr?f.useLayoutEffect:f.useEffect,gs=f.createContext(null);function br(e,t){e.indexOf(t)===-1&&e.push(t)}function vr(e,t){const n=e.indexOf(t);n>-1&&e.splice(n,1)}const ot=(e,t,n)=>n>t?t:n<e?e:n;function Ws(e,t){return t?`${e}. For more information and steps for solving, visit https://motion.dev/troubleshooting/${t}`:e}let Jt=()=>{},at=()=>{};process.env.NODE_ENV!=="production"&&(Jt=(e,t,n)=>{!e&&typeof console<"u"&&console.warn(Ws(t,n))},at=(e,t,n)=>{if(!e)throw new Error(Ws(t,n))});const lt={},ko=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e);function No(e){return typeof e=="object"&&e!==null}const Ro=e=>/^0[^.\s]+$/u.test(e);function wr(e){let t;return()=>(t===void 0&&(t=e()),t)}const Be=e=>e,nc=(e,t)=>n=>t(e(n)),On=(...e)=>e.reduce(nc),kn=(e,t,n)=>{const s=t-e;return s===0?1:(n-e)/s};class Sr{constructor(){this.subscriptions=[]}add(t){return br(this.subscriptions,t),()=>vr(this.subscriptions,t)}notify(t,n,s){const r=this.subscriptions.length;if(r)if(r===1)this.subscriptions[0](t,n,s);else for(let o=0;o<r;o++){const i=this.subscriptions[o];i&&i(t,n,s)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const qe=e=>e*1e3,Fe=e=>e/1e3;function Do(e,t){return t?e*(1e3/t):0}const ri=new Set;function Tr(e,t,n){e||ri.has(t)||(console.warn(Ws(t,n)),ri.add(t))}const Vo=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,sc=1e-7,rc=12;function ic(e,t,n,s,r){let o,i,a=0;do i=t+(n-t)/2,o=Vo(i,s,r)-e,o>0?n=i:t=i;while(Math.abs(o)>sc&&++a<rc);return i}function Ln(e,t,n,s){if(e===t&&n===s)return Be;const r=o=>ic(o,0,1,e,n);return o=>o===0||o===1?o:Vo(r(o),t,s)}const Io=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,Oo=e=>t=>1-e(1-t),Lo=Ln(.33,1.53,.69,.99),Cr=Oo(Lo),$o=Io(Cr),Fo=e=>(e*=2)<1?.5*Cr(e):.5*(2-Math.pow(2,-10*(e-1))),jr=e=>1-Math.sin(Math.acos(e)),Bo=Oo(jr),Uo=Io(jr),oc=Ln(.42,0,1,1),ac=Ln(0,0,.58,1),zo=Ln(.42,0,.58,1),lc=e=>Array.isArray(e)&&typeof e[0]!="number",_o=e=>Array.isArray(e)&&typeof e[0]=="number",ii={linear:Be,easeIn:oc,easeInOut:zo,easeOut:ac,circIn:jr,circInOut:Uo,circOut:Bo,backIn:Cr,backInOut:$o,backOut:Lo,anticipate:Fo},cc=e=>typeof e=="string",oi=e=>{if(_o(e)){at(e.length===4,"Cubic bezier arrays must contain four numerical values.","cubic-bezier-length");const[t,n,s,r]=e;return Ln(t,n,s,r)}else if(cc(e))return at(ii[e]!==void 0,`Invalid easing type '${e}'`,"invalid-easing-type"),ii[e];return e},Zn=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function uc(e,t){let n=new Set,s=new Set,r=!1,o=!1;const i=new WeakSet;let a={delta:0,timestamp:0,isProcessing:!1};function l(d){i.has(d)&&(u.schedule(d),e()),d(a)}const u={schedule:(d,h=!1,m=!1)=>{const T=m&&r?n:s;return h&&i.add(d),T.has(d)||T.add(d),d},cancel:d=>{s.delete(d),i.delete(d)},process:d=>{if(a=d,r){o=!0;return}r=!0,[n,s]=[s,n],n.forEach(l),n.clear(),r=!1,o&&(o=!1,u.process(d))}};return u}const dc=40;function Xo(e,t){let n=!1,s=!0;const r={delta:0,timestamp:0,isProcessing:!1},o=()=>n=!0,i=Zn.reduce((M,$)=>(M[$]=uc(o),M),{}),{setup:a,read:l,resolveKeyframes:u,preUpdate:d,update:h,preRender:m,render:p,postRender:T}=i,v=()=>{const M=lt.useManualTiming?r.timestamp:performance.now();n=!1,lt.useManualTiming||(r.delta=s?1e3/60:Math.max(Math.min(M-r.timestamp,dc),1)),r.timestamp=M,r.isProcessing=!0,a.process(r),l.process(r),u.process(r),d.process(r),h.process(r),m.process(r),p.process(r),T.process(r),r.isProcessing=!1,n&&t&&(s=!1,e(v))},C=()=>{n=!0,s=!0,r.isProcessing||e(v)};return{schedule:Zn.reduce((M,$)=>{const R=i[$];return M[$]=(I,N=!1,j=!1)=>(n||C(),R.schedule(I,N,j)),M},{}),cancel:M=>{for(let $=0;$<Zn.length;$++)i[Zn[$]].cancel(M)},state:r,steps:i}}const{schedule:le,cancel:gt,state:ve,steps:As}=Xo(typeof requestAnimationFrame<"u"?requestAnimationFrame:Be,!0);let is;function hc(){is=void 0}const Ne={now:()=>(is===void 0&&Ne.set(ve.isProcessing||lt.useManualTiming?ve.timestamp:performance.now()),is),set:e=>{is=e,queueMicrotask(hc)}},Wo=e=>t=>typeof t=="string"&&t.startsWith(e),Pr=Wo("--"),fc=Wo("var(--"),Ar=e=>fc(e)?mc.test(e.split("/*")[0].trim()):!1,mc=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu,Zt={test:e=>typeof e=="number",parse:parseFloat,transform:e=>e},Nn={...Zt,transform:e=>ot(0,1,e)},Qn={...Zt,default:1},jn=e=>Math.round(e*1e5)/1e5,Mr=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function pc(e){return e==null}const gc=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,Er=(e,t)=>n=>!!(typeof n=="string"&&gc.test(n)&&n.startsWith(e)||t&&!pc(n)&&Object.prototype.hasOwnProperty.call(n,t)),qo=(e,t,n)=>s=>{if(typeof s!="string")return s;const[r,o,i,a]=s.match(Mr);return{[e]:parseFloat(r),[t]:parseFloat(o),[n]:parseFloat(i),alpha:a!==void 0?parseFloat(a):1}},yc=e=>ot(0,255,e),Ms={...Zt,transform:e=>Math.round(yc(e))},Et={test:Er("rgb","red"),parse:qo("red","green","blue"),transform:({red:e,green:t,blue:n,alpha:s=1})=>"rgba("+Ms.transform(e)+", "+Ms.transform(t)+", "+Ms.transform(n)+", "+jn(Nn.transform(s))+")"};function xc(e){let t="",n="",s="",r="";return e.length>5?(t=e.substring(1,3),n=e.substring(3,5),s=e.substring(5,7),r=e.substring(7,9)):(t=e.substring(1,2),n=e.substring(2,3),s=e.substring(3,4),r=e.substring(4,5),t+=t,n+=n,s+=s,r+=r),{red:parseInt(t,16),green:parseInt(n,16),blue:parseInt(s,16),alpha:r?parseInt(r,16)/255:1}}const qs={test:Er("#"),parse:xc,transform:Et.transform},$n=e=>({test:t=>typeof t=="string"&&t.endsWith(e)&&t.split(" ").length===1,parse:parseFloat,transform:t=>`${t}${e}`}),pt=$n("deg"),et=$n("%"),z=$n("px"),bc=$n("vh"),vc=$n("vw"),ai={...et,parse:e=>et.parse(e)/100,transform:e=>et.transform(e*100)},Ut={test:Er("hsl","hue"),parse:qo("hue","saturation","lightness"),transform:({hue:e,saturation:t,lightness:n,alpha:s=1})=>"hsla("+Math.round(e)+", "+et.transform(jn(t))+", "+et.transform(jn(n))+", "+jn(Nn.transform(s))+")"},pe={test:e=>Et.test(e)||qs.test(e)||Ut.test(e),parse:e=>Et.test(e)?Et.parse(e):Ut.test(e)?Ut.parse(e):qs.parse(e),transform:e=>typeof e=="string"?e:e.hasOwnProperty("red")?Et.transform(e):Ut.transform(e),getAnimatableNone:e=>{const t=pe.parse(e);return t.alpha=0,pe.transform(t)}},wc=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function Sc(e){return isNaN(e)&&typeof e=="string"&&(e.match(Mr)?.length||0)+(e.match(wc)?.length||0)>0}const Ko="number",Go="color",Tc="var",Cc="var(",li="${}",jc=/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 Rn(e){const t=e.toString(),n=[],s={color:[],number:[],var:[]},r=[];let o=0;const a=t.replace(jc,l=>(pe.test(l)?(s.color.push(o),r.push(Go),n.push(pe.parse(l))):l.startsWith(Cc)?(s.var.push(o),r.push(Tc),n.push(l)):(s.number.push(o),r.push(Ko),n.push(parseFloat(l))),++o,li)).split(li);return{values:n,split:a,indexes:s,types:r}}function Yo(e){return Rn(e).values}function Ho(e){const{split:t,types:n}=Rn(e),s=t.length;return r=>{let o="";for(let i=0;i<s;i++)if(o+=t[i],r[i]!==void 0){const a=n[i];a===Ko?o+=jn(r[i]):a===Go?o+=pe.transform(r[i]):o+=r[i]}return o}}const Pc=e=>typeof e=="number"?0:pe.test(e)?pe.getAnimatableNone(e):e;function Ac(e){const t=Yo(e);return Ho(e)(t.map(Pc))}const yt={test:Sc,parse:Yo,createTransformer:Ho,getAnimatableNone:Ac};function Es(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e}function Mc({hue:e,saturation:t,lightness:n,alpha:s}){e/=360,t/=100,n/=100;let r=0,o=0,i=0;if(!t)r=o=i=n;else{const a=n<.5?n*(1+t):n+t-n*t,l=2*n-a;r=Es(l,a,e+1/3),o=Es(l,a,e),i=Es(l,a,e-1/3)}return{red:Math.round(r*255),green:Math.round(o*255),blue:Math.round(i*255),alpha:s}}function us(e,t){return n=>n>0?t:e}const de=(e,t,n)=>e+(t-e)*n,ks=(e,t,n)=>{const s=e*e,r=n*(t*t-s)+s;return r<0?0:Math.sqrt(r)},Ec=[qs,Et,Ut],kc=e=>Ec.find(t=>t.test(e));function ci(e){const t=kc(e);if(Jt(!!t,`'${e}' is not an animatable color. Use the equivalent color code instead.`,"color-not-animatable"),!t)return!1;let n=t.parse(e);return t===Ut&&(n=Mc(n)),n}const ui=(e,t)=>{const n=ci(e),s=ci(t);if(!n||!s)return us(e,t);const r={...n};return o=>(r.red=ks(n.red,s.red,o),r.green=ks(n.green,s.green,o),r.blue=ks(n.blue,s.blue,o),r.alpha=de(n.alpha,s.alpha,o),Et.transform(r))},Ks=new Set(["none","hidden"]);function Nc(e,t){return Ks.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function Rc(e,t){return n=>de(e,t,n)}function kr(e){return typeof e=="number"?Rc:typeof e=="string"?Ar(e)?us:pe.test(e)?ui:Ic:Array.isArray(e)?Jo:typeof e=="object"?pe.test(e)?ui:Dc:us}function Jo(e,t){const n=[...e],s=n.length,r=e.map((o,i)=>kr(o)(o,t[i]));return o=>{for(let i=0;i<s;i++)n[i]=r[i](o);return n}}function Dc(e,t){const n={...e,...t},s={};for(const r in n)e[r]!==void 0&&t[r]!==void 0&&(s[r]=kr(e[r])(e[r],t[r]));return r=>{for(const o in s)n[o]=s[o](r);return n}}function Vc(e,t){const n=[],s={color:0,var:0,number:0};for(let r=0;r<t.values.length;r++){const o=t.types[r],i=e.indexes[o][s[o]],a=e.values[i]??0;n[r]=a,s[o]++}return n}const Ic=(e,t)=>{const n=yt.createTransformer(t),s=Rn(e),r=Rn(t);return s.indexes.var.length===r.indexes.var.length&&s.indexes.color.length===r.indexes.color.length&&s.indexes.number.length>=r.indexes.number.length?Ks.has(e)&&!r.values.length||Ks.has(t)&&!s.values.length?Nc(e,t):On(Jo(Vc(s,r),r.values),n):(Jt(!0,`Complex values '${e}' and '${t}' 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"),us(e,t))};function Zo(e,t,n){return typeof e=="number"&&typeof t=="number"&&typeof n=="number"?de(e,t,n):kr(e)(e,t)}const Oc=e=>{const t=({timestamp:n})=>e(n);return{start:(n=!0)=>le.update(t,n),stop:()=>gt(t),now:()=>ve.isProcessing?ve.timestamp:Ne.now()}},Qo=(e,t,n=10)=>{let s="";const r=Math.max(Math.round(t/n),2);for(let o=0;o<r;o++)s+=Math.round(e(o/(r-1))*1e4)/1e4+", ";return`linear(${s.substring(0,s.length-2)})`},ds=2e4;function Nr(e){let t=0;const n=50;let s=e.next(t);for(;!s.done&&t<ds;)t+=n,s=e.next(t);return t>=ds?1/0:t}function Lc(e,t=100,n){const s=n({...e,keyframes:[0,t]}),r=Math.min(Nr(s),ds);return{type:"keyframes",ease:o=>s.next(r*o).value/t,duration:Fe(r)}}const $c=5;function ea(e,t,n){const s=Math.max(t-$c,0);return Do(n-e(s),t-s)}const ue={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},Ns=.001;function Fc({duration:e=ue.duration,bounce:t=ue.bounce,velocity:n=ue.velocity,mass:s=ue.mass}){let r,o;Jt(e<=qe(ue.maxDuration),"Spring duration must be 10 seconds or less","spring-duration-limit");let i=1-t;i=ot(ue.minDamping,ue.maxDamping,i),e=ot(ue.minDuration,ue.maxDuration,Fe(e)),i<1?(r=u=>{const d=u*i,h=d*e,m=d-n,p=Gs(u,i),T=Math.exp(-h);return Ns-m/p*T},o=u=>{const h=u*i*e,m=h*n+n,p=Math.pow(i,2)*Math.pow(u,2)*e,T=Math.exp(-h),v=Gs(Math.pow(u,2),i);return(-r(u)+Ns>0?-1:1)*((m-p)*T)/v}):(r=u=>{const d=Math.exp(-u*e),h=(u-n)*e+1;return-Ns+d*h},o=u=>{const d=Math.exp(-u*e),h=(n-u)*(e*e);return d*h});const a=5/e,l=Uc(r,o,a);if(e=qe(e),isNaN(l))return{stiffness:ue.stiffness,damping:ue.damping,duration:e};{const u=Math.pow(l,2)*s;return{stiffness:u,damping:i*2*Math.sqrt(s*u),duration:e}}}const Bc=12;function Uc(e,t,n){let s=n;for(let r=1;r<Bc;r++)s=s-e(s)/t(s);return s}function Gs(e,t){return e*Math.sqrt(1-t*t)}const zc=["duration","bounce"],_c=["stiffness","damping","mass"];function di(e,t){return t.some(n=>e[n]!==void 0)}function Xc(e){let t={velocity:ue.velocity,stiffness:ue.stiffness,damping:ue.damping,mass:ue.mass,isResolvedFromDuration:!1,...e};if(!di(e,_c)&&di(e,zc))if(e.visualDuration){const n=e.visualDuration,s=2*Math.PI/(n*1.2),r=s*s,o=2*ot(.05,1,1-(e.bounce||0))*Math.sqrt(r);t={...t,mass:ue.mass,stiffness:r,damping:o}}else{const n=Fc(e);t={...t,...n,mass:ue.mass},t.isResolvedFromDuration=!0}return t}function hs(e=ue.visualDuration,t=ue.bounce){const n=typeof e!="object"?{visualDuration:e,keyframes:[0,1],bounce:t}:e;let{restSpeed:s,restDelta:r}=n;const o=n.keyframes[0],i=n.keyframes[n.keyframes.length-1],a={done:!1,value:o},{stiffness:l,damping:u,mass:d,duration:h,velocity:m,isResolvedFromDuration:p}=Xc({...n,velocity:-Fe(n.velocity||0)}),T=m||0,v=u/(2*Math.sqrt(l*d)),C=i-o,b=Fe(Math.sqrt(l/d)),E=Math.abs(C)<5;s||(s=E?ue.restSpeed.granular:ue.restSpeed.default),r||(r=E?ue.restDelta.granular:ue.restDelta.default);let M;if(v<1){const R=Gs(b,v);M=I=>{const N=Math.exp(-v*b*I);return i-N*((T+v*b*C)/R*Math.sin(R*I)+C*Math.cos(R*I))}}else if(v===1)M=R=>i-Math.exp(-b*R)*(C+(T+b*C)*R);else{const R=b*Math.sqrt(v*v-1);M=I=>{const N=Math.exp(-v*b*I),j=Math.min(R*I,300);return i-N*((T+v*b*C)*Math.sinh(j)+R*C*Math.cosh(j))/R}}const $={calculatedDuration:p&&h||null,next:R=>{const I=M(R);if(p)a.done=R>=h;else{let N=R===0?T:0;v<1&&(N=R===0?qe(T):ea(M,R,I));const j=Math.abs(N)<=s,O=Math.abs(i-I)<=r;a.done=j&&O}return a.value=a.done?i:I,a},toString:()=>{const R=Math.min(Nr($),ds),I=Qo(N=>$.next(R*N).value,R,30);return R+"ms "+I},toTransition:()=>{}};return $}hs.applyToOptions=e=>{const t=Lc(e,100,hs);return e.ease=t.ease,e.duration=qe(t.duration),e.type="keyframes",e};function Ys({keyframes:e,velocity:t=0,power:n=.8,timeConstant:s=325,bounceDamping:r=10,bounceStiffness:o=500,modifyTarget:i,min:a,max:l,restDelta:u=.5,restSpeed:d}){const h=e[0],m={done:!1,value:h},p=j=>a!==void 0&&j<a||l!==void 0&&j>l,T=j=>a===void 0?l:l===void 0||Math.abs(a-j)<Math.abs(l-j)?a:l;let v=n*t;const C=h+v,b=i===void 0?C:i(C);b!==C&&(v=b-h);const E=j=>-v*Math.exp(-j/s),M=j=>b+E(j),$=j=>{const O=E(j),A=M(j);m.done=Math.abs(O)<=u,m.value=m.done?b:A};let R,I;const N=j=>{p(m.value)&&(R=j,I=hs({keyframes:[m.value,T(m.value)],velocity:ea(M,j,m.value),damping:r,stiffness:o,restDelta:u,restSpeed:d}))};return N(0),{calculatedDuration:null,next:j=>{let O=!1;return!I&&R===void 0&&(O=!0,$(j),N(j)),R!==void 0&&j>=R?I.next(j-R):(!O&&$(j),m)}}}function Wc(e,t,n){const s=[],r=n||lt.mix||Zo,o=e.length-1;for(let i=0;i<o;i++){let a=r(e[i],e[i+1]);if(t){const l=Array.isArray(t)?t[i]||Be:t;a=On(l,a)}s.push(a)}return s}function qc(e,t,{clamp:n=!0,ease:s,mixer:r}={}){const o=e.length;if(at(o===t.length,"Both input and output ranges must be the same length","range-length"),o===1)return()=>t[0];if(o===2&&t[0]===t[1])return()=>t[1];const i=e[0]===e[1];e[0]>e[o-1]&&(e=[...e].reverse(),t=[...t].reverse());const a=Wc(t,s,r),l=a.length,u=d=>{if(i&&d<e[0])return t[0];let h=0;if(l>1)for(;h<e.length-2&&!(d<e[h+1]);h++);const m=kn(e[h],e[h+1],d);return a[h](m)};return n?d=>u(ot(e[0],e[o-1],d)):u}function Kc(e,t){const n=e[e.length-1];for(let s=1;s<=t;s++){const r=kn(0,t,s);e.push(de(n,1,r))}}function Gc(e){const t=[0];return Kc(t,e.length-1),t}function Yc(e,t){return e.map(n=>n*t)}function Hc(e,t){return e.map(()=>t||zo).splice(0,e.length-1)}function zt({duration:e=300,keyframes:t,times:n,ease:s="easeInOut"}){const r=lc(s)?s.map(oi):oi(s),o={done:!1,value:t[0]},i=Yc(n&&n.length===t.length?n:Gc(t),e),a=qc(i,t,{ease:Array.isArray(r)?r:Hc(t,r)});return{calculatedDuration:e,next:l=>(o.value=a(l),o.done=l>=e,o)}}const Jc=e=>e!==null;function Rr(e,{repeat:t,repeatType:n="loop"},s,r=1){const o=e.filter(Jc),a=r<0||t&&n!=="loop"&&t%2===1?0:o.length-1;return!a||s===void 0?o[a]:s}const Zc={decay:Ys,inertia:Ys,tween:zt,keyframes:zt,spring:hs};function ta(e){typeof e.type=="string"&&(e.type=Zc[e.type])}class Dr{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(t=>{this.resolve=t})}notifyFinished(){this.resolve()}then(t,n){return this.finished.then(t,n)}}const Qc=e=>e/100;class Vr extends Dr{constructor(t){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.stop=()=>{const{motionValue:n}=this.options;n&&n.updatedAt!==Ne.now()&&this.tick(Ne.now()),this.isStopped=!0,this.state!=="idle"&&(this.teardown(),this.options.onStop?.())},this.options=t,this.initAnimation(),this.play(),t.autoplay===!1&&this.pause()}initAnimation(){const{options:t}=this;ta(t);const{type:n=zt,repeat:s=0,repeatDelay:r=0,repeatType:o,velocity:i=0}=t;let{keyframes:a}=t;const l=n||zt;process.env.NODE_ENV!=="production"&&l!==zt&&at(a.length<=2,`Only two keyframes currently supported with spring and inertia animations. Trying to animate ${a}`,"spring-two-frames"),l!==zt&&typeof a[0]!="number"&&(this.mixKeyframes=On(Qc,Zo(a[0],a[1])),a=[0,100]);const u=l({...t,keyframes:a});o==="mirror"&&(this.mirroredGenerator=l({...t,keyframes:[...a].reverse(),velocity:-i})),u.calculatedDuration===null&&(u.calculatedDuration=Nr(u));const{calculatedDuration:d}=u;this.calculatedDuration=d,this.resolvedDuration=d+r,this.totalDuration=this.resolvedDuration*(s+1)-r,this.generator=u}updateTime(t){const n=Math.round(t-this.startTime)*this.playbackSpeed;this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=n}tick(t,n=!1){const{generator:s,totalDuration:r,mixKeyframes:o,mirroredGenerator:i,resolvedDuration:a,calculatedDuration:l}=this;if(this.startTime===null)return s.next(0);const{delay:u=0,keyframes:d,repeat:h,repeatType:m,repeatDelay:p,type:T,onUpdate:v,finalKeyframe:C}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,t):this.speed<0&&(this.startTime=Math.min(t-r/this.speed,this.startTime)),n?this.currentTime=t:this.updateTime(t);const b=this.currentTime-u*(this.playbackSpeed>=0?1:-1),E=this.playbackSpeed>=0?b<0:b>r;this.currentTime=Math.max(b,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=r);let M=this.currentTime,$=s;if(h){const j=Math.min(this.currentTime,r)/a;let O=Math.floor(j),A=j%1;!A&&j>=1&&(A=1),A===1&&O--,O=Math.min(O,h+1),!!(O%2)&&(m==="reverse"?(A=1-A,p&&(A-=p/a)):m==="mirror"&&($=i)),M=ot(0,1,A)*a}const R=E?{done:!1,value:d[0]}:$.next(M);o&&(R.value=o(R.value));let{done:I}=R;!E&&l!==null&&(I=this.playbackSpeed>=0?this.currentTime>=r:this.currentTime<=0);const N=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&I);return N&&T!==Ys&&(R.value=Rr(d,this.options,C,this.speed)),v&&v(R.value),N&&this.finish(),R}then(t,n){return this.finished.then(t,n)}get duration(){return Fe(this.calculatedDuration)}get iterationDuration(){const{delay:t=0}=this.options||{};return this.duration+Fe(t)}get time(){return Fe(this.currentTime)}set time(t){t=qe(t),this.currentTime=t,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=t:this.driver&&(this.startTime=this.driver.now()-t/this.playbackSpeed),this.driver?.start(!1)}get speed(){return this.playbackSpeed}set speed(t){this.updateTime(Ne.now());const n=this.playbackSpeed!==t;this.playbackSpeed=t,n&&(this.time=Fe(this.currentTime))}play(){if(this.isStopped)return;const{driver:t=Oc,startTime:n}=this.options;this.driver||(this.driver=t(r=>this.tick(r))),this.options.onPlay?.();const s=this.driver.now();this.state==="finished"?(this.updateFinished(),this.startTime=s):this.holdTime!==null?this.startTime=s-this.holdTime:this.startTime||(this.startTime=n??s),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(Ne.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(t){return this.startTime=0,this.tick(t,!0)}attachTimeline(t){return this.options.allowFlatten&&(this.options.type="keyframes",this.options.ease="linear",this.initAnimation()),this.driver?.stop(),t.observe(this)}}function eu(e){for(let t=1;t<e.length;t++)e[t]??(e[t]=e[t-1])}const kt=e=>e*180/Math.PI,Hs=e=>{const t=kt(Math.atan2(e[1],e[0]));return Js(t)},tu={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:Hs,rotateZ:Hs,skewX:e=>kt(Math.atan(e[1])),skewY:e=>kt(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},Js=e=>(e=e%360,e<0&&(e+=360),e),hi=Hs,fi=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),mi=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),nu={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:fi,scaleY:mi,scale:e=>(fi(e)+mi(e))/2,rotateX:e=>Js(kt(Math.atan2(e[6],e[5]))),rotateY:e=>Js(kt(Math.atan2(-e[2],e[0]))),rotateZ:hi,rotate:hi,skewX:e=>kt(Math.atan(e[4])),skewY:e=>kt(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function Zs(e){return e.includes("scale")?1:0}function Qs(e,t){if(!e||e==="none")return Zs(t);const n=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let s,r;if(n)s=nu,r=n;else{const a=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);s=tu,r=a}if(!r)return Zs(t);const o=s[t],i=r[1].split(",").map(ru);return typeof o=="function"?o(i):i[o]}const su=(e,t)=>{const{transform:n="none"}=getComputedStyle(e);return Qs(n,t)};function ru(e){return parseFloat(e.trim())}const Qt=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],en=new Set(Qt),pi=e=>e===Zt||e===z,iu=new Set(["x","y","z"]),ou=Qt.filter(e=>!iu.has(e));function au(e){const t=[];return ou.forEach(n=>{const s=e.getValue(n);s!==void 0&&(t.push([n,s.get()]),s.set(n.startsWith("scale")?1:0))}),t}const Nt={width:({x:e},{paddingLeft:t="0",paddingRight:n="0"})=>e.max-e.min-parseFloat(t)-parseFloat(n),height:({y:e},{paddingTop:t="0",paddingBottom:n="0"})=>e.max-e.min-parseFloat(t)-parseFloat(n),top:(e,{top:t})=>parseFloat(t),left:(e,{left:t})=>parseFloat(t),bottom:({y:e},{top:t})=>parseFloat(t)+(e.max-e.min),right:({x:e},{left:t})=>parseFloat(t)+(e.max-e.min),x:(e,{transform:t})=>Qs(t,"x"),y:(e,{transform:t})=>Qs(t,"y")};Nt.translateX=Nt.x;Nt.translateY=Nt.y;const Rt=new Set;let er=!1,tr=!1,nr=!1;function na(){if(tr){const e=Array.from(Rt).filter(s=>s.needsMeasurement),t=new Set(e.map(s=>s.element)),n=new Map;t.forEach(s=>{const r=au(s);r.length&&(n.set(s,r),s.render())}),e.forEach(s=>s.measureInitialState()),t.forEach(s=>{s.render();const r=n.get(s);r&&r.forEach(([o,i])=>{s.getValue(o)?.set(i)})}),e.forEach(s=>s.measureEndState()),e.forEach(s=>{s.suspendedScrollY!==void 0&&window.scrollTo(0,s.suspendedScrollY)})}tr=!1,er=!1,Rt.forEach(e=>e.complete(nr)),Rt.clear()}function sa(){Rt.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(tr=!0)})}function lu(){nr=!0,sa(),na(),nr=!1}class Ir{constructor(t,n,s,r,o,i=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...t],this.onComplete=n,this.name=s,this.motionValue=r,this.element=o,this.isAsync=i}scheduleResolve(){this.state="scheduled",this.isAsync?(Rt.add(this),er||(er=!0,le.read(sa),le.resolveKeyframes(na))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:t,name:n,element:s,motionValue:r}=this;if(t[0]===null){const o=r?.get(),i=t[t.length-1];if(o!==void 0)t[0]=o;else if(s&&n){const a=s.readValue(n,i);a!=null&&(t[0]=a)}t[0]===void 0&&(t[0]=i),r&&o===void 0&&r.set(t[0])}eu(t)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(t=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,t),Rt.delete(this)}cancel(){this.state==="scheduled"&&(Rt.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const cu=e=>e.startsWith("--");function uu(e,t,n){cu(t)?e.style.setProperty(t,n):e.style[t]=n}const du=wr(()=>window.ScrollTimeline!==void 0),hu={};function fu(e,t){const n=wr(e);return()=>hu[t]??n()}const ra=fu(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),Tn=([e,t,n,s])=>`cubic-bezier(${e}, ${t}, ${n}, ${s})`,gi={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:Tn([0,.65,.55,1]),circOut:Tn([.55,0,1,.45]),backIn:Tn([.31,.01,.66,-.59]),backOut:Tn([.33,1.53,.69,.99])};function ia(e,t){if(e)return typeof e=="function"?ra()?Qo(e,t):"ease-out":_o(e)?Tn(e):Array.isArray(e)?e.map(n=>ia(n,t)||gi.easeOut):gi[e]}function mu(e,t,n,{delay:s=0,duration:r=300,repeat:o=0,repeatType:i="loop",ease:a="easeOut",times:l}={},u=void 0){const d={[t]:n};l&&(d.offset=l);const h=ia(a,r);Array.isArray(h)&&(d.easing=h);const m={delay:s,duration:r,easing:Array.isArray(h)?"linear":h,fill:"both",iterations:o+1,direction:i==="reverse"?"alternate":"normal"};return u&&(m.pseudoElement=u),e.animate(d,m)}function oa(e){return typeof e=="function"&&"applyToOptions"in e}function pu({type:e,...t}){return oa(e)&&ra()?e.applyToOptions(t):(t.duration??(t.duration=300),t.ease??(t.ease="easeOut"),t)}class gu extends Dr{constructor(t){if(super(),this.finishedTime=null,this.isStopped=!1,!t)return;const{element:n,name:s,keyframes:r,pseudoElement:o,allowFlatten:i=!1,finalKeyframe:a,onComplete:l}=t;this.isPseudoElement=!!o,this.allowFlatten=i,this.options=t,at(typeof t.type!="string",`Mini animate() doesn't support "type" as a string.`,"mini-spring");const u=pu(t);this.animation=mu(n,s,r,u,o),u.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!o){const d=Rr(r,this.options,a,this.speed);this.updateMotionValue?this.updateMotionValue(d):uu(n,s,d),this.animation.cancel()}l?.(),this.notifyFinished()}}play(){this.isStopped||(this.animation.play(),this.state==="finished"&&this.updateFinished())}pause(){this.animation.pause()}complete(){this.animation.finish?.()}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;const{state:t}=this;t==="idle"||t==="finished"||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){this.isPseudoElement||this.animation.commitStyles?.()}get duration(){const t=this.animation.effect?.getComputedTiming?.().duration||0;return Fe(Number(t))}get iterationDuration(){const{delay:t=0}=this.options||{};return this.duration+Fe(t)}get time(){return Fe(Number(this.animation.currentTime)||0)}set time(t){this.finishedTime=null,this.animation.currentTime=qe(t)}get speed(){return this.animation.playbackRate}set speed(t){t<0&&(this.finishedTime=null),this.animation.playbackRate=t}get state(){return this.finishedTime!==null?"finished":this.animation.playState}get startTime(){return Number(this.animation.startTime)}set startTime(t){this.animation.startTime=t}attachTimeline({timeline:t,observe:n}){return this.allowFlatten&&this.animation.effect?.updateTiming({easing:"linear"}),this.animation.onfinish=null,t&&du()?(this.animation.timeline=t,Be):n(this)}}const aa={anticipate:Fo,backInOut:$o,circInOut:Uo};function yu(e){return e in aa}function xu(e){typeof e.ease=="string"&&yu(e.ease)&&(e.ease=aa[e.ease])}const yi=10;class bu extends gu{constructor(t){xu(t),ta(t),super(t),t.startTime&&(this.startTime=t.startTime),this.options=t}updateMotionValue(t){const{motionValue:n,onUpdate:s,onComplete:r,element:o,...i}=this.options;if(!n)return;if(t!==void 0){n.set(t);return}const a=new Vr({...i,autoplay:!1}),l=qe(this.finishedTime??this.time);n.setWithVelocity(a.sample(l-yi).value,a.sample(l).value,yi),a.stop()}}const xi=(e,t)=>t==="zIndex"?!1:!!(typeof e=="number"||Array.isArray(e)||typeof e=="string"&&(yt.test(e)||e==="0")&&!e.startsWith("url("));function vu(e){const t=e[0];if(e.length===1)return!0;for(let n=0;n<e.length;n++)if(e[n]!==t)return!0}function wu(e,t,n,s){const r=e[0];if(r===null)return!1;if(t==="display"||t==="visibility")return!0;const o=e[e.length-1],i=xi(r,t),a=xi(o,t);return Jt(i===a,`You are trying to animate ${t} from "${r}" to "${o}". "${i?o:r}" is not an animatable value.`,"value-not-animatable"),!i||!a?!1:vu(e)||(n==="spring"||oa(n))&&s}function sr(e){e.duration=0,e.type="keyframes"}const Su=new Set(["opacity","clipPath","filter","transform"]),Tu=wr(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function Cu(e){const{motionValue:t,name:n,repeatDelay:s,repeatType:r,damping:o,type:i}=e;if(!(t?.owner?.current instanceof HTMLElement))return!1;const{onUpdate:l,transformTemplate:u}=t.owner.getProps();return Tu()&&n&&Su.has(n)&&(n!=="transform"||!u)&&!l&&!s&&r!=="mirror"&&o!==0&&i!=="inertia"}const ju=40;class Pu extends Dr{constructor({autoplay:t=!0,delay:n=0,type:s="keyframes",repeat:r=0,repeatDelay:o=0,repeatType:i="loop",keyframes:a,name:l,motionValue:u,element:d,...h}){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=Ne.now();const m={autoplay:t,delay:n,type:s,repeat:r,repeatDelay:o,repeatType:i,name:l,motionValue:u,element:d,...h},p=d?.KeyframeResolver||Ir;this.keyframeResolver=new p(a,(T,v,C)=>this.onKeyframesResolved(T,v,m,!C),l,u,d),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(t,n,s,r){this.keyframeResolver=void 0;const{name:o,type:i,velocity:a,delay:l,isHandoff:u,onUpdate:d}=s;this.resolvedAt=Ne.now(),wu(t,o,i,a)||((lt.instantAnimations||!l)&&d?.(Rr(t,s,n)),t[0]=t[t.length-1],sr(s),s.repeat=0);const m={startTime:r?this.resolvedAt?this.resolvedAt-this.createdAt>ju?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...s,keyframes:t},p=!u&&Cu(m)?new bu({...m,element:m.motionValue.owner.current}):new Vr(m);p.finished.then(()=>this.notifyFinished()).catch(Be),this.pendingTimeline&&(this.stopTimeline=p.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=p}get finished(){return this._animation?this.animation.finished:this._finished}then(t,n){return this.finished.finally(t).then(()=>{})}get animation(){return this._animation||(this.keyframeResolver?.resume(),lu()),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(t){this.animation.time=t}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(t){this.animation.speed=t}get startTime(){return this.animation.startTime}attachTimeline(t){return this._animation?this.stopTimeline=this.animation.attachTimeline(t):this.pendingTimeline=t,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){this._animation&&this.animation.cancel(),this.keyframeResolver?.cancel()}}const Au=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function Mu(e){const t=Au.exec(e);if(!t)return[,];const[,n,s,r]=t;return[`--${n??s}`,r]}const Eu=4;function la(e,t,n=1){at(n<=Eu,`Max CSS variable fallback depth detected in property "${e}". This may indicate a circular fallback dependency.`,"max-css-var-depth");const[s,r]=Mu(e);if(!s)return;const o=window.getComputedStyle(t).getPropertyValue(s);if(o){const i=o.trim();return ko(i)?parseFloat(i):i}return Ar(r)?la(r,t,n+1):r}function Or(e,t){return e?.[t]??e?.default??e}const ca=new Set(["width","height","top","left","right","bottom",...Qt]),ku={test:e=>e==="auto",parse:e=>e},ua=e=>t=>t.test(e),da=[Zt,z,et,pt,vc,bc,ku],bi=e=>da.find(ua(e));function Nu(e){return typeof e=="number"?e===0:e!==null?e==="none"||e==="0"||Ro(e):!0}const Ru=new Set(["brightness","contrast","saturate","opacity"]);function Du(e){const[t,n]=e.slice(0,-1).split("(");if(t==="drop-shadow")return e;const[s]=n.match(Mr)||[];if(!s)return e;const r=n.replace(s,"");let o=Ru.has(t)?1:0;return s!==n&&(o*=100),t+"("+o+r+")"}const Vu=/\b([a-z-]*)\(.*?\)/gu,rr={...yt,getAnimatableNone:e=>{const t=e.match(Vu);return t?t.map(Du).join(" "):e}},vi={...Zt,transform:Math.round},Iu={rotate:pt,rotateX:pt,rotateY:pt,rotateZ:pt,scale:Qn,scaleX:Qn,scaleY:Qn,scaleZ:Qn,skew:pt,skewX:pt,skewY:pt,distance:z,translateX:z,translateY:z,translateZ:z,x:z,y:z,z,perspective:z,transformPerspective:z,opacity:Nn,originX:ai,originY:ai,originZ:z},Lr={borderWidth:z,borderTopWidth:z,borderRightWidth:z,borderBottomWidth:z,borderLeftWidth:z,borderRadius:z,radius:z,borderTopLeftRadius:z,borderTopRightRadius:z,borderBottomRightRadius:z,borderBottomLeftRadius:z,width:z,maxWidth:z,height:z,maxHeight:z,top:z,right:z,bottom:z,left:z,padding:z,paddingTop:z,paddingRight:z,paddingBottom:z,paddingLeft:z,margin:z,marginTop:z,marginRight:z,marginBottom:z,marginLeft:z,backgroundPositionX:z,backgroundPositionY:z,...Iu,zIndex:vi,fillOpacity:Nn,strokeOpacity:Nn,numOctaves:vi},Ou={...Lr,color:pe,backgroundColor:pe,outlineColor:pe,fill:pe,stroke:pe,borderColor:pe,borderTopColor:pe,borderRightColor:pe,borderBottomColor:pe,borderLeftColor:pe,filter:rr,WebkitFilter:rr},ha=e=>Ou[e];function fa(e,t){let n=ha(e);return n!==rr&&(n=yt),n.getAnimatableNone?n.getAnimatableNone(t):void 0}const Lu=new Set(["auto","none","0"]);function $u(e,t,n){let s=0,r;for(;s<e.length&&!r;){const o=e[s];typeof o=="string"&&!Lu.has(o)&&Rn(o).values.length&&(r=e[s]),s++}if(r&&n)for(const o of t)e[o]=fa(n,r)}class Fu extends Ir{constructor(t,n,s,r,o){super(t,n,s,r,o,!0)}readKeyframes(){const{unresolvedKeyframes:t,element:n,name:s}=this;if(!n||!n.current)return;super.readKeyframes();for(let l=0;l<t.length;l++){let u=t[l];if(typeof u=="string"&&(u=u.trim(),Ar(u))){const d=la(u,n.current);d!==void 0&&(t[l]=d),l===t.length-1&&(this.finalKeyframe=u)}}if(this.resolveNoneKeyframes(),!ca.has(s)||t.length!==2)return;const[r,o]=t,i=bi(r),a=bi(o);if(i!==a)if(pi(i)&&pi(a))for(let l=0;l<t.length;l++){const u=t[l];typeof u=="string"&&(t[l]=parseFloat(u))}else Nt[s]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:t,name:n}=this,s=[];for(let r=0;r<t.length;r++)(t[r]===null||Nu(t[r]))&&s.push(r);s.length&&$u(t,s,n)}measureInitialState(){const{element:t,unresolvedKeyframes:n,name:s}=this;if(!t||!t.current)return;s==="height"&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=Nt[s](t.measureViewportBox(),window.getComputedStyle(t.current)),n[0]=this.measuredOrigin;const r=n[n.length-1];r!==void 0&&t.getValue(s,r).jump(r,!1)}measureEndState(){const{element:t,name:n,unresolvedKeyframes:s}=this;if(!t||!t.current)return;const r=t.getValue(n);r&&r.jump(this.measuredOrigin,!1);const o=s.length-1,i=s[o];s[o]=Nt[n](t.measureViewportBox(),window.getComputedStyle(t.current)),i!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=i),this.removedTransforms?.length&&this.removedTransforms.forEach(([a,l])=>{t.getValue(a).set(l)}),this.resolveNoneKeyframes()}}function Bu(e,t,n){if(e instanceof EventTarget)return[e];if(typeof e=="string"){let s=document;const r=n?.[e]??s.querySelectorAll(e);return r?Array.from(r):[]}return Array.from(e)}const ma=(e,t)=>t&&typeof e=="number"?t.transform(e):e;function pa(e){return No(e)&&"offsetHeight"in e}const wi=30,Uu=e=>!isNaN(parseFloat(e));class zu{constructor(t,n={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=s=>{const r=Ne.now();if(this.updatedAt!==r&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(s),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(t),this.owner=n.owner}setCurrent(t){this.current=t,this.updatedAt=Ne.now(),this.canTrackVelocity===null&&t!==void 0&&(this.canTrackVelocity=Uu(this.current))}setPrevFrameValue(t=this.current){this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt}onChange(t){return process.env.NODE_ENV!=="production"&&Tr(!1,'value.onChange(callback) is deprecated. Switch to value.on("change", callback).'),this.on("change",t)}on(t,n){this.events[t]||(this.events[t]=new Sr);const s=this.events[t].add(n);return t==="change"?()=>{s(),le.read(()=>{this.events.change.getSize()||this.stop()})}:s}clearListeners(){for(const t in this.events)this.events[t].clear()}attach(t,n){this.passiveEffect=t,this.stopPassiveEffect=n}set(t){this.passiveEffect?this.passiveEffect(t,this.updateAndNotify):this.updateAndNotify(t)}setWithVelocity(t,n,s){this.set(n),this.prev=void 0,this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt-s}jump(t,n=!0){this.updateAndNotify(t),this.prev=t,this.prevUpdatedAt=this.prevFrameValue=void 0,n&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){this.events.change?.notify(this.current)}addDependent(t){this.dependents||(this.dependents=new Set),this.dependents.add(t)}removeDependent(t){this.dependents&&this.dependents.delete(t)}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const t=Ne.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||t-this.updatedAt>wi)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,wi);return Do(parseFloat(this.current)-parseFloat(this.prevFrameValue),n)}start(t){return this.stop(),new Promise(n=>{this.hasAnimated=!0,this.animation=t(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 Yt(e,t){return new zu(e,t)}const{schedule:$r}=Xo(queueMicrotask,!1),Xe={x:!1,y:!1};function ga(){return Xe.x||Xe.y}function _u(e){return e==="x"||e==="y"?Xe[e]?null:(Xe[e]=!0,()=>{Xe[e]=!1}):Xe.x||Xe.y?null:(Xe.x=Xe.y=!0,()=>{Xe.x=Xe.y=!1})}function ya(e,t){const n=Bu(e),s=new AbortController,r={passive:!0,...t,signal:s.signal};return[n,r,()=>s.abort()]}function Si(e){return!(e.pointerType==="touch"||ga())}function Xu(e,t,n={}){const[s,r,o]=ya(e,n),i=a=>{if(!Si(a))return;const{target:l}=a,u=t(l,a);if(typeof u!="function"||!l)return;const d=h=>{Si(h)&&(u(h),l.removeEventListener("pointerleave",d))};l.addEventListener("pointerleave",d,r)};return s.forEach(a=>{a.addEventListener("pointerenter",i,r)}),o}const xa=(e,t)=>t?e===t?!0:xa(e,t.parentElement):!1,Fr=e=>e.pointerType==="mouse"?typeof e.button!="number"||e.button<=0:e.isPrimary!==!1,Wu=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function qu(e){return Wu.has(e.tagName)||e.tabIndex!==-1}const os=new WeakSet;function Ti(e){return t=>{t.key==="Enter"&&e(t)}}function Rs(e,t){e.dispatchEvent(new PointerEvent("pointer"+t,{isPrimary:!0,bubbles:!0}))}const Ku=(e,t)=>{const n=e.currentTarget;if(!n)return;const s=Ti(()=>{if(os.has(n))return;Rs(n,"down");const r=Ti(()=>{Rs(n,"up")}),o=()=>Rs(n,"cancel");n.addEventListener("keyup",r,t),n.addEventListener("blur",o,t)});n.addEventListener("keydown",s,t),n.addEventListener("blur",()=>n.removeEventListener("keydown",s),t)};function Ci(e){return Fr(e)&&!ga()}function Gu(e,t,n={}){const[s,r,o]=ya(e,n),i=a=>{const l=a.currentTarget;if(!Ci(a))return;os.add(l);const u=t(l,a),d=(p,T)=>{window.removeEventListener("pointerup",h),window.removeEventListener("pointercancel",m),os.has(l)&&os.delete(l),Ci(p)&&typeof u=="function"&&u(p,{success:T})},h=p=>{d(p,l===window||l===document||n.useGlobalTarget||xa(l,p.target))},m=p=>{d(p,!1)};window.addEventListener("pointerup",h,r),window.addEventListener("pointercancel",m,r)};return s.forEach(a=>{(n.useGlobalTarget?window:a).addEventListener("pointerdown",i,r),pa(a)&&(a.addEventListener("focus",u=>Ku(u,r)),!qu(a)&&!a.hasAttribute("tabindex")&&(a.tabIndex=0))}),o}function ba(e){return No(e)&&"ownerSVGElement"in e}function Yu(e){return ba(e)&&e.tagName==="svg"}const Se=e=>!!(e&&e.getVelocity),Hu=[...da,pe,yt],Ju=e=>Hu.find(ua(e)),Br=f.createContext({transformPagePoint:e=>e,isStatic:!1,reducedMotion:"never"});function ji(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Zu(...e){return t=>{let n=!1;const s=e.map(r=>{const o=ji(r,t);return!n&&typeof o=="function"&&(n=!0),o});if(n)return()=>{for(let r=0;r<s.length;r++){const o=s[r];typeof o=="function"?o():ji(e[r],null)}}}}function Qu(...e){return We.useCallback(Zu(...e),e)}class ed extends We.Component{getSnapshotBeforeUpdate(t){const n=this.props.childRef.current;if(n&&t.isPresent&&!this.props.isPresent){const s=n.offsetParent,r=pa(s)&&s.offsetWidth||0,o=this.props.sizeRef.current;o.height=n.offsetHeight||0,o.width=n.offsetWidth||0,o.top=n.offsetTop,o.left=n.offsetLeft,o.right=r-o.width-o.left}return null}componentDidUpdate(){}render(){return this.props.children}}function td({children:e,isPresent:t,anchorX:n,root:s}){const r=f.useId(),o=f.useRef(null),i=f.useRef({width:0,height:0,top:0,left:0,right:0}),{nonce:a}=f.useContext(Br),l=Qu(o,e?.ref);return f.useInsertionEffect(()=>{const{width:u,height:d,top:h,left:m,right:p}=i.current;if(t||!o.current||!u||!d)return;const T=n==="left"?`left: ${m}`:`right: ${p}`;o.current.dataset.motionPopId=r;const v=document.createElement("style");a&&(v.nonce=a);const C=s??document.head;return C.appendChild(v),v.sheet&&v.sheet.insertRule(`
|
|
3
3
|
[data-motion-pop-id="${r}"] {
|
|
4
4
|
position: absolute !important;
|
|
5
5
|
width: ${u}px !important;
|
|
6
6
|
height: ${d}px !important;
|
|
7
|
-
${
|
|
8
|
-
top: ${
|
|
7
|
+
${T}px !important;
|
|
8
|
+
top: ${h}px !important;
|
|
9
9
|
}
|
|
10
|
-
`),()=>{C.contains(v)&&C.removeChild(v)}},[t]),c.jsx(sd,{isPresent:t,childRef:o,sizeRef:i,children:qe.cloneElement(e,{ref:l})})}const id=({children:e,initial:t,isPresent:n,onExitComplete:s,custom:r,presenceAffectsLayout:o,mode:i,anchorX:a,root:l})=>{const u=yr(od),d=h.useId();let f=!0,m=h.useMemo(()=>(f=!1,{id:d,initial:t,isPresent:n,custom:r,onExitComplete:p=>{u.set(p,!0);for(const S of u.values())if(!S)return;s&&s()},register:p=>(u.set(p,!1),()=>u.delete(p))}),[n,u,s]);return o&&f&&(m={...m}),h.useMemo(()=>{u.forEach((p,S)=>u.set(S,!1))},[n]),qe.useEffect(()=>{!n&&!u.size&&s&&s()},[n]),i==="popLayout"&&(e=c.jsx(rd,{isPresent:n,anchorX:a,root:l,children:e})),c.jsx(ps.Provider,{value:m,children:e})};function od(){return new Map}function wa(e=!0){const t=h.useContext(ps);if(t===null)return[!0,null];const{isPresent:n,onExitComplete:s,register:r}=t,o=h.useId();h.useEffect(()=>{if(e)return r(o)},[e]);const i=h.useCallback(()=>e&&s&&s(o),[o,s,e]);return!n&&s?[!1,i]:[!0]}const Qn=e=>e.key||"";function Ai(e){const t=[];return h.Children.forEach(e,n=>{h.isValidElement(n)&&t.push(n)}),t}const ad=({children:e,custom:t,initial:n=!0,onExitComplete:s,presenceAffectsLayout:r=!0,mode:o="sync",propagate:i=!1,anchorX:a="left",root:l})=>{const[u,d]=wa(i),f=h.useMemo(()=>Ai(e),[e]),m=i&&!u?[]:f.map(Qn),p=h.useRef(!0),S=h.useRef(f),v=yr(()=>new Map),[C,b]=h.useState(f),[M,E]=h.useState(f);ko(()=>{p.current=!1,S.current=f;for(let I=0;I<M.length;I++){const N=Qn(M[I]);m.includes(N)?v.delete(N):v.get(N)!==!0&&v.set(N,!1)}},[M,m.length,m.join("-")]);const $=[];if(f!==C){let I=[...f];for(let N=0;N<M.length;N++){const P=M[N],O=Qn(P);m.includes(O)||(I.splice(N,0,P),$.push(P))}return o==="wait"&&$.length&&(I=$),E(Ai(I)),b(f),null}process.env.NODE_ENV!=="production"&&o==="wait"&&M.length>1&&console.warn(`You're attempting to animate multiple children within AnimatePresence, but its mode is set to "wait". This will lead to odd visual behaviour.`);const{forceRender:R}=h.useContext(gr);return c.jsx(c.Fragment,{children:M.map(I=>{const N=Qn(I),P=i&&!u?!1:f===M||m.includes(N),O=()=>{if(v.has(N))v.set(N,!0);else return;let A=!0;v.forEach(k=>{k||(A=!1)}),A&&(R?.(),E(S.current),i&&d?.(),s&&s())};return c.jsx(id,{isPresent:P,initial:!p.current||n?void 0:!1,custom:t,presenceAffectsLayout:r,mode:o,root:l,onExitComplete:P?void 0:O,anchorX:a,children:I},N)})})},Ur=h.createContext({strict:!1}),Ei={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]},Qt={};for(const e in Ei)Qt[e]={isEnabled:t=>Ei[e].some(n=>!!t[n])};function ir(e){for(const t in e)Qt[t]={...Qt[t],...e[t]}}function ld({children:e,features:t,strict:n=!1}){const[,s]=h.useState(!Ds(t)),r=h.useRef(void 0);if(!Ds(t)){const{renderer:o,...i}=t;r.current=o,ir(i)}return h.useEffect(()=>{Ds(t)&&t().then(({renderer:o,...i})=>{ir(i),r.current=o,s(!0)})},[]),c.jsx(Ur.Provider,{value:{renderer:r.current,strict:n},children:e})}function Ds(e){return typeof e=="function"}const cd=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","ignoreStrict","viewport"]);function fs(e){return e.startsWith("while")||e.startsWith("drag")&&e!=="draggable"||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||cd.has(e)}let Sa=e=>!fs(e);function ud(e){typeof e=="function"&&(Sa=t=>t.startsWith("on")?!fs(t):e(t))}try{ud(require("@emotion/is-prop-valid").default)}catch{}function dd(e,t,n){const s={};for(const r in e)r==="values"&&typeof e.values=="object"||(Sa(r)||n===!0&&fs(r)||!t&&!fs(r)||e.draggable&&r.startsWith("onDrag"))&&(s[r]=e[r]);return s}const gs=h.createContext({});function ys(e){return e!==null&&typeof e=="object"&&typeof e.start=="function"}function On(e){return typeof e=="string"||Array.isArray(e)}const zr=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],_r=["initial",...zr];function xs(e){return ys(e.animate)||_r.some(t=>On(e[t]))}function Ta(e){return!!(xs(e)||e.variants)}function fd(e,t){if(xs(e)){const{initial:n,animate:s}=e;return{initial:n===!1||On(n)?n:void 0,animate:On(s)?s:void 0}}return e.inherit!==!1?t:{}}function hd(e){const{initial:t,animate:n}=fd(e,h.useContext(gs));return h.useMemo(()=>({initial:t,animate:n}),[Mi(t),Mi(n)])}function Mi(e){return Array.isArray(e)?e.join(" "):e}const Ln={};function md(e){for(const t in e)Ln[t]=e[t],Pr(t)&&(Ln[t].isCSSVariable=!0)}function Ca(e,{layout:t,layoutId:n}){return sn.has(e)||e.startsWith("origin")||(t||n!==void 0)&&(!!Ln[e]||e==="opacity")}const pd={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},gd=nn.length;function yd(e,t,n){let s="",r=!0;for(let o=0;o<gd;o++){const i=nn[o],a=e[i];if(a===void 0)continue;let l=!0;if(typeof a=="number"?l=a===(i.startsWith("scale")?1:0):l=parseFloat(a)===0,!l||n){const u=pa(a,Lr[i]);if(!l){r=!1;const d=pd[i]||i;s+=`${d}(${u}) `}n&&(t[i]=u)}}return s=s.trim(),n?s=n(t,r?"":s):r&&(s="none"),s}function Xr(e,t,n){const{style:s,vars:r,transformOrigin:o}=e;let i=!1,a=!1;for(const l in t){const u=t[l];if(sn.has(l)){i=!0;continue}else if(Pr(l)){r[l]=u;continue}else{const d=pa(u,Lr[l]);l.startsWith("origin")?(a=!0,o[l]=d):s[l]=d}}if(t.transform||(i||n?s.transform=yd(t,e.transform,n):s.transform&&(s.transform="none")),a){const{originX:l="50%",originY:u="50%",originZ:d=0}=o;s.transformOrigin=`${l} ${u} ${d}`}}const Wr=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function ja(e,t,n){for(const s in t)!Ce(t[s])&&!Ca(s,n)&&(e[s]=t[s])}function xd({transformTemplate:e},t){return h.useMemo(()=>{const n=Wr();return Xr(n,t,e),Object.assign({},n.vars,n.style)},[t])}function bd(e,t){const n=e.style||{},s={};return ja(s,n,e),Object.assign(s,xd(e,t)),s}function vd(e,t){const n={},s=bd(e,t);return e.drag&&e.dragListener!==!1&&(n.draggable=!1,s.userSelect=s.WebkitUserSelect=s.WebkitTouchCallout="none",s.touchAction=e.drag===!0?"none":`pan-${e.drag==="x"?"y":"x"}`),e.tabIndex===void 0&&(e.onTap||e.onTapStart||e.whileTap)&&(n.tabIndex=0),n.style=s,n}const wd={offset:"stroke-dashoffset",array:"stroke-dasharray"},Sd={offset:"strokeDashoffset",array:"strokeDasharray"};function Td(e,t,n=1,s=0,r=!0){e.pathLength=1;const o=r?wd:Sd;e[o.offset]=U.transform(-s);const i=U.transform(t),a=U.transform(n);e[o.array]=`${i} ${a}`}function Pa(e,{attrX:t,attrY:n,attrScale:s,pathLength:r,pathSpacing:o=1,pathOffset:i=0,...a},l,u,d){if(Xr(e,a,u),l){e.style.viewBox&&(e.attrs.viewBox=e.style.viewBox);return}e.attrs=e.style,e.style={};const{attrs:f,style:m}=e;f.transform&&(m.transform=f.transform,delete f.transform),(m.transform||f.transformOrigin)&&(m.transformOrigin=f.transformOrigin??"50% 50%",delete f.transformOrigin),m.transform&&(m.transformBox=d?.transformBox??"fill-box",delete f.transformBox),t!==void 0&&(f.x=t),n!==void 0&&(f.y=n),s!==void 0&&(f.scale=s),r!==void 0&&Td(f,r,o,i,!1)}const Aa=()=>({...Wr(),attrs:{}}),Ea=e=>typeof e=="string"&&e.toLowerCase()==="svg";function Cd(e,t,n,s){const r=h.useMemo(()=>{const o=Aa();return Pa(o,t,Ea(s),e.transformTemplate,e.style),{...o.attrs,style:{...o.style}}},[t]);if(e.style){const o={};ja(o,e.style,e),r.style={...o,...r.style}}return r}const jd=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function qr(e){return typeof e!="string"||e.includes("-")?!1:!!(jd.indexOf(e)>-1||/[A-Z]/u.test(e))}function Pd(e,t,n,{latestValues:s},r,o=!1){const a=(qr(e)?Cd:vd)(t,s,r,e),l=dd(t,typeof e=="string",o),u=e!==h.Fragment?{...l,...a,ref:n}:{},{children:d}=t,f=h.useMemo(()=>Ce(d)?d.get():d,[d]);return h.createElement(e,{...u,children:f})}function ki(e){const t=[{},{}];return e?.values.forEach((n,s)=>{t[0][s]=n.get(),t[1][s]=n.getVelocity()}),t}function Kr(e,t,n,s){if(typeof t=="function"){const[r,o]=ki(s);t=t(n!==void 0?n:e.custom,r,o)}if(typeof t=="string"&&(t=e.variants&&e.variants[t]),typeof t=="function"){const[r,o]=ki(s);t=t(n!==void 0?n:e.custom,r,o)}return t}function os(e){return Ce(e)?e.get():e}function Ad({scrapeMotionValuesFromProps:e,createRenderState:t},n,s,r){return{latestValues:Ed(n,s,r,e),renderState:t()}}function Ed(e,t,n,s){const r={},o=s(e,{});for(const m in o)r[m]=os(o[m]);let{initial:i,animate:a}=e;const l=xs(e),u=Ta(e);t&&u&&!l&&e.inherit!==!1&&(i===void 0&&(i=t.initial),a===void 0&&(a=t.animate));let d=n?n.initial===!1:!1;d=d||i===!1;const f=d?a:i;if(f&&typeof f!="boolean"&&!ys(f)){const m=Array.isArray(f)?f:[f];for(let p=0;p<m.length;p++){const S=Kr(e,m[p]);if(S){const{transitionEnd:v,transition:C,...b}=S;for(const M in b){let E=b[M];if(Array.isArray(E)){const $=d?E.length-1:0;E=E[$]}E!==null&&(r[M]=E)}for(const M in v)r[M]=v[M]}}}return r}const Ma=e=>(t,n)=>{const s=h.useContext(gs),r=h.useContext(ps),o=()=>Ad(e,t,s,r);return n?o():yr(o)};function Gr(e,t,n){const{style:s}=e,r={};for(const o in s)(Ce(s[o])||t.style&&Ce(t.style[o])||Ca(o,e)||n?.getValue(o)?.liveStyle!==void 0)&&(r[o]=s[o]);return r}const Md=Ma({scrapeMotionValuesFromProps:Gr,createRenderState:Wr});function ka(e,t,n){const s=Gr(e,t,n);for(const r in e)if(Ce(e[r])||Ce(t[r])){const o=nn.indexOf(r)!==-1?"attr"+r.charAt(0).toUpperCase()+r.substring(1):r;s[o]=e[r]}return s}const kd=Ma({scrapeMotionValuesFromProps:ka,createRenderState:Aa}),Nd=Symbol.for("motionComponentSymbol");function qt(e){return e&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"current")}function Rd(e,t,n){return h.useCallback(s=>{s&&e.onMount&&e.onMount(s),t&&(s?t.mount(s):t.unmount()),n&&(typeof n=="function"?n(s):qt(n)&&(n.current=s))},[t])}const Yr=e=>e.replace(/([a-z])([A-Z])/gu,"$1-$2").toLowerCase(),Dd="framerAppearId",Na="data-"+Yr(Dd),Ra=h.createContext({});function Vd(e,t,n,s,r){const{visualElement:o}=h.useContext(gs),i=h.useContext(Ur),a=h.useContext(ps),l=h.useContext(Br).reducedMotion,u=h.useRef(null);s=s||i.renderer,!u.current&&s&&(u.current=s(e,{visualState:t,parent:o,props:n,presenceContext:a,blockInitialAnimation:a?a.initial===!1:!1,reducedMotionConfig:l}));const d=u.current,f=h.useContext(Ra);d&&!d.projection&&r&&(d.type==="html"||d.type==="svg")&&Id(u.current,n,r,f);const m=h.useRef(!1);h.useInsertionEffect(()=>{d&&m.current&&d.update(n,a)});const p=n[Na],S=h.useRef(!!p&&!window.MotionHandoffIsComplete?.(p)&&window.MotionHasOptimisedAnimation?.(p));return ko(()=>{d&&(m.current=!0,window.MotionIsMounted=!0,d.updateFeatures(),d.scheduleRenderMicrotask(),S.current&&d.animationState&&d.animationState.animateChanges())}),h.useEffect(()=>{d&&(!S.current&&d.animationState&&d.animationState.animateChanges(),S.current&&(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(p)}),S.current=!1),d.enteringChildren=void 0)}),d}function Id(e,t,n,s){const{layoutId:r,layout:o,drag:i,dragConstraints:a,layoutScroll:l,layoutRoot:u,layoutCrossfade:d}=t;e.projection=new n(e.latestValues,t["data-framer-portal-id"]?void 0:Da(e.parent)),e.projection.setOptions({layoutId:r,layout:o,alwaysMeasureLayout:!!i||a&&qt(a),visualElement:e,animationType:typeof o=="string"?o:"both",initialPromotionConfig:s,crossfade:d,layoutScroll:l,layoutRoot:u})}function Da(e){if(e)return e.options.allowProjection!==!1?e.projection:Da(e.parent)}function as(e,{forwardMotionProps:t=!1}={},n,s){n&&ir(n);const r=qr(e)?kd:Md;function o(a,l){let u;const d={...h.useContext(Br),...a,layoutId:Od(a)},{isStatic:f}=d,m=hd(a),p=r(a,f);if(!f&&xr){Ld(d,n);const S=$d(d);u=S.MeasureLayout,m.visualElement=Vd(e,p,d,s,S.ProjectionNode)}return c.jsxs(gs.Provider,{value:m,children:[u&&m.visualElement?c.jsx(u,{visualElement:m.visualElement,...d}):null,Pd(e,a,Rd(p,m.visualElement,l),p,f,t)]})}o.displayName=`motion.${typeof e=="string"?e:`create(${e.displayName??e.name??""})`}`;const i=h.forwardRef(o);return i[Nd]=e,i}function Od({layoutId:e}){const t=h.useContext(gr).id;return t&&e!==void 0?t+"-"+e:e}function Ld(e,t){const n=h.useContext(Ur).strict;if(process.env.NODE_ENV!=="production"&&t&&n){const s="You have rendered a `motion` component within a `LazyMotion` component. This will break tree shaking. Import and render a `m` component instead.";e.ignoreStrict?en(!1,s,"lazy-strict-mode"):ot(!1,s,"lazy-strict-mode")}}function $d(e){const{drag:t,layout:n}=Qt;if(!t&&!n)return{};const s={...t,...n};return{MeasureLayout:t?.isEnabled(e)||n?.isEnabled(e)?s.MeasureLayout:void 0,ProjectionNode:s.ProjectionNode}}function Fd(e,t){if(typeof Proxy>"u")return as;const n=new Map,s=(o,i)=>as(o,i,e,t),r=(o,i)=>(process.env.NODE_ENV!=="production"&&Tr(!1,"motion() is deprecated. Use motion.create() instead."),s(o,i));return new Proxy(r,{get:(o,i)=>i==="create"?s:(n.has(i)||n.set(i,as(i,void 0,e,t)),n.get(i))})}function Va({top:e,left:t,right:n,bottom:s}){return{x:{min:t,max:n},y:{min:e,max:s}}}function Bd({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function Ud(e,t){if(!t)return e;const n=t({x:e.left,y:e.top}),s=t({x:e.right,y:e.bottom});return{top:n.y,left:n.x,bottom:s.y,right:s.x}}function Vs(e){return e===void 0||e===1}function or({scale:e,scaleX:t,scaleY:n}){return!Vs(e)||!Vs(t)||!Vs(n)}function kt(e){return or(e)||Ia(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function Ia(e){return Ni(e.x)||Ni(e.y)}function Ni(e){return e&&e!=="0%"}function hs(e,t,n){const s=e-n,r=t*s;return n+r}function Ri(e,t,n,s,r){return r!==void 0&&(e=hs(e,r,s)),hs(e,n,s)+t}function ar(e,t=0,n=1,s,r){e.min=Ri(e.min,t,n,s,r),e.max=Ri(e.max,t,n,s,r)}function Oa(e,{x:t,y:n}){ar(e.x,t.translate,t.scale,t.originPoint),ar(e.y,n.translate,n.scale,n.originPoint)}const Di=.999999999999,Vi=1.0000000000001;function zd(e,t,n,s=!1){const r=n.length;if(!r)return;t.x=t.y=1;let o,i;for(let a=0;a<r;a++){o=n[a],i=o.projectionDelta;const{visualElement:l}=o.options;l&&l.props.style&&l.props.style.display==="contents"||(s&&o.options.layoutScroll&&o.scroll&&o!==o.root&&Gt(e,{x:-o.scroll.offset.x,y:-o.scroll.offset.y}),i&&(t.x*=i.x.scale,t.y*=i.y.scale,Oa(e,i)),s&&kt(o.latestValues)&&Gt(e,o.latestValues))}t.x<Vi&&t.x>Di&&(t.x=1),t.y<Vi&&t.y>Di&&(t.y=1)}function Kt(e,t){e.min=e.min+t,e.max=e.max+t}function Ii(e,t,n,s,r=.5){const o=de(e.min,e.max,r);ar(e,t,n,o,s)}function Gt(e,t){Ii(e.x,t.x,t.scaleX,t.scale,t.originX),Ii(e.y,t.y,t.scaleY,t.scale,t.originY)}function La(e,t){return Va(Ud(e.getBoundingClientRect(),t))}function _d(e,t,n){const s=La(e,n),{scroll:r}=t;return r&&(Kt(s.x,r.offset.x),Kt(s.y,r.offset.y)),s}const Oi=()=>({translate:0,scale:1,origin:0,originPoint:0}),Yt=()=>({x:Oi(),y:Oi()}),Li=()=>({min:0,max:0}),pe=()=>({x:Li(),y:Li()}),lr={current:null},$a={current:!1};function Xd(){if($a.current=!0,!!xr)if(window.matchMedia){const e=window.matchMedia("(prefers-reduced-motion)"),t=()=>lr.current=e.matches;e.addEventListener("change",t),t()}else lr.current=!1}const Wd=new WeakMap;function qd(e,t,n){for(const s in t){const r=t[s],o=n[s];if(Ce(r))e.addValue(s,r);else if(Ce(o))e.addValue(s,Zt(r,{owner:e}));else if(o!==r)if(e.hasValue(s)){const i=e.getValue(s);i.liveStyle===!0?i.jump(r):i.hasAnimated||i.set(r)}else{const i=e.getStaticValue(s);e.addValue(s,Zt(i!==void 0?i:r,{owner:e}))}}for(const s in n)t[s]===void 0&&e.removeValue(s);return t}const $i=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];class Kd{scrapeMotionValuesFromProps(t,n,s){return{}}constructor({parent:t,props:n,presenceContext:s,reducedMotionConfig:r,blockInitialAnimation:o,visualState:i},a={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.values=new Map,this.KeyframeResolver=Ir,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},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 m=Ne.now();this.renderScheduledAt<m&&(this.renderScheduledAt=m,ce.render(this.render,!1,!0))};const{latestValues:l,renderState:u}=i;this.latestValues=l,this.baseTarget={...l},this.initialValues=n.initial?{...l}:{},this.renderState=u,this.parent=t,this.props=n,this.presenceContext=s,this.depth=t?t.depth+1:0,this.reducedMotionConfig=r,this.options=a,this.blockInitialAnimation=!!o,this.isControllingVariants=xs(n),this.isVariantNode=Ta(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(t&&t.current);const{willChange:d,...f}=this.scrapeMotionValuesFromProps(n,{},this);for(const m in f){const p=f[m];l[m]!==void 0&&Ce(p)&&p.set(l[m])}}mount(t){this.current=t,Wd.set(t,this),this.projection&&!this.projection.instance&&this.projection.mount(t),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((n,s)=>this.bindToMotionValue(s,n)),$a.current||Xd(),this.shouldReduceMotion=this.reducedMotionConfig==="never"?!1:this.reducedMotionConfig==="always"?!0:lr.current,process.env.NODE_ENV!=="production"&&Tr(this.shouldReduceMotion!==!0,"You have Reduced Motion enabled on your device. Animations may not appear as expected.","reduced-motion-disabled"),this.parent?.addChild(this),this.update(this.props,this.presenceContext)}unmount(){this.projection&&this.projection.unmount(),pt(this.notifyUpdate),pt(this.render),this.valueSubscriptions.forEach(t=>t()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent?.removeChild(this);for(const t in this.events)this.events[t].clear();for(const t in this.features){const n=this.features[t];n&&(n.unmount(),n.isMounted=!1)}this.current=null}addChild(t){this.children.add(t),this.enteringChildren??(this.enteringChildren=new Set),this.enteringChildren.add(t)}removeChild(t){this.children.delete(t),this.enteringChildren&&this.enteringChildren.delete(t)}bindToMotionValue(t,n){this.valueSubscriptions.has(t)&&this.valueSubscriptions.get(t)();const s=sn.has(t);s&&this.onBindTransform&&this.onBindTransform();const r=n.on("change",i=>{this.latestValues[t]=i,this.props.onUpdate&&ce.preRender(this.notifyUpdate),s&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});let o;window.MotionCheckAppearSync&&(o=window.MotionCheckAppearSync(this,t,n)),this.valueSubscriptions.set(t,()=>{r(),o&&o(),n.owner&&n.stop()})}sortNodePosition(t){return!this.current||!this.sortInstanceNodePosition||this.type!==t.type?0:this.sortInstanceNodePosition(this.current,t.current)}updateFeatures(){let t="animation";for(t in Qt){const n=Qt[t];if(!n)continue;const{isEnabled:s,Feature:r}=n;if(!this.features[t]&&r&&s(this.props)&&(this.features[t]=new r(this)),this.features[t]){const o=this.features[t];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):pe()}getStaticValue(t){return this.latestValues[t]}setStaticValue(t,n){this.latestValues[t]=n}update(t,n){(t.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=t,this.prevPresenceContext=this.presenceContext,this.presenceContext=n;for(let s=0;s<$i.length;s++){const r=$i[s];this.propEventSubscriptions[r]&&(this.propEventSubscriptions[r](),delete this.propEventSubscriptions[r]);const o="on"+r,i=t[o];i&&(this.propEventSubscriptions[r]=this.on(r,i))}this.prevMotionValues=qd(this,this.scrapeMotionValuesFromProps(t,this.prevProps,this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(t){return this.props.variants?this.props.variants[t]: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(t){const n=this.getClosestVariantNode();if(n)return n.variantChildren&&n.variantChildren.add(t),()=>n.variantChildren.delete(t)}addValue(t,n){const s=this.values.get(t);n!==s&&(s&&this.removeValue(t),this.bindToMotionValue(t,n),this.values.set(t,n),this.latestValues[t]=n.get())}removeValue(t){this.values.delete(t);const n=this.valueSubscriptions.get(t);n&&(n(),this.valueSubscriptions.delete(t)),delete this.latestValues[t],this.removeValueFromRenderState(t,this.renderState)}hasValue(t){return this.values.has(t)}getValue(t,n){if(this.props.values&&this.props.values[t])return this.props.values[t];let s=this.values.get(t);return s===void 0&&n!==void 0&&(s=Zt(n===null?void 0:n,{owner:this}),this.addValue(t,s)),s}readValue(t,n){let s=this.latestValues[t]!==void 0||!this.current?this.latestValues[t]:this.getBaseTargetFromProps(this.props,t)??this.readValueFromInstance(this.current,t,this.options);return s!=null&&(typeof s=="string"&&(No(s)||Do(s))?s=parseFloat(s):!ed(s)&>.test(n)&&(s=ma(t,n)),this.setBaseTarget(t,Ce(s)?s.get():s)),Ce(s)?s.get():s}setBaseTarget(t,n){this.baseTarget[t]=n}getBaseTarget(t){const{initial:n}=this.props;let s;if(typeof n=="string"||typeof n=="object"){const o=Kr(this.props,n,this.presenceContext?.custom);o&&(s=o[t])}if(n&&s!==void 0)return s;const r=this.getBaseTargetFromProps(this.props,t);return r!==void 0&&!Ce(r)?r:this.initialValues[t]!==void 0&&s===void 0?void 0:this.baseTarget[t]}on(t,n){return this.events[t]||(this.events[t]=new Sr),this.events[t].add(n)}notify(t,...n){this.events[t]&&this.events[t].notify(...n)}scheduleRenderMicrotask(){$r.render(this.render)}}class Fa extends Kd{constructor(){super(...arguments),this.KeyframeResolver=zu}sortInstanceNodePosition(t,n){return t.compareDocumentPosition(n)&2?1:-1}getBaseTargetFromProps(t,n){return t.style?t.style[n]:void 0}removeValueFromRenderState(t,{vars:n,style:s}){delete n[t],delete s[t]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:t}=this.props;Ce(t)&&(this.childSubscription=t.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}function Ba(e,{style:t,vars:n},s,r){const o=e.style;let i;for(i in t)o[i]=t[i];r?.applyProjectionStyles(o,s);for(i in n)o.setProperty(i,n[i])}function Gd(e){return window.getComputedStyle(e)}class Yd extends Fa{constructor(){super(...arguments),this.type="html",this.renderInstance=Ba}readValueFromInstance(t,n){if(sn.has(n))return this.projection?.isProjecting?Zs(n):ou(t,n);{const s=Gd(t),r=(Pr(n)?s.getPropertyValue(n):s[n])||0;return typeof r=="string"?r.trim():r}}measureInstanceViewportBox(t,{transformPagePoint:n}){return La(t,n)}build(t,n,s){Xr(t,n,s.transformTemplate)}scrapeMotionValuesFromProps(t,n,s){return Gr(t,n,s)}}const Ua=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"]);function Hd(e,t,n,s){Ba(e,t,void 0,s);for(const r in t.attrs)e.setAttribute(Ua.has(r)?r:Yr(r),t.attrs[r])}class Jd extends Fa{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=pe}getBaseTargetFromProps(t,n){return t[n]}readValueFromInstance(t,n){if(sn.has(n)){const s=ha(n);return s&&s.default||0}return n=Ua.has(n)?n:Yr(n),t.getAttribute(n)}scrapeMotionValuesFromProps(t,n,s){return ka(t,n,s)}build(t,n,s){Pa(t,n,this.isSVGTag,s.transformTemplate,s.style)}renderInstance(t,n,s,r){Hd(t,n,s,r)}mount(t){this.isSVGTag=Ea(t.tagName),super.mount(t)}}const za=(e,t)=>qr(e)?new Jd(t):new Yd(t,{allowProjection:e!==h.Fragment});function Jt(e,t,n){const s=e.getProps();return Kr(s,t,n!==void 0?n:s.custom,e)}const cr=e=>Array.isArray(e);function Zd(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,Zt(n))}function Qd(e){return cr(e)?e[e.length-1]||0:e}function ef(e,t){const n=Jt(e,t);let{transitionEnd:s={},transition:r={},...o}=n||{};o={...o,...s};for(const i in o){const a=Qd(o[i]);Zd(e,i,a)}}function tf(e){return!!(Ce(e)&&e.add)}function ur(e,t){const n=e.getValue("willChange");if(tf(n))return n.add(t);if(!n&&at.WillChange){const s=new at.WillChange("auto");e.addValue("willChange",s),s.add(t)}}function _a(e){return e.props[Na]}const nf=e=>e!==null;function sf(e,{repeat:t,repeatType:n="loop"},s){const r=e.filter(nf),o=t&&n!=="loop"&&t%2===1?0:r.length-1;return r[o]}const rf={type:"spring",stiffness:500,damping:25,restSpeed:10},of=e=>({type:"spring",stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),af={type:"keyframes",duration:.8},lf={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},cf=(e,{keyframes:t})=>t.length>2?af:sn.has(e)?e.startsWith("scale")?of(t[1]):rf:lf;function uf({when:e,delay:t,delayChildren:n,staggerChildren:s,staggerDirection:r,repeat:o,repeatType:i,repeatDelay:a,from:l,elapsed:u,...d}){return!!Object.keys(d).length}const Hr=(e,t,n,s={},r,o)=>i=>{const a=Or(s,e)||{},l=a.delay||s.delay||0;let{elapsed:u=0}=s;u=u-Ke(l);const d={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:t.getVelocity(),...a,delay:-u,onUpdate:m=>{t.set(m),a.onUpdate&&a.onUpdate(m)},onComplete:()=>{i(),a.onComplete&&a.onComplete()},name:e,motionValue:t,element:o?void 0:r};uf(a)||Object.assign(d,cf(e,d)),d.duration&&(d.duration=Ke(d.duration)),d.repeatDelay&&(d.repeatDelay=Ke(d.repeatDelay)),d.from!==void 0&&(d.keyframes[0]=d.from);let f=!1;if((d.type===!1||d.duration===0&&!d.repeatDelay)&&(sr(d),d.delay===0&&(f=!0)),(at.instantAnimations||at.skipAnimations)&&(f=!0,sr(d),d.delay=0),d.allowFlatten=!a.type&&!a.ease,f&&!o&&t.get()!==void 0){const m=sf(d.keyframes,a);if(m!==void 0){ce.update(()=>{d.onUpdate(m),d.onComplete()});return}}return a.isSync?new Vr(d):new Mu(d)};function df({protectedKeys:e,needsAnimating:t},n){const s=e.hasOwnProperty(n)&&t[n]!==!0;return t[n]=!1,s}function Xa(e,t,{delay:n=0,transitionOverride:s,type:r}={}){let{transition:o=e.getDefaultTransition(),transitionEnd:i,...a}=t;s&&(o=s);const l=[],u=r&&e.animationState&&e.animationState.getState()[r];for(const d in a){const f=e.getValue(d,e.latestValues[d]??null),m=a[d];if(m===void 0||u&&df(u,d))continue;const p={delay:n,...Or(o||{},d)},S=f.get();if(S!==void 0&&!f.isAnimating&&!Array.isArray(m)&&m===S&&!p.velocity)continue;let v=!1;if(window.MotionHandoffAnimation){const b=_a(e);if(b){const M=window.MotionHandoffAnimation(b,d,ce);M!==null&&(p.startTime=M,v=!0)}}ur(e,d),f.start(Hr(d,f,m,e.shouldReduceMotion&&ua.has(d)?{type:!1}:p,e,v));const C=f.animation;C&&l.push(C)}return i&&Promise.all(l).then(()=>{ce.update(()=>{i&&ef(e,i)})}),l}function Wa(e,t,n,s=0,r=1){const o=Array.from(e).sort((u,d)=>u.sortNodePosition(d)).indexOf(t),i=e.size,a=(i-1)*s;return typeof n=="function"?n(o,i):r===1?o*s:a-o*s}function dr(e,t,n={}){const s=Jt(e,t,n.type==="exit"?e.presenceContext?.custom:void 0);let{transition:r=e.getDefaultTransition()||{}}=s||{};n.transitionOverride&&(r=n.transitionOverride);const o=s?()=>Promise.all(Xa(e,s,n)):()=>Promise.resolve(),i=e.variantChildren&&e.variantChildren.size?(l=0)=>{const{delayChildren:u=0,staggerChildren:d,staggerDirection:f}=r;return ff(e,t,l,u,d,f,n)}:()=>Promise.resolve(),{when:a}=r;if(a){const[l,u]=a==="beforeChildren"?[o,i]:[i,o];return l().then(()=>u())}else return Promise.all([o(),i(n.delay)])}function ff(e,t,n=0,s=0,r=0,o=1,i){const a=[];for(const l of e.variantChildren)l.notify("AnimationStart",t),a.push(dr(l,t,{...i,delay:n+(typeof s=="function"?0:s)+Wa(e.variantChildren,l,s,r,o)}).then(()=>l.notify("AnimationComplete",t)));return Promise.all(a)}function hf(e,t,n={}){e.notify("AnimationStart",t);let s;if(Array.isArray(t)){const r=t.map(o=>dr(e,o,n));s=Promise.all(r)}else if(typeof t=="string")s=dr(e,t,n);else{const r=typeof t=="function"?Jt(e,t,n.custom):t;s=Promise.all(Xa(e,r,n))}return s.then(()=>{e.notify("AnimationComplete",t)})}function qa(e,t){if(!Array.isArray(t))return!1;const n=t.length;if(n!==e.length)return!1;for(let s=0;s<n;s++)if(t[s]!==e[s])return!1;return!0}const mf=_r.length;function Ka(e){if(!e)return;if(!e.isControllingVariants){const n=e.parent?Ka(e.parent)||{}:{};return e.props.initial!==void 0&&(n.initial=e.props.initial),n}const t={};for(let n=0;n<mf;n++){const s=_r[n],r=e.props[s];(On(r)||r===!1)&&(t[s]=r)}return t}const pf=[...zr].reverse(),gf=zr.length;function yf(e){return t=>Promise.all(t.map(({animation:n,options:s})=>hf(e,n,s)))}function xf(e){let t=yf(e),n=Fi(),s=!0;const r=l=>(u,d)=>{const f=Jt(e,d,l==="exit"?e.presenceContext?.custom:void 0);if(f){const{transition:m,transitionEnd:p,...S}=f;u={...u,...S,...p}}return u};function o(l){t=l(e)}function i(l){const{props:u}=e,d=Ka(e.parent)||{},f=[],m=new Set;let p={},S=1/0;for(let C=0;C<gf;C++){const b=pf[C],M=n[b],E=u[b]!==void 0?u[b]:d[b],$=On(E),R=b===l?M.isActive:null;R===!1&&(S=C);let I=E===d[b]&&E!==u[b]&&$;if(I&&s&&e.manuallyAnimateOnMount&&(I=!1),M.protectedKeys={...p},!M.isActive&&R===null||!E&&!M.prevProp||ys(E)||typeof E=="boolean")continue;const N=bf(M.prevProp,E);let P=N||b===l&&M.isActive&&!I&&$||C>S&&$,O=!1;const A=Array.isArray(E)?E:[E];let k=A.reduce(r(b),{});R===!1&&(k={});const{prevResolvedValues:F={}}=M,V={...F,...k},B=G=>{P=!0,m.has(G)&&(O=!0,m.delete(G)),M.needsAnimating[G]=!0;const ie=e.getValue(G);ie&&(ie.liveStyle=!1)};for(const G in V){const ie=k[G],ye=F[G];if(p.hasOwnProperty(G))continue;let Ge=!1;cr(ie)&&cr(ye)?Ge=!qa(ie,ye):Ge=ie!==ye,Ge?ie!=null?B(G):m.add(G):ie!==void 0&&m.has(G)?B(G):M.protectedKeys[G]=!0}M.prevProp=E,M.prevResolvedValues=k,M.isActive&&(p={...p,...k}),s&&e.blockInitialAnimation&&(P=!1);const W=I&&N;P&&(!W||O)&&f.push(...A.map(G=>{const ie={type:b};if(typeof G=="string"&&s&&!W&&e.manuallyAnimateOnMount&&e.parent){const{parent:ye}=e,Ge=Jt(ye,G);if(ye.enteringChildren&&Ge){const{delayChildren:xt}=Ge.transition||{};ie.delay=Wa(ye.enteringChildren,e,xt)}}return{animation:G,options:ie}}))}if(m.size){const C={};if(typeof u.initial!="boolean"){const b=Jt(e,Array.isArray(u.initial)?u.initial[0]:u.initial);b&&b.transition&&(C.transition=b.transition)}m.forEach(b=>{const M=e.getBaseTarget(b),E=e.getValue(b);E&&(E.liveStyle=!0),C[b]=M??null}),f.push({animation:C})}let v=!!f.length;return s&&(u.initial===!1||u.initial===u.animate)&&!e.manuallyAnimateOnMount&&(v=!1),s=!1,v?t(f):Promise.resolve()}function a(l,u){if(n[l].isActive===u)return Promise.resolve();e.variantChildren?.forEach(f=>f.animationState?.setActive(l,u)),n[l].isActive=u;const d=i(l);for(const f in n)n[f].protectedKeys={};return d}return{animateChanges:i,setActive:a,setAnimateFunction:o,getState:()=>n,reset:()=>{n=Fi()}}}function bf(e,t){return typeof t=="string"?t!==e:Array.isArray(t)?!qa(t,e):!1}function Et(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function Fi(){return{animate:Et(!0),whileInView:Et(),whileHover:Et(),whileTap:Et(),whileDrag:Et(),whileFocus:Et(),exit:Et()}}class yt{constructor(t){this.isMounted=!1,this.node=t}update(){}}class vf extends yt{constructor(t){super(t),t.animationState||(t.animationState=xf(t))}updateAnimationControlsSubscription(){const{animate:t}=this.node.getProps();ys(t)&&(this.unmountControls=t.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:t}=this.node.getProps(),{animate:n}=this.node.prevProps||{};t!==n&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}}let wf=0;class Sf extends yt{constructor(){super(...arguments),this.id=wf++}update(){if(!this.node.presenceContext)return;const{isPresent:t,onExitComplete:n}=this.node.presenceContext,{isPresent:s}=this.node.prevPresenceContext||{};if(!this.node.animationState||t===s)return;const r=this.node.animationState.setActive("exit",!t);n&&!t&&r.then(()=>{n(this.id)})}mount(){const{register:t,onExitComplete:n}=this.node.presenceContext||{};n&&n(this.id),t&&(this.unmount=t(this.id))}unmount(){}}const Ga={animation:{Feature:vf},exit:{Feature:Sf}};function $n(e,t,n,s={passive:!0}){return e.addEventListener(t,n,s),()=>e.removeEventListener(t,n)}function zn(e){return{point:{x:e.pageX,y:e.pageY}}}const Tf=e=>t=>Fr(t)&&e(t,zn(t));function Mn(e,t,n,s){return $n(e,t,Tf(n),s)}const Ya=1e-4,Cf=1-Ya,jf=1+Ya,Ha=.01,Pf=0-Ha,Af=0+Ha;function Ee(e){return e.max-e.min}function Ef(e,t,n){return Math.abs(e-t)<=n}function Bi(e,t,n,s=.5){e.origin=s,e.originPoint=de(t.min,t.max,e.origin),e.scale=Ee(n)/Ee(t),e.translate=de(n.min,n.max,e.origin)-e.originPoint,(e.scale>=Cf&&e.scale<=jf||isNaN(e.scale))&&(e.scale=1),(e.translate>=Pf&&e.translate<=Af||isNaN(e.translate))&&(e.translate=0)}function kn(e,t,n,s){Bi(e.x,t.x,n.x,s?s.originX:void 0),Bi(e.y,t.y,n.y,s?s.originY:void 0)}function Ui(e,t,n){e.min=n.min+t.min,e.max=e.min+Ee(t)}function Mf(e,t,n){Ui(e.x,t.x,n.x),Ui(e.y,t.y,n.y)}function zi(e,t,n){e.min=t.min-n.min,e.max=e.min+Ee(t)}function Nn(e,t,n){zi(e.x,t.x,n.x),zi(e.y,t.y,n.y)}function Oe(e){return[e("x"),e("y")]}const Ja=({current:e})=>e?e.ownerDocument.defaultView:null,_i=(e,t)=>Math.abs(e-t);function kf(e,t){const n=_i(e.x,t.x),s=_i(e.y,t.y);return Math.sqrt(n**2+s**2)}class Za{constructor(t,n,{transformPagePoint:s,contextWindow:r=window,dragSnapToOrigin:o=!1,distanceThreshold:i=3}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const m=Os(this.lastMoveEventInfo,this.history),p=this.startEvent!==null,S=kf(m.offset,{x:0,y:0})>=this.distanceThreshold;if(!p&&!S)return;const{point:v}=m,{timestamp:C}=Se;this.history.push({...v,timestamp:C});const{onStart:b,onMove:M}=this.handlers;p||(b&&b(this.lastMoveEvent,m),this.startEvent=this.lastMoveEvent),M&&M(this.lastMoveEvent,m)},this.handlePointerMove=(m,p)=>{this.lastMoveEvent=m,this.lastMoveEventInfo=Is(p,this.transformPagePoint),ce.update(this.updatePoint,!0)},this.handlePointerUp=(m,p)=>{this.end();const{onEnd:S,onSessionEnd:v,resumeAnimation:C}=this.handlers;if(this.dragSnapToOrigin&&C&&C(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const b=Os(m.type==="pointercancel"?this.lastMoveEventInfo:Is(p,this.transformPagePoint),this.history);this.startEvent&&S&&S(m,b),v&&v(m,b)},!Fr(t))return;this.dragSnapToOrigin=o,this.handlers=n,this.transformPagePoint=s,this.distanceThreshold=i,this.contextWindow=r||window;const a=zn(t),l=Is(a,this.transformPagePoint),{point:u}=l,{timestamp:d}=Se;this.history=[{...u,timestamp:d}];const{onSessionStart:f}=n;f&&f(t,Os(l,this.history)),this.removeListeners=Fn(Mn(this.contextWindow,"pointermove",this.handlePointerMove),Mn(this.contextWindow,"pointerup",this.handlePointerUp),Mn(this.contextWindow,"pointercancel",this.handlePointerUp))}updateHandlers(t){this.handlers=t}end(){this.removeListeners&&this.removeListeners(),pt(this.updatePoint)}}function Is(e,t){return t?{point:t(e.point)}:e}function Xi(e,t){return{x:e.x-t.x,y:e.y-t.y}}function Os({point:e},t){return{point:e,delta:Xi(e,Qa(t)),offset:Xi(e,Nf(t)),velocity:Rf(t,.1)}}function Nf(e){return e[0]}function Qa(e){return e[e.length-1]}function Rf(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,s=null;const r=Qa(e);for(;n>=0&&(s=e[n],!(r.timestamp-s.timestamp>Ke(t)));)n--;if(!s)return{x:0,y:0};const o=$e(r.timestamp-s.timestamp);if(o===0)return{x:0,y:0};const i={x:(r.x-s.x)/o,y:(r.y-s.y)/o};return i.x===1/0&&(i.x=0),i.y===1/0&&(i.y=0),i}function Df(e,{min:t,max:n},s){return t!==void 0&&e<t?e=s?de(t,e,s.min):Math.max(e,t):n!==void 0&&e>n&&(e=s?de(n,e,s.max):Math.min(e,n)),e}function Wi(e,t,n){return{min:t!==void 0?e.min+t:void 0,max:n!==void 0?e.max+n-(e.max-e.min):void 0}}function Vf(e,{top:t,left:n,bottom:s,right:r}){return{x:Wi(e.x,n,r),y:Wi(e.y,t,s)}}function qi(e,t){let n=t.min-e.min,s=t.max-e.max;return t.max-t.min<e.max-e.min&&([n,s]=[s,n]),{min:n,max:s}}function If(e,t){return{x:qi(e.x,t.x),y:qi(e.y,t.y)}}function Of(e,t){let n=.5;const s=Ee(e),r=Ee(t);return r>s?n=Dn(t.min,t.max-s,e.min):s>r&&(n=Dn(e.min,e.max-r,t.min)),it(0,1,n)}function Lf(e,t){const n={};return t.min!==void 0&&(n.min=t.min-e.min),t.max!==void 0&&(n.max=t.max-e.min),n}const fr=.35;function $f(e=fr){return e===!1?e=0:e===!0&&(e=fr),{x:Ki(e,"left","right"),y:Ki(e,"top","bottom")}}function Ki(e,t,n){return{min:Gi(e,t),max:Gi(e,n)}}function Gi(e,t){return typeof e=="number"?e:e[t]||0}const Ff=new WeakMap;class Bf{constructor(t){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=pe(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=t}start(t,{snapToCursor:n=!1,distanceThreshold:s}={}){const{presenceContext:r}=this.visualElement;if(r&&r.isPresent===!1)return;const o=f=>{const{dragSnapToOrigin:m}=this.getProps();m?this.pauseAnimation():this.stopAnimation(),n&&this.snapToCursor(zn(f).point)},i=(f,m)=>{const{drag:p,dragPropagation:S,onDragStart:v}=this.getProps();if(p&&!S&&(this.openDragLock&&this.openDragLock(),this.openDragLock=qu(p),!this.openDragLock))return;this.latestPointerEvent=f,this.latestPanInfo=m,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),Oe(b=>{let M=this.getAxisMotionValue(b).get()||0;if(tt.test(M)){const{projection:E}=this.visualElement;if(E&&E.layout){const $=E.layout.layoutBox[b];$&&(M=Ee($)*(parseFloat(M)/100))}}this.originPoint[b]=M}),v&&ce.postRender(()=>v(f,m)),ur(this.visualElement,"transform");const{animationState:C}=this.visualElement;C&&C.setActive("whileDrag",!0)},a=(f,m)=>{this.latestPointerEvent=f,this.latestPanInfo=m;const{dragPropagation:p,dragDirectionLock:S,onDirectionLock:v,onDrag:C}=this.getProps();if(!p&&!this.openDragLock)return;const{offset:b}=m;if(S&&this.currentDirection===null){this.currentDirection=Uf(b),this.currentDirection!==null&&v&&v(this.currentDirection);return}this.updateAxis("x",m.point,b),this.updateAxis("y",m.point,b),this.visualElement.render(),C&&C(f,m)},l=(f,m)=>{this.latestPointerEvent=f,this.latestPanInfo=m,this.stop(f,m),this.latestPointerEvent=null,this.latestPanInfo=null},u=()=>Oe(f=>this.getAnimationState(f)==="paused"&&this.getAxisMotionValue(f).animation?.play()),{dragSnapToOrigin:d}=this.getProps();this.panSession=new Za(t,{onSessionStart:o,onStart:i,onMove:a,onSessionEnd:l,resumeAnimation:u},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:d,distanceThreshold:s,contextWindow:Ja(this.visualElement)})}stop(t,n){const s=t||this.latestPointerEvent,r=n||this.latestPanInfo,o=this.isDragging;if(this.cancel(),!o||!r||!s)return;const{velocity:i}=r;this.startAnimation(i);const{onDragEnd:a}=this.getProps();a&&ce.postRender(()=>a(s,r))}cancel(){this.isDragging=!1;const{projection:t,animationState:n}=this.visualElement;t&&(t.isAnimationBlocked=!1),this.panSession&&this.panSession.end(),this.panSession=void 0;const{dragPropagation:s}=this.getProps();!s&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),n&&n.setActive("whileDrag",!1)}updateAxis(t,n,s){const{drag:r}=this.getProps();if(!s||!es(t,r,this.currentDirection))return;const o=this.getAxisMotionValue(t);let i=this.originPoint[t]+s[t];this.constraints&&this.constraints[t]&&(i=Df(i,this.constraints[t],this.elastic[t])),o.set(i)}resolveConstraints(){const{dragConstraints:t,dragElastic:n}=this.getProps(),s=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,r=this.constraints;t&&qt(t)?this.constraints||(this.constraints=this.resolveRefConstraints()):t&&s?this.constraints=Vf(s.layoutBox,t):this.constraints=!1,this.elastic=$f(n),r!==this.constraints&&s&&this.constraints&&!this.hasMutatedConstraints&&Oe(o=>{this.constraints!==!1&&this.getAxisMotionValue(o)&&(this.constraints[o]=Lf(s.layoutBox[o],this.constraints[o]))})}resolveRefConstraints(){const{dragConstraints:t,onMeasureDragConstraints:n}=this.getProps();if(!t||!qt(t))return!1;const s=t.current;ot(s!==null,"If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.","drag-constraints-ref");const{projection:r}=this.visualElement;if(!r||!r.layout)return!1;const o=_d(s,r.root,this.visualElement.getTransformPagePoint());let i=If(r.layout.layoutBox,o);if(n){const a=n(Bd(i));this.hasMutatedConstraints=!!a,a&&(i=Va(a))}return i}startAnimation(t){const{drag:n,dragMomentum:s,dragElastic:r,dragTransition:o,dragSnapToOrigin:i,onDragTransitionEnd:a}=this.getProps(),l=this.constraints||{},u=Oe(d=>{if(!es(d,n,this.currentDirection))return;let f=l&&l[d]||{};i&&(f={min:0,max:0});const m=r?200:1e6,p=r?40:1e7,S={type:"inertia",velocity:s?t[d]:0,bounceStiffness:m,bounceDamping:p,timeConstant:750,restDelta:1,restSpeed:10,...o,...f};return this.startAxisValueAnimation(d,S)});return Promise.all(u).then(a)}startAxisValueAnimation(t,n){const s=this.getAxisMotionValue(t);return ur(this.visualElement,t),s.start(Hr(t,s,0,n,this.visualElement,!1))}stopAnimation(){Oe(t=>this.getAxisMotionValue(t).stop())}pauseAnimation(){Oe(t=>this.getAxisMotionValue(t).animation?.pause())}getAnimationState(t){return this.getAxisMotionValue(t).animation?.state}getAxisMotionValue(t){const n=`_drag${t.toUpperCase()}`,s=this.visualElement.getProps(),r=s[n];return r||this.visualElement.getValue(t,(s.initial?s.initial[t]:void 0)||0)}snapToCursor(t){Oe(n=>{const{drag:s}=this.getProps();if(!es(n,s,this.currentDirection))return;const{projection:r}=this.visualElement,o=this.getAxisMotionValue(n);if(r&&r.layout){const{min:i,max:a}=r.layout.layoutBox[n];o.set(t[n]-de(i,a,.5))}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:t,dragConstraints:n}=this.getProps(),{projection:s}=this.visualElement;if(!qt(n)||!s||!this.constraints)return;this.stopAnimation();const r={x:0,y:0};Oe(i=>{const a=this.getAxisMotionValue(i);if(a&&this.constraints!==!1){const l=a.get();r[i]=Of({min:l,max:l},this.constraints[i])}});const{transformTemplate:o}=this.visualElement.getProps();this.visualElement.current.style.transform=o?o({},""):"none",s.root&&s.root.updateScroll(),s.updateLayout(),this.resolveConstraints(),Oe(i=>{if(!es(i,t,null))return;const a=this.getAxisMotionValue(i),{min:l,max:u}=this.constraints[i];a.set(de(l,u,r[i]))})}addListeners(){if(!this.visualElement.current)return;Ff.set(this.visualElement,this);const t=this.visualElement.current,n=Mn(t,"pointerdown",l=>{const{drag:u,dragListener:d=!0}=this.getProps();u&&d&&this.start(l)}),s=()=>{const{dragConstraints:l}=this.getProps();qt(l)&&l.current&&(this.constraints=this.resolveRefConstraints())},{projection:r}=this.visualElement,o=r.addEventListener("measure",s);r&&!r.layout&&(r.root&&r.root.updateScroll(),r.updateLayout()),ce.read(s);const i=$n(window,"resize",()=>this.scalePositionWithinConstraints()),a=r.addEventListener("didUpdate",({delta:l,hasLayoutChanged:u})=>{this.isDragging&&u&&(Oe(d=>{const f=this.getAxisMotionValue(d);f&&(this.originPoint[d]+=l[d].translate,f.set(f.get()+l[d].translate))}),this.visualElement.render())});return()=>{i(),n(),o(),a&&a()}}getProps(){const t=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:s=!1,dragPropagation:r=!1,dragConstraints:o=!1,dragElastic:i=fr,dragMomentum:a=!0}=t;return{...t,drag:n,dragDirectionLock:s,dragPropagation:r,dragConstraints:o,dragElastic:i,dragMomentum:a}}}function es(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function Uf(e,t=10){let n=null;return Math.abs(e.y)>t?n="y":Math.abs(e.x)>t&&(n="x"),n}class zf extends yt{constructor(t){super(t),this.removeGroupControls=Fe,this.removeListeners=Fe,this.controls=new Bf(t)}mount(){const{dragControls:t}=this.node.getProps();t&&(this.removeGroupControls=t.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||Fe}unmount(){this.removeGroupControls(),this.removeListeners()}}const Yi=e=>(t,n)=>{e&&ce.postRender(()=>e(t,n))};class _f extends yt{constructor(){super(...arguments),this.removePointerDownListener=Fe}onPointerDown(t){this.session=new Za(t,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:Ja(this.node)})}createPanHandlers(){const{onPanSessionStart:t,onPanStart:n,onPan:s,onPanEnd:r}=this.node.getProps();return{onSessionStart:Yi(t),onStart:Yi(n),onMove:s,onEnd:(o,i)=>{delete this.session,r&&ce.postRender(()=>r(o,i))}}}mount(){this.removePointerDownListener=Mn(this.node.current,"pointerdown",t=>this.onPointerDown(t))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}const ls={hasAnimatedSinceResize:!0,hasEverUpdated:!1};function Hi(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}const Cn={correct:(e,t)=>{if(!t.target)return e;if(typeof e=="string")if(U.test(e))e=parseFloat(e);else return e;const n=Hi(e,t.target.x),s=Hi(e,t.target.y);return`${n}% ${s}%`}},Xf={correct:(e,{treeScale:t,projectionDelta:n})=>{const s=e,r=gt.parse(e);if(r.length>5)return s;const o=gt.createTransformer(e),i=typeof r[0]!="number"?1:0,a=n.x.scale*t.x,l=n.y.scale*t.y;r[0+i]/=a,r[1+i]/=l;const u=de(a,l,.5);return typeof r[2+i]=="number"&&(r[2+i]/=u),typeof r[3+i]=="number"&&(r[3+i]/=u),o(r)}};let Ls=!1;class Wf extends h.Component{componentDidMount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:s,layoutId:r}=this.props,{projection:o}=t;md(qf),o&&(n.group&&n.group.add(o),s&&s.register&&r&&s.register(o),Ls&&o.root.didUpdate(),o.addEventListener("animationComplete",()=>{this.safeToRemove()}),o.setOptions({...o.options,onExitComplete:()=>this.safeToRemove()})),ls.hasEverUpdated=!0}getSnapshotBeforeUpdate(t){const{layoutDependency:n,visualElement:s,drag:r,isPresent:o}=this.props,{projection:i}=s;return i&&(i.isPresent=o,Ls=!0,r||t.layoutDependency!==n||n===void 0||t.isPresent!==o?i.willUpdate():this.safeToRemove(),t.isPresent!==o&&(o?i.promote():i.relegate()||ce.postRender(()=>{const a=i.getStack();(!a||!a.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:t}=this.props.visualElement;t&&(t.root.didUpdate(),$r.postRender(()=>{!t.currentAnimation&&t.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:s}=this.props,{projection:r}=t;Ls=!0,r&&(r.scheduleCheckAfterUnmount(),n&&n.group&&n.group.remove(r),s&&s.deregister&&s.deregister(r))}safeToRemove(){const{safeToRemove:t}=this.props;t&&t()}render(){return null}}function el(e){const[t,n]=wa(),s=h.useContext(gr);return c.jsx(Wf,{...e,layoutGroup:s,switchLayoutGroup:h.useContext(Ra),isPresent:t,safeToRemove:n})}const qf={borderRadius:{...Cn,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:Cn,borderTopRightRadius:Cn,borderBottomLeftRadius:Cn,borderBottomRightRadius:Cn,boxShadow:Xf};function Kf(e,t,n){const s=Ce(e)?e:Zt(e);return s.start(Hr("",s,t,n)),s.animation}const Gf=(e,t)=>e.depth-t.depth;class Yf{constructor(){this.children=[],this.isDirty=!1}add(t){br(this.children,t),this.isDirty=!0}remove(t){vr(this.children,t),this.isDirty=!0}forEach(t){this.isDirty&&this.children.sort(Gf),this.isDirty=!1,this.children.forEach(t)}}function Hf(e,t){const n=Ne.now(),s=({timestamp:r})=>{const o=r-n;o>=t&&(pt(s),e(o-t))};return ce.setup(s,!0),()=>pt(s)}const tl=["TopLeft","TopRight","BottomLeft","BottomRight"],Jf=tl.length,Ji=e=>typeof e=="string"?parseFloat(e):e,Zi=e=>typeof e=="number"||U.test(e);function Zf(e,t,n,s,r,o){r?(e.opacity=de(0,n.opacity??1,Qf(s)),e.opacityExit=de(t.opacity??1,0,eh(s))):o&&(e.opacity=de(t.opacity??1,n.opacity??1,s));for(let i=0;i<Jf;i++){const a=`border${tl[i]}Radius`;let l=Qi(t,a),u=Qi(n,a);if(l===void 0&&u===void 0)continue;l||(l=0),u||(u=0),l===0||u===0||Zi(l)===Zi(u)?(e[a]=Math.max(de(Ji(l),Ji(u),s),0),(tt.test(u)||tt.test(l))&&(e[a]+="%")):e[a]=u}(t.rotate||n.rotate)&&(e.rotate=de(t.rotate||0,n.rotate||0,s))}function Qi(e,t){return e[t]!==void 0?e[t]:e.borderRadius}const Qf=nl(0,.5,Uo),eh=nl(.5,.95,Fe);function nl(e,t,n){return s=>s<e?0:s>t?1:n(Dn(e,t,s))}function eo(e,t){e.min=t.min,e.max=t.max}function Ie(e,t){eo(e.x,t.x),eo(e.y,t.y)}function to(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}function no(e,t,n,s,r){return e-=t,e=hs(e,1/n,s),r!==void 0&&(e=hs(e,1/r,s)),e}function th(e,t=0,n=1,s=.5,r,o=e,i=e){if(tt.test(t)&&(t=parseFloat(t),t=de(i.min,i.max,t/100)-i.min),typeof t!="number")return;let a=de(o.min,o.max,s);e===o&&(a-=t),e.min=no(e.min,t,n,a,r),e.max=no(e.max,t,n,a,r)}function so(e,t,[n,s,r],o,i){th(e,t[n],t[s],t[r],t.scale,o,i)}const nh=["x","scaleX","originX"],sh=["y","scaleY","originY"];function ro(e,t,n,s){so(e.x,t,nh,n?n.x:void 0,s?s.x:void 0),so(e.y,t,sh,n?n.y:void 0,s?s.y:void 0)}function io(e){return e.translate===0&&e.scale===1}function sl(e){return io(e.x)&&io(e.y)}function oo(e,t){return e.min===t.min&&e.max===t.max}function rh(e,t){return oo(e.x,t.x)&&oo(e.y,t.y)}function ao(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function rl(e,t){return ao(e.x,t.x)&&ao(e.y,t.y)}function lo(e){return Ee(e.x)/Ee(e.y)}function co(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}class ih{constructor(){this.members=[]}add(t){br(this.members,t),t.scheduleRender()}remove(t){if(vr(this.members,t),t===this.prevLead&&(this.prevLead=void 0),t===this.lead){const n=this.members[this.members.length-1];n&&this.promote(n)}}relegate(t){const n=this.members.findIndex(r=>t===r);if(n===0)return!1;let s;for(let r=n;r>=0;r--){const o=this.members[r];if(o.isPresent!==!1){s=o;break}}return s?(this.promote(s),!0):!1}promote(t,n){const s=this.lead;if(t!==s&&(this.prevLead=s,this.lead=t,t.show(),s)){s.instance&&s.scheduleRender(),t.scheduleRender(),t.resumeFrom=s,n&&(t.resumeFrom.preserveOpacity=!0),s.snapshot&&(t.snapshot=s.snapshot,t.snapshot.latestValues=s.animationValues||s.latestValues),t.root&&t.root.isUpdating&&(t.isLayoutDirty=!0);const{crossfade:r}=t.options;r===!1&&s.hide()}}exitAnimationComplete(){this.members.forEach(t=>{const{options:n,resumingFrom:s}=t;n.onExitComplete&&n.onExitComplete(),s&&s.options.onExitComplete&&s.options.onExitComplete()})}scheduleRender(){this.members.forEach(t=>{t.instance&&t.scheduleRender(!1)})}removeLeadSnapshot(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)}}function oh(e,t,n){let s="";const r=e.x.translate/t.x,o=e.y.translate/t.y,i=n?.z||0;if((r||o||i)&&(s=`translate3d(${r}px, ${o}px, ${i}px) `),(t.x!==1||t.y!==1)&&(s+=`scale(${1/t.x}, ${1/t.y}) `),n){const{transformPerspective:u,rotate:d,rotateX:f,rotateY:m,skewX:p,skewY:S}=n;u&&(s=`perspective(${u}px) ${s}`),d&&(s+=`rotate(${d}deg) `),f&&(s+=`rotateX(${f}deg) `),m&&(s+=`rotateY(${m}deg) `),p&&(s+=`skewX(${p}deg) `),S&&(s+=`skewY(${S}deg) `)}const a=e.x.scale*t.x,l=e.y.scale*t.y;return(a!==1||l!==1)&&(s+=`scale(${a}, ${l})`),s||"none"}const $s=["","X","Y","Z"],ah=1e3;let lh=0;function Fs(e,t,n,s){const{latestValues:r}=t;r[e]&&(n[e]=r[e],t.setStaticValue(e,0),s&&(s[e]=0))}function il(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;const{visualElement:t}=e.options;if(!t)return;const n=_a(t);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:r,layoutId:o}=e.options;window.MotionCancelOptimisedAnimation(n,"transform",ce,!(r||o))}const{parent:s}=e;s&&!s.hasCheckedOptimisedAppear&&il(s)}function ol({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:s,resetTransform:r}){return class{constructor(i={},a=t?.()){this.id=lh++,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.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(dh),this.nodes.forEach(ph),this.nodes.forEach(gh),this.nodes.forEach(fh)},this.resolvedRelativeTargetAt=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=i,this.root=a?a.root||a:this,this.path=a?[...a.path,a]:[],this.parent=a,this.depth=a?a.depth+1:0;for(let l=0;l<this.path.length;l++)this.path[l].shouldResetTransform=!0;this.root===this&&(this.nodes=new Yf)}addEventListener(i,a){return this.eventHandlers.has(i)||this.eventHandlers.set(i,new Sr),this.eventHandlers.get(i).add(a)}notifyListeners(i,...a){const l=this.eventHandlers.get(i);l&&l.notify(...a)}hasListeners(i){return this.eventHandlers.has(i)}mount(i){if(this.instance)return;this.isSVG=va(i)&&!Zu(i),this.instance=i;const{layoutId:a,layout:l,visualElement:u}=this.options;if(u&&!u.current&&u.mount(i),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(l||a)&&(this.isLayoutDirty=!0),e){let d,f=0;const m=()=>this.root.updateBlockedByResize=!1;ce.read(()=>{f=window.innerWidth}),e(i,()=>{const p=window.innerWidth;p!==f&&(f=p,this.root.updateBlockedByResize=!0,d&&d(),d=Hf(m,250),ls.hasAnimatedSinceResize&&(ls.hasAnimatedSinceResize=!1,this.nodes.forEach(ho)))})}a&&this.root.registerSharedNode(a,this),this.options.animate!==!1&&u&&(a||l)&&this.addEventListener("didUpdate",({delta:d,hasLayoutChanged:f,hasRelativeLayoutChanged:m,layout:p})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const S=this.options.transition||u.getDefaultTransition()||wh,{onLayoutAnimationStart:v,onLayoutAnimationComplete:C}=u.getProps(),b=!this.targetLayout||!rl(this.targetLayout,p),M=!f&&m;if(this.options.layoutRoot||this.resumeFrom||M||f&&(b||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const E={...Or(S,"layout"),onPlay:v,onComplete:C};(u.shouldReduceMotion||this.options.layoutRoot)&&(E.delay=0,E.type=!1),this.startAnimation(E),this.setAnimationOrigin(d,M)}else f||ho(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=p})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const i=this.getStack();i&&i.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),pt(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(yh),this.animationId++)}getTransformTemplate(){const{visualElement:i}=this.options;return i&&i.getProps().transformTemplate}willUpdate(i=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&il(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let d=0;d<this.path.length;d++){const f=this.path[d];f.shouldResetTransform=!0,f.updateScroll("snapshot"),f.options.layoutRoot&&f.willUpdate(!1)}const{layoutId:a,layout:l}=this.options;if(a===void 0&&!l)return;const u=this.getTransformTemplate();this.prevTransformTemplateValue=u?u(this.latestValues,""):void 0,this.updateSnapshot(),i&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){this.unblockUpdate(),this.clearAllSnapshots(),this.nodes.forEach(uo);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(fo);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(mh),this.nodes.forEach(ch),this.nodes.forEach(uh)):this.nodes.forEach(fo),this.clearAllSnapshots();const a=Ne.now();Se.delta=it(0,1e3/60,a-Se.timestamp),Se.timestamp=a,Se.isProcessing=!0,As.update.process(Se),As.preRender.process(Se),As.render.process(Se),Se.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,$r.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(hh),this.sharedNodes.forEach(xh)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,ce.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){ce.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!Ee(this.snapshot.measuredBox.x)&&!Ee(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 l=0;l<this.path.length;l++)this.path[l].updateScroll();const i=this.layout;this.layout=this.measure(!1),this.layoutCorrected=pe(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);const{visualElement:a}=this.options;a&&a.notify("LayoutMeasure",this.layout.layoutBox,i?i.layoutBox:void 0)}updateScroll(i="measure"){let a=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===i&&(a=!1),a&&this.instance){const l=s(this.instance);this.scroll={animationId:this.root.animationId,phase:i,isRoot:l,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:l}}}resetTransform(){if(!r)return;const i=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,a=this.projectionDelta&&!sl(this.projectionDelta),l=this.getTransformTemplate(),u=l?l(this.latestValues,""):void 0,d=u!==this.prevTransformTemplateValue;i&&this.instance&&(a||kt(this.latestValues)||d)&&(r(this.instance,u),this.shouldResetTransform=!1,this.scheduleRender())}measure(i=!0){const a=this.measurePageBox();let l=this.removeElementScroll(a);return i&&(l=this.removeTransform(l)),Sh(l),{animationId:this.root.animationId,measuredBox:a,layoutBox:l,latestValues:{},source:this.id}}measurePageBox(){const{visualElement:i}=this.options;if(!i)return pe();const a=i.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(Th))){const{scroll:u}=this.root;u&&(Kt(a.x,u.offset.x),Kt(a.y,u.offset.y))}return a}removeElementScroll(i){const a=pe();if(Ie(a,i),this.scroll?.wasRoot)return a;for(let l=0;l<this.path.length;l++){const u=this.path[l],{scroll:d,options:f}=u;u!==this.root&&d&&f.layoutScroll&&(d.wasRoot&&Ie(a,i),Kt(a.x,d.offset.x),Kt(a.y,d.offset.y))}return a}applyTransform(i,a=!1){const l=pe();Ie(l,i);for(let u=0;u<this.path.length;u++){const d=this.path[u];!a&&d.options.layoutScroll&&d.scroll&&d!==d.root&&Gt(l,{x:-d.scroll.offset.x,y:-d.scroll.offset.y}),kt(d.latestValues)&&Gt(l,d.latestValues)}return kt(this.latestValues)&&Gt(l,this.latestValues),l}removeTransform(i){const a=pe();Ie(a,i);for(let l=0;l<this.path.length;l++){const u=this.path[l];if(!u.instance||!kt(u.latestValues))continue;or(u.latestValues)&&u.updateSnapshot();const d=pe(),f=u.measurePageBox();Ie(d,f),ro(a,u.latestValues,u.snapshot?u.snapshot.layoutBox:void 0,d)}return kt(this.latestValues)&&ro(a,this.latestValues),a}setTargetDelta(i){this.targetDelta=i,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(i){this.options={...this.options,...i,crossfade:i.crossfade!==void 0?i.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!==Se.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(i=!1){const a=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=a.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=a.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=a.isSharedProjectionDirty);const l=!!this.resumingFrom||this!==a;if(!(i||l&&this.isSharedProjectionDirty||this.isProjectionDirty||this.parent?.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:d,layoutId:f}=this.options;if(!(!this.layout||!(d||f))){if(this.resolvedRelativeTargetAt=Se.timestamp,!this.targetDelta&&!this.relativeTarget){const m=this.getClosestProjectingParent();m&&m.layout&&this.animationProgress!==1?(this.relativeParent=m,this.forceRelativeParentToResolveTarget(),this.relativeTarget=pe(),this.relativeTargetOrigin=pe(),Nn(this.relativeTargetOrigin,this.layout.layoutBox,m.layout.layoutBox),Ie(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}if(!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=pe(),this.targetWithTransforms=pe()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),Mf(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):Ie(this.target,this.layout.layoutBox),Oa(this.target,this.targetDelta)):Ie(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget)){this.attemptToResolveRelativeTarget=!1;const m=this.getClosestProjectingParent();m&&!!m.resumingFrom==!!this.resumingFrom&&!m.options.layoutScroll&&m.target&&this.animationProgress!==1?(this.relativeParent=m,this.forceRelativeParentToResolveTarget(),this.relativeTarget=pe(),this.relativeTargetOrigin=pe(),Nn(this.relativeTargetOrigin,this.target,m.target),Ie(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}}}getClosestProjectingParent(){if(!(!this.parent||or(this.parent.latestValues)||Ia(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}calcProjection(){const i=this.getLead(),a=!!this.resumingFrom||this!==i;let l=!0;if((this.isProjectionDirty||this.parent?.isProjectionDirty)&&(l=!1),a&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(l=!1),this.resolvedRelativeTargetAt===Se.timestamp&&(l=!1),l)return;const{layout:u,layoutId:d}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(u||d))return;Ie(this.layoutCorrected,this.layout.layoutBox);const f=this.treeScale.x,m=this.treeScale.y;zd(this.layoutCorrected,this.treeScale,this.path,a),i.layout&&!i.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(i.target=i.layout.layoutBox,i.targetWithTransforms=pe());const{target:p}=i;if(!p){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(to(this.prevProjectionDelta.x,this.projectionDelta.x),to(this.prevProjectionDelta.y,this.projectionDelta.y)),kn(this.projectionDelta,this.layoutCorrected,p,this.latestValues),(this.treeScale.x!==f||this.treeScale.y!==m||!co(this.projectionDelta.x,this.prevProjectionDelta.x)||!co(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",p))}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(i=!0){if(this.options.visualElement?.scheduleRender(),i){const a=this.getStack();a&&a.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=Yt(),this.projectionDelta=Yt(),this.projectionDeltaWithTransform=Yt()}setAnimationOrigin(i,a=!1){const l=this.snapshot,u=l?l.latestValues:{},d={...this.latestValues},f=Yt();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!a;const m=pe(),p=l?l.source:void 0,S=this.layout?this.layout.source:void 0,v=p!==S,C=this.getStack(),b=!C||C.members.length<=1,M=!!(v&&!b&&this.options.crossfade===!0&&!this.path.some(vh));this.animationProgress=0;let E;this.mixTargetDelta=$=>{const R=$/1e3;mo(f.x,i.x,R),mo(f.y,i.y,R),this.setTargetDelta(f),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(Nn(m,this.layout.layoutBox,this.relativeParent.layout.layoutBox),bh(this.relativeTarget,this.relativeTargetOrigin,m,R),E&&rh(this.relativeTarget,E)&&(this.isProjectionDirty=!1),E||(E=pe()),Ie(E,this.relativeTarget)),v&&(this.animationValues=d,Zf(d,u,this.latestValues,R,M,b)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=R},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(i){this.notifyListeners("animationStart"),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&(pt(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=ce.update(()=>{ls.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=Zt(0)),this.currentAnimation=Kf(this.motionValue,[0,1e3],{...i,velocity:0,isSync:!0,onUpdate:a=>{this.mixTargetDelta(a),i.onUpdate&&i.onUpdate(a)},onStop:()=>{},onComplete:()=>{i.onComplete&&i.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 i=this.getStack();i&&i.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(ah),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const i=this.getLead();let{targetWithTransforms:a,target:l,layout:u,latestValues:d}=i;if(!(!a||!l||!u)){if(this!==i&&this.layout&&u&&al(this.options.animationType,this.layout.layoutBox,u.layoutBox)){l=this.target||pe();const f=Ee(this.layout.layoutBox.x);l.x.min=i.target.x.min,l.x.max=l.x.min+f;const m=Ee(this.layout.layoutBox.y);l.y.min=i.target.y.min,l.y.max=l.y.min+m}Ie(a,l),Gt(a,d),kn(this.projectionDeltaWithTransform,this.layoutCorrected,a,d)}}registerSharedNode(i,a){this.sharedNodes.has(i)||this.sharedNodes.set(i,new ih),this.sharedNodes.get(i).add(a);const u=a.options.initialPromotionConfig;a.promote({transition:u?u.transition:void 0,preserveFollowOpacity:u&&u.shouldPreserveFollowOpacity?u.shouldPreserveFollowOpacity(a):void 0})}isLead(){const i=this.getStack();return i?i.lead===this:!0}getLead(){const{layoutId:i}=this.options;return i?this.getStack()?.lead||this:this}getPrevLead(){const{layoutId:i}=this.options;return i?this.getStack()?.prevLead:void 0}getStack(){const{layoutId:i}=this.options;if(i)return this.root.sharedNodes.get(i)}promote({needsReset:i,transition:a,preserveFollowOpacity:l}={}){const u=this.getStack();u&&u.promote(this,l),i&&(this.projectionDelta=void 0,this.needsReset=!0),a&&this.setOptions({transition:a})}relegate(){const i=this.getStack();return i?i.relegate(this):!1}resetSkewAndRotation(){const{visualElement:i}=this.options;if(!i)return;let a=!1;const{latestValues:l}=i;if((l.z||l.rotate||l.rotateX||l.rotateY||l.rotateZ||l.skewX||l.skewY)&&(a=!0),!a)return;const u={};l.z&&Fs("z",i,u,this.animationValues);for(let d=0;d<$s.length;d++)Fs(`rotate${$s[d]}`,i,u,this.animationValues),Fs(`skew${$s[d]}`,i,u,this.animationValues);i.render();for(const d in u)i.setStaticValue(d,u[d]),this.animationValues&&(this.animationValues[d]=u[d]);i.scheduleRender()}applyProjectionStyles(i,a){if(!this.instance||this.isSVG)return;if(!this.isVisible){i.visibility="hidden";return}const l=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,i.visibility="",i.opacity="",i.pointerEvents=os(a?.pointerEvents)||"",i.transform=l?l(this.latestValues,""):"none";return}const u=this.getLead();if(!this.projectionDelta||!this.layout||!u.target){this.options.layoutId&&(i.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,i.pointerEvents=os(a?.pointerEvents)||""),this.hasProjected&&!kt(this.latestValues)&&(i.transform=l?l({},""):"none",this.hasProjected=!1);return}i.visibility="";const d=u.animationValues||u.latestValues;this.applyTransformsToTarget();let f=oh(this.projectionDeltaWithTransform,this.treeScale,d);l&&(f=l(d,f)),i.transform=f;const{x:m,y:p}=this.projectionDelta;i.transformOrigin=`${m.origin*100}% ${p.origin*100}% 0`,u.animationValues?i.opacity=u===this?d.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:d.opacityExit:i.opacity=u===this?d.opacity!==void 0?d.opacity:"":d.opacityExit!==void 0?d.opacityExit:0;for(const S in Ln){if(d[S]===void 0)continue;const{correct:v,applyTo:C,isCSSVariable:b}=Ln[S],M=f==="none"?d[S]:v(d[S],u);if(C){const E=C.length;for(let $=0;$<E;$++)i[C[$]]=M}else b?this.options.visualElement.renderState.vars[S]=M:i[S]=M}this.options.layoutId&&(i.pointerEvents=u===this?os(a?.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(i=>i.currentAnimation?.stop()),this.root.nodes.forEach(uo),this.root.sharedNodes.clear()}}}function ch(e){e.updateLayout()}function uh(e){const t=e.resumeFrom?.snapshot||e.snapshot;if(e.isLead()&&e.layout&&t&&e.hasListeners("didUpdate")){const{layoutBox:n,measuredBox:s}=e.layout,{animationType:r}=e.options,o=t.source!==e.layout.source;r==="size"?Oe(d=>{const f=o?t.measuredBox[d]:t.layoutBox[d],m=Ee(f);f.min=n[d].min,f.max=f.min+m}):al(r,t.layoutBox,n)&&Oe(d=>{const f=o?t.measuredBox[d]:t.layoutBox[d],m=Ee(n[d]);f.max=f.min+m,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[d].max=e.relativeTarget[d].min+m)});const i=Yt();kn(i,n,t.layoutBox);const a=Yt();o?kn(a,e.applyTransform(s,!0),t.measuredBox):kn(a,n,t.layoutBox);const l=!sl(i);let u=!1;if(!e.resumeFrom){const d=e.getClosestProjectingParent();if(d&&!d.resumeFrom){const{snapshot:f,layout:m}=d;if(f&&m){const p=pe();Nn(p,t.layoutBox,f.layoutBox);const S=pe();Nn(S,n,m.layoutBox),rl(p,S)||(u=!0),d.options.layoutRoot&&(e.relativeTarget=S,e.relativeTargetOrigin=p,e.relativeParent=d)}}}e.notifyListeners("didUpdate",{layout:n,snapshot:t,delta:a,layoutDelta:i,hasLayoutChanged:l,hasRelativeLayoutChanged:u})}else if(e.isLead()){const{onExitComplete:n}=e.options;n&&n()}e.options.transition=void 0}function dh(e){e.parent&&(e.isProjecting()||(e.isProjectionDirty=e.parent.isProjectionDirty),e.isSharedProjectionDirty||(e.isSharedProjectionDirty=!!(e.isProjectionDirty||e.parent.isProjectionDirty||e.parent.isSharedProjectionDirty)),e.isTransformDirty||(e.isTransformDirty=e.parent.isTransformDirty))}function fh(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function hh(e){e.clearSnapshot()}function uo(e){e.clearMeasurements()}function fo(e){e.isLayoutDirty=!1}function mh(e){const{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify("BeforeLayoutMeasure"),e.resetTransform()}function ho(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function ph(e){e.resolveTargetDelta()}function gh(e){e.calcProjection()}function yh(e){e.resetSkewAndRotation()}function xh(e){e.removeLeadSnapshot()}function mo(e,t,n){e.translate=de(t.translate,0,n),e.scale=de(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function po(e,t,n,s){e.min=de(t.min,n.min,s),e.max=de(t.max,n.max,s)}function bh(e,t,n,s){po(e.x,t.x,n.x,s),po(e.y,t.y,n.y,s)}function vh(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}const wh={duration:.45,ease:[.4,0,.1,1]},go=e=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),yo=go("applewebkit/")&&!go("chrome/")?Math.round:Fe;function xo(e){e.min=yo(e.min),e.max=yo(e.max)}function Sh(e){xo(e.x),xo(e.y)}function al(e,t,n){return e==="position"||e==="preserve-aspect"&&!Ef(lo(t),lo(n),.2)}function Th(e){return e!==e.root&&e.scroll?.wasRoot}const Ch=ol({attachResizeListener:(e,t)=>$n(e,"resize",t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0}),Bs={current:void 0},ll=ol({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!Bs.current){const e=new Ch({});e.mount(window),e.setOptions({layoutScroll:!0}),Bs.current=e}return Bs.current},resetTransform:(e,t)=>{e.style.transform=t!==void 0?t:"none"},checkIsScrollRoot:e=>window.getComputedStyle(e).position==="fixed"}),jh={pan:{Feature:_f},drag:{Feature:zf,ProjectionNode:ll,MeasureLayout:el}};function bo(e,t,n){const{props:s}=e;e.animationState&&s.whileHover&&e.animationState.setActive("whileHover",n==="Start");const r="onHover"+n,o=s[r];o&&ce.postRender(()=>o(t,zn(t)))}class Ph extends yt{mount(){const{current:t}=this.node;t&&(this.unmount=Ku(t,(n,s)=>(bo(this.node,s,"Start"),r=>bo(this.node,r,"End"))))}unmount(){}}class Ah extends yt{constructor(){super(...arguments),this.isActive=!1}onFocus(){let t=!1;try{t=this.node.current.matches(":focus-visible")}catch{t=!0}!t||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=Fn($n(this.node.current,"focus",()=>this.onFocus()),$n(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function vo(e,t,n){const{props:s}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&s.whileTap&&e.animationState.setActive("whileTap",n==="Start");const r="onTap"+(n==="End"?"":n),o=s[r];o&&ce.postRender(()=>o(t,zn(t)))}class Eh extends yt{mount(){const{current:t}=this.node;t&&(this.unmount=Ju(t,(n,s)=>(vo(this.node,s,"Start"),(r,{success:o})=>vo(this.node,r,o?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}const hr=new WeakMap,Us=new WeakMap,Mh=e=>{const t=hr.get(e.target);t&&t(e)},kh=e=>{e.forEach(Mh)};function Nh({root:e,...t}){const n=e||document;Us.has(n)||Us.set(n,{});const s=Us.get(n),r=JSON.stringify(t);return s[r]||(s[r]=new IntersectionObserver(kh,{root:e,...t})),s[r]}function Rh(e,t,n){const s=Nh(t);return hr.set(e,n),s.observe(e),()=>{hr.delete(e),s.unobserve(e)}}const Dh={some:0,all:1};class Vh extends yt{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:t={}}=this.node.getProps(),{root:n,margin:s,amount:r="some",once:o}=t,i={root:n?n.current:void 0,rootMargin:s,threshold:typeof r=="number"?r:Dh[r]},a=l=>{const{isIntersecting:u}=l;if(this.isInView===u||(this.isInView=u,o&&!u&&this.hasEnteredView))return;u&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",u);const{onViewportEnter:d,onViewportLeave:f}=this.node.getProps(),m=u?d:f;m&&m(l)};return Rh(this.node.current,i,a)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:t,prevProps:n}=this.node;["amount","margin","root"].some(Ih(t,n))&&this.startObserver()}unmount(){}}function Ih({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}const cl={inView:{Feature:Vh},tap:{Feature:Eh},focus:{Feature:Ah},hover:{Feature:Ph}},Oh={layout:{ProjectionNode:ll,MeasureLayout:el}},Lh={...Ga,...cl,...jh,...Oh},$h=Fd(Lh,za),Fh={renderer:za,...Ga,...cl};function Jr(e,t){return as(e,t)}const Bh=Jr("button"),ts=Jr("div"),Uh=Jr("p");function zh({toolName:e,description:t,args:n,onApprove:s,onDeny:r}){const o=Object.keys(n).length>0;return c.jsx("div",{className:"bg-stone-100 dark:bg-stone-800 border border-border rounded-lg px-3 py-2.5 my-1.5",children:c.jsxs("div",{className:"flex items-start gap-2",children:[c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsx("div",{className:"flex items-center gap-1.5 mb-1",children:c.jsx("span",{className:"text-sm font-medium text-foreground",children:e})}),o&&c.jsx("div",{className:"space-y-0.5 mb-1.5",children:Object.entries(n).map(([i,a])=>c.jsxs("div",{className:"flex items-start gap-1.5 text-xs",children:[c.jsxs("span",{className:"text-muted-foreground min-w-[60px]",children:[i,":"]}),c.jsx("span",{className:"font-mono text-foreground",children:typeof a=="string"?a:JSON.stringify(a)})]},i))})]}),c.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[c.jsxs(je,{size:"sm",variant:"ghost",className:"h-6 px-2 text-xs",onClick:s,children:[c.jsx(ee.Check,{className:"h-3 w-3 mr-1"}),"Approve"]}),c.jsx(je,{size:"sm",variant:"ghost",className:"h-6 px-2 text-xs text-muted-foreground",onClick:r,children:c.jsx(ee.X,{className:"h-3 w-3"})})]})]})})}function _h({toolName:e,args:t,isDenied:n,isSafe:s}){const[r,o]=h.useState(!1);if(e==="fetchDocContent")return null;const i=["k","maxResults","_organizationId"];e==="searchDocs"&&i.push("filters");const a=Object.fromEntries(Object.entries(t).filter(([u])=>!i.includes(u))),l=Object.keys(a).length>0;return c.jsxs("div",{className:"my-1",children:[c.jsxs("button",{onClick:()=>l&&o(!r),className:`inline-flex items-center gap-1.5 text-xs rounded-md px-2 py-1 transition-colors bg-muted text-muted-foreground ${l?"cursor-pointer hover:bg-muted/80":""}`,children:[l&&c.jsx("span",{className:"transition-transform duration-200",children:r?c.jsx(ee.ChevronDown,{className:"h-3 w-3"}):c.jsx(ee.ChevronRight,{className:"h-3 w-3"})}),n?c.jsx(ee.X,{className:"h-3 w-3"}):s?c.jsx(ee.Zap,{className:"h-3 w-3"}):c.jsx(ee.Check,{className:"h-3 w-3"}),c.jsxs("span",{className:"font-medium",children:[n?"Denied":s?"Auto-executed":"Executed"," ",e]})]}),r&&l&&c.jsx("div",{className:"mt-1 ml-6 p-2 bg-stone-50 dark:bg-stone-900 rounded-md border border-border",children:c.jsx("div",{className:"space-y-0.5",children:Object.entries(a).map(([u,d])=>c.jsxs("div",{className:"flex items-start gap-1.5 text-xs",children:[c.jsxs("span",{className:"text-muted-foreground min-w-[60px]",children:[u,":"]}),c.jsx("span",{className:"font-mono text-foreground",children:typeof d=="string"?d:JSON.stringify(d)})]},u))})})]})}function Xh({...e}){return c.jsx(mr.Root,{"data-slot":"collapsible",...e})}function Wh({...e}){return c.jsx(mr.CollapsibleTrigger,{"data-slot":"collapsible-trigger",...e})}function qh({...e}){return c.jsx(mr.CollapsibleContent,{"data-slot":"collapsible-content",...e})}const Kh=h.lazy(()=>import("streamdown").then(e=>({default:e.Streamdown}))),Zr=h.memo(({className:e,...t})=>typeof window>"u"?null:c.jsx(h.Suspense,{fallback:null,children:c.jsx(Kh,{className:ne("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",e),...t})}),(e,t)=>e.children===t.children);Zr.displayName="Response";const Gh=Object.freeze(Object.defineProperty({__proto__:null,Response:Zr},Symbol.toStringTag,{value:"Module"})),Yh=({children:e,as:t="p",className:n,duration:s=2,spread:r=2})=>{const o=$h.create(t),i=h.useMemo(()=>(e?.length??0)*r,[e,r]);return c.jsx(o,{animate:{backgroundPosition:"0% center"},className:ne("relative inline-block bg-[length:250%_100%,auto] bg-clip-text text-transparent","[--bg:linear-gradient(90deg,#0000_calc(50%-var(--spread)),var(--color-background),#0000_calc(50%+var(--spread)))] [background-repeat:no-repeat,padding-box]",n),initial:{backgroundPosition:"100% center"},style:{"--spread":`${i}px`,backgroundImage:"var(--bg), linear-gradient(var(--color-muted-foreground), var(--color-muted-foreground))"},transition:{repeat:Number.POSITIVE_INFINITY,duration:s,ease:"linear"},children:e})},Hh=h.memo(Yh),ul=h.createContext(null),Jh=()=>{const e=h.useContext(ul);if(!e)throw new Error("Reasoning components must be used within Reasoning");return e},Zh=1e3,Qh=1e3,dl=h.memo(({className:e,isStreaming:t=!1,open:n,defaultOpen:s=!0,onOpenChange:r,duration:o,children:i,...a})=>{const[l,u]=si.useControllableState({prop:n,defaultProp:s,onChange:r}),[d,f]=si.useControllableState({prop:o,defaultProp:0}),[m,p]=h.useState(!1),[S,v]=h.useState(null);h.useEffect(()=>{t?S===null&&v(Date.now()):S!==null&&(f(Math.ceil((Date.now()-S)/Qh)),v(null))},[t,S,f]),h.useEffect(()=>{if(s&&!t&&l&&!m){const b=setTimeout(()=>{u(!1),p(!0)},Zh);return()=>clearTimeout(b)}},[t,l,s,u,m]);const C=b=>{u(b)};return c.jsx(ul.Provider,{value:{isStreaming:t,isOpen:l,setIsOpen:u,duration:d},children:c.jsx(Xh,{className:ne("not-prose mb-4",e),onOpenChange:C,open:l,...a,children:i})})}),em=(e,t)=>e||t===0?c.jsx(Hh,{duration:1,children:"Thinking..."}):t===void 0?c.jsx("p",{children:"Thought for a few seconds"}):c.jsxs("p",{children:["Thought for ",t," seconds"]}),fl=h.memo(({className:e,children:t,...n})=>{const{isStreaming:s,isOpen:r,duration:o}=Jh();return c.jsx(Wh,{className:ne("flex w-full items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground",e),...n,children:t??c.jsxs(c.Fragment,{children:[c.jsx(ee.BrainIcon,{className:"size-4"}),em(s,o),c.jsx(ee.ChevronDownIcon,{className:ne("size-4 transition-transform",r?"rotate-180":"rotate-0")})]})})}),hl=h.memo(({className:e,children:t,...n})=>c.jsx(qh,{className:ne("mt-4 text-sm","data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-muted-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in",e),...n,children:c.jsx(Zr,{className:"grid gap-2",children:t})}));dl.displayName="Reasoning";fl.displayName="ReasoningTrigger";hl.displayName="ReasoningContent";function wo(e){return`https://www.google.com/s2/favicons?domain=${encodeURIComponent(e)}&sz=16`}function tm({sources:e,citationNumber:t,className:n}){const s=e.find(o=>o.number===t);if(!s)return null;const r=wo(s.domain);return c.jsxs(dt,{children:[c.jsx(ft,{asChild:!0,children:c.jsxs("button",{className:ne("inline-flex items-center gap-1 px-1 py-0.5 rounded text-[10px] font-medium","bg-stone-200/60 dark:bg-stone-700/60 text-stone-800 dark:text-stone-200","hover:bg-stone-300/80 dark:hover:bg-stone-600/80","transition-all duration-200","border border-stone-300/60 dark:border-stone-600/60","cursor-pointer hover:scale-105 active:scale-95","leading-tight",n),onClick:o=>{o.preventDefault(),o.stopPropagation(),window.open(s.url,"_blank","noopener,noreferrer")},children:[c.jsx("img",{src:r,alt:"",className:"w-3 h-3 leading-none",onError:o=>{const i=o.target;i.style.display="none"}}),c.jsx("span",{className:"leading-none",children:s.domain})]})}),c.jsx(ht,{side:"top",className:"bg-stone-800 dark:bg-stone-900 border border-stone-700 dark:border-stone-600 p-3 max-w-sm z-50 rounded-lg shadow-lg",children:c.jsxs("div",{className:"space-y-1.5",children:[c.jsxs("div",{className:"text-xs font-semibold text-stone-300 dark:text-stone-200 mb-2 pb-2 border-b border-stone-700 dark:border-stone-600",children:["Sources • ",e.length]}),e.map(o=>{const i=o.title||o.domain;return c.jsxs("a",{href:o.url,target:"_blank",rel:"noopener noreferrer",className:ne("flex items-center gap-2 p-2 rounded-md hover:bg-stone-700/50 dark:hover:bg-stone-700/50 transition-colors","text-stone-300 dark:text-stone-300 hover:text-white dark:hover:text-white"),onClick:a=>a.stopPropagation(),children:[c.jsx("img",{src:wo(o.domain),alt:"",className:"w-4 h-4 flex-shrink-0",onError:a=>{const l=a.target;l.style.display="none"}}),c.jsx("span",{className:"text-xs flex-1 truncate",children:i})]},o.number)})]})})]})}function nm({text:e,citations:t,citationMap:n,groupedCitations:s,referencesText:r,ResponseComponent:o,className:i,showCitations:a=!0,showReferences:l=!0}){const u=h.useRef(null),[d,f]=h.useState([]);h.useEffect(()=>{if(!a||!u.current||t.length===0||n.size===0){(n.size===0||!a)&&f([]);return}const C=u.current;let b,M=!1;const E=new WeakSet,$=()=>{if(!u.current||M)return;M=!0;const I=u.current,N=/\[(\d+)\]/g,P=document.createTreeWalker(I,NodeFilter.SHOW_TEXT,null),O=[];let A;for(;A=P.nextNode();)if(A.nodeType===Node.TEXT_NODE&&!E.has(A)){const F=A,V=F.textContent||"";let B=F.parentElement,W=!1;for(;B&&B!==I;){if(B.tagName==="A"||B.tagName==="CODE"||B.tagName==="PRE"){W=!0;break}B=B.parentElement}if(!W){const G=Array.from(V.matchAll(N)).filter(ie=>{if(!ie[1])return!1;const ye=parseInt(ie[1],10);return n.has(ye)});G.length>0&&O.push({node:F,matches:G})}}if(O.length===0){M=!1;return}const k=[];O.forEach(({node:F,matches:V})=>{E.add(F);const B=F.textContent||"",W=document.createDocumentFragment();let H=0;V.forEach(G=>{if(!G[1])return;G.index!==void 0&&G.index>H&&W.appendChild(document.createTextNode(B.slice(H,G.index)));const ie=document.createElement("span");ie.className="inline-flex items-center citation-button-container";const ye=parseInt(G[1],10);ie.setAttribute("data-citation",G[1]),W.appendChild(ie),k.push({element:ie,citationNum:ye}),H=(G.index||0)+G[0].length}),H<B.length&&W.appendChild(document.createTextNode(B.slice(H))),F.parentNode&&F.parentNode.replaceChild(W,F)}),k.length>0&&f(F=>{const V=new Set(F.map(H=>H.element)),B=F.filter(H=>H.element.isConnected),W=k.filter(H=>!V.has(H.element));return[...B,...W]}),M=!1},R=new MutationObserver(()=>{clearTimeout(b),b=setTimeout($,100)});return R.observe(C,{childList:!0,subtree:!0,characterData:!0}),b=setTimeout($,200),()=>{R.disconnect(),clearTimeout(b)}},[e,t,n,a]);const m=s&&s.length>0||n&&n.size>0||r;function p(C){return`https://www.google.com/s2/favicons?domain=${encodeURIComponent(C)}&sz=16`}function S(C){try{return new URL(C).hostname.replace(/^www\./,"")}catch{return C}}const v=a&&l&&m?c.jsxs("div",{className:"mt-4 pt-4 border-t border-stone-200 dark:border-stone-700",children:[c.jsx("div",{className:"text-xs font-semibold text-stone-600 dark:text-stone-400 mb-3",children:"References"}),c.jsx("div",{className:"flex flex-wrap gap-2",children:s&&s.length>0?s.map((C,b)=>{const M=C.title||C.baseUrl,E=S(C.url),$=p(E);return c.jsxs("a",{href:C.url,target:"_blank",rel:"noopener noreferrer",className:ne("inline-flex items-center gap-1.5 px-2.5 py-1.5 rounded-md text-xs font-medium","bg-stone-100 dark:bg-stone-800 text-stone-700 dark:text-stone-300","hover:bg-stone-200 dark:hover:bg-stone-700","transition-all duration-200","border border-stone-200 dark:border-stone-700","cursor-pointer hover:scale-105 active:scale-95","no-underline"),children:[c.jsx("img",{src:$,alt:"",className:"w-3.5 h-3.5 shrink-0",onError:R=>{const I=R.target;I.style.display="none"}}),c.jsx("span",{className:"leading-none",children:M})]},`group-${b}`)}):Array.from(n.entries()).sort(([C],[b])=>C-b).map(([C,b])=>{const M=S(b),E=p(M);return c.jsxs("a",{href:b,target:"_blank",rel:"noopener noreferrer",className:ne("inline-flex items-center gap-1.5 px-2.5 py-1.5 rounded-md text-xs font-medium","bg-stone-100 dark:bg-stone-800 text-stone-700 dark:text-stone-300","hover:bg-stone-200 dark:hover:bg-stone-700","transition-all duration-200","border border-stone-200 dark:border-stone-700","cursor-pointer hover:scale-105 active:scale-95","no-underline"),children:[c.jsx("img",{src:E,alt:"",className:"w-3.5 h-3.5 shrink-0",onError:$=>{const R=$.target;R.style.display="none"}}),c.jsx("span",{className:"leading-none",children:b})]},C)})})]}):null;return c.jsxs("div",{className:i,children:[c.jsx("div",{ref:u,children:c.jsx(o,{children:e})}),a&&d.filter(({element:C})=>C.isConnected).map(({element:C,citationNum:b},M)=>{if(!t.find(R=>R.number===b))return null;const $=Array.from(new Map(t.map(R=>{const I=R.url.replace(/\/+$/,""),N=s?.find(P=>P.url.replace(/\/+$/,"")===I);return[I,{number:R.number,url:R.url,domain:S(R.url),title:N?.title}]})).values());return Dl.createPortal(c.jsx(tm,{sources:$,citationNumber:b},`citation-${b}-${C}`),C,`citation-${b}-${M}`)}),v]})}function rn({...e}){return c.jsx(It.Root,{"data-slot":"dialog",...e})}function sm({...e}){return c.jsx(It.Portal,{"data-slot":"dialog-portal",...e})}function rm({className:e,...t}){return c.jsx(It.Overlay,{"data-slot":"dialog-overlay",className:ne("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",e),...t})}function on({className:e,children:t,showCloseButton:n=!0,...s}){return c.jsxs(sm,{"data-slot":"dialog-portal",children:[c.jsx(rm,{}),c.jsxs(It.Content,{"data-slot":"dialog-content",className:ne("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",e),...s,children:[t,n&&c.jsxs(It.Close,{"data-slot":"dialog-close",className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[c.jsx(ee.XIcon,{}),c.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function an({className:e,...t}){return c.jsx("div",{"data-slot":"dialog-header",className:ne("flex flex-col gap-2 text-center sm:text-left",e),...t})}function ln({className:e,...t}){return c.jsx("div",{"data-slot":"dialog-footer",className:ne("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...t})}function cn({className:e,...t}){return c.jsx(It.Title,{"data-slot":"dialog-title",className:ne("text-lg leading-none font-semibold",e),...t})}function un({className:e,...t}){return c.jsx(It.Description,{"data-slot":"dialog-description",className:ne("text-muted-foreground text-sm",e),...t})}function dn({className:e,type:t,...n}){return c.jsx("input",{type:t,"data-slot":"input",className:ne("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input h-9 w-full min-w-0 rounded-md border bg-white px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm","focus-visible:border-ring","aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",e),...n})}function im({isOpen:e,title:t="Password Required",description:n="Please enter your password to continue",placeholder:s="Enter password...",onComplete:r}){const[o,i]=h.useState(""),[a,l]=h.useState(!1),[u,d]=h.useState(!1),f=async p=>{if(p.preventDefault(),!!o.trim()){d(!0);try{r(o)}finally{d(!1)}}},m=()=>{i(""),r(null)};return c.jsx(rn,{open:e,children:c.jsx(on,{showCloseButton:!1,children:c.jsxs("form",{onSubmit:f,children:[c.jsxs(an,{children:[c.jsx(cn,{children:t}),c.jsx(un,{children:n})]}),c.jsx("div",{className:"py-4",children:c.jsxs("div",{className:"relative",children:[c.jsx(dn,{type:a?"text":"password",value:o,onChange:p=>i(p.target.value),placeholder:s,className:"pr-10",autoFocus:!0,disabled:u}),c.jsx("button",{type:"button",onClick:()=>l(!a),className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600",disabled:u,children:a?c.jsx(ee.EyeOff,{className:"h-4 w-4"}):c.jsx(ee.Eye,{className:"h-4 w-4"})})]})}),c.jsxs(ln,{children:[c.jsx(je,{type:"button",variant:"ghost",onClick:m,disabled:u,children:"Cancel"}),c.jsx(je,{type:"submit",disabled:!o.trim()||u,children:u?"Submitting...":"Submit"})]})]})})})}function om({isOpen:e,title:t="Email Required",description:n="Please enter your email address",placeholder:s="Enter email address...",onComplete:r}){const[o,i]=h.useState(""),[a,l]=h.useState(!0),[u,d]=h.useState(!1),f=v=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(v),m=v=>{i(v),v.trim()?l(f(v)):l(!0)},p=async v=>{if(v.preventDefault(),!o.trim()||!f(o)){l(!1);return}d(!0);try{r(o)}finally{d(!1)}},S=()=>{i(""),l(!0),r(null)};return c.jsx(rn,{open:e,children:c.jsx(on,{showCloseButton:!1,children:c.jsxs("form",{onSubmit:p,children:[c.jsxs(an,{children:[c.jsxs(cn,{className:"flex items-center gap-2",children:[c.jsx(ee.Mail,{className:"h-5 w-5"}),t]}),c.jsx(un,{children:n})]}),c.jsxs("div",{className:"py-4",children:[c.jsx(dn,{type:"email",value:o,onChange:v=>m(v.target.value),placeholder:s,className:a?"":"border-red-500",autoFocus:!0,disabled:u}),!a&&c.jsx("p",{className:"text-sm text-red-500 mt-1",children:"Please enter a valid email address"})]}),c.jsxs(ln,{children:[c.jsx(je,{type:"button",variant:"ghost",onClick:S,disabled:u,children:"Cancel"}),c.jsx(je,{type:"submit",disabled:!o.trim()||!a||u,children:u?"Submitting...":"Submit"})]})]})})})}function am({isOpen:e,title:t="Phone Number Required",description:n="Please enter your phone number",placeholder:s="Enter phone number...",onComplete:r}){const[o,i]=h.useState(""),[a,l]=h.useState(!0),[u,d]=h.useState(!1),f=C=>{const b=C.replace(/\D/g,"");return b.length<=3?b:b.length<=6?`(${b.slice(0,3)}) ${b.slice(3)}`:`(${b.slice(0,3)}) ${b.slice(3,6)}-${b.slice(6,10)}`},m=C=>C.replace(/\D/g,"").length===10,p=C=>{const b=f(C);i(b),b.trim()?l(m(b)):l(!0)},S=async C=>{if(C.preventDefault(),!o.trim()||!m(o)){l(!1);return}d(!0);try{const b=o.replace(/\D/g,"");r(b)}finally{d(!1)}},v=()=>{i(""),l(!0),r(null)};return c.jsx(rn,{open:e,children:c.jsx(on,{showCloseButton:!1,children:c.jsxs("form",{onSubmit:S,children:[c.jsxs(an,{children:[c.jsxs(cn,{className:"flex items-center gap-2",children:[c.jsx(ee.Phone,{className:"h-5 w-5"}),t]}),c.jsx(un,{children:n})]}),c.jsxs("div",{className:"py-4",children:[c.jsx(dn,{type:"tel",value:o,onChange:C=>p(C.target.value),placeholder:s,className:a?"":"border-red-500",maxLength:14,autoFocus:!0,disabled:u}),!a&&c.jsx("p",{className:"text-sm text-red-500 mt-1",children:"Please enter a valid 10-digit phone number"})]}),c.jsxs(ln,{children:[c.jsx(je,{type:"button",variant:"ghost",onClick:v,disabled:u,children:"Cancel"}),c.jsx(je,{type:"submit",disabled:!o.trim()||!a||u,children:u?"Submitting...":"Submit"})]})]})})})}function lm({isOpen:e,title:t="PIN Required",description:n="Please enter your PIN",placeholder:s="Enter PIN...",length:r=4,onComplete:o}){const[i,a]=h.useState(""),[l,u]=h.useState(!1),d=p=>{const S=p.replace(/\D/g,"");a(S.slice(0,r))},f=async p=>{if(p.preventDefault(),i.length===r){u(!0);try{o(i)}finally{u(!1)}}},m=()=>{a(""),o(null)};return c.jsx(rn,{open:e,children:c.jsx(on,{showCloseButton:!1,children:c.jsxs("form",{onSubmit:f,children:[c.jsxs(an,{children:[c.jsxs(cn,{className:"flex items-center gap-2",children:[c.jsx(ee.Shield,{className:"h-5 w-5"}),t]}),c.jsx(un,{children:n})]}),c.jsxs("div",{className:"py-4",children:[c.jsx(dn,{type:"password",value:i,onChange:p=>d(p.target.value),placeholder:s,className:"text-center text-lg tracking-widest",maxLength:r,autoFocus:!0,disabled:l}),c.jsxs("p",{className:"text-sm text-gray-500 mt-1 text-center",children:["Enter ",r,"-digit PIN"]})]}),c.jsxs(ln,{children:[c.jsx(je,{type:"button",variant:"ghost",onClick:m,disabled:l,children:"Cancel"}),c.jsx(je,{type:"submit",disabled:i.length!==r||l,children:l?"Submitting...":"Submit"})]})]})})})}function zs({isOpen:e,title:t="Secure Input Required",description:n="Please enter the requested information",placeholder:s="Enter value...",type:r="password",onComplete:o}){const[i,a]=h.useState(""),[l,u]=h.useState(!1),d=async m=>{if(m.preventDefault(),!!i.trim()){u(!0);try{o(i)}finally{u(!1)}}},f=()=>{a(""),o(null)};return c.jsx(rn,{open:e,children:c.jsx(on,{showCloseButton:!1,children:c.jsxs("form",{onSubmit:d,children:[c.jsxs(an,{children:[c.jsxs(cn,{className:"flex items-center gap-2",children:[c.jsx(ee.Lock,{className:"h-5 w-5"}),t]}),c.jsx(un,{children:n})]}),c.jsx("div",{className:"py-4",children:c.jsx(dn,{type:r,value:i,onChange:m=>a(m.target.value),placeholder:s,autoFocus:!0,disabled:l})}),c.jsxs(ln,{children:[c.jsx(je,{type:"button",variant:"ghost",onClick:f,disabled:l,children:"Cancel"}),c.jsx(je,{type:"submit",disabled:!i.trim()||l,children:l?"Submitting...":"Submit"})]})]})})})}function cm({isOpen:e,title:t,description:n,fields:s,onComplete:r,submitText:o="Submit",cancelText:i="Cancel"}){const[a,l]=h.useState(()=>{const A={};return s.forEach(k=>{A[k.name]=k.value||""}),A}),[u,d]=h.useState({}),[f,m]=h.useState({}),[p,S]=h.useState(!1),v=A=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(A)?null:"Please enter a valid email address",C=A=>A.replace(/\D/g,"").length===10?null:"Please enter a valid 10-digit phone number",b=(A,k=4)=>A.length===k?null:`PIN must be ${k} digits`,M=A=>{const k=A.replace(/\D/g,"");return k.length<=3?k:k.length<=6?`(${k.slice(0,3)}) ${k.slice(3)}`:`(${k.slice(0,3)}) ${k.slice(3,6)}-${k.slice(6,10)}`},E=(A,k,F)=>{let V=k,B=null;switch(F.type){case"phone":V=M(k),V.trim()&&(B=C(V));break;case"email":k.trim()&&(B=v(k));break;case"pin":V=k.replace(/\D/g,"").slice(0,6),V.trim()&&(B=b(V));break}!B&&F.validation&&V.trim()&&(B=F.validation(V)),l(W=>({...W,[A]:V})),d(W=>({...W,[A]:B||""}))},$=()=>{const A={};let k=!0;return s.forEach(F=>{const V=a[F.name]||"";let B=null;if(F.required&&!V.trim())B=`${F.label} is required`;else if(V.trim()){switch(F.type){case"email":B=v(V);break;case"phone":B=C(V);break;case"pin":B=b(V);break}!B&&F.validation&&(B=F.validation(V))}B&&(A[F.name]=B,k=!1)}),d(A),k},R=async A=>{if(A.preventDefault(),!!$()){S(!0);try{const k={};s.forEach(F=>{const V=a[F.name]?.trim();V&&(F.type==="phone"?k[F.name]=V.replace(/\D/g,""):k[F.name]=V)}),r(k)}finally{S(!1)}}},I=()=>{l({}),d({}),m({}),r(null)},N=A=>{m(k=>({...k,[A]:!k[A]}))},P=A=>{switch(A.type){case"password":return f[A.name]?"text":"password";case"email":return"email";case"phone":return"tel";case"pin":case"ssn":return"password";default:return"text"}},O=A=>{if(A.placeholder)return A.placeholder;switch(A.type){case"email":return"Enter email address...";case"phone":return"Enter phone number...";case"password":return"Enter password...";case"pin":return"Enter PIN...";case"ssn":return"XXX-XX-XXXX";case"creditCard":return"XXXX XXXX XXXX XXXX";default:return`Enter ${A.label.toLowerCase()}...`}};return c.jsx(rn,{open:e,children:c.jsx(on,{showCloseButton:!1,className:"max-w-md",children:c.jsxs("form",{onSubmit:R,children:[c.jsxs(an,{children:[c.jsx(cn,{children:t}),n&&c.jsx(un,{children:n})]}),c.jsx("div",{className:"py-4 space-y-4",children:s.map(A=>c.jsxs("div",{children:[c.jsxs("label",{className:"block text-sm font-medium mb-1",children:[A.label,A.required&&c.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),c.jsxs("div",{className:"relative",children:[c.jsx(dn,{type:P(A),value:a[A.name]||"",onChange:k=>E(A.name,k.target.value,A),placeholder:O(A),className:u[A.name]?"border-red-500":"",disabled:p,autoFocus:A===s[0],maxLength:A.type==="pin"?6:A.type==="phone"?14:void 0}),A.type==="password"&&c.jsx("button",{type:"button",onClick:()=>N(A.name),className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600",disabled:p,children:f[A.name]?c.jsx(ee.EyeOff,{className:"h-4 w-4"}):c.jsx(ee.Eye,{className:"h-4 w-4"})})]}),u[A.name]&&c.jsxs("div",{className:"flex items-center gap-1 mt-1 text-sm text-red-500",children:[c.jsx(ee.AlertCircle,{className:"h-3 w-3"}),u[A.name]]})]},A.name))}),c.jsxs(ln,{children:[c.jsx(je,{type:"button",variant:"ghost",onClick:I,disabled:p,children:i}),c.jsx(je,{type:"submit",disabled:p,children:p?"Submitting...":o})]})]})})})}const ml=h.createContext(void 0);function pl(){const e=h.useContext(ml);if(!e)throw new Error("useSecureModal must be used within a SecureModalProvider");return e}function gl({children:e}){const[t,n]=h.useState(null),[s,r]=h.useState(null),o=h.useRef(null),i=h.useRef(null),a=h.useCallback(p=>new Promise(S=>{n(p),o.current=S}),[]),l=h.useCallback(p=>new Promise(S=>{r(p),i.current=S}),[]),u=h.useCallback(p=>{o.current&&(o.current(p),o.current=null),n(null)},[]),d=h.useCallback(p=>{i.current&&(i.current(p),i.current=null),r(null)},[]),f=()=>{if(s){const S=s.fields.map(v=>({name:v.name,type:v.type==="text"?"text":v.type==="password"?"password":v.type==="email"?"email":v.type==="phone"?"phone":v.type==="pin"?"pin":v.type==="ssn"?"ssn":v.type==="creditCard"?"creditCard":"text",label:v.label,placeholder:v.placeholder,required:v.required!==!1,value:v.value}));return c.jsx(cm,{isOpen:!0,title:s.title,description:s.description,fields:S,onComplete:d})}if(!t)return null;const p={isOpen:!0,title:t.title,description:t.description,placeholder:t.placeholder,onComplete:u};switch(t.type){case"password":return c.jsx(im,{...p});case"email":return c.jsx(om,{...p});case"phone":return c.jsx(am,{...p});case"pin":return c.jsx(lm,{...p});case"ssn":return c.jsx(zs,{...p,title:t.title||"SSN Required",placeholder:t.placeholder||"XXX-XX-XXXX"});case"creditCard":return c.jsx(zs,{...p,title:t.title||"Credit Card Required",placeholder:t.placeholder||"XXXX XXXX XXXX XXXX",type:"text"});case"text":default:return c.jsx(zs,{...p})}},m=h.useMemo(()=>({showSecureModal:a,showSecureForm:l}),[a,l]);return c.jsxs(ml.Provider,{value:m,children:[e,f()]})}function um(e){try{const t=new URL(e),n=`${t.protocol}//${t.host}${t.pathname}`,s=t.hash?t.hash.substring(1):void 0;return{baseUrl:n,anchor:s}}catch{const t=e.indexOf("#");return t!==-1?{baseUrl:e.substring(0,t),anchor:e.substring(t+1)}:{baseUrl:e}}}function dm(e){try{const t=new URL(e),s=t.pathname.split("/").filter(a=>a.length>0);if(s.length===0)return t.hostname;const r=s[s.length-1];return r&&r.replace(/\.(md|mdx|html|htm)$/i,"").replace(/[-_]/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").split(" ").map(a=>a.charAt(0).toUpperCase()+a.slice(1).toLowerCase()).join(" ")||t.hostname}catch{const t=e.indexOf("#"),n=t!==-1?e.substring(0,t):e,s=n.split("/").filter(r=>r.length>0);if(s.length>0){const r=s[s.length-1];return r&&r.replace(/\.(md|mdx|html|htm)$/i,"").replace(/[-_]/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").split(" ").map(a=>a.charAt(0).toUpperCase()+a.slice(1).toLowerCase()).join(" ")||n}return n}}function So(e){let t=e.replace(/_+$/gm,"");const n=/(?:^|\n)(?:#+\s*)?(?:References|References:)(?:\*\*)?\s*\n?([\s\S]*?)(?=\n\n|\n#|$)/i,s=t.match(n),r=new Map,o=[],i=new Map,a=new Map,l=new Map,u=new Map;if(s&&s[1]){const P=s[1],O=/\[(\d+)\]\s*(https?:\/\/[^\s\)]+)/g;let A;for(;(A=O.exec(P))!==null;)if(A[1]&&A[2]){const k=parseInt(A[1],10),F=A[2].replace(/[.,;:!?]+$/,""),V=F.replace(/\/+$/,"");if(a.has(V)||a.set(V,F),i.has(V)||i.set(V,[]),i.get(V).push(k),!l.has(V))l.set(V,k);else{const B=l.get(V);k<B&&l.set(V,k)}}for(const[k,F]of i.entries()){const V=l.get(k);for(const B of F)B!==V&&u.set(B,V)}for(const[k,F]of l.entries()){const V=a.get(k)||k;r.set(F,V),o.push({number:F,url:V})}}let d,f=t;s&&s[0]&&(d=s[0],f=t.replace(n,""));const m=[];let p=0;const S=/```[\s\S]*?```|`[^`]+`/g;let v;for(;(v=S.exec(f))!==null;)v.index>p&&m.push({type:"text",content:f.slice(p,v.index),start:p,end:v.index}),m.push({type:"code",content:v[0],start:v.index,end:v.index+v[0].length}),p=v.index+v[0].length;p<f.length&&m.push({type:"text",content:f.slice(p),start:p,end:f.length});const C=m.map(P=>{if(P.type==="code")return P.content;let O=P.content;return O=O.replace(/\[(\d+)\]\((https?:\/\/[^\)]+)\)/g,(k,F,V)=>{const B=parseInt(F,10),W=V.replace(/\/+$/,""),H=u.get(B)||B;return l.has(W)||(l.set(W,H),r.has(H)||(r.set(H,V),o.push({number:H,url:V}))),`[${H}]`}),O=O.replace(/\[(\d+)\]/g,(k,F)=>{const V=parseInt(F,10);return`[${u.get(V)||V}]`}),O}),b=[];for(const[P,O]of l.entries()){const A=a.get(P)||P,{baseUrl:k,anchor:F}=um(A),V=dm(A);b.push({url:A,baseUrl:k,numbers:[O],anchor:F,title:V})}b.sort((P,O)=>(P.numbers[0]||0)-(O.numbers[0]||0));const M=new Map;let E=1;for(const P of b){const O=P.numbers[0];M.set(O,E),P.numbers=[E],E++}const $=new Map;for(const[P,O]of r.entries()){const A=M.get(P);A&&$.set(A,O)}const R=o.map(P=>{const O=M.get(P.number);return O?{number:O,url:P.url}:P}).filter(P=>M.has(P.number)),I=Array.from(M.entries()).sort((P,O)=>O[0]-P[0]);let N=C.join("");for(const[P,O]of I){const A=new RegExp(`\\[${P}\\](?!\\d)`,"g");N=N.replace(A,`[${O}]`)}return{processedText:N,citations:R.sort((P,O)=>P.number-O.number),citationMap:$,groupedCitations:b,referencesText:d}}function Rn(e){if(typeof e=="string")try{const t=JSON.parse(e);return Rn(t)}catch{return e}if(Array.isArray(e))return e.map(Rn);if(e&&typeof e=="object"){const t={};for(const[n,s]of Object.entries(e))t[n]=Rn(s);return t}return e}function _s(e){if(typeof e=="string"){try{const t=JSON.parse(e);if(t&&typeof t=="object"&&!Array.isArray(t))return Rn(t)}catch{}return{}}return e&&typeof e=="object"&&!Array.isArray(e)?Rn(e):{}}function fm({theme:e="auto",layout:t="sidebar",model:n="auto",animated:s=!0,title:r="Chat",logo:o=void 0,defaultWidth:i=384,minWidth:a=300,maxWidth:l=800,initiallyExpanded:u=!1,tools:d=[],safeTools:f=[],safeToolNames:m,toolMetadata:p,systemPrompt:S="",agentId:v,agentName:C,tokenEndpoint:b="/api/arcten/token",apiBaseUrl:M="https://api.arcten.com",user:E,state:$,onStateChange:R,allowStateEdits:I=!0,sources:N,ragConfig:P,showCitations:O=!0,sensitiveParams:A,autoDetectSensitive:k=!1}){const F=M.replace(/\/+$/,""),{showSecureModal:V}=pl(),B=Eo({apiBaseUrl:F,tokenEndpoint:b,user:E,tools:d,safeTools:f,toolMetadata:p,sensitiveParams:A,autoDetectSensitive:k,agentId:v,agentName:C,state:$,onStateChange:R,allowStateEdits:I,sources:N,ragConfig:P});h.useMemo(()=>P!==void 0?P:N&&N.length>0?{enabled:!0,organizationId:N[0],autoExecute:!0,filters:void 0}:{enabled:!1},[N,P]);const[W,H]=h.useState(u),[G,ie]=h.useState(i),[ye,Ge]=h.useState(600),[xt,nt]=h.useState(!1),[Y,Ot]=h.useState(!1),[Me,bt]=h.useState(!1),[Pe,Be]=h.useState({x:100,y:100}),[fn,oe]=h.useState(!1),[hn,vt]=h.useState({x:0,y:0}),[mn,_n]=h.useState(!1),Ue=h.useRef(null),wt=h.useRef(null),[St,Re]=h.useState(""),[pn,bs]=h.useState(null),[Lt,Xn]=h.useState("Thinking..."),[Tt,lt]=h.useState(new Set),[vs,Wn]=h.useState(""),[Ye,ws]=h.useState([]),qn=h.useRef(new Map),$t=h.useRef(!1),gn=h.useRef(""),[le,yn]=h.useState(!1),[ze,Te]=h.useState(!1),He=h.useMemo(()=>[...d,...f],[d,f]),_e=h.useMemo(()=>pr(He,p),[He,p]),Ft=h.useMemo(()=>{const T=new Map,_=new Map(_e.map(X=>[X.name,X]));return He.forEach(X=>{const q=X[Le];if(q){const J=_.get(q);if(J){T.set(J.name,X);return}}const Z=_e.find(J=>J.name===X.name);Z&&T.set(Z.name,X)}),T},[He,_e]),Ct=h.useMemo(()=>{const T=new Set,_=new Map(_e.map(X=>[X.name,X]));return f.forEach(X=>{const q=X[Le];if(q&&_.has(q))T.add(q);else{const Z=_e.find(J=>J.name===X.name);Z&&T.add(Z.name)}}),m&&Array.isArray(m)&&m.forEach(X=>{typeof X=="string"&&T.add(X)}),T},[f,_e,m]),jt=["Thinking...","Pondering...","Contemplating...","Considering...","Analyzing...","Processing...","Reasoning...","Mulling it over...","Computing...","Cooking up a response...","Brewing ideas...","Connecting the dots...","Piecing it together...","Spinning up thoughts...","Loading brain cells...","Sharpening pencils...","Herding ideas...","Warming up neurons...","Stirring the think-pot...","Plotting a plan...","Wiggling the logic wires...","Rolling ideas around...","Charging the brainstorm...","Booting the brain...","Dusting off the cortex...","Running mental diagnostics...","Fetching cleverness...","Whisking up notions...","Tuning the idea radio...","Juggling possibilities...","Breathing in inspiration...","Squeezing the thought sponge...","Tickling the gray matter...","Bubbling up insights...","Spicing the soup of thought...","Lacing up hypotheses...","Winding the idea clock...","Casting the net for clues...","Polishing the crystal ball...","Mapping the maze...","Crunching the brain-biscuits...","Cueing the eureka moment...","Summoning the muse...","Knocking on insight’s door...","Combing the noodle...","Sailing the think-ship...","Scooping brain gelato...","Testing wild hunches...","Tick-tocking the neurons...","Planting idea seeds...","Shaking the thought snow globe...","Unlocking the mental toolbox...","Nudging the puzzle pieces...","Lighting the idea bulb...","Preheating the oven of insight...","Mixing the mental trail mix...","Spooling up reasoning reels...","Skimming the mind-palace index...","Surfing the thought waves...","Kicking the tires on ideas...","Rattling the idea can...","Waving the logic wand..."];h.useEffect(()=>{if(typeof window<"u"){const T=localStorage.getItem("arcten-sidebar-expanded");T&&H(JSON.parse(T));const _=localStorage.getItem("arcten-sidebar-width");_&&ie(parseInt(_));const X=localStorage.getItem("arcten-sidebar-height");X&&Ge(parseInt(X));const q=localStorage.getItem("arcten-sidebar-detached");q&&Ot(JSON.parse(q));const Z=localStorage.getItem("arcten-sidebar-position");if(Z){const ke=JSON.parse(Z),se=50,be=Math.max(se-i,Math.min(ke.x,window.innerWidth-se)),z=Math.max(0,Math.min(ke.y,window.innerHeight-se));Be({x:be,y:z})}const J=localStorage.getItem("arcten-sidebar-minimized");J&&bt(JSON.parse(J)),_n(!0)}},[]),h.useMemo(()=>E,[E?.id]),h.useEffect(()=>{(async()=>{if(He.length===0)return;const _=He.map(X=>`${X.name}:${X.toString()}`).join("|");if(_!==gn.current&&!$t.current){$t.current=!0,gn.current=_;try{const X=He.map(Z=>({name:Z.name,code:Z.toString()})),q=await fetch(`${F}/tools/describe`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tools:X})});if(q.ok){const Z=await q.json();Z.tools&&Z.tools.forEach(J=>{qn.current.set(J.name,J)}),ws(Z.tools)}}catch(X){console.error("Failed to fetch tool descriptions:",X)}finally{$t.current=!1}}})()},[He,F]),h.useEffect(()=>{Promise.resolve().then(()=>Gh).then(T=>{bs(()=>T.Response)})},[]),h.useEffect(()=>{const T=()=>{Wn(window.location.pathname)};T(),window.addEventListener("popstate",T);const _=setInterval(T,500);return()=>{window.removeEventListener("popstate",T),clearInterval(_)}},[]);const{id:xn,messages:De,sendMessage:Pt,status:xe,error:Kn,stop:Bt,addToolOutput:st,setMessages:Qr,clientToken:bn,tokenError:vn,conversations:Je,isLoadingConversations:ct,loadConversation:Ut,deleteConversation:Xe,startNewConversation:Ze}=B;h.useEffect(()=>{W&&wt.current&&wt.current.focus()},[W,De]),h.useEffect(()=>{const T=De[De.length-1];if(!T||T.role!=="assistant")return;const _=T.parts?.filter(X=>X.type?.startsWith("tool-")&&X.state==="input-available"&&typeof X.toolCallId=="string"&&X.input!==void 0)||[];for(const X of _){const q=X,Z=q.type?.replace("tool-","")||"",J=q.toolCallId;if(Ct.has(Z)){if(Tt.has(J))continue;lt(se=>se.has(J)?se:new Set(se).add(J)),(async()=>{try{const se=Ft.get(Z);if(!se){console.warn(`[ArctenAgent] Tool ${Z} not found in toolsMap`),st({toolCallId:J,tool:Z,output:`Error: Tool ${Z} not found`}),lt(te=>{const he=new Set(te);return he.delete(J),he});return}const be=_s(q.input),z=_e.find(te=>te.name===Z);let fe;if(z&&z.jsonSchema?.properties){const he=Object.keys(z.jsonSchema.properties).map(me=>be[me]);fe=await se(...he)}else fe=await se(...Object.values(be));st({toolCallId:J,tool:Z,output:fe}),lt(te=>{const he=new Set(te);return he.delete(J),he})}catch(se){console.error(`[ArctenAgent] Error executing safe tool ${Z}:`,se),st({toolCallId:J,tool:Z,output:`Error: ${se instanceof Error?se.message:String(se)}`}),lt(be=>{const z=new Set(be);return z.delete(J),z})}})()}}},[De,Ct,Ft,_e,st,Tt]);function Gn(){H(!0),localStorage.setItem("arcten-sidebar-expanded","true")}function Yn(){H(!1),localStorage.setItem("arcten-sidebar-expanded","false")}h.useEffect(()=>{},[W]),h.useEffect(()=>{Ue.current&&Ue.current.scrollIntoView({behavior:"smooth"})},[De]),h.useEffect(()=>{function T(_){_.key==="Escape"&&(xe==="streaming"||xe==="submitted")&&(_.preventDefault(),Bt())}return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[xe,Bt]);function rt(T){const _=Math.floor((Date.now()-T)/1e3);return _<60?"now":_<3600?`${Math.floor(_/60)}m`:_<86400?`${Math.floor(_/3600)}h`:`${Math.floor(_/86400)}d`}function At(){Ze(),Te(!1)}function wn(T){if(T.preventDefault(),!St.trim())return;(xe==="streaming"||xe==="submitted")&&Bt();const _=jt[Math.floor(Math.random()*jt.length)]||"Thinking...";Xn(_),Pt({text:St}),Re("")}function Hn(T){const _=T.target.value;Re(_)}h.useEffect(()=>{if(!xt)return;function T(X){if(Y){const q=X.clientX-Pe.x,Z=X.clientY-Pe.y;q>=a&&q<=l&&ie(q),Z>=400&&Z<=1e3&&Ge(Z)}else{const q=window.innerWidth-X.clientX;q>=a&&q<=l&&ie(q)}}function _(){nt(!1),localStorage.setItem("arcten-sidebar-width",G.toString()),localStorage.setItem("arcten-sidebar-height",ye.toString())}return window.addEventListener("mousemove",T),window.addEventListener("mouseup",_),()=>{window.removeEventListener("mousemove",T),window.removeEventListener("mouseup",_)}},[xt,G,ye,Y,Pe,a,l]);function ut(T){T.preventDefault(),nt(!0)}function zt(){Ot(!0),bt(!1),localStorage.setItem("arcten-sidebar-detached","true"),localStorage.setItem("arcten-sidebar-minimized","false")}function Ss(){Ot(!1),bt(!1),localStorage.setItem("arcten-sidebar-detached","false"),localStorage.setItem("arcten-sidebar-minimized","false")}function _t(){bt(!Me),localStorage.setItem("arcten-sidebar-minimized",JSON.stringify(!Me))}function Sn(T){Y&&(oe(!0),vt({x:T.clientX-Pe.x,y:T.clientY-Pe.y}))}return h.useEffect(()=>{if(!Y)return;function T(){Be(_=>{const q=window.innerWidth-50,Z=window.innerHeight-50,J=50-G,ke=0,se=Math.max(J,Math.min(_.x,q)),be=Math.max(ke,Math.min(_.y,Z));if(se!==_.x||be!==_.y){const z={x:se,y:be};return localStorage.setItem("arcten-sidebar-position",JSON.stringify(z)),z}return _})}return window.addEventListener("resize",T),()=>window.removeEventListener("resize",T)},[Y,G]),h.useEffect(()=>{if(!fn)return;function T(X){const q=X.clientX-hn.x,Z=X.clientY-hn.y,J=50,ke=window.innerWidth-J,se=window.innerHeight-J,be=J-G,z=0,fe=Math.max(be,Math.min(q,ke)),te=Math.max(z,Math.min(Z,se));Be({x:fe,y:te})}function _(){oe(!1),localStorage.setItem("arcten-sidebar-position",JSON.stringify(Pe))}return window.addEventListener("mousemove",T),window.addEventListener("mouseup",_),()=>{window.removeEventListener("mousemove",T),window.removeEventListener("mouseup",_)}},[fn,hn,Pe,G]),mn?vn?c.jsx("div",{className:"fixed right-0 top-0 h-screen w-96 flex items-center justify-center p-4 bg-stone-50 dark:bg-stone-900 border-l border-border",children:c.jsxs("div",{className:"p-4 bg-destructive/10 text-destructive text-sm rounded-lg",children:["Authentication error: ",vn]})}):bn?c.jsx(ld,{features:Fh,children:c.jsx(ts,{id:"arcten-sidebar","data-theme":e,"data-layout":t,"data-model":n,initial:Y?{opacity:0,scale:.95,filter:"blur(4px)"}:!1,animate:Y?{opacity:1,scale:1,filter:"blur(0px)"}:{},transition:{duration:.2,ease:"easeOut"},className:`
|
|
11
|
-
${
|
|
12
|
-
${
|
|
13
|
-
${
|
|
14
|
-
${
|
|
15
|
-
`,style:W?Y?{width:`${G}px`,height:Me?"auto":`${ye}px`,left:`${Pe.x}px`,top:`${Pe.y}px`}:{width:`${G}px`}:void 0,onClick:W?void 0:Gn,children:W?c.jsxs(c.Fragment,{children:[!Y&&c.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-1 cursor-col-resize hover:bg-blue-500/40 hover:w-1 transition-all group",onMouseDown:ut,children:c.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-3 -translate-x-1"})}),Y&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"absolute bottom-0 right-0 w-4 h-4 cursor-nwse-resize",onMouseDown:T=>{T.preventDefault(),nt(!0)}}),c.jsx("div",{className:"absolute bottom-0 left-4 right-4 h-3 cursor-move hover:bg-blue-500/20 group",onMouseDown:T=>{T.preventDefault(),T.stopPropagation(),oe(!0),vt({x:T.clientX-Pe.x,y:T.clientY-Pe.y})},children:c.jsx("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-8 h-1 rounded-full bg-stone-400/30 group-hover:bg-blue-500/40 transition-colors"})}),c.jsx("div",{className:"absolute top-0 right-0 bottom-0 w-1 cursor-ew-resize hover:bg-blue-500/40",onMouseDown:T=>{T.preventDefault(),nt(!0)}})]}),c.jsxs("div",{className:"flex flex-col h-full",children:[c.jsxs("div",{className:`flex items-center justify-between p-3 border-b border-border ${Y?"cursor-move":""}`,onMouseDown:Y?Sn:void 0,children:[c.jsx("h2",{className:`text-base font-semibold ${Y&&Me?"cursor-pointer":""}`,onClick:Y&&Me?T=>{T.stopPropagation(),_t()}:void 0,children:r}),c.jsxs("div",{className:"flex items-center gap-1",onClick:T=>T.stopPropagation(),children:[c.jsxs(dt,{children:[c.jsx(ft,{asChild:!0,children:c.jsx("button",{type:"button",className:ne(Mt({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:At,"aria-label":"New chat",children:c.jsx(ee.Plus,{className:"h-4 w-4"})})}),c.jsx(ht,{children:"Start a new conversation"})]}),c.jsxs(dt,{children:[c.jsx(ft,{asChild:!0,children:c.jsx("button",{type:"button",className:ne(Mt({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:Y?Ss:zt,"aria-label":Y?"Dock sidebar":"Float sidebar",children:Y?c.jsx(ee.Dock,{className:"h-4 w-4"}):c.jsx(ee.PictureInPicture2,{className:"h-4 w-4"})})}),c.jsx(ht,{children:Y?"Dock to sidebar":"Undock to floating window"})]}),c.jsxs(dt,{children:[c.jsx(ft,{asChild:!0,children:c.jsx("button",{type:"button",className:ne(Mt({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:Y?_t:Yn,"aria-label":Y?Me?"Maximize":"Minimize":"Close sidebar",children:Y?Me?c.jsx(ee.Maximize2,{className:"h-4 w-4"}):c.jsx(ee.Minimize2,{className:"h-4 w-4"}):c.jsx(ee.X,{className:"h-4 w-4"})})}),c.jsx(ht,{children:Y?Me?"Maximize window":"Minimize to header":"Close the chat"})]})]})]}),!Me&&c.jsxs(c.Fragment,{children:[E&&Je.length>0&&c.jsxs("div",{className:`border-b border-border ${ze?"flex flex-col flex-1":""}`,children:[c.jsxs("div",{className:"flex items-center justify-between px-3 py-1",children:[c.jsx("h3",{className:"text-xs font-semibold text-muted-foreground",children:"Recent chats"}),c.jsx(je,{variant:"ghost",className:"h-auto px-2 py-1 text-xs text-muted-foreground hover:text-foreground",onClick:()=>{Te(!ze)},children:ze?"Show less":"View all"})]}),c.jsx("div",{className:`px-2 pb-2 space-y-0.5 ${ze?"flex-1 overflow-y-auto":""}`,children:Je.slice(0,ze?void 0:3).map(T=>c.jsxs("div",{className:"group relative",children:[c.jsxs(Bh,{type:"button",className:ne(Mt({variant:"ghost"}),"w-full justify-between h-auto py-1 px-3 font-normal active:scale-[0.99]"),onClick:()=>{Ut(T.chatId||T._id),Te(!1)},children:[c.jsx("span",{className:"text-xs truncate",children:T.title}),c.jsx("div",{className:"ml-2 flex items-center",children:c.jsx("span",{className:"text-xs text-muted-foreground group-hover:hidden",children:rt(T.updatedAt)})})]}),c.jsx("button",{type:"button",className:"absolute right-2 top-1/2 -translate-y-1/2 h-6 w-6 p-0 hidden group-hover:flex items-center justify-center text-muted-foreground hover:text-foreground rounded-md hover:bg-accent transition-colors",onClick:_=>{_.stopPropagation(),Xe(T._id)},"aria-label":"Delete conversation",children:c.jsx(ee.X,{className:"h-3 w-3"})})]},T._id))})]}),c.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden relative",children:[c.jsx("div",{className:"flex-1 overflow-y-auto p-4 space-y-4 scroll-smooth",children:De.length===0?c.jsxs("div",{className:"flex flex-col items-center justify-center h-full",children:[o&&c.jsx("div",{className:"mb-6",children:o}),c.jsx("h3",{className:"text-lg font-semibold text-center mb-2",children:"How can I help you?"}),Ye.length>0&&c.jsx("div",{className:"mt-4 px-4 max-w-md mx-auto",children:c.jsxs("div",{className:"flex flex-wrap gap-2 justify-center",children:[(le?Ye:Ye.slice(0,10)).map(T=>c.jsxs(dt,{children:[c.jsx(ft,{asChild:!0,children:c.jsx(Ps,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>{Re(T.sampleUsage),wt.current?.focus()},children:T.friendlyName})}),c.jsx(ht,{children:c.jsxs("div",{className:"max-w-xs",children:[c.jsx("p",{className:"font-medium",children:T.description}),c.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:[c.jsx("span",{className:"font-medium",children:"Example:"}),' "',T.sampleUsage,'"']}),T.paramCount>0&&c.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[c.jsx("span",{className:"font-medium",children:"Parameters:"})," ",T.params.join(", ")]})]})})]},T.name)),Ye.length>10&&!le&&c.jsxs(dt,{children:[c.jsx(ft,{asChild:!0,children:c.jsxs(Ps,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>yn(!0),children:["+",Ye.length-10," more"]})}),c.jsx(ht,{children:c.jsxs("div",{className:"max-w-xs",children:[c.jsx("p",{className:"font-medium mb-2",children:"Additional tools:"}),c.jsx("div",{className:"space-y-1 max-h-64 overflow-y-auto pr-2",children:Ye.slice(10).map(T=>c.jsxs("div",{children:[c.jsxs("span",{className:"font-medium text-xs",children:[T.friendlyName,":"]}),c.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:T.description})]},T.name))}),c.jsx("p",{className:"text-xs text-muted-foreground mt-2 italic",children:"Click to show all tools"})]})})]}),le&&Ye.length>10&&c.jsx(Ps,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>yn(!1),children:"Show less"})]})})]}):c.jsxs(c.Fragment,{children:[De.map(T=>{const X=T.parts.filter(z=>z.type==="text").map(z=>z.text).join("");let q=T.parts;T.role==="assistant"&&T.parts.some(fe=>fe.timestamp)&&(q=[...T.parts].sort((fe,te)=>{const he=fe.timestamp||0,me=te.timestamp||0;return he-me}));let Z=[],J=new Map,ke=[],se,be=!0;if(T.role==="assistant"){const z=q.filter(me=>me.type==="text"&&me.text),fe=[],te=[];z.forEach(me=>{const{citations:Qe,citationMap:we,groupedCitations:Ae,referencesText:Ve}=So(me.text);Z.push(...Qe),fe.push(we),Ae&&te.push(...Ae),Ve&&(se=Ve)}),fe.forEach(me=>{me.forEach((Qe,we)=>{J.has(we)||J.set(we,Qe)})}),ke=Array.from(new Map(te.map(me=>[me.url,me])).values()).sort((me,Qe)=>(me.numbers[0]||0)-(Qe.numbers[0]||0)),be=!(xe==="streaming"&&T.id===De.at(-1)?.id)}return c.jsx("div",{className:`${T.role==="user"?"flex justify-end":"w-full"}`,children:c.jsx("div",{className:`${T.role==="user"?"max-w-[85%] text-right":"w-full"}`,children:T.role==="user"?c.jsx(Uh,{initial:{opacity:0,filter:"blur(4px)"},animate:{opacity:1,filter:"blur(0px)"},transition:{duration:.3,ease:"easeOut"},className:"text-sm whitespace-pre-wrap inline-block bg-stone-100 dark:bg-stone-800 px-3 py-2 rounded-xl",children:X}):c.jsx("div",{className:"space-y-2",children:q.map((z,fe)=>{if(z.type?.startsWith("tool-")){const te=z.type?.replace("tool-","")||"",he=_e.find(we=>we.name===te),me=z.state==="input-available",Qe=z.state==="output-available";if(me&&Ct.has(te),me){if(Ct.has(te))return null;const we=_s(z.input);return c.jsx(ts,{initial:{opacity:0,y:10,filter:"blur(4px)"},animate:{opacity:1,y:0,filter:"blur(0px)"},transition:{duration:.3,ease:"easeOut"},children:c.jsx(zh,{toolName:te,description:he?.description||"",args:we,onApprove:async()=>{if(Tt.has(z.toolCallId))return;lt(Ve=>new Set(Ve).add(z.toolCallId));const Ae=Ft.get(te);if(Ae)try{const Ve=await Ae(...Object.values(we));st({toolCallId:z.toolCallId,tool:te,output:Ve})}catch(Ve){st({toolCallId:z.toolCallId,tool:te,output:`Error: ${Ve}`})}},onDeny:async()=>{Tt.has(z.toolCallId)||(lt(Ae=>new Set(Ae).add(z.toolCallId)),st({toolCallId:z.toolCallId,tool:te,output:"User denied tool execution"}))}})},`${z.toolCallId}-${fe}`)}else if(Qe){const we=z.output==="User denied tool execution",Ae=_s(z.input);return c.jsx(_h,{toolName:te,args:Ae,isDenied:we,isSafe:Ct.has(te)},`${z.toolCallId}-${fe}`)}return null}if(z.type==="text"&&z.text&&pn){const{processedText:te}=So(z.text),we=!q.slice(fe+1).some(Ae=>Ae.type==="text"&&Ae.text)&&be&&J.size>0;return c.jsx(nm,{text:te,citations:Z,citationMap:J,groupedCitations:we?ke:void 0,referencesText:we?se:void 0,ResponseComponent:pn,className:"text-sm prose prose-sm dark:prose-invert max-w-none",showCitations:O,showReferences:we},`${T.id}-${fe}`)}return z.type==="reasoning"&&z.text?c.jsxs(dl,{className:"w-full",isStreaming:xe==="streaming"&&fe===T.parts.length-1&&T.id===De.at(-1)?.id,children:[c.jsx(fl,{}),c.jsx(hl,{children:z.text})]},`${T.id}-${fe}`):null})})})},T.id)}),c.jsx("div",{ref:Ue})]})}),Kn&&c.jsxs("div",{className:"px-4 py-2 bg-destructive/10 text-destructive text-xs",children:["Error: ",Kn.message]}),c.jsxs("div",{className:"p-4 border-t border-border relative overflow-visible",children:[c.jsx(ad,{mode:"wait",children:(xe==="streaming"||xe==="submitted")&&c.jsxs(ts,{initial:{opacity:0,filter:"blur(4px)",y:5},animate:{opacity:1,filter:"blur(0px)",y:0},exit:{opacity:0,filter:"blur(4px)",y:5},transition:{duration:.2,ease:"easeOut"},className:"absolute left-1/2 -translate-x-1/2 -top-6 flex items-center gap-1.5 bg-stone-100 dark:bg-stone-800 px-3 py-1.5 rounded-full shadow-lg border border-border z-50",children:[c.jsx(ts,{className:"w-2 h-2 bg-stone-400 dark:bg-stone-600",animate:{rotate:[0,0,90,90],borderRadius:["50%","30%","30%","50%"],scale:[.75,1,1,.75]},transition:{duration:2,repeat:1/0,ease:"easeInOut",times:[0,.4,.6,1]}}),c.jsx("p",{className:"text-xs text-muted-foreground",children:Lt})]})}),c.jsxs("form",{onSubmit:wn,className:"relative",children:[c.jsx(Mo,{ref:wt,value:St,onChange:Hn,placeholder:"Ask anything..",className:"w-full pr-12 resize-none border border-border rounded-xl px-4 py-3",minHeight:24,maxHeight:200,onKeyDown:T=>{T.key==="Enter"&&!T.shiftKey&&(T.preventDefault(),wn(T))}}),xe==="streaming"||xe==="submitted"?c.jsxs(dt,{children:[c.jsx(ft,{asChild:!0,children:c.jsx("button",{type:"button",className:ne(Mt({variant:"ghost",size:"icon"}),"absolute top-1/2 -translate-y-1/2 right-2 h-8 w-8"),onClick:Bt,children:c.jsx(ee.Square,{className:"h-4 w-4"})})}),c.jsxs(ht,{children:[c.jsx(ri,{children:"Escape"})," to stop"]})]}):c.jsxs(dt,{children:[c.jsx(ft,{asChild:!0,children:c.jsx("button",{type:"submit",className:ne(Mt({variant:"ghost",size:"icon"}),"absolute top-1/2 -translate-y-1/2 right-2 h-8 w-8"),disabled:!St.trim(),children:c.jsx(ee.ArrowRight,{className:"h-4 w-4"})})}),c.jsxs(ht,{children:[c.jsx(ri,{children:"Enter"})," to send"]})]})]})]})]}),c.jsxs("a",{href:"https://arcten.com",target:"_blank",rel:"noopener noreferrer",className:"group flex items-center justify-center gap-1.5 py-3 text-xs text-muted-foreground/40 hover:text-muted-foreground/60 transition-all",children:[c.jsx("span",{className:"whitespace-nowrap",children:"Powered by"}),c.jsx("div",{className:"w-4 h-2 bg-current rounded-t-full flex-shrink-0"}),c.jsx("span",{className:"whitespace-nowrap",children:"Arcten"})]})]})]})]}):c.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 h-full cursor-pointer",children:[c.jsx(ee.BotMessageSquare,{className:"h-5 w-5 text-stone-600 dark:text-stone-400"}),c.jsx("span",{className:"text-xs font-medium text-stone-600 dark:text-stone-400 [writing-mode:vertical-lr]",children:"AI agent"})]})})}):c.jsx("div",{className:"fixed right-0 top-0 h-screen w-96 flex items-center justify-center p-4 bg-stone-50 dark:bg-stone-900 border-l border-border",children:c.jsx("div",{className:"p-4 text-muted-foreground text-sm",children:"Loading..."})}):null}function hm(e){return c.jsx(gl,{children:c.jsx(fm,{...e})})}exports.verifyToken=Il.verifyToken;exports.ARCTEN_ORIGINAL_NAME=Le;exports.ArctenAgent=hm;exports.SecureModalProvider=gl;exports.extractToolsMetadata=pr;exports.preserveToolName=Ol;exports.useAgent=Eo;exports.useSecureModal=pl;
|
|
10
|
+
`),()=>{C.contains(v)&&C.removeChild(v)}},[t]),c.jsx(ed,{isPresent:t,childRef:o,sizeRef:i,children:We.cloneElement(e,{ref:l})})}const nd=({children:e,initial:t,isPresent:n,onExitComplete:s,custom:r,presenceAffectsLayout:o,mode:i,anchorX:a,root:l})=>{const u=yr(sd),d=f.useId();let h=!0,m=f.useMemo(()=>(h=!1,{id:d,initial:t,isPresent:n,custom:r,onExitComplete:p=>{u.set(p,!0);for(const T of u.values())if(!T)return;s&&s()},register:p=>(u.set(p,!1),()=>u.delete(p))}),[n,u,s]);return o&&h&&(m={...m}),f.useMemo(()=>{u.forEach((p,T)=>u.set(T,!1))},[n]),We.useEffect(()=>{!n&&!u.size&&s&&s()},[n]),i==="popLayout"&&(e=c.jsx(td,{isPresent:n,anchorX:a,root:l,children:e})),c.jsx(gs.Provider,{value:m,children:e})};function sd(){return new Map}function va(e=!0){const t=f.useContext(gs);if(t===null)return[!0,null];const{isPresent:n,onExitComplete:s,register:r}=t,o=f.useId();f.useEffect(()=>{if(e)return r(o)},[e]);const i=f.useCallback(()=>e&&s&&s(o),[o,s,e]);return!n&&s?[!1,i]:[!0]}const es=e=>e.key||"";function Pi(e){const t=[];return f.Children.forEach(e,n=>{f.isValidElement(n)&&t.push(n)}),t}const rd=({children:e,custom:t,initial:n=!0,onExitComplete:s,presenceAffectsLayout:r=!0,mode:o="sync",propagate:i=!1,anchorX:a="left",root:l})=>{const[u,d]=va(i),h=f.useMemo(()=>Pi(e),[e]),m=i&&!u?[]:h.map(es),p=f.useRef(!0),T=f.useRef(h),v=yr(()=>new Map),[C,b]=f.useState(h),[E,M]=f.useState(h);Eo(()=>{p.current=!1,T.current=h;for(let I=0;I<E.length;I++){const N=es(E[I]);m.includes(N)?v.delete(N):v.get(N)!==!0&&v.set(N,!1)}},[E,m.length,m.join("-")]);const $=[];if(h!==C){let I=[...h];for(let N=0;N<E.length;N++){const j=E[N],O=es(j);m.includes(O)||(I.splice(N,0,j),$.push(j))}return o==="wait"&&$.length&&(I=$),M(Pi(I)),b(h),null}process.env.NODE_ENV!=="production"&&o==="wait"&&E.length>1&&console.warn(`You're attempting to animate multiple children within AnimatePresence, but its mode is set to "wait". This will lead to odd visual behaviour.`);const{forceRender:R}=f.useContext(gr);return c.jsx(c.Fragment,{children:E.map(I=>{const N=es(I),j=i&&!u?!1:h===E||m.includes(N),O=()=>{if(v.has(N))v.set(N,!0);else return;let A=!0;v.forEach(k=>{k||(A=!1)}),A&&(R?.(),M(T.current),i&&d?.(),s&&s())};return c.jsx(nd,{isPresent:j,initial:!p.current||n?void 0:!1,custom:t,presenceAffectsLayout:r,mode:o,root:l,onExitComplete:j?void 0:O,anchorX:a,children:I},N)})})},Ur=f.createContext({strict:!1}),Ai={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]},Ht={};for(const e in Ai)Ht[e]={isEnabled:t=>Ai[e].some(n=>!!t[n])};function ir(e){for(const t in e)Ht[t]={...Ht[t],...e[t]}}function id({children:e,features:t,strict:n=!1}){const[,s]=f.useState(!Ds(t)),r=f.useRef(void 0);if(!Ds(t)){const{renderer:o,...i}=t;r.current=o,ir(i)}return f.useEffect(()=>{Ds(t)&&t().then(({renderer:o,...i})=>{ir(i),r.current=o,s(!0)})},[]),c.jsx(Ur.Provider,{value:{renderer:r.current,strict:n},children:e})}function Ds(e){return typeof e=="function"}const od=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","ignoreStrict","viewport"]);function fs(e){return e.startsWith("while")||e.startsWith("drag")&&e!=="draggable"||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||od.has(e)}let wa=e=>!fs(e);function ad(e){typeof e=="function"&&(wa=t=>t.startsWith("on")?!fs(t):e(t))}try{ad(require("@emotion/is-prop-valid").default)}catch{}function ld(e,t,n){const s={};for(const r in e)r==="values"&&typeof e.values=="object"||(wa(r)||n===!0&&fs(r)||!t&&!fs(r)||e.draggable&&r.startsWith("onDrag"))&&(s[r]=e[r]);return s}const ys=f.createContext({});function xs(e){return e!==null&&typeof e=="object"&&typeof e.start=="function"}function Dn(e){return typeof e=="string"||Array.isArray(e)}const zr=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],_r=["initial",...zr];function bs(e){return xs(e.animate)||_r.some(t=>Dn(e[t]))}function Sa(e){return!!(bs(e)||e.variants)}function cd(e,t){if(bs(e)){const{initial:n,animate:s}=e;return{initial:n===!1||Dn(n)?n:void 0,animate:Dn(s)?s:void 0}}return e.inherit!==!1?t:{}}function ud(e){const{initial:t,animate:n}=cd(e,f.useContext(ys));return f.useMemo(()=>({initial:t,animate:n}),[Mi(t),Mi(n)])}function Mi(e){return Array.isArray(e)?e.join(" "):e}const Vn={};function dd(e){for(const t in e)Vn[t]=e[t],Pr(t)&&(Vn[t].isCSSVariable=!0)}function Ta(e,{layout:t,layoutId:n}){return en.has(e)||e.startsWith("origin")||(t||n!==void 0)&&(!!Vn[e]||e==="opacity")}const hd={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},fd=Qt.length;function md(e,t,n){let s="",r=!0;for(let o=0;o<fd;o++){const i=Qt[o],a=e[i];if(a===void 0)continue;let l=!0;if(typeof a=="number"?l=a===(i.startsWith("scale")?1:0):l=parseFloat(a)===0,!l||n){const u=ma(a,Lr[i]);if(!l){r=!1;const d=hd[i]||i;s+=`${d}(${u}) `}n&&(t[i]=u)}}return s=s.trim(),n?s=n(t,r?"":s):r&&(s="none"),s}function Xr(e,t,n){const{style:s,vars:r,transformOrigin:o}=e;let i=!1,a=!1;for(const l in t){const u=t[l];if(en.has(l)){i=!0;continue}else if(Pr(l)){r[l]=u;continue}else{const d=ma(u,Lr[l]);l.startsWith("origin")?(a=!0,o[l]=d):s[l]=d}}if(t.transform||(i||n?s.transform=md(t,e.transform,n):s.transform&&(s.transform="none")),a){const{originX:l="50%",originY:u="50%",originZ:d=0}=o;s.transformOrigin=`${l} ${u} ${d}`}}const Wr=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function Ca(e,t,n){for(const s in t)!Se(t[s])&&!Ta(s,n)&&(e[s]=t[s])}function pd({transformTemplate:e},t){return f.useMemo(()=>{const n=Wr();return Xr(n,t,e),Object.assign({},n.vars,n.style)},[t])}function gd(e,t){const n=e.style||{},s={};return Ca(s,n,e),Object.assign(s,pd(e,t)),s}function yd(e,t){const n={},s=gd(e,t);return e.drag&&e.dragListener!==!1&&(n.draggable=!1,s.userSelect=s.WebkitUserSelect=s.WebkitTouchCallout="none",s.touchAction=e.drag===!0?"none":`pan-${e.drag==="x"?"y":"x"}`),e.tabIndex===void 0&&(e.onTap||e.onTapStart||e.whileTap)&&(n.tabIndex=0),n.style=s,n}const xd={offset:"stroke-dashoffset",array:"stroke-dasharray"},bd={offset:"strokeDashoffset",array:"strokeDasharray"};function vd(e,t,n=1,s=0,r=!0){e.pathLength=1;const o=r?xd:bd;e[o.offset]=z.transform(-s);const i=z.transform(t),a=z.transform(n);e[o.array]=`${i} ${a}`}function ja(e,{attrX:t,attrY:n,attrScale:s,pathLength:r,pathSpacing:o=1,pathOffset:i=0,...a},l,u,d){if(Xr(e,a,u),l){e.style.viewBox&&(e.attrs.viewBox=e.style.viewBox);return}e.attrs=e.style,e.style={};const{attrs:h,style:m}=e;h.transform&&(m.transform=h.transform,delete h.transform),(m.transform||h.transformOrigin)&&(m.transformOrigin=h.transformOrigin??"50% 50%",delete h.transformOrigin),m.transform&&(m.transformBox=d?.transformBox??"fill-box",delete h.transformBox),t!==void 0&&(h.x=t),n!==void 0&&(h.y=n),s!==void 0&&(h.scale=s),r!==void 0&&vd(h,r,o,i,!1)}const Pa=()=>({...Wr(),attrs:{}}),Aa=e=>typeof e=="string"&&e.toLowerCase()==="svg";function wd(e,t,n,s){const r=f.useMemo(()=>{const o=Pa();return ja(o,t,Aa(s),e.transformTemplate,e.style),{...o.attrs,style:{...o.style}}},[t]);if(e.style){const o={};Ca(o,e.style,e),r.style={...o,...r.style}}return r}const Sd=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function qr(e){return typeof e!="string"||e.includes("-")?!1:!!(Sd.indexOf(e)>-1||/[A-Z]/u.test(e))}function Td(e,t,n,{latestValues:s},r,o=!1){const a=(qr(e)?wd:yd)(t,s,r,e),l=ld(t,typeof e=="string",o),u=e!==f.Fragment?{...l,...a,ref:n}:{},{children:d}=t,h=f.useMemo(()=>Se(d)?d.get():d,[d]);return f.createElement(e,{...u,children:h})}function Ei(e){const t=[{},{}];return e?.values.forEach((n,s)=>{t[0][s]=n.get(),t[1][s]=n.getVelocity()}),t}function Kr(e,t,n,s){if(typeof t=="function"){const[r,o]=Ei(s);t=t(n!==void 0?n:e.custom,r,o)}if(typeof t=="string"&&(t=e.variants&&e.variants[t]),typeof t=="function"){const[r,o]=Ei(s);t=t(n!==void 0?n:e.custom,r,o)}return t}function as(e){return Se(e)?e.get():e}function Cd({scrapeMotionValuesFromProps:e,createRenderState:t},n,s,r){return{latestValues:jd(n,s,r,e),renderState:t()}}function jd(e,t,n,s){const r={},o=s(e,{});for(const m in o)r[m]=as(o[m]);let{initial:i,animate:a}=e;const l=bs(e),u=Sa(e);t&&u&&!l&&e.inherit!==!1&&(i===void 0&&(i=t.initial),a===void 0&&(a=t.animate));let d=n?n.initial===!1:!1;d=d||i===!1;const h=d?a:i;if(h&&typeof h!="boolean"&&!xs(h)){const m=Array.isArray(h)?h:[h];for(let p=0;p<m.length;p++){const T=Kr(e,m[p]);if(T){const{transitionEnd:v,transition:C,...b}=T;for(const E in b){let M=b[E];if(Array.isArray(M)){const $=d?M.length-1:0;M=M[$]}M!==null&&(r[E]=M)}for(const E in v)r[E]=v[E]}}}return r}const Ma=e=>(t,n)=>{const s=f.useContext(ys),r=f.useContext(gs),o=()=>Cd(e,t,s,r);return n?o():yr(o)};function Gr(e,t,n){const{style:s}=e,r={};for(const o in s)(Se(s[o])||t.style&&Se(t.style[o])||Ta(o,e)||n?.getValue(o)?.liveStyle!==void 0)&&(r[o]=s[o]);return r}const Pd=Ma({scrapeMotionValuesFromProps:Gr,createRenderState:Wr});function Ea(e,t,n){const s=Gr(e,t,n);for(const r in e)if(Se(e[r])||Se(t[r])){const o=Qt.indexOf(r)!==-1?"attr"+r.charAt(0).toUpperCase()+r.substring(1):r;s[o]=e[r]}return s}const Ad=Ma({scrapeMotionValuesFromProps:Ea,createRenderState:Pa}),Md=Symbol.for("motionComponentSymbol");function _t(e){return e&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"current")}function Ed(e,t,n){return f.useCallback(s=>{s&&e.onMount&&e.onMount(s),t&&(s?t.mount(s):t.unmount()),n&&(typeof n=="function"?n(s):_t(n)&&(n.current=s))},[t])}const Yr=e=>e.replace(/([a-z])([A-Z])/gu,"$1-$2").toLowerCase(),kd="framerAppearId",ka="data-"+Yr(kd),Na=f.createContext({});function Nd(e,t,n,s,r){const{visualElement:o}=f.useContext(ys),i=f.useContext(Ur),a=f.useContext(gs),l=f.useContext(Br).reducedMotion,u=f.useRef(null);s=s||i.renderer,!u.current&&s&&(u.current=s(e,{visualState:t,parent:o,props:n,presenceContext:a,blockInitialAnimation:a?a.initial===!1:!1,reducedMotionConfig:l}));const d=u.current,h=f.useContext(Na);d&&!d.projection&&r&&(d.type==="html"||d.type==="svg")&&Rd(u.current,n,r,h);const m=f.useRef(!1);f.useInsertionEffect(()=>{d&&m.current&&d.update(n,a)});const p=n[ka],T=f.useRef(!!p&&!window.MotionHandoffIsComplete?.(p)&&window.MotionHasOptimisedAnimation?.(p));return Eo(()=>{d&&(m.current=!0,window.MotionIsMounted=!0,d.updateFeatures(),d.scheduleRenderMicrotask(),T.current&&d.animationState&&d.animationState.animateChanges())}),f.useEffect(()=>{d&&(!T.current&&d.animationState&&d.animationState.animateChanges(),T.current&&(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(p)}),T.current=!1),d.enteringChildren=void 0)}),d}function Rd(e,t,n,s){const{layoutId:r,layout:o,drag:i,dragConstraints:a,layoutScroll:l,layoutRoot:u,layoutCrossfade:d}=t;e.projection=new n(e.latestValues,t["data-framer-portal-id"]?void 0:Ra(e.parent)),e.projection.setOptions({layoutId:r,layout:o,alwaysMeasureLayout:!!i||a&&_t(a),visualElement:e,animationType:typeof o=="string"?o:"both",initialPromotionConfig:s,crossfade:d,layoutScroll:l,layoutRoot:u})}function Ra(e){if(e)return e.options.allowProjection!==!1?e.projection:Ra(e.parent)}function ls(e,{forwardMotionProps:t=!1}={},n,s){n&&ir(n);const r=qr(e)?Ad:Pd;function o(a,l){let u;const d={...f.useContext(Br),...a,layoutId:Dd(a)},{isStatic:h}=d,m=ud(a),p=r(a,h);if(!h&&xr){Vd(d,n);const T=Id(d);u=T.MeasureLayout,m.visualElement=Nd(e,p,d,s,T.ProjectionNode)}return c.jsxs(ys.Provider,{value:m,children:[u&&m.visualElement?c.jsx(u,{visualElement:m.visualElement,...d}):null,Td(e,a,Ed(p,m.visualElement,l),p,h,t)]})}o.displayName=`motion.${typeof e=="string"?e:`create(${e.displayName??e.name??""})`}`;const i=f.forwardRef(o);return i[Md]=e,i}function Dd({layoutId:e}){const t=f.useContext(gr).id;return t&&e!==void 0?t+"-"+e:e}function Vd(e,t){const n=f.useContext(Ur).strict;if(process.env.NODE_ENV!=="production"&&t&&n){const s="You have rendered a `motion` component within a `LazyMotion` component. This will break tree shaking. Import and render a `m` component instead.";e.ignoreStrict?Jt(!1,s,"lazy-strict-mode"):at(!1,s,"lazy-strict-mode")}}function Id(e){const{drag:t,layout:n}=Ht;if(!t&&!n)return{};const s={...t,...n};return{MeasureLayout:t?.isEnabled(e)||n?.isEnabled(e)?s.MeasureLayout:void 0,ProjectionNode:s.ProjectionNode}}function Od(e,t){if(typeof Proxy>"u")return ls;const n=new Map,s=(o,i)=>ls(o,i,e,t),r=(o,i)=>(process.env.NODE_ENV!=="production"&&Tr(!1,"motion() is deprecated. Use motion.create() instead."),s(o,i));return new Proxy(r,{get:(o,i)=>i==="create"?s:(n.has(i)||n.set(i,ls(i,void 0,e,t)),n.get(i))})}function Da({top:e,left:t,right:n,bottom:s}){return{x:{min:t,max:n},y:{min:e,max:s}}}function Ld({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function $d(e,t){if(!t)return e;const n=t({x:e.left,y:e.top}),s=t({x:e.right,y:e.bottom});return{top:n.y,left:n.x,bottom:s.y,right:s.x}}function Vs(e){return e===void 0||e===1}function or({scale:e,scaleX:t,scaleY:n}){return!Vs(e)||!Vs(t)||!Vs(n)}function Mt(e){return or(e)||Va(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function Va(e){return ki(e.x)||ki(e.y)}function ki(e){return e&&e!=="0%"}function ms(e,t,n){const s=e-n,r=t*s;return n+r}function Ni(e,t,n,s,r){return r!==void 0&&(e=ms(e,r,s)),ms(e,n,s)+t}function ar(e,t=0,n=1,s,r){e.min=Ni(e.min,t,n,s,r),e.max=Ni(e.max,t,n,s,r)}function Ia(e,{x:t,y:n}){ar(e.x,t.translate,t.scale,t.originPoint),ar(e.y,n.translate,n.scale,n.originPoint)}const Ri=.999999999999,Di=1.0000000000001;function Fd(e,t,n,s=!1){const r=n.length;if(!r)return;t.x=t.y=1;let o,i;for(let a=0;a<r;a++){o=n[a],i=o.projectionDelta;const{visualElement:l}=o.options;l&&l.props.style&&l.props.style.display==="contents"||(s&&o.options.layoutScroll&&o.scroll&&o!==o.root&&Wt(e,{x:-o.scroll.offset.x,y:-o.scroll.offset.y}),i&&(t.x*=i.x.scale,t.y*=i.y.scale,Ia(e,i)),s&&Mt(o.latestValues)&&Wt(e,o.latestValues))}t.x<Di&&t.x>Ri&&(t.x=1),t.y<Di&&t.y>Ri&&(t.y=1)}function Xt(e,t){e.min=e.min+t,e.max=e.max+t}function Vi(e,t,n,s,r=.5){const o=de(e.min,e.max,r);ar(e,t,n,o,s)}function Wt(e,t){Vi(e.x,t.x,t.scaleX,t.scale,t.originX),Vi(e.y,t.y,t.scaleY,t.scale,t.originY)}function Oa(e,t){return Da($d(e.getBoundingClientRect(),t))}function Bd(e,t,n){const s=Oa(e,n),{scroll:r}=t;return r&&(Xt(s.x,r.offset.x),Xt(s.y,r.offset.y)),s}const Ii=()=>({translate:0,scale:1,origin:0,originPoint:0}),qt=()=>({x:Ii(),y:Ii()}),Oi=()=>({min:0,max:0}),me=()=>({x:Oi(),y:Oi()}),lr={current:null},La={current:!1};function Ud(){if(La.current=!0,!!xr)if(window.matchMedia){const e=window.matchMedia("(prefers-reduced-motion)"),t=()=>lr.current=e.matches;e.addEventListener("change",t),t()}else lr.current=!1}const zd=new WeakMap;function _d(e,t,n){for(const s in t){const r=t[s],o=n[s];if(Se(r))e.addValue(s,r);else if(Se(o))e.addValue(s,Yt(r,{owner:e}));else if(o!==r)if(e.hasValue(s)){const i=e.getValue(s);i.liveStyle===!0?i.jump(r):i.hasAnimated||i.set(r)}else{const i=e.getStaticValue(s);e.addValue(s,Yt(i!==void 0?i:r,{owner:e}))}}for(const s in n)t[s]===void 0&&e.removeValue(s);return t}const Li=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];class Xd{scrapeMotionValuesFromProps(t,n,s){return{}}constructor({parent:t,props:n,presenceContext:s,reducedMotionConfig:r,blockInitialAnimation:o,visualState:i},a={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.values=new Map,this.KeyframeResolver=Ir,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},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 m=Ne.now();this.renderScheduledAt<m&&(this.renderScheduledAt=m,le.render(this.render,!1,!0))};const{latestValues:l,renderState:u}=i;this.latestValues=l,this.baseTarget={...l},this.initialValues=n.initial?{...l}:{},this.renderState=u,this.parent=t,this.props=n,this.presenceContext=s,this.depth=t?t.depth+1:0,this.reducedMotionConfig=r,this.options=a,this.blockInitialAnimation=!!o,this.isControllingVariants=bs(n),this.isVariantNode=Sa(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(t&&t.current);const{willChange:d,...h}=this.scrapeMotionValuesFromProps(n,{},this);for(const m in h){const p=h[m];l[m]!==void 0&&Se(p)&&p.set(l[m])}}mount(t){this.current=t,zd.set(t,this),this.projection&&!this.projection.instance&&this.projection.mount(t),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((n,s)=>this.bindToMotionValue(s,n)),La.current||Ud(),this.shouldReduceMotion=this.reducedMotionConfig==="never"?!1:this.reducedMotionConfig==="always"?!0:lr.current,process.env.NODE_ENV!=="production"&&Tr(this.shouldReduceMotion!==!0,"You have Reduced Motion enabled on your device. Animations may not appear as expected.","reduced-motion-disabled"),this.parent?.addChild(this),this.update(this.props,this.presenceContext)}unmount(){this.projection&&this.projection.unmount(),gt(this.notifyUpdate),gt(this.render),this.valueSubscriptions.forEach(t=>t()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent?.removeChild(this);for(const t in this.events)this.events[t].clear();for(const t in this.features){const n=this.features[t];n&&(n.unmount(),n.isMounted=!1)}this.current=null}addChild(t){this.children.add(t),this.enteringChildren??(this.enteringChildren=new Set),this.enteringChildren.add(t)}removeChild(t){this.children.delete(t),this.enteringChildren&&this.enteringChildren.delete(t)}bindToMotionValue(t,n){this.valueSubscriptions.has(t)&&this.valueSubscriptions.get(t)();const s=en.has(t);s&&this.onBindTransform&&this.onBindTransform();const r=n.on("change",i=>{this.latestValues[t]=i,this.props.onUpdate&&le.preRender(this.notifyUpdate),s&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});let o;window.MotionCheckAppearSync&&(o=window.MotionCheckAppearSync(this,t,n)),this.valueSubscriptions.set(t,()=>{r(),o&&o(),n.owner&&n.stop()})}sortNodePosition(t){return!this.current||!this.sortInstanceNodePosition||this.type!==t.type?0:this.sortInstanceNodePosition(this.current,t.current)}updateFeatures(){let t="animation";for(t in Ht){const n=Ht[t];if(!n)continue;const{isEnabled:s,Feature:r}=n;if(!this.features[t]&&r&&s(this.props)&&(this.features[t]=new r(this)),this.features[t]){const o=this.features[t];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):me()}getStaticValue(t){return this.latestValues[t]}setStaticValue(t,n){this.latestValues[t]=n}update(t,n){(t.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=t,this.prevPresenceContext=this.presenceContext,this.presenceContext=n;for(let s=0;s<Li.length;s++){const r=Li[s];this.propEventSubscriptions[r]&&(this.propEventSubscriptions[r](),delete this.propEventSubscriptions[r]);const o="on"+r,i=t[o];i&&(this.propEventSubscriptions[r]=this.on(r,i))}this.prevMotionValues=_d(this,this.scrapeMotionValuesFromProps(t,this.prevProps,this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(t){return this.props.variants?this.props.variants[t]: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(t){const n=this.getClosestVariantNode();if(n)return n.variantChildren&&n.variantChildren.add(t),()=>n.variantChildren.delete(t)}addValue(t,n){const s=this.values.get(t);n!==s&&(s&&this.removeValue(t),this.bindToMotionValue(t,n),this.values.set(t,n),this.latestValues[t]=n.get())}removeValue(t){this.values.delete(t);const n=this.valueSubscriptions.get(t);n&&(n(),this.valueSubscriptions.delete(t)),delete this.latestValues[t],this.removeValueFromRenderState(t,this.renderState)}hasValue(t){return this.values.has(t)}getValue(t,n){if(this.props.values&&this.props.values[t])return this.props.values[t];let s=this.values.get(t);return s===void 0&&n!==void 0&&(s=Yt(n===null?void 0:n,{owner:this}),this.addValue(t,s)),s}readValue(t,n){let s=this.latestValues[t]!==void 0||!this.current?this.latestValues[t]:this.getBaseTargetFromProps(this.props,t)??this.readValueFromInstance(this.current,t,this.options);return s!=null&&(typeof s=="string"&&(ko(s)||Ro(s))?s=parseFloat(s):!Ju(s)&&yt.test(n)&&(s=fa(t,n)),this.setBaseTarget(t,Se(s)?s.get():s)),Se(s)?s.get():s}setBaseTarget(t,n){this.baseTarget[t]=n}getBaseTarget(t){const{initial:n}=this.props;let s;if(typeof n=="string"||typeof n=="object"){const o=Kr(this.props,n,this.presenceContext?.custom);o&&(s=o[t])}if(n&&s!==void 0)return s;const r=this.getBaseTargetFromProps(this.props,t);return r!==void 0&&!Se(r)?r:this.initialValues[t]!==void 0&&s===void 0?void 0:this.baseTarget[t]}on(t,n){return this.events[t]||(this.events[t]=new Sr),this.events[t].add(n)}notify(t,...n){this.events[t]&&this.events[t].notify(...n)}scheduleRenderMicrotask(){$r.render(this.render)}}class $a extends Xd{constructor(){super(...arguments),this.KeyframeResolver=Fu}sortInstanceNodePosition(t,n){return t.compareDocumentPosition(n)&2?1:-1}getBaseTargetFromProps(t,n){return t.style?t.style[n]:void 0}removeValueFromRenderState(t,{vars:n,style:s}){delete n[t],delete s[t]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:t}=this.props;Se(t)&&(this.childSubscription=t.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}function Fa(e,{style:t,vars:n},s,r){const o=e.style;let i;for(i in t)o[i]=t[i];r?.applyProjectionStyles(o,s);for(i in n)o.setProperty(i,n[i])}function Wd(e){return window.getComputedStyle(e)}class qd extends $a{constructor(){super(...arguments),this.type="html",this.renderInstance=Fa}readValueFromInstance(t,n){if(en.has(n))return this.projection?.isProjecting?Zs(n):su(t,n);{const s=Wd(t),r=(Pr(n)?s.getPropertyValue(n):s[n])||0;return typeof r=="string"?r.trim():r}}measureInstanceViewportBox(t,{transformPagePoint:n}){return Oa(t,n)}build(t,n,s){Xr(t,n,s.transformTemplate)}scrapeMotionValuesFromProps(t,n,s){return Gr(t,n,s)}}const Ba=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"]);function Kd(e,t,n,s){Fa(e,t,void 0,s);for(const r in t.attrs)e.setAttribute(Ba.has(r)?r:Yr(r),t.attrs[r])}class Gd extends $a{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=me}getBaseTargetFromProps(t,n){return t[n]}readValueFromInstance(t,n){if(en.has(n)){const s=ha(n);return s&&s.default||0}return n=Ba.has(n)?n:Yr(n),t.getAttribute(n)}scrapeMotionValuesFromProps(t,n,s){return Ea(t,n,s)}build(t,n,s){ja(t,n,this.isSVGTag,s.transformTemplate,s.style)}renderInstance(t,n,s,r){Kd(t,n,s,r)}mount(t){this.isSVGTag=Aa(t.tagName),super.mount(t)}}const Ua=(e,t)=>qr(e)?new Gd(t):new qd(t,{allowProjection:e!==f.Fragment});function Gt(e,t,n){const s=e.getProps();return Kr(s,t,n!==void 0?n:s.custom,e)}const cr=e=>Array.isArray(e);function Yd(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,Yt(n))}function Hd(e){return cr(e)?e[e.length-1]||0:e}function Jd(e,t){const n=Gt(e,t);let{transitionEnd:s={},transition:r={},...o}=n||{};o={...o,...s};for(const i in o){const a=Hd(o[i]);Yd(e,i,a)}}function Zd(e){return!!(Se(e)&&e.add)}function ur(e,t){const n=e.getValue("willChange");if(Zd(n))return n.add(t);if(!n&<.WillChange){const s=new lt.WillChange("auto");e.addValue("willChange",s),s.add(t)}}function za(e){return e.props[ka]}const Qd=e=>e!==null;function eh(e,{repeat:t,repeatType:n="loop"},s){const r=e.filter(Qd),o=t&&n!=="loop"&&t%2===1?0:r.length-1;return r[o]}const th={type:"spring",stiffness:500,damping:25,restSpeed:10},nh=e=>({type:"spring",stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),sh={type:"keyframes",duration:.8},rh={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},ih=(e,{keyframes:t})=>t.length>2?sh:en.has(e)?e.startsWith("scale")?nh(t[1]):th:rh;function oh({when:e,delay:t,delayChildren:n,staggerChildren:s,staggerDirection:r,repeat:o,repeatType:i,repeatDelay:a,from:l,elapsed:u,...d}){return!!Object.keys(d).length}const Hr=(e,t,n,s={},r,o)=>i=>{const a=Or(s,e)||{},l=a.delay||s.delay||0;let{elapsed:u=0}=s;u=u-qe(l);const d={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:t.getVelocity(),...a,delay:-u,onUpdate:m=>{t.set(m),a.onUpdate&&a.onUpdate(m)},onComplete:()=>{i(),a.onComplete&&a.onComplete()},name:e,motionValue:t,element:o?void 0:r};oh(a)||Object.assign(d,ih(e,d)),d.duration&&(d.duration=qe(d.duration)),d.repeatDelay&&(d.repeatDelay=qe(d.repeatDelay)),d.from!==void 0&&(d.keyframes[0]=d.from);let h=!1;if((d.type===!1||d.duration===0&&!d.repeatDelay)&&(sr(d),d.delay===0&&(h=!0)),(lt.instantAnimations||lt.skipAnimations)&&(h=!0,sr(d),d.delay=0),d.allowFlatten=!a.type&&!a.ease,h&&!o&&t.get()!==void 0){const m=eh(d.keyframes,a);if(m!==void 0){le.update(()=>{d.onUpdate(m),d.onComplete()});return}}return a.isSync?new Vr(d):new Pu(d)};function ah({protectedKeys:e,needsAnimating:t},n){const s=e.hasOwnProperty(n)&&t[n]!==!0;return t[n]=!1,s}function _a(e,t,{delay:n=0,transitionOverride:s,type:r}={}){let{transition:o=e.getDefaultTransition(),transitionEnd:i,...a}=t;s&&(o=s);const l=[],u=r&&e.animationState&&e.animationState.getState()[r];for(const d in a){const h=e.getValue(d,e.latestValues[d]??null),m=a[d];if(m===void 0||u&&ah(u,d))continue;const p={delay:n,...Or(o||{},d)},T=h.get();if(T!==void 0&&!h.isAnimating&&!Array.isArray(m)&&m===T&&!p.velocity)continue;let v=!1;if(window.MotionHandoffAnimation){const b=za(e);if(b){const E=window.MotionHandoffAnimation(b,d,le);E!==null&&(p.startTime=E,v=!0)}}ur(e,d),h.start(Hr(d,h,m,e.shouldReduceMotion&&ca.has(d)?{type:!1}:p,e,v));const C=h.animation;C&&l.push(C)}return i&&Promise.all(l).then(()=>{le.update(()=>{i&&Jd(e,i)})}),l}function Xa(e,t,n,s=0,r=1){const o=Array.from(e).sort((u,d)=>u.sortNodePosition(d)).indexOf(t),i=e.size,a=(i-1)*s;return typeof n=="function"?n(o,i):r===1?o*s:a-o*s}function dr(e,t,n={}){const s=Gt(e,t,n.type==="exit"?e.presenceContext?.custom:void 0);let{transition:r=e.getDefaultTransition()||{}}=s||{};n.transitionOverride&&(r=n.transitionOverride);const o=s?()=>Promise.all(_a(e,s,n)):()=>Promise.resolve(),i=e.variantChildren&&e.variantChildren.size?(l=0)=>{const{delayChildren:u=0,staggerChildren:d,staggerDirection:h}=r;return lh(e,t,l,u,d,h,n)}:()=>Promise.resolve(),{when:a}=r;if(a){const[l,u]=a==="beforeChildren"?[o,i]:[i,o];return l().then(()=>u())}else return Promise.all([o(),i(n.delay)])}function lh(e,t,n=0,s=0,r=0,o=1,i){const a=[];for(const l of e.variantChildren)l.notify("AnimationStart",t),a.push(dr(l,t,{...i,delay:n+(typeof s=="function"?0:s)+Xa(e.variantChildren,l,s,r,o)}).then(()=>l.notify("AnimationComplete",t)));return Promise.all(a)}function ch(e,t,n={}){e.notify("AnimationStart",t);let s;if(Array.isArray(t)){const r=t.map(o=>dr(e,o,n));s=Promise.all(r)}else if(typeof t=="string")s=dr(e,t,n);else{const r=typeof t=="function"?Gt(e,t,n.custom):t;s=Promise.all(_a(e,r,n))}return s.then(()=>{e.notify("AnimationComplete",t)})}function Wa(e,t){if(!Array.isArray(t))return!1;const n=t.length;if(n!==e.length)return!1;for(let s=0;s<n;s++)if(t[s]!==e[s])return!1;return!0}const uh=_r.length;function qa(e){if(!e)return;if(!e.isControllingVariants){const n=e.parent?qa(e.parent)||{}:{};return e.props.initial!==void 0&&(n.initial=e.props.initial),n}const t={};for(let n=0;n<uh;n++){const s=_r[n],r=e.props[s];(Dn(r)||r===!1)&&(t[s]=r)}return t}const dh=[...zr].reverse(),hh=zr.length;function fh(e){return t=>Promise.all(t.map(({animation:n,options:s})=>ch(e,n,s)))}function mh(e){let t=fh(e),n=$i(),s=!0;const r=l=>(u,d)=>{const h=Gt(e,d,l==="exit"?e.presenceContext?.custom:void 0);if(h){const{transition:m,transitionEnd:p,...T}=h;u={...u,...T,...p}}return u};function o(l){t=l(e)}function i(l){const{props:u}=e,d=qa(e.parent)||{},h=[],m=new Set;let p={},T=1/0;for(let C=0;C<hh;C++){const b=dh[C],E=n[b],M=u[b]!==void 0?u[b]:d[b],$=Dn(M),R=b===l?E.isActive:null;R===!1&&(T=C);let I=M===d[b]&&M!==u[b]&&$;if(I&&s&&e.manuallyAnimateOnMount&&(I=!1),E.protectedKeys={...p},!E.isActive&&R===null||!M&&!E.prevProp||xs(M)||typeof M=="boolean")continue;const N=ph(E.prevProp,M);let j=N||b===l&&E.isActive&&!I&&$||C>T&&$,O=!1;const A=Array.isArray(M)?M:[M];let k=A.reduce(r(b),{});R===!1&&(k={});const{prevResolvedValues:F={}}=E,D={...F,...k},B=K=>{j=!0,m.has(K)&&(O=!0,m.delete(K)),E.needsAnimating[K]=!0;const ie=e.getValue(K);ie&&(ie.liveStyle=!1)};for(const K in D){const ie=k[K],ge=F[K];if(p.hasOwnProperty(K))continue;let Ke=!1;cr(ie)&&cr(ge)?Ke=!Wa(ie,ge):Ke=ie!==ge,Ke?ie!=null?B(K):m.add(K):ie!==void 0&&m.has(K)?B(K):E.protectedKeys[K]=!0}E.prevProp=M,E.prevResolvedValues=k,E.isActive&&(p={...p,...k}),s&&e.blockInitialAnimation&&(j=!1);const X=I&&N;j&&(!X||O)&&h.push(...A.map(K=>{const ie={type:b};if(typeof K=="string"&&s&&!X&&e.manuallyAnimateOnMount&&e.parent){const{parent:ge}=e,Ke=Gt(ge,K);if(ge.enteringChildren&&Ke){const{delayChildren:bt}=Ke.transition||{};ie.delay=Xa(ge.enteringChildren,e,bt)}}return{animation:K,options:ie}}))}if(m.size){const C={};if(typeof u.initial!="boolean"){const b=Gt(e,Array.isArray(u.initial)?u.initial[0]:u.initial);b&&b.transition&&(C.transition=b.transition)}m.forEach(b=>{const E=e.getBaseTarget(b),M=e.getValue(b);M&&(M.liveStyle=!0),C[b]=E??null}),h.push({animation:C})}let v=!!h.length;return s&&(u.initial===!1||u.initial===u.animate)&&!e.manuallyAnimateOnMount&&(v=!1),s=!1,v?t(h):Promise.resolve()}function a(l,u){if(n[l].isActive===u)return Promise.resolve();e.variantChildren?.forEach(h=>h.animationState?.setActive(l,u)),n[l].isActive=u;const d=i(l);for(const h in n)n[h].protectedKeys={};return d}return{animateChanges:i,setActive:a,setAnimateFunction:o,getState:()=>n,reset:()=>{n=$i()}}}function ph(e,t){return typeof t=="string"?t!==e:Array.isArray(t)?!Wa(t,e):!1}function Pt(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function $i(){return{animate:Pt(!0),whileInView:Pt(),whileHover:Pt(),whileTap:Pt(),whileDrag:Pt(),whileFocus:Pt(),exit:Pt()}}class xt{constructor(t){this.isMounted=!1,this.node=t}update(){}}class gh extends xt{constructor(t){super(t),t.animationState||(t.animationState=mh(t))}updateAnimationControlsSubscription(){const{animate:t}=this.node.getProps();xs(t)&&(this.unmountControls=t.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:t}=this.node.getProps(),{animate:n}=this.node.prevProps||{};t!==n&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}}let yh=0;class xh extends xt{constructor(){super(...arguments),this.id=yh++}update(){if(!this.node.presenceContext)return;const{isPresent:t,onExitComplete:n}=this.node.presenceContext,{isPresent:s}=this.node.prevPresenceContext||{};if(!this.node.animationState||t===s)return;const r=this.node.animationState.setActive("exit",!t);n&&!t&&r.then(()=>{n(this.id)})}mount(){const{register:t,onExitComplete:n}=this.node.presenceContext||{};n&&n(this.id),t&&(this.unmount=t(this.id))}unmount(){}}const Ka={animation:{Feature:gh},exit:{Feature:xh}};function In(e,t,n,s={passive:!0}){return e.addEventListener(t,n,s),()=>e.removeEventListener(t,n)}function Fn(e){return{point:{x:e.pageX,y:e.pageY}}}const bh=e=>t=>Fr(t)&&e(t,Fn(t));function Pn(e,t,n,s){return In(e,t,bh(n),s)}const Ga=1e-4,vh=1-Ga,wh=1+Ga,Ya=.01,Sh=0-Ya,Th=0+Ya;function Ae(e){return e.max-e.min}function Ch(e,t,n){return Math.abs(e-t)<=n}function Fi(e,t,n,s=.5){e.origin=s,e.originPoint=de(t.min,t.max,e.origin),e.scale=Ae(n)/Ae(t),e.translate=de(n.min,n.max,e.origin)-e.originPoint,(e.scale>=vh&&e.scale<=wh||isNaN(e.scale))&&(e.scale=1),(e.translate>=Sh&&e.translate<=Th||isNaN(e.translate))&&(e.translate=0)}function An(e,t,n,s){Fi(e.x,t.x,n.x,s?s.originX:void 0),Fi(e.y,t.y,n.y,s?s.originY:void 0)}function Bi(e,t,n){e.min=n.min+t.min,e.max=e.min+Ae(t)}function jh(e,t,n){Bi(e.x,t.x,n.x),Bi(e.y,t.y,n.y)}function Ui(e,t,n){e.min=t.min-n.min,e.max=e.min+Ae(t)}function Mn(e,t,n){Ui(e.x,t.x,n.x),Ui(e.y,t.y,n.y)}function Le(e){return[e("x"),e("y")]}const Ha=({current:e})=>e?e.ownerDocument.defaultView:null,zi=(e,t)=>Math.abs(e-t);function Ph(e,t){const n=zi(e.x,t.x),s=zi(e.y,t.y);return Math.sqrt(n**2+s**2)}class Ja{constructor(t,n,{transformPagePoint:s,contextWindow:r=window,dragSnapToOrigin:o=!1,distanceThreshold:i=3}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const m=Os(this.lastMoveEventInfo,this.history),p=this.startEvent!==null,T=Ph(m.offset,{x:0,y:0})>=this.distanceThreshold;if(!p&&!T)return;const{point:v}=m,{timestamp:C}=ve;this.history.push({...v,timestamp:C});const{onStart:b,onMove:E}=this.handlers;p||(b&&b(this.lastMoveEvent,m),this.startEvent=this.lastMoveEvent),E&&E(this.lastMoveEvent,m)},this.handlePointerMove=(m,p)=>{this.lastMoveEvent=m,this.lastMoveEventInfo=Is(p,this.transformPagePoint),le.update(this.updatePoint,!0)},this.handlePointerUp=(m,p)=>{this.end();const{onEnd:T,onSessionEnd:v,resumeAnimation:C}=this.handlers;if(this.dragSnapToOrigin&&C&&C(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const b=Os(m.type==="pointercancel"?this.lastMoveEventInfo:Is(p,this.transformPagePoint),this.history);this.startEvent&&T&&T(m,b),v&&v(m,b)},!Fr(t))return;this.dragSnapToOrigin=o,this.handlers=n,this.transformPagePoint=s,this.distanceThreshold=i,this.contextWindow=r||window;const a=Fn(t),l=Is(a,this.transformPagePoint),{point:u}=l,{timestamp:d}=ve;this.history=[{...u,timestamp:d}];const{onSessionStart:h}=n;h&&h(t,Os(l,this.history)),this.removeListeners=On(Pn(this.contextWindow,"pointermove",this.handlePointerMove),Pn(this.contextWindow,"pointerup",this.handlePointerUp),Pn(this.contextWindow,"pointercancel",this.handlePointerUp))}updateHandlers(t){this.handlers=t}end(){this.removeListeners&&this.removeListeners(),gt(this.updatePoint)}}function Is(e,t){return t?{point:t(e.point)}:e}function _i(e,t){return{x:e.x-t.x,y:e.y-t.y}}function Os({point:e},t){return{point:e,delta:_i(e,Za(t)),offset:_i(e,Ah(t)),velocity:Mh(t,.1)}}function Ah(e){return e[0]}function Za(e){return e[e.length-1]}function Mh(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,s=null;const r=Za(e);for(;n>=0&&(s=e[n],!(r.timestamp-s.timestamp>qe(t)));)n--;if(!s)return{x:0,y:0};const o=Fe(r.timestamp-s.timestamp);if(o===0)return{x:0,y:0};const i={x:(r.x-s.x)/o,y:(r.y-s.y)/o};return i.x===1/0&&(i.x=0),i.y===1/0&&(i.y=0),i}function Eh(e,{min:t,max:n},s){return t!==void 0&&e<t?e=s?de(t,e,s.min):Math.max(e,t):n!==void 0&&e>n&&(e=s?de(n,e,s.max):Math.min(e,n)),e}function Xi(e,t,n){return{min:t!==void 0?e.min+t:void 0,max:n!==void 0?e.max+n-(e.max-e.min):void 0}}function kh(e,{top:t,left:n,bottom:s,right:r}){return{x:Xi(e.x,n,r),y:Xi(e.y,t,s)}}function Wi(e,t){let n=t.min-e.min,s=t.max-e.max;return t.max-t.min<e.max-e.min&&([n,s]=[s,n]),{min:n,max:s}}function Nh(e,t){return{x:Wi(e.x,t.x),y:Wi(e.y,t.y)}}function Rh(e,t){let n=.5;const s=Ae(e),r=Ae(t);return r>s?n=kn(t.min,t.max-s,e.min):s>r&&(n=kn(e.min,e.max-r,t.min)),ot(0,1,n)}function Dh(e,t){const n={};return t.min!==void 0&&(n.min=t.min-e.min),t.max!==void 0&&(n.max=t.max-e.min),n}const hr=.35;function Vh(e=hr){return e===!1?e=0:e===!0&&(e=hr),{x:qi(e,"left","right"),y:qi(e,"top","bottom")}}function qi(e,t,n){return{min:Ki(e,t),max:Ki(e,n)}}function Ki(e,t){return typeof e=="number"?e:e[t]||0}const Ih=new WeakMap;class Oh{constructor(t){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=me(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=t}start(t,{snapToCursor:n=!1,distanceThreshold:s}={}){const{presenceContext:r}=this.visualElement;if(r&&r.isPresent===!1)return;const o=h=>{const{dragSnapToOrigin:m}=this.getProps();m?this.pauseAnimation():this.stopAnimation(),n&&this.snapToCursor(Fn(h).point)},i=(h,m)=>{const{drag:p,dragPropagation:T,onDragStart:v}=this.getProps();if(p&&!T&&(this.openDragLock&&this.openDragLock(),this.openDragLock=_u(p),!this.openDragLock))return;this.latestPointerEvent=h,this.latestPanInfo=m,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),Le(b=>{let E=this.getAxisMotionValue(b).get()||0;if(et.test(E)){const{projection:M}=this.visualElement;if(M&&M.layout){const $=M.layout.layoutBox[b];$&&(E=Ae($)*(parseFloat(E)/100))}}this.originPoint[b]=E}),v&&le.postRender(()=>v(h,m)),ur(this.visualElement,"transform");const{animationState:C}=this.visualElement;C&&C.setActive("whileDrag",!0)},a=(h,m)=>{this.latestPointerEvent=h,this.latestPanInfo=m;const{dragPropagation:p,dragDirectionLock:T,onDirectionLock:v,onDrag:C}=this.getProps();if(!p&&!this.openDragLock)return;const{offset:b}=m;if(T&&this.currentDirection===null){this.currentDirection=Lh(b),this.currentDirection!==null&&v&&v(this.currentDirection);return}this.updateAxis("x",m.point,b),this.updateAxis("y",m.point,b),this.visualElement.render(),C&&C(h,m)},l=(h,m)=>{this.latestPointerEvent=h,this.latestPanInfo=m,this.stop(h,m),this.latestPointerEvent=null,this.latestPanInfo=null},u=()=>Le(h=>this.getAnimationState(h)==="paused"&&this.getAxisMotionValue(h).animation?.play()),{dragSnapToOrigin:d}=this.getProps();this.panSession=new Ja(t,{onSessionStart:o,onStart:i,onMove:a,onSessionEnd:l,resumeAnimation:u},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:d,distanceThreshold:s,contextWindow:Ha(this.visualElement)})}stop(t,n){const s=t||this.latestPointerEvent,r=n||this.latestPanInfo,o=this.isDragging;if(this.cancel(),!o||!r||!s)return;const{velocity:i}=r;this.startAnimation(i);const{onDragEnd:a}=this.getProps();a&&le.postRender(()=>a(s,r))}cancel(){this.isDragging=!1;const{projection:t,animationState:n}=this.visualElement;t&&(t.isAnimationBlocked=!1),this.panSession&&this.panSession.end(),this.panSession=void 0;const{dragPropagation:s}=this.getProps();!s&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),n&&n.setActive("whileDrag",!1)}updateAxis(t,n,s){const{drag:r}=this.getProps();if(!s||!ts(t,r,this.currentDirection))return;const o=this.getAxisMotionValue(t);let i=this.originPoint[t]+s[t];this.constraints&&this.constraints[t]&&(i=Eh(i,this.constraints[t],this.elastic[t])),o.set(i)}resolveConstraints(){const{dragConstraints:t,dragElastic:n}=this.getProps(),s=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,r=this.constraints;t&&_t(t)?this.constraints||(this.constraints=this.resolveRefConstraints()):t&&s?this.constraints=kh(s.layoutBox,t):this.constraints=!1,this.elastic=Vh(n),r!==this.constraints&&s&&this.constraints&&!this.hasMutatedConstraints&&Le(o=>{this.constraints!==!1&&this.getAxisMotionValue(o)&&(this.constraints[o]=Dh(s.layoutBox[o],this.constraints[o]))})}resolveRefConstraints(){const{dragConstraints:t,onMeasureDragConstraints:n}=this.getProps();if(!t||!_t(t))return!1;const s=t.current;at(s!==null,"If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.","drag-constraints-ref");const{projection:r}=this.visualElement;if(!r||!r.layout)return!1;const o=Bd(s,r.root,this.visualElement.getTransformPagePoint());let i=Nh(r.layout.layoutBox,o);if(n){const a=n(Ld(i));this.hasMutatedConstraints=!!a,a&&(i=Da(a))}return i}startAnimation(t){const{drag:n,dragMomentum:s,dragElastic:r,dragTransition:o,dragSnapToOrigin:i,onDragTransitionEnd:a}=this.getProps(),l=this.constraints||{},u=Le(d=>{if(!ts(d,n,this.currentDirection))return;let h=l&&l[d]||{};i&&(h={min:0,max:0});const m=r?200:1e6,p=r?40:1e7,T={type:"inertia",velocity:s?t[d]:0,bounceStiffness:m,bounceDamping:p,timeConstant:750,restDelta:1,restSpeed:10,...o,...h};return this.startAxisValueAnimation(d,T)});return Promise.all(u).then(a)}startAxisValueAnimation(t,n){const s=this.getAxisMotionValue(t);return ur(this.visualElement,t),s.start(Hr(t,s,0,n,this.visualElement,!1))}stopAnimation(){Le(t=>this.getAxisMotionValue(t).stop())}pauseAnimation(){Le(t=>this.getAxisMotionValue(t).animation?.pause())}getAnimationState(t){return this.getAxisMotionValue(t).animation?.state}getAxisMotionValue(t){const n=`_drag${t.toUpperCase()}`,s=this.visualElement.getProps(),r=s[n];return r||this.visualElement.getValue(t,(s.initial?s.initial[t]:void 0)||0)}snapToCursor(t){Le(n=>{const{drag:s}=this.getProps();if(!ts(n,s,this.currentDirection))return;const{projection:r}=this.visualElement,o=this.getAxisMotionValue(n);if(r&&r.layout){const{min:i,max:a}=r.layout.layoutBox[n];o.set(t[n]-de(i,a,.5))}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:t,dragConstraints:n}=this.getProps(),{projection:s}=this.visualElement;if(!_t(n)||!s||!this.constraints)return;this.stopAnimation();const r={x:0,y:0};Le(i=>{const a=this.getAxisMotionValue(i);if(a&&this.constraints!==!1){const l=a.get();r[i]=Rh({min:l,max:l},this.constraints[i])}});const{transformTemplate:o}=this.visualElement.getProps();this.visualElement.current.style.transform=o?o({},""):"none",s.root&&s.root.updateScroll(),s.updateLayout(),this.resolveConstraints(),Le(i=>{if(!ts(i,t,null))return;const a=this.getAxisMotionValue(i),{min:l,max:u}=this.constraints[i];a.set(de(l,u,r[i]))})}addListeners(){if(!this.visualElement.current)return;Ih.set(this.visualElement,this);const t=this.visualElement.current,n=Pn(t,"pointerdown",l=>{const{drag:u,dragListener:d=!0}=this.getProps();u&&d&&this.start(l)}),s=()=>{const{dragConstraints:l}=this.getProps();_t(l)&&l.current&&(this.constraints=this.resolveRefConstraints())},{projection:r}=this.visualElement,o=r.addEventListener("measure",s);r&&!r.layout&&(r.root&&r.root.updateScroll(),r.updateLayout()),le.read(s);const i=In(window,"resize",()=>this.scalePositionWithinConstraints()),a=r.addEventListener("didUpdate",({delta:l,hasLayoutChanged:u})=>{this.isDragging&&u&&(Le(d=>{const h=this.getAxisMotionValue(d);h&&(this.originPoint[d]+=l[d].translate,h.set(h.get()+l[d].translate))}),this.visualElement.render())});return()=>{i(),n(),o(),a&&a()}}getProps(){const t=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:s=!1,dragPropagation:r=!1,dragConstraints:o=!1,dragElastic:i=hr,dragMomentum:a=!0}=t;return{...t,drag:n,dragDirectionLock:s,dragPropagation:r,dragConstraints:o,dragElastic:i,dragMomentum:a}}}function ts(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function Lh(e,t=10){let n=null;return Math.abs(e.y)>t?n="y":Math.abs(e.x)>t&&(n="x"),n}class $h extends xt{constructor(t){super(t),this.removeGroupControls=Be,this.removeListeners=Be,this.controls=new Oh(t)}mount(){const{dragControls:t}=this.node.getProps();t&&(this.removeGroupControls=t.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||Be}unmount(){this.removeGroupControls(),this.removeListeners()}}const Gi=e=>(t,n)=>{e&&le.postRender(()=>e(t,n))};class Fh extends xt{constructor(){super(...arguments),this.removePointerDownListener=Be}onPointerDown(t){this.session=new Ja(t,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:Ha(this.node)})}createPanHandlers(){const{onPanSessionStart:t,onPanStart:n,onPan:s,onPanEnd:r}=this.node.getProps();return{onSessionStart:Gi(t),onStart:Gi(n),onMove:s,onEnd:(o,i)=>{delete this.session,r&&le.postRender(()=>r(o,i))}}}mount(){this.removePointerDownListener=Pn(this.node.current,"pointerdown",t=>this.onPointerDown(t))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}const cs={hasAnimatedSinceResize:!0,hasEverUpdated:!1};function Yi(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}const wn={correct:(e,t)=>{if(!t.target)return e;if(typeof e=="string")if(z.test(e))e=parseFloat(e);else return e;const n=Yi(e,t.target.x),s=Yi(e,t.target.y);return`${n}% ${s}%`}},Bh={correct:(e,{treeScale:t,projectionDelta:n})=>{const s=e,r=yt.parse(e);if(r.length>5)return s;const o=yt.createTransformer(e),i=typeof r[0]!="number"?1:0,a=n.x.scale*t.x,l=n.y.scale*t.y;r[0+i]/=a,r[1+i]/=l;const u=de(a,l,.5);return typeof r[2+i]=="number"&&(r[2+i]/=u),typeof r[3+i]=="number"&&(r[3+i]/=u),o(r)}};let Ls=!1;class Uh extends f.Component{componentDidMount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:s,layoutId:r}=this.props,{projection:o}=t;dd(zh),o&&(n.group&&n.group.add(o),s&&s.register&&r&&s.register(o),Ls&&o.root.didUpdate(),o.addEventListener("animationComplete",()=>{this.safeToRemove()}),o.setOptions({...o.options,onExitComplete:()=>this.safeToRemove()})),cs.hasEverUpdated=!0}getSnapshotBeforeUpdate(t){const{layoutDependency:n,visualElement:s,drag:r,isPresent:o}=this.props,{projection:i}=s;return i&&(i.isPresent=o,Ls=!0,r||t.layoutDependency!==n||n===void 0||t.isPresent!==o?i.willUpdate():this.safeToRemove(),t.isPresent!==o&&(o?i.promote():i.relegate()||le.postRender(()=>{const a=i.getStack();(!a||!a.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:t}=this.props.visualElement;t&&(t.root.didUpdate(),$r.postRender(()=>{!t.currentAnimation&&t.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:s}=this.props,{projection:r}=t;Ls=!0,r&&(r.scheduleCheckAfterUnmount(),n&&n.group&&n.group.remove(r),s&&s.deregister&&s.deregister(r))}safeToRemove(){const{safeToRemove:t}=this.props;t&&t()}render(){return null}}function Qa(e){const[t,n]=va(),s=f.useContext(gr);return c.jsx(Uh,{...e,layoutGroup:s,switchLayoutGroup:f.useContext(Na),isPresent:t,safeToRemove:n})}const zh={borderRadius:{...wn,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:wn,borderTopRightRadius:wn,borderBottomLeftRadius:wn,borderBottomRightRadius:wn,boxShadow:Bh};function _h(e,t,n){const s=Se(e)?e:Yt(e);return s.start(Hr("",s,t,n)),s.animation}const Xh=(e,t)=>e.depth-t.depth;class Wh{constructor(){this.children=[],this.isDirty=!1}add(t){br(this.children,t),this.isDirty=!0}remove(t){vr(this.children,t),this.isDirty=!0}forEach(t){this.isDirty&&this.children.sort(Xh),this.isDirty=!1,this.children.forEach(t)}}function qh(e,t){const n=Ne.now(),s=({timestamp:r})=>{const o=r-n;o>=t&&(gt(s),e(o-t))};return le.setup(s,!0),()=>gt(s)}const el=["TopLeft","TopRight","BottomLeft","BottomRight"],Kh=el.length,Hi=e=>typeof e=="string"?parseFloat(e):e,Ji=e=>typeof e=="number"||z.test(e);function Gh(e,t,n,s,r,o){r?(e.opacity=de(0,n.opacity??1,Yh(s)),e.opacityExit=de(t.opacity??1,0,Hh(s))):o&&(e.opacity=de(t.opacity??1,n.opacity??1,s));for(let i=0;i<Kh;i++){const a=`border${el[i]}Radius`;let l=Zi(t,a),u=Zi(n,a);if(l===void 0&&u===void 0)continue;l||(l=0),u||(u=0),l===0||u===0||Ji(l)===Ji(u)?(e[a]=Math.max(de(Hi(l),Hi(u),s),0),(et.test(u)||et.test(l))&&(e[a]+="%")):e[a]=u}(t.rotate||n.rotate)&&(e.rotate=de(t.rotate||0,n.rotate||0,s))}function Zi(e,t){return e[t]!==void 0?e[t]:e.borderRadius}const Yh=tl(0,.5,Bo),Hh=tl(.5,.95,Be);function tl(e,t,n){return s=>s<e?0:s>t?1:n(kn(e,t,s))}function Qi(e,t){e.min=t.min,e.max=t.max}function Oe(e,t){Qi(e.x,t.x),Qi(e.y,t.y)}function eo(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}function to(e,t,n,s,r){return e-=t,e=ms(e,1/n,s),r!==void 0&&(e=ms(e,1/r,s)),e}function Jh(e,t=0,n=1,s=.5,r,o=e,i=e){if(et.test(t)&&(t=parseFloat(t),t=de(i.min,i.max,t/100)-i.min),typeof t!="number")return;let a=de(o.min,o.max,s);e===o&&(a-=t),e.min=to(e.min,t,n,a,r),e.max=to(e.max,t,n,a,r)}function no(e,t,[n,s,r],o,i){Jh(e,t[n],t[s],t[r],t.scale,o,i)}const Zh=["x","scaleX","originX"],Qh=["y","scaleY","originY"];function so(e,t,n,s){no(e.x,t,Zh,n?n.x:void 0,s?s.x:void 0),no(e.y,t,Qh,n?n.y:void 0,s?s.y:void 0)}function ro(e){return e.translate===0&&e.scale===1}function nl(e){return ro(e.x)&&ro(e.y)}function io(e,t){return e.min===t.min&&e.max===t.max}function ef(e,t){return io(e.x,t.x)&&io(e.y,t.y)}function oo(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function sl(e,t){return oo(e.x,t.x)&&oo(e.y,t.y)}function ao(e){return Ae(e.x)/Ae(e.y)}function lo(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}class tf{constructor(){this.members=[]}add(t){br(this.members,t),t.scheduleRender()}remove(t){if(vr(this.members,t),t===this.prevLead&&(this.prevLead=void 0),t===this.lead){const n=this.members[this.members.length-1];n&&this.promote(n)}}relegate(t){const n=this.members.findIndex(r=>t===r);if(n===0)return!1;let s;for(let r=n;r>=0;r--){const o=this.members[r];if(o.isPresent!==!1){s=o;break}}return s?(this.promote(s),!0):!1}promote(t,n){const s=this.lead;if(t!==s&&(this.prevLead=s,this.lead=t,t.show(),s)){s.instance&&s.scheduleRender(),t.scheduleRender(),t.resumeFrom=s,n&&(t.resumeFrom.preserveOpacity=!0),s.snapshot&&(t.snapshot=s.snapshot,t.snapshot.latestValues=s.animationValues||s.latestValues),t.root&&t.root.isUpdating&&(t.isLayoutDirty=!0);const{crossfade:r}=t.options;r===!1&&s.hide()}}exitAnimationComplete(){this.members.forEach(t=>{const{options:n,resumingFrom:s}=t;n.onExitComplete&&n.onExitComplete(),s&&s.options.onExitComplete&&s.options.onExitComplete()})}scheduleRender(){this.members.forEach(t=>{t.instance&&t.scheduleRender(!1)})}removeLeadSnapshot(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)}}function nf(e,t,n){let s="";const r=e.x.translate/t.x,o=e.y.translate/t.y,i=n?.z||0;if((r||o||i)&&(s=`translate3d(${r}px, ${o}px, ${i}px) `),(t.x!==1||t.y!==1)&&(s+=`scale(${1/t.x}, ${1/t.y}) `),n){const{transformPerspective:u,rotate:d,rotateX:h,rotateY:m,skewX:p,skewY:T}=n;u&&(s=`perspective(${u}px) ${s}`),d&&(s+=`rotate(${d}deg) `),h&&(s+=`rotateX(${h}deg) `),m&&(s+=`rotateY(${m}deg) `),p&&(s+=`skewX(${p}deg) `),T&&(s+=`skewY(${T}deg) `)}const a=e.x.scale*t.x,l=e.y.scale*t.y;return(a!==1||l!==1)&&(s+=`scale(${a}, ${l})`),s||"none"}const $s=["","X","Y","Z"],sf=1e3;let rf=0;function Fs(e,t,n,s){const{latestValues:r}=t;r[e]&&(n[e]=r[e],t.setStaticValue(e,0),s&&(s[e]=0))}function rl(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;const{visualElement:t}=e.options;if(!t)return;const n=za(t);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:r,layoutId:o}=e.options;window.MotionCancelOptimisedAnimation(n,"transform",le,!(r||o))}const{parent:s}=e;s&&!s.hasCheckedOptimisedAppear&&rl(s)}function il({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:s,resetTransform:r}){return class{constructor(i={},a=t?.()){this.id=rf++,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.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(lf),this.nodes.forEach(hf),this.nodes.forEach(ff),this.nodes.forEach(cf)},this.resolvedRelativeTargetAt=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=i,this.root=a?a.root||a:this,this.path=a?[...a.path,a]:[],this.parent=a,this.depth=a?a.depth+1:0;for(let l=0;l<this.path.length;l++)this.path[l].shouldResetTransform=!0;this.root===this&&(this.nodes=new Wh)}addEventListener(i,a){return this.eventHandlers.has(i)||this.eventHandlers.set(i,new Sr),this.eventHandlers.get(i).add(a)}notifyListeners(i,...a){const l=this.eventHandlers.get(i);l&&l.notify(...a)}hasListeners(i){return this.eventHandlers.has(i)}mount(i){if(this.instance)return;this.isSVG=ba(i)&&!Yu(i),this.instance=i;const{layoutId:a,layout:l,visualElement:u}=this.options;if(u&&!u.current&&u.mount(i),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(l||a)&&(this.isLayoutDirty=!0),e){let d,h=0;const m=()=>this.root.updateBlockedByResize=!1;le.read(()=>{h=window.innerWidth}),e(i,()=>{const p=window.innerWidth;p!==h&&(h=p,this.root.updateBlockedByResize=!0,d&&d(),d=qh(m,250),cs.hasAnimatedSinceResize&&(cs.hasAnimatedSinceResize=!1,this.nodes.forEach(ho)))})}a&&this.root.registerSharedNode(a,this),this.options.animate!==!1&&u&&(a||l)&&this.addEventListener("didUpdate",({delta:d,hasLayoutChanged:h,hasRelativeLayoutChanged:m,layout:p})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const T=this.options.transition||u.getDefaultTransition()||xf,{onLayoutAnimationStart:v,onLayoutAnimationComplete:C}=u.getProps(),b=!this.targetLayout||!sl(this.targetLayout,p),E=!h&&m;if(this.options.layoutRoot||this.resumeFrom||E||h&&(b||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const M={...Or(T,"layout"),onPlay:v,onComplete:C};(u.shouldReduceMotion||this.options.layoutRoot)&&(M.delay=0,M.type=!1),this.startAnimation(M),this.setAnimationOrigin(d,E)}else h||ho(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=p})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const i=this.getStack();i&&i.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),gt(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(mf),this.animationId++)}getTransformTemplate(){const{visualElement:i}=this.options;return i&&i.getProps().transformTemplate}willUpdate(i=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&rl(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let d=0;d<this.path.length;d++){const h=this.path[d];h.shouldResetTransform=!0,h.updateScroll("snapshot"),h.options.layoutRoot&&h.willUpdate(!1)}const{layoutId:a,layout:l}=this.options;if(a===void 0&&!l)return;const u=this.getTransformTemplate();this.prevTransformTemplateValue=u?u(this.latestValues,""):void 0,this.updateSnapshot(),i&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){this.unblockUpdate(),this.clearAllSnapshots(),this.nodes.forEach(co);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(uo);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(df),this.nodes.forEach(of),this.nodes.forEach(af)):this.nodes.forEach(uo),this.clearAllSnapshots();const a=Ne.now();ve.delta=ot(0,1e3/60,a-ve.timestamp),ve.timestamp=a,ve.isProcessing=!0,As.update.process(ve),As.preRender.process(ve),As.render.process(ve),ve.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,$r.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(uf),this.sharedNodes.forEach(pf)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,le.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){le.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!Ae(this.snapshot.measuredBox.x)&&!Ae(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 l=0;l<this.path.length;l++)this.path[l].updateScroll();const i=this.layout;this.layout=this.measure(!1),this.layoutCorrected=me(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);const{visualElement:a}=this.options;a&&a.notify("LayoutMeasure",this.layout.layoutBox,i?i.layoutBox:void 0)}updateScroll(i="measure"){let a=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===i&&(a=!1),a&&this.instance){const l=s(this.instance);this.scroll={animationId:this.root.animationId,phase:i,isRoot:l,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:l}}}resetTransform(){if(!r)return;const i=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,a=this.projectionDelta&&!nl(this.projectionDelta),l=this.getTransformTemplate(),u=l?l(this.latestValues,""):void 0,d=u!==this.prevTransformTemplateValue;i&&this.instance&&(a||Mt(this.latestValues)||d)&&(r(this.instance,u),this.shouldResetTransform=!1,this.scheduleRender())}measure(i=!0){const a=this.measurePageBox();let l=this.removeElementScroll(a);return i&&(l=this.removeTransform(l)),bf(l),{animationId:this.root.animationId,measuredBox:a,layoutBox:l,latestValues:{},source:this.id}}measurePageBox(){const{visualElement:i}=this.options;if(!i)return me();const a=i.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(vf))){const{scroll:u}=this.root;u&&(Xt(a.x,u.offset.x),Xt(a.y,u.offset.y))}return a}removeElementScroll(i){const a=me();if(Oe(a,i),this.scroll?.wasRoot)return a;for(let l=0;l<this.path.length;l++){const u=this.path[l],{scroll:d,options:h}=u;u!==this.root&&d&&h.layoutScroll&&(d.wasRoot&&Oe(a,i),Xt(a.x,d.offset.x),Xt(a.y,d.offset.y))}return a}applyTransform(i,a=!1){const l=me();Oe(l,i);for(let u=0;u<this.path.length;u++){const d=this.path[u];!a&&d.options.layoutScroll&&d.scroll&&d!==d.root&&Wt(l,{x:-d.scroll.offset.x,y:-d.scroll.offset.y}),Mt(d.latestValues)&&Wt(l,d.latestValues)}return Mt(this.latestValues)&&Wt(l,this.latestValues),l}removeTransform(i){const a=me();Oe(a,i);for(let l=0;l<this.path.length;l++){const u=this.path[l];if(!u.instance||!Mt(u.latestValues))continue;or(u.latestValues)&&u.updateSnapshot();const d=me(),h=u.measurePageBox();Oe(d,h),so(a,u.latestValues,u.snapshot?u.snapshot.layoutBox:void 0,d)}return Mt(this.latestValues)&&so(a,this.latestValues),a}setTargetDelta(i){this.targetDelta=i,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(i){this.options={...this.options,...i,crossfade:i.crossfade!==void 0?i.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!==ve.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(i=!1){const a=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=a.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=a.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=a.isSharedProjectionDirty);const l=!!this.resumingFrom||this!==a;if(!(i||l&&this.isSharedProjectionDirty||this.isProjectionDirty||this.parent?.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:d,layoutId:h}=this.options;if(!(!this.layout||!(d||h))){if(this.resolvedRelativeTargetAt=ve.timestamp,!this.targetDelta&&!this.relativeTarget){const m=this.getClosestProjectingParent();m&&m.layout&&this.animationProgress!==1?(this.relativeParent=m,this.forceRelativeParentToResolveTarget(),this.relativeTarget=me(),this.relativeTargetOrigin=me(),Mn(this.relativeTargetOrigin,this.layout.layoutBox,m.layout.layoutBox),Oe(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}if(!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=me(),this.targetWithTransforms=me()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),jh(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):Oe(this.target,this.layout.layoutBox),Ia(this.target,this.targetDelta)):Oe(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget)){this.attemptToResolveRelativeTarget=!1;const m=this.getClosestProjectingParent();m&&!!m.resumingFrom==!!this.resumingFrom&&!m.options.layoutScroll&&m.target&&this.animationProgress!==1?(this.relativeParent=m,this.forceRelativeParentToResolveTarget(),this.relativeTarget=me(),this.relativeTargetOrigin=me(),Mn(this.relativeTargetOrigin,this.target,m.target),Oe(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}}}getClosestProjectingParent(){if(!(!this.parent||or(this.parent.latestValues)||Va(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}calcProjection(){const i=this.getLead(),a=!!this.resumingFrom||this!==i;let l=!0;if((this.isProjectionDirty||this.parent?.isProjectionDirty)&&(l=!1),a&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(l=!1),this.resolvedRelativeTargetAt===ve.timestamp&&(l=!1),l)return;const{layout:u,layoutId:d}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(u||d))return;Oe(this.layoutCorrected,this.layout.layoutBox);const h=this.treeScale.x,m=this.treeScale.y;Fd(this.layoutCorrected,this.treeScale,this.path,a),i.layout&&!i.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(i.target=i.layout.layoutBox,i.targetWithTransforms=me());const{target:p}=i;if(!p){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(eo(this.prevProjectionDelta.x,this.projectionDelta.x),eo(this.prevProjectionDelta.y,this.projectionDelta.y)),An(this.projectionDelta,this.layoutCorrected,p,this.latestValues),(this.treeScale.x!==h||this.treeScale.y!==m||!lo(this.projectionDelta.x,this.prevProjectionDelta.x)||!lo(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",p))}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(i=!0){if(this.options.visualElement?.scheduleRender(),i){const a=this.getStack();a&&a.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=qt(),this.projectionDelta=qt(),this.projectionDeltaWithTransform=qt()}setAnimationOrigin(i,a=!1){const l=this.snapshot,u=l?l.latestValues:{},d={...this.latestValues},h=qt();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!a;const m=me(),p=l?l.source:void 0,T=this.layout?this.layout.source:void 0,v=p!==T,C=this.getStack(),b=!C||C.members.length<=1,E=!!(v&&!b&&this.options.crossfade===!0&&!this.path.some(yf));this.animationProgress=0;let M;this.mixTargetDelta=$=>{const R=$/1e3;fo(h.x,i.x,R),fo(h.y,i.y,R),this.setTargetDelta(h),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(Mn(m,this.layout.layoutBox,this.relativeParent.layout.layoutBox),gf(this.relativeTarget,this.relativeTargetOrigin,m,R),M&&ef(this.relativeTarget,M)&&(this.isProjectionDirty=!1),M||(M=me()),Oe(M,this.relativeTarget)),v&&(this.animationValues=d,Gh(d,u,this.latestValues,R,E,b)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=R},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(i){this.notifyListeners("animationStart"),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&(gt(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=le.update(()=>{cs.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=Yt(0)),this.currentAnimation=_h(this.motionValue,[0,1e3],{...i,velocity:0,isSync:!0,onUpdate:a=>{this.mixTargetDelta(a),i.onUpdate&&i.onUpdate(a)},onStop:()=>{},onComplete:()=>{i.onComplete&&i.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 i=this.getStack();i&&i.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(sf),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const i=this.getLead();let{targetWithTransforms:a,target:l,layout:u,latestValues:d}=i;if(!(!a||!l||!u)){if(this!==i&&this.layout&&u&&ol(this.options.animationType,this.layout.layoutBox,u.layoutBox)){l=this.target||me();const h=Ae(this.layout.layoutBox.x);l.x.min=i.target.x.min,l.x.max=l.x.min+h;const m=Ae(this.layout.layoutBox.y);l.y.min=i.target.y.min,l.y.max=l.y.min+m}Oe(a,l),Wt(a,d),An(this.projectionDeltaWithTransform,this.layoutCorrected,a,d)}}registerSharedNode(i,a){this.sharedNodes.has(i)||this.sharedNodes.set(i,new tf),this.sharedNodes.get(i).add(a);const u=a.options.initialPromotionConfig;a.promote({transition:u?u.transition:void 0,preserveFollowOpacity:u&&u.shouldPreserveFollowOpacity?u.shouldPreserveFollowOpacity(a):void 0})}isLead(){const i=this.getStack();return i?i.lead===this:!0}getLead(){const{layoutId:i}=this.options;return i?this.getStack()?.lead||this:this}getPrevLead(){const{layoutId:i}=this.options;return i?this.getStack()?.prevLead:void 0}getStack(){const{layoutId:i}=this.options;if(i)return this.root.sharedNodes.get(i)}promote({needsReset:i,transition:a,preserveFollowOpacity:l}={}){const u=this.getStack();u&&u.promote(this,l),i&&(this.projectionDelta=void 0,this.needsReset=!0),a&&this.setOptions({transition:a})}relegate(){const i=this.getStack();return i?i.relegate(this):!1}resetSkewAndRotation(){const{visualElement:i}=this.options;if(!i)return;let a=!1;const{latestValues:l}=i;if((l.z||l.rotate||l.rotateX||l.rotateY||l.rotateZ||l.skewX||l.skewY)&&(a=!0),!a)return;const u={};l.z&&Fs("z",i,u,this.animationValues);for(let d=0;d<$s.length;d++)Fs(`rotate${$s[d]}`,i,u,this.animationValues),Fs(`skew${$s[d]}`,i,u,this.animationValues);i.render();for(const d in u)i.setStaticValue(d,u[d]),this.animationValues&&(this.animationValues[d]=u[d]);i.scheduleRender()}applyProjectionStyles(i,a){if(!this.instance||this.isSVG)return;if(!this.isVisible){i.visibility="hidden";return}const l=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,i.visibility="",i.opacity="",i.pointerEvents=as(a?.pointerEvents)||"",i.transform=l?l(this.latestValues,""):"none";return}const u=this.getLead();if(!this.projectionDelta||!this.layout||!u.target){this.options.layoutId&&(i.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,i.pointerEvents=as(a?.pointerEvents)||""),this.hasProjected&&!Mt(this.latestValues)&&(i.transform=l?l({},""):"none",this.hasProjected=!1);return}i.visibility="";const d=u.animationValues||u.latestValues;this.applyTransformsToTarget();let h=nf(this.projectionDeltaWithTransform,this.treeScale,d);l&&(h=l(d,h)),i.transform=h;const{x:m,y:p}=this.projectionDelta;i.transformOrigin=`${m.origin*100}% ${p.origin*100}% 0`,u.animationValues?i.opacity=u===this?d.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:d.opacityExit:i.opacity=u===this?d.opacity!==void 0?d.opacity:"":d.opacityExit!==void 0?d.opacityExit:0;for(const T in Vn){if(d[T]===void 0)continue;const{correct:v,applyTo:C,isCSSVariable:b}=Vn[T],E=h==="none"?d[T]:v(d[T],u);if(C){const M=C.length;for(let $=0;$<M;$++)i[C[$]]=E}else b?this.options.visualElement.renderState.vars[T]=E:i[T]=E}this.options.layoutId&&(i.pointerEvents=u===this?as(a?.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(i=>i.currentAnimation?.stop()),this.root.nodes.forEach(co),this.root.sharedNodes.clear()}}}function of(e){e.updateLayout()}function af(e){const t=e.resumeFrom?.snapshot||e.snapshot;if(e.isLead()&&e.layout&&t&&e.hasListeners("didUpdate")){const{layoutBox:n,measuredBox:s}=e.layout,{animationType:r}=e.options,o=t.source!==e.layout.source;r==="size"?Le(d=>{const h=o?t.measuredBox[d]:t.layoutBox[d],m=Ae(h);h.min=n[d].min,h.max=h.min+m}):ol(r,t.layoutBox,n)&&Le(d=>{const h=o?t.measuredBox[d]:t.layoutBox[d],m=Ae(n[d]);h.max=h.min+m,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[d].max=e.relativeTarget[d].min+m)});const i=qt();An(i,n,t.layoutBox);const a=qt();o?An(a,e.applyTransform(s,!0),t.measuredBox):An(a,n,t.layoutBox);const l=!nl(i);let u=!1;if(!e.resumeFrom){const d=e.getClosestProjectingParent();if(d&&!d.resumeFrom){const{snapshot:h,layout:m}=d;if(h&&m){const p=me();Mn(p,t.layoutBox,h.layoutBox);const T=me();Mn(T,n,m.layoutBox),sl(p,T)||(u=!0),d.options.layoutRoot&&(e.relativeTarget=T,e.relativeTargetOrigin=p,e.relativeParent=d)}}}e.notifyListeners("didUpdate",{layout:n,snapshot:t,delta:a,layoutDelta:i,hasLayoutChanged:l,hasRelativeLayoutChanged:u})}else if(e.isLead()){const{onExitComplete:n}=e.options;n&&n()}e.options.transition=void 0}function lf(e){e.parent&&(e.isProjecting()||(e.isProjectionDirty=e.parent.isProjectionDirty),e.isSharedProjectionDirty||(e.isSharedProjectionDirty=!!(e.isProjectionDirty||e.parent.isProjectionDirty||e.parent.isSharedProjectionDirty)),e.isTransformDirty||(e.isTransformDirty=e.parent.isTransformDirty))}function cf(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function uf(e){e.clearSnapshot()}function co(e){e.clearMeasurements()}function uo(e){e.isLayoutDirty=!1}function df(e){const{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify("BeforeLayoutMeasure"),e.resetTransform()}function ho(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function hf(e){e.resolveTargetDelta()}function ff(e){e.calcProjection()}function mf(e){e.resetSkewAndRotation()}function pf(e){e.removeLeadSnapshot()}function fo(e,t,n){e.translate=de(t.translate,0,n),e.scale=de(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function mo(e,t,n,s){e.min=de(t.min,n.min,s),e.max=de(t.max,n.max,s)}function gf(e,t,n,s){mo(e.x,t.x,n.x,s),mo(e.y,t.y,n.y,s)}function yf(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}const xf={duration:.45,ease:[.4,0,.1,1]},po=e=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),go=po("applewebkit/")&&!po("chrome/")?Math.round:Be;function yo(e){e.min=go(e.min),e.max=go(e.max)}function bf(e){yo(e.x),yo(e.y)}function ol(e,t,n){return e==="position"||e==="preserve-aspect"&&!Ch(ao(t),ao(n),.2)}function vf(e){return e!==e.root&&e.scroll?.wasRoot}const wf=il({attachResizeListener:(e,t)=>In(e,"resize",t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0}),Bs={current:void 0},al=il({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!Bs.current){const e=new wf({});e.mount(window),e.setOptions({layoutScroll:!0}),Bs.current=e}return Bs.current},resetTransform:(e,t)=>{e.style.transform=t!==void 0?t:"none"},checkIsScrollRoot:e=>window.getComputedStyle(e).position==="fixed"}),Sf={pan:{Feature:Fh},drag:{Feature:$h,ProjectionNode:al,MeasureLayout:Qa}};function xo(e,t,n){const{props:s}=e;e.animationState&&s.whileHover&&e.animationState.setActive("whileHover",n==="Start");const r="onHover"+n,o=s[r];o&&le.postRender(()=>o(t,Fn(t)))}class Tf extends xt{mount(){const{current:t}=this.node;t&&(this.unmount=Xu(t,(n,s)=>(xo(this.node,s,"Start"),r=>xo(this.node,r,"End"))))}unmount(){}}class Cf extends xt{constructor(){super(...arguments),this.isActive=!1}onFocus(){let t=!1;try{t=this.node.current.matches(":focus-visible")}catch{t=!0}!t||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=On(In(this.node.current,"focus",()=>this.onFocus()),In(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function bo(e,t,n){const{props:s}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&s.whileTap&&e.animationState.setActive("whileTap",n==="Start");const r="onTap"+(n==="End"?"":n),o=s[r];o&&le.postRender(()=>o(t,Fn(t)))}class jf extends xt{mount(){const{current:t}=this.node;t&&(this.unmount=Gu(t,(n,s)=>(bo(this.node,s,"Start"),(r,{success:o})=>bo(this.node,r,o?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}const fr=new WeakMap,Us=new WeakMap,Pf=e=>{const t=fr.get(e.target);t&&t(e)},Af=e=>{e.forEach(Pf)};function Mf({root:e,...t}){const n=e||document;Us.has(n)||Us.set(n,{});const s=Us.get(n),r=JSON.stringify(t);return s[r]||(s[r]=new IntersectionObserver(Af,{root:e,...t})),s[r]}function Ef(e,t,n){const s=Mf(t);return fr.set(e,n),s.observe(e),()=>{fr.delete(e),s.unobserve(e)}}const kf={some:0,all:1};class Nf extends xt{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:t={}}=this.node.getProps(),{root:n,margin:s,amount:r="some",once:o}=t,i={root:n?n.current:void 0,rootMargin:s,threshold:typeof r=="number"?r:kf[r]},a=l=>{const{isIntersecting:u}=l;if(this.isInView===u||(this.isInView=u,o&&!u&&this.hasEnteredView))return;u&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",u);const{onViewportEnter:d,onViewportLeave:h}=this.node.getProps(),m=u?d:h;m&&m(l)};return Ef(this.node.current,i,a)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:t,prevProps:n}=this.node;["amount","margin","root"].some(Rf(t,n))&&this.startObserver()}unmount(){}}function Rf({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}const ll={inView:{Feature:Nf},tap:{Feature:jf},focus:{Feature:Cf},hover:{Feature:Tf}},Df={layout:{ProjectionNode:al,MeasureLayout:Qa}},Vf={...Ka,...ll,...Sf,...Df},If=Od(Vf,Ua),Of={renderer:Ua,...Ka,...ll};function Jr(e,t){return ls(e,t)}const Lf=Jr("button"),ns=Jr("div"),$f=Jr("p");function Ff({toolName:e,description:t,args:n,onApprove:s,onDeny:r}){const o=Object.keys(n).length>0;return c.jsx("div",{className:"bg-stone-100 dark:bg-stone-800 border border-border rounded-lg px-3 py-2.5 my-1.5",children:c.jsxs("div",{className:"flex items-start gap-2",children:[c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsx("div",{className:"flex items-center gap-1.5 mb-1",children:c.jsx("span",{className:"text-sm font-medium text-foreground",children:e})}),o&&c.jsx("div",{className:"space-y-0.5 mb-1.5",children:Object.entries(n).map(([i,a])=>c.jsxs("div",{className:"flex items-start gap-1.5 text-xs",children:[c.jsxs("span",{className:"text-muted-foreground min-w-[60px]",children:[i,":"]}),c.jsx("span",{className:"font-mono text-foreground",children:typeof a=="string"?a:JSON.stringify(a)})]},i))})]}),c.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[c.jsxs(Te,{size:"sm",variant:"ghost",className:"h-6 px-2 text-xs",onClick:s,children:[c.jsx(ee.Check,{className:"h-3 w-3 mr-1"}),"Approve"]}),c.jsx(Te,{size:"sm",variant:"ghost",className:"h-6 px-2 text-xs text-muted-foreground",onClick:r,children:c.jsx(ee.X,{className:"h-3 w-3"})})]})]})})}function Bf({toolName:e,args:t,isDenied:n,isSafe:s}){const[r,o]=f.useState(!1);if(e==="fetchDocContent")return null;const i=["k","maxResults","_organizationId"];e==="searchDocs"&&i.push("filters");const a=Object.fromEntries(Object.entries(t).filter(([u])=>!i.includes(u))),l=Object.keys(a).length>0;return c.jsxs("div",{className:"my-1",children:[c.jsxs("button",{onClick:()=>l&&o(!r),className:`inline-flex items-center gap-1.5 text-xs rounded-md px-2 py-1 transition-colors bg-muted text-muted-foreground ${l?"cursor-pointer hover:bg-muted/80":""}`,children:[l&&c.jsx("span",{className:"transition-transform duration-200",children:r?c.jsx(ee.ChevronDown,{className:"h-3 w-3"}):c.jsx(ee.ChevronRight,{className:"h-3 w-3"})}),n?c.jsx(ee.X,{className:"h-3 w-3"}):s?c.jsx(ee.Zap,{className:"h-3 w-3"}):c.jsx(ee.Check,{className:"h-3 w-3"}),c.jsxs("span",{className:"font-medium",children:[n?"Denied":s?"Auto-executed":"Executed"," ",e]})]}),r&&l&&c.jsx("div",{className:"mt-1 ml-6 p-2 bg-stone-50 dark:bg-stone-900 rounded-md border border-border",children:c.jsx("div",{className:"space-y-0.5",children:Object.entries(a).map(([u,d])=>c.jsxs("div",{className:"flex items-start gap-1.5 text-xs",children:[c.jsxs("span",{className:"text-muted-foreground min-w-[60px]",children:[u,":"]}),c.jsx("span",{className:"font-mono text-foreground",children:typeof d=="string"?d:JSON.stringify(d)})]},u))})})]})}function Uf({...e}){return c.jsx(mr.Root,{"data-slot":"collapsible",...e})}function zf({...e}){return c.jsx(mr.CollapsibleTrigger,{"data-slot":"collapsible-trigger",...e})}function _f({...e}){return c.jsx(mr.CollapsibleContent,{"data-slot":"collapsible-content",...e})}const Xf=f.lazy(()=>import("streamdown").then(e=>({default:e.Streamdown}))),Zr=f.memo(({className:e,...t})=>typeof window>"u"?null:c.jsx(f.Suspense,{fallback:null,children:c.jsx(Xf,{className:ne("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",e),...t})}),(e,t)=>e.children===t.children);Zr.displayName="Response";const Wf=Object.freeze(Object.defineProperty({__proto__:null,Response:Zr},Symbol.toStringTag,{value:"Module"})),qf=({children:e,as:t="p",className:n,duration:s=2,spread:r=2})=>{const o=If.create(t),i=f.useMemo(()=>(e?.length??0)*r,[e,r]);return c.jsx(o,{animate:{backgroundPosition:"0% center"},className:ne("relative inline-block bg-[length:250%_100%,auto] bg-clip-text text-transparent","[--bg:linear-gradient(90deg,#0000_calc(50%-var(--spread)),var(--color-background),#0000_calc(50%+var(--spread)))] [background-repeat:no-repeat,padding-box]",n),initial:{backgroundPosition:"100% center"},style:{"--spread":`${i}px`,backgroundImage:"var(--bg), linear-gradient(var(--color-muted-foreground), var(--color-muted-foreground))"},transition:{repeat:Number.POSITIVE_INFINITY,duration:s,ease:"linear"},children:e})},Kf=f.memo(qf),cl=f.createContext(null),Gf=()=>{const e=f.useContext(cl);if(!e)throw new Error("Reasoning components must be used within Reasoning");return e},Yf=1e3,Hf=1e3,ul=f.memo(({className:e,isStreaming:t=!1,open:n,defaultOpen:s=!0,onOpenChange:r,duration:o,children:i,...a})=>{const[l,u]=ni.useControllableState({prop:n,defaultProp:s,onChange:r}),[d,h]=ni.useControllableState({prop:o,defaultProp:0}),[m,p]=f.useState(!1),[T,v]=f.useState(null);f.useEffect(()=>{t?T===null&&v(Date.now()):T!==null&&(h(Math.ceil((Date.now()-T)/Hf)),v(null))},[t,T,h]),f.useEffect(()=>{if(s&&!t&&l&&!m){const b=setTimeout(()=>{u(!1),p(!0)},Yf);return()=>clearTimeout(b)}},[t,l,s,u,m]);const C=b=>{u(b)};return c.jsx(cl.Provider,{value:{isStreaming:t,isOpen:l,setIsOpen:u,duration:d},children:c.jsx(Uf,{className:ne("not-prose mb-4",e),onOpenChange:C,open:l,...a,children:i})})}),Jf=(e,t)=>e||t===0?c.jsx(Kf,{duration:1,children:"Thinking..."}):t===void 0?c.jsx("p",{children:"Thought for a few seconds"}):c.jsxs("p",{children:["Thought for ",t," seconds"]}),dl=f.memo(({className:e,children:t,...n})=>{const{isStreaming:s,isOpen:r,duration:o}=Gf();return c.jsx(zf,{className:ne("flex w-full items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground",e),...n,children:t??c.jsxs(c.Fragment,{children:[c.jsx(ee.BrainIcon,{className:"size-4"}),Jf(s,o),c.jsx(ee.ChevronDownIcon,{className:ne("size-4 transition-transform",r?"rotate-180":"rotate-0")})]})})}),hl=f.memo(({className:e,children:t,...n})=>c.jsx(_f,{className:ne("mt-4 text-sm","data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-muted-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in",e),...n,children:c.jsx(Zr,{className:"grid gap-2",children:t})}));ul.displayName="Reasoning";dl.displayName="ReasoningTrigger";hl.displayName="ReasoningContent";function vo(e){return`https://www.google.com/s2/favicons?domain=${encodeURIComponent(e)}&sz=16`}function Zf({sources:e,citationNumber:t,className:n}){const s=e.find(o=>o.number===t);if(!s)return null;const r=vo(s.domain);return c.jsxs(ht,{children:[c.jsx(ft,{asChild:!0,children:c.jsxs("button",{className:ne("inline-flex items-center gap-1 px-1 py-0.5 rounded text-[10px] font-medium","bg-stone-200/60 dark:bg-stone-700/60 text-stone-800 dark:text-stone-200","hover:bg-stone-300/80 dark:hover:bg-stone-600/80","transition-all duration-200","border border-stone-300/60 dark:border-stone-600/60","cursor-pointer hover:scale-105 active:scale-95","leading-tight",n),onClick:o=>{o.preventDefault(),o.stopPropagation(),window.open(s.url,"_blank","noopener,noreferrer")},children:[c.jsx("img",{src:r,alt:"",className:"w-3 h-3 leading-none",onError:o=>{const i=o.target;i.style.display="none"}}),c.jsx("span",{className:"leading-none",children:s.domain})]})}),c.jsx(mt,{side:"top",className:"bg-stone-800 dark:bg-stone-900 border border-stone-700 dark:border-stone-600 p-3 max-w-sm z-50 rounded-lg shadow-lg",children:c.jsxs("div",{className:"space-y-1.5",children:[c.jsxs("div",{className:"text-xs font-semibold text-stone-300 dark:text-stone-200 mb-2 pb-2 border-b border-stone-700 dark:border-stone-600",children:["Sources • ",e.length]}),e.map(o=>{const i=o.title||o.domain;return c.jsxs("a",{href:o.url,target:"_blank",rel:"noopener noreferrer",className:ne("flex items-center gap-2 p-2 rounded-md hover:bg-stone-700/50 dark:hover:bg-stone-700/50 transition-colors","text-stone-300 dark:text-stone-300 hover:text-white dark:hover:text-white"),onClick:a=>a.stopPropagation(),children:[c.jsx("img",{src:vo(o.domain),alt:"",className:"w-4 h-4 flex-shrink-0",onError:a=>{const l=a.target;l.style.display="none"}}),c.jsx("span",{className:"text-xs flex-1 truncate",children:i})]},o.number)})]})})]})}function Qf({text:e,citations:t,citationMap:n,groupedCitations:s,referencesText:r,ResponseComponent:o,className:i,showCitations:a=!0,showReferences:l=!0}){const u=f.useRef(null),[d,h]=f.useState([]);f.useEffect(()=>{if(!a||!u.current||t.length===0||n.size===0){(n.size===0||!a)&&h([]);return}const C=u.current;let b,E=!1;const M=new WeakSet,$=()=>{if(!u.current||E)return;E=!0;const I=u.current,N=/\[(\d+)\]/g,j=document.createTreeWalker(I,NodeFilter.SHOW_TEXT,null),O=[];let A;for(;A=j.nextNode();)if(A.nodeType===Node.TEXT_NODE&&!M.has(A)){const F=A,D=F.textContent||"";let B=F.parentElement,X=!1;for(;B&&B!==I;){if(B.tagName==="A"||B.tagName==="CODE"||B.tagName==="PRE"){X=!0;break}B=B.parentElement}if(!X){const K=Array.from(D.matchAll(N)).filter(ie=>{if(!ie[1])return!1;const ge=parseInt(ie[1],10);return n.has(ge)});K.length>0&&O.push({node:F,matches:K})}}if(O.length===0){E=!1;return}const k=[];O.forEach(({node:F,matches:D})=>{M.add(F);const B=F.textContent||"",X=document.createDocumentFragment();let Y=0;D.forEach(K=>{if(!K[1])return;K.index!==void 0&&K.index>Y&&X.appendChild(document.createTextNode(B.slice(Y,K.index)));const ie=document.createElement("span");ie.className="inline-flex items-center citation-button-container";const ge=parseInt(K[1],10);ie.setAttribute("data-citation",K[1]),X.appendChild(ie),k.push({element:ie,citationNum:ge}),Y=(K.index||0)+K[0].length}),Y<B.length&&X.appendChild(document.createTextNode(B.slice(Y))),F.parentNode&&F.parentNode.replaceChild(X,F)}),k.length>0&&h(F=>{const D=new Set(F.map(Y=>Y.element)),B=F.filter(Y=>Y.element.isConnected),X=k.filter(Y=>!D.has(Y.element));return[...B,...X]}),E=!1},R=new MutationObserver(()=>{clearTimeout(b),b=setTimeout($,100)});return R.observe(C,{childList:!0,subtree:!0,characterData:!0}),b=setTimeout($,200),()=>{R.disconnect(),clearTimeout(b)}},[e,t,n,a]);const m=s&&s.length>0||n&&n.size>0||r;function p(C){return`https://www.google.com/s2/favicons?domain=${encodeURIComponent(C)}&sz=16`}function T(C){try{return new URL(C).hostname.replace(/^www\./,"")}catch{return C}}const v=a&&l&&m?c.jsxs("div",{className:"mt-4 pt-4 border-t border-stone-200 dark:border-stone-700",children:[c.jsx("div",{className:"text-xs font-semibold text-stone-600 dark:text-stone-400 mb-3",children:"References"}),c.jsx("div",{className:"flex flex-wrap gap-2",children:s&&s.length>0?s.map((C,b)=>{const E=C.title||C.baseUrl,M=T(C.url),$=p(M);return c.jsxs("a",{href:C.url,target:"_blank",rel:"noopener noreferrer",className:ne("inline-flex items-center gap-1.5 px-2.5 py-1.5 rounded-md text-xs font-medium","bg-stone-100 dark:bg-stone-800 text-stone-700 dark:text-stone-300","hover:bg-stone-200 dark:hover:bg-stone-700","transition-all duration-200","border border-stone-200 dark:border-stone-700","cursor-pointer hover:scale-105 active:scale-95","no-underline"),children:[c.jsx("img",{src:$,alt:"",className:"w-3.5 h-3.5 shrink-0",onError:R=>{const I=R.target;I.style.display="none"}}),c.jsx("span",{className:"leading-none",children:E})]},`group-${b}`)}):Array.from(n.entries()).sort(([C],[b])=>C-b).map(([C,b])=>{const E=T(b),M=p(E);return c.jsxs("a",{href:b,target:"_blank",rel:"noopener noreferrer",className:ne("inline-flex items-center gap-1.5 px-2.5 py-1.5 rounded-md text-xs font-medium","bg-stone-100 dark:bg-stone-800 text-stone-700 dark:text-stone-300","hover:bg-stone-200 dark:hover:bg-stone-700","transition-all duration-200","border border-stone-200 dark:border-stone-700","cursor-pointer hover:scale-105 active:scale-95","no-underline"),children:[c.jsx("img",{src:M,alt:"",className:"w-3.5 h-3.5 shrink-0",onError:$=>{const R=$.target;R.style.display="none"}}),c.jsx("span",{className:"leading-none",children:b})]},C)})})]}):null;return c.jsxs("div",{className:i,children:[c.jsx("div",{ref:u,children:c.jsx(o,{children:e})}),a&&d.filter(({element:C})=>C.isConnected).map(({element:C,citationNum:b},E)=>{if(!t.find(R=>R.number===b))return null;const $=Array.from(new Map(t.map(R=>{const I=R.url.replace(/\/+$/,""),N=s?.find(j=>j.url.replace(/\/+$/,"")===I);return[I,{number:R.number,url:R.url,domain:T(R.url),title:N?.title}]})).values());return kl.createPortal(c.jsx(Zf,{sources:$,citationNumber:b},`citation-${b}-${C}`),C,`citation-${b}-${E}`)}),v]})}function tn({...e}){return c.jsx(Dt.Root,{"data-slot":"dialog",...e})}function em({...e}){return c.jsx(Dt.Portal,{"data-slot":"dialog-portal",...e})}function tm({className:e,...t}){return c.jsx(Dt.Overlay,{"data-slot":"dialog-overlay",className:ne("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",e),...t})}function nn({className:e,children:t,showCloseButton:n=!0,...s}){return c.jsxs(em,{"data-slot":"dialog-portal",children:[c.jsx(tm,{}),c.jsxs(Dt.Content,{"data-slot":"dialog-content",className:ne("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",e),...s,children:[t,n&&c.jsxs(Dt.Close,{"data-slot":"dialog-close",className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[c.jsx(ee.XIcon,{}),c.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function sn({className:e,...t}){return c.jsx("div",{"data-slot":"dialog-header",className:ne("flex flex-col gap-2 text-center sm:text-left",e),...t})}function rn({className:e,...t}){return c.jsx("div",{"data-slot":"dialog-footer",className:ne("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...t})}function on({className:e,...t}){return c.jsx(Dt.Title,{"data-slot":"dialog-title",className:ne("text-lg leading-none font-semibold",e),...t})}function an({className:e,...t}){return c.jsx(Dt.Description,{"data-slot":"dialog-description",className:ne("text-muted-foreground text-sm",e),...t})}function ln({className:e,type:t,...n}){return c.jsx("input",{type:t,"data-slot":"input",className:ne("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input h-9 w-full min-w-0 rounded-md border bg-white px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm","focus-visible:border-ring","aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",e),...n})}function nm({isOpen:e,title:t="Password Required",description:n="Please enter your password to continue",placeholder:s="Enter password...",onComplete:r}){const[o,i]=f.useState(""),[a,l]=f.useState(!1),[u,d]=f.useState(!1),h=async p=>{if(p.preventDefault(),!!o.trim()){d(!0);try{r(o)}finally{d(!1)}}},m=()=>{i(""),r(null)};return c.jsx(tn,{open:e,children:c.jsx(nn,{showCloseButton:!1,children:c.jsxs("form",{onSubmit:h,children:[c.jsxs(sn,{children:[c.jsx(on,{children:t}),c.jsx(an,{children:n})]}),c.jsx("div",{className:"py-4",children:c.jsxs("div",{className:"relative",children:[c.jsx(ln,{type:a?"text":"password",value:o,onChange:p=>i(p.target.value),placeholder:s,className:"pr-10",autoFocus:!0,disabled:u}),c.jsx("button",{type:"button",onClick:()=>l(!a),className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600",disabled:u,children:a?c.jsx(ee.EyeOff,{className:"h-4 w-4"}):c.jsx(ee.Eye,{className:"h-4 w-4"})})]})}),c.jsxs(rn,{children:[c.jsx(Te,{type:"button",variant:"ghost",onClick:m,disabled:u,children:"Cancel"}),c.jsx(Te,{type:"submit",disabled:!o.trim()||u,children:u?"Submitting...":"Submit"})]})]})})})}function sm({isOpen:e,title:t="Email Required",description:n="Please enter your email address",placeholder:s="Enter email address...",onComplete:r}){const[o,i]=f.useState(""),[a,l]=f.useState(!0),[u,d]=f.useState(!1),h=v=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(v),m=v=>{i(v),v.trim()?l(h(v)):l(!0)},p=async v=>{if(v.preventDefault(),!o.trim()||!h(o)){l(!1);return}d(!0);try{r(o)}finally{d(!1)}},T=()=>{i(""),l(!0),r(null)};return c.jsx(tn,{open:e,children:c.jsx(nn,{showCloseButton:!1,children:c.jsxs("form",{onSubmit:p,children:[c.jsxs(sn,{children:[c.jsxs(on,{className:"flex items-center gap-2",children:[c.jsx(ee.Mail,{className:"h-5 w-5"}),t]}),c.jsx(an,{children:n})]}),c.jsxs("div",{className:"py-4",children:[c.jsx(ln,{type:"email",value:o,onChange:v=>m(v.target.value),placeholder:s,className:a?"":"border-red-500",autoFocus:!0,disabled:u}),!a&&c.jsx("p",{className:"text-sm text-red-500 mt-1",children:"Please enter a valid email address"})]}),c.jsxs(rn,{children:[c.jsx(Te,{type:"button",variant:"ghost",onClick:T,disabled:u,children:"Cancel"}),c.jsx(Te,{type:"submit",disabled:!o.trim()||!a||u,children:u?"Submitting...":"Submit"})]})]})})})}function rm({isOpen:e,title:t="Phone Number Required",description:n="Please enter your phone number",placeholder:s="Enter phone number...",onComplete:r}){const[o,i]=f.useState(""),[a,l]=f.useState(!0),[u,d]=f.useState(!1),h=C=>{const b=C.replace(/\D/g,"");return b.length<=3?b:b.length<=6?`(${b.slice(0,3)}) ${b.slice(3)}`:`(${b.slice(0,3)}) ${b.slice(3,6)}-${b.slice(6,10)}`},m=C=>C.replace(/\D/g,"").length===10,p=C=>{const b=h(C);i(b),b.trim()?l(m(b)):l(!0)},T=async C=>{if(C.preventDefault(),!o.trim()||!m(o)){l(!1);return}d(!0);try{const b=o.replace(/\D/g,"");r(b)}finally{d(!1)}},v=()=>{i(""),l(!0),r(null)};return c.jsx(tn,{open:e,children:c.jsx(nn,{showCloseButton:!1,children:c.jsxs("form",{onSubmit:T,children:[c.jsxs(sn,{children:[c.jsxs(on,{className:"flex items-center gap-2",children:[c.jsx(ee.Phone,{className:"h-5 w-5"}),t]}),c.jsx(an,{children:n})]}),c.jsxs("div",{className:"py-4",children:[c.jsx(ln,{type:"tel",value:o,onChange:C=>p(C.target.value),placeholder:s,className:a?"":"border-red-500",maxLength:14,autoFocus:!0,disabled:u}),!a&&c.jsx("p",{className:"text-sm text-red-500 mt-1",children:"Please enter a valid 10-digit phone number"})]}),c.jsxs(rn,{children:[c.jsx(Te,{type:"button",variant:"ghost",onClick:v,disabled:u,children:"Cancel"}),c.jsx(Te,{type:"submit",disabled:!o.trim()||!a||u,children:u?"Submitting...":"Submit"})]})]})})})}function im({isOpen:e,title:t="PIN Required",description:n="Please enter your PIN",placeholder:s="Enter PIN...",length:r=4,onComplete:o}){const[i,a]=f.useState(""),[l,u]=f.useState(!1),d=p=>{const T=p.replace(/\D/g,"");a(T.slice(0,r))},h=async p=>{if(p.preventDefault(),i.length===r){u(!0);try{o(i)}finally{u(!1)}}},m=()=>{a(""),o(null)};return c.jsx(tn,{open:e,children:c.jsx(nn,{showCloseButton:!1,children:c.jsxs("form",{onSubmit:h,children:[c.jsxs(sn,{children:[c.jsxs(on,{className:"flex items-center gap-2",children:[c.jsx(ee.Shield,{className:"h-5 w-5"}),t]}),c.jsx(an,{children:n})]}),c.jsxs("div",{className:"py-4",children:[c.jsx(ln,{type:"password",value:i,onChange:p=>d(p.target.value),placeholder:s,className:"text-center text-lg tracking-widest",maxLength:r,autoFocus:!0,disabled:l}),c.jsxs("p",{className:"text-sm text-gray-500 mt-1 text-center",children:["Enter ",r,"-digit PIN"]})]}),c.jsxs(rn,{children:[c.jsx(Te,{type:"button",variant:"ghost",onClick:m,disabled:l,children:"Cancel"}),c.jsx(Te,{type:"submit",disabled:i.length!==r||l,children:l?"Submitting...":"Submit"})]})]})})})}function zs({isOpen:e,title:t="Secure Input Required",description:n="Please enter the requested information",placeholder:s="Enter value...",type:r="password",onComplete:o}){const[i,a]=f.useState(""),[l,u]=f.useState(!1),d=async m=>{if(m.preventDefault(),!!i.trim()){u(!0);try{o(i)}finally{u(!1)}}},h=()=>{a(""),o(null)};return c.jsx(tn,{open:e,children:c.jsx(nn,{showCloseButton:!1,children:c.jsxs("form",{onSubmit:d,children:[c.jsxs(sn,{children:[c.jsxs(on,{className:"flex items-center gap-2",children:[c.jsx(ee.Lock,{className:"h-5 w-5"}),t]}),c.jsx(an,{children:n})]}),c.jsx("div",{className:"py-4",children:c.jsx(ln,{type:r,value:i,onChange:m=>a(m.target.value),placeholder:s,autoFocus:!0,disabled:l})}),c.jsxs(rn,{children:[c.jsx(Te,{type:"button",variant:"ghost",onClick:h,disabled:l,children:"Cancel"}),c.jsx(Te,{type:"submit",disabled:!i.trim()||l,children:l?"Submitting...":"Submit"})]})]})})})}function om({isOpen:e,title:t,description:n,fields:s,onComplete:r,submitText:o="Submit",cancelText:i="Cancel"}){const[a,l]=f.useState(()=>{const A={};return s.forEach(k=>{A[k.name]=k.value||""}),A}),[u,d]=f.useState({}),[h,m]=f.useState({}),[p,T]=f.useState(!1),v=A=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(A)?null:"Please enter a valid email address",C=A=>A.replace(/\D/g,"").length===10?null:"Please enter a valid 10-digit phone number",b=(A,k=4)=>A.length===k?null:`PIN must be ${k} digits`,E=A=>{const k=A.replace(/\D/g,"");return k.length<=3?k:k.length<=6?`(${k.slice(0,3)}) ${k.slice(3)}`:`(${k.slice(0,3)}) ${k.slice(3,6)}-${k.slice(6,10)}`},M=(A,k,F)=>{let D=k,B=null;switch(F.type){case"phone":D=E(k),D.trim()&&(B=C(D));break;case"email":k.trim()&&(B=v(k));break;case"pin":D=k.replace(/\D/g,"").slice(0,6),D.trim()&&(B=b(D));break}!B&&F.validation&&D.trim()&&(B=F.validation(D)),l(X=>({...X,[A]:D})),d(X=>({...X,[A]:B||""}))},$=()=>{const A={};let k=!0;return s.forEach(F=>{const D=a[F.name]||"";let B=null;if(F.required&&!D.trim())B=`${F.label} is required`;else if(D.trim()){switch(F.type){case"email":B=v(D);break;case"phone":B=C(D);break;case"pin":B=b(D);break}!B&&F.validation&&(B=F.validation(D))}B&&(A[F.name]=B,k=!1)}),d(A),k},R=async A=>{if(A.preventDefault(),!!$()){T(!0);try{const k={};s.forEach(F=>{const D=a[F.name]?.trim();D&&(F.type==="phone"?k[F.name]=D.replace(/\D/g,""):k[F.name]=D)}),r(k)}finally{T(!1)}}},I=()=>{l({}),d({}),m({}),r(null)},N=A=>{m(k=>({...k,[A]:!k[A]}))},j=A=>{switch(A.type){case"password":return h[A.name]?"text":"password";case"email":return"email";case"phone":return"tel";case"pin":case"ssn":return"password";default:return"text"}},O=A=>{if(A.placeholder)return A.placeholder;switch(A.type){case"email":return"Enter email address...";case"phone":return"Enter phone number...";case"password":return"Enter password...";case"pin":return"Enter PIN...";case"ssn":return"XXX-XX-XXXX";case"creditCard":return"XXXX XXXX XXXX XXXX";default:return`Enter ${A.label.toLowerCase()}...`}};return c.jsx(tn,{open:e,children:c.jsx(nn,{showCloseButton:!1,className:"max-w-md",children:c.jsxs("form",{onSubmit:R,children:[c.jsxs(sn,{children:[c.jsx(on,{children:t}),n&&c.jsx(an,{children:n})]}),c.jsx("div",{className:"py-4 space-y-4",children:s.map(A=>c.jsxs("div",{children:[c.jsxs("label",{className:"block text-sm font-medium mb-1",children:[A.label,A.required&&c.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),c.jsxs("div",{className:"relative",children:[c.jsx(ln,{type:j(A),value:a[A.name]||"",onChange:k=>M(A.name,k.target.value,A),placeholder:O(A),className:u[A.name]?"border-red-500":"",disabled:p,autoFocus:A===s[0],maxLength:A.type==="pin"?6:A.type==="phone"?14:void 0}),A.type==="password"&&c.jsx("button",{type:"button",onClick:()=>N(A.name),className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600",disabled:p,children:h[A.name]?c.jsx(ee.EyeOff,{className:"h-4 w-4"}):c.jsx(ee.Eye,{className:"h-4 w-4"})})]}),u[A.name]&&c.jsxs("div",{className:"flex items-center gap-1 mt-1 text-sm text-red-500",children:[c.jsx(ee.AlertCircle,{className:"h-3 w-3"}),u[A.name]]})]},A.name))}),c.jsxs(rn,{children:[c.jsx(Te,{type:"button",variant:"ghost",onClick:I,disabled:p,children:i}),c.jsx(Te,{type:"submit",disabled:p,children:p?"Submitting...":o})]})]})})})}const fl=f.createContext(void 0);function ml(){const e=f.useContext(fl);if(!e)throw new Error("useSecureModal must be used within a SecureModalProvider");return e}function pl({children:e}){const[t,n]=f.useState(null),[s,r]=f.useState(null),o=f.useRef(null),i=f.useRef(null),a=f.useCallback(p=>new Promise(T=>{n(p),o.current=T}),[]),l=f.useCallback(p=>new Promise(T=>{r(p),i.current=T}),[]),u=f.useCallback(p=>{o.current&&(o.current(p),o.current=null),n(null)},[]),d=f.useCallback(p=>{i.current&&(i.current(p),i.current=null),r(null)},[]),h=()=>{if(s){const T=s.fields.map(v=>({name:v.name,type:v.type==="text"?"text":v.type==="password"?"password":v.type==="email"?"email":v.type==="phone"?"phone":v.type==="pin"?"pin":v.type==="ssn"?"ssn":v.type==="creditCard"?"creditCard":"text",label:v.label,placeholder:v.placeholder,required:v.required!==!1,value:v.value}));return c.jsx(om,{isOpen:!0,title:s.title,description:s.description,fields:T,onComplete:d})}if(!t)return null;const p={isOpen:!0,title:t.title,description:t.description,placeholder:t.placeholder,onComplete:u};switch(t.type){case"password":return c.jsx(nm,{...p});case"email":return c.jsx(sm,{...p});case"phone":return c.jsx(rm,{...p});case"pin":return c.jsx(im,{...p});case"ssn":return c.jsx(zs,{...p,title:t.title||"SSN Required",placeholder:t.placeholder||"XXX-XX-XXXX"});case"creditCard":return c.jsx(zs,{...p,title:t.title||"Credit Card Required",placeholder:t.placeholder||"XXXX XXXX XXXX XXXX",type:"text"});case"text":default:return c.jsx(zs,{...p})}},m=f.useMemo(()=>({showSecureModal:a,showSecureForm:l}),[a,l]);return c.jsxs(fl.Provider,{value:m,children:[e,h()]})}function am(e){try{const t=new URL(e),n=`${t.protocol}//${t.host}${t.pathname}`,s=t.hash?t.hash.substring(1):void 0;return{baseUrl:n,anchor:s}}catch{const t=e.indexOf("#");return t!==-1?{baseUrl:e.substring(0,t),anchor:e.substring(t+1)}:{baseUrl:e}}}function lm(e){try{const t=new URL(e),s=t.pathname.split("/").filter(a=>a.length>0);if(s.length===0)return t.hostname;const r=s[s.length-1];return r&&r.replace(/\.(md|mdx|html|htm)$/i,"").replace(/[-_]/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").split(" ").map(a=>a.charAt(0).toUpperCase()+a.slice(1).toLowerCase()).join(" ")||t.hostname}catch{const t=e.indexOf("#"),n=t!==-1?e.substring(0,t):e,s=n.split("/").filter(r=>r.length>0);if(s.length>0){const r=s[s.length-1];return r&&r.replace(/\.(md|mdx|html|htm)$/i,"").replace(/[-_]/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").split(" ").map(a=>a.charAt(0).toUpperCase()+a.slice(1).toLowerCase()).join(" ")||n}return n}}function wo(e){let t=e.replace(/_+$/gm,"");const n=/(?:^|\n)(?:#+\s*)?(?:References|References:)(?:\*\*)?\s*\n?([\s\S]*?)(?=\n\n|\n#|$)/i,s=t.match(n),r=new Map,o=[],i=new Map,a=new Map,l=new Map,u=new Map;if(s&&s[1]){const j=s[1],O=/\[(\d+)\]\s*(https?:\/\/[^\s\)]+)/g;let A;for(;(A=O.exec(j))!==null;)if(A[1]&&A[2]){const k=parseInt(A[1],10),F=A[2].replace(/[.,;:!?]+$/,""),D=F.replace(/\/+$/,"");if(a.has(D)||a.set(D,F),i.has(D)||i.set(D,[]),i.get(D).push(k),!l.has(D))l.set(D,k);else{const B=l.get(D);k<B&&l.set(D,k)}}for(const[k,F]of i.entries()){const D=l.get(k);for(const B of F)B!==D&&u.set(B,D)}for(const[k,F]of l.entries()){const D=a.get(k)||k;r.set(F,D),o.push({number:F,url:D})}}let d,h=t;s&&s[0]&&(d=s[0],h=t.replace(n,""));const m=[];let p=0;const T=/```[\s\S]*?```|`[^`]+`/g;let v;for(;(v=T.exec(h))!==null;)v.index>p&&m.push({type:"text",content:h.slice(p,v.index),start:p,end:v.index}),m.push({type:"code",content:v[0],start:v.index,end:v.index+v[0].length}),p=v.index+v[0].length;p<h.length&&m.push({type:"text",content:h.slice(p),start:p,end:h.length});const C=m.map(j=>{if(j.type==="code")return j.content;let O=j.content;return O=O.replace(/\[(\d+)\]\((https?:\/\/[^\)]+)\)/g,(k,F,D)=>{const B=parseInt(F,10),X=D.replace(/\/+$/,""),Y=u.get(B)||B;return l.has(X)||(l.set(X,Y),r.has(Y)||(r.set(Y,D),o.push({number:Y,url:D}))),`[${Y}]`}),O=O.replace(/\[(\d+)\]/g,(k,F)=>{const D=parseInt(F,10);return`[${u.get(D)||D}]`}),O}),b=[];for(const[j,O]of l.entries()){const A=a.get(j)||j,{baseUrl:k,anchor:F}=am(A),D=lm(A);b.push({url:A,baseUrl:k,numbers:[O],anchor:F,title:D})}b.sort((j,O)=>(j.numbers[0]||0)-(O.numbers[0]||0));const E=new Map;let M=1;for(const j of b){const O=j.numbers[0];E.set(O,M),j.numbers=[M],M++}const $=new Map;for(const[j,O]of r.entries()){const A=E.get(j);A&&$.set(A,O)}const R=o.map(j=>{const O=E.get(j.number);return O?{number:O,url:j.url}:j}).filter(j=>E.has(j.number)),I=Array.from(E.entries()).sort((j,O)=>O[0]-j[0]);let N=C.join("");for(const[j,O]of I){const A=new RegExp(`\\[${j}\\](?!\\d)`,"g");N=N.replace(A,`[${O}]`)}return{processedText:N,citations:R.sort((j,O)=>j.number-O.number),citationMap:$,groupedCitations:b,referencesText:d}}function En(e){if(typeof e=="string")try{const t=JSON.parse(e);return En(t)}catch{return e}if(Array.isArray(e))return e.map(En);if(e&&typeof e=="object"){const t={};for(const[n,s]of Object.entries(e))t[n]=En(s);return t}return e}function _s(e){if(typeof e=="string"){try{const t=JSON.parse(e);if(t&&typeof t=="object"&&!Array.isArray(t))return En(t)}catch{}return{}}return e&&typeof e=="object"&&!Array.isArray(e)?En(e):{}}function cm({theme:e="auto",layout:t="sidebar",model:n="auto",animated:s=!0,title:r="Chat",logo:o=void 0,defaultWidth:i=384,minWidth:a=300,maxWidth:l=800,initiallyExpanded:u=!1,tools:d=[],safeTools:h=[],safeToolNames:m,toolMetadata:p,systemPrompt:T="",agentId:v,agentName:C,tokenEndpoint:b="/api/arcten/token",apiBaseUrl:E="https://api.arcten.com",user:M,state:$,onStateChange:R,allowStateEdits:I=!0,sources:N,ragConfig:j,showCitations:O=!0,sensitiveParams:A,autoDetectSensitive:k=!1}){const F=E.replace(/\/+$/,""),{showSecureModal:D}=ml(),B=Ao({apiBaseUrl:F,tokenEndpoint:b,user:M,tools:d,safeTools:h,toolMetadata:p,sensitiveParams:A,autoDetectSensitive:k,agentId:v,agentName:C,state:$,onStateChange:R,allowStateEdits:I,sources:N,ragConfig:j});f.useMemo(()=>j!==void 0?j:N&&N.length>0?{enabled:!0,organizationId:N[0],autoExecute:!0,filters:void 0}:{enabled:!1},[N,j]);const[X,Y]=f.useState(u),[K,ie]=f.useState(i),[ge,Ke]=f.useState(600),[bt,tt]=f.useState(!1),[G,Vt]=f.useState(!1),[Me,vt]=f.useState(!1),[Ce,Ue]=f.useState({x:100,y:100}),[cn,oe]=f.useState(!1),[un,wt]=f.useState({x:0,y:0}),[dn,Bn]=f.useState(!1),ze=f.useRef(null),St=f.useRef(null),[Tt,Re]=f.useState(""),[hn,vs]=f.useState(null),[It,fn]=f.useState("Thinking..."),[Ot,nt]=f.useState(new Set),[ws,Un]=f.useState(""),[st,zn]=f.useState([]),_n=f.useRef(new Map),Lt=f.useRef(!1),ce=f.useRef(""),[$t,ct]=f.useState(!1),[ye,mn]=f.useState(!1),Ge=f.useMemo(()=>[...d,...h],[d,h]),Ve=f.useMemo(()=>pr(Ge,p),[Ge,p]),pn=f.useMemo(()=>{const S=new Map,W=new Map(Ve.map(_=>[_.name,_]));return Ge.forEach(_=>{const J=_[$e];if(J){const Z=W.get(J);if(Z){S.set(Z.name,_);return}}const H=Ve.find(Z=>Z.name===_.name);H&&S.set(H.name,_)}),S},[Ge,Ve]),Ye=f.useMemo(()=>{const S=new Set,W=new Map(Ve.map(_=>[_.name,_]));return h.forEach(_=>{const J=_[$e];if(J&&W.has(J))S.add(J);else{const H=Ve.find(Z=>Z.name===_.name);H&&S.add(H.name)}}),m&&Array.isArray(m)&&m.forEach(_=>{typeof _=="string"&&S.add(_)}),S},[h,Ve,m]),Ct=["Thinking...","Pondering...","Contemplating...","Considering...","Analyzing...","Processing...","Reasoning...","Mulling it over...","Computing...","Cooking up a response...","Brewing ideas...","Connecting the dots...","Piecing it together...","Spinning up thoughts...","Loading brain cells...","Sharpening pencils...","Herding ideas...","Warming up neurons...","Stirring the think-pot...","Plotting a plan...","Wiggling the logic wires...","Rolling ideas around...","Charging the brainstorm...","Booting the brain...","Dusting off the cortex...","Running mental diagnostics...","Fetching cleverness...","Whisking up notions...","Tuning the idea radio...","Juggling possibilities...","Breathing in inspiration...","Squeezing the thought sponge...","Tickling the gray matter...","Bubbling up insights...","Spicing the soup of thought...","Lacing up hypotheses...","Winding the idea clock...","Casting the net for clues...","Polishing the crystal ball...","Mapping the maze...","Crunching the brain-biscuits...","Cueing the eureka moment...","Summoning the muse...","Knocking on insight’s door...","Combing the noodle...","Sailing the think-ship...","Scooping brain gelato...","Testing wild hunches...","Tick-tocking the neurons...","Planting idea seeds...","Shaking the thought snow globe...","Unlocking the mental toolbox...","Nudging the puzzle pieces...","Lighting the idea bulb...","Preheating the oven of insight...","Mixing the mental trail mix...","Spooling up reasoning reels...","Skimming the mind-palace index...","Surfing the thought waves...","Kicking the tires on ideas...","Rattling the idea can...","Waving the logic wand..."];f.useEffect(()=>{if(typeof window<"u"){const S=localStorage.getItem("arcten-sidebar-expanded");S&&Y(JSON.parse(S));const W=localStorage.getItem("arcten-sidebar-width");W&&ie(parseInt(W));const _=localStorage.getItem("arcten-sidebar-height");_&&Ke(parseInt(_));const J=localStorage.getItem("arcten-sidebar-detached");J&&Vt(JSON.parse(J));const H=localStorage.getItem("arcten-sidebar-position");if(H){const Ee=JSON.parse(H),se=50,we=Math.max(se-i,Math.min(Ee.x,window.innerWidth-se)),U=Math.max(0,Math.min(Ee.y,window.innerHeight-se));Ue({x:we,y:U})}const Z=localStorage.getItem("arcten-sidebar-minimized");Z&&vt(JSON.parse(Z)),Bn(!0)}},[]),f.useMemo(()=>M,[M?.id]),f.useEffect(()=>{(async()=>{if(Ge.length===0)return;const W=Ge.map(_=>`${_.name}:${_.toString()}`).join("|");if(W!==ce.current&&!Lt.current){Lt.current=!0,ce.current=W;try{const _=Ge.map(H=>({name:H.name,code:H.toString()})),J=await fetch(`${F}/tools/describe`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tools:_})});if(J.ok){const H=await J.json();H.tools&&H.tools.forEach(Z=>{_n.current.set(Z.name,Z)}),zn(H.tools)}}catch(_){console.error("Failed to fetch tool descriptions:",_)}finally{Lt.current=!1}}})()},[Ge,F]),f.useEffect(()=>{Promise.resolve().then(()=>Wf).then(S=>{vs(()=>S.Response)})},[]),f.useEffect(()=>{const S=()=>{Un(window.location.pathname)};S(),window.addEventListener("popstate",S);const W=setInterval(S,500);return()=>{window.removeEventListener("popstate",S),clearInterval(W)}},[]);const{id:Xn,messages:je,sendMessage:ut,status:De,error:Wn,stop:Ft,addToolOutput:rt,setMessages:qn,clientToken:Kn,tokenError:He,conversations:Je,isLoadingConversations:gn,loadConversation:_e,deleteConversation:Ze,startNewConversation:Gn}=B;f.useEffect(()=>{X&&St.current&&St.current.focus()},[X,je]),f.useEffect(()=>{const S=je[je.length-1];if(!S||S.role!=="assistant")return;const W=S.parts?.filter(_=>_.type?.startsWith("tool-")&&_.state==="input-available"&&typeof _.toolCallId=="string"&&_.input!==void 0)||[];for(const _ of W){const J=_,H=J.type?.replace("tool-","")||"",Z=J.toolCallId;if(Ye.has(H)){if(Ot.has(Z))continue;nt(se=>se.has(Z)?se:new Set(se).add(Z)),(async()=>{try{const se=pn.get(H);if(!se){console.warn(`[ArctenAgent] Tool ${H} not found in toolsMap`),rt({toolCallId:Z,tool:H,output:`Error: Tool ${H} not found`}),nt(te=>{const Pe=new Set(te);return Pe.delete(Z),Pe});return}const we=_s(J.input),U=Ve.find(te=>te.name===H);let fe;if(U&&U.jsonSchema?.properties){const Pe=Object.keys(U.jsonSchema.properties).map(he=>we[he]);fe=await se(...Pe)}else fe=await se(...Object.values(we));rt({toolCallId:Z,tool:H,output:fe}),nt(te=>{const Pe=new Set(te);return Pe.delete(Z),Pe})}catch(se){console.error(`[ArctenAgent] Error executing safe tool ${H}:`,se),rt({toolCallId:Z,tool:H,output:`Error: ${se instanceof Error?se.message:String(se)}`}),nt(we=>{const U=new Set(we);return U.delete(Z),U})}})()}}},[je,Ye,pn,Ve,rt,Ot]);function Yn(){Y(!0),localStorage.setItem("arcten-sidebar-expanded","true")}function it(){Y(!1),localStorage.setItem("arcten-sidebar-expanded","false")}f.useEffect(()=>{},[X]),f.useEffect(()=>{ze.current&&ze.current.scrollIntoView({behavior:"smooth"})},[je]),f.useEffect(()=>{function S(W){W.key==="Escape"&&(De==="streaming"||De==="submitted")&&(W.preventDefault(),Ft())}return window.addEventListener("keydown",S),()=>window.removeEventListener("keydown",S)},[De,Ft]);function jt(S){const W=Math.floor((Date.now()-S)/1e3);return W<60?"now":W<3600?`${Math.floor(W/60)}m`:W<86400?`${Math.floor(W/3600)}h`:`${Math.floor(W/86400)}d`}function Hn(){Gn(),mn(!1)}function yn(S){if(S.preventDefault(),!Tt.trim())return;(De==="streaming"||De==="submitted")&&Ft();const W=Ct[Math.floor(Math.random()*Ct.length)]||"Thinking...";fn(W),ut({text:Tt}),Re("")}function dt(S){const W=S.target.value;Re(W)}f.useEffect(()=>{if(!bt)return;function S(_){if(G){const J=_.clientX-Ce.x,H=_.clientY-Ce.y;J>=a&&J<=l&&ie(J),H>=400&&H<=1e3&&Ke(H)}else{const J=window.innerWidth-_.clientX;J>=a&&J<=l&&ie(J)}}function W(){tt(!1),localStorage.setItem("arcten-sidebar-width",K.toString()),localStorage.setItem("arcten-sidebar-height",ge.toString())}return window.addEventListener("mousemove",S),window.addEventListener("mouseup",W),()=>{window.removeEventListener("mousemove",S),window.removeEventListener("mouseup",W)}},[bt,K,ge,G,Ce,a,l]);function Bt(S){S.preventDefault(),tt(!0)}function Ss(){Vt(!0),vt(!1),localStorage.setItem("arcten-sidebar-detached","true"),localStorage.setItem("arcten-sidebar-minimized","false")}function xn(){Vt(!1),vt(!1),localStorage.setItem("arcten-sidebar-detached","false"),localStorage.setItem("arcten-sidebar-minimized","false")}function bn(){vt(!Me),localStorage.setItem("arcten-sidebar-minimized",JSON.stringify(!Me))}function Jn(S){G&&(oe(!0),wt({x:S.clientX-Ce.x,y:S.clientY-Ce.y}))}return f.useEffect(()=>{if(!G)return;function S(){Ue(W=>{const J=window.innerWidth-50,H=window.innerHeight-50,Z=50-K,Ee=0,se=Math.max(Z,Math.min(W.x,J)),we=Math.max(Ee,Math.min(W.y,H));if(se!==W.x||we!==W.y){const U={x:se,y:we};return localStorage.setItem("arcten-sidebar-position",JSON.stringify(U)),U}return W})}return window.addEventListener("resize",S),()=>window.removeEventListener("resize",S)},[G,K]),f.useEffect(()=>{if(!cn)return;function S(_){const J=_.clientX-un.x,H=_.clientY-un.y,Z=50,Ee=window.innerWidth-Z,se=window.innerHeight-Z,we=Z-K,U=0,fe=Math.max(we,Math.min(J,Ee)),te=Math.max(U,Math.min(H,se));Ue({x:fe,y:te})}function W(){oe(!1),localStorage.setItem("arcten-sidebar-position",JSON.stringify(Ce))}return window.addEventListener("mousemove",S),window.addEventListener("mouseup",W),()=>{window.removeEventListener("mousemove",S),window.removeEventListener("mouseup",W)}},[cn,un,Ce,K]),dn?He?c.jsx("div",{className:"fixed right-0 top-0 h-screen w-96 flex items-center justify-center p-4 bg-stone-50 dark:bg-stone-900 border-l border-border",children:c.jsxs("div",{className:"p-4 bg-destructive/10 text-destructive text-sm rounded-lg",children:["Authentication error: ",He]})}):Kn?c.jsx(id,{features:Of,children:c.jsx(ns,{id:"arcten-sidebar","data-theme":e,"data-layout":t,"data-model":n,initial:G?{opacity:0,scale:.95,filter:"blur(4px)"}:!1,animate:G?{opacity:1,scale:1,filter:"blur(0px)"}:{},transition:{duration:.2,ease:"easeOut"},className:`
|
|
11
|
+
${G?"fixed z-50 shadow-xl rounded-xl":"h-screen flex-shrink-0 relative rounded-l-2xl"}
|
|
12
|
+
${X?"bg-stone-50 dark:bg-stone-900":"bg-stone-100 dark:bg-stone-800 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors duration-200"}
|
|
13
|
+
${G?"border border-border":"border-l border-border"}
|
|
14
|
+
${X?"":"w-[30px]"}
|
|
15
|
+
`,style:X?G?{width:`${K}px`,height:Me?"auto":`${ge}px`,left:`${Ce.x}px`,top:`${Ce.y}px`}:{width:`${K}px`}:void 0,onClick:X?void 0:Yn,children:X?c.jsxs(c.Fragment,{children:[!G&&c.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-1 cursor-col-resize hover:bg-blue-500/40 hover:w-1 transition-all group",onMouseDown:Bt,children:c.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-3 -translate-x-1"})}),G&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"absolute bottom-0 right-0 w-4 h-4 cursor-nwse-resize",onMouseDown:S=>{S.preventDefault(),tt(!0)}}),c.jsx("div",{className:"absolute bottom-0 left-4 right-4 h-3 cursor-move hover:bg-blue-500/20 group",onMouseDown:S=>{S.preventDefault(),S.stopPropagation(),oe(!0),wt({x:S.clientX-Ce.x,y:S.clientY-Ce.y})},children:c.jsx("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-8 h-1 rounded-full bg-stone-400/30 group-hover:bg-blue-500/40 transition-colors"})}),c.jsx("div",{className:"absolute top-0 right-0 bottom-0 w-1 cursor-ew-resize hover:bg-blue-500/40",onMouseDown:S=>{S.preventDefault(),tt(!0)}})]}),c.jsxs("div",{className:"flex flex-col h-full",children:[c.jsxs("div",{className:`flex items-center justify-between p-3 border-b border-border ${G?"cursor-move":""}`,onMouseDown:G?Jn:void 0,children:[c.jsx("h2",{className:`text-base font-semibold ${G&&Me?"cursor-pointer":""}`,onClick:G&&Me?S=>{S.stopPropagation(),bn()}:void 0,children:r}),c.jsxs("div",{className:"flex items-center gap-1",onClick:S=>S.stopPropagation(),children:[c.jsxs(ht,{children:[c.jsx(ft,{asChild:!0,children:c.jsx("button",{type:"button",className:ne(At({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:Hn,"aria-label":"New chat",children:c.jsx(ee.Plus,{className:"h-4 w-4"})})}),c.jsx(mt,{children:"Start a new conversation"})]}),c.jsxs(ht,{children:[c.jsx(ft,{asChild:!0,children:c.jsx("button",{type:"button",className:ne(At({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:G?xn:Ss,"aria-label":G?"Dock sidebar":"Float sidebar",children:G?c.jsx(ee.Dock,{className:"h-4 w-4"}):c.jsx(ee.PictureInPicture2,{className:"h-4 w-4"})})}),c.jsx(mt,{children:G?"Dock to sidebar":"Undock to floating window"})]}),c.jsxs(ht,{children:[c.jsx(ft,{asChild:!0,children:c.jsx("button",{type:"button",className:ne(At({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:G?bn:it,"aria-label":G?Me?"Maximize":"Minimize":"Close sidebar",children:G?Me?c.jsx(ee.Maximize2,{className:"h-4 w-4"}):c.jsx(ee.Minimize2,{className:"h-4 w-4"}):c.jsx(ee.X,{className:"h-4 w-4"})})}),c.jsx(mt,{children:G?Me?"Maximize window":"Minimize to header":"Close the chat"})]})]})]}),!Me&&c.jsxs(c.Fragment,{children:[M&&Je.length>0&&c.jsxs("div",{className:`border-b border-border ${ye?"flex flex-col flex-1":""}`,children:[c.jsxs("div",{className:"flex items-center justify-between px-3 py-1",children:[c.jsx("h3",{className:"text-xs font-semibold text-muted-foreground",children:"Recent chats"}),c.jsx(Te,{variant:"ghost",className:"h-auto px-2 py-1 text-xs text-muted-foreground hover:text-foreground",onClick:()=>{mn(!ye)},children:ye?"Show less":"View all"})]}),c.jsx("div",{className:`px-2 pb-2 space-y-0.5 ${ye?"flex-1 overflow-y-auto":""}`,children:Je.slice(0,ye?void 0:3).map(S=>c.jsxs("div",{className:"group relative",children:[c.jsxs(Lf,{type:"button",className:ne(At({variant:"ghost"}),"w-full justify-between h-auto py-1 px-3 font-normal active:scale-[0.99]"),onClick:()=>{_e(S.chatId||S._id),mn(!1)},children:[c.jsx("span",{className:"text-xs truncate",children:S.title}),c.jsx("div",{className:"ml-2 flex items-center",children:c.jsx("span",{className:"text-xs text-muted-foreground group-hover:hidden",children:jt(S.updatedAt)})})]}),c.jsx("button",{type:"button",className:"absolute right-2 top-1/2 -translate-y-1/2 h-6 w-6 p-0 hidden group-hover:flex items-center justify-center text-muted-foreground hover:text-foreground rounded-md hover:bg-accent transition-colors",onClick:W=>{W.stopPropagation(),Ze(S._id)},"aria-label":"Delete conversation",children:c.jsx(ee.X,{className:"h-3 w-3"})})]},S._id))})]}),c.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden relative",children:[c.jsx("div",{className:"flex-1 overflow-y-auto p-4 space-y-4 scroll-smooth",children:je.length===0?c.jsxs("div",{className:"flex flex-col items-center justify-center h-full",children:[o&&c.jsx("div",{className:"mb-6",children:o}),c.jsx("h3",{className:"text-lg font-semibold text-center mb-2",children:"How can I help you?"}),st.length>0&&c.jsx("div",{className:"mt-4 px-4 max-w-md mx-auto",children:c.jsxs("div",{className:"flex flex-wrap gap-2 justify-center",children:[($t?st:st.slice(0,10)).map(S=>c.jsxs(ht,{children:[c.jsx(ft,{asChild:!0,children:c.jsx(Ps,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>{Re(S.sampleUsage),St.current?.focus()},children:S.friendlyName})}),c.jsx(mt,{children:c.jsxs("div",{className:"max-w-xs",children:[c.jsx("p",{className:"font-medium",children:S.description}),c.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:[c.jsx("span",{className:"font-medium",children:"Example:"}),' "',S.sampleUsage,'"']}),S.paramCount>0&&c.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[c.jsx("span",{className:"font-medium",children:"Parameters:"})," ",S.params.join(", ")]})]})})]},S.name)),st.length>10&&!$t&&c.jsxs(ht,{children:[c.jsx(ft,{asChild:!0,children:c.jsxs(Ps,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>ct(!0),children:["+",st.length-10," more"]})}),c.jsx(mt,{children:c.jsxs("div",{className:"max-w-xs",children:[c.jsx("p",{className:"font-medium mb-2",children:"Additional tools:"}),c.jsx("div",{className:"space-y-1 max-h-64 overflow-y-auto pr-2",children:st.slice(10).map(S=>c.jsxs("div",{children:[c.jsxs("span",{className:"font-medium text-xs",children:[S.friendlyName,":"]}),c.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:S.description})]},S.name))}),c.jsx("p",{className:"text-xs text-muted-foreground mt-2 italic",children:"Click to show all tools"})]})})]}),$t&&st.length>10&&c.jsx(Ps,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>ct(!1),children:"Show less"})]})})]}):c.jsxs(c.Fragment,{children:[je.map(S=>{const _=S.parts.filter(U=>U.type==="text").map(U=>U.text).join("");let J=S.parts;S.role==="assistant"&&S.parts.some(fe=>fe.timestamp)&&(J=[...S.parts].sort((fe,te)=>{const Pe=fe.timestamp||0,he=te.timestamp||0;return Pe-he}));let H=[],Z=new Map,Ee=[],se,we=!0;if(S.role==="assistant"){const U=J.filter(he=>he.type==="text"&&he.text),fe=[],te=[];U.forEach(he=>{const{citations:Ie,citationMap:be,groupedCitations:ke,referencesText:g}=wo(he.text);H.push(...Ie),fe.push(be),ke&&te.push(...ke),g&&(se=g)}),fe.forEach(he=>{he.forEach((Ie,be)=>{Z.has(be)||Z.set(be,Ie)})}),Ee=Array.from(new Map(te.map(he=>[he.url,he])).values()).sort((he,Ie)=>(he.numbers[0]||0)-(Ie.numbers[0]||0)),we=!(De==="streaming"&&S.id===je.at(-1)?.id)}return c.jsx("div",{className:`${S.role==="user"?"flex justify-end":"w-full"}`,children:c.jsx("div",{className:`${S.role==="user"?"max-w-[85%] text-right":"w-full"}`,children:S.role==="user"?c.jsx($f,{initial:{opacity:0,filter:"blur(4px)"},animate:{opacity:1,filter:"blur(0px)"},transition:{duration:.3,ease:"easeOut"},className:"text-sm whitespace-pre-wrap inline-block bg-stone-100 dark:bg-stone-800 px-3 py-2 rounded-xl",children:_}):c.jsx("div",{className:"space-y-2",children:J.map((U,fe)=>{if(U.type?.startsWith("tool-")){const te=U.type?.replace("tool-","")||"",Pe=Ve.find(be=>be.name===te),he=U.state==="input-available",Ie=U.state==="output-available";if(he&&Ye.has(te),he){if(Ye.has(te))return null;const be=_s(U.input);return c.jsx(ns,{initial:{opacity:0,y:10,filter:"blur(4px)"},animate:{opacity:1,y:0,filter:"blur(0px)"},transition:{duration:.3,ease:"easeOut"},children:c.jsx(Ff,{toolName:te,description:Pe?.description||"",args:be,onApprove:async()=>{if(Ot.has(U.toolCallId))return;nt(g=>new Set(g).add(U.toolCallId));const ke=pn.get(te);if(ke)try{const g=await ke(...Object.values(be));rt({toolCallId:U.toolCallId,tool:te,output:g})}catch(g){rt({toolCallId:U.toolCallId,tool:te,output:`Error: ${g}`})}},onDeny:async()=>{Ot.has(U.toolCallId)||(nt(ke=>new Set(ke).add(U.toolCallId)),rt({toolCallId:U.toolCallId,tool:te,output:"User denied tool execution"}))}})},`${U.toolCallId}-${fe}`)}else if(Ie){const be=U.output==="User denied tool execution",ke=_s(U.input);return c.jsx(Bf,{toolName:te,args:ke,isDenied:be,isSafe:Ye.has(te)},`${U.toolCallId}-${fe}`)}return null}if(U.type==="text"&&U.text&&hn){const{processedText:te}=wo(U.text),be=!J.slice(fe+1).some(ke=>ke.type==="text"&&ke.text)&&we&&Z.size>0;return c.jsx(Qf,{text:te,citations:H,citationMap:Z,groupedCitations:be?Ee:void 0,referencesText:be?se:void 0,ResponseComponent:hn,className:"text-sm prose prose-sm dark:prose-invert max-w-none",showCitations:O,showReferences:be},`${S.id}-${fe}`)}return U.type==="reasoning"&&U.text?c.jsxs(ul,{className:"w-full",isStreaming:De==="streaming"&&fe===S.parts.length-1&&S.id===je.at(-1)?.id,children:[c.jsx(dl,{}),c.jsx(hl,{children:U.text})]},`${S.id}-${fe}`):null})})})},S.id)}),c.jsx("div",{ref:ze})]})}),Wn&&c.jsxs("div",{className:"px-4 py-2 bg-destructive/10 text-destructive text-xs",children:["Error: ",Wn.message]}),c.jsxs("div",{className:"p-4 border-t border-border relative overflow-visible",children:[c.jsx(rd,{mode:"wait",children:(De==="streaming"||De==="submitted")&&c.jsxs(ns,{initial:{opacity:0,filter:"blur(4px)",y:5},animate:{opacity:1,filter:"blur(0px)",y:0},exit:{opacity:0,filter:"blur(4px)",y:5},transition:{duration:.2,ease:"easeOut"},className:"absolute left-1/2 -translate-x-1/2 -top-6 flex items-center gap-1.5 bg-stone-100 dark:bg-stone-800 px-3 py-1.5 rounded-full shadow-lg border border-border z-50",children:[c.jsx(ns,{className:"w-2 h-2 bg-stone-400 dark:bg-stone-600",animate:{rotate:[0,0,90,90],borderRadius:["50%","30%","30%","50%"],scale:[.75,1,1,.75]},transition:{duration:2,repeat:1/0,ease:"easeInOut",times:[0,.4,.6,1]}}),c.jsx("p",{className:"text-xs text-muted-foreground",children:It})]})}),c.jsxs("form",{onSubmit:yn,className:"relative",children:[c.jsx(Mo,{ref:St,value:Tt,onChange:dt,placeholder:"Ask anything..",className:"w-full pr-12 resize-none border border-border rounded-xl px-4 py-3",minHeight:24,maxHeight:200,onKeyDown:S=>{S.key==="Enter"&&!S.shiftKey&&(S.preventDefault(),yn(S))}}),De==="streaming"||De==="submitted"?c.jsxs(ht,{children:[c.jsx(ft,{asChild:!0,children:c.jsx("button",{type:"button",className:ne(At({variant:"ghost",size:"icon"}),"absolute top-1/2 -translate-y-1/2 right-2 h-8 w-8"),onClick:Ft,children:c.jsx(ee.Square,{className:"h-4 w-4"})})}),c.jsxs(mt,{children:[c.jsx(si,{children:"Escape"})," to stop"]})]}):c.jsxs(ht,{children:[c.jsx(ft,{asChild:!0,children:c.jsx("button",{type:"submit",className:ne(At({variant:"ghost",size:"icon"}),"absolute top-1/2 -translate-y-1/2 right-2 h-8 w-8"),disabled:!Tt.trim(),children:c.jsx(ee.ArrowRight,{className:"h-4 w-4"})})}),c.jsxs(mt,{children:[c.jsx(si,{children:"Enter"})," to send"]})]})]})]})]}),c.jsxs("a",{href:"https://arcten.com",target:"_blank",rel:"noopener noreferrer",className:"group flex items-center justify-center gap-1.5 py-3 text-xs text-muted-foreground/40 hover:text-muted-foreground/60 transition-all",children:[c.jsx("span",{className:"whitespace-nowrap",children:"Powered by"}),c.jsx("div",{className:"w-4 h-2 bg-current rounded-t-full flex-shrink-0"}),c.jsx("span",{className:"whitespace-nowrap",children:"Arcten"})]})]})]})]}):c.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 h-full cursor-pointer",children:[c.jsx(ee.BotMessageSquare,{className:"h-5 w-5 text-stone-600 dark:text-stone-400"}),c.jsx("span",{className:"text-xs font-medium text-stone-600 dark:text-stone-400 [writing-mode:vertical-lr]",children:"AI agent"})]})})}):c.jsx("div",{className:"fixed right-0 top-0 h-screen w-96 flex items-center justify-center p-4 bg-stone-50 dark:bg-stone-900 border-l border-border",children:c.jsx("div",{className:"p-4 text-muted-foreground text-sm",children:"Loading..."})}):null}function um(e){return c.jsx(pl,{children:c.jsx(cm,{...e})})}exports.verifyToken=Rl.verifyToken;exports.ARCTEN_ORIGINAL_NAME=$e;exports.ArctenAgent=um;exports.SecureModalProvider=pl;exports.extractToolsMetadata=pr;exports.preserveToolName=Dl;exports.useAgent=Ao;exports.useSecureModal=ml;
|