@arcteninc/core 0.0.161 → 0.0.162

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 yl=Object.create;var Qr=Object.defineProperty;var xl=Object.getOwnPropertyDescriptor;var bl=Object.getOwnPropertyNames;var vl=Object.getPrototypeOf,wl=Object.prototype.hasOwnProperty;var Sl=(e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of bl(t))!wl.call(e,r)&&r!==n&&Qr(e,r,{get:()=>t[r],enumerable:!(s=xl(t,r))||s.enumerable});return e};var Tl=(e,t,n)=>(n=e!=null?yl(vl(e)):{},Sl(t||!e||!e.__esModule?Qr(n,"default",{value:e,enumerable:!0}):n,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react/jsx-runtime"),f=require("react"),ee=require("lucide-react"),Cl=require("@ai-sdk/react"),ei=require("ai"),wo=require("@radix-ui/react-slot"),So=require("class-variance-authority"),jl=require("clsx"),Pl=require("tailwind-merge"),Al=require("@radix-ui/react-tooltip"),ti=require("@radix-ui/react-use-controllable-state"),Ml=require("@radix-ui/react-collapsible"),El=require("react-dom"),kl=require("@radix-ui/react-dialog"),Nl=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 _e=ms(f),Gt=ms(Al),fr=ms(Ml),Rt=ms(kl),Oe=Symbol.for("@arcteninc/core:originalName");function Dl(e,t){return e[Oe]=t,e}function Rl(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 mr(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=Rl(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 Vl={password:[/^password$/i,/^pwd$/i,/^pass$/i,/^newPassword$/i,/^oldPassword$/i,/^currentPassword$/i,/^confirmPassword$/i,/.*password.*/i],email:[/^email$/i,/^emailAddress$/i,/^mail$/i,/.*email.*/i],phone:[/^phone$/i,/^phoneNumber$/i,/^mobile$/i,/^cell$/i,/^cellPhone$/i,/^telephone$/i,/.*phone.*/i,/.*mobile.*/i],pin:[/^pin$/i,/^pinCode$/i,/^securityPin$/i,/^accessPin$/i,/.*pin$/i],ssn:[/^ssn$/i,/^socialSecurityNumber$/i,/^social$/i,/.*ssn.*/i,/.*social.*/i],creditCard:[/^creditCard$/i,/^cardNumber$/i,/^card$/i,/^ccNumber$/i,/^creditCardNumber$/i,/.*card.*/i,/^cvv$/i,/^cvc$/i,/^cvn$/i,/^securityCode$/i],text:[]};function Sn(e){for(const[t,n]of Object.entries(Vl))if(t!=="text"){for(const s of n)if(s.test(e))return t}return null}function Il(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 Ol(e,t,n){return t.length>0}function Ll(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=$l(s[i]),d={name:i,type:Fl(l||Sn(i)||"text"),label:To(i),placeholder:Bl(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:Ol(e,t),fields:r,title:Ul(e),description:zl(e,r.length)}}function $l(e){if(e!=null){if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return String(e)}}function Fl(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 To(e){return e.replace(/([A-Z])/g," $1").replace(/_/g," ").trim().toLowerCase().split(" ").map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" ")}function Bl(e,t){return t?Il(t,e).placeholder:`Enter ${To(e).toLowerCase()}...`}function Ul(e){return e.replace(/([A-Z])/g," $1").trim().toLowerCase().split(" ").map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" ")}function zl(e,t){const n=e.toLowerCase();return t<=2?`Please provide the required information to ${n}.`:`Please fill out the form below to ${n}. Required fields are marked with *.`}function Cn(e){if(typeof e=="string")try{const t=JSON.parse(e);return Cn(t)}catch{return e}if(Array.isArray(e))return e.map(Cn);if(e&&typeof e=="object"){const t={};for(const[n,s]of Object.entries(e))t[n]=Cn(s);return t}return e}function _l(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 Xl(e){if(typeof e=="string"){try{const t=JSON.parse(e);if(t&&typeof t=="object"&&!Array.isArray(t))return Cn(t)}catch{}return{}}return e&&typeof e=="object"&&!Array.isArray(e)?Cn(e):{}}const ns="__secureOutput",ss="[hidden for privacy]";function Wl(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 Kl(e){if(typeof globalThis.structuredClone=="function")return globalThis.structuredClone(e);try{return JSON.parse(JSON.stringify(e))}catch(t){return console.warn("[useAgent] Failed to clone value for redaction:",t),e}}function ql(e){return e.replace(/\[(\w+)\]/g,".$1").split(".").map(t=>t.trim()).filter(Boolean)}function Gl(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 Yl(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 _s(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 Co(e,t=""){const n={};return e&&typeof e=="object"?Object.entries(e).forEach(([s,r])=>{const o=t?`${t}.${s}`:s;n[o]=_s(r),r&&typeof r=="object"&&Object.assign(n,Co(r,o))}):t&&(n[t]=_s(e)),n}function Hl(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 Jl(e){if(!e)return{};const t={};for(const[n,s]of Object.entries(e)){const r=Hl(s);r&&(t[n]=r)}return t}function jo(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=Co(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 jo(e,t,{...n,strategy:"full",fields:[]});if(typeof t!="object"||t===null)return{value:s,[ns]:{...r,redactedFields:n.fields}};const o=Kl(t),i=[],a={};return n.fields.forEach(l=>{const u=ql(l);if(u.length===0)return;const d=Gl(o,u),h=_s(d);a[l]=h,Yl(o,u,s)&&i.push(l)}),r.redactedFields=i,n.includeFieldStatus&&(r.fieldStatus=a),o[ns]=r,o}function Po({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:T,projectId:b,enableRemoteConfig:E,remoteConfigUrl:M,initialMessages:$=[],conversationId:D,state:I,onStateChange:N,allowStateEdits:P=!0,onToolCall:O,onFinish:A,sources:k,ragConfig:F,ragFilters:V,secureInputHandler:B}={}){const X=e.replace(/\/+$/,""),[Y,q]=f.useState(null),[ie,ye]=f.useState(!1),[We,bt]=f.useState(null),tt=f.useMemo(()=>{const g=k||[],y=Y?.config?.sources||[];return[...new Set([...g,...y])]},[k,Y]),G=f.useMemo(()=>F!==void 0?F:V?{enabled:!0,filters:V}:tt&&tt.length>0?{enabled:!0,organizationId:tt[0],autoExecute:!0,filters:void 0}:{enabled:!1},[tt,F,V]),Vt=f.useMemo(()=>E===!1?!1:!!b,[b,E]);f.useEffect(()=>{if(!Vt||!oe.current)return;(async()=>{ye(!0),bt(null);try{const x=`${M||X.replace("/chat","").replace(/\/$/,"")}/convex/api/query`,w=await fetch(x,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${oe.current}`},body:JSON.stringify({path:"agents:getConfigForClient",args:{projectId:b,agentName:T,agentId:v},format:"json"})});if(!w.ok){if(w.status===404){console.warn("[useAgent] Remote config endpoint not found (404), using local tools only"),q(null);return}const R=await w.text().catch(()=>"Unknown error");throw new Error(`Failed to fetch remote config: ${w.status} ${R}`)}const j=await w.json();q(j?.value||null),console.log("[useAgent] Remote config loaded successfully:",j?.value)}catch(y){console.error("[useAgent] Failed to fetch remote config:",y);const x=y instanceof Error?y:new Error(String(y));bt(x),q(null)}finally{ye(!1)}})()},[Vt,b,T,v,X,M]);const Me=f.useMemo(()=>{const g={};if(u)for(const[y,x]of Object.entries(u))if(g[y]={},Array.isArray(x))for(const w of x){const j=Sn(w);g[y][w]=j||"text"}else for(const[w,j]of Object.entries(x))g[y][w]=j;if(l){for(const[y,x]of Object.entries(l))if(x&&typeof x=="object"&&"sensitiveParams"in x){g[y]||(g[y]={});const w=x.sensitiveParams;if(Array.isArray(w))for(const j of w){const R=Sn(j);g[y][j]=R||"text"}else if(w&&typeof w=="object")for(const[j,R]of Object.entries(w))g[y][j]=R}}return g},[u,l,h]),vt=f.useMemo(()=>Jl(d),[d]),je=f.useCallback((g,y)=>{const x=vt[g];if(!x)return y;try{return jo(g,y,x)}catch(w){return console.error(`[useAgent] Failed to redact output for ${g}:`,w),{value:ss,[ns]:{tool:g,redacted:!0,error:String(w)}}}},[vt]),[Fe,un]=f.useState(n||null),oe=f.useRef(n||null),[dn,wt]=f.useState(null),[hn,Bn]=f.useState(null),Be=f.useRef(null),[St,Tt]=f.useState([]),[ke,fn]=f.useState(D||(typeof window<"u"?crypto.randomUUID():null)),[bs,It]=f.useState(!1),mn=f.useRef(new Set),[Ot,nt]=f.useState(new Map),[vs,Un]=f.useState(new Map),[st,zn]=f.useState(new Map),[_n,Lt]=f.useState(new Map),ce=I!==void 0,[$t,ct]=f.useState({}),xe=f.useRef({}),pn=ce?I||{}:$t;ce&&I?xe.current=I:ce||(xe.current=$t);const[Ke,Re]=f.useState(!1),[gn,qe]=f.useState(null),Ct=f.useRef(!1),Xn=f.useCallback(async(g,y=3)=>{if(!ke||!oe.current)return;const x=async()=>{const j=`${X.replace("/chat","").replace(/\/$/,"")}/convex/api/mutation`,R=await fetch(j,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${oe.current}`},body:JSON.stringify({path:"conversations:mergeStateByChatId",args:{chatId:ke,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<y;w++)try{await x(),qe(null);return}catch(j){if(w===y-1){const L=j instanceof Error?j:new Error(String(j));throw qe(L),console.error("Failed to sync state to Convex after retries:",j),L}await new Promise(L=>setTimeout(L,Math.pow(2,w)*100))}},[ke,X,oe]),Pe=f.useMemo(()=>function(){return xe.current},[]),ut=f.useMemo(()=>async function(y){const x={...xe.current,...y};xe.current=x,ce||ct(x),N&&N(x);try{await Xn(y)}catch(w){throw w}},[Xn,N,ce]);f.useEffect(()=>{ce&&I&&(xe.current=I)},[ce,I]);const Ne=f.useCallback(g=>B?B.showSecureModal(g):new Promise(y=>{nt(x=>new Map(x).set(g.id,g)),Un(x=>new Map(x).set(g.id,y))}),[B]),Wn=f.useCallback((g,y)=>{if(B)return;const x=vs.get(g);x&&(x(y),nt(w=>{const j=new Map(w);return j.delete(g),j}),Un(w=>{const j=new Map(w);return j.delete(g),j}))},[vs,B]),Ft=f.useCallback(g=>B?B.showSecureForm(g):new Promise(y=>{zn(x=>new Map(x).set(g.id,g)),Lt(x=>new Map(x).set(g.id,y))}),[B]),rt=f.useCallback((g,y)=>{if(B)return;const x=_n.get(g);x&&(x(y),zn(w=>{const j=new Map(w);return j.delete(g),j}),Lt(w=>{const j=new Map(w);return j.delete(g),j}))},[_n,B]),Kn=f.useCallback((g,y)=>{const x=Me[g]||{},w=Object.keys(x).length>0;if(h){const j=Object.keys(y).filter(R=>Sn(R)!==null);return w||j.length>0}return w},[Me,h]),qn=f.useCallback((g,y)=>{const w={...Me[g]||{}};if(h){for(const R of Object.keys(y))if(!(R in w)){const L=Sn(R);L&&(w[R]=L)}}const j=Object.entries(w).filter(([R])=>Object.prototype.hasOwnProperty.call(y,R));return j.length>0?Object.fromEntries(j):w},[Me,h]),Ge=f.useMemo(()=>G?.enabled?async function(y,x=20,w){const j={...G.filters,...w};if(k&&k.length>1){const L=k.map(K=>fetch(`${X}/search`,{method:"POST",headers:{"Content-Type":"application/json",...oe.current?{Authorization:`Bearer ${oe.current}`}:{}},body:JSON.stringify({q:y,k:Math.min(x,100),organizationId:K,...Object.keys(j).length>0?{filters:j}:{}})}).then(re=>re.ok?re.json():null)),ae=await Promise.all(L),Q=[];for(const K of ae)K?.candidates&&Q.push(...K.candidates);Q.sort((K,re)=>{const Qe=K.scores?.rerank||K.scores?.dense||0;return(re.scores?.rerank||re.scores?.dense||0)-Qe});const be=Q.slice(0,x).map((K,re)=>{const Qe=K.citation||K.url;return{rank:re+1,doc_id:K.doc_id,block_id:K.block_id,url:K.url,citation:Qe,title:K.title||"Untitled",snippet:K.snippet,score:K.scores?.rerank||K.scores?.dense||0,metadata:{site:K.metadata?.site,lang:K.metadata?.lang,contentType:K.metadata?.content_type}}});return{success:!0,query:y,total:Q.length,results:be,summary:`Found ${Q.length} relevant results across ${k.length} source(s) for "${y}". 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:y,k:Math.min(x,100)};R&&(L.organizationId=R),Object.keys(j).length>0&&(L.filters=j);const ae={"Content-Type":"application/json"};oe.current&&(ae.Authorization=`Bearer ${oe.current}`);const Q=await fetch(`${X}/search`,{method:"POST",headers:ae,body:JSON.stringify(L)});if(!Q.ok){const re=await Q.text();return{success:!1,error:`Search failed: ${Q.status} ${re}`}}const be=await Q.json(),K=be.candidates.map((re,Qe)=>{const vn=re.citation||re.url;return{rank:Qe+1,doc_id:re.doc_id,block_id:re.block_id,url:re.url,citation:vn,title:re.title||"Untitled",snippet:re.snippet,score:re.scores?.rerank||re.scores?.dense||0,metadata:{site:re.metadata?.site,lang:re.metadata?.lang,contentType:re.metadata?.content_type}}});return{success:!0,query:be.query,total:be.total,results:K,summary:`Found ${be.total} relevant results for "${y}". Top result: ${K[0]?.title||"N/A"}`}}catch(L){return{success:!1,error:L instanceof Error?L.message:"Unknown error occurred"}}}:null,[G,X,oe]),Ye=f.useMemo(()=>G?.enabled?async function(y,x){const w=G.organizationId&&G.organizationId!=="default"?G.organizationId:k&&k.length>0?k[0]:void 0;try{const j={"Content-Type":"application/json"};oe.current&&(j.Authorization=`Bearer ${oe.current}`);const R=await fetch(`${X}/fetch`,{method:"POST",headers:j,body:JSON.stringify({doc_id:y,block_ids:x,...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||y}`}}catch(j){return{success:!1,error:j instanceof Error?j.message:"Unknown error occurred"}}}:null,[G,X,oe]),yn=f.useMemo(()=>{if(Y&&Y.config?.tools){const g=Wl(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]),Ue=Y?.enableStateTools??!0,He=Y?.enableRagTools??G?.enabled??!1,Gn=f.useMemo(()=>{const g=[...yn,...i];return Ue&&(g.push(Pe),(!ce||P)&&g.push(ut)),He&&(Ge&&g.push(Ge),Ye&&g.push(Ye)),g},[yn,i,Pe,ut,Ge,Ye,Ue,He,ce,P]),Yn=f.useMemo(()=>[...yn,...i],[yn,i]),it=f.useMemo(()=>mr(Yn,l),[Yn,l]),jt=f.useMemo(()=>{const g=new Map,y=new Map(it.map(x=>[x.name,x]));return g.set("getState",Pe),(!ce||P)&&g.set("setState",ut),G?.enabled&&(Ge&&g.set("searchDocs",Ge),Ye&&g.set("fetchDocContent",Ye)),Gn.forEach(x=>{if(x===Pe||x===ut||x===Ge||x===Ye)return;const w=x[Oe];if(w){const R=y.get(w);if(R){g.set(R.name,x);return}}const j=it.find(R=>R.name===x.name);j&&g.set(j.name,x)}),g},[Gn,it,Pe,ut,Ge,Ye,G,ce,P]),Hn=f.useMemo(()=>new Set(it.map(g=>g.name)),[it]),xn=f.useMemo(()=>{const g=[];Ue&&(g.push({name:"getState",description:"Get the current agent state. Returns IDs, workflow state, checklists, and other persistent data.",jsonSchema:{type:"object",properties:{},required:[]}}),(!ce||P)&&g.push({name:"setState",description:"Update the agent state. Store IDs, workflow state, checklists, context, and other data that must persist across conversations. Merges with existing state.",jsonSchema:{type:"object",properties:{updates:{type:"object",description:"Partial state updates to merge with existing state"}},required:["updates"]}}));const y=[];He&&y.push({name:"searchDocs",description:"Search documentation using semantic search. Returns relevant results with snippets and scores. Use this first to find relevant documentation. Default returns 20 results - use higher k values (30-50) when you need to find many sources.",jsonSchema:{type:"object",properties:{query:{type:"string",description:"The search query (user's question or keywords)"},k:{type:"number",description:"Number of results to return (default: 20, max: 100). Use 20-30 for comprehensive searches, or higher (50-100) when you need to find all relevant sources.",default:20},filters:{type:"object",description:"Optional filters to scope the search",properties:{site:{type:"string"},lang:{type:"string"},tags:{type:"array",items:{type:"string"}},docIds:{type:"array",items:{type:"string"}},pageIds:{type:"array",items:{type:"string"}}}}},required:["query"]}},{name:"fetchDocContent",description:"Fetch full content of documentation blocks after searching. Use this AFTER searchDocs when you find relevant results (scores > 0.3) to get complete text. Automatically fetches nearby blocks (5 chunks before/after each requested block) for context. You can pass multiple block_ids to fetch comprehensive content from multiple blocks/pages.",jsonSchema:{type:"object",properties:{doc_id:{type:"string",description:"The doc_id from searchDocs results"},block_ids:{type:"array",items:{type:"string"},description:"Array of block_ids from searchDocs results. You can pass multiple block_ids to fetch comprehensive content."}},required:["doc_id","block_ids"]}});const x=[];return Y?.config?.workflows&&Y.config.workflows.forEach(w=>{const j={},R=[];w.parameters&&w.parameters.forEach(L=>{j[L.name]={type:L.type||"string",description:L.description},L.required&&R.push(L.name)}),x.push({name:`workflow_${w.name.replace(/\s+/g,"_").toLowerCase()}`,description:w.description||`Execute the "${w.name}" workflow. ${w.contentPlaintext?.slice(0,200)||""}`,jsonSchema:{type:"object",properties:j,required:R},_workflow:w})}),[...it,...g,...y,...x]},[it,Ue,He,ce,P,Y]),dt=f.useMemo(()=>xn.filter(g=>g.name==="getState"?Ue:g.name==="setState"?Ue&&(!ce||P):g.name==="searchDocs"||g.name==="fetchDocContent"?He:g.name.startsWith("workflow_")?!0:Hn.has(g.name)),[xn,Hn,Ue,He,ce,P]),Bt=f.useMemo(()=>{const g=new Set;return Ue&&(g.add("getState"),g.add("setState")),He&&G?.autoExecute!==!1&&(g.add("searchDocs"),g.add("fetchDocContent")),Y?.config?.tools?Y.config.tools.forEach(y=>{y.isEnabled&&!y.requiresApproval&&g.add(y.name)}):(i.forEach(y=>{for(const[x,w]of jt.entries())if(w===y){g.add(x);break}}),a&&Array.isArray(a)&&a.forEach(y=>{typeof y=="string"&&g.add(y)})),Y?.config?.workflows&&Y.config.workflows.forEach(y=>{const x=`workflow_${y.name.replace(/\s+/g,"_").toLowerCase()}`;y.requiresApproval||g.add(x)}),g},[Y,i,a,jt,Ue,He,G]);f.useEffect(()=>s||n?void 0:((async()=>{try{const y=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:r})});if(!y.ok)throw new Error("Failed to fetch token");const x=await y.json();un(x.clientToken),oe.current=x.clientToken,Bn(x.expiresAt),wt(null)}catch(y){console.error("[useAgent] Token fetch failed:",y),wt(y instanceof Error?y.message:"Failed to fetch token")}})(),()=>{Be.current&&clearTimeout(Be.current)}),[t,JSON.stringify(r),s,n]),f.useEffect(()=>{if(!hn||s||n)return;Be.current&&clearTimeout(Be.current);const g=Math.floor(Date.now()/1e3),y=hn-g,w=Math.max(0,y-5);return Be.current=setTimeout(async()=>{try{const j=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:r})});if(!j.ok)throw new Error("Failed to refresh token");const R=await j.json();un(R.clientToken),oe.current=R.clientToken,Bn(R.expiresAt),wt(null)}catch(j){console.error("[useAgent] Token refresh failed:",j),wt(j instanceof Error?j.message:"Failed to refresh token")}},w*1e3),()=>{Be.current&&clearTimeout(Be.current)}},[hn,t,JSON.stringify(r),s,n]);const ws=async(g,y={})=>{const x=y.headers?new Headers(y.headers):new Headers;x.delete("user-agent"),x.delete("User-Agent"),console.log("[useAgent] Making request to:",g),console.log("[useAgent] Method:",y.method||"GET"),console.log("[useAgent] Has Authorization header:",x.has("Authorization")),console.log("[useAgent] Client token available:",!!oe.current);try{const w=await fetch(g,{...y,headers:x});if(!w.ok){console.error("[useAgent] Request failed:",w.status,w.statusText);const j=await w.text().catch(()=>"Unable to read error response");console.error("[useAgent] Error response:",j)}return w}catch(w){throw console.error("[useAgent] Fetch error:",w),w}},Ut=f.useRef(null),bn=`${X}/chat`;console.log("[useAgent] Chat API URL:",bn);const{messages:Je,sendMessage:C,status:_,error:z,stop:Z,addToolResult:H,setMessages:J}=Cl.useChat({id:ke||void 0,messages:$,transport:new ei.DefaultChatTransport({api:bn,fetch:ws,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 =",T);const g=dt.map(w=>({name:w.name,description:w.description,inputSchema:w.jsonSchema})),y=g.filter(w=>w.name==="getState"||w.name==="setState").map(w=>w.name),x=g.filter(w=>w.name==="searchDocs"||w.name==="fetchDocContent").map(w=>w.name);return y.length>0&&console.log("[useAgent] State tools included in tools list sent to AI SDK:",y),x.length>0?console.log("[useAgent] RAG tools included in tools list sent to AI SDK:",x):G?.enabled&&console.warn("[useAgent] RAG is enabled but no RAG tools found in tools list!"),{tools:g,...v&&{agentId:v},...T&&{agentName:T},state:xe.current,...V&&{ragFilters:V}}}}),sendAutomaticallyWhen:g=>{const y=g.messages,x=y[y.length-1];if(console.log("[sendAutomaticallyWhen] ===== CALLED ====="),console.log("[sendAutomaticallyWhen] lastMessage role:",x?.role),console.log("[sendAutomaticallyWhen] message count:",y.length),x?.role!=="assistant")return console.log("[sendAutomaticallyWhen] BLOCKED: not assistant"),!1;const j=[...y].reverse().find(L=>L.role==="user")?.id;if(console.log("[sendAutomaticallyWhen] lastUserMessageId:",j),console.log("[sendAutomaticallyWhen] ref.current:",Ut.current),j&&Ut.current===j)return console.log("[sendAutomaticallyWhen] BLOCKED: already auto-sent for this user message"),!1;const R=ei.lastAssistantMessageIsCompleteWithToolCalls(g);return console.log("[sendAutomaticallyWhen] shouldAutoSend (from SDK helper):",R),R&&j&&(console.log("[sendAutomaticallyWhen] SETTING ref to:",j),Ut.current=j),console.log("[sendAutomaticallyWhen] RETURNING:",R),R}}),De=C,se=f.useCallback(g=>(Ut.current=null,De(g)),[De]),ue=f.useCallback((g,y,x)=>{const w=je(g,x);H({toolCallId:y,tool:g,output:w})},[H,je]);f.useEffect(()=>{Je.forEach(g=>{g.role==="assistant"&&g.parts.forEach(y=>{if(!y.type?.startsWith("tool-")||y.state!=="input-available")return;const x=y.type.replace("tool-",""),w=y.toolCallId;if(mn.current.has(w))return;mn.current.add(w);const j=Xl(y.input);if(Kn(x,j)){const R=qn(x,j),L=Object.entries(R).filter(([K])=>j[K]!==void 0),ae=L.length>0?Object.fromEntries(L):R,Q=Object.keys(j),be=_l(j,ae);(async()=>{try{const K=Ll(x,Q,ae,j),re={id:`${w}-form`,toolName:x,toolCallId:w,title:K.title,description:K.description,fields:K.fields},Qe=await Ft(re);if(Qe===null){ue(x,w,"User cancelled secure input");return}const vn={...be,...Qe},Ss=jt.get(x);if(!Ss)throw new Error(`Tool ${x} not found`);let Ts;const Cs=dt.find(Zr=>Zr.name===x);if(Cs&&Cs.jsonSchema?.properties){const pl=Object.keys(Cs.jsonSchema.properties).map(gl=>vn[gl]);Ts=await Ss(...pl)}else Ts=await Ss(...Object.values(vn));ue(x,w,Ts)}catch(K){console.error(`[useAgent] Error executing tool with secure input ${x}:`,K),ue(x,w,`Error: ${K}`)}})();return}if(x.startsWith("workflow_")&&Bt.has(x)){(async()=>{try{const L=dt.find(Q=>Q.name===x)?._workflow;if(!L)throw new Error(`Workflow metadata not found for ${x}`);let ae;if(L.webhook?.url){let Q=j;if(L.webhook.bodyTemplate){let K=L.webhook.bodyTemplate;Object.entries(j).forEach(([re,Qe])=>{K=K.replace(new RegExp(`\\{\\{${re}\\}\\}`,"g"),String(Qe))}),Q=JSON.parse(K)}const be=await fetch(L.webhook.url,{method:L.webhook.method||"POST",headers:{"Content-Type":"application/json",...L.webhook.headers||{}},body:JSON.stringify(Q)});if(be.ok)ae={success:!0,data:await be.json().catch(()=>({success:!0}))};else{const K=await be.text();ae={success:!1,error:`Webhook failed: ${be.status} ${K}`}}}else ae={success:!0,message:`Workflow "${L.name}" acknowledged. Follow the workflow instructions to proceed.`,instructions:L.contentPlaintext};ue(x,w,ae)}catch(R){console.error(`[useAgent] Error executing workflow ${x}:`,R),ue(x,w,`Error: ${R}`)}})();return}if(Bt.has(x)&&!Kn(x,j)){const R=jt.get(x);R?(async()=>{try{const L=dt.find(Q=>Q.name===x);let ae;if(L&&L.jsonSchema?.properties){const be=Object.keys(L.jsonSchema.properties).map(K=>j[K]);ae=await R(...be)}else if(x==="getState")ae=R();else if(x==="setState"){const Q=j.updates||j;ae=await R(Q)}else ae=await R(...Object.values(j));ue(x,w,ae)}catch(L){console.error(`[useAgent] Error executing tool ${x}:`,L),ue(x,w,`Error: ${L}`)}})():console.warn(`[useAgent] Tool ${x} not found in toolsMap`)}else x.startsWith("workflow_")&&O?O({toolCall:{toolCallId:w,toolName:x,args:j}}):O&&O({toolCall:{toolCallId:w,toolName:x,args:j}})})})},[Je,Bt,jt,O,ue,ut,dt,Kn,qn,Ne]),f.useEffect(()=>{if(_==="ready"&&Je.length>0&&A){const g=Je[Je.length-1];g&&g.role==="assistant"&&A({message:g,messages:Je,isAbort:!1,isDisconnect:!1,isError:!!z})}},[_,Je,z,A]);async function W(){if(!(!r?.id||!Fe)){It(!0);try{const y=await(await fetch(`${X}/conversations`,{headers:{Authorization:`Bearer ${Fe}`}})).json();Tt(y.conversations||[])}catch(g){console.error("Failed to fetch conversations:",g)}finally{It(!1)}}}f.useEffect(()=>{r?.id&&Fe&&W()},[JSON.stringify(r),Fe,X]),f.useEffect(()=>{if(!ke||!oe.current)return;(async()=>{Re(!0),qe(null);try{const y=await fetch(`${X.replace("/chat","")}/convex/api/query`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${oe.current}`},body:JSON.stringify({path:"conversations:getStateByChatId",args:{chatId:ke},format:"json"})});if(!y.ok){const j=await y.text().catch(()=>"Unknown error");throw new Error(`Failed to fetch conversation state: ${y.status} ${j}`)}const w=(await y.json())?.value||{};xe.current=w,ce||ct(w),N&&N(w),Ct.current=!0}catch(y){console.error("Failed to fetch state:",y);const x=y instanceof Error?y:new Error(String(y));qe(x),Ct.current||(xe.current={},ce?N&&N({}):(ct({}),N&&N({})),Ct.current=!0)}finally{Re(!1)}})()},[ke,X,ce,N]);async function me(g){fn(g),It(!0);try{const y=await fetch(`${X}/conversations/${g}/messages`,{headers:{Authorization:`Bearer ${oe.current}`}});if(!y.ok)throw new Error(`Failed to fetch messages: ${y.statusText}`);const w=(await y.json()).messages||[];J(w)}catch(y){console.error("Failed to load conversation messages:",y)}finally{It(!1)}}async function te(g){if(Fe)try{await fetch(`${X}/conversations/${g}`,{method:"DELETE",headers:{Authorization:`Bearer ${Fe}`}}),Tt(St.filter(y=>y._id!==g)),g===ke&&Se()}catch(y){console.error("Failed to delete conversation:",y)}}function Se(){const g=crypto.randomUUID();fn(g),J([]),mn.current=new Set,xe.current={},ce?N&&N({}):(ct({}),N&&N({})),Ct.current=!1}function de(g){const y=g.tool||"unknown-tool",x=je(y,g.output);H({toolCallId:g.toolCallId,tool:y,output:x})}async function Ze(g,y,x){if(!y.startsWith("workflow_"))throw new Error(`${y} is not a workflow tool`);try{const j=dt.find(L=>L.name===y)?._workflow;if(!j)throw new Error(`Workflow metadata not found for ${y}`);let R;if(j.webhook?.url){let L=x;if(j.webhook.bodyTemplate){let Q=j.webhook.bodyTemplate;Object.entries(x).forEach(([be,K])=>{Q=Q.replace(new RegExp(`\\{\\{${be}\\}\\}`,"g"),String(K))}),L=JSON.parse(Q)}const ae=await fetch(j.webhook.url,{method:j.webhook.method||"POST",headers:{"Content-Type":"application/json",...j.webhook.headers||{}},body:JSON.stringify(L)});if(ae.ok)R={success:!0,data:await ae.json().catch(()=>({success:!0}))};else{const Q=await ae.text();R={success:!1,error:`Webhook failed: ${ae.status} ${Q}`}}}else R={success:!0,message:`Workflow "${j.name}" acknowledged. Follow the workflow instructions to proceed.`,instructions:j.contentPlaintext};return de({toolCallId:g,tool:y,output:R}),R}catch(w){const j={success:!1,error:String(w)};throw de({toolCallId:g,tool:y,output:j}),w}}async function ve(g){const y={...xe.current,...g};xe.current=y,ce||ct(y),N&&N(y);try{await Xn(g)}catch(x){throw x}}return{id:ke,messages:Je,status:_,error:z,sendMessage:se,stop:Z,addToolOutput:de,executeWorkflowTool:Ze,setMessages:J,conversations:St,loadConversation:me,deleteConversation:te,startNewConversation:Se,isLoadingConversations:bs,clientToken:Fe,tokenError:dn,state:pn,setState:ve,isStateLoading:Ke,stateError:gn,pendingSecureInputs:Array.from(Ot.values()),completeSecureInput:Wn,pendingSecureForms:Array.from(st.values()),completeSecureForm:rt,safeToolNames:Bt}}function ne(...e){return Pl.twMerge(jl.clsx(e))}const At=So.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?wo.Slot:"button";return c.jsx(i,{ref:o,"data-slot":"button",className:ne(At({variant:t,size:n,className:e})),...r})});Ce.displayName="Button";const Zl=So.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 js({className:e,variant:t,asChild:n=!1,...s}){const r=n?wo.Slot:"span";return c.jsx(r,{"data-slot":"badge",className:ne(Zl({variant:t}),e),...s})}const Ql=({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])},Ao=_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 Ql({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)}})});Ao.displayName="AutosizeTextarea";function ec({delayDuration:e=0,...t}){return c.jsx(Gt.Provider,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function ht({...e}){return c.jsx(ec,{children:c.jsx(Gt.Root,{"data-slot":"tooltip",...e})})}function ft({...e}){return c.jsx(Gt.Trigger,{"data-slot":"tooltip-trigger",...e})}function mt({className:e,sideOffset:t=0,children:n,...s}){return c.jsx(Gt.Portal,{children:c.jsxs(Gt.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(Gt.Arrow,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}function ni({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 pr=f.createContext({});function gr(e){const t=f.useRef(null);return t.current===null&&(t.current=e()),t.current}const yr=typeof window<"u",Mo=yr?f.useLayoutEffect:f.useEffect,ps=f.createContext(null);function xr(e,t){e.indexOf(t)===-1&&e.push(t)}function br(e,t){const n=e.indexOf(t);n>-1&&e.splice(n,1)}const ot=(e,t,n)=>n>t?t:n<e?e:n;function Xs(e,t){return t?`${e}. For more information and steps for solving, visit https://motion.dev/troubleshooting/${t}`:e}let Zt=()=>{},at=()=>{};process.env.NODE_ENV!=="production"&&(Zt=(e,t,n)=>{!e&&typeof console<"u"&&console.warn(Xs(t,n))},at=(e,t,n)=>{if(!e)throw new Error(Xs(t,n))});const lt={},Eo=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e);function ko(e){return typeof e=="object"&&e!==null}const No=e=>/^0[^.\s]+$/u.test(e);function vr(e){let t;return()=>(t===void 0&&(t=e()),t)}const $e=e=>e,tc=(e,t)=>n=>t(e(n)),On=(...e)=>e.reduce(tc),kn=(e,t,n)=>{const s=t-e;return s===0?1:(n-e)/s};class wr{constructor(){this.subscriptions=[]}add(t){return xr(this.subscriptions,t),()=>br(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,Le=e=>e/1e3;function Do(e,t){return t?e*(1e3/t):0}const si=new Set;function Sr(e,t,n){e||si.has(t)||(console.warn(Xs(t,n)),si.add(t))}const Ro=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,nc=1e-7,sc=12;function rc(e,t,n,s,r){let o,i,a=0;do i=t+(n-t)/2,o=Ro(i,s,r)-e,o>0?n=i:t=i;while(Math.abs(o)>nc&&++a<sc);return i}function Ln(e,t,n,s){if(e===t&&n===s)return $e;const r=o=>rc(o,0,1,e,n);return o=>o===0||o===1?o:Ro(r(o),t,s)}const Vo=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,Io=e=>t=>1-e(1-t),Oo=Ln(.33,1.53,.69,.99),Tr=Io(Oo),Lo=Vo(Tr),$o=e=>(e*=2)<1?.5*Tr(e):.5*(2-Math.pow(2,-10*(e-1))),Cr=e=>1-Math.sin(Math.acos(e)),Fo=Io(Cr),Bo=Vo(Cr),ic=Ln(.42,0,1,1),oc=Ln(0,0,.58,1),Uo=Ln(.42,0,.58,1),ac=e=>Array.isArray(e)&&typeof e[0]!="number",zo=e=>Array.isArray(e)&&typeof e[0]=="number",ri={linear:$e,easeIn:ic,easeInOut:Uo,easeOut:oc,circIn:Cr,circInOut:Bo,circOut:Fo,backIn:Tr,backInOut:Lo,backOut:Oo,anticipate:$o},lc=e=>typeof e=="string",ii=e=>{if(zo(e)){at(e.length===4,"Cubic bezier arrays must contain four numerical values.","cubic-bezier-length");const[t,n,s,r]=e;return Ln(t,n,s,r)}else if(lc(e))return at(ri[e]!==void 0,`Invalid easing type '${e}'`,"invalid-easing-type"),ri[e];return e},Jn=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function cc(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 uc=40;function _o(e,t){let n=!1,s=!0;const r={delta:0,timestamp:0,isProcessing:!1},o=()=>n=!0,i=Jn.reduce((M,$)=>(M[$]=cc(o),M),{}),{setup:a,read:l,resolveKeyframes:u,preUpdate:d,update:h,preRender:m,render:p,postRender:S}=i,v=()=>{const M=lt.useManualTiming?r.timestamp:performance.now();n=!1,lt.useManualTiming||(r.delta=s?1e3/60:Math.max(Math.min(M-r.timestamp,uc),1)),r.timestamp=M,r.isProcessing=!0,a.process(r),l.process(r),u.process(r),d.process(r),h.process(r),m.process(r),p.process(r),S.process(r),r.isProcessing=!1,n&&t&&(s=!1,e(v))},T=()=>{n=!0,s=!0,r.isProcessing||e(v)};return{schedule:Jn.reduce((M,$)=>{const D=i[$];return M[$]=(I,N=!1,P=!1)=>(n||T(),D.schedule(I,N,P)),M},{}),cancel:M=>{for(let $=0;$<Jn.length;$++)i[Jn[$]].cancel(M)},state:r,steps:i}}const{schedule:le,cancel:gt,state:we,steps:Ps}=_o(typeof requestAnimationFrame<"u"?requestAnimationFrame:$e,!0);let rs;function dc(){rs=void 0}const Ee={now:()=>(rs===void 0&&Ee.set(we.isProcessing||lt.useManualTiming?we.timestamp:performance.now()),rs),set:e=>{rs=e,queueMicrotask(dc)}},Xo=e=>t=>typeof t=="string"&&t.startsWith(e),jr=Xo("--"),hc=Xo("var(--"),Pr=e=>hc(e)?fc.test(e.split("/*")[0].trim()):!1,fc=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu,Qt={test:e=>typeof e=="number",parse:parseFloat,transform:e=>e},Nn={...Qt,transform:e=>ot(0,1,e)},Zn={...Qt,default:1},jn=e=>Math.round(e*1e5)/1e5,Ar=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function mc(e){return e==null}const pc=/^(?:#[\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"&&pc.test(n)&&n.startsWith(e)||t&&!mc(n)&&Object.prototype.hasOwnProperty.call(n,t)),Wo=(e,t,n)=>s=>{if(typeof s!="string")return s;const[r,o,i,a]=s.match(Ar);return{[e]:parseFloat(r),[t]:parseFloat(o),[n]:parseFloat(i),alpha:a!==void 0?parseFloat(a):1}},gc=e=>ot(0,255,e),As={...Qt,transform:e=>Math.round(gc(e))},Et={test:Mr("rgb","red"),parse:Wo("red","green","blue"),transform:({red:e,green:t,blue:n,alpha:s=1})=>"rgba("+As.transform(e)+", "+As.transform(t)+", "+As.transform(n)+", "+jn(Nn.transform(s))+")"};function yc(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 Ws={test:Mr("#"),parse:yc,transform:Et.transform},$n=e=>({test:t=>typeof t=="string"&&t.endsWith(e)&&t.split(" ").length===1,parse:parseFloat,transform:t=>`${t}${e}`}),pt=$n("deg"),et=$n("%"),U=$n("px"),xc=$n("vh"),bc=$n("vw"),oi={...et,parse:e=>et.parse(e)/100,transform:e=>et.transform(e*100)},zt={test:Mr("hsl","hue"),parse:Wo("hue","saturation","lightness"),transform:({hue:e,saturation:t,lightness:n,alpha:s=1})=>"hsla("+Math.round(e)+", "+et.transform(jn(t))+", "+et.transform(jn(n))+", "+jn(Nn.transform(s))+")"},ge={test:e=>Et.test(e)||Ws.test(e)||zt.test(e),parse:e=>Et.test(e)?Et.parse(e):zt.test(e)?zt.parse(e):Ws.parse(e),transform:e=>typeof e=="string"?e:e.hasOwnProperty("red")?Et.transform(e):zt.transform(e),getAnimatableNone:e=>{const t=ge.parse(e);return t.alpha=0,ge.transform(t)}},vc=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function wc(e){return isNaN(e)&&typeof e=="string"&&(e.match(Ar)?.length||0)+(e.match(vc)?.length||0)>0}const Ko="number",qo="color",Sc="var",Tc="var(",ai="${}",Cc=/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 Dn(e){const t=e.toString(),n=[],s={color:[],number:[],var:[]},r=[];let o=0;const a=t.replace(Cc,l=>(ge.test(l)?(s.color.push(o),r.push(qo),n.push(ge.parse(l))):l.startsWith(Tc)?(s.var.push(o),r.push(Sc),n.push(l)):(s.number.push(o),r.push(Ko),n.push(parseFloat(l))),++o,ai)).split(ai);return{values:n,split:a,indexes:s,types:r}}function Go(e){return Dn(e).values}function Yo(e){const{split:t,types:n}=Dn(e),s=t.length;return r=>{let o="";for(let i=0;i<s;i++)if(o+=t[i],r[i]!==void 0){const a=n[i];a===Ko?o+=jn(r[i]):a===qo?o+=ge.transform(r[i]):o+=r[i]}return o}}const jc=e=>typeof e=="number"?0:ge.test(e)?ge.getAnimatableNone(e):e;function Pc(e){const t=Go(e);return Yo(e)(t.map(jc))}const yt={test:wc,parse:Go,createTransformer:Yo,getAnimatableNone:Pc};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 Ac({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 fe=(e,t,n)=>e+(t-e)*n,Es=(e,t,n)=>{const s=e*e,r=n*(t*t-s)+s;return r<0?0:Math.sqrt(r)},Mc=[Ws,Et,zt],Ec=e=>Mc.find(t=>t.test(e));function li(e){const t=Ec(e);if(Zt(!!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===zt&&(n=Ac(n)),n}const ci=(e,t)=>{const n=li(e),s=li(t);if(!n||!s)return cs(e,t);const r={...n};return o=>(r.red=Es(n.red,s.red,o),r.green=Es(n.green,s.green,o),r.blue=Es(n.blue,s.blue,o),r.alpha=fe(n.alpha,s.alpha,o),Et.transform(r))},Ks=new Set(["none","hidden"]);function kc(e,t){return Ks.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function Nc(e,t){return n=>fe(e,t,n)}function Er(e){return typeof e=="number"?Nc:typeof e=="string"?Pr(e)?cs:ge.test(e)?ci:Vc:Array.isArray(e)?Ho:typeof e=="object"?ge.test(e)?ci:Dc:cs}function Ho(e,t){const n=[...e],s=n.length,r=e.map((o,i)=>Er(o)(o,t[i]));return o=>{for(let i=0;i<s;i++)n[i]=r[i](o);return n}}function Dc(e,t){const n={...e,...t},s={};for(const r in n)e[r]!==void 0&&t[r]!==void 0&&(s[r]=Er(e[r])(e[r],t[r]));return r=>{for(const o in s)n[o]=s[o](r);return n}}function Rc(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 Vc=(e,t)=>{const n=yt.createTransformer(t),s=Dn(e),r=Dn(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?kc(e,t):On(Ho(Rc(s,r),r.values),n):(Zt(!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 Jo(e,t,n){return typeof e=="number"&&typeof t=="number"&&typeof n=="number"?fe(e,t,n):Er(e)(e,t)}const Ic=e=>{const t=({timestamp:n})=>e(n);return{start:(n=!0)=>le.update(t,n),stop:()=>gt(t),now:()=>we.isProcessing?we.timestamp:Ee.now()}},Zo=(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 kr(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 Oc(e,t=100,n){const s=n({...e,keyframes:[0,t]}),r=Math.min(kr(s),us);return{type:"keyframes",ease:o=>s.next(r*o).value/t,duration:Le(r)}}const Lc=5;function Qo(e,t,n){const s=Math.max(t-Lc,0);return Do(n-e(s),t-s)}const he={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},ks=.001;function $c({duration:e=he.duration,bounce:t=he.bounce,velocity:n=he.velocity,mass:s=he.mass}){let r,o;Zt(e<=Xe(he.maxDuration),"Spring duration must be 10 seconds or less","spring-duration-limit");let i=1-t;i=ot(he.minDamping,he.maxDamping,i),e=ot(he.minDuration,he.maxDuration,Le(e)),i<1?(r=u=>{const d=u*i,h=d*e,m=d-n,p=qs(u,i),S=Math.exp(-h);return ks-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=qs(Math.pow(u,2),i);return(-r(u)+ks>0?-1:1)*((m-p)*S)/v}):(r=u=>{const d=Math.exp(-u*e),h=(u-n)*e+1;return-ks+d*h},o=u=>{const d=Math.exp(-u*e),h=(n-u)*(e*e);return d*h});const a=5/e,l=Bc(r,o,a);if(e=Xe(e),isNaN(l))return{stiffness:he.stiffness,damping:he.damping,duration:e};{const u=Math.pow(l,2)*s;return{stiffness:u,damping:i*2*Math.sqrt(s*u),duration:e}}}const Fc=12;function Bc(e,t,n){let s=n;for(let r=1;r<Fc;r++)s=s-e(s)/t(s);return s}function qs(e,t){return e*Math.sqrt(1-t*t)}const Uc=["duration","bounce"],zc=["stiffness","damping","mass"];function ui(e,t){return t.some(n=>e[n]!==void 0)}function _c(e){let t={velocity:he.velocity,stiffness:he.stiffness,damping:he.damping,mass:he.mass,isResolvedFromDuration:!1,...e};if(!ui(e,zc)&&ui(e,Uc))if(e.visualDuration){const n=e.visualDuration,s=2*Math.PI/(n*1.2),r=s*s,o=2*ot(.05,1,1-(e.bounce||0))*Math.sqrt(r);t={...t,mass:he.mass,stiffness:r,damping:o}}else{const n=$c(e);t={...t,...n,mass:he.mass},t.isResolvedFromDuration=!0}return t}function ds(e=he.visualDuration,t=he.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}=_c({...n,velocity:-Le(n.velocity||0)}),S=m||0,v=u/(2*Math.sqrt(l*d)),T=i-o,b=Le(Math.sqrt(l/d)),E=Math.abs(T)<5;s||(s=E?he.restSpeed.granular:he.restSpeed.default),r||(r=E?he.restDelta.granular:he.restDelta.default);let M;if(v<1){const D=qs(b,v);M=I=>{const N=Math.exp(-v*b*I);return i-N*((S+v*b*T)/D*Math.sin(D*I)+T*Math.cos(D*I))}}else if(v===1)M=D=>i-Math.exp(-b*D)*(T+(S+b*T)*D);else{const D=b*Math.sqrt(v*v-1);M=I=>{const N=Math.exp(-v*b*I),P=Math.min(D*I,300);return i-N*((S+v*b*T)*Math.sinh(P)+D*T*Math.cosh(P))/D}}const $={calculatedDuration:p&&h||null,next:D=>{const I=M(D);if(p)a.done=D>=h;else{let N=D===0?S:0;v<1&&(N=D===0?Xe(S):Qo(M,D,I));const P=Math.abs(N)<=s,O=Math.abs(i-I)<=r;a.done=P&&O}return a.value=a.done?i:I,a},toString:()=>{const D=Math.min(kr($),us),I=Zo(N=>$.next(D*N).value,D,30);return D+"ms "+I},toTransition:()=>{}};return $}ds.applyToOptions=e=>{const t=Oc(e,100,ds);return e.ease=t.ease,e.duration=Xe(t.duration),e.type="keyframes",e};function Gs({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=P=>a!==void 0&&P<a||l!==void 0&&P>l,S=P=>a===void 0?l:l===void 0||Math.abs(a-P)<Math.abs(l-P)?a:l;let v=n*t;const T=h+v,b=i===void 0?T:i(T);b!==T&&(v=b-h);const E=P=>-v*Math.exp(-P/s),M=P=>b+E(P),$=P=>{const O=E(P),A=M(P);m.done=Math.abs(O)<=u,m.value=m.done?b:A};let D,I;const N=P=>{p(m.value)&&(D=P,I=ds({keyframes:[m.value,S(m.value)],velocity:Qo(M,P,m.value),damping:r,stiffness:o,restDelta:u,restSpeed:d}))};return N(0),{calculatedDuration:null,next:P=>{let O=!1;return!I&&D===void 0&&(O=!0,$(P),N(P)),D!==void 0&&P>=D?I.next(P-D):(!O&&$(P),m)}}}function Xc(e,t,n){const s=[],r=n||lt.mix||Jo,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=On(l,a)}s.push(a)}return s}function Wc(e,t,{clamp:n=!0,ease:s,mixer:r}={}){const o=e.length;if(at(o===t.length,"Both input and output ranges must be the same length","range-length"),o===1)return()=>t[0];if(o===2&&t[0]===t[1])return()=>t[1];const i=e[0]===e[1];e[0]>e[o-1]&&(e=[...e].reverse(),t=[...t].reverse());const a=Xc(t,s,r),l=a.length,u=d=>{if(i&&d<e[0])return t[0];let h=0;if(l>1)for(;h<e.length-2&&!(d<e[h+1]);h++);const m=kn(e[h],e[h+1],d);return a[h](m)};return n?d=>u(ot(e[0],e[o-1],d)):u}function Kc(e,t){const n=e[e.length-1];for(let s=1;s<=t;s++){const r=kn(0,t,s);e.push(fe(n,1,r))}}function qc(e){const t=[0];return Kc(t,e.length-1),t}function Gc(e,t){return e.map(n=>n*t)}function Yc(e,t){return e.map(()=>t||Uo).splice(0,e.length-1)}function _t({duration:e=300,keyframes:t,times:n,ease:s="easeInOut"}){const r=ac(s)?s.map(ii):ii(s),o={done:!1,value:t[0]},i=Gc(n&&n.length===t.length?n:qc(t),e),a=Wc(i,t,{ease:Array.isArray(r)?r:Yc(t,r)});return{calculatedDuration:e,next:l=>(o.value=a(l),o.done=l>=e,o)}}const Hc=e=>e!==null;function Nr(e,{repeat:t,repeatType:n="loop"},s,r=1){const o=e.filter(Hc),a=r<0||t&&n!=="loop"&&t%2===1?0:o.length-1;return!a||s===void 0?o[a]:s}const Jc={decay:Gs,inertia:Gs,tween:_t,keyframes:_t,spring:ds};function ea(e){typeof e.type=="string"&&(e.type=Jc[e.type])}class Dr{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(t=>{this.resolve=t})}notifyFinished(){this.resolve()}then(t,n){return this.finished.then(t,n)}}const Zc=e=>e/100;class Rr extends Dr{constructor(t){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.stop=()=>{const{motionValue:n}=this.options;n&&n.updatedAt!==Ee.now()&&this.tick(Ee.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;ea(t);const{type:n=_t,repeat:s=0,repeatDelay:r=0,repeatType:o,velocity:i=0}=t;let{keyframes:a}=t;const l=n||_t;process.env.NODE_ENV!=="production"&&l!==_t&&at(a.length<=2,`Only two keyframes currently supported with spring and inertia animations. Trying to animate ${a}`,"spring-two-frames"),l!==_t&&typeof a[0]!="number"&&(this.mixKeyframes=On(Zc,Jo(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=kr(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: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 b=this.currentTime-u*(this.playbackSpeed>=0?1:-1),E=this.playbackSpeed>=0?b<0:b>r;this.currentTime=Math.max(b,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=r);let M=this.currentTime,$=s;if(h){const P=Math.min(this.currentTime,r)/a;let O=Math.floor(P),A=P%1;!A&&P>=1&&(A=1),A===1&&O--,O=Math.min(O,h+1),!!(O%2)&&(m==="reverse"?(A=1-A,p&&(A-=p/a)):m==="mirror"&&($=i)),M=ot(0,1,A)*a}const D=E?{done:!1,value:d[0]}:$.next(M);o&&(D.value=o(D.value));let{done:I}=D;!E&&l!==null&&(I=this.playbackSpeed>=0?this.currentTime>=r:this.currentTime<=0);const N=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&I);return N&&S!==Gs&&(D.value=Nr(d,this.options,T,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=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(Ee.now());const n=this.playbackSpeed!==t;this.playbackSpeed=t,n&&(this.time=Le(this.currentTime))}play(){if(this.isStopped)return;const{driver:t=Ic,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(Ee.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 Qc(e){for(let t=1;t<e.length;t++)e[t]??(e[t]=e[t-1])}const kt=e=>e*180/Math.PI,Ys=e=>{const t=kt(Math.atan2(e[1],e[0]));return Hs(t)},eu={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:Ys,rotateZ:Ys,skewX:e=>kt(Math.atan(e[1])),skewY:e=>kt(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},Hs=e=>(e=e%360,e<0&&(e+=360),e),di=Ys,hi=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),fi=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),tu={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:hi,scaleY:fi,scale:e=>(hi(e)+fi(e))/2,rotateX:e=>Hs(kt(Math.atan2(e[6],e[5]))),rotateY:e=>Hs(kt(Math.atan2(-e[2],e[0]))),rotateZ:di,rotate:di,skewX:e=>kt(Math.atan(e[4])),skewY:e=>kt(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function Js(e){return e.includes("scale")?1:0}function Zs(e,t){if(!e||e==="none")return Js(t);const n=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let s,r;if(n)s=tu,r=n;else{const a=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);s=eu,r=a}if(!r)return Js(t);const o=s[t],i=r[1].split(",").map(su);return typeof o=="function"?o(i):i[o]}const nu=(e,t)=>{const{transform:n="none"}=getComputedStyle(e);return Zs(n,t)};function su(e){return parseFloat(e.trim())}const en=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],tn=new Set(en),mi=e=>e===Qt||e===U,ru=new Set(["x","y","z"]),iu=en.filter(e=>!ru.has(e));function ou(e){const t=[];return iu.forEach(n=>{const s=e.getValue(n);s!==void 0&&(t.push([n,s.get()]),s.set(n.startsWith("scale")?1:0))}),t}const Nt={width:({x:e},{paddingLeft:t="0",paddingRight:n="0"})=>e.max-e.min-parseFloat(t)-parseFloat(n),height:({y:e},{paddingTop:t="0",paddingBottom:n="0"})=>e.max-e.min-parseFloat(t)-parseFloat(n),top:(e,{top:t})=>parseFloat(t),left:(e,{left:t})=>parseFloat(t),bottom:({y:e},{top:t})=>parseFloat(t)+(e.max-e.min),right:({x:e},{left:t})=>parseFloat(t)+(e.max-e.min),x:(e,{transform:t})=>Zs(t,"x"),y:(e,{transform:t})=>Zs(t,"y")};Nt.translateX=Nt.x;Nt.translateY=Nt.y;const Dt=new Set;let Qs=!1,er=!1,tr=!1;function ta(){if(er){const e=Array.from(Dt).filter(s=>s.needsMeasurement),t=new Set(e.map(s=>s.element)),n=new Map;t.forEach(s=>{const r=ou(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)})}er=!1,Qs=!1,Dt.forEach(e=>e.complete(tr)),Dt.clear()}function na(){Dt.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(er=!0)})}function au(){tr=!0,na(),ta(),tr=!1}class Vr{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?(Dt.add(this),Qs||(Qs=!0,le.read(na),le.resolveKeyframes(ta))):(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])}Qc(t)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(t=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,t),Dt.delete(this)}cancel(){this.state==="scheduled"&&(Dt.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const lu=e=>e.startsWith("--");function cu(e,t,n){lu(t)?e.style.setProperty(t,n):e.style[t]=n}const uu=vr(()=>window.ScrollTimeline!==void 0),du={};function hu(e,t){const n=vr(e);return()=>du[t]??n()}const sa=hu(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),Tn=([e,t,n,s])=>`cubic-bezier(${e}, ${t}, ${n}, ${s})`,pi={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:Tn([0,.65,.55,1]),circOut:Tn([.55,0,1,.45]),backIn:Tn([.31,.01,.66,-.59]),backOut:Tn([.33,1.53,.69,.99])};function ra(e,t){if(e)return typeof e=="function"?sa()?Zo(e,t):"ease-out":zo(e)?Tn(e):Array.isArray(e)?e.map(n=>ra(n,t)||pi.easeOut):pi[e]}function fu(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=ra(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 ia(e){return typeof e=="function"&&"applyToOptions"in e}function mu({type:e,...t}){return ia(e)&&sa()?e.applyToOptions(t):(t.duration??(t.duration=300),t.ease??(t.ease="easeOut"),t)}class pu extends Dr{constructor(t){if(super(),this.finishedTime=null,this.isStopped=!1,!t)return;const{element:n,name:s,keyframes:r,pseudoElement:o,allowFlatten:i=!1,finalKeyframe:a,onComplete:l}=t;this.isPseudoElement=!!o,this.allowFlatten=i,this.options=t,at(typeof t.type!="string",`Mini animate() doesn't support "type" as a string.`,"mini-spring");const u=mu(t);this.animation=fu(n,s,r,u,o),u.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!o){const d=Nr(r,this.options,a,this.speed);this.updateMotionValue?this.updateMotionValue(d):cu(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=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&&uu()?(this.animation.timeline=t,$e):n(this)}}const oa={anticipate:$o,backInOut:Lo,circInOut:Bo};function gu(e){return e in oa}function yu(e){typeof e.ease=="string"&&gu(e.ease)&&(e.ease=oa[e.ease])}const gi=10;class xu extends pu{constructor(t){yu(t),ea(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 Rr({...i,autoplay:!1}),l=Xe(this.finishedTime??this.time);n.setWithVelocity(a.sample(l-gi).value,a.sample(l).value,gi),a.stop()}}const yi=(e,t)=>t==="zIndex"?!1:!!(typeof e=="number"||Array.isArray(e)||typeof e=="string"&&(yt.test(e)||e==="0")&&!e.startsWith("url("));function bu(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 vu(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=yi(r,t),a=yi(o,t);return Zt(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:bu(e)||(n==="spring"||ia(n))&&s}function nr(e){e.duration=0,e.type="keyframes"}const wu=new Set(["opacity","clipPath","filter","transform"]),Su=vr(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function Tu(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 Su()&&n&&wu.has(n)&&(n!=="transform"||!u)&&!l&&!s&&r!=="mirror"&&o!==0&&i!=="inertia"}const Cu=40;class ju extends Dr{constructor({autoplay:t=!0,delay:n=0,type:s="keyframes",repeat:r=0,repeatDelay:o=0,repeatType:i="loop",keyframes:a,name:l,motionValue:u,element:d,...h}){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=Ee.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||Vr;this.keyframeResolver=new p(a,(S,v,T)=>this.onKeyframesResolved(S,v,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=Ee.now(),vu(t,o,i,a)||((lt.instantAnimations||!l)&&d?.(Nr(t,s,n)),t[0]=t[t.length-1],nr(s),s.repeat=0);const m={startTime:r?this.resolvedAt?this.resolvedAt-this.createdAt>Cu?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...s,keyframes:t},p=!u&&Tu(m)?new xu({...m,element:m.motionValue.owner.current}):new Rr(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(),au()),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 Pu=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function Au(e){const t=Pu.exec(e);if(!t)return[,];const[,n,s,r]=t;return[`--${n??s}`,r]}const Mu=4;function aa(e,t,n=1){at(n<=Mu,`Max CSS variable fallback depth detected in property "${e}". This may indicate a circular fallback dependency.`,"max-css-var-depth");const[s,r]=Au(e);if(!s)return;const o=window.getComputedStyle(t).getPropertyValue(s);if(o){const i=o.trim();return Eo(i)?parseFloat(i):i}return Pr(r)?aa(r,t,n+1):r}function Ir(e,t){return e?.[t]??e?.default??e}const la=new Set(["width","height","top","left","right","bottom",...en]),Eu={test:e=>e==="auto",parse:e=>e},ca=e=>t=>t.test(e),ua=[Qt,U,et,pt,bc,xc,Eu],xi=e=>ua.find(ca(e));function ku(e){return typeof e=="number"?e===0:e!==null?e==="none"||e==="0"||No(e):!0}const Nu=new Set(["brightness","contrast","saturate","opacity"]);function Du(e){const[t,n]=e.slice(0,-1).split("(");if(t==="drop-shadow")return e;const[s]=n.match(Ar)||[];if(!s)return e;const r=n.replace(s,"");let o=Nu.has(t)?1:0;return s!==n&&(o*=100),t+"("+o+r+")"}const Ru=/\b([a-z-]*)\(.*?\)/gu,sr={...yt,getAnimatableNone:e=>{const t=e.match(Ru);return t?t.map(Du).join(" "):e}},bi={...Qt,transform:Math.round},Vu={rotate:pt,rotateX:pt,rotateY:pt,rotateZ:pt,scale:Zn,scaleX:Zn,scaleY:Zn,scaleZ:Zn,skew:pt,skewX:pt,skewY:pt,distance:U,translateX:U,translateY:U,translateZ:U,x:U,y:U,z:U,perspective:U,transformPerspective:U,opacity:Nn,originX:oi,originY:oi,originZ:U},Or={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,...Vu,zIndex:bi,fillOpacity:Nn,strokeOpacity:Nn,numOctaves:bi},Iu={...Or,color:ge,backgroundColor:ge,outlineColor:ge,fill:ge,stroke:ge,borderColor:ge,borderTopColor:ge,borderRightColor:ge,borderBottomColor:ge,borderLeftColor:ge,filter:sr,WebkitFilter:sr},da=e=>Iu[e];function ha(e,t){let n=da(e);return n!==sr&&(n=yt),n.getAnimatableNone?n.getAnimatableNone(t):void 0}const Ou=new Set(["auto","none","0"]);function Lu(e,t,n){let s=0,r;for(;s<e.length&&!r;){const o=e[s];typeof o=="string"&&!Ou.has(o)&&Dn(o).values.length&&(r=e[s]),s++}if(r&&n)for(const o of t)e[o]=ha(n,r)}class $u extends Vr{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(),Pr(u))){const d=aa(u,n.current);d!==void 0&&(t[l]=d),l===t.length-1&&(this.finalKeyframe=u)}}if(this.resolveNoneKeyframes(),!la.has(s)||t.length!==2)return;const[r,o]=t,i=xi(r),a=xi(o);if(i!==a)if(mi(i)&&mi(a))for(let l=0;l<t.length;l++){const u=t[l];typeof u=="string"&&(t[l]=parseFloat(u))}else Nt[s]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:t,name:n}=this,s=[];for(let r=0;r<t.length;r++)(t[r]===null||ku(t[r]))&&s.push(r);s.length&&Lu(t,s,n)}measureInitialState(){const{element:t,unresolvedKeyframes:n,name:s}=this;if(!t||!t.current)return;s==="height"&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=Nt[s](t.measureViewportBox(),window.getComputedStyle(t.current)),n[0]=this.measuredOrigin;const r=n[n.length-1];r!==void 0&&t.getValue(s,r).jump(r,!1)}measureEndState(){const{element:t,name:n,unresolvedKeyframes:s}=this;if(!t||!t.current)return;const r=t.getValue(n);r&&r.jump(this.measuredOrigin,!1);const o=s.length-1,i=s[o];s[o]=Nt[n](t.measureViewportBox(),window.getComputedStyle(t.current)),i!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=i),this.removedTransforms?.length&&this.removedTransforms.forEach(([a,l])=>{t.getValue(a).set(l)}),this.resolveNoneKeyframes()}}function Fu(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 fa=(e,t)=>t&&typeof e=="number"?t.transform(e):e;function ma(e){return ko(e)&&"offsetHeight"in e}const vi=30,Bu=e=>!isNaN(parseFloat(e));class Uu{constructor(t,n={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=s=>{const r=Ee.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=Ee.now(),this.canTrackVelocity===null&&t!==void 0&&(this.canTrackVelocity=Bu(this.current))}setPrevFrameValue(t=this.current){this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt}onChange(t){return process.env.NODE_ENV!=="production"&&Sr(!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 wr);const s=this.events[t].add(n);return t==="change"?()=>{s(),le.read(()=>{this.events.change.getSize()||this.stop()})}:s}clearListeners(){for(const t in this.events)this.events[t].clear()}attach(t,n){this.passiveEffect=t,this.stopPassiveEffect=n}set(t){this.passiveEffect?this.passiveEffect(t,this.updateAndNotify):this.updateAndNotify(t)}setWithVelocity(t,n,s){this.set(n),this.prev=void 0,this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt-s}jump(t,n=!0){this.updateAndNotify(t),this.prev=t,this.prevUpdatedAt=this.prevFrameValue=void 0,n&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){this.events.change?.notify(this.current)}addDependent(t){this.dependents||(this.dependents=new Set),this.dependents.add(t)}removeDependent(t){this.dependents&&this.dependents.delete(t)}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const t=Ee.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||t-this.updatedAt>vi)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,vi);return Do(parseFloat(this.current)-parseFloat(this.prevFrameValue),n)}start(t){return this.stop(),new Promise(n=>{this.hasAnimated=!0,this.animation=t(n),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.dependents?.clear(),this.events.destroy?.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function Ht(e,t){return new Uu(e,t)}const{schedule:Lr}=_o(queueMicrotask,!1),ze={x:!1,y:!1};function pa(){return ze.x||ze.y}function zu(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 ga(e,t){const n=Fu(e),s=new AbortController,r={passive:!0,...t,signal:s.signal};return[n,r,()=>s.abort()]}function wi(e){return!(e.pointerType==="touch"||pa())}function _u(e,t,n={}){const[s,r,o]=ga(e,n),i=a=>{if(!wi(a))return;const{target:l}=a,u=t(l,a);if(typeof u!="function"||!l)return;const d=h=>{wi(h)&&(u(h),l.removeEventListener("pointerleave",d))};l.addEventListener("pointerleave",d,r)};return s.forEach(a=>{a.addEventListener("pointerenter",i,r)}),o}const ya=(e,t)=>t?e===t?!0:ya(e,t.parentElement):!1,$r=e=>e.pointerType==="mouse"?typeof e.button!="number"||e.button<=0:e.isPrimary!==!1,Xu=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function Wu(e){return Xu.has(e.tagName)||e.tabIndex!==-1}const is=new WeakSet;function Si(e){return t=>{t.key==="Enter"&&e(t)}}function Ns(e,t){e.dispatchEvent(new PointerEvent("pointer"+t,{isPrimary:!0,bubbles:!0}))}const Ku=(e,t)=>{const n=e.currentTarget;if(!n)return;const s=Si(()=>{if(is.has(n))return;Ns(n,"down");const r=Si(()=>{Ns(n,"up")}),o=()=>Ns(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 Ti(e){return $r(e)&&!pa()}function qu(e,t,n={}){const[s,r,o]=ga(e,n),i=a=>{const l=a.currentTarget;if(!Ti(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),Ti(p)&&typeof u=="function"&&u(p,{success:S})},h=p=>{d(p,l===window||l===document||n.useGlobalTarget||ya(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),ma(a)&&(a.addEventListener("focus",u=>Ku(u,r)),!Wu(a)&&!a.hasAttribute("tabindex")&&(a.tabIndex=0))}),o}function xa(e){return ko(e)&&"ownerSVGElement"in e}function Gu(e){return xa(e)&&e.tagName==="svg"}const Te=e=>!!(e&&e.getVelocity),Yu=[...ua,ge,yt],Hu=e=>Yu.find(ca(e)),Fr=f.createContext({transformPagePoint:e=>e,isStatic:!1,reducedMotion:"never"});function Ci(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Ju(...e){return t=>{let n=!1;const s=e.map(r=>{const o=Ci(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():Ci(e[r],null)}}}}function Zu(...e){return _e.useCallback(Ju(...e),e)}class Qu extends _e.Component{getSnapshotBeforeUpdate(t){const n=this.props.childRef.current;if(n&&t.isPresent&&!this.props.isPresent){const s=n.offsetParent,r=ma(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 ed({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(Fr),l=Zu(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 T=s??document.head;return T.appendChild(v),v.sheet&&v.sheet.insertRule(`
1
+ "use strict";var yl=Object.create;var Qr=Object.defineProperty;var xl=Object.getOwnPropertyDescriptor;var bl=Object.getOwnPropertyNames;var vl=Object.getPrototypeOf,wl=Object.prototype.hasOwnProperty;var Sl=(e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of bl(t))!wl.call(e,r)&&r!==n&&Qr(e,r,{get:()=>t[r],enumerable:!(s=xl(t,r))||s.enumerable});return e};var Tl=(e,t,n)=>(n=e!=null?yl(vl(e)):{},Sl(t||!e||!e.__esModule?Qr(n,"default",{value:e,enumerable:!0}):n,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react/jsx-runtime"),f=require("react"),ee=require("lucide-react"),Cl=require("@ai-sdk/react"),ei=require("ai"),wo=require("@radix-ui/react-slot"),So=require("class-variance-authority"),jl=require("clsx"),Pl=require("tailwind-merge"),Al=require("@radix-ui/react-tooltip"),ti=require("@radix-ui/react-use-controllable-state"),El=require("@radix-ui/react-collapsible"),Ml=require("react-dom"),kl=require("@radix-ui/react-dialog"),Nl=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 _e=ms(f),Gt=ms(Al),fr=ms(El),Rt=ms(kl),Oe=Symbol.for("@arcteninc/core:originalName");function Dl(e,t){return e[Oe]=t,e}function Rl(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 mr(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=Rl(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 Vl={password:[/^password$/i,/^pwd$/i,/^pass$/i,/^newPassword$/i,/^oldPassword$/i,/^currentPassword$/i,/^confirmPassword$/i,/.*password.*/i],email:[/^email$/i,/^emailAddress$/i,/^mail$/i,/.*email.*/i],phone:[/^phone$/i,/^phoneNumber$/i,/^mobile$/i,/^cell$/i,/^cellPhone$/i,/^telephone$/i,/.*phone.*/i,/.*mobile.*/i],pin:[/^pin$/i,/^pinCode$/i,/^securityPin$/i,/^accessPin$/i,/.*pin$/i],ssn:[/^ssn$/i,/^socialSecurityNumber$/i,/^social$/i,/.*ssn.*/i,/.*social.*/i],creditCard:[/^creditCard$/i,/^cardNumber$/i,/^card$/i,/^ccNumber$/i,/^creditCardNumber$/i,/.*card.*/i,/^cvv$/i,/^cvc$/i,/^cvn$/i,/^securityCode$/i],text:[]};function Sn(e){for(const[t,n]of Object.entries(Vl))if(t!=="text"){for(const s of n)if(s.test(e))return t}return null}function Il(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 Ol(e,t,n){return t.length>0}function Ll(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=$l(s[i]),d={name:i,type:Fl(l||Sn(i)||"text"),label:To(i),placeholder:Bl(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:Ol(e,t),fields:r,title:Ul(e),description:zl(e,r.length)}}function $l(e){if(e!=null){if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return String(e)}}function Fl(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 To(e){return e.replace(/([A-Z])/g," $1").replace(/_/g," ").trim().toLowerCase().split(" ").map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" ")}function Bl(e,t){return t?Il(t,e).placeholder:`Enter ${To(e).toLowerCase()}...`}function Ul(e){return e.replace(/([A-Z])/g," $1").trim().toLowerCase().split(" ").map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" ")}function zl(e,t){const n=e.toLowerCase();return t<=2?`Please provide the required information to ${n}.`:`Please fill out the form below to ${n}. Required fields are marked with *.`}function Cn(e){if(typeof e=="string")try{const t=JSON.parse(e);return Cn(t)}catch{return e}if(Array.isArray(e))return e.map(Cn);if(e&&typeof e=="object"){const t={};for(const[n,s]of Object.entries(e))t[n]=Cn(s);return t}return e}function _l(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 Xl(e){if(typeof e=="string"){try{const t=JSON.parse(e);if(t&&typeof t=="object"&&!Array.isArray(t))return Cn(t)}catch{}return{}}return e&&typeof e=="object"&&!Array.isArray(e)?Cn(e):{}}const ns="__secureOutput",ss="[hidden for privacy]";function Wl(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 Kl(e){if(typeof globalThis.structuredClone=="function")return globalThis.structuredClone(e);try{return JSON.parse(JSON.stringify(e))}catch(t){return console.warn("[useAgent] Failed to clone value for redaction:",t),e}}function ql(e){return e.replace(/\[(\w+)\]/g,".$1").split(".").map(t=>t.trim()).filter(Boolean)}function Gl(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 Yl(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 _s(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 Co(e,t=""){const n={};return e&&typeof e=="object"?Object.entries(e).forEach(([s,r])=>{const o=t?`${t}.${s}`:s;n[o]=_s(r),r&&typeof r=="object"&&Object.assign(n,Co(r,o))}):t&&(n[t]=_s(e)),n}function Hl(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 Jl(e){if(!e)return{};const t={};for(const[n,s]of Object.entries(e)){const r=Hl(s);r&&(t[n]=r)}return t}function jo(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=Co(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 jo(e,t,{...n,strategy:"full",fields:[]});if(typeof t!="object"||t===null)return{value:s,[ns]:{...r,redactedFields:n.fields}};const o=Kl(t),i=[],a={};return n.fields.forEach(l=>{const u=ql(l);if(u.length===0)return;const d=Gl(o,u),h=_s(d);a[l]=h,Yl(o,u,s)&&i.push(l)}),r.redactedFields=i,n.includeFieldStatus&&(r.fieldStatus=a),o[ns]=r,o}function Po({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:T,projectId:b,enableRemoteConfig:M,remoteConfigUrl:E,initialMessages:$=[],conversationId:D,state:I,onStateChange:N,allowStateEdits:P=!0,onToolCall:O,onFinish:A,sources:k,ragConfig:F,ragFilters:V,secureInputHandler:B}={}){const X=e.replace(/\/+$/,""),[Y,q]=f.useState(null),[ie,ye]=f.useState(!1),[We,bt]=f.useState(null),tt=f.useMemo(()=>{const g=k||[],y=Y?.config?.sources||[];return[...new Set([...g,...y])]},[k,Y]),G=f.useMemo(()=>F!==void 0?F:V?{enabled:!0,filters:V}:tt&&tt.length>0?{enabled:!0,organizationId:tt[0],autoExecute:!0,filters:void 0}:{enabled:!1},[tt,F,V]),Vt=f.useMemo(()=>M===!1?!1:!!b,[b,M]);f.useEffect(()=>{if(!Vt||!oe.current)return;(async()=>{ye(!0),bt(null);try{const x=`${E||X.replace("/chat","").replace(/\/$/,"")}/convex/api/query`,w=await fetch(x,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${oe.current}`},body:JSON.stringify({path:"agents:getConfigForClient",args:{projectId:b,agentName:T,agentId:v},format:"json"})});if(!w.ok){if(w.status===404){console.warn("[useAgent] Remote config endpoint not found (404), using local tools only"),q(null);return}const R=await w.text().catch(()=>"Unknown error");throw new Error(`Failed to fetch remote config: ${w.status} ${R}`)}const j=await w.json();q(j?.value||null),console.log("[useAgent] Remote config loaded successfully:",j?.value)}catch(y){console.error("[useAgent] Failed to fetch remote config:",y);const x=y instanceof Error?y:new Error(String(y));bt(x),q(null)}finally{ye(!1)}})()},[Vt,b,T,v,X,E]);const Ee=f.useMemo(()=>{const g={};if(u)for(const[y,x]of Object.entries(u))if(g[y]={},Array.isArray(x))for(const w of x){const j=Sn(w);g[y][w]=j||"text"}else for(const[w,j]of Object.entries(x))g[y][w]=j;if(l){for(const[y,x]of Object.entries(l))if(x&&typeof x=="object"&&"sensitiveParams"in x){g[y]||(g[y]={});const w=x.sensitiveParams;if(Array.isArray(w))for(const j of w){const R=Sn(j);g[y][j]=R||"text"}else if(w&&typeof w=="object")for(const[j,R]of Object.entries(w))g[y][j]=R}}return g},[u,l,h]),vt=f.useMemo(()=>Jl(d),[d]),je=f.useCallback((g,y)=>{const x=vt[g];if(!x)return y;try{return jo(g,y,x)}catch(w){return console.error(`[useAgent] Failed to redact output for ${g}:`,w),{value:ss,[ns]:{tool:g,redacted:!0,error:String(w)}}}},[vt]),[Fe,un]=f.useState(n||null),oe=f.useRef(n||null),[dn,wt]=f.useState(null),[hn,Bn]=f.useState(null),Be=f.useRef(null),[St,Tt]=f.useState([]),[ke,fn]=f.useState(D||(typeof window<"u"?crypto.randomUUID():null)),[bs,It]=f.useState(!1),mn=f.useRef(new Set),[Ot,nt]=f.useState(new Map),[vs,Un]=f.useState(new Map),[st,zn]=f.useState(new Map),[_n,Lt]=f.useState(new Map),ce=I!==void 0,[$t,ct]=f.useState({}),xe=f.useRef({}),pn=ce?I||{}:$t;ce&&I?xe.current=I:ce||(xe.current=$t);const[Ke,Re]=f.useState(!1),[gn,qe]=f.useState(null),Ct=f.useRef(!1),Xn=f.useCallback(async(g,y=3)=>{if(!ke||!oe.current)return;const x=async()=>{const j=`${X.replace("/chat","").replace(/\/$/,"")}/convex/api/mutation`,R=await fetch(j,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${oe.current}`},body:JSON.stringify({path:"conversations:mergeStateByChatId",args:{chatId:ke,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<y;w++)try{await x(),qe(null);return}catch(j){if(w===y-1){const L=j instanceof Error?j:new Error(String(j));throw qe(L),console.error("Failed to sync state to Convex after retries:",j),L}await new Promise(L=>setTimeout(L,Math.pow(2,w)*100))}},[ke,X,oe]),Pe=f.useMemo(()=>function(){return xe.current},[]),ut=f.useMemo(()=>async function(y){const x={...xe.current,...y};xe.current=x,ce||ct(x),N&&N(x);try{await Xn(y)}catch(w){throw w}},[Xn,N,ce]);f.useEffect(()=>{ce&&I&&(xe.current=I)},[ce,I]);const Ne=f.useCallback(g=>B?B.showSecureModal(g):new Promise(y=>{nt(x=>new Map(x).set(g.id,g)),Un(x=>new Map(x).set(g.id,y))}),[B]),Wn=f.useCallback((g,y)=>{if(B)return;const x=vs.get(g);x&&(x(y),nt(w=>{const j=new Map(w);return j.delete(g),j}),Un(w=>{const j=new Map(w);return j.delete(g),j}))},[vs,B]),Ft=f.useCallback(g=>B?B.showSecureForm(g):new Promise(y=>{zn(x=>new Map(x).set(g.id,g)),Lt(x=>new Map(x).set(g.id,y))}),[B]),rt=f.useCallback((g,y)=>{if(B)return;const x=_n.get(g);x&&(x(y),zn(w=>{const j=new Map(w);return j.delete(g),j}),Lt(w=>{const j=new Map(w);return j.delete(g),j}))},[_n,B]),Kn=f.useCallback((g,y)=>{const x=Ee[g]||{},w=Object.keys(x).length>0;if(h){const j=Object.keys(y).filter(R=>Sn(R)!==null);return w||j.length>0}return w},[Ee,h]),qn=f.useCallback((g,y)=>{const w={...Ee[g]||{}};if(h){for(const R of Object.keys(y))if(!(R in w)){const L=Sn(R);L&&(w[R]=L)}}const j=Object.entries(w).filter(([R])=>Object.prototype.hasOwnProperty.call(y,R));return j.length>0?Object.fromEntries(j):w},[Ee,h]),Ge=f.useMemo(()=>G?.enabled?async function(y,x=20,w){const j={...G.filters,...w};if(k&&k.length>1){const L=k.map(K=>fetch(`${X}/search`,{method:"POST",headers:{"Content-Type":"application/json",...oe.current?{Authorization:`Bearer ${oe.current}`}:{}},body:JSON.stringify({q:y,k:Math.min(x,100),organizationId:K,...Object.keys(j).length>0?{filters:j}:{}})}).then(re=>re.ok?re.json():null)),ae=await Promise.all(L),Q=[];for(const K of ae)K?.candidates&&Q.push(...K.candidates);Q.sort((K,re)=>{const Qe=K.scores?.rerank||K.scores?.dense||0;return(re.scores?.rerank||re.scores?.dense||0)-Qe});const be=Q.slice(0,x).map((K,re)=>{const Qe=K.citation||K.url;return{rank:re+1,doc_id:K.doc_id,block_id:K.block_id,url:K.url,citation:Qe,title:K.title||"Untitled",snippet:K.snippet,score:K.scores?.rerank||K.scores?.dense||0,metadata:{site:K.metadata?.site,lang:K.metadata?.lang,contentType:K.metadata?.content_type}}});return{success:!0,query:y,total:Q.length,results:be,summary:`Found ${Q.length} relevant results across ${k.length} source(s) for "${y}". 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:y,k:Math.min(x,100)};R&&(L.organizationId=R),Object.keys(j).length>0&&(L.filters=j);const ae={"Content-Type":"application/json"};oe.current&&(ae.Authorization=`Bearer ${oe.current}`);const Q=await fetch(`${X}/search`,{method:"POST",headers:ae,body:JSON.stringify(L)});if(!Q.ok){const re=await Q.text();return{success:!1,error:`Search failed: ${Q.status} ${re}`}}const be=await Q.json(),K=be.candidates.map((re,Qe)=>{const vn=re.citation||re.url;return{rank:Qe+1,doc_id:re.doc_id,block_id:re.block_id,url:re.url,citation:vn,title:re.title||"Untitled",snippet:re.snippet,score:re.scores?.rerank||re.scores?.dense||0,metadata:{site:re.metadata?.site,lang:re.metadata?.lang,contentType:re.metadata?.content_type}}});return{success:!0,query:be.query,total:be.total,results:K,summary:`Found ${be.total} relevant results for "${y}". Top result: ${K[0]?.title||"N/A"}`}}catch(L){return{success:!1,error:L instanceof Error?L.message:"Unknown error occurred"}}}:null,[G,X,oe]),Ye=f.useMemo(()=>G?.enabled?async function(y,x){const w=G.organizationId&&G.organizationId!=="default"?G.organizationId:k&&k.length>0?k[0]:void 0;try{const j={"Content-Type":"application/json"};oe.current&&(j.Authorization=`Bearer ${oe.current}`);const R=await fetch(`${X}/fetch`,{method:"POST",headers:j,body:JSON.stringify({doc_id:y,block_ids:x,...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||y}`}}catch(j){return{success:!1,error:j instanceof Error?j.message:"Unknown error occurred"}}}:null,[G,X,oe]),yn=f.useMemo(()=>{if(Y&&Y.config?.tools){const g=Wl(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]),Ue=Y?.enableStateTools??!0,He=Y?.enableRagTools??G?.enabled??!1,Gn=f.useMemo(()=>{const g=[...yn,...i];return Ue&&(g.push(Pe),(!ce||P)&&g.push(ut)),He&&(Ge&&g.push(Ge),Ye&&g.push(Ye)),g},[yn,i,Pe,ut,Ge,Ye,Ue,He,ce,P]),Yn=f.useMemo(()=>[...yn,...i],[yn,i]),it=f.useMemo(()=>mr(Yn,l),[Yn,l]),jt=f.useMemo(()=>{const g=new Map,y=new Map(it.map(x=>[x.name,x]));return g.set("getState",Pe),(!ce||P)&&g.set("setState",ut),G?.enabled&&(Ge&&g.set("searchDocs",Ge),Ye&&g.set("fetchDocContent",Ye)),Gn.forEach(x=>{if(x===Pe||x===ut||x===Ge||x===Ye)return;const w=x[Oe];if(w){const R=y.get(w);if(R){g.set(R.name,x);return}}const j=it.find(R=>R.name===x.name);j&&g.set(j.name,x)}),g},[Gn,it,Pe,ut,Ge,Ye,G,ce,P]),Hn=f.useMemo(()=>new Set(it.map(g=>g.name)),[it]),xn=f.useMemo(()=>{const g=[];Ue&&(g.push({name:"getState",description:"Get the current agent state. Returns IDs, workflow state, checklists, and other persistent data.",jsonSchema:{type:"object",properties:{},required:[]}}),(!ce||P)&&g.push({name:"setState",description:"Update the agent state. Store IDs, workflow state, checklists, context, and other data that must persist across conversations. Merges with existing state.",jsonSchema:{type:"object",properties:{updates:{type:"object",description:"Partial state updates to merge with existing state"}},required:["updates"]}}));const y=[];He&&y.push({name:"searchDocs",description:"Search documentation using semantic search. Returns relevant results with snippets and scores. Use this first to find relevant documentation. Default returns 20 results - use higher k values (30-50) when you need to find many sources.",jsonSchema:{type:"object",properties:{query:{type:"string",description:"The search query (user's question or keywords)"},k:{type:"number",description:"Number of results to return (default: 20, max: 100). Use 20-30 for comprehensive searches, or higher (50-100) when you need to find all relevant sources.",default:20},filters:{type:"object",description:"Optional filters to scope the search",properties:{site:{type:"string"},lang:{type:"string"},tags:{type:"array",items:{type:"string"}},docIds:{type:"array",items:{type:"string"}},pageIds:{type:"array",items:{type:"string"}}}}},required:["query"]}},{name:"fetchDocContent",description:"Fetch full content of documentation blocks after searching. Use this AFTER searchDocs when you find relevant results (scores > 0.3) to get complete text. Automatically fetches nearby blocks (5 chunks before/after each requested block) for context. You can pass multiple block_ids to fetch comprehensive content from multiple blocks/pages.",jsonSchema:{type:"object",properties:{doc_id:{type:"string",description:"The doc_id from searchDocs results"},block_ids:{type:"array",items:{type:"string"},description:"Array of block_ids from searchDocs results. You can pass multiple block_ids to fetch comprehensive content."}},required:["doc_id","block_ids"]}});const x=[];return Y?.config?.workflows&&Y.config.workflows.forEach(w=>{const j={},R=[];w.parameters&&w.parameters.forEach(L=>{j[L.name]={type:L.type||"string",description:L.description},L.required&&R.push(L.name)}),x.push({name:`workflow_${w.name.replace(/\s+/g,"_").toLowerCase()}`,description:w.description||`Execute the "${w.name}" workflow. ${w.contentPlaintext?.slice(0,200)||""}`,jsonSchema:{type:"object",properties:j,required:R},_workflow:w})}),[...it,...g,...y,...x]},[it,Ue,He,ce,P,Y]),dt=f.useMemo(()=>xn.filter(g=>g.name==="getState"?Ue:g.name==="setState"?Ue&&(!ce||P):g.name==="searchDocs"||g.name==="fetchDocContent"?He:g.name.startsWith("workflow_")?!0:Hn.has(g.name)),[xn,Hn,Ue,He,ce,P]),Bt=f.useMemo(()=>{const g=new Set;return Ue&&(g.add("getState"),g.add("setState")),He&&G?.autoExecute!==!1&&(g.add("searchDocs"),g.add("fetchDocContent")),Y?.config?.tools?Y.config.tools.forEach(y=>{y.isEnabled&&!y.requiresApproval&&g.add(y.name)}):(i.forEach(y=>{for(const[x,w]of jt.entries())if(w===y){g.add(x);break}}),a&&Array.isArray(a)&&a.forEach(y=>{typeof y=="string"&&g.add(y)})),Y?.config?.workflows&&Y.config.workflows.forEach(y=>{const x=`workflow_${y.name.replace(/\s+/g,"_").toLowerCase()}`;y.requiresApproval||g.add(x)}),g},[Y,i,a,jt,Ue,He,G]);f.useEffect(()=>s||n?void 0:((async()=>{try{const y=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:r})});if(!y.ok)throw new Error("Failed to fetch token");const x=await y.json();un(x.clientToken),oe.current=x.clientToken,Bn(x.expiresAt),wt(null)}catch(y){console.error("[useAgent] Token fetch failed:",y),wt(y instanceof Error?y.message:"Failed to fetch token")}})(),()=>{Be.current&&clearTimeout(Be.current)}),[t,JSON.stringify(r),s,n]),f.useEffect(()=>{if(!hn||s||n)return;Be.current&&clearTimeout(Be.current);const g=Math.floor(Date.now()/1e3),y=hn-g,w=Math.max(0,y-5);return Be.current=setTimeout(async()=>{try{const j=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:r})});if(!j.ok)throw new Error("Failed to refresh token");const R=await j.json();un(R.clientToken),oe.current=R.clientToken,Bn(R.expiresAt),wt(null)}catch(j){console.error("[useAgent] Token refresh failed:",j),wt(j instanceof Error?j.message:"Failed to refresh token")}},w*1e3),()=>{Be.current&&clearTimeout(Be.current)}},[hn,t,JSON.stringify(r),s,n]);const ws=async(g,y={})=>{const x=y.headers?new Headers(y.headers):new Headers;x.delete("user-agent"),x.delete("User-Agent"),console.log("[customFetch] ===== REQUEST ====="),console.log("[customFetch] URL:",g),console.log("[customFetch] Stack trace:",new Error().stack),console.log("[useAgent] Making request to:",g),console.log("[useAgent] Method:",y.method||"GET"),console.log("[useAgent] Has Authorization header:",x.has("Authorization")),console.log("[useAgent] Client token available:",!!oe.current);try{const w=await fetch(g,{...y,headers:x});if(!w.ok){console.error("[useAgent] Request failed:",w.status,w.statusText);const j=await w.text().catch(()=>"Unable to read error response");console.error("[useAgent] Error response:",j)}return w}catch(w){throw console.error("[useAgent] Fetch error:",w),w}},Ut=f.useRef(null),bn=`${X}/chat`;console.log("[useAgent] Chat API URL:",bn);const{messages:Je,sendMessage:C,status:_,error:z,stop:Z,addToolResult:H,setMessages:J}=Cl.useChat({id:ke||void 0,messages:$,transport:new ei.DefaultChatTransport({api:bn,fetch:ws,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 =",T);const g=dt.map(w=>({name:w.name,description:w.description,inputSchema:w.jsonSchema})),y=g.filter(w=>w.name==="getState"||w.name==="setState").map(w=>w.name),x=g.filter(w=>w.name==="searchDocs"||w.name==="fetchDocContent").map(w=>w.name);return y.length>0&&console.log("[useAgent] State tools included in tools list sent to AI SDK:",y),x.length>0?console.log("[useAgent] RAG tools included in tools list sent to AI SDK:",x):G?.enabled&&console.warn("[useAgent] RAG is enabled but no RAG tools found in tools list!"),{tools:g,...v&&{agentId:v},...T&&{agentName:T},state:xe.current,...V&&{ragFilters:V}}}}),sendAutomaticallyWhen:g=>{const y=g.messages,x=y[y.length-1];if(console.log("[sendAutomaticallyWhen] ===== CALLED ====="),console.log("[sendAutomaticallyWhen] lastMessage role:",x?.role),console.log("[sendAutomaticallyWhen] message count:",y.length),x?.role!=="assistant")return console.log("[sendAutomaticallyWhen] BLOCKED: not assistant"),!1;const j=[...y].reverse().find(L=>L.role==="user")?.id;if(console.log("[sendAutomaticallyWhen] lastUserMessageId:",j),console.log("[sendAutomaticallyWhen] ref.current:",Ut.current),j&&Ut.current===j)return console.log("[sendAutomaticallyWhen] BLOCKED: already auto-sent for this user message"),!1;const R=ei.lastAssistantMessageIsCompleteWithToolCalls(g);return console.log("[sendAutomaticallyWhen] shouldAutoSend (from SDK helper):",R),R&&j&&(console.log("[sendAutomaticallyWhen] SETTING ref to:",j),Ut.current=j),console.log("[sendAutomaticallyWhen] RETURNING:",R),R}}),De=C,se=f.useCallback(g=>(Ut.current=null,De(g)),[De]),ue=f.useCallback((g,y,x)=>{const w=je(g,x);H({toolCallId:y,tool:g,output:w})},[H,je]);f.useEffect(()=>{Je.forEach(g=>{g.role==="assistant"&&g.parts.forEach(y=>{if(!y.type?.startsWith("tool-")||y.state!=="input-available")return;const x=y.type.replace("tool-",""),w=y.toolCallId;if(mn.current.has(w))return;mn.current.add(w);const j=Xl(y.input);if(Kn(x,j)){const R=qn(x,j),L=Object.entries(R).filter(([K])=>j[K]!==void 0),ae=L.length>0?Object.fromEntries(L):R,Q=Object.keys(j),be=_l(j,ae);(async()=>{try{const K=Ll(x,Q,ae,j),re={id:`${w}-form`,toolName:x,toolCallId:w,title:K.title,description:K.description,fields:K.fields},Qe=await Ft(re);if(Qe===null){ue(x,w,"User cancelled secure input");return}const vn={...be,...Qe},Ss=jt.get(x);if(!Ss)throw new Error(`Tool ${x} not found`);let Ts;const Cs=dt.find(Zr=>Zr.name===x);if(Cs&&Cs.jsonSchema?.properties){const pl=Object.keys(Cs.jsonSchema.properties).map(gl=>vn[gl]);Ts=await Ss(...pl)}else Ts=await Ss(...Object.values(vn));ue(x,w,Ts)}catch(K){console.error(`[useAgent] Error executing tool with secure input ${x}:`,K),ue(x,w,`Error: ${K}`)}})();return}if(x.startsWith("workflow_")&&Bt.has(x)){(async()=>{try{const L=dt.find(Q=>Q.name===x)?._workflow;if(!L)throw new Error(`Workflow metadata not found for ${x}`);let ae;if(L.webhook?.url){let Q=j;if(L.webhook.bodyTemplate){let K=L.webhook.bodyTemplate;Object.entries(j).forEach(([re,Qe])=>{K=K.replace(new RegExp(`\\{\\{${re}\\}\\}`,"g"),String(Qe))}),Q=JSON.parse(K)}const be=await fetch(L.webhook.url,{method:L.webhook.method||"POST",headers:{"Content-Type":"application/json",...L.webhook.headers||{}},body:JSON.stringify(Q)});if(be.ok)ae={success:!0,data:await be.json().catch(()=>({success:!0}))};else{const K=await be.text();ae={success:!1,error:`Webhook failed: ${be.status} ${K}`}}}else ae={success:!0,message:`Workflow "${L.name}" acknowledged. Follow the workflow instructions to proceed.`,instructions:L.contentPlaintext};ue(x,w,ae)}catch(R){console.error(`[useAgent] Error executing workflow ${x}:`,R),ue(x,w,`Error: ${R}`)}})();return}if(Bt.has(x)&&!Kn(x,j)){const R=jt.get(x);R?(async()=>{try{const L=dt.find(Q=>Q.name===x);let ae;if(L&&L.jsonSchema?.properties){const be=Object.keys(L.jsonSchema.properties).map(K=>j[K]);ae=await R(...be)}else if(x==="getState")ae=R();else if(x==="setState"){const Q=j.updates||j;ae=await R(Q)}else ae=await R(...Object.values(j));ue(x,w,ae)}catch(L){console.error(`[useAgent] Error executing tool ${x}:`,L),ue(x,w,`Error: ${L}`)}})():console.warn(`[useAgent] Tool ${x} not found in toolsMap`)}else x.startsWith("workflow_")&&O?O({toolCall:{toolCallId:w,toolName:x,args:j}}):O&&O({toolCall:{toolCallId:w,toolName:x,args:j}})})})},[Je,Bt,jt,O,ue,ut,dt,Kn,qn,Ne]),f.useEffect(()=>{if(_==="ready"&&Je.length>0&&A){const g=Je[Je.length-1];g&&g.role==="assistant"&&A({message:g,messages:Je,isAbort:!1,isDisconnect:!1,isError:!!z})}},[_,Je,z,A]);async function W(){if(!(!r?.id||!Fe)){It(!0);try{const y=await(await fetch(`${X}/conversations`,{headers:{Authorization:`Bearer ${Fe}`}})).json();Tt(y.conversations||[])}catch(g){console.error("Failed to fetch conversations:",g)}finally{It(!1)}}}f.useEffect(()=>{r?.id&&Fe&&W()},[JSON.stringify(r),Fe,X]),f.useEffect(()=>{if(!ke||!oe.current)return;(async()=>{Re(!0),qe(null);try{const y=await fetch(`${X.replace("/chat","")}/convex/api/query`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${oe.current}`},body:JSON.stringify({path:"conversations:getStateByChatId",args:{chatId:ke},format:"json"})});if(!y.ok){const j=await y.text().catch(()=>"Unknown error");throw new Error(`Failed to fetch conversation state: ${y.status} ${j}`)}const w=(await y.json())?.value||{};xe.current=w,ce||ct(w),N&&N(w),Ct.current=!0}catch(y){console.error("Failed to fetch state:",y);const x=y instanceof Error?y:new Error(String(y));qe(x),Ct.current||(xe.current={},ce?N&&N({}):(ct({}),N&&N({})),Ct.current=!0)}finally{Re(!1)}})()},[ke,X,ce,N]);async function me(g){fn(g),It(!0);try{const y=await fetch(`${X}/conversations/${g}/messages`,{headers:{Authorization:`Bearer ${oe.current}`}});if(!y.ok)throw new Error(`Failed to fetch messages: ${y.statusText}`);const w=(await y.json()).messages||[];J(w)}catch(y){console.error("Failed to load conversation messages:",y)}finally{It(!1)}}async function te(g){if(Fe)try{await fetch(`${X}/conversations/${g}`,{method:"DELETE",headers:{Authorization:`Bearer ${Fe}`}}),Tt(St.filter(y=>y._id!==g)),g===ke&&Se()}catch(y){console.error("Failed to delete conversation:",y)}}function Se(){const g=crypto.randomUUID();fn(g),J([]),mn.current=new Set,xe.current={},ce?N&&N({}):(ct({}),N&&N({})),Ct.current=!1}function de(g){const y=g.tool||"unknown-tool",x=je(y,g.output);H({toolCallId:g.toolCallId,tool:y,output:x})}async function Ze(g,y,x){if(!y.startsWith("workflow_"))throw new Error(`${y} is not a workflow tool`);try{const j=dt.find(L=>L.name===y)?._workflow;if(!j)throw new Error(`Workflow metadata not found for ${y}`);let R;if(j.webhook?.url){let L=x;if(j.webhook.bodyTemplate){let Q=j.webhook.bodyTemplate;Object.entries(x).forEach(([be,K])=>{Q=Q.replace(new RegExp(`\\{\\{${be}\\}\\}`,"g"),String(K))}),L=JSON.parse(Q)}const ae=await fetch(j.webhook.url,{method:j.webhook.method||"POST",headers:{"Content-Type":"application/json",...j.webhook.headers||{}},body:JSON.stringify(L)});if(ae.ok)R={success:!0,data:await ae.json().catch(()=>({success:!0}))};else{const Q=await ae.text();R={success:!1,error:`Webhook failed: ${ae.status} ${Q}`}}}else R={success:!0,message:`Workflow "${j.name}" acknowledged. Follow the workflow instructions to proceed.`,instructions:j.contentPlaintext};return de({toolCallId:g,tool:y,output:R}),R}catch(w){const j={success:!1,error:String(w)};throw de({toolCallId:g,tool:y,output:j}),w}}async function ve(g){const y={...xe.current,...g};xe.current=y,ce||ct(y),N&&N(y);try{await Xn(g)}catch(x){throw x}}return{id:ke,messages:Je,status:_,error:z,sendMessage:se,stop:Z,addToolOutput:de,executeWorkflowTool:Ze,setMessages:J,conversations:St,loadConversation:me,deleteConversation:te,startNewConversation:Se,isLoadingConversations:bs,clientToken:Fe,tokenError:dn,state:pn,setState:ve,isStateLoading:Ke,stateError:gn,pendingSecureInputs:Array.from(Ot.values()),completeSecureInput:Wn,pendingSecureForms:Array.from(st.values()),completeSecureForm:rt,safeToolNames:Bt}}function ne(...e){return Pl.twMerge(jl.clsx(e))}const At=So.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?wo.Slot:"button";return c.jsx(i,{ref:o,"data-slot":"button",className:ne(At({variant:t,size:n,className:e})),...r})});Ce.displayName="Button";const Zl=So.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 js({className:e,variant:t,asChild:n=!1,...s}){const r=n?wo.Slot:"span";return c.jsx(r,{"data-slot":"badge",className:ne(Zl({variant:t}),e),...s})}const Ql=({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])},Ao=_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 Ql({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)}})});Ao.displayName="AutosizeTextarea";function ec({delayDuration:e=0,...t}){return c.jsx(Gt.Provider,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function ht({...e}){return c.jsx(ec,{children:c.jsx(Gt.Root,{"data-slot":"tooltip",...e})})}function ft({...e}){return c.jsx(Gt.Trigger,{"data-slot":"tooltip-trigger",...e})}function mt({className:e,sideOffset:t=0,children:n,...s}){return c.jsx(Gt.Portal,{children:c.jsxs(Gt.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(Gt.Arrow,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}function ni({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 pr=f.createContext({});function gr(e){const t=f.useRef(null);return t.current===null&&(t.current=e()),t.current}const yr=typeof window<"u",Eo=yr?f.useLayoutEffect:f.useEffect,ps=f.createContext(null);function xr(e,t){e.indexOf(t)===-1&&e.push(t)}function br(e,t){const n=e.indexOf(t);n>-1&&e.splice(n,1)}const ot=(e,t,n)=>n>t?t:n<e?e:n;function Xs(e,t){return t?`${e}. For more information and steps for solving, visit https://motion.dev/troubleshooting/${t}`:e}let Zt=()=>{},at=()=>{};process.env.NODE_ENV!=="production"&&(Zt=(e,t,n)=>{!e&&typeof console<"u"&&console.warn(Xs(t,n))},at=(e,t,n)=>{if(!e)throw new Error(Xs(t,n))});const lt={},Mo=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e);function ko(e){return typeof e=="object"&&e!==null}const No=e=>/^0[^.\s]+$/u.test(e);function vr(e){let t;return()=>(t===void 0&&(t=e()),t)}const $e=e=>e,tc=(e,t)=>n=>t(e(n)),On=(...e)=>e.reduce(tc),kn=(e,t,n)=>{const s=t-e;return s===0?1:(n-e)/s};class wr{constructor(){this.subscriptions=[]}add(t){return xr(this.subscriptions,t),()=>br(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,Le=e=>e/1e3;function Do(e,t){return t?e*(1e3/t):0}const si=new Set;function Sr(e,t,n){e||si.has(t)||(console.warn(Xs(t,n)),si.add(t))}const Ro=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,nc=1e-7,sc=12;function rc(e,t,n,s,r){let o,i,a=0;do i=t+(n-t)/2,o=Ro(i,s,r)-e,o>0?n=i:t=i;while(Math.abs(o)>nc&&++a<sc);return i}function Ln(e,t,n,s){if(e===t&&n===s)return $e;const r=o=>rc(o,0,1,e,n);return o=>o===0||o===1?o:Ro(r(o),t,s)}const Vo=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,Io=e=>t=>1-e(1-t),Oo=Ln(.33,1.53,.69,.99),Tr=Io(Oo),Lo=Vo(Tr),$o=e=>(e*=2)<1?.5*Tr(e):.5*(2-Math.pow(2,-10*(e-1))),Cr=e=>1-Math.sin(Math.acos(e)),Fo=Io(Cr),Bo=Vo(Cr),ic=Ln(.42,0,1,1),oc=Ln(0,0,.58,1),Uo=Ln(.42,0,.58,1),ac=e=>Array.isArray(e)&&typeof e[0]!="number",zo=e=>Array.isArray(e)&&typeof e[0]=="number",ri={linear:$e,easeIn:ic,easeInOut:Uo,easeOut:oc,circIn:Cr,circInOut:Bo,circOut:Fo,backIn:Tr,backInOut:Lo,backOut:Oo,anticipate:$o},lc=e=>typeof e=="string",ii=e=>{if(zo(e)){at(e.length===4,"Cubic bezier arrays must contain four numerical values.","cubic-bezier-length");const[t,n,s,r]=e;return Ln(t,n,s,r)}else if(lc(e))return at(ri[e]!==void 0,`Invalid easing type '${e}'`,"invalid-easing-type"),ri[e];return e},Jn=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function cc(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 uc=40;function _o(e,t){let n=!1,s=!0;const r={delta:0,timestamp:0,isProcessing:!1},o=()=>n=!0,i=Jn.reduce((E,$)=>(E[$]=cc(o),E),{}),{setup:a,read:l,resolveKeyframes:u,preUpdate:d,update:h,preRender:m,render:p,postRender:S}=i,v=()=>{const E=lt.useManualTiming?r.timestamp:performance.now();n=!1,lt.useManualTiming||(r.delta=s?1e3/60:Math.max(Math.min(E-r.timestamp,uc),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))},T=()=>{n=!0,s=!0,r.isProcessing||e(v)};return{schedule:Jn.reduce((E,$)=>{const D=i[$];return E[$]=(I,N=!1,P=!1)=>(n||T(),D.schedule(I,N,P)),E},{}),cancel:E=>{for(let $=0;$<Jn.length;$++)i[Jn[$]].cancel(E)},state:r,steps:i}}const{schedule:le,cancel:gt,state:we,steps:Ps}=_o(typeof requestAnimationFrame<"u"?requestAnimationFrame:$e,!0);let rs;function dc(){rs=void 0}const Me={now:()=>(rs===void 0&&Me.set(we.isProcessing||lt.useManualTiming?we.timestamp:performance.now()),rs),set:e=>{rs=e,queueMicrotask(dc)}},Xo=e=>t=>typeof t=="string"&&t.startsWith(e),jr=Xo("--"),hc=Xo("var(--"),Pr=e=>hc(e)?fc.test(e.split("/*")[0].trim()):!1,fc=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu,Qt={test:e=>typeof e=="number",parse:parseFloat,transform:e=>e},Nn={...Qt,transform:e=>ot(0,1,e)},Zn={...Qt,default:1},jn=e=>Math.round(e*1e5)/1e5,Ar=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function mc(e){return e==null}const pc=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,Er=(e,t)=>n=>!!(typeof n=="string"&&pc.test(n)&&n.startsWith(e)||t&&!mc(n)&&Object.prototype.hasOwnProperty.call(n,t)),Wo=(e,t,n)=>s=>{if(typeof s!="string")return s;const[r,o,i,a]=s.match(Ar);return{[e]:parseFloat(r),[t]:parseFloat(o),[n]:parseFloat(i),alpha:a!==void 0?parseFloat(a):1}},gc=e=>ot(0,255,e),As={...Qt,transform:e=>Math.round(gc(e))},Mt={test:Er("rgb","red"),parse:Wo("red","green","blue"),transform:({red:e,green:t,blue:n,alpha:s=1})=>"rgba("+As.transform(e)+", "+As.transform(t)+", "+As.transform(n)+", "+jn(Nn.transform(s))+")"};function yc(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 Ws={test:Er("#"),parse:yc,transform:Mt.transform},$n=e=>({test:t=>typeof t=="string"&&t.endsWith(e)&&t.split(" ").length===1,parse:parseFloat,transform:t=>`${t}${e}`}),pt=$n("deg"),et=$n("%"),U=$n("px"),xc=$n("vh"),bc=$n("vw"),oi={...et,parse:e=>et.parse(e)/100,transform:e=>et.transform(e*100)},zt={test:Er("hsl","hue"),parse:Wo("hue","saturation","lightness"),transform:({hue:e,saturation:t,lightness:n,alpha:s=1})=>"hsla("+Math.round(e)+", "+et.transform(jn(t))+", "+et.transform(jn(n))+", "+jn(Nn.transform(s))+")"},ge={test:e=>Mt.test(e)||Ws.test(e)||zt.test(e),parse:e=>Mt.test(e)?Mt.parse(e):zt.test(e)?zt.parse(e):Ws.parse(e),transform:e=>typeof e=="string"?e:e.hasOwnProperty("red")?Mt.transform(e):zt.transform(e),getAnimatableNone:e=>{const t=ge.parse(e);return t.alpha=0,ge.transform(t)}},vc=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function wc(e){return isNaN(e)&&typeof e=="string"&&(e.match(Ar)?.length||0)+(e.match(vc)?.length||0)>0}const Ko="number",qo="color",Sc="var",Tc="var(",ai="${}",Cc=/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 Dn(e){const t=e.toString(),n=[],s={color:[],number:[],var:[]},r=[];let o=0;const a=t.replace(Cc,l=>(ge.test(l)?(s.color.push(o),r.push(qo),n.push(ge.parse(l))):l.startsWith(Tc)?(s.var.push(o),r.push(Sc),n.push(l)):(s.number.push(o),r.push(Ko),n.push(parseFloat(l))),++o,ai)).split(ai);return{values:n,split:a,indexes:s,types:r}}function Go(e){return Dn(e).values}function Yo(e){const{split:t,types:n}=Dn(e),s=t.length;return r=>{let o="";for(let i=0;i<s;i++)if(o+=t[i],r[i]!==void 0){const a=n[i];a===Ko?o+=jn(r[i]):a===qo?o+=ge.transform(r[i]):o+=r[i]}return o}}const jc=e=>typeof e=="number"?0:ge.test(e)?ge.getAnimatableNone(e):e;function Pc(e){const t=Go(e);return Yo(e)(t.map(jc))}const yt={test:wc,parse:Go,createTransformer:Yo,getAnimatableNone:Pc};function Es(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e}function Ac({hue:e,saturation:t,lightness:n,alpha:s}){e/=360,t/=100,n/=100;let r=0,o=0,i=0;if(!t)r=o=i=n;else{const a=n<.5?n*(1+t):n+t-n*t,l=2*n-a;r=Es(l,a,e+1/3),o=Es(l,a,e),i=Es(l,a,e-1/3)}return{red:Math.round(r*255),green:Math.round(o*255),blue:Math.round(i*255),alpha:s}}function cs(e,t){return n=>n>0?t:e}const fe=(e,t,n)=>e+(t-e)*n,Ms=(e,t,n)=>{const s=e*e,r=n*(t*t-s)+s;return r<0?0:Math.sqrt(r)},Ec=[Ws,Mt,zt],Mc=e=>Ec.find(t=>t.test(e));function li(e){const t=Mc(e);if(Zt(!!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===zt&&(n=Ac(n)),n}const ci=(e,t)=>{const n=li(e),s=li(t);if(!n||!s)return cs(e,t);const r={...n};return o=>(r.red=Ms(n.red,s.red,o),r.green=Ms(n.green,s.green,o),r.blue=Ms(n.blue,s.blue,o),r.alpha=fe(n.alpha,s.alpha,o),Mt.transform(r))},Ks=new Set(["none","hidden"]);function kc(e,t){return Ks.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function Nc(e,t){return n=>fe(e,t,n)}function Mr(e){return typeof e=="number"?Nc:typeof e=="string"?Pr(e)?cs:ge.test(e)?ci:Vc:Array.isArray(e)?Ho:typeof e=="object"?ge.test(e)?ci:Dc:cs}function Ho(e,t){const n=[...e],s=n.length,r=e.map((o,i)=>Mr(o)(o,t[i]));return o=>{for(let i=0;i<s;i++)n[i]=r[i](o);return n}}function Dc(e,t){const n={...e,...t},s={};for(const r in n)e[r]!==void 0&&t[r]!==void 0&&(s[r]=Mr(e[r])(e[r],t[r]));return r=>{for(const o in s)n[o]=s[o](r);return n}}function Rc(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 Vc=(e,t)=>{const n=yt.createTransformer(t),s=Dn(e),r=Dn(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?kc(e,t):On(Ho(Rc(s,r),r.values),n):(Zt(!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 Jo(e,t,n){return typeof e=="number"&&typeof t=="number"&&typeof n=="number"?fe(e,t,n):Mr(e)(e,t)}const Ic=e=>{const t=({timestamp:n})=>e(n);return{start:(n=!0)=>le.update(t,n),stop:()=>gt(t),now:()=>we.isProcessing?we.timestamp:Me.now()}},Zo=(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 kr(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 Oc(e,t=100,n){const s=n({...e,keyframes:[0,t]}),r=Math.min(kr(s),us);return{type:"keyframes",ease:o=>s.next(r*o).value/t,duration:Le(r)}}const Lc=5;function Qo(e,t,n){const s=Math.max(t-Lc,0);return Do(n-e(s),t-s)}const he={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},ks=.001;function $c({duration:e=he.duration,bounce:t=he.bounce,velocity:n=he.velocity,mass:s=he.mass}){let r,o;Zt(e<=Xe(he.maxDuration),"Spring duration must be 10 seconds or less","spring-duration-limit");let i=1-t;i=ot(he.minDamping,he.maxDamping,i),e=ot(he.minDuration,he.maxDuration,Le(e)),i<1?(r=u=>{const d=u*i,h=d*e,m=d-n,p=qs(u,i),S=Math.exp(-h);return ks-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=qs(Math.pow(u,2),i);return(-r(u)+ks>0?-1:1)*((m-p)*S)/v}):(r=u=>{const d=Math.exp(-u*e),h=(u-n)*e+1;return-ks+d*h},o=u=>{const d=Math.exp(-u*e),h=(n-u)*(e*e);return d*h});const a=5/e,l=Bc(r,o,a);if(e=Xe(e),isNaN(l))return{stiffness:he.stiffness,damping:he.damping,duration:e};{const u=Math.pow(l,2)*s;return{stiffness:u,damping:i*2*Math.sqrt(s*u),duration:e}}}const Fc=12;function Bc(e,t,n){let s=n;for(let r=1;r<Fc;r++)s=s-e(s)/t(s);return s}function qs(e,t){return e*Math.sqrt(1-t*t)}const Uc=["duration","bounce"],zc=["stiffness","damping","mass"];function ui(e,t){return t.some(n=>e[n]!==void 0)}function _c(e){let t={velocity:he.velocity,stiffness:he.stiffness,damping:he.damping,mass:he.mass,isResolvedFromDuration:!1,...e};if(!ui(e,zc)&&ui(e,Uc))if(e.visualDuration){const n=e.visualDuration,s=2*Math.PI/(n*1.2),r=s*s,o=2*ot(.05,1,1-(e.bounce||0))*Math.sqrt(r);t={...t,mass:he.mass,stiffness:r,damping:o}}else{const n=$c(e);t={...t,...n,mass:he.mass},t.isResolvedFromDuration=!0}return t}function ds(e=he.visualDuration,t=he.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}=_c({...n,velocity:-Le(n.velocity||0)}),S=m||0,v=u/(2*Math.sqrt(l*d)),T=i-o,b=Le(Math.sqrt(l/d)),M=Math.abs(T)<5;s||(s=M?he.restSpeed.granular:he.restSpeed.default),r||(r=M?he.restDelta.granular:he.restDelta.default);let E;if(v<1){const D=qs(b,v);E=I=>{const N=Math.exp(-v*b*I);return i-N*((S+v*b*T)/D*Math.sin(D*I)+T*Math.cos(D*I))}}else if(v===1)E=D=>i-Math.exp(-b*D)*(T+(S+b*T)*D);else{const D=b*Math.sqrt(v*v-1);E=I=>{const N=Math.exp(-v*b*I),P=Math.min(D*I,300);return i-N*((S+v*b*T)*Math.sinh(P)+D*T*Math.cosh(P))/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?Xe(S):Qo(E,D,I));const P=Math.abs(N)<=s,O=Math.abs(i-I)<=r;a.done=P&&O}return a.value=a.done?i:I,a},toString:()=>{const D=Math.min(kr($),us),I=Zo(N=>$.next(D*N).value,D,30);return D+"ms "+I},toTransition:()=>{}};return $}ds.applyToOptions=e=>{const t=Oc(e,100,ds);return e.ease=t.ease,e.duration=Xe(t.duration),e.type="keyframes",e};function Gs({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=P=>a!==void 0&&P<a||l!==void 0&&P>l,S=P=>a===void 0?l:l===void 0||Math.abs(a-P)<Math.abs(l-P)?a:l;let v=n*t;const T=h+v,b=i===void 0?T:i(T);b!==T&&(v=b-h);const M=P=>-v*Math.exp(-P/s),E=P=>b+M(P),$=P=>{const O=M(P),A=E(P);m.done=Math.abs(O)<=u,m.value=m.done?b:A};let D,I;const N=P=>{p(m.value)&&(D=P,I=ds({keyframes:[m.value,S(m.value)],velocity:Qo(E,P,m.value),damping:r,stiffness:o,restDelta:u,restSpeed:d}))};return N(0),{calculatedDuration:null,next:P=>{let O=!1;return!I&&D===void 0&&(O=!0,$(P),N(P)),D!==void 0&&P>=D?I.next(P-D):(!O&&$(P),m)}}}function Xc(e,t,n){const s=[],r=n||lt.mix||Jo,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=On(l,a)}s.push(a)}return s}function Wc(e,t,{clamp:n=!0,ease:s,mixer:r}={}){const o=e.length;if(at(o===t.length,"Both input and output ranges must be the same length","range-length"),o===1)return()=>t[0];if(o===2&&t[0]===t[1])return()=>t[1];const i=e[0]===e[1];e[0]>e[o-1]&&(e=[...e].reverse(),t=[...t].reverse());const a=Xc(t,s,r),l=a.length,u=d=>{if(i&&d<e[0])return t[0];let h=0;if(l>1)for(;h<e.length-2&&!(d<e[h+1]);h++);const m=kn(e[h],e[h+1],d);return a[h](m)};return n?d=>u(ot(e[0],e[o-1],d)):u}function Kc(e,t){const n=e[e.length-1];for(let s=1;s<=t;s++){const r=kn(0,t,s);e.push(fe(n,1,r))}}function qc(e){const t=[0];return Kc(t,e.length-1),t}function Gc(e,t){return e.map(n=>n*t)}function Yc(e,t){return e.map(()=>t||Uo).splice(0,e.length-1)}function _t({duration:e=300,keyframes:t,times:n,ease:s="easeInOut"}){const r=ac(s)?s.map(ii):ii(s),o={done:!1,value:t[0]},i=Gc(n&&n.length===t.length?n:qc(t),e),a=Wc(i,t,{ease:Array.isArray(r)?r:Yc(t,r)});return{calculatedDuration:e,next:l=>(o.value=a(l),o.done=l>=e,o)}}const Hc=e=>e!==null;function Nr(e,{repeat:t,repeatType:n="loop"},s,r=1){const o=e.filter(Hc),a=r<0||t&&n!=="loop"&&t%2===1?0:o.length-1;return!a||s===void 0?o[a]:s}const Jc={decay:Gs,inertia:Gs,tween:_t,keyframes:_t,spring:ds};function ea(e){typeof e.type=="string"&&(e.type=Jc[e.type])}class Dr{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(t=>{this.resolve=t})}notifyFinished(){this.resolve()}then(t,n){return this.finished.then(t,n)}}const Zc=e=>e/100;class Rr extends Dr{constructor(t){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.stop=()=>{const{motionValue:n}=this.options;n&&n.updatedAt!==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;ea(t);const{type:n=_t,repeat:s=0,repeatDelay:r=0,repeatType:o,velocity:i=0}=t;let{keyframes:a}=t;const l=n||_t;process.env.NODE_ENV!=="production"&&l!==_t&&at(a.length<=2,`Only two keyframes currently supported with spring and inertia animations. Trying to animate ${a}`,"spring-two-frames"),l!==_t&&typeof a[0]!="number"&&(this.mixKeyframes=On(Zc,Jo(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=kr(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: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 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 P=Math.min(this.currentTime,r)/a;let O=Math.floor(P),A=P%1;!A&&P>=1&&(A=1),A===1&&O--,O=Math.min(O,h+1),!!(O%2)&&(m==="reverse"?(A=1-A,p&&(A-=p/a)):m==="mirror"&&($=i)),E=ot(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!==Gs&&(D.value=Nr(d,this.options,T,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=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=Le(this.currentTime))}play(){if(this.isStopped)return;const{driver:t=Ic,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 Qc(e){for(let t=1;t<e.length;t++)e[t]??(e[t]=e[t-1])}const kt=e=>e*180/Math.PI,Ys=e=>{const t=kt(Math.atan2(e[1],e[0]));return Hs(t)},eu={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:Ys,rotateZ:Ys,skewX:e=>kt(Math.atan(e[1])),skewY:e=>kt(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},Hs=e=>(e=e%360,e<0&&(e+=360),e),di=Ys,hi=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),fi=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),tu={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:hi,scaleY:fi,scale:e=>(hi(e)+fi(e))/2,rotateX:e=>Hs(kt(Math.atan2(e[6],e[5]))),rotateY:e=>Hs(kt(Math.atan2(-e[2],e[0]))),rotateZ:di,rotate:di,skewX:e=>kt(Math.atan(e[4])),skewY:e=>kt(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function Js(e){return e.includes("scale")?1:0}function Zs(e,t){if(!e||e==="none")return Js(t);const n=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let s,r;if(n)s=tu,r=n;else{const a=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);s=eu,r=a}if(!r)return Js(t);const o=s[t],i=r[1].split(",").map(su);return typeof o=="function"?o(i):i[o]}const nu=(e,t)=>{const{transform:n="none"}=getComputedStyle(e);return Zs(n,t)};function su(e){return parseFloat(e.trim())}const en=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],tn=new Set(en),mi=e=>e===Qt||e===U,ru=new Set(["x","y","z"]),iu=en.filter(e=>!ru.has(e));function ou(e){const t=[];return iu.forEach(n=>{const s=e.getValue(n);s!==void 0&&(t.push([n,s.get()]),s.set(n.startsWith("scale")?1:0))}),t}const Nt={width:({x:e},{paddingLeft:t="0",paddingRight:n="0"})=>e.max-e.min-parseFloat(t)-parseFloat(n),height:({y:e},{paddingTop:t="0",paddingBottom:n="0"})=>e.max-e.min-parseFloat(t)-parseFloat(n),top:(e,{top:t})=>parseFloat(t),left:(e,{left:t})=>parseFloat(t),bottom:({y:e},{top:t})=>parseFloat(t)+(e.max-e.min),right:({x:e},{left:t})=>parseFloat(t)+(e.max-e.min),x:(e,{transform:t})=>Zs(t,"x"),y:(e,{transform:t})=>Zs(t,"y")};Nt.translateX=Nt.x;Nt.translateY=Nt.y;const Dt=new Set;let Qs=!1,er=!1,tr=!1;function ta(){if(er){const e=Array.from(Dt).filter(s=>s.needsMeasurement),t=new Set(e.map(s=>s.element)),n=new Map;t.forEach(s=>{const r=ou(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)})}er=!1,Qs=!1,Dt.forEach(e=>e.complete(tr)),Dt.clear()}function na(){Dt.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(er=!0)})}function au(){tr=!0,na(),ta(),tr=!1}class Vr{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?(Dt.add(this),Qs||(Qs=!0,le.read(na),le.resolveKeyframes(ta))):(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])}Qc(t)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(t=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,t),Dt.delete(this)}cancel(){this.state==="scheduled"&&(Dt.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const lu=e=>e.startsWith("--");function cu(e,t,n){lu(t)?e.style.setProperty(t,n):e.style[t]=n}const uu=vr(()=>window.ScrollTimeline!==void 0),du={};function hu(e,t){const n=vr(e);return()=>du[t]??n()}const sa=hu(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),Tn=([e,t,n,s])=>`cubic-bezier(${e}, ${t}, ${n}, ${s})`,pi={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:Tn([0,.65,.55,1]),circOut:Tn([.55,0,1,.45]),backIn:Tn([.31,.01,.66,-.59]),backOut:Tn([.33,1.53,.69,.99])};function ra(e,t){if(e)return typeof e=="function"?sa()?Zo(e,t):"ease-out":zo(e)?Tn(e):Array.isArray(e)?e.map(n=>ra(n,t)||pi.easeOut):pi[e]}function fu(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=ra(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 ia(e){return typeof e=="function"&&"applyToOptions"in e}function mu({type:e,...t}){return ia(e)&&sa()?e.applyToOptions(t):(t.duration??(t.duration=300),t.ease??(t.ease="easeOut"),t)}class pu extends Dr{constructor(t){if(super(),this.finishedTime=null,this.isStopped=!1,!t)return;const{element:n,name:s,keyframes:r,pseudoElement:o,allowFlatten:i=!1,finalKeyframe:a,onComplete:l}=t;this.isPseudoElement=!!o,this.allowFlatten=i,this.options=t,at(typeof t.type!="string",`Mini animate() doesn't support "type" as a string.`,"mini-spring");const u=mu(t);this.animation=fu(n,s,r,u,o),u.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!o){const d=Nr(r,this.options,a,this.speed);this.updateMotionValue?this.updateMotionValue(d):cu(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=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&&uu()?(this.animation.timeline=t,$e):n(this)}}const oa={anticipate:$o,backInOut:Lo,circInOut:Bo};function gu(e){return e in oa}function yu(e){typeof e.ease=="string"&&gu(e.ease)&&(e.ease=oa[e.ease])}const gi=10;class xu extends pu{constructor(t){yu(t),ea(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 Rr({...i,autoplay:!1}),l=Xe(this.finishedTime??this.time);n.setWithVelocity(a.sample(l-gi).value,a.sample(l).value,gi),a.stop()}}const yi=(e,t)=>t==="zIndex"?!1:!!(typeof e=="number"||Array.isArray(e)||typeof e=="string"&&(yt.test(e)||e==="0")&&!e.startsWith("url("));function bu(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 vu(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=yi(r,t),a=yi(o,t);return Zt(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:bu(e)||(n==="spring"||ia(n))&&s}function nr(e){e.duration=0,e.type="keyframes"}const wu=new Set(["opacity","clipPath","filter","transform"]),Su=vr(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function Tu(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 Su()&&n&&wu.has(n)&&(n!=="transform"||!u)&&!l&&!s&&r!=="mirror"&&o!==0&&i!=="inertia"}const Cu=40;class ju extends Dr{constructor({autoplay:t=!0,delay:n=0,type:s="keyframes",repeat:r=0,repeatDelay:o=0,repeatType:i="loop",keyframes:a,name:l,motionValue:u,element:d,...h}){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=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||Vr;this.keyframeResolver=new p(a,(S,v,T)=>this.onKeyframesResolved(S,v,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(),vu(t,o,i,a)||((lt.instantAnimations||!l)&&d?.(Nr(t,s,n)),t[0]=t[t.length-1],nr(s),s.repeat=0);const m={startTime:r?this.resolvedAt?this.resolvedAt-this.createdAt>Cu?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...s,keyframes:t},p=!u&&Tu(m)?new xu({...m,element:m.motionValue.owner.current}):new Rr(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(),au()),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 Pu=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function Au(e){const t=Pu.exec(e);if(!t)return[,];const[,n,s,r]=t;return[`--${n??s}`,r]}const Eu=4;function aa(e,t,n=1){at(n<=Eu,`Max CSS variable fallback depth detected in property "${e}". This may indicate a circular fallback dependency.`,"max-css-var-depth");const[s,r]=Au(e);if(!s)return;const o=window.getComputedStyle(t).getPropertyValue(s);if(o){const i=o.trim();return Mo(i)?parseFloat(i):i}return Pr(r)?aa(r,t,n+1):r}function Ir(e,t){return e?.[t]??e?.default??e}const la=new Set(["width","height","top","left","right","bottom",...en]),Mu={test:e=>e==="auto",parse:e=>e},ca=e=>t=>t.test(e),ua=[Qt,U,et,pt,bc,xc,Mu],xi=e=>ua.find(ca(e));function ku(e){return typeof e=="number"?e===0:e!==null?e==="none"||e==="0"||No(e):!0}const Nu=new Set(["brightness","contrast","saturate","opacity"]);function Du(e){const[t,n]=e.slice(0,-1).split("(");if(t==="drop-shadow")return e;const[s]=n.match(Ar)||[];if(!s)return e;const r=n.replace(s,"");let o=Nu.has(t)?1:0;return s!==n&&(o*=100),t+"("+o+r+")"}const Ru=/\b([a-z-]*)\(.*?\)/gu,sr={...yt,getAnimatableNone:e=>{const t=e.match(Ru);return t?t.map(Du).join(" "):e}},bi={...Qt,transform:Math.round},Vu={rotate:pt,rotateX:pt,rotateY:pt,rotateZ:pt,scale:Zn,scaleX:Zn,scaleY:Zn,scaleZ:Zn,skew:pt,skewX:pt,skewY:pt,distance:U,translateX:U,translateY:U,translateZ:U,x:U,y:U,z:U,perspective:U,transformPerspective:U,opacity:Nn,originX:oi,originY:oi,originZ:U},Or={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,...Vu,zIndex:bi,fillOpacity:Nn,strokeOpacity:Nn,numOctaves:bi},Iu={...Or,color:ge,backgroundColor:ge,outlineColor:ge,fill:ge,stroke:ge,borderColor:ge,borderTopColor:ge,borderRightColor:ge,borderBottomColor:ge,borderLeftColor:ge,filter:sr,WebkitFilter:sr},da=e=>Iu[e];function ha(e,t){let n=da(e);return n!==sr&&(n=yt),n.getAnimatableNone?n.getAnimatableNone(t):void 0}const Ou=new Set(["auto","none","0"]);function Lu(e,t,n){let s=0,r;for(;s<e.length&&!r;){const o=e[s];typeof o=="string"&&!Ou.has(o)&&Dn(o).values.length&&(r=e[s]),s++}if(r&&n)for(const o of t)e[o]=ha(n,r)}class $u extends Vr{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(),Pr(u))){const d=aa(u,n.current);d!==void 0&&(t[l]=d),l===t.length-1&&(this.finalKeyframe=u)}}if(this.resolveNoneKeyframes(),!la.has(s)||t.length!==2)return;const[r,o]=t,i=xi(r),a=xi(o);if(i!==a)if(mi(i)&&mi(a))for(let l=0;l<t.length;l++){const u=t[l];typeof u=="string"&&(t[l]=parseFloat(u))}else Nt[s]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:t,name:n}=this,s=[];for(let r=0;r<t.length;r++)(t[r]===null||ku(t[r]))&&s.push(r);s.length&&Lu(t,s,n)}measureInitialState(){const{element:t,unresolvedKeyframes:n,name:s}=this;if(!t||!t.current)return;s==="height"&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=Nt[s](t.measureViewportBox(),window.getComputedStyle(t.current)),n[0]=this.measuredOrigin;const r=n[n.length-1];r!==void 0&&t.getValue(s,r).jump(r,!1)}measureEndState(){const{element:t,name:n,unresolvedKeyframes:s}=this;if(!t||!t.current)return;const r=t.getValue(n);r&&r.jump(this.measuredOrigin,!1);const o=s.length-1,i=s[o];s[o]=Nt[n](t.measureViewportBox(),window.getComputedStyle(t.current)),i!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=i),this.removedTransforms?.length&&this.removedTransforms.forEach(([a,l])=>{t.getValue(a).set(l)}),this.resolveNoneKeyframes()}}function Fu(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 fa=(e,t)=>t&&typeof e=="number"?t.transform(e):e;function ma(e){return ko(e)&&"offsetHeight"in e}const vi=30,Bu=e=>!isNaN(parseFloat(e));class Uu{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=Bu(this.current))}setPrevFrameValue(t=this.current){this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt}onChange(t){return process.env.NODE_ENV!=="production"&&Sr(!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 wr);const s=this.events[t].add(n);return t==="change"?()=>{s(),le.read(()=>{this.events.change.getSize()||this.stop()})}:s}clearListeners(){for(const t in this.events)this.events[t].clear()}attach(t,n){this.passiveEffect=t,this.stopPassiveEffect=n}set(t){this.passiveEffect?this.passiveEffect(t,this.updateAndNotify):this.updateAndNotify(t)}setWithVelocity(t,n,s){this.set(n),this.prev=void 0,this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt-s}jump(t,n=!0){this.updateAndNotify(t),this.prev=t,this.prevUpdatedAt=this.prevFrameValue=void 0,n&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){this.events.change?.notify(this.current)}addDependent(t){this.dependents||(this.dependents=new Set),this.dependents.add(t)}removeDependent(t){this.dependents&&this.dependents.delete(t)}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const t=Me.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||t-this.updatedAt>vi)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,vi);return Do(parseFloat(this.current)-parseFloat(this.prevFrameValue),n)}start(t){return this.stop(),new Promise(n=>{this.hasAnimated=!0,this.animation=t(n),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.dependents?.clear(),this.events.destroy?.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function Ht(e,t){return new Uu(e,t)}const{schedule:Lr}=_o(queueMicrotask,!1),ze={x:!1,y:!1};function pa(){return ze.x||ze.y}function zu(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 ga(e,t){const n=Fu(e),s=new AbortController,r={passive:!0,...t,signal:s.signal};return[n,r,()=>s.abort()]}function wi(e){return!(e.pointerType==="touch"||pa())}function _u(e,t,n={}){const[s,r,o]=ga(e,n),i=a=>{if(!wi(a))return;const{target:l}=a,u=t(l,a);if(typeof u!="function"||!l)return;const d=h=>{wi(h)&&(u(h),l.removeEventListener("pointerleave",d))};l.addEventListener("pointerleave",d,r)};return s.forEach(a=>{a.addEventListener("pointerenter",i,r)}),o}const ya=(e,t)=>t?e===t?!0:ya(e,t.parentElement):!1,$r=e=>e.pointerType==="mouse"?typeof e.button!="number"||e.button<=0:e.isPrimary!==!1,Xu=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function Wu(e){return Xu.has(e.tagName)||e.tabIndex!==-1}const is=new WeakSet;function Si(e){return t=>{t.key==="Enter"&&e(t)}}function Ns(e,t){e.dispatchEvent(new PointerEvent("pointer"+t,{isPrimary:!0,bubbles:!0}))}const Ku=(e,t)=>{const n=e.currentTarget;if(!n)return;const s=Si(()=>{if(is.has(n))return;Ns(n,"down");const r=Si(()=>{Ns(n,"up")}),o=()=>Ns(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 Ti(e){return $r(e)&&!pa()}function qu(e,t,n={}){const[s,r,o]=ga(e,n),i=a=>{const l=a.currentTarget;if(!Ti(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),Ti(p)&&typeof u=="function"&&u(p,{success:S})},h=p=>{d(p,l===window||l===document||n.useGlobalTarget||ya(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),ma(a)&&(a.addEventListener("focus",u=>Ku(u,r)),!Wu(a)&&!a.hasAttribute("tabindex")&&(a.tabIndex=0))}),o}function xa(e){return ko(e)&&"ownerSVGElement"in e}function Gu(e){return xa(e)&&e.tagName==="svg"}const Te=e=>!!(e&&e.getVelocity),Yu=[...ua,ge,yt],Hu=e=>Yu.find(ca(e)),Fr=f.createContext({transformPagePoint:e=>e,isStatic:!1,reducedMotion:"never"});function Ci(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Ju(...e){return t=>{let n=!1;const s=e.map(r=>{const o=Ci(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():Ci(e[r],null)}}}}function Zu(...e){return _e.useCallback(Ju(...e),e)}class Qu extends _e.Component{getSnapshotBeforeUpdate(t){const n=this.props.childRef.current;if(n&&t.isPresent&&!this.props.isPresent){const s=n.offsetParent,r=ma(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 ed({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(Fr),l=Zu(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 T=s??document.head;return T.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(v)&&T.removeChild(v)}},[t]),c.jsx(Qu,{isPresent:t,childRef:o,sizeRef:i,children:_e.cloneElement(e,{ref:l})})}const td=({children:e,initial:t,isPresent:n,onExitComplete:s,custom:r,presenceAffectsLayout:o,mode:i,anchorX:a,root:l})=>{const u=gr(nd),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(ed,{isPresent:n,anchorX:a,root:l,children:e})),c.jsx(ps.Provider,{value:m,children:e})};function nd(){return new Map}function ba(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 ji(e){const t=[];return f.Children.forEach(e,n=>{f.isValidElement(n)&&t.push(n)}),t}const sd=({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]=ba(i),h=f.useMemo(()=>ji(e),[e]),m=i&&!u?[]:h.map(Qn),p=f.useRef(!0),S=f.useRef(h),v=gr(()=>new Map),[T,b]=f.useState(h),[E,M]=f.useState(h);Mo(()=>{p.current=!1,S.current=h;for(let I=0;I<E.length;I++){const N=Qn(E[I]);m.includes(N)?v.delete(N):v.get(N)!==!0&&v.set(N,!1)}},[E,m.length,m.join("-")]);const $=[];if(h!==T){let I=[...h];for(let N=0;N<E.length;N++){const P=E[N],O=Qn(P);m.includes(O)||(I.splice(N,0,P),$.push(P))}return o==="wait"&&$.length&&(I=$),M(ji(I)),b(h),null}process.env.NODE_ENV!=="production"&&o==="wait"&&E.length>1&&console.warn(`You're attempting to animate multiple children within AnimatePresence, but its mode is set to "wait". This will lead to odd visual behaviour.`);const{forceRender:D}=f.useContext(pr);return c.jsx(c.Fragment,{children:E.map(I=>{const N=Qn(I),P=i&&!u?!1:h===E||m.includes(N),O=()=>{if(v.has(N))v.set(N,!0);else return;let A=!0;v.forEach(k=>{k||(A=!1)}),A&&(D?.(),M(S.current),i&&d?.(),s&&s())};return c.jsx(td,{isPresent:P,initial:!p.current||n?void 0:!1,custom:t,presenceAffectsLayout:r,mode:o,root:l,onExitComplete:P?void 0:O,anchorX:a,children:I},N)})})},Br=f.createContext({strict:!1}),Pi={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"]},Jt={};for(const e in Pi)Jt[e]={isEnabled:t=>Pi[e].some(n=>!!t[n])};function rr(e){for(const t in e)Jt[t]={...Jt[t],...e[t]}}function rd({children:e,features:t,strict:n=!1}){const[,s]=f.useState(!Ds(t)),r=f.useRef(void 0);if(!Ds(t)){const{renderer:o,...i}=t;r.current=o,rr(i)}return f.useEffect(()=>{Ds(t)&&t().then(({renderer:o,...i})=>{rr(i),r.current=o,s(!0)})},[]),c.jsx(Br.Provider,{value:{renderer:r.current,strict:n},children:e})}function Ds(e){return typeof e=="function"}const id=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")||id.has(e)}let va=e=>!hs(e);function od(e){typeof e=="function"&&(va=t=>t.startsWith("on")?!hs(t):e(t))}try{od(require("@emotion/is-prop-valid").default)}catch{}function ad(e,t,n){const s={};for(const r in e)r==="values"&&typeof e.values=="object"||(va(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 Rn(e){return typeof e=="string"||Array.isArray(e)}const Ur=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],zr=["initial",...Ur];function xs(e){return ys(e.animate)||zr.some(t=>Rn(e[t]))}function wa(e){return!!(xs(e)||e.variants)}function ld(e,t){if(xs(e)){const{initial:n,animate:s}=e;return{initial:n===!1||Rn(n)?n:void 0,animate:Rn(s)?s:void 0}}return e.inherit!==!1?t:{}}function cd(e){const{initial:t,animate:n}=ld(e,f.useContext(gs));return f.useMemo(()=>({initial:t,animate:n}),[Ai(t),Ai(n)])}function Ai(e){return Array.isArray(e)?e.join(" "):e}const Vn={};function ud(e){for(const t in e)Vn[t]=e[t],jr(t)&&(Vn[t].isCSSVariable=!0)}function Sa(e,{layout:t,layoutId:n}){return tn.has(e)||e.startsWith("origin")||(t||n!==void 0)&&(!!Vn[e]||e==="opacity")}const dd={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},hd=en.length;function fd(e,t,n){let s="",r=!0;for(let o=0;o<hd;o++){const i=en[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=fa(a,Or[i]);if(!l){r=!1;const d=dd[i]||i;s+=`${d}(${u}) `}n&&(t[i]=u)}}return s=s.trim(),n?s=n(t,r?"":s):r&&(s="none"),s}function _r(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(tn.has(l)){i=!0;continue}else if(jr(l)){r[l]=u;continue}else{const d=fa(u,Or[l]);l.startsWith("origin")?(a=!0,o[l]=d):s[l]=d}}if(t.transform||(i||n?s.transform=fd(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 Xr=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function Ta(e,t,n){for(const s in t)!Te(t[s])&&!Sa(s,n)&&(e[s]=t[s])}function md({transformTemplate:e},t){return f.useMemo(()=>{const n=Xr();return _r(n,t,e),Object.assign({},n.vars,n.style)},[t])}function pd(e,t){const n=e.style||{},s={};return Ta(s,n,e),Object.assign(s,md(e,t)),s}function gd(e,t){const n={},s=pd(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 yd={offset:"stroke-dashoffset",array:"stroke-dasharray"},xd={offset:"strokeDashoffset",array:"strokeDasharray"};function bd(e,t,n=1,s=0,r=!0){e.pathLength=1;const o=r?yd:xd;e[o.offset]=U.transform(-s);const i=U.transform(t),a=U.transform(n);e[o.array]=`${i} ${a}`}function Ca(e,{attrX:t,attrY:n,attrScale:s,pathLength:r,pathSpacing:o=1,pathOffset:i=0,...a},l,u,d){if(_r(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&&bd(h,r,o,i,!1)}const ja=()=>({...Xr(),attrs:{}}),Pa=e=>typeof e=="string"&&e.toLowerCase()==="svg";function vd(e,t,n,s){const r=f.useMemo(()=>{const o=ja();return Ca(o,t,Pa(s),e.transformTemplate,e.style),{...o.attrs,style:{...o.style}}},[t]);if(e.style){const o={};Ta(o,e.style,e),r.style={...o,...r.style}}return r}const wd=["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 Wr(e){return typeof e!="string"||e.includes("-")?!1:!!(wd.indexOf(e)>-1||/[A-Z]/u.test(e))}function Sd(e,t,n,{latestValues:s},r,o=!1){const a=(Wr(e)?vd:gd)(t,s,r,e),l=ad(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 Mi(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]=Mi(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]=Mi(s);t=t(n!==void 0?n:e.custom,r,o)}return t}function os(e){return Te(e)?e.get():e}function Td({scrapeMotionValuesFromProps:e,createRenderState:t},n,s,r){return{latestValues:Cd(n,s,r,e),renderState:t()}}function Cd(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=wa(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:T,...b}=S;for(const E in b){let M=b[E];if(Array.isArray(M)){const $=d?M.length-1:0;M=M[$]}M!==null&&(r[E]=M)}for(const E in v)r[E]=v[E]}}}return r}const Aa=e=>(t,n)=>{const s=f.useContext(gs),r=f.useContext(ps),o=()=>Td(e,t,s,r);return n?o():gr(o)};function qr(e,t,n){const{style:s}=e,r={};for(const o in s)(Te(s[o])||t.style&&Te(t.style[o])||Sa(o,e)||n?.getValue(o)?.liveStyle!==void 0)&&(r[o]=s[o]);return r}const jd=Aa({scrapeMotionValuesFromProps:qr,createRenderState:Xr});function Ma(e,t,n){const s=qr(e,t,n);for(const r in e)if(Te(e[r])||Te(t[r])){const o=en.indexOf(r)!==-1?"attr"+r.charAt(0).toUpperCase()+r.substring(1):r;s[o]=e[r]}return s}const Pd=Aa({scrapeMotionValuesFromProps:Ma,createRenderState:ja}),Ad=Symbol.for("motionComponentSymbol");function Xt(e){return e&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"current")}function Md(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):Xt(n)&&(n.current=s))},[t])}const Gr=e=>e.replace(/([a-z])([A-Z])/gu,"$1-$2").toLowerCase(),Ed="framerAppearId",Ea="data-"+Gr(Ed),ka=f.createContext({});function kd(e,t,n,s,r){const{visualElement:o}=f.useContext(gs),i=f.useContext(Br),a=f.useContext(ps),l=f.useContext(Fr).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(ka);d&&!d.projection&&r&&(d.type==="html"||d.type==="svg")&&Nd(u.current,n,r,h);const m=f.useRef(!1);f.useInsertionEffect(()=>{d&&m.current&&d.update(n,a)});const p=n[Ea],S=f.useRef(!!p&&!window.MotionHandoffIsComplete?.(p)&&window.MotionHasOptimisedAnimation?.(p));return Mo(()=>{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 Nd(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:Na(e.parent)),e.projection.setOptions({layoutId:r,layout:o,alwaysMeasureLayout:!!i||a&&Xt(a),visualElement:e,animationType:typeof o=="string"?o:"both",initialPromotionConfig:s,crossfade:d,layoutScroll:l,layoutRoot:u})}function Na(e){if(e)return e.options.allowProjection!==!1?e.projection:Na(e.parent)}function as(e,{forwardMotionProps:t=!1}={},n,s){n&&rr(n);const r=Wr(e)?Pd:jd;function o(a,l){let u;const d={...f.useContext(Fr),...a,layoutId:Dd(a)},{isStatic:h}=d,m=cd(a),p=r(a,h);if(!h&&yr){Rd(d,n);const S=Vd(d);u=S.MeasureLayout,m.visualElement=kd(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,Sd(e,a,Md(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[Ad]=e,i}function Dd({layoutId:e}){const t=f.useContext(pr).id;return t&&e!==void 0?t+"-"+e:e}function Rd(e,t){const n=f.useContext(Br).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?Zt(!1,s,"lazy-strict-mode"):at(!1,s,"lazy-strict-mode")}}function Vd(e){const{drag:t,layout:n}=Jt;if(!t&&!n)return{};const s={...t,...n};return{MeasureLayout:t?.isEnabled(e)||n?.isEnabled(e)?s.MeasureLayout:void 0,ProjectionNode:s.ProjectionNode}}function Id(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"&&Sr(!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 Da({top:e,left:t,right:n,bottom:s}){return{x:{min:t,max:n},y:{min:e,max:s}}}function Od({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function Ld(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 Rs(e){return e===void 0||e===1}function ir({scale:e,scaleX:t,scaleY:n}){return!Rs(e)||!Rs(t)||!Rs(n)}function Mt(e){return ir(e)||Ra(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function Ra(e){return Ei(e.x)||Ei(e.y)}function Ei(e){return e&&e!=="0%"}function fs(e,t,n){const s=e-n,r=t*s;return n+r}function ki(e,t,n,s,r){return r!==void 0&&(e=fs(e,r,s)),fs(e,n,s)+t}function or(e,t=0,n=1,s,r){e.min=ki(e.min,t,n,s,r),e.max=ki(e.max,t,n,s,r)}function Va(e,{x:t,y:n}){or(e.x,t.translate,t.scale,t.originPoint),or(e.y,n.translate,n.scale,n.originPoint)}const Ni=.999999999999,Di=1.0000000000001;function $d(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&&Kt(e,{x:-o.scroll.offset.x,y:-o.scroll.offset.y}),i&&(t.x*=i.x.scale,t.y*=i.y.scale,Va(e,i)),s&&Mt(o.latestValues)&&Kt(e,o.latestValues))}t.x<Di&&t.x>Ni&&(t.x=1),t.y<Di&&t.y>Ni&&(t.y=1)}function Wt(e,t){e.min=e.min+t,e.max=e.max+t}function Ri(e,t,n,s,r=.5){const o=fe(e.min,e.max,r);or(e,t,n,o,s)}function Kt(e,t){Ri(e.x,t.x,t.scaleX,t.scale,t.originX),Ri(e.y,t.y,t.scaleY,t.scale,t.originY)}function Ia(e,t){return Da(Ld(e.getBoundingClientRect(),t))}function Fd(e,t,n){const s=Ia(e,n),{scroll:r}=t;return r&&(Wt(s.x,r.offset.x),Wt(s.y,r.offset.y)),s}const Vi=()=>({translate:0,scale:1,origin:0,originPoint:0}),qt=()=>({x:Vi(),y:Vi()}),Ii=()=>({min:0,max:0}),pe=()=>({x:Ii(),y:Ii()}),ar={current:null},Oa={current:!1};function Bd(){if(Oa.current=!0,!!yr)if(window.matchMedia){const e=window.matchMedia("(prefers-reduced-motion)"),t=()=>ar.current=e.matches;e.addEventListener("change",t),t()}else ar.current=!1}const Ud=new WeakMap;function zd(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,Ht(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,Ht(i!==void 0?i:r,{owner:e}))}}for(const s in n)t[s]===void 0&&e.removeValue(s);return t}const Oi=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];class _d{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=Vr,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=Ee.now();this.renderScheduledAt<m&&(this.renderScheduledAt=m,le.render(this.render,!1,!0))};const{latestValues:l,renderState:u}=i;this.latestValues=l,this.baseTarget={...l},this.initialValues=n.initial?{...l}:{},this.renderState=u,this.parent=t,this.props=n,this.presenceContext=s,this.depth=t?t.depth+1:0,this.reducedMotionConfig=r,this.options=a,this.blockInitialAnimation=!!o,this.isControllingVariants=xs(n),this.isVariantNode=wa(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,Ud.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)),Oa.current||Bd(),this.shouldReduceMotion=this.reducedMotionConfig==="never"?!1:this.reducedMotionConfig==="always"?!0:ar.current,process.env.NODE_ENV!=="production"&&Sr(this.shouldReduceMotion!==!0,"You have Reduced Motion enabled on your device. Animations may not appear as expected.","reduced-motion-disabled"),this.parent?.addChild(this),this.update(this.props,this.presenceContext)}unmount(){this.projection&&this.projection.unmount(),gt(this.notifyUpdate),gt(this.render),this.valueSubscriptions.forEach(t=>t()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent?.removeChild(this);for(const t in this.events)this.events[t].clear();for(const t in this.features){const n=this.features[t];n&&(n.unmount(),n.isMounted=!1)}this.current=null}addChild(t){this.children.add(t),this.enteringChildren??(this.enteringChildren=new Set),this.enteringChildren.add(t)}removeChild(t){this.children.delete(t),this.enteringChildren&&this.enteringChildren.delete(t)}bindToMotionValue(t,n){this.valueSubscriptions.has(t)&&this.valueSubscriptions.get(t)();const s=tn.has(t);s&&this.onBindTransform&&this.onBindTransform();const r=n.on("change",i=>{this.latestValues[t]=i,this.props.onUpdate&&le.preRender(this.notifyUpdate),s&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});let o;window.MotionCheckAppearSync&&(o=window.MotionCheckAppearSync(this,t,n)),this.valueSubscriptions.set(t,()=>{r(),o&&o(),n.owner&&n.stop()})}sortNodePosition(t){return!this.current||!this.sortInstanceNodePosition||this.type!==t.type?0:this.sortInstanceNodePosition(this.current,t.current)}updateFeatures(){let t="animation";for(t in Jt){const n=Jt[t];if(!n)continue;const{isEnabled:s,Feature:r}=n;if(!this.features[t]&&r&&s(this.props)&&(this.features[t]=new r(this)),this.features[t]){const o=this.features[t];o.isMounted?o.update():(o.mount(),o.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):pe()}getStaticValue(t){return this.latestValues[t]}setStaticValue(t,n){this.latestValues[t]=n}update(t,n){(t.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=t,this.prevPresenceContext=this.presenceContext,this.presenceContext=n;for(let s=0;s<Oi.length;s++){const r=Oi[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=zd(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=Ht(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"&&(Eo(s)||No(s))?s=parseFloat(s):!Hu(s)&&yt.test(n)&&(s=ha(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=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&&!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 wr),this.events[t].add(n)}notify(t,...n){this.events[t]&&this.events[t].notify(...n)}scheduleRenderMicrotask(){Lr.render(this.render)}}class La extends _d{constructor(){super(...arguments),this.KeyframeResolver=$u}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 $a(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 Xd(e){return window.getComputedStyle(e)}class Wd extends La{constructor(){super(...arguments),this.type="html",this.renderInstance=$a}readValueFromInstance(t,n){if(tn.has(n))return this.projection?.isProjecting?Js(n):nu(t,n);{const s=Xd(t),r=(jr(n)?s.getPropertyValue(n):s[n])||0;return typeof r=="string"?r.trim():r}}measureInstanceViewportBox(t,{transformPagePoint:n}){return Ia(t,n)}build(t,n,s){_r(t,n,s.transformTemplate)}scrapeMotionValuesFromProps(t,n,s){return qr(t,n,s)}}const Fa=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues","viewBox","gradientTransform","pathLength","startOffset","textLength","lengthAdjust"]);function Kd(e,t,n,s){$a(e,t,void 0,s);for(const r in t.attrs)e.setAttribute(Fa.has(r)?r:Gr(r),t.attrs[r])}class qd extends La{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=pe}getBaseTargetFromProps(t,n){return t[n]}readValueFromInstance(t,n){if(tn.has(n)){const s=da(n);return s&&s.default||0}return n=Fa.has(n)?n:Gr(n),t.getAttribute(n)}scrapeMotionValuesFromProps(t,n,s){return Ma(t,n,s)}build(t,n,s){Ca(t,n,this.isSVGTag,s.transformTemplate,s.style)}renderInstance(t,n,s,r){Kd(t,n,s,r)}mount(t){this.isSVGTag=Pa(t.tagName),super.mount(t)}}const Ba=(e,t)=>Wr(e)?new qd(t):new Wd(t,{allowProjection:e!==f.Fragment});function Yt(e,t,n){const s=e.getProps();return Kr(s,t,n!==void 0?n:s.custom,e)}const lr=e=>Array.isArray(e);function Gd(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,Ht(n))}function Yd(e){return lr(e)?e[e.length-1]||0:e}function Hd(e,t){const n=Yt(e,t);let{transitionEnd:s={},transition:r={},...o}=n||{};o={...o,...s};for(const i in o){const a=Yd(o[i]);Gd(e,i,a)}}function Jd(e){return!!(Te(e)&&e.add)}function cr(e,t){const n=e.getValue("willChange");if(Jd(n))return n.add(t);if(!n&&lt.WillChange){const s=new lt.WillChange("auto");e.addValue("willChange",s),s.add(t)}}function Ua(e){return e.props[Ea]}const Zd=e=>e!==null;function Qd(e,{repeat:t,repeatType:n="loop"},s){const r=e.filter(Zd),o=t&&n!=="loop"&&t%2===1?0:r.length-1;return r[o]}const eh={type:"spring",stiffness:500,damping:25,restSpeed:10},th=e=>({type:"spring",stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),nh={type:"keyframes",duration:.8},sh={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},rh=(e,{keyframes:t})=>t.length>2?nh:tn.has(e)?e.startsWith("scale")?th(t[1]):eh:sh;function ih({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 Yr=(e,t,n,s={},r,o)=>i=>{const a=Ir(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};ih(a)||Object.assign(d,rh(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)&&(nr(d),d.delay===0&&(h=!0)),(lt.instantAnimations||lt.skipAnimations)&&(h=!0,nr(d),d.delay=0),d.allowFlatten=!a.type&&!a.ease,h&&!o&&t.get()!==void 0){const m=Qd(d.keyframes,a);if(m!==void 0){le.update(()=>{d.onUpdate(m),d.onComplete()});return}}return a.isSync?new Rr(d):new ju(d)};function oh({protectedKeys:e,needsAnimating:t},n){const s=e.hasOwnProperty(n)&&t[n]!==!0;return t[n]=!1,s}function za(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&&oh(u,d))continue;const p={delay:n,...Ir(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=Ua(e);if(b){const E=window.MotionHandoffAnimation(b,d,le);E!==null&&(p.startTime=E,v=!0)}}cr(e,d),h.start(Yr(d,h,m,e.shouldReduceMotion&&la.has(d)?{type:!1}:p,e,v));const T=h.animation;T&&l.push(T)}return i&&Promise.all(l).then(()=>{le.update(()=>{i&&Hd(e,i)})}),l}function _a(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 ur(e,t,n={}){const s=Yt(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(za(e,s,n)):()=>Promise.resolve(),i=e.variantChildren&&e.variantChildren.size?(l=0)=>{const{delayChildren:u=0,staggerChildren:d,staggerDirection:h}=r;return ah(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 ah(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(ur(l,t,{...i,delay:n+(typeof s=="function"?0:s)+_a(e.variantChildren,l,s,r,o)}).then(()=>l.notify("AnimationComplete",t)));return Promise.all(a)}function lh(e,t,n={}){e.notify("AnimationStart",t);let s;if(Array.isArray(t)){const r=t.map(o=>ur(e,o,n));s=Promise.all(r)}else if(typeof t=="string")s=ur(e,t,n);else{const r=typeof t=="function"?Yt(e,t,n.custom):t;s=Promise.all(za(e,r,n))}return s.then(()=>{e.notify("AnimationComplete",t)})}function Xa(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 ch=zr.length;function Wa(e){if(!e)return;if(!e.isControllingVariants){const n=e.parent?Wa(e.parent)||{}:{};return e.props.initial!==void 0&&(n.initial=e.props.initial),n}const t={};for(let n=0;n<ch;n++){const s=zr[n],r=e.props[s];(Rn(r)||r===!1)&&(t[s]=r)}return t}const uh=[...Ur].reverse(),dh=Ur.length;function hh(e){return t=>Promise.all(t.map(({animation:n,options:s})=>lh(e,n,s)))}function fh(e){let t=hh(e),n=Li(),s=!0;const r=l=>(u,d)=>{const h=Yt(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=Wa(e.parent)||{},h=[],m=new Set;let p={},S=1/0;for(let T=0;T<dh;T++){const b=uh[T],E=n[b],M=u[b]!==void 0?u[b]:d[b],$=Rn(M),D=b===l?E.isActive:null;D===!1&&(S=T);let I=M===d[b]&&M!==u[b]&&$;if(I&&s&&e.manuallyAnimateOnMount&&(I=!1),E.protectedKeys={...p},!E.isActive&&D===null||!M&&!E.prevProp||ys(M)||typeof M=="boolean")continue;const N=mh(E.prevProp,M);let P=N||b===l&&E.isActive&&!I&&$||T>S&&$,O=!1;const A=Array.isArray(M)?M:[M];let k=A.reduce(r(b),{});D===!1&&(k={});const{prevResolvedValues:F={}}=E,V={...F,...k},B=q=>{P=!0,m.has(q)&&(O=!0,m.delete(q)),E.needsAnimating[q]=!0;const ie=e.getValue(q);ie&&(ie.liveStyle=!1)};for(const q in V){const ie=k[q],ye=F[q];if(p.hasOwnProperty(q))continue;let We=!1;lr(ie)&&lr(ye)?We=!Xa(ie,ye):We=ie!==ye,We?ie!=null?B(q):m.add(q):ie!==void 0&&m.has(q)?B(q):E.protectedKeys[q]=!0}E.prevProp=M,E.prevResolvedValues=k,E.isActive&&(p={...p,...k}),s&&e.blockInitialAnimation&&(P=!1);const X=I&&N;P&&(!X||O)&&h.push(...A.map(q=>{const ie={type:b};if(typeof q=="string"&&s&&!X&&e.manuallyAnimateOnMount&&e.parent){const{parent:ye}=e,We=Yt(ye,q);if(ye.enteringChildren&&We){const{delayChildren:bt}=We.transition||{};ie.delay=_a(ye.enteringChildren,e,bt)}}return{animation:q,options:ie}}))}if(m.size){const T={};if(typeof u.initial!="boolean"){const b=Yt(e,Array.isArray(u.initial)?u.initial[0]:u.initial);b&&b.transition&&(T.transition=b.transition)}m.forEach(b=>{const E=e.getBaseTarget(b),M=e.getValue(b);M&&(M.liveStyle=!0),T[b]=E??null}),h.push({animation:T})}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=Li()}}}function mh(e,t){return typeof t=="string"?t!==e:Array.isArray(t)?!Xa(t,e):!1}function Pt(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function Li(){return{animate:Pt(!0),whileInView:Pt(),whileHover:Pt(),whileTap:Pt(),whileDrag:Pt(),whileFocus:Pt(),exit:Pt()}}class xt{constructor(t){this.isMounted=!1,this.node=t}update(){}}class ph extends xt{constructor(t){super(t),t.animationState||(t.animationState=fh(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 gh=0;class yh extends xt{constructor(){super(...arguments),this.id=gh++}update(){if(!this.node.presenceContext)return;const{isPresent:t,onExitComplete:n}=this.node.presenceContext,{isPresent:s}=this.node.prevPresenceContext||{};if(!this.node.animationState||t===s)return;const r=this.node.animationState.setActive("exit",!t);n&&!t&&r.then(()=>{n(this.id)})}mount(){const{register:t,onExitComplete:n}=this.node.presenceContext||{};n&&n(this.id),t&&(this.unmount=t(this.id))}unmount(){}}const Ka={animation:{Feature:ph},exit:{Feature:yh}};function In(e,t,n,s={passive:!0}){return e.addEventListener(t,n,s),()=>e.removeEventListener(t,n)}function Fn(e){return{point:{x:e.pageX,y:e.pageY}}}const xh=e=>t=>$r(t)&&e(t,Fn(t));function Pn(e,t,n,s){return In(e,t,xh(n),s)}const qa=1e-4,bh=1-qa,vh=1+qa,Ga=.01,wh=0-Ga,Sh=0+Ga;function Ae(e){return e.max-e.min}function Th(e,t,n){return Math.abs(e-t)<=n}function $i(e,t,n,s=.5){e.origin=s,e.originPoint=fe(t.min,t.max,e.origin),e.scale=Ae(n)/Ae(t),e.translate=fe(n.min,n.max,e.origin)-e.originPoint,(e.scale>=bh&&e.scale<=vh||isNaN(e.scale))&&(e.scale=1),(e.translate>=wh&&e.translate<=Sh||isNaN(e.translate))&&(e.translate=0)}function An(e,t,n,s){$i(e.x,t.x,n.x,s?s.originX:void 0),$i(e.y,t.y,n.y,s?s.originY:void 0)}function Fi(e,t,n){e.min=n.min+t.min,e.max=e.min+Ae(t)}function Ch(e,t,n){Fi(e.x,t.x,n.x),Fi(e.y,t.y,n.y)}function Bi(e,t,n){e.min=t.min-n.min,e.max=e.min+Ae(t)}function Mn(e,t,n){Bi(e.x,t.x,n.x),Bi(e.y,t.y,n.y)}function Ie(e){return[e("x"),e("y")]}const Ya=({current:e})=>e?e.ownerDocument.defaultView:null,Ui=(e,t)=>Math.abs(e-t);function jh(e,t){const n=Ui(e.x,t.x),s=Ui(e.y,t.y);return Math.sqrt(n**2+s**2)}class Ha{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=Is(this.lastMoveEventInfo,this.history),p=this.startEvent!==null,S=jh(m.offset,{x:0,y:0})>=this.distanceThreshold;if(!p&&!S)return;const{point:v}=m,{timestamp:T}=we;this.history.push({...v,timestamp:T});const{onStart:b,onMove:E}=this.handlers;p||(b&&b(this.lastMoveEvent,m),this.startEvent=this.lastMoveEvent),E&&E(this.lastMoveEvent,m)},this.handlePointerMove=(m,p)=>{this.lastMoveEvent=m,this.lastMoveEventInfo=Vs(p,this.transformPagePoint),le.update(this.updatePoint,!0)},this.handlePointerUp=(m,p)=>{this.end();const{onEnd:S,onSessionEnd:v,resumeAnimation:T}=this.handlers;if(this.dragSnapToOrigin&&T&&T(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const b=Is(m.type==="pointercancel"?this.lastMoveEventInfo:Vs(p,this.transformPagePoint),this.history);this.startEvent&&S&&S(m,b),v&&v(m,b)},!$r(t))return;this.dragSnapToOrigin=o,this.handlers=n,this.transformPagePoint=s,this.distanceThreshold=i,this.contextWindow=r||window;const a=Fn(t),l=Vs(a,this.transformPagePoint),{point:u}=l,{timestamp:d}=we;this.history=[{...u,timestamp:d}];const{onSessionStart:h}=n;h&&h(t,Is(l,this.history)),this.removeListeners=On(Pn(this.contextWindow,"pointermove",this.handlePointerMove),Pn(this.contextWindow,"pointerup",this.handlePointerUp),Pn(this.contextWindow,"pointercancel",this.handlePointerUp))}updateHandlers(t){this.handlers=t}end(){this.removeListeners&&this.removeListeners(),gt(this.updatePoint)}}function Vs(e,t){return t?{point:t(e.point)}:e}function zi(e,t){return{x:e.x-t.x,y:e.y-t.y}}function Is({point:e},t){return{point:e,delta:zi(e,Ja(t)),offset:zi(e,Ph(t)),velocity:Ah(t,.1)}}function Ph(e){return e[0]}function Ja(e){return e[e.length-1]}function Ah(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,s=null;const r=Ja(e);for(;n>=0&&(s=e[n],!(r.timestamp-s.timestamp>Xe(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 Mh(e,{min:t,max:n},s){return t!==void 0&&e<t?e=s?fe(t,e,s.min):Math.max(e,t):n!==void 0&&e>n&&(e=s?fe(n,e,s.max):Math.min(e,n)),e}function _i(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 Eh(e,{top:t,left:n,bottom:s,right:r}){return{x:_i(e.x,n,r),y:_i(e.y,t,s)}}function Xi(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 kh(e,t){return{x:Xi(e.x,t.x),y:Xi(e.y,t.y)}}function Nh(e,t){let n=.5;const s=Ae(e),r=Ae(t);return r>s?n=kn(t.min,t.max-s,e.min):s>r&&(n=kn(e.min,e.max-r,t.min)),ot(0,1,n)}function Dh(e,t){const n={};return t.min!==void 0&&(n.min=t.min-e.min),t.max!==void 0&&(n.max=t.max-e.min),n}const dr=.35;function Rh(e=dr){return e===!1?e=0:e===!0&&(e=dr),{x:Wi(e,"left","right"),y:Wi(e,"top","bottom")}}function Wi(e,t,n){return{min:Ki(e,t),max:Ki(e,n)}}function Ki(e,t){return typeof e=="number"?e:e[t]||0}const Vh=new WeakMap;class Ih{constructor(t){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=pe(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=t}start(t,{snapToCursor:n=!1,distanceThreshold:s}={}){const{presenceContext:r}=this.visualElement;if(r&&r.isPresent===!1)return;const o=h=>{const{dragSnapToOrigin:m}=this.getProps();m?this.pauseAnimation():this.stopAnimation(),n&&this.snapToCursor(Fn(h).point)},i=(h,m)=>{const{drag:p,dragPropagation:S,onDragStart:v}=this.getProps();if(p&&!S&&(this.openDragLock&&this.openDragLock(),this.openDragLock=zu(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 E=this.getAxisMotionValue(b).get()||0;if(et.test(E)){const{projection:M}=this.visualElement;if(M&&M.layout){const $=M.layout.layoutBox[b];$&&(E=Ae($)*(parseFloat(E)/100))}}this.originPoint[b]=E}),v&&le.postRender(()=>v(h,m)),cr(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:v,onDrag:T}=this.getProps();if(!p&&!this.openDragLock)return;const{offset:b}=m;if(S&&this.currentDirection===null){this.currentDirection=Oh(b),this.currentDirection!==null&&v&&v(this.currentDirection);return}this.updateAxis("x",m.point,b),this.updateAxis("y",m.point,b),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=()=>Ie(h=>this.getAnimationState(h)==="paused"&&this.getAxisMotionValue(h).animation?.play()),{dragSnapToOrigin:d}=this.getProps();this.panSession=new Ha(t,{onSessionStart:o,onStart:i,onMove:a,onSessionEnd:l,resumeAnimation:u},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:d,distanceThreshold:s,contextWindow:Ya(this.visualElement)})}stop(t,n){const s=t||this.latestPointerEvent,r=n||this.latestPanInfo,o=this.isDragging;if(this.cancel(),!o||!r||!s)return;const{velocity:i}=r;this.startAnimation(i);const{onDragEnd:a}=this.getProps();a&&le.postRender(()=>a(s,r))}cancel(){this.isDragging=!1;const{projection:t,animationState:n}=this.visualElement;t&&(t.isAnimationBlocked=!1),this.panSession&&this.panSession.end(),this.panSession=void 0;const{dragPropagation:s}=this.getProps();!s&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),n&&n.setActive("whileDrag",!1)}updateAxis(t,n,s){const{drag:r}=this.getProps();if(!s||!es(t,r,this.currentDirection))return;const o=this.getAxisMotionValue(t);let i=this.originPoint[t]+s[t];this.constraints&&this.constraints[t]&&(i=Mh(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&&Xt(t)?this.constraints||(this.constraints=this.resolveRefConstraints()):t&&s?this.constraints=Eh(s.layoutBox,t):this.constraints=!1,this.elastic=Rh(n),r!==this.constraints&&s&&this.constraints&&!this.hasMutatedConstraints&&Ie(o=>{this.constraints!==!1&&this.getAxisMotionValue(o)&&(this.constraints[o]=Dh(s.layoutBox[o],this.constraints[o]))})}resolveRefConstraints(){const{dragConstraints:t,onMeasureDragConstraints:n}=this.getProps();if(!t||!Xt(t))return!1;const s=t.current;at(s!==null,"If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.","drag-constraints-ref");const{projection:r}=this.visualElement;if(!r||!r.layout)return!1;const o=Fd(s,r.root,this.visualElement.getTransformPagePoint());let i=kh(r.layout.layoutBox,o);if(n){const a=n(Od(i));this.hasMutatedConstraints=!!a,a&&(i=Da(a))}return i}startAnimation(t){const{drag:n,dragMomentum:s,dragElastic:r,dragTransition:o,dragSnapToOrigin:i,onDragTransitionEnd:a}=this.getProps(),l=this.constraints||{},u=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 cr(this.visualElement,t),s.start(Yr(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]-fe(i,a,.5))}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:t,dragConstraints:n}=this.getProps(),{projection:s}=this.visualElement;if(!Xt(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]=Nh({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(fe(l,u,r[i]))})}addListeners(){if(!this.visualElement.current)return;Vh.set(this.visualElement,this);const t=this.visualElement.current,n=Pn(t,"pointerdown",l=>{const{drag:u,dragListener:d=!0}=this.getProps();u&&d&&this.start(l)}),s=()=>{const{dragConstraints:l}=this.getProps();Xt(l)&&l.current&&(this.constraints=this.resolveRefConstraints())},{projection:r}=this.visualElement,o=r.addEventListener("measure",s);r&&!r.layout&&(r.root&&r.root.updateScroll(),r.updateLayout()),le.read(s);const i=In(window,"resize",()=>this.scalePositionWithinConstraints()),a=r.addEventListener("didUpdate",({delta:l,hasLayoutChanged:u})=>{this.isDragging&&u&&(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=dr,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 Oh(e,t=10){let n=null;return Math.abs(e.y)>t?n="y":Math.abs(e.x)>t&&(n="x"),n}class Lh extends xt{constructor(t){super(t),this.removeGroupControls=$e,this.removeListeners=$e,this.controls=new Ih(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 qi=e=>(t,n)=>{e&&le.postRender(()=>e(t,n))};class $h extends xt{constructor(){super(...arguments),this.removePointerDownListener=$e}onPointerDown(t){this.session=new Ha(t,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:Ya(this.node)})}createPanHandlers(){const{onPanSessionStart:t,onPanStart:n,onPan:s,onPanEnd:r}=this.node.getProps();return{onSessionStart:qi(t),onStart:qi(n),onMove:s,onEnd:(o,i)=>{delete this.session,r&&le.postRender(()=>r(o,i))}}}mount(){this.removePointerDownListener=Pn(this.node.current,"pointerdown",t=>this.onPointerDown(t))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}const ls={hasAnimatedSinceResize:!0,hasEverUpdated:!1};function Gi(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}const wn={correct:(e,t)=>{if(!t.target)return e;if(typeof e=="string")if(U.test(e))e=parseFloat(e);else return e;const n=Gi(e,t.target.x),s=Gi(e,t.target.y);return`${n}% ${s}%`}},Fh={correct:(e,{treeScale:t,projectionDelta:n})=>{const s=e,r=yt.parse(e);if(r.length>5)return s;const o=yt.createTransformer(e),i=typeof r[0]!="number"?1:0,a=n.x.scale*t.x,l=n.y.scale*t.y;r[0+i]/=a,r[1+i]/=l;const u=fe(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 Os=!1;class Bh extends f.Component{componentDidMount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:s,layoutId:r}=this.props,{projection:o}=t;ud(Uh),o&&(n.group&&n.group.add(o),s&&s.register&&r&&s.register(o),Os&&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,Os=!0,r||t.layoutDependency!==n||n===void 0||t.isPresent!==o?i.willUpdate():this.safeToRemove(),t.isPresent!==o&&(o?i.promote():i.relegate()||le.postRender(()=>{const a=i.getStack();(!a||!a.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:t}=this.props.visualElement;t&&(t.root.didUpdate(),Lr.postRender(()=>{!t.currentAnimation&&t.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:s}=this.props,{projection:r}=t;Os=!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 Za(e){const[t,n]=ba(),s=f.useContext(pr);return c.jsx(Bh,{...e,layoutGroup:s,switchLayoutGroup:f.useContext(ka),isPresent:t,safeToRemove:n})}const Uh={borderRadius:{...wn,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:wn,borderTopRightRadius:wn,borderBottomLeftRadius:wn,borderBottomRightRadius:wn,boxShadow:Fh};function zh(e,t,n){const s=Te(e)?e:Ht(e);return s.start(Yr("",s,t,n)),s.animation}const _h=(e,t)=>e.depth-t.depth;class Xh{constructor(){this.children=[],this.isDirty=!1}add(t){xr(this.children,t),this.isDirty=!0}remove(t){br(this.children,t),this.isDirty=!0}forEach(t){this.isDirty&&this.children.sort(_h),this.isDirty=!1,this.children.forEach(t)}}function Wh(e,t){const n=Ee.now(),s=({timestamp:r})=>{const o=r-n;o>=t&&(gt(s),e(o-t))};return le.setup(s,!0),()=>gt(s)}const Qa=["TopLeft","TopRight","BottomLeft","BottomRight"],Kh=Qa.length,Yi=e=>typeof e=="string"?parseFloat(e):e,Hi=e=>typeof e=="number"||U.test(e);function qh(e,t,n,s,r,o){r?(e.opacity=fe(0,n.opacity??1,Gh(s)),e.opacityExit=fe(t.opacity??1,0,Yh(s))):o&&(e.opacity=fe(t.opacity??1,n.opacity??1,s));for(let i=0;i<Kh;i++){const a=`border${Qa[i]}Radius`;let l=Ji(t,a),u=Ji(n,a);if(l===void 0&&u===void 0)continue;l||(l=0),u||(u=0),l===0||u===0||Hi(l)===Hi(u)?(e[a]=Math.max(fe(Yi(l),Yi(u),s),0),(et.test(u)||et.test(l))&&(e[a]+="%")):e[a]=u}(t.rotate||n.rotate)&&(e.rotate=fe(t.rotate||0,n.rotate||0,s))}function Ji(e,t){return e[t]!==void 0?e[t]:e.borderRadius}const Gh=el(0,.5,Fo),Yh=el(.5,.95,$e);function el(e,t,n){return s=>s<e?0:s>t?1:n(kn(e,t,s))}function Zi(e,t){e.min=t.min,e.max=t.max}function Ve(e,t){Zi(e.x,t.x),Zi(e.y,t.y)}function Qi(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}function eo(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 Hh(e,t=0,n=1,s=.5,r,o=e,i=e){if(et.test(t)&&(t=parseFloat(t),t=fe(i.min,i.max,t/100)-i.min),typeof t!="number")return;let a=fe(o.min,o.max,s);e===o&&(a-=t),e.min=eo(e.min,t,n,a,r),e.max=eo(e.max,t,n,a,r)}function to(e,t,[n,s,r],o,i){Hh(e,t[n],t[s],t[r],t.scale,o,i)}const Jh=["x","scaleX","originX"],Zh=["y","scaleY","originY"];function no(e,t,n,s){to(e.x,t,Jh,n?n.x:void 0,s?s.x:void 0),to(e.y,t,Zh,n?n.y:void 0,s?s.y:void 0)}function so(e){return e.translate===0&&e.scale===1}function tl(e){return so(e.x)&&so(e.y)}function ro(e,t){return e.min===t.min&&e.max===t.max}function Qh(e,t){return ro(e.x,t.x)&&ro(e.y,t.y)}function io(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function nl(e,t){return io(e.x,t.x)&&io(e.y,t.y)}function oo(e){return Ae(e.x)/Ae(e.y)}function ao(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}class ef{constructor(){this.members=[]}add(t){xr(this.members,t),t.scheduleRender()}remove(t){if(br(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 tf(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 Ls=["","X","Y","Z"],nf=1e3;let sf=0;function $s(e,t,n,s){const{latestValues:r}=t;r[e]&&(n[e]=r[e],t.setStaticValue(e,0),s&&(s[e]=0))}function sl(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;const{visualElement:t}=e.options;if(!t)return;const n=Ua(t);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:r,layoutId:o}=e.options;window.MotionCancelOptimisedAnimation(n,"transform",le,!(r||o))}const{parent:s}=e;s&&!s.hasCheckedOptimisedAppear&&sl(s)}function rl({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:s,resetTransform:r}){return class{constructor(i={},a=t?.()){this.id=sf++,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(af),this.nodes.forEach(df),this.nodes.forEach(hf),this.nodes.forEach(lf)},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 Xh)}addEventListener(i,a){return this.eventHandlers.has(i)||this.eventHandlers.set(i,new wr),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=xa(i)&&!Gu(i),this.instance=i;const{layoutId:a,layout:l,visualElement:u}=this.options;if(u&&!u.current&&u.mount(i),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(l||a)&&(this.isLayoutDirty=!0),e){let d,h=0;const m=()=>this.root.updateBlockedByResize=!1;le.read(()=>{h=window.innerWidth}),e(i,()=>{const p=window.innerWidth;p!==h&&(h=p,this.root.updateBlockedByResize=!0,d&&d(),d=Wh(m,250),ls.hasAnimatedSinceResize&&(ls.hasAnimatedSinceResize=!1,this.nodes.forEach(uo)))})}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()||yf,{onLayoutAnimationStart:v,onLayoutAnimationComplete:T}=u.getProps(),b=!this.targetLayout||!nl(this.targetLayout,p),E=!h&&m;if(this.options.layoutRoot||this.resumeFrom||E||h&&(b||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const M={...Ir(S,"layout"),onPlay:v,onComplete:T};(u.shouldReduceMotion||this.options.layoutRoot)&&(M.delay=0,M.type=!1),this.startAnimation(M),this.setAnimationOrigin(d,E)}else h||uo(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=p})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const i=this.getStack();i&&i.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),gt(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(ff),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&&sl(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(lo);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(co);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(uf),this.nodes.forEach(rf),this.nodes.forEach(of)):this.nodes.forEach(co),this.clearAllSnapshots();const a=Ee.now();we.delta=ot(0,1e3/60,a-we.timestamp),we.timestamp=a,we.isProcessing=!0,Ps.update.process(we),Ps.preRender.process(we),Ps.render.process(we),we.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,Lr.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(cf),this.sharedNodes.forEach(mf)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,le.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){le.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!Ae(this.snapshot.measuredBox.x)&&!Ae(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let l=0;l<this.path.length;l++)this.path[l].updateScroll();const i=this.layout;this.layout=this.measure(!1),this.layoutCorrected=pe(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);const{visualElement:a}=this.options;a&&a.notify("LayoutMeasure",this.layout.layoutBox,i?i.layoutBox:void 0)}updateScroll(i="measure"){let a=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===i&&(a=!1),a&&this.instance){const l=s(this.instance);this.scroll={animationId:this.root.animationId,phase:i,isRoot:l,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:l}}}resetTransform(){if(!r)return;const i=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,a=this.projectionDelta&&!tl(this.projectionDelta),l=this.getTransformTemplate(),u=l?l(this.latestValues,""):void 0,d=u!==this.prevTransformTemplateValue;i&&this.instance&&(a||Mt(this.latestValues)||d)&&(r(this.instance,u),this.shouldResetTransform=!1,this.scheduleRender())}measure(i=!0){const a=this.measurePageBox();let l=this.removeElementScroll(a);return i&&(l=this.removeTransform(l)),xf(l),{animationId:this.root.animationId,measuredBox:a,layoutBox:l,latestValues:{},source:this.id}}measurePageBox(){const{visualElement:i}=this.options;if(!i)return pe();const a=i.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(bf))){const{scroll:u}=this.root;u&&(Wt(a.x,u.offset.x),Wt(a.y,u.offset.y))}return a}removeElementScroll(i){const a=pe();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),Wt(a.x,d.offset.x),Wt(a.y,d.offset.y))}return a}applyTransform(i,a=!1){const l=pe();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&&Kt(l,{x:-d.scroll.offset.x,y:-d.scroll.offset.y}),Mt(d.latestValues)&&Kt(l,d.latestValues)}return Mt(this.latestValues)&&Kt(l,this.latestValues),l}removeTransform(i){const a=pe();Ve(a,i);for(let l=0;l<this.path.length;l++){const u=this.path[l];if(!u.instance||!Mt(u.latestValues))continue;ir(u.latestValues)&&u.updateSnapshot();const d=pe(),h=u.measurePageBox();Ve(d,h),no(a,u.latestValues,u.snapshot?u.snapshot.layoutBox:void 0,d)}return Mt(this.latestValues)&&no(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=pe(),this.relativeTargetOrigin=pe(),Mn(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=pe(),this.targetWithTransforms=pe()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),Ch(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):Ve(this.target,this.layout.layoutBox),Va(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=pe(),this.relativeTargetOrigin=pe(),Mn(this.relativeTargetOrigin,this.target,m.target),Ve(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}}}getClosestProjectingParent(){if(!(!this.parent||ir(this.parent.latestValues)||Ra(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;$d(this.layoutCorrected,this.treeScale,this.path,a),i.layout&&!i.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(i.target=i.layout.layoutBox,i.targetWithTransforms=pe());const{target:p}=i;if(!p){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(Qi(this.prevProjectionDelta.x,this.projectionDelta.x),Qi(this.prevProjectionDelta.y,this.projectionDelta.y)),An(this.projectionDelta,this.layoutCorrected,p,this.latestValues),(this.treeScale.x!==h||this.treeScale.y!==m||!ao(this.projectionDelta.x,this.prevProjectionDelta.x)||!ao(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",p))}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(i=!0){if(this.options.visualElement?.scheduleRender(),i){const a=this.getStack();a&&a.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=qt(),this.projectionDelta=qt(),this.projectionDeltaWithTransform=qt()}setAnimationOrigin(i,a=!1){const l=this.snapshot,u=l?l.latestValues:{},d={...this.latestValues},h=qt();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!a;const m=pe(),p=l?l.source:void 0,S=this.layout?this.layout.source:void 0,v=p!==S,T=this.getStack(),b=!T||T.members.length<=1,E=!!(v&&!b&&this.options.crossfade===!0&&!this.path.some(gf));this.animationProgress=0;let M;this.mixTargetDelta=$=>{const D=$/1e3;ho(h.x,i.x,D),ho(h.y,i.y,D),this.setTargetDelta(h),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(Mn(m,this.layout.layoutBox,this.relativeParent.layout.layoutBox),pf(this.relativeTarget,this.relativeTargetOrigin,m,D),M&&Qh(this.relativeTarget,M)&&(this.isProjectionDirty=!1),M||(M=pe()),Ve(M,this.relativeTarget)),v&&(this.animationValues=d,qh(d,u,this.latestValues,D,E,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&&(gt(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=le.update(()=>{ls.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=Ht(0)),this.currentAnimation=zh(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(nf),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&&il(this.options.animationType,this.layout.layoutBox,u.layoutBox)){l=this.target||pe();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}Ve(a,l),Kt(a,d),An(this.projectionDeltaWithTransform,this.layoutCorrected,a,d)}}registerSharedNode(i,a){this.sharedNodes.has(i)||this.sharedNodes.set(i,new ef),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&&$s("z",i,u,this.animationValues);for(let d=0;d<Ls.length;d++)$s(`rotate${Ls[d]}`,i,u,this.animationValues),$s(`skew${Ls[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&&!Mt(this.latestValues)&&(i.transform=l?l({},""):"none",this.hasProjected=!1);return}i.visibility="";const d=u.animationValues||u.latestValues;this.applyTransformsToTarget();let h=tf(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 Vn){if(d[S]===void 0)continue;const{correct:v,applyTo:T,isCSSVariable:b}=Vn[S],E=h==="none"?d[S]:v(d[S],u);if(T){const M=T.length;for(let $=0;$<M;$++)i[T[$]]=E}else b?this.options.visualElement.renderState.vars[S]=E:i[S]=E}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(lo),this.root.sharedNodes.clear()}}}function rf(e){e.updateLayout()}function of(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=Ae(h);h.min=n[d].min,h.max=h.min+m}):il(r,t.layoutBox,n)&&Ie(d=>{const h=o?t.measuredBox[d]:t.layoutBox[d],m=Ae(n[d]);h.max=h.min+m,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[d].max=e.relativeTarget[d].min+m)});const i=qt();An(i,n,t.layoutBox);const a=qt();o?An(a,e.applyTransform(s,!0),t.measuredBox):An(a,n,t.layoutBox);const l=!tl(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=pe();Mn(p,t.layoutBox,h.layoutBox);const S=pe();Mn(S,n,m.layoutBox),nl(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 af(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 lf(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function cf(e){e.clearSnapshot()}function lo(e){e.clearMeasurements()}function co(e){e.isLayoutDirty=!1}function uf(e){const{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify("BeforeLayoutMeasure"),e.resetTransform()}function uo(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function df(e){e.resolveTargetDelta()}function hf(e){e.calcProjection()}function ff(e){e.resetSkewAndRotation()}function mf(e){e.removeLeadSnapshot()}function ho(e,t,n){e.translate=fe(t.translate,0,n),e.scale=fe(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function fo(e,t,n,s){e.min=fe(t.min,n.min,s),e.max=fe(t.max,n.max,s)}function pf(e,t,n,s){fo(e.x,t.x,n.x,s),fo(e.y,t.y,n.y,s)}function gf(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}const yf={duration:.45,ease:[.4,0,.1,1]},mo=e=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),po=mo("applewebkit/")&&!mo("chrome/")?Math.round:$e;function go(e){e.min=po(e.min),e.max=po(e.max)}function xf(e){go(e.x),go(e.y)}function il(e,t,n){return e==="position"||e==="preserve-aspect"&&!Th(oo(t),oo(n),.2)}function bf(e){return e!==e.root&&e.scroll?.wasRoot}const vf=rl({attachResizeListener:(e,t)=>In(e,"resize",t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0}),Fs={current:void 0},ol=rl({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!Fs.current){const e=new vf({});e.mount(window),e.setOptions({layoutScroll:!0}),Fs.current=e}return Fs.current},resetTransform:(e,t)=>{e.style.transform=t!==void 0?t:"none"},checkIsScrollRoot:e=>window.getComputedStyle(e).position==="fixed"}),wf={pan:{Feature:$h},drag:{Feature:Lh,ProjectionNode:ol,MeasureLayout:Za}};function yo(e,t,n){const{props:s}=e;e.animationState&&s.whileHover&&e.animationState.setActive("whileHover",n==="Start");const r="onHover"+n,o=s[r];o&&le.postRender(()=>o(t,Fn(t)))}class Sf extends xt{mount(){const{current:t}=this.node;t&&(this.unmount=_u(t,(n,s)=>(yo(this.node,s,"Start"),r=>yo(this.node,r,"End"))))}unmount(){}}class Tf extends xt{constructor(){super(...arguments),this.isActive=!1}onFocus(){let t=!1;try{t=this.node.current.matches(":focus-visible")}catch{t=!0}!t||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=On(In(this.node.current,"focus",()=>this.onFocus()),In(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function xo(e,t,n){const{props:s}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&s.whileTap&&e.animationState.setActive("whileTap",n==="Start");const r="onTap"+(n==="End"?"":n),o=s[r];o&&le.postRender(()=>o(t,Fn(t)))}class Cf extends xt{mount(){const{current:t}=this.node;t&&(this.unmount=qu(t,(n,s)=>(xo(this.node,s,"Start"),(r,{success:o})=>xo(this.node,r,o?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}const hr=new WeakMap,Bs=new WeakMap,jf=e=>{const t=hr.get(e.target);t&&t(e)},Pf=e=>{e.forEach(jf)};function Af({root:e,...t}){const n=e||document;Bs.has(n)||Bs.set(n,{});const s=Bs.get(n),r=JSON.stringify(t);return s[r]||(s[r]=new IntersectionObserver(Pf,{root:e,...t})),s[r]}function Mf(e,t,n){const s=Af(t);return hr.set(e,n),s.observe(e),()=>{hr.delete(e),s.unobserve(e)}}const Ef={some:0,all:1};class kf extends xt{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:t={}}=this.node.getProps(),{root:n,margin:s,amount:r="some",once:o}=t,i={root:n?n.current:void 0,rootMargin:s,threshold:typeof r=="number"?r:Ef[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 Mf(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(Nf(t,n))&&this.startObserver()}unmount(){}}function Nf({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}const al={inView:{Feature:kf},tap:{Feature:Cf},focus:{Feature:Tf},hover:{Feature:Sf}},Df={layout:{ProjectionNode:ol,MeasureLayout:Za}},Rf={...Ka,...al,...wf,...Df},Vf=Id(Rf,Ba),If={renderer:Ba,...Ka,...al};function Hr(e,t){return as(e,t)}const Of=Hr("button"),ts=Hr("div"),Lf=Hr("p");function $f({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(ee.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(ee.X,{className:"h-3 w-3"})})]})]})})}function Ff({toolName:e,args:t,isDenied:n,isSafe:s}){const[r,o]=f.useState(!1);if(e==="fetchDocContent")return null;const i=["k","maxResults","_organizationId"];e==="searchDocs"&&i.push("filters");const a=Object.fromEntries(Object.entries(t).filter(([u])=>!i.includes(u))),l=Object.keys(a).length>0;return c.jsxs("div",{className:"my-1",children:[c.jsxs("button",{onClick:()=>l&&o(!r),className:`inline-flex items-center gap-1.5 text-xs rounded-md px-2 py-1 transition-colors bg-muted text-muted-foreground ${l?"cursor-pointer hover:bg-muted/80":""}`,children:[l&&c.jsx("span",{className:"transition-transform duration-200",children:r?c.jsx(ee.ChevronDown,{className:"h-3 w-3"}):c.jsx(ee.ChevronRight,{className:"h-3 w-3"})}),n?c.jsx(ee.X,{className:"h-3 w-3"}):s?c.jsx(ee.Zap,{className:"h-3 w-3"}):c.jsx(ee.Check,{className:"h-3 w-3"}),c.jsxs("span",{className:"font-medium",children:[n?"Denied":s?"Auto-executed":"Executed"," ",e]})]}),r&&l&&c.jsx("div",{className:"mt-1 ml-6 p-2 bg-stone-50 dark:bg-stone-900 rounded-md border border-border",children:c.jsx("div",{className:"space-y-0.5",children:Object.entries(a).map(([u,d])=>c.jsxs("div",{className:"flex items-start gap-1.5 text-xs",children:[c.jsxs("span",{className:"text-muted-foreground min-w-[60px]",children:[u,":"]}),c.jsx("span",{className:"font-mono text-foreground",children:typeof d=="string"?d:JSON.stringify(d)})]},u))})})]})}function Bf({...e}){return c.jsx(fr.Root,{"data-slot":"collapsible",...e})}function Uf({...e}){return c.jsx(fr.CollapsibleTrigger,{"data-slot":"collapsible-trigger",...e})}function zf({...e}){return c.jsx(fr.CollapsibleContent,{"data-slot":"collapsible-content",...e})}const _f=f.lazy(()=>import("streamdown").then(e=>({default:e.Streamdown}))),Jr=f.memo(({className:e,...t})=>typeof window>"u"?null:c.jsx(f.Suspense,{fallback:null,children:c.jsx(_f,{className:ne("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",e),...t})}),(e,t)=>e.children===t.children);Jr.displayName="Response";const Xf=Object.freeze(Object.defineProperty({__proto__:null,Response:Jr},Symbol.toStringTag,{value:"Module"})),Wf=({children:e,as:t="p",className:n,duration:s=2,spread:r=2})=>{const o=Vf.create(t),i=f.useMemo(()=>(e?.length??0)*r,[e,r]);return c.jsx(o,{animate:{backgroundPosition:"0% center"},className:ne("relative inline-block bg-[length:250%_100%,auto] bg-clip-text text-transparent","[--bg:linear-gradient(90deg,#0000_calc(50%-var(--spread)),var(--color-background),#0000_calc(50%+var(--spread)))] [background-repeat:no-repeat,padding-box]",n),initial:{backgroundPosition:"100% center"},style:{"--spread":`${i}px`,backgroundImage:"var(--bg), linear-gradient(var(--color-muted-foreground), var(--color-muted-foreground))"},transition:{repeat:Number.POSITIVE_INFINITY,duration:s,ease:"linear"},children:e})},Kf=f.memo(Wf),ll=f.createContext(null),qf=()=>{const e=f.useContext(ll);if(!e)throw new Error("Reasoning components must be used within Reasoning");return e},Gf=1e3,Yf=1e3,cl=f.memo(({className:e,isStreaming:t=!1,open:n,defaultOpen:s=!0,onOpenChange:r,duration:o,children:i,...a})=>{const[l,u]=ti.useControllableState({prop:n,defaultProp:s,onChange:r}),[d,h]=ti.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)/Yf)),v(null))},[t,S,h]),f.useEffect(()=>{if(s&&!t&&l&&!m){const b=setTimeout(()=>{u(!1),p(!0)},Gf);return()=>clearTimeout(b)}},[t,l,s,u,m]);const T=b=>{u(b)};return c.jsx(ll.Provider,{value:{isStreaming:t,isOpen:l,setIsOpen:u,duration:d},children:c.jsx(Bf,{className:ne("not-prose mb-4",e),onOpenChange:T,open:l,...a,children:i})})}),Hf=(e,t)=>e||t===0?c.jsx(Kf,{duration:1,children:"Thinking..."}):t===void 0?c.jsx("p",{children:"Thought for a few seconds"}):c.jsxs("p",{children:["Thought for ",t," seconds"]}),ul=f.memo(({className:e,children:t,...n})=>{const{isStreaming:s,isOpen:r,duration:o}=qf();return c.jsx(Uf,{className:ne("flex w-full items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground",e),...n,children:t??c.jsxs(c.Fragment,{children:[c.jsx(ee.BrainIcon,{className:"size-4"}),Hf(s,o),c.jsx(ee.ChevronDownIcon,{className:ne("size-4 transition-transform",r?"rotate-180":"rotate-0")})]})})}),dl=f.memo(({className:e,children:t,...n})=>c.jsx(zf,{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(Jr,{className:"grid gap-2",children:t})}));cl.displayName="Reasoning";ul.displayName="ReasoningTrigger";dl.displayName="ReasoningContent";function bo(e){return`https://www.google.com/s2/favicons?domain=${encodeURIComponent(e)}&sz=16`}function Jf({sources:e,citationNumber:t,className:n}){const s=e.find(o=>o.number===t);if(!s)return null;const r=bo(s.domain);return c.jsxs(ht,{children:[c.jsx(ft,{asChild:!0,children:c.jsxs("button",{className:ne("inline-flex items-center gap-1 px-1 py-0.5 rounded text-[10px] font-medium","bg-stone-200/60 dark:bg-stone-700/60 text-stone-800 dark:text-stone-200","hover:bg-stone-300/80 dark:hover:bg-stone-600/80","transition-all duration-200","border border-stone-300/60 dark:border-stone-600/60","cursor-pointer hover:scale-105 active:scale-95","leading-tight",n),onClick:o=>{o.preventDefault(),o.stopPropagation(),window.open(s.url,"_blank","noopener,noreferrer")},children:[c.jsx("img",{src:r,alt:"",className:"w-3 h-3 leading-none",onError:o=>{const i=o.target;i.style.display="none"}}),c.jsx("span",{className:"leading-none",children:s.domain})]})}),c.jsx(mt,{side:"top",className:"bg-stone-800 dark:bg-stone-900 border border-stone-700 dark:border-stone-600 p-3 max-w-sm z-50 rounded-lg shadow-lg",children:c.jsxs("div",{className:"space-y-1.5",children:[c.jsxs("div",{className:"text-xs font-semibold text-stone-300 dark:text-stone-200 mb-2 pb-2 border-b border-stone-700 dark:border-stone-600",children:["Sources • ",e.length]}),e.map(o=>{const i=o.title||o.domain;return c.jsxs("a",{href:o.url,target:"_blank",rel:"noopener noreferrer",className:ne("flex items-center gap-2 p-2 rounded-md hover:bg-stone-700/50 dark:hover:bg-stone-700/50 transition-colors","text-stone-300 dark:text-stone-300 hover:text-white dark:hover:text-white"),onClick:a=>a.stopPropagation(),children:[c.jsx("img",{src:bo(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 Zf({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 b,E=!1;const M=new WeakSet,$=()=>{if(!u.current||E)return;E=!0;const I=u.current,N=/\[(\d+)\]/g,P=document.createTreeWalker(I,NodeFilter.SHOW_TEXT,null),O=[];let A;for(;A=P.nextNode();)if(A.nodeType===Node.TEXT_NODE&&!M.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 q=Array.from(V.matchAll(N)).filter(ie=>{if(!ie[1])return!1;const ye=parseInt(ie[1],10);return n.has(ye)});q.length>0&&O.push({node:F,matches:q})}}if(O.length===0){E=!1;return}const k=[];O.forEach(({node:F,matches:V})=>{M.add(F);const B=F.textContent||"",X=document.createDocumentFragment();let Y=0;V.forEach(q=>{if(!q[1])return;q.index!==void 0&&q.index>Y&&X.appendChild(document.createTextNode(B.slice(Y,q.index)));const ie=document.createElement("span");ie.className="inline-flex items-center citation-button-container";const ye=parseInt(q[1],10);ie.setAttribute("data-citation",q[1]),X.appendChild(ie),k.push({element:ie,citationNum:ye}),Y=(q.index||0)+q[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]}),E=!1},D=new MutationObserver(()=>{clearTimeout(b),b=setTimeout($,100)});return D.observe(T,{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(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 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((T,b)=>{const E=T.title||T.baseUrl,M=S(T.url),$=p(M);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:E})]},`group-${b}`)}):Array.from(n.entries()).sort(([T],[b])=>T-b).map(([T,b])=>{const E=S(b),M=p(E);return c.jsxs("a",{href:b,target:"_blank",rel:"noopener noreferrer",className:ne("inline-flex items-center gap-1.5 px-2.5 py-1.5 rounded-md text-xs font-medium","bg-stone-100 dark:bg-stone-800 text-stone-700 dark:text-stone-300","hover:bg-stone-200 dark:hover:bg-stone-700","transition-all duration-200","border border-stone-200 dark:border-stone-700","cursor-pointer hover:scale-105 active:scale-95","no-underline"),children:[c.jsx("img",{src:M,alt:"",className:"w-3.5 h-3.5 shrink-0",onError:$=>{const D=$.target;D.style.display="none"}}),c.jsx("span",{className:"leading-none",children:b})]},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:b},E)=>{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(P=>P.url.replace(/\/+$/,"")===I);return[I,{number:D.number,url:D.url,domain:S(D.url),title:N?.title}]})).values());return El.createPortal(c.jsx(Jf,{sources:$,citationNumber:b},`citation-${b}-${T}`),T,`citation-${b}-${E}`)}),v]})}function nn({...e}){return c.jsx(Rt.Root,{"data-slot":"dialog",...e})}function Qf({...e}){return c.jsx(Rt.Portal,{"data-slot":"dialog-portal",...e})}function em({className:e,...t}){return c.jsx(Rt.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 sn({className:e,children:t,showCloseButton:n=!0,...s}){return c.jsxs(Qf,{"data-slot":"dialog-portal",children:[c.jsx(em,{}),c.jsxs(Rt.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(Rt.Close,{"data-slot":"dialog-close",className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[c.jsx(ee.XIcon,{}),c.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function rn({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 on({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 an({className:e,...t}){return c.jsx(Rt.Title,{"data-slot":"dialog-title",className:ne("text-lg leading-none font-semibold",e),...t})}function ln({className:e,...t}){return c.jsx(Rt.Description,{"data-slot":"dialog-description",className:ne("text-muted-foreground text-sm",e),...t})}function cn({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 tm({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(nn,{open:e,children:c.jsx(sn,{showCloseButton:!1,children:c.jsxs("form",{onSubmit:h,children:[c.jsxs(rn,{children:[c.jsx(an,{children:t}),c.jsx(ln,{children:n})]}),c.jsx("div",{className:"py-4",children:c.jsxs("div",{className:"relative",children:[c.jsx(cn,{type:a?"text":"password",value:o,onChange:p=>i(p.target.value),placeholder:s,className:"pr-10",autoFocus:!0,disabled:u}),c.jsx("button",{type:"button",onClick:()=>l(!a),className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600",disabled:u,children:a?c.jsx(ee.EyeOff,{className:"h-4 w-4"}):c.jsx(ee.Eye,{className:"h-4 w-4"})})]})}),c.jsxs(on,{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 nm({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(nn,{open:e,children:c.jsx(sn,{showCloseButton:!1,children:c.jsxs("form",{onSubmit:p,children:[c.jsxs(rn,{children:[c.jsxs(an,{className:"flex items-center gap-2",children:[c.jsx(ee.Mail,{className:"h-5 w-5"}),t]}),c.jsx(ln,{children:n})]}),c.jsxs("div",{className:"py-4",children:[c.jsx(cn,{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(on,{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 sm({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 b=T.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=T=>T.replace(/\D/g,"").length===10,p=T=>{const b=h(T);i(b),b.trim()?l(m(b)):l(!0)},S=async T=>{if(T.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(nn,{open:e,children:c.jsx(sn,{showCloseButton:!1,children:c.jsxs("form",{onSubmit:S,children:[c.jsxs(rn,{children:[c.jsxs(an,{className:"flex items-center gap-2",children:[c.jsx(ee.Phone,{className:"h-5 w-5"}),t]}),c.jsx(ln,{children:n})]}),c.jsxs("div",{className:"py-4",children:[c.jsx(cn,{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(on,{children:[c.jsx(Ce,{type:"button",variant:"ghost",onClick:v,disabled:u,children:"Cancel"}),c.jsx(Ce,{type:"submit",disabled:!o.trim()||!a||u,children:u?"Submitting...":"Submit"})]})]})})})}function rm({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(nn,{open:e,children:c.jsx(sn,{showCloseButton:!1,children:c.jsxs("form",{onSubmit:h,children:[c.jsxs(rn,{children:[c.jsxs(an,{className:"flex items-center gap-2",children:[c.jsx(ee.Shield,{className:"h-5 w-5"}),t]}),c.jsx(ln,{children:n})]}),c.jsxs("div",{className:"py-4",children:[c.jsx(cn,{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(on,{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 Us({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(nn,{open:e,children:c.jsx(sn,{showCloseButton:!1,children:c.jsxs("form",{onSubmit:d,children:[c.jsxs(rn,{children:[c.jsxs(an,{className:"flex items-center gap-2",children:[c.jsx(ee.Lock,{className:"h-5 w-5"}),t]}),c.jsx(ln,{children:n})]}),c.jsx("div",{className:"py-4",children:c.jsx(cn,{type:r,value:i,onChange:m=>a(m.target.value),placeholder:s,autoFocus:!0,disabled:l})}),c.jsxs(on,{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 im({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",T=A=>A.replace(/\D/g,"").length===10?null:"Please enter a valid 10-digit phone number",b=(A,k=4)=>A.length===k?null:`PIN must be ${k} digits`,E=A=>{const k=A.replace(/\D/g,"");return k.length<=3?k:k.length<=6?`(${k.slice(0,3)}) ${k.slice(3)}`:`(${k.slice(0,3)}) ${k.slice(3,6)}-${k.slice(6,10)}`},M=(A,k,F)=>{let V=k,B=null;switch(F.type){case"phone":V=E(k),V.trim()&&(B=T(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=T(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]}))},P=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(nn,{open:e,children:c.jsx(sn,{showCloseButton:!1,className:"max-w-md",children:c.jsxs("form",{onSubmit:D,children:[c.jsxs(rn,{children:[c.jsx(an,{children:t}),n&&c.jsx(ln,{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(cn,{type:P(A),value:a[A.name]||"",onChange:k=>M(A.name,k.target.value,A),placeholder:O(A),className:u[A.name]?"border-red-500":"",disabled:p,autoFocus:A===s[0],maxLength:A.type==="pin"?6:A.type==="phone"?14:void 0}),A.type==="password"&&c.jsx("button",{type:"button",onClick:()=>N(A.name),className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600",disabled:p,children:h[A.name]?c.jsx(ee.EyeOff,{className:"h-4 w-4"}):c.jsx(ee.Eye,{className:"h-4 w-4"})})]}),u[A.name]&&c.jsxs("div",{className:"flex items-center gap-1 mt-1 text-sm text-red-500",children:[c.jsx(ee.AlertCircle,{className:"h-3 w-3"}),u[A.name]]})]},A.name))}),c.jsxs(on,{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 hl=f.createContext(void 0);function fl(){const e=f.useContext(hl);if(!e)throw new Error("useSecureModal must be used within a SecureModalProvider");return e}function ml({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(im,{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(tm,{...p});case"email":return c.jsx(nm,{...p});case"phone":return c.jsx(sm,{...p});case"pin":return c.jsx(rm,{...p});case"ssn":return c.jsx(Us,{...p,title:t.title||"SSN Required",placeholder:t.placeholder||"XXX-XX-XXXX"});case"creditCard":return c.jsx(Us,{...p,title:t.title||"Credit Card Required",placeholder:t.placeholder||"XXXX XXXX XXXX XXXX",type:"text"});case"text":default:return c.jsx(Us,{...p})}},m=f.useMemo(()=>({showSecureModal:a,showSecureForm:l}),[a,l]);return c.jsxs(hl.Provider,{value:m,children:[e,h()]})}function om(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 am(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 vo(e){let t=e.replace(/_+$/gm,"");const n=/(?:^|\n)(?:#+\s*)?(?:References|References:)(?:\*\*)?\s*\n?([\s\S]*?)(?=\n\n|\n#|$)/i,s=t.match(n),r=new Map,o=[],i=new Map,a=new Map,l=new Map,u=new Map;if(s&&s[1]){const P=s[1],O=/\[(\d+)\]\s*(https?:\/\/[^\s\)]+)/g;let A;for(;(A=O.exec(P))!==null;)if(A[1]&&A[2]){const k=parseInt(A[1],10),F=A[2].replace(/[.,;:!?]+$/,""),V=F.replace(/\/+$/,"");if(a.has(V)||a.set(V,F),i.has(V)||i.set(V,[]),i.get(V).push(k),!l.has(V))l.set(V,k);else{const B=l.get(V);k<B&&l.set(V,k)}}for(const[k,F]of i.entries()){const V=l.get(k);for(const B of F)B!==V&&u.set(B,V)}for(const[k,F]of l.entries()){const V=a.get(k)||k;r.set(F,V),o.push({number:F,url:V})}}let d,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 T=m.map(P=>{if(P.type==="code")return P.content;let O=P.content;return O=O.replace(/\[(\d+)\]\((https?:\/\/[^\)]+)\)/g,(k,F,V)=>{const B=parseInt(F,10),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[P,O]of l.entries()){const A=a.get(P)||P,{baseUrl:k,anchor:F}=om(A),V=am(A);b.push({url:A,baseUrl:k,numbers:[O],anchor:F,title:V})}b.sort((P,O)=>(P.numbers[0]||0)-(O.numbers[0]||0));const E=new Map;let M=1;for(const P of b){const O=P.numbers[0];E.set(O,M),P.numbers=[M],M++}const $=new Map;for(const[P,O]of r.entries()){const A=E.get(P);A&&$.set(A,O)}const D=o.map(P=>{const O=E.get(P.number);return O?{number:O,url:P.url}:P}).filter(P=>E.has(P.number)),I=Array.from(E.entries()).sort((P,O)=>O[0]-P[0]);let N=T.join("");for(const[P,O]of I){const A=new RegExp(`\\[${P}\\](?!\\d)`,"g");N=N.replace(A,`[${O}]`)}return{processedText:N,citations:D.sort((P,O)=>P.number-O.number),citationMap:$,groupedCitations:b,referencesText:d}}function En(e){if(typeof e=="string")try{const t=JSON.parse(e);return En(t)}catch{return e}if(Array.isArray(e))return e.map(En);if(e&&typeof e=="object"){const t={};for(const[n,s]of Object.entries(e))t[n]=En(s);return t}return e}function zs(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 lm({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:T,tokenEndpoint:b="/api/arcten/token",apiBaseUrl:E="https://api.arcten.com",user:M,state:$,onStateChange:D,allowStateEdits:I=!0,sources:N,ragConfig:P,showCitations:O=!0,sensitiveParams:A,autoDetectSensitive:k=!1}){const F=E.replace(/\/+$/,""),{showSecureModal:V}=fl(),B=Po({apiBaseUrl:F,tokenEndpoint:b,user:M,tools:d,safeTools:h,toolMetadata:p,sensitiveParams:A,autoDetectSensitive:k,agentId:v,agentName:T,state:$,onStateChange:D,allowStateEdits:I,sources:N,ragConfig:P});f.useMemo(()=>P!==void 0?P:N&&N.length>0?{enabled:!0,organizationId:N[0],autoExecute:!0,filters:void 0}:{enabled:!1},[N,P]);const[X,Y]=f.useState(u),[q,ie]=f.useState(i),[ye,We]=f.useState(600),[bt,tt]=f.useState(!1),[G,Vt]=f.useState(!1),[Me,vt]=f.useState(!1),[je,Fe]=f.useState({x:100,y:100}),[un,oe]=f.useState(!1),[dn,wt]=f.useState({x:0,y:0}),[hn,Bn]=f.useState(!1),Be=f.useRef(null),St=f.useRef(null),[Tt,ke]=f.useState(""),[fn,bs]=f.useState(null),[It,mn]=f.useState("Thinking..."),[Ot,nt]=f.useState(new Set),[vs,Un]=f.useState(""),[st,zn]=f.useState([]),_n=f.useRef(new Map),Lt=f.useRef(!1),ce=f.useRef(""),[$t,ct]=f.useState(!1),[xe,pn]=f.useState(!1),Ke=f.useMemo(()=>[...d,...h],[d,h]),Re=f.useMemo(()=>mr(Ke,p),[Ke,p]),gn=f.useMemo(()=>{const C=new Map,_=new Map(Re.map(z=>[z.name,z]));return Ke.forEach(z=>{const Z=z[Oe];if(Z){const J=_.get(Z);if(J){C.set(J.name,z);return}}const H=Re.find(J=>J.name===z.name);H&&C.set(H.name,z)}),C},[Ke,Re]),qe=f.useMemo(()=>{const C=new Set,_=new Map(Re.map(z=>[z.name,z]));return h.forEach(z=>{const Z=z[Oe];if(Z&&_.has(Z))C.add(Z);else{const H=Re.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,Re,m]),Ct=["Thinking...","Pondering...","Contemplating...","Considering...","Analyzing...","Processing...","Reasoning...","Mulling it over...","Computing...","Cooking up a response...","Brewing ideas...","Connecting the dots...","Piecing it together...","Spinning up thoughts...","Loading brain cells...","Sharpening pencils...","Herding ideas...","Warming up neurons...","Stirring the think-pot...","Plotting a plan...","Wiggling the logic wires...","Rolling ideas around...","Charging the brainstorm...","Booting the brain...","Dusting off the cortex...","Running mental diagnostics...","Fetching cleverness...","Whisking up notions...","Tuning the idea radio...","Juggling possibilities...","Breathing in inspiration...","Squeezing the thought sponge...","Tickling the gray matter...","Bubbling up insights...","Spicing the soup of thought...","Lacing up hypotheses...","Winding the idea clock...","Casting the net for clues...","Polishing the crystal ball...","Mapping the maze...","Crunching the brain-biscuits...","Cueing the eureka moment...","Summoning the muse...","Knocking on insight’s door...","Combing the noodle...","Sailing the think-ship...","Scooping brain gelato...","Testing wild hunches...","Tick-tocking the neurons...","Planting idea seeds...","Shaking the thought snow globe...","Unlocking the mental toolbox...","Nudging the puzzle pieces...","Lighting the idea bulb...","Preheating the oven of insight...","Mixing the mental trail mix...","Spooling up reasoning reels...","Skimming the mind-palace index...","Surfing the thought waves...","Kicking the tires on ideas...","Rattling the idea can...","Waving the logic wand..."];f.useEffect(()=>{if(typeof window<"u"){const 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&&Vt(JSON.parse(Z));const H=localStorage.getItem("arcten-sidebar-position");if(H){const De=JSON.parse(H),se=50,ue=Math.max(se-i,Math.min(De.x,window.innerWidth-se)),W=Math.max(0,Math.min(De.y,window.innerHeight-se));Fe({x:ue,y:W})}const J=localStorage.getItem("arcten-sidebar-minimized");J&&vt(JSON.parse(J)),Bn(!0)}},[]),f.useMemo(()=>M,[M?.id]),f.useEffect(()=>{(async()=>{if(Ke.length===0)return;const _=Ke.map(z=>`${z.name}:${z.toString()}`).join("|");if(_!==ce.current&&!Lt.current){Lt.current=!0,ce.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=>{_n.current.set(J.name,J)}),zn(H.tools)}}catch(z){console.error("Failed to fetch tool descriptions:",z)}finally{Lt.current=!1}}})()},[Ke,F]),f.useEffect(()=>{Promise.resolve().then(()=>Xf).then(C=>{bs(()=>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:Xn,messages:Pe,sendMessage:ut,status:Ne,error:Wn,stop:Ft,addToolOutput:rt,setMessages:Kn,clientToken:qn,tokenError:Ge,conversations:Ye,isLoadingConversations:yn,loadConversation:Ue,deleteConversation:He,startNewConversation:Gn}=B;f.useEffect(()=>{X&&St.current&&St.current.focus()},[X,Pe]),f.useEffect(()=>{const C=Pe[Pe.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(qe.has(H)){if(Ot.has(J))continue;nt(se=>se.has(J)?se:new Set(se).add(J)),(async()=>{try{const se=gn.get(H);if(!se){console.warn(`[ArctenAgent] Tool ${H} not found in toolsMap`),rt({toolCallId:J,tool:H,output:`Error: Tool ${H} not found`}),nt(te=>{const Se=new Set(te);return Se.delete(J),Se});return}const ue=zs(Z.input),W=Re.find(te=>te.name===H);let me;if(W&&W.jsonSchema?.properties){const Se=Object.keys(W.jsonSchema.properties).map(de=>ue[de]);me=await se(...Se)}else me=await se(...Object.values(ue));rt({toolCallId:J,tool:H,output:me}),nt(te=>{const Se=new Set(te);return Se.delete(J),Se})}catch(se){console.error(`[ArctenAgent] Error executing safe tool ${H}:`,se),rt({toolCallId:J,tool:H,output:`Error: ${se instanceof Error?se.message:String(se)}`}),nt(ue=>{const W=new Set(ue);return W.delete(J),W})}})()}}},[Pe,qe,gn,Re,rt,Ot]);function Yn(){Y(!0),localStorage.setItem("arcten-sidebar-expanded","true")}function it(){Y(!1),localStorage.setItem("arcten-sidebar-expanded","false")}f.useEffect(()=>{},[X]),f.useEffect(()=>{Be.current&&Be.current.scrollIntoView({behavior:"smooth"})},[Pe]),f.useEffect(()=>{function C(_){_.key==="Escape"&&(Ne==="streaming"||Ne==="submitted")&&(_.preventDefault(),Ft())}return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[Ne,Ft]);function jt(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 Hn(){Gn(),pn(!1)}function xn(C){if(C.preventDefault(),!Tt.trim())return;(Ne==="streaming"||Ne==="submitted")&&Ft();const _=Ct[Math.floor(Math.random()*Ct.length)]||"Thinking...";mn(_),ut({text:Tt}),ke("")}function dt(C){const _=C.target.value;ke(_)}f.useEffect(()=>{if(!bt)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 _(){tt(!1),localStorage.setItem("arcten-sidebar-width",q.toString()),localStorage.setItem("arcten-sidebar-height",ye.toString())}return window.addEventListener("mousemove",C),window.addEventListener("mouseup",_),()=>{window.removeEventListener("mousemove",C),window.removeEventListener("mouseup",_)}},[bt,q,ye,G,je,a,l]);function Bt(C){C.preventDefault(),tt(!0)}function ws(){Vt(!0),vt(!1),localStorage.setItem("arcten-sidebar-detached","true"),localStorage.setItem("arcten-sidebar-minimized","false")}function Ut(){Vt(!1),vt(!1),localStorage.setItem("arcten-sidebar-detached","false"),localStorage.setItem("arcten-sidebar-minimized","false")}function bn(){vt(!Me),localStorage.setItem("arcten-sidebar-minimized",JSON.stringify(!Me))}function Je(C){G&&(oe(!0),wt({x:C.clientX-je.x,y:C.clientY-je.y}))}return f.useEffect(()=>{if(!G)return;function C(){Fe(_=>{const Z=window.innerWidth-50,H=window.innerHeight-50,J=50-q,De=0,se=Math.max(J,Math.min(_.x,Z)),ue=Math.max(De,Math.min(_.y,H));if(se!==_.x||ue!==_.y){const W={x:se,y:ue};return localStorage.setItem("arcten-sidebar-position",JSON.stringify(W)),W}return _})}return window.addEventListener("resize",C),()=>window.removeEventListener("resize",C)},[G,q]),f.useEffect(()=>{if(!un)return;function C(z){const Z=z.clientX-dn.x,H=z.clientY-dn.y,J=50,De=window.innerWidth-J,se=window.innerHeight-J,ue=J-q,W=0,me=Math.max(ue,Math.min(Z,De)),te=Math.max(W,Math.min(H,se));Fe({x:me,y:te})}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",_)}},[un,dn,je,q]),hn?Ge?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: ",Ge]})}):qn?c.jsx(rd,{features:If,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:`
10
+ `),()=>{T.contains(v)&&T.removeChild(v)}},[t]),c.jsx(Qu,{isPresent:t,childRef:o,sizeRef:i,children:_e.cloneElement(e,{ref:l})})}const td=({children:e,initial:t,isPresent:n,onExitComplete:s,custom:r,presenceAffectsLayout:o,mode:i,anchorX:a,root:l})=>{const u=gr(nd),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(ed,{isPresent:n,anchorX:a,root:l,children:e})),c.jsx(ps.Provider,{value:m,children:e})};function nd(){return new Map}function ba(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 ji(e){const t=[];return f.Children.forEach(e,n=>{f.isValidElement(n)&&t.push(n)}),t}const sd=({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]=ba(i),h=f.useMemo(()=>ji(e),[e]),m=i&&!u?[]:h.map(Qn),p=f.useRef(!0),S=f.useRef(h),v=gr(()=>new Map),[T,b]=f.useState(h),[M,E]=f.useState(h);Eo(()=>{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!==T){let I=[...h];for(let N=0;N<M.length;N++){const P=M[N],O=Qn(P);m.includes(O)||(I.splice(N,0,P),$.push(P))}return o==="wait"&&$.length&&(I=$),E(ji(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(pr);return c.jsx(c.Fragment,{children:M.map(I=>{const N=Qn(I),P=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(td,{isPresent:P,initial:!p.current||n?void 0:!1,custom:t,presenceAffectsLayout:r,mode:o,root:l,onExitComplete:P?void 0:O,anchorX:a,children:I},N)})})},Br=f.createContext({strict:!1}),Pi={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"]},Jt={};for(const e in Pi)Jt[e]={isEnabled:t=>Pi[e].some(n=>!!t[n])};function rr(e){for(const t in e)Jt[t]={...Jt[t],...e[t]}}function rd({children:e,features:t,strict:n=!1}){const[,s]=f.useState(!Ds(t)),r=f.useRef(void 0);if(!Ds(t)){const{renderer:o,...i}=t;r.current=o,rr(i)}return f.useEffect(()=>{Ds(t)&&t().then(({renderer:o,...i})=>{rr(i),r.current=o,s(!0)})},[]),c.jsx(Br.Provider,{value:{renderer:r.current,strict:n},children:e})}function Ds(e){return typeof e=="function"}const id=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")||id.has(e)}let va=e=>!hs(e);function od(e){typeof e=="function"&&(va=t=>t.startsWith("on")?!hs(t):e(t))}try{od(require("@emotion/is-prop-valid").default)}catch{}function ad(e,t,n){const s={};for(const r in e)r==="values"&&typeof e.values=="object"||(va(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 Rn(e){return typeof e=="string"||Array.isArray(e)}const Ur=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],zr=["initial",...Ur];function xs(e){return ys(e.animate)||zr.some(t=>Rn(e[t]))}function wa(e){return!!(xs(e)||e.variants)}function ld(e,t){if(xs(e)){const{initial:n,animate:s}=e;return{initial:n===!1||Rn(n)?n:void 0,animate:Rn(s)?s:void 0}}return e.inherit!==!1?t:{}}function cd(e){const{initial:t,animate:n}=ld(e,f.useContext(gs));return f.useMemo(()=>({initial:t,animate:n}),[Ai(t),Ai(n)])}function Ai(e){return Array.isArray(e)?e.join(" "):e}const Vn={};function ud(e){for(const t in e)Vn[t]=e[t],jr(t)&&(Vn[t].isCSSVariable=!0)}function Sa(e,{layout:t,layoutId:n}){return tn.has(e)||e.startsWith("origin")||(t||n!==void 0)&&(!!Vn[e]||e==="opacity")}const dd={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},hd=en.length;function fd(e,t,n){let s="",r=!0;for(let o=0;o<hd;o++){const i=en[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=fa(a,Or[i]);if(!l){r=!1;const d=dd[i]||i;s+=`${d}(${u}) `}n&&(t[i]=u)}}return s=s.trim(),n?s=n(t,r?"":s):r&&(s="none"),s}function _r(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(tn.has(l)){i=!0;continue}else if(jr(l)){r[l]=u;continue}else{const d=fa(u,Or[l]);l.startsWith("origin")?(a=!0,o[l]=d):s[l]=d}}if(t.transform||(i||n?s.transform=fd(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 Xr=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function Ta(e,t,n){for(const s in t)!Te(t[s])&&!Sa(s,n)&&(e[s]=t[s])}function md({transformTemplate:e},t){return f.useMemo(()=>{const n=Xr();return _r(n,t,e),Object.assign({},n.vars,n.style)},[t])}function pd(e,t){const n=e.style||{},s={};return Ta(s,n,e),Object.assign(s,md(e,t)),s}function gd(e,t){const n={},s=pd(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 yd={offset:"stroke-dashoffset",array:"stroke-dasharray"},xd={offset:"strokeDashoffset",array:"strokeDasharray"};function bd(e,t,n=1,s=0,r=!0){e.pathLength=1;const o=r?yd:xd;e[o.offset]=U.transform(-s);const i=U.transform(t),a=U.transform(n);e[o.array]=`${i} ${a}`}function Ca(e,{attrX:t,attrY:n,attrScale:s,pathLength:r,pathSpacing:o=1,pathOffset:i=0,...a},l,u,d){if(_r(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&&bd(h,r,o,i,!1)}const ja=()=>({...Xr(),attrs:{}}),Pa=e=>typeof e=="string"&&e.toLowerCase()==="svg";function vd(e,t,n,s){const r=f.useMemo(()=>{const o=ja();return Ca(o,t,Pa(s),e.transformTemplate,e.style),{...o.attrs,style:{...o.style}}},[t]);if(e.style){const o={};Ta(o,e.style,e),r.style={...o,...r.style}}return r}const wd=["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 Wr(e){return typeof e!="string"||e.includes("-")?!1:!!(wd.indexOf(e)>-1||/[A-Z]/u.test(e))}function Sd(e,t,n,{latestValues:s},r,o=!1){const a=(Wr(e)?vd:gd)(t,s,r,e),l=ad(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 Ei(e){const t=[{},{}];return e?.values.forEach((n,s)=>{t[0][s]=n.get(),t[1][s]=n.getVelocity()}),t}function Kr(e,t,n,s){if(typeof t=="function"){const[r,o]=Ei(s);t=t(n!==void 0?n:e.custom,r,o)}if(typeof t=="string"&&(t=e.variants&&e.variants[t]),typeof t=="function"){const[r,o]=Ei(s);t=t(n!==void 0?n:e.custom,r,o)}return t}function os(e){return Te(e)?e.get():e}function Td({scrapeMotionValuesFromProps:e,createRenderState:t},n,s,r){return{latestValues:Cd(n,s,r,e),renderState:t()}}function Cd(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=wa(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:T,...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 Aa=e=>(t,n)=>{const s=f.useContext(gs),r=f.useContext(ps),o=()=>Td(e,t,s,r);return n?o():gr(o)};function qr(e,t,n){const{style:s}=e,r={};for(const o in s)(Te(s[o])||t.style&&Te(t.style[o])||Sa(o,e)||n?.getValue(o)?.liveStyle!==void 0)&&(r[o]=s[o]);return r}const jd=Aa({scrapeMotionValuesFromProps:qr,createRenderState:Xr});function Ea(e,t,n){const s=qr(e,t,n);for(const r in e)if(Te(e[r])||Te(t[r])){const o=en.indexOf(r)!==-1?"attr"+r.charAt(0).toUpperCase()+r.substring(1):r;s[o]=e[r]}return s}const Pd=Aa({scrapeMotionValuesFromProps:Ea,createRenderState:ja}),Ad=Symbol.for("motionComponentSymbol");function Xt(e){return e&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"current")}function Ed(e,t,n){return f.useCallback(s=>{s&&e.onMount&&e.onMount(s),t&&(s?t.mount(s):t.unmount()),n&&(typeof n=="function"?n(s):Xt(n)&&(n.current=s))},[t])}const Gr=e=>e.replace(/([a-z])([A-Z])/gu,"$1-$2").toLowerCase(),Md="framerAppearId",Ma="data-"+Gr(Md),ka=f.createContext({});function kd(e,t,n,s,r){const{visualElement:o}=f.useContext(gs),i=f.useContext(Br),a=f.useContext(ps),l=f.useContext(Fr).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(ka);d&&!d.projection&&r&&(d.type==="html"||d.type==="svg")&&Nd(u.current,n,r,h);const m=f.useRef(!1);f.useInsertionEffect(()=>{d&&m.current&&d.update(n,a)});const p=n[Ma],S=f.useRef(!!p&&!window.MotionHandoffIsComplete?.(p)&&window.MotionHasOptimisedAnimation?.(p));return Eo(()=>{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 Nd(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:Na(e.parent)),e.projection.setOptions({layoutId:r,layout:o,alwaysMeasureLayout:!!i||a&&Xt(a),visualElement:e,animationType:typeof o=="string"?o:"both",initialPromotionConfig:s,crossfade:d,layoutScroll:l,layoutRoot:u})}function Na(e){if(e)return e.options.allowProjection!==!1?e.projection:Na(e.parent)}function as(e,{forwardMotionProps:t=!1}={},n,s){n&&rr(n);const r=Wr(e)?Pd:jd;function o(a,l){let u;const d={...f.useContext(Fr),...a,layoutId:Dd(a)},{isStatic:h}=d,m=cd(a),p=r(a,h);if(!h&&yr){Rd(d,n);const S=Vd(d);u=S.MeasureLayout,m.visualElement=kd(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,Sd(e,a,Ed(p,m.visualElement,l),p,h,t)]})}o.displayName=`motion.${typeof e=="string"?e:`create(${e.displayName??e.name??""})`}`;const i=f.forwardRef(o);return i[Ad]=e,i}function Dd({layoutId:e}){const t=f.useContext(pr).id;return t&&e!==void 0?t+"-"+e:e}function Rd(e,t){const n=f.useContext(Br).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?Zt(!1,s,"lazy-strict-mode"):at(!1,s,"lazy-strict-mode")}}function Vd(e){const{drag:t,layout:n}=Jt;if(!t&&!n)return{};const s={...t,...n};return{MeasureLayout:t?.isEnabled(e)||n?.isEnabled(e)?s.MeasureLayout:void 0,ProjectionNode:s.ProjectionNode}}function Id(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"&&Sr(!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 Da({top:e,left:t,right:n,bottom:s}){return{x:{min:t,max:n},y:{min:e,max:s}}}function Od({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function Ld(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 Rs(e){return e===void 0||e===1}function ir({scale:e,scaleX:t,scaleY:n}){return!Rs(e)||!Rs(t)||!Rs(n)}function Et(e){return ir(e)||Ra(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function Ra(e){return Mi(e.x)||Mi(e.y)}function Mi(e){return e&&e!=="0%"}function fs(e,t,n){const s=e-n,r=t*s;return n+r}function ki(e,t,n,s,r){return r!==void 0&&(e=fs(e,r,s)),fs(e,n,s)+t}function or(e,t=0,n=1,s,r){e.min=ki(e.min,t,n,s,r),e.max=ki(e.max,t,n,s,r)}function Va(e,{x:t,y:n}){or(e.x,t.translate,t.scale,t.originPoint),or(e.y,n.translate,n.scale,n.originPoint)}const Ni=.999999999999,Di=1.0000000000001;function $d(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&&Kt(e,{x:-o.scroll.offset.x,y:-o.scroll.offset.y}),i&&(t.x*=i.x.scale,t.y*=i.y.scale,Va(e,i)),s&&Et(o.latestValues)&&Kt(e,o.latestValues))}t.x<Di&&t.x>Ni&&(t.x=1),t.y<Di&&t.y>Ni&&(t.y=1)}function Wt(e,t){e.min=e.min+t,e.max=e.max+t}function Ri(e,t,n,s,r=.5){const o=fe(e.min,e.max,r);or(e,t,n,o,s)}function Kt(e,t){Ri(e.x,t.x,t.scaleX,t.scale,t.originX),Ri(e.y,t.y,t.scaleY,t.scale,t.originY)}function Ia(e,t){return Da(Ld(e.getBoundingClientRect(),t))}function Fd(e,t,n){const s=Ia(e,n),{scroll:r}=t;return r&&(Wt(s.x,r.offset.x),Wt(s.y,r.offset.y)),s}const Vi=()=>({translate:0,scale:1,origin:0,originPoint:0}),qt=()=>({x:Vi(),y:Vi()}),Ii=()=>({min:0,max:0}),pe=()=>({x:Ii(),y:Ii()}),ar={current:null},Oa={current:!1};function Bd(){if(Oa.current=!0,!!yr)if(window.matchMedia){const e=window.matchMedia("(prefers-reduced-motion)"),t=()=>ar.current=e.matches;e.addEventListener("change",t),t()}else ar.current=!1}const Ud=new WeakMap;function zd(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,Ht(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,Ht(i!==void 0?i:r,{owner:e}))}}for(const s in n)t[s]===void 0&&e.removeValue(s);return t}const Oi=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];class _d{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=Vr,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,le.render(this.render,!1,!0))};const{latestValues:l,renderState:u}=i;this.latestValues=l,this.baseTarget={...l},this.initialValues=n.initial?{...l}:{},this.renderState=u,this.parent=t,this.props=n,this.presenceContext=s,this.depth=t?t.depth+1:0,this.reducedMotionConfig=r,this.options=a,this.blockInitialAnimation=!!o,this.isControllingVariants=xs(n),this.isVariantNode=wa(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,Ud.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)),Oa.current||Bd(),this.shouldReduceMotion=this.reducedMotionConfig==="never"?!1:this.reducedMotionConfig==="always"?!0:ar.current,process.env.NODE_ENV!=="production"&&Sr(this.shouldReduceMotion!==!0,"You have Reduced Motion enabled on your device. Animations may not appear as expected.","reduced-motion-disabled"),this.parent?.addChild(this),this.update(this.props,this.presenceContext)}unmount(){this.projection&&this.projection.unmount(),gt(this.notifyUpdate),gt(this.render),this.valueSubscriptions.forEach(t=>t()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent?.removeChild(this);for(const t in this.events)this.events[t].clear();for(const t in this.features){const n=this.features[t];n&&(n.unmount(),n.isMounted=!1)}this.current=null}addChild(t){this.children.add(t),this.enteringChildren??(this.enteringChildren=new Set),this.enteringChildren.add(t)}removeChild(t){this.children.delete(t),this.enteringChildren&&this.enteringChildren.delete(t)}bindToMotionValue(t,n){this.valueSubscriptions.has(t)&&this.valueSubscriptions.get(t)();const s=tn.has(t);s&&this.onBindTransform&&this.onBindTransform();const r=n.on("change",i=>{this.latestValues[t]=i,this.props.onUpdate&&le.preRender(this.notifyUpdate),s&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});let o;window.MotionCheckAppearSync&&(o=window.MotionCheckAppearSync(this,t,n)),this.valueSubscriptions.set(t,()=>{r(),o&&o(),n.owner&&n.stop()})}sortNodePosition(t){return!this.current||!this.sortInstanceNodePosition||this.type!==t.type?0:this.sortInstanceNodePosition(this.current,t.current)}updateFeatures(){let t="animation";for(t in Jt){const n=Jt[t];if(!n)continue;const{isEnabled:s,Feature:r}=n;if(!this.features[t]&&r&&s(this.props)&&(this.features[t]=new r(this)),this.features[t]){const o=this.features[t];o.isMounted?o.update():(o.mount(),o.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):pe()}getStaticValue(t){return this.latestValues[t]}setStaticValue(t,n){this.latestValues[t]=n}update(t,n){(t.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=t,this.prevPresenceContext=this.presenceContext,this.presenceContext=n;for(let s=0;s<Oi.length;s++){const r=Oi[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=zd(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=Ht(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"&&(Mo(s)||No(s))?s=parseFloat(s):!Hu(s)&&yt.test(n)&&(s=ha(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=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&&!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 wr),this.events[t].add(n)}notify(t,...n){this.events[t]&&this.events[t].notify(...n)}scheduleRenderMicrotask(){Lr.render(this.render)}}class La extends _d{constructor(){super(...arguments),this.KeyframeResolver=$u}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 $a(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 Xd(e){return window.getComputedStyle(e)}class Wd extends La{constructor(){super(...arguments),this.type="html",this.renderInstance=$a}readValueFromInstance(t,n){if(tn.has(n))return this.projection?.isProjecting?Js(n):nu(t,n);{const s=Xd(t),r=(jr(n)?s.getPropertyValue(n):s[n])||0;return typeof r=="string"?r.trim():r}}measureInstanceViewportBox(t,{transformPagePoint:n}){return Ia(t,n)}build(t,n,s){_r(t,n,s.transformTemplate)}scrapeMotionValuesFromProps(t,n,s){return qr(t,n,s)}}const Fa=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues","viewBox","gradientTransform","pathLength","startOffset","textLength","lengthAdjust"]);function Kd(e,t,n,s){$a(e,t,void 0,s);for(const r in t.attrs)e.setAttribute(Fa.has(r)?r:Gr(r),t.attrs[r])}class qd extends La{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=pe}getBaseTargetFromProps(t,n){return t[n]}readValueFromInstance(t,n){if(tn.has(n)){const s=da(n);return s&&s.default||0}return n=Fa.has(n)?n:Gr(n),t.getAttribute(n)}scrapeMotionValuesFromProps(t,n,s){return Ea(t,n,s)}build(t,n,s){Ca(t,n,this.isSVGTag,s.transformTemplate,s.style)}renderInstance(t,n,s,r){Kd(t,n,s,r)}mount(t){this.isSVGTag=Pa(t.tagName),super.mount(t)}}const Ba=(e,t)=>Wr(e)?new qd(t):new Wd(t,{allowProjection:e!==f.Fragment});function Yt(e,t,n){const s=e.getProps();return Kr(s,t,n!==void 0?n:s.custom,e)}const lr=e=>Array.isArray(e);function Gd(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,Ht(n))}function Yd(e){return lr(e)?e[e.length-1]||0:e}function Hd(e,t){const n=Yt(e,t);let{transitionEnd:s={},transition:r={},...o}=n||{};o={...o,...s};for(const i in o){const a=Yd(o[i]);Gd(e,i,a)}}function Jd(e){return!!(Te(e)&&e.add)}function cr(e,t){const n=e.getValue("willChange");if(Jd(n))return n.add(t);if(!n&&lt.WillChange){const s=new lt.WillChange("auto");e.addValue("willChange",s),s.add(t)}}function Ua(e){return e.props[Ma]}const Zd=e=>e!==null;function Qd(e,{repeat:t,repeatType:n="loop"},s){const r=e.filter(Zd),o=t&&n!=="loop"&&t%2===1?0:r.length-1;return r[o]}const eh={type:"spring",stiffness:500,damping:25,restSpeed:10},th=e=>({type:"spring",stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),nh={type:"keyframes",duration:.8},sh={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},rh=(e,{keyframes:t})=>t.length>2?nh:tn.has(e)?e.startsWith("scale")?th(t[1]):eh:sh;function ih({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 Yr=(e,t,n,s={},r,o)=>i=>{const a=Ir(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};ih(a)||Object.assign(d,rh(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)&&(nr(d),d.delay===0&&(h=!0)),(lt.instantAnimations||lt.skipAnimations)&&(h=!0,nr(d),d.delay=0),d.allowFlatten=!a.type&&!a.ease,h&&!o&&t.get()!==void 0){const m=Qd(d.keyframes,a);if(m!==void 0){le.update(()=>{d.onUpdate(m),d.onComplete()});return}}return a.isSync?new Rr(d):new ju(d)};function oh({protectedKeys:e,needsAnimating:t},n){const s=e.hasOwnProperty(n)&&t[n]!==!0;return t[n]=!1,s}function za(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&&oh(u,d))continue;const p={delay:n,...Ir(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=Ua(e);if(b){const M=window.MotionHandoffAnimation(b,d,le);M!==null&&(p.startTime=M,v=!0)}}cr(e,d),h.start(Yr(d,h,m,e.shouldReduceMotion&&la.has(d)?{type:!1}:p,e,v));const T=h.animation;T&&l.push(T)}return i&&Promise.all(l).then(()=>{le.update(()=>{i&&Hd(e,i)})}),l}function _a(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 ur(e,t,n={}){const s=Yt(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(za(e,s,n)):()=>Promise.resolve(),i=e.variantChildren&&e.variantChildren.size?(l=0)=>{const{delayChildren:u=0,staggerChildren:d,staggerDirection:h}=r;return ah(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 ah(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(ur(l,t,{...i,delay:n+(typeof s=="function"?0:s)+_a(e.variantChildren,l,s,r,o)}).then(()=>l.notify("AnimationComplete",t)));return Promise.all(a)}function lh(e,t,n={}){e.notify("AnimationStart",t);let s;if(Array.isArray(t)){const r=t.map(o=>ur(e,o,n));s=Promise.all(r)}else if(typeof t=="string")s=ur(e,t,n);else{const r=typeof t=="function"?Yt(e,t,n.custom):t;s=Promise.all(za(e,r,n))}return s.then(()=>{e.notify("AnimationComplete",t)})}function Xa(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 ch=zr.length;function Wa(e){if(!e)return;if(!e.isControllingVariants){const n=e.parent?Wa(e.parent)||{}:{};return e.props.initial!==void 0&&(n.initial=e.props.initial),n}const t={};for(let n=0;n<ch;n++){const s=zr[n],r=e.props[s];(Rn(r)||r===!1)&&(t[s]=r)}return t}const uh=[...Ur].reverse(),dh=Ur.length;function hh(e){return t=>Promise.all(t.map(({animation:n,options:s})=>lh(e,n,s)))}function fh(e){let t=hh(e),n=Li(),s=!0;const r=l=>(u,d)=>{const h=Yt(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=Wa(e.parent)||{},h=[],m=new Set;let p={},S=1/0;for(let T=0;T<dh;T++){const b=uh[T],M=n[b],E=u[b]!==void 0?u[b]:d[b],$=Rn(E),D=b===l?M.isActive:null;D===!1&&(S=T);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=mh(M.prevProp,E);let P=N||b===l&&M.isActive&&!I&&$||T>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=q=>{P=!0,m.has(q)&&(O=!0,m.delete(q)),M.needsAnimating[q]=!0;const ie=e.getValue(q);ie&&(ie.liveStyle=!1)};for(const q in V){const ie=k[q],ye=F[q];if(p.hasOwnProperty(q))continue;let We=!1;lr(ie)&&lr(ye)?We=!Xa(ie,ye):We=ie!==ye,We?ie!=null?B(q):m.add(q):ie!==void 0&&m.has(q)?B(q):M.protectedKeys[q]=!0}M.prevProp=E,M.prevResolvedValues=k,M.isActive&&(p={...p,...k}),s&&e.blockInitialAnimation&&(P=!1);const X=I&&N;P&&(!X||O)&&h.push(...A.map(q=>{const ie={type:b};if(typeof q=="string"&&s&&!X&&e.manuallyAnimateOnMount&&e.parent){const{parent:ye}=e,We=Yt(ye,q);if(ye.enteringChildren&&We){const{delayChildren:bt}=We.transition||{};ie.delay=_a(ye.enteringChildren,e,bt)}}return{animation:q,options:ie}}))}if(m.size){const T={};if(typeof u.initial!="boolean"){const b=Yt(e,Array.isArray(u.initial)?u.initial[0]:u.initial);b&&b.transition&&(T.transition=b.transition)}m.forEach(b=>{const M=e.getBaseTarget(b),E=e.getValue(b);E&&(E.liveStyle=!0),T[b]=M??null}),h.push({animation:T})}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=Li()}}}function mh(e,t){return typeof t=="string"?t!==e:Array.isArray(t)?!Xa(t,e):!1}function Pt(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function Li(){return{animate:Pt(!0),whileInView:Pt(),whileHover:Pt(),whileTap:Pt(),whileDrag:Pt(),whileFocus:Pt(),exit:Pt()}}class xt{constructor(t){this.isMounted=!1,this.node=t}update(){}}class ph extends xt{constructor(t){super(t),t.animationState||(t.animationState=fh(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 gh=0;class yh extends xt{constructor(){super(...arguments),this.id=gh++}update(){if(!this.node.presenceContext)return;const{isPresent:t,onExitComplete:n}=this.node.presenceContext,{isPresent:s}=this.node.prevPresenceContext||{};if(!this.node.animationState||t===s)return;const r=this.node.animationState.setActive("exit",!t);n&&!t&&r.then(()=>{n(this.id)})}mount(){const{register:t,onExitComplete:n}=this.node.presenceContext||{};n&&n(this.id),t&&(this.unmount=t(this.id))}unmount(){}}const Ka={animation:{Feature:ph},exit:{Feature:yh}};function In(e,t,n,s={passive:!0}){return e.addEventListener(t,n,s),()=>e.removeEventListener(t,n)}function Fn(e){return{point:{x:e.pageX,y:e.pageY}}}const xh=e=>t=>$r(t)&&e(t,Fn(t));function Pn(e,t,n,s){return In(e,t,xh(n),s)}const qa=1e-4,bh=1-qa,vh=1+qa,Ga=.01,wh=0-Ga,Sh=0+Ga;function Ae(e){return e.max-e.min}function Th(e,t,n){return Math.abs(e-t)<=n}function $i(e,t,n,s=.5){e.origin=s,e.originPoint=fe(t.min,t.max,e.origin),e.scale=Ae(n)/Ae(t),e.translate=fe(n.min,n.max,e.origin)-e.originPoint,(e.scale>=bh&&e.scale<=vh||isNaN(e.scale))&&(e.scale=1),(e.translate>=wh&&e.translate<=Sh||isNaN(e.translate))&&(e.translate=0)}function An(e,t,n,s){$i(e.x,t.x,n.x,s?s.originX:void 0),$i(e.y,t.y,n.y,s?s.originY:void 0)}function Fi(e,t,n){e.min=n.min+t.min,e.max=e.min+Ae(t)}function Ch(e,t,n){Fi(e.x,t.x,n.x),Fi(e.y,t.y,n.y)}function Bi(e,t,n){e.min=t.min-n.min,e.max=e.min+Ae(t)}function En(e,t,n){Bi(e.x,t.x,n.x),Bi(e.y,t.y,n.y)}function Ie(e){return[e("x"),e("y")]}const Ya=({current:e})=>e?e.ownerDocument.defaultView:null,Ui=(e,t)=>Math.abs(e-t);function jh(e,t){const n=Ui(e.x,t.x),s=Ui(e.y,t.y);return Math.sqrt(n**2+s**2)}class Ha{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=Is(this.lastMoveEventInfo,this.history),p=this.startEvent!==null,S=jh(m.offset,{x:0,y:0})>=this.distanceThreshold;if(!p&&!S)return;const{point:v}=m,{timestamp:T}=we;this.history.push({...v,timestamp:T});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=Vs(p,this.transformPagePoint),le.update(this.updatePoint,!0)},this.handlePointerUp=(m,p)=>{this.end();const{onEnd:S,onSessionEnd:v,resumeAnimation:T}=this.handlers;if(this.dragSnapToOrigin&&T&&T(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const b=Is(m.type==="pointercancel"?this.lastMoveEventInfo:Vs(p,this.transformPagePoint),this.history);this.startEvent&&S&&S(m,b),v&&v(m,b)},!$r(t))return;this.dragSnapToOrigin=o,this.handlers=n,this.transformPagePoint=s,this.distanceThreshold=i,this.contextWindow=r||window;const a=Fn(t),l=Vs(a,this.transformPagePoint),{point:u}=l,{timestamp:d}=we;this.history=[{...u,timestamp:d}];const{onSessionStart:h}=n;h&&h(t,Is(l,this.history)),this.removeListeners=On(Pn(this.contextWindow,"pointermove",this.handlePointerMove),Pn(this.contextWindow,"pointerup",this.handlePointerUp),Pn(this.contextWindow,"pointercancel",this.handlePointerUp))}updateHandlers(t){this.handlers=t}end(){this.removeListeners&&this.removeListeners(),gt(this.updatePoint)}}function Vs(e,t){return t?{point:t(e.point)}:e}function zi(e,t){return{x:e.x-t.x,y:e.y-t.y}}function Is({point:e},t){return{point:e,delta:zi(e,Ja(t)),offset:zi(e,Ph(t)),velocity:Ah(t,.1)}}function Ph(e){return e[0]}function Ja(e){return e[e.length-1]}function Ah(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,s=null;const r=Ja(e);for(;n>=0&&(s=e[n],!(r.timestamp-s.timestamp>Xe(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 Eh(e,{min:t,max:n},s){return t!==void 0&&e<t?e=s?fe(t,e,s.min):Math.max(e,t):n!==void 0&&e>n&&(e=s?fe(n,e,s.max):Math.min(e,n)),e}function _i(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 Mh(e,{top:t,left:n,bottom:s,right:r}){return{x:_i(e.x,n,r),y:_i(e.y,t,s)}}function Xi(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 kh(e,t){return{x:Xi(e.x,t.x),y:Xi(e.y,t.y)}}function Nh(e,t){let n=.5;const s=Ae(e),r=Ae(t);return r>s?n=kn(t.min,t.max-s,e.min):s>r&&(n=kn(e.min,e.max-r,t.min)),ot(0,1,n)}function Dh(e,t){const n={};return t.min!==void 0&&(n.min=t.min-e.min),t.max!==void 0&&(n.max=t.max-e.min),n}const dr=.35;function Rh(e=dr){return e===!1?e=0:e===!0&&(e=dr),{x:Wi(e,"left","right"),y:Wi(e,"top","bottom")}}function Wi(e,t,n){return{min:Ki(e,t),max:Ki(e,n)}}function Ki(e,t){return typeof e=="number"?e:e[t]||0}const Vh=new WeakMap;class Ih{constructor(t){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=pe(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=t}start(t,{snapToCursor:n=!1,distanceThreshold:s}={}){const{presenceContext:r}=this.visualElement;if(r&&r.isPresent===!1)return;const o=h=>{const{dragSnapToOrigin:m}=this.getProps();m?this.pauseAnimation():this.stopAnimation(),n&&this.snapToCursor(Fn(h).point)},i=(h,m)=>{const{drag:p,dragPropagation:S,onDragStart:v}=this.getProps();if(p&&!S&&(this.openDragLock&&this.openDragLock(),this.openDragLock=zu(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(et.test(M)){const{projection:E}=this.visualElement;if(E&&E.layout){const $=E.layout.layoutBox[b];$&&(M=Ae($)*(parseFloat(M)/100))}}this.originPoint[b]=M}),v&&le.postRender(()=>v(h,m)),cr(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:v,onDrag:T}=this.getProps();if(!p&&!this.openDragLock)return;const{offset:b}=m;if(S&&this.currentDirection===null){this.currentDirection=Oh(b),this.currentDirection!==null&&v&&v(this.currentDirection);return}this.updateAxis("x",m.point,b),this.updateAxis("y",m.point,b),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=()=>Ie(h=>this.getAnimationState(h)==="paused"&&this.getAxisMotionValue(h).animation?.play()),{dragSnapToOrigin:d}=this.getProps();this.panSession=new Ha(t,{onSessionStart:o,onStart:i,onMove:a,onSessionEnd:l,resumeAnimation:u},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:d,distanceThreshold:s,contextWindow:Ya(this.visualElement)})}stop(t,n){const s=t||this.latestPointerEvent,r=n||this.latestPanInfo,o=this.isDragging;if(this.cancel(),!o||!r||!s)return;const{velocity:i}=r;this.startAnimation(i);const{onDragEnd:a}=this.getProps();a&&le.postRender(()=>a(s,r))}cancel(){this.isDragging=!1;const{projection:t,animationState:n}=this.visualElement;t&&(t.isAnimationBlocked=!1),this.panSession&&this.panSession.end(),this.panSession=void 0;const{dragPropagation:s}=this.getProps();!s&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),n&&n.setActive("whileDrag",!1)}updateAxis(t,n,s){const{drag:r}=this.getProps();if(!s||!es(t,r,this.currentDirection))return;const o=this.getAxisMotionValue(t);let i=this.originPoint[t]+s[t];this.constraints&&this.constraints[t]&&(i=Eh(i,this.constraints[t],this.elastic[t])),o.set(i)}resolveConstraints(){const{dragConstraints:t,dragElastic:n}=this.getProps(),s=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,r=this.constraints;t&&Xt(t)?this.constraints||(this.constraints=this.resolveRefConstraints()):t&&s?this.constraints=Mh(s.layoutBox,t):this.constraints=!1,this.elastic=Rh(n),r!==this.constraints&&s&&this.constraints&&!this.hasMutatedConstraints&&Ie(o=>{this.constraints!==!1&&this.getAxisMotionValue(o)&&(this.constraints[o]=Dh(s.layoutBox[o],this.constraints[o]))})}resolveRefConstraints(){const{dragConstraints:t,onMeasureDragConstraints:n}=this.getProps();if(!t||!Xt(t))return!1;const s=t.current;at(s!==null,"If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.","drag-constraints-ref");const{projection:r}=this.visualElement;if(!r||!r.layout)return!1;const o=Fd(s,r.root,this.visualElement.getTransformPagePoint());let i=kh(r.layout.layoutBox,o);if(n){const a=n(Od(i));this.hasMutatedConstraints=!!a,a&&(i=Da(a))}return i}startAnimation(t){const{drag:n,dragMomentum:s,dragElastic:r,dragTransition:o,dragSnapToOrigin:i,onDragTransitionEnd:a}=this.getProps(),l=this.constraints||{},u=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 cr(this.visualElement,t),s.start(Yr(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]-fe(i,a,.5))}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:t,dragConstraints:n}=this.getProps(),{projection:s}=this.visualElement;if(!Xt(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]=Nh({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(fe(l,u,r[i]))})}addListeners(){if(!this.visualElement.current)return;Vh.set(this.visualElement,this);const t=this.visualElement.current,n=Pn(t,"pointerdown",l=>{const{drag:u,dragListener:d=!0}=this.getProps();u&&d&&this.start(l)}),s=()=>{const{dragConstraints:l}=this.getProps();Xt(l)&&l.current&&(this.constraints=this.resolveRefConstraints())},{projection:r}=this.visualElement,o=r.addEventListener("measure",s);r&&!r.layout&&(r.root&&r.root.updateScroll(),r.updateLayout()),le.read(s);const i=In(window,"resize",()=>this.scalePositionWithinConstraints()),a=r.addEventListener("didUpdate",({delta:l,hasLayoutChanged:u})=>{this.isDragging&&u&&(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=dr,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 Oh(e,t=10){let n=null;return Math.abs(e.y)>t?n="y":Math.abs(e.x)>t&&(n="x"),n}class Lh extends xt{constructor(t){super(t),this.removeGroupControls=$e,this.removeListeners=$e,this.controls=new Ih(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 qi=e=>(t,n)=>{e&&le.postRender(()=>e(t,n))};class $h extends xt{constructor(){super(...arguments),this.removePointerDownListener=$e}onPointerDown(t){this.session=new Ha(t,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:Ya(this.node)})}createPanHandlers(){const{onPanSessionStart:t,onPanStart:n,onPan:s,onPanEnd:r}=this.node.getProps();return{onSessionStart:qi(t),onStart:qi(n),onMove:s,onEnd:(o,i)=>{delete this.session,r&&le.postRender(()=>r(o,i))}}}mount(){this.removePointerDownListener=Pn(this.node.current,"pointerdown",t=>this.onPointerDown(t))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}const ls={hasAnimatedSinceResize:!0,hasEverUpdated:!1};function Gi(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}const wn={correct:(e,t)=>{if(!t.target)return e;if(typeof e=="string")if(U.test(e))e=parseFloat(e);else return e;const n=Gi(e,t.target.x),s=Gi(e,t.target.y);return`${n}% ${s}%`}},Fh={correct:(e,{treeScale:t,projectionDelta:n})=>{const s=e,r=yt.parse(e);if(r.length>5)return s;const o=yt.createTransformer(e),i=typeof r[0]!="number"?1:0,a=n.x.scale*t.x,l=n.y.scale*t.y;r[0+i]/=a,r[1+i]/=l;const u=fe(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 Os=!1;class Bh extends f.Component{componentDidMount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:s,layoutId:r}=this.props,{projection:o}=t;ud(Uh),o&&(n.group&&n.group.add(o),s&&s.register&&r&&s.register(o),Os&&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,Os=!0,r||t.layoutDependency!==n||n===void 0||t.isPresent!==o?i.willUpdate():this.safeToRemove(),t.isPresent!==o&&(o?i.promote():i.relegate()||le.postRender(()=>{const a=i.getStack();(!a||!a.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:t}=this.props.visualElement;t&&(t.root.didUpdate(),Lr.postRender(()=>{!t.currentAnimation&&t.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:s}=this.props,{projection:r}=t;Os=!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 Za(e){const[t,n]=ba(),s=f.useContext(pr);return c.jsx(Bh,{...e,layoutGroup:s,switchLayoutGroup:f.useContext(ka),isPresent:t,safeToRemove:n})}const Uh={borderRadius:{...wn,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:wn,borderTopRightRadius:wn,borderBottomLeftRadius:wn,borderBottomRightRadius:wn,boxShadow:Fh};function zh(e,t,n){const s=Te(e)?e:Ht(e);return s.start(Yr("",s,t,n)),s.animation}const _h=(e,t)=>e.depth-t.depth;class Xh{constructor(){this.children=[],this.isDirty=!1}add(t){xr(this.children,t),this.isDirty=!0}remove(t){br(this.children,t),this.isDirty=!0}forEach(t){this.isDirty&&this.children.sort(_h),this.isDirty=!1,this.children.forEach(t)}}function Wh(e,t){const n=Me.now(),s=({timestamp:r})=>{const o=r-n;o>=t&&(gt(s),e(o-t))};return le.setup(s,!0),()=>gt(s)}const Qa=["TopLeft","TopRight","BottomLeft","BottomRight"],Kh=Qa.length,Yi=e=>typeof e=="string"?parseFloat(e):e,Hi=e=>typeof e=="number"||U.test(e);function qh(e,t,n,s,r,o){r?(e.opacity=fe(0,n.opacity??1,Gh(s)),e.opacityExit=fe(t.opacity??1,0,Yh(s))):o&&(e.opacity=fe(t.opacity??1,n.opacity??1,s));for(let i=0;i<Kh;i++){const a=`border${Qa[i]}Radius`;let l=Ji(t,a),u=Ji(n,a);if(l===void 0&&u===void 0)continue;l||(l=0),u||(u=0),l===0||u===0||Hi(l)===Hi(u)?(e[a]=Math.max(fe(Yi(l),Yi(u),s),0),(et.test(u)||et.test(l))&&(e[a]+="%")):e[a]=u}(t.rotate||n.rotate)&&(e.rotate=fe(t.rotate||0,n.rotate||0,s))}function Ji(e,t){return e[t]!==void 0?e[t]:e.borderRadius}const Gh=el(0,.5,Fo),Yh=el(.5,.95,$e);function el(e,t,n){return s=>s<e?0:s>t?1:n(kn(e,t,s))}function Zi(e,t){e.min=t.min,e.max=t.max}function Ve(e,t){Zi(e.x,t.x),Zi(e.y,t.y)}function Qi(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}function eo(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 Hh(e,t=0,n=1,s=.5,r,o=e,i=e){if(et.test(t)&&(t=parseFloat(t),t=fe(i.min,i.max,t/100)-i.min),typeof t!="number")return;let a=fe(o.min,o.max,s);e===o&&(a-=t),e.min=eo(e.min,t,n,a,r),e.max=eo(e.max,t,n,a,r)}function to(e,t,[n,s,r],o,i){Hh(e,t[n],t[s],t[r],t.scale,o,i)}const Jh=["x","scaleX","originX"],Zh=["y","scaleY","originY"];function no(e,t,n,s){to(e.x,t,Jh,n?n.x:void 0,s?s.x:void 0),to(e.y,t,Zh,n?n.y:void 0,s?s.y:void 0)}function so(e){return e.translate===0&&e.scale===1}function tl(e){return so(e.x)&&so(e.y)}function ro(e,t){return e.min===t.min&&e.max===t.max}function Qh(e,t){return ro(e.x,t.x)&&ro(e.y,t.y)}function io(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function nl(e,t){return io(e.x,t.x)&&io(e.y,t.y)}function oo(e){return Ae(e.x)/Ae(e.y)}function ao(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}class ef{constructor(){this.members=[]}add(t){xr(this.members,t),t.scheduleRender()}remove(t){if(br(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 tf(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 Ls=["","X","Y","Z"],nf=1e3;let sf=0;function $s(e,t,n,s){const{latestValues:r}=t;r[e]&&(n[e]=r[e],t.setStaticValue(e,0),s&&(s[e]=0))}function sl(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;const{visualElement:t}=e.options;if(!t)return;const n=Ua(t);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:r,layoutId:o}=e.options;window.MotionCancelOptimisedAnimation(n,"transform",le,!(r||o))}const{parent:s}=e;s&&!s.hasCheckedOptimisedAppear&&sl(s)}function rl({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:s,resetTransform:r}){return class{constructor(i={},a=t?.()){this.id=sf++,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(af),this.nodes.forEach(df),this.nodes.forEach(hf),this.nodes.forEach(lf)},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 Xh)}addEventListener(i,a){return this.eventHandlers.has(i)||this.eventHandlers.set(i,new wr),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=xa(i)&&!Gu(i),this.instance=i;const{layoutId:a,layout:l,visualElement:u}=this.options;if(u&&!u.current&&u.mount(i),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(l||a)&&(this.isLayoutDirty=!0),e){let d,h=0;const m=()=>this.root.updateBlockedByResize=!1;le.read(()=>{h=window.innerWidth}),e(i,()=>{const p=window.innerWidth;p!==h&&(h=p,this.root.updateBlockedByResize=!0,d&&d(),d=Wh(m,250),ls.hasAnimatedSinceResize&&(ls.hasAnimatedSinceResize=!1,this.nodes.forEach(uo)))})}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()||yf,{onLayoutAnimationStart:v,onLayoutAnimationComplete:T}=u.getProps(),b=!this.targetLayout||!nl(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={...Ir(S,"layout"),onPlay:v,onComplete:T};(u.shouldReduceMotion||this.options.layoutRoot)&&(E.delay=0,E.type=!1),this.startAnimation(E),this.setAnimationOrigin(d,M)}else h||uo(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=p})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const i=this.getStack();i&&i.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),gt(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(ff),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&&sl(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(lo);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(co);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(uf),this.nodes.forEach(rf),this.nodes.forEach(of)):this.nodes.forEach(co),this.clearAllSnapshots();const a=Me.now();we.delta=ot(0,1e3/60,a-we.timestamp),we.timestamp=a,we.isProcessing=!0,Ps.update.process(we),Ps.preRender.process(we),Ps.render.process(we),we.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,Lr.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(cf),this.sharedNodes.forEach(mf)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,le.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){le.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!Ae(this.snapshot.measuredBox.x)&&!Ae(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let l=0;l<this.path.length;l++)this.path[l].updateScroll();const i=this.layout;this.layout=this.measure(!1),this.layoutCorrected=pe(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);const{visualElement:a}=this.options;a&&a.notify("LayoutMeasure",this.layout.layoutBox,i?i.layoutBox:void 0)}updateScroll(i="measure"){let a=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===i&&(a=!1),a&&this.instance){const l=s(this.instance);this.scroll={animationId:this.root.animationId,phase:i,isRoot:l,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:l}}}resetTransform(){if(!r)return;const i=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,a=this.projectionDelta&&!tl(this.projectionDelta),l=this.getTransformTemplate(),u=l?l(this.latestValues,""):void 0,d=u!==this.prevTransformTemplateValue;i&&this.instance&&(a||Et(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)),xf(l),{animationId:this.root.animationId,measuredBox:a,layoutBox:l,latestValues:{},source:this.id}}measurePageBox(){const{visualElement:i}=this.options;if(!i)return pe();const a=i.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(bf))){const{scroll:u}=this.root;u&&(Wt(a.x,u.offset.x),Wt(a.y,u.offset.y))}return a}removeElementScroll(i){const a=pe();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),Wt(a.x,d.offset.x),Wt(a.y,d.offset.y))}return a}applyTransform(i,a=!1){const l=pe();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&&Kt(l,{x:-d.scroll.offset.x,y:-d.scroll.offset.y}),Et(d.latestValues)&&Kt(l,d.latestValues)}return Et(this.latestValues)&&Kt(l,this.latestValues),l}removeTransform(i){const a=pe();Ve(a,i);for(let l=0;l<this.path.length;l++){const u=this.path[l];if(!u.instance||!Et(u.latestValues))continue;ir(u.latestValues)&&u.updateSnapshot();const d=pe(),h=u.measurePageBox();Ve(d,h),no(a,u.latestValues,u.snapshot?u.snapshot.layoutBox:void 0,d)}return Et(this.latestValues)&&no(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=pe(),this.relativeTargetOrigin=pe(),En(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=pe(),this.targetWithTransforms=pe()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),Ch(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):Ve(this.target,this.layout.layoutBox),Va(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=pe(),this.relativeTargetOrigin=pe(),En(this.relativeTargetOrigin,this.target,m.target),Ve(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}}}getClosestProjectingParent(){if(!(!this.parent||ir(this.parent.latestValues)||Ra(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;$d(this.layoutCorrected,this.treeScale,this.path,a),i.layout&&!i.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(i.target=i.layout.layoutBox,i.targetWithTransforms=pe());const{target:p}=i;if(!p){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(Qi(this.prevProjectionDelta.x,this.projectionDelta.x),Qi(this.prevProjectionDelta.y,this.projectionDelta.y)),An(this.projectionDelta,this.layoutCorrected,p,this.latestValues),(this.treeScale.x!==h||this.treeScale.y!==m||!ao(this.projectionDelta.x,this.prevProjectionDelta.x)||!ao(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",p))}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(i=!0){if(this.options.visualElement?.scheduleRender(),i){const a=this.getStack();a&&a.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=qt(),this.projectionDelta=qt(),this.projectionDeltaWithTransform=qt()}setAnimationOrigin(i,a=!1){const l=this.snapshot,u=l?l.latestValues:{},d={...this.latestValues},h=qt();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!a;const m=pe(),p=l?l.source:void 0,S=this.layout?this.layout.source:void 0,v=p!==S,T=this.getStack(),b=!T||T.members.length<=1,M=!!(v&&!b&&this.options.crossfade===!0&&!this.path.some(gf));this.animationProgress=0;let E;this.mixTargetDelta=$=>{const D=$/1e3;ho(h.x,i.x,D),ho(h.y,i.y,D),this.setTargetDelta(h),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(En(m,this.layout.layoutBox,this.relativeParent.layout.layoutBox),pf(this.relativeTarget,this.relativeTargetOrigin,m,D),E&&Qh(this.relativeTarget,E)&&(this.isProjectionDirty=!1),E||(E=pe()),Ve(E,this.relativeTarget)),v&&(this.animationValues=d,qh(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&&(gt(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=le.update(()=>{ls.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=Ht(0)),this.currentAnimation=zh(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(nf),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&&il(this.options.animationType,this.layout.layoutBox,u.layoutBox)){l=this.target||pe();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}Ve(a,l),Kt(a,d),An(this.projectionDeltaWithTransform,this.layoutCorrected,a,d)}}registerSharedNode(i,a){this.sharedNodes.has(i)||this.sharedNodes.set(i,new ef),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&&$s("z",i,u,this.animationValues);for(let d=0;d<Ls.length;d++)$s(`rotate${Ls[d]}`,i,u,this.animationValues),$s(`skew${Ls[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&&!Et(this.latestValues)&&(i.transform=l?l({},""):"none",this.hasProjected=!1);return}i.visibility="";const d=u.animationValues||u.latestValues;this.applyTransformsToTarget();let h=tf(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 Vn){if(d[S]===void 0)continue;const{correct:v,applyTo:T,isCSSVariable:b}=Vn[S],M=h==="none"?d[S]:v(d[S],u);if(T){const E=T.length;for(let $=0;$<E;$++)i[T[$]]=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(lo),this.root.sharedNodes.clear()}}}function rf(e){e.updateLayout()}function of(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=Ae(h);h.min=n[d].min,h.max=h.min+m}):il(r,t.layoutBox,n)&&Ie(d=>{const h=o?t.measuredBox[d]:t.layoutBox[d],m=Ae(n[d]);h.max=h.min+m,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[d].max=e.relativeTarget[d].min+m)});const i=qt();An(i,n,t.layoutBox);const a=qt();o?An(a,e.applyTransform(s,!0),t.measuredBox):An(a,n,t.layoutBox);const l=!tl(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=pe();En(p,t.layoutBox,h.layoutBox);const S=pe();En(S,n,m.layoutBox),nl(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 af(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 lf(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function cf(e){e.clearSnapshot()}function lo(e){e.clearMeasurements()}function co(e){e.isLayoutDirty=!1}function uf(e){const{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify("BeforeLayoutMeasure"),e.resetTransform()}function uo(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function df(e){e.resolveTargetDelta()}function hf(e){e.calcProjection()}function ff(e){e.resetSkewAndRotation()}function mf(e){e.removeLeadSnapshot()}function ho(e,t,n){e.translate=fe(t.translate,0,n),e.scale=fe(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function fo(e,t,n,s){e.min=fe(t.min,n.min,s),e.max=fe(t.max,n.max,s)}function pf(e,t,n,s){fo(e.x,t.x,n.x,s),fo(e.y,t.y,n.y,s)}function gf(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}const yf={duration:.45,ease:[.4,0,.1,1]},mo=e=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),po=mo("applewebkit/")&&!mo("chrome/")?Math.round:$e;function go(e){e.min=po(e.min),e.max=po(e.max)}function xf(e){go(e.x),go(e.y)}function il(e,t,n){return e==="position"||e==="preserve-aspect"&&!Th(oo(t),oo(n),.2)}function bf(e){return e!==e.root&&e.scroll?.wasRoot}const vf=rl({attachResizeListener:(e,t)=>In(e,"resize",t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0}),Fs={current:void 0},ol=rl({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!Fs.current){const e=new vf({});e.mount(window),e.setOptions({layoutScroll:!0}),Fs.current=e}return Fs.current},resetTransform:(e,t)=>{e.style.transform=t!==void 0?t:"none"},checkIsScrollRoot:e=>window.getComputedStyle(e).position==="fixed"}),wf={pan:{Feature:$h},drag:{Feature:Lh,ProjectionNode:ol,MeasureLayout:Za}};function yo(e,t,n){const{props:s}=e;e.animationState&&s.whileHover&&e.animationState.setActive("whileHover",n==="Start");const r="onHover"+n,o=s[r];o&&le.postRender(()=>o(t,Fn(t)))}class Sf extends xt{mount(){const{current:t}=this.node;t&&(this.unmount=_u(t,(n,s)=>(yo(this.node,s,"Start"),r=>yo(this.node,r,"End"))))}unmount(){}}class Tf extends xt{constructor(){super(...arguments),this.isActive=!1}onFocus(){let t=!1;try{t=this.node.current.matches(":focus-visible")}catch{t=!0}!t||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=On(In(this.node.current,"focus",()=>this.onFocus()),In(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function xo(e,t,n){const{props:s}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&s.whileTap&&e.animationState.setActive("whileTap",n==="Start");const r="onTap"+(n==="End"?"":n),o=s[r];o&&le.postRender(()=>o(t,Fn(t)))}class Cf extends xt{mount(){const{current:t}=this.node;t&&(this.unmount=qu(t,(n,s)=>(xo(this.node,s,"Start"),(r,{success:o})=>xo(this.node,r,o?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}const hr=new WeakMap,Bs=new WeakMap,jf=e=>{const t=hr.get(e.target);t&&t(e)},Pf=e=>{e.forEach(jf)};function Af({root:e,...t}){const n=e||document;Bs.has(n)||Bs.set(n,{});const s=Bs.get(n),r=JSON.stringify(t);return s[r]||(s[r]=new IntersectionObserver(Pf,{root:e,...t})),s[r]}function Ef(e,t,n){const s=Af(t);return hr.set(e,n),s.observe(e),()=>{hr.delete(e),s.unobserve(e)}}const Mf={some:0,all:1};class kf extends xt{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:t={}}=this.node.getProps(),{root:n,margin:s,amount:r="some",once:o}=t,i={root:n?n.current:void 0,rootMargin:s,threshold:typeof r=="number"?r:Mf[r]},a=l=>{const{isIntersecting:u}=l;if(this.isInView===u||(this.isInView=u,o&&!u&&this.hasEnteredView))return;u&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",u);const{onViewportEnter:d,onViewportLeave:h}=this.node.getProps(),m=u?d:h;m&&m(l)};return Ef(this.node.current,i,a)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:t,prevProps:n}=this.node;["amount","margin","root"].some(Nf(t,n))&&this.startObserver()}unmount(){}}function Nf({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}const al={inView:{Feature:kf},tap:{Feature:Cf},focus:{Feature:Tf},hover:{Feature:Sf}},Df={layout:{ProjectionNode:ol,MeasureLayout:Za}},Rf={...Ka,...al,...wf,...Df},Vf=Id(Rf,Ba),If={renderer:Ba,...Ka,...al};function Hr(e,t){return as(e,t)}const Of=Hr("button"),ts=Hr("div"),Lf=Hr("p");function $f({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(ee.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(ee.X,{className:"h-3 w-3"})})]})]})})}function Ff({toolName:e,args:t,isDenied:n,isSafe:s}){const[r,o]=f.useState(!1);if(e==="fetchDocContent")return null;const i=["k","maxResults","_organizationId"];e==="searchDocs"&&i.push("filters");const a=Object.fromEntries(Object.entries(t).filter(([u])=>!i.includes(u))),l=Object.keys(a).length>0;return c.jsxs("div",{className:"my-1",children:[c.jsxs("button",{onClick:()=>l&&o(!r),className:`inline-flex items-center gap-1.5 text-xs rounded-md px-2 py-1 transition-colors bg-muted text-muted-foreground ${l?"cursor-pointer hover:bg-muted/80":""}`,children:[l&&c.jsx("span",{className:"transition-transform duration-200",children:r?c.jsx(ee.ChevronDown,{className:"h-3 w-3"}):c.jsx(ee.ChevronRight,{className:"h-3 w-3"})}),n?c.jsx(ee.X,{className:"h-3 w-3"}):s?c.jsx(ee.Zap,{className:"h-3 w-3"}):c.jsx(ee.Check,{className:"h-3 w-3"}),c.jsxs("span",{className:"font-medium",children:[n?"Denied":s?"Auto-executed":"Executed"," ",e]})]}),r&&l&&c.jsx("div",{className:"mt-1 ml-6 p-2 bg-stone-50 dark:bg-stone-900 rounded-md border border-border",children:c.jsx("div",{className:"space-y-0.5",children:Object.entries(a).map(([u,d])=>c.jsxs("div",{className:"flex items-start gap-1.5 text-xs",children:[c.jsxs("span",{className:"text-muted-foreground min-w-[60px]",children:[u,":"]}),c.jsx("span",{className:"font-mono text-foreground",children:typeof d=="string"?d:JSON.stringify(d)})]},u))})})]})}function Bf({...e}){return c.jsx(fr.Root,{"data-slot":"collapsible",...e})}function Uf({...e}){return c.jsx(fr.CollapsibleTrigger,{"data-slot":"collapsible-trigger",...e})}function zf({...e}){return c.jsx(fr.CollapsibleContent,{"data-slot":"collapsible-content",...e})}const _f=f.lazy(()=>import("streamdown").then(e=>({default:e.Streamdown}))),Jr=f.memo(({className:e,...t})=>typeof window>"u"?null:c.jsx(f.Suspense,{fallback:null,children:c.jsx(_f,{className:ne("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",e),...t})}),(e,t)=>e.children===t.children);Jr.displayName="Response";const Xf=Object.freeze(Object.defineProperty({__proto__:null,Response:Jr},Symbol.toStringTag,{value:"Module"})),Wf=({children:e,as:t="p",className:n,duration:s=2,spread:r=2})=>{const o=Vf.create(t),i=f.useMemo(()=>(e?.length??0)*r,[e,r]);return c.jsx(o,{animate:{backgroundPosition:"0% center"},className:ne("relative inline-block bg-[length:250%_100%,auto] bg-clip-text text-transparent","[--bg:linear-gradient(90deg,#0000_calc(50%-var(--spread)),var(--color-background),#0000_calc(50%+var(--spread)))] [background-repeat:no-repeat,padding-box]",n),initial:{backgroundPosition:"100% center"},style:{"--spread":`${i}px`,backgroundImage:"var(--bg), linear-gradient(var(--color-muted-foreground), var(--color-muted-foreground))"},transition:{repeat:Number.POSITIVE_INFINITY,duration:s,ease:"linear"},children:e})},Kf=f.memo(Wf),ll=f.createContext(null),qf=()=>{const e=f.useContext(ll);if(!e)throw new Error("Reasoning components must be used within Reasoning");return e},Gf=1e3,Yf=1e3,cl=f.memo(({className:e,isStreaming:t=!1,open:n,defaultOpen:s=!0,onOpenChange:r,duration:o,children:i,...a})=>{const[l,u]=ti.useControllableState({prop:n,defaultProp:s,onChange:r}),[d,h]=ti.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)/Yf)),v(null))},[t,S,h]),f.useEffect(()=>{if(s&&!t&&l&&!m){const b=setTimeout(()=>{u(!1),p(!0)},Gf);return()=>clearTimeout(b)}},[t,l,s,u,m]);const T=b=>{u(b)};return c.jsx(ll.Provider,{value:{isStreaming:t,isOpen:l,setIsOpen:u,duration:d},children:c.jsx(Bf,{className:ne("not-prose mb-4",e),onOpenChange:T,open:l,...a,children:i})})}),Hf=(e,t)=>e||t===0?c.jsx(Kf,{duration:1,children:"Thinking..."}):t===void 0?c.jsx("p",{children:"Thought for a few seconds"}):c.jsxs("p",{children:["Thought for ",t," seconds"]}),ul=f.memo(({className:e,children:t,...n})=>{const{isStreaming:s,isOpen:r,duration:o}=qf();return c.jsx(Uf,{className:ne("flex w-full items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground",e),...n,children:t??c.jsxs(c.Fragment,{children:[c.jsx(ee.BrainIcon,{className:"size-4"}),Hf(s,o),c.jsx(ee.ChevronDownIcon,{className:ne("size-4 transition-transform",r?"rotate-180":"rotate-0")})]})})}),dl=f.memo(({className:e,children:t,...n})=>c.jsx(zf,{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(Jr,{className:"grid gap-2",children:t})}));cl.displayName="Reasoning";ul.displayName="ReasoningTrigger";dl.displayName="ReasoningContent";function bo(e){return`https://www.google.com/s2/favicons?domain=${encodeURIComponent(e)}&sz=16`}function Jf({sources:e,citationNumber:t,className:n}){const s=e.find(o=>o.number===t);if(!s)return null;const r=bo(s.domain);return c.jsxs(ht,{children:[c.jsx(ft,{asChild:!0,children:c.jsxs("button",{className:ne("inline-flex items-center gap-1 px-1 py-0.5 rounded text-[10px] font-medium","bg-stone-200/60 dark:bg-stone-700/60 text-stone-800 dark:text-stone-200","hover:bg-stone-300/80 dark:hover:bg-stone-600/80","transition-all duration-200","border border-stone-300/60 dark:border-stone-600/60","cursor-pointer hover:scale-105 active:scale-95","leading-tight",n),onClick:o=>{o.preventDefault(),o.stopPropagation(),window.open(s.url,"_blank","noopener,noreferrer")},children:[c.jsx("img",{src:r,alt:"",className:"w-3 h-3 leading-none",onError:o=>{const i=o.target;i.style.display="none"}}),c.jsx("span",{className:"leading-none",children:s.domain})]})}),c.jsx(mt,{side:"top",className:"bg-stone-800 dark:bg-stone-900 border border-stone-700 dark:border-stone-600 p-3 max-w-sm z-50 rounded-lg shadow-lg",children:c.jsxs("div",{className:"space-y-1.5",children:[c.jsxs("div",{className:"text-xs font-semibold text-stone-300 dark:text-stone-200 mb-2 pb-2 border-b border-stone-700 dark:border-stone-600",children:["Sources • ",e.length]}),e.map(o=>{const i=o.title||o.domain;return c.jsxs("a",{href:o.url,target:"_blank",rel:"noopener noreferrer",className:ne("flex items-center gap-2 p-2 rounded-md hover:bg-stone-700/50 dark:hover:bg-stone-700/50 transition-colors","text-stone-300 dark:text-stone-300 hover:text-white dark:hover:text-white"),onClick:a=>a.stopPropagation(),children:[c.jsx("img",{src:bo(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 Zf({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 b,M=!1;const E=new WeakSet,$=()=>{if(!u.current||M)return;M=!0;const I=u.current,N=/\[(\d+)\]/g,P=document.createTreeWalker(I,NodeFilter.SHOW_TEXT,null),O=[];let A;for(;A=P.nextNode();)if(A.nodeType===Node.TEXT_NODE&&!E.has(A)){const F=A,V=F.textContent||"";let B=F.parentElement,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 q=Array.from(V.matchAll(N)).filter(ie=>{if(!ie[1])return!1;const ye=parseInt(ie[1],10);return n.has(ye)});q.length>0&&O.push({node:F,matches:q})}}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(q=>{if(!q[1])return;q.index!==void 0&&q.index>Y&&X.appendChild(document.createTextNode(B.slice(Y,q.index)));const ie=document.createElement("span");ie.className="inline-flex items-center citation-button-container";const ye=parseInt(q[1],10);ie.setAttribute("data-citation",q[1]),X.appendChild(ie),k.push({element:ie,citationNum:ye}),Y=(q.index||0)+q[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(T,{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(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 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((T,b)=>{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-${b}`)}):Array.from(n.entries()).sort(([T],[b])=>T-b).map(([T,b])=>{const M=S(b),E=p(M);return c.jsxs("a",{href:b,target:"_blank",rel:"noopener noreferrer",className:ne("inline-flex items-center gap-1.5 px-2.5 py-1.5 rounded-md text-xs font-medium","bg-stone-100 dark:bg-stone-800 text-stone-700 dark:text-stone-300","hover:bg-stone-200 dark:hover:bg-stone-700","transition-all duration-200","border border-stone-200 dark:border-stone-700","cursor-pointer hover:scale-105 active:scale-95","no-underline"),children:[c.jsx("img",{src:E,alt:"",className:"w-3.5 h-3.5 shrink-0",onError:$=>{const D=$.target;D.style.display="none"}}),c.jsx("span",{className:"leading-none",children:b})]},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: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(P=>P.url.replace(/\/+$/,"")===I);return[I,{number:D.number,url:D.url,domain:S(D.url),title:N?.title}]})).values());return Ml.createPortal(c.jsx(Jf,{sources:$,citationNumber:b},`citation-${b}-${T}`),T,`citation-${b}-${M}`)}),v]})}function nn({...e}){return c.jsx(Rt.Root,{"data-slot":"dialog",...e})}function Qf({...e}){return c.jsx(Rt.Portal,{"data-slot":"dialog-portal",...e})}function em({className:e,...t}){return c.jsx(Rt.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 sn({className:e,children:t,showCloseButton:n=!0,...s}){return c.jsxs(Qf,{"data-slot":"dialog-portal",children:[c.jsx(em,{}),c.jsxs(Rt.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(Rt.Close,{"data-slot":"dialog-close",className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[c.jsx(ee.XIcon,{}),c.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function rn({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 on({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 an({className:e,...t}){return c.jsx(Rt.Title,{"data-slot":"dialog-title",className:ne("text-lg leading-none font-semibold",e),...t})}function ln({className:e,...t}){return c.jsx(Rt.Description,{"data-slot":"dialog-description",className:ne("text-muted-foreground text-sm",e),...t})}function cn({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 tm({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(nn,{open:e,children:c.jsx(sn,{showCloseButton:!1,children:c.jsxs("form",{onSubmit:h,children:[c.jsxs(rn,{children:[c.jsx(an,{children:t}),c.jsx(ln,{children:n})]}),c.jsx("div",{className:"py-4",children:c.jsxs("div",{className:"relative",children:[c.jsx(cn,{type:a?"text":"password",value:o,onChange:p=>i(p.target.value),placeholder:s,className:"pr-10",autoFocus:!0,disabled:u}),c.jsx("button",{type:"button",onClick:()=>l(!a),className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600",disabled:u,children:a?c.jsx(ee.EyeOff,{className:"h-4 w-4"}):c.jsx(ee.Eye,{className:"h-4 w-4"})})]})}),c.jsxs(on,{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 nm({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(nn,{open:e,children:c.jsx(sn,{showCloseButton:!1,children:c.jsxs("form",{onSubmit:p,children:[c.jsxs(rn,{children:[c.jsxs(an,{className:"flex items-center gap-2",children:[c.jsx(ee.Mail,{className:"h-5 w-5"}),t]}),c.jsx(ln,{children:n})]}),c.jsxs("div",{className:"py-4",children:[c.jsx(cn,{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(on,{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 sm({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 b=T.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=T=>T.replace(/\D/g,"").length===10,p=T=>{const b=h(T);i(b),b.trim()?l(m(b)):l(!0)},S=async T=>{if(T.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(nn,{open:e,children:c.jsx(sn,{showCloseButton:!1,children:c.jsxs("form",{onSubmit:S,children:[c.jsxs(rn,{children:[c.jsxs(an,{className:"flex items-center gap-2",children:[c.jsx(ee.Phone,{className:"h-5 w-5"}),t]}),c.jsx(ln,{children:n})]}),c.jsxs("div",{className:"py-4",children:[c.jsx(cn,{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(on,{children:[c.jsx(Ce,{type:"button",variant:"ghost",onClick:v,disabled:u,children:"Cancel"}),c.jsx(Ce,{type:"submit",disabled:!o.trim()||!a||u,children:u?"Submitting...":"Submit"})]})]})})})}function rm({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(nn,{open:e,children:c.jsx(sn,{showCloseButton:!1,children:c.jsxs("form",{onSubmit:h,children:[c.jsxs(rn,{children:[c.jsxs(an,{className:"flex items-center gap-2",children:[c.jsx(ee.Shield,{className:"h-5 w-5"}),t]}),c.jsx(ln,{children:n})]}),c.jsxs("div",{className:"py-4",children:[c.jsx(cn,{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(on,{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 Us({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(nn,{open:e,children:c.jsx(sn,{showCloseButton:!1,children:c.jsxs("form",{onSubmit:d,children:[c.jsxs(rn,{children:[c.jsxs(an,{className:"flex items-center gap-2",children:[c.jsx(ee.Lock,{className:"h-5 w-5"}),t]}),c.jsx(ln,{children:n})]}),c.jsx("div",{className:"py-4",children:c.jsx(cn,{type:r,value:i,onChange:m=>a(m.target.value),placeholder:s,autoFocus:!0,disabled:l})}),c.jsxs(on,{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 im({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",T=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=T(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=T(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]}))},P=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(nn,{open:e,children:c.jsx(sn,{showCloseButton:!1,className:"max-w-md",children:c.jsxs("form",{onSubmit:D,children:[c.jsxs(rn,{children:[c.jsx(an,{children:t}),n&&c.jsx(ln,{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(cn,{type:P(A),value:a[A.name]||"",onChange:k=>E(A.name,k.target.value,A),placeholder:O(A),className:u[A.name]?"border-red-500":"",disabled:p,autoFocus:A===s[0],maxLength:A.type==="pin"?6:A.type==="phone"?14:void 0}),A.type==="password"&&c.jsx("button",{type:"button",onClick:()=>N(A.name),className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600",disabled:p,children:h[A.name]?c.jsx(ee.EyeOff,{className:"h-4 w-4"}):c.jsx(ee.Eye,{className:"h-4 w-4"})})]}),u[A.name]&&c.jsxs("div",{className:"flex items-center gap-1 mt-1 text-sm text-red-500",children:[c.jsx(ee.AlertCircle,{className:"h-3 w-3"}),u[A.name]]})]},A.name))}),c.jsxs(on,{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 hl=f.createContext(void 0);function fl(){const e=f.useContext(hl);if(!e)throw new Error("useSecureModal must be used within a SecureModalProvider");return e}function ml({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(im,{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(tm,{...p});case"email":return c.jsx(nm,{...p});case"phone":return c.jsx(sm,{...p});case"pin":return c.jsx(rm,{...p});case"ssn":return c.jsx(Us,{...p,title:t.title||"SSN Required",placeholder:t.placeholder||"XXX-XX-XXXX"});case"creditCard":return c.jsx(Us,{...p,title:t.title||"Credit Card Required",placeholder:t.placeholder||"XXXX XXXX XXXX XXXX",type:"text"});case"text":default:return c.jsx(Us,{...p})}},m=f.useMemo(()=>({showSecureModal:a,showSecureForm:l}),[a,l]);return c.jsxs(hl.Provider,{value:m,children:[e,h()]})}function om(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 am(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 vo(e){let t=e.replace(/_+$/gm,"");const n=/(?:^|\n)(?:#+\s*)?(?:References|References:)(?:\*\*)?\s*\n?([\s\S]*?)(?=\n\n|\n#|$)/i,s=t.match(n),r=new Map,o=[],i=new Map,a=new Map,l=new Map,u=new Map;if(s&&s[1]){const P=s[1],O=/\[(\d+)\]\s*(https?:\/\/[^\s\)]+)/g;let A;for(;(A=O.exec(P))!==null;)if(A[1]&&A[2]){const k=parseInt(A[1],10),F=A[2].replace(/[.,;:!?]+$/,""),V=F.replace(/\/+$/,"");if(a.has(V)||a.set(V,F),i.has(V)||i.set(V,[]),i.get(V).push(k),!l.has(V))l.set(V,k);else{const B=l.get(V);k<B&&l.set(V,k)}}for(const[k,F]of i.entries()){const V=l.get(k);for(const B of F)B!==V&&u.set(B,V)}for(const[k,F]of l.entries()){const V=a.get(k)||k;r.set(F,V),o.push({number:F,url:V})}}let d,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 T=m.map(P=>{if(P.type==="code")return P.content;let O=P.content;return O=O.replace(/\[(\d+)\]\((https?:\/\/[^\)]+)\)/g,(k,F,V)=>{const B=parseInt(F,10),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[P,O]of l.entries()){const A=a.get(P)||P,{baseUrl:k,anchor:F}=om(A),V=am(A);b.push({url:A,baseUrl:k,numbers:[O],anchor:F,title:V})}b.sort((P,O)=>(P.numbers[0]||0)-(O.numbers[0]||0));const M=new Map;let E=1;for(const P of b){const O=P.numbers[0];M.set(O,E),P.numbers=[E],E++}const $=new Map;for(const[P,O]of r.entries()){const A=M.get(P);A&&$.set(A,O)}const D=o.map(P=>{const O=M.get(P.number);return O?{number:O,url:P.url}:P}).filter(P=>M.has(P.number)),I=Array.from(M.entries()).sort((P,O)=>O[0]-P[0]);let N=T.join("");for(const[P,O]of I){const A=new RegExp(`\\[${P}\\](?!\\d)`,"g");N=N.replace(A,`[${O}]`)}return{processedText:N,citations:D.sort((P,O)=>P.number-O.number),citationMap:$,groupedCitations:b,referencesText:d}}function Mn(e){if(typeof e=="string")try{const t=JSON.parse(e);return Mn(t)}catch{return e}if(Array.isArray(e))return e.map(Mn);if(e&&typeof e=="object"){const t={};for(const[n,s]of Object.entries(e))t[n]=Mn(s);return t}return e}function zs(e){if(typeof e=="string"){try{const t=JSON.parse(e);if(t&&typeof t=="object"&&!Array.isArray(t))return Mn(t)}catch{}return{}}return e&&typeof e=="object"&&!Array.isArray(e)?Mn(e):{}}function lm({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:T,tokenEndpoint:b="/api/arcten/token",apiBaseUrl:M="https://api.arcten.com",user:E,state:$,onStateChange:D,allowStateEdits:I=!0,sources:N,ragConfig:P,showCitations:O=!0,sensitiveParams:A,autoDetectSensitive:k=!1}){const F=M.replace(/\/+$/,""),{showSecureModal:V}=fl(),B=Po({apiBaseUrl:F,tokenEndpoint:b,user:E,tools:d,safeTools:h,toolMetadata:p,sensitiveParams:A,autoDetectSensitive:k,agentId:v,agentName:T,state:$,onStateChange:D,allowStateEdits:I,sources:N,ragConfig:P});f.useMemo(()=>P!==void 0?P:N&&N.length>0?{enabled:!0,organizationId:N[0],autoExecute:!0,filters:void 0}:{enabled:!1},[N,P]);const[X,Y]=f.useState(u),[q,ie]=f.useState(i),[ye,We]=f.useState(600),[bt,tt]=f.useState(!1),[G,Vt]=f.useState(!1),[Ee,vt]=f.useState(!1),[je,Fe]=f.useState({x:100,y:100}),[un,oe]=f.useState(!1),[dn,wt]=f.useState({x:0,y:0}),[hn,Bn]=f.useState(!1),Be=f.useRef(null),St=f.useRef(null),[Tt,ke]=f.useState(""),[fn,bs]=f.useState(null),[It,mn]=f.useState("Thinking..."),[Ot,nt]=f.useState(new Set),[vs,Un]=f.useState(""),[st,zn]=f.useState([]),_n=f.useRef(new Map),Lt=f.useRef(!1),ce=f.useRef(""),[$t,ct]=f.useState(!1),[xe,pn]=f.useState(!1),Ke=f.useMemo(()=>[...d,...h],[d,h]),Re=f.useMemo(()=>mr(Ke,p),[Ke,p]),gn=f.useMemo(()=>{const C=new Map,_=new Map(Re.map(z=>[z.name,z]));return Ke.forEach(z=>{const Z=z[Oe];if(Z){const J=_.get(Z);if(J){C.set(J.name,z);return}}const H=Re.find(J=>J.name===z.name);H&&C.set(H.name,z)}),C},[Ke,Re]),qe=f.useMemo(()=>{const C=new Set,_=new Map(Re.map(z=>[z.name,z]));return h.forEach(z=>{const Z=z[Oe];if(Z&&_.has(Z))C.add(Z);else{const H=Re.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,Re,m]),Ct=["Thinking...","Pondering...","Contemplating...","Considering...","Analyzing...","Processing...","Reasoning...","Mulling it over...","Computing...","Cooking up a response...","Brewing ideas...","Connecting the dots...","Piecing it together...","Spinning up thoughts...","Loading brain cells...","Sharpening pencils...","Herding ideas...","Warming up neurons...","Stirring the think-pot...","Plotting a plan...","Wiggling the logic wires...","Rolling ideas around...","Charging the brainstorm...","Booting the brain...","Dusting off the cortex...","Running mental diagnostics...","Fetching cleverness...","Whisking up notions...","Tuning the idea radio...","Juggling possibilities...","Breathing in inspiration...","Squeezing the thought sponge...","Tickling the gray matter...","Bubbling up insights...","Spicing the soup of thought...","Lacing up hypotheses...","Winding the idea clock...","Casting the net for clues...","Polishing the crystal ball...","Mapping the maze...","Crunching the brain-biscuits...","Cueing the eureka moment...","Summoning the muse...","Knocking on insight’s door...","Combing the noodle...","Sailing the think-ship...","Scooping brain gelato...","Testing wild hunches...","Tick-tocking the neurons...","Planting idea seeds...","Shaking the thought snow globe...","Unlocking the mental toolbox...","Nudging the puzzle pieces...","Lighting the idea bulb...","Preheating the oven of insight...","Mixing the mental trail mix...","Spooling up reasoning reels...","Skimming the mind-palace index...","Surfing the thought waves...","Kicking the tires on ideas...","Rattling the idea can...","Waving the logic wand..."];f.useEffect(()=>{if(typeof window<"u"){const 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&&Vt(JSON.parse(Z));const H=localStorage.getItem("arcten-sidebar-position");if(H){const De=JSON.parse(H),se=50,ue=Math.max(se-i,Math.min(De.x,window.innerWidth-se)),W=Math.max(0,Math.min(De.y,window.innerHeight-se));Fe({x:ue,y:W})}const J=localStorage.getItem("arcten-sidebar-minimized");J&&vt(JSON.parse(J)),Bn(!0)}},[]),f.useMemo(()=>E,[E?.id]),f.useEffect(()=>{(async()=>{if(Ke.length===0)return;const _=Ke.map(z=>`${z.name}:${z.toString()}`).join("|");if(_!==ce.current&&!Lt.current){Lt.current=!0,ce.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=>{_n.current.set(J.name,J)}),zn(H.tools)}}catch(z){console.error("Failed to fetch tool descriptions:",z)}finally{Lt.current=!1}}})()},[Ke,F]),f.useEffect(()=>{Promise.resolve().then(()=>Xf).then(C=>{bs(()=>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:Xn,messages:Pe,sendMessage:ut,status:Ne,error:Wn,stop:Ft,addToolOutput:rt,setMessages:Kn,clientToken:qn,tokenError:Ge,conversations:Ye,isLoadingConversations:yn,loadConversation:Ue,deleteConversation:He,startNewConversation:Gn}=B;f.useEffect(()=>{X&&St.current&&St.current.focus()},[X,Pe]),f.useEffect(()=>{const C=Pe[Pe.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(qe.has(H)){if(Ot.has(J))continue;nt(se=>se.has(J)?se:new Set(se).add(J)),(async()=>{try{const se=gn.get(H);if(!se){console.warn(`[ArctenAgent] Tool ${H} not found in toolsMap`),rt({toolCallId:J,tool:H,output:`Error: Tool ${H} not found`}),nt(te=>{const Se=new Set(te);return Se.delete(J),Se});return}const ue=zs(Z.input),W=Re.find(te=>te.name===H);let me;if(W&&W.jsonSchema?.properties){const Se=Object.keys(W.jsonSchema.properties).map(de=>ue[de]);me=await se(...Se)}else me=await se(...Object.values(ue));rt({toolCallId:J,tool:H,output:me}),nt(te=>{const Se=new Set(te);return Se.delete(J),Se})}catch(se){console.error(`[ArctenAgent] Error executing safe tool ${H}:`,se),rt({toolCallId:J,tool:H,output:`Error: ${se instanceof Error?se.message:String(se)}`}),nt(ue=>{const W=new Set(ue);return W.delete(J),W})}})()}}},[Pe,qe,gn,Re,rt,Ot]);function Yn(){Y(!0),localStorage.setItem("arcten-sidebar-expanded","true")}function it(){Y(!1),localStorage.setItem("arcten-sidebar-expanded","false")}f.useEffect(()=>{},[X]),f.useEffect(()=>{Be.current&&Be.current.scrollIntoView({behavior:"smooth"})},[Pe]),f.useEffect(()=>{function C(_){_.key==="Escape"&&(Ne==="streaming"||Ne==="submitted")&&(_.preventDefault(),Ft())}return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[Ne,Ft]);function jt(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 Hn(){Gn(),pn(!1)}function xn(C){if(C.preventDefault(),!Tt.trim())return;(Ne==="streaming"||Ne==="submitted")&&Ft();const _=Ct[Math.floor(Math.random()*Ct.length)]||"Thinking...";mn(_),ut({text:Tt}),ke("")}function dt(C){const _=C.target.value;ke(_)}f.useEffect(()=>{if(!bt)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 _(){tt(!1),localStorage.setItem("arcten-sidebar-width",q.toString()),localStorage.setItem("arcten-sidebar-height",ye.toString())}return window.addEventListener("mousemove",C),window.addEventListener("mouseup",_),()=>{window.removeEventListener("mousemove",C),window.removeEventListener("mouseup",_)}},[bt,q,ye,G,je,a,l]);function Bt(C){C.preventDefault(),tt(!0)}function ws(){Vt(!0),vt(!1),localStorage.setItem("arcten-sidebar-detached","true"),localStorage.setItem("arcten-sidebar-minimized","false")}function Ut(){Vt(!1),vt(!1),localStorage.setItem("arcten-sidebar-detached","false"),localStorage.setItem("arcten-sidebar-minimized","false")}function bn(){vt(!Ee),localStorage.setItem("arcten-sidebar-minimized",JSON.stringify(!Ee))}function Je(C){G&&(oe(!0),wt({x:C.clientX-je.x,y:C.clientY-je.y}))}return f.useEffect(()=>{if(!G)return;function C(){Fe(_=>{const Z=window.innerWidth-50,H=window.innerHeight-50,J=50-q,De=0,se=Math.max(J,Math.min(_.x,Z)),ue=Math.max(De,Math.min(_.y,H));if(se!==_.x||ue!==_.y){const W={x:se,y:ue};return localStorage.setItem("arcten-sidebar-position",JSON.stringify(W)),W}return _})}return window.addEventListener("resize",C),()=>window.removeEventListener("resize",C)},[G,q]),f.useEffect(()=>{if(!un)return;function C(z){const Z=z.clientX-dn.x,H=z.clientY-dn.y,J=50,De=window.innerWidth-J,se=window.innerHeight-J,ue=J-q,W=0,me=Math.max(ue,Math.min(Z,De)),te=Math.max(W,Math.min(H,se));Fe({x:me,y:te})}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",_)}},[un,dn,je,q]),hn?Ge?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: ",Ge]})}):qn?c.jsx(rd,{features:If,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:`${q}px`,height:Me?"auto":`${ye}px`,left:`${je.x}px`,top:`${je.y}px`}:{width:`${q}px`}:void 0,onClick:X?void 0:Yn,children:X?c.jsxs(c.Fragment,{children:[!G&&c.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-1 cursor-col-resize hover:bg-blue-500/40 hover:w-1 transition-all group",onMouseDown:Bt,children:c.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-3 -translate-x-1"})}),G&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"absolute bottom-0 right-0 w-4 h-4 cursor-nwse-resize",onMouseDown:C=>{C.preventDefault(),tt(!0)}}),c.jsx("div",{className:"absolute bottom-0 left-4 right-4 h-3 cursor-move hover:bg-blue-500/20 group",onMouseDown:C=>{C.preventDefault(),C.stopPropagation(),oe(!0),wt({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(),tt(!0)}})]}),c.jsxs("div",{className:"flex flex-col h-full",children:[c.jsxs("div",{className:`flex items-center justify-between p-3 border-b border-border ${G?"cursor-move":""}`,onMouseDown:G?Je:void 0,children:[c.jsx("h2",{className:`text-base font-semibold ${G&&Me?"cursor-pointer":""}`,onClick:G&&Me?C=>{C.stopPropagation(),bn()}:void 0,children:r}),c.jsxs("div",{className:"flex items-center gap-1",onClick:C=>C.stopPropagation(),children:[c.jsxs(ht,{children:[c.jsx(ft,{asChild:!0,children:c.jsx("button",{type:"button",className:ne(At({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:Hn,"aria-label":"New chat",children:c.jsx(ee.Plus,{className:"h-4 w-4"})})}),c.jsx(mt,{children:"Start a new conversation"})]}),c.jsxs(ht,{children:[c.jsx(ft,{asChild:!0,children:c.jsx("button",{type:"button",className:ne(At({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:G?Ut:ws,"aria-label":G?"Dock sidebar":"Float sidebar",children:G?c.jsx(ee.Dock,{className:"h-4 w-4"}):c.jsx(ee.PictureInPicture2,{className:"h-4 w-4"})})}),c.jsx(mt,{children:G?"Dock to sidebar":"Undock to floating window"})]}),c.jsxs(ht,{children:[c.jsx(ft,{asChild:!0,children:c.jsx("button",{type:"button",className:ne(At({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:G?bn:it,"aria-label":G?Me?"Maximize":"Minimize":"Close sidebar",children:G?Me?c.jsx(ee.Maximize2,{className:"h-4 w-4"}):c.jsx(ee.Minimize2,{className:"h-4 w-4"}):c.jsx(ee.X,{className:"h-4 w-4"})})}),c.jsx(mt,{children:G?Me?"Maximize window":"Minimize to header":"Close the chat"})]})]})]}),!Me&&c.jsxs(c.Fragment,{children:[M&&Ye.length>0&&c.jsxs("div",{className:`border-b border-border ${xe?"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:()=>{pn(!xe)},children:xe?"Show less":"View all"})]}),c.jsx("div",{className:`px-2 pb-2 space-y-0.5 ${xe?"flex-1 overflow-y-auto":""}`,children:Ye.slice(0,xe?void 0:3).map(C=>c.jsxs("div",{className:"group relative",children:[c.jsxs(Of,{type:"button",className:ne(At({variant:"ghost"}),"w-full justify-between h-auto py-1 px-3 font-normal active:scale-[0.99]"),onClick:()=>{Ue(C.chatId||C._id),pn(!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:jt(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(),He(C._id)},"aria-label":"Delete conversation",children:c.jsx(ee.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:Pe.length===0?c.jsxs("div",{className:"flex flex-col items-center justify-center h-full",children:[o&&c.jsx("div",{className:"mb-6",children:o}),c.jsx("h3",{className:"text-lg font-semibold text-center mb-2",children:"How can I help you?"}),st.length>0&&c.jsx("div",{className:"mt-4 px-4 max-w-md mx-auto",children:c.jsxs("div",{className:"flex flex-wrap gap-2 justify-center",children:[($t?st:st.slice(0,10)).map(C=>c.jsxs(ht,{children:[c.jsx(ft,{asChild:!0,children:c.jsx(js,{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),St.current?.focus()},children:C.friendlyName})}),c.jsx(mt,{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)),st.length>10&&!$t&&c.jsxs(ht,{children:[c.jsx(ft,{asChild:!0,children:c.jsxs(js,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>ct(!0),children:["+",st.length-10," more"]})}),c.jsx(mt,{children:c.jsxs("div",{className:"max-w-xs",children:[c.jsx("p",{className:"font-medium mb-2",children:"Additional tools:"}),c.jsx("div",{className:"space-y-1 max-h-64 overflow-y-auto pr-2",children:st.slice(10).map(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"})]})})]}),$t&&st.length>10&&c.jsx(js,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>ct(!1),children:"Show less"})]})})]}):c.jsxs(c.Fragment,{children:[Pe.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(me=>me.timestamp)&&(Z=[...C.parts].sort((me,te)=>{const Se=me.timestamp||0,de=te.timestamp||0;return Se-de}));let H=[],J=new Map,De=[],se,ue=!0;if(C.role==="assistant"){const W=Z.filter(de=>de.type==="text"&&de.text),me=[],te=[];W.forEach(de=>{const{citations:Ze,citationMap:ve,groupedCitations:g,referencesText:y}=vo(de.text);H.push(...Ze),me.push(ve),g&&te.push(...g),y&&(se=y)}),me.forEach(de=>{de.forEach((Ze,ve)=>{J.has(ve)||J.set(ve,Ze)})}),De=Array.from(new Map(te.map(de=>[de.url,de])).values()).sort((de,Ze)=>(de.numbers[0]||0)-(Ze.numbers[0]||0)),ue=!(Ne==="streaming"&&C.id===Pe.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(Lf,{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,me)=>{if(W.type?.startsWith("tool-")){const te=W.type?.replace("tool-","")||"",Se=Re.find(ve=>ve.name===te),de=W.state==="input-available",Ze=W.state==="output-available";if(de&&qe.has(te),de){if(qe.has(te))return null;const ve=zs(W.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($f,{toolName:te,description:Se?.description||"",args:ve,onApprove:async()=>{if(Ot.has(W.toolCallId))return;nt(y=>new Set(y).add(W.toolCallId));const g=gn.get(te);if(g)try{const y=await g(...Object.values(ve));rt({toolCallId:W.toolCallId,tool:te,output:y})}catch(y){rt({toolCallId:W.toolCallId,tool:te,output:`Error: ${y}`})}},onDeny:async()=>{Ot.has(W.toolCallId)||(nt(g=>new Set(g).add(W.toolCallId)),rt({toolCallId:W.toolCallId,tool:te,output:"User denied tool execution"}))}})},`${W.toolCallId}-${me}`)}else if(Ze){const ve=W.output==="User denied tool execution",g=zs(W.input);return c.jsx(Ff,{toolName:te,args:g,isDenied:ve,isSafe:qe.has(te)},`${W.toolCallId}-${me}`)}return null}if(W.type==="text"&&W.text&&fn){const{processedText:te}=vo(W.text),ve=!Z.slice(me+1).some(g=>g.type==="text"&&g.text)&&ue&&J.size>0;return c.jsx(Zf,{text:te,citations:H,citationMap:J,groupedCitations:ve?De:void 0,referencesText:ve?se:void 0,ResponseComponent:fn,className:"text-sm prose prose-sm dark:prose-invert max-w-none",showCitations:O,showReferences:ve},`${C.id}-${me}`)}return W.type==="reasoning"&&W.text?c.jsxs(cl,{className:"w-full",isStreaming:Ne==="streaming"&&me===C.parts.length-1&&C.id===Pe.at(-1)?.id,children:[c.jsx(ul,{}),c.jsx(dl,{children:W.text})]},`${C.id}-${me}`):null})})})},C.id)}),c.jsx("div",{ref:Be})]})}),Wn&&c.jsxs("div",{className:"px-4 py-2 bg-destructive/10 text-destructive text-xs",children:["Error: ",Wn.message]}),c.jsxs("div",{className:"p-4 border-t border-border relative overflow-visible",children:[c.jsx(sd,{mode:"wait",children:(Ne==="streaming"||Ne==="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:It})]})}),c.jsxs("form",{onSubmit:xn,className:"relative",children:[c.jsx(Ao,{ref:St,value:Tt,onChange:dt,placeholder:"Ask anything..",className:"w-full pr-12 resize-none border border-border rounded-xl px-4 py-3",minHeight:24,maxHeight:200,onKeyDown:C=>{C.key==="Enter"&&!C.shiftKey&&(C.preventDefault(),xn(C))}}),Ne==="streaming"||Ne==="submitted"?c.jsxs(ht,{children:[c.jsx(ft,{asChild:!0,children:c.jsx("button",{type:"button",className:ne(At({variant:"ghost",size:"icon"}),"absolute top-1/2 -translate-y-1/2 right-2 h-8 w-8"),onClick:Ft,children:c.jsx(ee.Square,{className:"h-4 w-4"})})}),c.jsxs(mt,{children:[c.jsx(ni,{children:"Escape"})," to stop"]})]}):c.jsxs(ht,{children:[c.jsx(ft,{asChild:!0,children:c.jsx("button",{type:"submit",className:ne(At({variant:"ghost",size:"icon"}),"absolute top-1/2 -translate-y-1/2 right-2 h-8 w-8"),disabled:!Tt.trim(),children:c.jsx(ee.ArrowRight,{className:"h-4 w-4"})})}),c.jsxs(mt,{children:[c.jsx(ni,{children:"Enter"})," to send"]})]})]})]})]}),c.jsxs("a",{href:"https://arcten.com",target:"_blank",rel:"noopener noreferrer",className:"group flex items-center justify-center gap-1.5 py-3 text-xs text-muted-foreground/40 hover:text-muted-foreground/60 transition-all",children:[c.jsx("span",{className:"whitespace-nowrap",children:"Powered by"}),c.jsx("div",{className:"w-4 h-2 bg-current rounded-t-full flex-shrink-0"}),c.jsx("span",{className:"whitespace-nowrap",children:"Arcten"})]})]})]})]}):c.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 h-full cursor-pointer",children:[c.jsx(ee.BotMessageSquare,{className:"h-5 w-5 text-stone-600 dark:text-stone-400"}),c.jsx("span",{className:"text-xs font-medium text-stone-600 dark:text-stone-400 [writing-mode:vertical-lr]",children:"AI agent"})]})})}):c.jsx("div",{className:"fixed right-0 top-0 h-screen w-96 flex items-center justify-center p-4 bg-stone-50 dark:bg-stone-900 border-l border-border",children:c.jsx("div",{className:"p-4 text-muted-foreground text-sm",children:"Loading..."})}):null}function cm(e){return c.jsx(ml,{children:c.jsx(lm,{...e})})}exports.verifyToken=Nl.verifyToken;exports.ARCTEN_ORIGINAL_NAME=Oe;exports.ArctenAgent=cm;exports.SecureModalProvider=ml;exports.extractToolsMetadata=mr;exports.preserveToolName=Dl;exports.useAgent=Po;exports.useSecureModal=fl;
15
+ `,style:X?G?{width:`${q}px`,height:Ee?"auto":`${ye}px`,left:`${je.x}px`,top:`${je.y}px`}:{width:`${q}px`}:void 0,onClick:X?void 0:Yn,children:X?c.jsxs(c.Fragment,{children:[!G&&c.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-1 cursor-col-resize hover:bg-blue-500/40 hover:w-1 transition-all group",onMouseDown:Bt,children:c.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-3 -translate-x-1"})}),G&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"absolute bottom-0 right-0 w-4 h-4 cursor-nwse-resize",onMouseDown:C=>{C.preventDefault(),tt(!0)}}),c.jsx("div",{className:"absolute bottom-0 left-4 right-4 h-3 cursor-move hover:bg-blue-500/20 group",onMouseDown:C=>{C.preventDefault(),C.stopPropagation(),oe(!0),wt({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(),tt(!0)}})]}),c.jsxs("div",{className:"flex flex-col h-full",children:[c.jsxs("div",{className:`flex items-center justify-between p-3 border-b border-border ${G?"cursor-move":""}`,onMouseDown:G?Je:void 0,children:[c.jsx("h2",{className:`text-base font-semibold ${G&&Ee?"cursor-pointer":""}`,onClick:G&&Ee?C=>{C.stopPropagation(),bn()}:void 0,children:r}),c.jsxs("div",{className:"flex items-center gap-1",onClick:C=>C.stopPropagation(),children:[c.jsxs(ht,{children:[c.jsx(ft,{asChild:!0,children:c.jsx("button",{type:"button",className:ne(At({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:Hn,"aria-label":"New chat",children:c.jsx(ee.Plus,{className:"h-4 w-4"})})}),c.jsx(mt,{children:"Start a new conversation"})]}),c.jsxs(ht,{children:[c.jsx(ft,{asChild:!0,children:c.jsx("button",{type:"button",className:ne(At({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:G?Ut:ws,"aria-label":G?"Dock sidebar":"Float sidebar",children:G?c.jsx(ee.Dock,{className:"h-4 w-4"}):c.jsx(ee.PictureInPicture2,{className:"h-4 w-4"})})}),c.jsx(mt,{children:G?"Dock to sidebar":"Undock to floating window"})]}),c.jsxs(ht,{children:[c.jsx(ft,{asChild:!0,children:c.jsx("button",{type:"button",className:ne(At({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:G?bn:it,"aria-label":G?Ee?"Maximize":"Minimize":"Close sidebar",children:G?Ee?c.jsx(ee.Maximize2,{className:"h-4 w-4"}):c.jsx(ee.Minimize2,{className:"h-4 w-4"}):c.jsx(ee.X,{className:"h-4 w-4"})})}),c.jsx(mt,{children:G?Ee?"Maximize window":"Minimize to header":"Close the chat"})]})]})]}),!Ee&&c.jsxs(c.Fragment,{children:[E&&Ye.length>0&&c.jsxs("div",{className:`border-b border-border ${xe?"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:()=>{pn(!xe)},children:xe?"Show less":"View all"})]}),c.jsx("div",{className:`px-2 pb-2 space-y-0.5 ${xe?"flex-1 overflow-y-auto":""}`,children:Ye.slice(0,xe?void 0:3).map(C=>c.jsxs("div",{className:"group relative",children:[c.jsxs(Of,{type:"button",className:ne(At({variant:"ghost"}),"w-full justify-between h-auto py-1 px-3 font-normal active:scale-[0.99]"),onClick:()=>{Ue(C.chatId||C._id),pn(!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:jt(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(),He(C._id)},"aria-label":"Delete conversation",children:c.jsx(ee.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:Pe.length===0?c.jsxs("div",{className:"flex flex-col items-center justify-center h-full",children:[o&&c.jsx("div",{className:"mb-6",children:o}),c.jsx("h3",{className:"text-lg font-semibold text-center mb-2",children:"How can I help you?"}),st.length>0&&c.jsx("div",{className:"mt-4 px-4 max-w-md mx-auto",children:c.jsxs("div",{className:"flex flex-wrap gap-2 justify-center",children:[($t?st:st.slice(0,10)).map(C=>c.jsxs(ht,{children:[c.jsx(ft,{asChild:!0,children:c.jsx(js,{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),St.current?.focus()},children:C.friendlyName})}),c.jsx(mt,{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)),st.length>10&&!$t&&c.jsxs(ht,{children:[c.jsx(ft,{asChild:!0,children:c.jsxs(js,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>ct(!0),children:["+",st.length-10," more"]})}),c.jsx(mt,{children:c.jsxs("div",{className:"max-w-xs",children:[c.jsx("p",{className:"font-medium mb-2",children:"Additional tools:"}),c.jsx("div",{className:"space-y-1 max-h-64 overflow-y-auto pr-2",children:st.slice(10).map(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"})]})})]}),$t&&st.length>10&&c.jsx(js,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>ct(!1),children:"Show less"})]})})]}):c.jsxs(c.Fragment,{children:[Pe.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(me=>me.timestamp)&&(Z=[...C.parts].sort((me,te)=>{const Se=me.timestamp||0,de=te.timestamp||0;return Se-de}));let H=[],J=new Map,De=[],se,ue=!0;if(C.role==="assistant"){const W=Z.filter(de=>de.type==="text"&&de.text),me=[],te=[];W.forEach(de=>{const{citations:Ze,citationMap:ve,groupedCitations:g,referencesText:y}=vo(de.text);H.push(...Ze),me.push(ve),g&&te.push(...g),y&&(se=y)}),me.forEach(de=>{de.forEach((Ze,ve)=>{J.has(ve)||J.set(ve,Ze)})}),De=Array.from(new Map(te.map(de=>[de.url,de])).values()).sort((de,Ze)=>(de.numbers[0]||0)-(Ze.numbers[0]||0)),ue=!(Ne==="streaming"&&C.id===Pe.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(Lf,{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,me)=>{if(W.type?.startsWith("tool-")){const te=W.type?.replace("tool-","")||"",Se=Re.find(ve=>ve.name===te),de=W.state==="input-available",Ze=W.state==="output-available";if(de&&qe.has(te),de){if(qe.has(te))return null;const ve=zs(W.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($f,{toolName:te,description:Se?.description||"",args:ve,onApprove:async()=>{if(Ot.has(W.toolCallId))return;nt(y=>new Set(y).add(W.toolCallId));const g=gn.get(te);if(g)try{const y=await g(...Object.values(ve));rt({toolCallId:W.toolCallId,tool:te,output:y})}catch(y){rt({toolCallId:W.toolCallId,tool:te,output:`Error: ${y}`})}},onDeny:async()=>{Ot.has(W.toolCallId)||(nt(g=>new Set(g).add(W.toolCallId)),rt({toolCallId:W.toolCallId,tool:te,output:"User denied tool execution"}))}})},`${W.toolCallId}-${me}`)}else if(Ze){const ve=W.output==="User denied tool execution",g=zs(W.input);return c.jsx(Ff,{toolName:te,args:g,isDenied:ve,isSafe:qe.has(te)},`${W.toolCallId}-${me}`)}return null}if(W.type==="text"&&W.text&&fn){const{processedText:te}=vo(W.text),ve=!Z.slice(me+1).some(g=>g.type==="text"&&g.text)&&ue&&J.size>0;return c.jsx(Zf,{text:te,citations:H,citationMap:J,groupedCitations:ve?De:void 0,referencesText:ve?se:void 0,ResponseComponent:fn,className:"text-sm prose prose-sm dark:prose-invert max-w-none",showCitations:O,showReferences:ve},`${C.id}-${me}`)}return W.type==="reasoning"&&W.text?c.jsxs(cl,{className:"w-full",isStreaming:Ne==="streaming"&&me===C.parts.length-1&&C.id===Pe.at(-1)?.id,children:[c.jsx(ul,{}),c.jsx(dl,{children:W.text})]},`${C.id}-${me}`):null})})})},C.id)}),c.jsx("div",{ref:Be})]})}),Wn&&c.jsxs("div",{className:"px-4 py-2 bg-destructive/10 text-destructive text-xs",children:["Error: ",Wn.message]}),c.jsxs("div",{className:"p-4 border-t border-border relative overflow-visible",children:[c.jsx(sd,{mode:"wait",children:(Ne==="streaming"||Ne==="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:It})]})}),c.jsxs("form",{onSubmit:xn,className:"relative",children:[c.jsx(Ao,{ref:St,value:Tt,onChange:dt,placeholder:"Ask anything..",className:"w-full pr-12 resize-none border border-border rounded-xl px-4 py-3",minHeight:24,maxHeight:200,onKeyDown:C=>{C.key==="Enter"&&!C.shiftKey&&(C.preventDefault(),xn(C))}}),Ne==="streaming"||Ne==="submitted"?c.jsxs(ht,{children:[c.jsx(ft,{asChild:!0,children:c.jsx("button",{type:"button",className:ne(At({variant:"ghost",size:"icon"}),"absolute top-1/2 -translate-y-1/2 right-2 h-8 w-8"),onClick:Ft,children:c.jsx(ee.Square,{className:"h-4 w-4"})})}),c.jsxs(mt,{children:[c.jsx(ni,{children:"Escape"})," to stop"]})]}):c.jsxs(ht,{children:[c.jsx(ft,{asChild:!0,children:c.jsx("button",{type:"submit",className:ne(At({variant:"ghost",size:"icon"}),"absolute top-1/2 -translate-y-1/2 right-2 h-8 w-8"),disabled:!Tt.trim(),children:c.jsx(ee.ArrowRight,{className:"h-4 w-4"})})}),c.jsxs(mt,{children:[c.jsx(ni,{children:"Enter"})," to send"]})]})]})]})]}),c.jsxs("a",{href:"https://arcten.com",target:"_blank",rel:"noopener noreferrer",className:"group flex items-center justify-center gap-1.5 py-3 text-xs text-muted-foreground/40 hover:text-muted-foreground/60 transition-all",children:[c.jsx("span",{className:"whitespace-nowrap",children:"Powered by"}),c.jsx("div",{className:"w-4 h-2 bg-current rounded-t-full flex-shrink-0"}),c.jsx("span",{className:"whitespace-nowrap",children:"Arcten"})]})]})]})]}):c.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 h-full cursor-pointer",children:[c.jsx(ee.BotMessageSquare,{className:"h-5 w-5 text-stone-600 dark:text-stone-400"}),c.jsx("span",{className:"text-xs font-medium text-stone-600 dark:text-stone-400 [writing-mode:vertical-lr]",children:"AI agent"})]})})}):c.jsx("div",{className:"fixed right-0 top-0 h-screen w-96 flex items-center justify-center p-4 bg-stone-50 dark:bg-stone-900 border-l border-border",children:c.jsx("div",{className:"p-4 text-muted-foreground text-sm",children:"Loading..."})}):null}function cm(e){return c.jsx(ml,{children:c.jsx(lm,{...e})})}exports.verifyToken=Nl.verifyToken;exports.ARCTEN_ORIGINAL_NAME=Oe;exports.ArctenAgent=cm;exports.SecureModalProvider=ml;exports.extractToolsMetadata=mr;exports.preserveToolName=Dl;exports.useAgent=Po;exports.useSecureModal=fl;
package/dist/index.mjs CHANGED
@@ -1002,7 +1002,7 @@ function Cc({
1002
1002
  }, [vn, t, JSON.stringify(r), s, n]);
1003
1003
  const Ms = async (p, g = {}) => {
1004
1004
  const y = g.headers ? new Headers(g.headers) : new Headers();
1005
- y.delete("user-agent"), y.delete("User-Agent"), console.log("[useAgent] Making request to:", p), console.log("[useAgent] Method:", g.method || "GET"), console.log("[useAgent] Has Authorization header:", y.has("Authorization")), console.log("[useAgent] Client token available:", !!le.current);
1005
+ y.delete("user-agent"), y.delete("User-Agent"), console.log("[customFetch] ===== REQUEST ====="), console.log("[customFetch] URL:", p), console.log("[customFetch] Stack trace:", new Error().stack), console.log("[useAgent] Making request to:", p), console.log("[useAgent] Method:", g.method || "GET"), console.log("[useAgent] Has Authorization header:", y.has("Authorization")), console.log("[useAgent] Client token available:", !!le.current);
1006
1006
  try {
1007
1007
  const x = await fetch(p, {
1008
1008
  ...g,
@@ -1 +1 @@
1
- {"version":3,"file":"useAgent.d.ts","sourceRoot":"","sources":["../../src/lib/useAgent.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EAKf,MAAM,oBAAoB,CAAC;AA8X5B,wBAAgB,QAAQ,CAAC,EACvB,UAAU,EAAE,aAAwC,EACpD,aAAmC,EACnC,WAAW,EAAE,aAAa,EAC1B,cAAsB,EACtB,IAAI,EACJ,KAAU,EACV,SAAc,EACd,aAAa,EAAE,iBAAiB,EAChC,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,mBAA2B,EAC3B,kBAA0B,EAC1B,QAAiB,EAEjB,YAAiB,EACjB,OAAO,EACP,SAAS,EACT,SAAS,EACT,kBAAkB,EAClB,eAAe,EACf,eAAoB,EACpB,cAAc,EAAE,qBAAqB,EACrC,KAAK,EAAE,eAAe,EACtB,aAAa,EACb,eAAsB,EACtB,UAAU,EACV,QAAQ,EACR,OAAO,EACP,SAAS,EACT,UAAU,EAAE,+CAA+C;AAC3D,kBAAkB,GACnB,GAAE,eAAoB,GAAG,cAAc,CAkvDvC"}
1
+ {"version":3,"file":"useAgent.d.ts","sourceRoot":"","sources":["../../src/lib/useAgent.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EAKf,MAAM,oBAAoB,CAAC;AA8X5B,wBAAgB,QAAQ,CAAC,EACvB,UAAU,EAAE,aAAwC,EACpD,aAAmC,EACnC,WAAW,EAAE,aAAa,EAC1B,cAAsB,EACtB,IAAI,EACJ,KAAU,EACV,SAAc,EACd,aAAa,EAAE,iBAAiB,EAChC,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,mBAA2B,EAC3B,kBAA0B,EAC1B,QAAiB,EAEjB,YAAiB,EACjB,OAAO,EACP,SAAS,EACT,SAAS,EACT,kBAAkB,EAClB,eAAe,EACf,eAAoB,EACpB,cAAc,EAAE,qBAAqB,EACrC,KAAK,EAAE,eAAe,EACtB,aAAa,EACb,eAAsB,EACtB,UAAU,EACV,QAAQ,EACR,OAAO,EACP,SAAS,EACT,UAAU,EAAE,+CAA+C;AAC3D,kBAAkB,GACnB,GAAE,eAAoB,GAAG,cAAc,CAuvDvC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcteninc/core",
3
- "version": "0.0.161",
3
+ "version": "0.0.162",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",