@arcteninc/core 0.0.150 → 0.0.152

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 CHANGED
@@ -1,5 +1,5 @@
1
- "use strict";var pl=Object.create;var Jr=Object.defineProperty;var gl=Object.getOwnPropertyDescriptor;var yl=Object.getOwnPropertyNames;var xl=Object.getPrototypeOf,bl=Object.prototype.hasOwnProperty;var vl=(e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of yl(t))!bl.call(e,r)&&r!==n&&Jr(e,r,{get:()=>t[r],enumerable:!(s=gl(t,r))||s.enumerable});return e};var wl=(e,t,n)=>(n=e!=null?pl(xl(e)):{},vl(t||!e||!e.__esModule?Jr(n,"default",{value:e,enumerable:!0}):n,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react/jsx-runtime"),f=require("react"),te=require("lucide-react"),Sl=require("@ai-sdk/react"),Zr=require("ai"),bo=require("@radix-ui/react-slot"),vo=require("class-variance-authority"),Tl=require("clsx"),Cl=require("tailwind-merge"),jl=require("@radix-ui/react-tooltip"),Qr=require("@radix-ui/react-use-controllable-state"),Pl=require("@radix-ui/react-collapsible"),Al=require("react-dom"),El=require("@radix-ui/react-dialog"),Ml=require("./server.cjs");function us(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 _e=us(f),qt=us(jl),ur=us(Pl),Dt=us(El),Ve=Symbol.for("@arcteninc/core:originalName");function kl(e,t){return e[Ve]=t,e}function Nl(e,t,n,s){if(typeof e!="function")return null;const r=e[Ve];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[Ve]=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[Ve]=i.name,{fn:e,meta:i}}else if(i=Object.values(t).find(l=>!n.has(l.name)),i)return e[Ve]=i.name,{fn:e,meta:i};return null}function dr(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=Nl(o,n,r,s);if(!i){const a=o.name,u=o[Ve]||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 Dl={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 wn(e){for(const[t,n]of Object.entries(Dl))if(t!=="text"){for(const s of n)if(s.test(e))return t}return null}function Rl(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 Vl(e,t,n){return t.length>0}function Il(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=Ol(s[i]),d={name:i,type:Ll(l||wn(i)||"text"),label:wo(i),placeholder:$l(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:Vl(e,t),fields:r,title:Fl(e),description:Bl(e,r.length)}}function Ol(e){if(e!=null){if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return String(e)}}function Ll(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 wo(e){return e.replace(/([A-Z])/g," $1").replace(/_/g," ").trim().toLowerCase().split(" ").map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" ")}function $l(e,t){return t?Rl(t,e).placeholder:`Enter ${wo(e).toLowerCase()}...`}function Fl(e){return e.replace(/([A-Z])/g," $1").trim().toLowerCase().split(" ").map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" ")}function Bl(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 Tn(e){if(typeof e=="string")try{const t=JSON.parse(e);return Tn(t)}catch{return e}if(Array.isArray(e))return e.map(Tn);if(e&&typeof e=="object"){const t={};for(const[n,s]of Object.entries(e))t[n]=Tn(s);return t}return e}function Ul(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 zl(e){if(typeof e=="string"){try{const t=JSON.parse(e);if(t&&typeof t=="object"&&!Array.isArray(t))return Tn(t)}catch{}return{}}return e&&typeof e=="object"&&!Array.isArray(e)?Tn(e):{}}const Zn="__secureOutput",Qn="[hidden for privacy]";function _l(e,t){if(!e||e.length===0)return t;const n=new Map;t.forEach(o=>{const i=o[Ve]||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[Ve]||o.name;i&&!s.has(i)&&(console.log(`[useAgent] Allowing client-only tool (forward compatible): ${i}`),r.push(o))}),r}function Xl(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 Wl(e){return e.replace(/\[(\w+)\]/g,".$1").split(".").map(t=>t.trim()).filter(Boolean)}function ql(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 Kl(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 Bs(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 So(e,t=""){const n={};return e&&typeof e=="object"?Object.entries(e).forEach(([s,r])=>{const o=t?`${t}.${s}`:s;n[o]=Bs(r),r&&typeof r=="object"&&Object.assign(n,So(r,o))}):t&&(n[t]=Bs(e)),n}function Gl(e){if(e===void 0||e===!1)return;if(e===!0)return{strategy:"full",fields:[],placeholder:Qn,includeFieldStatus:!1,preserve:[]};if(Array.isArray(e))return{strategy:"fields",fields:e,placeholder:Qn,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??Qn,includeFieldStatus:e.includeFieldStatus??!1,preserve:e.preserve??[]}}function Yl(e){if(!e)return{};const t={};for(const[n,s]of Object.entries(e)){const r=Gl(s);r&&(t[n]=r)}return t}function To(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=So(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[Zn]=r,l}if(n.fields.includes("*"))return To(e,t,{...n,strategy:"full",fields:[]});if(typeof t!="object"||t===null)return{value:s,[Zn]:{...r,redactedFields:n.fields}};const o=Xl(t),i=[],a={};return n.fields.forEach(l=>{const u=Wl(l);if(u.length===0)return;const d=ql(o,u),h=Bs(d);a[l]=h,Kl(o,u,s)&&i.push(l)}),r.redactedFields=i,n.includeFieldStatus&&(r.fieldStatus=a),o[Zn]=r,o}function Co({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:S="",agentId:w,agentName:T,projectId:v,enableRemoteConfig:M,remoteConfigUrl:E,initialMessages:$=[],conversationId:D,state:I,onStateChange:N,allowStateEdits:j=!0,onToolCall:O,onFinish:A,sources:k,ragConfig:F,ragFilters:V,secureInputHandler:B}={}){const X=e.replace(/\/+$/,""),[Y,K]=f.useState(null),[ie,ye]=f.useState(!1),[We,pt]=f.useState(null),Qe=f.useMemo(()=>{const y=k||[],g=Y?.config?.sources||[];return[...new Set([...y,...g])]},[k,Y]),G=f.useMemo(()=>F!==void 0?F:V?{enabled:!0,filters:V}:Qe&&Qe.length>0?{enabled:!0,organizationId:Qe[0],autoExecute:!0,filters:void 0}:{enabled:!1},[Qe,F,V]),Rt=f.useMemo(()=>M===!1?!1:!!v,[v,M]);f.useEffect(()=>{if(!Rt||!oe.current)return;(async()=>{ye(!0),pt(null);try{const x=`${E||X.replace("/chat","").replace(/\/$/,"")}/convex/api/query`,b=await fetch(x,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${oe.current}`},body:JSON.stringify({path:"agents:getConfigForClient",args:{projectId:v,agentName:T,agentId:w},format:"json"})});if(!b.ok){if(b.status===404){console.warn("[useAgent] Remote config endpoint not found (404), using local tools only"),K(null);return}const R=await b.text().catch(()=>"Unknown error");throw new Error(`Failed to fetch remote config: ${b.status} ${R}`)}const P=await b.json();K(P?.value||null),console.log("[useAgent] Remote config loaded successfully:",P?.value)}catch(g){console.error("[useAgent] Failed to fetch remote config:",g);const x=g instanceof Error?g:new Error(String(g));pt(x),K(null)}finally{ye(!1)}})()},[Rt,v,T,w,X,E]);const Ee=f.useMemo(()=>{const y={};if(u)for(const[g,x]of Object.entries(u))if(y[g]={},Array.isArray(x))for(const b of x){const P=wn(b);y[g][b]=P||"text"}else for(const[b,P]of Object.entries(x))y[g][b]=P;if(l){for(const[g,x]of Object.entries(l))if(x&&typeof x=="object"&&"sensitiveParams"in x){y[g]||(y[g]={});const b=x.sensitiveParams;if(Array.isArray(b))for(const P of b){const R=wn(P);y[g][P]=R||"text"}else if(b&&typeof b=="object")for(const[P,R]of Object.entries(b))y[g][P]=R}}return y},[u,l,h]),gt=f.useMemo(()=>Yl(d),[d]),je=f.useCallback((y,g)=>{const x=gt[y];if(!x)return g;try{return To(y,g,x)}catch(b){return console.error(`[useAgent] Failed to redact output for ${y}:`,b),{value:Qn,[Zn]:{tool:y,redacted:!0,error:String(b)}}}},[gt]),[Le,ln]=f.useState(n||null),oe=f.useRef(n||null),[cn,yt]=f.useState(null),[un,Fn]=f.useState(null),$e=f.useRef(null),[xt,bt]=f.useState([]),[ke,dn]=f.useState(D||(typeof window<"u"?crypto.randomUUID():null)),[ps,Vt]=f.useState(!1),[Bn,vt]=f.useState(new Set),[it,gs]=f.useState(new Map),[Un,qe]=f.useState(new Map),[ys,zn]=f.useState(new Map),[It,hn]=f.useState(new Map),le=I!==void 0,[fn,Fe]=f.useState({}),we=f.useRef({}),Ke=le?I||{}:fn;le&&I?we.current=I:le||(we.current=fn);const[Be,Ot]=f.useState(!1),[wt,St]=f.useState(null),mn=f.useRef(!1),Ne=f.useCallback(async(y,g=3)=>{if(!ke||!oe.current)return;const x=async()=>{const P=`${X.replace("/chat","").replace(/\/$/,"")}/convex/api/mutation`,R=await fetch(P,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${oe.current}`},body:JSON.stringify({path:"conversations:mergeStateByChatId",args:{chatId:ke,updates:y},format:"json"})});if(!R.ok){if(R.status===404){console.warn("[useAgent] Convex API endpoint not available (404), state changes will not be persisted");return}const L=await R.text().catch(()=>"Unknown error");throw new Error(`Failed to sync conversation state: ${R.status} ${L}`)}};for(let b=0;b<g;b++)try{await x(),St(null);return}catch(P){if(b===g-1){const L=P instanceof Error?P:new Error(String(P));throw St(L),console.error("Failed to sync state to Convex after retries:",P),L}await new Promise(L=>setTimeout(L,Math.pow(2,b)*100))}},[ke,X,oe]),Tt=f.useMemo(()=>function(){return we.current},[]),xe=f.useMemo(()=>async function(g){const x={...we.current,...g};we.current=x,le||Fe(x),N&&N(x);try{await Ne(g)}catch(b){throw b}},[Ne,N,le]);f.useEffect(()=>{le&&I&&(we.current=I)},[le,I]);const _n=f.useCallback(y=>B?B.showSecureModal(y):new Promise(g=>{gs(x=>new Map(x).set(y.id,y)),qe(x=>new Map(x).set(y.id,g))}),[B]),Lt=f.useCallback((y,g)=>{if(B)return;const x=Un.get(y);x&&(x(g),gs(b=>{const P=new Map(b);return P.delete(y),P}),qe(b=>{const P=new Map(b);return P.delete(y),P}))},[Un,B]),et=f.useCallback(y=>B?B.showSecureForm(y):new Promise(g=>{zn(x=>new Map(x).set(y.id,y)),hn(x=>new Map(x).set(y.id,g))}),[B]),Yr=f.useCallback((y,g)=>{if(B)return;const x=It.get(y);x&&(x(g),zn(b=>{const P=new Map(b);return P.delete(y),P}),hn(b=>{const P=new Map(b);return P.delete(y),P}))},[It,B]),pn=f.useCallback((y,g)=>{const x=Ee[y]||{},b=Object.keys(x).length>0;if(h){const P=Object.keys(g).filter(R=>wn(R)!==null);return b||P.length>0}return b},[Ee,h]),gn=f.useCallback((y,g)=>{const b={...Ee[y]||{}};if(h){for(const R of Object.keys(g))if(!(R in b)){const L=wn(R);L&&(b[R]=L)}}const P=Object.entries(b).filter(([R])=>Object.prototype.hasOwnProperty.call(g,R));return P.length>0?Object.fromEntries(P):b},[Ee,h]),Ge=f.useMemo(()=>G?.enabled?async function(g,x=20,b){const P={...G.filters,...b};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:g,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),ee=[];for(const q of ae)q?.candidates&&ee.push(...q.candidates);ee.sort((q,re)=>{const Je=q.scores?.rerank||q.scores?.dense||0;return(re.scores?.rerank||re.scores?.dense||0)-Je});const be=ee.slice(0,x).map((q,re)=>{const Je=q.citation||q.url;return{rank:re+1,doc_id:q.doc_id,block_id:q.block_id,url:q.url,citation:Je,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:g,total:ee.length,results:be,summary:`Found ${ee.length} relevant results across ${k.length} source(s) for "${g}". Top result: ${be[0]?.title||"N/A"}`}}const R=G.organizationId&&G.organizationId!=="default"?G.organizationId:k&&k.length>0?k[0]:void 0;try{const L={q:g,k:Math.min(x,100)};R&&(L.organizationId=R),Object.keys(P).length>0&&(L.filters=P);const ae={"Content-Type":"application/json"};oe.current&&(ae.Authorization=`Bearer ${oe.current}`);const ee=await fetch(`${X}/search`,{method:"POST",headers:ae,body:JSON.stringify(L)});if(!ee.ok){const re=await ee.text();return{success:!1,error:`Search failed: ${ee.status} ${re}`}}const be=await ee.json(),q=be.candidates.map((re,Je)=>{const bn=re.citation||re.url;return{rank:Je+1,doc_id:re.doc_id,block_id:re.block_id,url:re.url,citation:bn,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:be.query,total:be.total,results:q,summary:`Found ${be.total} relevant results for "${g}". 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]),ot=f.useMemo(()=>G?.enabled?async function(g,x){const b=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 R=await fetch(`${X}/fetch`,{method:"POST",headers:P,body:JSON.stringify({doc_id:g,block_ids:x,...b?{organizationId:b}:{}})});if(!R.ok){const ae=await R.text();return{success:!1,error:`Fetch failed: ${R.status} ${ae}`}}const L=await R.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||g}`}}catch(P){return{success:!1,error:P instanceof Error?P.message:"Unknown error occurred"}}}:null,[G,X,oe]),$t=f.useMemo(()=>{if(Y&&Y.config?.tools){const y=_l(Y.config.tools,o);return console.log("[useAgent] Merged remote config:",{remoteToolCount:Y.config.tools.length,localToolCount:o.length,mergedToolCount:y.length}),y}return o},[Y,o]),Ue=Y?.enableStateTools??!0,Ye=Y?.enableRagTools??G?.enabled??!1,Xn=f.useMemo(()=>{const y=[...$t,...i];return Ue&&(y.push(Tt),(!le||j)&&y.push(xe)),Ye&&(Ge&&y.push(Ge),ot&&y.push(ot)),y},[$t,i,Tt,xe,Ge,ot,Ue,Ye,le,j]),Wn=f.useMemo(()=>[...$t,...i],[$t,i]),tt=f.useMemo(()=>dr(Wn,l),[Wn,l]),Ct=f.useMemo(()=>{const y=new Map,g=new Map(tt.map(x=>[x.name,x]));return y.set("getState",Tt),(!le||j)&&y.set("setState",xe),G?.enabled&&(Ge&&y.set("searchDocs",Ge),ot&&y.set("fetchDocContent",ot)),Xn.forEach(x=>{if(x===Tt||x===xe||x===Ge||x===ot)return;const b=x[Ve];if(b){const R=g.get(b);if(R){y.set(R.name,x);return}}const P=tt.find(R=>R.name===x.name);P&&y.set(P.name,x)}),y},[Xn,tt,Tt,xe,Ge,ot,G,le,j]),yn=f.useMemo(()=>new Set(tt.map(y=>y.name)),[tt]),qn=f.useMemo(()=>{const y=[];Ue&&(y.push({name:"getState",description:"Get the current agent state. Returns IDs, workflow state, checklists, and other persistent data.",jsonSchema:{type:"object",properties:{},required:[]}}),(!le||j)&&y.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 g=[];Ye&&g.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(b=>{const P={},R=[];b.parameters&&b.parameters.forEach(L=>{P[L.name]={type:L.type||"string",description:L.description},L.required&&R.push(L.name)}),x.push({name:`workflow_${b.name.replace(/\s+/g,"_").toLowerCase()}`,description:b.description||`Execute the "${b.name}" workflow. ${b.contentPlaintext?.slice(0,200)||""}`,jsonSchema:{type:"object",properties:P,required:R},_workflow:b})}),[...tt,...y,...g,...x]},[tt,Ue,Ye,le,j,Y]),at=f.useMemo(()=>qn.filter(y=>y.name==="getState"?Ue:y.name==="setState"?Ue&&(!le||j):y.name==="searchDocs"||y.name==="fetchDocContent"?Ye:y.name.startsWith("workflow_")?!0:yn.has(y.name)),[qn,yn,Ue,Ye,le,j]),Ft=f.useMemo(()=>{const y=new Set;return Ue&&(y.add("getState"),y.add("setState")),Ye&&G?.autoExecute!==!1&&(y.add("searchDocs"),y.add("fetchDocContent")),Y?.config?.tools?Y.config.tools.forEach(g=>{g.isEnabled&&!g.requiresApproval&&y.add(g.name)}):(i.forEach(g=>{for(const[x,b]of Ct.entries())if(b===g){y.add(x);break}}),a&&Array.isArray(a)&&a.forEach(g=>{typeof g=="string"&&y.add(g)})),Y?.config?.workflows&&Y.config.workflows.forEach(g=>{const x=`workflow_${g.name.replace(/\s+/g,"_").toLowerCase()}`;g.requiresApproval||y.add(x)}),y},[Y,i,a,Ct,Ue,Ye,G]);f.useEffect(()=>s||n?void 0:((async()=>{try{const g=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:r})});if(!g.ok)throw new Error("Failed to fetch token");const x=await g.json();ln(x.clientToken),oe.current=x.clientToken,Fn(x.expiresAt),yt(null)}catch(g){console.error("[useAgent] Token fetch failed:",g),yt(g instanceof Error?g.message:"Failed to fetch token")}})(),()=>{$e.current&&clearTimeout($e.current)}),[t,JSON.stringify(r),s,n]),f.useEffect(()=>{if(!un||s||n)return;$e.current&&clearTimeout($e.current);const y=Math.floor(Date.now()/1e3),g=un-y,b=Math.max(0,g-5);return $e.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 R=await P.json();ln(R.clientToken),oe.current=R.clientToken,Fn(R.expiresAt),yt(null)}catch(P){console.error("[useAgent] Token refresh failed:",P),yt(P instanceof Error?P.message:"Failed to refresh token")}},b*1e3),()=>{$e.current&&clearTimeout($e.current)}},[un,t,JSON.stringify(r),s,n]);const xs=async(y,g={})=>{const x=g.headers?new Headers(g.headers):new Headers;x.delete("user-agent"),x.delete("User-Agent"),console.log("[useAgent] Making request to:",y),console.log("[useAgent] Method:",g.method||"GET"),console.log("[useAgent] Has Authorization header:",x.has("Authorization")),console.log("[useAgent] Client token available:",!!oe.current);try{const b=await fetch(y,{...g,headers:x});if(!b.ok){console.error("[useAgent] Request failed:",b.status,b.statusText);const P=await b.text().catch(()=>"Unable to read error response");console.error("[useAgent] Error response:",P)}return b}catch(b){throw console.error("[useAgent] Fetch error:",b),b}},xn=`${X}/chat`;console.log("[useAgent] Chat API URL:",xn);const{messages:He,sendMessage:C,status:_,error:z,stop:Z,addToolResult:H,setMessages:J}=Sl.useChat({id:ke||void 0,messages:$,transport:new Zr.DefaultChatTransport({api:xn,fetch:xs,headers:()=>{const y={};return oe.current?(y.Authorization=`Bearer ${oe.current}`,console.log("[useAgent] Adding Authorization header with token")):console.warn("[useAgent] No client token available - request may fail"),y},body:()=>{console.log("[ArctenAgent] body() agentName =",T);const y=at.map(b=>({name:b.name,description:b.description,inputSchema:b.jsonSchema})),g=y.filter(b=>b.name==="getState"||b.name==="setState").map(b=>b.name),x=y.filter(b=>b.name==="searchDocs"||b.name==="fetchDocContent").map(b=>b.name);return g.length>0&&console.log("[useAgent] State tools included in tools list sent to AI SDK:",g),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:y,...w&&{agentId:w},...T&&{agentName:T},state:we.current,...V&&{ragFilters:V}}}}),sendAutomaticallyWhen:Zr.lastAssistantMessageIsCompleteWithToolCalls}),ge=f.useCallback((y,g,x)=>{const b=je(y,x);H({toolCallId:g,tool:y,output:b})},[H,je]);f.useEffect(()=>{He.forEach(y=>{y.role==="assistant"&&y.parts.forEach(g=>{if(!g.type?.startsWith("tool-")||g.state!=="input-available")return;const x=g.type.replace("tool-",""),b=g.toolCallId;if(Bn.has(b))return;vt(R=>new Set(R).add(b));const P=zl(g.input);if(pn(x,P)){const R=gn(x,P),L=Object.entries(R).filter(([q])=>P[q]!==void 0),ae=L.length>0?Object.fromEntries(L):R,ee=Object.keys(P),be=Ul(P,ae);(async()=>{try{const q=Il(x,ee,ae,P),re={id:`${b}-form`,toolName:x,toolCallId:b,title:q.title,description:q.description,fields:q.fields},Je=await et(re);if(Je===null){ge(x,b,"User cancelled secure input");return}const bn={...be,...Je},bs=Ct.get(x);if(!bs)throw new Error(`Tool ${x} not found`);let vs;const ws=at.find(Hr=>Hr.name===x);if(ws&&ws.jsonSchema?.properties){const fl=Object.keys(ws.jsonSchema.properties).map(ml=>bn[ml]);vs=await bs(...fl)}else vs=await bs(...Object.values(bn));ge(x,b,vs)}catch(q){console.error(`[useAgent] Error executing tool with secure input ${x}:`,q),ge(x,b,`Error: ${q}`)}})();return}if(x.startsWith("workflow_")&&Ft.has(x)){(async()=>{try{const L=at.find(ee=>ee.name===x)?._workflow;if(!L)throw new Error(`Workflow metadata not found for ${x}`);let ae;if(L.webhook?.url){let ee=P;if(L.webhook.bodyTemplate){let q=L.webhook.bodyTemplate;Object.entries(P).forEach(([re,Je])=>{q=q.replace(new RegExp(`\\{\\{${re}\\}\\}`,"g"),String(Je))}),ee=JSON.parse(q)}const be=await fetch(L.webhook.url,{method:L.webhook.method||"POST",headers:{"Content-Type":"application/json",...L.webhook.headers||{}},body:JSON.stringify(ee)});if(be.ok)ae={success:!0,data:await be.json().catch(()=>({success:!0}))};else{const q=await be.text();ae={success:!1,error:`Webhook failed: ${be.status} ${q}`}}}else ae={success:!0,message:`Workflow "${L.name}" acknowledged. Follow the workflow instructions to proceed.`,instructions:L.contentPlaintext};ge(x,b,ae)}catch(R){console.error(`[useAgent] Error executing workflow ${x}:`,R),ge(x,b,`Error: ${R}`)}})();return}if(Ft.has(x)&&!pn(x,P)){const R=Ct.get(x);R?(async()=>{try{const L=at.find(ee=>ee.name===x);let ae;if(L&&L.jsonSchema?.properties){const be=Object.keys(L.jsonSchema.properties).map(q=>P[q]);ae=await R(...be)}else if(x==="getState")ae=R();else if(x==="setState"){const ee=P.updates||P;ae=await R(ee)}else ae=await R(...Object.values(P));ge(x,b,ae)}catch(L){console.error(`[useAgent] Error executing tool ${x}:`,L),ge(x,b,`Error: ${L}`)}})():console.warn(`[useAgent] Tool ${x} not found in toolsMap`)}else x.startsWith("workflow_")&&O?O({toolCall:{toolCallId:b,toolName:x,args:P}}):O&&O({toolCall:{toolCallId:b,toolName:x,args:P}})})})},[He,Ft,Ct,O,ge,Bn,xe,at,pn,gn,_n]),f.useEffect(()=>{if(_==="ready"&&He.length>0&&A){const y=He[He.length-1];y&&y.role==="assistant"&&A({message:y,messages:He,isAbort:!1,isDisconnect:!1,isError:!!z})}},[_,He,z,A]);async function se(){if(!(!r?.id||!Le)){Vt(!0);try{const g=await(await fetch(`${X}/conversations`,{headers:{Authorization:`Bearer ${Le}`}})).json();bt(g.conversations||[])}catch(y){console.error("Failed to fetch conversations:",y)}finally{Vt(!1)}}}f.useEffect(()=>{r?.id&&Le&&se()},[JSON.stringify(r),Le,X]),f.useEffect(()=>{if(!ke||!oe.current)return;(async()=>{Ot(!0),St(null);try{const g=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:ke},format:"json"})});if(!g.ok){const P=await g.text().catch(()=>"Unknown error");throw new Error(`Failed to fetch conversation state: ${g.status} ${P}`)}const b=(await g.json())?.value||{};we.current=b,le||Fe(b),N&&N(b),mn.current=!0}catch(g){console.error("Failed to fetch state:",g);const x=g instanceof Error?g:new Error(String(g));St(x),mn.current||(we.current={},le?N&&N({}):(Fe({}),N&&N({})),mn.current=!0)}finally{Ot(!1)}})()},[ke,X,le,N]);async function Se(y){dn(y),Vt(!0);try{const g=await fetch(`${X}/conversations/${y}/messages`,{headers:{Authorization:`Bearer ${oe.current}`}});if(!g.ok)throw new Error(`Failed to fetch messages: ${g.statusText}`);const b=(await g.json()).messages||[];J(b)}catch(g){console.error("Failed to load conversation messages:",g)}finally{Vt(!1)}}async function W(y){if(Le)try{await fetch(`${X}/conversations/${y}`,{method:"DELETE",headers:{Authorization:`Bearer ${Le}`}}),bt(xt.filter(g=>g._id!==y)),y===ke&&he()}catch(g){console.error("Failed to delete conversation:",g)}}function he(){const y=crypto.randomUUID();dn(y),J([]),vt(new Set),we.current={},le?N&&N({}):(Fe({}),N&&N({})),mn.current=!1}function Q(y){const g=y.tool||"unknown-tool",x=je(g,y.output);H({toolCallId:y.toolCallId,tool:g,output:x})}async function Pe(y,g,x){if(!g.startsWith("workflow_"))throw new Error(`${g} is not a workflow tool`);try{const P=at.find(L=>L.name===g)?._workflow;if(!P)throw new Error(`Workflow metadata not found for ${g}`);let R;if(P.webhook?.url){let L=x;if(P.webhook.bodyTemplate){let ee=P.webhook.bodyTemplate;Object.entries(x).forEach(([be,q])=>{ee=ee.replace(new RegExp(`\\{\\{${be}\\}\\}`,"g"),String(q))}),L=JSON.parse(ee)}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)R={success:!0,data:await ae.json().catch(()=>({success:!0}))};else{const ee=await ae.text();R={success:!1,error:`Webhook failed: ${ae.status} ${ee}`}}}else R={success:!0,message:`Workflow "${P.name}" acknowledged. Follow the workflow instructions to proceed.`,instructions:P.contentPlaintext};return Q({toolCallId:y,tool:g,output:R}),R}catch(b){const P={success:!1,error:String(b)};throw Q({toolCallId:y,tool:g,output:P}),b}}async function fe(y){const g={...we.current,...y};we.current=g,le||Fe(g),N&&N(g);try{await Ne(y)}catch(x){throw x}}return{id:ke,messages:He,status:_,error:z,sendMessage:C,stop:Z,addToolOutput:Q,executeWorkflowTool:Pe,setMessages:J,conversations:xt,loadConversation:Se,deleteConversation:W,startNewConversation:he,isLoadingConversations:ps,clientToken:Le,tokenError:cn,state:Ke,setState:fe,isStateLoading:Be,stateError:wt,pendingSecureInputs:Array.from(it.values()),completeSecureInput:Lt,pendingSecureForms:Array.from(ys.values()),completeSecureForm:Yr,safeToolNames:Ft}}function ne(...e){return Cl.twMerge(Tl.clsx(e))}const Pt=vo.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"}}),Ce=_e.forwardRef(({className:e,variant:t,size:n,asChild:s=!1,...r},o)=>{const i=s?bo.Slot:"button";return c.jsx(i,{ref:o,"data-slot":"button",className:ne(Pt({variant:t,size:n,className:e})),...r})});Ce.displayName="Button";const Hl=vo.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 Ss({className:e,variant:t,asChild:n=!1,...s}){const r=n?bo.Slot:"span";return c.jsx(r,{"data-slot":"badge",className:ne(Hl({variant:t}),e),...s})}const Jl=({textAreaRef:e,triggerAutoSize:t,maxHeight:n=Number.MAX_SAFE_INTEGER,minHeight:s=0})=>{const[r,o]=_e.useState(!0);_e.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])},jo=_e.forwardRef(({maxHeight:e=Number.MAX_SAFE_INTEGER,minHeight:t=52,className:n,onChange:s,value:r,...o},i)=>{const a=_e.useRef(null),[l,u]=_e.useState("");return Jl({textAreaRef:a,triggerAutoSize:l,maxHeight:e,minHeight:t}),f.useImperativeHandle(i,()=>({textArea:a.current,focus:()=>a?.current?.focus(),maxHeight:e,minHeight:t})),_e.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)}})});jo.displayName="AutosizeTextarea";function Zl({delayDuration:e=0,...t}){return c.jsx(qt.Provider,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function lt({...e}){return c.jsx(Zl,{children:c.jsx(qt.Root,{"data-slot":"tooltip",...e})})}function ct({...e}){return c.jsx(qt.Trigger,{"data-slot":"tooltip-trigger",...e})}function ut({className:e,sideOffset:t=0,children:n,...s}){return c.jsx(qt.Portal,{children:c.jsxs(qt.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(qt.Arrow,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}function ei({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 hr=f.createContext({});function fr(e){const t=f.useRef(null);return t.current===null&&(t.current=e()),t.current}const mr=typeof window<"u",Po=mr?f.useLayoutEffect:f.useEffect,ds=f.createContext(null);function pr(e,t){e.indexOf(t)===-1&&e.push(t)}function gr(e,t){const n=e.indexOf(t);n>-1&&e.splice(n,1)}const nt=(e,t,n)=>n>t?t:n<e?e:n;function Us(e,t){return t?`${e}. For more information and steps for solving, visit https://motion.dev/troubleshooting/${t}`:e}let Ht=()=>{},st=()=>{};process.env.NODE_ENV!=="production"&&(Ht=(e,t,n)=>{!e&&typeof console<"u"&&console.warn(Us(t,n))},st=(e,t,n)=>{if(!e)throw new Error(Us(t,n))});const rt={},Ao=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e);function Eo(e){return typeof e=="object"&&e!==null}const Mo=e=>/^0[^.\s]+$/u.test(e);function yr(e){let t;return()=>(t===void 0&&(t=e()),t)}const Oe=e=>e,Ql=(e,t)=>n=>t(e(n)),In=(...e)=>e.reduce(Ql),Mn=(e,t,n)=>{const s=t-e;return s===0?1:(n-e)/s};class xr{constructor(){this.subscriptions=[]}add(t){return pr(this.subscriptions,t),()=>gr(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 Xe=e=>e*1e3,Ie=e=>e/1e3;function ko(e,t){return t?e*(1e3/t):0}const ti=new Set;function br(e,t,n){e||ti.has(t)||(console.warn(Us(t,n)),ti.add(t))}const No=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,ec=1e-7,tc=12;function nc(e,t,n,s,r){let o,i,a=0;do i=t+(n-t)/2,o=No(i,s,r)-e,o>0?n=i:t=i;while(Math.abs(o)>ec&&++a<tc);return i}function On(e,t,n,s){if(e===t&&n===s)return Oe;const r=o=>nc(o,0,1,e,n);return o=>o===0||o===1?o:No(r(o),t,s)}const Do=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,Ro=e=>t=>1-e(1-t),Vo=On(.33,1.53,.69,.99),vr=Ro(Vo),Io=Do(vr),Oo=e=>(e*=2)<1?.5*vr(e):.5*(2-Math.pow(2,-10*(e-1))),wr=e=>1-Math.sin(Math.acos(e)),Lo=Ro(wr),$o=Do(wr),sc=On(.42,0,1,1),rc=On(0,0,.58,1),Fo=On(.42,0,.58,1),ic=e=>Array.isArray(e)&&typeof e[0]!="number",Bo=e=>Array.isArray(e)&&typeof e[0]=="number",ni={linear:Oe,easeIn:sc,easeInOut:Fo,easeOut:rc,circIn:wr,circInOut:$o,circOut:Lo,backIn:vr,backInOut:Io,backOut:Vo,anticipate:Oo},oc=e=>typeof e=="string",si=e=>{if(Bo(e)){st(e.length===4,"Cubic bezier arrays must contain four numerical values.","cubic-bezier-length");const[t,n,s,r]=e;return On(t,n,s,r)}else if(oc(e))return st(ni[e]!==void 0,`Invalid easing type '${e}'`,"invalid-easing-type"),ni[e];return e},Kn=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function ac(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 S=m&&r?n:s;return h&&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 lc=40;function Uo(e,t){let n=!1,s=!0;const r={delta:0,timestamp:0,isProcessing:!1},o=()=>n=!0,i=Kn.reduce((E,$)=>(E[$]=ac(o),E),{}),{setup:a,read:l,resolveKeyframes:u,preUpdate:d,update:h,preRender:m,render:p,postRender:S}=i,w=()=>{const E=rt.useManualTiming?r.timestamp:performance.now();n=!1,rt.useManualTiming||(r.delta=s?1e3/60:Math.max(Math.min(E-r.timestamp,lc),1)),r.timestamp=E,r.isProcessing=!0,a.process(r),l.process(r),u.process(r),d.process(r),h.process(r),m.process(r),p.process(r),S.process(r),r.isProcessing=!1,n&&t&&(s=!1,e(w))},T=()=>{n=!0,s=!0,r.isProcessing||e(w)};return{schedule:Kn.reduce((E,$)=>{const D=i[$];return E[$]=(I,N=!1,j=!1)=>(n||T(),D.schedule(I,N,j)),E},{}),cancel:E=>{for(let $=0;$<Kn.length;$++)i[Kn[$]].cancel(E)},state:r,steps:i}}const{schedule:ce,cancel:ht,state:ve,steps:Ts}=Uo(typeof requestAnimationFrame<"u"?requestAnimationFrame:Oe,!0);let es;function cc(){es=void 0}const Me={now:()=>(es===void 0&&Me.set(ve.isProcessing||rt.useManualTiming?ve.timestamp:performance.now()),es),set:e=>{es=e,queueMicrotask(cc)}},zo=e=>t=>typeof t=="string"&&t.startsWith(e),Sr=zo("--"),uc=zo("var(--"),Tr=e=>uc(e)?dc.test(e.split("/*")[0].trim()):!1,dc=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu,Jt={test:e=>typeof e=="number",parse:parseFloat,transform:e=>e},kn={...Jt,transform:e=>nt(0,1,e)},Gn={...Jt,default:1},Cn=e=>Math.round(e*1e5)/1e5,Cr=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function hc(e){return e==null}const fc=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,jr=(e,t)=>n=>!!(typeof n=="string"&&fc.test(n)&&n.startsWith(e)||t&&!hc(n)&&Object.prototype.hasOwnProperty.call(n,t)),_o=(e,t,n)=>s=>{if(typeof s!="string")return s;const[r,o,i,a]=s.match(Cr);return{[e]:parseFloat(r),[t]:parseFloat(o),[n]:parseFloat(i),alpha:a!==void 0?parseFloat(a):1}},mc=e=>nt(0,255,e),Cs={...Jt,transform:e=>Math.round(mc(e))},Et={test:jr("rgb","red"),parse:_o("red","green","blue"),transform:({red:e,green:t,blue:n,alpha:s=1})=>"rgba("+Cs.transform(e)+", "+Cs.transform(t)+", "+Cs.transform(n)+", "+Cn(kn.transform(s))+")"};function pc(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 zs={test:jr("#"),parse:pc,transform:Et.transform},Ln=e=>({test:t=>typeof t=="string"&&t.endsWith(e)&&t.split(" ").length===1,parse:parseFloat,transform:t=>`${t}${e}`}),dt=Ln("deg"),Ze=Ln("%"),U=Ln("px"),gc=Ln("vh"),yc=Ln("vw"),ri={...Ze,parse:e=>Ze.parse(e)/100,transform:e=>Ze.transform(e*100)},Bt={test:jr("hsl","hue"),parse:_o("hue","saturation","lightness"),transform:({hue:e,saturation:t,lightness:n,alpha:s=1})=>"hsla("+Math.round(e)+", "+Ze.transform(Cn(t))+", "+Ze.transform(Cn(n))+", "+Cn(kn.transform(s))+")"},pe={test:e=>Et.test(e)||zs.test(e)||Bt.test(e),parse:e=>Et.test(e)?Et.parse(e):Bt.test(e)?Bt.parse(e):zs.parse(e),transform:e=>typeof e=="string"?e:e.hasOwnProperty("red")?Et.transform(e):Bt.transform(e),getAnimatableNone:e=>{const t=pe.parse(e);return t.alpha=0,pe.transform(t)}},xc=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function bc(e){return isNaN(e)&&typeof e=="string"&&(e.match(Cr)?.length||0)+(e.match(xc)?.length||0)>0}const Xo="number",Wo="color",vc="var",wc="var(",ii="${}",Sc=/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 Nn(e){const t=e.toString(),n=[],s={color:[],number:[],var:[]},r=[];let o=0;const a=t.replace(Sc,l=>(pe.test(l)?(s.color.push(o),r.push(Wo),n.push(pe.parse(l))):l.startsWith(wc)?(s.var.push(o),r.push(vc),n.push(l)):(s.number.push(o),r.push(Xo),n.push(parseFloat(l))),++o,ii)).split(ii);return{values:n,split:a,indexes:s,types:r}}function qo(e){return Nn(e).values}function Ko(e){const{split:t,types:n}=Nn(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===Xo?o+=Cn(r[i]):a===Wo?o+=pe.transform(r[i]):o+=r[i]}return o}}const Tc=e=>typeof e=="number"?0:pe.test(e)?pe.getAnimatableNone(e):e;function Cc(e){const t=qo(e);return Ko(e)(t.map(Tc))}const ft={test:bc,parse:qo,createTransformer:Ko,getAnimatableNone:Cc};function js(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 jc({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=js(l,a,e+1/3),o=js(l,a,e),i=js(l,a,e-1/3)}return{red:Math.round(r*255),green:Math.round(o*255),blue:Math.round(i*255),alpha:s}}function is(e,t){return n=>n>0?t:e}const de=(e,t,n)=>e+(t-e)*n,Ps=(e,t,n)=>{const s=e*e,r=n*(t*t-s)+s;return r<0?0:Math.sqrt(r)},Pc=[zs,Et,Bt],Ac=e=>Pc.find(t=>t.test(e));function oi(e){const t=Ac(e);if(Ht(!!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===Bt&&(n=jc(n)),n}const ai=(e,t)=>{const n=oi(e),s=oi(t);if(!n||!s)return is(e,t);const r={...n};return o=>(r.red=Ps(n.red,s.red,o),r.green=Ps(n.green,s.green,o),r.blue=Ps(n.blue,s.blue,o),r.alpha=de(n.alpha,s.alpha,o),Et.transform(r))},_s=new Set(["none","hidden"]);function Ec(e,t){return _s.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function Mc(e,t){return n=>de(e,t,n)}function Pr(e){return typeof e=="number"?Mc:typeof e=="string"?Tr(e)?is:pe.test(e)?ai:Dc:Array.isArray(e)?Go:typeof e=="object"?pe.test(e)?ai:kc:is}function Go(e,t){const n=[...e],s=n.length,r=e.map((o,i)=>Pr(o)(o,t[i]));return o=>{for(let i=0;i<s;i++)n[i]=r[i](o);return n}}function kc(e,t){const n={...e,...t},s={};for(const r in n)e[r]!==void 0&&t[r]!==void 0&&(s[r]=Pr(e[r])(e[r],t[r]));return r=>{for(const o in s)n[o]=s[o](r);return n}}function Nc(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 Dc=(e,t)=>{const n=ft.createTransformer(t),s=Nn(e),r=Nn(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?_s.has(e)&&!r.values.length||_s.has(t)&&!s.values.length?Ec(e,t):In(Go(Nc(s,r),r.values),n):(Ht(!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"),is(e,t))};function Yo(e,t,n){return typeof e=="number"&&typeof t=="number"&&typeof n=="number"?de(e,t,n):Pr(e)(e,t)}const Rc=e=>{const t=({timestamp:n})=>e(n);return{start:(n=!0)=>ce.update(t,n),stop:()=>ht(t),now:()=>ve.isProcessing?ve.timestamp:Me.now()}},Ho=(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)})`},os=2e4;function Ar(e){let t=0;const n=50;let s=e.next(t);for(;!s.done&&t<os;)t+=n,s=e.next(t);return t>=os?1/0:t}function Vc(e,t=100,n){const s=n({...e,keyframes:[0,t]}),r=Math.min(Ar(s),os);return{type:"keyframes",ease:o=>s.next(r*o).value/t,duration:Ie(r)}}const Ic=5;function Jo(e,t,n){const s=Math.max(t-Ic,0);return ko(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},As=.001;function Oc({duration:e=ue.duration,bounce:t=ue.bounce,velocity:n=ue.velocity,mass:s=ue.mass}){let r,o;Ht(e<=Xe(ue.maxDuration),"Spring duration must be 10 seconds or less","spring-duration-limit");let i=1-t;i=nt(ue.minDamping,ue.maxDamping,i),e=nt(ue.minDuration,ue.maxDuration,Ie(e)),i<1?(r=u=>{const d=u*i,h=d*e,m=d-n,p=Xs(u,i),S=Math.exp(-h);return As-m/p*S},o=u=>{const h=u*i*e,m=h*n+n,p=Math.pow(i,2)*Math.pow(u,2)*e,S=Math.exp(-h),w=Xs(Math.pow(u,2),i);return(-r(u)+As>0?-1:1)*((m-p)*S)/w}):(r=u=>{const d=Math.exp(-u*e),h=(u-n)*e+1;return-As+d*h},o=u=>{const d=Math.exp(-u*e),h=(n-u)*(e*e);return d*h});const a=5/e,l=$c(r,o,a);if(e=Xe(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 Lc=12;function $c(e,t,n){let s=n;for(let r=1;r<Lc;r++)s=s-e(s)/t(s);return s}function Xs(e,t){return e*Math.sqrt(1-t*t)}const Fc=["duration","bounce"],Bc=["stiffness","damping","mass"];function li(e,t){return t.some(n=>e[n]!==void 0)}function Uc(e){let t={velocity:ue.velocity,stiffness:ue.stiffness,damping:ue.damping,mass:ue.mass,isResolvedFromDuration:!1,...e};if(!li(e,Bc)&&li(e,Fc))if(e.visualDuration){const n=e.visualDuration,s=2*Math.PI/(n*1.2),r=s*s,o=2*nt(.05,1,1-(e.bounce||0))*Math.sqrt(r);t={...t,mass:ue.mass,stiffness:r,damping:o}}else{const n=Oc(e);t={...t,...n,mass:ue.mass},t.isResolvedFromDuration=!0}return t}function as(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}=Uc({...n,velocity:-Ie(n.velocity||0)}),S=m||0,w=u/(2*Math.sqrt(l*d)),T=i-o,v=Ie(Math.sqrt(l/d)),M=Math.abs(T)<5;s||(s=M?ue.restSpeed.granular:ue.restSpeed.default),r||(r=M?ue.restDelta.granular:ue.restDelta.default);let E;if(w<1){const D=Xs(v,w);E=I=>{const N=Math.exp(-w*v*I);return i-N*((S+w*v*T)/D*Math.sin(D*I)+T*Math.cos(D*I))}}else if(w===1)E=D=>i-Math.exp(-v*D)*(T+(S+v*T)*D);else{const D=v*Math.sqrt(w*w-1);E=I=>{const N=Math.exp(-w*v*I),j=Math.min(D*I,300);return i-N*((S+w*v*T)*Math.sinh(j)+D*T*Math.cosh(j))/D}}const $={calculatedDuration:p&&h||null,next:D=>{const I=E(D);if(p)a.done=D>=h;else{let N=D===0?S:0;w<1&&(N=D===0?Xe(S):Jo(E,D,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 D=Math.min(Ar($),os),I=Ho(N=>$.next(D*N).value,D,30);return D+"ms "+I},toTransition:()=>{}};return $}as.applyToOptions=e=>{const t=Vc(e,100,as);return e.ease=t.ease,e.duration=Xe(t.duration),e.type="keyframes",e};function Ws({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,S=j=>a===void 0?l:l===void 0||Math.abs(a-j)<Math.abs(l-j)?a:l;let w=n*t;const T=h+w,v=i===void 0?T:i(T);v!==T&&(w=v-h);const M=j=>-w*Math.exp(-j/s),E=j=>v+M(j),$=j=>{const O=M(j),A=E(j);m.done=Math.abs(O)<=u,m.value=m.done?v:A};let D,I;const N=j=>{p(m.value)&&(D=j,I=as({keyframes:[m.value,S(m.value)],velocity:Jo(E,j,m.value),damping:r,stiffness:o,restDelta:u,restSpeed:d}))};return N(0),{calculatedDuration:null,next:j=>{let O=!1;return!I&&D===void 0&&(O=!0,$(j),N(j)),D!==void 0&&j>=D?I.next(j-D):(!O&&$(j),m)}}}function zc(e,t,n){const s=[],r=n||rt.mix||Yo,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]||Oe:t;a=In(l,a)}s.push(a)}return s}function _c(e,t,{clamp:n=!0,ease:s,mixer:r}={}){const o=e.length;if(st(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=zc(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=Mn(e[h],e[h+1],d);return a[h](m)};return n?d=>u(nt(e[0],e[o-1],d)):u}function Xc(e,t){const n=e[e.length-1];for(let s=1;s<=t;s++){const r=Mn(0,t,s);e.push(de(n,1,r))}}function Wc(e){const t=[0];return Xc(t,e.length-1),t}function qc(e,t){return e.map(n=>n*t)}function Kc(e,t){return e.map(()=>t||Fo).splice(0,e.length-1)}function Ut({duration:e=300,keyframes:t,times:n,ease:s="easeInOut"}){const r=ic(s)?s.map(si):si(s),o={done:!1,value:t[0]},i=qc(n&&n.length===t.length?n:Wc(t),e),a=_c(i,t,{ease:Array.isArray(r)?r:Kc(t,r)});return{calculatedDuration:e,next:l=>(o.value=a(l),o.done=l>=e,o)}}const Gc=e=>e!==null;function Er(e,{repeat:t,repeatType:n="loop"},s,r=1){const o=e.filter(Gc),a=r<0||t&&n!=="loop"&&t%2===1?0:o.length-1;return!a||s===void 0?o[a]:s}const Yc={decay:Ws,inertia:Ws,tween:Ut,keyframes:Ut,spring:as};function Zo(e){typeof e.type=="string"&&(e.type=Yc[e.type])}class Mr{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 Hc=e=>e/100;class kr extends Mr{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!==Me.now()&&this.tick(Me.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;Zo(t);const{type:n=Ut,repeat:s=0,repeatDelay:r=0,repeatType:o,velocity:i=0}=t;let{keyframes:a}=t;const l=n||Ut;process.env.NODE_ENV!=="production"&&l!==Ut&&st(a.length<=2,`Only two keyframes currently supported with spring and inertia animations. Trying to animate ${a}`,"spring-two-frames"),l!==Ut&&typeof a[0]!="number"&&(this.mixKeyframes=In(Hc,Yo(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=Ar(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:S,onUpdate:w,finalKeyframe:T}=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 v=this.currentTime-u*(this.playbackSpeed>=0?1:-1),M=this.playbackSpeed>=0?v<0:v>r;this.currentTime=Math.max(v,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=r);let E=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)),E=nt(0,1,A)*a}const D=M?{done:!1,value:d[0]}:$.next(E);o&&(D.value=o(D.value));let{done:I}=D;!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!==Ws&&(D.value=Er(d,this.options,T,this.speed)),w&&w(D.value),N&&this.finish(),D}then(t,n){return this.finished.then(t,n)}get duration(){return Ie(this.calculatedDuration)}get iterationDuration(){const{delay:t=0}=this.options||{};return this.duration+Ie(t)}get time(){return Ie(this.currentTime)}set time(t){t=Xe(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(Me.now());const n=this.playbackSpeed!==t;this.playbackSpeed=t,n&&(this.time=Ie(this.currentTime))}play(){if(this.isStopped)return;const{driver:t=Rc,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(Me.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 Jc(e){for(let t=1;t<e.length;t++)e[t]??(e[t]=e[t-1])}const Mt=e=>e*180/Math.PI,qs=e=>{const t=Mt(Math.atan2(e[1],e[0]));return Ks(t)},Zc={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:qs,rotateZ:qs,skewX:e=>Mt(Math.atan(e[1])),skewY:e=>Mt(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},Ks=e=>(e=e%360,e<0&&(e+=360),e),ci=qs,ui=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),di=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),Qc={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:ui,scaleY:di,scale:e=>(ui(e)+di(e))/2,rotateX:e=>Ks(Mt(Math.atan2(e[6],e[5]))),rotateY:e=>Ks(Mt(Math.atan2(-e[2],e[0]))),rotateZ:ci,rotate:ci,skewX:e=>Mt(Math.atan(e[4])),skewY:e=>Mt(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function Gs(e){return e.includes("scale")?1:0}function Ys(e,t){if(!e||e==="none")return Gs(t);const n=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let s,r;if(n)s=Qc,r=n;else{const a=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);s=Zc,r=a}if(!r)return Gs(t);const o=s[t],i=r[1].split(",").map(tu);return typeof o=="function"?o(i):i[o]}const eu=(e,t)=>{const{transform:n="none"}=getComputedStyle(e);return Ys(n,t)};function tu(e){return parseFloat(e.trim())}const Zt=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],Qt=new Set(Zt),hi=e=>e===Jt||e===U,nu=new Set(["x","y","z"]),su=Zt.filter(e=>!nu.has(e));function ru(e){const t=[];return su.forEach(n=>{const s=e.getValue(n);s!==void 0&&(t.push([n,s.get()]),s.set(n.startsWith("scale")?1:0))}),t}const kt={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})=>Ys(t,"x"),y:(e,{transform:t})=>Ys(t,"y")};kt.translateX=kt.x;kt.translateY=kt.y;const Nt=new Set;let Hs=!1,Js=!1,Zs=!1;function Qo(){if(Js){const e=Array.from(Nt).filter(s=>s.needsMeasurement),t=new Set(e.map(s=>s.element)),n=new Map;t.forEach(s=>{const r=ru(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)})}Js=!1,Hs=!1,Nt.forEach(e=>e.complete(Zs)),Nt.clear()}function ea(){Nt.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(Js=!0)})}function iu(){Zs=!0,ea(),Qo(),Zs=!1}class Nr{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?(Nt.add(this),Hs||(Hs=!0,ce.read(ea),ce.resolveKeyframes(Qo))):(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])}Jc(t)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(t=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,t),Nt.delete(this)}cancel(){this.state==="scheduled"&&(Nt.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const ou=e=>e.startsWith("--");function au(e,t,n){ou(t)?e.style.setProperty(t,n):e.style[t]=n}const lu=yr(()=>window.ScrollTimeline!==void 0),cu={};function uu(e,t){const n=yr(e);return()=>cu[t]??n()}const ta=uu(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),Sn=([e,t,n,s])=>`cubic-bezier(${e}, ${t}, ${n}, ${s})`,fi={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:Sn([0,.65,.55,1]),circOut:Sn([.55,0,1,.45]),backIn:Sn([.31,.01,.66,-.59]),backOut:Sn([.33,1.53,.69,.99])};function na(e,t){if(e)return typeof e=="function"?ta()?Ho(e,t):"ease-out":Bo(e)?Sn(e):Array.isArray(e)?e.map(n=>na(n,t)||fi.easeOut):fi[e]}function du(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=na(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 sa(e){return typeof e=="function"&&"applyToOptions"in e}function hu({type:e,...t}){return sa(e)&&ta()?e.applyToOptions(t):(t.duration??(t.duration=300),t.ease??(t.ease="easeOut"),t)}class fu extends Mr{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,st(typeof t.type!="string",`Mini animate() doesn't support "type" as a string.`,"mini-spring");const u=hu(t);this.animation=du(n,s,r,u,o),u.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!o){const d=Er(r,this.options,a,this.speed);this.updateMotionValue?this.updateMotionValue(d):au(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 Ie(Number(t))}get iterationDuration(){const{delay:t=0}=this.options||{};return this.duration+Ie(t)}get time(){return Ie(Number(this.animation.currentTime)||0)}set time(t){this.finishedTime=null,this.animation.currentTime=Xe(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&&lu()?(this.animation.timeline=t,Oe):n(this)}}const ra={anticipate:Oo,backInOut:Io,circInOut:$o};function mu(e){return e in ra}function pu(e){typeof e.ease=="string"&&mu(e.ease)&&(e.ease=ra[e.ease])}const mi=10;class gu extends fu{constructor(t){pu(t),Zo(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 kr({...i,autoplay:!1}),l=Xe(this.finishedTime??this.time);n.setWithVelocity(a.sample(l-mi).value,a.sample(l).value,mi),a.stop()}}const pi=(e,t)=>t==="zIndex"?!1:!!(typeof e=="number"||Array.isArray(e)||typeof e=="string"&&(ft.test(e)||e==="0")&&!e.startsWith("url("));function yu(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 xu(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=pi(r,t),a=pi(o,t);return Ht(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:yu(e)||(n==="spring"||sa(n))&&s}function Qs(e){e.duration=0,e.type="keyframes"}const bu=new Set(["opacity","clipPath","filter","transform"]),vu=yr(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function wu(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 vu()&&n&&bu.has(n)&&(n!=="transform"||!u)&&!l&&!s&&r!=="mirror"&&o!==0&&i!=="inertia"}const Su=40;class Tu extends Mr{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=Me.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||Nr;this.keyframeResolver=new p(a,(S,w,T)=>this.onKeyframesResolved(S,w,m,!T),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=Me.now(),xu(t,o,i,a)||((rt.instantAnimations||!l)&&d?.(Er(t,s,n)),t[0]=t[t.length-1],Qs(s),s.repeat=0);const m={startTime:r?this.resolvedAt?this.resolvedAt-this.createdAt>Su?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...s,keyframes:t},p=!u&&wu(m)?new gu({...m,element:m.motionValue.owner.current}):new kr(m);p.finished.then(()=>this.notifyFinished()).catch(Oe),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(),iu()),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 Cu=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function ju(e){const t=Cu.exec(e);if(!t)return[,];const[,n,s,r]=t;return[`--${n??s}`,r]}const Pu=4;function ia(e,t,n=1){st(n<=Pu,`Max CSS variable fallback depth detected in property "${e}". This may indicate a circular fallback dependency.`,"max-css-var-depth");const[s,r]=ju(e);if(!s)return;const o=window.getComputedStyle(t).getPropertyValue(s);if(o){const i=o.trim();return Ao(i)?parseFloat(i):i}return Tr(r)?ia(r,t,n+1):r}function Dr(e,t){return e?.[t]??e?.default??e}const oa=new Set(["width","height","top","left","right","bottom",...Zt]),Au={test:e=>e==="auto",parse:e=>e},aa=e=>t=>t.test(e),la=[Jt,U,Ze,dt,yc,gc,Au],gi=e=>la.find(aa(e));function Eu(e){return typeof e=="number"?e===0:e!==null?e==="none"||e==="0"||Mo(e):!0}const Mu=new Set(["brightness","contrast","saturate","opacity"]);function ku(e){const[t,n]=e.slice(0,-1).split("(");if(t==="drop-shadow")return e;const[s]=n.match(Cr)||[];if(!s)return e;const r=n.replace(s,"");let o=Mu.has(t)?1:0;return s!==n&&(o*=100),t+"("+o+r+")"}const Nu=/\b([a-z-]*)\(.*?\)/gu,er={...ft,getAnimatableNone:e=>{const t=e.match(Nu);return t?t.map(ku).join(" "):e}},yi={...Jt,transform:Math.round},Du={rotate:dt,rotateX:dt,rotateY:dt,rotateZ:dt,scale:Gn,scaleX:Gn,scaleY:Gn,scaleZ:Gn,skew:dt,skewX:dt,skewY:dt,distance:U,translateX:U,translateY:U,translateZ:U,x:U,y:U,z:U,perspective:U,transformPerspective:U,opacity:kn,originX:ri,originY:ri,originZ:U},Rr={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,...Du,zIndex:yi,fillOpacity:kn,strokeOpacity:kn,numOctaves:yi},Ru={...Rr,color:pe,backgroundColor:pe,outlineColor:pe,fill:pe,stroke:pe,borderColor:pe,borderTopColor:pe,borderRightColor:pe,borderBottomColor:pe,borderLeftColor:pe,filter:er,WebkitFilter:er},ca=e=>Ru[e];function ua(e,t){let n=ca(e);return n!==er&&(n=ft),n.getAnimatableNone?n.getAnimatableNone(t):void 0}const Vu=new Set(["auto","none","0"]);function Iu(e,t,n){let s=0,r;for(;s<e.length&&!r;){const o=e[s];typeof o=="string"&&!Vu.has(o)&&Nn(o).values.length&&(r=e[s]),s++}if(r&&n)for(const o of t)e[o]=ua(n,r)}class Ou extends Nr{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(),Tr(u))){const d=ia(u,n.current);d!==void 0&&(t[l]=d),l===t.length-1&&(this.finalKeyframe=u)}}if(this.resolveNoneKeyframes(),!oa.has(s)||t.length!==2)return;const[r,o]=t,i=gi(r),a=gi(o);if(i!==a)if(hi(i)&&hi(a))for(let l=0;l<t.length;l++){const u=t[l];typeof u=="string"&&(t[l]=parseFloat(u))}else kt[s]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:t,name:n}=this,s=[];for(let r=0;r<t.length;r++)(t[r]===null||Eu(t[r]))&&s.push(r);s.length&&Iu(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=kt[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]=kt[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 Lu(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 da=(e,t)=>t&&typeof e=="number"?t.transform(e):e;function ha(e){return Eo(e)&&"offsetHeight"in e}const xi=30,$u=e=>!isNaN(parseFloat(e));class Fu{constructor(t,n={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=s=>{const r=Me.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=Me.now(),this.canTrackVelocity===null&&t!==void 0&&(this.canTrackVelocity=$u(this.current))}setPrevFrameValue(t=this.current){this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt}onChange(t){return process.env.NODE_ENV!=="production"&&br(!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 xr);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=Me.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||t-this.updatedAt>xi)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,xi);return ko(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 Gt(e,t){return new Fu(e,t)}const{schedule:Vr}=Uo(queueMicrotask,!1),ze={x:!1,y:!1};function fa(){return ze.x||ze.y}function Bu(e){return e==="x"||e==="y"?ze[e]?null:(ze[e]=!0,()=>{ze[e]=!1}):ze.x||ze.y?null:(ze.x=ze.y=!0,()=>{ze.x=ze.y=!1})}function ma(e,t){const n=Lu(e),s=new AbortController,r={passive:!0,...t,signal:s.signal};return[n,r,()=>s.abort()]}function bi(e){return!(e.pointerType==="touch"||fa())}function Uu(e,t,n={}){const[s,r,o]=ma(e,n),i=a=>{if(!bi(a))return;const{target:l}=a,u=t(l,a);if(typeof u!="function"||!l)return;const d=h=>{bi(h)&&(u(h),l.removeEventListener("pointerleave",d))};l.addEventListener("pointerleave",d,r)};return s.forEach(a=>{a.addEventListener("pointerenter",i,r)}),o}const pa=(e,t)=>t?e===t?!0:pa(e,t.parentElement):!1,Ir=e=>e.pointerType==="mouse"?typeof e.button!="number"||e.button<=0:e.isPrimary!==!1,zu=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function _u(e){return zu.has(e.tagName)||e.tabIndex!==-1}const ts=new WeakSet;function vi(e){return t=>{t.key==="Enter"&&e(t)}}function Es(e,t){e.dispatchEvent(new PointerEvent("pointer"+t,{isPrimary:!0,bubbles:!0}))}const Xu=(e,t)=>{const n=e.currentTarget;if(!n)return;const s=vi(()=>{if(ts.has(n))return;Es(n,"down");const r=vi(()=>{Es(n,"up")}),o=()=>Es(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 wi(e){return Ir(e)&&!fa()}function Wu(e,t,n={}){const[s,r,o]=ma(e,n),i=a=>{const l=a.currentTarget;if(!wi(a))return;ts.add(l);const u=t(l,a),d=(p,S)=>{window.removeEventListener("pointerup",h),window.removeEventListener("pointercancel",m),ts.has(l)&&ts.delete(l),wi(p)&&typeof u=="function"&&u(p,{success:S})},h=p=>{d(p,l===window||l===document||n.useGlobalTarget||pa(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),ha(a)&&(a.addEventListener("focus",u=>Xu(u,r)),!_u(a)&&!a.hasAttribute("tabindex")&&(a.tabIndex=0))}),o}function ga(e){return Eo(e)&&"ownerSVGElement"in e}function qu(e){return ga(e)&&e.tagName==="svg"}const Te=e=>!!(e&&e.getVelocity),Ku=[...la,pe,ft],Gu=e=>Ku.find(aa(e)),Or=f.createContext({transformPagePoint:e=>e,isStatic:!1,reducedMotion:"never"});function Si(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Yu(...e){return t=>{let n=!1;const s=e.map(r=>{const o=Si(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():Si(e[r],null)}}}}function Hu(...e){return _e.useCallback(Yu(...e),e)}class Ju extends _e.Component{getSnapshotBeforeUpdate(t){const n=this.props.childRef.current;if(n&&t.isPresent&&!this.props.isPresent){const s=n.offsetParent,r=ha(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 Zu({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(Or),l=Hu(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 S=n==="left"?`left: ${m}`:`right: ${p}`;o.current.dataset.motionPopId=r;const w=document.createElement("style");a&&(w.nonce=a);const T=s??document.head;return T.appendChild(w),w.sheet&&w.sheet.insertRule(`
1
+ "use strict";var vl=Object.create;var ti=Object.defineProperty;var wl=Object.getOwnPropertyDescriptor;var Sl=Object.getOwnPropertyNames;var Tl=Object.getPrototypeOf,Cl=Object.prototype.hasOwnProperty;var jl=(e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Sl(t))!Cl.call(e,r)&&r!==n&&ti(e,r,{get:()=>t[r],enumerable:!(s=wl(t,r))||s.enumerable});return e};var Pl=(e,t,n)=>(n=e!=null?vl(Tl(e)):{},jl(t||!e||!e.__esModule?ti(n,"default",{value:e,enumerable:!0}):n,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react/jsx-runtime"),f=require("react"),te=require("lucide-react"),Al=require("@ai-sdk/react"),ni=require("ai"),To=require("@radix-ui/react-slot"),Co=require("class-variance-authority"),El=require("clsx"),Ml=require("tailwind-merge"),kl=require("@radix-ui/react-tooltip"),si=require("@radix-ui/react-use-controllable-state"),Nl=require("@radix-ui/react-collapsible"),Dl=require("react-dom"),Rl=require("@radix-ui/react-dialog"),Vl=require("./server.cjs");function ms(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=ms(f),Ht=ms(kl),mr=ms(Nl),It=ms(Rl),Oe=Symbol.for("@arcteninc/core:originalName");function Il(e,t){return e[Oe]=t,e}function Ol(e,t,n,s){if(typeof e!="function")return null;const r=e[Oe];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[Oe]=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[Oe]=i.name,{fn:e,meta:i}}else if(i=Object.values(t).find(l=>!n.has(l.name)),i)return e[Oe]=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=Ol(o,n,r,s);if(!i){const a=o.name,u=o[Oe]||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 Ll={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(Ll))if(t!=="text"){for(const s of n)if(s.test(e))return t}return null}function $l(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 Fl(e,t,n){return t.length>0}function Bl(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=Ul(s[i]),d={name:i,type:zl(l||jn(i)||"text"),label:jo(i),placeholder:_l(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:Fl(e,t),fields:r,title:Xl(e),description:Wl(e,r.length)}}function Ul(e){if(e!=null){if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return String(e)}}function zl(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 _l(e,t){return t?$l(t,e).placeholder:`Enter ${jo(e).toLowerCase()}...`}function Xl(e){return e.replace(/([A-Z])/g," $1").trim().toLowerCase().split(" ").map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" ")}function Wl(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 ql(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 Kl(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 Gl(e,t){if(!e||e.length===0)return t;const n=new Map;t.forEach(o=>{const i=o[Oe]||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[Oe]||o.name;i&&!s.has(i)&&(console.log(`[useAgent] Allowing client-only tool (forward compatible): ${i}`),r.push(o))}),r}function Yl(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 Hl(e){return e.replace(/\[(\w+)\]/g,".$1").split(".").map(t=>t.trim()).filter(Boolean)}function Jl(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 Zl(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 Ql(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 ec(e){if(!e)return{};const t={};for(const[n,s]of Object.entries(e)){const r=Ql(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=Yl(t),i=[],a={};return n.fields.forEach(l=>{const u=Hl(l);if(u.length===0)return;const d=Jl(o,u),h=Xs(d);a[l]=h,Zl(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:h=!1,autoFormGeneration:m=!1,formMode:p="auto",systemPrompt:S="",agentId:v,agentName:C,projectId:b,enableRemoteConfig:M,remoteConfigUrl:E,initialMessages:$=[],conversationId:D,state:I,onStateChange:N,allowStateEdits:j=!0,onToolCall:O,onFinish:A,sources:k,ragConfig:F,ragFilters:V,secureInputHandler:B}={}){const X=e.replace(/\/+$/,""),[Y,K]=f.useState(null),[ie,ge]=f.useState(!1),[Ke,xt]=f.useState(null),nt=f.useMemo(()=>{const g=k||[],x=Y?.config?.sources||[];return[...new Set([...g,...x])]},[k,Y]),G=f.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=f.useMemo(()=>M===!1?!1:!!b,[b,M]);f.useEffect(()=>{if(!Ot||!oe.current)return;(async()=>{ge(!0),xt(null);try{const y=`${E||X.replace("/chat","").replace(/\/$/,"")}/convex/api/query`,w=await fetch(y,{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 R=await w.text().catch(()=>"Unknown error");throw new Error(`Failed to fetch remote config: ${w.status} ${R}`)}const P=await w.json();K(P?.value||null),console.log("[useAgent] Remote config loaded successfully:",P?.value)}catch(x){console.error("[useAgent] Failed to fetch remote config:",x);const y=x instanceof Error?x:new Error(String(x));xt(y),K(null)}finally{ge(!1)}})()},[Ot,b,C,v,X,E]);const Me=f.useMemo(()=>{const g={};if(u)for(const[x,y]of Object.entries(u))if(g[x]={},Array.isArray(y))for(const w of y){const P=jn(w);g[x][w]=P||"text"}else for(const[w,P]of Object.entries(y))g[x][w]=P;if(l){for(const[x,y]of Object.entries(l))if(y&&typeof y=="object"&&"sensitiveParams"in y){g[x]||(g[x]={});const w=y.sensitiveParams;if(Array.isArray(w))for(const P of w){const R=jn(P);g[x][P]=R||"text"}else if(w&&typeof w=="object")for(const[P,R]of Object.entries(w))g[x][P]=R}}return g},[u,l,h]),bt=f.useMemo(()=>ec(d),[d]),Pe=f.useCallback((g,x)=>{const y=bt[g];if(!y)return x;try{return Ao(g,x,y)}catch(w){return console.error(`[useAgent] Failed to redact output for ${g}:`,w),{value:ss,[ns]:{tool:g,redacted:!0,error:String(w)}}}},[bt]),[Fe,hn]=f.useState(n||null),oe=f.useRef(n||null),[fn,vt]=f.useState(null),[mn,_n]=f.useState(null),Be=f.useRef(null),[wt,St]=f.useState([]),[Ne,pn]=f.useState(D||(typeof window<"u"?crypto.randomUUID():null)),[bs,Lt]=f.useState(!1),[Xn,Tt]=f.useState(new Set),[lt,vs]=f.useState(new Map),[Wn,Ge]=f.useState(new Map),[ws,qn]=f.useState(new Map),[$t,gn]=f.useState(new Map),le=I!==void 0,[yn,Ue]=f.useState({}),Se=f.useRef({}),Ye=le?I||{}:yn;le&&I?Se.current=I:le||(Se.current=yn);const[ze,Ft]=f.useState(!1),[Ct,jt]=f.useState(null),xn=f.useRef(!1),De=f.useCallback(async(g,x=3)=>{if(!Ne||!oe.current)return;const y=async()=>{const P=`${X.replace("/chat","").replace(/\/$/,"")}/convex/api/mutation`,R=await fetch(P,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${oe.current}`},body:JSON.stringify({path:"conversations:mergeStateByChatId",args:{chatId:Ne,updates:g},format:"json"})});if(!R.ok){if(R.status===404){console.warn("[useAgent] Convex API endpoint not available (404), state changes will not be persisted");return}const L=await R.text().catch(()=>"Unknown error");throw new Error(`Failed to sync conversation state: ${R.status} ${L}`)}};for(let w=0;w<x;w++)try{await y(),jt(null);return}catch(P){if(w===x-1){const L=P instanceof Error?P:new Error(String(P));throw jt(L),console.error("Failed to sync state to Convex after retries:",P),L}await new Promise(L=>setTimeout(L,Math.pow(2,w)*100))}},[Ne,X,oe]),Pt=f.useMemo(()=>function(){return Se.current},[]),ye=f.useMemo(()=>async function(x){const y={...Se.current,...x};Se.current=y,le||Ue(y),N&&N(y);try{await De(x)}catch(w){throw w}},[De,N,le]);f.useEffect(()=>{le&&I&&(Se.current=I)},[le,I]);const Kn=f.useCallback(g=>B?B.showSecureModal(g):new Promise(x=>{vs(y=>new Map(y).set(g.id,g)),Ge(y=>new Map(y).set(g.id,x))}),[B]),Bt=f.useCallback((g,x)=>{if(B)return;const y=Wn.get(g);y&&(y(x),vs(w=>{const P=new Map(w);return P.delete(g),P}),Ge(w=>{const P=new Map(w);return P.delete(g),P}))},[Wn,B]),st=f.useCallback(g=>B?B.showSecureForm(g):new Promise(x=>{qn(y=>new Map(y).set(g.id,g)),gn(y=>new Map(y).set(g.id,x))}),[B]),Qr=f.useCallback((g,x)=>{if(B)return;const y=$t.get(g);y&&(y(x),qn(w=>{const P=new Map(w);return P.delete(g),P}),gn(w=>{const P=new Map(w);return P.delete(g),P}))},[$t,B]),bn=f.useCallback((g,x)=>{const y=Me[g]||{},w=Object.keys(y).length>0;if(h){const P=Object.keys(x).filter(R=>jn(R)!==null);return w||P.length>0}return w},[Me,h]),vn=f.useCallback((g,x)=>{const w={...Me[g]||{}};if(h){for(const R of Object.keys(x))if(!(R in w)){const L=jn(R);L&&(w[R]=L)}}const P=Object.entries(w).filter(([R])=>Object.prototype.hasOwnProperty.call(x,R));return P.length>0?Object.fromEntries(P):w},[Me,h]),He=f.useMemo(()=>G?.enabled?async function(x,y=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:x,k:Math.min(y,100),organizationId:q,...Object.keys(P).length>0?{filters:P}:{}})}).then(re=>re.ok?re.json():null)),ae=await Promise.all(L),ee=[];for(const q of ae)q?.candidates&&ee.push(...q.candidates);ee.sort((q,re)=>{const et=q.scores?.rerank||q.scores?.dense||0;return(re.scores?.rerank||re.scores?.dense||0)-et});const ve=ee.slice(0,y).map((q,re)=>{const et=q.citation||q.url;return{rank:re+1,doc_id:q.doc_id,block_id:q.block_id,url:q.url,citation:et,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:x,total:ee.length,results:ve,summary:`Found ${ee.length} relevant results across ${k.length} source(s) for "${x}". Top result: ${ve[0]?.title||"N/A"}`}}const R=G.organizationId&&G.organizationId!=="default"?G.organizationId:k&&k.length>0?k[0]:void 0;try{const L={q:x,k:Math.min(y,100)};R&&(L.organizationId=R),Object.keys(P).length>0&&(L.filters=P);const ae={"Content-Type":"application/json"};oe.current&&(ae.Authorization=`Bearer ${oe.current}`);const ee=await fetch(`${X}/search`,{method:"POST",headers:ae,body:JSON.stringify(L)});if(!ee.ok){const re=await ee.text();return{success:!1,error:`Search failed: ${ee.status} ${re}`}}const ve=await ee.json(),q=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:q,summary:`Found ${ve.total} relevant results for "${x}". 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]),ct=f.useMemo(()=>G?.enabled?async function(x,y){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 R=await fetch(`${X}/fetch`,{method:"POST",headers:P,body:JSON.stringify({doc_id:x,block_ids:y,...w?{organizationId:w}:{}})});if(!R.ok){const ae=await R.text();return{success:!1,error:`Fetch failed: ${R.status} ${ae}`}}const L=await R.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||x}`}}catch(P){return{success:!1,error:P instanceof Error?P.message:"Unknown error occurred"}}}:null,[G,X,oe]),Ut=f.useMemo(()=>{if(Y&&Y.config?.tools){const g=Gl(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,Je=Y?.enableRagTools??G?.enabled??!1,Gn=f.useMemo(()=>{const g=[...Ut,...i];return _e&&(g.push(Pt),(!le||j)&&g.push(ye)),Je&&(He&&g.push(He),ct&&g.push(ct)),g},[Ut,i,Pt,ye,He,ct,_e,Je,le,j]),Yn=f.useMemo(()=>[...Ut,...i],[Ut,i]),rt=f.useMemo(()=>pr(Yn,l),[Yn,l]),At=f.useMemo(()=>{const g=new Map,x=new Map(rt.map(y=>[y.name,y]));return g.set("getState",Pt),(!le||j)&&g.set("setState",ye),G?.enabled&&(He&&g.set("searchDocs",He),ct&&g.set("fetchDocContent",ct)),Gn.forEach(y=>{if(y===Pt||y===ye||y===He||y===ct)return;const w=y[Oe];if(w){const R=x.get(w);if(R){g.set(R.name,y);return}}const P=rt.find(R=>R.name===y.name);P&&g.set(P.name,y)}),g},[Gn,rt,Pt,ye,He,ct,G,le,j]),wn=f.useMemo(()=>new Set(rt.map(g=>g.name)),[rt]),Hn=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:[]}}),(!le||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 x=[];Je&&x.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 y=[];return Y?.config?.workflows&&Y.config.workflows.forEach(w=>{const P={},R=[];w.parameters&&w.parameters.forEach(L=>{P[L.name]={type:L.type||"string",description:L.description},L.required&&R.push(L.name)}),y.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:R},_workflow:w})}),[...rt,...g,...x,...y]},[rt,_e,Je,le,j,Y]),ut=f.useMemo(()=>Hn.filter(g=>g.name==="getState"?_e:g.name==="setState"?_e&&(!le||j):g.name==="searchDocs"||g.name==="fetchDocContent"?Je:g.name.startsWith("workflow_")?!0:wn.has(g.name)),[Hn,wn,_e,Je,le,j]),zt=f.useMemo(()=>{const g=new Set;return _e&&(g.add("getState"),g.add("setState")),Je&&G?.autoExecute!==!1&&(g.add("searchDocs"),g.add("fetchDocContent")),Y?.config?.tools?Y.config.tools.forEach(x=>{x.isEnabled&&!x.requiresApproval&&g.add(x.name)}):(i.forEach(x=>{for(const[y,w]of At.entries())if(w===x){g.add(y);break}}),a&&Array.isArray(a)&&a.forEach(x=>{typeof x=="string"&&g.add(x)})),Y?.config?.workflows&&Y.config.workflows.forEach(x=>{const y=`workflow_${x.name.replace(/\s+/g,"_").toLowerCase()}`;x.requiresApproval||g.add(y)}),g},[Y,i,a,At,_e,Je,G]);f.useEffect(()=>s||n?void 0:((async()=>{try{const x=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:r})});if(!x.ok)throw new Error("Failed to fetch token");const y=await x.json();hn(y.clientToken),oe.current=y.clientToken,_n(y.expiresAt),vt(null)}catch(x){console.error("[useAgent] Token fetch failed:",x),vt(x instanceof Error?x.message:"Failed to fetch token")}})(),()=>{Be.current&&clearTimeout(Be.current)}),[t,JSON.stringify(r),s,n]),f.useEffect(()=>{if(!mn||s||n)return;Be.current&&clearTimeout(Be.current);const g=Math.floor(Date.now()/1e3),x=mn-g,w=Math.max(0,x-5);return Be.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 R=await P.json();hn(R.clientToken),oe.current=R.clientToken,_n(R.expiresAt),vt(null)}catch(P){console.error("[useAgent] Token refresh failed:",P),vt(P instanceof Error?P.message:"Failed to refresh token")}},w*1e3),()=>{Be.current&&clearTimeout(Be.current)}},[mn,t,JSON.stringify(r),s,n]);const Ss=async(g,x={})=>{const y=x.headers?new Headers(x.headers):new Headers;y.delete("user-agent"),y.delete("User-Agent"),console.log("[useAgent] Making request to:",g),console.log("[useAgent] Method:",x.method||"GET"),console.log("[useAgent] Has Authorization header:",y.has("Authorization")),console.log("[useAgent] Client token available:",!!oe.current);try{const w=await fetch(g,{...x,headers:y});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}},_t=f.useRef(!1),Sn=f.useRef(null),T=f.useRef(!1),W=`${X}/chat`;console.log("[useAgent] Chat API URL:",W);const{messages:U,sendMessage:Z,status:H,error:J,stop:Re,addToolResult:ne,setMessages:xe}=Al.useChat({id:Ne||void 0,messages:$,transport:new ni.DefaultChatTransport({api:W,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})),x=g.filter(w=>w.name==="getState"||w.name==="setState").map(w=>w.name),y=g.filter(w=>w.name==="searchDocs"||w.name==="fetchDocContent").map(w=>w.name);return x.length>0&&console.log("[useAgent] State tools included in tools list sent to AI SDK:",x),y.length>0?console.log("[useAgent] RAG tools included in tools list sent to AI SDK:",y):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:Se.current,...V&&{ragFilters:V}}}}),sendAutomaticallyWhen:g=>{const x=g.messages;if(_t.current)return _t.current=!1,!1;const y=x[x.length-1];if(y&&y.role==="user"||T.current||y&&y.role==="assistant"&&y.id&&Sn.current===y.id)return!1;const w=ni.lastAssistantMessageIsCompleteWithToolCalls(g);return w&&y&&y.role==="assistant"&&y.id&&(Sn.current=y.id),w}}),_=Z,he=f.useCallback(g=>(_t.current=!0,Sn.current=null,T.current=!1,_(g)),[_]);f.useEffect(()=>{let g=!1;U.forEach(x=>{x.role==="assistant"&&x.parts.forEach(y=>{y.type?.startsWith("tool-")&&y.state==="input-available"&&(g=!0)})}),!g&&T.current&&(T.current=!1)},[U]);const Q=f.useCallback((g,x,y)=>{const w=Pe(g,y);ne({toolCallId:x,tool:g,output:w})},[ne,Pe]);f.useEffect(()=>{U.forEach(g=>{g.role==="assistant"&&g.parts.forEach(x=>{if(!x.type?.startsWith("tool-")||x.state!=="input-available")return;const y=x.type.replace("tool-",""),w=x.toolCallId;if(Xn.has(w))return;Tt(R=>new Set(R).add(w));const P=Kl(x.input);if(bn(y,P)){const R=vn(y,P),L=Object.entries(R).filter(([q])=>P[q]!==void 0),ae=L.length>0?Object.fromEntries(L):R,ee=Object.keys(P),ve=ql(P,ae);(async()=>{try{const q=Bl(y,ee,ae,P),re={id:`${w}-form`,toolName:y,toolCallId:w,title:q.title,description:q.description,fields:q.fields},et=await st(re);if(et===null){Q(y,w,"User cancelled secure input");return}const Tn={...ve,...et},Ts=At.get(y);if(!Ts)throw new Error(`Tool ${y} not found`);let Cs;const js=ut.find(ei=>ei.name===y);if(js&&js.jsonSchema?.properties){const xl=Object.keys(js.jsonSchema.properties).map(bl=>Tn[bl]);Cs=await Ts(...xl)}else Cs=await Ts(...Object.values(Tn));Q(y,w,Cs)}catch(q){console.error(`[useAgent] Error executing tool with secure input ${y}:`,q),Q(y,w,`Error: ${q}`)}})();return}if(y.startsWith("workflow_")&&zt.has(y)){(async()=>{try{const L=ut.find(ee=>ee.name===y)?._workflow;if(!L)throw new Error(`Workflow metadata not found for ${y}`);let ae;if(L.webhook?.url){let ee=P;if(L.webhook.bodyTemplate){let q=L.webhook.bodyTemplate;Object.entries(P).forEach(([re,et])=>{q=q.replace(new RegExp(`\\{\\{${re}\\}\\}`,"g"),String(et))}),ee=JSON.parse(q)}const ve=await fetch(L.webhook.url,{method:L.webhook.method||"POST",headers:{"Content-Type":"application/json",...L.webhook.headers||{}},body:JSON.stringify(ee)});if(ve.ok)ae={success:!0,data:await ve.json().catch(()=>({success:!0}))};else{const q=await ve.text();ae={success:!1,error:`Webhook failed: ${ve.status} ${q}`}}}else ae={success:!0,message:`Workflow "${L.name}" acknowledged. Follow the workflow instructions to proceed.`,instructions:L.contentPlaintext};Q(y,w,ae)}catch(R){console.error(`[useAgent] Error executing workflow ${y}:`,R),Q(y,w,`Error: ${R}`)}})();return}if(zt.has(y)&&!bn(y,P)){const R=At.get(y);R?(async()=>{try{const L=ut.find(ee=>ee.name===y);let ae;if(L&&L.jsonSchema?.properties){const ve=Object.keys(L.jsonSchema.properties).map(q=>P[q]);ae=await R(...ve)}else if(y==="getState")ae=R();else if(y==="setState"){const ee=P.updates||P;ae=await R(ee)}else ae=await R(...Object.values(P));Q(y,w,ae)}catch(L){console.error(`[useAgent] Error executing tool ${y}:`,L),Q(y,w,`Error: ${L}`)}})():console.warn(`[useAgent] Tool ${y} not found in toolsMap`)}else y.startsWith("workflow_")&&O?(T.current=!0,O({toolCall:{toolCallId:w,toolName:y,args:P}})):O&&(T.current=!0,O({toolCall:{toolCallId:w,toolName:y,args:P}}))})})},[U,zt,At,O,Q,Xn,ye,ut,bn,vn,Kn]),f.useEffect(()=>{if(H==="ready"&&U.length>0&&A){const g=U[U.length-1];g&&g.role==="assistant"&&A({message:g,messages:U,isAbort:!1,isDisconnect:!1,isError:!!J})}},[H,U,J,A]);async function Ae(){if(!(!r?.id||!Fe)){Lt(!0);try{const x=await(await fetch(`${X}/conversations`,{headers:{Authorization:`Bearer ${Fe}`}})).json();St(x.conversations||[])}catch(g){console.error("Failed to fetch conversations:",g)}finally{Lt(!1)}}}f.useEffect(()=>{r?.id&&Fe&&Ae()},[JSON.stringify(r),Fe,X]),f.useEffect(()=>{if(!Ne||!oe.current)return;(async()=>{Ft(!0),jt(null);try{const x=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:Ne},format:"json"})});if(!x.ok){const P=await x.text().catch(()=>"Unknown error");throw new Error(`Failed to fetch conversation state: ${x.status} ${P}`)}const w=(await x.json())?.value||{};Se.current=w,le||Ue(w),N&&N(w),xn.current=!0}catch(x){console.error("Failed to fetch state:",x);const y=x instanceof Error?x:new Error(String(x));jt(y),xn.current||(Se.current={},le?N&&N({}):(Ue({}),N&&N({})),xn.current=!0)}finally{Ft(!1)}})()},[Ne,X,le,N]);async function fe(g){pn(g),Lt(!0);try{const x=await fetch(`${X}/conversations/${g}/messages`,{headers:{Authorization:`Bearer ${oe.current}`}});if(!x.ok)throw new Error(`Failed to fetch messages: ${x.statusText}`);const w=(await x.json()).messages||[];xe(w)}catch(x){console.error("Failed to load conversation messages:",x)}finally{Lt(!1)}}async function Ze(g){if(Fe)try{await fetch(`${X}/conversations/${g}`,{method:"DELETE",headers:{Authorization:`Bearer ${Fe}`}}),St(wt.filter(x=>x._id!==g)),g===Ne&&be()}catch(x){console.error("Failed to delete conversation:",x)}}function be(){const g=crypto.randomUUID();pn(g),xe([]),Tt(new Set),Se.current={},le?N&&N({}):(Ue({}),N&&N({})),xn.current=!1}function Te(g){const x=g.tool||"unknown-tool",y=Pe(x,g.output);ne({toolCallId:g.toolCallId,tool:x,output:y})}async function Qe(g,x,y){if(!x.startsWith("workflow_"))throw new Error(`${x} is not a workflow tool`);try{const P=ut.find(L=>L.name===x)?._workflow;if(!P)throw new Error(`Workflow metadata not found for ${x}`);let R;if(P.webhook?.url){let L=y;if(P.webhook.bodyTemplate){let ee=P.webhook.bodyTemplate;Object.entries(y).forEach(([ve,q])=>{ee=ee.replace(new RegExp(`\\{\\{${ve}\\}\\}`,"g"),String(q))}),L=JSON.parse(ee)}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)R={success:!0,data:await ae.json().catch(()=>({success:!0}))};else{const ee=await ae.text();R={success:!1,error:`Webhook failed: ${ae.status} ${ee}`}}}else R={success:!0,message:`Workflow "${P.name}" acknowledged. Follow the workflow instructions to proceed.`,instructions:P.contentPlaintext};return Te({toolCallId:g,tool:x,output:R}),R}catch(w){const P={success:!1,error:String(w)};throw Te({toolCallId:g,tool:x,output:P}),w}}async function yl(g){const x={...Se.current,...g};Se.current=x,le||Ue(x),N&&N(x);try{await De(g)}catch(y){throw y}}return{id:Ne,messages:U,status:H,error:J,sendMessage:he,stop:Re,addToolOutput:Te,executeWorkflowTool:Qe,setMessages:xe,conversations:wt,loadConversation:fe,deleteConversation:Ze,startNewConversation:be,isLoadingConversations:bs,clientToken:Fe,tokenError:fn,state:Ye,setState:yl,isStateLoading:ze,stateError:Ct,pendingSecureInputs:Array.from(lt.values()),completeSecureInput:Bt,pendingSecureForms:Array.from(ws.values()),completeSecureForm:Qr,safeToolNames:zt}}function se(...e){return Ml.twMerge(El.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=We.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:se(Mt({variant:t,size:n,className:e})),...r})});je.displayName="Button";const tc=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:se(tc({variant:t}),e),...s})}const nc=({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 nc({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:se("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 sc({delayDuration:e=0,...t}){return c.jsx(Ht.Provider,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function dt({...e}){return c.jsx(sc,{children:c.jsx(Ht.Root,{"data-slot":"tooltip",...e})})}function ht({...e}){return c.jsx(Ht.Trigger,{"data-slot":"tooltip-trigger",...e})}function ft({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:se("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:se("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",ko=xr?f.useLayoutEffect:f.useEffect,ps=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 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 Do(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 $e=e=>e,rc=(e,t)=>n=>t(e(n)),Fn=(...e)=>e.reduce(rc),Rn=(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,Le=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,ic=1e-7,oc=12;function ac(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)>ic&&++a<oc);return i}function Bn(e,t,n,s){if(e===t&&n===s)return $e;const r=o=>ac(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),lc=Bn(.42,0,1,1),cc=Bn(0,0,.58,1),_o=Bn(.42,0,.58,1),uc=e=>Array.isArray(e)&&typeof e[0]!="number",Xo=e=>Array.isArray(e)&&typeof e[0]=="number",oi={linear:$e,easeIn:lc,easeInOut:_o,easeOut:cc,circIn:jr,circInOut:zo,circOut:Uo,backIn:Cr,backInOut:Fo,backOut:$o,anticipate:Bo},dc=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(dc(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,h=!1,m=!1)=>{const S=m&&r?n:s;return h&&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 fc=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:h,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,fc),1)),r.timestamp=E,r.isProcessing=!0,a.process(r),l.process(r),u.process(r),d.process(r),h.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 D=i[$];return E[$]=(I,N=!1,j=!1)=>(n||C(),D.schedule(I,N,j)),E},{}),cancel:E=>{for(let $=0;$<Jn.length;$++)i[Jn[$]].cancel(E)},state:r,steps:i}}const{schedule:ce,cancel:pt,state:we,steps:As}=Wo(typeof requestAnimationFrame<"u"?requestAnimationFrame:$e,!0);let rs;function mc(){rs=void 0}const ke={now:()=>(rs===void 0&&ke.set(we.isProcessing||at.useManualTiming?we.timestamp:performance.now()),rs),set:e=>{rs=e,queueMicrotask(mc)}},qo=e=>t=>typeof t=="string"&&t.startsWith(e),Pr=qo("--"),pc=qo("var(--"),Ar=e=>pc(e)?gc.test(e.split("/*")[0].trim()):!1,gc=/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 yc(e){return e==null}const xc=/^(?:#[\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"&&xc.test(n)&&n.startsWith(e)||t&&!yc(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}},bc=e=>it(0,255,e),Es={...tn,transform:e=>Math.round(bc(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 vc(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:vc,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("%"),z=Un("px"),wc=Un("vh"),Sc=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))+")"},pe={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=pe.parse(e);return t.alpha=0,pe.transform(t)}},Tc=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function Cc(e){return isNaN(e)&&typeof e=="string"&&(e.match(Er)?.length||0)+(e.match(Tc)?.length||0)>0}const Go="number",Yo="color",jc="var",Pc="var(",ci="${}",Ac=/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(Ac,l=>(pe.test(l)?(s.color.push(o),r.push(Yo),n.push(pe.parse(l))):l.startsWith(Pc)?(s.var.push(o),r.push(jc),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+=pe.transform(r[i]):o+=r[i]}return o}}const Ec=e=>typeof e=="number"?0:pe.test(e)?pe.getAnimatableNone(e):e;function Mc(e){const t=Ho(e);return Jo(e)(t.map(Ec))}const gt={test:Cc,parse:Ho,createTransformer:Jo,getAnimatableNone:Mc};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 kc({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)},Nc=[qs,Nt,Xt],Dc=e=>Nc.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=kc(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 Rc(e,t){return Ks.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function Vc(e,t){return n=>de(e,t,n)}function kr(e){return typeof e=="number"?Vc:typeof e=="string"?Ar(e)?cs:pe.test(e)?di:Lc:Array.isArray(e)?Zo:typeof e=="object"?pe.test(e)?di:Ic: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 Ic(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 Oc(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 Lc=(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?Rc(e,t):Fn(Zo(Oc(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 $c=e=>{const t=({timestamp:n})=>e(n);return{start:(n=!0)=>ce.update(t,n),stop:()=>pt(t),now:()=>we.isProcessing?we.timestamp:ke.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 Fc(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:Le(r)}}const Bc=5;function ta(e,t,n){const s=Math.max(t-Bc,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 Uc({duration:e=ue.duration,bounce:t=ue.bounce,velocity:n=ue.velocity,mass:s=ue.mass}){let r,o;en(e<=qe(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,Le(e)),i<1?(r=u=>{const d=u*i,h=d*e,m=d-n,p=Gs(u,i),S=Math.exp(-h);return Ns-m/p*S},o=u=>{const h=u*i*e,m=h*n+n,p=Math.pow(i,2)*Math.pow(u,2)*e,S=Math.exp(-h),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),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=_c(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 zc=12;function _c(e,t,n){let s=n;for(let r=1;r<zc;r++)s=s-e(s)/t(s);return s}function Gs(e,t){return e*Math.sqrt(1-t*t)}const Xc=["duration","bounce"],Wc=["stiffness","damping","mass"];function hi(e,t){return t.some(n=>e[n]!==void 0)}function qc(e){let t={velocity:ue.velocity,stiffness:ue.stiffness,damping:ue.damping,mass:ue.mass,isResolvedFromDuration:!1,...e};if(!hi(e,Wc)&&hi(e,Xc))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=Uc(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:h,velocity:m,isResolvedFromDuration:p}=qc({...n,velocity:-Le(n.velocity||0)}),S=m||0,v=u/(2*Math.sqrt(l*d)),C=i-o,b=Le(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 D=Gs(b,v);E=I=>{const N=Math.exp(-v*b*I);return i-N*((S+v*b*C)/D*Math.sin(D*I)+C*Math.cos(D*I))}}else if(v===1)E=D=>i-Math.exp(-b*D)*(C+(S+b*C)*D);else{const D=b*Math.sqrt(v*v-1);E=I=>{const N=Math.exp(-v*b*I),j=Math.min(D*I,300);return i-N*((S+v*b*C)*Math.sinh(j)+D*C*Math.cosh(j))/D}}const $={calculatedDuration:p&&h||null,next:D=>{const I=E(D);if(p)a.done=D>=h;else{let N=D===0?S:0;v<1&&(N=D===0?qe(S):ta(E,D,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 D=Math.min(Nr($),us),I=ea(N=>$.next(D*N).value,D,30);return D+"ms "+I},toTransition:()=>{}};return $}ds.applyToOptions=e=>{const t=Fc(e,100,ds);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,S=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 M=j=>-v*Math.exp(-j/s),E=j=>b+M(j),$=j=>{const O=M(j),A=E(j);m.done=Math.abs(O)<=u,m.value=m.done?b:A};let D,I;const N=j=>{p(m.value)&&(D=j,I=ds({keyframes:[m.value,S(m.value)],velocity:ta(E,j,m.value),damping:r,stiffness:o,restDelta:u,restSpeed:d}))};return N(0),{calculatedDuration:null,next:j=>{let O=!1;return!I&&D===void 0&&(O=!0,$(j),N(j)),D!==void 0&&j>=D?I.next(j-D):(!O&&$(j),m)}}}function Kc(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]||$e:t;a=Fn(l,a)}s.push(a)}return s}function Gc(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=Kc(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=Rn(e[h],e[h+1],d);return a[h](m)};return n?d=>u(it(e[0],e[o-1],d)):u}function Yc(e,t){const n=e[e.length-1];for(let s=1;s<=t;s++){const r=Rn(0,t,s);e.push(de(n,1,r))}}function Hc(e){const t=[0];return Yc(t,e.length-1),t}function Jc(e,t){return e.map(n=>n*t)}function Zc(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=uc(s)?s.map(ai):ai(s),o={done:!1,value:t[0]},i=Jc(n&&n.length===t.length?n:Hc(t),e),a=Gc(i,t,{ease:Array.isArray(r)?r:Zc(t,r)});return{calculatedDuration:e,next:l=>(o.value=a(l),o.done=l>=e,o)}}const Qc=e=>e!==null;function Dr(e,{repeat:t,repeatType:n="loop"},s,r=1){const o=e.filter(Qc),a=r<0||t&&n!=="loop"&&t%2===1?0:o.length-1;return!a||s===void 0?o[a]:s}const eu={decay:Ys,inertia:Ys,tween:Wt,keyframes:Wt,spring:ds};function na(e){typeof e.type=="string"&&(e.type=eu[e.type])}class Rr{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 tu=e=>e/100;class Vr extends Rr{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!==ke.now()&&this.tick(ke.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(tu,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:h,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(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)),E=it(0,1,A)*a}const D=M?{done:!1,value:d[0]}:$.next(E);o&&(D.value=o(D.value));let{done:I}=D;!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&&(D.value=Dr(d,this.options,C,this.speed)),v&&v(D.value),N&&this.finish(),D}then(t,n){return this.finished.then(t,n)}get duration(){return Le(this.calculatedDuration)}get iterationDuration(){const{delay:t=0}=this.options||{};return this.duration+Le(t)}get time(){return Le(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(ke.now());const n=this.playbackSpeed!==t;this.playbackSpeed=t,n&&(this.time=Le(this.currentTime))}play(){if(this.isStopped)return;const{driver:t=$c,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(ke.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 nu(e){for(let t=1;t<e.length;t++)e[t]??(e[t]=e[t-1])}const Dt=e=>e*180/Math.PI,Hs=e=>{const t=Dt(Math.atan2(e[1],e[0]));return Js(t)},su={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=>Dt(Math.atan(e[1])),skewY:e=>Dt(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),fi=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]),ru={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(Dt(Math.atan2(e[6],e[5]))),rotateY:e=>Js(Dt(Math.atan2(-e[2],e[0]))),rotateZ:fi,rotate:fi,skewX:e=>Dt(Math.atan(e[4])),skewY:e=>Dt(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=ru,r=n;else{const a=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);s=su,r=a}if(!r)return Zs(t);const o=s[t],i=r[1].split(",").map(ou);return typeof o=="function"?o(i):i[o]}const iu=(e,t)=>{const{transform:n="none"}=getComputedStyle(e);return Qs(n,t)};function ou(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===z,au=new Set(["x","y","z"]),lu=nn.filter(e=>!au.has(e));function cu(e){const t=[];return lu.forEach(n=>{const s=e.getValue(n);s!==void 0&&(t.push([n,s.get()]),s.set(n.startsWith("scale")?1:0))}),t}const Rt={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")};Rt.translateX=Rt.x;Rt.translateY=Rt.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=cu(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 uu(){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])}nu(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 du=e=>e.startsWith("--");function hu(e,t,n){du(t)?e.style.setProperty(t,n):e.style[t]=n}const fu=wr(()=>window.ScrollTimeline!==void 0),mu={};function pu(e,t){const n=wr(e);return()=>mu[t]??n()}const ia=pu(()=>{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 gu(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=oa(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 aa(e){return typeof e=="function"&&"applyToOptions"in e}function yu({type:e,...t}){return aa(e)&&ia()?e.applyToOptions(t):(t.duration??(t.duration=300),t.ease??(t.ease="easeOut"),t)}class xu extends Rr{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=yu(t);this.animation=gu(n,s,r,u,o),u.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!o){const d=Dr(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 Le(Number(t))}get iterationDuration(){const{delay:t=0}=this.options||{};return this.duration+Le(t)}get time(){return Le(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&&fu()?(this.animation.timeline=t,$e):n(this)}}const la={anticipate:Bo,backInOut:Fo,circInOut:zo};function bu(e){return e in la}function vu(e){typeof e.ease=="string"&&bu(e.ease)&&(e.ease=la[e.ease])}const xi=10;class wu extends xu{constructor(t){vu(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=qe(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 Su(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 Tu(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:Su(e)||(n==="spring"||aa(n))&&s}function sr(e){e.duration=0,e.type="keyframes"}const Cu=new Set(["opacity","clipPath","filter","transform"]),ju=wr(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function Pu(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 ju()&&n&&Cu.has(n)&&(n!=="transform"||!u)&&!l&&!s&&r!=="mirror"&&o!==0&&i!=="inertia"}const Au=40;class Eu extends Rr{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=ke.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,(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=ke.now(),Tu(t,o,i,a)||((at.instantAnimations||!l)&&d?.(Dr(t,s,n)),t[0]=t[t.length-1],sr(s),s.repeat=0);const m={startTime:r?this.resolvedAt?this.resolvedAt-this.createdAt>Au?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...s,keyframes:t},p=!u&&Pu(m)?new wu({...m,element:m.motionValue.owner.current}):new Vr(m);p.finished.then(()=>this.notifyFinished()).catch($e),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(),uu()),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 Mu=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function ku(e){const t=Mu.exec(e);if(!t)return[,];const[,n,s,r]=t;return[`--${n??s}`,r]}const Nu=4;function ca(e,t,n=1){ot(n<=Nu,`Max CSS variable fallback depth detected in property "${e}". This may indicate a circular fallback dependency.`,"max-css-var-depth");const[s,r]=ku(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),ha=[tn,z,tt,mt,Sc,wc,Du],vi=e=>ha.find(da(e));function Ru(e){return typeof e=="number"?e===0:e!==null?e==="none"||e==="0"||Ro(e):!0}const Vu=new Set(["brightness","contrast","saturate","opacity"]);function Iu(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=Vu.has(t)?1:0;return s!==n&&(o*=100),t+"("+o+r+")"}const Ou=/\b([a-z-]*)\(.*?\)/gu,rr={...gt,getAnimatableNone:e=>{const t=e.match(Ou);return t?t.map(Iu).join(" "):e}},wi={...tn,transform:Math.round},Lu={rotate:mt,rotateX:mt,rotateY:mt,rotateZ:mt,scale:Zn,scaleX:Zn,scaleY:Zn,scaleZ:Zn,skew:mt,skewX:mt,skewY:mt,distance:z,translateX:z,translateY:z,translateZ:z,x:z,y:z,z,perspective:z,transformPerspective:z,opacity:Vn,originX:li,originY:li,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,...Lu,zIndex:wi,fillOpacity:Vn,strokeOpacity:Vn,numOctaves:wi},$u={...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},fa=e=>$u[e];function ma(e,t){let n=fa(e);return n!==rr&&(n=gt),n.getAnimatableNone?n.getAnimatableNone(t):void 0}const Fu=new Set(["auto","none","0"]);function Bu(e,t,n){let s=0,r;for(;s<e.length&&!r;){const o=e[s];typeof o=="string"&&!Fu.has(o)&&In(o).values.length&&(r=e[s]),s++}if(r&&n)for(const o of t)e[o]=ma(n,r)}class Uu 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 Rt[s]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:t,name:n}=this,s=[];for(let r=0;r<t.length;r++)(t[r]===null||Ru(t[r]))&&s.push(r);s.length&&Bu(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=Rt[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]=Rt[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 zu(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 Do(e)&&"offsetHeight"in e}const Si=30,_u=e=>!isNaN(parseFloat(e));class Xu{constructor(t,n={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=s=>{const r=ke.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=ke.now(),this.canTrackVelocity===null&&t!==void 0&&(this.canTrackVelocity=_u(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=ke.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 Xu(e,t)}const{schedule:$r}=Wo(queueMicrotask,!1),Xe={x:!1,y:!1};function ya(){return Xe.x||Xe.y}function Wu(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 xa(e,t){const n=zu(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 qu(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=h=>{Ti(h)&&(u(h),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,Ku=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function Gu(e){return Ku.has(e.tagName)||e.tabIndex!==-1}const is=new WeakSet;function Ci(e){return t=>{t.key==="Enter"&&e(t)}}function Ds(e,t){e.dispatchEvent(new PointerEvent("pointer"+t,{isPrimary:!0,bubbles:!0}))}const Yu=(e,t)=>{const n=e.currentTarget;if(!n)return;const s=Ci(()=>{if(is.has(n))return;Ds(n,"down");const r=Ci(()=>{Ds(n,"up")}),o=()=>Ds(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 Hu(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",h),window.removeEventListener("pointercancel",m),is.has(l)&&is.delete(l),ji(p)&&typeof u=="function"&&u(p,{success:S})},h=p=>{d(p,l===window||l===document||n.useGlobalTarget||ba(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),ga(a)&&(a.addEventListener("focus",u=>Yu(u,r)),!Gu(a)&&!a.hasAttribute("tabindex")&&(a.tabIndex=0))}),o}function va(e){return Do(e)&&"ownerSVGElement"in e}function Ju(e){return va(e)&&e.tagName==="svg"}const Ce=e=>!!(e&&e.getVelocity),Zu=[...ha,pe,gt],Qu=e=>Zu.find(da(e)),Br=f.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 ed(...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 td(...e){return We.useCallback(ed(...e),e)}class nd extends We.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 sd({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=td(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 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(`
3
3
  [data-motion-pop-id="${r}"] {
4
4
  position: absolute !important;
5
5
  width: ${u}px !important;
@@ -7,9 +7,9 @@
7
7
  ${S}px !important;
8
8
  top: ${h}px !important;
9
9
  }
10
- `),()=>{T.contains(w)&&T.removeChild(w)}},[t]),c.jsx(Ju,{isPresent:t,childRef:o,sizeRef:i,children:_e.cloneElement(e,{ref:l})})}const Qu=({children:e,initial:t,isPresent:n,onExitComplete:s,custom:r,presenceAffectsLayout:o,mode:i,anchorX:a,root:l})=>{const u=fr(ed),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 S of u.values())if(!S)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,S)=>u.set(S,!1))},[n]),_e.useEffect(()=>{!n&&!u.size&&s&&s()},[n]),i==="popLayout"&&(e=c.jsx(Zu,{isPresent:n,anchorX:a,root:l,children:e})),c.jsx(ds.Provider,{value:m,children:e})};function ed(){return new Map}function ya(e=!0){const t=f.useContext(ds);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 Yn=e=>e.key||"";function Ti(e){const t=[];return f.Children.forEach(e,n=>{f.isValidElement(n)&&t.push(n)}),t}const td=({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]=ya(i),h=f.useMemo(()=>Ti(e),[e]),m=i&&!u?[]:h.map(Yn),p=f.useRef(!0),S=f.useRef(h),w=fr(()=>new Map),[T,v]=f.useState(h),[M,E]=f.useState(h);Po(()=>{p.current=!1,S.current=h;for(let I=0;I<M.length;I++){const N=Yn(M[I]);m.includes(N)?w.delete(N):w.get(N)!==!0&&w.set(N,!1)}},[M,m.length,m.join("-")]);const $=[];if(h!==T){let I=[...h];for(let N=0;N<M.length;N++){const j=M[N],O=Yn(j);m.includes(O)||(I.splice(N,0,j),$.push(j))}return o==="wait"&&$.length&&(I=$),E(Ti(I)),v(h),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:D}=f.useContext(hr);return c.jsx(c.Fragment,{children:M.map(I=>{const N=Yn(I),j=i&&!u?!1:h===M||m.includes(N),O=()=>{if(w.has(N))w.set(N,!0);else return;let A=!0;w.forEach(k=>{k||(A=!1)}),A&&(D?.(),E(S.current),i&&d?.(),s&&s())};return c.jsx(Qu,{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)})})},Lr=f.createContext({strict:!1}),Ci={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"]},Yt={};for(const e in Ci)Yt[e]={isEnabled:t=>Ci[e].some(n=>!!t[n])};function tr(e){for(const t in e)Yt[t]={...Yt[t],...e[t]}}function nd({children:e,features:t,strict:n=!1}){const[,s]=f.useState(!Ms(t)),r=f.useRef(void 0);if(!Ms(t)){const{renderer:o,...i}=t;r.current=o,tr(i)}return f.useEffect(()=>{Ms(t)&&t().then(({renderer:o,...i})=>{tr(i),r.current=o,s(!0)})},[]),c.jsx(Lr.Provider,{value:{renderer:r.current,strict:n},children:e})}function Ms(e){return typeof e=="function"}const sd=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 ls(e){return e.startsWith("while")||e.startsWith("drag")&&e!=="draggable"||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||sd.has(e)}let xa=e=>!ls(e);function rd(e){typeof e=="function"&&(xa=t=>t.startsWith("on")?!ls(t):e(t))}try{rd(require("@emotion/is-prop-valid").default)}catch{}function id(e,t,n){const s={};for(const r in e)r==="values"&&typeof e.values=="object"||(xa(r)||n===!0&&ls(r)||!t&&!ls(r)||e.draggable&&r.startsWith("onDrag"))&&(s[r]=e[r]);return s}const hs=f.createContext({});function fs(e){return e!==null&&typeof e=="object"&&typeof e.start=="function"}function Dn(e){return typeof e=="string"||Array.isArray(e)}const $r=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],Fr=["initial",...$r];function ms(e){return fs(e.animate)||Fr.some(t=>Dn(e[t]))}function ba(e){return!!(ms(e)||e.variants)}function od(e,t){if(ms(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 ad(e){const{initial:t,animate:n}=od(e,f.useContext(hs));return f.useMemo(()=>({initial:t,animate:n}),[ji(t),ji(n)])}function ji(e){return Array.isArray(e)?e.join(" "):e}const Rn={};function ld(e){for(const t in e)Rn[t]=e[t],Sr(t)&&(Rn[t].isCSSVariable=!0)}function va(e,{layout:t,layoutId:n}){return Qt.has(e)||e.startsWith("origin")||(t||n!==void 0)&&(!!Rn[e]||e==="opacity")}const cd={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},ud=Zt.length;function dd(e,t,n){let s="",r=!0;for(let o=0;o<ud;o++){const i=Zt[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=da(a,Rr[i]);if(!l){r=!1;const d=cd[i]||i;s+=`${d}(${u}) `}n&&(t[i]=u)}}return s=s.trim(),n?s=n(t,r?"":s):r&&(s="none"),s}function Br(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(Qt.has(l)){i=!0;continue}else if(Sr(l)){r[l]=u;continue}else{const d=da(u,Rr[l]);l.startsWith("origin")?(a=!0,o[l]=d):s[l]=d}}if(t.transform||(i||n?s.transform=dd(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 Ur=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function wa(e,t,n){for(const s in t)!Te(t[s])&&!va(s,n)&&(e[s]=t[s])}function hd({transformTemplate:e},t){return f.useMemo(()=>{const n=Ur();return Br(n,t,e),Object.assign({},n.vars,n.style)},[t])}function fd(e,t){const n=e.style||{},s={};return wa(s,n,e),Object.assign(s,hd(e,t)),s}function md(e,t){const n={},s=fd(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 pd={offset:"stroke-dashoffset",array:"stroke-dasharray"},gd={offset:"strokeDashoffset",array:"strokeDasharray"};function yd(e,t,n=1,s=0,r=!0){e.pathLength=1;const o=r?pd:gd;e[o.offset]=U.transform(-s);const i=U.transform(t),a=U.transform(n);e[o.array]=`${i} ${a}`}function Sa(e,{attrX:t,attrY:n,attrScale:s,pathLength:r,pathSpacing:o=1,pathOffset:i=0,...a},l,u,d){if(Br(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&&yd(h,r,o,i,!1)}const Ta=()=>({...Ur(),attrs:{}}),Ca=e=>typeof e=="string"&&e.toLowerCase()==="svg";function xd(e,t,n,s){const r=f.useMemo(()=>{const o=Ta();return Sa(o,t,Ca(s),e.transformTemplate,e.style),{...o.attrs,style:{...o.style}}},[t]);if(e.style){const o={};wa(o,e.style,e),r.style={...o,...r.style}}return r}const bd=["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 zr(e){return typeof e!="string"||e.includes("-")?!1:!!(bd.indexOf(e)>-1||/[A-Z]/u.test(e))}function vd(e,t,n,{latestValues:s},r,o=!1){const a=(zr(e)?xd:md)(t,s,r,e),l=id(t,typeof e=="string",o),u=e!==f.Fragment?{...l,...a,ref:n}:{},{children:d}=t,h=f.useMemo(()=>Te(d)?d.get():d,[d]);return f.createElement(e,{...u,children:h})}function Pi(e){const t=[{},{}];return e?.values.forEach((n,s)=>{t[0][s]=n.get(),t[1][s]=n.getVelocity()}),t}function _r(e,t,n,s){if(typeof t=="function"){const[r,o]=Pi(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]=Pi(s);t=t(n!==void 0?n:e.custom,r,o)}return t}function ns(e){return Te(e)?e.get():e}function wd({scrapeMotionValuesFromProps:e,createRenderState:t},n,s,r){return{latestValues:Sd(n,s,r,e),renderState:t()}}function Sd(e,t,n,s){const r={},o=s(e,{});for(const m in o)r[m]=ns(o[m]);let{initial:i,animate:a}=e;const l=ms(e),u=ba(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"&&!fs(h)){const m=Array.isArray(h)?h:[h];for(let p=0;p<m.length;p++){const S=_r(e,m[p]);if(S){const{transitionEnd:w,transition:T,...v}=S;for(const M in v){let E=v[M];if(Array.isArray(E)){const $=d?E.length-1:0;E=E[$]}E!==null&&(r[M]=E)}for(const M in w)r[M]=w[M]}}}return r}const ja=e=>(t,n)=>{const s=f.useContext(hs),r=f.useContext(ds),o=()=>wd(e,t,s,r);return n?o():fr(o)};function Xr(e,t,n){const{style:s}=e,r={};for(const o in s)(Te(s[o])||t.style&&Te(t.style[o])||va(o,e)||n?.getValue(o)?.liveStyle!==void 0)&&(r[o]=s[o]);return r}const Td=ja({scrapeMotionValuesFromProps:Xr,createRenderState:Ur});function Pa(e,t,n){const s=Xr(e,t,n);for(const r in e)if(Te(e[r])||Te(t[r])){const o=Zt.indexOf(r)!==-1?"attr"+r.charAt(0).toUpperCase()+r.substring(1):r;s[o]=e[r]}return s}const Cd=ja({scrapeMotionValuesFromProps:Pa,createRenderState:Ta}),jd=Symbol.for("motionComponentSymbol");function zt(e){return e&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"current")}function Pd(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):zt(n)&&(n.current=s))},[t])}const Wr=e=>e.replace(/([a-z])([A-Z])/gu,"$1-$2").toLowerCase(),Ad="framerAppearId",Aa="data-"+Wr(Ad),Ea=f.createContext({});function Ed(e,t,n,s,r){const{visualElement:o}=f.useContext(hs),i=f.useContext(Lr),a=f.useContext(ds),l=f.useContext(Or).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(Ea);d&&!d.projection&&r&&(d.type==="html"||d.type==="svg")&&Md(u.current,n,r,h);const m=f.useRef(!1);f.useInsertionEffect(()=>{d&&m.current&&d.update(n,a)});const p=n[Aa],S=f.useRef(!!p&&!window.MotionHandoffIsComplete?.(p)&&window.MotionHasOptimisedAnimation?.(p));return Po(()=>{d&&(m.current=!0,window.MotionIsMounted=!0,d.updateFeatures(),d.scheduleRenderMicrotask(),S.current&&d.animationState&&d.animationState.animateChanges())}),f.useEffect(()=>{d&&(!S.current&&d.animationState&&d.animationState.animateChanges(),S.current&&(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(p)}),S.current=!1),d.enteringChildren=void 0)}),d}function Md(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:Ma(e.parent)),e.projection.setOptions({layoutId:r,layout:o,alwaysMeasureLayout:!!i||a&&zt(a),visualElement:e,animationType:typeof o=="string"?o:"both",initialPromotionConfig:s,crossfade:d,layoutScroll:l,layoutRoot:u})}function Ma(e){if(e)return e.options.allowProjection!==!1?e.projection:Ma(e.parent)}function ss(e,{forwardMotionProps:t=!1}={},n,s){n&&tr(n);const r=zr(e)?Cd:Td;function o(a,l){let u;const d={...f.useContext(Or),...a,layoutId:kd(a)},{isStatic:h}=d,m=ad(a),p=r(a,h);if(!h&&mr){Nd(d,n);const S=Dd(d);u=S.MeasureLayout,m.visualElement=Ed(e,p,d,s,S.ProjectionNode)}return c.jsxs(hs.Provider,{value:m,children:[u&&m.visualElement?c.jsx(u,{visualElement:m.visualElement,...d}):null,vd(e,a,Pd(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[jd]=e,i}function kd({layoutId:e}){const t=f.useContext(hr).id;return t&&e!==void 0?t+"-"+e:e}function Nd(e,t){const n=f.useContext(Lr).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?Ht(!1,s,"lazy-strict-mode"):st(!1,s,"lazy-strict-mode")}}function Dd(e){const{drag:t,layout:n}=Yt;if(!t&&!n)return{};const s={...t,...n};return{MeasureLayout:t?.isEnabled(e)||n?.isEnabled(e)?s.MeasureLayout:void 0,ProjectionNode:s.ProjectionNode}}function Rd(e,t){if(typeof Proxy>"u")return ss;const n=new Map,s=(o,i)=>ss(o,i,e,t),r=(o,i)=>(process.env.NODE_ENV!=="production"&&br(!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,ss(i,void 0,e,t)),n.get(i))})}function ka({top:e,left:t,right:n,bottom:s}){return{x:{min:t,max:n},y:{min:e,max:s}}}function Vd({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function Id(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 ks(e){return e===void 0||e===1}function nr({scale:e,scaleX:t,scaleY:n}){return!ks(e)||!ks(t)||!ks(n)}function At(e){return nr(e)||Na(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function Na(e){return Ai(e.x)||Ai(e.y)}function Ai(e){return e&&e!=="0%"}function cs(e,t,n){const s=e-n,r=t*s;return n+r}function Ei(e,t,n,s,r){return r!==void 0&&(e=cs(e,r,s)),cs(e,n,s)+t}function sr(e,t=0,n=1,s,r){e.min=Ei(e.min,t,n,s,r),e.max=Ei(e.max,t,n,s,r)}function Da(e,{x:t,y:n}){sr(e.x,t.translate,t.scale,t.originPoint),sr(e.y,n.translate,n.scale,n.originPoint)}const Mi=.999999999999,ki=1.0000000000001;function Od(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&&Xt(e,{x:-o.scroll.offset.x,y:-o.scroll.offset.y}),i&&(t.x*=i.x.scale,t.y*=i.y.scale,Da(e,i)),s&&At(o.latestValues)&&Xt(e,o.latestValues))}t.x<ki&&t.x>Mi&&(t.x=1),t.y<ki&&t.y>Mi&&(t.y=1)}function _t(e,t){e.min=e.min+t,e.max=e.max+t}function Ni(e,t,n,s,r=.5){const o=de(e.min,e.max,r);sr(e,t,n,o,s)}function Xt(e,t){Ni(e.x,t.x,t.scaleX,t.scale,t.originX),Ni(e.y,t.y,t.scaleY,t.scale,t.originY)}function Ra(e,t){return ka(Id(e.getBoundingClientRect(),t))}function Ld(e,t,n){const s=Ra(e,n),{scroll:r}=t;return r&&(_t(s.x,r.offset.x),_t(s.y,r.offset.y)),s}const Di=()=>({translate:0,scale:1,origin:0,originPoint:0}),Wt=()=>({x:Di(),y:Di()}),Ri=()=>({min:0,max:0}),me=()=>({x:Ri(),y:Ri()}),rr={current:null},Va={current:!1};function $d(){if(Va.current=!0,!!mr)if(window.matchMedia){const e=window.matchMedia("(prefers-reduced-motion)"),t=()=>rr.current=e.matches;e.addEventListener("change",t),t()}else rr.current=!1}const Fd=new WeakMap;function Bd(e,t,n){for(const s in t){const r=t[s],o=n[s];if(Te(r))e.addValue(s,r);else if(Te(o))e.addValue(s,Gt(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,Gt(i!==void 0?i:r,{owner:e}))}}for(const s in n)t[s]===void 0&&e.removeValue(s);return t}const Vi=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];class Ud{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=Nr,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=Me.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=ms(n),this.isVariantNode=ba(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&&Te(p)&&p.set(l[m])}}mount(t){this.current=t,Fd.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)),Va.current||$d(),this.shouldReduceMotion=this.reducedMotionConfig==="never"?!1:this.reducedMotionConfig==="always"?!0:rr.current,process.env.NODE_ENV!=="production"&&br(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(),ht(this.notifyUpdate),ht(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=Qt.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 Yt){const n=Yt[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<Vi.length;s++){const r=Vi[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=Bd(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=Gt(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"&&(Ao(s)||Mo(s))?s=parseFloat(s):!Gu(s)&&ft.test(n)&&(s=ua(t,n)),this.setBaseTarget(t,Te(s)?s.get():s)),Te(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=_r(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&&!Te(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 xr),this.events[t].add(n)}notify(t,...n){this.events[t]&&this.events[t].notify(...n)}scheduleRenderMicrotask(){Vr.render(this.render)}}class Ia extends Ud{constructor(){super(...arguments),this.KeyframeResolver=Ou}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;Te(t)&&(this.childSubscription=t.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}function Oa(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 zd(e){return window.getComputedStyle(e)}class _d extends Ia{constructor(){super(...arguments),this.type="html",this.renderInstance=Oa}readValueFromInstance(t,n){if(Qt.has(n))return this.projection?.isProjecting?Gs(n):eu(t,n);{const s=zd(t),r=(Sr(n)?s.getPropertyValue(n):s[n])||0;return typeof r=="string"?r.trim():r}}measureInstanceViewportBox(t,{transformPagePoint:n}){return Ra(t,n)}build(t,n,s){Br(t,n,s.transformTemplate)}scrapeMotionValuesFromProps(t,n,s){return Xr(t,n,s)}}const La=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 Xd(e,t,n,s){Oa(e,t,void 0,s);for(const r in t.attrs)e.setAttribute(La.has(r)?r:Wr(r),t.attrs[r])}class Wd extends Ia{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=me}getBaseTargetFromProps(t,n){return t[n]}readValueFromInstance(t,n){if(Qt.has(n)){const s=ca(n);return s&&s.default||0}return n=La.has(n)?n:Wr(n),t.getAttribute(n)}scrapeMotionValuesFromProps(t,n,s){return Pa(t,n,s)}build(t,n,s){Sa(t,n,this.isSVGTag,s.transformTemplate,s.style)}renderInstance(t,n,s,r){Xd(t,n,s,r)}mount(t){this.isSVGTag=Ca(t.tagName),super.mount(t)}}const $a=(e,t)=>zr(e)?new Wd(t):new _d(t,{allowProjection:e!==f.Fragment});function Kt(e,t,n){const s=e.getProps();return _r(s,t,n!==void 0?n:s.custom,e)}const ir=e=>Array.isArray(e);function qd(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,Gt(n))}function Kd(e){return ir(e)?e[e.length-1]||0:e}function Gd(e,t){const n=Kt(e,t);let{transitionEnd:s={},transition:r={},...o}=n||{};o={...o,...s};for(const i in o){const a=Kd(o[i]);qd(e,i,a)}}function Yd(e){return!!(Te(e)&&e.add)}function or(e,t){const n=e.getValue("willChange");if(Yd(n))return n.add(t);if(!n&&rt.WillChange){const s=new rt.WillChange("auto");e.addValue("willChange",s),s.add(t)}}function Fa(e){return e.props[Aa]}const Hd=e=>e!==null;function Jd(e,{repeat:t,repeatType:n="loop"},s){const r=e.filter(Hd),o=t&&n!=="loop"&&t%2===1?0:r.length-1;return r[o]}const Zd={type:"spring",stiffness:500,damping:25,restSpeed:10},Qd=e=>({type:"spring",stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),eh={type:"keyframes",duration:.8},th={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},nh=(e,{keyframes:t})=>t.length>2?eh:Qt.has(e)?e.startsWith("scale")?Qd(t[1]):Zd:th;function sh({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 qr=(e,t,n,s={},r,o)=>i=>{const a=Dr(s,e)||{},l=a.delay||s.delay||0;let{elapsed:u=0}=s;u=u-Xe(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};sh(a)||Object.assign(d,nh(e,d)),d.duration&&(d.duration=Xe(d.duration)),d.repeatDelay&&(d.repeatDelay=Xe(d.repeatDelay)),d.from!==void 0&&(d.keyframes[0]=d.from);let h=!1;if((d.type===!1||d.duration===0&&!d.repeatDelay)&&(Qs(d),d.delay===0&&(h=!0)),(rt.instantAnimations||rt.skipAnimations)&&(h=!0,Qs(d),d.delay=0),d.allowFlatten=!a.type&&!a.ease,h&&!o&&t.get()!==void 0){const m=Jd(d.keyframes,a);if(m!==void 0){ce.update(()=>{d.onUpdate(m),d.onComplete()});return}}return a.isSync?new kr(d):new Tu(d)};function rh({protectedKeys:e,needsAnimating:t},n){const s=e.hasOwnProperty(n)&&t[n]!==!0;return t[n]=!1,s}function Ba(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&&rh(u,d))continue;const p={delay:n,...Dr(o||{},d)},S=h.get();if(S!==void 0&&!h.isAnimating&&!Array.isArray(m)&&m===S&&!p.velocity)continue;let w=!1;if(window.MotionHandoffAnimation){const v=Fa(e);if(v){const M=window.MotionHandoffAnimation(v,d,ce);M!==null&&(p.startTime=M,w=!0)}}or(e,d),h.start(qr(d,h,m,e.shouldReduceMotion&&oa.has(d)?{type:!1}:p,e,w));const T=h.animation;T&&l.push(T)}return i&&Promise.all(l).then(()=>{ce.update(()=>{i&&Gd(e,i)})}),l}function Ua(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 ar(e,t,n={}){const s=Kt(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(Ba(e,s,n)):()=>Promise.resolve(),i=e.variantChildren&&e.variantChildren.size?(l=0)=>{const{delayChildren:u=0,staggerChildren:d,staggerDirection:h}=r;return ih(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 ih(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(ar(l,t,{...i,delay:n+(typeof s=="function"?0:s)+Ua(e.variantChildren,l,s,r,o)}).then(()=>l.notify("AnimationComplete",t)));return Promise.all(a)}function oh(e,t,n={}){e.notify("AnimationStart",t);let s;if(Array.isArray(t)){const r=t.map(o=>ar(e,o,n));s=Promise.all(r)}else if(typeof t=="string")s=ar(e,t,n);else{const r=typeof t=="function"?Kt(e,t,n.custom):t;s=Promise.all(Ba(e,r,n))}return s.then(()=>{e.notify("AnimationComplete",t)})}function za(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 ah=Fr.length;function _a(e){if(!e)return;if(!e.isControllingVariants){const n=e.parent?_a(e.parent)||{}:{};return e.props.initial!==void 0&&(n.initial=e.props.initial),n}const t={};for(let n=0;n<ah;n++){const s=Fr[n],r=e.props[s];(Dn(r)||r===!1)&&(t[s]=r)}return t}const lh=[...$r].reverse(),ch=$r.length;function uh(e){return t=>Promise.all(t.map(({animation:n,options:s})=>oh(e,n,s)))}function dh(e){let t=uh(e),n=Ii(),s=!0;const r=l=>(u,d)=>{const h=Kt(e,d,l==="exit"?e.presenceContext?.custom:void 0);if(h){const{transition:m,transitionEnd:p,...S}=h;u={...u,...S,...p}}return u};function o(l){t=l(e)}function i(l){const{props:u}=e,d=_a(e.parent)||{},h=[],m=new Set;let p={},S=1/0;for(let T=0;T<ch;T++){const v=lh[T],M=n[v],E=u[v]!==void 0?u[v]:d[v],$=Dn(E),D=v===l?M.isActive:null;D===!1&&(S=T);let I=E===d[v]&&E!==u[v]&&$;if(I&&s&&e.manuallyAnimateOnMount&&(I=!1),M.protectedKeys={...p},!M.isActive&&D===null||!E&&!M.prevProp||fs(E)||typeof E=="boolean")continue;const N=hh(M.prevProp,E);let j=N||v===l&&M.isActive&&!I&&$||T>S&&$,O=!1;const A=Array.isArray(E)?E:[E];let k=A.reduce(r(v),{});D===!1&&(k={});const{prevResolvedValues:F={}}=M,V={...F,...k},B=K=>{j=!0,m.has(K)&&(O=!0,m.delete(K)),M.needsAnimating[K]=!0;const ie=e.getValue(K);ie&&(ie.liveStyle=!1)};for(const K in V){const ie=k[K],ye=F[K];if(p.hasOwnProperty(K))continue;let We=!1;ir(ie)&&ir(ye)?We=!za(ie,ye):We=ie!==ye,We?ie!=null?B(K):m.add(K):ie!==void 0&&m.has(K)?B(K):M.protectedKeys[K]=!0}M.prevProp=E,M.prevResolvedValues=k,M.isActive&&(p={...p,...k}),s&&e.blockInitialAnimation&&(j=!1);const X=I&&N;j&&(!X||O)&&h.push(...A.map(K=>{const ie={type:v};if(typeof K=="string"&&s&&!X&&e.manuallyAnimateOnMount&&e.parent){const{parent:ye}=e,We=Kt(ye,K);if(ye.enteringChildren&&We){const{delayChildren:pt}=We.transition||{};ie.delay=Ua(ye.enteringChildren,e,pt)}}return{animation:K,options:ie}}))}if(m.size){const T={};if(typeof u.initial!="boolean"){const v=Kt(e,Array.isArray(u.initial)?u.initial[0]:u.initial);v&&v.transition&&(T.transition=v.transition)}m.forEach(v=>{const M=e.getBaseTarget(v),E=e.getValue(v);E&&(E.liveStyle=!0),T[v]=M??null}),h.push({animation:T})}let w=!!h.length;return s&&(u.initial===!1||u.initial===u.animate)&&!e.manuallyAnimateOnMount&&(w=!1),s=!1,w?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=Ii()}}}function hh(e,t){return typeof t=="string"?t!==e:Array.isArray(t)?!za(t,e):!1}function jt(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function Ii(){return{animate:jt(!0),whileInView:jt(),whileHover:jt(),whileTap:jt(),whileDrag:jt(),whileFocus:jt(),exit:jt()}}class mt{constructor(t){this.isMounted=!1,this.node=t}update(){}}class fh extends mt{constructor(t){super(t),t.animationState||(t.animationState=dh(t))}updateAnimationControlsSubscription(){const{animate:t}=this.node.getProps();fs(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 mh=0;class ph extends mt{constructor(){super(...arguments),this.id=mh++}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 Xa={animation:{Feature:fh},exit:{Feature:ph}};function Vn(e,t,n,s={passive:!0}){return e.addEventListener(t,n,s),()=>e.removeEventListener(t,n)}function $n(e){return{point:{x:e.pageX,y:e.pageY}}}const gh=e=>t=>Ir(t)&&e(t,$n(t));function jn(e,t,n,s){return Vn(e,t,gh(n),s)}const Wa=1e-4,yh=1-Wa,xh=1+Wa,qa=.01,bh=0-qa,vh=0+qa;function Ae(e){return e.max-e.min}function wh(e,t,n){return Math.abs(e-t)<=n}function Oi(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>=yh&&e.scale<=xh||isNaN(e.scale))&&(e.scale=1),(e.translate>=bh&&e.translate<=vh||isNaN(e.translate))&&(e.translate=0)}function Pn(e,t,n,s){Oi(e.x,t.x,n.x,s?s.originX:void 0),Oi(e.y,t.y,n.y,s?s.originY:void 0)}function Li(e,t,n){e.min=n.min+t.min,e.max=e.min+Ae(t)}function Sh(e,t,n){Li(e.x,t.x,n.x),Li(e.y,t.y,n.y)}function $i(e,t,n){e.min=t.min-n.min,e.max=e.min+Ae(t)}function An(e,t,n){$i(e.x,t.x,n.x),$i(e.y,t.y,n.y)}function Re(e){return[e("x"),e("y")]}const Ka=({current:e})=>e?e.ownerDocument.defaultView:null,Fi=(e,t)=>Math.abs(e-t);function Th(e,t){const n=Fi(e.x,t.x),s=Fi(e.y,t.y);return Math.sqrt(n**2+s**2)}class Ga{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=Ds(this.lastMoveEventInfo,this.history),p=this.startEvent!==null,S=Th(m.offset,{x:0,y:0})>=this.distanceThreshold;if(!p&&!S)return;const{point:w}=m,{timestamp:T}=ve;this.history.push({...w,timestamp:T});const{onStart:v,onMove:M}=this.handlers;p||(v&&v(this.lastMoveEvent,m),this.startEvent=this.lastMoveEvent),M&&M(this.lastMoveEvent,m)},this.handlePointerMove=(m,p)=>{this.lastMoveEvent=m,this.lastMoveEventInfo=Ns(p,this.transformPagePoint),ce.update(this.updatePoint,!0)},this.handlePointerUp=(m,p)=>{this.end();const{onEnd:S,onSessionEnd:w,resumeAnimation:T}=this.handlers;if(this.dragSnapToOrigin&&T&&T(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const v=Ds(m.type==="pointercancel"?this.lastMoveEventInfo:Ns(p,this.transformPagePoint),this.history);this.startEvent&&S&&S(m,v),w&&w(m,v)},!Ir(t))return;this.dragSnapToOrigin=o,this.handlers=n,this.transformPagePoint=s,this.distanceThreshold=i,this.contextWindow=r||window;const a=$n(t),l=Ns(a,this.transformPagePoint),{point:u}=l,{timestamp:d}=ve;this.history=[{...u,timestamp:d}];const{onSessionStart:h}=n;h&&h(t,Ds(l,this.history)),this.removeListeners=In(jn(this.contextWindow,"pointermove",this.handlePointerMove),jn(this.contextWindow,"pointerup",this.handlePointerUp),jn(this.contextWindow,"pointercancel",this.handlePointerUp))}updateHandlers(t){this.handlers=t}end(){this.removeListeners&&this.removeListeners(),ht(this.updatePoint)}}function Ns(e,t){return t?{point:t(e.point)}:e}function Bi(e,t){return{x:e.x-t.x,y:e.y-t.y}}function Ds({point:e},t){return{point:e,delta:Bi(e,Ya(t)),offset:Bi(e,Ch(t)),velocity:jh(t,.1)}}function Ch(e){return e[0]}function Ya(e){return e[e.length-1]}function jh(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,s=null;const r=Ya(e);for(;n>=0&&(s=e[n],!(r.timestamp-s.timestamp>Xe(t)));)n--;if(!s)return{x:0,y:0};const o=Ie(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 Ph(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 Ui(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 Ah(e,{top:t,left:n,bottom:s,right:r}){return{x:Ui(e.x,n,r),y:Ui(e.y,t,s)}}function zi(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 Eh(e,t){return{x:zi(e.x,t.x),y:zi(e.y,t.y)}}function Mh(e,t){let n=.5;const s=Ae(e),r=Ae(t);return r>s?n=Mn(t.min,t.max-s,e.min):s>r&&(n=Mn(e.min,e.max-r,t.min)),nt(0,1,n)}function kh(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 lr=.35;function Nh(e=lr){return e===!1?e=0:e===!0&&(e=lr),{x:_i(e,"left","right"),y:_i(e,"top","bottom")}}function _i(e,t,n){return{min:Xi(e,t),max:Xi(e,n)}}function Xi(e,t){return typeof e=="number"?e:e[t]||0}const Dh=new WeakMap;class Rh{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($n(h).point)},i=(h,m)=>{const{drag:p,dragPropagation:S,onDragStart:w}=this.getProps();if(p&&!S&&(this.openDragLock&&this.openDragLock(),this.openDragLock=Bu(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),Re(v=>{let M=this.getAxisMotionValue(v).get()||0;if(Ze.test(M)){const{projection:E}=this.visualElement;if(E&&E.layout){const $=E.layout.layoutBox[v];$&&(M=Ae($)*(parseFloat(M)/100))}}this.originPoint[v]=M}),w&&ce.postRender(()=>w(h,m)),or(this.visualElement,"transform");const{animationState:T}=this.visualElement;T&&T.setActive("whileDrag",!0)},a=(h,m)=>{this.latestPointerEvent=h,this.latestPanInfo=m;const{dragPropagation:p,dragDirectionLock:S,onDirectionLock:w,onDrag:T}=this.getProps();if(!p&&!this.openDragLock)return;const{offset:v}=m;if(S&&this.currentDirection===null){this.currentDirection=Vh(v),this.currentDirection!==null&&w&&w(this.currentDirection);return}this.updateAxis("x",m.point,v),this.updateAxis("y",m.point,v),this.visualElement.render(),T&&T(h,m)},l=(h,m)=>{this.latestPointerEvent=h,this.latestPanInfo=m,this.stop(h,m),this.latestPointerEvent=null,this.latestPanInfo=null},u=()=>Re(h=>this.getAnimationState(h)==="paused"&&this.getAxisMotionValue(h).animation?.play()),{dragSnapToOrigin:d}=this.getProps();this.panSession=new Ga(t,{onSessionStart:o,onStart:i,onMove:a,onSessionEnd:l,resumeAnimation:u},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:d,distanceThreshold:s,contextWindow:Ka(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||!Hn(t,r,this.currentDirection))return;const o=this.getAxisMotionValue(t);let i=this.originPoint[t]+s[t];this.constraints&&this.constraints[t]&&(i=Ph(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&&zt(t)?this.constraints||(this.constraints=this.resolveRefConstraints()):t&&s?this.constraints=Ah(s.layoutBox,t):this.constraints=!1,this.elastic=Nh(n),r!==this.constraints&&s&&this.constraints&&!this.hasMutatedConstraints&&Re(o=>{this.constraints!==!1&&this.getAxisMotionValue(o)&&(this.constraints[o]=kh(s.layoutBox[o],this.constraints[o]))})}resolveRefConstraints(){const{dragConstraints:t,onMeasureDragConstraints:n}=this.getProps();if(!t||!zt(t))return!1;const s=t.current;st(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=Ld(s,r.root,this.visualElement.getTransformPagePoint());let i=Eh(r.layout.layoutBox,o);if(n){const a=n(Vd(i));this.hasMutatedConstraints=!!a,a&&(i=ka(a))}return i}startAnimation(t){const{drag:n,dragMomentum:s,dragElastic:r,dragTransition:o,dragSnapToOrigin:i,onDragTransitionEnd:a}=this.getProps(),l=this.constraints||{},u=Re(d=>{if(!Hn(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,S={type:"inertia",velocity:s?t[d]:0,bounceStiffness:m,bounceDamping:p,timeConstant:750,restDelta:1,restSpeed:10,...o,...h};return this.startAxisValueAnimation(d,S)});return Promise.all(u).then(a)}startAxisValueAnimation(t,n){const s=this.getAxisMotionValue(t);return or(this.visualElement,t),s.start(qr(t,s,0,n,this.visualElement,!1))}stopAnimation(){Re(t=>this.getAxisMotionValue(t).stop())}pauseAnimation(){Re(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){Re(n=>{const{drag:s}=this.getProps();if(!Hn(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(!zt(n)||!s||!this.constraints)return;this.stopAnimation();const r={x:0,y:0};Re(i=>{const a=this.getAxisMotionValue(i);if(a&&this.constraints!==!1){const l=a.get();r[i]=Mh({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(),Re(i=>{if(!Hn(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;Dh.set(this.visualElement,this);const t=this.visualElement.current,n=jn(t,"pointerdown",l=>{const{drag:u,dragListener:d=!0}=this.getProps();u&&d&&this.start(l)}),s=()=>{const{dragConstraints:l}=this.getProps();zt(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=Vn(window,"resize",()=>this.scalePositionWithinConstraints()),a=r.addEventListener("didUpdate",({delta:l,hasLayoutChanged:u})=>{this.isDragging&&u&&(Re(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=lr,dragMomentum:a=!0}=t;return{...t,drag:n,dragDirectionLock:s,dragPropagation:r,dragConstraints:o,dragElastic:i,dragMomentum:a}}}function Hn(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function Vh(e,t=10){let n=null;return Math.abs(e.y)>t?n="y":Math.abs(e.x)>t&&(n="x"),n}class Ih extends mt{constructor(t){super(t),this.removeGroupControls=Oe,this.removeListeners=Oe,this.controls=new Rh(t)}mount(){const{dragControls:t}=this.node.getProps();t&&(this.removeGroupControls=t.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||Oe}unmount(){this.removeGroupControls(),this.removeListeners()}}const Wi=e=>(t,n)=>{e&&ce.postRender(()=>e(t,n))};class Oh extends mt{constructor(){super(...arguments),this.removePointerDownListener=Oe}onPointerDown(t){this.session=new Ga(t,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:Ka(this.node)})}createPanHandlers(){const{onPanSessionStart:t,onPanStart:n,onPan:s,onPanEnd:r}=this.node.getProps();return{onSessionStart:Wi(t),onStart:Wi(n),onMove:s,onEnd:(o,i)=>{delete this.session,r&&ce.postRender(()=>r(o,i))}}}mount(){this.removePointerDownListener=jn(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 rs={hasAnimatedSinceResize:!0,hasEverUpdated:!1};function qi(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}const vn={correct:(e,t)=>{if(!t.target)return e;if(typeof e=="string")if(U.test(e))e=parseFloat(e);else return e;const n=qi(e,t.target.x),s=qi(e,t.target.y);return`${n}% ${s}%`}},Lh={correct:(e,{treeScale:t,projectionDelta:n})=>{const s=e,r=ft.parse(e);if(r.length>5)return s;const o=ft.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 Rs=!1;class $h extends f.Component{componentDidMount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:s,layoutId:r}=this.props,{projection:o}=t;ld(Fh),o&&(n.group&&n.group.add(o),s&&s.register&&r&&s.register(o),Rs&&o.root.didUpdate(),o.addEventListener("animationComplete",()=>{this.safeToRemove()}),o.setOptions({...o.options,onExitComplete:()=>this.safeToRemove()})),rs.hasEverUpdated=!0}getSnapshotBeforeUpdate(t){const{layoutDependency:n,visualElement:s,drag:r,isPresent:o}=this.props,{projection:i}=s;return i&&(i.isPresent=o,Rs=!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(),Vr.postRender(()=>{!t.currentAnimation&&t.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:s}=this.props,{projection:r}=t;Rs=!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 Ha(e){const[t,n]=ya(),s=f.useContext(hr);return c.jsx($h,{...e,layoutGroup:s,switchLayoutGroup:f.useContext(Ea),isPresent:t,safeToRemove:n})}const Fh={borderRadius:{...vn,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:vn,borderTopRightRadius:vn,borderBottomLeftRadius:vn,borderBottomRightRadius:vn,boxShadow:Lh};function Bh(e,t,n){const s=Te(e)?e:Gt(e);return s.start(qr("",s,t,n)),s.animation}const Uh=(e,t)=>e.depth-t.depth;class zh{constructor(){this.children=[],this.isDirty=!1}add(t){pr(this.children,t),this.isDirty=!0}remove(t){gr(this.children,t),this.isDirty=!0}forEach(t){this.isDirty&&this.children.sort(Uh),this.isDirty=!1,this.children.forEach(t)}}function _h(e,t){const n=Me.now(),s=({timestamp:r})=>{const o=r-n;o>=t&&(ht(s),e(o-t))};return ce.setup(s,!0),()=>ht(s)}const Ja=["TopLeft","TopRight","BottomLeft","BottomRight"],Xh=Ja.length,Ki=e=>typeof e=="string"?parseFloat(e):e,Gi=e=>typeof e=="number"||U.test(e);function Wh(e,t,n,s,r,o){r?(e.opacity=de(0,n.opacity??1,qh(s)),e.opacityExit=de(t.opacity??1,0,Kh(s))):o&&(e.opacity=de(t.opacity??1,n.opacity??1,s));for(let i=0;i<Xh;i++){const a=`border${Ja[i]}Radius`;let l=Yi(t,a),u=Yi(n,a);if(l===void 0&&u===void 0)continue;l||(l=0),u||(u=0),l===0||u===0||Gi(l)===Gi(u)?(e[a]=Math.max(de(Ki(l),Ki(u),s),0),(Ze.test(u)||Ze.test(l))&&(e[a]+="%")):e[a]=u}(t.rotate||n.rotate)&&(e.rotate=de(t.rotate||0,n.rotate||0,s))}function Yi(e,t){return e[t]!==void 0?e[t]:e.borderRadius}const qh=Za(0,.5,Lo),Kh=Za(.5,.95,Oe);function Za(e,t,n){return s=>s<e?0:s>t?1:n(Mn(e,t,s))}function Hi(e,t){e.min=t.min,e.max=t.max}function De(e,t){Hi(e.x,t.x),Hi(e.y,t.y)}function Ji(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}function Zi(e,t,n,s,r){return e-=t,e=cs(e,1/n,s),r!==void 0&&(e=cs(e,1/r,s)),e}function Gh(e,t=0,n=1,s=.5,r,o=e,i=e){if(Ze.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=Zi(e.min,t,n,a,r),e.max=Zi(e.max,t,n,a,r)}function Qi(e,t,[n,s,r],o,i){Gh(e,t[n],t[s],t[r],t.scale,o,i)}const Yh=["x","scaleX","originX"],Hh=["y","scaleY","originY"];function eo(e,t,n,s){Qi(e.x,t,Yh,n?n.x:void 0,s?s.x:void 0),Qi(e.y,t,Hh,n?n.y:void 0,s?s.y:void 0)}function to(e){return e.translate===0&&e.scale===1}function Qa(e){return to(e.x)&&to(e.y)}function no(e,t){return e.min===t.min&&e.max===t.max}function Jh(e,t){return no(e.x,t.x)&&no(e.y,t.y)}function so(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function el(e,t){return so(e.x,t.x)&&so(e.y,t.y)}function ro(e){return Ae(e.x)/Ae(e.y)}function io(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}class Zh{constructor(){this.members=[]}add(t){pr(this.members,t),t.scheduleRender()}remove(t){if(gr(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 Qh(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:S}=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) `),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 Vs=["","X","Y","Z"],ef=1e3;let tf=0;function Is(e,t,n,s){const{latestValues:r}=t;r[e]&&(n[e]=r[e],t.setStaticValue(e,0),s&&(s[e]=0))}function tl(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;const{visualElement:t}=e.options;if(!t)return;const n=Fa(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&&tl(s)}function nl({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:s,resetTransform:r}){return class{constructor(i={},a=t?.()){this.id=tf++,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(rf),this.nodes.forEach(cf),this.nodes.forEach(uf),this.nodes.forEach(of)},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 zh)}addEventListener(i,a){return this.eventHandlers.has(i)||this.eventHandlers.set(i,new xr),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=ga(i)&&!qu(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;ce.read(()=>{h=window.innerWidth}),e(i,()=>{const p=window.innerWidth;p!==h&&(h=p,this.root.updateBlockedByResize=!0,d&&d(),d=_h(m,250),rs.hasAnimatedSinceResize&&(rs.hasAnimatedSinceResize=!1,this.nodes.forEach(lo)))})}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 S=this.options.transition||u.getDefaultTransition()||pf,{onLayoutAnimationStart:w,onLayoutAnimationComplete:T}=u.getProps(),v=!this.targetLayout||!el(this.targetLayout,p),M=!h&&m;if(this.options.layoutRoot||this.resumeFrom||M||h&&(v||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const E={...Dr(S,"layout"),onPlay:w,onComplete:T};(u.shouldReduceMotion||this.options.layoutRoot)&&(E.delay=0,E.type=!1),this.startAnimation(E),this.setAnimationOrigin(d,M)}else h||lo(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(),ht(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(df),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&&tl(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(oo);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(ao);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(lf),this.nodes.forEach(nf),this.nodes.forEach(sf)):this.nodes.forEach(ao),this.clearAllSnapshots();const a=Me.now();ve.delta=nt(0,1e3/60,a-ve.timestamp),ve.timestamp=a,ve.isProcessing=!0,Ts.update.process(ve),Ts.preRender.process(ve),Ts.render.process(ve),ve.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,Vr.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(af),this.sharedNodes.forEach(hf)}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&&!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&&!Qa(this.projectionDelta),l=this.getTransformTemplate(),u=l?l(this.latestValues,""):void 0,d=u!==this.prevTransformTemplateValue;i&&this.instance&&(a||At(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)),gf(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(yf))){const{scroll:u}=this.root;u&&(_t(a.x,u.offset.x),_t(a.y,u.offset.y))}return a}removeElementScroll(i){const a=me();if(De(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&&De(a,i),_t(a.x,d.offset.x),_t(a.y,d.offset.y))}return a}applyTransform(i,a=!1){const l=me();De(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&&Xt(l,{x:-d.scroll.offset.x,y:-d.scroll.offset.y}),At(d.latestValues)&&Xt(l,d.latestValues)}return At(this.latestValues)&&Xt(l,this.latestValues),l}removeTransform(i){const a=me();De(a,i);for(let l=0;l<this.path.length;l++){const u=this.path[l];if(!u.instance||!At(u.latestValues))continue;nr(u.latestValues)&&u.updateSnapshot();const d=me(),h=u.measurePageBox();De(d,h),eo(a,u.latestValues,u.snapshot?u.snapshot.layoutBox:void 0,d)}return At(this.latestValues)&&eo(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(),An(this.relativeTargetOrigin,this.layout.layoutBox,m.layout.layoutBox),De(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(),Sh(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):De(this.target,this.layout.layoutBox),Da(this.target,this.targetDelta)):De(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(),An(this.relativeTargetOrigin,this.target,m.target),De(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}}}getClosestProjectingParent(){if(!(!this.parent||nr(this.parent.latestValues)||Na(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;De(this.layoutCorrected,this.layout.layoutBox);const h=this.treeScale.x,m=this.treeScale.y;Od(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():(Ji(this.prevProjectionDelta.x,this.projectionDelta.x),Ji(this.prevProjectionDelta.y,this.projectionDelta.y)),Pn(this.projectionDelta,this.layoutCorrected,p,this.latestValues),(this.treeScale.x!==h||this.treeScale.y!==m||!io(this.projectionDelta.x,this.prevProjectionDelta.x)||!io(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=Wt(),this.projectionDelta=Wt(),this.projectionDeltaWithTransform=Wt()}setAnimationOrigin(i,a=!1){const l=this.snapshot,u=l?l.latestValues:{},d={...this.latestValues},h=Wt();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!a;const m=me(),p=l?l.source:void 0,S=this.layout?this.layout.source:void 0,w=p!==S,T=this.getStack(),v=!T||T.members.length<=1,M=!!(w&&!v&&this.options.crossfade===!0&&!this.path.some(mf));this.animationProgress=0;let E;this.mixTargetDelta=$=>{const D=$/1e3;co(h.x,i.x,D),co(h.y,i.y,D),this.setTargetDelta(h),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(An(m,this.layout.layoutBox,this.relativeParent.layout.layoutBox),ff(this.relativeTarget,this.relativeTargetOrigin,m,D),E&&Jh(this.relativeTarget,E)&&(this.isProjectionDirty=!1),E||(E=me()),De(E,this.relativeTarget)),w&&(this.animationValues=d,Wh(d,u,this.latestValues,D,M,v)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=D},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(i){this.notifyListeners("animationStart"),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&(ht(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=ce.update(()=>{rs.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=Gt(0)),this.currentAnimation=Bh(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(ef),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&&sl(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}De(a,l),Xt(a,d),Pn(this.projectionDeltaWithTransform,this.layoutCorrected,a,d)}}registerSharedNode(i,a){this.sharedNodes.has(i)||this.sharedNodes.set(i,new Zh),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&&Is("z",i,u,this.animationValues);for(let d=0;d<Vs.length;d++)Is(`rotate${Vs[d]}`,i,u,this.animationValues),Is(`skew${Vs[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=ns(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=ns(a?.pointerEvents)||""),this.hasProjected&&!At(this.latestValues)&&(i.transform=l?l({},""):"none",this.hasProjected=!1);return}i.visibility="";const d=u.animationValues||u.latestValues;this.applyTransformsToTarget();let h=Qh(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 S in Rn){if(d[S]===void 0)continue;const{correct:w,applyTo:T,isCSSVariable:v}=Rn[S],M=h==="none"?d[S]:w(d[S],u);if(T){const E=T.length;for(let $=0;$<E;$++)i[T[$]]=M}else v?this.options.visualElement.renderState.vars[S]=M:i[S]=M}this.options.layoutId&&(i.pointerEvents=u===this?ns(a?.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(i=>i.currentAnimation?.stop()),this.root.nodes.forEach(oo),this.root.sharedNodes.clear()}}}function nf(e){e.updateLayout()}function sf(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"?Re(d=>{const h=o?t.measuredBox[d]:t.layoutBox[d],m=Ae(h);h.min=n[d].min,h.max=h.min+m}):sl(r,t.layoutBox,n)&&Re(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=Wt();Pn(i,n,t.layoutBox);const a=Wt();o?Pn(a,e.applyTransform(s,!0),t.measuredBox):Pn(a,n,t.layoutBox);const l=!Qa(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();An(p,t.layoutBox,h.layoutBox);const S=me();An(S,n,m.layoutBox),el(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 rf(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 of(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function af(e){e.clearSnapshot()}function oo(e){e.clearMeasurements()}function ao(e){e.isLayoutDirty=!1}function lf(e){const{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify("BeforeLayoutMeasure"),e.resetTransform()}function lo(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function cf(e){e.resolveTargetDelta()}function uf(e){e.calcProjection()}function df(e){e.resetSkewAndRotation()}function hf(e){e.removeLeadSnapshot()}function co(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 uo(e,t,n,s){e.min=de(t.min,n.min,s),e.max=de(t.max,n.max,s)}function ff(e,t,n,s){uo(e.x,t.x,n.x,s),uo(e.y,t.y,n.y,s)}function mf(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}const pf={duration:.45,ease:[.4,0,.1,1]},ho=e=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),fo=ho("applewebkit/")&&!ho("chrome/")?Math.round:Oe;function mo(e){e.min=fo(e.min),e.max=fo(e.max)}function gf(e){mo(e.x),mo(e.y)}function sl(e,t,n){return e==="position"||e==="preserve-aspect"&&!wh(ro(t),ro(n),.2)}function yf(e){return e!==e.root&&e.scroll?.wasRoot}const xf=nl({attachResizeListener:(e,t)=>Vn(e,"resize",t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0}),Os={current:void 0},rl=nl({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!Os.current){const e=new xf({});e.mount(window),e.setOptions({layoutScroll:!0}),Os.current=e}return Os.current},resetTransform:(e,t)=>{e.style.transform=t!==void 0?t:"none"},checkIsScrollRoot:e=>window.getComputedStyle(e).position==="fixed"}),bf={pan:{Feature:Oh},drag:{Feature:Ih,ProjectionNode:rl,MeasureLayout:Ha}};function po(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,$n(t)))}class vf extends mt{mount(){const{current:t}=this.node;t&&(this.unmount=Uu(t,(n,s)=>(po(this.node,s,"Start"),r=>po(this.node,r,"End"))))}unmount(){}}class wf extends mt{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=In(Vn(this.node.current,"focus",()=>this.onFocus()),Vn(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function go(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,$n(t)))}class Sf extends mt{mount(){const{current:t}=this.node;t&&(this.unmount=Wu(t,(n,s)=>(go(this.node,s,"Start"),(r,{success:o})=>go(this.node,r,o?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}const cr=new WeakMap,Ls=new WeakMap,Tf=e=>{const t=cr.get(e.target);t&&t(e)},Cf=e=>{e.forEach(Tf)};function jf({root:e,...t}){const n=e||document;Ls.has(n)||Ls.set(n,{});const s=Ls.get(n),r=JSON.stringify(t);return s[r]||(s[r]=new IntersectionObserver(Cf,{root:e,...t})),s[r]}function Pf(e,t,n){const s=jf(t);return cr.set(e,n),s.observe(e),()=>{cr.delete(e),s.unobserve(e)}}const Af={some:0,all:1};class Ef extends mt{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:Af[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 Pf(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(Mf(t,n))&&this.startObserver()}unmount(){}}function Mf({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}const il={inView:{Feature:Ef},tap:{Feature:Sf},focus:{Feature:wf},hover:{Feature:vf}},kf={layout:{ProjectionNode:rl,MeasureLayout:Ha}},Nf={...Xa,...il,...bf,...kf},Df=Rd(Nf,$a),Rf={renderer:$a,...Xa,...il};function Kr(e,t){return ss(e,t)}const Vf=Kr("button"),Jn=Kr("div"),If=Kr("p");function Of({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(Ce,{size:"sm",variant:"ghost",className:"h-6 px-2 text-xs",onClick:s,children:[c.jsx(te.Check,{className:"h-3 w-3 mr-1"}),"Approve"]}),c.jsx(Ce,{size:"sm",variant:"ghost",className:"h-6 px-2 text-xs text-muted-foreground",onClick:r,children:c.jsx(te.X,{className:"h-3 w-3"})})]})]})})}function Lf({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(te.ChevronDown,{className:"h-3 w-3"}):c.jsx(te.ChevronRight,{className:"h-3 w-3"})}),n?c.jsx(te.X,{className:"h-3 w-3"}):s?c.jsx(te.Zap,{className:"h-3 w-3"}):c.jsx(te.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 $f({...e}){return c.jsx(ur.Root,{"data-slot":"collapsible",...e})}function Ff({...e}){return c.jsx(ur.CollapsibleTrigger,{"data-slot":"collapsible-trigger",...e})}function Bf({...e}){return c.jsx(ur.CollapsibleContent,{"data-slot":"collapsible-content",...e})}const Uf=f.lazy(()=>import("streamdown").then(e=>({default:e.Streamdown}))),Gr=f.memo(({className:e,...t})=>typeof window>"u"?null:c.jsx(f.Suspense,{fallback:null,children:c.jsx(Uf,{className:ne("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",e),...t})}),(e,t)=>e.children===t.children);Gr.displayName="Response";const zf=Object.freeze(Object.defineProperty({__proto__:null,Response:Gr},Symbol.toStringTag,{value:"Module"})),_f=({children:e,as:t="p",className:n,duration:s=2,spread:r=2})=>{const o=Df.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})},Xf=f.memo(_f),ol=f.createContext(null),Wf=()=>{const e=f.useContext(ol);if(!e)throw new Error("Reasoning components must be used within Reasoning");return e},qf=1e3,Kf=1e3,al=f.memo(({className:e,isStreaming:t=!1,open:n,defaultOpen:s=!0,onOpenChange:r,duration:o,children:i,...a})=>{const[l,u]=Qr.useControllableState({prop:n,defaultProp:s,onChange:r}),[d,h]=Qr.useControllableState({prop:o,defaultProp:0}),[m,p]=f.useState(!1),[S,w]=f.useState(null);f.useEffect(()=>{t?S===null&&w(Date.now()):S!==null&&(h(Math.ceil((Date.now()-S)/Kf)),w(null))},[t,S,h]),f.useEffect(()=>{if(s&&!t&&l&&!m){const v=setTimeout(()=>{u(!1),p(!0)},qf);return()=>clearTimeout(v)}},[t,l,s,u,m]);const T=v=>{u(v)};return c.jsx(ol.Provider,{value:{isStreaming:t,isOpen:l,setIsOpen:u,duration:d},children:c.jsx($f,{className:ne("not-prose mb-4",e),onOpenChange:T,open:l,...a,children:i})})}),Gf=(e,t)=>e||t===0?c.jsx(Xf,{duration:1,children:"Thinking..."}):t===void 0?c.jsx("p",{children:"Thought for a few seconds"}):c.jsxs("p",{children:["Thought for ",t," seconds"]}),ll=f.memo(({className:e,children:t,...n})=>{const{isStreaming:s,isOpen:r,duration:o}=Wf();return c.jsx(Ff,{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(te.BrainIcon,{className:"size-4"}),Gf(s,o),c.jsx(te.ChevronDownIcon,{className:ne("size-4 transition-transform",r?"rotate-180":"rotate-0")})]})})}),cl=f.memo(({className:e,children:t,...n})=>c.jsx(Bf,{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(Gr,{className:"grid gap-2",children:t})}));al.displayName="Reasoning";ll.displayName="ReasoningTrigger";cl.displayName="ReasoningContent";function yo(e){return`https://www.google.com/s2/favicons?domain=${encodeURIComponent(e)}&sz=16`}function Yf({sources:e,citationNumber:t,className:n}){const s=e.find(o=>o.number===t);if(!s)return null;const r=yo(s.domain);return c.jsxs(lt,{children:[c.jsx(ct,{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(ut,{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:yo(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 Hf({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 T=u.current;let v,M=!1;const E=new WeakSet,$=()=>{if(!u.current||M)return;M=!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&&!E.has(A)){const F=A,V=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(V.matchAll(N)).filter(ie=>{if(!ie[1])return!1;const ye=parseInt(ie[1],10);return n.has(ye)});K.length>0&&O.push({node:F,matches:K})}}if(O.length===0){M=!1;return}const k=[];O.forEach(({node:F,matches:V})=>{E.add(F);const B=F.textContent||"",X=document.createDocumentFragment();let Y=0;V.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 ye=parseInt(K[1],10);ie.setAttribute("data-citation",K[1]),X.appendChild(ie),k.push({element:ie,citationNum:ye}),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 V=new Set(F.map(Y=>Y.element)),B=F.filter(Y=>Y.element.isConnected),X=k.filter(Y=>!V.has(Y.element));return[...B,...X]}),M=!1},D=new MutationObserver(()=>{clearTimeout(v),v=setTimeout($,100)});return D.observe(T,{childList:!0,subtree:!0,characterData:!0}),v=setTimeout($,200),()=>{D.disconnect(),clearTimeout(v)}},[e,t,n,a]);const m=s&&s.length>0||n&&n.size>0||r;function p(T){return`https://www.google.com/s2/favicons?domain=${encodeURIComponent(T)}&sz=16`}function S(T){try{return new URL(T).hostname.replace(/^www\./,"")}catch{return T}}const w=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((T,v)=>{const M=T.title||T.baseUrl,E=S(T.url),$=p(E);return c.jsxs("a",{href:T.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:D=>{const I=D.target;I.style.display="none"}}),c.jsx("span",{className:"leading-none",children:M})]},`group-${v}`)}):Array.from(n.entries()).sort(([T],[v])=>T-v).map(([T,v])=>{const M=S(v),E=p(M);return c.jsxs("a",{href:v,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 D=$.target;D.style.display="none"}}),c.jsx("span",{className:"leading-none",children:v})]},T)})})]}):null;return c.jsxs("div",{className:i,children:[c.jsx("div",{ref:u,children:c.jsx(o,{children:e})}),a&&d.filter(({element:T})=>T.isConnected).map(({element:T,citationNum:v},M)=>{if(!t.find(D=>D.number===v))return null;const $=Array.from(new Map(t.map(D=>{const I=D.url.replace(/\/+$/,""),N=s?.find(j=>j.url.replace(/\/+$/,"")===I);return[I,{number:D.number,url:D.url,domain:S(D.url),title:N?.title}]})).values());return Al.createPortal(c.jsx(Yf,{sources:$,citationNumber:v},`citation-${v}-${T}`),T,`citation-${v}-${M}`)}),w]})}function en({...e}){return c.jsx(Dt.Root,{"data-slot":"dialog",...e})}function Jf({...e}){return c.jsx(Dt.Portal,{"data-slot":"dialog-portal",...e})}function Zf({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 tn({className:e,children:t,showCloseButton:n=!0,...s}){return c.jsxs(Jf,{"data-slot":"dialog-portal",children:[c.jsx(Zf,{}),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(te.XIcon,{}),c.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function nn({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 sn({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 rn({className:e,...t}){return c.jsx(Dt.Title,{"data-slot":"dialog-title",className:ne("text-lg leading-none font-semibold",e),...t})}function on({className:e,...t}){return c.jsx(Dt.Description,{"data-slot":"dialog-description",className:ne("text-muted-foreground text-sm",e),...t})}function an({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 Qf({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(en,{open:e,children:c.jsx(tn,{showCloseButton:!1,children:c.jsxs("form",{onSubmit:h,children:[c.jsxs(nn,{children:[c.jsx(rn,{children:t}),c.jsx(on,{children:n})]}),c.jsx("div",{className:"py-4",children:c.jsxs("div",{className:"relative",children:[c.jsx(an,{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(te.EyeOff,{className:"h-4 w-4"}):c.jsx(te.Eye,{className:"h-4 w-4"})})]})}),c.jsxs(sn,{children:[c.jsx(Ce,{type:"button",variant:"ghost",onClick:m,disabled:u,children:"Cancel"}),c.jsx(Ce,{type:"submit",disabled:!o.trim()||u,children:u?"Submitting...":"Submit"})]})]})})})}function em({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=w=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(w),m=w=>{i(w),w.trim()?l(h(w)):l(!0)},p=async w=>{if(w.preventDefault(),!o.trim()||!h(o)){l(!1);return}d(!0);try{r(o)}finally{d(!1)}},S=()=>{i(""),l(!0),r(null)};return c.jsx(en,{open:e,children:c.jsx(tn,{showCloseButton:!1,children:c.jsxs("form",{onSubmit:p,children:[c.jsxs(nn,{children:[c.jsxs(rn,{className:"flex items-center gap-2",children:[c.jsx(te.Mail,{className:"h-5 w-5"}),t]}),c.jsx(on,{children:n})]}),c.jsxs("div",{className:"py-4",children:[c.jsx(an,{type:"email",value:o,onChange:w=>m(w.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(sn,{children:[c.jsx(Ce,{type:"button",variant:"ghost",onClick:S,disabled:u,children:"Cancel"}),c.jsx(Ce,{type:"submit",disabled:!o.trim()||!a||u,children:u?"Submitting...":"Submit"})]})]})})})}function tm({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=T=>{const v=T.replace(/\D/g,"");return v.length<=3?v:v.length<=6?`(${v.slice(0,3)}) ${v.slice(3)}`:`(${v.slice(0,3)}) ${v.slice(3,6)}-${v.slice(6,10)}`},m=T=>T.replace(/\D/g,"").length===10,p=T=>{const v=h(T);i(v),v.trim()?l(m(v)):l(!0)},S=async T=>{if(T.preventDefault(),!o.trim()||!m(o)){l(!1);return}d(!0);try{const v=o.replace(/\D/g,"");r(v)}finally{d(!1)}},w=()=>{i(""),l(!0),r(null)};return c.jsx(en,{open:e,children:c.jsx(tn,{showCloseButton:!1,children:c.jsxs("form",{onSubmit:S,children:[c.jsxs(nn,{children:[c.jsxs(rn,{className:"flex items-center gap-2",children:[c.jsx(te.Phone,{className:"h-5 w-5"}),t]}),c.jsx(on,{children:n})]}),c.jsxs("div",{className:"py-4",children:[c.jsx(an,{type:"tel",value:o,onChange:T=>p(T.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(sn,{children:[c.jsx(Ce,{type:"button",variant:"ghost",onClick:w,disabled:u,children:"Cancel"}),c.jsx(Ce,{type:"submit",disabled:!o.trim()||!a||u,children:u?"Submitting...":"Submit"})]})]})})})}function nm({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 S=p.replace(/\D/g,"");a(S.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(en,{open:e,children:c.jsx(tn,{showCloseButton:!1,children:c.jsxs("form",{onSubmit:h,children:[c.jsxs(nn,{children:[c.jsxs(rn,{className:"flex items-center gap-2",children:[c.jsx(te.Shield,{className:"h-5 w-5"}),t]}),c.jsx(on,{children:n})]}),c.jsxs("div",{className:"py-4",children:[c.jsx(an,{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(sn,{children:[c.jsx(Ce,{type:"button",variant:"ghost",onClick:m,disabled:l,children:"Cancel"}),c.jsx(Ce,{type:"submit",disabled:i.length!==r||l,children:l?"Submitting...":"Submit"})]})]})})})}function $s({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(en,{open:e,children:c.jsx(tn,{showCloseButton:!1,children:c.jsxs("form",{onSubmit:d,children:[c.jsxs(nn,{children:[c.jsxs(rn,{className:"flex items-center gap-2",children:[c.jsx(te.Lock,{className:"h-5 w-5"}),t]}),c.jsx(on,{children:n})]}),c.jsx("div",{className:"py-4",children:c.jsx(an,{type:r,value:i,onChange:m=>a(m.target.value),placeholder:s,autoFocus:!0,disabled:l})}),c.jsxs(sn,{children:[c.jsx(Ce,{type:"button",variant:"ghost",onClick:h,disabled:l,children:"Cancel"}),c.jsx(Ce,{type:"submit",disabled:!i.trim()||l,children:l?"Submitting...":"Submit"})]})]})})})}function sm({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,S]=f.useState(!1),w=A=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(A)?null:"Please enter a valid email address",T=A=>A.replace(/\D/g,"").length===10?null:"Please enter a valid 10-digit phone number",v=(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=T(V));break;case"email":k.trim()&&(B=w(k));break;case"pin":V=k.replace(/\D/g,"").slice(0,6),V.trim()&&(B=v(V));break}!B&&F.validation&&V.trim()&&(B=F.validation(V)),l(X=>({...X,[A]:V})),d(X=>({...X,[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=w(V);break;case"phone":B=T(V);break;case"pin":B=v(V);break}!B&&F.validation&&(B=F.validation(V))}B&&(A[F.name]=B,k=!1)}),d(A),k},D=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]}))},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(en,{open:e,children:c.jsx(tn,{showCloseButton:!1,className:"max-w-md",children:c.jsxs("form",{onSubmit:D,children:[c.jsxs(nn,{children:[c.jsx(rn,{children:t}),n&&c.jsx(on,{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(an,{type:j(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:h[A.name]?c.jsx(te.EyeOff,{className:"h-4 w-4"}):c.jsx(te.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(te.AlertCircle,{className:"h-3 w-3"}),u[A.name]]})]},A.name))}),c.jsxs(sn,{children:[c.jsx(Ce,{type:"button",variant:"ghost",onClick:I,disabled:p,children:i}),c.jsx(Ce,{type:"submit",disabled:p,children:p?"Submitting...":o})]})]})})})}const ul=f.createContext(void 0);function dl(){const e=f.useContext(ul);if(!e)throw new Error("useSecureModal must be used within a SecureModalProvider");return e}function hl({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(S=>{n(p),o.current=S}),[]),l=f.useCallback(p=>new Promise(S=>{r(p),i.current=S}),[]),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 S=s.fields.map(w=>({name:w.name,type:w.type==="text"?"text":w.type==="password"?"password":w.type==="email"?"email":w.type==="phone"?"phone":w.type==="pin"?"pin":w.type==="ssn"?"ssn":w.type==="creditCard"?"creditCard":"text",label:w.label,placeholder:w.placeholder,required:w.required!==!1,value:w.value}));return c.jsx(sm,{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(Qf,{...p});case"email":return c.jsx(em,{...p});case"phone":return c.jsx(tm,{...p});case"pin":return c.jsx(nm,{...p});case"ssn":return c.jsx($s,{...p,title:t.title||"SSN Required",placeholder:t.placeholder||"XXX-XX-XXXX"});case"creditCard":return c.jsx($s,{...p,title:t.title||"Credit Card Required",placeholder:t.placeholder||"XXXX XXXX XXXX XXXX",type:"text"});case"text":default:return c.jsx($s,{...p})}},m=f.useMemo(()=>({showSecureModal:a,showSecureForm:l}),[a,l]);return c.jsxs(ul.Provider,{value:m,children:[e,h()]})}function rm(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 im(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 xo(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(/[.,;:!?]+$/,""),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,h=t;s&&s[0]&&(d=s[0],h=t.replace(n,""));const m=[];let p=0;const S=/```[\s\S]*?```|`[^`]+`/g;let w;for(;(w=S.exec(h))!==null;)w.index>p&&m.push({type:"text",content:h.slice(p,w.index),start:p,end:w.index}),m.push({type:"code",content:w[0],start:w.index,end:w.index+w[0].length}),p=w.index+w[0].length;p<h.length&&m.push({type:"text",content:h.slice(p),start:p,end:h.length});const T=m.map(j=>{if(j.type==="code")return j.content;let O=j.content;return O=O.replace(/\[(\d+)\]\((https?:\/\/[^\)]+)\)/g,(k,F,V)=>{const B=parseInt(F,10),X=V.replace(/\/+$/,""),Y=u.get(B)||B;return l.has(X)||(l.set(X,Y),r.has(Y)||(r.set(Y,V),o.push({number:Y,url:V}))),`[${Y}]`}),O=O.replace(/\[(\d+)\]/g,(k,F)=>{const V=parseInt(F,10);return`[${u.get(V)||V}]`}),O}),v=[];for(const[j,O]of l.entries()){const A=a.get(j)||j,{baseUrl:k,anchor:F}=rm(A),V=im(A);v.push({url:A,baseUrl:k,numbers:[O],anchor:F,title:V})}v.sort((j,O)=>(j.numbers[0]||0)-(O.numbers[0]||0));const M=new Map;let E=1;for(const j of v){const O=j.numbers[0];M.set(O,E),j.numbers=[E],E++}const $=new Map;for(const[j,O]of r.entries()){const A=M.get(j);A&&$.set(A,O)}const D=o.map(j=>{const O=M.get(j.number);return O?{number:O,url:j.url}:j}).filter(j=>M.has(j.number)),I=Array.from(M.entries()).sort((j,O)=>O[0]-j[0]);let N=T.join("");for(const[j,O]of I){const A=new RegExp(`\\[${j}\\](?!\\d)`,"g");N=N.replace(A,`[${O}]`)}return{processedText:N,citations:D.sort((j,O)=>j.number-O.number),citationMap:$,groupedCitations:v,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 Fs(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 om({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:S="",agentId:w,agentName:T,tokenEndpoint:v="/api/arcten/token",apiBaseUrl:M="https://api.arcten.com",user:E,state:$,onStateChange:D,allowStateEdits:I=!0,sources:N,ragConfig:j,showCitations:O=!0,sensitiveParams:A,autoDetectSensitive:k=!1}){const F=M.replace(/\/+$/,""),{showSecureModal:V}=dl(),B=Co({apiBaseUrl:F,tokenEndpoint:v,user:E,tools:d,safeTools:h,toolMetadata:p,sensitiveParams:A,autoDetectSensitive:k,agentId:w,agentName:T,state:$,onStateChange:D,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),[ye,We]=f.useState(600),[pt,Qe]=f.useState(!1),[G,Rt]=f.useState(!1),[Ee,gt]=f.useState(!1),[je,Le]=f.useState({x:100,y:100}),[ln,oe]=f.useState(!1),[cn,yt]=f.useState({x:0,y:0}),[un,Fn]=f.useState(!1),$e=f.useRef(null),xt=f.useRef(null),[bt,ke]=f.useState(""),[dn,ps]=f.useState(null),[Vt,Bn]=f.useState("Thinking..."),[vt,it]=f.useState(new Set),[gs,Un]=f.useState(""),[qe,ys]=f.useState([]),zn=f.useRef(new Map),It=f.useRef(!1),hn=f.useRef(""),[le,fn]=f.useState(!1),[Fe,we]=f.useState(!1),Ke=f.useMemo(()=>[...d,...h],[d,h]),Be=f.useMemo(()=>dr(Ke,p),[Ke,p]),Ot=f.useMemo(()=>{const C=new Map,_=new Map(Be.map(z=>[z.name,z]));return Ke.forEach(z=>{const Z=z[Ve];if(Z){const J=_.get(Z);if(J){C.set(J.name,z);return}}const H=Be.find(J=>J.name===z.name);H&&C.set(H.name,z)}),C},[Ke,Be]),wt=f.useMemo(()=>{const C=new Set,_=new Map(Be.map(z=>[z.name,z]));return h.forEach(z=>{const Z=z[Ve];if(Z&&_.has(Z))C.add(Z);else{const H=Be.find(J=>J.name===z.name);H&&C.add(H.name)}}),m&&Array.isArray(m)&&m.forEach(z=>{typeof z=="string"&&C.add(z)}),C},[h,Be,m]),St=["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 C=localStorage.getItem("arcten-sidebar-expanded");C&&Y(JSON.parse(C));const _=localStorage.getItem("arcten-sidebar-width");_&&ie(parseInt(_));const z=localStorage.getItem("arcten-sidebar-height");z&&We(parseInt(z));const Z=localStorage.getItem("arcten-sidebar-detached");Z&&Rt(JSON.parse(Z));const H=localStorage.getItem("arcten-sidebar-position");if(H){const ge=JSON.parse(H),se=50,Se=Math.max(se-i,Math.min(ge.x,window.innerWidth-se)),W=Math.max(0,Math.min(ge.y,window.innerHeight-se));Le({x:Se,y:W})}const J=localStorage.getItem("arcten-sidebar-minimized");J&&gt(JSON.parse(J)),Fn(!0)}},[]),f.useMemo(()=>E,[E?.id]),f.useEffect(()=>{(async()=>{if(Ke.length===0)return;const _=Ke.map(z=>`${z.name}:${z.toString()}`).join("|");if(_!==hn.current&&!It.current){It.current=!0,hn.current=_;try{const z=Ke.map(H=>({name:H.name,code:H.toString()})),Z=await fetch(`${F}/tools/describe`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tools:z})});if(Z.ok){const H=await Z.json();H.tools&&H.tools.forEach(J=>{zn.current.set(J.name,J)}),ys(H.tools)}}catch(z){console.error("Failed to fetch tool descriptions:",z)}finally{It.current=!1}}})()},[Ke,F]),f.useEffect(()=>{Promise.resolve().then(()=>zf).then(C=>{ps(()=>C.Response)})},[]),f.useEffect(()=>{const C=()=>{Un(window.location.pathname)};C(),window.addEventListener("popstate",C);const _=setInterval(C,500);return()=>{window.removeEventListener("popstate",C),clearInterval(_)}},[]);const{id:mn,messages:Ne,sendMessage:Tt,status:xe,error:_n,stop:Lt,addToolOutput:et,setMessages:Yr,clientToken:pn,tokenError:gn,conversations:Ge,isLoadingConversations:ot,loadConversation:$t,deleteConversation:Ue,startNewConversation:Ye}=B;f.useEffect(()=>{X&&xt.current&&xt.current.focus()},[X,Ne]),f.useEffect(()=>{const C=Ne[Ne.length-1];if(!C||C.role!=="assistant")return;const _=C.parts?.filter(z=>z.type?.startsWith("tool-")&&z.state==="input-available"&&typeof z.toolCallId=="string"&&z.input!==void 0)||[];for(const z of _){const Z=z,H=Z.type?.replace("tool-","")||"",J=Z.toolCallId;if(wt.has(H)){if(vt.has(J))continue;it(se=>se.has(J)?se:new Set(se).add(J)),(async()=>{try{const se=Ot.get(H);if(!se){console.warn(`[ArctenAgent] Tool ${H} not found in toolsMap`),et({toolCallId:J,tool:H,output:`Error: Tool ${H} not found`}),it(Q=>{const Pe=new Set(Q);return Pe.delete(J),Pe});return}const Se=Fs(Z.input),W=Be.find(Q=>Q.name===H);let he;if(W&&W.jsonSchema?.properties){const Pe=Object.keys(W.jsonSchema.properties).map(fe=>Se[fe]);he=await se(...Pe)}else he=await se(...Object.values(Se));et({toolCallId:J,tool:H,output:he}),it(Q=>{const Pe=new Set(Q);return Pe.delete(J),Pe})}catch(se){console.error(`[ArctenAgent] Error executing safe tool ${H}:`,se),et({toolCallId:J,tool:H,output:`Error: ${se instanceof Error?se.message:String(se)}`}),it(Se=>{const W=new Set(Se);return W.delete(J),W})}})()}}},[Ne,wt,Ot,Be,et,vt]);function Xn(){Y(!0),localStorage.setItem("arcten-sidebar-expanded","true")}function Wn(){Y(!1),localStorage.setItem("arcten-sidebar-expanded","false")}f.useEffect(()=>{},[X]),f.useEffect(()=>{$e.current&&$e.current.scrollIntoView({behavior:"smooth"})},[Ne]),f.useEffect(()=>{function C(_){_.key==="Escape"&&(xe==="streaming"||xe==="submitted")&&(_.preventDefault(),Lt())}return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[xe,Lt]);function tt(C){const _=Math.floor((Date.now()-C)/1e3);return _<60?"now":_<3600?`${Math.floor(_/60)}m`:_<86400?`${Math.floor(_/3600)}h`:`${Math.floor(_/86400)}d`}function Ct(){Ye(),we(!1)}function yn(C){if(C.preventDefault(),!bt.trim())return;(xe==="streaming"||xe==="submitted")&&Lt();const _=St[Math.floor(Math.random()*St.length)]||"Thinking...";Bn(_),Tt({text:bt}),ke("")}function qn(C){const _=C.target.value;ke(_)}f.useEffect(()=>{if(!pt)return;function C(z){if(G){const Z=z.clientX-je.x,H=z.clientY-je.y;Z>=a&&Z<=l&&ie(Z),H>=400&&H<=1e3&&We(H)}else{const Z=window.innerWidth-z.clientX;Z>=a&&Z<=l&&ie(Z)}}function _(){Qe(!1),localStorage.setItem("arcten-sidebar-width",K.toString()),localStorage.setItem("arcten-sidebar-height",ye.toString())}return window.addEventListener("mousemove",C),window.addEventListener("mouseup",_),()=>{window.removeEventListener("mousemove",C),window.removeEventListener("mouseup",_)}},[pt,K,ye,G,je,a,l]);function at(C){C.preventDefault(),Qe(!0)}function Ft(){Rt(!0),gt(!1),localStorage.setItem("arcten-sidebar-detached","true"),localStorage.setItem("arcten-sidebar-minimized","false")}function xs(){Rt(!1),gt(!1),localStorage.setItem("arcten-sidebar-detached","false"),localStorage.setItem("arcten-sidebar-minimized","false")}function xn(){gt(!Ee),localStorage.setItem("arcten-sidebar-minimized",JSON.stringify(!Ee))}function He(C){G&&(oe(!0),yt({x:C.clientX-je.x,y:C.clientY-je.y}))}return f.useEffect(()=>{if(!G)return;function C(){Le(_=>{const Z=window.innerWidth-50,H=window.innerHeight-50,J=50-K,ge=0,se=Math.max(J,Math.min(_.x,Z)),Se=Math.max(ge,Math.min(_.y,H));if(se!==_.x||Se!==_.y){const W={x:se,y:Se};return localStorage.setItem("arcten-sidebar-position",JSON.stringify(W)),W}return _})}return window.addEventListener("resize",C),()=>window.removeEventListener("resize",C)},[G,K]),f.useEffect(()=>{if(!ln)return;function C(z){const Z=z.clientX-cn.x,H=z.clientY-cn.y,J=50,ge=window.innerWidth-J,se=window.innerHeight-J,Se=J-K,W=0,he=Math.max(Se,Math.min(Z,ge)),Q=Math.max(W,Math.min(H,se));Le({x:he,y:Q})}function _(){oe(!1),localStorage.setItem("arcten-sidebar-position",JSON.stringify(je))}return window.addEventListener("mousemove",C),window.addEventListener("mouseup",_),()=>{window.removeEventListener("mousemove",C),window.removeEventListener("mouseup",_)}},[ln,cn,je,K]),un?gn?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: ",gn]})}):pn?c.jsx(nd,{features:Rf,children:c.jsx(Jn,{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:`
10
+ `),()=>{C.contains(v)&&C.removeChild(v)}},[t]),c.jsx(nd,{isPresent:t,childRef:o,sizeRef:i,children:We.cloneElement(e,{ref:l})})}const rd=({children:e,initial:t,isPresent:n,onExitComplete:s,custom:r,presenceAffectsLayout:o,mode:i,anchorX:a,root:l})=>{const u=yr(id),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 S of u.values())if(!S)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,S)=>u.set(S,!1))},[n]),We.useEffect(()=>{!n&&!u.size&&s&&s()},[n]),i==="popLayout"&&(e=c.jsx(sd,{isPresent:n,anchorX:a,root:l,children:e})),c.jsx(ps.Provider,{value:m,children:e})};function id(){return new Map}function wa(e=!0){const t=f.useContext(ps);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 Qn=e=>e.key||"";function Ai(e){const t=[];return f.Children.forEach(e,n=>{f.isValidElement(n)&&t.push(n)}),t}const od=({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),h=f.useMemo(()=>Ai(e),[e]),m=i&&!u?[]:h.map(Qn),p=f.useRef(!0),S=f.useRef(h),v=yr(()=>new Map),[C,b]=f.useState(h),[M,E]=f.useState(h);ko(()=>{p.current=!1,S.current=h;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(h!==C){let I=[...h];for(let N=0;N<M.length;N++){const j=M[N],O=Qn(j);m.includes(O)||(I.splice(N,0,j),$.push(j))}return o==="wait"&&$.length&&(I=$),E(Ai(I)),b(h),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:D}=f.useContext(gr);return c.jsx(c.Fragment,{children:M.map(I=>{const N=Qn(I),j=i&&!u?!1:h===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&&(D?.(),E(S.current),i&&d?.(),s&&s())};return c.jsx(rd,{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}),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 ad({children:e,features:t,strict:n=!1}){const[,s]=f.useState(!Rs(t)),r=f.useRef(void 0);if(!Rs(t)){const{renderer:o,...i}=t;r.current=o,ir(i)}return f.useEffect(()=>{Rs(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 Rs(e){return typeof e=="function"}const ld=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 hs(e){return e.startsWith("while")||e.startsWith("drag")&&e!=="draggable"||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||ld.has(e)}let Sa=e=>!hs(e);function cd(e){typeof e=="function"&&(Sa=t=>t.startsWith("on")?!hs(t):e(t))}try{cd(require("@emotion/is-prop-valid").default)}catch{}function ud(e,t,n){const s={};for(const r in e)r==="values"&&typeof e.values=="object"||(Sa(r)||n===!0&&hs(r)||!t&&!hs(r)||e.draggable&&r.startsWith("onDrag"))&&(s[r]=e[r]);return s}const gs=f.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 dd(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}=dd(e,f.useContext(gs));return f.useMemo(()=>({initial:t,animate:n}),[Mi(t),Mi(n)])}function Mi(e){return Array.isArray(e)?e.join(" "):e}const Ln={};function fd(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 md={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},pd=nn.length;function gd(e,t,n){let s="",r=!0;for(let o=0;o<pd;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=md[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=gd(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 yd({transformTemplate:e},t){return f.useMemo(()=>{const n=Wr();return Xr(n,t,e),Object.assign({},n.vars,n.style)},[t])}function xd(e,t){const n=e.style||{},s={};return ja(s,n,e),Object.assign(s,yd(e,t)),s}function bd(e,t){const n={},s=xd(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 vd={offset:"stroke-dashoffset",array:"stroke-dasharray"},wd={offset:"strokeDashoffset",array:"strokeDasharray"};function Sd(e,t,n=1,s=0,r=!0){e.pathLength=1;const o=r?vd:wd;e[o.offset]=z.transform(-s);const i=z.transform(t),a=z.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: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&&Sd(h,r,o,i,!1)}const Aa=()=>({...Wr(),attrs:{}}),Ea=e=>typeof e=="string"&&e.toLowerCase()==="svg";function Td(e,t,n,s){const r=f.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 Cd=["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:!!(Cd.indexOf(e)>-1||/[A-Z]/u.test(e))}function jd(e,t,n,{latestValues:s},r,o=!1){const a=(qr(e)?Td:bd)(t,s,r,e),l=ud(t,typeof e=="string",o),u=e!==f.Fragment?{...l,...a,ref:n}:{},{children:d}=t,h=f.useMemo(()=>Ce(d)?d.get():d,[d]);return f.createElement(e,{...u,children:h})}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 Pd({scrapeMotionValuesFromProps:e,createRenderState:t},n,s,r){return{latestValues:Ad(n,s,r,e),renderState:t()}}function Ad(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 h=d?a:i;if(h&&typeof h!="boolean"&&!ys(h)){const m=Array.isArray(h)?h:[h];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=f.useContext(gs),r=f.useContext(ps),o=()=>Pd(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 Ed=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 Md=Ma({scrapeMotionValuesFromProps:ka,createRenderState:Aa}),kd=Symbol.for("motionComponentSymbol");function qt(e){return e&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"current")}function Nd(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):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),Da=f.createContext({});function Rd(e,t,n,s,r){const{visualElement:o}=f.useContext(gs),i=f.useContext(Ur),a=f.useContext(ps),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(Da);d&&!d.projection&&r&&(d.type==="html"||d.type==="svg")&&Vd(u.current,n,r,h);const m=f.useRef(!1);f.useInsertionEffect(()=>{d&&m.current&&d.update(n,a)});const p=n[Na],S=f.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())}),f.useEffect(()=>{d&&(!S.current&&d.animationState&&d.animationState.animateChanges(),S.current&&(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(p)}),S.current=!1),d.enteringChildren=void 0)}),d}function Vd(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&&qt(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 as(e,{forwardMotionProps:t=!1}={},n,s){n&&ir(n);const r=qr(e)?Md:Ed;function o(a,l){let u;const d={...f.useContext(Br),...a,layoutId:Id(a)},{isStatic:h}=d,m=hd(a),p=r(a,h);if(!h&&xr){Od(d,n);const S=Ld(d);u=S.MeasureLayout,m.visualElement=Rd(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,jd(e,a,Nd(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[kd]=e,i}function Id({layoutId:e}){const t=f.useContext(gr).id;return t&&e!==void 0?t+"-"+e:e}function Od(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?en(!1,s,"lazy-strict-mode"):ot(!1,s,"lazy-strict-mode")}}function Ld(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 $d(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 Fd({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function Bd(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 fs(e,t,n){const s=e-n,r=t*s;return n+r}function Di(e,t,n,s,r){return r!==void 0&&(e=fs(e,r,s)),fs(e,n,s)+t}function ar(e,t=0,n=1,s,r){e.min=Di(e.min,t,n,s,r),e.max=Di(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 Ri=.999999999999,Vi=1.0000000000001;function Ud(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>Ri&&(t.x=1),t.y<Vi&&t.y>Ri&&(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(Bd(e.getBoundingClientRect(),t))}function zd(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}),me=()=>({x:Li(),y:Li()}),lr={current:null},$a={current:!1};function _d(){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 Xd=new WeakMap;function Wd(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 qd{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=ke.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,...h}=this.scrapeMotionValuesFromProps(n,{},this);for(const m in h){const p=h[m];l[m]!==void 0&&Ce(p)&&p.set(l[m])}}mount(t){this.current=t,Xd.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||_d(),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):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<$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=Wd(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)||Ro(s))?s=parseFloat(s):!Qu(s)&&gt.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 qd{constructor(){super(...arguments),this.KeyframeResolver=Uu}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 Kd(e){return window.getComputedStyle(e)}class Gd extends Fa{constructor(){super(...arguments),this.type="html",this.renderInstance=Ba}readValueFromInstance(t,n){if(sn.has(n))return this.projection?.isProjecting?Zs(n):iu(t,n);{const s=Kd(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 Yd(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 Hd extends Fa{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=me}getBaseTargetFromProps(t,n){return t[n]}readValueFromInstance(t,n){if(sn.has(n)){const s=fa(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){Yd(t,n,s,r)}mount(t){this.isSVGTag=Ea(t.tagName),super.mount(t)}}const za=(e,t)=>qr(e)?new Hd(t):new Gd(t,{allowProjection:e!==f.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 Jd(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,Zt(n))}function Zd(e){return cr(e)?e[e.length-1]||0:e}function Qd(e,t){const n=Jt(e,t);let{transitionEnd:s={},transition:r={},...o}=n||{};o={...o,...s};for(const i in o){const a=Zd(o[i]);Jd(e,i,a)}}function eh(e){return!!(Ce(e)&&e.add)}function ur(e,t){const n=e.getValue("willChange");if(eh(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 th=e=>e!==null;function nh(e,{repeat:t,repeatType:n="loop"},s){const r=e.filter(th),o=t&&n!=="loop"&&t%2===1?0:r.length-1;return r[o]}const sh={type:"spring",stiffness:500,damping:25,restSpeed:10},rh=e=>({type:"spring",stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),ih={type:"keyframes",duration:.8},oh={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},ah=(e,{keyframes:t})=>t.length>2?ih:sn.has(e)?e.startsWith("scale")?rh(t[1]):sh:oh;function lh({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};lh(a)||Object.assign(d,ah(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)),(at.instantAnimations||at.skipAnimations)&&(h=!0,sr(d),d.delay=0),d.allowFlatten=!a.type&&!a.ease,h&&!o&&t.get()!==void 0){const m=nh(d.keyframes,a);if(m!==void 0){ce.update(()=>{d.onUpdate(m),d.onComplete()});return}}return a.isSync?new Vr(d):new Eu(d)};function ch({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 h=e.getValue(d,e.latestValues[d]??null),m=a[d];if(m===void 0||u&&ch(u,d))continue;const p={delay:n,...Or(o||{},d)},S=h.get();if(S!==void 0&&!h.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),h.start(Hr(d,h,m,e.shouldReduceMotion&&ua.has(d)?{type:!1}:p,e,v));const C=h.animation;C&&l.push(C)}return i&&Promise.all(l).then(()=>{ce.update(()=>{i&&Qd(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:h}=r;return uh(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 uh(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 dh(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 hh=_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<hh;n++){const s=_r[n],r=e.props[s];(On(r)||r===!1)&&(t[s]=r)}return t}const fh=[...zr].reverse(),mh=zr.length;function ph(e){return t=>Promise.all(t.map(({animation:n,options:s})=>dh(e,n,s)))}function gh(e){let t=ph(e),n=Fi(),s=!0;const r=l=>(u,d)=>{const h=Jt(e,d,l==="exit"?e.presenceContext?.custom:void 0);if(h){const{transition:m,transitionEnd:p,...S}=h;u={...u,...S,...p}}return u};function o(l){t=l(e)}function i(l){const{props:u}=e,d=Ka(e.parent)||{},h=[],m=new Set;let p={},S=1/0;for(let C=0;C<mh;C++){const b=fh[C],M=n[b],E=u[b]!==void 0?u[b]:d[b],$=On(E),D=b===l?M.isActive:null;D===!1&&(S=C);let I=E===d[b]&&E!==u[b]&&$;if(I&&s&&e.manuallyAnimateOnMount&&(I=!1),M.protectedKeys={...p},!M.isActive&&D===null||!E&&!M.prevProp||ys(E)||typeof E=="boolean")continue;const N=yh(M.prevProp,E);let j=N||b===l&&M.isActive&&!I&&$||C>S&&$,O=!1;const A=Array.isArray(E)?E:[E];let k=A.reduce(r(b),{});D===!1&&(k={});const{prevResolvedValues:F={}}=M,V={...F,...k},B=K=>{j=!0,m.has(K)&&(O=!0,m.delete(K)),M.needsAnimating[K]=!0;const ie=e.getValue(K);ie&&(ie.liveStyle=!1)};for(const K in V){const ie=k[K],ge=F[K];if(p.hasOwnProperty(K))continue;let Ke=!1;cr(ie)&&cr(ge)?Ke=!qa(ie,ge):Ke=ie!==ge,Ke?ie!=null?B(K):m.add(K):ie!==void 0&&m.has(K)?B(K):M.protectedKeys[K]=!0}M.prevProp=E,M.prevResolvedValues=k,M.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=Jt(ge,K);if(ge.enteringChildren&&Ke){const{delayChildren:xt}=Ke.transition||{};ie.delay=Wa(ge.enteringChildren,e,xt)}}return{animation:K,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}),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=Fi()}}}function yh(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 xh extends yt{constructor(t){super(t),t.animationState||(t.animationState=gh(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 bh=0;class vh extends yt{constructor(){super(...arguments),this.id=bh++}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:xh},exit:{Feature:vh}};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 wh=e=>t=>Fr(t)&&e(t,zn(t));function Mn(e,t,n,s){return $n(e,t,wh(n),s)}const Ya=1e-4,Sh=1-Ya,Th=1+Ya,Ha=.01,Ch=0-Ha,jh=0+Ha;function Ee(e){return e.max-e.min}function Ph(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>=Sh&&e.scale<=Th||isNaN(e.scale))&&(e.scale=1),(e.translate>=Ch&&e.translate<=jh||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 Ah(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 Ie(e){return[e("x"),e("y")]}const Ja=({current:e})=>e?e.ownerDocument.defaultView:null,_i=(e,t)=>Math.abs(e-t);function Eh(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=Eh(m.offset,{x:0,y:0})>=this.distanceThreshold;if(!p&&!S)return;const{point:v}=m,{timestamp:C}=we;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}=we;this.history=[{...u,timestamp:d}];const{onSessionStart:h}=n;h&&h(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,Mh(t)),velocity:kh(t,.1)}}function Mh(e){return e[0]}function Qa(e){return e[e.length-1]}function kh(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>qe(t)));)n--;if(!s)return{x:0,y:0};const o=Le(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 Nh(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 Dh(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 Rh(e,t){return{x:qi(e.x,t.x),y:qi(e.y,t.y)}}function Vh(e,t){let n=.5;const s=Ee(e),r=Ee(t);return r>s?n=Rn(t.min,t.max-s,e.min):s>r&&(n=Rn(e.min,e.max-r,t.min)),it(0,1,n)}function Ih(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 Oh(e=hr){return e===!1?e=0:e===!0&&(e=hr),{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 Lh=new WeakMap;class $h{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(zn(h).point)},i=(h,m)=>{const{drag:p,dragPropagation:S,onDragStart:v}=this.getProps();if(p&&!S&&(this.openDragLock&&this.openDragLock(),this.openDragLock=Wu(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),Ie(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(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:S,onDirectionLock:v,onDrag:C}=this.getProps();if(!p&&!this.openDragLock)return;const{offset:b}=m;if(S&&this.currentDirection===null){this.currentDirection=Fh(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=()=>Ie(h=>this.getAnimationState(h)==="paused"&&this.getAxisMotionValue(h).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=Nh(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=Dh(s.layoutBox,t):this.constraints=!1,this.elastic=Oh(n),r!==this.constraints&&s&&this.constraints&&!this.hasMutatedConstraints&&Ie(o=>{this.constraints!==!1&&this.getAxisMotionValue(o)&&(this.constraints[o]=Ih(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=zd(s,r.root,this.visualElement.getTransformPagePoint());let i=Rh(r.layout.layoutBox,o);if(n){const a=n(Fd(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=Ie(d=>{if(!es(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,S={type:"inertia",velocity:s?t[d]:0,bounceStiffness:m,bounceDamping:p,timeConstant:750,restDelta:1,restSpeed:10,...o,...h};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(){Ie(t=>this.getAxisMotionValue(t).stop())}pauseAnimation(){Ie(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){Ie(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};Ie(i=>{const a=this.getAxisMotionValue(i);if(a&&this.constraints!==!1){const l=a.get();r[i]=Vh({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(),Ie(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;Lh.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&&(Ie(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 es(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function Fh(e,t=10){let n=null;return Math.abs(e.y)>t?n="y":Math.abs(e.x)>t&&(n="x"),n}class Bh extends yt{constructor(t){super(t),this.removeGroupControls=$e,this.removeListeners=$e,this.controls=new $h(t)}mount(){const{dragControls:t}=this.node.getProps();t&&(this.removeGroupControls=t.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||$e}unmount(){this.removeGroupControls(),this.removeListeners()}}const Yi=e=>(t,n)=>{e&&ce.postRender(()=>e(t,n))};class Uh extends yt{constructor(){super(...arguments),this.removePointerDownListener=$e}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(z.test(e))e=parseFloat(e);else return e;const n=Hi(e,t.target.x),s=Hi(e,t.target.y);return`${n}% ${s}%`}},zh={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 _h extends f.Component{componentDidMount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:s,layoutId:r}=this.props,{projection:o}=t;fd(Xh),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=f.useContext(gr);return c.jsx(_h,{...e,layoutGroup:s,switchLayoutGroup:f.useContext(Da),isPresent:t,safeToRemove:n})}const Xh={borderRadius:{...Cn,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:Cn,borderTopRightRadius:Cn,borderBottomLeftRadius:Cn,borderBottomRightRadius:Cn,boxShadow:zh};function Wh(e,t,n){const s=Ce(e)?e:Zt(e);return s.start(Hr("",s,t,n)),s.animation}const qh=(e,t)=>e.depth-t.depth;class Kh{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(qh),this.isDirty=!1,this.children.forEach(t)}}function Gh(e,t){const n=ke.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"],Yh=tl.length,Ji=e=>typeof e=="string"?parseFloat(e):e,Zi=e=>typeof e=="number"||z.test(e);function Hh(e,t,n,s,r,o){r?(e.opacity=de(0,n.opacity??1,Jh(s)),e.opacityExit=de(t.opacity??1,0,Zh(s))):o&&(e.opacity=de(t.opacity??1,n.opacity??1,s));for(let i=0;i<Yh;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 Jh=nl(0,.5,Uo),Zh=nl(.5,.95,$e);function nl(e,t,n){return s=>s<e?0:s>t?1:n(Rn(e,t,s))}function eo(e,t){e.min=t.min,e.max=t.max}function Ve(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=fs(e,1/n,s),r!==void 0&&(e=fs(e,1/r,s)),e}function Qh(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){Qh(e,t[n],t[s],t[r],t.scale,o,i)}const ef=["x","scaleX","originX"],tf=["y","scaleY","originY"];function ro(e,t,n,s){so(e.x,t,ef,n?n.x:void 0,s?s.x:void 0),so(e.y,t,tf,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 nf(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 sf{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 rf(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:S}=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) `),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"],of=1e3;let af=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=af++,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(uf),this.nodes.forEach(mf),this.nodes.forEach(pf),this.nodes.forEach(df)},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 Kh)}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)&&!Ju(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;ce.read(()=>{h=window.innerWidth}),e(i,()=>{const p=window.innerWidth;p!==h&&(h=p,this.root.updateBlockedByResize=!0,d&&d(),d=Gh(m,250),ls.hasAnimatedSinceResize&&(ls.hasAnimatedSinceResize=!1,this.nodes.forEach(fo)))})}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 S=this.options.transition||u.getDefaultTransition()||vf,{onLayoutAnimationStart:v,onLayoutAnimationComplete:C}=u.getProps(),b=!this.targetLayout||!rl(this.targetLayout,p),M=!h&&m;if(this.options.layoutRoot||this.resumeFrom||M||h&&(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 h||fo(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(gf),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 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(uo);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(ho);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(ff),this.nodes.forEach(lf),this.nodes.forEach(cf)):this.nodes.forEach(ho),this.clearAllSnapshots();const a=ke.now();we.delta=it(0,1e3/60,a-we.timestamp),we.timestamp=a,we.isProcessing=!0,As.update.process(we),As.preRender.process(we),As.render.process(we),we.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,$r.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(hf),this.sharedNodes.forEach(yf)}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=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&&!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)),wf(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(Sf))){const{scroll:u}=this.root;u&&(Kt(a.x,u.offset.x),Kt(a.y,u.offset.y))}return a}removeElementScroll(i){const a=me();if(Ve(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&&Ve(a,i),Kt(a.x,d.offset.x),Kt(a.y,d.offset.y))}return a}applyTransform(i,a=!1){const l=me();Ve(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=me();Ve(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=me(),h=u.measurePageBox();Ve(d,h),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!==we.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=we.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(),Nn(this.relativeTargetOrigin,this.layout.layoutBox,m.layout.layoutBox),Ve(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(),Ah(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):Ve(this.target,this.layout.layoutBox),Oa(this.target,this.targetDelta)):Ve(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(),Nn(this.relativeTargetOrigin,this.target,m.target),Ve(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===we.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;Ve(this.layoutCorrected,this.layout.layoutBox);const h=this.treeScale.x,m=this.treeScale.y;Ud(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():(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!==h||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},h=Yt();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!a;const m=me(),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(bf));this.animationProgress=0;let E;this.mixTargetDelta=$=>{const D=$/1e3;mo(h.x,i.x,D),mo(h.y,i.y,D),this.setTargetDelta(h),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(Nn(m,this.layout.layoutBox,this.relativeParent.layout.layoutBox),xf(this.relativeTarget,this.relativeTargetOrigin,m,D),E&&nf(this.relativeTarget,E)&&(this.isProjectionDirty=!1),E||(E=me()),Ve(E,this.relativeTarget)),v&&(this.animationValues=d,Hh(d,u,this.latestValues,D,M,b)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=D},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=Wh(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(of),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||me();const h=Ee(this.layout.layoutBox.x);l.x.min=i.target.x.min,l.x.max=l.x.min+h;const m=Ee(this.layout.layoutBox.y);l.y.min=i.target.y.min,l.y.max=l.y.min+m}Ve(a,l),Gt(a,d),kn(this.projectionDeltaWithTransform,this.layoutCorrected,a,d)}}registerSharedNode(i,a){this.sharedNodes.has(i)||this.sharedNodes.set(i,new sf),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 h=rf(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 S in Ln){if(d[S]===void 0)continue;const{correct:v,applyTo:C,isCSSVariable:b}=Ln[S],M=h==="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 lf(e){e.updateLayout()}function cf(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"?Ie(d=>{const h=o?t.measuredBox[d]:t.layoutBox[d],m=Ee(h);h.min=n[d].min,h.max=h.min+m}):al(r,t.layoutBox,n)&&Ie(d=>{const h=o?t.measuredBox[d]:t.layoutBox[d],m=Ee(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=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:h,layout:m}=d;if(h&&m){const p=me();Nn(p,t.layoutBox,h.layoutBox);const S=me();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 uf(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 df(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function hf(e){e.clearSnapshot()}function uo(e){e.clearMeasurements()}function ho(e){e.isLayoutDirty=!1}function ff(e){const{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify("BeforeLayoutMeasure"),e.resetTransform()}function fo(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function mf(e){e.resolveTargetDelta()}function pf(e){e.calcProjection()}function gf(e){e.resetSkewAndRotation()}function yf(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 xf(e,t,n,s){po(e.x,t.x,n.x,s),po(e.y,t.y,n.y,s)}function bf(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}const vf={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:$e;function xo(e){e.min=yo(e.min),e.max=yo(e.max)}function wf(e){xo(e.x),xo(e.y)}function al(e,t,n){return e==="position"||e==="preserve-aspect"&&!Ph(lo(t),lo(n),.2)}function Sf(e){return e!==e.root&&e.scroll?.wasRoot}const Tf=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 Tf({});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"}),Cf={pan:{Feature:Uh},drag:{Feature:Bh,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 jf extends yt{mount(){const{current:t}=this.node;t&&(this.unmount=qu(t,(n,s)=>(bo(this.node,s,"Start"),r=>bo(this.node,r,"End"))))}unmount(){}}class Pf 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 Af extends yt{mount(){const{current:t}=this.node;t&&(this.unmount=Hu(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 fr=new WeakMap,Us=new WeakMap,Ef=e=>{const t=fr.get(e.target);t&&t(e)},Mf=e=>{e.forEach(Ef)};function kf({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(Mf,{root:e,...t})),s[r]}function Nf(e,t,n){const s=kf(t);return fr.set(e,n),s.observe(e),()=>{fr.delete(e),s.unobserve(e)}}const Df={some:0,all:1};class Rf 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:Df[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 Nf(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(Vf(t,n))&&this.startObserver()}unmount(){}}function Vf({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}const cl={inView:{Feature:Rf},tap:{Feature:Af},focus:{Feature:Pf},hover:{Feature:jf}},If={layout:{ProjectionNode:ll,MeasureLayout:el}},Of={...Ga,...cl,...Cf,...If},Lf=$d(Of,za),$f={renderer:za,...Ga,...cl};function Jr(e,t){return as(e,t)}const Ff=Jr("button"),ts=Jr("div"),Bf=Jr("p");function Uf({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(te.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(te.X,{className:"h-3 w-3"})})]})]})})}function zf({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(te.ChevronDown,{className:"h-3 w-3"}):c.jsx(te.ChevronRight,{className:"h-3 w-3"})}),n?c.jsx(te.X,{className:"h-3 w-3"}):s?c.jsx(te.Zap,{className:"h-3 w-3"}):c.jsx(te.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 _f({...e}){return c.jsx(mr.Root,{"data-slot":"collapsible",...e})}function Xf({...e}){return c.jsx(mr.CollapsibleTrigger,{"data-slot":"collapsible-trigger",...e})}function Wf({...e}){return c.jsx(mr.CollapsibleContent,{"data-slot":"collapsible-content",...e})}const qf=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(qf,{className:se("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",e),...t})}),(e,t)=>e.children===t.children);Zr.displayName="Response";const Kf=Object.freeze(Object.defineProperty({__proto__:null,Response:Zr},Symbol.toStringTag,{value:"Module"})),Gf=({children:e,as:t="p",className:n,duration:s=2,spread:r=2})=>{const o=Lf.create(t),i=f.useMemo(()=>(e?.length??0)*r,[e,r]);return c.jsx(o,{animate:{backgroundPosition:"0% center"},className:se("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})},Yf=f.memo(Gf),ul=f.createContext(null),Hf=()=>{const e=f.useContext(ul);if(!e)throw new Error("Reasoning components must be used within Reasoning");return e},Jf=1e3,Zf=1e3,dl=f.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,h]=si.useControllableState({prop:o,defaultProp:0}),[m,p]=f.useState(!1),[S,v]=f.useState(null);f.useEffect(()=>{t?S===null&&v(Date.now()):S!==null&&(h(Math.ceil((Date.now()-S)/Zf)),v(null))},[t,S,h]),f.useEffect(()=>{if(s&&!t&&l&&!m){const b=setTimeout(()=>{u(!1),p(!0)},Jf);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(_f,{className:se("not-prose mb-4",e),onOpenChange:C,open:l,...a,children:i})})}),Qf=(e,t)=>e||t===0?c.jsx(Yf,{duration:1,children:"Thinking..."}):t===void 0?c.jsx("p",{children:"Thought for a few seconds"}):c.jsxs("p",{children:["Thought for ",t," seconds"]}),hl=f.memo(({className:e,children:t,...n})=>{const{isStreaming:s,isOpen:r,duration:o}=Hf();return c.jsx(Xf,{className:se("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(te.BrainIcon,{className:"size-4"}),Qf(s,o),c.jsx(te.ChevronDownIcon,{className:se("size-4 transition-transform",r?"rotate-180":"rotate-0")})]})})}),fl=f.memo(({className:e,children:t,...n})=>c.jsx(Wf,{className:se("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";hl.displayName="ReasoningTrigger";fl.displayName="ReasoningContent";function wo(e){return`https://www.google.com/s2/favicons?domain=${encodeURIComponent(e)}&sz=16`}function em({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(ht,{asChild:!0,children:c.jsxs("button",{className:se("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(ft,{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:se("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 tm({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,M=!1;const E=new WeakSet,$=()=>{if(!u.current||M)return;M=!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&&!E.has(A)){const F=A,V=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(V.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){M=!1;return}const k=[];O.forEach(({node:F,matches:V})=>{E.add(F);const B=F.textContent||"",X=document.createDocumentFragment();let Y=0;V.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 V=new Set(F.map(Y=>Y.element)),B=F.filter(Y=>Y.element.isConnected),X=k.filter(Y=>!V.has(Y.element));return[...B,...X]}),M=!1},D=new MutationObserver(()=>{clearTimeout(b),b=setTimeout($,100)});return D.observe(C,{childList:!0,subtree:!0,characterData:!0}),b=setTimeout($,200),()=>{D.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:se("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:D=>{const I=D.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:se("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 D=$.target;D.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(D=>D.number===b))return null;const $=Array.from(new Map(t.map(D=>{const I=D.url.replace(/\/+$/,""),N=s?.find(j=>j.url.replace(/\/+$/,"")===I);return[I,{number:D.number,url:D.url,domain:S(D.url),title:N?.title}]})).values());return Dl.createPortal(c.jsx(em,{sources:$,citationNumber:b},`citation-${b}-${C}`),C,`citation-${b}-${M}`)}),v]})}function rn({...e}){return c.jsx(It.Root,{"data-slot":"dialog",...e})}function nm({...e}){return c.jsx(It.Portal,{"data-slot":"dialog-portal",...e})}function sm({className:e,...t}){return c.jsx(It.Overlay,{"data-slot":"dialog-overlay",className:se("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(nm,{"data-slot":"dialog-portal",children:[c.jsx(sm,{}),c.jsxs(It.Content,{"data-slot":"dialog-content",className:se("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(te.XIcon,{}),c.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function an({className:e,...t}){return c.jsx("div",{"data-slot":"dialog-header",className:se("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:se("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:se("text-lg leading-none font-semibold",e),...t})}function un({className:e,...t}){return c.jsx(It.Description,{"data-slot":"dialog-description",className:se("text-muted-foreground text-sm",e),...t})}function dn({className:e,type:t,...n}){return c.jsx("input",{type:t,"data-slot":"input",className:se("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 rm({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(rn,{open:e,children:c.jsx(on,{showCloseButton:!1,children:c.jsxs("form",{onSubmit:h,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(te.EyeOff,{className:"h-4 w-4"}):c.jsx(te.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 im({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)}},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(te.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 om({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)},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(te.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 am({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 S=p.replace(/\D/g,"");a(S.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(rn,{open:e,children:c.jsx(on,{showCloseButton:!1,children:c.jsxs("form",{onSubmit:h,children:[c.jsxs(an,{children:[c.jsxs(cn,{className:"flex items-center gap-2",children:[c.jsx(te.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]=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(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(te.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:h,disabled:l,children:"Cancel"}),c.jsx(je,{type:"submit",disabled:!i.trim()||l,children:l?"Submitting...":"Submit"})]})]})})})}function lm({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,S]=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`,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(X=>({...X,[A]:V})),d(X=>({...X,[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},D=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]}))},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(rn,{open:e,children:c.jsx(on,{showCloseButton:!1,className:"max-w-md",children:c.jsxs("form",{onSubmit:D,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:j(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:h[A.name]?c.jsx(te.EyeOff,{className:"h-4 w-4"}):c.jsx(te.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(te.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=f.createContext(void 0);function pl(){const e=f.useContext(ml);if(!e)throw new Error("useSecureModal must be used within a SecureModalProvider");return e}function gl({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(S=>{n(p),o.current=S}),[]),l=f.useCallback(p=>new Promise(S=>{r(p),i.current=S}),[]),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 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(lm,{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(rm,{...p});case"email":return c.jsx(im,{...p});case"phone":return c.jsx(om,{...p});case"pin":return c.jsx(am,{...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(ml.Provider,{value:m,children:[e,h()]})}function cm(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 um(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 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(/[.,;:!?]+$/,""),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,h=t;s&&s[0]&&(d=s[0],h=t.replace(n,""));const m=[];let p=0;const S=/```[\s\S]*?```|`[^`]+`/g;let v;for(;(v=S.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,V)=>{const B=parseInt(F,10),X=V.replace(/\/+$/,""),Y=u.get(B)||B;return l.has(X)||(l.set(X,Y),r.has(Y)||(r.set(Y,V),o.push({number:Y,url:V}))),`[${Y}]`}),O=O.replace(/\[(\d+)\]/g,(k,F)=>{const V=parseInt(F,10);return`[${u.get(V)||V}]`}),O}),b=[];for(const[j,O]of l.entries()){const A=a.get(j)||j,{baseUrl:k,anchor:F}=cm(A),V=um(A);b.push({url:A,baseUrl:k,numbers:[O],anchor:F,title:V})}b.sort((j,O)=>(j.numbers[0]||0)-(O.numbers[0]||0));const M=new Map;let E=1;for(const j of b){const O=j.numbers[0];M.set(O,E),j.numbers=[E],E++}const $=new Map;for(const[j,O]of r.entries()){const A=M.get(j);A&&$.set(A,O)}const D=o.map(j=>{const O=M.get(j.number);return O?{number:O,url:j.url}:j}).filter(j=>M.has(j.number)),I=Array.from(M.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:D.sort((j,O)=>j.number-O.number),citationMap:$,groupedCitations:b,referencesText:d}}function Dn(e){if(typeof e=="string")try{const t=JSON.parse(e);return Dn(t)}catch{return e}if(Array.isArray(e))return e.map(Dn);if(e&&typeof e=="object"){const t={};for(const[n,s]of Object.entries(e))t[n]=Dn(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 Dn(t)}catch{}return{}}return e&&typeof e=="object"&&!Array.isArray(e)?Dn(e):{}}function dm({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:S="",agentId:v,agentName:C,tokenEndpoint:b="/api/arcten/token",apiBaseUrl:M="https://api.arcten.com",user:E,state:$,onStateChange:D,allowStateEdits:I=!0,sources:N,ragConfig:j,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:h,toolMetadata:p,sensitiveParams:A,autoDetectSensitive:k,agentId:v,agentName:C,state:$,onStateChange:D,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),[xt,nt]=f.useState(!1),[G,Ot]=f.useState(!1),[Me,bt]=f.useState(!1),[Pe,Fe]=f.useState({x:100,y:100}),[hn,oe]=f.useState(!1),[fn,vt]=f.useState({x:0,y:0}),[mn,_n]=f.useState(!1),Be=f.useRef(null),wt=f.useRef(null),[St,Ne]=f.useState(""),[pn,bs]=f.useState(null),[Lt,Xn]=f.useState("Thinking..."),[Tt,lt]=f.useState(new Set),[vs,Wn]=f.useState(""),[Ge,ws]=f.useState([]),qn=f.useRef(new Map),$t=f.useRef(!1),gn=f.useRef(""),[le,yn]=f.useState(!1),[Ue,Se]=f.useState(!1),Ye=f.useMemo(()=>[...d,...h],[d,h]),ze=f.useMemo(()=>pr(Ye,p),[Ye,p]),Ft=f.useMemo(()=>{const T=new Map,W=new Map(ze.map(U=>[U.name,U]));return Ye.forEach(U=>{const Z=U[Oe];if(Z){const J=W.get(Z);if(J){T.set(J.name,U);return}}const H=ze.find(J=>J.name===U.name);H&&T.set(H.name,U)}),T},[Ye,ze]),Ct=f.useMemo(()=>{const T=new Set,W=new Map(ze.map(U=>[U.name,U]));return h.forEach(U=>{const Z=U[Oe];if(Z&&W.has(Z))T.add(Z);else{const H=ze.find(J=>J.name===U.name);H&&T.add(H.name)}}),m&&Array.isArray(m)&&m.forEach(U=>{typeof U=="string"&&T.add(U)}),T},[h,ze,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..."];f.useEffect(()=>{if(typeof window<"u"){const T=localStorage.getItem("arcten-sidebar-expanded");T&&Y(JSON.parse(T));const W=localStorage.getItem("arcten-sidebar-width");W&&ie(parseInt(W));const U=localStorage.getItem("arcten-sidebar-height");U&&Ke(parseInt(U));const Z=localStorage.getItem("arcten-sidebar-detached");Z&&Ot(JSON.parse(Z));const H=localStorage.getItem("arcten-sidebar-position");if(H){const Re=JSON.parse(H),ne=50,xe=Math.max(ne-i,Math.min(Re.x,window.innerWidth-ne)),_=Math.max(0,Math.min(Re.y,window.innerHeight-ne));Fe({x:xe,y:_})}const J=localStorage.getItem("arcten-sidebar-minimized");J&&bt(JSON.parse(J)),_n(!0)}},[]),f.useMemo(()=>E,[E?.id]),f.useEffect(()=>{(async()=>{if(Ye.length===0)return;const W=Ye.map(U=>`${U.name}:${U.toString()}`).join("|");if(W!==gn.current&&!$t.current){$t.current=!0,gn.current=W;try{const U=Ye.map(H=>({name:H.name,code:H.toString()})),Z=await fetch(`${F}/tools/describe`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tools:U})});if(Z.ok){const H=await Z.json();H.tools&&H.tools.forEach(J=>{qn.current.set(J.name,J)}),ws(H.tools)}}catch(U){console.error("Failed to fetch tool descriptions:",U)}finally{$t.current=!1}}})()},[Ye,F]),f.useEffect(()=>{Promise.resolve().then(()=>Kf).then(T=>{bs(()=>T.Response)})},[]),f.useEffect(()=>{const T=()=>{Wn(window.location.pathname)};T(),window.addEventListener("popstate",T);const W=setInterval(T,500);return()=>{window.removeEventListener("popstate",T),clearInterval(W)}},[]);const{id:xn,messages:De,sendMessage:Pt,status:ye,error:Kn,stop:Bt,addToolOutput:st,setMessages:Qr,clientToken:bn,tokenError:vn,conversations:He,isLoadingConversations:ct,loadConversation:Ut,deleteConversation:_e,startNewConversation:Je}=B;f.useEffect(()=>{X&&wt.current&&wt.current.focus()},[X,De]),f.useEffect(()=>{const T=De[De.length-1];if(!T||T.role!=="assistant")return;const W=T.parts?.filter(U=>U.type?.startsWith("tool-")&&U.state==="input-available"&&typeof U.toolCallId=="string"&&U.input!==void 0)||[];for(const U of W){const Z=U,H=Z.type?.replace("tool-","")||"",J=Z.toolCallId;if(Ct.has(H)){if(Tt.has(J))continue;lt(ne=>ne.has(J)?ne:new Set(ne).add(J)),(async()=>{try{const ne=Ft.get(H);if(!ne){console.warn(`[ArctenAgent] Tool ${H} not found in toolsMap`),st({toolCallId:J,tool:H,output:`Error: Tool ${H} not found`}),lt(Q=>{const Ae=new Set(Q);return Ae.delete(J),Ae});return}const xe=_s(Z.input),_=ze.find(Q=>Q.name===H);let he;if(_&&_.jsonSchema?.properties){const Ae=Object.keys(_.jsonSchema.properties).map(fe=>xe[fe]);he=await ne(...Ae)}else he=await ne(...Object.values(xe));st({toolCallId:J,tool:H,output:he}),lt(Q=>{const Ae=new Set(Q);return Ae.delete(J),Ae})}catch(ne){console.error(`[ArctenAgent] Error executing safe tool ${H}:`,ne),st({toolCallId:J,tool:H,output:`Error: ${ne instanceof Error?ne.message:String(ne)}`}),lt(xe=>{const _=new Set(xe);return _.delete(J),_})}})()}}},[De,Ct,Ft,ze,st,Tt]);function Gn(){Y(!0),localStorage.setItem("arcten-sidebar-expanded","true")}function Yn(){Y(!1),localStorage.setItem("arcten-sidebar-expanded","false")}f.useEffect(()=>{},[X]),f.useEffect(()=>{Be.current&&Be.current.scrollIntoView({behavior:"smooth"})},[De]),f.useEffect(()=>{function T(W){W.key==="Escape"&&(ye==="streaming"||ye==="submitted")&&(W.preventDefault(),Bt())}return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[ye,Bt]);function rt(T){const W=Math.floor((Date.now()-T)/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 At(){Je(),Se(!1)}function wn(T){if(T.preventDefault(),!St.trim())return;(ye==="streaming"||ye==="submitted")&&Bt();const W=jt[Math.floor(Math.random()*jt.length)]||"Thinking...";Xn(W),Pt({text:St}),Ne("")}function Hn(T){const W=T.target.value;Ne(W)}f.useEffect(()=>{if(!xt)return;function T(U){if(G){const Z=U.clientX-Pe.x,H=U.clientY-Pe.y;Z>=a&&Z<=l&&ie(Z),H>=400&&H<=1e3&&Ke(H)}else{const Z=window.innerWidth-U.clientX;Z>=a&&Z<=l&&ie(Z)}}function W(){nt(!1),localStorage.setItem("arcten-sidebar-width",K.toString()),localStorage.setItem("arcten-sidebar-height",ge.toString())}return window.addEventListener("mousemove",T),window.addEventListener("mouseup",W),()=>{window.removeEventListener("mousemove",T),window.removeEventListener("mouseup",W)}},[xt,K,ge,G,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){G&&(oe(!0),vt({x:T.clientX-Pe.x,y:T.clientY-Pe.y}))}return f.useEffect(()=>{if(!G)return;function T(){Fe(W=>{const Z=window.innerWidth-50,H=window.innerHeight-50,J=50-K,Re=0,ne=Math.max(J,Math.min(W.x,Z)),xe=Math.max(Re,Math.min(W.y,H));if(ne!==W.x||xe!==W.y){const _={x:ne,y:xe};return localStorage.setItem("arcten-sidebar-position",JSON.stringify(_)),_}return W})}return window.addEventListener("resize",T),()=>window.removeEventListener("resize",T)},[G,K]),f.useEffect(()=>{if(!hn)return;function T(U){const Z=U.clientX-fn.x,H=U.clientY-fn.y,J=50,Re=window.innerWidth-J,ne=window.innerHeight-J,xe=J-K,_=0,he=Math.max(xe,Math.min(Z,Re)),Q=Math.max(_,Math.min(H,ne));Fe({x:he,y:Q})}function W(){oe(!1),localStorage.setItem("arcten-sidebar-position",JSON.stringify(Pe))}return window.addEventListener("mousemove",T),window.addEventListener("mouseup",W),()=>{window.removeEventListener("mousemove",T),window.removeEventListener("mouseup",W)}},[hn,fn,Pe,K]),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(ad,{features:$f,children:c.jsx(ts,{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
11
  ${G?"fixed z-50 shadow-xl rounded-xl":"h-screen flex-shrink-0 relative rounded-l-2xl"}
12
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
13
  ${G?"border border-border":"border-l border-border"}
14
14
  ${X?"":"w-[30px]"}
15
- `,style:X?G?{width:`${K}px`,height:Ee?"auto":`${ye}px`,left:`${je.x}px`,top:`${je.y}px`}:{width:`${K}px`}:void 0,onClick:X?void 0:Xn,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:at,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:C=>{C.preventDefault(),Qe(!0)}}),c.jsx("div",{className:"absolute bottom-0 left-4 right-4 h-3 cursor-move hover:bg-blue-500/20 group",onMouseDown:C=>{C.preventDefault(),C.stopPropagation(),oe(!0),yt({x:C.clientX-je.x,y:C.clientY-je.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:C=>{C.preventDefault(),Qe(!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?He:void 0,children:[c.jsx("h2",{className:`text-base font-semibold ${G&&Ee?"cursor-pointer":""}`,onClick:G&&Ee?C=>{C.stopPropagation(),xn()}:void 0,children:r}),c.jsxs("div",{className:"flex items-center gap-1",onClick:C=>C.stopPropagation(),children:[c.jsxs(lt,{children:[c.jsx(ct,{asChild:!0,children:c.jsx("button",{type:"button",className:ne(Pt({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:Ct,"aria-label":"New chat",children:c.jsx(te.Plus,{className:"h-4 w-4"})})}),c.jsx(ut,{children:"Start a new conversation"})]}),c.jsxs(lt,{children:[c.jsx(ct,{asChild:!0,children:c.jsx("button",{type:"button",className:ne(Pt({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:G?xs:Ft,"aria-label":G?"Dock sidebar":"Float sidebar",children:G?c.jsx(te.Dock,{className:"h-4 w-4"}):c.jsx(te.PictureInPicture2,{className:"h-4 w-4"})})}),c.jsx(ut,{children:G?"Dock to sidebar":"Undock to floating window"})]}),c.jsxs(lt,{children:[c.jsx(ct,{asChild:!0,children:c.jsx("button",{type:"button",className:ne(Pt({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:G?xn:Wn,"aria-label":G?Ee?"Maximize":"Minimize":"Close sidebar",children:G?Ee?c.jsx(te.Maximize2,{className:"h-4 w-4"}):c.jsx(te.Minimize2,{className:"h-4 w-4"}):c.jsx(te.X,{className:"h-4 w-4"})})}),c.jsx(ut,{children:G?Ee?"Maximize window":"Minimize to header":"Close the chat"})]})]})]}),!Ee&&c.jsxs(c.Fragment,{children:[E&&Ge.length>0&&c.jsxs("div",{className:`border-b border-border ${Fe?"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(Ce,{variant:"ghost",className:"h-auto px-2 py-1 text-xs text-muted-foreground hover:text-foreground",onClick:()=>{we(!Fe)},children:Fe?"Show less":"View all"})]}),c.jsx("div",{className:`px-2 pb-2 space-y-0.5 ${Fe?"flex-1 overflow-y-auto":""}`,children:Ge.slice(0,Fe?void 0:3).map(C=>c.jsxs("div",{className:"group relative",children:[c.jsxs(Vf,{type:"button",className:ne(Pt({variant:"ghost"}),"w-full justify-between h-auto py-1 px-3 font-normal active:scale-[0.99]"),onClick:()=>{$t(C.chatId||C._id),we(!1)},children:[c.jsx("span",{className:"text-xs truncate",children:C.title}),c.jsx("div",{className:"ml-2 flex items-center",children:c.jsx("span",{className:"text-xs text-muted-foreground group-hover:hidden",children:tt(C.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(),Ue(C._id)},"aria-label":"Delete conversation",children:c.jsx(te.X,{className:"h-3 w-3"})})]},C._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:Ne.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?"}),qe.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?qe:qe.slice(0,10)).map(C=>c.jsxs(lt,{children:[c.jsx(ct,{asChild:!0,children:c.jsx(Ss,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>{ke(C.sampleUsage),xt.current?.focus()},children:C.friendlyName})}),c.jsx(ut,{children:c.jsxs("div",{className:"max-w-xs",children:[c.jsx("p",{className:"font-medium",children:C.description}),c.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:[c.jsx("span",{className:"font-medium",children:"Example:"}),' "',C.sampleUsage,'"']}),C.paramCount>0&&c.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[c.jsx("span",{className:"font-medium",children:"Parameters:"})," ",C.params.join(", ")]})]})})]},C.name)),qe.length>10&&!le&&c.jsxs(lt,{children:[c.jsx(ct,{asChild:!0,children:c.jsxs(Ss,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>fn(!0),children:["+",qe.length-10," more"]})}),c.jsx(ut,{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:qe.slice(10).map(C=>c.jsxs("div",{children:[c.jsxs("span",{className:"font-medium text-xs",children:[C.friendlyName,":"]}),c.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:C.description})]},C.name))}),c.jsx("p",{className:"text-xs text-muted-foreground mt-2 italic",children:"Click to show all tools"})]})})]}),le&&qe.length>10&&c.jsx(Ss,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>fn(!1),children:"Show less"})]})})]}):c.jsxs(c.Fragment,{children:[Ne.map(C=>{const z=C.parts.filter(W=>W.type==="text").map(W=>W.text).join("");let Z=C.parts;C.role==="assistant"&&C.parts.some(he=>he.timestamp)&&(Z=[...C.parts].sort((he,Q)=>{const Pe=he.timestamp||0,fe=Q.timestamp||0;return Pe-fe}));let H=[],J=new Map,ge=[],se,Se=!0;if(C.role==="assistant"){const W=Z.filter(fe=>fe.type==="text"&&fe.text),he=[],Q=[];W.forEach(fe=>{const{citations:y,citationMap:g,groupedCitations:x,referencesText:b}=xo(fe.text);H.push(...y),he.push(g),x&&Q.push(...x),b&&(se=b)}),he.forEach(fe=>{fe.forEach((y,g)=>{J.has(g)||J.set(g,y)})}),ge=Array.from(new Map(Q.map(fe=>[fe.url,fe])).values()).sort((fe,y)=>(fe.numbers[0]||0)-(y.numbers[0]||0)),Se=!(xe==="streaming"&&C.id===Ne.at(-1)?.id)}return c.jsx("div",{className:`${C.role==="user"?"flex justify-end":"w-full"}`,children:c.jsx("div",{className:`${C.role==="user"?"max-w-[85%] text-right":"w-full"}`,children:C.role==="user"?c.jsx(If,{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:z}):c.jsx("div",{className:"space-y-2",children:Z.map((W,he)=>{if(W.type?.startsWith("tool-")){const Q=W.type?.replace("tool-","")||"",Pe=Be.find(g=>g.name===Q),fe=W.state==="input-available",y=W.state==="output-available";if(fe&&wt.has(Q),fe){if(wt.has(Q))return null;const g=Fs(W.input);return c.jsx(Jn,{initial:{opacity:0,y:10,filter:"blur(4px)"},animate:{opacity:1,y:0,filter:"blur(0px)"},transition:{duration:.3,ease:"easeOut"},children:c.jsx(Of,{toolName:Q,description:Pe?.description||"",args:g,onApprove:async()=>{if(vt.has(W.toolCallId))return;it(b=>new Set(b).add(W.toolCallId));const x=Ot.get(Q);if(x)try{const b=await x(...Object.values(g));et({toolCallId:W.toolCallId,tool:Q,output:b})}catch(b){et({toolCallId:W.toolCallId,tool:Q,output:`Error: ${b}`})}},onDeny:async()=>{vt.has(W.toolCallId)||(it(x=>new Set(x).add(W.toolCallId)),et({toolCallId:W.toolCallId,tool:Q,output:"User denied tool execution"}))}})},`${W.toolCallId}-${he}`)}else if(y){const g=W.output==="User denied tool execution",x=Fs(W.input);return c.jsx(Lf,{toolName:Q,args:x,isDenied:g,isSafe:wt.has(Q)},`${W.toolCallId}-${he}`)}return null}if(W.type==="text"&&W.text&&dn){const{processedText:Q}=xo(W.text),g=!Z.slice(he+1).some(x=>x.type==="text"&&x.text)&&Se&&J.size>0;return c.jsx(Hf,{text:Q,citations:H,citationMap:J,groupedCitations:g?ge:void 0,referencesText:g?se:void 0,ResponseComponent:dn,className:"text-sm prose prose-sm dark:prose-invert max-w-none",showCitations:O,showReferences:g},`${C.id}-${he}`)}return W.type==="reasoning"&&W.text?c.jsxs(al,{className:"w-full",isStreaming:xe==="streaming"&&he===C.parts.length-1&&C.id===Ne.at(-1)?.id,children:[c.jsx(ll,{}),c.jsx(cl,{children:W.text})]},`${C.id}-${he}`):null})})})},C.id)}),c.jsx("div",{ref:$e})]})}),_n&&c.jsxs("div",{className:"px-4 py-2 bg-destructive/10 text-destructive text-xs",children:["Error: ",_n.message]}),c.jsxs("div",{className:"p-4 border-t border-border relative overflow-visible",children:[c.jsx(td,{mode:"wait",children:(xe==="streaming"||xe==="submitted")&&c.jsxs(Jn,{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(Jn,{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:Vt})]})}),c.jsxs("form",{onSubmit:yn,className:"relative",children:[c.jsx(jo,{ref:xt,value:bt,onChange:qn,placeholder:"Ask anything..",className:"w-full pr-12 resize-none border border-border rounded-xl px-4 py-3",minHeight:24,maxHeight:200,onKeyDown:C=>{C.key==="Enter"&&!C.shiftKey&&(C.preventDefault(),yn(C))}}),xe==="streaming"||xe==="submitted"?c.jsxs(lt,{children:[c.jsx(ct,{asChild:!0,children:c.jsx("button",{type:"button",className:ne(Pt({variant:"ghost",size:"icon"}),"absolute top-1/2 -translate-y-1/2 right-2 h-8 w-8"),onClick:Lt,children:c.jsx(te.Square,{className:"h-4 w-4"})})}),c.jsxs(ut,{children:[c.jsx(ei,{children:"Escape"})," to stop"]})]}):c.jsxs(lt,{children:[c.jsx(ct,{asChild:!0,children:c.jsx("button",{type:"submit",className:ne(Pt({variant:"ghost",size:"icon"}),"absolute top-1/2 -translate-y-1/2 right-2 h-8 w-8"),disabled:!bt.trim(),children:c.jsx(te.ArrowRight,{className:"h-4 w-4"})})}),c.jsxs(ut,{children:[c.jsx(ei,{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(te.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 am(e){return c.jsx(hl,{children:c.jsx(om,{...e})})}exports.verifyToken=Ml.verifyToken;exports.ARCTEN_ORIGINAL_NAME=Ve;exports.ArctenAgent=am;exports.SecureModalProvider=hl;exports.extractToolsMetadata=dr;exports.preserveToolName=kl;exports.useAgent=Co;exports.useSecureModal=dl;
15
+ `,style:X?G?{width:`${K}px`,height:Me?"auto":`${ge}px`,left:`${Pe.x}px`,top:`${Pe.y}px`}:{width:`${K}px`}:void 0,onClick:X?void 0:Gn,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:ut,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: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 ${G?"cursor-move":""}`,onMouseDown:G?Sn:void 0,children:[c.jsx("h2",{className:`text-base font-semibold ${G&&Me?"cursor-pointer":""}`,onClick:G&&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(ht,{asChild:!0,children:c.jsx("button",{type:"button",className:se(Mt({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:At,"aria-label":"New chat",children:c.jsx(te.Plus,{className:"h-4 w-4"})})}),c.jsx(ft,{children:"Start a new conversation"})]}),c.jsxs(dt,{children:[c.jsx(ht,{asChild:!0,children:c.jsx("button",{type:"button",className:se(Mt({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:G?Ss:zt,"aria-label":G?"Dock sidebar":"Float sidebar",children:G?c.jsx(te.Dock,{className:"h-4 w-4"}):c.jsx(te.PictureInPicture2,{className:"h-4 w-4"})})}),c.jsx(ft,{children:G?"Dock to sidebar":"Undock to floating window"})]}),c.jsxs(dt,{children:[c.jsx(ht,{asChild:!0,children:c.jsx("button",{type:"button",className:se(Mt({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:G?_t:Yn,"aria-label":G?Me?"Maximize":"Minimize":"Close sidebar",children:G?Me?c.jsx(te.Maximize2,{className:"h-4 w-4"}):c.jsx(te.Minimize2,{className:"h-4 w-4"}):c.jsx(te.X,{className:"h-4 w-4"})})}),c.jsx(ft,{children:G?Me?"Maximize window":"Minimize to header":"Close the chat"})]})]})]}),!Me&&c.jsxs(c.Fragment,{children:[E&&He.length>0&&c.jsxs("div",{className:`border-b border-border ${Ue?"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:()=>{Se(!Ue)},children:Ue?"Show less":"View all"})]}),c.jsx("div",{className:`px-2 pb-2 space-y-0.5 ${Ue?"flex-1 overflow-y-auto":""}`,children:He.slice(0,Ue?void 0:3).map(T=>c.jsxs("div",{className:"group relative",children:[c.jsxs(Ff,{type:"button",className:se(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),Se(!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:W=>{W.stopPropagation(),_e(T._id)},"aria-label":"Delete conversation",children:c.jsx(te.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?"}),Ge.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?Ge:Ge.slice(0,10)).map(T=>c.jsxs(dt,{children:[c.jsx(ht,{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:()=>{Ne(T.sampleUsage),wt.current?.focus()},children:T.friendlyName})}),c.jsx(ft,{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)),Ge.length>10&&!le&&c.jsxs(dt,{children:[c.jsx(ht,{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:["+",Ge.length-10," more"]})}),c.jsx(ft,{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:Ge.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&&Ge.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 U=T.parts.filter(_=>_.type==="text").map(_=>_.text).join("");let Z=T.parts;T.role==="assistant"&&T.parts.some(he=>he.timestamp)&&(Z=[...T.parts].sort((he,Q)=>{const Ae=he.timestamp||0,fe=Q.timestamp||0;return Ae-fe}));let H=[],J=new Map,Re=[],ne,xe=!0;if(T.role==="assistant"){const _=Z.filter(fe=>fe.type==="text"&&fe.text),he=[],Q=[];_.forEach(fe=>{const{citations:Ze,citationMap:be,groupedCitations:Te,referencesText:Qe}=So(fe.text);H.push(...Ze),he.push(be),Te&&Q.push(...Te),Qe&&(ne=Qe)}),he.forEach(fe=>{fe.forEach((Ze,be)=>{J.has(be)||J.set(be,Ze)})}),Re=Array.from(new Map(Q.map(fe=>[fe.url,fe])).values()).sort((fe,Ze)=>(fe.numbers[0]||0)-(Ze.numbers[0]||0)),xe=!(ye==="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(Bf,{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:U}):c.jsx("div",{className:"space-y-2",children:Z.map((_,he)=>{if(_.type?.startsWith("tool-")){const Q=_.type?.replace("tool-","")||"",Ae=ze.find(be=>be.name===Q),fe=_.state==="input-available",Ze=_.state==="output-available";if(fe&&Ct.has(Q),fe){if(Ct.has(Q))return null;const be=_s(_.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(Uf,{toolName:Q,description:Ae?.description||"",args:be,onApprove:async()=>{if(Tt.has(_.toolCallId))return;lt(Qe=>new Set(Qe).add(_.toolCallId));const Te=Ft.get(Q);if(Te)try{const Qe=await Te(...Object.values(be));st({toolCallId:_.toolCallId,tool:Q,output:Qe})}catch(Qe){st({toolCallId:_.toolCallId,tool:Q,output:`Error: ${Qe}`})}},onDeny:async()=>{Tt.has(_.toolCallId)||(lt(Te=>new Set(Te).add(_.toolCallId)),st({toolCallId:_.toolCallId,tool:Q,output:"User denied tool execution"}))}})},`${_.toolCallId}-${he}`)}else if(Ze){const be=_.output==="User denied tool execution",Te=_s(_.input);return c.jsx(zf,{toolName:Q,args:Te,isDenied:be,isSafe:Ct.has(Q)},`${_.toolCallId}-${he}`)}return null}if(_.type==="text"&&_.text&&pn){const{processedText:Q}=So(_.text),be=!Z.slice(he+1).some(Te=>Te.type==="text"&&Te.text)&&xe&&J.size>0;return c.jsx(tm,{text:Q,citations:H,citationMap:J,groupedCitations:be?Re:void 0,referencesText:be?ne:void 0,ResponseComponent:pn,className:"text-sm prose prose-sm dark:prose-invert max-w-none",showCitations:O,showReferences:be},`${T.id}-${he}`)}return _.type==="reasoning"&&_.text?c.jsxs(dl,{className:"w-full",isStreaming:ye==="streaming"&&he===T.parts.length-1&&T.id===De.at(-1)?.id,children:[c.jsx(hl,{}),c.jsx(fl,{children:_.text})]},`${T.id}-${he}`):null})})})},T.id)}),c.jsx("div",{ref:Be})]})}),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(od,{mode:"wait",children:(ye==="streaming"||ye==="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))}}),ye==="streaming"||ye==="submitted"?c.jsxs(dt,{children:[c.jsx(ht,{asChild:!0,children:c.jsx("button",{type:"button",className:se(Mt({variant:"ghost",size:"icon"}),"absolute top-1/2 -translate-y-1/2 right-2 h-8 w-8"),onClick:Bt,children:c.jsx(te.Square,{className:"h-4 w-4"})})}),c.jsxs(ft,{children:[c.jsx(ri,{children:"Escape"})," to stop"]})]}):c.jsxs(dt,{children:[c.jsx(ht,{asChild:!0,children:c.jsx("button",{type:"submit",className:se(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(te.ArrowRight,{className:"h-4 w-4"})})}),c.jsxs(ft,{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(te.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(dm,{...e})})}exports.verifyToken=Vl.verifyToken;exports.ARCTEN_ORIGINAL_NAME=Oe;exports.ArctenAgent=hm;exports.SecureModalProvider=gl;exports.extractToolsMetadata=pr;exports.preserveToolName=Il;exports.useAgent=Eo;exports.useSecureModal=pl;